@carbon/react 1.24.0 → 1.25.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 (131) hide show
  1. package/es/components/CodeSnippet/CodeSnippet.js +13 -115
  2. package/es/components/ComboBox/ComboBox.d.ts +6 -0
  3. package/es/components/ComboBox/ComboBox.js +19 -172
  4. package/es/components/ComboButton/index.js +164 -0
  5. package/es/components/ComposedModal/ComposedModal.js +1 -2
  6. package/es/components/DataTable/TableToolbar.d.ts +19 -0
  7. package/es/components/DataTable/TableToolbar.js +1 -1
  8. package/es/components/DataTable/TableToolbarAction.d.ts +21 -0
  9. package/es/components/DataTable/TableToolbarContent.d.ts +21 -0
  10. package/es/components/DataTable/TableToolbarMenu.d.ts +24 -0
  11. package/es/components/DataTable/TableToolbarMenu.js +3 -3
  12. package/es/components/DataTable/tools/sorting.js +2 -1
  13. package/es/components/DataTableSkeleton/DataTableSkeleton.d.ts +107 -0
  14. package/es/components/Dropdown/Dropdown.d.ts +6 -0
  15. package/es/components/Dropdown/Dropdown.js +8 -145
  16. package/es/components/FileUploader/FileUploader.js +1 -1
  17. package/es/components/FileUploader/FileUploaderDropContainer.js +30 -18
  18. package/es/components/FileUploader/FileUploaderItem.js +2 -1
  19. package/es/components/FileUploader/Filename.js +8 -2
  20. package/es/components/FluidTextArea/FluidTextArea.js +12 -1
  21. package/es/components/IconButton/index.js +1 -0
  22. package/es/components/ListBox/ListBoxSelection.js +4 -23
  23. package/es/components/ListBox/next/ListBoxSelection.js +2 -23
  24. package/es/components/Menu/Menu.js +50 -29
  25. package/es/components/Menu/MenuItem.js +1 -0
  26. package/es/components/MenuButton/index.js +127 -0
  27. package/es/components/Modal/Modal.js +4 -3
  28. package/es/components/MultiSelect/FilterableMultiSelect.js +31 -137
  29. package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
  30. package/es/components/MultiSelect/MultiSelect.js +48 -26
  31. package/es/components/Notification/Notification.js +27 -264
  32. package/es/components/OverflowMenu/OverflowMenu.js +13 -139
  33. package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +58 -0
  34. package/es/components/OverflowMenuItem/OverflowMenuItem.js +12 -7
  35. package/es/components/OverflowMenuV2/index.js +15 -51
  36. package/es/components/Popover/index.d.ts +5 -1
  37. package/es/components/Popover/index.js +37 -9
  38. package/es/components/RadioButtonGroup/RadioButtonGroup.js +7 -4
  39. package/es/components/RadioTile/RadioTile.js +6 -6
  40. package/es/components/Select/Select.d.ts +89 -0
  41. package/es/components/SelectItem/SelectItem.d.ts +62 -0
  42. package/es/components/SelectItem/SelectItem.js +2 -4
  43. package/es/components/SelectItemGroup/SelectItemGroup.d.ts +52 -0
  44. package/es/components/SkeletonText/SkeletonText.js +1 -1
  45. package/es/components/StructuredList/StructuredList.js +10 -38
  46. package/es/components/Tabs/Tabs.js +3 -1
  47. package/es/components/TextArea/TextArea.Skeleton.d.ts +33 -0
  48. package/es/components/TextArea/TextArea.Skeleton.js +5 -5
  49. package/es/components/TextArea/TextArea.d.ts +9 -2
  50. package/es/components/TextArea/TextArea.js +31 -8
  51. package/es/components/TextArea/index.js +1 -0
  52. package/es/components/Toggle/Toggle.js +8 -19
  53. package/es/components/Tooltip/DefinitionTooltip.d.ts +52 -0
  54. package/es/components/Tooltip/DefinitionTooltip.js +2 -2
  55. package/es/components/Tooltip/Tooltip.d.ts +117 -0
  56. package/es/components/Tooltip/Tooltip.js +6 -4
  57. package/es/components/Tooltip/index.d.ts +9 -0
  58. package/es/index.d.ts +2 -0
  59. package/es/index.js +5 -3
  60. package/es/internal/ClickListener.js +1 -2
  61. package/es/internal/keyboard/match.js +1 -1
  62. package/es/internal/useAttachedMenu.js +85 -0
  63. package/es/internal/useDelayedState.d.ts +19 -0
  64. package/es/internal/useDelayedState.js +7 -3
  65. package/es/internal/useId.js +1 -1
  66. package/lib/components/CodeSnippet/CodeSnippet.js +13 -115
  67. package/lib/components/ComboBox/ComboBox.d.ts +6 -0
  68. package/lib/components/ComboBox/ComboBox.js +18 -171
  69. package/lib/components/ComboButton/index.js +174 -0
  70. package/lib/components/ComposedModal/ComposedModal.js +1 -2
  71. package/lib/components/DataTable/TableToolbar.d.ts +19 -0
  72. package/lib/components/DataTable/TableToolbar.js +1 -1
  73. package/lib/components/DataTable/TableToolbarAction.d.ts +21 -0
  74. package/lib/components/DataTable/TableToolbarContent.d.ts +21 -0
  75. package/lib/components/DataTable/TableToolbarMenu.d.ts +24 -0
  76. package/lib/components/DataTable/TableToolbarMenu.js +3 -3
  77. package/lib/components/DataTable/tools/sorting.js +2 -1
  78. package/lib/components/DataTableSkeleton/DataTableSkeleton.d.ts +107 -0
  79. package/lib/components/Dropdown/Dropdown.d.ts +6 -0
  80. package/lib/components/Dropdown/Dropdown.js +7 -144
  81. package/lib/components/FileUploader/FileUploader.js +1 -1
  82. package/lib/components/FileUploader/FileUploaderDropContainer.js +30 -18
  83. package/lib/components/FileUploader/FileUploaderItem.js +2 -1
  84. package/lib/components/FileUploader/Filename.js +8 -2
  85. package/lib/components/FluidTextArea/FluidTextArea.js +12 -1
  86. package/lib/components/IconButton/index.js +1 -0
  87. package/lib/components/ListBox/ListBoxSelection.js +4 -23
  88. package/lib/components/ListBox/next/ListBoxSelection.js +2 -23
  89. package/lib/components/Menu/Menu.js +50 -29
  90. package/lib/components/Menu/MenuItem.js +1 -0
  91. package/lib/components/MenuButton/index.js +137 -0
  92. package/lib/components/Modal/Modal.js +4 -3
  93. package/lib/components/MultiSelect/FilterableMultiSelect.js +29 -135
  94. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  95. package/lib/components/MultiSelect/MultiSelect.js +47 -25
  96. package/lib/components/Notification/Notification.js +27 -264
  97. package/lib/components/OverflowMenu/OverflowMenu.js +13 -139
  98. package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +58 -0
  99. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +12 -7
  100. package/lib/components/OverflowMenuV2/index.js +13 -49
  101. package/lib/components/Popover/index.d.ts +5 -1
  102. package/lib/components/Popover/index.js +37 -9
  103. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +6 -3
  104. package/lib/components/RadioTile/RadioTile.js +6 -6
  105. package/lib/components/Select/Select.d.ts +89 -0
  106. package/lib/components/SelectItem/SelectItem.d.ts +62 -0
  107. package/lib/components/SelectItem/SelectItem.js +1 -3
  108. package/lib/components/SelectItemGroup/SelectItemGroup.d.ts +52 -0
  109. package/lib/components/SkeletonText/SkeletonText.js +1 -1
  110. package/lib/components/StructuredList/StructuredList.js +10 -38
  111. package/lib/components/Tabs/Tabs.js +3 -1
  112. package/lib/components/TextArea/TextArea.Skeleton.d.ts +33 -0
  113. package/lib/components/TextArea/TextArea.Skeleton.js +5 -5
  114. package/lib/components/TextArea/TextArea.d.ts +9 -2
  115. package/lib/components/TextArea/TextArea.js +30 -7
  116. package/lib/components/TextArea/index.js +2 -0
  117. package/lib/components/Toggle/Toggle.js +8 -19
  118. package/lib/components/Tooltip/DefinitionTooltip.d.ts +52 -0
  119. package/lib/components/Tooltip/DefinitionTooltip.js +2 -2
  120. package/lib/components/Tooltip/Tooltip.d.ts +117 -0
  121. package/lib/components/Tooltip/Tooltip.js +6 -4
  122. package/lib/components/Tooltip/index.d.ts +9 -0
  123. package/lib/index.d.ts +2 -0
  124. package/lib/index.js +50 -46
  125. package/lib/internal/ClickListener.js +1 -2
  126. package/lib/internal/keyboard/match.js +1 -1
  127. package/lib/internal/useAttachedMenu.js +89 -0
  128. package/lib/internal/useDelayedState.d.ts +19 -0
  129. package/lib/internal/useDelayedState.js +7 -3
  130. package/lib/internal/useId.js +1 -1
  131. package/package.json +3 -3
@@ -11,8 +11,6 @@ import React__default from 'react';
11
11
  import PropTypes from 'prop-types';
12
12
  import { Close } from '@carbon/icons-react';
13
13
  import { usePrefix } from '../../../internal/usePrefix.js';
14
- import { match } from '../../../internal/keyboard/match.js';
15
- import { Enter } from '../../../internal/keyboard/keys.js';
16
14
 
17
15
  var _Close, _Close2, _defaultTranslations;
18
16
 
@@ -52,23 +50,6 @@ function ListBoxSelection(_ref) {
52
50
  }
53
51
  }
54
52
 
55
- function onKeyDown(event) {
56
- event.stopPropagation();
57
-
58
- if (disabled) {
59
- return;
60
- } // When a user hits ENTER, we'll clear the selection
61
-
62
-
63
- if (match(event, Enter)) {
64
- clearSelection(event);
65
-
66
- if (onClearSelection) {
67
- onClearSelection(event);
68
- }
69
- }
70
- }
71
-
72
53
  if (selectionCount) {
73
54
  return /*#__PURE__*/React__default.createElement("div", {
74
55
  className: tagClasses
@@ -80,8 +61,7 @@ function ListBoxSelection(_ref) {
80
61
  className: "".concat(prefix, "--tag__close-icon"),
81
62
  disabled: disabled,
82
63
  onClick: onClick,
83
- onKeyDown: onKeyDown,
84
- tabIndex: disabled ? -1 : 0,
64
+ tabIndex: -1,
85
65
  title: description,
86
66
  type: "button"
87
67
  }, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null))));
@@ -92,8 +72,7 @@ function ListBoxSelection(_ref) {
92
72
  className: className,
93
73
  disabled: disabled,
94
74
  onClick: onClick,
95
- onKeyDown: onKeyDown,
96
- tabIndex: disabled ? -1 : 0,
75
+ tabIndex: -1,
97
76
  title: description,
98
77
  type: "button"
99
78
  }), _Close2 || (_Close2 = /*#__PURE__*/React__default.createElement(Close, null)));
@@ -16,7 +16,7 @@ import { MenuContext, menuReducer } from './MenuContext.js';
16
16
  import { match } from '../../internal/keyboard/match.js';
17
17
  import { Escape, ArrowLeft, ArrowUp, ArrowDown } from '../../internal/keyboard/keys.js';
18
18
 
19
- var _excluded = ["children", "className", "label", "onClose", "open", "size", "target", "x", "y"];
19
+ var _excluded = ["children", "className", "label", "onClose", "onOpen", "open", "size", "target", "x", "y"];
20
20
  var spacing = 8; // distance to keep to window edges, in px
21
21
 
22
22
  var Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardRef) {
@@ -26,6 +26,7 @@ var Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardRef
26
26
  className = _ref.className,
27
27
  label = _ref.label,
28
28
  onClose = _ref.onClose,
29
+ onOpen = _ref.onOpen,
29
30
  open = _ref.open,
30
31
  _ref$size = _ref.size,
31
32
  size = _ref$size === void 0 ? 'sm' : _ref$size,
@@ -67,7 +68,7 @@ var Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardRef
67
68
  setPosition = _useState2[1];
68
69
 
69
70
  var focusableItems = childContext.state.items.filter(function (item) {
70
- return !item.disabled;
71
+ return !item.disabled && item.ref.current;
71
72
  });
72
73
 
73
74
  function returnFocus() {
@@ -79,8 +80,15 @@ var Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardRef
79
80
  function handleOpen() {
80
81
  if (menu.current) {
81
82
  focusReturn.current = document.activeElement;
82
- setPosition(calculatePosition());
83
+ var pos = calculatePosition();
84
+ menu.current.style.left = "".concat(pos[0], "px");
85
+ menu.current.style.top = "".concat(pos[1], "px");
86
+ setPosition(pos);
83
87
  menu.current.focus();
88
+
89
+ if (onOpen) {
90
+ onOpen();
91
+ }
84
92
  }
85
93
  }
86
94
 
@@ -103,39 +111,46 @@ var Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardRef
103
111
  }
104
112
 
105
113
  function handleKeyDown(e) {
106
- e.stopPropagation();
107
- var currentItem = focusableItems.findIndex(function (item) {
108
- return item.ref.current.contains(document.activeElement);
109
- });
110
- var indexToFocus = currentItem; // if the user presses escape or this is a submenu
114
+ e.stopPropagation(); // if the user presses escape or this is a submenu
111
115
  // and the user presses ArrowLeft, close it
112
116
 
113
117
  if ((match(e, Escape) || !isRoot && match(e, ArrowLeft)) && onClose) {
114
118
  handleClose(e);
115
119
  } else {
116
- // if currentItem is -1, the menu itself is focused.
117
- // in this case, the arrow keys define the first item
118
- // to be focused.
120
+ focusItem(e);
121
+ }
122
+ }
123
+
124
+ function focusItem(e) {
125
+ var currentItem = focusableItems.findIndex(function (item) {
126
+ return item.ref.current.contains(document.activeElement);
127
+ });
128
+ var indexToFocus = currentItem; // if currentItem is -1, no menu item is focused yet.
129
+ // in this case, the first item should receive focus.
130
+
131
+ if (currentItem === -1) {
132
+ indexToFocus = 0;
133
+ } else if (e) {
119
134
  if (match(e, ArrowUp)) {
120
- indexToFocus = currentItem === -1 ? focusableItems.length - 1 : indexToFocus - 1;
135
+ indexToFocus = indexToFocus - 1;
121
136
  }
122
137
 
123
138
  if (match(e, ArrowDown)) {
124
- indexToFocus = currentItem === -1 ? 0 : indexToFocus + 1;
139
+ indexToFocus = indexToFocus + 1;
125
140
  }
141
+ }
126
142
 
127
- if (indexToFocus < 0) {
128
- indexToFocus = 0;
129
- }
143
+ if (indexToFocus < 0) {
144
+ indexToFocus = focusableItems.length - 1;
145
+ }
130
146
 
131
- if (indexToFocus >= focusableItems.length) {
132
- indexToFocus = focusableItems.length - 1;
133
- }
147
+ if (indexToFocus >= focusableItems.length) {
148
+ indexToFocus = 0;
149
+ }
134
150
 
135
- if (indexToFocus !== currentItem) {
136
- var nodeToFocus = focusableItems[indexToFocus];
137
- nodeToFocus.ref.current.focus();
138
- }
151
+ if (indexToFocus !== currentItem) {
152
+ var nodeToFocus = focusableItems[indexToFocus];
153
+ nodeToFocus.ref.current.focus();
139
154
  }
140
155
  }
141
156
 
@@ -197,6 +212,12 @@ var Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardRef
197
212
  return [-1, -1];
198
213
  }
199
214
 
215
+ useEffect(function () {
216
+ if (open && focusableItems.length > 0) {
217
+ focusItem();
218
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
219
+
220
+ }, [open, focusableItems]);
200
221
  useEffect(function () {
201
222
  if (open) {
202
223
  handleOpen();
@@ -217,12 +238,7 @@ var Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardRef
217
238
  "aria-label": label,
218
239
  tabIndex: -1,
219
240
  onKeyDown: handleKeyDown,
220
- onBlur: handleBlur // eslint-disable-next-line react/forbid-dom-props
221
- ,
222
- style: {
223
- left: "".concat(position[0], "px"),
224
- top: "".concat(position[1], "px")
225
- }
241
+ onBlur: handleBlur
226
242
  }), children));
227
243
  return isRoot ? open && /*#__PURE__*/createPortal(rendered, target) || null : rendered;
228
244
  });
@@ -247,6 +263,11 @@ Menu.propTypes = {
247
263
  */
248
264
  onClose: PropTypes.func,
249
265
 
266
+ /**
267
+ * Provide an optional function to be called when the Menu is opened.
268
+ */
269
+ onOpen: PropTypes.func,
270
+
250
271
  /**
251
272
  * Whether the Menu is open or not.
252
273
  */
@@ -126,6 +126,7 @@ var MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref, fo
126
126
  function handleKeyDown(e) {
127
127
  if (hasChildren && match(e, ArrowRight)) {
128
128
  openSubmenu();
129
+ e.stopPropagation();
129
130
  }
130
131
 
131
132
  if (match(e, Enter) || match(e, Space)) {
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React__default, { useRef, useState } from 'react';
10
+ import PropTypes from 'prop-types';
11
+ import cx from 'classnames';
12
+ import { ChevronDown } from '@carbon/icons-react';
13
+ import Button from '../Button/Button.js';
14
+ import { Menu } from '../Menu/Menu.js';
15
+ import { useAttachedMenu } from '../../internal/useAttachedMenu.js';
16
+ import { useId } from '../../internal/useId.js';
17
+ import { useMergedRefs } from '../../internal/useMergedRefs.js';
18
+ import { usePrefix } from '../../internal/usePrefix.js';
19
+
20
+ var _excluded = ["children", "className", "disabled", "kind", "label", "size"];
21
+ var spacing = 4; // top and bottom spacing between the button and the menu. in px
22
+
23
+ var validButtonKinds = ['primary', 'tertiary', 'ghost'];
24
+ var defaultButtonKind = 'primary';
25
+ var MenuButton = /*#__PURE__*/React__default.forwardRef(function MenuButton(_ref, forwardRef) {
26
+ var children = _ref.children,
27
+ className = _ref.className,
28
+ disabled = _ref.disabled,
29
+ _ref$kind = _ref.kind,
30
+ kind = _ref$kind === void 0 ? defaultButtonKind : _ref$kind,
31
+ label = _ref.label,
32
+ _ref$size = _ref.size,
33
+ size = _ref$size === void 0 ? 'lg' : _ref$size,
34
+ rest = _objectWithoutProperties(_ref, _excluded);
35
+
36
+ var id = useId('MenuButton');
37
+ var prefix = usePrefix();
38
+ var triggerRef = useRef(null);
39
+ var menuRef = useRef(null);
40
+ var ref = useMergedRefs([forwardRef, triggerRef]);
41
+
42
+ var _useState = useState(0),
43
+ _useState2 = _slicedToArray(_useState, 2),
44
+ width = _useState2[0],
45
+ setWidth = _useState2[1];
46
+
47
+ var _useAttachedMenu = useAttachedMenu(triggerRef),
48
+ open = _useAttachedMenu.open,
49
+ x = _useAttachedMenu.x,
50
+ y = _useAttachedMenu.y,
51
+ hookOnClick = _useAttachedMenu.handleClick,
52
+ handleMousedown = _useAttachedMenu.handleMousedown,
53
+ handleClose = _useAttachedMenu.handleClose;
54
+
55
+ function handleClick() {
56
+ if (triggerRef.current) {
57
+ var _triggerRef$current$g = triggerRef.current.getBoundingClientRect(),
58
+ w = _triggerRef$current$g.width;
59
+
60
+ setWidth(w);
61
+ hookOnClick();
62
+ }
63
+ }
64
+
65
+ function handleOpen() {
66
+ menuRef.current.style.width = "".concat(width, "px");
67
+ }
68
+
69
+ var triggerClasses = cx("".concat(prefix, "--menu-button__trigger"), _defineProperty({}, "".concat(prefix, "--menu-button__trigger--open"), open), className);
70
+ var buttonKind = validButtonKinds.includes(kind) ? kind : defaultButtonKind;
71
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button, _extends({}, rest, {
72
+ ref: ref,
73
+ className: triggerClasses,
74
+ size: size,
75
+ kind: buttonKind,
76
+ renderIcon: ChevronDown,
77
+ disabled: disabled,
78
+ "aria-haspopup": true,
79
+ "aria-expanded": open,
80
+ onClick: handleClick,
81
+ onMouseDown: handleMousedown,
82
+ "aria-owns": open ? id : null
83
+ }), label), /*#__PURE__*/React__default.createElement(Menu, {
84
+ ref: menuRef,
85
+ id: id,
86
+ label: label,
87
+ size: size,
88
+ open: open,
89
+ onClose: handleClose,
90
+ onOpen: handleOpen,
91
+ x: x,
92
+ y: [y[0] - spacing, y[1] + spacing]
93
+ }, children));
94
+ });
95
+ MenuButton.propTypes = {
96
+ /**
97
+ * A collection of MenuItems to be rendered as actions for this MenuButton.
98
+ */
99
+ children: PropTypes.node.isRequired,
100
+
101
+ /**
102
+ * Additional CSS class names.
103
+ */
104
+ className: PropTypes.string,
105
+
106
+ /**
107
+ * Specify whether the MenuButton should be disabled, or not.
108
+ */
109
+ disabled: PropTypes.bool,
110
+
111
+ /**
112
+ * Specify the type of button to be used as the base for the trigger button.
113
+ */
114
+ kind: PropTypes.oneOf(validButtonKinds),
115
+
116
+ /**
117
+ * Provide the label to be renderd on the trigger button.
118
+ */
119
+ label: PropTypes.string.isRequired,
120
+
121
+ /**
122
+ * Specify the size of the button and menu.
123
+ */
124
+ size: PropTypes.oneOf(['sm', 'md', 'lg'])
125
+ };
126
+
127
+ export { MenuButton };
@@ -20,12 +20,13 @@ import { usePrefix } from '../../internal/usePrefix.js';
20
20
 
21
21
  var _Modal$propTypes;
22
22
 
23
- var _excluded = ["children", "className", "modalHeading", "modalLabel", "modalAriaLabel", "passiveModal", "secondaryButtonText", "primaryButtonText", "open", "onRequestClose", "onRequestSubmit", "onSecondarySubmit", "primaryButtonDisabled", "danger", "alert", "secondaryButtons", "selectorPrimaryFocus", "selectorsFloatingMenus", "shouldSubmitOnEnter", "size", "hasScrollingContent", "closeButtonLabel", "preventCloseOnClickOutside", "isFullWidth"];
23
+ var _excluded = ["aria-label", "children", "className", "modalHeading", "modalLabel", "modalAriaLabel", "passiveModal", "secondaryButtonText", "primaryButtonText", "open", "onRequestClose", "onRequestSubmit", "onSecondarySubmit", "primaryButtonDisabled", "danger", "alert", "secondaryButtons", "selectorPrimaryFocus", "selectorsFloatingMenus", "shouldSubmitOnEnter", "size", "hasScrollingContent", "closeButtonLabel", "preventCloseOnClickOutside", "isFullWidth"];
24
24
  var getInstanceId = setupGetInstanceId();
25
25
  var Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
26
26
  var _classNames, _classNames2;
27
27
 
28
- var children = _ref.children,
28
+ var ariaLabelProp = _ref['aria-label'],
29
+ children = _ref.children,
29
30
  className = _ref.className,
30
31
  modalHeading = _ref.modalHeading,
31
32
  modalLabel = _ref.modalLabel,
@@ -122,7 +123,7 @@ var Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
122
123
  tabIndex: "-1",
123
124
  className: "".concat(modalCloseButtonClass, "__icon")
124
125
  }));
125
- var ariaLabel = modalLabel || rest['aria-label'] || modalAriaLabel || modalHeading;
126
+ var ariaLabel = modalLabel || ariaLabelProp || modalAriaLabel || modalHeading;
126
127
  var getAriaLabelledBy = modalLabel ? modalLabelId : modalHeadingId;
127
128
  var hasScrollingContentProps = hasScrollingContent ? {
128
129
  tabIndex: 0,
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends, objectSpread2 as _objectSpread2$1 } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
10
10
  import cx from 'classnames';
11
11
  import Downshift from 'downshift';
@@ -29,12 +29,14 @@ import { match } from '../../internal/keyboard/match.js';
29
29
  import ListBoxSelection from '../ListBox/next/ListBoxSelection.js';
30
30
  import ListBoxTrigger from '../ListBox/next/ListBoxTrigger.js';
31
31
  import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
32
- import { Space, Tab } from '../../internal/keyboard/keys.js';
32
+ import { Space, Enter, Delete, Escape, Tab } from '../../internal/keyboard/keys.js';
33
33
 
34
+ var _objectSpread2, _FilterableMultiSelec;
34
35
  var FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function FilterableMultiSelect(_ref, ref) {
35
36
  var _cx, _cx2, _cx3, _cx4;
36
37
 
37
- var ariaLabel = _ref.ariaLabel,
38
+ var ariaLabel = _ref['aria-label'],
39
+ deprecatedAriaLabel = _ref.ariaLabel,
38
40
  containerClassName = _ref.className,
39
41
  compareItems = _ref.compareItems,
40
42
  direction = _ref.direction,
@@ -117,7 +119,7 @@ var FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Filt
117
119
 
118
120
  var inline = type === 'inline';
119
121
  var showWarning = !invalid && warn;
120
- var wrapperClasses = cx("".concat(prefix, "--multi-select__wrapper"), "".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null], (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--multi-select__wrapper--inline"), inline), _defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--inline"), inline), _defineProperty(_cx, "".concat(prefix, "--multi-select__wrapper--inline--invalid"), inline && invalid), _defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--inline--invalid"), inline && invalid), _defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--fluid--invalid"), isFluid && invalid), _defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--fluid--focus"), isFluid && isFocused), _cx));
122
+ var wrapperClasses = cx("".concat(prefix, "--multi-select__wrapper"), "".concat(prefix, "--multi-select--filterable__wrapper"), "".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null], (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--multi-select__wrapper--inline"), inline), _defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--inline"), inline), _defineProperty(_cx, "".concat(prefix, "--multi-select__wrapper--inline--invalid"), inline && invalid), _defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--inline--invalid"), inline && invalid), _defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--fluid--invalid"), isFluid && invalid), _defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--fluid--focus"), isFluid && isFocused), _cx));
121
123
  var helperId = !helperText ? undefined : "filterablemultiselect-helper-text-".concat(filterableMultiSelectInstanceId);
122
124
  var labelId = "".concat(id, "-label");
123
125
  var titleClasses = cx((_cx2 = {}, _defineProperty(_cx2, "".concat(prefix, "--label"), true), _defineProperty(_cx2, "".concat(prefix, "--label--disabled"), disabled), _defineProperty(_cx2, "".concat(prefix, "--visually-hidden"), hideLabel), _cx2));
@@ -246,7 +248,7 @@ var FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Filt
246
248
  isOpen = _ref4.isOpen,
247
249
  inputValue = _ref4.inputValue,
248
250
  selectedItem = _ref4.selectedItem;
249
- var className = cx("".concat(prefix, "--multi-select"), "".concat(prefix, "--combo-box"), "".concat(prefix, "--multi-select--filterable"), [enabled ? null : containerClassName], (_cx5 = {}, _defineProperty(_cx5, "".concat(prefix, "--multi-select--invalid"), invalid), _defineProperty(_cx5, "".concat(prefix, "--multi-select--open"), isOpen), _defineProperty(_cx5, "".concat(prefix, "--multi-select--inline"), inline), _defineProperty(_cx5, "".concat(prefix, "--multi-select--selected"), selectedItem.length > 0), _defineProperty(_cx5, "".concat(prefix, "--multi-select--filterable--input-focused"), inputFocused), _cx5));
251
+ var className = cx("".concat(prefix, "--multi-select"), "".concat(prefix, "--combo-box"), "".concat(prefix, "--multi-select--filterable"), [enabled ? null : containerClassName], (_cx5 = {}, _defineProperty(_cx5, "".concat(prefix, "--multi-select--invalid"), invalid), _defineProperty(_cx5, "".concat(prefix, "--multi-select--invalid--focused"), invalid && inputFocused), _defineProperty(_cx5, "".concat(prefix, "--multi-select--open"), isOpen), _defineProperty(_cx5, "".concat(prefix, "--multi-select--inline"), inline), _defineProperty(_cx5, "".concat(prefix, "--multi-select--selected"), selectedItem.length > 0), _defineProperty(_cx5, "".concat(prefix, "--multi-select--filterable--input-focused"), inputFocused), _cx5));
250
252
  var rootProps = getRootProps({}, {
251
253
  suppressRefError: true
252
254
  });
@@ -291,6 +293,26 @@ var FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Filt
291
293
  event.stopPropagation();
292
294
  }
293
295
 
296
+ if (match(event, Enter)) {
297
+ handleOnMenuChange(true);
298
+ }
299
+
300
+ if (!disabled) {
301
+ if (match(event, Delete) || match(event, Escape)) {
302
+ if (isOpen) {
303
+ handleOnMenuChange(true);
304
+ clearInputValue();
305
+ event.stopPropagation();
306
+ } else if (!isOpen) {
307
+ clearInputValue();
308
+
309
+ _clearSelection();
310
+
311
+ event.stopPropagation();
312
+ }
313
+ }
314
+ }
315
+
294
316
  if (match(event, Tab)) {
295
317
  handleOnMenuChange(false);
296
318
  }
@@ -300,6 +322,7 @@ var FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Filt
300
322
  },
301
323
  onBlur: function onBlur() {
302
324
  setInputFocused(false);
325
+ setInputValue('');
303
326
  }
304
327
  });
305
328
  var menuProps = getMenuProps({
@@ -321,6 +344,7 @@ var FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Filt
321
344
  }, titleText ? /*#__PURE__*/React__default.createElement("label", _extends({
322
345
  className: titleClasses
323
346
  }, labelProps), titleText) : null, /*#__PURE__*/React__default.createElement(ListBox, {
347
+ "aria-label": deprecatedAriaLabel || ariaLabel,
324
348
  onFocus: isFluid ? handleFocus : null,
325
349
  onBlur: isFluid ? handleFocus : null,
326
350
  className: className,
@@ -411,125 +435,7 @@ var FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Filt
411
435
  }
412
436
  });
413
437
  });
414
- FilterableMultiSelect.propTypes = _objectSpread2(_objectSpread2({
415
- /**
416
- * 'aria-label' of the ListBox component.
417
- */
418
- ariaLabel: PropTypes.string,
419
-
420
- /**
421
- * Specify the direction of the multiselect dropdown. Can be either top or bottom.
422
- */
423
- direction: PropTypes.oneOf(['top', 'bottom']),
424
-
425
- /**
426
- * Disable the control
427
- */
428
- disabled: PropTypes.bool,
429
-
430
- /**
431
- * Additional props passed to Downshift
432
- */
433
- downshiftProps: PropTypes.shape(Downshift.propTypes),
434
-
435
- /**
436
- * Specify whether the title text should be hidden or not
437
- */
438
- hideLabel: PropTypes.bool,
439
-
440
- /**
441
- * Specify a custom `id`
442
- */
443
- id: PropTypes.string.isRequired,
444
-
445
- /**
446
- * Allow users to pass in arbitrary items from their collection that are
447
- * pre-selected
448
- */
449
- initialSelectedItems: PropTypes.array,
450
-
451
- /**
452
- * Is the current selection invalid?
453
- */
454
- invalid: PropTypes.bool,
455
-
456
- /**
457
- * If invalid, what is the error?
458
- */
459
- invalidText: PropTypes.node,
460
-
461
- /**
462
- * Function to render items as custom components instead of strings.
463
- * Defaults to null and is overridden by a getter
464
- */
465
- itemToElement: PropTypes.func,
466
-
467
- /**
468
- * Helper function passed to downshift that allows the library to render a
469
- * given item to a string label. By default, it extracts the `label` field
470
- * from a given item to serve as the item label in the list.
471
- */
472
- itemToString: PropTypes.func,
473
-
474
- /**
475
- * We try to stay as generic as possible here to allow individuals to pass
476
- * in a collection of whatever kind of data structure they prefer
477
- */
478
- items: PropTypes.array.isRequired,
479
-
480
- /**
481
- * `true` to use the light version.
482
- */
483
- light: deprecate(PropTypes.bool, 'The `light` prop for `FilterableMultiSelect` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
484
-
485
- /**
486
- * Specify the locale of the control. Used for the default `compareItems`
487
- * used for sorting the list of items in the control.
488
- */
489
- locale: PropTypes.string,
490
-
491
- /**
492
- * `onChange` is a utility for this controlled component to communicate to a
493
- * consuming component what kind of internal state changes are occurring.
494
- */
495
- onChange: PropTypes.func,
496
-
497
- /**
498
- * `onInputValueChange` is a utility for this controlled component to communicate to
499
- * the currently typed input.
500
- */
501
- onInputValueChange: PropTypes.func,
502
-
503
- /**
504
- * `onMenuChange` is a utility for this controlled component to communicate to a
505
- * consuming component that the menu was opened(`true`)/closed(`false`).
506
- */
507
- onMenuChange: PropTypes.func,
508
-
509
- /**
510
- * Initialize the component with an open(`true`)/closed(`false`) menu.
511
- */
512
- open: PropTypes.bool,
513
-
514
- /**
515
- * Generic `placeholder` that will be used as the textual representation of
516
- * what this field is for
517
- */
518
- placeholder: PropTypes.string,
519
-
520
- /**
521
- * Specify feedback (mode) of the selection.
522
- * `top`: selected item jumps to top
523
- * `fixed`: selected item stays at it's position
524
- * `top-after-reopen`: selected item jump to top after reopen dropdown
525
- */
526
- selectionFeedback: PropTypes.oneOf(['top', 'fixed', 'top-after-reopen']),
527
-
528
- /**
529
- * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
530
- */
531
- size: ListBoxSize
532
- }, sortingPropTypes), {}, {
438
+ FilterableMultiSelect.propTypes = _objectSpread2$1(_objectSpread2$1((_objectSpread2 = {}, _defineProperty(_objectSpread2, 'aria-label', PropTypes.string), _defineProperty(_objectSpread2, "ariaLabel", deprecate(PropTypes.string, 'This prop syntax has been deprecated. Please use the new `aria-label`.')), _defineProperty(_objectSpread2, "direction", PropTypes.oneOf(['top', 'bottom'])), _defineProperty(_objectSpread2, "disabled", PropTypes.bool), _defineProperty(_objectSpread2, "downshiftProps", PropTypes.shape(Downshift.propTypes)), _defineProperty(_objectSpread2, "hideLabel", PropTypes.bool), _defineProperty(_objectSpread2, "id", PropTypes.string.isRequired), _defineProperty(_objectSpread2, "initialSelectedItems", PropTypes.array), _defineProperty(_objectSpread2, "invalid", PropTypes.bool), _defineProperty(_objectSpread2, "invalidText", PropTypes.node), _defineProperty(_objectSpread2, "itemToElement", PropTypes.func), _defineProperty(_objectSpread2, "itemToString", PropTypes.func), _defineProperty(_objectSpread2, "items", PropTypes.array.isRequired), _defineProperty(_objectSpread2, "light", deprecate(PropTypes.bool, 'The `light` prop for `FilterableMultiSelect` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.')), _defineProperty(_objectSpread2, "locale", PropTypes.string), _defineProperty(_objectSpread2, "onChange", PropTypes.func), _defineProperty(_objectSpread2, "onInputValueChange", PropTypes.func), _defineProperty(_objectSpread2, "onMenuChange", PropTypes.func), _defineProperty(_objectSpread2, "open", PropTypes.bool), _defineProperty(_objectSpread2, "placeholder", PropTypes.string), _defineProperty(_objectSpread2, "selectionFeedback", PropTypes.oneOf(['top', 'fixed', 'top-after-reopen'])), _defineProperty(_objectSpread2, "size", ListBoxSize), _objectSpread2), sortingPropTypes), {}, {
533
439
  /**
534
440
  * Callback function for translating ListBoxMenuIcon SVG title
535
441
  */
@@ -550,19 +456,7 @@ FilterableMultiSelect.propTypes = _objectSpread2(_objectSpread2({
550
456
  */
551
457
  warnText: PropTypes.node
552
458
  });
553
- FilterableMultiSelect.defaultProps = {
554
- ariaLabel: 'Choose an item',
555
- compareItems: defaultCompareItems,
556
- direction: 'bottom',
557
- disabled: false,
558
- filterItems: defaultFilterItems,
559
- initialSelectedItems: [],
560
- itemToString: defaultItemToString,
561
- locale: 'en',
562
- sortItems: defaultSortItems,
563
- open: false,
564
- selectionFeedback: 'top-after-reopen'
565
- };
459
+ FilterableMultiSelect.defaultProps = (_FilterableMultiSelec = {}, _defineProperty(_FilterableMultiSelec, 'aria-label', 'Choose an item'), _defineProperty(_FilterableMultiSelec, "compareItems", defaultCompareItems), _defineProperty(_FilterableMultiSelec, "direction", 'bottom'), _defineProperty(_FilterableMultiSelec, "disabled", false), _defineProperty(_FilterableMultiSelec, "filterItems", defaultFilterItems), _defineProperty(_FilterableMultiSelec, "initialSelectedItems", []), _defineProperty(_FilterableMultiSelec, "itemToString", defaultItemToString), _defineProperty(_FilterableMultiSelec, "locale", 'en'), _defineProperty(_FilterableMultiSelec, "sortItems", defaultSortItems), _defineProperty(_FilterableMultiSelec, "open", false), _defineProperty(_FilterableMultiSelec, "selectionFeedback", 'top-after-reopen'), _FilterableMultiSelec);
566
460
  var FilterableMultiSelect$1 = FilterableMultiSelect;
567
461
 
568
462
  export { FilterableMultiSelect$1 as default };
@@ -114,7 +114,7 @@ export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<Item
114
114
  onChange?(data: OnChangeData<ItemType>): void;
115
115
  /**
116
116
  * `onMenuChange` is a utility for this controlled component to communicate to a
117
- * consuming component that the menu was opend(`true`)/closed(`false`).
117
+ * consuming component that the menu was open(`true`)/closed(`false`).
118
118
  */
119
119
  onMenuChange?(open: boolean): void;
120
120
  /**