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

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 +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
@@ -1,173 +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 './CheckboxField.scss';
8
-
9
- export const CheckboxField = ({
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
- onChange={changeHandler}
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
- CheckboxField.defaultProps = {
83
- changeHandler: null,
84
- checked: false,
85
- disabled: false,
86
- forwardedRef: undefined,
87
- helpText: null,
88
- id: undefined,
89
- inFormLayout: false,
90
- isLabelVisible: true,
91
- labelPosition: 'after',
92
- layout: 'vertical',
93
- required: false,
94
- validationState: null,
95
- validationText: null,
96
- value: undefined,
97
- };
98
-
99
- CheckboxField.propTypes = {
100
- /**
101
- * Function to call when the input is toggled.
102
- */
103
- changeHandler: PropTypes.func,
104
- /**
105
- * If `true`, the input will be checked.
106
- */
107
- checked: PropTypes.bool,
108
- /**
109
- * If `true`, the input will be disabled.
110
- */
111
- disabled: PropTypes.bool,
112
- /**
113
- * Reference forwarded to the `input` element.
114
- */
115
- forwardedRef: PropTypes.oneOfType([
116
- PropTypes.func,
117
- // eslint-disable-next-line react/forbid-prop-types
118
- PropTypes.shape({ current: PropTypes.any }),
119
- ]),
120
- /**
121
- * Optional help text.
122
- */
123
- helpText: PropTypes.node,
124
- /**
125
- * ID of the input HTML element. It also serves as a prefix for important inner elements:
126
- * `<ID>__label`, `<ID>__labelText`, `<ID>__helpText`, and `<ID>__validationText`.
127
- */
128
- id: PropTypes.string,
129
- /**
130
- * Treat the field differently when it's inside a FormLayout. Do not set manually!
131
- */
132
- inFormLayout: PropTypes.bool,
133
- /**
134
- * If `false`, the label will be visually hidden (but remains accessible by assistive
135
- * technologies).
136
- */
137
- isLabelVisible: PropTypes.bool,
138
- /**
139
- * Checkbox field label.
140
- */
141
- label: PropTypes.string.isRequired,
142
- /**
143
- * Placement of the label relative to the input.
144
- */
145
- labelPosition: PropTypes.oneOf(['before', 'after']),
146
- /**
147
- * Layout of the field. It has impact only on CheckboxField inside a FormLayout.
148
- */
149
- layout: PropTypes.oneOf(['horizontal', 'vertical']),
150
- /**
151
- * If `true`, the input will be required.
152
- */
153
- required: PropTypes.bool,
154
- /**
155
- * Alter the field to provide feedback based on validation result.
156
- */
157
- validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
158
- /**
159
- * Validation message to be displayed.
160
- */
161
- validationText: PropTypes.node,
162
- /**
163
- * Value of the input.
164
- */
165
- value: PropTypes.oneOfType([
166
- PropTypes.string,
167
- PropTypes.number,
168
- ]),
169
- };
170
-
171
- export const CheckboxFieldWithContext = withForwardedRef(withProviderContext(CheckboxField, 'CheckboxField'));
172
-
173
- export default CheckboxFieldWithContext;
@@ -1,158 +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 './FileInputField.scss';
8
-
9
- export const FileInputField = ({
10
- changeHandler,
11
- disabled,
12
- forwardedRef,
13
- fullWidth,
14
- helpText,
15
- id,
16
- inFormLayout,
17
- isLabelVisible,
18
- label,
19
- layout,
20
- required,
21
- validationState,
22
- validationText,
23
- ...restProps
24
- }) => (
25
- <label
26
- className={[
27
- styles.root,
28
- fullWidth ? styles.isRootFullWidth : '',
29
- inFormLayout ? styles.isRootInFormLayout : '',
30
- layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
31
- disabled ? styles.isRootDisabled : '',
32
- required ? styles.isRootRequired : '',
33
- getRootValidationStateClassName(validationState, styles),
34
- ].join(' ')}
35
- htmlFor={id}
36
- id={id && `${id}__label`}
37
- >
38
- <div
39
- className={[
40
- styles.label,
41
- isLabelVisible ? '' : styles.isLabelHidden,
42
- ].join(' ')}
43
- id={id && `${id}__labelText`}
44
- >
45
- {label}
46
- </div>
47
- <div className={styles.field}>
48
- <div className={styles.inputContainer}>
49
- <input
50
- {...transferProps(restProps)}
51
- className={styles.input}
52
- disabled={disabled}
53
- id={id}
54
- onChange={changeHandler}
55
- ref={forwardedRef}
56
- required={required}
57
- type="file"
58
- />
59
- </div>
60
- {helpText && (
61
- <div
62
- className={styles.helpText}
63
- id={id && `${id}__helpText`}
64
- >
65
- {helpText}
66
- </div>
67
- )}
68
- {validationText && (
69
- <div
70
- className={styles.validationText}
71
- id={id && `${id}__validationText`}
72
- >
73
- {validationText}
74
- </div>
75
- )}
76
- </div>
77
- </label>
78
- );
79
-
80
- FileInputField.defaultProps = {
81
- changeHandler: null,
82
- disabled: false,
83
- forwardedRef: undefined,
84
- fullWidth: false,
85
- helpText: null,
86
- id: undefined,
87
- inFormLayout: false,
88
- isLabelVisible: true,
89
- layout: 'vertical',
90
- required: false,
91
- validationState: null,
92
- validationText: null,
93
- };
94
-
95
- FileInputField.propTypes = {
96
- /**
97
- * Function to call when the input has changed.
98
- */
99
- changeHandler: PropTypes.func,
100
- /**
101
- * If `true`, the input will be disabled.
102
- */
103
- disabled: PropTypes.bool,
104
- /**
105
- * Reference forwarded to the `input` element.
106
- */
107
- forwardedRef: PropTypes.oneOfType([
108
- PropTypes.func,
109
- // eslint-disable-next-line react/forbid-prop-types
110
- PropTypes.shape({ current: PropTypes.any }),
111
- ]),
112
- /**
113
- * If `true`, the field will span the full width of its parent.
114
- */
115
- fullWidth: PropTypes.bool,
116
- /**
117
- * Optional help text.
118
- */
119
- helpText: PropTypes.node,
120
- /**
121
- * ID of the input HTML element. It also serves as a prefix for important inner elements:
122
- * `<ID>__label`, `<ID>__labelText`, `<ID>__helpText`, and `<ID>__validationText`.
123
- */
124
- id: PropTypes.string,
125
- /**
126
- * Treat the field differently when it's inside a FormLayout. Do not set manually!
127
- */
128
- inFormLayout: PropTypes.bool,
129
- /**
130
- * If `false`, the label will be visually hidden (but remains accessible by assistive
131
- * technologies).
132
- */
133
- isLabelVisible: PropTypes.bool,
134
- /**
135
- * Text field label.
136
- */
137
- label: PropTypes.string.isRequired,
138
- /**
139
- * Layout of the field.
140
- */
141
- layout: PropTypes.oneOf(['horizontal', 'vertical']),
142
- /**
143
- * If `true`, the input will be required.
144
- */
145
- required: PropTypes.bool,
146
- /**
147
- * Alter the field to provide feedback based on validation result.
148
- */
149
- validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
150
- /**
151
- * Validation message to be displayed.
152
- */
153
- validationText: PropTypes.node,
154
- };
155
-
156
- export const FileInputFieldWithContext = withForwardedRef(withProviderContext(FileInputField, 'FileInputField'));
157
-
158
- export default FileInputFieldWithContext;
@@ -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;