@carbon/react 1.52.0 → 1.53.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 (58) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1617 -1393
  2. package/es/components/Accordion/AccordionItem.js +1 -1
  3. package/es/components/CodeSnippet/CodeSnippet.js +2 -2
  4. package/es/components/Copy/Copy.d.ts +74 -0
  5. package/es/components/Copy/Copy.js +1 -1
  6. package/es/components/Copy/index.d.ts +9 -0
  7. package/es/components/CopyButton/CopyButton.d.ts +71 -0
  8. package/es/components/CopyButton/index.d.ts +9 -0
  9. package/es/components/Dropdown/Dropdown.Skeleton.d.ts +11 -0
  10. package/es/components/Dropdown/Dropdown.Skeleton.js +11 -6
  11. package/es/components/FileUploader/FileUploaderItem.d.ts +1 -1
  12. package/es/components/FileUploader/FileUploaderItem.js +2 -1
  13. package/es/components/Notification/Notification.d.ts +2 -2
  14. package/es/components/Notification/Notification.js +2 -1
  15. package/es/components/OverflowMenu/OverflowMenu.js +13 -1
  16. package/es/components/RadioTile/RadioTile.js +16 -3
  17. package/es/components/Tag/DismissibleTag.d.ts +104 -0
  18. package/es/components/Tag/OperationalTag.d.ts +101 -0
  19. package/es/components/Tag/SelectableTag.d.ts +87 -0
  20. package/es/components/Tag/Tag.d.ts +17 -12
  21. package/es/components/Tag/Tag.js +25 -17
  22. package/es/components/Tag/index.d.ts +0 -1
  23. package/es/components/Toggle/Toggle.js +3 -1
  24. package/es/components/Toggletip/index.d.ts +5 -3
  25. package/es/components/Toggletip/index.js +13 -2
  26. package/es/components/Tooltip/DefinitionTooltip.js +3 -0
  27. package/es/feature-flags.js +2 -1
  28. package/es/index.js +3 -3
  29. package/es/internal/Selection.js +15 -21
  30. package/lib/components/Accordion/AccordionItem.js +1 -1
  31. package/lib/components/CodeSnippet/CodeSnippet.js +2 -2
  32. package/lib/components/Copy/Copy.d.ts +74 -0
  33. package/lib/components/Copy/Copy.js +1 -1
  34. package/lib/components/Copy/index.d.ts +9 -0
  35. package/lib/components/CopyButton/CopyButton.d.ts +71 -0
  36. package/lib/components/CopyButton/index.d.ts +9 -0
  37. package/lib/components/Dropdown/Dropdown.Skeleton.d.ts +11 -0
  38. package/lib/components/Dropdown/Dropdown.Skeleton.js +11 -6
  39. package/lib/components/FileUploader/FileUploaderItem.d.ts +1 -1
  40. package/lib/components/FileUploader/FileUploaderItem.js +2 -1
  41. package/lib/components/Notification/Notification.d.ts +2 -2
  42. package/lib/components/Notification/Notification.js +2 -1
  43. package/lib/components/OverflowMenu/OverflowMenu.js +13 -1
  44. package/lib/components/RadioTile/RadioTile.js +15 -2
  45. package/lib/components/Tag/DismissibleTag.d.ts +104 -0
  46. package/lib/components/Tag/OperationalTag.d.ts +101 -0
  47. package/lib/components/Tag/SelectableTag.d.ts +87 -0
  48. package/lib/components/Tag/Tag.d.ts +17 -12
  49. package/lib/components/Tag/Tag.js +26 -17
  50. package/lib/components/Tag/index.d.ts +0 -1
  51. package/lib/components/Toggle/Toggle.js +3 -1
  52. package/lib/components/Toggletip/index.d.ts +5 -3
  53. package/lib/components/Toggletip/index.js +13 -2
  54. package/lib/components/Tooltip/DefinitionTooltip.js +3 -0
  55. package/lib/feature-flags.js +2 -1
  56. package/lib/index.js +4 -5
  57. package/lib/internal/Selection.js +14 -20
  58. package/package.json +8 -8
@@ -45,7 +45,7 @@ function AccordionItem(_ref) {
45
45
  const prefix = usePrefix();
46
46
  const className = cx({
47
47
  [`${prefix}--accordion__item`]: true,
48
- [`${prefix}--accordion__item--active`]: isOpen,
48
+ [`${prefix}--accordion__item--active`]: isOpen && !disabled,
49
49
  [`${prefix}--accordion__item--disabled`]: disabled,
50
50
  [customClassName]: !!customClassName
51
51
  });
@@ -24,7 +24,7 @@ const rowHeightInPixels = 16;
24
24
  const defaultMaxCollapsedNumberOfRows = 15;
25
25
  const defaultMaxExpandedNumberOfRows = 0;
26
26
  const defaultMinCollapsedNumberOfRows = 3;
27
- const defaultMinExpandedNumberOfRows = 16;
27
+ const defaultMinExpandedNumberOfRows = 0;
28
28
  function CodeSnippet(_ref) {
29
29
  let {
30
30
  align = 'bottom',
@@ -101,7 +101,7 @@ function CodeSnippet(_ref) {
101
101
  if (codeContentRef?.current && type === 'multi') {
102
102
  const {
103
103
  height
104
- } = codeContentRef.current.getBoundingClientRect();
104
+ } = innerCodeRef.current.getBoundingClientRect();
105
105
  if (maxCollapsedNumberOfRows > 0 && (maxExpandedNumberOfRows <= 0 || maxExpandedNumberOfRows > maxCollapsedNumberOfRows) && height > maxCollapsedNumberOfRows * rowHeightInPixels) {
106
106
  setShouldShowMoreLessBtn(true);
107
107
  } else {
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import PropTypes from 'prop-types';
8
+ import React, { AnimationEventHandler, MouseEventHandler, PropsWithChildren } from 'react';
9
+ interface CopyProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
10
+ /**
11
+ * Specify how the trigger should align with the tooltip
12
+ */
13
+ align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
14
+ /**
15
+ * Specify an optional className to be applied to the underlying `<button>`
16
+ */
17
+ className?: string;
18
+ /**
19
+ * Specify the string that is displayed when the button is clicked and the
20
+ * content is copied
21
+ */
22
+ feedback?: string;
23
+ /**
24
+ * Specify the time it takes for the feedback message to timeout
25
+ */
26
+ feedbackTimeout?: number;
27
+ /**
28
+ * Specify an optional `onAnimationEnd` handler that is called when the underlying
29
+ * animation ends
30
+ */
31
+ onAnimationEnd?: AnimationEventHandler<HTMLButtonElement>;
32
+ /**
33
+ * Specify an optional `onClick` handler that is called when the underlying
34
+ * `<button>` is clicked
35
+ */
36
+ onClick?: MouseEventHandler<HTMLButtonElement>;
37
+ }
38
+ declare function Copy({ align, children, className, feedback, feedbackTimeout, onAnimationEnd, onClick, ...other }: PropsWithChildren<CopyProps>): import("react/jsx-runtime").JSX.Element;
39
+ declare namespace Copy {
40
+ var propTypes: {
41
+ /**
42
+ * Specify how the trigger should align with the tooltip
43
+ */
44
+ align: PropTypes.Requireable<string>;
45
+ /**
46
+ * Pass in content to be rendered in the underlying `<button>`
47
+ */
48
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
49
+ /**
50
+ * Specify an optional className to be applied to the underlying `<button>`
51
+ */
52
+ className: PropTypes.Requireable<string>;
53
+ /**
54
+ * Specify the string that is displayed when the button is clicked and the
55
+ * content is copied
56
+ */
57
+ feedback: PropTypes.Requireable<string>;
58
+ /**
59
+ * Specify the time it takes for the feedback message to timeout
60
+ */
61
+ feedbackTimeout: PropTypes.Requireable<number>;
62
+ /**
63
+ * Specify an optional `onAnimationEnd` handler that is called when the underlying
64
+ * animation ends
65
+ */
66
+ onAnimationEnd: PropTypes.Requireable<(...args: any[]) => any>;
67
+ /**
68
+ * Specify an optional `onClick` handler that is called when the underlying
69
+ * `<button>` is clicked
70
+ */
71
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
72
+ };
73
+ }
74
+ export default Copy;
@@ -57,7 +57,7 @@ function Copy(_ref) {
57
57
  onClick: composeEventHandlers([onClick, handleClick]),
58
58
  onAnimationEnd: composeEventHandlers([onAnimationEnd, handleAnimationEnd])
59
59
  }, other, {
60
- "aria-label": !children && (animation ? feedback : other['aria-label']) || null
60
+ "aria-label": !children && (animation ? feedback : other['aria-label']) || undefined
61
61
  }), children);
62
62
  }
63
63
  Copy.propTypes = {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import Copy from './Copy';
8
+ export default Copy;
9
+ export { Copy };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import PropTypes from 'prop-types';
8
+ import { MouseEventHandler } from 'react';
9
+ import { ButtonProps } from '../Button';
10
+ export interface CopyButtonProps extends ButtonProps<'button'> {
11
+ /**
12
+ * Specify how the trigger should align with the tooltip
13
+ */
14
+ align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
15
+ /**
16
+ * Specify an optional className to be applied to the underlying `<button>`
17
+ */
18
+ className?: string;
19
+ /**
20
+ * Specify the string that is displayed when the button is clicked and the
21
+ * content is copied
22
+ */
23
+ feedback?: string;
24
+ /**
25
+ * Specify the time it takes for the feedback message to timeout
26
+ */
27
+ feedbackTimeout?: number;
28
+ /**
29
+ * Provide a description for the icon representing the copy action that can
30
+ * be read by screen readers
31
+ */
32
+ iconDescription?: string;
33
+ /**
34
+ * Specify an optional `onClick` handler that is called when the underlying
35
+ * `<button>` is clicked
36
+ */
37
+ onClick?: MouseEventHandler<HTMLButtonElement>;
38
+ }
39
+ declare function CopyButton({ align, feedback, feedbackTimeout, iconDescription, className, onClick, ...other }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
40
+ declare namespace CopyButton {
41
+ var propTypes: {
42
+ /**
43
+ * Specify how the trigger should align with the tooltip
44
+ */
45
+ align: PropTypes.Requireable<string>;
46
+ /**
47
+ * Specify an optional className to be applied to the underlying `<button>`
48
+ */
49
+ className: PropTypes.Requireable<string>;
50
+ /**
51
+ * Specify the string that is displayed when the button is clicked and the
52
+ * content is copied
53
+ */
54
+ feedback: PropTypes.Requireable<string>;
55
+ /**
56
+ * Specify the time it takes for the feedback message to timeout
57
+ */
58
+ feedbackTimeout: PropTypes.Requireable<number>;
59
+ /**
60
+ * Provide a description for the icon representing the copy action that can
61
+ * be read by screen readers
62
+ */
63
+ iconDescription: PropTypes.Requireable<string>;
64
+ /**
65
+ * Specify an optional `onClick` handler that is called when the underlying
66
+ * `<button>` is clicked
67
+ */
68
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
69
+ };
70
+ }
71
+ export default CopyButton;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import CopyButton from './CopyButton';
8
+ export default CopyButton;
9
+ export { CopyButton };
@@ -8,6 +8,17 @@ import React from 'react';
8
8
  import { ListBoxSize } from '../ListBox';
9
9
  import { ReactAttr } from '../../types/common';
10
10
  export interface DropdownSkeletonProps extends ReactAttr<HTMLDivElement> {
11
+ /**
12
+ * Specify an optional className to add.
13
+ */
14
+ className?: string;
15
+ /**
16
+ * Specify whether the label should be hidden, or not
17
+ */
18
+ hideLabel?: boolean;
19
+ /**
20
+ * Specify the size of the ListBox.
21
+ */
11
22
  size?: ListBoxSize;
12
23
  }
13
24
  declare const DropdownSkeleton: React.FC<DropdownSkeletonProps>;
@@ -17,25 +17,30 @@ const DropdownSkeleton = _ref => {
17
17
  let {
18
18
  className,
19
19
  size,
20
+ hideLabel,
20
21
  ...rest
21
22
  } = _ref;
22
23
  const prefix = usePrefix();
23
- const wrapperClasses = cx(className, `${prefix}--skeleton`, `${prefix}--dropdown-v2`, `${prefix}--list-box`, `${prefix}--form-item`, {
24
+ const wrapperClasses = cx(className, `${prefix}--skeleton`, `${prefix}--form-item`, {
24
25
  [`${prefix}--list-box--${size}`]: size
25
26
  });
26
27
  return /*#__PURE__*/React__default.createElement("div", _extends({
27
28
  className: wrapperClasses
28
- }, rest), /*#__PURE__*/React__default.createElement("div", {
29
- className: `${prefix}--list-box__field`
30
- }, /*#__PURE__*/React__default.createElement("span", {
31
- className: `${prefix}--list-box__label`
32
- })));
29
+ }, rest), !hideLabel && /*#__PURE__*/React__default.createElement("span", {
30
+ className: `${prefix}--label ${prefix}--skeleton`
31
+ }), /*#__PURE__*/React__default.createElement("div", {
32
+ className: `${prefix}--skeleton ${prefix}--dropdown`
33
+ }));
33
34
  };
34
35
  DropdownSkeleton.propTypes = {
35
36
  /**
36
37
  * Specify an optional className to add.
37
38
  */
38
39
  className: PropTypes.string,
40
+ /**
41
+ * Specify whether the label should be hidden, or not
42
+ */
43
+ hideLabel: PropTypes.bool,
39
44
  /**
40
45
  * Specify the size of the ListBox.
41
46
  */
@@ -53,7 +53,7 @@ export interface FileUploaderItemProps extends ReactAttr<HTMLSpanElement> {
53
53
  */
54
54
  uuid?: string;
55
55
  }
56
- declare function FileUploaderItem({ uuid, name, status, iconDescription, onDelete, invalid, errorSubject, errorBody, size, ...other }: FileUploaderItemProps): import("react/jsx-runtime").JSX.Element;
56
+ declare function FileUploaderItem({ uuid, name, status, iconDescription, onDelete, invalid, errorSubject, errorBody, size, className, ...other }: FileUploaderItemProps): import("react/jsx-runtime").JSX.Element;
57
57
  declare namespace FileUploaderItem {
58
58
  var propTypes: {
59
59
  /**
@@ -31,6 +31,7 @@ function FileUploaderItem(_ref) {
31
31
  errorSubject,
32
32
  errorBody,
33
33
  size,
34
+ className,
34
35
  ...other
35
36
  } = _ref;
36
37
  const [isEllipsisApplied, setIsEllipsisApplied] = useState(false);
@@ -38,7 +39,7 @@ function FileUploaderItem(_ref) {
38
39
  const {
39
40
  current: id
40
41
  } = useRef(uuid || uniqueId());
41
- const classes = cx(`${prefix}--file__selected-file`, {
42
+ const classes = cx(`${prefix}--file__selected-file`, className, {
42
43
  [`${prefix}--file__selected-file--invalid`]: invalid,
43
44
  [`${prefix}--file__selected-file--md`]: size === 'md',
44
45
  [`${prefix}--file__selected-file--sm`]: size === 'sm'
@@ -549,7 +549,7 @@ export interface StaticNotificationProps extends HTMLAttributes<HTMLDivElement>
549
549
  /**
550
550
  * Specify the subtitle
551
551
  */
552
- subtitle?: string;
552
+ subtitle?: ReactNode;
553
553
  /**
554
554
  * Specify the title
555
555
  */
@@ -593,7 +593,7 @@ export declare namespace StaticNotification {
593
593
  /**
594
594
  * Specify the subtitle
595
595
  */
596
- subtitle: PropTypes.Requireable<string>;
596
+ subtitle: PropTypes.Requireable<PropTypes.ReactNodeLike>;
597
597
  /**
598
598
  * Specify the title
599
599
  */
@@ -729,6 +729,7 @@ function StaticNotification(_ref8) {
729
729
  className: `${prefix}--actionable-notification__button-wrapper`
730
730
  }, actionButtonLabel && /*#__PURE__*/React__default.createElement(NotificationActionButton, {
731
731
  onClick: onActionButtonClick,
732
+ "aria-describedby": titleId,
732
733
  inline: true
733
734
  }, actionButtonLabel)));
734
735
  }
@@ -764,7 +765,7 @@ StaticNotification.propTypes = {
764
765
  /**
765
766
  * Specify the subtitle
766
767
  */
767
- subtitle: PropTypes.string,
768
+ subtitle: PropTypes.node,
768
769
  /**
769
770
  * Specify the title
770
771
  */
@@ -118,6 +118,9 @@ class OverflowMenu extends Component {
118
118
  const {
119
119
  onClick = noopFn
120
120
  } = this.props;
121
+ this.setState({
122
+ click: true
123
+ });
121
124
  evt.stopPropagation();
122
125
  if (!this._menuBody || !this._menuBody.contains(evt.target)) {
123
126
  this.setState({
@@ -127,6 +130,15 @@ class OverflowMenu extends Component {
127
130
  }
128
131
  });
129
132
  _defineProperty(this, "closeMenuAndFocus", () => {
133
+ let wasClicked = this.state.click;
134
+ let wasOpen = this.state.open;
135
+ this.closeMenu(() => {
136
+ if (wasOpen && !wasClicked) {
137
+ this.focusMenuEl();
138
+ }
139
+ });
140
+ });
141
+ _defineProperty(this, "closeMenuOnEscape", () => {
130
142
  let wasOpen = this.state.open;
131
143
  this.closeMenu(() => {
132
144
  if (wasOpen) {
@@ -141,7 +153,7 @@ class OverflowMenu extends Component {
141
153
 
142
154
  // Close the overflow menu on escape
143
155
  if (matches(evt, [Escape])) {
144
- this.closeMenuAndFocus();
156
+ this.closeMenuOnEscape();
145
157
 
146
158
  // Stop the esc keypress from bubbling out and closing something it shouldn't
147
159
  evt.stopPropagation();
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import { CheckmarkFilled } from '@carbon/icons-react';
9
+ import { RadioButtonChecked, RadioButton, CheckmarkFilled } from '@carbon/icons-react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
12
  import React__default from 'react';
@@ -15,11 +15,12 @@ import { usePrefix } from '../../internal/usePrefix.js';
15
15
  import deprecate from '../../prop-types/deprecate.js';
16
16
  import { noopFn } from '../../internal/noopFn.js';
17
17
  import '../Text/index.js';
18
+ import { useFeatureFlag } from '../FeatureFlags/index.js';
18
19
  import { Text } from '../Text/Text.js';
19
20
  import { matches } from '../../internal/keyboard/match.js';
20
21
  import { Enter, Space } from '../../internal/keyboard/keys.js';
21
22
 
22
- var _CheckmarkFilled;
23
+ var _RadioButtonChecked, _RadioButton, _CheckmarkFilled;
23
24
  const RadioTile = /*#__PURE__*/React__default.forwardRef(function RadioTile(_ref, ref) {
24
25
  let {
25
26
  children,
@@ -42,6 +43,18 @@ const RadioTile = /*#__PURE__*/React__default.forwardRef(function RadioTile(_ref
42
43
  [`${prefix}--tile--light`]: light,
43
44
  [`${prefix}--tile--disabled`]: disabled
44
45
  });
46
+ const v12TileRadioIcons = useFeatureFlag('enable-v12-tile-radio-icons');
47
+ function icon() {
48
+ if (v12TileRadioIcons) {
49
+ if (checked) {
50
+ return _RadioButtonChecked || (_RadioButtonChecked = /*#__PURE__*/React__default.createElement(RadioButtonChecked, null));
51
+ } else {
52
+ return _RadioButton || (_RadioButton = /*#__PURE__*/React__default.createElement(RadioButton, null));
53
+ }
54
+ } else {
55
+ return _CheckmarkFilled || (_CheckmarkFilled = /*#__PURE__*/React__default.createElement(CheckmarkFilled, null));
56
+ }
57
+ }
45
58
  function handleOnChange(evt) {
46
59
  onChange(value, name, evt);
47
60
  }
@@ -68,7 +81,7 @@ const RadioTile = /*#__PURE__*/React__default.forwardRef(function RadioTile(_ref
68
81
  className: className
69
82
  }), /*#__PURE__*/React__default.createElement("span", {
70
83
  className: `${prefix}--tile__checkmark`
71
- }, _CheckmarkFilled || (_CheckmarkFilled = /*#__PURE__*/React__default.createElement(CheckmarkFilled, null))), /*#__PURE__*/React__default.createElement(Text, {
84
+ }, icon()), /*#__PURE__*/React__default.createElement(Text, {
72
85
  className: `${prefix}--tile-content`
73
86
  }, children)));
74
87
  });
@@ -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
+ import PropTypes, { ReactNodeLike } from 'prop-types';
8
+ import React from 'react';
9
+ import { PolymorphicProps } from '../../types/common';
10
+ import { SIZES, TYPES } from './Tag';
11
+ export interface DismissibleTagBaseProps {
12
+ /**
13
+ * Provide content to be rendered inside of a `DismissibleTag`
14
+ */
15
+ children?: React.ReactNode;
16
+ /**
17
+ * Provide a custom className that is applied to the containing <span>
18
+ */
19
+ className?: string;
20
+ /**
21
+ * Specify if the `DismissibleTag` is disabled
22
+ */
23
+ disabled?: boolean;
24
+ /**
25
+ * Specify the id for the selectabletag.
26
+ */
27
+ id?: string;
28
+ /**
29
+ * Click handler for filter tag close button.
30
+ */
31
+ onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
32
+ /**
33
+ * Optional prop to render a custom icon.
34
+ * Can be a React component class
35
+ */
36
+ renderIcon?: React.ElementType;
37
+ /**
38
+ * Specify the size of the Tag. Currently supports either `sm`,
39
+ * `md` (default) or `lg` sizes.
40
+ */
41
+ size?: keyof typeof SIZES;
42
+ /**
43
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
44
+ */
45
+ slug?: ReactNodeLike;
46
+ /**
47
+ * Text to show on clear filters
48
+ */
49
+ title?: string;
50
+ /**
51
+ * Specify the type of the `Tag`
52
+ */
53
+ type?: keyof typeof TYPES;
54
+ }
55
+ export type DismissibleTagProps<T extends React.ElementType> = PolymorphicProps<T, DismissibleTagBaseProps>;
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;
58
+ propTypes: {
59
+ /**
60
+ * Provide content to be rendered inside of a `DismissibleTag`
61
+ */
62
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
63
+ /**
64
+ * Provide a custom className that is applied to the containing <span>
65
+ */
66
+ className: PropTypes.Requireable<string>;
67
+ /**
68
+ * Specify if the `DismissibleTag` is disabled
69
+ */
70
+ disabled: PropTypes.Requireable<boolean>;
71
+ /**
72
+ * Specify the id for the tag.
73
+ */
74
+ id: PropTypes.Requireable<string>;
75
+ /**
76
+ * Click handler for filter tag close button.
77
+ */
78
+ onClose: PropTypes.Requireable<(...args: any[]) => any>;
79
+ /**
80
+ * Optional prop to render a custom icon.
81
+ * Can be a React component class
82
+ */
83
+ renderIcon: PropTypes.Requireable<object>;
84
+ /**
85
+ * Specify the size of the Tag. Currently supports either `sm`,
86
+ * `md` (default) or `lg` sizes.
87
+ */
88
+ size: PropTypes.Requireable<string>;
89
+ /**
90
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
91
+ */
92
+ slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
93
+ /**
94
+ * Text to show on clear filters
95
+ */
96
+ title: PropTypes.Requireable<string>;
97
+ /**
98
+ * Specify the type of the `Tag`
99
+ */
100
+ type: PropTypes.Requireable<string>;
101
+ };
102
+ };
103
+ export declare const types: string[];
104
+ export default DismissibleTag;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import PropTypes, { ReactNodeLike } from 'prop-types';
8
+ import React, { MouseEventHandler } from 'react';
9
+ import { PolymorphicProps } from '../../types/common';
10
+ import { SIZES } from './Tag';
11
+ declare const TYPES: {
12
+ red: string;
13
+ magenta: string;
14
+ purple: string;
15
+ blue: string;
16
+ cyan: string;
17
+ teal: string;
18
+ green: string;
19
+ gray: string;
20
+ 'cool-gray': string;
21
+ 'warm-gray': string;
22
+ };
23
+ export interface OperationalTagBaseProps {
24
+ /**
25
+ * Provide content to be rendered inside of a `OperationalTag`
26
+ */
27
+ children?: React.ReactNode;
28
+ /**
29
+ * Provide a custom className that is applied to the containing <span>
30
+ */
31
+ className?: string;
32
+ /**
33
+ * Specify if the `OperationalTag` is disabled
34
+ */
35
+ disabled?: boolean;
36
+ /**
37
+ * Specify the id for the OperationalTag.
38
+ */
39
+ id?: string;
40
+ /**
41
+ * Optional prop to render a custom icon.
42
+ * Can be a React component class
43
+ */
44
+ renderIcon?: React.ElementType;
45
+ onClick?: MouseEventHandler;
46
+ /**
47
+ * Specify the size of the Tag. Currently supports either `sm`,
48
+ * `md` (default) or `lg` sizes.
49
+ */
50
+ size?: keyof typeof SIZES;
51
+ /**
52
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
53
+ */
54
+ slug?: ReactNodeLike;
55
+ /**
56
+ * Specify the type of the `Tag`
57
+ */
58
+ type?: keyof typeof TYPES;
59
+ }
60
+ export type OperationalTagProps<T extends React.ElementType> = PolymorphicProps<T, OperationalTagBaseProps>;
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;
63
+ propTypes: {
64
+ /**
65
+ * Provide content to be rendered inside of a `OperationalTag`
66
+ */
67
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
68
+ /**
69
+ * Provide a custom className that is applied to the containing <span>
70
+ */
71
+ className: PropTypes.Requireable<string>;
72
+ /**
73
+ * Specify if the `OperationalTag` is disabled
74
+ */
75
+ disabled: PropTypes.Requireable<boolean>;
76
+ /**
77
+ * Specify the id for the tag.
78
+ */
79
+ id: PropTypes.Requireable<string>;
80
+ /**
81
+ * Optional prop to render a custom icon.
82
+ * Can be a React component class
83
+ */
84
+ renderIcon: PropTypes.Requireable<object>;
85
+ /**
86
+ * Specify the size of the Tag. Currently supports either `sm`,
87
+ * `md` (default) or `lg` sizes.
88
+ */
89
+ size: PropTypes.Requireable<string>;
90
+ /**
91
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
92
+ */
93
+ slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
94
+ /**
95
+ * Specify the type of the `Tag`
96
+ */
97
+ type: PropTypes.Requireable<string>;
98
+ };
99
+ };
100
+ export declare const types: string[];
101
+ export default OperationalTag;