1
- import { default as Switch } from 'antd/es/switch' ;
2
- import { BoolCodeControl } from 'comps/controls/codeControl' ;
3
- import { booleanExposingStateControl } from 'comps/controls/codeStateControl' ;
4
- import {
5
- changeEvent ,
6
- eventHandlerControl ,
7
- } from 'comps/controls/eventHandlerControl' ;
8
- import { LabelControl } from 'comps/controls/labelControl' ;
9
- import { styleControl } from 'comps/controls/styleControl' ;
10
- import {
11
- SwitchStyle ,
12
- SwitchStyleType ,
13
- LabelStyle ,
14
- InputFieldStyle ,
15
- AnimationStyle ,
16
- } from 'comps/controls/styleControlConstants' ;
17
- import { migrateOldData } from 'comps/generators/simpleGenerators' ;
18
- import { Section , sectionNames } from 'lowcoder-design' ;
19
- import styled , { css } from 'styled-components' ;
20
- import { UICompBuilder } from '../generators' ;
21
- import {
22
- CommonNameConfig ,
23
- NameConfig ,
24
- withExposingConfigs ,
25
- } from '../generators/withExposing' ;
26
- import {
27
- formDataChildren ,
28
- FormDataPropertyView ,
29
- } from './formComp/formDataConstants' ;
30
- import {
31
- hiddenPropertyView ,
32
- disabledPropertyView ,
33
- } from 'comps/utils/propertyUtils' ;
34
- import { trans } from 'i18n' ;
35
- import { RefControl } from 'comps/controls/refControl' ;
36
- import { refMethods } from 'comps/generators/withMethodExposing' ;
37
- import {
38
- blurMethod ,
39
- clickMethod ,
40
- focusWithOptions ,
41
- } from 'comps/utils/methodUtils' ;
1
+ import { default as Switch } from "antd/es/switch" ;
2
+ import { BoolCodeControl } from "comps/controls/codeControl" ;
3
+ import { booleanExposingStateControl } from "comps/controls/codeStateControl" ;
4
+ import { changeEvent , eventHandlerControl } from "comps/controls/eventHandlerControl" ;
5
+ import { LabelControl } from "comps/controls/labelControl" ;
6
+ import { styleControl } from "comps/controls/styleControl" ;
7
+ import { SwitchStyle , SwitchStyleType , LabelStyle , InputFieldStyle , AnimationStyle } from "comps/controls/styleControlConstants" ;
8
+ import { migrateOldData } from "comps/generators/simpleGenerators" ;
9
+ import { Section , sectionNames } from "lowcoder-design" ;
10
+ import styled , { css } from "styled-components" ;
11
+ import { UICompBuilder } from "../generators" ;
12
+ import { CommonNameConfig , NameConfig , withExposingConfigs } from "../generators/withExposing" ;
13
+ import { formDataChildren , FormDataPropertyView } from "./formComp/formDataConstants" ;
14
+ import { hiddenPropertyView , disabledPropertyView } from "comps/utils/propertyUtils" ;
15
+ import { trans } from "i18n" ;
16
+ import { RefControl } from "comps/controls/refControl" ;
17
+ import { refMethods } from "comps/generators/withMethodExposing" ;
18
+ import { blurMethod , clickMethod , focusWithOptions } from "comps/utils/methodUtils" ;
42
19
43
- import { useContext } from ' react' ;
44
- import { EditorContext } from ' comps/editorState' ;
20
+ import { useContext } from " react" ;
21
+ import { EditorContext } from " comps/editorState" ;
45
22
46
23
const EventOptions = [
47
24
changeEvent ,
48
25
{
49
- label : trans ( ' switchComp.open' ) ,
50
- value : ' true' ,
51
- description : trans ( ' switchComp.openDesc' ) ,
26
+ label : trans ( " switchComp.open" ) ,
27
+ value : " true" ,
28
+ description : trans ( " switchComp.openDesc" ) ,
52
29
} ,
53
30
{
54
- label : trans ( ' switchComp.close' ) ,
55
- value : ' false' ,
56
- description : trans ( ' switchComp.closeDesc' ) ,
31
+ label : trans ( " switchComp.close" ) ,
32
+ value : " false" ,
33
+ description : trans ( " switchComp.closeDesc" ) ,
57
34
} ,
58
35
] as const ;
59
36
@@ -72,7 +49,7 @@ const getStyle = (style: SwitchStyleType) => {
72
49
` ;
73
50
} ;
74
51
75
- const SwitchWrapper = styled . div < { disabled : boolean ; $style : SwitchStyleType } > `
52
+ const SwitchWrapper = styled . div < { disabled : boolean ; $style : SwitchStyleType } > `
76
53
min-height: 32px;
77
54
display: flex;
78
55
align-items: center;
@@ -92,7 +69,7 @@ const SwitchWrapper = styled.div<{disabled: boolean; $style: SwitchStyleType}>`
92
69
* compatible with old data 2022-08-23
93
70
*/
94
71
function fixOldData ( oldData : any ) {
95
- if ( oldData && oldData . hasOwnProperty ( ' unChecked' ) ) {
72
+ if ( oldData && oldData . hasOwnProperty ( " unChecked" ) ) {
96
73
return {
97
74
label : oldData . label ,
98
75
handle : oldData . handle ,
@@ -127,8 +104,8 @@ let SwitchTmpComp = (function () {
127
104
return props . label ( {
128
105
style : props . style ,
129
106
labelStyle : props . labelStyle ,
130
- inputFieldStyle : props . inputFieldStyle ,
131
- animationStyle : props . animationStyle ,
107
+ inputFieldStyle :props . inputFieldStyle ,
108
+ animationStyle :props . animationStyle ,
132
109
children : (
133
110
< SwitchWrapper disabled = { props . disabled } $style = { props . inputFieldStyle } >
134
111
< Switch
@@ -137,8 +114,8 @@ let SwitchTmpComp = (function () {
137
114
ref = { props . viewRef }
138
115
onChange = { ( checked ) => {
139
116
props . value . onChange ( checked ) ;
140
- props . onEvent ( ' change' ) ;
141
- props . onEvent ( checked ? ' true' : ' false' ) ;
117
+ props . onEvent ( " change" ) ;
118
+ props . onEvent ( checked ? " true" : " false" ) ;
142
119
} }
143
120
/>
144
121
</ SwitchWrapper >
@@ -149,30 +126,24 @@ let SwitchTmpComp = (function () {
149
126
return (
150
127
< >
151
128
< Section name = { sectionNames . basic } >
152
- { children . value . propertyView ( {
153
- label : trans ( 'switchComp.defaultValue' ) ,
154
- } ) }
129
+ { children . value . propertyView ( { label : trans ( "switchComp.defaultValue" ) } ) }
155
130
</ Section >
156
131
157
132
< FormDataPropertyView { ...children } />
158
133
159
- { [ 'logic' , 'both' ] . includes (
160
- useContext ( EditorContext ) . editorModeStatus
161
- ) && (
134
+ { [ "logic" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
162
135
< Section name = { sectionNames . interaction } >
163
136
{ children . onEvent . getPropertyView ( ) }
164
137
{ disabledPropertyView ( children ) }
165
138
{ hiddenPropertyView ( children ) }
166
139
</ Section >
167
140
) }
168
141
169
- { [ ' layout' , ' both' ] . includes (
170
- useContext ( EditorContext ) . editorModeStatus
171
- ) && children . label . getPropertyView ( ) }
142
+ { [ " layout" , " both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
143
+ children . label . getPropertyView ( )
144
+ ) }
172
145
173
- { [ 'layout' , 'both' ] . includes (
174
- useContext ( EditorContext ) . editorModeStatus
175
- ) && (
146
+ { [ "layout" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
176
147
< >
177
148
< Section name = { sectionNames . style } >
178
149
{ children . style . getPropertyView ( ) }
@@ -191,13 +162,11 @@ let SwitchTmpComp = (function () {
191
162
</ >
192
163
) ;
193
164
} )
194
- . setExposeMethodConfigs (
195
- refMethods ( [ focusWithOptions , blurMethod , clickMethod ] )
196
- )
165
+ . setExposeMethodConfigs ( refMethods ( [ focusWithOptions , blurMethod , clickMethod ] ) )
197
166
. build ( ) ;
198
167
} ) ( ) ;
199
168
200
169
export const SwitchComp = withExposingConfigs ( SwitchTmpComp , [
201
- new NameConfig ( ' value' , trans ( ' switchComp.valueDesc' ) ) ,
170
+ new NameConfig ( " value" , trans ( " switchComp.valueDesc" ) ) ,
202
171
...CommonNameConfig ,
203
172
] ) ;
0 commit comments