@react-ui-org/react-ui 0.48.0 → 0.50.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. package/dist/lib.development.js +162 -66
  2. package/dist/lib.js +1 -1
  3. package/package.json +1 -1
  4. package/src/lib/components/Alert/Alert.jsx +3 -0
  5. package/src/lib/components/Alert/Alert.scss +10 -10
  6. package/src/lib/components/Alert/README.mdx +14 -0
  7. package/src/lib/components/Badge/Badge.jsx +4 -8
  8. package/src/lib/components/Badge/Badge.scss +21 -21
  9. package/src/lib/components/Badge/README.mdx +14 -0
  10. package/src/lib/components/Button/Button.jsx +2 -13
  11. package/src/lib/components/Button/README.mdx +17 -5
  12. package/src/lib/components/Button/_base.scss +20 -20
  13. package/src/lib/components/Button/_priorities.scss +35 -35
  14. package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +7 -7
  15. package/src/lib/components/Button/helpers/getRootPriorityClassName.js +3 -3
  16. package/src/lib/components/ButtonGroup/ButtonGroup.jsx +0 -7
  17. package/src/lib/components/ButtonGroup/README.mdx +14 -0
  18. package/src/lib/components/Card/Card.jsx +6 -10
  19. package/src/lib/components/Card/Card.scss +13 -13
  20. package/src/lib/components/Card/CardBody.jsx +6 -10
  21. package/src/lib/components/Card/CardFooter.jsx +6 -7
  22. package/src/lib/components/Card/README.mdx +14 -0
  23. package/src/lib/components/CheckboxField/CheckboxField.jsx +1 -27
  24. package/src/lib/components/CheckboxField/README.mdx +17 -5
  25. package/src/lib/components/FileInputField/FileInputField.jsx +2 -12
  26. package/src/lib/components/FileInputField/FileInputField.scss +3 -7
  27. package/src/lib/components/FileInputField/README.mdx +29 -27
  28. package/src/lib/components/FormLayout/FormLayout.jsx +5 -9
  29. package/src/lib/components/FormLayout/FormLayout.scss +3 -3
  30. package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +4 -1
  31. package/src/lib/components/FormLayout/FormLayoutCustomField.scss +8 -8
  32. package/src/lib/components/FormLayout/README.mdx +13 -0
  33. package/src/lib/components/Grid/Grid.jsx +0 -7
  34. package/src/lib/components/Grid/GridSpan.jsx +0 -7
  35. package/src/lib/components/Grid/README.mdx +14 -0
  36. package/src/lib/components/Modal/Modal.jsx +7 -11
  37. package/src/lib/components/Modal/ModalBody.jsx +3 -7
  38. package/src/lib/components/Modal/ModalCloseButton.jsx +0 -16
  39. package/src/lib/components/Modal/ModalContent.jsx +3 -7
  40. package/src/lib/components/Modal/ModalFooter.jsx +3 -7
  41. package/src/lib/components/Modal/ModalFooter.scss +5 -5
  42. package/src/lib/components/Modal/ModalHeader.jsx +3 -7
  43. package/src/lib/components/Modal/ModalHeader.scss +5 -5
  44. package/src/lib/components/Modal/ModalTitle.jsx +6 -7
  45. package/src/lib/components/Modal/README.mdx +32 -6
  46. package/src/lib/components/Modal/_helpers/getJustifyClassName.js +5 -5
  47. package/src/lib/components/Paper/Paper.jsx +5 -9
  48. package/src/lib/components/Paper/Paper.scss +2 -2
  49. package/src/lib/components/Paper/README.mdx +14 -0
  50. package/src/lib/components/Popover/Popover.jsx +0 -16
  51. package/src/lib/components/Popover/PopoverWrapper.jsx +0 -7
  52. package/src/lib/components/Popover/README.mdx +19 -0
  53. package/src/lib/components/Radio/README.mdx +12 -5
  54. package/src/lib/components/Radio/Radio.jsx +2 -2
  55. package/src/lib/components/Radio/Radio.scss +3 -3
  56. package/src/lib/components/ScrollView/README.mdx +19 -0
  57. package/src/lib/components/ScrollView/ScrollView.jsx +11 -4
  58. package/src/lib/components/SelectField/README.mdx +17 -5
  59. package/src/lib/components/SelectField/SelectField.jsx +3 -22
  60. package/src/lib/components/SelectField/SelectField.scss +8 -8
  61. package/src/lib/components/Table/README.mdx +21 -7
  62. package/src/lib/components/Table/Table.jsx +43 -101
  63. package/src/lib/components/Table/Table.scss +0 -24
  64. package/src/lib/components/Table/_components/TableBodyCell/TableBodyCell.jsx +46 -0
  65. package/src/lib/components/Table/_components/TableBodyCell/index.js +1 -0
  66. package/src/lib/components/Table/_components/TableCell.scss +25 -0
  67. package/src/lib/components/Table/_components/TableHeaderCell/TableHeaderCell.jsx +71 -0
  68. package/src/lib/components/Table/_components/TableHeaderCell/index.js +1 -0
  69. package/src/lib/components/Tabs/README.mdx +16 -0
  70. package/src/lib/components/Tabs/Tabs.jsx +6 -1
  71. package/src/lib/components/Tabs/TabsItem.jsx +3 -0
  72. package/src/lib/components/Text/README.mdx +16 -0
  73. package/src/lib/components/Text/Text.jsx +3 -7
  74. package/src/lib/components/Text/Text.scss +6 -6
  75. package/src/lib/components/Text/_helpers/getRootClampClassName.js +2 -2
  76. package/src/lib/components/Text/_helpers/getRootHyphensClassName.js +2 -2
  77. package/src/lib/components/Text/_helpers/getRootWordWrappingClassName.js +2 -2
  78. package/src/lib/components/TextArea/README.mdx +33 -30
  79. package/src/lib/components/TextArea/TextArea.jsx +3 -43
  80. package/src/lib/components/TextArea/TextArea.scss +8 -8
  81. package/src/lib/components/TextField/README.mdx +53 -51
  82. package/src/lib/components/TextField/TextField.jsx +3 -29
  83. package/src/lib/components/TextField/TextField.scss +9 -9
  84. package/src/lib/components/TextLink/README.mdx +12 -5
  85. package/src/lib/components/TextLink/TextLink.jsx +0 -10
  86. package/src/lib/components/Toggle/README.mdx +17 -5
  87. package/src/lib/components/Toggle/Toggle.jsx +1 -27
  88. package/src/lib/components/Toolbar/README.mdx +13 -0
  89. package/src/lib/components/Toolbar/Toolbar.jsx +9 -43
  90. package/src/lib/components/Toolbar/Toolbar.scss +24 -12
  91. package/src/lib/components/Toolbar/ToolbarGroup.jsx +7 -26
  92. package/src/lib/components/Toolbar/ToolbarItem.jsx +3 -7
  93. package/src/lib/components/Toolbar/_helpers/getAlignClassName.js +19 -0
  94. package/src/lib/components/Toolbar/_helpers/getJustifyClassName.js +16 -0
  95. package/src/lib/components/_helpers/getRootColorClassName.js +10 -10
  96. package/src/lib/components/_helpers/getRootSizeClassName.js +3 -3
  97. package/src/lib/styles/generic/_forms.scss +10 -6
  98. package/src/lib/styles/theme/_accessibility.scss +2 -0
  99. package/src/lib/styles/theme/_form-fields.scss +1 -0
  100. package/src/lib/styles/tools/_accessibility.scss +2 -0
  101. package/src/lib/styles/tools/form-fields/_box-field-layout.scss +15 -15
  102. package/src/lib/styles/tools/form-fields/_foundation.scss +2 -0
  103. package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +1 -1
  104. package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +9 -9
  105. package/src/lib/theme.scss +4 -1
@@ -11,7 +11,6 @@ import styles from './TextArea.scss';
11
11
 
12
12
  export const TextArea = React.forwardRef((props, ref) => {
13
13
  const {
14
- cols,
15
14
  disabled,
16
15
  fullWidth,
17
16
  helpText,
@@ -19,13 +18,10 @@ export const TextArea = React.forwardRef((props, ref) => {
19
18
  isLabelVisible,
20
19
  label,
21
20
  layout,
22
- placeholder,
23
21
  required,
24
- rows,
25
22
  size,
26
23
  validationState,
27
24
  validationText,
28
- value,
29
25
  variant,
30
26
  ...restProps
31
27
  } = props;
@@ -39,13 +35,13 @@ export const TextArea = React.forwardRef((props, ref) => {
39
35
  fullWidth && styles.isRootFullWidth,
40
36
  context && styles.isRootInFormLayout,
41
37
  resolveContextOrProp(context && context.layout, layout) === 'horizontal'
42
- ? styles.rootLayoutHorizontal
43
- : styles.rootLayoutVertical,
38
+ ? styles.isRootLayoutHorizontal
39
+ : styles.isRootLayoutVertical,
44
40
  disabled && styles.isRootDisabled,
45
41
  required && styles.isRootRequired,
46
42
  getRootSizeClassName(size, styles),
47
43
  getRootValidationStateClassName(validationState, styles),
48
- variant === 'filled' ? styles.rootVariantFilled : styles.rootVariantOutline,
44
+ variant === 'filled' ? styles.isRootVariantFilled : styles.isRootVariantOutline,
49
45
  )}
50
46
  htmlFor={id}
51
47
  id={id && `${id}__label`}
@@ -64,14 +60,10 @@ export const TextArea = React.forwardRef((props, ref) => {
64
60
  <textarea
65
61
  {...transferProps(restProps)}
66
62
  className={styles.input}
67
- cols={cols}
68
63
  disabled={disabled}
69
64
  id={id}
70
- placeholder={placeholder}
71
65
  ref={ref}
72
66
  required={required}
73
- rows={rows}
74
- value={value}
75
67
  />
76
68
  {variant === 'filled' && (
77
69
  <div className={styles.bottomLine} />
@@ -99,29 +91,20 @@ export const TextArea = React.forwardRef((props, ref) => {
99
91
  });
100
92
 
101
93
  TextArea.defaultProps = {
102
- cols: null,
103
94
  disabled: false,
104
95
  fullWidth: false,
105
96
  helpText: null,
106
97
  id: undefined,
107
98
  isLabelVisible: true,
108
99
  layout: 'vertical',
109
- placeholder: null,
110
- ref: undefined,
111
100
  required: false,
112
- rows: 3,
113
101
  size: 'medium',
114
102
  validationState: null,
115
103
  validationText: null,
116
- value: undefined,
117
104
  variant: 'outline',
118
105
  };
119
106
 
120
107
  TextArea.propTypes = {
121
- /**
122
- * The number of visible text columns for the control.
123
- */
124
- cols: PropTypes.number,
125
108
  /**
126
109
  * If `true`, the input will be disabled.
127
110
  */
@@ -157,26 +140,10 @@ TextArea.propTypes = {
157
140
  * as the value is inherited in such case.
158
141
  */
159
142
  layout: PropTypes.oneOf(['horizontal', 'vertical']),
160
- /**
161
- * Optional example value.
162
- */
163
- placeholder: PropTypes.string,
164
143
  /**
165
144
  * If `true`, the input will be required.
166
145
  */
167
- /**
168
- * Reference forwarded to the `textarea` element.
169
- */
170
- ref: PropTypes.oneOfType([
171
- PropTypes.func,
172
- // eslint-disable-next-line react/forbid-prop-types
173
- PropTypes.shape({ current: PropTypes.any }),
174
- ]),
175
146
  required: PropTypes.bool,
176
- /**
177
- * The number of visible text lines for the control.
178
- */
179
- rows: PropTypes.number,
180
147
  /**
181
148
  * Size of the field.
182
149
  */
@@ -189,13 +156,6 @@ TextArea.propTypes = {
189
156
  * Validation message to be displayed.
190
157
  */
191
158
  validationText: PropTypes.node,
192
- /**
193
- * Value of the input.
194
- */
195
- value: PropTypes.oneOfType([
196
- PropTypes.string,
197
- PropTypes.number,
198
- ]),
199
159
  /**
200
160
  * Design variant of the field, further customizable with CSS custom properties.
201
161
  */
@@ -37,11 +37,11 @@
37
37
  }
38
38
 
39
39
  // Visual variants
40
- .rootVariantFilled {
40
+ .isRootVariantFilled {
41
41
  @include variants.visual(box, $variant: filled);
42
42
  }
43
43
 
44
- .rootVariantOutline {
44
+ .isRootVariantOutline {
45
45
  @include variants.visual(box, $variant: outline);
46
46
  }
47
47
 
@@ -64,12 +64,12 @@
64
64
  }
65
65
 
66
66
  // Layouts
67
- .rootLayoutVertical,
68
- .rootLayoutHorizontal {
67
+ .isRootLayoutVertical,
68
+ .isRootLayoutHorizontal {
69
69
  @include box-field-layout.vertical();
70
70
  }
71
71
 
72
- .rootLayoutHorizontal {
72
+ .isRootLayoutHorizontal {
73
73
  @include box-field-layout.horizontal();
74
74
  }
75
75
 
@@ -82,14 +82,14 @@
82
82
  }
83
83
 
84
84
  // Sizes
85
- .rootSizeSmall {
85
+ .isRootSizeSmall {
86
86
  @include box-field-sizes.size(small, $is-multiline: true);
87
87
  }
88
88
 
89
- .rootSizeMedium {
89
+ .isRootSizeMedium {
90
90
  @include box-field-sizes.size(medium, $is-multiline: true);
91
91
  }
92
92
 
93
- .rootSizeLarge {
93
+ .isRootSizeLarge {
94
94
  @include box-field-sizes.size(large, $is-multiline: true);
95
95
  }
@@ -215,47 +215,6 @@ DOM for numeric inputs.
215
215
  />
216
216
  </Playground>
217
217
 
218
- ## Forwarding HTML Attributes
219
-
220
- When you want to improve the accessibility of your text fields even further, you
221
- can **add whatever HTML attribute you like.** All attributes that don't
222
- interfere with [component's API](#api) are forwarded to the native HTML input.
223
-
224
- <Playground>
225
- <TextField
226
- label="Address"
227
- autoComplete="street-address"
228
- minLength={3}
229
- maxLength={80}
230
- />
231
- <TextField
232
- label="Address"
233
- variant="filled"
234
- autoComplete="street-address"
235
- minLength={3}
236
- maxLength={80}
237
- />
238
- <TextField
239
- inputSize={3}
240
- min={13}
241
- max={120}
242
- label="Age"
243
- type="number"
244
- />
245
- <TextField
246
- inputSize={3}
247
- min={13}
248
- max={120}
249
- label="Age"
250
- type="number"
251
- variant="filled"
252
- />
253
- </Playground>
254
-
255
- 👉 Refer to the MDN reference for the full list of supported attributes of the
256
- [text][input-text], [email][input-email], [number][input-number],
257
- [tel][input-tel], and [password][input-password] input types.
258
-
259
218
  ## Invisible Label
260
219
 
261
220
  In some cases, it may be convenient to visually hide the field label. The label
@@ -489,12 +448,54 @@ It's possible to disable the whole input.
489
448
  />
490
449
  </Playground>
491
450
 
492
- ## API
451
+ ## Forwarding HTML Attributes
493
452
 
494
- In addition to the options below, you can specify [React synthetic events] or
495
- any custom HTML attributes that do not interfere with the API, and they will be
496
- passed to the `<input>` HTML element. This enables making the component
497
- interactive and helps improve its [accessibility](#forwarding-html-attributes).
453
+ In addition to the options below in the [component's API](#api) section, you
454
+ can specify [React synthetic events] or you can **add whatever HTML attribute
455
+ you like.** All attributes that don't interfere with the API are forwarded to
456
+ the native HTML `<input>`. This enables making the component interactive and
457
+ helps to improve its accessibility.
458
+
459
+ <Playground>
460
+ <TextField
461
+ label="Address"
462
+ autoComplete="street-address"
463
+ minLength={3}
464
+ maxLength={80}
465
+ />
466
+ <TextField
467
+ label="Address"
468
+ variant="filled"
469
+ autoComplete="street-address"
470
+ minLength={3}
471
+ maxLength={80}
472
+ />
473
+ <TextField
474
+ inputSize={3}
475
+ min={13}
476
+ max={120}
477
+ label="Age"
478
+ type="number"
479
+ />
480
+ <TextField
481
+ inputSize={3}
482
+ min={13}
483
+ max={120}
484
+ label="Age"
485
+ type="number"
486
+ variant="filled"
487
+ />
488
+ </Playground>
489
+
490
+ 👉 Refer to the MDN reference for the full list of supported attributes of the
491
+ [text][input-text], [email][input-email], [number][input-number],
492
+ [tel][input-tel], and [password][input-password] input types.
493
+
494
+ ## Forwarding ref
495
+
496
+ If you provide [ref], it is forwarded to the native HTML `<input>` element.
497
+
498
+ ## API
498
499
 
499
500
  <Props table of={TextField} />
500
501
 
@@ -507,10 +508,11 @@ Head to [Forms Theming][theming-forms] to see shared form theming options.
507
508
  [size]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text#size
508
509
  [max]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#max
509
510
  [input-number-size]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#Controlling_input_size
510
- [input-text]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text
511
- [input-email]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email
512
- [input-number]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number
513
- [input-tel]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel
514
- [input-password]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password
511
+ [input-text]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text#additional_attributes
512
+ [input-email]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#additional_attributes
513
+ [input-number]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#additional_attributes
514
+ [input-tel]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel#additional_attributes
515
+ [input-password]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password#additional_attributes
515
516
  [theming-forms]: /customize/theming/forms
516
517
  [React synthetic events]: https://reactjs.org/docs/events.html
518
+ [ref]: https://reactjs.org/docs/refs-and-the-dom.html
@@ -21,13 +21,11 @@ export const TextField = React.forwardRef((props, ref) => {
21
21
  isLabelVisible,
22
22
  label,
23
23
  layout,
24
- placeholder,
25
24
  required,
26
25
  size,
27
26
  type,
28
27
  validationState,
29
28
  validationText,
30
- value,
31
29
  variant,
32
30
  ...restProps
33
31
  } = props;
@@ -43,13 +41,13 @@ export const TextField = React.forwardRef((props, ref) => {
43
41
  inputSize && styles.hasRootCustomInputSize,
44
42
  context && styles.isRootInFormLayout,
45
43
  resolveContextOrProp(context && context.layout, layout) === 'horizontal'
46
- ? styles.rootLayoutHorizontal
47
- : styles.rootLayoutVertical,
44
+ ? styles.isRootLayoutHorizontal
45
+ : styles.isRootLayoutVertical,
48
46
  disabled && styles.isRootDisabled,
49
47
  required && styles.isRootRequired,
50
48
  getRootSizeClassName(size, styles),
51
49
  getRootValidationStateClassName(validationState, styles),
52
- variant === 'filled' ? styles.rootVariantFilled : styles.rootVariantOutline,
50
+ variant === 'filled' ? styles.isRootVariantFilled : styles.isRootVariantOutline,
53
51
  )}
54
52
  htmlFor={id}
55
53
  id={id && `${id}__label`}
@@ -71,12 +69,10 @@ export const TextField = React.forwardRef((props, ref) => {
71
69
  className={styles.input}
72
70
  disabled={disabled}
73
71
  id={id}
74
- placeholder={placeholder}
75
72
  ref={ref}
76
73
  required={required}
77
74
  size={type !== 'number' ? inputSize : null}
78
75
  type={type}
79
- value={value}
80
76
  />
81
77
  {variant === 'filled' && (
82
78
  <div className={styles.bottomLine} />
@@ -111,14 +107,11 @@ TextField.defaultProps = {
111
107
  inputSize: null,
112
108
  isLabelVisible: true,
113
109
  layout: 'vertical',
114
- placeholder: null,
115
- ref: undefined,
116
110
  required: false,
117
111
  size: 'medium',
118
112
  type: 'text',
119
113
  validationState: null,
120
114
  validationText: null,
121
- value: undefined,
122
115
  variant: 'outline',
123
116
  };
124
117
 
@@ -163,18 +156,6 @@ TextField.propTypes = {
163
156
  * as the value is inherited in such case.
164
157
  */
165
158
  layout: PropTypes.oneOf(['horizontal', 'vertical']),
166
- /**
167
- * Optional example value.
168
- */
169
- placeholder: PropTypes.string,
170
- /**
171
- * Reference forwarded to the `input` element.
172
- */
173
- ref: PropTypes.oneOfType([
174
- PropTypes.func,
175
- // eslint-disable-next-line react/forbid-prop-types
176
- PropTypes.shape({ current: PropTypes.any }),
177
- ]),
178
159
  /**
179
160
  * If `true`, the input will be required.
180
161
  */
@@ -195,13 +176,6 @@ TextField.propTypes = {
195
176
  * Validation message to be displayed.
196
177
  */
197
178
  validationText: PropTypes.node,
198
- /**
199
- * Value of the input.
200
- */
201
- value: PropTypes.oneOfType([
202
- PropTypes.string,
203
- PropTypes.number,
204
- ]),
205
179
  /**
206
180
  * Design variant of the field, further customizable with CSS custom properties.
207
181
  */
@@ -40,11 +40,11 @@
40
40
  }
41
41
 
42
42
  // Variants
43
- .rootVariantFilled {
43
+ .isRootVariantFilled {
44
44
  @include variants.visual(box, $variant: filled);
45
45
  }
46
46
 
47
- .rootVariantOutline {
47
+ .isRootVariantOutline {
48
48
  @include variants.visual(box, $variant: outline);
49
49
  }
50
50
 
@@ -67,12 +67,12 @@
67
67
  }
68
68
 
69
69
  // Layouts
70
- .rootLayoutVertical,
71
- .rootLayoutHorizontal {
70
+ .isRootLayoutVertical,
71
+ .isRootLayoutHorizontal {
72
72
  @include box-field-layout.vertical();
73
73
  }
74
74
 
75
- .rootLayoutHorizontal {
75
+ .isRootLayoutHorizontal {
76
76
  @include box-field-layout.horizontal();
77
77
  }
78
78
 
@@ -84,19 +84,19 @@
84
84
  @include box-field-layout.in-form-layout();
85
85
  }
86
86
 
87
- .hasRootSmallInput.rootLayoutHorizontal {
87
+ .hasRootSmallInput.isRootLayoutHorizontal {
88
88
  @include box-field-layout.horizontal-with-small-input();
89
89
  }
90
90
 
91
91
  // Sizes
92
- .rootSizeSmall {
92
+ .isRootSizeSmall {
93
93
  @include box-field-sizes.size(small);
94
94
  }
95
95
 
96
- .rootSizeMedium {
96
+ .isRootSizeMedium {
97
97
  @include box-field-sizes.size(medium);
98
98
  }
99
99
 
100
- .rootSizeLarge {
100
+ .isRootSizeLarge {
101
101
  @include box-field-sizes.size(large);
102
102
  }
@@ -56,12 +56,18 @@ It's common to use custom function for routing within SPAs. Use the
56
56
  />
57
57
  </Playground>
58
58
 
59
- ## API
59
+ ## Forwarding HTML Attributes
60
+
61
+ In addition to the options below in the [component's API](#api) section, you
62
+ can specify [React synthetic events] or **any HTML attribute you like.** All
63
+ attributes that don't interfere with the API are forwarded to the `<a>` HTML
64
+ element. This enables making the component interactive and helps to improve its
65
+ accessibility.
60
66
 
61
- In addition to the options below, you can specify [React synthetic events] or
62
- any custom HTML attributes that do not interfere with the API, and they will be
63
- passed to the `<a>` HTML element. This enables making the component interactive
64
- and helps improve its accessibility.
67
+ 👉 Refer to the MDN reference for the full list of supported attributes of the
68
+ [a] element.
69
+
70
+ ## API
65
71
 
66
72
  <Props table of={TextLink} />
67
73
 
@@ -75,3 +81,4 @@ and helps improve its accessibility.
75
81
  | `--rui-TextLink--hover__text-decoration` | Text decoration on hover |
76
82
 
77
83
  [React synthetic events]: https://reactjs.org/docs/events.html
84
+ [a]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes
@@ -6,7 +6,6 @@ import styles from './TextLink.scss';
6
6
 
7
7
  export const TextLink = ({
8
8
  href,
9
- id,
10
9
  label,
11
10
  ...restProps
12
11
  }) => (
@@ -14,25 +13,16 @@ export const TextLink = ({
14
13
  {...transferProps(restProps)}
15
14
  href={href}
16
15
  className={styles.root}
17
- id={id}
18
16
  >
19
17
  {label}
20
18
  </a>
21
19
  );
22
20
 
23
- TextLink.defaultProps = {
24
- id: undefined,
25
- };
26
-
27
21
  TextLink.propTypes = {
28
22
  /**
29
23
  * Link's `href` attribute.
30
24
  */
31
25
  href: PropTypes.string.isRequired,
32
- /**
33
- * ID of the root HTML element.
34
- */
35
- id: PropTypes.string,
36
26
  /**
37
27
  * Link label.
38
28
  */
@@ -177,12 +177,22 @@ Disabled state makes the input unavailable.
177
177
  />
178
178
  </Playground>
179
179
 
180
- ## API
180
+ ## Forwarding HTML Attributes
181
+
182
+ In addition to the options below in the [component's API](#api) section, you
183
+ can specify [React synthetic events] or you can **add whatever HTML attribute
184
+ you like.** All attributes that don't interfere with the API are forwarded to
185
+ the native HTML `<input>`. This enables making the component interactive and
186
+ helps to improve its accessibility.
187
+
188
+ 👉 Refer to the MDN reference for the full list of supported attributes of the
189
+ [checkbox] input type.
181
190
 
182
- In addition to the options below, you can specify [React synthetic events] or
183
- any custom HTML attributes that do not interfere with the API, and they will be
184
- passed to the `<input>` HTML element. This enables making the component
185
- interactive and helps improve its accessibility.
191
+ ## Forwarding ref
192
+
193
+ If you provide [ref], it is forwarded to the native HTML `<input>` element.
194
+
195
+ ## API
186
196
 
187
197
  <Props table of={Toggle} />
188
198
 
@@ -202,3 +212,5 @@ options. On top of that, the following options are available for Toggle.
202
212
  | `--rui-FormField--check__input--toggle--checked__background-position` | Background position of checked input |
203
213
 
204
214
  [React synthetic events]: https://reactjs.org/docs/events.html
215
+ [checkbox]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#additional_attributes
216
+ [ref]: https://reactjs.org/docs/refs-and-the-dom.html
@@ -9,7 +9,6 @@ import styles from './Toggle.scss';
9
9
 
10
10
  export const Toggle = React.forwardRef((props, ref) => {
11
11
  const {
12
- checked,
13
12
  disabled,
14
13
  helpText,
15
14
  id,
@@ -19,7 +18,6 @@ export const Toggle = React.forwardRef((props, ref) => {
19
18
  required,
20
19
  validationState,
21
20
  validationText,
22
- value,
23
21
  ...restProps
24
22
  } = props;
25
23
 
@@ -30,7 +28,7 @@ export const Toggle = React.forwardRef((props, ref) => {
30
28
  className={classNames(
31
29
  styles.root,
32
30
  context && styles.isRootInFormLayout,
33
- context && context.layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
31
+ context && context.layout === 'horizontal' ? styles.isRootLayoutHorizontal : styles.isRootLayoutVertical,
34
32
  labelPosition === 'before' && styles.hasRootLabelBefore,
35
33
  disabled && styles.isRootDisabled,
36
34
  required && styles.isRootRequired,
@@ -51,7 +49,6 @@ export const Toggle = React.forwardRef((props, ref) => {
51
49
  </div>
52
50
  <input
53
51
  {...transferProps(restProps)}
54
- checked={checked}
55
52
  className={styles.input}
56
53
  disabled={disabled}
57
54
  id={id}
@@ -59,7 +56,6 @@ export const Toggle = React.forwardRef((props, ref) => {
59
56
  ref={ref}
60
57
  required={required}
61
58
  type="checkbox"
62
- value={value}
63
59
  />
64
60
  </div>
65
61
  {helpText && (
@@ -83,24 +79,17 @@ export const Toggle = React.forwardRef((props, ref) => {
83
79
  });
84
80
 
85
81
  Toggle.defaultProps = {
86
- checked: undefined,
87
82
  disabled: false,
88
83
  helpText: null,
89
84
  id: undefined,
90
85
  isLabelVisible: true,
91
86
  labelPosition: 'after',
92
- ref: undefined,
93
87
  required: false,
94
88
  validationState: null,
95
89
  validationText: null,
96
- value: undefined,
97
90
  };
98
91
 
99
92
  Toggle.propTypes = {
100
- /**
101
- * If `true`, the input will be checked.
102
- */
103
- checked: PropTypes.bool,
104
93
  /**
105
94
  * If `true`, the input will be disabled.
106
95
  */
@@ -130,14 +119,6 @@ Toggle.propTypes = {
130
119
  * Placement of the label relative to the input.
131
120
  */
132
121
  labelPosition: PropTypes.oneOf(['before', 'after']),
133
- /**
134
- * Reference forwarded to the `input` element.
135
- */
136
- ref: PropTypes.oneOfType([
137
- PropTypes.func,
138
- // eslint-disable-next-line react/forbid-prop-types
139
- PropTypes.shape({ current: PropTypes.any }),
140
- ]),
141
122
  /**
142
123
  * If `true`, the input will be required.
143
124
  */
@@ -150,13 +131,6 @@ Toggle.propTypes = {
150
131
  * Validation message to be displayed.
151
132
  */
152
133
  validationText: PropTypes.node,
153
- /**
154
- * Value of the input.
155
- */
156
- value: PropTypes.oneOfType([
157
- PropTypes.string,
158
- PropTypes.number,
159
- ]),
160
134
  };
161
135
 
162
136
  export const ToggleWithGlobalProps = withGlobalProps(Toggle, 'Toggle');
@@ -335,6 +335,17 @@ Or to build a classic media layout with image on the left and text on the right:
335
335
  </Toolbar>
336
336
  </Playground>
337
337
 
338
+ ## Forwarding HTML Attributes
339
+
340
+ In addition to the options below in the [component's API](#api) section, you
341
+ can specify [React synthetic events] or **any HTML attribute you like.** All
342
+ attributes that don't interfere with the API are forwarded to the root `<div>`
343
+ HTML element. This enables making the component interactive and helps to improve
344
+ its accessibility.
345
+
346
+ 👉 Refer to the MDN reference for the full list of supported attributes of the
347
+ [div] element.
348
+
338
349
  ## API
339
350
 
340
351
  <Props table of={Toolbar} />
@@ -363,3 +374,5 @@ A wrapper for individual toolbar items.
363
374
  [grid]: /components/grid
364
375
  [spacing]: /css-helpers/spacing
365
376
  [text]: /components/text
377
+ [React synthetic events]: https://reactjs.org/docs/events.html
378
+ [div]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes