@carbon/react 1.81.0 → 1.82.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +892 -892
  2. package/es/components/AILabel/index.d.ts +1 -1
  3. package/es/components/AILabel/index.js +2 -9
  4. package/es/components/Breadcrumb/Breadcrumb.d.ts +2 -3
  5. package/es/components/Breadcrumb/Breadcrumb.js +4 -4
  6. package/es/components/Breadcrumb/BreadcrumbItem.d.ts +3 -4
  7. package/es/components/Breadcrumb/BreadcrumbItem.js +5 -4
  8. package/es/components/Button/Button.js +2 -10
  9. package/es/components/ButtonSet/ButtonSet.d.ts +2 -3
  10. package/es/components/ButtonSet/ButtonSet.js +4 -4
  11. package/es/components/CodeSnippet/CodeSnippet.d.ts +1 -1
  12. package/es/components/CodeSnippet/CodeSnippet.js +3 -19
  13. package/es/components/ComboBox/ComboBox.d.ts +1 -1
  14. package/es/components/ComboBox/ComboBox.js +2 -2
  15. package/es/components/ComboButton/index.d.ts +1 -1
  16. package/es/components/ComboButton/index.js +2 -18
  17. package/es/components/ComposedModal/ComposedModal.js +5 -3
  18. package/es/components/Copy/Copy.d.ts +1 -1
  19. package/es/components/Copy/Copy.js +2 -18
  20. package/es/components/CopyButton/CopyButton.d.ts +1 -1
  21. package/es/components/CopyButton/CopyButton.js +2 -18
  22. package/es/components/DataTable/DataTable.d.ts +7 -12
  23. package/es/components/DataTable/DataTable.js +0 -5
  24. package/es/components/DataTable/TableToolbarAction.d.ts +2 -4
  25. package/es/components/DataTable/TableToolbarAction.js +5 -4
  26. package/es/components/DataTable/tools/sorting.d.ts +42 -0
  27. package/es/components/DataTable/tools/sorting.js +24 -53
  28. package/es/components/DatePicker/DatePicker.d.ts +1 -1
  29. package/es/components/DatePicker/DatePicker.js +18 -18
  30. package/es/components/Dialog/index.d.ts +1 -1
  31. package/es/components/Dropdown/Dropdown.Skeleton.d.ts +2 -2
  32. package/es/components/Dropdown/Dropdown.Skeleton.js +2 -2
  33. package/es/components/Dropdown/Dropdown.d.ts +7 -6
  34. package/es/components/Dropdown/Dropdown.js +7 -3
  35. package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
  36. package/es/components/FileUploader/FileUploaderButton.js +1 -1
  37. package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
  38. package/es/components/FileUploader/FileUploaderItem.js +1 -1
  39. package/es/components/FluidDropdown/FluidDropdown.d.ts +1 -1
  40. package/es/components/FluidSearch/FluidSearch.d.ts +3 -6
  41. package/es/components/IconButton/index.d.ts +1 -1
  42. package/es/components/IconButton/index.js +2 -18
  43. package/es/components/ListBox/ListBox.d.ts +4 -5
  44. package/es/components/ListBox/ListBox.js +8 -7
  45. package/es/components/ListBox/ListBoxMenu.d.ts +4 -4
  46. package/es/components/ListBox/ListBoxMenu.js +4 -2
  47. package/es/components/ListBox/ListBoxMenuItem.d.ts +9 -8
  48. package/es/components/ListBox/ListBoxPropTypes.d.ts +3 -3
  49. package/es/components/ListBox/ListBoxPropTypes.js +3 -3
  50. package/es/components/ListBox/index.d.ts +7 -5
  51. package/es/components/ListBox/index.js +1 -1
  52. package/es/components/Menu/Menu.js +5 -0
  53. package/es/components/Modal/Modal.js +9 -9
  54. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +3 -2
  55. package/es/components/MultiSelect/FilterableMultiSelect.js +3 -2
  56. package/es/components/MultiSelect/MultiSelect.d.ts +8 -2
  57. package/es/components/MultiSelect/MultiSelect.js +3 -3
  58. package/es/components/Notification/Notification.js +1 -1
  59. package/es/components/OverflowMenu/OverflowMenu.js +2 -21
  60. package/es/components/OverflowMenu/next/index.js +2 -18
  61. package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +2 -4
  62. package/es/components/OverflowMenuItem/OverflowMenuItem.js +5 -4
  63. package/es/components/PageHeader/PageHeader.d.ts +153 -8
  64. package/es/components/PageHeader/PageHeader.js +143 -21
  65. package/es/components/PageHeader/index.d.ts +2 -2
  66. package/es/components/PageHeader/index.js +1 -1
  67. package/es/components/Popover/index.js +4 -21
  68. package/es/components/Search/Search.d.ts +2 -5
  69. package/es/components/Search/Search.js +24 -8
  70. package/es/components/Stack/HStack.d.ts +2 -3
  71. package/es/components/Stack/HStack.js +4 -7
  72. package/es/components/Stack/Stack.d.ts +3 -4
  73. package/es/components/Stack/Stack.js +3 -6
  74. package/es/components/Stack/VStack.d.ts +2 -3
  75. package/es/components/Stack/VStack.js +3 -2
  76. package/es/components/Stack/index.d.ts +4 -4
  77. package/es/components/TextArea/TextArea.js +3 -5
  78. package/es/components/TimePicker/TimePicker.d.ts +3 -4
  79. package/es/components/TimePicker/TimePicker.js +5 -4
  80. package/es/components/TimePickerSelect/TimePickerSelect.d.ts +23 -4
  81. package/es/components/TimePickerSelect/TimePickerSelect.js +5 -4
  82. package/es/components/TreeView/TreeNode.js +13 -1
  83. package/es/components/TreeView/TreeView.js +1 -1
  84. package/es/index.js +1 -1
  85. package/es/internal/FloatingMenu.js +9 -5
  86. package/es/internal/environment.js +7 -0
  87. package/es/internal/keyboard/navigation.d.ts +0 -10
  88. package/es/internal/keyboard/navigation.js +1 -13
  89. package/es/internal/useId.js +1 -1
  90. package/es/internal/useNoInteractiveChildren.js +7 -0
  91. package/es/internal/useOutsideClick.js +3 -0
  92. package/es/internal/wrapFocus.d.ts +49 -0
  93. package/es/internal/wrapFocus.js +64 -51
  94. package/es/tools/events.d.ts +17 -0
  95. package/es/tools/events.js +10 -13
  96. package/es/tools/mapPopoverAlign.d.ts +15 -0
  97. package/es/tools/mapPopoverAlign.js +28 -0
  98. package/es/tools/uniqueId.d.ts +7 -0
  99. package/es/tools/uniqueId.js +3 -3
  100. package/es/types/common.d.ts +0 -2
  101. package/lib/components/AILabel/index.d.ts +1 -1
  102. package/lib/components/AILabel/index.js +2 -9
  103. package/lib/components/Breadcrumb/Breadcrumb.d.ts +2 -3
  104. package/lib/components/Breadcrumb/Breadcrumb.js +3 -3
  105. package/lib/components/Breadcrumb/BreadcrumbItem.d.ts +3 -4
  106. package/lib/components/Breadcrumb/BreadcrumbItem.js +4 -3
  107. package/lib/components/Button/Button.js +1 -9
  108. package/lib/components/ButtonSet/ButtonSet.d.ts +2 -3
  109. package/lib/components/ButtonSet/ButtonSet.js +3 -3
  110. package/lib/components/CodeSnippet/CodeSnippet.d.ts +1 -1
  111. package/lib/components/CodeSnippet/CodeSnippet.js +3 -19
  112. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  113. package/lib/components/ComboBox/ComboBox.js +1 -1
  114. package/lib/components/ComboButton/index.d.ts +1 -1
  115. package/lib/components/ComboButton/index.js +2 -18
  116. package/lib/components/ComposedModal/ComposedModal.js +5 -3
  117. package/lib/components/Copy/Copy.d.ts +1 -1
  118. package/lib/components/Copy/Copy.js +2 -18
  119. package/lib/components/CopyButton/CopyButton.d.ts +1 -1
  120. package/lib/components/CopyButton/CopyButton.js +2 -18
  121. package/lib/components/DataTable/DataTable.d.ts +7 -12
  122. package/lib/components/DataTable/DataTable.js +0 -5
  123. package/lib/components/DataTable/TableToolbarAction.d.ts +2 -4
  124. package/lib/components/DataTable/TableToolbarAction.js +4 -3
  125. package/lib/components/DataTable/tools/sorting.d.ts +42 -0
  126. package/lib/components/DataTable/tools/sorting.js +23 -53
  127. package/lib/components/DatePicker/DatePicker.d.ts +1 -1
  128. package/lib/components/DatePicker/DatePicker.js +18 -18
  129. package/lib/components/Dialog/index.d.ts +1 -1
  130. package/lib/components/Dropdown/Dropdown.Skeleton.d.ts +2 -2
  131. package/lib/components/Dropdown/Dropdown.Skeleton.js +1 -1
  132. package/lib/components/Dropdown/Dropdown.d.ts +7 -6
  133. package/lib/components/Dropdown/Dropdown.js +6 -2
  134. package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
  135. package/lib/components/FileUploader/FileUploaderButton.js +1 -1
  136. package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
  137. package/lib/components/FileUploader/FileUploaderItem.js +1 -1
  138. package/lib/components/FluidDropdown/FluidDropdown.d.ts +1 -1
  139. package/lib/components/FluidSearch/FluidSearch.d.ts +3 -6
  140. package/lib/components/IconButton/index.d.ts +1 -1
  141. package/lib/components/IconButton/index.js +2 -18
  142. package/lib/components/ListBox/ListBox.d.ts +4 -5
  143. package/lib/components/ListBox/ListBox.js +7 -6
  144. package/lib/components/ListBox/ListBoxMenu.d.ts +4 -4
  145. package/lib/components/ListBox/ListBoxMenu.js +3 -1
  146. package/lib/components/ListBox/ListBoxMenuItem.d.ts +9 -8
  147. package/lib/components/ListBox/ListBoxPropTypes.d.ts +3 -3
  148. package/lib/components/ListBox/ListBoxPropTypes.js +4 -4
  149. package/lib/components/ListBox/index.d.ts +7 -5
  150. package/lib/components/ListBox/index.js +2 -2
  151. package/lib/components/Menu/Menu.js +5 -0
  152. package/lib/components/Modal/Modal.js +9 -9
  153. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +3 -2
  154. package/lib/components/MultiSelect/FilterableMultiSelect.js +2 -1
  155. package/lib/components/MultiSelect/MultiSelect.d.ts +8 -2
  156. package/lib/components/MultiSelect/MultiSelect.js +2 -2
  157. package/lib/components/Notification/Notification.js +1 -1
  158. package/lib/components/OverflowMenu/OverflowMenu.js +2 -21
  159. package/lib/components/OverflowMenu/next/index.js +2 -18
  160. package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +2 -4
  161. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +4 -3
  162. package/lib/components/PageHeader/PageHeader.d.ts +153 -8
  163. package/lib/components/PageHeader/PageHeader.js +145 -19
  164. package/lib/components/PageHeader/index.d.ts +2 -2
  165. package/lib/components/PageHeader/index.js +4 -0
  166. package/lib/components/Popover/index.js +4 -21
  167. package/lib/components/Search/Search.d.ts +2 -5
  168. package/lib/components/Search/Search.js +24 -8
  169. package/lib/components/Stack/HStack.d.ts +2 -3
  170. package/lib/components/Stack/HStack.js +3 -6
  171. package/lib/components/Stack/Stack.d.ts +3 -4
  172. package/lib/components/Stack/Stack.js +2 -5
  173. package/lib/components/Stack/VStack.d.ts +2 -3
  174. package/lib/components/Stack/VStack.js +2 -1
  175. package/lib/components/Stack/index.d.ts +4 -4
  176. package/lib/components/TextArea/TextArea.js +2 -4
  177. package/lib/components/TimePicker/TimePicker.d.ts +3 -4
  178. package/lib/components/TimePicker/TimePicker.js +4 -3
  179. package/lib/components/TimePickerSelect/TimePickerSelect.d.ts +23 -4
  180. package/lib/components/TimePickerSelect/TimePickerSelect.js +4 -3
  181. package/lib/components/TreeView/TreeNode.js +13 -1
  182. package/lib/components/TreeView/TreeView.js +1 -1
  183. package/lib/index.js +2 -2
  184. package/lib/internal/FloatingMenu.js +9 -5
  185. package/lib/internal/environment.js +7 -0
  186. package/lib/internal/keyboard/navigation.d.ts +0 -10
  187. package/lib/internal/keyboard/navigation.js +0 -14
  188. package/lib/internal/useNoInteractiveChildren.js +7 -0
  189. package/lib/internal/useOutsideClick.js +3 -0
  190. package/lib/internal/wrapFocus.d.ts +49 -0
  191. package/lib/internal/wrapFocus.js +66 -53
  192. package/lib/tools/events.d.ts +17 -0
  193. package/lib/tools/events.js +10 -13
  194. package/lib/tools/mapPopoverAlign.d.ts +15 -0
  195. package/lib/tools/mapPopoverAlign.js +32 -0
  196. package/lib/tools/uniqueId.d.ts +7 -0
  197. package/lib/tools/uniqueId.js +3 -3
  198. package/lib/types/common.d.ts +0 -2
  199. package/package.json +7 -7
  200. package/telemetry.yml +3 -1
  201. package/es/tools/createPropAdapter.js +0 -40
  202. package/lib/tools/createPropAdapter.js +0 -44
@@ -9,18 +9,19 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
9
9
  import { ChevronDown } from '@carbon/icons-react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
- import React__default from 'react';
12
+ import React__default, { forwardRef } from 'react';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
14
14
 
15
- const TimePickerSelect = /*#__PURE__*/React__default.forwardRef(function TimePickerSelect(_ref, ref) {
16
- let {
15
+ const frFn = forwardRef;
16
+ const TimePickerSelect = frFn((props, ref) => {
17
+ const {
17
18
  ['aria-label']: ariaLabel = 'open list of options',
18
19
  children,
19
20
  id,
20
21
  disabled = false,
21
22
  className,
22
23
  ...rest
23
- } = _ref;
24
+ } = props;
24
25
  const prefix = usePrefix();
25
26
  const selectClasses = cx({
26
27
  [`${prefix}--select`]: true,
@@ -14,7 +14,7 @@ import { ArrowLeft, ArrowRight, Enter, Space } from '../../internal/keyboard/key
14
14
  import { matches, match } from '../../internal/keyboard/match.js';
15
15
  import { useControllableState } from '../../internal/useControllableState.js';
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
17
- import uniqueId from '../../tools/uniqueId.js';
17
+ import { uniqueId } from '../../tools/uniqueId.js';
18
18
  import { useFeatureFlag } from '../FeatureFlags/index.js';
19
19
 
20
20
  const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, forwardedRef) => {
@@ -201,6 +201,18 @@ const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, forwardedRef) =>
201
201
  }
202
202
  if (matches(event, [Enter, Space])) {
203
203
  event.preventDefault();
204
+ if (match(event, Enter) && children) {
205
+ // Toggle expansion state for parent nodes
206
+ if (!enableTreeviewControllable) {
207
+ onToggle?.(event, {
208
+ id,
209
+ isExpanded: !expanded,
210
+ label,
211
+ value
212
+ });
213
+ }
214
+ setExpanded(!expanded);
215
+ }
204
216
  if (href) {
205
217
  currentNode.current?.click();
206
218
  }
@@ -13,7 +13,7 @@ import { ArrowUp, ArrowDown, Home, End } from '../../internal/keyboard/keys.js';
13
13
  import { matches, match } from '../../internal/keyboard/match.js';
14
14
  import { useControllableState } from '../../internal/useControllableState.js';
15
15
  import { usePrefix } from '../../internal/usePrefix.js';
16
- import uniqueId from '../../tools/uniqueId.js';
16
+ import { uniqueId } from '../../tools/uniqueId.js';
17
17
  import { useFeatureFlag } from '../FeatureFlags/index.js';
18
18
  import TreeNode from './TreeNode.js';
19
19
 
package/es/index.js CHANGED
@@ -107,8 +107,8 @@ export { default as SkeletonPlaceholder } from './components/SkeletonPlaceholder
107
107
  export { default as SkeletonText } from './components/SkeletonText/SkeletonText.js';
108
108
  export { default as Slider } from './components/Slider/index.js';
109
109
  export { HStack } from './components/Stack/HStack.js';
110
- export { VStack } from './components/Stack/VStack.js';
111
110
  export { Stack } from './components/Stack/Stack.js';
111
+ export { VStack } from './components/Stack/VStack.js';
112
112
  export { StructuredListBody, StructuredListCell, StructuredListHead, StructuredListInput, StructuredListRow, StructuredListWrapper } from './components/StructuredList/StructuredList.js';
113
113
  export { default as StructuredListSkeleton } from './components/StructuredList/StructuredList.Skeleton.js';
114
114
  export { default as Switch } from './components/Switch/Switch.js';
@@ -15,7 +15,7 @@ import { selectorTabbable, selectorFocusable } from './keyboard/navigation.js';
15
15
  import { OptimizedResize } from './OptimizedResize.js';
16
16
  import { PrefixContext } from './usePrefix.js';
17
17
  import { warning } from './warning.js';
18
- import wrapFocus, { wrapFocusWithoutSentinels } from './wrapFocus.js';
18
+ import { wrapFocus, wrapFocusWithoutSentinels } from './wrapFocus.js';
19
19
 
20
20
  const DIRECTION_LEFT = 'left';
21
21
  const DIRECTION_TOP = 'top';
@@ -246,13 +246,17 @@ const FloatingMenu = _ref2 => {
246
246
  * Blur handler used when focus trapping is enabled.
247
247
  */
248
248
  const handleBlur = event => {
249
- if (menuBodyRef.current && startSentinelRef.current && endSentinelRef.current) {
249
+ const {
250
+ target,
251
+ relatedTarget
252
+ } = event;
253
+ if (menuBodyRef.current && startSentinelRef.current && endSentinelRef.current && target instanceof HTMLElement && relatedTarget instanceof HTMLElement) {
250
254
  wrapFocus({
251
255
  bodyNode: menuBodyRef.current,
252
256
  startTrapNode: startSentinelRef.current,
253
257
  endTrapNode: endSentinelRef.current,
254
- currentActiveNode: event.relatedTarget,
255
- oldActiveNode: event.target
258
+ currentActiveNode: relatedTarget,
259
+ oldActiveNode: target
256
260
  });
257
261
  }
258
262
  };
@@ -261,7 +265,7 @@ const FloatingMenu = _ref2 => {
261
265
  * Keydown handler for focus wrapping when experimental focus trap is enabled.
262
266
  */
263
267
  const handleKeyDown = event => {
264
- if (match(event, Tab) && menuBodyRef.current) {
268
+ if (match(event, Tab) && menuBodyRef.current && event.target instanceof HTMLElement) {
265
269
  wrapFocusWithoutSentinels({
266
270
  containerNode: menuBodyRef.current,
267
271
  currentActiveNode: event.target,
@@ -11,9 +11,16 @@
11
11
  * @see https://github.com/facebook/fbjs/blob/4d1751311d3f67af2dcce2e40df8512a23c7b9c6/packages/fbjs/src/core/ExecutionEnvironment.js#L12
12
12
  */
13
13
  const canUseDOM = !!(typeof window !== 'undefined' &&
14
+ // TODO: `ssr-friendly` doesn't support ESLint v9.
15
+ // https://github.com/kopiro/eslint-plugin-ssr-friendly/issues/30
16
+ // https://github.com/carbon-design-system/carbon/issues/18991
17
+ /*
14
18
  // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
19
+ */
15
20
  window.document &&
21
+ /*
16
22
  // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
23
+ */
17
24
  window.document.createElement);
18
25
 
19
26
  export { 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
  */
@@ -29,18 +29,6 @@ const getNextIndex = (key, index, arrayLength) => {
29
29
  return;
30
30
  };
31
31
 
32
- /**
33
- * A flag `node.compareDocumentPosition(target)` returns that indicates
34
- * `target` is located earlier than `node` in the document or `target` contains `node`.
35
- */
36
- const DOCUMENT_POSITION_BROAD_PRECEDING = typeof Node !== 'undefined' ? Node.DOCUMENT_POSITION_PRECEDING | Node.DOCUMENT_POSITION_CONTAINS : 0;
37
-
38
- /**
39
- * A flag `node.compareDocumentPosition(target)` returns that indicates
40
- * `target` is located later than `node` in the document or `node` contains `target`.
41
- */
42
- const DOCUMENT_POSITION_BROAD_FOLLOWING = typeof Node !== 'undefined' ? Node.DOCUMENT_POSITION_FOLLOWING | Node.DOCUMENT_POSITION_CONTAINED_BY : 0;
43
-
44
32
  /**
45
33
  * CSS selector that selects major nodes that are sequentially focusable.
46
34
  */
@@ -61,4 +49,4 @@ const selectorFocusable = `
61
49
  iframe, object, embed, *[tabindex]:not([disabled]), *[contenteditable=true]
62
50
  `;
63
51
 
64
- export { DOCUMENT_POSITION_BROAD_FOLLOWING, DOCUMENT_POSITION_BROAD_PRECEDING, getNextIndex, selectorFocusable, selectorTabbable };
52
+ export { getNextIndex, selectorFocusable, selectorTabbable };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React__default, { useState, useEffect, useLayoutEffect } from 'react';
8
+ import React__default, { useLayoutEffect, useEffect, useState } from 'react';
9
9
  import { setupGetInstanceId } from '../tools/setupGetInstanceId.js';
10
10
  import { canUseDOM } from './environment.js';
11
11
  import { useIdPrefix } from './useIdPrefix.js';
@@ -10,11 +10,15 @@ import { useEffect } from 'react';
10
10
  function useNoInteractiveChildren(ref) {
11
11
  let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'component should have no interactive child nodes';
12
12
  if (process.env.NODE_ENV !== 'production') {
13
+ // TODO: https://github.com/carbon-design-system/carbon/issues/19005
14
+ /*
13
15
  // eslint-disable-next-line react-hooks/rules-of-hooks
16
+ */
14
17
  useEffect(() => {
15
18
  const node = ref.current ? getInteractiveContent(ref.current) : false;
16
19
  if (node) {
17
20
  const errorMessage = `Error: ${message}.\n\nInstead found: ${node.outerHTML}`;
21
+ // eslint-disable-next-line no-console
18
22
  console.error(errorMessage);
19
23
  throw new Error(errorMessage);
20
24
  }
@@ -24,7 +28,10 @@ function useNoInteractiveChildren(ref) {
24
28
  function useInteractiveChildrenNeedDescription(ref) {
25
29
  let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : `interactive child node(s) should have an \`aria-describedby\` property`;
26
30
  if (process.env.NODE_ENV !== 'production') {
31
+ // TODO: https://github.com/carbon-design-system/carbon/issues/19005
32
+ /*
27
33
  // eslint-disable-next-line react-hooks/rules-of-hooks
34
+ */
28
35
  useEffect(() => {
29
36
  const node = ref.current ? getInteractiveContent(ref.current) : false;
30
37
  if (node && !node.hasAttribute('aria-describedby')) {
@@ -19,7 +19,10 @@ const useOutsideClick = (ref, callback) => {
19
19
  // treated as a constant as it will be false when executed in a Node.js
20
20
  // environment and true when executed in the browser
21
21
  if (canUseDOM) {
22
+ // TODO: https://github.com/carbon-design-system/carbon/issues/19005
23
+ /*
22
24
  // eslint-disable-next-line react-hooks/rules-of-hooks
25
+ */
23
26
  useWindowEvent('click', event => {
24
27
  const {
25
28
  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;
@@ -6,33 +6,45 @@
6
6
  */
7
7
 
8
8
  import { useEffect } from 'react';
9
- import { DOCUMENT_POSITION_BROAD_PRECEDING, selectorTabbable, DOCUMENT_POSITION_BROAD_FOLLOWING } from './keyboard/navigation.js';
10
9
  import { tabbable } from 'tabbable';
10
+ import { selectorTabbable } from './keyboard/navigation.js';
11
11
 
12
12
  /**
13
- * @param {Node} node A DOM node.
14
- * @param {string[]} selectorsFloatingMenus The CSS selectors that matches floating menus.
15
- * @returns {boolean} `true` of the given `node` is in a floating menu.
13
+ * A flag `node.compareDocumentPosition(target)` returns that indicates
14
+ * `target` is located earlier than `node` in the document or `target` contains `node`.
16
15
  */
17
- function elementOrParentIsFloatingMenu(node) {
16
+ const DOCUMENT_POSITION_BROAD_PRECEDING = typeof Node !== 'undefined' ? Node.DOCUMENT_POSITION_PRECEDING | Node.DOCUMENT_POSITION_CONTAINS : 0;
17
+
18
+ /**
19
+ * A flag `node.compareDocumentPosition(target)` returns that indicates
20
+ * `target` is located later than `node` in the document or `node` contains `target`.
21
+ */
22
+ const DOCUMENT_POSITION_BROAD_FOLLOWING = typeof Node !== 'undefined' ? Node.DOCUMENT_POSITION_FOLLOWING | Node.DOCUMENT_POSITION_CONTAINED_BY : 0;
23
+
24
+ /**
25
+ * Checks whether the given node or one of its ancestors matches any of the
26
+ * specified floating menu selectors.
27
+ *
28
+ * @param {Node} node - A DOM node.
29
+ * @param {string[]} selectorsFloatingMenus - Additional CSS selectors that
30
+ * match floating menus.
31
+ * @returns {boolean} Whether the node or one of its ancestors is in a floating
32
+ * menu.
33
+ */
34
+ const elementOrParentIsFloatingMenu = function (node) {
18
35
  let selectorsFloatingMenus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
19
- if (node && typeof node.closest === 'function') {
20
- const allSelectorsFloatingMenus = [`.cds--overflow-menu-options`, `.cds--tooltip`, '.flatpickr-calendar', ...selectorsFloatingMenus];
21
- return allSelectorsFloatingMenus.some(selector => node.closest(selector));
36
+ if (node instanceof Element && typeof node.closest === 'function') {
37
+ const allSelectorsFloatingMenus = ['.cds--overflow-menu-options', '.cds--tooltip', '.flatpickr-calendar', ...selectorsFloatingMenus];
38
+ return allSelectorsFloatingMenus.some(selector => !!node.closest(selector));
22
39
  }
23
- }
40
+ return false;
41
+ };
24
42
 
25
43
  /**
26
- * Ensures the focus is kept in the given `modalNode`, implementing "focus-wrap" behavior.
27
- * @param {object} options The options.
28
- * @param {Node|null} options.bodyNode
29
- * @param {Node|null} options.startTrapNode The DOM node of the focus sentinel the is placed earlier next to `modalNode`.
30
- * @param {Node|null} options.endTrapNode The DOM node of the focus sentinel the is placed next to `modalNode`.
31
- * @param {Node} options.currentActiveNode The DOM node that has focus.
32
- * @param {Node} options.oldActiveNode The DOM node that previously had focus.
33
- * @param {string[]} [options.selectorsFloatingMenus] The CSS selectors that matches floating menus.
44
+ * Ensures the focus is kept within the given container by implementing
45
+ * "focus-wrap" behavior.
34
46
  */
35
- function wrapFocus(_ref) {
47
+ const wrapFocus = _ref => {
36
48
  let {
37
49
  bodyNode,
38
50
  startTrapNode,
@@ -44,59 +56,60 @@ function wrapFocus(_ref) {
44
56
  if (bodyNode && currentActiveNode && oldActiveNode && !bodyNode.contains(currentActiveNode) && !elementOrParentIsFloatingMenu(currentActiveNode, selectorsFloatingMenus)) {
45
57
  const comparisonResult = oldActiveNode.compareDocumentPosition(currentActiveNode);
46
58
  if (currentActiveNode === startTrapNode || comparisonResult & DOCUMENT_POSITION_BROAD_PRECEDING) {
47
- const tabbable = [...bodyNode.querySelectorAll(selectorTabbable)].reverse().find(elem => Boolean(elem.offsetParent));
48
- if (tabbable) {
49
- tabbable.focus();
59
+ const tabbableElement = Array.from(bodyNode.querySelectorAll(selectorTabbable)).reverse().find(_ref2 => {
60
+ let {
61
+ offsetParent
62
+ } = _ref2;
63
+ return Boolean(offsetParent);
64
+ });
65
+ if (tabbableElement) {
66
+ tabbableElement.focus();
50
67
  } else if (bodyNode !== oldActiveNode) {
51
68
  bodyNode.focus();
52
69
  }
53
70
  } else if (currentActiveNode === endTrapNode || comparisonResult & DOCUMENT_POSITION_BROAD_FOLLOWING) {
54
- const tabbable = Array.prototype.find.call(bodyNode.querySelectorAll(selectorTabbable), elem => Boolean(elem.offsetParent));
55
- if (tabbable) {
56
- tabbable.focus();
71
+ const tabbableElement = Array.from(bodyNode.querySelectorAll(selectorTabbable)).find(_ref3 => {
72
+ let {
73
+ offsetParent
74
+ } = _ref3;
75
+ return Boolean(offsetParent);
76
+ });
77
+ if (tabbableElement) {
78
+ tabbableElement.focus();
57
79
  } else if (bodyNode !== oldActiveNode) {
58
80
  bodyNode.focus();
59
81
  }
60
82
  }
61
83
  }
62
- }
84
+ };
63
85
 
64
86
  /**
65
- * Ensures the focus is kept in the given `containerNode`, implementing "focus-wrap" behavior.
66
- * Note: This must be called *before* focus moves using onKeyDown or similar.
67
- * @param {object} options The options.
68
- * @param {Node|null} options.containerNode
69
- * @param {EventTarget} options.currentActiveNode The DOM node that has focus.
70
- * @param {React.KeyboardEvent} options.event The DOM event
87
+ * Ensures the focus is kept in the given container, implementing "focus-wrap"
88
+ * behavior.
89
+ *
90
+ * Note: This must be called *before* focus moves using `onKeyDown` or similar.
71
91
  */
72
- function wrapFocusWithoutSentinels(_ref2) {
92
+ const wrapFocusWithoutSentinels = _ref4 => {
73
93
  let {
74
94
  containerNode,
75
95
  currentActiveNode,
76
96
  event
77
- } = _ref2;
78
- if (['blur', 'focusout', 'focusin', 'focus'].includes(event.type) && process.env.NODE_ENV !== 'production') {
79
- // eslint-disable-next-line react-hooks/rules-of-hooks
80
- useEffect(() => {
97
+ } = _ref4;
98
+ if (!containerNode) return;
99
+ useEffect(() => {
100
+ if (['blur', 'focusout', 'focusin', 'focus'].includes(event.type) && process.env.NODE_ENV !== 'production') {
81
101
  throw new Error(`Error: wrapFocusWithoutSentinels(...) called in unsupported ${event.type} event.\n\nCall wrapFocusWithoutSentinels(...) from onKeyDown instead.`);
82
- });
83
- }
102
+ }
103
+ }, []);
84
104
 
85
- // The reason we're using tabbable is because it returns the tabbable
86
- // items *in tab order*, whereas using our `selectorTabbable` only
87
- // returns in DOM order
105
+ // Use `tabbable` to get the focusable elements in tab order.
106
+ // `selectorTabbable` returns elements in DOM order which is why it's not
107
+ // used.
88
108
  const tabbables = tabbable(containerNode);
89
109
  const firstTabbable = tabbables[0];
90
110
  const lastTabbable = tabbables[tabbables.length - 1];
91
111
 
92
- // console.log(`---------------------------------`);
93
- // console.log(containerNode);
94
- // console.log(tabbables);
95
- // console.log(firstTabbable);
96
- // console.log(lastTabbable);
97
- // console.log(currentActiveNode);
98
-
99
- // The shift key is used to determine if focus is moving forwards or backwards
112
+ // The shift key indicates if focus is moving forwards or backwards.
100
113
  if (currentActiveNode === lastTabbable && !event.shiftKey) {
101
114
  // Cancel the current movement of focus because we're going to place it ourselves
102
115
  event.preventDefault();
@@ -107,6 +120,6 @@ function wrapFocusWithoutSentinels(_ref2) {
107
120
  event.preventDefault();
108
121
  lastTabbable.focus();
109
122
  }
110
- }
123
+ };
111
124
 
112
- export { wrapFocus as default, elementOrParentIsFloatingMenu, wrapFocusWithoutSentinels };
125
+ export { elementOrParentIsFloatingMenu, wrapFocus, 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;
@@ -5,28 +5,25 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- // @ts-check
9
-
10
8
  /**
11
- * Generic utility to compose event handlers so that consumers can supply their
12
- * own event listeners on table components. The default heuristic here is to
13
- * iterate through the given functions until `preventDefault` is called on the
14
- * given event.
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.
15
13
  *
16
- * @param {Array<Function|undefined>} fns array of functions to apply to the event
17
- * @returns {any}
14
+ * @param handlers - An array of event handler functions.
15
+ * @returns A composite event handler.
18
16
  */
19
- const composeEventHandlers = fns => function (event) {
17
+ const composeEventHandlers = handlers => function (event) {
20
18
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
21
19
  args[_key - 1] = arguments[_key];
22
20
  }
23
- for (let i = 0; i < fns.length; i++) {
21
+ for (const handler of handlers) {
24
22
  if (event.defaultPrevented) {
25
23
  break;
26
24
  }
27
- const fn = fns[i];
28
- if (typeof fn === 'function') {
29
- fn(event, ...args);
25
+ if (typeof handler === 'function') {
26
+ handler(event, ...args);
30
27
  }
31
28
  }
32
29
  };
@@ -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,28 @@
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
+ const popoverAlignMapping = {
9
+ 'top-left': 'top-start',
10
+ 'top-right': 'top-end',
11
+ 'bottom-left': 'bottom-start',
12
+ 'bottom-right': 'bottom-end',
13
+ 'left-bottom': 'left-end',
14
+ 'left-top': 'left-start',
15
+ 'right-bottom': 'right-end',
16
+ 'right-top': 'right-start'
17
+ };
18
+
19
+ /**
20
+ * Maps popover alignment values to their corresponding replacement values.
21
+ *
22
+ * @param align - The original align value.
23
+ * @returns The new align value based on mapping or the original align if no
24
+ * mapping exists.
25
+ */
26
+ const mapPopoverAlign = align => popoverAlignMapping[align] ?? align;
27
+
28
+ export { 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;
@@ -6,10 +6,10 @@
6
6
  */
7
7
 
8
8
  let lastId = 0;
9
- function uniqueId() {
9
+ const uniqueId = function () {
10
10
  let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'id';
11
11
  lastId++;
12
12
  return `${prefix}${lastId}`;
13
- }
13
+ };
14
14
 
15
- export { uniqueId as default };
15
+ export { 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
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2024
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.
@@ -17,7 +17,7 @@ var React = require('react');
17
17
  var usePrefix = require('../../internal/usePrefix.js');
18
18
  var index = require('../Toggletip/index.js');
19
19
  var index$1 = require('../IconButton/index.js');
20
- var createPropAdapter = require('../../tools/createPropAdapter.js');
20
+ var mapPopoverAlign = require('../../tools/mapPopoverAlign.js');
21
21
  var iconsReact = require('@carbon/icons-react');
22
22
  var useId = require('../../internal/useId.js');
23
23
  var deprecate = require('../../prop-types/deprecate.js');
@@ -90,9 +90,6 @@ AILabelActions.propTypes = {
90
90
  * @deprecated Use NewPopoverAlignment instead.
91
91
  */
92
92
 
93
- const propMappingFunction = deprecatedValue => {
94
- return createPropAdapter.mapPopoverAlignProp(deprecatedValue);
95
- };
96
93
  const AILabel = /*#__PURE__*/React__default["default"].forwardRef(function AILabel(_ref3, ref) {
97
94
  let {
98
95
  aiText = 'AI',
@@ -191,11 +188,7 @@ AILabel.propTypes = {
191
188
  // deprecated use right-start instead
192
189
 
193
190
  // new values to match floating-ui
194
- 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
195
- //allowed prop values
196
- ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'],
197
- //optional mapper function
198
- propMappingFunction),
191
+ 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']), ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'], mapPopoverAlign.mapPopoverAlign),
199
192
  /**
200
193
  * Specify the text that will be provided to the aria-label of the `AILabel` button
201
194
  */
@@ -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 BreadcrumbProps extends React.HTMLAttributes<HTMLElement> {
10
9
  /**
11
10
  * Specify the label for the breadcrumb container
@@ -25,5 +24,5 @@ export interface BreadcrumbProps extends React.HTMLAttributes<HTMLElement> {
25
24
  */
26
25
  size?: 'sm' | 'md';
27
26
  }
28
- declare const Breadcrumb: ForwardRefReturn<HTMLElement, BreadcrumbProps>;
27
+ declare const Breadcrumb: React.ForwardRefExoticComponent<BreadcrumbProps & React.RefAttributes<HTMLElement>>;
29
28
  export default Breadcrumb;