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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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,10 +1,11 @@
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 { resolveContextOrProp } from '../../helpers/resolveContextOrProp';
6
- import { withProviderContext } from '../../provider';
7
- import transferProps from '../../utils/transferProps';
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 { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
8
+ import { transferProps } from '../_helpers/transferProps';
8
9
  import { FormLayoutContext } from '../FormLayout';
9
10
  import withForwardedRef from '../withForwardedRef';
10
11
  import styles from './TextArea.scss';
@@ -33,27 +34,27 @@ export const TextArea = ({
33
34
 
34
35
  return (
35
36
  <label
36
- className={[
37
+ className={classNames(
37
38
  styles.root,
38
- fullWidth ? styles.isRootFullWidth : '',
39
- context ? styles.isRootInFormLayout : '',
39
+ fullWidth && styles.isRootFullWidth,
40
+ context && styles.isRootInFormLayout,
40
41
  resolveContextOrProp(context && context.layout, layout) === 'horizontal'
41
42
  ? styles.rootLayoutHorizontal
42
43
  : styles.rootLayoutVertical,
43
- disabled ? styles.isRootDisabled : '',
44
- required ? styles.isRootRequired : '',
44
+ disabled && styles.isRootDisabled,
45
+ required && styles.isRootRequired,
45
46
  getRootSizeClassName(size, styles),
46
47
  getRootValidationStateClassName(validationState, styles),
47
48
  variant === 'filled' ? styles.rootVariantFilled : styles.rootVariantOutline,
48
- ].join(' ')}
49
+ )}
49
50
  htmlFor={id}
50
51
  id={id && `${id}__label`}
51
52
  >
52
53
  <div
53
- className={[
54
+ className={classNames(
54
55
  styles.label,
55
- isLabelVisible ? '' : styles.isLabelHidden,
56
- ].join(' ')}
56
+ !isLabelVisible && styles.isLabelHidden,
57
+ )}
57
58
  id={id && `${id}__labelText`}
58
59
  >
59
60
  {label}
@@ -191,13 +192,16 @@ TextArea.propTypes = {
191
192
  /**
192
193
  * Value of the input.
193
194
  */
194
- value: PropTypes.string,
195
+ value: PropTypes.oneOfType([
196
+ PropTypes.string,
197
+ PropTypes.number,
198
+ ]),
195
199
  /**
196
200
  * Design variant of the field, further customizable with CSS custom properties.
197
201
  */
198
202
  variant: PropTypes.oneOf(['filled', 'outline']),
199
203
  };
200
204
 
201
- export const TextAreaWithContext = withForwardedRef(withProviderContext(TextArea, 'TextArea'));
205
+ export const TextAreaWithGlobalProps = withForwardedRef(withGlobalProps(TextArea, 'TextArea'));
202
206
 
203
- export default TextAreaWithContext;
207
+ export default TextAreaWithGlobalProps;
@@ -1,95 +1,95 @@
1
- @use '../../styles/tools/form-fields/box-field-elements';
2
- @use '../../styles/tools/form-fields/box-field-layout';
3
- @use '../../styles/tools/form-fields/box-field-sizes';
4
- @use '../../styles/tools/form-fields/foundation';
5
- @use '../../styles/tools/form-fields/variants';
6
- @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/box-field-sizes";
4
+ @use "../../styles/tools/form-fields/foundation";
5
+ @use "../../styles/tools/form-fields/variants";
6
+ @use "../../styles/tools/accessibility";
7
7
 
8
8
  // Foundation
9
9
  .root {
10
- @include foundation.root();
10
+ @include foundation.root();
11
11
  }
12
12
 
13
13
  .label {
14
- @include foundation.label();
14
+ @include foundation.label();
15
15
  }
16
16
 
17
17
  .inputContainer {
18
- @include box-field-elements.input-container();
18
+ @include box-field-elements.input-container();
19
19
  }
20
20
 
21
21
  .input {
22
- @include box-field-elements.input();
23
- @include box-field-elements.input-textarea();
22
+ @include box-field-elements.input();
23
+ @include box-field-elements.input-textarea();
24
24
  }
25
25
 
26
26
  .bottomLine {
27
- @include box-field-elements.bottom-line();
27
+ @include box-field-elements.bottom-line();
28
28
  }
29
29
 
30
30
  .helpText,
31
31
  .validationText {
32
- @include foundation.help-text();
32
+ @include foundation.help-text();
33
33
  }
34
34
 
35
35
  .isRootRequired .label {
36
- @include foundation.label-required();
36
+ @include foundation.label-required();
37
37
  }
38
38
 
39
39
  // Visual variants
40
40
  .rootVariantFilled {
41
- @include variants.visual(box, $variant: filled);
41
+ @include variants.visual(box, $variant: filled);
42
42
  }
43
43
 
44
44
  .rootVariantOutline {
45
- @include variants.visual(box, $variant: outline);
45
+ @include variants.visual(box, $variant: outline);
46
46
  }
47
47
 
48
48
  // States
49
49
  .isRootStateInvalid {
50
- @include variants.validation(invalid);
50
+ @include variants.validation(invalid);
51
51
  }
52
52
 
53
53
  .isRootStateValid {
54
- @include variants.validation(valid);
54
+ @include variants.validation(valid);
55
55
  }
56
56
 
57
57
  .isRootStateWarning {
58
- @include variants.validation(warning);
58
+ @include variants.validation(warning);
59
59
  }
60
60
 
61
61
  // Invisible label
62
62
  .isLabelHidden {
63
- @include accessibility.hide-text();
63
+ @include accessibility.hide-text();
64
64
  }
65
65
 
66
66
  // Layouts
67
67
  .rootLayoutVertical,
68
68
  .rootLayoutHorizontal {
69
- @include box-field-layout.vertical();
69
+ @include box-field-layout.vertical();
70
70
  }
71
71
 
72
72
  .rootLayoutHorizontal {
73
- @include box-field-layout.horizontal();
73
+ @include box-field-layout.horizontal();
74
74
  }
75
75
 
76
76
  .isRootFullWidth {
77
- @include box-field-layout.full-width();
77
+ @include box-field-layout.full-width();
78
78
  }
79
79
 
80
80
  .isRootInFormLayout {
81
- @include box-field-layout.in-form-layout();
81
+ @include box-field-layout.in-form-layout();
82
82
  }
83
83
 
84
84
  // Sizes
85
85
  .rootSizeSmall {
86
- @include box-field-sizes.size(small, $is-multiline: true);
86
+ @include box-field-sizes.size(small, $is-multiline: true);
87
87
  }
88
88
 
89
89
  .rootSizeMedium {
90
- @include box-field-sizes.size(medium, $is-multiline: true);
90
+ @include box-field-sizes.size(medium, $is-multiline: true);
91
91
  }
92
92
 
93
93
  .rootSizeLarge {
94
- @include box-field-sizes.size(large, $is-multiline: true);
94
+ @include box-field-sizes.size(large, $is-multiline: true);
95
95
  }
@@ -493,7 +493,7 @@ It's possible to disable the whole input.
493
493
 
494
494
  In addition to the options below, you can specify [React synthetic events] or
495
495
  any custom HTML attributes that do not interfere with the API, and they will be
496
- passed to the `input` HTML element. This enables making the component
496
+ passed to the `<input>` HTML element. This enables making the component
497
497
  interactive and helps improve its [accessibility](#forwarding-html-attributes).
498
498
 
499
499
  <Props table of={TextField} />
@@ -1,10 +1,11 @@
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 { resolveContextOrProp } from '../../helpers/resolveContextOrProp';
6
- import { withProviderContext } from '../../provider';
7
- import transferProps from '../../utils/transferProps';
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 { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
8
+ import { transferProps } from '../_helpers/transferProps';
8
9
  import { FormLayoutContext } from '../FormLayout';
9
10
  import withForwardedRef from '../withForwardedRef';
10
11
  import styles from './TextField.scss';
@@ -36,30 +37,30 @@ export const TextField = ({
36
37
 
37
38
  return (
38
39
  <label
39
- className={[
40
+ className={classNames(
40
41
  styles.root,
41
- fullWidth ? styles.isRootFullWidth : '',
42
- hasSmallInput ? styles.hasRootSmallInput : '',
43
- inputSize ? styles.hasRootCustomInputSize : '',
44
- context ? styles.isRootInFormLayout : '',
42
+ fullWidth && styles.isRootFullWidth,
43
+ hasSmallInput && styles.hasRootSmallInput,
44
+ inputSize && styles.hasRootCustomInputSize,
45
+ context && styles.isRootInFormLayout,
45
46
  resolveContextOrProp(context && context.layout, layout) === 'horizontal'
46
47
  ? styles.rootLayoutHorizontal
47
48
  : styles.rootLayoutVertical,
48
- disabled ? styles.isRootDisabled : '',
49
- required ? styles.isRootRequired : '',
49
+ disabled && styles.isRootDisabled,
50
+ required && styles.isRootRequired,
50
51
  getRootSizeClassName(size, styles),
51
52
  getRootValidationStateClassName(validationState, styles),
52
53
  variant === 'filled' ? styles.rootVariantFilled : styles.rootVariantOutline,
53
- ].join(' ')}
54
+ )}
54
55
  htmlFor={id}
55
56
  id={id && `${id}__label`}
56
57
  {...(inputSize ? { style: { '--rui-custom-input-size': inputSize } } : {})}
57
58
  >
58
59
  <div
59
- className={[
60
+ className={classNames(
60
61
  styles.label,
61
- isLabelVisible ? '' : styles.isLabelHidden,
62
- ].join(' ')}
62
+ !isLabelVisible && styles.isLabelHidden,
63
+ )}
63
64
  id={id && `${id}__labelText`}
64
65
  >
65
66
  {label}
@@ -208,6 +209,6 @@ TextField.propTypes = {
208
209
  variant: PropTypes.oneOf(['filled', 'outline']),
209
210
  };
210
211
 
211
- export const TextFieldWithContext = withForwardedRef(withProviderContext(TextField, 'TextField'));
212
+ export const TextFieldWithGlobalProps = withForwardedRef(withGlobalProps(TextField, 'TextField'));
212
213
 
213
- export default TextFieldWithContext;
214
+ export default TextFieldWithGlobalProps;
@@ -1,102 +1,102 @@
1
- @use '../../styles/tools/form-fields/box-field-elements';
2
- @use '../../styles/tools/form-fields/box-field-layout';
3
- @use '../../styles/tools/form-fields/box-field-sizes';
4
- @use '../../styles/tools/form-fields/foundation';
5
- @use '../../styles/tools/form-fields/variants';
6
- @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/box-field-sizes";
4
+ @use "../../styles/tools/form-fields/foundation";
5
+ @use "../../styles/tools/form-fields/variants";
6
+ @use "../../styles/tools/accessibility";
7
7
 
8
8
  // Foundation
9
9
  .root {
10
- @include foundation.root();
10
+ @include foundation.root();
11
11
  }
12
12
 
13
13
  .label {
14
- @include foundation.label();
14
+ @include foundation.label();
15
15
  }
16
16
 
17
17
  .inputContainer {
18
- @include box-field-elements.input-container();
18
+ @include box-field-elements.input-container();
19
19
  }
20
20
 
21
21
  .input {
22
- @include box-field-elements.input();
22
+ @include box-field-elements.input();
23
23
  }
24
24
 
25
25
  .bottomLine {
26
- @include box-field-elements.bottom-line();
26
+ @include box-field-elements.bottom-line();
27
27
  }
28
28
 
29
29
  .helpText,
30
30
  .validationText {
31
- @include foundation.help-text();
31
+ @include foundation.help-text();
32
32
  }
33
33
 
34
34
  .hasRootCustomInputSize .input {
35
- @include box-field-elements.input-size();
35
+ @include box-field-elements.input-size();
36
36
  }
37
37
 
38
38
  .isRootRequired .label {
39
- @include foundation.label-required();
39
+ @include foundation.label-required();
40
40
  }
41
41
 
42
42
  // Variants
43
43
  .rootVariantFilled {
44
- @include variants.visual(box, $variant: filled);
44
+ @include variants.visual(box, $variant: filled);
45
45
  }
46
46
 
47
47
  .rootVariantOutline {
48
- @include variants.visual(box, $variant: outline);
48
+ @include variants.visual(box, $variant: outline);
49
49
  }
50
50
 
51
51
  // States
52
52
  .isRootStateInvalid {
53
- @include variants.validation(invalid);
53
+ @include variants.validation(invalid);
54
54
  }
55
55
 
56
56
  .isRootStateValid {
57
- @include variants.validation(valid);
57
+ @include variants.validation(valid);
58
58
  }
59
59
 
60
60
  .isRootStateWarning {
61
- @include variants.validation(warning);
61
+ @include variants.validation(warning);
62
62
  }
63
63
 
64
64
  // Invisible label
65
65
  .isLabelHidden {
66
- @include accessibility.hide-text();
66
+ @include accessibility.hide-text();
67
67
  }
68
68
 
69
69
  // Layouts
70
70
  .rootLayoutVertical,
71
71
  .rootLayoutHorizontal {
72
- @include box-field-layout.vertical();
72
+ @include box-field-layout.vertical();
73
73
  }
74
74
 
75
75
  .rootLayoutHorizontal {
76
- @include box-field-layout.horizontal();
76
+ @include box-field-layout.horizontal();
77
77
  }
78
78
 
79
79
  .isRootFullWidth {
80
- @include box-field-layout.full-width();
80
+ @include box-field-layout.full-width();
81
81
  }
82
82
 
83
83
  .isRootInFormLayout {
84
- @include box-field-layout.in-form-layout();
84
+ @include box-field-layout.in-form-layout();
85
85
  }
86
86
 
87
87
  .hasRootSmallInput.rootLayoutHorizontal {
88
- @include box-field-layout.horizontal-with-small-input();
88
+ @include box-field-layout.horizontal-with-small-input();
89
89
  }
90
90
 
91
91
  // Sizes
92
92
  .rootSizeSmall {
93
- @include box-field-sizes.size(small);
93
+ @include box-field-sizes.size(small);
94
94
  }
95
95
 
96
96
  .rootSizeMedium {
97
- @include box-field-sizes.size(medium);
97
+ @include box-field-sizes.size(medium);
98
98
  }
99
99
 
100
100
  .rootSizeLarge {
101
- @include box-field-sizes.size(large);
101
+ @include box-field-sizes.size(large);
102
102
  }
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: TextLink
3
+ menu: 'Actions'
4
+ route: /components/text-link
5
+ ---
6
+
7
+ # TextLink
8
+
9
+ import {
10
+ Playground,
11
+ Props,
12
+ } from 'docz'
13
+ import { TextLink } from './TextLink'
14
+
15
+ TextLink allows users to follow navigation.
16
+
17
+ ## Basic Usage
18
+
19
+ To implement the TextLink component, you need to import it first:
20
+
21
+ ```js
22
+ import { TextLink } from '@react-ui-org/react-ui';
23
+ ```
24
+
25
+ And use it:
26
+
27
+ <Playground>
28
+ <TextLink
29
+ href="/contribute/guidelines"
30
+ label="How can I contribute to React UI?"
31
+ />
32
+ </Playground>
33
+
34
+ See [API](#api) for all available options.
35
+
36
+ ## General Guidelines
37
+
38
+ **Avoid using links for actions**, use a [Button](/components/button)
39
+ instead. This is because users expect navigation to happen when clicking on
40
+ something what looks like a link.
41
+
42
+ ## Custom Routing
43
+
44
+ It's common to use custom function for routing within SPAs. Use the
45
+ `onClick` option to provide such function.
46
+
47
+ <Playground>
48
+ <TextLink
49
+ href="/contribute/guidelines"
50
+ label="This link is controlled by custom function"
51
+ onClick={(event) => {
52
+ event.preventDefault();
53
+ alert('You will be redirected.')
54
+ window.location = event.currentTarget.getAttribute('href');
55
+ }}
56
+ />
57
+ </Playground>
58
+
59
+ ## API
60
+
61
+ In addition to the options below, you can specify [React synthetic events] or
62
+ any custom HTML attributes that do not interfere with the API, and they will be
63
+ passed to the `<a>` HTML element. This enables making the component interactive
64
+ and helps improve its accessibility.
65
+
66
+ <Props table of={TextLink} />
67
+
68
+ ## Theming
69
+
70
+ | Custom Property | Description |
71
+ |------------------------------------------|-----------------------------------|
72
+ | `--rui-TextLink__color` | Text color |
73
+ | `--rui-TextLink__text-decoration` | Text decoration, e.g. underline |
74
+ | `--rui-TextLink--hover__color` | Text color on hover |
75
+ | `--rui-TextLink--hover__text-decoration` | Text decoration on hover |
76
+
77
+ [React synthetic events]: https://reactjs.org/docs/events.html
@@ -0,0 +1,44 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import { withGlobalProps } from '../../provider';
4
+ import { transferProps } from '../_helpers/transferProps';
5
+ import styles from './TextLink.scss';
6
+
7
+ export const TextLink = ({
8
+ href,
9
+ id,
10
+ label,
11
+ ...restProps
12
+ }) => (
13
+ <a
14
+ {...transferProps(restProps)}
15
+ href={href}
16
+ className={styles.root}
17
+ id={id}
18
+ >
19
+ {label}
20
+ </a>
21
+ );
22
+
23
+ TextLink.defaultProps = {
24
+ id: undefined,
25
+ };
26
+
27
+ TextLink.propTypes = {
28
+ /**
29
+ * Link's `href` attribute.
30
+ */
31
+ href: PropTypes.string.isRequired,
32
+ /**
33
+ * ID of the root HTML element.
34
+ */
35
+ id: PropTypes.string,
36
+ /**
37
+ * Link label.
38
+ */
39
+ label: PropTypes.string.isRequired,
40
+ };
41
+
42
+ export const LinkWithGlobalProps = withGlobalProps(TextLink, 'TextLink');
43
+
44
+ export default LinkWithGlobalProps;
@@ -0,0 +1,11 @@
1
+ @use "theme";
2
+
3
+ .root {
4
+ text-decoration: theme.$text-decoration;
5
+ color: theme.$color;
6
+
7
+ &:hover {
8
+ text-decoration: theme.$hover-text-decoration;
9
+ color: theme.$hover-color;
10
+ }
11
+ }
@@ -0,0 +1,4 @@
1
+ $color: var(--rui-TextLink__color);
2
+ $text-decoration: var(--rui-TextLink__text-decoration);
3
+ $hover-color: var(--rui-TextLink--hover__color);
4
+ $hover-text-decoration: var(--rui-TextLink--hover__text-decoration);
@@ -0,0 +1 @@
1
+ export { default } from './TextLink';
@@ -181,7 +181,7 @@ Disabled state makes the input unavailable.
181
181
 
182
182
  In addition to the options below, you can specify [React synthetic events] or
183
183
  any custom HTML attributes that do not interfere with the API, and they will be
184
- passed to the `input` HTML element. This enables making the component
184
+ passed to the `<input>` HTML element. This enables making the component
185
185
  interactive and helps improve its accessibility.
186
186
 
187
187
  <Props table of={Toggle} />
@@ -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
- import { withProviderContext } from '../../provider';
5
- import transferProps from '../../utils/transferProps';
3
+ import { withGlobalProps } from '../../provider';
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 './Toggle.scss';
@@ -26,19 +27,28 @@ export const Toggle = ({
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}
@@ -51,15 +61,6 @@ export const Toggle = ({
51
61
  type="checkbox"
52
62
  value={value}
53
63
  />
54
- <div
55
- className={[
56
- styles.label,
57
- isLabelVisible ? '' : styles.isLabelHidden,
58
- ].join(' ')}
59
- id={id && `${id}__labelText`}
60
- >
61
- {label}
62
- </div>
63
64
  </div>
64
65
  {helpText && (
65
66
  <div
@@ -158,6 +159,6 @@ Toggle.propTypes = {
158
159
  ]),
159
160
  };
160
161
 
161
- export const ToggleWithContext = withForwardedRef(withProviderContext(Toggle, 'Toggle'));
162
+ export const ToggleWithGlobalProps = withForwardedRef(withGlobalProps(Toggle, 'Toggle'));
162
163
 
163
- export default ToggleWithContext;
164
+ export default ToggleWithGlobalProps;