@carbon/react 1.77.0 → 1.78.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 (126) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +945 -858
  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 +13 -9
  10. package/es/components/Dropdown/Dropdown.d.ts +1 -1
  11. package/es/components/Dropdown/Dropdown.js +3 -2
  12. package/es/components/FileUploader/FileUploader.js +1 -1
  13. package/es/components/FileUploader/FileUploaderItem.js +1 -1
  14. package/es/components/IconButton/index.d.ts +7 -1
  15. package/es/components/IconButton/index.js +18 -2
  16. package/es/components/IconIndicator/index.d.ts +1 -1
  17. package/es/components/InlineLoading/InlineLoading.js +2 -5
  18. package/es/components/Menu/MenuItem.js +1 -1
  19. package/es/components/Modal/Modal.d.ts +3 -3
  20. package/es/components/Modal/Modal.js +9 -3
  21. package/es/components/Modal/next/index.d.ts +1 -5
  22. package/es/components/MultiSelect/MultiSelect.js +3 -2
  23. package/es/components/MultiSelect/MultiSelectPropTypes.d.ts +5 -2
  24. package/es/components/MultiSelect/tools/sorting.js +8 -7
  25. package/es/components/Notification/Notification.js +1 -1
  26. package/es/components/NumberInput/NumberInput.js +12 -12
  27. package/es/components/OverflowMenu/OverflowMenu.d.ts +8 -20
  28. package/es/components/OverflowMenu/OverflowMenu.js +7 -9
  29. package/es/components/OverflowMenuItem/OverflowMenuItem.js +1 -1
  30. package/es/components/ProgressIndicator/ProgressIndicator.js +1 -1
  31. package/es/components/RadioTile/RadioTile.js +1 -1
  32. package/es/components/Select/Select.js +11 -2
  33. package/es/components/ShapeIndicator/index.d.ts +29 -0
  34. package/es/components/ShapeIndicator/index.js +92 -0
  35. package/es/components/Tabs/Tabs.d.ts +6 -4
  36. package/es/components/Tabs/Tabs.js +27 -8
  37. package/es/components/Tag/OperationalTag.d.ts +1 -36
  38. package/es/components/Tag/OperationalTag.js +7 -5
  39. package/es/components/Text/Text.d.ts +11 -9
  40. package/es/components/Text/Text.js +6 -6
  41. package/es/components/Text/TextDirection.d.ts +7 -9
  42. package/es/components/Text/TextDirection.js +5 -2
  43. package/es/components/Text/TextDirectionContext.d.ts +14 -0
  44. package/es/components/Text/TextDirectionContext.js +6 -2
  45. package/es/components/Text/createTextComponent.d.ts +5 -5
  46. package/es/components/Text/createTextComponent.js +5 -4
  47. package/es/components/Text/index.d.ts +6 -7
  48. package/es/components/Text/index.js +3 -2
  49. package/es/components/Tile/Tile.d.ts +6 -0
  50. package/es/components/Tile/Tile.js +5 -9
  51. package/es/components/Toggletip/index.d.ts +3 -2
  52. package/es/components/Tooltip/DefinitionTooltip.d.ts +4 -0
  53. package/es/components/Tooltip/DefinitionTooltip.js +7 -1
  54. package/es/components/Tooltip/Tooltip.d.ts +5 -66
  55. package/es/components/Tooltip/Tooltip.js +26 -26
  56. package/es/components/UIShell/HeaderGlobalAction.d.ts +9 -0
  57. package/es/components/UIShell/HeaderGlobalAction.js +16 -1
  58. package/es/index.d.ts +4 -1
  59. package/es/index.js +2 -1
  60. package/es/internal/FloatingMenu.d.ts +83 -0
  61. package/es/internal/FloatingMenu.js +216 -408
  62. package/es/internal/wrapFocus.js +1 -1
  63. package/lib/components/Accordion/AccordionItem.js +1 -1
  64. package/lib/components/BadgeIndicator/index.d.ts +23 -0
  65. package/lib/components/BadgeIndicator/index.js +56 -0
  66. package/lib/components/Breadcrumb/Breadcrumb.d.ts +5 -0
  67. package/lib/components/Breadcrumb/Breadcrumb.js +8 -2
  68. package/lib/components/Button/Button.d.ts +9 -0
  69. package/lib/components/Button/Button.js +13 -0
  70. package/lib/components/ComboBox/ComboBox.js +13 -9
  71. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  72. package/lib/components/Dropdown/Dropdown.js +2 -1
  73. package/lib/components/FileUploader/FileUploader.js +1 -1
  74. package/lib/components/FileUploader/FileUploaderItem.js +1 -1
  75. package/lib/components/IconButton/index.d.ts +7 -1
  76. package/lib/components/IconButton/index.js +18 -2
  77. package/lib/components/IconIndicator/index.d.ts +1 -1
  78. package/lib/components/InlineLoading/InlineLoading.js +2 -5
  79. package/lib/components/Menu/MenuItem.js +1 -1
  80. package/lib/components/Modal/Modal.d.ts +3 -3
  81. package/lib/components/Modal/Modal.js +9 -3
  82. package/lib/components/Modal/next/index.d.ts +1 -5
  83. package/lib/components/MultiSelect/MultiSelect.js +2 -1
  84. package/lib/components/MultiSelect/MultiSelectPropTypes.d.ts +5 -2
  85. package/lib/components/MultiSelect/tools/sorting.js +8 -7
  86. package/lib/components/Notification/Notification.js +1 -1
  87. package/lib/components/NumberInput/NumberInput.js +12 -12
  88. package/lib/components/OverflowMenu/OverflowMenu.d.ts +8 -20
  89. package/lib/components/OverflowMenu/OverflowMenu.js +7 -9
  90. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +1 -1
  91. package/lib/components/ProgressIndicator/ProgressIndicator.js +1 -1
  92. package/lib/components/RadioTile/RadioTile.js +1 -1
  93. package/lib/components/Select/Select.js +11 -2
  94. package/lib/components/ShapeIndicator/index.d.ts +29 -0
  95. package/lib/components/ShapeIndicator/index.js +104 -0
  96. package/lib/components/Tabs/Tabs.d.ts +6 -4
  97. package/lib/components/Tabs/Tabs.js +42 -23
  98. package/lib/components/Tag/OperationalTag.d.ts +1 -36
  99. package/lib/components/Tag/OperationalTag.js +6 -4
  100. package/lib/components/Text/Text.d.ts +11 -9
  101. package/lib/components/Text/Text.js +5 -5
  102. package/lib/components/Text/TextDirection.d.ts +7 -9
  103. package/lib/components/Text/TextDirection.js +5 -2
  104. package/lib/components/Text/TextDirectionContext.d.ts +14 -0
  105. package/lib/components/Text/TextDirectionContext.js +6 -2
  106. package/lib/components/Text/createTextComponent.d.ts +5 -5
  107. package/lib/components/Text/createTextComponent.js +5 -4
  108. package/lib/components/Text/index.d.ts +6 -7
  109. package/lib/components/Text/index.js +4 -3
  110. package/lib/components/Tile/Tile.d.ts +6 -0
  111. package/lib/components/Tile/Tile.js +5 -9
  112. package/lib/components/Toggletip/index.d.ts +3 -2
  113. package/lib/components/Tooltip/DefinitionTooltip.d.ts +4 -0
  114. package/lib/components/Tooltip/DefinitionTooltip.js +7 -1
  115. package/lib/components/Tooltip/Tooltip.d.ts +5 -66
  116. package/lib/components/Tooltip/Tooltip.js +26 -26
  117. package/lib/components/UIShell/HeaderGlobalAction.d.ts +9 -0
  118. package/lib/components/UIShell/HeaderGlobalAction.js +16 -1
  119. package/lib/index.d.ts +4 -1
  120. package/lib/index.js +42 -40
  121. package/lib/internal/FloatingMenu.d.ts +83 -0
  122. package/lib/internal/FloatingMenu.js +216 -409
  123. package/lib/internal/wrapFocus.js +1 -1
  124. package/package.json +5 -5
  125. package/scss/components/badge-indicator/_badge-indicator.scss +9 -0
  126. package/scss/components/badge-indicator/_index.scss +9 -0
@@ -15,8 +15,8 @@ import { useId } from '../../internal/useId.js';
15
15
  import deprecate from '../../prop-types/deprecate.js';
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
17
17
  import { AccordionContext } from './AccordionProvider.js';
18
- import { Text } from '../Text/Text.js';
19
18
  import { match } from '../../internal/keyboard/match.js';
19
+ import { Text } from '../Text/Text.js';
20
20
  import { Escape } from '../../internal/keyboard/keys.js';
21
21
 
22
22
  const defaultRenderToggle = props => /*#__PURE__*/React__default.createElement("button", _extends({
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ interface BadgeIndicatorProps {
9
+ /**
10
+ * Specify an optional className to add.
11
+ */
12
+ className?: string;
13
+ /**
14
+ * Count of badge indicator
15
+ */
16
+ count?: number;
17
+ /**
18
+ * Provide an `id` to uniquely identify the BadgeIndidcator
19
+ */
20
+ id?: string;
21
+ }
22
+ export declare const BadgeIndicator: React.ForwardRefExoticComponent<BadgeIndicatorProps & React.RefAttributes<HTMLDivElement>>;
23
+ export default BadgeIndicator;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import PropTypes from 'prop-types';
10
+ import React__default from 'react';
11
+ import cx from 'classnames';
12
+ import { usePrefix } from '../../internal/usePrefix.js';
13
+
14
+ const BadgeIndicator = /*#__PURE__*/React__default.forwardRef(function BadgeIndicatorContent(_ref, ref) {
15
+ let {
16
+ className: customClassName,
17
+ count,
18
+ ...rest
19
+ } = _ref;
20
+ const prefix = usePrefix();
21
+ const classNames = cx(`${prefix}--badge-indicator`, customClassName, {
22
+ [`${prefix}--badge-indicator--count`]: count
23
+ });
24
+ const displayCount = count && count > 999 ? '999+' : count;
25
+ return /*#__PURE__*/React__default.createElement("div", _extends({
26
+ className: classNames,
27
+ ref: ref
28
+ }, rest), displayCount);
29
+ });
30
+ BadgeIndicator.propTypes = {
31
+ /**
32
+ * Specify an optional className to add.
33
+ */
34
+ className: PropTypes.string,
35
+ /**
36
+ * Count of badge indicator
37
+ */
38
+ count: PropTypes.number,
39
+ /**
40
+ * Provide an `id` to uniquely identify the BadgeIndidcator
41
+ */
42
+ id: PropTypes.string
43
+ };
44
+
45
+ export { BadgeIndicator, BadgeIndicator as default };
@@ -19,6 +19,11 @@ export interface BreadcrumbProps extends React.HTMLAttributes<HTMLElement> {
19
19
  * Optional prop to omit the trailing slash for the breadcrumbs
20
20
  */
21
21
  noTrailingSlash?: boolean;
22
+ /**
23
+ * Specify the size of the Breadcrumb. Currently
24
+ * supports the following: `sm` & `md` (default: 'md')
25
+ */
26
+ size?: 'sm' | 'md';
22
27
  }
23
28
  declare const Breadcrumb: ForwardRefReturn<HTMLElement, BreadcrumbProps>;
24
29
  export default Breadcrumb;
@@ -17,12 +17,14 @@ const Breadcrumb = /*#__PURE__*/React__default.forwardRef(function Breadcrumb(_r
17
17
  children,
18
18
  className: customClassNameNav,
19
19
  noTrailingSlash,
20
+ size,
20
21
  ...rest
21
22
  } = _ref;
22
23
  const prefix = usePrefix();
23
24
  const className = cx({
24
25
  [`${prefix}--breadcrumb`]: true,
25
- [`${prefix}--breadcrumb--no-trailing-slash`]: noTrailingSlash
26
+ [`${prefix}--breadcrumb--no-trailing-slash`]: noTrailingSlash,
27
+ [`${prefix}--breadcrumb--sm`]: size === 'sm'
26
28
  });
27
29
  return /*#__PURE__*/React__default.createElement("nav", _extends({
28
30
  className: customClassNameNav,
@@ -49,7 +51,11 @@ Breadcrumb.propTypes = {
49
51
  /**
50
52
  * Optional prop to omit the trailing slash for the breadcrumbs
51
53
  */
52
- noTrailingSlash: PropTypes.bool
54
+ noTrailingSlash: PropTypes.bool,
55
+ /**
56
+ * Specify the size of the Breadcrumb. Currently supports the following:
57
+ */
58
+ size: PropTypes.oneOf(['sm', 'md'])
53
59
  };
54
60
 
55
61
  export { Breadcrumb as default };
@@ -67,6 +67,15 @@ export interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonEl
67
67
  * Can be one of: start, center, or end.
68
68
  */
69
69
  tooltipAlignment?: ButtonTooltipAlignment;
70
+ /**
71
+ * Enable drop shadow for tooltips for icon-only buttons.
72
+ */
73
+ tooltipDropShadow?: boolean;
74
+ /**
75
+ * Enable high-contrast theme for tooltips on icon-only buttons.
76
+ * Defaults to true.
77
+ */
78
+ tooltipHighContrast?: boolean;
70
79
  /**
71
80
  * Specify the direction of the tooltip for icon-only buttons.
72
81
  * Can be either top, right, bottom, or left.
@@ -29,6 +29,8 @@ const Button = /*#__PURE__*/React__default.forwardRef((props, ref) => {
29
29
  autoAlign = false,
30
30
  children,
31
31
  hasIconOnly = false,
32
+ tooltipHighContrast = true,
33
+ tooltipDropShadow = false,
32
34
  iconDescription,
33
35
  kind = 'primary',
34
36
  onBlur,
@@ -81,6 +83,8 @@ const Button = /*#__PURE__*/React__default.forwardRef((props, ref) => {
81
83
  label: iconDescription,
82
84
  kind: kind,
83
85
  size: size,
86
+ highContrast: tooltipHighContrast,
87
+ dropShadow: tooltipDropShadow,
84
88
  onMouseEnter: onMouseEnter,
85
89
  onMouseLeave: onMouseLeave,
86
90
  onFocus: onFocus,
@@ -215,6 +219,15 @@ Button.propTypes = {
215
219
  * Can be one of: start, center, or end.
216
220
  */
217
221
  tooltipAlignment: PropTypes.oneOf(['start', 'center', 'end']),
222
+ /**
223
+ * Enable drop shadow for tooltips for icon-only buttons.
224
+ */
225
+ tooltipDropShadow: PropTypes.bool,
226
+ /**
227
+ * Enable high-contrast theme for tooltips for icon-only buttons.
228
+ * Defaults to true.
229
+ */
230
+ tooltipHighContrast: PropTypes.bool,
218
231
  /**
219
232
  * Specify the direction of the tooltip for icon-only buttons.
220
233
  * Can be either top, right, bottom, or left.
@@ -24,9 +24,9 @@ import '../FluidForm/FluidForm.js';
24
24
  import { FormContext } from '../FluidForm/FormContext.js';
25
25
  import { useFloating, flip, hide, autoUpdate } from '@floating-ui/react';
26
26
  import { useFeatureFlag } from '../FeatureFlags/index.js';
27
- import { Text } from '../Text/Text.js';
28
27
  import { match } from '../../internal/keyboard/match.js';
29
28
  import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
29
+ import { Text } from '../Text/Text.js';
30
30
  import { Space, Enter, Escape, Home, End } from '../../internal/keyboard/keys.js';
31
31
 
32
32
  const {
@@ -465,11 +465,22 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
465
465
  }
466
466
  }
467
467
  },
468
+ initialSelectedItem: initialSelectedItem,
469
+ inputId: id,
470
+ stateReducer,
471
+ isItemDisabled(item, _index) {
472
+ return item?.disabled;
473
+ },
474
+ ...downshiftProps,
468
475
  onStateChange: _ref6 => {
469
476
  let {
470
477
  type,
471
478
  selectedItem: newSelectedItem
472
479
  } = _ref6;
480
+ downshiftProps?.onStateChange?.({
481
+ type,
482
+ selectedItem: newSelectedItem
483
+ });
473
484
  if (type === useCombobox.stateChangeTypes.ItemClick && !isEqual(selectedItemProp, newSelectedItem)) {
474
485
  onChange({
475
486
  selectedItem: newSelectedItem
@@ -481,14 +492,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
481
492
  selectedItem: newSelectedItem
482
493
  });
483
494
  }
484
- },
485
- initialSelectedItem: initialSelectedItem,
486
- inputId: id,
487
- stateReducer,
488
- isItemDisabled(item, _index) {
489
- return item?.disabled;
490
- },
491
- ...downshiftProps
495
+ }
492
496
  });
493
497
  useEffect(() => {
494
498
  // Used to expose the downshift actions to consumers for use with downshiftProps
@@ -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.
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { useEffect, useContext, useCallback, useMemo, useState } from 'react';
9
+ import React__default, { useEffect, useContext, useCallback, useMemo, useState, isValidElement } from 'react';
10
10
  import { useSelect } from 'downshift';
11
11
  import cx from 'classnames';
12
12
  import PropTypes from 'prop-types';
@@ -320,11 +320,12 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
320
320
  }
321
321
  return /*#__PURE__*/React__default.isValidElement(element) ? element : null;
322
322
  }, [slug, decorator]);
323
+ const labelProps = ! /*#__PURE__*/isValidElement(titleText) ? getLabelProps() : null;
323
324
  return /*#__PURE__*/React__default.createElement("div", _extends({
324
325
  className: wrapperClasses
325
326
  }, other), titleText && /*#__PURE__*/React__default.createElement("label", _extends({
326
327
  className: titleClasses
327
- }, getLabelProps()), titleText), /*#__PURE__*/React__default.createElement(ListBox, {
328
+ }, labelProps), titleText), /*#__PURE__*/React__default.createElement(ListBox, {
328
329
  onFocus: handleFocus,
329
330
  onBlur: handleFocus,
330
331
  size: size$1,
@@ -15,8 +15,8 @@ import { ButtonKinds } from '../Button/Button.js';
15
15
  import { usePrefix } from '../../internal/usePrefix.js';
16
16
  import '../Text/index.js';
17
17
  import { useId } from '../../internal/useId.js';
18
- import { Text } from '../Text/Text.js';
19
18
  import { matches } from '../../internal/keyboard/match.js';
19
+ import { Text } from '../Text/Text.js';
20
20
  import { Enter, Space } from '../../internal/keyboard/keys.js';
21
21
 
22
22
  const FileUploader = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
@@ -16,8 +16,8 @@ import { noopFn } from '../../internal/noopFn.js';
16
16
  import '../Text/index.js';
17
17
  import '../Tooltip/DefinitionTooltip.js';
18
18
  import { Tooltip } from '../Tooltip/Tooltip.js';
19
- import { Text } from '../Text/Text.js';
20
19
  import { matches } from '../../internal/keyboard/match.js';
20
+ import { Text } from '../Text/Text.js';
21
21
  import { Enter, Space } from '../../internal/keyboard/keys.js';
22
22
 
23
23
  function FileUploaderItem(_ref) {
@@ -20,6 +20,11 @@ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
20
20
  * **Experimental**: Will attempt to automatically align the tooltip
21
21
  */
22
22
  autoAlign?: boolean;
23
+ /**
24
+ * **Experimental**: Display a badge on the button. An empty/dot badge if 0, a numbered badge if > 0.
25
+ * Must be used with size="lg" and kind="ghost"
26
+ */
27
+ badgeCount?: number;
23
28
  /**
24
29
  * Optionally specify an href for your IconButton to become an `<a>` element
25
30
  */
@@ -68,7 +73,8 @@ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
68
73
  * Provide the label to be rendered inside of the Tooltip. The label will use
69
74
  * `aria-labelledby` and will fully describe the child node that is provided.
70
75
  * This means that if you have text in the child node it will not be
71
- * announced to the screen reader.
76
+ * announced to the screen reader. If using the badgeCount = 0 then provide a
77
+ * label with describing there is a new notification.
72
78
  */
73
79
  label: ReactNode;
74
80
  /**
@@ -11,9 +11,11 @@ import React__default from 'react';
11
11
  import cx from 'classnames';
12
12
  import '../Tooltip/DefinitionTooltip.js';
13
13
  import { Tooltip } from '../Tooltip/Tooltip.js';
14
+ import { useId } from '../../internal/useId.js';
14
15
  import { usePrefix } from '../../internal/usePrefix.js';
15
16
  import ButtonBase from '../Button/ButtonBase.js';
16
17
  import deprecateValuesWithin from '../../prop-types/deprecateValuesWithin.js';
18
+ import { BadgeIndicator } from '../BadgeIndicator/index.js';
17
19
 
18
20
  const IconButtonKinds = ['primary', 'secondary', 'ghost', 'tertiary'];
19
21
  const propMappingFunction = deprecatedValue => {
@@ -33,6 +35,7 @@ const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(_r
33
35
  let {
34
36
  align,
35
37
  autoAlign = false,
38
+ badgeCount,
36
39
  children,
37
40
  className,
38
41
  closeOnActivation = true,
@@ -53,6 +56,10 @@ const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(_r
53
56
  const tooltipClasses = cx(wrapperClasses, `${prefix}--icon-tooltip`, {
54
57
  [`${prefix}--icon-tooltip--disabled`]: disabled
55
58
  });
59
+ if (badgeCount && (kind !== 'ghost' || size !== 'lg')) {
60
+ console.warn("The prop BadgeCount must be used with hasIconOnly=true, kind='ghost' and size='lg'");
61
+ }
62
+ const badgeId = useId('badge-indicator');
56
63
  return /*#__PURE__*/React__default.createElement(Tooltip, {
57
64
  align: align,
58
65
  autoAlign: autoAlign,
@@ -71,8 +78,12 @@ const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(_r
71
78
  size: size,
72
79
  className: cx(`${prefix}--btn--icon-only`, {
73
80
  [`${prefix}--btn--selected`]: isSelected
74
- }, className)
75
- }), children));
81
+ }, className),
82
+ "aria-describedby": badgeCount && badgeId
83
+ }), children, !disabled && badgeCount !== undefined && /*#__PURE__*/React__default.createElement(BadgeIndicator, {
84
+ id: badgeId,
85
+ count: badgeCount > 0 ? badgeCount : undefined
86
+ })));
76
87
  });
77
88
  IconButton.propTypes = {
78
89
  /**
@@ -108,6 +119,11 @@ IconButton.propTypes = {
108
119
  * **Experimental**: Will attempt to automatically align the tooltip
109
120
  */
110
121
  autoAlign: PropTypes.bool,
122
+ /**
123
+ * **Experimental**: Display a badge on the button. An empty/dot badge if 0, a numbered badge if > 0.
124
+ * Must be used with size="lg", kind="ghost" and hasIconOnly=true
125
+ */
126
+ badgeCount: PropTypes.number,
111
127
  /**
112
128
  * Optionally specify an href for your IconButton to become an `<a>` element
113
129
  */
@@ -7,7 +7,7 @@
7
7
  import React from 'react';
8
8
  export declare const IconIndicatorKinds: string[];
9
9
  export type IconIndicatorKind = (typeof IconIndicatorKinds)[number];
10
- interface IconIndicatorProps {
10
+ export interface IconIndicatorProps {
11
11
  /**
12
12
  * Specify an optional className to add.
13
13
  */
@@ -66,10 +66,7 @@ const InlineLoading = _ref => {
66
66
  }
67
67
  return undefined;
68
68
  };
69
-
70
- // TODO: Should this element only be constructed, similar to
71
- // `loadingAnimation`, if `description` is specified?
72
- const loadingText = /*#__PURE__*/React__default.createElement("div", {
69
+ const loadingText = description && /*#__PURE__*/React__default.createElement("div", {
73
70
  className: `${prefix}--inline-loading__text`
74
71
  }, description);
75
72
  const loading = getLoading();
@@ -80,7 +77,7 @@ const InlineLoading = _ref => {
80
77
  className: loadingClasses
81
78
  }, rest, {
82
79
  "aria-live": rest['aria-live'] ?? 'assertive'
83
- }), loadingAnimation, description && loadingText);
80
+ }), loadingAnimation, loadingText);
84
81
  };
85
82
  InlineLoading.propTypes = {
86
83
  /**
@@ -19,8 +19,8 @@ import { Menu } from './Menu.js';
19
19
  import { MenuContext } from './MenuContext.js';
20
20
  import '../Text/index.js';
21
21
  import { useLayoutDirection } from '../LayoutDirection/useLayoutDirection.js';
22
- import { Text } from '../Text/Text.js';
23
22
  import { match } from '../../internal/keyboard/match.js';
23
+ import { Text } from '../Text/Text.js';
24
24
  import { ArrowRight, Enter, Space } from '../../internal/keyboard/keys.js';
25
25
 
26
26
  var _CaretLeft, _CaretRight;
@@ -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
  */
@@ -28,8 +28,8 @@ import { useFeatureFlag } from '../FeatureFlags/index.js';
28
28
  import { composeEventHandlers } from '../../tools/events.js';
29
29
  import deprecate from '../../prop-types/deprecate.js';
30
30
  import { debounce } from '../../node_modules/es-toolkit/dist/compat/function/debounce.mjs.js';
31
- import { Text } from '../Text/Text.js';
32
31
  import { match } from '../../internal/keyboard/match.js';
32
+ import { Text } from '../Text/Text.js';
33
33
  import { Escape, Enter, Tab } from '../../internal/keyboard/keys.js';
34
34
 
35
35
  const ModalSizes = ['xs', 'sm', 'md', 'lg'];
@@ -190,7 +190,9 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
190
190
  useEffect(() => {
191
191
  if (!open && launcherButtonRef) {
192
192
  setTimeout(() => {
193
- launcherButtonRef?.current?.focus();
193
+ if ('current' in launcherButtonRef) {
194
+ launcherButtonRef.current?.focus();
195
+ }
194
196
  });
195
197
  }
196
198
  }, [open, launcherButtonRef]);
@@ -373,7 +375,11 @@ Modal.propTypes = {
373
375
  * Provide a ref to return focus to once the modal is closed.
374
376
  */
375
377
  launcherButtonRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
376
- current: PropTypes.any
378
+ current: PropTypes.oneOfType([
379
+ // `PropTypes.instanceOf(HTMLButtonElement)` alone won't work because
380
+ // `HTMLButtonElement` is not defined in the test environment even
381
+ // though `testEnvironment` is set to `jsdom`.
382
+ typeof HTMLButtonElement !== 'undefined' ? PropTypes.instanceOf(HTMLButtonElement) : PropTypes.any, PropTypes.oneOf([null])]).isRequired
377
383
  })]),
378
384
  /**
379
385
  * 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
  */
@@ -11,7 +11,7 @@ import cx from 'classnames';
11
11
  import { useSelect } from 'downshift';
12
12
  import isEqual from 'react-fast-compare';
13
13
  import PropTypes from 'prop-types';
14
- import React__default, { useMemo, useContext, useState, useLayoutEffect } from 'react';
14
+ import React__default, { useMemo, useContext, useState, useLayoutEffect, isValidElement } from 'react';
15
15
  import ListBox from '../ListBox/index.js';
16
16
  import { sortingPropTypes } from './MultiSelectPropTypes.js';
17
17
  import { defaultSortItems, defaultCompareItems } from './tools/sorting.js';
@@ -424,11 +424,12 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
424
424
  const menuProps = useMemo(() => getMenuProps({
425
425
  ref: enableFloatingStyles ? refs.setFloating : null
426
426
  }), [enableFloatingStyles, getMenuProps, refs.setFloating]);
427
+ const labelProps = ! /*#__PURE__*/isValidElement(titleText) ? getLabelProps() : null;
427
428
  return /*#__PURE__*/React__default.createElement("div", {
428
429
  className: wrapperClasses
429
430
  }, /*#__PURE__*/React__default.createElement("label", _extends({
430
431
  className: titleClasses
431
- }, getLabelProps()), titleText && titleText, selectedItems.length > 0 && /*#__PURE__*/React__default.createElement("span", {
432
+ }, labelProps), titleText && titleText, selectedItems.length > 0 && /*#__PURE__*/React__default.createElement("span", {
432
433
  className: `${prefix}--visually-hidden`
433
434
  }, clearSelectionDescription, " ", selectedItems.length, ' ', itemsSelectedText, ",", clearSelectionText)), /*#__PURE__*/React__default.createElement(ListBox, {
434
435
  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
@@ -6,14 +6,15 @@
6
6
  */
7
7
 
8
8
  /**
9
- * Use the local `localCompare` with the `numeric` option to sort two,
10
- * potentially alpha-numeric, strings in a list of items.
9
+ * Use the locale `localeCompare` with the `numeric` option to sort two
10
+ * alpha-numeric strings.
11
11
  *
12
- * @param {ItemType} itemA
13
- * @param {ItemType} itemB
14
- * @param {object} options
15
- * @param {string} options.locale
16
- * @returns {number}
12
+ * @param {string} itemA - The first string to compare.
13
+ * @param {string} itemB - The second string to compare.
14
+ * @param {object} options - Options for comparing.
15
+ * @param {string} options.locale - The locale to use for comparison.
16
+ * @returns {number} A negative number if itemA comes before itemB, a positive
17
+ * number if itemA comes after itemB, or 0 if they are equal.
17
18
  */
18
19
  const defaultCompareItems = (itemA, itemB, _ref) => {
19
20
  let {
@@ -23,8 +23,8 @@ import wrapFocus, { wrapFocusWithoutSentinels } from '../../internal/wrapFocus.j
23
23
  import { useFeatureFlag } from '../FeatureFlags/index.js';
24
24
  import { warning } from '../../internal/warning.js';
25
25
  import deprecateValuesWithin from '../../prop-types/deprecateValuesWithin.js';
26
- import { Text } from '../Text/Text.js';
27
26
  import { match, matches } from '../../internal/keyboard/match.js';
27
+ import { Text } from '../Text/Text.js';
28
28
  import { Tab, Escape } from '../../internal/keyboard/keys.js';
29
29
 
30
30
  /**
@@ -163,20 +163,20 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
163
163
  [`${prefix}--number-input--fluid--disabled`]: isFluid && disabled
164
164
  });
165
165
  const Icon = normalizedProps.icon;
166
- function handleStepperClick(event, direction) {
166
+ const getDecimalPlaces = num => {
167
+ const parts = num.toString().split('.');
168
+ return parts[1] ? parts[1].length : 0;
169
+ };
170
+ const handleStepperClick = (event, direction) => {
167
171
  if (inputRef.current) {
168
172
  const currentValue = Number(inputRef.current.value);
169
- let newValue = direction === 'up' ? currentValue + step : currentValue - step;
170
- if (min !== undefined) {
171
- newValue = Math.max(newValue, min);
172
- }
173
- if (max !== undefined) {
174
- newValue = Math.min(newValue, max);
175
- }
176
- const currentInputValue = inputRef.current ? inputRef.current.value : '';
173
+ const rawValue = direction === 'up' ? currentValue + step : currentValue - step;
174
+ const precision = Math.max(getDecimalPlaces(currentValue), getDecimalPlaces(step));
175
+ const floatValue = parseFloat(rawValue.toFixed(precision));
176
+ const newValue = typeof min !== 'undefined' && typeof max !== 'undefined' ? Math.min(Math.max(floatValue, min), max) : floatValue;
177
177
  const state = {
178
- value: allowEmpty && currentInputValue === '' && step === 0 ? '' : newValue,
179
- direction: direction
178
+ value: allowEmpty && inputRef.current.value === '' && step === 0 ? '' : newValue,
179
+ direction
180
180
  };
181
181
  setValue(state.value);
182
182
  if (onChange) {
@@ -186,7 +186,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
186
186
  onClick(event, state);
187
187
  }
188
188
  }
189
- }
189
+ };
190
190
 
191
191
  // AILabel always size `mini`
192
192
  let normalizedDecorator = /*#__PURE__*/React__default.isValidElement(slug ?? decorator) ? slug ?? decorator : null;