@khanacademy/wonder-blocks-dropdown 2.5.1 → 2.6.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.
- package/CHANGELOG.md +41 -0
- package/dist/es/index.js +184 -182
- package/dist/index.js +2 -0
- package/package.json +15 -16
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +8 -8
- package/src/components/__tests__/action-item.test.js +30 -8
- package/src/components/__tests__/action-menu.test.js +1 -0
- package/src/components/__tests__/dropdown-core-virtualized.test.js +9 -0
- package/src/components/__tests__/dropdown-core.test.js +9 -0
- package/src/components/__tests__/multi-select.test.js +9 -0
- package/src/components/__tests__/search-text-input.test.js +1 -0
- package/src/components/__tests__/single-select.test.js +6 -11
- package/src/components/action-item.js +8 -0
- package/src/components/action-menu.stories.js +48 -0
- package/src/components/checkbox.js +1 -2
- package/src/components/dropdown-core.js +2 -3
- package/src/components/multi-select.stories.js +3 -3
- package/src/components/select-opener.js +2 -9
- package/LICENSE +0 -21
- package/src/components/__tests__/__snapshots__/action-item.test.js.snap +0 -63
package/dist/index.js
CHANGED
|
@@ -506,6 +506,7 @@ class ActionItem extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
506
506
|
target,
|
|
507
507
|
indent,
|
|
508
508
|
label,
|
|
509
|
+
lang,
|
|
509
510
|
onClick,
|
|
510
511
|
role,
|
|
511
512
|
style,
|
|
@@ -534,6 +535,7 @@ class ActionItem extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
534
535
|
...childrenProps
|
|
535
536
|
};
|
|
536
537
|
const children = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__["LabelMedium"], {
|
|
538
|
+
lang: lang,
|
|
537
539
|
style: [indent && styles.indent, styles.label]
|
|
538
540
|
}, label));
|
|
539
541
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-dropdown",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"description": "Dropdown variants for Wonder Blocks.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@babel/runtime": "^7.
|
|
19
|
-
"@khanacademy/wonder-blocks-button": "^2.
|
|
20
|
-
"@khanacademy/wonder-blocks-clickable": "^2.2.
|
|
21
|
-
"@khanacademy/wonder-blocks-color": "^1.1.
|
|
22
|
-
"@khanacademy/wonder-blocks-core": "^
|
|
23
|
-
"@khanacademy/wonder-blocks-icon": "^1.2.
|
|
24
|
-
"@khanacademy/wonder-blocks-icon-button": "^3.4.
|
|
25
|
-
"@khanacademy/wonder-blocks-layout": "^1.4.
|
|
26
|
-
"@khanacademy/wonder-blocks-modal": "^2.1
|
|
27
|
-
"@khanacademy/wonder-blocks-spacing": "^3.0.
|
|
28
|
-
"@khanacademy/wonder-blocks-timing": "^2.0
|
|
29
|
-
"@khanacademy/wonder-blocks-typography": "^1.1.
|
|
18
|
+
"@babel/runtime": "^7.16.3",
|
|
19
|
+
"@khanacademy/wonder-blocks-button": "^2.11.2",
|
|
20
|
+
"@khanacademy/wonder-blocks-clickable": "^2.2.3",
|
|
21
|
+
"@khanacademy/wonder-blocks-color": "^1.1.20",
|
|
22
|
+
"@khanacademy/wonder-blocks-core": "^4.2.1",
|
|
23
|
+
"@khanacademy/wonder-blocks-icon": "^1.2.25",
|
|
24
|
+
"@khanacademy/wonder-blocks-icon-button": "^3.4.3",
|
|
25
|
+
"@khanacademy/wonder-blocks-layout": "^1.4.7",
|
|
26
|
+
"@khanacademy/wonder-blocks-modal": "^2.2.1",
|
|
27
|
+
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
28
|
+
"@khanacademy/wonder-blocks-timing": "^2.1.0",
|
|
29
|
+
"@khanacademy/wonder-blocks-typography": "^1.1.29"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@popperjs/core": "^2.10.1",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"react-window": "^1.8.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"wb-dev-build-settings": "^0.
|
|
43
|
-
}
|
|
44
|
-
"gitHead": "61090a61b6e9d2a735976d5fd53a15d06f10c853"
|
|
42
|
+
"wb-dev-build-settings": "^0.3.0"
|
|
43
|
+
}
|
|
45
44
|
}
|
|
@@ -651,7 +651,7 @@ exports[`wonder-blocks-dropdown example 4 1`] = `
|
|
|
651
651
|
"touchAction": "manipulation",
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
|
-
tabIndex={
|
|
654
|
+
tabIndex={0}
|
|
655
655
|
type="button"
|
|
656
656
|
>
|
|
657
657
|
<div
|
|
@@ -1134,8 +1134,8 @@ exports[`wonder-blocks-dropdown example 6 1`] = `
|
|
|
1134
1134
|
}
|
|
1135
1135
|
/>
|
|
1136
1136
|
<button
|
|
1137
|
+
aria-disabled={false}
|
|
1137
1138
|
className=""
|
|
1138
|
-
disabled={false}
|
|
1139
1139
|
onBlur={[Function]}
|
|
1140
1140
|
onClick={[Function]}
|
|
1141
1141
|
onDragStart={[Function]}
|
|
@@ -1627,7 +1627,7 @@ exports[`wonder-blocks-dropdown example 10 1`] = `
|
|
|
1627
1627
|
"whiteSpace": "nowrap",
|
|
1628
1628
|
}
|
|
1629
1629
|
}
|
|
1630
|
-
tabIndex={
|
|
1630
|
+
tabIndex={0}
|
|
1631
1631
|
type="button"
|
|
1632
1632
|
>
|
|
1633
1633
|
<span
|
|
@@ -1926,7 +1926,7 @@ exports[`wonder-blocks-dropdown example 12 1`] = `
|
|
|
1926
1926
|
"whiteSpace": "nowrap",
|
|
1927
1927
|
}
|
|
1928
1928
|
}
|
|
1929
|
-
tabIndex={
|
|
1929
|
+
tabIndex={0}
|
|
1930
1930
|
type="button"
|
|
1931
1931
|
>
|
|
1932
1932
|
<span
|
|
@@ -2292,8 +2292,8 @@ exports[`wonder-blocks-dropdown example 14 1`] = `
|
|
|
2292
2292
|
}
|
|
2293
2293
|
/>
|
|
2294
2294
|
<button
|
|
2295
|
+
aria-disabled={false}
|
|
2295
2296
|
className=""
|
|
2296
|
-
disabled={false}
|
|
2297
2297
|
onBlur={[Function]}
|
|
2298
2298
|
onClick={[Function]}
|
|
2299
2299
|
onDragStart={[Function]}
|
|
@@ -2998,8 +2998,8 @@ exports[`wonder-blocks-dropdown example 20 1`] = `
|
|
|
2998
2998
|
}
|
|
2999
2999
|
>
|
|
3000
3000
|
<button
|
|
3001
|
+
aria-disabled={false}
|
|
3001
3002
|
className=""
|
|
3002
|
-
disabled={false}
|
|
3003
3003
|
onBlur={[Function]}
|
|
3004
3004
|
onClick={[Function]}
|
|
3005
3005
|
onDragStart={[Function]}
|
|
@@ -3159,7 +3159,7 @@ exports[`wonder-blocks-dropdown example 21 1`] = `
|
|
|
3159
3159
|
"whiteSpace": "nowrap",
|
|
3160
3160
|
}
|
|
3161
3161
|
}
|
|
3162
|
-
tabIndex={
|
|
3162
|
+
tabIndex={0}
|
|
3163
3163
|
type="button"
|
|
3164
3164
|
>
|
|
3165
3165
|
<span
|
|
@@ -3661,8 +3661,8 @@ exports[`wonder-blocks-dropdown example 24 1`] = `
|
|
|
3661
3661
|
}
|
|
3662
3662
|
/>
|
|
3663
3663
|
<button
|
|
3664
|
+
aria-disabled={false}
|
|
3664
3665
|
className=""
|
|
3665
|
-
disabled={false}
|
|
3666
3666
|
onBlur={[Function]}
|
|
3667
3667
|
onClick={[Function]}
|
|
3668
3668
|
onDragStart={[Function]}
|
|
@@ -1,32 +1,54 @@
|
|
|
1
|
+
// @flow
|
|
1
2
|
import * as React from "react";
|
|
2
|
-
import renderer from "react-test-renderer";
|
|
3
3
|
import {MemoryRouter, Link} from "react-router-dom";
|
|
4
4
|
import {mount} from "enzyme";
|
|
5
|
+
import {render, screen} from "@testing-library/react";
|
|
5
6
|
|
|
6
7
|
import ActionItem from "../action-item.js";
|
|
7
8
|
|
|
8
9
|
describe("ActionItem", () => {
|
|
9
10
|
it("should render with disabled styles", () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
// Arrange
|
|
12
|
+
|
|
13
|
+
// Act
|
|
14
|
+
render(<ActionItem href="/foo" label="Example" disabled={true} />);
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
// Assert
|
|
17
|
+
expect(screen.getByRole("menuitem")).toBeDisabled();
|
|
15
18
|
});
|
|
16
19
|
|
|
17
20
|
it("should render an anchor if there's no router", () => {
|
|
18
|
-
|
|
21
|
+
// Arrange
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
// Act
|
|
24
|
+
render(<ActionItem href="/foo" label="Example" />);
|
|
25
|
+
|
|
26
|
+
// Assert
|
|
27
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
28
|
+
expect(document.querySelectorAll("a")).toHaveLength(1);
|
|
21
29
|
});
|
|
22
30
|
|
|
23
31
|
it("should render a Link if there's a router", () => {
|
|
32
|
+
// Arrange
|
|
33
|
+
|
|
34
|
+
// Act
|
|
24
35
|
const wrapper = mount(
|
|
25
36
|
<MemoryRouter>
|
|
26
|
-
<ActionItem href="/foo" />
|
|
37
|
+
<ActionItem href="/foo" label="Example" />
|
|
27
38
|
</MemoryRouter>,
|
|
28
39
|
);
|
|
29
40
|
|
|
41
|
+
// Assert
|
|
30
42
|
expect(wrapper.find(Link)).toHaveLength(1);
|
|
31
43
|
});
|
|
44
|
+
|
|
45
|
+
it("should set the lang attribute if it's passed down", () => {
|
|
46
|
+
// Arrange
|
|
47
|
+
|
|
48
|
+
// Act
|
|
49
|
+
render(<ActionItem label="Español" lang="es" />);
|
|
50
|
+
|
|
51
|
+
// Assert
|
|
52
|
+
expect(screen.getByText("Español")).toHaveAttribute("lang", "es");
|
|
53
|
+
});
|
|
32
54
|
});
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {VariableSizeList as List} from "react-window";
|
|
4
4
|
import {mount} from "enzyme";
|
|
5
|
+
import "jest-enzyme";
|
|
5
6
|
|
|
6
7
|
import OptionItem from "../option-item.js";
|
|
7
8
|
import SeparatorItem from "../separator-item.js";
|
|
8
9
|
import DropdownCoreVirtualized from "../dropdown-core-virtualized.js";
|
|
9
10
|
import SearchTextInput from "../search-text-input.js";
|
|
10
11
|
|
|
12
|
+
import {unmountAll} from "../../../../../utils/testing/enzyme-shim.js";
|
|
13
|
+
|
|
11
14
|
describe("DropdownCoreVirtualized", () => {
|
|
12
15
|
beforeEach(() => {
|
|
13
16
|
jest.useFakeTimers();
|
|
@@ -24,6 +27,12 @@ describe("DropdownCoreVirtualized", () => {
|
|
|
24
27
|
});
|
|
25
28
|
|
|
26
29
|
afterEach(() => {
|
|
30
|
+
// We have to explicitly unmount before clearing mocks, otherwise jest
|
|
31
|
+
// timers will throw because we'll try to clear an animation frame that
|
|
32
|
+
// we set with a setTimeout but are clearing with clearAnimationFrame
|
|
33
|
+
// because we restored the clearAnimationFrame mock (and we won't
|
|
34
|
+
// have cleared the timeout we actually set!)
|
|
35
|
+
unmountAll();
|
|
27
36
|
jest.restoreAllMocks();
|
|
28
37
|
});
|
|
29
38
|
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import * as ReactDOM from "react-dom";
|
|
4
4
|
import {mount} from "enzyme";
|
|
5
|
+
import "jest-enzyme";
|
|
5
6
|
|
|
6
7
|
import OptionItem from "../option-item.js";
|
|
7
8
|
import SearchTextInput from "../search-text-input.js";
|
|
8
9
|
import DropdownCore from "../dropdown-core.js";
|
|
9
10
|
import {keyCodes} from "../../util/constants.js";
|
|
10
11
|
|
|
12
|
+
import {unmountAll} from "../../../../../utils/testing/enzyme-shim.js";
|
|
13
|
+
|
|
11
14
|
jest.mock("../dropdown-core-virtualized.js");
|
|
12
15
|
|
|
13
16
|
const elementAtIndex = (wrapper, index) =>
|
|
@@ -87,6 +90,12 @@ describe("DropdownCore", () => {
|
|
|
87
90
|
});
|
|
88
91
|
|
|
89
92
|
afterEach(() => {
|
|
93
|
+
// We have to explicitly unmount before clearing mocks, otherwise jest
|
|
94
|
+
// timers will throw because we'll try to clear an animation frame that
|
|
95
|
+
// we set with a setTimeout but are clearing with clearAnimationFrame
|
|
96
|
+
// because we restored the clearAnimationFrame mock (and we won't
|
|
97
|
+
// have cleared the timeout we actually set!)
|
|
98
|
+
unmountAll();
|
|
90
99
|
jest.restoreAllMocks();
|
|
91
100
|
});
|
|
92
101
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
//@flow
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import {mount} from "enzyme";
|
|
5
|
+
import "jest-enzyme";
|
|
5
6
|
|
|
6
7
|
import {ClickableBehavior} from "@khanacademy/wonder-blocks-clickable";
|
|
7
8
|
import IconButton from "@khanacademy/wonder-blocks-icon-button";
|
|
@@ -14,6 +15,8 @@ import MultiSelect from "../multi-select.js";
|
|
|
14
15
|
import {keyCodes} from "../../util/constants.js";
|
|
15
16
|
import SearchTextInput from "../search-text-input.js";
|
|
16
17
|
|
|
18
|
+
import {unmountAll} from "../../../../../utils/testing/enzyme-shim.js";
|
|
19
|
+
|
|
17
20
|
import type {Labels} from "../multi-select.js";
|
|
18
21
|
|
|
19
22
|
jest.useFakeTimers();
|
|
@@ -68,6 +71,12 @@ describe("MultiSelect", () => {
|
|
|
68
71
|
});
|
|
69
72
|
|
|
70
73
|
afterEach(() => {
|
|
74
|
+
// We have to explicitly unmount before clearing mocks, otherwise jest
|
|
75
|
+
// timers will throw because we'll try to clear an animation frame that
|
|
76
|
+
// we set with a setTimeout but are clearing with clearAnimationFrame
|
|
77
|
+
// because we restored the clearAnimationFrame mock (and we won't
|
|
78
|
+
// have cleared the timeout we actually set!)
|
|
79
|
+
unmountAll();
|
|
71
80
|
jest.restoreAllMocks();
|
|
72
81
|
});
|
|
73
82
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
//@flow
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {render, screen} from "@testing-library/react";
|
|
4
|
-
// eslint-disable-next-line import/no-unassigned-import
|
|
5
|
-
import "@testing-library/jest-dom/extend-expect";
|
|
6
4
|
|
|
7
5
|
import OptionItem from "../option-item.js";
|
|
8
6
|
import SingleSelect from "../single-select.js";
|
|
@@ -25,8 +23,7 @@ describe("SingleSelect", () => {
|
|
|
25
23
|
afterEach(() => {
|
|
26
24
|
window.scrollTo.mockClear();
|
|
27
25
|
onChange.mockReset();
|
|
28
|
-
|
|
29
|
-
console.error.mockReset(); // eslint-disable-line no-console
|
|
26
|
+
jest.spyOn(console, "error").mockReset();
|
|
30
27
|
});
|
|
31
28
|
|
|
32
29
|
afterEach(() => {
|
|
@@ -52,7 +49,7 @@ describe("SingleSelect", () => {
|
|
|
52
49
|
userEvent.click(opener);
|
|
53
50
|
|
|
54
51
|
// Assert
|
|
55
|
-
expect(screen.
|
|
52
|
+
expect(screen.getByRole("listbox")).toBeInTheDocument();
|
|
56
53
|
});
|
|
57
54
|
|
|
58
55
|
it("should focus the first item in the dropdown", () => {
|
|
@@ -121,9 +118,7 @@ describe("SingleSelect", () => {
|
|
|
121
118
|
userEvent.keyboard(key);
|
|
122
119
|
|
|
123
120
|
// Assert
|
|
124
|
-
expect(
|
|
125
|
-
screen.queryByRole("listbox"),
|
|
126
|
-
).toBeInTheDocument();
|
|
121
|
+
expect(screen.getByRole("listbox")).toBeInTheDocument();
|
|
127
122
|
});
|
|
128
123
|
|
|
129
124
|
it("should focus the first item in the dropdown", () => {
|
|
@@ -152,7 +147,7 @@ describe("SingleSelect", () => {
|
|
|
152
147
|
|
|
153
148
|
// Assert
|
|
154
149
|
expect(onChange).not.toHaveBeenCalled();
|
|
155
|
-
expect(screen.
|
|
150
|
+
expect(screen.getByRole("listbox")).toBeInTheDocument();
|
|
156
151
|
});
|
|
157
152
|
|
|
158
153
|
it("should select an item when pressing {space}", () => {
|
|
@@ -278,7 +273,7 @@ describe("SingleSelect", () => {
|
|
|
278
273
|
userEvent.click(screen.getByText("Choose"));
|
|
279
274
|
|
|
280
275
|
// Assert
|
|
281
|
-
expect(screen.
|
|
276
|
+
expect(screen.getByRole("listbox")).toBeInTheDocument();
|
|
282
277
|
});
|
|
283
278
|
|
|
284
279
|
it("closes the menu when the anchor is clicked", () => {
|
|
@@ -321,7 +316,7 @@ describe("SingleSelect", () => {
|
|
|
321
316
|
userEvent.click(opener);
|
|
322
317
|
|
|
323
318
|
// Assert
|
|
324
|
-
expect(screen.
|
|
319
|
+
expect(screen.getByRole("listbox")).toBeInTheDocument();
|
|
325
320
|
});
|
|
326
321
|
|
|
327
322
|
it("calls the custom onClick handler", () => {
|
|
@@ -38,6 +38,12 @@ type ActionProps = {|
|
|
|
38
38
|
*/
|
|
39
39
|
href?: string,
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Optional attribute to indicate to the Screen Reader which language the
|
|
43
|
+
* item text is in.
|
|
44
|
+
*/
|
|
45
|
+
lang?: string,
|
|
46
|
+
|
|
41
47
|
/**
|
|
42
48
|
* A target destination window for a link to open in.
|
|
43
49
|
*/
|
|
@@ -131,6 +137,7 @@ export default class ActionItem extends React.Component<ActionProps> {
|
|
|
131
137
|
target,
|
|
132
138
|
indent,
|
|
133
139
|
label,
|
|
140
|
+
lang,
|
|
134
141
|
onClick,
|
|
135
142
|
role,
|
|
136
143
|
style,
|
|
@@ -176,6 +183,7 @@ export default class ActionItem extends React.Component<ActionProps> {
|
|
|
176
183
|
const children = (
|
|
177
184
|
<React.Fragment>
|
|
178
185
|
<LabelMedium
|
|
186
|
+
lang={lang}
|
|
179
187
|
style={[indent && styles.indent, styles.label]}
|
|
180
188
|
>
|
|
181
189
|
{label}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import type {StoryComponentType} from "@storybook/react";
|
|
5
|
+
import ActionMenu from "./action-menu.js";
|
|
6
|
+
import ActionItem from "./action-item.js";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: "Dropdown / ActionMenu",
|
|
10
|
+
component: ActionMenu,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const ActionMenuWithLang: StoryComponentType = () => (
|
|
14
|
+
<ActionMenu menuText="Locales">
|
|
15
|
+
{locales.map((locale) => (
|
|
16
|
+
<ActionItem
|
|
17
|
+
key={locale.locale}
|
|
18
|
+
label={locale.localName}
|
|
19
|
+
lang={locale.locale}
|
|
20
|
+
testId={"language_picker_" + locale.locale}
|
|
21
|
+
/>
|
|
22
|
+
))}
|
|
23
|
+
</ActionMenu>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
ActionMenuWithLang.storyName = "Using the ActionMenu with the lang attribute";
|
|
27
|
+
|
|
28
|
+
ActionMenuWithLang.parameters = {
|
|
29
|
+
docs: {
|
|
30
|
+
storyDescription:
|
|
31
|
+
"You can use the `lang` attribute to specify the language of the action item(s). This is useful if you want to avoid issues with Screen Readers trying to read the proper language for the rendered text.",
|
|
32
|
+
},
|
|
33
|
+
chromatic: {
|
|
34
|
+
disableSnapshot: true,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const locales = [
|
|
39
|
+
{id: "az", locale: "az", localName: "Azərbaycanca"},
|
|
40
|
+
{id: "id", locale: "id", localName: "Bahasa Indonesia"},
|
|
41
|
+
{id: "cs", locale: "cs", localName: "čeština"},
|
|
42
|
+
{id: "da", locale: "da", localName: "dansk"},
|
|
43
|
+
{id: "de", locale: "de", localName: "Deutsch"},
|
|
44
|
+
{id: "en", locale: "en", localName: "English"},
|
|
45
|
+
{id: "es", locale: "es", localName: "español"},
|
|
46
|
+
{id: "fr", locale: "fr", localName: "français"},
|
|
47
|
+
{id: "it", locale: "it", localName: "italiano"},
|
|
48
|
+
];
|
|
@@ -14,8 +14,7 @@ import type {IconAsset} from "@khanacademy/wonder-blocks-icon";
|
|
|
14
14
|
// If the intended icon is a check without a checkbox, you should be using
|
|
15
15
|
// icons.check from the Wonder Blocks Icon package.
|
|
16
16
|
const checkboxCheck: IconAsset = {
|
|
17
|
-
small:
|
|
18
|
-
"M11.263 4.324a1 1 0 1 1 1.474 1.352l-5.5 6a1 1 0 0 1-1.505-.036l-2.5-3a1 1 0 1 1 1.536-1.28L6.536 9.48l4.727-5.157z",
|
|
17
|
+
small: "M11.263 4.324a1 1 0 1 1 1.474 1.352l-5.5 6a1 1 0 0 1-1.505-.036l-2.5-3a1 1 0 1 1 1.536-1.28L6.536 9.48l4.727-5.157z",
|
|
19
18
|
};
|
|
20
19
|
const {blue, white, offBlack16, offBlack32, offBlack50, offWhite} = Color;
|
|
21
20
|
|
|
@@ -522,9 +522,8 @@ class DropdownCore extends React.Component<Props, State> {
|
|
|
522
522
|
// appropriate item in handleKeyDown
|
|
523
523
|
this.itemsClicked = true;
|
|
524
524
|
this.focusedIndex = index;
|
|
525
|
-
this.focusedOriginalIndex =
|
|
526
|
-
this.focusedIndex
|
|
527
|
-
].originalIndex;
|
|
525
|
+
this.focusedOriginalIndex =
|
|
526
|
+
this.state.itemRefs[this.focusedIndex].originalIndex;
|
|
528
527
|
};
|
|
529
528
|
|
|
530
529
|
handleDropdownMouseUp: (event: SyntheticMouseEvent<>) => void = (event) => {
|
|
@@ -79,18 +79,18 @@ class MultiSelectWithCustomStyles extends React.Component<Props, State> {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
export const
|
|
82
|
+
export const CustomStyles: StoryComponentType = () => (
|
|
83
83
|
<MultiSelectWithCustomStyles />
|
|
84
84
|
);
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
CustomStyles.parameters = {
|
|
87
87
|
chromatic: {
|
|
88
88
|
// we don't need screenshots because this story only tests behavior.
|
|
89
89
|
disableSnapshot: true,
|
|
90
90
|
},
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
export const
|
|
93
|
+
export const CustomStylesOpened: StoryComponentType = () => (
|
|
94
94
|
<MultiSelectWithCustomStyles opened={true} />
|
|
95
95
|
);
|
|
96
96
|
|
|
@@ -16,15 +16,8 @@ import {DROPDOWN_ITEM_HEIGHT} from "../util/constants.js";
|
|
|
16
16
|
|
|
17
17
|
const StyledButton = addStyle("button");
|
|
18
18
|
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
white,
|
|
22
|
-
white50,
|
|
23
|
-
offBlack,
|
|
24
|
-
offBlack16,
|
|
25
|
-
offBlack32,
|
|
26
|
-
offBlack64,
|
|
27
|
-
} = Color;
|
|
19
|
+
const {blue, white, white50, offBlack, offBlack16, offBlack32, offBlack64} =
|
|
20
|
+
Color;
|
|
28
21
|
|
|
29
22
|
type SelectOpenerProps = {|
|
|
30
23
|
...AriaProps,
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Khan Academy
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`ActionItem should render with disabled styles 1`] = `
|
|
4
|
-
<button
|
|
5
|
-
className=""
|
|
6
|
-
disabled={true}
|
|
7
|
-
onBlur={[Function]}
|
|
8
|
-
onClick={[Function]}
|
|
9
|
-
onDragStart={[Function]}
|
|
10
|
-
onFocus={[Function]}
|
|
11
|
-
onKeyDown={[Function]}
|
|
12
|
-
onKeyUp={[Function]}
|
|
13
|
-
onMouseDown={[Function]}
|
|
14
|
-
onMouseEnter={[Function]}
|
|
15
|
-
onMouseLeave={[Function]}
|
|
16
|
-
onMouseUp={[Function]}
|
|
17
|
-
onTouchCancel={[Function]}
|
|
18
|
-
onTouchEnd={[Function]}
|
|
19
|
-
onTouchStart={[Function]}
|
|
20
|
-
role="menuitem"
|
|
21
|
-
style={
|
|
22
|
-
Object {
|
|
23
|
-
"::MozFocusInner": Object {
|
|
24
|
-
"border": 0,
|
|
25
|
-
},
|
|
26
|
-
"alignItems": "center",
|
|
27
|
-
"background": "#ffffff",
|
|
28
|
-
"border": "none",
|
|
29
|
-
"color": "rgba(33,36,44,0.32)",
|
|
30
|
-
"cursor": "default",
|
|
31
|
-
"display": "flex",
|
|
32
|
-
"flexDirection": "row",
|
|
33
|
-
"height": 40,
|
|
34
|
-
"margin": 0,
|
|
35
|
-
"minHeight": 40,
|
|
36
|
-
"outline": "none",
|
|
37
|
-
"paddingLeft": 16,
|
|
38
|
-
"paddingRight": 16,
|
|
39
|
-
"textDecoration": "none",
|
|
40
|
-
"touchAction": "manipulation",
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
tabIndex={-1}
|
|
44
|
-
type="button"
|
|
45
|
-
>
|
|
46
|
-
<span
|
|
47
|
-
className=""
|
|
48
|
-
style={
|
|
49
|
-
Object {
|
|
50
|
-
"MozOsxFontSmoothing": "grayscale",
|
|
51
|
-
"WebkitFontSmoothing": "antialiased",
|
|
52
|
-
"display": "block",
|
|
53
|
-
"fontFamily": "Lato, \\"Noto Sans\\", sans-serif",
|
|
54
|
-
"fontSize": 16,
|
|
55
|
-
"fontWeight": 400,
|
|
56
|
-
"lineHeight": "20px",
|
|
57
|
-
"userSelect": "none",
|
|
58
|
-
"whiteSpace": "nowrap",
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/>
|
|
62
|
-
</button>
|
|
63
|
-
`;
|