1
- import { trans } from " i18n" ;
2
- import { green , red , yellow } from " @ant-design/colors/es" ;
3
- import { FormItemProps } from " antd/es/form/FormItem" ;
4
- import { BoolControl } from " comps/controls/boolControl" ;
5
- import { NumberControl , StringControl } from " comps/controls/codeControl" ;
6
- import { dropdownControl } from " comps/controls/dropdownControl" ;
7
- import { withDefault } from " comps/generators" ;
8
- import { MultiCompBuilder } from " comps/generators/multi" ;
9
- import { labelCss , Section , Tooltip , UnderlineCss } from " lowcoder-design" ;
10
- import { ValueFromOption } from " lowcoder-design" ;
11
- import { isEmpty } from " lodash" ;
12
- import { Fragment , ReactNode } from " react" ;
13
- import styled , { css } from " styled-components" ;
14
- import { AlignLeft } from " lowcoder-design" ;
15
- import { AlignRight } from " lowcoder-design" ;
16
- import { StarIcon } from " lowcoder-design" ;
1
+ import { trans } from ' i18n' ;
2
+ import { green , red , yellow } from ' @ant-design/colors/es' ;
3
+ import { FormItemProps } from ' antd/es/form/FormItem' ;
4
+ import { BoolControl } from ' comps/controls/boolControl' ;
5
+ import { NumberControl , StringControl } from ' comps/controls/codeControl' ;
6
+ import { dropdownControl } from ' comps/controls/dropdownControl' ;
7
+ import { withDefault } from ' comps/generators' ;
8
+ import { MultiCompBuilder } from ' comps/generators/multi' ;
9
+ import { labelCss , Section , Tooltip , UnderlineCss } from ' lowcoder-design' ;
10
+ import { ValueFromOption } from ' lowcoder-design' ;
11
+ import { isEmpty } from ' lodash' ;
12
+ import { Fragment , ReactNode } from ' react' ;
13
+ import styled , { css } from ' styled-components' ;
14
+ import { AlignLeft } from ' lowcoder-design' ;
15
+ import { AlignRight } from ' lowcoder-design' ;
16
+ import { StarIcon } from ' lowcoder-design' ;
17
17
18
18
import {
19
19
LabelStyleType ,
20
20
heightCalculator ,
21
21
widthCalculator ,
22
- } from " ./styleControlConstants" ;
22
+ } from ' ./styleControlConstants' ;
23
23
24
24
type LabelViewProps = Pick <
25
25
FormItemProps ,
26
- " required" | " help" | " validateStatus"
26
+ ' required' | ' help' | ' validateStatus'
27
27
> & {
28
28
children : ReactNode ;
29
29
style ?: Record < string , string > ;
@@ -51,7 +51,7 @@ function getStyle(style: any) {
51
51
` ;
52
52
}
53
53
54
- const LabelViewWrapper = styled . div < { $style : any ; inputFieldStyle : any } > `
54
+ const LabelViewWrapper = styled . div < { $style : any ; inputFieldStyle : any } > `
55
55
${ ( props ) => {
56
56
return (
57
57
props . $style && {
@@ -74,13 +74,13 @@ const MainWrapper = styled.div<{
74
74
flex-grow: 1;
75
75
width: 100%;
76
76
margin-top: ${ ( props ) =>
77
- props . $position === " column" && props . $hasLabel ? " 4px" : 0 } ;
77
+ props . $position === ' column' && props . $hasLabel ? ' 4px' : 0 } ;
78
78
height: ${ ( props ) =>
79
- props . $position === " column" && props . $hasLabel
80
- ? " calc(100% - 4px)"
81
- : " 100%" } ;
79
+ props . $position === ' column' && props . $hasLabel
80
+ ? ' calc(100% - 4px)'
81
+ : ' 100%' } ;
82
82
display: flex;
83
- align-items: ${ ( props ) => ( props . $position === " row" ? " center" : " start" ) } ;
83
+ align-items: ${ ( props ) => ( props . $position === ' row' ? ' center' : ' start' ) } ;
84
84
flex-shrink: 0;
85
85
` ;
86
86
@@ -92,9 +92,9 @@ const LabelWrapper = styled.div<{
92
92
display: flex;
93
93
align-items: center;
94
94
margin-right: 8px;
95
- margin-bottom: ${ ( props ) => ( props . $position === " row" ? 0 : " 3.5px" ) } ;
96
- justify-content: ${ ( props ) => ( props . $align === " left" ? " start" : " end" ) } ;
97
- max-width: ${ ( props ) => ( props . $position === " row" ? " 80%" : " 100%" ) } ;
95
+ margin-bottom: ${ ( props ) => ( props . $position === ' row' ? 0 : ' 3.5px' ) } ;
96
+ justify-content: ${ ( props ) => ( props . $align === ' left' ? ' start' : ' end' ) } ;
97
+ max-width: ${ ( props ) => ( props . $position === ' row' ? ' 80%' : ' 100%' ) } ;
98
98
flex-shrink: 0;
99
99
` ;
100
100
// ${(props) => props.$border && UnderlineCss};
@@ -103,7 +103,7 @@ const LabelWrapper = styled.div<{
103
103
const Label = styled . span < {
104
104
$border : boolean ;
105
105
$labelStyle : LabelStyleType ;
106
- $validateStatus : " success" | " warning" | " error" | " validating" | null ;
106
+ $validateStatus : ' success' | ' warning' | ' error' | ' validating' | null ;
107
107
} > `
108
108
${ labelCss } ;
109
109
font-family: ${ ( props ) => props . $labelStyle . fontFamily } ;
@@ -113,11 +113,11 @@ const Label = styled.span<{
113
113
text-decoration: ${ ( props ) => props . $labelStyle . textDecoration } ;
114
114
font-size: ${ ( props ) => props . $labelStyle . textSize } ;
115
115
color: ${ ( props ) =>
116
- ! ! props . $validateStatus && props ?. $validateStatus === " error"
116
+ ! ! props . $validateStatus && props ?. $validateStatus === ' error'
117
117
? props . $labelStyle . validate
118
118
: props . $labelStyle . label } !important;
119
119
${ ( props ) =>
120
- `border:${ props . $labelStyle . borderWidth } ${ props . $labelStyle . borderStyle } ${ ! ! props . $validateStatus && props ?. $validateStatus === " error" ? props . $labelStyle . validate : props . $labelStyle . border } ;` }
120
+ `border:${ props . $labelStyle . borderWidth } ${ props . $labelStyle . borderStyle } ${ ! ! props . $validateStatus && props ?. $validateStatus === ' error' ? props . $labelStyle . validate : props . $labelStyle . border } ;` }
121
121
border-radius:${ ( props ) => props . $labelStyle . radius } ;
122
122
padding: ${ ( props ) => props . $labelStyle . padding } ;
123
123
margin: ${ ( props ) => props . $labelStyle . margin } ;
@@ -153,38 +153,38 @@ const TooltipWrapper = styled.span`
153
153
` ;
154
154
155
155
const PositionOptions = [
156
- { label : trans ( " labelProp.left" ) , value : " row" } ,
157
- { label : trans ( " labelProp.top" ) , value : " column" } ,
156
+ { label : trans ( ' labelProp.left' ) , value : ' row' } ,
157
+ { label : trans ( ' labelProp.top' ) , value : ' column' } ,
158
158
] as const ;
159
159
type PositionOptionsValue = ValueFromOption < typeof PositionOptions > ;
160
160
161
161
const AlignOptions = [
162
- { label : < AlignLeft /> , value : " left" } ,
163
- { label : < AlignRight /> , value : " right" } ,
162
+ { label : < AlignLeft /> , value : ' left' } ,
163
+ { label : < AlignRight /> , value : ' right' } ,
164
164
] as const ;
165
165
type AlignOptionsValue = ValueFromOption < typeof AlignOptions > ;
166
166
167
167
const WidthUnitOptions = [
168
- { label : "px" , value : "px" } ,
169
- { label : "%" , value : "%" } ,
168
+ { label : 'px' , value : 'px' } ,
169
+ { label : '%' , value : '%' } ,
170
170
] ;
171
171
172
172
function getLabelWidth ( width : number , widthUnit : string ) : string {
173
173
if ( width <= 0 || isNaN ( width ) ) {
174
- return "0%" ;
174
+ return '0%' ;
175
175
}
176
176
return width + widthUnit ;
177
177
}
178
178
179
179
export const LabelControl = ( function ( ) {
180
180
const childrenMap = {
181
- text : withDefault ( StringControl , trans ( " label" ) ) ,
181
+ text : withDefault ( StringControl , trans ( ' label' ) ) ,
182
182
tooltip : StringControl ,
183
183
hidden : BoolControl ,
184
184
width : withDefault ( NumberControl , 33 ) ,
185
- widthUnit : dropdownControl ( WidthUnitOptions , "%" ) ,
186
- position : dropdownControl ( PositionOptions , " row" ) ,
187
- align : dropdownControl ( AlignOptions , " left" ) ,
185
+ widthUnit : dropdownControl ( WidthUnitOptions , '%' ) ,
186
+ position : dropdownControl ( PositionOptions , ' row' ) ,
187
+ align : dropdownControl ( AlignOptions , ' left' ) ,
188
188
} ;
189
189
190
190
return new MultiCompBuilder (
@@ -194,7 +194,6 @@ export const LabelControl = (function () {
194
194
< LabelViewWrapper
195
195
$style = { args . style }
196
196
inputFieldStyle = { args . inputFieldStyle }
197
- className = "animate__animated animate__rubberBand animate__delay-2s"
198
197
>
199
198
< MainWrapper
200
199
$position = { props . position }
@@ -208,12 +207,12 @@ export const LabelControl = (function () {
208
207
width : widthCalculator (
209
208
args && args . inputFieldStyle
210
209
? args ?. inputFieldStyle ?. margin
211
- : " 0px"
210
+ : ' 0px'
212
211
) ,
213
212
height : heightCalculator (
214
213
args && args . inputFieldStyle
215
214
? args ?. inputFieldStyle ?. margin
216
- : " 0px"
215
+ : ' 0px'
217
216
) ,
218
217
} }
219
218
>
@@ -222,11 +221,11 @@ export const LabelControl = (function () {
222
221
$align = { props . align }
223
222
style = { {
224
223
width :
225
- props . position === " row"
224
+ props . position === ' row'
226
225
? getLabelWidth ( props . width , props . widthUnit )
227
- : " 100%" ,
228
- maxWidth : props . position === " row" ? " 70%" : " 100%" ,
229
- fontSize : args && args . style ? args ?. style ?. textSize : " 14px" ,
226
+ : ' 100%' ,
227
+ maxWidth : props . position === ' row' ? ' 70%' : ' 100%' ,
228
+ fontSize : args && args . style ? args ?. style ?. textSize : ' 14px' ,
230
229
} }
231
230
$position = { props . position }
232
231
$hasToolTip = { ! ! props . tooltip }
@@ -243,15 +242,15 @@ export const LabelControl = (function () {
243
242
placement = "top"
244
243
color = "#2c2c2c"
245
244
getPopupContainer = { ( node : any ) =>
246
- node . closest ( " .react-grid-item" )
245
+ node . closest ( ' .react-grid-item' )
247
246
}
248
247
>
249
248
< Label
250
249
$border = { ! ! props . tooltip }
251
250
$validateStatus = {
252
251
args && args . validateStatus ? args . validateStatus : null
253
252
}
254
- $labelStyle = { { ...args . labelStyle } }
253
+ $labelStyle = { { ...args . labelStyle } }
255
254
>
256
255
{ props . text }
257
256
</ Label >
@@ -262,13 +261,13 @@ export const LabelControl = (function () {
262
261
< ChildrenWrapper
263
262
style = { {
264
263
width :
265
- props . position === " row"
264
+ props . position === ' row'
266
265
? `calc(100% - ${ getLabelWidth ( props . width , props . widthUnit ) } - 8px)`
267
- : " 100%" ,
266
+ : ' 100%' ,
268
267
height :
269
- props . position === " column" && ! ! props . text
270
- ? " calc(100% - 22px)"
271
- : " 100%" ,
268
+ props . position === ' column' && ! ! props . text
269
+ ? ' calc(100% - 22px)'
270
+ : ' 100%' ,
272
271
} }
273
272
>
274
273
{ args . children }
@@ -278,16 +277,16 @@ export const LabelControl = (function () {
278
277
{ args . help && (
279
278
< HelpWrapper
280
279
$marginLeft = {
281
- props . position === " column" ||
280
+ props . position === ' column' ||
282
281
isEmpty ( props . text ) ||
283
282
props . hidden
284
- ? "0"
283
+ ? '0'
285
284
: `calc(min(${ getLabelWidth ( props . width , props . widthUnit ) } , 70%) + 8px)`
286
285
}
287
286
$color = {
288
- args . validateStatus === " error"
287
+ args . validateStatus === ' error'
289
288
? red . primary
290
- : args . validateStatus === " warning"
289
+ : args . validateStatus === ' warning'
291
290
? yellow . primary
292
291
: green . primary
293
292
}
@@ -300,21 +299,21 @@ export const LabelControl = (function () {
300
299
}
301
300
)
302
301
. setPropertyViewFn ( ( children ) => (
303
- < Section name = { trans ( " label" ) } >
304
- { children . text . propertyView ( { label : trans ( " labelProp.text" ) } ) }
305
- { children . tooltip . propertyView ( { label : trans ( " labelProp.tooltip" ) } ) }
302
+ < Section name = { trans ( ' label' ) } >
303
+ { children . text . propertyView ( { label : trans ( ' labelProp.text' ) } ) }
304
+ { children . tooltip . propertyView ( { label : trans ( ' labelProp.tooltip' ) } ) }
306
305
{ children . position . propertyView ( {
307
- label : trans ( " labelProp.position" ) ,
306
+ label : trans ( ' labelProp.position' ) ,
308
307
radioButton : true ,
309
308
} ) }
310
309
{ children . align . propertyView ( {
311
- label : trans ( " labelProp.align" ) ,
310
+ label : trans ( ' labelProp.align' ) ,
312
311
radioButton : true ,
313
312
} ) }
314
- { children . position . getView ( ) !== " column" &&
313
+ { children . position . getView ( ) !== ' column' &&
315
314
children . width . propertyView ( {
316
- label : trans ( " labelProp.width" ) ,
317
- tooltip : trans ( " labelProp.widthTooltip" ) ,
315
+ label : trans ( ' labelProp.width' ) ,
316
+ tooltip : trans ( ' labelProp.widthTooltip' ) ,
318
317
lastNode : children . widthUnit . propertyView ( { } ) ,
319
318
} ) }
320
319
</ Section >
0 commit comments