@khanacademy/wonder-blocks-form 4.3.1 → 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.
@@ -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 React from "react";
8
- import type { StyleType } from "@khanacademy/wonder-blocks-core";
9
- import Choice from "./choice";
10
- declare type RadioGroupProps = {|
11
- /**
12
- * Children should be Choice components.
13
- */
14
- children: Array<
15
- React.Element<typeof Choice> | false | null | void
16
- >,
17
-
18
- /**
19
- * Group name for this checkbox or radio group. Should be unique for all
20
- * such groups displayed on a page.
21
- */
22
- groupName: string,
23
-
24
- /**
25
- * Optional label for the group. This label is optional to allow for
26
- * greater flexibility in implementing checkbox and radio groups.
27
- */
28
- label?: React.Node,
29
-
30
- /**
31
- * Optional description for the group.
32
- */
33
- description?: React.Node,
34
-
35
- /**
36
- * Optional error message. If supplied, the group will be displayed in an
37
- * error state, along with this error message. If no error state is desired,
38
- * simply do not supply this prop, or pass along null.
39
- */
40
- errorMessage?: string,
41
-
42
- /**
43
- * Custom styling for this group of checkboxes.
44
- */
45
- style?: StyleType,
46
-
47
- /**
48
- * Callback for when the selected value of the radio group has changed.
49
- */
50
- onChange: (selectedValue: string) => mixed,
51
-
52
- /**
53
- * Value of the selected radio item.
54
- */
55
- selectedValue: string,
56
-
57
- /**
58
- * Test ID used for e2e testing.
59
- */
60
- testId?: string,
61
- |};
62
- /**
63
- * A radio group allows only single selection. Like CheckboxGroup, this
64
- * component auto-populates many props for its children Choice components. The
65
- * Choice component is exposed for the user to apply custom styles or to
66
- * indicate which choices are disabled. The use of the groupName prop is
67
- * important to maintain expected keyboard navigation behavior for
68
- * accessibility.
69
- *
70
- * ### Usage
71
- *
72
- * ```jsx
73
- * import {Choice, RadioGroup} from "@khanacademy/wonder-blocks-form";
74
- *
75
- * const [selectedValue, setSelectedValue] = React.useState("");
76
- *
77
- * <RadioGroup
78
- * label="some-label"
79
- * description="some-description"
80
- * groupName="some-group-name"
81
- * onChange={setSelectedValue}
82
- * selectedValue={selectedValue}
83
- * >
84
- * // Add as many choices as necessary
85
- * <Choice
86
- * label="Choice 1"
87
- * value="some-choice-value"
88
- * />
89
- * <Choice
90
- * label="Choice 2"
91
- * value="some-choice-value-2"
92
- * description="Some choice description."
93
- * />
94
- * </RadioGroup>
95
- * ```
96
- */
97
- declare var RadioGroup: React.AbstractComponent<
98
- RadioGroupProps,
99
- HTMLFieldSetElement
100
- >;
101
- declare export default typeof RadioGroup;
@@ -1,86 +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
- * 🔘 A nicely styled radio button for all your non-AMFM radio button needs. Can
13
- * optionally take label and description props.
14
- *
15
- * This component should not really be used by itself because radio buttons are
16
- * often grouped together. See RadioGroup.
17
- */
18
- declare var Radio: React.ForwardRefExoticComponent<{|
19
- ...$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>,
20
- ...$ReadOnly<{|
21
- 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,
22
- |}>,
23
- ...{|
24
- /**
25
- * Whether this component is checked
26
- */
27
- checked: boolean,
28
-
29
- /**
30
- * Whether this component is disabled
31
- */
32
- disabled?: boolean | void,
33
-
34
- /**
35
- * Whether this component should show an error state
36
- */
37
- error?: boolean | void,
38
-
39
- /**
40
- * Callback when this component is selected. The newCheckedState is the
41
- * new checked state of the component.
42
- */
43
- onChange: (newCheckedState: boolean) => mixed,
44
-
45
- /**
46
- * Optional label for the field.
47
- */
48
- label?: React.Node,
49
-
50
- /**
51
- * Optional description for the field.
52
- */
53
- description?: React.Node,
54
-
55
- /**
56
- * Unique identifier attached to the HTML input element. If used, need to
57
- * guarantee that the ID is unique within everything rendered on a page.
58
- * Used to match `<label>` with `<input>` elements for screenreaders.
59
- */
60
- id?: string | void,
61
-
62
- /**
63
- * Optional styling for the container. Does not style the component.
64
- */
65
- style?: StyleType,
66
-
67
- /**
68
- * Adds CSS classes to the Checkbox.
69
- */
70
- className?: string | void,
71
-
72
- /**
73
- * Optional test ID for e2e testing
74
- */
75
- testId?: string | void,
76
-
77
- /**
78
- * Name for the checkbox or radio button group. Only applicable for group
79
- * contexts, auto-populated by group components via Choice.
80
- * @ignore
81
- */
82
- groupName?: string | void,
83
- |},
84
- ...React.RefAttributes<HTMLInputElement>,
85
- |}>;
86
- declare export default typeof Radio;
@@ -1,182 +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 type { StyleType, AriaProps } from "@khanacademy/wonder-blocks-core";
9
- export type TextFieldType = "text" | "password" | "email" | "number" | "tel";
10
- declare type WithForwardRef = {|
11
- forwardedRef: {|
12
- current: HTMLInputElement | null,
13
- |},
14
- |};
15
- declare type Props = {|
16
- ...AriaProps,
17
- ...{|
18
- /**
19
- * The unique identifier for the input.
20
- */
21
- id: string,
22
-
23
- /**
24
- * Determines the type of input. Defaults to text.
25
- */
26
- type: TextFieldType,
27
-
28
- /**
29
- * The input value.
30
- */
31
- value: string,
32
-
33
- /**
34
- * Makes a read-only input field that cannot be focused. Defaults to false.
35
- */
36
- disabled: boolean,
37
-
38
- /**
39
- * Provide a validation for the input value.
40
- * Return a string error message or null | void for a valid input.
41
- */
42
- validate?: (value: string) => string | null | void,
43
-
44
- /**
45
- * Called right after the TextField input is validated.
46
- */
47
- onValidate?: (errorMessage?: string | null | void) => mixed,
48
-
49
- /**
50
- * Called when the value has changed.
51
- */
52
- onChange: (newValue: string) => mixed,
53
-
54
- /**
55
- * Called when a key is pressed.
56
- */
57
- onKeyDown?: (event: SyntheticKeyboardEvent<HTMLInputElement>) => mixed,
58
-
59
- /**
60
- * Called when the element has been focused.
61
- */
62
- onFocus?: (event: SyntheticFocusEvent<HTMLInputElement>) => mixed,
63
-
64
- /**
65
- * Called when the element has been blurred.
66
- */
67
- onBlur?: (event: SyntheticFocusEvent<HTMLInputElement>) => mixed,
68
-
69
- /**
70
- * Provide hints or examples of what to enter.
71
- */
72
- placeholder?: string,
73
-
74
- /**
75
- * Whether this field is required to to continue, or the error message to
76
- * render if this field is left blank.
77
- *
78
- * This can be a boolean or a string.
79
- *
80
- * String:
81
- * Please pass in a translated string to use as the error message that will
82
- * render if the user leaves this field blank. If this field is required,
83
- * and a string is not passed in, a default untranslated string will render
84
- * upon error.
85
- * Note: The string will not be used if a `validate` prop is passed in.
86
- *
87
- * Example message: i18n._("A password is required to log in.")
88
- *
89
- * Boolean:
90
- * True/false indicating whether this field is required. Please do not pass
91
- * in `true` if possible - pass in the error string instead.
92
- * If `true` is passed, and a `validate` prop is not passed, that means
93
- * there is no corresponding message and the default untranlsated message
94
- * will be used.
95
- */
96
- required?: boolean | string,
97
-
98
- /**
99
- * Change the default focus ring color to fit a dark background.
100
- */
101
- light: boolean,
102
-
103
- /**
104
- * Custom styles for the input.
105
- */
106
- style?: StyleType,
107
-
108
- /**
109
- * Optional test ID for e2e testing.
110
- */
111
- testId?: string,
112
-
113
- /**
114
- * Specifies if the input field is read-only.
115
- */
116
- readOnly?: boolean,
117
-
118
- /**
119
- * Whether this field should autofocus on page load.
120
- */
121
- autoFocus?: boolean,
122
-
123
- /**
124
- * Specifies if the input field allows autocomplete.
125
- */
126
- autoComplete?: string,
127
- |},
128
- |};
129
- declare type PropsWithForwardRef = {| ...Props, ...WithForwardRef |};
130
- declare type DefaultProps = {|
131
- type: $PropertyType<PropsWithForwardRef, "type">,
132
- disabled: $PropertyType<PropsWithForwardRef, "disabled">,
133
- light: $PropertyType<PropsWithForwardRef, "light">,
134
- |};
135
- declare type State = {|
136
- /**
137
- * Displayed when the validation fails.
138
- */
139
- error: string | null | void,
140
-
141
- /**
142
- * The user focuses on this field.
143
- */
144
- focused: boolean,
145
- |};
146
- /**
147
- * A TextField is an element used to accept a single line of text from the user.
148
- */
149
- declare class TextField extends React.Component<PropsWithForwardRef, State> {
150
- static defaultProps: DefaultProps;
151
- constructor(props: PropsWithForwardRef): this;
152
- state: State;
153
- componentDidMount(): void;
154
- maybeValidate: (newValue: string) => void;
155
- handleChange: (event: SyntheticInputEvent<HTMLInputElement>) => mixed;
156
- handleFocus: (event: SyntheticFocusEvent<HTMLInputElement>) => mixed;
157
- handleBlur: (event: SyntheticFocusEvent<HTMLInputElement>) => mixed;
158
- render(): React.Node;
159
- }
160
- declare type ExportProps = $Diff<
161
- React.ElementConfig<typeof TextField>,
162
- { forwardedRef: any }
163
- >;
164
- /**
165
- * A TextField is an element used to accept a single line of text from the user.
166
- *
167
- * ### Usage
168
- *
169
- * ```jsx
170
- * import {TextField} from "@khanacademy/wonder-blocks-form";
171
- *
172
- * const [value, setValue] = React.useState("");
173
- *
174
- * <TextField
175
- * id="some-unique-text-field-id"
176
- * value={value}
177
- * onChange={setValue}
178
- * />
179
- * ```
180
- */
181
- declare var _default: React.AbstractComponent<ExportProps, HTMLInputElement>;
182
- declare export default typeof _default;
@@ -1,20 +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 Checkbox from "./components/checkbox";
8
- import Choice from "./components/choice";
9
- import CheckboxGroup from "./components/checkbox-group";
10
- import RadioGroup from "./components/radio-group";
11
- import TextField from "./components/text-field";
12
- import LabeledTextField from "./components/labeled-text-field";
13
- declare export {
14
- Checkbox,
15
- Choice,
16
- CheckboxGroup,
17
- RadioGroup,
18
- TextField,
19
- LabeledTextField,
20
- };
@@ -1,138 +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 type { AriaProps, StyleType } from "@khanacademy/wonder-blocks-core";
8
- import Choice from "../components/choice";
9
- export type Checked = boolean | null | void;
10
- export type ChoiceCoreProps = {|
11
- ...AriaProps,
12
- ...{|
13
- /**
14
- * Whether this component is checked
15
- */
16
- checked: Checked,
17
-
18
- /**
19
- * Whether this component is disabled
20
- */
21
- disabled: boolean,
22
-
23
- /**
24
- * Whether this component should show an error state
25
- */
26
- error: boolean,
27
-
28
- /**
29
- * Name for the checkbox or radio button group
30
- */
31
- groupName?: string,
32
-
33
- /**
34
- * Unique identifier attached to the HTML input element. If used, need to
35
- * guarantee that the ID is unique within everything rendered on a page.
36
- * Used to match <label> with <input> elements for screenreaders.
37
- */
38
- id?: string,
39
-
40
- /**
41
- * Optional test ID for e2e testing
42
- */
43
- testId?: string,
44
-
45
- /**
46
- * Function that executes when the choice is clicked.
47
- */
48
- onClick: () => void,
49
- |},
50
- |};
51
- export type ChoiceComponentProps = {|
52
- ...ChoiceCoreProps,
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?: string,
64
-
65
- /**
66
- * Optional description for the field.
67
- */
68
- description?: string,
69
-
70
- /**
71
- * Ignored because only applicable to Choice components in a group.
72
- */
73
- value?: string,
74
-
75
- /**
76
- * Optional styling for the container. Does not style the component.
77
- */
78
- style?: StyleType,
79
- |},
80
- |};
81
- export type SharedGroupProps = {|
82
- /**
83
- * Children should be Choice components.
84
- */
85
- children: typeof Choice,
86
-
87
- /**
88
- * Group name for this checkbox or radio group. Should be unique for all
89
- * such groups displayed on a page.
90
- */
91
- groupName: string,
92
-
93
- /**
94
- * Optional label for the group. This label is optional to allow for
95
- * greater flexibility in implementing checkbox and radio groups.
96
- */
97
- label?: string,
98
-
99
- /**
100
- * Optional description for the group.
101
- */
102
- description?: string,
103
-
104
- /**
105
- * Optional error message. If supplied, the group will be displayed in an
106
- * error state, along with this error message. If no error state is desired,
107
- * simply do not supply this prop, or pass along null.
108
- */
109
- errorMessage?: string,
110
-
111
- /**
112
- * Custom styling for this group of checkboxes.
113
- */
114
- style?: StyleType,
115
- |};
116
- export type CheckboxGroupProps = {|
117
- /**
118
- * Callback for when selection of the group has changed. Passes the newly
119
- * selected values.
120
- */
121
- onChange: (selectedValues: Array<string>) => mixed,
122
-
123
- /**
124
- * An array of the values of the selected values in this checkbox group.
125
- */
126
- selectedValues: Array<string>,
127
- |};
128
- export type RadioGroupProps = {|
129
- /**
130
- * Callback for when the selected value of the radio group has changed.
131
- */
132
- onChange: (selectedValue: string) => mixed,
133
-
134
- /**
135
- * Value of the selected radio item.
136
- */
137
- selectedValue: string,
138
- |};