@react-ui-org/react-ui 0.47.0 → 0.48.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/lib.development.js +330 -54
- package/dist/lib.js +1 -1
- package/package.json +1 -1
- package/src/lib/components/Alert/README.mdx +4 -2
- package/src/lib/components/Alert/index.js +1 -1
- package/src/lib/components/Badge/README.mdx +1 -1
- package/src/lib/components/Badge/index.js +1 -1
- package/src/lib/components/Button/Button.jsx +31 -31
- package/src/lib/components/Button/README.mdx +4 -2
- package/src/lib/components/Button/index.js +1 -1
- package/src/lib/components/ButtonGroup/ButtonGroup.jsx +2 -1
- package/src/lib/components/ButtonGroup/README.mdx +4 -2
- package/src/lib/components/Card/README.mdx +7 -5
- package/src/lib/components/CheckboxField/CheckboxField.jsx +27 -28
- package/src/lib/components/CheckboxField/README.mdx +1 -1
- package/src/lib/components/CheckboxField/index.js +1 -1
- package/src/lib/components/FileInputField/FileInputField.jsx +27 -27
- package/src/lib/components/FileInputField/README.mdx +1 -1
- package/src/lib/components/FileInputField/index.js +1 -1
- package/src/lib/components/FormLayout/README.mdx +15 -13
- package/src/lib/components/Grid/Grid.jsx +31 -28
- package/src/lib/components/Grid/Grid.scss +10 -15
- package/src/lib/components/Grid/GridSpan.jsx +5 -4
- package/src/lib/components/Grid/README.mdx +34 -36
- package/src/lib/components/Grid/_helpers/generateResponsiveCustomProperties.js +11 -3
- package/src/lib/components/Grid/_settings.scss +18 -0
- package/src/lib/components/Grid/_tools.scss +5 -5
- package/src/lib/components/Modal/Modal.jsx +147 -250
- package/src/lib/components/Modal/Modal.scss +7 -55
- package/src/lib/components/Modal/ModalBody.jsx +64 -0
- package/src/lib/components/Modal/ModalBody.scss +18 -0
- package/src/lib/components/Modal/ModalCloseButton.jsx +61 -0
- package/src/lib/components/Modal/ModalCloseButton.scss +18 -0
- package/src/lib/components/Modal/ModalContent.jsx +43 -0
- package/src/lib/components/Modal/ModalContent.scss +5 -0
- package/src/lib/components/Modal/ModalFooter.jsx +46 -0
- package/src/lib/components/Modal/ModalFooter.scss +35 -0
- package/src/lib/components/Modal/ModalHeader.jsx +48 -0
- package/src/lib/components/Modal/ModalHeader.scss +30 -0
- package/src/lib/components/Modal/ModalTitle.jsx +45 -0
- package/src/lib/components/Modal/ModalTitle.scss +10 -0
- package/src/lib/components/Modal/README.mdx +842 -197
- package/src/lib/components/Modal/_helpers/getJustifyClassName.js +19 -0
- package/src/lib/components/Modal/_helpers/getScrollingClassName.js +11 -0
- package/src/lib/components/Modal/_settings.scss +1 -5
- package/src/lib/components/Modal/_theme.scss +6 -0
- package/src/lib/components/Modal/index.js +7 -1
- package/src/lib/components/Paper/README.mdx +1 -1
- package/src/lib/components/Paper/index.js +1 -1
- package/src/lib/components/Popover/Popover.jsx +24 -24
- package/src/lib/components/Popover/Popover.scss +7 -6
- package/src/lib/components/Popover/PopoverWrapper.jsx +5 -5
- package/src/lib/components/Popover/PopoverWrapper.scss +3 -0
- package/src/lib/components/Popover/README.mdx +13 -11
- package/src/lib/components/Popover/_theme.scss +1 -1
- package/src/lib/components/Radio/README.mdx +1 -1
- package/src/lib/components/Radio/Radio.jsx +37 -27
- package/src/lib/components/Radio/index.js +1 -1
- package/src/lib/components/ScrollView/README.mdx +146 -84
- package/src/lib/components/ScrollView/ScrollView.jsx +104 -113
- package/src/lib/components/ScrollView/ScrollView.scss +18 -16
- package/src/lib/components/ScrollView/index.js +1 -1
- package/src/lib/components/SelectField/README.mdx +66 -2
- package/src/lib/components/SelectField/SelectField.jsx +93 -49
- package/src/lib/components/SelectField/_components/Option/Option.jsx +46 -0
- package/src/lib/components/SelectField/_components/Option/index.js +1 -0
- package/src/lib/components/SelectField/index.js +1 -1
- package/src/lib/components/Table/README.mdx +4 -2
- package/src/lib/components/Table/Table.jsx +1 -1
- package/src/lib/components/Table/index.js +1 -1
- package/src/lib/components/Tabs/README.mdx +5 -3
- package/src/lib/components/Tabs/TabsItem.scss +1 -2
- package/src/lib/components/Text/README.mdx +9 -7
- package/src/lib/components/Text/index.js +1 -1
- package/src/lib/components/TextArea/README.mdx +1 -1
- package/src/lib/components/TextArea/TextArea.jsx +33 -33
- package/src/lib/components/TextArea/index.js +1 -1
- package/src/lib/components/TextField/README.mdx +3 -3
- package/src/lib/components/TextField/TextField.jsx +33 -34
- package/src/lib/components/TextField/index.js +1 -1
- package/src/lib/components/TextLink/README.mdx +1 -1
- package/src/lib/components/TextLink/index.js +1 -1
- package/src/lib/components/Toggle/README.mdx +1 -1
- package/src/lib/components/Toggle/Toggle.jsx +28 -28
- package/src/lib/components/Toggle/index.js +1 -1
- package/src/lib/components/Toolbar/README.mdx +8 -6
- package/src/lib/components/_helpers/transferProps.js +1 -1
- package/src/lib/index.js +24 -16
- package/src/lib/provider/withGlobalProps.jsx +20 -3
- package/src/lib/theme.scss +18 -26
- package/src/lib/translations/en.js +1 -1
- package/src/lib/components/Grid/_theme.scss +0 -11
- package/src/lib/components/ScrollView/_theme.scss +0 -2
- package/src/lib/components/withForwardedRef.jsx +0 -11
package/package.json
CHANGED
@@ -12,8 +12,10 @@ import {
|
|
12
12
|
} from 'docz'
|
13
13
|
import Icon from '../../../docs/_components/Icon'
|
14
14
|
import Placeholder from '../../../docs/_components/Placeholder'
|
15
|
-
import
|
16
|
-
|
15
|
+
import {
|
16
|
+
Button,
|
17
|
+
Alert,
|
18
|
+
} from '../..'
|
17
19
|
|
18
20
|
Alert presents feedback or important information to users.
|
19
21
|
|
@@ -1 +1 @@
|
|
1
|
-
export { default } from './Alert';
|
1
|
+
export { default as Alert } from './Alert';
|
@@ -1 +1 @@
|
|
1
|
-
export { default } from './Badge';
|
1
|
+
export { default as Badge } from './Badge';
|
@@ -6,30 +6,30 @@ import { getRootColorClassName } from '../_helpers/getRootColorClassName';
|
|
6
6
|
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
7
7
|
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
8
8
|
import { transferProps } from '../_helpers/transferProps';
|
9
|
-
import withForwardedRef from '../withForwardedRef';
|
10
9
|
import { ButtonGroupContext } from '../ButtonGroup';
|
11
10
|
import getRootLabelVisibilityClassName from './helpers/getRootLabelVisibilityClassName';
|
12
11
|
import getRootPriorityClassName from './helpers/getRootPriorityClassName';
|
13
12
|
import styles from './Button.scss';
|
14
13
|
|
15
|
-
export const Button = ({
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
}
|
14
|
+
export const Button = React.forwardRef((props, ref) => {
|
15
|
+
const {
|
16
|
+
afterLabel,
|
17
|
+
beforeLabel,
|
18
|
+
block,
|
19
|
+
disabled,
|
20
|
+
endCorner,
|
21
|
+
feedbackIcon,
|
22
|
+
id,
|
23
|
+
label,
|
24
|
+
labelVisibility,
|
25
|
+
priority,
|
26
|
+
size,
|
27
|
+
startCorner,
|
28
|
+
type,
|
29
|
+
color,
|
30
|
+
...restProps
|
31
|
+
} = props;
|
32
|
+
|
33
33
|
const context = useContext(ButtonGroupContext);
|
34
34
|
|
35
35
|
return (
|
@@ -55,7 +55,7 @@ export const Button = ({
|
|
55
55
|
)}
|
56
56
|
disabled={resolveContextOrProp(context && context.disabled, disabled) || !!feedbackIcon}
|
57
57
|
id={id}
|
58
|
-
ref={
|
58
|
+
ref={ref}
|
59
59
|
type={type}
|
60
60
|
>
|
61
61
|
{startCorner && (
|
@@ -92,7 +92,7 @@ export const Button = ({
|
|
92
92
|
</button>
|
93
93
|
/* eslint-enable react/button-has-type */
|
94
94
|
);
|
95
|
-
};
|
95
|
+
});
|
96
96
|
|
97
97
|
Button.defaultProps = {
|
98
98
|
afterLabel: null,
|
@@ -102,10 +102,10 @@ Button.defaultProps = {
|
|
102
102
|
disabled: false,
|
103
103
|
endCorner: null,
|
104
104
|
feedbackIcon: null,
|
105
|
-
forwardedRef: undefined,
|
106
105
|
id: undefined,
|
107
106
|
labelVisibility: 'xs',
|
108
107
|
priority: 'filled',
|
108
|
+
ref: undefined,
|
109
109
|
size: 'medium',
|
110
110
|
startCorner: null,
|
111
111
|
type: 'button',
|
@@ -147,14 +147,6 @@ Button.propTypes = {
|
|
147
147
|
* button is in feedback state.
|
148
148
|
*/
|
149
149
|
feedbackIcon: PropTypes.node,
|
150
|
-
/**
|
151
|
-
* Reference forwarded to the `button` element.
|
152
|
-
*/
|
153
|
-
forwardedRef: PropTypes.oneOfType([
|
154
|
-
PropTypes.func,
|
155
|
-
// eslint-disable-next-line react/forbid-prop-types
|
156
|
-
PropTypes.shape({ current: PropTypes.any }),
|
157
|
-
]),
|
158
150
|
/**
|
159
151
|
* ID of the root HTML element.
|
160
152
|
*
|
@@ -177,6 +169,14 @@ Button.propTypes = {
|
|
177
169
|
* as the value is inherited in such case.
|
178
170
|
*/
|
179
171
|
priority: PropTypes.oneOf(['filled', 'outline', 'flat']),
|
172
|
+
/**
|
173
|
+
* Reference forwarded to the `button` element.
|
174
|
+
*/
|
175
|
+
ref: PropTypes.oneOfType([
|
176
|
+
PropTypes.func,
|
177
|
+
// eslint-disable-next-line react/forbid-prop-types
|
178
|
+
PropTypes.shape({ current: PropTypes.any }),
|
179
|
+
]),
|
180
180
|
/**
|
181
181
|
* Size of the button.
|
182
182
|
*
|
@@ -194,6 +194,6 @@ Button.propTypes = {
|
|
194
194
|
type: PropTypes.oneOf(['button', 'submit']),
|
195
195
|
};
|
196
196
|
|
197
|
-
export const ButtonWithGlobalProps =
|
197
|
+
export const ButtonWithGlobalProps = withGlobalProps(Button, 'Button');
|
198
198
|
|
199
199
|
export default ButtonWithGlobalProps;
|
@@ -12,8 +12,10 @@ import {
|
|
12
12
|
} from 'docz'
|
13
13
|
import Icon from '../../../docs/_components/Icon'
|
14
14
|
import Placeholder from '../../../docs/_components/Placeholder'
|
15
|
-
import
|
16
|
-
|
15
|
+
import {
|
16
|
+
Badge,
|
17
|
+
Button,
|
18
|
+
} from '../..'
|
17
19
|
|
18
20
|
Buttons allow users to take actions.
|
19
21
|
|
@@ -1 +1 @@
|
|
1
|
-
export { default } from './Button';
|
1
|
+
export { default as Button } from './Button';
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
3
3
|
import { withGlobalProps } from '../../provider';
|
4
4
|
import { classNames } from '../../utils/classNames';
|
5
5
|
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
|
6
|
+
import { transferProps } from '../_helpers/transferProps';
|
6
7
|
import styles from './ButtonGroup.scss';
|
7
8
|
import { ButtonGroupContext } from './ButtonGroupContext';
|
8
9
|
|
@@ -21,13 +22,13 @@ export const ButtonGroup = ({
|
|
21
22
|
|
22
23
|
return (
|
23
24
|
<div
|
25
|
+
{...transferProps(restProps)}
|
24
26
|
className={classNames(
|
25
27
|
styles.root,
|
26
28
|
block && styles.isRootBlock,
|
27
29
|
)}
|
28
30
|
id={id}
|
29
31
|
role="group"
|
30
|
-
{...restProps}
|
31
32
|
>
|
32
33
|
<ButtonGroupContext.Provider
|
33
34
|
value={{
|
@@ -10,11 +10,13 @@ import {
|
|
10
10
|
Playground,
|
11
11
|
Props,
|
12
12
|
} from 'docz'
|
13
|
-
import
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
import {
|
14
|
+
Button,
|
15
|
+
ScrollView,
|
16
|
+
Card,
|
17
|
+
CardBody,
|
18
|
+
CardFooter,
|
19
|
+
} from '../..'
|
18
20
|
|
19
21
|
Cards contain content and actions about a single subject.
|
20
22
|
|
@@ -5,24 +5,23 @@ import { classNames } from '../../utils/classNames';
|
|
5
5
|
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
|
6
6
|
import { transferProps } from '../_helpers/transferProps';
|
7
7
|
import { FormLayoutContext } from '../FormLayout';
|
8
|
-
import withForwardedRef from '../withForwardedRef';
|
9
8
|
import styles from './CheckboxField.scss';
|
10
9
|
|
11
|
-
export const CheckboxField = ({
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
10
|
+
export const CheckboxField = React.forwardRef((props, ref) => {
|
11
|
+
const {
|
12
|
+
checked,
|
13
|
+
disabled,
|
14
|
+
helpText,
|
15
|
+
id,
|
16
|
+
isLabelVisible,
|
17
|
+
label,
|
18
|
+
labelPosition,
|
19
|
+
required,
|
20
|
+
validationState,
|
21
|
+
validationText,
|
22
|
+
value,
|
23
|
+
...restProps
|
24
|
+
} = props;
|
26
25
|
const context = useContext(FormLayoutContext);
|
27
26
|
|
28
27
|
return (
|
@@ -55,7 +54,7 @@ export const CheckboxField = ({
|
|
55
54
|
className={styles.input}
|
56
55
|
disabled={disabled}
|
57
56
|
id={id}
|
58
|
-
ref={
|
57
|
+
ref={ref}
|
59
58
|
required={required}
|
60
59
|
type="checkbox"
|
61
60
|
value={value}
|
@@ -79,16 +78,16 @@ export const CheckboxField = ({
|
|
79
78
|
)}
|
80
79
|
</label>
|
81
80
|
);
|
82
|
-
};
|
81
|
+
});
|
83
82
|
|
84
83
|
CheckboxField.defaultProps = {
|
85
84
|
checked: undefined,
|
86
85
|
disabled: false,
|
87
|
-
forwardedRef: undefined,
|
88
86
|
helpText: null,
|
89
87
|
id: undefined,
|
90
88
|
isLabelVisible: true,
|
91
89
|
labelPosition: 'after',
|
90
|
+
ref: undefined,
|
92
91
|
required: false,
|
93
92
|
validationState: null,
|
94
93
|
validationText: null,
|
@@ -104,14 +103,6 @@ CheckboxField.propTypes = {
|
|
104
103
|
* If `true`, the input will be disabled.
|
105
104
|
*/
|
106
105
|
disabled: PropTypes.bool,
|
107
|
-
/**
|
108
|
-
* Reference forwarded to the `input` element.
|
109
|
-
*/
|
110
|
-
forwardedRef: PropTypes.oneOfType([
|
111
|
-
PropTypes.func,
|
112
|
-
// eslint-disable-next-line react/forbid-prop-types
|
113
|
-
PropTypes.shape({ current: PropTypes.any }),
|
114
|
-
]),
|
115
106
|
/**
|
116
107
|
* Optional help text.
|
117
108
|
*/
|
@@ -139,6 +130,14 @@ CheckboxField.propTypes = {
|
|
139
130
|
* Placement of the label relative to the input.
|
140
131
|
*/
|
141
132
|
labelPosition: PropTypes.oneOf(['before', 'after']),
|
133
|
+
/**
|
134
|
+
* Reference forwarded to the `input` element.
|
135
|
+
*/
|
136
|
+
ref: PropTypes.oneOfType([
|
137
|
+
PropTypes.func,
|
138
|
+
// eslint-disable-next-line react/forbid-prop-types
|
139
|
+
PropTypes.shape({ current: PropTypes.any }),
|
140
|
+
]),
|
142
141
|
/**
|
143
142
|
* If `true`, the input will be required.
|
144
143
|
*/
|
@@ -160,6 +159,6 @@ CheckboxField.propTypes = {
|
|
160
159
|
]),
|
161
160
|
};
|
162
161
|
|
163
|
-
export const CheckboxFieldWithGlobalProps =
|
162
|
+
export const CheckboxFieldWithGlobalProps = withGlobalProps(CheckboxField, 'CheckboxField');
|
164
163
|
|
165
164
|
export default CheckboxFieldWithGlobalProps;
|
@@ -1 +1 @@
|
|
1
|
-
export { default } from './CheckboxField';
|
1
|
+
export { default as CheckboxField } from './CheckboxField';
|
@@ -6,23 +6,23 @@ import { getRootValidationStateClassName } from '../_helpers/getRootValidationSt
|
|
6
6
|
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
7
7
|
import { transferProps } from '../_helpers/transferProps';
|
8
8
|
import { FormLayoutContext } from '../FormLayout';
|
9
|
-
import withForwardedRef from '../withForwardedRef';
|
10
9
|
import styles from './FileInputField.scss';
|
11
10
|
|
12
|
-
export const FileInputField = ({
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
11
|
+
export const FileInputField = React.forwardRef((props, ref) => {
|
12
|
+
const {
|
13
|
+
disabled,
|
14
|
+
fullWidth,
|
15
|
+
helpText,
|
16
|
+
id,
|
17
|
+
isLabelVisible,
|
18
|
+
label,
|
19
|
+
layout,
|
20
|
+
required,
|
21
|
+
validationState,
|
22
|
+
validationText,
|
23
|
+
...restProps
|
24
|
+
} = props;
|
25
|
+
|
26
26
|
const context = useContext(FormLayoutContext);
|
27
27
|
|
28
28
|
return (
|
@@ -57,7 +57,7 @@ export const FileInputField = ({
|
|
57
57
|
className={styles.input}
|
58
58
|
disabled={disabled}
|
59
59
|
id={id}
|
60
|
-
ref={
|
60
|
+
ref={ref}
|
61
61
|
required={required}
|
62
62
|
type="file"
|
63
63
|
/>
|
@@ -81,16 +81,16 @@ export const FileInputField = ({
|
|
81
81
|
</div>
|
82
82
|
</label>
|
83
83
|
);
|
84
|
-
};
|
84
|
+
});
|
85
85
|
|
86
86
|
FileInputField.defaultProps = {
|
87
87
|
disabled: false,
|
88
|
-
forwardedRef: undefined,
|
89
88
|
fullWidth: false,
|
90
89
|
helpText: null,
|
91
90
|
id: undefined,
|
92
91
|
isLabelVisible: true,
|
93
92
|
layout: 'vertical',
|
93
|
+
ref: undefined,
|
94
94
|
required: false,
|
95
95
|
validationState: null,
|
96
96
|
validationText: null,
|
@@ -101,14 +101,6 @@ FileInputField.propTypes = {
|
|
101
101
|
* If `true`, the input will be disabled.
|
102
102
|
*/
|
103
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
104
|
/**
|
113
105
|
* If `true`, the field will span the full width of its parent.
|
114
106
|
*/
|
@@ -144,6 +136,14 @@ FileInputField.propTypes = {
|
|
144
136
|
*
|
145
137
|
*/
|
146
138
|
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
139
|
+
/**
|
140
|
+
* Reference forwarded to the `input` element.
|
141
|
+
*/
|
142
|
+
ref: PropTypes.oneOfType([
|
143
|
+
PropTypes.func,
|
144
|
+
// eslint-disable-next-line react/forbid-prop-types
|
145
|
+
PropTypes.shape({ current: PropTypes.any }),
|
146
|
+
]),
|
147
147
|
/**
|
148
148
|
* If `true`, the input will be required.
|
149
149
|
*/
|
@@ -158,6 +158,6 @@ FileInputField.propTypes = {
|
|
158
158
|
validationText: PropTypes.node,
|
159
159
|
};
|
160
160
|
|
161
|
-
export const FileInputFieldWithGlobalProps =
|
161
|
+
export const FileInputFieldWithGlobalProps = withGlobalProps(FileInputField, 'FileInputField');
|
162
162
|
|
163
163
|
export default FileInputFieldWithGlobalProps;
|
@@ -1 +1 @@
|
|
1
|
-
export { default } from './FileInputField';
|
1
|
+
export { default as FileInputField } from './FileInputField';
|
@@ -13,19 +13,21 @@ import {
|
|
13
13
|
Props,
|
14
14
|
} from 'docz'
|
15
15
|
import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
|
16
|
-
import {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
16
|
+
import {
|
17
|
+
Button,
|
18
|
+
ButtonGroup,
|
19
|
+
CheckboxField,
|
20
|
+
FileInputField,
|
21
|
+
Radio,
|
22
|
+
SelectField,
|
23
|
+
TextArea,
|
24
|
+
TextField,
|
25
|
+
Toggle,
|
26
|
+
Toolbar,
|
27
|
+
ToolbarItem,
|
28
|
+
FormLayout,
|
29
|
+
FormLayoutCustomField,
|
30
|
+
} from '../..'
|
29
31
|
|
30
32
|
## Basic Usage
|
31
33
|
|
@@ -2,9 +2,12 @@ import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
3
3
|
import { withGlobalProps } from '../../provider';
|
4
4
|
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
|
5
|
+
import { transferProps } from '../_helpers/transferProps';
|
5
6
|
import { generateResponsiveCustomProperties } from './_helpers/generateResponsiveCustomProperties';
|
6
7
|
import styles from './Grid.scss';
|
7
8
|
|
9
|
+
const SPACING_VALUES = [0, 1, 2, 3, 4, 5, 6, 7];
|
10
|
+
|
8
11
|
export const Grid = ({
|
9
12
|
alignContent,
|
10
13
|
alignItems,
|
@@ -18,7 +21,7 @@ export const Grid = ({
|
|
18
21
|
rowGap,
|
19
22
|
rows,
|
20
23
|
tag: Tag,
|
21
|
-
...
|
24
|
+
...restProps
|
22
25
|
}) => {
|
23
26
|
if (isChildrenEmpty(children)) {
|
24
27
|
return null;
|
@@ -26,20 +29,20 @@ export const Grid = ({
|
|
26
29
|
|
27
30
|
return (
|
28
31
|
<Tag
|
32
|
+
{...transferProps(restProps)}
|
29
33
|
id={id}
|
30
34
|
className={styles.root}
|
31
35
|
style={{
|
32
36
|
...generateResponsiveCustomProperties(columns, 'columns'),
|
33
|
-
...generateResponsiveCustomProperties(columnGap, 'column-gap'),
|
37
|
+
...generateResponsiveCustomProperties(columnGap, 'column-gap', 'spacing'),
|
34
38
|
...generateResponsiveCustomProperties(rows, 'rows'),
|
35
|
-
...generateResponsiveCustomProperties(rowGap, 'row-gap'),
|
39
|
+
...generateResponsiveCustomProperties(rowGap, 'row-gap', 'spacing'),
|
36
40
|
...generateResponsiveCustomProperties(autoFlow, 'auto-flow'),
|
37
41
|
...generateResponsiveCustomProperties(alignContent, 'align-content'),
|
38
42
|
...generateResponsiveCustomProperties(alignItems, 'align-items'),
|
39
43
|
...generateResponsiveCustomProperties(justifyContent, 'justify-content'),
|
40
44
|
...generateResponsiveCustomProperties(justifyItems, 'justify-items'),
|
41
45
|
}}
|
42
|
-
{...other}
|
43
46
|
>
|
44
47
|
{children}
|
45
48
|
</Tag>
|
@@ -54,13 +57,13 @@ Grid.defaultProps = {
|
|
54
57
|
alignItems: undefined,
|
55
58
|
autoFlow: undefined,
|
56
59
|
children: null,
|
57
|
-
columnGap:
|
58
|
-
columns:
|
60
|
+
columnGap: 4,
|
61
|
+
columns: '1fr',
|
59
62
|
id: undefined,
|
60
63
|
justifyContent: undefined,
|
61
64
|
justifyItems: undefined,
|
62
|
-
rowGap:
|
63
|
-
rows:
|
65
|
+
rowGap: 4,
|
66
|
+
rows: 'auto',
|
64
67
|
tag: 'div',
|
65
68
|
};
|
66
69
|
|
@@ -118,19 +121,19 @@ Grid.propTypes = {
|
|
118
121
|
*/
|
119
122
|
children: PropTypes.node,
|
120
123
|
/**
|
121
|
-
* Gap between columns. Accepts any
|
122
|
-
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) for more
|
124
|
+
* Gap between columns. Accepts any of [spacing values](/foundation/spacing-values) as number.
|
125
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) for more about `column-gap`.
|
123
126
|
*/
|
124
127
|
columnGap: PropTypes.oneOfType([
|
125
|
-
PropTypes.
|
128
|
+
PropTypes.oneOf(SPACING_VALUES),
|
126
129
|
PropTypes.shape({
|
127
|
-
xs: PropTypes.
|
128
|
-
sm: PropTypes.
|
129
|
-
md: PropTypes.
|
130
|
-
lg: PropTypes.
|
131
|
-
xl: PropTypes.
|
132
|
-
x2l: PropTypes.
|
133
|
-
x3l: PropTypes.
|
130
|
+
xs: PropTypes.oneOf(SPACING_VALUES),
|
131
|
+
sm: PropTypes.oneOf(SPACING_VALUES),
|
132
|
+
md: PropTypes.oneOf(SPACING_VALUES),
|
133
|
+
lg: PropTypes.oneOf(SPACING_VALUES),
|
134
|
+
xl: PropTypes.oneOf(SPACING_VALUES),
|
135
|
+
x2l: PropTypes.oneOf(SPACING_VALUES),
|
136
|
+
x3l: PropTypes.oneOf(SPACING_VALUES),
|
134
137
|
}),
|
135
138
|
]),
|
136
139
|
/**
|
@@ -186,19 +189,19 @@ Grid.propTypes = {
|
|
186
189
|
}),
|
187
190
|
]),
|
188
191
|
/**
|
189
|
-
* Gap between rows. Accepts any
|
190
|
-
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) for more
|
192
|
+
* Gap between rows. Accepts any of [spacing values](/foundation/spacing-values) as number.
|
193
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) for more about `row-gap`.
|
191
194
|
*/
|
192
195
|
rowGap: PropTypes.oneOfType([
|
193
|
-
PropTypes.
|
196
|
+
PropTypes.oneOf(SPACING_VALUES),
|
194
197
|
PropTypes.shape({
|
195
|
-
xs: PropTypes.
|
196
|
-
sm: PropTypes.
|
197
|
-
md: PropTypes.
|
198
|
-
lg: PropTypes.
|
199
|
-
xl: PropTypes.
|
200
|
-
x2l: PropTypes.
|
201
|
-
x3l: PropTypes.
|
198
|
+
xs: PropTypes.oneOf(SPACING_VALUES),
|
199
|
+
sm: PropTypes.oneOf(SPACING_VALUES),
|
200
|
+
md: PropTypes.oneOf(SPACING_VALUES),
|
201
|
+
lg: PropTypes.oneOf(SPACING_VALUES),
|
202
|
+
xl: PropTypes.oneOf(SPACING_VALUES),
|
203
|
+
x2l: PropTypes.oneOf(SPACING_VALUES),
|
204
|
+
x3l: PropTypes.oneOf(SPACING_VALUES),
|
202
205
|
}),
|
203
206
|
]),
|
204
207
|
/**
|