1
- import React , { useEffect , useState } from " react" ;
2
- import { Input , Section , sectionNames } from " lowcoder-design" ;
3
- import { BoolControl } from " comps/controls/boolControl" ;
4
- import { styleControl } from " comps/controls/styleControl" ;
1
+ import React , { useEffect , useState } from ' react' ;
2
+ import { Input , Section , sectionNames } from ' lowcoder-design' ;
3
+ import { BoolControl } from ' comps/controls/boolControl' ;
4
+ import { styleControl } from ' comps/controls/styleControl' ;
5
5
import {
6
6
InputFieldStyle ,
7
7
InputLikeStyle ,
8
8
InputLikeStyleType ,
9
9
LabelStyle ,
10
- } from " comps/controls/styleControlConstants" ;
10
+ } from ' comps/controls/styleControlConstants' ;
11
11
import {
12
12
NameConfig ,
13
13
NameConfigPlaceHolder ,
14
14
NameConfigRequired ,
15
15
withExposingConfigs ,
16
- } from " comps/generators/withExposing" ;
17
- import styled , { css } from " styled-components" ;
18
- import { UICompBuilder } from " ../../generators" ;
19
- import { FormDataPropertyView } from " ../formComp/formDataConstants" ;
20
- import { jsonControl } from " comps/controls/codeControl" ;
21
- import { dropdownControl } from " comps/controls/dropdownControl" ;
16
+ } from ' comps/generators/withExposing' ;
17
+ import styled , { css } from ' styled-components' ;
18
+ import { UICompBuilder } from ' ../../generators' ;
19
+ import { FormDataPropertyView } from ' ../formComp/formDataConstants' ;
20
+ import { jsonControl } from ' comps/controls/codeControl' ;
21
+ import { dropdownControl } from ' comps/controls/dropdownControl' ;
22
22
import {
23
23
getStyle ,
24
24
TextInputBasicSection ,
@@ -27,23 +27,21 @@ import {
27
27
TextInputInteractionSection ,
28
28
textInputValidate ,
29
29
TextInputValidationSection ,
30
- } from " ../textInputComp/textInputConstants" ;
30
+ } from ' ../textInputComp/textInputConstants' ;
31
31
import {
32
32
allowClearPropertyView ,
33
33
hiddenPropertyView ,
34
- } from "comps/utils/propertyUtils" ;
35
- import { trans } from "i18n" ;
36
- import { IconControl } from "comps/controls/iconControl" ;
37
- import { hasIcon } from "comps/utils" ;
38
- import { InputRef } from "antd/es/input" ;
39
- import { default as ConfigProvider } from "antd/es/config-provider" ;
40
- import { default as AutoComplete } from "antd/es/auto-complete" ;
41
- import { RefControl } from "comps/controls/refControl" ;
42
- import {
43
- booleanExposingStateControl ,
44
- } from "comps/controls/codeStateControl" ;
34
+ } from 'comps/utils/propertyUtils' ;
35
+ import { trans } from 'i18n' ;
36
+ import { IconControl } from 'comps/controls/iconControl' ;
37
+ import { hasIcon } from 'comps/utils' ;
38
+ import { InputRef } from 'antd/es/input' ;
39
+ import { default as ConfigProvider } from 'antd/es/config-provider' ;
40
+ import { default as AutoComplete } from 'antd/es/auto-complete' ;
41
+ import { RefControl } from 'comps/controls/refControl' ;
42
+ import { booleanExposingStateControl } from 'comps/controls/codeStateControl' ;
45
43
46
- import { getDayJSLocale } from " i18n/dayjsLocale" ;
44
+ import { getDayJSLocale } from ' i18n/dayjsLocale' ;
47
45
import {
48
46
autoCompleteDate ,
49
47
itemsDataTooltip ,
@@ -53,51 +51,51 @@ import {
53
51
autoCompleteType ,
54
52
autocompleteIconColor ,
55
53
componentSize ,
56
- } from "./autoCompleteConstants" ;
57
-
58
-
54
+ } from './autoCompleteConstants' ;
59
55
60
- const InputStyle = styled ( Input ) < { $style : InputLikeStyleType } > `
61
- ${ ( props ) => css `
62
- ${ getStyle ( props . $style ) }
63
- input {
64
- padding : ${ props . style ?. padding } ;
65
- }
66
- .ant-select-single {
67
- width : 100% !important ;
68
- }
69
- ` }
56
+ const InputStyle = styled ( Input ) < { $style : InputLikeStyleType } > `
57
+ ${ ( props ) => {
58
+ return css `
59
+ ${ getStyle ( props . $style ) }
60
+ input {
61
+ padding : ${ props . style ?. padding } ;
62
+ rotate : ${ props ?. $style ?. rotation } ;
63
+ }
64
+ .ant-select-single {
65
+ width : 100% !important ;
66
+ }
67
+ ` ;
68
+ } }
70
69
` ;
71
70
72
-
73
71
const childrenMap = {
74
72
...textInputChildren ,
75
73
viewRef : RefControl < InputRef > ,
76
74
allowClear : BoolControl . DEFAULT_TRUE ,
77
75
style : styleControl ( InputFieldStyle ) ,
78
- labelStyle :styleControl ( LabelStyle ) ,
76
+ labelStyle : styleControl ( LabelStyle ) ,
79
77
prefixIcon : IconControl ,
80
78
suffixIcon : IconControl ,
81
79
items : jsonControl ( convertAutoCompleteData , autoCompleteDate ) ,
82
80
ignoreCase : BoolControl . DEFAULT_TRUE ,
83
81
searchFirstPY : BoolControl . DEFAULT_TRUE ,
84
82
searchCompletePY : BoolControl ,
85
83
searchLabelOnly : BoolControl . DEFAULT_TRUE ,
86
- valueOrLabel : dropdownControl ( valueOrLabelOption , " label" ) ,
87
- autoCompleteType : dropdownControl ( autoCompleteType , " normal" ) ,
88
- autocompleteIconColor : dropdownControl ( autocompleteIconColor , " blue" ) ,
89
- componentSize : dropdownControl ( componentSize , " small" ) ,
90
- valueInItems : booleanExposingStateControl ( " valueInItems" ) ,
84
+ valueOrLabel : dropdownControl ( valueOrLabelOption , ' label' ) ,
85
+ autoCompleteType : dropdownControl ( autoCompleteType , ' normal' ) ,
86
+ autocompleteIconColor : dropdownControl ( autocompleteIconColor , ' blue' ) ,
87
+ componentSize : dropdownControl ( componentSize , ' small' ) ,
88
+ valueInItems : booleanExposingStateControl ( ' valueInItems' ) ,
91
89
inputFieldStyle : styleControl ( InputLikeStyle ) ,
92
90
} ;
93
91
94
- const getValidate = ( value : any ) : "" | " warning" | " error" | undefined => {
92
+ const getValidate = ( value : any ) : '' | ' warning' | ' error' | undefined => {
95
93
if (
96
- value . hasOwnProperty ( " validateStatus" ) &&
97
- value [ " validateStatus" ] === " error"
94
+ value . hasOwnProperty ( ' validateStatus' ) &&
95
+ value [ ' validateStatus' ] === ' error'
98
96
)
99
- return " error" ;
100
- return "" ;
97
+ return ' error' ;
98
+ return '' ;
101
99
} ;
102
100
103
101
let AutoCompleteCompBase = ( function ( ) {
@@ -115,11 +113,10 @@ let AutoCompleteCompBase = (function () {
115
113
autocompleteIconColor,
116
114
componentSize,
117
115
} = props ;
118
-
119
116
120
117
const getTextInputValidate = ( ) => {
121
118
return {
122
- value : { value : props . value . value } ,
119
+ value : { value : props . value . value } ,
123
120
required : props . required ,
124
121
minLength : props ?. minLength ?? 0 ,
125
122
maxLength : props ?. maxLength ?? 0 ,
@@ -134,7 +131,7 @@ let AutoCompleteCompBase = (function () {
134
131
const [ validateState , setvalidateState ] = useState ( { } ) ;
135
132
136
133
// 是否中文环境
137
- const [ chineseEnv , setChineseEnv ] = useState ( getDayJSLocale ( ) === " zh-cn" ) ;
134
+ const [ chineseEnv , setChineseEnv ] = useState ( getDayJSLocale ( ) === ' zh-cn' ) ;
138
135
139
136
useEffect ( ( ) => {
140
137
setsearchtext ( props . value . value ) ;
@@ -162,32 +159,32 @@ let AutoCompleteCompBase = (function () {
162
159
borderRadius : parseInt ( props . inputFieldStyle . radius ) ,
163
160
colorText : props . inputFieldStyle . text ,
164
161
colorPrimary : props . inputFieldStyle . accent ,
165
- controlHeight : componentSize === " small" ? 30 : 38 ,
162
+ controlHeight : componentSize === ' small' ? 30 : 38 ,
166
163
} ,
167
164
} }
168
165
>
169
- < AutoComplete
166
+ < AutoComplete
170
167
disabled = { props . disabled }
171
168
value = { searchtext }
172
- options = { items }
173
- style = { { width : " 100%" } }
169
+ options = { items }
170
+ style = { { width : ' 100%' } }
174
171
onChange = { ( value : string , option ) => {
175
172
props . valueInItems . onChange ( false ) ;
176
173
setvalidateState ( textInputValidate ( getTextInputValidate ( ) ) ) ;
177
174
setsearchtext ( value ) ;
178
- props . value . onChange ( value ) ;
179
- props . onEvent ( " change" )
180
- } }
175
+ props . value . onChange ( value ) ;
176
+ props . onEvent ( ' change' ) ;
177
+ } }
181
178
onFocus = { ( ) => {
182
- setActivationFlag ( true )
183
- props . onEvent ( " focus" )
179
+ setActivationFlag ( true ) ;
180
+ props . onEvent ( ' focus' ) ;
184
181
} }
185
- onBlur = { ( ) => props . onEvent ( " blur" ) }
182
+ onBlur = { ( ) => props . onEvent ( ' blur' ) }
186
183
onSelect = { ( data : string , option ) => {
187
184
setsearchtext ( option [ valueOrLabel ] ) ;
188
185
props . valueInItems . onChange ( true ) ;
189
186
props . value . onChange ( option [ valueOrLabel ] ) ;
190
- props . onEvent ( " submit" ) ;
187
+ props . onEvent ( ' submit' ) ;
191
188
} }
192
189
filterOption = { ( inputValue : string , option ) => {
193
190
if ( ignoreCase ) {
@@ -207,7 +204,7 @@ let AutoCompleteCompBase = (function () {
207
204
searchFirstPY &&
208
205
option ?. label &&
209
206
option . label
210
- . spell ( " first" )
207
+ . spell ( ' first' )
211
208
. toString ( )
212
209
. toLowerCase ( )
213
210
. indexOf ( inputValue . toLowerCase ( ) ) >= 0
@@ -245,7 +242,7 @@ let AutoCompleteCompBase = (function () {
245
242
searchFirstPY &&
246
243
option ?. value &&
247
244
option . value
248
- . spell ( " first" )
245
+ . spell ( ' first' )
249
246
. toString ( )
250
247
. toLowerCase ( )
251
248
. indexOf ( inputValue . toLowerCase ( ) ) >= 0
@@ -266,62 +263,62 @@ let AutoCompleteCompBase = (function () {
266
263
return false ;
267
264
} }
268
265
>
269
- < InputStyle
270
- ref = { props . viewRef }
271
- placeholder = { placeholder }
272
- allowClear = { props . allowClear }
273
- $style = { props . inputFieldStyle }
274
- prefix = { hasIcon ( props . prefixIcon ) && props . prefixIcon }
275
- suffix = { hasIcon ( props . suffixIcon ) && props . suffixIcon }
276
- status = { getValidate ( validateState ) }
277
- onPressEnter = { undefined }
278
- />
266
+ < InputStyle
267
+ ref = { props . viewRef }
268
+ placeholder = { placeholder }
269
+ allowClear = { props . allowClear }
270
+ $style = { props . inputFieldStyle }
271
+ prefix = { hasIcon ( props . prefixIcon ) && props . prefixIcon }
272
+ suffix = { hasIcon ( props . suffixIcon ) && props . suffixIcon }
273
+ status = { getValidate ( validateState ) }
274
+ onPressEnter = { undefined }
275
+ />
279
276
</ AutoComplete >
280
277
</ ConfigProvider >
281
278
</ >
282
279
) ,
283
280
style : props . style ,
284
281
labelStyle : props . labelStyle ,
285
- inputFieldStyle :props . inputFieldStyle ,
282
+ inputFieldStyle : props . inputFieldStyle ,
286
283
...validateState ,
287
284
} ) ;
288
285
} )
289
286
. setPropertyViewFn ( ( children ) => {
290
287
return (
291
288
< >
292
289
< Section >
293
- { children . autoCompleteType . getView ( ) === " normal" &&
290
+ { children . autoCompleteType . getView ( ) === ' normal' &&
294
291
children . prefixIcon . propertyView ( {
295
- label : trans ( " button.prefixIcon" ) ,
292
+ label : trans ( ' button.prefixIcon' ) ,
296
293
} ) }
297
- { children . autoCompleteType . getView ( ) === " normal" &&
294
+ { children . autoCompleteType . getView ( ) === ' normal' &&
298
295
children . suffixIcon . propertyView ( {
299
- label : trans ( " button.suffixIcon" ) ,
296
+ label : trans ( ' button.suffixIcon' ) ,
300
297
} ) }
301
- { allowClearPropertyView ( children ) }
298
+ { allowClearPropertyView ( children ) }
302
299
</ Section >
303
- < Section name = { trans ( " autoComplete.SectionDataName" ) } >
300
+ < Section name = { trans ( ' autoComplete.SectionDataName' ) } >
304
301
{ children . items . propertyView ( {
305
- label : trans ( " autoComplete.value" ) ,
302
+ label : trans ( ' autoComplete.value' ) ,
306
303
tooltip : itemsDataTooltip ,
307
- placeholder : "[]" ,
304
+ placeholder : '[]' ,
308
305
} ) }
309
- { getDayJSLocale ( ) === " zh-cn" &&
306
+ { getDayJSLocale ( ) === ' zh-cn' &&
310
307
children . searchFirstPY . propertyView ( {
311
- label : trans ( " autoComplete.searchFirstPY" ) ,
308
+ label : trans ( ' autoComplete.searchFirstPY' ) ,
312
309
} ) }
313
- { getDayJSLocale ( ) === " zh-cn" &&
310
+ { getDayJSLocale ( ) === ' zh-cn' &&
314
311
children . searchCompletePY . propertyView ( {
315
- label : trans ( " autoComplete.searchCompletePY" ) ,
312
+ label : trans ( ' autoComplete.searchCompletePY' ) ,
316
313
} ) }
317
314
{ children . searchLabelOnly . propertyView ( {
318
- label : trans ( " autoComplete.searchLabelOnly" ) ,
315
+ label : trans ( ' autoComplete.searchLabelOnly' ) ,
319
316
} ) }
320
317
{ children . ignoreCase . propertyView ( {
321
- label : trans ( " autoComplete.ignoreCase" ) ,
318
+ label : trans ( ' autoComplete.ignoreCase' ) ,
322
319
} ) }
323
320
{ children . valueOrLabel . propertyView ( {
324
- label : trans ( " autoComplete.checkedValueFrom" ) ,
321
+ label : trans ( ' autoComplete.checkedValueFrom' ) ,
325
322
radioButton : true ,
326
323
} ) }
327
324
</ Section >
@@ -352,8 +349,8 @@ let AutoCompleteCompBase = (function () {
352
349
} )
353
350
. setExposeMethodConfigs ( autoCompleteRefMethods )
354
351
. setExposeStateConfigs ( [
355
- new NameConfig ( " value" , trans ( " export.inputValueDesc" ) ) ,
356
- new NameConfig ( " valueInItems" , trans ( " autoComplete.valueInItems" ) ) ,
352
+ new NameConfig ( ' value' , trans ( ' export.inputValueDesc' ) ) ,
353
+ new NameConfig ( ' valueInItems' , trans ( ' autoComplete.valueInItems' ) ) ,
357
354
NameConfigPlaceHolder ,
358
355
NameConfigRequired ,
359
356
...TextInputConfigs ,
@@ -368,9 +365,9 @@ AutoCompleteCompBase = class extends AutoCompleteCompBase {
368
365
} ;
369
366
370
367
export const AutoCompleteComp = withExposingConfigs ( AutoCompleteCompBase , [
371
- new NameConfig ( " value" , trans ( " export.inputValueDesc" ) ) ,
372
- new NameConfig ( " valueInItems" , trans ( " autoComplete.valueInItems" ) ) ,
368
+ new NameConfig ( ' value' , trans ( ' export.inputValueDesc' ) ) ,
369
+ new NameConfig ( ' valueInItems' , trans ( ' autoComplete.valueInItems' ) ) ,
373
370
NameConfigPlaceHolder ,
374
- NameConfigRequired ,
371
+ NameConfigRequired ,
375
372
...TextInputConfigs ,
376
373
] ) ;
0 commit comments