@carbon/react 1.45.0-rc.0 → 1.45.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 (38) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +828 -910
  2. package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
  3. package/es/components/ComboBox/ComboBox.js +1 -1
  4. package/es/components/ContentSwitcher/ContentSwitcher.js +1 -1
  5. package/es/components/DatePickerInput/DatePickerInput.js +1 -1
  6. package/es/components/Dropdown/Dropdown.js +1 -1
  7. package/es/components/MultiSelect/FilterableMultiSelect.js +1 -1
  8. package/es/components/MultiSelect/MultiSelect.js +4 -1
  9. package/es/components/NumberInput/NumberInput.js +2 -2
  10. package/es/components/ProgressIndicator/ProgressIndicator.js +4 -0
  11. package/es/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  12. package/es/components/Select/Select.js +1 -1
  13. package/es/components/Slug/index.js +1 -0
  14. package/es/components/Tag/Tag.d.ts +18 -10
  15. package/es/components/Tag/Tag.js +23 -7
  16. package/es/components/TextArea/TextArea.js +1 -1
  17. package/es/components/TextInput/TextInput.js +1 -1
  18. package/es/components/Tile/Tile.js +2 -2
  19. package/es/components/UIShell/Switcher.js +1 -1
  20. package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
  21. package/lib/components/ComboBox/ComboBox.js +1 -1
  22. package/lib/components/ContentSwitcher/ContentSwitcher.js +1 -1
  23. package/lib/components/DatePickerInput/DatePickerInput.js +1 -1
  24. package/lib/components/Dropdown/Dropdown.js +1 -1
  25. package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -1
  26. package/lib/components/MultiSelect/MultiSelect.js +4 -1
  27. package/lib/components/NumberInput/NumberInput.js +2 -2
  28. package/lib/components/ProgressIndicator/ProgressIndicator.js +4 -0
  29. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  30. package/lib/components/Select/Select.js +1 -1
  31. package/lib/components/Slug/index.js +1 -0
  32. package/lib/components/Tag/Tag.d.ts +18 -10
  33. package/lib/components/Tag/Tag.js +23 -7
  34. package/lib/components/TextArea/TextArea.js +1 -1
  35. package/lib/components/TextInput/TextInput.js +1 -1
  36. package/lib/components/Tile/Tile.js +2 -2
  37. package/lib/components/UIShell/Switcher.js +1 -1
  38. package/package.json +4 -4
@@ -47,7 +47,7 @@ function CheckboxGroup(_ref) {
47
47
 
48
48
  // Slug is always size `mini`
49
49
  let normalizedSlug;
50
- if (slug) {
50
+ if (slug && slug['type']?.displayName === 'Slug') {
51
51
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
52
52
  size: 'mini',
53
53
  kind: 'default'
@@ -257,7 +257,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
257
257
 
258
258
  // Slug is always size `mini`
259
259
  let normalizedSlug;
260
- if (slug) {
260
+ if (slug && slug['type']?.displayName === 'Slug') {
261
261
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
262
262
  size: 'mini'
263
263
  });
@@ -130,7 +130,7 @@ class ContentSwitcher extends React__default.Component {
130
130
  className: classes,
131
131
  role: "tablist",
132
132
  onChange: undefined
133
- }), children && React__default.Children.map(children, (child, index) => /*#__PURE__*/React__default.cloneElement(child, {
133
+ }), children && React__default.Children.toArray(children).map((child, index) => /*#__PURE__*/React__default.cloneElement(child, {
134
134
  index,
135
135
  onClick: composeEventHandlers([this.handleChildChange, child.props.onClick]),
136
136
  onKeyDown: this.handleChildChange,
@@ -98,7 +98,7 @@ const DatePickerInput = /*#__PURE__*/React__default.forwardRef(function DatePick
98
98
 
99
99
  // Slug is always size `mini`
100
100
  let normalizedSlug;
101
- if (slug) {
101
+ if (slug && slug['type']?.displayName === 'Slug') {
102
102
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
103
103
  size: 'mini'
104
104
  });
@@ -228,7 +228,7 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
228
228
 
229
229
  // Slug is always size `mini`
230
230
  let normalizedSlug;
231
- if (slug) {
231
+ if (slug && slug['type']?.displayName === 'Slug') {
232
232
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
233
233
  size: 'mini'
234
234
  });
@@ -193,7 +193,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
193
193
 
194
194
  // Slug is always size `mini`
195
195
  let normalizedSlug;
196
- if (slug) {
196
+ if (slug && slug['type']?.displayName === 'Slug') {
197
197
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
198
198
  size: 'mini'
199
199
  });
@@ -237,6 +237,9 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
237
237
  if (changes.selectedItem === undefined) {
238
238
  break;
239
239
  }
240
+ if (Array.isArray(changes.selectedItem)) {
241
+ break;
242
+ }
240
243
  onItemChange(changes.selectedItem);
241
244
  return {
242
245
  ...changes,
@@ -298,7 +301,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
298
301
 
299
302
  // Slug is always size `mini`
300
303
  let normalizedSlug;
301
- if (slug) {
304
+ if (slug && slug['type']?.displayName === 'Slug') {
302
305
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
303
306
  size: 'mini'
304
307
  });
@@ -172,7 +172,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
172
172
 
173
173
  // Slug is always size `mini`
174
174
  let normalizedSlug;
175
- if (slug) {
175
+ if (slug && slug['type']?.displayName === 'Slug') {
176
176
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
177
177
  size: 'mini'
178
178
  });
@@ -180,7 +180,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
180
180
 
181
181
  // Need to update the internal value when the revert button is clicked
182
182
  let isRevertActive;
183
- if (slug) {
183
+ if (slug && slug['type']?.displayName === 'Slug') {
184
184
  isRevertActive = normalizedSlug.props.revertActive;
185
185
  }
186
186
  useEffect(() => {
@@ -51,6 +51,10 @@ function ProgressIndicator(_ref) {
51
51
  return /*#__PURE__*/React__default.createElement("ul", _extends({
52
52
  className: className
53
53
  }, rest), React__default.Children.map(children, (child, index) => {
54
+ if (! /*#__PURE__*/React__default.isValidElement(child)) {
55
+ return null;
56
+ }
57
+
54
58
  // only setup click handlers if onChange event is passed
55
59
  const onClick = onChange ? () => onChange(index) : undefined;
56
60
  if (index === currentIndex) {
@@ -104,7 +104,7 @@ const RadioButtonGroup = /*#__PURE__*/React__default.forwardRef((props, ref) =>
104
104
 
105
105
  // Slug is always size `mini`
106
106
  let normalizedSlug;
107
- if (slug) {
107
+ if (slug && slug['type']?.displayName === 'Slug') {
108
108
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
109
109
  size: 'mini',
110
110
  kind: 'default'
@@ -128,7 +128,7 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
128
128
 
129
129
  // Slug is always size `mini`
130
130
  let normalizedSlug;
131
- if (slug) {
131
+ if (slug && slug['type']?.displayName === 'Slug') {
132
132
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
133
133
  size: 'mini'
134
134
  });
@@ -125,6 +125,7 @@ const Slug = /*#__PURE__*/React__default.forwardRef(function Slug(_ref3, ref) {
125
125
  className: `${prefix}--slug__additional-text`
126
126
  }, aiTextLabel)), children));
127
127
  });
128
+ Slug.displayName = 'Slug';
128
129
  Slug.propTypes = {
129
130
  /**
130
131
  * Specify the correct translation of the AI text
@@ -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 PropTypes from 'prop-types';
7
+ import PropTypes, { ReactNodeLike } from 'prop-types';
8
8
  import React from 'react';
9
9
  import { PolymorphicProps } from '../../types/common';
10
10
  declare const TYPES: {
@@ -23,7 +23,7 @@ declare const TYPES: {
23
23
  };
24
24
  export interface TagBaseProps {
25
25
  /**
26
- * Provide content to be rendered inside of a <Tag>
26
+ * Provide content to be rendered inside of a `Tag`
27
27
  */
28
28
  children?: React.ReactNode;
29
29
  /**
@@ -31,11 +31,11 @@ export interface TagBaseProps {
31
31
  */
32
32
  className?: string;
33
33
  /**
34
- * Specify if the <Tag> is disabled
34
+ * Specify if the `Tag` is disabled
35
35
  */
36
36
  disabled?: boolean;
37
37
  /**
38
- * Determine if <Tag> is a filter/chip
38
+ * Determine if `Tag` is a filter/chip
39
39
  */
40
40
  filter?: boolean;
41
41
  /**
@@ -56,18 +56,22 @@ export interface TagBaseProps {
56
56
  * 'md' (default) sizes.
57
57
  */
58
58
  size?: 'sm' | 'md';
59
+ /**
60
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
61
+ */
62
+ slug?: ReactNodeLike;
59
63
  /**
60
64
  * Text to show on clear filters
61
65
  */
62
66
  title?: string;
63
67
  /**
64
- * Specify the type of the <Tag>
68
+ * Specify the type of the `Tag`
65
69
  */
66
70
  type?: keyof typeof TYPES;
67
71
  }
68
72
  export type TagProps<T extends React.ElementType> = PolymorphicProps<T, TagBaseProps>;
69
73
  declare const Tag: {
70
- <T extends React.ElementType<any>>({ children, className, id, type, filter, renderIcon: CustomIconElement, title, disabled, onClose, size, as: BaseComponent, ...other }: TagProps<T>): JSX.Element;
74
+ <T extends React.ElementType<any>>({ children, className, id, type, filter, renderIcon: CustomIconElement, title, disabled, onClose, size, as: BaseComponent, slug, ...other }: TagProps<T>): JSX.Element;
71
75
  propTypes: {
72
76
  /**
73
77
  * Provide an alternative tag or component to use instead of the default
@@ -75,7 +79,7 @@ declare const Tag: {
75
79
  */
76
80
  as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
77
81
  /**
78
- * Provide content to be rendered inside of a <Tag>
82
+ * Provide content to be rendered inside of a `Tag`
79
83
  */
80
84
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
81
85
  /**
@@ -83,11 +87,11 @@ declare const Tag: {
83
87
  */
84
88
  className: PropTypes.Requireable<string>;
85
89
  /**
86
- * Specify if the <Tag> is disabled
90
+ * Specify if the `Tag` is disabled
87
91
  */
88
92
  disabled: PropTypes.Requireable<boolean>;
89
93
  /**
90
- * Determine if <Tag> is a filter/chip
94
+ * Determine if `Tag` is a filter/chip
91
95
  */
92
96
  filter: PropTypes.Requireable<boolean>;
93
97
  /**
@@ -108,12 +112,16 @@ declare const Tag: {
108
112
  * 'md' (default) sizes.
109
113
  */
110
114
  size: PropTypes.Requireable<string>;
115
+ /**
116
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
117
+ */
118
+ slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
111
119
  /**
112
120
  * Text to show on clear filters
113
121
  */
114
122
  title: PropTypes.Requireable<string>;
115
123
  /**
116
- * Specify the type of the <Tag>
124
+ * Specify the type of the `Tag`
117
125
  */
118
126
  type: PropTypes.Requireable<string>;
119
127
  };
@@ -44,6 +44,7 @@ const Tag = _ref => {
44
44
  onClose,
45
45
  size,
46
46
  as: BaseComponent,
47
+ slug,
47
48
  ...other
48
49
  } = _ref;
49
50
  const prefix = usePrefix();
@@ -64,15 +65,26 @@ const Tag = _ref => {
64
65
  onClose(event);
65
66
  }
66
67
  };
68
+
69
+ // Slug is always size `md` and `inline`
70
+ let normalizedSlug;
71
+ if (slug && slug['type']?.displayName === 'Slug') {
72
+ normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
73
+ size: 'sm',
74
+ kind: 'inline'
75
+ });
76
+ }
67
77
  if (filter) {
68
78
  const ComponentTag = BaseComponent ?? 'div';
69
79
  return /*#__PURE__*/React__default.createElement(ComponentTag, _extends({
70
80
  className: tagClasses,
71
81
  id: tagId
72
- }, other), /*#__PURE__*/React__default.createElement(Text, {
82
+ }, other), CustomIconElement ? /*#__PURE__*/React__default.createElement("div", {
83
+ className: `${prefix}--tag__custom-icon`
84
+ }, /*#__PURE__*/React__default.createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default.createElement(Text, {
73
85
  className: `${prefix}--tag__label`,
74
86
  title: typeof children === 'string' ? children : undefined
75
- }, children !== null && children !== undefined ? children : typeText), /*#__PURE__*/React__default.createElement("button", {
87
+ }, children !== null && children !== undefined ? children : typeText), normalizedSlug, /*#__PURE__*/React__default.createElement("button", {
76
88
  type: "button",
77
89
  className: `${prefix}--tag__close-icon`,
78
90
  onClick: handleClose,
@@ -90,7 +102,7 @@ const Tag = _ref => {
90
102
  className: `${prefix}--tag__custom-icon`
91
103
  }, /*#__PURE__*/React__default.createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default.createElement(Text, {
92
104
  title: typeof children === 'string' ? children : undefined
93
- }, children !== null && children !== undefined ? children : typeText));
105
+ }, children !== null && children !== undefined ? children : typeText), normalizedSlug);
94
106
  };
95
107
  Tag.propTypes = {
96
108
  /**
@@ -99,7 +111,7 @@ Tag.propTypes = {
99
111
  */
100
112
  as: PropTypes.elementType,
101
113
  /**
102
- * Provide content to be rendered inside of a <Tag>
114
+ * Provide content to be rendered inside of a `Tag`
103
115
  */
104
116
  children: PropTypes.node,
105
117
  /**
@@ -107,11 +119,11 @@ Tag.propTypes = {
107
119
  */
108
120
  className: PropTypes.string,
109
121
  /**
110
- * Specify if the <Tag> is disabled
122
+ * Specify if the `Tag` is disabled
111
123
  */
112
124
  disabled: PropTypes.bool,
113
125
  /**
114
- * Determine if <Tag> is a filter/chip
126
+ * Determine if `Tag` is a filter/chip
115
127
  */
116
128
  filter: PropTypes.bool,
117
129
  /**
@@ -132,12 +144,16 @@ Tag.propTypes = {
132
144
  * 'md' (default) sizes.
133
145
  */
134
146
  size: PropTypes.oneOf(['sm', 'md']),
147
+ /**
148
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
149
+ */
150
+ slug: PropTypes.node,
135
151
  /**
136
152
  * Text to show on clear filters
137
153
  */
138
154
  title: PropTypes.string,
139
155
  /**
140
- * Specify the type of the <Tag>
156
+ * Specify the type of the `Tag`
141
157
  */
142
158
  type: PropTypes.oneOf(Object.keys(TYPES))
143
159
  };
@@ -226,7 +226,7 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
226
226
 
227
227
  // Slug is always size `mini`
228
228
  let normalizedSlug;
229
- if (slug) {
229
+ if (slug && slug['type']?.displayName === 'Slug') {
230
230
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
231
231
  size: 'mini'
232
232
  });
@@ -157,7 +157,7 @@ const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref
157
157
 
158
158
  // Slug is always size `mini`
159
159
  let normalizedSlug;
160
- if (slug) {
160
+ if (slug && slug['type']?.displayName === 'Slug') {
161
161
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
162
162
  size: 'mini'
163
163
  });
@@ -269,7 +269,7 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
269
269
  // Slug is always size `xs`
270
270
  const slugRef = useRef(null);
271
271
  let normalizedSlug;
272
- if (slug) {
272
+ if (slug && slug['type']?.displayName === 'Slug') {
273
273
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
274
274
  size: 'xs',
275
275
  ref: slugRef
@@ -494,7 +494,7 @@ const ExpandableTile = /*#__PURE__*/React__default.forwardRef(function Expandabl
494
494
 
495
495
  // Slug is always size `xs`
496
496
  let normalizedSlug;
497
- if (slug) {
497
+ if (slug && slug['type']?.displayName === 'Slug') {
498
498
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
499
499
  size: 'xs'
500
500
  });
@@ -60,7 +60,7 @@ const Switcher = /*#__PURE__*/forwardRef(function Switcher(props, forwardRef) {
60
60
  switcherItem.focus();
61
61
  }
62
62
  };
63
- const childrenWithProps = React__default.Children.map(children, (child, index) => {
63
+ const childrenWithProps = React__default.Children.toArray(children).map((child, index) => {
64
64
  // only setup click handlers if onChange event is passed
65
65
  if ( /*#__PURE__*/React__default.isValidElement(child) && child.type && getDisplayName(child.type) === 'Switcher') {
66
66
  return /*#__PURE__*/React__default.cloneElement(child, {
@@ -57,7 +57,7 @@ function CheckboxGroup(_ref) {
57
57
 
58
58
  // Slug is always size `mini`
59
59
  let normalizedSlug;
60
- if (slug) {
60
+ if (slug && slug['type']?.displayName === 'Slug') {
61
61
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
62
62
  size: 'mini',
63
63
  kind: 'default'
@@ -268,7 +268,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
268
268
 
269
269
  // Slug is always size `mini`
270
270
  let normalizedSlug;
271
- if (slug) {
271
+ if (slug && slug['type']?.displayName === 'Slug') {
272
272
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
273
273
  size: 'mini'
274
274
  });
@@ -140,7 +140,7 @@ class ContentSwitcher extends React__default["default"].Component {
140
140
  className: classes,
141
141
  role: "tablist",
142
142
  onChange: undefined
143
- }), children && React__default["default"].Children.map(children, (child, index) => /*#__PURE__*/React__default["default"].cloneElement(child, {
143
+ }), children && React__default["default"].Children.toArray(children).map((child, index) => /*#__PURE__*/React__default["default"].cloneElement(child, {
144
144
  index,
145
145
  onClick: events.composeEventHandlers([this.handleChildChange, child.props.onClick]),
146
146
  onKeyDown: this.handleChildChange,
@@ -108,7 +108,7 @@ const DatePickerInput = /*#__PURE__*/React__default["default"].forwardRef(functi
108
108
 
109
109
  // Slug is always size `mini`
110
110
  let normalizedSlug;
111
- if (slug) {
111
+ if (slug && slug['type']?.displayName === 'Slug') {
112
112
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
113
113
  size: 'mini'
114
114
  });
@@ -238,7 +238,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
238
238
 
239
239
  // Slug is always size `mini`
240
240
  let normalizedSlug;
241
- if (slug) {
241
+ if (slug && slug['type']?.displayName === 'Slug') {
242
242
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
243
243
  size: 'mini'
244
244
  });
@@ -205,7 +205,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
205
205
 
206
206
  // Slug is always size `mini`
207
207
  let normalizedSlug;
208
- if (slug) {
208
+ if (slug && slug['type']?.displayName === 'Slug') {
209
209
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
210
210
  size: 'mini'
211
211
  });
@@ -248,6 +248,9 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
248
248
  if (changes.selectedItem === undefined) {
249
249
  break;
250
250
  }
251
+ if (Array.isArray(changes.selectedItem)) {
252
+ break;
253
+ }
251
254
  onItemChange(changes.selectedItem);
252
255
  return {
253
256
  ...changes,
@@ -309,7 +312,7 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
309
312
 
310
313
  // Slug is always size `mini`
311
314
  let normalizedSlug;
312
- if (slug) {
315
+ if (slug && slug['type']?.displayName === 'Slug') {
313
316
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
314
317
  size: 'mini'
315
318
  });
@@ -182,7 +182,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
182
182
 
183
183
  // Slug is always size `mini`
184
184
  let normalizedSlug;
185
- if (slug) {
185
+ if (slug && slug['type']?.displayName === 'Slug') {
186
186
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
187
187
  size: 'mini'
188
188
  });
@@ -190,7 +190,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
190
190
 
191
191
  // Need to update the internal value when the revert button is clicked
192
192
  let isRevertActive;
193
- if (slug) {
193
+ if (slug && slug['type']?.displayName === 'Slug') {
194
194
  isRevertActive = normalizedSlug.props.revertActive;
195
195
  }
196
196
  React.useEffect(() => {
@@ -61,6 +61,10 @@ function ProgressIndicator(_ref) {
61
61
  return /*#__PURE__*/React__default["default"].createElement("ul", _rollupPluginBabelHelpers["extends"]({
62
62
  className: className
63
63
  }, rest), React__default["default"].Children.map(children, (child, index) => {
64
+ if (! /*#__PURE__*/React__default["default"].isValidElement(child)) {
65
+ return null;
66
+ }
67
+
64
68
  // only setup click handlers if onChange event is passed
65
69
  const onClick = onChange ? () => onChange(index) : undefined;
66
70
  if (index === currentIndex) {
@@ -114,7 +114,7 @@ const RadioButtonGroup = /*#__PURE__*/React__default["default"].forwardRef((prop
114
114
 
115
115
  // Slug is always size `mini`
116
116
  let normalizedSlug;
117
- if (slug) {
117
+ if (slug && slug['type']?.displayName === 'Slug') {
118
118
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
119
119
  size: 'mini',
120
120
  kind: 'default'
@@ -138,7 +138,7 @@ const Select = /*#__PURE__*/React__default["default"].forwardRef(function Select
138
138
 
139
139
  // Slug is always size `mini`
140
140
  let normalizedSlug;
141
- if (slug) {
141
+ if (slug && slug['type']?.displayName === 'Slug') {
142
142
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
143
143
  size: 'mini'
144
144
  });
@@ -135,6 +135,7 @@ const Slug = /*#__PURE__*/React__default["default"].forwardRef(function Slug(_re
135
135
  className: `${prefix}--slug__additional-text`
136
136
  }, aiTextLabel)), children));
137
137
  });
138
+ Slug.displayName = 'Slug';
138
139
  Slug.propTypes = {
139
140
  /**
140
141
  * Specify the correct translation of the AI text
@@ -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 PropTypes from 'prop-types';
7
+ import PropTypes, { ReactNodeLike } from 'prop-types';
8
8
  import React from 'react';
9
9
  import { PolymorphicProps } from '../../types/common';
10
10
  declare const TYPES: {
@@ -23,7 +23,7 @@ declare const TYPES: {
23
23
  };
24
24
  export interface TagBaseProps {
25
25
  /**
26
- * Provide content to be rendered inside of a <Tag>
26
+ * Provide content to be rendered inside of a `Tag`
27
27
  */
28
28
  children?: React.ReactNode;
29
29
  /**
@@ -31,11 +31,11 @@ export interface TagBaseProps {
31
31
  */
32
32
  className?: string;
33
33
  /**
34
- * Specify if the <Tag> is disabled
34
+ * Specify if the `Tag` is disabled
35
35
  */
36
36
  disabled?: boolean;
37
37
  /**
38
- * Determine if <Tag> is a filter/chip
38
+ * Determine if `Tag` is a filter/chip
39
39
  */
40
40
  filter?: boolean;
41
41
  /**
@@ -56,18 +56,22 @@ export interface TagBaseProps {
56
56
  * 'md' (default) sizes.
57
57
  */
58
58
  size?: 'sm' | 'md';
59
+ /**
60
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
61
+ */
62
+ slug?: ReactNodeLike;
59
63
  /**
60
64
  * Text to show on clear filters
61
65
  */
62
66
  title?: string;
63
67
  /**
64
- * Specify the type of the <Tag>
68
+ * Specify the type of the `Tag`
65
69
  */
66
70
  type?: keyof typeof TYPES;
67
71
  }
68
72
  export type TagProps<T extends React.ElementType> = PolymorphicProps<T, TagBaseProps>;
69
73
  declare const Tag: {
70
- <T extends React.ElementType<any>>({ children, className, id, type, filter, renderIcon: CustomIconElement, title, disabled, onClose, size, as: BaseComponent, ...other }: TagProps<T>): JSX.Element;
74
+ <T extends React.ElementType<any>>({ children, className, id, type, filter, renderIcon: CustomIconElement, title, disabled, onClose, size, as: BaseComponent, slug, ...other }: TagProps<T>): JSX.Element;
71
75
  propTypes: {
72
76
  /**
73
77
  * Provide an alternative tag or component to use instead of the default
@@ -75,7 +79,7 @@ declare const Tag: {
75
79
  */
76
80
  as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
77
81
  /**
78
- * Provide content to be rendered inside of a <Tag>
82
+ * Provide content to be rendered inside of a `Tag`
79
83
  */
80
84
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
81
85
  /**
@@ -83,11 +87,11 @@ declare const Tag: {
83
87
  */
84
88
  className: PropTypes.Requireable<string>;
85
89
  /**
86
- * Specify if the <Tag> is disabled
90
+ * Specify if the `Tag` is disabled
87
91
  */
88
92
  disabled: PropTypes.Requireable<boolean>;
89
93
  /**
90
- * Determine if <Tag> is a filter/chip
94
+ * Determine if `Tag` is a filter/chip
91
95
  */
92
96
  filter: PropTypes.Requireable<boolean>;
93
97
  /**
@@ -108,12 +112,16 @@ declare const Tag: {
108
112
  * 'md' (default) sizes.
109
113
  */
110
114
  size: PropTypes.Requireable<string>;
115
+ /**
116
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
117
+ */
118
+ slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
111
119
  /**
112
120
  * Text to show on clear filters
113
121
  */
114
122
  title: PropTypes.Requireable<string>;
115
123
  /**
116
- * Specify the type of the <Tag>
124
+ * Specify the type of the `Tag`
117
125
  */
118
126
  type: PropTypes.Requireable<string>;
119
127
  };