@react-ui-org/react-ui 0.65.0 → 0.67.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/dist/react-ui.css +11 -11
- package/dist/react-ui.d.ts +36 -28
- package/dist/react-ui.development.css +742 -165
- package/dist/react-ui.development.js +56 -266
- package/dist/react-ui.js +1 -1
- package/package.json +35 -37
- package/src/components/Button/helpers/getRootLabelVisibilityClassName.ts +1 -1
- package/src/components/CheckboxField/CheckboxField.module.scss +7 -3
- package/src/components/CheckboxField/CheckboxField.tsx +3 -3
- package/src/components/CheckboxField/CheckboxField.types.ts +4 -3
- package/src/components/CheckboxField/README.md +25 -3
- package/src/components/FileInputField/FileInputField.module.scss +7 -3
- package/src/components/FileInputField/FileInputField.tsx +3 -3
- package/src/components/FileInputField/FileInputField.types.ts +4 -3
- package/src/components/FileInputField/README.md +20 -3
- package/src/components/FormLayout/FormLayout.module.scss +4 -6
- package/src/components/FormLayout/FormLayoutCustomField.module.scss +7 -3
- package/src/components/FormLayout/FormLayoutCustomField.tsx +3 -3
- package/src/components/FormLayout/FormLayoutCustomField.types.ts +4 -3
- package/src/components/FormLayout/README.md +2 -9
- package/src/components/Grid/_helpers/generateResponsiveCustomProperties.ts +1 -0
- package/src/components/InputGroup/InputGroup.module.scss +7 -3
- package/src/components/InputGroup/InputGroup.tsx +8 -14
- package/src/components/InputGroup/README.md +35 -7
- package/src/components/Modal/_helpers/getPositionClassName.ts +1 -1
- package/src/components/Modal/_helpers/getScrollingClassName.ts +1 -1
- package/src/components/Radio/README.md +40 -3
- package/src/components/Radio/Radio.module.scss +7 -3
- package/src/components/Radio/Radio.tsx +3 -3
- package/src/components/Radio/Radio.types.ts +4 -3
- package/src/components/SelectField/README.md +53 -6
- package/src/components/SelectField/SelectField.module.scss +7 -3
- package/src/components/SelectField/SelectField.tsx +3 -3
- package/src/components/SelectField/SelectField.types.ts +4 -3
- package/src/components/Text/_helpers/getRootClampClassName.ts +1 -1
- package/src/components/Text/_helpers/getRootHyphensClassName.ts +1 -1
- package/src/components/Text/_helpers/getRootWordWrappingClassName.ts +1 -1
- package/src/components/TextArea/README.md +30 -6
- package/src/components/TextArea/TextArea.module.scss +7 -3
- package/src/components/TextArea/TextArea.tsx +3 -3
- package/src/components/TextArea/TextArea.types.ts +4 -3
- package/src/components/TextField/README.md +30 -6
- package/src/components/TextField/TextField.module.scss +7 -3
- package/src/components/TextField/TextField.tsx +3 -3
- package/src/components/TextField/TextField.types.ts +6 -5
- package/src/components/TextLink/README.md +1 -1
- package/src/components/Toggle/README.md +25 -3
- package/src/components/Toggle/Toggle.module.scss +7 -3
- package/src/components/Toggle/Toggle.tsx +3 -3
- package/src/components/Toggle/Toggle.types.ts +4 -3
- package/src/components/_helpers/getRootColorClassName.ts +1 -1
- package/src/components/_helpers/getRootPriorityClassName.ts +1 -1
- package/src/components/_helpers/getRootSizeClassName.ts +1 -1
- package/src/components/_helpers/getRootStateClassName.ts +24 -0
- package/src/index.ts +1 -1
- package/src/styles/settings/_form-fields.scss +2 -1
- package/src/styles/theme/_form-fields.scss +16 -11
- package/src/styles/theme-constants/_colors.scss +21 -0
- package/src/styles/tools/form-fields/_box-field-layout.scss +5 -8
- package/src/styles/tools/form-fields/_inline-field-elements.scss +0 -7
- package/src/styles/tools/form-fields/_inline-field-layout.scss +0 -8
- package/src/styles/tools/form-fields/_variants.scss +7 -7
- package/src/theme.scss +37 -12
- package/src/types/index.ts +1 -1
- package/src/types/states.ts +1 -0
- package/src/components/_helpers/getRootValidationStateClassName.ts +0 -20
- package/src/types/validationStates.ts +0 -1
|
@@ -377,7 +377,7 @@ have.
|
|
|
377
377
|
<TextField
|
|
378
378
|
label="User name"
|
|
379
379
|
onChange={() => {}}
|
|
380
|
-
|
|
380
|
+
state="valid"
|
|
381
381
|
validationText="Looks good!"
|
|
382
382
|
value="johnny1986"
|
|
383
383
|
required
|
|
@@ -385,7 +385,7 @@ have.
|
|
|
385
385
|
<TextField
|
|
386
386
|
label="User name"
|
|
387
387
|
onChange={() => {}}
|
|
388
|
-
|
|
388
|
+
state="warning"
|
|
389
389
|
validationText={(
|
|
390
390
|
<>
|
|
391
391
|
Account with this name already exists, pick a different one.
|
|
@@ -398,14 +398,14 @@ have.
|
|
|
398
398
|
/>
|
|
399
399
|
<TextField
|
|
400
400
|
label="User name"
|
|
401
|
-
|
|
401
|
+
state="invalid"
|
|
402
402
|
validationText="Please enter a user name of your choice."
|
|
403
403
|
required
|
|
404
404
|
/>
|
|
405
405
|
<TextField
|
|
406
406
|
label="User name"
|
|
407
407
|
onChange={() => {}}
|
|
408
|
-
|
|
408
|
+
state="valid"
|
|
409
409
|
validationText="Looks good!"
|
|
410
410
|
variant="filled"
|
|
411
411
|
value="johnny1986"
|
|
@@ -414,7 +414,7 @@ have.
|
|
|
414
414
|
<TextField
|
|
415
415
|
label="User name"
|
|
416
416
|
onChange={() => {}}
|
|
417
|
-
|
|
417
|
+
state="warning"
|
|
418
418
|
validationText={(
|
|
419
419
|
<>
|
|
420
420
|
Account with this name already exists, pick a different one.
|
|
@@ -428,13 +428,37 @@ have.
|
|
|
428
428
|
/>
|
|
429
429
|
<TextField
|
|
430
430
|
label="User name"
|
|
431
|
-
|
|
431
|
+
state="invalid"
|
|
432
432
|
validationText="Please enter a user name of your choice."
|
|
433
433
|
variant="filled"
|
|
434
434
|
required
|
|
435
435
|
/>
|
|
436
436
|
```
|
|
437
437
|
|
|
438
|
+
### Changed State
|
|
439
|
+
|
|
440
|
+
Changed state highlights fields whose value differs from the saved one, so users
|
|
441
|
+
can review their edits before saving.
|
|
442
|
+
|
|
443
|
+
A field shows one state at a time. When a changed value is also invalid, it's
|
|
444
|
+
up to you to pick the state that matters more to the user.
|
|
445
|
+
|
|
446
|
+
```docoff-react-preview
|
|
447
|
+
<TextField
|
|
448
|
+
label="User name"
|
|
449
|
+
onChange={() => {}}
|
|
450
|
+
state="changed"
|
|
451
|
+
value="johnny1986"
|
|
452
|
+
/>
|
|
453
|
+
<TextField
|
|
454
|
+
label="User name"
|
|
455
|
+
onChange={() => {}}
|
|
456
|
+
state="changed"
|
|
457
|
+
variant="filled"
|
|
458
|
+
value="johnny1986"
|
|
459
|
+
/>
|
|
460
|
+
```
|
|
461
|
+
|
|
438
462
|
### Disabled State
|
|
439
463
|
|
|
440
464
|
It's possible to disable the whole input.
|
|
@@ -50,16 +50,20 @@
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// States
|
|
53
|
+
.isRootStateChanged {
|
|
54
|
+
@include variants.state(changed);
|
|
55
|
+
}
|
|
56
|
+
|
|
53
57
|
.isRootStateInvalid {
|
|
54
|
-
@include variants.
|
|
58
|
+
@include variants.state(invalid);
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
.isRootStateValid {
|
|
58
|
-
@include variants.
|
|
62
|
+
@include variants.state(valid);
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
.isRootStateWarning {
|
|
62
|
-
@include variants.
|
|
66
|
+
@include variants.state(warning);
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
// Invisible label
|
|
@@ -4,7 +4,7 @@ import { withGlobalProps } from '../../providers/globalProps';
|
|
|
4
4
|
import { classNames } from '../../helpers/classNames/classNames';
|
|
5
5
|
import { transferProps } from '../../helpers/transferProps';
|
|
6
6
|
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
|
7
|
-
import {
|
|
7
|
+
import { getRootStateClassName } from '../_helpers/getRootStateClassName';
|
|
8
8
|
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
|
9
9
|
import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
|
|
10
10
|
import { FormLayoutCustomFieldContext } from '../FormLayout/FormLayoutCustomFieldContext';
|
|
@@ -25,8 +25,8 @@ export const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(({
|
|
|
25
25
|
layout = 'vertical',
|
|
26
26
|
required = false,
|
|
27
27
|
size = 'medium',
|
|
28
|
+
state,
|
|
28
29
|
type = 'text',
|
|
29
|
-
validationState,
|
|
30
30
|
validationText,
|
|
31
31
|
variant = 'outline',
|
|
32
32
|
...restProps
|
|
@@ -54,7 +54,7 @@ export const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(({
|
|
|
54
54
|
styles,
|
|
55
55
|
resolveContextOrProp(inputGroupContext && inputGroupContext.size, size),
|
|
56
56
|
),
|
|
57
|
-
|
|
57
|
+
getRootStateClassName(styles, state),
|
|
58
58
|
variant === 'filled' ? styles.isRootVariantFilled : styles.isRootVariantOutline,
|
|
59
59
|
)}
|
|
60
60
|
htmlFor={id}
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
import type {
|
|
6
6
|
Layout,
|
|
7
7
|
Size,
|
|
8
|
-
|
|
8
|
+
State,
|
|
9
9
|
} from '../../types';
|
|
10
10
|
|
|
11
11
|
export type TextFieldType = 'email' | 'number' | 'password' | 'tel' | 'text';
|
|
@@ -73,13 +73,14 @@ export type TextFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size'
|
|
|
73
73
|
*/
|
|
74
74
|
size?: Size;
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
76
|
+
* Alter the field to reflect the state of its data, e.g. a validation result or a change
|
|
77
|
+
* against the saved value.
|
|
77
78
|
*/
|
|
78
|
-
|
|
79
|
+
state?: State;
|
|
79
80
|
/**
|
|
80
|
-
*
|
|
81
|
+
* HTML input type, translated as `type` attribute of the input.
|
|
81
82
|
*/
|
|
82
|
-
|
|
83
|
+
type?: TextFieldType;
|
|
83
84
|
/**
|
|
84
85
|
* Validation message to be displayed.
|
|
85
86
|
*
|
|
@@ -68,7 +68,7 @@ helps to improve its accessibility.
|
|
|
68
68
|
parent component. This applies for components using
|
|
69
69
|
[Feedback color collection](/docs/foundation/collections#colors) and for
|
|
70
70
|
components in any of the supported
|
|
71
|
-
[
|
|
71
|
+
[states](../../docs/foundation/colors.md#states).
|
|
72
72
|
In such cases, the custom properties marked with an asterisk (\*) are ignored.
|
|
73
73
|
|
|
74
74
|
| Custom Property | Description |
|
|
@@ -131,13 +131,13 @@ React.createElement(() => {
|
|
|
131
131
|
checked={studioQuality}
|
|
132
132
|
label="Listen in studio quality"
|
|
133
133
|
onChange={() => setStudioQuality(!studioQuality)}
|
|
134
|
-
|
|
134
|
+
state="valid"
|
|
135
135
|
/>
|
|
136
136
|
<Toggle
|
|
137
137
|
checked={studioQuality}
|
|
138
138
|
label="Listen in studio quality"
|
|
139
139
|
onChange={() => setStudioQuality(!studioQuality)}
|
|
140
|
-
|
|
140
|
+
state="warning"
|
|
141
141
|
validationText={
|
|
142
142
|
'Looks like you are connected over cellular network. '
|
|
143
143
|
+ 'Please make sure you know what you are doing.'
|
|
@@ -147,7 +147,7 @@ React.createElement(() => {
|
|
|
147
147
|
checked={studioQuality}
|
|
148
148
|
label="Listen in studio quality"
|
|
149
149
|
onChange={() => setStudioQuality(!studioQuality)}
|
|
150
|
-
|
|
150
|
+
state="invalid"
|
|
151
151
|
validationText={(
|
|
152
152
|
<>
|
|
153
153
|
Please
|
|
@@ -163,6 +163,28 @@ React.createElement(() => {
|
|
|
163
163
|
});
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
+
### Changed State
|
|
167
|
+
|
|
168
|
+
Changed state highlights fields whose value differs from the saved one, so users
|
|
169
|
+
can review their edits before saving.
|
|
170
|
+
|
|
171
|
+
A field shows one state at a time. When a changed value is also invalid, it's
|
|
172
|
+
up to you to pick the state that matters more to the user.
|
|
173
|
+
|
|
174
|
+
```docoff-react-preview
|
|
175
|
+
React.createElement(() => {
|
|
176
|
+
const [studioQuality, setStudioQuality] = React.useState(true);
|
|
177
|
+
return (
|
|
178
|
+
<Toggle
|
|
179
|
+
checked={studioQuality}
|
|
180
|
+
label="Listen in studio quality"
|
|
181
|
+
onChange={() => setStudioQuality(!studioQuality)}
|
|
182
|
+
state="changed"
|
|
183
|
+
/>
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
166
188
|
### Required State
|
|
167
189
|
|
|
168
190
|
The required state indicates that the input is mandatory.
|
|
@@ -35,16 +35,20 @@
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// States
|
|
38
|
+
.isRootStateChanged {
|
|
39
|
+
@include variants.state(changed);
|
|
40
|
+
}
|
|
41
|
+
|
|
38
42
|
.isRootStateInvalid {
|
|
39
|
-
@include variants.
|
|
43
|
+
@include variants.state(invalid);
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
.isRootStateValid {
|
|
43
|
-
@include variants.
|
|
47
|
+
@include variants.state(valid);
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
.isRootStateWarning {
|
|
47
|
-
@include variants.
|
|
51
|
+
@include variants.state(warning);
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
// Invisible label
|
|
@@ -2,7 +2,7 @@ import React, { useContext } from 'react';
|
|
|
2
2
|
import { withGlobalProps } from '../../providers/globalProps';
|
|
3
3
|
import { classNames } from '../../helpers/classNames/classNames';
|
|
4
4
|
import { transferProps } from '../../helpers/transferProps';
|
|
5
|
-
import {
|
|
5
|
+
import { getRootStateClassName } from '../_helpers/getRootStateClassName';
|
|
6
6
|
import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
|
|
7
7
|
import styles from './Toggle.module.scss';
|
|
8
8
|
import type { ToggleProps } from './Toggle.types';
|
|
@@ -16,7 +16,7 @@ export const Toggle = React.forwardRef<HTMLInputElement, ToggleProps>(({
|
|
|
16
16
|
labelPosition = 'after',
|
|
17
17
|
renderAsRequired = false,
|
|
18
18
|
required = false,
|
|
19
|
-
|
|
19
|
+
state,
|
|
20
20
|
validationText,
|
|
21
21
|
...restProps
|
|
22
22
|
}, ref) => {
|
|
@@ -31,7 +31,7 @@ export const Toggle = React.forwardRef<HTMLInputElement, ToggleProps>(({
|
|
|
31
31
|
labelPosition === 'before' && styles.hasRootLabelBefore,
|
|
32
32
|
disabled && styles.isRootDisabled,
|
|
33
33
|
(required || renderAsRequired) && styles.isRootRequired,
|
|
34
|
-
|
|
34
|
+
getRootStateClassName(styles, state),
|
|
35
35
|
)}
|
|
36
36
|
htmlFor={id}
|
|
37
37
|
id={id && `${id}__label`}
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
} from 'react';
|
|
5
5
|
import type {
|
|
6
6
|
LabelPosition,
|
|
7
|
-
|
|
7
|
+
State,
|
|
8
8
|
} from '../../types';
|
|
9
9
|
|
|
10
10
|
export type ToggleLabelPosition = LabelPosition;
|
|
@@ -48,9 +48,10 @@ export type ToggleProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> &
|
|
|
48
48
|
*/
|
|
49
49
|
required?: boolean;
|
|
50
50
|
/**
|
|
51
|
-
* Alter the field to
|
|
51
|
+
* Alter the field to reflect the state of its data, e.g. a validation result or a change
|
|
52
|
+
* against the saved value.
|
|
52
53
|
*/
|
|
53
|
-
|
|
54
|
+
state?: State;
|
|
54
55
|
/**
|
|
55
56
|
* Validation message to be displayed.
|
|
56
57
|
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CssModuleClasses,
|
|
3
|
+
State,
|
|
4
|
+
} from '../../types';
|
|
5
|
+
|
|
6
|
+
export const getRootStateClassName = (styles: CssModuleClasses, state?: State) => {
|
|
7
|
+
if (state === 'changed') {
|
|
8
|
+
return styles.isRootStateChanged;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (state === 'invalid') {
|
|
12
|
+
return styles.isRootStateInvalid;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (state === 'valid') {
|
|
16
|
+
return styles.isRootStateValid;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (state === 'warning') {
|
|
20
|
+
return styles.isRootStateWarning;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return undefined;
|
|
24
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -34,7 +34,8 @@ $themeable-variant-states: (
|
|
|
34
34
|
custom: (
|
|
35
35
|
default: (default, disabled),
|
|
36
36
|
),
|
|
37
|
-
|
|
37
|
+
state: (
|
|
38
|
+
changed: (default, checked, disabled, checked-disabled),
|
|
38
39
|
invalid: (default, checked, disabled, checked-disabled),
|
|
39
40
|
valid: (default, checked, disabled, checked-disabled),
|
|
40
41
|
warning: (default, checked, disabled, checked-disabled),
|
|
@@ -30,22 +30,27 @@ $horizontal-label-vertical-alignment: var(--rui-FormField--horizontal__label__ve
|
|
|
30
30
|
$horizontal-field-vertical-alignment: var(--rui-FormField--horizontal__field__vertical-alignment);
|
|
31
31
|
$horizontal-full-width-label-width: var(--rui-FormField--horizontal--full-width__label__width);
|
|
32
32
|
|
|
33
|
-
// Form fields: links in
|
|
34
|
-
$link-
|
|
33
|
+
// Form fields: links in states
|
|
34
|
+
$link-state-colors: (
|
|
35
|
+
changed: (
|
|
36
|
+
default: var(--rui-color-state-changed),
|
|
37
|
+
hover: var(--rui-color-state-changed-hover),
|
|
38
|
+
active: var(--rui-color-state-changed-active),
|
|
39
|
+
),
|
|
35
40
|
invalid: (
|
|
36
|
-
default: var(--rui-color-
|
|
37
|
-
hover: var(--rui-color-
|
|
38
|
-
active: var(--rui-color-
|
|
41
|
+
default: var(--rui-color-state-invalid),
|
|
42
|
+
hover: var(--rui-color-state-invalid-hover),
|
|
43
|
+
active: var(--rui-color-state-invalid-active),
|
|
39
44
|
),
|
|
40
45
|
valid: (
|
|
41
|
-
default: var(--rui-color-
|
|
42
|
-
hover: var(--rui-color-
|
|
43
|
-
active: var(--rui-color-
|
|
46
|
+
default: var(--rui-color-state-valid),
|
|
47
|
+
hover: var(--rui-color-state-valid-hover),
|
|
48
|
+
active: var(--rui-color-state-valid-active),
|
|
44
49
|
),
|
|
45
50
|
warning: (
|
|
46
|
-
default: var(--rui-color-
|
|
47
|
-
hover: var(--rui-color-
|
|
48
|
-
active: var(--rui-color-
|
|
51
|
+
default: var(--rui-color-state-warning),
|
|
52
|
+
hover: var(--rui-color-state-warning-hover),
|
|
53
|
+
active: var(--rui-color-state-warning-active),
|
|
49
54
|
),
|
|
50
55
|
);
|
|
51
56
|
|
|
@@ -34,6 +34,11 @@ $help: #6610f2;
|
|
|
34
34
|
$info: #17a2b8;
|
|
35
35
|
$note: #007bff;
|
|
36
36
|
|
|
37
|
+
$state-valid: #2f9e44;
|
|
38
|
+
$state-invalid: #e03131;
|
|
39
|
+
$state-warning: #f59f00;
|
|
40
|
+
$state-changed: #b5179e;
|
|
41
|
+
|
|
37
42
|
$white: #fff;
|
|
38
43
|
$black: #000;
|
|
39
44
|
|
|
@@ -81,3 +86,19 @@ $note-light: colors.lighten-color($note, $_amount-light);
|
|
|
81
86
|
$note-dark: colors.darken-color($note, $_amount-dark);
|
|
82
87
|
$note-darker: colors.darken-color($note, $_amount-darker);
|
|
83
88
|
$on-note: $white;
|
|
89
|
+
|
|
90
|
+
$state-valid-light: colors.lighten-color($state-valid, $_amount-light);
|
|
91
|
+
$state-valid-dark: colors.darken-color($state-valid, $_amount-dark);
|
|
92
|
+
$state-valid-darker: colors.darken-color($state-valid, $_amount-darker);
|
|
93
|
+
|
|
94
|
+
$state-invalid-light: colors.lighten-color($state-invalid, $_amount-light);
|
|
95
|
+
$state-invalid-dark: colors.darken-color($state-invalid, $_amount-dark);
|
|
96
|
+
$state-invalid-darker: colors.darken-color($state-invalid, $_amount-darker);
|
|
97
|
+
|
|
98
|
+
$state-warning-light: colors.lighten-color($state-warning, $_amount-light);
|
|
99
|
+
$state-warning-dark: colors.darken-color($state-warning, $_amount-dark);
|
|
100
|
+
$state-warning-darker: colors.darken-color($state-warning, $_amount-darker);
|
|
101
|
+
|
|
102
|
+
$state-changed-light: colors.lighten-color($state-changed, $_amount-light);
|
|
103
|
+
$state-changed-dark: colors.darken-color($state-changed, $_amount-dark);
|
|
104
|
+
$state-changed-darker: colors.darken-color($state-changed, $_amount-darker);
|
|
@@ -26,12 +26,13 @@
|
|
|
26
26
|
// Reverted for full-width fields.
|
|
27
27
|
//
|
|
28
28
|
// 8. Grid settings are inherited from horizontal FormLayout and applied using `subgrid`.
|
|
29
|
-
// A fallback is supplied to browsers that don't support `subgrid` yet.
|
|
30
29
|
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
30
|
+
// `<fieldset>` cannot be a subgrid: the HTML spec wraps its content in an anonymous box which
|
|
31
|
+
// breaks it, and Chrome doesn't support it at all. This is why `<fieldset>` uses
|
|
32
|
+
// `display: contents` instead.
|
|
33
33
|
//
|
|
34
|
-
// https://
|
|
34
|
+
// https://issues.chromium.org/issues/40278914
|
|
35
|
+
// https://github.com/whatwg/html/issues/11546
|
|
35
36
|
// https://github.com/react-ui-org/react-ui/issues/232
|
|
36
37
|
//
|
|
37
38
|
// 9. Help texts and validation messages can take up full width of FormLayout. There is no reason
|
|
@@ -213,10 +214,6 @@
|
|
|
213
214
|
grid: inherit;
|
|
214
215
|
grid-template-columns: subgrid;
|
|
215
216
|
grid-column: span 2;
|
|
216
|
-
|
|
217
|
-
@supports not (grid-template-columns: subgrid) {
|
|
218
|
-
display: contents;
|
|
219
|
-
}
|
|
220
217
|
}
|
|
221
218
|
|
|
222
219
|
&.isRootLayoutHorizontal.isRootFullWidth {
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
//
|
|
7
7
|
// 3. Reset extra space previously added to symmetrically pad the field in FormLayout context as
|
|
8
8
|
// there already is a sufficient row gap provided by FormLayout.
|
|
9
|
-
//
|
|
10
|
-
// 4. Destroy tap target when subgrid is not supported.
|
|
11
9
|
|
|
12
10
|
@use "../../theme/typography";
|
|
13
11
|
@use "../../theme/form-fields" as theme;
|
|
@@ -101,11 +99,6 @@
|
|
|
101
99
|
|
|
102
100
|
&.isRootInFormLayout.isRootLayoutHorizontal::before {
|
|
103
101
|
grid-column-start: 2;
|
|
104
|
-
|
|
105
|
-
// 4.
|
|
106
|
-
@supports not (grid-template-columns: subgrid) {
|
|
107
|
-
display: none;
|
|
108
|
-
}
|
|
109
102
|
}
|
|
110
103
|
}
|
|
111
104
|
}
|
|
@@ -73,10 +73,6 @@
|
|
|
73
73
|
grid: inherit;
|
|
74
74
|
grid-template-columns: subgrid;
|
|
75
75
|
grid-column: span 2;
|
|
76
|
-
|
|
77
|
-
@supports not (grid-template-columns: subgrid) {
|
|
78
|
-
display: contents;
|
|
79
|
-
}
|
|
80
76
|
}
|
|
81
77
|
|
|
82
78
|
&.isRootLayoutHorizontal .field {
|
|
@@ -102,10 +98,6 @@
|
|
|
102
98
|
&.isRootLayoutHorizontal .validationText {
|
|
103
99
|
width: auto;
|
|
104
100
|
max-width: 100%;
|
|
105
|
-
|
|
106
|
-
@supports not (grid-template-columns: subgrid) {
|
|
107
|
-
margin-top: calc(-1 * var(--rui-FormLayout__row-gap));
|
|
108
|
-
}
|
|
109
101
|
}
|
|
110
102
|
|
|
111
103
|
&.isRootLayoutHorizontal.hasRootLabelBefore .label {
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
$infix: $type;
|
|
30
30
|
$fallback-state: "default";
|
|
31
31
|
|
|
32
|
-
@if $type == "
|
|
32
|
+
@if $type == "state" {
|
|
33
33
|
$infix: $variant;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
@if $type != "
|
|
36
|
+
@if $type != "state" and $variant != "default" {
|
|
37
37
|
$infix: #{$type}--#{$variant};
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -142,10 +142,10 @@
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
@mixin
|
|
146
|
-
--rui-local-link-color: #{map.get(theme.$link-
|
|
147
|
-
--rui-local-link-color-hover: #{map.get(theme.$link-
|
|
148
|
-
--rui-local-link-color-active: #{map.get(theme.$link-
|
|
145
|
+
@mixin state($variant) {
|
|
146
|
+
--rui-local-link-color: #{map.get(theme.$link-state-colors, $variant, default)};
|
|
147
|
+
--rui-local-link-color-hover: #{map.get(theme.$link-state-colors, $variant, hover)};
|
|
148
|
+
--rui-local-link-color-active: #{map.get(theme.$link-state-colors, $variant, active)};
|
|
149
149
|
|
|
150
|
-
@include _get-theme(
|
|
150
|
+
@include _get-theme(state, $variant);
|
|
151
151
|
}
|
package/src/theme.scss
CHANGED
|
@@ -208,6 +208,20 @@
|
|
|
208
208
|
--rui-color-feedback-note-active: #{colors.$note-darker};
|
|
209
209
|
--rui-color-feedback-on-note: #{colors.$on-note};
|
|
210
210
|
|
|
211
|
+
// State colors
|
|
212
|
+
--rui-color-state-valid: #{colors.$state-valid};
|
|
213
|
+
--rui-color-state-valid-hover: #{colors.$state-valid-dark};
|
|
214
|
+
--rui-color-state-valid-active: #{colors.$state-valid-darker};
|
|
215
|
+
--rui-color-state-invalid: #{colors.$state-invalid};
|
|
216
|
+
--rui-color-state-invalid-hover: #{colors.$state-invalid-dark};
|
|
217
|
+
--rui-color-state-invalid-active: #{colors.$state-invalid-darker};
|
|
218
|
+
--rui-color-state-warning: #{colors.$state-warning};
|
|
219
|
+
--rui-color-state-warning-hover: #{colors.$state-warning-dark};
|
|
220
|
+
--rui-color-state-warning-active: #{colors.$state-warning-darker};
|
|
221
|
+
--rui-color-state-changed: #{colors.$state-changed};
|
|
222
|
+
--rui-color-state-changed-hover: #{colors.$state-changed-dark};
|
|
223
|
+
--rui-color-state-changed-active: #{colors.$state-changed-darker};
|
|
224
|
+
|
|
211
225
|
// Neutral colors
|
|
212
226
|
--rui-color-neutral-light: #{colors.$white};
|
|
213
227
|
--rui-color-neutral-light-hover: #{colors.$gray-50};
|
|
@@ -236,6 +250,10 @@
|
|
|
236
250
|
--rui-color-background-help: #{colors.$help-light};
|
|
237
251
|
--rui-color-background-info: #{colors.$info-light};
|
|
238
252
|
--rui-color-background-note: #{colors.$note-light};
|
|
253
|
+
--rui-color-background-state-valid: #{colors.$state-valid-light};
|
|
254
|
+
--rui-color-background-state-invalid: #{colors.$state-invalid-light};
|
|
255
|
+
--rui-color-background-state-warning: #{colors.$state-warning-light};
|
|
256
|
+
--rui-color-background-state-changed: #{colors.$state-changed-light};
|
|
239
257
|
--rui-color-background-light: #{colors.$gray-100};
|
|
240
258
|
--rui-color-background-dark: #{colors.$gray-600};
|
|
241
259
|
|
|
@@ -910,27 +928,34 @@
|
|
|
910
928
|
--rui-FormField--disabled__cursor: var(--rui-cursor-not-allowed);
|
|
911
929
|
--rui-FormField--disabled__opacity: var(--rui-ratio-disabled-opacity);
|
|
912
930
|
|
|
913
|
-
// Form fields:
|
|
914
|
-
--rui-FormField--invalid--default__border-color: var(--rui-color-
|
|
915
|
-
--rui-FormField--invalid--default__background: var(--rui-color-background-
|
|
931
|
+
// Form fields: states: invalid
|
|
932
|
+
--rui-FormField--invalid--default__border-color: var(--rui-color-state-invalid);
|
|
933
|
+
--rui-FormField--invalid--default__background: var(--rui-color-background-state-invalid);
|
|
916
934
|
--rui-FormField--invalid--default__check-background-color: var(--rui-FormField--invalid--default__background);
|
|
917
|
-
--rui-FormField--invalid--default__surrounding-text-color: var(--rui-color-
|
|
935
|
+
--rui-FormField--invalid--default__surrounding-text-color: var(--rui-color-state-invalid);
|
|
918
936
|
--rui-FormField--invalid--checked__check-background-color: var(--rui-FormField--invalid--default__border-color);
|
|
919
937
|
|
|
920
|
-
// Form fields:
|
|
921
|
-
--rui-FormField--valid--default__border-color: var(--rui-color-
|
|
922
|
-
--rui-FormField--valid--default__background: var(--rui-color-background-
|
|
938
|
+
// Form fields: states: valid
|
|
939
|
+
--rui-FormField--valid--default__border-color: var(--rui-color-state-valid);
|
|
940
|
+
--rui-FormField--valid--default__background: var(--rui-color-background-state-valid);
|
|
923
941
|
--rui-FormField--valid--default__check-background-color: var(--rui-FormField--valid--default__background);
|
|
924
|
-
--rui-FormField--valid--default__surrounding-text-color: var(--rui-color-
|
|
942
|
+
--rui-FormField--valid--default__surrounding-text-color: var(--rui-color-state-valid);
|
|
925
943
|
--rui-FormField--valid--checked__check-background-color: var(--rui-FormField--valid--default__border-color);
|
|
926
944
|
|
|
927
|
-
// Form fields:
|
|
928
|
-
--rui-FormField--warning--default__border-color: var(--rui-color-
|
|
929
|
-
--rui-FormField--warning--default__background: var(--rui-color-background-warning);
|
|
945
|
+
// Form fields: states: warning
|
|
946
|
+
--rui-FormField--warning--default__border-color: var(--rui-color-state-warning-hover);
|
|
947
|
+
--rui-FormField--warning--default__background: var(--rui-color-background-state-warning);
|
|
930
948
|
--rui-FormField--warning--default__check-background-color: var(--rui-FormField--warning--default__background);
|
|
931
|
-
--rui-FormField--warning--default__surrounding-text-color: var(--rui-color-
|
|
949
|
+
--rui-FormField--warning--default__surrounding-text-color: var(--rui-color-state-warning-active);
|
|
932
950
|
--rui-FormField--warning--checked__check-background-color: var(--rui-FormField--warning--default__border-color);
|
|
933
951
|
|
|
952
|
+
// Form fields: states: changed
|
|
953
|
+
--rui-FormField--changed--default__border-color: var(--rui-color-state-changed);
|
|
954
|
+
--rui-FormField--changed--default__background: var(--rui-color-background-state-changed);
|
|
955
|
+
--rui-FormField--changed--default__check-background-color: var(--rui-FormField--changed--default__background);
|
|
956
|
+
--rui-FormField--changed--default__surrounding-text-color: var(--rui-color-state-changed);
|
|
957
|
+
--rui-FormField--changed--checked__check-background-color: var(--rui-FormField--changed--default__border-color);
|
|
958
|
+
|
|
934
959
|
// Form fields: box fields
|
|
935
960
|
--rui-FormField--box__border-width: var(--rui-dimension-border-width-1);
|
|
936
961
|
--rui-FormField--box__border-radius: var(--rui-dimension-radius-2);
|
package/src/types/index.ts
CHANGED
|
@@ -9,5 +9,5 @@ export type { LabelPosition } from './labelPositions';
|
|
|
9
9
|
export type { Layout } from './layouts';
|
|
10
10
|
export type { Priority } from './priorities';
|
|
11
11
|
export type { Size } from './sizes';
|
|
12
|
+
export type { State } from './states';
|
|
12
13
|
export type { CssModuleClasses } from './styles';
|
|
13
|
-
export type { ValidationState } from './validationStates';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type State = 'changed' | 'invalid' | 'valid' | 'warning';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CssModuleClasses,
|
|
3
|
-
ValidationState,
|
|
4
|
-
} from '../../types';
|
|
5
|
-
|
|
6
|
-
export const getRootValidationStateClassName = (styles: CssModuleClasses, validationState?: ValidationState) => {
|
|
7
|
-
if (validationState === 'invalid') {
|
|
8
|
-
return styles.isRootStateInvalid;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (validationState === 'valid') {
|
|
12
|
-
return styles.isRootStateValid;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (validationState === 'warning') {
|
|
16
|
-
return styles.isRootStateWarning;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return null;
|
|
20
|
-
};
|