@khanacademy/wonder-blocks-form 6.0.5 → 7.0.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/CHANGELOG.md +20 -0
- package/dist/components/checkbox-core.d.ts +4 -4
- package/dist/components/checkbox.d.ts +7 -7
- package/dist/components/choice-internal.d.ts +7 -7
- package/dist/components/choice.d.ts +9 -9
- package/dist/components/field-heading.d.ts +0 -4
- package/dist/components/labeled-text-field.d.ts +0 -5
- package/dist/components/radio-core.d.ts +4 -4
- package/dist/components/radio.d.ts +7 -7
- package/dist/components/text-area.d.ts +26 -30
- package/dist/components/text-field.d.ts +0 -4
- package/dist/es/index.js +18 -137
- package/dist/index.js +18 -137
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-form
|
|
2
2
|
|
|
3
|
+
## 7.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 8d26588f: Remove `light` variant from LabeledTextField, TextField and TextArea"
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [0de25cd8]
|
|
12
|
+
- @khanacademy/wonder-blocks-tokens@4.0.0
|
|
13
|
+
- @khanacademy/wonder-blocks-clickable@5.0.6
|
|
14
|
+
- @khanacademy/wonder-blocks-layout@3.0.6
|
|
15
|
+
|
|
16
|
+
## 6.0.6
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- d9bc865b: TextField and TextArea: Set `aria-required` if it is required
|
|
21
|
+
- d9bc865b: TextField and TextArea validation: Always clear error message onChange if instantValidation=false so externally set error state can still be cleared
|
|
22
|
+
|
|
3
23
|
## 6.0.5
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -4,14 +4,14 @@ import type { Checked } from "../util/types";
|
|
|
4
4
|
* The internal stateless ☑️ Checkbox
|
|
5
5
|
*/
|
|
6
6
|
declare const CheckboxCore: React.ForwardRefExoticComponent<Readonly<import("@khanacademy/wonder-blocks-core").AriaAttributes> & Readonly<{
|
|
7
|
-
role?: import("@khanacademy/wonder-blocks-core").AriaRole
|
|
7
|
+
role?: import("@khanacademy/wonder-blocks-core").AriaRole;
|
|
8
8
|
}> & {
|
|
9
9
|
checked: Checked;
|
|
10
10
|
disabled: boolean;
|
|
11
11
|
error: boolean;
|
|
12
|
-
groupName?: string
|
|
13
|
-
id?: string
|
|
14
|
-
testId?: string
|
|
12
|
+
groupName?: string;
|
|
13
|
+
id?: string;
|
|
14
|
+
testId?: string;
|
|
15
15
|
onClick: () => void;
|
|
16
16
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
17
17
|
export default CheckboxCore;
|
|
@@ -23,7 +23,7 @@ import type { Checked } from "../util/types";
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
declare const Checkbox: React.ForwardRefExoticComponent<Readonly<import("@khanacademy/wonder-blocks-core").AriaAttributes> & Readonly<{
|
|
26
|
-
role?: import("@khanacademy/wonder-blocks-core").AriaRole
|
|
26
|
+
role?: import("@khanacademy/wonder-blocks-core").AriaRole;
|
|
27
27
|
}> & {
|
|
28
28
|
/**
|
|
29
29
|
* Whether this component is checked or indeterminate
|
|
@@ -32,11 +32,11 @@ declare const Checkbox: React.ForwardRefExoticComponent<Readonly<import("@khanac
|
|
|
32
32
|
/**
|
|
33
33
|
* Whether this component is disabled
|
|
34
34
|
*/
|
|
35
|
-
disabled?: boolean
|
|
35
|
+
disabled?: boolean;
|
|
36
36
|
/**
|
|
37
37
|
* Whether this component should show an error state
|
|
38
38
|
*/
|
|
39
|
-
error?: boolean
|
|
39
|
+
error?: boolean;
|
|
40
40
|
/**
|
|
41
41
|
* Callback when this component is selected. The newCheckedState is the
|
|
42
42
|
* new checked state of the component.
|
|
@@ -55,7 +55,7 @@ declare const Checkbox: React.ForwardRefExoticComponent<Readonly<import("@khanac
|
|
|
55
55
|
* guarantee that the ID is unique within everything rendered on a page.
|
|
56
56
|
* Used to match `<label>` with `<input>` elements for screenreaders.
|
|
57
57
|
*/
|
|
58
|
-
id?: string
|
|
58
|
+
id?: string;
|
|
59
59
|
/**
|
|
60
60
|
* Optional styling for the container. Does not style the component.
|
|
61
61
|
*/
|
|
@@ -63,16 +63,16 @@ declare const Checkbox: React.ForwardRefExoticComponent<Readonly<import("@khanac
|
|
|
63
63
|
/**
|
|
64
64
|
* Adds CSS classes to the Checkbox.
|
|
65
65
|
*/
|
|
66
|
-
className?: string
|
|
66
|
+
className?: string;
|
|
67
67
|
/**
|
|
68
68
|
* Optional test ID for e2e testing
|
|
69
69
|
*/
|
|
70
|
-
testId?: string
|
|
70
|
+
testId?: string;
|
|
71
71
|
/**
|
|
72
72
|
* Name for the checkbox or radio button group. Only applicable for group
|
|
73
73
|
* contexts, auto-populated by group components via Choice.
|
|
74
74
|
* @ignore
|
|
75
75
|
*/
|
|
76
|
-
groupName?: string
|
|
76
|
+
groupName?: string;
|
|
77
77
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
78
78
|
export default Checkbox;
|
|
@@ -8,21 +8,21 @@ import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
|
8
8
|
* example, we can make onChange a required prop on Checkbox but not on Choice
|
|
9
9
|
* (because for Choice, that prop would be auto-populated by CheckboxGroup).
|
|
10
10
|
*/ declare const ChoiceInternal: React.ForwardRefExoticComponent<Readonly<import("@khanacademy/wonder-blocks-core").AriaAttributes> & Readonly<{
|
|
11
|
-
role?: import("@khanacademy/wonder-blocks-core").AriaRole
|
|
11
|
+
role?: import("@khanacademy/wonder-blocks-core").AriaRole;
|
|
12
12
|
}> & {
|
|
13
13
|
/** Whether this choice is checked. */
|
|
14
14
|
checked: boolean | null | undefined;
|
|
15
15
|
/** Whether this choice option is disabled. */
|
|
16
|
-
disabled?: boolean
|
|
16
|
+
disabled?: boolean;
|
|
17
17
|
/** Whether this choice is in error mode. */
|
|
18
|
-
error?: boolean
|
|
18
|
+
error?: boolean;
|
|
19
19
|
/** Returns the new checked state of the component. */
|
|
20
20
|
onChange: (newCheckedState: boolean) => unknown;
|
|
21
21
|
/**
|
|
22
22
|
* Used for accessibility purposes, where the label id should match the
|
|
23
23
|
* input id.
|
|
24
24
|
*/
|
|
25
|
-
id?: string
|
|
25
|
+
id?: string;
|
|
26
26
|
/**
|
|
27
27
|
* Optional additional styling.
|
|
28
28
|
*/
|
|
@@ -30,11 +30,11 @@ import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
|
30
30
|
/**
|
|
31
31
|
* Adds CSS classes to the Button.
|
|
32
32
|
*/
|
|
33
|
-
className?: string
|
|
33
|
+
className?: string;
|
|
34
34
|
/**
|
|
35
35
|
* Optional id for testing purposes.
|
|
36
36
|
*/
|
|
37
|
-
testId?: string
|
|
37
|
+
testId?: string;
|
|
38
38
|
/**
|
|
39
39
|
* Label for the field.
|
|
40
40
|
*/
|
|
@@ -42,7 +42,7 @@ import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
|
42
42
|
/** Optional description for the field. */
|
|
43
43
|
description?: React.ReactNode;
|
|
44
44
|
/** Auto-populated by parent's groupName prop if in a group. */
|
|
45
|
-
groupName?: string
|
|
45
|
+
groupName?: string;
|
|
46
46
|
/** Takes either "radio" or "checkbox" value. */
|
|
47
47
|
variant: "radio" | "checkbox";
|
|
48
48
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -67,7 +67,7 @@ import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
69
|
declare const Choice: React.ForwardRefExoticComponent<Readonly<import("@khanacademy/wonder-blocks-core").AriaAttributes> & Readonly<{
|
|
70
|
-
role?: import("@khanacademy/wonder-blocks-core").AriaRole
|
|
70
|
+
role?: import("@khanacademy/wonder-blocks-core").AriaRole;
|
|
71
71
|
}> & {
|
|
72
72
|
/** User-defined. Label for the field. */
|
|
73
73
|
label: React.ReactNode;
|
|
@@ -76,42 +76,42 @@ declare const Choice: React.ForwardRefExoticComponent<Readonly<import("@khanacad
|
|
|
76
76
|
/** User-defined. Should be distinct for each item in the group. */
|
|
77
77
|
value: string;
|
|
78
78
|
/** User-defined. Whether this choice option is disabled. Default false. */
|
|
79
|
-
disabled?: boolean
|
|
79
|
+
disabled?: boolean;
|
|
80
80
|
/** User-defined. Optional id for testing purposes. */
|
|
81
|
-
testId?: string
|
|
81
|
+
testId?: string;
|
|
82
82
|
/** User-defined. Optional additional styling. */
|
|
83
83
|
style?: StyleType;
|
|
84
84
|
/**
|
|
85
85
|
* Auto-populated by parent. Whether this choice is checked.
|
|
86
86
|
* @ignore
|
|
87
87
|
*/
|
|
88
|
-
checked?: boolean
|
|
88
|
+
checked?: boolean;
|
|
89
89
|
/**
|
|
90
90
|
* Auto-populated by parent. Whether this choice is in error mode (everything
|
|
91
91
|
* in a choice group would be in error mode at the same time).
|
|
92
92
|
* @ignore
|
|
93
93
|
*/
|
|
94
|
-
error?: boolean
|
|
94
|
+
error?: boolean;
|
|
95
95
|
/**
|
|
96
96
|
* Auto-populated by parent. Used for accessibility purposes, where the label
|
|
97
97
|
* id should match the input id.
|
|
98
98
|
* @ignore
|
|
99
99
|
*/
|
|
100
|
-
id?: string
|
|
100
|
+
id?: string;
|
|
101
101
|
/**
|
|
102
102
|
* Auto-populated by parent's groupName prop.
|
|
103
103
|
* @ignore
|
|
104
104
|
*/
|
|
105
|
-
groupName?: string
|
|
105
|
+
groupName?: string;
|
|
106
106
|
/**
|
|
107
107
|
* Auto-populated by parent. Returns the new checked state of the component.
|
|
108
108
|
* @ignore
|
|
109
109
|
*/
|
|
110
|
-
onChange?: (
|
|
110
|
+
onChange?: (newCheckedState: boolean) => unknown;
|
|
111
111
|
/**
|
|
112
112
|
* Auto-populated by parent.
|
|
113
113
|
* @ignore
|
|
114
114
|
*/
|
|
115
|
-
variant?: "
|
|
115
|
+
variant?: "radio" | "checkbox";
|
|
116
116
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
117
117
|
export default Choice;
|
|
@@ -36,10 +36,6 @@ type Props = {
|
|
|
36
36
|
* Optional test ID for e2e testing.
|
|
37
37
|
*/
|
|
38
38
|
testId?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Change the field’s sub-components to fit a dark background.
|
|
41
|
-
*/
|
|
42
|
-
light?: boolean;
|
|
43
39
|
};
|
|
44
40
|
/**
|
|
45
41
|
* A FieldHeading is an element that provides a label, description, and error element
|
|
@@ -91,10 +91,6 @@ type CommonProps = {
|
|
|
91
91
|
* Provide hints or examples of what to enter.
|
|
92
92
|
*/
|
|
93
93
|
placeholder?: string;
|
|
94
|
-
/**
|
|
95
|
-
* Change the field’s sub-components to fit a dark background.
|
|
96
|
-
*/
|
|
97
|
-
light: boolean;
|
|
98
94
|
/**
|
|
99
95
|
* Custom styles for the container.
|
|
100
96
|
*
|
|
@@ -137,7 +133,6 @@ type PropsWithForwardRef = Props & WithForwardRef;
|
|
|
137
133
|
type DefaultProps = {
|
|
138
134
|
type: PropsWithForwardRef["type"];
|
|
139
135
|
disabled: PropsWithForwardRef["disabled"];
|
|
140
|
-
light: PropsWithForwardRef["light"];
|
|
141
136
|
};
|
|
142
137
|
type State = {
|
|
143
138
|
/**
|
|
@@ -3,14 +3,14 @@ import type { Checked } from "../util/types";
|
|
|
3
3
|
/**
|
|
4
4
|
* The internal stateless 🔘 Radio button
|
|
5
5
|
*/ declare const RadioCore: React.ForwardRefExoticComponent<Readonly<import("@khanacademy/wonder-blocks-core").AriaAttributes> & Readonly<{
|
|
6
|
-
role?: import("@khanacademy/wonder-blocks-core").AriaRole
|
|
6
|
+
role?: import("@khanacademy/wonder-blocks-core").AriaRole;
|
|
7
7
|
}> & {
|
|
8
8
|
checked: Checked;
|
|
9
9
|
disabled: boolean;
|
|
10
10
|
error: boolean;
|
|
11
|
-
groupName?: string
|
|
12
|
-
id?: string
|
|
13
|
-
testId?: string
|
|
11
|
+
groupName?: string;
|
|
12
|
+
id?: string;
|
|
13
|
+
testId?: string;
|
|
14
14
|
onClick: () => void;
|
|
15
15
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
16
16
|
export default RadioCore;
|
|
@@ -7,7 +7,7 @@ import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
|
7
7
|
* This component should not really be used by itself because radio buttons are
|
|
8
8
|
* often grouped together. See RadioGroup.
|
|
9
9
|
*/ declare const Radio: React.ForwardRefExoticComponent<Readonly<import("@khanacademy/wonder-blocks-core").AriaAttributes> & Readonly<{
|
|
10
|
-
role?: import("@khanacademy/wonder-blocks-core").AriaRole
|
|
10
|
+
role?: import("@khanacademy/wonder-blocks-core").AriaRole;
|
|
11
11
|
}> & {
|
|
12
12
|
/**
|
|
13
13
|
* Whether this component is checked
|
|
@@ -16,11 +16,11 @@ import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
|
16
16
|
/**
|
|
17
17
|
* Whether this component is disabled
|
|
18
18
|
*/
|
|
19
|
-
disabled?: boolean
|
|
19
|
+
disabled?: boolean;
|
|
20
20
|
/**
|
|
21
21
|
* Whether this component should show an error state
|
|
22
22
|
*/
|
|
23
|
-
error?: boolean
|
|
23
|
+
error?: boolean;
|
|
24
24
|
/**
|
|
25
25
|
* Callback when this component is selected. The newCheckedState is the
|
|
26
26
|
* new checked state of the component.
|
|
@@ -39,7 +39,7 @@ import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
|
39
39
|
* guarantee that the ID is unique within everything rendered on a page.
|
|
40
40
|
* Used to match `<label>` with `<input>` elements for screenreaders.
|
|
41
41
|
*/
|
|
42
|
-
id?: string
|
|
42
|
+
id?: string;
|
|
43
43
|
/**
|
|
44
44
|
* Optional styling for the container. Does not style the component.
|
|
45
45
|
*/
|
|
@@ -47,16 +47,16 @@ import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
|
47
47
|
/**
|
|
48
48
|
* Adds CSS classes to the Checkbox.
|
|
49
49
|
*/
|
|
50
|
-
className?: string
|
|
50
|
+
className?: string;
|
|
51
51
|
/**
|
|
52
52
|
* Optional test ID for e2e testing
|
|
53
53
|
*/
|
|
54
|
-
testId?: string
|
|
54
|
+
testId?: string;
|
|
55
55
|
/**
|
|
56
56
|
* Name for the checkbox or radio button group. Only applicable for group
|
|
57
57
|
* contexts, auto-populated by group components via Choice.
|
|
58
58
|
* @ignore
|
|
59
59
|
*/
|
|
60
|
-
groupName?: string
|
|
60
|
+
groupName?: string;
|
|
61
61
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
62
62
|
export default Radio;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
3
|
declare const TextArea: React.ForwardRefExoticComponent<Readonly<import("@khanacademy/wonder-blocks-core").AriaAttributes> & Readonly<{
|
|
4
|
-
role?: import("@khanacademy/wonder-blocks-core").AriaRole
|
|
4
|
+
role?: import("@khanacademy/wonder-blocks-core").AriaRole;
|
|
5
5
|
}> & {
|
|
6
6
|
/**
|
|
7
7
|
* The text area value.
|
|
@@ -15,11 +15,11 @@ declare const TextArea: React.ForwardRefExoticComponent<Readonly<import("@khanac
|
|
|
15
15
|
* An optional unique identifier for the TextArea.
|
|
16
16
|
* If no id is specified, a unique id will be auto-generated.
|
|
17
17
|
*/
|
|
18
|
-
id?: string
|
|
18
|
+
id?: string;
|
|
19
19
|
/**
|
|
20
20
|
* Optional test ID for e2e testing.
|
|
21
21
|
*/
|
|
22
|
-
testId?: string
|
|
22
|
+
testId?: string;
|
|
23
23
|
/**
|
|
24
24
|
* Custom styles for the textarea element.
|
|
25
25
|
*/
|
|
@@ -33,39 +33,39 @@ declare const TextArea: React.ForwardRefExoticComponent<Readonly<import("@khanac
|
|
|
33
33
|
/**
|
|
34
34
|
* Provide hints or examples of what to enter.
|
|
35
35
|
*/
|
|
36
|
-
placeholder?: string
|
|
36
|
+
placeholder?: string;
|
|
37
37
|
/**
|
|
38
38
|
* Whether the text area should be disabled.
|
|
39
39
|
*/
|
|
40
|
-
disabled?: boolean
|
|
40
|
+
disabled?: boolean;
|
|
41
41
|
/**
|
|
42
42
|
* Specifies if the text area is read-only.
|
|
43
43
|
*/
|
|
44
|
-
readOnly?: boolean
|
|
44
|
+
readOnly?: boolean;
|
|
45
45
|
/**
|
|
46
46
|
* Specifies if the text area allows autocomplete.
|
|
47
47
|
*/
|
|
48
|
-
autoComplete?: "
|
|
48
|
+
autoComplete?: "on" | "off";
|
|
49
49
|
/**
|
|
50
50
|
* The name for the text area control. This is submitted along with
|
|
51
51
|
* the form data.
|
|
52
52
|
*/
|
|
53
|
-
name?: string
|
|
53
|
+
name?: string;
|
|
54
54
|
/**
|
|
55
55
|
* CSS classes for the textarea element. It is recommended that the style prop is used instead where possible
|
|
56
56
|
*/
|
|
57
|
-
className?: string
|
|
57
|
+
className?: string;
|
|
58
58
|
/**
|
|
59
59
|
* Whether this textarea should autofocus on page load.
|
|
60
60
|
*/
|
|
61
|
-
autoFocus?: boolean
|
|
61
|
+
autoFocus?: boolean;
|
|
62
62
|
/**
|
|
63
63
|
* The number of visible lines of text for the textarea.
|
|
64
64
|
* By default, 2 rows are shown.
|
|
65
65
|
* `rows` is ignored if a height is applied to the textarea using CSS.
|
|
66
66
|
* The number of rows can change if the resize control is used by the user.
|
|
67
67
|
*/
|
|
68
|
-
rows?: number
|
|
68
|
+
rows?: number;
|
|
69
69
|
/**
|
|
70
70
|
* Determines if the textarea should be checked for spelling by the browser/OS.
|
|
71
71
|
* By default, it is enabled. It will be checked for spelling when you try
|
|
@@ -74,46 +74,46 @@ declare const TextArea: React.ForwardRefExoticComponent<Readonly<import("@khanac
|
|
|
74
74
|
* **Note**: Consider disabling `spellCheck` for
|
|
75
75
|
* sensitive information (see [Security and Privacy concerns](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck#security_and_privacy_concerns) for more details)
|
|
76
76
|
*/
|
|
77
|
-
spellCheck?: boolean
|
|
77
|
+
spellCheck?: boolean;
|
|
78
78
|
/**
|
|
79
79
|
* How the control should wrap the value for form submission. If not provided,
|
|
80
80
|
* `soft` is the default behaviour. For more details, see the
|
|
81
81
|
* [wrap attribute MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#wrap)
|
|
82
82
|
*/
|
|
83
|
-
wrap?: "
|
|
83
|
+
wrap?: "hard" | "soft" | "off";
|
|
84
84
|
/**
|
|
85
85
|
* The minimum number of characters allowed in the textarea.
|
|
86
86
|
*/
|
|
87
|
-
minLength?: number
|
|
87
|
+
minLength?: number;
|
|
88
88
|
/**
|
|
89
89
|
* The maximum number of characters allowed in the textarea.
|
|
90
90
|
*/
|
|
91
|
-
maxLength?: number
|
|
91
|
+
maxLength?: number;
|
|
92
92
|
/**
|
|
93
93
|
* Called when the textarea is clicked.
|
|
94
94
|
* @param event The event from the click
|
|
95
95
|
*/
|
|
96
|
-
onClick?: React.MouseEventHandler<HTMLTextAreaElement
|
|
96
|
+
onClick?: React.MouseEventHandler<HTMLTextAreaElement>;
|
|
97
97
|
/**
|
|
98
98
|
* Called when a key is pressed.
|
|
99
99
|
* @param event The keyboard event
|
|
100
100
|
*/
|
|
101
|
-
onKeyDown?: React.KeyboardEventHandler<HTMLTextAreaElement
|
|
101
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLTextAreaElement>;
|
|
102
102
|
/**
|
|
103
103
|
* Called when a key is released.
|
|
104
104
|
* @param event The keyboard event
|
|
105
105
|
*/
|
|
106
|
-
onKeyUp?: React.KeyboardEventHandler<HTMLTextAreaElement
|
|
106
|
+
onKeyUp?: React.KeyboardEventHandler<HTMLTextAreaElement>;
|
|
107
107
|
/**
|
|
108
108
|
* Called when the element has been focused.
|
|
109
109
|
* @param event The focus event
|
|
110
110
|
*/
|
|
111
|
-
onFocus?: React.FocusEventHandler<HTMLTextAreaElement
|
|
111
|
+
onFocus?: React.FocusEventHandler<HTMLTextAreaElement>;
|
|
112
112
|
/**
|
|
113
113
|
* Called when the element has been focused.
|
|
114
114
|
* @param event The blur event
|
|
115
115
|
*/
|
|
116
|
-
onBlur?: React.FocusEventHandler<HTMLTextAreaElement
|
|
116
|
+
onBlur?: React.FocusEventHandler<HTMLTextAreaElement>;
|
|
117
117
|
/**
|
|
118
118
|
* Provide a validation for the textarea value.
|
|
119
119
|
* Return a string error message or null | void for a valid input.
|
|
@@ -121,25 +121,25 @@ declare const TextArea: React.ForwardRefExoticComponent<Readonly<import("@khanac
|
|
|
121
121
|
* Use this for errors that are shown to the user while they are filling out
|
|
122
122
|
* a form.
|
|
123
123
|
*/
|
|
124
|
-
validate?: (
|
|
124
|
+
validate?: (value: string) => string | null | void;
|
|
125
125
|
/**
|
|
126
126
|
* Called right after the textarea is validated.
|
|
127
127
|
*/
|
|
128
|
-
onValidate?: (
|
|
128
|
+
onValidate?: (errorMessage?: string | null | undefined) => unknown;
|
|
129
129
|
/**
|
|
130
130
|
* If true, textarea is validated as the user types (onChange). If false,
|
|
131
131
|
* it is validated when the user's focus moves out of the field (onBlur).
|
|
132
132
|
* It is preferred that instantValidation is set to `false`, however, it
|
|
133
133
|
* defaults to `true` for backwards compatibility with existing implementations.
|
|
134
134
|
*/
|
|
135
|
-
instantValidation?: boolean
|
|
135
|
+
instantValidation?: boolean;
|
|
136
136
|
/**
|
|
137
137
|
* Whether the textarea is in an error state.
|
|
138
138
|
*
|
|
139
139
|
* Use this for errors that are triggered by something external to the
|
|
140
140
|
* component (example: an error after form submission).
|
|
141
141
|
*/
|
|
142
|
-
error?: boolean
|
|
142
|
+
error?: boolean;
|
|
143
143
|
/**
|
|
144
144
|
* Whether this textarea is required to continue, or the error message to
|
|
145
145
|
* render if this textarea is left blank.
|
|
@@ -162,15 +162,11 @@ declare const TextArea: React.ForwardRefExoticComponent<Readonly<import("@khanac
|
|
|
162
162
|
* there is no corresponding message and the default untranlsated message
|
|
163
163
|
* will be used.
|
|
164
164
|
*/
|
|
165
|
-
required?:
|
|
165
|
+
required?: boolean | string;
|
|
166
166
|
/**
|
|
167
167
|
* Specifies the resizing behaviour for the textarea. Defaults to both
|
|
168
168
|
* behaviour. For more details, see the [CSS resize property values MDN docs](https://developer.mozilla.org/en-US/docs/Web/CSS/resize#values)
|
|
169
169
|
*/
|
|
170
|
-
resizeType?: "
|
|
171
|
-
/**
|
|
172
|
-
* Change the default focus ring color to fit a dark background.
|
|
173
|
-
*/
|
|
174
|
-
light?: boolean | undefined;
|
|
170
|
+
resizeType?: "horizontal" | "vertical" | "both" | "none";
|
|
175
171
|
} & React.RefAttributes<HTMLTextAreaElement>>;
|
|
176
172
|
export default TextArea;
|
package/dist/es/index.js
CHANGED
|
@@ -604,11 +604,9 @@ const useFieldValidation = ({
|
|
|
604
604
|
if (_instantValidation) {
|
|
605
605
|
handleValidation(newValue);
|
|
606
606
|
} else {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
onValidate(null);
|
|
611
|
-
}
|
|
607
|
+
setErrorMessage(null);
|
|
608
|
+
if (onValidate) {
|
|
609
|
+
onValidate(null);
|
|
612
610
|
}
|
|
613
611
|
}
|
|
614
612
|
};
|
|
@@ -650,7 +648,7 @@ const useFieldValidation = ({
|
|
|
650
648
|
};
|
|
651
649
|
};
|
|
652
650
|
|
|
653
|
-
const _excluded$2 = ["id", "type", "value", "name", "disabled", "
|
|
651
|
+
const _excluded$2 = ["id", "type", "value", "name", "disabled", "error", "validate", "onValidate", "required", "placeholder", "style", "testId", "readOnly", "autoFocus", "autoComplete", "forwardedRef", "instantValidation", "onKeyDown", "onChange", "onFocus", "onBlur"];
|
|
654
652
|
const StyledInput = addStyle("input");
|
|
655
653
|
const TextField = props => {
|
|
656
654
|
const {
|
|
@@ -659,7 +657,6 @@ const TextField = props => {
|
|
|
659
657
|
value,
|
|
660
658
|
name,
|
|
661
659
|
disabled = false,
|
|
662
|
-
light = false,
|
|
663
660
|
error,
|
|
664
661
|
validate,
|
|
665
662
|
onValidate,
|
|
@@ -707,22 +704,17 @@ const TextField = props => {
|
|
|
707
704
|
onBlur(event);
|
|
708
705
|
}
|
|
709
706
|
};
|
|
710
|
-
const getStyles = () => {
|
|
711
|
-
const baseStyles = [styles$2.input, styles$7.LabelMedium];
|
|
712
|
-
const defaultStyles = [styles$2.default, !disabled && styles$2.defaultFocus, disabled && styles$2.disabled, hasError && styles$2.error];
|
|
713
|
-
const lightStyles = [styles$2.light, !disabled && styles$2.lightFocus, disabled && styles$2.lightDisabled, hasError && styles$2.lightError];
|
|
714
|
-
return [...baseStyles, ...(light ? lightStyles : defaultStyles)];
|
|
715
|
-
};
|
|
716
707
|
return React.createElement(Id, {
|
|
717
708
|
id: id
|
|
718
709
|
}, uniqueId => React.createElement(StyledInput, _extends({
|
|
719
|
-
style: [
|
|
710
|
+
style: [styles$2.input, styles$7.LabelMedium, styles$2.default, !disabled && styles$2.defaultFocus, disabled && styles$2.disabled, hasError && styles$2.error, style],
|
|
720
711
|
id: uniqueId,
|
|
721
712
|
type: type,
|
|
722
713
|
placeholder: placeholder,
|
|
723
714
|
value: value,
|
|
724
715
|
name: name,
|
|
725
716
|
"aria-disabled": disabled,
|
|
717
|
+
"aria-required": !!required,
|
|
726
718
|
onChange: handleChange,
|
|
727
719
|
onKeyDown: disabled ? undefined : onKeyDown,
|
|
728
720
|
onFocus: handleFocus,
|
|
@@ -783,49 +775,6 @@ const styles$2 = StyleSheet.create({
|
|
|
783
775
|
outline: `2px solid ${color.offBlack32}`,
|
|
784
776
|
outlineOffset: "-3px"
|
|
785
777
|
}
|
|
786
|
-
},
|
|
787
|
-
light: {
|
|
788
|
-
background: color.white,
|
|
789
|
-
border: `1px solid ${color.offBlack16}`,
|
|
790
|
-
color: color.offBlack,
|
|
791
|
-
"::placeholder": {
|
|
792
|
-
color: color.offBlack64
|
|
793
|
-
}
|
|
794
|
-
},
|
|
795
|
-
lightFocus: {
|
|
796
|
-
":focus-visible": {
|
|
797
|
-
outline: `3px solid ${color.blue}`,
|
|
798
|
-
outlineOffset: "-4px",
|
|
799
|
-
borderColor: color.white
|
|
800
|
-
}
|
|
801
|
-
},
|
|
802
|
-
lightDisabled: {
|
|
803
|
-
backgroundColor: "transparent",
|
|
804
|
-
border: `1px solid ${color.white32}`,
|
|
805
|
-
color: color.white64,
|
|
806
|
-
"::placeholder": {
|
|
807
|
-
color: color.white64
|
|
808
|
-
},
|
|
809
|
-
cursor: "not-allowed",
|
|
810
|
-
":focus-visible": {
|
|
811
|
-
borderColor: mix(color.white32, color.blue),
|
|
812
|
-
outline: `3px solid ${color.fadedBlue}`,
|
|
813
|
-
outlineOffset: "-4px"
|
|
814
|
-
}
|
|
815
|
-
},
|
|
816
|
-
lightError: {
|
|
817
|
-
background: color.fadedRed8,
|
|
818
|
-
border: `1px solid ${color.white}`,
|
|
819
|
-
outline: `2px solid ${color.red}`,
|
|
820
|
-
outlineOffset: "-3px",
|
|
821
|
-
color: color.offBlack,
|
|
822
|
-
"::placeholder": {
|
|
823
|
-
color: color.offBlack64
|
|
824
|
-
},
|
|
825
|
-
":focus-visible": {
|
|
826
|
-
outline: `3px solid ${color.red}`,
|
|
827
|
-
outlineOffset: "-4px"
|
|
828
|
-
}
|
|
829
778
|
}
|
|
830
779
|
});
|
|
831
780
|
var TextField$1 = React.forwardRef((props, ref) => React.createElement(TextField, _extends({}, props, {
|
|
@@ -839,15 +788,14 @@ class FieldHeading extends React.Component {
|
|
|
839
788
|
label,
|
|
840
789
|
id,
|
|
841
790
|
required,
|
|
842
|
-
testId
|
|
843
|
-
light
|
|
791
|
+
testId
|
|
844
792
|
} = this.props;
|
|
845
793
|
const requiredIcon = React.createElement(StyledSpan, {
|
|
846
|
-
style:
|
|
794
|
+
style: styles$1.required,
|
|
847
795
|
"aria-hidden": true
|
|
848
796
|
}, " ", "*");
|
|
849
797
|
return React.createElement(React.Fragment, null, React.createElement(LabelMedium, {
|
|
850
|
-
style:
|
|
798
|
+
style: styles$1.label,
|
|
851
799
|
tag: "label",
|
|
852
800
|
htmlFor: id && `${id}-field`,
|
|
853
801
|
testId: testId && `${testId}-label`
|
|
@@ -858,14 +806,13 @@ class FieldHeading extends React.Component {
|
|
|
858
806
|
maybeRenderDescription() {
|
|
859
807
|
const {
|
|
860
808
|
description,
|
|
861
|
-
testId
|
|
862
|
-
light
|
|
809
|
+
testId
|
|
863
810
|
} = this.props;
|
|
864
811
|
if (!description) {
|
|
865
812
|
return null;
|
|
866
813
|
}
|
|
867
814
|
return React.createElement(React.Fragment, null, React.createElement(LabelSmall, {
|
|
868
|
-
style:
|
|
815
|
+
style: styles$1.description,
|
|
869
816
|
testId: testId && `${testId}-description`
|
|
870
817
|
}, description), React.createElement(Strut, {
|
|
871
818
|
size: spacing.xxxSmall_4
|
|
@@ -875,8 +822,7 @@ class FieldHeading extends React.Component {
|
|
|
875
822
|
const {
|
|
876
823
|
error,
|
|
877
824
|
id,
|
|
878
|
-
testId
|
|
879
|
-
light
|
|
825
|
+
testId
|
|
880
826
|
} = this.props;
|
|
881
827
|
if (!error) {
|
|
882
828
|
return null;
|
|
@@ -884,7 +830,7 @@ class FieldHeading extends React.Component {
|
|
|
884
830
|
return React.createElement(React.Fragment, null, React.createElement(Strut, {
|
|
885
831
|
size: spacing.small_12
|
|
886
832
|
}), React.createElement(LabelSmall, {
|
|
887
|
-
style:
|
|
833
|
+
style: styles$1.error,
|
|
888
834
|
role: "alert",
|
|
889
835
|
id: id && `${id}-error`,
|
|
890
836
|
testId: testId && `${testId}-error`
|
|
@@ -906,30 +852,18 @@ const styles$1 = StyleSheet.create({
|
|
|
906
852
|
label: {
|
|
907
853
|
color: color.offBlack
|
|
908
854
|
},
|
|
909
|
-
lightLabel: {
|
|
910
|
-
color: color.white
|
|
911
|
-
},
|
|
912
855
|
description: {
|
|
913
856
|
color: color.offBlack64
|
|
914
857
|
},
|
|
915
|
-
lightDescription: {
|
|
916
|
-
color: color.white64
|
|
917
|
-
},
|
|
918
858
|
error: {
|
|
919
859
|
color: color.red
|
|
920
860
|
},
|
|
921
|
-
lightError: {
|
|
922
|
-
color: color.fadedRed
|
|
923
|
-
},
|
|
924
861
|
required: {
|
|
925
862
|
color: color.red
|
|
926
|
-
},
|
|
927
|
-
lightRequired: {
|
|
928
|
-
color: color.fadedRed
|
|
929
863
|
}
|
|
930
864
|
});
|
|
931
865
|
|
|
932
|
-
const _excluded$1 = ["id", "type", "label", "description", "value", "disabled", "required", "validate", "onChange", "onKeyDown", "placeholder", "
|
|
866
|
+
const _excluded$1 = ["id", "type", "label", "description", "value", "disabled", "required", "validate", "onChange", "onKeyDown", "placeholder", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "ariaDescribedby", "name", "onValidate", "onFocus", "onBlur"];
|
|
933
867
|
class LabeledTextField extends React.Component {
|
|
934
868
|
constructor(props) {
|
|
935
869
|
super(props);
|
|
@@ -988,7 +922,6 @@ class LabeledTextField extends React.Component {
|
|
|
988
922
|
onChange,
|
|
989
923
|
onKeyDown,
|
|
990
924
|
placeholder,
|
|
991
|
-
light,
|
|
992
925
|
style,
|
|
993
926
|
testId,
|
|
994
927
|
readOnly,
|
|
@@ -1004,7 +937,6 @@ class LabeledTextField extends React.Component {
|
|
|
1004
937
|
id: uniqueId,
|
|
1005
938
|
testId: testId,
|
|
1006
939
|
style: style,
|
|
1007
|
-
light: light,
|
|
1008
940
|
field: React.createElement(TextField$1, _extends({
|
|
1009
941
|
id: `${uniqueId}-field`,
|
|
1010
942
|
"aria-describedby": ariaDescribedby ? ariaDescribedby : `${uniqueId}-error`,
|
|
@@ -1021,7 +953,6 @@ class LabeledTextField extends React.Component {
|
|
|
1021
953
|
onKeyDown: onKeyDown,
|
|
1022
954
|
onFocus: this.handleFocus,
|
|
1023
955
|
onBlur: this.handleBlur,
|
|
1024
|
-
light: light,
|
|
1025
956
|
readOnly: readOnly,
|
|
1026
957
|
autoComplete: autoComplete,
|
|
1027
958
|
ref: forwardedRef,
|
|
@@ -1036,14 +967,13 @@ class LabeledTextField extends React.Component {
|
|
|
1036
967
|
}
|
|
1037
968
|
LabeledTextField.defaultProps = {
|
|
1038
969
|
type: "text",
|
|
1039
|
-
disabled: false
|
|
1040
|
-
light: false
|
|
970
|
+
disabled: false
|
|
1041
971
|
};
|
|
1042
972
|
var labeledTextField = React.forwardRef((props, ref) => React.createElement(LabeledTextField, _extends({}, props, {
|
|
1043
973
|
forwardedRef: ref
|
|
1044
974
|
})));
|
|
1045
975
|
|
|
1046
|
-
const _excluded = ["onChange", "value", "placeholder", "disabled", "id", "testId", "style", "readOnly", "autoComplete", "name", "className", "autoFocus", "rows", "spellCheck", "wrap", "minLength", "maxLength", "onClick", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "validate", "onValidate", "required", "resizeType", "
|
|
976
|
+
const _excluded = ["onChange", "value", "placeholder", "disabled", "id", "testId", "style", "readOnly", "autoComplete", "name", "className", "autoFocus", "rows", "spellCheck", "wrap", "minLength", "maxLength", "onClick", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "validate", "onValidate", "required", "resizeType", "rootStyle", "error", "instantValidation"];
|
|
1047
977
|
const StyledTextArea = addStyle("textarea");
|
|
1048
978
|
const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
1049
979
|
const {
|
|
@@ -1073,7 +1003,6 @@ const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
|
1073
1003
|
onValidate,
|
|
1074
1004
|
required,
|
|
1075
1005
|
resizeType,
|
|
1076
|
-
light,
|
|
1077
1006
|
rootStyle,
|
|
1078
1007
|
error,
|
|
1079
1008
|
instantValidation = true
|
|
@@ -1105,12 +1034,6 @@ const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
|
1105
1034
|
onBlur(event);
|
|
1106
1035
|
}
|
|
1107
1036
|
};
|
|
1108
|
-
const getStyles = () => {
|
|
1109
|
-
const baseStyles = [styles.textarea, styles$7.LabelMedium, resizeType && resizeStyles[resizeType]];
|
|
1110
|
-
const defaultStyles = [styles.default, !disabled && styles.defaultFocus, disabled && styles.disabled, hasError && styles.error];
|
|
1111
|
-
const lightStyles = [styles.light, !disabled && styles.lightFocus, disabled && styles.lightDisabled, hasError && styles.lightError];
|
|
1112
|
-
return [...baseStyles, ...(light ? lightStyles : defaultStyles)];
|
|
1113
|
-
};
|
|
1114
1037
|
return React.createElement(View, {
|
|
1115
1038
|
style: [{
|
|
1116
1039
|
width: "100%"
|
|
@@ -1120,7 +1043,7 @@ const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
|
1120
1043
|
"data-testid": testId,
|
|
1121
1044
|
ref: ref,
|
|
1122
1045
|
className: className,
|
|
1123
|
-
style: [
|
|
1046
|
+
style: [styles.textarea, styles$7.LabelMedium, resizeType && resizeStyles[resizeType], styles.default, !disabled && styles.defaultFocus, disabled && styles.disabled, hasError && styles.error, style],
|
|
1124
1047
|
value: value,
|
|
1125
1048
|
onChange: handleChange,
|
|
1126
1049
|
placeholder: placeholder,
|
|
@@ -1134,6 +1057,7 @@ const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
|
1134
1057
|
wrap: wrap,
|
|
1135
1058
|
minLength: minLength,
|
|
1136
1059
|
maxLength: maxLength,
|
|
1060
|
+
"aria-required": !!required,
|
|
1137
1061
|
onClick: disabled ? undefined : onClick,
|
|
1138
1062
|
onKeyDown: disabled ? undefined : onKeyDown,
|
|
1139
1063
|
onKeyUp: disabled ? undefined : onKeyUp,
|
|
@@ -1191,49 +1115,6 @@ const styles = StyleSheet.create({
|
|
|
1191
1115
|
outlineColor: color.red,
|
|
1192
1116
|
borderColor: color.red
|
|
1193
1117
|
}
|
|
1194
|
-
},
|
|
1195
|
-
light: {
|
|
1196
|
-
background: color.white,
|
|
1197
|
-
border: `1px solid ${color.offBlack16}`,
|
|
1198
|
-
color: color.offBlack,
|
|
1199
|
-
"::placeholder": {
|
|
1200
|
-
color: color.offBlack64
|
|
1201
|
-
}
|
|
1202
|
-
},
|
|
1203
|
-
lightFocus: {
|
|
1204
|
-
":focus-visible": {
|
|
1205
|
-
outline: `3px solid ${color.blue}`,
|
|
1206
|
-
outlineOffset: "-4px",
|
|
1207
|
-
borderColor: color.white
|
|
1208
|
-
}
|
|
1209
|
-
},
|
|
1210
|
-
lightDisabled: {
|
|
1211
|
-
backgroundColor: "transparent",
|
|
1212
|
-
border: `1px solid ${color.white32}`,
|
|
1213
|
-
color: color.white64,
|
|
1214
|
-
"::placeholder": {
|
|
1215
|
-
color: color.white64
|
|
1216
|
-
},
|
|
1217
|
-
cursor: "not-allowed",
|
|
1218
|
-
":focus-visible": {
|
|
1219
|
-
borderColor: mix(color.white32, color.blue),
|
|
1220
|
-
outline: `3px solid ${color.fadedBlue}`,
|
|
1221
|
-
outlineOffset: "-4px"
|
|
1222
|
-
}
|
|
1223
|
-
},
|
|
1224
|
-
lightError: {
|
|
1225
|
-
background: color.fadedRed8,
|
|
1226
|
-
border: `1px solid ${color.white}`,
|
|
1227
|
-
outline: `2px solid ${color.red}`,
|
|
1228
|
-
outlineOffset: "-3px",
|
|
1229
|
-
color: color.offBlack,
|
|
1230
|
-
"::placeholder": {
|
|
1231
|
-
color: color.offBlack64
|
|
1232
|
-
},
|
|
1233
|
-
":focus-visible": {
|
|
1234
|
-
outline: `3px solid ${color.red}`,
|
|
1235
|
-
outlineOffset: "-4px"
|
|
1236
|
-
}
|
|
1237
1118
|
}
|
|
1238
1119
|
});
|
|
1239
1120
|
const resizeStyles = StyleSheet.create({
|
package/dist/index.js
CHANGED
|
@@ -633,11 +633,9 @@ const useFieldValidation = ({
|
|
|
633
633
|
if (_instantValidation) {
|
|
634
634
|
handleValidation(newValue);
|
|
635
635
|
} else {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
onValidate(null);
|
|
640
|
-
}
|
|
636
|
+
setErrorMessage(null);
|
|
637
|
+
if (onValidate) {
|
|
638
|
+
onValidate(null);
|
|
641
639
|
}
|
|
642
640
|
}
|
|
643
641
|
};
|
|
@@ -679,7 +677,7 @@ const useFieldValidation = ({
|
|
|
679
677
|
};
|
|
680
678
|
};
|
|
681
679
|
|
|
682
|
-
const _excluded$2 = ["id", "type", "value", "name", "disabled", "
|
|
680
|
+
const _excluded$2 = ["id", "type", "value", "name", "disabled", "error", "validate", "onValidate", "required", "placeholder", "style", "testId", "readOnly", "autoFocus", "autoComplete", "forwardedRef", "instantValidation", "onKeyDown", "onChange", "onFocus", "onBlur"];
|
|
683
681
|
const StyledInput = wonderBlocksCore.addStyle("input");
|
|
684
682
|
const TextField = props => {
|
|
685
683
|
const {
|
|
@@ -688,7 +686,6 @@ const TextField = props => {
|
|
|
688
686
|
value,
|
|
689
687
|
name,
|
|
690
688
|
disabled = false,
|
|
691
|
-
light = false,
|
|
692
689
|
error,
|
|
693
690
|
validate,
|
|
694
691
|
onValidate,
|
|
@@ -736,22 +733,17 @@ const TextField = props => {
|
|
|
736
733
|
onBlur(event);
|
|
737
734
|
}
|
|
738
735
|
};
|
|
739
|
-
const getStyles = () => {
|
|
740
|
-
const baseStyles = [styles$2.input, wonderBlocksTypography.styles.LabelMedium];
|
|
741
|
-
const defaultStyles = [styles$2.default, !disabled && styles$2.defaultFocus, disabled && styles$2.disabled, hasError && styles$2.error];
|
|
742
|
-
const lightStyles = [styles$2.light, !disabled && styles$2.lightFocus, disabled && styles$2.lightDisabled, hasError && styles$2.lightError];
|
|
743
|
-
return [...baseStyles, ...(light ? lightStyles : defaultStyles)];
|
|
744
|
-
};
|
|
745
736
|
return React__namespace.createElement(wonderBlocksCore.Id, {
|
|
746
737
|
id: id
|
|
747
738
|
}, uniqueId => React__namespace.createElement(StyledInput, _extends__default["default"]({
|
|
748
|
-
style: [
|
|
739
|
+
style: [styles$2.input, wonderBlocksTypography.styles.LabelMedium, styles$2.default, !disabled && styles$2.defaultFocus, disabled && styles$2.disabled, hasError && styles$2.error, style],
|
|
749
740
|
id: uniqueId,
|
|
750
741
|
type: type,
|
|
751
742
|
placeholder: placeholder,
|
|
752
743
|
value: value,
|
|
753
744
|
name: name,
|
|
754
745
|
"aria-disabled": disabled,
|
|
746
|
+
"aria-required": !!required,
|
|
755
747
|
onChange: handleChange,
|
|
756
748
|
onKeyDown: disabled ? undefined : onKeyDown,
|
|
757
749
|
onFocus: handleFocus,
|
|
@@ -812,49 +804,6 @@ const styles$2 = aphrodite.StyleSheet.create({
|
|
|
812
804
|
outline: `2px solid ${wonderBlocksTokens.color.offBlack32}`,
|
|
813
805
|
outlineOffset: "-3px"
|
|
814
806
|
}
|
|
815
|
-
},
|
|
816
|
-
light: {
|
|
817
|
-
background: wonderBlocksTokens.color.white,
|
|
818
|
-
border: `1px solid ${wonderBlocksTokens.color.offBlack16}`,
|
|
819
|
-
color: wonderBlocksTokens.color.offBlack,
|
|
820
|
-
"::placeholder": {
|
|
821
|
-
color: wonderBlocksTokens.color.offBlack64
|
|
822
|
-
}
|
|
823
|
-
},
|
|
824
|
-
lightFocus: {
|
|
825
|
-
":focus-visible": {
|
|
826
|
-
outline: `3px solid ${wonderBlocksTokens.color.blue}`,
|
|
827
|
-
outlineOffset: "-4px",
|
|
828
|
-
borderColor: wonderBlocksTokens.color.white
|
|
829
|
-
}
|
|
830
|
-
},
|
|
831
|
-
lightDisabled: {
|
|
832
|
-
backgroundColor: "transparent",
|
|
833
|
-
border: `1px solid ${wonderBlocksTokens.color.white32}`,
|
|
834
|
-
color: wonderBlocksTokens.color.white64,
|
|
835
|
-
"::placeholder": {
|
|
836
|
-
color: wonderBlocksTokens.color.white64
|
|
837
|
-
},
|
|
838
|
-
cursor: "not-allowed",
|
|
839
|
-
":focus-visible": {
|
|
840
|
-
borderColor: wonderBlocksTokens.mix(wonderBlocksTokens.color.white32, wonderBlocksTokens.color.blue),
|
|
841
|
-
outline: `3px solid ${wonderBlocksTokens.color.fadedBlue}`,
|
|
842
|
-
outlineOffset: "-4px"
|
|
843
|
-
}
|
|
844
|
-
},
|
|
845
|
-
lightError: {
|
|
846
|
-
background: wonderBlocksTokens.color.fadedRed8,
|
|
847
|
-
border: `1px solid ${wonderBlocksTokens.color.white}`,
|
|
848
|
-
outline: `2px solid ${wonderBlocksTokens.color.red}`,
|
|
849
|
-
outlineOffset: "-3px",
|
|
850
|
-
color: wonderBlocksTokens.color.offBlack,
|
|
851
|
-
"::placeholder": {
|
|
852
|
-
color: wonderBlocksTokens.color.offBlack64
|
|
853
|
-
},
|
|
854
|
-
":focus-visible": {
|
|
855
|
-
outline: `3px solid ${wonderBlocksTokens.color.red}`,
|
|
856
|
-
outlineOffset: "-4px"
|
|
857
|
-
}
|
|
858
807
|
}
|
|
859
808
|
});
|
|
860
809
|
var TextField$1 = React__namespace.forwardRef((props, ref) => React__namespace.createElement(TextField, _extends__default["default"]({}, props, {
|
|
@@ -868,15 +817,14 @@ class FieldHeading extends React__namespace.Component {
|
|
|
868
817
|
label,
|
|
869
818
|
id,
|
|
870
819
|
required,
|
|
871
|
-
testId
|
|
872
|
-
light
|
|
820
|
+
testId
|
|
873
821
|
} = this.props;
|
|
874
822
|
const requiredIcon = React__namespace.createElement(StyledSpan, {
|
|
875
|
-
style:
|
|
823
|
+
style: styles$1.required,
|
|
876
824
|
"aria-hidden": true
|
|
877
825
|
}, " ", "*");
|
|
878
826
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
|
|
879
|
-
style:
|
|
827
|
+
style: styles$1.label,
|
|
880
828
|
tag: "label",
|
|
881
829
|
htmlFor: id && `${id}-field`,
|
|
882
830
|
testId: testId && `${testId}-label`
|
|
@@ -887,14 +835,13 @@ class FieldHeading extends React__namespace.Component {
|
|
|
887
835
|
maybeRenderDescription() {
|
|
888
836
|
const {
|
|
889
837
|
description,
|
|
890
|
-
testId
|
|
891
|
-
light
|
|
838
|
+
testId
|
|
892
839
|
} = this.props;
|
|
893
840
|
if (!description) {
|
|
894
841
|
return null;
|
|
895
842
|
}
|
|
896
843
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
|
|
897
|
-
style:
|
|
844
|
+
style: styles$1.description,
|
|
898
845
|
testId: testId && `${testId}-description`
|
|
899
846
|
}, description), React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
900
847
|
size: wonderBlocksTokens.spacing.xxxSmall_4
|
|
@@ -904,8 +851,7 @@ class FieldHeading extends React__namespace.Component {
|
|
|
904
851
|
const {
|
|
905
852
|
error,
|
|
906
853
|
id,
|
|
907
|
-
testId
|
|
908
|
-
light
|
|
854
|
+
testId
|
|
909
855
|
} = this.props;
|
|
910
856
|
if (!error) {
|
|
911
857
|
return null;
|
|
@@ -913,7 +859,7 @@ class FieldHeading extends React__namespace.Component {
|
|
|
913
859
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
914
860
|
size: wonderBlocksTokens.spacing.small_12
|
|
915
861
|
}), React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
|
|
916
|
-
style:
|
|
862
|
+
style: styles$1.error,
|
|
917
863
|
role: "alert",
|
|
918
864
|
id: id && `${id}-error`,
|
|
919
865
|
testId: testId && `${testId}-error`
|
|
@@ -935,30 +881,18 @@ const styles$1 = aphrodite.StyleSheet.create({
|
|
|
935
881
|
label: {
|
|
936
882
|
color: wonderBlocksTokens.color.offBlack
|
|
937
883
|
},
|
|
938
|
-
lightLabel: {
|
|
939
|
-
color: wonderBlocksTokens.color.white
|
|
940
|
-
},
|
|
941
884
|
description: {
|
|
942
885
|
color: wonderBlocksTokens.color.offBlack64
|
|
943
886
|
},
|
|
944
|
-
lightDescription: {
|
|
945
|
-
color: wonderBlocksTokens.color.white64
|
|
946
|
-
},
|
|
947
887
|
error: {
|
|
948
888
|
color: wonderBlocksTokens.color.red
|
|
949
889
|
},
|
|
950
|
-
lightError: {
|
|
951
|
-
color: wonderBlocksTokens.color.fadedRed
|
|
952
|
-
},
|
|
953
890
|
required: {
|
|
954
891
|
color: wonderBlocksTokens.color.red
|
|
955
|
-
},
|
|
956
|
-
lightRequired: {
|
|
957
|
-
color: wonderBlocksTokens.color.fadedRed
|
|
958
892
|
}
|
|
959
893
|
});
|
|
960
894
|
|
|
961
|
-
const _excluded$1 = ["id", "type", "label", "description", "value", "disabled", "required", "validate", "onChange", "onKeyDown", "placeholder", "
|
|
895
|
+
const _excluded$1 = ["id", "type", "label", "description", "value", "disabled", "required", "validate", "onChange", "onKeyDown", "placeholder", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "ariaDescribedby", "name", "onValidate", "onFocus", "onBlur"];
|
|
962
896
|
class LabeledTextField extends React__namespace.Component {
|
|
963
897
|
constructor(props) {
|
|
964
898
|
super(props);
|
|
@@ -1017,7 +951,6 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
1017
951
|
onChange,
|
|
1018
952
|
onKeyDown,
|
|
1019
953
|
placeholder,
|
|
1020
|
-
light,
|
|
1021
954
|
style,
|
|
1022
955
|
testId,
|
|
1023
956
|
readOnly,
|
|
@@ -1033,7 +966,6 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
1033
966
|
id: uniqueId,
|
|
1034
967
|
testId: testId,
|
|
1035
968
|
style: style,
|
|
1036
|
-
light: light,
|
|
1037
969
|
field: React__namespace.createElement(TextField$1, _extends__default["default"]({
|
|
1038
970
|
id: `${uniqueId}-field`,
|
|
1039
971
|
"aria-describedby": ariaDescribedby ? ariaDescribedby : `${uniqueId}-error`,
|
|
@@ -1050,7 +982,6 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
1050
982
|
onKeyDown: onKeyDown,
|
|
1051
983
|
onFocus: this.handleFocus,
|
|
1052
984
|
onBlur: this.handleBlur,
|
|
1053
|
-
light: light,
|
|
1054
985
|
readOnly: readOnly,
|
|
1055
986
|
autoComplete: autoComplete,
|
|
1056
987
|
ref: forwardedRef,
|
|
@@ -1065,14 +996,13 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
1065
996
|
}
|
|
1066
997
|
LabeledTextField.defaultProps = {
|
|
1067
998
|
type: "text",
|
|
1068
|
-
disabled: false
|
|
1069
|
-
light: false
|
|
999
|
+
disabled: false
|
|
1070
1000
|
};
|
|
1071
1001
|
var labeledTextField = React__namespace.forwardRef((props, ref) => React__namespace.createElement(LabeledTextField, _extends__default["default"]({}, props, {
|
|
1072
1002
|
forwardedRef: ref
|
|
1073
1003
|
})));
|
|
1074
1004
|
|
|
1075
|
-
const _excluded = ["onChange", "value", "placeholder", "disabled", "id", "testId", "style", "readOnly", "autoComplete", "name", "className", "autoFocus", "rows", "spellCheck", "wrap", "minLength", "maxLength", "onClick", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "validate", "onValidate", "required", "resizeType", "
|
|
1005
|
+
const _excluded = ["onChange", "value", "placeholder", "disabled", "id", "testId", "style", "readOnly", "autoComplete", "name", "className", "autoFocus", "rows", "spellCheck", "wrap", "minLength", "maxLength", "onClick", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "validate", "onValidate", "required", "resizeType", "rootStyle", "error", "instantValidation"];
|
|
1076
1006
|
const StyledTextArea = wonderBlocksCore.addStyle("textarea");
|
|
1077
1007
|
const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
|
|
1078
1008
|
const {
|
|
@@ -1102,7 +1032,6 @@ const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
|
|
|
1102
1032
|
onValidate,
|
|
1103
1033
|
required,
|
|
1104
1034
|
resizeType,
|
|
1105
|
-
light,
|
|
1106
1035
|
rootStyle,
|
|
1107
1036
|
error,
|
|
1108
1037
|
instantValidation = true
|
|
@@ -1134,12 +1063,6 @@ const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
|
|
|
1134
1063
|
onBlur(event);
|
|
1135
1064
|
}
|
|
1136
1065
|
};
|
|
1137
|
-
const getStyles = () => {
|
|
1138
|
-
const baseStyles = [styles.textarea, wonderBlocksTypography.styles.LabelMedium, resizeType && resizeStyles[resizeType]];
|
|
1139
|
-
const defaultStyles = [styles.default, !disabled && styles.defaultFocus, disabled && styles.disabled, hasError && styles.error];
|
|
1140
|
-
const lightStyles = [styles.light, !disabled && styles.lightFocus, disabled && styles.lightDisabled, hasError && styles.lightError];
|
|
1141
|
-
return [...baseStyles, ...(light ? lightStyles : defaultStyles)];
|
|
1142
|
-
};
|
|
1143
1066
|
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
1144
1067
|
style: [{
|
|
1145
1068
|
width: "100%"
|
|
@@ -1149,7 +1072,7 @@ const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
|
|
|
1149
1072
|
"data-testid": testId,
|
|
1150
1073
|
ref: ref,
|
|
1151
1074
|
className: className,
|
|
1152
|
-
style: [
|
|
1075
|
+
style: [styles.textarea, wonderBlocksTypography.styles.LabelMedium, resizeType && resizeStyles[resizeType], styles.default, !disabled && styles.defaultFocus, disabled && styles.disabled, hasError && styles.error, style],
|
|
1153
1076
|
value: value,
|
|
1154
1077
|
onChange: handleChange,
|
|
1155
1078
|
placeholder: placeholder,
|
|
@@ -1163,6 +1086,7 @@ const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
|
|
|
1163
1086
|
wrap: wrap,
|
|
1164
1087
|
minLength: minLength,
|
|
1165
1088
|
maxLength: maxLength,
|
|
1089
|
+
"aria-required": !!required,
|
|
1166
1090
|
onClick: disabled ? undefined : onClick,
|
|
1167
1091
|
onKeyDown: disabled ? undefined : onKeyDown,
|
|
1168
1092
|
onKeyUp: disabled ? undefined : onKeyUp,
|
|
@@ -1220,49 +1144,6 @@ const styles = aphrodite.StyleSheet.create({
|
|
|
1220
1144
|
outlineColor: wonderBlocksTokens.color.red,
|
|
1221
1145
|
borderColor: wonderBlocksTokens.color.red
|
|
1222
1146
|
}
|
|
1223
|
-
},
|
|
1224
|
-
light: {
|
|
1225
|
-
background: wonderBlocksTokens.color.white,
|
|
1226
|
-
border: `1px solid ${wonderBlocksTokens.color.offBlack16}`,
|
|
1227
|
-
color: wonderBlocksTokens.color.offBlack,
|
|
1228
|
-
"::placeholder": {
|
|
1229
|
-
color: wonderBlocksTokens.color.offBlack64
|
|
1230
|
-
}
|
|
1231
|
-
},
|
|
1232
|
-
lightFocus: {
|
|
1233
|
-
":focus-visible": {
|
|
1234
|
-
outline: `3px solid ${wonderBlocksTokens.color.blue}`,
|
|
1235
|
-
outlineOffset: "-4px",
|
|
1236
|
-
borderColor: wonderBlocksTokens.color.white
|
|
1237
|
-
}
|
|
1238
|
-
},
|
|
1239
|
-
lightDisabled: {
|
|
1240
|
-
backgroundColor: "transparent",
|
|
1241
|
-
border: `1px solid ${wonderBlocksTokens.color.white32}`,
|
|
1242
|
-
color: wonderBlocksTokens.color.white64,
|
|
1243
|
-
"::placeholder": {
|
|
1244
|
-
color: wonderBlocksTokens.color.white64
|
|
1245
|
-
},
|
|
1246
|
-
cursor: "not-allowed",
|
|
1247
|
-
":focus-visible": {
|
|
1248
|
-
borderColor: wonderBlocksTokens.mix(wonderBlocksTokens.color.white32, wonderBlocksTokens.color.blue),
|
|
1249
|
-
outline: `3px solid ${wonderBlocksTokens.color.fadedBlue}`,
|
|
1250
|
-
outlineOffset: "-4px"
|
|
1251
|
-
}
|
|
1252
|
-
},
|
|
1253
|
-
lightError: {
|
|
1254
|
-
background: wonderBlocksTokens.color.fadedRed8,
|
|
1255
|
-
border: `1px solid ${wonderBlocksTokens.color.white}`,
|
|
1256
|
-
outline: `2px solid ${wonderBlocksTokens.color.red}`,
|
|
1257
|
-
outlineOffset: "-3px",
|
|
1258
|
-
color: wonderBlocksTokens.color.offBlack,
|
|
1259
|
-
"::placeholder": {
|
|
1260
|
-
color: wonderBlocksTokens.color.offBlack64
|
|
1261
|
-
},
|
|
1262
|
-
":focus-visible": {
|
|
1263
|
-
outline: `3px solid ${wonderBlocksTokens.color.red}`,
|
|
1264
|
-
outlineOffset: "-4px"
|
|
1265
|
-
}
|
|
1266
1147
|
}
|
|
1267
1148
|
});
|
|
1268
1149
|
const resizeStyles = aphrodite.StyleSheet.create({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-form",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"description": "Form components for Wonder Blocks.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime": "^7.18.6",
|
|
20
|
-
"@khanacademy/wonder-blocks-clickable": "^5.0.
|
|
20
|
+
"@khanacademy/wonder-blocks-clickable": "^5.0.6",
|
|
21
21
|
"@khanacademy/wonder-blocks-core": "^11.1.0",
|
|
22
22
|
"@khanacademy/wonder-blocks-icon": "^5.0.5",
|
|
23
|
-
"@khanacademy/wonder-blocks-layout": "^3.0.
|
|
24
|
-
"@khanacademy/wonder-blocks-tokens": "^
|
|
23
|
+
"@khanacademy/wonder-blocks-layout": "^3.0.6",
|
|
24
|
+
"@khanacademy/wonder-blocks-tokens": "^4.0.0",
|
|
25
25
|
"@khanacademy/wonder-blocks-typography": "^3.0.5"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|