@carbon/react 1.81.0-rc.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 (222) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +784 -784
  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 +54 -32
  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/TableCell.js +28 -4
  25. package/es/components/DataTable/TableToolbarAction.d.ts +2 -4
  26. package/es/components/DataTable/TableToolbarAction.js +5 -4
  27. package/es/components/DataTable/tools/cells.d.ts +13 -0
  28. package/es/components/DataTable/tools/cells.js +3 -6
  29. package/es/components/DataTable/tools/filter.d.ts +26 -0
  30. package/es/components/DataTable/tools/filter.js +8 -17
  31. package/es/components/DataTable/tools/sorting.d.ts +42 -0
  32. package/es/components/DataTable/tools/sorting.js +24 -53
  33. package/es/components/DatePicker/DatePicker.d.ts +1 -1
  34. package/es/components/DatePicker/DatePicker.js +19 -19
  35. package/es/components/Dialog/index.d.ts +1 -1
  36. package/es/components/Dropdown/Dropdown.Skeleton.d.ts +2 -2
  37. package/es/components/Dropdown/Dropdown.Skeleton.js +2 -2
  38. package/es/components/Dropdown/Dropdown.d.ts +7 -6
  39. package/es/components/Dropdown/Dropdown.js +13 -9
  40. package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
  41. package/es/components/FileUploader/FileUploaderButton.js +1 -1
  42. package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
  43. package/es/components/FileUploader/FileUploaderItem.js +1 -1
  44. package/es/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +1 -1
  45. package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +5 -6
  46. package/es/components/FluidDropdown/FluidDropdown.d.ts +1 -1
  47. package/es/components/FluidSearch/FluidSearch.d.ts +3 -6
  48. package/es/components/IconButton/index.d.ts +1 -1
  49. package/es/components/IconButton/index.js +2 -18
  50. package/es/components/ListBox/ListBox.d.ts +4 -5
  51. package/es/components/ListBox/ListBox.js +8 -7
  52. package/es/components/ListBox/ListBoxMenu.d.ts +4 -4
  53. package/es/components/ListBox/ListBoxMenu.js +4 -2
  54. package/es/components/ListBox/ListBoxMenuItem.d.ts +9 -8
  55. package/es/components/ListBox/ListBoxPropTypes.d.ts +3 -3
  56. package/es/components/ListBox/ListBoxPropTypes.js +3 -3
  57. package/es/components/ListBox/index.d.ts +7 -5
  58. package/es/components/ListBox/index.js +1 -1
  59. package/es/components/Menu/Menu.js +9 -14
  60. package/es/components/Menu/MenuItem.js +15 -4
  61. package/es/components/Modal/Modal.js +9 -9
  62. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +3 -2
  63. package/es/components/MultiSelect/FilterableMultiSelect.js +3 -2
  64. package/es/components/MultiSelect/MultiSelect.d.ts +8 -2
  65. package/es/components/MultiSelect/MultiSelect.js +7 -4
  66. package/es/components/Notification/Notification.js +1 -1
  67. package/es/components/OverflowMenu/OverflowMenu.js +2 -21
  68. package/es/components/OverflowMenu/index.d.ts +1 -1
  69. package/es/components/OverflowMenu/index.js +2 -3
  70. package/es/components/OverflowMenu/next/index.js +2 -18
  71. package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +2 -4
  72. package/es/components/OverflowMenuItem/OverflowMenuItem.js +5 -4
  73. package/es/components/PageHeader/PageHeader.d.ts +160 -8
  74. package/es/components/PageHeader/PageHeader.js +155 -21
  75. package/es/components/PageHeader/index.d.ts +2 -2
  76. package/es/components/PageHeader/index.js +1 -1
  77. package/es/components/Popover/index.js +4 -21
  78. package/es/components/Search/Search.d.ts +2 -5
  79. package/es/components/Search/Search.js +24 -8
  80. package/es/components/Stack/HStack.d.ts +2 -3
  81. package/es/components/Stack/HStack.js +4 -7
  82. package/es/components/Stack/Stack.d.ts +3 -4
  83. package/es/components/Stack/Stack.js +3 -6
  84. package/es/components/Stack/VStack.d.ts +2 -3
  85. package/es/components/Stack/VStack.js +3 -2
  86. package/es/components/Stack/index.d.ts +4 -4
  87. package/es/components/TextArea/TextArea.js +3 -5
  88. package/es/components/TimePicker/TimePicker.d.ts +3 -4
  89. package/es/components/TimePicker/TimePicker.js +5 -4
  90. package/es/components/TimePickerSelect/TimePickerSelect.d.ts +23 -4
  91. package/es/components/TimePickerSelect/TimePickerSelect.js +5 -4
  92. package/es/components/TreeView/TreeNode.js +13 -1
  93. package/es/components/TreeView/TreeView.js +1 -1
  94. package/es/index.js +1 -1
  95. package/es/internal/FloatingMenu.js +9 -5
  96. package/es/internal/environment.js +7 -0
  97. package/es/internal/keyboard/navigation.d.ts +0 -10
  98. package/es/internal/keyboard/navigation.js +1 -13
  99. package/es/internal/useId.js +1 -1
  100. package/es/internal/useNoInteractiveChildren.js +7 -0
  101. package/es/internal/useOutsideClick.js +3 -0
  102. package/es/internal/wrapFocus.d.ts +49 -0
  103. package/es/internal/wrapFocus.js +64 -51
  104. package/es/tools/events.d.ts +17 -0
  105. package/es/tools/events.js +10 -13
  106. package/es/tools/mapPopoverAlign.d.ts +15 -0
  107. package/es/tools/mapPopoverAlign.js +28 -0
  108. package/es/tools/uniqueId.d.ts +7 -0
  109. package/es/tools/uniqueId.js +3 -3
  110. package/es/types/common.d.ts +0 -2
  111. package/lib/components/AILabel/index.d.ts +1 -1
  112. package/lib/components/AILabel/index.js +2 -9
  113. package/lib/components/Breadcrumb/Breadcrumb.d.ts +2 -3
  114. package/lib/components/Breadcrumb/Breadcrumb.js +3 -3
  115. package/lib/components/Breadcrumb/BreadcrumbItem.d.ts +3 -4
  116. package/lib/components/Breadcrumb/BreadcrumbItem.js +4 -3
  117. package/lib/components/Button/Button.js +1 -9
  118. package/lib/components/ButtonSet/ButtonSet.d.ts +2 -3
  119. package/lib/components/ButtonSet/ButtonSet.js +3 -3
  120. package/lib/components/CodeSnippet/CodeSnippet.d.ts +1 -1
  121. package/lib/components/CodeSnippet/CodeSnippet.js +3 -19
  122. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  123. package/lib/components/ComboBox/ComboBox.js +53 -31
  124. package/lib/components/ComboButton/index.d.ts +1 -1
  125. package/lib/components/ComboButton/index.js +2 -18
  126. package/lib/components/ComposedModal/ComposedModal.js +5 -3
  127. package/lib/components/Copy/Copy.d.ts +1 -1
  128. package/lib/components/Copy/Copy.js +2 -18
  129. package/lib/components/CopyButton/CopyButton.d.ts +1 -1
  130. package/lib/components/CopyButton/CopyButton.js +2 -18
  131. package/lib/components/DataTable/DataTable.d.ts +7 -12
  132. package/lib/components/DataTable/DataTable.js +0 -5
  133. package/lib/components/DataTable/TableCell.js +28 -3
  134. package/lib/components/DataTable/TableToolbarAction.d.ts +2 -4
  135. package/lib/components/DataTable/TableToolbarAction.js +4 -3
  136. package/lib/components/DataTable/tools/cells.d.ts +13 -0
  137. package/lib/components/DataTable/tools/cells.js +3 -6
  138. package/lib/components/DataTable/tools/filter.d.ts +26 -0
  139. package/lib/components/DataTable/tools/filter.js +8 -17
  140. package/lib/components/DataTable/tools/sorting.d.ts +42 -0
  141. package/lib/components/DataTable/tools/sorting.js +23 -53
  142. package/lib/components/DatePicker/DatePicker.d.ts +1 -1
  143. package/lib/components/DatePicker/DatePicker.js +19 -19
  144. package/lib/components/Dialog/index.d.ts +1 -1
  145. package/lib/components/Dropdown/Dropdown.Skeleton.d.ts +2 -2
  146. package/lib/components/Dropdown/Dropdown.Skeleton.js +1 -1
  147. package/lib/components/Dropdown/Dropdown.d.ts +7 -6
  148. package/lib/components/Dropdown/Dropdown.js +12 -8
  149. package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
  150. package/lib/components/FileUploader/FileUploaderButton.js +1 -1
  151. package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
  152. package/lib/components/FileUploader/FileUploaderItem.js +1 -1
  153. package/lib/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +1 -1
  154. package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +4 -5
  155. package/lib/components/FluidDropdown/FluidDropdown.d.ts +1 -1
  156. package/lib/components/FluidSearch/FluidSearch.d.ts +3 -6
  157. package/lib/components/IconButton/index.d.ts +1 -1
  158. package/lib/components/IconButton/index.js +2 -18
  159. package/lib/components/ListBox/ListBox.d.ts +4 -5
  160. package/lib/components/ListBox/ListBox.js +7 -6
  161. package/lib/components/ListBox/ListBoxMenu.d.ts +4 -4
  162. package/lib/components/ListBox/ListBoxMenu.js +3 -1
  163. package/lib/components/ListBox/ListBoxMenuItem.d.ts +9 -8
  164. package/lib/components/ListBox/ListBoxPropTypes.d.ts +3 -3
  165. package/lib/components/ListBox/ListBoxPropTypes.js +4 -4
  166. package/lib/components/ListBox/index.d.ts +7 -5
  167. package/lib/components/ListBox/index.js +2 -2
  168. package/lib/components/Menu/Menu.js +9 -14
  169. package/lib/components/Menu/MenuItem.js +15 -4
  170. package/lib/components/Modal/Modal.js +9 -9
  171. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +3 -2
  172. package/lib/components/MultiSelect/FilterableMultiSelect.js +2 -1
  173. package/lib/components/MultiSelect/MultiSelect.d.ts +8 -2
  174. package/lib/components/MultiSelect/MultiSelect.js +6 -3
  175. package/lib/components/Notification/Notification.js +1 -1
  176. package/lib/components/OverflowMenu/OverflowMenu.js +2 -21
  177. package/lib/components/OverflowMenu/index.d.ts +1 -1
  178. package/lib/components/OverflowMenu/index.js +2 -3
  179. package/lib/components/OverflowMenu/next/index.js +2 -18
  180. package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +2 -4
  181. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +4 -3
  182. package/lib/components/PageHeader/PageHeader.d.ts +160 -8
  183. package/lib/components/PageHeader/PageHeader.js +159 -19
  184. package/lib/components/PageHeader/index.d.ts +2 -2
  185. package/lib/components/PageHeader/index.js +6 -0
  186. package/lib/components/Popover/index.js +4 -21
  187. package/lib/components/Search/Search.d.ts +2 -5
  188. package/lib/components/Search/Search.js +24 -8
  189. package/lib/components/Stack/HStack.d.ts +2 -3
  190. package/lib/components/Stack/HStack.js +3 -6
  191. package/lib/components/Stack/Stack.d.ts +3 -4
  192. package/lib/components/Stack/Stack.js +2 -5
  193. package/lib/components/Stack/VStack.d.ts +2 -3
  194. package/lib/components/Stack/VStack.js +2 -1
  195. package/lib/components/Stack/index.d.ts +4 -4
  196. package/lib/components/TextArea/TextArea.js +2 -4
  197. package/lib/components/TimePicker/TimePicker.d.ts +3 -4
  198. package/lib/components/TimePicker/TimePicker.js +4 -3
  199. package/lib/components/TimePickerSelect/TimePickerSelect.d.ts +23 -4
  200. package/lib/components/TimePickerSelect/TimePickerSelect.js +4 -3
  201. package/lib/components/TreeView/TreeNode.js +13 -1
  202. package/lib/components/TreeView/TreeView.js +1 -1
  203. package/lib/index.js +2 -2
  204. package/lib/internal/FloatingMenu.js +9 -5
  205. package/lib/internal/environment.js +7 -0
  206. package/lib/internal/keyboard/navigation.d.ts +0 -10
  207. package/lib/internal/keyboard/navigation.js +0 -14
  208. package/lib/internal/useNoInteractiveChildren.js +7 -0
  209. package/lib/internal/useOutsideClick.js +3 -0
  210. package/lib/internal/wrapFocus.d.ts +49 -0
  211. package/lib/internal/wrapFocus.js +66 -53
  212. package/lib/tools/events.d.ts +17 -0
  213. package/lib/tools/events.js +10 -13
  214. package/lib/tools/mapPopoverAlign.d.ts +15 -0
  215. package/lib/tools/mapPopoverAlign.js +32 -0
  216. package/lib/tools/uniqueId.d.ts +7 -0
  217. package/lib/tools/uniqueId.js +3 -3
  218. package/lib/types/common.d.ts +0 -2
  219. package/package.json +9 -9
  220. package/telemetry.yml +3 -1
  221. package/es/tools/createPropAdapter.js +0 -40
  222. package/lib/tools/createPropAdapter.js +0 -44
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
- import React from 'react';
8
+ import React, { type MouseEvent } from 'react';
9
9
  import type { DataTableSortState } from './state/sortStates';
10
10
  import Table from './Table';
11
11
  import TableActionList from './TableActionList';
@@ -125,7 +125,7 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
125
125
  [key: string]: unknown;
126
126
  };
127
127
  getSelectionProps: (getSelectionPropsArgs?: {
128
- onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
128
+ onClick?: (e: MouseEvent<HTMLInputElement, globalThis.MouseEvent>) => void;
129
129
  row: DataTableRow<ColTypes>;
130
130
  [key: string]: unknown;
131
131
  }) => {
@@ -381,7 +381,7 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
381
381
  'aria-label': any;
382
382
  'aria-controls': string;
383
383
  isExpanded: boolean;
384
- onExpand: any;
384
+ onExpand: (event: React.MouseEvent<HTMLButtonElement, globalThis.MouseEvent>, ...args: any[]) => void;
385
385
  };
386
386
  /**
387
387
  * Decorate consumer's `onClick` event handler with sort parameters
@@ -413,7 +413,7 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
413
413
  [key: string]: unknown;
414
414
  }) => {
415
415
  key: string;
416
- onExpand: any;
416
+ onExpand: (event: React.MouseEvent<HTMLButtonElement, globalThis.MouseEvent>, ...args: any[]) => void;
417
417
  isExpanded: boolean | undefined;
418
418
  'aria-label': any;
419
419
  'aria-controls': string;
@@ -437,19 +437,14 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
437
437
  * Gets the props associated with selection for a header or a row, where
438
438
  * applicable. Most often used to indicate selection status of the table or
439
439
  * for a specific row.
440
- *
441
- * @param {object} [row] an optional row that we want to access the props for
442
- * @param {Function} row.onClick
443
- * @param {object} row.row
444
- * @returns {object}
445
440
  */
446
441
  getSelectionProps: ({ onClick, row, ...rest }?: {
447
442
  [key: string]: unknown;
448
- onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
443
+ onClick?: (e: MouseEvent<HTMLInputElement, globalThis.MouseEvent>) => void;
449
444
  row: DataTableRow<ColTypes>;
450
445
  }) => {
451
446
  checked: boolean | undefined;
452
- onSelect: any;
447
+ onSelect: (event: React.MouseEvent<HTMLInputElement, globalThis.MouseEvent>, ...args: any[]) => void;
453
448
  id: string;
454
449
  name: string;
455
450
  'aria-label': any;
@@ -461,7 +456,7 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
461
456
  id: string;
462
457
  indeterminate: boolean;
463
458
  name: string;
464
- onSelect: any;
459
+ onSelect: (event: React.MouseEvent<HTMLInputElement, globalThis.MouseEvent>, ...args: any[]) => void;
465
460
  };
466
461
  getToolbarProps: (props?: {}) => {
467
462
  size: "sm" | undefined;
@@ -233,11 +233,6 @@ class DataTable extends React__default.Component {
233
233
  * Gets the props associated with selection for a header or a row, where
234
234
  * applicable. Most often used to indicate selection status of the table or
235
235
  * for a specific row.
236
- *
237
- * @param {object} [row] an optional row that we want to access the props for
238
- * @param {Function} row.onClick
239
- * @param {object} row.row
240
- * @returns {object}
241
236
  */
242
237
  _defineProperty(this, "getSelectionProps", function () {
243
238
  let {
@@ -6,18 +6,20 @@
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 cx from 'classnames';
11
11
  import { usePrefix } from '../../internal/usePrefix.js';
12
+ import PropTypes from 'prop-types';
12
13
 
13
- const TableCell = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
14
- let {
14
+ const frFn = forwardRef;
15
+ const TableCell = frFn((props, ref) => {
16
+ const {
15
17
  children,
16
18
  className,
17
19
  hasAILabelHeader,
18
20
  colSpan,
19
21
  ...rest
20
- } = _ref;
22
+ } = props;
21
23
  const prefix = usePrefix();
22
24
  const tableCellClassNames = cx(className, {
23
25
  [`${prefix}--table-cell--column-slug`]: hasAILabelHeader
@@ -29,5 +31,27 @@ const TableCell = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
29
31
  }, rest), children);
30
32
  });
31
33
  TableCell.displayName = 'TableCell';
34
+ TableCell.propTypes = {
35
+ /**
36
+ * Pass in children that will be embedded in the table header label
37
+ */
38
+ children: PropTypes.node,
39
+ /**
40
+ * Specify an optional className to be applied to the container node
41
+ */
42
+ className: PropTypes.string,
43
+ /**
44
+ * The width of the expanded row's internal cell
45
+ */
46
+ colSpan: PropTypes.number,
47
+ /**
48
+ * Specify if the table cell is in an AI column
49
+ */
50
+ hasAILabelHeader: PropTypes.bool,
51
+ /**
52
+ * The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43
53
+ */
54
+ headers: PropTypes.string
55
+ };
32
56
 
33
57
  export { TableCell as default };
@@ -1,11 +1,10 @@
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 { ForwardRefReturn } from '../../types/common';
9
8
  export interface TableToolbarActionProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick'> {
10
9
  /**
11
10
  * Pass in the children that will be rendered inside the TableToolbarAction
@@ -16,6 +15,5 @@ export interface TableToolbarActionProps extends Omit<React.HTMLAttributes<HTMLD
16
15
  */
17
16
  onClick: (event: React.MouseEvent<HTMLDivElement>) => void;
18
17
  }
19
- export type TableToolbarActionComponent = ForwardRefReturn<HTMLDivElement, TableToolbarActionProps>;
20
- declare const TableToolbarAction: TableToolbarActionComponent;
18
+ declare const TableToolbarAction: React.ForwardRefExoticComponent<TableToolbarActionProps & React.RefAttributes<HTMLDivElement>>;
21
19
  export default TableToolbarAction;
@@ -7,14 +7,15 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
- import React__default from 'react';
10
+ import React__default, { forwardRef } from 'react';
11
11
  import OverflowMenuItem from '../OverflowMenuItem/OverflowMenuItem.js';
12
12
 
13
- const TableToolbarAction = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
14
- let {
13
+ const frFn = forwardRef;
14
+ const TableToolbarAction = frFn((props, ref) => {
15
+ const {
15
16
  children,
16
17
  ...rest
17
- } = _ref;
18
+ } = props;
18
19
  return /*#__PURE__*/React__default.createElement(OverflowMenuItem, _extends({
19
20
  ref: ref,
20
21
  itemText: children
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2025
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
+ /**
8
+ * Generates a unique cell ID by combining the row ID and header.
9
+ *
10
+ * Generic helper used to consolidate all call sites for getting a cell ID into
11
+ * one method.
12
+ */
13
+ export declare const getCellId: (rowId: string, header: string) => string;
@@ -6,13 +6,10 @@
6
6
  */
7
7
 
8
8
  /**
9
- * Generic helper used to consolidate all call sites for getting a cell id into
10
- * one method. The strategy currently is that a "cellId" is just the combination
11
- * of the row id and the header key used to access this field in a row.
9
+ * Generates a unique cell ID by combining the row ID and header.
12
10
  *
13
- * @param {string} rowId
14
- * @param {string} header
15
- * @returns {string}
11
+ * Generic helper used to consolidate all call sites for getting a cell ID into
12
+ * one method.
16
13
  */
17
14
  const getCellId = (rowId, header) => `${rowId}:${header}`;
18
15
 
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2025
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
+ /**
8
+ * Filters row IDs based on whether any of the cell values in the row include
9
+ * the input value as a substring. Boolean cell values are ignored.
10
+ */
11
+ export declare const defaultFilterRows: ({ rowIds, headers, cellsById, inputValue, getCellId, }: {
12
+ /** Table row IDs. */
13
+ rowIds: string[];
14
+ /** Table headers. */
15
+ headers: {
16
+ key: string;
17
+ }[];
18
+ /** Mapping of cell IDs to their corresponding cells. */
19
+ cellsById: Record<string, {
20
+ value: unknown;
21
+ }>;
22
+ /** Input value to search for. */
23
+ inputValue: string;
24
+ /** Function that returns a cell ID given a row ID and a header. */
25
+ getCellId: (rowId: string, header: string) => string;
26
+ }) => string[];
@@ -6,18 +6,8 @@
6
6
  */
7
7
 
8
8
  /**
9
- * Default implementation of how we filter rows internally. The idea behind this
10
- * implementation is to use the given list of row ids and headers to get the
11
- * individual cell values for a row. Then, we go through each cell value and see
12
- * if any of them includes the given inputValue.
13
- *
14
- * @param {object} config
15
- * @param {Array<string>} config.rowIds array of all the row ids in the table
16
- * @param {Array<object>} config.headers
17
- * @param {object} config.cellsById object containing a map of cell id to cell
18
- * @param {string} config.inputValue the current input value in the Table Search
19
- * @param {Function} config.getCellId
20
- * @returns {Array<string>} rowIds
9
+ * Filters row IDs based on whether any of the cell values in the row include
10
+ * the input value as a substring. Boolean cell values are ignored.
21
11
  */
22
12
  const defaultFilterRows = _ref => {
23
13
  let {
@@ -27,15 +17,16 @@ const defaultFilterRows = _ref => {
27
17
  inputValue,
28
18
  getCellId
29
19
  } = _ref;
20
+ const normalizedInput = inputValue.trim().toLowerCase();
21
+ if (!normalizedInput) return rowIds;
30
22
  return rowIds.filter(rowId => headers.some(_ref2 => {
31
23
  let {
32
24
  key
33
25
  } = _ref2;
34
- const id = getCellId(rowId, key);
35
- if (typeof cellsById[id].value === 'boolean') {
36
- return false;
37
- }
38
- return ('' + cellsById[id].value).toLowerCase().includes(inputValue.toLowerCase());
26
+ const cellId = getCellId(rowId, key);
27
+ const cell = cellsById[cellId];
28
+ if (typeof cell.value === 'boolean') return false;
29
+ return String(cell.value).toLowerCase().includes(normalizedInput);
39
30
  }));
40
31
  };
41
32
 
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2025
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 { type DataTableSortState } from '../state/sortStates';
8
+ /**
9
+ * Compare two values to determine their order. If both values have the same
10
+ * type, the default sort algorithm will be used for those types. Otherwise, the
11
+ * values will be converted to strings for comparison.
12
+ */
13
+ export declare const compare: (a: any, b: any, locale?: string) => number;
14
+ interface Cell {
15
+ id: string;
16
+ value: any;
17
+ }
18
+ interface SortRowParams {
19
+ key: string;
20
+ sortDirection: DataTableSortState;
21
+ sortStates: Record<DataTableSortState, DataTableSortState>;
22
+ locale: string;
23
+ compare: typeof compare;
24
+ rowIds: string[];
25
+ }
26
+ interface SortRowsConfig {
27
+ rowIds: string[];
28
+ cellsById: Record<string, Cell>;
29
+ key: string;
30
+ sortDirection: DataTableSortState;
31
+ locale?: string;
32
+ sortRow?: (cellA: any, cellB: any, params: SortRowParams) => number;
33
+ }
34
+ /**
35
+ * Sorts table rows based on the provided column key and direction.
36
+ */
37
+ export declare const sortRows: ({ rowIds, cellsById, sortDirection, key, locale, sortRow, }: SortRowsConfig) => string[];
38
+ /**
39
+ * Sorts table rows based on the sort direction.
40
+ */
41
+ export declare const defaultSortRow: (cellA: any, cellB: any, { sortDirection, sortStates, locale, }: Pick<SortRowParams, "locale" | "sortDirection" | "sortStates">) => number;
42
+ export {};
@@ -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
  }
@@ -461,7 +461,7 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
461
461
  }
462
462
  };
463
463
  // eslint-disable-next-line react-hooks/exhaustive-deps
464
- }, [savedOnChange, savedOnOpen, readOnly, closeOnSelect, hasInput]);
464
+ }, [savedOnChange, savedOnOpen, readOnly, closeOnSelect, hasInput, datePickerType]);
465
465
 
466
466
  // this hook allows consumers to access the flatpickr calendar
467
467
  // instance for cases where functions like open() or close()
@@ -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 };