@@ -3,12 +3,11 @@ import { BoolCodeControl } from "comps/controls/codeControl";
3
3
import { BoolControl } from "comps/controls/boolControl" ;
4
4
import { stringExposingStateControl , numberExposingStateControl } from "comps/controls/codeStateControl" ;
5
5
import { ChangeEventHandlerControl } from "comps/controls/eventHandlerControl" ;
6
- import { LabelControl } from "comps/controls/labelControl" ;
7
6
import { StepOptionControl } from "comps/controls/optionsControl" ;
8
7
import { styleControl } from "comps/controls/styleControl" ;
9
- import { StepsStyle , StepsStyleType } from "comps/controls/styleControlConstants" ;
8
+ import { StepsStyle , StepsStyleType , heightCalculator , widthCalculator , marginCalculator } from "comps/controls/styleControlConstants" ;
10
9
import styled , { css } from "styled-components" ;
11
- import { UICompBuilder , withDefault } from "../../generators" ;
10
+ import { UICompBuilder } from "../../generators" ;
12
11
import { CommonNameConfig , NameConfig , withExposingConfigs } from "../../generators/withExposing" ;
13
12
import { selectDivRefMethods , } from "./selectInputConstants" ;
14
13
import { Section , sectionNames } from "lowcoder-design" ;
@@ -17,7 +16,6 @@ import { trans } from "i18n";
17
16
import { hasIcon } from "comps/utils" ;
18
17
import { RefControl } from "comps/controls/refControl" ;
19
18
import { dropdownControl } from "comps/controls/dropdownControl" ;
20
-
21
19
import { useContext , useState , useEffect } from "react" ;
22
20
import { EditorContext } from "comps/editorState" ;
23
21
@@ -79,14 +77,16 @@ const statusOptions = [
79
77
]
80
78
81
79
const StepsChildrenMap = {
82
- initialValue : numberExposingStateControl ( "0 " ) ,
80
+ initialValue : numberExposingStateControl ( "1 " ) ,
83
81
value : stringExposingStateControl ( "value" ) ,
84
- stepsStatus : stringExposingStateControl ( "process" ) ,
82
+ stepStatus : stringExposingStateControl ( "process" ) ,
83
+ stepPercent : numberExposingStateControl ( "60" ) ,
85
84
size : dropdownControl ( sizeOptions , "default" ) ,
86
85
displayType : dropdownControl ( typeOptions , "default" ) ,
87
86
direction : dropdownControl ( directionOptions , "horizontal" ) ,
88
87
showDots : BoolControl ,
89
88
showIcons : BoolControl ,
89
+ selectable : BoolControl ,
90
90
labelPlacement : dropdownControl ( directionOptions , "horizontal" ) ,
91
91
disabled : BoolCodeControl ,
92
92
onEvent : ChangeEventHandlerControl ,
@@ -98,82 +98,108 @@ const StepsChildrenMap = {
98
98
let StepControlBasicComp = ( function ( ) {
99
99
return new UICompBuilder ( StepsChildrenMap , ( props ) => {
100
100
101
- // enabling user interaction to change the current step
102
- const [ current , setCurrent ] = useState ( 0 ) ;
101
+ const StyledWrapper = styled . div < { style : StepsStyleType } > `
102
+ min-height: 24px;
103
+ max-width: ${ widthCalculator ( props . style . margin ) } ;
104
+ max-height: ${ heightCalculator ( props . style . margin ) } ;
105
+ display: flex;
106
+ flex-direction: column;
107
+ justify-content: center;
108
+ align-items: center;
109
+ text-decoration: ${ props . style . textDecoration } ;
110
+ font-style: ${ props . style . fontStyle } ;
111
+ font-weight: ${ props . style . textWeight } ;
112
+ font-size: ${ props . style . textSize } ;
113
+ text-transform: ${ props . style . textTransform } ;
114
+ margin: ${ props . style . margin } ;
115
+ padding: ${ props . style . padding } ;
116
+ background-color: ${ props . style . background } ;
117
+ border: ${ props . style . borderWidth } solid ${ props . style . border } ;
118
+ border-radius: ${ props . style . radius } ;
119
+ background-image: ${ props . style . backgroundImage } ;
120
+ background-repeat: ${ props . style . backgroundImageRepeat } ;
121
+ background-size: ${ props . style . backgroundImageSize } ;
122
+ background-position: ${ props . style . backgroundImagePosition } ;
123
+ background-origin: ${ props . style . backgroundImageOrigin } ;
124
+ .ant-steps-item { padding-top: 5px !important; }
125
+ .ant-steps.ant-steps-label-vertical.ant-steps-small .ant-steps-item-icon { margin-top: 17px !important; }
126
+ .ant-steps.ant-steps-label-vertical.ant-steps-default .ant-steps-item-icon { margin-top: 12px !important; }
127
+ .ant-steps.ant-steps-dot .ant-steps-item-process .ant-steps-icon .ant-steps-icon-dot { margin-top: 4px !important; }
128
+ .ant-steps.ant-steps-default .ant-steps-item-icon .ant-steps-icon-dot { margin-top: 9px !important; }
129
+ .ant-steps.ant-steps-small .ant-steps-item-icon .ant-steps-icon-dot { margin-top: 4px !important; }
130
+ .ant-steps.ant-steps-dot .ant-steps-item-title { margin-top: 10px !important; }
131
+ .ant-steps.ant-steps-default.ant-steps-with-progress.ant-steps-label-horizontal .ant-steps-item.ant-steps-item-custom div.ant-steps-item-icon { margin-top:4px !important; }
132
+ .ant-steps.ant-steps-default.ant-steps-with-progress.ant-steps-label-vertical .ant-steps-item.ant-steps-item-custom div.ant-steps-item-icon { margin-top:17px !important; }
133
+ .ant-steps.ant-steps-dot.ant-steps-small.ant-steps-with-progress .ant-steps-item-icon .ant-progress { inset-block-start: -8px !important; inset-inline-start: -11px !important; }
134
+ .ant-steps.ant-steps-dot.ant-steps-default.ant-steps-with-progress .ant-steps-item-icon .ant-progress { inset-block-start: -7px !important; inset-inline-start: -13px !important; }
135
+ .ant-steps.ant-steps-small.ant-steps-with-progress .ant-steps-item:not(.ant-steps-item-custom) .ant-progress { inset-block-start: -5px !important; inset-inline-start: -5px !important; }
136
+ .ant-steps.ant-steps-default.ant-steps-with-progress .ant-steps-item:not(.ant-steps-item-custom) .ant-progress { inset-block-start: -5px !important; inset-inline-start: -5px !important; }
137
+ .ant-steps.ant-steps-small.ant-steps-with-progress .ant-steps-item.ant-steps-item-custom .ant-progress { inset-block-start: -5px !important; inset-inline-start: -10px !important; }
138
+ .ant-steps.ant-steps-default.ant-steps-with-progress .ant-steps-item.ant-steps-item-custom .ant-progress { inset-block-start: -4px !important; inset-inline-start: -13px !important; }
139
+ ` ;
140
+
141
+ const [ current , setCurrent ] = useState ( props . initialValue . value - 1 ) ; // Convert 1-based index to 0-based.
103
142
104
- // updating the state of current by the expose value
105
143
useEffect ( ( ) => {
106
- setCurrent ( Number ( props . value . value ) ) ;
144
+ const newValue = Number ( props . value . value ) ;
145
+ setCurrent ( newValue - 1 ) ; // Adjust for 0-based index.
107
146
} , [ props . value . value ] ) ;
108
147
109
-
110
- const onChange = ( current : number ) => {
111
- setCurrent ( current ) ;
112
- if ( props . options [ current ] ?. value !== undefined ) {
113
- props . value . onChange ( props . options [ current ] . value + "" ) ;
148
+ const onChange = ( index : number ) => {
149
+ if ( props . selectable == false ) return ;
150
+ const newIndex = Math . max ( 0 , index ) ;
151
+ setCurrent ( newIndex ) ;
152
+ if ( props . options [ newIndex ] ?. value !== undefined ) {
153
+ props . value . onChange ( newIndex + 1 + "" ) ; // Convert back to 1-based index for display.
114
154
props . onEvent ( "change" ) ;
115
155
}
116
156
} ;
117
157
118
- // margin-top: 17px; is important cause the dots where placed wrong.
119
- /*
120
- .ant-steps.ant-steps-small .ant-steps-item-icon {
121
- margin-top: 17px;
122
- }
123
- */
124
- const StepsWrapper = styled . div `
125
- width: 100%;
126
- min-height: 24px;
127
-
128
- ` ;
129
-
130
158
return (
131
- < StepsWrapper ref = { props . viewRef } >
132
159
< ConfigProvider
133
160
theme = { {
134
- components : {
135
- Steps : {
136
- colorPrimary : '#00b96b' ,
137
- algorithm : true ,
138
- }
139
- } ,
161
+ token : {
162
+ colorPrimary : props . style . activeBackground ,
163
+ colorText : props . style . titleText ,
164
+ colorTextDescription : props . style . text ,
165
+ fontFamily : props . style . fontFamily ,
166
+ }
140
167
} }
141
168
>
142
- < Steps
143
- initial = { Number ( props . initialValue . value ) - 1 }
144
- current = { current }
145
- onChange = { ( current ) => {
146
- onChange ( current ) ;
147
- } }
148
- percent = { 60 }
149
- status = { props . stepsStatus . value as "error" | "finish" | "process" | "wait" }
150
- type = { props . displayType }
151
- size = { props . size }
152
- labelPlacement = { props . labelPlacement }
153
- progressDot = { props . showDots }
154
- direction = { props . direction }
155
- >
156
- { props . options . map ( ( option , index ) => (
157
- < Steps . Step
158
- key = { index }
159
- title = { option . label }
160
- subTitle = { option . subTitle }
161
- description = { option . description }
162
- status = { option . status as "error" | "finish" | "wait" | "process" | undefined }
163
- icon = { props . showIcons && hasIcon ( option . icon ) && option . icon || undefined }
164
- />
165
- ) ) }
166
- </ Steps >
169
+ < StyledWrapper style = { props . style } >
170
+ < Steps
171
+ initial = { props . initialValue . value - 1 }
172
+ current = { current }
173
+ onChange = { onChange }
174
+ percent = { props . stepPercent . value }
175
+ status = { props . stepStatus . value as "error" | "finish" | "process" | "wait" }
176
+ type = { props . displayType }
177
+ size = { props . size }
178
+ labelPlacement = { props . labelPlacement }
179
+ progressDot = { props . showDots }
180
+ direction = { props . direction }
181
+ >
182
+ { props . options . map ( ( option , index ) => (
183
+ < Steps . Step
184
+ key = { index }
185
+ title = { option . label }
186
+ subTitle = { option . subTitle }
187
+ description = { option . description }
188
+ status = { option . status as "error" | "finish" | "wait" | "process" | undefined }
189
+ icon = { props . showIcons && hasIcon ( option . icon ) && option . icon | | undefined }
190
+ />
191
+ ) ) }
192
+ </ Steps >
193
+ </ StyledWrapper >
167
194
</ ConfigProvider >
168
- </ StepsWrapper >
169
195
) ;
170
196
171
197
} )
172
198
. setPropertyViewFn ( ( children ) => (
173
199
< >
174
200
< Section name = { sectionNames . basic } >
175
201
{ children . options . propertyView ( { } ) }
176
- { children . initialValue . propertyView ( { label : trans ( "step.initialValue" ) } ) }
202
+ { children . initialValue . propertyView ( { label : trans ( "step.initialValue" ) , tooltip : trans ( "step.initialValueTooltip" ) } ) }
177
203
</ Section >
178
204
179
205
{ [ "logic" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
@@ -182,7 +208,9 @@ let StepControlBasicComp = (function () {
182
208
{ children . onEvent . getPropertyView ( ) }
183
209
{ disabledPropertyView ( children ) }
184
210
{ hiddenPropertyView ( children ) }
185
- { children . stepsStatus . propertyView ( { label : trans ( "step.status" ) } ) }
211
+ { children . stepStatus . propertyView ( { label : trans ( "step.status" ) } ) }
212
+ { children . stepPercent . propertyView ( { label : trans ( "step.percent" ) } ) }
213
+ { children . selectable . propertyView ( { label : trans ( "step.selectable" ) } ) }
186
214
</ Section > </ >
187
215
) }
188
216
@@ -200,12 +228,18 @@ let StepControlBasicComp = (function () {
200
228
label : trans ( "step.direction" ) ,
201
229
radioButton : true ,
202
230
} ) }
203
- { children . labelPlacement . propertyView ( {
204
- label : trans ( "step.labelPlacement" ) ,
205
- radioButton : true ,
206
- } ) }
207
- { children . showDots . propertyView ( { label : trans ( "step.showDots" ) } ) }
208
- { children . showIcons . propertyView ( { label : trans ( "step.showIcons" ) } ) }
231
+ { children . direction . getView ( ) == "horizontal" &&
232
+ children . labelPlacement . propertyView ( {
233
+ label : trans ( "step.labelPlacement" ) ,
234
+ radioButton : true ,
235
+ } )
236
+ }
237
+ { children . displayType . getView ( ) != "inline" && ! children . showIcons . getView ( ) && (
238
+ children . showDots . propertyView ( { label : trans ( "step.showDots" ) }
239
+ ) ) }
240
+ { children . displayType . getView ( ) != "inline" && ! children . showDots . getView ( ) && (
241
+ children . showIcons . propertyView ( { label : trans ( "step.showIcons" ) }
242
+ ) ) }
209
243
</ Section >
210
244
) }
211
245
@@ -222,5 +256,7 @@ let StepControlBasicComp = (function () {
222
256
223
257
export const StepComp = withExposingConfigs ( StepControlBasicComp , [
224
258
new NameConfig ( "value" , trans ( "step.valueDesc" ) ) ,
259
+ new NameConfig ( "stepStatus" , trans ( "step.status" ) ) ,
260
+ new NameConfig ( "stepPercent" , trans ( "step.percent" ) ) ,
225
261
...CommonNameConfig ,
226
262
] ) ;
0 commit comments