@khanacademy/wonder-blocks-form 4.3.2 → 4.3.3
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 +14 -0
- package/package.json +8 -8
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/components/checkbox-core.js.flow +0 -30
- package/dist/components/checkbox-group.js.flow +0 -100
- package/dist/components/checkbox.js.flow +0 -101
- package/dist/components/choice-internal.js.flow +0 -88
- package/dist/components/choice.js.flow +0 -153
- package/dist/components/field-heading.js.flow +0 -62
- package/dist/components/group-styles.js.flow +0 -9
- package/dist/components/labeled-text-field.js.flow +0 -202
- package/dist/components/radio-core.js.flow +0 -30
- package/dist/components/radio-group.js.flow +0 -101
- package/dist/components/radio.js.flow +0 -86
- package/dist/components/text-field.js.flow +0 -182
- package/dist/index.js.flow +0 -20
- package/dist/util/types.js.flow +0 -138
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as $Flowgen$Import$_2e__2e__2f__2e__2e__2f__2e__2e__2f_wonder_2d_blocks_2d_core_2f_src_2f_util_2f_aria_2d_types from "../../../wonder-blocks-core/src/util/aria-types";
|
|
8
|
-
import * as React from "react";
|
|
9
|
-
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
10
|
-
import type { Checked } from "../util/types";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* ☑️ A nicely styled checkbox for all your checking needs. Can optionally take
|
|
14
|
-
* label and description props.
|
|
15
|
-
*
|
|
16
|
-
* If used by itself, a checkbox provides two options - checked and unchecked.
|
|
17
|
-
* A group of checkboxes can be used to allow a user to select multiple values
|
|
18
|
-
* from a list of options.
|
|
19
|
-
*
|
|
20
|
-
* If you want a whole group of Checkbox[es] that are related, see the Choice
|
|
21
|
-
* and CheckboxGroup components.
|
|
22
|
-
*
|
|
23
|
-
* ### Usage
|
|
24
|
-
*
|
|
25
|
-
* ```jsx
|
|
26
|
-
* import {Checkbox} from "@khanacademy/wonder-blocks-form";
|
|
27
|
-
*
|
|
28
|
-
* const [checked, setChecked] = React.useState(false);
|
|
29
|
-
*
|
|
30
|
-
* <Checkbox checked={checked} onChange={setChecked} />
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
declare var Checkbox: React.ForwardRefExoticComponent<{|
|
|
34
|
-
...$ReadOnly<$Flowgen$Import$_2e__2e__2f__2e__2e__2f__2e__2e__2f_wonder_2d_blocks_2d_core_2f_src_2f_util_2f_aria_2d_types.AriaAttributes>,
|
|
35
|
-
...$ReadOnly<{|
|
|
36
|
-
role?: $Flowgen$Import$_2e__2e__2f__2e__2e__2f__2e__2e__2f_wonder_2d_blocks_2d_core_2f_src_2f_util_2f_aria_2d_types.AriaRole | void,
|
|
37
|
-
|}>,
|
|
38
|
-
...{|
|
|
39
|
-
/**
|
|
40
|
-
* Whether this component is checked or indeterminate
|
|
41
|
-
*/
|
|
42
|
-
checked: Checked,
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Whether this component is disabled
|
|
46
|
-
*/
|
|
47
|
-
disabled?: boolean | void,
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Whether this component should show an error state
|
|
51
|
-
*/
|
|
52
|
-
error?: boolean | void,
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Callback when this component is selected. The newCheckedState is the
|
|
56
|
-
* new checked state of the component.
|
|
57
|
-
*/
|
|
58
|
-
onChange: (newCheckedState: boolean) => mixed,
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Optional label for the field.
|
|
62
|
-
*/
|
|
63
|
-
label?: React.Node,
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Optional description for the field.
|
|
67
|
-
*/
|
|
68
|
-
description?: React.Node,
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Unique identifier attached to the HTML input element. If used, need to
|
|
72
|
-
* guarantee that the ID is unique within everything rendered on a page.
|
|
73
|
-
* Used to match `<label>` with `<input>` elements for screenreaders.
|
|
74
|
-
*/
|
|
75
|
-
id?: string | void,
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Optional styling for the container. Does not style the component.
|
|
79
|
-
*/
|
|
80
|
-
style?: StyleType,
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Adds CSS classes to the Checkbox.
|
|
84
|
-
*/
|
|
85
|
-
className?: string | void,
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Optional test ID for e2e testing
|
|
89
|
-
*/
|
|
90
|
-
testId?: string | void,
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Name for the checkbox or radio button group. Only applicable for group
|
|
94
|
-
* contexts, auto-populated by group components via Choice.
|
|
95
|
-
* @ignore
|
|
96
|
-
*/
|
|
97
|
-
groupName?: string | void,
|
|
98
|
-
|},
|
|
99
|
-
...React.RefAttributes<HTMLInputElement>,
|
|
100
|
-
|}>;
|
|
101
|
-
declare export default typeof Checkbox;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as $Flowgen$Import$_2e__2e__2f__2e__2e__2f__2e__2e__2f_wonder_2d_blocks_2d_core_2f_src_2f_util_2f_aria_2d_types from "../../../wonder-blocks-core/src/util/aria-types";
|
|
8
|
-
import * as React from "react";
|
|
9
|
-
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* This is a potentially labeled 🔘 or ☑️ item. This is an internal component
|
|
13
|
-
* that's wrapped by Checkbox and Radio. Choice is a wrapper for Checkbox and
|
|
14
|
-
* Radio with many of its props auto-populated, to be used with CheckboxGroup
|
|
15
|
-
* and RadioGroup. This design allows for more explicit prop typing. For
|
|
16
|
-
* example, we can make onChange a required prop on Checkbox but not on Choice
|
|
17
|
-
* (because for Choice, that prop would be auto-populated by CheckboxGroup).
|
|
18
|
-
*/
|
|
19
|
-
declare var ChoiceInternal: React.ForwardRefExoticComponent<{|
|
|
20
|
-
...$ReadOnly<$Flowgen$Import$_2e__2e__2f__2e__2e__2f__2e__2e__2f_wonder_2d_blocks_2d_core_2f_src_2f_util_2f_aria_2d_types.AriaAttributes>,
|
|
21
|
-
...$ReadOnly<{|
|
|
22
|
-
role?: $Flowgen$Import$_2e__2e__2f__2e__2e__2f__2e__2e__2f_wonder_2d_blocks_2d_core_2f_src_2f_util_2f_aria_2d_types.AriaRole | void,
|
|
23
|
-
|}>,
|
|
24
|
-
...{|
|
|
25
|
-
/**
|
|
26
|
-
* Whether this choice is checked.
|
|
27
|
-
*/
|
|
28
|
-
checked: boolean | null | void,
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Whether this choice option is disabled.
|
|
32
|
-
*/
|
|
33
|
-
disabled?: boolean | void,
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Whether this choice is in error mode.
|
|
37
|
-
*/
|
|
38
|
-
error?: boolean | void,
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Returns the new checked state of the component.
|
|
42
|
-
*/
|
|
43
|
-
onChange: (newCheckedState: boolean) => mixed,
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Used for accessibility purposes, where the label id should match the
|
|
47
|
-
* input id.
|
|
48
|
-
*/
|
|
49
|
-
id?: string | void,
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Optional additional styling.
|
|
53
|
-
*/
|
|
54
|
-
style?: StyleType,
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Adds CSS classes to the Button.
|
|
58
|
-
*/
|
|
59
|
-
className?: string | void,
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Optional id for testing purposes.
|
|
63
|
-
*/
|
|
64
|
-
testId?: string | void,
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Label for the field.
|
|
68
|
-
*/
|
|
69
|
-
label?: React.Node,
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Optional description for the field.
|
|
73
|
-
*/
|
|
74
|
-
description?: React.Node,
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Auto-populated by parent's groupName prop if in a group.
|
|
78
|
-
*/
|
|
79
|
-
groupName?: string | void,
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Takes either "radio" or "checkbox" value.
|
|
83
|
-
*/
|
|
84
|
-
variant: "radio" | "checkbox",
|
|
85
|
-
|},
|
|
86
|
-
...React.RefAttributes<HTMLInputElement>,
|
|
87
|
-
|}>;
|
|
88
|
-
declare export default typeof ChoiceInternal;
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as $Flowgen$Import$_2e__2e__2f__2e__2e__2f__2e__2e__2f_wonder_2d_blocks_2d_core_2f_src_2f_util_2f_aria_2d_types from "../../../wonder-blocks-core/src/util/aria-types";
|
|
8
|
-
import * as React from "react";
|
|
9
|
-
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* This is a labeled 🔘 or ☑️ item. Choice is meant to be used as children of
|
|
13
|
-
* CheckboxGroup and RadioGroup because many of its props are auto-populated
|
|
14
|
-
* and not shown in the documentation here. See those components for usage
|
|
15
|
-
* examples.
|
|
16
|
-
*
|
|
17
|
-
* If you wish to use just a single field, use Checkbox or Radio with the
|
|
18
|
-
* optional label and description props.
|
|
19
|
-
*
|
|
20
|
-
* ### Checkbox Usage
|
|
21
|
-
*
|
|
22
|
-
* ```jsx
|
|
23
|
-
* import {Choice, CheckboxGroup} from "@khanacademy/wonder-blocks-form";
|
|
24
|
-
*
|
|
25
|
-
* const [selectedValues, setSelectedValues] = React.useState([]);
|
|
26
|
-
*
|
|
27
|
-
* // Checkbox usage
|
|
28
|
-
* <CheckboxGroup
|
|
29
|
-
* label="some-label"
|
|
30
|
-
* description="some-description"
|
|
31
|
-
* groupName="some-group-name"
|
|
32
|
-
* onChange={setSelectedValues}
|
|
33
|
-
* selectedValues={selectedValues}
|
|
34
|
-
* />
|
|
35
|
-
* // Add as many choices as necessary
|
|
36
|
-
* <Choice
|
|
37
|
-
* label="Choice 1"
|
|
38
|
-
* value="some-choice-value"
|
|
39
|
-
* description="Some choice description."
|
|
40
|
-
* />
|
|
41
|
-
* <Choice
|
|
42
|
-
* label="Choice 2"
|
|
43
|
-
* value="some-choice-value-2"
|
|
44
|
-
* description="Some choice description."
|
|
45
|
-
* />
|
|
46
|
-
* </CheckboxGroup>
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* ### Radio Usage
|
|
50
|
-
*
|
|
51
|
-
* ```jsx
|
|
52
|
-
* import {Choice, RadioGroup} from "@khanacademy/wonder-blocks-form";
|
|
53
|
-
*
|
|
54
|
-
* const [selectedValue, setSelectedValue] = React.useState("");
|
|
55
|
-
*
|
|
56
|
-
* <RadioGroup
|
|
57
|
-
* label="some-label"
|
|
58
|
-
* description="some-description"
|
|
59
|
-
* groupName="some-group-name"
|
|
60
|
-
* onChange={setSelectedValue}>
|
|
61
|
-
* selectedValues={selectedValue}
|
|
62
|
-
* />
|
|
63
|
-
* // Add as many choices as necessary
|
|
64
|
-
* <Choice
|
|
65
|
-
* label="Choice 1"
|
|
66
|
-
* value="some-choice-value"
|
|
67
|
-
* description="Some choice description."
|
|
68
|
-
* />
|
|
69
|
-
* <Choice
|
|
70
|
-
* label="Choice 2"
|
|
71
|
-
* value="some-choice-value-2"
|
|
72
|
-
* description="Some choice description."
|
|
73
|
-
* />
|
|
74
|
-
* </RadioGroup>
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
declare var Choice: React.ForwardRefExoticComponent<{|
|
|
78
|
-
...$ReadOnly<$Flowgen$Import$_2e__2e__2f__2e__2e__2f__2e__2e__2f_wonder_2d_blocks_2d_core_2f_src_2f_util_2f_aria_2d_types.AriaAttributes>,
|
|
79
|
-
...$ReadOnly<{|
|
|
80
|
-
role?: $Flowgen$Import$_2e__2e__2f__2e__2e__2f__2e__2e__2f_wonder_2d_blocks_2d_core_2f_src_2f_util_2f_aria_2d_types.AriaRole | void,
|
|
81
|
-
|}>,
|
|
82
|
-
...{|
|
|
83
|
-
/**
|
|
84
|
-
* User-defined. Label for the field.
|
|
85
|
-
*/
|
|
86
|
-
label: React.Node,
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* User-defined. Optional description for the field.
|
|
90
|
-
*/
|
|
91
|
-
description?: React.Node,
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* User-defined. Should be distinct for each item in the group.
|
|
95
|
-
*/
|
|
96
|
-
value: string,
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* User-defined. Whether this choice option is disabled. Default false.
|
|
100
|
-
*/
|
|
101
|
-
disabled?: boolean | void,
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* User-defined. Optional id for testing purposes.
|
|
105
|
-
*/
|
|
106
|
-
testId?: string | void,
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* User-defined. Optional additional styling.
|
|
110
|
-
*/
|
|
111
|
-
style?: StyleType,
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Auto-populated by parent. Whether this choice is checked.
|
|
115
|
-
* @ignore
|
|
116
|
-
*/
|
|
117
|
-
checked?: boolean | void,
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Auto-populated by parent. Whether this choice is in error mode (everything
|
|
121
|
-
* in a choice group would be in error mode at the same time).
|
|
122
|
-
* @ignore
|
|
123
|
-
*/
|
|
124
|
-
error?: boolean | void,
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Auto-populated by parent. Used for accessibility purposes, where the label
|
|
128
|
-
* id should match the input id.
|
|
129
|
-
* @ignore
|
|
130
|
-
*/
|
|
131
|
-
id?: string | void,
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Auto-populated by parent's groupName prop.
|
|
135
|
-
* @ignore
|
|
136
|
-
*/
|
|
137
|
-
groupName?: string | void,
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Auto-populated by parent. Returns the new checked state of the component.
|
|
141
|
-
* @ignore
|
|
142
|
-
*/
|
|
143
|
-
onChange?: ((newCheckedState: boolean) => mixed) | void,
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Auto-populated by parent.
|
|
147
|
-
* @ignore
|
|
148
|
-
*/
|
|
149
|
-
variant?: "checkbox" | "radio" | void,
|
|
150
|
-
|},
|
|
151
|
-
...React.RefAttributes<HTMLInputElement>,
|
|
152
|
-
|}>;
|
|
153
|
-
declare export default typeof Choice;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
import { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
9
|
-
declare type Props = {|
|
|
10
|
-
/**
|
|
11
|
-
* The form field component.
|
|
12
|
-
*/
|
|
13
|
-
field: React.Node,
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The title for the label element.
|
|
17
|
-
*/
|
|
18
|
-
label: React.Node,
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The text for the description element.
|
|
22
|
-
*/
|
|
23
|
-
description?: React.Node,
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Whether this field is required to continue.
|
|
27
|
-
*/
|
|
28
|
-
required?: boolean,
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The message for the error element.
|
|
32
|
-
*/
|
|
33
|
-
error?: React.Node,
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Custom styles for the field heading container.
|
|
37
|
-
*/
|
|
38
|
-
style?: StyleType,
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* A unique id to link the label (and optional error) to the field.
|
|
42
|
-
*
|
|
43
|
-
* The label will assume that the field will have its id formatted as `${id}-field`.
|
|
44
|
-
* The field can assume that the error will have its id formatted as `${id}-error`.
|
|
45
|
-
*/
|
|
46
|
-
id?: string,
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Optional test ID for e2e testing.
|
|
50
|
-
*/
|
|
51
|
-
testId?: string,
|
|
52
|
-
|};
|
|
53
|
-
/**
|
|
54
|
-
* A FieldHeading is an element that provides a label, description, and error element
|
|
55
|
-
* to present better context and hints to any type of form field component.
|
|
56
|
-
*/
|
|
57
|
-
declare export default class FieldHeading extends React.Component<Props> {
|
|
58
|
-
renderLabel(): React.Node;
|
|
59
|
-
maybeRenderDescription(): React.Node | null | void;
|
|
60
|
-
maybeRenderError(): React.Node | null | void;
|
|
61
|
-
render(): React.Node;
|
|
62
|
-
}
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
import { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
9
|
-
import { TextFieldType } from "./text-field";
|
|
10
|
-
declare type WithForwardRef = {|
|
|
11
|
-
forwardedRef: {|
|
|
12
|
-
current: HTMLInputElement | null,
|
|
13
|
-
|},
|
|
14
|
-
|};
|
|
15
|
-
declare type Props = {|
|
|
16
|
-
/**
|
|
17
|
-
* An optional unique identifier for the TextField.
|
|
18
|
-
* If no id is specified, a unique id will be auto-generated.
|
|
19
|
-
*/
|
|
20
|
-
id?: string,
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Determines the type of input. Defaults to text.
|
|
24
|
-
*/
|
|
25
|
-
type: TextFieldType,
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Provide a label for the TextField.
|
|
29
|
-
*/
|
|
30
|
-
label: React.Node,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Provide a description for the TextField.
|
|
34
|
-
*/
|
|
35
|
-
description?: React.Node,
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The input value.
|
|
39
|
-
*/
|
|
40
|
-
value: string,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Makes a read-only input field that cannot be focused. Defaults to false.
|
|
44
|
-
*/
|
|
45
|
-
disabled: boolean,
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Whether this field is required to to continue, or the error message to
|
|
49
|
-
* render if this field is left blank.
|
|
50
|
-
*
|
|
51
|
-
* This can be a boolean or a string.
|
|
52
|
-
*
|
|
53
|
-
* String:
|
|
54
|
-
* Please pass in a translated string to use as the error message that will
|
|
55
|
-
* render if the user leaves this field blank. If this field is required,
|
|
56
|
-
* and a string is not passed in, a default untranslated string will render
|
|
57
|
-
* upon error.
|
|
58
|
-
* Note: The string will not be used if a `validate` prop is passed in.
|
|
59
|
-
*
|
|
60
|
-
* Example message: i18n._("A password is required to log in.")
|
|
61
|
-
*
|
|
62
|
-
* Boolean:
|
|
63
|
-
* True/false indicating whether this field is required. Please do not pass
|
|
64
|
-
* in `true` if possible - pass in the error string instead.
|
|
65
|
-
* If `true` is passed, and a `validate` prop is not passed, that means
|
|
66
|
-
* there is no corresponding message and the default untranlsated message
|
|
67
|
-
* will be used.
|
|
68
|
-
*/
|
|
69
|
-
required?: boolean | string,
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Identifies the element or elements that describes this text field.
|
|
73
|
-
*/
|
|
74
|
-
ariaDescribedby?: string | void,
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Provide a validation for the input value.
|
|
78
|
-
* Return a string error message or null | void for a valid input.
|
|
79
|
-
*/
|
|
80
|
-
validate?: (value: string) => string | null | void,
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Called when the TextField input is validated.
|
|
84
|
-
*/
|
|
85
|
-
onValidate?: (errorMessage?: string | null | void) => mixed,
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Called when the value has changed.
|
|
89
|
-
*/
|
|
90
|
-
onChange: (newValue: string) => mixed,
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Called when a key is pressed.
|
|
94
|
-
*/
|
|
95
|
-
onKeyDown?: (event: SyntheticKeyboardEvent<HTMLInputElement>) => mixed,
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Called when the element has been focused.
|
|
99
|
-
*/
|
|
100
|
-
onFocus?: (event: SyntheticFocusEvent<HTMLInputElement>) => mixed,
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Called when the element has been blurred.
|
|
104
|
-
*/
|
|
105
|
-
onBlur?: (event: SyntheticFocusEvent<HTMLInputElement>) => mixed,
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Provide hints or examples of what to enter.
|
|
109
|
-
*/
|
|
110
|
-
placeholder?: string,
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Change the field’s sub-components to fit a dark background.
|
|
114
|
-
*/
|
|
115
|
-
light: boolean,
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Custom styles for the container.
|
|
119
|
-
*
|
|
120
|
-
* Note: This style is passed to the field heading container
|
|
121
|
-
* due to scenarios where we would like to set a specific
|
|
122
|
-
* width for the text field. If we apply the style directly
|
|
123
|
-
* to the text field, the container would not be affected.
|
|
124
|
-
* For example, setting text field to "width: 50%" would not
|
|
125
|
-
* affect the container since text field is a child of the container.
|
|
126
|
-
* In this case, the container would maintain its width ocuppying
|
|
127
|
-
* unnecessary space when the text field is smaller.
|
|
128
|
-
*/
|
|
129
|
-
style?: StyleType,
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Optional test ID for e2e testing.
|
|
133
|
-
*/
|
|
134
|
-
testId?: string,
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Specifies if the TextField is read-only.
|
|
138
|
-
*/
|
|
139
|
-
readOnly?: boolean,
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Specifies if the TextField allows autocomplete.
|
|
143
|
-
*/
|
|
144
|
-
autoComplete?: string,
|
|
145
|
-
|};
|
|
146
|
-
declare type PropsWithForwardRef = {| ...Props, ...WithForwardRef |};
|
|
147
|
-
declare type DefaultProps = {|
|
|
148
|
-
type: $PropertyType<PropsWithForwardRef, "type">,
|
|
149
|
-
disabled: $PropertyType<PropsWithForwardRef, "disabled">,
|
|
150
|
-
light: $PropertyType<PropsWithForwardRef, "light">,
|
|
151
|
-
|};
|
|
152
|
-
declare type State = {|
|
|
153
|
-
/**
|
|
154
|
-
* Displayed when the validation fails.
|
|
155
|
-
*/
|
|
156
|
-
error: string | null | void,
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* The user focuses on the textfield.
|
|
160
|
-
*/
|
|
161
|
-
focused: boolean,
|
|
162
|
-
|};
|
|
163
|
-
/**
|
|
164
|
-
* A LabeledTextField is an element used to accept a single line of text
|
|
165
|
-
* from the user paired with a label, description, and error field elements.
|
|
166
|
-
*/
|
|
167
|
-
declare class LabeledTextField
|
|
168
|
-
extends React.Component<PropsWithForwardRef, State>
|
|
169
|
-
{
|
|
170
|
-
static defaultProps: DefaultProps;
|
|
171
|
-
constructor(props: PropsWithForwardRef): this;
|
|
172
|
-
handleValidate: (errorMessage?: string | null | void) => mixed;
|
|
173
|
-
handleFocus: (event: SyntheticFocusEvent<HTMLInputElement>) => mixed;
|
|
174
|
-
handleBlur: (event: SyntheticFocusEvent<HTMLInputElement>) => mixed;
|
|
175
|
-
render(): React.Node;
|
|
176
|
-
}
|
|
177
|
-
declare type ExportProps = $Diff<
|
|
178
|
-
React.ElementConfig<typeof LabeledTextField>,
|
|
179
|
-
{ forwardedRef: any }
|
|
180
|
-
>;
|
|
181
|
-
/**
|
|
182
|
-
* A LabeledTextField is an element used to accept a single line of text
|
|
183
|
-
* from the user paired with a label, description, and error field elements.
|
|
184
|
-
*
|
|
185
|
-
* ### Usage
|
|
186
|
-
*
|
|
187
|
-
* ```jsx
|
|
188
|
-
* import {LabeledTextField} from "@khanacademy/wonder-blocks-form";
|
|
189
|
-
*
|
|
190
|
-
* const [value, setValue] = React.useState("");
|
|
191
|
-
*
|
|
192
|
-
* <LabeledTextField
|
|
193
|
-
* label="Label"
|
|
194
|
-
* description="Hello, this is the description for this field"
|
|
195
|
-
* placeholder="Placeholder"
|
|
196
|
-
* value={value}
|
|
197
|
-
* onChange={setValue}
|
|
198
|
-
* />
|
|
199
|
-
* ```
|
|
200
|
-
*/
|
|
201
|
-
declare var _default: React.AbstractComponent<ExportProps, HTMLInputElement>;
|
|
202
|
-
declare export default typeof _default;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as $Flowgen$Import$_2e__2e__2f__2e__2e__2f__2e__2e__2f_wonder_2d_blocks_2d_core_2f_src_2f_util_2f_aria_2d_types from "../../../wonder-blocks-core/src/util/aria-types";
|
|
8
|
-
import * as React from "react";
|
|
9
|
-
import type { Checked } from "../util/types";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The internal stateless 🔘 Radio button
|
|
13
|
-
*/
|
|
14
|
-
declare var RadioCore: React.ForwardRefExoticComponent<{|
|
|
15
|
-
...$ReadOnly<$Flowgen$Import$_2e__2e__2f__2e__2e__2f__2e__2e__2f_wonder_2d_blocks_2d_core_2f_src_2f_util_2f_aria_2d_types.AriaAttributes>,
|
|
16
|
-
...$ReadOnly<{|
|
|
17
|
-
role?: $Flowgen$Import$_2e__2e__2f__2e__2e__2f__2e__2e__2f_wonder_2d_blocks_2d_core_2f_src_2f_util_2f_aria_2d_types.AriaRole | void,
|
|
18
|
-
|}>,
|
|
19
|
-
...{|
|
|
20
|
-
checked: Checked,
|
|
21
|
-
disabled: boolean,
|
|
22
|
-
error: boolean,
|
|
23
|
-
groupName?: string | void,
|
|
24
|
-
id?: string | void,
|
|
25
|
-
testId?: string | void,
|
|
26
|
-
onClick: () => void,
|
|
27
|
-
|},
|
|
28
|
-
...React.RefAttributes<HTMLInputElement>,
|
|
29
|
-
|}>;
|
|
30
|
-
declare export default typeof RadioCore;
|