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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. package/dist/lib.development.js +465 -93
  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 +18 -2
  7. package/src/lib/components/Alert/index.js +1 -1
  8. package/src/lib/components/Badge/Badge.jsx +4 -8
  9. package/src/lib/components/Badge/Badge.scss +21 -21
  10. package/src/lib/components/Badge/README.mdx +15 -1
  11. package/src/lib/components/Badge/index.js +1 -1
  12. package/src/lib/components/Button/Button.jsx +23 -34
  13. package/src/lib/components/Button/README.mdx +21 -7
  14. package/src/lib/components/Button/_base.scss +20 -20
  15. package/src/lib/components/Button/_priorities.scss +35 -35
  16. package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +7 -7
  17. package/src/lib/components/Button/helpers/getRootPriorityClassName.js +3 -3
  18. package/src/lib/components/Button/index.js +1 -1
  19. package/src/lib/components/ButtonGroup/ButtonGroup.jsx +2 -8
  20. package/src/lib/components/ButtonGroup/README.mdx +18 -2
  21. package/src/lib/components/Card/Card.jsx +6 -10
  22. package/src/lib/components/Card/Card.scss +13 -13
  23. package/src/lib/components/Card/CardBody.jsx +6 -10
  24. package/src/lib/components/Card/CardFooter.jsx +6 -7
  25. package/src/lib/components/Card/README.mdx +21 -5
  26. package/src/lib/components/CheckboxField/CheckboxField.jsx +17 -44
  27. package/src/lib/components/CheckboxField/README.mdx +18 -6
  28. package/src/lib/components/CheckboxField/index.js +1 -1
  29. package/src/lib/components/FileInputField/FileInputField.jsx +20 -29
  30. package/src/lib/components/FileInputField/FileInputField.scss +3 -3
  31. package/src/lib/components/FileInputField/README.mdx +30 -28
  32. package/src/lib/components/FileInputField/index.js +1 -1
  33. package/src/lib/components/FormLayout/FormLayout.jsx +5 -9
  34. package/src/lib/components/FormLayout/FormLayout.scss +3 -3
  35. package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +4 -1
  36. package/src/lib/components/FormLayout/FormLayoutCustomField.scss +8 -8
  37. package/src/lib/components/FormLayout/README.mdx +28 -13
  38. package/src/lib/components/Grid/Grid.jsx +31 -35
  39. package/src/lib/components/Grid/Grid.scss +10 -15
  40. package/src/lib/components/Grid/GridSpan.jsx +5 -11
  41. package/src/lib/components/Grid/README.mdx +48 -36
  42. package/src/lib/components/Grid/_helpers/generateResponsiveCustomProperties.js +11 -3
  43. package/src/lib/components/Grid/_settings.scss +18 -0
  44. package/src/lib/components/Grid/_tools.scss +5 -5
  45. package/src/lib/components/Modal/Modal.jsx +147 -254
  46. package/src/lib/components/Modal/Modal.scss +7 -55
  47. package/src/lib/components/Modal/ModalBody.jsx +60 -0
  48. package/src/lib/components/Modal/ModalBody.scss +18 -0
  49. package/src/lib/components/Modal/ModalCloseButton.jsx +45 -0
  50. package/src/lib/components/Modal/ModalCloseButton.scss +18 -0
  51. package/src/lib/components/Modal/ModalContent.jsx +39 -0
  52. package/src/lib/components/Modal/ModalContent.scss +5 -0
  53. package/src/lib/components/Modal/ModalFooter.jsx +42 -0
  54. package/src/lib/components/Modal/ModalFooter.scss +35 -0
  55. package/src/lib/components/Modal/ModalHeader.jsx +44 -0
  56. package/src/lib/components/Modal/ModalHeader.scss +30 -0
  57. package/src/lib/components/Modal/ModalTitle.jsx +44 -0
  58. package/src/lib/components/Modal/ModalTitle.scss +10 -0
  59. package/src/lib/components/Modal/README.mdx +865 -195
  60. package/src/lib/components/Modal/_helpers/getJustifyClassName.js +19 -0
  61. package/src/lib/components/Modal/_helpers/getScrollingClassName.js +11 -0
  62. package/src/lib/components/Modal/_settings.scss +1 -5
  63. package/src/lib/components/Modal/_theme.scss +6 -0
  64. package/src/lib/components/Modal/index.js +7 -1
  65. package/src/lib/components/Paper/Paper.jsx +5 -9
  66. package/src/lib/components/Paper/Paper.scss +2 -2
  67. package/src/lib/components/Paper/README.mdx +15 -1
  68. package/src/lib/components/Paper/index.js +1 -1
  69. package/src/lib/components/Popover/Popover.jsx +14 -30
  70. package/src/lib/components/Popover/Popover.scss +7 -6
  71. package/src/lib/components/Popover/PopoverWrapper.jsx +5 -12
  72. package/src/lib/components/Popover/PopoverWrapper.scss +3 -0
  73. package/src/lib/components/Popover/README.mdx +32 -11
  74. package/src/lib/components/Popover/_theme.scss +1 -1
  75. package/src/lib/components/Radio/README.mdx +13 -6
  76. package/src/lib/components/Radio/Radio.jsx +39 -29
  77. package/src/lib/components/Radio/Radio.scss +3 -3
  78. package/src/lib/components/Radio/index.js +1 -1
  79. package/src/lib/components/ScrollView/README.mdx +165 -84
  80. package/src/lib/components/ScrollView/ScrollView.jsx +115 -117
  81. package/src/lib/components/ScrollView/ScrollView.scss +18 -16
  82. package/src/lib/components/ScrollView/index.js +1 -1
  83. package/src/lib/components/SelectField/README.mdx +83 -7
  84. package/src/lib/components/SelectField/SelectField.jsx +86 -61
  85. package/src/lib/components/SelectField/SelectField.scss +8 -8
  86. package/src/lib/components/SelectField/_components/Option/Option.jsx +46 -0
  87. package/src/lib/components/SelectField/_components/Option/index.js +1 -0
  88. package/src/lib/components/SelectField/index.js +1 -1
  89. package/src/lib/components/Table/README.mdx +25 -9
  90. package/src/lib/components/Table/Table.jsx +43 -101
  91. package/src/lib/components/Table/Table.scss +0 -24
  92. package/src/lib/components/Table/_components/TableBodyCell/TableBodyCell.jsx +46 -0
  93. package/src/lib/components/Table/_components/TableBodyCell/index.js +1 -0
  94. package/src/lib/components/Table/_components/TableCell.scss +25 -0
  95. package/src/lib/components/Table/_components/TableHeaderCell/TableHeaderCell.jsx +71 -0
  96. package/src/lib/components/Table/_components/TableHeaderCell/index.js +1 -0
  97. package/src/lib/components/Table/index.js +1 -1
  98. package/src/lib/components/Tabs/README.mdx +21 -3
  99. package/src/lib/components/Tabs/Tabs.jsx +6 -1
  100. package/src/lib/components/Tabs/TabsItem.jsx +3 -0
  101. package/src/lib/components/Tabs/TabsItem.scss +1 -2
  102. package/src/lib/components/Text/README.mdx +25 -7
  103. package/src/lib/components/Text/Text.jsx +3 -7
  104. package/src/lib/components/Text/Text.scss +6 -6
  105. package/src/lib/components/Text/_helpers/getRootClampClassName.js +2 -2
  106. package/src/lib/components/Text/_helpers/getRootHyphensClassName.js +2 -2
  107. package/src/lib/components/Text/_helpers/getRootWordWrappingClassName.js +2 -2
  108. package/src/lib/components/Text/index.js +1 -1
  109. package/src/lib/components/TextArea/README.mdx +34 -31
  110. package/src/lib/components/TextArea/TextArea.jsx +23 -63
  111. package/src/lib/components/TextArea/TextArea.scss +8 -8
  112. package/src/lib/components/TextArea/index.js +1 -1
  113. package/src/lib/components/TextField/README.mdx +56 -54
  114. package/src/lib/components/TextField/TextField.jsx +25 -52
  115. package/src/lib/components/TextField/TextField.scss +9 -9
  116. package/src/lib/components/TextField/index.js +1 -1
  117. package/src/lib/components/TextLink/README.mdx +13 -6
  118. package/src/lib/components/TextLink/TextLink.jsx +0 -10
  119. package/src/lib/components/TextLink/index.js +1 -1
  120. package/src/lib/components/Toggle/README.mdx +18 -6
  121. package/src/lib/components/Toggle/Toggle.jsx +18 -44
  122. package/src/lib/components/Toggle/index.js +1 -1
  123. package/src/lib/components/Toolbar/README.mdx +21 -6
  124. package/src/lib/components/Toolbar/Toolbar.jsx +9 -43
  125. package/src/lib/components/Toolbar/Toolbar.scss +24 -12
  126. package/src/lib/components/Toolbar/ToolbarGroup.jsx +7 -26
  127. package/src/lib/components/Toolbar/ToolbarItem.jsx +3 -7
  128. package/src/lib/components/Toolbar/_helpers/getAlignClassName.js +19 -0
  129. package/src/lib/components/Toolbar/_helpers/getJustifyClassName.js +16 -0
  130. package/src/lib/components/_helpers/getRootColorClassName.js +10 -10
  131. package/src/lib/components/_helpers/getRootSizeClassName.js +3 -3
  132. package/src/lib/components/_helpers/transferProps.js +1 -1
  133. package/src/lib/index.js +24 -16
  134. package/src/lib/provider/withGlobalProps.jsx +20 -3
  135. package/src/lib/styles/tools/form-fields/_box-field-layout.scss +15 -15
  136. package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +1 -1
  137. package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +9 -9
  138. package/src/lib/theme.scss +18 -26
  139. package/src/lib/translations/en.js +1 -1
  140. package/src/lib/components/Grid/_theme.scss +0 -11
  141. package/src/lib/components/ScrollView/_theme.scss +0 -2
  142. package/src/lib/components/withForwardedRef.jsx +0 -11
@@ -5,24 +5,21 @@ import { classNames } from '../../utils/classNames';
5
5
  import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
6
6
  import { transferProps } from '../_helpers/transferProps';
7
7
  import { FormLayoutContext } from '../FormLayout';
8
- import withForwardedRef from '../withForwardedRef';
9
8
  import styles from './CheckboxField.scss';
10
9
 
11
- export const CheckboxField = ({
12
- checked,
13
- disabled,
14
- forwardedRef,
15
- helpText,
16
- id,
17
- isLabelVisible,
18
- label,
19
- labelPosition,
20
- required,
21
- validationState,
22
- validationText,
23
- value,
24
- ...restProps
25
- }) => {
10
+ export const CheckboxField = React.forwardRef((props, ref) => {
11
+ const {
12
+ disabled,
13
+ helpText,
14
+ id,
15
+ isLabelVisible,
16
+ label,
17
+ labelPosition,
18
+ required,
19
+ validationState,
20
+ validationText,
21
+ ...restProps
22
+ } = props;
26
23
  const context = useContext(FormLayoutContext);
27
24
 
28
25
  return (
@@ -30,7 +27,7 @@ export const CheckboxField = ({
30
27
  className={classNames(
31
28
  styles.root,
32
29
  context && styles.isRootInFormLayout,
33
- context && context.layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
30
+ context && context.layout === 'horizontal' ? styles.isRootLayoutHorizontal : styles.isRootLayoutVertical,
34
31
  labelPosition === 'before' && styles.hasRootLabelBefore,
35
32
  disabled && styles.isRootDisabled,
36
33
  required && styles.isRootRequired,
@@ -51,14 +48,12 @@ export const CheckboxField = ({
51
48
  </div>
52
49
  <input
53
50
  {...transferProps(restProps)}
54
- checked={checked}
55
51
  className={styles.input}
56
52
  disabled={disabled}
57
53
  id={id}
58
- ref={forwardedRef}
54
+ ref={ref}
59
55
  required={required}
60
56
  type="checkbox"
61
- value={value}
62
57
  />
63
58
  </div>
64
59
  {helpText && (
@@ -79,12 +74,10 @@ export const CheckboxField = ({
79
74
  )}
80
75
  </label>
81
76
  );
82
- };
77
+ });
83
78
 
84
79
  CheckboxField.defaultProps = {
85
- checked: undefined,
86
80
  disabled: false,
87
- forwardedRef: undefined,
88
81
  helpText: null,
89
82
  id: undefined,
90
83
  isLabelVisible: true,
@@ -92,26 +85,13 @@ CheckboxField.defaultProps = {
92
85
  required: false,
93
86
  validationState: null,
94
87
  validationText: null,
95
- value: undefined,
96
88
  };
97
89
 
98
90
  CheckboxField.propTypes = {
99
- /**
100
- * If `true`, the input will be checked.
101
- */
102
- checked: PropTypes.bool,
103
91
  /**
104
92
  * If `true`, the input will be disabled.
105
93
  */
106
94
  disabled: PropTypes.bool,
107
- /**
108
- * Reference forwarded to the `input` element.
109
- */
110
- forwardedRef: PropTypes.oneOfType([
111
- PropTypes.func,
112
- // eslint-disable-next-line react/forbid-prop-types
113
- PropTypes.shape({ current: PropTypes.any }),
114
- ]),
115
95
  /**
116
96
  * Optional help text.
117
97
  */
@@ -151,15 +131,8 @@ CheckboxField.propTypes = {
151
131
  * Validation message to be displayed.
152
132
  */
153
133
  validationText: PropTypes.node,
154
- /**
155
- * Value of the input.
156
- */
157
- value: PropTypes.oneOfType([
158
- PropTypes.string,
159
- PropTypes.number,
160
- ]),
161
134
  };
162
135
 
163
- export const CheckboxFieldWithGlobalProps = withForwardedRef(withGlobalProps(CheckboxField, 'CheckboxField'));
136
+ export const CheckboxFieldWithGlobalProps = withGlobalProps(CheckboxField, 'CheckboxField');
164
137
 
165
138
  export default CheckboxFieldWithGlobalProps;
@@ -12,7 +12,7 @@ import {
12
12
  Playground,
13
13
  Props,
14
14
  } from 'docz'
15
- import { CheckboxField } from './CheckboxField'
15
+ import { CheckboxField } from '../..'
16
16
 
17
17
  ## Basic Usage
18
18
 
@@ -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
@@ -1 +1 @@
1
- export { default } from './CheckboxField';
1
+ export { default as CheckboxField } from './CheckboxField';
@@ -6,23 +6,23 @@ import { getRootValidationStateClassName } from '../_helpers/getRootValidationSt
6
6
  import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
7
7
  import { transferProps } from '../_helpers/transferProps';
8
8
  import { FormLayoutContext } from '../FormLayout';
9
- import withForwardedRef from '../withForwardedRef';
10
9
  import styles from './FileInputField.scss';
11
10
 
12
- export const FileInputField = ({
13
- disabled,
14
- forwardedRef,
15
- fullWidth,
16
- helpText,
17
- id,
18
- isLabelVisible,
19
- label,
20
- layout,
21
- required,
22
- validationState,
23
- validationText,
24
- ...restProps
25
- }) => {
11
+ export const FileInputField = React.forwardRef((props, ref) => {
12
+ const {
13
+ disabled,
14
+ fullWidth,
15
+ helpText,
16
+ id,
17
+ isLabelVisible,
18
+ label,
19
+ layout,
20
+ required,
21
+ validationState,
22
+ validationText,
23
+ ...restProps
24
+ } = props;
25
+
26
26
  const context = useContext(FormLayoutContext);
27
27
 
28
28
  return (
@@ -32,8 +32,8 @@ export const FileInputField = ({
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),
@@ -57,7 +57,7 @@ export const FileInputField = ({
57
57
  className={styles.input}
58
58
  disabled={disabled}
59
59
  id={id}
60
- ref={forwardedRef}
60
+ ref={ref}
61
61
  required={required}
62
62
  type="file"
63
63
  />
@@ -81,11 +81,10 @@ export const FileInputField = ({
81
81
  </div>
82
82
  </label>
83
83
  );
84
- };
84
+ });
85
85
 
86
86
  FileInputField.defaultProps = {
87
87
  disabled: false,
88
- forwardedRef: undefined,
89
88
  fullWidth: false,
90
89
  helpText: null,
91
90
  id: undefined,
@@ -101,14 +100,6 @@ FileInputField.propTypes = {
101
100
  * If `true`, the input will be disabled.
102
101
  */
103
102
  disabled: PropTypes.bool,
104
- /**
105
- * Reference forwarded to the `input` element.
106
- */
107
- forwardedRef: PropTypes.oneOfType([
108
- PropTypes.func,
109
- // eslint-disable-next-line react/forbid-prop-types
110
- PropTypes.shape({ current: PropTypes.any }),
111
- ]),
112
103
  /**
113
104
  * If `true`, the field will span the full width of its parent.
114
105
  */
@@ -158,6 +149,6 @@ FileInputField.propTypes = {
158
149
  validationText: PropTypes.node,
159
150
  };
160
151
 
161
- export const FileInputFieldWithGlobalProps = withForwardedRef(withGlobalProps(FileInputField, 'FileInputField'));
152
+ export const FileInputFieldWithGlobalProps = withGlobalProps(FileInputField, 'FileInputField');
162
153
 
163
154
  export default FileInputFieldWithGlobalProps;
@@ -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
 
@@ -12,7 +12,7 @@ import {
12
12
  Playground,
13
13
  Props,
14
14
  } from 'docz'
15
- import { FileInputField } from './FileInputField'
15
+ import { FileInputField } from '../..'
16
16
 
17
17
  ## Basic Usage
18
18
 
@@ -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 +1 @@
1
- export { default } from './FileInputField';
1
+ export { default as FileInputField } from './FileInputField';
@@ -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
  }
@@ -1,6 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
3
  import { withGlobalProps } from '../../provider';
4
+ import { transferProps } from '../_helpers/transferProps';
4
5
  import { classNames } from '../../utils/classNames';
5
6
  import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
6
7
  import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
@@ -45,6 +46,7 @@ export const FormLayoutCustomField = ({
45
46
  labelForId,
46
47
  required,
47
48
  validationState,
49
+ ...restProps
48
50
  }) => {
49
51
  const context = useContext(FormLayoutContext);
50
52
 
@@ -54,11 +56,12 @@ export const FormLayoutCustomField = ({
54
56
 
55
57
  return (
56
58
  <div
59
+ {...transferProps(restProps)}
57
60
  id={id}
58
61
  className={classNames(
59
62
  styles.root,
60
63
  fullWidth && styles.isRootFullWidth,
61
- context && context.layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
64
+ context && context.layout === 'horizontal' ? styles.isRootLayoutHorizontal : styles.isRootLayoutVertical,
62
65
  disabled && styles.isRootDisabled,
63
66
  required && styles.isRootRequired,
64
67
  getRootSizeClassName(innerFieldSize, styles),
@@ -31,17 +31,17 @@
31
31
  }
32
32
 
33
33
  // Layouts
34
- .rootLayoutVertical,
35
- .rootLayoutHorizontal {
34
+ .isRootLayoutVertical,
35
+ .isRootLayoutHorizontal {
36
36
  @include box-field-layout.vertical();
37
37
  }
38
38
 
39
- .rootLayoutHorizontal {
39
+ .isRootLayoutHorizontal {
40
40
  @include box-field-layout.horizontal();
41
41
  }
42
42
 
43
- .rootLayoutVertical .field,
44
- .rootLayoutHorizontal .field {
43
+ .isRootLayoutVertical .field,
44
+ .isRootLayoutHorizontal .field {
45
45
  width: auto;
46
46
  }
47
47
 
@@ -50,14 +50,14 @@
50
50
  }
51
51
 
52
52
  // Sizes
53
- .rootSizeSmall {
53
+ .isRootSizeSmall {
54
54
  @include box-field-sizes.size(small);
55
55
  }
56
56
 
57
- .rootSizeMedium {
57
+ .isRootSizeMedium {
58
58
  @include box-field-sizes.size(medium);
59
59
  }
60
60
 
61
- .rootSizeLarge {
61
+ .isRootSizeLarge {
62
62
  @include box-field-sizes.size(large);
63
63
  }
@@ -13,19 +13,21 @@ import {
13
13
  Props,
14
14
  } from 'docz'
15
15
  import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
16
- import { Button } from '../Button/Button'
17
- import { ButtonGroup } from '../ButtonGroup/ButtonGroup'
18
- import { CheckboxField } from '../CheckboxField/CheckboxField'
19
- import { FileInputField } from '../FileInputField/FileInputField'
20
- import { Radio } from '../Radio/Radio'
21
- import { SelectField } from '../SelectField/SelectField'
22
- import { TextArea } from '../TextArea/TextArea'
23
- import { TextField } from '../TextField/TextField'
24
- import { Toggle } from '../Toggle/Toggle'
25
- import { Toolbar } from '../Toolbar/Toolbar'
26
- import { ToolbarItem } from '../Toolbar/ToolbarItem'
27
- import { FormLayout } from './FormLayout'
28
- import { FormLayoutCustomField } from './FormLayoutCustomField'
16
+ import {
17
+ Button,
18
+ ButtonGroup,
19
+ CheckboxField,
20
+ FileInputField,
21
+ Radio,
22
+ SelectField,
23
+ TextArea,
24
+ TextField,
25
+ Toggle,
26
+ Toolbar,
27
+ ToolbarItem,
28
+ FormLayout,
29
+ FormLayoutCustomField,
30
+ } from '../..'
29
31
 
30
32
  ## Basic Usage
31
33
 
@@ -436,6 +438,17 @@ This is a demo of all components supported by FormLayout.
436
438
  }}
437
439
  </Playground>
438
440
 
441
+ ## Forwarding HTML Attributes
442
+
443
+ In addition to the options below in the [component's API](#api) section, you
444
+ can specify [React synthetic events] or **any HTML attribute you like.** All
445
+ attributes that don't interfere with the API are forwarded to the root `<div>`
446
+ HTML element. This enables making the component interactive and helps to improve
447
+ its accessibility.
448
+
449
+ 👉 Refer to the MDN reference for the full list of supported attributes of the
450
+ [div] element.
451
+
439
452
  ## API
440
453
 
441
454
  <Props table of={FormLayout} />
@@ -470,3 +483,5 @@ FormLayoutCustomField can be styled using a small subset of
470
483
  [fragments]: https://reactjs.org/docs/fragments.html
471
484
  [rui-232]: https://github.com/react-ui-org/react-ui/issues/232
472
485
  [rui-265]: https://github.com/react-ui-org/react-ui/issues/265
486
+ [React synthetic events]: https://reactjs.org/docs/events.html
487
+ [div]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes