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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/CONTRIBUTING.md +44 -25
  2. package/README.md +1 -1
  3. package/dist/lib.development.js +1597 -651
  4. package/dist/lib.js +1 -9
  5. package/package.json +47 -46
  6. package/src/lib/components/{ui/Alert → Alert}/Alert.jsx +17 -14
  7. package/src/lib/components/{ui/Alert → Alert}/Alert.scss +3 -3
  8. package/src/lib/components/{ui/Alert → Alert}/README.mdx +6 -6
  9. package/src/lib/components/{ui/Alert → Alert}/_settings.scss +1 -1
  10. package/src/lib/components/{ui/Alert → Alert}/_theme.scss +0 -0
  11. package/src/lib/components/{ui/Alert → Alert}/_tools.scss +0 -0
  12. package/src/lib/components/{ui/Alert → Alert}/index.js +0 -0
  13. package/src/lib/components/{ui/Badge → Badge}/Badge.jsx +2 -2
  14. package/src/lib/components/{ui/Badge → Badge}/Badge.scss +3 -3
  15. package/src/lib/components/{ui/Badge → Badge}/README.mdx +3 -3
  16. package/src/lib/components/{ui/Badge → Badge}/index.js +0 -0
  17. package/src/lib/components/Button/Button.jsx +198 -0
  18. package/src/lib/components/{ui/Button → Button}/Button.scss +0 -0
  19. package/src/lib/components/{ui/Button → Button}/README.mdx +161 -76
  20. package/src/lib/components/Button/_base.scss +148 -0
  21. package/src/lib/components/{ui/Button → Button}/_priorities.scss +0 -4
  22. package/src/lib/components/{ui/Button → Button}/_settings.scss +2 -3
  23. package/src/lib/components/{ui/Button → Button}/_theme.scss +3 -11
  24. package/src/lib/components/{ui/Button → Button}/_tools.scss +27 -44
  25. package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +33 -0
  26. package/src/lib/components/{ui/Button → Button}/helpers/getRootPriorityClassName.js +0 -4
  27. package/src/lib/components/{ui/Button → Button}/index.js +0 -0
  28. package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/ButtonGroup.jsx +9 -11
  29. package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/ButtonGroup.scss +0 -0
  30. package/src/lib/components/ButtonGroup/ButtonGroupContext.js +3 -0
  31. package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/README.mdx +30 -6
  32. package/src/lib/components/ButtonGroup/index.js +2 -0
  33. package/src/lib/components/{layout/CTA → CTA}/CTA.jsx +5 -2
  34. package/src/lib/components/{layout/CTA → CTA}/CTA.scss +2 -2
  35. package/src/lib/components/{layout/CTA → CTA}/CTACenter.jsx +1 -1
  36. package/src/lib/components/{layout/CTA → CTA}/CTAEnd.jsx +1 -1
  37. package/src/lib/components/{layout/CTA → CTA}/CTAStart.jsx +1 -1
  38. package/src/lib/components/{layout/CTA → CTA}/README.mdx +4 -4
  39. package/src/lib/components/{layout/CTA → CTA}/index.js +0 -0
  40. package/src/lib/components/{ui/Card → Card}/Card.jsx +6 -4
  41. package/src/lib/components/{ui/Card → Card}/Card.scss +1 -1
  42. package/src/lib/components/{ui/Card → Card}/CardBody.jsx +1 -1
  43. package/src/lib/components/{ui/Card → Card}/CardFooter.jsx +1 -1
  44. package/src/lib/components/{ui/Card → Card}/README.mdx +4 -4
  45. package/src/lib/components/{ui/Card → Card}/_theme.scss +0 -0
  46. package/src/lib/components/{ui/Card → Card}/_tools.scss +0 -0
  47. package/src/lib/components/{ui/Card → Card}/index.js +0 -0
  48. package/src/lib/components/{layout/Center → Center}/Center.jsx +1 -1
  49. package/src/lib/components/{layout/Center → Center}/Center.scss +0 -0
  50. package/src/lib/components/{layout/Center → Center}/README.mdx +2 -2
  51. package/src/lib/components/{layout/Center → Center}/index.js +0 -0
  52. package/src/lib/components/CheckboxField/CheckboxField.jsx +164 -0
  53. package/src/lib/components/{ui/CheckboxField → CheckboxField}/CheckboxField.scss +5 -5
  54. package/src/lib/components/{ui/CheckboxField → CheckboxField}/README.mdx +17 -14
  55. package/src/lib/components/{ui/CheckboxField → CheckboxField}/index.js +0 -0
  56. package/src/lib/components/FileInputField/FileInputField.jsx +162 -0
  57. package/src/lib/components/{ui/FileInputField → FileInputField}/FileInputField.scss +5 -5
  58. package/src/lib/components/{ui/FileInputField → FileInputField}/README.mdx +8 -6
  59. package/src/lib/components/{ui/FileInputField → FileInputField}/index.js +0 -0
  60. package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayout.jsx +16 -18
  61. package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayout.scss +3 -3
  62. package/src/lib/components/FormLayout/FormLayoutContext.js +3 -0
  63. package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayoutCustomField.jsx +33 -30
  64. package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayoutCustomField.scss +4 -4
  65. package/src/lib/components/{layout/FormLayout → FormLayout}/README.mdx +37 -47
  66. package/src/lib/components/{layout/FormLayout → FormLayout}/_theme.scss +0 -0
  67. package/src/lib/components/{layout/FormLayout → FormLayout}/index.js +1 -0
  68. package/src/lib/components/{layout/Grid → Grid}/Grid.jsx +23 -5
  69. package/src/lib/components/{layout/Grid → Grid}/Grid.scss +13 -4
  70. package/src/lib/components/{layout/Grid → Grid}/GridSpan.jsx +10 -3
  71. package/src/lib/components/{layout/Grid → Grid}/README.mdx +42 -38
  72. package/src/lib/components/{layout/Grid → Grid}/_theme.scss +1 -2
  73. package/src/lib/components/{layout/Grid → Grid}/_tools.scss +2 -2
  74. package/src/lib/components/{layout/Grid → Grid}/helpers/generateResponsiveCustomProperties.js +0 -0
  75. package/src/lib/components/{layout/Grid → Grid}/index.js +0 -0
  76. package/src/lib/components/Link/Link.jsx +45 -0
  77. package/src/lib/components/Link/Link.scss +11 -0
  78. package/src/lib/components/Link/README.mdx +85 -0
  79. package/src/lib/components/Link/_theme.scss +4 -0
  80. package/src/lib/components/Link/index.js +1 -0
  81. package/src/lib/components/{layout/List → List}/List.jsx +1 -1
  82. package/src/lib/components/{layout/List → List}/List.scss +2 -2
  83. package/src/lib/components/{layout/List → List}/ListItem.jsx +1 -1
  84. package/src/lib/components/{layout/List → List}/README.mdx +3 -3
  85. package/src/lib/components/{layout/List → List}/_theme.scss +0 -0
  86. package/src/lib/components/{layout/List → List}/index.js +0 -0
  87. package/src/lib/components/{layout/Media → Media}/Media.jsx +4 -2
  88. package/src/lib/components/{layout/Media → Media}/Media.scss +1 -1
  89. package/src/lib/components/{layout/Media → Media}/MediaBody.jsx +1 -1
  90. package/src/lib/components/{layout/Media → Media}/MediaObject.jsx +1 -1
  91. package/src/lib/components/{layout/Media → Media}/README.mdx +2 -2
  92. package/src/lib/components/{layout/Media → Media}/index.js +0 -0
  93. package/src/lib/components/{ui/Modal → Modal}/Modal.jsx +28 -27
  94. package/src/lib/components/{ui/Modal → Modal}/Modal.scss +5 -5
  95. package/src/lib/components/{ui/Modal → Modal}/README.mdx +42 -42
  96. package/src/lib/components/{ui/Modal → Modal}/_settings.scss +4 -4
  97. package/src/lib/components/{ui/Modal → Modal}/_theme.scss +0 -0
  98. package/src/lib/components/{ui/Modal → Modal}/index.js +0 -0
  99. package/src/lib/components/{ui/Paper → Paper}/Paper.jsx +8 -1
  100. package/src/lib/components/{ui/Paper → Paper}/Paper.scss +5 -0
  101. package/src/lib/components/{ui/Paper → Paper}/README.mdx +15 -3
  102. package/src/lib/components/{ui/Paper → Paper}/_theme.scss +2 -0
  103. package/src/lib/components/{ui/Paper → Paper}/index.js +0 -0
  104. package/src/lib/components/{ui/Radio → Radio}/README.mdx +20 -17
  105. package/src/lib/components/Radio/Radio.jsx +188 -0
  106. package/src/lib/components/{ui/Radio → Radio}/Radio.scss +9 -9
  107. package/src/lib/components/{ui/Radio → Radio}/index.js +0 -0
  108. package/src/lib/components/{ui/ScrollView → ScrollView}/README.mdx +11 -11
  109. package/src/lib/components/{ui/ScrollView → ScrollView}/ScrollView.jsx +9 -10
  110. package/src/lib/components/{ui/ScrollView → ScrollView}/ScrollView.scss +6 -6
  111. package/src/lib/components/{ui/ScrollView → ScrollView}/_theme.scss +0 -0
  112. package/src/lib/components/{ui/ScrollView → ScrollView}/index.js +0 -0
  113. package/src/lib/components/{ui/SelectField → SelectField}/README.mdx +47 -44
  114. package/src/lib/components/SelectField/SelectField.jsx +219 -0
  115. package/src/lib/components/{ui/SelectField → SelectField}/SelectField.scss +6 -6
  116. package/src/lib/components/{ui/SelectField → SelectField}/index.js +0 -0
  117. package/src/lib/components/{ui/Table → Table}/README.mdx +10 -10
  118. package/src/lib/components/{ui/Table → Table}/Table.jsx +9 -13
  119. package/src/lib/components/{ui/Table → Table}/Table.scss +1 -1
  120. package/src/lib/components/{ui/Table → Table}/_settings.scss +4 -4
  121. package/src/lib/components/{ui/Table → Table}/index.js +0 -0
  122. package/src/lib/components/{ui/Tabs → Tabs}/README.mdx +4 -4
  123. package/src/lib/components/{ui/Tabs → Tabs}/Tabs.jsx +4 -4
  124. package/src/lib/components/{ui/Tabs → Tabs}/Tabs.scss +1 -1
  125. package/src/lib/components/{ui/Tabs → Tabs}/TabsItem.jsx +4 -3
  126. package/src/lib/components/{ui/Tabs → Tabs}/TabsItem.scss +3 -3
  127. package/src/lib/components/{ui/Tabs → Tabs}/_theme.scss +0 -0
  128. package/src/lib/components/{ui/Tabs → Tabs}/index.js +0 -0
  129. package/src/lib/components/{ui/Text → Text}/README.mdx +19 -19
  130. package/src/lib/components/{ui/Text → Text}/Text.jsx +1 -1
  131. package/src/lib/components/{ui/Text → Text}/Text.scss +0 -0
  132. package/src/lib/components/{ui/Text → Text}/helpers/getRootHyphensClassName.js +0 -0
  133. package/src/lib/components/{ui/Text → Text}/helpers/getRootWordWrappingClassName.js +0 -0
  134. package/src/lib/components/{ui/Text → Text}/index.js +0 -0
  135. package/src/lib/components/{ui/TextArea → TextArea}/README.mdx +8 -6
  136. package/src/lib/components/{ui/TextArea → TextArea}/TextArea.jsx +78 -78
  137. package/src/lib/components/{ui/TextArea → TextArea}/TextArea.scss +6 -6
  138. package/src/lib/components/{ui/TextArea → TextArea}/index.js +0 -0
  139. package/src/lib/components/{ui/TextField → TextField}/README.mdx +7 -6
  140. package/src/lib/components/{ui/TextField → TextField}/TextField.jsx +20 -22
  141. package/src/lib/components/{ui/TextField → TextField}/TextField.scss +6 -6
  142. package/src/lib/components/{ui/TextField → TextField}/index.js +0 -0
  143. package/src/lib/components/{ui/Toggle → Toggle}/README.mdx +17 -14
  144. package/src/lib/components/Toggle/Toggle.jsx +163 -0
  145. package/src/lib/components/{ui/Toggle → Toggle}/Toggle.scss +5 -5
  146. package/src/lib/components/{ui/Toggle → Toggle}/index.js +0 -0
  147. package/src/lib/components/{layout/Toolbar → Toolbar}/README.mdx +29 -29
  148. package/src/lib/components/{layout/Toolbar → Toolbar}/Toolbar.jsx +1 -1
  149. package/src/lib/components/{layout/Toolbar → Toolbar}/Toolbar.scss +1 -1
  150. package/src/lib/components/{layout/Toolbar → Toolbar}/ToolbarGroup.jsx +1 -1
  151. package/src/lib/components/{layout/Toolbar → Toolbar}/ToolbarItem.jsx +1 -1
  152. package/src/lib/components/{layout/Toolbar → Toolbar}/_theme.scss +0 -0
  153. package/src/lib/components/{layout/Toolbar → Toolbar}/index.js +0 -0
  154. package/src/lib/components/{ui/withForwardedRef.jsx → withForwardedRef.jsx} +0 -0
  155. package/src/lib/helpers/resolveContextOrProp.js +7 -0
  156. package/src/lib/index.js +34 -35
  157. package/src/lib/styles/tools/_accessibility.scss +9 -0
  158. package/src/lib/theme.scss +25 -7
  159. package/src/lib/components/ui/Button/Button.jsx +0 -191
  160. package/src/lib/components/ui/Button/_base.scss +0 -154
  161. package/src/lib/components/ui/Button/helpers/getRootLabelVisibilityClassName.js +0 -11
  162. package/src/lib/components/ui/ButtonGroup/index.js +0 -1
  163. package/src/lib/components/ui/CheckboxField/CheckboxField.jsx +0 -173
  164. package/src/lib/components/ui/FileInputField/FileInputField.jsx +0 -158
  165. package/src/lib/components/ui/Radio/Radio.jsx +0 -179
  166. package/src/lib/components/ui/SelectField/SelectField.jsx +0 -214
  167. package/src/lib/components/ui/Toggle/Toggle.jsx +0 -174
@@ -0,0 +1,33 @@
1
+ export default (labelVisibility, styles) => {
2
+ // Intentionally omitting `xs` which means label is visible on all screen sizes.
3
+
4
+ if (labelVisibility === 'sm') {
5
+ return styles.withLabelVisibleSm;
6
+ }
7
+
8
+ if (labelVisibility === 'md') {
9
+ return styles.withLabelVisibleMd;
10
+ }
11
+
12
+ if (labelVisibility === 'lg') {
13
+ return styles.withLabelVisibleLg;
14
+ }
15
+
16
+ if (labelVisibility === 'xl') {
17
+ return styles.withLabelVisibleXl;
18
+ }
19
+
20
+ if (labelVisibility === 'xxl') {
21
+ return styles.withLabelVisibleXxl;
22
+ }
23
+
24
+ if (labelVisibility === 'xxxl') {
25
+ return styles.withLabelVisibleXxxl;
26
+ }
27
+
28
+ if (labelVisibility === 'none') {
29
+ return styles.withLabelHidden;
30
+ }
31
+
32
+ return null;
33
+ };
@@ -11,9 +11,5 @@ export default (priority, styles) => {
11
11
  return styles.rootPriorityFlat;
12
12
  }
13
13
 
14
- if (priority === 'link') {
15
- return styles.rootPriorityLink;
16
- }
17
-
18
14
  return null;
19
15
  };
@@ -1,7 +1,8 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../../provider';
3
+ import { withProviderContext } from '../../provider';
4
4
  import styles from './ButtonGroup.scss';
5
+ import { ButtonGroupContext } from './ButtonGroupContext';
5
6
 
6
7
  export const ButtonGroup = ({
7
8
  block,
@@ -19,19 +20,16 @@ export const ButtonGroup = ({
19
20
  role="group"
20
21
  {...restProps}
21
22
  >
22
- {React.Children.map(children, (child) => {
23
- if (!React.isValidElement(child)) {
24
- return null;
25
- }
26
-
27
- return React.cloneElement(child, {
23
+ <ButtonGroupContext.Provider
24
+ value={{
28
25
  block,
29
26
  disabled,
30
- grouped: true,
31
27
  priority,
32
28
  size,
33
- });
34
- })}
29
+ }}
30
+ >
31
+ {children}
32
+ </ButtonGroupContext.Provider>
35
33
  </div>
36
34
  );
37
35
 
@@ -50,7 +48,7 @@ ButtonGroup.propTypes = {
50
48
  /**
51
49
  * Buttons to be grouped.
52
50
  */
53
- children: PropTypes.arrayOf(PropTypes.element).isRequired,
51
+ children: PropTypes.node.isRequired,
54
52
  /**
55
53
  * If `true`, all buttons inside the group will be disabled.
56
54
  */
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+
3
+ export const ButtonGroupContext = React.createContext(null);
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: ButtonGroup
3
- menu: 'UI'
4
- route: /components/ui/button-group
3
+ menu: 'Layouts'
4
+ route: /components/button-group
5
5
  ---
6
6
 
7
7
  # ButtonGroup
@@ -12,6 +12,7 @@ import {
12
12
  Playground,
13
13
  Props,
14
14
  } from 'docz'
15
+ import Icon from '../../../docs/_components/Icon'
15
16
  import Button from '../Button'
16
17
  import { ButtonGroup } from './ButtonGroup'
17
18
 
@@ -43,11 +44,11 @@ See [API](#api) for all available options.
43
44
  - Use **short labels or icons** so the buttons can fit small screens.
44
45
 
45
46
  - For toggling between on/off states, use rather the
46
- [Toggle](/components/ui/toggle) component.
47
+ [Toggle](/components/toggle) component.
47
48
 
48
49
  - For switching between options in a form that needs to be submitted, use rather
49
- the [SelectField](/components/ui/select-field) or
50
- [Radio](/components/ui/radio) components.
50
+ the [SelectField](/components/select-field) or
51
+ [Radio](/components/radio) components.
51
52
 
52
53
  - Be careful with using `startCorner` and `endCorner` options for grouped
53
54
  buttons. Overflowing elements may cause undesired interaction problems.
@@ -64,7 +65,7 @@ different types or sizes.
64
65
  ## Priorities
65
66
 
66
67
  There are three **visual priorities** of buttons which exactly copy the
67
- priorities of the [Button](/components/ui/button) component:
68
+ priorities of the [Button](/components/button) component:
68
69
 
69
70
  1. filled
70
71
  2. outline
@@ -166,6 +167,29 @@ Disables all buttons inside the group.
166
167
  </ButtonGroup>
167
168
  </Playground>
168
169
 
170
+ ### Feedback State
171
+
172
+ When user's action triggers an asynchronous process on background, feedback
173
+ state of individual buttons can be indicated by showing an icon.
174
+
175
+ <Playground>
176
+ <ButtonGroup>
177
+ <Button label="Week" color="success" feedbackIcon={<Icon icon="success" />} />
178
+ <Button label="Month" />
179
+ <Button label="Year" />
180
+ </ButtonGroup>
181
+ <ButtonGroup priority="outline">
182
+ <Button label="Week" color="success" feedbackIcon={<Icon icon="success" />} />
183
+ <Button label="Month" />
184
+ <Button label="Year" />
185
+ </ButtonGroup>
186
+ <ButtonGroup priority="flat">
187
+ <Button label="Week" color="success" feedbackIcon={<Icon icon="success" />} />
188
+ <Button label="Month" />
189
+ <Button label="Year" />
190
+ </ButtonGroup>
191
+ </Playground>
192
+
169
193
  ### Active State
170
194
 
171
195
  To highlight the selected option, the active state can be achieved by setting
@@ -0,0 +1,2 @@
1
+ export { default as ButtonGroup } from './ButtonGroup';
2
+ export { ButtonGroupContext } from './ButtonGroupContext';
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../../provider';
3
+ import { withProviderContext } from '../../provider';
4
4
  import styles from './CTA.scss';
5
5
 
6
6
  export const CTA = (props) => {
@@ -47,7 +47,10 @@ CTA.propTypes = {
47
47
  */
48
48
  align: PropTypes.oneOf(['top', 'middle', 'bottom', 'baseline']),
49
49
  /**
50
- * Slot for individual CTA elements: CTAStart, CTACenter, and CTAEnd.
50
+ * Nested elements. Supported types are:
51
+ * * `CTAStart`
52
+ * * `CTACenter`
53
+ * * `CTAEnd`
51
54
  */
52
55
  children: PropTypes.node.isRequired,
53
56
  };
@@ -1,5 +1,5 @@
1
- @use '../../../styles/tools/breakpoint';
2
- @use '../../../styles/tools/spacing';
1
+ @use '../../styles/tools/breakpoint';
2
+ @use '../../styles/tools/spacing';
3
3
 
4
4
  $_breakpoint: lg;
5
5
  $_spacing: spacing.of(1);
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../../provider';
3
+ import { withProviderContext } from '../../provider';
4
4
  import styles from './CTA.scss';
5
5
 
6
6
  export const CTACenter = (props) => {
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../../provider';
3
+ import { withProviderContext } from '../../provider';
4
4
  import styles from './CTA.scss';
5
5
 
6
6
  export const CTAEnd = (props) => {
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../../provider';
3
+ import { withProviderContext } from '../../provider';
4
4
  import styles from './CTA.scss';
5
5
 
6
6
  export const CTAStart = (props) => {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: CTA
3
3
  menu: 'Layouts'
4
- route: /components/layout/cta
4
+ route: /components/cta
5
5
  ---
6
6
 
7
7
  # CTA
@@ -13,7 +13,7 @@ import {
13
13
  Playground,
14
14
  Props,
15
15
  } from 'docz'
16
- import { Placeholder } from '../../../../docs/_components/Placeholder/Placeholder'
16
+ import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
17
17
  import { CTA } from './CTA'
18
18
  import { CTACenter } from './CTACenter'
19
19
  import { CTAEnd } from './CTAEnd'
@@ -61,9 +61,9 @@ See [API](#api) for all available options.
61
61
 
62
62
  - Place rather **a few smaller elements** into the layout, so they fit the
63
63
  screen even at the smallest size. For complex layouts and a lot of actions,
64
- consider using the [Toolbar](/components/layout/toolbar) layout.
64
+ consider using the [Toolbar](/components/toolbar) layout.
65
65
 
66
- 👉 On screen sizes smaller than 66 em (the `lg`
66
+ 📐 On screen sizes smaller than 66 em (the `lg`
67
67
  [breakpoint](/foundation/breakpoints)), the start element expands over the full
68
68
  width of its parent. Please resize your browser rather than the playground to
69
69
  see this work.
File without changes
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import getRootColorClassName from '../../../helpers/getRootColorClassName';
4
- import { withProviderContext } from '../../../provider';
3
+ import getRootColorClassName from '../../helpers/getRootColorClassName';
4
+ import { withProviderContext } from '../../provider';
5
5
  import styles from './Card.scss';
6
6
 
7
7
  export const Card = ({
@@ -36,8 +36,10 @@ Card.defaultProps = {
36
36
 
37
37
  Card.propTypes = {
38
38
  /**
39
- * Slot for individual card elements that build up the inner layout: CardBody, CardFooter, or
40
- * ScrollView.
39
+ * Slot for individual card elements that build up the inner layout:
40
+ * * `CardBody`
41
+ * * `CardFooter`
42
+ * * `ScrollView`
41
43
  */
42
44
  children: PropTypes.node.isRequired,
43
45
  /**
@@ -1,6 +1,6 @@
1
1
  // 1. Retain equal card widths in flex and grid layouts independently on their content.
2
2
 
3
- @use '../../../styles/theme/colors';
3
+ @use '../../styles/theme/colors';
4
4
  @use 'theme';
5
5
  @use 'tools';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../../provider';
3
+ import { withProviderContext } from '../../provider';
4
4
  import styles from './Card.scss';
5
5
 
6
6
  export const CardBody = (props) => {
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../../provider';
3
+ import { withProviderContext } from '../../provider';
4
4
  import styles from './Card.scss';
5
5
 
6
6
  export const CardFooter = (props) => {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: Card
3
- menu: 'UI'
4
- route: /components/ui/card
3
+ menu: 'Miscellaneous'
4
+ route: /components/card
5
5
  ---
6
6
 
7
7
  # Card
@@ -53,7 +53,7 @@ See [API](#api) for all available options.
53
53
  grid. It will help you keep the UI clean and easy to scan.
54
54
 
55
55
  - **Card, or Paper?** Card is a versatile surface for displaying content.
56
- However, there is also the [Paper](/components/ui/paper) component. While Card
56
+ However, there is also the [Paper](/components/paper) component. While Card
57
57
  is designed for displaying items (and also supports more visual options),
58
58
  Paper is usually used to hold larger content areas like lists, grids, or
59
59
  forms.
@@ -119,7 +119,7 @@ card should be also smaller to keep the card contained and easy to scan.
119
119
 
120
120
  ## Scrollable Card
121
121
 
122
- Combine Card with [ScrollView](/components/ui/scroll-view) to enable scrolling
122
+ Combine Card with [ScrollView](/components/scroll-view) to enable scrolling
123
123
  for card content.
124
124
 
125
125
  <Playground>
File without changes
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { withProviderContext } from '../../../provider';
3
+ import { withProviderContext } from '../../provider';
4
4
  import styles from './Center.scss';
5
5
 
6
6
  export const Center = ({ children }) => (
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: Center
3
3
  menu: 'Layouts'
4
- route: /components/layout/center
4
+ route: /components/center
5
5
  ---
6
6
 
7
7
  # Center
@@ -12,7 +12,7 @@ import {
12
12
  Playground,
13
13
  Props,
14
14
  } from 'docz'
15
- import { Placeholder } from '../../../../docs/_components/Placeholder/Placeholder'
15
+ import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
16
16
  import { Center } from './Center'
17
17
 
18
18
  ## Basic Usage
@@ -0,0 +1,164 @@
1
+ import PropTypes from 'prop-types';
2
+ import React, { useContext } from 'react';
3
+ import getRootValidationStateClassName from '../../helpers/getRootValidationStateClassName';
4
+ import { withProviderContext } from '../../provider';
5
+ import transferProps from '../../utils/transferProps';
6
+ import { FormLayoutContext } from '../FormLayout';
7
+ import withForwardedRef from '../withForwardedRef';
8
+ import styles from './CheckboxField.scss';
9
+
10
+ export const CheckboxField = ({
11
+ checked,
12
+ disabled,
13
+ forwardedRef,
14
+ helpText,
15
+ id,
16
+ isLabelVisible,
17
+ label,
18
+ labelPosition,
19
+ required,
20
+ validationState,
21
+ validationText,
22
+ value,
23
+ ...restProps
24
+ }) => {
25
+ const context = useContext(FormLayoutContext);
26
+
27
+ return (
28
+ <label
29
+ className={[
30
+ styles.root,
31
+ context ? styles.isRootInFormLayout : '',
32
+ context && context.layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
33
+ labelPosition === 'before' ? styles.hasRootLabelBefore : '',
34
+ disabled ? styles.isRootDisabled : '',
35
+ required ? styles.isRootRequired : '',
36
+ getRootValidationStateClassName(validationState, styles),
37
+ ].join(' ')}
38
+ htmlFor={id}
39
+ id={id && `${id}__label`}
40
+ >
41
+ <div className={styles.field}>
42
+ <input
43
+ {...transferProps(restProps)}
44
+ checked={checked}
45
+ className={styles.input}
46
+ disabled={disabled}
47
+ id={id}
48
+ ref={forwardedRef}
49
+ required={required}
50
+ type="checkbox"
51
+ value={value}
52
+ />
53
+ <div
54
+ className={[
55
+ styles.label,
56
+ isLabelVisible ? '' : styles.isLabelHidden,
57
+ ].join(' ')}
58
+ id={id && `${id}__labelText`}
59
+ >
60
+ {label}
61
+ </div>
62
+ </div>
63
+ {helpText && (
64
+ <div
65
+ className={styles.helpText}
66
+ id={id && `${id}__helpText`}
67
+ >
68
+ {helpText}
69
+ </div>
70
+ )}
71
+ {validationText && (
72
+ <div
73
+ className={styles.validationText}
74
+ id={id && `${id}__validationText`}
75
+ >
76
+ {validationText}
77
+ </div>
78
+ )}
79
+ </label>
80
+ );
81
+ };
82
+
83
+ CheckboxField.defaultProps = {
84
+ checked: undefined,
85
+ disabled: false,
86
+ forwardedRef: undefined,
87
+ helpText: null,
88
+ id: undefined,
89
+ isLabelVisible: true,
90
+ labelPosition: 'after',
91
+ required: false,
92
+ validationState: null,
93
+ validationText: null,
94
+ value: undefined,
95
+ };
96
+
97
+ CheckboxField.propTypes = {
98
+ /**
99
+ * If `true`, the input will be checked.
100
+ */
101
+ checked: PropTypes.bool,
102
+ /**
103
+ * If `true`, the input will be disabled.
104
+ */
105
+ disabled: PropTypes.bool,
106
+ /**
107
+ * Reference forwarded to the `input` element.
108
+ */
109
+ forwardedRef: PropTypes.oneOfType([
110
+ PropTypes.func,
111
+ // eslint-disable-next-line react/forbid-prop-types
112
+ PropTypes.shape({ current: PropTypes.any }),
113
+ ]),
114
+ /**
115
+ * Optional help text.
116
+ */
117
+ helpText: PropTypes.node,
118
+ /**
119
+ * ID of the `<input>` HTML element.
120
+ *
121
+ * Also serves as base for ids of nested elements:
122
+ * * `<ID>__label`
123
+ * * `<ID>__labelText`
124
+ * * `<ID>__helpText`
125
+ * * `<ID>__validationText`
126
+ */
127
+ id: PropTypes.string,
128
+ /**
129
+ * If `false`, the label will be visually hidden (but remains accessible by assistive
130
+ * technologies).
131
+ */
132
+ isLabelVisible: PropTypes.bool,
133
+ /**
134
+ * Checkbox field label.
135
+ */
136
+ label: PropTypes.string.isRequired,
137
+ /**
138
+ * Placement of the label relative to the input.
139
+ */
140
+ labelPosition: PropTypes.oneOf(['before', 'after']),
141
+ /**
142
+ * If `true`, the input will be required.
143
+ */
144
+ required: PropTypes.bool,
145
+ /**
146
+ * Alter the field to provide feedback based on validation result.
147
+ */
148
+ validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
149
+ /**
150
+ * Validation message to be displayed.
151
+ */
152
+ validationText: PropTypes.node,
153
+ /**
154
+ * Value of the input.
155
+ */
156
+ value: PropTypes.oneOfType([
157
+ PropTypes.string,
158
+ PropTypes.number,
159
+ ]),
160
+ };
161
+
162
+ export const CheckboxFieldWithContext = withForwardedRef(withProviderContext(CheckboxField, 'CheckboxField'));
163
+
164
+ export default CheckboxFieldWithContext;
@@ -1,8 +1,8 @@
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 {