@carbon/react 1.84.0-rc.0 → 1.85.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 (177) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +943 -943
  2. package/es/components/AILabel/index.js +6 -1
  3. package/es/components/Checkbox/Checkbox.d.ts +2 -2
  4. package/es/components/Checkbox/Checkbox.js +8 -8
  5. package/es/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
  6. package/es/components/CheckboxGroup/CheckboxGroup.js +9 -8
  7. package/es/components/CodeSnippet/CodeSnippet.js +2 -4
  8. package/es/components/ComboBox/ComboBox.d.ts +1 -1
  9. package/es/components/ComboBox/ComboBox.js +8 -7
  10. package/es/components/ComposedModal/ComposedModal.d.ts +1 -1
  11. package/es/components/ComposedModal/ComposedModal.js +34 -12
  12. package/es/components/ContainedList/ContainedList.d.ts +1 -1
  13. package/es/components/ContainedList/ContainedList.js +4 -2
  14. package/es/components/ContentSwitcher/ContentSwitcher.js +6 -5
  15. package/es/components/DataTable/DataTable.js +3 -0
  16. package/es/components/DataTable/TableDecoratorRow.d.ts +2 -2
  17. package/es/components/DataTable/TableDecoratorRow.js +8 -8
  18. package/es/components/DataTable/TableExpandRow.d.ts +1 -1
  19. package/es/components/DataTable/TableExpandRow.js +15 -6
  20. package/es/components/DataTable/TableHeader.js +10 -10
  21. package/es/components/DataTable/TableRow.js +12 -4
  22. package/es/components/DataTable/tools/normalize.js +2 -1
  23. package/es/components/DatePickerInput/DatePickerInput.js +8 -7
  24. package/es/components/Dialog/index.d.ts +5 -1
  25. package/es/components/Dialog/index.js +20 -0
  26. package/es/components/Dropdown/Dropdown.d.ts +1 -1
  27. package/es/components/Dropdown/Dropdown.js +8 -10
  28. package/es/components/FileUploader/FileUploaderButton.js +2 -2
  29. package/es/components/FileUploader/FileUploaderDropContainer.js +2 -2
  30. package/es/components/FileUploader/FileUploaderItem.js +2 -2
  31. package/es/components/Layer/index.d.ts +1 -3
  32. package/es/components/Layer/index.js +9 -8
  33. package/es/components/Menu/Menu.js +0 -6
  34. package/es/components/Modal/Modal.d.ts +2 -2
  35. package/es/components/Modal/Modal.js +39 -11
  36. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  37. package/es/components/MultiSelect/FilterableMultiSelect.js +29 -7
  38. package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
  39. package/es/components/MultiSelect/MultiSelect.js +8 -7
  40. package/es/components/NumberInput/NumberInput.d.ts +1 -1
  41. package/es/components/NumberInput/NumberInput.js +9 -8
  42. package/es/components/OverflowMenu/OverflowMenu.js +4 -5
  43. package/es/components/PageHeader/PageHeader.d.ts +10 -9
  44. package/es/components/PageHeader/PageHeader.js +94 -34
  45. package/es/components/PageHeader/index.d.ts +2 -2
  46. package/es/components/PageHeader/index.js +1 -1
  47. package/es/components/Popover/index.js +2 -1
  48. package/es/components/RadioButton/RadioButton.d.ts +2 -2
  49. package/es/components/RadioButton/RadioButton.js +8 -8
  50. package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
  51. package/es/components/RadioButtonGroup/RadioButtonGroup.js +9 -8
  52. package/es/components/RadioTile/RadioTile.d.ts +1 -1
  53. package/es/components/RadioTile/RadioTile.js +8 -7
  54. package/es/components/Search/Search.js +0 -1
  55. package/es/components/Select/Select.d.ts +2 -2
  56. package/es/components/Select/Select.js +8 -7
  57. package/es/components/Slider/Slider.js +6 -0
  58. package/es/components/Tag/DismissibleTag.d.ts +1 -1
  59. package/es/components/Tag/DismissibleTag.js +9 -8
  60. package/es/components/Tag/Tag.d.ts +1 -1
  61. package/es/components/Tag/Tag.js +9 -8
  62. package/es/components/TextArea/TextArea.js +12 -11
  63. package/es/components/TextInput/TextInput.d.ts +1 -1
  64. package/es/components/TextInput/TextInput.js +20 -9
  65. package/es/components/Tile/Tile.d.ts +2 -2
  66. package/es/components/Tile/Tile.js +30 -36
  67. package/es/components/TileGroup/TileGroup.d.ts +4 -4
  68. package/es/components/TileGroup/TileGroup.js +45 -53
  69. package/es/components/TileGroup/index.d.ts +3 -3
  70. package/es/components/Toggletip/index.js +2 -2
  71. package/es/components/Tooltip/DefinitionTooltip.js +1 -0
  72. package/es/components/TreeView/TreeNode.js +3 -3
  73. package/es/components/TreeView/TreeView.js +3 -3
  74. package/es/components/UIShell/Content.d.ts +5 -3
  75. package/es/components/UIShell/HeaderMenuItem.js +2 -1
  76. package/es/components/UIShell/HeaderPanel.d.ts +2 -2
  77. package/es/components/UIShell/HeaderPanel.js +9 -5
  78. package/es/index.js +1 -1
  79. package/es/internal/Selection.js +8 -3
  80. package/es/internal/environment.js +1 -12
  81. package/es/internal/{__mocks__/mockHTMLElement.d.ts → index.d.ts} +2 -4
  82. package/es/internal/useOverflowItems.d.ts +29 -0
  83. package/es/internal/useOverflowItems.js +122 -0
  84. package/es/internal/useResizeObserver.d.ts +1 -1
  85. package/es/internal/utils.d.ts +14 -0
  86. package/es/internal/utils.js +18 -0
  87. package/es/tools/uniqueId.d.ts +1 -6
  88. package/lib/components/AILabel/index.js +6 -1
  89. package/lib/components/Checkbox/Checkbox.d.ts +2 -2
  90. package/lib/components/Checkbox/Checkbox.js +7 -7
  91. package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
  92. package/lib/components/CheckboxGroup/CheckboxGroup.js +8 -7
  93. package/lib/components/CodeSnippet/CodeSnippet.js +2 -4
  94. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  95. package/lib/components/ComboBox/ComboBox.js +11 -10
  96. package/lib/components/ComposedModal/ComposedModal.d.ts +1 -1
  97. package/lib/components/ComposedModal/ComposedModal.js +35 -13
  98. package/lib/components/ContainedList/ContainedList.d.ts +1 -1
  99. package/lib/components/ContainedList/ContainedList.js +4 -2
  100. package/lib/components/ContentSwitcher/ContentSwitcher.js +5 -4
  101. package/lib/components/DataTable/DataTable.js +3 -0
  102. package/lib/components/DataTable/TableDecoratorRow.d.ts +2 -2
  103. package/lib/components/DataTable/TableDecoratorRow.js +8 -8
  104. package/lib/components/DataTable/TableExpandRow.d.ts +1 -1
  105. package/lib/components/DataTable/TableExpandRow.js +14 -5
  106. package/lib/components/DataTable/TableHeader.js +9 -9
  107. package/lib/components/DataTable/TableRow.js +11 -3
  108. package/lib/components/DataTable/tools/normalize.js +2 -1
  109. package/lib/components/DatePickerInput/DatePickerInput.js +7 -6
  110. package/lib/components/Dialog/index.d.ts +5 -1
  111. package/lib/components/Dialog/index.js +20 -0
  112. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  113. package/lib/components/Dropdown/Dropdown.js +12 -14
  114. package/lib/components/FileUploader/FileUploaderButton.js +2 -2
  115. package/lib/components/FileUploader/FileUploaderDropContainer.js +2 -2
  116. package/lib/components/FileUploader/FileUploaderItem.js +2 -2
  117. package/lib/components/Layer/index.d.ts +1 -3
  118. package/lib/components/Layer/index.js +9 -8
  119. package/lib/components/Menu/Menu.js +0 -6
  120. package/lib/components/Modal/Modal.d.ts +2 -2
  121. package/lib/components/Modal/Modal.js +47 -19
  122. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  123. package/lib/components/MultiSelect/FilterableMultiSelect.js +33 -11
  124. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  125. package/lib/components/MultiSelect/MultiSelect.js +13 -12
  126. package/lib/components/NumberInput/NumberInput.d.ts +1 -1
  127. package/lib/components/NumberInput/NumberInput.js +8 -7
  128. package/lib/components/OverflowMenu/OverflowMenu.js +4 -5
  129. package/lib/components/PageHeader/PageHeader.d.ts +10 -9
  130. package/lib/components/PageHeader/PageHeader.js +92 -34
  131. package/lib/components/PageHeader/index.d.ts +2 -2
  132. package/lib/components/PageHeader/index.js +0 -2
  133. package/lib/components/Popover/index.js +2 -1
  134. package/lib/components/RadioButton/RadioButton.d.ts +2 -2
  135. package/lib/components/RadioButton/RadioButton.js +7 -7
  136. package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
  137. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +10 -9
  138. package/lib/components/RadioTile/RadioTile.d.ts +1 -1
  139. package/lib/components/RadioTile/RadioTile.js +7 -6
  140. package/lib/components/Search/Search.js +0 -1
  141. package/lib/components/Select/Select.d.ts +2 -2
  142. package/lib/components/Select/Select.js +7 -6
  143. package/lib/components/Slider/Slider.js +6 -0
  144. package/lib/components/Tag/DismissibleTag.d.ts +1 -1
  145. package/lib/components/Tag/DismissibleTag.js +8 -7
  146. package/lib/components/Tag/Tag.d.ts +1 -1
  147. package/lib/components/Tag/Tag.js +8 -7
  148. package/lib/components/TextArea/TextArea.js +11 -10
  149. package/lib/components/TextInput/TextInput.d.ts +1 -1
  150. package/lib/components/TextInput/TextInput.js +19 -8
  151. package/lib/components/Tile/Tile.d.ts +2 -2
  152. package/lib/components/Tile/Tile.js +29 -35
  153. package/lib/components/TileGroup/TileGroup.d.ts +4 -4
  154. package/lib/components/TileGroup/TileGroup.js +44 -52
  155. package/lib/components/TileGroup/index.d.ts +3 -3
  156. package/lib/components/Toggletip/index.js +2 -2
  157. package/lib/components/Tooltip/DefinitionTooltip.js +1 -0
  158. package/lib/components/TreeView/TreeNode.js +3 -3
  159. package/lib/components/TreeView/TreeView.js +3 -3
  160. package/lib/components/UIShell/Content.d.ts +5 -3
  161. package/lib/components/UIShell/HeaderMenuItem.js +2 -1
  162. package/lib/components/UIShell/HeaderPanel.d.ts +2 -2
  163. package/lib/components/UIShell/HeaderPanel.js +8 -4
  164. package/lib/index.js +1 -1
  165. package/lib/internal/Selection.js +8 -3
  166. package/lib/internal/environment.js +1 -12
  167. package/lib/internal/{__mocks__/mockHTMLElement.d.ts → index.d.ts} +2 -4
  168. package/lib/internal/useOverflowItems.d.ts +29 -0
  169. package/lib/internal/useOverflowItems.js +126 -0
  170. package/lib/internal/useResizeObserver.d.ts +1 -1
  171. package/lib/internal/utils.d.ts +14 -0
  172. package/lib/internal/utils.js +22 -0
  173. package/lib/tools/uniqueId.d.ts +1 -6
  174. package/package.json +14 -23
  175. package/telemetry.yml +3 -0
  176. package/es/tools/uniqueId.js +0 -14
  177. package/lib/tools/uniqueId.js +0 -18
@@ -0,0 +1,122 @@
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
+ import { useRef, useState, useMemo, useEffect } from 'react';
9
+ import { useResizeObserver } from './useResizeObserver.js';
10
+ import { usePreviousValue } from './usePreviousValue.js';
11
+
12
+ /**
13
+ * Manages overflow items in a container by automatically hiding items that don't fit.
14
+ * @param items - Array of items to manage for overflow, each must have an `id` property.
15
+ * @param containerRef - React ref to the container element that holds the items.
16
+ * @param offsetRef - Optional ref to an offset element (like a "more" button) whose width is reserved when calculating available space.
17
+ * @param maxItems - Optional maximum number of visible items. If undefined, only container space constrains visibility.
18
+ * @param onChange - Optional callback called when hidden items change. Receives array of currently hidden items.
19
+ * @returns Object with `visibleItems` (items to display), `hiddenItems` (items that don't fit), and `itemRefHandler` (function to attach refs to items for width measurement).
20
+ */
21
+
22
+ const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) => {
23
+ const itemsRef = useRef(null);
24
+ const [maxWidth, setMaxWidth] = useState(0);
25
+ if (!items || !Array.isArray(items)) {
26
+ return {
27
+ visibleItems: [],
28
+ hiddenItems: [],
29
+ itemRefHandler: () => {}
30
+ };
31
+ }
32
+ const handleResize = () => {
33
+ if (containerRef.current) {
34
+ const offset = offsetRef?.current?.offsetWidth || 0;
35
+ const newMax = containerRef.current.offsetWidth - offset;
36
+ setMaxWidth(newMax);
37
+ }
38
+ };
39
+ useResizeObserver({
40
+ ref: containerRef,
41
+ onResize: handleResize
42
+ });
43
+ const getMap = () => {
44
+ if (!itemsRef.current) {
45
+ itemsRef.current = new Map();
46
+ }
47
+ return itemsRef.current;
48
+ };
49
+ const itemRefHandler = (id, node) => {
50
+ const map = getMap();
51
+ if (node) {
52
+ const style = getComputedStyle?.(node);
53
+ const totalWidth = node.offsetWidth + parseInt(style.marginLeft) + parseInt(style.marginRight);
54
+ map.set(id, totalWidth);
55
+ }
56
+ return () => {
57
+ map.delete(id);
58
+ };
59
+ };
60
+ const getVisibleItems = () => {
61
+ if (!items || Array.isArray(items) === false) {
62
+ return [];
63
+ }
64
+ if (!containerRef) {
65
+ return items;
66
+ }
67
+ const map = getMap();
68
+ let maxReached = false;
69
+ let accumulatedWidth = 0;
70
+ const visibleItems = items.slice(0, maxItems).reduce((prev, cur) => {
71
+ if (maxReached) {
72
+ return prev;
73
+ }
74
+ const itemWidth = map.get(cur.id) || 0;
75
+ const willFit = accumulatedWidth + itemWidth <= maxWidth;
76
+ if (willFit) {
77
+ accumulatedWidth += itemWidth;
78
+ prev.push(cur);
79
+ } else {
80
+ maxReached = true;
81
+ }
82
+ return prev;
83
+ }, []);
84
+ return visibleItems;
85
+ };
86
+
87
+ // Memoize visible items calculation to avoid recalculating on every render
88
+ const visibleItems = useMemo(() => {
89
+ if (!Array.isArray(items)) {
90
+ return [];
91
+ }
92
+ return getVisibleItems();
93
+ }, [items, maxWidth, maxItems]);
94
+
95
+ // Memoize hidden items calculation
96
+ const hiddenItems = useMemo(() => {
97
+ if (!Array.isArray(items)) {
98
+ return [];
99
+ }
100
+ return items.slice(visibleItems.length);
101
+ }, [items, visibleItems]);
102
+
103
+ // Use previous value to compare and only call onChange when needed
104
+ const previousHiddenItems = usePreviousValue(hiddenItems);
105
+
106
+ // Only call onChange if hidden items actually changed
107
+ useEffect(() => {
108
+ if (previousHiddenItems && onChange) {
109
+ const hasChanged = hiddenItems.length !== previousHiddenItems.length || hiddenItems.some((item, index) => item !== previousHiddenItems[index]);
110
+ if (hasChanged) {
111
+ onChange(hiddenItems);
112
+ }
113
+ }
114
+ }, [hiddenItems, previousHiddenItems, onChange]);
115
+ return {
116
+ visibleItems,
117
+ itemRefHandler,
118
+ hiddenItems
119
+ };
120
+ };
121
+
122
+ export { useOverflowItems as default };
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { RefObject } from 'react';
8
8
  export declare const useResizeObserver: ({ ref, onResize, }: {
9
- ref: RefObject<HTMLElement>;
9
+ ref: RefObject<HTMLElement | null>;
10
10
  onResize?: (rect: DOMRectReadOnly) => void;
11
11
  }) => {
12
12
  width: number;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright IBM Corp. 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 ComponentType, type ReactElement, type ReactNode } from 'react';
8
+ /**
9
+ * Checks if an element is a valid React element of a given component type.
10
+ *
11
+ * @param element - The element to test.
12
+ * @param component - The component to match.
13
+ */
14
+ export declare const isComponentElement: <P>(element: ReactNode, component: ComponentType<P>) => element is ReactElement<P>;
@@ -0,0 +1,18 @@
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
+ import { isValidElement } from 'react';
9
+
10
+ /**
11
+ * Checks if an element is a valid React element of a given component type.
12
+ *
13
+ * @param element - The element to test.
14
+ * @param component - The component to match.
15
+ */
16
+ const isComponentElement = (element, component) => /*#__PURE__*/isValidElement(element) && element.type === component;
17
+
18
+ export { isComponentElement };
@@ -1,7 +1,2 @@
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
- */
1
+ export declare const uniqueIdDeprecationMessage = "The `uniqueId()` helper function from @carbon/react was called. This function should no longer be used.\n\n@carbon/react components should use the internal/useId.js hook instead. Other projects can use React's `useId()` hook: https://react.dev/reference/react/useId";
7
2
  export declare const uniqueId: (prefix?: string) => string;
@@ -37,7 +37,12 @@ const AILabelContent = /*#__PURE__*/React__default["default"].forwardRef(functio
37
37
  const prefix = usePrefix.usePrefix();
38
38
  const hasAILabelActions = React__default["default"].Children.toArray(children).some(child => {
39
39
  const item = child;
40
- item.type?.displayName === 'AILabelActions';
40
+ // TODO: Is there supposed to be a `return` here? If so, this issue would
41
+ // have been caught by ESLint. It's concerning that this code is 7 months
42
+ // old and no one has noticed any issues with it. It also makes me question
43
+ // whether the code is necessary.
44
+ // https://github.com/carbon-design-system/carbon/issues/18991
45
+ item.type === AILabelActions;
41
46
  });
42
47
  const aiLabelContentClasses = cx__default["default"](className, {
43
48
  [`${prefix}--ai-label-content`]: true,
@@ -1,10 +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
- import React, { ReactNode } from 'react';
7
+ import React, { type ReactNode } from 'react';
8
8
  type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type';
9
9
  export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
10
10
  /**
@@ -19,6 +19,8 @@ var usePrefix = require('../../internal/usePrefix.js');
19
19
  var iconsReact = require('@carbon/icons-react');
20
20
  var useId = require('../../internal/useId.js');
21
21
  var noopFn = require('../../internal/noopFn.js');
22
+ var index = require('../AILabel/index.js');
23
+ var utils = require('../../internal/utils.js');
22
24
  var Text = require('../Text/Text.js');
23
25
 
24
26
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -65,13 +67,11 @@ const Checkbox = /*#__PURE__*/React__default["default"].forwardRef(({
65
67
  const innerLabelClasses = cx__default["default"](`${prefix}--checkbox-label-text`, {
66
68
  [`${prefix}--visually-hidden`]: hideLabel
67
69
  });
68
- let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
69
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
70
- const size = normalizedDecorator.props?.['kind'] === 'inline' ? 'md' : 'mini';
71
- normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
72
- size
73
- });
74
- }
70
+ const candidate = slug ?? decorator;
71
+ const candidateIsAILabel = utils.isComponentElement(candidate, index.AILabel);
72
+ const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
73
+ size: candidate.props.kind === 'inline' ? 'md' : 'mini'
74
+ }) : null;
75
75
  return /*#__PURE__*/React__default["default"].createElement("div", {
76
76
  className: wrapperClasses
77
77
  }, /*#__PURE__*/React__default["default"].createElement("input", _rollupPluginBabelHelpers["extends"]({}, other, {
@@ -1,10 +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
- import React, { ReactNode } from 'react';
7
+ import React, { type ReactNode } from 'react';
8
8
  export interface CheckboxGroupProps {
9
9
  children?: ReactNode;
10
10
  className?: string;
@@ -17,6 +17,8 @@ var deprecate = require('../../prop-types/deprecate.js');
17
17
  var usePrefix = require('../../internal/usePrefix.js');
18
18
  var iconsReact = require('@carbon/icons-react');
19
19
  var useId = require('../../internal/useId.js');
20
+ var index = require('../AILabel/index.js');
21
+ var utils = require('../../internal/utils.js');
20
22
 
21
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
24
 
@@ -59,13 +61,12 @@ const CheckboxGroup = ({
59
61
  });
60
62
 
61
63
  // AILabel always size `mini`
62
- let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
63
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
64
- normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
65
- size: 'mini',
66
- kind: 'default'
67
- });
68
- }
64
+ const candidate = slug ?? decorator;
65
+ const candidateIsAILabel = utils.isComponentElement(candidate, index.AILabel);
66
+ const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
67
+ size: 'mini',
68
+ kind: 'default'
69
+ }) : null;
69
70
  return /*#__PURE__*/React__default["default"].createElement("fieldset", _rollupPluginBabelHelpers["extends"]({
70
71
  className: fieldsetClasses,
71
72
  "data-invalid": invalid ? true : undefined,
@@ -19,7 +19,7 @@ var Copy = require('../Copy/Copy.js');
19
19
  var Button = require('../Button/Button.js');
20
20
  require('../Button/Button.Skeleton.js');
21
21
  var CopyButton = require('../CopyButton/CopyButton.js');
22
- var uniqueId = require('../../tools/uniqueId.js');
22
+ var useId = require('../../internal/useId.js');
23
23
  var copy = require('copy-to-clipboard');
24
24
  var deprecate = require('../../prop-types/deprecate.js');
25
25
  var usePrefix = require('../../internal/usePrefix.js');
@@ -67,7 +67,7 @@ function CodeSnippet({
67
67
  const [shouldShowMoreLessBtn, setShouldShowMoreLessBtn] = React.useState(false);
68
68
  const {
69
69
  current: uid
70
- } = React.useRef(uniqueId.uniqueId());
70
+ } = React.useRef(useId.useId());
71
71
  const codeContentRef = React.useRef(null);
72
72
  const codeContainerRef = React.useRef(null);
73
73
  const innerCodeRef = React.useRef(null);
@@ -111,8 +111,6 @@ function CodeSnippet({
111
111
  setHasRightOverflow(horizontalOverflow && codeScrollLeft + codeClientWidth !== codeScrollWidth);
112
112
  }, [type, getCodeRefDimensions]);
113
113
  useResizeObserver.useResizeObserver({
114
- // Cast the ref until the hook supports React 19
115
- // https://github.com/ZeeCoder/use-resize-observer/issues/108
116
114
  ref: getCodeRef(),
117
115
  onResize: () => {
118
116
  if (codeContentRef?.current && type === 'multi') {
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { UseComboboxProps, UseComboboxActions } from 'downshift';
8
- import React, { type ReactNode, type ComponentType, type ReactElement, type RefAttributes, type PropsWithChildren, type PropsWithRef, type InputHTMLAttributes, type MouseEvent } from 'react';
8
+ import React, { type ComponentType, type InputHTMLAttributes, type MouseEvent, type PropsWithChildren, type PropsWithRef, type ReactElement, type ReactNode, type RefAttributes } from 'react';
9
9
  import { type ListBoxSize } from '../ListBox';
10
10
  import { TranslateWithId } from '../../types/common';
11
11
  type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type' | 'size';
@@ -17,7 +17,7 @@ var React = require('react');
17
17
  require('../Text/index.js');
18
18
  var iconsReact = require('@carbon/icons-react');
19
19
  var isEqual = require('react-fast-compare');
20
- var index$1 = require('../ListBox/index.js');
20
+ var index$2 = require('../ListBox/index.js');
21
21
  var ListBoxSelection = require('../ListBox/next/ListBoxSelection.js');
22
22
  var ListBoxTrigger = require('../ListBox/next/ListBoxTrigger.js');
23
23
  var keys = require('../../internal/keyboard/keys.js');
@@ -30,6 +30,8 @@ require('../FluidForm/FluidForm.js');
30
30
  var FormContext = require('../FluidForm/FormContext.js');
31
31
  var react = require('@floating-ui/react');
32
32
  var index = require('../FeatureFlags/index.js');
33
+ var index$1 = require('../AILabel/index.js');
34
+ var utils = require('../../internal/utils.js');
33
35
  var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
34
36
  var Text = require('../Text/Text.js');
35
37
 
@@ -448,12 +450,11 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
448
450
  const ItemToElement = itemToElement;
449
451
 
450
452
  // AILabel always size `mini`
451
- let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
452
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
453
- normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
454
- size: 'mini'
455
- });
456
- }
453
+ const candidate = slug ?? decorator;
454
+ const candidateIsAILabel = utils.isComponentElement(candidate, index$1.AILabel);
455
+ const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
456
+ size: 'mini'
457
+ }) : null;
457
458
  const {
458
459
  // Prop getters
459
460
  getInputProps,
@@ -604,7 +605,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
604
605
  }, titleText && /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["extends"]({
605
606
  as: "label",
606
607
  className: titleClasses
607
- }, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index$1["default"], {
608
+ }, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index$2["default"], {
608
609
  onFocus: handleFocus,
609
610
  onBlur: handleFocus,
610
611
  className: className,
@@ -728,7 +729,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
728
729
  translateWithId: translateWithId
729
730
  }))), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
730
731
  className: `${prefix}--list-box__inner-wrapper--decorator`
731
- }, normalizedDecorator) : '', /*#__PURE__*/React__default["default"].createElement(index$1["default"].Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
732
+ }, normalizedDecorator) : '', /*#__PURE__*/React__default["default"].createElement(index$2["default"].Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
732
733
  const isObject = item !== null && typeof item === 'object';
733
734
  const title = isObject && 'text' in item && itemToElement ? item.text?.toString() : itemToString(item);
734
735
  const itemProps = getItemProps({
@@ -746,7 +747,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
746
747
  // eslint-disable-line @typescript-eslint/no-unused-vars
747
748
  ...modifiedItemProps
748
749
  } = itemProps;
749
- return /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
750
+ return /*#__PURE__*/React__default["default"].createElement(index$2["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
750
751
  key: itemProps.id,
751
752
  isActive: selectedItem === item,
752
753
  isHighlighted: highlightedIndex === index,
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, { type MouseEvent, type KeyboardEvent, type HTMLAttributes, type ReactNode, type RefObject } from 'react';
7
+ import React, { type HTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactNode, type RefObject } from 'react';
8
8
  export interface ModalBodyProps extends HTMLAttributes<HTMLDivElement> {
9
9
  /** Specify the content to be placed in the ModalBody. */
10
10
  children?: ReactNode;
@@ -28,8 +28,10 @@ var match = require('../../internal/keyboard/match.js');
28
28
  var index$1 = require('../FeatureFlags/index.js');
29
29
  var events = require('../../tools/events.js');
30
30
  var deprecate = require('../../prop-types/deprecate.js');
31
- var index$2 = require('../Dialog/index.js');
31
+ var index$3 = require('../Dialog/index.js');
32
32
  var warning = require('../../internal/warning.js');
33
+ var index$2 = require('../AILabel/index.js');
34
+ var utils = require('../../internal/utils.js');
33
35
  var debounce = require('../../node_modules/es-toolkit/dist/compat/function/debounce.mjs.js');
34
36
 
35
37
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -178,7 +180,10 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
178
180
  } = evt;
179
181
  const mouseDownTarget = onMouseDownTarget.current;
180
182
  evt.stopPropagation();
181
- if (!preventCloseOnClickOutside && target instanceof Node && !wrapFocus.elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target) && !innerModal.current.contains(mouseDownTarget)) {
183
+ const containsModalFooter = React.Children.toArray(childrenWithProps).some(child => utils.isComponentElement(child, ModalFooter.ModalFooter));
184
+ const isPassive = !containsModalFooter;
185
+ const shouldCloseOnOutsideClick = isPassive ? preventCloseOnClickOutside !== false : preventCloseOnClickOutside === true;
186
+ if (shouldCloseOnOutsideClick && target instanceof Node && !wrapFocus.elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target) && !innerModal.current.contains(mouseDownTarget)) {
182
187
  closeModal(evt);
183
188
  }
184
189
  }
@@ -186,7 +191,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
186
191
  target: oldActiveNode,
187
192
  relatedTarget: currentActiveNode
188
193
  }) {
189
- if (open && currentActiveNode && oldActiveNode && innerModal.current) {
194
+ if (!enableDialogElement && !focusTrapWithoutSentinels && open && currentActiveNode && oldActiveNode && innerModal.current) {
190
195
  const {
191
196
  current: bodyNode
192
197
  } = innerModal;
@@ -205,6 +210,23 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
205
210
  selectorsFloatingMenus: selectorsFloatingMenus?.filter(Boolean)
206
211
  });
207
212
  }
213
+
214
+ // Adjust scroll if needed so that element with focus is not obscured by gradient
215
+ const modalContent = document.querySelector(`.${prefix}--modal-content`);
216
+ if (!modalContent || !modalContent.classList.contains(`${prefix}--modal-scroll-content`) || !currentActiveNode || !modalContent.contains(currentActiveNode)) {
217
+ return;
218
+ }
219
+ const lastContent = modalContent.children[modalContent.children.length - 1];
220
+ const gradientSpacing = modalContent.scrollHeight - lastContent.offsetTop - lastContent.clientHeight;
221
+ for (let elem of modalContent.children) {
222
+ if (elem.contains(currentActiveNode)) {
223
+ const spaceBelow = modalContent.clientHeight - elem.offsetTop + modalContent.scrollTop - elem.clientHeight;
224
+ if (spaceBelow < gradientSpacing) {
225
+ modalContent.scrollTop = modalContent.scrollTop + (gradientSpacing - spaceBelow);
226
+ }
227
+ break;
228
+ }
229
+ }
208
230
  }
209
231
  function closeModal(evt) {
210
232
  if (!onClose || onClose(evt) !== false) {
@@ -247,10 +269,10 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
247
269
  React.useEffect(() => {
248
270
  if (!enableDialogElement && !open && launcherButtonRef) {
249
271
  setTimeout(() => {
250
- launcherButtonRef?.current?.focus();
272
+ launcherButtonRef.current?.focus();
251
273
  });
252
274
  }
253
- }, [open, launcherButtonRef]);
275
+ }, [enableDialogElement, open, launcherButtonRef]);
254
276
  React.useEffect(() => {
255
277
  if (!enableDialogElement) {
256
278
  const initialFocus = focusContainerElement => {
@@ -277,14 +299,14 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
277
299
  }, [open, selectorPrimaryFocus, isOpen]);
278
300
 
279
301
  // AILabel is always size `sm`
280
- let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
281
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
282
- normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
283
- size: 'sm'
284
- });
285
- }
286
- const modalBody = enableDialogElement ? /*#__PURE__*/React__default["default"].createElement(index$2.unstable__Dialog, {
302
+ const candidate = slug ?? decorator;
303
+ const candidateIsAILabel = utils.isComponentElement(candidate, index$2.AILabel);
304
+ const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
305
+ size: 'sm'
306
+ }) : null;
307
+ const modalBody = enableDialogElement ? /*#__PURE__*/React__default["default"].createElement(index$3.unstable__Dialog, {
287
308
  open: open,
309
+ focusAfterCloseRef: launcherButtonRef,
288
310
  modal: true,
289
311
  className: containerClass,
290
312
  "aria-label": ariaLabel ? ariaLabel : generatedAriaLabel,
@@ -319,7 +341,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
319
341
  role: "presentation",
320
342
  ref: ref,
321
343
  "aria-hidden": !open,
322
- onBlur: !enableDialogElement && !focusTrapWithoutSentinels ? handleBlur : () => {},
344
+ onBlur: handleBlur,
323
345
  onClick: events.composeEventHandlers([rest?.onClick, handleOnClick]),
324
346
  onMouseDown: events.composeEventHandlers([rest?.onMouseDown, handleOnMouseDown]),
325
347
  onKeyDown: handleKeyDown,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2022
2
+ * Copyright IBM Corp. 2022, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -17,6 +17,8 @@ var index = require('../Layout/index.js');
17
17
  var useId = require('../../internal/useId.js');
18
18
  var usePrefix = require('../../internal/usePrefix.js');
19
19
  var ContainedListItem = require('./ContainedListItem/ContainedListItem.js');
20
+ var Search = require('../Search/Search.js');
21
+ require('../Search/Search.Skeleton.js');
20
22
 
21
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
24
 
@@ -37,13 +39,13 @@ function filterChildren(children) {
37
39
  function renderChildren(children) {
38
40
  if (Array.isArray(children)) {
39
41
  children.map((child, index) => {
40
- if (index === 0 && child.type?.displayName === 'Search') {
42
+ if (index === 0 && child.type === Search["default"]) {
41
43
  return child;
42
44
  }
43
45
  return child;
44
46
  });
45
47
  }
46
- if (children && children.type?.displayName === 'Search') {
48
+ if (children && children.type === Search["default"]) {
47
49
  return children;
48
50
  }
49
51
  return children;
@@ -21,6 +21,8 @@ var match = require('../../internal/keyboard/match.js');
21
21
  var navigation = require('../../internal/keyboard/navigation.js');
22
22
  var usePrefix = require('../../internal/usePrefix.js');
23
23
  var noopFn = require('../../internal/noopFn.js');
24
+ require('../Switch/Switch.js');
25
+ var IconSwitch = require('../Switch/IconSwitch.js');
24
26
 
25
27
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
26
28
 
@@ -89,10 +91,9 @@ const ContentSwitcher = ({
89
91
  onChange(event);
90
92
  }
91
93
  };
92
- const isIconOnly = childrenArray.every(
93
- // TODO: Update this code when
94
- // https://github.com/carbon-design-system/carbon/pull/18971 is merged.
95
- child => child.type.displayName === 'IconSwitch');
94
+ const isIconOnly = React.Children.map(children, child => {
95
+ return /*#__PURE__*/React.isValidElement(child) ? child.type === IconSwitch["default"] : null;
96
+ })?.every(val => val === true);
96
97
  const classes = cx__default["default"](`${prefix}--content-switcher`, className, {
97
98
  [`${prefix}--content-switcher--light`]: light,
98
99
  [`${prefix}--content-switcher--${size}`]: size,
@@ -185,6 +185,7 @@ class DataTable extends React.Component {
185
185
  return {
186
186
  ...rest,
187
187
  key: row.id,
188
+ onClick,
188
189
  // Compose the event handlers so we don't overwrite a consumer's `onClick`
189
190
  // handler
190
191
  onExpand: events.composeEventHandlers([this.handleOnExpandRow(row.id), onClick]),
@@ -307,6 +308,8 @@ class DataTable extends React.Component {
307
308
  useStaticWidth
308
309
  };
309
310
  });
311
+ // TODO: `getHeaderProps` and `getRowProps` return `key` props. Would it be
312
+ // beneficial for this function to also return a `key` prop?
310
313
  /**
311
314
  * Get the props associated with the given table cell.
312
315
  */
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
- import { ReactNode } from 'react';
8
+ import { type ReactNode } from 'react';
9
9
  export interface TableDecoratorRowProps {
10
10
  /**
11
11
  * The CSS class names of the cell that wraps the underlying input control
@@ -9,16 +9,18 @@
9
9
 
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
+ var cx = require('classnames');
12
13
  var PropTypes = require('prop-types');
13
14
  var React = require('react');
14
- var cx = require('classnames');
15
15
  var usePrefix = require('../../internal/usePrefix.js');
16
+ var index = require('../AILabel/index.js');
17
+ var utils = require('../../internal/utils.js');
16
18
 
17
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
20
 
21
+ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
19
22
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
20
23
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
21
- var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
22
24
 
23
25
  const TableDecoratorRow = ({
24
26
  className,
@@ -32,12 +34,10 @@ const TableDecoratorRow = ({
32
34
  [`${prefix}--table-column-decorator`]: true,
33
35
  [`${prefix}--table-column-decorator--active`]: decorator
34
36
  });
35
- let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(decorator) ? decorator : null;
36
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
37
- normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
38
- size: 'mini'
39
- });
40
- }
37
+ const decoratorIsAILabel = utils.isComponentElement(decorator, index.AILabel);
38
+ const normalizedDecorator = decoratorIsAILabel ? /*#__PURE__*/React.cloneElement(decorator, {
39
+ size: 'mini'
40
+ }) : null;
41
41
  return /*#__PURE__*/React__default["default"].createElement("td", {
42
42
  className: TableDecoratorRowClasses
43
43
  }, normalizedDecorator);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.