@carbon/react 1.68.0-rc.0 → 1.69.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 (112) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +743 -743
  2. package/README.md +3 -3
  3. package/es/components/Accordion/AccordionItem.js +0 -1
  4. package/es/components/Button/Button.js +6 -0
  5. package/es/components/CheckboxGroup/CheckboxGroup.js +1 -2
  6. package/es/components/CheckboxGroup/index.d.ts +10 -0
  7. package/es/components/ComboBox/ComboBox.d.ts +5 -0
  8. package/es/components/ComboBox/ComboBox.js +139 -54
  9. package/es/components/ComboButton/index.js +10 -3
  10. package/es/components/DataTable/TableCell.d.ts +1 -4
  11. package/es/components/DataTable/TableCell.js +3 -2
  12. package/es/components/DatePicker/DatePicker.js +10 -6
  13. package/es/components/Disclosure/index.d.ts +18 -0
  14. package/es/components/Dropdown/Dropdown.js +11 -9
  15. package/es/components/FileUploader/FileUploader.d.ts +8 -92
  16. package/es/components/FileUploader/FileUploader.js +116 -137
  17. package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
  18. package/es/components/FluidComboBox/FluidComboBox.Skeleton.d.ts +15 -0
  19. package/es/components/FluidComboBox/FluidComboBox.Skeleton.js +1 -2
  20. package/es/components/FluidComboBox/FluidComboBox.d.ts +102 -0
  21. package/es/components/FluidComboBox/FluidComboBox.js +2 -3
  22. package/es/components/FluidComboBox/index.d.ts +13 -0
  23. package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.d.ts +19 -0
  24. package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +2 -2
  25. package/es/components/FluidDatePicker/FluidDatePicker.d.ts +39 -0
  26. package/es/components/FluidDatePicker/FluidDatePicker.js +2 -3
  27. package/es/components/FluidDatePicker/index.d.ts +13 -0
  28. package/es/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +10 -0
  29. package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +1 -2
  30. package/es/components/FluidDatePickerInput/index.d.ts +9 -0
  31. package/es/components/IdPrefix/index.d.ts +26 -0
  32. package/es/components/Menu/MenuItem.js +1 -4
  33. package/es/components/MenuButton/index.d.ts +4 -0
  34. package/es/components/MenuButton/index.js +19 -5
  35. package/es/components/MultiSelect/MultiSelect.js +11 -9
  36. package/es/components/OverflowMenu/next/index.d.ts +4 -0
  37. package/es/components/OverflowMenu/next/index.js +19 -9
  38. package/es/components/PaginationNav/PaginationNav.js +1 -1
  39. package/es/components/Popover/index.js +18 -14
  40. package/es/components/Portal/index.d.ts +25 -0
  41. package/es/components/Slider/Slider.js +2 -2
  42. package/es/components/Tabs/usePressable.js +2 -0
  43. package/es/components/Tag/DismissibleTag.js +2 -2
  44. package/es/components/Tag/OperationalTag.d.ts +2 -10
  45. package/es/components/Tag/OperationalTag.js +2 -14
  46. package/es/components/Tag/SelectableTag.d.ts +2 -10
  47. package/es/components/Tag/SelectableTag.js +2 -16
  48. package/es/components/Toggle/Toggle.js +2 -0
  49. package/es/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
  50. package/es/components/ToggleSmall/index.d.ts +7 -0
  51. package/es/components/TreeView/TreeNode.js +4 -2
  52. package/es/components/TreeView/TreeView.js +4 -4
  53. package/es/components/UIShell/SideNavMenuItem.d.ts +4 -3
  54. package/es/components/UIShell/SideNavMenuItem.js +1 -4
  55. package/es/index.js +6 -6
  56. package/es/internal/useIdPrefix.d.ts +9 -0
  57. package/lib/components/Accordion/AccordionItem.js +0 -1
  58. package/lib/components/Button/Button.js +6 -0
  59. package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -2
  60. package/lib/components/CheckboxGroup/index.d.ts +10 -0
  61. package/lib/components/ComboBox/ComboBox.d.ts +5 -0
  62. package/lib/components/ComboBox/ComboBox.js +144 -59
  63. package/lib/components/ComboButton/index.js +12 -5
  64. package/lib/components/DataTable/TableCell.d.ts +1 -4
  65. package/lib/components/DataTable/TableCell.js +3 -2
  66. package/lib/components/DatePicker/DatePicker.js +9 -5
  67. package/lib/components/Disclosure/index.d.ts +18 -0
  68. package/lib/components/Dropdown/Dropdown.js +18 -16
  69. package/lib/components/FileUploader/FileUploader.d.ts +8 -92
  70. package/lib/components/FileUploader/FileUploader.js +113 -134
  71. package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
  72. package/lib/components/FluidComboBox/FluidComboBox.Skeleton.d.ts +15 -0
  73. package/lib/components/FluidComboBox/FluidComboBox.Skeleton.js +1 -2
  74. package/lib/components/FluidComboBox/FluidComboBox.d.ts +102 -0
  75. package/lib/components/FluidComboBox/FluidComboBox.js +2 -3
  76. package/lib/components/FluidComboBox/index.d.ts +13 -0
  77. package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.d.ts +19 -0
  78. package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +2 -2
  79. package/lib/components/FluidDatePicker/FluidDatePicker.d.ts +39 -0
  80. package/lib/components/FluidDatePicker/FluidDatePicker.js +3 -4
  81. package/lib/components/FluidDatePicker/index.d.ts +13 -0
  82. package/lib/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +10 -0
  83. package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +1 -2
  84. package/lib/components/FluidDatePickerInput/index.d.ts +9 -0
  85. package/lib/components/IdPrefix/index.d.ts +26 -0
  86. package/lib/components/Menu/MenuItem.js +1 -4
  87. package/lib/components/MenuButton/index.d.ts +4 -0
  88. package/lib/components/MenuButton/index.js +19 -5
  89. package/lib/components/MultiSelect/MultiSelect.js +18 -16
  90. package/lib/components/OverflowMenu/next/index.d.ts +4 -0
  91. package/lib/components/OverflowMenu/next/index.js +21 -11
  92. package/lib/components/PaginationNav/PaginationNav.js +1 -1
  93. package/lib/components/Popover/index.js +18 -14
  94. package/lib/components/Portal/index.d.ts +25 -0
  95. package/lib/components/Slider/Slider.js +2 -2
  96. package/lib/components/Tabs/usePressable.js +2 -0
  97. package/lib/components/Tag/DismissibleTag.js +2 -2
  98. package/lib/components/Tag/OperationalTag.d.ts +2 -10
  99. package/lib/components/Tag/OperationalTag.js +2 -14
  100. package/lib/components/Tag/SelectableTag.d.ts +2 -10
  101. package/lib/components/Tag/SelectableTag.js +2 -16
  102. package/lib/components/Toggle/Toggle.js +2 -0
  103. package/lib/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
  104. package/lib/components/ToggleSmall/index.d.ts +7 -0
  105. package/lib/components/TreeView/TreeNode.js +4 -2
  106. package/lib/components/TreeView/TreeView.js +4 -4
  107. package/lib/components/UIShell/SideNavMenuItem.d.ts +4 -3
  108. package/lib/components/UIShell/SideNavMenuItem.js +1 -4
  109. package/lib/index.js +12 -12
  110. package/lib/internal/useIdPrefix.d.ts +9 -0
  111. package/package.json +7 -7
  112. package/telemetry.yml +809 -809
@@ -16,7 +16,7 @@ var PropTypes = require('prop-types');
16
16
  var React = require('react');
17
17
  require('../Text/index.js');
18
18
  var iconsReact = require('@carbon/icons-react');
19
- var index = require('../ListBox/index.js');
19
+ var index$1 = require('../ListBox/index.js');
20
20
  var ListBoxSelection = require('../ListBox/next/ListBoxSelection.js');
21
21
  var ListBoxTrigger = require('../ListBox/next/ListBoxTrigger.js');
22
22
  var useId = require('../../internal/useId.js');
@@ -27,6 +27,7 @@ require('../FluidForm/FluidForm.js');
27
27
  var FormContext = require('../FluidForm/FormContext.js');
28
28
  var react = require('@floating-ui/react');
29
29
  var floatingUi_dom = require('../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js');
30
+ var index = require('../FeatureFlags/index.js');
30
31
  var Text = require('../Text/Text.js');
31
32
  var match = require('../../internal/keyboard/match.js');
32
33
  var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
@@ -46,8 +47,7 @@ const {
46
47
  ItemMouseMove,
47
48
  InputKeyDownArrowUp,
48
49
  InputKeyDownArrowDown,
49
- MenuMouseLeave,
50
- FunctionSelectItem
50
+ MenuMouseLeave
51
51
  } = Downshift.useCombobox.stateChangeTypes;
52
52
  const defaultItemToString = item => {
53
53
  if (typeof item === 'string') {
@@ -62,26 +62,42 @@ const defaultItemToString = item => {
62
62
  return '';
63
63
  };
64
64
  const defaultShouldFilterItem = () => true;
65
- const getInputValue = _ref => {
65
+ const autocompleteCustomFilter = _ref => {
66
+ let {
67
+ item,
68
+ inputValue
69
+ } = _ref;
70
+ if (inputValue === null || inputValue === '') {
71
+ return true; // Show all items if there's no input
72
+ }
73
+ const lowercaseItem = item.toLowerCase();
74
+ const lowercaseInput = inputValue.toLowerCase();
75
+ return lowercaseItem.startsWith(lowercaseInput);
76
+ };
77
+ const getInputValue = _ref2 => {
66
78
  let {
67
79
  initialSelectedItem,
68
80
  inputValue,
69
81
  itemToString,
70
- selectedItem
71
- } = _ref;
82
+ selectedItem,
83
+ prevSelectedItem
84
+ } = _ref2;
72
85
  if (selectedItem) {
73
86
  return itemToString(selectedItem);
74
87
  }
75
88
  if (initialSelectedItem) {
76
89
  return itemToString(initialSelectedItem);
77
90
  }
91
+ if (!selectedItem && prevSelectedItem) {
92
+ return '';
93
+ }
78
94
  return inputValue || '';
79
95
  };
80
- const findHighlightedIndex = (_ref2, inputValue) => {
96
+ const findHighlightedIndex = (_ref3, inputValue) => {
81
97
  let {
82
98
  items,
83
99
  itemToString = defaultItemToString
84
- } = _ref2;
100
+ } = _ref3;
85
101
  if (!inputValue) {
86
102
  return -1;
87
103
  }
@@ -104,6 +120,8 @@ const findHighlightedIndex = (_ref2, inputValue) => {
104
120
  */
105
121
 
106
122
  const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
123
+ const prevInputLengthRef = React.useRef(0);
124
+ const inputRef = React.useRef(null);
107
125
  const {
108
126
  ['aria-label']: ariaLabel = 'Choose an item',
109
127
  ariaLabel: deprecatedAriaLabel,
@@ -132,25 +150,27 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
132
150
  size,
133
151
  titleText,
134
152
  translateWithId,
153
+ typeahead = false,
135
154
  warn,
136
155
  warnText,
137
156
  allowCustomValue = false,
138
157
  slug,
139
158
  ...rest
140
159
  } = props;
160
+ const enableFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
141
161
  const {
142
162
  refs,
143
163
  floatingStyles,
144
164
  middlewareData
145
- } = react.useFloating(autoAlign ? {
165
+ } = react.useFloating(enableFloatingStyles ? {
146
166
  placement: direction,
147
167
  strategy: 'fixed',
148
- middleware: [react.flip(), floatingUi_dom.hide()],
168
+ middleware: autoAlign ? [react.flip(), floatingUi_dom.hide()] : undefined,
149
169
  whileElementsMounted: react.autoUpdate
150
170
  } : {});
151
171
  const parentWidth = refs?.reference?.current?.clientWidth;
152
172
  React.useEffect(() => {
153
- if (autoAlign) {
173
+ if (enableFloatingStyles) {
154
174
  const updatedFloatingStyles = {
155
175
  ...floatingStyles,
156
176
  visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
@@ -164,34 +184,69 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
164
184
  refs.floating.current.style.width = parentWidth + 'px';
165
185
  }
166
186
  }
167
- }, [autoAlign, floatingStyles, refs.floating, parentWidth]);
168
- const prefix = usePrefix.usePrefix();
169
- const {
170
- isFluid
171
- } = React.useContext(FormContext.FormContext);
172
- const textInput = React.useRef(null);
173
- const comboBoxInstanceId = useId.useId();
187
+ }, [enableFloatingStyles, floatingStyles, refs.floating, parentWidth]);
174
188
  const [inputValue, setInputValue] = React.useState(getInputValue({
175
189
  initialSelectedItem,
176
190
  inputValue: '',
177
191
  itemToString,
178
192
  selectedItem: selectedItemProp
179
193
  }));
194
+ const [typeaheadText, setTypeaheadText] = React.useState('');
195
+ React.useEffect(() => {
196
+ if (typeahead) {
197
+ if (inputValue.length >= prevInputLengthRef.current) {
198
+ if (inputValue) {
199
+ const filteredItems = items.filter(item => autocompleteCustomFilter({
200
+ item: itemToString(item),
201
+ inputValue: inputValue
202
+ }));
203
+ if (filteredItems.length > 0) {
204
+ const suggestion = itemToString(filteredItems[0]);
205
+ setTypeaheadText(suggestion.slice(inputValue.length));
206
+ } else {
207
+ setTypeaheadText('');
208
+ }
209
+ } else {
210
+ setTypeaheadText('');
211
+ }
212
+ } else {
213
+ setTypeaheadText('');
214
+ }
215
+ prevInputLengthRef.current = inputValue.length;
216
+ }
217
+ }, [typeahead, inputValue, items, itemToString, autocompleteCustomFilter]);
218
+ const prefix = usePrefix.usePrefix();
219
+ const {
220
+ isFluid
221
+ } = React.useContext(FormContext.FormContext);
222
+ const textInput = React.useRef(null);
223
+ const comboBoxInstanceId = useId.useId();
180
224
  const [isFocused, setIsFocused] = React.useState(false);
181
- const [prevSelectedItem, setPrevSelectedItem] = React.useState();
182
- const [doneInitialSelectedItem, setDoneInitialSelectedItem] = React.useState(false);
183
225
  const savedOnInputChange = React.useRef(onInputChange);
184
- if (!doneInitialSelectedItem || prevSelectedItem !== selectedItemProp) {
185
- setDoneInitialSelectedItem(true);
186
- setPrevSelectedItem(selectedItemProp);
187
- setInputValue(getInputValue({
188
- initialSelectedItem,
189
- inputValue,
190
- itemToString,
191
- selectedItem: selectedItemProp
192
- }));
193
- }
194
- const filterItems = (items, itemToString, inputValue) => items.filter(item => shouldFilterItem ? shouldFilterItem({
226
+ const prevSelectedItemProp = React.useRef(selectedItemProp);
227
+
228
+ // fully controlled combobox: handle changes to selectedItemProp
229
+ React.useEffect(() => {
230
+ if (prevSelectedItemProp.current !== selectedItemProp) {
231
+ const currentInputValue = getInputValue({
232
+ initialSelectedItem,
233
+ inputValue,
234
+ itemToString,
235
+ selectedItem: selectedItemProp,
236
+ prevSelectedItem: prevSelectedItemProp.current
237
+ });
238
+ setInputValue(currentInputValue);
239
+ onChange({
240
+ selectedItem: selectedItemProp,
241
+ inputValue: currentInputValue
242
+ });
243
+ prevSelectedItemProp.current = selectedItemProp;
244
+ }
245
+ }, [selectedItemProp]);
246
+ const filterItems = (items, itemToString, inputValue) => items.filter(item => typeahead ? autocompleteCustomFilter({
247
+ item: itemToString(item),
248
+ inputValue
249
+ }) : shouldFilterItem ? shouldFilterItem({
195
250
  item,
196
251
  itemToString,
197
252
  inputValue
@@ -214,7 +269,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
214
269
  ...props,
215
270
  items: filteredItems(inputValue)
216
271
  }, inputValue);
217
- const stateReducer = React__default["default"].useCallback((state, actionAndChanges) => {
272
+ const stateReducer = React.useCallback((state, actionAndChanges) => {
218
273
  const {
219
274
  type,
220
275
  changes
@@ -250,14 +305,6 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
250
305
  }
251
306
  return changes;
252
307
  }
253
- case FunctionSelectItem:
254
- if (onChange) {
255
- onChange({
256
- selectedItem: changes.selectedItem,
257
- inputValue: changes.inputValue
258
- });
259
- }
260
- return changes;
261
308
  case InputKeyDownEnter:
262
309
  if (allowCustomValue) {
263
310
  setInputValue(inputValue);
@@ -331,7 +378,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
331
378
  [`${prefix}--list-box--up`]: direction === 'top',
332
379
  [`${prefix}--combo-box--warning`]: showWarning,
333
380
  [`${prefix}--combo-box--readonly`]: readOnly,
334
- [`${prefix}--autoalign`]: autoAlign
381
+ [`${prefix}--autoalign`]: enableFloatingStyles
335
382
  });
336
383
  const titleClasses = cx__default["default"](`${prefix}--label`, {
337
384
  [`${prefix}--label--disabled`]: disabled
@@ -387,25 +434,33 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
387
434
  itemToString: item => {
388
435
  return itemToString(item);
389
436
  },
390
- onInputValueChange(_ref3) {
437
+ onInputValueChange(_ref4) {
391
438
  let {
392
439
  inputValue
393
- } = _ref3;
394
- setInputValue(inputValue || '');
395
- setHighlightedIndex(indexToHighlight(inputValue));
440
+ } = _ref4;
441
+ const normalizedInput = inputValue || '';
442
+ setInputValue(normalizedInput);
443
+ if (selectedItemProp && !inputValue) {
444
+ // ensure onChange is called when selectedItem is cleared
445
+ onChange({
446
+ selectedItem,
447
+ inputValue: normalizedInput
448
+ });
449
+ }
450
+ setHighlightedIndex(indexToHighlight(normalizedInput));
396
451
  },
397
- onSelectedItemChange(_ref4) {
452
+ onSelectedItemChange(_ref5) {
398
453
  let {
399
454
  selectedItem
400
- } = _ref4;
455
+ } = _ref5;
401
456
  onChange({
402
457
  selectedItem
403
458
  });
404
459
  },
405
- onHighlightedIndexChange: _ref5 => {
460
+ onHighlightedIndexChange: _ref6 => {
406
461
  let {
407
462
  highlightedIndex
408
- } = _ref5;
463
+ } = _ref6;
409
464
  if (highlightedIndex > -1 && typeof window !== undefined) {
410
465
  const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
411
466
  const highlightedItem = itemArray[highlightedIndex];
@@ -484,15 +539,24 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
484
539
 
485
540
  // Memoize the value of getMenuProps to avoid an infinite loop
486
541
  const menuProps = React.useMemo(() => getMenuProps({
487
- 'aria-label': deprecatedAriaLabel || ariaLabel,
488
- ref: autoAlign ? refs.setFloating : null
489
- }), [autoAlign, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
542
+ ref: enableFloatingStyles ? refs.setFloating : null
543
+ }), [enableFloatingStyles, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
544
+ React.useEffect(() => {
545
+ if (textInput.current) {
546
+ if (inputRef.current && typeaheadText) {
547
+ const selectionStart = inputValue.length;
548
+ const selectionEnd = selectionStart + typeaheadText.length;
549
+ inputRef.current.value = inputValue + typeaheadText;
550
+ inputRef.current.setSelectionRange(selectionStart, selectionEnd);
551
+ }
552
+ }
553
+ }, [inputValue, typeaheadText]);
490
554
  return /*#__PURE__*/React__default["default"].createElement("div", {
491
555
  className: wrapperClasses
492
556
  }, titleText && /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["extends"]({
493
557
  as: "label",
494
558
  className: titleClasses
495
- }, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index["default"], {
559
+ }, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index$1["default"], {
496
560
  onFocus: handleFocus,
497
561
  onBlur: handleFocus,
498
562
  className: className,
@@ -504,7 +568,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
504
568
  light: light,
505
569
  size: size,
506
570
  warn: warn,
507
- ref: autoAlign ? refs.setReference : null,
571
+ ref: enableFloatingStyles ? refs.setReference : null,
508
572
  warnText: warnText,
509
573
  warnTextId: warnTextId
510
574
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -517,9 +581,16 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
517
581
  "aria-haspopup": "listbox",
518
582
  title: textInput?.current?.value
519
583
  }, getInputProps({
584
+ 'aria-label': titleText ? undefined : deprecatedAriaLabel || ariaLabel,
520
585
  'aria-controls': isOpen ? undefined : menuProps.id,
521
586
  placeholder,
522
- ref: mergeRefs["default"](textInput, ref),
587
+ value: inputValue,
588
+ onChange: e => {
589
+ const newValue = e.target.value;
590
+ setInputValue(newValue);
591
+ downshiftSetInputValue(newValue);
592
+ },
593
+ ref: mergeRefs["default"](textInput, ref, inputRef),
523
594
  onKeyDown: event => {
524
595
  if (match.match(event, keys.Space)) {
525
596
  event.stopPropagation();
@@ -567,6 +638,15 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
567
638
  toggleMenu();
568
639
  }
569
640
  }
641
+ if (typeahead && event.key === 'Tab') {
642
+ // event.preventDefault();
643
+ const matchingItem = items.find(item => itemToString(item).toLowerCase().startsWith(inputValue.toLowerCase()));
644
+ if (matchingItem) {
645
+ const newValue = itemToString(matchingItem);
646
+ downshiftSetInputValue(newValue);
647
+ selectItem(matchingItem);
648
+ }
649
+ }
570
650
  }
571
651
  }), rest, readOnlyEventHandlers, {
572
652
  readOnly: readOnly,
@@ -586,12 +666,12 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
586
666
  }), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
587
667
  isOpen: isOpen,
588
668
  translateWithId: translateWithId
589
- }))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index$1) => {
669
+ }))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index$1["default"].Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
590
670
  const isObject = item !== null && typeof item === 'object';
591
671
  const title = isObject && 'text' in item && itemToElement ? item.text?.toString() : itemToString(item);
592
672
  const itemProps = getItemProps({
593
673
  item,
594
- index: index$1
674
+ index
595
675
  });
596
676
 
597
677
  // The initial implementation using <Downshift> would place the disabled attribute
@@ -604,10 +684,10 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
604
684
  // eslint-disable-line @typescript-eslint/no-unused-vars
605
685
  ...modifiedItemProps
606
686
  } = itemProps;
607
- return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
687
+ return /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
608
688
  key: itemProps.id,
609
689
  isActive: selectedItem === item,
610
- isHighlighted: highlightedIndex === index$1,
690
+ isHighlighted: highlightedIndex === index,
611
691
  title: title,
612
692
  disabled: disabled
613
693
  }, modifiedItemProps), ItemToElement ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
@@ -759,6 +839,7 @@ ComboBox.propTypes = {
759
839
  * Specify your own filtering logic by passing in a `shouldFilterItem`
760
840
  * function that takes in the current input and an item and passes back
761
841
  * whether or not the item should be filtered.
842
+ * this prop will be ignored if `typeahead` prop is enabled
762
843
  */
763
844
  shouldFilterItem: PropTypes__default["default"].func,
764
845
  /**
@@ -779,6 +860,10 @@ ComboBox.propTypes = {
779
860
  * and returns the localized string for the message
780
861
  */
781
862
  translateWithId: PropTypes__default["default"].func,
863
+ /**
864
+ * **Experimental**: will enable autcomplete and typeahead for the input field
865
+ */
866
+ typeahead: PropTypes__default["default"].bool,
782
867
  /**
783
868
  * Specify whether the control is currently in warning state
784
869
  */
@@ -14,7 +14,7 @@ var React = require('react');
14
14
  var PropTypes = require('prop-types');
15
15
  var cx = require('classnames');
16
16
  var iconsReact = require('@carbon/icons-react');
17
- var index = require('../IconButton/index.js');
17
+ var index$1 = require('../IconButton/index.js');
18
18
  var Button = require('../Button/Button.js');
19
19
  require('../Button/Button.Skeleton.js');
20
20
  var Menu = require('../Menu/Menu.js');
@@ -24,6 +24,7 @@ var useId = require('../../internal/useId.js');
24
24
  var usePrefix = require('../../internal/usePrefix.js');
25
25
  var react = require('@floating-ui/react');
26
26
  var floatingUi_dom = require('../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js');
27
+ var index = require('../FeatureFlags/index.js');
27
28
  var mergeRefs = require('../../tools/mergeRefs.js');
28
29
 
29
30
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -57,12 +58,18 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
57
58
  translateWithId: t = defaultTranslateWithId,
58
59
  ...rest
59
60
  } = _ref;
61
+ // feature flag utilized to separate out only the dynamic styles from @floating-ui
62
+ // flag is turned on when collision detection (ie. flip, hide) logic is not desired
63
+ const enableOnlyFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles');
60
64
  const id = useId.useId('combobutton');
61
65
  const prefix = usePrefix.usePrefix();
62
66
  const containerRef = React.useRef(null);
63
- const middlewares = [react.flip({
64
- crossAxis: false
65
- }), floatingUi_dom.hide()];
67
+ let middlewares = [];
68
+ if (!enableOnlyFloatingStyles) {
69
+ middlewares = [react.flip({
70
+ crossAxis: false
71
+ }), floatingUi_dom.hide()];
72
+ }
66
73
  if (menuAlignment === 'bottom' || menuAlignment === 'top') {
67
74
  middlewares.push(react.size({
68
75
  apply(_ref2) {
@@ -137,7 +144,7 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
137
144
  size: size,
138
145
  disabled: disabled,
139
146
  onClick: handlePrimaryActionClick
140
- }, label)), /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
147
+ }, label)), /*#__PURE__*/React__default["default"].createElement(index$1.IconButton, {
141
148
  ref: refs.setReference,
142
149
  className: triggerClasses,
143
150
  label: t('carbon.combo-button.additional-actions'),
@@ -28,8 +28,5 @@ interface TableCellProps extends ReactAttr<HTMLTableCellElement> {
28
28
  */
29
29
  headers?: string;
30
30
  }
31
- declare const TableCell: {
32
- ({ children, className, hasSlugHeader, colSpan, ...rest }: TableCellProps): import("react/jsx-runtime").JSX.Element;
33
- displayName: string;
34
- };
31
+ declare const TableCell: React.ForwardRefExoticComponent<TableCellProps & React.RefAttributes<HTMLTableCellElement>>;
35
32
  export default TableCell;
@@ -19,7 +19,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
19
19
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
20
20
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
21
21
 
22
- const TableCell = _ref => {
22
+ const TableCell = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
23
23
  let {
24
24
  children,
25
25
  className,
@@ -33,9 +33,10 @@ const TableCell = _ref => {
33
33
  });
34
34
  return /*#__PURE__*/React__default["default"].createElement("td", _rollupPluginBabelHelpers["extends"]({
35
35
  className: tableCellClassNames ? tableCellClassNames : undefined,
36
+ ref: ref,
36
37
  colSpan: colSpan
37
38
  }, rest), children);
38
- };
39
+ });
39
40
  TableCell.displayName = 'TableCell';
40
41
 
41
42
  exports["default"] = TableCell;
@@ -403,9 +403,6 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
403
403
  }
404
404
  }
405
405
  function handleOnChange(event) {
406
- if (datePickerType == 'single' && closeOnSelect) {
407
- calendar.calendarContainer.classList.remove('open');
408
- }
409
406
  const {
410
407
  target
411
408
  } = event;
@@ -421,12 +418,16 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
421
418
  if (calendar.selectedDates.length === 0) {
422
419
  return;
423
420
  }
424
- calendar.clear();
425
- calendar.input.focus();
421
+ }
422
+ function handleKeyPress(event) {
423
+ if (match.match(event, keys.Enter) && closeOnSelect && datePickerType == 'single') {
424
+ calendar.calendarContainer.classList.remove('open');
425
+ }
426
426
  }
427
427
  if (start) {
428
428
  start.addEventListener('keydown', handleArrowDown);
429
429
  start.addEventListener('change', handleOnChange);
430
+ start.addEventListener('keypress', handleKeyPress);
430
431
  if (calendar && calendar.calendarContainer) {
431
432
  // Flatpickr's calendar dialog is not rendered in a landmark causing an
432
433
  // error with IBM Equal Access Accessibility Checker so we add an aria
@@ -439,6 +440,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
439
440
  if (end) {
440
441
  end.addEventListener('keydown', handleArrowDown);
441
442
  end.addEventListener('change', handleOnChange);
443
+ end.addEventListener('keypress', handleKeyPress);
442
444
  }
443
445
 
444
446
  //component did unmount equivalent
@@ -462,10 +464,12 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
462
464
  if (start) {
463
465
  start.removeEventListener('keydown', handleArrowDown);
464
466
  start.removeEventListener('change', handleOnChange);
467
+ start.removeEventListener('keypress', handleKeyPress);
465
468
  }
466
469
  if (end) {
467
470
  end.removeEventListener('keydown', handleArrowDown);
468
471
  end.removeEventListener('change', handleOnChange);
472
+ end.removeEventListener('change', handleKeyPress);
469
473
  }
470
474
  };
471
475
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -0,0 +1,18 @@
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
+ declare function useDisclosure(id: any): {
8
+ buttonProps: {
9
+ 'aria-controls': any;
10
+ 'aria-expanded': boolean;
11
+ onClick(): void;
12
+ };
13
+ contentProps: {
14
+ id: any;
15
+ };
16
+ open: boolean;
17
+ };
18
+ export { useDisclosure };
@@ -15,7 +15,7 @@ var Downshift = require('downshift');
15
15
  var cx = require('classnames');
16
16
  var PropTypes = require('prop-types');
17
17
  var iconsReact = require('@carbon/icons-react');
18
- var index = require('../ListBox/index.js');
18
+ var index$1 = require('../ListBox/index.js');
19
19
  var mergeRefs = require('../../tools/mergeRefs.js');
20
20
  var deprecate = require('../../prop-types/deprecate.js');
21
21
  var usePrefix = require('../../internal/usePrefix.js');
@@ -24,6 +24,7 @@ var FormContext = require('../FluidForm/FormContext.js');
24
24
  var useId = require('../../internal/useId.js');
25
25
  var react = require('@floating-ui/react');
26
26
  var floatingUi_dom = require('../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js');
27
+ var index = require('../FeatureFlags/index.js');
27
28
  var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
28
29
 
29
30
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -81,11 +82,12 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
81
82
  slug,
82
83
  ...other
83
84
  } = _ref;
85
+ const enableFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles');
84
86
  const {
85
87
  refs,
86
88
  floatingStyles,
87
89
  middlewareData
88
- } = react.useFloating(autoAlign ? {
90
+ } = react.useFloating(enableFloatingStyles || autoAlign ? {
89
91
  placement: direction,
90
92
  // The floating element is positioned relative to its nearest
91
93
  // containing block (usually the viewport). It will in many cases also
@@ -103,12 +105,14 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
103
105
  width: `${rects.reference.width}px`
104
106
  });
105
107
  }
106
- }), react.flip(), floatingUi_dom.hide()],
108
+ }), autoAlign && react.flip(), autoAlign && floatingUi_dom.hide()],
107
109
  whileElementsMounted: react.autoUpdate
108
- } : {} // When autoAlign is turned off, floating-ui will not be used
110
+ } : {}
111
+ // When autoAlign is turned off & the `enable-v12-dynamic-floating-styles` feature flag is not
112
+ // enabled, floating-ui will not be used
109
113
  );
110
114
  React.useEffect(() => {
111
- if (autoAlign) {
115
+ if (enableFloatingStyles || autoAlign) {
112
116
  const updatedFloatingStyles = {
113
117
  ...floatingStyles,
114
118
  visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
@@ -247,9 +251,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
247
251
  // NOTE: does not prevent click
248
252
  evt.preventDefault();
249
253
  // focus on the element as per readonly input behavior
250
- if (mergedRef.current !== undefined) {
251
- mergedRef.current.focus();
252
- }
254
+ mergedRef?.current?.focus();
253
255
  },
254
256
  onKeyDown: evt => {
255
257
  const selectAccessKeys = ['ArrowDown', 'ArrowUp', ' ', 'Enter'];
@@ -277,7 +279,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
277
279
  }
278
280
  };
279
281
  const menuProps = React.useMemo(() => getMenuProps({
280
- ref: autoAlign ? refs.setFloating : null
282
+ ref: enableFloatingStyles || autoAlign ? refs.setFloating : null
281
283
  }), [autoAlign, getMenuProps, refs.setFloating]);
282
284
 
283
285
  // Slug is always size `mini`
@@ -291,7 +293,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
291
293
  className: wrapperClasses
292
294
  }, other), titleText && /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
293
295
  className: titleClasses
294
- }, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index["default"], {
296
+ }, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index$1["default"], {
295
297
  onFocus: handleFocus,
296
298
  onBlur: handleFocus,
297
299
  size: size,
@@ -302,7 +304,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
302
304
  warnText: warnText,
303
305
  light: light,
304
306
  isOpen: isOpen,
305
- ref: autoAlign ? refs.setReference : null,
307
+ ref: enableFloatingStyles || autoAlign ? refs.setReference : null,
306
308
  id: id
307
309
  }, invalid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
308
310
  className: `${prefix}--list-box__invalid-icon`
@@ -322,23 +324,23 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
322
324
  ref: mergedRef
323
325
  }), /*#__PURE__*/React__default["default"].createElement("span", {
324
326
  className: `${prefix}--list-box__label`
325
- }, selectedItem ? renderSelectedItem ? renderSelectedItem(selectedItem) : itemToString(selectedItem) : label), /*#__PURE__*/React__default["default"].createElement(index["default"].MenuIcon, {
327
+ }, selectedItem ? renderSelectedItem ? renderSelectedItem(selectedItem) : itemToString(selectedItem) : label), /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuIcon, {
326
328
  isOpen: isOpen,
327
329
  translateWithId: translateWithId
328
- })), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen && items.map((item, index$1) => {
330
+ })), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index$1["default"].Menu, menuProps, isOpen && items.map((item, index) => {
329
331
  const isObject = item !== null && typeof item === 'object';
330
332
  const itemProps = getItemProps({
331
333
  item,
332
- index: index$1
334
+ index
333
335
  });
334
336
  if (item !== null && typeof item === 'object' && Object.prototype.hasOwnProperty.call(item, 'id')) {
335
337
  itemProps.id = item['id'];
336
338
  }
337
339
  const title = isObject && 'text' in item && itemToElement ? item.text : itemToString(item);
338
- return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
340
+ return /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
339
341
  key: itemProps.id,
340
342
  isActive: selectedItem === item,
341
- isHighlighted: highlightedIndex === index$1,
343
+ isHighlighted: highlightedIndex === index,
342
344
  title: title,
343
345
  disabled: itemProps['aria-disabled']
344
346
  }, itemProps), typeof item === 'object' && ItemToElement !== undefined && ItemToElement !== null ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({