rift-ds 1.40.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/README.md +6 -2
- 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/shell.css +9 -11
- 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 +41 -116
- package/bin/templates/blocks/components/blocks/DocsShell.tsx +5 -1
- package/bin/templates/blocks/registry.json +44 -6
- package/chat/ChatLauncher.d.ts +2 -2
- package/chat/ChatWidget.css +7 -7
- package/chat/ChatWidget.d.ts +1 -1
- 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/AppLayout/AppLayout.css +1 -1
- package/components/AppLayout/AppLayout.d.ts +2 -2
- package/components/AppSidebar/AppSidebar.css +25 -17
- package/components/AppSidebar/AppSidebar.d.ts +4 -4
- package/components/AppSidebar/AppSidebar.js +14 -5
- package/components/Attachment/AttachmentGroup.js +2 -1
- package/components/Attachment/AttachmentTile.js +2 -1
- package/components/Avatar/Avatar.css +18 -5
- package/components/Avatar/Avatar.d.ts +2 -0
- package/components/Avatar/Avatar.js +2 -1
- package/components/AvatarGroup/AvatarGroup.css +8 -1
- package/components/AvatarGroup/AvatarGroup.d.ts +6 -0
- package/components/AvatarGroup/AvatarGroup.js +2 -2
- 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 +91 -4
- package/components/DataTable/DataTable.d.ts +42 -4
- package/components/DataTable/DataTable.js +121 -90
- 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/DrillMenu/DrillMenu.d.ts +2 -1
- package/components/DrillMenu/DrillMenu.js +14 -3
- package/components/Dropdown/Dropdown.css +3 -1
- package/components/EmptyState/EmptyState.css +8 -1
- package/components/EntitySwitcher/EntitySwitcher.css +2 -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/Icon/Icon.css +6 -1
- package/components/Icon/Icon.d.ts +3 -1
- package/components/Icon/Icon.js +2 -0
- 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/PixelAvatar/PixelAvatar.css +7 -1
- package/components/PixelAvatar/PixelAvatar.d.ts +2 -0
- package/components/PixelAvatar/PixelAvatar.js +2 -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/ShaderField/useShaderField.js +2 -2
- package/components/ShaderScene/ShaderScene.js +2 -2
- package/components/SiteHeader/SiteHeader.css +0 -9
- package/components/SourceChip/SourceChip.css +2 -1
- 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/SubNavPanel/SubNavPanel.css +10 -9
- package/components/Table/Table.css +409 -14
- package/components/Table/Table.d.ts +32 -2
- package/components/Table/Table.js +66 -34
- 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 +5 -2
- package/components/registry.json.d.ts +5 -2
- package/components/registry.json.js +1 -1
- package/package.json +9 -3
- package/tokens/motion.d.ts +2 -0
- package/tokens/motion.js +2 -0
- package/tokens/presets/contrast.css +36 -3
- package/tokens/presets/coral.css +39 -3
- package/tokens/presets/forest.css +55 -3
- package/tokens/presets/gold.css +39 -4
- package/tokens/presets/marquee.css +42 -4
- package/tokens/presets/mono.css +107 -29
- package/tokens/presets/pink.css +41 -3
- package/tokens/presets/plum.css +41 -1
- package/tokens/presets/terminal.css +40 -4
- package/tokens/presets/violet.css +42 -3
- package/tokens/presets/warm.css +49 -5
- package/tokens/presets/zest.css +47 -3
- package/tokens/registry.json +2 -0
- package/tokens/registry.json.d.ts +2 -0
- package/tokens/registry.json.js +1 -1
- package/tokens/tokens-dark.css +5 -0
- package/tokens/tokens-light.css +9 -0
- package/tokens/values.d.ts +14 -1
- package/tokens/values.js +14 -1
- package/tokens/values.json.js +1 -1
|
@@ -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
|
);
|
|
@@ -33,6 +33,13 @@ type RadarChartOwnProps = {
|
|
|
33
33
|
height?: number;
|
|
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, { useCallback, useId, useState } from "react";
|
|
|
4
4
|
import { ResponsiveContainer, RadarChart as RadarChart$1, PolarGrid, PolarAngleAxis, PolarRadiusAxis, Tooltip, Radar, 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 { formatAxisNumber, formatNumber } from "../../behaviors/locale.js";
|
|
@@ -30,6 +31,8 @@ const RadarChart = React.forwardRef(({
|
|
|
30
31
|
summaryItems,
|
|
31
32
|
height = 350,
|
|
32
33
|
bare = false,
|
|
34
|
+
loading = false,
|
|
35
|
+
loadingLabel = "Loading chart",
|
|
33
36
|
className = "",
|
|
34
37
|
locale: localeProp,
|
|
35
38
|
...rest
|
|
@@ -93,38 +96,41 @@ const RadarChart = React.forwardRef(({
|
|
|
93
96
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? formatNumber(item.value, locale) : item.value })
|
|
94
97
|
] }, i)) })
|
|
95
98
|
] }),
|
|
96
|
-
/* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */ jsx(
|
|
98
|
-
/* @__PURE__ */ jsx(
|
|
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
|
-
|
|
99
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__body`, children: [
|
|
100
|
+
/* @__PURE__ */ jsx(ChartSkeleton, { shape: "radar", height, loading, loadingLabel }),
|
|
101
|
+
!loading && /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, onResize: (width) => setBodyWidth(width), children: /* @__PURE__ */ jsxs(RadarChart$1, { data, cx: "50%", cy: "50%", outerRadius, children: [
|
|
102
|
+
/* @__PURE__ */ jsx(PolarGrid, { stroke: gridColor }),
|
|
103
|
+
/* @__PURE__ */ jsx(PolarAngleAxis, { dataKey: categoryKey, tick: renderAngleTick }),
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
105
|
+
PolarRadiusAxis,
|
|
106
|
+
{
|
|
107
|
+
tickFormatter: formatTick,
|
|
108
|
+
tick: { fill: textSecondary, fontSize: textSize },
|
|
109
|
+
axisLine: false,
|
|
110
|
+
tickCount: 5
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
|
|
114
|
+
series.map((s, i) => /* @__PURE__ */ jsx(
|
|
115
|
+
Radar,
|
|
116
|
+
{
|
|
117
|
+
...animation,
|
|
118
|
+
name: s.label,
|
|
119
|
+
dataKey: s.dataKey,
|
|
120
|
+
stroke: s.color || seriesColors[i % seriesColors.length],
|
|
121
|
+
fill: s.color || seriesColors[i % seriesColors.length],
|
|
122
|
+
fillOpacity: s.fillOpacity ?? 0.3
|
|
123
|
+
},
|
|
124
|
+
s.dataKey
|
|
125
|
+
)),
|
|
126
|
+
series.length > 1 && /* @__PURE__ */ jsx(
|
|
127
|
+
Legend,
|
|
128
|
+
{
|
|
129
|
+
wrapperStyle: { color: textSecondary, fontSize: textSize }
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
] }) })
|
|
133
|
+
] })
|
|
128
134
|
]
|
|
129
135
|
}
|
|
130
136
|
);
|
|
@@ -39,6 +39,13 @@ type RadialChartOwnProps = {
|
|
|
39
39
|
centerSublabel?: string;
|
|
40
40
|
/** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
|
|
41
41
|
bare?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Holds the chart's placeholder, the outline of this chart type, in place of the chart while its data is still being fetched.
|
|
44
|
+
* Before its first draw the chart shows the same placeholder by itself, so this is only for a wait the host knows about.
|
|
45
|
+
*/
|
|
46
|
+
loading?: boolean;
|
|
47
|
+
/** Accessible name announced while `loading`. */
|
|
48
|
+
loadingLabel?: string;
|
|
42
49
|
/** Additional CSS classes on the wrapper */
|
|
43
50
|
className?: string;
|
|
44
51
|
};
|
|
@@ -4,6 +4,7 @@ import React, { useId, useCallback } from "react";
|
|
|
4
4
|
import { ResponsiveContainer, RadialBarChart, PolarAngleAxis, RadialBar, 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";
|
|
@@ -38,6 +39,8 @@ const RadialChart = React.forwardRef(({
|
|
|
38
39
|
centerLabel,
|
|
39
40
|
centerSublabel,
|
|
40
41
|
bare = false,
|
|
42
|
+
loading = false,
|
|
43
|
+
loadingLabel = "Loading chart",
|
|
41
44
|
className = "",
|
|
42
45
|
locale: localeProp,
|
|
43
46
|
...rest
|
|
@@ -82,7 +85,8 @@ const RadialChart = React.forwardRef(({
|
|
|
82
85
|
] }, i)) })
|
|
83
86
|
] }),
|
|
84
87
|
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__body`, children: [
|
|
85
|
-
/* @__PURE__ */ jsx(
|
|
88
|
+
/* @__PURE__ */ jsx(ChartSkeleton, { shape: "radial", height, loading, loadingLabel }),
|
|
89
|
+
!loading && /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(
|
|
86
90
|
RadialBarChart,
|
|
87
91
|
{
|
|
88
92
|
cx: "50%",
|
|
@@ -37,6 +37,13 @@ type ScatterChartOwnProps = {
|
|
|
37
37
|
yAxisFormatter?: (value: number) => string;
|
|
38
38
|
/** Strip the card chrome (border, padding, fill) when the chart sits inside another panel that supplies the surface */
|
|
39
39
|
bare?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Holds the chart's placeholder, the outline of this chart type, in place of the chart while its data is still being fetched.
|
|
42
|
+
* Before its first draw the chart shows the same placeholder by itself, so this is only for a wait the host knows about.
|
|
43
|
+
*/
|
|
44
|
+
loading?: boolean;
|
|
45
|
+
/** Accessible name announced while `loading`. */
|
|
46
|
+
loadingLabel?: string;
|
|
40
47
|
/** Additional CSS classes on the wrapper */
|
|
41
48
|
className?: string;
|
|
42
49
|
};
|