@carbon/react 1.92.0 → 1.93.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 (302) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1011 -970
  2. package/es/components/AILabel/index.js +4 -4
  3. package/es/components/Breadcrumb/BreadcrumbItem.js +1 -1
  4. package/es/components/Button/Button.js +2 -2
  5. package/es/components/ChatButton/ChatButton.js +1 -1
  6. package/es/components/Checkbox/Checkbox.js +1 -1
  7. package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
  8. package/es/components/ComboBox/ComboBox.d.ts +3 -11
  9. package/es/components/ComboBox/ComboBox.js +15 -25
  10. package/es/components/ComboButton/index.d.ts +5 -8
  11. package/es/components/ComboButton/index.js +9 -12
  12. package/es/components/ComposedModal/ComposedModal.js +22 -36
  13. package/es/components/DataTable/DataTable.d.ts +25 -16
  14. package/es/components/DataTable/DataTable.js +33 -34
  15. package/es/components/DataTable/Table.js +2 -2
  16. package/es/components/DataTable/TableBatchActions.d.ts +49 -10
  17. package/es/components/DataTable/TableBatchActions.js +26 -21
  18. package/es/components/DataTable/TableExpandHeader.js +2 -2
  19. package/es/components/DataTable/TableExpandRow.js +1 -1
  20. package/es/components/DataTable/TableHeader.d.ts +8 -10
  21. package/es/components/DataTable/TableHeader.js +11 -13
  22. package/es/components/DataTable/TableRow.js +5 -5
  23. package/es/components/DataTable/TableSlugRow.js +1 -1
  24. package/es/components/DataTable/TableToolbarMenu.js +1 -1
  25. package/es/components/DataTable/TableToolbarSearch.d.ts +8 -7
  26. package/es/components/DataTable/TableToolbarSearch.js +11 -11
  27. package/es/components/DataTable/index.d.ts +2 -2
  28. package/es/components/DataTable/state/sorting.d.ts +2 -2
  29. package/es/components/DataTable/state/sorting.js +1 -1
  30. package/es/components/DataTable/tools/sorting.js +1 -1
  31. package/es/components/DatePicker/DatePicker.js +9 -9
  32. package/es/components/DatePickerInput/DatePickerInput.js +5 -5
  33. package/es/components/Dialog/Dialog.js +6 -6
  34. package/es/components/Dropdown/Dropdown.d.ts +1 -1
  35. package/es/components/Dropdown/Dropdown.js +8 -8
  36. package/es/components/ErrorBoundary/ErrorBoundaryContext.js +1 -1
  37. package/es/components/FileUploader/FileUploader.js +4 -4
  38. package/es/components/FileUploader/FileUploaderButton.js +1 -1
  39. package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
  40. package/es/components/FileUploader/FileUploaderItem.js +2 -2
  41. package/es/components/FluidComboBox/FluidComboBox.d.ts +4 -7
  42. package/es/components/FluidComboBox/FluidComboBox.js +1 -1
  43. package/es/components/FluidDropdown/FluidDropdown.d.ts +4 -8
  44. package/es/components/FluidDropdown/FluidDropdown.js +1 -1
  45. package/es/components/FluidMultiSelect/FluidFilterableMultiSelect.d.ts +3 -7
  46. package/es/components/FluidMultiSelect/FluidMultiSelect.d.ts +3 -7
  47. package/es/components/FluidMultiSelect/FluidMultiSelect.js +3 -3
  48. package/es/components/FluidNumberInput/FluidNumberInput.d.ts +4 -7
  49. package/es/components/FluidNumberInput/FluidNumberInput.js +2 -2
  50. package/es/components/FluidSearch/FluidSearch.js +1 -1
  51. package/es/components/FluidSelect/FluidSelect.js +1 -1
  52. package/es/components/FluidTextInput/FluidTextInput.js +1 -1
  53. package/es/components/FluidTimePicker/FluidTimePicker.js +3 -3
  54. package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +1 -1
  55. package/es/components/Grid/CSSGrid.js +3 -3
  56. package/es/components/Grid/Column.js +2 -2
  57. package/es/components/Grid/ColumnHang.js +1 -1
  58. package/es/components/Grid/FlexGrid.js +1 -1
  59. package/es/components/Grid/Row.js +1 -1
  60. package/es/components/Heading/index.js +2 -2
  61. package/es/components/IconButton/index.js +2 -2
  62. package/es/components/IconIndicator/index.js +2 -2
  63. package/es/components/InlineCheckbox/InlineCheckbox.js +1 -1
  64. package/es/components/Layout/index.js +2 -2
  65. package/es/components/LayoutDirection/LayoutDirection.js +1 -1
  66. package/es/components/Link/Link.js +2 -2
  67. package/es/components/ListBox/ListBoxField.d.ts +0 -1
  68. package/es/components/ListBox/ListBoxMenuIcon.d.ts +8 -4
  69. package/es/components/ListBox/ListBoxMenuIcon.js +10 -6
  70. package/es/components/ListBox/ListBoxMenuItem.js +2 -2
  71. package/es/components/ListBox/ListBoxSelection.d.ts +3 -6
  72. package/es/components/ListBox/ListBoxSelection.js +5 -10
  73. package/es/components/ListBox/index.d.ts +5 -3
  74. package/es/components/ListBox/next/ListBoxSelection.d.ts +6 -13
  75. package/es/components/ListBox/next/ListBoxSelection.js +16 -8
  76. package/es/components/ListBox/next/ListBoxTrigger.d.ts +5 -10
  77. package/es/components/ListBox/next/ListBoxTrigger.js +6 -6
  78. package/es/components/Menu/MenuContext.js +1 -1
  79. package/es/components/Menu/MenuItem.js +1 -1
  80. package/es/components/MenuButton/index.js +5 -5
  81. package/es/components/Modal/Modal.js +20 -36
  82. package/es/components/ModalWrapper/ModalWrapper.js +2 -2
  83. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +3 -12
  84. package/es/components/MultiSelect/FilterableMultiSelect.js +18 -27
  85. package/es/components/MultiSelect/MultiSelect.d.ts +2 -2
  86. package/es/components/MultiSelect/MultiSelect.js +12 -12
  87. package/es/components/Notification/Notification.js +1 -1
  88. package/es/components/NumberInput/NumberInput.d.ts +2 -5
  89. package/es/components/NumberInput/NumberInput.js +13 -18
  90. package/es/components/OverflowMenu/OverflowMenu.d.ts +2 -2
  91. package/es/components/OverflowMenu/OverflowMenu.js +4 -4
  92. package/es/components/OverflowMenu/next/index.d.ts +1 -1
  93. package/es/components/OverflowMenu/next/index.js +2 -2
  94. package/es/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
  95. package/es/components/PageHeader/PageHeader.js +12 -12
  96. package/es/components/Pagination/Pagination.js +3 -3
  97. package/es/components/PaginationNav/PaginationNav.d.ts +6 -9
  98. package/es/components/PaginationNav/PaginationNav.js +21 -22
  99. package/es/components/Popover/index.js +8 -8
  100. package/es/components/ProgressBar/ProgressBar.js +2 -2
  101. package/es/components/ProgressIndicator/ProgressIndicator.d.ts +11 -15
  102. package/es/components/ProgressIndicator/ProgressIndicator.js +15 -15
  103. package/es/components/RadioButton/RadioButton.js +1 -1
  104. package/es/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  105. package/es/components/RadioTile/RadioTile.js +1 -1
  106. package/es/components/Select/Select.js +7 -5
  107. package/es/components/ShapeIndicator/index.js +2 -2
  108. package/es/components/Slider/Slider.d.ts +7 -9
  109. package/es/components/Slider/Slider.js +16 -20
  110. package/es/components/Stack/HStack.js +1 -1
  111. package/es/components/Stack/Stack.js +1 -1
  112. package/es/components/Stack/VStack.js +1 -1
  113. package/es/components/StructuredList/StructuredList.js +3 -3
  114. package/es/components/Tabs/Tabs.js +12 -12
  115. package/es/components/Tag/DismissibleTag.js +3 -3
  116. package/es/components/Tag/OperationalTag.js +2 -2
  117. package/es/components/Tag/SelectableTag.js +2 -2
  118. package/es/components/Tag/Tag.js +4 -4
  119. package/es/components/Tag/isEllipsisActive.js +1 -1
  120. package/es/components/Text/Text.js +1 -1
  121. package/es/components/TextArea/TextArea.js +1 -1
  122. package/es/components/TextInput/PasswordInput.js +4 -4
  123. package/es/components/TextInput/TextInput.js +3 -3
  124. package/es/components/Theme/index.js +3 -3
  125. package/es/components/Tile/Tile.js +3 -3
  126. package/es/components/TimePicker/TimePicker.js +1 -1
  127. package/es/components/Toggletip/index.js +4 -4
  128. package/es/components/Tooltip/DefinitionTooltip.js +1 -1
  129. package/es/components/Tooltip/Tooltip.js +3 -3
  130. package/es/components/TreeView/TreeNode.js +6 -6
  131. package/es/components/TreeView/TreeView.js +5 -5
  132. package/es/components/UIShell/HeaderContainer.js +1 -1
  133. package/es/components/UIShell/HeaderMenu.js +1 -1
  134. package/es/components/UIShell/Link.js +2 -2
  135. package/es/components/UIShell/SideNavItems.js +1 -1
  136. package/es/components/UIShell/Switcher.js +1 -1
  137. package/es/components/UIShell/SwitcherItem.js +1 -1
  138. package/es/index.d.ts +1 -1
  139. package/es/internal/FloatingMenu.js +4 -4
  140. package/es/internal/Selection.js +6 -6
  141. package/es/internal/useMergedRefs.js +1 -1
  142. package/es/internal/useNoInteractiveChildren.js +4 -4
  143. package/es/internal/useOutsideClick.js +1 -1
  144. package/es/internal/useOverflowItems.js +6 -6
  145. package/es/internal/useResizeObserver.js +3 -3
  146. package/es/internal/useSavedCallback.js +1 -1
  147. package/es/internal/warning.js +1 -1
  148. package/es/prop-types/isRequiredOneOf.js +2 -2
  149. package/es/tools/events.js +1 -1
  150. package/es/tools/wrapComponent.js +1 -1
  151. package/es/types/common.d.ts +6 -2
  152. package/lib/components/AILabel/index.js +4 -4
  153. package/lib/components/Breadcrumb/BreadcrumbItem.js +1 -1
  154. package/lib/components/Button/Button.js +2 -2
  155. package/lib/components/ChatButton/ChatButton.js +1 -1
  156. package/lib/components/Checkbox/Checkbox.js +1 -1
  157. package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
  158. package/lib/components/ComboBox/ComboBox.d.ts +3 -11
  159. package/lib/components/ComboBox/ComboBox.js +15 -25
  160. package/lib/components/ComboButton/index.d.ts +5 -8
  161. package/lib/components/ComboButton/index.js +9 -12
  162. package/lib/components/ComposedModal/ComposedModal.js +21 -35
  163. package/lib/components/DataTable/DataTable.d.ts +25 -16
  164. package/lib/components/DataTable/DataTable.js +33 -34
  165. package/lib/components/DataTable/Table.js +2 -2
  166. package/lib/components/DataTable/TableBatchActions.d.ts +49 -10
  167. package/lib/components/DataTable/TableBatchActions.js +26 -21
  168. package/lib/components/DataTable/TableExpandHeader.js +2 -2
  169. package/lib/components/DataTable/TableExpandRow.js +1 -1
  170. package/lib/components/DataTable/TableHeader.d.ts +8 -10
  171. package/lib/components/DataTable/TableHeader.js +11 -13
  172. package/lib/components/DataTable/TableRow.js +5 -5
  173. package/lib/components/DataTable/TableSlugRow.js +1 -1
  174. package/lib/components/DataTable/TableToolbarMenu.js +1 -1
  175. package/lib/components/DataTable/TableToolbarSearch.d.ts +8 -7
  176. package/lib/components/DataTable/TableToolbarSearch.js +11 -11
  177. package/lib/components/DataTable/index.d.ts +2 -2
  178. package/lib/components/DataTable/state/sorting.d.ts +2 -2
  179. package/lib/components/DataTable/state/sorting.js +1 -1
  180. package/lib/components/DataTable/tools/sorting.js +1 -1
  181. package/lib/components/DatePicker/DatePicker.js +9 -9
  182. package/lib/components/DatePickerInput/DatePickerInput.js +5 -5
  183. package/lib/components/Dialog/Dialog.js +6 -6
  184. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  185. package/lib/components/Dropdown/Dropdown.js +8 -8
  186. package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +1 -1
  187. package/lib/components/FileUploader/FileUploader.js +4 -4
  188. package/lib/components/FileUploader/FileUploaderButton.js +1 -1
  189. package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
  190. package/lib/components/FileUploader/FileUploaderItem.js +2 -2
  191. package/lib/components/FluidComboBox/FluidComboBox.d.ts +4 -7
  192. package/lib/components/FluidComboBox/FluidComboBox.js +1 -1
  193. package/lib/components/FluidDropdown/FluidDropdown.d.ts +4 -8
  194. package/lib/components/FluidDropdown/FluidDropdown.js +1 -1
  195. package/lib/components/FluidMultiSelect/FluidFilterableMultiSelect.d.ts +3 -7
  196. package/lib/components/FluidMultiSelect/FluidMultiSelect.d.ts +3 -7
  197. package/lib/components/FluidMultiSelect/FluidMultiSelect.js +3 -3
  198. package/lib/components/FluidNumberInput/FluidNumberInput.d.ts +4 -7
  199. package/lib/components/FluidNumberInput/FluidNumberInput.js +2 -2
  200. package/lib/components/FluidSearch/FluidSearch.js +1 -1
  201. package/lib/components/FluidSelect/FluidSelect.js +1 -1
  202. package/lib/components/FluidTextInput/FluidTextInput.js +1 -1
  203. package/lib/components/FluidTimePicker/FluidTimePicker.js +3 -3
  204. package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +1 -1
  205. package/lib/components/Grid/CSSGrid.js +3 -3
  206. package/lib/components/Grid/Column.js +2 -2
  207. package/lib/components/Grid/ColumnHang.js +1 -1
  208. package/lib/components/Grid/FlexGrid.js +1 -1
  209. package/lib/components/Grid/Row.js +1 -1
  210. package/lib/components/Heading/index.js +2 -2
  211. package/lib/components/IconButton/index.js +2 -2
  212. package/lib/components/IconIndicator/index.js +2 -2
  213. package/lib/components/InlineCheckbox/InlineCheckbox.js +1 -1
  214. package/lib/components/Layout/index.js +2 -2
  215. package/lib/components/LayoutDirection/LayoutDirection.js +1 -1
  216. package/lib/components/Link/Link.js +2 -2
  217. package/lib/components/ListBox/ListBoxField.d.ts +0 -1
  218. package/lib/components/ListBox/ListBoxMenuIcon.d.ts +8 -4
  219. package/lib/components/ListBox/ListBoxMenuIcon.js +10 -6
  220. package/lib/components/ListBox/ListBoxMenuItem.js +2 -2
  221. package/lib/components/ListBox/ListBoxSelection.d.ts +3 -6
  222. package/lib/components/ListBox/ListBoxSelection.js +4 -10
  223. package/lib/components/ListBox/index.d.ts +5 -3
  224. package/lib/components/ListBox/next/ListBoxSelection.d.ts +6 -13
  225. package/lib/components/ListBox/next/ListBoxSelection.js +16 -8
  226. package/lib/components/ListBox/next/ListBoxTrigger.d.ts +5 -10
  227. package/lib/components/ListBox/next/ListBoxTrigger.js +5 -6
  228. package/lib/components/Menu/MenuContext.js +1 -1
  229. package/lib/components/Menu/MenuItem.js +1 -1
  230. package/lib/components/MenuButton/index.js +5 -5
  231. package/lib/components/Modal/Modal.js +19 -35
  232. package/lib/components/ModalWrapper/ModalWrapper.js +2 -2
  233. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +3 -12
  234. package/lib/components/MultiSelect/FilterableMultiSelect.js +18 -27
  235. package/lib/components/MultiSelect/MultiSelect.d.ts +2 -2
  236. package/lib/components/MultiSelect/MultiSelect.js +12 -12
  237. package/lib/components/Notification/Notification.js +1 -1
  238. package/lib/components/NumberInput/NumberInput.d.ts +2 -5
  239. package/lib/components/NumberInput/NumberInput.js +12 -18
  240. package/lib/components/OverflowMenu/OverflowMenu.d.ts +2 -2
  241. package/lib/components/OverflowMenu/OverflowMenu.js +4 -4
  242. package/lib/components/OverflowMenu/next/index.d.ts +1 -1
  243. package/lib/components/OverflowMenu/next/index.js +2 -2
  244. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
  245. package/lib/components/PageHeader/PageHeader.js +12 -12
  246. package/lib/components/Pagination/Pagination.js +3 -3
  247. package/lib/components/PaginationNav/PaginationNav.d.ts +6 -9
  248. package/lib/components/PaginationNav/PaginationNav.js +21 -22
  249. package/lib/components/Popover/index.js +8 -8
  250. package/lib/components/ProgressBar/ProgressBar.js +2 -2
  251. package/lib/components/ProgressIndicator/ProgressIndicator.d.ts +11 -15
  252. package/lib/components/ProgressIndicator/ProgressIndicator.js +15 -15
  253. package/lib/components/RadioButton/RadioButton.js +1 -1
  254. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  255. package/lib/components/RadioTile/RadioTile.js +1 -1
  256. package/lib/components/Select/Select.js +7 -5
  257. package/lib/components/ShapeIndicator/index.js +2 -2
  258. package/lib/components/Slider/Slider.d.ts +7 -9
  259. package/lib/components/Slider/Slider.js +16 -20
  260. package/lib/components/Stack/HStack.js +1 -1
  261. package/lib/components/Stack/Stack.js +1 -1
  262. package/lib/components/Stack/VStack.js +1 -1
  263. package/lib/components/StructuredList/StructuredList.js +3 -3
  264. package/lib/components/Tabs/Tabs.js +12 -12
  265. package/lib/components/Tag/DismissibleTag.js +3 -3
  266. package/lib/components/Tag/OperationalTag.js +2 -2
  267. package/lib/components/Tag/SelectableTag.js +2 -2
  268. package/lib/components/Tag/Tag.js +4 -4
  269. package/lib/components/Tag/isEllipsisActive.js +1 -1
  270. package/lib/components/Text/Text.js +1 -1
  271. package/lib/components/TextArea/TextArea.js +1 -1
  272. package/lib/components/TextInput/PasswordInput.js +4 -4
  273. package/lib/components/TextInput/TextInput.js +3 -3
  274. package/lib/components/Theme/index.js +3 -3
  275. package/lib/components/Tile/Tile.js +3 -3
  276. package/lib/components/TimePicker/TimePicker.js +1 -1
  277. package/lib/components/Toggletip/index.js +4 -4
  278. package/lib/components/Tooltip/DefinitionTooltip.js +1 -1
  279. package/lib/components/Tooltip/Tooltip.js +3 -3
  280. package/lib/components/TreeView/TreeNode.js +6 -6
  281. package/lib/components/TreeView/TreeView.js +5 -5
  282. package/lib/components/UIShell/HeaderContainer.js +1 -1
  283. package/lib/components/UIShell/HeaderMenu.js +1 -1
  284. package/lib/components/UIShell/Link.js +2 -2
  285. package/lib/components/UIShell/SideNavItems.js +1 -1
  286. package/lib/components/UIShell/Switcher.js +1 -1
  287. package/lib/components/UIShell/SwitcherItem.js +1 -1
  288. package/lib/index.d.ts +1 -1
  289. package/lib/internal/FloatingMenu.js +4 -4
  290. package/lib/internal/Selection.js +6 -6
  291. package/lib/internal/useMergedRefs.js +1 -1
  292. package/lib/internal/useNoInteractiveChildren.js +4 -4
  293. package/lib/internal/useOutsideClick.js +1 -1
  294. package/lib/internal/useOverflowItems.js +6 -6
  295. package/lib/internal/useResizeObserver.js +3 -3
  296. package/lib/internal/useSavedCallback.js +1 -1
  297. package/lib/internal/warning.js +1 -1
  298. package/lib/prop-types/isRequiredOneOf.js +2 -2
  299. package/lib/tools/events.js +1 -1
  300. package/lib/tools/wrapComponent.js +1 -1
  301. package/lib/types/common.d.ts +6 -2
  302. package/package.json +9 -9
@@ -11,12 +11,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
13
  var React = require('react');
14
+ var useResizeObserver = require('../../internal/useResizeObserver.js');
14
15
  var reactIs = require('react-is');
15
16
  var PropTypes = require('prop-types');
16
17
  var index = require('../Layer/index.js');
17
18
  var ModalHeader = require('./ModalHeader.js');
18
19
  var ModalFooter = require('./ModalFooter.js');
19
- var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
20
20
  var mergeRefs = require('../../tools/mergeRefs.js');
21
21
  var cx = require('classnames');
22
22
  var toggleClass = require('../../tools/toggleClass.js');
@@ -36,7 +36,6 @@ var react = require('@floating-ui/react');
36
36
  var ComposedModalPresence = require('./ComposedModalPresence.js');
37
37
  var useId = require('../../internal/useId.js');
38
38
  var useComposedModalState = require('./useComposedModalState.js');
39
- var debounce = require('../../node_modules/es-toolkit/dist/compat/function/debounce.js');
40
39
 
41
40
  const ModalBody = /*#__PURE__*/React.forwardRef(function ModalBody({
42
41
  className: customClassName,
@@ -47,28 +46,23 @@ const ModalBody = /*#__PURE__*/React.forwardRef(function ModalBody({
47
46
  }, ref) {
48
47
  const prefix = usePrefix.usePrefix();
49
48
  const contentRef = React.useRef(null);
50
- const [isScrollable, setIsScrollable] = React.useState(false);
49
+ const {
50
+ height
51
+ } = useResizeObserver.useResizeObserver({
52
+ ref: contentRef
53
+ });
54
+
55
+ /**
56
+ * isScrollable is implicitly dependent on height, when height gets updated
57
+ * via `useResizeObserver`, clientHeight and scrollHeight get updated too
58
+ */
59
+ const isScrollable = !!contentRef.current && contentRef?.current?.scrollHeight > contentRef?.current?.clientHeight;
51
60
  const contentClass = cx({
52
61
  [`${prefix}--modal-content`]: true,
53
62
  [`${prefix}--modal-content--with-form`]: hasForm,
54
- [`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable
63
+ [`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable,
64
+ [`${prefix}--modal-scroll-content--no-fade`]: height <= 300
55
65
  }, customClassName);
56
- useIsomorphicEffect.default(() => {
57
- if (contentRef.current) {
58
- setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
59
- }
60
- function handler() {
61
- if (contentRef.current) {
62
- setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
63
- }
64
- }
65
- const debouncedHandler = debounce.debounce(handler, 200);
66
- window.addEventListener('resize', debouncedHandler);
67
- return () => {
68
- debouncedHandler.cancel();
69
- window.removeEventListener('resize', debouncedHandler);
70
- };
71
- }, []);
72
66
  const hasScrollingContentProps = hasScrollingContent || isScrollable ? {
73
67
  tabIndex: 0,
74
68
  role: 'region'
@@ -173,7 +167,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
173
167
  if (!enableDialogElement) {
174
168
  toggleClass.toggleClass(document.body, `${prefix}--body--with-modal-open`, !!open);
175
169
  }
176
- // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
170
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
177
171
  }, [open, prefix]);
178
172
  // Remove the document.body className on unmount
179
173
  React.useEffect(() => {
@@ -247,17 +241,9 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
247
241
  if (!modalContent || !modalContent.classList.contains(`${prefix}--modal-scroll-content`) || !currentActiveNode || !modalContent.contains(currentActiveNode)) {
248
242
  return;
249
243
  }
250
- const lastContent = modalContent.children[modalContent.children.length - 1];
251
- const gradientSpacing = modalContent.scrollHeight - lastContent.offsetTop - lastContent.clientHeight;
252
- for (const elem of modalContent.children) {
253
- if (elem.contains(currentActiveNode)) {
254
- const spaceBelow = modalContent.clientHeight - elem.offsetTop + modalContent.scrollTop - elem.clientHeight;
255
- if (spaceBelow < gradientSpacing) {
256
- modalContent.scrollTop = modalContent.scrollTop + (gradientSpacing - spaceBelow);
257
- }
258
- break;
259
- }
260
- }
244
+ currentActiveNode.scrollIntoView({
245
+ block: 'center'
246
+ });
261
247
  }
262
248
  function closeModal(evt) {
263
249
  if (!onClose || onClose(evt) !== false) {
@@ -317,7 +303,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
317
303
  return () => {
318
304
  document.removeEventListener('keydown', handleEscapeKey, true);
319
305
  };
320
- // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
306
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
321
307
  }, [open]);
322
308
  React.useEffect(() => {
323
309
  if (!enableDialogElement && !enablePresence && !open && launcherButtonRef) {
@@ -360,7 +346,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
360
346
  focusButton(innerModal.current);
361
347
  }
362
348
  }
363
- // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
349
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
364
350
  }, [open, selectorPrimaryFocus, isOpen]);
365
351
 
366
352
  // AILabel is always size `sm`
@@ -368,7 +354,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
368
354
  const candidateIsAILabel = utils.isComponentElement(candidate, index$2.AILabel);
369
355
  const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
370
356
  size: 'sm'
371
- }) : null;
357
+ }) : candidate;
372
358
  const modalBody = enableDialogElement ? /*#__PURE__*/React.createElement(Dialog.Dialog, {
373
359
  open: open,
374
360
  focusAfterCloseRef: launcherButtonRef,
@@ -8,21 +8,21 @@ import PropTypes from 'prop-types';
8
8
  import React, { type ChangeEvent, type MouseEvent, type ReactElement, type ReactNode } from 'react';
9
9
  import { type SortRowFn } from './state/sorting';
10
10
  import type { DataTableSortState } from './state/sortStates';
11
- import { TranslateWithId } from '../../types/common';
12
- declare const translationKeys: {
13
- readonly expandRow: "carbon.table.row.expand";
14
- readonly collapseRow: "carbon.table.row.collapse";
15
- readonly expandAll: "carbon.table.all.expand";
16
- readonly collapseAll: "carbon.table.all.collapse";
17
- readonly selectAll: "carbon.table.all.select";
18
- readonly unselectAll: "carbon.table.all.unselect";
19
- readonly selectRow: "carbon.table.row.select";
20
- readonly unselectRow: "carbon.table.row.unselect";
11
+ import type { TranslateWithId } from '../../types/common';
12
+ declare const translationIds: {
13
+ readonly 'carbon.table.row.expand': "carbon.table.row.expand";
14
+ readonly 'carbon.table.row.collapse': "carbon.table.row.collapse";
15
+ readonly 'carbon.table.all.expand': "carbon.table.all.expand";
16
+ readonly 'carbon.table.all.collapse': "carbon.table.all.collapse";
17
+ readonly 'carbon.table.all.select': "carbon.table.all.select";
18
+ readonly 'carbon.table.all.unselect': "carbon.table.all.unselect";
19
+ readonly 'carbon.table.row.select': "carbon.table.row.select";
20
+ readonly 'carbon.table.row.unselect': "carbon.table.row.unselect";
21
21
  };
22
22
  /**
23
23
  * Message IDs that will be passed to translateWithId().
24
24
  */
25
- type TranslationKey = (typeof translationKeys)[keyof typeof translationKeys];
25
+ type TranslationKey = keyof typeof translationIds;
26
26
  export type DataTableSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
27
27
  export interface DataTableCell<T> {
28
28
  id: string;
@@ -233,7 +233,6 @@ export interface DataTableProps<RowType, ColTypes extends any[]> extends Transla
233
233
  */
234
234
  export declare const DataTable: {
235
235
  <RowType, ColTypes extends any[]>(props: DataTableProps<RowType, ColTypes>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
236
- translationKeys: ("carbon.table.row.expand" | "carbon.table.row.collapse" | "carbon.table.all.expand" | "carbon.table.all.collapse" | "carbon.table.all.select" | "carbon.table.all.unselect" | "carbon.table.row.select" | "carbon.table.row.unselect")[];
237
236
  Table: {
238
237
  ({ className, children, useZebraStyles, size, isSortable, useStaticWidth, stickyHeader, overflowMenuOnHover, experimentalAutoAlign, tabIndex, ...other }: React.PropsWithChildren<import("./Table").TableProps>): import("react/jsx-runtime").JSX.Element;
239
238
  propTypes: {
@@ -258,7 +257,19 @@ export declare const DataTable: {
258
257
  renderIcon: PropTypes.Requireable<object>;
259
258
  };
260
259
  };
261
- TableBatchActions: import("./TableBatchActions").TableBatchActionsComponent;
260
+ TableBatchActions: {
261
+ ({ className, children, shouldShowBatchActions, totalSelected, totalCount, onCancel, onSelectAll, translateWithId: t, ...rest }: import("./TableBatchActions").TableBatchActionsProps): import("react/jsx-runtime").JSX.Element;
262
+ propTypes: {
263
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
264
+ className: PropTypes.Requireable<string>;
265
+ onCancel: PropTypes.Validator<(...args: any[]) => any>;
266
+ onSelectAll: PropTypes.Requireable<(...args: any[]) => any>;
267
+ shouldShowBatchActions: PropTypes.Requireable<boolean>;
268
+ totalCount: PropTypes.Requireable<number>;
269
+ totalSelected: PropTypes.Validator<number>;
270
+ translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
271
+ };
272
+ };
262
273
  TableBody: {
263
274
  ({ children, className, ...rest }: import("./TableBody").TableBodyProps): import("react/jsx-runtime").JSX.Element;
264
275
  propTypes: {
@@ -454,9 +465,7 @@ export declare const DataTable: {
454
465
  */
455
466
  stickyHeader: PropTypes.Requireable<boolean>;
456
467
  /**
457
- * Optional method that takes in a message ID and returns an
458
- * internationalized string. See `DataTable.translationKeys` for all
459
- * available message IDs.
468
+ * Translates component strings using your i18n tool.
460
469
  */
461
470
  translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
462
471
  /**
@@ -42,15 +42,15 @@ var TableToolbarMenu = require('./TableToolbarMenu.js');
42
42
  var deprecate = require('../../prop-types/deprecate.js');
43
43
 
44
44
  const getInstanceId = setupGetInstanceId.setupGetInstanceId();
45
- const translationKeys = {
46
- expandRow: 'carbon.table.row.expand',
47
- collapseRow: 'carbon.table.row.collapse',
48
- expandAll: 'carbon.table.all.expand',
49
- collapseAll: 'carbon.table.all.collapse',
50
- selectAll: 'carbon.table.all.select',
51
- unselectAll: 'carbon.table.all.unselect',
52
- selectRow: 'carbon.table.row.select',
53
- unselectRow: 'carbon.table.row.unselect'
45
+ const translationIds = {
46
+ 'carbon.table.row.expand': 'carbon.table.row.expand',
47
+ 'carbon.table.row.collapse': 'carbon.table.row.collapse',
48
+ 'carbon.table.all.expand': 'carbon.table.all.expand',
49
+ 'carbon.table.all.collapse': 'carbon.table.all.collapse',
50
+ 'carbon.table.all.select': 'carbon.table.all.select',
51
+ 'carbon.table.all.unselect': 'carbon.table.all.unselect',
52
+ 'carbon.table.row.select': 'carbon.table.row.select',
53
+ 'carbon.table.row.unselect': 'carbon.table.row.unselect'
54
54
  };
55
55
 
56
56
  /**
@@ -58,26 +58,28 @@ const translationKeys = {
58
58
  */
59
59
 
60
60
  const defaultTranslations = {
61
- [translationKeys.expandAll]: 'Expand all rows',
62
- [translationKeys.collapseAll]: 'Collapse all rows',
63
- [translationKeys.expandRow]: 'Expand current row',
64
- [translationKeys.collapseRow]: 'Collapse current row',
65
- [translationKeys.selectAll]: 'Select all rows',
66
- [translationKeys.unselectAll]: 'Unselect all rows',
67
- [translationKeys.selectRow]: 'Select row',
68
- [translationKeys.unselectRow]: 'Unselect row'
61
+ [translationIds['carbon.table.all.expand']]: 'Expand all rows',
62
+ [translationIds['carbon.table.all.collapse']]: 'Collapse all rows',
63
+ [translationIds['carbon.table.row.expand']]: 'Expand current row',
64
+ [translationIds['carbon.table.row.collapse']]: 'Collapse current row',
65
+ [translationIds['carbon.table.all.select']]: 'Select all rows',
66
+ [translationIds['carbon.table.all.unselect']]: 'Unselect all rows',
67
+ [translationIds['carbon.table.row.select']]: 'Select row',
68
+ [translationIds['carbon.table.row.unselect']]: 'Unselect row'
69
+ };
70
+ const defaultTranslateWithId = messageId => {
71
+ return defaultTranslations[messageId];
69
72
  };
70
- const translateWithId = id => defaultTranslations[id];
71
73
 
72
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
74
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
73
75
 
74
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
76
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
75
77
 
76
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
77
79
 
78
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
79
81
 
80
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
82
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
81
83
 
82
84
  /**
83
85
  * DataTable components are used to represent a collection of resources,
@@ -87,14 +89,14 @@ const translateWithId = id => defaultTranslations[id];
87
89
  * the DataTable is accessible through look-up by ID, and updating the state of
88
90
  * a single entity cascades updates to the consumer.
89
91
  */
90
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
92
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
91
93
  const DataTable = props => {
92
94
  const {
93
95
  children,
94
96
  filterRows = filter.defaultFilterRows,
95
97
  headers,
96
98
  render,
97
- translateWithId: t = translateWithId,
99
+ translateWithId: t = defaultTranslateWithId,
98
100
  size,
99
101
  isSortable: isSortableProp,
100
102
  useZebraStyles,
@@ -130,7 +132,7 @@ const DataTable = props => {
130
132
  if (hasRowIdsChanged || hasHeadersChanged || hasRowsChanged) {
131
133
  setState(prev => getDerivedStateFromProps.default(props, prev));
132
134
  }
133
- // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
135
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
134
136
  }, [headers, rows]);
135
137
  const getHeaderProps = ({
136
138
  header,
@@ -183,7 +185,7 @@ const DataTable = props => {
183
185
  rowsById
184
186
  } = state;
185
187
  const isExpanded = isExpandedAll || rowIds.every(id => rowsById[id].isExpanded);
186
- const translationKey = isExpanded ? translationKeys.collapseAll : translationKeys.expandAll;
188
+ const translationKey = isExpanded ? translationIds['carbon.table.all.collapse'] : translationIds['carbon.table.all.expand'];
187
189
  const handlers = [handleOnExpandAll, onExpand];
188
190
  if (onClick) {
189
191
  handlers.push(handleOnExpandHeaderClick(onClick, {
@@ -218,7 +220,7 @@ const DataTable = props => {
218
220
  onClick,
219
221
  ...rest
220
222
  }) => {
221
- const translationKey = row.isExpanded ? translationKeys.collapseRow : translationKeys.expandRow;
223
+ const translationKey = row.isExpanded ? translationIds['carbon.table.row.collapse'] : translationIds['carbon.table.row.expand'];
222
224
  return {
223
225
  ...rest,
224
226
  key: row.id,
@@ -253,7 +255,7 @@ const DataTable = props => {
253
255
  } = {}) => {
254
256
  // If we're given a row, return the selection state values for that row
255
257
  if (row) {
256
- const translationKey = row.isSelected ? translationKeys.unselectRow : translationKeys.selectRow;
258
+ const translationKey = row.isSelected ? translationIds['carbon.table.row.unselect'] : translationIds['carbon.table.row.select'];
257
259
  return {
258
260
  ...rest,
259
261
  checked: row.isSelected,
@@ -272,7 +274,7 @@ const DataTable = props => {
272
274
  const selectedRowCount = selectedRows.length;
273
275
  const checked = rowCount > 0 && selectedRowCount === rowCount;
274
276
  const indeterminate = rowCount > 0 && selectedRowCount > 0 && selectedRowCount !== rowCount;
275
- const translationKey = checked || indeterminate ? translationKeys.unselectAll : translationKeys.selectAll;
277
+ const translationKey = checked || indeterminate ? translationIds['carbon.table.all.unselect'] : translationIds['carbon.table.all.select'];
276
278
  return {
277
279
  ...rest,
278
280
  'aria-label': t(translationKey),
@@ -554,7 +556,6 @@ const DataTable = props => {
554
556
  }
555
557
  return null;
556
558
  };
557
- DataTable.translationKeys = Object.values(translationKeys);
558
559
  DataTable.Table = Table.Table;
559
560
  DataTable.TableActionList = TableActionList.default;
560
561
  DataTable.TableBatchAction = TableBatchAction.default;
@@ -650,9 +651,7 @@ DataTable.propTypes = {
650
651
  */
651
652
  stickyHeader: PropTypes.bool,
652
653
  /**
653
- * Optional method that takes in a message ID and returns an
654
- * internationalized string. See `DataTable.translationKeys` for all
655
- * available message IDs.
654
+ * Translates component strings using your i18n tool.
656
655
  */
657
656
  translateWithId: PropTypes.func,
658
657
  /**
@@ -76,11 +76,11 @@ const Table = ({
76
76
  [`${prefix}--data-table--visible-overflow-menu`]: !overflowMenuOnHover
77
77
  });
78
78
  const toggleTableBodyAlignmentClass = React.useCallback((alignTop = false) => {
79
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20071
79
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20452
80
80
  alignTop ? tableRef.current?.classList.add(`${prefix}--data-table--top-aligned-body`) : tableRef.current?.classList.remove(`${prefix}--data-table--top-aligned-body`);
81
81
  }, [prefix]);
82
82
  const toggleTableHeaderAlignmentClass = React.useCallback((alignTop = false) => {
83
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20071
83
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20452
84
84
  alignTop ? tableRef.current?.classList.add(`${prefix}--data-table--top-aligned-header`) : tableRef.current?.classList.remove(`${prefix}--data-table--top-aligned-header`);
85
85
  }, [prefix]);
86
86
  const setTableAlignment = React.useCallback(() => {
@@ -1,18 +1,24 @@
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 PropTypes from 'prop-types';
7
8
  import React, { type MouseEventHandler } from 'react';
8
9
  import type { TranslateWithId } from '../../types/common';
9
- declare const TableBatchActionsTranslationKeys: readonly ["carbon.table.batch.cancel", "carbon.table.batch.items.selected", "carbon.table.batch.item.selected", "carbon.table.batch.selectAll"];
10
- export type TableBatchActionsTranslationKey = (typeof TableBatchActionsTranslationKeys)[number];
11
- export interface TableBatchActionsTranslationArgs {
10
+ declare const translationIds: {
11
+ readonly 'carbon.table.batch.cancel': "carbon.table.batch.cancel";
12
+ readonly 'carbon.table.batch.items.selected': "carbon.table.batch.items.selected";
13
+ readonly 'carbon.table.batch.item.selected': "carbon.table.batch.item.selected";
14
+ readonly 'carbon.table.batch.selectAll': "carbon.table.batch.selectAll";
15
+ };
16
+ type TranslationKey = keyof typeof translationIds;
17
+ export type TableBatchActionsTranslationArgs = {
12
18
  totalSelected?: number;
13
19
  totalCount?: number;
14
- }
15
- export interface TableBatchActionsProps extends React.HTMLAttributes<HTMLDivElement>, TranslateWithId<TableBatchActionsTranslationKey, TableBatchActionsTranslationArgs> {
20
+ };
21
+ export interface TableBatchActionsProps extends React.HTMLAttributes<HTMLDivElement>, TranslateWithId<TranslationKey, TableBatchActionsTranslationArgs> {
16
22
  /**
17
23
  * Provide elements to be rendered inside of the component.
18
24
  */
@@ -44,8 +50,41 @@ export interface TableBatchActionsProps extends React.HTMLAttributes<HTMLDivElem
44
50
  */
45
51
  totalCount?: number;
46
52
  }
47
- export interface TableBatchActionsComponent extends React.FC<TableBatchActionsProps> {
48
- translationKeys: ReadonlyArray<TableBatchActionsTranslationKey>;
49
- }
50
- declare const TableBatchActions: TableBatchActionsComponent;
53
+ declare const TableBatchActions: {
54
+ ({ className, children, shouldShowBatchActions, totalSelected, totalCount, onCancel, onSelectAll, translateWithId: t, ...rest }: TableBatchActionsProps): import("react/jsx-runtime").JSX.Element;
55
+ propTypes: {
56
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
57
+ className: PropTypes.Requireable<string>;
58
+ /**
59
+ * Hook required to listen for when the user initiates a cancel request
60
+ * through this component
61
+ */
62
+ onCancel: PropTypes.Validator<(...args: any[]) => any>;
63
+ /**
64
+ * Hook to listen for when the user initiates a select all
65
+ * request through this component. This _only_ controls the rendering
66
+ * of the `Select All` button and does not include built in functionality
67
+ */
68
+ onSelectAll: PropTypes.Requireable<(...args: any[]) => any>;
69
+ /**
70
+ * Boolean specifier for whether or not the batch action bar should be
71
+ * displayed
72
+ */
73
+ shouldShowBatchActions: PropTypes.Requireable<boolean>;
74
+ /**
75
+ * Numeric representation of the total number of items in a table.
76
+ * This number is used in the select all button text
77
+ */
78
+ totalCount: PropTypes.Requireable<number>;
79
+ /**
80
+ * Numeric representation of the total number of items selected in a table.
81
+ * This number is used to derive the selection message
82
+ */
83
+ totalSelected: PropTypes.Validator<number>;
84
+ /**
85
+ * Translates component strings using your i18n tool.
86
+ */
87
+ translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
88
+ };
89
+ };
51
90
  export default TableBatchActions;
@@ -20,27 +20,35 @@ var Text = require('../Text/Text.js');
20
20
  require('../Text/TextDirection.js');
21
21
  var usePrefix = require('../../internal/usePrefix.js');
22
22
 
23
- const TableBatchActionsTranslationKeys = ['carbon.table.batch.cancel', 'carbon.table.batch.items.selected', 'carbon.table.batch.item.selected', 'carbon.table.batch.selectAll'];
24
- const translationKeys = {
25
- 'carbon.table.batch.cancel': 'Cancel',
26
- 'carbon.table.batch.items.selected': 'items selected',
27
- 'carbon.table.batch.item.selected': 'item selected',
28
- 'carbon.table.batch.selectAll': 'Select all'
23
+ const translationIds = {
24
+ 'carbon.table.batch.cancel': 'carbon.table.batch.cancel',
25
+ 'carbon.table.batch.items.selected': 'carbon.table.batch.items.selected',
26
+ 'carbon.table.batch.item.selected': 'carbon.table.batch.item.selected',
27
+ 'carbon.table.batch.selectAll': 'carbon.table.batch.selectAll'
29
28
  };
30
- const translateWithId = (id, {
31
- totalSelected,
32
- totalCount
33
- } = {
29
+ const defaultTranslations = {
30
+ [translationIds['carbon.table.batch.cancel']]: 'Cancel',
31
+ [translationIds['carbon.table.batch.items.selected']]: 'items selected',
32
+ [translationIds['carbon.table.batch.item.selected']]: 'item selected',
33
+ [translationIds['carbon.table.batch.selectAll']]: 'Select all'
34
+ };
35
+ const defaultTranslateWithId = (messageId, args = {
34
36
  totalSelected: 0,
35
37
  totalCount: 0
36
38
  }) => {
37
- if (id === 'carbon.table.batch.cancel') {
38
- return translationKeys[id];
39
- }
40
- if (id === 'carbon.table.batch.selectAll') {
41
- return `${translationKeys[id]} (${totalCount})`;
39
+ const {
40
+ totalSelected,
41
+ totalCount
42
+ } = args;
43
+ switch (messageId) {
44
+ case translationIds['carbon.table.batch.cancel']:
45
+ return defaultTranslations[messageId];
46
+ case translationIds['carbon.table.batch.selectAll']:
47
+ return `${defaultTranslations[messageId]} (${totalCount})`;
48
+ case translationIds['carbon.table.batch.items.selected']:
49
+ case translationIds['carbon.table.batch.item.selected']:
50
+ return `${totalSelected} ${defaultTranslations[messageId]}`;
42
51
  }
43
- return `${totalSelected} ${translationKeys[id]}`;
44
52
  };
45
53
  const TableBatchActions = ({
46
54
  className,
@@ -50,7 +58,7 @@ const TableBatchActions = ({
50
58
  totalCount,
51
59
  onCancel,
52
60
  onSelectAll,
53
- translateWithId: t = translateWithId,
61
+ translateWithId: t = defaultTranslateWithId,
54
62
  ...rest
55
63
  }) => {
56
64
  const [isScrolling, setIsScrolling] = React.useState(false);
@@ -89,7 +97,6 @@ const TableBatchActions = ({
89
97
  onClick: onCancel
90
98
  }, t('carbon.table.batch.cancel'))));
91
99
  };
92
- TableBatchActions.translationKeys = TableBatchActionsTranslationKeys;
93
100
  TableBatchActions.propTypes = {
94
101
  children: PropTypes.node,
95
102
  className: PropTypes.string,
@@ -120,9 +127,7 @@ TableBatchActions.propTypes = {
120
127
  */
121
128
  totalSelected: PropTypes.number.isRequired,
122
129
  /**
123
- * Supply a method to translate internal strings with your i18n tool of
124
- * choice. Translation keys are available on the `translationKeys` field for
125
- * this component.
130
+ * Translates component strings using your i18n tool.
126
131
  */
127
132
  translateWithId: PropTypes.func
128
133
  };
@@ -96,9 +96,9 @@ TableExpandHeader.propTypes = {
96
96
  * Hook for when a listener initiates a request to expand the given row
97
97
  */
98
98
  onExpand: PropTypes.oneOfType([requiredIfGivenPropIsTruthy.requiredIfGivenPropIsTruthy('enableExpando', PropTypes.func
99
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
99
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
100
100
  ), requiredIfGivenPropIsTruthy.requiredIfGivenPropIsTruthy('enableToggle', PropTypes.func
101
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
101
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
102
102
  )])
103
103
  };
104
104
 
@@ -96,7 +96,7 @@ TableExpandRow.propTypes = {
96
96
  * Specify the string read by a voice reader when the expand trigger is
97
97
  * focused
98
98
  */
99
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20071
99
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20452
100
100
  /**@ts-ignore*/
101
101
  'aria-label': PropTypes.string,
102
102
  /**
@@ -5,21 +5,19 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React, { type HTMLAttributes, type MouseEventHandler, type ReactNode } from 'react';
8
- import { TranslateWithId } from '../../types/common';
8
+ import type { TranslateWithId } from '../../types/common';
9
9
  import { sortStates, type DataTableSortState } from './state/sortStates';
10
- export type TableHeaderTranslationKey = 'carbon.table.header.icon.description';
11
- export interface TableHeaderTranslationArgs {
10
+ declare const translationIds: {
11
+ readonly 'carbon.table.header.icon.description': "carbon.table.header.icon.description";
12
+ };
13
+ type TranslationKey = keyof typeof translationIds;
14
+ interface TableHeaderTranslationArgs {
12
15
  header: ReactNode;
13
16
  isSortHeader?: boolean;
14
17
  sortDirection?: DataTableSortState;
15
18
  sortStates: typeof sortStates;
16
19
  }
17
- export interface TableHeaderProps extends HTMLAttributes<HTMLTableCellElement & HTMLButtonElement>, TranslateWithId<TableHeaderTranslationKey, {
18
- header: any;
19
- sortDirection: any;
20
- isSortHeader: any;
21
- sortStates: any;
22
- }> {
20
+ export interface TableHeaderProps extends HTMLAttributes<HTMLTableCellElement & HTMLButtonElement>, TranslateWithId<TranslationKey, TableHeaderTranslationArgs> {
23
21
  /**
24
22
  * Pass in children that will be embedded in the table header label
25
23
  */
@@ -69,7 +67,7 @@ export interface TableHeaderProps extends HTMLAttributes<HTMLTableCellElement &
69
67
  * Specify which direction we are currently sorting by, should be one of DESC,
70
68
  * NONE, or ASC.
71
69
  */
72
- sortDirection?: string;
70
+ sortDirection?: DataTableSortState;
73
71
  }
74
72
  declare const TableHeader: React.ForwardRefExoticComponent<TableHeaderProps & React.RefAttributes<HTMLTableCellElement>>;
75
73
  export default TableHeader;
@@ -21,11 +21,14 @@ var index = require('../AILabel/index.js');
21
21
  var utils = require('../../internal/utils.js');
22
22
 
23
23
  const defaultScope = 'col';
24
- const translationKeys = {
25
- buttonDescription: 'carbon.table.header.icon.description'
24
+ const translationIds = {
25
+ 'carbon.table.header.icon.description': 'carbon.table.header.icon.description'
26
26
  };
27
- const translateWithId = (key, args) => {
28
- if (args && key === translationKeys.buttonDescription) {
27
+ const defaultTranslations = {
28
+ [translationIds['carbon.table.header.icon.description']]: 'Click to sort rows by header in ascending order'
29
+ };
30
+ const defaultTranslateWithId = (messageId, args) => {
31
+ if (args && messageId === translationIds['carbon.table.header.icon.description']) {
29
32
  if (args.isSortHeader && sortStates.sortStates) {
30
33
  // When transitioning, we know that the sequence of states is as follows:
31
34
  // NONE -> ASC -> DESC -> NONE
@@ -39,7 +42,7 @@ const translateWithId = (key, args) => {
39
42
  }
40
43
  return `Click to sort rows by ${args.header} header in ascending order`;
41
44
  }
42
- return '';
45
+ return defaultTranslations[messageId];
43
46
  };
44
47
  const sortDirections = {
45
48
  [sortStates.sortStates.NONE]: 'none',
@@ -56,7 +59,7 @@ const TableHeader = /*#__PURE__*/React.forwardRef(function TableHeader({
56
59
  onClick,
57
60
  scope = defaultScope,
58
61
  sortDirection,
59
- translateWithId: t = translateWithId,
62
+ translateWithId: t = defaultTranslateWithId,
60
63
  slug,
61
64
  id,
62
65
  ...rest
@@ -72,7 +75,7 @@ const TableHeader = /*#__PURE__*/React.forwardRef(function TableHeader({
72
75
  const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
73
76
  size: 'mini',
74
77
  ref: AILableRef
75
- }) : null;
78
+ }) : candidate;
76
79
  const headerLabelClassNames = cx({
77
80
  [`${prefix}--table-header-label`]: true,
78
81
  [`${prefix}--table-header-label--slug ${prefix}--table-header-label--ai-label`]: colHasAILabel,
@@ -186,15 +189,10 @@ TableHeader.propTypes = {
186
189
  */
187
190
  sortDirection: PropTypes.oneOf(Object.values(sortStates.sortStates)),
188
191
  /**
189
- * Supply a method to translate internal strings with your i18n tool of
190
- * choice. Translation keys are available on the `translationKeys` field for
191
- * this component.
192
+ * Translates component strings using your i18n tool.
192
193
  */
193
194
  translateWithId: PropTypes.func
194
195
  };
195
-
196
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
197
- TableHeader.translationKeys = Object.values(translationKeys);
198
196
  TableHeader.displayName = 'TableHeader';
199
197
 
200
198
  exports.default = TableHeader;