@khanacademy/wonder-blocks-dropdown 3.0.11 → 3.0.13

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @khanacademy/wonder-blocks-dropdown
2
2
 
3
+ ## 3.0.13
4
+
5
+ ### Patch Changes
6
+
7
+ - df9a10aa: Update state and props to be readonly in components using getDerivedStateFromProps()
8
+ - Updated dependencies [5a1ea891]
9
+ - Updated dependencies [df9a10aa]
10
+ - @khanacademy/wonder-blocks-layout@2.0.11
11
+ - @khanacademy/wonder-blocks-modal@4.0.12
12
+ - @khanacademy/wonder-blocks-core@5.2.1
13
+ - @khanacademy/wonder-blocks-clickable@3.0.11
14
+ - @khanacademy/wonder-blocks-timing@4.0.1
15
+ - @khanacademy/wonder-blocks-icon@2.0.11
16
+ - @khanacademy/wonder-blocks-search-field@2.0.13
17
+ - @khanacademy/wonder-blocks-typography@2.0.11
18
+
19
+ ## 3.0.12
20
+
21
+ ### Patch Changes
22
+
23
+ - @khanacademy/wonder-blocks-search-field@2.0.12
24
+
3
25
  ## 3.0.11
4
26
 
5
27
  ### Patch Changes
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import type { AriaProps, StyleType } from "@khanacademy/wonder-blocks-core";
3
3
  import DropdownOpener from "./dropdown-opener";
4
4
  import type { Item, DropdownItem, OpenerProps } from "../util/types";
5
- type Props = AriaProps & {
5
+ type Props = AriaProps & Readonly<{
6
6
  /**
7
7
  * The items in this dropdown.
8
8
  */
@@ -63,17 +63,17 @@ type Props = AriaProps & {
63
63
  * element to access pointer event state.
64
64
  */
65
65
  opener?: (openerProps: OpenerProps) => React.ReactElement<any>;
66
- };
67
- type State = {
66
+ }>;
67
+ type State = Readonly<{
68
68
  /**
69
69
  * Whether or not the dropdown is open.
70
70
  */
71
71
  opened: boolean;
72
- };
73
- type DefaultProps = {
72
+ }>;
73
+ type DefaultProps = Readonly<{
74
74
  alignment: Props["alignment"];
75
75
  disabled: Props["disabled"];
76
- };
76
+ }>;
77
77
  /**
78
78
  * A menu that consists of various types of items.
79
79
  *
@@ -10,7 +10,7 @@ import DropdownOpener from "./dropdown-opener";
10
10
  import type { Item, DropdownItem, OpenerProps } from "../util/types";
11
11
  declare type Props = {|
12
12
  ...AriaProps,
13
- ...{|
13
+ ...$ReadOnly<{|
14
14
  /**
15
15
  * The items in this dropdown.
16
16
  */
@@ -83,18 +83,18 @@ declare type Props = {|
83
83
  * element to access pointer event state.
84
84
  */
85
85
  opener?: (openerProps: OpenerProps) => React.Element<any>,
86
- |},
86
+ |}>,
87
87
  |};
88
- declare type State = {|
88
+ declare type State = $ReadOnly<{|
89
89
  /**
90
90
  * Whether or not the dropdown is open.
91
91
  */
92
92
  opened: boolean,
93
- |};
94
- declare type DefaultProps = {|
93
+ |}>;
94
+ declare type DefaultProps = $ReadOnly<{|
95
95
  alignment: $PropertyType<Props, "alignment">,
96
96
  disabled: $PropertyType<Props, "disabled">,
97
- |};
97
+ |}>;
98
98
  /**
99
99
  * A menu that consists of various types of items.
100
100
  *
@@ -21,11 +21,11 @@ type Labels = {
21
21
  someResults: (numOptions: number) => string;
22
22
  };
23
23
  type DropdownAriaRole = "listbox" | "menu";
24
- type ExportProps = {
24
+ declare const _default: React.ComponentType<Readonly<{
25
25
  /**
26
26
  * Items for the menu.
27
27
  */
28
- items: Array<DropdownItem>;
28
+ items: DropdownItem[];
29
29
  /**
30
30
  * Callback for when the menu is opened or closed. Parameter is whether
31
31
  * the dropdown menu should be open.
@@ -38,11 +38,11 @@ type ExportProps = {
38
38
  /**
39
39
  * The component that opens the menu.
40
40
  */
41
- opener: React.ReactElement<any>;
41
+ opener: React.ReactElement<any, string | React.JSXElementConstructor<any>>;
42
42
  /**
43
43
  * Ref to the opener element.
44
44
  */
45
- openerElement?: HTMLElement;
45
+ openerElement?: HTMLElement | undefined;
46
46
  /**
47
47
  * The aria "role" applied to the dropdown container.
48
48
  */
@@ -52,7 +52,7 @@ type ExportProps = {
52
52
  * the searchText exist, SearchField will be displayed at the top of the
53
53
  * dropdown body.
54
54
  */
55
- onSearchTextChanged?: (searchText: string) => unknown | null | undefined;
55
+ onSearchTextChanged?: ((searchText: string) => unknown) | undefined;
56
56
  /**
57
57
  * An optional string that the user entered to search the items. When this
58
58
  * and the onSearchTextChanged exist, SearchField will be displayed at the
@@ -71,21 +71,21 @@ type ExportProps = {
71
71
  /**
72
72
  * Optional CSS classes for the entire dropdown component.
73
73
  */
74
- className?: string;
74
+ className?: string | undefined;
75
75
  /**
76
76
  * When this is true, the dropdown body shows a search text input at the
77
77
  * top. The items will be filtered by the input.
78
78
  */
79
- isFilterable?: boolean;
79
+ isFilterable?: boolean | undefined;
80
80
  /**
81
81
  * Whether this menu should be left-aligned or right-aligned with the
82
82
  * opener component. Defaults to left-aligned.
83
83
  */
84
- alignment?: "left" | "right";
84
+ alignment?: "left" | "right" | undefined;
85
85
  /**
86
86
  * Whether to auto focus an option. Defaults to true.
87
87
  */
88
- autoFocus?: boolean;
88
+ autoFocus?: boolean | undefined;
89
89
  /**
90
90
  * Whether to enable the type-ahead suggestions feature. Defaults to true.
91
91
  *
@@ -99,25 +99,24 @@ type ExportProps = {
99
99
  * some cases where it's not desirable (for example when using a `TextField`
100
100
  * as the opener element).
101
101
  */
102
- enableTypeAhead?: boolean;
102
+ enableTypeAhead?: boolean | undefined;
103
103
  /**
104
104
  * An index that represents the index of the focused element when the menu
105
105
  * is opened.
106
106
  */
107
- initialFocusedIndex?: number;
107
+ initialFocusedIndex?: number | undefined;
108
108
  /**
109
109
  * The object containing the custom labels used inside this component.
110
110
  */
111
- labels?: Labels;
111
+ labels?: Labels | undefined;
112
112
  /**
113
113
  * Whether to display the "light" version of this component instead, for
114
114
  * use when the item is used on a dark background.
115
115
  */
116
- light?: boolean;
116
+ light?: boolean | undefined;
117
117
  /**
118
118
  * Used to determine if we can automatically select an item using the keyboard.
119
119
  */
120
- selectionType?: "single" | "multi";
121
- };
122
- declare const _default: React.ComponentType<ExportProps>;
120
+ selectionType?: "single" | "multi" | undefined;
121
+ }>>;
123
122
  export default _default;
@@ -30,121 +30,122 @@ declare type Labels = {|
30
30
  someResults: (numOptions: number) => string,
31
31
  |};
32
32
  declare type DropdownAriaRole = "listbox" | "menu";
33
- declare type ExportProps = {|
34
- /**
35
- * Items for the menu.
36
- */
37
- items: Array<DropdownItem>,
38
-
39
- /**
40
- * Callback for when the menu is opened or closed. Parameter is whether
41
- * the dropdown menu should be open.
42
- */
43
- onOpenChanged: (open: boolean) => mixed,
44
-
45
- /**
46
- * Whether the menu is open or not.
47
- */
48
- open: boolean,
49
-
50
- /**
51
- * The component that opens the menu.
52
- */
53
- opener: React.Element<any>,
54
-
55
- /**
56
- * Ref to the opener element.
57
- */
58
- openerElement?: HTMLElement,
59
-
60
- /**
61
- * The aria "role" applied to the dropdown container.
62
- */
63
- role: DropdownAriaRole,
64
-
65
- /**
66
- * An optional handler to set the searchText of the parent. When this and
67
- * the searchText exist, SearchField will be displayed at the top of the
68
- * dropdown body.
69
- */
70
- onSearchTextChanged?: (searchText: string) => mixed | null | void,
71
-
72
- /**
73
- * An optional string that the user entered to search the items. When this
74
- * and the onSearchTextChanged exist, SearchField will be displayed at the
75
- * top of the dropdown body.
76
- */
77
- searchText?: string | null | void,
78
-
79
- /**
80
- * Styling specific to the dropdown component that isn't part of the opener,
81
- * passed by the specific implementation of the dropdown menu,
82
- */
83
- dropdownStyle?: StyleType,
84
-
85
- /**
86
- * Optional styling for the entire dropdown component.
87
- */
88
- style?: StyleType,
89
-
90
- /**
91
- * Optional CSS classes for the entire dropdown component.
92
- */
93
- className?: string,
94
-
95
- /**
96
- * When this is true, the dropdown body shows a search text input at the
97
- * top. The items will be filtered by the input.
98
- */
99
- isFilterable?: boolean,
100
-
101
- /**
102
- * Whether this menu should be left-aligned or right-aligned with the
103
- * opener component. Defaults to left-aligned.
104
- */
105
- alignment?: "left" | "right",
106
-
107
- /**
108
- * Whether to auto focus an option. Defaults to true.
109
- */
110
- autoFocus?: boolean,
111
-
112
- /**
113
- * Whether to enable the type-ahead suggestions feature. Defaults to true.
114
- *
115
- * This feature allows to navigate the listbox using the keyboard.
116
- * - Type a character: focus moves to the next item with a name that starts
117
- * with the typed character.
118
- * - Type multiple characters in rapid succession: focus moves to the next
119
- * item with a name that starts with the string of characters typed.
120
- *
121
- * **NOTE:** Type-ahead is recommended for all listboxes, but there might be
122
- * some cases where it's not desirable (for example when using a `TextField`
123
- * as the opener element).
124
- */
125
- enableTypeAhead?: boolean,
126
-
127
- /**
128
- * An index that represents the index of the focused element when the menu
129
- * is opened.
130
- */
131
- initialFocusedIndex?: number,
132
-
133
- /**
134
- * The object containing the custom labels used inside this component.
135
- */
136
- labels?: Labels,
137
-
138
- /**
139
- * Whether to display the "light" version of this component instead, for
140
- * use when the item is used on a dark background.
141
- */
142
- light?: boolean,
143
-
144
- /**
145
- * Used to determine if we can automatically select an item using the keyboard.
146
- */
147
- selectionType?: "single" | "multi",
148
- |};
149
- declare var _default: React.ComponentType<ExportProps>;
33
+ declare var _default: React.ComponentType<
34
+ $ReadOnly<{|
35
+ /**
36
+ * Items for the menu.
37
+ */
38
+ items: DropdownItem[],
39
+
40
+ /**
41
+ * Callback for when the menu is opened or closed. Parameter is whether
42
+ * the dropdown menu should be open.
43
+ */
44
+ onOpenChanged: (open: boolean) => mixed,
45
+
46
+ /**
47
+ * Whether the menu is open or not.
48
+ */
49
+ open: boolean,
50
+
51
+ /**
52
+ * The component that opens the menu.
53
+ */
54
+ opener: React.Element<any, string | React.JSXElementConstructor<any>>,
55
+
56
+ /**
57
+ * Ref to the opener element.
58
+ */
59
+ openerElement?: HTMLElement | void,
60
+
61
+ /**
62
+ * The aria "role" applied to the dropdown container.
63
+ */
64
+ role: DropdownAriaRole,
65
+
66
+ /**
67
+ * An optional handler to set the searchText of the parent. When this and
68
+ * the searchText exist, SearchField will be displayed at the top of the
69
+ * dropdown body.
70
+ */
71
+ onSearchTextChanged?: ((searchText: string) => mixed) | void,
72
+
73
+ /**
74
+ * An optional string that the user entered to search the items. When this
75
+ * and the onSearchTextChanged exist, SearchField will be displayed at the
76
+ * top of the dropdown body.
77
+ */
78
+ searchText?: string | null | void,
79
+
80
+ /**
81
+ * Styling specific to the dropdown component that isn't part of the opener,
82
+ * passed by the specific implementation of the dropdown menu,
83
+ */
84
+ dropdownStyle?: StyleType,
85
+
86
+ /**
87
+ * Optional styling for the entire dropdown component.
88
+ */
89
+ style?: StyleType,
90
+
91
+ /**
92
+ * Optional CSS classes for the entire dropdown component.
93
+ */
94
+ className?: string | void,
95
+
96
+ /**
97
+ * When this is true, the dropdown body shows a search text input at the
98
+ * top. The items will be filtered by the input.
99
+ */
100
+ isFilterable?: boolean | void,
101
+
102
+ /**
103
+ * Whether this menu should be left-aligned or right-aligned with the
104
+ * opener component. Defaults to left-aligned.
105
+ */
106
+ alignment?: "left" | "right" | void,
107
+
108
+ /**
109
+ * Whether to auto focus an option. Defaults to true.
110
+ */
111
+ autoFocus?: boolean | void,
112
+
113
+ /**
114
+ * Whether to enable the type-ahead suggestions feature. Defaults to true.
115
+ *
116
+ * This feature allows to navigate the listbox using the keyboard.
117
+ * - Type a character: focus moves to the next item with a name that starts
118
+ * with the typed character.
119
+ * - Type multiple characters in rapid succession: focus moves to the next
120
+ * item with a name that starts with the string of characters typed.
121
+ *
122
+ * **NOTE:** Type-ahead is recommended for all listboxes, but there might be
123
+ * some cases where it's not desirable (for example when using a `TextField`
124
+ * as the opener element).
125
+ */
126
+ enableTypeAhead?: boolean | void,
127
+
128
+ /**
129
+ * An index that represents the index of the focused element when the menu
130
+ * is opened.
131
+ */
132
+ initialFocusedIndex?: number | void,
133
+
134
+ /**
135
+ * The object containing the custom labels used inside this component.
136
+ */
137
+ labels?: Labels | void,
138
+
139
+ /**
140
+ * Whether to display the "light" version of this component instead, for
141
+ * use when the item is used on a dark background.
142
+ */
143
+ light?: boolean | void,
144
+
145
+ /**
146
+ * Used to determine if we can automatically select an item using the keyboard.
147
+ */
148
+ selectionType?: "single" | "multi" | void,
149
+ |}>
150
+ >;
150
151
  declare export default typeof _default;
@@ -38,7 +38,7 @@ export type Labels = {
38
38
  */
39
39
  allSelected: string;
40
40
  };
41
- type DefaultProps = {
41
+ type DefaultProps = Readonly<{
42
42
  /**
43
43
  * Whether this dropdown should be left-aligned or right-aligned with the
44
44
  * opener component. Defaults to left-aligned.
@@ -62,8 +62,8 @@ type DefaultProps = {
62
62
  * Whether to display shortcuts for Select All and Select None.
63
63
  */
64
64
  shortcuts: boolean;
65
- };
66
- type Props = AriaProps & DefaultProps & {
65
+ }>;
66
+ type Props = AriaProps & DefaultProps & Readonly<{
67
67
  /**
68
68
  * The items in this select.
69
69
  */
@@ -125,8 +125,8 @@ type Props = AriaProps & DefaultProps & {
125
125
  * Test ID used for e2e testing.
126
126
  */
127
127
  testId?: string;
128
- };
129
- type State = {
128
+ }>;
129
+ type State = Readonly<{
130
130
  /**
131
131
  * Whether or not the dropdown is open.
132
132
  */
@@ -151,7 +151,7 @@ type State = {
151
151
  * to this element, and also to pass the reference to Popper.js.
152
152
  */
153
153
  openerElement?: HTMLElement;
154
- };
154
+ }>;
155
155
  /**
156
156
  * A dropdown that consists of multiple selection items. This select allows
157
157
  * multiple options to be selected. Clients are responsible for keeping track
@@ -51,7 +51,7 @@ export type Labels = {|
51
51
  */
52
52
  allSelected: string,
53
53
  |};
54
- declare type DefaultProps = {|
54
+ declare type DefaultProps = $ReadOnly<{|
55
55
  /**
56
56
  * Whether this dropdown should be left-aligned or right-aligned with the
57
57
  * opener component. Defaults to left-aligned.
@@ -79,11 +79,11 @@ declare type DefaultProps = {|
79
79
  * Whether to display shortcuts for Select All and Select None.
80
80
  */
81
81
  shortcuts: boolean,
82
- |};
82
+ |}>;
83
83
  declare type Props = {|
84
84
  ...AriaProps,
85
85
  ...DefaultProps,
86
- ...{|
86
+ ...$ReadOnly<{|
87
87
  /**
88
88
  * The items in this select.
89
89
  */
@@ -159,9 +159,9 @@ declare type Props = {|
159
159
  * Test ID used for e2e testing.
160
160
  */
161
161
  testId?: string,
162
- |},
162
+ |}>,
163
163
  |};
164
- declare type State = {|
164
+ declare type State = $ReadOnly<{|
165
165
  /**
166
166
  * Whether or not the dropdown is open.
167
167
  */
@@ -190,7 +190,7 @@ declare type State = {|
190
190
  * to this element, and also to pass the reference to Popper.js.
191
191
  */
192
192
  openerElement?: HTMLElement,
193
- |};
193
+ |}>;
194
194
  /**
195
195
  * A dropdown that consists of multiple selection items. This select allows
196
196
  * multiple options to be selected. Clients are responsible for keeping track
@@ -22,7 +22,7 @@ export type SingleSelectLabels = {
22
22
  */
23
23
  someResults: (numOptions: number) => string;
24
24
  };
25
- type DefaultProps = {
25
+ type DefaultProps = Readonly<{
26
26
  /**
27
27
  * Whether this dropdown should be left-aligned or right-aligned with the
28
28
  * opener component. Defaults to left-aligned.
@@ -60,8 +60,8 @@ type DefaultProps = {
60
60
  * The object containing the custom labels used inside this component.
61
61
  */
62
62
  labels: SingleSelectLabels;
63
- };
64
- type Props = AriaProps & DefaultProps & {
63
+ }>;
64
+ type Props = AriaProps & DefaultProps & Readonly<{
65
65
  /**
66
66
  * The items in this select.
67
67
  */
@@ -121,8 +121,8 @@ type Props = AriaProps & DefaultProps & {
121
121
  * top. The items will be filtered by the input.
122
122
  */
123
123
  isFilterable?: boolean;
124
- };
125
- type State = {
124
+ }>;
125
+ type State = Readonly<{
126
126
  /**
127
127
  * Whether or not the dropdown is open.
128
128
  */
@@ -137,7 +137,7 @@ type State = {
137
137
  * to this element, and also to pass the reference to Popper.js.
138
138
  */
139
139
  openerElement?: HTMLElement;
140
- };
140
+ }>;
141
141
  /**
142
142
  * The single select allows the selection of one item. Clients are responsible
143
143
  * for keeping track of the selected item in the select.
@@ -31,7 +31,7 @@ export type SingleSelectLabels = {|
31
31
  */
32
32
  someResults: (numOptions: number) => string,
33
33
  |};
34
- declare type DefaultProps = {|
34
+ declare type DefaultProps = $ReadOnly<{|
35
35
  /**
36
36
  * Whether this dropdown should be left-aligned or right-aligned with the
37
37
  * opener component. Defaults to left-aligned.
@@ -74,11 +74,11 @@ declare type DefaultProps = {|
74
74
  * The object containing the custom labels used inside this component.
75
75
  */
76
76
  labels: SingleSelectLabels,
77
- |};
77
+ |}>;
78
78
  declare type Props = {|
79
79
  ...AriaProps,
80
80
  ...DefaultProps,
81
- ...{|
81
+ ...$ReadOnly<{|
82
82
  /**
83
83
  * The items in this select.
84
84
  */
@@ -152,9 +152,9 @@ declare type Props = {|
152
152
  * top. The items will be filtered by the input.
153
153
  */
154
154
  isFilterable?: boolean,
155
- |},
155
+ |}>,
156
156
  |};
157
- declare type State = {|
157
+ declare type State = $ReadOnly<{|
158
158
  /**
159
159
  * Whether or not the dropdown is open.
160
160
  */
@@ -171,7 +171,7 @@ declare type State = {|
171
171
  * to this element, and also to pass the reference to Popper.js.
172
172
  */
173
173
  openerElement?: HTMLElement,
174
- |};
174
+ |}>;
175
175
  /**
176
176
  * The single select allows the selection of one item. Clients are responsible
177
177
  * for keeping track of the selected item in the select.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-dropdown",
3
- "version": "3.0.11",
3
+ "version": "3.0.13",
4
4
  "design": "v1",
5
5
  "description": "Dropdown variants for Wonder Blocks.",
6
6
  "main": "dist/index.js",
@@ -16,16 +16,16 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.18.6",
19
- "@khanacademy/wonder-blocks-clickable": "^3.0.10",
19
+ "@khanacademy/wonder-blocks-clickable": "^3.0.11",
20
20
  "@khanacademy/wonder-blocks-color": "^2.0.1",
21
- "@khanacademy/wonder-blocks-core": "^5.2.0",
22
- "@khanacademy/wonder-blocks-icon": "^2.0.10",
23
- "@khanacademy/wonder-blocks-layout": "^2.0.10",
24
- "@khanacademy/wonder-blocks-modal": "^4.0.11",
25
- "@khanacademy/wonder-blocks-search-field": "^2.0.11",
21
+ "@khanacademy/wonder-blocks-core": "^5.2.1",
22
+ "@khanacademy/wonder-blocks-icon": "^2.0.11",
23
+ "@khanacademy/wonder-blocks-layout": "^2.0.11",
24
+ "@khanacademy/wonder-blocks-modal": "^4.0.12",
25
+ "@khanacademy/wonder-blocks-search-field": "^2.0.13",
26
26
  "@khanacademy/wonder-blocks-spacing": "^4.0.1",
27
- "@khanacademy/wonder-blocks-timing": "^4.0.0",
28
- "@khanacademy/wonder-blocks-typography": "^2.0.10"
27
+ "@khanacademy/wonder-blocks-timing": "^4.0.1",
28
+ "@khanacademy/wonder-blocks-typography": "^2.0.11"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@popperjs/core": "^2.10.1",
@@ -38,7 +38,7 @@
38
38
  "react-window": "^1.8.5"
39
39
  },
40
40
  "devDependencies": {
41
- "@khanacademy/wonder-blocks-button": "^4.0.10",
41
+ "@khanacademy/wonder-blocks-button": "^4.0.11",
42
42
  "wb-dev-build-settings": "^0.9.7"
43
43
  }
44
44
  }