@carbon/react 1.71.0-rc.0 → 1.71.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.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +910 -885
- package/es/components/Checkbox/Checkbox.d.ts +5 -0
- package/es/components/Checkbox/Checkbox.js +16 -7
- package/es/components/CheckboxGroup/CheckboxGroup.d.ts +5 -0
- package/es/components/CheckboxGroup/CheckboxGroup.js +16 -7
- package/es/components/ComboBox/ComboBox.d.ts +1 -1
- package/es/components/ComposedModal/ComposedModal.d.ts +5 -0
- package/es/components/ComposedModal/ComposedModal.js +16 -10
- package/es/components/FluidNumberInput/FluidNumberInput.d.ts +4 -0
- package/es/components/FluidSelect/FluidSelect.d.ts +4 -0
- package/es/components/FluidSelect/FluidSelect.js +5 -1
- package/es/components/FluidTextArea/FluidTextArea.d.ts +4 -0
- package/es/components/FluidTextArea/FluidTextArea.js +5 -1
- package/es/components/FluidTextInput/FluidPasswordInput.d.ts +4 -0
- package/es/components/FluidTextInput/FluidPasswordInput.js +5 -1
- package/es/components/FluidTextInput/FluidTextInput.d.ts +4 -0
- package/es/components/FluidTextInput/FluidTextInput.js +5 -1
- package/es/components/FluidTimePicker/FluidTimePicker.d.ts +4 -0
- package/es/components/FluidTimePicker/FluidTimePicker.js +23 -7
- package/es/components/Modal/Modal.d.ts +5 -0
- package/es/components/Modal/Modal.js +16 -10
- package/es/components/PaginationNav/PaginationNav.js +15 -3
- package/es/components/RadioButton/RadioButton.d.ts +5 -0
- package/es/components/RadioButton/RadioButton.js +16 -7
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +5 -0
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +16 -7
- package/es/components/RadioTile/RadioTile.d.ts +5 -0
- package/es/components/RadioTile/RadioTile.js +17 -8
- package/es/components/Tag/DismissibleTag.d.ts +11 -2
- package/es/components/Tag/DismissibleTag.js +13 -5
- package/es/components/Tag/Tag.d.ts +5 -0
- package/es/components/Tag/Tag.js +14 -7
- package/es/components/Tile/Tile.d.ts +21 -1
- package/es/components/Tile/Tile.js +68 -48
- package/lib/components/Checkbox/Checkbox.d.ts +5 -0
- package/lib/components/Checkbox/Checkbox.js +16 -7
- package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +5 -0
- package/lib/components/CheckboxGroup/CheckboxGroup.js +16 -7
- package/lib/components/ComboBox/ComboBox.d.ts +1 -1
- package/lib/components/ComposedModal/ComposedModal.d.ts +5 -0
- package/lib/components/ComposedModal/ComposedModal.js +16 -10
- package/lib/components/FluidNumberInput/FluidNumberInput.d.ts +4 -0
- package/lib/components/FluidSelect/FluidSelect.d.ts +4 -0
- package/lib/components/FluidSelect/FluidSelect.js +5 -1
- package/lib/components/FluidTextArea/FluidTextArea.d.ts +4 -0
- package/lib/components/FluidTextArea/FluidTextArea.js +5 -1
- package/lib/components/FluidTextInput/FluidPasswordInput.d.ts +4 -0
- package/lib/components/FluidTextInput/FluidPasswordInput.js +5 -1
- package/lib/components/FluidTextInput/FluidTextInput.d.ts +4 -0
- package/lib/components/FluidTextInput/FluidTextInput.js +5 -1
- package/lib/components/FluidTimePicker/FluidTimePicker.d.ts +4 -0
- package/lib/components/FluidTimePicker/FluidTimePicker.js +23 -7
- package/lib/components/Modal/Modal.d.ts +5 -0
- package/lib/components/Modal/Modal.js +16 -10
- package/lib/components/PaginationNav/PaginationNav.js +15 -3
- package/lib/components/RadioButton/RadioButton.d.ts +5 -0
- package/lib/components/RadioButton/RadioButton.js +16 -7
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +5 -0
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +16 -7
- package/lib/components/RadioTile/RadioTile.d.ts +5 -0
- package/lib/components/RadioTile/RadioTile.js +17 -8
- package/lib/components/Tag/DismissibleTag.d.ts +11 -2
- package/lib/components/Tag/DismissibleTag.js +13 -5
- package/lib/components/Tag/Tag.d.ts +5 -0
- package/lib/components/Tag/Tag.js +14 -7
- package/lib/components/Tile/Tile.d.ts +21 -1
- package/lib/components/Tile/Tile.js +67 -47
- package/package.json +4 -4
|
@@ -89,5 +89,9 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
89
89
|
/**
|
|
90
90
|
* Provide the text that is displayed when the control is in warning state
|
|
91
91
|
*/
|
|
92
|
-
warnText: PropTypes__default["default"].node
|
|
92
|
+
warnText: PropTypes__default["default"].node,
|
|
93
|
+
/**
|
|
94
|
+
* Whether or not the component is readonly
|
|
95
|
+
*/
|
|
96
|
+
readOnly: PropTypes__default["default"].bool
|
|
93
97
|
});
|
|
@@ -65,6 +65,10 @@ export interface FluidTextInputProps {
|
|
|
65
65
|
* Provide the text that is displayed when the control is in warning state
|
|
66
66
|
*/
|
|
67
67
|
warnText?: React.ReactNode;
|
|
68
|
+
/**
|
|
69
|
+
* Whether or not the component is readonly
|
|
70
|
+
*/
|
|
71
|
+
readOnly?: boolean;
|
|
68
72
|
}
|
|
69
73
|
declare const FluidTextInput: React.ForwardRefExoticComponent<FluidTextInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
70
74
|
export default FluidTextInput;
|
|
@@ -107,7 +107,11 @@ FluidTextInput.propTypes = {
|
|
|
107
107
|
/**
|
|
108
108
|
* Provide the text that is displayed when the control is in warning state
|
|
109
109
|
*/
|
|
110
|
-
warnText: PropTypes__default["default"].node
|
|
110
|
+
warnText: PropTypes__default["default"].node,
|
|
111
|
+
/**
|
|
112
|
+
* Whether or not the component is readonly
|
|
113
|
+
*/
|
|
114
|
+
readOnly: PropTypes__default["default"].bool
|
|
111
115
|
};
|
|
112
116
|
|
|
113
117
|
exports["default"] = FluidTextInput;
|
|
@@ -40,6 +40,10 @@ export interface FluidTimePickerProps extends FluidTextInputProps {
|
|
|
40
40
|
* Provide the text that is displayed when the control is in warning state
|
|
41
41
|
*/
|
|
42
42
|
warnText?: React.ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* Specify if the component is readonly
|
|
45
|
+
*/
|
|
46
|
+
readOnly?: boolean;
|
|
43
47
|
}
|
|
44
48
|
declare const FluidTimePicker: React.ForwardRefExoticComponent<FluidTimePickerProps & React.RefAttributes<HTMLInputElement>>;
|
|
45
49
|
export default FluidTimePicker;
|
|
@@ -34,6 +34,7 @@ const FluidTimePicker = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
34
34
|
invalidText,
|
|
35
35
|
warn,
|
|
36
36
|
warnText,
|
|
37
|
+
readOnly,
|
|
37
38
|
...other
|
|
38
39
|
} = _ref;
|
|
39
40
|
const prefix = usePrefix.usePrefix();
|
|
@@ -53,6 +54,19 @@ const FluidTimePicker = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
56
|
const error = invalid || warn;
|
|
57
|
+
const childrenWithProps = () => {
|
|
58
|
+
if (disabled) {
|
|
59
|
+
return React__default["default"].Children.toArray(children).map(child => /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
60
|
+
disabled: true
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
if (readOnly) {
|
|
64
|
+
return React__default["default"].Children.toArray(children).map(child => /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
65
|
+
readOnly: true
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
return children;
|
|
69
|
+
};
|
|
56
70
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
57
71
|
className: classNames
|
|
58
72
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -60,12 +74,10 @@ const FluidTimePicker = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
60
74
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
61
75
|
className: `${prefix}--time-picker__input`
|
|
62
76
|
}, /*#__PURE__*/React__default["default"].createElement(FluidTextInput["default"], _rollupPluginBabelHelpers["extends"]({
|
|
63
|
-
ref: ref
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
}) : children), error && /*#__PURE__*/React__default["default"].createElement("hr", {
|
|
77
|
+
ref: ref,
|
|
78
|
+
readOnly: readOnly,
|
|
79
|
+
disabled: disabled
|
|
80
|
+
}, other))), childrenWithProps()), error && /*#__PURE__*/React__default["default"].createElement("hr", {
|
|
69
81
|
className: `${prefix}--time-picker__divider`
|
|
70
82
|
}), error && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
71
83
|
className: `${prefix}--form-requirement`
|
|
@@ -108,7 +120,11 @@ FluidTimePicker.propTypes = {
|
|
|
108
120
|
/**
|
|
109
121
|
* Provide the text that is displayed when the control is in warning state
|
|
110
122
|
*/
|
|
111
|
-
warnText: PropTypes__default["default"].node
|
|
123
|
+
warnText: PropTypes__default["default"].node,
|
|
124
|
+
/**
|
|
125
|
+
* Whether or not the component is readonly
|
|
126
|
+
*/
|
|
127
|
+
readOnly: PropTypes__default["default"].bool
|
|
112
128
|
};
|
|
113
129
|
|
|
114
130
|
exports["default"] = FluidTimePicker;
|
|
@@ -39,6 +39,10 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
|
|
|
39
39
|
* Specify whether the Modal is for dangerous actions
|
|
40
40
|
*/
|
|
41
41
|
danger?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* **Experimental**: Provide a decorator component to be rendered inside the `Modal` component
|
|
44
|
+
*/
|
|
45
|
+
decorator?: ReactNode;
|
|
42
46
|
/**
|
|
43
47
|
* Specify whether the modal contains scrolling content
|
|
44
48
|
*/
|
|
@@ -151,6 +155,7 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
|
|
|
151
155
|
*/
|
|
152
156
|
size?: ModalSize;
|
|
153
157
|
/**
|
|
158
|
+
* @deprecated please use decorator instead.
|
|
154
159
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `Modal` component
|
|
155
160
|
*/
|
|
156
161
|
slug?: ReactNode;
|
|
@@ -31,6 +31,7 @@ var noopFn = require('../../internal/noopFn.js');
|
|
|
31
31
|
require('../Text/index.js');
|
|
32
32
|
var index = require('../FeatureFlags/index.js');
|
|
33
33
|
var events = require('../../tools/events.js');
|
|
34
|
+
var deprecate = require('../../prop-types/deprecate.js');
|
|
34
35
|
var Text = require('../Text/Text.js');
|
|
35
36
|
var match = require('../../internal/keyboard/match.js');
|
|
36
37
|
var keys = require('../../internal/keyboard/keys.js');
|
|
@@ -48,6 +49,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
|
|
|
48
49
|
'aria-label': ariaLabelProp,
|
|
49
50
|
children,
|
|
50
51
|
className,
|
|
52
|
+
decorator,
|
|
51
53
|
modalHeading = '',
|
|
52
54
|
modalLabel = '',
|
|
53
55
|
modalAriaLabel,
|
|
@@ -154,7 +156,8 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
|
|
|
154
156
|
[`${prefix}--modal-tall`]: !passiveModal,
|
|
155
157
|
'is-visible': open,
|
|
156
158
|
[`${prefix}--modal--danger`]: danger,
|
|
157
|
-
[`${prefix}--modal--slug`]: slug
|
|
159
|
+
[`${prefix}--modal--slug`]: slug,
|
|
160
|
+
[`${prefix}--modal--decorator`]: decorator
|
|
158
161
|
}, className);
|
|
159
162
|
const containerClasses = cx__default["default"](`${prefix}--modal-container`, {
|
|
160
163
|
[`${prefix}--modal-container--${size}`]: size,
|
|
@@ -238,10 +241,10 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
|
|
|
238
241
|
};
|
|
239
242
|
}, []);
|
|
240
243
|
|
|
241
|
-
//
|
|
242
|
-
let
|
|
243
|
-
if (
|
|
244
|
-
|
|
244
|
+
// AILabel always size `sm`
|
|
245
|
+
let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
|
|
246
|
+
if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
|
|
247
|
+
normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
|
|
245
248
|
size: 'sm'
|
|
246
249
|
});
|
|
247
250
|
}
|
|
@@ -278,7 +281,9 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
|
|
|
278
281
|
as: "h2",
|
|
279
282
|
id: modalHeadingId,
|
|
280
283
|
className: `${prefix}--modal-header__heading`
|
|
281
|
-
}, modalHeading),
|
|
284
|
+
}, modalHeading), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
285
|
+
className: `${prefix}--modal--inner__decorator`
|
|
286
|
+
}, normalizedDecorator) : '', !passiveModal && modalButton), /*#__PURE__*/React__default["default"].createElement(index$1.Layer, _rollupPluginBabelHelpers["extends"]({
|
|
282
287
|
ref: contentRef,
|
|
283
288
|
id: modalBodyId,
|
|
284
289
|
className: contentClasses
|
|
@@ -359,6 +364,10 @@ Modal.propTypes = {
|
|
|
359
364
|
* Specify whether the Modal is for dangerous actions
|
|
360
365
|
*/
|
|
361
366
|
danger: PropTypes__default["default"].bool,
|
|
367
|
+
/**
|
|
368
|
+
* **Experimental**: Provide a decorator component to be rendered inside the `Modal` component
|
|
369
|
+
*/
|
|
370
|
+
decorator: PropTypes__default["default"].node,
|
|
362
371
|
/**
|
|
363
372
|
* Specify whether the modal contains scrolling content
|
|
364
373
|
*/
|
|
@@ -489,10 +498,7 @@ Modal.propTypes = {
|
|
|
489
498
|
* Specify the size variant.
|
|
490
499
|
*/
|
|
491
500
|
size: PropTypes__default["default"].oneOf(ModalSizes),
|
|
492
|
-
|
|
493
|
-
* **Experimental**: Provide a `Slug` component to be rendered inside the `Modal` component
|
|
494
|
-
*/
|
|
495
|
-
slug: PropTypes__default["default"].node
|
|
501
|
+
slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.')
|
|
496
502
|
};
|
|
497
503
|
|
|
498
504
|
exports.ModalSizes = ModalSizes;
|
|
@@ -193,8 +193,20 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
193
193
|
} = _ref4;
|
|
194
194
|
const smMediaQuery = `(max-width: ${layout.breakpoints.sm.width})`;
|
|
195
195
|
const isSm = useMatchMedia.useMatchMedia(smMediaQuery);
|
|
196
|
+
let numberOfPages;
|
|
197
|
+
switch (size) {
|
|
198
|
+
case 'md':
|
|
199
|
+
numberOfPages = itemsShown === 4 ? itemsShown : 5;
|
|
200
|
+
break;
|
|
201
|
+
case 'sm':
|
|
202
|
+
numberOfPages = Math.max(4, Math.min(itemsShown, 7));
|
|
203
|
+
break;
|
|
204
|
+
default:
|
|
205
|
+
numberOfPages = 4;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
196
208
|
const [currentPage, setCurrentPage] = React.useState(page);
|
|
197
|
-
const [itemsDisplayedOnPage, setItemsDisplayedOnPage] = React.useState(itemsShown >= 4 && !isSm ? itemsShown :
|
|
209
|
+
const [itemsDisplayedOnPage, setItemsDisplayedOnPage] = React.useState(itemsShown >= 4 && !isSm ? itemsShown : numberOfPages);
|
|
198
210
|
const [cuts, setCuts] = React.useState(calculateCuts(currentPage, totalItems, itemsDisplayedOnPage));
|
|
199
211
|
const prevPage = usePrevious(currentPage);
|
|
200
212
|
const prefix = usePrefix.usePrefix();
|
|
@@ -239,10 +251,10 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
239
251
|
|
|
240
252
|
// re-calculate cuts if props.totalItems or props.itemsShown change
|
|
241
253
|
React.useEffect(() => {
|
|
242
|
-
const itemsToBeShown = itemsShown >= 4 && !isSm ? itemsShown :
|
|
254
|
+
const itemsToBeShown = itemsShown >= 4 && !isSm ? itemsShown : numberOfPages;
|
|
243
255
|
setItemsDisplayedOnPage(Math.max(itemsToBeShown, 4));
|
|
244
256
|
setCuts(calculateCuts(currentPage, totalItems, Math.max(itemsToBeShown, 4)));
|
|
245
|
-
}, [totalItems, itemsShown, isSm]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
257
|
+
}, [totalItems, itemsShown, isSm, size]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
246
258
|
|
|
247
259
|
// update cuts if necessary whenever currentPage changes
|
|
248
260
|
React.useEffect(() => {
|
|
@@ -15,6 +15,10 @@ export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
15
15
|
* Provide an optional className to be applied to the containing node
|
|
16
16
|
*/
|
|
17
17
|
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `RadioButton` component
|
|
20
|
+
*/
|
|
21
|
+
decorator?: ReactNode;
|
|
18
22
|
/**
|
|
19
23
|
* Specify whether the `<RadioButton>` should be checked by default
|
|
20
24
|
*/
|
|
@@ -55,6 +59,7 @@ export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
55
59
|
*/
|
|
56
60
|
onClick?: (evt: React.MouseEvent<HTMLInputElement>) => void;
|
|
57
61
|
/**
|
|
62
|
+
* @deprecated please use decorator instead.
|
|
58
63
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButton` component
|
|
59
64
|
*/
|
|
60
65
|
slug?: ReactNode;
|
|
@@ -14,6 +14,7 @@ var PropTypes = require('prop-types');
|
|
|
14
14
|
var React = require('react');
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
require('../Text/index.js');
|
|
17
|
+
var deprecate = require('../../prop-types/deprecate.js');
|
|
17
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
19
|
var useId = require('../../internal/useId.js');
|
|
19
20
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
@@ -28,6 +29,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
28
29
|
const RadioButton = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
|
|
29
30
|
const {
|
|
30
31
|
className,
|
|
32
|
+
decorator,
|
|
31
33
|
disabled,
|
|
32
34
|
hideLabel,
|
|
33
35
|
id,
|
|
@@ -51,13 +53,14 @@ const RadioButton = /*#__PURE__*/React__default["default"].forwardRef((props, re
|
|
|
51
53
|
});
|
|
52
54
|
const wrapperClasses = cx__default["default"](className, `${prefix}--radio-button-wrapper`, {
|
|
53
55
|
[`${prefix}--radio-button-wrapper--label-${labelPosition}`]: labelPosition !== 'right',
|
|
54
|
-
[`${prefix}--radio-button-wrapper--slug`]: slug
|
|
56
|
+
[`${prefix}--radio-button-wrapper--slug`]: slug,
|
|
57
|
+
[`${prefix}--radio-button-wrapper--decorator`]: decorator
|
|
55
58
|
});
|
|
56
59
|
const inputRef = React.useRef(null);
|
|
57
|
-
let
|
|
58
|
-
if (
|
|
59
|
-
const size =
|
|
60
|
-
|
|
60
|
+
let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
|
|
61
|
+
if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
|
|
62
|
+
const size = normalizedDecorator.props?.['kind'] === 'inline' ? 'md' : 'mini';
|
|
63
|
+
normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
|
|
61
64
|
size
|
|
62
65
|
});
|
|
63
66
|
}
|
|
@@ -80,7 +83,9 @@ const RadioButton = /*#__PURE__*/React__default["default"].forwardRef((props, re
|
|
|
80
83
|
className: `${prefix}--radio-button__appearance`
|
|
81
84
|
}), labelText && /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
82
85
|
className: innerLabelClasses
|
|
83
|
-
}, labelText,
|
|
86
|
+
}, labelText, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
87
|
+
className: `${prefix}--radio-button-wrapper-inner--decorator`
|
|
88
|
+
}, normalizedDecorator) : '')));
|
|
84
89
|
});
|
|
85
90
|
RadioButton.displayName = 'RadioButton';
|
|
86
91
|
RadioButton.propTypes = {
|
|
@@ -92,6 +97,10 @@ RadioButton.propTypes = {
|
|
|
92
97
|
* Provide an optional className to be applied to the containing node
|
|
93
98
|
*/
|
|
94
99
|
className: PropTypes__default["default"].string,
|
|
100
|
+
/**
|
|
101
|
+
* **Experimental**: Provide a decorator component to be rendered inside the `RadioButton` component
|
|
102
|
+
*/
|
|
103
|
+
decorator: PropTypes__default["default"].node,
|
|
95
104
|
/**
|
|
96
105
|
* Specify whether the `<RadioButton>` should be checked by default
|
|
97
106
|
*/
|
|
@@ -138,7 +147,7 @@ RadioButton.propTypes = {
|
|
|
138
147
|
/**
|
|
139
148
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButton` component
|
|
140
149
|
*/
|
|
141
|
-
slug: PropTypes__default["default"].node,
|
|
150
|
+
slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
|
|
142
151
|
/**
|
|
143
152
|
* Specify the value of the `<RadioButton>`
|
|
144
153
|
*/
|
|
@@ -17,6 +17,10 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
|
|
|
17
17
|
* Provide an optional className to be applied to the container node
|
|
18
18
|
*/
|
|
19
19
|
className?: string;
|
|
20
|
+
/**
|
|
21
|
+
* **Experimental**: Provide a decorator component to be rendered inside the `RadioButtonGroup` component
|
|
22
|
+
*/
|
|
23
|
+
decorator?: ReactNode;
|
|
20
24
|
/**
|
|
21
25
|
* Specify the `<RadioButton>` to be selected by default
|
|
22
26
|
*/
|
|
@@ -64,6 +68,7 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
|
|
|
64
68
|
*/
|
|
65
69
|
readOnly?: boolean;
|
|
66
70
|
/**
|
|
71
|
+
* @deprecated please use decorator instead.
|
|
67
72
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButtonGroup` component
|
|
68
73
|
*/
|
|
69
74
|
slug?: ReactNode;
|
|
@@ -16,6 +16,7 @@ var cx = require('classnames');
|
|
|
16
16
|
var index = require('../Text/index.js');
|
|
17
17
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
18
|
var iconsReact = require('@carbon/icons-react');
|
|
19
|
+
var deprecate = require('../../prop-types/deprecate.js');
|
|
19
20
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
20
21
|
var useId = require('../../internal/useId.js');
|
|
21
22
|
|
|
@@ -29,6 +30,7 @@ const RadioButtonGroup = /*#__PURE__*/React__default["default"].forwardRef((prop
|
|
|
29
30
|
const {
|
|
30
31
|
children,
|
|
31
32
|
className,
|
|
33
|
+
decorator,
|
|
32
34
|
defaultSelected,
|
|
33
35
|
disabled,
|
|
34
36
|
helperText,
|
|
@@ -97,7 +99,8 @@ const RadioButtonGroup = /*#__PURE__*/React__default["default"].forwardRef((prop
|
|
|
97
99
|
[`${prefix}--radio-button-group--readonly`]: readOnly,
|
|
98
100
|
[`${prefix}--radio-button-group--invalid`]: !readOnly && invalid,
|
|
99
101
|
[`${prefix}--radio-button-group--warning`]: showWarning,
|
|
100
|
-
[`${prefix}--radio-button-group--slug`]: slug
|
|
102
|
+
[`${prefix}--radio-button-group--slug`]: slug,
|
|
103
|
+
[`${prefix}--radio-button-group--decorator`]: decorator
|
|
101
104
|
});
|
|
102
105
|
const helperClasses = cx__default["default"](`${prefix}--form__helper-text`, {
|
|
103
106
|
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
@@ -109,10 +112,10 @@ const RadioButtonGroup = /*#__PURE__*/React__default["default"].forwardRef((prop
|
|
|
109
112
|
}, helperText) : null;
|
|
110
113
|
const divRef = React.useRef(null);
|
|
111
114
|
|
|
112
|
-
//
|
|
113
|
-
let
|
|
114
|
-
if (
|
|
115
|
-
|
|
115
|
+
// AILabel is always size `mini`
|
|
116
|
+
let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
|
|
117
|
+
if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
|
|
118
|
+
normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
|
|
116
119
|
size: 'mini',
|
|
117
120
|
kind: 'default'
|
|
118
121
|
});
|
|
@@ -127,7 +130,9 @@ const RadioButtonGroup = /*#__PURE__*/React__default["default"].forwardRef((prop
|
|
|
127
130
|
"aria-describedby": showHelper && helperText ? helperId : undefined
|
|
128
131
|
}, rest), legendText && /*#__PURE__*/React__default["default"].createElement(index.Legend, {
|
|
129
132
|
className: `${prefix}--label`
|
|
130
|
-
}, legendText,
|
|
133
|
+
}, legendText, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
134
|
+
className: `${prefix}--radio-button-group-inner--decorator`
|
|
135
|
+
}, normalizedDecorator) : ''), getRadioButtons()), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
131
136
|
className: `${prefix}--radio-button__validation-msg`
|
|
132
137
|
}, !readOnly && invalid && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
|
|
133
138
|
className: `${prefix}--radio-button__invalid-icon`
|
|
@@ -148,6 +153,10 @@ RadioButtonGroup.propTypes = {
|
|
|
148
153
|
* Provide an optional className to be applied to the container node
|
|
149
154
|
*/
|
|
150
155
|
className: PropTypes__default["default"].string,
|
|
156
|
+
/**
|
|
157
|
+
* **Experimental**: Provide a decorator component to be rendered inside the `RadioButtonGroup` component
|
|
158
|
+
*/
|
|
159
|
+
decorator: PropTypes__default["default"].node,
|
|
151
160
|
/**
|
|
152
161
|
* Specify the `<RadioButton>` to be selected by default
|
|
153
162
|
*/
|
|
@@ -201,7 +210,7 @@ RadioButtonGroup.propTypes = {
|
|
|
201
210
|
/**
|
|
202
211
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButtonGroup` component
|
|
203
212
|
*/
|
|
204
|
-
slug: PropTypes__default["default"].node,
|
|
213
|
+
slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
|
|
205
214
|
/**
|
|
206
215
|
* Specify the value that is currently selected in the group
|
|
207
216
|
*/
|
|
@@ -18,6 +18,10 @@ export interface RadioTileProps {
|
|
|
18
18
|
* Provide an optional `className` to be applied to the underlying `<label>`.
|
|
19
19
|
*/
|
|
20
20
|
className?: string;
|
|
21
|
+
/**
|
|
22
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `RadioTile` component
|
|
23
|
+
*/
|
|
24
|
+
decorator?: React.ReactNode;
|
|
21
25
|
/**
|
|
22
26
|
* Specify whether the `RadioTile` should be disabled.
|
|
23
27
|
*/
|
|
@@ -48,6 +52,7 @@ export interface RadioTileProps {
|
|
|
48
52
|
*/
|
|
49
53
|
onChange?: (value: string | number, name: string | undefined, event: React.ChangeEvent<HTMLInputElement> | React.KeyboardEvent<HTMLInputElement>) => void;
|
|
50
54
|
/**
|
|
55
|
+
* @deprecated please use `decorator` instead.
|
|
51
56
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
52
57
|
*/
|
|
53
58
|
slug?: React.ReactNode;
|
|
@@ -35,6 +35,7 @@ const RadioTile = /*#__PURE__*/React__default["default"].forwardRef(function Rad
|
|
|
35
35
|
let {
|
|
36
36
|
children,
|
|
37
37
|
className: customClassName,
|
|
38
|
+
decorator,
|
|
38
39
|
disabled,
|
|
39
40
|
light,
|
|
40
41
|
checked,
|
|
@@ -55,7 +56,9 @@ const RadioTile = /*#__PURE__*/React__default["default"].forwardRef(function Rad
|
|
|
55
56
|
[`${prefix}--tile--light`]: light,
|
|
56
57
|
[`${prefix}--tile--disabled`]: disabled,
|
|
57
58
|
[`${prefix}--tile--slug`]: slug,
|
|
58
|
-
[`${prefix}--tile--slug-rounded`]: slug && hasRoundedCorners
|
|
59
|
+
[`${prefix}--tile--slug-rounded`]: slug && hasRoundedCorners,
|
|
60
|
+
[`${prefix}--tile--decorator`]: decorator,
|
|
61
|
+
[`${prefix}--tile--decorator-rounded`]: decorator && hasRoundedCorners
|
|
59
62
|
});
|
|
60
63
|
const v12TileRadioIcons = index.useFeatureFlag('enable-v12-tile-radio-icons');
|
|
61
64
|
function icon() {
|
|
@@ -79,10 +82,10 @@ const RadioTile = /*#__PURE__*/React__default["default"].forwardRef(function Rad
|
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
|
|
82
|
-
//
|
|
83
|
-
let
|
|
84
|
-
if (
|
|
85
|
-
|
|
85
|
+
// AILabel is always size `xs`
|
|
86
|
+
let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
|
|
87
|
+
if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
|
|
88
|
+
normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
|
|
86
89
|
size: 'xs'
|
|
87
90
|
});
|
|
88
91
|
}
|
|
@@ -106,7 +109,9 @@ const RadioTile = /*#__PURE__*/React__default["default"].forwardRef(function Rad
|
|
|
106
109
|
className: `${prefix}--tile__checkmark`
|
|
107
110
|
}, icon()), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
108
111
|
className: `${prefix}--tile-content`
|
|
109
|
-
}, children),
|
|
112
|
+
}, children), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
113
|
+
className: `${prefix}--tile--inner-decorator`
|
|
114
|
+
}, normalizedDecorator) : ''));
|
|
110
115
|
});
|
|
111
116
|
RadioTile.displayName = 'RadioTile';
|
|
112
117
|
RadioTile.propTypes = {
|
|
@@ -122,6 +127,10 @@ RadioTile.propTypes = {
|
|
|
122
127
|
* Provide an optional `className` to be applied to the underlying `<label>`.
|
|
123
128
|
*/
|
|
124
129
|
className: PropTypes__default["default"].string,
|
|
130
|
+
/**
|
|
131
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `RadioTile` component
|
|
132
|
+
*/
|
|
133
|
+
decorator: PropTypes__default["default"].node,
|
|
125
134
|
/**
|
|
126
135
|
* Specify whether the `RadioTile` should be disabled.
|
|
127
136
|
*/
|
|
@@ -154,9 +163,9 @@ RadioTile.propTypes = {
|
|
|
154
163
|
*/
|
|
155
164
|
required: PropTypes__default["default"].bool,
|
|
156
165
|
/**
|
|
157
|
-
* **Experimental**: Provide a `Slug` component to be rendered inside the `
|
|
166
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `RadioTile` component
|
|
158
167
|
*/
|
|
159
|
-
slug: PropTypes__default["default"].node,
|
|
168
|
+
slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop for `RadioTile` has ' + 'been deprecated in favor of the new `decorator` prop. It will be removed in the next major release.'),
|
|
160
169
|
/**
|
|
161
170
|
* Specify the tab index of the underlying `<input>`.
|
|
162
171
|
*/
|
|
@@ -13,6 +13,10 @@ export interface DismissibleTagBaseProps {
|
|
|
13
13
|
* Provide a custom className that is applied to the containing <span>
|
|
14
14
|
*/
|
|
15
15
|
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* **Experimental:** Provide a `decorator` component to be rendered inside the `DismissibleTag` component
|
|
18
|
+
*/
|
|
19
|
+
decorator?: ReactNode;
|
|
16
20
|
/**
|
|
17
21
|
* Specify if the `DismissibleTag` is disabled
|
|
18
22
|
*/
|
|
@@ -36,6 +40,7 @@ export interface DismissibleTagBaseProps {
|
|
|
36
40
|
*/
|
|
37
41
|
size?: keyof typeof SIZES;
|
|
38
42
|
/**
|
|
43
|
+
* @deprecated please use `decorator` instead.
|
|
39
44
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
|
|
40
45
|
*/
|
|
41
46
|
slug?: ReactNode;
|
|
@@ -58,12 +63,16 @@ export interface DismissibleTagBaseProps {
|
|
|
58
63
|
}
|
|
59
64
|
export type DismissibleTagProps<T extends React.ElementType> = PolymorphicProps<T, DismissibleTagBaseProps>;
|
|
60
65
|
declare const DismissibleTag: {
|
|
61
|
-
<T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon, title, onClose, slug, size, text, tagTitle, type, ...other }: DismissibleTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
66
|
+
<T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, decorator, disabled, id, renderIcon, title, onClose, slug, size, text, tagTitle, type, ...other }: DismissibleTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
62
67
|
propTypes: {
|
|
63
68
|
/**
|
|
64
69
|
* Provide a custom className that is applied to the containing <span>
|
|
65
70
|
*/
|
|
66
71
|
className: PropTypes.Requireable<string>;
|
|
72
|
+
/**
|
|
73
|
+
* **Experimental:** Provide a `decorator` component to be rendered inside the `DismissibleTag` component
|
|
74
|
+
*/
|
|
75
|
+
decorator: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
67
76
|
/**
|
|
68
77
|
* Specify if the `DismissibleTag` is disabled
|
|
69
78
|
*/
|
|
@@ -89,7 +98,7 @@ declare const DismissibleTag: {
|
|
|
89
98
|
/**
|
|
90
99
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
|
|
91
100
|
*/
|
|
92
|
-
slug:
|
|
101
|
+
slug: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
93
102
|
/**
|
|
94
103
|
* Provide text to be rendered inside of a the tag.
|
|
95
104
|
*/
|
|
@@ -15,6 +15,7 @@ var React = require('react');
|
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
var useId = require('../../internal/useId.js');
|
|
17
17
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
|
+
var deprecate = require('../../prop-types/deprecate.js');
|
|
18
19
|
var Tag = require('./Tag.js');
|
|
19
20
|
var iconsReact = require('@carbon/icons-react');
|
|
20
21
|
require('../Tooltip/DefinitionTooltip.js');
|
|
@@ -33,6 +34,7 @@ var _Close;
|
|
|
33
34
|
const DismissibleTag = _ref => {
|
|
34
35
|
let {
|
|
35
36
|
className,
|
|
37
|
+
decorator,
|
|
36
38
|
disabled,
|
|
37
39
|
id,
|
|
38
40
|
renderIcon,
|
|
@@ -60,9 +62,9 @@ const DismissibleTag = _ref => {
|
|
|
60
62
|
onClose(event);
|
|
61
63
|
}
|
|
62
64
|
};
|
|
63
|
-
let
|
|
64
|
-
if (
|
|
65
|
-
|
|
65
|
+
let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
|
|
66
|
+
if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
|
|
67
|
+
normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
|
|
66
68
|
size: 'sm',
|
|
67
69
|
kind: 'inline'
|
|
68
70
|
});
|
|
@@ -89,7 +91,9 @@ const DismissibleTag = _ref => {
|
|
|
89
91
|
}, /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
90
92
|
title: tagTitle ? tagTitle : text,
|
|
91
93
|
className: `${prefix}--tag__label`
|
|
92
|
-
}, text),
|
|
94
|
+
}, text), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
95
|
+
className: `${prefix}--tag__decorator`
|
|
96
|
+
}, normalizedDecorator) : '', /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
93
97
|
label: isEllipsisApplied ? dismissLabel : title,
|
|
94
98
|
align: "bottom",
|
|
95
99
|
className: tooltipClasses,
|
|
@@ -108,6 +112,10 @@ DismissibleTag.propTypes = {
|
|
|
108
112
|
* Provide a custom className that is applied to the containing <span>
|
|
109
113
|
*/
|
|
110
114
|
className: PropTypes__default["default"].string,
|
|
115
|
+
/**
|
|
116
|
+
* **Experimental:** Provide a `decorator` component to be rendered inside the `DismissibleTag` component
|
|
117
|
+
*/
|
|
118
|
+
decorator: PropTypes__default["default"].node,
|
|
111
119
|
/**
|
|
112
120
|
* Specify if the `DismissibleTag` is disabled
|
|
113
121
|
*/
|
|
@@ -133,7 +141,7 @@ DismissibleTag.propTypes = {
|
|
|
133
141
|
/**
|
|
134
142
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
|
|
135
143
|
*/
|
|
136
|
-
slug: PropTypes__default["default"].node,
|
|
144
|
+
slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
|
|
137
145
|
/**
|
|
138
146
|
* Provide text to be rendered inside of a the tag.
|
|
139
147
|
*/
|
|
@@ -34,6 +34,10 @@ export interface TagBaseProps {
|
|
|
34
34
|
* Provide a custom className that is applied to the containing <span>
|
|
35
35
|
*/
|
|
36
36
|
className?: string;
|
|
37
|
+
/**
|
|
38
|
+
* **Experimental:** Provide a `decorator` component to be rendered inside the `Tag` component
|
|
39
|
+
*/
|
|
40
|
+
decorator?: ReactNode;
|
|
37
41
|
/**
|
|
38
42
|
* Specify if the `Tag` is disabled
|
|
39
43
|
*/
|
|
@@ -61,6 +65,7 @@ export interface TagBaseProps {
|
|
|
61
65
|
*/
|
|
62
66
|
size?: keyof typeof SIZES;
|
|
63
67
|
/**
|
|
68
|
+
* @deprecated please use `decorator` instead.
|
|
64
69
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
|
|
65
70
|
*/
|
|
66
71
|
slug?: ReactNode;
|