@carbon/react 1.84.0 → 1.85.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 (181) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +899 -829
  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 +15 -10
  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/DatePicker/DatePicker.d.ts +1 -1
  24. package/es/components/DatePicker/DatePicker.js +2 -2
  25. package/es/components/DatePicker/plugins/appendToPlugin.d.ts +12 -0
  26. package/es/components/DatePicker/plugins/appendToPlugin.js +9 -12
  27. package/es/components/DatePickerInput/DatePickerInput.js +8 -7
  28. package/es/components/Dialog/index.d.ts +5 -1
  29. package/es/components/Dialog/index.js +20 -0
  30. package/es/components/Dropdown/Dropdown.d.ts +1 -1
  31. package/es/components/Dropdown/Dropdown.js +8 -10
  32. package/es/components/FileUploader/FileUploaderButton.js +2 -2
  33. package/es/components/FileUploader/FileUploaderDropContainer.js +2 -2
  34. package/es/components/FileUploader/FileUploaderItem.js +2 -2
  35. package/es/components/Layer/index.d.ts +1 -3
  36. package/es/components/Layer/index.js +9 -8
  37. package/es/components/Menu/Menu.js +7 -8
  38. package/es/components/Menu/MenuItem.js +13 -2
  39. package/es/components/Modal/Modal.d.ts +2 -2
  40. package/es/components/Modal/Modal.js +20 -9
  41. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  42. package/es/components/MultiSelect/FilterableMultiSelect.js +9 -8
  43. package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
  44. package/es/components/MultiSelect/MultiSelect.js +8 -7
  45. package/es/components/MultiSelect/filter.d.ts +10 -0
  46. package/es/components/MultiSelect/filter.js +21 -0
  47. package/es/components/NumberInput/NumberInput.d.ts +1 -1
  48. package/es/components/NumberInput/NumberInput.js +9 -8
  49. package/es/components/PageHeader/PageHeader.js +2 -2
  50. package/es/components/Popover/index.js +2 -1
  51. package/es/components/RadioButton/RadioButton.d.ts +2 -2
  52. package/es/components/RadioButton/RadioButton.js +8 -8
  53. package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
  54. package/es/components/RadioButtonGroup/RadioButtonGroup.js +9 -8
  55. package/es/components/RadioTile/RadioTile.d.ts +1 -1
  56. package/es/components/RadioTile/RadioTile.js +8 -7
  57. package/es/components/Select/Select.d.ts +2 -2
  58. package/es/components/Select/Select.js +8 -7
  59. package/es/components/Slider/Slider.d.ts +59 -198
  60. package/es/components/Slider/Slider.js +68 -120
  61. package/es/components/Tabs/usePressable.d.ts +19 -0
  62. package/es/components/Tabs/usePressable.js +19 -33
  63. package/es/components/Tag/DismissibleTag.d.ts +1 -1
  64. package/es/components/Tag/DismissibleTag.js +9 -8
  65. package/es/components/Tag/Tag.d.ts +1 -1
  66. package/es/components/Tag/Tag.js +9 -8
  67. package/es/components/TextArea/TextArea.js +8 -7
  68. package/es/components/TextInput/TextInput.d.ts +1 -1
  69. package/es/components/TextInput/TextInput.js +20 -9
  70. package/es/components/Tile/Tile.d.ts +2 -2
  71. package/es/components/Tile/Tile.js +30 -36
  72. package/es/components/Toggletip/index.js +2 -2
  73. package/es/components/Tooltip/DefinitionTooltip.js +1 -0
  74. package/es/components/Tooltip/Tooltip.d.ts +2 -2
  75. package/es/components/Tooltip/Tooltip.js +2 -2
  76. package/es/components/TreeView/TreeNode.d.ts +22 -0
  77. package/es/components/TreeView/TreeNode.js +119 -12
  78. package/es/components/TreeView/TreeView.js +3 -3
  79. package/es/components/UIShell/Content.d.ts +5 -3
  80. package/es/components/UIShell/HeaderPanel.d.ts +2 -2
  81. package/es/components/UIShell/HeaderPanel.js +9 -5
  82. package/es/internal/Selection.js +8 -3
  83. package/es/internal/environment.js +1 -12
  84. package/{lib/internal/__mocks__/mockHTMLElement.d.ts → es/internal/index.d.ts} +2 -4
  85. package/es/internal/useResizeObserver.d.ts +1 -1
  86. package/es/internal/utils.d.ts +14 -0
  87. package/es/internal/utils.js +18 -0
  88. package/es/tools/uniqueId.d.ts +1 -6
  89. package/lib/components/AILabel/index.js +6 -1
  90. package/lib/components/Checkbox/Checkbox.d.ts +2 -2
  91. package/lib/components/Checkbox/Checkbox.js +7 -7
  92. package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
  93. package/lib/components/CheckboxGroup/CheckboxGroup.js +8 -7
  94. package/lib/components/CodeSnippet/CodeSnippet.js +2 -4
  95. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  96. package/lib/components/ComboBox/ComboBox.js +11 -10
  97. package/lib/components/ComposedModal/ComposedModal.d.ts +1 -1
  98. package/lib/components/ComposedModal/ComposedModal.js +16 -11
  99. package/lib/components/ContainedList/ContainedList.d.ts +1 -1
  100. package/lib/components/ContainedList/ContainedList.js +4 -2
  101. package/lib/components/ContentSwitcher/ContentSwitcher.js +5 -4
  102. package/lib/components/DataTable/DataTable.js +3 -0
  103. package/lib/components/DataTable/TableDecoratorRow.d.ts +2 -2
  104. package/lib/components/DataTable/TableDecoratorRow.js +8 -8
  105. package/lib/components/DataTable/TableExpandRow.d.ts +1 -1
  106. package/lib/components/DataTable/TableExpandRow.js +14 -5
  107. package/lib/components/DataTable/TableHeader.js +9 -9
  108. package/lib/components/DataTable/TableRow.js +11 -3
  109. package/lib/components/DataTable/tools/normalize.js +2 -1
  110. package/lib/components/DatePicker/DatePicker.d.ts +1 -1
  111. package/lib/components/DatePicker/DatePicker.js +1 -1
  112. package/lib/components/DatePicker/plugins/appendToPlugin.d.ts +12 -0
  113. package/lib/components/DatePicker/plugins/appendToPlugin.js +9 -12
  114. package/lib/components/DatePickerInput/DatePickerInput.js +7 -6
  115. package/lib/components/Dialog/index.d.ts +5 -1
  116. package/lib/components/Dialog/index.js +20 -0
  117. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  118. package/lib/components/Dropdown/Dropdown.js +12 -14
  119. package/lib/components/FileUploader/FileUploaderButton.js +2 -2
  120. package/lib/components/FileUploader/FileUploaderDropContainer.js +2 -2
  121. package/lib/components/FileUploader/FileUploaderItem.js +2 -2
  122. package/lib/components/Layer/index.d.ts +1 -3
  123. package/lib/components/Layer/index.js +9 -8
  124. package/lib/components/Menu/Menu.js +7 -8
  125. package/lib/components/Menu/MenuItem.js +13 -2
  126. package/lib/components/Modal/Modal.d.ts +2 -2
  127. package/lib/components/Modal/Modal.js +28 -17
  128. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  129. package/lib/components/MultiSelect/FilterableMultiSelect.js +13 -12
  130. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  131. package/lib/components/MultiSelect/MultiSelect.js +13 -12
  132. package/lib/components/MultiSelect/filter.d.ts +10 -0
  133. package/lib/components/MultiSelect/filter.js +25 -0
  134. package/lib/components/NumberInput/NumberInput.d.ts +1 -1
  135. package/lib/components/NumberInput/NumberInput.js +8 -7
  136. package/lib/components/PageHeader/PageHeader.js +2 -2
  137. package/lib/components/Popover/index.js +2 -1
  138. package/lib/components/RadioButton/RadioButton.d.ts +2 -2
  139. package/lib/components/RadioButton/RadioButton.js +7 -7
  140. package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
  141. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +10 -9
  142. package/lib/components/RadioTile/RadioTile.d.ts +1 -1
  143. package/lib/components/RadioTile/RadioTile.js +7 -6
  144. package/lib/components/Select/Select.d.ts +2 -2
  145. package/lib/components/Select/Select.js +7 -6
  146. package/lib/components/Slider/Slider.d.ts +59 -198
  147. package/lib/components/Slider/Slider.js +67 -119
  148. package/lib/components/Tabs/usePressable.d.ts +19 -0
  149. package/lib/components/Tabs/usePressable.js +19 -33
  150. package/lib/components/Tag/DismissibleTag.d.ts +1 -1
  151. package/lib/components/Tag/DismissibleTag.js +8 -7
  152. package/lib/components/Tag/Tag.d.ts +1 -1
  153. package/lib/components/Tag/Tag.js +8 -7
  154. package/lib/components/TextArea/TextArea.js +7 -6
  155. package/lib/components/TextInput/TextInput.d.ts +1 -1
  156. package/lib/components/TextInput/TextInput.js +19 -8
  157. package/lib/components/Tile/Tile.d.ts +2 -2
  158. package/lib/components/Tile/Tile.js +29 -35
  159. package/lib/components/Toggletip/index.js +2 -2
  160. package/lib/components/Tooltip/DefinitionTooltip.js +1 -0
  161. package/lib/components/Tooltip/Tooltip.d.ts +2 -2
  162. package/lib/components/Tooltip/Tooltip.js +2 -2
  163. package/lib/components/TreeView/TreeNode.d.ts +22 -0
  164. package/lib/components/TreeView/TreeNode.js +118 -11
  165. package/lib/components/TreeView/TreeView.js +3 -3
  166. package/lib/components/UIShell/Content.d.ts +5 -3
  167. package/lib/components/UIShell/HeaderPanel.d.ts +2 -2
  168. package/lib/components/UIShell/HeaderPanel.js +8 -4
  169. package/lib/internal/Selection.js +8 -3
  170. package/lib/internal/environment.js +1 -12
  171. package/{es/internal/__mocks__/mockHTMLElement.d.ts → lib/internal/index.d.ts} +2 -4
  172. package/lib/internal/useResizeObserver.d.ts +1 -1
  173. package/lib/internal/utils.d.ts +14 -0
  174. package/lib/internal/utils.js +22 -0
  175. package/lib/tools/uniqueId.d.ts +1 -6
  176. package/package.json +11 -20
  177. package/telemetry.yml +1 -0
  178. package/es/components/ComboBox/tools/filter.js +0 -18
  179. package/es/tools/uniqueId.js +0 -14
  180. package/lib/components/ComboBox/tools/filter.js +0 -22
  181. package/lib/tools/uniqueId.js +0 -18
@@ -8,12 +8,13 @@
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import cx from 'classnames';
10
10
  import PropTypes from 'prop-types';
11
- import React, { useRef, useState } from 'react';
11
+ import React, { useRef, useState, isValidElement } from 'react';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
13
13
  import { Escape } from '../../internal/keyboard/keys.js';
14
14
  import { match } from '../../internal/keyboard/match.js';
15
15
  import { useWindowEvent } from '../../internal/useEvent.js';
16
16
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
17
+ import Switcher from './Switcher.js';
17
18
 
18
19
  const noopFn = () => {};
19
20
  const HeaderPanel = /*#__PURE__*/React.forwardRef(function HeaderPanel({
@@ -58,10 +59,13 @@ const HeaderPanel = /*#__PURE__*/React.forwardRef(function HeaderPanel({
58
59
  };
59
60
  }
60
61
  useWindowEvent('click', () => {
61
- const focusedElement = document.activeElement;
62
- setLastClickedElement(focusedElement);
63
- const childJsxElement = children;
64
- if (childJsxElement?.type?.displayName === 'Switcher' && !focusedElement?.closest(`.${prefix}--header-panel--expanded`) && !focusedElement?.closest(`.${prefix}--header__action`) && !headerPanelReference?.current?.classList.contains(`${prefix}--switcher`) && expanded) {
62
+ const {
63
+ activeElement
64
+ } = document;
65
+ if (!(activeElement instanceof HTMLElement)) return;
66
+ setLastClickedElement(activeElement);
67
+ const isChildASwitcher = /*#__PURE__*/isValidElement(children) && typeof children.type !== 'string' && children.type === Switcher;
68
+ if (isChildASwitcher && !activeElement.closest(`.${prefix}--header-panel--expanded`) && !activeElement.closest(`.${prefix}--header__action`) && !headerPanelReference?.current?.classList.contains(`${prefix}--switcher`) && expanded) {
65
69
  setExpandedState(false);
66
70
  onHeaderPanelFocus();
67
71
  }
@@ -17,9 +17,14 @@ const callOnChangeHandler = ({
17
17
  }) => {
18
18
  if (isControlled) {
19
19
  if (isMounted && onChangeHandlerControlled) {
20
- onChangeHandlerControlled({
21
- selectedItems
22
- });
20
+ // Use setTimeout to defer the controlled onChange call,
21
+ // avoiding React’s warning: "Cannot update a component while rendering a different component".
22
+ // This ensures the parent state updates after rendering completes.
23
+ setTimeout(() => {
24
+ onChangeHandlerControlled({
25
+ selectedItems
26
+ });
27
+ }, 0);
23
28
  }
24
29
  } else {
25
30
  onChangeHandlerUncontrolled(selectedItems);
@@ -10,17 +10,6 @@
10
10
  *
11
11
  * @see https://github.com/facebook/fbjs/blob/4d1751311d3f67af2dcce2e40df8512a23c7b9c6/packages/fbjs/src/core/ExecutionEnvironment.js#L12
12
12
  */
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
- /*
18
- // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
19
- */
20
- window.document &&
21
- /*
22
- // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
23
- */
24
- window.document.createElement);
13
+ const canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
25
14
 
26
15
  export { canUseDOM };
@@ -1,9 +1,7 @@
1
1
  /**
2
- * Copyright IBM Corp. 2025, 2025
2
+ * Copyright IBM Corp. 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
- export declare const mockHTMLElement: (options: HTMLElement) => {
8
- mockRestore: () => void;
9
- };
7
+ export * from './utils';
@@ -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
  }
@@ -264,10 +269,10 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
264
269
  React.useEffect(() => {
265
270
  if (!enableDialogElement && !open && launcherButtonRef) {
266
271
  setTimeout(() => {
267
- launcherButtonRef?.current?.focus();
272
+ launcherButtonRef.current?.focus();
268
273
  });
269
274
  }
270
- }, [open, launcherButtonRef]);
275
+ }, [enableDialogElement, open, launcherButtonRef]);
271
276
  React.useEffect(() => {
272
277
  if (!enableDialogElement) {
273
278
  const initialFocus = focusContainerElement => {
@@ -294,14 +299,14 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
294
299
  }, [open, selectorPrimaryFocus, isOpen]);
295
300
 
296
301
  // AILabel is always size `sm`
297
- let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
298
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
299
- normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
300
- size: 'sm'
301
- });
302
- }
303
- 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, {
304
308
  open: open,
309
+ focusAfterCloseRef: launcherButtonRef,
305
310
  modal: true,
306
311
  className: containerClass,
307
312
  "aria-label": ariaLabel ? ariaLabel : generatedAriaLabel,
@@ -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.
@@ -16,6 +16,10 @@ var React = require('react');
16
16
  var iconsReact = require('@carbon/icons-react');
17
17
  var TableCell = require('./TableCell.js');
18
18
  var usePrefix = require('../../internal/usePrefix.js');
19
+ var TableSlugRow = require('./TableSlugRow.js');
20
+ var TableDecoratorRow = require('./TableDecoratorRow.js');
21
+ var index = require('../AILabel/index.js');
22
+ var utils = require('../../internal/utils.js');
19
23
 
20
24
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
25
 
@@ -40,16 +44,21 @@ const TableExpandRow = /*#__PURE__*/React__default["default"].forwardRef(({
40
44
 
41
45
  // We need to put the AILabel and Decorator before the expansion arrow and all other table cells after the arrow.
42
46
  let rowHasAILabel;
43
- const decorator = React__default["default"].Children.toArray(children).map(child => {
44
- if (child.type?.displayName === 'TableSlugRow' || child.type?.displayName === 'TableDecoratorRow') {
45
- if (child.props.slug || child.props.decorator?.type.displayName === 'AILabel') {
47
+ const decorator = React.Children.toArray(children).map(child => {
48
+ if (utils.isComponentElement(child, TableSlugRow["default"])) {
49
+ if (child.props.slug) {
50
+ rowHasAILabel = true;
51
+ }
52
+ return child;
53
+ } else if (utils.isComponentElement(child, TableDecoratorRow["default"])) {
54
+ if (utils.isComponentElement(child.props.decorator, index.AILabel)) {
46
55
  rowHasAILabel = true;
47
56
  }
48
57
  return child;
49
58
  }
50
59
  });
51
- const normalizedChildren = React__default["default"].Children.toArray(children).map(child => {
52
- if (child.type?.displayName !== 'TableSlugRow' && child.type?.displayName !== 'TableDecoratorRow') {
60
+ const normalizedChildren = React.Children.toArray(children).map(child => {
61
+ if (/*#__PURE__*/React.isValidElement(child) && child.type !== TableSlugRow["default"] && child.type !== TableDecoratorRow["default"]) {
53
62
  return child;
54
63
  }
55
64
  });
@@ -17,6 +17,8 @@ var iconsReact = require('@carbon/icons-react');
17
17
  require('./state/sorting.js');
18
18
  var useId = require('../../internal/useId.js');
19
19
  var usePrefix = require('../../internal/usePrefix.js');
20
+ var index = require('../AILabel/index.js');
21
+ var utils = require('../../internal/utils.js');
20
22
  var sortStates = require('./state/sortStates.js');
21
23
 
22
24
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -71,15 +73,13 @@ const TableHeader = /*#__PURE__*/React__default["default"].forwardRef(function T
71
73
 
72
74
  // AILabel is always size `mini`
73
75
  const AILableRef = React.useRef(null);
74
- let colHasAILabel;
75
- let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
76
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
77
- colHasAILabel = true;
78
- normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
79
- size: 'mini',
80
- ref: AILableRef
81
- });
82
- }
76
+ const candidate = slug ?? decorator;
77
+ const candidateIsAILabel = utils.isComponentElement(candidate, index.AILabel);
78
+ const colHasAILabel = candidateIsAILabel;
79
+ const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
80
+ size: 'mini',
81
+ ref: AILableRef
82
+ }) : null;
83
83
  const headerLabelClassNames = cx__default["default"]({
84
84
  [`${prefix}--table-header-label`]: true,
85
85
  [`${prefix}--table-header-label--slug ${prefix}--table-header-label--ai-label`]: colHasAILabel,