@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
@@ -0,0 +1,92 @@
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
+ import { Critical, CriticalSeverity, Caution, DiamondFill, LowSeverity, CircleFill, CircleStroke } from '@carbon/icons-react';
14
+
15
+ var _path;
16
+ const ShapeIndicatorKinds = ['failed', 'critical', 'high', 'medium', 'low', 'cautious', 'undefined', 'stable', 'informative', 'incomplete', 'draft'];
17
+
18
+ // TODO: update to import '@carbon/icons-react'
19
+ const incompleteIcon = props => /*#__PURE__*/React__default.createElement("svg", _extends({
20
+ xmlns: "http://www.w3.org/2000/svg",
21
+ width: 16,
22
+ height: 16,
23
+ fill: "none",
24
+ "aria-hidden": "true"
25
+ }, props), /*#__PURE__*/React__default.createElement("path", {
26
+ fill: "#fff",
27
+ fillOpacity: 0.01,
28
+ d: "M0 0h16v16H0z",
29
+ style: {
30
+ mixBlendMode: 'multiply'
31
+ }
32
+ }), _path || (_path = /*#__PURE__*/React__default.createElement("path", {
33
+ fill: "#161616",
34
+ 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"
35
+ })));
36
+ const shapeTypes = {
37
+ failed: Critical,
38
+ critical: CriticalSeverity,
39
+ high: Caution,
40
+ medium: DiamondFill,
41
+ low: LowSeverity,
42
+ cautious: Caution,
43
+ undefined: DiamondFill,
44
+ stable: CircleFill,
45
+ informative: LowSeverity,
46
+ incomplete: incompleteIcon,
47
+ draft: CircleStroke
48
+ };
49
+ const ShapeIndicator = /*#__PURE__*/React__default.forwardRef(function ShapeIndicatorContent(_ref, ref) {
50
+ let {
51
+ className: customClassName,
52
+ kind,
53
+ label,
54
+ textSize = 12,
55
+ ...rest
56
+ } = _ref;
57
+ const prefix = usePrefix();
58
+ const classNames = cx(`${prefix}--shape-indicator`, customClassName, {
59
+ [`${prefix}--shape-indicator--14`]: textSize == 14
60
+ });
61
+ const ShapeForKind = shapeTypes[kind];
62
+ if (!ShapeForKind) {
63
+ return null;
64
+ }
65
+ return /*#__PURE__*/React__default.createElement("div", {
66
+ className: classNames,
67
+ ref: ref
68
+ }, /*#__PURE__*/React__default.createElement(ShapeForKind, {
69
+ size: 16,
70
+ className: `${prefix}--shape-indicator--${kind}`
71
+ }), label);
72
+ });
73
+ ShapeIndicator.propTypes = {
74
+ /**
75
+ * Specify an optional className to add.
76
+ */
77
+ className: PropTypes.string,
78
+ /**
79
+ * Specify the kind of the Shape Indicator
80
+ */
81
+ kind: PropTypes.oneOf(ShapeIndicatorKinds).isRequired,
82
+ /**
83
+ * Label next to the shape.
84
+ */
85
+ label: PropTypes.string.isRequired,
86
+ /**
87
+ * Specify the text size of the Shape Indicator. Defaults to 12.
88
+ */
89
+ textSize: PropTypes.oneOf([12, 14])
90
+ };
91
+
92
+ export { ShapeIndicator, ShapeIndicatorKinds, ShapeIndicator as default };
@@ -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
  /**
@@ -10,7 +10,7 @@ import { ChevronLeft, ChevronRight, Close } from '@carbon/icons-react';
10
10
  import { breakpoints } from '@carbon/layout';
11
11
  import cx from 'classnames';
12
12
  import PropTypes from 'prop-types';
13
- import React__default, { useState, useRef, useCallback, useEffect, forwardRef } from 'react';
13
+ import React__default, { useState, useRef, useCallback, useEffect, forwardRef, createContext, useMemo } from 'react';
14
14
  import '../Grid/FlexGrid.js';
15
15
  import { Grid as GridAsGridComponent } from '../Grid/Grid.js';
16
16
  import '../Grid/Row.js';
@@ -32,12 +32,13 @@ import deprecate from '../../prop-types/deprecate.js';
32
32
  import { useEvent } from '../../internal/useEvent.js';
33
33
  import { useMatchMedia } from '../../internal/useMatchMedia.js';
34
34
  import '../Text/index.js';
35
+ import { BadgeIndicator } from '../BadgeIndicator/index.js';
35
36
  import { debounce } from '../../node_modules/es-toolkit/dist/compat/function/debounce.mjs.js';
36
- import { Text } from '../Text/Text.js';
37
37
  import { matches, match } from '../../internal/keyboard/match.js';
38
+ import { Text } from '../Text/Text.js';
38
39
  import { ArrowRight, ArrowLeft, Home, End, ArrowDown, ArrowUp, Delete } from '../../internal/keyboard/keys.js';
39
40
 
40
- var _ChevronLeft, _ChevronRight;
41
+ var _ChevronLeft, _ChevronRight, _BadgeIndicator;
41
42
  const verticalTabHeight = 64;
42
43
 
43
44
  // Used to manage the overall state of the Tabs
@@ -798,6 +799,9 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref10, forwardRef) {
798
799
  hasSecondaryLabel,
799
800
  contained
800
801
  } = React__default.useContext(TabContext);
802
+ const {
803
+ badgeIndicator
804
+ } = React__default.useContext(IconTabContext) || {};
801
805
  const dismissIconRef = useRef(null);
802
806
  const tabRef = useRef(null);
803
807
  const ref = useMergedRefs([forwardRef, tabRef]);
@@ -975,7 +979,7 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref10, forwardRef) {
975
979
  as: "div",
976
980
  className: `${prefix}--tabs__nav-item-secondary-label`,
977
981
  title: secondaryLabel
978
- }, secondaryLabel)), DismissIcon);
982
+ }, secondaryLabel), !disabled && badgeIndicator && (_BadgeIndicator || (_BadgeIndicator = /*#__PURE__*/React__default.createElement(BadgeIndicator, null)))), DismissIcon);
979
983
  });
980
984
  Tab.propTypes = {
981
985
  /**
@@ -1026,8 +1030,10 @@ Tab.propTypes = {
1026
1030
  * IconTab
1027
1031
  */
1028
1032
 
1033
+ const IconTabContext = /*#__PURE__*/createContext(false);
1029
1034
  const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref11, ref) {
1030
1035
  let {
1036
+ badgeIndicator,
1031
1037
  children,
1032
1038
  className: customClassName,
1033
1039
  defaultOpen = false,
@@ -1037,8 +1043,16 @@ const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref11,
1037
1043
  ...rest
1038
1044
  } = _ref11;
1039
1045
  const prefix = usePrefix();
1040
- const classNames = cx(`${prefix}--tabs__nav-item--icon-only`, customClassName);
1041
- return /*#__PURE__*/React__default.createElement(Tooltip, {
1046
+ const value = useMemo(() => ({
1047
+ badgeIndicator
1048
+ }), [badgeIndicator]);
1049
+ const hasSize20 = /*#__PURE__*/React__default.isValidElement(children) && children.props?.size === 20;
1050
+ const classNames = cx(`${prefix}--tabs__nav-item--icon-only`, customClassName, {
1051
+ [`${prefix}--tabs__nav-item--icon-only__20`]: hasSize20
1052
+ });
1053
+ return /*#__PURE__*/React__default.createElement(IconTabContext.Provider, {
1054
+ value: value
1055
+ }, /*#__PURE__*/React__default.createElement(Tooltip, {
1042
1056
  align: "bottom",
1043
1057
  defaultOpen: defaultOpen,
1044
1058
  className: `${prefix}--icon-tooltip`,
@@ -1048,9 +1062,13 @@ const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref11,
1048
1062
  }, /*#__PURE__*/React__default.createElement(Tab, _extends({
1049
1063
  className: classNames,
1050
1064
  ref: ref
1051
- }, rest), children));
1065
+ }, rest), children)));
1052
1066
  });
1053
1067
  IconTab.propTypes = {
1068
+ /**
1069
+ * **Experimental**: Display an empty dot badge on the Tab.
1070
+ */
1071
+ badgeIndicator: PropTypes.bool,
1054
1072
  /**
1055
1073
  * Provide an icon to be rendered inside `IconTab` as the visual label for Tab.
1056
1074
  */
@@ -1071,7 +1089,8 @@ IconTab.propTypes = {
1071
1089
  * Provide the label to be rendered inside the Tooltip. The label will use
1072
1090
  * `aria-labelledby` and will fully describe the child node that is provided.
1073
1091
  * This means that if you have text in the child node it will not be
1074
- * announced to the screen reader.
1092
+ * announced to the screen reader. If using the badgeIndicator then provide a
1093
+ * label with describing that there is a new notification.
1075
1094
  */
1076
1095
  label: PropTypes.node.isRequired,
1077
1096
  /**
@@ -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;
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
- import React__default, { useRef, useState, useLayoutEffect } from 'react';
10
+ import React__default, { forwardRef, useRef, useState, useLayoutEffect } from 'react';
11
11
  import cx from 'classnames';
12
12
  import { useId } from '../../internal/useId.js';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
@@ -16,6 +16,7 @@ import '../Tooltip/DefinitionTooltip.js';
16
16
  import { Tooltip } from '../Tooltip/Tooltip.js';
17
17
  import '../Text/index.js';
18
18
  import { isEllipsisActive } from './isEllipsisActive.js';
19
+ import mergeRefs from '../../tools/mergeRefs.js';
19
20
  import { Text } from '../Text/Text.js';
20
21
 
21
22
  const TYPES = {
@@ -30,7 +31,7 @@ const TYPES = {
30
31
  'cool-gray': 'Cool-Gray',
31
32
  'warm-gray': 'Warm-Gray'
32
33
  };
33
- const OperationalTag = _ref => {
34
+ const OperationalTag = /*#__PURE__*/forwardRef((_ref, forwardRef) => {
34
35
  let {
35
36
  className,
36
37
  disabled,
@@ -51,6 +52,7 @@ const OperationalTag = _ref => {
51
52
  setIsEllipsisApplied(isEllipsisActive(newElement));
52
53
  }, [prefix, tagRef]);
53
54
  const tooltipClasses = cx(`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
55
+ const combinedRef = mergeRefs(tagRef, forwardRef);
54
56
  if (isEllipsisApplied) {
55
57
  return /*#__PURE__*/React__default.createElement(Tooltip, {
56
58
  label: text,
@@ -60,7 +62,7 @@ const OperationalTag = _ref => {
60
62
  onMouseEnter: () => false,
61
63
  closeOnActivation: true
62
64
  }, /*#__PURE__*/React__default.createElement(Tag, _extends({
63
- ref: tagRef,
65
+ ref: combinedRef,
64
66
  type: type,
65
67
  size: size,
66
68
  renderIcon: renderIcon,
@@ -73,7 +75,7 @@ const OperationalTag = _ref => {
73
75
  }, text)));
74
76
  }
75
77
  return /*#__PURE__*/React__default.createElement(Tag, _extends({
76
- ref: tagRef,
78
+ ref: combinedRef,
77
79
  type: type,
78
80
  size: size,
79
81
  renderIcon: renderIcon,
@@ -84,7 +86,7 @@ const OperationalTag = _ref => {
84
86
  title: text,
85
87
  className: `${prefix}--tag__label`
86
88
  }, text));
87
- };
89
+ });
88
90
  OperationalTag.propTypes = {
89
91
  /**
90
92
  * 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 {};
@@ -7,17 +7,17 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
- import React__default, { useContext } from 'react';
10
+ import React__default, { forwardRef, useContext, Children } from 'react';
11
+ import './index.js';
11
12
  import { TextDirectionContext } from './TextDirectionContext.js';
12
13
 
13
- const Text = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
14
+ const Text = /*#__PURE__*/forwardRef((_ref, ref) => {
14
15
  let {
15
16
  as,
16
17
  children,
17
18
  dir = 'auto',
18
19
  ...rest
19
20
  } = _ref;
20
- // TODO: Update with context typing once its been converted to TS
21
21
  const context = useContext(TextDirectionContext);
22
22
  const textProps = {};
23
23
  const BaseComponent = as ?? 'span';
@@ -69,11 +69,11 @@ Text.propTypes = {
69
69
  */
70
70
  dir: PropTypes.oneOf(['ltr', 'rtl', 'auto'])
71
71
  };
72
- function getTextFromChildren(children) {
72
+ const getTextFromChildren = children => {
73
73
  if (typeof children === 'string') {
74
74
  return children;
75
75
  }
76
- const text = React__default.Children.map(children, child => {
76
+ const text = Children.map(children, child => {
77
77
  if (typeof child === 'string') {
78
78
  return child;
79
79
  }
@@ -85,6 +85,6 @@ function getTextFromChildren(children) {
85
85
  return text[0];
86
86
  }
87
87
  return text;
88
- }
88
+ };
89
89
 
90
90
  export { Text };
@@ -1,21 +1,20 @@
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
7
  import PropTypes from 'prop-types';
8
8
  import { ReactNode } from 'react';
9
- export type TextDir = 'ltr' | 'rtl' | 'auto' | string;
10
- export type GetTextDirection = (text: string | string[] | undefined) => TextDir;
9
+ import { type GetTextDirection, type TextDir } from '.';
11
10
  export interface TextDirectionProps {
12
- children: ReactNode | undefined;
11
+ children: ReactNode;
13
12
  dir?: TextDir;
14
13
  getTextDirection?: GetTextDirection;
15
14
  }
16
- declare function TextDirection({ children, dir, getTextDirection, }: TextDirectionProps): import("react/jsx-runtime").JSX.Element;
17
- declare namespace TextDirection {
18
- var propTypes: {
15
+ export declare const TextDirection: {
16
+ ({ children, dir, getTextDirection, }: TextDirectionProps): import("react/jsx-runtime").JSX.Element;
17
+ propTypes: {
19
18
  /**
20
19
  * Provide children to be rendered inside of this component
21
20
  */
@@ -31,5 +30,4 @@ declare namespace TextDirection {
31
30
  */
32
31
  getTextDirection: PropTypes.Requireable<(...args: any[]) => any>;
33
32
  };
34
- }
35
- export { TextDirection };
33
+ };
@@ -7,9 +7,10 @@
7
7
 
8
8
  import PropTypes from 'prop-types';
9
9
  import React__default, { useRef, useMemo, useEffect } from 'react';
10
+ import './index.js';
10
11
  import { TextDirectionContext } from './TextDirectionContext.js';
11
12
 
12
- function TextDirection(_ref) {
13
+ const TextDirection = _ref => {
13
14
  let {
14
15
  children,
15
16
  dir = 'auto',
@@ -24,11 +25,13 @@ function TextDirection(_ref) {
24
25
  }, [dir]);
25
26
  useEffect(() => {
26
27
  savedCallback.current = getTextDirection;
28
+ // TODO: Is this `useEffect` supposed to have a dependency on
29
+ // `getTextDirection`?
27
30
  });
28
31
  return /*#__PURE__*/React__default.createElement(TextDirectionContext.Provider, {
29
32
  value: value
30
33
  }, children);
31
- }
34
+ };
32
35
  TextDirection.propTypes = {
33
36
  /**
34
37
  * Provide children to be rendered inside of this component
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { type MutableRefObject } from 'react';
8
+ export type TextDir = 'ltr' | 'rtl' | 'auto' | string;
9
+ export type GetTextDirection = (text: string | string[] | undefined) => TextDir;
10
+ export interface TextDirectionContextType {
11
+ direction: TextDir;
12
+ getTextDirection: MutableRefObject<GetTextDirection | undefined>;
13
+ }
14
+ export declare const TextDirectionContext: import("react").Context<TextDirectionContextType>;
@@ -7,7 +7,11 @@
7
7
 
8
8
  import { createContext } from 'react';
9
9
 
10
- /** @type any */
11
- const TextDirectionContext = /*#__PURE__*/createContext(null);
10
+ const TextDirectionContext = /*#__PURE__*/createContext({
11
+ direction: 'auto',
12
+ getTextDirection: {
13
+ current: undefined
14
+ }
15
+ });
12
16
 
13
17
  export { TextDirectionContext };
@@ -1,18 +1,18 @@
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 from 'react';
8
- import { TextProps } from './Text';
7
+ import { type ElementType } from 'react';
8
+ import { TextProps } from '.';
9
9
  /**
10
10
  * Create a text component wrapper for a given text node type. Useful for
11
11
  * returning a `Text` component for a text node like a `<label>`.
12
12
  * @param {string} element
13
13
  * @param {string} displayName
14
14
  */
15
- export declare function createTextComponent(element: React.ElementType, displayName: string): {
16
- (props: TextProps<React.ElementType>): import("react/jsx-runtime").JSX.Element;
15
+ export declare const createTextComponent: (element: ElementType, displayName: string) => {
16
+ (props: TextProps<ElementType>): import("react/jsx-runtime").JSX.Element;
17
17
  displayName: string;
18
18
  };
@@ -7,6 +7,7 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default from 'react';
10
+ import './index.js';
10
11
  import { Text } from './Text.js';
11
12
 
12
13
  /**
@@ -15,16 +16,16 @@ import { Text } from './Text.js';
15
16
  * @param {string} element
16
17
  * @param {string} displayName
17
18
  */
18
- function createTextComponent(element, displayName) {
19
- function TextWrapper(props) {
19
+ const createTextComponent = (element, displayName) => {
20
+ const TextWrapper = props => {
20
21
  return /*#__PURE__*/React__default.createElement(Text, _extends({
21
22
  as: element
22
23
  }, props));
23
- }
24
+ };
24
25
  if (process.env.NODE_ENV !== "production") {
25
26
  TextWrapper.displayName = displayName;
26
27
  }
27
28
  return TextWrapper;
28
- }
29
+ };
29
30
 
30
31
  export { createTextComponent };
@@ -1,18 +1,17 @@
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 { TextDirection, TextDirectionProps, GetTextDirection, TextDir } from './TextDirection';
8
- import { Text, TextBaseProps, TextProps } from './Text';
9
- export { TextDirection, Text };
10
- export type { TextBaseProps, TextProps, TextDirectionProps, GetTextDirection, TextDir, };
7
+ export * from './Text';
8
+ export * from './TextDirection';
9
+ export * from './TextDirectionContext';
11
10
  export declare const Label: {
12
- (props: TextProps<React.ElementType>): import("react/jsx-runtime").JSX.Element;
11
+ (props: import("./Text").TextProps<import("react").ElementType>): import("react/jsx-runtime").JSX.Element;
13
12
  displayName: string;
14
13
  };
15
14
  export declare const Legend: {
16
- (props: TextProps<React.ElementType>): import("react/jsx-runtime").JSX.Element;
15
+ (props: import("./Text").TextProps<import("react").ElementType>): import("react/jsx-runtime").JSX.Element;
17
16
  displayName: string;
18
17
  };
@@ -5,9 +5,10 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- export { TextDirection } from './TextDirection.js';
9
- export { Text } from './Text.js';
10
8
  import { createTextComponent } from './createTextComponent.js';
9
+ export { Text } from './Text.js';
10
+ export { TextDirection } from './TextDirection.js';
11
+ import 'react';
11
12
 
12
13
  createTextComponent('label', 'Label');
13
14
  const Legend = createTextComponent('legend', 'Legend');
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2019, 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
+ */
1
7
  import React, { type ReactNode, type MouseEvent, type KeyboardEvent, type HTMLAttributes, type ChangeEvent, type ComponentType } from 'react';
2
8
  export interface TileProps extends HTMLAttributes<HTMLDivElement> {
3
9
  children?: ReactNode;
@@ -20,8 +20,8 @@ import { useMergedRefs } from '../../internal/useMergedRefs.js';
20
20
  import { useFeatureFlag } from '../FeatureFlags/index.js';
21
21
  import { useId } from '../../internal/useId.js';
22
22
  import '../Text/index.js';
23
- import { Text } from '../Text/Text.js';
24
23
  import { matches } from '../../internal/keyboard/match.js';
24
+ import { Text } from '../Text/Text.js';
25
25
  import { Enter, Space } from '../../internal/keyboard/keys.js';
26
26
 
27
27
  var _CheckboxCheckedFille, _Checkbox, _ChevronDown, _ChevronDown2;
@@ -239,9 +239,7 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
239
239
  [`${prefix}--tile--decorator`]: decorator,
240
240
  [`${prefix}--tile--decorator-rounded`]: decorator && hasRoundedCorners
241
241
  }, className);
242
-
243
- // TODO: rename to handleClick when handleClick prop is deprecated
244
- function handleOnClick(evt) {
242
+ function handleClick(evt) {
245
243
  evt.preventDefault();
246
244
  evt?.persist?.();
247
245
  if (normalizedDecorator && decoratorRef.current && decoratorRef.current.contains(evt.target)) {
@@ -251,9 +249,7 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
251
249
  clickHandler(evt);
252
250
  onChange(evt, isSelected, id);
253
251
  }
254
-
255
- // TODO: rename to handleKeyDown when handleKeyDown prop is deprecated
256
- function handleOnKeyDown(evt) {
252
+ function handleKeyDown(evt) {
257
253
  evt?.persist?.();
258
254
  if (matches(evt, [Enter, Space])) {
259
255
  evt.preventDefault();
@@ -285,10 +281,10 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
285
281
  // eslint-disable-next-line jsx-a11y/interactive-supports-focus
286
282
  React__default.createElement("div", _extends({
287
283
  className: classes,
288
- onClick: !disabled ? handleOnClick : undefined,
284
+ onClick: !disabled ? handleClick : undefined,
289
285
  role: "checkbox",
290
286
  "aria-checked": isSelected,
291
- onKeyDown: !disabled ? handleOnKeyDown : undefined
287
+ onKeyDown: !disabled ? handleKeyDown : undefined
292
288
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
293
289
  ,
294
290
  tabIndex: !disabled ? tabIndex : undefined,