@carbon/react 1.36.0-rc.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 (53) hide show
  1. package/es/components/Breadcrumb/index.d.ts +11 -0
  2. package/es/components/BreadcrumbItem/index.d.ts +7 -0
  3. package/es/components/ComboBox/ComboBox.js +2 -4
  4. package/es/components/DataTable/DataTable.d.ts +26 -0
  5. package/es/components/DataTable/DataTable.js +25 -0
  6. package/es/components/DataTable/TableExpandHeader.d.ts +27 -5
  7. package/es/components/DataTable/TableExpandHeader.js +17 -3
  8. package/es/components/DataTable/TableExpandRow.d.ts +24 -3
  9. package/es/components/DataTable/TableExpandRow.js +18 -3
  10. package/es/components/DataTable/TableRow.js +1 -1
  11. package/es/components/Dropdown/Dropdown.d.ts +1 -1
  12. package/es/components/Dropdown/Dropdown.js +40 -40
  13. package/es/components/ListBox/ListBoxMenu.d.ts +2 -2
  14. package/es/components/ListBox/ListBoxMenu.js +1 -1
  15. package/es/components/ListBox/ListBoxMenuItem.d.ts +6 -2
  16. package/es/components/ListBox/ListBoxMenuItem.js +6 -3
  17. package/es/components/MultiSelect/FilterableMultiSelect.js +24 -4
  18. package/es/components/MultiSelect/MultiSelect.js +77 -56
  19. package/es/components/NumberInput/NumberInput.d.ts +1 -1
  20. package/es/components/NumberInput/NumberInput.js +18 -44
  21. package/es/components/Slider/Slider.d.ts +6 -0
  22. package/es/components/Slider/Slider.js +17 -2
  23. package/es/components/TextArea/TextArea.js +1 -1
  24. package/es/components/Tile/Tile.js +5 -5
  25. package/es/components/UIShell/SideNav.js +5 -1
  26. package/es/index.js +3 -3
  27. package/lib/components/Breadcrumb/index.d.ts +11 -0
  28. package/lib/components/BreadcrumbItem/index.d.ts +7 -0
  29. package/lib/components/ComboBox/ComboBox.js +2 -4
  30. package/lib/components/DataTable/DataTable.d.ts +26 -0
  31. package/lib/components/DataTable/DataTable.js +25 -0
  32. package/lib/components/DataTable/TableExpandHeader.d.ts +27 -5
  33. package/lib/components/DataTable/TableExpandHeader.js +17 -3
  34. package/lib/components/DataTable/TableExpandRow.d.ts +24 -3
  35. package/lib/components/DataTable/TableExpandRow.js +18 -3
  36. package/lib/components/DataTable/TableRow.js +1 -1
  37. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  38. package/lib/components/Dropdown/Dropdown.js +39 -39
  39. package/lib/components/ListBox/ListBoxMenu.d.ts +2 -2
  40. package/lib/components/ListBox/ListBoxMenu.js +1 -1
  41. package/lib/components/ListBox/ListBoxMenuItem.d.ts +6 -2
  42. package/lib/components/ListBox/ListBoxMenuItem.js +6 -3
  43. package/lib/components/MultiSelect/FilterableMultiSelect.js +24 -4
  44. package/lib/components/MultiSelect/MultiSelect.js +75 -55
  45. package/lib/components/NumberInput/NumberInput.d.ts +1 -1
  46. package/lib/components/NumberInput/NumberInput.js +18 -44
  47. package/lib/components/Slider/Slider.d.ts +6 -0
  48. package/lib/components/Slider/Slider.js +17 -2
  49. package/lib/components/TextArea/TextArea.js +1 -1
  50. package/lib/components/Tile/Tile.js +5 -5
  51. package/lib/components/UIShell/SideNav.js +5 -1
  52. package/lib/index.js +6 -6
  53. package/package.json +7 -7
@@ -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
@@ -161,6 +161,10 @@ class DataTable extends React__default["default"].Component {
161
161
  return {
162
162
  ...rest,
163
163
  ariaLabel: t(translationKey),
164
+ // TODO: remove in v12
165
+ 'aria-label': t(translationKey),
166
+ // Provide a string of all the expanded row id's, separated by a space.
167
+ 'aria-controls': rowIds.map(id => `expanded-row-${id}`).join(' '),
164
168
  isExpanded,
165
169
  // Compose the event handlers so we don't overwrite a consumer's `onClick`
166
170
  // handler
@@ -215,10 +219,30 @@ class DataTable extends React__default["default"].Component {
215
219
  onExpand: events.composeEventHandlers([this.handleOnExpandRow(row.id), onClick]),
216
220
  isExpanded: row.isExpanded,
217
221
  ariaLabel: t(translationKey),
222
+ // TODO remove in v12
223
+ 'aria-label': t(translationKey),
224
+ 'aria-controls': `expanded-row-${row.id}`,
218
225
  isSelected: row.isSelected,
219
226
  disabled: row.disabled
220
227
  };
221
228
  });
229
+ /**
230
+ * Get the props associated with an expanded row
231
+ *
232
+ * @param {object} config
233
+ * @param {object} config.row the parent row we want the props for
234
+ * @returns {object}
235
+ */
236
+ _rollupPluginBabelHelpers.defineProperty(this, "getExpandedRowProps", _ref3 => {
237
+ let {
238
+ row,
239
+ ...rest
240
+ } = _ref3;
241
+ return {
242
+ ...rest,
243
+ id: `expanded-row-${row.id}`
244
+ };
245
+ });
222
246
  /**
223
247
  * Gets the props associated with selection for a header or a row, where
224
248
  * applicable. Most often used to indicate selection status of the table or
@@ -596,6 +620,7 @@ class DataTable extends React__default["default"].Component {
596
620
  getHeaderProps: this.getHeaderProps,
597
621
  getExpandHeaderProps: this.getExpandHeaderProps,
598
622
  getRowProps: this.getRowProps,
623
+ getExpandedRowProps: this.getExpandedRowProps,
599
624
  getSelectionProps: this.getSelectionProps,
600
625
  getToolbarProps: this.getToolbarProps,
601
626
  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
  /**
@@ -26,7 +26,9 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
26
26
 
27
27
  const TableExpandHeader = _ref => {
28
28
  let {
29
- ariaLabel,
29
+ ['aria-controls']: ariaControls,
30
+ ['aria-label']: ariaLabel,
31
+ ariaLabel: deprecatedAriaLabel,
30
32
  className: headerClassName,
31
33
  enableExpando,
32
34
  enableToggle,
@@ -50,7 +52,9 @@ const TableExpandHeader = _ref => {
50
52
  className: `${prefix}--table-expand__button`,
51
53
  onClick: onExpand,
52
54
  title: expandIconDescription,
53
- "aria-label": ariaLabel
55
+ "aria-label": deprecatedAriaLabel || ariaLabel,
56
+ "aria-expanded": isExpanded,
57
+ "aria-controls": ariaControls
54
58
  }, /*#__PURE__*/React__default["default"].createElement(iconsReact.ChevronRight, {
55
59
  className: `${prefix}--table-expand__svg`,
56
60
  "aria-label": expandIconDescription
@@ -58,10 +62,20 @@ const TableExpandHeader = _ref => {
58
62
  };
59
63
  TableExpandHeader.propTypes = {
60
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__default["default"].string,
68
+ /**
69
+ * Specify the string read by a voice reader when the expand trigger is
70
+ * focused
71
+ */
72
+ ['aria-label']: PropTypes__default["default"].string,
73
+ /**
74
+ * Deprecated, please use `aria-label` instead.
61
75
  * Specify the string read by a voice reader when the expand trigger is
62
76
  * focused
63
77
  */
64
- ariaLabel: PropTypes__default["default"].oneOfType([requiredIfGivenPropIsTruthy["default"]('enableExpando', PropTypes__default["default"].string), requiredIfGivenPropIsTruthy["default"]('enableToggle', PropTypes__default["default"].string)]),
78
+ ariaLabel: PropTypes__default["default"].string,
65
79
  children: PropTypes__default["default"].node,
66
80
  className: PropTypes__default["default"].string,
67
81
  /**
@@ -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
  /**
@@ -25,7 +25,9 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
25
25
 
26
26
  const TableExpandRow = _ref => {
27
27
  let {
28
- ariaLabel,
28
+ ['aria-controls']: ariaControls,
29
+ ['aria-label']: ariaLabel,
30
+ ariaLabel: deprecatedAriaLabel,
29
31
  className: rowClassName,
30
32
  children,
31
33
  isExpanded,
@@ -54,7 +56,9 @@ const TableExpandRow = _ref => {
54
56
  className: `${prefix}--table-expand__button`,
55
57
  onClick: onExpand,
56
58
  title: expandIconDescription,
57
- "aria-label": ariaLabel
59
+ "aria-label": deprecatedAriaLabel || ariaLabel,
60
+ "aria-expanded": isExpanded,
61
+ "aria-controls": ariaControls
58
62
  }, /*#__PURE__*/React__default["default"].createElement(iconsReact.ChevronRight, {
59
63
  className: `${prefix}--table-expand__svg`,
60
64
  "aria-label": expandIconDescription
@@ -62,10 +66,21 @@ const TableExpandRow = _ref => {
62
66
  };
63
67
  TableExpandRow.propTypes = {
64
68
  /**
69
+ * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
70
+ * TODO: make this required in v12
71
+ */
72
+ ['aria-controls']: PropTypes__default["default"].string,
73
+ /**
74
+ * Specify the string read by a voice reader when the expand trigger is
75
+ * focused
76
+ */
77
+ ['aria-label']: PropTypes__default["default"].string,
78
+ /**
79
+ * Deprecated, please use `aria-label` instead.
65
80
  * Specify the string read by a voice reader when the expand trigger is
66
81
  * focused
67
82
  */
68
- ariaLabel: PropTypes__default["default"].string.isRequired,
83
+ ariaLabel: PropTypes__default["default"].string,
69
84
  children: PropTypes__default["default"].node,
70
85
  className: PropTypes__default["default"].string,
71
86
  /**
@@ -30,7 +30,7 @@ const TableRow = props => {
30
30
  [`${prefix}--data-table--selected`]: props.isSelected
31
31
  });
32
32
  const cleanProps = {
33
- ...omit__default["default"](props, ['ariaLabel', 'onExpand', 'isExpanded', 'isSelected']),
33
+ ...omit__default["default"](props, ['ariaLabel', 'aria-label', 'aria-controls', 'onExpand', 'isExpanded', 'isSelected']),
34
34
  className: className || undefined
35
35
  };
36
36
  return /*#__PURE__*/React__default["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
@@ -32,11 +32,11 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
32
32
 
33
33
  const getInstanceId = setupGetInstanceId["default"]();
34
34
  const {
35
- MenuBlur,
36
- MenuKeyDownArrowDown,
37
- MenuKeyDownArrowUp,
38
- MenuKeyDownEscape,
39
- ToggleButtonClick
35
+ ToggleButtonKeyDownArrowDown,
36
+ ToggleButtonKeyDownArrowUp,
37
+ ToggleButtonKeyDownHome,
38
+ ToggleButtonKeyDownEnd,
39
+ ItemMouseMove
40
40
  } = Downshift.useSelect.stateChangeTypes;
41
41
  const defaultItemToString = item => {
42
42
  if (typeof item === 'string') {
@@ -82,7 +82,6 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
82
82
  ...other
83
83
  } = _ref;
84
84
  const prefix = usePrefix.usePrefix();
85
- const [highlightedIndex, setHighlightedIndex] = React.useState();
86
85
  const {
87
86
  isFluid
88
87
  } = React.useContext(FormContext.FormContext);
@@ -90,31 +89,43 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
90
89
  ...downshiftProps,
91
90
  items,
92
91
  itemToString,
93
- highlightedIndex,
94
92
  initialSelectedItem,
95
93
  onSelectedItemChange,
96
- onStateChange
94
+ stateReducer,
95
+ isItemDisabled(item, _index) {
96
+ const isObject = item !== null && typeof item === 'object';
97
+ return isObject && 'disabled' in item && item.disabled === true;
98
+ }
97
99
  };
98
100
  const {
99
101
  current: dropdownInstanceId
100
102
  } = React.useRef(getInstanceId());
101
- function onStateChange(changes) {
103
+ function stateReducer(state, actionAndChanges) {
102
104
  const {
105
+ changes,
106
+ props,
103
107
  type
108
+ } = actionAndChanges;
109
+ const {
110
+ highlightedIndex
104
111
  } = changes;
105
112
  switch (type) {
106
- case MenuKeyDownArrowDown:
107
- case MenuKeyDownArrowUp:
108
- setHighlightedIndex(changes.highlightedIndex);
109
- break;
110
- case MenuBlur:
111
- case MenuKeyDownEscape:
112
- setHighlightedIndex(changes.highlightedIndex);
113
- break;
114
- case ToggleButtonClick:
115
- setHighlightedIndex(changes.highlightedIndex);
116
- break;
113
+ case ToggleButtonKeyDownArrowDown:
114
+ case ToggleButtonKeyDownArrowUp:
115
+ case ToggleButtonKeyDownHome:
116
+ case ToggleButtonKeyDownEnd:
117
+ if (highlightedIndex > -1) {
118
+ const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
119
+ props.scrollIntoView(itemArray[highlightedIndex]);
120
+ }
121
+ return changes;
122
+ case ItemMouseMove:
123
+ return {
124
+ ...changes,
125
+ highlightedIndex: state.highlightedIndex
126
+ };
117
127
  }
128
+ return changes;
118
129
  }
119
130
 
120
131
  // only set selectedItem if the prop is defined. Setting if it is undefined
@@ -128,7 +139,8 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
128
139
  getLabelProps,
129
140
  getMenuProps,
130
141
  getItemProps,
131
- selectedItem
142
+ selectedItem,
143
+ highlightedIndex
132
144
  } = Downshift.useSelect(selectProps);
133
145
  const inline = type === 'inline';
134
146
  const showWarning = !invalid && warn;
@@ -172,14 +184,12 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
172
184
  let {
173
185
  selectedItem
174
186
  } = _ref2;
175
- setIsFocused(false);
176
187
  if (onChange) {
177
188
  onChange({
178
189
  selectedItem: selectedItem ?? null
179
190
  });
180
191
  }
181
192
  }
182
- const menuItemOptionRefs = React.useRef(items.map(_ => /*#__PURE__*/React__default["default"].createRef()));
183
193
  const handleFocus = evt => {
184
194
  setIsFocused(evt.type === 'focus' ? true : false);
185
195
  };
@@ -210,10 +220,6 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
210
220
  setIsTyping(true);
211
221
  }
212
222
  if (isTyping && evt.code === 'Space' || !['ArrowDown', 'ArrowUp', ' ', 'Enter'].includes(evt.key)) {
213
- if (evt.code === 'Space') {
214
- evt.preventDefault();
215
- return;
216
- }
217
223
  if (currTimer) {
218
224
  clearTimeout(currTimer);
219
225
  }
@@ -221,7 +227,9 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
221
227
  setIsTyping(false);
222
228
  }, 3000));
223
229
  }
224
- toggleButtonProps.onKeyDown(evt);
230
+ if (toggleButtonProps.onKeyDown) {
231
+ toggleButtonProps.onKeyDown(evt);
232
+ }
225
233
  }
226
234
  };
227
235
  const menuProps = getMenuProps();
@@ -250,16 +258,12 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
250
258
  type: "button"
251
259
  // aria-expanded is already being passed through {...toggleButtonProps}
252
260
  ,
253
- role: "combobox" // eslint-disable-line jsx-a11y/role-has-required-aria-props
254
- ,
255
- "aria-owns": getMenuProps().id,
256
- "aria-controls": getMenuProps().id,
257
261
  className: `${prefix}--list-box__field`,
258
262
  disabled: disabled,
259
263
  "aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
260
264
  ,
261
265
  "aria-describedby": !inline && !invalid && !warn && helper ? helperId : undefined,
262
- title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : label
266
+ title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : defaultItemToString(label)
263
267
  }, toggleButtonProps, readOnlyEventHandlers, {
264
268
  ref: mergedRef
265
269
  }), /*#__PURE__*/React__default["default"].createElement("span", {
@@ -269,11 +273,9 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
269
273
  translateWithId: translateWithId
270
274
  })), /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen && items.map((item, index$1) => {
271
275
  const isObject = item !== null && typeof item === 'object';
272
- const disabled = isObject && 'disabled' in item && item.disabled === true;
273
276
  const itemProps = getItemProps({
274
277
  item,
275
- index: index$1,
276
- disabled
278
+ index: index$1
277
279
  });
278
280
  const title = isObject && 'text' in item && itemToElement ? item.text : itemToString(item);
279
281
  return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
@@ -281,9 +283,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
281
283
  isActive: selectedItem === item,
282
284
  isHighlighted: highlightedIndex === index$1,
283
285
  title: title,
284
- ref: {
285
- menuItemOptionRef: menuItemOptionRefs.current[index$1]
286
- }
286
+ disabled: itemProps['aria-disabled']
287
287
  }, itemProps), typeof item === 'object' && ItemToElement !== undefined && ItemToElement !== null ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
288
288
  key: itemProps.id
289
289
  }, item)) : itemToString(item), selectedItem === item && /*#__PURE__*/React__default["default"].createElement(iconsReact.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
@@ -32,7 +32,7 @@ const ListBoxMenu = /*#__PURE__*/React__default["default"].forwardRef(function L
32
32
  ...rest
33
33
  } = _ref;
34
34
  const prefix = usePrefix.usePrefix();
35
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
35
+ return /*#__PURE__*/React__default["default"].createElement("ul", _rollupPluginBabelHelpers["extends"]({
36
36
  ref: ref,
37
37
  id: id,
38
38
  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>;
@@ -52,10 +52,9 @@ const ListBoxMenuItem = /*#__PURE__*/React__default["default"].forwardRef(functi
52
52
  [`${prefix}--list-box__menu-item--active`]: isActive,
53
53
  [`${prefix}--list-box__menu-item--highlighted`]: isHighlighted
54
54
  });
55
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
55
+ return /*#__PURE__*/React__default["default"].createElement("li", _rollupPluginBabelHelpers["extends"]({}, rest, {
56
56
  className: className,
57
- title: isTruncated ? title : undefined,
58
- tabIndex: -1
57
+ title: isTruncated ? title : undefined
59
58
  }), /*#__PURE__*/React__default["default"].createElement("div", {
60
59
  className: `${prefix}--list-box__menu-item__option`,
61
60
  ref: forwardedRef?.menuItemOptionRef || ref
@@ -68,6 +67,10 @@ ListBoxMenuItem.propTypes = {
68
67
  * Menu Item
69
68
  */
70
69
  children: PropTypes__default["default"].node,
70
+ /**
71
+ * Specify if the item should be disabled
72
+ */
73
+ disabled: PropTypes__default["default"].bool,
71
74
  /**
72
75
  * Specify whether the current menu item is "active".
73
76
  */
@@ -45,6 +45,8 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
45
45
  const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function FilterableMultiSelect(_ref, ref) {
46
46
  let {
47
47
  className: containerClassName,
48
+ clearSelectionDescription,
49
+ clearSelectionText,
48
50
  compareItems,
49
51
  direction,
50
52
  disabled,
@@ -332,11 +334,18 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
332
334
  setIsFocused(evt.type === 'focus' ? true : false);
333
335
  }
334
336
  };
337
+ const clearSelectionContent = selectedItems.length > 0 ? /*#__PURE__*/React__default["default"].createElement("span", {
338
+ className: `${prefix}--visually-hidden`
339
+ }, clearSelectionDescription, " ", selectedItems.length, ",", clearSelectionText) : /*#__PURE__*/React__default["default"].createElement("span", {
340
+ className: `${prefix}--visually-hidden`
341
+ }, clearSelectionDescription, ": 0");
335
342
  return /*#__PURE__*/React__default["default"].createElement("div", {
336
343
  className: wrapperClasses
337
344
  }, titleText ? /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
338
345
  className: titleClasses
339
- }, labelProps), titleText) : null, /*#__PURE__*/React__default["default"].createElement(index["default"], {
346
+ }, labelProps), titleText, /*#__PURE__*/React__default["default"].createElement("span", {
347
+ className: `${prefix}--visually-hidden`
348
+ }, clearSelectionContent)) : null, /*#__PURE__*/React__default["default"].createElement(index["default"], {
340
349
  onFocus: isFluid ? handleFocus : null,
341
350
  onBlur: isFluid ? handleFocus : null,
342
351
  className: className,
@@ -397,12 +406,13 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
397
406
  compareItems,
398
407
  locale
399
408
  }).map((item, index$1) => {
409
+ const isChecked = selectedItem.filter(selected => isEqual__default["default"](selected, item)).length > 0;
400
410
  const itemProps = getItemProps({
401
411
  item,
402
- disabled: item.disabled
412
+ disabled: item.disabled,
413
+ ['aria-selected']: isChecked
403
414
  });
404
415
  const itemText = itemToString(item);
405
- const isChecked = selectedItem.filter(selected => isEqual__default["default"](selected, item)).length > 0;
406
416
  return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
407
417
  key: itemProps.id,
408
418
  "aria-label": itemText,
@@ -435,6 +445,14 @@ FilterableMultiSelect.propTypes = {
435
445
  * Specify a label to be read by screen readers on the container note.
436
446
  */
437
447
  ariaLabel: deprecate["default"](PropTypes__default["default"].string, 'ariaLabel / aria-label props are no longer required for FilterableMultiSelect'),
448
+ /**
449
+ * Specify the text that should be read for screen readers that describes total items selected
450
+ */
451
+ clearSelectionDescription: PropTypes__default["default"].string,
452
+ /**
453
+ * Specify the text that should be read for screen readers to clear selection.
454
+ */
455
+ clearSelectionText: PropTypes__default["default"].string,
438
456
  /**
439
457
  * Specify the direction of the multiselect dropdown. Can be either top or bottom.
440
458
  */
@@ -556,7 +574,9 @@ FilterableMultiSelect.defaultProps = {
556
574
  locale: 'en',
557
575
  sortItems: sorting.defaultSortItems,
558
576
  open: false,
559
- selectionFeedback: 'top-after-reopen'
577
+ selectionFeedback: 'top-after-reopen',
578
+ clearSelectionText: 'To clear selection, press Delete or Backspace,',
579
+ clearSelectionDescription: 'Total items selected: '
560
580
  };
561
581
  var FilterableMultiSelect$1 = FilterableMultiSelect;
562
582