@carbon/react 1.81.0 → 1.82.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +892 -892
  2. package/es/components/AILabel/index.d.ts +1 -1
  3. package/es/components/AILabel/index.js +2 -9
  4. package/es/components/Breadcrumb/Breadcrumb.d.ts +2 -3
  5. package/es/components/Breadcrumb/Breadcrumb.js +4 -4
  6. package/es/components/Breadcrumb/BreadcrumbItem.d.ts +3 -4
  7. package/es/components/Breadcrumb/BreadcrumbItem.js +5 -4
  8. package/es/components/Button/Button.js +2 -10
  9. package/es/components/ButtonSet/ButtonSet.d.ts +2 -3
  10. package/es/components/ButtonSet/ButtonSet.js +4 -4
  11. package/es/components/CodeSnippet/CodeSnippet.d.ts +1 -1
  12. package/es/components/CodeSnippet/CodeSnippet.js +3 -19
  13. package/es/components/ComboBox/ComboBox.d.ts +1 -1
  14. package/es/components/ComboBox/ComboBox.js +2 -2
  15. package/es/components/ComboButton/index.d.ts +1 -1
  16. package/es/components/ComboButton/index.js +2 -18
  17. package/es/components/ComposedModal/ComposedModal.js +5 -3
  18. package/es/components/Copy/Copy.d.ts +1 -1
  19. package/es/components/Copy/Copy.js +2 -18
  20. package/es/components/CopyButton/CopyButton.d.ts +1 -1
  21. package/es/components/CopyButton/CopyButton.js +2 -18
  22. package/es/components/DataTable/DataTable.d.ts +7 -12
  23. package/es/components/DataTable/DataTable.js +0 -5
  24. package/es/components/DataTable/TableToolbarAction.d.ts +2 -4
  25. package/es/components/DataTable/TableToolbarAction.js +5 -4
  26. package/es/components/DataTable/tools/sorting.d.ts +42 -0
  27. package/es/components/DataTable/tools/sorting.js +24 -53
  28. package/es/components/DatePicker/DatePicker.d.ts +1 -1
  29. package/es/components/DatePicker/DatePicker.js +18 -18
  30. package/es/components/Dialog/index.d.ts +1 -1
  31. package/es/components/Dropdown/Dropdown.Skeleton.d.ts +2 -2
  32. package/es/components/Dropdown/Dropdown.Skeleton.js +2 -2
  33. package/es/components/Dropdown/Dropdown.d.ts +7 -6
  34. package/es/components/Dropdown/Dropdown.js +7 -3
  35. package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
  36. package/es/components/FileUploader/FileUploaderButton.js +1 -1
  37. package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
  38. package/es/components/FileUploader/FileUploaderItem.js +1 -1
  39. package/es/components/FluidDropdown/FluidDropdown.d.ts +1 -1
  40. package/es/components/FluidSearch/FluidSearch.d.ts +3 -6
  41. package/es/components/IconButton/index.d.ts +1 -1
  42. package/es/components/IconButton/index.js +2 -18
  43. package/es/components/ListBox/ListBox.d.ts +4 -5
  44. package/es/components/ListBox/ListBox.js +8 -7
  45. package/es/components/ListBox/ListBoxMenu.d.ts +4 -4
  46. package/es/components/ListBox/ListBoxMenu.js +4 -2
  47. package/es/components/ListBox/ListBoxMenuItem.d.ts +9 -8
  48. package/es/components/ListBox/ListBoxPropTypes.d.ts +3 -3
  49. package/es/components/ListBox/ListBoxPropTypes.js +3 -3
  50. package/es/components/ListBox/index.d.ts +7 -5
  51. package/es/components/ListBox/index.js +1 -1
  52. package/es/components/Menu/Menu.js +5 -0
  53. package/es/components/Modal/Modal.js +9 -9
  54. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +3 -2
  55. package/es/components/MultiSelect/FilterableMultiSelect.js +3 -2
  56. package/es/components/MultiSelect/MultiSelect.d.ts +8 -2
  57. package/es/components/MultiSelect/MultiSelect.js +3 -3
  58. package/es/components/Notification/Notification.js +1 -1
  59. package/es/components/OverflowMenu/OverflowMenu.js +2 -21
  60. package/es/components/OverflowMenu/next/index.js +2 -18
  61. package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +2 -4
  62. package/es/components/OverflowMenuItem/OverflowMenuItem.js +5 -4
  63. package/es/components/PageHeader/PageHeader.d.ts +153 -8
  64. package/es/components/PageHeader/PageHeader.js +143 -21
  65. package/es/components/PageHeader/index.d.ts +2 -2
  66. package/es/components/PageHeader/index.js +1 -1
  67. package/es/components/Popover/index.js +4 -21
  68. package/es/components/Search/Search.d.ts +2 -5
  69. package/es/components/Search/Search.js +24 -8
  70. package/es/components/Stack/HStack.d.ts +2 -3
  71. package/es/components/Stack/HStack.js +4 -7
  72. package/es/components/Stack/Stack.d.ts +3 -4
  73. package/es/components/Stack/Stack.js +3 -6
  74. package/es/components/Stack/VStack.d.ts +2 -3
  75. package/es/components/Stack/VStack.js +3 -2
  76. package/es/components/Stack/index.d.ts +4 -4
  77. package/es/components/TextArea/TextArea.js +3 -5
  78. package/es/components/TimePicker/TimePicker.d.ts +3 -4
  79. package/es/components/TimePicker/TimePicker.js +5 -4
  80. package/es/components/TimePickerSelect/TimePickerSelect.d.ts +23 -4
  81. package/es/components/TimePickerSelect/TimePickerSelect.js +5 -4
  82. package/es/components/TreeView/TreeNode.js +13 -1
  83. package/es/components/TreeView/TreeView.js +1 -1
  84. package/es/index.js +1 -1
  85. package/es/internal/FloatingMenu.js +9 -5
  86. package/es/internal/environment.js +7 -0
  87. package/es/internal/keyboard/navigation.d.ts +0 -10
  88. package/es/internal/keyboard/navigation.js +1 -13
  89. package/es/internal/useId.js +1 -1
  90. package/es/internal/useNoInteractiveChildren.js +7 -0
  91. package/es/internal/useOutsideClick.js +3 -0
  92. package/es/internal/wrapFocus.d.ts +49 -0
  93. package/es/internal/wrapFocus.js +64 -51
  94. package/es/tools/events.d.ts +17 -0
  95. package/es/tools/events.js +10 -13
  96. package/es/tools/mapPopoverAlign.d.ts +15 -0
  97. package/es/tools/mapPopoverAlign.js +28 -0
  98. package/es/tools/uniqueId.d.ts +7 -0
  99. package/es/tools/uniqueId.js +3 -3
  100. package/es/types/common.d.ts +0 -2
  101. package/lib/components/AILabel/index.d.ts +1 -1
  102. package/lib/components/AILabel/index.js +2 -9
  103. package/lib/components/Breadcrumb/Breadcrumb.d.ts +2 -3
  104. package/lib/components/Breadcrumb/Breadcrumb.js +3 -3
  105. package/lib/components/Breadcrumb/BreadcrumbItem.d.ts +3 -4
  106. package/lib/components/Breadcrumb/BreadcrumbItem.js +4 -3
  107. package/lib/components/Button/Button.js +1 -9
  108. package/lib/components/ButtonSet/ButtonSet.d.ts +2 -3
  109. package/lib/components/ButtonSet/ButtonSet.js +3 -3
  110. package/lib/components/CodeSnippet/CodeSnippet.d.ts +1 -1
  111. package/lib/components/CodeSnippet/CodeSnippet.js +3 -19
  112. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  113. package/lib/components/ComboBox/ComboBox.js +1 -1
  114. package/lib/components/ComboButton/index.d.ts +1 -1
  115. package/lib/components/ComboButton/index.js +2 -18
  116. package/lib/components/ComposedModal/ComposedModal.js +5 -3
  117. package/lib/components/Copy/Copy.d.ts +1 -1
  118. package/lib/components/Copy/Copy.js +2 -18
  119. package/lib/components/CopyButton/CopyButton.d.ts +1 -1
  120. package/lib/components/CopyButton/CopyButton.js +2 -18
  121. package/lib/components/DataTable/DataTable.d.ts +7 -12
  122. package/lib/components/DataTable/DataTable.js +0 -5
  123. package/lib/components/DataTable/TableToolbarAction.d.ts +2 -4
  124. package/lib/components/DataTable/TableToolbarAction.js +4 -3
  125. package/lib/components/DataTable/tools/sorting.d.ts +42 -0
  126. package/lib/components/DataTable/tools/sorting.js +23 -53
  127. package/lib/components/DatePicker/DatePicker.d.ts +1 -1
  128. package/lib/components/DatePicker/DatePicker.js +18 -18
  129. package/lib/components/Dialog/index.d.ts +1 -1
  130. package/lib/components/Dropdown/Dropdown.Skeleton.d.ts +2 -2
  131. package/lib/components/Dropdown/Dropdown.Skeleton.js +1 -1
  132. package/lib/components/Dropdown/Dropdown.d.ts +7 -6
  133. package/lib/components/Dropdown/Dropdown.js +6 -2
  134. package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
  135. package/lib/components/FileUploader/FileUploaderButton.js +1 -1
  136. package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
  137. package/lib/components/FileUploader/FileUploaderItem.js +1 -1
  138. package/lib/components/FluidDropdown/FluidDropdown.d.ts +1 -1
  139. package/lib/components/FluidSearch/FluidSearch.d.ts +3 -6
  140. package/lib/components/IconButton/index.d.ts +1 -1
  141. package/lib/components/IconButton/index.js +2 -18
  142. package/lib/components/ListBox/ListBox.d.ts +4 -5
  143. package/lib/components/ListBox/ListBox.js +7 -6
  144. package/lib/components/ListBox/ListBoxMenu.d.ts +4 -4
  145. package/lib/components/ListBox/ListBoxMenu.js +3 -1
  146. package/lib/components/ListBox/ListBoxMenuItem.d.ts +9 -8
  147. package/lib/components/ListBox/ListBoxPropTypes.d.ts +3 -3
  148. package/lib/components/ListBox/ListBoxPropTypes.js +4 -4
  149. package/lib/components/ListBox/index.d.ts +7 -5
  150. package/lib/components/ListBox/index.js +2 -2
  151. package/lib/components/Menu/Menu.js +5 -0
  152. package/lib/components/Modal/Modal.js +9 -9
  153. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +3 -2
  154. package/lib/components/MultiSelect/FilterableMultiSelect.js +2 -1
  155. package/lib/components/MultiSelect/MultiSelect.d.ts +8 -2
  156. package/lib/components/MultiSelect/MultiSelect.js +2 -2
  157. package/lib/components/Notification/Notification.js +1 -1
  158. package/lib/components/OverflowMenu/OverflowMenu.js +2 -21
  159. package/lib/components/OverflowMenu/next/index.js +2 -18
  160. package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +2 -4
  161. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +4 -3
  162. package/lib/components/PageHeader/PageHeader.d.ts +153 -8
  163. package/lib/components/PageHeader/PageHeader.js +145 -19
  164. package/lib/components/PageHeader/index.d.ts +2 -2
  165. package/lib/components/PageHeader/index.js +4 -0
  166. package/lib/components/Popover/index.js +4 -21
  167. package/lib/components/Search/Search.d.ts +2 -5
  168. package/lib/components/Search/Search.js +24 -8
  169. package/lib/components/Stack/HStack.d.ts +2 -3
  170. package/lib/components/Stack/HStack.js +3 -6
  171. package/lib/components/Stack/Stack.d.ts +3 -4
  172. package/lib/components/Stack/Stack.js +2 -5
  173. package/lib/components/Stack/VStack.d.ts +2 -3
  174. package/lib/components/Stack/VStack.js +2 -1
  175. package/lib/components/Stack/index.d.ts +4 -4
  176. package/lib/components/TextArea/TextArea.js +2 -4
  177. package/lib/components/TimePicker/TimePicker.d.ts +3 -4
  178. package/lib/components/TimePicker/TimePicker.js +4 -3
  179. package/lib/components/TimePickerSelect/TimePickerSelect.d.ts +23 -4
  180. package/lib/components/TimePickerSelect/TimePickerSelect.js +4 -3
  181. package/lib/components/TreeView/TreeNode.js +13 -1
  182. package/lib/components/TreeView/TreeView.js +1 -1
  183. package/lib/index.js +2 -2
  184. package/lib/internal/FloatingMenu.js +9 -5
  185. package/lib/internal/environment.js +7 -0
  186. package/lib/internal/keyboard/navigation.d.ts +0 -10
  187. package/lib/internal/keyboard/navigation.js +0 -14
  188. package/lib/internal/useNoInteractiveChildren.js +7 -0
  189. package/lib/internal/useOutsideClick.js +3 -0
  190. package/lib/internal/wrapFocus.d.ts +49 -0
  191. package/lib/internal/wrapFocus.js +66 -53
  192. package/lib/tools/events.d.ts +17 -0
  193. package/lib/tools/events.js +10 -13
  194. package/lib/tools/mapPopoverAlign.d.ts +15 -0
  195. package/lib/tools/mapPopoverAlign.js +32 -0
  196. package/lib/tools/uniqueId.d.ts +7 -0
  197. package/lib/tools/uniqueId.js +3 -3
  198. package/lib/types/common.d.ts +0 -2
  199. package/package.json +7 -7
  200. package/telemetry.yml +3 -1
  201. package/es/tools/createPropAdapter.js +0 -40
  202. package/lib/tools/createPropAdapter.js +0 -44
@@ -54,7 +54,7 @@ const TreeNode = /*#__PURE__*/React__default["default"].forwardRef((_ref, forwar
54
54
  const enableTreeviewControllable = index.useFeatureFlag('enable-treeview-controllable');
55
55
  const {
56
56
  current: id
57
- } = React.useRef(nodeId || uniqueId["default"]());
57
+ } = React.useRef(nodeId || uniqueId.uniqueId());
58
58
  const controllableExpandedState = useControllableState.useControllableState({
59
59
  value: isExpanded,
60
60
  onChange: newValue => {
@@ -211,6 +211,18 @@ const TreeNode = /*#__PURE__*/React__default["default"].forwardRef((_ref, forwar
211
211
  }
212
212
  if (match.matches(event, [keys.Enter, keys.Space])) {
213
213
  event.preventDefault();
214
+ if (match.match(event, keys.Enter) && children) {
215
+ // Toggle expansion state for parent nodes
216
+ if (!enableTreeviewControllable) {
217
+ onToggle?.(event, {
218
+ id,
219
+ isExpanded: !expanded,
220
+ label,
221
+ value
222
+ });
223
+ }
224
+ setExpanded(!expanded);
225
+ }
214
226
  if (href) {
215
227
  currentNode.current?.click();
216
228
  }
@@ -44,7 +44,7 @@ const TreeView = _ref => {
44
44
  const enableTreeviewControllable = index.useFeatureFlag('enable-treeview-controllable');
45
45
  const {
46
46
  current: treeId
47
- } = React.useRef(rest.id || uniqueId["default"]());
47
+ } = React.useRef(rest.id || uniqueId.uniqueId());
48
48
  const prefix = usePrefix.usePrefix();
49
49
  const treeClasses = cx__default["default"](className, `${prefix}--tree`, {
50
50
  // @ts-ignore - will always be false according to prop types
package/lib/index.js CHANGED
@@ -110,8 +110,8 @@ var SkeletonPlaceholder = require('./components/SkeletonPlaceholder/SkeletonPlac
110
110
  var SkeletonText = require('./components/SkeletonText/SkeletonText.js');
111
111
  var index$d = require('./components/Slider/index.js');
112
112
  var HStack = require('./components/Stack/HStack.js');
113
- var VStack = require('./components/Stack/VStack.js');
114
113
  var Stack = require('./components/Stack/Stack.js');
114
+ var VStack = require('./components/Stack/VStack.js');
115
115
  var StructuredList = require('./components/StructuredList/StructuredList.js');
116
116
  var StructuredList_Skeleton = require('./components/StructuredList/StructuredList.Skeleton.js');
117
117
  var Switch = require('./components/Switch/Switch.js');
@@ -366,8 +366,8 @@ exports.SkeletonPlaceholder = SkeletonPlaceholder["default"];
366
366
  exports.SkeletonText = SkeletonText["default"];
367
367
  exports.Slider = index$d["default"];
368
368
  exports.HStack = HStack.HStack;
369
- exports.VStack = VStack.VStack;
370
369
  exports.Stack = Stack.Stack;
370
+ exports.VStack = VStack.VStack;
371
371
  exports.StructuredListBody = StructuredList.StructuredListBody;
372
372
  exports.StructuredListCell = StructuredList.StructuredListCell;
373
373
  exports.StructuredListHead = StructuredList.StructuredListHead;
@@ -275,13 +275,17 @@ const FloatingMenu = _ref2 => {
275
275
  * Blur handler used when focus trapping is enabled.
276
276
  */
277
277
  const handleBlur = event => {
278
- if (menuBodyRef.current && startSentinelRef.current && endSentinelRef.current) {
279
- wrapFocus["default"]({
278
+ const {
279
+ target,
280
+ relatedTarget
281
+ } = event;
282
+ if (menuBodyRef.current && startSentinelRef.current && endSentinelRef.current && target instanceof HTMLElement && relatedTarget instanceof HTMLElement) {
283
+ wrapFocus.wrapFocus({
280
284
  bodyNode: menuBodyRef.current,
281
285
  startTrapNode: startSentinelRef.current,
282
286
  endTrapNode: endSentinelRef.current,
283
- currentActiveNode: event.relatedTarget,
284
- oldActiveNode: event.target
287
+ currentActiveNode: relatedTarget,
288
+ oldActiveNode: target
285
289
  });
286
290
  }
287
291
  };
@@ -290,7 +294,7 @@ const FloatingMenu = _ref2 => {
290
294
  * Keydown handler for focus wrapping when experimental focus trap is enabled.
291
295
  */
292
296
  const handleKeyDown = event => {
293
- if (match.match(event, keys.Tab) && menuBodyRef.current) {
297
+ if (match.match(event, keys.Tab) && menuBodyRef.current && event.target instanceof HTMLElement) {
294
298
  wrapFocus.wrapFocusWithoutSentinels({
295
299
  containerNode: menuBodyRef.current,
296
300
  currentActiveNode: event.target,
@@ -15,9 +15,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
15
15
  * @see https://github.com/facebook/fbjs/blob/4d1751311d3f67af2dcce2e40df8512a23c7b9c6/packages/fbjs/src/core/ExecutionEnvironment.js#L12
16
16
  */
17
17
  const canUseDOM = !!(typeof window !== 'undefined' &&
18
+ // TODO: `ssr-friendly` doesn't support ESLint v9.
19
+ // https://github.com/kopiro/eslint-plugin-ssr-friendly/issues/30
20
+ // https://github.com/carbon-design-system/carbon/issues/18991
21
+ /*
18
22
  // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
23
+ */
19
24
  window.document &&
25
+ /*
20
26
  // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
27
+ */
21
28
  window.document.createElement);
22
29
 
23
30
  exports.canUseDOM = canUseDOM;
@@ -17,16 +17,6 @@ import { KeyboardEvent } from 'react';
17
17
  * getNextIndex(keyCodes.RIGHT, 0, 4)
18
18
  */
19
19
  export declare const getNextIndex: (key: KeyboardEvent | number | string, index: number, arrayLength: number) => number | undefined;
20
- /**
21
- * A flag `node.compareDocumentPosition(target)` returns that indicates
22
- * `target` is located earlier than `node` in the document or `target` contains `node`.
23
- */
24
- export declare const DOCUMENT_POSITION_BROAD_PRECEDING: number;
25
- /**
26
- * A flag `node.compareDocumentPosition(target)` returns that indicates
27
- * `target` is located later than `node` in the document or `node` contains `target`.
28
- */
29
- export declare const DOCUMENT_POSITION_BROAD_FOLLOWING: number;
30
20
  /**
31
21
  * CSS selector that selects major nodes that are sequentially focusable.
32
22
  */
@@ -33,18 +33,6 @@ const getNextIndex = (key, index, arrayLength) => {
33
33
  return;
34
34
  };
35
35
 
36
- /**
37
- * A flag `node.compareDocumentPosition(target)` returns that indicates
38
- * `target` is located earlier than `node` in the document or `target` contains `node`.
39
- */
40
- const DOCUMENT_POSITION_BROAD_PRECEDING = typeof Node !== 'undefined' ? Node.DOCUMENT_POSITION_PRECEDING | Node.DOCUMENT_POSITION_CONTAINS : 0;
41
-
42
- /**
43
- * A flag `node.compareDocumentPosition(target)` returns that indicates
44
- * `target` is located later than `node` in the document or `node` contains `target`.
45
- */
46
- const DOCUMENT_POSITION_BROAD_FOLLOWING = typeof Node !== 'undefined' ? Node.DOCUMENT_POSITION_FOLLOWING | Node.DOCUMENT_POSITION_CONTAINED_BY : 0;
47
-
48
36
  /**
49
37
  * CSS selector that selects major nodes that are sequentially focusable.
50
38
  */
@@ -65,8 +53,6 @@ const selectorFocusable = `
65
53
  iframe, object, embed, *[tabindex]:not([disabled]), *[contenteditable=true]
66
54
  `;
67
55
 
68
- exports.DOCUMENT_POSITION_BROAD_FOLLOWING = DOCUMENT_POSITION_BROAD_FOLLOWING;
69
- exports.DOCUMENT_POSITION_BROAD_PRECEDING = DOCUMENT_POSITION_BROAD_PRECEDING;
70
56
  exports.getNextIndex = getNextIndex;
71
57
  exports.selectorFocusable = selectorFocusable;
72
58
  exports.selectorTabbable = selectorTabbable;
@@ -14,11 +14,15 @@ var React = require('react');
14
14
  function useNoInteractiveChildren(ref) {
15
15
  let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'component should have no interactive child nodes';
16
16
  if (process.env.NODE_ENV !== 'production') {
17
+ // TODO: https://github.com/carbon-design-system/carbon/issues/19005
18
+ /*
17
19
  // eslint-disable-next-line react-hooks/rules-of-hooks
20
+ */
18
21
  React.useEffect(() => {
19
22
  const node = ref.current ? getInteractiveContent(ref.current) : false;
20
23
  if (node) {
21
24
  const errorMessage = `Error: ${message}.\n\nInstead found: ${node.outerHTML}`;
25
+ // eslint-disable-next-line no-console
22
26
  console.error(errorMessage);
23
27
  throw new Error(errorMessage);
24
28
  }
@@ -28,7 +32,10 @@ function useNoInteractiveChildren(ref) {
28
32
  function useInteractiveChildrenNeedDescription(ref) {
29
33
  let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : `interactive child node(s) should have an \`aria-describedby\` property`;
30
34
  if (process.env.NODE_ENV !== 'production') {
35
+ // TODO: https://github.com/carbon-design-system/carbon/issues/19005
36
+ /*
31
37
  // eslint-disable-next-line react-hooks/rules-of-hooks
38
+ */
32
39
  React.useEffect(() => {
33
40
  const node = ref.current ? getInteractiveContent(ref.current) : false;
34
41
  if (node && !node.hasAttribute('aria-describedby')) {
@@ -23,7 +23,10 @@ const useOutsideClick = (ref, callback) => {
23
23
  // treated as a constant as it will be false when executed in a Node.js
24
24
  // environment and true when executed in the browser
25
25
  if (environment.canUseDOM) {
26
+ // TODO: https://github.com/carbon-design-system/carbon/issues/19005
27
+ /*
26
28
  // eslint-disable-next-line react-hooks/rules-of-hooks
29
+ */
27
30
  useEvent.useWindowEvent('click', event => {
28
31
  const {
29
32
  target
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 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
+ * Checks whether the given node or one of its ancestors matches any of the
9
+ * specified floating menu selectors.
10
+ *
11
+ * @param {Node} node - A DOM node.
12
+ * @param {string[]} selectorsFloatingMenus - Additional CSS selectors that
13
+ * match floating menus.
14
+ * @returns {boolean} Whether the node or one of its ancestors is in a floating
15
+ * menu.
16
+ */
17
+ export declare const elementOrParentIsFloatingMenu: (node: Node, selectorsFloatingMenus?: string[]) => boolean;
18
+ /**
19
+ * Ensures the focus is kept within the given container by implementing
20
+ * "focus-wrap" behavior.
21
+ */
22
+ export declare const wrapFocus: ({ bodyNode, startTrapNode, endTrapNode, currentActiveNode, oldActiveNode, selectorsFloatingMenus, }: {
23
+ /** The DOM node of the container. */
24
+ bodyNode: HTMLElement | null;
25
+ /** The start sentinel node for focus trapping. */
26
+ startTrapNode: HTMLElement | null;
27
+ /** The end sentinel node for focus trapping. */
28
+ endTrapNode: HTMLElement | null;
29
+ /** The current active node (i.e., the one with focus). */
30
+ currentActiveNode: HTMLElement;
31
+ /** The previous active node (i.e., the one that had focus before). */
32
+ oldActiveNode: HTMLElement;
33
+ /** CSS selectors for floating menus. */
34
+ selectorsFloatingMenus?: string[];
35
+ }) => void;
36
+ /**
37
+ * Ensures the focus is kept in the given container, implementing "focus-wrap"
38
+ * behavior.
39
+ *
40
+ * Note: This must be called *before* focus moves using `onKeyDown` or similar.
41
+ */
42
+ export declare const wrapFocusWithoutSentinels: ({ containerNode, currentActiveNode, event, }: {
43
+ /** The container node within which to keep focus. */
44
+ containerNode: HTMLElement;
45
+ /** The current active node (i.e., the one with focus). */
46
+ currentActiveNode: HTMLElement;
47
+ /** The event that triggered this function. */
48
+ event: React.KeyboardEvent | KeyboardEvent;
49
+ }) => void;
@@ -10,33 +10,45 @@
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  var React = require('react');
13
- var navigation = require('./keyboard/navigation.js');
14
13
  var tabbable = require('tabbable');
14
+ var navigation = require('./keyboard/navigation.js');
15
15
 
16
16
  /**
17
- * @param {Node} node A DOM node.
18
- * @param {string[]} selectorsFloatingMenus The CSS selectors that matches floating menus.
19
- * @returns {boolean} `true` of the given `node` is in a floating menu.
17
+ * A flag `node.compareDocumentPosition(target)` returns that indicates
18
+ * `target` is located earlier than `node` in the document or `target` contains `node`.
20
19
  */
21
- function elementOrParentIsFloatingMenu(node) {
20
+ const DOCUMENT_POSITION_BROAD_PRECEDING = typeof Node !== 'undefined' ? Node.DOCUMENT_POSITION_PRECEDING | Node.DOCUMENT_POSITION_CONTAINS : 0;
21
+
22
+ /**
23
+ * A flag `node.compareDocumentPosition(target)` returns that indicates
24
+ * `target` is located later than `node` in the document or `node` contains `target`.
25
+ */
26
+ const DOCUMENT_POSITION_BROAD_FOLLOWING = typeof Node !== 'undefined' ? Node.DOCUMENT_POSITION_FOLLOWING | Node.DOCUMENT_POSITION_CONTAINED_BY : 0;
27
+
28
+ /**
29
+ * Checks whether the given node or one of its ancestors matches any of the
30
+ * specified floating menu selectors.
31
+ *
32
+ * @param {Node} node - A DOM node.
33
+ * @param {string[]} selectorsFloatingMenus - Additional CSS selectors that
34
+ * match floating menus.
35
+ * @returns {boolean} Whether the node or one of its ancestors is in a floating
36
+ * menu.
37
+ */
38
+ const elementOrParentIsFloatingMenu = function (node) {
22
39
  let selectorsFloatingMenus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
23
- if (node && typeof node.closest === 'function') {
24
- const allSelectorsFloatingMenus = [`.cds--overflow-menu-options`, `.cds--tooltip`, '.flatpickr-calendar', ...selectorsFloatingMenus];
25
- return allSelectorsFloatingMenus.some(selector => node.closest(selector));
40
+ if (node instanceof Element && typeof node.closest === 'function') {
41
+ const allSelectorsFloatingMenus = ['.cds--overflow-menu-options', '.cds--tooltip', '.flatpickr-calendar', ...selectorsFloatingMenus];
42
+ return allSelectorsFloatingMenus.some(selector => !!node.closest(selector));
26
43
  }
27
- }
44
+ return false;
45
+ };
28
46
 
29
47
  /**
30
- * Ensures the focus is kept in the given `modalNode`, implementing "focus-wrap" behavior.
31
- * @param {object} options The options.
32
- * @param {Node|null} options.bodyNode
33
- * @param {Node|null} options.startTrapNode The DOM node of the focus sentinel the is placed earlier next to `modalNode`.
34
- * @param {Node|null} options.endTrapNode The DOM node of the focus sentinel the is placed next to `modalNode`.
35
- * @param {Node} options.currentActiveNode The DOM node that has focus.
36
- * @param {Node} options.oldActiveNode The DOM node that previously had focus.
37
- * @param {string[]} [options.selectorsFloatingMenus] The CSS selectors that matches floating menus.
48
+ * Ensures the focus is kept within the given container by implementing
49
+ * "focus-wrap" behavior.
38
50
  */
39
- function wrapFocus(_ref) {
51
+ const wrapFocus = _ref => {
40
52
  let {
41
53
  bodyNode,
42
54
  startTrapNode,
@@ -47,60 +59,61 @@ function wrapFocus(_ref) {
47
59
  } = _ref;
48
60
  if (bodyNode && currentActiveNode && oldActiveNode && !bodyNode.contains(currentActiveNode) && !elementOrParentIsFloatingMenu(currentActiveNode, selectorsFloatingMenus)) {
49
61
  const comparisonResult = oldActiveNode.compareDocumentPosition(currentActiveNode);
50
- if (currentActiveNode === startTrapNode || comparisonResult & navigation.DOCUMENT_POSITION_BROAD_PRECEDING) {
51
- const tabbable = [...bodyNode.querySelectorAll(navigation.selectorTabbable)].reverse().find(elem => Boolean(elem.offsetParent));
52
- if (tabbable) {
53
- tabbable.focus();
62
+ if (currentActiveNode === startTrapNode || comparisonResult & DOCUMENT_POSITION_BROAD_PRECEDING) {
63
+ const tabbableElement = Array.from(bodyNode.querySelectorAll(navigation.selectorTabbable)).reverse().find(_ref2 => {
64
+ let {
65
+ offsetParent
66
+ } = _ref2;
67
+ return Boolean(offsetParent);
68
+ });
69
+ if (tabbableElement) {
70
+ tabbableElement.focus();
54
71
  } else if (bodyNode !== oldActiveNode) {
55
72
  bodyNode.focus();
56
73
  }
57
- } else if (currentActiveNode === endTrapNode || comparisonResult & navigation.DOCUMENT_POSITION_BROAD_FOLLOWING) {
58
- const tabbable = Array.prototype.find.call(bodyNode.querySelectorAll(navigation.selectorTabbable), elem => Boolean(elem.offsetParent));
59
- if (tabbable) {
60
- tabbable.focus();
74
+ } else if (currentActiveNode === endTrapNode || comparisonResult & DOCUMENT_POSITION_BROAD_FOLLOWING) {
75
+ const tabbableElement = Array.from(bodyNode.querySelectorAll(navigation.selectorTabbable)).find(_ref3 => {
76
+ let {
77
+ offsetParent
78
+ } = _ref3;
79
+ return Boolean(offsetParent);
80
+ });
81
+ if (tabbableElement) {
82
+ tabbableElement.focus();
61
83
  } else if (bodyNode !== oldActiveNode) {
62
84
  bodyNode.focus();
63
85
  }
64
86
  }
65
87
  }
66
- }
88
+ };
67
89
 
68
90
  /**
69
- * Ensures the focus is kept in the given `containerNode`, implementing "focus-wrap" behavior.
70
- * Note: This must be called *before* focus moves using onKeyDown or similar.
71
- * @param {object} options The options.
72
- * @param {Node|null} options.containerNode
73
- * @param {EventTarget} options.currentActiveNode The DOM node that has focus.
74
- * @param {React.KeyboardEvent} options.event The DOM event
91
+ * Ensures the focus is kept in the given container, implementing "focus-wrap"
92
+ * behavior.
93
+ *
94
+ * Note: This must be called *before* focus moves using `onKeyDown` or similar.
75
95
  */
76
- function wrapFocusWithoutSentinels(_ref2) {
96
+ const wrapFocusWithoutSentinels = _ref4 => {
77
97
  let {
78
98
  containerNode,
79
99
  currentActiveNode,
80
100
  event
81
- } = _ref2;
82
- if (['blur', 'focusout', 'focusin', 'focus'].includes(event.type) && process.env.NODE_ENV !== 'production') {
83
- // eslint-disable-next-line react-hooks/rules-of-hooks
84
- React.useEffect(() => {
101
+ } = _ref4;
102
+ if (!containerNode) return;
103
+ React.useEffect(() => {
104
+ if (['blur', 'focusout', 'focusin', 'focus'].includes(event.type) && process.env.NODE_ENV !== 'production') {
85
105
  throw new Error(`Error: wrapFocusWithoutSentinels(...) called in unsupported ${event.type} event.\n\nCall wrapFocusWithoutSentinels(...) from onKeyDown instead.`);
86
- });
87
- }
106
+ }
107
+ }, []);
88
108
 
89
- // The reason we're using tabbable is because it returns the tabbable
90
- // items *in tab order*, whereas using our `selectorTabbable` only
91
- // returns in DOM order
109
+ // Use `tabbable` to get the focusable elements in tab order.
110
+ // `selectorTabbable` returns elements in DOM order which is why it's not
111
+ // used.
92
112
  const tabbables = tabbable.tabbable(containerNode);
93
113
  const firstTabbable = tabbables[0];
94
114
  const lastTabbable = tabbables[tabbables.length - 1];
95
115
 
96
- // console.log(`---------------------------------`);
97
- // console.log(containerNode);
98
- // console.log(tabbables);
99
- // console.log(firstTabbable);
100
- // console.log(lastTabbable);
101
- // console.log(currentActiveNode);
102
-
103
- // The shift key is used to determine if focus is moving forwards or backwards
116
+ // The shift key indicates if focus is moving forwards or backwards.
104
117
  if (currentActiveNode === lastTabbable && !event.shiftKey) {
105
118
  // Cancel the current movement of focus because we're going to place it ourselves
106
119
  event.preventDefault();
@@ -111,8 +124,8 @@ function wrapFocusWithoutSentinels(_ref2) {
111
124
  event.preventDefault();
112
125
  lastTabbable.focus();
113
126
  }
114
- }
127
+ };
115
128
 
116
- exports["default"] = wrapFocus;
117
129
  exports.elementOrParentIsFloatingMenu = elementOrParentIsFloatingMenu;
130
+ exports.wrapFocus = wrapFocus;
118
131
  exports.wrapFocusWithoutSentinels = wrapFocusWithoutSentinels;
@@ -0,0 +1,17 @@
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 { SyntheticEvent } from 'react';
8
+ /**
9
+ * Composes multiple event handler functions into a single event handler. The
10
+ * composed handler calls each provided function sequentially with the event and
11
+ * any additional arguments. If any handler calls `event.preventDefault()`,
12
+ * further handlers are skipped.
13
+ *
14
+ * @param handlers - An array of event handler functions.
15
+ * @returns A composite event handler.
16
+ */
17
+ export declare const composeEventHandlers: <E extends SyntheticEvent = SyntheticEvent<Element, Event>>(handlers: (((event: E, ...args: any[]) => void) | undefined)[]) => (event: E, ...args: any[]) => void;
@@ -9,28 +9,25 @@
9
9
 
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
- // @ts-check
13
-
14
12
  /**
15
- * Generic utility to compose event handlers so that consumers can supply their
16
- * own event listeners on table components. The default heuristic here is to
17
- * iterate through the given functions until `preventDefault` is called on the
18
- * given event.
13
+ * Composes multiple event handler functions into a single event handler. The
14
+ * composed handler calls each provided function sequentially with the event and
15
+ * any additional arguments. If any handler calls `event.preventDefault()`,
16
+ * further handlers are skipped.
19
17
  *
20
- * @param {Array<Function|undefined>} fns array of functions to apply to the event
21
- * @returns {any}
18
+ * @param handlers - An array of event handler functions.
19
+ * @returns A composite event handler.
22
20
  */
23
- const composeEventHandlers = fns => function (event) {
21
+ const composeEventHandlers = handlers => function (event) {
24
22
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
25
23
  args[_key - 1] = arguments[_key];
26
24
  }
27
- for (let i = 0; i < fns.length; i++) {
25
+ for (const handler of handlers) {
28
26
  if (event.defaultPrevented) {
29
27
  break;
30
28
  }
31
- const fn = fns[i];
32
- if (typeof fn === 'function') {
33
- fn(event, ...args);
29
+ if (typeof handler === 'function') {
30
+ handler(event, ...args);
34
31
  }
35
32
  }
36
33
  };
@@ -0,0 +1,15 @@
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 { Placement } from '@floating-ui/react';
8
+ /**
9
+ * Maps popover alignment values to their corresponding replacement values.
10
+ *
11
+ * @param align - The original align value.
12
+ * @returns The new align value based on mapping or the original align if no
13
+ * mapping exists.
14
+ */
15
+ export declare const mapPopoverAlign: (align: string) => Placement;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ const popoverAlignMapping = {
13
+ 'top-left': 'top-start',
14
+ 'top-right': 'top-end',
15
+ 'bottom-left': 'bottom-start',
16
+ 'bottom-right': 'bottom-end',
17
+ 'left-bottom': 'left-end',
18
+ 'left-top': 'left-start',
19
+ 'right-bottom': 'right-end',
20
+ 'right-top': 'right-start'
21
+ };
22
+
23
+ /**
24
+ * Maps popover alignment values to their corresponding replacement values.
25
+ *
26
+ * @param align - The original align value.
27
+ * @returns The new align value based on mapping or the original align if no
28
+ * mapping exists.
29
+ */
30
+ const mapPopoverAlign = align => popoverAlignMapping[align] ?? align;
31
+
32
+ exports.mapPopoverAlign = mapPopoverAlign;
@@ -0,0 +1,7 @@
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
+ export declare const uniqueId: (prefix?: string) => string;
@@ -10,10 +10,10 @@
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  let lastId = 0;
13
- function uniqueId() {
13
+ const uniqueId = function () {
14
14
  let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'id';
15
15
  lastId++;
16
16
  return `${prefix}${lastId}`;
17
- }
17
+ };
18
18
 
19
- exports["default"] = uniqueId;
19
+ exports.uniqueId = uniqueId;
@@ -6,8 +6,6 @@
6
6
  */
7
7
  import * as React from 'react';
8
8
  export type ReactAttr<T = HTMLElement> = React.HTMLAttributes<T>;
9
- export type ForwardRefProps<T, P = unknown> = React.PropsWithoutRef<React.PropsWithChildren<P>> & React.RefAttributes<T>;
10
- export type ForwardRefReturn<T, P = unknown> = React.ForwardRefExoticComponent<ForwardRefProps<T, P>>;
11
9
  /**
12
10
  * For "as" props. Creates an "as" property that supports native html tags such as 'span', 'a', 'button' as well as custom functional components
13
11
  * All native props for the supplied html tag/component are inferred as part of the base component props, allowing us to use props like `href` on an 'a' element etc
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/react",
3
3
  "description": "React components for the Carbon Design System",
4
- "version": "1.81.0",
4
+ "version": "1.82.0-rc.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -53,9 +53,10 @@
53
53
  "dependencies": {
54
54
  "@babel/runtime": "^7.24.7",
55
55
  "@carbon/feature-flags": "^0.26.0",
56
- "@carbon/icons-react": "^11.59.0",
57
- "@carbon/layout": "^11.33.0",
58
- "@carbon/styles": "^1.80.0",
56
+ "@carbon/icons-react": "^11.60.0-rc.0",
57
+ "@carbon/layout": "^11.34.0-rc.0",
58
+ "@carbon/styles": "^1.81.0-rc.0",
59
+ "@carbon/utilities": "^0.5.0",
59
60
  "@floating-ui/react": "^0.27.4",
60
61
  "@ibm/telemetry-js": "^1.5.0",
61
62
  "classnames": "2.5.1",
@@ -80,7 +81,7 @@
80
81
  "@babel/preset-react": "^7.24.7",
81
82
  "@babel/preset-typescript": "^7.24.7",
82
83
  "@carbon/test-utils": "^10.36.0",
83
- "@carbon/themes": "^11.51.0",
84
+ "@carbon/themes": "^11.52.0-rc.0",
84
85
  "@figma/code-connect": "^1.3.2",
85
86
  "@rollup/plugin-babel": "^6.0.0",
86
87
  "@rollup/plugin-commonjs": "^28.0.0",
@@ -92,7 +93,6 @@
92
93
  "@storybook/addon-docs": "^8.4.7",
93
94
  "@storybook/addon-essentials": "^8.4.7",
94
95
  "@storybook/addon-links": "^8.4.7",
95
- "@storybook/addon-storysource": "^8.4.7",
96
96
  "@storybook/addon-webpack5-compiler-babel": "^3.0.3",
97
97
  "@storybook/blocks": "^8.4.7",
98
98
  "@storybook/manager-api": "^8.4.7",
@@ -147,5 +147,5 @@
147
147
  "**/*.scss",
148
148
  "**/*.css"
149
149
  ],
150
- "gitHead": "01b2d2b1c2d901921c615dcbdb85e0a2340b67e6"
150
+ "gitHead": "3b78e2acacf62b0a9e5425e5f3b43e6798cd209f"
151
151
  }
package/telemetry.yml CHANGED
@@ -172,6 +172,7 @@ collect:
172
172
  - orientation
173
173
  - overflowMenuOnHover
174
174
  - page
175
+ - pageActions
175
176
  - paragraph
176
177
  - passiveModal
177
178
  - pattern
@@ -457,7 +458,8 @@ collect:
457
458
  - wrapperClassName
458
459
  # PageHeaderContent
459
460
  - contextualActions
460
- - pageActions
461
+ # PageHeaderContentPageActions
462
+ - menuButtonLabel
461
463
  # PageSelector
462
464
  - currentPage
463
465
  - totalPages