@carbon/react 1.84.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 (151) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +784 -784
  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/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 +20 -9
  36. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  37. package/es/components/MultiSelect/FilterableMultiSelect.js +8 -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/PageHeader/PageHeader.js +2 -2
  43. package/es/components/Popover/index.js +2 -1
  44. package/es/components/RadioButton/RadioButton.d.ts +2 -2
  45. package/es/components/RadioButton/RadioButton.js +8 -8
  46. package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
  47. package/es/components/RadioButtonGroup/RadioButtonGroup.js +9 -8
  48. package/es/components/RadioTile/RadioTile.d.ts +1 -1
  49. package/es/components/RadioTile/RadioTile.js +8 -7
  50. package/es/components/Select/Select.d.ts +2 -2
  51. package/es/components/Select/Select.js +8 -7
  52. package/es/components/Tag/DismissibleTag.d.ts +1 -1
  53. package/es/components/Tag/DismissibleTag.js +9 -8
  54. package/es/components/Tag/Tag.d.ts +1 -1
  55. package/es/components/Tag/Tag.js +9 -8
  56. package/es/components/TextArea/TextArea.js +8 -7
  57. package/es/components/TextInput/TextInput.d.ts +1 -1
  58. package/es/components/TextInput/TextInput.js +20 -9
  59. package/es/components/Tile/Tile.d.ts +2 -2
  60. package/es/components/Tile/Tile.js +30 -36
  61. package/es/components/Toggletip/index.js +2 -2
  62. package/es/components/Tooltip/DefinitionTooltip.js +1 -0
  63. package/es/components/TreeView/TreeNode.js +3 -3
  64. package/es/components/TreeView/TreeView.js +3 -3
  65. package/es/components/UIShell/Content.d.ts +5 -3
  66. package/es/components/UIShell/HeaderPanel.d.ts +2 -2
  67. package/es/components/UIShell/HeaderPanel.js +9 -5
  68. package/es/internal/Selection.js +8 -3
  69. package/es/internal/environment.js +1 -12
  70. package/es/internal/{__mocks__/mockHTMLElement.d.ts → index.d.ts} +2 -4
  71. package/es/internal/useResizeObserver.d.ts +1 -1
  72. package/es/internal/utils.d.ts +14 -0
  73. package/es/internal/utils.js +18 -0
  74. package/es/tools/uniqueId.d.ts +1 -6
  75. package/lib/components/AILabel/index.js +6 -1
  76. package/lib/components/Checkbox/Checkbox.d.ts +2 -2
  77. package/lib/components/Checkbox/Checkbox.js +7 -7
  78. package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
  79. package/lib/components/CheckboxGroup/CheckboxGroup.js +8 -7
  80. package/lib/components/CodeSnippet/CodeSnippet.js +2 -4
  81. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  82. package/lib/components/ComboBox/ComboBox.js +11 -10
  83. package/lib/components/ComposedModal/ComposedModal.d.ts +1 -1
  84. package/lib/components/ComposedModal/ComposedModal.js +16 -11
  85. package/lib/components/ContainedList/ContainedList.d.ts +1 -1
  86. package/lib/components/ContainedList/ContainedList.js +4 -2
  87. package/lib/components/ContentSwitcher/ContentSwitcher.js +5 -4
  88. package/lib/components/DataTable/DataTable.js +3 -0
  89. package/lib/components/DataTable/TableDecoratorRow.d.ts +2 -2
  90. package/lib/components/DataTable/TableDecoratorRow.js +8 -8
  91. package/lib/components/DataTable/TableExpandRow.d.ts +1 -1
  92. package/lib/components/DataTable/TableExpandRow.js +14 -5
  93. package/lib/components/DataTable/TableHeader.js +9 -9
  94. package/lib/components/DataTable/TableRow.js +11 -3
  95. package/lib/components/DataTable/tools/normalize.js +2 -1
  96. package/lib/components/DatePickerInput/DatePickerInput.js +7 -6
  97. package/lib/components/Dialog/index.d.ts +5 -1
  98. package/lib/components/Dialog/index.js +20 -0
  99. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  100. package/lib/components/Dropdown/Dropdown.js +12 -14
  101. package/lib/components/FileUploader/FileUploaderButton.js +2 -2
  102. package/lib/components/FileUploader/FileUploaderDropContainer.js +2 -2
  103. package/lib/components/FileUploader/FileUploaderItem.js +2 -2
  104. package/lib/components/Layer/index.d.ts +1 -3
  105. package/lib/components/Layer/index.js +9 -8
  106. package/lib/components/Menu/Menu.js +0 -6
  107. package/lib/components/Modal/Modal.d.ts +2 -2
  108. package/lib/components/Modal/Modal.js +28 -17
  109. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  110. package/lib/components/MultiSelect/FilterableMultiSelect.js +12 -11
  111. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  112. package/lib/components/MultiSelect/MultiSelect.js +13 -12
  113. package/lib/components/NumberInput/NumberInput.d.ts +1 -1
  114. package/lib/components/NumberInput/NumberInput.js +8 -7
  115. package/lib/components/PageHeader/PageHeader.js +2 -2
  116. package/lib/components/Popover/index.js +2 -1
  117. package/lib/components/RadioButton/RadioButton.d.ts +2 -2
  118. package/lib/components/RadioButton/RadioButton.js +7 -7
  119. package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
  120. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +10 -9
  121. package/lib/components/RadioTile/RadioTile.d.ts +1 -1
  122. package/lib/components/RadioTile/RadioTile.js +7 -6
  123. package/lib/components/Select/Select.d.ts +2 -2
  124. package/lib/components/Select/Select.js +7 -6
  125. package/lib/components/Tag/DismissibleTag.d.ts +1 -1
  126. package/lib/components/Tag/DismissibleTag.js +8 -7
  127. package/lib/components/Tag/Tag.d.ts +1 -1
  128. package/lib/components/Tag/Tag.js +8 -7
  129. package/lib/components/TextArea/TextArea.js +7 -6
  130. package/lib/components/TextInput/TextInput.d.ts +1 -1
  131. package/lib/components/TextInput/TextInput.js +19 -8
  132. package/lib/components/Tile/Tile.d.ts +2 -2
  133. package/lib/components/Tile/Tile.js +29 -35
  134. package/lib/components/Toggletip/index.js +2 -2
  135. package/lib/components/Tooltip/DefinitionTooltip.js +1 -0
  136. package/lib/components/TreeView/TreeNode.js +3 -3
  137. package/lib/components/TreeView/TreeView.js +3 -3
  138. package/lib/components/UIShell/Content.d.ts +5 -3
  139. package/lib/components/UIShell/HeaderPanel.d.ts +2 -2
  140. package/lib/components/UIShell/HeaderPanel.js +8 -4
  141. package/lib/internal/Selection.js +8 -3
  142. package/lib/internal/environment.js +1 -12
  143. package/lib/internal/{__mocks__/mockHTMLElement.d.ts → index.d.ts} +2 -4
  144. package/lib/internal/useResizeObserver.d.ts +1 -1
  145. package/lib/internal/utils.d.ts +14 -0
  146. package/lib/internal/utils.js +22 -0
  147. package/lib/tools/uniqueId.d.ts +1 -6
  148. package/package.json +11 -20
  149. package/telemetry.yml +1 -0
  150. package/es/tools/uniqueId.js +0 -14
  151. package/lib/tools/uniqueId.js +0 -18
@@ -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,
@@ -14,6 +14,10 @@ var React = require('react');
14
14
  var PropTypes = require('prop-types');
15
15
  var cx = require('classnames');
16
16
  var usePrefix = require('../../internal/usePrefix.js');
17
+ var TableSlugRow = require('./TableSlugRow.js');
18
+ var TableDecoratorRow = require('./TableDecoratorRow.js');
19
+ var index = require('../AILabel/index.js');
20
+ var utils = require('../../internal/utils.js');
17
21
 
18
22
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
23
 
@@ -25,11 +29,15 @@ const TableRow = /*#__PURE__*/React__default["default"].forwardRef((props, ref)
25
29
  const prefix = usePrefix.usePrefix();
26
30
  let rowHasAILabel;
27
31
  if (props?.children) {
28
- React__default["default"].Children.toArray(props.children).map(child => {
29
- if (child.type?.displayName === 'TableSlugRow' || child.type?.displayName === 'TableDecoratorRow') {
30
- if (child.props.slug || child.props.decorator?.type.displayName === 'AILabel') {
32
+ // TODO: Why is this loop a `map`? It's not returning anything. Ideally,
33
+ // it seems that it should be a `some`. Maybe I'm missing something?
34
+ React.Children.toArray(props.children).map(child => {
35
+ if (utils.isComponentElement(child, TableSlugRow["default"])) {
36
+ if (child.props.slug) {
31
37
  rowHasAILabel = true;
32
38
  }
39
+ } else if (utils.isComponentElement(child, TableDecoratorRow["default"]) && utils.isComponentElement(child.props.decorator, index.AILabel)) {
40
+ rowHasAILabel = true;
33
41
  }
34
42
  });
35
43
  }
@@ -9,6 +9,7 @@
9
9
 
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
+ var index = require('../../AILabel/index.js');
12
13
  var cells = require('./cells.js');
13
14
 
14
15
  /**
@@ -63,7 +64,7 @@ const normalize = (rows, headers, prevState = {}) => {
63
64
  isEditing: false,
64
65
  isValid: true,
65
66
  errors: null,
66
- hasAILabelHeader: !!(slug || decorator?.type?.displayName === 'AILabel'),
67
+ hasAILabelHeader: !!(slug || decorator?.type === index.AILabel),
67
68
  info: {
68
69
  header: key
69
70
  }
@@ -19,6 +19,8 @@ var FormContext = require('../FluidForm/FormContext.js');
19
19
  var useId = require('../../internal/useId.js');
20
20
  require('../Text/index.js');
21
21
  var deprecate = require('../../prop-types/deprecate.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 }; }
@@ -109,12 +111,11 @@ const DatePickerInput = /*#__PURE__*/React__default["default"].forwardRef(functi
109
111
  const input = /*#__PURE__*/React__default["default"].createElement("input", inputProps);
110
112
 
111
113
  // AILabel always size `mini`
112
- let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
113
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
114
- normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
115
- size: 'mini'
116
- });
117
- }
114
+ const candidate = slug ?? decorator;
115
+ const candidateIsAILabel = utils.isComponentElement(candidate, index.AILabel);
116
+ const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
117
+ size: 'mini'
118
+ }) : null;
118
119
  return /*#__PURE__*/React__default["default"].createElement("div", {
119
120
  className: containerClasses
120
121
  }, labelText && /*#__PURE__*/React__default["default"].createElement(Text.Text, {
@@ -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 HTMLAttributes } from 'react';
7
+ import React, { type HTMLAttributes, type RefObject } from 'react';
8
8
  import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
9
9
  /**
10
10
  * ----------
@@ -20,6 +20,10 @@ interface DialogProps extends HTMLAttributes<HTMLDialogElement> {
20
20
  * Specify an optional className to be applied to the modal root node
21
21
  */
22
22
  className?: string;
23
+ /**
24
+ * Provide a ref to return focus to once the dialog is closed.
25
+ */
26
+ focusAfterCloseRef?: RefObject<HTMLElement | null>;
23
27
  /**
24
28
  * Specifies whether the dialog is modal or non-modal. This cannot be changed
25
29
  * while open=true
@@ -45,6 +45,7 @@ const DialogContext = /*#__PURE__*/React.createContext({});
45
45
  const unstable__Dialog = /*#__PURE__*/React__default["default"].forwardRef(({
46
46
  children,
47
47
  className,
48
+ focusAfterCloseRef,
48
49
  modal,
49
50
  onCancel = noopFn.noopFn,
50
51
  onClick = noopFn.noopFn,
@@ -103,6 +104,19 @@ const unstable__Dialog = /*#__PURE__*/React__default["default"].forwardRef(({
103
104
  }
104
105
  }
105
106
  }, [modal, open]);
107
+ React.useEffect(() => {
108
+ if (!open && focusAfterCloseRef) {
109
+ // use setTimeout to ensure focus is set after all other default focus behavior
110
+ const moveFocus = setTimeout(() => {
111
+ focusAfterCloseRef.current?.focus();
112
+ });
113
+
114
+ //component did unmount equivalent
115
+ return () => {
116
+ clearTimeout(moveFocus);
117
+ };
118
+ }
119
+ }, [open, focusAfterCloseRef]);
106
120
  const containerClasses = cx__default["default"](`${prefix}--dialog-container`);
107
121
  const contextValue = {
108
122
  dialogId,
@@ -148,6 +162,12 @@ unstable__Dialog.propTypes = {
148
162
  * Specify an optional className to be applied to the modal root node
149
163
  */
150
164
  className: PropTypes__default["default"].string,
165
+ /**
166
+ * Provide a ref to return focus to once the dialog is closed.
167
+ */
168
+ focusAfterCloseRef: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].shape({
169
+ current: PropTypes__default["default"].any
170
+ })]),
151
171
  /**
152
172
  * Modal specifies whether the Dialog is modal or non-modal. This cannot be
153
173
  * changed while open=true
@@ -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, { Ref, type HTMLAttributes, type ReactNode } from 'react';
7
+ import React, { type HTMLAttributes, type ReactNode, type Ref } from 'react';
8
8
  import { UseSelectProps } from 'downshift';
9
9
  import { type ListBoxMenuIconTranslationKey, type ListBoxSize, type ListBoxType } from '../ListBox';
10
10
  import { TranslateWithId } from '../../types/common';