@carbon/react 1.81.0 → 1.82.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 (202) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +892 -892
  2. package/es/components/AILabel/index.d.ts +1 -1
  3. package/es/components/AILabel/index.js +2 -9
  4. package/es/components/Breadcrumb/Breadcrumb.d.ts +2 -3
  5. package/es/components/Breadcrumb/Breadcrumb.js +4 -4
  6. package/es/components/Breadcrumb/BreadcrumbItem.d.ts +3 -4
  7. package/es/components/Breadcrumb/BreadcrumbItem.js +5 -4
  8. package/es/components/Button/Button.js +2 -10
  9. package/es/components/ButtonSet/ButtonSet.d.ts +2 -3
  10. package/es/components/ButtonSet/ButtonSet.js +4 -4
  11. package/es/components/CodeSnippet/CodeSnippet.d.ts +1 -1
  12. package/es/components/CodeSnippet/CodeSnippet.js +3 -19
  13. package/es/components/ComboBox/ComboBox.d.ts +1 -1
  14. package/es/components/ComboBox/ComboBox.js +2 -2
  15. package/es/components/ComboButton/index.d.ts +1 -1
  16. package/es/components/ComboButton/index.js +2 -18
  17. package/es/components/ComposedModal/ComposedModal.js +5 -3
  18. package/es/components/Copy/Copy.d.ts +1 -1
  19. package/es/components/Copy/Copy.js +2 -18
  20. package/es/components/CopyButton/CopyButton.d.ts +1 -1
  21. package/es/components/CopyButton/CopyButton.js +2 -18
  22. package/es/components/DataTable/DataTable.d.ts +7 -12
  23. package/es/components/DataTable/DataTable.js +0 -5
  24. package/es/components/DataTable/TableToolbarAction.d.ts +2 -4
  25. package/es/components/DataTable/TableToolbarAction.js +5 -4
  26. package/es/components/DataTable/tools/sorting.d.ts +42 -0
  27. package/es/components/DataTable/tools/sorting.js +24 -53
  28. package/es/components/DatePicker/DatePicker.d.ts +1 -1
  29. package/es/components/DatePicker/DatePicker.js +18 -18
  30. package/es/components/Dialog/index.d.ts +1 -1
  31. package/es/components/Dropdown/Dropdown.Skeleton.d.ts +2 -2
  32. package/es/components/Dropdown/Dropdown.Skeleton.js +2 -2
  33. package/es/components/Dropdown/Dropdown.d.ts +7 -6
  34. package/es/components/Dropdown/Dropdown.js +7 -3
  35. package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
  36. package/es/components/FileUploader/FileUploaderButton.js +1 -1
  37. package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
  38. package/es/components/FileUploader/FileUploaderItem.js +1 -1
  39. package/es/components/FluidDropdown/FluidDropdown.d.ts +1 -1
  40. package/es/components/FluidSearch/FluidSearch.d.ts +3 -6
  41. package/es/components/IconButton/index.d.ts +1 -1
  42. package/es/components/IconButton/index.js +2 -18
  43. package/es/components/ListBox/ListBox.d.ts +4 -5
  44. package/es/components/ListBox/ListBox.js +8 -7
  45. package/es/components/ListBox/ListBoxMenu.d.ts +4 -4
  46. package/es/components/ListBox/ListBoxMenu.js +4 -2
  47. package/es/components/ListBox/ListBoxMenuItem.d.ts +9 -8
  48. package/es/components/ListBox/ListBoxPropTypes.d.ts +3 -3
  49. package/es/components/ListBox/ListBoxPropTypes.js +3 -3
  50. package/es/components/ListBox/index.d.ts +7 -5
  51. package/es/components/ListBox/index.js +1 -1
  52. package/es/components/Menu/Menu.js +5 -0
  53. package/es/components/Modal/Modal.js +9 -9
  54. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +3 -2
  55. package/es/components/MultiSelect/FilterableMultiSelect.js +3 -2
  56. package/es/components/MultiSelect/MultiSelect.d.ts +8 -2
  57. package/es/components/MultiSelect/MultiSelect.js +3 -3
  58. package/es/components/Notification/Notification.js +1 -1
  59. package/es/components/OverflowMenu/OverflowMenu.js +2 -21
  60. package/es/components/OverflowMenu/next/index.js +2 -18
  61. package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +2 -4
  62. package/es/components/OverflowMenuItem/OverflowMenuItem.js +5 -4
  63. package/es/components/PageHeader/PageHeader.d.ts +153 -8
  64. package/es/components/PageHeader/PageHeader.js +143 -21
  65. package/es/components/PageHeader/index.d.ts +2 -2
  66. package/es/components/PageHeader/index.js +1 -1
  67. package/es/components/Popover/index.js +4 -21
  68. package/es/components/Search/Search.d.ts +2 -5
  69. package/es/components/Search/Search.js +24 -8
  70. package/es/components/Stack/HStack.d.ts +2 -3
  71. package/es/components/Stack/HStack.js +4 -7
  72. package/es/components/Stack/Stack.d.ts +3 -4
  73. package/es/components/Stack/Stack.js +3 -6
  74. package/es/components/Stack/VStack.d.ts +2 -3
  75. package/es/components/Stack/VStack.js +3 -2
  76. package/es/components/Stack/index.d.ts +4 -4
  77. package/es/components/TextArea/TextArea.js +3 -5
  78. package/es/components/TimePicker/TimePicker.d.ts +3 -4
  79. package/es/components/TimePicker/TimePicker.js +5 -4
  80. package/es/components/TimePickerSelect/TimePickerSelect.d.ts +23 -4
  81. package/es/components/TimePickerSelect/TimePickerSelect.js +5 -4
  82. package/es/components/TreeView/TreeNode.js +13 -1
  83. package/es/components/TreeView/TreeView.js +1 -1
  84. package/es/index.js +1 -1
  85. package/es/internal/FloatingMenu.js +9 -5
  86. package/es/internal/environment.js +7 -0
  87. package/es/internal/keyboard/navigation.d.ts +0 -10
  88. package/es/internal/keyboard/navigation.js +1 -13
  89. package/es/internal/useId.js +1 -1
  90. package/es/internal/useNoInteractiveChildren.js +7 -0
  91. package/es/internal/useOutsideClick.js +3 -0
  92. package/es/internal/wrapFocus.d.ts +49 -0
  93. package/es/internal/wrapFocus.js +64 -51
  94. package/es/tools/events.d.ts +17 -0
  95. package/es/tools/events.js +10 -13
  96. package/es/tools/mapPopoverAlign.d.ts +15 -0
  97. package/es/tools/mapPopoverAlign.js +28 -0
  98. package/es/tools/uniqueId.d.ts +7 -0
  99. package/es/tools/uniqueId.js +3 -3
  100. package/es/types/common.d.ts +0 -2
  101. package/lib/components/AILabel/index.d.ts +1 -1
  102. package/lib/components/AILabel/index.js +2 -9
  103. package/lib/components/Breadcrumb/Breadcrumb.d.ts +2 -3
  104. package/lib/components/Breadcrumb/Breadcrumb.js +3 -3
  105. package/lib/components/Breadcrumb/BreadcrumbItem.d.ts +3 -4
  106. package/lib/components/Breadcrumb/BreadcrumbItem.js +4 -3
  107. package/lib/components/Button/Button.js +1 -9
  108. package/lib/components/ButtonSet/ButtonSet.d.ts +2 -3
  109. package/lib/components/ButtonSet/ButtonSet.js +3 -3
  110. package/lib/components/CodeSnippet/CodeSnippet.d.ts +1 -1
  111. package/lib/components/CodeSnippet/CodeSnippet.js +3 -19
  112. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  113. package/lib/components/ComboBox/ComboBox.js +1 -1
  114. package/lib/components/ComboButton/index.d.ts +1 -1
  115. package/lib/components/ComboButton/index.js +2 -18
  116. package/lib/components/ComposedModal/ComposedModal.js +5 -3
  117. package/lib/components/Copy/Copy.d.ts +1 -1
  118. package/lib/components/Copy/Copy.js +2 -18
  119. package/lib/components/CopyButton/CopyButton.d.ts +1 -1
  120. package/lib/components/CopyButton/CopyButton.js +2 -18
  121. package/lib/components/DataTable/DataTable.d.ts +7 -12
  122. package/lib/components/DataTable/DataTable.js +0 -5
  123. package/lib/components/DataTable/TableToolbarAction.d.ts +2 -4
  124. package/lib/components/DataTable/TableToolbarAction.js +4 -3
  125. package/lib/components/DataTable/tools/sorting.d.ts +42 -0
  126. package/lib/components/DataTable/tools/sorting.js +23 -53
  127. package/lib/components/DatePicker/DatePicker.d.ts +1 -1
  128. package/lib/components/DatePicker/DatePicker.js +18 -18
  129. package/lib/components/Dialog/index.d.ts +1 -1
  130. package/lib/components/Dropdown/Dropdown.Skeleton.d.ts +2 -2
  131. package/lib/components/Dropdown/Dropdown.Skeleton.js +1 -1
  132. package/lib/components/Dropdown/Dropdown.d.ts +7 -6
  133. package/lib/components/Dropdown/Dropdown.js +6 -2
  134. package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
  135. package/lib/components/FileUploader/FileUploaderButton.js +1 -1
  136. package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
  137. package/lib/components/FileUploader/FileUploaderItem.js +1 -1
  138. package/lib/components/FluidDropdown/FluidDropdown.d.ts +1 -1
  139. package/lib/components/FluidSearch/FluidSearch.d.ts +3 -6
  140. package/lib/components/IconButton/index.d.ts +1 -1
  141. package/lib/components/IconButton/index.js +2 -18
  142. package/lib/components/ListBox/ListBox.d.ts +4 -5
  143. package/lib/components/ListBox/ListBox.js +7 -6
  144. package/lib/components/ListBox/ListBoxMenu.d.ts +4 -4
  145. package/lib/components/ListBox/ListBoxMenu.js +3 -1
  146. package/lib/components/ListBox/ListBoxMenuItem.d.ts +9 -8
  147. package/lib/components/ListBox/ListBoxPropTypes.d.ts +3 -3
  148. package/lib/components/ListBox/ListBoxPropTypes.js +4 -4
  149. package/lib/components/ListBox/index.d.ts +7 -5
  150. package/lib/components/ListBox/index.js +2 -2
  151. package/lib/components/Menu/Menu.js +5 -0
  152. package/lib/components/Modal/Modal.js +9 -9
  153. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +3 -2
  154. package/lib/components/MultiSelect/FilterableMultiSelect.js +2 -1
  155. package/lib/components/MultiSelect/MultiSelect.d.ts +8 -2
  156. package/lib/components/MultiSelect/MultiSelect.js +2 -2
  157. package/lib/components/Notification/Notification.js +1 -1
  158. package/lib/components/OverflowMenu/OverflowMenu.js +2 -21
  159. package/lib/components/OverflowMenu/next/index.js +2 -18
  160. package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +2 -4
  161. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +4 -3
  162. package/lib/components/PageHeader/PageHeader.d.ts +153 -8
  163. package/lib/components/PageHeader/PageHeader.js +145 -19
  164. package/lib/components/PageHeader/index.d.ts +2 -2
  165. package/lib/components/PageHeader/index.js +4 -0
  166. package/lib/components/Popover/index.js +4 -21
  167. package/lib/components/Search/Search.d.ts +2 -5
  168. package/lib/components/Search/Search.js +24 -8
  169. package/lib/components/Stack/HStack.d.ts +2 -3
  170. package/lib/components/Stack/HStack.js +3 -6
  171. package/lib/components/Stack/Stack.d.ts +3 -4
  172. package/lib/components/Stack/Stack.js +2 -5
  173. package/lib/components/Stack/VStack.d.ts +2 -3
  174. package/lib/components/Stack/VStack.js +2 -1
  175. package/lib/components/Stack/index.d.ts +4 -4
  176. package/lib/components/TextArea/TextArea.js +2 -4
  177. package/lib/components/TimePicker/TimePicker.d.ts +3 -4
  178. package/lib/components/TimePicker/TimePicker.js +4 -3
  179. package/lib/components/TimePickerSelect/TimePickerSelect.d.ts +23 -4
  180. package/lib/components/TimePickerSelect/TimePickerSelect.js +4 -3
  181. package/lib/components/TreeView/TreeNode.js +13 -1
  182. package/lib/components/TreeView/TreeView.js +1 -1
  183. package/lib/index.js +2 -2
  184. package/lib/internal/FloatingMenu.js +9 -5
  185. package/lib/internal/environment.js +7 -0
  186. package/lib/internal/keyboard/navigation.d.ts +0 -10
  187. package/lib/internal/keyboard/navigation.js +0 -14
  188. package/lib/internal/useNoInteractiveChildren.js +7 -0
  189. package/lib/internal/useOutsideClick.js +3 -0
  190. package/lib/internal/wrapFocus.d.ts +49 -0
  191. package/lib/internal/wrapFocus.js +66 -53
  192. package/lib/tools/events.d.ts +17 -0
  193. package/lib/tools/events.js +10 -13
  194. package/lib/tools/mapPopoverAlign.d.ts +15 -0
  195. package/lib/tools/mapPopoverAlign.js +32 -0
  196. package/lib/tools/uniqueId.d.ts +7 -0
  197. package/lib/tools/uniqueId.js +3 -3
  198. package/lib/types/common.d.ts +0 -2
  199. package/package.json +7 -7
  200. package/telemetry.yml +3 -1
  201. package/es/tools/createPropAdapter.js +0 -40
  202. package/lib/tools/createPropAdapter.js +0 -44
@@ -9,76 +9,43 @@ import { getCellId } from './cells.js';
9
9
  import { sortStates } from '../state/sortStates.js';
10
10
 
11
11
  /**
12
- * Compare two primitives to determine which comes first. Initially, this method
13
- * will try and figure out if both entries are the same type. If so, it will
14
- * apply the default sort algorithm for those types. Otherwise, it defaults to a
15
- * string conversion.
16
- *
17
- * @param {number|string} a
18
- * @param {number|string} b
19
- * @param {string} locale
20
- * @returns {number}
12
+ * Compare two values to determine their order. If both values have the same
13
+ * type, the default sort algorithm will be used for those types. Otherwise, the
14
+ * values will be converted to strings for comparison.
21
15
  */
22
16
  const compare = function (a, b) {
23
17
  let locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en';
24
18
  // prevent multiple null values in one column (sorting breaks)
25
- a === null ? a = '' : null;
26
- b === null ? b = '' : null;
19
+ if (a === null) a = '';
20
+ if (b === null) b = '';
27
21
  if (typeof a === 'number' && typeof b === 'number') {
28
22
  return a - b;
29
23
  }
30
24
  if (typeof a === 'string' && typeof b === 'string') {
31
25
  return compareStrings(a, b, locale);
32
26
  }
33
-
34
- // if column has React elements, this should sort by the child string if there is one
35
- if (typeof a === 'object' && typeof b === 'object') {
36
- if (typeof a.props?.children === 'string' && typeof b.props?.children === 'string') {
37
- return compareStrings(a.props.children, b.props.children, locale);
38
- }
27
+ const aChild = a?.props?.children;
28
+ const bChild = b?.props?.children;
29
+ if (typeof aChild === 'string' && typeof bChild === 'string') {
30
+ return compareStrings(aChild, bChild, locale);
39
31
  }
40
- return compareStrings('' + a, '' + b, locale);
32
+ return compareStrings(String(a), String(b), locale);
41
33
  };
42
34
 
43
35
  /**
44
- * Use the built-in `localeCompare` function available on strings to compare two
45
- * strings.
36
+ * Compares two strings using `localeCompare`.
46
37
  *
47
- * @param {string} a
48
- * @param {string} b
49
- * @param {string} locale
50
- * @returns {number}
38
+ * Note: Uses numeric comparison if strings are numeric.
51
39
  */
52
40
  const compareStrings = function (a, b) {
53
41
  let locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en';
54
- // Only set `numeric: true` if the string only contains numbers
55
- // https://stackoverflow.com/a/175787
56
- if (!isNaN(a) && !isNaN(parseFloat(a)) && !isNaN(b) && !isNaN(parseFloat(b))) {
57
- return a.localeCompare(b, locale, {
58
- numeric: true
59
- });
60
- }
61
- return a.localeCompare(b, locale);
42
+ const isNumeric = !isNaN(parseFloat(a)) && !isNaN(parseFloat(b));
43
+ return a.localeCompare(b, locale, {
44
+ numeric: isNumeric
45
+ });
62
46
  };
63
-
64
47
  /**
65
- * Default implementation of how we sort rows internally. The idea behind this
66
- * implementation is to use the given list of row ids to look up the cells in
67
- * the row by the given key. We then use the value of these cells and pipe them
68
- * into our local `compareStrings` method, including the locale where
69
- * appropriate.
70
- *
71
- * @param {object} config
72
- * @param {Array[string]} config.rowIds array of all the row ids in the table
73
- * @param {object} config.cellsById object containing a mapping of cell id to
74
- * cell
75
- * @param {string} config.key the header key that we use to lookup the cell
76
- * @param {string} [config.locale] optional locale used in the comparison
77
- * function
78
- * @param {string} config.sortDirection the sort direction used to determine the
79
- * order the comparison is called in
80
- * @param {Function} config.sortRow
81
- * @returns {Array[string]} array of sorted rowIds
48
+ * Sorts table rows based on the provided column key and direction.
82
49
  */
83
50
  const sortRows = _ref => {
84
51
  let {
@@ -92,16 +59,20 @@ const sortRows = _ref => {
92
59
  return rowIds.slice().sort((a, b) => {
93
60
  const cellA = cellsById[getCellId(a, key)];
94
61
  const cellB = cellsById[getCellId(b, key)];
95
- return sortRow(cellA && cellA.value, cellB && cellB.value, {
62
+ return sortRow(cellA?.value, cellB?.value, {
96
63
  key,
97
64
  sortDirection,
98
- locale,
99
65
  sortStates,
66
+ locale,
100
67
  compare,
101
68
  rowIds: [a, b]
102
69
  });
103
70
  });
104
71
  };
72
+
73
+ /**
74
+ * Sorts table rows based on the sort direction.
75
+ */
105
76
  const defaultSortRow = (cellA, cellB, _ref2) => {
106
77
  let {
107
78
  sortDirection,
@@ -114,4 +85,4 @@ const defaultSortRow = (cellA, cellB, _ref2) => {
114
85
  return compare(cellB, cellA, locale);
115
86
  };
116
87
 
117
- export { compare, compareStrings, defaultSortRow, sortRows };
88
+ export { compare, defaultSortRow, sortRows };
@@ -120,7 +120,7 @@ export interface DatePickerProps {
120
120
  * The value of the date value provided to flatpickr, could
121
121
  * be a date, a date number, a date string, an array of dates.
122
122
  */
123
- value?: string | number | (string | number | object)[] | object | undefined;
123
+ value?: DateOption | DateOption[];
124
124
  /**
125
125
  * Specify whether the control is currently in warning state (Fluid only)
126
126
  */
@@ -173,13 +173,14 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
173
173
  }
174
174
  }, []);
175
175
  const lastStartValue = useRef('');
176
+ const calendarRef = useRef(null);
176
177
  const [calendarCloseEvent, setCalendarCloseEvent] = useState(null);
177
178
 
178
179
  // fix datepicker deleting the selectedDate when the calendar closes
179
180
  const handleCalendarClose = useCallback((selectedDates, dateStr, instance) => {
180
181
  if (lastStartValue.current && selectedDates[0] && !startInputField.current.value) {
181
182
  startInputField.current.value = lastStartValue.current;
182
- calendarRef.current.setDate([startInputField.current.value, endInputField?.current?.value], true, calendarRef.current.config.dateFormat);
183
+ calendarRef.current?.setDate([startInputField.current.value, endInputField?.current?.value], true, calendarRef.current.config.dateFormat);
183
184
  }
184
185
  if (onClose) {
185
186
  onClose(selectedDates, dateStr, instance);
@@ -207,7 +208,6 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
207
208
  }
208
209
  }, [calendarCloseEvent, handleCalendarClose]);
209
210
  const endInputField = useRef(null);
210
- const calendarRef = useRef(null);
211
211
  const savedOnChange = useSavedCallback(onChange);
212
212
  const savedOnOpen = useSavedCallback(onOpen);
213
213
  const datePickerClasses = cx(`${prefix}--date-picker`, {
@@ -324,7 +324,7 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
324
324
  const {
325
325
  current: end
326
326
  } = endInputField;
327
- const flatpickerconfig = {
327
+ const flatpickerConfig = {
328
328
  inline: inline ?? false,
329
329
  onClose: onCalendarClose,
330
330
  disableMobile: true,
@@ -370,7 +370,7 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
370
370
  },
371
371
  onValueUpdate: onHook
372
372
  };
373
- const calendar = flatpickr(start, flatpickerconfig);
373
+ const calendar = flatpickr(start, flatpickerConfig);
374
374
  calendarRef.current = calendar;
375
375
  function handleArrowDown(event) {
376
376
  if (match(event, Escape)) {
@@ -383,10 +383,10 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
383
383
  const {
384
384
  calendarContainer,
385
385
  selectedDateElem: fpSelectedDateElem,
386
- todayDateElem: fptodayDateElem
386
+ todayDateElem: fpTodayDateElem
387
387
  } = calendar;
388
388
  const selectedDateElem = calendarContainer.querySelector('.selected') && fpSelectedDateElem;
389
- const todayDateElem = calendarContainer.querySelector('.today') && fptodayDateElem;
389
+ const todayDateElem = calendarContainer.querySelector('.today') && fpTodayDateElem;
390
390
  (selectedDateElem || todayDateElem || calendarContainer.querySelector('.flatpickr-day[tabindex]') || calendarContainer).focus();
391
391
  }
392
392
  }
@@ -472,44 +472,44 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
472
472
  }
473
473
  }));
474
474
  useEffect(() => {
475
- if (calendarRef?.current?.set) {
475
+ if (calendarRef.current?.set) {
476
476
  calendarRef.current.set({
477
477
  dateFormat
478
478
  });
479
479
  }
480
480
  }, [dateFormat]);
481
481
  useEffect(() => {
482
- if (calendarRef?.current?.set) {
482
+ if (calendarRef.current?.set) {
483
483
  calendarRef.current.set('minDate', minDate);
484
484
  }
485
485
  }, [minDate]);
486
486
  useEffect(() => {
487
- if (calendarRef?.current?.set) {
487
+ if (calendarRef.current?.set) {
488
488
  calendarRef.current.set('allowInput', allowInput);
489
489
  }
490
490
  }, [allowInput]);
491
491
  useEffect(() => {
492
- if (calendarRef?.current?.set) {
492
+ if (calendarRef.current?.set) {
493
493
  calendarRef.current.set('maxDate', maxDate);
494
494
  }
495
495
  }, [maxDate]);
496
496
  useEffect(() => {
497
- if (calendarRef?.current?.set && disable) {
497
+ if (calendarRef.current?.set && disable) {
498
498
  calendarRef.current.set('disable', disable);
499
499
  }
500
500
  }, [disable]);
501
501
  useEffect(() => {
502
- if (calendarRef?.current?.set && enable) {
502
+ if (calendarRef.current?.set && enable) {
503
503
  calendarRef.current.set('enable', enable);
504
504
  }
505
505
  }, [enable]);
506
506
  useEffect(() => {
507
- if (calendarRef?.current?.set && inline) {
507
+ if (calendarRef.current?.set && inline) {
508
508
  calendarRef.current.set('inline', inline);
509
509
  }
510
510
  }, [inline]);
511
511
  useEffect(() => {
512
- //when value prop is set to empty, this clears the faltpicker's calendar instance and text input
512
+ //when value prop is set to empty, this clears the flatpicker's calendar instance and text input
513
513
  if (value === '') {
514
514
  calendarRef.current?.clear();
515
515
  if (startInputField.current) {
@@ -528,9 +528,9 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
528
528
  }
529
529
  };
530
530
  const closeCalendar = event => {
531
- calendarRef.current.close();
531
+ calendarRef.current?.close();
532
532
  // Remove focus from endDate calendar input
533
- onCalendarClose(calendarRef.current.selectedDates, '', calendarRef.current, {
533
+ onCalendarClose(calendarRef.current?.selectedDates, '', calendarRef.current, {
534
534
  type: 'clickOutside'
535
535
  });
536
536
  };
@@ -540,7 +540,7 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
540
540
  };
541
541
  }, [calendarRef, startInputField, endInputField, onCalendarClose]);
542
542
  useEffect(() => {
543
- if (calendarRef?.current?.set) {
543
+ if (calendarRef.current?.set) {
544
544
  if (value !== undefined) {
545
545
  calendarRef.current.setDate(value);
546
546
  }
@@ -554,7 +554,7 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
554
554
  useEffect(() => {
555
555
  if (!calendarRef.current || !startInputField.current) return;
556
556
  const handleKeyDown = event => {
557
- if (match(event, Tab) && !event.shiftKey && document.activeElement === endInputField.current && calendarRef.current.isOpen) {
557
+ if (match(event, Tab) && !event.shiftKey && document.activeElement === endInputField.current && calendarRef.current?.isOpen) {
558
558
  calendarRef.current.close();
559
559
  onCalendarClose(calendarRef.current.selectedDates, '', calendarRef.current, event);
560
560
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2014, 2024
2
+ * Copyright IBM Corp. 2014, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import { ListBoxSize } from '../ListBox';
8
+ import { type ListBoxSize } from '../ListBox';
9
9
  import { ReactAttr } from '../../types/common';
10
10
  export interface DropdownSkeletonProps extends ReactAttr<HTMLDivElement> {
11
11
  /**
@@ -11,7 +11,7 @@ import React__default from 'react';
11
11
  import cx from 'classnames';
12
12
  import '../ListBox/index.js';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
14
- import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
14
+ import { ListBoxSizePropType } from '../ListBox/ListBoxPropTypes.js';
15
15
 
16
16
  const DropdownSkeleton = _ref => {
17
17
  let {
@@ -44,7 +44,7 @@ DropdownSkeleton.propTypes = {
44
44
  /**
45
45
  * Specify the size of the ListBox.
46
46
  */
47
- size: ListBoxSize
47
+ size: ListBoxSizePropType
48
48
  };
49
49
 
50
50
  export { DropdownSkeleton, DropdownSkeleton as default };
@@ -4,15 +4,15 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, { ReactNode } from 'react';
7
+ import React, { ReactNode, Ref } from 'react';
8
8
  import { UseSelectProps } from 'downshift';
9
- import { type ListBoxMenuIconTranslationKey, ListBoxSize, ListBoxType } from '../ListBox';
9
+ import { type ListBoxMenuIconTranslationKey, type ListBoxSize, type ListBoxType } from '../ListBox';
10
10
  import { TranslateWithId, ReactAttr } from '../../types/common';
11
11
  type ExcludedAttributes = 'id' | 'onChange';
12
12
  export interface OnChangeData<ItemType> {
13
13
  selectedItem: ItemType | null;
14
14
  }
15
- export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes>, TranslateWithId<ListBoxMenuIconTranslationKey>, React.RefAttributes<HTMLDivElement> {
15
+ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes>, TranslateWithId<ListBoxMenuIconTranslationKey> {
16
16
  /**
17
17
  * Specify a label to be read by screen readers on the container node
18
18
  * 'aria-label' of the ListBox component.
@@ -147,9 +147,10 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
147
147
  warnText?: ReactNode;
148
148
  }
149
149
  export type DropdownTranslationKey = ListBoxMenuIconTranslationKey;
150
- type DropdownComponentProps<ItemType> = React.PropsWithoutRef<React.PropsWithChildren<DropdownProps<ItemType>> & React.RefAttributes<HTMLButtonElement>>;
151
- export interface DropdownComponent {
152
- <ItemType>(props: DropdownComponentProps<ItemType>): React.ReactElement<any> | null;
150
+ interface DropdownComponent {
151
+ <ItemType>(props: DropdownProps<ItemType> & {
152
+ ref?: Ref<HTMLButtonElement>;
153
+ }): React.ReactElement<any> | null;
153
154
  }
154
155
  declare const _default: DropdownComponent;
155
156
  export default _default;
@@ -20,7 +20,7 @@ import { FormContext } from '../FluidForm/FormContext.js';
20
20
  import { useId } from '../../internal/useId.js';
21
21
  import { useFloating, size, flip, hide, autoUpdate } from '@floating-ui/react';
22
22
  import { useFeatureFlag } from '../FeatureFlags/index.js';
23
- import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
23
+ import { ListBoxSizePropType, ListBoxTypePropType } from '../ListBox/ListBoxPropTypes.js';
24
24
 
25
25
  const {
26
26
  ItemMouseMove,
@@ -384,6 +384,10 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
384
384
  }));
385
385
  }))), !inline && !invalid && !warn && helper);
386
386
  });
387
+
388
+ // Workaround problems with forwardRef() and generics. In the long term, should stop using forwardRef().
389
+ // See https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref.
390
+
387
391
  Dropdown.displayName = 'Dropdown';
388
392
  Dropdown.propTypes = {
389
393
  /**
@@ -497,7 +501,7 @@ Dropdown.propTypes = {
497
501
  /**
498
502
  * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
499
503
  */
500
- size: ListBoxSize,
504
+ size: ListBoxSizePropType,
501
505
  /**
502
506
  * **Experimental**: Provide a `Slug` component to be rendered inside the `Dropdown` component
503
507
  */
@@ -514,7 +518,7 @@ Dropdown.propTypes = {
514
518
  /**
515
519
  * The dropdown type, `default` or `inline`
516
520
  */
517
- type: ListBoxType,
521
+ type: ListBoxTypePropType,
518
522
  /**
519
523
  * Specify whether the control is currently in warning state
520
524
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -12,7 +12,7 @@ import React__default, { useState, useRef } from 'react';
12
12
  import { Enter, Space } from '../../internal/keyboard/keys.js';
13
13
  import { matches } from '../../internal/keyboard/match.js';
14
14
  import { ButtonKinds } from '../../prop-types/types.js';
15
- import uniqueId from '../../tools/uniqueId.js';
15
+ import { uniqueId } from '../../tools/uniqueId.js';
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
17
17
  import deprecate from '../../prop-types/deprecate.js';
18
18
  import { noopFn } from '../../internal/noopFn.js';
@@ -11,7 +11,7 @@ import PropTypes from 'prop-types';
11
11
  import cx from 'classnames';
12
12
  import { Enter, Space } from '../../internal/keyboard/keys.js';
13
13
  import { matches } from '../../internal/keyboard/match.js';
14
- import uniqueId from '../../tools/uniqueId.js';
14
+ import { uniqueId } from '../../tools/uniqueId.js';
15
15
  import { usePrefix } from '../../internal/usePrefix.js';
16
16
  import { composeEventHandlers } from '../../tools/events.js';
17
17
  import deprecate from '../../prop-types/deprecate.js';
@@ -12,7 +12,7 @@ import React__default, { useRef, useState, useLayoutEffect } from 'react';
12
12
  import Filename from './Filename.js';
13
13
  import { Enter, Space } from '../../internal/keyboard/keys.js';
14
14
  import { matches } from '../../internal/keyboard/match.js';
15
- import uniqueId from '../../tools/uniqueId.js';
15
+ import { uniqueId } from '../../tools/uniqueId.js';
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
17
17
  import { noopFn } from '../../internal/noopFn.js';
18
18
  import '../Text/index.js';
@@ -97,5 +97,5 @@ export interface FluidDropdownProps<ItemType> extends DropdownProps<ItemType> {
97
97
  */
98
98
  warnText?: React.ReactNode;
99
99
  }
100
- declare const FluidDropdown: React.ForwardRefExoticComponent<Omit<FluidDropdownProps<unknown>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
100
+ declare const FluidDropdown: React.ForwardRefExoticComponent<FluidDropdownProps<unknown> & React.RefAttributes<HTMLButtonElement>>;
101
101
  export default FluidDropdown;
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Copyright IBM Corp. 2022
2
+ * Copyright IBM Corp. 2022, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React from 'react';
7
+ import React, { type ChangeEvent } from 'react';
8
8
  export interface FluidSearchProps {
9
9
  /**
10
10
  * Specify an optional value for the `autocomplete` property on the underlying
@@ -38,10 +38,7 @@ export interface FluidSearchProps {
38
38
  /**
39
39
  * Optional callback called when the search value changes.
40
40
  */
41
- onChange?(e: {
42
- target: HTMLInputElement;
43
- type: 'change';
44
- }): void;
41
+ onChange?(event: ChangeEvent<HTMLInputElement>): void;
45
42
  /**
46
43
  * Optional callback called when the search value is cleared.
47
44
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -16,21 +16,9 @@ import { usePrefix } from '../../internal/usePrefix.js';
16
16
  import ButtonBase from '../Button/ButtonBase.js';
17
17
  import deprecateValuesWithin from '../../prop-types/deprecateValuesWithin.js';
18
18
  import { BadgeIndicator } from '../BadgeIndicator/index.js';
19
+ import { mapPopoverAlign } from '../../tools/mapPopoverAlign.js';
19
20
 
20
21
  const IconButtonKinds = ['primary', 'secondary', 'ghost', 'tertiary'];
21
- const propMappingFunction = deprecatedValue => {
22
- const mapping = {
23
- 'top-left': 'top-start',
24
- 'top-right': 'top-end',
25
- 'bottom-left': 'bottom-start',
26
- 'bottom-right': 'bottom-end',
27
- 'left-bottom': 'left-end',
28
- 'left-top': 'left-start',
29
- 'right-bottom': 'right-end',
30
- 'right-top': 'right-start'
31
- };
32
- return mapping[deprecatedValue];
33
- };
34
22
  const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(_ref, ref) {
35
23
  let {
36
24
  align,
@@ -110,11 +98,7 @@ IconButton.propTypes = {
110
98
  // deprecated use right-start instead
111
99
 
112
100
  // new values to match floating-ui
113
- 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
114
- //allowed prop values
115
- ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'],
116
- //optional mapper function
117
- propMappingFunction),
101
+ 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']), ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'], mapPopoverAlign),
118
102
  /**
119
103
  * **Experimental**: Will attempt to automatically align the tooltip
120
104
  */
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- import { ListBoxType, ListBoxSize } from './ListBoxPropTypes';
9
- import { ForwardRefReturn, ReactAttr } from '../../types/common';
8
+ import { type ListBoxSize, type ListBoxType } from '.';
9
+ import { ReactAttr } from '../../types/common';
10
10
  type ExcludedAttributes = 'onKeyDown' | 'onKeyPress' | 'ref';
11
11
  export interface ListBoxProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes> {
12
12
  /**
@@ -59,10 +59,9 @@ export interface ListBoxProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAt
59
59
  */
60
60
  warnTextId?: string;
61
61
  }
62
- export type ListBoxComponent = ForwardRefReturn<HTMLDivElement, ListBoxProps>;
63
62
  /**
64
63
  * `ListBox` is a generic container component that handles creating the
65
64
  * container class name in response to certain props.
66
65
  */
67
- declare const ListBox: ListBoxComponent;
66
+ declare const ListBox: React.ForwardRefExoticComponent<ListBoxProps & React.RefAttributes<HTMLDivElement>>;
68
67
  export default ListBox;
@@ -7,13 +7,14 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import cx from 'classnames';
10
- import React__default, { useContext } from 'react';
10
+ import React__default, { forwardRef, useContext } from 'react';
11
11
  import PropTypes from 'prop-types';
12
12
  import deprecate from '../../prop-types/deprecate.js';
13
- import { ListBoxSize, ListBoxType } from './ListBoxPropTypes.js';
13
+ import './index.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
15
  import '../FluidForm/FluidForm.js';
16
16
  import { FormContext } from '../FluidForm/FormContext.js';
17
+ import { ListBoxSizePropType, ListBoxTypePropType } from './ListBoxPropTypes.js';
17
18
 
18
19
  const handleOnKeyDown = event => {
19
20
  if (event.keyCode === 27) {
@@ -28,8 +29,8 @@ const handleClick = event => {
28
29
  * `ListBox` is a generic container component that handles creating the
29
30
  * container class name in response to certain props.
30
31
  */
31
- const ListBox = /*#__PURE__*/React__default.forwardRef(function ListBox(_ref, ref) {
32
- let {
32
+ const ListBox = /*#__PURE__*/forwardRef((props, ref) => {
33
+ const {
33
34
  children,
34
35
  className: containerClassName,
35
36
  disabled = false,
@@ -44,7 +45,7 @@ const ListBox = /*#__PURE__*/React__default.forwardRef(function ListBox(_ref, re
44
45
  light,
45
46
  isOpen,
46
47
  ...rest
47
- } = _ref;
48
+ } = props;
48
49
  const prefix = usePrefix();
49
50
  const {
50
51
  isFluid
@@ -117,12 +118,12 @@ ListBox.propTypes = {
117
118
  /**
118
119
  * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
119
120
  */
120
- size: ListBoxSize,
121
+ size: ListBoxSizePropType,
121
122
  /**
122
123
  * Specify the "type" of the ListBox. Currently supports either `default` or
123
124
  * `inline` as an option.
124
125
  */
125
- type: ListBoxType,
126
+ type: ListBoxTypePropType,
126
127
  /**
127
128
  * Specify whether the control is currently in warning state
128
129
  */
@@ -1,10 +1,11 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { ForwardRefReturn, ReactAttr } from '../../types/common';
7
+ import React from 'react';
8
+ import { ReactAttr } from '../../types/common';
8
9
  type ExcludedAttributes = 'id';
9
10
  export interface ListBoxMenuProps extends Omit<ReactAttr<HTMLUListElement>, ExcludedAttributes> {
10
11
  children?: any;
@@ -13,11 +14,10 @@ export interface ListBoxMenuProps extends Omit<ReactAttr<HTMLUListElement>, Excl
13
14
  */
14
15
  id: string;
15
16
  }
16
- export type ListBoxMenuComponent = ForwardRefReturn<HTMLUListElement, ListBoxMenuProps>;
17
17
  /**
18
18
  * `ListBoxMenu` is a simple container node that isolates the `list-box__menu`
19
19
  * class into a single component. It is also being used to validate given
20
20
  * `children` components.
21
21
  */
22
- declare const ListBoxMenu: ListBoxMenuComponent;
22
+ declare const ListBoxMenu: React.ForwardRefExoticComponent<ListBoxMenuProps & React.RefAttributes<HTMLUListElement>>;
23
23
  export default ListBoxMenu;
@@ -6,17 +6,19 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default from 'react';
9
+ import React__default, { forwardRef } from 'react';
10
10
  import { usePrefix } from '../../internal/usePrefix.js';
11
11
  import PropTypes from 'prop-types';
12
12
  import ListBoxMenuItem from './ListBoxMenuItem.js';
13
13
 
14
+ const frFn = forwardRef;
15
+
14
16
  /**
15
17
  * `ListBoxMenu` is a simple container node that isolates the `list-box__menu`
16
18
  * class into a single component. It is also being used to validate given
17
19
  * `children` components.
18
20
  */
19
- const ListBoxMenu = /*#__PURE__*/React__default.forwardRef(function ListBoxMenu(_ref, ref) {
21
+ const ListBoxMenu = frFn((_ref, ref) => {
20
22
  let {
21
23
  children,
22
24
  id,