@carbon/react 1.43.0-rc.0 → 1.44.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 +1024 -905
- package/es/components/Accordion/AccordionItem.d.ts +1 -1
- package/es/components/Accordion/AccordionItem.js +19 -15
- package/es/components/Checkbox/Checkbox.d.ts +4 -0
- package/es/components/Checkbox/Checkbox.js +15 -2
- package/es/components/CheckboxGroup/CheckboxGroup.js +17 -2
- package/es/components/ComboBox/ComboBox.js +12 -0
- package/es/components/ComboButton/index.js +2 -1
- package/es/components/ComposedModal/ComposedModal.d.ts +3 -3
- package/es/components/ComposedModal/ComposedModal.js +3 -3
- package/es/components/ContextMenu/useContextMenu.js +2 -1
- package/es/components/DataTable/tools/sorting.js +1 -1
- package/es/components/DataTableSkeleton/DataTableSkeleton.js +1 -1
- package/es/components/Dropdown/Dropdown.js +4 -1
- package/es/components/FileUploader/FileUploader.js +5 -3
- package/es/components/Grid/Column.js +11 -1
- package/es/components/Link/Link.d.ts +5 -0
- package/es/components/Link/Link.js +9 -2
- package/es/components/Menu/Menu.js +14 -0
- package/es/components/Menu/MenuContext.js +1 -0
- package/es/components/Menu/MenuItem.js +19 -4
- package/es/components/MenuButton/index.js +10 -2
- package/es/components/RadioButton/RadioButton.d.ts +4 -0
- package/es/components/RadioButton/RadioButton.js +15 -2
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +4 -0
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +17 -2
- package/es/components/Select/Select.d.ts +1 -1
- package/es/components/Slug/index.js +2 -2
- package/es/components/Tile/Tile.d.ts +37 -0
- package/es/components/Tile/Tile.js +110 -13
- package/es/components/UIShell/Content.d.ts +296 -0
- package/es/components/UIShell/Content.js +1 -2
- package/es/components/UIShell/SideNav.d.ts +1 -1
- package/es/components/UIShell/SideNav.js +1 -1
- package/es/components/UIShell/Switcher.d.ts +38 -0
- package/es/components/UIShell/Switcher.js +14 -13
- package/es/components/UIShell/SwitcherDivider.d.ts +9 -0
- package/es/components/UIShell/SwitcherDivider.js +4 -5
- package/es/components/UIShell/SwitcherItem.d.ts +49 -0
- package/es/components/UIShell/SwitcherItem.js +13 -17
- package/es/prop-types/tools/getDisplayName.js +34 -0
- package/lib/components/Accordion/AccordionItem.d.ts +1 -1
- package/lib/components/Accordion/AccordionItem.js +18 -14
- package/lib/components/Checkbox/Checkbox.d.ts +4 -0
- package/lib/components/Checkbox/Checkbox.js +15 -2
- package/lib/components/CheckboxGroup/CheckboxGroup.js +17 -2
- package/lib/components/ComboBox/ComboBox.js +12 -0
- package/lib/components/ComboButton/index.js +2 -1
- package/lib/components/ComposedModal/ComposedModal.d.ts +3 -3
- package/lib/components/ComposedModal/ComposedModal.js +3 -3
- package/lib/components/ContextMenu/useContextMenu.js +2 -1
- package/lib/components/DataTable/tools/sorting.js +1 -1
- package/lib/components/DataTableSkeleton/DataTableSkeleton.js +1 -1
- package/lib/components/Dropdown/Dropdown.js +4 -1
- package/lib/components/FileUploader/FileUploader.js +5 -3
- package/lib/components/Grid/Column.js +11 -1
- package/lib/components/Link/Link.d.ts +5 -0
- package/lib/components/Link/Link.js +9 -2
- package/lib/components/Menu/Menu.js +14 -0
- package/lib/components/Menu/MenuContext.js +1 -0
- package/lib/components/Menu/MenuItem.js +19 -4
- package/lib/components/MenuButton/index.js +10 -2
- package/lib/components/RadioButton/RadioButton.d.ts +4 -0
- package/lib/components/RadioButton/RadioButton.js +15 -2
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +4 -0
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +17 -2
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/Slug/index.js +2 -2
- package/lib/components/Tile/Tile.d.ts +37 -0
- package/lib/components/Tile/Tile.js +110 -13
- package/lib/components/UIShell/Content.d.ts +296 -0
- package/lib/components/UIShell/Content.js +1 -2
- package/lib/components/UIShell/SideNav.d.ts +1 -1
- package/lib/components/UIShell/SideNav.js +1 -1
- package/lib/components/UIShell/Switcher.d.ts +38 -0
- package/lib/components/UIShell/Switcher.js +13 -12
- package/lib/components/UIShell/SwitcherDivider.d.ts +9 -0
- package/lib/components/UIShell/SwitcherDivider.js +4 -5
- package/lib/components/UIShell/SwitcherItem.d.ts +49 -0
- package/lib/components/UIShell/SwitcherItem.js +12 -16
- package/lib/prop-types/tools/getDisplayName.js +38 -0
- package/package.json +5 -5
|
@@ -26,6 +26,7 @@ const RadioButton = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
26
26
|
name,
|
|
27
27
|
onChange = () => {},
|
|
28
28
|
value = '',
|
|
29
|
+
slug,
|
|
29
30
|
...rest
|
|
30
31
|
} = props;
|
|
31
32
|
const prefix = usePrefix();
|
|
@@ -38,9 +39,17 @@ const RadioButton = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
38
39
|
[`${prefix}--visually-hidden`]: hideLabel
|
|
39
40
|
});
|
|
40
41
|
const wrapperClasses = cx(className, `${prefix}--radio-button-wrapper`, {
|
|
41
|
-
[`${prefix}--radio-button-wrapper--label-${labelPosition}`]: labelPosition !== 'right'
|
|
42
|
+
[`${prefix}--radio-button-wrapper--label-${labelPosition}`]: labelPosition !== 'right',
|
|
43
|
+
[`${prefix}--radio-button-wrapper--slug`]: slug
|
|
42
44
|
});
|
|
43
45
|
const inputRef = useRef(null);
|
|
46
|
+
let normalizedSlug;
|
|
47
|
+
if (slug && /*#__PURE__*/React__default.isValidElement(slug)) {
|
|
48
|
+
const size = slug.props?.['kind'] === 'inline' ? 'md' : 'mini';
|
|
49
|
+
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
50
|
+
size
|
|
51
|
+
});
|
|
52
|
+
}
|
|
44
53
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
45
54
|
className: wrapperClasses
|
|
46
55
|
}, /*#__PURE__*/React__default.createElement("input", _extends({}, rest, {
|
|
@@ -59,7 +68,7 @@ const RadioButton = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
59
68
|
className: `${prefix}--radio-button__appearance`
|
|
60
69
|
}), labelText && /*#__PURE__*/React__default.createElement(Text, {
|
|
61
70
|
className: innerLabelClasses
|
|
62
|
-
}, labelText)));
|
|
71
|
+
}, labelText, normalizedSlug)));
|
|
63
72
|
});
|
|
64
73
|
RadioButton.displayName = 'RadioButton';
|
|
65
74
|
RadioButton.propTypes = {
|
|
@@ -110,6 +119,10 @@ RadioButton.propTypes = {
|
|
|
110
119
|
* Provide a handler that is invoked when a user clicks on the control
|
|
111
120
|
*/
|
|
112
121
|
onClick: PropTypes.func,
|
|
122
|
+
/**
|
|
123
|
+
* Provide a `Slug` component to be rendered inside the `RadioButton` component
|
|
124
|
+
*/
|
|
125
|
+
slug: PropTypes.node,
|
|
113
126
|
/**
|
|
114
127
|
* Specify the value of the `<RadioButton>`
|
|
115
128
|
*/
|
|
@@ -63,6 +63,10 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
|
|
|
63
63
|
* Whether the RadioButtonGroup should be read-only
|
|
64
64
|
*/
|
|
65
65
|
readOnly?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Provide a `Slug` component to be rendered inside the `RadioButtonGroup` component
|
|
68
|
+
*/
|
|
69
|
+
slug?: ReactNodeLike;
|
|
66
70
|
/**
|
|
67
71
|
* Specify whether the control is currently in warning state
|
|
68
72
|
*/
|
|
@@ -34,6 +34,7 @@ const RadioButtonGroup = /*#__PURE__*/React__default.forwardRef((props, ref) =>
|
|
|
34
34
|
valueSelected,
|
|
35
35
|
warn = false,
|
|
36
36
|
warnText,
|
|
37
|
+
slug,
|
|
37
38
|
...rest
|
|
38
39
|
} = props;
|
|
39
40
|
const prefix = usePrefix();
|
|
@@ -88,7 +89,8 @@ const RadioButtonGroup = /*#__PURE__*/React__default.forwardRef((props, ref) =>
|
|
|
88
89
|
[`${prefix}--radio-button-group--label-${labelPosition}`]: labelPosition,
|
|
89
90
|
[`${prefix}--radio-button-group--readonly`]: readOnly,
|
|
90
91
|
[`${prefix}--radio-button-group--invalid`]: !readOnly && invalid,
|
|
91
|
-
[`${prefix}--radio-button-group--warning`]: showWarning
|
|
92
|
+
[`${prefix}--radio-button-group--warning`]: showWarning,
|
|
93
|
+
[`${prefix}--radio-button-group--slug`]: slug
|
|
92
94
|
});
|
|
93
95
|
const helperClasses = cx(`${prefix}--form__helper-text`, {
|
|
94
96
|
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
@@ -99,6 +101,15 @@ const RadioButtonGroup = /*#__PURE__*/React__default.forwardRef((props, ref) =>
|
|
|
99
101
|
className: helperClasses
|
|
100
102
|
}, helperText) : null;
|
|
101
103
|
const divRef = useRef(null);
|
|
104
|
+
|
|
105
|
+
// Slug is always size `mini`
|
|
106
|
+
let normalizedSlug;
|
|
107
|
+
if (slug) {
|
|
108
|
+
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
109
|
+
size: 'mini',
|
|
110
|
+
kind: 'default'
|
|
111
|
+
});
|
|
112
|
+
}
|
|
102
113
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
103
114
|
className: wrapperClasses,
|
|
104
115
|
ref: mergeRefs(divRef, ref)
|
|
@@ -109,7 +120,7 @@ const RadioButtonGroup = /*#__PURE__*/React__default.forwardRef((props, ref) =>
|
|
|
109
120
|
"aria-describedby": showHelper && helperText ? helperId : undefined
|
|
110
121
|
}, rest), legendText && /*#__PURE__*/React__default.createElement(Legend, {
|
|
111
122
|
className: `${prefix}--label`
|
|
112
|
-
}, legendText), getRadioButtons()), /*#__PURE__*/React__default.createElement("div", {
|
|
123
|
+
}, legendText, normalizedSlug), getRadioButtons()), /*#__PURE__*/React__default.createElement("div", {
|
|
113
124
|
className: `${prefix}--radio-button__validation-msg`
|
|
114
125
|
}, !readOnly && invalid && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
115
126
|
className: `${prefix}--radio-button__invalid-icon`
|
|
@@ -176,6 +187,10 @@ RadioButtonGroup.propTypes = {
|
|
|
176
187
|
* Whether the RadioButtonGroup should be read-only
|
|
177
188
|
*/
|
|
178
189
|
readOnly: PropTypes.bool,
|
|
190
|
+
/**
|
|
191
|
+
* Provide a `Slug` component to be rendered inside the `RadioButtonGroup` component
|
|
192
|
+
*/
|
|
193
|
+
slug: PropTypes.node,
|
|
179
194
|
/**
|
|
180
195
|
* Specify the value that is currently selected in the group
|
|
181
196
|
*/
|
|
@@ -90,5 +90,5 @@ interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttr
|
|
|
90
90
|
*/
|
|
91
91
|
warnText?: ReactNode;
|
|
92
92
|
}
|
|
93
|
-
declare const Select: React.ForwardRefExoticComponent<Pick<SelectProps, "value" | "children" | "disabled" | "form" | "slot" | "style" | "title" | "className" | "size" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "autoComplete" | "multiple" | "key" | "id" | "aria-controls" | "aria-expanded" | "onClick" | "
|
|
93
|
+
declare const Select: React.ForwardRefExoticComponent<Pick<SelectProps, "value" | "children" | "disabled" | "form" | "slot" | "style" | "title" | "className" | "size" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "autoComplete" | "multiple" | "key" | "id" | "aria-controls" | "aria-expanded" | "onClick" | "onKeyDown" | "onTransitionEnd" | "tabIndex" | "color" | "lang" | "name" | "role" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEndCapture" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "inline" | "readOnly" | "required" | "light" | "invalid" | "labelText" | "helperText" | "invalidText" | "hideLabel" | "warn" | "warnText" | "slug" | "noLabel"> & React.RefAttributes<HTMLSelectElement>>;
|
|
94
94
|
export default Select;
|
|
@@ -73,7 +73,7 @@ const Slug = /*#__PURE__*/React__default.forwardRef(function Slug(_ref3, ref) {
|
|
|
73
73
|
children,
|
|
74
74
|
className,
|
|
75
75
|
dotType,
|
|
76
|
-
kind,
|
|
76
|
+
kind = 'default',
|
|
77
77
|
onRevertClick,
|
|
78
78
|
revertActive,
|
|
79
79
|
revertLabel = 'Revert to AI input',
|
|
@@ -103,7 +103,7 @@ const Slug = /*#__PURE__*/React__default.forwardRef(function Slug(_ref3, ref) {
|
|
|
103
103
|
onRevertClick(evt);
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
-
const ariaLabel = `${aiText} - ${slugLabel}`;
|
|
106
|
+
const ariaLabel = !aiTextLabel ? `${aiText} - ${slugLabel}` : `${aiText} - ${aiTextLabel}`;
|
|
107
107
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
108
108
|
className: slugClasses,
|
|
109
109
|
ref: ref,
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import React, { type ReactNode, type MouseEvent, type KeyboardEvent, type HTMLAttributes, type ChangeEvent, type ComponentType } from 'react';
|
|
2
|
+
import { ReactNodeLike } from 'prop-types';
|
|
2
3
|
export interface TileProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
4
|
children?: ReactNode;
|
|
4
5
|
className?: string;
|
|
5
6
|
/** @deprecated */
|
|
6
7
|
light?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Specify if the `Tile` component should be rendered with rounded corners. Only valid
|
|
10
|
+
* when `slug` prop is present
|
|
11
|
+
*/
|
|
12
|
+
hasRoundedCorners?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
15
|
+
*/
|
|
16
|
+
slug?: ReactNodeLike;
|
|
7
17
|
}
|
|
8
18
|
export declare const Tile: React.ForwardRefExoticComponent<TileProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
19
|
export interface ClickableTileProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
@@ -19,6 +29,11 @@ export interface ClickableTileProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
19
29
|
* Specify whether the ClickableTile should be disabled
|
|
20
30
|
*/
|
|
21
31
|
disabled?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Specify if the `ClickableTile` component should be rendered with rounded corners.
|
|
34
|
+
* Only valid when `slug` prop is present
|
|
35
|
+
*/
|
|
36
|
+
hasRoundedCorners?: boolean;
|
|
22
37
|
/**
|
|
23
38
|
* The href for the link.
|
|
24
39
|
*/
|
|
@@ -41,6 +56,10 @@ export interface ClickableTileProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
41
56
|
* The rel property for the link.
|
|
42
57
|
*/
|
|
43
58
|
rel?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Specify if a `Slug` icon should be rendered inside the `ClickableTile`
|
|
61
|
+
*/
|
|
62
|
+
slug?: boolean;
|
|
44
63
|
}
|
|
45
64
|
export declare const ClickableTile: React.ForwardRefExoticComponent<ClickableTileProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
46
65
|
export interface SelectableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -52,6 +71,11 @@ export interface SelectableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
52
71
|
* Specify whether the SelectableTile should be disabled
|
|
53
72
|
*/
|
|
54
73
|
disabled?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Specify if the `SelectableTile` component should be rendered with rounded corners.
|
|
76
|
+
* Only valid when `slug` prop is present
|
|
77
|
+
*/
|
|
78
|
+
hasRoundedCorners?: boolean;
|
|
55
79
|
/**
|
|
56
80
|
* The ID of the `<input>`.
|
|
57
81
|
*/
|
|
@@ -77,6 +101,10 @@ export interface SelectableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
77
101
|
* `true` to select this tile.
|
|
78
102
|
*/
|
|
79
103
|
selected?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
106
|
+
*/
|
|
107
|
+
slug?: ReactNodeLike;
|
|
80
108
|
/**
|
|
81
109
|
* Specify the tab index of the wrapper element
|
|
82
110
|
*/
|
|
@@ -101,6 +129,11 @@ export interface ExpandableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
101
129
|
* `true` if the tile is expanded.
|
|
102
130
|
*/
|
|
103
131
|
expanded?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Specify if the `ExpandableTile` component should be rendered with rounded corners.
|
|
134
|
+
* Only valid when `slug` prop is present
|
|
135
|
+
*/
|
|
136
|
+
hasRoundedCorners?: boolean;
|
|
104
137
|
/**
|
|
105
138
|
* An ID that can be provided to aria-labelledby
|
|
106
139
|
*/
|
|
@@ -113,6 +146,10 @@ export interface ExpandableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
113
146
|
* optional handler to trigger a function when a key is pressed
|
|
114
147
|
*/
|
|
115
148
|
onKeyUp?(event: KeyboardEvent): void;
|
|
149
|
+
/**
|
|
150
|
+
* Provide a `Slug` component to be rendered inside the `ExpandableTile` component
|
|
151
|
+
*/
|
|
152
|
+
slug?: ReactNodeLike;
|
|
116
153
|
/**
|
|
117
154
|
* The `tabindex` attribute.
|
|
118
155
|
*/
|
|
@@ -24,20 +24,26 @@ import { Text } from '../Text/Text.js';
|
|
|
24
24
|
import { matches } from '../../internal/keyboard/match.js';
|
|
25
25
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
26
26
|
|
|
27
|
-
var _CheckboxCheckedFille, _Checkbox, _ChevronDown, _ChevronDown2;
|
|
27
|
+
var _rect, _path, _CheckboxCheckedFille, _Checkbox, _ChevronDown, _ChevronDown2;
|
|
28
28
|
const Tile = /*#__PURE__*/React__default.forwardRef(function Tile(_ref, ref) {
|
|
29
29
|
let {
|
|
30
30
|
children,
|
|
31
31
|
className,
|
|
32
32
|
light = false,
|
|
33
|
+
slug,
|
|
34
|
+
hasRoundedCorners = false,
|
|
33
35
|
...rest
|
|
34
36
|
} = _ref;
|
|
35
37
|
const prefix = usePrefix();
|
|
36
|
-
const tileClasses = cx(`${prefix}--tile`,
|
|
38
|
+
const tileClasses = cx(`${prefix}--tile`, {
|
|
39
|
+
[`${prefix}--tile--light`]: light,
|
|
40
|
+
[`${prefix}--tile--slug`]: slug,
|
|
41
|
+
[`${prefix}--tile--slug-rounded`]: slug && hasRoundedCorners
|
|
42
|
+
}, className);
|
|
37
43
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
38
44
|
className: tileClasses,
|
|
39
45
|
ref: ref
|
|
40
|
-
}, rest), children);
|
|
46
|
+
}, rest), children, slug);
|
|
41
47
|
});
|
|
42
48
|
Tile.displayName = 'Tile';
|
|
43
49
|
Tile.propTypes = {
|
|
@@ -49,13 +55,22 @@ Tile.propTypes = {
|
|
|
49
55
|
* The CSS class names.
|
|
50
56
|
*/
|
|
51
57
|
className: PropTypes.string,
|
|
58
|
+
/**
|
|
59
|
+
* Specify if the `Tile` component should be rendered with rounded corners. Only valid
|
|
60
|
+
* when `slug` prop is present
|
|
61
|
+
*/
|
|
62
|
+
hasRoundedCorners: PropTypes.bool,
|
|
52
63
|
/**
|
|
53
64
|
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
54
65
|
* Don't use this to make tile background color same as container background color.
|
|
55
66
|
*
|
|
56
67
|
* @deprecated
|
|
57
68
|
*/
|
|
58
|
-
light: deprecate(PropTypes.bool, 'The `light` prop for `Tile` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.')
|
|
69
|
+
light: deprecate(PropTypes.bool, 'The `light` prop for `Tile` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.'),
|
|
70
|
+
/**
|
|
71
|
+
* Provide a `Slug` component to be rendered inside the `Tile` component
|
|
72
|
+
*/
|
|
73
|
+
slug: PropTypes.node
|
|
59
74
|
};
|
|
60
75
|
const ClickableTile = /*#__PURE__*/React__default.forwardRef(function ClickableTile(_ref2, ref) {
|
|
61
76
|
let {
|
|
@@ -68,10 +83,17 @@ const ClickableTile = /*#__PURE__*/React__default.forwardRef(function ClickableT
|
|
|
68
83
|
onClick = () => {},
|
|
69
84
|
onKeyDown = () => {},
|
|
70
85
|
renderIcon: Icon,
|
|
86
|
+
hasRoundedCorners,
|
|
87
|
+
slug,
|
|
71
88
|
...rest
|
|
72
89
|
} = _ref2;
|
|
73
90
|
const prefix = usePrefix();
|
|
74
|
-
const classes = cx(`${prefix}--tile`, `${prefix}--tile--clickable`,
|
|
91
|
+
const classes = cx(`${prefix}--tile`, `${prefix}--tile--clickable`, {
|
|
92
|
+
[`${prefix}--tile--is-clicked`]: clicked,
|
|
93
|
+
[`${prefix}--tile--light`]: light,
|
|
94
|
+
[`${prefix}--tile--slug`]: slug,
|
|
95
|
+
[`${prefix}--tile--slug-rounded`]: slug && hasRoundedCorners
|
|
96
|
+
}, className);
|
|
75
97
|
const [isSelected, setIsSelected] = useState(clicked);
|
|
76
98
|
function handleOnClick(evt) {
|
|
77
99
|
evt?.persist?.();
|
|
@@ -85,6 +107,25 @@ const ClickableTile = /*#__PURE__*/React__default.forwardRef(function ClickableT
|
|
|
85
107
|
}
|
|
86
108
|
onKeyDown(evt);
|
|
87
109
|
}
|
|
110
|
+
|
|
111
|
+
// To Do: Replace with an an icon from `@carbon/react`
|
|
112
|
+
// since the hollow slug in `ClickableTile` is not interactive
|
|
113
|
+
const hollowSlugIcon = /*#__PURE__*/React__default.createElement("svg", {
|
|
114
|
+
className: `${prefix}--tile--slug-icon`,
|
|
115
|
+
width: "24",
|
|
116
|
+
height: "24",
|
|
117
|
+
viewBox: "0 0 24 24",
|
|
118
|
+
fill: "none",
|
|
119
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
120
|
+
}, _rect || (_rect = /*#__PURE__*/React__default.createElement("rect", {
|
|
121
|
+
x: "0.5",
|
|
122
|
+
y: "0.5",
|
|
123
|
+
width: "23",
|
|
124
|
+
height: "23"
|
|
125
|
+
})), _path || (_path = /*#__PURE__*/React__default.createElement("path", {
|
|
126
|
+
d: "M13.2436 16H11.5996L10.9276 13.864H7.95164L7.29164 16H5.68364L8.49164 7.624H10.4596L13.2436 16ZM10.5436 12.508L9.46364 9.064H9.40364L8.33564 12.508H10.5436ZM17.9341 16H14.1301V14.728H15.2341V8.896H14.1301V7.624H17.9341V8.896H16.8181V14.728H17.9341V16Z",
|
|
127
|
+
fill: "#161616"
|
|
128
|
+
})));
|
|
88
129
|
const v12DefaultIcons = useFeatureFlag('enable-v12-tile-default-icons');
|
|
89
130
|
if (v12DefaultIcons) {
|
|
90
131
|
if (!Icon) {
|
|
@@ -106,7 +147,9 @@ const ClickableTile = /*#__PURE__*/React__default.forwardRef(function ClickableT
|
|
|
106
147
|
onKeyDown: handleOnKeyDown,
|
|
107
148
|
ref: ref,
|
|
108
149
|
disabled: disabled
|
|
109
|
-
}, rest),
|
|
150
|
+
}, rest), slug ? /*#__PURE__*/React__default.createElement("div", {
|
|
151
|
+
className: `${prefix}--tile-content`
|
|
152
|
+
}, children) : children, slug && hollowSlugIcon, Icon && /*#__PURE__*/React__default.createElement(Icon, {
|
|
110
153
|
className: iconClasses,
|
|
111
154
|
"aria-hidden": "true"
|
|
112
155
|
}));
|
|
@@ -129,6 +172,11 @@ ClickableTile.propTypes = {
|
|
|
129
172
|
* Specify whether the ClickableTile should be disabled
|
|
130
173
|
*/
|
|
131
174
|
disabled: PropTypes.bool,
|
|
175
|
+
/**
|
|
176
|
+
* Specify if the `ClickableTile` component should be rendered with rounded corners.
|
|
177
|
+
* Only valid when `slug` prop is present
|
|
178
|
+
*/
|
|
179
|
+
hasRoundedCorners: PropTypes.bool,
|
|
132
180
|
/**
|
|
133
181
|
* The href for the link.
|
|
134
182
|
*/
|
|
@@ -170,6 +218,8 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
|
|
|
170
218
|
selected = false,
|
|
171
219
|
tabIndex = 0,
|
|
172
220
|
title = 'title',
|
|
221
|
+
slug,
|
|
222
|
+
hasRoundedCorners,
|
|
173
223
|
...rest
|
|
174
224
|
} = _ref3;
|
|
175
225
|
const prefix = usePrefix();
|
|
@@ -177,12 +227,21 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
|
|
|
177
227
|
const keyDownHandler = onKeyDown;
|
|
178
228
|
const [isSelected, setIsSelected] = useState(selected);
|
|
179
229
|
const [prevSelected, setPrevSelected] = useState(selected);
|
|
180
|
-
const classes = cx(`${prefix}--tile`, `${prefix}--tile--selectable`,
|
|
230
|
+
const classes = cx(`${prefix}--tile`, `${prefix}--tile--selectable`, {
|
|
231
|
+
[`${prefix}--tile--is-selected`]: isSelected,
|
|
232
|
+
[`${prefix}--tile--light`]: light,
|
|
233
|
+
[`${prefix}--tile--disabled`]: disabled,
|
|
234
|
+
[`${prefix}--tile--slug`]: slug,
|
|
235
|
+
[`${prefix}--tile--slug-rounded`]: slug && hasRoundedCorners
|
|
236
|
+
}, className);
|
|
181
237
|
|
|
182
238
|
// TODO: rename to handleClick when handleClick prop is deprecated
|
|
183
239
|
function handleOnClick(evt) {
|
|
184
240
|
evt.preventDefault();
|
|
185
241
|
evt?.persist?.();
|
|
242
|
+
if (slug && slugRef.current && slugRef.current.contains(evt.target)) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
186
245
|
setIsSelected(!isSelected);
|
|
187
246
|
clickHandler(evt);
|
|
188
247
|
onChange(evt);
|
|
@@ -206,6 +265,16 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
|
|
|
206
265
|
setIsSelected(selected);
|
|
207
266
|
setPrevSelected(selected);
|
|
208
267
|
}
|
|
268
|
+
|
|
269
|
+
// Slug is always size `xs`
|
|
270
|
+
const slugRef = useRef(null);
|
|
271
|
+
let normalizedSlug;
|
|
272
|
+
if (slug) {
|
|
273
|
+
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
274
|
+
size: 'xs',
|
|
275
|
+
ref: slugRef
|
|
276
|
+
});
|
|
277
|
+
}
|
|
209
278
|
return (
|
|
210
279
|
/*#__PURE__*/
|
|
211
280
|
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
|
|
@@ -228,10 +297,9 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
|
|
|
228
297
|
as: "label",
|
|
229
298
|
htmlFor: id,
|
|
230
299
|
className: `${prefix}--tile-content`
|
|
231
|
-
}, children))
|
|
300
|
+
}, children), normalizedSlug)
|
|
232
301
|
);
|
|
233
302
|
});
|
|
234
|
-
SelectableTile.displayName = 'SelectableTile';
|
|
235
303
|
SelectableTile.propTypes = {
|
|
236
304
|
children: PropTypes.node,
|
|
237
305
|
className: PropTypes.string,
|
|
@@ -239,6 +307,11 @@ SelectableTile.propTypes = {
|
|
|
239
307
|
* Specify whether the SelectableTile should be disabled
|
|
240
308
|
*/
|
|
241
309
|
disabled: PropTypes.bool,
|
|
310
|
+
/**
|
|
311
|
+
* Specify if the `SelectableTile` component should be rendered with rounded corners.
|
|
312
|
+
* Only valid when `slug` prop is present
|
|
313
|
+
*/
|
|
314
|
+
hasRoundedCorners: PropTypes.bool,
|
|
242
315
|
/**
|
|
243
316
|
* The ID of the `<input>`.
|
|
244
317
|
*/
|
|
@@ -269,6 +342,10 @@ SelectableTile.propTypes = {
|
|
|
269
342
|
* `true` to select this tile.
|
|
270
343
|
*/
|
|
271
344
|
selected: PropTypes.bool,
|
|
345
|
+
/**
|
|
346
|
+
* Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
347
|
+
*/
|
|
348
|
+
slug: PropTypes.node,
|
|
272
349
|
/**
|
|
273
350
|
* Specify the tab index of the wrapper element
|
|
274
351
|
*/
|
|
@@ -300,6 +377,8 @@ const ExpandableTile = /*#__PURE__*/React__default.forwardRef(function Expandabl
|
|
|
300
377
|
tileCollapsedLabel,
|
|
301
378
|
tileExpandedLabel,
|
|
302
379
|
light,
|
|
380
|
+
slug,
|
|
381
|
+
hasRoundedCorners,
|
|
303
382
|
...rest
|
|
304
383
|
} = _ref4;
|
|
305
384
|
const [isTileMaxHeight, setIsTileMaxHeight] = useState(tileMaxHeight);
|
|
@@ -355,7 +434,12 @@ const ExpandableTile = /*#__PURE__*/React__default.forwardRef(function Expandabl
|
|
|
355
434
|
[`${prefix}--tile--is-expanded`]: isExpanded,
|
|
356
435
|
[`${prefix}--tile--light`]: light
|
|
357
436
|
}, className);
|
|
358
|
-
const interactiveClassNames = cx(`${prefix}--tile`, `${prefix}--tile--expandable`, `${prefix}--tile--expandable--interactive`,
|
|
437
|
+
const interactiveClassNames = cx(`${prefix}--tile`, `${prefix}--tile--expandable`, `${prefix}--tile--expandable--interactive`, {
|
|
438
|
+
[`${prefix}--tile--is-expanded`]: isExpanded,
|
|
439
|
+
[`${prefix}--tile--light`]: light,
|
|
440
|
+
[`${prefix}--tile--slug`]: slug,
|
|
441
|
+
[`${prefix}--tile--slug-rounded`]: slug && hasRoundedCorners
|
|
442
|
+
}, className);
|
|
359
443
|
const chevronInteractiveClassNames = cx(`${prefix}--tile__chevron`, `${prefix}--tile__chevron--interactive`);
|
|
360
444
|
const childrenAsArray = getChildren();
|
|
361
445
|
useIsomorphicEffect(() => {
|
|
@@ -381,10 +465,10 @@ const ExpandableTile = /*#__PURE__*/React__default.forwardRef(function Expandabl
|
|
|
381
465
|
|
|
382
466
|
// Interactive elements or elements that are given a role should be treated
|
|
383
467
|
// the same because elements with a role can not be rendered inside a `button`
|
|
384
|
-
if (!getInteractiveContent(belowTheFold.current) && !getRoleContent(belowTheFold.current) && !getInteractiveContent(aboveTheFold.current) && !getRoleContent(aboveTheFold.current)) {
|
|
468
|
+
if (!getInteractiveContent(belowTheFold.current) && !getRoleContent(belowTheFold.current) && !getInteractiveContent(aboveTheFold.current) && !getRoleContent(aboveTheFold.current) && !slug) {
|
|
385
469
|
setInteractive(false);
|
|
386
470
|
}
|
|
387
|
-
}, []);
|
|
471
|
+
}, [slug]);
|
|
388
472
|
useIsomorphicEffect(() => {
|
|
389
473
|
if (!tile.current) {
|
|
390
474
|
return;
|
|
@@ -407,13 +491,21 @@ const ExpandableTile = /*#__PURE__*/React__default.forwardRef(function Expandabl
|
|
|
407
491
|
return () => resizeObserver.disconnect();
|
|
408
492
|
}, []);
|
|
409
493
|
const belowTheFoldId = useId('expandable-tile-interactive');
|
|
494
|
+
|
|
495
|
+
// Slug is always size `xs`
|
|
496
|
+
let normalizedSlug;
|
|
497
|
+
if (slug) {
|
|
498
|
+
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
499
|
+
size: 'xs'
|
|
500
|
+
});
|
|
501
|
+
}
|
|
410
502
|
return interactive ? /*#__PURE__*/React__default.createElement("div", _extends({
|
|
411
503
|
// @ts-expect-error: Needlesly strict & deep typing for the element type
|
|
412
504
|
ref: ref,
|
|
413
505
|
className: interactiveClassNames
|
|
414
506
|
}, rest), /*#__PURE__*/React__default.createElement("div", {
|
|
415
507
|
ref: tileContent
|
|
416
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
508
|
+
}, normalizedSlug, /*#__PURE__*/React__default.createElement("div", {
|
|
417
509
|
ref: aboveTheFold,
|
|
418
510
|
className: `${prefix}--tile-content`
|
|
419
511
|
}, childrenAsArray[0]), /*#__PURE__*/React__default.createElement("button", {
|
|
@@ -459,6 +551,11 @@ ExpandableTile.propTypes = {
|
|
|
459
551
|
* `true` if the tile is expanded.
|
|
460
552
|
*/
|
|
461
553
|
expanded: PropTypes.bool,
|
|
554
|
+
/**
|
|
555
|
+
* Specify if the `ExpandableTile` component should be rendered with rounded corners.
|
|
556
|
+
* Only valid when `slug` prop is present
|
|
557
|
+
*/
|
|
558
|
+
hasRoundedCorners: PropTypes.bool,
|
|
462
559
|
/**
|
|
463
560
|
* An ID that can be provided to aria-labelledby
|
|
464
561
|
*/
|