@khanacademy/wonder-blocks-dropdown 9.0.0 → 9.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
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.
package/dist/es/index.js CHANGED
@@ -96,10 +96,10 @@ class ActionItem extends React.Component {
96
96
  const labelComponent = typeof label === "string" ? React.createElement(LabelMedium, {
97
97
  lang: lang,
98
98
  style: styles$c.label
99
- }, label) : React.cloneElement(label, _extends({
99
+ }, label) : (React.cloneElement(label, _extends({
100
100
  lang,
101
101
  style: styles$c.label
102
- }, label.props));
102
+ }, label.props)));
103
103
  return React.createElement(CompactCell, {
104
104
  disabled: disabled,
105
105
  horizontalRule: horizontalRule,
@@ -232,7 +232,7 @@ const styles$a = StyleSheet.create({
232
232
  });
233
233
 
234
234
  const _excluded$5 = ["disabled", "label", "selected", "testId", "leftAccessory", "horizontalRule", "parentComponent", "rightAccessory", "style", "subtitle1", "subtitle2", "value", "onClick", "onToggle", "variant", "role"];
235
- const StyledListItem = addStyle("li");
235
+ const StyledLi = addStyle("li");
236
236
  class OptionItem extends React.Component {
237
237
  constructor(...args) {
238
238
  super(...args);
@@ -320,7 +320,7 @@ class OptionItem extends React.Component {
320
320
  selected
321
321
  } = this.props;
322
322
  if (parentComponent === "listbox") {
323
- return React.createElement(StyledListItem, {
323
+ return React.createElement(StyledLi, {
324
324
  onMouseDown: e => {
325
325
  e.preventDefault();
326
326
  },
@@ -455,10 +455,11 @@ class SeparatorItem extends React.Component {
455
455
  return instance && instance.type && instance.type.__IS_SEPARATOR_ITEM__;
456
456
  }
457
457
  render() {
458
- return React.createElement(View, {
459
- style: [styles$8.separator, this.props.style],
460
- "aria-hidden": "true"
461
- });
458
+ return (React.createElement(View, {
459
+ style: [styles$8.separator, this.props.style],
460
+ "aria-hidden": "true"
461
+ })
462
+ );
462
463
  }
463
464
  }
464
465
  SeparatorItem.__IS_SEPARATOR_ITEM__ = true;
@@ -1736,6 +1737,7 @@ class SelectOpener extends React.Component {
1736
1737
  "data-testid": testId,
1737
1738
  id: id,
1738
1739
  role: "combobox",
1740
+ type: "button",
1739
1741
  style: style,
1740
1742
  onClick: !disabled ? this.handleClick : undefined,
1741
1743
  onKeyDown: !disabled ? this.handleKeyDown : undefined,
@@ -2654,7 +2656,7 @@ function ComboboxLiveRegion({
2654
2656
  if (selected && selected !== (lastSelectedValue == null ? void 0 : lastSelectedValue.current)) {
2655
2657
  var _lastSelectedValue$cu, _lastSelectedValue$cu2, _selected$length;
2656
2658
  let newMessage = "";
2657
- const lastSelectedLength = (_lastSelectedValue$cu = lastSelectedValue == null ? void 0 : (_lastSelectedValue$cu2 = lastSelectedValue.current) == null ? void 0 : _lastSelectedValue$cu2.length) != null ? _lastSelectedValue$cu : 0;
2659
+ const lastSelectedLength = (_lastSelectedValue$cu = lastSelectedValue == null || (_lastSelectedValue$cu2 = lastSelectedValue.current) == null ? void 0 : _lastSelectedValue$cu2.length) != null ? _lastSelectedValue$cu : 0;
2658
2660
  const selectedLength = (_selected$length = selected == null ? void 0 : selected.length) != null ? _selected$length : 0;
2659
2661
  if (Array.isArray(selected) && selected.length > 0) {
2660
2662
  const currentLabels = selectedLabels.join(", ");
@@ -2809,7 +2811,7 @@ function StandaloneListbox(props) {
2809
2811
  });
2810
2812
  React.useEffect(() => {
2811
2813
  if (selected && selected !== value) {
2812
- onChange == null ? void 0 : onChange(selected);
2814
+ onChange == null || onChange(selected);
2813
2815
  }
2814
2816
  }, [onChange, selected, value]);
2815
2817
  return React.createElement(View, {
@@ -2881,7 +2883,7 @@ function Combobox({
2881
2883
  testId,
2882
2884
  value = ""
2883
2885
  }) {
2884
- var _renderList$find, _renderList$focusedIn, _renderList$focusedIn2;
2886
+ var _renderList$find, _renderList$focusedIn;
2885
2887
  const generatedUniqueId = useId();
2886
2888
  const uniqueId = id != null ? id : generatedUniqueId;
2887
2889
  const comboboxRef = React.useRef(null);
@@ -2940,12 +2942,12 @@ function Combobox({
2940
2942
  }
2941
2943
  setCurrentOptions(children);
2942
2944
  }
2943
- onToggle == null ? void 0 : onToggle(newState);
2945
+ onToggle == null || onToggle(newState);
2944
2946
  }, [children, disabled, isControlled, labelFromSelected, onToggle, openState, selectionType, setFocusedIndex]);
2945
2947
  const handleChange = React.useCallback(value => {
2946
2948
  if (value !== valueState) {
2947
2949
  setSelectedValue(value);
2948
- onChange == null ? void 0 : onChange(value);
2950
+ onChange == null || onChange(value);
2949
2951
  }
2950
2952
  if (selectionType === "single" && typeof value === "string") {
2951
2953
  var _renderList$find2;
@@ -3003,13 +3005,13 @@ function Combobox({
3003
3005
  e.stopPropagation();
3004
3006
  setInputValue("");
3005
3007
  setSelected("");
3006
- onChange == null ? void 0 : onChange("");
3007
- (_comboboxRef$current = comboboxRef.current) == null ? void 0 : _comboboxRef$current.focus();
3008
+ onChange == null || onChange("");
3009
+ (_comboboxRef$current = comboboxRef.current) == null || _comboboxRef$current.focus();
3008
3010
  }, [onChange, setSelected]);
3009
3011
  React.useEffect(() => {
3010
3012
  if (openState) {
3011
3013
  var _comboboxRef$current2;
3012
- (_comboboxRef$current2 = comboboxRef.current) == null ? void 0 : _comboboxRef$current2.focus();
3014
+ (_comboboxRef$current2 = comboboxRef.current) == null || _comboboxRef$current2.focus();
3013
3015
  }
3014
3016
  }, [openState]);
3015
3017
  const selectedLabels = React.useMemo(() => {
@@ -3037,7 +3039,7 @@ function Combobox({
3037
3039
  };
3038
3040
  const pillIdPrefix = `${uniqueId}-pill-`;
3039
3041
  const textFieldId = useId();
3040
- const currentActiveDescendant = !openState ? undefined : focusedIndex >= 0 ? (_renderList$focusedIn = renderList[focusedIndex]) == null ? void 0 : (_renderList$focusedIn2 = _renderList$focusedIn.props) == null ? void 0 : _renderList$focusedIn2.id : pillIdPrefix + focusedMultiSelectIndex;
3042
+ const currentActiveDescendant = !openState ? undefined : focusedIndex >= 0 ? (_renderList$focusedIn = renderList[focusedIndex]) == null || (_renderList$focusedIn = _renderList$focusedIn.props) == null ? void 0 : _renderList$focusedIn.id : pillIdPrefix + focusedMultiSelectIndex;
3041
3043
  const controlledWidget = !openState ? undefined : focusedIndex >= 0 ? uniqueId : pillIdPrefix;
3042
3044
  return React.createElement(React.Fragment, null, React.createElement(View, {
3043
3045
  onClick: () => {
@@ -3122,7 +3124,7 @@ function Combobox({
3122
3124
  return React.createElement(React.Fragment, null, renderList.length === 0 ? React.createElement(DetailCell, {
3123
3125
  title: labels.noItems,
3124
3126
  style: [styles.listbox, {
3125
- minWidth: rootNodeRef == null ? void 0 : (_rootNodeRef$current = rootNodeRef.current) == null ? void 0 : _rootNodeRef$current.offsetWidth
3127
+ minWidth: rootNodeRef == null || (_rootNodeRef$current = rootNodeRef.current) == null ? void 0 : _rootNodeRef$current.offsetWidth
3126
3128
  }],
3127
3129
  horizontalRule: "none"
3128
3130
  }) : React.createElement(Listbox, {
@@ -3130,7 +3132,7 @@ function Combobox({
3130
3132
  tabIndex: -1,
3131
3133
  selectionType: selectionType,
3132
3134
  style: [styles.listbox, isReferenceHidden && styles.hidden, {
3133
- minWidth: rootNodeRef == null ? void 0 : (_rootNodeRef$current2 = rootNodeRef.current) == null ? void 0 : _rootNodeRef$current2.offsetWidth
3135
+ minWidth: rootNodeRef == null || (_rootNodeRef$current2 = rootNodeRef.current) == null ? void 0 : _rootNodeRef$current2.offsetWidth
3134
3136
  }],
3135
3137
  testId: testId ? `${testId}-listbox` : undefined,
3136
3138
  "aria-label": labels.listbox,
package/dist/index.js CHANGED
@@ -131,10 +131,10 @@ class ActionItem extends React__namespace.Component {
131
131
  const labelComponent = typeof label === "string" ? React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
132
132
  lang: lang,
133
133
  style: styles$c.label
134
- }, label) : React__namespace.cloneElement(label, _extends__default["default"]({
134
+ }, label) : (React__namespace.cloneElement(label, _extends__default["default"]({
135
135
  lang,
136
136
  style: styles$c.label
137
- }, label.props));
137
+ }, label.props)));
138
138
  return React__namespace.createElement(wonderBlocksCell.CompactCell, {
139
139
  disabled: disabled,
140
140
  horizontalRule: horizontalRule,
@@ -267,7 +267,7 @@ const styles$a = aphrodite.StyleSheet.create({
267
267
  });
268
268
 
269
269
  const _excluded$5 = ["disabled", "label", "selected", "testId", "leftAccessory", "horizontalRule", "parentComponent", "rightAccessory", "style", "subtitle1", "subtitle2", "value", "onClick", "onToggle", "variant", "role"];
270
- const StyledListItem = wonderBlocksCore.addStyle("li");
270
+ const StyledLi = wonderBlocksCore.addStyle("li");
271
271
  class OptionItem extends React__namespace.Component {
272
272
  constructor(...args) {
273
273
  super(...args);
@@ -355,7 +355,7 @@ class OptionItem extends React__namespace.Component {
355
355
  selected
356
356
  } = this.props;
357
357
  if (parentComponent === "listbox") {
358
- return React__namespace.createElement(StyledListItem, {
358
+ return React__namespace.createElement(StyledLi, {
359
359
  onMouseDown: e => {
360
360
  e.preventDefault();
361
361
  },
@@ -490,10 +490,11 @@ class SeparatorItem extends React__namespace.Component {
490
490
  return instance && instance.type && instance.type.__IS_SEPARATOR_ITEM__;
491
491
  }
492
492
  render() {
493
- return React__namespace.createElement(wonderBlocksCore.View, {
494
- style: [styles$8.separator, this.props.style],
495
- "aria-hidden": "true"
496
- });
493
+ return (React__namespace.createElement(wonderBlocksCore.View, {
494
+ style: [styles$8.separator, this.props.style],
495
+ "aria-hidden": "true"
496
+ })
497
+ );
497
498
  }
498
499
  }
499
500
  SeparatorItem.__IS_SEPARATOR_ITEM__ = true;
@@ -1771,6 +1772,7 @@ class SelectOpener extends React__namespace.Component {
1771
1772
  "data-testid": testId,
1772
1773
  id: id,
1773
1774
  role: "combobox",
1775
+ type: "button",
1774
1776
  style: style,
1775
1777
  onClick: !disabled ? this.handleClick : undefined,
1776
1778
  onKeyDown: !disabled ? this.handleKeyDown : undefined,
@@ -2689,7 +2691,7 @@ function ComboboxLiveRegion({
2689
2691
  if (selected && selected !== (lastSelectedValue == null ? void 0 : lastSelectedValue.current)) {
2690
2692
  var _lastSelectedValue$cu, _lastSelectedValue$cu2, _selected$length;
2691
2693
  let newMessage = "";
2692
- const lastSelectedLength = (_lastSelectedValue$cu = lastSelectedValue == null ? void 0 : (_lastSelectedValue$cu2 = lastSelectedValue.current) == null ? void 0 : _lastSelectedValue$cu2.length) != null ? _lastSelectedValue$cu : 0;
2694
+ const lastSelectedLength = (_lastSelectedValue$cu = lastSelectedValue == null || (_lastSelectedValue$cu2 = lastSelectedValue.current) == null ? void 0 : _lastSelectedValue$cu2.length) != null ? _lastSelectedValue$cu : 0;
2693
2695
  const selectedLength = (_selected$length = selected == null ? void 0 : selected.length) != null ? _selected$length : 0;
2694
2696
  if (Array.isArray(selected) && selected.length > 0) {
2695
2697
  const currentLabels = selectedLabels.join(", ");
@@ -2844,7 +2846,7 @@ function StandaloneListbox(props) {
2844
2846
  });
2845
2847
  React__namespace.useEffect(() => {
2846
2848
  if (selected && selected !== value) {
2847
- onChange == null ? void 0 : onChange(selected);
2849
+ onChange == null || onChange(selected);
2848
2850
  }
2849
2851
  }, [onChange, selected, value]);
2850
2852
  return React__namespace.createElement(wonderBlocksCore.View, {
@@ -2916,7 +2918,7 @@ function Combobox({
2916
2918
  testId,
2917
2919
  value = ""
2918
2920
  }) {
2919
- var _renderList$find, _renderList$focusedIn, _renderList$focusedIn2;
2921
+ var _renderList$find, _renderList$focusedIn;
2920
2922
  const generatedUniqueId = React.useId();
2921
2923
  const uniqueId = id != null ? id : generatedUniqueId;
2922
2924
  const comboboxRef = React__namespace.useRef(null);
@@ -2975,12 +2977,12 @@ function Combobox({
2975
2977
  }
2976
2978
  setCurrentOptions(children);
2977
2979
  }
2978
- onToggle == null ? void 0 : onToggle(newState);
2980
+ onToggle == null || onToggle(newState);
2979
2981
  }, [children, disabled, isControlled, labelFromSelected, onToggle, openState, selectionType, setFocusedIndex]);
2980
2982
  const handleChange = React__namespace.useCallback(value => {
2981
2983
  if (value !== valueState) {
2982
2984
  setSelectedValue(value);
2983
- onChange == null ? void 0 : onChange(value);
2985
+ onChange == null || onChange(value);
2984
2986
  }
2985
2987
  if (selectionType === "single" && typeof value === "string") {
2986
2988
  var _renderList$find2;
@@ -3038,13 +3040,13 @@ function Combobox({
3038
3040
  e.stopPropagation();
3039
3041
  setInputValue("");
3040
3042
  setSelected("");
3041
- onChange == null ? void 0 : onChange("");
3042
- (_comboboxRef$current = comboboxRef.current) == null ? void 0 : _comboboxRef$current.focus();
3043
+ onChange == null || onChange("");
3044
+ (_comboboxRef$current = comboboxRef.current) == null || _comboboxRef$current.focus();
3043
3045
  }, [onChange, setSelected]);
3044
3046
  React__namespace.useEffect(() => {
3045
3047
  if (openState) {
3046
3048
  var _comboboxRef$current2;
3047
- (_comboboxRef$current2 = comboboxRef.current) == null ? void 0 : _comboboxRef$current2.focus();
3049
+ (_comboboxRef$current2 = comboboxRef.current) == null || _comboboxRef$current2.focus();
3048
3050
  }
3049
3051
  }, [openState]);
3050
3052
  const selectedLabels = React__namespace.useMemo(() => {
@@ -3072,7 +3074,7 @@ function Combobox({
3072
3074
  };
3073
3075
  const pillIdPrefix = `${uniqueId}-pill-`;
3074
3076
  const textFieldId = React.useId();
3075
- const currentActiveDescendant = !openState ? undefined : focusedIndex >= 0 ? (_renderList$focusedIn = renderList[focusedIndex]) == null ? void 0 : (_renderList$focusedIn2 = _renderList$focusedIn.props) == null ? void 0 : _renderList$focusedIn2.id : pillIdPrefix + focusedMultiSelectIndex;
3077
+ const currentActiveDescendant = !openState ? undefined : focusedIndex >= 0 ? (_renderList$focusedIn = renderList[focusedIndex]) == null || (_renderList$focusedIn = _renderList$focusedIn.props) == null ? void 0 : _renderList$focusedIn.id : pillIdPrefix + focusedMultiSelectIndex;
3076
3078
  const controlledWidget = !openState ? undefined : focusedIndex >= 0 ? uniqueId : pillIdPrefix;
3077
3079
  return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksCore.View, {
3078
3080
  onClick: () => {
@@ -3157,7 +3159,7 @@ function Combobox({
3157
3159
  return React__namespace.createElement(React__namespace.Fragment, null, renderList.length === 0 ? React__namespace.createElement(wonderBlocksCell.DetailCell, {
3158
3160
  title: labels.noItems,
3159
3161
  style: [styles.listbox, {
3160
- minWidth: rootNodeRef == null ? void 0 : (_rootNodeRef$current = rootNodeRef.current) == null ? void 0 : _rootNodeRef$current.offsetWidth
3162
+ minWidth: rootNodeRef == null || (_rootNodeRef$current = rootNodeRef.current) == null ? void 0 : _rootNodeRef$current.offsetWidth
3161
3163
  }],
3162
3164
  horizontalRule: "none"
3163
3165
  }) : React__namespace.createElement(Listbox, {
@@ -3165,7 +3167,7 @@ function Combobox({
3165
3167
  tabIndex: -1,
3166
3168
  selectionType: selectionType,
3167
3169
  style: [styles.listbox, isReferenceHidden && styles.hidden, {
3168
- minWidth: rootNodeRef == null ? void 0 : (_rootNodeRef$current2 = rootNodeRef.current) == null ? void 0 : _rootNodeRef$current2.offsetWidth
3170
+ minWidth: rootNodeRef == null || (_rootNodeRef$current2 = rootNodeRef.current) == null ? void 0 : _rootNodeRef$current2.offsetWidth
3169
3171
  }],
3170
3172
  testId: testId ? `${testId}-listbox` : undefined,
3171
3173
  "aria-label": labels.listbox,
package/package.json CHANGED
@@ -1,33 +1,29 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-dropdown",
3
- "version": "9.0.0",
3
+ "version": "9.1.1",
4
4
  "design": "v1",
5
5
  "description": "Dropdown variants for Wonder Blocks.",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/es/index.js",
8
8
  "types": "dist/index.d.ts",
9
- "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1",
11
- "prepublishOnly": "../../utils/publish/package-pre-publish-check.sh"
12
- },
13
9
  "author": "",
14
10
  "license": "MIT",
15
11
  "publishConfig": {
16
12
  "access": "public"
17
13
  },
18
14
  "dependencies": {
19
- "@babel/runtime": "^7.18.6",
20
- "@khanacademy/wonder-blocks-cell": "^4.0.8",
21
- "@khanacademy/wonder-blocks-clickable": "^6.0.0",
22
- "@khanacademy/wonder-blocks-core": "^12.0.0",
23
- "@khanacademy/wonder-blocks-icon": "^5.0.6",
24
- "@khanacademy/wonder-blocks-layout": "^3.0.8",
25
- "@khanacademy/wonder-blocks-modal": "^7.0.7",
26
- "@khanacademy/wonder-blocks-pill": "^3.0.8",
27
- "@khanacademy/wonder-blocks-search-field": "^5.0.3",
28
- "@khanacademy/wonder-blocks-timing": "^6.0.1",
29
- "@khanacademy/wonder-blocks-tokens": "^4.1.0",
30
- "@khanacademy/wonder-blocks-typography": "^3.0.6"
15
+ "@babel/runtime": "^7.24.5",
16
+ "@khanacademy/wonder-blocks-cell": "4.1.1",
17
+ "@khanacademy/wonder-blocks-clickable": "6.1.1",
18
+ "@khanacademy/wonder-blocks-core": "12.1.1",
19
+ "@khanacademy/wonder-blocks-icon": "5.1.1",
20
+ "@khanacademy/wonder-blocks-layout": "3.1.1",
21
+ "@khanacademy/wonder-blocks-modal": "7.1.1",
22
+ "@khanacademy/wonder-blocks-pill": "3.1.1",
23
+ "@khanacademy/wonder-blocks-search-field": "5.1.1",
24
+ "@khanacademy/wonder-blocks-timing": "7.0.1",
25
+ "@khanacademy/wonder-blocks-tokens": "4.2.1",
26
+ "@khanacademy/wonder-blocks-typography": "3.1.1"
31
27
  },
32
28
  "peerDependencies": {
33
29
  "@phosphor-icons/core": "^2.0.2",
@@ -38,10 +34,12 @@
38
34
  "react-popper": "^2.0.0",
39
35
  "react-router": "5.3.4",
40
36
  "react-router-dom": "5.3.4",
41
- "react-window": "^1.8.10"
37
+ "react-window": "^1.8.11"
42
38
  },
43
39
  "devDependencies": {
44
- "@khanacademy/wonder-blocks-button": "^7.0.8",
45
- "@khanacademy/wb-dev-build-settings": "^2.0.0"
40
+ "@khanacademy/wb-dev-build-settings": "2.1.1"
41
+ },
42
+ "scripts": {
43
+ "test": "echo \"Error: no test specified\" && exit 1"
46
44
  }
47
45
  }