1
- import { default as AntdSegmented } from 'antd/es/segmented' ;
2
- import { BoolCodeControl } from 'comps/controls/codeControl' ;
3
- import { stringExposingStateControl } from 'comps/controls/codeStateControl' ;
4
- import { ChangeEventHandlerControl } from 'comps/controls/eventHandlerControl' ;
5
- import { LabelControl } from 'comps/controls/labelControl' ;
6
- import { SelectOptionControl } from 'comps/controls/optionsControl' ;
7
- import { styleControl } from 'comps/controls/styleControl' ;
8
- import {
9
- AnimationStyle ,
10
- SegmentStyle ,
11
- SegmentStyleType ,
12
- } from 'comps/controls/styleControlConstants' ;
13
- import styled , { css } from 'styled-components' ;
14
- import { UICompBuilder } from '../../generators' ;
15
- import {
16
- CommonNameConfig ,
17
- NameConfig ,
18
- withExposingConfigs ,
19
- } from '../../generators/withExposing' ;
20
- import {
21
- formDataChildren ,
22
- FormDataPropertyView ,
23
- } from '../formComp/formDataConstants' ;
1
+ import { default as AntdSegmented } from "antd/es/segmented" ;
2
+ import { BoolCodeControl } from "comps/controls/codeControl" ;
3
+ import { stringExposingStateControl } from "comps/controls/codeStateControl" ;
4
+ import { ChangeEventHandlerControl } from "comps/controls/eventHandlerControl" ;
5
+ import { LabelControl } from "comps/controls/labelControl" ;
6
+ import { SelectOptionControl } from "comps/controls/optionsControl" ;
7
+ import { styleControl } from "comps/controls/styleControl" ;
8
+ import { AnimationStyle , SegmentStyle , SegmentStyleType } from "comps/controls/styleControlConstants" ;
9
+ import styled , { css } from "styled-components" ;
10
+ import { UICompBuilder } from "../../generators" ;
11
+ import { CommonNameConfig , NameConfig , withExposingConfigs } from "../../generators/withExposing" ;
12
+ import { formDataChildren , FormDataPropertyView } from "../formComp/formDataConstants" ;
24
13
import {
25
14
selectDivRefMethods ,
26
15
SelectInputInvalidConfig ,
27
16
SelectInputValidationChildren ,
28
17
SelectInputValidationSection ,
29
18
useSelectInputValidate ,
30
- } from './selectInputConstants' ;
31
- import { Section , sectionNames } from 'lowcoder-design' ;
32
- import {
33
- hiddenPropertyView ,
34
- disabledPropertyView ,
35
- } from 'comps/utils/propertyUtils' ;
36
- import { trans } from 'i18n' ;
37
- import { hasIcon } from 'comps/utils' ;
38
- import { RefControl } from 'comps/controls/refControl' ;
19
+ } from "./selectInputConstants" ;
20
+ import { Section , sectionNames } from "lowcoder-design" ;
21
+ import { hiddenPropertyView , disabledPropertyView } from "comps/utils/propertyUtils" ;
22
+ import { trans } from "i18n" ;
23
+ import { hasIcon } from "comps/utils" ;
24
+ import { RefControl } from "comps/controls/refControl" ;
25
+
26
+ import { useContext } from "react" ;
27
+ import { EditorContext } from "comps/editorState" ;
28
+ import { migrateOldData , withDefault } from "comps/generators/simpleGenerators" ;
29
+ import { fixOldInputCompData } from "../textInputComp/textInputConstants" ;
39
30
40
- import { useContext } from 'react' ;
41
- import { EditorContext } from 'comps/editorState' ;
42
- import { migrateOldData , withDefault } from 'comps/generators/simpleGenerators' ;
43
- import { fixOldInputCompData } from '../textInputComp/textInputConstants' ;
44
31
45
32
const getStyle = ( style : SegmentStyleType ) => {
46
33
return css `
@@ -66,33 +53,32 @@ const getStyle = (style: SegmentStyleType) => {
66
53
.ant-segmented-item-selected {
67
54
border-radius : ${ style . radius } ;
68
55
}
69
- & .ant-segmented ,
70
- .ant-segmented-item-label {
71
- font-family : ${ style . fontFamily } ;
72
- font-style : ${ style . fontStyle } ;
73
- font-size : ${ style . textSize } ;
74
- font-weight : ${ style . textWeight } ;
75
- text-transform : ${ style . textTransform } ;
76
- text-decoration : ${ style . textDecoration } ;
56
+ & .ant-segmented , .ant-segmented-item-label {
57
+ font-family : ${ style . fontFamily } ;
58
+ font-style : ${ style . fontStyle } ;
59
+ font-size : ${ style . textSize } ;
60
+ font-weight : ${ style . textWeight } ;
61
+ text-transform : ${ style . textTransform } ;
62
+ text-decoration : ${ style . textDecoration } ;
77
63
}
78
64
` ;
79
65
} ;
80
66
81
- const Segmented = styled ( AntdSegmented ) < { $style : SegmentStyleType } > `
67
+ const Segmented = styled ( AntdSegmented ) < { $style : SegmentStyleType } > `
82
68
width: 100%;
83
69
min-height: 24px; // keep the height unchanged when there are no options
84
70
${ ( props ) => props . $style && getStyle ( props . $style ) }
85
71
` ;
86
72
87
73
const SegmentChildrenMap = {
88
- defaultValue : stringExposingStateControl ( ' value' ) ,
89
- value : stringExposingStateControl ( ' value' ) ,
74
+ defaultValue : stringExposingStateControl ( " value" ) ,
75
+ value : stringExposingStateControl ( " value" ) ,
90
76
label : LabelControl ,
91
77
disabled : BoolCodeControl ,
92
78
onEvent : ChangeEventHandlerControl ,
93
79
options : SelectOptionControl ,
94
- style : withDefault ( styleControl ( SegmentStyle ) , { borderWidth : '1px' } ) ,
95
- animationStyle : styleControl ( AnimationStyle ) ,
80
+ style : withDefault ( styleControl ( SegmentStyle ) , { borderWidth : '1px' } ) ,
81
+ animationStyle :styleControl ( AnimationStyle ) ,
96
82
viewRef : RefControl < HTMLDivElement > ,
97
83
98
84
...SelectInputValidationChildren ,
@@ -101,7 +87,10 @@ const SegmentChildrenMap = {
101
87
102
88
let SegmentedControlBasicComp = ( function ( ) {
103
89
return new UICompBuilder ( SegmentChildrenMap , ( props ) => {
104
- const [ validateState , handleChange ] = useSelectInputValidate ( props ) ;
90
+ const [
91
+ validateState ,
92
+ handleChange ,
93
+ ] = useSelectInputValidate ( props ) ;
105
94
return props . label ( {
106
95
required : props . required ,
107
96
style : props . style ,
@@ -133,57 +122,43 @@ let SegmentedControlBasicComp = (function () {
133
122
< >
134
123
< Section name = { sectionNames . basic } >
135
124
{ children . options . propertyView ( { } ) }
136
- { children . defaultValue . propertyView ( {
137
- label : trans ( 'prop.defaultValue' ) ,
138
- } ) }
125
+ { children . defaultValue . propertyView ( { label : trans ( "prop.defaultValue" ) } ) }
139
126
</ Section >
140
127
141
- { [ 'logic' , 'both' ] . includes (
142
- useContext ( EditorContext ) . editorModeStatus
143
- ) && (
144
- < >
145
- < SelectInputValidationSection { ...children } />
146
- < FormDataPropertyView { ...children } />
147
- < Section name = { sectionNames . interaction } >
148
- { children . onEvent . getPropertyView ( ) }
149
- { disabledPropertyView ( children ) }
150
- { hiddenPropertyView ( children ) }
151
- </ Section >
152
- </ >
128
+ { [ "logic" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
129
+ < > < SelectInputValidationSection { ...children } />
130
+ < FormDataPropertyView { ...children } />
131
+ < Section name = { sectionNames . interaction } >
132
+ { children . onEvent . getPropertyView ( ) }
133
+ { disabledPropertyView ( children ) }
134
+ { hiddenPropertyView ( children ) }
135
+ </ Section > </ >
153
136
) }
154
137
155
- { [ ' layout' , ' both' ] . includes (
156
- useContext ( EditorContext ) . editorModeStatus
157
- ) && children . label . getPropertyView ( ) }
138
+ { [ " layout" , " both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
139
+ children . label . getPropertyView ( )
140
+ ) }
158
141
159
- { [ 'layout' , 'both' ] . includes (
160
- useContext ( EditorContext ) . editorModeStatus
161
- ) && (
142
+ { [ "layout" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
162
143
< >
163
- < Section name = { sectionNames . style } >
164
- { children . style . getPropertyView ( ) }
144
+ < Section name = { sectionNames . style } >
145
+ { children . style . getPropertyView ( ) }
146
+ </ Section >
147
+ < Section name = { sectionNames . animationStyle } >
148
+ { children . animationStyle . getPropertyView ( ) }
165
149
</ Section >
166
- < Section name = { sectionNames . animationStyle } >
167
- { children . animationStyle . getPropertyView ( ) }
168
- </ Section >
169
- </ >
150
+ </ >
170
151
) }
171
152
</ >
172
153
) )
173
154
. setExposeMethodConfigs ( selectDivRefMethods )
174
155
. build ( ) ;
175
156
} ) ( ) ;
176
157
177
- SegmentedControlBasicComp = migrateOldData (
178
- SegmentedControlBasicComp ,
179
- fixOldInputCompData
180
- ) ;
158
+ SegmentedControlBasicComp = migrateOldData ( SegmentedControlBasicComp , fixOldInputCompData ) ;
181
159
182
- export const SegmentedControlComp = withExposingConfigs (
183
- SegmentedControlBasicComp ,
184
- [
185
- new NameConfig ( 'value' , trans ( 'selectInput.valueDesc' ) ) ,
186
- SelectInputInvalidConfig ,
187
- ...CommonNameConfig ,
188
- ]
189
- ) ;
160
+ export const SegmentedControlComp = withExposingConfigs ( SegmentedControlBasicComp , [
161
+ new NameConfig ( "value" , trans ( "selectInput.valueDesc" ) ) ,
162
+ SelectInputInvalidConfig ,
163
+ ...CommonNameConfig ,
164
+ ] ) ;
0 commit comments