@react-ui-org/react-ui 0.42.0 → 0.44.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 (167) hide show
  1. package/CONTRIBUTING.md +44 -25
  2. package/README.md +1 -1
  3. package/dist/lib.development.js +1598 -652
  4. package/dist/lib.js +1 -9
  5. package/package.json +49 -48
  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 +160 -75
  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 +26 -2
  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 +3 -3
  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 +2 -2
  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 +15 -12
  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 +30 -40
  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 +2 -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 +2 -2
  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 +40 -40
  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 +14 -2
  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 +17 -14
  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 +10 -10
  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 +44 -41
  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 +7 -7
  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 +3 -3
  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 -23
  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 +15 -12
  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 +26 -26
  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
@@ -1,179 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import getRootValidationStateClassName from '../../../helpers/getRootValidationStateClassName';
4
- import { withProviderContext } from '../../../provider';
5
- import transferProps from '../../../utils/transferProps';
6
- import styles from './Radio.scss';
7
-
8
- export const Radio = ({
9
- changeHandler,
10
- disabled,
11
- helpText,
12
- id,
13
- inFormLayout,
14
- isLabelVisible,
15
- label,
16
- layout,
17
- options,
18
- required,
19
- validationState,
20
- validationText,
21
- value,
22
- ...restProps
23
- }) => (
24
- <div
25
- className={[
26
- styles.root,
27
- inFormLayout ? styles.isRootInFormLayout : '',
28
- layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
29
- disabled ? styles.isRootDisabled : '',
30
- required ? styles.isRootRequired : '',
31
- getRootValidationStateClassName(validationState, styles),
32
- ].join(' ')}
33
- >
34
- <div
35
- className={[
36
- styles.label,
37
- isLabelVisible ? '' : styles.isLabelHidden,
38
- ].join(' ')}
39
- id={id && `${id}__labelText`}
40
- >
41
- {label}
42
- </div>
43
- <div className={styles.field}>
44
- <ul className={styles.list}>
45
- {
46
- options.map((option) => (
47
- <li key={option.value}>
48
- <label
49
- className={styles.option}
50
- htmlFor={id && `${id}__item__${option.value}`}
51
- id={id && `${id}__item__${option.value}__label`}
52
- >
53
- <input
54
- {...transferProps(restProps)}
55
- className={styles.input}
56
- checked={(value === option.value) || false}
57
- disabled={disabled || option.disabled}
58
- id={id && `${id}__item__${option.value}`}
59
- name={id}
60
- onChange={changeHandler}
61
- type="radio"
62
- value={option.value}
63
- />
64
- <span
65
- className={styles.optionLabel}
66
- id={id && `${id}__item__${option.value}__labelText`}
67
- >
68
- { option.label }
69
- </span>
70
- </label>
71
- </li>
72
- ))
73
- }
74
- </ul>
75
- {helpText && (
76
- <div
77
- className={styles.helpText}
78
- id={id && `${id}__helpText`}
79
- >
80
- {helpText}
81
- </div>
82
- )}
83
- {validationText && (
84
- <div
85
- className={styles.validationText}
86
- id={id && `${id}__validationText`}
87
- >
88
- {validationText}
89
- </div>
90
- )}
91
- </div>
92
- </div>
93
- );
94
-
95
- Radio.defaultProps = {
96
- changeHandler: null,
97
- disabled: false,
98
- helpText: null,
99
- id: undefined,
100
- inFormLayout: false,
101
- isLabelVisible: true,
102
- layout: 'vertical',
103
- required: false,
104
- validationState: null,
105
- validationText: null,
106
- value: undefined,
107
- };
108
-
109
- Radio.propTypes = {
110
- /**
111
- * Function to call when the input has changed.
112
- */
113
- changeHandler: PropTypes.func,
114
- /**
115
- * If `true`, the input will be disabled.
116
- */
117
- disabled: PropTypes.bool,
118
- /**
119
- * Optional help text.
120
- */
121
- helpText: PropTypes.node,
122
- /**
123
- * Prefix for ID of important inner elements: `<ID>__labelText`, `<ID>__helpText`,
124
- * `<ID>__validationText`, and all options: `<ID>__item__<VALUE>` (individual inputs),
125
- * `<ID>__item__<VALUE>__label`, and `<ID>__item__<VALUE>__labelText`.
126
- */
127
- id: PropTypes.string,
128
- /**
129
- * Treat the field differently when it's inside a FormLayout. Do not set manually!
130
- */
131
- inFormLayout: PropTypes.bool,
132
- /**
133
- * If `false`, the label will be visually hidden (but remains accessible by assistive
134
- * technologies).
135
- */
136
- isLabelVisible: PropTypes.bool,
137
- /**
138
- * Label of the group of options.
139
- */
140
- label: PropTypes.string.isRequired,
141
- /**
142
- * Layout of the field.
143
- */
144
- layout: PropTypes.oneOf(['horizontal', 'vertical']),
145
- /**
146
- * Set of options to be chosen from.
147
- */
148
- options: PropTypes.arrayOf(PropTypes.shape({
149
- disabled: PropTypes.bool,
150
- label: PropTypes.string.isRequired,
151
- value: PropTypes.oneOfType([
152
- PropTypes.string,
153
- PropTypes.number,
154
- ]),
155
- })).isRequired,
156
- /**
157
- * If `true`, the input will be required.
158
- */
159
- required: PropTypes.bool,
160
- /**
161
- * Alter the field to provide feedback based on validation result.
162
- */
163
- validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
164
- /**
165
- * Validation message to be displayed.
166
- */
167
- validationText: PropTypes.node,
168
- /**
169
- * Value of the input.
170
- */
171
- value: PropTypes.oneOfType([
172
- PropTypes.string,
173
- PropTypes.number,
174
- ]),
175
- };
176
-
177
- export const RadioWithContext = withProviderContext(Radio, 'Radio');
178
-
179
- export default RadioWithContext;
@@ -1,214 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import getRootSizeClassName from '../../../helpers/getRootSizeClassName';
4
- import getRootValidationStateClassName from '../../../helpers/getRootValidationStateClassName';
5
- import { withProviderContext } from '../../../provider';
6
- import transferProps from '../../../utils/transferProps';
7
- import withForwardedRef from '../withForwardedRef';
8
- import styles from './SelectField.scss';
9
-
10
- export const SelectField = ({
11
- changeHandler,
12
- disabled,
13
- forwardedRef,
14
- fullWidth,
15
- helpText,
16
- id,
17
- inFormLayout,
18
- isLabelVisible,
19
- label,
20
- layout,
21
- options,
22
- required,
23
- size,
24
- validationState,
25
- validationText,
26
- value,
27
- variant,
28
- ...restProps
29
- }) => (
30
- <label
31
- className={[
32
- styles.root,
33
- fullWidth ? styles.isRootFullWidth : '',
34
- inFormLayout ? styles.isRootInFormLayout : '',
35
- layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
36
- disabled ? styles.isRootDisabled : '',
37
- required ? styles.isRootRequired : '',
38
- getRootSizeClassName(size, styles),
39
- getRootValidationStateClassName(validationState, styles),
40
- variant === 'filled' ? styles.rootVariantFilled : styles.rootVariantOutline,
41
- ].join(' ')}
42
- htmlFor={id}
43
- id={id && `${id}__label`}
44
- >
45
- <div
46
- className={[
47
- styles.label,
48
- isLabelVisible ? '' : styles.isLabelHidden,
49
- ].join(' ')}
50
- id={id && `${id}__labelText`}
51
- >
52
- {label}
53
- </div>
54
- <div className={styles.field}>
55
- <div className={styles.inputContainer}>
56
- <select
57
- {...transferProps(restProps)}
58
- className={styles.input}
59
- disabled={disabled}
60
- id={id}
61
- onChange={changeHandler}
62
- ref={forwardedRef}
63
- required={required}
64
- value={value}
65
- >
66
- {
67
- options.map((option) => (
68
- <option
69
- disabled={option.disabled}
70
- id={id && `${id}__item__${option.value}`}
71
- key={option.value}
72
- value={option.value}
73
- >
74
- {option.label}
75
- </option>
76
- ))
77
- }
78
- </select>
79
- <div className={styles.caret}>
80
- <span className={styles.caretIcon} />
81
- </div>
82
- {variant === 'filled' && (
83
- <div className={styles.bottomLine} />
84
- )}
85
- </div>
86
- {helpText && (
87
- <div
88
- className={styles.helpText}
89
- id={id && `${id}__helpText`}
90
- >
91
- {helpText}
92
- </div>
93
- )}
94
- {validationText && (
95
- <div
96
- className={styles.validationText}
97
- id={id && `${id}__validationText`}
98
- >
99
- {validationText}
100
- </div>
101
- )}
102
- </div>
103
- </label>
104
- );
105
-
106
- SelectField.defaultProps = {
107
- changeHandler: null,
108
- disabled: false,
109
- forwardedRef: undefined,
110
- fullWidth: false,
111
- helpText: null,
112
- id: undefined,
113
- inFormLayout: false,
114
- isLabelVisible: true,
115
- layout: 'vertical',
116
- required: false,
117
- size: 'medium',
118
- validationState: null,
119
- validationText: null,
120
- value: undefined,
121
- variant: 'outline',
122
- };
123
-
124
- SelectField.propTypes = {
125
- /**
126
- * Function to call when the input has changed.
127
- */
128
- changeHandler: PropTypes.func,
129
- /**
130
- * If `true`, the input will be disabled.
131
- */
132
- disabled: PropTypes.bool,
133
- /**
134
- * Reference forwarded to the `select` element.
135
- */
136
- forwardedRef: PropTypes.oneOfType([
137
- PropTypes.func,
138
- // eslint-disable-next-line react/forbid-prop-types
139
- PropTypes.shape({ current: PropTypes.any }),
140
- ]),
141
- /**
142
- * If `true`, the field will span the full width of its parent.
143
- */
144
- fullWidth: PropTypes.bool,
145
- /**
146
- * Optional help text.
147
- */
148
- helpText: PropTypes.node,
149
- /**
150
- * ID of the input HTML element. It also serves as a prefix for important inner elements:
151
- * `<ID>__label`, `<ID>__labelText`, `<ID>__helpText`, `<ID>__validationText`, and all options:
152
- * `<ID>__item__<VALUE>`.
153
- */
154
- id: PropTypes.string,
155
- /**
156
- * Treat the field differently when it's inside a FormLayout. Do not set manually!
157
- */
158
- inFormLayout: PropTypes.bool,
159
- /**
160
- * If `false`, the label will be visually hidden (but remains accessible by assistive
161
- * technologies).
162
- */
163
- isLabelVisible: PropTypes.bool,
164
- /**
165
- * Select field label.
166
- */
167
- label: PropTypes.string.isRequired,
168
- /**
169
- * Layout of the field.
170
- */
171
- layout: PropTypes.oneOf(['horizontal', 'vertical']),
172
- /**
173
- * Set of options to be chosen from.
174
- */
175
- options: PropTypes.arrayOf(PropTypes.shape({
176
- disabled: PropTypes.bool,
177
- label: PropTypes.string.isRequired,
178
- value: PropTypes.oneOfType([
179
- PropTypes.string,
180
- PropTypes.number,
181
- ]),
182
- })).isRequired,
183
- /**
184
- * If `true`, the input will be required.
185
- */
186
- required: PropTypes.bool,
187
- /**
188
- * Size of the field.
189
- */
190
- size: PropTypes.oneOf(['small', 'medium', 'large']),
191
- /**
192
- * Alter the field to provide feedback based on validation result.
193
- */
194
- validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
195
- /**
196
- * Validation message to be displayed.
197
- */
198
- validationText: PropTypes.node,
199
- /**
200
- * Value of the input.
201
- */
202
- value: PropTypes.oneOfType([
203
- PropTypes.string,
204
- PropTypes.number,
205
- ]),
206
- /**
207
- * Design variant of the field, further customizable with CSS custom properties.
208
- */
209
- variant: PropTypes.oneOf(['filled', 'outline']),
210
- };
211
-
212
- export const SelectFieldWithContext = withForwardedRef(withProviderContext(SelectField, 'SelectField'));
213
-
214
- export default SelectFieldWithContext;
@@ -1,174 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import getRootValidationStateClassName from '../../../helpers/getRootValidationStateClassName';
4
- import { withProviderContext } from '../../../provider';
5
- import transferProps from '../../../utils/transferProps';
6
- import withForwardedRef from '../withForwardedRef';
7
- import styles from './Toggle.scss';
8
-
9
- export const Toggle = ({
10
- changeHandler,
11
- checked,
12
- disabled,
13
- forwardedRef,
14
- helpText,
15
- id,
16
- inFormLayout,
17
- isLabelVisible,
18
- label,
19
- labelPosition,
20
- layout,
21
- required,
22
- validationState,
23
- validationText,
24
- value,
25
- ...restProps
26
- }) => (
27
- <label
28
- className={[
29
- styles.root,
30
- inFormLayout ? styles.isRootInFormLayout : '',
31
- labelPosition === 'before' ? styles.hasRootLabelBefore : '',
32
- layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
33
- disabled ? styles.isRootDisabled : '',
34
- required ? styles.isRootRequired : '',
35
- getRootValidationStateClassName(validationState, styles),
36
- ].join(' ')}
37
- htmlFor={id}
38
- id={id && `${id}__label`}
39
- >
40
- <div className={styles.field}>
41
- <input
42
- {...transferProps(restProps)}
43
- checked={checked}
44
- className={styles.input}
45
- disabled={disabled}
46
- id={id}
47
- name={id}
48
- onChange={changeHandler}
49
- ref={forwardedRef}
50
- required={required}
51
- type="checkbox"
52
- value={value}
53
- />
54
- <div
55
- className={[
56
- styles.label,
57
- isLabelVisible ? '' : styles.isLabelHidden,
58
- ].join(' ')}
59
- id={id && `${id}__labelText`}
60
- >
61
- {label}
62
- </div>
63
- </div>
64
- {helpText && (
65
- <div
66
- className={styles.helpText}
67
- id={id && `${id}__helpText`}
68
- >
69
- {helpText}
70
- </div>
71
- )}
72
- {validationText && (
73
- <div
74
- className={styles.validationText}
75
- id={id && `${id}__validationText`}
76
- >
77
- {validationText}
78
- </div>
79
- )}
80
- </label>
81
- );
82
-
83
- Toggle.defaultProps = {
84
- changeHandler: null,
85
- checked: false,
86
- disabled: false,
87
- forwardedRef: undefined,
88
- helpText: null,
89
- id: undefined,
90
- inFormLayout: false,
91
- isLabelVisible: true,
92
- labelPosition: 'after',
93
- layout: 'vertical',
94
- required: false,
95
- validationState: null,
96
- validationText: null,
97
- value: undefined,
98
- };
99
-
100
- Toggle.propTypes = {
101
- /**
102
- * Function to call when the input is toggled.
103
- */
104
- changeHandler: PropTypes.func,
105
- /**
106
- * If `true`, the input will be checked.
107
- */
108
- checked: PropTypes.bool,
109
- /**
110
- * If `true`, the input will be disabled.
111
- */
112
- disabled: PropTypes.bool,
113
- /**
114
- * Reference forwarded to the `input` element.
115
- */
116
- forwardedRef: PropTypes.oneOfType([
117
- PropTypes.func,
118
- // eslint-disable-next-line react/forbid-prop-types
119
- PropTypes.shape({ current: PropTypes.any }),
120
- ]),
121
- /**
122
- * Optional help text.
123
- */
124
- helpText: PropTypes.node,
125
- /**
126
- * ID of the input HTML element. It also serves as a prefix for important inner elements:
127
- * `<ID>__label`, `<ID>__labelText`, `<ID>__helpText`, and `<ID>__validationText`.
128
- */
129
- id: PropTypes.string,
130
- /**
131
- * Treat the field differently when it's inside a FormLayout. Do not set manually!
132
- */
133
- inFormLayout: PropTypes.bool,
134
- /**
135
- * If `false`, the label will be visually hidden (but remains accessible by assistive
136
- * technologies).
137
- */
138
- isLabelVisible: PropTypes.bool,
139
- /**
140
- * Toggle label.
141
- */
142
- label: PropTypes.string.isRequired,
143
- /**
144
- * Placement of the label relative to the input.
145
- */
146
- labelPosition: PropTypes.oneOf(['before', 'after']),
147
- /**
148
- * Layout of the field. It has impact only on Toggle inside a FormLayout.
149
- */
150
- layout: PropTypes.oneOf(['horizontal', 'vertical']),
151
- /**
152
- * If `true`, the input will be required.
153
- */
154
- required: PropTypes.bool,
155
- /**
156
- * Alter the field to provide feedback based on validation result.
157
- */
158
- validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
159
- /**
160
- * Validation message to be displayed.
161
- */
162
- validationText: PropTypes.node,
163
- /**
164
- * Value of the input.
165
- */
166
- value: PropTypes.oneOfType([
167
- PropTypes.string,
168
- PropTypes.number,
169
- ]),
170
- };
171
-
172
- export const ToggleWithContext = withForwardedRef(withProviderContext(Toggle, 'Toggle'));
173
-
174
- export default ToggleWithContext;