@khanacademy/wonder-blocks-dropdown 3.0.0 → 3.0.2

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/components/__mocks__/dropdown-core-virtualized.d.ts +1 -1
  3. package/dist/components/__mocks__/dropdown-core-virtualized.js.flow +3 -4
  4. package/dist/components/action-item.d.ts +1 -1
  5. package/dist/components/action-item.js.flow +5 -7
  6. package/dist/components/action-menu-opener-core.d.ts +1 -1
  7. package/dist/components/action-menu-opener-core.js.flow +6 -7
  8. package/dist/components/action-menu.d.ts +1 -1
  9. package/dist/components/action-menu.js.flow +12 -15
  10. package/dist/components/check.js.flow +3 -4
  11. package/dist/components/checkbox.js.flow +3 -4
  12. package/dist/components/dropdown-core-virtualized-item.d.ts +1 -1
  13. package/dist/components/dropdown-core-virtualized-item.js.flow +3 -4
  14. package/dist/components/dropdown-core-virtualized.js.flow +4 -5
  15. package/dist/components/dropdown-core.js.flow +4 -6
  16. package/dist/components/dropdown-opener.d.ts +2 -2
  17. package/dist/components/dropdown-opener.js.flow +10 -12
  18. package/dist/components/dropdown-popper.d.ts +1 -1
  19. package/dist/components/dropdown-popper.js.flow +4 -5
  20. package/dist/components/multi-select.d.ts +1 -1
  21. package/dist/components/multi-select.js.flow +20 -27
  22. package/dist/components/option-item.d.ts +1 -1
  23. package/dist/components/option-item.js.flow +7 -9
  24. package/dist/components/select-opener.d.ts +1 -1
  25. package/dist/components/select-opener.js.flow +8 -10
  26. package/dist/components/separator-item.d.ts +1 -1
  27. package/dist/components/separator-item.js.flow +4 -5
  28. package/dist/components/single-select.d.ts +1 -1
  29. package/dist/components/single-select.js.flow +23 -28
  30. package/dist/util/constants.js.flow +8 -12
  31. package/dist/util/types.js.flow +8 -10
  32. package/package.json +13 -13
  33. package/src/components/__mocks__/dropdown-core-virtualized.tsx +1 -1
  34. package/src/components/action-item.tsx +1 -1
  35. package/src/components/action-menu-opener-core.tsx +1 -1
  36. package/src/components/action-menu.tsx +1 -1
  37. package/src/components/dropdown-core-virtualized-item.ts +1 -1
  38. package/src/components/dropdown-core.tsx +1 -2
  39. package/src/components/dropdown-opener.tsx +2 -3
  40. package/src/components/dropdown-popper.tsx +1 -1
  41. package/src/components/multi-select.tsx +1 -1
  42. package/src/components/option-item.tsx +1 -1
  43. package/src/components/select-opener.tsx +1 -1
  44. package/src/components/separator-item.tsx +1 -1
  45. package/src/components/single-select.tsx +1 -1
  46. package/tsconfig.tsbuildinfo +1 -1
@@ -13,5 +13,5 @@ export default class SeparatorItem extends React.Component<{
13
13
  }> {
14
14
  static isClassOf(instance: React.ReactElement<any>): boolean;
15
15
  static __IS_SEPARATOR_ITEM__: boolean;
16
- render(): React.ReactElement;
16
+ render(): React.ReactNode;
17
17
  }
@@ -12,18 +12,17 @@ import type { StyleType } from "@khanacademy/wonder-blocks-core";
12
12
  * A separator used in a dropdown menu.
13
13
  */
14
14
  declare export default class SeparatorItem
15
- mixins
16
- React.Component<{
15
+ extends
16
+ React.Component<{|
17
17
  /**
18
18
  * In case we use react-window, this needs to be added in order to inject
19
19
  * styles to calculate the position
20
20
  * @ignore
21
21
  */
22
22
  style?: StyleType,
23
- ...
24
- }>
23
+ |}>
25
24
  {
26
25
  static isClassOf(instance: React.Element<any>): boolean;
27
26
  static __IS_SEPARATOR_ITEM__: boolean;
28
- render(): React.Element<any>;
27
+ render(): React.Node;
29
28
  }
@@ -201,6 +201,6 @@ export default class SingleSelect extends React.Component<Props, State> {
201
201
  handleOpenerRef: (node?: any) => void;
202
202
  handleClick: (e: React.SyntheticEvent) => void;
203
203
  renderOpener(numItems: number): React.ReactElement<React.ComponentProps<typeof DropdownOpener>> | React.ReactElement<React.ComponentProps<typeof SelectOpener>>;
204
- render(): React.ReactElement;
204
+ render(): React.ReactNode;
205
205
  }
206
206
  export {};
@@ -11,7 +11,7 @@ import DropdownOpener from "./dropdown-opener";
11
11
  import SelectOpener from "./select-opener";
12
12
  import OptionItem from "./option-item";
13
13
  import type { DropdownItem, OpenerProps } from "../util/types";
14
- export type SingleSelectLabels = {
14
+ export type SingleSelectLabels = {|
15
15
  /**
16
16
  * Label for describing the dismiss icon on the search filter.
17
17
  */
@@ -31,9 +31,8 @@ export type SingleSelectLabels = {
31
31
  * Label for the opening component when there are some items selected.
32
32
  */
33
33
  someResults: (numOptions: number) => string,
34
- ...
35
- };
36
- declare type DefaultProps = {
34
+ |};
35
+ declare type DefaultProps = {|
37
36
  /**
38
37
  * Whether this dropdown should be left-aligned or right-aligned with the
39
38
  * opener component. Defaults to left-aligned.
@@ -76,20 +75,16 @@ declare type DefaultProps = {
76
75
  * The object containing the custom labels used inside this component.
77
76
  */
78
77
  labels: SingleSelectLabels,
79
- ...
80
- };
81
- declare type Props = {
78
+ |};
79
+ declare type Props = {|
82
80
  ...AriaProps,
83
81
  ...DefaultProps,
84
- ...{
82
+ ...{|
85
83
  /**
86
84
  * The items in this select.
87
85
  */
88
86
  children?: Array<
89
- | React.Element<React.ComponentProps<typeof OptionItem>>
90
- | false
91
- | null
92
- | void
87
+ React.Element<React.ElementProps<typeof OptionItem>> | false | null | void
93
88
  >,
94
89
 
95
90
  /**
@@ -158,10 +153,9 @@ declare type Props = {
158
153
  * top. The items will be filtered by the input.
159
154
  */
160
155
  isFilterable?: boolean,
161
- ...
162
- },
163
- };
164
- declare type State = {
156
+ |},
157
+ |};
158
+ declare type State = {|
165
159
  /**
166
160
  * Whether or not the dropdown is open.
167
161
  */
@@ -178,8 +172,7 @@ declare type State = {
178
172
  * to this element, and also to pass the reference to Popper.js.
179
173
  */
180
174
  openerElement: HTMLElement | null | void,
181
- ...
182
- };
175
+ |};
183
176
  /**
184
177
  * The single select allows the selection of one item. Clients are responsible
185
178
  * for keeping track of the selected item in the select.
@@ -225,7 +218,9 @@ declare type State = {
225
218
  * </SingleSelect>
226
219
  * ```
227
220
  */
228
- declare export default class SingleSelect extends React.Component<Props, State> {
221
+ declare export default class SingleSelect
222
+ extends React.Component<Props, State>
223
+ {
229
224
  selectedIndex: number;
230
225
  static defaultProps: DefaultProps;
231
226
  constructor(props: Props): this;
@@ -237,25 +232,25 @@ declare export default class SingleSelect extends React.Component<Props, State>
237
232
  static getDerivedStateFromProps(
238
233
  props: Props,
239
234
  state: State
240
- ): $Rest<State, { ... }> | null;
235
+ ): $Rest<State, {}> | null;
241
236
  handleOpenChanged: (opened: boolean) => void;
242
237
  handleToggle: (selectedValue: string) => void;
243
238
  mapOptionItemsToDropdownItems: (
244
- children: Array<React.Element<React.ComponentProps<typeof OptionItem>>>
239
+ children: Array<React.Element<React.ElementProps<typeof OptionItem>>>
245
240
  ) => Array<DropdownItem>;
246
241
  filterChildren(
247
- children: Array<React.Element<React.ComponentProps<typeof OptionItem>>>
248
- ): Array<React.Element<React.ComponentProps<typeof OptionItem>>>;
242
+ children: Array<React.Element<React.ElementProps<typeof OptionItem>>>
243
+ ): Array<React.Element<React.ElementProps<typeof OptionItem>>>;
249
244
  getMenuItems(
250
- children: Array<React.Element<React.ComponentProps<typeof OptionItem>>>
245
+ children: Array<React.Element<React.ElementProps<typeof OptionItem>>>
251
246
  ): Array<DropdownItem>;
252
247
  handleSearchTextChanged: (searchText: string) => void;
253
248
  handleOpenerRef: (node?: any) => void;
254
- handleClick: (e: React.SyntheticEvent<>) => void;
249
+ handleClick: (e: SyntheticEvent<>) => void;
255
250
  renderOpener(
256
251
  numItems: number
257
252
  ):
258
- | React.Element<React.ComponentProps<typeof DropdownOpener>>
259
- | React.Element<React.ComponentProps<typeof SelectOpener>>;
260
- render(): React.Element<any>;
253
+ | React.Element<React.ElementProps<typeof DropdownOpener>>
254
+ | React.Element<React.ElementProps<typeof SelectOpener>>;
255
+ render(): React.Node;
261
256
  }
@@ -5,24 +5,21 @@
5
5
  * @flow
6
6
  */
7
7
 
8
- declare export var keyCodes: {
8
+ declare export var keyCodes: {|
9
9
  +tab: 9,
10
10
  +enter: 13,
11
11
  +escape: 27,
12
12
  +space: 32,
13
13
  +up: 38,
14
14
  +down: 40,
15
- ...
16
- };
17
- declare export var selectDropdownStyle: {
15
+ |};
16
+ declare export var selectDropdownStyle: {|
18
17
  +marginTop: 8,
19
18
  +marginBottom: 8,
20
- ...
21
- };
22
- declare export var filterableDropdownStyle: {
19
+ |};
20
+ declare export var filterableDropdownStyle: {|
23
21
  +minHeight: 100,
24
- ...
25
- };
22
+ |};
26
23
  declare export var DROPDOWN_ITEM_HEIGHT: 40;
27
24
  /**
28
25
  * Maximum visible items inside the dropdown list. Based on the defined height
@@ -31,7 +28,7 @@ declare export var DROPDOWN_ITEM_HEIGHT: 40;
31
28
  */
32
29
  declare export var MAX_VISIBLE_ITEMS: 9;
33
30
  declare export var SEPARATOR_ITEM_HEIGHT: 9;
34
- declare export var defaultLabels: {
31
+ declare export var defaultLabels: {|
35
32
  +clearSearch: "Clear search",
36
33
  +filter: "Filter",
37
34
  +noResults: "No results",
@@ -40,5 +37,4 @@ declare export var defaultLabels: {
40
37
  +noneSelected: "0 items",
41
38
  +someSelected: (numSelectedValues: number) => string,
42
39
  +allSelected: "All items",
43
- ...
44
- };
40
+ |};
@@ -13,13 +13,13 @@ import SeparatorItem from "../components/separator-item";
13
13
  export type Item =
14
14
  | false
15
15
  | React.Element<
16
- React.ComponentProps<
16
+ React.ElementProps<
17
17
  typeof ActionItem | typeof OptionItem | typeof SeparatorItem
18
18
  >
19
19
  >;
20
- export type DropdownItem = {
20
+ export type DropdownItem = {|
21
21
  component: React.Element<
22
- React.ComponentProps<
22
+ React.ElementProps<
23
23
  typeof ActionItem | typeof OptionItem | typeof SeparatorItem
24
24
  >
25
25
  >,
@@ -28,12 +28,10 @@ export type DropdownItem = {
28
28
  onClick?: () => mixed,
29
29
  ref?: any,
30
30
  role?: string,
31
- ...
32
- };
33
- export type OpenerProps = {
31
+ |};
32
+ export type OpenerProps = {|
34
33
  ...ClickableState,
35
- ...{
34
+ ...{|
36
35
  text: string,
37
- ...
38
- },
39
- };
36
+ |},
37
+ |};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-dropdown",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
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.0",
20
- "@khanacademy/wonder-blocks-color": "^2.0.0",
21
- "@khanacademy/wonder-blocks-core": "^5.0.0",
22
- "@khanacademy/wonder-blocks-icon": "^2.0.0",
23
- "@khanacademy/wonder-blocks-layout": "^2.0.0",
24
- "@khanacademy/wonder-blocks-modal": "^4.0.0",
25
- "@khanacademy/wonder-blocks-search-field": "^2.0.0",
26
- "@khanacademy/wonder-blocks-spacing": "^4.0.0",
27
- "@khanacademy/wonder-blocks-timing": "^3.0.0",
28
- "@khanacademy/wonder-blocks-typography": "^2.0.0"
19
+ "@khanacademy/wonder-blocks-clickable": "^3.0.2",
20
+ "@khanacademy/wonder-blocks-color": "^2.0.1",
21
+ "@khanacademy/wonder-blocks-core": "^5.0.2",
22
+ "@khanacademy/wonder-blocks-icon": "^2.0.2",
23
+ "@khanacademy/wonder-blocks-layout": "^2.0.2",
24
+ "@khanacademy/wonder-blocks-modal": "^4.0.2",
25
+ "@khanacademy/wonder-blocks-search-field": "^2.0.2",
26
+ "@khanacademy/wonder-blocks-spacing": "^4.0.1",
27
+ "@khanacademy/wonder-blocks-timing": "^3.0.1",
28
+ "@khanacademy/wonder-blocks-typography": "^2.0.2"
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.0",
42
- "wb-dev-build-settings": "^0.8.0"
41
+ "@khanacademy/wonder-blocks-button": "^4.0.2",
42
+ "wb-dev-build-settings": "^0.9.1"
43
43
  }
44
44
  }
@@ -14,7 +14,7 @@ type Props = {
14
14
  * A minimal mocked version of the Virtualized implementation
15
15
  */
16
16
  class DropdownCoreVirtualizedMock extends React.Component<Props> {
17
- render(): React.ReactElement {
17
+ render(): React.ReactNode {
18
18
  const {data, listRef} = this.props;
19
19
  return (
20
20
  <List
@@ -215,7 +215,7 @@ export default class ActionItem extends React.Component<ActionProps> {
215
215
  );
216
216
  }
217
217
 
218
- render(): React.ReactElement {
218
+ render(): React.ReactNode {
219
219
  return (
220
220
  <__RouterContext.Consumer>
221
221
  {(router) => this.renderClickableBehavior(router)}
@@ -41,7 +41,7 @@ const StyledButton = addStyle<"button">("button");
41
41
  * - the down caret icon is smaller that the one that would be used by ButtonCore
42
42
  */
43
43
  export default class ActionMenuOpenerCore extends React.Component<Props> {
44
- render(): React.ReactElement {
44
+ render(): React.ReactNode {
45
45
  const {
46
46
  children,
47
47
  disabled: disabledProp,
@@ -263,7 +263,7 @@ export default class ActionMenu extends React.Component<Props, State> {
263
263
  );
264
264
  }
265
265
 
266
- render(): React.ReactElement {
266
+ render(): React.ReactNode {
267
267
  const {alignment, dropdownStyle, style, className} = this.props;
268
268
 
269
269
  const items = this.getMenuItems();
@@ -32,7 +32,7 @@ type Props = {
32
32
  * react-window make its own calculations.
33
33
  */
34
34
  class DropdownVirtualizedItem extends React.Component<Props> {
35
- render(): React.ReactElement {
35
+ render(): React.ReactNode {
36
36
  const {data, index, style} = this.props;
37
37
  const item = data[index];
38
38
 
@@ -993,7 +993,6 @@ class DropdownCore extends React.Component<Props, State> {
993
993
  referenceElement={openerElement}
994
994
  >
995
995
  {(isReferenceHidden) =>
996
- // @ts-expect-error [FEI-5019] - TS2322 - Type 'ReactNode' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>>'.
997
996
  this.renderDropdownMenu(listRenderer, isReferenceHidden)
998
997
  }
999
998
  </DropdownPopper>
@@ -1018,7 +1017,7 @@ class DropdownCore extends React.Component<Props, State> {
1018
1017
  );
1019
1018
  }
1020
1019
 
1021
- render(): React.ReactElement {
1020
+ render(): React.ReactNode {
1022
1021
  const {open, opener, style, className} = this.props;
1023
1022
 
1024
1023
  return (
@@ -53,7 +53,7 @@ class DropdownOpener extends React.Component<Props> {
53
53
  renderAnchorChildren(
54
54
  eventState: ClickableState,
55
55
  clickableChildrenProps: ChildrenProps,
56
- ): React.ReactNode {
56
+ ): React.ReactElement {
57
57
  const {disabled, testId, text} = this.props;
58
58
  const renderedChildren = this.props.children({...eventState, text});
59
59
  const childrenProps = renderedChildren.props;
@@ -77,14 +77,13 @@ class DropdownOpener extends React.Component<Props> {
77
77
  });
78
78
  }
79
79
 
80
- render(): React.ReactElement {
80
+ render(): React.ReactNode {
81
81
  return (
82
82
  <ClickableBehavior
83
83
  onClick={this.props.onClick}
84
84
  disabled={this.props.disabled}
85
85
  >
86
86
  {(eventState, handlers) =>
87
- // @ts-expect-error [FEI-5019] - TS2322 - Type 'ReactNode' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>>'.
88
87
  this.renderAnchorChildren(eventState, handlers)
89
88
  }
90
89
  </ClickableBehavior>
@@ -25,7 +25,7 @@ type Props = {
25
25
  /**
26
26
  * The children that will be wrapped by PopperJS.
27
27
  */
28
- children: (isReferenceHidden: boolean) => React.ReactElement;
28
+ children: (isReferenceHidden: boolean) => React.ReactNode;
29
29
  /**
30
30
  * The reference element used to position the popper.
31
31
  */
@@ -517,7 +517,7 @@ export default class MultiSelect extends React.Component<Props, State> {
517
517
  return dropdownOpener;
518
518
  }
519
519
 
520
- render(): React.ReactElement {
520
+ render(): React.ReactNode {
521
521
  const {
522
522
  alignment,
523
523
  light,
@@ -106,7 +106,7 @@ export default class OptionItem extends React.Component<OptionProps> {
106
106
  }
107
107
  };
108
108
 
109
- render(): React.ReactElement {
109
+ render(): React.ReactNode {
110
110
  const {
111
111
  disabled,
112
112
  label,
@@ -153,7 +153,7 @@ export default class SelectOpener extends React.Component<SelectOpenerProps> {
153
153
  );
154
154
  }
155
155
 
156
- render(): React.ReactElement {
156
+ render(): React.ReactNode {
157
157
  return (
158
158
  <__RouterContext.Consumer>
159
159
  {(router) => this.renderClickableBehavior(router)}
@@ -28,7 +28,7 @@ export default class SeparatorItem extends React.Component<{
28
28
 
29
29
  static __IS_SEPARATOR_ITEM__ = true;
30
30
 
31
- render(): React.ReactElement {
31
+ render(): React.ReactNode {
32
32
  return (
33
33
  // pass optional styles from react-window (if applies)
34
34
  <View
@@ -424,7 +424,7 @@ export default class SingleSelect extends React.Component<Props, State> {
424
424
  return dropdownOpener;
425
425
  }
426
426
 
427
- render(): React.ReactElement {
427
+ render(): React.ReactNode {
428
428
  const {
429
429
  alignment,
430
430
  autoFocus,