@carbon/react 1.36.0 → 1.37.0-rc.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.
Files changed (45) hide show
  1. package/es/components/ComboBox/ComboBox.js +2 -4
  2. package/es/components/DataTable/DataTable.d.ts +26 -0
  3. package/es/components/DataTable/DataTable.js +25 -0
  4. package/es/components/DataTable/TableExpandHeader.d.ts +27 -5
  5. package/es/components/DataTable/TableExpandHeader.js +17 -3
  6. package/es/components/DataTable/TableExpandRow.d.ts +24 -3
  7. package/es/components/DataTable/TableExpandRow.js +18 -3
  8. package/es/components/DataTable/TableRow.js +1 -1
  9. package/es/components/Dropdown/Dropdown.d.ts +1 -1
  10. package/es/components/Dropdown/Dropdown.js +40 -40
  11. package/es/components/ListBox/ListBoxMenu.d.ts +2 -2
  12. package/es/components/ListBox/ListBoxMenu.js +1 -1
  13. package/es/components/ListBox/ListBoxMenuItem.d.ts +6 -2
  14. package/es/components/ListBox/ListBoxMenuItem.js +6 -3
  15. package/es/components/MultiSelect/FilterableMultiSelect.js +24 -4
  16. package/es/components/MultiSelect/MultiSelect.js +77 -56
  17. package/es/components/NumberInput/NumberInput.d.ts +1 -1
  18. package/es/components/NumberInput/NumberInput.js +18 -44
  19. package/es/components/Slider/Slider.d.ts +6 -0
  20. package/es/components/Slider/Slider.js +17 -2
  21. package/es/components/TextArea/TextArea.js +1 -1
  22. package/es/components/Tile/Tile.js +5 -5
  23. package/lib/components/ComboBox/ComboBox.js +2 -4
  24. package/lib/components/DataTable/DataTable.d.ts +26 -0
  25. package/lib/components/DataTable/DataTable.js +25 -0
  26. package/lib/components/DataTable/TableExpandHeader.d.ts +27 -5
  27. package/lib/components/DataTable/TableExpandHeader.js +17 -3
  28. package/lib/components/DataTable/TableExpandRow.d.ts +24 -3
  29. package/lib/components/DataTable/TableExpandRow.js +18 -3
  30. package/lib/components/DataTable/TableRow.js +1 -1
  31. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  32. package/lib/components/Dropdown/Dropdown.js +39 -39
  33. package/lib/components/ListBox/ListBoxMenu.d.ts +2 -2
  34. package/lib/components/ListBox/ListBoxMenu.js +1 -1
  35. package/lib/components/ListBox/ListBoxMenuItem.d.ts +6 -2
  36. package/lib/components/ListBox/ListBoxMenuItem.js +6 -3
  37. package/lib/components/MultiSelect/FilterableMultiSelect.js +24 -4
  38. package/lib/components/MultiSelect/MultiSelect.js +75 -55
  39. package/lib/components/NumberInput/NumberInput.d.ts +1 -1
  40. package/lib/components/NumberInput/NumberInput.js +18 -44
  41. package/lib/components/Slider/Slider.d.ts +6 -0
  42. package/lib/components/Slider/Slider.js +17 -2
  43. package/lib/components/TextArea/TextArea.js +1 -1
  44. package/lib/components/Tile/Tile.js +5 -5
  45. package/package.json +3 -3
@@ -208,7 +208,7 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
208
208
  }
209
209
  if (event.target === textInput.current && isOpen) {
210
210
  event.preventDownshiftDefault = true;
211
- event.persist();
211
+ event?.persist?.();
212
212
  }
213
213
  };
214
214
  const showWarning = !invalid && warn;
@@ -289,8 +289,6 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
289
289
  }
290
290
  });
291
291
  const inputProps = getInputProps({
292
- // Remove excess aria `aria-labelledby`. HTML <label for> provides this aria information.
293
- 'aria-labelledby': null,
294
292
  disabled,
295
293
  placeholder,
296
294
  onClick() {
@@ -307,7 +305,7 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
307
305
  if (event.target === textInput.current && isOpen) {
308
306
  toggleMenu();
309
307
  event.preventDownshiftDefault = true;
310
- event.persist();
308
+ event?.persist?.();
311
309
  }
312
310
  }
313
311
  if (match(event, Home)) {
@@ -99,6 +99,7 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
99
99
  [key: string]: unknown;
100
100
  }) => {
101
101
  ariaLabel: string;
102
+ ['aria-label']: string;
102
103
  isExpanded: boolean;
103
104
  onExpand: (e: MouseEvent) => void;
104
105
  [key: string]: unknown;
@@ -109,6 +110,7 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
109
110
  [key: string]: unknown;
110
111
  }) => {
111
112
  ariaLabel: string;
113
+ ['aria-label']: string;
112
114
  disabled: boolean | undefined;
113
115
  isExpanded?: boolean;
114
116
  isSelected?: boolean;
@@ -116,6 +118,13 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
116
118
  onExpand: (e: MouseEvent) => void;
117
119
  [key: string]: unknown;
118
120
  };
121
+ getExpandedRowProps: (getExpandedRowPropsArgs: {
122
+ row: DataTableRow<ColTypes>;
123
+ [key: string]: unknown;
124
+ }) => {
125
+ ['id']: string;
126
+ [key: string]: unknown;
127
+ };
119
128
  getSelectionProps: (getSelectionPropsArgs: {
120
129
  onClick?: (e: MouseEvent) => void;
121
130
  row: DataTableRow<ColTypes>;
@@ -375,6 +384,8 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
375
384
  onExpand?: ((e: MouseEvent) => void) | undefined;
376
385
  }) => {
377
386
  ariaLabel: string;
387
+ 'aria-label': string;
388
+ 'aria-controls': string;
378
389
  isExpanded: boolean;
379
390
  onExpand: any;
380
391
  };
@@ -411,9 +422,24 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
411
422
  onExpand: any;
412
423
  isExpanded: boolean | undefined;
413
424
  ariaLabel: string;
425
+ 'aria-label': string;
426
+ 'aria-controls': string;
414
427
  isSelected: boolean | undefined;
415
428
  disabled: boolean | undefined;
416
429
  };
430
+ /**
431
+ * Get the props associated with an expanded row
432
+ *
433
+ * @param {object} config
434
+ * @param {object} config.row the parent row we want the props for
435
+ * @returns {object}
436
+ */
437
+ getExpandedRowProps: ({ row, ...rest }: {
438
+ [key: string]: unknown;
439
+ row: DataTableRow<ColTypes>;
440
+ }) => {
441
+ id: string;
442
+ };
417
443
  /**
418
444
  * Gets the props associated with selection for a header or a row, where
419
445
  * applicable. Most often used to indicate selection status of the table or
@@ -151,6 +151,10 @@ class DataTable extends React__default.Component {
151
151
  return {
152
152
  ...rest,
153
153
  ariaLabel: t(translationKey),
154
+ // TODO: remove in v12
155
+ 'aria-label': t(translationKey),
156
+ // Provide a string of all the expanded row id's, separated by a space.
157
+ 'aria-controls': rowIds.map(id => `expanded-row-${id}`).join(' '),
154
158
  isExpanded,
155
159
  // Compose the event handlers so we don't overwrite a consumer's `onClick`
156
160
  // handler
@@ -205,10 +209,30 @@ class DataTable extends React__default.Component {
205
209
  onExpand: composeEventHandlers([this.handleOnExpandRow(row.id), onClick]),
206
210
  isExpanded: row.isExpanded,
207
211
  ariaLabel: t(translationKey),
212
+ // TODO remove in v12
213
+ 'aria-label': t(translationKey),
214
+ 'aria-controls': `expanded-row-${row.id}`,
208
215
  isSelected: row.isSelected,
209
216
  disabled: row.disabled
210
217
  };
211
218
  });
219
+ /**
220
+ * Get the props associated with an expanded row
221
+ *
222
+ * @param {object} config
223
+ * @param {object} config.row the parent row we want the props for
224
+ * @returns {object}
225
+ */
226
+ _defineProperty(this, "getExpandedRowProps", _ref3 => {
227
+ let {
228
+ row,
229
+ ...rest
230
+ } = _ref3;
231
+ return {
232
+ ...rest,
233
+ id: `expanded-row-${row.id}`
234
+ };
235
+ });
212
236
  /**
213
237
  * Gets the props associated with selection for a header or a row, where
214
238
  * applicable. Most often used to indicate selection status of the table or
@@ -586,6 +610,7 @@ class DataTable extends React__default.Component {
586
610
  getHeaderProps: this.getHeaderProps,
587
611
  getExpandHeaderProps: this.getExpandHeaderProps,
588
612
  getRowProps: this.getRowProps,
613
+ getExpandedRowProps: this.getExpandedRowProps,
589
614
  getSelectionProps: this.getSelectionProps,
590
615
  getToolbarProps: this.getToolbarProps,
591
616
  getBatchActionProps: this.getBatchActionProps,
@@ -8,11 +8,21 @@ import PropTypes from 'prop-types';
8
8
  import React from 'react';
9
9
  import { ReactAttr } from '../../types/common';
10
10
  type TableExpandHeaderPropsBase = {
11
+ /**
12
+ * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandHeader
13
+ */
14
+ ['aria-controls']: string;
15
+ /**
16
+ * @deprecated This prop has been deprecated and will be
17
+ * removed in the next major release of Carbon. Use the
18
+ * `aria-label` prop instead.
19
+ */
20
+ ariaLabel?: string;
11
21
  /**
12
22
  * Specify the string read by a voice reader when the expand trigger is
13
23
  * focused
14
24
  */
15
- ariaLabel?: string;
25
+ ['aria-label']: string;
16
26
  /**
17
27
  * @deprecated The enableExpando prop is being replaced by `enableToggle`
18
28
  */
@@ -35,25 +45,37 @@ type TableExpandHeaderPropsBase = {
35
45
  */
36
46
  onExpand?(event: React.MouseEvent<HTMLButtonElement>): void;
37
47
  } & ReactAttr<HTMLTableCellElement>;
38
- type TableExpandHeaderPropsWithToggle = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'enableToggle' | 'onExpand'> & {
48
+ type TableExpandHeaderPropsWithToggle = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'aria-label' | 'enableToggle' | 'onExpand'> & {
39
49
  enableToggle: true;
40
50
  ariaLabel: string;
51
+ ['aria-label']: string;
41
52
  onExpand(event: React.MouseEvent<HTMLButtonElement>): void;
42
53
  };
43
- type TableExpandHeaderPropsWithExpando = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'enableExpando' | 'onExpand'> & {
54
+ type TableExpandHeaderPropsWithExpando = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'aria-label' | 'enableExpando' | 'onExpand'> & {
44
55
  enableExpando: true;
45
56
  ariaLabel: string;
57
+ ['aria-label']: string;
46
58
  onExpand(event: React.MouseEvent<HTMLButtonElement>): void;
47
59
  };
48
60
  export type TableExpandHeaderProps = TableExpandHeaderPropsWithToggle | TableExpandHeaderPropsWithExpando | TableExpandHeaderPropsBase;
49
61
  declare const TableExpandHeader: {
50
- ({ ariaLabel, className: headerClassName, enableExpando, enableToggle, id, isExpanded, onExpand, expandIconDescription, children, ...rest }: TableExpandHeaderProps): JSX.Element;
62
+ ({ ["aria-controls"]: ariaControls, ["aria-label"]: ariaLabel, ariaLabel: deprecatedAriaLabel, className: headerClassName, enableExpando, enableToggle, id, isExpanded, onExpand, expandIconDescription, children, ...rest }: TableExpandHeaderProps): JSX.Element;
51
63
  propTypes: {
52
64
  /**
65
+ * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandHeader
66
+ */
67
+ "aria-controls": PropTypes.Requireable<string>;
68
+ /**
69
+ * Specify the string read by a voice reader when the expand trigger is
70
+ * focused
71
+ */
72
+ "aria-label": PropTypes.Requireable<string>;
73
+ /**
74
+ * Deprecated, please use `aria-label` instead.
53
75
  * Specify the string read by a voice reader when the expand trigger is
54
76
  * focused
55
77
  */
56
- ariaLabel: PropTypes.Requireable<any>;
78
+ ariaLabel: PropTypes.Requireable<string>;
57
79
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
58
80
  className: PropTypes.Requireable<string>;
59
81
  /**
@@ -16,7 +16,9 @@ import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsT
16
16
 
17
17
  const TableExpandHeader = _ref => {
18
18
  let {
19
- ariaLabel,
19
+ ['aria-controls']: ariaControls,
20
+ ['aria-label']: ariaLabel,
21
+ ariaLabel: deprecatedAriaLabel,
20
22
  className: headerClassName,
21
23
  enableExpando,
22
24
  enableToggle,
@@ -40,7 +42,9 @@ const TableExpandHeader = _ref => {
40
42
  className: `${prefix}--table-expand__button`,
41
43
  onClick: onExpand,
42
44
  title: expandIconDescription,
43
- "aria-label": ariaLabel
45
+ "aria-label": deprecatedAriaLabel || ariaLabel,
46
+ "aria-expanded": isExpanded,
47
+ "aria-controls": ariaControls
44
48
  }, /*#__PURE__*/React__default.createElement(ChevronRight, {
45
49
  className: `${prefix}--table-expand__svg`,
46
50
  "aria-label": expandIconDescription
@@ -48,10 +52,20 @@ const TableExpandHeader = _ref => {
48
52
  };
49
53
  TableExpandHeader.propTypes = {
50
54
  /**
55
+ * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandHeader
56
+ */
57
+ ['aria-controls']: PropTypes.string,
58
+ /**
59
+ * Specify the string read by a voice reader when the expand trigger is
60
+ * focused
61
+ */
62
+ ['aria-label']: PropTypes.string,
63
+ /**
64
+ * Deprecated, please use `aria-label` instead.
51
65
  * Specify the string read by a voice reader when the expand trigger is
52
66
  * focused
53
67
  */
54
- ariaLabel: PropTypes.oneOfType([requiredIfGivenPropIsTruthy('enableExpando', PropTypes.string), requiredIfGivenPropIsTruthy('enableToggle', PropTypes.string)]),
68
+ ariaLabel: PropTypes.string,
55
69
  children: PropTypes.node,
56
70
  className: PropTypes.string,
57
71
  /**
@@ -8,11 +8,21 @@ import PropTypes from 'prop-types';
8
8
  import { MouseEventHandler, PropsWithChildren } from 'react';
9
9
  import { TableRowProps } from './TableRow';
10
10
  interface TableExpandRowProps extends PropsWithChildren<TableRowProps> {
11
+ /**
12
+ * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
13
+ */
14
+ ['aria-controls']: string;
15
+ /**
16
+ * @deprecated This prop has been deprecated and will be
17
+ * removed in the next major release of Carbon. Use the
18
+ * `aria-label` prop instead.
19
+ */
20
+ ariaLabel?: string;
11
21
  /**
12
22
  * Specify the string read by a voice reader when the expand trigger is
13
23
  * focused
14
24
  */
15
- ariaLabel: string;
25
+ ['aria-label']: string;
16
26
  /**
17
27
  * The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43
18
28
  */
@@ -32,13 +42,24 @@ interface TableExpandRowProps extends PropsWithChildren<TableRowProps> {
32
42
  onExpand: MouseEventHandler<HTMLButtonElement>;
33
43
  }
34
44
  declare const TableExpandRow: {
35
- ({ ariaLabel, className: rowClassName, children, isExpanded, onExpand, expandIconDescription, isSelected, expandHeader, ...rest }: TableExpandRowProps): JSX.Element;
45
+ ({ ["aria-controls"]: ariaControls, ["aria-label"]: ariaLabel, ariaLabel: deprecatedAriaLabel, className: rowClassName, children, isExpanded, onExpand, expandIconDescription, isSelected, expandHeader, ...rest }: TableExpandRowProps): JSX.Element;
36
46
  propTypes: {
37
47
  /**
48
+ * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
49
+ * TODO: make this required in v12
50
+ */
51
+ "aria-controls": PropTypes.Requireable<string>;
52
+ /**
53
+ * Specify the string read by a voice reader when the expand trigger is
54
+ * focused
55
+ */
56
+ "aria-label": PropTypes.Requireable<string>;
57
+ /**
58
+ * Deprecated, please use `aria-label` instead.
38
59
  * Specify the string read by a voice reader when the expand trigger is
39
60
  * focused
40
61
  */
41
- ariaLabel: PropTypes.Validator<string>;
62
+ ariaLabel: PropTypes.Requireable<string>;
42
63
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
43
64
  className: PropTypes.Requireable<string>;
44
65
  /**
@@ -15,7 +15,9 @@ import { usePrefix } from '../../internal/usePrefix.js';
15
15
 
16
16
  const TableExpandRow = _ref => {
17
17
  let {
18
- ariaLabel,
18
+ ['aria-controls']: ariaControls,
19
+ ['aria-label']: ariaLabel,
20
+ ariaLabel: deprecatedAriaLabel,
19
21
  className: rowClassName,
20
22
  children,
21
23
  isExpanded,
@@ -44,7 +46,9 @@ const TableExpandRow = _ref => {
44
46
  className: `${prefix}--table-expand__button`,
45
47
  onClick: onExpand,
46
48
  title: expandIconDescription,
47
- "aria-label": ariaLabel
49
+ "aria-label": deprecatedAriaLabel || ariaLabel,
50
+ "aria-expanded": isExpanded,
51
+ "aria-controls": ariaControls
48
52
  }, /*#__PURE__*/React__default.createElement(ChevronRight, {
49
53
  className: `${prefix}--table-expand__svg`,
50
54
  "aria-label": expandIconDescription
@@ -52,10 +56,21 @@ const TableExpandRow = _ref => {
52
56
  };
53
57
  TableExpandRow.propTypes = {
54
58
  /**
59
+ * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
60
+ * TODO: make this required in v12
61
+ */
62
+ ['aria-controls']: PropTypes.string,
63
+ /**
64
+ * Specify the string read by a voice reader when the expand trigger is
65
+ * focused
66
+ */
67
+ ['aria-label']: PropTypes.string,
68
+ /**
69
+ * Deprecated, please use `aria-label` instead.
55
70
  * Specify the string read by a voice reader when the expand trigger is
56
71
  * focused
57
72
  */
58
- ariaLabel: PropTypes.string.isRequired,
73
+ ariaLabel: PropTypes.string,
59
74
  children: PropTypes.node,
60
75
  className: PropTypes.string,
61
76
  /**
@@ -19,7 +19,7 @@ const TableRow = props => {
19
19
  [`${prefix}--data-table--selected`]: props.isSelected
20
20
  });
21
21
  const cleanProps = {
22
- ...omit(props, ['ariaLabel', 'onExpand', 'isExpanded', 'isSelected']),
22
+ ...omit(props, ['ariaLabel', 'aria-label', 'aria-controls', 'onExpand', 'isExpanded', 'isSelected']),
23
23
  className: className || undefined
24
24
  };
25
25
  return /*#__PURE__*/React__default.createElement("tr", cleanProps);
@@ -71,7 +71,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
71
71
  * given item to a string label. By default, it extracts the `label` field
72
72
  * from a given item to serve as the item label in the list.
73
73
  */
74
- itemToString?(item: ItemType): string;
74
+ itemToString?(item: ItemType | null): string;
75
75
  /**
76
76
  * We try to stay as generic as possible here to allow individuals to pass
77
77
  * in a collection of whatever kind of data structure they prefer
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { useState, useContext, useRef } from 'react';
9
+ import React__default, { useContext, useRef, useState } from 'react';
10
10
  import { useSelect } from 'downshift';
11
11
  import cx from 'classnames';
12
12
  import PropTypes from 'prop-types';
@@ -22,11 +22,11 @@ import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
22
22
 
23
23
  const getInstanceId = setupGetInstanceId();
24
24
  const {
25
- MenuBlur,
26
- MenuKeyDownArrowDown,
27
- MenuKeyDownArrowUp,
28
- MenuKeyDownEscape,
29
- ToggleButtonClick
25
+ ToggleButtonKeyDownArrowDown,
26
+ ToggleButtonKeyDownArrowUp,
27
+ ToggleButtonKeyDownHome,
28
+ ToggleButtonKeyDownEnd,
29
+ ItemMouseMove
30
30
  } = useSelect.stateChangeTypes;
31
31
  const defaultItemToString = item => {
32
32
  if (typeof item === 'string') {
@@ -72,7 +72,6 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
72
72
  ...other
73
73
  } = _ref;
74
74
  const prefix = usePrefix();
75
- const [highlightedIndex, setHighlightedIndex] = useState();
76
75
  const {
77
76
  isFluid
78
77
  } = useContext(FormContext);
@@ -80,31 +79,43 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
80
79
  ...downshiftProps,
81
80
  items,
82
81
  itemToString,
83
- highlightedIndex,
84
82
  initialSelectedItem,
85
83
  onSelectedItemChange,
86
- onStateChange
84
+ stateReducer,
85
+ isItemDisabled(item, _index) {
86
+ const isObject = item !== null && typeof item === 'object';
87
+ return isObject && 'disabled' in item && item.disabled === true;
88
+ }
87
89
  };
88
90
  const {
89
91
  current: dropdownInstanceId
90
92
  } = useRef(getInstanceId());
91
- function onStateChange(changes) {
93
+ function stateReducer(state, actionAndChanges) {
92
94
  const {
95
+ changes,
96
+ props,
93
97
  type
98
+ } = actionAndChanges;
99
+ const {
100
+ highlightedIndex
94
101
  } = changes;
95
102
  switch (type) {
96
- case MenuKeyDownArrowDown:
97
- case MenuKeyDownArrowUp:
98
- setHighlightedIndex(changes.highlightedIndex);
99
- break;
100
- case MenuBlur:
101
- case MenuKeyDownEscape:
102
- setHighlightedIndex(changes.highlightedIndex);
103
- break;
104
- case ToggleButtonClick:
105
- setHighlightedIndex(changes.highlightedIndex);
106
- break;
103
+ case ToggleButtonKeyDownArrowDown:
104
+ case ToggleButtonKeyDownArrowUp:
105
+ case ToggleButtonKeyDownHome:
106
+ case ToggleButtonKeyDownEnd:
107
+ if (highlightedIndex > -1) {
108
+ const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
109
+ props.scrollIntoView(itemArray[highlightedIndex]);
110
+ }
111
+ return changes;
112
+ case ItemMouseMove:
113
+ return {
114
+ ...changes,
115
+ highlightedIndex: state.highlightedIndex
116
+ };
107
117
  }
118
+ return changes;
108
119
  }
109
120
 
110
121
  // only set selectedItem if the prop is defined. Setting if it is undefined
@@ -118,7 +129,8 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
118
129
  getLabelProps,
119
130
  getMenuProps,
120
131
  getItemProps,
121
- selectedItem
132
+ selectedItem,
133
+ highlightedIndex
122
134
  } = useSelect(selectProps);
123
135
  const inline = type === 'inline';
124
136
  const showWarning = !invalid && warn;
@@ -162,14 +174,12 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
162
174
  let {
163
175
  selectedItem
164
176
  } = _ref2;
165
- setIsFocused(false);
166
177
  if (onChange) {
167
178
  onChange({
168
179
  selectedItem: selectedItem ?? null
169
180
  });
170
181
  }
171
182
  }
172
- const menuItemOptionRefs = useRef(items.map(_ => /*#__PURE__*/React__default.createRef()));
173
183
  const handleFocus = evt => {
174
184
  setIsFocused(evt.type === 'focus' ? true : false);
175
185
  };
@@ -200,10 +210,6 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
200
210
  setIsTyping(true);
201
211
  }
202
212
  if (isTyping && evt.code === 'Space' || !['ArrowDown', 'ArrowUp', ' ', 'Enter'].includes(evt.key)) {
203
- if (evt.code === 'Space') {
204
- evt.preventDefault();
205
- return;
206
- }
207
213
  if (currTimer) {
208
214
  clearTimeout(currTimer);
209
215
  }
@@ -211,7 +217,9 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
211
217
  setIsTyping(false);
212
218
  }, 3000));
213
219
  }
214
- toggleButtonProps.onKeyDown(evt);
220
+ if (toggleButtonProps.onKeyDown) {
221
+ toggleButtonProps.onKeyDown(evt);
222
+ }
215
223
  }
216
224
  };
217
225
  const menuProps = getMenuProps();
@@ -240,16 +248,12 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
240
248
  type: "button"
241
249
  // aria-expanded is already being passed through {...toggleButtonProps}
242
250
  ,
243
- role: "combobox" // eslint-disable-line jsx-a11y/role-has-required-aria-props
244
- ,
245
- "aria-owns": getMenuProps().id,
246
- "aria-controls": getMenuProps().id,
247
251
  className: `${prefix}--list-box__field`,
248
252
  disabled: disabled,
249
253
  "aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
250
254
  ,
251
255
  "aria-describedby": !inline && !invalid && !warn && helper ? helperId : undefined,
252
- title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : label
256
+ title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : defaultItemToString(label)
253
257
  }, toggleButtonProps, readOnlyEventHandlers, {
254
258
  ref: mergedRef
255
259
  }), /*#__PURE__*/React__default.createElement("span", {
@@ -259,11 +263,9 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
259
263
  translateWithId: translateWithId
260
264
  })), /*#__PURE__*/React__default.createElement(ListBox.Menu, menuProps, isOpen && items.map((item, index) => {
261
265
  const isObject = item !== null && typeof item === 'object';
262
- const disabled = isObject && 'disabled' in item && item.disabled === true;
263
266
  const itemProps = getItemProps({
264
267
  item,
265
- index,
266
- disabled
268
+ index
267
269
  });
268
270
  const title = isObject && 'text' in item && itemToElement ? item.text : itemToString(item);
269
271
  return /*#__PURE__*/React__default.createElement(ListBox.MenuItem, _extends({
@@ -271,9 +273,7 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
271
273
  isActive: selectedItem === item,
272
274
  isHighlighted: highlightedIndex === index,
273
275
  title: title,
274
- ref: {
275
- menuItemOptionRef: menuItemOptionRefs.current[index]
276
- }
276
+ disabled: itemProps['aria-disabled']
277
277
  }, itemProps), typeof item === 'object' && ItemToElement !== undefined && ItemToElement !== null ? /*#__PURE__*/React__default.createElement(ItemToElement, _extends({
278
278
  key: itemProps.id
279
279
  }, item)) : itemToString(item), selectedItem === item && /*#__PURE__*/React__default.createElement(Checkmark, {
@@ -6,13 +6,13 @@
6
6
  */
7
7
  import { ForwardRefReturn, ReactAttr } from '../../types/common';
8
8
  type ExcludedAttributes = 'id';
9
- export interface ListBoxMenuProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes> {
9
+ export interface ListBoxMenuProps extends Omit<ReactAttr<HTMLUListElement>, ExcludedAttributes> {
10
10
  /**
11
11
  * Specify a custom `id`
12
12
  */
13
13
  id: string;
14
14
  }
15
- export type ListBoxMenuComponent = ForwardRefReturn<HTMLDivElement, ListBoxMenuProps>;
15
+ export type ListBoxMenuComponent = ForwardRefReturn<HTMLUListElement, ListBoxMenuProps>;
16
16
  /**
17
17
  * `ListBoxMenu` is a simple container node that isolates the `list-box__menu`
18
18
  * class into a single component. It is also being used to validate given
@@ -23,7 +23,7 @@ const ListBoxMenu = /*#__PURE__*/React__default.forwardRef(function ListBoxMenu(
23
23
  ...rest
24
24
  } = _ref;
25
25
  const prefix = usePrefix();
26
- return /*#__PURE__*/React__default.createElement("div", _extends({
26
+ return /*#__PURE__*/React__default.createElement("ul", _extends({
27
27
  ref: ref,
28
28
  id: id,
29
29
  className: `${prefix}--list-box__menu`,
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import React, { ForwardedRef } from 'react';
8
8
  import { ForwardRefReturn, ReactAttr } from '../../types/common';
9
- export interface ListBoxMenuItemProps extends ReactAttr<HTMLDivElement> {
9
+ export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
10
10
  /**
11
11
  * Specify whether the current menu item is "active".
12
12
  */
@@ -15,8 +15,12 @@ export interface ListBoxMenuItemProps extends ReactAttr<HTMLDivElement> {
15
15
  * Specify whether the current menu item is "highlighted".
16
16
  */
17
17
  isHighlighted?: boolean;
18
+ /**
19
+ * Specify whether the item should be disabled
20
+ */
21
+ disabled?: boolean;
18
22
  }
19
- export type ListBoxMenuItemForwardedRef = (ForwardedRef<HTMLDivElement> & {
23
+ export type ListBoxMenuItemForwardedRef = (ForwardedRef<HTMLLIElement> & {
20
24
  menuItemOptionRef?: React.Ref<HTMLDivElement>;
21
25
  }) | null;
22
26
  export type ListBoxMenuItemComponent = ForwardRefReturn<ListBoxMenuItemForwardedRef, ListBoxMenuItemProps>;
@@ -42,10 +42,9 @@ const ListBoxMenuItem = /*#__PURE__*/React__default.forwardRef(function ListBoxM
42
42
  [`${prefix}--list-box__menu-item--active`]: isActive,
43
43
  [`${prefix}--list-box__menu-item--highlighted`]: isHighlighted
44
44
  });
45
- return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
45
+ return /*#__PURE__*/React__default.createElement("li", _extends({}, rest, {
46
46
  className: className,
47
- title: isTruncated ? title : undefined,
48
- tabIndex: -1
47
+ title: isTruncated ? title : undefined
49
48
  }), /*#__PURE__*/React__default.createElement("div", {
50
49
  className: `${prefix}--list-box__menu-item__option`,
51
50
  ref: forwardedRef?.menuItemOptionRef || ref
@@ -58,6 +57,10 @@ ListBoxMenuItem.propTypes = {
58
57
  * Menu Item
59
58
  */
60
59
  children: PropTypes.node,
60
+ /**
61
+ * Specify if the item should be disabled
62
+ */
63
+ disabled: PropTypes.bool,
61
64
  /**
62
65
  * Specify whether the current menu item is "active".
63
66
  */