@carbon/react 1.81.0 → 1.82.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 +902 -902
  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
@@ -13,76 +13,43 @@ var cells = require('./cells.js');
13
13
  var sortStates = require('../state/sortStates.js');
14
14
 
15
15
  /**
16
- * Compare two primitives to determine which comes first. Initially, this method
17
- * will try and figure out if both entries are the same type. If so, it will
18
- * apply the default sort algorithm for those types. Otherwise, it defaults to a
19
- * string conversion.
20
- *
21
- * @param {number|string} a
22
- * @param {number|string} b
23
- * @param {string} locale
24
- * @returns {number}
16
+ * Compare two values to determine their order. If both values have the same
17
+ * type, the default sort algorithm will be used for those types. Otherwise, the
18
+ * values will be converted to strings for comparison.
25
19
  */
26
20
  const compare = function (a, b) {
27
21
  let locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en';
28
22
  // prevent multiple null values in one column (sorting breaks)
29
- a === null ? a = '' : null;
30
- b === null ? b = '' : null;
23
+ if (a === null) a = '';
24
+ if (b === null) b = '';
31
25
  if (typeof a === 'number' && typeof b === 'number') {
32
26
  return a - b;
33
27
  }
34
28
  if (typeof a === 'string' && typeof b === 'string') {
35
29
  return compareStrings(a, b, locale);
36
30
  }
37
-
38
- // if column has React elements, this should sort by the child string if there is one
39
- if (typeof a === 'object' && typeof b === 'object') {
40
- if (typeof a.props?.children === 'string' && typeof b.props?.children === 'string') {
41
- return compareStrings(a.props.children, b.props.children, locale);
42
- }
31
+ const aChild = a?.props?.children;
32
+ const bChild = b?.props?.children;
33
+ if (typeof aChild === 'string' && typeof bChild === 'string') {
34
+ return compareStrings(aChild, bChild, locale);
43
35
  }
44
- return compareStrings('' + a, '' + b, locale);
36
+ return compareStrings(String(a), String(b), locale);
45
37
  };
46
38
 
47
39
  /**
48
- * Use the built-in `localeCompare` function available on strings to compare two
49
- * strings.
40
+ * Compares two strings using `localeCompare`.
50
41
  *
51
- * @param {string} a
52
- * @param {string} b
53
- * @param {string} locale
54
- * @returns {number}
42
+ * Note: Uses numeric comparison if strings are numeric.
55
43
  */
56
44
  const compareStrings = function (a, b) {
57
45
  let locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en';
58
- // Only set `numeric: true` if the string only contains numbers
59
- // https://stackoverflow.com/a/175787
60
- if (!isNaN(a) && !isNaN(parseFloat(a)) && !isNaN(b) && !isNaN(parseFloat(b))) {
61
- return a.localeCompare(b, locale, {
62
- numeric: true
63
- });
64
- }
65
- return a.localeCompare(b, locale);
46
+ const isNumeric = !isNaN(parseFloat(a)) && !isNaN(parseFloat(b));
47
+ return a.localeCompare(b, locale, {
48
+ numeric: isNumeric
49
+ });
66
50
  };
67
-
68
51
  /**
69
- * Default implementation of how we sort rows internally. The idea behind this
70
- * implementation is to use the given list of row ids to look up the cells in
71
- * the row by the given key. We then use the value of these cells and pipe them
72
- * into our local `compareStrings` method, including the locale where
73
- * appropriate.
74
- *
75
- * @param {object} config
76
- * @param {Array[string]} config.rowIds array of all the row ids in the table
77
- * @param {object} config.cellsById object containing a mapping of cell id to
78
- * cell
79
- * @param {string} config.key the header key that we use to lookup the cell
80
- * @param {string} [config.locale] optional locale used in the comparison
81
- * function
82
- * @param {string} config.sortDirection the sort direction used to determine the
83
- * order the comparison is called in
84
- * @param {Function} config.sortRow
85
- * @returns {Array[string]} array of sorted rowIds
52
+ * Sorts table rows based on the provided column key and direction.
86
53
  */
87
54
  const sortRows = _ref => {
88
55
  let {
@@ -96,16 +63,20 @@ const sortRows = _ref => {
96
63
  return rowIds.slice().sort((a, b) => {
97
64
  const cellA = cellsById[cells.getCellId(a, key)];
98
65
  const cellB = cellsById[cells.getCellId(b, key)];
99
- return sortRow(cellA && cellA.value, cellB && cellB.value, {
66
+ return sortRow(cellA?.value, cellB?.value, {
100
67
  key,
101
68
  sortDirection,
102
- locale,
103
69
  sortStates: sortStates.sortStates,
70
+ locale,
104
71
  compare,
105
72
  rowIds: [a, b]
106
73
  });
107
74
  });
108
75
  };
76
+
77
+ /**
78
+ * Sorts table rows based on the sort direction.
79
+ */
109
80
  const defaultSortRow = (cellA, cellB, _ref2) => {
110
81
  let {
111
82
  sortDirection,
@@ -119,6 +90,5 @@ const defaultSortRow = (cellA, cellB, _ref2) => {
119
90
  };
120
91
 
121
92
  exports.compare = compare;
122
- exports.compareStrings = compareStrings;
123
93
  exports.defaultSortRow = defaultSortRow;
124
94
  exports.sortRows = 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
  */
@@ -185,13 +185,14 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
185
185
  }
186
186
  }, []);
187
187
  const lastStartValue = React.useRef('');
188
+ const calendarRef = React.useRef(null);
188
189
  const [calendarCloseEvent, setCalendarCloseEvent] = React.useState(null);
189
190
 
190
191
  // fix datepicker deleting the selectedDate when the calendar closes
191
192
  const handleCalendarClose = React.useCallback((selectedDates, dateStr, instance) => {
192
193
  if (lastStartValue.current && selectedDates[0] && !startInputField.current.value) {
193
194
  startInputField.current.value = lastStartValue.current;
194
- calendarRef.current.setDate([startInputField.current.value, endInputField?.current?.value], true, calendarRef.current.config.dateFormat);
195
+ calendarRef.current?.setDate([startInputField.current.value, endInputField?.current?.value], true, calendarRef.current.config.dateFormat);
195
196
  }
196
197
  if (onClose) {
197
198
  onClose(selectedDates, dateStr, instance);
@@ -219,7 +220,6 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
219
220
  }
220
221
  }, [calendarCloseEvent, handleCalendarClose]);
221
222
  const endInputField = React.useRef(null);
222
- const calendarRef = React.useRef(null);
223
223
  const savedOnChange = useSavedCallback.useSavedCallback(onChange);
224
224
  const savedOnOpen = useSavedCallback.useSavedCallback(onOpen);
225
225
  const datePickerClasses = cx__default["default"](`${prefix}--date-picker`, {
@@ -336,7 +336,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
336
336
  const {
337
337
  current: end
338
338
  } = endInputField;
339
- const flatpickerconfig = {
339
+ const flatpickerConfig = {
340
340
  inline: inline ?? false,
341
341
  onClose: onCalendarClose,
342
342
  disableMobile: true,
@@ -382,7 +382,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
382
382
  },
383
383
  onValueUpdate: onHook
384
384
  };
385
- const calendar = flatpickr__default["default"](start, flatpickerconfig);
385
+ const calendar = flatpickr__default["default"](start, flatpickerConfig);
386
386
  calendarRef.current = calendar;
387
387
  function handleArrowDown(event) {
388
388
  if (match.match(event, keys.Escape)) {
@@ -395,10 +395,10 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
395
395
  const {
396
396
  calendarContainer,
397
397
  selectedDateElem: fpSelectedDateElem,
398
- todayDateElem: fptodayDateElem
398
+ todayDateElem: fpTodayDateElem
399
399
  } = calendar;
400
400
  const selectedDateElem = calendarContainer.querySelector('.selected') && fpSelectedDateElem;
401
- const todayDateElem = calendarContainer.querySelector('.today') && fptodayDateElem;
401
+ const todayDateElem = calendarContainer.querySelector('.today') && fpTodayDateElem;
402
402
  (selectedDateElem || todayDateElem || calendarContainer.querySelector('.flatpickr-day[tabindex]') || calendarContainer).focus();
403
403
  }
404
404
  }
@@ -484,44 +484,44 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
484
484
  }
485
485
  }));
486
486
  React.useEffect(() => {
487
- if (calendarRef?.current?.set) {
487
+ if (calendarRef.current?.set) {
488
488
  calendarRef.current.set({
489
489
  dateFormat
490
490
  });
491
491
  }
492
492
  }, [dateFormat]);
493
493
  React.useEffect(() => {
494
- if (calendarRef?.current?.set) {
494
+ if (calendarRef.current?.set) {
495
495
  calendarRef.current.set('minDate', minDate);
496
496
  }
497
497
  }, [minDate]);
498
498
  React.useEffect(() => {
499
- if (calendarRef?.current?.set) {
499
+ if (calendarRef.current?.set) {
500
500
  calendarRef.current.set('allowInput', allowInput);
501
501
  }
502
502
  }, [allowInput]);
503
503
  React.useEffect(() => {
504
- if (calendarRef?.current?.set) {
504
+ if (calendarRef.current?.set) {
505
505
  calendarRef.current.set('maxDate', maxDate);
506
506
  }
507
507
  }, [maxDate]);
508
508
  React.useEffect(() => {
509
- if (calendarRef?.current?.set && disable) {
509
+ if (calendarRef.current?.set && disable) {
510
510
  calendarRef.current.set('disable', disable);
511
511
  }
512
512
  }, [disable]);
513
513
  React.useEffect(() => {
514
- if (calendarRef?.current?.set && enable) {
514
+ if (calendarRef.current?.set && enable) {
515
515
  calendarRef.current.set('enable', enable);
516
516
  }
517
517
  }, [enable]);
518
518
  React.useEffect(() => {
519
- if (calendarRef?.current?.set && inline) {
519
+ if (calendarRef.current?.set && inline) {
520
520
  calendarRef.current.set('inline', inline);
521
521
  }
522
522
  }, [inline]);
523
523
  React.useEffect(() => {
524
- //when value prop is set to empty, this clears the faltpicker's calendar instance and text input
524
+ //when value prop is set to empty, this clears the flatpicker's calendar instance and text input
525
525
  if (value === '') {
526
526
  calendarRef.current?.clear();
527
527
  if (startInputField.current) {
@@ -540,9 +540,9 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
540
540
  }
541
541
  };
542
542
  const closeCalendar = event => {
543
- calendarRef.current.close();
543
+ calendarRef.current?.close();
544
544
  // Remove focus from endDate calendar input
545
- onCalendarClose(calendarRef.current.selectedDates, '', calendarRef.current, {
545
+ onCalendarClose(calendarRef.current?.selectedDates, '', calendarRef.current, {
546
546
  type: 'clickOutside'
547
547
  });
548
548
  };
@@ -552,7 +552,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
552
552
  };
553
553
  }, [calendarRef, startInputField, endInputField, onCalendarClose]);
554
554
  React.useEffect(() => {
555
- if (calendarRef?.current?.set) {
555
+ if (calendarRef.current?.set) {
556
556
  if (value !== undefined) {
557
557
  calendarRef.current.setDate(value);
558
558
  }
@@ -566,7 +566,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
566
566
  React.useEffect(() => {
567
567
  if (!calendarRef.current || !startInputField.current) return;
568
568
  const handleKeyDown = event => {
569
- if (match.match(event, keys.Tab) && !event.shiftKey && document.activeElement === endInputField.current && calendarRef.current.isOpen) {
569
+ if (match.match(event, keys.Tab) && !event.shiftKey && document.activeElement === endInputField.current && calendarRef.current?.isOpen) {
570
570
  calendarRef.current.close();
571
571
  onCalendarClose(calendarRef.current.selectedDates, '', calendarRef.current, event);
572
572
  }
@@ -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
  /**
@@ -54,7 +54,7 @@ DropdownSkeleton.propTypes = {
54
54
  /**
55
55
  * Specify the size of the ListBox.
56
56
  */
57
- size: ListBoxPropTypes.ListBoxSize
57
+ size: ListBoxPropTypes.ListBoxSizePropType
58
58
  };
59
59
 
60
60
  exports.DropdownSkeleton = DropdownSkeleton;
@@ -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;
@@ -394,6 +394,10 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
394
394
  }));
395
395
  }))), !inline && !invalid && !warn && helper);
396
396
  });
397
+
398
+ // Workaround problems with forwardRef() and generics. In the long term, should stop using forwardRef().
399
+ // See https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref.
400
+
397
401
  Dropdown.displayName = 'Dropdown';
398
402
  Dropdown.propTypes = {
399
403
  /**
@@ -507,7 +511,7 @@ Dropdown.propTypes = {
507
511
  /**
508
512
  * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
509
513
  */
510
- size: ListBoxPropTypes.ListBoxSize,
514
+ size: ListBoxPropTypes.ListBoxSizePropType,
511
515
  /**
512
516
  * **Experimental**: Provide a `Slug` component to be rendered inside the `Dropdown` component
513
517
  */
@@ -524,7 +528,7 @@ Dropdown.propTypes = {
524
528
  /**
525
529
  * The dropdown type, `default` or `inline`
526
530
  */
527
- type: ListBoxPropTypes.ListBoxType,
531
+ type: ListBoxPropTypes.ListBoxTypePropType,
528
532
  /**
529
533
  * Specify whether the control is currently in warning state
530
534
  */
@@ -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.
@@ -49,7 +49,7 @@ function FileUploaderButton(_ref) {
49
49
  const [prevOwnerLabelText, setPrevOwnerLabelText] = React.useState(ownerLabelText);
50
50
  const {
51
51
  current: inputId
52
- } = React.useRef(id || uniqueId["default"]());
52
+ } = React.useRef(id || uniqueId.uniqueId());
53
53
  const inputNode = React.useRef(null);
54
54
  const classes = cx__default["default"](`${prefix}--btn`, className, {
55
55
  [`${prefix}--btn--${buttonKind}`]: buttonKind,
@@ -47,7 +47,7 @@ function FileUploaderDropContainer(_ref) {
47
47
  const inputRef = React.useRef(null);
48
48
  const {
49
49
  current: uid
50
- } = React.useRef(id || uniqueId["default"]());
50
+ } = React.useRef(id || uniqueId.uniqueId());
51
51
  const [isActive, setActive] = React.useState(false);
52
52
  const dropareaClasses = cx__default["default"](`${prefix}--file__drop-container`, `${prefix}--file-browse-btn`, {
53
53
  [`${prefix}--file__drop-container--drag-over`]: isActive,
@@ -49,7 +49,7 @@ function FileUploaderItem(_ref) {
49
49
  const prefix = usePrefix.usePrefix();
50
50
  const {
51
51
  current: id
52
- } = React.useRef(uuid || uniqueId["default"]());
52
+ } = React.useRef(uuid || uniqueId.uniqueId());
53
53
  const classes = cx__default["default"](`${prefix}--file__selected-file`, className, {
54
54
  [`${prefix}--file__selected-file--invalid`]: invalid,
55
55
  [`${prefix}--file__selected-file--md`]: size === 'md',
@@ -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.
@@ -20,6 +20,7 @@ var usePrefix = require('../../internal/usePrefix.js');
20
20
  var ButtonBase = require('../Button/ButtonBase.js');
21
21
  var deprecateValuesWithin = require('../../prop-types/deprecateValuesWithin.js');
22
22
  var index = require('../BadgeIndicator/index.js');
23
+ var mapPopoverAlign = require('../../tools/mapPopoverAlign.js');
23
24
 
24
25
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
25
26
 
@@ -28,19 +29,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
28
29
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
29
30
 
30
31
  const IconButtonKinds = ['primary', 'secondary', 'ghost', 'tertiary'];
31
- const propMappingFunction = deprecatedValue => {
32
- const mapping = {
33
- 'top-left': 'top-start',
34
- 'top-right': 'top-end',
35
- 'bottom-left': 'bottom-start',
36
- 'bottom-right': 'bottom-end',
37
- 'left-bottom': 'left-end',
38
- 'left-top': 'left-start',
39
- 'right-bottom': 'right-end',
40
- 'right-top': 'right-start'
41
- };
42
- return mapping[deprecatedValue];
43
- };
44
32
  const IconButton = /*#__PURE__*/React__default["default"].forwardRef(function IconButton(_ref, ref) {
45
33
  let {
46
34
  align,
@@ -120,11 +108,7 @@ IconButton.propTypes = {
120
108
  // deprecated use right-start instead
121
109
 
122
110
  // new values to match floating-ui
123
- 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
124
- //allowed prop values
125
- ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'],
126
- //optional mapper function
127
- propMappingFunction),
111
+ '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.mapPopoverAlign),
128
112
  /**
129
113
  * **Experimental**: Will attempt to automatically align the tooltip
130
114
  */
@@ -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;
@@ -14,10 +14,11 @@ var cx = require('classnames');
14
14
  var React = require('react');
15
15
  var PropTypes = require('prop-types');
16
16
  var deprecate = require('../../prop-types/deprecate.js');
17
- var ListBoxPropTypes = require('./ListBoxPropTypes.js');
17
+ require('./index.js');
18
18
  var usePrefix = require('../../internal/usePrefix.js');
19
19
  require('../FluidForm/FluidForm.js');
20
20
  var FormContext = require('../FluidForm/FormContext.js');
21
+ var ListBoxPropTypes = require('./ListBoxPropTypes.js');
21
22
 
22
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
23
24
 
@@ -38,8 +39,8 @@ const handleClick = event => {
38
39
  * `ListBox` is a generic container component that handles creating the
39
40
  * container class name in response to certain props.
40
41
  */
41
- const ListBox = /*#__PURE__*/React__default["default"].forwardRef(function ListBox(_ref, ref) {
42
- let {
42
+ const ListBox = /*#__PURE__*/React.forwardRef((props, ref) => {
43
+ const {
43
44
  children,
44
45
  className: containerClassName,
45
46
  disabled = false,
@@ -54,7 +55,7 @@ const ListBox = /*#__PURE__*/React__default["default"].forwardRef(function ListB
54
55
  light,
55
56
  isOpen,
56
57
  ...rest
57
- } = _ref;
58
+ } = props;
58
59
  const prefix = usePrefix.usePrefix();
59
60
  const {
60
61
  isFluid
@@ -127,12 +128,12 @@ ListBox.propTypes = {
127
128
  /**
128
129
  * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
129
130
  */
130
- size: ListBoxPropTypes.ListBoxSize,
131
+ size: ListBoxPropTypes.ListBoxSizePropType,
131
132
  /**
132
133
  * Specify the "type" of the ListBox. Currently supports either `default` or
133
134
  * `inline` as an option.
134
135
  */
135
- type: ListBoxPropTypes.ListBoxType,
136
+ type: ListBoxPropTypes.ListBoxTypePropType,
136
137
  /**
137
138
  * Specify whether the control is currently in warning state
138
139
  */
@@ -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;
@@ -20,12 +20,14 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
20
20
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
21
21
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
22
22
 
23
+ const frFn = React.forwardRef;
24
+
23
25
  /**
24
26
  * `ListBoxMenu` is a simple container node that isolates the `list-box__menu`
25
27
  * class into a single component. It is also being used to validate given
26
28
  * `children` components.
27
29
  */
28
- const ListBoxMenu = /*#__PURE__*/React__default["default"].forwardRef(function ListBoxMenu(_ref, ref) {
30
+ const ListBoxMenu = frFn((_ref, ref) => {
29
31
  let {
30
32
  children,
31
33
  id,
@@ -4,8 +4,8 @@
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 { ForwardedRef, ReactNode, type Ref } from 'react';
8
- import { ForwardRefReturn, ReactAttr } from '../../types/common';
7
+ import React, { ReactNode } from 'react';
8
+ import { ReactAttr } from '../../types/common';
9
9
  export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
10
10
  /**
11
11
  * Specify any children nodes that should be rendered inside of the ListBox
@@ -29,9 +29,10 @@ export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
29
29
  */
30
30
  title?: string;
31
31
  }
32
- export type ListBoxMenuItemForwardedRef = (ForwardedRef<HTMLLIElement> & {
33
- menuItemOptionRef?: Ref<HTMLDivElement>;
34
- }) | null;
35
- export type ListBoxMenuItemComponent = ForwardRefReturn<ListBoxMenuItemForwardedRef, ListBoxMenuItemProps>;
36
- declare const _default: ListBoxMenuItemComponent;
37
- export default _default;
32
+ /**
33
+ * `ListBoxMenuItem` is a helper component for managing the container class
34
+ * name, alongside any classes for any corresponding states, for a generic list
35
+ * box menu item.
36
+ */
37
+ declare const ListBoxMenuItem: React.ForwardRefExoticComponent<ListBoxMenuItemProps & React.RefAttributes<HTMLLIElement>>;
38
+ export default ListBoxMenuItem;