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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
const GRID_ROWS = "M0 0H100M0 25H100M0 50H100M0 75H100M0 100H100";
|
|
4
|
+
const GRID_COLUMNS = "M0 0V100M25 0V100M50 0V100M75 0V100M100 0V100";
|
|
5
|
+
const BAR_HEIGHTS = [46, 72, 58, 88, 64, 78, 42];
|
|
6
|
+
const BAND = 100 / BAR_HEIGHTS.length;
|
|
7
|
+
const BAR_WIDTH = BAND * 0.6;
|
|
8
|
+
const BAR_INSET = BAND * 0.2;
|
|
9
|
+
const TREND = "M0 70C8 62 12 42 20 46S34 72 42 60S58 22 66 32S84 54 100 26";
|
|
10
|
+
const DOTS = "M8 72h0M15 50h0M22 80h0M28 58h0M34 36h0M41 64h0M47 44h0M54 70h0M60 28h0M66 52h0M73 38h0M79 60h0M86 22h0M93 42h0";
|
|
11
|
+
const TILES = [
|
|
12
|
+
[0, 0, 46, 100],
|
|
13
|
+
[46, 0, 54, 56],
|
|
14
|
+
[46, 56, 30, 44],
|
|
15
|
+
[76, 56, 24, 24],
|
|
16
|
+
[76, 80, 24, 20]
|
|
17
|
+
];
|
|
18
|
+
const FUNNEL_WIDTHS = [100, 74, 50, 32, 32];
|
|
19
|
+
function ring(radius, radii) {
|
|
20
|
+
const count = 6;
|
|
21
|
+
return Array.from({ length: count }, (_, i) => {
|
|
22
|
+
const angle = Math.PI / 180 * (-90 + 360 / count * i);
|
|
23
|
+
const r = radii ? radii[i] : radius;
|
|
24
|
+
return `${(50 + r * Math.cos(angle)).toFixed(2)},${(50 + r * Math.sin(angle)).toFixed(2)}`;
|
|
25
|
+
}).join(" ");
|
|
26
|
+
}
|
|
27
|
+
function bars(stacked) {
|
|
28
|
+
return BAR_HEIGHTS.map((h, i) => {
|
|
29
|
+
const x = i * BAND + BAR_INSET;
|
|
30
|
+
if (!stacked) {
|
|
31
|
+
return /* @__PURE__ */ jsx("rect", { className: "ds-chart__skeleton-mark", x, y: 100 - h, width: BAR_WIDTH, height: h }, i);
|
|
32
|
+
}
|
|
33
|
+
const lower = h * 0.58;
|
|
34
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
35
|
+
/* @__PURE__ */ jsx("rect", { className: "ds-chart__skeleton-mark", x, y: 100 - lower, width: BAR_WIDTH, height: lower }),
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
37
|
+
"rect",
|
|
38
|
+
{
|
|
39
|
+
className: "ds-chart__skeleton-mark ds-chart__skeleton-mark--soft",
|
|
40
|
+
x,
|
|
41
|
+
y: 100 - h,
|
|
42
|
+
width: BAR_WIDTH,
|
|
43
|
+
height: h - lower
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
] }, i);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function drawing(shape, hole) {
|
|
50
|
+
switch (shape) {
|
|
51
|
+
case "bar":
|
|
52
|
+
case "stacked-bar":
|
|
53
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
54
|
+
/* @__PURE__ */ jsx("path", { className: "ds-chart__skeleton-grid", d: GRID_ROWS }),
|
|
55
|
+
bars(shape === "stacked-bar")
|
|
56
|
+
] });
|
|
57
|
+
case "combo":
|
|
58
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
59
|
+
/* @__PURE__ */ jsx("path", { className: "ds-chart__skeleton-grid", d: GRID_ROWS }),
|
|
60
|
+
/* @__PURE__ */ jsx("g", { className: "ds-chart__skeleton-mark--soft", children: bars(false) }),
|
|
61
|
+
/* @__PURE__ */ jsx("path", { className: "ds-chart__skeleton-line", d: TREND })
|
|
62
|
+
] });
|
|
63
|
+
case "line":
|
|
64
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
65
|
+
/* @__PURE__ */ jsx("path", { className: "ds-chart__skeleton-grid", d: GRID_ROWS }),
|
|
66
|
+
/* @__PURE__ */ jsx("path", { className: "ds-chart__skeleton-line", d: TREND })
|
|
67
|
+
] });
|
|
68
|
+
case "area":
|
|
69
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
70
|
+
/* @__PURE__ */ jsx("path", { className: "ds-chart__skeleton-grid", d: GRID_ROWS }),
|
|
71
|
+
/* @__PURE__ */ jsx("path", { className: "ds-chart__skeleton-mark ds-chart__skeleton-mark--soft", d: `${TREND}V100H0Z` }),
|
|
72
|
+
/* @__PURE__ */ jsx("path", { className: "ds-chart__skeleton-line", d: TREND })
|
|
73
|
+
] });
|
|
74
|
+
case "scatter":
|
|
75
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
76
|
+
/* @__PURE__ */ jsx("path", { className: "ds-chart__skeleton-grid", d: GRID_ROWS + GRID_COLUMNS }),
|
|
77
|
+
/* @__PURE__ */ jsx("path", { className: "ds-chart__skeleton-dots", d: DOTS })
|
|
78
|
+
] });
|
|
79
|
+
case "pie": {
|
|
80
|
+
const inner = Math.min(Math.max(hole, 0), 40);
|
|
81
|
+
return inner > 0 ? /* @__PURE__ */ jsx(
|
|
82
|
+
"circle",
|
|
83
|
+
{
|
|
84
|
+
className: "ds-chart__skeleton-ring",
|
|
85
|
+
cx: "50",
|
|
86
|
+
cy: "50",
|
|
87
|
+
r: (45 + inner) / 2,
|
|
88
|
+
strokeWidth: 45 - inner
|
|
89
|
+
}
|
|
90
|
+
) : /* @__PURE__ */ jsx("circle", { className: "ds-chart__skeleton-mark", cx: "50", cy: "50", r: "45" });
|
|
91
|
+
}
|
|
92
|
+
case "radial":
|
|
93
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
94
|
+
/* @__PURE__ */ jsx("circle", { className: "ds-chart__skeleton-ring", cx: "50", cy: "50", r: "37", strokeWidth: "5" }),
|
|
95
|
+
/* @__PURE__ */ jsx("circle", { className: "ds-chart__skeleton-ring", cx: "50", cy: "50", r: "28", strokeWidth: "5" }),
|
|
96
|
+
/* @__PURE__ */ jsx("circle", { className: "ds-chart__skeleton-ring", cx: "50", cy: "50", r: "19", strokeWidth: "5" })
|
|
97
|
+
] });
|
|
98
|
+
case "radar":
|
|
99
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
100
|
+
/* @__PURE__ */ jsx("polygon", { className: "ds-chart__skeleton-grid", points: ring(36) }),
|
|
101
|
+
/* @__PURE__ */ jsx("polygon", { className: "ds-chart__skeleton-grid", points: ring(24) }),
|
|
102
|
+
/* @__PURE__ */ jsx("polygon", { className: "ds-chart__skeleton-grid", points: ring(12) }),
|
|
103
|
+
/* @__PURE__ */ jsx("polygon", { className: "ds-chart__skeleton-mark", points: ring(0, [30, 20, 27, 16, 29, 22]) })
|
|
104
|
+
] });
|
|
105
|
+
case "treemap":
|
|
106
|
+
return TILES.map(([x, y, width, height], i) => /* @__PURE__ */ jsx("rect", { className: "ds-chart__skeleton-mark ds-chart__skeleton-mark--tile", x, y, width, height }, i));
|
|
107
|
+
case "funnel":
|
|
108
|
+
return FUNNEL_WIDTHS.slice(0, -1).map((top, i) => {
|
|
109
|
+
const bottom = FUNNEL_WIDTHS[i + 1];
|
|
110
|
+
const y0 = i * 25;
|
|
111
|
+
const y1 = y0 + 25;
|
|
112
|
+
return /* @__PURE__ */ jsx(
|
|
113
|
+
"polygon",
|
|
114
|
+
{
|
|
115
|
+
className: "ds-chart__skeleton-mark ds-chart__skeleton-mark--tile",
|
|
116
|
+
points: `${50 - top / 2},${y0} ${50 + top / 2},${y0} ${50 + bottom / 2},${y1} ${50 - bottom / 2},${y1}`
|
|
117
|
+
},
|
|
118
|
+
i
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const POLAR = /* @__PURE__ */ new Set(["pie", "radar", "radial"]);
|
|
124
|
+
const PLOTTED = /* @__PURE__ */ new Set(["area", "bar", "combo", "line", "scatter", "stacked-bar"]);
|
|
125
|
+
function ChartSkeleton({ shape, height, loading, loadingLabel, hole = 0 }) {
|
|
126
|
+
const classes = [
|
|
127
|
+
"ds-chart__skeleton",
|
|
128
|
+
PLOTTED.has(shape) ? "ds-chart__skeleton--plotted" : "",
|
|
129
|
+
loading ? "ds-chart__skeleton--held" : ""
|
|
130
|
+
].filter(Boolean).join(" ");
|
|
131
|
+
const svg = /* @__PURE__ */ jsx(
|
|
132
|
+
"svg",
|
|
133
|
+
{
|
|
134
|
+
className: "ds-chart__skeleton-drawing",
|
|
135
|
+
viewBox: "0 0 100 100",
|
|
136
|
+
preserveAspectRatio: POLAR.has(shape) ? "xMidYMid meet" : "none",
|
|
137
|
+
"aria-hidden": "true",
|
|
138
|
+
focusable: "false",
|
|
139
|
+
children: drawing(shape, hole)
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
if (loading) {
|
|
143
|
+
return /* @__PURE__ */ jsx("div", { className: classes, role: "status", "aria-label": loadingLabel, "aria-busy": "true", style: { height }, children: svg });
|
|
144
|
+
}
|
|
145
|
+
return /* @__PURE__ */ jsx("div", { className: classes, "aria-hidden": "true", children: svg });
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
ChartSkeleton
|
|
149
|
+
};
|
|
@@ -45,6 +45,13 @@ type ComboChartOwnProps = {
|
|
|
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, ComposedChart, CartesianGrid, XAxis, YAxis, Toolti
|
|
|
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";
|
|
@@ -43,6 +44,8 @@ const ComboChart = React.forwardRef(({
|
|
|
43
44
|
summaryItems,
|
|
44
45
|
height = 350,
|
|
45
46
|
bare = false,
|
|
47
|
+
loading = false,
|
|
48
|
+
loadingLabel = "Loading chart",
|
|
46
49
|
className = "",
|
|
47
50
|
onActiveChange,
|
|
48
51
|
yAxisFormatter,
|
|
@@ -97,80 +100,83 @@ const ComboChart = React.forwardRef(({
|
|
|
97
100
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? formatNumber(item.value, locale) : item.value })
|
|
98
101
|
] }, i)) })
|
|
99
102
|
] }),
|
|
100
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
103
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__body`, children: [
|
|
104
|
+
/* @__PURE__ */ jsx(ChartSkeleton, { shape: "combo", height, loading, loadingLabel }),
|
|
105
|
+
!loading && /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(
|
|
106
|
+
ComposedChart,
|
|
107
|
+
{
|
|
108
|
+
data,
|
|
109
|
+
margin: { top: 8, right: secondaryAxis ? -12 : 4, bottom: 0, left: -12 },
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: gridColor }),
|
|
112
|
+
/* @__PURE__ */ jsx(
|
|
113
|
+
XAxis,
|
|
114
|
+
{
|
|
115
|
+
dataKey: xKey,
|
|
116
|
+
tick: { fill: textSecondary, fontSize: textSize },
|
|
117
|
+
tickLine: false,
|
|
118
|
+
axisLine: { stroke: gridColor }
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
/* @__PURE__ */ jsx(
|
|
122
|
+
YAxis,
|
|
123
|
+
{
|
|
124
|
+
tickFormatter: yAxisFormatter ?? formatTick,
|
|
125
|
+
yAxisId: "bar",
|
|
126
|
+
tick: { fill: textSecondary, fontSize: textSize },
|
|
127
|
+
tickLine: false,
|
|
128
|
+
axisLine: false
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
secondaryAxis && /* @__PURE__ */ jsx(
|
|
132
|
+
YAxis,
|
|
133
|
+
{
|
|
134
|
+
tickFormatter: secondaryAxisFormatter ?? formatTick,
|
|
135
|
+
yAxisId: "line",
|
|
136
|
+
orientation: "right",
|
|
137
|
+
tick: { fill: textSecondary, fontSize: textSize },
|
|
138
|
+
tickLine: false,
|
|
139
|
+
axisLine: false
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
/* @__PURE__ */ jsx(
|
|
143
|
+
Tooltip,
|
|
144
|
+
{
|
|
145
|
+
content: renderTooltip,
|
|
146
|
+
cursor: { fill: cursorColor, opacity: 0.4 }
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
/* @__PURE__ */ jsx(
|
|
150
|
+
Bar,
|
|
151
|
+
{
|
|
152
|
+
...animation,
|
|
153
|
+
className: `${baseClass}__bar`,
|
|
154
|
+
yAxisId: "bar",
|
|
155
|
+
dataKey: barKey,
|
|
156
|
+
name: resolvedBarLabel,
|
|
157
|
+
fill: resolvedBarColor,
|
|
158
|
+
radius: [3, 3, 0, 0],
|
|
159
|
+
maxBarSize: 32
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
/* @__PURE__ */ jsx(
|
|
163
|
+
Line,
|
|
164
|
+
{
|
|
165
|
+
...animation,
|
|
166
|
+
yAxisId: secondaryAxis ? "line" : "bar",
|
|
167
|
+
type: "monotone",
|
|
168
|
+
dataKey: lineKey,
|
|
169
|
+
name: resolvedLineLabel,
|
|
170
|
+
stroke: resolvedLineColor,
|
|
171
|
+
strokeWidth: 2,
|
|
172
|
+
dot: false,
|
|
173
|
+
activeDot: { r: 4, strokeWidth: 0 }
|
|
174
|
+
}
|
|
175
|
+
)
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
) })
|
|
179
|
+
] })
|
|
174
180
|
]
|
|
175
181
|
}
|
|
176
182
|
);
|
|
@@ -3,13 +3,18 @@ import { ChartActiveHandler, ChartSummaryItem } from './BarChart';
|
|
|
3
3
|
export interface LineSeriesConfig {
|
|
4
4
|
/** Key in data for this series */
|
|
5
5
|
dataKey: string;
|
|
6
|
-
/** Display name (shown in tooltip) */
|
|
6
|
+
/** Display name (shown in the tooltip and the legend) */
|
|
7
7
|
label: string;
|
|
8
8
|
/** Line colour — CSS value */
|
|
9
9
|
color?: string;
|
|
10
10
|
/** Dashed line */
|
|
11
11
|
strokeDasharray?: string;
|
|
12
12
|
}
|
|
13
|
+
/** A summary stat in a line chart's header, which can be keyed to one of its lines. */
|
|
14
|
+
export interface LineChartSummaryItem extends ChartSummaryItem {
|
|
15
|
+
/** The `dataKey` of the series this figure belongs to. The item then carries a swatch in that line's colour, so the header keys the lines. */
|
|
16
|
+
seriesKey?: string;
|
|
17
|
+
}
|
|
13
18
|
/** Props owned by LineChart itself; everything else falls through to the root div. */
|
|
14
19
|
type LineChartOwnProps = {
|
|
15
20
|
/** The BCP 47 locale the values, tooltips and value axis are written in, such as `de-DE`. Defaults to the nearest LocaleProvider's, else `en-US`. */
|
|
@@ -27,12 +32,14 @@ type LineChartOwnProps = {
|
|
|
27
32
|
title?: string;
|
|
28
33
|
/** Description text below the title */
|
|
29
34
|
subtitle?: string;
|
|
30
|
-
/** Summary stats displayed in the header */
|
|
31
|
-
summaryItems?:
|
|
35
|
+
/** Summary stats displayed in the header. An item that names a series through `seriesKey` carries that line's colour as a swatch. */
|
|
36
|
+
summaryItems?: LineChartSummaryItem[];
|
|
32
37
|
/** Chart area height in pixels */
|
|
33
38
|
height?: number;
|
|
34
39
|
/** Y-axis tick formatter, such as a currency or a percent. Defaults to a short number in the chart's locale. */
|
|
35
40
|
yAxisFormatter?: (value: number) => string;
|
|
41
|
+
/** Show the legend under a multi-series chart. On by default; a chart with one line never draws it. */
|
|
42
|
+
showLegend?: boolean;
|
|
36
43
|
/** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
|
|
37
44
|
bare?: boolean;
|
|
38
45
|
/**
|
|
@@ -41,6 +48,13 @@ type LineChartOwnProps = {
|
|
|
41
48
|
* neither is on the plot. For a headline figure that follows the cursor.
|
|
42
49
|
*/
|
|
43
50
|
onActiveChange?: ChartActiveHandler;
|
|
51
|
+
/**
|
|
52
|
+
* Holds the chart's placeholder, the outline of this chart type, in place of the chart while its data is still being fetched.
|
|
53
|
+
* Before its first draw the chart shows the same placeholder by itself, so this is only for a wait the host knows about.
|
|
54
|
+
*/
|
|
55
|
+
loading?: boolean;
|
|
56
|
+
/** Accessible name announced while `loading`. */
|
|
57
|
+
loadingLabel?: string;
|
|
44
58
|
/** Additional CSS classes on the wrapper */
|
|
45
59
|
className?: string;
|
|
46
60
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
3
3
|
import React, { useCallback, useId } from "react";
|
|
4
|
-
import { ResponsiveContainer, LineChart as LineChart$1, CartesianGrid, XAxis, YAxis, Tooltip, Line } from "recharts";
|
|
4
|
+
import { ResponsiveContainer, LineChart as LineChart$1, CartesianGrid, XAxis, YAxis, Tooltip, Line, Legend } from "recharts";
|
|
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";
|
|
@@ -30,7 +31,10 @@ const LineChart = React.forwardRef(({
|
|
|
30
31
|
subtitle,
|
|
31
32
|
summaryItems,
|
|
32
33
|
height = 350,
|
|
34
|
+
showLegend = true,
|
|
33
35
|
bare = false,
|
|
36
|
+
loading = false,
|
|
37
|
+
loadingLabel = "Loading chart",
|
|
34
38
|
className = "",
|
|
35
39
|
onActiveChange,
|
|
36
40
|
yAxisFormatter,
|
|
@@ -51,6 +55,10 @@ const LineChart = React.forwardRef(({
|
|
|
51
55
|
const textSize = readTokenPx("--font-caption-size", "12px");
|
|
52
56
|
const gridColor = getCSSVar("--color-divider", "rgba(214, 214, 214, 0.8)");
|
|
53
57
|
const seriesColors = getChartSeriesColors();
|
|
58
|
+
const colorOf = (dataKey) => {
|
|
59
|
+
const index = dataKey === void 0 ? -1 : series.findIndex((s) => s.dataKey === dataKey);
|
|
60
|
+
return index < 0 ? void 0 : series[index].color || seriesColors[index % seriesColors.length];
|
|
61
|
+
};
|
|
54
62
|
const renderTooltip = useCallback(
|
|
55
63
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
56
64
|
(props) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -75,47 +83,61 @@ const LineChart = React.forwardRef(({
|
|
|
75
83
|
subtitle && /* @__PURE__ */ jsx("p", { id: subtitleId, className: `${baseClass}__subtitle`, children: subtitle })
|
|
76
84
|
] }),
|
|
77
85
|
summaryItems && summaryItems.length > 0 && /* @__PURE__ */ jsx("div", { className: `${baseClass}__summary`, children: summaryItems.map((item, i) => /* @__PURE__ */ jsxs("div", { className: `${baseClass}__summary-item`, children: [
|
|
78
|
-
/* @__PURE__ */
|
|
86
|
+
/* @__PURE__ */ jsxs("span", { className: `${baseClass}__summary-label`, children: [
|
|
87
|
+
colorOf(item.seriesKey) && /* @__PURE__ */ jsx(
|
|
88
|
+
"span",
|
|
89
|
+
{
|
|
90
|
+
className: `${baseClass}__summary-swatch`,
|
|
91
|
+
style: { backgroundColor: colorOf(item.seriesKey) },
|
|
92
|
+
"aria-hidden": "true"
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
item.label
|
|
96
|
+
] }),
|
|
79
97
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? formatNumber(item.value, locale) : item.value })
|
|
80
98
|
] }, i)) })
|
|
81
99
|
] }),
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
/* @__PURE__ */ jsx(
|
|
84
|
-
/* @__PURE__ */ jsx(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
100
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__body`, children: [
|
|
101
|
+
/* @__PURE__ */ jsx(ChartSkeleton, { shape: "line", height, loading, loadingLabel }),
|
|
102
|
+
!loading && /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(LineChart$1, { data, margin: { top: 8, right: 4, bottom: 0, left: -12 }, children: [
|
|
103
|
+
/* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: gridColor }),
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
105
|
+
XAxis,
|
|
106
|
+
{
|
|
107
|
+
dataKey: xKey,
|
|
108
|
+
tick: { fill: textSecondary, fontSize: textSize },
|
|
109
|
+
tickLine: false,
|
|
110
|
+
axisLine: { stroke: gridColor }
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ jsx(
|
|
114
|
+
YAxis,
|
|
115
|
+
{
|
|
116
|
+
tickFormatter: yAxisFormatter ?? formatTick,
|
|
117
|
+
tick: { fill: textSecondary, fontSize: textSize },
|
|
118
|
+
tickLine: false,
|
|
119
|
+
axisLine: false
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
/* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
|
|
123
|
+
series.map((s, i) => /* @__PURE__ */ jsx(
|
|
124
|
+
Line,
|
|
125
|
+
{
|
|
126
|
+
...animation,
|
|
127
|
+
type: "monotone",
|
|
128
|
+
dataKey: s.dataKey,
|
|
129
|
+
name: s.label,
|
|
130
|
+
stroke: s.color || seriesColors[i % seriesColors.length],
|
|
131
|
+
strokeWidth: 2,
|
|
132
|
+
strokeDasharray: s.strokeDasharray,
|
|
133
|
+
dot: false,
|
|
134
|
+
activeDot: { r: 4, strokeWidth: 0 }
|
|
135
|
+
},
|
|
136
|
+
s.dataKey
|
|
137
|
+
)),
|
|
138
|
+
showLegend && series.length > 1 && /* @__PURE__ */ jsx(Legend, { wrapperStyle: { color: textSecondary, fontSize: textSize } })
|
|
139
|
+
] }) })
|
|
140
|
+
] })
|
|
119
141
|
]
|
|
120
142
|
}
|
|
121
143
|
);
|
|
@@ -33,6 +33,13 @@ type PieChartOwnProps = {
|
|
|
33
33
|
showLegend?: boolean;
|
|
34
34
|
/** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
|
|
35
35
|
bare?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Holds the chart's placeholder, the outline of this chart type, in place of the chart while its data is still being fetched.
|
|
38
|
+
* Before its first draw the chart shows the same placeholder by itself, so this is only for a wait the host knows about.
|
|
39
|
+
*/
|
|
40
|
+
loading?: boolean;
|
|
41
|
+
/** Accessible name announced while `loading`. */
|
|
42
|
+
loadingLabel?: string;
|
|
36
43
|
/** Additional CSS classes on the wrapper */
|
|
37
44
|
className?: string;
|
|
38
45
|
};
|
|
@@ -4,6 +4,7 @@ import React, { useId, useCallback } from "react";
|
|
|
4
4
|
import { ResponsiveContainer, PieChart as PieChart$1, Pie, Cell, Tooltip, Legend } from "recharts";
|
|
5
5
|
import { readTokenPx, getChartSeriesColors } from "./palette.js";
|
|
6
6
|
import { useChartAnimation } from "./useChartAnimation.js";
|
|
7
|
+
import { ChartSkeleton } from "./ChartSkeleton.js";
|
|
7
8
|
import "./Chart.css";
|
|
8
9
|
import { useLocale } from "../../behaviors/LocaleProvider.js";
|
|
9
10
|
import { formatNumber } from "../../behaviors/locale.js";
|
|
@@ -35,6 +36,8 @@ const PieChart = React.forwardRef(({
|
|
|
35
36
|
outerRadius = "90%",
|
|
36
37
|
showLegend = true,
|
|
37
38
|
bare = false,
|
|
39
|
+
loading = false,
|
|
40
|
+
loadingLabel = "Loading chart",
|
|
38
41
|
className = "",
|
|
39
42
|
locale: localeProp,
|
|
40
43
|
...rest
|
|
@@ -53,6 +56,7 @@ const PieChart = React.forwardRef(({
|
|
|
53
56
|
(props) => /* @__PURE__ */ jsx(PieChartTooltip, { ...props, locale }),
|
|
54
57
|
[locale]
|
|
55
58
|
);
|
|
59
|
+
const skeletonHole = typeof innerRadius === "string" ? parseFloat(innerRadius) / 100 * 50 || 0 : height > 0 ? innerRadius * 100 / height : 0;
|
|
56
60
|
return /* @__PURE__ */ jsxs(
|
|
57
61
|
"div",
|
|
58
62
|
{
|
|
@@ -73,40 +77,43 @@ const PieChart = React.forwardRef(({
|
|
|
73
77
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? formatNumber(item.value, locale) : item.value })
|
|
74
78
|
] }, i)) })
|
|
75
79
|
] }),
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
/* @__PURE__ */ jsx(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
80
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__body`, children: [
|
|
81
|
+
/* @__PURE__ */ jsx(ChartSkeleton, { shape: "pie", height, loading, loadingLabel, hole: skeletonHole }),
|
|
82
|
+
!loading && /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(PieChart$1, { children: [
|
|
83
|
+
/* @__PURE__ */ jsx(
|
|
84
|
+
Pie,
|
|
85
|
+
{
|
|
86
|
+
...animation,
|
|
87
|
+
data,
|
|
88
|
+
dataKey: "value",
|
|
89
|
+
nameKey: "name",
|
|
90
|
+
cx: "50%",
|
|
91
|
+
cy: "50%",
|
|
92
|
+
innerRadius,
|
|
93
|
+
outerRadius,
|
|
94
|
+
strokeWidth: 2,
|
|
95
|
+
stroke: "var(--color-bg-container-primary)",
|
|
96
|
+
children: data.map((slice, i) => /* @__PURE__ */ jsx(
|
|
97
|
+
Cell,
|
|
98
|
+
{
|
|
99
|
+
fill: slice.color || defaultColors[i % defaultColors.length]
|
|
100
|
+
},
|
|
101
|
+
slice.name
|
|
102
|
+
))
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
|
|
106
|
+
showLegend && /* @__PURE__ */ jsx(
|
|
107
|
+
Legend,
|
|
108
|
+
{
|
|
109
|
+
verticalAlign: "bottom",
|
|
110
|
+
iconType: "circle",
|
|
111
|
+
iconSize: 8,
|
|
112
|
+
formatter: (value) => /* @__PURE__ */ jsx("span", { style: { color: textSecondary, fontSize: textSize }, children: value })
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
] }) })
|
|
116
|
+
] })
|
|
110
117
|
]
|
|
111
118
|
}
|
|
112
119
|
);
|