@react-ui-org/react-ui 0.44.0 → 0.46.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CONTRIBUTING.md +7 -0
- package/dist/lib.development.js +209 -305
- package/dist/lib.js +1 -1
- package/package.json +10 -13
- package/src/lib/components/Alert/Alert.jsx +4 -3
- package/src/lib/components/Alert/Alert.scss +48 -48
- 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 +6 -8
- package/src/lib/components/Badge/Badge.scss +57 -57
- package/src/lib/components/Button/Button.jsx +10 -9
- package/src/lib/components/Button/Button.scss +2 -2
- package/src/lib/components/Button/README.mdx +8 -3
- package/src/lib/components/Button/_base.scss +65 -65
- 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/ButtonGroup/ButtonGroup.jsx +31 -22
- package/src/lib/components/ButtonGroup/ButtonGroup.scss +3 -3
- package/src/lib/components/ButtonGroup/README.mdx +4 -4
- package/src/lib/components/Card/Card.jsx +7 -6
- package/src/lib/components/Card/Card.scss +28 -28
- package/src/lib/components/Card/CardBody.jsx +5 -11
- package/src/lib/components/Card/CardFooter.jsx +10 -5
- package/src/lib/components/Card/README.mdx +2 -2
- 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 +18 -17
- package/src/lib/components/CheckboxField/CheckboxField.scss +20 -20
- package/src/lib/components/CheckboxField/README.mdx +3 -3
- package/src/lib/components/FileInputField/FileInputField.jsx +13 -12
- 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 +16 -14
- package/src/lib/components/FormLayout/FormLayout.scss +17 -17
- package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +15 -9
- package/src/lib/components/FormLayout/FormLayoutCustomField.scss +18 -18
- package/src/lib/components/FormLayout/README.mdx +27 -49
- package/src/lib/components/Grid/Grid.jsx +4 -3
- package/src/lib/components/Grid/Grid.scss +32 -23
- package/src/lib/components/Grid/GridSpan.jsx +4 -3
- 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/List/List.jsx +14 -12
- package/src/lib/components/List/List.scss +21 -21
- package/src/lib/components/List/ListItem.jsx +3 -2
- package/src/lib/components/List/README.mdx +1 -1
- package/src/lib/components/Media/Media.jsx +12 -5
- package/src/lib/components/Media/Media.scss +6 -6
- package/src/lib/components/Media/MediaBody.jsx +18 -7
- package/src/lib/components/Media/MediaObject.jsx +18 -7
- package/src/lib/components/Modal/Modal.jsx +8 -6
- package/src/lib/components/Modal/Modal.scss +73 -73
- package/src/lib/components/Modal/README.mdx +2 -2
- 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 +6 -6
- package/src/lib/components/Paper/Paper.scss +8 -8
- package/src/lib/components/Paper/README.mdx +1 -1
- package/src/lib/components/Radio/README.mdx +4 -4
- package/src/lib/components/Radio/Radio.jsx +12 -11
- package/src/lib/components/Radio/Radio.scss +26 -26
- package/src/lib/components/ScrollView/README.mdx +4 -1
- package/src/lib/components/ScrollView/ScrollView.jsx +11 -9
- 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 +4 -4
- package/src/lib/components/SelectField/SelectField.jsx +14 -13
- package/src/lib/components/SelectField/SelectField.scss +30 -30
- package/src/lib/components/Table/README.mdx +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/README.mdx +1 -1
- package/src/lib/components/Tabs/Tabs.jsx +1 -2
- package/src/lib/components/Tabs/Tabs.scss +21 -21
- package/src/lib/components/Tabs/TabsItem.jsx +4 -3
- package/src/lib/components/Tabs/TabsItem.scss +78 -78
- package/src/lib/components/Text/README.mdx +1 -1
- package/src/lib/components/Text/Text.jsx +13 -6
- 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 +18 -14
- 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 +16 -14
- package/src/lib/components/TextField/TextField.scss +28 -28
- package/src/lib/components/TextLink/README.mdx +77 -0
- package/src/lib/components/{Link/Link.jsx → TextLink/TextLink.jsx} +12 -13
- 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 +3 -3
- package/src/lib/components/Toggle/Toggle.jsx +18 -17
- package/src/lib/components/Toggle/Toggle.scss +20 -20
- package/src/lib/components/Toolbar/README.mdx +19 -3
- package/src/lib/components/Toolbar/Toolbar.jsx +23 -14
- package/src/lib/components/Toolbar/Toolbar.scss +35 -30
- package/src/lib/components/Toolbar/ToolbarGroup.jsx +18 -13
- package/src/lib/components/Toolbar/ToolbarItem.jsx +26 -7
- 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 +4 -8
- 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 +2 -2
- 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 +17 -21
- 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 +958 -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.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
@@ -9,54 +9,54 @@ $disabled-background-color: var(--rui-Card--disabled__background-color);
|
|
9
9
|
$disabled-opacity: var(--rui-Card--disabled__opacity);
|
10
10
|
|
11
11
|
$colors: (
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
12
|
+
primary: (
|
13
|
+
color: var(--rui-Card--primary__color),
|
14
|
+
border-color: var(--rui-Card--primary__border-color),
|
15
|
+
background-color: var(--rui-Card--primary__background-color),
|
16
|
+
),
|
17
|
+
secondary: (
|
18
|
+
color: var(--rui-Card--secondary__color),
|
19
|
+
border-color: var(--rui-Card--secondary__border-color),
|
20
|
+
background-color: var(--rui-Card--secondary__background-color),
|
21
|
+
),
|
22
|
+
success: (
|
23
|
+
color: var(--rui-Card--success__color),
|
24
|
+
border-color: var(--rui-Card--success__border-color),
|
25
|
+
background-color: var(--rui-Card--success__background-color),
|
26
|
+
),
|
27
|
+
warning: (
|
28
|
+
color: var(--rui-Card--warning__color),
|
29
|
+
border-color: var(--rui-Card--warning__border-color),
|
30
|
+
background-color: var(--rui-Card--warning__background-color),
|
31
|
+
),
|
32
|
+
danger: (
|
33
|
+
color: var(--rui-Card--danger__color),
|
34
|
+
border-color: var(--rui-Card--danger__border-color),
|
35
|
+
background-color: var(--rui-Card--danger__background-color),
|
36
|
+
),
|
37
|
+
info: (
|
38
|
+
color: var(--rui-Card--info__color),
|
39
|
+
border-color: var(--rui-Card--info__border-color),
|
40
|
+
background-color: var(--rui-Card--info__background-color),
|
41
|
+
),
|
42
|
+
help: (
|
43
|
+
color: var(--rui-Card--help__color),
|
44
|
+
border-color: var(--rui-Card--help__border-color),
|
45
|
+
background-color: var(--rui-Card--help__background-color),
|
46
|
+
),
|
47
|
+
note: (
|
48
|
+
color: var(--rui-Card--note__color),
|
49
|
+
border-color: var(--rui-Card--note__border-color),
|
50
|
+
background-color: var(--rui-Card--note__background-color),
|
51
|
+
),
|
52
|
+
light: (
|
53
|
+
color: var(--rui-Card--light__color),
|
54
|
+
border-color: var(--rui-Card--light__border-color),
|
55
|
+
background-color: var(--rui-Card--light__background-color),
|
56
|
+
),
|
57
|
+
dark: (
|
58
|
+
color: var(--rui-Card--dark__color),
|
59
|
+
border-color: var(--rui-Card--dark__border-color),
|
60
|
+
background-color: var(--rui-Card--dark__background-color),
|
61
|
+
),
|
62
62
|
);
|
@@ -1,10 +1,10 @@
|
|
1
|
-
@use
|
2
|
-
@use
|
1
|
+
@use "sass:map";
|
2
|
+
@use "theme";
|
3
3
|
|
4
4
|
@mixin color($color) {
|
5
|
-
|
5
|
+
$color-variant-properties: map.get(theme.$colors, $color);
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
--rui-local-color: #{map.get($color-variant-properties, color)};
|
8
|
+
--rui-local-border-color: #{map.get($color-variant-properties, border-color)};
|
9
|
+
--rui-local-background-color: #{map.get($color-variant-properties, background-color)};
|
10
10
|
}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React, { useContext } from 'react';
|
3
|
-
import getRootValidationStateClassName from '../../helpers/getRootValidationStateClassName';
|
4
3
|
import { withProviderContext } from '../../provider';
|
5
|
-
import
|
4
|
+
import { classNames } from '../../utils/classNames';
|
5
|
+
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
|
6
|
+
import { transferProps } from '../_helpers/transferProps';
|
6
7
|
import { FormLayoutContext } from '../FormLayout';
|
7
8
|
import withForwardedRef from '../withForwardedRef';
|
8
9
|
import styles from './CheckboxField.scss';
|
@@ -26,19 +27,28 @@ export const CheckboxField = ({
|
|
26
27
|
|
27
28
|
return (
|
28
29
|
<label
|
29
|
-
className={
|
30
|
+
className={classNames(
|
30
31
|
styles.root,
|
31
|
-
context
|
32
|
+
context && styles.isRootInFormLayout,
|
32
33
|
context && context.layout === 'horizontal' ? styles.rootLayoutHorizontal : styles.rootLayoutVertical,
|
33
|
-
labelPosition === 'before'
|
34
|
-
disabled
|
35
|
-
required
|
34
|
+
labelPosition === 'before' && styles.hasRootLabelBefore,
|
35
|
+
disabled && styles.isRootDisabled,
|
36
|
+
required && styles.isRootRequired,
|
36
37
|
getRootValidationStateClassName(validationState, styles),
|
37
|
-
|
38
|
+
)}
|
38
39
|
htmlFor={id}
|
39
40
|
id={id && `${id}__label`}
|
40
41
|
>
|
41
42
|
<div className={styles.field}>
|
43
|
+
<div
|
44
|
+
className={classNames(
|
45
|
+
styles.label,
|
46
|
+
!isLabelVisible && styles.isLabelHidden,
|
47
|
+
)}
|
48
|
+
id={id && `${id}__labelText`}
|
49
|
+
>
|
50
|
+
{label}
|
51
|
+
</div>
|
42
52
|
<input
|
43
53
|
{...transferProps(restProps)}
|
44
54
|
checked={checked}
|
@@ -50,15 +60,6 @@ export const CheckboxField = ({
|
|
50
60
|
type="checkbox"
|
51
61
|
value={value}
|
52
62
|
/>
|
53
|
-
<div
|
54
|
-
className={[
|
55
|
-
styles.label,
|
56
|
-
isLabelVisible ? '' : styles.isLabelHidden,
|
57
|
-
].join(' ')}
|
58
|
-
id={id && `${id}__labelText`}
|
59
|
-
>
|
60
|
-
{label}
|
61
|
-
</div>
|
62
63
|
</div>
|
63
64
|
{helpText && (
|
64
65
|
<div
|
@@ -1,61 +1,61 @@
|
|
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 {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
@include foundation.root();
|
10
|
+
@include inline-field-layout.root();
|
11
|
+
@include inline-field-elements.min-tap-target($type: checkbox);
|
12
|
+
@include variants.visual(check);
|
13
13
|
}
|
14
14
|
|
15
15
|
.label {
|
16
|
-
|
16
|
+
@include foundation.label();
|
17
17
|
}
|
18
18
|
|
19
19
|
.field {
|
20
|
-
|
20
|
+
@include inline-field-layout.field($type: checkbox);
|
21
21
|
}
|
22
22
|
|
23
23
|
.input {
|
24
|
-
|
24
|
+
@include inline-field-elements.check-input($type: checkbox);
|
25
25
|
}
|
26
26
|
|
27
27
|
.helpText,
|
28
28
|
.validationText {
|
29
|
-
|
29
|
+
@include foundation.help-text();
|
30
30
|
}
|
31
31
|
|
32
32
|
.isRootRequired .label {
|
33
|
-
|
33
|
+
@include foundation.label-required();
|
34
34
|
}
|
35
35
|
|
36
36
|
// States
|
37
37
|
.isRootStateInvalid {
|
38
|
-
|
38
|
+
@include variants.validation(invalid);
|
39
39
|
}
|
40
40
|
|
41
41
|
.isRootStateValid {
|
42
|
-
|
42
|
+
@include variants.validation(valid);
|
43
43
|
}
|
44
44
|
|
45
45
|
.isRootStateWarning {
|
46
|
-
|
46
|
+
@include variants.validation(warning);
|
47
47
|
}
|
48
48
|
|
49
49
|
// Invisible label
|
50
50
|
.isLabelHidden {
|
51
|
-
|
51
|
+
@include accessibility.hide-text();
|
52
52
|
}
|
53
53
|
|
54
54
|
// Layouts
|
55
55
|
.hasRootLabelBefore {
|
56
|
-
|
56
|
+
@include inline-field-layout.has-label-before();
|
57
57
|
}
|
58
58
|
|
59
59
|
.isRootInFormLayout {
|
60
|
-
|
60
|
+
@include inline-field-layout.in-form-layout();
|
61
61
|
}
|
@@ -44,13 +44,13 @@ See [API](#api) for all available options.
|
|
44
44
|
- Use the CheckboxField when there are lists of options and the user may
|
45
45
|
**select any number of choices,** including zero, one, or several. For
|
46
46
|
selecting just a single option from the list, use either the
|
47
|
-
[Radio](/components/
|
47
|
+
[Radio](/components/radio) or [SelectField](/components/select-field)
|
48
48
|
component.
|
49
49
|
|
50
50
|
- Use the CheckboxField for boolean (true/false) input **in forms that require
|
51
51
|
to be confirmed** by a button to become active. To toggle things on or off
|
52
52
|
with an immediate effect (without confirmation), use rather the
|
53
|
-
[Toggle](/components/
|
53
|
+
[Toggle](/components/toggle) component.
|
54
54
|
|
55
55
|
- **Use positive wording for the checkbox label,** so that it's clear what will
|
56
56
|
happen when the user turns on the checkbox. Avoid negations such as “Don't
|
@@ -185,7 +185,7 @@ Disabled state makes the input unavailable.
|
|
185
185
|
|
186
186
|
In addition to the options below, you can specify [React synthetic events] or
|
187
187
|
any custom HTML attributes that do not interfere with the API, and they will be
|
188
|
-
passed to the
|
188
|
+
passed to the `<input>` HTML element. This enables making the component
|
189
189
|
interactive and helps improve its accessibility.
|
190
190
|
|
191
191
|
<Props table of={CheckboxField} />
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React, { useContext } from 'react';
|
3
|
-
import getRootValidationStateClassName from '../../helpers/getRootValidationStateClassName';
|
4
|
-
import { resolveContextOrProp } from '../../helpers/resolveContextOrProp';
|
5
3
|
import { withProviderContext } from '../../provider';
|
6
|
-
import
|
4
|
+
import { classNames } from '../../utils/classNames';
|
5
|
+
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
|
6
|
+
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
7
|
+
import { transferProps } from '../_helpers/transferProps';
|
7
8
|
import { FormLayoutContext } from '../FormLayout';
|
8
9
|
import withForwardedRef from '../withForwardedRef';
|
9
10
|
import styles from './FileInputField.scss';
|
@@ -26,25 +27,25 @@ export const FileInputField = ({
|
|
26
27
|
|
27
28
|
return (
|
28
29
|
<label
|
29
|
-
className={
|
30
|
+
className={classNames(
|
30
31
|
styles.root,
|
31
|
-
fullWidth
|
32
|
-
context
|
32
|
+
fullWidth && styles.isRootFullWidth,
|
33
|
+
context && styles.isRootInFormLayout,
|
33
34
|
resolveContextOrProp(context && context.layout, layout) === 'horizontal'
|
34
35
|
? styles.rootLayoutHorizontal
|
35
36
|
: styles.rootLayoutVertical,
|
36
|
-
disabled
|
37
|
-
required
|
37
|
+
disabled && styles.isRootDisabled,
|
38
|
+
required && styles.isRootRequired,
|
38
39
|
getRootValidationStateClassName(validationState, styles),
|
39
|
-
|
40
|
+
)}
|
40
41
|
htmlFor={id}
|
41
42
|
id={id && `${id}__label`}
|
42
43
|
>
|
43
44
|
<div
|
44
|
-
className={
|
45
|
+
className={classNames(
|
45
46
|
styles.label,
|
46
|
-
isLabelVisible
|
47
|
-
|
47
|
+
!isLabelVisible && styles.isLabelHidden,
|
48
|
+
)}
|
48
49
|
id={id && `${id}__labelText`}
|
49
50
|
>
|
50
51
|
{label}
|
@@ -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
3
|
import { withProviderContext } 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
|
/**
|
@@ -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 getRootSizeClassName from '../../helpers/getRootSizeClassName';
|
4
|
-
import getRootValidationStateClassName from '../../helpers/getRootValidationStateClassName';
|
5
3
|
import { withProviderContext } from '../../provider';
|
6
|
-
import
|
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
|
/**
|