1
- import { useState , useEffect } from ' react' ;
1
+ import { useState , useEffect } from " react" ;
2
2
import {
3
3
NameConfig ,
4
4
NameConfigPlaceHolder ,
5
5
NameConfigRequired ,
6
6
withExposingConfigs ,
7
- } from ' comps/generators/withExposing' ;
8
- import { Section , sectionNames } from ' lowcoder-design' ;
9
- import { BoolControl } from ' ../../controls/boolControl' ;
10
- import { AutoHeightControl } from ' ../../controls/autoHeightControl' ;
11
- import { UICompBuilder } from ' ../../generators' ;
12
- import { FormDataPropertyView } from ' ../formComp/formDataConstants' ;
7
+ } from " comps/generators/withExposing" ;
8
+ import { Section , sectionNames } from " lowcoder-design" ;
9
+ import { BoolControl } from " ../../controls/boolControl" ;
10
+ import { AutoHeightControl } from " ../../controls/autoHeightControl" ;
11
+ import { UICompBuilder } from " ../../generators" ;
12
+ import { FormDataPropertyView } from " ../formComp/formDataConstants" ;
13
13
import {
14
14
checkMentionListData ,
15
15
fixOldInputCompData ,
16
16
textInputChildren ,
17
- } from ' ./textInputConstants' ;
17
+ } from " ./textInputConstants" ;
18
18
import {
19
19
withMethodExposing ,
20
20
refMethods ,
21
- } from ' ../../generators/withMethodExposing' ;
22
- import { styleControl } from ' comps/controls/styleControl' ;
23
- import styled from ' styled-components' ;
21
+ } from " ../../generators/withMethodExposing" ;
22
+ import { styleControl } from " comps/controls/styleControl" ;
23
+ import styled from " styled-components" ;
24
24
import {
25
25
AnimationStyle ,
26
26
InputLikeStyle ,
27
27
InputLikeStyleType ,
28
- } from ' comps/controls/styleControlConstants' ;
28
+ } from " comps/controls/styleControlConstants" ;
29
29
import {
30
30
disabledPropertyView ,
31
31
hiddenPropertyView ,
32
32
maxLengthPropertyView ,
33
33
minLengthPropertyView ,
34
34
readOnlyPropertyView ,
35
35
requiredPropertyView ,
36
- } from 'comps/utils/propertyUtils' ;
37
- import { booleanExposingStateControl } from 'comps/controls/codeStateControl' ;
38
- import { trans } from 'i18n' ;
39
- import { RefControl } from 'comps/controls/refControl' ;
40
- import { TextAreaRef } from 'antd/es/input/TextArea' ;
41
- import { default as ConfigProvider } from 'antd/es/config-provider' ;
42
- import { default as Mentions , type MentionsOptionProps } from 'antd/es/mentions' ;
43
- import { blurMethod , focusWithOptions } from 'comps/utils/methodUtils' ;
44
- import { textInputValidate } from '../textInputComp/textInputConstants' ;
45
- import { jsonControl } from 'comps/controls/codeControl' ;
36
+ } from "comps/utils/propertyUtils" ;
37
+ import { booleanExposingStateControl } from "comps/controls/codeStateControl" ;
38
+ import { trans } from "i18n" ;
39
+ import { RefControl } from "comps/controls/refControl" ;
40
+ import { TextAreaRef } from "antd/es/input/TextArea" ;
41
+ import { default as ConfigProvider } from "antd/es/config-provider" ;
42
+ import { default as Mentions , type MentionsOptionProps } from "antd/es/mentions" ;
43
+ import { blurMethod , focusWithOptions } from "comps/utils/methodUtils" ;
44
+ import {
45
+ textInputValidate ,
46
+ } from "../textInputComp/textInputConstants" ;
47
+ import { jsonControl } from "comps/controls/codeControl" ;
46
48
import {
47
49
submitEvent ,
48
50
eventHandlerControl ,
49
51
mentionEvent ,
50
52
focusEvent ,
51
53
blurEvent ,
52
- changeEvent ,
53
- } from ' comps/controls/eventHandlerControl' ;
54
+ changeEvent
55
+ } from " comps/controls/eventHandlerControl" ;
54
56
55
- import React , { useContext } from ' react' ;
56
- import { EditorContext } from ' comps/editorState' ;
57
- import { migrateOldData } from ' comps/generators/simpleGenerators' ;
57
+ import React , { useContext } from " react" ;
58
+ import { EditorContext } from " comps/editorState" ;
59
+ import { migrateOldData } from " comps/generators/simpleGenerators" ;
58
60
59
61
const Wrapper = styled . div < {
60
62
$style : InputLikeStyleType ;
61
63
} > `
62
- box-sizing: border-box;
64
+ box-sizing:border-box;
63
65
.rc-textarea {
64
- background-color: ${ ( props ) => props . $style . background } ;
65
- padding: ${ ( props ) => props . $style . padding } ;
66
- text-transform: ${ ( props ) => props . $style . textTransform } ;
67
- text-decoration: ${ ( props ) => props . $style . textDecoration } ;
66
+ background-color:${ ( props ) => props . $style . background } ;
67
+ padding:${ ( props ) => props . $style . padding } ;
68
+ text-transform:${ ( props ) => props . $style . textTransform } ;
69
+ text-decoration:${ ( props ) => props . $style . textDecoration } ;
68
70
margin: 0px 3px 0px 3px !important;
69
71
}
70
72
@@ -105,42 +107,42 @@ let MentionTmpComp = (function () {
105
107
} ;
106
108
107
109
return new UICompBuilder ( childrenMap , ( props ) => {
108
- const { mentionList} = props ;
110
+ const { mentionList } = props ;
109
111
const [ validateState , setvalidateState ] = useState ( { } ) ;
110
112
const [ activationFlag , setActivationFlag ] = useState ( false ) ;
111
- const [ prefix , setPrefix ] = useState < PrefixType > ( '@' ) ;
112
- type PrefixType = '@' | keyof typeof mentionList ;
113
+ const [ prefix , setPrefix ] = useState < PrefixType > ( "@" ) ;
114
+ type PrefixType = "@" | keyof typeof mentionList ;
113
115
114
116
const onSearch = ( _ : string , newPrefix : PrefixType ) => {
115
117
setPrefix ( newPrefix ) ;
116
118
} ;
117
119
const onChange = ( value : string ) => {
118
120
props . value . onChange ( value ) ;
119
- props . onEvent ( ' change' ) ;
121
+ props . onEvent ( " change" ) ;
120
122
} ;
121
123
122
124
const onPressEnter = ( e : any ) => {
123
125
if ( e . shiftKey ) {
124
126
e . preventDefault ( ) ;
125
- props . onEvent ( ' submit' ) ;
127
+ props . onEvent ( " submit" ) ;
126
128
}
127
129
} ;
128
130
129
131
const onSelect = ( option : MentionsOptionProps ) => {
130
- props . onEvent ( ' mention' ) ;
132
+ props . onEvent ( " mention" ) ;
131
133
} ;
132
- const getValidate = ( value : any ) : '' | ' warning' | ' error' | undefined => {
134
+ const getValidate = ( value : any ) : "" | " warning" | " error" | undefined => {
133
135
if (
134
- value . hasOwnProperty ( ' validateStatus' ) &&
135
- value [ ' validateStatus' ] === ' error'
136
+ value . hasOwnProperty ( " validateStatus" ) &&
137
+ value [ " validateStatus" ] === " error"
136
138
)
137
- return ' error' ;
138
- return '' ;
139
+ return " error" ;
140
+ return "" ;
139
141
} ;
140
142
141
143
const getTextInputValidate = ( ) => {
142
144
return {
143
- value : { value : props . value . value } ,
145
+ value : { value : props . value . value } ,
144
146
required : props . required ,
145
147
minLength : props ?. minLength ?? 0 ,
146
148
maxLength : props ?. maxLength ?? 0 ,
@@ -154,7 +156,7 @@ let MentionTmpComp = (function () {
154
156
if ( activationFlag ) {
155
157
const temp = textInputValidate ( getTextInputValidate ( ) ) ;
156
158
setvalidateState ( temp ) ;
157
- props . invalid . onChange ( temp . validateStatus !== '' ) ;
159
+ props . invalid . onChange ( temp . validateStatus !== "" ) ;
158
160
}
159
161
} , [
160
162
props . value . value ,
@@ -184,9 +186,9 @@ let MentionTmpComp = (function () {
184
186
prefix = { Object . keys ( mentionList ) }
185
187
onFocus = { ( ) => {
186
188
setActivationFlag ( true ) ;
187
- props . onEvent ( ' focus' ) ;
189
+ props . onEvent ( " focus" ) ;
188
190
} }
189
- onBlur = { ( ) => props . onEvent ( ' blur' ) }
191
+ onBlur = { ( ) => props . onEvent ( " blur" ) }
190
192
onPressEnter = { onPressEnter }
191
193
onSearch = { onSearch }
192
194
onChange = { onChange }
@@ -202,15 +204,15 @@ let MentionTmpComp = (function () {
202
204
} ) ) }
203
205
autoSize = { props . autoHeight }
204
206
style = { {
205
- height : ' 100%' ,
206
- maxHeight : ' 100%' ,
207
- resize : ' none' ,
207
+ height : " 100%" ,
208
+ maxHeight : " 100%" ,
209
+ resize : " none" ,
208
210
// padding: props.style.padding,
209
211
fontStyle : props . style . fontStyle ,
210
212
fontFamily : props . style . fontFamily ,
211
213
borderWidth : props . style . borderWidth ,
212
214
fontWeight : props . style . textWeight ,
213
- fontSize : props . style . textSize ,
215
+ fontSize : props . style . textSize
214
216
} }
215
217
readOnly = { props . readOnly }
216
218
/>
@@ -225,58 +227,48 @@ let MentionTmpComp = (function () {
225
227
. setPropertyViewFn ( ( children ) => (
226
228
< >
227
229
< Section name = { sectionNames . basic } >
228
- { children . value . propertyView ( { label : trans ( ' prop.defaultValue' ) } ) }
230
+ { children . value . propertyView ( { label : trans ( " prop.defaultValue" ) } ) }
229
231
{ children . placeholder . propertyView ( {
230
- label : trans ( ' prop.placeholder' ) ,
232
+ label : trans ( " prop.placeholder" ) ,
231
233
} ) }
232
- { [ 'logic' , 'both' ] . includes (
233
- useContext ( EditorContext ) . editorModeStatus
234
- ) &&
234
+ { [ "logic" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
235
235
children . mentionList . propertyView ( {
236
- label : trans ( 'mention.mentionList' ) ,
237
- } ) }
236
+ label : trans ( "mention.mentionList" ) ,
237
+ } )
238
+ ) }
238
239
</ Section >
239
240
< FormDataPropertyView { ...children } />
240
241
241
- { [ ' layout' , ' both' ] . includes (
242
- useContext ( EditorContext ) . editorModeStatus
243
- ) && children . label . getPropertyView ( ) }
242
+ { [ " layout" , " both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
243
+ children . label . getPropertyView ( )
244
+ ) }
244
245
245
- { [ 'logic' , 'both' ] . includes (
246
- useContext ( EditorContext ) . editorModeStatus
247
- ) && (
248
- < >
249
- < Section name = { sectionNames . interaction } >
250
- { children . onEvent . getPropertyView ( ) }
251
- { disabledPropertyView ( children ) }
252
- </ Section >
253
- < Section name = { sectionNames . layout } >
254
- { hiddenPropertyView ( children ) }
255
- </ Section >
246
+ { [ "logic" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
247
+ < > < Section name = { sectionNames . interaction } >
248
+ { children . onEvent . getPropertyView ( ) }
249
+ { disabledPropertyView ( children ) }
250
+ </ Section >
251
+ < Section name = { sectionNames . layout } > { hiddenPropertyView ( children ) } </ Section >
256
252
< Section name = { sectionNames . advanced } >
257
253
{ readOnlyPropertyView ( children ) }
258
- </ Section >
259
- < Section name = { sectionNames . validation } >
254
+ </ Section > < Section name = { sectionNames . validation } >
260
255
{ requiredPropertyView ( children ) }
261
256
{ children . validationType . propertyView ( {
262
- label : trans ( ' prop.textType' ) ,
257
+ label : trans ( " prop.textType" ) ,
263
258
} ) }
264
259
{ minLengthPropertyView ( children ) }
265
260
{ maxLengthPropertyView ( children ) }
266
261
{ children . customRule . propertyView ( { } ) }
267
- </ Section >
268
- </ >
262
+ </ Section > </ >
269
263
) }
270
264
271
- { [ 'layout' , 'both' ] . includes (
272
- useContext ( EditorContext ) . editorModeStatus
273
- ) && (
265
+ { [ "layout" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
274
266
< >
275
267
< Section name = { sectionNames . style } >
276
- { children . style . getPropertyView ( ) }
268
+ { children . style . getPropertyView ( ) }
277
269
</ Section >
278
270
< Section name = { sectionNames . animationStyle } >
279
- { children . animationStyle . getPropertyView ( ) }
271
+ { children . animationStyle . getPropertyView ( ) }
280
272
</ Section >
281
273
</ >
282
274
) }
@@ -285,6 +277,7 @@ let MentionTmpComp = (function () {
285
277
. build ( ) ;
286
278
} ) ( ) ;
287
279
280
+
288
281
MentionTmpComp = class extends MentionTmpComp {
289
282
override autoHeight ( ) : boolean {
290
283
return this . children . autoHeight . getView ( ) ;
@@ -299,10 +292,10 @@ const TextareaTmp2Comp = withMethodExposing(
299
292
) ;
300
293
301
294
export const MentionComp = withExposingConfigs ( TextareaTmp2Comp , [
302
- new NameConfig ( ' value' , trans ( ' export.inputValueDesc' ) ) ,
295
+ new NameConfig ( " value" , trans ( " export.inputValueDesc" ) ) ,
303
296
NameConfigPlaceHolder ,
304
297
NameConfigRequired ,
305
- new NameConfig ( ' invalid' , trans ( ' export.invalidDesc' ) ) ,
306
- new NameConfig ( ' hidden' , trans ( ' export.hiddenDesc' ) ) ,
307
- new NameConfig ( ' disabled' , trans ( ' export.disabledDesc' ) ) ,
298
+ new NameConfig ( " invalid" , trans ( " export.invalidDesc" ) ) ,
299
+ new NameConfig ( " hidden" , trans ( " export.hiddenDesc" ) ) ,
300
+ new NameConfig ( " disabled" , trans ( " export.disabledDesc" ) ) ,
308
301
] ) ;
0 commit comments