@carbon/react 1.114.0-rc.0 → 1.115.0-rc.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 +2816 -1339
- package/es/components/BigNumber/BigNumber.d.ts +82 -0
- package/es/components/BigNumber/BigNumberSkeleton.d.ts +16 -0
- package/es/components/BigNumber/constants.d.ts +19 -0
- package/es/components/BigNumber/index.d.ts +9 -0
- package/es/components/Card/Card.d.ts +48 -0
- package/es/components/Card/Card.js +160 -0
- package/es/components/Card/Card.types.d.ts +119 -0
- package/es/components/Card/CardAction.d.ts +37 -0
- package/es/components/Card/CardAction.js +32 -0
- package/es/components/Card/CardActions.d.ts +30 -0
- package/es/components/Card/CardActions.js +93 -0
- package/es/components/Card/CardBody.d.ts +12 -0
- package/es/components/Card/CardBody.js +35 -0
- package/es/components/Card/CardContext.d.ts +17 -0
- package/es/components/Card/CardContext.js +31 -0
- package/es/components/Card/CardFooter.d.ts +15 -0
- package/es/components/Card/CardFooter.js +45 -0
- package/es/components/Card/CardHeader.d.ts +11 -0
- package/es/components/Card/CardHeader.js +44 -0
- package/es/components/Card/CardHeaderMedia.d.ts +21 -0
- package/es/components/Card/CardHeaderMedia.js +24 -0
- package/es/components/Card/CardMedia.d.ts +35 -0
- package/es/components/Card/CardMedia.js +42 -0
- package/es/components/Card/CardTitle.d.ts +72 -0
- package/es/components/Card/CardTitle.js +86 -0
- package/es/components/Card/CardTitleMedia.d.ts +23 -0
- package/es/components/Card/CardTitleMedia.js +36 -0
- package/es/components/Card/_story-assets/data.d.ts +6 -0
- package/es/components/Card/_story-assets/options.d.ts +47 -0
- package/es/components/Card/index.d.ts +8 -0
- package/es/components/Card/index.js +33 -0
- package/es/components/Checkbox/Checkbox.js +1 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/es/components/ComboBox/ComboBox.js +2 -2
- package/es/components/ComboButton/index.js +1 -1
- package/es/components/ComposedModal/ComposedModal.js +1 -1
- package/es/components/DatePicker/DatePicker.d.ts +1 -1
- package/es/components/DatePicker/DatePicker.js +1 -1
- package/es/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
- package/es/components/DatePickerInput/DatePickerInput.js +1 -1
- package/es/components/Dropdown/Dropdown.js +2 -2
- package/es/components/ExpandableSearch/ExpandableSearch.js +1 -1
- package/es/components/FileUploader/FileUploaderDropContainer.js +11 -5
- package/es/components/FormLabel/FormLabel.d.ts +2 -2
- package/es/components/FormLabel/FormLabel.js +1 -1
- package/es/components/MenuButton/index.js +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +2 -2
- package/es/components/MultiSelect/MultiSelect.js +2 -2
- package/es/components/NumberInput/NumberInput.js +2 -2
- package/es/components/OverflowMenu/next/index.js +1 -1
- package/es/components/RadioButton/RadioButton.js +1 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/es/components/Select/Select.js +1 -1
- package/es/components/Tabs/Tabs.js +13 -2
- package/es/components/Tag/SelectableTag.js +1 -1
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/TextInput/TextInput.js +1 -1
- package/es/components/Tile/Tile.js +1 -1
- package/es/index.d.ts +3 -1
- package/es/index.js +7 -6
- package/es/internal/DisplayBox.d.ts +14 -0
- package/es/internal/getSupportedLocale.d.ts +12 -0
- package/lib/components/BigNumber/BigNumber.d.ts +82 -0
- package/lib/components/BigNumber/BigNumberSkeleton.d.ts +16 -0
- package/lib/components/BigNumber/constants.d.ts +19 -0
- package/lib/components/BigNumber/index.d.ts +9 -0
- package/lib/components/Card/Card.d.ts +48 -0
- package/lib/components/Card/Card.js +173 -0
- package/lib/components/Card/Card.types.d.ts +119 -0
- package/lib/components/Card/CardAction.d.ts +37 -0
- package/lib/components/Card/CardAction.js +41 -0
- package/lib/components/Card/CardActions.d.ts +30 -0
- package/lib/components/Card/CardActions.js +96 -0
- package/lib/components/Card/CardBody.d.ts +12 -0
- package/lib/components/Card/CardBody.js +38 -0
- package/lib/components/Card/CardContext.d.ts +17 -0
- package/lib/components/Card/CardContext.js +32 -0
- package/lib/components/Card/CardFooter.d.ts +15 -0
- package/lib/components/Card/CardFooter.js +48 -0
- package/lib/components/Card/CardHeader.d.ts +11 -0
- package/lib/components/Card/CardHeader.js +47 -0
- package/lib/components/Card/CardHeaderMedia.d.ts +21 -0
- package/lib/components/Card/CardHeaderMedia.js +33 -0
- package/lib/components/Card/CardMedia.d.ts +35 -0
- package/lib/components/Card/CardMedia.js +51 -0
- package/lib/components/Card/CardTitle.d.ts +72 -0
- package/lib/components/Card/CardTitle.js +89 -0
- package/lib/components/Card/CardTitleMedia.d.ts +23 -0
- package/lib/components/Card/CardTitleMedia.js +39 -0
- package/lib/components/Card/_story-assets/data.d.ts +6 -0
- package/lib/components/Card/_story-assets/options.d.ts +47 -0
- package/lib/components/Card/index.d.ts +8 -0
- package/lib/components/Card/index.js +48 -0
- package/lib/components/Checkbox/Checkbox.js +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/lib/components/ComboBox/ComboBox.js +2 -2
- package/lib/components/ComboButton/index.js +1 -1
- package/lib/components/ComposedModal/ComposedModal.js +1 -1
- package/lib/components/DatePicker/DatePicker.d.ts +1 -1
- package/lib/components/DatePicker/DatePicker.js +1 -1
- package/lib/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
- package/lib/components/DatePickerInput/DatePickerInput.js +1 -1
- package/lib/components/Dropdown/Dropdown.js +2 -2
- package/lib/components/ExpandableSearch/ExpandableSearch.js +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.js +11 -5
- package/lib/components/FormLabel/FormLabel.d.ts +2 -2
- package/lib/components/FormLabel/FormLabel.js +1 -1
- package/lib/components/MenuButton/index.js +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +2 -2
- package/lib/components/MultiSelect/MultiSelect.js +2 -2
- package/lib/components/NumberInput/NumberInput.js +2 -2
- package/lib/components/OverflowMenu/next/index.js +1 -1
- package/lib/components/RadioButton/RadioButton.js +1 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/lib/components/Select/Select.js +1 -1
- package/lib/components/Tabs/Tabs.js +13 -2
- package/lib/components/Tag/SelectableTag.js +1 -1
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/TextInput/TextInput.js +1 -1
- package/lib/components/Tile/Tile.js +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +55 -48
- package/lib/internal/DisplayBox.d.ts +14 -0
- package/lib/internal/getSupportedLocale.d.ts +12 -0
- package/package.json +20 -20
- package/scss/_border-radius.scss +9 -0
- package/scss/components/OptionsTile/_index.scss +5 -0
- package/scss/components/OptionsTile/_options-tile.scss +5 -0
- package/scss/components/big-number/_big-number.scss +9 -0
- package/scss/components/big-number/_index.scss +9 -0
- package/scss/components/coachmark/_coachmark.scss +5 -0
- package/scss/components/coachmark/_index.scss +5 -0
- package/scss/components/edit-in-place/_edit-in-place.scss +5 -0
- package/scss/components/edit-in-place/_index.scss +5 -0
- package/scss/components/full-page-error/_full-page-error.scss +5 -0
- package/scss/components/full-page-error/_index.scss +5 -0
- package/scss/components/interstitial-screen/_index.scss +6 -0
- package/scss/components/interstitial-screen/_interstitial-screen.scss +12 -0
- package/scss/components/scroll-gradient/_index.scss +9 -0
- package/scss/components/scroll-gradient/_scroll-gradient.scss +9 -0
- package/scss/components/user-avatar/_index.scss +9 -0
- package/scss/components/user-avatar/_user-avatar.scss +9 -0
- package/telemetry.yml +107 -3
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { CardProps } from './Card.types';
|
|
9
|
+
import { CardHeader } from './CardHeader';
|
|
10
|
+
import { CardBody } from './CardBody';
|
|
11
|
+
import { CardFooter } from './CardFooter';
|
|
12
|
+
import { CardHeaderMedia } from './CardHeaderMedia';
|
|
13
|
+
import { CardMedia } from './CardMedia';
|
|
14
|
+
import { CardTitle } from './CardTitle';
|
|
15
|
+
import { CardTitleMedia } from './CardTitleMedia';
|
|
16
|
+
import { CardActions } from './CardActions';
|
|
17
|
+
import { CardAction } from './CardAction';
|
|
18
|
+
export declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement>> & {
|
|
19
|
+
Header: React.ForwardRefExoticComponent<import("./Card.types").CardBaseProps & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
Body: React.ForwardRefExoticComponent<import("./Card.types").CardBodyProps & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
+
Footer: React.ForwardRefExoticComponent<import("./Card.types").CardBaseProps & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
+
HeaderMedia: {
|
|
23
|
+
({ children, className, ...rest }: import("./CardHeaderMedia").CardHeaderMediaProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
displayName: string;
|
|
25
|
+
};
|
|
26
|
+
Media: {
|
|
27
|
+
({ children, className, ratio, mediaWidth, ...rest }: import("./CardMedia").CardMediaProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
displayName: string;
|
|
29
|
+
};
|
|
30
|
+
Title: React.ForwardRefExoticComponent<import("./CardTitle").CardTitleProps & React.RefAttributes<HTMLDivElement>>;
|
|
31
|
+
TitleMedia: React.ForwardRefExoticComponent<import("./CardTitleMedia").CardTitleMediaProps & React.RefAttributes<HTMLDivElement>>;
|
|
32
|
+
Actions: {
|
|
33
|
+
({ children, className, overflowMenuLabel, ...rest }: import("./CardActions").CardActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
displayName: string;
|
|
35
|
+
};
|
|
36
|
+
Action: {
|
|
37
|
+
({ children, className, ...rest }: import("./CardAction").CardActionProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
displayName: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export { Card as default, CardHeader, CardBody, CardFooter, CardHeaderMedia, CardMedia, CardTitle, CardTitleMedia, CardActions, CardAction, };
|
|
42
|
+
export type { CardProps, CardHeaderProps, CardBodyProps, CardFooterProps, } from './Card.types';
|
|
43
|
+
export type { CardHeaderMediaProps } from './CardHeaderMedia';
|
|
44
|
+
export type { CardMediaProps } from './CardMedia';
|
|
45
|
+
export type { CardTitleProps } from './CardTitle';
|
|
46
|
+
export type { CardTitleMediaProps } from './CardTitleMedia';
|
|
47
|
+
export type { CardActionsProps } from './CardActions';
|
|
48
|
+
export type { CardActionProps } from './CardAction';
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
9
|
+
const require_usePrefix = require("../../internal/usePrefix.js");
|
|
10
|
+
const require_index = require("../AILabel/index.js");
|
|
11
|
+
const require_CardContext = require("./CardContext.js");
|
|
12
|
+
const require_CardHeader = require("./CardHeader.js");
|
|
13
|
+
const require_CardBody = require("./CardBody.js");
|
|
14
|
+
const require_CardFooter = require("./CardFooter.js");
|
|
15
|
+
const require_CardHeaderMedia = require("./CardHeaderMedia.js");
|
|
16
|
+
const require_CardMedia = require("./CardMedia.js");
|
|
17
|
+
const require_CardTitle = require("./CardTitle.js");
|
|
18
|
+
const require_CardTitleMedia = require("./CardTitleMedia.js");
|
|
19
|
+
const require_CardActions = require("./CardActions.js");
|
|
20
|
+
const require_CardAction = require("./CardAction.js");
|
|
21
|
+
let react = require("react");
|
|
22
|
+
react = require_runtime.__toESM(react);
|
|
23
|
+
let classnames = require("classnames");
|
|
24
|
+
classnames = require_runtime.__toESM(classnames);
|
|
25
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
let _carbon_icons_react = require("@carbon/icons-react");
|
|
27
|
+
//#region src/components/Card/Card.tsx
|
|
28
|
+
/**
|
|
29
|
+
* Copyright IBM Corp. 2026
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/
|
|
34
|
+
const componentName = "Card";
|
|
35
|
+
/**
|
|
36
|
+
* Card component - Root container for composable card
|
|
37
|
+
*/
|
|
38
|
+
const CardComponent = (0, react.forwardRef)(({ as, clickable = false, onClick, onKeyDown, disabled = false, density = "productive", decorator, horizontal = false, renderFooterIcon: FooterIcon = _carbon_icons_react.ArrowRight, className, children, ...rest }, ref) => {
|
|
39
|
+
const blockClass = `${require_usePrefix.usePrefix()}--card`;
|
|
40
|
+
const hasAILabel = (0, react.useMemo)(() => (0, react.isValidElement)(decorator) && decorator.type === require_index.AILabel, [decorator]);
|
|
41
|
+
if (FooterIcon !== _carbon_icons_react.ArrowRight && !clickable) console.error("[Card] `renderFooterIcon` only has effect when `clickable` is true.");
|
|
42
|
+
if (clickable && !rest["aria-label"] && !rest["aria-labelledby"]) console.error("[Card] A clickable card must have an accessible name. Pass `aria-label` or `aria-labelledby` to the Card.");
|
|
43
|
+
const contextValue = (0, react.useMemo)(() => ({
|
|
44
|
+
clickable,
|
|
45
|
+
disabled,
|
|
46
|
+
decorator,
|
|
47
|
+
horizontal,
|
|
48
|
+
onClick
|
|
49
|
+
}), [
|
|
50
|
+
clickable,
|
|
51
|
+
disabled,
|
|
52
|
+
decorator,
|
|
53
|
+
horizontal,
|
|
54
|
+
onClick
|
|
55
|
+
]);
|
|
56
|
+
const handleKeyDown = (0, react.useCallback)((event) => {
|
|
57
|
+
if (clickable && !disabled && (event.key === "Enter" || event.key === " ")) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
onClick?.(event);
|
|
60
|
+
}
|
|
61
|
+
onKeyDown?.(event);
|
|
62
|
+
}, [
|
|
63
|
+
clickable,
|
|
64
|
+
disabled,
|
|
65
|
+
onClick,
|
|
66
|
+
onKeyDown
|
|
67
|
+
]);
|
|
68
|
+
const handleClick = (0, react.useCallback)((event) => {
|
|
69
|
+
if (!disabled) onClick?.(event);
|
|
70
|
+
}, [disabled, onClick]);
|
|
71
|
+
const cardClasses = (0, classnames.default)(blockClass, className, {
|
|
72
|
+
[`${blockClass}--clickable`]: clickable && !disabled,
|
|
73
|
+
[`${blockClass}--disabled`]: disabled,
|
|
74
|
+
[`${blockClass}--${density}`]: density,
|
|
75
|
+
[`${blockClass}--has-ai-label`]: hasAILabel,
|
|
76
|
+
[`${blockClass}--horizontal`]: horizontal
|
|
77
|
+
});
|
|
78
|
+
const BaseComponent = as ?? "div";
|
|
79
|
+
const isAnchor = BaseComponent === "a";
|
|
80
|
+
const cardProps = {
|
|
81
|
+
...rest,
|
|
82
|
+
ref,
|
|
83
|
+
className: cardClasses,
|
|
84
|
+
...disabled && { "aria-disabled": true },
|
|
85
|
+
...clickable && { ...isAnchor ? { onClick: handleClick } : {
|
|
86
|
+
role: "button",
|
|
87
|
+
tabIndex: disabled ? -1 : 0,
|
|
88
|
+
onClick: handleClick,
|
|
89
|
+
onKeyDown: handleKeyDown,
|
|
90
|
+
"aria-disabled": disabled
|
|
91
|
+
} }
|
|
92
|
+
};
|
|
93
|
+
const { mediaChildren, contentChildren, mediaIsFirst } = (0, react.useMemo)(() => {
|
|
94
|
+
if (!horizontal) return {
|
|
95
|
+
mediaChildren: [],
|
|
96
|
+
contentChildren: [],
|
|
97
|
+
mediaIsFirst: false
|
|
98
|
+
};
|
|
99
|
+
const childArray = react.default.Children.toArray(children);
|
|
100
|
+
const isMedia = (child) => react.default.isValidElement(child) && child.type === require_CardMedia.CardMedia;
|
|
101
|
+
return {
|
|
102
|
+
mediaChildren: childArray.filter(isMedia),
|
|
103
|
+
contentChildren: childArray.filter((c) => !isMedia(c)),
|
|
104
|
+
mediaIsFirst: childArray.findIndex(isMedia) < childArray.findIndex((c) => !isMedia(c))
|
|
105
|
+
};
|
|
106
|
+
}, [children, horizontal]);
|
|
107
|
+
let renderedChildren = children;
|
|
108
|
+
if (horizontal) {
|
|
109
|
+
const contentWrapper = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
110
|
+
className: `${blockClass}__content`,
|
|
111
|
+
children: contentChildren
|
|
112
|
+
});
|
|
113
|
+
renderedChildren = mediaIsFirst ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [mediaChildren, contentWrapper] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [contentWrapper, mediaChildren] });
|
|
114
|
+
}
|
|
115
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CardContext.CardContext.Provider, {
|
|
116
|
+
value: contextValue,
|
|
117
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(BaseComponent, {
|
|
118
|
+
...cardProps,
|
|
119
|
+
children: [renderedChildren, clickable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
120
|
+
className: `${blockClass}__clickable-footer`,
|
|
121
|
+
"aria-hidden": "true",
|
|
122
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FooterIcon, { "aria-hidden": "true" })
|
|
123
|
+
})]
|
|
124
|
+
})
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
CardComponent.displayName = componentName;
|
|
128
|
+
/**
|
|
129
|
+
* -------
|
|
130
|
+
* Exports
|
|
131
|
+
* -------
|
|
132
|
+
*/
|
|
133
|
+
const Header = require_CardHeader.CardHeader;
|
|
134
|
+
Header.displayName = "Card.Header";
|
|
135
|
+
const Body = require_CardBody.CardBody;
|
|
136
|
+
Body.displayName = "Card.Body";
|
|
137
|
+
const Footer = require_CardFooter.CardFooter;
|
|
138
|
+
Footer.displayName = "Card.Footer";
|
|
139
|
+
const HeaderMedia = require_CardHeaderMedia.CardHeaderMedia;
|
|
140
|
+
HeaderMedia.displayName = "Card.HeaderMedia";
|
|
141
|
+
const Media = require_CardMedia.CardMedia;
|
|
142
|
+
Media.displayName = "Card.Media";
|
|
143
|
+
const Title = require_CardTitle.CardTitle;
|
|
144
|
+
Title.displayName = "Card.Title";
|
|
145
|
+
const TitleMedia = require_CardTitleMedia.CardTitleMedia;
|
|
146
|
+
TitleMedia.displayName = "Card.TitleMedia";
|
|
147
|
+
const Actions = require_CardActions.CardActions;
|
|
148
|
+
Actions.displayName = "Card.Actions";
|
|
149
|
+
const Action = require_CardAction.CardAction;
|
|
150
|
+
Action.displayName = "Card.Action";
|
|
151
|
+
const Card = Object.assign(CardComponent, {
|
|
152
|
+
Header,
|
|
153
|
+
Body,
|
|
154
|
+
Footer,
|
|
155
|
+
HeaderMedia,
|
|
156
|
+
Media,
|
|
157
|
+
Title,
|
|
158
|
+
TitleMedia,
|
|
159
|
+
Actions,
|
|
160
|
+
Action
|
|
161
|
+
});
|
|
162
|
+
//#endregion
|
|
163
|
+
exports.Card = Card;
|
|
164
|
+
exports.default = Card;
|
|
165
|
+
exports.CardAction = require_CardAction.CardAction;
|
|
166
|
+
exports.CardActions = require_CardActions.CardActions;
|
|
167
|
+
exports.CardBody = require_CardBody.CardBody;
|
|
168
|
+
exports.CardFooter = require_CardFooter.CardFooter;
|
|
169
|
+
exports.CardHeader = require_CardHeader.CardHeader;
|
|
170
|
+
exports.CardHeaderMedia = require_CardHeaderMedia.CardHeaderMedia;
|
|
171
|
+
exports.CardMedia = require_CardMedia.CardMedia;
|
|
172
|
+
exports.CardTitle = require_CardTitle.CardTitle;
|
|
173
|
+
exports.CardTitleMedia = require_CardTitleMedia.CardTitleMedia;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React, { ReactNode } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* Base props shared across card components
|
|
10
|
+
*/
|
|
11
|
+
export interface CardBaseProps {
|
|
12
|
+
/**
|
|
13
|
+
* Additional CSS class names
|
|
14
|
+
*/
|
|
15
|
+
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Card content
|
|
18
|
+
*/
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Props for the Card root component
|
|
23
|
+
*/
|
|
24
|
+
export interface CardProps extends CardBaseProps {
|
|
25
|
+
/**
|
|
26
|
+
* The underlying element or component to render the card as.
|
|
27
|
+
* Defaults to `'div'`. Use `'a'` or a router Link component for
|
|
28
|
+
* navigation cards when combined with `clickable`.
|
|
29
|
+
* @example <Card as="a" clickable href="/dashboard">...</Card>
|
|
30
|
+
* @example <Card as={RouterLink} clickable to="/dashboard">...</Card>
|
|
31
|
+
*/
|
|
32
|
+
as?: React.ElementType;
|
|
33
|
+
/**
|
|
34
|
+
* Makes the entire card clickable. When true, the card gains interactive
|
|
35
|
+
* styles (hover, focus, active) and renders a built-in footer affordance
|
|
36
|
+
* with an arrow icon. Use `onClick` for action cards or `as="a"` with
|
|
37
|
+
* `href` for navigation cards.
|
|
38
|
+
*/
|
|
39
|
+
clickable?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Click handler for clickable cards. Only has effect when `clickable`
|
|
42
|
+
* is true.
|
|
43
|
+
*/
|
|
44
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Keyboard event handler. Only has effect when `clickable` is true.
|
|
47
|
+
*/
|
|
48
|
+
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Disables the card and all interactive elements
|
|
51
|
+
*/
|
|
52
|
+
disabled?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Density variant: productive uses heading-compact-02, expressive uses heading-03
|
|
55
|
+
*/
|
|
56
|
+
density?: 'productive' | 'expressive';
|
|
57
|
+
/**
|
|
58
|
+
* Optional decorator component (typically AILabel from Carbon).
|
|
59
|
+
* Renders in the top-right corner of the card header with a blue gradient border.
|
|
60
|
+
*/
|
|
61
|
+
decorator?: ReactNode;
|
|
62
|
+
/**
|
|
63
|
+
* When true, the card renders in a horizontal layout: media on the left,
|
|
64
|
+
* header/body/footer stacked vertically on the right.
|
|
65
|
+
*/
|
|
66
|
+
horizontal?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Icon rendered in the built-in footer affordance of a clickable card.
|
|
69
|
+
* Only has effect when `clickable` is true. Defaults to ArrowRight.
|
|
70
|
+
* Pass any icon component from `@carbon/icons-react`.
|
|
71
|
+
* @example <Card clickable renderFooterIcon={Launch}>...</Card>
|
|
72
|
+
*/
|
|
73
|
+
renderFooterIcon?: React.ElementType;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Props for CardHeader component
|
|
77
|
+
*/
|
|
78
|
+
export type CardHeaderProps = CardBaseProps;
|
|
79
|
+
/**
|
|
80
|
+
* Props for CardBody component
|
|
81
|
+
*/
|
|
82
|
+
export interface CardBodyProps extends CardBaseProps {
|
|
83
|
+
/**
|
|
84
|
+
* When true, removes all padding so content fills the body edge-to-edge.
|
|
85
|
+
* Use when the body contains a component (e.g. a table, chart, or image)
|
|
86
|
+
* that manages its own internal spacing.
|
|
87
|
+
*/
|
|
88
|
+
isFlush?: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Props for CardFooter component
|
|
92
|
+
*/
|
|
93
|
+
export type CardFooterProps = CardBaseProps;
|
|
94
|
+
/**
|
|
95
|
+
* Context value for Card
|
|
96
|
+
*/
|
|
97
|
+
export interface CardContextValue {
|
|
98
|
+
/**
|
|
99
|
+
* Whether the card is clickable
|
|
100
|
+
*/
|
|
101
|
+
clickable: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Whether the card is disabled
|
|
104
|
+
*/
|
|
105
|
+
disabled: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Optional decorator component (typically AILabel) to be rendered by CardHeader
|
|
108
|
+
*/
|
|
109
|
+
decorator?: ReactNode;
|
|
110
|
+
/**
|
|
111
|
+
* Whether the card is in horizontal layout mode
|
|
112
|
+
*/
|
|
113
|
+
horizontal?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Click handler forwarded from the Card root, available to child components
|
|
116
|
+
* (e.g. the built-in clickable footer affordance).
|
|
117
|
+
*/
|
|
118
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
119
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { ReactNode } from 'react';
|
|
8
|
+
export interface CardActionProps {
|
|
9
|
+
/**
|
|
10
|
+
* Provide the contents of the CardAction (typically a Button or IconButton).
|
|
11
|
+
* Wrapping content in CardAction opts into action-set layout: no footer
|
|
12
|
+
* padding, automatic top border, and stretch/fixed-width button behavior.
|
|
13
|
+
*/
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Provide an optional class to be applied to the containing node.
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Label shown in the overflow menu when this action is hidden.
|
|
21
|
+
* If not provided, CardActions will attempt to read it from the
|
|
22
|
+
* direct child's props (label, iconDescription, or children text).
|
|
23
|
+
*/
|
|
24
|
+
label?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* CardAction is a wrapper for interactive elements in the card footer.
|
|
28
|
+
* Its presence signals action-set layout to the footer (no padding, auto
|
|
29
|
+
* border, stretch behavior).
|
|
30
|
+
*
|
|
31
|
+
* Note: do not use CardAction inside a clickable card — clickable cards
|
|
32
|
+
* should not contain interactive elements (see usage guidelines).
|
|
33
|
+
*/
|
|
34
|
+
export declare const CardAction: {
|
|
35
|
+
({ children, className, ...rest }: CardActionProps): import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
displayName: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
9
|
+
const require_usePrefix = require("../../internal/usePrefix.js");
|
|
10
|
+
let react = require("react");
|
|
11
|
+
react = require_runtime.__toESM(react);
|
|
12
|
+
let classnames = require("classnames");
|
|
13
|
+
classnames = require_runtime.__toESM(classnames);
|
|
14
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
|
+
//#region src/components/Card/CardAction.tsx
|
|
16
|
+
/**
|
|
17
|
+
* Copyright IBM Corp. 2026
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
const componentName = "CardAction";
|
|
23
|
+
/**
|
|
24
|
+
* CardAction is a wrapper for interactive elements in the card footer.
|
|
25
|
+
* Its presence signals action-set layout to the footer (no padding, auto
|
|
26
|
+
* border, stretch behavior).
|
|
27
|
+
*
|
|
28
|
+
* Note: do not use CardAction inside a clickable card — clickable cards
|
|
29
|
+
* should not contain interactive elements (see usage guidelines).
|
|
30
|
+
*/
|
|
31
|
+
const CardAction = ({ children, className, ...rest }) => {
|
|
32
|
+
const prefix = require_usePrefix.usePrefix();
|
|
33
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
34
|
+
...rest,
|
|
35
|
+
className: (0, classnames.default)(`${prefix}--card__action`, className),
|
|
36
|
+
children
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
CardAction.displayName = componentName;
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.CardAction = CardAction;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { ReactNode } from 'react';
|
|
8
|
+
export interface CardActionsProps {
|
|
9
|
+
/**
|
|
10
|
+
* Provide the contents of the CardActions (typically CardAction components).
|
|
11
|
+
*/
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Provide an optional class to be applied to the containing node.
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Aria label for the overflow menu
|
|
19
|
+
*/
|
|
20
|
+
overflowMenuLabel?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* CardActions is a container for action buttons in the card header.
|
|
24
|
+
* Positioned in the top-right corner with 8px gap between actions.
|
|
25
|
+
* When actions exceed 50% of available header space, overflow menu is shown.
|
|
26
|
+
*/
|
|
27
|
+
export declare const CardActions: {
|
|
28
|
+
({ children, className, overflowMenuLabel, ...rest }: CardActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
displayName: string;
|
|
30
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
9
|
+
const require_usePrefix = require("../../internal/usePrefix.js");
|
|
10
|
+
const require_MenuItem = require("../Menu/MenuItem.js");
|
|
11
|
+
const require_index = require("../OverflowMenu/next/index.js");
|
|
12
|
+
let react = require("react");
|
|
13
|
+
react = require_runtime.__toESM(react);
|
|
14
|
+
let classnames = require("classnames");
|
|
15
|
+
classnames = require_runtime.__toESM(classnames);
|
|
16
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
17
|
+
let _carbon_utilities = require("@carbon/utilities");
|
|
18
|
+
//#region src/components/Card/CardActions.tsx
|
|
19
|
+
/**
|
|
20
|
+
* Copyright IBM Corp. 2026
|
|
21
|
+
*
|
|
22
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
23
|
+
* LICENSE file in the root directory of this source tree.
|
|
24
|
+
*/
|
|
25
|
+
const componentName = "CardActions";
|
|
26
|
+
/**
|
|
27
|
+
* CardActions is a container for action buttons in the card header.
|
|
28
|
+
* Positioned in the top-right corner with 8px gap between actions.
|
|
29
|
+
* When actions exceed 50% of available header space, overflow menu is shown.
|
|
30
|
+
*/
|
|
31
|
+
const CardActions = ({ children, className, overflowMenuLabel = "More actions", ...rest }) => {
|
|
32
|
+
const blockClass = `${require_usePrefix.usePrefix()}--card`;
|
|
33
|
+
const containerRef = (0, react.useRef)(null);
|
|
34
|
+
const [hiddenItems, setHiddenItems] = (0, react.useState)([]);
|
|
35
|
+
const classes = (0, classnames.default)(`${blockClass}__actions`, className);
|
|
36
|
+
const actionItems = (0, react.useMemo)(() => {
|
|
37
|
+
const items = [];
|
|
38
|
+
react.Children.forEach(children, (child, index) => {
|
|
39
|
+
if (react.default.isValidElement(child)) {
|
|
40
|
+
const actionProps = child.props;
|
|
41
|
+
const button = actionProps.children;
|
|
42
|
+
const buttonProps = react.default.isValidElement(button) ? button.props : null;
|
|
43
|
+
const label = actionProps.label ?? buttonProps?.label ?? buttonProps?.iconDescription ?? (typeof buttonProps?.children === "string" ? buttonProps.children : `Action ${index + 1}`);
|
|
44
|
+
const id = `${label}-${index}`;
|
|
45
|
+
items.push({
|
|
46
|
+
id,
|
|
47
|
+
element: child,
|
|
48
|
+
label
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return items;
|
|
53
|
+
}, [children]);
|
|
54
|
+
(0, react.useEffect)(() => {
|
|
55
|
+
if (!containerRef.current || actionItems.length === 0) return;
|
|
56
|
+
const handler = (0, _carbon_utilities.createOverflowHandler)({
|
|
57
|
+
container: containerRef.current,
|
|
58
|
+
onChange: (_visible, hidden) => {
|
|
59
|
+
const hiddenIds = hidden.map((el) => el.dataset.id);
|
|
60
|
+
setHiddenItems(actionItems.filter((item) => hiddenIds.includes(item.id)));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return () => handler.disconnect();
|
|
64
|
+
}, [actionItems]);
|
|
65
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
66
|
+
ref: containerRef,
|
|
67
|
+
className: classes,
|
|
68
|
+
...rest,
|
|
69
|
+
children: [actionItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
70
|
+
"data-id": item.id,
|
|
71
|
+
children: item.element
|
|
72
|
+
}, item.id)), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
73
|
+
"data-offset": true,
|
|
74
|
+
"data-hidden": true,
|
|
75
|
+
"data-floating-menu-container": true,
|
|
76
|
+
style: { position: "relative" },
|
|
77
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.OverflowMenu, {
|
|
78
|
+
size: "sm",
|
|
79
|
+
label: overflowMenuLabel,
|
|
80
|
+
children: hiddenItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MenuItem.MenuItem, {
|
|
81
|
+
label: item.label || "Action",
|
|
82
|
+
onClick: () => {
|
|
83
|
+
const button = item.element.props.children;
|
|
84
|
+
if (button && react.default.isValidElement(button)) {
|
|
85
|
+
const buttonProps = button.props;
|
|
86
|
+
if (buttonProps.onClick) buttonProps.onClick();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, item.id))
|
|
90
|
+
})
|
|
91
|
+
})]
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
CardActions.displayName = componentName;
|
|
95
|
+
//#endregion
|
|
96
|
+
exports.CardActions = CardActions;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { CardBodyProps } from './Card.types';
|
|
9
|
+
/**
|
|
10
|
+
* CardBody component - Body section of the card for free-form content
|
|
11
|
+
*/
|
|
12
|
+
export declare const CardBody: React.ForwardRefExoticComponent<CardBodyProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
9
|
+
const require_usePrefix = require("../../internal/usePrefix.js");
|
|
10
|
+
let react = require("react");
|
|
11
|
+
react = require_runtime.__toESM(react);
|
|
12
|
+
let classnames = require("classnames");
|
|
13
|
+
classnames = require_runtime.__toESM(classnames);
|
|
14
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
|
+
//#region src/components/Card/CardBody.tsx
|
|
16
|
+
/**
|
|
17
|
+
* Copyright IBM Corp. 2026
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
const componentName = "CardBody";
|
|
23
|
+
/**
|
|
24
|
+
* CardBody component - Body section of the card for free-form content
|
|
25
|
+
*/
|
|
26
|
+
const CardBody = (0, react.forwardRef)(({ className, children, isFlush = false, ...rest }, ref) => {
|
|
27
|
+
const prefix = require_usePrefix.usePrefix();
|
|
28
|
+
const bodyClasses = (0, classnames.default)(`${prefix}--card__body`, className, { [`${prefix}--card__body--flush`]: isFlush });
|
|
29
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
30
|
+
...rest,
|
|
31
|
+
ref,
|
|
32
|
+
className: bodyClasses,
|
|
33
|
+
children
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
CardBody.displayName = componentName;
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.CardBody = CardBody;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { CardContextValue } from './Card.types';
|
|
8
|
+
/**
|
|
9
|
+
* Context for sharing Card state with child components
|
|
10
|
+
*/
|
|
11
|
+
export declare const CardContext: import("react").Context<CardContextValue | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* Hook to access Card context
|
|
14
|
+
* @returns CardContextValue
|
|
15
|
+
* @throws Error if used outside of Card component
|
|
16
|
+
*/
|
|
17
|
+
export declare const useCardContext: () => CardContextValue;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
let react = require("react");
|
|
9
|
+
//#region src/components/Card/CardContext.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Copyright IBM Corp. 2026
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Context for sharing Card state with child components
|
|
18
|
+
*/
|
|
19
|
+
const CardContext = (0, react.createContext)(void 0);
|
|
20
|
+
/**
|
|
21
|
+
* Hook to access Card context
|
|
22
|
+
* @returns CardContextValue
|
|
23
|
+
* @throws Error if used outside of Card component
|
|
24
|
+
*/
|
|
25
|
+
const useCardContext = () => {
|
|
26
|
+
const context = (0, react.useContext)(CardContext);
|
|
27
|
+
if (!context) throw new Error("Card subcomponents must be used within a Card component");
|
|
28
|
+
return context;
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.CardContext = CardContext;
|
|
32
|
+
exports.useCardContext = useCardContext;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* CardFooter component - Footer section of the card.
|
|
10
|
+
*
|
|
11
|
+
* Not supported inside a `clickable` card. A clickable card renders its own
|
|
12
|
+
* built-in footer affordance automatically. Use the `renderFooterIcon` prop on
|
|
13
|
+
* `Card` to customize the icon.
|
|
14
|
+
*/
|
|
15
|
+
export declare const CardFooter: React.ForwardRefExoticComponent<import("./Card.types").CardBaseProps & React.RefAttributes<HTMLDivElement>>;
|