@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
@@ -0,0 +1,137 @@
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
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
+ var React = require('react');
14
+ var PropTypes = require('prop-types');
15
+ var cx = require('classnames');
16
+ var iconsReact = require('@carbon/icons-react');
17
+ var Button = require('../Button/Button.js');
18
+ var Menu = require('../Menu/Menu.js');
19
+ var useAttachedMenu = require('../../internal/useAttachedMenu.js');
20
+ var useId = require('../../internal/useId.js');
21
+ var useMergedRefs = require('../../internal/useMergedRefs.js');
22
+ var usePrefix = require('../../internal/usePrefix.js');
23
+
24
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
25
+
26
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
27
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
28
+ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
29
+
30
+ var _excluded = ["children", "className", "disabled", "kind", "label", "size"];
31
+ var spacing = 4; // top and bottom spacing between the button and the menu. in px
32
+
33
+ var validButtonKinds = ['primary', 'tertiary', 'ghost'];
34
+ var defaultButtonKind = 'primary';
35
+ var MenuButton = /*#__PURE__*/React__default["default"].forwardRef(function MenuButton(_ref, forwardRef) {
36
+ var children = _ref.children,
37
+ className = _ref.className,
38
+ disabled = _ref.disabled,
39
+ _ref$kind = _ref.kind,
40
+ kind = _ref$kind === void 0 ? defaultButtonKind : _ref$kind,
41
+ label = _ref.label,
42
+ _ref$size = _ref.size,
43
+ size = _ref$size === void 0 ? 'lg' : _ref$size,
44
+ rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
45
+
46
+ var id = useId.useId('MenuButton');
47
+ var prefix = usePrefix.usePrefix();
48
+ var triggerRef = React.useRef(null);
49
+ var menuRef = React.useRef(null);
50
+ var ref = useMergedRefs.useMergedRefs([forwardRef, triggerRef]);
51
+
52
+ var _useState = React.useState(0),
53
+ _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
54
+ width = _useState2[0],
55
+ setWidth = _useState2[1];
56
+
57
+ var _useAttachedMenu = useAttachedMenu.useAttachedMenu(triggerRef),
58
+ open = _useAttachedMenu.open,
59
+ x = _useAttachedMenu.x,
60
+ y = _useAttachedMenu.y,
61
+ hookOnClick = _useAttachedMenu.handleClick,
62
+ handleMousedown = _useAttachedMenu.handleMousedown,
63
+ handleClose = _useAttachedMenu.handleClose;
64
+
65
+ function handleClick() {
66
+ if (triggerRef.current) {
67
+ var _triggerRef$current$g = triggerRef.current.getBoundingClientRect(),
68
+ w = _triggerRef$current$g.width;
69
+
70
+ setWidth(w);
71
+ hookOnClick();
72
+ }
73
+ }
74
+
75
+ function handleOpen() {
76
+ menuRef.current.style.width = "".concat(width, "px");
77
+ }
78
+
79
+ var triggerClasses = cx__default["default"]("".concat(prefix, "--menu-button__trigger"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--menu-button__trigger--open"), open), className);
80
+ var buttonKind = validButtonKinds.includes(kind) ? kind : defaultButtonKind;
81
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Button["default"], _rollupPluginBabelHelpers["extends"]({}, rest, {
82
+ ref: ref,
83
+ className: triggerClasses,
84
+ size: size,
85
+ kind: buttonKind,
86
+ renderIcon: iconsReact.ChevronDown,
87
+ disabled: disabled,
88
+ "aria-haspopup": true,
89
+ "aria-expanded": open,
90
+ onClick: handleClick,
91
+ onMouseDown: handleMousedown,
92
+ "aria-owns": open ? id : null
93
+ }), label), /*#__PURE__*/React__default["default"].createElement(Menu.Menu, {
94
+ ref: menuRef,
95
+ id: id,
96
+ label: label,
97
+ size: size,
98
+ open: open,
99
+ onClose: handleClose,
100
+ onOpen: handleOpen,
101
+ x: x,
102
+ y: [y[0] - spacing, y[1] + spacing]
103
+ }, children));
104
+ });
105
+ MenuButton.propTypes = {
106
+ /**
107
+ * A collection of MenuItems to be rendered as actions for this MenuButton.
108
+ */
109
+ children: PropTypes__default["default"].node.isRequired,
110
+
111
+ /**
112
+ * Additional CSS class names.
113
+ */
114
+ className: PropTypes__default["default"].string,
115
+
116
+ /**
117
+ * Specify whether the MenuButton should be disabled, or not.
118
+ */
119
+ disabled: PropTypes__default["default"].bool,
120
+
121
+ /**
122
+ * Specify the type of button to be used as the base for the trigger button.
123
+ */
124
+ kind: PropTypes__default["default"].oneOf(validButtonKinds),
125
+
126
+ /**
127
+ * Provide the label to be renderd on the trigger button.
128
+ */
129
+ label: PropTypes__default["default"].string.isRequired,
130
+
131
+ /**
132
+ * Specify the size of the button and menu.
133
+ */
134
+ size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg'])
135
+ };
136
+
137
+ exports.MenuButton = MenuButton;
@@ -30,12 +30,13 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
30
30
 
31
31
  var _Modal$propTypes;
32
32
 
33
- 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"];
33
+ 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"];
34
34
  var getInstanceId = setupGetInstanceId["default"]();
35
35
  var Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_ref, ref) {
36
36
  var _classNames, _classNames2;
37
37
 
38
- var children = _ref.children,
38
+ var ariaLabelProp = _ref['aria-label'],
39
+ children = _ref.children,
39
40
  className = _ref.className,
40
41
  modalHeading = _ref.modalHeading,
41
42
  modalLabel = _ref.modalLabel,
@@ -132,7 +133,7 @@ var Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_re
132
133
  tabIndex: "-1",
133
134
  className: "".concat(modalCloseButtonClass, "__icon")
134
135
  }));
135
- var ariaLabel = modalLabel || rest['aria-label'] || modalAriaLabel || modalHeading;
136
+ var ariaLabel = modalLabel || ariaLabelProp || modalAriaLabel || modalHeading;
136
137
  var getAriaLabelledBy = modalLabel ? modalLabelId : modalHeadingId;
137
138
  var hasScrollingContentProps = hasScrollingContent ? {
138
139
  tabIndex: 0,
@@ -43,10 +43,12 @@ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
43
43
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
44
44
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
45
45
 
46
+ var _objectSpread2, _FilterableMultiSelec;
46
47
  var FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function FilterableMultiSelect(_ref, ref) {
47
48
  var _cx, _cx2, _cx3, _cx4;
48
49
 
49
- var ariaLabel = _ref.ariaLabel,
50
+ var ariaLabel = _ref['aria-label'],
51
+ deprecatedAriaLabel = _ref.ariaLabel,
50
52
  containerClassName = _ref.className,
51
53
  compareItems = _ref.compareItems,
52
54
  direction = _ref.direction,
@@ -129,7 +131,7 @@ var FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(fu
129
131
 
130
132
  var inline = type === 'inline';
131
133
  var showWarning = !invalid && warn;
132
- var wrapperClasses = cx__default["default"]("".concat(prefix, "--multi-select__wrapper"), "".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null], (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--multi-select__wrapper--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--multi-select__wrapper--inline--invalid"), inline && invalid), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--inline--invalid"), inline && invalid), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--fluid--invalid"), isFluid && invalid), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--fluid--focus"), isFluid && isFocused), _cx));
134
+ var wrapperClasses = cx__default["default"]("".concat(prefix, "--multi-select__wrapper"), "".concat(prefix, "--multi-select--filterable__wrapper"), "".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null], (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--multi-select__wrapper--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--multi-select__wrapper--inline--invalid"), inline && invalid), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--inline--invalid"), inline && invalid), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--fluid--invalid"), isFluid && invalid), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box__wrapper--fluid--focus"), isFluid && isFocused), _cx));
133
135
  var helperId = !helperText ? undefined : "filterablemultiselect-helper-text-".concat(filterableMultiSelectInstanceId);
134
136
  var labelId = "".concat(id, "-label");
135
137
  var titleClasses = cx__default["default"]((_cx2 = {}, _rollupPluginBabelHelpers.defineProperty(_cx2, "".concat(prefix, "--label"), true), _rollupPluginBabelHelpers.defineProperty(_cx2, "".concat(prefix, "--label--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_cx2, "".concat(prefix, "--visually-hidden"), hideLabel), _cx2));
@@ -258,7 +260,7 @@ var FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(fu
258
260
  isOpen = _ref4.isOpen,
259
261
  inputValue = _ref4.inputValue,
260
262
  selectedItem = _ref4.selectedItem;
261
- var className = cx__default["default"]("".concat(prefix, "--multi-select"), "".concat(prefix, "--combo-box"), "".concat(prefix, "--multi-select--filterable"), [enabled ? null : containerClassName], (_cx5 = {}, _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--multi-select--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--multi-select--open"), isOpen), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--multi-select--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--multi-select--selected"), selectedItem.length > 0), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--multi-select--filterable--input-focused"), inputFocused), _cx5));
263
+ var className = cx__default["default"]("".concat(prefix, "--multi-select"), "".concat(prefix, "--combo-box"), "".concat(prefix, "--multi-select--filterable"), [enabled ? null : containerClassName], (_cx5 = {}, _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--multi-select--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--multi-select--invalid--focused"), invalid && inputFocused), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--multi-select--open"), isOpen), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--multi-select--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--multi-select--selected"), selectedItem.length > 0), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--multi-select--filterable--input-focused"), inputFocused), _cx5));
262
264
  var rootProps = getRootProps({}, {
263
265
  suppressRefError: true
264
266
  });
@@ -303,6 +305,26 @@ var FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(fu
303
305
  event.stopPropagation();
304
306
  }
305
307
 
308
+ if (match.match(event, keys.Enter)) {
309
+ handleOnMenuChange(true);
310
+ }
311
+
312
+ if (!disabled) {
313
+ if (match.match(event, keys.Delete) || match.match(event, keys.Escape)) {
314
+ if (isOpen) {
315
+ handleOnMenuChange(true);
316
+ clearInputValue();
317
+ event.stopPropagation();
318
+ } else if (!isOpen) {
319
+ clearInputValue();
320
+
321
+ _clearSelection();
322
+
323
+ event.stopPropagation();
324
+ }
325
+ }
326
+ }
327
+
306
328
  if (match.match(event, keys.Tab)) {
307
329
  handleOnMenuChange(false);
308
330
  }
@@ -312,6 +334,7 @@ var FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(fu
312
334
  },
313
335
  onBlur: function onBlur() {
314
336
  setInputFocused(false);
337
+ setInputValue('');
315
338
  }
316
339
  });
317
340
  var menuProps = getMenuProps({
@@ -333,6 +356,7 @@ var FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(fu
333
356
  }, titleText ? /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
334
357
  className: titleClasses
335
358
  }, labelProps), titleText) : null, /*#__PURE__*/React__default["default"].createElement(index$1["default"], {
359
+ "aria-label": deprecatedAriaLabel || ariaLabel,
336
360
  onFocus: isFluid ? handleFocus : null,
337
361
  onBlur: isFluid ? handleFocus : null,
338
362
  className: className,
@@ -423,125 +447,7 @@ var FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(fu
423
447
  }
424
448
  });
425
449
  });
426
- FilterableMultiSelect.propTypes = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({
427
- /**
428
- * 'aria-label' of the ListBox component.
429
- */
430
- ariaLabel: PropTypes__default["default"].string,
431
-
432
- /**
433
- * Specify the direction of the multiselect dropdown. Can be either top or bottom.
434
- */
435
- direction: PropTypes__default["default"].oneOf(['top', 'bottom']),
436
-
437
- /**
438
- * Disable the control
439
- */
440
- disabled: PropTypes__default["default"].bool,
441
-
442
- /**
443
- * Additional props passed to Downshift
444
- */
445
- downshiftProps: PropTypes__default["default"].shape(Downshift__default["default"].propTypes),
446
-
447
- /**
448
- * Specify whether the title text should be hidden or not
449
- */
450
- hideLabel: PropTypes__default["default"].bool,
451
-
452
- /**
453
- * Specify a custom `id`
454
- */
455
- id: PropTypes__default["default"].string.isRequired,
456
-
457
- /**
458
- * Allow users to pass in arbitrary items from their collection that are
459
- * pre-selected
460
- */
461
- initialSelectedItems: PropTypes__default["default"].array,
462
-
463
- /**
464
- * Is the current selection invalid?
465
- */
466
- invalid: PropTypes__default["default"].bool,
467
-
468
- /**
469
- * If invalid, what is the error?
470
- */
471
- invalidText: PropTypes__default["default"].node,
472
-
473
- /**
474
- * Function to render items as custom components instead of strings.
475
- * Defaults to null and is overridden by a getter
476
- */
477
- itemToElement: PropTypes__default["default"].func,
478
-
479
- /**
480
- * Helper function passed to downshift that allows the library to render a
481
- * given item to a string label. By default, it extracts the `label` field
482
- * from a given item to serve as the item label in the list.
483
- */
484
- itemToString: PropTypes__default["default"].func,
485
-
486
- /**
487
- * We try to stay as generic as possible here to allow individuals to pass
488
- * in a collection of whatever kind of data structure they prefer
489
- */
490
- items: PropTypes__default["default"].array.isRequired,
491
-
492
- /**
493
- * `true` to use the light version.
494
- */
495
- light: deprecate["default"](PropTypes__default["default"].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.'),
496
-
497
- /**
498
- * Specify the locale of the control. Used for the default `compareItems`
499
- * used for sorting the list of items in the control.
500
- */
501
- locale: PropTypes__default["default"].string,
502
-
503
- /**
504
- * `onChange` is a utility for this controlled component to communicate to a
505
- * consuming component what kind of internal state changes are occurring.
506
- */
507
- onChange: PropTypes__default["default"].func,
508
-
509
- /**
510
- * `onInputValueChange` is a utility for this controlled component to communicate to
511
- * the currently typed input.
512
- */
513
- onInputValueChange: PropTypes__default["default"].func,
514
-
515
- /**
516
- * `onMenuChange` is a utility for this controlled component to communicate to a
517
- * consuming component that the menu was opened(`true`)/closed(`false`).
518
- */
519
- onMenuChange: PropTypes__default["default"].func,
520
-
521
- /**
522
- * Initialize the component with an open(`true`)/closed(`false`) menu.
523
- */
524
- open: PropTypes__default["default"].bool,
525
-
526
- /**
527
- * Generic `placeholder` that will be used as the textual representation of
528
- * what this field is for
529
- */
530
- placeholder: PropTypes__default["default"].string,
531
-
532
- /**
533
- * Specify feedback (mode) of the selection.
534
- * `top`: selected item jumps to top
535
- * `fixed`: selected item stays at it's position
536
- * `top-after-reopen`: selected item jump to top after reopen dropdown
537
- */
538
- selectionFeedback: PropTypes__default["default"].oneOf(['top', 'fixed', 'top-after-reopen']),
539
-
540
- /**
541
- * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
542
- */
543
- size: ListBoxPropTypes.ListBoxSize
544
- }, MultiSelectPropTypes.sortingPropTypes), {}, {
450
+ FilterableMultiSelect.propTypes = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2((_objectSpread2 = {}, _rollupPluginBabelHelpers.defineProperty(_objectSpread2, 'aria-label', PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "ariaLabel", deprecate["default"](PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.')), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "direction", PropTypes__default["default"].oneOf(['top', 'bottom'])), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "disabled", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "downshiftProps", PropTypes__default["default"].shape(Downshift__default["default"].propTypes)), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "hideLabel", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "id", PropTypes__default["default"].string.isRequired), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "initialSelectedItems", PropTypes__default["default"].array), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "invalid", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "invalidText", PropTypes__default["default"].node), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "itemToElement", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "itemToString", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "items", PropTypes__default["default"].array.isRequired), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "light", deprecate["default"](PropTypes__default["default"].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.')), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "locale", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "onChange", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "onInputValueChange", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "onMenuChange", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "open", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "placeholder", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "selectionFeedback", PropTypes__default["default"].oneOf(['top', 'fixed', 'top-after-reopen'])), _rollupPluginBabelHelpers.defineProperty(_objectSpread2, "size", ListBoxPropTypes.ListBoxSize), _objectSpread2), MultiSelectPropTypes.sortingPropTypes), {}, {
545
451
  /**
546
452
  * Callback function for translating ListBoxMenuIcon SVG title
547
453
  */
@@ -562,19 +468,7 @@ FilterableMultiSelect.propTypes = _rollupPluginBabelHelpers.objectSpread2(_rollu
562
468
  */
563
469
  warnText: PropTypes__default["default"].node
564
470
  });
565
- FilterableMultiSelect.defaultProps = {
566
- ariaLabel: 'Choose an item',
567
- compareItems: sorting.defaultCompareItems,
568
- direction: 'bottom',
569
- disabled: false,
570
- filterItems: filter.defaultFilterItems,
571
- initialSelectedItems: [],
572
- itemToString: itemToString.defaultItemToString,
573
- locale: 'en',
574
- sortItems: sorting.defaultSortItems,
575
- open: false,
576
- selectionFeedback: 'top-after-reopen'
577
- };
471
+ FilterableMultiSelect.defaultProps = (_FilterableMultiSelec = {}, _rollupPluginBabelHelpers.defineProperty(_FilterableMultiSelec, 'aria-label', 'Choose an item'), _rollupPluginBabelHelpers.defineProperty(_FilterableMultiSelec, "compareItems", sorting.defaultCompareItems), _rollupPluginBabelHelpers.defineProperty(_FilterableMultiSelec, "direction", 'bottom'), _rollupPluginBabelHelpers.defineProperty(_FilterableMultiSelec, "disabled", false), _rollupPluginBabelHelpers.defineProperty(_FilterableMultiSelec, "filterItems", filter.defaultFilterItems), _rollupPluginBabelHelpers.defineProperty(_FilterableMultiSelec, "initialSelectedItems", []), _rollupPluginBabelHelpers.defineProperty(_FilterableMultiSelec, "itemToString", itemToString.defaultItemToString), _rollupPluginBabelHelpers.defineProperty(_FilterableMultiSelec, "locale", 'en'), _rollupPluginBabelHelpers.defineProperty(_FilterableMultiSelec, "sortItems", sorting.defaultSortItems), _rollupPluginBabelHelpers.defineProperty(_FilterableMultiSelec, "open", false), _rollupPluginBabelHelpers.defineProperty(_FilterableMultiSelec, "selectionFeedback", 'top-after-reopen'), _FilterableMultiSelec);
578
472
  var FilterableMultiSelect$1 = FilterableMultiSelect;
579
473
 
580
474
  exports["default"] = FilterableMultiSelect$1;
@@ -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
  /**
@@ -123,20 +123,25 @@ var MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function Mul
123
123
  isFocused = _useState4[0],
124
124
  setIsFocused = _useState4[1];
125
125
 
126
- var _useState5 = React.useState(open),
126
+ var _useState5 = React.useState(false),
127
127
  _useState6 = _rollupPluginBabelHelpers.slicedToArray(_useState5, 2),
128
- isOpen = _useState6[0],
129
- setIsOpen = _useState6[1];
128
+ inputFocused = _useState6[0],
129
+ setInputFocused = _useState6[1];
130
130
 
131
- var _useState7 = React.useState(open),
131
+ var _useState7 = React.useState(open || false),
132
132
  _useState8 = _rollupPluginBabelHelpers.slicedToArray(_useState7, 2),
133
- prevOpenProp = _useState8[0],
134
- setPrevOpenProp = _useState8[1];
133
+ isOpen = _useState8[0],
134
+ setIsOpen = _useState8[1];
135
135
 
136
- var _useState9 = React.useState([]),
136
+ var _useState9 = React.useState(open),
137
137
  _useState10 = _rollupPluginBabelHelpers.slicedToArray(_useState9, 2),
138
- topItems = _useState10[0],
139
- setTopItems = _useState10[1];
138
+ prevOpenProp = _useState10[0],
139
+ setPrevOpenProp = _useState10[1];
140
+
141
+ var _useState11 = React.useState([]),
142
+ _useState12 = _rollupPluginBabelHelpers.slicedToArray(_useState11, 2),
143
+ topItems = _useState12[0],
144
+ setTopItems = _useState12[1];
140
145
 
141
146
  var _useSelection = Selection.useSelection({
142
147
  disabled: disabled,
@@ -176,7 +181,14 @@ var MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function Mul
176
181
  getItemProps = _useSelect.getItemProps,
177
182
  selectedItem = _useSelect.selectedItem;
178
183
 
179
- var toggleButtonProps = getToggleButtonProps();
184
+ var toggleButtonProps = getToggleButtonProps({
185
+ onFocus: function onFocus() {
186
+ setInputFocused(true);
187
+ },
188
+ onBlur: function onBlur() {
189
+ setInputFocused(false);
190
+ }
191
+ });
180
192
  var mergedRef = mergeRefs["default"](toggleButtonProps.ref, ref);
181
193
  var selectedItems = selectedItem;
182
194
  /**
@@ -208,7 +220,7 @@ var MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function Mul
208
220
  var helperId = !helperText ? undefined : "multiselect-helper-text-".concat(multiSelectInstanceId);
209
221
  var fieldLabelId = "multiselect-field-label-".concat(multiSelectInstanceId);
210
222
  var helperClasses = cx__default["default"]("".concat(prefix, "--form__helper-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
211
- var className = cx__default["default"]("".concat(prefix, "--multi-select"), [enabled ? null : containerClassName], (_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--multi-select--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--multi-select--warning"), showWarning), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--multi-select--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--multi-select--selected"), selectedItems && selectedItems.length > 0), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box--up"), direction === 'top'), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--multi-select--readonly"), readOnly), _cx4)); // needs to be capitalized for react to render it correctly
223
+ var className = cx__default["default"]("".concat(prefix, "--multi-select"), [enabled ? null : containerClassName], (_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--multi-select--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--multi-select--invalid--focused"), invalid && inputFocused), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--multi-select--warning"), showWarning), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--multi-select--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--multi-select--selected"), selectedItems && selectedItems.length > 0), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box--up"), direction === 'top'), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--multi-select--readonly"), readOnly), _cx4)); // needs to be capitalized for react to render it correctly
212
224
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
213
225
 
214
226
  var ItemToElement = itemToElement;
@@ -262,12 +274,20 @@ var MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function Mul
262
274
  }
263
275
 
264
276
  var onKeyDown = function onKeyDown(e) {
265
- if (match.match(e, keys.Delete) && !disabled) {
266
- clearSelection();
267
- e.stopPropagation();
277
+ if (!disabled) {
278
+ if (match.match(e, keys.Delete) || match.match(e, keys.Escape)) {
279
+ clearSelection();
280
+ e.stopPropagation();
281
+ }
282
+
283
+ if (match.match(e, keys.Space) || match.match(e, keys.ArrowDown)) {
284
+ setIsOpenWrapper(true);
285
+ }
268
286
  }
269
287
  };
270
288
 
289
+ var multiSelectFieldWrapperClasses = cx__default["default"]("".concat(prefix, "--list-box__field--wrapper"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--list-box__field--wrapper--input-focused"), inputFocused));
290
+
271
291
  var handleFocus = function handleFocus(evt) {
272
292
  evt.target.classList.contains("".concat(prefix, "--tag__close-icon")) ? setIsFocused(false) : setIsFocused(evt.type === 'focus' ? true : false);
273
293
  };
@@ -313,6 +333,15 @@ var MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function Mul
313
333
  className: "".concat(prefix, "--list-box__invalid-icon")
314
334
  }), showWarning && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
315
335
  className: "".concat(prefix, "--list-box__invalid-icon ").concat(prefix, "--list-box__invalid-icon--warning")
336
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
337
+ className: multiSelectFieldWrapperClasses
338
+ }, selectedItems.length > 0 && /*#__PURE__*/React__default["default"].createElement(index$1["default"].Selection, {
339
+ readOnly: readOnly,
340
+ clearSelection: !disabled && !readOnly ? clearSelection : noop,
341
+ selectionCount: selectedItems.length // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
342
+ ,
343
+ translateWithId: translateWithId,
344
+ disabled: disabled
316
345
  }), /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({
317
346
  type: "button",
318
347
  className: "".concat(prefix, "--list-box__field"),
@@ -321,20 +350,13 @@ var MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function Mul
321
350
  }, toggleButtonProps, {
322
351
  ref: mergedRef,
323
352
  onKeyDown: onKeyDown
324
- }, readOnlyEventHandlers), selectedItems.length > 0 && /*#__PURE__*/React__default["default"].createElement(index$1["default"].Selection, {
325
- readOnly: readOnly,
326
- clearSelection: !disabled && !readOnly ? clearSelection : noop,
327
- selectionCount: selectedItems.length // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
328
- ,
329
- translateWithId: translateWithId,
330
- disabled: disabled
331
- }), /*#__PURE__*/React__default["default"].createElement("span", {
353
+ }, readOnlyEventHandlers), /*#__PURE__*/React__default["default"].createElement("span", {
332
354
  id: fieldLabelId,
333
355
  className: "".concat(prefix, "--list-box__label")
334
356
  }, label), /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuIcon, {
335
- isOpen: !!isOpen,
357
+ isOpen: isOpen,
336
358
  translateWithId: translateWithId
337
- })), /*#__PURE__*/React__default["default"].createElement(index$1["default"].Menu, _rollupPluginBabelHelpers["extends"]({
359
+ }))), /*#__PURE__*/React__default["default"].createElement(index$1["default"].Menu, _rollupPluginBabelHelpers["extends"]({
338
360
  "aria-multiselectable": "true"
339
361
  }, getMenuProps()), isOpen && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
340
362
  sortItems(items, sortOptions).map(function (item, index) {
@@ -478,7 +500,7 @@ MultiSelect.propTypes = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBab
478
500
 
479
501
  /**
480
502
  * `onMenuChange` is a utility for this controlled component to communicate to a
481
- * consuming component that the menu was opend(`true`)/closed(`false`).
503
+ * consuming component that the menu was open(`true`)/closed(`false`).
482
504
  */
483
505
  onMenuChange: PropTypes__default["default"].func,
484
506