@carbon/react 1.67.1 → 1.68.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 (73) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +880 -880
  2. package/es/components/ComboBox/ComboBox.d.ts +5 -0
  3. package/es/components/ComboBox/ComboBox.js +147 -45
  4. package/es/components/ComposedModal/ModalHeader.js +1 -1
  5. package/es/components/DatePicker/DatePicker.js +10 -6
  6. package/es/components/Dropdown/Dropdown.js +3 -2
  7. package/es/components/FeatureFlags/index.d.ts +56 -0
  8. package/es/components/FeatureFlags/index.js +2 -2
  9. package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
  10. package/es/components/FluidComboBox/FluidComboBox.Skeleton.d.ts +15 -0
  11. package/es/components/FluidComboBox/FluidComboBox.Skeleton.js +1 -2
  12. package/es/components/FluidComboBox/FluidComboBox.d.ts +102 -0
  13. package/es/components/FluidComboBox/FluidComboBox.js +2 -3
  14. package/es/components/FluidComboBox/index.d.ts +13 -0
  15. package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.d.ts +19 -0
  16. package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +2 -2
  17. package/es/components/FluidDatePicker/FluidDatePicker.d.ts +39 -0
  18. package/es/components/FluidDatePicker/FluidDatePicker.js +2 -3
  19. package/es/components/FluidDatePicker/index.d.ts +13 -0
  20. package/es/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +10 -0
  21. package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +1 -2
  22. package/es/components/FluidDatePickerInput/index.d.ts +9 -0
  23. package/es/components/FluidMultiSelect/FluidFilterableMultiSelect.d.ts +144 -0
  24. package/es/components/FluidMultiSelect/FluidMultiSelect.Skeleton.d.ts +15 -0
  25. package/es/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +1 -2
  26. package/es/components/FluidMultiSelect/FluidMultiSelect.d.ts +149 -0
  27. package/es/components/FluidMultiSelect/FluidMultiSelect.js +5 -3
  28. package/es/components/FluidMultiSelect/index.d.ts +13 -0
  29. package/es/components/FluidNumberInput/index.d.ts +2 -2
  30. package/es/components/FluidSearch/index.d.ts +2 -2
  31. package/es/components/FluidSelect/index.d.ts +2 -2
  32. package/es/components/FluidTimePicker/index.d.ts +2 -2
  33. package/es/components/Modal/Modal.js +1 -1
  34. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +2 -2
  35. package/es/components/Tabs/usePressable.js +2 -0
  36. package/es/components/Tooltip/DefinitionTooltip.js +4 -2
  37. package/es/index.js +7 -7
  38. package/lib/components/ComboBox/ComboBox.d.ts +5 -0
  39. package/lib/components/ComboBox/ComboBox.js +146 -44
  40. package/lib/components/ComposedModal/ModalHeader.js +1 -1
  41. package/lib/components/DatePicker/DatePicker.js +9 -5
  42. package/lib/components/Dropdown/Dropdown.js +3 -2
  43. package/lib/components/FeatureFlags/index.d.ts +56 -0
  44. package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
  45. package/lib/components/FluidComboBox/FluidComboBox.Skeleton.d.ts +15 -0
  46. package/lib/components/FluidComboBox/FluidComboBox.Skeleton.js +1 -2
  47. package/lib/components/FluidComboBox/FluidComboBox.d.ts +102 -0
  48. package/lib/components/FluidComboBox/FluidComboBox.js +2 -3
  49. package/lib/components/FluidComboBox/index.d.ts +13 -0
  50. package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.d.ts +19 -0
  51. package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +2 -2
  52. package/lib/components/FluidDatePicker/FluidDatePicker.d.ts +39 -0
  53. package/lib/components/FluidDatePicker/FluidDatePicker.js +3 -4
  54. package/lib/components/FluidDatePicker/index.d.ts +13 -0
  55. package/lib/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +10 -0
  56. package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +1 -2
  57. package/lib/components/FluidDatePickerInput/index.d.ts +9 -0
  58. package/lib/components/FluidMultiSelect/FluidFilterableMultiSelect.d.ts +144 -0
  59. package/lib/components/FluidMultiSelect/FluidMultiSelect.Skeleton.d.ts +15 -0
  60. package/lib/components/FluidMultiSelect/FluidMultiSelect.Skeleton.js +1 -2
  61. package/lib/components/FluidMultiSelect/FluidMultiSelect.d.ts +149 -0
  62. package/lib/components/FluidMultiSelect/FluidMultiSelect.js +5 -3
  63. package/lib/components/FluidMultiSelect/index.d.ts +13 -0
  64. package/lib/components/FluidNumberInput/index.d.ts +2 -2
  65. package/lib/components/FluidSearch/index.d.ts +2 -2
  66. package/lib/components/FluidSelect/index.d.ts +2 -2
  67. package/lib/components/FluidTimePicker/index.d.ts +2 -2
  68. package/lib/components/Modal/Modal.js +1 -1
  69. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +2 -2
  70. package/lib/components/Tabs/usePressable.js +2 -0
  71. package/lib/components/Tooltip/DefinitionTooltip.js +4 -2
  72. package/lib/index.js +14 -14
  73. package/package.json +9 -9
@@ -158,6 +158,7 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
158
158
  * Specify your own filtering logic by passing in a `shouldFilterItem`
159
159
  * function that takes in the current input and an item and passes back
160
160
  * whether or not the item should be filtered.
161
+ * this prop will be ignored if `typeahead` prop is enabled
161
162
  */
162
163
  shouldFilterItem?: (input: {
163
164
  item: ItemType;
@@ -177,6 +178,10 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
177
178
  * combobox via ARIA attributes.
178
179
  */
179
180
  titleText?: ReactNode;
181
+ /**
182
+ * **Experimental**: will enable autcomplete and typeahead for the input field
183
+ */
184
+ typeahead?: boolean;
180
185
  /**
181
186
  * Specify whether the control is currently in warning state
182
187
  */
@@ -46,8 +46,7 @@ const {
46
46
  ItemMouseMove,
47
47
  InputKeyDownArrowUp,
48
48
  InputKeyDownArrowDown,
49
- MenuMouseLeave,
50
- FunctionSelectItem
49
+ MenuMouseLeave
51
50
  } = Downshift.useCombobox.stateChangeTypes;
52
51
  const defaultItemToString = item => {
53
52
  if (typeof item === 'string') {
@@ -62,26 +61,42 @@ const defaultItemToString = item => {
62
61
  return '';
63
62
  };
64
63
  const defaultShouldFilterItem = () => true;
65
- const getInputValue = _ref => {
64
+ const autocompleteCustomFilter = _ref => {
65
+ let {
66
+ item,
67
+ inputValue
68
+ } = _ref;
69
+ if (inputValue === null || inputValue === '') {
70
+ return true; // Show all items if there's no input
71
+ }
72
+ const lowercaseItem = item.toLowerCase();
73
+ const lowercaseInput = inputValue.toLowerCase();
74
+ return lowercaseItem.startsWith(lowercaseInput);
75
+ };
76
+ const getInputValue = _ref2 => {
66
77
  let {
67
78
  initialSelectedItem,
68
79
  inputValue,
69
80
  itemToString,
70
- selectedItem
71
- } = _ref;
81
+ selectedItem,
82
+ prevSelectedItem
83
+ } = _ref2;
72
84
  if (selectedItem) {
73
85
  return itemToString(selectedItem);
74
86
  }
75
87
  if (initialSelectedItem) {
76
88
  return itemToString(initialSelectedItem);
77
89
  }
90
+ if (!selectedItem && prevSelectedItem) {
91
+ return '';
92
+ }
78
93
  return inputValue || '';
79
94
  };
80
- const findHighlightedIndex = (_ref2, inputValue) => {
95
+ const findHighlightedIndex = (_ref3, inputValue) => {
81
96
  let {
82
97
  items,
83
98
  itemToString = defaultItemToString
84
- } = _ref2;
99
+ } = _ref3;
85
100
  if (!inputValue) {
86
101
  return -1;
87
102
  }
@@ -104,6 +119,9 @@ const findHighlightedIndex = (_ref2, inputValue) => {
104
119
  */
105
120
 
106
121
  const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
122
+ const [cursorPosition, setCursorPosition] = React.useState(0);
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,6 +150,7 @@ 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,
@@ -165,33 +184,68 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
165
184
  }
166
185
  }
167
186
  }, [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();
174
187
  const [inputValue, setInputValue] = React.useState(getInputValue({
175
188
  initialSelectedItem,
176
189
  inputValue: '',
177
190
  itemToString,
178
191
  selectedItem: selectedItemProp
179
192
  }));
193
+ const [typeaheadText, setTypeaheadText] = React.useState('');
194
+ React.useEffect(() => {
195
+ if (typeahead) {
196
+ if (inputValue.length >= prevInputLengthRef.current) {
197
+ if (inputValue) {
198
+ const filteredItems = items.filter(item => autocompleteCustomFilter({
199
+ item: itemToString(item),
200
+ inputValue: inputValue
201
+ }));
202
+ if (filteredItems.length > 0) {
203
+ const suggestion = itemToString(filteredItems[0]);
204
+ setTypeaheadText(suggestion.slice(inputValue.length));
205
+ } else {
206
+ setTypeaheadText('');
207
+ }
208
+ } else {
209
+ setTypeaheadText('');
210
+ }
211
+ } else {
212
+ setTypeaheadText('');
213
+ }
214
+ prevInputLengthRef.current = inputValue.length;
215
+ }
216
+ }, [typeahead, inputValue, items, itemToString, autocompleteCustomFilter]);
217
+ const prefix = usePrefix.usePrefix();
218
+ const {
219
+ isFluid
220
+ } = React.useContext(FormContext.FormContext);
221
+ const textInput = React.useRef(null);
222
+ const comboBoxInstanceId = useId.useId();
180
223
  const [isFocused, setIsFocused] = React.useState(false);
181
- const [prevSelectedItem, setPrevSelectedItem] = React.useState();
182
- const [doneInitialSelectedItem, setDoneInitialSelectedItem] = React.useState(false);
183
224
  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({
225
+ const prevSelectedItemProp = React.useRef(selectedItemProp);
226
+
227
+ // fully controlled combobox: handle changes to selectedItemProp
228
+ React.useEffect(() => {
229
+ if (prevSelectedItemProp.current !== selectedItemProp) {
230
+ const currentInputValue = getInputValue({
231
+ initialSelectedItem,
232
+ inputValue,
233
+ itemToString,
234
+ selectedItem: selectedItemProp,
235
+ prevSelectedItem: prevSelectedItemProp.current
236
+ });
237
+ setInputValue(currentInputValue);
238
+ onChange({
239
+ selectedItem: selectedItemProp,
240
+ inputValue: currentInputValue
241
+ });
242
+ prevSelectedItemProp.current = selectedItemProp;
243
+ }
244
+ }, [selectedItemProp]);
245
+ const filterItems = (items, itemToString, inputValue) => items.filter(item => typeahead ? autocompleteCustomFilter({
246
+ item: itemToString(item),
247
+ inputValue
248
+ }) : shouldFilterItem ? shouldFilterItem({
195
249
  item,
196
250
  itemToString,
197
251
  inputValue
@@ -214,7 +268,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
214
268
  ...props,
215
269
  items: filteredItems(inputValue)
216
270
  }, inputValue);
217
- const stateReducer = React__default["default"].useCallback((state, actionAndChanges) => {
271
+ const stateReducer = React.useCallback((state, actionAndChanges) => {
218
272
  const {
219
273
  type,
220
274
  changes
@@ -250,14 +304,6 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
250
304
  }
251
305
  return changes;
252
306
  }
253
- case FunctionSelectItem:
254
- if (onChange) {
255
- onChange({
256
- selectedItem: changes.selectedItem,
257
- inputValue: changes.inputValue
258
- });
259
- }
260
- return changes;
261
307
  case InputKeyDownEnter:
262
308
  if (allowCustomValue) {
263
309
  setInputValue(inputValue);
@@ -314,6 +360,12 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
314
360
  if (onToggleClick) {
315
361
  onToggleClick(event);
316
362
  }
363
+ if (readOnly) {
364
+ // Prevent the list from opening if readOnly is true
365
+ event.preventDownshiftDefault = true;
366
+ event?.persist?.();
367
+ return;
368
+ }
317
369
  if (event.target === textInput.current && isOpen) {
318
370
  event.preventDownshiftDefault = true;
319
371
  event?.persist?.();
@@ -381,25 +433,34 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
381
433
  itemToString: item => {
382
434
  return itemToString(item);
383
435
  },
384
- onInputValueChange(_ref3) {
436
+ onInputValueChange(_ref4) {
385
437
  let {
386
438
  inputValue
387
- } = _ref3;
388
- setInputValue(inputValue || '');
389
- setHighlightedIndex(indexToHighlight(inputValue));
439
+ } = _ref4;
440
+ const normalizedInput = inputValue || '';
441
+ setInputValue(normalizedInput);
442
+ if (selectedItemProp && !inputValue) {
443
+ // ensure onChange is called when selectedItem is cleared
444
+ onChange({
445
+ selectedItem,
446
+ inputValue: normalizedInput
447
+ });
448
+ }
449
+ setHighlightedIndex(indexToHighlight(normalizedInput));
450
+ setCursorPosition(inputValue === null ? 0 : normalizedInput.length);
390
451
  },
391
- onSelectedItemChange(_ref4) {
452
+ onSelectedItemChange(_ref5) {
392
453
  let {
393
454
  selectedItem
394
- } = _ref4;
455
+ } = _ref5;
395
456
  onChange({
396
457
  selectedItem
397
458
  });
398
459
  },
399
- onHighlightedIndexChange: _ref5 => {
460
+ onHighlightedIndexChange: _ref6 => {
400
461
  let {
401
462
  highlightedIndex
402
- } = _ref5;
463
+ } = _ref6;
403
464
  if (highlightedIndex > -1 && typeof window !== undefined) {
404
465
  const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
405
466
  const highlightedItem = itemArray[highlightedIndex];
@@ -435,6 +496,11 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
435
496
  };
436
497
  }
437
498
  }, [closeMenu, openMenu, reset, selectItem, setHighlightedIndex, downshiftSetInputValue, toggleMenu]);
499
+ React.useEffect(() => {
500
+ if (inputRef.current) {
501
+ inputRef.current.setSelectionRange(cursorPosition, cursorPosition);
502
+ }
503
+ }, [inputValue, cursorPosition]);
438
504
  const buttonProps = getToggleButtonProps({
439
505
  disabled: disabled || readOnly,
440
506
  onClick: handleToggleClick(isOpen),
@@ -462,6 +528,12 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
462
528
  if (evt.key !== 'Tab') {
463
529
  evt.preventDefault();
464
530
  }
531
+ },
532
+ onClick: evt => {
533
+ // Prevent the default behavior which would open the list
534
+ evt.preventDefault();
535
+ // Focus on the element as per readonly input behavior
536
+ evt.currentTarget.focus();
465
537
  }
466
538
  } : {};
467
539
 
@@ -475,6 +547,16 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
475
547
  'aria-label': deprecatedAriaLabel || ariaLabel,
476
548
  ref: autoAlign ? refs.setFloating : null
477
549
  }), [autoAlign, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
550
+ React.useEffect(() => {
551
+ if (textInput.current) {
552
+ if (inputRef.current && typeaheadText) {
553
+ const selectionStart = inputValue.length;
554
+ const selectionEnd = selectionStart + typeaheadText.length;
555
+ inputRef.current.value = inputValue + typeaheadText;
556
+ inputRef.current.setSelectionRange(selectionStart, selectionEnd);
557
+ }
558
+ }
559
+ }, [inputValue, typeaheadText]);
478
560
  return /*#__PURE__*/React__default["default"].createElement("div", {
479
561
  className: wrapperClasses
480
562
  }, titleText && /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["extends"]({
@@ -507,7 +589,12 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
507
589
  }, getInputProps({
508
590
  'aria-controls': isOpen ? undefined : menuProps.id,
509
591
  placeholder,
510
- ref: mergeRefs["default"](textInput, ref),
592
+ value: inputValue,
593
+ onChange: e => {
594
+ const newValue = e.target.value;
595
+ downshiftSetInputValue(newValue);
596
+ },
597
+ ref: mergeRefs["default"](textInput, ref, inputRef),
511
598
  onKeyDown: event => {
512
599
  if (match.match(event, keys.Space)) {
513
600
  event.stopPropagation();
@@ -555,6 +642,16 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
555
642
  toggleMenu();
556
643
  }
557
644
  }
645
+ if (typeahead && event.key === 'Tab') {
646
+ // event.preventDefault();
647
+ const matchingItem = items.find(item => itemToString(item).toLowerCase().startsWith(inputValue.toLowerCase()));
648
+ if (matchingItem) {
649
+ const newValue = itemToString(matchingItem);
650
+ downshiftSetInputValue(newValue);
651
+ setCursorPosition(newValue.length);
652
+ selectItem(matchingItem);
653
+ }
654
+ }
558
655
  }
559
656
  }), rest, readOnlyEventHandlers, {
560
657
  readOnly: readOnly,
@@ -747,6 +844,7 @@ ComboBox.propTypes = {
747
844
  * Specify your own filtering logic by passing in a `shouldFilterItem`
748
845
  * function that takes in the current input and an item and passes back
749
846
  * whether or not the item should be filtered.
847
+ * this prop will be ignored if `typeahead` prop is enabled
750
848
  */
751
849
  shouldFilterItem: PropTypes__default["default"].func,
752
850
  /**
@@ -767,6 +865,10 @@ ComboBox.propTypes = {
767
865
  * and returns the localized string for the message
768
866
  */
769
867
  translateWithId: PropTypes__default["default"].func,
868
+ /**
869
+ * **Experimental**: will enable autcomplete and typeahead for the input field
870
+ */
871
+ typeahead: PropTypes__default["default"].bool,
770
872
  /**
771
873
  * Specify whether the control is currently in warning state
772
874
  */
@@ -54,7 +54,7 @@ const ModalHeader = /*#__PURE__*/React__default["default"].forwardRef(function M
54
54
  ref: ref
55
55
  }), label && /*#__PURE__*/React__default["default"].createElement("h2", {
56
56
  className: labelClass
57
- }, label), title && /*#__PURE__*/React__default["default"].createElement("h3", {
57
+ }, label), title && /*#__PURE__*/React__default["default"].createElement("h2", {
58
58
  className: titleClass
59
59
  }, title), children, /*#__PURE__*/React__default["default"].createElement("div", {
60
60
  className: `${prefix}--modal-close-button`
@@ -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
@@ -217,7 +217,9 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
217
217
 
218
218
  // needs to be Capitalized for react to render it correctly
219
219
  const ItemToElement = itemToElement;
220
- const toggleButtonProps = getToggleButtonProps();
220
+ const toggleButtonProps = getToggleButtonProps({
221
+ 'aria-label': ariaLabel || deprecatedAriaLabel
222
+ });
221
223
  const helper = helperText && !isFluid ? /*#__PURE__*/React__default["default"].createElement("div", {
222
224
  id: helperId,
223
225
  className: helperClasses
@@ -292,7 +294,6 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
292
294
  }, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index["default"], {
293
295
  onFocus: handleFocus,
294
296
  onBlur: handleFocus,
295
- "aria-label": deprecatedAriaLabel || ariaLabel,
296
297
  size: size,
297
298
  className: className,
298
299
  invalid: invalid,
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Copyright IBM Corp. 2015, 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
+ import PropTypes from 'prop-types';
8
+ import React, { ReactNode } from 'react';
9
+ interface FeatureFlagsProps {
10
+ children?: ReactNode;
11
+ flags?: Record<string, boolean>;
12
+ enableV12TileDefaultIcons?: boolean;
13
+ enableV12TileRadioIcons?: boolean;
14
+ enableV12Overflowmenu?: boolean;
15
+ enableTreeviewControllable?: boolean;
16
+ enableExperimentalFocusWrapWithoutSentinels?: boolean;
17
+ }
18
+ /**
19
+ * Our FeatureFlagContext is used alongside the FeatureFlags component to enable
20
+ * or disable feature flags in a given React tree
21
+ */
22
+ declare const FeatureFlagContext: React.Context<any>;
23
+ /**
24
+ * Supports an object of feature flag values with the `flags` prop, merging them
25
+ * along with the current `FeatureFlagContext` to provide consumers to check if
26
+ * a feature flag is enabled or disabled in a given React tree
27
+ */
28
+ declare function FeatureFlags({ children, flags, enableV12TileDefaultIcons, enableV12TileRadioIcons, enableV12Overflowmenu, enableTreeviewControllable, enableExperimentalFocusWrapWithoutSentinels, }: FeatureFlagsProps): JSX.Element;
29
+ declare namespace FeatureFlags {
30
+ var propTypes: {
31
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
32
+ /**
33
+ * Provide the feature flags to enabled or disabled in the current Rea,ct tree
34
+ */
35
+ flags: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
36
+ enableV12TileDefaultIcons: PropTypes.Requireable<boolean>;
37
+ enableV12TileRadioIcons: PropTypes.Requireable<boolean>;
38
+ enableV12Overflowmenu: PropTypes.Requireable<boolean>;
39
+ enableTreeviewControllable: PropTypes.Requireable<boolean>;
40
+ enableExperimentalFocusWrapWithoutSentinels: PropTypes.Requireable<boolean>;
41
+ };
42
+ }
43
+ /**
44
+ * Access whether a given flag is enabled or disabled in a given
45
+ * FeatureFlagContext
46
+ *
47
+ * @returns {boolean}
48
+ */
49
+ declare function useFeatureFlag(flag: any): any;
50
+ /**
51
+ * Access all feature flag information for the given FeatureFlagContext
52
+ *
53
+ * @returns {FeatureFlagScope}
54
+ */
55
+ declare function useFeatureFlags(): any;
56
+ export { FeatureFlags, FeatureFlagContext, useFeatureFlags, useFeatureFlag };
@@ -153,7 +153,7 @@ function FileUploaderDropContainer(_ref) {
153
153
  multiple: multiple,
154
154
  onChange: handleChange,
155
155
  onClick: evt => {
156
- evt.target.value = null;
156
+ evt.target.value = '';
157
157
  }
158
158
  }));
159
159
  }
@@ -0,0 +1,15 @@
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
+ import React from 'react';
8
+ export interface FluidComboBoxSkeletonProps {
9
+ /**
10
+ * Specify an optional className to add.
11
+ */
12
+ className?: string;
13
+ }
14
+ declare const FluidComboBoxSkeleton: React.FC<FluidComboBoxSkeletonProps>;
15
+ export default FluidComboBoxSkeleton;
@@ -44,6 +44,5 @@ FluidComboBoxSkeleton.propTypes = {
44
44
  */
45
45
  className: PropTypes__default["default"].string
46
46
  };
47
- var FluidComboBoxSkeleton$1 = FluidComboBoxSkeleton;
48
47
 
49
- exports["default"] = FluidComboBoxSkeleton$1;
48
+ exports["default"] = FluidComboBoxSkeleton;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022
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
+ import React, { ComponentType } from 'react';
8
+ import { ComboBoxProps } from '../ComboBox/ComboBox';
9
+ type ItemToStringHandler<ItemType> = (item: ItemType | null) => string;
10
+ interface OnChangeData<ItemType> {
11
+ selectedItem: ItemType | null | undefined;
12
+ inputValue?: string | null;
13
+ }
14
+ export interface FluidComboBoxProps<ItemType> extends ComboBoxProps<ItemType> {
15
+ /**
16
+ * Specify an optional className to be applied to the outer FluidForm wrapper
17
+ */
18
+ className?: string;
19
+ /**
20
+ * Specify the direction of the dropdown. Can be either top or bottom.
21
+ */
22
+ direction?: 'top' | 'bottom';
23
+ /**
24
+ * Specify whether the `<input>` should be disabled
25
+ */
26
+ disabled?: boolean;
27
+ /**
28
+ * Specify a custom `id` for the `<input>`
29
+ */
30
+ id: string;
31
+ /**
32
+ * Allow users to pass in an arbitrary item or a string (in case their items are an array of strings)
33
+ * from their collection that are pre-selected
34
+ */
35
+ initialSelectedItem?: ItemType;
36
+ /**
37
+ * Specify if the currently selected value is invalid.
38
+ */
39
+ invalid?: boolean;
40
+ /**
41
+ * Provide the text that is displayed when the control is in an invalid state
42
+ */
43
+ invalidText?: React.ReactNode;
44
+ /**
45
+ * Specify if the `FluidComboBox` should render its menu items in condensed mode
46
+ */
47
+ isCondensed?: boolean;
48
+ /**
49
+ * Function to render items as custom components instead of strings.
50
+ * Defaults to null and is overridden by a getter
51
+ */
52
+ itemToElement?: ComponentType<ItemType> | null;
53
+ /**
54
+ * Helper function passed to downshift that allows the library to render a
55
+ * given item to a string label. By default, it extracts the `label` field
56
+ * from a given item to serve as the item label in the list.
57
+ */
58
+ itemToString?: ItemToStringHandler<ItemType>;
59
+ /**
60
+ * We try to stay as generic as possible here to allow individuals to pass
61
+ * in a collection of whatever kind of data structure they prefer
62
+ */
63
+ items: ItemType[];
64
+ /**
65
+ * Generic `label` that will be used as the textual representation of what
66
+ * this field is for
67
+ */
68
+ label: React.ReactNode;
69
+ /**
70
+ * `onChange` is a utility for this controlled component to communicate to a
71
+ * consuming component what kind of internal state changes are occurring.
72
+ */
73
+ onChange: (data: OnChangeData<ItemType>) => void;
74
+ /**
75
+ * An optional callback to render the currently selected item as a react element instead of only
76
+ * as a string.
77
+ */
78
+ renderSelectedItem?: (selectedItem: ItemType) => React.ReactNode;
79
+ /**
80
+ * In the case you want to control the dropdown selection entirely.
81
+ * */
82
+ selectedItem?: ItemType | null;
83
+ /**
84
+ * Provide the title text that will be read by a screen reader when
85
+ * visiting this control
86
+ */
87
+ titleText?: React.ReactNode;
88
+ /**
89
+ * Callback function for translating ListBoxMenuIcon SVG title
90
+ */
91
+ translateWithId?: (id: string) => string;
92
+ /**
93
+ * Specify whether the control is currently in warning state
94
+ */
95
+ warn?: boolean;
96
+ /**
97
+ * Provide the text that is displayed when the control is in warning state
98
+ */
99
+ warnText?: React.ReactNode;
100
+ }
101
+ declare const FluidComboBox: React.ForwardRefExoticComponent<FluidComboBoxProps<unknown> & React.RefAttributes<HTMLInputElement>>;
102
+ export default FluidComboBox;
@@ -101,7 +101,7 @@ FluidComboBox.propTypes = {
101
101
  * `onChange` is a utility for this controlled component to communicate to a
102
102
  * consuming component what kind of internal state changes are occurring.
103
103
  */
104
- onChange: PropTypes__default["default"].func,
104
+ onChange: PropTypes__default["default"].func.isRequired,
105
105
  /**
106
106
  * An optional callback to render the currently selected item as a react element instead of only
107
107
  * as a string.
@@ -129,6 +129,5 @@ FluidComboBox.propTypes = {
129
129
  */
130
130
  warnText: PropTypes__default["default"].node
131
131
  };
132
- var FluidComboBox$1 = FluidComboBox;
133
132
 
134
- exports["default"] = FluidComboBox$1;
133
+ exports["default"] = FluidComboBox;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022
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
+ import FluidComboBox from './FluidComboBox';
8
+ import type { FluidComboBoxProps } from './FluidComboBox';
9
+ import type { FluidComboBoxSkeletonProps } from './FluidComboBox.Skeleton';
10
+ export type { FluidComboBoxProps, FluidComboBoxSkeletonProps };
11
+ export default FluidComboBox;
12
+ export { FluidComboBox };
13
+ export { default as FluidComboBoxSkeleton } from './FluidComboBox.Skeleton';
@@ -0,0 +1,19 @@
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
+ import React from 'react';
8
+ export interface FluidDatePickerSkeletonProps {
9
+ /**
10
+ * Specify an optional className to be applied to the outer FluidForm wrapper
11
+ */
12
+ className?: string;
13
+ /**
14
+ * Specify which variant of the DatePicker the skeleton should mimic
15
+ */
16
+ datePickerType?: 'simple' | 'single' | 'range';
17
+ }
18
+ declare const FluidDatePickerSkeleton: React.FC<FluidDatePickerSkeletonProps>;
19
+ export default FluidDatePickerSkeleton;