rift-ds 1.41.0 → 1.42.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/behaviors/LoadingImage.d.ts +2 -0
- package/behaviors/LoadingImage.js +34 -0
- package/behaviors/ScrollRegion.js +15 -2
- package/behaviors/VisuallyHidden.d.ts +30 -0
- package/behaviors/VisuallyHidden.js +17 -0
- package/behaviors/loading-image.css +30 -0
- package/behaviors/quietFocus.d.ts +4 -0
- package/behaviors/quietFocus.js +14 -0
- package/behaviors/useFocusScope.d.ts +3 -1
- package/behaviors/useFocusScope.js +4 -6
- package/bin/rift-ds.mjs +1 -0
- package/bin/templates/app/components/rift/ColorModeScript.tsx +3 -1
- package/bin/templates/app/components/rift/RiftRoot.tsx +40 -1
- package/bin/templates/blocks/app/dashboard/page.tsx +7 -5
- package/bin/templates/blocks/app/landing/page.tsx +1 -1
- package/bin/templates/blocks/app/pricing/page.module.css +15 -1
- package/bin/templates/blocks/app/pricing/page.tsx +8 -1
- package/bin/templates/blocks/app/sign-in/page.tsx +10 -2
- package/bin/templates/blocks/app/sign-up/page.module.css +83 -0
- package/bin/templates/blocks/app/sign-up/page.tsx +126 -0
- package/bin/templates/blocks/app/starter/page.tsx +1 -1
- package/bin/templates/blocks/components/blocks/AppShell.module.css +0 -10
- package/bin/templates/blocks/components/blocks/AppShell.tsx +39 -115
- package/bin/templates/blocks/components/blocks/DocsShell.tsx +5 -1
- package/bin/templates/blocks/registry.json +44 -6
- package/components/AgentPlan/AgentPlan.css +1 -1
- package/components/AlertDialog/AlertDialog.css +14 -0
- package/components/AlertDialog/AlertDialog.d.ts +35 -3
- package/components/AlertDialog/AlertDialog.js +16 -5
- package/components/AppSidebar/AppSidebar.css +13 -2
- package/components/AppSidebar/AppSidebar.js +7 -2
- package/components/Attachment/AttachmentGroup.js +2 -1
- package/components/Attachment/AttachmentTile.js +2 -1
- package/components/Badge/Badge.css +6 -0
- package/components/Breadcrumb/Breadcrumb.css +4 -1
- package/components/Button/Button.css +20 -1
- package/components/Button/Button.js +6 -1
- package/components/Card/Card.css +11 -0
- package/components/Card/Card.d.ts +9 -3
- package/components/Card/Card.js +21 -2
- package/components/Chart/AreaChart.d.ts +7 -0
- package/components/Chart/AreaChart.js +51 -45
- package/components/Chart/BarChart.d.ts +7 -0
- package/components/Chart/BarChart.js +52 -46
- package/components/Chart/Chart.css +122 -1
- package/components/Chart/ChartSkeleton.d.ts +32 -0
- package/components/Chart/ChartSkeleton.js +149 -0
- package/components/Chart/ComboChart.d.ts +7 -0
- package/components/Chart/ComboChart.js +80 -74
- package/components/Chart/LineChart.d.ts +17 -3
- package/components/Chart/LineChart.js +61 -39
- package/components/Chart/PieChart.d.ts +7 -0
- package/components/Chart/PieChart.js +41 -34
- package/components/Chart/RadarChart.d.ts +7 -0
- package/components/Chart/RadarChart.js +38 -32
- package/components/Chart/RadialChart.d.ts +7 -0
- package/components/Chart/RadialChart.js +5 -1
- package/components/Chart/ScatterChart.d.ts +7 -0
- package/components/Chart/ScatterChart.js +46 -40
- package/components/Chart/StackedBarChart.d.ts +10 -1
- package/components/Chart/StackedBarChart.js +51 -43
- package/components/Chart/Treemap.d.ts +7 -0
- package/components/Chart/Treemap.js +17 -11
- package/components/Checkbox/Checkbox.css +25 -1
- package/components/Checkbox/Checkbox.d.ts +8 -4
- package/components/Checkbox/Checkbox.js +17 -8
- package/components/Chip/Chip.css +5 -3
- package/components/ContactCard/ContactCard.css +4 -3
- package/components/ContributionGraph/ContributionGraph.css +20 -0
- package/components/ContributionGraph/ContributionGraph.d.ts +4 -0
- package/components/ContributionGraph/ContributionGraph.js +11 -6
- package/components/DataTable/DataTable.css +28 -4
- package/components/DataTable/DataTable.d.ts +16 -2
- package/components/DataTable/DataTable.js +5 -0
- package/components/DateInput/DateInput.css +3 -1
- package/components/DatePicker/DatePicker.css +16 -0
- package/components/DatePicker/DatePicker.d.ts +13 -0
- package/components/DatePicker/DatePicker.js +21 -27
- package/components/DatePicker/MonthGrid.d.ts +2 -2
- package/components/DatePicker/MonthGrid.js +1 -1
- package/components/DatePicker/today.d.ts +15 -0
- package/components/DatePicker/today.js +17 -0
- package/components/DateRangePicker/DateRangePicker.d.ts +14 -1
- package/components/DateRangePicker/DateRangePicker.js +18 -7
- package/components/DescriptionList/DescriptionList.css +11 -0
- package/components/DescriptionList/DescriptionList.d.ts +5 -1
- package/components/DescriptionList/DescriptionList.js +21 -6
- package/components/Dialog/Dialog.css +9 -0
- package/components/Dialog/Dialog.d.ts +9 -0
- package/components/Dialog/Dialog.js +32 -19
- package/components/DocumentChip/DocumentChip.css +1 -1
- package/components/Drawer/Drawer.d.ts +9 -0
- package/components/Drawer/Drawer.js +8 -0
- package/components/Dropdown/Dropdown.css +3 -1
- package/components/EmptyState/EmptyState.css +8 -1
- package/components/Field/Field.css +2 -2
- package/components/FileInput/FileInput.css +1 -1
- package/components/FilterBar/FilterBar.d.ts +6 -1
- package/components/FunnelChart/FunnelChart.d.ts +7 -0
- package/components/FunnelChart/FunnelChart.js +44 -30
- package/components/GanttChart/GanttChart.css +10 -0
- package/components/GanttChart/GanttChart.d.ts +4 -0
- package/components/GanttChart/GanttChart.js +66 -33
- package/components/Gauge/Gauge.css +23 -0
- package/components/Gauge/Gauge.d.ts +4 -0
- package/components/Gauge/Gauge.js +14 -8
- package/components/ImageCompare/ImageCompare.js +2 -1
- package/components/Input/Input.css +3 -1
- package/components/List/List.css +1 -1
- package/components/NotificationCenter/NotificationCenter.css +16 -0
- package/components/NotificationCenter/NotificationCenter.d.ts +4 -0
- package/components/NotificationCenter/NotificationCenter.js +23 -1
- package/components/NumberInput/NumberInput.css +2 -0
- package/components/PageHeader/PageHeader.css +12 -4
- package/components/Panel/Panel.d.ts +1 -1
- package/components/Prose/Prose.css +1 -1
- package/components/RadioButton/RadioButton.css +1 -1
- package/components/RadioButton/RadioButton.d.ts +4 -2
- package/components/RadioButton/RadioButton.js +5 -2
- package/components/ResourceTimeline/ResourceTimeline.css +12 -0
- package/components/ResourceTimeline/ResourceTimeline.d.ts +5 -1
- package/components/ResourceTimeline/ResourceTimeline.js +94 -52
- package/components/RichDropdown/RichDropdown.css +3 -1
- package/components/SelectionCard/SelectionCard.css +29 -0
- package/components/SelectionCard/SelectionCard.d.ts +7 -0
- package/components/SelectionCard/SelectionCard.js +25 -2
- package/components/Sparkline/Sparkline.css +20 -0
- package/components/Sparkline/Sparkline.d.ts +4 -0
- package/components/Sparkline/Sparkline.js +14 -8
- package/components/Stat/Stat.css +31 -0
- package/components/Stat/Stat.d.ts +23 -2
- package/components/Stat/Stat.js +21 -6
- package/components/Table/Table.css +101 -16
- package/components/Table/Table.d.ts +4 -0
- package/components/Table/Table.js +43 -28
- package/components/Textarea/Textarea.css +4 -2
- package/components/ThemeToggle/colorMode.d.ts +10 -2
- package/components/ThemeToggle/colorMode.js +4 -2
- package/components/ThreadHistory/ThreadHistory.css +11 -0
- package/components/ThreadHistory/ThreadHistory.d.ts +5 -1
- package/components/ThreadHistory/ThreadHistory.js +6 -1
- package/components/ThreadPanel/ThreadPanel.d.ts +4 -0
- package/components/ThreadPanel/ThreadPanel.js +5 -1
- package/components/TimePicker/TimePicker.css +3 -1
- package/components/TimePicker/TimePicker.d.ts +4 -2
- package/components/TimePicker/TimePicker.js +11 -3
- package/components/Timeline/Timeline.css +15 -0
- package/components/Timeline/Timeline.d.ts +8 -0
- package/components/Timeline/Timeline.js +21 -0
- package/components/Toast/Toast.css +16 -0
- package/components/Toast/Toast.d.ts +7 -2
- package/components/ToggleGroup/ToggleGroup.css +28 -2
- package/components/ToggleSwitch/ToggleSwitch.css +1 -1
- package/components/Tooltip/Tooltip.d.ts +9 -0
- package/components/Tooltip/Tooltip.js +34 -8
- package/components/TreeView/TreeView.css +12 -0
- package/components/TreeView/TreeView.d.ts +4 -0
- package/components/TreeView/TreeView.js +20 -0
- package/components/UsageCard/UsageCard.css +11 -0
- package/components/UsageCard/UsageCard.d.ts +4 -0
- package/components/UsageCard/UsageCard.js +25 -16
- package/components/Widget/Widget.css +7 -0
- package/components/Widget/Widget.d.ts +4 -0
- package/components/Widget/Widget.js +14 -2
- package/components/registry.json +4 -1
- package/components/registry.json.d.ts +4 -1
- package/components/registry.json.js +1 -1
- package/package.json +7 -2
- package/tokens/presets/contrast.css +4 -4
- package/tokens/presets/coral.css +3 -4
- package/tokens/presets/forest.css +16 -4
- package/tokens/presets/gold.css +4 -3
- package/tokens/presets/marquee.css +2 -3
- package/tokens/presets/mono.css +28 -28
- package/tokens/presets/pink.css +5 -4
- package/tokens/presets/terminal.css +4 -3
- package/tokens/presets/violet.css +3 -4
- package/tokens/presets/warm.css +16 -4
- package/tokens/presets/zest.css +2 -2
- package/tokens/registry.json +1 -0
- package/tokens/registry.json.d.ts +1 -0
- package/tokens/registry.json.js +1 -1
- package/tokens/tokens-dark.css +4 -0
- package/tokens/tokens-light.css +4 -0
- package/tokens/values.d.ts +14 -1
- package/tokens/values.js +14 -1
- package/tokens/values.json.js +1 -1
|
@@ -579,7 +579,8 @@
|
|
|
579
579
|
/* ============================================
|
|
580
580
|
LOADING
|
|
581
581
|
Keeps the variant's full-colour appearance (no disabled dim);
|
|
582
|
-
the spinner occupies the left icon slot and inherits its colour
|
|
582
|
+
the spinner occupies the left icon slot and inherits its colour, or
|
|
583
|
+
sits over the label when the button has no left icon.
|
|
583
584
|
============================================ */
|
|
584
585
|
|
|
585
586
|
.ds-button--loading {
|
|
@@ -597,6 +598,24 @@
|
|
|
597
598
|
justify-content: center;
|
|
598
599
|
}
|
|
599
600
|
|
|
601
|
+
/* A button with text and no left icon keeps its width while loading: the
|
|
602
|
+
spinner sits centred over the label, and the label and any trailing icon
|
|
603
|
+
keep their room unseen. Opacity, never visibility: a hidden label would
|
|
604
|
+
leave the button with no accessible name. */
|
|
605
|
+
.ds-button--loading-over {
|
|
606
|
+
position: relative;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
.ds-button--loading-over .ds-button__spinner {
|
|
610
|
+
position: absolute;
|
|
611
|
+
inset: 0;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
.ds-button--loading-over .ds-button__text,
|
|
615
|
+
.ds-button--loading-over .ds-button__icon--right {
|
|
616
|
+
opacity: 0;
|
|
617
|
+
}
|
|
618
|
+
|
|
600
619
|
/* The generic icon-slot svg sizing must not distort the spinner —
|
|
601
620
|
it sizes itself from the Spinner size prop */
|
|
602
621
|
.ds-button .ds-button__icon .ds-spinner__circle {
|
|
@@ -65,13 +65,17 @@ const Button = React.forwardRef(
|
|
|
65
65
|
const resolvedState = state ?? (isDisabled ? "disabled" : "default");
|
|
66
66
|
const isLoading = Boolean(loading);
|
|
67
67
|
const spinnerSize = size === "compact" ? "sm" : "md";
|
|
68
|
-
const
|
|
68
|
+
const spinner = /* @__PURE__ */ jsx(Spinner, { size: spinnerSize, tone: "inherit" });
|
|
69
|
+
const startIcon = iconLeft || icon;
|
|
70
|
+
const spinnerOverLabel = isLoading && !startIcon && text && Boolean(label);
|
|
71
|
+
const leftIcon = isLoading && !spinnerOverLabel ? spinner : startIcon;
|
|
69
72
|
const classes = [
|
|
70
73
|
baseClass,
|
|
71
74
|
`${baseClass}--${resolvedVariant}`,
|
|
72
75
|
`${baseClass}--${resolvedState}`,
|
|
73
76
|
`${baseClass}--${size}`,
|
|
74
77
|
isLoading && `${baseClass}--loading`,
|
|
78
|
+
spinnerOverLabel && `${baseClass}--loading-over`,
|
|
75
79
|
glass && `${baseClass}--glass`,
|
|
76
80
|
text && label && leftIcon && `${baseClass}--icon-start`,
|
|
77
81
|
text && label && iconRight && `${baseClass}--icon-end`,
|
|
@@ -89,6 +93,7 @@ const Button = React.forwardRef(
|
|
|
89
93
|
const fallbackAriaLabel = needsAccessibleName && label && !rest["aria-label"] ? label : void 0;
|
|
90
94
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
91
95
|
leftIcon && renderIcon(leftIcon),
|
|
96
|
+
spinnerOverLabel && /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon ${baseClass}__spinner`, "aria-hidden": "true", children: spinner }),
|
|
92
97
|
text && /* @__PURE__ */ jsx("span", { className: `${baseClass}__text`, children: label }),
|
|
93
98
|
iconRight && renderIcon(iconRight, "right")
|
|
94
99
|
] });
|
package/components/Card/Card.css
CHANGED
|
@@ -106,6 +106,17 @@
|
|
|
106
106
|
box-shadow: none;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/* A case-study card with no href goes nowhere, so it does not lift or
|
|
110
|
+
offer a pointer; it keeps its full colour, unlike a placeholder. */
|
|
111
|
+
.ds-card--case-study--static {
|
|
112
|
+
cursor: default;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.ds-card--case-study--static:hover {
|
|
116
|
+
transform: none;
|
|
117
|
+
box-shadow: none;
|
|
118
|
+
}
|
|
119
|
+
|
|
109
120
|
.ds-card--case-study__cover-wrap {
|
|
110
121
|
width: 100%;
|
|
111
122
|
aspect-ratio: 940 / 480;
|
|
@@ -15,7 +15,13 @@ type CardOwnProps = {
|
|
|
15
15
|
interactive?: boolean;
|
|
16
16
|
/** Additional CSS classes */
|
|
17
17
|
className?: string;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Where the card goes. With it the card renders as a link in either
|
|
20
|
+
* variant, through `linkComponent`: the default variant becomes a link
|
|
21
|
+
* named by its title and wears the interactive lift, and the case-study
|
|
22
|
+
* variant links its whole tile. A case-study card without it, or one
|
|
23
|
+
* marked `placeholder`, is a still tile that does not lift.
|
|
24
|
+
*/
|
|
19
25
|
href?: string;
|
|
20
26
|
/** Cover image src */
|
|
21
27
|
coverSrc?: string;
|
|
@@ -47,8 +53,8 @@ export interface CardProps extends CardOwnProps, Omit<React.ComponentPropsWithou
|
|
|
47
53
|
/**
|
|
48
54
|
* Card renders a preview tile, or a case-study tile when `variant="case-study"`.
|
|
49
55
|
*
|
|
50
|
-
* Renders a `<div>`, or
|
|
51
|
-
*
|
|
56
|
+
* Renders a `<div>`, or a link in either variant when `href` is supplied.
|
|
57
|
+
* Forwards a ref to whichever element it renders and spreads
|
|
52
58
|
* unrecognised props onto it.
|
|
53
59
|
*/
|
|
54
60
|
export declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement | HTMLAnchorElement>>;
|
package/components/Card/Card.js
CHANGED
|
@@ -4,6 +4,7 @@ import React from "react";
|
|
|
4
4
|
import { useLinkComponent } from "../../behaviors/LinkProvider.js";
|
|
5
5
|
import "./Card.css";
|
|
6
6
|
import "../../fonts/material-symbols.css";
|
|
7
|
+
import { LoadingImage } from "../../behaviors/LoadingImage.js";
|
|
7
8
|
const Card = React.forwardRef(
|
|
8
9
|
({
|
|
9
10
|
variant = "default",
|
|
@@ -28,7 +29,7 @@ const Card = React.forwardRef(
|
|
|
28
29
|
if (variant === "case-study") {
|
|
29
30
|
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
30
31
|
/* @__PURE__ */ jsx("div", { className: "ds-card--case-study__cover-wrap", children: cover ? /* @__PURE__ */ jsx("div", { className: "ds-card--case-study__cover-slot", children: cover }) : coverSrc ? /* @__PURE__ */ jsx(
|
|
31
|
-
|
|
32
|
+
LoadingImage,
|
|
32
33
|
{
|
|
33
34
|
src: coverSrc,
|
|
34
35
|
alt: coverAlt ?? `${title} cover`,
|
|
@@ -55,6 +56,8 @@ const Card = React.forwardRef(
|
|
|
55
56
|
"ds-card",
|
|
56
57
|
"ds-card--case-study",
|
|
57
58
|
placeholder ? "ds-card--case-study--placeholder" : "",
|
|
59
|
+
// A card that goes nowhere stays still under the pointer.
|
|
60
|
+
!placeholder && !href ? "ds-card--case-study--static" : "",
|
|
58
61
|
className
|
|
59
62
|
].filter(Boolean).join(" ");
|
|
60
63
|
if (placeholder || !href) {
|
|
@@ -82,7 +85,23 @@ const Card = React.forwardRef(
|
|
|
82
85
|
);
|
|
83
86
|
}
|
|
84
87
|
const baseClass = "ds-card";
|
|
85
|
-
const classes = [baseClass, interactive ? `${baseClass}--interactive` : "", className].filter(Boolean).join(" ");
|
|
88
|
+
const classes = [baseClass, interactive || href ? `${baseClass}--interactive` : "", className].filter(Boolean).join(" ");
|
|
89
|
+
if (href) {
|
|
90
|
+
return /* @__PURE__ */ jsxs(
|
|
91
|
+
Link,
|
|
92
|
+
{
|
|
93
|
+
...rest,
|
|
94
|
+
ref,
|
|
95
|
+
href,
|
|
96
|
+
className: classes,
|
|
97
|
+
onClick,
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ jsx("div", { className: `${baseClass}__preview`, children }),
|
|
100
|
+
/* @__PURE__ */ jsx("h3", { className: `${baseClass}__title`, children: title })
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
}
|
|
86
105
|
const handleKeyDown = (e) => {
|
|
87
106
|
onKeyDown?.(e);
|
|
88
107
|
if (!interactive) return;
|
|
@@ -45,6 +45,13 @@ type AreaChartOwnProps = {
|
|
|
45
45
|
* neither is on the plot. For a headline figure that follows the cursor.
|
|
46
46
|
*/
|
|
47
47
|
onActiveChange?: ChartActiveHandler;
|
|
48
|
+
/**
|
|
49
|
+
* Holds the chart's placeholder, the outline of this chart type, in place of the chart while its data is still being fetched.
|
|
50
|
+
* Before its first draw the chart shows the same placeholder by itself, so this is only for a wait the host knows about.
|
|
51
|
+
*/
|
|
52
|
+
loading?: boolean;
|
|
53
|
+
/** Accessible name announced while `loading`. */
|
|
54
|
+
loadingLabel?: string;
|
|
48
55
|
/** Additional CSS classes on the wrapper */
|
|
49
56
|
className?: string;
|
|
50
57
|
};
|
|
@@ -5,6 +5,7 @@ import { ResponsiveContainer, AreaChart as AreaChart$1, CartesianGrid, XAxis, YA
|
|
|
5
5
|
import { ActiveReporter } from "./ActiveReporter.js";
|
|
6
6
|
import { readTokenPx, getChartSeriesColors } from "./palette.js";
|
|
7
7
|
import { useChartAnimation } from "./useChartAnimation.js";
|
|
8
|
+
import { ChartSkeleton } from "./ChartSkeleton.js";
|
|
8
9
|
import "./Chart.css";
|
|
9
10
|
import { useLocale } from "../../behaviors/LocaleProvider.js";
|
|
10
11
|
import { formatAxisNumber, formatNumber } from "../../behaviors/locale.js";
|
|
@@ -33,6 +34,8 @@ const AreaChart = React.forwardRef(({
|
|
|
33
34
|
height = 350,
|
|
34
35
|
showLegend = true,
|
|
35
36
|
bare = false,
|
|
37
|
+
loading = false,
|
|
38
|
+
loadingLabel = "Loading chart",
|
|
36
39
|
className = "",
|
|
37
40
|
onActiveChange,
|
|
38
41
|
yAxisFormatter,
|
|
@@ -81,51 +84,54 @@ const AreaChart = React.forwardRef(({
|
|
|
81
84
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? formatNumber(item.value, locale) : item.value })
|
|
82
85
|
] }, i)) })
|
|
83
86
|
] }),
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
/* @__PURE__ */ jsx(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
87
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__body`, children: [
|
|
88
|
+
/* @__PURE__ */ jsx(ChartSkeleton, { shape: "area", height, loading, loadingLabel }),
|
|
89
|
+
!loading && /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(AreaChart$1, { data, margin: { top: 8, right: 4, bottom: 0, left: -12 }, children: [
|
|
90
|
+
/* @__PURE__ */ jsx("defs", { children: series.map((s, i) => {
|
|
91
|
+
const color = s.color || seriesColors[i % seriesColors.length];
|
|
92
|
+
return /* @__PURE__ */ jsxs("linearGradient", { id: `area-gradient-${s.dataKey}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
93
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: color, stopOpacity: 0.4 }),
|
|
94
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color, stopOpacity: 0.05 })
|
|
95
|
+
] }, `grad-${s.dataKey}`);
|
|
96
|
+
}) }),
|
|
97
|
+
/* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: gridColor }),
|
|
98
|
+
/* @__PURE__ */ jsx(
|
|
99
|
+
XAxis,
|
|
100
|
+
{
|
|
101
|
+
dataKey: xKey,
|
|
102
|
+
tick: { fill: textSecondary, fontSize: textSize },
|
|
103
|
+
tickLine: false,
|
|
104
|
+
axisLine: { stroke: gridColor }
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ jsx(
|
|
108
|
+
YAxis,
|
|
109
|
+
{
|
|
110
|
+
tickFormatter: yAxisFormatter ?? formatTick,
|
|
111
|
+
tick: { fill: textSecondary, fontSize: textSize },
|
|
112
|
+
tickLine: false,
|
|
113
|
+
axisLine: false
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
/* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
|
|
117
|
+
series.map((s, i) => /* @__PURE__ */ jsx(
|
|
118
|
+
Area,
|
|
119
|
+
{
|
|
120
|
+
...animation,
|
|
121
|
+
type: "monotone",
|
|
122
|
+
dataKey: s.dataKey,
|
|
123
|
+
name: s.label,
|
|
124
|
+
stroke: s.color || seriesColors[i % seriesColors.length],
|
|
125
|
+
strokeWidth: 2,
|
|
126
|
+
fill: `url(#area-gradient-${s.dataKey})`,
|
|
127
|
+
fillOpacity: s.fillOpacity ?? 1,
|
|
128
|
+
stackId: stacked ? "stack" : void 0
|
|
129
|
+
},
|
|
130
|
+
s.dataKey
|
|
131
|
+
)),
|
|
132
|
+
showLegend && series.length > 1 && /* @__PURE__ */ jsx(Legend, { wrapperStyle: { color: textSecondary, fontSize: textSize } })
|
|
133
|
+
] }) })
|
|
134
|
+
] })
|
|
129
135
|
]
|
|
130
136
|
}
|
|
131
137
|
);
|
|
@@ -46,6 +46,13 @@ type BarChartOwnProps = {
|
|
|
46
46
|
* neither is on the plot. For a headline figure that follows the cursor.
|
|
47
47
|
*/
|
|
48
48
|
onActiveChange?: ChartActiveHandler;
|
|
49
|
+
/**
|
|
50
|
+
* Holds the chart's placeholder, the outline of this chart type, in place of the chart while its data is still being fetched.
|
|
51
|
+
* Before its first draw the chart shows the same placeholder by itself, so this is only for a wait the host knows about.
|
|
52
|
+
*/
|
|
53
|
+
loading?: boolean;
|
|
54
|
+
/** Accessible name announced while `loading`. */
|
|
55
|
+
loadingLabel?: string;
|
|
49
56
|
/** Additional CSS classes on the wrapper */
|
|
50
57
|
className?: string;
|
|
51
58
|
};
|
|
@@ -3,6 +3,7 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import React, { useCallback, useId } from "react";
|
|
4
4
|
import { ResponsiveContainer, BarChart as BarChart$1, CartesianGrid, XAxis, YAxis, Tooltip, Bar } from "recharts";
|
|
5
5
|
import { useChartAnimation } from "./useChartAnimation.js";
|
|
6
|
+
import { ChartSkeleton } from "./ChartSkeleton.js";
|
|
6
7
|
import "./Chart.css";
|
|
7
8
|
import { ActiveReporter } from "./ActiveReporter.js";
|
|
8
9
|
import { readTokenPx } from "./palette.js";
|
|
@@ -40,6 +41,8 @@ const BarChart = React.forwardRef(({
|
|
|
40
41
|
barColor,
|
|
41
42
|
height = 350,
|
|
42
43
|
bare = false,
|
|
44
|
+
loading = false,
|
|
45
|
+
loadingLabel = "Loading chart",
|
|
43
46
|
className = "",
|
|
44
47
|
onActiveChange,
|
|
45
48
|
yAxisFormatter,
|
|
@@ -89,52 +92,55 @@ const BarChart = React.forwardRef(({
|
|
|
89
92
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? formatNumber(item.value, locale) : item.value })
|
|
90
93
|
] }, i)) })
|
|
91
94
|
] }),
|
|
92
|
-
/* @__PURE__ */
|
|
93
|
-
/* @__PURE__ */ jsx(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
95
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__body`, children: [
|
|
96
|
+
/* @__PURE__ */ jsx(ChartSkeleton, { shape: "bar", height, loading, loadingLabel }),
|
|
97
|
+
!loading && /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(BarChart$1, { data, margin: { top: 8, right: 4, bottom: 0, left: -12 }, children: [
|
|
98
|
+
/* @__PURE__ */ jsx(
|
|
99
|
+
CartesianGrid,
|
|
100
|
+
{
|
|
101
|
+
vertical: false,
|
|
102
|
+
stroke: gridColor,
|
|
103
|
+
strokeDasharray: ""
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ jsx(
|
|
107
|
+
XAxis,
|
|
108
|
+
{
|
|
109
|
+
dataKey: xKey,
|
|
110
|
+
tick: { fill: textSecondary, fontSize: textSize },
|
|
111
|
+
tickLine: false,
|
|
112
|
+
axisLine: { stroke: gridColor }
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ jsx(
|
|
116
|
+
YAxis,
|
|
117
|
+
{
|
|
118
|
+
tickFormatter: yAxisFormatter ?? formatTick,
|
|
119
|
+
tick: { fill: textSecondary, fontSize: textSize },
|
|
120
|
+
tickLine: false,
|
|
121
|
+
axisLine: false
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ jsx(
|
|
125
|
+
Tooltip,
|
|
126
|
+
{
|
|
127
|
+
content: renderTooltip,
|
|
128
|
+
cursor: { fill: cursorColor, opacity: 0.4 }
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
Bar,
|
|
133
|
+
{
|
|
134
|
+
...animation,
|
|
135
|
+
className: `${baseClass}__bar`,
|
|
136
|
+
dataKey: yKey,
|
|
137
|
+
fill: resolvedBarColor,
|
|
138
|
+
radius: [3, 3, 0, 0],
|
|
139
|
+
maxBarSize: 32
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
] }) })
|
|
143
|
+
] })
|
|
138
144
|
]
|
|
139
145
|
}
|
|
140
146
|
);
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
width: 100%;
|
|
20
20
|
padding: var(--padding-500); /* 24px */
|
|
21
21
|
border: var(--border-025) solid var(--color-bg-container-border);
|
|
22
|
-
|
|
22
|
+
/* The content-card corner, Panel's and Widget's, so a chart beside a
|
|
23
|
+
panel or a table reads as one family of surfaces. */
|
|
24
|
+
border-radius: var(--radius-600); /* 24px */
|
|
23
25
|
background-color: var(--color-bg-container-primary);
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -85,6 +87,21 @@
|
|
|
85
87
|
color: var(--color-text-secondary);
|
|
86
88
|
}
|
|
87
89
|
|
|
90
|
+
/* A summary figure keyed to a series: the tooltip's dot, in that series'
|
|
91
|
+
colour, ahead of the label. */
|
|
92
|
+
.ds-chart__summary-label:has(.ds-chart__summary-swatch) {
|
|
93
|
+
display: inline-flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
gap: var(--gap-100);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.ds-chart__summary-swatch {
|
|
99
|
+
width: 8px;
|
|
100
|
+
height: 8px;
|
|
101
|
+
border-radius: var(--radius-pill);
|
|
102
|
+
flex-shrink: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
88
105
|
.ds-chart__summary-value {
|
|
89
106
|
font-family: var(--font-heading-1-family);
|
|
90
107
|
font-size: var(--font-heading-1-size);
|
|
@@ -110,6 +127,110 @@
|
|
|
110
127
|
fill-opacity: 0.45;
|
|
111
128
|
}
|
|
112
129
|
|
|
130
|
+
/* ============================================
|
|
131
|
+
SKELETON — the outline of the chart type,
|
|
132
|
+
drawn in the body until the marks exist.
|
|
133
|
+
recharts draws nothing before it has measured
|
|
134
|
+
its container in the browser, so the server
|
|
135
|
+
markup carries this instead of an empty box;
|
|
136
|
+
it leaves the moment recharts mounts its
|
|
137
|
+
wrapper. With `loading` it holds the body
|
|
138
|
+
(ChartSkeleton.tsx).
|
|
139
|
+
============================================ */
|
|
140
|
+
|
|
141
|
+
.ds-chart__skeleton {
|
|
142
|
+
position: absolute;
|
|
143
|
+
inset: 0;
|
|
144
|
+
pointer-events: none;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.ds-chart__body:has(.recharts-wrapper) > .ds-chart__skeleton {
|
|
148
|
+
display: none;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* While the host is loading there is no chart under it, so the placeholder
|
|
152
|
+
is in flow and its own height holds the body. */
|
|
153
|
+
.ds-chart__skeleton--held {
|
|
154
|
+
position: relative;
|
|
155
|
+
inset: auto;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* A cartesian drawing sits where the plot will: clear of the value axis on
|
|
159
|
+
the left and the category axis underneath. */
|
|
160
|
+
.ds-chart__skeleton--plotted {
|
|
161
|
+
/* ds-allow(spacing): recharts' own axis metrics (a 60px value axis less the charts' -12px margin, a 30px category axis), which no token carries */
|
|
162
|
+
padding: var(--padding-200) var(--padding-100) 30px 48px; /* ds-allow(physical): recharts draws the value axis on the screen's left in either reading direction */
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.ds-chart__skeleton-drawing {
|
|
166
|
+
display: block;
|
|
167
|
+
width: 100%;
|
|
168
|
+
height: 100%;
|
|
169
|
+
overflow: visible;
|
|
170
|
+
/* ds-allow(motion): the pulse needs a symmetric in-out curve and no
|
|
171
|
+
--motion-ease-* token provides one; the duration is tokenized. */
|
|
172
|
+
animation: ds-chart-skeleton-pulse var(--motion-duration-loop-shimmer) ease-in-out infinite alternate;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.ds-chart__skeleton-mark {
|
|
176
|
+
fill: var(--color-bg-container-secondary);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.ds-chart__skeleton-mark--soft {
|
|
180
|
+
opacity: 0.6;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/* Tiles and funnel bands are parted by a surface-coloured stroke, as the
|
|
184
|
+
real ones are. */
|
|
185
|
+
.ds-chart__skeleton-mark--tile {
|
|
186
|
+
stroke: var(--color-bg-container-primary);
|
|
187
|
+
stroke-width: 2px;
|
|
188
|
+
vector-effect: non-scaling-stroke;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.ds-chart__skeleton-grid {
|
|
192
|
+
fill: none;
|
|
193
|
+
stroke: var(--color-divider);
|
|
194
|
+
stroke-width: 1px;
|
|
195
|
+
vector-effect: non-scaling-stroke;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.ds-chart__skeleton-line,
|
|
199
|
+
.ds-chart__skeleton-dots,
|
|
200
|
+
.ds-chart__skeleton-ring {
|
|
201
|
+
fill: none;
|
|
202
|
+
stroke: var(--color-bg-container-secondary);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* A thin mark is too little ink to read in the Skeleton fill, so lines and
|
|
206
|
+
dots take the next container step. */
|
|
207
|
+
.ds-chart__skeleton-line,
|
|
208
|
+
.ds-chart__skeleton-dots {
|
|
209
|
+
stroke: var(--color-bg-container-tertiary);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.ds-chart__skeleton-line {
|
|
213
|
+
stroke-width: 3px;
|
|
214
|
+
stroke-linecap: round;
|
|
215
|
+
stroke-linejoin: round;
|
|
216
|
+
vector-effect: non-scaling-stroke;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.ds-chart__skeleton-dots {
|
|
220
|
+
stroke-width: 10px;
|
|
221
|
+
stroke-linecap: round;
|
|
222
|
+
vector-effect: non-scaling-stroke;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@keyframes ds-chart-skeleton-pulse {
|
|
226
|
+
from {
|
|
227
|
+
opacity: 1;
|
|
228
|
+
}
|
|
229
|
+
to {
|
|
230
|
+
opacity: 0.5;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
113
234
|
/* ============================================
|
|
114
235
|
BARE MODE — the chart sits inside another
|
|
115
236
|
panel that supplies the surface, so its own
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** The drawing a chart's placeholder takes: one per chart type. */
|
|
3
|
+
export type ChartSkeletonShape = 'area' | 'bar' | 'combo' | 'funnel' | 'line' | 'pie' | 'radar' | 'radial' | 'scatter' | 'stacked-bar' | 'treemap';
|
|
4
|
+
interface ChartSkeletonProps {
|
|
5
|
+
/** Which chart's outline to draw. */
|
|
6
|
+
shape: ChartSkeletonShape;
|
|
7
|
+
/** The chart area's height in pixels, the box the placeholder holds while the chart is loading. */
|
|
8
|
+
height: number;
|
|
9
|
+
/** True while the host is still fetching: the placeholder holds the body and is announced. */
|
|
10
|
+
loading: boolean;
|
|
11
|
+
/** The accessible name announced while `loading`. */
|
|
12
|
+
loadingLabel: string;
|
|
13
|
+
/** The inner radius of a pie's hole, in viewBox units out of 50; 0 draws a full disc. */
|
|
14
|
+
hole?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The placeholder a chart draws in its body until its marks exist: the
|
|
18
|
+
* outline of that chart type, in the Skeleton fill, pulsing.
|
|
19
|
+
*
|
|
20
|
+
* It covers two waits. recharts draws nothing until its container has been
|
|
21
|
+
* measured in the browser, so server markup, and every frame before
|
|
22
|
+
* hydration, would otherwise be an empty box: the placeholder is in that
|
|
23
|
+
* markup, and Chart.css hides it the moment recharts mounts its wrapper,
|
|
24
|
+
* with no state and no re-render. And while a host is still fetching, the
|
|
25
|
+
* chart's `loading` prop holds the placeholder in place of the chart and
|
|
26
|
+
* announces it.
|
|
27
|
+
*
|
|
28
|
+
* Internal to the chart family (a row of INTERNAL_PARTS): the charts are the
|
|
29
|
+
* public surface, through `loading` and `loadingLabel`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function ChartSkeleton({ shape, height, loading, loadingLabel, hole }: ChartSkeletonProps): React.JSX.Element;
|
|
32
|
+
export {};
|