@react-ui-org/react-ui 0.42.1 → 0.44.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/CONTRIBUTING.md +44 -25
  2. package/README.md +1 -1
  3. package/dist/lib.development.js +1597 -651
  4. package/dist/lib.js +1 -9
  5. package/package.json +47 -46
  6. package/src/lib/components/{ui/Alert → Alert}/Alert.jsx +17 -14
  7. package/src/lib/components/{ui/Alert → Alert}/Alert.scss +3 -3
  8. package/src/lib/components/{ui/Alert → Alert}/README.mdx +6 -6
  9. package/src/lib/components/{ui/Alert → Alert}/_settings.scss +1 -1
  10. package/src/lib/components/{ui/Alert → Alert}/_theme.scss +0 -0
  11. package/src/lib/components/{ui/Alert → Alert}/_tools.scss +0 -0
  12. package/src/lib/components/{ui/Alert → Alert}/index.js +0 -0
  13. package/src/lib/components/{ui/Badge → Badge}/Badge.jsx +2 -2
  14. package/src/lib/components/{ui/Badge → Badge}/Badge.scss +3 -3
  15. package/src/lib/components/{ui/Badge → Badge}/README.mdx +3 -3
  16. package/src/lib/components/{ui/Badge → Badge}/index.js +0 -0
  17. package/src/lib/components/Button/Button.jsx +198 -0
  18. package/src/lib/components/{ui/Button → Button}/Button.scss +0 -0
  19. package/src/lib/components/{ui/Button → Button}/README.mdx +161 -76
  20. package/src/lib/components/Button/_base.scss +148 -0
  21. package/src/lib/components/{ui/Button → Button}/_priorities.scss +0 -4
  22. package/src/lib/components/{ui/Button → Button}/_settings.scss +2 -3
  23. package/src/lib/components/{ui/Button → Button}/_theme.scss +3 -11
  24. package/src/lib/components/{ui/Button → Button}/_tools.scss +27 -44
  25. package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +33 -0
  26. package/src/lib/components/{ui/Button → Button}/helpers/getRootPriorityClassName.js +0 -4
  27. package/src/lib/components/{ui/Button → Button}/index.js +0 -0
  28. package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/ButtonGroup.jsx +9 -11
  29. package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/ButtonGroup.scss +0 -0
  30. package/src/lib/components/ButtonGroup/ButtonGroupContext.js +3 -0
  31. package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/README.mdx +30 -6
  32. package/src/lib/components/ButtonGroup/index.js +2 -0
  33. package/src/lib/components/{layout/CTA → CTA}/CTA.jsx +5 -2
  34. package/src/lib/components/{layout/CTA → CTA}/CTA.scss +2 -2
  35. package/src/lib/components/{layout/CTA → CTA}/CTACenter.jsx +1 -1
  36. package/src/lib/components/{layout/CTA → CTA}/CTAEnd.jsx +1 -1
  37. package/src/lib/components/{layout/CTA → CTA}/CTAStart.jsx +1 -1
  38. package/src/lib/components/{layout/CTA → CTA}/README.mdx +4 -4
  39. package/src/lib/components/{layout/CTA → CTA}/index.js +0 -0
  40. package/src/lib/components/{ui/Card → Card}/Card.jsx +6 -4
  41. package/src/lib/components/{ui/Card → Card}/Card.scss +1 -1
  42. package/src/lib/components/{ui/Card → Card}/CardBody.jsx +1 -1
  43. package/src/lib/components/{ui/Card → Card}/CardFooter.jsx +1 -1
  44. package/src/lib/components/{ui/Card → Card}/README.mdx +4 -4
  45. package/src/lib/components/{ui/Card → Card}/_theme.scss +0 -0
  46. package/src/lib/components/{ui/Card → Card}/_tools.scss +0 -0
  47. package/src/lib/components/{ui/Card → Card}/index.js +0 -0
  48. package/src/lib/components/{layout/Center → Center}/Center.jsx +1 -1
  49. package/src/lib/components/{layout/Center → Center}/Center.scss +0 -0
  50. package/src/lib/components/{layout/Center → Center}/README.mdx +2 -2
  51. package/src/lib/components/{layout/Center → Center}/index.js +0 -0
  52. package/src/lib/components/CheckboxField/CheckboxField.jsx +164 -0
  53. package/src/lib/components/{ui/CheckboxField → CheckboxField}/CheckboxField.scss +5 -5
  54. package/src/lib/components/{ui/CheckboxField → CheckboxField}/README.mdx +17 -14
  55. package/src/lib/components/{ui/CheckboxField → CheckboxField}/index.js +0 -0
  56. package/src/lib/components/FileInputField/FileInputField.jsx +162 -0
  57. package/src/lib/components/{ui/FileInputField → FileInputField}/FileInputField.scss +5 -5
  58. package/src/lib/components/{ui/FileInputField → FileInputField}/README.mdx +8 -6
  59. package/src/lib/components/{ui/FileInputField → FileInputField}/index.js +0 -0
  60. package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayout.jsx +16 -18
  61. package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayout.scss +3 -3
  62. package/src/lib/components/FormLayout/FormLayoutContext.js +3 -0
  63. package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayoutCustomField.jsx +33 -30
  64. package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayoutCustomField.scss +4 -4
  65. package/src/lib/components/{layout/FormLayout → FormLayout}/README.mdx +37 -47
  66. package/src/lib/components/{layout/FormLayout → FormLayout}/_theme.scss +0 -0
  67. package/src/lib/components/{layout/FormLayout → FormLayout}/index.js +1 -0
  68. package/src/lib/components/{layout/Grid → Grid}/Grid.jsx +23 -5
  69. package/src/lib/components/{layout/Grid → Grid}/Grid.scss +13 -4
  70. package/src/lib/components/{layout/Grid → Grid}/GridSpan.jsx +10 -3
  71. package/src/lib/components/{layout/Grid → Grid}/README.mdx +42 -38
  72. package/src/lib/components/{layout/Grid → Grid}/_theme.scss +1 -2
  73. package/src/lib/components/{layout/Grid → Grid}/_tools.scss +2 -2
  74. package/src/lib/components/{layout/Grid → Grid}/helpers/generateResponsiveCustomProperties.js +0 -0
  75. package/src/lib/components/{layout/Grid → Grid}/index.js +0 -0
  76. package/src/lib/components/Link/Link.jsx +45 -0
  77. package/src/lib/components/Link/Link.scss +11 -0
  78. package/src/lib/components/Link/README.mdx +85 -0
  79. package/src/lib/components/Link/_theme.scss +4 -0
  80. package/src/lib/components/Link/index.js +1 -0
  81. package/src/lib/components/{layout/List → List}/List.jsx +1 -1
  82. package/src/lib/components/{layout/List → List}/List.scss +2 -2
  83. package/src/lib/components/{layout/List → List}/ListItem.jsx +1 -1
  84. package/src/lib/components/{layout/List → List}/README.mdx +3 -3
  85. package/src/lib/components/{layout/List → List}/_theme.scss +0 -0
  86. package/src/lib/components/{layout/List → List}/index.js +0 -0
  87. package/src/lib/components/{layout/Media → Media}/Media.jsx +4 -2
  88. package/src/lib/components/{layout/Media → Media}/Media.scss +1 -1
  89. package/src/lib/components/{layout/Media → Media}/MediaBody.jsx +1 -1
  90. package/src/lib/components/{layout/Media → Media}/MediaObject.jsx +1 -1
  91. package/src/lib/components/{layout/Media → Media}/README.mdx +2 -2
  92. package/src/lib/components/{layout/Media → Media}/index.js +0 -0
  93. package/src/lib/components/{ui/Modal → Modal}/Modal.jsx +28 -27
  94. package/src/lib/components/{ui/Modal → Modal}/Modal.scss +5 -5
  95. package/src/lib/components/{ui/Modal → Modal}/README.mdx +42 -42
  96. package/src/lib/components/{ui/Modal → Modal}/_settings.scss +4 -4
  97. package/src/lib/components/{ui/Modal → Modal}/_theme.scss +0 -0
  98. package/src/lib/components/{ui/Modal → Modal}/index.js +0 -0
  99. package/src/lib/components/{ui/Paper → Paper}/Paper.jsx +8 -1
  100. package/src/lib/components/{ui/Paper → Paper}/Paper.scss +5 -0
  101. package/src/lib/components/{ui/Paper → Paper}/README.mdx +15 -3
  102. package/src/lib/components/{ui/Paper → Paper}/_theme.scss +2 -0
  103. package/src/lib/components/{ui/Paper → Paper}/index.js +0 -0
  104. package/src/lib/components/{ui/Radio → Radio}/README.mdx +20 -17
  105. package/src/lib/components/Radio/Radio.jsx +188 -0
  106. package/src/lib/components/{ui/Radio → Radio}/Radio.scss +9 -9
  107. package/src/lib/components/{ui/Radio → Radio}/index.js +0 -0
  108. package/src/lib/components/{ui/ScrollView → ScrollView}/README.mdx +11 -11
  109. package/src/lib/components/{ui/ScrollView → ScrollView}/ScrollView.jsx +9 -10
  110. package/src/lib/components/{ui/ScrollView → ScrollView}/ScrollView.scss +6 -6
  111. package/src/lib/components/{ui/ScrollView → ScrollView}/_theme.scss +0 -0
  112. package/src/lib/components/{ui/ScrollView → ScrollView}/index.js +0 -0
  113. package/src/lib/components/{ui/SelectField → SelectField}/README.mdx +47 -44
  114. package/src/lib/components/SelectField/SelectField.jsx +219 -0
  115. package/src/lib/components/{ui/SelectField → SelectField}/SelectField.scss +6 -6
  116. package/src/lib/components/{ui/SelectField → SelectField}/index.js +0 -0
  117. package/src/lib/components/{ui/Table → Table}/README.mdx +10 -10
  118. package/src/lib/components/{ui/Table → Table}/Table.jsx +9 -13
  119. package/src/lib/components/{ui/Table → Table}/Table.scss +1 -1
  120. package/src/lib/components/{ui/Table → Table}/_settings.scss +4 -4
  121. package/src/lib/components/{ui/Table → Table}/index.js +0 -0
  122. package/src/lib/components/{ui/Tabs → Tabs}/README.mdx +4 -4
  123. package/src/lib/components/{ui/Tabs → Tabs}/Tabs.jsx +4 -4
  124. package/src/lib/components/{ui/Tabs → Tabs}/Tabs.scss +1 -1
  125. package/src/lib/components/{ui/Tabs → Tabs}/TabsItem.jsx +4 -3
  126. package/src/lib/components/{ui/Tabs → Tabs}/TabsItem.scss +3 -3
  127. package/src/lib/components/{ui/Tabs → Tabs}/_theme.scss +0 -0
  128. package/src/lib/components/{ui/Tabs → Tabs}/index.js +0 -0
  129. package/src/lib/components/{ui/Text → Text}/README.mdx +19 -19
  130. package/src/lib/components/{ui/Text → Text}/Text.jsx +1 -1
  131. package/src/lib/components/{ui/Text → Text}/Text.scss +0 -0
  132. package/src/lib/components/{ui/Text → Text}/helpers/getRootHyphensClassName.js +0 -0
  133. package/src/lib/components/{ui/Text → Text}/helpers/getRootWordWrappingClassName.js +0 -0
  134. package/src/lib/components/{ui/Text → Text}/index.js +0 -0
  135. package/src/lib/components/{ui/TextArea → TextArea}/README.mdx +8 -6
  136. package/src/lib/components/{ui/TextArea → TextArea}/TextArea.jsx +78 -78
  137. package/src/lib/components/{ui/TextArea → TextArea}/TextArea.scss +6 -6
  138. package/src/lib/components/{ui/TextArea → TextArea}/index.js +0 -0
  139. package/src/lib/components/{ui/TextField → TextField}/README.mdx +7 -6
  140. package/src/lib/components/{ui/TextField → TextField}/TextField.jsx +20 -22
  141. package/src/lib/components/{ui/TextField → TextField}/TextField.scss +6 -6
  142. package/src/lib/components/{ui/TextField → TextField}/index.js +0 -0
  143. package/src/lib/components/{ui/Toggle → Toggle}/README.mdx +17 -14
  144. package/src/lib/components/Toggle/Toggle.jsx +163 -0
  145. package/src/lib/components/{ui/Toggle → Toggle}/Toggle.scss +5 -5
  146. package/src/lib/components/{ui/Toggle → Toggle}/index.js +0 -0
  147. package/src/lib/components/{layout/Toolbar → Toolbar}/README.mdx +29 -29
  148. package/src/lib/components/{layout/Toolbar → Toolbar}/Toolbar.jsx +1 -1
  149. package/src/lib/components/{layout/Toolbar → Toolbar}/Toolbar.scss +1 -1
  150. package/src/lib/components/{layout/Toolbar → Toolbar}/ToolbarGroup.jsx +1 -1
  151. package/src/lib/components/{layout/Toolbar → Toolbar}/ToolbarItem.jsx +1 -1
  152. package/src/lib/components/{layout/Toolbar → Toolbar}/_theme.scss +0 -0
  153. package/src/lib/components/{layout/Toolbar → Toolbar}/index.js +0 -0
  154. package/src/lib/components/{ui/withForwardedRef.jsx → withForwardedRef.jsx} +0 -0
  155. package/src/lib/helpers/resolveContextOrProp.js +7 -0
  156. package/src/lib/index.js +34 -35
  157. package/src/lib/styles/tools/_accessibility.scss +9 -0
  158. package/src/lib/theme.scss +25 -7
  159. package/src/lib/components/ui/Button/Button.jsx +0 -191
  160. package/src/lib/components/ui/Button/_base.scss +0 -154
  161. package/src/lib/components/ui/Button/helpers/getRootLabelVisibilityClassName.js +0 -11
  162. package/src/lib/components/ui/ButtonGroup/index.js +0 -1
  163. package/src/lib/components/ui/CheckboxField/CheckboxField.jsx +0 -173
  164. package/src/lib/components/ui/FileInputField/FileInputField.jsx +0 -158
  165. package/src/lib/components/ui/Radio/Radio.jsx +0 -179
  166. package/src/lib/components/ui/SelectField/SelectField.jsx +0 -214
  167. package/src/lib/components/ui/Toggle/Toggle.jsx +0 -174
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: SelectField
3
- menu: 'UI'
4
- route: /components/ui/select-field
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',
@@ -56,13 +56,13 @@ See [API](#api) for all available options.
56
56
  ## General Guidelines
57
57
 
58
58
  - Use SelectField for **many options**. For sets of just a few options
59
- (say 3 at maximum) consider using the [Radio](/components/ui/radio) component.
59
+ (say 3 at maximum) consider using the [Radio](/components/radio) component.
60
60
  This will help keep your UI clean and uncluttered and prevent your users from
61
61
  being overwhelmed by too many options.
62
62
 
63
63
  - **Don't use for boolean** (true/false) selection or to toggle things on and
64
- off. [CheckboxField](/components/ui/checkbox-field) and
65
- [Toggle](/components/ui/toggle) are more suitable for such cases.
64
+ off. [CheckboxField](/components/checkbox-field) and
65
+ [Toggle](/components/toggle) are more suitable for such cases.
66
66
 
67
67
  - Use **short and descriptive labels**, ideally nouns rather than seemingly
68
68
  polite phrases like _Please select your favourite fruit_. Short labels will
@@ -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
- value={fruit}
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 add any custom attributes that do not
600
- interfere with the API, and they will be passed to the `select` HTML element.
601
- This is useful mainly to improve component's accessibility.
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 '../../../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';
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 {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: Table
3
- menu: 'UI'
4
- route: /components/ui/table
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 '../../../../docs/_components/Icon'
15
+ import Icon from '../../../docs/_components/Icon'
16
16
  import ScrollView from '../ScrollView'
17
17
  import { Table } from './Table'
18
18
 
@@ -77,16 +77,16 @@ See [API](#api) for all available options.
77
77
 
78
78
  - Tables are **good for displaying complex tabular data.** For simpler data sets
79
79
  or even plain key-value pairs, consider using the
80
- [List](/components/layout/list) component.
80
+ [List](/components/list) component.
81
81
 
82
82
  - Tables make **lots of information easier to scan and compare.** If you have
83
83
  fewer sections and want to emphasize each group more, consider using
84
- [Cards](/components/ui/card).
84
+ [Cards](/components/card).
85
85
 
86
86
  ## Responsive Tables
87
87
 
88
88
  The easiest way to make tables responsive is to wrap them with the
89
- [ScrollView](/components/ui/scroll-view) component in the horizontal mode.
89
+ [ScrollView](/components/scroll-view) component in the horizontal mode.
90
90
 
91
91
  <Playground>
92
92
  <ScrollView direction="horizontal" shadowSize="100px">
@@ -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
- changeHandler: (column, direction) => {
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
  );