@khanacademy/wonder-blocks-dropdown 7.0.5 → 8.0.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 +26 -0
- package/dist/components/combobox.d.ts +0 -7
- package/dist/components/dropdown-core-virtualized.d.ts +3 -3
- package/dist/components/dropdown-core.d.ts +17 -21
- package/dist/components/multi-select.d.ts +0 -5
- package/dist/components/select-opener.d.ts +0 -6
- package/dist/components/single-select.d.ts +0 -5
- package/dist/es/index.js +77 -118
- package/dist/hooks/use-listbox.d.ts +14 -14
- package/dist/index.js +158 -199
- package/dist/util/helpers.d.ts +0 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-dropdown
|
|
2
2
|
|
|
3
|
+
## 8.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- d8d41dc9: Removes the `light` prop from wonder-blocks-dropdown. This includes removing that in `SingleSelect` and `MultiSelect`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- c774f7da: Updates `SelectOpener` (internal component) from `Dropdown` to match Design specs. Also converts `color` tokens to use `semanticColor` tokens.
|
|
12
|
+
- Updated dependencies [8d26588f]
|
|
13
|
+
- Updated dependencies [0de25cd8]
|
|
14
|
+
- @khanacademy/wonder-blocks-search-field@5.0.0
|
|
15
|
+
- @khanacademy/wonder-blocks-tokens@4.0.0
|
|
16
|
+
- @khanacademy/wonder-blocks-cell@4.0.6
|
|
17
|
+
- @khanacademy/wonder-blocks-clickable@5.0.6
|
|
18
|
+
- @khanacademy/wonder-blocks-layout@3.0.6
|
|
19
|
+
- @khanacademy/wonder-blocks-modal@7.0.4
|
|
20
|
+
- @khanacademy/wonder-blocks-pill@3.0.6
|
|
21
|
+
|
|
22
|
+
## 7.0.6
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- b2df9d32: MultiSelect: Clear error state when "Select none" or "Select all" shortcuts are used
|
|
27
|
+
- @khanacademy/wonder-blocks-search-field@4.0.6
|
|
28
|
+
|
|
3
29
|
## 7.0.5
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -47,13 +47,6 @@ type Props = {
|
|
|
47
47
|
* This is useful for internationalization. Defaults to English.
|
|
48
48
|
*/
|
|
49
49
|
labels?: ComboboxLabels;
|
|
50
|
-
/**
|
|
51
|
-
* Whether to display the light version of this component.
|
|
52
|
-
*
|
|
53
|
-
* For use when the component is used on a dark background. Defaults to
|
|
54
|
-
* false.
|
|
55
|
-
*/
|
|
56
|
-
light?: boolean;
|
|
57
50
|
/**
|
|
58
51
|
* TODO(WB-1678): Add async support to the listbox.
|
|
59
52
|
*
|
|
@@ -3,9 +3,9 @@ import { VariableSizeList as List } from "react-window";
|
|
|
3
3
|
import type { DropdownItem } from "../util/types";
|
|
4
4
|
declare const _default: {
|
|
5
5
|
(props: {
|
|
6
|
-
data: DropdownItem
|
|
7
|
-
width?: number | null | undefined;
|
|
8
|
-
listRef?: React.RefObject<List
|
|
6
|
+
data: Array<DropdownItem>;
|
|
7
|
+
width?: number | null | undefined | undefined;
|
|
8
|
+
listRef?: React.RefObject<List> | undefined;
|
|
9
9
|
}): React.JSX.Element;
|
|
10
10
|
displayName: string;
|
|
11
11
|
};
|
|
@@ -21,11 +21,11 @@ type Labels = {
|
|
|
21
21
|
someResults: (numOptions: number) => string;
|
|
22
22
|
};
|
|
23
23
|
type DropdownAriaRole = "listbox" | "menu";
|
|
24
|
-
|
|
24
|
+
type ExportProps = Readonly<{
|
|
25
25
|
/**
|
|
26
26
|
* Items for the menu.
|
|
27
27
|
*/
|
|
28
|
-
items: DropdownItem
|
|
28
|
+
items: Array<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 @@ declare const _default: React.ComponentType<Readonly<{
|
|
|
38
38
|
/**
|
|
39
39
|
* The component that opens the menu.
|
|
40
40
|
*/
|
|
41
|
-
opener: React.ReactElement<any
|
|
41
|
+
opener: React.ReactElement<any>;
|
|
42
42
|
/**
|
|
43
43
|
* Ref to the opener element.
|
|
44
44
|
*/
|
|
45
|
-
openerElement?: HTMLElement
|
|
45
|
+
openerElement?: HTMLElement;
|
|
46
46
|
/**
|
|
47
47
|
* The aria "role" applied to the dropdown container.
|
|
48
48
|
*/
|
|
@@ -52,7 +52,7 @@ declare const _default: React.ComponentType<Readonly<{
|
|
|
52
52
|
* the searchText exist, SearchField will be displayed at the top of the
|
|
53
53
|
* dropdown body.
|
|
54
54
|
*/
|
|
55
|
-
onSearchTextChanged?: (
|
|
55
|
+
onSearchTextChanged?: (searchText: string) => unknown | null | 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,29 +71,29 @@ declare const _default: React.ComponentType<Readonly<{
|
|
|
71
71
|
/**
|
|
72
72
|
* Optional CSS classes for the entire dropdown component.
|
|
73
73
|
*/
|
|
74
|
-
className?: string
|
|
74
|
+
className?: string;
|
|
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;
|
|
80
80
|
/**
|
|
81
81
|
* Whether the dropdown and it's interactions should be disabled.
|
|
82
82
|
*/
|
|
83
|
-
disabled?: boolean
|
|
83
|
+
disabled?: boolean;
|
|
84
84
|
/**
|
|
85
85
|
* Unique identifier attached to the dropdown.
|
|
86
86
|
*/
|
|
87
|
-
id?: string
|
|
87
|
+
id?: string;
|
|
88
88
|
/**
|
|
89
89
|
* Whether this menu should be left-aligned or right-aligned with the
|
|
90
90
|
* opener component. Defaults to left-aligned.
|
|
91
91
|
*/
|
|
92
|
-
alignment?: "left" | "right"
|
|
92
|
+
alignment?: "left" | "right";
|
|
93
93
|
/**
|
|
94
94
|
* Whether to auto focus an option. Defaults to true.
|
|
95
95
|
*/
|
|
96
|
-
autoFocus?: boolean
|
|
96
|
+
autoFocus?: boolean;
|
|
97
97
|
/**
|
|
98
98
|
* Whether to enable the type-ahead suggestions feature. Defaults to true.
|
|
99
99
|
*
|
|
@@ -107,24 +107,20 @@ declare const _default: React.ComponentType<Readonly<{
|
|
|
107
107
|
* some cases where it's not desirable (for example when using a `TextField`
|
|
108
108
|
* as the opener element).
|
|
109
109
|
*/
|
|
110
|
-
enableTypeAhead?: boolean
|
|
110
|
+
enableTypeAhead?: boolean;
|
|
111
111
|
/**
|
|
112
112
|
* An index that represents the index of the focused element when the menu
|
|
113
113
|
* is opened.
|
|
114
114
|
*/
|
|
115
|
-
initialFocusedIndex?: number
|
|
115
|
+
initialFocusedIndex?: number;
|
|
116
116
|
/**
|
|
117
117
|
* The object containing the custom labels used inside this component.
|
|
118
118
|
*/
|
|
119
|
-
labels?: Labels
|
|
120
|
-
/**
|
|
121
|
-
* Whether to display the "light" version of this component instead, for
|
|
122
|
-
* use when the item is used on a dark background.
|
|
123
|
-
*/
|
|
124
|
-
light?: boolean | undefined;
|
|
119
|
+
labels?: Labels;
|
|
125
120
|
/**
|
|
126
121
|
* Used to determine if we can automatically select an item using the keyboard.
|
|
127
122
|
*/
|
|
128
|
-
selectionType?: "single" | "multi"
|
|
129
|
-
}
|
|
123
|
+
selectionType?: "single" | "multi";
|
|
124
|
+
}>;
|
|
125
|
+
declare const _default: React.ComponentType<ExportProps>;
|
|
130
126
|
export default _default;
|
|
@@ -51,11 +51,6 @@ type DefaultProps = Readonly<{
|
|
|
51
51
|
* Whether this component is in an error state. Defaults to false.
|
|
52
52
|
*/
|
|
53
53
|
error?: boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Whether to display the "light" version of this component instead, for
|
|
56
|
-
* use when the component is used on a dark background.
|
|
57
|
-
*/
|
|
58
|
-
light?: boolean;
|
|
59
54
|
/**
|
|
60
55
|
* The values of the items that are currently selected.
|
|
61
56
|
*/
|
|
@@ -25,11 +25,6 @@ type SelectOpenerProps = AriaProps & {
|
|
|
25
25
|
* of this component. A placeholder has more faded text colors and styles.
|
|
26
26
|
*/
|
|
27
27
|
isPlaceholder: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Whether to display the "light" version of this component instead, for
|
|
30
|
-
* use when the item is used on a dark background.
|
|
31
|
-
*/
|
|
32
|
-
light: boolean;
|
|
33
28
|
/**
|
|
34
29
|
* Callback for when the SelectOpener is pressed.
|
|
35
30
|
*/
|
|
@@ -50,7 +45,6 @@ type SelectOpenerProps = AriaProps & {
|
|
|
50
45
|
type DefaultProps = {
|
|
51
46
|
disabled: SelectOpenerProps["disabled"];
|
|
52
47
|
error: SelectOpenerProps["error"];
|
|
53
|
-
light: SelectOpenerProps["light"];
|
|
54
48
|
isPlaceholder: SelectOpenerProps["isPlaceholder"];
|
|
55
49
|
};
|
|
56
50
|
type SelectOpenerState = {
|
|
@@ -53,11 +53,6 @@ type DefaultProps = Readonly<{
|
|
|
53
53
|
* Whether or not the input in is an error state. Defaults to false.
|
|
54
54
|
*/
|
|
55
55
|
error?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Whether to display the "light" version of this component instead, for
|
|
58
|
-
* use when the component is used on a dark background.
|
|
59
|
-
*/
|
|
60
|
-
light?: boolean;
|
|
61
56
|
/**
|
|
62
57
|
* The object containing the custom labels used inside this component.
|
|
63
58
|
*/
|
package/dist/es/index.js
CHANGED
|
@@ -3,8 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useId } from 'react';
|
|
4
4
|
import { StyleSheet } from 'aphrodite';
|
|
5
5
|
import { CompactCell, DetailCell } from '@khanacademy/wonder-blocks-cell';
|
|
6
|
-
import
|
|
7
|
-
import { spacing, color, mix, fade, font, border, semanticColor } from '@khanacademy/wonder-blocks-tokens';
|
|
6
|
+
import { spacing, color, mix, fade, semanticColor, border, font } from '@khanacademy/wonder-blocks-tokens';
|
|
8
7
|
import { LabelMedium, LabelSmall, LabelLarge } from '@khanacademy/wonder-blocks-typography';
|
|
9
8
|
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutPropertiesLoose';
|
|
10
9
|
import { View, addStyle, Id, useOnMountEffect } from '@khanacademy/wonder-blocks-core';
|
|
@@ -1259,7 +1258,6 @@ class DropdownCore extends React.Component {
|
|
|
1259
1258
|
"aria-required": ariaRequired,
|
|
1260
1259
|
dropdownStyle,
|
|
1261
1260
|
isFilterable,
|
|
1262
|
-
light,
|
|
1263
1261
|
openerElement,
|
|
1264
1262
|
role,
|
|
1265
1263
|
id
|
|
@@ -1268,7 +1266,7 @@ class DropdownCore extends React.Component {
|
|
|
1268
1266
|
const minDropdownWidth = openerStyle ? openerStyle.getPropertyValue("width") : 0;
|
|
1269
1267
|
return React.createElement(View, {
|
|
1270
1268
|
onMouseUp: this.handleDropdownMouseUp,
|
|
1271
|
-
style: [styles$7.dropdown,
|
|
1269
|
+
style: [styles$7.dropdown, isReferenceHidden && styles$7.hidden, dropdownStyle],
|
|
1272
1270
|
testId: "dropdown-core-container"
|
|
1273
1271
|
}, isFilterable && this.renderSearchField(), React.createElement(View, {
|
|
1274
1272
|
id: id,
|
|
@@ -1337,7 +1335,6 @@ DropdownCore.defaultProps = {
|
|
|
1337
1335
|
noResults: defaultLabels.noResults,
|
|
1338
1336
|
someResults: defaultLabels.someSelected
|
|
1339
1337
|
},
|
|
1340
|
-
light: false,
|
|
1341
1338
|
selectionType: "single"
|
|
1342
1339
|
};
|
|
1343
1340
|
const styles$7 = StyleSheet.create({
|
|
@@ -1353,9 +1350,6 @@ const styles$7 = StyleSheet.create({
|
|
|
1353
1350
|
boxShadow: `0px 8px 8px 0px ${fade(color.offBlack, 0.1)}`,
|
|
1354
1351
|
maxHeight: "var(--popper-max-height)"
|
|
1355
1352
|
},
|
|
1356
|
-
light: {
|
|
1357
|
-
border: "none"
|
|
1358
|
-
},
|
|
1359
1353
|
listboxOrMenu: {
|
|
1360
1354
|
overflowY: "auto"
|
|
1361
1355
|
},
|
|
@@ -1682,7 +1676,7 @@ const styles$5 = StyleSheet.create({
|
|
|
1682
1676
|
}
|
|
1683
1677
|
});
|
|
1684
1678
|
|
|
1685
|
-
const _excluded$2 = ["children", "disabled", "error", "id", "isPlaceholder", "
|
|
1679
|
+
const _excluded$2 = ["children", "disabled", "error", "id", "isPlaceholder", "open", "testId", "aria-required", "onBlur", "onOpenChanged"];
|
|
1686
1680
|
const StyledButton = addStyle("button");
|
|
1687
1681
|
class SelectOpener extends React.Component {
|
|
1688
1682
|
constructor(props) {
|
|
@@ -1723,16 +1717,15 @@ class SelectOpener extends React.Component {
|
|
|
1723
1717
|
error,
|
|
1724
1718
|
id,
|
|
1725
1719
|
isPlaceholder,
|
|
1726
|
-
light,
|
|
1727
1720
|
open,
|
|
1728
1721
|
testId,
|
|
1729
1722
|
"aria-required": ariaRequired,
|
|
1730
1723
|
onBlur
|
|
1731
1724
|
} = _this$props,
|
|
1732
1725
|
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$2);
|
|
1733
|
-
const stateStyles = _generateStyles(
|
|
1734
|
-
const iconColor =
|
|
1735
|
-
const style = [styles$4.shared, stateStyles.default, disabled && stateStyles.disabled, !disabled && this.state.pressed && stateStyles.
|
|
1726
|
+
const stateStyles = _generateStyles(isPlaceholder, error);
|
|
1727
|
+
const iconColor = disabled ? semanticColor.action.disabled.default : semanticColor.icon.primary;
|
|
1728
|
+
const style = [styles$4.shared, stateStyles.default, disabled && stateStyles.disabled, !disabled && this.state.pressed && stateStyles.press];
|
|
1736
1729
|
return React.createElement(StyledButton, _extends({}, sharedProps, {
|
|
1737
1730
|
"aria-disabled": disabled,
|
|
1738
1731
|
"aria-expanded": open ? "true" : "false",
|
|
@@ -1761,7 +1754,6 @@ class SelectOpener extends React.Component {
|
|
|
1761
1754
|
SelectOpener.defaultProps = {
|
|
1762
1755
|
disabled: false,
|
|
1763
1756
|
error: false,
|
|
1764
|
-
light: false,
|
|
1765
1757
|
isPlaceholder: false
|
|
1766
1758
|
};
|
|
1767
1759
|
const styles$4 = StyleSheet.create({
|
|
@@ -1770,12 +1762,12 @@ const styles$4 = StyleSheet.create({
|
|
|
1770
1762
|
display: "inline-flex",
|
|
1771
1763
|
alignItems: "center",
|
|
1772
1764
|
justifyContent: "space-between",
|
|
1773
|
-
color:
|
|
1765
|
+
color: semanticColor.text.primary,
|
|
1774
1766
|
height: DROPDOWN_ITEM_HEIGHT,
|
|
1775
|
-
paddingLeft:
|
|
1776
|
-
paddingRight:
|
|
1767
|
+
paddingLeft: spacing.medium_16,
|
|
1768
|
+
paddingRight: spacing.small_12,
|
|
1777
1769
|
borderWidth: 0,
|
|
1778
|
-
borderRadius:
|
|
1770
|
+
borderRadius: border.radius.medium_4,
|
|
1779
1771
|
borderStyle: "solid",
|
|
1780
1772
|
outline: "none",
|
|
1781
1773
|
textDecoration: "none",
|
|
@@ -1784,7 +1776,7 @@ const styles$4 = StyleSheet.create({
|
|
|
1784
1776
|
touchAction: "manipulation"
|
|
1785
1777
|
},
|
|
1786
1778
|
text: {
|
|
1787
|
-
marginRight:
|
|
1779
|
+
marginRight: spacing.xSmall_8,
|
|
1788
1780
|
whiteSpace: "nowrap",
|
|
1789
1781
|
userSelect: "none",
|
|
1790
1782
|
overflow: "hidden",
|
|
@@ -1794,103 +1786,74 @@ const styles$4 = StyleSheet.create({
|
|
|
1794
1786
|
minWidth: 16
|
|
1795
1787
|
}
|
|
1796
1788
|
});
|
|
1797
|
-
const adjustedPaddingLeft = tokens.spacing.medium_16 - 1;
|
|
1798
|
-
const adjustedPaddingRight = tokens.spacing.small_12 - 1;
|
|
1799
1789
|
const stateStyles = {};
|
|
1800
|
-
const _generateStyles = (
|
|
1801
|
-
const styleKey = `${
|
|
1790
|
+
const _generateStyles = (placeholder, error) => {
|
|
1791
|
+
const styleKey = `${placeholder}-${error}`;
|
|
1802
1792
|
if (stateStyles[styleKey]) {
|
|
1803
1793
|
return stateStyles[styleKey];
|
|
1804
1794
|
}
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
const focusHoverStyling = {
|
|
1852
|
-
borderColor: error ? tokens.color.red : tokens.color.blue,
|
|
1853
|
-
borderWidth: tokens.border.width.thin,
|
|
1854
|
-
paddingLeft: adjustedPaddingLeft,
|
|
1855
|
-
paddingRight: adjustedPaddingRight
|
|
1856
|
-
};
|
|
1857
|
-
const activePressedStyling = {
|
|
1858
|
-
background: error ? tokens.color.fadedRed : tokens.color.fadedBlue,
|
|
1859
|
-
borderColor: error ? tokens.color.red : tokens.color.activeBlue,
|
|
1860
|
-
borderWidth: tokens.border.width.thin,
|
|
1861
|
-
paddingLeft: adjustedPaddingLeft,
|
|
1862
|
-
paddingRight: adjustedPaddingRight
|
|
1863
|
-
};
|
|
1864
|
-
newStyles = {
|
|
1865
|
-
default: {
|
|
1866
|
-
background: error ? tokens.color.fadedRed8 : tokens.color.white,
|
|
1867
|
-
borderColor: error ? tokens.color.red : tokens.color.offBlack50,
|
|
1868
|
-
borderWidth: tokens.border.width.hairline,
|
|
1869
|
-
color: placeholder ? tokens.color.offBlack64 : tokens.color.offBlack,
|
|
1870
|
-
":hover:not([aria-disabled=true])": focusHoverStyling,
|
|
1871
|
-
["@media not (hover: hover)"]: {
|
|
1872
|
-
":hover:not([aria-disabled=true])": {
|
|
1873
|
-
borderColor: error ? tokens.color.red : tokens.color.offBlack50,
|
|
1874
|
-
borderWidth: tokens.border.width.hairline,
|
|
1875
|
-
paddingLeft: tokens.spacing.medium_16,
|
|
1876
|
-
paddingRight: tokens.spacing.small_12
|
|
1877
|
-
}
|
|
1878
|
-
},
|
|
1879
|
-
":focus-visible:not([aria-disabled=true])": focusHoverStyling,
|
|
1880
|
-
":active:not([aria-disabled=true])": activePressedStyling
|
|
1881
|
-
},
|
|
1882
|
-
disabled: {
|
|
1883
|
-
background: tokens.color.offWhite,
|
|
1884
|
-
borderColor: tokens.color.offBlack16,
|
|
1885
|
-
color: tokens.color.offBlack64,
|
|
1886
|
-
cursor: "not-allowed",
|
|
1887
|
-
":focus-visible": {
|
|
1888
|
-
boxShadow: `0 0 0 1px ${tokens.color.white}, 0 0 0 3px ${tokens.color.offBlack32}`
|
|
1795
|
+
const states = {
|
|
1796
|
+
default: {
|
|
1797
|
+
border: semanticColor.border.strong,
|
|
1798
|
+
background: semanticColor.surface.primary,
|
|
1799
|
+
foreground: semanticColor.text.primary
|
|
1800
|
+
},
|
|
1801
|
+
disabled: {
|
|
1802
|
+
border: semanticColor.border.primary,
|
|
1803
|
+
background: semanticColor.action.disabled.secondary,
|
|
1804
|
+
foreground: semanticColor.text.secondary
|
|
1805
|
+
},
|
|
1806
|
+
error: {
|
|
1807
|
+
border: semanticColor.status.critical.foreground,
|
|
1808
|
+
background: semanticColor.status.critical.background,
|
|
1809
|
+
foreground: semanticColor.text.primary
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
const actionType = error ? "destructive" : "progressive";
|
|
1813
|
+
const action = semanticColor.action.outlined[actionType];
|
|
1814
|
+
const sharedOutlineStyling = {
|
|
1815
|
+
outlineOffset: -border.width.thin,
|
|
1816
|
+
outlineStyle: "solid",
|
|
1817
|
+
outlineWidth: border.width.thin
|
|
1818
|
+
};
|
|
1819
|
+
const focusHoverStyling = _extends({
|
|
1820
|
+
outlineColor: action.hover.border
|
|
1821
|
+
}, sharedOutlineStyling);
|
|
1822
|
+
const pressStyling = _extends({
|
|
1823
|
+
background: action.press.background,
|
|
1824
|
+
color: placeholder ? error ? semanticColor.text.secondary : semanticColor.action.outlined.progressive.press.foreground : semanticColor.text.primary,
|
|
1825
|
+
outlineColor: action.press.border
|
|
1826
|
+
}, sharedOutlineStyling);
|
|
1827
|
+
const currentState = error ? states.error : states.default;
|
|
1828
|
+
const newStyles = {
|
|
1829
|
+
default: {
|
|
1830
|
+
background: currentState.background,
|
|
1831
|
+
borderColor: currentState.border,
|
|
1832
|
+
borderWidth: border.width.hairline,
|
|
1833
|
+
color: placeholder ? semanticColor.text.secondary : currentState.foreground,
|
|
1834
|
+
":hover:not([aria-disabled=true])": focusHoverStyling,
|
|
1835
|
+
["@media not (hover: hover)"]: {
|
|
1836
|
+
":hover:not([aria-disabled=true])": {
|
|
1837
|
+
borderColor: currentState.border,
|
|
1838
|
+
borderWidth: border.width.hairline,
|
|
1839
|
+
paddingLeft: spacing.medium_16,
|
|
1840
|
+
paddingRight: spacing.small_12
|
|
1889
1841
|
}
|
|
1890
1842
|
},
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1843
|
+
":focus-visible:not([aria-disabled=true])": focusHoverStyling,
|
|
1844
|
+
":active:not([aria-disabled=true])": pressStyling
|
|
1845
|
+
},
|
|
1846
|
+
disabled: {
|
|
1847
|
+
background: states.disabled.background,
|
|
1848
|
+
borderColor: states.disabled.border,
|
|
1849
|
+
color: states.disabled.foreground,
|
|
1850
|
+
cursor: "not-allowed",
|
|
1851
|
+
":focus-visible": _extends({
|
|
1852
|
+
outlineColor: semanticColor.action.disabled.default
|
|
1853
|
+
}, sharedOutlineStyling)
|
|
1854
|
+
},
|
|
1855
|
+
press: pressStyling
|
|
1856
|
+
};
|
|
1894
1857
|
stateStyles[styleKey] = StyleSheet.create(newStyles);
|
|
1895
1858
|
return stateStyles[styleKey];
|
|
1896
1859
|
};
|
|
@@ -1964,7 +1927,7 @@ function useSelectValidation({
|
|
|
1964
1927
|
};
|
|
1965
1928
|
}
|
|
1966
1929
|
|
|
1967
|
-
const _excluded$1 = ["children", "error", "id", "opener", "
|
|
1930
|
+
const _excluded$1 = ["children", "error", "id", "opener", "placeholder", "selectedValue", "testId", "alignment", "autoFocus", "dropdownStyle", "enableTypeAhead", "isFilterable", "labels", "onChange", "onToggle", "opened", "style", "className", "aria-invalid", "aria-required", "disabled", "dropdownId", "validate", "onValidate", "required", "showOpenerLabelAsText"];
|
|
1968
1931
|
const SingleSelect = props => {
|
|
1969
1932
|
const selectedIndex = React.useRef(0);
|
|
1970
1933
|
const {
|
|
@@ -1972,7 +1935,6 @@ const SingleSelect = props => {
|
|
|
1972
1935
|
error = false,
|
|
1973
1936
|
id,
|
|
1974
1937
|
opener,
|
|
1975
|
-
light = false,
|
|
1976
1938
|
placeholder,
|
|
1977
1939
|
selectedValue,
|
|
1978
1940
|
testId,
|
|
@@ -2118,7 +2080,6 @@ const SingleSelect = props => {
|
|
|
2118
2080
|
id: uniqueOpenerId,
|
|
2119
2081
|
error: hasError,
|
|
2120
2082
|
isPlaceholder: !selectedItem,
|
|
2121
|
-
light: light,
|
|
2122
2083
|
onOpenChanged: handleOpenChanged,
|
|
2123
2084
|
open: open,
|
|
2124
2085
|
ref: handleOpenerRef,
|
|
@@ -2144,7 +2105,6 @@ const SingleSelect = props => {
|
|
|
2144
2105
|
dropdownStyle: [isFilterable && filterableDropdownStyle, selectDropdownStyle, dropdownStyle],
|
|
2145
2106
|
initialFocusedIndex: selectedIndex.current,
|
|
2146
2107
|
items: items,
|
|
2147
|
-
light: light,
|
|
2148
2108
|
onOpenChanged: handleOpenChanged,
|
|
2149
2109
|
open: open,
|
|
2150
2110
|
opener: renderOpener(isDisabled, uniqueDropdownId),
|
|
@@ -2161,11 +2121,10 @@ const SingleSelect = props => {
|
|
|
2161
2121
|
}));
|
|
2162
2122
|
};
|
|
2163
2123
|
|
|
2164
|
-
const _excluded = ["id", "
|
|
2124
|
+
const _excluded = ["id", "opener", "testId", "alignment", "dropdownStyle", "implicitAllEnabled", "isFilterable", "labels", "onChange", "onToggle", "opened", "selectedValues", "shortcuts", "style", "className", "aria-invalid", "aria-required", "disabled", "error", "children", "dropdownId", "showOpenerLabelAsText", "validate", "onValidate", "required"];
|
|
2165
2125
|
const MultiSelect = props => {
|
|
2166
2126
|
const {
|
|
2167
2127
|
id,
|
|
2168
|
-
light = false,
|
|
2169
2128
|
opener,
|
|
2170
2129
|
testId,
|
|
2171
2130
|
alignment = "left",
|
|
@@ -2248,9 +2207,11 @@ const MultiSelect = props => {
|
|
|
2248
2207
|
const allChildren = React.Children.toArray(children);
|
|
2249
2208
|
const selected = allChildren.filter(option => !!option && !option.props.disabled).map(option => option.props.value);
|
|
2250
2209
|
onChange(selected);
|
|
2210
|
+
onSelectedValuesChangeValidation();
|
|
2251
2211
|
};
|
|
2252
2212
|
const handleSelectNone = () => {
|
|
2253
2213
|
onChange([]);
|
|
2214
|
+
onSelectedValuesChangeValidation();
|
|
2254
2215
|
};
|
|
2255
2216
|
const getMenuText = children => {
|
|
2256
2217
|
const {
|
|
@@ -2399,7 +2360,6 @@ const MultiSelect = props => {
|
|
|
2399
2360
|
id: uniqueOpenerId,
|
|
2400
2361
|
"aria-controls": dropdownId,
|
|
2401
2362
|
isPlaceholder: menuText === noneSelected,
|
|
2402
|
-
light: light,
|
|
2403
2363
|
onOpenChanged: handleOpenChanged,
|
|
2404
2364
|
onBlur: onOpenerBlurValidation,
|
|
2405
2365
|
open: open,
|
|
@@ -2428,7 +2388,6 @@ const MultiSelect = props => {
|
|
|
2428
2388
|
dropdownStyle: [isFilterable && filterableDropdownStyle, selectDropdownStyle, dropdownStyle],
|
|
2429
2389
|
isFilterable: isFilterable,
|
|
2430
2390
|
items: [...getShortcuts(numEnabledOptions), ...filteredItems],
|
|
2431
|
-
light: light,
|
|
2432
2391
|
onOpenChanged: handleOpenChanged,
|
|
2433
2392
|
open: open,
|
|
2434
2393
|
opener: renderOpener(allChildren, isDisabled, uniqueDropdownId),
|
|
@@ -47,32 +47,32 @@ export declare function useListbox({ children: options, disabled, disableSpaceSe
|
|
|
47
47
|
focusedIndex: number;
|
|
48
48
|
setFocusedIndex: React.Dispatch<React.SetStateAction<number>>;
|
|
49
49
|
renderList: React.ReactElement<Pick<Readonly<import("@khanacademy/wonder-blocks-core").AriaAttributes> & Readonly<{
|
|
50
|
-
role?: import("@khanacademy/wonder-blocks-core").AriaRole
|
|
50
|
+
role?: import("@khanacademy/wonder-blocks-core").AriaRole;
|
|
51
51
|
}> & {
|
|
52
52
|
label: import("../util/types").OptionLabel;
|
|
53
|
-
labelAsText?: string
|
|
53
|
+
labelAsText?: string;
|
|
54
54
|
value: string;
|
|
55
55
|
disabled: boolean;
|
|
56
|
-
onClick?: (
|
|
56
|
+
onClick?: () => unknown;
|
|
57
57
|
onToggle: (value: string) => unknown;
|
|
58
58
|
selected: boolean;
|
|
59
59
|
focused: boolean;
|
|
60
|
-
role: "menuitem" | "
|
|
61
|
-
testId?: string
|
|
62
|
-
variant?: "
|
|
60
|
+
role: "menuitem" | "option" | "menuitemcheckbox";
|
|
61
|
+
testId?: string;
|
|
62
|
+
variant?: "check" | "checkbox";
|
|
63
63
|
style?: import("@khanacademy/wonder-blocks-core").StyleType;
|
|
64
|
-
parentComponent?: "
|
|
65
|
-
id?: string
|
|
66
|
-
horizontalRule: import("
|
|
67
|
-
leftAccessory?:
|
|
68
|
-
rightAccessory?:
|
|
69
|
-
subtitle1?: import("
|
|
70
|
-
subtitle2?: import("
|
|
64
|
+
parentComponent?: "dropdown" | "listbox";
|
|
65
|
+
id?: string;
|
|
66
|
+
horizontalRule: import("../util/types").CellProps["horizontalRule"];
|
|
67
|
+
leftAccessory?: import("../util/types").CellProps["leftAccessory"];
|
|
68
|
+
rightAccessory?: import("../util/types").CellProps["rightAccessory"];
|
|
69
|
+
subtitle1?: import("../util/types").CellProps["subtitle1"];
|
|
70
|
+
subtitle2?: import("../util/types").CellProps["subtitle2"];
|
|
71
71
|
}, keyof import("@khanacademy/wonder-blocks-core").AriaAttributes | "style" | "label" | "leftAccessory" | "rightAccessory" | "testId" | "onClick" | "subtitle1" | "subtitle2" | "value" | "id" | "labelAsText" | "variant" | "parentComponent"> & {
|
|
72
72
|
selected?: boolean | undefined;
|
|
73
73
|
role?: "menuitem" | "menuitemcheckbox" | "option" | undefined;
|
|
74
74
|
disabled?: boolean | undefined;
|
|
75
|
-
horizontalRule?: import("
|
|
75
|
+
horizontalRule?: import("../util/types").CellProps["horizontalRule"];
|
|
76
76
|
focused?: boolean | undefined;
|
|
77
77
|
onToggle?: ((value: string) => unknown) | undefined;
|
|
78
78
|
} & {}, string | React.JSXElementConstructor<any>>[];
|