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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. package/CONTRIBUTING.md +7 -0
  2. package/README.md +15 -16
  3. package/dist/lib.development.js +271 -415
  4. package/dist/lib.js +1 -1
  5. package/package.json +11 -13
  6. package/src/lib/components/Alert/Alert.jsx +45 -44
  7. package/src/lib/components/Alert/Alert.scss +48 -48
  8. package/src/lib/components/Alert/README.mdx +2 -5
  9. package/src/lib/components/Alert/_settings.scss +4 -4
  10. package/src/lib/components/Alert/_theme.scss +50 -50
  11. package/src/lib/components/Alert/_tools.scss +6 -6
  12. package/src/lib/components/Badge/Badge.jsx +9 -11
  13. package/src/lib/components/Badge/Badge.scss +57 -57
  14. package/src/lib/components/Button/Button.jsx +14 -13
  15. package/src/lib/components/Button/Button.scss +2 -2
  16. package/src/lib/components/Button/README.mdx +11 -6
  17. package/src/lib/components/Button/_base.scss +69 -69
  18. package/src/lib/components/Button/_priorities.scss +49 -49
  19. package/src/lib/components/Button/_settings.scss +10 -10
  20. package/src/lib/components/Button/_theme.scss +18 -15
  21. package/src/lib/components/Button/_tools.scss +98 -100
  22. package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +4 -4
  23. package/src/lib/components/ButtonGroup/ButtonGroup.jsx +41 -25
  24. package/src/lib/components/ButtonGroup/ButtonGroup.scss +3 -3
  25. package/src/lib/components/ButtonGroup/README.mdx +1 -1
  26. package/src/lib/components/Card/Card.jsx +10 -9
  27. package/src/lib/components/Card/Card.scss +28 -28
  28. package/src/lib/components/Card/CardBody.jsx +17 -12
  29. package/src/lib/components/Card/CardFooter.jsx +22 -9
  30. package/src/lib/components/Card/_theme.scss +50 -50
  31. package/src/lib/components/Card/_tools.scss +6 -6
  32. package/src/lib/components/CheckboxField/CheckboxField.jsx +21 -20
  33. package/src/lib/components/CheckboxField/CheckboxField.scss +20 -20
  34. package/src/lib/components/CheckboxField/README.mdx +1 -1
  35. package/src/lib/components/FileInputField/FileInputField.jsx +16 -15
  36. package/src/lib/components/FileInputField/FileInputField.scss +19 -19
  37. package/src/lib/components/FileInputField/README.mdx +1 -1
  38. package/src/lib/components/FormLayout/FormLayout.jsx +19 -17
  39. package/src/lib/components/FormLayout/FormLayout.scss +17 -17
  40. package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +18 -12
  41. package/src/lib/components/FormLayout/FormLayoutCustomField.scss +18 -18
  42. package/src/lib/components/FormLayout/README.mdx +26 -49
  43. package/src/lib/components/Grid/Grid.jsx +25 -24
  44. package/src/lib/components/Grid/Grid.scss +33 -29
  45. package/src/lib/components/Grid/GridSpan.jsx +11 -10
  46. package/src/lib/components/Grid/README.mdx +46 -20
  47. package/src/lib/components/Grid/{helpers → _helpers}/generateResponsiveCustomProperties.js +0 -2
  48. package/src/lib/components/Grid/_theme.scss +9 -9
  49. package/src/lib/components/Grid/_tools.scss +20 -20
  50. package/src/lib/components/Modal/Modal.jsx +38 -32
  51. package/src/lib/components/Modal/Modal.scss +73 -73
  52. package/src/lib/components/Modal/README.mdx +2 -5
  53. package/src/lib/components/Modal/_settings.scss +5 -5
  54. package/src/lib/components/Modal/_theme.scss +17 -17
  55. package/src/lib/components/Paper/Paper.jsx +9 -9
  56. package/src/lib/components/Paper/Paper.scss +8 -8
  57. package/src/lib/components/Popover/Popover.jsx +94 -0
  58. package/src/lib/components/Popover/Popover.scss +235 -0
  59. package/src/lib/components/Popover/PopoverWrapper.jsx +46 -0
  60. package/src/lib/components/Popover/README.mdx +333 -0
  61. package/src/lib/components/Popover/_helpers/getRootAlignmentClassName.js +13 -0
  62. package/src/lib/components/Popover/_helpers/getRootSideClassName.js +17 -0
  63. package/src/lib/components/Popover/_theme.scss +16 -0
  64. package/src/lib/components/Popover/index.js +2 -0
  65. package/src/lib/components/Radio/README.mdx +1 -1
  66. package/src/lib/components/Radio/Radio.jsx +15 -14
  67. package/src/lib/components/Radio/Radio.scss +26 -26
  68. package/src/lib/components/ScrollView/README.mdx +5 -5
  69. package/src/lib/components/ScrollView/ScrollView.jsx +22 -22
  70. package/src/lib/components/ScrollView/ScrollView.scss +113 -113
  71. package/src/lib/{services/elementPositionService.js → components/ScrollView/_helpers/getElementsPositionDifference.js} +0 -2
  72. package/src/lib/{hooks → components/ScrollView/_hooks}/useLoadResizeHook.js +1 -1
  73. package/src/lib/{hooks → components/ScrollView/_hooks}/useScrollPositionHook.js +1 -1
  74. package/src/lib/components/SelectField/README.mdx +1 -1
  75. package/src/lib/components/SelectField/SelectField.jsx +17 -16
  76. package/src/lib/components/SelectField/SelectField.scss +30 -30
  77. package/src/lib/components/Table/README.mdx +1 -1
  78. package/src/lib/components/Table/Table.jsx +3 -3
  79. package/src/lib/components/Table/Table.scss +28 -35
  80. package/src/lib/components/Table/_settings.scss +5 -5
  81. package/src/lib/components/Tabs/Tabs.jsx +4 -5
  82. package/src/lib/components/Tabs/Tabs.scss +21 -21
  83. package/src/lib/components/Tabs/TabsItem.jsx +7 -6
  84. package/src/lib/components/Tabs/TabsItem.scss +78 -78
  85. package/src/lib/components/Text/README.mdx +3 -3
  86. package/src/lib/components/Text/Text.jsx +16 -9
  87. package/src/lib/components/Text/Text.scss +23 -13
  88. package/src/lib/components/Text/_helpers/getRootClampClassName.js +11 -0
  89. package/src/lib/components/Text/{helpers → _helpers}/getRootHyphensClassName.js +1 -1
  90. package/src/lib/components/Text/{helpers → _helpers}/getRootWordWrappingClassName.js +1 -1
  91. package/src/lib/components/TextArea/README.mdx +1 -1
  92. package/src/lib/components/TextArea/TextArea.jsx +21 -17
  93. package/src/lib/components/TextArea/TextArea.scss +27 -27
  94. package/src/lib/components/TextField/README.mdx +1 -1
  95. package/src/lib/components/TextField/TextField.jsx +19 -18
  96. package/src/lib/components/TextField/TextField.scss +28 -28
  97. package/src/lib/components/TextLink/README.mdx +77 -0
  98. package/src/lib/components/TextLink/TextLink.jsx +44 -0
  99. package/src/lib/components/TextLink/TextLink.scss +11 -0
  100. package/src/lib/components/TextLink/_theme.scss +4 -0
  101. package/src/lib/components/TextLink/index.js +1 -0
  102. package/src/lib/components/Toggle/README.mdx +1 -1
  103. package/src/lib/components/Toggle/Toggle.jsx +21 -20
  104. package/src/lib/components/Toggle/Toggle.scss +20 -20
  105. package/src/lib/components/Toolbar/README.mdx +33 -5
  106. package/src/lib/components/Toolbar/Toolbar.jsx +33 -17
  107. package/src/lib/components/Toolbar/Toolbar.scss +29 -42
  108. package/src/lib/components/Toolbar/ToolbarGroup.jsx +28 -16
  109. package/src/lib/components/Toolbar/ToolbarItem.jsx +36 -10
  110. package/src/lib/{helpers → components/_helpers}/getRootColorClassName.js +1 -1
  111. package/src/lib/{helpers → components/_helpers}/getRootSizeClassName.js +1 -1
  112. package/src/lib/{helpers → components/_helpers}/getRootValidationStateClassName.js +1 -1
  113. package/src/lib/components/_helpers/isChildrenEmpty.js +3 -0
  114. package/src/lib/{helpers → components/_helpers}/resolveContextOrProp.js +0 -0
  115. package/src/lib/{utils → components/_helpers}/transferProps.js +1 -1
  116. package/src/lib/foundation.scss +11 -11
  117. package/src/lib/helpers.scss +2 -2
  118. package/src/lib/index.js +8 -17
  119. package/src/lib/provider/index.js +2 -1
  120. package/src/lib/provider/withGlobalProps.jsx +21 -0
  121. package/src/lib/styles/_utilities.scss +13 -13
  122. package/src/lib/styles/elements/_code.scss +7 -7
  123. package/src/lib/styles/elements/_links.scss +8 -8
  124. package/src/lib/styles/elements/_lists.scss +3 -3
  125. package/src/lib/styles/elements/_page.scss +14 -14
  126. package/src/lib/styles/elements/_rulers.scss +6 -6
  127. package/src/lib/styles/elements/_small.scss +2 -2
  128. package/src/lib/styles/generic/_box-sizing.scss +3 -2
  129. package/src/lib/styles/generic/_forms.scss +3 -3
  130. package/src/lib/styles/generic/_reset.scss +6 -6
  131. package/src/lib/styles/generic/_shared.scss +3 -3
  132. package/src/lib/styles/helpers/_animation.scss +8 -8
  133. package/src/lib/styles/settings/_breakpoints.scss +7 -7
  134. package/src/lib/styles/settings/_escaped-characters.scss +5 -5
  135. package/src/lib/styles/settings/_form-fields.scss +24 -24
  136. package/src/lib/styles/settings/_utilities.scss +112 -100
  137. package/src/lib/styles/theme/_colors.scss +50 -50
  138. package/src/lib/styles/theme/_form-fields.scss +32 -32
  139. package/src/lib/styles/theme/_spacing.scss +11 -11
  140. package/src/lib/styles/theme/_typography.scss +12 -11
  141. package/src/lib/styles/theme-constants/_breakpoints.scss +4 -4
  142. package/src/lib/styles/theme-constants/_colors.scss +2 -2
  143. package/src/lib/styles/theme-constants/_svg.scss +1 -2
  144. package/src/lib/styles/tools/_accessibility.scss +29 -29
  145. package/src/lib/styles/tools/_breakpoint.scss +11 -14
  146. package/src/lib/styles/tools/_caret.scss +8 -8
  147. package/src/lib/styles/tools/_colors.scss +3 -3
  148. package/src/lib/styles/tools/_reset.scss +24 -21
  149. package/src/lib/styles/tools/_scrollbar.scss +4 -4
  150. package/src/lib/styles/tools/_spacing.scss +14 -22
  151. package/src/lib/styles/tools/_string.scss +9 -9
  152. package/src/lib/styles/tools/_svg.scss +13 -16
  153. package/src/lib/styles/tools/_transition.scss +42 -44
  154. package/src/lib/styles/tools/_utilities.scss +19 -19
  155. package/src/lib/styles/tools/form-fields/_box-field-elements.scss +88 -88
  156. package/src/lib/styles/tools/form-fields/_box-field-layout.scss +147 -147
  157. package/src/lib/styles/tools/form-fields/_box-field-sizes.scss +13 -15
  158. package/src/lib/styles/tools/form-fields/_foundation.scss +12 -12
  159. package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +82 -71
  160. package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +88 -47
  161. package/src/lib/styles/tools/form-fields/_variants.scss +104 -106
  162. package/src/lib/theme.scss +959 -954
  163. package/src/lib/utils/classNames.js +8 -0
  164. package/src/lib/components/CTA/CTA.jsx +0 -60
  165. package/src/lib/components/CTA/CTA.scss +0 -71
  166. package/src/lib/components/CTA/CTACenter.jsx +0 -27
  167. package/src/lib/components/CTA/CTAEnd.jsx +0 -27
  168. package/src/lib/components/CTA/CTAStart.jsx +0 -27
  169. package/src/lib/components/CTA/README.mdx +0 -119
  170. package/src/lib/components/CTA/index.js +0 -4
  171. package/src/lib/components/Center/Center.jsx +0 -27
  172. package/src/lib/components/Center/Center.scss +0 -7
  173. package/src/lib/components/Center/README.mdx +0 -52
  174. package/src/lib/components/Center/index.js +0 -1
  175. package/src/lib/components/Link/Link.jsx +0 -45
  176. package/src/lib/components/Link/Link.scss +0 -11
  177. package/src/lib/components/Link/README.mdx +0 -85
  178. package/src/lib/components/Link/_theme.scss +0 -4
  179. package/src/lib/components/Link/index.js +0 -1
  180. package/src/lib/components/List/List.jsx +0 -71
  181. package/src/lib/components/List/List.scss +0 -53
  182. package/src/lib/components/List/ListItem.jsx +0 -31
  183. package/src/lib/components/List/README.mdx +0 -114
  184. package/src/lib/components/List/_theme.scss +0 -1
  185. package/src/lib/components/List/index.js +0 -2
  186. package/src/lib/components/Media/Media.jsx +0 -29
  187. package/src/lib/components/Media/Media.scss +0 -16
  188. package/src/lib/components/Media/MediaBody.jsx +0 -21
  189. package/src/lib/components/Media/MediaObject.jsx +0 -21
  190. package/src/lib/components/Media/README.mdx +0 -63
  191. package/src/lib/components/Media/index.js +0 -3
  192. package/src/lib/provider/withProviderContext.jsx +0 -32
@@ -1,67 +1,67 @@
1
- @use '../../styles/tools/form-fields/box-field-elements';
2
- @use '../../styles/tools/form-fields/box-field-layout';
3
- @use '../../styles/tools/form-fields/foundation';
4
- @use '../../styles/tools/form-fields/variants';
5
- @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/foundation";
4
+ @use "../../styles/tools/form-fields/variants";
5
+ @use "../../styles/tools/accessibility";
6
6
 
7
7
  // Foundation
8
8
  .root {
9
- @include foundation.root();
9
+ @include foundation.root();
10
10
  }
11
11
 
12
12
  .label {
13
- @include foundation.label();
13
+ @include foundation.label();
14
14
  }
15
15
 
16
16
  .inputContainer {
17
- @include box-field-elements.input-container();
17
+ @include box-field-elements.input-container();
18
18
  }
19
19
 
20
20
  .input {
21
- @include accessibility.focus-ring();
21
+ @include accessibility.focus-ring();
22
22
  }
23
23
 
24
24
  .helpText,
25
25
  .validationText {
26
- @include foundation.help-text();
26
+ @include foundation.help-text();
27
27
  }
28
28
 
29
29
  .isRootRequired .label {
30
- @include foundation.label-required();
30
+ @include foundation.label-required();
31
31
  }
32
32
 
33
33
  // States
34
34
  .isRootStateInvalid {
35
- @include variants.validation(invalid);
35
+ @include variants.validation(invalid);
36
36
  }
37
37
 
38
38
  .isRootStateValid {
39
- @include variants.validation(valid);
39
+ @include variants.validation(valid);
40
40
  }
41
41
 
42
42
  .isRootStateWarning {
43
- @include variants.validation(warning);
43
+ @include variants.validation(warning);
44
44
  }
45
45
 
46
46
  // Invisible label
47
47
  .isLabelHidden {
48
- @include accessibility.hide-text();
48
+ @include accessibility.hide-text();
49
49
  }
50
50
 
51
51
  // Layouts
52
52
  .rootLayoutVertical,
53
53
  .rootLayoutHorizontal {
54
- @include box-field-layout.vertical();
54
+ @include box-field-layout.vertical();
55
55
  }
56
56
 
57
57
  .rootLayoutHorizontal {
58
- @include box-field-layout.horizontal();
58
+ @include box-field-layout.horizontal();
59
59
  }
60
60
 
61
61
  .isRootFullWidth {
62
- @include box-field-layout.full-width();
62
+ @include box-field-layout.full-width();
63
63
  }
64
64
 
65
65
  .isRootInFormLayout {
66
- @include box-field-layout.in-form-layout();
66
+ @include box-field-layout.in-form-layout();
67
67
  }
@@ -191,7 +191,7 @@ It's possible to disable the whole input.
191
191
 
192
192
  In addition to the options below, you can specify [React synthetic events] or
193
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
194
+ passed to the `<input>` HTML element. This enables making the component
195
195
  interactive and helps improve its [accessibility](#forwarding-html-attributes).
196
196
 
197
197
  <Props table of={FileInputField} />
@@ -1,21 +1,21 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../provider';
3
+ import { withGlobalProps } from '../../provider';
4
+ import { classNames } from '../../utils/classNames';
5
+ import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
4
6
  import { FormLayoutContext } from './FormLayoutContext';
5
7
  import styles from './FormLayout.scss';
6
8
 
7
9
  const PREDEFINED_LABEL_WIDTH_VALUES = ['auto', 'default', 'limited'];
8
10
 
9
- export const FormLayout = (props) => {
10
- const {
11
- autoWidth,
12
- children,
13
- fieldLayout,
14
- id,
15
- labelWidth,
16
- } = props;
17
-
18
- if (!children) {
11
+ export const FormLayout = ({
12
+ autoWidth,
13
+ children,
14
+ fieldLayout,
15
+ id,
16
+ labelWidth,
17
+ }) => {
18
+ if (isChildrenEmpty(children)) {
19
19
  return null;
20
20
  }
21
21
 
@@ -48,12 +48,12 @@ export const FormLayout = (props) => {
48
48
  return (
49
49
  <div
50
50
  id={id}
51
- className={[
51
+ className={classNames(
52
52
  styles.root,
53
53
  fieldLayoutClass(fieldLayout),
54
- autoWidth ? styles.isRootAutoWidth : '',
55
- fieldLayout === 'horizontal' ? labelWidthClass(labelWidth) : '',
56
- ].join(' ')}
54
+ autoWidth && styles.isRootAutoWidth,
55
+ fieldLayout === 'horizontal' && labelWidthClass(labelWidth),
56
+ )}
57
57
  {...hasCustomLabelWidth ? { style: { '--rui-custom-label-width': labelWidth } } : {}}
58
58
  >
59
59
  <FormLayoutContext.Provider
@@ -88,6 +88,8 @@ FormLayout.propTypes = {
88
88
  * * `TextArea`
89
89
  * * `TextField`
90
90
  * * `Toggle`
91
+ *
92
+ * If none are provided nothing is rendered.
91
93
  */
92
94
  children: PropTypes.node,
93
95
  /**
@@ -108,6 +110,6 @@ FormLayout.propTypes = {
108
110
  ]),
109
111
  };
110
112
 
111
- export const FormLayoutWithContext = withProviderContext(FormLayout, 'FormLayout');
113
+ export const FormLayoutWithGlobalProps = withGlobalProps(FormLayout, 'FormLayout');
112
114
 
113
- export default FormLayoutWithContext;
115
+ export default FormLayoutWithGlobalProps;
@@ -13,46 +13,46 @@
13
13
  // (a global default which can be customised per use).
14
14
  // https://github.com/react-ui-org/react-ui/issues/232
15
15
 
16
- @use '../../styles/settings/forms';
17
- @use '../../styles/tools/breakpoint';
18
- @use '../../styles/tools/spacing';
19
- @use 'theme';
16
+ @use "../../styles/settings/forms";
17
+ @use "../../styles/tools/breakpoint";
18
+ @use "../../styles/tools/spacing";
19
+ @use "theme";
20
20
 
21
21
  .root {
22
- --rui-local-field-width: 1fr;
22
+ --rui-local-field-width: 1fr;
23
23
 
24
- @include spacing.bottom(layouts);
24
+ @include spacing.bottom(layouts);
25
25
  }
26
26
 
27
27
  .rootFieldLayoutVertical,
28
28
  .rootFieldLayoutHorizontal {
29
- display: grid;
30
- grid-template-columns: var(--rui-local-field-width);
31
- grid-row-gap: theme.$row-gap;
29
+ display: grid;
30
+ grid-template-columns: var(--rui-local-field-width);
31
+ grid-row-gap: theme.$row-gap;
32
32
  }
33
33
 
34
34
  .rootFieldLayoutHorizontal {
35
- @include breakpoint.up(forms.$horizontal-breakpoint) {
36
- grid-template-columns: var(--rui-local-label-width) var(--rui-local-field-width); // 1.
37
- }
35
+ @include breakpoint.up(forms.$horizontal-breakpoint) {
36
+ grid-template-columns: var(--rui-local-label-width) var(--rui-local-field-width); // 1.
37
+ }
38
38
  }
39
39
 
40
40
  .hasRootLabelWidthDefault {
41
- --rui-local-label-width: #{theme.$horizontal-label-width}; // 1., 2.
41
+ --rui-local-label-width: #{theme.$horizontal-label-width}; // 1., 2.
42
42
  }
43
43
 
44
44
  .hasRootLabelWidthAuto {
45
- --rui-local-label-width: #{theme.$horizontal-label-width-auto}; // 4.
45
+ --rui-local-label-width: #{theme.$horizontal-label-width-auto}; // 4.
46
46
  }
47
47
 
48
48
  .hasRootLabelWidthLimited {
49
- --rui-local-label-width: #{theme.$horizontal-label-width-limited}; // 4.
49
+ --rui-local-label-width: #{theme.$horizontal-label-width-limited}; // 4.
50
50
  }
51
51
 
52
52
  .hasRootLabelWidthCustom {
53
- --rui-local-label-width: var(--rui-custom-label-width); // 3.
53
+ --rui-local-label-width: var(--rui-custom-label-width); // 3.
54
54
  }
55
55
 
56
56
  .isRootAutoWidth {
57
- --rui-local-field-width: min-content;
57
+ --rui-local-field-width: min-content;
58
58
  }
@@ -1,10 +1,12 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
- import getRootSizeClassName from '../../helpers/getRootSizeClassName';
4
- import getRootValidationStateClassName from '../../helpers/getRootValidationStateClassName';
5
- import { withProviderContext } from '../../provider';
6
- import styles from './FormLayoutCustomField.scss';
3
+ import { withGlobalProps } from '../../provider';
4
+ import { classNames } from '../../utils/classNames';
5
+ import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
6
+ import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
7
+ import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
7
8
  import { FormLayoutContext } from './FormLayoutContext';
9
+ import styles from './FormLayoutCustomField.scss';
8
10
 
9
11
  const renderLabel = (id, label, labelForId) => {
10
12
  if (labelForId && label) {
@@ -46,18 +48,22 @@ export const FormLayoutCustomField = ({
46
48
  }) => {
47
49
  const context = useContext(FormLayoutContext);
48
50
 
51
+ if (isChildrenEmpty(children)) {
52
+ return null;
53
+ }
54
+
49
55
  return (
50
56
  <div
51
57
  id={id}
52
- className={[
58
+ className={classNames(
53
59
  styles.root,
54
- fullWidth ? styles.isRootFullWidth : '',
60
+ fullWidth && styles.isRootFullWidth,
55
61
  context && context.layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
56
- disabled ? styles.isRootDisabled : '',
57
- required ? styles.isRootRequired : '',
62
+ disabled && styles.isRootDisabled,
63
+ required && styles.isRootRequired,
58
64
  getRootSizeClassName(innerFieldSize, styles),
59
65
  getRootValidationStateClassName(validationState, styles),
60
- ].join(' ')}
66
+ )}
61
67
  >
62
68
  {renderLabel(id, label, labelForId)}
63
69
  <div
@@ -84,7 +90,7 @@ FormLayoutCustomField.defaultProps = {
84
90
 
85
91
  FormLayoutCustomField.propTypes = {
86
92
  /**
87
- * Custom HTML or React component(s).
93
+ * Custom HTML or React component(s). If none are provided nothing is rendered.
88
94
  */
89
95
  children: PropTypes.node,
90
96
  /**
@@ -125,6 +131,6 @@ FormLayoutCustomField.propTypes = {
125
131
  validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
126
132
  };
127
133
 
128
- export const FormLayoutCustomFieldWithContext = withProviderContext(FormLayoutCustomField, 'FormLayoutCustomField');
134
+ export const FormLayoutCustomFieldWithGlobalProps = withGlobalProps(FormLayoutCustomField, 'FormLayoutCustomField');
129
135
 
130
- export default FormLayoutCustomFieldWithContext;
136
+ export default FormLayoutCustomFieldWithGlobalProps;
@@ -1,63 +1,63 @@
1
- @use '../../styles/tools/form-fields/foundation';
2
- @use '../../styles/tools/form-fields/box-field-layout';
3
- @use '../../styles/tools/form-fields/box-field-sizes';
4
- @use '../../styles/tools/form-fields/variants';
1
+ @use "../../styles/tools/form-fields/foundation";
2
+ @use "../../styles/tools/form-fields/box-field-layout";
3
+ @use "../../styles/tools/form-fields/box-field-sizes";
4
+ @use "../../styles/tools/form-fields/variants";
5
5
 
6
6
  // Foundation
7
7
  .root {
8
- @include box-field-layout.in-form-layout();
9
- @include variants.visual(custom);
8
+ @include box-field-layout.in-form-layout();
9
+ @include variants.visual(custom);
10
10
  }
11
11
 
12
12
  .label {
13
- @include foundation.label();
13
+ @include foundation.label();
14
14
  }
15
15
 
16
16
  .isRootRequired .label {
17
- @include foundation.label-required();
17
+ @include foundation.label-required();
18
18
  }
19
19
 
20
20
  // States
21
21
  .isRootStateInvalid {
22
- @include variants.validation(invalid);
22
+ @include variants.validation(invalid);
23
23
  }
24
24
 
25
25
  .isRootStateValid {
26
- @include variants.validation(valid);
26
+ @include variants.validation(valid);
27
27
  }
28
28
 
29
29
  .isRootStateWarning {
30
- @include variants.validation(warning);
30
+ @include variants.validation(warning);
31
31
  }
32
32
 
33
33
  // Layouts
34
34
  .rootLayoutVertical,
35
35
  .rootLayoutHorizontal {
36
- @include box-field-layout.vertical();
36
+ @include box-field-layout.vertical();
37
37
  }
38
38
 
39
39
  .rootLayoutHorizontal {
40
- @include box-field-layout.horizontal();
40
+ @include box-field-layout.horizontal();
41
41
  }
42
42
 
43
43
  .rootLayoutVertical .field,
44
44
  .rootLayoutHorizontal .field {
45
- width: auto;
45
+ width: auto;
46
46
  }
47
47
 
48
48
  .isRootFullWidth .field {
49
- justify-self: stretch;
49
+ justify-self: stretch;
50
50
  }
51
51
 
52
52
  // Sizes
53
53
  .rootSizeSmall {
54
- @include box-field-sizes.size(small);
54
+ @include box-field-sizes.size(small);
55
55
  }
56
56
 
57
57
  .rootSizeMedium {
58
- @include box-field-sizes.size(medium);
58
+ @include box-field-sizes.size(medium);
59
59
  }
60
60
 
61
61
  .rootSizeLarge {
62
- @include box-field-sizes.size(large);
62
+ @include box-field-sizes.size(large);
63
63
  }
@@ -22,7 +22,6 @@ import { SelectField } from '../SelectField/SelectField'
22
22
  import { TextArea } from '../TextArea/TextArea'
23
23
  import { TextField } from '../TextField/TextField'
24
24
  import { Toggle } from '../Toggle/Toggle'
25
- import { Center } from '../Center/Center'
26
25
  import { Toolbar } from '../Toolbar/Toolbar'
27
26
  import { ToolbarItem } from '../Toolbar/ToolbarItem'
28
27
  import { FormLayout } from './FormLayout'
@@ -51,13 +50,11 @@ See [API](#api) for all available options.
51
50
  Since all form fields in React UI are styled as inline blocks, they **queue up
52
51
  one after another in a row by default.** The FormLayout component is there to
53
52
  make building **vertical and horizontal forms** easy. It uses the right tool for
54
- the job: the
55
- [CSS grid layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout).
53
+ the job: the [CSS grid layout][grid].
56
54
 
57
55
  - Put **only form field components** from React UI inside the FormLayout and
58
- make sure they are **direct descendants** of it (React
59
- [fragments](https://reactjs.org/docs/fragments.html)
60
- are supported!). All React UI form components are ready for this use case and
56
+ make sure they are **direct descendants** of it (React [fragments] are
57
+ supported!). All React UI form components are ready for this use case and
61
58
  don't need to be wrapped in any `div`s. Namely, the FormLayout supports the
62
59
  following React UI components:
63
60
  [CheckboxField](/components/checkbox-field),
@@ -73,17 +70,14 @@ the job: the
73
70
 
74
71
  👉 For usage in auto-width Modal, you may need to turn on the `autoWidth` option
75
72
  for your FormLayout. This prevents FormLayout from unexpectedly growing in
76
- browsers that
77
- [don't support](https://github.com/react-ui-org/react-ui/issues/232)
78
- [CSS subgrid](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Subgrid)
79
- in cases when there are longer validation messages or help texts.
73
+ browsers that [don't support][rui-232] [CSS subgrid][subgrid] in cases when
74
+ there are longer validation messages or help texts.
80
75
 
81
76
  ## Vertical Layout
82
77
 
83
- Vertical FormLayout works similar to the [List](/components/list) layout
84
- except that no equivalent of ListItems is needed. It stacks the form fields
85
- vertically while it forces the vertical layout mode on them. To use this layout,
86
- simply wrap your form fields with the FormLayout component:
78
+ Vertical FormLayout works similar to single-column [Grid](/components/grid)
79
+ layout while it also forces vertical layout mode on form fields. To use this
80
+ layout, simply wrap your form fields with the FormLayout component:
87
81
 
88
82
  <Playground>
89
83
  <FormLayout>
@@ -148,7 +142,7 @@ with CSS custom properties.
148
142
  <span id="label-width-options-label">Label width:</span>
149
143
  </ToolbarItem>
150
144
  <ToolbarItem>
151
- <ButtonGroup aria-labelledby="#label-width-options-label">
145
+ <ButtonGroup aria-labelledby="label-width-options-label">
152
146
  <Button
153
147
  color={labelWidth === 'default' ? 'dark' : 'primary'}
154
148
  label="default"
@@ -205,41 +199,18 @@ with CSS custom properties.
205
199
 
206
200
  ### Limitations
207
201
 
202
+ #### Label Position
203
+
204
+ Label position of inline form fields (CheckboxField, Toggle) is ignored in
205
+ horizontal FormLayout.
206
+
208
207
  #### Modals
209
208
 
210
209
  Please note the `auto` and `limited` label width options may not function
211
210
  correctly in combination with other auto layout mechanisms, e.g. the auto-width
212
- [Modal](/components/modal). It's just too much of magic that doesn't quite
211
+ [Modal](/components/modal). It's just too much of magic that does not quite
213
212
  work together yet 🎩.
214
213
 
215
- #### Inline Form Fields
216
-
217
- CheckboxField and Toggle always display their labels after inputs inside
218
- FormLayout. In other words, their labels never appear in a column with other
219
- fields' labels even when they have `labelPosition` set to `before`. This feature
220
- [will be implemented](https://github.com/react-ui-org/react-ui/issues/232)
221
- once
222
- [CSS subgrid](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Subgrid)
223
- is fully supported in
224
- [browsers that we support](/getting-started/browsers-and-devices).
225
-
226
- ## Alignment
227
-
228
- To align whole FormLayout to center of a container, simply wrap it with the
229
- [Center](/components/center) layout.
230
-
231
- <Playground>
232
- <Placeholder bordered height="24rem">
233
- <Center>
234
- <FormLayout autoWidth>
235
- <TextField label="A form element" />
236
- <TextField label="Another form element" />
237
- <TextField label="Yet another one" />
238
- </FormLayout>
239
- </Center>
240
- </Placeholder>
241
- </Playground>
242
-
243
214
  ## Custom Fields
244
215
 
245
216
  You can even place any content you need into the FormLayout — just wrap it with
@@ -267,11 +238,10 @@ as API options as such are **not** inherited.
267
238
 
268
239
  If you are in a situation with one or more box form fields inside your
269
240
  FormLayoutCustomField, you may want to have its label aligned with the fields
270
- inside. Since it's
271
- [not quite possible to do this automatically](https://github.com/react-ui-org/react-ui/issues/265)
272
- due to limited browser support, there is `innerFieldSize` option which accepts
273
- any of existing box field sizes (small, medium, or large) and is intended right
274
- for this task.
241
+ inside. Since it's [not quite possible to do this automatically][rui-265] due to
242
+ limited browser support, there is `innerFieldSize` option which accepts any of
243
+ existing box field sizes (small, medium, or large) and is intended right for
244
+ this task.
275
245
 
276
246
  <Playground>
277
247
  <FormLayout fieldLayout="horizontal" labelWidth="auto">
@@ -428,6 +398,7 @@ This is a demo of all components supported by FormLayout.
428
398
  </FormLayoutCustomField>
429
399
  <CheckboxField
430
400
  checked={isDeliveryAddress}
401
+ helpText="Uncheck if you wish to deliver to a different address."
431
402
  label="This is my delivery address"
432
403
  onChange={() => setIsDeliveryAddress(!isDeliveryAddress)}
433
404
  />
@@ -493,3 +464,9 @@ FormLayoutCustomField can be styled using a small subset of
493
464
  |------------------------------------------------------|--------------------------------------------------------------|
494
465
  | `--rui-FormField--custom--default__surrounding-text-color` | Custom field label color in default state |
495
466
  | `--rui-FormField--custom--disabled__surrounding-text-color` | Custom field label color in disabled-like state |
467
+
468
+ [grid]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
469
+ [subgrid]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Subgrid
470
+ [fragments]: https://reactjs.org/docs/fragments.html
471
+ [rui-232]: https://github.com/react-ui-org/react-ui/issues/232
472
+ [rui-265]: https://github.com/react-ui-org/react-ui/issues/265
@@ -1,7 +1,8 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../provider';
4
- import { generateResponsiveCustomProperties } from './helpers/generateResponsiveCustomProperties';
3
+ import { withGlobalProps } from '../../provider';
4
+ import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
5
+ import { generateResponsiveCustomProperties } from './_helpers/generateResponsiveCustomProperties';
5
6
  import styles from './Grid.scss';
6
7
 
7
8
  export const Grid = ({
@@ -19,7 +20,7 @@ export const Grid = ({
19
20
  tag: Tag,
20
21
  ...other
21
22
  }) => {
22
- if (!children) {
23
+ if (isChildrenEmpty(children)) {
23
24
  return null;
24
25
  }
25
26
 
@@ -76,8 +77,8 @@ Grid.propTypes = {
76
77
  md: PropTypes.string,
77
78
  lg: PropTypes.string,
78
79
  xl: PropTypes.string,
79
- xxl: PropTypes.string,
80
- xxxl: PropTypes.string,
80
+ x2l: PropTypes.string,
81
+ x3l: PropTypes.string,
81
82
  }),
82
83
  ]),
83
84
  /**
@@ -92,8 +93,8 @@ Grid.propTypes = {
92
93
  md: PropTypes.string,
93
94
  lg: PropTypes.string,
94
95
  xl: PropTypes.string,
95
- xxl: PropTypes.string,
96
- xxxl: PropTypes.string,
96
+ x2l: PropTypes.string,
97
+ x3l: PropTypes.string,
97
98
  }),
98
99
  ]),
99
100
  /**
@@ -108,12 +109,12 @@ Grid.propTypes = {
108
109
  md: PropTypes.string,
109
110
  lg: PropTypes.string,
110
111
  xl: PropTypes.string,
111
- xxl: PropTypes.string,
112
- xxxl: PropTypes.string,
112
+ x2l: PropTypes.string,
113
+ x3l: PropTypes.string,
113
114
  }),
114
115
  ]),
115
116
  /**
116
- * Items to be aligned in the grid.
117
+ * Items to be aligned in the grid. If none are provided nothing is rendered.
117
118
  */
118
119
  children: PropTypes.node,
119
120
  /**
@@ -128,8 +129,8 @@ Grid.propTypes = {
128
129
  md: PropTypes.string,
129
130
  lg: PropTypes.string,
130
131
  xl: PropTypes.string,
131
- xxl: PropTypes.string,
132
- xxxl: PropTypes.string,
132
+ x2l: PropTypes.string,
133
+ x3l: PropTypes.string,
133
134
  }),
134
135
  ]),
135
136
  /**
@@ -144,8 +145,8 @@ Grid.propTypes = {
144
145
  md: PropTypes.string,
145
146
  lg: PropTypes.string,
146
147
  xl: PropTypes.string,
147
- xxl: PropTypes.string,
148
- xxxl: PropTypes.string,
148
+ x2l: PropTypes.string,
149
+ x3l: PropTypes.string,
149
150
  }),
150
151
  ]),
151
152
  /**
@@ -164,8 +165,8 @@ Grid.propTypes = {
164
165
  md: PropTypes.string,
165
166
  lg: PropTypes.string,
166
167
  xl: PropTypes.string,
167
- xxl: PropTypes.string,
168
- xxxl: PropTypes.string,
168
+ x2l: PropTypes.string,
169
+ x3l: PropTypes.string,
169
170
  }),
170
171
  ]),
171
172
  /**
@@ -180,8 +181,8 @@ Grid.propTypes = {
180
181
  md: PropTypes.string,
181
182
  lg: PropTypes.string,
182
183
  xl: PropTypes.string,
183
- xxl: PropTypes.string,
184
- xxxl: PropTypes.string,
184
+ x2l: PropTypes.string,
185
+ x3l: PropTypes.string,
185
186
  }),
186
187
  ]),
187
188
  /**
@@ -196,8 +197,8 @@ Grid.propTypes = {
196
197
  md: PropTypes.string,
197
198
  lg: PropTypes.string,
198
199
  xl: PropTypes.string,
199
- xxl: PropTypes.string,
200
- xxxl: PropTypes.string,
200
+ x2l: PropTypes.string,
201
+ x3l: PropTypes.string,
201
202
  }),
202
203
  ]),
203
204
  /**
@@ -212,8 +213,8 @@ Grid.propTypes = {
212
213
  md: PropTypes.string,
213
214
  lg: PropTypes.string,
214
215
  xl: PropTypes.string,
215
- xxl: PropTypes.string,
216
- xxxl: PropTypes.string,
216
+ x2l: PropTypes.string,
217
+ x3l: PropTypes.string,
217
218
  }),
218
219
  ]),
219
220
  /**
@@ -223,6 +224,6 @@ Grid.propTypes = {
223
224
  tag: PropTypes.string,
224
225
  };
225
226
 
226
- export const GridWithContext = withProviderContext(Grid, 'Grid');
227
+ export const GridWithGlobalProps = withGlobalProps(Grid, 'Grid');
227
228
 
228
- export default GridWithContext;
229
+ export default GridWithGlobalProps;