@khanacademy/wonder-blocks-form 4.2.2 → 4.3.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 +31 -0
- package/dist/components/checkbox-core.d.ts +13 -8
- package/dist/components/checkbox-core.js.flow +19 -10
- package/dist/components/checkbox-group.d.ts +2 -5
- package/dist/components/checkbox-group.js.flow +5 -6
- package/dist/components/checkbox.d.ts +33 -39
- package/dist/components/checkbox.js.flow +38 -41
- package/dist/components/choice-internal.d.ts +19 -31
- package/dist/components/choice-internal.js.flow +25 -32
- package/dist/components/choice.d.ts +50 -60
- package/dist/components/choice.js.flow +79 -84
- package/dist/components/radio-core.d.ts +13 -5
- package/dist/components/radio-core.js.flow +19 -7
- package/dist/components/radio-group.d.ts +2 -5
- package/dist/components/radio-group.js.flow +5 -6
- package/dist/components/radio.d.ts +18 -24
- package/dist/components/radio.js.flow +24 -27
- package/dist/es/index.js +262 -294
- package/dist/index.js +262 -294
- package/dist/util/types.d.ts +1 -1
- package/dist/util/types.js.flow +1 -1
- package/package.json +6 -6
- package/src/components/__tests__/{checkbox.test.js → checkbox.test.tsx} +55 -1
- package/src/components/checkbox-core.tsx +32 -31
- package/src/components/checkbox-group.tsx +33 -22
- package/src/components/checkbox.tsx +21 -16
- package/src/components/choice-internal.tsx +60 -58
- package/src/components/choice.tsx +39 -32
- package/src/components/radio-core.tsx +16 -14
- package/src/components/radio-group.tsx +14 -11
- package/src/components/radio.tsx +21 -16
- package/src/util/types.ts +1 -1
- package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-form
|
|
2
2
|
|
|
3
|
+
## 4.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b05c5344: Forward refs in RadioGroup
|
|
8
|
+
- f84dfb23: Foward refs in CheckboxGroup
|
|
9
|
+
- 13f9de9c: Forward refs in Checkbox
|
|
10
|
+
- a5116f0b: Forwards refs in Choice, Radio, and RadioCore
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [0423a440]
|
|
15
|
+
- Updated dependencies [c37b99aa]
|
|
16
|
+
- Updated dependencies [afd5a801]
|
|
17
|
+
- Updated dependencies [13c48aa0]
|
|
18
|
+
- Updated dependencies [cade62f3]
|
|
19
|
+
- Updated dependencies [c4cef3e6]
|
|
20
|
+
- Updated dependencies [4c900085]
|
|
21
|
+
- @khanacademy/wonder-blocks-typography@2.1.0
|
|
22
|
+
- @khanacademy/wonder-blocks-core@5.3.0
|
|
23
|
+
- @khanacademy/wonder-blocks-clickable@3.1.1
|
|
24
|
+
- @khanacademy/wonder-blocks-icon@2.0.14
|
|
25
|
+
- @khanacademy/wonder-blocks-layout@2.0.14
|
|
26
|
+
|
|
27
|
+
## 4.2.3
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [ad8beb23]
|
|
32
|
+
- @khanacademy/wonder-blocks-clickable@3.1.0
|
|
33
|
+
|
|
3
34
|
## 4.2.2
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Checked } from "../util/types";
|
|
3
3
|
/**
|
|
4
4
|
* The internal stateless ☑️ Checkbox
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
declare const CheckboxCore: React.ForwardRefExoticComponent<Readonly<import("../../../wonder-blocks-core/src/util/aria-types").AriaAttributes> & Readonly<{
|
|
7
|
+
role?: import("../../../wonder-blocks-core/src/util/aria-types").AriaRole | undefined;
|
|
8
|
+
}> & {
|
|
9
|
+
checked: Checked;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
error: boolean;
|
|
12
|
+
groupName?: string | undefined;
|
|
13
|
+
id?: string | undefined;
|
|
14
|
+
testId?: string | undefined;
|
|
15
|
+
onClick: () => void;
|
|
16
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
17
|
+
export default CheckboxCore;
|
|
@@ -4,18 +4,27 @@
|
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
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";
|
|
7
8
|
import * as React from "react";
|
|
8
|
-
import type {
|
|
9
|
+
import type { Checked } from "../util/types";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* The internal stateless ☑️ Checkbox
|
|
12
13
|
*/
|
|
13
|
-
declare
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
declare var CheckboxCore: 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 CheckboxCore;
|
|
@@ -77,8 +77,5 @@ type CheckboxGroupProps = {
|
|
|
77
77
|
* </CheckboxGroup>
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
render(): React.ReactNode;
|
|
83
|
-
}
|
|
84
|
-
export {};
|
|
80
|
+
declare const CheckboxGroup: React.ForwardRefExoticComponent<CheckboxGroupProps & React.RefAttributes<HTMLFieldSetElement>>;
|
|
81
|
+
export default CheckboxGroup;
|
|
@@ -93,9 +93,8 @@ declare type CheckboxGroupProps = {|
|
|
|
93
93
|
* </CheckboxGroup>
|
|
94
94
|
* ```
|
|
95
95
|
*/
|
|
96
|
-
declare
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
96
|
+
declare var CheckboxGroup: React.AbstractComponent<
|
|
97
|
+
CheckboxGroupProps,
|
|
98
|
+
HTMLFieldSetElement
|
|
99
|
+
>;
|
|
100
|
+
declare export default typeof CheckboxGroup;
|
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
3
|
import type { Checked } from "../util/types";
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* ☑️ A nicely styled checkbox for all your checking needs. Can optionally take
|
|
6
|
+
* label and description props.
|
|
7
|
+
*
|
|
8
|
+
* If used by itself, a checkbox provides two options - checked and unchecked.
|
|
9
|
+
* A group of checkboxes can be used to allow a user to select multiple values
|
|
10
|
+
* from a list of options.
|
|
11
|
+
*
|
|
12
|
+
* If you want a whole group of Checkbox[es] that are related, see the Choice
|
|
13
|
+
* and CheckboxGroup components.
|
|
14
|
+
*
|
|
15
|
+
* ### Usage
|
|
16
|
+
*
|
|
17
|
+
* ```jsx
|
|
18
|
+
* import {Checkbox} from "@khanacademy/wonder-blocks-form";
|
|
19
|
+
*
|
|
20
|
+
* const [checked, setChecked] = React.useState(false);
|
|
21
|
+
*
|
|
22
|
+
* <Checkbox checked={checked} onChange={setChecked} />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare const Checkbox: React.ForwardRefExoticComponent<Readonly<import("../../../wonder-blocks-core/src/util/aria-types").AriaAttributes> & Readonly<{
|
|
26
|
+
role?: import("../../../wonder-blocks-core/src/util/aria-types").AriaRole | undefined;
|
|
27
|
+
}> & {
|
|
5
28
|
/**
|
|
6
29
|
* Whether this component is checked or indeterminate
|
|
7
30
|
*/
|
|
@@ -9,11 +32,11 @@ type ChoiceComponentProps = AriaProps & {
|
|
|
9
32
|
/**
|
|
10
33
|
* Whether this component is disabled
|
|
11
34
|
*/
|
|
12
|
-
disabled
|
|
35
|
+
disabled?: boolean | undefined;
|
|
13
36
|
/**
|
|
14
37
|
* Whether this component should show an error state
|
|
15
38
|
*/
|
|
16
|
-
error
|
|
39
|
+
error?: boolean | undefined;
|
|
17
40
|
/**
|
|
18
41
|
* Callback when this component is selected. The newCheckedState is the
|
|
19
42
|
* new checked state of the component.
|
|
@@ -32,7 +55,7 @@ type ChoiceComponentProps = AriaProps & {
|
|
|
32
55
|
* guarantee that the ID is unique within everything rendered on a page.
|
|
33
56
|
* Used to match `<label>` with `<input>` elements for screenreaders.
|
|
34
57
|
*/
|
|
35
|
-
id?: string;
|
|
58
|
+
id?: string | undefined;
|
|
36
59
|
/**
|
|
37
60
|
* Optional styling for the container. Does not style the component.
|
|
38
61
|
*/
|
|
@@ -40,45 +63,16 @@ type ChoiceComponentProps = AriaProps & {
|
|
|
40
63
|
/**
|
|
41
64
|
* Adds CSS classes to the Checkbox.
|
|
42
65
|
*/
|
|
43
|
-
className?: string;
|
|
66
|
+
className?: string | undefined;
|
|
44
67
|
/**
|
|
45
68
|
* Optional test ID for e2e testing
|
|
46
69
|
*/
|
|
47
|
-
testId?: string;
|
|
70
|
+
testId?: string | undefined;
|
|
48
71
|
/**
|
|
49
72
|
* Name for the checkbox or radio button group. Only applicable for group
|
|
50
73
|
* contexts, auto-populated by group components via Choice.
|
|
51
74
|
* @ignore
|
|
52
75
|
*/
|
|
53
|
-
groupName?: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
disabled: ChoiceComponentProps["disabled"];
|
|
57
|
-
error: ChoiceComponentProps["error"];
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* ☑️ A nicely styled checkbox for all your checking needs. Can optionally take
|
|
61
|
-
* label and description props.
|
|
62
|
-
*
|
|
63
|
-
* If used by itself, a checkbox provides two options - checked and unchecked.
|
|
64
|
-
* A group of checkboxes can be used to allow a user to select multiple values
|
|
65
|
-
* from a list of options.
|
|
66
|
-
*
|
|
67
|
-
* If you want a whole group of Checkbox[es] that are related, see the Choice
|
|
68
|
-
* and CheckboxGroup components.
|
|
69
|
-
*
|
|
70
|
-
* ### Usage
|
|
71
|
-
*
|
|
72
|
-
* ```jsx
|
|
73
|
-
* import {Checkbox} from "@khanacademy/wonder-blocks-form";
|
|
74
|
-
*
|
|
75
|
-
* const [checked, setChecked] = React.useState(false);
|
|
76
|
-
*
|
|
77
|
-
* <Checkbox checked={checked} onChange={setChecked} />
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
export default class Checkbox extends React.Component<ChoiceComponentProps> {
|
|
81
|
-
static defaultProps: DefaultProps;
|
|
82
|
-
render(): React.ReactNode;
|
|
83
|
-
}
|
|
84
|
-
export {};
|
|
76
|
+
groupName?: string | undefined;
|
|
77
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
78
|
+
export default Checkbox;
|
|
@@ -4,11 +4,37 @@
|
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
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";
|
|
7
8
|
import * as React from "react";
|
|
8
|
-
import type {
|
|
9
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
9
10
|
import type { Checked } from "../util/types";
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
|}>,
|
|
12
38
|
...{|
|
|
13
39
|
/**
|
|
14
40
|
* Whether this component is checked or indeterminate
|
|
@@ -18,12 +44,12 @@ declare type ChoiceComponentProps = {|
|
|
|
18
44
|
/**
|
|
19
45
|
* Whether this component is disabled
|
|
20
46
|
*/
|
|
21
|
-
disabled
|
|
47
|
+
disabled?: boolean | void,
|
|
22
48
|
|
|
23
49
|
/**
|
|
24
50
|
* Whether this component should show an error state
|
|
25
51
|
*/
|
|
26
|
-
error
|
|
52
|
+
error?: boolean | void,
|
|
27
53
|
|
|
28
54
|
/**
|
|
29
55
|
* Callback when this component is selected. The newCheckedState is the
|
|
@@ -46,7 +72,7 @@ declare type ChoiceComponentProps = {|
|
|
|
46
72
|
* guarantee that the ID is unique within everything rendered on a page.
|
|
47
73
|
* Used to match `<label>` with `<input>` elements for screenreaders.
|
|
48
74
|
*/
|
|
49
|
-
id?: string,
|
|
75
|
+
id?: string | void,
|
|
50
76
|
|
|
51
77
|
/**
|
|
52
78
|
* Optional styling for the container. Does not style the component.
|
|
@@ -56,49 +82,20 @@ declare type ChoiceComponentProps = {|
|
|
|
56
82
|
/**
|
|
57
83
|
* Adds CSS classes to the Checkbox.
|
|
58
84
|
*/
|
|
59
|
-
className?: string,
|
|
85
|
+
className?: string | void,
|
|
60
86
|
|
|
61
87
|
/**
|
|
62
88
|
* Optional test ID for e2e testing
|
|
63
89
|
*/
|
|
64
|
-
testId?: string,
|
|
90
|
+
testId?: string | void,
|
|
65
91
|
|
|
66
92
|
/**
|
|
67
93
|
* Name for the checkbox or radio button group. Only applicable for group
|
|
68
94
|
* contexts, auto-populated by group components via Choice.
|
|
69
95
|
* @ignore
|
|
70
96
|
*/
|
|
71
|
-
groupName?: string,
|
|
97
|
+
groupName?: string | void,
|
|
72
98
|
|},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
error: $PropertyType<ChoiceComponentProps, "error">,
|
|
77
|
-
|};
|
|
78
|
-
/**
|
|
79
|
-
* ☑️ A nicely styled checkbox for all your checking needs. Can optionally take
|
|
80
|
-
* label and description props.
|
|
81
|
-
*
|
|
82
|
-
* If used by itself, a checkbox provides two options - checked and unchecked.
|
|
83
|
-
* A group of checkboxes can be used to allow a user to select multiple values
|
|
84
|
-
* from a list of options.
|
|
85
|
-
*
|
|
86
|
-
* If you want a whole group of Checkbox[es] that are related, see the Choice
|
|
87
|
-
* and CheckboxGroup components.
|
|
88
|
-
*
|
|
89
|
-
* ### Usage
|
|
90
|
-
*
|
|
91
|
-
* ```jsx
|
|
92
|
-
* import {Checkbox} from "@khanacademy/wonder-blocks-form";
|
|
93
|
-
*
|
|
94
|
-
* const [checked, setChecked] = React.useState(false);
|
|
95
|
-
*
|
|
96
|
-
* <Checkbox checked={checked} onChange={setChecked} />
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
declare export default class Checkbox
|
|
100
|
-
extends React.Component<ChoiceComponentProps>
|
|
101
|
-
{
|
|
102
|
-
static defaultProps: DefaultProps;
|
|
103
|
-
render(): React.Node;
|
|
104
|
-
}
|
|
99
|
+
...React.RefAttributes<HTMLInputElement>,
|
|
100
|
+
|}>;
|
|
101
|
+
declare export default typeof Checkbox;
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
/**
|
|
4
|
+
* This is a potentially labeled 🔘 or ☑️ item. This is an internal component
|
|
5
|
+
* that's wrapped by Checkbox and Radio. Choice is a wrapper for Checkbox and
|
|
6
|
+
* Radio with many of its props auto-populated, to be used with CheckboxGroup
|
|
7
|
+
* and RadioGroup. This design allows for more explicit prop typing. For
|
|
8
|
+
* example, we can make onChange a required prop on Checkbox but not on Choice
|
|
9
|
+
* (because for Choice, that prop would be auto-populated by CheckboxGroup).
|
|
10
|
+
*/ declare const ChoiceInternal: React.ForwardRefExoticComponent<Readonly<import("../../../wonder-blocks-core/src/util/aria-types").AriaAttributes> & Readonly<{
|
|
11
|
+
role?: import("../../../wonder-blocks-core/src/util/aria-types").AriaRole | undefined;
|
|
12
|
+
}> & {
|
|
6
13
|
/** Whether this choice is checked. */
|
|
7
14
|
checked: boolean | null | undefined;
|
|
8
15
|
/** Whether this choice option is disabled. */
|
|
9
|
-
disabled
|
|
16
|
+
disabled?: boolean | undefined;
|
|
10
17
|
/** Whether this choice is in error mode. */
|
|
11
|
-
error
|
|
18
|
+
error?: boolean | undefined;
|
|
12
19
|
/** Returns the new checked state of the component. */
|
|
13
20
|
onChange: (newCheckedState: boolean) => unknown;
|
|
14
21
|
/**
|
|
15
22
|
* Used for accessibility purposes, where the label id should match the
|
|
16
23
|
* input id.
|
|
17
24
|
*/
|
|
18
|
-
id?: string;
|
|
25
|
+
id?: string | undefined;
|
|
19
26
|
/**
|
|
20
27
|
* Optional additional styling.
|
|
21
28
|
*/
|
|
@@ -23,11 +30,11 @@ type Props = AriaProps & {
|
|
|
23
30
|
/**
|
|
24
31
|
* Adds CSS classes to the Button.
|
|
25
32
|
*/
|
|
26
|
-
className?: string;
|
|
33
|
+
className?: string | undefined;
|
|
27
34
|
/**
|
|
28
35
|
* Optional id for testing purposes.
|
|
29
36
|
*/
|
|
30
|
-
testId?: string;
|
|
37
|
+
testId?: string | undefined;
|
|
31
38
|
/**
|
|
32
39
|
* Label for the field.
|
|
33
40
|
*/
|
|
@@ -35,27 +42,8 @@ type Props = AriaProps & {
|
|
|
35
42
|
/** Optional description for the field. */
|
|
36
43
|
description?: React.ReactNode;
|
|
37
44
|
/** Auto-populated by parent's groupName prop if in a group. */
|
|
38
|
-
groupName?: string;
|
|
45
|
+
groupName?: string | undefined;
|
|
39
46
|
/** Takes either "radio" or "checkbox" value. */
|
|
40
47
|
variant: "radio" | "checkbox";
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
disabled: Props["disabled"];
|
|
44
|
-
error: Props["error"];
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* This is a potentially labeled 🔘 or ☑️ item. This is an internal component
|
|
48
|
-
* that's wrapped by Checkbox and Radio. Choice is a wrapper for Checkbox and
|
|
49
|
-
* Radio with many of its props auto-populated, to be used with CheckboxGroup
|
|
50
|
-
* and RadioGroup. This design allows for more explicit prop typing. For
|
|
51
|
-
* example, we can make onChange a required prop on Checkbox but not on Choice
|
|
52
|
-
* (because for Choice, that prop would be auto-populated by CheckboxGroup).
|
|
53
|
-
*/ export default class ChoiceInternal extends React.Component<Props> {
|
|
54
|
-
static defaultProps: DefaultProps;
|
|
55
|
-
handleClick: () => void;
|
|
56
|
-
getChoiceCoreComponent(): typeof RadioCore | typeof CheckboxCore;
|
|
57
|
-
getLabel(id: string): React.ReactNode;
|
|
58
|
-
getDescription(id?: string): React.ReactNode;
|
|
59
|
-
render(): React.ReactNode;
|
|
60
|
-
}
|
|
61
|
-
export {};
|
|
48
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
49
|
+
export default ChoiceInternal;
|
|
@@ -4,12 +4,23 @@
|
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
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";
|
|
7
8
|
import * as React from "react";
|
|
8
|
-
import type {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
|}>,
|
|
13
24
|
...{|
|
|
14
25
|
/**
|
|
15
26
|
* Whether this choice is checked.
|
|
@@ -19,12 +30,12 @@ declare type Props = {|
|
|
|
19
30
|
/**
|
|
20
31
|
* Whether this choice option is disabled.
|
|
21
32
|
*/
|
|
22
|
-
disabled
|
|
33
|
+
disabled?: boolean | void,
|
|
23
34
|
|
|
24
35
|
/**
|
|
25
36
|
* Whether this choice is in error mode.
|
|
26
37
|
*/
|
|
27
|
-
error
|
|
38
|
+
error?: boolean | void,
|
|
28
39
|
|
|
29
40
|
/**
|
|
30
41
|
* Returns the new checked state of the component.
|
|
@@ -35,7 +46,7 @@ declare type Props = {|
|
|
|
35
46
|
* Used for accessibility purposes, where the label id should match the
|
|
36
47
|
* input id.
|
|
37
48
|
*/
|
|
38
|
-
id?: string,
|
|
49
|
+
id?: string | void,
|
|
39
50
|
|
|
40
51
|
/**
|
|
41
52
|
* Optional additional styling.
|
|
@@ -45,12 +56,12 @@ declare type Props = {|
|
|
|
45
56
|
/**
|
|
46
57
|
* Adds CSS classes to the Button.
|
|
47
58
|
*/
|
|
48
|
-
className?: string,
|
|
59
|
+
className?: string | void,
|
|
49
60
|
|
|
50
61
|
/**
|
|
51
62
|
* Optional id for testing purposes.
|
|
52
63
|
*/
|
|
53
|
-
testId?: string,
|
|
64
|
+
testId?: string | void,
|
|
54
65
|
|
|
55
66
|
/**
|
|
56
67
|
* Label for the field.
|
|
@@ -65,31 +76,13 @@ declare type Props = {|
|
|
|
65
76
|
/**
|
|
66
77
|
* Auto-populated by parent's groupName prop if in a group.
|
|
67
78
|
*/
|
|
68
|
-
groupName?: string,
|
|
79
|
+
groupName?: string | void,
|
|
69
80
|
|
|
70
81
|
/**
|
|
71
82
|
* Takes either "radio" or "checkbox" value.
|
|
72
83
|
*/
|
|
73
84
|
variant: "radio" | "checkbox",
|
|
74
85
|
|},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
error: $PropertyType<Props, "error">,
|
|
79
|
-
|};
|
|
80
|
-
/**
|
|
81
|
-
* This is a potentially labeled 🔘 or ☑️ item. This is an internal component
|
|
82
|
-
* that's wrapped by Checkbox and Radio. Choice is a wrapper for Checkbox and
|
|
83
|
-
* Radio with many of its props auto-populated, to be used with CheckboxGroup
|
|
84
|
-
* and RadioGroup. This design allows for more explicit prop typing. For
|
|
85
|
-
* example, we can make onChange a required prop on Checkbox but not on Choice
|
|
86
|
-
* (because for Choice, that prop would be auto-populated by CheckboxGroup).
|
|
87
|
-
*/
|
|
88
|
-
declare export default class ChoiceInternal extends React.Component<Props> {
|
|
89
|
-
static defaultProps: DefaultProps;
|
|
90
|
-
handleClick: () => void;
|
|
91
|
-
getChoiceCoreComponent(): typeof RadioCore | typeof CheckboxCore;
|
|
92
|
-
getLabel(id: string): React.Node;
|
|
93
|
-
getDescription(id?: string): React.Node;
|
|
94
|
-
render(): React.Node;
|
|
95
|
-
}
|
|
86
|
+
...React.RefAttributes<HTMLInputElement>,
|
|
87
|
+
|}>;
|
|
88
|
+
declare export default typeof ChoiceInternal;
|
|
@@ -1,58 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type {
|
|
3
|
-
import Checkbox from "./checkbox";
|
|
4
|
-
import Radio from "./radio";
|
|
5
|
-
type Props = AriaProps & {
|
|
6
|
-
/** User-defined. Label for the field. */
|
|
7
|
-
label: React.ReactNode;
|
|
8
|
-
/** User-defined. Optional description for the field. */
|
|
9
|
-
description?: React.ReactNode;
|
|
10
|
-
/** User-defined. Should be distinct for each item in the group. */
|
|
11
|
-
value: string;
|
|
12
|
-
/** User-defined. Whether this choice option is disabled. Default false. */
|
|
13
|
-
disabled: boolean;
|
|
14
|
-
/** User-defined. Optional id for testing purposes. */
|
|
15
|
-
testId?: string;
|
|
16
|
-
/** User-defined. Optional additional styling. */
|
|
17
|
-
style?: StyleType;
|
|
18
|
-
/**
|
|
19
|
-
* Auto-populated by parent. Whether this choice is checked.
|
|
20
|
-
* @ignore
|
|
21
|
-
*/
|
|
22
|
-
checked: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Auto-populated by parent. Whether this choice is in error mode (everything
|
|
25
|
-
* in a choice group would be in error mode at the same time).
|
|
26
|
-
* @ignore
|
|
27
|
-
*/
|
|
28
|
-
error?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Auto-populated by parent. Used for accessibility purposes, where the label
|
|
31
|
-
* id should match the input id.
|
|
32
|
-
* @ignore
|
|
33
|
-
*/
|
|
34
|
-
id?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Auto-populated by parent's groupName prop.
|
|
37
|
-
* @ignore
|
|
38
|
-
*/
|
|
39
|
-
groupName?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Auto-populated by parent. Returns the new checked state of the component.
|
|
42
|
-
* @ignore
|
|
43
|
-
*/
|
|
44
|
-
onChange: (newCheckedState: boolean) => unknown;
|
|
45
|
-
/**
|
|
46
|
-
* Auto-populated by parent.
|
|
47
|
-
* @ignore
|
|
48
|
-
*/
|
|
49
|
-
variant?: "radio" | "checkbox";
|
|
50
|
-
};
|
|
51
|
-
type DefaultProps = {
|
|
52
|
-
checked: Props["checked"];
|
|
53
|
-
disabled: Props["disabled"];
|
|
54
|
-
onChange: Props["onChange"];
|
|
55
|
-
};
|
|
2
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
56
3
|
/**
|
|
57
4
|
* This is a labeled 🔘 or ☑️ item. Choice is meant to be used as children of
|
|
58
5
|
* CheckboxGroup and RadioGroup because many of its props are auto-populated
|
|
@@ -119,9 +66,52 @@ type DefaultProps = {
|
|
|
119
66
|
* </RadioGroup>
|
|
120
67
|
* ```
|
|
121
68
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
69
|
+
declare const Choice: React.ForwardRefExoticComponent<Readonly<import("../../../wonder-blocks-core/src/util/aria-types").AriaAttributes> & Readonly<{
|
|
70
|
+
role?: import("../../../wonder-blocks-core/src/util/aria-types").AriaRole | undefined;
|
|
71
|
+
}> & {
|
|
72
|
+
/** User-defined. Label for the field. */
|
|
73
|
+
label: React.ReactNode;
|
|
74
|
+
/** User-defined. Optional description for the field. */
|
|
75
|
+
description?: React.ReactNode;
|
|
76
|
+
/** User-defined. Should be distinct for each item in the group. */
|
|
77
|
+
value: string;
|
|
78
|
+
/** User-defined. Whether this choice option is disabled. Default false. */
|
|
79
|
+
disabled?: boolean | undefined;
|
|
80
|
+
/** User-defined. Optional id for testing purposes. */
|
|
81
|
+
testId?: string | undefined;
|
|
82
|
+
/** User-defined. Optional additional styling. */
|
|
83
|
+
style?: StyleType;
|
|
84
|
+
/**
|
|
85
|
+
* Auto-populated by parent. Whether this choice is checked.
|
|
86
|
+
* @ignore
|
|
87
|
+
*/
|
|
88
|
+
checked?: boolean | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Auto-populated by parent. Whether this choice is in error mode (everything
|
|
91
|
+
* in a choice group would be in error mode at the same time).
|
|
92
|
+
* @ignore
|
|
93
|
+
*/
|
|
94
|
+
error?: boolean | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Auto-populated by parent. Used for accessibility purposes, where the label
|
|
97
|
+
* id should match the input id.
|
|
98
|
+
* @ignore
|
|
99
|
+
*/
|
|
100
|
+
id?: string | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Auto-populated by parent's groupName prop.
|
|
103
|
+
* @ignore
|
|
104
|
+
*/
|
|
105
|
+
groupName?: string | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Auto-populated by parent. Returns the new checked state of the component.
|
|
108
|
+
* @ignore
|
|
109
|
+
*/
|
|
110
|
+
onChange?: ((newCheckedState: boolean) => unknown) | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Auto-populated by parent.
|
|
113
|
+
* @ignore
|
|
114
|
+
*/
|
|
115
|
+
variant?: "checkbox" | "radio" | undefined;
|
|
116
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
117
|
+
export default Choice;
|