@react-ui-org/react-ui 0.44.1 → 0.47.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CONTRIBUTING.md +7 -0
- package/README.md +15 -16
- package/dist/lib.development.js +271 -415
- package/dist/lib.js +1 -1
- package/package.json +11 -13
- package/src/lib/components/Alert/Alert.jsx +45 -44
- package/src/lib/components/Alert/Alert.scss +48 -48
- package/src/lib/components/Alert/README.mdx +2 -5
- package/src/lib/components/Alert/_settings.scss +4 -4
- package/src/lib/components/Alert/_theme.scss +50 -50
- package/src/lib/components/Alert/_tools.scss +6 -6
- package/src/lib/components/Badge/Badge.jsx +9 -11
- package/src/lib/components/Badge/Badge.scss +57 -57
- package/src/lib/components/Button/Button.jsx +14 -13
- package/src/lib/components/Button/Button.scss +2 -2
- package/src/lib/components/Button/README.mdx +11 -6
- package/src/lib/components/Button/_base.scss +69 -69
- package/src/lib/components/Button/_priorities.scss +49 -49
- package/src/lib/components/Button/_settings.scss +10 -10
- package/src/lib/components/Button/_theme.scss +18 -15
- package/src/lib/components/Button/_tools.scss +98 -100
- package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +4 -4
- package/src/lib/components/ButtonGroup/ButtonGroup.jsx +41 -25
- package/src/lib/components/ButtonGroup/ButtonGroup.scss +3 -3
- package/src/lib/components/ButtonGroup/README.mdx +1 -1
- package/src/lib/components/Card/Card.jsx +10 -9
- package/src/lib/components/Card/Card.scss +28 -28
- package/src/lib/components/Card/CardBody.jsx +17 -12
- package/src/lib/components/Card/CardFooter.jsx +22 -9
- package/src/lib/components/Card/_theme.scss +50 -50
- package/src/lib/components/Card/_tools.scss +6 -6
- package/src/lib/components/CheckboxField/CheckboxField.jsx +21 -20
- package/src/lib/components/CheckboxField/CheckboxField.scss +20 -20
- package/src/lib/components/CheckboxField/README.mdx +1 -1
- package/src/lib/components/FileInputField/FileInputField.jsx +16 -15
- package/src/lib/components/FileInputField/FileInputField.scss +19 -19
- package/src/lib/components/FileInputField/README.mdx +1 -1
- package/src/lib/components/FormLayout/FormLayout.jsx +19 -17
- package/src/lib/components/FormLayout/FormLayout.scss +17 -17
- package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +18 -12
- package/src/lib/components/FormLayout/FormLayoutCustomField.scss +18 -18
- package/src/lib/components/FormLayout/README.mdx +26 -49
- package/src/lib/components/Grid/Grid.jsx +25 -24
- package/src/lib/components/Grid/Grid.scss +33 -29
- package/src/lib/components/Grid/GridSpan.jsx +11 -10
- package/src/lib/components/Grid/README.mdx +46 -20
- package/src/lib/components/Grid/{helpers → _helpers}/generateResponsiveCustomProperties.js +0 -2
- package/src/lib/components/Grid/_theme.scss +9 -9
- package/src/lib/components/Grid/_tools.scss +20 -20
- package/src/lib/components/Modal/Modal.jsx +38 -32
- package/src/lib/components/Modal/Modal.scss +73 -73
- package/src/lib/components/Modal/README.mdx +2 -5
- package/src/lib/components/Modal/_settings.scss +5 -5
- package/src/lib/components/Modal/_theme.scss +17 -17
- package/src/lib/components/Paper/Paper.jsx +9 -9
- package/src/lib/components/Paper/Paper.scss +8 -8
- package/src/lib/components/Popover/Popover.jsx +94 -0
- package/src/lib/components/Popover/Popover.scss +235 -0
- package/src/lib/components/Popover/PopoverWrapper.jsx +46 -0
- package/src/lib/components/Popover/README.mdx +333 -0
- package/src/lib/components/Popover/_helpers/getRootAlignmentClassName.js +13 -0
- package/src/lib/components/Popover/_helpers/getRootSideClassName.js +17 -0
- package/src/lib/components/Popover/_theme.scss +16 -0
- package/src/lib/components/Popover/index.js +2 -0
- package/src/lib/components/Radio/README.mdx +1 -1
- package/src/lib/components/Radio/Radio.jsx +15 -14
- package/src/lib/components/Radio/Radio.scss +26 -26
- package/src/lib/components/ScrollView/README.mdx +5 -5
- package/src/lib/components/ScrollView/ScrollView.jsx +22 -22
- package/src/lib/components/ScrollView/ScrollView.scss +113 -113
- package/src/lib/{services/elementPositionService.js → components/ScrollView/_helpers/getElementsPositionDifference.js} +0 -2
- package/src/lib/{hooks → components/ScrollView/_hooks}/useLoadResizeHook.js +1 -1
- package/src/lib/{hooks → components/ScrollView/_hooks}/useScrollPositionHook.js +1 -1
- package/src/lib/components/SelectField/README.mdx +1 -1
- package/src/lib/components/SelectField/SelectField.jsx +17 -16
- package/src/lib/components/SelectField/SelectField.scss +30 -30
- package/src/lib/components/Table/README.mdx +1 -1
- package/src/lib/components/Table/Table.jsx +3 -3
- package/src/lib/components/Table/Table.scss +28 -35
- package/src/lib/components/Table/_settings.scss +5 -5
- package/src/lib/components/Tabs/Tabs.jsx +4 -5
- package/src/lib/components/Tabs/Tabs.scss +21 -21
- package/src/lib/components/Tabs/TabsItem.jsx +7 -6
- package/src/lib/components/Tabs/TabsItem.scss +78 -78
- package/src/lib/components/Text/README.mdx +3 -3
- package/src/lib/components/Text/Text.jsx +16 -9
- package/src/lib/components/Text/Text.scss +23 -13
- package/src/lib/components/Text/_helpers/getRootClampClassName.js +11 -0
- package/src/lib/components/Text/{helpers → _helpers}/getRootHyphensClassName.js +1 -1
- package/src/lib/components/Text/{helpers → _helpers}/getRootWordWrappingClassName.js +1 -1
- package/src/lib/components/TextArea/README.mdx +1 -1
- package/src/lib/components/TextArea/TextArea.jsx +21 -17
- package/src/lib/components/TextArea/TextArea.scss +27 -27
- package/src/lib/components/TextField/README.mdx +1 -1
- package/src/lib/components/TextField/TextField.jsx +19 -18
- package/src/lib/components/TextField/TextField.scss +28 -28
- package/src/lib/components/TextLink/README.mdx +77 -0
- package/src/lib/components/TextLink/TextLink.jsx +44 -0
- package/src/lib/components/TextLink/TextLink.scss +11 -0
- package/src/lib/components/TextLink/_theme.scss +4 -0
- package/src/lib/components/TextLink/index.js +1 -0
- package/src/lib/components/Toggle/README.mdx +1 -1
- package/src/lib/components/Toggle/Toggle.jsx +21 -20
- package/src/lib/components/Toggle/Toggle.scss +20 -20
- package/src/lib/components/Toolbar/README.mdx +33 -5
- package/src/lib/components/Toolbar/Toolbar.jsx +33 -17
- package/src/lib/components/Toolbar/Toolbar.scss +29 -42
- package/src/lib/components/Toolbar/ToolbarGroup.jsx +28 -16
- package/src/lib/components/Toolbar/ToolbarItem.jsx +36 -10
- package/src/lib/{helpers → components/_helpers}/getRootColorClassName.js +1 -1
- package/src/lib/{helpers → components/_helpers}/getRootSizeClassName.js +1 -1
- package/src/lib/{helpers → components/_helpers}/getRootValidationStateClassName.js +1 -1
- package/src/lib/components/_helpers/isChildrenEmpty.js +3 -0
- package/src/lib/{helpers → components/_helpers}/resolveContextOrProp.js +0 -0
- package/src/lib/{utils → components/_helpers}/transferProps.js +1 -1
- package/src/lib/foundation.scss +11 -11
- package/src/lib/helpers.scss +2 -2
- package/src/lib/index.js +8 -17
- package/src/lib/provider/index.js +2 -1
- package/src/lib/provider/withGlobalProps.jsx +21 -0
- package/src/lib/styles/_utilities.scss +13 -13
- package/src/lib/styles/elements/_code.scss +7 -7
- package/src/lib/styles/elements/_links.scss +8 -8
- package/src/lib/styles/elements/_lists.scss +3 -3
- package/src/lib/styles/elements/_page.scss +14 -14
- package/src/lib/styles/elements/_rulers.scss +6 -6
- package/src/lib/styles/elements/_small.scss +2 -2
- package/src/lib/styles/generic/_box-sizing.scss +3 -2
- package/src/lib/styles/generic/_forms.scss +3 -3
- package/src/lib/styles/generic/_reset.scss +6 -6
- package/src/lib/styles/generic/_shared.scss +3 -3
- package/src/lib/styles/helpers/_animation.scss +8 -8
- package/src/lib/styles/settings/_breakpoints.scss +7 -7
- package/src/lib/styles/settings/_escaped-characters.scss +5 -5
- package/src/lib/styles/settings/_form-fields.scss +24 -24
- package/src/lib/styles/settings/_utilities.scss +112 -100
- package/src/lib/styles/theme/_colors.scss +50 -50
- package/src/lib/styles/theme/_form-fields.scss +32 -32
- package/src/lib/styles/theme/_spacing.scss +11 -11
- package/src/lib/styles/theme/_typography.scss +12 -11
- package/src/lib/styles/theme-constants/_breakpoints.scss +4 -4
- package/src/lib/styles/theme-constants/_colors.scss +2 -2
- package/src/lib/styles/theme-constants/_svg.scss +1 -2
- package/src/lib/styles/tools/_accessibility.scss +29 -29
- package/src/lib/styles/tools/_breakpoint.scss +11 -14
- package/src/lib/styles/tools/_caret.scss +8 -8
- package/src/lib/styles/tools/_colors.scss +3 -3
- package/src/lib/styles/tools/_reset.scss +24 -21
- package/src/lib/styles/tools/_scrollbar.scss +4 -4
- package/src/lib/styles/tools/_spacing.scss +14 -22
- package/src/lib/styles/tools/_string.scss +9 -9
- package/src/lib/styles/tools/_svg.scss +13 -16
- package/src/lib/styles/tools/_transition.scss +42 -44
- package/src/lib/styles/tools/_utilities.scss +19 -19
- package/src/lib/styles/tools/form-fields/_box-field-elements.scss +88 -88
- package/src/lib/styles/tools/form-fields/_box-field-layout.scss +147 -147
- package/src/lib/styles/tools/form-fields/_box-field-sizes.scss +13 -15
- package/src/lib/styles/tools/form-fields/_foundation.scss +12 -12
- package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +82 -71
- package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +88 -47
- package/src/lib/styles/tools/form-fields/_variants.scss +104 -106
- package/src/lib/theme.scss +959 -954
- package/src/lib/utils/classNames.js +8 -0
- package/src/lib/components/CTA/CTA.jsx +0 -60
- package/src/lib/components/CTA/CTA.scss +0 -71
- package/src/lib/components/CTA/CTACenter.jsx +0 -27
- package/src/lib/components/CTA/CTAEnd.jsx +0 -27
- package/src/lib/components/CTA/CTAStart.jsx +0 -27
- package/src/lib/components/CTA/README.mdx +0 -119
- package/src/lib/components/CTA/index.js +0 -4
- package/src/lib/components/Center/Center.jsx +0 -27
- package/src/lib/components/Center/Center.scss +0 -7
- package/src/lib/components/Center/README.mdx +0 -52
- package/src/lib/components/Center/index.js +0 -1
- package/src/lib/components/Link/Link.jsx +0 -45
- package/src/lib/components/Link/Link.scss +0 -11
- package/src/lib/components/Link/README.mdx +0 -85
- package/src/lib/components/Link/_theme.scss +0 -4
- package/src/lib/components/Link/index.js +0 -1
- package/src/lib/components/List/List.jsx +0 -71
- package/src/lib/components/List/List.scss +0 -53
- package/src/lib/components/List/ListItem.jsx +0 -31
- package/src/lib/components/List/README.mdx +0 -114
- package/src/lib/components/List/_theme.scss +0 -1
- package/src/lib/components/List/index.js +0 -2
- package/src/lib/components/Media/Media.jsx +0 -29
- package/src/lib/components/Media/Media.scss +0 -16
- package/src/lib/components/Media/MediaBody.jsx +0 -21
- package/src/lib/components/Media/MediaObject.jsx +0 -21
- package/src/lib/components/Media/README.mdx +0 -63
- package/src/lib/components/Media/index.js +0 -3
- package/src/lib/provider/withProviderContext.jsx +0 -32
@@ -1,67 +1,67 @@
|
|
1
|
-
@use
|
2
|
-
@use
|
3
|
-
@use
|
4
|
-
@use
|
5
|
-
@use
|
1
|
+
@use "../../styles/tools/form-fields/box-field-elements";
|
2
|
+
@use "../../styles/tools/form-fields/box-field-layout";
|
3
|
+
@use "../../styles/tools/form-fields/foundation";
|
4
|
+
@use "../../styles/tools/form-fields/variants";
|
5
|
+
@use "../../styles/tools/accessibility";
|
6
6
|
|
7
7
|
// Foundation
|
8
8
|
.root {
|
9
|
-
|
9
|
+
@include foundation.root();
|
10
10
|
}
|
11
11
|
|
12
12
|
.label {
|
13
|
-
|
13
|
+
@include foundation.label();
|
14
14
|
}
|
15
15
|
|
16
16
|
.inputContainer {
|
17
|
-
|
17
|
+
@include box-field-elements.input-container();
|
18
18
|
}
|
19
19
|
|
20
20
|
.input {
|
21
|
-
|
21
|
+
@include accessibility.focus-ring();
|
22
22
|
}
|
23
23
|
|
24
24
|
.helpText,
|
25
25
|
.validationText {
|
26
|
-
|
26
|
+
@include foundation.help-text();
|
27
27
|
}
|
28
28
|
|
29
29
|
.isRootRequired .label {
|
30
|
-
|
30
|
+
@include foundation.label-required();
|
31
31
|
}
|
32
32
|
|
33
33
|
// States
|
34
34
|
.isRootStateInvalid {
|
35
|
-
|
35
|
+
@include variants.validation(invalid);
|
36
36
|
}
|
37
37
|
|
38
38
|
.isRootStateValid {
|
39
|
-
|
39
|
+
@include variants.validation(valid);
|
40
40
|
}
|
41
41
|
|
42
42
|
.isRootStateWarning {
|
43
|
-
|
43
|
+
@include variants.validation(warning);
|
44
44
|
}
|
45
45
|
|
46
46
|
// Invisible label
|
47
47
|
.isLabelHidden {
|
48
|
-
|
48
|
+
@include accessibility.hide-text();
|
49
49
|
}
|
50
50
|
|
51
51
|
// Layouts
|
52
52
|
.rootLayoutVertical,
|
53
53
|
.rootLayoutHorizontal {
|
54
|
-
|
54
|
+
@include box-field-layout.vertical();
|
55
55
|
}
|
56
56
|
|
57
57
|
.rootLayoutHorizontal {
|
58
|
-
|
58
|
+
@include box-field-layout.horizontal();
|
59
59
|
}
|
60
60
|
|
61
61
|
.isRootFullWidth {
|
62
|
-
|
62
|
+
@include box-field-layout.full-width();
|
63
63
|
}
|
64
64
|
|
65
65
|
.isRootInFormLayout {
|
66
|
-
|
66
|
+
@include box-field-layout.in-form-layout();
|
67
67
|
}
|
@@ -191,7 +191,7 @@ It's possible to disable the whole input.
|
|
191
191
|
|
192
192
|
In addition to the options below, you can specify [React synthetic events] or
|
193
193
|
any custom HTML attributes that do not interfere with the API, and they will be
|
194
|
-
passed to the
|
194
|
+
passed to the `<input>` HTML element. This enables making the component
|
195
195
|
interactive and helps improve its [accessibility](#forwarding-html-attributes).
|
196
196
|
|
197
197
|
<Props table of={FileInputField} />
|
@@ -1,21 +1,21 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import {
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
|
+
import { classNames } from '../../utils/classNames';
|
5
|
+
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
|
4
6
|
import { FormLayoutContext } from './FormLayoutContext';
|
5
7
|
import styles from './FormLayout.scss';
|
6
8
|
|
7
9
|
const PREDEFINED_LABEL_WIDTH_VALUES = ['auto', 'default', 'limited'];
|
8
10
|
|
9
|
-
export const FormLayout = (
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
if (!children) {
|
11
|
+
export const FormLayout = ({
|
12
|
+
autoWidth,
|
13
|
+
children,
|
14
|
+
fieldLayout,
|
15
|
+
id,
|
16
|
+
labelWidth,
|
17
|
+
}) => {
|
18
|
+
if (isChildrenEmpty(children)) {
|
19
19
|
return null;
|
20
20
|
}
|
21
21
|
|
@@ -48,12 +48,12 @@ export const FormLayout = (props) => {
|
|
48
48
|
return (
|
49
49
|
<div
|
50
50
|
id={id}
|
51
|
-
className={
|
51
|
+
className={classNames(
|
52
52
|
styles.root,
|
53
53
|
fieldLayoutClass(fieldLayout),
|
54
|
-
autoWidth
|
55
|
-
fieldLayout === 'horizontal'
|
56
|
-
|
54
|
+
autoWidth && styles.isRootAutoWidth,
|
55
|
+
fieldLayout === 'horizontal' && labelWidthClass(labelWidth),
|
56
|
+
)}
|
57
57
|
{...hasCustomLabelWidth ? { style: { '--rui-custom-label-width': labelWidth } } : {}}
|
58
58
|
>
|
59
59
|
<FormLayoutContext.Provider
|
@@ -88,6 +88,8 @@ FormLayout.propTypes = {
|
|
88
88
|
* * `TextArea`
|
89
89
|
* * `TextField`
|
90
90
|
* * `Toggle`
|
91
|
+
*
|
92
|
+
* If none are provided nothing is rendered.
|
91
93
|
*/
|
92
94
|
children: PropTypes.node,
|
93
95
|
/**
|
@@ -108,6 +110,6 @@ FormLayout.propTypes = {
|
|
108
110
|
]),
|
109
111
|
};
|
110
112
|
|
111
|
-
export const
|
113
|
+
export const FormLayoutWithGlobalProps = withGlobalProps(FormLayout, 'FormLayout');
|
112
114
|
|
113
|
-
export default
|
115
|
+
export default FormLayoutWithGlobalProps;
|
@@ -13,46 +13,46 @@
|
|
13
13
|
// (a global default which can be customised per use).
|
14
14
|
// https://github.com/react-ui-org/react-ui/issues/232
|
15
15
|
|
16
|
-
@use
|
17
|
-
@use
|
18
|
-
@use
|
19
|
-
@use
|
16
|
+
@use "../../styles/settings/forms";
|
17
|
+
@use "../../styles/tools/breakpoint";
|
18
|
+
@use "../../styles/tools/spacing";
|
19
|
+
@use "theme";
|
20
20
|
|
21
21
|
.root {
|
22
|
-
|
22
|
+
--rui-local-field-width: 1fr;
|
23
23
|
|
24
|
-
|
24
|
+
@include spacing.bottom(layouts);
|
25
25
|
}
|
26
26
|
|
27
27
|
.rootFieldLayoutVertical,
|
28
28
|
.rootFieldLayoutHorizontal {
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
display: grid;
|
30
|
+
grid-template-columns: var(--rui-local-field-width);
|
31
|
+
grid-row-gap: theme.$row-gap;
|
32
32
|
}
|
33
33
|
|
34
34
|
.rootFieldLayoutHorizontal {
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
@include breakpoint.up(forms.$horizontal-breakpoint) {
|
36
|
+
grid-template-columns: var(--rui-local-label-width) var(--rui-local-field-width); // 1.
|
37
|
+
}
|
38
38
|
}
|
39
39
|
|
40
40
|
.hasRootLabelWidthDefault {
|
41
|
-
|
41
|
+
--rui-local-label-width: #{theme.$horizontal-label-width}; // 1., 2.
|
42
42
|
}
|
43
43
|
|
44
44
|
.hasRootLabelWidthAuto {
|
45
|
-
|
45
|
+
--rui-local-label-width: #{theme.$horizontal-label-width-auto}; // 4.
|
46
46
|
}
|
47
47
|
|
48
48
|
.hasRootLabelWidthLimited {
|
49
|
-
|
49
|
+
--rui-local-label-width: #{theme.$horizontal-label-width-limited}; // 4.
|
50
50
|
}
|
51
51
|
|
52
52
|
.hasRootLabelWidthCustom {
|
53
|
-
|
53
|
+
--rui-local-label-width: var(--rui-custom-label-width); // 3.
|
54
54
|
}
|
55
55
|
|
56
56
|
.isRootAutoWidth {
|
57
|
-
|
57
|
+
--rui-local-field-width: min-content;
|
58
58
|
}
|
@@ -1,10 +1,12 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React, { useContext } from 'react';
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import {
|
6
|
-
import
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
|
+
import { classNames } from '../../utils/classNames';
|
5
|
+
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
6
|
+
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
|
7
|
+
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
|
7
8
|
import { FormLayoutContext } from './FormLayoutContext';
|
9
|
+
import styles from './FormLayoutCustomField.scss';
|
8
10
|
|
9
11
|
const renderLabel = (id, label, labelForId) => {
|
10
12
|
if (labelForId && label) {
|
@@ -46,18 +48,22 @@ export const FormLayoutCustomField = ({
|
|
46
48
|
}) => {
|
47
49
|
const context = useContext(FormLayoutContext);
|
48
50
|
|
51
|
+
if (isChildrenEmpty(children)) {
|
52
|
+
return null;
|
53
|
+
}
|
54
|
+
|
49
55
|
return (
|
50
56
|
<div
|
51
57
|
id={id}
|
52
|
-
className={
|
58
|
+
className={classNames(
|
53
59
|
styles.root,
|
54
|
-
fullWidth
|
60
|
+
fullWidth && styles.isRootFullWidth,
|
55
61
|
context && context.layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
|
56
|
-
disabled
|
57
|
-
required
|
62
|
+
disabled && styles.isRootDisabled,
|
63
|
+
required && styles.isRootRequired,
|
58
64
|
getRootSizeClassName(innerFieldSize, styles),
|
59
65
|
getRootValidationStateClassName(validationState, styles),
|
60
|
-
|
66
|
+
)}
|
61
67
|
>
|
62
68
|
{renderLabel(id, label, labelForId)}
|
63
69
|
<div
|
@@ -84,7 +90,7 @@ FormLayoutCustomField.defaultProps = {
|
|
84
90
|
|
85
91
|
FormLayoutCustomField.propTypes = {
|
86
92
|
/**
|
87
|
-
* Custom HTML or React component(s).
|
93
|
+
* Custom HTML or React component(s). If none are provided nothing is rendered.
|
88
94
|
*/
|
89
95
|
children: PropTypes.node,
|
90
96
|
/**
|
@@ -125,6 +131,6 @@ FormLayoutCustomField.propTypes = {
|
|
125
131
|
validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
|
126
132
|
};
|
127
133
|
|
128
|
-
export const
|
134
|
+
export const FormLayoutCustomFieldWithGlobalProps = withGlobalProps(FormLayoutCustomField, 'FormLayoutCustomField');
|
129
135
|
|
130
|
-
export default
|
136
|
+
export default FormLayoutCustomFieldWithGlobalProps;
|
@@ -1,63 +1,63 @@
|
|
1
|
-
@use
|
2
|
-
@use
|
3
|
-
@use
|
4
|
-
@use
|
1
|
+
@use "../../styles/tools/form-fields/foundation";
|
2
|
+
@use "../../styles/tools/form-fields/box-field-layout";
|
3
|
+
@use "../../styles/tools/form-fields/box-field-sizes";
|
4
|
+
@use "../../styles/tools/form-fields/variants";
|
5
5
|
|
6
6
|
// Foundation
|
7
7
|
.root {
|
8
|
-
|
9
|
-
|
8
|
+
@include box-field-layout.in-form-layout();
|
9
|
+
@include variants.visual(custom);
|
10
10
|
}
|
11
11
|
|
12
12
|
.label {
|
13
|
-
|
13
|
+
@include foundation.label();
|
14
14
|
}
|
15
15
|
|
16
16
|
.isRootRequired .label {
|
17
|
-
|
17
|
+
@include foundation.label-required();
|
18
18
|
}
|
19
19
|
|
20
20
|
// States
|
21
21
|
.isRootStateInvalid {
|
22
|
-
|
22
|
+
@include variants.validation(invalid);
|
23
23
|
}
|
24
24
|
|
25
25
|
.isRootStateValid {
|
26
|
-
|
26
|
+
@include variants.validation(valid);
|
27
27
|
}
|
28
28
|
|
29
29
|
.isRootStateWarning {
|
30
|
-
|
30
|
+
@include variants.validation(warning);
|
31
31
|
}
|
32
32
|
|
33
33
|
// Layouts
|
34
34
|
.rootLayoutVertical,
|
35
35
|
.rootLayoutHorizontal {
|
36
|
-
|
36
|
+
@include box-field-layout.vertical();
|
37
37
|
}
|
38
38
|
|
39
39
|
.rootLayoutHorizontal {
|
40
|
-
|
40
|
+
@include box-field-layout.horizontal();
|
41
41
|
}
|
42
42
|
|
43
43
|
.rootLayoutVertical .field,
|
44
44
|
.rootLayoutHorizontal .field {
|
45
|
-
|
45
|
+
width: auto;
|
46
46
|
}
|
47
47
|
|
48
48
|
.isRootFullWidth .field {
|
49
|
-
|
49
|
+
justify-self: stretch;
|
50
50
|
}
|
51
51
|
|
52
52
|
// Sizes
|
53
53
|
.rootSizeSmall {
|
54
|
-
|
54
|
+
@include box-field-sizes.size(small);
|
55
55
|
}
|
56
56
|
|
57
57
|
.rootSizeMedium {
|
58
|
-
|
58
|
+
@include box-field-sizes.size(medium);
|
59
59
|
}
|
60
60
|
|
61
61
|
.rootSizeLarge {
|
62
|
-
|
62
|
+
@include box-field-sizes.size(large);
|
63
63
|
}
|
@@ -22,7 +22,6 @@ import { SelectField } from '../SelectField/SelectField'
|
|
22
22
|
import { TextArea } from '../TextArea/TextArea'
|
23
23
|
import { TextField } from '../TextField/TextField'
|
24
24
|
import { Toggle } from '../Toggle/Toggle'
|
25
|
-
import { Center } from '../Center/Center'
|
26
25
|
import { Toolbar } from '../Toolbar/Toolbar'
|
27
26
|
import { ToolbarItem } from '../Toolbar/ToolbarItem'
|
28
27
|
import { FormLayout } from './FormLayout'
|
@@ -51,13 +50,11 @@ See [API](#api) for all available options.
|
|
51
50
|
Since all form fields in React UI are styled as inline blocks, they **queue up
|
52
51
|
one after another in a row by default.** The FormLayout component is there to
|
53
52
|
make building **vertical and horizontal forms** easy. It uses the right tool for
|
54
|
-
the job: the
|
55
|
-
[CSS grid layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout).
|
53
|
+
the job: the [CSS grid layout][grid].
|
56
54
|
|
57
55
|
- Put **only form field components** from React UI inside the FormLayout and
|
58
|
-
make sure they are **direct descendants** of it (React
|
59
|
-
|
60
|
-
are supported!). All React UI form components are ready for this use case and
|
56
|
+
make sure they are **direct descendants** of it (React [fragments] are
|
57
|
+
supported!). All React UI form components are ready for this use case and
|
61
58
|
don't need to be wrapped in any `div`s. Namely, the FormLayout supports the
|
62
59
|
following React UI components:
|
63
60
|
[CheckboxField](/components/checkbox-field),
|
@@ -73,17 +70,14 @@ the job: the
|
|
73
70
|
|
74
71
|
👉 For usage in auto-width Modal, you may need to turn on the `autoWidth` option
|
75
72
|
for your FormLayout. This prevents FormLayout from unexpectedly growing in
|
76
|
-
browsers that
|
77
|
-
|
78
|
-
[CSS subgrid](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Subgrid)
|
79
|
-
in cases when there are longer validation messages or help texts.
|
73
|
+
browsers that [don't support][rui-232] [CSS subgrid][subgrid] in cases when
|
74
|
+
there are longer validation messages or help texts.
|
80
75
|
|
81
76
|
## Vertical Layout
|
82
77
|
|
83
|
-
Vertical FormLayout works similar to
|
84
|
-
|
85
|
-
|
86
|
-
simply wrap your form fields with the FormLayout component:
|
78
|
+
Vertical FormLayout works similar to single-column [Grid](/components/grid)
|
79
|
+
layout while it also forces vertical layout mode on form fields. To use this
|
80
|
+
layout, simply wrap your form fields with the FormLayout component:
|
87
81
|
|
88
82
|
<Playground>
|
89
83
|
<FormLayout>
|
@@ -148,7 +142,7 @@ with CSS custom properties.
|
|
148
142
|
<span id="label-width-options-label">Label width:</span>
|
149
143
|
</ToolbarItem>
|
150
144
|
<ToolbarItem>
|
151
|
-
<ButtonGroup aria-labelledby="
|
145
|
+
<ButtonGroup aria-labelledby="label-width-options-label">
|
152
146
|
<Button
|
153
147
|
color={labelWidth === 'default' ? 'dark' : 'primary'}
|
154
148
|
label="default"
|
@@ -205,41 +199,18 @@ with CSS custom properties.
|
|
205
199
|
|
206
200
|
### Limitations
|
207
201
|
|
202
|
+
#### Label Position
|
203
|
+
|
204
|
+
Label position of inline form fields (CheckboxField, Toggle) is ignored in
|
205
|
+
horizontal FormLayout.
|
206
|
+
|
208
207
|
#### Modals
|
209
208
|
|
210
209
|
Please note the `auto` and `limited` label width options may not function
|
211
210
|
correctly in combination with other auto layout mechanisms, e.g. the auto-width
|
212
|
-
[Modal](/components/modal). It's just too much of magic that
|
211
|
+
[Modal](/components/modal). It's just too much of magic that does not quite
|
213
212
|
work together yet 🎩.
|
214
213
|
|
215
|
-
#### Inline Form Fields
|
216
|
-
|
217
|
-
CheckboxField and Toggle always display their labels after inputs inside
|
218
|
-
FormLayout. In other words, their labels never appear in a column with other
|
219
|
-
fields' labels even when they have `labelPosition` set to `before`. This feature
|
220
|
-
[will be implemented](https://github.com/react-ui-org/react-ui/issues/232)
|
221
|
-
once
|
222
|
-
[CSS subgrid](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Subgrid)
|
223
|
-
is fully supported in
|
224
|
-
[browsers that we support](/getting-started/browsers-and-devices).
|
225
|
-
|
226
|
-
## Alignment
|
227
|
-
|
228
|
-
To align whole FormLayout to center of a container, simply wrap it with the
|
229
|
-
[Center](/components/center) layout.
|
230
|
-
|
231
|
-
<Playground>
|
232
|
-
<Placeholder bordered height="24rem">
|
233
|
-
<Center>
|
234
|
-
<FormLayout autoWidth>
|
235
|
-
<TextField label="A form element" />
|
236
|
-
<TextField label="Another form element" />
|
237
|
-
<TextField label="Yet another one" />
|
238
|
-
</FormLayout>
|
239
|
-
</Center>
|
240
|
-
</Placeholder>
|
241
|
-
</Playground>
|
242
|
-
|
243
214
|
## Custom Fields
|
244
215
|
|
245
216
|
You can even place any content you need into the FormLayout — just wrap it with
|
@@ -267,11 +238,10 @@ as API options as such are **not** inherited.
|
|
267
238
|
|
268
239
|
If you are in a situation with one or more box form fields inside your
|
269
240
|
FormLayoutCustomField, you may want to have its label aligned with the fields
|
270
|
-
inside. Since it's
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
for this task.
|
241
|
+
inside. Since it's [not quite possible to do this automatically][rui-265] due to
|
242
|
+
limited browser support, there is `innerFieldSize` option which accepts any of
|
243
|
+
existing box field sizes (small, medium, or large) and is intended right for
|
244
|
+
this task.
|
275
245
|
|
276
246
|
<Playground>
|
277
247
|
<FormLayout fieldLayout="horizontal" labelWidth="auto">
|
@@ -428,6 +398,7 @@ This is a demo of all components supported by FormLayout.
|
|
428
398
|
</FormLayoutCustomField>
|
429
399
|
<CheckboxField
|
430
400
|
checked={isDeliveryAddress}
|
401
|
+
helpText="Uncheck if you wish to deliver to a different address."
|
431
402
|
label="This is my delivery address"
|
432
403
|
onChange={() => setIsDeliveryAddress(!isDeliveryAddress)}
|
433
404
|
/>
|
@@ -493,3 +464,9 @@ FormLayoutCustomField can be styled using a small subset of
|
|
493
464
|
|------------------------------------------------------|--------------------------------------------------------------|
|
494
465
|
| `--rui-FormField--custom--default__surrounding-text-color` | Custom field label color in default state |
|
495
466
|
| `--rui-FormField--custom--disabled__surrounding-text-color` | Custom field label color in disabled-like state |
|
467
|
+
|
468
|
+
[grid]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
|
469
|
+
[subgrid]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Subgrid
|
470
|
+
[fragments]: https://reactjs.org/docs/fragments.html
|
471
|
+
[rui-232]: https://github.com/react-ui-org/react-ui/issues/232
|
472
|
+
[rui-265]: https://github.com/react-ui-org/react-ui/issues/265
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
|
+
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
|
5
|
+
import { generateResponsiveCustomProperties } from './_helpers/generateResponsiveCustomProperties';
|
5
6
|
import styles from './Grid.scss';
|
6
7
|
|
7
8
|
export const Grid = ({
|
@@ -19,7 +20,7 @@ export const Grid = ({
|
|
19
20
|
tag: Tag,
|
20
21
|
...other
|
21
22
|
}) => {
|
22
|
-
if (
|
23
|
+
if (isChildrenEmpty(children)) {
|
23
24
|
return null;
|
24
25
|
}
|
25
26
|
|
@@ -76,8 +77,8 @@ Grid.propTypes = {
|
|
76
77
|
md: PropTypes.string,
|
77
78
|
lg: PropTypes.string,
|
78
79
|
xl: PropTypes.string,
|
79
|
-
|
80
|
-
|
80
|
+
x2l: PropTypes.string,
|
81
|
+
x3l: PropTypes.string,
|
81
82
|
}),
|
82
83
|
]),
|
83
84
|
/**
|
@@ -92,8 +93,8 @@ Grid.propTypes = {
|
|
92
93
|
md: PropTypes.string,
|
93
94
|
lg: PropTypes.string,
|
94
95
|
xl: PropTypes.string,
|
95
|
-
|
96
|
-
|
96
|
+
x2l: PropTypes.string,
|
97
|
+
x3l: PropTypes.string,
|
97
98
|
}),
|
98
99
|
]),
|
99
100
|
/**
|
@@ -108,12 +109,12 @@ Grid.propTypes = {
|
|
108
109
|
md: PropTypes.string,
|
109
110
|
lg: PropTypes.string,
|
110
111
|
xl: PropTypes.string,
|
111
|
-
|
112
|
-
|
112
|
+
x2l: PropTypes.string,
|
113
|
+
x3l: PropTypes.string,
|
113
114
|
}),
|
114
115
|
]),
|
115
116
|
/**
|
116
|
-
* Items to be aligned in the grid.
|
117
|
+
* Items to be aligned in the grid. If none are provided nothing is rendered.
|
117
118
|
*/
|
118
119
|
children: PropTypes.node,
|
119
120
|
/**
|
@@ -128,8 +129,8 @@ Grid.propTypes = {
|
|
128
129
|
md: PropTypes.string,
|
129
130
|
lg: PropTypes.string,
|
130
131
|
xl: PropTypes.string,
|
131
|
-
|
132
|
-
|
132
|
+
x2l: PropTypes.string,
|
133
|
+
x3l: PropTypes.string,
|
133
134
|
}),
|
134
135
|
]),
|
135
136
|
/**
|
@@ -144,8 +145,8 @@ Grid.propTypes = {
|
|
144
145
|
md: PropTypes.string,
|
145
146
|
lg: PropTypes.string,
|
146
147
|
xl: PropTypes.string,
|
147
|
-
|
148
|
-
|
148
|
+
x2l: PropTypes.string,
|
149
|
+
x3l: PropTypes.string,
|
149
150
|
}),
|
150
151
|
]),
|
151
152
|
/**
|
@@ -164,8 +165,8 @@ Grid.propTypes = {
|
|
164
165
|
md: PropTypes.string,
|
165
166
|
lg: PropTypes.string,
|
166
167
|
xl: PropTypes.string,
|
167
|
-
|
168
|
-
|
168
|
+
x2l: PropTypes.string,
|
169
|
+
x3l: PropTypes.string,
|
169
170
|
}),
|
170
171
|
]),
|
171
172
|
/**
|
@@ -180,8 +181,8 @@ Grid.propTypes = {
|
|
180
181
|
md: PropTypes.string,
|
181
182
|
lg: PropTypes.string,
|
182
183
|
xl: PropTypes.string,
|
183
|
-
|
184
|
-
|
184
|
+
x2l: PropTypes.string,
|
185
|
+
x3l: PropTypes.string,
|
185
186
|
}),
|
186
187
|
]),
|
187
188
|
/**
|
@@ -196,8 +197,8 @@ Grid.propTypes = {
|
|
196
197
|
md: PropTypes.string,
|
197
198
|
lg: PropTypes.string,
|
198
199
|
xl: PropTypes.string,
|
199
|
-
|
200
|
-
|
200
|
+
x2l: PropTypes.string,
|
201
|
+
x3l: PropTypes.string,
|
201
202
|
}),
|
202
203
|
]),
|
203
204
|
/**
|
@@ -212,8 +213,8 @@ Grid.propTypes = {
|
|
212
213
|
md: PropTypes.string,
|
213
214
|
lg: PropTypes.string,
|
214
215
|
xl: PropTypes.string,
|
215
|
-
|
216
|
-
|
216
|
+
x2l: PropTypes.string,
|
217
|
+
x3l: PropTypes.string,
|
217
218
|
}),
|
218
219
|
]),
|
219
220
|
/**
|
@@ -223,6 +224,6 @@ Grid.propTypes = {
|
|
223
224
|
tag: PropTypes.string,
|
224
225
|
};
|
225
226
|
|
226
|
-
export const
|
227
|
+
export const GridWithGlobalProps = withGlobalProps(Grid, 'Grid');
|
227
228
|
|
228
|
-
export default
|
229
|
+
export default GridWithGlobalProps;
|