@carbon/react 1.78.2 → 1.79.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 (253) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +882 -882
  2. package/es/components/Accordion/AccordionItem.js +2 -2
  3. package/es/components/Button/Button.d.ts +2 -3
  4. package/es/components/Button/Button.js +29 -19
  5. package/es/components/Button/ButtonBase.js +3 -1
  6. package/es/components/ChatButton/ChatButton.d.ts +2 -3
  7. package/es/components/ChatButton/ChatButton.js +1 -2
  8. package/es/components/ComboBox/ComboBox.js +34 -24
  9. package/es/components/ComposedModal/ComposedModal.js +65 -51
  10. package/es/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +2 -2
  11. package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -1
  12. package/es/components/ContentSwitcher/ContentSwitcher.js +3 -3
  13. package/es/components/DataTable/TableBatchAction.d.ts +3 -3
  14. package/es/components/DataTable/TableBatchAction.js +1 -1
  15. package/es/components/DataTable/TableContainer.d.ts +1 -1
  16. package/es/components/DataTable/TableContainer.js +5 -4
  17. package/es/components/DataTable/TableExpandHeader.d.ts +6 -5
  18. package/es/components/DataTable/TableToolbarMenu.d.ts +2 -2
  19. package/es/components/DataTable/TableToolbarMenu.js +1 -1
  20. package/es/components/DatePicker/DatePicker.js +2 -2
  21. package/es/components/DatePicker/plugins/fixEventsPlugin.js +1 -1
  22. package/es/components/Dialog/index.d.ts +42 -4
  23. package/es/components/Dialog/index.js +177 -0
  24. package/es/components/ExpandableSearch/ExpandableSearch.js +2 -2
  25. package/es/components/FeatureFlags/index.d.ts +3 -1
  26. package/es/components/FeatureFlags/index.js +3 -0
  27. package/es/components/FileUploader/FileUploader.d.ts +1 -1
  28. package/es/components/FileUploader/FileUploader.js +2 -2
  29. package/es/components/FileUploader/FileUploaderButton.js +2 -2
  30. package/es/components/FileUploader/FileUploaderDropContainer.d.ts +1 -1
  31. package/es/components/FileUploader/FileUploaderDropContainer.js +6 -4
  32. package/es/components/FileUploader/FileUploaderItem.d.ts +1 -1
  33. package/es/components/FileUploader/FileUploaderItem.js +2 -2
  34. package/es/components/Grid/CSSGrid.js +18 -14
  35. package/es/components/Grid/Column.d.ts +2 -2
  36. package/es/components/Grid/Column.js +7 -8
  37. package/es/components/Grid/FlexGrid.js +7 -6
  38. package/es/components/Grid/GridTypes.d.ts +5 -3
  39. package/es/components/IconButton/index.d.ts +2 -2
  40. package/es/components/IconButton/index.js +4 -4
  41. package/es/components/Layer/index.d.ts +4 -6
  42. package/es/components/Layer/index.js +5 -6
  43. package/es/components/Link/Link.d.ts +2 -3
  44. package/es/components/Link/Link.js +1 -2
  45. package/es/components/ListBox/ListBoxMenuItem.d.ts +3 -3
  46. package/es/components/ListBox/ListBoxMenuItem.js +37 -15
  47. package/es/components/Menu/Menu.js +2 -2
  48. package/es/components/Menu/MenuItem.d.ts +2 -2
  49. package/es/components/Menu/MenuItem.js +3 -3
  50. package/es/components/Modal/Modal.js +121 -49
  51. package/es/components/ModalWrapper/ModalWrapper.js +1 -1
  52. package/es/components/MultiSelect/FilterableMultiSelect.js +3 -3
  53. package/es/components/MultiSelect/MultiSelect.js +2 -2
  54. package/es/components/MultiSelect/index.d.ts +1 -1
  55. package/es/components/MultiSelect/index.js +1 -8
  56. package/es/components/Notification/Notification.d.ts +5 -13
  57. package/es/components/Notification/Notification.js +3 -4
  58. package/es/components/OverflowMenu/OverflowMenu.d.ts +22 -201
  59. package/es/components/OverflowMenu/OverflowMenu.js +269 -338
  60. package/es/components/OverflowMenu/index.d.ts +5 -5
  61. package/es/components/OverflowMenu/index.js +2 -2
  62. package/es/components/OverflowMenu/next/index.d.ts +4 -4
  63. package/es/components/OverflowMenu/next/index.js +1 -1
  64. package/es/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
  65. package/es/components/ProgressIndicator/ProgressIndicator.js +2 -2
  66. package/es/components/RadioTile/RadioTile.js +2 -2
  67. package/es/components/Search/Search.d.ts +2 -3
  68. package/es/components/Search/Search.js +4 -6
  69. package/es/components/Slider/Slider.d.ts +39 -44
  70. package/es/components/Slider/Slider.js +57 -59
  71. package/es/components/Tabs/Tabs.d.ts +3 -6
  72. package/es/components/Tabs/Tabs.js +16 -18
  73. package/es/components/Tag/DismissibleTag.d.ts +3 -5
  74. package/es/components/Tag/DismissibleTag.js +1 -2
  75. package/es/components/Tag/OperationalTag.d.ts +2 -3
  76. package/es/components/Tag/OperationalTag.js +1 -2
  77. package/es/components/Tag/SelectableTag.d.ts +3 -5
  78. package/es/components/Tag/SelectableTag.js +1 -2
  79. package/es/components/Tag/Tag.d.ts +2 -3
  80. package/es/components/Tag/Tag.js +1 -2
  81. package/es/components/Tile/Tile.d.ts +3 -5
  82. package/es/components/Tile/Tile.js +16 -10
  83. package/es/components/Toggletip/index.js +2 -2
  84. package/es/components/Tooltip/DefinitionTooltip.js +2 -2
  85. package/es/components/Tooltip/Tooltip.d.ts +1 -1
  86. package/es/components/Tooltip/Tooltip.js +2 -2
  87. package/es/components/TreeView/TreeNode.d.ts +3 -5
  88. package/es/components/TreeView/TreeNode.js +3 -4
  89. package/es/components/TreeView/TreeView.js +2 -2
  90. package/es/components/UIShell/HeaderContainer.js +2 -2
  91. package/es/components/UIShell/HeaderMenu.js +2 -2
  92. package/es/components/UIShell/HeaderPanel.js +2 -2
  93. package/es/components/UIShell/SideNav.d.ts +1 -1
  94. package/es/components/UIShell/SideNav.js +2 -2
  95. package/es/components/UIShell/SideNavHeader.d.ts +2 -3
  96. package/es/components/UIShell/SideNavHeader.js +1 -2
  97. package/es/components/UIShell/SideNavLink.d.ts +2 -2
  98. package/es/components/UIShell/SideNavLink.js +1 -1
  99. package/es/components/UIShell/SideNavMenu.d.ts +2 -2
  100. package/es/components/UIShell/SideNavMenu.js +3 -3
  101. package/es/components/UIShell/SwitcherItem.js +2 -2
  102. package/es/index.js +1 -1
  103. package/es/internal/FloatingMenu.d.ts +2 -2
  104. package/es/internal/FloatingMenu.js +8 -5
  105. package/es/internal/OptimizedResize.d.ts +18 -0
  106. package/es/internal/OptimizedResize.js +21 -24
  107. package/es/internal/createClassWrapper.d.ts +3 -3
  108. package/es/internal/createClassWrapper.js +4 -4
  109. package/es/internal/keyboard/index.d.ts +9 -0
  110. package/es/internal/keyboard/keys.d.ts +23 -0
  111. package/es/internal/keyboard/keys.js +2 -2
  112. package/es/internal/keyboard/match.d.ts +26 -0
  113. package/es/internal/keyboard/match.js +17 -41
  114. package/es/internal/keyboard/navigation.d.ts +37 -0
  115. package/es/internal/keyboard/navigation.js +15 -27
  116. package/es/internal/useIsomorphicEffect.d.ts +10 -0
  117. package/es/internal/useIsomorphicEffect.js +2 -3
  118. package/es/internal/useMatchMedia.d.ts +8 -0
  119. package/es/internal/useMatchMedia.js +10 -20
  120. package/es/internal/useMergedRefs.js +3 -0
  121. package/es/internal/useNormalizedInputProps.d.ts +52 -0
  122. package/es/internal/useNormalizedInputProps.js +9 -36
  123. package/lib/components/Accordion/AccordionItem.js +2 -2
  124. package/lib/components/Button/Button.d.ts +2 -3
  125. package/lib/components/Button/Button.js +29 -19
  126. package/lib/components/Button/ButtonBase.js +3 -1
  127. package/lib/components/ChatButton/ChatButton.d.ts +2 -3
  128. package/lib/components/ChatButton/ChatButton.js +1 -2
  129. package/lib/components/ComboBox/ComboBox.js +34 -24
  130. package/lib/components/ComposedModal/ComposedModal.js +64 -50
  131. package/lib/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +2 -2
  132. package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -1
  133. package/lib/components/ContentSwitcher/ContentSwitcher.js +3 -3
  134. package/lib/components/DataTable/TableBatchAction.d.ts +3 -3
  135. package/lib/components/DataTable/TableBatchAction.js +1 -1
  136. package/lib/components/DataTable/TableContainer.d.ts +1 -1
  137. package/lib/components/DataTable/TableContainer.js +5 -4
  138. package/lib/components/DataTable/TableExpandHeader.d.ts +6 -5
  139. package/lib/components/DataTable/TableToolbarMenu.d.ts +2 -2
  140. package/lib/components/DataTable/TableToolbarMenu.js +1 -1
  141. package/lib/components/DatePicker/DatePicker.js +2 -2
  142. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +1 -1
  143. package/lib/components/Dialog/index.d.ts +42 -4
  144. package/lib/components/Dialog/index.js +190 -0
  145. package/lib/components/ExpandableSearch/ExpandableSearch.js +2 -2
  146. package/lib/components/FeatureFlags/index.d.ts +3 -1
  147. package/lib/components/FeatureFlags/index.js +3 -0
  148. package/lib/components/FileUploader/FileUploader.d.ts +1 -1
  149. package/lib/components/FileUploader/FileUploader.js +2 -2
  150. package/lib/components/FileUploader/FileUploaderButton.js +2 -2
  151. package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +1 -1
  152. package/lib/components/FileUploader/FileUploaderDropContainer.js +6 -4
  153. package/lib/components/FileUploader/FileUploaderItem.d.ts +1 -1
  154. package/lib/components/FileUploader/FileUploaderItem.js +2 -2
  155. package/lib/components/Grid/CSSGrid.js +18 -14
  156. package/lib/components/Grid/Column.d.ts +2 -2
  157. package/lib/components/Grid/Column.js +7 -8
  158. package/lib/components/Grid/FlexGrid.js +7 -6
  159. package/lib/components/Grid/GridTypes.d.ts +5 -3
  160. package/lib/components/IconButton/index.d.ts +2 -2
  161. package/lib/components/IconButton/index.js +4 -4
  162. package/lib/components/Layer/index.d.ts +4 -6
  163. package/lib/components/Layer/index.js +5 -6
  164. package/lib/components/Link/Link.d.ts +2 -3
  165. package/lib/components/Link/Link.js +1 -2
  166. package/lib/components/ListBox/ListBoxMenuItem.d.ts +3 -3
  167. package/lib/components/ListBox/ListBoxMenuItem.js +36 -14
  168. package/lib/components/Menu/Menu.js +2 -2
  169. package/lib/components/Menu/MenuItem.d.ts +2 -2
  170. package/lib/components/Menu/MenuItem.js +3 -3
  171. package/lib/components/Modal/Modal.js +123 -51
  172. package/lib/components/ModalWrapper/ModalWrapper.js +1 -1
  173. package/lib/components/MultiSelect/FilterableMultiSelect.js +3 -3
  174. package/lib/components/MultiSelect/MultiSelect.js +2 -2
  175. package/lib/components/MultiSelect/index.d.ts +1 -1
  176. package/lib/components/MultiSelect/index.js +1 -8
  177. package/lib/components/Notification/Notification.d.ts +5 -13
  178. package/lib/components/Notification/Notification.js +3 -4
  179. package/lib/components/OverflowMenu/OverflowMenu.d.ts +22 -201
  180. package/lib/components/OverflowMenu/OverflowMenu.js +268 -336
  181. package/lib/components/OverflowMenu/index.d.ts +5 -5
  182. package/lib/components/OverflowMenu/index.js +2 -2
  183. package/lib/components/OverflowMenu/next/index.d.ts +4 -4
  184. package/lib/components/OverflowMenu/next/index.js +1 -1
  185. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
  186. package/lib/components/ProgressIndicator/ProgressIndicator.js +2 -2
  187. package/lib/components/RadioTile/RadioTile.js +2 -2
  188. package/lib/components/Search/Search.d.ts +2 -3
  189. package/lib/components/Search/Search.js +4 -6
  190. package/lib/components/Slider/Slider.d.ts +39 -44
  191. package/lib/components/Slider/Slider.js +57 -59
  192. package/lib/components/Tabs/Tabs.d.ts +3 -6
  193. package/lib/components/Tabs/Tabs.js +16 -18
  194. package/lib/components/Tag/DismissibleTag.d.ts +3 -5
  195. package/lib/components/Tag/DismissibleTag.js +1 -2
  196. package/lib/components/Tag/OperationalTag.d.ts +2 -3
  197. package/lib/components/Tag/OperationalTag.js +1 -2
  198. package/lib/components/Tag/SelectableTag.d.ts +3 -5
  199. package/lib/components/Tag/SelectableTag.js +1 -2
  200. package/lib/components/Tag/Tag.d.ts +2 -3
  201. package/lib/components/Tag/Tag.js +1 -2
  202. package/lib/components/Tile/Tile.d.ts +3 -5
  203. package/lib/components/Tile/Tile.js +16 -10
  204. package/lib/components/Toggletip/index.js +2 -2
  205. package/lib/components/Tooltip/DefinitionTooltip.js +2 -2
  206. package/lib/components/Tooltip/Tooltip.d.ts +1 -1
  207. package/lib/components/Tooltip/Tooltip.js +2 -2
  208. package/lib/components/TreeView/TreeNode.d.ts +3 -5
  209. package/lib/components/TreeView/TreeNode.js +3 -4
  210. package/lib/components/TreeView/TreeView.js +2 -2
  211. package/lib/components/UIShell/HeaderContainer.js +2 -2
  212. package/lib/components/UIShell/HeaderMenu.js +2 -2
  213. package/lib/components/UIShell/HeaderPanel.js +2 -2
  214. package/lib/components/UIShell/SideNav.d.ts +1 -1
  215. package/lib/components/UIShell/SideNav.js +2 -2
  216. package/lib/components/UIShell/SideNavHeader.d.ts +2 -3
  217. package/lib/components/UIShell/SideNavHeader.js +1 -2
  218. package/lib/components/UIShell/SideNavLink.d.ts +2 -2
  219. package/lib/components/UIShell/SideNavLink.js +1 -1
  220. package/lib/components/UIShell/SideNavMenu.d.ts +2 -2
  221. package/lib/components/UIShell/SideNavMenu.js +3 -3
  222. package/lib/components/UIShell/SwitcherItem.js +2 -2
  223. package/lib/index.js +2 -2
  224. package/lib/internal/FloatingMenu.d.ts +2 -2
  225. package/lib/internal/FloatingMenu.js +9 -6
  226. package/lib/internal/OptimizedResize.d.ts +18 -0
  227. package/lib/internal/OptimizedResize.js +21 -24
  228. package/lib/internal/createClassWrapper.d.ts +3 -3
  229. package/lib/internal/createClassWrapper.js +4 -4
  230. package/lib/internal/keyboard/index.d.ts +9 -0
  231. package/lib/internal/keyboard/keys.d.ts +23 -0
  232. package/lib/internal/keyboard/keys.js +2 -2
  233. package/lib/internal/keyboard/match.d.ts +26 -0
  234. package/lib/internal/keyboard/match.js +17 -41
  235. package/lib/internal/keyboard/navigation.d.ts +37 -0
  236. package/lib/internal/keyboard/navigation.js +15 -27
  237. package/lib/internal/useIsomorphicEffect.d.ts +10 -0
  238. package/lib/internal/useIsomorphicEffect.js +2 -3
  239. package/lib/internal/useMatchMedia.d.ts +8 -0
  240. package/lib/internal/useMatchMedia.js +10 -20
  241. package/lib/internal/useMergedRefs.js +3 -0
  242. package/lib/internal/useNormalizedInputProps.d.ts +52 -0
  243. package/lib/internal/useNormalizedInputProps.js +9 -36
  244. package/package.json +6 -6
  245. package/scss/components/dialog/_dialog.scss +9 -0
  246. package/scss/components/dialog/_index.scss +9 -0
  247. package/telemetry.yml +1 -0
  248. package/es/components/Modal/next/index.d.ts +0 -171
  249. package/es/internal/focus/index.js +0 -15
  250. package/es/internal/useEffectOnce.js +0 -30
  251. package/lib/components/Modal/next/index.d.ts +0 -171
  252. package/lib/internal/focus/index.js +0 -19
  253. package/lib/internal/useEffectOnce.js +0 -34
@@ -11,13 +11,13 @@ import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
12
  import React__default, { useState, useContext } from 'react';
13
13
  import '../Text/index.js';
14
+ import { Escape } from '../../internal/keyboard/keys.js';
15
+ import { match } from '../../internal/keyboard/match.js';
14
16
  import { useId } from '../../internal/useId.js';
15
17
  import deprecate from '../../prop-types/deprecate.js';
16
18
  import { usePrefix } from '../../internal/usePrefix.js';
17
19
  import { AccordionContext } from './AccordionProvider.js';
18
- import { match } from '../../internal/keyboard/match.js';
19
20
  import { Text } from '../Text/Text.js';
20
- import { Escape } from '../../internal/keyboard/keys.js';
21
21
 
22
22
  const defaultRenderToggle = props => /*#__PURE__*/React__default.createElement("button", _extends({
23
23
  type: "button"
@@ -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.
@@ -50,8 +50,7 @@ export interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonEl
50
50
  */
51
51
  rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>['rel'];
52
52
  /**
53
- * Optional prop to allow overriding the icon rendering.
54
- * Can be a React component class
53
+ * A component used to render an icon.
55
54
  */
56
55
  renderIcon?: React.ElementType;
57
56
  /**
@@ -76,23 +76,34 @@ const Button = /*#__PURE__*/React__default.forwardRef((props, ref) => {
76
76
  if (tooltipPosition === 'right' || tooltipPosition === 'left') {
77
77
  align = tooltipPosition;
78
78
  }
79
- return /*#__PURE__*/React__default.createElement(IconButton, _extends({}, rest, {
80
- ref: ref,
81
- as: as,
82
- align: align,
83
- label: iconDescription,
84
- kind: kind,
85
- size: size,
86
- highContrast: tooltipHighContrast,
87
- dropShadow: tooltipDropShadow,
88
- onMouseEnter: onMouseEnter,
89
- onMouseLeave: onMouseLeave,
90
- onFocus: onFocus,
91
- onBlur: onBlur,
92
- autoAlign: autoAlign,
93
- onClick: composeEventHandlers([onClick, handleClick]),
94
- renderIcon: iconOnlyImage ? null : ButtonImageElement // avoid doubling the icon.
95
- }), iconOnlyImage ?? children);
79
+ return (
80
+ /*#__PURE__*/
81
+ // @ts-expect-error - `IconButton` does not support all `size`s that
82
+ // `Button` supports.
83
+ //
84
+ // TODO: What should be done here?
85
+ // 1. Should the `IconButton` not be rendered if the `size` is not
86
+ // supported?
87
+ // 2. Should an error be thrown?
88
+ // 3. Something else?
89
+ React__default.createElement(IconButton, _extends({}, rest, {
90
+ ref: ref,
91
+ as: as,
92
+ align: align,
93
+ label: iconDescription,
94
+ kind: kind,
95
+ size: size,
96
+ highContrast: tooltipHighContrast,
97
+ dropShadow: tooltipDropShadow,
98
+ onMouseEnter: onMouseEnter,
99
+ onMouseLeave: onMouseLeave,
100
+ onFocus: onFocus,
101
+ onBlur: onBlur,
102
+ autoAlign: autoAlign,
103
+ onClick: composeEventHandlers([onClick, handleClick]),
104
+ renderIcon: iconOnlyImage ? null : ButtonImageElement // avoid doubling the icon.
105
+ }), iconOnlyImage ?? children)
106
+ );
96
107
  }
97
108
  });
98
109
  Button.displayName = 'Button';
@@ -194,8 +205,7 @@ Button.propTypes = {
194
205
  */
195
206
  rel: PropTypes.string,
196
207
  /**
197
- * Optional prop to allow overriding the icon rendering.
198
- * Can be a React component class
208
+ * A component used to render an icon.
199
209
  */
200
210
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
201
211
  /**
@@ -41,6 +41,8 @@ const ButtonBase = /*#__PURE__*/React__default.forwardRef(function ButtonBase(_r
41
41
  // TODO: V12 - Remove this class
42
42
  [`${prefix}--btn--md`]: size === 'md' && !isExpressive,
43
43
  // TODO: V12 - Remove this class
44
+ [`${prefix}--btn--lg`]: size === 'lg' && !isExpressive,
45
+ // TODO: V12 - Remove this class
44
46
  [`${prefix}--btn--xl`]: size === 'xl',
45
47
  // TODO: V12 - Remove this class
46
48
  [`${prefix}--btn--2xl`]: size === '2xl',
@@ -49,7 +51,7 @@ const ButtonBase = /*#__PURE__*/React__default.forwardRef(function ButtonBase(_r
49
51
  [`${prefix}--btn--${kind}`]: kind,
50
52
  [`${prefix}--btn--disabled`]: disabled,
51
53
  [`${prefix}--btn--expressive`]: isExpressive,
52
- [`${prefix}--btn--icon-only`]: hasIconOnly && !className?.includes(`${prefix}--btn--icon-only`),
54
+ [`${prefix}--btn--icon-only`]: hasIconOnly,
53
55
  [`${prefix}--btn--selected`]: hasIconOnly && isSelected && kind === 'ghost'
54
56
  });
55
57
  const commonProps = {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2024
2
+ * Copyright IBM Corp. 2024, 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.
@@ -33,8 +33,7 @@ export interface ChatButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
33
33
  */
34
34
  kind?: ChatButtonKind;
35
35
  /**
36
- * Optional prop to specify an icon to be rendered.
37
- * Can be a React component class
36
+ * A component used to render an icon.
38
37
  */
39
38
  renderIcon?: ComponentType | FunctionComponent;
40
39
  /**
@@ -75,8 +75,7 @@ ChatButton.propTypes = {
75
75
  */
76
76
  kind: PropTypes.oneOf(['primary', 'secondary', 'danger', 'ghost', 'tertiary']),
77
77
  /**
78
- * Optional prop to specify an icon to be rendered.
79
- * Can be a React component class
78
+ * A component used to render an icon.
80
79
  */
81
80
  // @ts-expect-error: PropTypes are not expressive enough to cover this case
82
81
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
@@ -16,6 +16,8 @@ import isEqual from 'react-fast-compare';
16
16
  import ListBox from '../ListBox/index.js';
17
17
  import ListBoxSelection from '../ListBox/next/ListBoxSelection.js';
18
18
  import ListBoxTrigger from '../ListBox/next/ListBoxTrigger.js';
19
+ import { Space, Enter, Escape, Home, End } from '../../internal/keyboard/keys.js';
20
+ import { match } from '../../internal/keyboard/match.js';
19
21
  import { useId } from '../../internal/useId.js';
20
22
  import mergeRefs from '../../tools/mergeRefs.js';
21
23
  import deprecate from '../../prop-types/deprecate.js';
@@ -24,10 +26,8 @@ import '../FluidForm/FluidForm.js';
24
26
  import { FormContext } from '../FluidForm/FormContext.js';
25
27
  import { useFloating, flip, hide, autoUpdate } from '@floating-ui/react';
26
28
  import { useFeatureFlag } from '../FeatureFlags/index.js';
27
- import { match } from '../../internal/keyboard/match.js';
28
29
  import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
29
30
  import { Text } from '../Text/Text.js';
30
- import { Space, Enter, Escape, Home, End } from '../../internal/keyboard/keys.js';
31
31
 
32
32
  const {
33
33
  InputBlur,
@@ -301,31 +301,41 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
301
301
  return changes;
302
302
  }
303
303
  case InputKeyDownEnter:
304
- if (highlightedIndex === -1 && !allowCustomValue && state.selectedItem) {
305
- return {
306
- ...changes,
307
- selectedItem: null,
308
- inputValue: state.inputValue
309
- };
310
- }
311
- if (allowCustomValue) {
312
- setInputValue(inputValue);
313
- setHighlightedIndex(changes.selectedItem);
314
- if (onChange) {
315
- onChange({
316
- selectedItem: changes.selectedItem,
304
+ if (!allowCustomValue) {
305
+ const highlightedIndex = indexToHighlight(inputValue);
306
+ const matchingItem = items[highlightedIndex];
307
+ if (matchingItem) {
308
+ // Prevent matching items that are marked as `disabled` from
309
+ // being selected.
310
+ if (matchingItem.disabled) {
311
+ return state;
312
+ }
313
+
314
+ // Select the matching item.
315
+ return {
316
+ ...changes,
317
+ selectedItem: matchingItem,
318
+ inputValue: itemToString(matchingItem)
319
+ };
320
+ }
321
+
322
+ // If no matching item is found and there is an existing
323
+ // selection, clear the selection.
324
+ if (state.selectedItem !== null) {
325
+ return {
326
+ ...changes,
327
+ selectedItem: null,
317
328
  inputValue
318
- });
329
+ };
319
330
  }
320
- return changes;
321
- } else if (changes.selectedItem && !allowCustomValue) {
322
- return changes;
323
- } else {
324
- return {
325
- ...changes,
326
- isOpen: true
327
- };
328
331
  }
332
+
333
+ // For `allowCustomValue` or if no matching item is found, keep the
334
+ // menu open.
335
+ return {
336
+ ...changes,
337
+ isOpen: true
338
+ };
329
339
  case FunctionToggleMenu:
330
340
  case ToggleButtonClick:
331
341
  if (!changes.isOpen && state.inputValue && highlightedIndex === -1 && !allowCustomValue) {
@@ -17,14 +17,15 @@ import mergeRefs from '../../tools/mergeRefs.js';
17
17
  import cx from 'classnames';
18
18
  import toggleClass from '../../tools/toggleClass.js';
19
19
  import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsTruthy.js';
20
- import wrapFocus, { wrapFocusWithoutSentinels, elementOrParentIsFloatingMenu } from '../../internal/wrapFocus.js';
20
+ import wrapFocus, { elementOrParentIsFloatingMenu } from '../../internal/wrapFocus.js';
21
21
  import { usePrefix } from '../../internal/usePrefix.js';
22
+ import { Escape } from '../../internal/keyboard/keys.js';
23
+ import { match } from '../../internal/keyboard/match.js';
22
24
  import { useFeatureFlag } from '../FeatureFlags/index.js';
23
25
  import { composeEventHandlers } from '../../tools/events.js';
24
26
  import deprecate from '../../prop-types/deprecate.js';
27
+ import { unstable__Dialog } from '../Dialog/index.js';
25
28
  import { debounce } from '../../node_modules/es-toolkit/dist/compat/function/debounce.mjs.js';
26
- import { match } from '../../internal/keyboard/match.js';
27
- import { Escape, Tab } from '../../internal/keyboard/keys.js';
28
29
 
29
30
  const ModalBody = /*#__PURE__*/React__default.forwardRef(function ModalBody(_ref, ref) {
30
31
  let {
@@ -120,12 +121,14 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
120
121
  const startSentinel = useRef(null);
121
122
  const endSentinel = useRef(null);
122
123
  const onMouseDownTarget = useRef(null);
123
- const focusTrapWithoutSentinels = useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
124
+ const enableDialogElement =
125
+ // useFeatureFlag('enable-experimental-focus-wrap-without-sentinels') ||
126
+ useFeatureFlag('enable-dialog-element');
124
127
 
125
128
  // Keep track of modal open/close state
126
129
  // and propagate it to the document.body
127
130
  useEffect(() => {
128
- if (open !== wasOpen) {
131
+ if (!enableDialogElement && open !== wasOpen) {
129
132
  setIsOpen(!!open);
130
133
  setWasOpen(!!open);
131
134
  toggleClass(document.body, `${prefix}--body--with-modal-open`, !!open);
@@ -133,22 +136,19 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
133
136
  }, [open, wasOpen, prefix]);
134
137
  // Remove the document.body className on unmount
135
138
  useEffect(() => {
136
- return () => {
137
- toggleClass(document.body, `${prefix}--body--with-modal-open`, false);
138
- };
139
+ if (!enableDialogElement) {
140
+ return () => {
141
+ toggleClass(document.body, `${prefix}--body--with-modal-open`, false);
142
+ };
143
+ }
139
144
  }, []); // eslint-disable-line react-hooks/exhaustive-deps
140
145
 
141
146
  function handleKeyDown(event) {
142
- event.stopPropagation();
143
- if (match(event, Escape)) {
144
- closeModal(event);
145
- }
146
- if (focusTrapWithoutSentinels && open && match(event, Tab) && innerModal.current) {
147
- wrapFocusWithoutSentinels({
148
- containerNode: innerModal.current,
149
- currentActiveNode: event.target,
150
- event: event
151
- });
147
+ if (!enableDialogElement) {
148
+ event.stopPropagation();
149
+ if (match(event, Escape)) {
150
+ closeModal(event);
151
+ }
152
152
  }
153
153
  onKeyDown?.(event);
154
154
  }
@@ -228,32 +228,34 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
228
228
  }
229
229
  });
230
230
  useEffect(() => {
231
- if (!open && launcherButtonRef) {
231
+ if (!enableDialogElement && !open && launcherButtonRef) {
232
232
  setTimeout(() => {
233
233
  launcherButtonRef?.current?.focus();
234
234
  });
235
235
  }
236
236
  }, [open, launcherButtonRef]);
237
237
  useEffect(() => {
238
- const initialFocus = focusContainerElement => {
239
- const containerElement = focusContainerElement || innerModal.current;
240
- const primaryFocusElement = containerElement ? containerElement.querySelector(danger ? `.${prefix}--btn--secondary` : selectorPrimaryFocus) : null;
241
- if (primaryFocusElement) {
242
- return primaryFocusElement;
243
- }
244
- return button && button.current;
245
- };
246
- const focusButton = focusContainerElement => {
247
- const target = initialFocus(focusContainerElement);
248
- const closeButton = focusContainerElement.querySelector(`.${prefix}--modal-close`);
249
- if (target) {
250
- target.focus();
251
- } else if (!target && closeButton) {
252
- closeButton?.focus();
238
+ if (!enableDialogElement) {
239
+ const initialFocus = focusContainerElement => {
240
+ const containerElement = focusContainerElement || innerModal.current;
241
+ const primaryFocusElement = containerElement ? containerElement.querySelector(danger ? `.${prefix}--btn--secondary` : selectorPrimaryFocus) : null;
242
+ if (primaryFocusElement) {
243
+ return primaryFocusElement;
244
+ }
245
+ return button && button.current;
246
+ };
247
+ const focusButton = focusContainerElement => {
248
+ const target = initialFocus(focusContainerElement);
249
+ const closeButton = focusContainerElement.querySelector(`.${prefix}--modal-close`);
250
+ if (target) {
251
+ target.focus();
252
+ } else if (!target && closeButton) {
253
+ closeButton?.focus();
254
+ }
255
+ };
256
+ if (open && isOpen) {
257
+ focusButton(innerModal.current);
253
258
  }
254
- };
255
- if (open && isOpen) {
256
- focusButton(innerModal.current);
257
259
  }
258
260
  }, [open, selectorPrimaryFocus, isOpen]);
259
261
 
@@ -264,23 +266,24 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
264
266
  size: 'sm'
265
267
  });
266
268
  }
267
- return /*#__PURE__*/React__default.createElement(Layer, _extends({}, rest, {
268
- level: 0,
269
- role: "presentation",
270
- ref: ref,
271
- "aria-hidden": !open,
272
- onBlur: !focusTrapWithoutSentinels ? handleBlur : () => {},
273
- onClick: composeEventHandlers([rest?.onClick, handleOnClick]),
274
- onMouseDown: composeEventHandlers([rest?.onMouseDown, handleOnMouseDown]),
275
- onKeyDown: handleKeyDown,
276
- className: modalClass
277
- }), /*#__PURE__*/React__default.createElement("div", {
269
+ const modalBody = enableDialogElement ? /*#__PURE__*/React__default.createElement(unstable__Dialog, {
270
+ open: open,
271
+ modal: true,
272
+ className: containerClass,
273
+ "aria-label": ariaLabel ? ariaLabel : generatedAriaLabel,
274
+ "aria-labelledby": ariaLabelledBy
275
+ }, /*#__PURE__*/React__default.createElement("div", {
276
+ ref: innerModal,
277
+ className: `${prefix}--modal-container-body`
278
+ }, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default.createElement("div", {
279
+ className: `${prefix}--modal--inner__decorator`
280
+ }, normalizedDecorator) : '', childrenWithProps)) : /*#__PURE__*/React__default.createElement("div", {
278
281
  className: containerClass,
279
282
  role: "dialog",
280
283
  "aria-modal": "true",
281
284
  "aria-label": ariaLabel ? ariaLabel : generatedAriaLabel,
282
285
  "aria-labelledby": ariaLabelledBy
283
- }, !focusTrapWithoutSentinels && /*#__PURE__*/React__default.createElement("button", {
286
+ }, /*#__PURE__*/React__default.createElement("button", {
284
287
  type: "button",
285
288
  ref: startSentinel,
286
289
  className: `${prefix}--visually-hidden`
@@ -289,11 +292,22 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
289
292
  className: `${prefix}--modal-container-body`
290
293
  }, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default.createElement("div", {
291
294
  className: `${prefix}--modal--inner__decorator`
292
- }, normalizedDecorator) : '', childrenWithProps), !focusTrapWithoutSentinels && /*#__PURE__*/React__default.createElement("button", {
295
+ }, normalizedDecorator) : '', childrenWithProps), /*#__PURE__*/React__default.createElement("button", {
293
296
  type: "button",
294
297
  ref: endSentinel,
295
298
  className: `${prefix}--visually-hidden`
296
- }, "Focus sentinel")));
299
+ }, "Focus sentinel"));
300
+ return /*#__PURE__*/React__default.createElement(Layer, _extends({}, rest, {
301
+ level: 0,
302
+ role: "presentation",
303
+ ref: ref,
304
+ "aria-hidden": !open,
305
+ onBlur: !enableDialogElement ? handleBlur : () => {},
306
+ onClick: composeEventHandlers([rest?.onClick, handleOnClick]),
307
+ onMouseDown: composeEventHandlers([rest?.onMouseDown, handleOnMouseDown]),
308
+ onKeyDown: handleKeyDown,
309
+ className: modalClass
310
+ }), modalBody);
297
311
  });
298
312
  ComposedModal.propTypes = {
299
313
  /**
@@ -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.
@@ -27,7 +27,7 @@ interface ContainedListItemProps {
27
27
  */
28
28
  onClick?: () => void;
29
29
  /**
30
- * Provide an optional icon to render in front of the item's content.
30
+ * A component used to render an icon.
31
31
  */
32
32
  renderIcon?: ComponentType | FunctionComponent;
33
33
  }
@@ -71,7 +71,7 @@ ContainedListItem.propTypes = {
71
71
  */
72
72
  onClick: PropTypes.func,
73
73
  /**
74
- * Provide an optional icon to render in front of the item's content.
74
+ * A component used to render an icon.
75
75
  */
76
76
  // @ts-expect-error: PropTypes are not expressive enough to cover this case
77
77
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
@@ -12,11 +12,11 @@ import cx from 'classnames';
12
12
  import deprecate from '../../prop-types/deprecate.js';
13
13
  import { LayoutConstraint } from '../Layout/index.js';
14
14
  import { composeEventHandlers } from '../../tools/events.js';
15
- import { PrefixContext } from '../../internal/usePrefix.js';
16
- import { noopFn } from '../../internal/noopFn.js';
15
+ import { ArrowRight, ArrowLeft } from '../../internal/keyboard/keys.js';
17
16
  import { matches } from '../../internal/keyboard/match.js';
18
17
  import { getNextIndex } from '../../internal/keyboard/navigation.js';
19
- import { ArrowRight, ArrowLeft } from '../../internal/keyboard/keys.js';
18
+ import { PrefixContext } from '../../internal/usePrefix.js';
19
+ import { noopFn } from '../../internal/noopFn.js';
20
20
 
21
21
  class ContentSwitcher extends React__default.Component {
22
22
  constructor() {
@@ -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.
@@ -17,7 +17,7 @@ export interface TableBatchActionProps extends React.ButtonHTMLAttributes<HTMLBu
17
17
  */
18
18
  iconDescription?: string;
19
19
  /**
20
- * Optional function to render your own icon in the underlying button
20
+ * A component used to render an icon.
21
21
  */
22
22
  renderIcon?: React.ElementType;
23
23
  }
@@ -34,7 +34,7 @@ declare const TableBatchAction: {
34
34
  */
35
35
  iconDescription: (props: any) => Error | undefined;
36
36
  /**
37
- * Optional function to render your own icon in the underlying button
37
+ * A component used to render an icon.
38
38
  */
39
39
  renderIcon: PropTypes.Requireable<object>;
40
40
  };
@@ -39,7 +39,7 @@ TableBatchAction.propTypes = {
39
39
  return undefined;
40
40
  },
41
41
  /**
42
- * Optional function to render your own icon in the underlying button
42
+ * A component used to render an icon.
43
43
  */
44
44
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
45
45
  };
@@ -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.
@@ -12,6 +12,7 @@ import React__default, { useMemo } from 'react';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
13
13
  import { useId } from '../../internal/useId.js';
14
14
  import { TableContext } from './TableContext.js';
15
+ import { Section, Heading } from '../Heading/index.js';
15
16
 
16
17
  const TableContainer = _ref => {
17
18
  let {
@@ -39,14 +40,14 @@ const TableContainer = _ref => {
39
40
  }, [title, description, titleId, descriptionId]);
40
41
  return /*#__PURE__*/React__default.createElement(TableContext.Provider, {
41
42
  value: value
42
- }, /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
43
+ }, /*#__PURE__*/React__default.createElement(Section, _extends({}, rest, {
43
44
  className: tableContainerClasses
44
- }), title && /*#__PURE__*/React__default.createElement("div", {
45
+ }), (title || description) && /*#__PURE__*/React__default.createElement("div", {
45
46
  className: `${prefix}--data-table-header`
46
- }, /*#__PURE__*/React__default.createElement("h4", {
47
+ }, title && /*#__PURE__*/React__default.createElement(Heading, {
47
48
  className: `${prefix}--data-table-header__title`,
48
49
  id: titleId
49
- }, title), /*#__PURE__*/React__default.createElement("p", {
50
+ }, title), description && /*#__PURE__*/React__default.createElement("p", {
50
51
  className: `${prefix}--data-table-header__description`,
51
52
  id: descriptionId
52
53
  }, description)), children));
@@ -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.
@@ -45,15 +45,16 @@ export type TableExpandHeaderPropsBase = {
45
45
  */
46
46
  onExpand?(event: React.MouseEvent<HTMLButtonElement>): void;
47
47
  } & ReactAttr<HTMLTableCellElement>;
48
- export type TableExpandHeaderPropsWithToggle = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'aria-label' | 'enableToggle' | 'onExpand'> & {
48
+ export type TableExpandHeaderPropsWithToggle = Omit<TableExpandHeaderPropsBase, 'aria-label' | 'enableToggle' | 'onExpand'> & {
49
49
  enableToggle: true;
50
- ariaLabel: string;
51
50
  ['aria-label']: string;
52
51
  onExpand(event: React.MouseEvent<HTMLButtonElement>): void;
53
52
  };
54
- export type TableExpandHeaderPropsWithExpando = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'aria-label' | 'enableExpando' | 'onExpand'> & {
53
+ export type TableExpandHeaderPropsWithExpando = Omit<TableExpandHeaderPropsBase, 'aria-label' | 'enableExpando' | 'onExpand'> & {
54
+ /**
55
+ * @deprecated The enableExpando prop is being replaced by `enableToggle`
56
+ */
55
57
  enableExpando: true;
56
- ariaLabel: string;
57
58
  ['aria-label']: string;
58
59
  onExpand(event: React.MouseEvent<HTMLButtonElement>): void;
59
60
  };
@@ -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.
@@ -20,7 +20,7 @@ export interface TableToolbarMenuProps extends React.HTMLAttributes<HTMLDivEleme
20
20
  */
21
21
  menuOptionsClass?: string;
22
22
  /**
23
- * Optional prop to allow overriding the default menu icon
23
+ * A component used to render an icon.
24
24
  */
25
25
  renderIcon?: any;
26
26
  }
@@ -51,7 +51,7 @@ TableToolbarMenu.propTypes = {
51
51
  */
52
52
  menuOptionsClass: PropTypes.string,
53
53
  /**
54
- * Optional prop to allow overriding the default menu icon
54
+ * A component used to render an icon.
55
55
  */
56
56
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
57
57
  };
@@ -16,13 +16,13 @@ import carbonFlatpickrAppendToPlugin from './plugins/appendToPlugin.js';
16
16
  import carbonFlatpickrFixEventsPlugin from './plugins/fixEventsPlugin.js';
17
17
  import carbonFlatpickrRangePlugin from './plugins/rangePlugin.js';
18
18
  import deprecate from '../../prop-types/deprecate.js';
19
+ import { Escape, ArrowDown, Enter, Tab } from '../../internal/keyboard/keys.js';
20
+ import { match } from '../../internal/keyboard/match.js';
19
21
  import { usePrefix } from '../../internal/usePrefix.js';
20
22
  import { useSavedCallback } from '../../internal/useSavedCallback.js';
21
23
  import '../FluidForm/FluidForm.js';
22
24
  import { FormContext } from '../FluidForm/FormContext.js';
23
25
  import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
24
- import { match } from '../../internal/keyboard/match.js';
25
- import { Escape, ArrowDown, Enter, Tab } from '../../internal/keyboard/keys.js';
26
26
 
27
27
  // Weekdays shorthand for english locale
28
28
  l10n.en.weekdays.shorthand.forEach((_day, index) => {
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { match } from '../../../internal/keyboard/match.js';
9
8
  import { Enter, ArrowLeft, ArrowRight, ArrowDown } from '../../../internal/keyboard/keys.js';
9
+ import { match } from '../../../internal/keyboard/match.js';
10
10
 
11
11
  /**
12
12
  * @param {object} config Plugin configuration.