@carbon/react 1.57.0 → 1.58.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 (156) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1106 -990
  2. package/es/components/Accordion/Accordion.d.ts +1 -1
  3. package/es/components/Accordion/index.d.ts +2 -2
  4. package/es/components/Button/Button.js +2 -2
  5. package/es/components/Button/index.d.ts +2 -1
  6. package/es/components/Checkbox/Checkbox.d.ts +6 -7
  7. package/es/components/ComboBox/ComboBox.d.ts +4 -5
  8. package/es/components/ComboBox/ComboBox.js +268 -261
  9. package/es/components/ComposedModal/ComposedModal.d.ts +1 -2
  10. package/es/components/DataTable/TableHeader.d.ts +4 -5
  11. package/es/components/DataTable/TableSlugRow.d.ts +3 -2
  12. package/es/components/DatePicker/DatePicker.d.ts +4 -5
  13. package/es/components/Dropdown/Dropdown.d.ts +6 -7
  14. package/es/components/Dropdown/index.d.ts +2 -2
  15. package/es/components/FormLabel/index.d.ts +2 -2
  16. package/es/components/Grid/Column.d.ts +2 -2
  17. package/es/components/Grid/GridTypes.d.ts +1 -2
  18. package/es/components/Grid/index.d.ts +3 -1
  19. package/es/components/IconButton/index.d.ts +3 -4
  20. package/es/components/InlineLoading/index.d.ts +2 -2
  21. package/es/components/ListBox/next/ListBoxTrigger.js +1 -0
  22. package/es/components/Loading/index.d.ts +2 -2
  23. package/es/components/Menu/Menu.js +1 -1
  24. package/es/components/Menu/MenuItem.js +13 -2
  25. package/es/components/Modal/Modal.d.ts +8 -9
  26. package/es/components/Modal/index.d.ts +2 -2
  27. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -2
  28. package/es/components/MultiSelect/MultiSelect.d.ts +10 -9
  29. package/es/components/Notification/Notification.d.ts +2 -2
  30. package/es/components/NumberInput/NumberInput.d.ts +12 -2
  31. package/es/components/NumberInput/NumberInput.js +2 -2
  32. package/es/components/NumberInput/index.d.ts +1 -1
  33. package/es/components/OverflowMenu/OverflowMenu.d.ts +10 -6
  34. package/es/components/OverflowMenu/index.d.ts +13 -0
  35. package/es/components/PasswordInput/index.d.ts +3 -0
  36. package/es/components/Popover/index.d.ts +8 -2
  37. package/es/components/Popover/index.js +26 -1
  38. package/es/components/ProgressBar/ProgressBar.d.ts +1 -1
  39. package/es/components/ProgressBar/index.d.ts +2 -2
  40. package/es/components/ProgressIndicator/ProgressIndicator.d.ts +2 -2
  41. package/es/components/ProgressIndicator/index.d.ts +2 -0
  42. package/es/components/RadioButton/RadioButton.d.ts +3 -4
  43. package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +7 -8
  44. package/es/components/Select/Select.d.ts +1 -2
  45. package/es/components/Slider/Slider.d.ts +5 -5
  46. package/es/components/Slider/Slider.js +1 -1
  47. package/es/components/StructuredList/index.d.ts +2 -0
  48. package/es/components/Switch/Switch.d.ts +1 -1
  49. package/es/components/Switch/index.d.ts +2 -2
  50. package/es/components/Tab/index.d.ts +2 -1
  51. package/es/components/Tag/DismissibleTag.d.ts +12 -12
  52. package/es/components/Tag/DismissibleTag.js +34 -9
  53. package/es/components/Tag/OperationalTag.d.ts +12 -12
  54. package/es/components/Tag/OperationalTag.js +45 -9
  55. package/es/components/Tag/SelectableTag.d.ts +12 -12
  56. package/es/components/Tag/SelectableTag.js +46 -10
  57. package/es/components/Tag/Tag.d.ts +3 -3
  58. package/es/components/Tag/Tag.js +31 -5
  59. package/es/components/TextArea/TextArea.d.ts +6 -7
  60. package/es/components/TextArea/index.d.ts +2 -2
  61. package/es/components/TextInput/PasswordInput.d.ts +5 -6
  62. package/es/components/TextInput/PasswordInput.js +2 -2
  63. package/es/components/TextInput/TextInput.d.ts +1 -2
  64. package/es/components/TextInput/index.d.ts +4 -2
  65. package/es/components/Theme/index.d.ts +1 -0
  66. package/es/components/Theme/index.js +8 -2
  67. package/es/components/Tile/Tile.d.ts +3 -4
  68. package/es/components/TileGroup/TileGroup.d.ts +3 -2
  69. package/es/components/TileGroup/index.d.ts +9 -0
  70. package/es/components/Toggle/Toggle.js +1 -1
  71. package/es/components/Tooltip/DefinitionTooltip.js +1 -1
  72. package/es/components/Tooltip/Tooltip.js +16 -5
  73. package/es/components/Tooltip/index.d.ts +2 -2
  74. package/es/components/UnorderedList/UnorderedList.d.ts +1 -1
  75. package/es/components/UnorderedList/index.d.ts +1 -0
  76. package/es/index.js +4 -4
  77. package/es/prop-types/deprecateValuesWithin.js +35 -0
  78. package/lib/components/Accordion/Accordion.d.ts +1 -1
  79. package/lib/components/Accordion/index.d.ts +2 -2
  80. package/lib/components/Button/Button.js +2 -2
  81. package/lib/components/Button/index.d.ts +2 -1
  82. package/lib/components/Checkbox/Checkbox.d.ts +6 -7
  83. package/lib/components/ComboBox/ComboBox.d.ts +4 -5
  84. package/lib/components/ComboBox/ComboBox.js +267 -261
  85. package/lib/components/ComposedModal/ComposedModal.d.ts +1 -2
  86. package/lib/components/DataTable/TableHeader.d.ts +4 -5
  87. package/lib/components/DataTable/TableSlugRow.d.ts +3 -2
  88. package/lib/components/DatePicker/DatePicker.d.ts +4 -5
  89. package/lib/components/Dropdown/Dropdown.d.ts +6 -7
  90. package/lib/components/Dropdown/index.d.ts +2 -2
  91. package/lib/components/FormLabel/index.d.ts +2 -2
  92. package/lib/components/Grid/Column.d.ts +2 -2
  93. package/lib/components/Grid/GridTypes.d.ts +1 -2
  94. package/lib/components/Grid/index.d.ts +3 -1
  95. package/lib/components/IconButton/index.d.ts +3 -4
  96. package/lib/components/InlineLoading/index.d.ts +2 -2
  97. package/lib/components/ListBox/next/ListBoxTrigger.js +1 -0
  98. package/lib/components/Loading/index.d.ts +2 -2
  99. package/lib/components/Menu/Menu.js +1 -1
  100. package/lib/components/Menu/MenuItem.js +13 -2
  101. package/lib/components/Modal/Modal.d.ts +8 -9
  102. package/lib/components/Modal/index.d.ts +2 -2
  103. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -2
  104. package/lib/components/MultiSelect/MultiSelect.d.ts +10 -9
  105. package/lib/components/Notification/Notification.d.ts +2 -2
  106. package/lib/components/NumberInput/NumberInput.d.ts +12 -2
  107. package/lib/components/NumberInput/NumberInput.js +2 -2
  108. package/lib/components/NumberInput/index.d.ts +1 -1
  109. package/lib/components/OverflowMenu/OverflowMenu.d.ts +10 -6
  110. package/lib/components/OverflowMenu/index.d.ts +13 -0
  111. package/lib/components/PasswordInput/index.d.ts +3 -0
  112. package/lib/components/Popover/index.d.ts +8 -2
  113. package/lib/components/Popover/index.js +26 -1
  114. package/lib/components/ProgressBar/ProgressBar.d.ts +1 -1
  115. package/lib/components/ProgressBar/index.d.ts +2 -2
  116. package/lib/components/ProgressIndicator/ProgressIndicator.d.ts +2 -2
  117. package/lib/components/ProgressIndicator/index.d.ts +2 -0
  118. package/lib/components/RadioButton/RadioButton.d.ts +3 -4
  119. package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +7 -8
  120. package/lib/components/Select/Select.d.ts +1 -2
  121. package/lib/components/Slider/Slider.d.ts +5 -5
  122. package/lib/components/Slider/Slider.js +1 -1
  123. package/lib/components/StructuredList/index.d.ts +2 -0
  124. package/lib/components/Switch/Switch.d.ts +1 -1
  125. package/lib/components/Switch/index.d.ts +2 -2
  126. package/lib/components/Tab/index.d.ts +2 -1
  127. package/lib/components/Tag/DismissibleTag.d.ts +12 -12
  128. package/lib/components/Tag/DismissibleTag.js +33 -8
  129. package/lib/components/Tag/OperationalTag.d.ts +12 -12
  130. package/lib/components/Tag/OperationalTag.js +44 -8
  131. package/lib/components/Tag/SelectableTag.d.ts +12 -12
  132. package/lib/components/Tag/SelectableTag.js +45 -9
  133. package/lib/components/Tag/Tag.d.ts +3 -3
  134. package/lib/components/Tag/Tag.js +30 -4
  135. package/lib/components/TextArea/TextArea.d.ts +6 -7
  136. package/lib/components/TextArea/index.d.ts +2 -2
  137. package/lib/components/TextInput/PasswordInput.d.ts +5 -6
  138. package/lib/components/TextInput/PasswordInput.js +2 -2
  139. package/lib/components/TextInput/TextInput.d.ts +1 -2
  140. package/lib/components/TextInput/index.d.ts +4 -2
  141. package/lib/components/Theme/index.d.ts +1 -0
  142. package/lib/components/Theme/index.js +8 -1
  143. package/lib/components/Tile/Tile.d.ts +3 -4
  144. package/lib/components/TileGroup/TileGroup.d.ts +3 -2
  145. package/lib/components/TileGroup/index.d.ts +9 -0
  146. package/lib/components/Toggle/Toggle.js +1 -1
  147. package/lib/components/Tooltip/DefinitionTooltip.js +1 -1
  148. package/lib/components/Tooltip/Tooltip.js +16 -5
  149. package/lib/components/Tooltip/index.d.ts +2 -2
  150. package/lib/components/UnorderedList/UnorderedList.d.ts +1 -1
  151. package/lib/components/UnorderedList/index.d.ts +1 -0
  152. package/lib/index.js +30 -29
  153. package/lib/prop-types/deprecateValuesWithin.js +39 -0
  154. package/package.json +6 -6
  155. package/es/components/TileGroup/index.js +0 -13
  156. package/lib/components/TileGroup/index.js +0 -18
@@ -12,6 +12,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
12
12
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
13
  var cx = require('classnames');
14
14
  var PropTypes = require('prop-types');
15
+ var deprecateValuesWithin = require('../../prop-types/deprecateValuesWithin.js');
15
16
  var React = require('react');
16
17
  var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
17
18
  var useMergedRefs = require('../../internal/useMergedRefs.js');
@@ -35,6 +36,25 @@ const PopoverContext = /*#__PURE__*/React__default["default"].createContext({
35
36
  },
36
37
  autoAlign: null
37
38
  });
39
+
40
+ /**
41
+ * Deprecated popover alignment values.
42
+ * @deprecated Use NewPopoverAlignment instead.
43
+ */
44
+
45
+ const propMappingFunction = deprecatedValue => {
46
+ const mapping = {
47
+ 'top-left': 'top-start',
48
+ 'top-right': 'top-end',
49
+ 'bottom-left': 'bottom-start',
50
+ 'bottom-right': 'bottom-end',
51
+ 'left-bottom': 'left-end',
52
+ 'left-top': 'left-start',
53
+ 'right-bottom': 'right-end',
54
+ 'right-top': 'right-start'
55
+ };
56
+ return mapping[deprecatedValue];
57
+ };
38
58
  const Popover = /*#__PURE__*/React__default["default"].forwardRef(function PopoverRenderFunction(_ref, forwardRef) {
39
59
  let {
40
60
  isTabTip,
@@ -233,8 +253,9 @@ if (process.env.NODE_ENV !== "production") {
233
253
  Popover.propTypes = {
234
254
  /**
235
255
  * Specify how the popover should align with the trigger element
256
+
236
257
  */
237
- align: PropTypes__default["default"].oneOf(['top', 'top-left',
258
+ align: deprecateValuesWithin["default"](PropTypes__default["default"].oneOf(['top', 'top-left',
238
259
  // deprecated use top-start instead
239
260
  'top-right',
240
261
  // deprecated use top-end instead
@@ -256,6 +277,10 @@ Popover.propTypes = {
256
277
 
257
278
  // new values to match floating-ui
258
279
  'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
280
+ //allowed prop values
281
+ ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'],
282
+ //optional mapper function
283
+ propMappingFunction),
259
284
  /**
260
285
  * Provide a custom element or component to render the top-level node for the
261
286
  * component.
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
- interface ProgressBarProps {
8
+ export interface ProgressBarProps {
9
9
  /**
10
10
  * Additional CSS class names.
11
11
  */
@@ -4,6 +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 ProgressBar from './ProgressBar';
7
+ import ProgressBar, { type ProgressBarProps } from './ProgressBar';
8
8
  export default ProgressBar;
9
- export { ProgressBar };
9
+ export { ProgressBar, type ProgressBarProps };
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
8
  import React from 'react';
9
- interface ProgressIndicatorProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'onChange'> {
9
+ export interface ProgressIndicatorProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'onChange'> {
10
10
  /**
11
11
  * Provide `<ProgressStep>` components to be rendered in the
12
12
  * `<ProgressIndicator>`
@@ -63,7 +63,7 @@ declare namespace ProgressIndicator {
63
63
  vertical: PropTypes.Requireable<boolean>;
64
64
  };
65
65
  }
66
- interface ProgressStepProps {
66
+ export interface ProgressStepProps {
67
67
  /**
68
68
  * Provide an optional className to be applied to the containing `<li>` node
69
69
  */
@@ -4,5 +4,7 @@
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 ProgressIndicatorProps, type ProgressStepProps } from './ProgressIndicator';
7
8
  export { default as ProgressIndicatorSkeleton } from './ProgressIndicator.Skeleton';
8
9
  export * from './ProgressIndicator';
10
+ export { type ProgressIndicatorProps, type ProgressStepProps };
@@ -4,8 +4,7 @@
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 { ReactNodeLike } from 'prop-types';
8
- import React from 'react';
7
+ import React, { ReactNode } from 'react';
9
8
  type ExcludedAttributes = 'onChange';
10
9
  export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
11
10
  /**
@@ -41,7 +40,7 @@ export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInp
41
40
  * Provide label text to be read by screen readers when interacting with the
42
41
  * control
43
42
  */
44
- labelText: ReactNodeLike;
43
+ labelText: ReactNode;
45
44
  /**
46
45
  * Provide a name for the underlying `<input>` node
47
46
  */
@@ -58,7 +57,7 @@ export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInp
58
57
  /**
59
58
  * **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButton` component
60
59
  */
61
- slug?: ReactNodeLike;
60
+ slug?: ReactNode;
62
61
  /**
63
62
  * Specify the value of the `<RadioButton>`
64
63
  */
@@ -4,15 +4,14 @@
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 { ReactNodeLike } from 'prop-types';
8
- import React from 'react';
7
+ import React, { ReactNode } from 'react';
9
8
  export declare const RadioButtonGroupContext: React.Context<null>;
10
9
  type ExcludedAttributes = 'onChange';
11
10
  export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HTMLFieldSetElement>, ExcludedAttributes> {
12
11
  /**
13
12
  * Provide a collection of `<RadioButton>` components to render in the group
14
13
  */
15
- children?: ReactNodeLike;
14
+ children?: ReactNode;
16
15
  /**
17
16
  * Provide an optional className to be applied to the container node
18
17
  */
@@ -28,7 +27,7 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
28
27
  /**
29
28
  * Provide text that is used alongside the control label for additional help
30
29
  */
31
- helperText?: ReactNodeLike;
30
+ helperText?: ReactNode;
32
31
  /**
33
32
  * Specify whether the control is currently invalid
34
33
  */
@@ -36,7 +35,7 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
36
35
  /**
37
36
  * Provide the text that is displayed when the control is in an invalid state
38
37
  */
39
- invalidText?: ReactNodeLike;
38
+ invalidText?: ReactNode;
40
39
  /**
41
40
  * Provide where label text should be placed
42
41
  */
@@ -45,7 +44,7 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
45
44
  * Provide a legend to the RadioButtonGroup input that you are
46
45
  * exposing to the user
47
46
  */
48
- legendText?: ReactNodeLike;
47
+ legendText?: ReactNode;
49
48
  /**
50
49
  * Specify the name of the underlying `<input>` nodes
51
50
  */
@@ -66,7 +65,7 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
66
65
  /**
67
66
  * **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButtonGroup` component
68
67
  */
69
- slug?: ReactNodeLike;
68
+ slug?: ReactNode;
70
69
  /**
71
70
  * Specify whether the control is currently in warning state
72
71
  */
@@ -74,7 +73,7 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
74
73
  /**
75
74
  * Provide the text that is displayed when the control is in warning state
76
75
  */
77
- warnText?: ReactNodeLike;
76
+ warnText?: ReactNode;
78
77
  /**
79
78
  * Specify the value that is currently selected in the group
80
79
  */
@@ -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 { ReactNodeLike } from 'prop-types';
8
7
  import React, { ChangeEventHandler, ComponentPropsWithRef, ReactNode } from 'react';
9
8
  type ExcludedAttributes = 'size';
10
9
  interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttributes> {
@@ -80,7 +79,7 @@ interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttr
80
79
  /**
81
80
  * **Experimental**: Provide a `Slug` component to be rendered inside the `Dropdown` component
82
81
  */
83
- slug?: ReactNodeLike;
82
+ slug?: ReactNode;
84
83
  /**
85
84
  * Specify whether the control is currently in warning state
86
85
  */
@@ -4,8 +4,8 @@
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, { type KeyboardEventHandler, PureComponent } from 'react';
8
- import PropTypes, { ReactNodeLike } from 'prop-types';
7
+ import React, { type KeyboardEventHandler, PureComponent, ReactNode } from 'react';
8
+ import PropTypes from 'prop-types';
9
9
  /**
10
10
  * Distinguish two handles by lower and upper positions.
11
11
  */
@@ -26,7 +26,7 @@ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
26
26
  /**
27
27
  * The child nodes.
28
28
  */
29
- children?: ReactNodeLike;
29
+ children?: ReactNode;
30
30
  /**
31
31
  * The CSS class name for the slider, set on the wrapping div.
32
32
  */
@@ -58,11 +58,11 @@ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
58
58
  /**
59
59
  * Provide the text that is displayed when the Slider is in an invalid state
60
60
  */
61
- invalidText?: React.ReactNode;
61
+ invalidText?: ReactNode;
62
62
  /**
63
63
  * The label for the slider.
64
64
  */
65
- labelText?: ReactNodeLike;
65
+ labelText?: ReactNode;
66
66
  /**
67
67
  * @deprecated
68
68
  * `true` to use the light version.
@@ -474,7 +474,7 @@ class Slider extends React.PureComponent {
474
474
  });
475
475
  if (adjustedValue !== targetValue) {
476
476
  this.setState({
477
- correctedValue: targetValue,
477
+ correctedValue: targetValue.toString(),
478
478
  correctedPosition: handlePosition
479
479
  });
480
480
  } else {
@@ -4,5 +4,7 @@
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 StructuredListWrapperProps } from './StructuredList';
7
8
  export * from './StructuredList';
8
9
  export { default as StructuredListSkeleton, type StructuredListSkeletonProps, } from './StructuredList.Skeleton';
10
+ export { type StructuredListWrapperProps };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React, { ButtonHTMLAttributes, ReactNode } from 'react';
8
- interface SwitchEventHandlersParams {
8
+ export interface SwitchEventHandlersParams {
9
9
  index?: number;
10
10
  name?: string | number;
11
11
  text?: string;
@@ -4,7 +4,7 @@
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 Switch from './Switch';
7
+ import Switch, { type SwitchProps } from './Switch';
8
8
  import IconSwitch from './IconSwitch';
9
9
  export default Switch;
10
- export { Switch, IconSwitch };
10
+ export { Switch, IconSwitch, type SwitchProps };
@@ -5,5 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { Tab } from '../Tabs/Tabs';
8
+ import { type TabProps } from '../Tabs/Tabs';
8
9
  export default Tab;
9
- export { Tab };
10
+ export { Tab, type TabProps };
@@ -4,15 +4,11 @@
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, { ReactNodeLike } from 'prop-types';
8
- import React from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import React, { ReactNode } from 'react';
9
9
  import { PolymorphicProps } from '../../types/common';
10
10
  import { SIZES, TYPES } from './Tag';
11
11
  export interface DismissibleTagBaseProps {
12
- /**
13
- * Provide content to be rendered inside of a `DismissibleTag`
14
- */
15
- children?: React.ReactNode;
16
12
  /**
17
13
  * Provide a custom className that is applied to the containing <span>
18
14
  */
@@ -42,7 +38,11 @@ export interface DismissibleTagBaseProps {
42
38
  /**
43
39
  * **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
44
40
  */
45
- slug?: ReactNodeLike;
41
+ slug?: ReactNode;
42
+ /**
43
+ * Provide text to be rendered inside of a the tag.
44
+ */
45
+ text?: string;
46
46
  /**
47
47
  * Text to show on clear filters
48
48
  */
@@ -54,12 +54,8 @@ export interface DismissibleTagBaseProps {
54
54
  }
55
55
  export type DismissibleTagProps<T extends React.ElementType> = PolymorphicProps<T, DismissibleTagBaseProps>;
56
56
  declare const DismissibleTag: {
57
- <T extends React.ElementType<any>>({ children, className, disabled, id, renderIcon, title, onClose, slug, size, type, ...other }: DismissibleTagProps<T>): import("react/jsx-runtime").JSX.Element;
57
+ <T extends React.ElementType<any>>({ className, disabled, id, renderIcon, title, onClose, slug, size, text, type, ...other }: DismissibleTagProps<T>): import("react/jsx-runtime").JSX.Element;
58
58
  propTypes: {
59
- /**
60
- * Provide content to be rendered inside of a `DismissibleTag`
61
- */
62
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
63
59
  /**
64
60
  * Provide a custom className that is applied to the containing <span>
65
61
  */
@@ -90,6 +86,10 @@ declare const DismissibleTag: {
90
86
  * **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
91
87
  */
92
88
  slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
89
+ /**
90
+ * Provide text to be rendered inside of a the tag.
91
+ */
92
+ text: PropTypes.Requireable<string>;
93
93
  /**
94
94
  * Text to show on clear filters
95
95
  */
@@ -17,6 +17,10 @@ var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
17
17
  var usePrefix = require('../../internal/usePrefix.js');
18
18
  var Tag = require('./Tag.js');
19
19
  var iconsReact = require('@carbon/icons-react');
20
+ require('../Tooltip/DefinitionTooltip.js');
21
+ var Tooltip = require('../Tooltip/Tooltip.js');
22
+ require('../Text/index.js');
23
+ var Text = require('../Text/Text.js');
20
24
 
21
25
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
26
 
@@ -28,21 +32,31 @@ var _Close;
28
32
  const getInstanceId = setupGetInstanceId["default"]();
29
33
  const DismissibleTag = _ref => {
30
34
  let {
31
- children,
32
35
  className,
33
36
  disabled,
34
37
  id,
35
38
  renderIcon,
36
- title = 'Clear filter',
39
+ title = 'Dismiss',
37
40
  onClose,
38
41
  slug,
39
42
  size,
43
+ text,
40
44
  type,
41
45
  ...other
42
46
  } = _ref;
43
47
  const prefix = usePrefix.usePrefix();
44
48
  const tagId = id || `tag-${getInstanceId()}`;
45
49
  const tagClasses = cx__default["default"](`${prefix}--tag--filter`, className);
50
+ const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
51
+ const isEllipsisActive = element => {
52
+ setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
53
+ return element.offsetWidth < element.scrollWidth;
54
+ };
55
+ React.useLayoutEffect(() => {
56
+ const elementTagId = document.querySelector(`#${tagId}`);
57
+ const newElement = elementTagId?.getElementsByClassName(`${prefix}--tag__label`)[0];
58
+ isEllipsisActive(newElement);
59
+ }, [prefix, tagId]);
46
60
  const handleClose = event => {
47
61
  if (onClose) {
48
62
  event.stopPropagation();
@@ -56,6 +70,7 @@ const DismissibleTag = _ref => {
56
70
  kind: 'inline'
57
71
  });
58
72
  }
73
+ const tooltipClasses = cx__default["default"](`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
59
74
 
60
75
  // Removing onClick from the spread operator
61
76
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -63,6 +78,7 @@ const DismissibleTag = _ref => {
63
78
  onClick,
64
79
  ...otherProps
65
80
  } = other;
81
+ const dismissLabel = `Dismiss "${text}"`;
66
82
  return /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
67
83
  type: type,
68
84
  size: size,
@@ -72,20 +88,25 @@ const DismissibleTag = _ref => {
72
88
  id: tagId
73
89
  }, otherProps), /*#__PURE__*/React__default["default"].createElement("div", {
74
90
  className: `${prefix}--interactive--tag-children`
75
- }, children, normalizedSlug, /*#__PURE__*/React__default["default"].createElement("button", {
91
+ }, /*#__PURE__*/React__default["default"].createElement(Text.Text, {
92
+ title: text,
93
+ className: `${prefix}--tag__label`
94
+ }, text), /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
95
+ label: isEllipsisApplied ? dismissLabel : title,
96
+ align: "bottom",
97
+ className: tooltipClasses,
98
+ leaveDelayMs: 0,
99
+ closeOnActivation: true
100
+ }, /*#__PURE__*/React__default["default"].createElement("button", {
76
101
  type: "button",
77
102
  className: `${prefix}--tag__close-icon`,
78
103
  onClick: handleClose,
79
104
  disabled: disabled,
80
105
  "aria-label": title,
81
106
  title: title
82
- }, _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null)))));
107
+ }, _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null)))), normalizedSlug));
83
108
  };
84
109
  DismissibleTag.propTypes = {
85
- /**
86
- * Provide content to be rendered inside of a `DismissibleTag`
87
- */
88
- children: PropTypes__default["default"].node,
89
110
  /**
90
111
  * Provide a custom className that is applied to the containing <span>
91
112
  */
@@ -116,6 +137,10 @@ DismissibleTag.propTypes = {
116
137
  * **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
117
138
  */
118
139
  slug: PropTypes__default["default"].node,
140
+ /**
141
+ * Provide text to be rendered inside of a the tag.
142
+ */
143
+ text: PropTypes__default["default"].string,
119
144
  /**
120
145
  * Text to show on clear filters
121
146
  */
@@ -4,8 +4,8 @@
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, { ReactNodeLike } from 'prop-types';
8
- import React, { MouseEventHandler } from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import React, { MouseEventHandler, ReactNode } from 'react';
9
9
  import { PolymorphicProps } from '../../types/common';
10
10
  import { SIZES } from './Tag';
11
11
  declare const TYPES: {
@@ -21,10 +21,6 @@ declare const TYPES: {
21
21
  'warm-gray': string;
22
22
  };
23
23
  export interface OperationalTagBaseProps {
24
- /**
25
- * Provide content to be rendered inside of a `OperationalTag`
26
- */
27
- children?: React.ReactNode;
28
24
  /**
29
25
  * Provide a custom className that is applied to the containing <span>
30
26
  */
@@ -51,7 +47,11 @@ export interface OperationalTagBaseProps {
51
47
  /**
52
48
  * **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
53
49
  */
54
- slug?: ReactNodeLike;
50
+ slug?: ReactNode;
51
+ /**
52
+ * Provide text to be rendered inside of a the tag.
53
+ */
54
+ text?: string;
55
55
  /**
56
56
  * Specify the type of the `Tag`
57
57
  */
@@ -59,12 +59,8 @@ export interface OperationalTagBaseProps {
59
59
  }
60
60
  export type OperationalTagProps<T extends React.ElementType> = PolymorphicProps<T, OperationalTagBaseProps>;
61
61
  declare const OperationalTag: {
62
- <T extends React.ElementType<any>>({ children, className, disabled, id, renderIcon, slug, size, type, ...other }: OperationalTagProps<T>): import("react/jsx-runtime").JSX.Element;
62
+ <T extends React.ElementType<any>>({ className, disabled, id, renderIcon, slug, size, text, type, ...other }: OperationalTagProps<T>): import("react/jsx-runtime").JSX.Element;
63
63
  propTypes: {
64
- /**
65
- * Provide content to be rendered inside of a `OperationalTag`
66
- */
67
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
68
64
  /**
69
65
  * Provide a custom className that is applied to the containing <span>
70
66
  */
@@ -91,6 +87,10 @@ declare const OperationalTag: {
91
87
  * **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
92
88
  */
93
89
  slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
90
+ /**
91
+ * Provide text to be rendered inside of a the tag.
92
+ */
93
+ text: PropTypes.Requireable<string>;
94
94
  /**
95
95
  * Specify the type of the `Tag`
96
96
  */
@@ -16,6 +16,10 @@ var cx = require('classnames');
16
16
  var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
17
17
  var usePrefix = require('../../internal/usePrefix.js');
18
18
  var Tag = require('./Tag.js');
19
+ require('../Tooltip/DefinitionTooltip.js');
20
+ var Tooltip = require('../Tooltip/Tooltip.js');
21
+ require('../Text/index.js');
22
+ var Text = require('../Text/Text.js');
19
23
 
20
24
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
25
 
@@ -38,19 +42,29 @@ const TYPES = {
38
42
  };
39
43
  const OperationalTag = _ref => {
40
44
  let {
41
- children,
42
45
  className,
43
46
  disabled,
44
47
  id,
45
48
  renderIcon,
46
49
  slug,
47
50
  size,
51
+ text,
48
52
  type = 'gray',
49
53
  ...other
50
54
  } = _ref;
51
55
  const prefix = usePrefix.usePrefix();
52
56
  const tagId = id || `tag-${getInstanceId()}`;
53
57
  const tagClasses = cx__default["default"](`${prefix}--tag--operational`, className);
58
+ const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
59
+ const isEllipsisActive = element => {
60
+ setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
61
+ return element.offsetWidth < element.scrollWidth;
62
+ };
63
+ React.useLayoutEffect(() => {
64
+ const elementTagId = document.querySelector(`#${tagId}`);
65
+ const newElement = elementTagId?.getElementsByClassName(`${prefix}--tag__label`)[0];
66
+ isEllipsisActive(newElement);
67
+ }, [prefix, tagId]);
54
68
  let normalizedSlug;
55
69
  if (slug && slug['type']?.displayName === 'Slug') {
56
70
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
@@ -58,6 +72,27 @@ const OperationalTag = _ref => {
58
72
  kind: 'inline'
59
73
  });
60
74
  }
75
+ const tooltipClasses = cx__default["default"](`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
76
+ if (isEllipsisApplied) {
77
+ return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
78
+ label: text,
79
+ align: "bottom",
80
+ className: tooltipClasses,
81
+ leaveDelayMs: 0,
82
+ onMouseEnter: false,
83
+ closeOnActivation: true
84
+ }, /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
85
+ type: type,
86
+ size: size,
87
+ renderIcon: renderIcon,
88
+ disabled: disabled,
89
+ className: tagClasses,
90
+ id: tagId
91
+ }, other), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
92
+ title: text,
93
+ className: `${prefix}--tag__label`
94
+ }, text), normalizedSlug));
95
+ }
61
96
  return /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
62
97
  type: type,
63
98
  size: size,
@@ -65,15 +100,12 @@ const OperationalTag = _ref => {
65
100
  disabled: disabled,
66
101
  className: tagClasses,
67
102
  id: tagId
68
- }, other), /*#__PURE__*/React__default["default"].createElement("div", {
69
- className: `${prefix}--interactive--tag-children`
70
- }, children, normalizedSlug));
103
+ }, other), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(Text.Text, {
104
+ title: text,
105
+ className: `${prefix}--tag__label`
106
+ }, text));
71
107
  };
72
108
  OperationalTag.propTypes = {
73
- /**
74
- * Provide content to be rendered inside of a `OperationalTag`
75
- */
76
- children: PropTypes__default["default"].node,
77
109
  /**
78
110
  * Provide a custom className that is applied to the containing <span>
79
111
  */
@@ -100,6 +132,10 @@ OperationalTag.propTypes = {
100
132
  * **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
101
133
  */
102
134
  slug: PropTypes__default["default"].node,
135
+ /**
136
+ * Provide text to be rendered inside of a the tag.
137
+ */
138
+ text: PropTypes__default["default"].string,
103
139
  /**
104
140
  * Specify the type of the `Tag`
105
141
  */
@@ -4,15 +4,11 @@
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, { ReactNodeLike } from 'prop-types';
8
- import React from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import React, { ReactNode } from 'react';
9
9
  import { PolymorphicProps } from '../../types/common';
10
10
  import { SIZES } from './Tag';
11
11
  export interface SelectableTagBaseProps {
12
- /**
13
- * Provide content to be rendered inside of a `SelectableTag`
14
- */
15
- children?: React.ReactNode;
16
12
  /**
17
13
  * Provide a custom className that is applied to the containing <span>
18
14
  */
@@ -42,16 +38,16 @@ export interface SelectableTagBaseProps {
42
38
  /**
43
39
  * **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
44
40
  */
45
- slug?: ReactNodeLike;
41
+ slug?: ReactNode;
42
+ /**
43
+ * Provide text to be rendered inside of a the tag.
44
+ */
45
+ text?: string;
46
46
  }
47
47
  export type SelectableTagProps<T extends React.ElementType> = PolymorphicProps<T, SelectableTagBaseProps>;
48
48
  declare const SelectableTag: {
49
- <T extends React.ElementType<any>>({ children, className, disabled, id, renderIcon, selected, slug, size, ...other }: SelectableTagProps<T>): import("react/jsx-runtime").JSX.Element;
49
+ <T extends React.ElementType<any>>({ className, disabled, id, renderIcon, selected, slug, size, text, ...other }: SelectableTagProps<T>): import("react/jsx-runtime").JSX.Element;
50
50
  propTypes: {
51
- /**
52
- * Provide content to be rendered inside of a `SelectableTag`
53
- */
54
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
55
51
  /**
56
52
  * Provide a custom className that is applied to the containing <span>
57
53
  */
@@ -82,6 +78,10 @@ declare const SelectableTag: {
82
78
  * **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
83
79
  */
84
80
  slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
81
+ /**
82
+ * Provide text to be rendered inside of a the tag.
83
+ */
84
+ text: PropTypes.Requireable<string>;
85
85
  };
86
86
  };
87
87
  export default SelectableTag;