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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/lib.development.js +160 -64
  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 -11
  26. package/src/lib/components/FileInputField/FileInputField.scss +3 -3
  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 +6 -10
  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 +25 -0
  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/tools/form-fields/_box-field-layout.scss +15 -15
  98. package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +1 -1
  99. package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +9 -9
@@ -2,31 +2,31 @@ export default (labelVisibility, styles) => {
2
2
  // Intentionally omitting `xs` which means label is visible on all screen sizes.
3
3
 
4
4
  if (labelVisibility === 'sm') {
5
- return styles.withLabelVisibleSm;
5
+ return styles.hasLabelVisibleSm;
6
6
  }
7
7
 
8
8
  if (labelVisibility === 'md') {
9
- return styles.withLabelVisibleMd;
9
+ return styles.hasLabelVisibleMd;
10
10
  }
11
11
 
12
12
  if (labelVisibility === 'lg') {
13
- return styles.withLabelVisibleLg;
13
+ return styles.hasLabelVisibleLg;
14
14
  }
15
15
 
16
16
  if (labelVisibility === 'xl') {
17
- return styles.withLabelVisibleXl;
17
+ return styles.hasLabelVisibleXl;
18
18
  }
19
19
 
20
20
  if (labelVisibility === 'x2l') {
21
- return styles.withLabelVisibleX2l;
21
+ return styles.hasLabelVisibleX2l;
22
22
  }
23
23
 
24
24
  if (labelVisibility === 'x3l') {
25
- return styles.withLabelVisibleX3l;
25
+ return styles.hasLabelVisibleX3l;
26
26
  }
27
27
 
28
28
  if (labelVisibility === 'none') {
29
- return styles.withLabelHidden;
29
+ return styles.hasLabelHidden;
30
30
  }
31
31
 
32
32
  return null;
@@ -1,14 +1,14 @@
1
1
  export default (priority, styles) => {
2
2
  if (priority === 'filled') {
3
- return styles.rootPriorityFilled;
3
+ return styles.isRootPriorityFilled;
4
4
  }
5
5
 
6
6
  if (priority === 'outline') {
7
- return styles.rootPriorityOutline;
7
+ return styles.isRootPriorityOutline;
8
8
  }
9
9
 
10
10
  if (priority === 'flat') {
11
- return styles.rootPriorityFlat;
11
+ return styles.isRootPriorityFlat;
12
12
  }
13
13
 
14
14
  return null;
@@ -11,7 +11,6 @@ export const ButtonGroup = ({
11
11
  block,
12
12
  disabled,
13
13
  children,
14
- id,
15
14
  priority,
16
15
  size,
17
16
  ...restProps
@@ -27,7 +26,6 @@ export const ButtonGroup = ({
27
26
  styles.root,
28
27
  block && styles.isRootBlock,
29
28
  )}
30
- id={id}
31
29
  role="group"
32
30
  >
33
31
  <ButtonGroupContext.Provider
@@ -48,7 +46,6 @@ ButtonGroup.defaultProps = {
48
46
  block: false,
49
47
  children: null,
50
48
  disabled: false,
51
- id: undefined,
52
49
  priority: 'filled',
53
50
  size: 'medium',
54
51
  };
@@ -66,10 +63,6 @@ ButtonGroup.propTypes = {
66
63
  * If `true`, all buttons inside the group will be disabled.
67
64
  */
68
65
  disabled: PropTypes.bool,
69
- /**
70
- * ID of the root HTML element.
71
- */
72
- id: PropTypes.string,
73
66
  /**
74
67
  * Visual priority to highlight or suppress the buttons.
75
68
  */
@@ -231,6 +231,17 @@ and communicating the state of individual options.
231
231
  </>
232
232
  </Playground>
233
233
 
234
+ ## Forwarding HTML Attributes
235
+
236
+ In addition to the options below in the [component's API](#api) section, you
237
+ can specify [React synthetic events] or **any HTML attribute you like.** All
238
+ attributes that don't interfere with the API are forwarded to the root `<div>`
239
+ HTML element. This enables making the component interactive and helps to improve
240
+ its accessibility.
241
+
242
+ 👉 Refer to the MDN reference for the full list of supported attributes of the
243
+ [div] element.
244
+
234
245
  ## API
235
246
 
236
247
  <Props table of={ButtonGroup} />
@@ -246,3 +257,6 @@ and communicating the state of individual options.
246
257
  | `--rui-ButtonGroup--flat__separator__width` | Separator width for `flat` buttons |
247
258
  | `--rui-ButtonGroup--flat__separator__color` | Separator color for `flat` buttons |
248
259
  | `--rui-ButtonGroup--outline__gap` | Gap between `outline` buttons |
260
+
261
+ [React synthetic events]: https://reactjs.org/docs/events.html
262
+ [div]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes
@@ -1,6 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
+ import { transferProps } from '../_helpers/transferProps';
4
5
  import { classNames } from '../../utils/classNames';
5
6
  import { getRootColorClassName } from '../_helpers/getRootColorClassName';
6
7
  import styles from './Card.scss';
@@ -9,19 +10,19 @@ export const Card = ({
9
10
  children,
10
11
  dense,
11
12
  disabled,
12
- id,
13
13
  raised,
14
14
  color,
15
+ ...restProps
15
16
  }) => (
16
17
  <div
18
+ {...transferProps(restProps)}
17
19
  className={classNames(
18
20
  styles.root,
19
21
  getRootColorClassName(color, styles),
20
- dense && styles.rootDense,
21
- raised && styles.rootRaised,
22
- disabled && styles.isDisabled,
22
+ dense && styles.isRootDense,
23
+ raised && styles.isRootRaised,
24
+ disabled && styles.isRootDisabled,
23
25
  )}
24
- id={id}
25
26
  >
26
27
  {children}
27
28
  </div>
@@ -31,7 +32,6 @@ Card.defaultProps = {
31
32
  color: 'light',
32
33
  dense: false,
33
34
  disabled: false,
34
- id: undefined,
35
35
  raised: false,
36
36
  };
37
37
 
@@ -57,10 +57,6 @@ Card.propTypes = {
57
57
  * If `true`, the card will be disabled.
58
58
  */
59
59
  disabled: PropTypes.bool,
60
- /**
61
- * ID of the root HTML element.
62
- */
63
- id: PropTypes.string,
64
60
  /**
65
61
  * Add shadow to pull the card above surface.
66
62
  */
@@ -25,55 +25,55 @@
25
25
  padding: var(--rui-local-padding);
26
26
  }
27
27
 
28
- .rootDense {
28
+ .isRootDense {
29
29
  --rui-local-padding: #{theme.$dense-padding};
30
30
  }
31
31
 
32
- .rootRaised {
32
+ .isRootRaised {
33
33
  box-shadow: theme.$raised-box-shadow;
34
34
  }
35
35
 
36
- .rootColorPrimary {
36
+ .isRootColorPrimary {
37
37
  @include tools.color(primary);
38
38
  }
39
39
 
40
- .rootColorSecondary {
40
+ .isRootColorSecondary {
41
41
  @include tools.color(secondary);
42
42
  }
43
43
 
44
- .rootColorSuccess {
44
+ .isRootColorSuccess {
45
45
  @include tools.color(success);
46
46
  }
47
47
 
48
- .rootColorWarning {
48
+ .isRootColorWarning {
49
49
  @include tools.color(warning);
50
50
  }
51
51
 
52
- .rootColorDanger {
52
+ .isRootColorDanger {
53
53
  @include tools.color(danger);
54
54
  }
55
55
 
56
- .rootColorHelp {
56
+ .isRootColorHelp {
57
57
  @include tools.color(help);
58
58
  }
59
59
 
60
- .rootColorInfo {
60
+ .isRootColorInfo {
61
61
  @include tools.color(info);
62
62
  }
63
63
 
64
- .rootColorNote {
64
+ .isRootColorNote {
65
65
  @include tools.color(note);
66
66
  }
67
67
 
68
- .rootColorLight {
68
+ .isRootColorLight {
69
69
  @include tools.color(light);
70
70
  }
71
71
 
72
- .rootColorDark {
72
+ .isRootColorDark {
73
73
  @include tools.color(dark);
74
74
  }
75
75
 
76
- .isDisabled {
76
+ .isRootDisabled {
77
77
  background-color: theme.$disabled-background-color;
78
78
  opacity: theme.$disabled-opacity;
79
79
  }
@@ -1,30 +1,26 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
+ import { transferProps } from '../_helpers/transferProps';
4
5
  import styles from './Card.scss';
5
6
 
6
7
  export const CardBody = ({
7
8
  children,
8
- id,
9
+ ...restProps
9
10
  }) => (
10
- <div className={styles.body} id={id}>
11
+ <div
12
+ {...transferProps(restProps)}
13
+ className={styles.body}
14
+ >
11
15
  {children}
12
16
  </div>
13
17
  );
14
18
 
15
- CardBody.defaultProps = {
16
- id: undefined,
17
- };
18
-
19
19
  CardBody.propTypes = {
20
20
  /**
21
21
  * Content of the card.
22
22
  */
23
23
  children: PropTypes.node.isRequired,
24
- /**
25
- * ID of the root HTML element.
26
- */
27
- id: PropTypes.string,
28
24
  };
29
25
 
30
26
  export const CardBodyWithGlobalProps = withGlobalProps(CardBody, 'CardBody');
@@ -2,18 +2,22 @@ import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
4
  import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
5
+ import { transferProps } from '../_helpers/transferProps';
5
6
  import styles from './Card.scss';
6
7
 
7
8
  export const CardFooter = ({
8
9
  children,
9
- id,
10
+ ...restProps
10
11
  }) => {
11
12
  if (isChildrenEmpty(children)) {
12
13
  return null;
13
14
  }
14
15
 
15
16
  return (
16
- <div className={styles.footer} id={id}>
17
+ <div
18
+ {...transferProps(restProps)}
19
+ className={styles.footer}
20
+ >
17
21
  {children}
18
22
  </div>
19
23
  );
@@ -21,7 +25,6 @@ export const CardFooter = ({
21
25
 
22
26
  CardFooter.defaultProps = {
23
27
  children: null,
24
- id: undefined,
25
28
  };
26
29
 
27
30
  CardFooter.propTypes = {
@@ -29,10 +32,6 @@ CardFooter.propTypes = {
29
32
  * Card actions, usually buttons.
30
33
  */
31
34
  children: PropTypes.node,
32
- /**
33
- * ID of the root HTML element.
34
- */
35
- id: PropTypes.string,
36
35
  };
37
36
 
38
37
  export const CardFooterWithGlobalProps = withGlobalProps(CardFooter, 'CardFooter');
@@ -280,6 +280,17 @@ its interactive elements to disallow user's interaction.
280
280
  </Card>
281
281
  </Playground>
282
282
 
283
+ ## Forwarding HTML Attributes
284
+
285
+ In addition to the options below in the [component's API](#api) section, you
286
+ can specify [React synthetic events] or **any HTML attribute you like.** All
287
+ attributes that don't interfere with the API are forwarded to the root `<div>`
288
+ HTML element. This enables making the component interactive and helps to improve
289
+ its accessibility.
290
+
291
+ 👉 Refer to the MDN reference for the full list of supported attributes of the
292
+ [div] element.
293
+
283
294
  ## API
284
295
 
285
296
  <Props table of={Card} />
@@ -326,3 +337,6 @@ Where:
326
337
  (see [color variants](#color-variants) and [API](#api)),
327
338
  - `<PROPERTY>` is one of `color` (color of text), `border-color`, or
328
339
  `background-color`.
340
+
341
+ [React synthetic events]: https://reactjs.org/docs/events.html
342
+ [div]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes
@@ -9,7 +9,6 @@ import styles from './CheckboxField.scss';
9
9
 
10
10
  export const CheckboxField = React.forwardRef((props, ref) => {
11
11
  const {
12
- checked,
13
12
  disabled,
14
13
  helpText,
15
14
  id,
@@ -19,7 +18,6 @@ export const CheckboxField = React.forwardRef((props, ref) => {
19
18
  required,
20
19
  validationState,
21
20
  validationText,
22
- value,
23
21
  ...restProps
24
22
  } = props;
25
23
  const context = useContext(FormLayoutContext);
@@ -29,7 +27,7 @@ export const CheckboxField = React.forwardRef((props, ref) => {
29
27
  className={classNames(
30
28
  styles.root,
31
29
  context && styles.isRootInFormLayout,
32
- context && context.layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
30
+ context && context.layout === 'horizontal' ? styles.isRootLayoutHorizontal : styles.isRootLayoutVertical,
33
31
  labelPosition === 'before' && styles.hasRootLabelBefore,
34
32
  disabled && styles.isRootDisabled,
35
33
  required && styles.isRootRequired,
@@ -50,14 +48,12 @@ export const CheckboxField = React.forwardRef((props, ref) => {
50
48
  </div>
51
49
  <input
52
50
  {...transferProps(restProps)}
53
- checked={checked}
54
51
  className={styles.input}
55
52
  disabled={disabled}
56
53
  id={id}
57
54
  ref={ref}
58
55
  required={required}
59
56
  type="checkbox"
60
- value={value}
61
57
  />
62
58
  </div>
63
59
  {helpText && (
@@ -81,24 +77,17 @@ export const CheckboxField = React.forwardRef((props, ref) => {
81
77
  });
82
78
 
83
79
  CheckboxField.defaultProps = {
84
- checked: undefined,
85
80
  disabled: false,
86
81
  helpText: null,
87
82
  id: undefined,
88
83
  isLabelVisible: true,
89
84
  labelPosition: 'after',
90
- ref: undefined,
91
85
  required: false,
92
86
  validationState: null,
93
87
  validationText: null,
94
- value: undefined,
95
88
  };
96
89
 
97
90
  CheckboxField.propTypes = {
98
- /**
99
- * If `true`, the input will be checked.
100
- */
101
- checked: PropTypes.bool,
102
91
  /**
103
92
  * If `true`, the input will be disabled.
104
93
  */
@@ -130,14 +119,6 @@ CheckboxField.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 @@ CheckboxField.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 CheckboxFieldWithGlobalProps = withGlobalProps(CheckboxField, 'CheckboxField');
@@ -181,12 +181,22 @@ Disabled state makes the input unavailable.
181
181
  />
182
182
  </Playground>
183
183
 
184
- ## API
184
+ ## Forwarding HTML Attributes
185
+
186
+ In addition to the options below in the [component's API](#api) section, you
187
+ can specify [React synthetic events] or you can **add whatever HTML attribute
188
+ you like.** All attributes that don't interfere with the API are forwarded to
189
+ the native HTML `<input>`. This enables making the component interactive and
190
+ helps to improve its accessibility.
191
+
192
+ 👉 Refer to the MDN reference for the full list of supported attributes of the
193
+ [checkbox] input type.
185
194
 
186
- In addition to the options below, you can specify [React synthetic events] or
187
- any custom HTML attributes that do not interfere with the API, and they will be
188
- passed to the `<input>` HTML element. This enables making the component
189
- interactive and helps improve its accessibility.
195
+ ## Forwarding ref
196
+
197
+ If you provide [ref], it is forwarded to the native HTML `<input>` element.
198
+
199
+ ## API
190
200
 
191
201
  <Props table of={CheckboxField} />
192
202
 
@@ -201,3 +211,5 @@ options. On top of that, the following options are available for CheckboxField.
201
211
  | `--rui-FormField--check__input--checkbox--checked__background-image` | Background image of checked input |
202
212
 
203
213
  [React synthetic events]: https://reactjs.org/docs/events.html
214
+ [checkbox]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#additional_attributes
215
+ [ref]: https://reactjs.org/docs/refs-and-the-dom.html
@@ -32,8 +32,8 @@ export const FileInputField = React.forwardRef((props, ref) => {
32
32
  fullWidth && styles.isRootFullWidth,
33
33
  context && styles.isRootInFormLayout,
34
34
  resolveContextOrProp(context && context.layout, layout) === 'horizontal'
35
- ? styles.rootLayoutHorizontal
36
- : styles.rootLayoutVertical,
35
+ ? styles.isRootLayoutHorizontal
36
+ : styles.isRootLayoutVertical,
37
37
  disabled && styles.isRootDisabled,
38
38
  required && styles.isRootRequired,
39
39
  getRootValidationStateClassName(validationState, styles),
@@ -90,7 +90,6 @@ FileInputField.defaultProps = {
90
90
  id: undefined,
91
91
  isLabelVisible: true,
92
92
  layout: 'vertical',
93
- ref: undefined,
94
93
  required: false,
95
94
  validationState: null,
96
95
  validationText: null,
@@ -136,14 +135,6 @@ FileInputField.propTypes = {
136
135
  *
137
136
  */
138
137
  layout: PropTypes.oneOf(['horizontal', 'vertical']),
139
- /**
140
- * Reference forwarded to the `input` element.
141
- */
142
- ref: PropTypes.oneOfType([
143
- PropTypes.func,
144
- // eslint-disable-next-line react/forbid-prop-types
145
- PropTypes.shape({ current: PropTypes.any }),
146
- ]),
147
138
  /**
148
139
  * If `true`, the input will be required.
149
140
  */
@@ -49,12 +49,12 @@
49
49
  }
50
50
 
51
51
  // Layouts
52
- .rootLayoutVertical,
53
- .rootLayoutHorizontal {
52
+ .isRootLayoutVertical,
53
+ .isRootLayoutHorizontal {
54
54
  @include box-field-layout.vertical();
55
55
  }
56
56
 
57
- .rootLayoutHorizontal {
57
+ .isRootLayoutHorizontal {
58
58
  @include box-field-layout.horizontal();
59
59
  }
60
60
 
@@ -66,28 +66,6 @@ Full-width fields span the full width of a parent:
66
66
  />
67
67
  </Playground>
68
68
 
69
- ## Forwarding HTML Attributes
70
-
71
- When you want to refine your file input fields even further, you
72
- can **add whatever HTML attribute you like.** All attributes that don't
73
- interfere with [component's API](#api) are forwarded to the native HTML input.
74
-
75
- <Playground>
76
- <FileInputField
77
- accept=".pdf,.jpg,.jpeg,.png"
78
- helpText={`
79
- Choose up to 10 files. Allowed extensions are .pdf, .jpg, .jpeg, or .png.
80
- Size limit is 10 MB.
81
- `}
82
- label="Attachment"
83
- multiple
84
- />
85
- </Playground>
86
-
87
- 👉 Refer to the MDN reference for the full list of supported attributes of the
88
- [file input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file)
89
- type.
90
-
91
69
  ## Invisible Label
92
70
 
93
71
  In some cases, it may be convenient to visually hide the field label. The label
@@ -187,12 +165,34 @@ It's possible to disable the whole input.
187
165
  />
188
166
  </Playground>
189
167
 
190
- ## API
168
+ ## Forwarding HTML Attributes
191
169
 
192
- In addition to the options below, you can specify [React synthetic events] or
193
- any custom HTML attributes that do not interfere with the API, and they will be
194
- passed to the `<input>` HTML element. This enables making the component
195
- interactive and helps improve its [accessibility](#forwarding-html-attributes).
170
+ In addition to the options below in the [component's API](#api) section, you
171
+ can specify [React synthetic events] or you can **add whatever HTML attribute
172
+ you like.** All attributes that don't interfere with the API are forwarded to
173
+ the native HTML `<input>`. This enables making the component interactive and
174
+ helps to improve its accessibility.
175
+
176
+ <Playground>
177
+ <FileInputField
178
+ accept=".pdf,.jpg,.jpeg,.png"
179
+ helpText={`
180
+ Choose up to 10 files. Allowed extensions are .pdf, .jpg, .jpeg, or .png.
181
+ Size limit is 10 MB.
182
+ `}
183
+ label="Attachment"
184
+ multiple
185
+ />
186
+ </Playground>
187
+
188
+ 👉 Refer to the MDN reference for the full list of supported attributes of the
189
+ [file] input type.
190
+
191
+ ## Forwarding ref
192
+
193
+ If you provide [ref], it is forwarded to the native HTML `<input>` element.
194
+
195
+ ## API
196
196
 
197
197
  <Props table of={FileInputField} />
198
198
 
@@ -202,3 +202,5 @@ Head to [Forms Theming](/customize/theming/forms) to see shared form theming
202
202
  options.
203
203
 
204
204
  [React synthetic events]: https://reactjs.org/docs/events.html
205
+ [file]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#additional_attributes
206
+ [ref]: https://reactjs.org/docs/refs-and-the-dom.html
@@ -1,6 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
+ import { transferProps } from '../_helpers/transferProps';
4
5
  import { classNames } from '../../utils/classNames';
5
6
  import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
6
7
  import { FormLayoutContext } from './FormLayoutContext';
@@ -12,8 +13,8 @@ export const FormLayout = ({
12
13
  autoWidth,
13
14
  children,
14
15
  fieldLayout,
15
- id,
16
16
  labelWidth,
17
+ ...restProps
17
18
  }) => {
18
19
  if (isChildrenEmpty(children)) {
19
20
  return null;
@@ -23,10 +24,10 @@ export const FormLayout = ({
23
24
 
24
25
  const fieldLayoutClass = (layout) => {
25
26
  if (layout === 'horizontal') {
26
- return styles.rootFieldLayoutHorizontal;
27
+ return styles.isRootFieldLayoutHorizontal;
27
28
  }
28
29
 
29
- return styles.rootFieldLayoutVertical;
30
+ return styles.isRootFieldLayoutVertical;
30
31
  };
31
32
 
32
33
  const labelWidthClass = (width) => {
@@ -47,7 +48,7 @@ export const FormLayout = ({
47
48
 
48
49
  return (
49
50
  <div
50
- id={id}
51
+ {...transferProps(restProps)}
51
52
  className={classNames(
52
53
  styles.root,
53
54
  fieldLayoutClass(fieldLayout),
@@ -69,7 +70,6 @@ FormLayout.defaultProps = {
69
70
  autoWidth: false,
70
71
  children: null,
71
72
  fieldLayout: 'vertical',
72
- id: undefined,
73
73
  labelWidth: 'default',
74
74
  };
75
75
 
@@ -96,10 +96,6 @@ FormLayout.propTypes = {
96
96
  * Layout that is forced on children form fields.
97
97
  */
98
98
  fieldLayout: PropTypes.oneOf(['horizontal', 'vertical']),
99
- /**
100
- * ID of the root HTML element.
101
- */
102
- id: PropTypes.string,
103
99
  /**
104
100
  * Width of the column with form field labels. Only available if the `fieldLayout` is set to
105
101
  * `horizontal`.
@@ -24,14 +24,14 @@
24
24
  @include spacing.bottom(layouts);
25
25
  }
26
26
 
27
- .rootFieldLayoutVertical,
28
- .rootFieldLayoutHorizontal {
27
+ .isRootFieldLayoutVertical,
28
+ .isRootFieldLayoutHorizontal {
29
29
  display: grid;
30
30
  grid-template-columns: var(--rui-local-field-width);
31
31
  grid-row-gap: theme.$row-gap;
32
32
  }
33
33
 
34
- .rootFieldLayoutHorizontal {
34
+ .isRootFieldLayoutHorizontal {
35
35
  @include breakpoint.up(forms.$horizontal-breakpoint) {
36
36
  grid-template-columns: var(--rui-local-label-width) var(--rui-local-field-width); // 1.
37
37
  }