@carbon/react 1.77.0 → 1.78.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 (144) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1038 -916
  2. package/es/components/Accordion/AccordionItem.js +1 -1
  3. package/es/components/BadgeIndicator/index.d.ts +23 -0
  4. package/es/components/BadgeIndicator/index.js +45 -0
  5. package/es/components/Breadcrumb/Breadcrumb.d.ts +5 -0
  6. package/es/components/Breadcrumb/Breadcrumb.js +8 -2
  7. package/es/components/Button/Button.d.ts +9 -0
  8. package/es/components/Button/Button.js +13 -0
  9. package/es/components/ComboBox/ComboBox.js +19 -15
  10. package/es/components/ComboButton/index.js +0 -1
  11. package/es/components/ContextMenu/useContextMenu.d.ts +0 -1
  12. package/es/components/ContextMenu/useContextMenu.js +1 -2
  13. package/es/components/Dropdown/Dropdown.d.ts +1 -1
  14. package/es/components/Dropdown/Dropdown.js +3 -2
  15. package/es/components/FileUploader/FileUploader.js +1 -1
  16. package/es/components/FileUploader/FileUploaderItem.js +1 -1
  17. package/es/components/IconButton/index.d.ts +7 -1
  18. package/es/components/IconButton/index.js +18 -2
  19. package/es/components/IconIndicator/index.d.ts +1 -1
  20. package/es/components/InlineLoading/InlineLoading.js +2 -5
  21. package/es/components/Menu/Menu.d.ts +1 -0
  22. package/es/components/Menu/Menu.js +5 -7
  23. package/es/components/Menu/MenuContext.d.ts +4 -4
  24. package/es/components/Menu/MenuContext.js +6 -1
  25. package/es/components/Menu/MenuItem.d.ts +1 -1
  26. package/es/components/Menu/MenuItem.js +15 -23
  27. package/es/components/MenuButton/index.js +14 -2
  28. package/es/components/Modal/Modal.d.ts +3 -3
  29. package/es/components/Modal/Modal.js +9 -3
  30. package/es/components/Modal/next/index.d.ts +1 -5
  31. package/es/components/MultiSelect/MultiSelect.js +3 -2
  32. package/es/components/MultiSelect/MultiSelectPropTypes.d.ts +5 -2
  33. package/es/components/MultiSelect/tools/sorting.js +8 -7
  34. package/es/components/Notification/Notification.js +5 -6
  35. package/es/components/NumberInput/NumberInput.js +12 -12
  36. package/es/components/OverflowMenu/OverflowMenu.d.ts +8 -20
  37. package/es/components/OverflowMenu/OverflowMenu.js +7 -9
  38. package/es/components/OverflowMenuItem/OverflowMenuItem.js +1 -1
  39. package/es/components/ProgressIndicator/ProgressIndicator.js +1 -1
  40. package/es/components/RadioTile/RadioTile.js +1 -1
  41. package/es/components/Select/Select.js +11 -2
  42. package/es/components/ShapeIndicator/index.d.ts +29 -0
  43. package/es/components/ShapeIndicator/index.js +92 -0
  44. package/es/components/Tabs/Tabs.d.ts +6 -4
  45. package/es/components/Tabs/Tabs.js +27 -8
  46. package/es/components/Tag/OperationalTag.d.ts +1 -36
  47. package/es/components/Tag/OperationalTag.js +7 -5
  48. package/es/components/Text/Text.d.ts +11 -9
  49. package/es/components/Text/Text.js +6 -6
  50. package/es/components/Text/TextDirection.d.ts +7 -9
  51. package/es/components/Text/TextDirection.js +5 -2
  52. package/es/components/Text/TextDirectionContext.d.ts +14 -0
  53. package/es/components/Text/TextDirectionContext.js +6 -2
  54. package/es/components/Text/createTextComponent.d.ts +5 -5
  55. package/es/components/Text/createTextComponent.js +5 -4
  56. package/es/components/Text/index.d.ts +6 -7
  57. package/es/components/Text/index.js +3 -2
  58. package/es/components/Tile/Tile.d.ts +6 -0
  59. package/es/components/Tile/Tile.js +5 -9
  60. package/es/components/Toggletip/index.d.ts +3 -2
  61. package/es/components/Tooltip/DefinitionTooltip.d.ts +4 -0
  62. package/es/components/Tooltip/DefinitionTooltip.js +7 -1
  63. package/es/components/Tooltip/Tooltip.d.ts +5 -66
  64. package/es/components/Tooltip/Tooltip.js +26 -26
  65. package/es/components/UIShell/HeaderGlobalAction.d.ts +9 -0
  66. package/es/components/UIShell/HeaderGlobalAction.js +16 -1
  67. package/es/index.d.ts +4 -1
  68. package/es/index.js +2 -1
  69. package/es/internal/FloatingMenu.d.ts +83 -0
  70. package/es/internal/FloatingMenu.js +216 -408
  71. package/es/internal/wrapFocus.js +1 -1
  72. package/lib/components/Accordion/AccordionItem.js +1 -1
  73. package/lib/components/BadgeIndicator/index.d.ts +23 -0
  74. package/lib/components/BadgeIndicator/index.js +56 -0
  75. package/lib/components/Breadcrumb/Breadcrumb.d.ts +5 -0
  76. package/lib/components/Breadcrumb/Breadcrumb.js +8 -2
  77. package/lib/components/Button/Button.d.ts +9 -0
  78. package/lib/components/Button/Button.js +13 -0
  79. package/lib/components/ComboBox/ComboBox.js +19 -15
  80. package/lib/components/ComboButton/index.js +0 -1
  81. package/lib/components/ContextMenu/useContextMenu.d.ts +0 -1
  82. package/lib/components/ContextMenu/useContextMenu.js +1 -2
  83. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  84. package/lib/components/Dropdown/Dropdown.js +2 -1
  85. package/lib/components/FileUploader/FileUploader.js +1 -1
  86. package/lib/components/FileUploader/FileUploaderItem.js +1 -1
  87. package/lib/components/IconButton/index.d.ts +7 -1
  88. package/lib/components/IconButton/index.js +18 -2
  89. package/lib/components/IconIndicator/index.d.ts +1 -1
  90. package/lib/components/InlineLoading/InlineLoading.js +2 -5
  91. package/lib/components/Menu/Menu.d.ts +1 -0
  92. package/lib/components/Menu/Menu.js +5 -7
  93. package/lib/components/Menu/MenuContext.d.ts +4 -4
  94. package/lib/components/Menu/MenuContext.js +6 -1
  95. package/lib/components/Menu/MenuItem.d.ts +1 -1
  96. package/lib/components/Menu/MenuItem.js +14 -22
  97. package/lib/components/MenuButton/index.js +14 -2
  98. package/lib/components/Modal/Modal.d.ts +3 -3
  99. package/lib/components/Modal/Modal.js +9 -3
  100. package/lib/components/Modal/next/index.d.ts +1 -5
  101. package/lib/components/MultiSelect/MultiSelect.js +2 -1
  102. package/lib/components/MultiSelect/MultiSelectPropTypes.d.ts +5 -2
  103. package/lib/components/MultiSelect/tools/sorting.js +8 -7
  104. package/lib/components/Notification/Notification.js +5 -6
  105. package/lib/components/NumberInput/NumberInput.js +12 -12
  106. package/lib/components/OverflowMenu/OverflowMenu.d.ts +8 -20
  107. package/lib/components/OverflowMenu/OverflowMenu.js +7 -9
  108. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +1 -1
  109. package/lib/components/ProgressIndicator/ProgressIndicator.js +1 -1
  110. package/lib/components/RadioTile/RadioTile.js +1 -1
  111. package/lib/components/Select/Select.js +11 -2
  112. package/lib/components/ShapeIndicator/index.d.ts +29 -0
  113. package/lib/components/ShapeIndicator/index.js +104 -0
  114. package/lib/components/Tabs/Tabs.d.ts +6 -4
  115. package/lib/components/Tabs/Tabs.js +42 -23
  116. package/lib/components/Tag/OperationalTag.d.ts +1 -36
  117. package/lib/components/Tag/OperationalTag.js +6 -4
  118. package/lib/components/Text/Text.d.ts +11 -9
  119. package/lib/components/Text/Text.js +5 -5
  120. package/lib/components/Text/TextDirection.d.ts +7 -9
  121. package/lib/components/Text/TextDirection.js +5 -2
  122. package/lib/components/Text/TextDirectionContext.d.ts +14 -0
  123. package/lib/components/Text/TextDirectionContext.js +6 -2
  124. package/lib/components/Text/createTextComponent.d.ts +5 -5
  125. package/lib/components/Text/createTextComponent.js +5 -4
  126. package/lib/components/Text/index.d.ts +6 -7
  127. package/lib/components/Text/index.js +4 -3
  128. package/lib/components/Tile/Tile.d.ts +6 -0
  129. package/lib/components/Tile/Tile.js +5 -9
  130. package/lib/components/Toggletip/index.d.ts +3 -2
  131. package/lib/components/Tooltip/DefinitionTooltip.d.ts +4 -0
  132. package/lib/components/Tooltip/DefinitionTooltip.js +7 -1
  133. package/lib/components/Tooltip/Tooltip.d.ts +5 -66
  134. package/lib/components/Tooltip/Tooltip.js +26 -26
  135. package/lib/components/UIShell/HeaderGlobalAction.d.ts +9 -0
  136. package/lib/components/UIShell/HeaderGlobalAction.js +16 -1
  137. package/lib/index.d.ts +4 -1
  138. package/lib/index.js +42 -40
  139. package/lib/internal/FloatingMenu.d.ts +83 -0
  140. package/lib/internal/FloatingMenu.js +216 -409
  141. package/lib/internal/wrapFocus.js +1 -1
  142. package/package.json +5 -5
  143. package/scss/components/badge-indicator/_badge-indicator.scss +9 -0
  144. package/scss/components/badge-indicator/_index.scss +9 -0
@@ -18,13 +18,12 @@ var iconsReact = require('@carbon/icons-react');
18
18
  var useControllableState = require('../../internal/useControllableState.js');
19
19
  var useMergedRefs = require('../../internal/useMergedRefs.js');
20
20
  var usePrefix = require('../../internal/usePrefix.js');
21
- var warning = require('../../internal/warning.js');
22
21
  var Menu = require('./Menu.js');
23
22
  var MenuContext = require('./MenuContext.js');
24
23
  require('../Text/index.js');
25
24
  var useLayoutDirection = require('../LayoutDirection/useLayoutDirection.js');
26
- var Text = require('../Text/Text.js');
27
25
  var match = require('../../internal/keyboard/match.js');
26
+ var Text = require('../Text/Text.js');
28
27
  var keys = require('../../internal/keyboard/keys.js');
29
28
 
30
29
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -33,7 +32,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
33
32
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
34
33
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
35
34
 
36
- var _CaretLeft, _CaretRight;
35
+ var _Checkmark, _CaretLeft, _CaretRight;
37
36
  const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(_ref, forwardRef) {
38
37
  let {
39
38
  children,
@@ -144,15 +143,14 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(_ref, forwardRe
144
143
  setRtl(false);
145
144
  }
146
145
  }, [direction]);
147
- const iconsAllowed = context.state.mode === 'basic' || rest.role === 'menuitemcheckbox' || rest.role === 'menuitemradio';
148
146
  React.useEffect(() => {
149
- if (iconsAllowed && IconElement && !context.state.hasIcons) {
147
+ if (IconElement && !context.state.hasIcons) {
150
148
  // @ts-ignore - TODO: Should we be passing payload?
151
149
  context.dispatch({
152
150
  type: 'enableIcons'
153
151
  });
154
152
  }
155
- }, [iconsAllowed, IconElement, context.state.hasIcons, context]);
153
+ }, [IconElement, context.state.hasIcons, context]);
156
154
  React.useEffect(() => {
157
155
  Object.keys(floatingStyles).forEach(style => {
158
156
  if (refs.floating.current && style !== 'position') {
@@ -176,8 +174,10 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(_ref, forwardRe
176
174
  onClick: handleClick,
177
175
  onKeyDown: handleKeyDown
178
176
  }, getReferenceProps()), /*#__PURE__*/React__default["default"].createElement("div", {
177
+ className: `${prefix}--menu-item__selection-icon`
178
+ }, rest['aria-checked'] && (_Checkmark || (_Checkmark = /*#__PURE__*/React__default["default"].createElement(iconsReact.Checkmark, null)))), /*#__PURE__*/React__default["default"].createElement("div", {
179
179
  className: `${prefix}--menu-item__icon`
180
- }, iconsAllowed && IconElement && /*#__PURE__*/React__default["default"].createElement(IconElement, null)), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
180
+ }, IconElement && /*#__PURE__*/React__default["default"].createElement(IconElement, null)), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
181
181
  as: "div",
182
182
  className: `${prefix}--menu-item__label`,
183
183
  title: label
@@ -222,7 +222,7 @@ MenuItem.propTypes = {
222
222
  // @ts-ignore-next-line -- avoid spurious (?) TS2322 error
223
223
  onClick: PropTypes__default["default"].func,
224
224
  /**
225
- * Only applicable if the parent menu is in `basic` mode. Sets the menu item's icon.
225
+ * Sets the menu item's icon.
226
226
  */
227
227
  // @ts-ignore-next-line -- avoid spurious (?) TS2322 error
228
228
  renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
@@ -243,9 +243,6 @@ const MenuItemSelectable = /*#__PURE__*/React.forwardRef(function MenuItemSelect
243
243
  } = _ref2;
244
244
  const prefix = usePrefix.usePrefix();
245
245
  const context = React.useContext(MenuContext.MenuContext);
246
- if (context.state.mode === 'basic') {
247
- process.env.NODE_ENV !== "production" ? warning.warning(false, 'MenuItemSelectable is not supported when the menu is in "basic" mode.') : void 0;
248
- }
249
246
  const [checked, setChecked] = useControllableState.useControllableState({
250
247
  value: selected,
251
248
  onChange,
@@ -255,13 +252,13 @@ const MenuItemSelectable = /*#__PURE__*/React.forwardRef(function MenuItemSelect
255
252
  setChecked(!checked);
256
253
  }
257
254
  React.useEffect(() => {
258
- if (!context.state.hasIcons) {
255
+ if (!context.state.hasSelectableItems) {
259
256
  // @ts-ignore - TODO: Should we be passing payload?
260
257
  context.dispatch({
261
- type: 'enableIcons'
258
+ type: 'enableSelectableItems'
262
259
  });
263
260
  }
264
- }, [context.state.hasIcons, context]);
261
+ }, [context.state.hasSelectableItems, context]);
265
262
  const classNames = cx__default["default"](className, `${prefix}--menu-item-selectable--selected`);
266
263
  return /*#__PURE__*/React__default["default"].createElement(MenuItem, _rollupPluginBabelHelpers["extends"]({}, rest, {
267
264
  ref: forwardRef,
@@ -269,7 +266,6 @@ const MenuItemSelectable = /*#__PURE__*/React.forwardRef(function MenuItemSelect
269
266
  className: classNames,
270
267
  role: "menuitemcheckbox",
271
268
  "aria-checked": checked,
272
- renderIcon: checked ? iconsReact.Checkmark : undefined,
273
269
  onClick: handleClick
274
270
  }));
275
271
  });
@@ -344,9 +340,6 @@ const MenuItemRadioGroup = /*#__PURE__*/React.forwardRef(function MenuItemRadioG
344
340
  } = _ref4;
345
341
  const prefix = usePrefix.usePrefix();
346
342
  const context = React.useContext(MenuContext.MenuContext);
347
- if (context.state.mode === 'basic') {
348
- process.env.NODE_ENV !== "production" ? warning.warning(false, 'MenuItemRadioGroup is not supported when the menu is in "basic" mode.') : void 0;
349
- }
350
343
  const [selection, setSelection] = useControllableState.useControllableState({
351
344
  value: selectedItem,
352
345
  onChange,
@@ -356,13 +349,13 @@ const MenuItemRadioGroup = /*#__PURE__*/React.forwardRef(function MenuItemRadioG
356
349
  setSelection(item);
357
350
  }
358
351
  React.useEffect(() => {
359
- if (!context.state.hasIcons) {
352
+ if (!context.state.hasSelectableItems) {
360
353
  // @ts-ignore - TODO: Should we be passing payload?
361
354
  context.dispatch({
362
- type: 'enableIcons'
355
+ type: 'enableSelectableItems'
363
356
  });
364
357
  }
365
- }, [context.state.hasIcons, context]);
358
+ }, [context.state.hasSelectableItems, context]);
366
359
  const classNames = cx__default["default"](className, `${prefix}--menu-item-radio-group`);
367
360
  return /*#__PURE__*/React__default["default"].createElement("li", {
368
361
  className: classNames,
@@ -376,7 +369,6 @@ const MenuItemRadioGroup = /*#__PURE__*/React.forwardRef(function MenuItemRadioG
376
369
  label: itemToString(item),
377
370
  role: "menuitemradio",
378
371
  "aria-checked": item === selection,
379
- renderIcon: item === selection ? iconsReact.Checkmark : undefined,
380
372
  onClick: e => {
381
373
  handleClick(item);
382
374
  }
@@ -83,6 +83,15 @@ const MenuButton = /*#__PURE__*/React.forwardRef(function MenuButton(_ref, forwa
83
83
  // “break” the floating element out of a clipping ancestor.
84
84
  // https://floating-ui.com/docs/misc#clipping
85
85
  strategy: 'fixed',
86
+ // Submenus are using a fixed position to break out of the parent menu's
87
+ // box avoiding clipping while allowing for vertical scroll. When an
88
+ // element is using transform it establishes a new containing block
89
+ // block for all of its descendants. Therefore, its padding box will be
90
+ // used for fixed-positioned descendants. This would cause the submenu
91
+ // to be clipped by its parent menu.
92
+ // Reference: https://www.w3.org/TR/2019/CR-css-transforms-1-20190214/#current-transformation-matrix-computation
93
+ // Reference: https://github.com/carbon-design-system/carbon/pull/18153#issuecomment-2498548835
94
+ transform: false,
86
95
  // Middleware order matters, arrow should be last
87
96
  middleware: middlewares,
88
97
  whileElementsMounted: react.autoUpdate
@@ -97,7 +106,11 @@ const MenuButton = /*#__PURE__*/React.forwardRef(function MenuButton(_ref, forwa
97
106
  React.useLayoutEffect(() => {
98
107
  Object.keys(floatingStyles).forEach(style => {
99
108
  if (refs.floating.current) {
100
- refs.floating.current.style[style] = floatingStyles[style];
109
+ let value = floatingStyles[style];
110
+ if (['top', 'right', 'bottom', 'left'].includes(style) && Number(value)) {
111
+ value += 'px';
112
+ }
113
+ refs.floating.current.style[style] = value;
101
114
  }
102
115
  });
103
116
  }, [floatingStyles, refs.floating, middlewareData, placement, open]);
@@ -136,7 +149,6 @@ const MenuButton = /*#__PURE__*/React.forwardRef(function MenuButton(_ref, forwa
136
149
  id: id,
137
150
  legacyAutoalign: false,
138
151
  label: label,
139
- mode: "basic",
140
152
  size: size,
141
153
  open: open,
142
154
  onClose: handleClose,
@@ -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, type Ref } from 'react';
8
8
  import { ReactAttr } from '../../types/common';
9
9
  import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
10
10
  export declare const ModalSizes: readonly ["xs", "sm", "md", "lg"];
@@ -58,7 +58,7 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
58
58
  /**
59
59
  * Provide a ref to return focus to once the modal is closed.
60
60
  */
61
- launcherButtonRef?: any;
61
+ launcherButtonRef?: Ref<HTMLButtonElement>;
62
62
  /**
63
63
  * Specify the description for the loading text
64
64
  */
@@ -32,8 +32,8 @@ var index = require('../FeatureFlags/index.js');
32
32
  var events = require('../../tools/events.js');
33
33
  var deprecate = require('../../prop-types/deprecate.js');
34
34
  var debounce = require('../../node_modules/es-toolkit/dist/compat/function/debounce.mjs.js');
35
- var Text = require('../Text/Text.js');
36
35
  var match = require('../../internal/keyboard/match.js');
36
+ var Text = require('../Text/Text.js');
37
37
  var keys = require('../../internal/keyboard/keys.js');
38
38
 
39
39
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -200,7 +200,9 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
200
200
  React.useEffect(() => {
201
201
  if (!open && launcherButtonRef) {
202
202
  setTimeout(() => {
203
- launcherButtonRef?.current?.focus();
203
+ if ('current' in launcherButtonRef) {
204
+ launcherButtonRef.current?.focus();
205
+ }
204
206
  });
205
207
  }
206
208
  }, [open, launcherButtonRef]);
@@ -383,7 +385,11 @@ Modal.propTypes = {
383
385
  * Provide a ref to return focus to once the modal is closed.
384
386
  */
385
387
  launcherButtonRef: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].shape({
386
- current: PropTypes__default["default"].any
388
+ current: PropTypes__default["default"].oneOfType([
389
+ // `PropTypes.instanceOf(HTMLButtonElement)` alone won't work because
390
+ // `HTMLButtonElement` is not defined in the test environment even
391
+ // though `testEnvironment` is set to `jsdom`.
392
+ typeof HTMLButtonElement !== 'undefined' ? PropTypes__default["default"].instanceOf(HTMLButtonElement) : PropTypes__default["default"].any, PropTypes__default["default"].oneOf([null])]).isRequired
387
393
  })]),
388
394
  /**
389
395
  * Specify the description for the loading text
@@ -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,10 +50,6 @@ export interface BaseModalProps extends ReactAttr<HTMLDivElement> {
50
50
  * Specify whether or not the Modal content should have any inner padding.
51
51
  */
52
52
  isFullWidth?: boolean;
53
- /**
54
- * Provide a ref to return focus to once the modal is closed.
55
- */
56
- launcherButtonRef?: any;
57
53
  /**
58
54
  * Specify the description for the loading text
59
55
  */
@@ -435,11 +435,12 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
435
435
  const menuProps = React.useMemo(() => getMenuProps({
436
436
  ref: enableFloatingStyles ? refs.setFloating : null
437
437
  }), [enableFloatingStyles, getMenuProps, refs.setFloating]);
438
+ const labelProps = ! /*#__PURE__*/React.isValidElement(titleText) ? getLabelProps() : null;
438
439
  return /*#__PURE__*/React__default["default"].createElement("div", {
439
440
  className: wrapperClasses
440
441
  }, /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
441
442
  className: titleClasses
442
- }, getLabelProps()), titleText && titleText, selectedItems.length > 0 && /*#__PURE__*/React__default["default"].createElement("span", {
443
+ }, labelProps), titleText && titleText, selectedItems.length > 0 && /*#__PURE__*/React__default["default"].createElement("span", {
443
444
  className: `${prefix}--visually-hidden`
444
445
  }, clearSelectionDescription, " ", selectedItems.length, ' ', itemsSelectedText, ",", clearSelectionText)), /*#__PURE__*/React__default["default"].createElement(index$1["default"], {
445
446
  onFocus: isFluid ? handleFocus : undefined,
@@ -40,8 +40,11 @@ interface DownshiftTypedProps<ItemType> {
40
40
  interface SharedOptions {
41
41
  locale: string;
42
42
  }
43
+ interface CompareItems {
44
+ (itemA: string, itemB: string, options: SharedOptions): number;
45
+ }
43
46
  export interface SortItemsOptions<ItemType> extends SharedOptions, DownshiftTypedProps<ItemType> {
44
- compareItems(item1: ItemType, item2: ItemType, options: SharedOptions): number;
47
+ compareItems: CompareItems;
45
48
  selectedItems: ItemType[];
46
49
  }
47
50
  export interface MultiSelectSortingProps<ItemType> {
@@ -49,7 +52,7 @@ export interface MultiSelectSortingProps<ItemType> {
49
52
  * Provide a compare function that is used to determine the ordering of
50
53
  * options. See 'sortItems' for more control.
51
54
  */
52
- compareItems?(item1: ItemType, item2: ItemType, options: SharedOptions): number;
55
+ compareItems?: CompareItems;
53
56
  /**
54
57
  * Provide a method that sorts all options in the control. Overriding this
55
58
  * prop means that you also have to handle the sort logic for selected versus
@@ -10,14 +10,15 @@
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  /**
13
- * Use the local `localCompare` with the `numeric` option to sort two,
14
- * potentially alpha-numeric, strings in a list of items.
13
+ * Use the locale `localeCompare` with the `numeric` option to sort two
14
+ * alpha-numeric strings.
15
15
  *
16
- * @param {ItemType} itemA
17
- * @param {ItemType} itemB
18
- * @param {object} options
19
- * @param {string} options.locale
20
- * @returns {number}
16
+ * @param {string} itemA - The first string to compare.
17
+ * @param {string} itemB - The second string to compare.
18
+ * @param {object} options - Options for comparing.
19
+ * @param {string} options.locale - The locale to use for comparison.
20
+ * @returns {number} A negative number if itemA comes before itemB, a positive
21
+ * number if itemA comes after itemB, or 0 if they are equal.
21
22
  */
22
23
  const defaultCompareItems = (itemA, itemB, _ref) => {
23
24
  let {
@@ -27,8 +27,8 @@ var wrapFocus = require('../../internal/wrapFocus.js');
27
27
  var index = require('../FeatureFlags/index.js');
28
28
  var warning = require('../../internal/warning.js');
29
29
  var deprecateValuesWithin = require('../../prop-types/deprecateValuesWithin.js');
30
- var Text = require('../Text/Text.js');
31
30
  var match = require('../../internal/keyboard/match.js');
31
+ var Text = require('../Text/Text.js');
32
32
  var keys = require('../../internal/keyboard/keys.js');
33
33
 
34
34
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -740,11 +740,9 @@ function Callout(_ref8) {
740
740
  [`${prefix}--actionable-notification--${kind}`]: kind,
741
741
  [`${prefix}--actionable-notification--hide-close-button`]: true
742
742
  });
743
- const ref = React.useRef(null);
744
- useNoInteractiveChildren.useInteractiveChildrenNeedDescription(ref, `interactive child node(s) should have an \`aria-describedby\` property with a value matching the value of \`titleId\``);
745
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
746
- ref: ref
747
- }, rest, {
743
+ const childrenContainer = React.useRef(null);
744
+ useNoInteractiveChildren.useInteractiveChildrenNeedDescription(childrenContainer, `interactive child node(s) should have an \`aria-describedby\` property with a value matching the value of \`titleId\``);
745
+ return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
748
746
  className: containerClassName
749
747
  }), /*#__PURE__*/React__default["default"].createElement("div", {
750
748
  className: `${prefix}--actionable-notification__details`
@@ -753,6 +751,7 @@ function Callout(_ref8) {
753
751
  kind: kind,
754
752
  iconDescription: statusIconDescription || `${kind} icon`
755
753
  }), /*#__PURE__*/React__default["default"].createElement("div", {
754
+ ref: childrenContainer,
756
755
  className: `${prefix}--actionable-notification__text-wrapper`
757
756
  }, title && /*#__PURE__*/React__default["default"].createElement(Text.Text, {
758
757
  as: "div",
@@ -173,20 +173,20 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
173
173
  [`${prefix}--number-input--fluid--disabled`]: isFluid && disabled
174
174
  });
175
175
  const Icon = normalizedProps.icon;
176
- function handleStepperClick(event, direction) {
176
+ const getDecimalPlaces = num => {
177
+ const parts = num.toString().split('.');
178
+ return parts[1] ? parts[1].length : 0;
179
+ };
180
+ const handleStepperClick = (event, direction) => {
177
181
  if (inputRef.current) {
178
182
  const currentValue = Number(inputRef.current.value);
179
- let newValue = direction === 'up' ? currentValue + step : currentValue - step;
180
- if (min !== undefined) {
181
- newValue = Math.max(newValue, min);
182
- }
183
- if (max !== undefined) {
184
- newValue = Math.min(newValue, max);
185
- }
186
- const currentInputValue = inputRef.current ? inputRef.current.value : '';
183
+ const rawValue = direction === 'up' ? currentValue + step : currentValue - step;
184
+ const precision = Math.max(getDecimalPlaces(currentValue), getDecimalPlaces(step));
185
+ const floatValue = parseFloat(rawValue.toFixed(precision));
186
+ const newValue = typeof min !== 'undefined' && typeof max !== 'undefined' ? Math.min(Math.max(floatValue, min), max) : floatValue;
187
187
  const state = {
188
- value: allowEmpty && currentInputValue === '' && step === 0 ? '' : newValue,
189
- direction: direction
188
+ value: allowEmpty && inputRef.current.value === '' && step === 0 ? '' : newValue,
189
+ direction
190
190
  };
191
191
  setValue(state.value);
192
192
  if (onChange) {
@@ -196,7 +196,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
196
196
  onClick(event, state);
197
197
  }
198
198
  }
199
- }
199
+ };
200
200
 
201
201
  // AILabel always size `mini`
202
202
  let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
@@ -1,25 +1,13 @@
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 { type MenuDirection, type MenuOffset } from '../../internal/FloatingMenu';
7
8
  import React, { ComponentType } from 'react';
8
9
  import PropTypes from 'prop-types';
9
- /**
10
- * @param {Element} menuBody The menu body with the menu arrow.
11
- * @param {string} direction The floating menu direction.
12
- * @returns {FloatingMenu~offset} The adjustment of the floating menu position, upon the position of the menu arrow.
13
- * @private
14
- */
15
- export declare const getMenuOffset: (menuBody: any, direction: any, trigger: any, flip: any) => {
16
- left: number;
17
- top: number;
18
- } | undefined;
19
- interface Offset {
20
- top?: number | null | undefined;
21
- left?: number | null | undefined;
22
- }
10
+ export declare const getMenuOffset: MenuOffset;
23
11
  type IconProps = {
24
12
  className?: string;
25
13
  'aria-label'?: string;
@@ -46,7 +34,7 @@ export interface OverflowMenuProps {
46
34
  /**
47
35
  * The menu direction.
48
36
  */
49
- direction?: string;
37
+ direction?: MenuDirection;
50
38
  /**
51
39
  * `true` if the menu alignment should be flipped.
52
40
  */
@@ -75,11 +63,11 @@ export interface OverflowMenuProps {
75
63
  /**
76
64
  * The adjustment in position applied to the floating menu.
77
65
  */
78
- menuOffset?: Offset | (() => void);
66
+ menuOffset?: MenuOffset;
79
67
  /**
80
68
  * The adjustment in position applied to the floating menu.
81
69
  */
82
- menuOffsetFlip?: Offset | (() => void);
70
+ menuOffsetFlip?: MenuOffset;
83
71
  /**
84
72
  * The class to apply to the menu options
85
73
  */
@@ -246,10 +234,10 @@ declare class OverflowMenu extends React.Component<OverflowMenuProps, OverflowMe
246
234
  _hBlurTimeout: any;
247
235
  /**
248
236
  * The element ref of the tooltip's trigger button.
249
- * @type {React.RefObject<Element>}
237
+ * @type {React.RefObject<HTMLElement>}
250
238
  * @private
251
239
  */
252
- _triggerRef: React.RefObject<unknown>;
240
+ _triggerRef: React.RefObject<HTMLElement>;
253
241
  componentDidUpdate(_: any, prevState: any): void;
254
242
  componentDidMount(): void;
255
243
  static getDerivedStateFromProps({ open }: {
@@ -64,13 +64,6 @@ const triggerButtonPositionFactors = {
64
64
  [FloatingMenu.DIRECTION_TOP]: -2,
65
65
  [FloatingMenu.DIRECTION_BOTTOM]: -1
66
66
  };
67
-
68
- /**
69
- * @param {Element} menuBody The menu body with the menu arrow.
70
- * @param {string} direction The floating menu direction.
71
- * @returns {FloatingMenu~offset} The adjustment of the floating menu position, upon the position of the menu arrow.
72
- * @private
73
- */
74
67
  const getMenuOffset = (menuBody, direction, trigger, flip) => {
75
68
  const triggerButtonPositionProp = triggerButtonPositionProps[direction];
76
69
  const triggerButtonPositionFactor = triggerButtonPositionFactors[direction];
@@ -92,6 +85,11 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
92
85
  top: 0
93
86
  };
94
87
  }
88
+ default:
89
+ return {
90
+ left: 0,
91
+ top: 0
92
+ };
95
93
  }
96
94
  };
97
95
  class OverflowMenu extends React__default["default"].Component {
@@ -117,7 +115,7 @@ class OverflowMenu extends React__default["default"].Component {
117
115
  _rollupPluginBabelHelpers.defineProperty(this, "_hBlurTimeout", void 0);
118
116
  /**
119
117
  * The element ref of the tooltip's trigger button.
120
- * @type {React.RefObject<Element>}
118
+ * @type {React.RefObject<HTMLElement>}
121
119
  * @private
122
120
  */
123
121
  _rollupPluginBabelHelpers.defineProperty(this, "_triggerRef", /*#__PURE__*/React__default["default"].createRef());
@@ -374,7 +372,7 @@ class OverflowMenu extends React__default["default"].Component {
374
372
  onKeyDown: this.handleKeyPress,
375
373
  id: menuBodyId
376
374
  }, childrenWithProps);
377
- const wrappedMenuBody = /*#__PURE__*/React__default["default"].createElement(FloatingMenu["default"], {
375
+ const wrappedMenuBody = /*#__PURE__*/React__default["default"].createElement(FloatingMenu.FloatingMenu, {
378
376
  focusTrap: focusTrap,
379
377
  triggerRef: this._triggerRef,
380
378
  menuDirection: direction,
@@ -16,8 +16,8 @@ var React = require('react');
16
16
  var usePrefix = require('../../internal/usePrefix.js');
17
17
  var warning = require('../../internal/warning.js');
18
18
  require('../Text/index.js');
19
- var Text = require('../Text/Text.js');
20
19
  var match = require('../../internal/keyboard/match.js');
20
+ var Text = require('../Text/Text.js');
21
21
  var keys = require('../../internal/keyboard/keys.js');
22
22
 
23
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -16,8 +16,8 @@ var React = require('react');
16
16
  var iconsReact = require('@carbon/icons-react');
17
17
  var usePrefix = require('../../internal/usePrefix.js');
18
18
  require('../Text/index.js');
19
- var Text = require('../Text/Text.js');
20
19
  var match = require('../../internal/keyboard/match.js');
20
+ var Text = require('../Text/Text.js');
21
21
  var keys = require('../../internal/keyboard/keys.js');
22
22
 
23
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -20,8 +20,8 @@ var deprecate = require('../../prop-types/deprecate.js');
20
20
  var noopFn = require('../../internal/noopFn.js');
21
21
  require('../Text/index.js');
22
22
  var index = require('../FeatureFlags/index.js');
23
- var Text = require('../Text/Text.js');
24
23
  var match = require('../../internal/keyboard/match.js');
24
+ var Text = require('../Text/Text.js');
25
25
  var keys = require('../../internal/keyboard/keys.js');
26
26
 
27
27
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -59,8 +59,16 @@ const Select = /*#__PURE__*/React__default["default"].forwardRef(function Select
59
59
  isFluid
60
60
  } = React.useContext(FormContext.FormContext);
61
61
  const [isFocused, setIsFocused] = React.useState(false);
62
- const [title, setTitle] = React.useState('');
63
62
  const selectInstanceId = useId.useId();
63
+ // Convert children to an array of valid elements once using type narrowing
64
+ const validChildren = React__default["default"].Children.toArray(children).filter(child => /*#__PURE__*/React__default["default"].isValidElement(child));
65
+
66
+ // Find the default option based on the specified defaultValue
67
+ const defaultOption = validChildren.find(child => child.props?.value === other?.defaultValue);
68
+
69
+ // Use the default option's text if available; otherwise, fallback to the first option's text
70
+ const initialTitle = defaultOption?.props?.text || validChildren[0]?.props?.text || '';
71
+ const [title, setTitle] = React.useState(initialTitle);
64
72
  const selectClasses = cx__default["default"]({
65
73
  [`${prefix}--select`]: true,
66
74
  [`${prefix}--select--inline`]: inline,
@@ -115,7 +123,8 @@ const Select = /*#__PURE__*/React__default["default"].forwardRef(function Select
115
123
  setIsFocused(evt.type === 'focus' ? true : false);
116
124
  };
117
125
  const handleChange = evt => {
118
- setTitle(evt?.target?.value);
126
+ const selectedOption = evt?.target?.options[evt.target.selectedIndex];
127
+ setTitle(selectedOption?.text);
119
128
  };
120
129
  const readOnlyEventHandlers = {
121
130
  onMouseDown: evt => {
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025, 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 React from 'react';
8
+ export declare const ShapeIndicatorKinds: string[];
9
+ export type ShapeIndicatorKind = (typeof ShapeIndicatorKinds)[number];
10
+ export interface ShapeIndicatorProps {
11
+ /**
12
+ * Specify an optional className to add.
13
+ */
14
+ className?: string;
15
+ /**
16
+ * Specify the kind of shape to be used
17
+ */
18
+ kind: ShapeIndicatorKind;
19
+ /**
20
+ * Label next to the shape
21
+ */
22
+ label: string;
23
+ /**
24
+ * Specify the text size of the Shape Indicator. Defaults to 12.
25
+ */
26
+ textSize?: 12 | 14;
27
+ }
28
+ export declare const ShapeIndicator: React.ForwardRefExoticComponent<ShapeIndicatorProps & React.RefAttributes<HTMLDivElement>>;
29
+ export default ShapeIndicator;