@@ -10,9 +10,12 @@ import {
10
10
RcTypography ,
11
11
RcIcon ,
12
12
RcTooltip ,
13
+ RcFormLabel ,
14
+ RcFormGroup ,
15
+ RcCheckbox ,
13
16
css ,
14
17
} from '@ringcentral/juno' ;
15
- import { styled } from '@ringcentral/juno/foundation' ;
18
+ import { styled , palette2 } from '@ringcentral/juno/foundation' ;
16
19
import { InfoBorder , Lock } from '@ringcentral/juno-icon' ;
17
20
18
21
const StyledAlert = styled ( RcAlert ) `
@@ -72,6 +75,87 @@ const StyledSwitchLabel = styled(RcTypography)`
72
75
font-size: 0.875rem;
73
76
` ;
74
77
78
+ const CheckboxSelectWrapper = styled . div `
79
+ display: flex;
80
+ flex-direction: column;
81
+ ` ;
82
+
83
+ const StyledFormLabel = styled ( RcFormLabel ) `
84
+ font-size: 0.75rem;
85
+ color: ${ palette2 ( 'neutral' , 'f05' ) } ;
86
+ ` ;
87
+
88
+ const StyledFormGroup = styled ( RcFormGroup ) `
89
+ display: flex;
90
+ flex-direction: row;
91
+ align-items: center;
92
+ flex-wrap: wrap;
93
+ ` ;
94
+
95
+ function CheckboxSelect ( {
96
+ value,
97
+ label,
98
+ options,
99
+ onChange,
100
+ required,
101
+ className,
102
+ readOnly,
103
+ multiple,
104
+ disabled,
105
+ helperText,
106
+ } ) {
107
+ let currentValue = value ;
108
+ if ( multiple && ! Array . isArray ( value ) ) {
109
+ currentValue = [ ] ;
110
+ }
111
+ return (
112
+ < CheckboxSelectWrapper className = { className } >
113
+ < StyledFormLabel required = { required } > { label } </ StyledFormLabel >
114
+ { helperText && (
115
+ < RcTypography variant = 'caption1' color = "neutral.f04" component = "span" >
116
+ { helperText }
117
+ </ RcTypography >
118
+ ) }
119
+ < StyledFormGroup >
120
+ { options . map ( ( option ) => {
121
+ const checked = multiple ? currentValue . includes ( option . id ) : currentValue === option . id ;
122
+ const itemDisabled = disabled || option . disabled ;
123
+ return (
124
+ < RcCheckbox
125
+ formControlLabelProps = { {
126
+ labelPlacement : 'end' ,
127
+ } }
128
+ label = { option . name }
129
+ key = { option . id }
130
+ id = { option . id }
131
+ name = { option . id }
132
+ checked = { checked }
133
+ disabled = { itemDisabled || readOnly }
134
+ onChange = { ( _ , checked ) => {
135
+ if ( readOnly ) {
136
+ return ;
137
+ }
138
+ if ( multiple ) {
139
+ if ( checked ) {
140
+ onChange ( [ ...currentValue , option . id ] ) ;
141
+ } else {
142
+ onChange ( currentValue . filter ( ( v ) => v !== option . id ) ) ;
143
+ }
144
+ return ;
145
+ }
146
+ if ( checked ) {
147
+ onChange ( option . id ) ;
148
+ } else {
149
+ onChange ( null ) ;
150
+ }
151
+ } }
152
+ />
153
+ )
154
+ } ) }
155
+ </ StyledFormGroup >
156
+ </ CheckboxSelectWrapper >
157
+ ) ;
158
+ }
75
159
export function SettingParamInput ( {
76
160
setting,
77
161
className,
@@ -177,13 +261,30 @@ export function SettingParamInput({
177
261
) ;
178
262
}
179
263
if ( setting . type === 'option' ) {
264
+ if ( setting . checkbox ) {
265
+ return (
266
+ < CheckboxSelect
267
+ label = { label }
268
+ value = { setting . value }
269
+ options = { setting . options }
270
+ onChange = { onChange }
271
+ required = { setting . required }
272
+ className = { className }
273
+ readOnly = { setting . readOnly }
274
+ multiple = { setting . multiple }
275
+ disabled = { setting . disabled }
276
+ helperText = { setting . helper }
277
+ />
278
+ ) ;
279
+ }
180
280
return (
181
281
< StyledSelect
182
282
label = { label }
183
283
value = { setting . value }
184
284
fullWidth
185
285
className = { className }
186
286
placeholder = { setting . placeholder }
287
+ multiple = { setting . multiple }
187
288
onChange = { ( e ) => {
188
289
if ( setting . readOnly ) {
189
290
return ;
0 commit comments