@carbon/react 1.85.0 → 1.86.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 (191) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +797 -797
  2. package/es/components/AILabel/index.js +1 -1
  3. package/es/components/Accordion/AccordionItem.d.ts +1 -1
  4. package/es/components/Accordion/AccordionItem.js +1 -1
  5. package/es/components/Checkbox/Checkbox.js +1 -1
  6. package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
  7. package/es/components/CodeSnippet/CodeSnippet.d.ts +2 -2
  8. package/es/components/CodeSnippet/CodeSnippet.js +1 -1
  9. package/es/components/ComboBox/ComboBox.js +1 -1
  10. package/es/components/ComposedModal/ComposedModal.js +1 -1
  11. package/es/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
  12. package/es/components/ContentSwitcher/ContentSwitcher.js +1 -1
  13. package/es/components/DataTable/DataTable.d.ts +230 -170
  14. package/es/components/DataTable/DataTable.js +508 -519
  15. package/es/components/DataTable/TableContainer.d.ts +9 -1
  16. package/es/components/DataTable/TableContainer.js +7 -1
  17. package/es/components/DataTable/TableExpandHeader.d.ts +1 -1
  18. package/es/components/DataTable/TableExpandHeader.js +1 -1
  19. package/es/components/DataTable/TableSelectAll.d.ts +2 -2
  20. package/es/components/DataTable/TableSelectAll.js +1 -1
  21. package/es/components/DataTable/TableSelectRow.d.ts +2 -2
  22. package/es/components/DataTable/TableSelectRow.js +1 -1
  23. package/es/components/DataTable/TableToolbar.d.ts +1 -1
  24. package/es/components/DataTable/TableToolbar.js +1 -1
  25. package/es/components/DataTable/TableToolbarMenu.d.ts +2 -18
  26. package/es/components/DataTable/TableToolbarMenu.js +0 -1
  27. package/es/components/DataTable/index.d.ts +1 -1
  28. package/es/components/DataTable/state/getDerivedStateFromProps.js +5 -1
  29. package/es/components/DatePicker/DatePicker.js +1 -1
  30. package/es/components/DatePickerInput/DatePickerInput.js +1 -1
  31. package/es/components/Dropdown/Dropdown.js +1 -1
  32. package/es/components/FeatureFlags/index.d.ts +2 -2
  33. package/es/components/FeatureFlags/index.js +1 -1
  34. package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
  35. package/es/components/FileUploader/FileUploaderButton.js +1 -1
  36. package/es/components/FileUploader/FileUploaderDropContainer.d.ts +2 -2
  37. package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
  38. package/es/components/FluidTextArea/FluidTextArea.d.ts +1 -1
  39. package/es/components/FluidTextArea/FluidTextArea.js +1 -1
  40. package/es/components/InlineCheckbox/InlineCheckbox.js +1 -1
  41. package/es/components/ListBox/ListBox.js +1 -1
  42. package/es/components/Loading/Loading.d.ts +1 -1
  43. package/es/components/Loading/Loading.js +1 -1
  44. package/es/components/Menu/Menu.js +1 -1
  45. package/es/components/Modal/Modal.js +1 -1
  46. package/es/components/MultiSelect/FilterableMultiSelect.js +1 -1
  47. package/es/components/MultiSelect/MultiSelect.js +1 -1
  48. package/es/components/Notification/Notification.d.ts +4 -4
  49. package/es/components/Notification/Notification.js +1 -1
  50. package/es/components/NumberInput/NumberInput.d.ts +7 -0
  51. package/es/components/NumberInput/NumberInput.js +80 -25
  52. package/es/components/OverflowMenu/OverflowMenu.d.ts +2 -6
  53. package/es/components/OverflowMenu/OverflowMenu.js +1 -1
  54. package/es/components/Pagination/Pagination.js +22 -5
  55. package/es/components/RadioButton/RadioButton.js +1 -1
  56. package/es/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  57. package/es/components/RadioTile/RadioTile.js +1 -1
  58. package/es/components/Search/Search.js +1 -1
  59. package/es/components/Select/Select.js +1 -1
  60. package/es/components/Slider/Slider.js +1 -1
  61. package/es/components/StructuredList/StructuredList.d.ts +5 -5
  62. package/es/components/StructuredList/StructuredList.js +1 -1
  63. package/es/components/Tabs/Tabs.d.ts +1 -1
  64. package/es/components/Tabs/Tabs.js +1 -1
  65. package/es/components/Tag/DismissibleTag.js +1 -1
  66. package/es/components/Tag/Tag.js +1 -1
  67. package/es/components/TextArea/TextArea.js +1 -1
  68. package/es/components/TextInput/ControlledPasswordInput.js +1 -1
  69. package/es/components/TextInput/PasswordInput.js +1 -1
  70. package/es/components/TextInput/TextInput.js +1 -1
  71. package/es/components/Tile/Tile.js +1 -1
  72. package/es/components/TileGroup/TileGroup.d.ts +5 -5
  73. package/es/components/TimePicker/TimePicker.d.ts +8 -0
  74. package/es/components/TimePicker/TimePicker.js +6 -4
  75. package/es/components/Tooltip/DefinitionTooltip.d.ts +1 -1
  76. package/es/components/Tooltip/DefinitionTooltip.js +1 -1
  77. package/es/components/TreeView/TreeContext.d.ts +19 -0
  78. package/es/components/TreeView/TreeContext.js +13 -0
  79. package/es/components/TreeView/TreeNode.d.ts +4 -4
  80. package/es/components/TreeView/TreeNode.js +56 -108
  81. package/es/components/TreeView/TreeView.js +42 -79
  82. package/es/components/UIShell/HeaderMenu.js +1 -1
  83. package/es/components/UIShell/HeaderMenuItem.d.ts +1 -1
  84. package/es/components/UIShell/HeaderMenuItem.js +1 -1
  85. package/es/components/UIShell/HeaderName.d.ts +1 -1
  86. package/es/components/UIShell/HeaderPanel.js +5 -7
  87. package/es/components/UIShell/Link.d.ts +2 -2
  88. package/es/components/UIShell/Link.js +1 -1
  89. package/es/components/UIShell/Switcher.d.ts +1 -1
  90. package/es/components/UIShell/Switcher.js +39 -12
  91. package/es/index.js +1 -1
  92. package/es/internal/useNoInteractiveChildren.d.ts +25 -0
  93. package/es/internal/useNoInteractiveChildren.js +39 -32
  94. package/es/prop-types/deprecate.d.ts +17 -0
  95. package/es/prop-types/deprecate.js +22 -12
  96. package/lib/components/AILabel/index.js +2 -2
  97. package/lib/components/Accordion/AccordionItem.d.ts +1 -1
  98. package/lib/components/Accordion/AccordionItem.js +1 -1
  99. package/lib/components/Checkbox/Checkbox.js +1 -1
  100. package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
  101. package/lib/components/CodeSnippet/CodeSnippet.d.ts +2 -2
  102. package/lib/components/CodeSnippet/CodeSnippet.js +2 -2
  103. package/lib/components/ComboBox/ComboBox.js +3 -3
  104. package/lib/components/ComposedModal/ComposedModal.js +1 -1
  105. package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
  106. package/lib/components/ContentSwitcher/ContentSwitcher.js +1 -1
  107. package/lib/components/DataTable/DataTable.d.ts +230 -170
  108. package/lib/components/DataTable/DataTable.js +507 -518
  109. package/lib/components/DataTable/TableContainer.d.ts +9 -1
  110. package/lib/components/DataTable/TableContainer.js +7 -1
  111. package/lib/components/DataTable/TableExpandHeader.d.ts +1 -1
  112. package/lib/components/DataTable/TableExpandHeader.js +1 -1
  113. package/lib/components/DataTable/TableSelectAll.d.ts +2 -2
  114. package/lib/components/DataTable/TableSelectAll.js +1 -1
  115. package/lib/components/DataTable/TableSelectRow.d.ts +2 -2
  116. package/lib/components/DataTable/TableSelectRow.js +1 -1
  117. package/lib/components/DataTable/TableToolbar.d.ts +1 -1
  118. package/lib/components/DataTable/TableToolbar.js +1 -1
  119. package/lib/components/DataTable/TableToolbarMenu.d.ts +2 -18
  120. package/lib/components/DataTable/TableToolbarMenu.js +0 -1
  121. package/lib/components/DataTable/index.d.ts +1 -1
  122. package/lib/components/DataTable/state/getDerivedStateFromProps.js +5 -1
  123. package/lib/components/DatePicker/DatePicker.js +1 -1
  124. package/lib/components/DatePickerInput/DatePickerInput.js +1 -1
  125. package/lib/components/Dropdown/Dropdown.js +3 -3
  126. package/lib/components/FeatureFlags/index.d.ts +2 -2
  127. package/lib/components/FeatureFlags/index.js +1 -1
  128. package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
  129. package/lib/components/FileUploader/FileUploaderButton.js +1 -1
  130. package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +2 -2
  131. package/lib/components/FileUploader/FileUploaderDropContainer.js +2 -2
  132. package/lib/components/FluidTextArea/FluidTextArea.d.ts +1 -1
  133. package/lib/components/FluidTextArea/FluidTextArea.js +1 -1
  134. package/lib/components/InlineCheckbox/InlineCheckbox.js +1 -1
  135. package/lib/components/ListBox/ListBox.js +1 -1
  136. package/lib/components/Loading/Loading.d.ts +1 -1
  137. package/lib/components/Loading/Loading.js +1 -1
  138. package/lib/components/Menu/Menu.js +1 -1
  139. package/lib/components/Modal/Modal.js +1 -1
  140. package/lib/components/MultiSelect/FilterableMultiSelect.js +4 -4
  141. package/lib/components/MultiSelect/MultiSelect.js +2 -2
  142. package/lib/components/Notification/Notification.d.ts +4 -4
  143. package/lib/components/Notification/Notification.js +4 -4
  144. package/lib/components/NumberInput/NumberInput.d.ts +7 -0
  145. package/lib/components/NumberInput/NumberInput.js +81 -26
  146. package/lib/components/OverflowMenu/OverflowMenu.d.ts +2 -6
  147. package/lib/components/OverflowMenu/OverflowMenu.js +2 -2
  148. package/lib/components/Pagination/Pagination.js +21 -4
  149. package/lib/components/RadioButton/RadioButton.js +1 -1
  150. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  151. package/lib/components/RadioTile/RadioTile.js +2 -2
  152. package/lib/components/Search/Search.js +1 -1
  153. package/lib/components/Select/Select.js +2 -2
  154. package/lib/components/Slider/Slider.js +1 -1
  155. package/lib/components/StructuredList/StructuredList.d.ts +5 -5
  156. package/lib/components/StructuredList/StructuredList.js +4 -4
  157. package/lib/components/Tabs/Tabs.d.ts +1 -1
  158. package/lib/components/Tabs/Tabs.js +1 -1
  159. package/lib/components/Tag/DismissibleTag.js +1 -1
  160. package/lib/components/Tag/Tag.js +4 -4
  161. package/lib/components/TextArea/TextArea.js +2 -2
  162. package/lib/components/TextInput/ControlledPasswordInput.js +1 -1
  163. package/lib/components/TextInput/PasswordInput.js +1 -1
  164. package/lib/components/TextInput/TextInput.js +2 -2
  165. package/lib/components/Tile/Tile.js +9 -9
  166. package/lib/components/TileGroup/TileGroup.d.ts +5 -5
  167. package/lib/components/TimePicker/TimePicker.d.ts +8 -0
  168. package/lib/components/TimePicker/TimePicker.js +6 -4
  169. package/lib/components/Tooltip/DefinitionTooltip.d.ts +1 -1
  170. package/lib/components/Tooltip/DefinitionTooltip.js +1 -1
  171. package/lib/components/TreeView/TreeContext.d.ts +19 -0
  172. package/lib/components/TreeView/TreeContext.js +18 -0
  173. package/lib/components/TreeView/TreeNode.d.ts +4 -4
  174. package/lib/components/TreeView/TreeNode.js +55 -107
  175. package/lib/components/TreeView/TreeView.js +41 -78
  176. package/lib/components/UIShell/HeaderMenu.js +1 -1
  177. package/lib/components/UIShell/HeaderMenuItem.d.ts +1 -1
  178. package/lib/components/UIShell/HeaderMenuItem.js +1 -1
  179. package/lib/components/UIShell/HeaderName.d.ts +1 -1
  180. package/lib/components/UIShell/HeaderPanel.js +5 -7
  181. package/lib/components/UIShell/Link.d.ts +2 -2
  182. package/lib/components/UIShell/Link.js +1 -1
  183. package/lib/components/UIShell/Switcher.d.ts +1 -1
  184. package/lib/components/UIShell/Switcher.js +38 -11
  185. package/lib/index.js +1 -1
  186. package/lib/internal/useNoInteractiveChildren.d.ts +25 -0
  187. package/lib/internal/useNoInteractiveChildren.js +39 -32
  188. package/lib/prop-types/deprecate.d.ts +17 -0
  189. package/lib/prop-types/deprecate.js +22 -12
  190. package/package.json +3 -3
  191. package/telemetry.yml +15 -14
@@ -6,13 +6,40 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React, { forwardRef, useRef } from 'react';
9
+ import React, { forwardRef, useRef, Children, isValidElement, cloneElement } from 'react';
10
10
  import cx from 'classnames';
11
11
  import { usePrefix } from '../../internal/usePrefix.js';
12
12
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
13
13
  import PropTypes from 'prop-types';
14
14
  import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
15
+ import './Content.js';
16
+ import './Header.js';
17
+ import './HeaderContainer.js';
18
+ import './HeaderGlobalAction.js';
19
+ import './HeaderGlobalBar.js';
20
+ import './HeaderMenu.js';
21
+ import './HeaderMenuButton.js';
22
+ import './HeaderMenuItem.js';
23
+ import './HeaderName.js';
24
+ import './HeaderNavigation.js';
25
+ import './HeaderPanel.js';
26
+ import './HeaderSideNavItems.js';
15
27
  import SwitcherItem from './SwitcherItem.js';
28
+ import SwitcherDivider from './SwitcherDivider.js';
29
+ import './SkipToContent.js';
30
+ import './SideNav.js';
31
+ import './SideNavDetails.js';
32
+ import './SideNavDivider.js';
33
+ import './SideNavFooter.js';
34
+ import './SideNavHeader.js';
35
+ import './SideNavIcon.js';
36
+ import './SideNavItem.js';
37
+ import './SideNavItems.js';
38
+ import './SideNavLink.js';
39
+ import './SideNavLinkText.js';
40
+ import './SideNavMenu.js';
41
+ import './SideNavMenuItem.js';
42
+ import './SideNavSwitcher.js';
16
43
 
17
44
  const Switcher = /*#__PURE__*/forwardRef(function Switcher(props, forwardRef) {
18
45
  const switcherRef = useRef(null);
@@ -36,8 +63,8 @@ const Switcher = /*#__PURE__*/forwardRef(function Switcher(props, forwardRef) {
36
63
  currentIndex,
37
64
  direction
38
65
  }) => {
39
- const enabledIndices = React.Children.toArray(children).reduce((acc, curr, i) => {
40
- if (/*#__PURE__*/React.isValidElement(curr) && Object.keys(curr.props).length !== 0 && curr.type === SwitcherItem) {
66
+ const enabledIndices = Children.toArray(children).reduce((acc, child, i) => {
67
+ if (/*#__PURE__*/isValidElement(child) && child.type === SwitcherItem && Object.keys(child.props).length) {
41
68
  acc.push(i);
42
69
  }
43
70
  return acc;
@@ -63,21 +90,21 @@ const Switcher = /*#__PURE__*/forwardRef(function Switcher(props, forwardRef) {
63
90
  switcherItem.focus();
64
91
  }
65
92
  };
66
- const childrenWithProps = React.Children.toArray(children).map((child, index) => {
67
- // only setup click handlers if onChange event is passed
68
- if (/*#__PURE__*/React.isValidElement(child) && child.type === SwitcherItem) {
69
- return /*#__PURE__*/React.cloneElement(child, {
93
+ const childrenWithProps = Children.toArray(children).map((child, index) => {
94
+ if (/*#__PURE__*/isValidElement(child) && child.type === SwitcherItem) {
95
+ return /*#__PURE__*/cloneElement(child, {
70
96
  handleSwitcherItemFocus,
71
97
  index,
72
98
  key: index,
73
99
  expanded
74
100
  });
75
101
  }
76
- return /*#__PURE__*/React.cloneElement(child, {
77
- index,
78
- key: index,
79
- expanded
80
- });
102
+ if (/*#__PURE__*/isValidElement(child) && child.type === SwitcherDivider) {
103
+ return /*#__PURE__*/cloneElement(child, {
104
+ key: index
105
+ });
106
+ }
107
+ return child;
81
108
  });
82
109
  return /*#__PURE__*/React.createElement("ul", _extends({
83
110
  ref: ref,
package/es/index.js CHANGED
@@ -33,7 +33,7 @@ export { default as useContextMenu } from './components/ContextMenu/useContextMe
33
33
  export { default as Copy } from './components/Copy/Copy.js';
34
34
  export { default as CopyButton } from './components/CopyButton/CopyButton.js';
35
35
  export { default as DangerButton } from './components/DangerButton/DangerButton.js';
36
- export { default as DataTable } from './components/DataTable/DataTable.js';
36
+ export { DataTable } from './components/DataTable/DataTable.js';
37
37
  export { Table } from './components/DataTable/Table.js';
38
38
  export { default as TableActionList } from './components/DataTable/TableActionList.js';
39
39
  export { default as TableBatchAction } from './components/DataTable/TableBatchAction.js';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { type RefObject } from 'react';
8
+ export declare const useNoInteractiveChildren: (ref: RefObject<HTMLElement | null>, message?: string) => void;
9
+ export declare const useInteractiveChildrenNeedDescription: (ref: RefObject<HTMLElement | null>, message?: string) => void;
10
+ /**
11
+ * Determines if a given DOM node has interactive content, or is itself
12
+ * interactive. It returns the interactive node if one is found.
13
+ *
14
+ * @param node - The node to check.
15
+ * @returns The interactive node, or `null` if none is found.
16
+ */
17
+ export declare const getInteractiveContent: (node: HTMLElement) => HTMLElement | null;
18
+ /**
19
+ * Determines if a given DOM node has a `role`, or has itself a `role`.
20
+ * It returns the node with a `role` if one is found.
21
+ *
22
+ * @param node - The node to check.
23
+ * @returns The node with a `role`, or `null` if none is found.
24
+ */
25
+ export declare const getRoleContent: (node: HTMLElement) => HTMLElement | null;
@@ -7,7 +7,8 @@
7
7
 
8
8
  import { useEffect } from 'react';
9
9
 
10
- function useNoInteractiveChildren(ref, message = 'component should have no interactive child nodes') {
10
+ const useNoInteractiveChildren = (ref, message = 'component should have no interactive child nodes') => {
11
+ // TODO: Why can't the condition go inside the hook?
11
12
  if (process.env.NODE_ENV !== 'production') {
12
13
  // TODO: https://github.com/carbon-design-system/carbon/issues/19005
13
14
  /*
@@ -17,14 +18,14 @@ function useNoInteractiveChildren(ref, message = 'component should have no inter
17
18
  const node = ref.current ? getInteractiveContent(ref.current) : false;
18
19
  if (node) {
19
20
  const errorMessage = `Error: ${message}.\n\nInstead found: ${node.outerHTML}`;
20
- // eslint-disable-next-line no-console
21
21
  console.error(errorMessage);
22
22
  throw new Error(errorMessage);
23
23
  }
24
24
  }, []);
25
25
  }
26
- }
27
- function useInteractiveChildrenNeedDescription(ref, message = `interactive child node(s) should have an \`aria-describedby\` property`) {
26
+ };
27
+ const useInteractiveChildrenNeedDescription = (ref, message = `interactive child node(s) should have an \`aria-describedby\` property`) => {
28
+ // TODO: Why can't the condition go inside the hook?
28
29
  if (process.env.NODE_ENV !== 'production') {
29
30
  // TODO: https://github.com/carbon-design-system/carbon/issues/19005
30
31
  /*
@@ -37,16 +38,16 @@ function useInteractiveChildrenNeedDescription(ref, message = `interactive child
37
38
  }
38
39
  });
39
40
  }
40
- }
41
+ };
41
42
 
42
43
  /**
43
44
  * Determines if a given DOM node has interactive content, or is itself
44
- * interactive. It returns the interactive node if one is found
45
+ * interactive. It returns the interactive node if one is found.
45
46
  *
46
- * @param {HTMLElement} node
47
- * @returns {HTMLElement}
47
+ * @param node - The node to check.
48
+ * @returns The interactive node, or `null` if none is found.
48
49
  */
49
- function getInteractiveContent(node) {
50
+ const getInteractiveContent = node => {
50
51
  if (!node || !node.childNodes) {
51
52
  return null;
52
53
  }
@@ -54,59 +55,65 @@ function getInteractiveContent(node) {
54
55
  return node;
55
56
  }
56
57
  for (const childNode of node.childNodes) {
57
- const interactiveNode = getInteractiveContent(childNode);
58
- if (interactiveNode) {
59
- return interactiveNode;
58
+ if (childNode instanceof HTMLElement) {
59
+ const interactiveNode = getInteractiveContent(childNode);
60
+ if (interactiveNode) {
61
+ return interactiveNode;
62
+ }
60
63
  }
61
64
  }
62
65
  return null;
63
- }
66
+ };
64
67
 
65
68
  /**
66
- * Determines if a given DOM node has a role, or has itself a role.
67
- * It returns the node with a role if one is found
69
+ * Determines if a given DOM node has a `role`, or has itself a `role`.
70
+ * It returns the node with a `role` if one is found.
68
71
  *
69
- * @param {HTMLElement} node
70
- * @returns {HTMLElement}
72
+ * @param node - The node to check.
73
+ * @returns The node with a `role`, or `null` if none is found.
71
74
  */
72
- function getRoleContent(node) {
75
+ const getRoleContent = node => {
73
76
  if (!node || !node.childNodes) {
74
77
  return null;
75
78
  }
76
- if (node?.getAttribute?.('role') && node.getAttribute('role') !== '') {
79
+ if (node.getAttribute('role') && node.getAttribute('role') !== '') {
77
80
  return node;
78
81
  }
79
82
  for (const childNode of node.childNodes) {
80
- const roleNode = getRoleContent(childNode);
81
- if (roleNode) {
82
- return roleNode;
83
+ if (childNode instanceof HTMLElement) {
84
+ const roleNode = getRoleContent(childNode);
85
+ if (roleNode) {
86
+ return roleNode;
87
+ }
83
88
  }
84
89
  }
85
90
  return null;
86
- }
91
+ };
87
92
 
88
93
  /**
89
- * Determines if the given element is focusable, or not
94
+ * Determines if the given element is focusable.
90
95
  *
91
- * @param {HTMLElement} element
92
- * @returns {boolean}
96
+ * @param element - The element to check.
97
+ * @returns Whether the element is focusable.
93
98
  * @see https://github.com/w3c/aria-practices/blob/0553bb51588ffa517506e2a1b2ca1422ed438c5f/examples/js/utils.js#L68
94
99
  */
95
- function isFocusable(element) {
100
+ const isFocusable = element => {
96
101
  if (element.tabIndex === undefined || element.tabIndex < 0) {
97
102
  return false;
98
103
  }
99
- if (element.disabled) {
100
- return false;
104
+ if (element instanceof HTMLButtonElement || element instanceof HTMLInputElement || element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement) {
105
+ if (element.disabled) {
106
+ return false;
107
+ }
101
108
  }
102
109
  switch (element.nodeName) {
103
110
  case 'A':
104
- return !!element.href && element.rel !== 'ignore';
111
+ return element instanceof HTMLAnchorElement && !!element.href && element.rel !== 'ignore';
105
112
  case 'INPUT':
106
- return element.type !== 'hidden';
113
+ return element instanceof HTMLInputElement && element.type !== 'hidden';
107
114
  default:
108
115
  return true;
109
116
  }
110
- }
117
+ };
111
118
 
112
119
  export { getInteractiveContent, getRoleContent, useInteractiveChildrenNeedDescription, useNoInteractiveChildren };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ type PropValidator = (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
8
+ /**
9
+ * Wraps a prop-type validator with a deprecation warning.
10
+ *
11
+ * @param propType - The original prop validator function.
12
+ * @param message - Deprecation message.
13
+ * @returns A new validator function that emits a warning the first time a
14
+ * deprecated prop is used.
15
+ */
16
+ export declare const deprecate: (propType: PropValidator, message?: string) => PropValidator;
17
+ export {};
@@ -7,22 +7,32 @@
7
7
 
8
8
  import { warning } from '../internal/warning.js';
9
9
 
10
- const didWarnAboutDeprecation = {};
11
- function deprecate(propType, message) {
12
- function checker(props, propName, componentName, ...rest) {
13
- if (props[propName] === undefined) {
10
+ const warningCache = new Map();
11
+
12
+ /**
13
+ * Wraps a prop-type validator with a deprecation warning.
14
+ *
15
+ * @param propType - The original prop validator function.
16
+ * @param message - Deprecation message.
17
+ * @returns A new validator function that emits a warning the first time a
18
+ * deprecated prop is used.
19
+ */
20
+ const deprecate = (propType, message) => {
21
+ const checker = (props, propName, componentName, ...rest) => {
22
+ if (typeof props[propName] === 'undefined') {
14
23
  return;
15
24
  }
16
- if (!didWarnAboutDeprecation[componentName] || !didWarnAboutDeprecation[componentName][propName]) {
17
- didWarnAboutDeprecation[componentName] = {
18
- ...didWarnAboutDeprecation[componentName],
19
- [propName]: true
20
- };
25
+ if (!warningCache.has(componentName)) {
26
+ warningCache.set(componentName, new Set());
27
+ }
28
+ const warnedProps = warningCache.get(componentName);
29
+ if (warnedProps && !warnedProps.has(propName)) {
30
+ warnedProps.add(propName);
21
31
  process.env.NODE_ENV !== "production" ? warning(false, message || `The prop \`${propName}\` has been deprecated for the ` + `${componentName} component. It will be removed in the next major ` + `release`) : void 0;
22
32
  }
23
33
  return propType(props, propName, componentName, ...rest);
24
- }
34
+ };
25
35
  return checker;
26
- }
36
+ };
27
37
 
28
- export { deprecate as default };
38
+ export { deprecate };
@@ -165,7 +165,7 @@ AILabel.propTypes = {
165
165
  * @deprecated
166
166
  * Specify additional text to be rendered next to the AI label in the inline variant
167
167
  */
168
- aiTextLabel: deprecate["default"](PropTypes__default["default"].string, '`aiTextLabel` on `AILabel` has been deprecated - Please use the `textLabel` prop instead'),
168
+ aiTextLabel: deprecate.deprecate(PropTypes__default["default"].string, '`aiTextLabel` on `AILabel` has been deprecated - Please use the `textLabel` prop instead'),
169
169
  /**
170
170
  * Specify how the popover should align with the button
171
171
  */
@@ -231,7 +231,7 @@ AILabel.propTypes = {
231
231
  * @deprecated
232
232
  * Specify the text that will be provided to the aria-label of the `AILabel` button
233
233
  */
234
- slugLabel: deprecate["default"](PropTypes__default["default"].string, '`slugLabel` on `AILabel` has been deprecated - Please use the `ariaLabel` prop instead'),
234
+ slugLabel: deprecate.deprecate(PropTypes__default["default"].string, '`slugLabel` on `AILabel` has been deprecated - Please use the `ariaLabel` prop instead'),
235
235
  /**
236
236
  * Specify additional text to be rendered next to the AI label in the inline variant
237
237
  */
@@ -90,7 +90,7 @@ declare namespace AccordionItem {
90
90
  * The callback function to render the expand button.
91
91
  * Can be a React component class.
92
92
  */
93
- renderExpando: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
93
+ renderExpando: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
94
94
  /**
95
95
  * The callback function to render the expand button.
96
96
  * Can be a React component class.
@@ -153,7 +153,7 @@ AccordionItem.propTypes = {
153
153
  * The callback function to render the expand button.
154
154
  * Can be a React component class.
155
155
  */
156
- renderExpando: deprecate["default"](PropTypes__default["default"].func, 'The `renderExpando` prop has been deprecated and will be removed in the next major release of Carbon. Use the `renderToggle` prop instead.'),
156
+ renderExpando: deprecate.deprecate(PropTypes__default["default"].func, 'The `renderExpando` prop has been deprecated and will be removed in the next major release of Carbon. Use the `renderToggle` prop instead.'),
157
157
  /**
158
158
  * The callback function to render the expand button.
159
159
  * Can be a React component class.
@@ -194,7 +194,7 @@ Checkbox.propTypes = {
194
194
  /**
195
195
  * **Experimental**: Provide a `Slug` component to be rendered inside the `Checkbox` component
196
196
  */
197
- slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
197
+ slug: deprecate.deprecate(PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
198
198
  /**
199
199
  * Specify a title for the <label> node for the Checkbox
200
200
  */
@@ -135,7 +135,7 @@ CheckboxGroup.propTypes = {
135
135
  /**
136
136
  * **Experimental**: Provide a `Slug` component to be rendered inside the `CheckboxGroup` component
137
137
  */
138
- slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
138
+ slug: deprecate.deprecate(PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
139
139
  /**
140
140
  * Specify whether the form group is currently in warning state
141
141
  */
@@ -120,7 +120,7 @@ declare namespace CodeSnippet {
120
120
  * Specify a label to be read by screen readers on the containing textbox
121
121
  * node
122
122
  */
123
- ariaLabel: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
123
+ ariaLabel: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
124
124
  /**
125
125
  * **Experimental**: Will attempt to automatically align the tooltip
126
126
  */
@@ -162,7 +162,7 @@ declare namespace CodeSnippet {
162
162
  * Specify whether you are using the light variant of the Code Snippet,
163
163
  * typically used for inline snippet to display an alternate color
164
164
  */
165
- light: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
165
+ light: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
166
166
  /**
167
167
  * Specify the maximum number of rows to be shown when in collapsed view
168
168
  */
@@ -276,7 +276,7 @@ CodeSnippet.propTypes = {
276
276
  * Specify a label to be read by screen readers on the containing textbox
277
277
  * node
278
278
  */
279
- ariaLabel: deprecate["default"](PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'),
279
+ ariaLabel: deprecate.deprecate(PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'),
280
280
  /**
281
281
  * **Experimental**: Will attempt to automatically align the tooltip
282
282
  */
@@ -319,7 +319,7 @@ CodeSnippet.propTypes = {
319
319
  * typically used for inline snippet to display an alternate color
320
320
  */
321
321
 
322
- light: deprecate["default"](PropTypes__default["default"].bool, 'The `light` prop for `CodeSnippet` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
322
+ light: deprecate.deprecate(PropTypes__default["default"].bool, 'The `light` prop for `CodeSnippet` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
323
323
  /**
324
324
  * Specify the maximum number of rows to be shown when in collapsed view
325
325
  */
@@ -781,7 +781,7 @@ ComboBox.propTypes = {
781
781
  * Specify a label to be read by screen readers on the container note.
782
782
  * 'aria-label' of the ListBox component.
783
783
  */
784
- ariaLabel: deprecate["default"](PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'),
784
+ ariaLabel: deprecate.deprecate(PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'),
785
785
  /**
786
786
  * **Experimental**: Will attempt to automatically align the floating
787
787
  * element to avoid collisions with the viewport and being clipped by
@@ -868,7 +868,7 @@ ComboBox.propTypes = {
868
868
  /**
869
869
  * should use "light theme" (white background)?
870
870
  */
871
- light: deprecate["default"](PropTypes__default["default"].bool, 'The `light` prop for `Combobox` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
871
+ light: deprecate.deprecate(PropTypes__default["default"].bool, 'The `light` prop for `Combobox` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
872
872
  /**
873
873
  * `onChange` is a utility for this controlled component to communicate to a
874
874
  * consuming component when a specific dropdown item is selected.
@@ -913,7 +913,7 @@ ComboBox.propTypes = {
913
913
  * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
914
914
  */
915
915
  size: ListBoxPropTypes.ListBoxSizePropType,
916
- slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
916
+ slug: deprecate.deprecate(PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
917
917
  /**
918
918
  * Provide text to be used in a `<label>` element that is tied to the
919
919
  * combobox via ARIA attributes.
@@ -416,7 +416,7 @@ ComposedModal.propTypes = {
416
416
  * Specify the size variant.
417
417
  */
418
418
  size: PropTypes__default["default"].oneOf(['xs', 'sm', 'md', 'lg']),
419
- slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop for `ComposedModal` has ' + 'been deprecated in favor of the new `decorator` prop. It will be removed in the next major release.')
419
+ slug: deprecate.deprecate(PropTypes__default["default"].node, 'The `slug` prop for `ComposedModal` has ' + 'been deprecated in favor of the new `decorator` prop. It will be removed in the next major release.')
420
420
  };
421
421
 
422
422
  exports.ModalBody = ModalBody;
@@ -65,7 +65,7 @@ export declare const ContentSwitcher: {
65
65
  /**
66
66
  * `true` to use the light variant.
67
67
  */
68
- light: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
68
+ light: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
69
69
  /**
70
70
  * `true` to use the low contrast version.
71
71
  */
@@ -134,7 +134,7 @@ ContentSwitcher.propTypes = {
134
134
  /**
135
135
  * `true` to use the light variant.
136
136
  */
137
- light: deprecate["default"](PropTypes__default["default"].bool, 'The `light` prop for `ContentSwitcher` is no longer needed and has ' + 'been deprecated. It will be removed in the next major release.'),
137
+ light: deprecate.deprecate(PropTypes__default["default"].bool, 'The `light` prop for `ContentSwitcher` is no longer needed and has ' + 'been deprecated. It will be removed in the next major release.'),
138
138
  /**
139
139
  * `true` to use the low contrast version.
140
140
  */