@khanacademy/wonder-blocks-dropdown 2.10.5 → 2.10.7
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 +28 -0
- package/dist/index.js.flow +1 -1
- package/package.json +12 -12
- package/src/components/__docs__/action-menu.stories.js +3 -3
- package/src/components/__docs__/multi-select.stories.js +3 -3
- package/src/components/__docs__/single-select.stories.js +3 -3
- package/src/components/__mocks__/dropdown-core-virtualized.js +2 -2
- package/src/components/__tests__/action-item.test.js +1 -1
- package/src/components/__tests__/action-menu.test.js +4 -4
- package/src/components/__tests__/dropdown-core-virtualized.test.js +3 -3
- package/src/components/__tests__/dropdown-core.test.js +2 -2
- package/src/components/__tests__/dropdown-popper.test.js +1 -1
- package/src/components/__tests__/multi-select.test.js +3 -3
- package/src/components/__tests__/single-select.test.js +3 -3
- package/src/components/action-item.js +1 -1
- package/src/components/action-menu-opener-core.js +1 -1
- package/src/components/action-menu.js +6 -6
- package/src/components/dropdown-core-virtualized-item.js +2 -2
- package/src/components/dropdown-core-virtualized.js +5 -5
- package/src/components/dropdown-core.js +7 -7
- package/src/components/dropdown-opener.js +1 -1
- package/src/components/multi-select.js +8 -8
- package/src/components/option-item.js +3 -3
- package/src/components/select-opener.js +1 -1
- package/src/components/single-select.js +29 -9
- package/src/index.js +8 -8
- package/src/util/__tests__/dropdown-menu-styles.test.js +3 -3
- package/src/util/__tests__/helpers.test.js +1 -1
- package/src/util/dropdown-menu-styles.js +3 -3
- package/src/util/types.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-dropdown
|
|
2
2
|
|
|
3
|
+
## 2.10.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 91cb727c: Remove file extensions from imports
|
|
8
|
+
- Updated dependencies [91cb727c]
|
|
9
|
+
- Updated dependencies [91cb727c]
|
|
10
|
+
- Updated dependencies [91cb727c]
|
|
11
|
+
- Updated dependencies [91cb727c]
|
|
12
|
+
- @khanacademy/wonder-blocks-icon@1.2.37
|
|
13
|
+
- @khanacademy/wonder-blocks-clickable@2.4.5
|
|
14
|
+
- @khanacademy/wonder-blocks-color@1.2.1
|
|
15
|
+
- @khanacademy/wonder-blocks-core@4.7.0
|
|
16
|
+
- @khanacademy/wonder-blocks-layout@1.4.16
|
|
17
|
+
- @khanacademy/wonder-blocks-modal@3.0.7
|
|
18
|
+
- @khanacademy/wonder-blocks-search-field@1.0.19
|
|
19
|
+
- @khanacademy/wonder-blocks-timing@2.1.1
|
|
20
|
+
- @khanacademy/wonder-blocks-typography@1.1.38
|
|
21
|
+
|
|
22
|
+
## 2.10.6
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [1a5624d4]
|
|
27
|
+
- @khanacademy/wonder-blocks-icon@1.2.36
|
|
28
|
+
- @khanacademy/wonder-blocks-modal@3.0.6
|
|
29
|
+
- @khanacademy/wonder-blocks-search-field@1.0.18
|
|
30
|
+
|
|
3
31
|
## 2.10.5
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/index.js.flow
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
export * from "../src/index
|
|
2
|
+
export * from "../src/index";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-dropdown",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.7",
|
|
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": "^2.4.
|
|
20
|
-
"@khanacademy/wonder-blocks-color": "^1.2.
|
|
21
|
-
"@khanacademy/wonder-blocks-core": "^4.
|
|
22
|
-
"@khanacademy/wonder-blocks-icon": "^1.2.
|
|
23
|
-
"@khanacademy/wonder-blocks-layout": "^1.4.
|
|
24
|
-
"@khanacademy/wonder-blocks-modal": "^3.0.
|
|
25
|
-
"@khanacademy/wonder-blocks-search-field": "^1.0.
|
|
19
|
+
"@khanacademy/wonder-blocks-clickable": "^2.4.5",
|
|
20
|
+
"@khanacademy/wonder-blocks-color": "^1.2.1",
|
|
21
|
+
"@khanacademy/wonder-blocks-core": "^4.7.0",
|
|
22
|
+
"@khanacademy/wonder-blocks-icon": "^1.2.37",
|
|
23
|
+
"@khanacademy/wonder-blocks-layout": "^1.4.16",
|
|
24
|
+
"@khanacademy/wonder-blocks-modal": "^3.0.7",
|
|
25
|
+
"@khanacademy/wonder-blocks-search-field": "^1.0.19",
|
|
26
26
|
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
27
|
-
"@khanacademy/wonder-blocks-timing": "^2.1.
|
|
28
|
-
"@khanacademy/wonder-blocks-typography": "^1.1.
|
|
27
|
+
"@khanacademy/wonder-blocks-timing": "^2.1.1",
|
|
28
|
+
"@khanacademy/wonder-blocks-typography": "^1.1.38"
|
|
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": "^3.0.
|
|
42
|
-
"wb-dev-build-settings": "^0.7.
|
|
41
|
+
"@khanacademy/wonder-blocks-button": "^3.0.14",
|
|
42
|
+
"wb-dev-build-settings": "^0.7.1"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -17,11 +17,11 @@ import {Checkbox} from "@khanacademy/wonder-blocks-form";
|
|
|
17
17
|
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
18
18
|
import {LabelLarge} from "@khanacademy/wonder-blocks-typography";
|
|
19
19
|
|
|
20
|
-
import actionMenuArgtypes from "./action-menu.argtypes
|
|
21
|
-
import ComponentInfo from "../../../../../.storybook/components/component-info
|
|
20
|
+
import actionMenuArgtypes from "./action-menu.argtypes";
|
|
21
|
+
import ComponentInfo from "../../../../../.storybook/components/component-info";
|
|
22
22
|
import {name, version} from "../../../package.json";
|
|
23
23
|
|
|
24
|
-
import type {Item} from "../../util/types
|
|
24
|
+
import type {Item} from "../../util/types";
|
|
25
25
|
|
|
26
26
|
type ActionMenuProps = React.ElementProps<typeof ActionMenu>;
|
|
27
27
|
|
|
@@ -15,10 +15,10 @@ import {OnePaneDialog, ModalLauncher} from "@khanacademy/wonder-blocks-modal";
|
|
|
15
15
|
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
16
16
|
import {HeadingLarge} from "@khanacademy/wonder-blocks-typography";
|
|
17
17
|
|
|
18
|
-
import ComponentInfo from "../../../../../.storybook/components/component-info
|
|
18
|
+
import ComponentInfo from "../../../../../.storybook/components/component-info";
|
|
19
19
|
import {name, version} from "../../../package.json";
|
|
20
|
-
import multiSelectArgtypes from "./base-select.argtypes
|
|
21
|
-
import {defaultLabels} from "../../util/constants
|
|
20
|
+
import multiSelectArgtypes from "./base-select.argtypes";
|
|
21
|
+
import {defaultLabels} from "../../util/constants";
|
|
22
22
|
|
|
23
23
|
export default {
|
|
24
24
|
title: "Dropdown / MultiSelect",
|
|
@@ -23,10 +23,10 @@ import {
|
|
|
23
23
|
import type {SingleSelectLabels} from "@khanacademy/wonder-blocks-dropdown";
|
|
24
24
|
import type {IconAsset} from "@khanacademy/wonder-blocks-icon";
|
|
25
25
|
|
|
26
|
-
import ComponentInfo from "../../../../../.storybook/components/component-info
|
|
26
|
+
import ComponentInfo from "../../../../../.storybook/components/component-info";
|
|
27
27
|
import {name, version} from "../../../package.json";
|
|
28
|
-
import singleSelectArgtypes from "./base-select.argtypes
|
|
29
|
-
import {defaultLabels} from "../../util/constants
|
|
28
|
+
import singleSelectArgtypes from "./base-select.argtypes";
|
|
29
|
+
import {defaultLabels} from "../../util/constants";
|
|
30
30
|
|
|
31
31
|
export default {
|
|
32
32
|
title: "Dropdown / SingleSelect",
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {VariableSizeList as List} from "react-window";
|
|
4
4
|
|
|
5
|
-
import DropdownVirtualizedItem from "../dropdown-core-virtualized-item
|
|
5
|
+
import DropdownVirtualizedItem from "../dropdown-core-virtualized-item";
|
|
6
6
|
|
|
7
|
-
import type {DropdownItem} from "../../util/types
|
|
7
|
+
import type {DropdownItem} from "../../util/types";
|
|
8
8
|
|
|
9
9
|
type Props = {|
|
|
10
10
|
data: Array<DropdownItem>,
|
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import {render, screen} from "@testing-library/react";
|
|
4
4
|
import * as ReactRouterDOM from "react-router-dom";
|
|
5
5
|
|
|
6
|
-
import ActionItem from "../action-item
|
|
6
|
+
import ActionItem from "../action-item";
|
|
7
7
|
|
|
8
8
|
jest.mock("react-router-dom", () => ({
|
|
9
9
|
__esModule: true,
|
|
@@ -3,10 +3,10 @@ import * as React from "react";
|
|
|
3
3
|
import {render, screen} from "@testing-library/react";
|
|
4
4
|
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
|
-
import ActionItem from "../action-item
|
|
7
|
-
import OptionItem from "../option-item
|
|
8
|
-
import SeparatorItem from "../separator-item
|
|
9
|
-
import ActionMenu from "../action-menu
|
|
6
|
+
import ActionItem from "../action-item";
|
|
7
|
+
import OptionItem from "../option-item";
|
|
8
|
+
import SeparatorItem from "../separator-item";
|
|
9
|
+
import ActionMenu from "../action-menu";
|
|
10
10
|
|
|
11
11
|
describe("ActionMenu", () => {
|
|
12
12
|
const onClick = jest.fn();
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {render, screen} from "@testing-library/react";
|
|
4
4
|
|
|
5
|
-
import OptionItem from "../option-item
|
|
6
|
-
import SeparatorItem from "../separator-item
|
|
7
|
-
import DropdownCoreVirtualized from "../dropdown-core-virtualized
|
|
5
|
+
import OptionItem from "../option-item";
|
|
6
|
+
import SeparatorItem from "../separator-item";
|
|
7
|
+
import DropdownCoreVirtualized from "../dropdown-core-virtualized";
|
|
8
8
|
|
|
9
9
|
describe("DropdownCoreVirtualized", () => {
|
|
10
10
|
it("should sort the items on first load", () => {
|
|
@@ -3,8 +3,8 @@ import * as React from "react";
|
|
|
3
3
|
import {fireEvent, render, screen, waitFor} from "@testing-library/react";
|
|
4
4
|
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
|
-
import OptionItem from "../option-item
|
|
7
|
-
import DropdownCore from "../dropdown-core
|
|
6
|
+
import OptionItem from "../option-item";
|
|
7
|
+
import DropdownCore from "../dropdown-core";
|
|
8
8
|
|
|
9
9
|
const items = [
|
|
10
10
|
{
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {render, screen} from "@testing-library/react";
|
|
4
4
|
|
|
5
|
-
import DropdownPopper from "../dropdown-popper
|
|
5
|
+
import DropdownPopper from "../dropdown-popper";
|
|
6
6
|
|
|
7
7
|
describe("DropdownPopper", () => {
|
|
8
8
|
it("renders the children if valid props are passed in", () => {
|
|
@@ -6,10 +6,10 @@ import userEvent from "@testing-library/user-event";
|
|
|
6
6
|
|
|
7
7
|
import {ngettext} from "@khanacademy/wonder-blocks-i18n";
|
|
8
8
|
|
|
9
|
-
import OptionItem from "../option-item
|
|
10
|
-
import MultiSelect from "../multi-select
|
|
9
|
+
import OptionItem from "../option-item";
|
|
10
|
+
import MultiSelect from "../multi-select";
|
|
11
11
|
|
|
12
|
-
import type {Labels} from "../multi-select
|
|
12
|
+
import type {Labels} from "../multi-select";
|
|
13
13
|
|
|
14
14
|
const labels: $Shape<Labels> = {
|
|
15
15
|
selectAllLabel: (numOptions) => `Sellect all (${numOptions})`,
|
|
@@ -3,9 +3,9 @@ import * as React from "react";
|
|
|
3
3
|
import {render, screen} from "@testing-library/react";
|
|
4
4
|
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
|
-
import OptionItem from "../option-item
|
|
7
|
-
import SingleSelect from "../single-select
|
|
8
|
-
import type {SingleSelectLabels} from "../single-select
|
|
6
|
+
import OptionItem from "../option-item";
|
|
7
|
+
import SingleSelect from "../single-select";
|
|
8
|
+
import type {SingleSelectLabels} from "../single-select";
|
|
9
9
|
|
|
10
10
|
describe("SingleSelect", () => {
|
|
11
11
|
const onChange = jest.fn();
|
|
@@ -16,7 +16,7 @@ import {addStyle} from "@khanacademy/wonder-blocks-core";
|
|
|
16
16
|
|
|
17
17
|
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
18
18
|
|
|
19
|
-
import {DROPDOWN_ITEM_HEIGHT} from "../util/constants
|
|
19
|
+
import {DROPDOWN_ITEM_HEIGHT} from "../util/constants";
|
|
20
20
|
|
|
21
21
|
const {blue, white, offBlack, offBlack32} = Color;
|
|
22
22
|
|
|
@@ -11,7 +11,7 @@ import {Strut} from "@khanacademy/wonder-blocks-layout";
|
|
|
11
11
|
import type {AriaProps} from "@khanacademy/wonder-blocks-core";
|
|
12
12
|
import type {ClickableState} from "@khanacademy/wonder-blocks-clickable";
|
|
13
13
|
|
|
14
|
-
import {DROPDOWN_ITEM_HEIGHT} from "../util/constants
|
|
14
|
+
import {DROPDOWN_ITEM_HEIGHT} from "../util/constants";
|
|
15
15
|
|
|
16
16
|
type Props = {|
|
|
17
17
|
...$Rest<AriaProps, {|"aria-disabled": "true" | "false" | void|}>,
|
|
@@ -4,13 +4,13 @@ import * as React from "react";
|
|
|
4
4
|
import ReactDOM from "react-dom";
|
|
5
5
|
import {StyleSheet} from "aphrodite";
|
|
6
6
|
import type {AriaProps, StyleType} from "@khanacademy/wonder-blocks-core";
|
|
7
|
-
import DropdownOpener from "./dropdown-opener
|
|
8
|
-
import ActionItem from "./action-item
|
|
9
|
-
import OptionItem from "./option-item
|
|
10
|
-
import DropdownCore from "./dropdown-core
|
|
7
|
+
import DropdownOpener from "./dropdown-opener";
|
|
8
|
+
import ActionItem from "./action-item";
|
|
9
|
+
import OptionItem from "./option-item";
|
|
10
|
+
import DropdownCore from "./dropdown-core";
|
|
11
11
|
|
|
12
|
-
import ActionMenuOpenerCore from "./action-menu-opener-core
|
|
13
|
-
import type {Item, DropdownItem, OpenerProps} from "../util/types
|
|
12
|
+
import ActionMenuOpenerCore from "./action-menu-opener-core";
|
|
13
|
+
import type {Item, DropdownItem, OpenerProps} from "../util/types";
|
|
14
14
|
|
|
15
15
|
type Props = {|
|
|
16
16
|
...AriaProps,
|
|
@@ -3,9 +3,9 @@ import * as React from "react";
|
|
|
3
3
|
|
|
4
4
|
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
5
5
|
|
|
6
|
-
import SeparatorItem from "./separator-item
|
|
6
|
+
import SeparatorItem from "./separator-item";
|
|
7
7
|
|
|
8
|
-
import type {DropdownItem} from "../util/types
|
|
8
|
+
import type {DropdownItem} from "../util/types";
|
|
9
9
|
|
|
10
10
|
// copied from https://github.com/bvaughn/react-window/blob/master/src/createListComponent.js#L17
|
|
11
11
|
type Props = {|
|
|
@@ -8,17 +8,17 @@ import type {
|
|
|
8
8
|
WithActionSchedulerProps,
|
|
9
9
|
WithoutActionScheduler,
|
|
10
10
|
} from "@khanacademy/wonder-blocks-timing";
|
|
11
|
-
import DropdownVirtualizedItem from "./dropdown-core-virtualized-item
|
|
12
|
-
import SeparatorItem from "./separator-item
|
|
11
|
+
import DropdownVirtualizedItem from "./dropdown-core-virtualized-item";
|
|
12
|
+
import SeparatorItem from "./separator-item";
|
|
13
13
|
|
|
14
|
-
import type {DropdownItem} from "../util/types
|
|
14
|
+
import type {DropdownItem} from "../util/types";
|
|
15
15
|
|
|
16
16
|
import {
|
|
17
17
|
DROPDOWN_ITEM_HEIGHT,
|
|
18
18
|
MAX_VISIBLE_ITEMS,
|
|
19
19
|
SEPARATOR_ITEM_HEIGHT,
|
|
20
|
-
} from "../util/constants
|
|
21
|
-
import {getDropdownMenuHeight} from "../util/dropdown-menu-styles
|
|
20
|
+
} from "../util/constants";
|
|
21
|
+
import {getDropdownMenuHeight} from "../util/dropdown-menu-styles";
|
|
22
22
|
|
|
23
23
|
type Props = {|
|
|
24
24
|
/**
|
|
@@ -21,16 +21,16 @@ import type {
|
|
|
21
21
|
WithActionSchedulerProps,
|
|
22
22
|
WithoutActionScheduler,
|
|
23
23
|
} from "@khanacademy/wonder-blocks-timing";
|
|
24
|
-
import DropdownCoreVirtualized from "./dropdown-core-virtualized
|
|
25
|
-
import SeparatorItem from "./separator-item
|
|
26
|
-
import {defaultLabels, keyCodes} from "../util/constants
|
|
27
|
-
import type {DropdownItem} from "../util/types
|
|
28
|
-
import DropdownPopper from "./dropdown-popper
|
|
29
|
-
import {debounce, getStringForKey} from "../util/helpers
|
|
24
|
+
import DropdownCoreVirtualized from "./dropdown-core-virtualized";
|
|
25
|
+
import SeparatorItem from "./separator-item";
|
|
26
|
+
import {defaultLabels, keyCodes} from "../util/constants";
|
|
27
|
+
import type {DropdownItem} from "../util/types";
|
|
28
|
+
import DropdownPopper from "./dropdown-popper";
|
|
29
|
+
import {debounce, getStringForKey} from "../util/helpers";
|
|
30
30
|
import {
|
|
31
31
|
generateDropdownMenuStyles,
|
|
32
32
|
getDropdownMenuHeight,
|
|
33
|
-
} from "../util/dropdown-menu-styles
|
|
33
|
+
} from "../util/dropdown-menu-styles";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* The number of options to apply the virtualized list to.
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
ClickableState,
|
|
10
10
|
} from "@khanacademy/wonder-blocks-clickable";
|
|
11
11
|
|
|
12
|
-
import type {OpenerProps} from "../util/types
|
|
12
|
+
import type {OpenerProps} from "../util/types";
|
|
13
13
|
|
|
14
14
|
type Props = {|
|
|
15
15
|
...$Rest<AriaProps, {|"aria-disabled": "true" | "false" | void|}>,
|
|
@@ -5,19 +5,19 @@ import ReactDOM from "react-dom";
|
|
|
5
5
|
|
|
6
6
|
import type {AriaProps, StyleType} from "@khanacademy/wonder-blocks-core";
|
|
7
7
|
|
|
8
|
-
import ActionItem from "./action-item
|
|
9
|
-
import DropdownCore from "./dropdown-core
|
|
10
|
-
import DropdownOpener from "./dropdown-opener
|
|
11
|
-
import SelectOpener from "./select-opener
|
|
12
|
-
import SeparatorItem from "./separator-item
|
|
8
|
+
import ActionItem from "./action-item";
|
|
9
|
+
import DropdownCore from "./dropdown-core";
|
|
10
|
+
import DropdownOpener from "./dropdown-opener";
|
|
11
|
+
import SelectOpener from "./select-opener";
|
|
12
|
+
import SeparatorItem from "./separator-item";
|
|
13
13
|
import {
|
|
14
14
|
defaultLabels,
|
|
15
15
|
selectDropdownStyle,
|
|
16
16
|
filterableDropdownStyle,
|
|
17
|
-
} from "../util/constants
|
|
17
|
+
} from "../util/constants";
|
|
18
18
|
|
|
19
|
-
import typeof OptionItem from "./option-item
|
|
20
|
-
import type {DropdownItem, OpenerProps} from "../util/types
|
|
19
|
+
import typeof OptionItem from "./option-item";
|
|
20
|
+
import type {DropdownItem, OpenerProps} from "../util/types";
|
|
21
21
|
|
|
22
22
|
export type Labels = {|
|
|
23
23
|
/**
|
|
@@ -11,9 +11,9 @@ import {getClickableBehavior} from "@khanacademy/wonder-blocks-clickable";
|
|
|
11
11
|
|
|
12
12
|
import type {AriaProps, StyleType} from "@khanacademy/wonder-blocks-core";
|
|
13
13
|
|
|
14
|
-
import {DROPDOWN_ITEM_HEIGHT} from "../util/constants
|
|
15
|
-
import Check from "./check
|
|
16
|
-
import Checkbox from "./checkbox
|
|
14
|
+
import {DROPDOWN_ITEM_HEIGHT} from "../util/constants";
|
|
15
|
+
import Check from "./check";
|
|
16
|
+
import Checkbox from "./checkbox";
|
|
17
17
|
|
|
18
18
|
type OptionProps = {|
|
|
19
19
|
...AriaProps,
|
|
@@ -12,7 +12,7 @@ import {getClickableBehavior} from "@khanacademy/wonder-blocks-clickable";
|
|
|
12
12
|
import Icon, {icons} from "@khanacademy/wonder-blocks-icon";
|
|
13
13
|
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
14
14
|
import {LabelMedium} from "@khanacademy/wonder-blocks-typography";
|
|
15
|
-
import {DROPDOWN_ITEM_HEIGHT} from "../util/constants
|
|
15
|
+
import {DROPDOWN_ITEM_HEIGHT} from "../util/constants";
|
|
16
16
|
|
|
17
17
|
const StyledButton = addStyle("button");
|
|
18
18
|
|
|
@@ -5,17 +5,17 @@ import ReactDOM from "react-dom";
|
|
|
5
5
|
|
|
6
6
|
import type {AriaProps, StyleType} from "@khanacademy/wonder-blocks-core";
|
|
7
7
|
|
|
8
|
-
import DropdownCore from "./dropdown-core
|
|
9
|
-
import DropdownOpener from "./dropdown-opener
|
|
10
|
-
import SelectOpener from "./select-opener
|
|
8
|
+
import DropdownCore from "./dropdown-core";
|
|
9
|
+
import DropdownOpener from "./dropdown-opener";
|
|
10
|
+
import SelectOpener from "./select-opener";
|
|
11
11
|
import {
|
|
12
12
|
defaultLabels,
|
|
13
13
|
selectDropdownStyle,
|
|
14
14
|
filterableDropdownStyle,
|
|
15
|
-
} from "../util/constants
|
|
15
|
+
} from "../util/constants";
|
|
16
16
|
|
|
17
|
-
import typeof OptionItem from "./option-item
|
|
18
|
-
import type {DropdownItem, OpenerProps} from "../util/types
|
|
17
|
+
import typeof OptionItem from "./option-item";
|
|
18
|
+
import type {DropdownItem, OpenerProps} from "../util/types";
|
|
19
19
|
|
|
20
20
|
export type SingleSelectLabels = {|
|
|
21
21
|
/**
|
|
@@ -193,15 +193,35 @@ type State = {|
|
|
|
193
193
|
* hundreds of items without performance problems.
|
|
194
194
|
*
|
|
195
195
|
* ## Usage
|
|
196
|
+
* General usage
|
|
196
197
|
*
|
|
197
198
|
* ```jsx
|
|
198
199
|
* import {OptionItem, SingleSelect} from "@khanacademy/wonder-blocks-dropdown";
|
|
199
200
|
*
|
|
200
|
-
* const [selectedValue, setSelectedValue] = useState("");
|
|
201
|
+
* const [selectedValue, setSelectedValue] = React.useState("");
|
|
201
202
|
*
|
|
202
203
|
* <SingleSelect placeholder="Choose a fruit" onChange={setSelectedValue} selectedValue={selectedValue}>
|
|
203
|
-
*
|
|
204
|
-
*
|
|
204
|
+
* <OptionItem label="Pear" value="pear" />
|
|
205
|
+
* <OptionItem label="Mango" value="mango" />
|
|
206
|
+
* </SingleSelect>
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* Mapping a list
|
|
210
|
+
*
|
|
211
|
+
* ```jsx
|
|
212
|
+
* import {OptionItem, SingleSelect} from "@khanacademy/wonder-blocks-dropdown";
|
|
213
|
+
*
|
|
214
|
+
* const [selectedValue, setSelectedValue] = React.useState("");
|
|
215
|
+
* const fruitArray = ["Apple", "Banana", "Orange", "Mango", "Pear"];
|
|
216
|
+
*
|
|
217
|
+
* <SingleSelect
|
|
218
|
+
* placeholder="Choose a fruit"
|
|
219
|
+
* onChange={setSelectedValue}
|
|
220
|
+
* selectedValue={selectedValue}
|
|
221
|
+
* >
|
|
222
|
+
* {fruitArray.map((value, index) => (
|
|
223
|
+
* <OptionItem key={index} value={value} label={value} />
|
|
224
|
+
* ))}
|
|
205
225
|
* </SingleSelect>
|
|
206
226
|
* ```
|
|
207
227
|
*/
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import ActionItem from "./components/action-item
|
|
3
|
-
import OptionItem from "./components/option-item
|
|
4
|
-
import SeparatorItem from "./components/separator-item
|
|
5
|
-
import ActionMenu from "./components/action-menu
|
|
6
|
-
import SingleSelect from "./components/single-select
|
|
7
|
-
import MultiSelect from "./components/multi-select
|
|
2
|
+
import ActionItem from "./components/action-item";
|
|
3
|
+
import OptionItem from "./components/option-item";
|
|
4
|
+
import SeparatorItem from "./components/separator-item";
|
|
5
|
+
import ActionMenu from "./components/action-menu";
|
|
6
|
+
import SingleSelect from "./components/single-select";
|
|
7
|
+
import MultiSelect from "./components/multi-select";
|
|
8
8
|
|
|
9
|
-
import type {Labels} from "./components/multi-select
|
|
10
|
-
import type {SingleSelectLabels} from "./components/single-select
|
|
9
|
+
import type {Labels} from "./components/multi-select";
|
|
10
|
+
import type {SingleSelectLabels} from "./components/single-select";
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
13
|
ActionItem,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import OptionItem from "../../components/option-item
|
|
4
|
-
import SeparatorItem from "../../components/separator-item
|
|
3
|
+
import OptionItem from "../../components/option-item";
|
|
4
|
+
import SeparatorItem from "../../components/separator-item";
|
|
5
5
|
|
|
6
|
-
import {getDropdownMenuHeight} from "../dropdown-menu-styles
|
|
6
|
+
import {getDropdownMenuHeight} from "../dropdown-menu-styles";
|
|
7
7
|
|
|
8
8
|
const optionItems = [
|
|
9
9
|
{
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
DROPDOWN_ITEM_HEIGHT,
|
|
8
8
|
MAX_VISIBLE_ITEMS,
|
|
9
9
|
SEPARATOR_ITEM_HEIGHT,
|
|
10
|
-
} from "./constants
|
|
10
|
+
} from "./constants";
|
|
11
11
|
|
|
12
|
-
import SeparatorItem from "../components/separator-item
|
|
12
|
+
import SeparatorItem from "../components/separator-item";
|
|
13
13
|
|
|
14
|
-
import type {DropdownItem} from "./types
|
|
14
|
+
import type {DropdownItem} from "./types";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* The list height that is automatically calculated depending on the
|
package/src/util/types.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import type {ClickableState} from "@khanacademy/wonder-blocks-clickable";
|
|
5
5
|
|
|
6
|
-
import typeof ActionItem from "../components/action-item
|
|
7
|
-
import typeof OptionItem from "../components/option-item
|
|
8
|
-
import typeof SeparatorItem from "../components/separator-item
|
|
6
|
+
import typeof ActionItem from "../components/action-item";
|
|
7
|
+
import typeof OptionItem from "../components/option-item";
|
|
8
|
+
import typeof SeparatorItem from "../components/separator-item";
|
|
9
9
|
|
|
10
10
|
//TODO: rename into something more descriptive
|
|
11
11
|
export type Item =
|