@khanacademy/wonder-blocks-dropdown 8.0.2 → 9.1.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/dist/es/index.js CHANGED
@@ -6,7 +6,7 @@ import { CompactCell, DetailCell } from '@khanacademy/wonder-blocks-cell';
6
6
  import { spacing, color, mix, fade, semanticColor, border, font } from '@khanacademy/wonder-blocks-tokens';
7
7
  import { LabelMedium, LabelSmall, LabelLarge } from '@khanacademy/wonder-blocks-typography';
8
8
  import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutPropertiesLoose';
9
- import { View, addStyle, Id, useOnMountEffect } from '@khanacademy/wonder-blocks-core';
9
+ import { View, addStyle, keys, Id, useOnMountEffect } from '@khanacademy/wonder-blocks-core';
10
10
  import { Strut } from '@khanacademy/wonder-blocks-layout';
11
11
  import { PhosphorIcon } from '@khanacademy/wonder-blocks-icon';
12
12
  import checkIcon from '@phosphor-icons/core/bold/check-bold.svg';
@@ -25,13 +25,6 @@ import { TextField } from '@khanacademy/wonder-blocks-form';
25
25
  import IconButton from '@khanacademy/wonder-blocks-icon-button';
26
26
  import Pill from '@khanacademy/wonder-blocks-pill';
27
27
 
28
- const keys = {
29
- escape: "Escape",
30
- tab: "Tab",
31
- space: " ",
32
- up: "ArrowUp",
33
- down: "ArrowDown"
34
- };
35
28
  const selectDropdownStyle = {
36
29
  marginTop: spacing.xSmall_8,
37
30
  marginBottom: spacing.xSmall_8
@@ -103,10 +96,10 @@ class ActionItem extends React.Component {
103
96
  const labelComponent = typeof label === "string" ? React.createElement(LabelMedium, {
104
97
  lang: lang,
105
98
  style: styles$c.label
106
- }, label) : React.cloneElement(label, _extends({
99
+ }, label) : (React.cloneElement(label, _extends({
107
100
  lang,
108
101
  style: styles$c.label
109
- }, label.props));
102
+ }, label.props)));
110
103
  return React.createElement(CompactCell, {
111
104
  disabled: disabled,
112
105
  horizontalRule: horizontalRule,
@@ -239,7 +232,7 @@ const styles$a = StyleSheet.create({
239
232
  });
240
233
 
241
234
  const _excluded$5 = ["disabled", "label", "selected", "testId", "leftAccessory", "horizontalRule", "parentComponent", "rightAccessory", "style", "subtitle1", "subtitle2", "value", "onClick", "onToggle", "variant", "role"];
242
- const StyledListItem = addStyle("li");
235
+ const StyledLi = addStyle("li");
243
236
  class OptionItem extends React.Component {
244
237
  constructor(...args) {
245
238
  super(...args);
@@ -327,7 +320,7 @@ class OptionItem extends React.Component {
327
320
  selected
328
321
  } = this.props;
329
322
  if (parentComponent === "listbox") {
330
- return React.createElement(StyledListItem, {
323
+ return React.createElement(StyledLi, {
331
324
  onMouseDown: e => {
332
325
  e.preventDefault();
333
326
  },
@@ -347,7 +340,7 @@ OptionItem.defaultProps = {
347
340
  disabled: false,
348
341
  focused: false,
349
342
  horizontalRule: "none",
350
- onToggle: () => void 0,
343
+ onToggle: () => undefined,
351
344
  role: "option",
352
345
  selected: false
353
346
  };
@@ -462,10 +455,11 @@ class SeparatorItem extends React.Component {
462
455
  return instance && instance.type && instance.type.__IS_SEPARATOR_ITEM__;
463
456
  }
464
457
  render() {
465
- return React.createElement(View, {
466
- style: [styles$8.separator, this.props.style],
467
- "aria-hidden": "true"
468
- });
458
+ return (React.createElement(View, {
459
+ style: [styles$8.separator, this.props.style],
460
+ "aria-hidden": "true"
461
+ })
462
+ );
469
463
  }
470
464
  }
471
465
  SeparatorItem.__IS_SEPARATOR_ITEM__ = true;
@@ -487,6 +481,7 @@ class DropdownOpener extends React.Component {
487
481
  };
488
482
  }
489
483
  renderAnchorChildren(eventState, clickableChildrenProps) {
484
+ var _childrenProps$ariaL;
490
485
  const {
491
486
  disabled,
492
487
  testId,
@@ -496,6 +491,7 @@ class DropdownOpener extends React.Component {
496
491
  "aria-haspopup": ariaHasPopUp,
497
492
  "aria-required": ariaRequired,
498
493
  id,
494
+ role,
499
495
  onBlur
500
496
  } = this.props;
501
497
  const renderedChildren = this.props.children(_extends({}, eventState, {
@@ -504,10 +500,13 @@ class DropdownOpener extends React.Component {
504
500
  }));
505
501
  const childrenProps = renderedChildren.props;
506
502
  const childrenTestId = this.getTestIdFromProps(childrenProps);
503
+ const renderedAriaLabel = (_childrenProps$ariaL = childrenProps["aria-label"]) != null ? _childrenProps$ariaL : this.props["aria-label"];
507
504
  return React.cloneElement(renderedChildren, _extends({}, clickableChildrenProps, {
505
+ "aria-label": renderedAriaLabel != null ? renderedAriaLabel : undefined,
508
506
  "aria-invalid": this.props.error,
509
507
  disabled,
510
508
  "aria-controls": ariaControls,
509
+ role,
511
510
  id,
512
511
  "aria-expanded": opened ? "true" : "false",
513
512
  "aria-haspopup": ariaHasPopUp,
@@ -612,7 +611,7 @@ class DropdownCoreVirtualized extends React.Component {
612
611
  }
613
612
  setWidth() {
614
613
  const rootNode = ReactDOM.findDOMNode(this);
615
- const parentNode = rootNode == null ? void 0 : rootNode.parentElement;
614
+ const parentNode = rootNode == null ? undefined : rootNode.parentElement;
616
615
  if (parentNode) {
617
616
  const width = parentNode.getBoundingClientRect().width;
618
617
  this.setState({
@@ -829,10 +828,10 @@ class DropdownCore extends React.Component {
829
828
  }
830
829
  constructor(props) {
831
830
  super(props);
832
- this.popperElement = void 0;
833
- this.virtualizedListRef = void 0;
834
- this.handleKeyDownDebounced = void 0;
835
- this.textSuggestion = void 0;
831
+ this.popperElement = undefined;
832
+ this.virtualizedListRef = undefined;
833
+ this.handleKeyDownDebounced = undefined;
834
+ this.textSuggestion = undefined;
836
835
  this.focusedIndex = -1;
837
836
  this.focusedOriginalIndex = -1;
838
837
  this.itemsClicked = false;
@@ -1511,7 +1510,7 @@ const _excluded$3 = ["text", "opened"];
1511
1510
  class ActionMenu extends React.Component {
1512
1511
  constructor(...args) {
1513
1512
  super(...args);
1514
- this.openerElement = void 0;
1513
+ this.openerElement = undefined;
1515
1514
  this.state = {
1516
1515
  opened: false
1517
1516
  };
@@ -1618,7 +1617,8 @@ class ActionMenu extends React.Component {
1618
1617
  text: menuText,
1619
1618
  ref: this.handleOpenerRef,
1620
1619
  testId: opener ? undefined : testId,
1621
- opened: this.state.opened
1620
+ opened: this.state.opened,
1621
+ role: "button"
1622
1622
  }, opener ? opener : openerProps => {
1623
1623
  const {
1624
1624
  opened
@@ -1676,7 +1676,7 @@ const styles$5 = StyleSheet.create({
1676
1676
  }
1677
1677
  });
1678
1678
 
1679
- const _excluded$2 = ["children", "disabled", "error", "id", "isPlaceholder", "open", "testId", "aria-required", "onBlur", "onOpenChanged"];
1679
+ const _excluded$2 = ["children", "disabled", "error", "id", "isPlaceholder", "open", "testId", "aria-label", "aria-required", "onBlur", "onOpenChanged"];
1680
1680
  const StyledButton = addStyle("button");
1681
1681
  class SelectOpener extends React.Component {
1682
1682
  constructor(props) {
@@ -1688,8 +1688,8 @@ class SelectOpener extends React.Component {
1688
1688
  this.props.onOpenChanged(!open);
1689
1689
  };
1690
1690
  this.handleKeyDown = e => {
1691
- const keyCode = e.key;
1692
- if (keyCode === "Enter" || keyCode === " ") {
1691
+ const keyName = e.key;
1692
+ if (keyName === keys.enter || keyName === keys.space) {
1693
1693
  this.setState({
1694
1694
  pressed: true
1695
1695
  });
@@ -1697,8 +1697,8 @@ class SelectOpener extends React.Component {
1697
1697
  }
1698
1698
  };
1699
1699
  this.handleKeyUp = e => {
1700
- const keyCode = e.key;
1701
- if (keyCode === "Enter" || keyCode === " ") {
1700
+ const keyName = e.key;
1701
+ if (keyName === keys.enter || keyName === keys.space) {
1702
1702
  this.setState({
1703
1703
  pressed: false
1704
1704
  });
@@ -1719,6 +1719,7 @@ class SelectOpener extends React.Component {
1719
1719
  isPlaceholder,
1720
1720
  open,
1721
1721
  testId,
1722
+ "aria-label": ariaLabel,
1722
1723
  "aria-required": ariaRequired,
1723
1724
  onBlur
1724
1725
  } = _this$props,
@@ -1730,19 +1731,23 @@ class SelectOpener extends React.Component {
1730
1731
  "aria-disabled": disabled,
1731
1732
  "aria-expanded": open ? "true" : "false",
1732
1733
  "aria-invalid": error,
1734
+ "aria-label": ariaLabel != null ? ariaLabel : undefined,
1733
1735
  "aria-required": ariaRequired,
1734
1736
  "aria-haspopup": "listbox",
1735
1737
  "data-testid": testId,
1736
1738
  id: id,
1737
- style: style,
1739
+ role: "combobox",
1738
1740
  type: "button",
1741
+ style: style,
1739
1742
  onClick: !disabled ? this.handleClick : undefined,
1740
1743
  onKeyDown: !disabled ? this.handleKeyDown : undefined,
1741
1744
  onKeyUp: !disabled ? this.handleKeyUp : undefined,
1742
1745
  onBlur: onBlur
1743
1746
  }), React.createElement(LabelMedium, {
1744
1747
  style: styles$4.text
1745
- }, children || "\u00A0"), React.createElement(PhosphorIcon, {
1748
+ }, children || React.createElement("span", {
1749
+ "aria-hidden": "true"
1750
+ }, "\xA0")), React.createElement(PhosphorIcon, {
1746
1751
  icon: caretDownIcon,
1747
1752
  color: iconColor,
1748
1753
  size: "small",
@@ -1927,7 +1932,7 @@ function useSelectValidation({
1927
1932
  };
1928
1933
  }
1929
1934
 
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"];
1935
+ const _excluded$1 = ["children", "error", "id", "opener", "placeholder", "selectedValue", "testId", "alignment", "autoFocus", "dropdownStyle", "enableTypeAhead", "isFilterable", "labels", "onChange", "onToggle", "opened", "style", "className", "aria-label", "aria-invalid", "aria-required", "disabled", "dropdownId", "validate", "onValidate", "required", "showOpenerLabelAsText"];
1931
1936
  const SingleSelect = props => {
1932
1937
  const selectedIndex = React.useRef(0);
1933
1938
  const {
@@ -1954,6 +1959,7 @@ const SingleSelect = props => {
1954
1959
  opened,
1955
1960
  style,
1956
1961
  className,
1962
+ "aria-label": ariaLabel,
1957
1963
  "aria-invalid": ariaInvalid,
1958
1964
  "aria-required": ariaRequired,
1959
1965
  disabled = false,
@@ -2065,16 +2071,19 @@ const SingleSelect = props => {
2065
2071
  }, uniqueOpenerId => {
2066
2072
  return opener ? React.createElement(DropdownOpener, {
2067
2073
  id: uniqueOpenerId,
2074
+ "aria-label": ariaLabel,
2068
2075
  "aria-controls": dropdownId,
2069
2076
  "aria-haspopup": "listbox",
2070
2077
  onClick: handleClick,
2071
2078
  disabled: isDisabled,
2072
2079
  ref: handleOpenerRef,
2080
+ role: "combobox",
2073
2081
  text: menuText,
2074
2082
  opened: open,
2075
2083
  error: hasError,
2076
2084
  onBlur: onOpenerBlurValidation
2077
2085
  }, opener) : React.createElement(SelectOpener, _extends({}, sharedProps, {
2086
+ "aria-label": ariaLabel,
2078
2087
  "aria-controls": dropdownId,
2079
2088
  disabled: isDisabled,
2080
2089
  id: uniqueOpenerId,
@@ -2121,7 +2130,7 @@ const SingleSelect = props => {
2121
2130
  }));
2122
2131
  };
2123
2132
 
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"];
2133
+ const _excluded = ["id", "opener", "testId", "alignment", "dropdownStyle", "implicitAllEnabled", "isFilterable", "labels", "onChange", "onToggle", "opened", "selectedValues", "shortcuts", "style", "className", "aria-label", "aria-invalid", "aria-required", "disabled", "error", "children", "dropdownId", "showOpenerLabelAsText", "validate", "onValidate", "required"];
2125
2134
  const MultiSelect = props => {
2126
2135
  const {
2127
2136
  id,
@@ -2139,6 +2148,7 @@ const MultiSelect = props => {
2139
2148
  shortcuts = false,
2140
2149
  style,
2141
2150
  className,
2151
+ "aria-label": ariaLabel,
2142
2152
  "aria-invalid": ariaInvalid,
2143
2153
  "aria-required": ariaRequired,
2144
2154
  disabled = false,
@@ -2213,7 +2223,7 @@ const MultiSelect = props => {
2213
2223
  onChange([]);
2214
2224
  onSelectedValuesChangeValidation();
2215
2225
  };
2216
- const getMenuText = children => {
2226
+ const getMenuTextOrNode = children => {
2217
2227
  const {
2218
2228
  noneSelected,
2219
2229
  someSelected,
@@ -2227,7 +2237,7 @@ const MultiSelect = props => {
2227
2237
  case 1:
2228
2238
  const selectedItem = children.find(option => option.props.value === selectedValues[0]);
2229
2239
  if (selectedItem) {
2230
- const selectedLabel = getSelectOpenerLabel(showOpenerLabelAsText, selectedItem == null ? void 0 : selectedItem.props);
2240
+ const selectedLabel = getSelectOpenerLabel(showOpenerLabelAsText, selectedItem == null ? undefined : selectedItem.props);
2231
2241
  if (selectedLabel) {
2232
2242
  return selectedLabel;
2233
2243
  } else {
@@ -2339,33 +2349,36 @@ const MultiSelect = props => {
2339
2349
  const {
2340
2350
  noneSelected
2341
2351
  } = labels;
2342
- const menuText = getMenuText(allChildren);
2352
+ const menuContent = getMenuTextOrNode(allChildren);
2343
2353
  const dropdownOpener = React.createElement(Id, {
2344
2354
  id: id
2345
2355
  }, uniqueOpenerId => {
2346
2356
  return opener ? React.createElement(DropdownOpener, {
2347
2357
  id: uniqueOpenerId,
2348
2358
  error: hasError,
2359
+ "aria-label": ariaLabel,
2349
2360
  "aria-controls": dropdownId,
2350
2361
  "aria-haspopup": "listbox",
2351
2362
  onClick: handleClick,
2352
2363
  onBlur: onOpenerBlurValidation,
2353
2364
  disabled: isDisabled,
2354
2365
  ref: handleOpenerRef,
2355
- text: menuText,
2366
+ role: "combobox",
2367
+ text: menuContent,
2356
2368
  opened: open
2357
2369
  }, opener) : React.createElement(SelectOpener, _extends({}, sharedProps, {
2358
2370
  error: hasError,
2359
2371
  disabled: isDisabled,
2360
2372
  id: uniqueOpenerId,
2373
+ "aria-label": ariaLabel,
2361
2374
  "aria-controls": dropdownId,
2362
- isPlaceholder: menuText === noneSelected,
2375
+ isPlaceholder: menuContent === noneSelected,
2363
2376
  onOpenChanged: handleOpenChanged,
2364
2377
  onBlur: onOpenerBlurValidation,
2365
2378
  open: open,
2366
2379
  ref: handleOpenerRef,
2367
2380
  testId: testId
2368
- }), menuText);
2381
+ }), menuContent);
2369
2382
  });
2370
2383
  return dropdownOpener;
2371
2384
  };
@@ -2532,7 +2545,7 @@ function useListbox({
2532
2545
  const renderList = React.useMemo(() => {
2533
2546
  return options.map((component, index) => {
2534
2547
  const isSingleSelection = selectionType === "single" && typeof selected === "string";
2535
- const isSelected = (isSingleSelection ? selected === component.props.value : selected == null ? void 0 : selected.includes(component.props.value)) || false;
2548
+ const isSelected = (isSingleSelection ? selected === component.props.value : selected == null ? undefined : selected.includes(component.props.value)) || false;
2536
2549
  const optionId = id ? `${id}-option-${index}` : `option-${index}`;
2537
2550
  return React.cloneElement(component, {
2538
2551
  key: index,
@@ -2579,19 +2592,19 @@ function useMultipleSelection({
2579
2592
  if (key === "ArrowLeft") {
2580
2593
  setFocusedMultiSelectIndex(prev => {
2581
2594
  const newIndex = prev - 1;
2582
- return newIndex < 0 ? (selected == null ? void 0 : selected.length) - 1 : newIndex;
2595
+ return newIndex < 0 ? (selected == null ? undefined : selected.length) - 1 : newIndex;
2583
2596
  });
2584
2597
  }
2585
2598
  if (key === "ArrowRight") {
2586
2599
  setFocusedMultiSelectIndex(prev => {
2587
2600
  const newIndex = prev + 1;
2588
- return newIndex >= (selected == null ? void 0 : selected.length) ? 0 : newIndex;
2601
+ return newIndex >= (selected == null ? undefined : selected.length) ? 0 : newIndex;
2589
2602
  });
2590
2603
  }
2591
2604
  if (inputValue === "" && key === "Backspace") {
2592
2605
  let newSelected = [];
2593
2606
  if (focusedMultiSelectIndex < 0) {
2594
- newSelected = selected == null ? void 0 : selected.slice(0, -1);
2607
+ newSelected = selected == null ? undefined : selected.slice(0, -1);
2595
2608
  } else {
2596
2609
  newSelected = selected.filter((_, index) => index !== focusedMultiSelectIndex);
2597
2610
  }
@@ -2599,7 +2612,7 @@ function useMultipleSelection({
2599
2612
  setFocusedMultiSelectIndex(-1);
2600
2613
  }
2601
2614
  if (focusedMultiSelectIndex >= 0 && key === "Enter") {
2602
- const newSelected = selected == null ? void 0 : selected.filter((_, index) => index !== focusedMultiSelectIndex);
2615
+ const newSelected = selected == null ? undefined : selected.filter((_, index) => index !== focusedMultiSelectIndex);
2603
2616
  setSelected(newSelected);
2604
2617
  setFocusedMultiSelectIndex(-1);
2605
2618
  }
@@ -2640,11 +2653,11 @@ function ComboboxLiveRegion({
2640
2653
  const lastSelectedValue = React.useRef(null);
2641
2654
  const [message, setMessage] = React.useState("");
2642
2655
  React.useEffect(() => {
2643
- if (selected && selected !== (lastSelectedValue == null ? void 0 : lastSelectedValue.current)) {
2656
+ if (selected && selected !== (lastSelectedValue == null ? undefined : lastSelectedValue.current)) {
2644
2657
  var _lastSelectedValue$cu, _lastSelectedValue$cu2, _selected$length;
2645
2658
  let newMessage = "";
2646
- const lastSelectedLength = (_lastSelectedValue$cu = lastSelectedValue == null ? void 0 : (_lastSelectedValue$cu2 = lastSelectedValue.current) == null ? void 0 : _lastSelectedValue$cu2.length) != null ? _lastSelectedValue$cu : 0;
2647
- const selectedLength = (_selected$length = selected == null ? void 0 : selected.length) != null ? _selected$length : 0;
2659
+ const lastSelectedLength = (_lastSelectedValue$cu = lastSelectedValue == null || (_lastSelectedValue$cu2 = lastSelectedValue.current) == null ? undefined : _lastSelectedValue$cu2.length) != null ? _lastSelectedValue$cu : 0;
2660
+ const selectedLength = (_selected$length = selected == null ? undefined : selected.length) != null ? _selected$length : 0;
2648
2661
  if (Array.isArray(selected) && selected.length > 0) {
2649
2662
  const currentLabels = selectedLabels.join(", ");
2650
2663
  const selectedState = selectedLength > lastSelectedLength ? labels.selected(currentLabels) : labels.unselected(currentLabels);
@@ -2798,7 +2811,7 @@ function StandaloneListbox(props) {
2798
2811
  });
2799
2812
  React.useEffect(() => {
2800
2813
  if (selected && selected !== value) {
2801
- onChange == null ? void 0 : onChange(selected);
2814
+ onChange == null || onChange(selected);
2802
2815
  }
2803
2816
  }, [onChange, selected, value]);
2804
2817
  return React.createElement(View, {
@@ -2870,7 +2883,7 @@ function Combobox({
2870
2883
  testId,
2871
2884
  value = ""
2872
2885
  }) {
2873
- var _renderList$find, _renderList$focusedIn, _renderList$focusedIn2;
2886
+ var _renderList$find, _renderList$focusedIn;
2874
2887
  const generatedUniqueId = useId();
2875
2888
  const uniqueId = id != null ? id : generatedUniqueId;
2876
2889
  const comboboxRef = React.useRef(null);
@@ -2901,7 +2914,7 @@ function Combobox({
2901
2914
  disableSpaceSelection: true,
2902
2915
  selectionType
2903
2916
  });
2904
- const itemFromSelected = (_renderList$find = renderList.find(item => item.props.value === selected)) == null ? void 0 : _renderList$find.props;
2917
+ const itemFromSelected = (_renderList$find = renderList.find(item => item.props.value === selected)) == null ? undefined : _renderList$find.props;
2905
2918
  const labelFromSelected = itemFromSelected ? getLabel(itemFromSelected) : "";
2906
2919
  const initialValue = typeof value === "string" ? labelFromSelected : "";
2907
2920
  const [inputValue, setInputValue] = React.useState(initialValue);
@@ -2929,16 +2942,16 @@ function Combobox({
2929
2942
  }
2930
2943
  setCurrentOptions(children);
2931
2944
  }
2932
- onToggle == null ? void 0 : onToggle(newState);
2945
+ onToggle == null || onToggle(newState);
2933
2946
  }, [children, disabled, isControlled, labelFromSelected, onToggle, openState, selectionType, setFocusedIndex]);
2934
2947
  const handleChange = React.useCallback(value => {
2935
2948
  if (value !== valueState) {
2936
2949
  setSelectedValue(value);
2937
- onChange == null ? void 0 : onChange(value);
2950
+ onChange == null || onChange(value);
2938
2951
  }
2939
2952
  if (selectionType === "single" && typeof value === "string") {
2940
2953
  var _renderList$find2;
2941
- const itemFromSelected = (_renderList$find2 = renderList.find(item => item.props.value === value)) == null ? void 0 : _renderList$find2.props;
2954
+ const itemFromSelected = (_renderList$find2 = renderList.find(item => item.props.value === value)) == null ? undefined : _renderList$find2.props;
2942
2955
  const labelFromSelected = itemFromSelected ? getLabel(itemFromSelected) : "";
2943
2956
  updateOpenState(false, labelFromSelected);
2944
2957
  } else if (Array.isArray(value)) {
@@ -2992,20 +3005,20 @@ function Combobox({
2992
3005
  e.stopPropagation();
2993
3006
  setInputValue("");
2994
3007
  setSelected("");
2995
- onChange == null ? void 0 : onChange("");
2996
- (_comboboxRef$current = comboboxRef.current) == null ? void 0 : _comboboxRef$current.focus();
3008
+ onChange == null || onChange("");
3009
+ (_comboboxRef$current = comboboxRef.current) == null || _comboboxRef$current.focus();
2997
3010
  }, [onChange, setSelected]);
2998
3011
  React.useEffect(() => {
2999
3012
  if (openState) {
3000
3013
  var _comboboxRef$current2;
3001
- (_comboboxRef$current2 = comboboxRef.current) == null ? void 0 : _comboboxRef$current2.focus();
3014
+ (_comboboxRef$current2 = comboboxRef.current) == null || _comboboxRef$current2.focus();
3002
3015
  }
3003
3016
  }, [openState]);
3004
3017
  const selectedLabels = React.useMemo(() => {
3005
3018
  if (Array.isArray(selected)) {
3006
3019
  return selected.map(value => {
3007
3020
  const item = children.find(item => item.props.value === value);
3008
- return item ? getLabel(item == null ? void 0 : item.props) : "";
3021
+ return item ? getLabel(item == null ? undefined : item.props) : "";
3009
3022
  });
3010
3023
  }
3011
3024
  return [labelFromSelected];
@@ -3026,7 +3039,7 @@ function Combobox({
3026
3039
  };
3027
3040
  const pillIdPrefix = `${uniqueId}-pill-`;
3028
3041
  const textFieldId = useId();
3029
- 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 ? undefined : _renderList$focusedIn.id : pillIdPrefix + focusedMultiSelectIndex;
3030
3043
  const controlledWidget = !openState ? undefined : focusedIndex >= 0 ? uniqueId : pillIdPrefix;
3031
3044
  return React.createElement(React.Fragment, null, React.createElement(View, {
3032
3045
  onClick: () => {
@@ -3105,13 +3118,13 @@ function Combobox({
3105
3118
  "aria-label": labels.comboboxButton
3106
3119
  })), openState && React.createElement(DropdownPopper, {
3107
3120
  alignment: "left",
3108
- referenceElement: rootNodeRef == null ? void 0 : rootNodeRef.current
3121
+ referenceElement: rootNodeRef == null ? undefined : rootNodeRef.current
3109
3122
  }, isReferenceHidden => {
3110
3123
  var _rootNodeRef$current, _rootNodeRef$current2;
3111
3124
  return React.createElement(React.Fragment, null, renderList.length === 0 ? React.createElement(DetailCell, {
3112
3125
  title: labels.noItems,
3113
3126
  style: [styles.listbox, {
3114
- minWidth: rootNodeRef == null ? void 0 : (_rootNodeRef$current = rootNodeRef.current) == null ? void 0 : _rootNodeRef$current.offsetWidth
3127
+ minWidth: rootNodeRef == null || (_rootNodeRef$current = rootNodeRef.current) == null ? undefined : _rootNodeRef$current.offsetWidth
3115
3128
  }],
3116
3129
  horizontalRule: "none"
3117
3130
  }) : React.createElement(Listbox, {
@@ -3119,7 +3132,7 @@ function Combobox({
3119
3132
  tabIndex: -1,
3120
3133
  selectionType: selectionType,
3121
3134
  style: [styles.listbox, isReferenceHidden && styles.hidden, {
3122
- minWidth: rootNodeRef == null ? void 0 : (_rootNodeRef$current2 = rootNodeRef.current) == null ? void 0 : _rootNodeRef$current2.offsetWidth
3135
+ minWidth: rootNodeRef == null || (_rootNodeRef$current2 = rootNodeRef.current) == null ? undefined : _rootNodeRef$current2.offsetWidth
3123
3136
  }],
3124
3137
  testId: testId ? `${testId}-listbox` : undefined,
3125
3138
  "aria-label": labels.listbox,
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import SingleSelect from "./components/single-select";
6
6
  import MultiSelect from "./components/multi-select";
7
7
  import Combobox from "./components/combobox";
8
8
  import Listbox from "./components/listbox";
9
- import type { Labels } from "./components/multi-select";
10
- import type { SingleSelectLabels } from "./components/single-select";
9
+ import type { LabelsValues } from "./components/multi-select";
10
+ import type { SingleSelectLabelsValues } from "./components/single-select";
11
11
  export { ActionItem, OptionItem, SeparatorItem, ActionMenu, SingleSelect, MultiSelect, Combobox, Listbox, };
12
- export type { Labels, SingleSelectLabels };
12
+ export type { LabelsValues, SingleSelectLabelsValues };