@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
@@ -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;
@@ -0,0 +1,104 @@
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
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
+ var PropTypes = require('prop-types');
14
+ var React = require('react');
15
+ var cx = require('classnames');
16
+ var usePrefix = require('../../internal/usePrefix.js');
17
+ var iconsReact = require('@carbon/icons-react');
18
+
19
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
+
21
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
22
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
23
+ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
24
+
25
+ var _path;
26
+ const ShapeIndicatorKinds = ['failed', 'critical', 'high', 'medium', 'low', 'cautious', 'undefined', 'stable', 'informative', 'incomplete', 'draft'];
27
+
28
+ // TODO: update to import '@carbon/icons-react'
29
+ const incompleteIcon = props => /*#__PURE__*/React__default["default"].createElement("svg", _rollupPluginBabelHelpers["extends"]({
30
+ xmlns: "http://www.w3.org/2000/svg",
31
+ width: 16,
32
+ height: 16,
33
+ fill: "none",
34
+ "aria-hidden": "true"
35
+ }, props), /*#__PURE__*/React__default["default"].createElement("path", {
36
+ fill: "#fff",
37
+ fillOpacity: 0.01,
38
+ d: "M0 0h16v16H0z",
39
+ style: {
40
+ mixBlendMode: 'multiply'
41
+ }
42
+ }), _path || (_path = /*#__PURE__*/React__default["default"].createElement("path", {
43
+ fill: "#161616",
44
+ d: "M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2Zm0 2a4.004 4.004 0 0 1 4 4H4a4.004 4.004 0 0 1 4-4Z"
45
+ })));
46
+ const shapeTypes = {
47
+ failed: iconsReact.Critical,
48
+ critical: iconsReact.CriticalSeverity,
49
+ high: iconsReact.Caution,
50
+ medium: iconsReact.DiamondFill,
51
+ low: iconsReact.LowSeverity,
52
+ cautious: iconsReact.Caution,
53
+ undefined: iconsReact.DiamondFill,
54
+ stable: iconsReact.CircleFill,
55
+ informative: iconsReact.LowSeverity,
56
+ incomplete: incompleteIcon,
57
+ draft: iconsReact.CircleStroke
58
+ };
59
+ const ShapeIndicator = /*#__PURE__*/React__default["default"].forwardRef(function ShapeIndicatorContent(_ref, ref) {
60
+ let {
61
+ className: customClassName,
62
+ kind,
63
+ label,
64
+ textSize = 12,
65
+ ...rest
66
+ } = _ref;
67
+ const prefix = usePrefix.usePrefix();
68
+ const classNames = cx__default["default"](`${prefix}--shape-indicator`, customClassName, {
69
+ [`${prefix}--shape-indicator--14`]: textSize == 14
70
+ });
71
+ const ShapeForKind = shapeTypes[kind];
72
+ if (!ShapeForKind) {
73
+ return null;
74
+ }
75
+ return /*#__PURE__*/React__default["default"].createElement("div", {
76
+ className: classNames,
77
+ ref: ref
78
+ }, /*#__PURE__*/React__default["default"].createElement(ShapeForKind, {
79
+ size: 16,
80
+ className: `${prefix}--shape-indicator--${kind}`
81
+ }), label);
82
+ });
83
+ ShapeIndicator.propTypes = {
84
+ /**
85
+ * Specify an optional className to add.
86
+ */
87
+ className: PropTypes__default["default"].string,
88
+ /**
89
+ * Specify the kind of the Shape Indicator
90
+ */
91
+ kind: PropTypes__default["default"].oneOf(ShapeIndicatorKinds).isRequired,
92
+ /**
93
+ * Label next to the shape.
94
+ */
95
+ label: PropTypes__default["default"].string.isRequired,
96
+ /**
97
+ * Specify the text size of the Shape Indicator. Defaults to 12.
98
+ */
99
+ textSize: PropTypes__default["default"].oneOf([12, 14])
100
+ };
101
+
102
+ exports.ShapeIndicator = ShapeIndicator;
103
+ exports.ShapeIndicatorKinds = ShapeIndicatorKinds;
104
+ exports["default"] = ShapeIndicator;
@@ -353,10 +353,11 @@ export interface TabProps extends HTMLAttributes<HTMLElement> {
353
353
  secondaryLabel?: string;
354
354
  }
355
355
  declare const Tab: React.ForwardRefExoticComponent<TabProps & React.RefAttributes<HTMLElement>>;
356
- /**
357
- * IconTab
358
- */
359
356
  export interface IconTabProps extends DivAttributes {
357
+ /**
358
+ * **Experimental**: Display an empty dot badge on the Tab.
359
+ */
360
+ badgeIndicator?: boolean;
360
361
  /**
361
362
  * Provide an icon to be rendered inside `IconTab` as the visual label for Tab.
362
363
  */
@@ -377,7 +378,8 @@ export interface IconTabProps extends DivAttributes {
377
378
  * Provide the label to be rendered inside the Tooltip. The label will use
378
379
  * `aria-labelledby` and will fully describe the child node that is provided.
379
380
  * This means that if you have text in the child node it will not be
380
- * announced to the screen reader.
381
+ * announced to the screen reader. If using the badgeIndicator then provide a
382
+ * label with describing that there is a new notification.
381
383
  */
382
384
  label: ReactNode;
383
385
  /**
@@ -36,9 +36,10 @@ var deprecate = require('../../prop-types/deprecate.js');
36
36
  var useEvent = require('../../internal/useEvent.js');
37
37
  var useMatchMedia = require('../../internal/useMatchMedia.js');
38
38
  require('../Text/index.js');
39
+ var index = require('../BadgeIndicator/index.js');
39
40
  var debounce = require('../../node_modules/es-toolkit/dist/compat/function/debounce.mjs.js');
40
- var Text = require('../Text/Text.js');
41
41
  var match = require('../../internal/keyboard/match.js');
42
+ var Text = require('../Text/Text.js');
42
43
  var keys = require('../../internal/keyboard/keys.js');
43
44
 
44
45
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -47,7 +48,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
47
48
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
48
49
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
49
50
 
50
- var _ChevronLeft, _ChevronRight;
51
+ var _ChevronLeft, _ChevronRight, _BadgeIndicator;
51
52
  const verticalTabHeight = 64;
52
53
 
53
54
  // Used to manage the overall state of the Tabs
@@ -804,23 +805,26 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(_ref10, forwardRef) {
804
805
  onTabCloseRequest
805
806
  } = React__default["default"].useContext(TabsContext);
806
807
  const {
807
- index,
808
+ index: index$1,
808
809
  hasSecondaryLabel,
809
810
  contained
810
811
  } = React__default["default"].useContext(TabContext);
812
+ const {
813
+ badgeIndicator
814
+ } = React__default["default"].useContext(IconTabContext) || {};
811
815
  const dismissIconRef = React.useRef(null);
812
816
  const tabRef = React.useRef(null);
813
817
  const ref = useMergedRefs.useMergedRefs([forwardRef, tabRef]);
814
818
  const [ignoreHover, setIgnoreHover] = React.useState(false);
815
- const id = `${baseId}-tab-${index}`;
816
- const panelId = `${baseId}-tabpanel-${index}`;
819
+ const id = `${baseId}-tab-${index$1}`;
820
+ const panelId = `${baseId}-tabpanel-${index$1}`;
817
821
  const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
818
822
  const isEllipsisActive = element => {
819
823
  setIsEllipsisApplied(element.offsetHeight < element.scrollHeight);
820
824
  return element.offsetHeight < element.scrollHeight;
821
825
  };
822
826
  const className = cx__default["default"](`${prefix}--tabs__nav-item`, `${prefix}--tabs__nav-link`, {
823
- [`${prefix}--tabs__nav-item--selected`]: selectedIndex === index,
827
+ [`${prefix}--tabs__nav-item--selected`]: selectedIndex === index$1,
824
828
  [`${prefix}--tabs__nav-item--disabled`]: disabled,
825
829
  [`${prefix}--tabs__nav-item--hover-off`]: ignoreHover
826
830
  }, customClassName);
@@ -856,7 +860,7 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(_ref10, forwardRef) {
856
860
  }, [prefix, id]);
857
861
  const handleClose = evt => {
858
862
  evt.stopPropagation();
859
- onTabCloseRequest?.(index);
863
+ onTabCloseRequest?.(index$1);
860
864
 
861
865
  // set focus after removing tab
862
866
  if (tabRef.current && tabRef.current.parentElement) {
@@ -867,7 +871,7 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(_ref10, forwardRef) {
867
871
  }).length;
868
872
 
869
873
  // if not removing last tab focus on next tab
870
- if (tabRef.current && index + 1 !== tabCount) {
874
+ if (tabRef.current && index$1 + 1 !== tabCount) {
871
875
  tabRef.current.focus();
872
876
  }
873
877
  // if removing last tab focus on previous tab
@@ -890,21 +894,21 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(_ref10, forwardRef) {
890
894
  })
891
895
  }, /*#__PURE__*/React__default["default"].createElement("button", {
892
896
  type: "button",
893
- tabIndex: selectedIndex === index && dismissable ? 0 : -1,
897
+ tabIndex: selectedIndex === index$1 && dismissable ? 0 : -1,
894
898
  "aria-disabled": disabled,
895
- "aria-hidden": selectedIndex === index && dismissable ? 'false' : 'true',
899
+ "aria-hidden": selectedIndex === index$1 && dismissable ? 'false' : 'true',
896
900
  disabled: disabled,
897
901
  className: cx__default["default"]({
898
902
  [`${prefix}--tabs__nav-item--close-icon`]: dismissable,
899
903
  [`${prefix}--visually-hidden`]: !dismissable,
900
- [`${prefix}--tabs__nav-item--close-icon--selected`]: selectedIndex === index,
904
+ [`${prefix}--tabs__nav-item--close-icon--selected`]: selectedIndex === index$1,
901
905
  [`${prefix}--tabs__nav-item--close-icon--disabled`]: disabled
902
906
  }),
903
907
  onClick: handleClose,
904
908
  title: `Remove ${typeof children === 'string' ? children : ''} tab`,
905
909
  ref: dismissIconRef
906
910
  }, /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, {
907
- "aria-hidden": selectedIndex === index && dismissable ? 'false' : 'true',
911
+ "aria-hidden": selectedIndex === index$1 && dismissable ? 'false' : 'true',
908
912
  "aria-label": `Press delete to remove ${typeof children === 'string' ? children : ''} tab`
909
913
  })));
910
914
  const hasIcon = Icon ?? dismissable;
@@ -921,7 +925,7 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(_ref10, forwardRef) {
921
925
  }, /*#__PURE__*/React__default["default"].createElement(BaseComponent, _rollupPluginBabelHelpers["extends"]({}, rest, {
922
926
  "aria-controls": panelId,
923
927
  "aria-disabled": disabled,
924
- "aria-selected": selectedIndex === index,
928
+ "aria-selected": selectedIndex === index$1,
925
929
  ref: ref,
926
930
  id: id,
927
931
  role: "tab",
@@ -932,11 +936,11 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(_ref10, forwardRef) {
932
936
  if (disabled) {
933
937
  return;
934
938
  }
935
- setSelectedIndex(index);
939
+ setSelectedIndex(index$1);
936
940
  onClick?.(evt);
937
941
  },
938
942
  onKeyDown: handleKeyDown,
939
- tabIndex: selectedIndex === index ? '0' : '-1',
943
+ tabIndex: selectedIndex === index$1 ? '0' : '-1',
940
944
  type: "button"
941
945
  }), /*#__PURE__*/React__default["default"].createElement("div", {
942
946
  className: `${prefix}--tabs__nav-item-label-wrapper`
@@ -951,7 +955,7 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(_ref10, forwardRef) {
951
955
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(BaseComponent, _rollupPluginBabelHelpers["extends"]({}, rest, {
952
956
  "aria-controls": panelId,
953
957
  "aria-disabled": disabled,
954
- "aria-selected": selectedIndex === index,
958
+ "aria-selected": selectedIndex === index$1,
955
959
  ref: ref,
956
960
  id: id,
957
961
  role: "tab",
@@ -961,11 +965,11 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(_ref10, forwardRef) {
961
965
  if (disabled) {
962
966
  return;
963
967
  }
964
- setSelectedIndex(index);
968
+ setSelectedIndex(index$1);
965
969
  onClick?.(evt);
966
970
  },
967
971
  onKeyDown: handleKeyDown,
968
- tabIndex: selectedIndex === index ? '0' : '-1',
972
+ tabIndex: selectedIndex === index$1 ? '0' : '-1',
969
973
  type: "button"
970
974
  }), /*#__PURE__*/React__default["default"].createElement("div", {
971
975
  className: `${prefix}--tabs__nav-item-label-wrapper`
@@ -985,7 +989,7 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(_ref10, forwardRef) {
985
989
  as: "div",
986
990
  className: `${prefix}--tabs__nav-item-secondary-label`,
987
991
  title: secondaryLabel
988
- }, secondaryLabel)), DismissIcon);
992
+ }, secondaryLabel), !disabled && badgeIndicator && (_BadgeIndicator || (_BadgeIndicator = /*#__PURE__*/React__default["default"].createElement(index.BadgeIndicator, null)))), DismissIcon);
989
993
  });
990
994
  Tab.propTypes = {
991
995
  /**
@@ -1036,8 +1040,10 @@ Tab.propTypes = {
1036
1040
  * IconTab
1037
1041
  */
1038
1042
 
1043
+ const IconTabContext = /*#__PURE__*/React.createContext(false);
1039
1044
  const IconTab = /*#__PURE__*/React__default["default"].forwardRef(function IconTab(_ref11, ref) {
1040
1045
  let {
1046
+ badgeIndicator,
1041
1047
  children,
1042
1048
  className: customClassName,
1043
1049
  defaultOpen = false,
@@ -1047,8 +1053,16 @@ const IconTab = /*#__PURE__*/React__default["default"].forwardRef(function IconT
1047
1053
  ...rest
1048
1054
  } = _ref11;
1049
1055
  const prefix = usePrefix.usePrefix();
1050
- const classNames = cx__default["default"](`${prefix}--tabs__nav-item--icon-only`, customClassName);
1051
- return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
1056
+ const value = React.useMemo(() => ({
1057
+ badgeIndicator
1058
+ }), [badgeIndicator]);
1059
+ const hasSize20 = /*#__PURE__*/React__default["default"].isValidElement(children) && children.props?.size === 20;
1060
+ const classNames = cx__default["default"](`${prefix}--tabs__nav-item--icon-only`, customClassName, {
1061
+ [`${prefix}--tabs__nav-item--icon-only__20`]: hasSize20
1062
+ });
1063
+ return /*#__PURE__*/React__default["default"].createElement(IconTabContext.Provider, {
1064
+ value: value
1065
+ }, /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
1052
1066
  align: "bottom",
1053
1067
  defaultOpen: defaultOpen,
1054
1068
  className: `${prefix}--icon-tooltip`,
@@ -1058,9 +1072,13 @@ const IconTab = /*#__PURE__*/React__default["default"].forwardRef(function IconT
1058
1072
  }, /*#__PURE__*/React__default["default"].createElement(Tab, _rollupPluginBabelHelpers["extends"]({
1059
1073
  className: classNames,
1060
1074
  ref: ref
1061
- }, rest), children));
1075
+ }, rest), children)));
1062
1076
  });
1063
1077
  IconTab.propTypes = {
1078
+ /**
1079
+ * **Experimental**: Display an empty dot badge on the Tab.
1080
+ */
1081
+ badgeIndicator: PropTypes__default["default"].bool,
1064
1082
  /**
1065
1083
  * Provide an icon to be rendered inside `IconTab` as the visual label for Tab.
1066
1084
  */
@@ -1081,7 +1099,8 @@ IconTab.propTypes = {
1081
1099
  * Provide the label to be rendered inside the Tooltip. The label will use
1082
1100
  * `aria-labelledby` and will fully describe the child node that is provided.
1083
1101
  * This means that if you have text in the child node it will not be
1084
- * announced to the screen reader.
1102
+ * announced to the screen reader. If using the badgeIndicator then provide a
1103
+ * label with describing that there is a new notification.
1085
1104
  */
1086
1105
  label: PropTypes__default["default"].node.isRequired,
1087
1106
  /**
@@ -4,7 +4,6 @@
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 PropTypes from 'prop-types';
8
7
  import React, { MouseEventHandler } from 'react';
9
8
  import { PolymorphicProps } from '../../types/common';
10
9
  import { SIZES } from './Tag';
@@ -54,40 +53,6 @@ export interface OperationalTagBaseProps {
54
53
  type?: keyof typeof TYPES;
55
54
  }
56
55
  export type OperationalTagProps<T extends React.ElementType> = PolymorphicProps<T, OperationalTagBaseProps>;
57
- declare const OperationalTag: {
58
- <T extends React.ElementType>({ className, disabled, id, renderIcon, size, text, type, ...other }: OperationalTagProps<T>): import("react/jsx-runtime").JSX.Element;
59
- propTypes: {
60
- /**
61
- * Provide a custom className that is applied to the containing <span>
62
- */
63
- className: PropTypes.Requireable<string>;
64
- /**
65
- * Specify if the `OperationalTag` is disabled
66
- */
67
- disabled: PropTypes.Requireable<boolean>;
68
- /**
69
- * Specify the id for the tag.
70
- */
71
- id: PropTypes.Requireable<string>;
72
- /**
73
- * Optional prop to render a custom icon.
74
- * Can be a React component class
75
- */
76
- renderIcon: PropTypes.Requireable<object>;
77
- /**
78
- * Specify the size of the Tag. Currently supports either `sm`,
79
- * `md` (default) or `lg` sizes.
80
- */
81
- size: PropTypes.Requireable<string>;
82
- /**
83
- * Provide text to be rendered inside of a the tag.
84
- */
85
- text: PropTypes.Requireable<string>;
86
- /**
87
- * Specify the type of the `Tag`
88
- */
89
- type: PropTypes.Requireable<string>;
90
- };
91
- };
56
+ declare const OperationalTag: React.ForwardRefExoticComponent<Omit<OperationalTagProps<React.ElementType<any, keyof React.JSX.IntrinsicElements>>, "ref"> & React.RefAttributes<HTMLLIElement>>;
92
57
  export declare const types: string[];
93
58
  export default OperationalTag;
@@ -20,6 +20,7 @@ require('../Tooltip/DefinitionTooltip.js');
20
20
  var Tooltip = require('../Tooltip/Tooltip.js');
21
21
  require('../Text/index.js');
22
22
  var isEllipsisActive = require('./isEllipsisActive.js');
23
+ var mergeRefs = require('../../tools/mergeRefs.js');
23
24
  var Text = require('../Text/Text.js');
24
25
 
25
26
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -40,7 +41,7 @@ const TYPES = {
40
41
  'cool-gray': 'Cool-Gray',
41
42
  'warm-gray': 'Warm-Gray'
42
43
  };
43
- const OperationalTag = _ref => {
44
+ const OperationalTag = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
44
45
  let {
45
46
  className,
46
47
  disabled,
@@ -61,6 +62,7 @@ const OperationalTag = _ref => {
61
62
  setIsEllipsisApplied(isEllipsisActive.isEllipsisActive(newElement));
62
63
  }, [prefix, tagRef]);
63
64
  const tooltipClasses = cx__default["default"](`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
65
+ const combinedRef = mergeRefs["default"](tagRef, forwardRef);
64
66
  if (isEllipsisApplied) {
65
67
  return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
66
68
  label: text,
@@ -70,7 +72,7 @@ const OperationalTag = _ref => {
70
72
  onMouseEnter: () => false,
71
73
  closeOnActivation: true
72
74
  }, /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
73
- ref: tagRef,
75
+ ref: combinedRef,
74
76
  type: type,
75
77
  size: size,
76
78
  renderIcon: renderIcon,
@@ -83,7 +85,7 @@ const OperationalTag = _ref => {
83
85
  }, text)));
84
86
  }
85
87
  return /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
86
- ref: tagRef,
88
+ ref: combinedRef,
87
89
  type: type,
88
90
  size: size,
89
91
  renderIcon: renderIcon,
@@ -94,7 +96,7 @@ const OperationalTag = _ref => {
94
96
  title: text,
95
97
  className: `${prefix}--tag__label`
96
98
  }, text));
97
- };
99
+ });
98
100
  OperationalTag.propTypes = {
99
101
  /**
100
102
  * Provide a custom className that is applied to the containing <span>
@@ -1,17 +1,19 @@
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';
8
- import { TextDir } from './TextDirection';
9
- import { PolymorphicComponentPropWithRef } from '../../internal/PolymorphicProps';
7
+ import { type ElementType, type ReactElement, type ReactNode } from 'react';
8
+ import { PolymorphicComponentPropWithRef, PolymorphicRef } from '../../internal/PolymorphicProps';
9
+ import { type TextDir } from '.';
10
10
  export interface TextBaseProps {
11
- dir?: TextDir | undefined;
11
+ dir?: TextDir;
12
12
  children?: ReactNode;
13
13
  }
14
- export type TextProps<T extends React.ElementType> = PolymorphicComponentPropWithRef<T, TextBaseProps>;
15
- type TextComponent = <T extends React.ElementType = 'span'>(props: TextProps<T>) => React.ReactElement | any;
16
- declare const Text: TextComponent;
17
- export { Text };
14
+ export type TextProps<T extends ElementType> = PolymorphicComponentPropWithRef<T, TextBaseProps>;
15
+ type TextComponent = <T extends ElementType = 'span'>(props: TextProps<T> & {
16
+ ref?: PolymorphicRef<T>;
17
+ }) => ReactElement | null;
18
+ export declare const Text: TextComponent;
19
+ export {};