@react-ui-org/react-ui 0.44.0 → 0.46.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. package/CONTRIBUTING.md +7 -0
  2. package/dist/lib.development.js +209 -305
  3. package/dist/lib.js +1 -1
  4. package/package.json +10 -13
  5. package/src/lib/components/Alert/Alert.jsx +4 -3
  6. package/src/lib/components/Alert/Alert.scss +48 -48
  7. package/src/lib/components/Alert/_settings.scss +4 -4
  8. package/src/lib/components/Alert/_theme.scss +50 -50
  9. package/src/lib/components/Alert/_tools.scss +6 -6
  10. package/src/lib/components/Badge/Badge.jsx +6 -8
  11. package/src/lib/components/Badge/Badge.scss +57 -57
  12. package/src/lib/components/Button/Button.jsx +10 -9
  13. package/src/lib/components/Button/Button.scss +2 -2
  14. package/src/lib/components/Button/README.mdx +8 -3
  15. package/src/lib/components/Button/_base.scss +65 -65
  16. package/src/lib/components/Button/_priorities.scss +49 -49
  17. package/src/lib/components/Button/_settings.scss +10 -10
  18. package/src/lib/components/Button/_theme.scss +18 -15
  19. package/src/lib/components/Button/_tools.scss +98 -100
  20. package/src/lib/components/ButtonGroup/ButtonGroup.jsx +31 -22
  21. package/src/lib/components/ButtonGroup/ButtonGroup.scss +3 -3
  22. package/src/lib/components/ButtonGroup/README.mdx +4 -4
  23. package/src/lib/components/Card/Card.jsx +7 -6
  24. package/src/lib/components/Card/Card.scss +28 -28
  25. package/src/lib/components/Card/CardBody.jsx +5 -11
  26. package/src/lib/components/Card/CardFooter.jsx +10 -5
  27. package/src/lib/components/Card/README.mdx +2 -2
  28. package/src/lib/components/Card/_theme.scss +50 -50
  29. package/src/lib/components/Card/_tools.scss +6 -6
  30. package/src/lib/components/CheckboxField/CheckboxField.jsx +18 -17
  31. package/src/lib/components/CheckboxField/CheckboxField.scss +20 -20
  32. package/src/lib/components/CheckboxField/README.mdx +3 -3
  33. package/src/lib/components/FileInputField/FileInputField.jsx +13 -12
  34. package/src/lib/components/FileInputField/FileInputField.scss +19 -19
  35. package/src/lib/components/FileInputField/README.mdx +1 -1
  36. package/src/lib/components/FormLayout/FormLayout.jsx +16 -14
  37. package/src/lib/components/FormLayout/FormLayout.scss +17 -17
  38. package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +15 -9
  39. package/src/lib/components/FormLayout/FormLayoutCustomField.scss +18 -18
  40. package/src/lib/components/FormLayout/README.mdx +27 -49
  41. package/src/lib/components/Grid/Grid.jsx +4 -3
  42. package/src/lib/components/Grid/Grid.scss +32 -23
  43. package/src/lib/components/Grid/GridSpan.jsx +4 -3
  44. package/src/lib/components/Grid/{helpers → _helpers}/generateResponsiveCustomProperties.js +0 -2
  45. package/src/lib/components/Grid/_theme.scss +9 -9
  46. package/src/lib/components/Grid/_tools.scss +20 -20
  47. package/src/lib/components/List/List.jsx +14 -12
  48. package/src/lib/components/List/List.scss +21 -21
  49. package/src/lib/components/List/ListItem.jsx +3 -2
  50. package/src/lib/components/List/README.mdx +1 -1
  51. package/src/lib/components/Media/Media.jsx +12 -5
  52. package/src/lib/components/Media/Media.scss +6 -6
  53. package/src/lib/components/Media/MediaBody.jsx +18 -7
  54. package/src/lib/components/Media/MediaObject.jsx +18 -7
  55. package/src/lib/components/Modal/Modal.jsx +8 -6
  56. package/src/lib/components/Modal/Modal.scss +73 -73
  57. package/src/lib/components/Modal/README.mdx +2 -2
  58. package/src/lib/components/Modal/_settings.scss +5 -5
  59. package/src/lib/components/Modal/_theme.scss +17 -17
  60. package/src/lib/components/Paper/Paper.jsx +6 -6
  61. package/src/lib/components/Paper/Paper.scss +8 -8
  62. package/src/lib/components/Paper/README.mdx +1 -1
  63. package/src/lib/components/Radio/README.mdx +4 -4
  64. package/src/lib/components/Radio/Radio.jsx +12 -11
  65. package/src/lib/components/Radio/Radio.scss +26 -26
  66. package/src/lib/components/ScrollView/README.mdx +4 -1
  67. package/src/lib/components/ScrollView/ScrollView.jsx +11 -9
  68. package/src/lib/components/ScrollView/ScrollView.scss +113 -113
  69. package/src/lib/{services/elementPositionService.js → components/ScrollView/_helpers/getElementsPositionDifference.js} +0 -2
  70. package/src/lib/{hooks → components/ScrollView/_hooks}/useLoadResizeHook.js +1 -1
  71. package/src/lib/{hooks → components/ScrollView/_hooks}/useScrollPositionHook.js +1 -1
  72. package/src/lib/components/SelectField/README.mdx +4 -4
  73. package/src/lib/components/SelectField/SelectField.jsx +14 -13
  74. package/src/lib/components/SelectField/SelectField.scss +30 -30
  75. package/src/lib/components/Table/README.mdx +3 -3
  76. package/src/lib/components/Table/Table.scss +28 -35
  77. package/src/lib/components/Table/_settings.scss +5 -5
  78. package/src/lib/components/Tabs/README.mdx +1 -1
  79. package/src/lib/components/Tabs/Tabs.jsx +1 -2
  80. package/src/lib/components/Tabs/Tabs.scss +21 -21
  81. package/src/lib/components/Tabs/TabsItem.jsx +4 -3
  82. package/src/lib/components/Tabs/TabsItem.scss +78 -78
  83. package/src/lib/components/Text/README.mdx +1 -1
  84. package/src/lib/components/Text/Text.jsx +13 -6
  85. package/src/lib/components/Text/Text.scss +23 -13
  86. package/src/lib/components/Text/_helpers/getRootClampClassName.js +11 -0
  87. package/src/lib/components/Text/{helpers → _helpers}/getRootHyphensClassName.js +1 -1
  88. package/src/lib/components/Text/{helpers → _helpers}/getRootWordWrappingClassName.js +1 -1
  89. package/src/lib/components/TextArea/README.mdx +1 -1
  90. package/src/lib/components/TextArea/TextArea.jsx +18 -14
  91. package/src/lib/components/TextArea/TextArea.scss +27 -27
  92. package/src/lib/components/TextField/README.mdx +1 -1
  93. package/src/lib/components/TextField/TextField.jsx +16 -14
  94. package/src/lib/components/TextField/TextField.scss +28 -28
  95. package/src/lib/components/TextLink/README.mdx +77 -0
  96. package/src/lib/components/{Link/Link.jsx → TextLink/TextLink.jsx} +12 -13
  97. package/src/lib/components/TextLink/TextLink.scss +11 -0
  98. package/src/lib/components/TextLink/_theme.scss +4 -0
  99. package/src/lib/components/TextLink/index.js +1 -0
  100. package/src/lib/components/Toggle/README.mdx +3 -3
  101. package/src/lib/components/Toggle/Toggle.jsx +18 -17
  102. package/src/lib/components/Toggle/Toggle.scss +20 -20
  103. package/src/lib/components/Toolbar/README.mdx +19 -3
  104. package/src/lib/components/Toolbar/Toolbar.jsx +23 -14
  105. package/src/lib/components/Toolbar/Toolbar.scss +35 -30
  106. package/src/lib/components/Toolbar/ToolbarGroup.jsx +18 -13
  107. package/src/lib/components/Toolbar/ToolbarItem.jsx +26 -7
  108. package/src/lib/{helpers → components/_helpers}/getRootColorClassName.js +1 -1
  109. package/src/lib/{helpers → components/_helpers}/getRootSizeClassName.js +1 -1
  110. package/src/lib/{helpers → components/_helpers}/getRootValidationStateClassName.js +1 -1
  111. package/src/lib/components/_helpers/isChildrenEmpty.js +3 -0
  112. package/src/lib/{helpers → components/_helpers}/resolveContextOrProp.js +0 -0
  113. package/src/lib/{utils → components/_helpers}/transferProps.js +1 -1
  114. package/src/lib/foundation.scss +11 -11
  115. package/src/lib/helpers.scss +2 -2
  116. package/src/lib/index.js +4 -8
  117. package/src/lib/styles/_utilities.scss +13 -13
  118. package/src/lib/styles/elements/_code.scss +7 -7
  119. package/src/lib/styles/elements/_links.scss +8 -8
  120. package/src/lib/styles/elements/_lists.scss +3 -3
  121. package/src/lib/styles/elements/_page.scss +14 -14
  122. package/src/lib/styles/elements/_rulers.scss +6 -6
  123. package/src/lib/styles/elements/_small.scss +2 -2
  124. package/src/lib/styles/generic/_box-sizing.scss +3 -2
  125. package/src/lib/styles/generic/_forms.scss +3 -3
  126. package/src/lib/styles/generic/_reset.scss +6 -6
  127. package/src/lib/styles/generic/_shared.scss +3 -3
  128. package/src/lib/styles/helpers/_animation.scss +8 -8
  129. package/src/lib/styles/settings/_breakpoints.scss +7 -7
  130. package/src/lib/styles/settings/_escaped-characters.scss +5 -5
  131. package/src/lib/styles/settings/_form-fields.scss +24 -24
  132. package/src/lib/styles/settings/_utilities.scss +112 -100
  133. package/src/lib/styles/theme/_colors.scss +50 -50
  134. package/src/lib/styles/theme/_form-fields.scss +32 -32
  135. package/src/lib/styles/theme/_spacing.scss +11 -11
  136. package/src/lib/styles/theme/_typography.scss +12 -11
  137. package/src/lib/styles/theme-constants/_breakpoints.scss +2 -2
  138. package/src/lib/styles/theme-constants/_colors.scss +2 -2
  139. package/src/lib/styles/theme-constants/_svg.scss +1 -2
  140. package/src/lib/styles/tools/_accessibility.scss +29 -29
  141. package/src/lib/styles/tools/_breakpoint.scss +11 -14
  142. package/src/lib/styles/tools/_caret.scss +8 -8
  143. package/src/lib/styles/tools/_colors.scss +3 -3
  144. package/src/lib/styles/tools/_reset.scss +24 -21
  145. package/src/lib/styles/tools/_scrollbar.scss +4 -4
  146. package/src/lib/styles/tools/_spacing.scss +17 -21
  147. package/src/lib/styles/tools/_string.scss +9 -9
  148. package/src/lib/styles/tools/_svg.scss +13 -16
  149. package/src/lib/styles/tools/_transition.scss +42 -44
  150. package/src/lib/styles/tools/_utilities.scss +19 -19
  151. package/src/lib/styles/tools/form-fields/_box-field-elements.scss +88 -88
  152. package/src/lib/styles/tools/form-fields/_box-field-layout.scss +147 -147
  153. package/src/lib/styles/tools/form-fields/_box-field-sizes.scss +13 -15
  154. package/src/lib/styles/tools/form-fields/_foundation.scss +12 -12
  155. package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +82 -71
  156. package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +88 -47
  157. package/src/lib/styles/tools/form-fields/_variants.scss +104 -106
  158. package/src/lib/theme.scss +958 -954
  159. package/src/lib/utils/classNames.js +8 -0
  160. package/src/lib/components/CTA/CTA.jsx +0 -60
  161. package/src/lib/components/CTA/CTA.scss +0 -71
  162. package/src/lib/components/CTA/CTACenter.jsx +0 -27
  163. package/src/lib/components/CTA/CTAEnd.jsx +0 -27
  164. package/src/lib/components/CTA/CTAStart.jsx +0 -27
  165. package/src/lib/components/CTA/README.mdx +0 -119
  166. package/src/lib/components/CTA/index.js +0 -4
  167. package/src/lib/components/Center/Center.jsx +0 -27
  168. package/src/lib/components/Center/Center.scss +0 -7
  169. package/src/lib/components/Center/README.mdx +0 -52
  170. package/src/lib/components/Center/index.js +0 -1
  171. package/src/lib/components/Link/Link.scss +0 -11
  172. package/src/lib/components/Link/README.mdx +0 -85
  173. package/src/lib/components/Link/_theme.scss +0 -4
  174. package/src/lib/components/Link/index.js +0 -1
@@ -9,54 +9,54 @@ $disabled-background-color: var(--rui-Card--disabled__background-color);
9
9
  $disabled-opacity: var(--rui-Card--disabled__opacity);
10
10
 
11
11
  $colors: (
12
- primary: (
13
- color: var(--rui-Card--primary__color),
14
- border-color: var(--rui-Card--primary__border-color),
15
- background-color: var(--rui-Card--primary__background-color),
16
- ),
17
- secondary: (
18
- color: var(--rui-Card--secondary__color),
19
- border-color: var(--rui-Card--secondary__border-color),
20
- background-color: var(--rui-Card--secondary__background-color),
21
- ),
22
- success: (
23
- color: var(--rui-Card--success__color),
24
- border-color: var(--rui-Card--success__border-color),
25
- background-color: var(--rui-Card--success__background-color),
26
- ),
27
- warning: (
28
- color: var(--rui-Card--warning__color),
29
- border-color: var(--rui-Card--warning__border-color),
30
- background-color: var(--rui-Card--warning__background-color),
31
- ),
32
- danger: (
33
- color: var(--rui-Card--danger__color),
34
- border-color: var(--rui-Card--danger__border-color),
35
- background-color: var(--rui-Card--danger__background-color),
36
- ),
37
- info: (
38
- color: var(--rui-Card--info__color),
39
- border-color: var(--rui-Card--info__border-color),
40
- background-color: var(--rui-Card--info__background-color),
41
- ),
42
- help: (
43
- color: var(--rui-Card--help__color),
44
- border-color: var(--rui-Card--help__border-color),
45
- background-color: var(--rui-Card--help__background-color),
46
- ),
47
- note: (
48
- color: var(--rui-Card--note__color),
49
- border-color: var(--rui-Card--note__border-color),
50
- background-color: var(--rui-Card--note__background-color),
51
- ),
52
- light: (
53
- color: var(--rui-Card--light__color),
54
- border-color: var(--rui-Card--light__border-color),
55
- background-color: var(--rui-Card--light__background-color),
56
- ),
57
- dark: (
58
- color: var(--rui-Card--dark__color),
59
- border-color: var(--rui-Card--dark__border-color),
60
- background-color: var(--rui-Card--dark__background-color),
61
- ),
12
+ primary: (
13
+ color: var(--rui-Card--primary__color),
14
+ border-color: var(--rui-Card--primary__border-color),
15
+ background-color: var(--rui-Card--primary__background-color),
16
+ ),
17
+ secondary: (
18
+ color: var(--rui-Card--secondary__color),
19
+ border-color: var(--rui-Card--secondary__border-color),
20
+ background-color: var(--rui-Card--secondary__background-color),
21
+ ),
22
+ success: (
23
+ color: var(--rui-Card--success__color),
24
+ border-color: var(--rui-Card--success__border-color),
25
+ background-color: var(--rui-Card--success__background-color),
26
+ ),
27
+ warning: (
28
+ color: var(--rui-Card--warning__color),
29
+ border-color: var(--rui-Card--warning__border-color),
30
+ background-color: var(--rui-Card--warning__background-color),
31
+ ),
32
+ danger: (
33
+ color: var(--rui-Card--danger__color),
34
+ border-color: var(--rui-Card--danger__border-color),
35
+ background-color: var(--rui-Card--danger__background-color),
36
+ ),
37
+ info: (
38
+ color: var(--rui-Card--info__color),
39
+ border-color: var(--rui-Card--info__border-color),
40
+ background-color: var(--rui-Card--info__background-color),
41
+ ),
42
+ help: (
43
+ color: var(--rui-Card--help__color),
44
+ border-color: var(--rui-Card--help__border-color),
45
+ background-color: var(--rui-Card--help__background-color),
46
+ ),
47
+ note: (
48
+ color: var(--rui-Card--note__color),
49
+ border-color: var(--rui-Card--note__border-color),
50
+ background-color: var(--rui-Card--note__background-color),
51
+ ),
52
+ light: (
53
+ color: var(--rui-Card--light__color),
54
+ border-color: var(--rui-Card--light__border-color),
55
+ background-color: var(--rui-Card--light__background-color),
56
+ ),
57
+ dark: (
58
+ color: var(--rui-Card--dark__color),
59
+ border-color: var(--rui-Card--dark__border-color),
60
+ background-color: var(--rui-Card--dark__background-color),
61
+ ),
62
62
  );
@@ -1,10 +1,10 @@
1
- @use 'sass:map';
2
- @use 'theme';
1
+ @use "sass:map";
2
+ @use "theme";
3
3
 
4
4
  @mixin color($color) {
5
- $color-variant-properties: map.get(theme.$colors, $color);
5
+ $color-variant-properties: map.get(theme.$colors, $color);
6
6
 
7
- --rui-local-color: #{map.get($color-variant-properties, color)};
8
- --rui-local-border-color: #{map.get($color-variant-properties, border-color)};
9
- --rui-local-background-color: #{map.get($color-variant-properties, background-color)};
7
+ --rui-local-color: #{map.get($color-variant-properties, color)};
8
+ --rui-local-border-color: #{map.get($color-variant-properties, border-color)};
9
+ --rui-local-background-color: #{map.get($color-variant-properties, background-color)};
10
10
  }
@@ -1,8 +1,9 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
- import getRootValidationStateClassName from '../../helpers/getRootValidationStateClassName';
4
3
  import { withProviderContext } from '../../provider';
5
- import transferProps from '../../utils/transferProps';
4
+ import { classNames } from '../../utils/classNames';
5
+ import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
6
+ import { transferProps } from '../_helpers/transferProps';
6
7
  import { FormLayoutContext } from '../FormLayout';
7
8
  import withForwardedRef from '../withForwardedRef';
8
9
  import styles from './CheckboxField.scss';
@@ -26,19 +27,28 @@ export const CheckboxField = ({
26
27
 
27
28
  return (
28
29
  <label
29
- className={[
30
+ className={classNames(
30
31
  styles.root,
31
- context ? styles.isRootInFormLayout : '',
32
+ context && styles.isRootInFormLayout,
32
33
  context && context.layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
33
- labelPosition === 'before' ? styles.hasRootLabelBefore : '',
34
- disabled ? styles.isRootDisabled : '',
35
- required ? styles.isRootRequired : '',
34
+ labelPosition === 'before' && styles.hasRootLabelBefore,
35
+ disabled && styles.isRootDisabled,
36
+ required && styles.isRootRequired,
36
37
  getRootValidationStateClassName(validationState, styles),
37
- ].join(' ')}
38
+ )}
38
39
  htmlFor={id}
39
40
  id={id && `${id}__label`}
40
41
  >
41
42
  <div className={styles.field}>
43
+ <div
44
+ className={classNames(
45
+ styles.label,
46
+ !isLabelVisible && styles.isLabelHidden,
47
+ )}
48
+ id={id && `${id}__labelText`}
49
+ >
50
+ {label}
51
+ </div>
42
52
  <input
43
53
  {...transferProps(restProps)}
44
54
  checked={checked}
@@ -50,15 +60,6 @@ export const CheckboxField = ({
50
60
  type="checkbox"
51
61
  value={value}
52
62
  />
53
- <div
54
- className={[
55
- styles.label,
56
- isLabelVisible ? '' : styles.isLabelHidden,
57
- ].join(' ')}
58
- id={id && `${id}__labelText`}
59
- >
60
- {label}
61
- </div>
62
63
  </div>
63
64
  {helpText && (
64
65
  <div
@@ -1,61 +1,61 @@
1
- @use '../../styles/tools/form-fields/foundation';
2
- @use '../../styles/tools/form-fields/inline-field-elements';
3
- @use '../../styles/tools/form-fields/inline-field-layout';
4
- @use '../../styles/tools/form-fields/variants';
5
- @use '../../styles/tools/accessibility';
1
+ @use "../../styles/tools/form-fields/foundation";
2
+ @use "../../styles/tools/form-fields/inline-field-elements";
3
+ @use "../../styles/tools/form-fields/inline-field-layout";
4
+ @use "../../styles/tools/form-fields/variants";
5
+ @use "../../styles/tools/accessibility";
6
6
 
7
7
  // Foundation
8
8
  .root {
9
- @include foundation.root();
10
- @include inline-field-layout.root();
11
- @include inline-field-elements.min-tap-target($type: checkbox);
12
- @include variants.visual(check);
9
+ @include foundation.root();
10
+ @include inline-field-layout.root();
11
+ @include inline-field-elements.min-tap-target($type: checkbox);
12
+ @include variants.visual(check);
13
13
  }
14
14
 
15
15
  .label {
16
- @include foundation.label();
16
+ @include foundation.label();
17
17
  }
18
18
 
19
19
  .field {
20
- @include inline-field-layout.field();
20
+ @include inline-field-layout.field($type: checkbox);
21
21
  }
22
22
 
23
23
  .input {
24
- @include inline-field-elements.check-input($type: checkbox);
24
+ @include inline-field-elements.check-input($type: checkbox);
25
25
  }
26
26
 
27
27
  .helpText,
28
28
  .validationText {
29
- @include foundation.help-text();
29
+ @include foundation.help-text();
30
30
  }
31
31
 
32
32
  .isRootRequired .label {
33
- @include foundation.label-required();
33
+ @include foundation.label-required();
34
34
  }
35
35
 
36
36
  // States
37
37
  .isRootStateInvalid {
38
- @include variants.validation(invalid);
38
+ @include variants.validation(invalid);
39
39
  }
40
40
 
41
41
  .isRootStateValid {
42
- @include variants.validation(valid);
42
+ @include variants.validation(valid);
43
43
  }
44
44
 
45
45
  .isRootStateWarning {
46
- @include variants.validation(warning);
46
+ @include variants.validation(warning);
47
47
  }
48
48
 
49
49
  // Invisible label
50
50
  .isLabelHidden {
51
- @include accessibility.hide-text();
51
+ @include accessibility.hide-text();
52
52
  }
53
53
 
54
54
  // Layouts
55
55
  .hasRootLabelBefore {
56
- @include inline-field-layout.has-label-before();
56
+ @include inline-field-layout.has-label-before();
57
57
  }
58
58
 
59
59
  .isRootInFormLayout {
60
- @include inline-field-layout.in-form-layout();
60
+ @include inline-field-layout.in-form-layout();
61
61
  }
@@ -44,13 +44,13 @@ See [API](#api) for all available options.
44
44
  - Use the CheckboxField when there are lists of options and the user may
45
45
  **select any number of choices,** including zero, one, or several. For
46
46
  selecting just a single option from the list, use either the
47
- [Radio](/components/ui/radio) or [SelectField](/components/ui/select-field)
47
+ [Radio](/components/radio) or [SelectField](/components/select-field)
48
48
  component.
49
49
 
50
50
  - Use the CheckboxField for boolean (true/false) input **in forms that require
51
51
  to be confirmed** by a button to become active. To toggle things on or off
52
52
  with an immediate effect (without confirmation), use rather the
53
- [Toggle](/components/ui/toggle) component.
53
+ [Toggle](/components/toggle) component.
54
54
 
55
55
  - **Use positive wording for the checkbox label,** so that it's clear what will
56
56
  happen when the user turns on the checkbox. Avoid negations such as “Don't
@@ -185,7 +185,7 @@ Disabled state makes the input unavailable.
185
185
 
186
186
  In addition to the options below, you can specify [React synthetic events] or
187
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
188
+ passed to the `<input>` HTML element. This enables making the component
189
189
  interactive and helps improve its accessibility.
190
190
 
191
191
  <Props table of={CheckboxField} />
@@ -1,9 +1,10 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
- import getRootValidationStateClassName from '../../helpers/getRootValidationStateClassName';
4
- import { resolveContextOrProp } from '../../helpers/resolveContextOrProp';
5
3
  import { withProviderContext } from '../../provider';
6
- import transferProps from '../../utils/transferProps';
4
+ import { classNames } from '../../utils/classNames';
5
+ import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
6
+ import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
7
+ import { transferProps } from '../_helpers/transferProps';
7
8
  import { FormLayoutContext } from '../FormLayout';
8
9
  import withForwardedRef from '../withForwardedRef';
9
10
  import styles from './FileInputField.scss';
@@ -26,25 +27,25 @@ export const FileInputField = ({
26
27
 
27
28
  return (
28
29
  <label
29
- className={[
30
+ className={classNames(
30
31
  styles.root,
31
- fullWidth ? styles.isRootFullWidth : '',
32
- context ? styles.isRootInFormLayout : '',
32
+ fullWidth && styles.isRootFullWidth,
33
+ context && styles.isRootInFormLayout,
33
34
  resolveContextOrProp(context && context.layout, layout) === 'horizontal'
34
35
  ? styles.rootLayoutHorizontal
35
36
  : styles.rootLayoutVertical,
36
- disabled ? styles.isRootDisabled : '',
37
- required ? styles.isRootRequired : '',
37
+ disabled && styles.isRootDisabled,
38
+ required && styles.isRootRequired,
38
39
  getRootValidationStateClassName(validationState, styles),
39
- ].join(' ')}
40
+ )}
40
41
  htmlFor={id}
41
42
  id={id && `${id}__label`}
42
43
  >
43
44
  <div
44
- className={[
45
+ className={classNames(
45
46
  styles.label,
46
- isLabelVisible ? '' : styles.isLabelHidden,
47
- ].join(' ')}
47
+ !isLabelVisible && styles.isLabelHidden,
48
+ )}
48
49
  id={id && `${id}__labelText`}
49
50
  >
50
51
  {label}
@@ -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
3
  import { withProviderContext } 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
  /**
@@ -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
3
  import { withProviderContext } from '../../provider';
6
- import styles from './FormLayoutCustomField.scss';
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
  /**