@khanacademy/wonder-blocks-form 6.0.6 → 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 +13 -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 +13 -132
- package/dist/index.js +13 -132
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
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
|
+
|
|
3
16
|
## 6.0.6
|
|
4
17
|
|
|
5
18
|
### 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
|
@@ -648,7 +648,7 @@ const useFieldValidation = ({
|
|
|
648
648
|
};
|
|
649
649
|
};
|
|
650
650
|
|
|
651
|
-
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"];
|
|
652
652
|
const StyledInput = addStyle("input");
|
|
653
653
|
const TextField = props => {
|
|
654
654
|
const {
|
|
@@ -657,7 +657,6 @@ const TextField = props => {
|
|
|
657
657
|
value,
|
|
658
658
|
name,
|
|
659
659
|
disabled = false,
|
|
660
|
-
light = false,
|
|
661
660
|
error,
|
|
662
661
|
validate,
|
|
663
662
|
onValidate,
|
|
@@ -705,16 +704,10 @@ const TextField = props => {
|
|
|
705
704
|
onBlur(event);
|
|
706
705
|
}
|
|
707
706
|
};
|
|
708
|
-
const getStyles = () => {
|
|
709
|
-
const baseStyles = [styles$2.input, styles$7.LabelMedium];
|
|
710
|
-
const defaultStyles = [styles$2.default, !disabled && styles$2.defaultFocus, disabled && styles$2.disabled, hasError && styles$2.error];
|
|
711
|
-
const lightStyles = [styles$2.light, !disabled && styles$2.lightFocus, disabled && styles$2.lightDisabled, hasError && styles$2.lightError];
|
|
712
|
-
return [...baseStyles, ...(light ? lightStyles : defaultStyles)];
|
|
713
|
-
};
|
|
714
707
|
return React.createElement(Id, {
|
|
715
708
|
id: id
|
|
716
709
|
}, uniqueId => React.createElement(StyledInput, _extends({
|
|
717
|
-
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],
|
|
718
711
|
id: uniqueId,
|
|
719
712
|
type: type,
|
|
720
713
|
placeholder: placeholder,
|
|
@@ -782,49 +775,6 @@ const styles$2 = StyleSheet.create({
|
|
|
782
775
|
outline: `2px solid ${color.offBlack32}`,
|
|
783
776
|
outlineOffset: "-3px"
|
|
784
777
|
}
|
|
785
|
-
},
|
|
786
|
-
light: {
|
|
787
|
-
background: color.white,
|
|
788
|
-
border: `1px solid ${color.offBlack16}`,
|
|
789
|
-
color: color.offBlack,
|
|
790
|
-
"::placeholder": {
|
|
791
|
-
color: color.offBlack64
|
|
792
|
-
}
|
|
793
|
-
},
|
|
794
|
-
lightFocus: {
|
|
795
|
-
":focus-visible": {
|
|
796
|
-
outline: `3px solid ${color.blue}`,
|
|
797
|
-
outlineOffset: "-4px",
|
|
798
|
-
borderColor: color.white
|
|
799
|
-
}
|
|
800
|
-
},
|
|
801
|
-
lightDisabled: {
|
|
802
|
-
backgroundColor: "transparent",
|
|
803
|
-
border: `1px solid ${color.white32}`,
|
|
804
|
-
color: color.white64,
|
|
805
|
-
"::placeholder": {
|
|
806
|
-
color: color.white64
|
|
807
|
-
},
|
|
808
|
-
cursor: "not-allowed",
|
|
809
|
-
":focus-visible": {
|
|
810
|
-
borderColor: mix(color.white32, color.blue),
|
|
811
|
-
outline: `3px solid ${color.fadedBlue}`,
|
|
812
|
-
outlineOffset: "-4px"
|
|
813
|
-
}
|
|
814
|
-
},
|
|
815
|
-
lightError: {
|
|
816
|
-
background: color.fadedRed8,
|
|
817
|
-
border: `1px solid ${color.white}`,
|
|
818
|
-
outline: `2px solid ${color.red}`,
|
|
819
|
-
outlineOffset: "-3px",
|
|
820
|
-
color: color.offBlack,
|
|
821
|
-
"::placeholder": {
|
|
822
|
-
color: color.offBlack64
|
|
823
|
-
},
|
|
824
|
-
":focus-visible": {
|
|
825
|
-
outline: `3px solid ${color.red}`,
|
|
826
|
-
outlineOffset: "-4px"
|
|
827
|
-
}
|
|
828
778
|
}
|
|
829
779
|
});
|
|
830
780
|
var TextField$1 = React.forwardRef((props, ref) => React.createElement(TextField, _extends({}, props, {
|
|
@@ -838,15 +788,14 @@ class FieldHeading extends React.Component {
|
|
|
838
788
|
label,
|
|
839
789
|
id,
|
|
840
790
|
required,
|
|
841
|
-
testId
|
|
842
|
-
light
|
|
791
|
+
testId
|
|
843
792
|
} = this.props;
|
|
844
793
|
const requiredIcon = React.createElement(StyledSpan, {
|
|
845
|
-
style:
|
|
794
|
+
style: styles$1.required,
|
|
846
795
|
"aria-hidden": true
|
|
847
796
|
}, " ", "*");
|
|
848
797
|
return React.createElement(React.Fragment, null, React.createElement(LabelMedium, {
|
|
849
|
-
style:
|
|
798
|
+
style: styles$1.label,
|
|
850
799
|
tag: "label",
|
|
851
800
|
htmlFor: id && `${id}-field`,
|
|
852
801
|
testId: testId && `${testId}-label`
|
|
@@ -857,14 +806,13 @@ class FieldHeading extends React.Component {
|
|
|
857
806
|
maybeRenderDescription() {
|
|
858
807
|
const {
|
|
859
808
|
description,
|
|
860
|
-
testId
|
|
861
|
-
light
|
|
809
|
+
testId
|
|
862
810
|
} = this.props;
|
|
863
811
|
if (!description) {
|
|
864
812
|
return null;
|
|
865
813
|
}
|
|
866
814
|
return React.createElement(React.Fragment, null, React.createElement(LabelSmall, {
|
|
867
|
-
style:
|
|
815
|
+
style: styles$1.description,
|
|
868
816
|
testId: testId && `${testId}-description`
|
|
869
817
|
}, description), React.createElement(Strut, {
|
|
870
818
|
size: spacing.xxxSmall_4
|
|
@@ -874,8 +822,7 @@ class FieldHeading extends React.Component {
|
|
|
874
822
|
const {
|
|
875
823
|
error,
|
|
876
824
|
id,
|
|
877
|
-
testId
|
|
878
|
-
light
|
|
825
|
+
testId
|
|
879
826
|
} = this.props;
|
|
880
827
|
if (!error) {
|
|
881
828
|
return null;
|
|
@@ -883,7 +830,7 @@ class FieldHeading extends React.Component {
|
|
|
883
830
|
return React.createElement(React.Fragment, null, React.createElement(Strut, {
|
|
884
831
|
size: spacing.small_12
|
|
885
832
|
}), React.createElement(LabelSmall, {
|
|
886
|
-
style:
|
|
833
|
+
style: styles$1.error,
|
|
887
834
|
role: "alert",
|
|
888
835
|
id: id && `${id}-error`,
|
|
889
836
|
testId: testId && `${testId}-error`
|
|
@@ -905,30 +852,18 @@ const styles$1 = StyleSheet.create({
|
|
|
905
852
|
label: {
|
|
906
853
|
color: color.offBlack
|
|
907
854
|
},
|
|
908
|
-
lightLabel: {
|
|
909
|
-
color: color.white
|
|
910
|
-
},
|
|
911
855
|
description: {
|
|
912
856
|
color: color.offBlack64
|
|
913
857
|
},
|
|
914
|
-
lightDescription: {
|
|
915
|
-
color: color.white64
|
|
916
|
-
},
|
|
917
858
|
error: {
|
|
918
859
|
color: color.red
|
|
919
860
|
},
|
|
920
|
-
lightError: {
|
|
921
|
-
color: color.fadedRed
|
|
922
|
-
},
|
|
923
861
|
required: {
|
|
924
862
|
color: color.red
|
|
925
|
-
},
|
|
926
|
-
lightRequired: {
|
|
927
|
-
color: color.fadedRed
|
|
928
863
|
}
|
|
929
864
|
});
|
|
930
865
|
|
|
931
|
-
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"];
|
|
932
867
|
class LabeledTextField extends React.Component {
|
|
933
868
|
constructor(props) {
|
|
934
869
|
super(props);
|
|
@@ -987,7 +922,6 @@ class LabeledTextField extends React.Component {
|
|
|
987
922
|
onChange,
|
|
988
923
|
onKeyDown,
|
|
989
924
|
placeholder,
|
|
990
|
-
light,
|
|
991
925
|
style,
|
|
992
926
|
testId,
|
|
993
927
|
readOnly,
|
|
@@ -1003,7 +937,6 @@ class LabeledTextField extends React.Component {
|
|
|
1003
937
|
id: uniqueId,
|
|
1004
938
|
testId: testId,
|
|
1005
939
|
style: style,
|
|
1006
|
-
light: light,
|
|
1007
940
|
field: React.createElement(TextField$1, _extends({
|
|
1008
941
|
id: `${uniqueId}-field`,
|
|
1009
942
|
"aria-describedby": ariaDescribedby ? ariaDescribedby : `${uniqueId}-error`,
|
|
@@ -1020,7 +953,6 @@ class LabeledTextField extends React.Component {
|
|
|
1020
953
|
onKeyDown: onKeyDown,
|
|
1021
954
|
onFocus: this.handleFocus,
|
|
1022
955
|
onBlur: this.handleBlur,
|
|
1023
|
-
light: light,
|
|
1024
956
|
readOnly: readOnly,
|
|
1025
957
|
autoComplete: autoComplete,
|
|
1026
958
|
ref: forwardedRef,
|
|
@@ -1035,14 +967,13 @@ class LabeledTextField extends React.Component {
|
|
|
1035
967
|
}
|
|
1036
968
|
LabeledTextField.defaultProps = {
|
|
1037
969
|
type: "text",
|
|
1038
|
-
disabled: false
|
|
1039
|
-
light: false
|
|
970
|
+
disabled: false
|
|
1040
971
|
};
|
|
1041
972
|
var labeledTextField = React.forwardRef((props, ref) => React.createElement(LabeledTextField, _extends({}, props, {
|
|
1042
973
|
forwardedRef: ref
|
|
1043
974
|
})));
|
|
1044
975
|
|
|
1045
|
-
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"];
|
|
1046
977
|
const StyledTextArea = addStyle("textarea");
|
|
1047
978
|
const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
1048
979
|
const {
|
|
@@ -1072,7 +1003,6 @@ const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
|
1072
1003
|
onValidate,
|
|
1073
1004
|
required,
|
|
1074
1005
|
resizeType,
|
|
1075
|
-
light,
|
|
1076
1006
|
rootStyle,
|
|
1077
1007
|
error,
|
|
1078
1008
|
instantValidation = true
|
|
@@ -1104,12 +1034,6 @@ const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
|
1104
1034
|
onBlur(event);
|
|
1105
1035
|
}
|
|
1106
1036
|
};
|
|
1107
|
-
const getStyles = () => {
|
|
1108
|
-
const baseStyles = [styles.textarea, styles$7.LabelMedium, resizeType && resizeStyles[resizeType]];
|
|
1109
|
-
const defaultStyles = [styles.default, !disabled && styles.defaultFocus, disabled && styles.disabled, hasError && styles.error];
|
|
1110
|
-
const lightStyles = [styles.light, !disabled && styles.lightFocus, disabled && styles.lightDisabled, hasError && styles.lightError];
|
|
1111
|
-
return [...baseStyles, ...(light ? lightStyles : defaultStyles)];
|
|
1112
|
-
};
|
|
1113
1037
|
return React.createElement(View, {
|
|
1114
1038
|
style: [{
|
|
1115
1039
|
width: "100%"
|
|
@@ -1119,7 +1043,7 @@ const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
|
1119
1043
|
"data-testid": testId,
|
|
1120
1044
|
ref: ref,
|
|
1121
1045
|
className: className,
|
|
1122
|
-
style: [
|
|
1046
|
+
style: [styles.textarea, styles$7.LabelMedium, resizeType && resizeStyles[resizeType], styles.default, !disabled && styles.defaultFocus, disabled && styles.disabled, hasError && styles.error, style],
|
|
1123
1047
|
value: value,
|
|
1124
1048
|
onChange: handleChange,
|
|
1125
1049
|
placeholder: placeholder,
|
|
@@ -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
|
@@ -677,7 +677,7 @@ const useFieldValidation = ({
|
|
|
677
677
|
};
|
|
678
678
|
};
|
|
679
679
|
|
|
680
|
-
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"];
|
|
681
681
|
const StyledInput = wonderBlocksCore.addStyle("input");
|
|
682
682
|
const TextField = props => {
|
|
683
683
|
const {
|
|
@@ -686,7 +686,6 @@ const TextField = props => {
|
|
|
686
686
|
value,
|
|
687
687
|
name,
|
|
688
688
|
disabled = false,
|
|
689
|
-
light = false,
|
|
690
689
|
error,
|
|
691
690
|
validate,
|
|
692
691
|
onValidate,
|
|
@@ -734,16 +733,10 @@ const TextField = props => {
|
|
|
734
733
|
onBlur(event);
|
|
735
734
|
}
|
|
736
735
|
};
|
|
737
|
-
const getStyles = () => {
|
|
738
|
-
const baseStyles = [styles$2.input, wonderBlocksTypography.styles.LabelMedium];
|
|
739
|
-
const defaultStyles = [styles$2.default, !disabled && styles$2.defaultFocus, disabled && styles$2.disabled, hasError && styles$2.error];
|
|
740
|
-
const lightStyles = [styles$2.light, !disabled && styles$2.lightFocus, disabled && styles$2.lightDisabled, hasError && styles$2.lightError];
|
|
741
|
-
return [...baseStyles, ...(light ? lightStyles : defaultStyles)];
|
|
742
|
-
};
|
|
743
736
|
return React__namespace.createElement(wonderBlocksCore.Id, {
|
|
744
737
|
id: id
|
|
745
738
|
}, uniqueId => React__namespace.createElement(StyledInput, _extends__default["default"]({
|
|
746
|
-
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],
|
|
747
740
|
id: uniqueId,
|
|
748
741
|
type: type,
|
|
749
742
|
placeholder: placeholder,
|
|
@@ -811,49 +804,6 @@ const styles$2 = aphrodite.StyleSheet.create({
|
|
|
811
804
|
outline: `2px solid ${wonderBlocksTokens.color.offBlack32}`,
|
|
812
805
|
outlineOffset: "-3px"
|
|
813
806
|
}
|
|
814
|
-
},
|
|
815
|
-
light: {
|
|
816
|
-
background: wonderBlocksTokens.color.white,
|
|
817
|
-
border: `1px solid ${wonderBlocksTokens.color.offBlack16}`,
|
|
818
|
-
color: wonderBlocksTokens.color.offBlack,
|
|
819
|
-
"::placeholder": {
|
|
820
|
-
color: wonderBlocksTokens.color.offBlack64
|
|
821
|
-
}
|
|
822
|
-
},
|
|
823
|
-
lightFocus: {
|
|
824
|
-
":focus-visible": {
|
|
825
|
-
outline: `3px solid ${wonderBlocksTokens.color.blue}`,
|
|
826
|
-
outlineOffset: "-4px",
|
|
827
|
-
borderColor: wonderBlocksTokens.color.white
|
|
828
|
-
}
|
|
829
|
-
},
|
|
830
|
-
lightDisabled: {
|
|
831
|
-
backgroundColor: "transparent",
|
|
832
|
-
border: `1px solid ${wonderBlocksTokens.color.white32}`,
|
|
833
|
-
color: wonderBlocksTokens.color.white64,
|
|
834
|
-
"::placeholder": {
|
|
835
|
-
color: wonderBlocksTokens.color.white64
|
|
836
|
-
},
|
|
837
|
-
cursor: "not-allowed",
|
|
838
|
-
":focus-visible": {
|
|
839
|
-
borderColor: wonderBlocksTokens.mix(wonderBlocksTokens.color.white32, wonderBlocksTokens.color.blue),
|
|
840
|
-
outline: `3px solid ${wonderBlocksTokens.color.fadedBlue}`,
|
|
841
|
-
outlineOffset: "-4px"
|
|
842
|
-
}
|
|
843
|
-
},
|
|
844
|
-
lightError: {
|
|
845
|
-
background: wonderBlocksTokens.color.fadedRed8,
|
|
846
|
-
border: `1px solid ${wonderBlocksTokens.color.white}`,
|
|
847
|
-
outline: `2px solid ${wonderBlocksTokens.color.red}`,
|
|
848
|
-
outlineOffset: "-3px",
|
|
849
|
-
color: wonderBlocksTokens.color.offBlack,
|
|
850
|
-
"::placeholder": {
|
|
851
|
-
color: wonderBlocksTokens.color.offBlack64
|
|
852
|
-
},
|
|
853
|
-
":focus-visible": {
|
|
854
|
-
outline: `3px solid ${wonderBlocksTokens.color.red}`,
|
|
855
|
-
outlineOffset: "-4px"
|
|
856
|
-
}
|
|
857
807
|
}
|
|
858
808
|
});
|
|
859
809
|
var TextField$1 = React__namespace.forwardRef((props, ref) => React__namespace.createElement(TextField, _extends__default["default"]({}, props, {
|
|
@@ -867,15 +817,14 @@ class FieldHeading extends React__namespace.Component {
|
|
|
867
817
|
label,
|
|
868
818
|
id,
|
|
869
819
|
required,
|
|
870
|
-
testId
|
|
871
|
-
light
|
|
820
|
+
testId
|
|
872
821
|
} = this.props;
|
|
873
822
|
const requiredIcon = React__namespace.createElement(StyledSpan, {
|
|
874
|
-
style:
|
|
823
|
+
style: styles$1.required,
|
|
875
824
|
"aria-hidden": true
|
|
876
825
|
}, " ", "*");
|
|
877
826
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
|
|
878
|
-
style:
|
|
827
|
+
style: styles$1.label,
|
|
879
828
|
tag: "label",
|
|
880
829
|
htmlFor: id && `${id}-field`,
|
|
881
830
|
testId: testId && `${testId}-label`
|
|
@@ -886,14 +835,13 @@ class FieldHeading extends React__namespace.Component {
|
|
|
886
835
|
maybeRenderDescription() {
|
|
887
836
|
const {
|
|
888
837
|
description,
|
|
889
|
-
testId
|
|
890
|
-
light
|
|
838
|
+
testId
|
|
891
839
|
} = this.props;
|
|
892
840
|
if (!description) {
|
|
893
841
|
return null;
|
|
894
842
|
}
|
|
895
843
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
|
|
896
|
-
style:
|
|
844
|
+
style: styles$1.description,
|
|
897
845
|
testId: testId && `${testId}-description`
|
|
898
846
|
}, description), React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
899
847
|
size: wonderBlocksTokens.spacing.xxxSmall_4
|
|
@@ -903,8 +851,7 @@ class FieldHeading extends React__namespace.Component {
|
|
|
903
851
|
const {
|
|
904
852
|
error,
|
|
905
853
|
id,
|
|
906
|
-
testId
|
|
907
|
-
light
|
|
854
|
+
testId
|
|
908
855
|
} = this.props;
|
|
909
856
|
if (!error) {
|
|
910
857
|
return null;
|
|
@@ -912,7 +859,7 @@ class FieldHeading extends React__namespace.Component {
|
|
|
912
859
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
913
860
|
size: wonderBlocksTokens.spacing.small_12
|
|
914
861
|
}), React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
|
|
915
|
-
style:
|
|
862
|
+
style: styles$1.error,
|
|
916
863
|
role: "alert",
|
|
917
864
|
id: id && `${id}-error`,
|
|
918
865
|
testId: testId && `${testId}-error`
|
|
@@ -934,30 +881,18 @@ const styles$1 = aphrodite.StyleSheet.create({
|
|
|
934
881
|
label: {
|
|
935
882
|
color: wonderBlocksTokens.color.offBlack
|
|
936
883
|
},
|
|
937
|
-
lightLabel: {
|
|
938
|
-
color: wonderBlocksTokens.color.white
|
|
939
|
-
},
|
|
940
884
|
description: {
|
|
941
885
|
color: wonderBlocksTokens.color.offBlack64
|
|
942
886
|
},
|
|
943
|
-
lightDescription: {
|
|
944
|
-
color: wonderBlocksTokens.color.white64
|
|
945
|
-
},
|
|
946
887
|
error: {
|
|
947
888
|
color: wonderBlocksTokens.color.red
|
|
948
889
|
},
|
|
949
|
-
lightError: {
|
|
950
|
-
color: wonderBlocksTokens.color.fadedRed
|
|
951
|
-
},
|
|
952
890
|
required: {
|
|
953
891
|
color: wonderBlocksTokens.color.red
|
|
954
|
-
},
|
|
955
|
-
lightRequired: {
|
|
956
|
-
color: wonderBlocksTokens.color.fadedRed
|
|
957
892
|
}
|
|
958
893
|
});
|
|
959
894
|
|
|
960
|
-
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"];
|
|
961
896
|
class LabeledTextField extends React__namespace.Component {
|
|
962
897
|
constructor(props) {
|
|
963
898
|
super(props);
|
|
@@ -1016,7 +951,6 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
1016
951
|
onChange,
|
|
1017
952
|
onKeyDown,
|
|
1018
953
|
placeholder,
|
|
1019
|
-
light,
|
|
1020
954
|
style,
|
|
1021
955
|
testId,
|
|
1022
956
|
readOnly,
|
|
@@ -1032,7 +966,6 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
1032
966
|
id: uniqueId,
|
|
1033
967
|
testId: testId,
|
|
1034
968
|
style: style,
|
|
1035
|
-
light: light,
|
|
1036
969
|
field: React__namespace.createElement(TextField$1, _extends__default["default"]({
|
|
1037
970
|
id: `${uniqueId}-field`,
|
|
1038
971
|
"aria-describedby": ariaDescribedby ? ariaDescribedby : `${uniqueId}-error`,
|
|
@@ -1049,7 +982,6 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
1049
982
|
onKeyDown: onKeyDown,
|
|
1050
983
|
onFocus: this.handleFocus,
|
|
1051
984
|
onBlur: this.handleBlur,
|
|
1052
|
-
light: light,
|
|
1053
985
|
readOnly: readOnly,
|
|
1054
986
|
autoComplete: autoComplete,
|
|
1055
987
|
ref: forwardedRef,
|
|
@@ -1064,14 +996,13 @@ class LabeledTextField extends React__namespace.Component {
|
|
|
1064
996
|
}
|
|
1065
997
|
LabeledTextField.defaultProps = {
|
|
1066
998
|
type: "text",
|
|
1067
|
-
disabled: false
|
|
1068
|
-
light: false
|
|
999
|
+
disabled: false
|
|
1069
1000
|
};
|
|
1070
1001
|
var labeledTextField = React__namespace.forwardRef((props, ref) => React__namespace.createElement(LabeledTextField, _extends__default["default"]({}, props, {
|
|
1071
1002
|
forwardedRef: ref
|
|
1072
1003
|
})));
|
|
1073
1004
|
|
|
1074
|
-
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"];
|
|
1075
1006
|
const StyledTextArea = wonderBlocksCore.addStyle("textarea");
|
|
1076
1007
|
const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
|
|
1077
1008
|
const {
|
|
@@ -1101,7 +1032,6 @@ const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
|
|
|
1101
1032
|
onValidate,
|
|
1102
1033
|
required,
|
|
1103
1034
|
resizeType,
|
|
1104
|
-
light,
|
|
1105
1035
|
rootStyle,
|
|
1106
1036
|
error,
|
|
1107
1037
|
instantValidation = true
|
|
@@ -1133,12 +1063,6 @@ const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
|
|
|
1133
1063
|
onBlur(event);
|
|
1134
1064
|
}
|
|
1135
1065
|
};
|
|
1136
|
-
const getStyles = () => {
|
|
1137
|
-
const baseStyles = [styles.textarea, wonderBlocksTypography.styles.LabelMedium, resizeType && resizeStyles[resizeType]];
|
|
1138
|
-
const defaultStyles = [styles.default, !disabled && styles.defaultFocus, disabled && styles.disabled, hasError && styles.error];
|
|
1139
|
-
const lightStyles = [styles.light, !disabled && styles.lightFocus, disabled && styles.lightDisabled, hasError && styles.lightError];
|
|
1140
|
-
return [...baseStyles, ...(light ? lightStyles : defaultStyles)];
|
|
1141
|
-
};
|
|
1142
1066
|
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
1143
1067
|
style: [{
|
|
1144
1068
|
width: "100%"
|
|
@@ -1148,7 +1072,7 @@ const TextArea = React__namespace.forwardRef(function TextArea(props, ref) {
|
|
|
1148
1072
|
"data-testid": testId,
|
|
1149
1073
|
ref: ref,
|
|
1150
1074
|
className: className,
|
|
1151
|
-
style: [
|
|
1075
|
+
style: [styles.textarea, wonderBlocksTypography.styles.LabelMedium, resizeType && resizeStyles[resizeType], styles.default, !disabled && styles.defaultFocus, disabled && styles.disabled, hasError && styles.error, style],
|
|
1152
1076
|
value: value,
|
|
1153
1077
|
onChange: handleChange,
|
|
1154
1078
|
placeholder: placeholder,
|
|
@@ -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": {
|