@carbon/react 1.6.0 → 1.8.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 (80) hide show
  1. package/es/components/ComposedModal/ComposedModal.js +1 -1
  2. package/es/components/ComposedModal/index.js +4 -4
  3. package/es/components/DataTable/DataTable.js +1 -1
  4. package/es/components/DataTable/Table.js +10 -2
  5. package/es/components/DataTable/TableContainer.js +20 -5
  6. package/es/components/DataTable/TableContext.js +15 -0
  7. package/es/components/DataTable/TableSelectRow.js +1 -1
  8. package/es/components/FileUploader/FileUploader.js +8 -1
  9. package/es/components/FileUploader/FileUploaderButton.js +3 -1
  10. package/es/components/FileUploader/FileUploaderDropContainer.js +3 -1
  11. package/es/components/FileUploader/FileUploaderItem.js +3 -1
  12. package/es/components/Form/Form.js +1 -1
  13. package/es/components/FormGroup/FormGroup.js +4 -4
  14. package/es/components/FormItem/FormItem.js +5 -6
  15. package/es/components/InlineLoading/InlineLoading.js +9 -5
  16. package/es/components/Loading/Loading.js +7 -18
  17. package/es/components/MultiSelect/FilterableMultiSelect.js +345 -386
  18. package/es/components/MultiSelect/index.js +4 -8
  19. package/es/components/Notification/Notification.js +322 -189
  20. package/es/components/Popover/index.js +137 -8
  21. package/es/components/ProgressBar/ProgressBar.js +6 -3
  22. package/es/components/RadioButton/RadioButton.js +58 -99
  23. package/es/components/RadioButton/index.js +2 -8
  24. package/es/components/RadioButtonGroup/RadioButtonGroup.js +72 -121
  25. package/es/components/RadioButtonGroup/index.js +2 -8
  26. package/es/components/Select/Select.js +14 -7
  27. package/es/components/Slider/Slider.js +2 -1
  28. package/es/components/Switch/Switch.js +0 -1
  29. package/es/components/TreeView/TreeView.js +19 -11
  30. package/es/components/UIShell/HeaderMenu.js +1 -1
  31. package/es/components/UIShell/HeaderMenuButton.js +4 -0
  32. package/es/components/UIShell/SideNavDetails.js +8 -3
  33. package/es/components/UIShell/SideNavLink.js +6 -9
  34. package/es/index.js +7 -6
  35. package/es/internal/createClassWrapper.js +2 -5
  36. package/lib/components/ComposedModal/index.js +7 -7
  37. package/lib/components/DataTable/DataTable.js +5 -5
  38. package/lib/components/DataTable/Table.js +9 -1
  39. package/lib/components/DataTable/TableContainer.js +19 -4
  40. package/lib/components/DataTable/TableContext.js +19 -0
  41. package/lib/components/DataTable/TableSelectRow.js +2 -2
  42. package/lib/components/FileUploader/FileUploader.js +8 -1
  43. package/lib/components/FileUploader/FileUploaderButton.js +3 -1
  44. package/lib/components/FileUploader/FileUploaderDropContainer.js +3 -1
  45. package/lib/components/FileUploader/FileUploaderItem.js +3 -1
  46. package/lib/components/Form/Form.js +1 -1
  47. package/lib/components/FormGroup/FormGroup.js +4 -4
  48. package/lib/components/FormItem/FormItem.js +5 -6
  49. package/lib/components/InlineLoading/InlineLoading.js +9 -5
  50. package/lib/components/Loading/Loading.js +6 -17
  51. package/lib/components/MultiSelect/FilterableMultiSelect.js +341 -382
  52. package/lib/components/MultiSelect/index.js +5 -28
  53. package/lib/components/Notification/Notification.js +321 -188
  54. package/lib/components/Popover/index.js +135 -6
  55. package/lib/components/ProgressBar/ProgressBar.js +6 -3
  56. package/lib/components/RadioButton/RadioButton.js +57 -99
  57. package/lib/components/RadioButton/index.js +2 -25
  58. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +68 -117
  59. package/lib/components/RadioButtonGroup/index.js +2 -25
  60. package/lib/components/Select/Select.js +14 -7
  61. package/lib/components/Slider/Slider.js +2 -1
  62. package/lib/components/Switch/Switch.js +0 -1
  63. package/lib/components/TreeView/TreeView.js +18 -10
  64. package/lib/components/UIShell/HeaderMenu.js +1 -0
  65. package/lib/components/UIShell/HeaderMenuButton.js +4 -0
  66. package/lib/components/UIShell/SideNavDetails.js +8 -3
  67. package/lib/components/UIShell/SideNavLink.js +6 -9
  68. package/lib/index.js +83 -83
  69. package/lib/internal/createClassWrapper.js +2 -5
  70. package/package.json +8 -8
  71. package/es/components/MultiSelect/next/FilterableMultiSelect.js +0 -542
  72. package/es/components/Notification/index.js +0 -42
  73. package/es/components/Notification/next/Notification.js +0 -663
  74. package/es/components/RadioButton/next/RadioButton.js +0 -130
  75. package/es/components/RadioButtonGroup/next/RadioButtonGroup.js +0 -141
  76. package/lib/components/MultiSelect/next/FilterableMultiSelect.js +0 -554
  77. package/lib/components/Notification/index.js +0 -51
  78. package/lib/components/Notification/next/Notification.js +0 -677
  79. package/lib/components/RadioButton/next/RadioButton.js +0 -140
  80. package/lib/components/RadioButtonGroup/next/RadioButtonGroup.js +0 -151
@@ -22,7 +22,7 @@ require('../ListBox/index.js');
22
22
  var Selection = require('../../internal/Selection.js');
23
23
  var itemToString = require('./tools/itemToString.js');
24
24
  var mergeRefs = require('../../tools/mergeRefs.js');
25
- var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
25
+ var useId = require('../../internal/useId.js');
26
26
  var sorting = require('./tools/sorting.js');
27
27
  var index = require('../FeatureFlags/index.js');
28
28
  var usePrefix = require('../../internal/usePrefix.js');
@@ -41,403 +41,364 @@ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
41
41
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
42
42
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
43
43
 
44
- var getInstanceId = setupGetInstanceId["default"]();
45
-
46
- var FilterableMultiSelect = /*#__PURE__*/function (_React$Component) {
47
- _rollupPluginBabelHelpers.inherits(FilterableMultiSelect, _React$Component);
48
-
49
- var _super = _rollupPluginBabelHelpers.createSuper(FilterableMultiSelect);
44
+ var FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function FilterableMultiSelect(_ref, ref) {
45
+ var _cx, _cx2, _cx3, _cx4;
46
+
47
+ var ariaLabel = _ref.ariaLabel,
48
+ containerClassName = _ref.className,
49
+ compareItems = _ref.compareItems,
50
+ direction = _ref.direction,
51
+ disabled = _ref.disabled,
52
+ downshiftProps = _ref.downshiftProps,
53
+ filterItems = _ref.filterItems,
54
+ helperText = _ref.helperText,
55
+ hideLabel = _ref.hideLabel,
56
+ id = _ref.id,
57
+ initialSelectedItems = _ref.initialSelectedItems,
58
+ invalid = _ref.invalid,
59
+ invalidText = _ref.invalidText,
60
+ items = _ref.items,
61
+ ItemToElement = _ref.itemToElement,
62
+ itemToString = _ref.itemToString,
63
+ light = _ref.light,
64
+ locale = _ref.locale,
65
+ onInputValueChange = _ref.onInputValueChange,
66
+ open = _ref.open,
67
+ onChange = _ref.onChange,
68
+ onMenuChange = _ref.onMenuChange,
69
+ placeholder = _ref.placeholder,
70
+ titleText = _ref.titleText,
71
+ type = _ref.type,
72
+ selectionFeedback = _ref.selectionFeedback,
73
+ size = _ref.size,
74
+ sortItems = _ref.sortItems,
75
+ translateWithId = _ref.translateWithId,
76
+ useTitleInItem = _ref.useTitleInItem,
77
+ warn = _ref.warn,
78
+ warnText = _ref.warnText;
79
+
80
+ var _useState = React.useState(open),
81
+ _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
82
+ isOpen = _useState2[0],
83
+ setIsOpen = _useState2[1];
84
+
85
+ var _useState3 = React.useState(open),
86
+ _useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
87
+ prevOpen = _useState4[0],
88
+ setPrevOpen = _useState4[1];
89
+
90
+ var _useState5 = React.useState(''),
91
+ _useState6 = _rollupPluginBabelHelpers.slicedToArray(_useState5, 2),
92
+ inputValue = _useState6[0],
93
+ setInputValue = _useState6[1];
94
+
95
+ var _useState7 = React.useState([]),
96
+ _useState8 = _rollupPluginBabelHelpers.slicedToArray(_useState7, 2),
97
+ topItems = _useState8[0],
98
+ setTopItems = _useState8[1];
99
+
100
+ var _useState9 = React.useState(false),
101
+ _useState10 = _rollupPluginBabelHelpers.slicedToArray(_useState9, 2),
102
+ inputFocused = _useState10[0],
103
+ setInputFocused = _useState10[1];
104
+
105
+ var _useState11 = React.useState(null),
106
+ _useState12 = _rollupPluginBabelHelpers.slicedToArray(_useState11, 2),
107
+ highlightedIndex = _useState12[0],
108
+ setHighlightedIndex = _useState12[1];
109
+
110
+ var textInput = React.useRef();
111
+ var filterableMultiSelectInstanceId = useId.useId();
112
+ var enabled = index.useFeatureFlag('enable-v11-release');
113
+ var prefix = usePrefix.usePrefix();
114
+
115
+ if (prevOpen !== open) {
116
+ setIsOpen(open);
117
+ setPrevOpen(open);
118
+ }
50
119
 
51
- function FilterableMultiSelect(props) {
52
- var _this;
120
+ var inline = type === 'inline';
121
+ var showWarning = !invalid && warn;
122
+ 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'), _cx));
123
+ var helperId = !helperText ? undefined : "filterablemultiselect-helper-text-".concat(filterableMultiSelectInstanceId);
124
+ var labelId = "".concat(id, "-label");
125
+ 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));
126
+ var helperClasses = cx__default["default"]((_cx3 = {}, _rollupPluginBabelHelpers.defineProperty(_cx3, "".concat(prefix, "--form__helper-text"), true), _rollupPluginBabelHelpers.defineProperty(_cx3, "".concat(prefix, "--form__helper-text--disabled"), disabled), _cx3));
127
+ var inputClasses = cx__default["default"]((_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--text-input"), true), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--text-input--empty"), !inputValue), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--text-input--light"), light), _cx4));
128
+ var helper = helperText ? /*#__PURE__*/React__default["default"].createElement("div", {
129
+ id: helperId,
130
+ className: helperClasses
131
+ }, helperText) : null;
132
+ var menuId = "".concat(id, "__menu");
133
+ var inputId = "".concat(id, "-input");
134
+
135
+ function handleOnChange(changes) {
136
+ if (onChange) {
137
+ onChange(changes);
138
+ }
139
+ }
53
140
 
54
- _rollupPluginBabelHelpers.classCallCheck(this, FilterableMultiSelect);
141
+ function handleOnMenuChange(forceIsOpen) {
142
+ var nextIsOpen = forceIsOpen !== null && forceIsOpen !== void 0 ? forceIsOpen : !isOpen;
143
+ setIsOpen(nextIsOpen);
55
144
 
56
- _this = _super.call(this, props);
145
+ if (onMenuChange) {
146
+ onMenuChange(nextIsOpen);
147
+ }
148
+ }
57
149
 
58
- _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleOnChange", function (changes) {
59
- if (_this.props.onChange) {
60
- _this.props.onChange(changes);
61
- }
62
- });
150
+ function handleOnOuterClick() {
151
+ handleOnMenuChange(false);
152
+ }
63
153
 
64
- _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleOnMenuChange", function (isOpen) {
65
- _this.setState(function (state) {
66
- return {
67
- isOpen: isOpen !== null && isOpen !== void 0 ? isOpen : !state.isOpen
68
- };
69
- });
154
+ function handleOnStateChange(changes, downshift) {
155
+ if (changes.isOpen && !isOpen) {
156
+ setTopItems(downshift.selectedItem);
157
+ }
70
158
 
71
- if (_this.props.onMenuChange) {
72
- _this.props.onMenuChange(isOpen);
73
- }
74
- });
159
+ var type = changes.type;
160
+ var stateChangeTypes = Downshift__default["default"].stateChangeTypes;
75
161
 
76
- _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleOnOuterClick", function () {
77
- _this.handleOnMenuChange(false);
78
- });
162
+ switch (type) {
163
+ case stateChangeTypes.keyDownArrowDown:
164
+ case stateChangeTypes.keyDownArrowUp:
165
+ case stateChangeTypes.keyDownHome:
166
+ case stateChangeTypes.keyDownEnd:
167
+ setHighlightedIndex(changes.highlightedIndex !== undefined ? changes.highlightedIndex : null);
79
168
 
80
- _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleOnStateChange", function (changes, downshift) {
81
- if (changes.isOpen && !_this.state.isOpen) {
82
- _this.setState({
83
- topItems: downshift.selectedItem
84
- });
85
- }
86
-
87
- var type = changes.type;
88
- var stateChangeTypes = Downshift__default["default"].stateChangeTypes;
89
-
90
- switch (type) {
91
- case stateChangeTypes.keyDownArrowDown:
92
- case stateChangeTypes.keyDownArrowUp:
93
- case stateChangeTypes.keyDownHome:
94
- case stateChangeTypes.keyDownEnd:
95
- _this.setState({
96
- highlightedIndex: changes.highlightedIndex !== undefined ? changes.highlightedIndex : null
97
- });
98
-
99
- if (stateChangeTypes.keyDownArrowDown === type && !_this.state.isOpen) {
100
- _this.handleOnMenuChange(true);
101
- }
102
-
103
- break;
169
+ if (stateChangeTypes.keyDownArrowDown === type && !isOpen) {
170
+ handleOnMenuChange(true);
171
+ }
104
172
 
105
- case stateChangeTypes.keyDownEscape:
106
- _this.handleOnMenuChange(false);
173
+ break;
107
174
 
108
- break;
109
- }
110
- });
175
+ case stateChangeTypes.keyDownEscape:
176
+ handleOnMenuChange(false);
177
+ break;
178
+ }
179
+ }
111
180
 
112
- _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleOnInputKeyDown", function (event) {
113
- event.stopPropagation();
114
- });
181
+ function handleOnInputValueChange(inputValue, _ref2) {
182
+ var type = _ref2.type;
115
183
 
116
- _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleOnInputValueChange", function (inputValue, _ref) {
117
- var type = _ref.type;
184
+ if (onInputValueChange) {
185
+ onInputValueChange(inputValue);
186
+ }
118
187
 
119
- if (_this.props.onInputValueChange) {
120
- _this.props.onInputValueChange(inputValue);
121
- }
188
+ if (type !== Downshift__default["default"].stateChangeTypes.changeInput) {
189
+ return;
190
+ }
122
191
 
123
- if (type !== Downshift__default["default"].stateChangeTypes.changeInput) {
124
- return;
125
- }
192
+ if (Array.isArray(inputValue)) {
193
+ clearInputValue();
194
+ } else {
195
+ setInputValue(inputValue);
196
+ }
126
197
 
127
- _this.setState(function () {
128
- if (Array.isArray(inputValue)) {
129
- return {
130
- inputValue: ''
131
- };
132
- }
198
+ if (inputValue && !isOpen) {
199
+ handleOnMenuChange(true);
200
+ } else if (!inputValue && isOpen) {
201
+ handleOnMenuChange(false);
202
+ }
203
+ }
133
204
 
134
- return {
135
- inputValue: inputValue || ''
136
- };
137
- });
205
+ function clearInputValue() {
206
+ setInputValue('');
138
207
 
139
- if (inputValue && !_this.state.isOpen) {
140
- _this.handleOnMenuChange(true);
141
- } else if (!inputValue && _this.state.isOpen) {
142
- _this.handleOnMenuChange(false);
143
- }
144
- });
145
-
146
- _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "clearInputValue", function () {
147
- _this.setState({
148
- inputValue: ''
149
- }, function () {
150
- if (_this.textInput.current) {
151
- _this.textInput.current.focus();
152
- }
153
- });
154
- });
155
-
156
- _this.filterableMultiSelectInstanceId = getInstanceId();
157
- _this.state = {
158
- isOpen: props.open,
159
- inputValue: '',
160
- topItems: [],
161
- inputFocused: false,
162
- highlightedIndex: null
163
- };
164
- _this.textInput = /*#__PURE__*/React__default["default"].createRef();
165
- return _this;
208
+ if (textInput.current) {
209
+ textInput.current.focus();
210
+ }
166
211
  }
167
212
 
168
- _rollupPluginBabelHelpers.createClass(FilterableMultiSelect, [{
169
- key: "render",
170
- value: function render() {
171
- var _this2 = this;
172
-
173
- var _this$state = this.state,
174
- highlightedIndex = _this$state.highlightedIndex,
175
- isOpen = _this$state.isOpen,
176
- inputValue = _this$state.inputValue;
177
- var _this$props = this.props,
178
- ariaLabel = _this$props.ariaLabel,
179
- containerClassName = _this$props.className,
180
- direction = _this$props.direction,
181
- disabled = _this$props.disabled,
182
- filterItems = _this$props.filterItems,
183
- items = _this$props.items,
184
- itemToElement = _this$props.itemToElement,
185
- itemToString = _this$props.itemToString,
186
- titleText = _this$props.titleText,
187
- hideLabel = _this$props.hideLabel,
188
- helperText = _this$props.helperText,
189
- type = _this$props.type,
190
- initialSelectedItems = _this$props.initialSelectedItems,
191
- id = _this$props.id,
192
- locale = _this$props.locale,
193
- size = _this$props.size,
194
- placeholder = _this$props.placeholder,
195
- sortItems = _this$props.sortItems,
196
- compareItems = _this$props.compareItems,
197
- light = _this$props.light,
198
- invalid = _this$props.invalid,
199
- invalidText = _this$props.invalidText,
200
- warn = _this$props.warn,
201
- warnText = _this$props.warnText,
202
- useTitleInItem = _this$props.useTitleInItem,
203
- translateWithId = _this$props.translateWithId,
204
- downshiftProps = _this$props.downshiftProps;
205
- var inline = type === 'inline';
206
- var showWarning = !invalid && warn; // needs to be capitalized for react to render it correctly
207
-
208
- var ItemToElement = itemToElement;
209
- var scope = this.context;
210
- var enabled;
211
-
212
- if (scope.enabled) {
213
- enabled = scope.enabled('enable-v11-release');
214
- }
215
-
216
- return /*#__PURE__*/React__default["default"].createElement(usePrefix.PrefixContext.Consumer, null, function (prefix) {
217
- var _cx, _cx2, _cx3, _cx4;
218
-
219
- 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'), _cx));
220
- var helperId = !helperText ? undefined : "filterablemultiselect-helper-text-".concat(_this2.filterableMultiSelectInstanceId);
221
- var labelId = "".concat(id, "-label");
222
- 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));
223
- var helperClasses = cx__default["default"]((_cx3 = {}, _rollupPluginBabelHelpers.defineProperty(_cx3, "".concat(prefix, "--form__helper-text"), true), _rollupPluginBabelHelpers.defineProperty(_cx3, "".concat(prefix, "--form__helper-text--disabled"), disabled), _cx3));
224
- var inputClasses = cx__default["default"]((_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--text-input"), true), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--text-input--empty"), !_this2.state.inputValue), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--text-input--light"), light), _cx4));
225
- var helper = helperText ? /*#__PURE__*/React__default["default"].createElement("div", {
226
- id: helperId,
227
- className: helperClasses
228
- }, helperText) : null;
229
- var menuId = "".concat(id, "__menu");
230
- var inputId = "".concat(id, "-input");
231
- return /*#__PURE__*/React__default["default"].createElement(Selection["default"], {
213
+ return /*#__PURE__*/React__default["default"].createElement(Selection["default"], {
214
+ disabled: disabled,
215
+ onChange: handleOnChange,
216
+ initialSelectedItems: initialSelectedItems,
217
+ render: function render(_ref3) {
218
+ var selectedItems = _ref3.selectedItems,
219
+ onItemChange = _ref3.onItemChange,
220
+ _clearSelection = _ref3.clearSelection;
221
+ return /*#__PURE__*/React__default["default"].createElement(Downshift__default["default"], _rollupPluginBabelHelpers["extends"]({}, downshiftProps, {
222
+ highlightedIndex: highlightedIndex,
223
+ id: id,
224
+ isOpen: isOpen,
225
+ inputValue: inputValue,
226
+ onInputValueChange: handleOnInputValueChange,
227
+ onChange: function onChange(selectedItem) {
228
+ if (selectedItem !== null) {
229
+ onItemChange(selectedItem);
230
+ }
231
+ },
232
+ itemToString: itemToString,
233
+ onStateChange: handleOnStateChange,
234
+ onOuterClick: handleOnOuterClick,
235
+ selectedItem: selectedItems,
236
+ labelId: labelId,
237
+ menuId: menuId,
238
+ inputId: inputId
239
+ }), function (_ref4) {
240
+ var _cx5;
241
+
242
+ var getInputProps = _ref4.getInputProps,
243
+ getItemProps = _ref4.getItemProps,
244
+ getLabelProps = _ref4.getLabelProps,
245
+ getMenuProps = _ref4.getMenuProps,
246
+ getRootProps = _ref4.getRootProps,
247
+ getToggleButtonProps = _ref4.getToggleButtonProps,
248
+ isOpen = _ref4.isOpen,
249
+ inputValue = _ref4.inputValue,
250
+ selectedItem = _ref4.selectedItem;
251
+ 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));
252
+ var rootProps = getRootProps({}, {
253
+ suppressRefError: true
254
+ });
255
+ var labelProps = getLabelProps();
256
+ var buttonProps = getToggleButtonProps({
257
+ disabled: disabled,
258
+ onClick: function onClick() {
259
+ handleOnMenuChange(!isOpen);
260
+
261
+ if (textInput.current) {
262
+ textInput.current.focus();
263
+ }
264
+ },
265
+ // When we moved the "root node" of Downshift to the <input> for
266
+ // ARIA 1.2 compliance, we unfortunately hit this branch for the
267
+ // "mouseup" event that downshift listens to:
268
+ // https://github.com/downshift-js/downshift/blob/v5.2.1/src/downshift.js#L1051-L1065
269
+ //
270
+ // As a result, it will reset the state of the component and so we
271
+ // stop the event from propagating to prevent this. This allows the
272
+ // toggleMenu behavior for the toggleButton to correctly open and
273
+ // close the menu.
274
+ onMouseUp: function onMouseUp(event) {
275
+ if (isOpen) {
276
+ event.stopPropagation();
277
+ }
278
+ }
279
+ });
280
+ var inputProps = getInputProps({
281
+ 'aria-controls': isOpen ? menuId : null,
282
+ 'aria-describedby': helperText ? helperId : null,
283
+ // Remove excess aria `aria-labelledby`. HTML <label for>
284
+ // provides this aria information.
285
+ 'aria-labelledby': null,
232
286
  disabled: disabled,
233
- onChange: _this2.handleOnChange,
234
- initialSelectedItems: initialSelectedItems,
235
- render: function render(_ref2) {
236
- var selectedItems = _ref2.selectedItems,
237
- onItemChange = _ref2.onItemChange,
238
- _clearSelection = _ref2.clearSelection;
239
- return /*#__PURE__*/React__default["default"].createElement(Downshift__default["default"], _rollupPluginBabelHelpers["extends"]({}, downshiftProps, {
240
- highlightedIndex: highlightedIndex,
241
- id: id,
242
- isOpen: isOpen,
243
- inputValue: inputValue,
244
- onInputValueChange: _this2.handleOnInputValueChange,
245
- onChange: function onChange(selectedItem) {
246
- if (selectedItem !== null) {
247
- onItemChange(selectedItem);
248
- }
249
- },
250
- itemToString: itemToString,
251
- onStateChange: _this2.handleOnStateChange,
252
- onOuterClick: _this2.handleOnOuterClick,
253
- selectedItem: selectedItems,
254
- labelId: labelId,
255
- menuId: menuId,
256
- inputId: inputId
257
- }), function (_ref3) {
258
- var _cx5;
259
-
260
- var getInputProps = _ref3.getInputProps,
261
- getItemProps = _ref3.getItemProps,
262
- getLabelProps = _ref3.getLabelProps,
263
- getMenuProps = _ref3.getMenuProps,
264
- getRootProps = _ref3.getRootProps,
265
- getToggleButtonProps = _ref3.getToggleButtonProps,
266
- isOpen = _ref3.isOpen,
267
- inputValue = _ref3.inputValue,
268
- selectedItem = _ref3.selectedItem;
269
- 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"), _this2.state.inputFocused), _cx5));
270
- var rootProps = getRootProps({}, {
271
- suppressRefError: true
272
- });
273
- var labelProps = getLabelProps();
274
- var buttonProps = getToggleButtonProps({
275
- disabled: disabled,
276
- onClick: function onClick() {
277
- _this2.handleOnMenuChange(!_this2.state.isOpen);
278
-
279
- if (_this2.textInput.current) {
280
- _this2.textInput.current.focus();
281
- }
282
- },
283
- // When we moved the "root node" of Downshift to the <input> for
284
- // ARIA 1.2 compliance, we unfortunately hit this branch for the
285
- // "mouseup" event that downshift listens to:
286
- // https://github.com/downshift-js/downshift/blob/v5.2.1/src/downshift.js#L1051-L1065
287
- //
288
- // As a result, it will reset the state of the component and so we
289
- // stop the event from propagating to prevent this. This allows the
290
- // toggleMenu behavior for the toggleButton to correctly open and
291
- // close the menu.
292
- onMouseUp: function onMouseUp(event) {
293
- event.stopPropagation();
294
- }
295
- });
296
- var inputProps = getInputProps({
297
- 'aria-controls': isOpen ? menuId : null,
298
- 'aria-describedby': helperText ? helperId : null,
299
- // Remove excess aria `aria-labelledby`. HTML <label for>
300
- // provides this aria information.
301
- 'aria-labelledby': null,
302
- disabled: disabled,
303
- placeholder: placeholder,
304
- onClick: function onClick() {
305
- _this2.handleOnMenuChange(true);
306
- },
307
- onKeyDown: function onKeyDown(event) {
308
- if (match.match(event, keys.Space)) {
309
- event.stopPropagation();
310
- }
311
- },
312
- onFocus: function onFocus() {
313
- _this2.setState({
314
- inputFocused: true
315
- });
316
- },
317
- onBlur: function onBlur() {
318
- _this2.setState({
319
- inputFocused: false
320
- });
321
- }
322
- });
323
- var menuProps = getMenuProps({
324
- 'aria-label': ariaLabel
325
- }, {
326
- suppressRefError: true
327
- });
328
- return /*#__PURE__*/React__default["default"].createElement("div", {
329
- className: wrapperClasses
330
- }, titleText ? /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
331
- className: titleClasses
332
- }, labelProps), titleText) : null, /*#__PURE__*/React__default["default"].createElement(ListBox["default"], {
333
- className: className,
334
- disabled: disabled,
335
- light: light,
336
- invalid: invalid,
337
- invalidText: invalidText,
338
- warn: warn,
339
- warnText: warnText,
340
- isOpen: isOpen,
341
- size: size
342
- }, /*#__PURE__*/React__default["default"].createElement("div", {
343
- className: "".concat(prefix, "--list-box__field")
344
- }, selectedItem.length > 0 && /*#__PURE__*/React__default["default"].createElement(ListBoxSelection["default"], {
345
- clearSelection: function clearSelection() {
346
- _clearSelection();
347
-
348
- if (_this2.textInput.current) {
349
- _this2.textInput.current.focus();
350
- }
351
- },
352
- selectionCount: selectedItem.length,
353
- translateWithId: translateWithId,
354
- disabled: disabled
355
- }), /*#__PURE__*/React__default["default"].createElement("input", _rollupPluginBabelHelpers["extends"]({
356
- className: inputClasses
357
- }, rootProps, inputProps, {
358
- ref: mergeRefs["default"](_this2.textInput, rootProps.ref)
359
- })), invalid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
360
- className: "".concat(prefix, "--list-box__invalid-icon")
361
- }), showWarning && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
362
- className: "".concat(prefix, "--list-box__invalid-icon ").concat(prefix, "--list-box__invalid-icon--warning")
363
- }), inputValue && /*#__PURE__*/React__default["default"].createElement(ListBoxSelection["default"], {
364
- clearSelection: _this2.clearInputValue,
365
- disabled: disabled,
366
- translateWithId: translateWithId,
367
- onMouseUp: function onMouseUp(event) {
368
- // If we do not stop this event from propagating,
369
- // it seems like Downshift takes our event and
370
- // prevents us from getting `onClick` /
371
- // `clearSelection` from the underlying <button> in
372
- // ListBoxSelection
373
- event.stopPropagation();
374
- }
375
- }), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
376
- isOpen: isOpen,
377
- translateWithId: translateWithId
378
- }))), isOpen ? /*#__PURE__*/React__default["default"].createElement(ListBox["default"].Menu, menuProps, sortItems(filterItems(items, {
379
- itemToString: itemToString,
380
- inputValue: inputValue
381
- }), {
382
- selectedItems: {
383
- top: selectedItems,
384
- fixed: [],
385
- 'top-after-reopen': _this2.state.topItems
386
- }[_this2.props.selectionFeedback],
387
- itemToString: itemToString,
388
- compareItems: compareItems,
389
- locale: locale
390
- }).map(function (item, index) {
391
- var itemProps = getItemProps({
392
- item: item,
393
- disabled: item.disabled
394
- });
395
- var itemText = itemToString(item);
396
- var isChecked = selectedItem.filter(function (selected) {
397
- return isEqual__default["default"](selected, item);
398
- }).length > 0;
399
- return /*#__PURE__*/React__default["default"].createElement(ListBox["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
400
- key: itemProps.id,
401
- "aria-label": itemText,
402
- isActive: isChecked,
403
- isHighlighted: highlightedIndex === index,
404
- title: itemText
405
- }, itemProps), /*#__PURE__*/React__default["default"].createElement("div", {
406
- className: "".concat(prefix, "--checkbox-wrapper")
407
- }, /*#__PURE__*/React__default["default"].createElement("span", {
408
- title: useTitleInItem ? itemText : null,
409
- className: "".concat(prefix, "--checkbox-label"),
410
- "data-contained-checkbox-state": isChecked,
411
- id: "".concat(itemProps.id, "-item")
412
- }, itemToElement ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
413
- key: itemProps.id
414
- }, item)) : itemText)));
415
- })) : null), !inline && !invalid && !warn ? helper : null);
416
- });
287
+ placeholder: placeholder,
288
+ onClick: function onClick() {
289
+ handleOnMenuChange(true);
290
+ },
291
+ onKeyDown: function onKeyDown(event) {
292
+ if (match.match(event, keys.Space)) {
293
+ event.stopPropagation();
294
+ }
295
+ },
296
+ onFocus: function onFocus() {
297
+ setInputFocused(true);
298
+ },
299
+ onBlur: function onBlur() {
300
+ setInputFocused(false);
417
301
  }
418
302
  });
303
+ var menuProps = getMenuProps({
304
+ 'aria-label': ariaLabel
305
+ }, {
306
+ suppressRefError: true
307
+ });
308
+ return /*#__PURE__*/React__default["default"].createElement("div", {
309
+ className: wrapperClasses
310
+ }, titleText ? /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
311
+ className: titleClasses
312
+ }, labelProps), titleText) : null, /*#__PURE__*/React__default["default"].createElement(ListBox["default"], {
313
+ className: className,
314
+ disabled: disabled,
315
+ light: light,
316
+ ref: ref,
317
+ invalid: invalid,
318
+ invalidText: invalidText,
319
+ warn: warn,
320
+ warnText: warnText,
321
+ isOpen: isOpen,
322
+ size: size
323
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
324
+ className: "".concat(prefix, "--list-box__field")
325
+ }, selectedItem.length > 0 && /*#__PURE__*/React__default["default"].createElement(ListBoxSelection["default"], {
326
+ clearSelection: function clearSelection() {
327
+ _clearSelection();
328
+
329
+ if (textInput.current) {
330
+ textInput.current.focus();
331
+ }
332
+ },
333
+ selectionCount: selectedItem.length,
334
+ translateWithId: translateWithId,
335
+ disabled: disabled
336
+ }), /*#__PURE__*/React__default["default"].createElement("input", _rollupPluginBabelHelpers["extends"]({
337
+ className: inputClasses
338
+ }, rootProps, inputProps, {
339
+ ref: mergeRefs["default"](textInput, rootProps.ref)
340
+ })), invalid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
341
+ className: "".concat(prefix, "--list-box__invalid-icon")
342
+ }), showWarning && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
343
+ className: "".concat(prefix, "--list-box__invalid-icon ").concat(prefix, "--list-box__invalid-icon--warning")
344
+ }), inputValue && /*#__PURE__*/React__default["default"].createElement(ListBoxSelection["default"], {
345
+ clearSelection: clearInputValue,
346
+ disabled: disabled,
347
+ translateWithId: translateWithId,
348
+ onMouseUp: function onMouseUp(event) {
349
+ // If we do not stop this event from propagating,
350
+ // it seems like Downshift takes our event and
351
+ // prevents us from getting `onClick` /
352
+ // `clearSelection` from the underlying <button> in
353
+ // ListBoxSelection
354
+ event.stopPropagation();
355
+ }
356
+ }), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
357
+ isOpen: isOpen,
358
+ translateWithId: translateWithId
359
+ }))), isOpen ? /*#__PURE__*/React__default["default"].createElement(ListBox["default"].Menu, menuProps, sortItems(filterItems(items, {
360
+ itemToString: itemToString,
361
+ inputValue: inputValue
362
+ }), {
363
+ selectedItems: {
364
+ top: selectedItems,
365
+ fixed: [],
366
+ 'top-after-reopen': topItems
367
+ }[selectionFeedback],
368
+ itemToString: itemToString,
369
+ compareItems: compareItems,
370
+ locale: locale
371
+ }).map(function (item, index) {
372
+ var itemProps = getItemProps({
373
+ item: item,
374
+ disabled: item.disabled
375
+ });
376
+ var itemText = itemToString(item);
377
+ var isChecked = selectedItem.filter(function (selected) {
378
+ return isEqual__default["default"](selected, item);
379
+ }).length > 0;
380
+ return /*#__PURE__*/React__default["default"].createElement(ListBox["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
381
+ key: itemProps.id,
382
+ "aria-label": itemText,
383
+ isActive: isChecked,
384
+ isHighlighted: highlightedIndex === index,
385
+ title: itemText
386
+ }, itemProps), /*#__PURE__*/React__default["default"].createElement("div", {
387
+ className: "".concat(prefix, "--checkbox-wrapper")
388
+ }, /*#__PURE__*/React__default["default"].createElement("span", {
389
+ title: useTitleInItem ? itemText : null,
390
+ className: "".concat(prefix, "--checkbox-label"),
391
+ "data-contained-checkbox-state": isChecked,
392
+ id: "".concat(itemProps.id, "-item")
393
+ }, ItemToElement ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
394
+ key: itemProps.id
395
+ }, item)) : itemText)));
396
+ })) : null), !inline && !invalid && !warn ? helper : null);
419
397
  });
420
398
  }
421
- }], [{
422
- key: "getDerivedStateFromProps",
423
- value: function getDerivedStateFromProps(_ref4, state) {
424
- var open = _ref4.open;
425
-
426
- /**
427
- * programmatically control this `open` prop
428
- */
429
- var prevOpen = state.prevOpen;
430
- return prevOpen === open ? null : {
431
- isOpen: open,
432
- prevOpen: open
433
- };
434
- }
435
- }]);
436
-
437
- return FilterableMultiSelect;
438
- }(React__default["default"].Component);
439
-
440
- _rollupPluginBabelHelpers.defineProperty(FilterableMultiSelect, "propTypes", _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({
399
+ });
400
+ });
401
+ FilterableMultiSelect.propTypes = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({
441
402
  /**
442
403
  * 'aria-label' of the ListBox component.
443
404
  */
@@ -541,7 +502,7 @@ _rollupPluginBabelHelpers.defineProperty(FilterableMultiSelect, "propTypes", _ro
541
502
  * Generic `placeholder` that will be used as the textual representation of
542
503
  * what this field is for
543
504
  */
544
- placeholder: PropTypes__default["default"].string.isRequired,
505
+ placeholder: PropTypes__default["default"].string,
545
506
 
546
507
  /**
547
508
  * Specify feedback (mode) of the selection.
@@ -575,11 +536,8 @@ _rollupPluginBabelHelpers.defineProperty(FilterableMultiSelect, "propTypes", _ro
575
536
  * Provide the text that is displayed when the control is in warning state
576
537
  */
577
538
  warnText: PropTypes__default["default"].node
578
- }));
579
-
580
- _rollupPluginBabelHelpers.defineProperty(FilterableMultiSelect, "contextType", index.FeatureFlagContext);
581
-
582
- _rollupPluginBabelHelpers.defineProperty(FilterableMultiSelect, "defaultProps", {
539
+ });
540
+ FilterableMultiSelect.defaultProps = {
583
541
  ariaLabel: 'Choose an item',
584
542
  compareItems: sorting.defaultCompareItems,
585
543
  direction: 'bottom',
@@ -592,6 +550,7 @@ _rollupPluginBabelHelpers.defineProperty(FilterableMultiSelect, "defaultProps",
592
550
  light: false,
593
551
  open: false,
594
552
  selectionFeedback: 'top-after-reopen'
595
- });
553
+ };
554
+ var FilterableMultiSelect$1 = FilterableMultiSelect;
596
555
 
597
- exports["default"] = FilterableMultiSelect;
556
+ exports["default"] = FilterableMultiSelect$1;