@carbon/react 1.114.0 → 1.115.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 +2700 -1188
- package/es/components/Accordion/AccordionItem.d.ts +5 -0
- package/es/components/Accordion/AccordionItem.js +0 -6
- 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 +1 -1
- package/es/components/Card/Card.js +19 -7
- package/es/components/Card/Card.types.d.ts +38 -7
- package/es/components/Card/CardActions.js +1 -1
- package/es/components/Card/CardBody.d.ts +2 -1
- package/es/components/Card/CardBody.js +3 -2
- package/es/components/Card/CardFooter.d.ts +5 -1
- package/es/components/Card/CardFooter.js +13 -2
- package/es/components/Card/CardTitle.d.ts +1 -1
- package/es/components/ComboBox/ComboBox.js +2 -2
- package/es/components/ComposedModal/ComposedModal.js +2 -2
- package/es/components/ContentSwitcher/ContentSwitcher.js +2 -2
- package/es/components/DatePicker/DatePicker.d.ts +1 -1
- package/es/components/DatePicker/DatePicker.js +2 -2
- package/es/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
- package/es/components/FileUploader/FileUploader.js +1 -1
- package/es/components/FileUploader/FileUploaderButton.js +2 -2
- package/es/components/FileUploader/FileUploaderDropContainer.js +13 -7
- package/es/components/FileUploader/FileUploaderItem.js +2 -2
- package/es/components/FormLabel/FormLabel.d.ts +2 -2
- package/es/components/FormLabel/FormLabel.js +1 -1
- package/es/components/Loading/Loading.js +82 -2
- package/es/components/Menu/Menu.js +2 -2
- package/es/components/Menu/MenuItem.js +2 -2
- package/es/components/Modal/Modal.js +3 -3
- package/es/components/MultiSelect/FilterableMultiSelect.js +2 -2
- package/es/components/MultiSelect/MultiSelect.js +2 -2
- package/es/components/Notification/Notification.js +2 -2
- package/es/components/NumberInput/NumberInput.js +2 -2
- package/es/components/OverflowMenu/OverflowMenu.js +2 -2
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +1 -1
- package/es/components/Pagination/Pagination.d.ts +1 -1
- package/es/components/Pagination/Pagination.js +52 -53
- package/es/components/Popover/index.js +1 -1
- package/es/components/RadioTile/RadioTile.js +2 -2
- package/es/components/Search/Search.js +2 -2
- package/es/components/Slider/Slider.js +2 -2
- package/es/components/Tabs/Tabs.js +15 -4
- package/es/components/Tile/Tile.js +3 -3
- package/es/components/Toggletip/index.js +2 -2
- package/es/components/Tooltip/DefinitionTooltip.js +2 -2
- package/es/components/Tooltip/Tooltip.js +2 -2
- package/es/components/TreeView/TreeNode.js +2 -2
- package/es/components/TreeView/TreeView.js +1 -1
- package/es/components/UIShell/HeaderContainer.js +1 -1
- package/es/components/UIShell/HeaderMenu.js +2 -2
- package/es/components/UIShell/HeaderPanel.js +2 -2
- package/es/components/UIShell/SideNav.js +2 -2
- package/es/index.d.ts +2 -1
- package/es/index.js +1 -1
- package/es/internal/DisplayBox.d.ts +14 -0
- package/es/internal/getSupportedLocale.d.ts +12 -0
- package/lib/components/Accordion/AccordionItem.d.ts +5 -0
- package/lib/components/Accordion/AccordionItem.js +0 -6
- 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 +1 -1
- package/lib/components/Card/Card.js +19 -7
- package/lib/components/Card/Card.types.d.ts +38 -7
- package/lib/components/Card/CardActions.js +1 -1
- package/lib/components/Card/CardBody.d.ts +2 -1
- package/lib/components/Card/CardBody.js +3 -2
- package/lib/components/Card/CardFooter.d.ts +5 -1
- package/lib/components/Card/CardFooter.js +13 -2
- package/lib/components/Card/CardTitle.d.ts +1 -1
- package/lib/components/ComboBox/ComboBox.js +2 -2
- package/lib/components/ComposedModal/ComposedModal.js +2 -2
- package/lib/components/ContentSwitcher/ContentSwitcher.js +2 -2
- package/lib/components/DatePicker/DatePicker.d.ts +1 -1
- package/lib/components/DatePicker/DatePicker.js +2 -2
- package/lib/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
- package/lib/components/FileUploader/FileUploader.js +1 -1
- package/lib/components/FileUploader/FileUploaderButton.js +2 -2
- package/lib/components/FileUploader/FileUploaderDropContainer.js +13 -7
- package/lib/components/FileUploader/FileUploaderItem.js +2 -2
- package/lib/components/FormLabel/FormLabel.d.ts +2 -2
- package/lib/components/FormLabel/FormLabel.js +1 -1
- package/lib/components/Loading/Loading.js +81 -1
- package/lib/components/Menu/Menu.js +2 -2
- package/lib/components/Menu/MenuItem.js +2 -2
- package/lib/components/Modal/Modal.js +3 -3
- package/lib/components/MultiSelect/FilterableMultiSelect.js +2 -2
- package/lib/components/MultiSelect/MultiSelect.js +2 -2
- package/lib/components/Notification/Notification.js +2 -2
- package/lib/components/NumberInput/NumberInput.js +2 -2
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -2
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +1 -1
- package/lib/components/Pagination/Pagination.d.ts +1 -1
- package/lib/components/Pagination/Pagination.js +52 -53
- package/lib/components/Popover/index.js +1 -1
- package/lib/components/RadioTile/RadioTile.js +2 -2
- package/lib/components/Search/Search.js +2 -2
- package/lib/components/Slider/Slider.js +2 -2
- package/lib/components/Tabs/Tabs.js +15 -4
- package/lib/components/Tile/Tile.js +3 -3
- package/lib/components/Toggletip/index.js +2 -2
- package/lib/components/Tooltip/DefinitionTooltip.js +2 -2
- package/lib/components/Tooltip/Tooltip.js +2 -2
- package/lib/components/TreeView/TreeNode.js +2 -2
- package/lib/components/TreeView/TreeView.js +1 -1
- package/lib/components/UIShell/HeaderContainer.js +1 -1
- package/lib/components/UIShell/HeaderMenu.js +2 -2
- package/lib/components/UIShell/HeaderPanel.js +2 -2
- package/lib/components/UIShell/SideNav.js +2 -2
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -1
- package/lib/internal/DisplayBox.d.ts +14 -0
- package/lib/internal/getSupportedLocale.d.ts +12 -0
- package/package.json +21 -21
- 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 +91 -3
|
@@ -61,6 +61,11 @@ export interface AccordionToggleProps {
|
|
|
61
61
|
className?: string;
|
|
62
62
|
disabled?: boolean;
|
|
63
63
|
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated `AccordionItem` no longer passes an `onKeyDown` handler to
|
|
66
|
+
* the toggle. This prop is kept only so custom `renderToggle`
|
|
67
|
+
* implementations that reference it don't hit a breaking type change.
|
|
68
|
+
*/
|
|
64
69
|
onKeyDown?: (event: KeyboardEvent<HTMLButtonElement>) => void;
|
|
65
70
|
type?: 'button';
|
|
66
71
|
}
|
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
9
9
|
import { AccordionContext } from "./AccordionProvider.js";
|
|
10
10
|
import { Text } from "../Text/Text.js";
|
|
11
|
-
import { Escape } from "../../internal/keyboard/keys.js";
|
|
12
|
-
import { match } from "../../internal/keyboard/match.js";
|
|
13
11
|
import { useId } from "../../internal/useId.js";
|
|
14
12
|
import { deprecate } from "../../prop-types/deprecate.js";
|
|
15
13
|
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
@@ -60,9 +58,6 @@ function AccordionItem({ children, className: customClassName = "", open = false
|
|
|
60
58
|
event
|
|
61
59
|
});
|
|
62
60
|
}
|
|
63
|
-
function onKeyDown(event) {
|
|
64
|
-
if (isOpen && match(event, Escape)) setIsOpen(false);
|
|
65
|
-
}
|
|
66
61
|
function onAnimationEnd(event) {
|
|
67
62
|
if (handleAnimationEnd) handleAnimationEnd(event);
|
|
68
63
|
}
|
|
@@ -76,7 +71,6 @@ function AccordionItem({ children, className: customClassName = "", open = false
|
|
|
76
71
|
"aria-label": ariaLabel,
|
|
77
72
|
className: `${prefix}--accordion__heading`,
|
|
78
73
|
onClick,
|
|
79
|
-
onKeyDown,
|
|
80
74
|
type: "button",
|
|
81
75
|
children: [/* @__PURE__ */ jsx(ChevronRight, { className: `${prefix}--accordion__arrow` }), /* @__PURE__ */ jsx(Text, {
|
|
82
76
|
as: "div",
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
import { BigNumberSizeValues } from './constants';
|
|
9
|
+
export interface BigNumberProps {
|
|
10
|
+
/**
|
|
11
|
+
* Provide an optional class to be applied to the containing node.
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The default behavior will hide `total` if `undefined` or is the same as `value`.
|
|
16
|
+
*
|
|
17
|
+
* Set to `true` to ignore the default behavior and show the `total`.
|
|
18
|
+
*/
|
|
19
|
+
forceShowTotal?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Specifies the number of fraction digits when truncating `value` and `total`.
|
|
22
|
+
*/
|
|
23
|
+
fractionDigits?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Displays an icon button next to `value`.
|
|
26
|
+
*/
|
|
27
|
+
iconButton?: ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Text label above the `value`.
|
|
30
|
+
*/
|
|
31
|
+
label: string;
|
|
32
|
+
/**
|
|
33
|
+
* When `true`, will show the loading state.
|
|
34
|
+
*/
|
|
35
|
+
loading?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Determines how `value` and `total` will be formatted.
|
|
38
|
+
*/
|
|
39
|
+
locale?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Appends a percent sign (_%_) after `value` and hides `total`.
|
|
42
|
+
*/
|
|
43
|
+
percentage?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Controls the visual size of the component.
|
|
46
|
+
*/
|
|
47
|
+
size?: BigNumberSizeValues;
|
|
48
|
+
/**
|
|
49
|
+
* When applied, an information icon will be rendered next to the
|
|
50
|
+
* `label` and the description will be applied to its tooltip.
|
|
51
|
+
*/
|
|
52
|
+
tooltipDescription?: string;
|
|
53
|
+
/**
|
|
54
|
+
* The number that will appear after the slash (i.e. the "denominator" of a fraction).
|
|
55
|
+
*
|
|
56
|
+
* This number will not be rendered if it's the same as `value` or
|
|
57
|
+
* `percentage` is true. See also the **forceShowTotal** prop.
|
|
58
|
+
*/
|
|
59
|
+
total?: number;
|
|
60
|
+
/**
|
|
61
|
+
* When `true`, will render a "trending up" icon.
|
|
62
|
+
*/
|
|
63
|
+
trending?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Abbreviates the number when `true`. E.g. from _1,000_ to _1K_.
|
|
66
|
+
*/
|
|
67
|
+
truncate?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The primary value to display (or the "numerator" of a fraction).
|
|
70
|
+
*/
|
|
71
|
+
value?: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* BigNumber is used to display large values in a small area. The display of
|
|
75
|
+
* values can be the value itself, or grouped in a `numerator/denominator` fashion.
|
|
76
|
+
* Control over the total fraction decimals displayed as well as how the
|
|
77
|
+
* values/totals are displayed are done via a locale prop. Other optional props
|
|
78
|
+
* allow control over size, truncation, if the value is a percentage, the addition
|
|
79
|
+
* of a button as well as tooltip functionality.
|
|
80
|
+
* The default locale is English (`en-US`) if one is not provided or if the provided one is not supported.
|
|
81
|
+
*/
|
|
82
|
+
export declare const BigNumber: React.ForwardRefExoticComponent<BigNumberProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { BigNumberProps } from './BigNumber';
|
|
9
|
+
/**
|
|
10
|
+
* BigNumberSkeleton is used to display a skeleton version while
|
|
11
|
+
* content is loading (handled by the BigNumber prop `loading`).
|
|
12
|
+
*
|
|
13
|
+
* Note: This component is only used within BigNumber.
|
|
14
|
+
*/
|
|
15
|
+
export type BigNumberSkeletonProps = Pick<BigNumberProps, 'className' | 'size'> & React.HTMLAttributes<HTMLDivElement>;
|
|
16
|
+
export declare const BigNumberSkeleton: React.ForwardRefExoticComponent<Pick<BigNumberProps, "className" | "size"> & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
export declare enum BigNumberSize {
|
|
8
|
+
Default = "default",
|
|
9
|
+
Large = "lg",
|
|
10
|
+
XLarge = "xl"
|
|
11
|
+
}
|
|
12
|
+
export type BigNumberSizeValues = `${BigNumberSize}`;
|
|
13
|
+
export declare enum Characters {
|
|
14
|
+
Dash = "\u2013",
|
|
15
|
+
Slash = "/"
|
|
16
|
+
}
|
|
17
|
+
export declare const DefaultLocale = "en-US";
|
|
18
|
+
export declare const formatValue: (locale: Intl.LocalesArgument, value: number | null | undefined, fractionDigits: number, truncate: boolean) => string | null | undefined;
|
|
19
|
+
export declare const getIconSize: (size: BigNumberSizeValues) => number;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export { BigNumber } from './BigNumber';
|
|
8
|
+
export type { BigNumberProps } from './BigNumber';
|
|
9
|
+
export { BigNumberSkeleton } from './BigNumberSkeleton';
|
|
@@ -17,7 +17,7 @@ import { CardActions } from './CardActions';
|
|
|
17
17
|
import { CardAction } from './CardAction';
|
|
18
18
|
export declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement>> & {
|
|
19
19
|
Header: React.ForwardRefExoticComponent<import("./Card.types").CardBaseProps & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
-
Body: React.ForwardRefExoticComponent<import("./Card.types").
|
|
20
|
+
Body: React.ForwardRefExoticComponent<import("./Card.types").CardBodyProps & React.RefAttributes<HTMLDivElement>>;
|
|
21
21
|
Footer: React.ForwardRefExoticComponent<import("./Card.types").CardBaseProps & React.RefAttributes<HTMLDivElement>>;
|
|
22
22
|
HeaderMedia: {
|
|
23
23
|
({ children, className, ...rest }: import("./CardHeaderMedia").CardHeaderMediaProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -20,6 +20,7 @@ import { CardAction } from "./CardAction.js";
|
|
|
20
20
|
import React, { forwardRef, isValidElement, useCallback, useMemo } from "react";
|
|
21
21
|
import cx from "classnames";
|
|
22
22
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
import { ArrowRight } from "@carbon/icons-react";
|
|
23
24
|
//#region src/components/Card/Card.tsx
|
|
24
25
|
/**
|
|
25
26
|
* Copyright IBM Corp. 2026
|
|
@@ -31,19 +32,23 @@ const componentName = "Card";
|
|
|
31
32
|
/**
|
|
32
33
|
* Card component - Root container for composable card
|
|
33
34
|
*/
|
|
34
|
-
const CardComponent = forwardRef(({ clickable = false, onClick, onKeyDown, disabled = false, density = "productive", decorator, horizontal = false, className, children, ...rest }, ref) => {
|
|
35
|
+
const CardComponent = forwardRef(({ as, clickable = false, onClick, onKeyDown, disabled = false, density = "productive", decorator, horizontal = false, renderFooterIcon: FooterIcon = ArrowRight, className, children, ...rest }, ref) => {
|
|
35
36
|
const blockClass = `${usePrefix()}--card`;
|
|
36
37
|
const hasAILabel = useMemo(() => isValidElement(decorator) && decorator.type === AILabel, [decorator]);
|
|
38
|
+
if (FooterIcon !== ArrowRight && !clickable) console.error("[Card] `renderFooterIcon` only has effect when `clickable` is true.");
|
|
39
|
+
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.");
|
|
37
40
|
const contextValue = useMemo(() => ({
|
|
38
41
|
clickable,
|
|
39
42
|
disabled,
|
|
40
43
|
decorator,
|
|
41
|
-
horizontal
|
|
44
|
+
horizontal,
|
|
45
|
+
onClick
|
|
42
46
|
}), [
|
|
43
47
|
clickable,
|
|
44
48
|
disabled,
|
|
45
49
|
decorator,
|
|
46
|
-
horizontal
|
|
50
|
+
horizontal,
|
|
51
|
+
onClick
|
|
47
52
|
]);
|
|
48
53
|
const handleKeyDown = useCallback((event) => {
|
|
49
54
|
if (clickable && !disabled && (event.key === "Enter" || event.key === " ")) {
|
|
@@ -67,17 +72,20 @@ const CardComponent = forwardRef(({ clickable = false, onClick, onKeyDown, disab
|
|
|
67
72
|
[`${blockClass}--has-ai-label`]: hasAILabel,
|
|
68
73
|
[`${blockClass}--horizontal`]: horizontal
|
|
69
74
|
});
|
|
75
|
+
const BaseComponent = as ?? "div";
|
|
76
|
+
const isAnchor = BaseComponent === "a";
|
|
70
77
|
const cardProps = {
|
|
71
78
|
...rest,
|
|
72
79
|
ref,
|
|
73
80
|
className: cardClasses,
|
|
74
|
-
...
|
|
81
|
+
...disabled && { "aria-disabled": true },
|
|
82
|
+
...clickable && { ...isAnchor ? { onClick: handleClick } : {
|
|
75
83
|
role: "button",
|
|
76
84
|
tabIndex: disabled ? -1 : 0,
|
|
77
85
|
onClick: handleClick,
|
|
78
86
|
onKeyDown: handleKeyDown,
|
|
79
87
|
"aria-disabled": disabled
|
|
80
|
-
}
|
|
88
|
+
} }
|
|
81
89
|
};
|
|
82
90
|
const { mediaChildren, contentChildren, mediaIsFirst } = useMemo(() => {
|
|
83
91
|
if (!horizontal) return {
|
|
@@ -103,9 +111,13 @@ const CardComponent = forwardRef(({ clickable = false, onClick, onKeyDown, disab
|
|
|
103
111
|
}
|
|
104
112
|
return /* @__PURE__ */ jsx(CardContext.Provider, {
|
|
105
113
|
value: contextValue,
|
|
106
|
-
children: /* @__PURE__ */
|
|
114
|
+
children: /* @__PURE__ */ jsxs(BaseComponent, {
|
|
107
115
|
...cardProps,
|
|
108
|
-
children: renderedChildren
|
|
116
|
+
children: [renderedChildren, clickable && /* @__PURE__ */ jsx("div", {
|
|
117
|
+
className: `${blockClass}__clickable-footer`,
|
|
118
|
+
"aria-hidden": "true",
|
|
119
|
+
children: /* @__PURE__ */ jsx(FooterIcon, { "aria-hidden": "true" })
|
|
120
|
+
})]
|
|
109
121
|
})
|
|
110
122
|
});
|
|
111
123
|
});
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import { ReactNode } from 'react';
|
|
7
|
+
import React, { ReactNode } from 'react';
|
|
8
8
|
/**
|
|
9
9
|
* Base props shared across card components
|
|
10
10
|
*/
|
|
@@ -23,17 +23,29 @@ export interface CardBaseProps {
|
|
|
23
23
|
*/
|
|
24
24
|
export interface CardProps extends CardBaseProps {
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
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.
|
|
27
38
|
*/
|
|
28
39
|
clickable?: boolean;
|
|
29
40
|
/**
|
|
30
|
-
* Click handler for clickable cards
|
|
41
|
+
* Click handler for clickable cards. Only has effect when `clickable`
|
|
42
|
+
* is true.
|
|
31
43
|
*/
|
|
32
|
-
onClick?: (event: React.MouseEvent
|
|
44
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
33
45
|
/**
|
|
34
|
-
* Keyboard event handler
|
|
46
|
+
* Keyboard event handler. Only has effect when `clickable` is true.
|
|
35
47
|
*/
|
|
36
|
-
onKeyDown?: (event: React.KeyboardEvent
|
|
48
|
+
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
37
49
|
/**
|
|
38
50
|
* Disables the card and all interactive elements
|
|
39
51
|
*/
|
|
@@ -52,6 +64,13 @@ export interface CardProps extends CardBaseProps {
|
|
|
52
64
|
* header/body/footer stacked vertically on the right.
|
|
53
65
|
*/
|
|
54
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;
|
|
55
74
|
}
|
|
56
75
|
/**
|
|
57
76
|
* Props for CardHeader component
|
|
@@ -60,7 +79,14 @@ export type CardHeaderProps = CardBaseProps;
|
|
|
60
79
|
/**
|
|
61
80
|
* Props for CardBody component
|
|
62
81
|
*/
|
|
63
|
-
export
|
|
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
|
+
}
|
|
64
90
|
/**
|
|
65
91
|
* Props for CardFooter component
|
|
66
92
|
*/
|
|
@@ -85,4 +111,9 @@ export interface CardContextValue {
|
|
|
85
111
|
* Whether the card is in horizontal layout mode
|
|
86
112
|
*/
|
|
87
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;
|
|
88
119
|
}
|
|
@@ -73,7 +73,7 @@ const CardActions = ({ children, className, overflowMenuLabel = "More actions",
|
|
|
73
73
|
style: { position: "relative" },
|
|
74
74
|
children: /* @__PURE__ */ jsx(OverflowMenu, {
|
|
75
75
|
size: "sm",
|
|
76
|
-
|
|
76
|
+
label: overflowMenuLabel,
|
|
77
77
|
children: hiddenItems.map((item) => /* @__PURE__ */ jsx(MenuItem, {
|
|
78
78
|
label: item.label || "Action",
|
|
79
79
|
onClick: () => {
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
+
import { CardBodyProps } from './Card.types';
|
|
8
9
|
/**
|
|
9
10
|
* CardBody component - Body section of the card for free-form content
|
|
10
11
|
*/
|
|
11
|
-
export declare const CardBody: React.ForwardRefExoticComponent<
|
|
12
|
+
export declare const CardBody: React.ForwardRefExoticComponent<CardBodyProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -20,8 +20,9 @@ const componentName = "CardBody";
|
|
|
20
20
|
/**
|
|
21
21
|
* CardBody component - Body section of the card for free-form content
|
|
22
22
|
*/
|
|
23
|
-
const CardBody = forwardRef(({ className, children, ...rest }, ref) => {
|
|
24
|
-
const
|
|
23
|
+
const CardBody = forwardRef(({ className, children, isFlush = false, ...rest }, ref) => {
|
|
24
|
+
const prefix = usePrefix();
|
|
25
|
+
const bodyClasses = cx(`${prefix}--card__body`, className, { [`${prefix}--card__body--flush`]: isFlush });
|
|
25
26
|
return /* @__PURE__ */ jsx("div", {
|
|
26
27
|
...rest,
|
|
27
28
|
ref,
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
/**
|
|
9
|
-
* CardFooter component - Footer section of the card
|
|
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.
|
|
10
14
|
*/
|
|
11
15
|
export declare const CardFooter: React.ForwardRefExoticComponent<import("./Card.types").CardBaseProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
9
|
+
import { useCardContext } from "./CardContext.js";
|
|
9
10
|
import { forwardRef } from "react";
|
|
10
11
|
import cx from "classnames";
|
|
11
12
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -18,10 +19,20 @@ import { jsx } from "react/jsx-runtime";
|
|
|
18
19
|
*/
|
|
19
20
|
const componentName = "CardFooter";
|
|
20
21
|
/**
|
|
21
|
-
* CardFooter component - Footer section of the card
|
|
22
|
+
* CardFooter component - Footer section of the card.
|
|
23
|
+
*
|
|
24
|
+
* Not supported inside a `clickable` card. A clickable card renders its own
|
|
25
|
+
* built-in footer affordance automatically. Use the `renderFooterIcon` prop on
|
|
26
|
+
* `Card` to customize the icon.
|
|
22
27
|
*/
|
|
23
28
|
const CardFooter = forwardRef(({ className, children, ...rest }, ref) => {
|
|
24
|
-
const
|
|
29
|
+
const prefix = usePrefix();
|
|
30
|
+
const { clickable } = useCardContext();
|
|
31
|
+
if (clickable) {
|
|
32
|
+
console.error("[Card] `Card.Footer` cannot be used inside a `clickable` card. A clickable card renders its own footer affordance automatically. Use the `renderFooterIcon` prop on `Card` to customize the icon.");
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const footerClasses = cx(`${prefix}--card__footer`, className);
|
|
25
36
|
return /* @__PURE__ */ jsx("div", {
|
|
26
37
|
...rest,
|
|
27
38
|
ref,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, { ReactNode } from 'react';
|
|
8
|
-
export interface CardTitleProps {
|
|
8
|
+
export interface CardTitleProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
9
9
|
/**
|
|
10
10
|
* Provide the contents of the CardTitle.
|
|
11
11
|
*/
|
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
|
|
8
8
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
9
9
|
import { Text } from "../Text/Text.js";
|
|
10
|
-
import { End, Enter, Escape, Home, Space } from "../../internal/keyboard/keys.js";
|
|
11
|
-
import { match } from "../../internal/keyboard/match.js";
|
|
12
10
|
import { useId } from "../../internal/useId.js";
|
|
13
11
|
import { deprecate } from "../../prop-types/deprecate.js";
|
|
14
12
|
import { defaultItemToString } from "../../internal/defaultItemToString.js";
|
|
15
13
|
import { isItemDisabled } from "../../internal/isItemDisabled.js";
|
|
16
14
|
import { isComponentElement } from "../../internal/utils.js";
|
|
15
|
+
import { End, Enter, Escape, Home, Space } from "../../internal/keyboard/keys.js";
|
|
16
|
+
import { match } from "../../internal/keyboard/match.js";
|
|
17
17
|
import { useFeatureFlag } from "../FeatureFlags/index.js";
|
|
18
18
|
import { AILabel } from "../AILabel/index.js";
|
|
19
19
|
import { mergeRefs } from "../../tools/mergeRefs.js";
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import { warning } from "../../internal/warning.js";
|
|
9
9
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
10
|
-
import { Escape, Tab } from "../../internal/keyboard/keys.js";
|
|
11
|
-
import { match } from "../../internal/keyboard/match.js";
|
|
12
10
|
import { useId } from "../../internal/useId.js";
|
|
13
11
|
import { deprecate } from "../../prop-types/deprecate.js";
|
|
14
12
|
import { isComponentElement } from "../../internal/utils.js";
|
|
13
|
+
import { Escape, Tab } from "../../internal/keyboard/keys.js";
|
|
14
|
+
import { match } from "../../internal/keyboard/match.js";
|
|
15
15
|
import { useFeatureFlag } from "../FeatureFlags/index.js";
|
|
16
16
|
import { AILabel } from "../AILabel/index.js";
|
|
17
17
|
import { mergeRefs } from "../../tools/mergeRefs.js";
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { PrefixContext } from "../../internal/usePrefix.js";
|
|
9
|
+
import { deprecate } from "../../prop-types/deprecate.js";
|
|
10
|
+
import { isComponentElement } from "../../internal/utils.js";
|
|
9
11
|
import { ArrowLeft, ArrowRight, Enter, Space } from "../../internal/keyboard/keys.js";
|
|
10
12
|
import { match } from "../../internal/keyboard/match.js";
|
|
11
13
|
import { getNextIndex } from "../../internal/keyboard/navigation.js";
|
|
12
|
-
import { deprecate } from "../../prop-types/deprecate.js";
|
|
13
|
-
import { isComponentElement } from "../../internal/utils.js";
|
|
14
14
|
import { LayoutConstraint } from "../Layout/index.js";
|
|
15
15
|
import Switch from "../Switch/Switch.js";
|
|
16
16
|
import IconSwitch from "../Switch/IconSwitch.js";
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { type ReactNode } from 'react';
|
|
8
8
|
import flatpickr from 'flatpickr';
|
|
9
|
-
import { DateLimit, DateOption } from 'flatpickr/dist/types/options';
|
|
9
|
+
import type { DateLimit, DateOption } from 'flatpickr/dist/types/options';
|
|
10
10
|
import { type SupportedLocale } from './DatePickerLocales';
|
|
11
11
|
export type DatePickerTypes = 'simple' | 'single' | 'range';
|
|
12
12
|
export interface DatePickerProps {
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
9
|
-
import { Enter, Escape, Tab } from "../../internal/keyboard/keys.js";
|
|
10
|
-
import { match } from "../../internal/keyboard/match.js";
|
|
11
9
|
import { deprecate } from "../../prop-types/deprecate.js";
|
|
12
10
|
import { isComponentElement } from "../../internal/utils.js";
|
|
11
|
+
import { Enter, Escape, Tab } from "../../internal/keyboard/keys.js";
|
|
12
|
+
import { match } from "../../internal/keyboard/match.js";
|
|
13
13
|
import DatePickerInput_default from "../DatePickerInput/index.js";
|
|
14
14
|
import { appendToPlugin } from "./plugins/appendToPlugin.js";
|
|
15
15
|
import { fixEventsPlugin } from "./plugins/fixEventsPlugin.js";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { type Config } from 'flatpickr/dist/plugins/rangePlugin';
|
|
8
|
-
import { Instance } from 'flatpickr/dist/types/instance';
|
|
8
|
+
import type { Instance } from 'flatpickr/dist/types/instance';
|
|
9
9
|
/**
|
|
10
10
|
* @param config Plugin configuration.
|
|
11
11
|
* @returns An extension of Flatpickr `rangePlugin` that does the following:
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
9
9
|
import { Text } from "../Text/Text.js";
|
|
10
|
+
import { useId } from "../../internal/useId.js";
|
|
10
11
|
import { Enter, Space } from "../../internal/keyboard/keys.js";
|
|
11
12
|
import { matches } from "../../internal/keyboard/match.js";
|
|
12
|
-
import { useId } from "../../internal/useId.js";
|
|
13
13
|
import { useFeatureFlag } from "../FeatureFlags/index.js";
|
|
14
14
|
import { ButtonKinds } from "../Button/Button.js";
|
|
15
15
|
import Filename from "./Filename.js";
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
import { noopFn } from "../../internal/noopFn.js";
|
|
9
9
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
10
|
-
import { Enter, Space } from "../../internal/keyboard/keys.js";
|
|
11
|
-
import { matches } from "../../internal/keyboard/match.js";
|
|
12
10
|
import { useId } from "../../internal/useId.js";
|
|
13
11
|
import { deprecate } from "../../prop-types/deprecate.js";
|
|
12
|
+
import { Enter, Space } from "../../internal/keyboard/keys.js";
|
|
13
|
+
import { matches } from "../../internal/keyboard/match.js";
|
|
14
14
|
import { ButtonKinds } from "../Button/Button.js";
|
|
15
15
|
import { useEffect, useRef, useState } from "react";
|
|
16
16
|
import cx from "classnames";
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
import { noopFn } from "../../internal/noopFn.js";
|
|
9
9
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
10
|
-
import { Enter, Space } from "../../internal/keyboard/keys.js";
|
|
11
|
-
import { matches } from "../../internal/keyboard/match.js";
|
|
12
10
|
import { useId } from "../../internal/useId.js";
|
|
13
11
|
import { deprecate } from "../../prop-types/deprecate.js";
|
|
12
|
+
import { Enter, Space } from "../../internal/keyboard/keys.js";
|
|
13
|
+
import { matches } from "../../internal/keyboard/match.js";
|
|
14
14
|
import { composeEventHandlers } from "../../tools/events.js";
|
|
15
15
|
import { useRef, useState } from "react";
|
|
16
16
|
import cx from "classnames";
|
|
@@ -53,13 +53,13 @@ function FileUploaderDropContainer({ accept = [], className, id, disabled, label
|
|
|
53
53
|
return acc.concat([curr]);
|
|
54
54
|
}, []);
|
|
55
55
|
}
|
|
56
|
-
const
|
|
57
|
-
if (!files.length) return
|
|
58
|
-
return
|
|
56
|
+
const getAddedFiles = (files) => {
|
|
57
|
+
if (!files.length) return [];
|
|
58
|
+
return validateFiles(multiple ? files : [files[0]]);
|
|
59
59
|
};
|
|
60
60
|
const handleChange = (event) => {
|
|
61
61
|
const files = [...event.target.files ?? []];
|
|
62
|
-
return
|
|
62
|
+
return onAddFiles(event, { addedFiles: getAddedFiles(files) });
|
|
63
63
|
};
|
|
64
64
|
const handleDrop = (event) => {
|
|
65
65
|
const items = [...event.dataTransfer.items ?? []];
|
|
@@ -70,7 +70,13 @@ function FileUploaderDropContainer({ accept = [], className, id, disabled, label
|
|
|
70
70
|
if (file) acc.push(file);
|
|
71
71
|
return acc;
|
|
72
72
|
}, []) : [...event.dataTransfer.files];
|
|
73
|
-
|
|
73
|
+
const addedFiles = getAddedFiles(files);
|
|
74
|
+
if (inputRef.current) try {
|
|
75
|
+
const dataTransfer = new DataTransfer();
|
|
76
|
+
addedFiles.forEach((file) => dataTransfer.items.add(file));
|
|
77
|
+
inputRef.current.files = dataTransfer.files;
|
|
78
|
+
} catch {}
|
|
79
|
+
return onAddFiles(event, { addedFiles });
|
|
74
80
|
};
|
|
75
81
|
const handleClick = () => {
|
|
76
82
|
if (!disabled) inputRef.current?.click();
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import { noopFn } from "../../internal/noopFn.js";
|
|
9
9
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
10
10
|
import { Text } from "../Text/Text.js";
|
|
11
|
-
import { Enter, Space } from "../../internal/keyboard/keys.js";
|
|
12
|
-
import { matches } from "../../internal/keyboard/match.js";
|
|
13
11
|
import useIsomorphicEffect from "../../internal/useIsomorphicEffect.js";
|
|
14
12
|
import { useId } from "../../internal/useId.js";
|
|
13
|
+
import { Enter, Space } from "../../internal/keyboard/keys.js";
|
|
14
|
+
import { matches } from "../../internal/keyboard/match.js";
|
|
15
15
|
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
16
16
|
import Filename from "./Filename.js";
|
|
17
17
|
import { useRef, useState } from "react";
|
|
@@ -16,7 +16,7 @@ export interface FormLabelProps extends Omit<React.LabelHTMLAttributes<HTMLLabel
|
|
|
16
16
|
*/
|
|
17
17
|
className?: string;
|
|
18
18
|
/**
|
|
19
|
-
* Provide a unique id for the given
|
|
19
|
+
* Provide a unique id for the given `FormLabel`
|
|
20
20
|
*/
|
|
21
21
|
id?: string;
|
|
22
22
|
}
|
|
@@ -32,7 +32,7 @@ declare namespace FormLabel {
|
|
|
32
32
|
*/
|
|
33
33
|
className: PropTypes.Requireable<string>;
|
|
34
34
|
/**
|
|
35
|
-
* Provide a unique id for the given
|
|
35
|
+
* Provide a unique id for the given `FormLabel`
|
|
36
36
|
*/
|
|
37
37
|
id: PropTypes.Requireable<string>;
|
|
38
38
|
};
|