@react-ui-org/react-ui 0.42.0 → 0.44.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CONTRIBUTING.md +44 -25
- package/README.md +1 -1
- package/dist/lib.development.js +1598 -652
- package/dist/lib.js +1 -9
- package/package.json +49 -48
- package/src/lib/components/{ui/Alert → Alert}/Alert.jsx +17 -14
- package/src/lib/components/{ui/Alert → Alert}/Alert.scss +3 -3
- package/src/lib/components/{ui/Alert → Alert}/README.mdx +6 -6
- package/src/lib/components/{ui/Alert → Alert}/_settings.scss +1 -1
- package/src/lib/components/{ui/Alert → Alert}/_theme.scss +0 -0
- package/src/lib/components/{ui/Alert → Alert}/_tools.scss +0 -0
- package/src/lib/components/{ui/Alert → Alert}/index.js +0 -0
- package/src/lib/components/{ui/Badge → Badge}/Badge.jsx +2 -2
- package/src/lib/components/{ui/Badge → Badge}/Badge.scss +3 -3
- package/src/lib/components/{ui/Badge → Badge}/README.mdx +3 -3
- package/src/lib/components/{ui/Badge → Badge}/index.js +0 -0
- package/src/lib/components/Button/Button.jsx +198 -0
- package/src/lib/components/{ui/Button → Button}/Button.scss +0 -0
- package/src/lib/components/{ui/Button → Button}/README.mdx +160 -75
- package/src/lib/components/Button/_base.scss +148 -0
- package/src/lib/components/{ui/Button → Button}/_priorities.scss +0 -4
- package/src/lib/components/{ui/Button → Button}/_settings.scss +2 -3
- package/src/lib/components/{ui/Button → Button}/_theme.scss +3 -11
- package/src/lib/components/{ui/Button → Button}/_tools.scss +27 -44
- package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +33 -0
- package/src/lib/components/{ui/Button → Button}/helpers/getRootPriorityClassName.js +0 -4
- package/src/lib/components/{ui/Button → Button}/index.js +0 -0
- package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/ButtonGroup.jsx +9 -11
- package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/ButtonGroup.scss +0 -0
- package/src/lib/components/ButtonGroup/ButtonGroupContext.js +3 -0
- package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/README.mdx +26 -2
- package/src/lib/components/ButtonGroup/index.js +2 -0
- package/src/lib/components/{layout/CTA → CTA}/CTA.jsx +5 -2
- package/src/lib/components/{layout/CTA → CTA}/CTA.scss +2 -2
- package/src/lib/components/{layout/CTA → CTA}/CTACenter.jsx +1 -1
- package/src/lib/components/{layout/CTA → CTA}/CTAEnd.jsx +1 -1
- package/src/lib/components/{layout/CTA → CTA}/CTAStart.jsx +1 -1
- package/src/lib/components/{layout/CTA → CTA}/README.mdx +3 -3
- package/src/lib/components/{layout/CTA → CTA}/index.js +0 -0
- package/src/lib/components/{ui/Card → Card}/Card.jsx +6 -4
- package/src/lib/components/{ui/Card → Card}/Card.scss +1 -1
- package/src/lib/components/{ui/Card → Card}/CardBody.jsx +1 -1
- package/src/lib/components/{ui/Card → Card}/CardFooter.jsx +1 -1
- package/src/lib/components/{ui/Card → Card}/README.mdx +2 -2
- package/src/lib/components/{ui/Card → Card}/_theme.scss +0 -0
- package/src/lib/components/{ui/Card → Card}/_tools.scss +0 -0
- package/src/lib/components/{ui/Card → Card}/index.js +0 -0
- package/src/lib/components/{layout/Center → Center}/Center.jsx +1 -1
- package/src/lib/components/{layout/Center → Center}/Center.scss +0 -0
- package/src/lib/components/{layout/Center → Center}/README.mdx +2 -2
- package/src/lib/components/{layout/Center → Center}/index.js +0 -0
- package/src/lib/components/CheckboxField/CheckboxField.jsx +164 -0
- package/src/lib/components/{ui/CheckboxField → CheckboxField}/CheckboxField.scss +5 -5
- package/src/lib/components/{ui/CheckboxField → CheckboxField}/README.mdx +15 -12
- package/src/lib/components/{ui/CheckboxField → CheckboxField}/index.js +0 -0
- package/src/lib/components/FileInputField/FileInputField.jsx +162 -0
- package/src/lib/components/{ui/FileInputField → FileInputField}/FileInputField.scss +5 -5
- package/src/lib/components/{ui/FileInputField → FileInputField}/README.mdx +8 -6
- package/src/lib/components/{ui/FileInputField → FileInputField}/index.js +0 -0
- package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayout.jsx +16 -18
- package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayout.scss +3 -3
- package/src/lib/components/FormLayout/FormLayoutContext.js +3 -0
- package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayoutCustomField.jsx +33 -30
- package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayoutCustomField.scss +4 -4
- package/src/lib/components/{layout/FormLayout → FormLayout}/README.mdx +30 -40
- package/src/lib/components/{layout/FormLayout → FormLayout}/_theme.scss +0 -0
- package/src/lib/components/{layout/FormLayout → FormLayout}/index.js +1 -0
- package/src/lib/components/{layout/Grid → Grid}/Grid.jsx +23 -5
- package/src/lib/components/{layout/Grid → Grid}/Grid.scss +2 -4
- package/src/lib/components/{layout/Grid → Grid}/GridSpan.jsx +10 -3
- package/src/lib/components/{layout/Grid → Grid}/README.mdx +42 -38
- package/src/lib/components/{layout/Grid → Grid}/_theme.scss +1 -2
- package/src/lib/components/{layout/Grid → Grid}/_tools.scss +2 -2
- package/src/lib/components/{layout/Grid → Grid}/helpers/generateResponsiveCustomProperties.js +0 -0
- package/src/lib/components/{layout/Grid → Grid}/index.js +0 -0
- package/src/lib/components/Link/Link.jsx +45 -0
- package/src/lib/components/Link/Link.scss +11 -0
- package/src/lib/components/Link/README.mdx +85 -0
- package/src/lib/components/Link/_theme.scss +4 -0
- package/src/lib/components/Link/index.js +1 -0
- package/src/lib/components/{layout/List → List}/List.jsx +1 -1
- package/src/lib/components/{layout/List → List}/List.scss +2 -2
- package/src/lib/components/{layout/List → List}/ListItem.jsx +1 -1
- package/src/lib/components/{layout/List → List}/README.mdx +2 -2
- package/src/lib/components/{layout/List → List}/_theme.scss +0 -0
- package/src/lib/components/{layout/List → List}/index.js +0 -0
- package/src/lib/components/{layout/Media → Media}/Media.jsx +4 -2
- package/src/lib/components/{layout/Media → Media}/Media.scss +1 -1
- package/src/lib/components/{layout/Media → Media}/MediaBody.jsx +1 -1
- package/src/lib/components/{layout/Media → Media}/MediaObject.jsx +1 -1
- package/src/lib/components/{layout/Media → Media}/README.mdx +2 -2
- package/src/lib/components/{layout/Media → Media}/index.js +0 -0
- package/src/lib/components/{ui/Modal → Modal}/Modal.jsx +28 -27
- package/src/lib/components/{ui/Modal → Modal}/Modal.scss +5 -5
- package/src/lib/components/{ui/Modal → Modal}/README.mdx +40 -40
- package/src/lib/components/{ui/Modal → Modal}/_settings.scss +4 -4
- package/src/lib/components/{ui/Modal → Modal}/_theme.scss +0 -0
- package/src/lib/components/{ui/Modal → Modal}/index.js +0 -0
- package/src/lib/components/{ui/Paper → Paper}/Paper.jsx +8 -1
- package/src/lib/components/{ui/Paper → Paper}/Paper.scss +5 -0
- package/src/lib/components/{ui/Paper → Paper}/README.mdx +14 -2
- package/src/lib/components/{ui/Paper → Paper}/_theme.scss +2 -0
- package/src/lib/components/{ui/Paper → Paper}/index.js +0 -0
- package/src/lib/components/{ui/Radio → Radio}/README.mdx +17 -14
- package/src/lib/components/Radio/Radio.jsx +188 -0
- package/src/lib/components/{ui/Radio → Radio}/Radio.scss +9 -9
- package/src/lib/components/{ui/Radio → Radio}/index.js +0 -0
- package/src/lib/components/{ui/ScrollView → ScrollView}/README.mdx +10 -10
- package/src/lib/components/{ui/ScrollView → ScrollView}/ScrollView.jsx +9 -10
- package/src/lib/components/{ui/ScrollView → ScrollView}/ScrollView.scss +6 -6
- package/src/lib/components/{ui/ScrollView → ScrollView}/_theme.scss +0 -0
- package/src/lib/components/{ui/ScrollView → ScrollView}/index.js +0 -0
- package/src/lib/components/{ui/SelectField → SelectField}/README.mdx +44 -41
- package/src/lib/components/SelectField/SelectField.jsx +219 -0
- package/src/lib/components/{ui/SelectField → SelectField}/SelectField.scss +6 -6
- package/src/lib/components/{ui/SelectField → SelectField}/index.js +0 -0
- package/src/lib/components/{ui/Table → Table}/README.mdx +7 -7
- package/src/lib/components/{ui/Table → Table}/Table.jsx +9 -13
- package/src/lib/components/{ui/Table → Table}/Table.scss +1 -1
- package/src/lib/components/{ui/Table → Table}/_settings.scss +4 -4
- package/src/lib/components/{ui/Table → Table}/index.js +0 -0
- package/src/lib/components/{ui/Tabs → Tabs}/README.mdx +3 -3
- package/src/lib/components/{ui/Tabs → Tabs}/Tabs.jsx +4 -4
- package/src/lib/components/{ui/Tabs → Tabs}/Tabs.scss +1 -1
- package/src/lib/components/{ui/Tabs → Tabs}/TabsItem.jsx +4 -3
- package/src/lib/components/{ui/Tabs → Tabs}/TabsItem.scss +3 -3
- package/src/lib/components/{ui/Tabs → Tabs}/_theme.scss +0 -0
- package/src/lib/components/{ui/Tabs → Tabs}/index.js +0 -0
- package/src/lib/components/{ui/Text → Text}/README.mdx +19 -19
- package/src/lib/components/{ui/Text → Text}/Text.jsx +1 -1
- package/src/lib/components/{ui/Text → Text}/Text.scss +0 -0
- package/src/lib/components/{ui/Text → Text}/helpers/getRootHyphensClassName.js +0 -0
- package/src/lib/components/{ui/Text → Text}/helpers/getRootWordWrappingClassName.js +0 -0
- package/src/lib/components/{ui/Text → Text}/index.js +0 -0
- package/src/lib/components/{ui/TextArea → TextArea}/README.mdx +8 -6
- package/src/lib/components/{ui/TextArea → TextArea}/TextArea.jsx +78 -78
- package/src/lib/components/{ui/TextArea → TextArea}/TextArea.scss +6 -6
- package/src/lib/components/{ui/TextArea → TextArea}/index.js +0 -0
- package/src/lib/components/{ui/TextField → TextField}/README.mdx +7 -6
- package/src/lib/components/{ui/TextField → TextField}/TextField.jsx +20 -23
- package/src/lib/components/{ui/TextField → TextField}/TextField.scss +6 -6
- package/src/lib/components/{ui/TextField → TextField}/index.js +0 -0
- package/src/lib/components/{ui/Toggle → Toggle}/README.mdx +15 -12
- package/src/lib/components/Toggle/Toggle.jsx +163 -0
- package/src/lib/components/{ui/Toggle → Toggle}/Toggle.scss +5 -5
- package/src/lib/components/{ui/Toggle → Toggle}/index.js +0 -0
- package/src/lib/components/{layout/Toolbar → Toolbar}/README.mdx +26 -26
- package/src/lib/components/{layout/Toolbar → Toolbar}/Toolbar.jsx +1 -1
- package/src/lib/components/{layout/Toolbar → Toolbar}/Toolbar.scss +1 -1
- package/src/lib/components/{layout/Toolbar → Toolbar}/ToolbarGroup.jsx +1 -1
- package/src/lib/components/{layout/Toolbar → Toolbar}/ToolbarItem.jsx +1 -1
- package/src/lib/components/{layout/Toolbar → Toolbar}/_theme.scss +0 -0
- package/src/lib/components/{layout/Toolbar → Toolbar}/index.js +0 -0
- package/src/lib/components/{ui/withForwardedRef.jsx → withForwardedRef.jsx} +0 -0
- package/src/lib/helpers/resolveContextOrProp.js +7 -0
- package/src/lib/index.js +34 -35
- package/src/lib/styles/tools/_accessibility.scss +9 -0
- package/src/lib/theme.scss +25 -7
- package/src/lib/components/ui/Button/Button.jsx +0 -191
- package/src/lib/components/ui/Button/_base.scss +0 -154
- package/src/lib/components/ui/Button/helpers/getRootLabelVisibilityClassName.js +0 -11
- package/src/lib/components/ui/ButtonGroup/index.js +0 -1
- package/src/lib/components/ui/CheckboxField/CheckboxField.jsx +0 -173
- package/src/lib/components/ui/FileInputField/FileInputField.jsx +0 -158
- package/src/lib/components/ui/Radio/Radio.jsx +0 -179
- package/src/lib/components/ui/SelectField/SelectField.jsx +0 -214
- package/src/lib/components/ui/Toggle/Toggle.jsx +0 -174
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
name: SelectField
|
3
|
-
menu: '
|
4
|
-
route: /components/
|
3
|
+
menu: 'Inputs'
|
4
|
+
route: /components/select-field
|
5
5
|
---
|
6
6
|
|
7
7
|
# SelectField
|
@@ -29,8 +29,8 @@ And use it:
|
|
29
29
|
const [fruit, setFruit] = React.useState('apple');
|
30
30
|
return (
|
31
31
|
<SelectField
|
32
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
33
32
|
label="Your favourite fruit"
|
33
|
+
onChange={(e) => setFruit(e.target.value)}
|
34
34
|
options={[
|
35
35
|
{
|
36
36
|
label: 'Apple',
|
@@ -110,14 +110,14 @@ further [customized](#theming) with CSS custom properties.
|
|
110
110
|
return (
|
111
111
|
<>
|
112
112
|
<SelectField
|
113
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
114
113
|
label="Your favourite fruit"
|
114
|
+
onChange={(e) => setFruit(e.target.value)}
|
115
115
|
options={options}
|
116
116
|
value={fruit}
|
117
117
|
/>
|
118
118
|
<SelectField
|
119
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
120
119
|
label="Your favourite fruit"
|
120
|
+
onChange={(e) => setFruit(e.target.value)}
|
121
121
|
options={options}
|
122
122
|
variant="filled"
|
123
123
|
value={fruit}
|
@@ -152,43 +152,43 @@ and large.
|
|
152
152
|
return (
|
153
153
|
<>
|
154
154
|
<SelectField
|
155
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
156
155
|
label="Your favourite fruit"
|
156
|
+
onChange={(e) => setFruit(e.target.value)}
|
157
157
|
options={options}
|
158
158
|
size="small"
|
159
159
|
value={fruit}
|
160
160
|
/>
|
161
161
|
<SelectField
|
162
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
163
162
|
label="Your favourite fruit"
|
163
|
+
onChange={(e) => setFruit(e.target.value)}
|
164
164
|
options={options}
|
165
165
|
value={fruit}
|
166
166
|
/>
|
167
167
|
<SelectField
|
168
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
169
168
|
label="Your favourite fruit"
|
169
|
+
onChange={(e) => setFruit(e.target.value)}
|
170
170
|
options={options}
|
171
171
|
size="large"
|
172
172
|
value={fruit}
|
173
173
|
/>
|
174
174
|
<SelectField
|
175
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
176
175
|
label="Your favourite fruit"
|
176
|
+
onChange={(e) => setFruit(e.target.value)}
|
177
177
|
options={options}
|
178
178
|
size="small"
|
179
179
|
value={fruit}
|
180
180
|
variant="filled"
|
181
181
|
/>
|
182
182
|
<SelectField
|
183
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
184
183
|
label="Your favourite fruit"
|
184
|
+
onChange={(e) => setFruit(e.target.value)}
|
185
185
|
options={options}
|
186
186
|
value={fruit}
|
187
187
|
variant="filled"
|
188
188
|
/>
|
189
189
|
<SelectField
|
190
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
191
190
|
label="Your favourite fruit"
|
191
|
+
onChange={(e) => setFruit(e.target.value)}
|
192
192
|
options={options}
|
193
193
|
size="large"
|
194
194
|
value={fruit}
|
@@ -221,16 +221,16 @@ Full-width fields span the full width of a parent:
|
|
221
221
|
return (
|
222
222
|
<>
|
223
223
|
<SelectField
|
224
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
225
224
|
fullWidth
|
226
225
|
label="Your favourite fruit"
|
226
|
+
onChange={(e) => setFruit(e.target.value)}
|
227
227
|
options={options}
|
228
228
|
value={fruit}
|
229
229
|
/>
|
230
230
|
<SelectField
|
231
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
232
231
|
fullWidth
|
233
232
|
label="Your favourite fruit"
|
233
|
+
onChange={(e) => setFruit(e.target.value)}
|
234
234
|
options={options}
|
235
235
|
value={fruit}
|
236
236
|
variant="filled"
|
@@ -267,16 +267,16 @@ the input.
|
|
267
267
|
return (
|
268
268
|
<>
|
269
269
|
<SelectField
|
270
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
271
270
|
isLabelVisible={false}
|
272
271
|
label="Your favourite fruit"
|
272
|
+
onChange={(e) => setFruit(e.target.value)}
|
273
273
|
options={options}
|
274
274
|
value={fruit}
|
275
275
|
/>
|
276
276
|
<SelectField
|
277
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
278
277
|
isLabelVisible={false}
|
279
278
|
label="Your favourite fruit"
|
279
|
+
onChange={(e) => setFruit(e.target.value)}
|
280
280
|
options={options}
|
281
281
|
value={fruit}
|
282
282
|
variant="filled"
|
@@ -312,52 +312,52 @@ supports this kind of layout as well.
|
|
312
312
|
return (
|
313
313
|
<>
|
314
314
|
<SelectField
|
315
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
316
315
|
label="Your favourite fruit"
|
317
316
|
layout="horizontal"
|
317
|
+
onChange={(e) => setFruit(e.target.value)}
|
318
318
|
options={options}
|
319
319
|
value={fruit}
|
320
320
|
/>
|
321
321
|
<SelectField
|
322
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
323
322
|
label="Your favourite fruit"
|
324
323
|
layout="horizontal"
|
324
|
+
onChange={(e) => setFruit(e.target.value)}
|
325
325
|
options={options}
|
326
326
|
value={fruit}
|
327
327
|
variant="filled"
|
328
328
|
/>
|
329
329
|
<SelectField
|
330
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
331
330
|
fullWidth
|
332
331
|
label="Your favourite fruit"
|
333
332
|
layout="horizontal"
|
333
|
+
onChange={(e) => setFruit(e.target.value)}
|
334
334
|
options={options}
|
335
335
|
value={fruit}
|
336
336
|
/>
|
337
337
|
<SelectField
|
338
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
339
338
|
fullWidth
|
340
339
|
label="Your favourite fruit"
|
341
340
|
layout="horizontal"
|
341
|
+
onChange={(e) => setFruit(e.target.value)}
|
342
342
|
options={options}
|
343
343
|
value={fruit}
|
344
344
|
variant="filled"
|
345
345
|
/>
|
346
346
|
<SelectField
|
347
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
348
347
|
fullWidth
|
349
348
|
isLabelVisible={false}
|
350
349
|
label="Your favourite fruit"
|
351
350
|
layout="horizontal"
|
352
|
-
|
351
|
+
onChange={(e) => setFruit(e.target.value)}
|
353
352
|
options={options}
|
353
|
+
value={fruit}
|
354
354
|
/>
|
355
355
|
<SelectField
|
356
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
357
356
|
fullWidth
|
358
357
|
isLabelVisible={false}
|
359
358
|
label="Your favourite fruit"
|
360
359
|
layout="horizontal"
|
360
|
+
onChange={(e) => setFruit(e.target.value)}
|
361
361
|
options={options}
|
362
362
|
value={fruit}
|
363
363
|
variant="filled"
|
@@ -392,52 +392,52 @@ filled.
|
|
392
392
|
return (
|
393
393
|
<>
|
394
394
|
<SelectField
|
395
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
396
395
|
helpText="Choose one or more kinds of fruit to feel happy."
|
397
396
|
label="Your favourite fruit"
|
397
|
+
onChange={(e) => setFruit(e.target.value)}
|
398
398
|
options={options}
|
399
399
|
value={fruit}
|
400
400
|
/>
|
401
401
|
<SelectField
|
402
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
403
402
|
helpText="Choose one or more kinds of fruit to feel happy."
|
404
403
|
label="Your favourite fruit"
|
404
|
+
onChange={(e) => setFruit(e.target.value)}
|
405
405
|
options={options}
|
406
406
|
value={fruit}
|
407
407
|
variant="filled"
|
408
408
|
/>
|
409
409
|
<SelectField
|
410
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
411
410
|
helpText="Choose one or more kinds of fruit to feel happy."
|
412
411
|
label="Your favourite fruit"
|
413
412
|
layout="horizontal"
|
413
|
+
onChange={(e) => setFruit(e.target.value)}
|
414
414
|
options={options}
|
415
415
|
value={fruit}
|
416
416
|
/>
|
417
417
|
<SelectField
|
418
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
419
418
|
helpText="Choose one or more kinds of fruit to feel happy."
|
420
419
|
label="Your favourite fruit"
|
421
420
|
layout="horizontal"
|
421
|
+
onChange={(e) => setFruit(e.target.value)}
|
422
422
|
options={options}
|
423
423
|
value={fruit}
|
424
424
|
variant="filled"
|
425
425
|
/>
|
426
426
|
<SelectField
|
427
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
428
427
|
fullWidth
|
429
428
|
helpText="Choose one or more kinds of fruit to feel happy."
|
430
429
|
label="Your favourite fruit"
|
431
430
|
layout="horizontal"
|
431
|
+
onChange={(e) => setFruit(e.target.value)}
|
432
432
|
options={options}
|
433
433
|
value={fruit}
|
434
434
|
/>
|
435
435
|
<SelectField
|
436
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
437
436
|
fullWidth
|
438
437
|
helpText="Choose one or more kinds of fruit to feel happy."
|
439
438
|
label="Your favourite fruit"
|
440
439
|
layout="horizontal"
|
440
|
+
onChange={(e) => setFruit(e.target.value)}
|
441
441
|
options={options}
|
442
442
|
value={fruit}
|
443
443
|
variant="filled"
|
@@ -476,8 +476,8 @@ have.
|
|
476
476
|
return (
|
477
477
|
<>
|
478
478
|
<SelectField
|
479
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
480
479
|
label="Your favourite fruit"
|
480
|
+
onChange={(e) => setFruit(e.target.value)}
|
481
481
|
options={options}
|
482
482
|
required
|
483
483
|
validationState="valid"
|
@@ -485,8 +485,8 @@ have.
|
|
485
485
|
value={fruit}
|
486
486
|
/>
|
487
487
|
<SelectField
|
488
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
489
488
|
label="Your favourite fruit"
|
489
|
+
onChange={(e) => setFruit(e.target.value)}
|
490
490
|
options={options}
|
491
491
|
required
|
492
492
|
validationState="warning"
|
@@ -494,8 +494,8 @@ have.
|
|
494
494
|
value={fruit}
|
495
495
|
/>
|
496
496
|
<SelectField
|
497
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
498
497
|
label="Your favourite fruit"
|
498
|
+
onChange={(e) => setFruit(e.target.value)}
|
499
499
|
options={options}
|
500
500
|
required
|
501
501
|
validationState="invalid"
|
@@ -503,8 +503,8 @@ have.
|
|
503
503
|
value={fruit}
|
504
504
|
/>
|
505
505
|
<SelectField
|
506
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
507
506
|
label="Your favourite fruit"
|
507
|
+
onChange={(e) => setFruit(e.target.value)}
|
508
508
|
options={options}
|
509
509
|
required
|
510
510
|
validationState="valid"
|
@@ -513,8 +513,8 @@ have.
|
|
513
513
|
variant="filled"
|
514
514
|
/>
|
515
515
|
<SelectField
|
516
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
517
516
|
label="Your favourite fruit"
|
517
|
+
onChange={(e) => setFruit(e.target.value)}
|
518
518
|
options={options}
|
519
519
|
required
|
520
520
|
validationState="warning"
|
@@ -523,8 +523,8 @@ have.
|
|
523
523
|
variant="filled"
|
524
524
|
/>
|
525
525
|
<SelectField
|
526
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
527
526
|
label="Your favourite fruit"
|
527
|
+
onChange={(e) => setFruit(e.target.value)}
|
528
528
|
options={options}
|
529
529
|
required
|
530
530
|
value={fruit}
|
@@ -562,29 +562,29 @@ It's possible to disable just some options or the whole input.
|
|
562
562
|
return (
|
563
563
|
<>
|
564
564
|
<SelectField
|
565
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
566
565
|
label="Your favourite fruit"
|
566
|
+
onChange={(e) => setFruit(e.target.value)}
|
567
567
|
options={options}
|
568
568
|
value={fruit}
|
569
569
|
/>
|
570
570
|
<SelectField
|
571
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
572
571
|
label="Your favourite fruit"
|
572
|
+
onChange={(e) => setFruit(e.target.value)}
|
573
573
|
options={options}
|
574
574
|
value={fruit}
|
575
575
|
variant="filled"
|
576
576
|
/>
|
577
577
|
<SelectField
|
578
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
579
578
|
disabled
|
580
579
|
label="Your favourite fruit"
|
580
|
+
onChange={(e) => setFruit(e.target.value)}
|
581
581
|
options={options}
|
582
582
|
value="apple"
|
583
583
|
/>
|
584
584
|
<SelectField
|
585
|
-
changeHandler={(e) => setFruit(e.target.value)}
|
586
585
|
disabled
|
587
586
|
label="Your favourite fruit"
|
587
|
+
onChange={(e) => setFruit(e.target.value)}
|
588
588
|
options={options}
|
589
589
|
value="apple"
|
590
590
|
variant="filled"
|
@@ -596,9 +596,10 @@ It's possible to disable just some options or the whole input.
|
|
596
596
|
|
597
597
|
## API
|
598
598
|
|
599
|
-
In addition to the options below, you can
|
600
|
-
interfere with the API, and they will be
|
601
|
-
|
599
|
+
In addition to the options below, you can specify [React synthetic events] or
|
600
|
+
any custom HTML attributes that do not interfere with the API, and they will be
|
601
|
+
passed to the `select` HTML element. This enables making the component
|
602
|
+
interactive and helps improve its accessibility.
|
602
603
|
|
603
604
|
<Props table of={SelectField} />
|
604
605
|
|
@@ -612,3 +613,5 @@ options. On top of that, the following options are available for SelectField.
|
|
612
613
|
| `--rui-FormField--box--select__caret__border-style` | SelectField arrow border style (e.g. `solid`) |
|
613
614
|
| `--rui-FormField--box--select__caret__background` | SelectField arrow background (including `url()` or gradient) |
|
614
615
|
| `--rui-FormField--box--select__option--disabled__color` | Text color of disabled SelectField options |
|
616
|
+
|
617
|
+
[React synthetic events]: https://reactjs.org/docs/events.html
|
@@ -0,0 +1,219 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import React, { useContext } from 'react';
|
3
|
+
import getRootSizeClassName from '../../helpers/getRootSizeClassName';
|
4
|
+
import getRootValidationStateClassName from '../../helpers/getRootValidationStateClassName';
|
5
|
+
import { resolveContextOrProp } from '../../helpers/resolveContextOrProp';
|
6
|
+
import { withProviderContext } from '../../provider';
|
7
|
+
import transferProps from '../../utils/transferProps';
|
8
|
+
import { FormLayoutContext } from '../FormLayout';
|
9
|
+
import withForwardedRef from '../withForwardedRef';
|
10
|
+
import styles from './SelectField.scss';
|
11
|
+
|
12
|
+
export const SelectField = ({
|
13
|
+
disabled,
|
14
|
+
forwardedRef,
|
15
|
+
fullWidth,
|
16
|
+
helpText,
|
17
|
+
id,
|
18
|
+
isLabelVisible,
|
19
|
+
label,
|
20
|
+
layout,
|
21
|
+
options,
|
22
|
+
required,
|
23
|
+
size,
|
24
|
+
validationState,
|
25
|
+
validationText,
|
26
|
+
value,
|
27
|
+
variant,
|
28
|
+
...restProps
|
29
|
+
}) => {
|
30
|
+
const context = useContext(FormLayoutContext);
|
31
|
+
|
32
|
+
return (
|
33
|
+
<label
|
34
|
+
className={[
|
35
|
+
styles.root,
|
36
|
+
fullWidth ? styles.isRootFullWidth : '',
|
37
|
+
context ? styles.isRootInFormLayout : '',
|
38
|
+
resolveContextOrProp(context && context.layout, layout) === 'horizontal'
|
39
|
+
? styles.rootLayoutHorizontal
|
40
|
+
: styles.rootLayoutVertical,
|
41
|
+
disabled ? styles.isRootDisabled : '',
|
42
|
+
required ? styles.isRootRequired : '',
|
43
|
+
getRootSizeClassName(size, styles),
|
44
|
+
getRootValidationStateClassName(validationState, styles),
|
45
|
+
variant === 'filled' ? styles.rootVariantFilled : styles.rootVariantOutline,
|
46
|
+
].join(' ')}
|
47
|
+
htmlFor={id}
|
48
|
+
id={id && `${id}__label`}
|
49
|
+
>
|
50
|
+
<div
|
51
|
+
className={[
|
52
|
+
styles.label,
|
53
|
+
isLabelVisible ? '' : styles.isLabelHidden,
|
54
|
+
].join(' ')}
|
55
|
+
id={id && `${id}__labelText`}
|
56
|
+
>
|
57
|
+
{label}
|
58
|
+
</div>
|
59
|
+
<div className={styles.field}>
|
60
|
+
<div className={styles.inputContainer}>
|
61
|
+
<select
|
62
|
+
{...transferProps(restProps)}
|
63
|
+
className={styles.input}
|
64
|
+
disabled={disabled}
|
65
|
+
id={id}
|
66
|
+
ref={forwardedRef}
|
67
|
+
required={required}
|
68
|
+
value={value}
|
69
|
+
>
|
70
|
+
{
|
71
|
+
options.map((option) => (
|
72
|
+
<option
|
73
|
+
disabled={option.disabled}
|
74
|
+
id={id && `${id}__item__${option.value}`}
|
75
|
+
key={option.value}
|
76
|
+
value={option.value}
|
77
|
+
>
|
78
|
+
{option.label}
|
79
|
+
</option>
|
80
|
+
))
|
81
|
+
}
|
82
|
+
</select>
|
83
|
+
<div className={styles.caret}>
|
84
|
+
<span className={styles.caretIcon} />
|
85
|
+
</div>
|
86
|
+
{variant === 'filled' && (
|
87
|
+
<div className={styles.bottomLine} />
|
88
|
+
)}
|
89
|
+
</div>
|
90
|
+
{helpText && (
|
91
|
+
<div
|
92
|
+
className={styles.helpText}
|
93
|
+
id={id && `${id}__helpText`}
|
94
|
+
>
|
95
|
+
{helpText}
|
96
|
+
</div>
|
97
|
+
)}
|
98
|
+
{validationText && (
|
99
|
+
<div
|
100
|
+
className={styles.validationText}
|
101
|
+
id={id && `${id}__validationText`}
|
102
|
+
>
|
103
|
+
{validationText}
|
104
|
+
</div>
|
105
|
+
)}
|
106
|
+
</div>
|
107
|
+
</label>
|
108
|
+
);
|
109
|
+
};
|
110
|
+
|
111
|
+
SelectField.defaultProps = {
|
112
|
+
disabled: false,
|
113
|
+
forwardedRef: undefined,
|
114
|
+
fullWidth: false,
|
115
|
+
helpText: null,
|
116
|
+
id: undefined,
|
117
|
+
isLabelVisible: true,
|
118
|
+
layout: 'vertical',
|
119
|
+
required: false,
|
120
|
+
size: 'medium',
|
121
|
+
validationState: null,
|
122
|
+
validationText: null,
|
123
|
+
value: undefined,
|
124
|
+
variant: 'outline',
|
125
|
+
};
|
126
|
+
|
127
|
+
SelectField.propTypes = {
|
128
|
+
/**
|
129
|
+
* If `true`, the input will be disabled.
|
130
|
+
*/
|
131
|
+
disabled: PropTypes.bool,
|
132
|
+
/**
|
133
|
+
* Reference forwarded to the `select` element.
|
134
|
+
*/
|
135
|
+
forwardedRef: PropTypes.oneOfType([
|
136
|
+
PropTypes.func,
|
137
|
+
// eslint-disable-next-line react/forbid-prop-types
|
138
|
+
PropTypes.shape({ current: PropTypes.any }),
|
139
|
+
]),
|
140
|
+
/**
|
141
|
+
* If `true`, the field will span the full width of its parent.
|
142
|
+
*/
|
143
|
+
fullWidth: PropTypes.bool,
|
144
|
+
/**
|
145
|
+
* Optional help text.
|
146
|
+
*/
|
147
|
+
helpText: PropTypes.node,
|
148
|
+
/**
|
149
|
+
* ID of the input HTML element.
|
150
|
+
*
|
151
|
+
* Also serves as a prefix for important inner elements:
|
152
|
+
* * `<ID>__label`
|
153
|
+
* * `<ID>__labelText`,
|
154
|
+
* * `<ID>__helpText`
|
155
|
+
* * `<ID>__validationText`
|
156
|
+
*
|
157
|
+
* and of individual options:
|
158
|
+
* * `<ID>__item__<VALUE>`
|
159
|
+
*/
|
160
|
+
id: PropTypes.string,
|
161
|
+
/**
|
162
|
+
* If `false`, the label will be visually hidden (but remains accessible by assistive
|
163
|
+
* technologies).
|
164
|
+
*/
|
165
|
+
isLabelVisible: PropTypes.bool,
|
166
|
+
/**
|
167
|
+
* Select field label.
|
168
|
+
*/
|
169
|
+
label: PropTypes.string.isRequired,
|
170
|
+
/**
|
171
|
+
* Layout of the field.
|
172
|
+
*
|
173
|
+
* Ignored if the component is rendered within `FormLayout` component
|
174
|
+
* as the value is inherited in such case.
|
175
|
+
*/
|
176
|
+
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
177
|
+
/**
|
178
|
+
* Set of options to be chosen from.
|
179
|
+
*/
|
180
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
181
|
+
disabled: PropTypes.bool,
|
182
|
+
label: PropTypes.string.isRequired,
|
183
|
+
value: PropTypes.oneOfType([
|
184
|
+
PropTypes.string,
|
185
|
+
PropTypes.number,
|
186
|
+
]),
|
187
|
+
})).isRequired,
|
188
|
+
/**
|
189
|
+
* If `true`, the input will be required.
|
190
|
+
*/
|
191
|
+
required: PropTypes.bool,
|
192
|
+
/**
|
193
|
+
* Size of the field.
|
194
|
+
*/
|
195
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
196
|
+
/**
|
197
|
+
* Alter the field to provide feedback based on validation result.
|
198
|
+
*/
|
199
|
+
validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
|
200
|
+
/**
|
201
|
+
* Validation message to be displayed.
|
202
|
+
*/
|
203
|
+
validationText: PropTypes.node,
|
204
|
+
/**
|
205
|
+
* Value of the input.
|
206
|
+
*/
|
207
|
+
value: PropTypes.oneOfType([
|
208
|
+
PropTypes.string,
|
209
|
+
PropTypes.number,
|
210
|
+
]),
|
211
|
+
/**
|
212
|
+
* Design variant of the field, further customizable with CSS custom properties.
|
213
|
+
*/
|
214
|
+
variant: PropTypes.oneOf(['filled', 'outline']),
|
215
|
+
};
|
216
|
+
|
217
|
+
export const SelectFieldWithContext = withForwardedRef(withProviderContext(SelectField, 'SelectField'));
|
218
|
+
|
219
|
+
export default SelectFieldWithContext;
|
@@ -1,9 +1,9 @@
|
|
1
|
-
@use '
|
2
|
-
@use '
|
3
|
-
@use '
|
4
|
-
@use '
|
5
|
-
@use '
|
6
|
-
@use '
|
1
|
+
@use '../../styles/tools/form-fields/box-field-elements';
|
2
|
+
@use '../../styles/tools/form-fields/box-field-layout';
|
3
|
+
@use '../../styles/tools/form-fields/box-field-sizes';
|
4
|
+
@use '../../styles/tools/form-fields/foundation';
|
5
|
+
@use '../../styles/tools/form-fields/variants';
|
6
|
+
@use '../../styles/tools/accessibility';
|
7
7
|
|
8
8
|
// Foundation
|
9
9
|
.root {
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
name: Table
|
3
|
-
menu: '
|
4
|
-
route: /components/
|
3
|
+
menu: 'Miscellaneous'
|
4
|
+
route: /components/table
|
5
5
|
---
|
6
6
|
|
7
7
|
# Table
|
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
Playground,
|
13
13
|
Props,
|
14
14
|
} from 'docz'
|
15
|
-
import Icon from '
|
15
|
+
import Icon from '../../../docs/_components/Icon'
|
16
16
|
import ScrollView from '../ScrollView'
|
17
17
|
import { Table } from './Table'
|
18
18
|
|
@@ -240,14 +240,14 @@ The following is an example of custom sorting function executed on the client.
|
|
240
240
|
rows={rows}
|
241
241
|
sort={{
|
242
242
|
ascendingIcon: <Icon icon="up" />,
|
243
|
-
|
243
|
+
column: tableSortColumn,
|
244
|
+
descendingIcon: <Icon icon="down" />,
|
245
|
+
direction: tableSortDirection,
|
246
|
+
onClick: (column, direction) => {
|
244
247
|
setTableSortColumn(column);
|
245
248
|
setTableSortDirection(direction === 'asc' ? 'desc' : 'asc');
|
246
249
|
setRows(compare(rows, column, direction));
|
247
250
|
},
|
248
|
-
column: tableSortColumn,
|
249
|
-
descendingIcon: <Icon icon="down" />,
|
250
|
-
direction: tableSortDirection,
|
251
251
|
}}
|
252
252
|
/>
|
253
253
|
);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import { withProviderContext } from '
|
3
|
+
import { withProviderContext } from '../../provider';
|
4
4
|
import Button from '../Button';
|
5
5
|
import styles from './Table.scss';
|
6
6
|
|
@@ -32,7 +32,6 @@ export class Table extends React.Component {
|
|
32
32
|
{sort && column.isSortable && (
|
33
33
|
<div className={styles.sortButton}>
|
34
34
|
<Button
|
35
|
-
clickHandler={() => sort.changeHandler(column.name, sortDirection)}
|
36
35
|
beforeLabel={
|
37
36
|
sortDirection === 'asc'
|
38
37
|
? sort.ascendingIcon
|
@@ -40,6 +39,7 @@ export class Table extends React.Component {
|
|
40
39
|
}
|
41
40
|
label={sortDirection}
|
42
41
|
labelVisibility="none"
|
42
|
+
onClick={() => sort.onClick(column.name, sortDirection)}
|
43
43
|
priority="flat"
|
44
44
|
{...(id && { id: `${id}__headerCell__${column.name}__sortButton` })}
|
45
45
|
/>
|
@@ -123,29 +123,25 @@ Table.propTypes = {
|
|
123
123
|
name: PropTypes.string.isRequired,
|
124
124
|
})).isRequired,
|
125
125
|
/**
|
126
|
-
* ID of the root HTML element. It also serves as
|
127
|
-
*
|
128
|
-
* `<ID>
|
126
|
+
* ID of the root HTML element. It also serves as base fo nested elements:
|
127
|
+
* * `<ID>__headerCell__<COLUMN_NAME>`
|
128
|
+
* * `<ID>__headerCell__<COLUMN_NAME>__sortButton`
|
129
|
+
* * `<ID>__bodyCell__<COLUMN_NAME>__<ROW_ID>`
|
129
130
|
*/
|
130
131
|
id: PropTypes.string,
|
131
132
|
/**
|
132
|
-
* Table data rows
|
133
|
+
* Table data rows, each object key must match a column `name`
|
133
134
|
*/
|
134
|
-
rows: PropTypes.arrayOf(PropTypes.shape({
|
135
|
-
id: PropTypes.oneOfType([
|
136
|
-
PropTypes.number,
|
137
|
-
PropTypes.string,
|
138
|
-
]).isRequired,
|
139
|
-
})).isRequired,
|
135
|
+
rows: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
|
140
136
|
/**
|
141
137
|
* Sorting configuration required to make columns sortable.
|
142
138
|
*/
|
143
139
|
sort: PropTypes.shape({
|
144
140
|
ascendingIcon: PropTypes.node.isRequired,
|
145
|
-
changeHandler: PropTypes.func.isRequired,
|
146
141
|
column: PropTypes.string.isRequired,
|
147
142
|
descendingIcon: PropTypes.node.isRequired,
|
148
143
|
direction: PropTypes.oneOf(['asc', 'desc']).isRequired,
|
144
|
+
onClick: PropTypes.func.isRequired,
|
149
145
|
}),
|
150
146
|
};
|
151
147
|
|