@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.
- package/CONTRIBUTING.md +44 -25
- package/README.md +1 -1
- package/dist/lib.development.js +1598 -652
- package/dist/lib.js +1 -9
- package/package.json +49 -48
- package/src/lib/components/{ui/Alert → Alert}/Alert.jsx +17 -14
- package/src/lib/components/{ui/Alert → Alert}/Alert.scss +3 -3
- package/src/lib/components/{ui/Alert → Alert}/README.mdx +6 -6
- package/src/lib/components/{ui/Alert → Alert}/_settings.scss +1 -1
- package/src/lib/components/{ui/Alert → Alert}/_theme.scss +0 -0
- package/src/lib/components/{ui/Alert → Alert}/_tools.scss +0 -0
- package/src/lib/components/{ui/Alert → Alert}/index.js +0 -0
- package/src/lib/components/{ui/Badge → Badge}/Badge.jsx +2 -2
- package/src/lib/components/{ui/Badge → Badge}/Badge.scss +3 -3
- package/src/lib/components/{ui/Badge → Badge}/README.mdx +3 -3
- package/src/lib/components/{ui/Badge → Badge}/index.js +0 -0
- package/src/lib/components/Button/Button.jsx +198 -0
- package/src/lib/components/{ui/Button → Button}/Button.scss +0 -0
- package/src/lib/components/{ui/Button → Button}/README.mdx +160 -75
- package/src/lib/components/Button/_base.scss +148 -0
- package/src/lib/components/{ui/Button → Button}/_priorities.scss +0 -4
- package/src/lib/components/{ui/Button → Button}/_settings.scss +2 -3
- package/src/lib/components/{ui/Button → Button}/_theme.scss +3 -11
- package/src/lib/components/{ui/Button → Button}/_tools.scss +27 -44
- package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +33 -0
- package/src/lib/components/{ui/Button → Button}/helpers/getRootPriorityClassName.js +0 -4
- package/src/lib/components/{ui/Button → Button}/index.js +0 -0
- package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/ButtonGroup.jsx +9 -11
- package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/ButtonGroup.scss +0 -0
- package/src/lib/components/ButtonGroup/ButtonGroupContext.js +3 -0
- package/src/lib/components/{ui/ButtonGroup → ButtonGroup}/README.mdx +26 -2
- package/src/lib/components/ButtonGroup/index.js +2 -0
- package/src/lib/components/{layout/CTA → CTA}/CTA.jsx +5 -2
- package/src/lib/components/{layout/CTA → CTA}/CTA.scss +2 -2
- package/src/lib/components/{layout/CTA → CTA}/CTACenter.jsx +1 -1
- package/src/lib/components/{layout/CTA → CTA}/CTAEnd.jsx +1 -1
- package/src/lib/components/{layout/CTA → CTA}/CTAStart.jsx +1 -1
- package/src/lib/components/{layout/CTA → CTA}/README.mdx +3 -3
- package/src/lib/components/{layout/CTA → CTA}/index.js +0 -0
- package/src/lib/components/{ui/Card → Card}/Card.jsx +6 -4
- package/src/lib/components/{ui/Card → Card}/Card.scss +1 -1
- package/src/lib/components/{ui/Card → Card}/CardBody.jsx +1 -1
- package/src/lib/components/{ui/Card → Card}/CardFooter.jsx +1 -1
- package/src/lib/components/{ui/Card → Card}/README.mdx +2 -2
- package/src/lib/components/{ui/Card → Card}/_theme.scss +0 -0
- package/src/lib/components/{ui/Card → Card}/_tools.scss +0 -0
- package/src/lib/components/{ui/Card → Card}/index.js +0 -0
- package/src/lib/components/{layout/Center → Center}/Center.jsx +1 -1
- package/src/lib/components/{layout/Center → Center}/Center.scss +0 -0
- package/src/lib/components/{layout/Center → Center}/README.mdx +2 -2
- package/src/lib/components/{layout/Center → Center}/index.js +0 -0
- package/src/lib/components/CheckboxField/CheckboxField.jsx +164 -0
- package/src/lib/components/{ui/CheckboxField → CheckboxField}/CheckboxField.scss +5 -5
- package/src/lib/components/{ui/CheckboxField → CheckboxField}/README.mdx +15 -12
- package/src/lib/components/{ui/CheckboxField → CheckboxField}/index.js +0 -0
- package/src/lib/components/FileInputField/FileInputField.jsx +162 -0
- package/src/lib/components/{ui/FileInputField → FileInputField}/FileInputField.scss +5 -5
- package/src/lib/components/{ui/FileInputField → FileInputField}/README.mdx +8 -6
- package/src/lib/components/{ui/FileInputField → FileInputField}/index.js +0 -0
- package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayout.jsx +16 -18
- package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayout.scss +3 -3
- package/src/lib/components/FormLayout/FormLayoutContext.js +3 -0
- package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayoutCustomField.jsx +33 -30
- package/src/lib/components/{layout/FormLayout → FormLayout}/FormLayoutCustomField.scss +4 -4
- package/src/lib/components/{layout/FormLayout → FormLayout}/README.mdx +30 -40
- package/src/lib/components/{layout/FormLayout → FormLayout}/_theme.scss +0 -0
- package/src/lib/components/{layout/FormLayout → FormLayout}/index.js +1 -0
- package/src/lib/components/{layout/Grid → Grid}/Grid.jsx +23 -5
- package/src/lib/components/{layout/Grid → Grid}/Grid.scss +2 -4
- package/src/lib/components/{layout/Grid → Grid}/GridSpan.jsx +10 -3
- package/src/lib/components/{layout/Grid → Grid}/README.mdx +42 -38
- package/src/lib/components/{layout/Grid → Grid}/_theme.scss +1 -2
- package/src/lib/components/{layout/Grid → Grid}/_tools.scss +2 -2
- package/src/lib/components/{layout/Grid → Grid}/helpers/generateResponsiveCustomProperties.js +0 -0
- package/src/lib/components/{layout/Grid → Grid}/index.js +0 -0
- package/src/lib/components/Link/Link.jsx +45 -0
- package/src/lib/components/Link/Link.scss +11 -0
- package/src/lib/components/Link/README.mdx +85 -0
- package/src/lib/components/Link/_theme.scss +4 -0
- package/src/lib/components/Link/index.js +1 -0
- package/src/lib/components/{layout/List → List}/List.jsx +1 -1
- package/src/lib/components/{layout/List → List}/List.scss +2 -2
- package/src/lib/components/{layout/List → List}/ListItem.jsx +1 -1
- package/src/lib/components/{layout/List → List}/README.mdx +2 -2
- package/src/lib/components/{layout/List → List}/_theme.scss +0 -0
- package/src/lib/components/{layout/List → List}/index.js +0 -0
- package/src/lib/components/{layout/Media → Media}/Media.jsx +4 -2
- package/src/lib/components/{layout/Media → Media}/Media.scss +1 -1
- package/src/lib/components/{layout/Media → Media}/MediaBody.jsx +1 -1
- package/src/lib/components/{layout/Media → Media}/MediaObject.jsx +1 -1
- package/src/lib/components/{layout/Media → Media}/README.mdx +2 -2
- package/src/lib/components/{layout/Media → Media}/index.js +0 -0
- package/src/lib/components/{ui/Modal → Modal}/Modal.jsx +28 -27
- package/src/lib/components/{ui/Modal → Modal}/Modal.scss +5 -5
- package/src/lib/components/{ui/Modal → Modal}/README.mdx +40 -40
- package/src/lib/components/{ui/Modal → Modal}/_settings.scss +4 -4
- package/src/lib/components/{ui/Modal → Modal}/_theme.scss +0 -0
- package/src/lib/components/{ui/Modal → Modal}/index.js +0 -0
- package/src/lib/components/{ui/Paper → Paper}/Paper.jsx +8 -1
- package/src/lib/components/{ui/Paper → Paper}/Paper.scss +5 -0
- package/src/lib/components/{ui/Paper → Paper}/README.mdx +14 -2
- package/src/lib/components/{ui/Paper → Paper}/_theme.scss +2 -0
- package/src/lib/components/{ui/Paper → Paper}/index.js +0 -0
- package/src/lib/components/{ui/Radio → Radio}/README.mdx +17 -14
- package/src/lib/components/Radio/Radio.jsx +188 -0
- package/src/lib/components/{ui/Radio → Radio}/Radio.scss +9 -9
- package/src/lib/components/{ui/Radio → Radio}/index.js +0 -0
- package/src/lib/components/{ui/ScrollView → ScrollView}/README.mdx +10 -10
- package/src/lib/components/{ui/ScrollView → ScrollView}/ScrollView.jsx +9 -10
- package/src/lib/components/{ui/ScrollView → ScrollView}/ScrollView.scss +6 -6
- package/src/lib/components/{ui/ScrollView → ScrollView}/_theme.scss +0 -0
- package/src/lib/components/{ui/ScrollView → ScrollView}/index.js +0 -0
- package/src/lib/components/{ui/SelectField → SelectField}/README.mdx +44 -41
- package/src/lib/components/SelectField/SelectField.jsx +219 -0
- package/src/lib/components/{ui/SelectField → SelectField}/SelectField.scss +6 -6
- package/src/lib/components/{ui/SelectField → SelectField}/index.js +0 -0
- package/src/lib/components/{ui/Table → Table}/README.mdx +7 -7
- package/src/lib/components/{ui/Table → Table}/Table.jsx +9 -13
- package/src/lib/components/{ui/Table → Table}/Table.scss +1 -1
- package/src/lib/components/{ui/Table → Table}/_settings.scss +4 -4
- package/src/lib/components/{ui/Table → Table}/index.js +0 -0
- package/src/lib/components/{ui/Tabs → Tabs}/README.mdx +3 -3
- package/src/lib/components/{ui/Tabs → Tabs}/Tabs.jsx +4 -4
- package/src/lib/components/{ui/Tabs → Tabs}/Tabs.scss +1 -1
- package/src/lib/components/{ui/Tabs → Tabs}/TabsItem.jsx +4 -3
- package/src/lib/components/{ui/Tabs → Tabs}/TabsItem.scss +3 -3
- package/src/lib/components/{ui/Tabs → Tabs}/_theme.scss +0 -0
- package/src/lib/components/{ui/Tabs → Tabs}/index.js +0 -0
- package/src/lib/components/{ui/Text → Text}/README.mdx +19 -19
- package/src/lib/components/{ui/Text → Text}/Text.jsx +1 -1
- package/src/lib/components/{ui/Text → Text}/Text.scss +0 -0
- package/src/lib/components/{ui/Text → Text}/helpers/getRootHyphensClassName.js +0 -0
- package/src/lib/components/{ui/Text → Text}/helpers/getRootWordWrappingClassName.js +0 -0
- package/src/lib/components/{ui/Text → Text}/index.js +0 -0
- package/src/lib/components/{ui/TextArea → TextArea}/README.mdx +8 -6
- package/src/lib/components/{ui/TextArea → TextArea}/TextArea.jsx +78 -78
- package/src/lib/components/{ui/TextArea → TextArea}/TextArea.scss +6 -6
- package/src/lib/components/{ui/TextArea → TextArea}/index.js +0 -0
- package/src/lib/components/{ui/TextField → TextField}/README.mdx +7 -6
- package/src/lib/components/{ui/TextField → TextField}/TextField.jsx +20 -23
- package/src/lib/components/{ui/TextField → TextField}/TextField.scss +6 -6
- package/src/lib/components/{ui/TextField → TextField}/index.js +0 -0
- package/src/lib/components/{ui/Toggle → Toggle}/README.mdx +15 -12
- package/src/lib/components/Toggle/Toggle.jsx +163 -0
- package/src/lib/components/{ui/Toggle → Toggle}/Toggle.scss +5 -5
- package/src/lib/components/{ui/Toggle → Toggle}/index.js +0 -0
- package/src/lib/components/{layout/Toolbar → Toolbar}/README.mdx +26 -26
- package/src/lib/components/{layout/Toolbar → Toolbar}/Toolbar.jsx +1 -1
- package/src/lib/components/{layout/Toolbar → Toolbar}/Toolbar.scss +1 -1
- package/src/lib/components/{layout/Toolbar → Toolbar}/ToolbarGroup.jsx +1 -1
- package/src/lib/components/{layout/Toolbar → Toolbar}/ToolbarItem.jsx +1 -1
- package/src/lib/components/{layout/Toolbar → Toolbar}/_theme.scss +0 -0
- package/src/lib/components/{layout/Toolbar → Toolbar}/index.js +0 -0
- package/src/lib/components/{ui/withForwardedRef.jsx → withForwardedRef.jsx} +0 -0
- package/src/lib/helpers/resolveContextOrProp.js +7 -0
- package/src/lib/index.js +34 -35
- package/src/lib/styles/tools/_accessibility.scss +9 -0
- package/src/lib/theme.scss +25 -7
- package/src/lib/components/ui/Button/Button.jsx +0 -191
- package/src/lib/components/ui/Button/_base.scss +0 -154
- package/src/lib/components/ui/Button/helpers/getRootLabelVisibilityClassName.js +0 -11
- package/src/lib/components/ui/ButtonGroup/index.js +0 -1
- package/src/lib/components/ui/CheckboxField/CheckboxField.jsx +0 -173
- package/src/lib/components/ui/FileInputField/FileInputField.jsx +0 -158
- package/src/lib/components/ui/Radio/Radio.jsx +0 -179
- package/src/lib/components/ui/SelectField/SelectField.jsx +0 -214
- package/src/lib/components/ui/Toggle/Toggle.jsx +0 -174
|
File without changes
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { withProviderContext } from '
|
|
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
|
-
|
|
23
|
-
|
|
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.
|
|
51
|
+
children: PropTypes.node.isRequired,
|
|
54
52
|
/**
|
|
55
53
|
* If `true`, all buttons inside the group will be disabled.
|
|
56
54
|
*/
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ButtonGroup
|
|
3
|
-
menu: '
|
|
4
|
-
route: /components/
|
|
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
|
|
|
@@ -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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { withProviderContext } from '
|
|
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
|
-
*
|
|
50
|
+
* Nested elements. Supported types are:
|
|
51
|
+
* * `CTAStart`
|
|
52
|
+
* * `CTACenter`
|
|
53
|
+
* * `CTAEnd`
|
|
51
54
|
*/
|
|
52
55
|
children: PropTypes.node.isRequired,
|
|
53
56
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: CTA
|
|
3
3
|
menu: 'Layouts'
|
|
4
|
-
route: /components/
|
|
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 '
|
|
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'
|
|
@@ -63,7 +63,7 @@ See [API](#api) for all available options.
|
|
|
63
63
|
screen even at the smallest size. For complex layouts and a lot of actions,
|
|
64
64
|
consider using the [Toolbar](/components/layout/toolbar) layout.
|
|
65
65
|
|
|
66
|
-
|
|
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 '
|
|
4
|
-
import { withProviderContext } from '
|
|
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:
|
|
40
|
-
*
|
|
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
|
/**
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: Center
|
|
3
3
|
menu: 'Layouts'
|
|
4
|
-
route: /components/
|
|
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 '
|
|
15
|
+
import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
|
|
16
16
|
import { Center } from './Center'
|
|
17
17
|
|
|
18
18
|
## Basic Usage
|
|
File without changes
|
|
@@ -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 '
|
|
2
|
-
@use '
|
|
3
|
-
@use '
|
|
4
|
-
@use '
|
|
5
|
-
@use '
|
|
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 {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: CheckboxField
|
|
3
|
-
menu: '
|
|
4
|
-
route: /components/
|
|
3
|
+
menu: 'Inputs'
|
|
4
|
+
route: /components/checkbox-field
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# CheckboxField
|
|
@@ -29,9 +29,9 @@ And use it:
|
|
|
29
29
|
const [agree, setAgree] = React.useState(true);
|
|
30
30
|
return (
|
|
31
31
|
<CheckboxField
|
|
32
|
-
changeHandler={() => setAgree(!agree)}
|
|
33
32
|
checked={agree}
|
|
34
33
|
label="I agree"
|
|
34
|
+
onChange={() => setAgree(!agree)}
|
|
35
35
|
/>
|
|
36
36
|
);
|
|
37
37
|
}}
|
|
@@ -81,10 +81,10 @@ turning the checkbox on or off.
|
|
|
81
81
|
const [getNewsletter, setGetNewsletter] = React.useState(true);
|
|
82
82
|
return (
|
|
83
83
|
<CheckboxField
|
|
84
|
-
changeHandler={() => setGetNewsletter(!getNewsletter)}
|
|
85
84
|
checked={getNewsletter}
|
|
86
85
|
helpText="We will not bother you more than once a month, we promise!"
|
|
87
86
|
label="Send me newsletter"
|
|
87
|
+
onChange={() => setGetNewsletter(!getNewsletter)}
|
|
88
88
|
/>
|
|
89
89
|
);
|
|
90
90
|
}}
|
|
@@ -100,10 +100,10 @@ label remains accessible to assistive technologies.
|
|
|
100
100
|
const [checked, setChecked] = React.useState(true);
|
|
101
101
|
return (
|
|
102
102
|
<CheckboxField
|
|
103
|
-
changeHandler={() => setChecked(!checked)}
|
|
104
103
|
checked={checked}
|
|
105
104
|
isLabelVisible={false}
|
|
106
105
|
label="You cannot see this"
|
|
106
|
+
onChange={() => setChecked(!checked)}
|
|
107
107
|
/>
|
|
108
108
|
);
|
|
109
109
|
}}
|
|
@@ -116,10 +116,10 @@ It's also possible to display label before input:
|
|
|
116
116
|
const [checked, setChecked] = React.useState(true);
|
|
117
117
|
return (
|
|
118
118
|
<CheckboxField
|
|
119
|
-
changeHandler={() => setChecked(!checked)}
|
|
120
119
|
checked={checked}
|
|
121
120
|
label="Label precedes input"
|
|
122
121
|
labelPosition="before"
|
|
122
|
+
onChange={() => setChecked(!checked)}
|
|
123
123
|
/>
|
|
124
124
|
);
|
|
125
125
|
}}
|
|
@@ -140,22 +140,22 @@ have.
|
|
|
140
140
|
return (
|
|
141
141
|
<>
|
|
142
142
|
<CheckboxField
|
|
143
|
-
changeHandler={() => setAgree(!agree)}
|
|
144
143
|
checked={agree}
|
|
145
144
|
label="I have read and agree with terms and conditions"
|
|
145
|
+
onChange={() => setAgree(!agree)}
|
|
146
146
|
validationState="valid"
|
|
147
147
|
/>
|
|
148
148
|
<CheckboxField
|
|
149
|
-
changeHandler={() => setAgree(!agree)}
|
|
150
149
|
checked={agree}
|
|
151
150
|
label="I have read and agree with terms and conditions"
|
|
151
|
+
onChange={() => setAgree(!agree)}
|
|
152
152
|
validationState="warning"
|
|
153
153
|
validationText="Please wait 10 minutes until we verify your data."
|
|
154
154
|
/>
|
|
155
155
|
<CheckboxField
|
|
156
|
-
changeHandler={() => setAgree(!agree)}
|
|
157
156
|
checked={agree}
|
|
158
157
|
label="I have read and agree with terms and conditions"
|
|
158
|
+
onChange={() => setAgree(!agree)}
|
|
159
159
|
required
|
|
160
160
|
validationState="invalid"
|
|
161
161
|
validationText="You must agree to be able to proceed."
|
|
@@ -183,9 +183,10 @@ Disabled state makes the input unavailable.
|
|
|
183
183
|
|
|
184
184
|
## API
|
|
185
185
|
|
|
186
|
-
In addition to the options below, you can
|
|
187
|
-
interfere with the API, and they will be
|
|
188
|
-
|
|
186
|
+
In addition to the options below, you can specify [React synthetic events] or
|
|
187
|
+
any custom HTML attributes that do not interfere with the API, and they will be
|
|
188
|
+
passed to the `input` HTML element. This enables making the component
|
|
189
|
+
interactive and helps improve its accessibility.
|
|
189
190
|
|
|
190
191
|
<Props table of={CheckboxField} />
|
|
191
192
|
|
|
@@ -198,3 +199,5 @@ options. On top of that, the following options are available for CheckboxField.
|
|
|
198
199
|
|----------------------------------------------------------------------|----------------------------------------------|
|
|
199
200
|
| `--rui-FormField--check__input--checkbox__border-radius` | Input corner radius |
|
|
200
201
|
| `--rui-FormField--check__input--checkbox--checked__background-image` | Background image of checked input |
|
|
202
|
+
|
|
203
|
+
[React synthetic events]: https://reactjs.org/docs/events.html
|
|
File without changes
|