@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
|
@@ -222,7 +222,7 @@ Disables all fields and buttons inside the group.
|
|
|
222
222
|
### Validation States
|
|
223
223
|
|
|
224
224
|
Validation states visually present the result of validation of the grouped
|
|
225
|
-
inputs. Input group's
|
|
225
|
+
inputs. Input group's state is taken from its child inputs. You
|
|
226
226
|
should always **provide validation messages for states other than valid**
|
|
227
227
|
directly through `validationTexts` prop so users know what happened and what
|
|
228
228
|
action they should take or what options they have.
|
|
@@ -230,7 +230,7 @@ action they should take or what options they have.
|
|
|
230
230
|
These messages are not semantically tied to the `children` elements, the
|
|
231
231
|
connection should be expressed in textual form in the actual message. The
|
|
232
232
|
individual `children` elements must not show any `validationText`, they only
|
|
233
|
-
show their respective `
|
|
233
|
+
show their respective `state`.
|
|
234
234
|
|
|
235
235
|
⚠️ Validation messages passed to input elements' `validationText` prop are
|
|
236
236
|
ignored within InputGroup.
|
|
@@ -252,13 +252,13 @@ for the underlying `<fieldset>` element.
|
|
|
252
252
|
label="First name"
|
|
253
253
|
placeholder="Eg. John"
|
|
254
254
|
required
|
|
255
|
-
|
|
255
|
+
state="invalid"
|
|
256
256
|
/>
|
|
257
257
|
<TextField
|
|
258
258
|
label="Last name"
|
|
259
259
|
placeholder="Eg. Doe"
|
|
260
260
|
required
|
|
261
|
-
|
|
261
|
+
state="invalid"
|
|
262
262
|
/>
|
|
263
263
|
<Button label="Submit" />
|
|
264
264
|
</InputGroup>
|
|
@@ -279,7 +279,7 @@ for the underlying `<fieldset>` element.
|
|
|
279
279
|
label="Last name"
|
|
280
280
|
placeholder="Eg. Doe"
|
|
281
281
|
required
|
|
282
|
-
|
|
282
|
+
state="warning"
|
|
283
283
|
value="123Doe"
|
|
284
284
|
/>
|
|
285
285
|
<Button label="Submit" />
|
|
@@ -292,14 +292,42 @@ for the underlying `<fieldset>` element.
|
|
|
292
292
|
label="First name"
|
|
293
293
|
placeholder="Eg. John"
|
|
294
294
|
required
|
|
295
|
-
|
|
295
|
+
state="valid"
|
|
296
296
|
value="John"
|
|
297
297
|
/>
|
|
298
298
|
<TextField
|
|
299
299
|
label="Last name"
|
|
300
300
|
placeholder="Eg. Doe"
|
|
301
301
|
required
|
|
302
|
-
|
|
302
|
+
state="valid"
|
|
303
|
+
value="Doe"
|
|
304
|
+
/>
|
|
305
|
+
<Button label="Submit" />
|
|
306
|
+
</InputGroup>
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Changed State
|
|
310
|
+
|
|
311
|
+
Changed state highlights inputs whose value differs from the saved one, so users
|
|
312
|
+
can review their edits before saving.
|
|
313
|
+
|
|
314
|
+
Input group shows one state at a time. When its inputs have different states,
|
|
315
|
+
the group takes the one that matters most to the user, in this order:
|
|
316
|
+
`invalid`, `warning`, `changed`, `valid`.
|
|
317
|
+
|
|
318
|
+
```docoff-react-preview
|
|
319
|
+
<InputGroup label="First and last name">
|
|
320
|
+
<TextField
|
|
321
|
+
label="First name"
|
|
322
|
+
onChange={() => {}}
|
|
323
|
+
placeholder="Eg. John"
|
|
324
|
+
value="John"
|
|
325
|
+
/>
|
|
326
|
+
<TextField
|
|
327
|
+
label="Last name"
|
|
328
|
+
onChange={() => {}}
|
|
329
|
+
placeholder="Eg. Doe"
|
|
330
|
+
state="changed"
|
|
303
331
|
value="Doe"
|
|
304
332
|
/>
|
|
305
333
|
<Button label="Submit" />
|
|
@@ -210,7 +210,7 @@ have.
|
|
|
210
210
|
onChange={(e) => setFruit(e.target.value)}
|
|
211
211
|
options={options}
|
|
212
212
|
required
|
|
213
|
-
|
|
213
|
+
state="valid"
|
|
214
214
|
validationText="Great, they're in stock!"
|
|
215
215
|
value={fruit}
|
|
216
216
|
/>
|
|
@@ -219,7 +219,7 @@ have.
|
|
|
219
219
|
onChange={(e) => setFruit(e.target.value)}
|
|
220
220
|
options={options}
|
|
221
221
|
required
|
|
222
|
-
|
|
222
|
+
state="warning"
|
|
223
223
|
validationText="Oh, really?"
|
|
224
224
|
value={fruit}
|
|
225
225
|
/>
|
|
@@ -228,7 +228,7 @@ have.
|
|
|
228
228
|
onChange={(e) => setFruit(e.target.value)}
|
|
229
229
|
options={options}
|
|
230
230
|
required
|
|
231
|
-
|
|
231
|
+
state="invalid"
|
|
232
232
|
validationText="You must select one kind of fruit."
|
|
233
233
|
value={fruit}
|
|
234
234
|
/>
|
|
@@ -237,6 +237,43 @@ have.
|
|
|
237
237
|
})
|
|
238
238
|
```
|
|
239
239
|
|
|
240
|
+
### Changed State
|
|
241
|
+
|
|
242
|
+
Changed state highlights fields whose value differs from the saved one, so users
|
|
243
|
+
can review their edits before saving.
|
|
244
|
+
|
|
245
|
+
A field shows one state at a time. When a changed value is also invalid, it's
|
|
246
|
+
up to you to pick the state that matters more to the user.
|
|
247
|
+
|
|
248
|
+
```docoff-react-preview
|
|
249
|
+
React.createElement(() => {
|
|
250
|
+
const [fruit, setFruit] = React.useState('banana');
|
|
251
|
+
const options = [
|
|
252
|
+
{
|
|
253
|
+
label: 'Apple',
|
|
254
|
+
value: 'apple',
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
label: 'Banana',
|
|
258
|
+
value: 'banana',
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
label: 'Grapefruit',
|
|
262
|
+
value: 'grapefruit',
|
|
263
|
+
},
|
|
264
|
+
];
|
|
265
|
+
return (
|
|
266
|
+
<Radio
|
|
267
|
+
label="Your favourite fruit"
|
|
268
|
+
onChange={(e) => setFruit(e.target.value)}
|
|
269
|
+
options={options}
|
|
270
|
+
state="changed"
|
|
271
|
+
value={fruit}
|
|
272
|
+
/>
|
|
273
|
+
);
|
|
274
|
+
})
|
|
275
|
+
```
|
|
276
|
+
|
|
240
277
|
### Required State
|
|
241
278
|
|
|
242
279
|
The required state indicates that the input is mandatory.
|
|
@@ -57,16 +57,20 @@
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// States
|
|
60
|
+
.isRootStateChanged {
|
|
61
|
+
@include variants.state(changed);
|
|
62
|
+
}
|
|
63
|
+
|
|
60
64
|
.isRootStateInvalid {
|
|
61
|
-
@include variants.
|
|
65
|
+
@include variants.state(invalid);
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
.isRootStateValid {
|
|
65
|
-
@include variants.
|
|
69
|
+
@include variants.state(valid);
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
.isRootStateWarning {
|
|
69
|
-
@include variants.
|
|
73
|
+
@include variants.state(warning);
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
// Layouts
|
|
@@ -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 { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
|
7
7
|
import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
|
|
8
8
|
import styles from './Radio.module.scss';
|
|
@@ -18,7 +18,7 @@ export const Radio: React.FunctionComponent<RadioProps> = ({
|
|
|
18
18
|
options,
|
|
19
19
|
renderAsRequired = false,
|
|
20
20
|
required = false,
|
|
21
|
-
|
|
21
|
+
state,
|
|
22
22
|
validationText,
|
|
23
23
|
value,
|
|
24
24
|
...restProps
|
|
@@ -35,7 +35,7 @@ export const Radio: React.FunctionComponent<RadioProps> = ({
|
|
|
35
35
|
: styles.isRootLayoutVertical,
|
|
36
36
|
disabled && styles.isRootDisabled,
|
|
37
37
|
(renderAsRequired || required) && styles.isRootRequired,
|
|
38
|
-
|
|
38
|
+
getRootStateClassName(styles, state),
|
|
39
39
|
)}
|
|
40
40
|
disabled={disabled}
|
|
41
41
|
id={id}
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
} from 'react';
|
|
5
5
|
import type {
|
|
6
6
|
Layout,
|
|
7
|
-
|
|
7
|
+
State,
|
|
8
8
|
} from '../../types';
|
|
9
9
|
|
|
10
10
|
export type RadioOption = {
|
|
@@ -76,9 +76,10 @@ export type RadioProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'v
|
|
|
76
76
|
*/
|
|
77
77
|
required?: boolean;
|
|
78
78
|
/**
|
|
79
|
-
* Alter the field to
|
|
79
|
+
* Alter the field to reflect the state of its data, e.g. a validation result or a change
|
|
80
|
+
* against the saved value.
|
|
80
81
|
*/
|
|
81
|
-
|
|
82
|
+
state?: State;
|
|
82
83
|
/**
|
|
83
84
|
* Validation message to be displayed.
|
|
84
85
|
*/
|
|
@@ -534,7 +534,7 @@ React.createElement(() => {
|
|
|
534
534
|
onChange={(e) => setFruit(e.target.value)}
|
|
535
535
|
options={options}
|
|
536
536
|
required
|
|
537
|
-
|
|
537
|
+
state="valid"
|
|
538
538
|
validationText="Great, they're in stock!"
|
|
539
539
|
value={fruit}
|
|
540
540
|
/>
|
|
@@ -543,7 +543,7 @@ React.createElement(() => {
|
|
|
543
543
|
onChange={(e) => setFruit(e.target.value)}
|
|
544
544
|
options={options}
|
|
545
545
|
required
|
|
546
|
-
|
|
546
|
+
state="warning"
|
|
547
547
|
validationText="Oh, really?"
|
|
548
548
|
value={fruit}
|
|
549
549
|
/>
|
|
@@ -552,7 +552,7 @@ React.createElement(() => {
|
|
|
552
552
|
onChange={(e) => setFruit(e.target.value)}
|
|
553
553
|
options={options}
|
|
554
554
|
required
|
|
555
|
-
|
|
555
|
+
state="invalid"
|
|
556
556
|
validationText="You must select at least one kind of fruit."
|
|
557
557
|
value={fruit}
|
|
558
558
|
/>
|
|
@@ -561,7 +561,7 @@ React.createElement(() => {
|
|
|
561
561
|
onChange={(e) => setFruit(e.target.value)}
|
|
562
562
|
options={options}
|
|
563
563
|
required
|
|
564
|
-
|
|
564
|
+
state="valid"
|
|
565
565
|
validationText="Great, they're in stock!"
|
|
566
566
|
value={fruit}
|
|
567
567
|
variant="filled"
|
|
@@ -571,7 +571,7 @@ React.createElement(() => {
|
|
|
571
571
|
onChange={(e) => setFruit(e.target.value)}
|
|
572
572
|
options={options}
|
|
573
573
|
required
|
|
574
|
-
|
|
574
|
+
state="warning"
|
|
575
575
|
validationText="Oh, really?"
|
|
576
576
|
value={fruit}
|
|
577
577
|
variant="filled"
|
|
@@ -582,7 +582,7 @@ React.createElement(() => {
|
|
|
582
582
|
options={options}
|
|
583
583
|
required
|
|
584
584
|
value={fruit}
|
|
585
|
-
|
|
585
|
+
state="invalid"
|
|
586
586
|
validationText="You must select at least one kind of fruit."
|
|
587
587
|
variant="filled"
|
|
588
588
|
/>
|
|
@@ -591,6 +591,53 @@ React.createElement(() => {
|
|
|
591
591
|
})
|
|
592
592
|
```
|
|
593
593
|
|
|
594
|
+
### Changed State
|
|
595
|
+
|
|
596
|
+
Changed state highlights fields whose value differs from the saved one, so users
|
|
597
|
+
can review their edits before saving.
|
|
598
|
+
|
|
599
|
+
A field shows one state at a time. When a changed value is also invalid, it's
|
|
600
|
+
up to you to pick the state that matters more to the user.
|
|
601
|
+
|
|
602
|
+
```docoff-react-preview
|
|
603
|
+
React.createElement(() => {
|
|
604
|
+
const [fruit, setFruit] = React.useState('banana');
|
|
605
|
+
const options = [
|
|
606
|
+
{
|
|
607
|
+
label: 'Apple',
|
|
608
|
+
value: 'apple',
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
label: 'Banana',
|
|
612
|
+
value: 'banana',
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
label: 'Grapefruit',
|
|
616
|
+
value: 'grapefruit',
|
|
617
|
+
},
|
|
618
|
+
];
|
|
619
|
+
return (
|
|
620
|
+
<>
|
|
621
|
+
<SelectField
|
|
622
|
+
label="Your favourite fruit"
|
|
623
|
+
onChange={(e) => setFruit(e.target.value)}
|
|
624
|
+
options={options}
|
|
625
|
+
state="changed"
|
|
626
|
+
value={fruit}
|
|
627
|
+
/>
|
|
628
|
+
<SelectField
|
|
629
|
+
label="Your favourite fruit"
|
|
630
|
+
onChange={(e) => setFruit(e.target.value)}
|
|
631
|
+
options={options}
|
|
632
|
+
state="changed"
|
|
633
|
+
value={fruit}
|
|
634
|
+
variant="filled"
|
|
635
|
+
/>
|
|
636
|
+
</>
|
|
637
|
+
);
|
|
638
|
+
})
|
|
639
|
+
```
|
|
640
|
+
|
|
594
641
|
### Required State
|
|
595
642
|
|
|
596
643
|
The required state indicates that the input is mandatory.
|
|
@@ -56,16 +56,20 @@
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// States
|
|
59
|
+
.isRootStateChanged {
|
|
60
|
+
@include variants.state(changed);
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
.isRootStateInvalid {
|
|
60
|
-
@include variants.
|
|
64
|
+
@include variants.state(invalid);
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
.isRootStateValid {
|
|
64
|
-
@include variants.
|
|
68
|
+
@include variants.state(valid);
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
.isRootStateWarning {
|
|
68
|
-
@include variants.
|
|
72
|
+
@include variants.state(warning);
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
// Invisible label
|
|
@@ -3,7 +3,7 @@ import { withGlobalProps } from '../../providers/globalProps';
|
|
|
3
3
|
import { classNames } from '../../helpers/classNames/classNames';
|
|
4
4
|
import { transferProps } from '../../helpers/transferProps';
|
|
5
5
|
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
|
6
|
-
import {
|
|
6
|
+
import { getRootStateClassName } from '../_helpers/getRootStateClassName';
|
|
7
7
|
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
|
8
8
|
import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
|
|
9
9
|
import { FormLayoutCustomFieldContext } from '../FormLayout/FormLayoutCustomFieldContext';
|
|
@@ -28,7 +28,7 @@ export const SelectField = React.forwardRef<HTMLSelectElement, SelectFieldProps>
|
|
|
28
28
|
renderAsRequired = false,
|
|
29
29
|
required = false,
|
|
30
30
|
size = 'medium',
|
|
31
|
-
|
|
31
|
+
state,
|
|
32
32
|
validationText,
|
|
33
33
|
variant = 'outline',
|
|
34
34
|
...restProps
|
|
@@ -53,7 +53,7 @@ export const SelectField = React.forwardRef<HTMLSelectElement, SelectFieldProps>
|
|
|
53
53
|
styles,
|
|
54
54
|
resolveContextOrProp(inputGroupContext && inputGroupContext.size, size),
|
|
55
55
|
),
|
|
56
|
-
|
|
56
|
+
getRootStateClassName(styles, state),
|
|
57
57
|
variant === 'filled' ? styles.isRootVariantFilled : styles.isRootVariantOutline,
|
|
58
58
|
)}
|
|
59
59
|
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 SelectFieldOption = {
|
|
@@ -103,9 +103,10 @@ export type SelectFieldProps = Omit<SelectHTMLAttributes<HTMLSelectElement>, 'si
|
|
|
103
103
|
*/
|
|
104
104
|
size?: Size;
|
|
105
105
|
/**
|
|
106
|
-
* Alter the field to
|
|
106
|
+
* Alter the field to reflect the state of its data, e.g. a validation result or a change
|
|
107
|
+
* against the saved value.
|
|
107
108
|
*/
|
|
108
|
-
|
|
109
|
+
state?: State;
|
|
109
110
|
/**
|
|
110
111
|
* Validation message to be displayed.
|
|
111
112
|
*
|
|
@@ -252,7 +252,7 @@ what happened and what action they should take or what options they have.
|
|
|
252
252
|
<TextArea
|
|
253
253
|
label="Your feedback"
|
|
254
254
|
onChange={() => {}}
|
|
255
|
-
|
|
255
|
+
state="valid"
|
|
256
256
|
validationText="Looks good!"
|
|
257
257
|
value="Like that!"
|
|
258
258
|
required
|
|
@@ -260,21 +260,21 @@ what happened and what action they should take or what options they have.
|
|
|
260
260
|
<TextArea
|
|
261
261
|
label="Your feedback"
|
|
262
262
|
onChange={() => {}}
|
|
263
|
-
|
|
263
|
+
state="warning"
|
|
264
264
|
validationText="The feedback should be at least 3 characters long."
|
|
265
265
|
value=".."
|
|
266
266
|
required
|
|
267
267
|
/>
|
|
268
268
|
<TextArea
|
|
269
269
|
label="Your feedback"
|
|
270
|
-
|
|
270
|
+
state="invalid"
|
|
271
271
|
validationText="Please share your feedback with us."
|
|
272
272
|
required
|
|
273
273
|
/>
|
|
274
274
|
<TextArea
|
|
275
275
|
label="Your feedback"
|
|
276
276
|
onChange={() => {}}
|
|
277
|
-
|
|
277
|
+
state="valid"
|
|
278
278
|
validationText="Looks good!"
|
|
279
279
|
variant="filled"
|
|
280
280
|
value="Like that!"
|
|
@@ -283,7 +283,7 @@ what happened and what action they should take or what options they have.
|
|
|
283
283
|
<TextArea
|
|
284
284
|
label="Your feedback"
|
|
285
285
|
onChange={() => {}}
|
|
286
|
-
|
|
286
|
+
state="warning"
|
|
287
287
|
validationText="The feedback should be at least 3 characters long."
|
|
288
288
|
variant="filled"
|
|
289
289
|
value=".."
|
|
@@ -291,13 +291,37 @@ what happened and what action they should take or what options they have.
|
|
|
291
291
|
/>
|
|
292
292
|
<TextArea
|
|
293
293
|
label="Your feedback"
|
|
294
|
-
|
|
294
|
+
state="invalid"
|
|
295
295
|
validationText="Please share your feedback with us."
|
|
296
296
|
variant="filled"
|
|
297
297
|
required
|
|
298
298
|
/>
|
|
299
299
|
```
|
|
300
300
|
|
|
301
|
+
### Changed State
|
|
302
|
+
|
|
303
|
+
Changed state highlights fields whose value differs from the saved one, so users
|
|
304
|
+
can review their edits before saving.
|
|
305
|
+
|
|
306
|
+
A field shows one state at a time. When a changed value is also invalid, it's
|
|
307
|
+
up to you to pick the state that matters more to the user.
|
|
308
|
+
|
|
309
|
+
```docoff-react-preview
|
|
310
|
+
<TextArea
|
|
311
|
+
label="Your feedback"
|
|
312
|
+
onChange={() => {}}
|
|
313
|
+
state="changed"
|
|
314
|
+
value="Like that!"
|
|
315
|
+
/>
|
|
316
|
+
<TextArea
|
|
317
|
+
label="Your feedback"
|
|
318
|
+
onChange={() => {}}
|
|
319
|
+
state="changed"
|
|
320
|
+
variant="filled"
|
|
321
|
+
value="Like that!"
|
|
322
|
+
/>
|
|
323
|
+
```
|
|
324
|
+
|
|
301
325
|
### Disabled State
|
|
302
326
|
|
|
303
327
|
It's possible to disable the whole input.
|
|
@@ -47,16 +47,20 @@
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// States
|
|
50
|
+
.isRootStateChanged {
|
|
51
|
+
@include variants.state(changed);
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
.isRootStateInvalid {
|
|
51
|
-
@include variants.
|
|
55
|
+
@include variants.state(invalid);
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
.isRootStateValid {
|
|
55
|
-
@include variants.
|
|
59
|
+
@include variants.state(valid);
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
.isRootStateWarning {
|
|
59
|
-
@include variants.
|
|
63
|
+
@include variants.state(warning);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
// Invisible label
|
|
@@ -3,7 +3,7 @@ import { withGlobalProps } from '../../providers/globalProps';
|
|
|
3
3
|
import { classNames } from '../../helpers/classNames/classNames';
|
|
4
4
|
import { transferProps } from '../../helpers/transferProps';
|
|
5
5
|
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
|
6
|
-
import {
|
|
6
|
+
import { getRootStateClassName } from '../_helpers/getRootStateClassName';
|
|
7
7
|
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
|
8
8
|
import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
|
|
9
9
|
import { FormLayoutCustomFieldContext } from '../FormLayout/FormLayoutCustomFieldContext';
|
|
@@ -20,7 +20,7 @@ export const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(({
|
|
|
20
20
|
layout = 'vertical',
|
|
21
21
|
required = false,
|
|
22
22
|
size = 'medium',
|
|
23
|
-
|
|
23
|
+
state,
|
|
24
24
|
validationText,
|
|
25
25
|
variant = 'outline',
|
|
26
26
|
...restProps
|
|
@@ -40,7 +40,7 @@ export const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(({
|
|
|
40
40
|
disabled && styles.isRootDisabled,
|
|
41
41
|
required && styles.isRootRequired,
|
|
42
42
|
getRootSizeClassName(styles, size),
|
|
43
|
-
|
|
43
|
+
getRootStateClassName(styles, state),
|
|
44
44
|
variant === 'filled' ? styles.isRootVariantFilled : styles.isRootVariantOutline,
|
|
45
45
|
)}
|
|
46
46
|
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 TextAreaVariant = 'filled' | 'outline';
|
|
@@ -61,9 +61,10 @@ export type TextAreaProps = TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
|
61
61
|
*/
|
|
62
62
|
size?: Size;
|
|
63
63
|
/**
|
|
64
|
-
* Alter the field to
|
|
64
|
+
* Alter the field to reflect the state of its data, e.g. a validation result or a change
|
|
65
|
+
* against the saved value.
|
|
65
66
|
*/
|
|
66
|
-
|
|
67
|
+
state?: State;
|
|
67
68
|
/**
|
|
68
69
|
* Validation message to be displayed.
|
|
69
70
|
*/
|