@spatika/react 1.1.0 → 1.2.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/AGENTS.md +71 -0
- package/README.md +4 -3
- package/dist/composites/Card.d.ts +7 -1
- package/dist/composites/Card.d.ts.map +1 -1
- package/dist/composites/Card.js +10 -0
- package/dist/composites/ChartDataGrid.d.ts +33 -0
- package/dist/composites/ChartDataGrid.d.ts.map +1 -0
- package/dist/composites/ChartDataGrid.js +77 -0
- package/dist/composites/CoverHero.d.ts +1 -1
- package/dist/composites/CoverHero.d.ts.map +1 -1
- package/dist/composites/CoverHero.js +2 -2
- package/dist/composites/EntityMediaCard.d.ts +1 -1
- package/dist/composites/EntityMediaCard.d.ts.map +1 -1
- package/dist/composites/EntityMediaCard.js +12 -4
- package/dist/composites/EventCalendar.d.ts +35 -0
- package/dist/composites/EventCalendar.d.ts.map +1 -0
- package/dist/composites/EventCalendar.js +339 -0
- package/dist/composites/EventEditor.d.ts +22 -0
- package/dist/composites/EventEditor.d.ts.map +1 -0
- package/dist/composites/EventEditor.js +86 -0
- package/dist/composites/EventTimeline.d.ts +24 -0
- package/dist/composites/EventTimeline.d.ts.map +1 -0
- package/dist/composites/EventTimeline.js +184 -0
- package/dist/composites/MapChart.d.ts +24 -0
- package/dist/composites/MapChart.d.ts.map +1 -0
- package/dist/composites/MapChart.js +58 -0
- package/dist/composites/ProfileHero.d.ts +6 -4
- package/dist/composites/ProfileHero.d.ts.map +1 -1
- package/dist/composites/ProfileHero.js +8 -8
- package/dist/composites/ScatterWebGL.d.ts +22 -0
- package/dist/composites/ScatterWebGL.d.ts.map +1 -0
- package/dist/composites/ScatterWebGL.js +45 -0
- package/dist/composites/SiteFooter.d.ts +1 -1
- package/dist/composites/SiteFooter.js +1 -1
- package/dist/composites/SiteNav.d.ts +7 -2
- package/dist/composites/SiteNav.d.ts.map +1 -1
- package/dist/composites/SiteNav.js +9 -5
- package/dist/composites/StatCard.d.ts +2 -1
- package/dist/composites/StatCard.d.ts.map +1 -1
- package/dist/composites/StatCard.js +3 -3
- package/dist/composites/StatusDot.d.ts +1 -1
- package/dist/composites/Wordmark.d.ts +2 -2
- package/dist/composites/Wordmark.d.ts.map +1 -1
- package/dist/composites/cartesian-charts.d.ts +138 -0
- package/dist/composites/cartesian-charts.d.ts.map +1 -0
- package/dist/composites/cartesian-charts.js +401 -0
- package/dist/composites/chart-composition.d.ts +139 -0
- package/dist/composites/chart-composition.d.ts.map +1 -0
- package/dist/composites/chart-composition.js +486 -0
- package/dist/composites/chart-ui.d.ts +83 -0
- package/dist/composites/chart-ui.d.ts.map +1 -0
- package/dist/composites/chart-ui.js +108 -0
- package/dist/composites/charts-3d.d.ts +37 -0
- package/dist/composites/charts-3d.d.ts.map +1 -0
- package/dist/composites/charts-3d.js +121 -0
- package/dist/composites/flow-charts.d.ts +89 -0
- package/dist/composites/flow-charts.d.ts.map +1 -0
- package/dist/composites/flow-charts.js +186 -0
- package/dist/composites/radial-charts.d.ts +109 -0
- package/dist/composites/radial-charts.d.ts.map +1 -0
- package/dist/composites/radial-charts.js +176 -0
- package/dist/composites/scheduler-ui.d.ts +43 -0
- package/dist/composites/scheduler-ui.d.ts.map +1 -0
- package/dist/composites/scheduler-ui.js +71 -0
- package/dist/index.d.ts +67 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -7
- package/dist/lib/chart-export.d.ts +10 -0
- package/dist/lib/chart-export.d.ts.map +1 -0
- package/dist/lib/chart-export.js +102 -0
- package/dist/lib/charts.d.ts +235 -0
- package/dist/lib/charts.d.ts.map +1 -0
- package/dist/lib/charts.js +744 -0
- package/dist/lib/geo.d.ts +39 -0
- package/dist/lib/geo.d.ts.map +1 -0
- package/dist/lib/geo.js +101 -0
- package/dist/lib/iso.d.ts +21 -0
- package/dist/lib/iso.d.ts.map +1 -0
- package/dist/lib/iso.js +56 -0
- package/dist/lib/rrule.d.ts +20 -0
- package/dist/lib/rrule.d.ts.map +1 -0
- package/dist/lib/rrule.js +236 -0
- package/dist/lib/scheduler.d.ts +152 -0
- package/dist/lib/scheduler.d.ts.map +1 -0
- package/dist/lib/scheduler.js +501 -0
- package/dist/lib/webgl-scatter.d.ts +44 -0
- package/dist/lib/webgl-scatter.d.ts.map +1 -0
- package/dist/lib/webgl-scatter.js +185 -0
- package/dist/primitives/Accordion.d.ts +44 -20
- package/dist/primitives/Accordion.d.ts.map +1 -1
- package/dist/primitives/Accordion.js +82 -22
- package/dist/primitives/AppBar.d.ts +13 -0
- package/dist/primitives/AppBar.d.ts.map +1 -0
- package/dist/primitives/AppBar.js +27 -0
- package/dist/primitives/Autocomplete.d.ts +28 -0
- package/dist/primitives/Autocomplete.d.ts.map +1 -0
- package/dist/primitives/Autocomplete.js +118 -0
- package/dist/primitives/Avatar.d.ts +13 -1
- package/dist/primitives/Avatar.d.ts.map +1 -1
- package/dist/primitives/Avatar.js +17 -2
- package/dist/primitives/Backdrop.d.ts +17 -0
- package/dist/primitives/Backdrop.d.ts.map +1 -0
- package/dist/primitives/Backdrop.js +17 -0
- package/dist/primitives/BottomNavigation.d.ts +23 -0
- package/dist/primitives/BottomNavigation.d.ts.map +1 -0
- package/dist/primitives/BottomNavigation.js +30 -0
- package/dist/primitives/ButtonBase.d.ts +14 -0
- package/dist/primitives/ButtonBase.d.ts.map +1 -0
- package/dist/primitives/ButtonBase.js +13 -0
- package/dist/primitives/ButtonGroup.d.ts +25 -0
- package/dist/primitives/ButtonGroup.d.ts.map +1 -0
- package/dist/primitives/ButtonGroup.js +44 -0
- package/dist/primitives/CircularProgress.d.ts +16 -0
- package/dist/primitives/CircularProgress.d.ts.map +1 -0
- package/dist/primitives/CircularProgress.js +17 -0
- package/dist/primitives/ClickAwayListener.d.ts +16 -0
- package/dist/primitives/ClickAwayListener.d.ts.map +1 -0
- package/dist/primitives/ClickAwayListener.js +33 -0
- package/dist/primitives/Collapse.d.ts +19 -0
- package/dist/primitives/Collapse.d.ts.map +1 -0
- package/dist/primitives/Collapse.js +14 -0
- package/dist/primitives/Container.d.ts +13 -0
- package/dist/primitives/Container.d.ts.map +1 -0
- package/dist/primitives/Container.js +26 -0
- package/dist/primitives/Fab.d.ts +22 -0
- package/dist/primitives/Fab.d.ts.map +1 -0
- package/dist/primitives/Fab.js +42 -0
- package/dist/primitives/FormControl.d.ts +27 -0
- package/dist/primitives/FormControl.d.ts.map +1 -0
- package/dist/primitives/FormControl.js +24 -0
- package/dist/primitives/FormControlLabel.d.ts +18 -0
- package/dist/primitives/FormControlLabel.d.ts.map +1 -0
- package/dist/primitives/FormControlLabel.js +19 -0
- package/dist/primitives/Grid.d.ts +32 -0
- package/dist/primitives/Grid.d.ts.map +1 -0
- package/dist/primitives/Grid.js +50 -0
- package/dist/primitives/IconButton.d.ts +22 -0
- package/dist/primitives/IconButton.d.ts.map +1 -0
- package/dist/primitives/IconButton.js +39 -0
- package/dist/primitives/ImageList.d.ts +31 -0
- package/dist/primitives/ImageList.d.ts.map +1 -0
- package/dist/primitives/ImageList.js +33 -0
- package/dist/primitives/InputAdornment.d.ts +28 -0
- package/dist/primitives/InputAdornment.d.ts.map +1 -0
- package/dist/primitives/InputAdornment.js +13 -0
- package/dist/primitives/Link.d.ts +17 -0
- package/dist/primitives/Link.d.ts.map +1 -0
- package/dist/primitives/Link.js +29 -0
- package/dist/primitives/List.d.ts +41 -0
- package/dist/primitives/List.d.ts.map +1 -0
- package/dist/primitives/List.js +22 -0
- package/dist/primitives/Masonry.d.ts +14 -0
- package/dist/primitives/Masonry.d.ts.map +1 -0
- package/dist/primitives/Masonry.js +15 -0
- package/dist/primitives/Menu.d.ts +28 -0
- package/dist/primitives/Menu.d.ts.map +1 -0
- package/dist/primitives/Menu.js +54 -0
- package/dist/primitives/MobileStepper.d.ts +15 -0
- package/dist/primitives/MobileStepper.d.ts.map +1 -0
- package/dist/primitives/MobileStepper.js +8 -0
- package/dist/primitives/Modal.d.ts +18 -0
- package/dist/primitives/Modal.d.ts.map +1 -0
- package/dist/primitives/Modal.js +29 -0
- package/dist/primitives/NoSsr.d.ts +15 -0
- package/dist/primitives/NoSsr.d.ts.map +1 -0
- package/dist/primitives/NoSsr.js +19 -0
- package/dist/primitives/Paper.d.ts +22 -0
- package/dist/primitives/Paper.d.ts.map +1 -0
- package/dist/primitives/Paper.js +33 -0
- package/dist/primitives/Progress.d.ts +6 -2
- package/dist/primitives/Progress.d.ts.map +1 -1
- package/dist/primitives/Progress.js +8 -3
- package/dist/primitives/Snackbar.d.ts +23 -0
- package/dist/primitives/Snackbar.d.ts.map +1 -0
- package/dist/primitives/Snackbar.js +33 -0
- package/dist/primitives/SpeedDial.d.ts +26 -0
- package/dist/primitives/SpeedDial.d.ts.map +1 -0
- package/dist/primitives/SpeedDial.js +26 -0
- package/dist/primitives/Stack.d.ts +15 -0
- package/dist/primitives/Stack.d.ts.map +1 -0
- package/dist/primitives/Stack.js +45 -0
- package/dist/primitives/StarRating.d.ts +19 -1
- package/dist/primitives/StarRating.d.ts.map +1 -1
- package/dist/primitives/StarRating.js +36 -6
- package/dist/primitives/Stepper.d.ts +36 -0
- package/dist/primitives/Stepper.d.ts.map +1 -0
- package/dist/primitives/Stepper.js +53 -0
- package/dist/primitives/TablePagination.d.ts +16 -0
- package/dist/primitives/TablePagination.d.ts.map +1 -0
- package/dist/primitives/TablePagination.js +12 -0
- package/dist/primitives/TextField.d.ts +24 -0
- package/dist/primitives/TextField.d.ts.map +1 -0
- package/dist/primitives/TextField.js +19 -0
- package/dist/primitives/TextareaAutosize.d.ts +11 -0
- package/dist/primitives/TextareaAutosize.d.ts.map +1 -0
- package/dist/primitives/TextareaAutosize.js +26 -0
- package/dist/primitives/ToggleButton.d.ts +28 -0
- package/dist/primitives/ToggleButton.d.ts.map +1 -0
- package/dist/primitives/ToggleButton.js +56 -0
- package/dist/primitives/TransferList.d.ts +21 -0
- package/dist/primitives/TransferList.d.ts.map +1 -0
- package/dist/primitives/TransferList.js +40 -0
- package/dist/primitives/Typography.d.ts +23 -0
- package/dist/primitives/Typography.d.ts.map +1 -0
- package/dist/primitives/Typography.js +69 -0
- package/dist/primitives/transitions.d.ts +29 -0
- package/dist/primitives/transitions.d.ts.map +1 -0
- package/dist/primitives/transitions.js +52 -0
- package/package.json +28 -4
- package/skills/spatika-ui/SKILL.md +96 -0
- package/src/composites/Card.tsx +51 -1
- package/src/composites/ChartDataGrid.test.tsx +57 -0
- package/src/composites/ChartDataGrid.tsx +196 -0
- package/src/composites/CoverHero.test.tsx +38 -0
- package/src/composites/CoverHero.tsx +29 -22
- package/src/composites/EntityMediaCard.test.tsx +58 -0
- package/src/composites/EntityMediaCard.tsx +31 -13
- package/src/composites/EventCalendar.tsx +928 -0
- package/src/composites/EventEditor.tsx +268 -0
- package/src/composites/EventTimeline.tsx +357 -0
- package/src/composites/MapChart.test.tsx +39 -0
- package/src/composites/MapChart.tsx +130 -0
- package/src/composites/ProfileHero.test.tsx +33 -0
- package/src/composites/ProfileHero.tsx +96 -79
- package/src/composites/ScatterWebGL.test.tsx +25 -0
- package/src/composites/ScatterWebGL.tsx +79 -0
- package/src/composites/SiteFooter.test.tsx +37 -0
- package/src/composites/SiteFooter.tsx +1 -1
- package/src/composites/SiteNav.test.tsx +46 -0
- package/src/composites/SiteNav.tsx +14 -4
- package/src/composites/StatCard.test.tsx +30 -0
- package/src/composites/StatCard.tsx +4 -0
- package/src/composites/Wordmark.test.tsx +23 -0
- package/src/composites/Wordmark.tsx +2 -2
- package/src/composites/cartesian-charts.test.tsx +52 -0
- package/src/composites/cartesian-charts.tsx +1287 -0
- package/src/composites/chart-composition.test.tsx +53 -0
- package/src/composites/chart-composition.tsx +898 -0
- package/src/composites/chart-ui.tsx +328 -0
- package/src/composites/charts-3d.test.tsx +25 -0
- package/src/composites/charts-3d.tsx +318 -0
- package/src/composites/charts.test.tsx +254 -0
- package/src/composites/chrome.test.tsx +29 -0
- package/src/composites/flow-charts.test.tsx +79 -0
- package/src/composites/flow-charts.tsx +607 -0
- package/src/composites/marketing.test.tsx +38 -34
- package/src/composites/radial-charts.test.tsx +74 -0
- package/src/composites/radial-charts.tsx +617 -0
- package/src/composites/scheduler-ui.tsx +304 -0
- package/src/composites/scheduler.test.tsx +194 -0
- package/src/index.test.ts +22 -0
- package/src/index.ts +277 -5
- package/src/lib/chart-export.test.ts +20 -0
- package/src/lib/chart-export.ts +99 -0
- package/src/lib/charts-platform.test.ts +93 -0
- package/src/lib/charts.test.ts +132 -0
- package/src/lib/charts.ts +1021 -0
- package/src/lib/geo.test.ts +42 -0
- package/src/lib/geo.ts +138 -0
- package/src/lib/iso.test.ts +22 -0
- package/src/lib/iso.ts +102 -0
- package/src/lib/rrule.test.ts +53 -0
- package/src/lib/rrule.ts +281 -0
- package/src/lib/scheduler.test.ts +186 -0
- package/src/lib/scheduler.ts +688 -0
- package/src/lib/tokens.test.ts +2 -2
- package/src/lib/webgl-scatter.test.ts +36 -0
- package/src/lib/webgl-scatter.ts +230 -0
- package/src/primitives/Accordion.tsx +218 -63
- package/src/primitives/AppBar.tsx +39 -0
- package/src/primitives/Autocomplete.tsx +236 -0
- package/src/primitives/Avatar.tsx +52 -1
- package/src/primitives/Backdrop.tsx +48 -0
- package/src/primitives/BottomNavigation.tsx +102 -0
- package/src/primitives/ButtonBase.tsx +34 -0
- package/src/primitives/ButtonGroup.tsx +90 -0
- package/src/primitives/CircularProgress.tsx +104 -0
- package/src/primitives/ClickAwayListener.tsx +46 -0
- package/src/primitives/Collapse.tsx +39 -0
- package/src/primitives/Container.tsx +40 -0
- package/src/primitives/Fab.tsx +62 -0
- package/src/primitives/FormControl.tsx +90 -0
- package/src/primitives/FormControlLabel.tsx +51 -0
- package/src/primitives/Grid.tsx +101 -0
- package/src/primitives/IconButton.tsx +59 -0
- package/src/primitives/ImageList.test.tsx +48 -0
- package/src/primitives/ImageList.tsx +112 -0
- package/src/primitives/InputAdornment.tsx +86 -0
- package/src/primitives/Link.tsx +48 -0
- package/src/primitives/List.tsx +121 -0
- package/src/primitives/Masonry.tsx +32 -0
- package/src/primitives/Menu.tsx +112 -0
- package/src/primitives/MobileStepper.tsx +64 -0
- package/src/primitives/Modal.tsx +70 -0
- package/src/primitives/NoSsr.tsx +28 -0
- package/src/primitives/Paper.tsx +55 -0
- package/src/primitives/Progress.tsx +25 -7
- package/src/primitives/Snackbar.tsx +83 -0
- package/src/primitives/SpeedDial.tsx +110 -0
- package/src/primitives/Stack.tsx +88 -0
- package/src/primitives/StarRating.tsx +87 -28
- package/src/primitives/Stepper.tsx +184 -0
- package/src/primitives/TablePagination.tsx +58 -0
- package/src/primitives/TextField.tsx +105 -0
- package/src/primitives/TextareaAutosize.tsx +49 -0
- package/src/primitives/ToggleButton.tsx +148 -0
- package/src/primitives/TransferList.tsx +110 -0
- package/src/primitives/Typography.tsx +90 -0
- package/src/primitives/mui-more.test.tsx +76 -0
- package/src/primitives/mui.test.tsx +134 -0
- package/src/primitives/transitions.tsx +120 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { ChartContainer } from "./chart-composition";
|
|
5
|
+
import { BarChart, LineChart, ScatterChart, SparkLineChart, WaterfallChart } from "./cartesian-charts";
|
|
6
|
+
import { Gauge, LinearGauge, PieChart, RadarChart } from "./radial-charts";
|
|
7
|
+
import { FunnelChart, Heatmap, SankeyChart, Treemap } from "./flow-charts";
|
|
8
|
+
import { MapChart } from "./MapChart";
|
|
9
|
+
import { BarChart3D, PieChart3D } from "./charts-3d";
|
|
10
|
+
import { ChartDataGrid } from "./ChartDataGrid";
|
|
11
|
+
|
|
12
|
+
const months = ["Jan", "Feb", "Mar"];
|
|
13
|
+
|
|
14
|
+
describe("charts", () => {
|
|
15
|
+
it("renders a grouped bar chart and shows a tooltip on hover", async () => {
|
|
16
|
+
const user = userEvent.setup();
|
|
17
|
+
render(
|
|
18
|
+
<BarChart
|
|
19
|
+
width={360}
|
|
20
|
+
height={220}
|
|
21
|
+
xAxis={[{ data: months }]}
|
|
22
|
+
series={[
|
|
23
|
+
{ label: "Views", data: [4, 3, 5] },
|
|
24
|
+
{ label: "Signups", data: [1, 2, 2] },
|
|
25
|
+
]}
|
|
26
|
+
/>,
|
|
27
|
+
);
|
|
28
|
+
expect(screen.getByRole("img", { name: /bar chart/i })).toBeInTheDocument();
|
|
29
|
+
const marks = document.querySelectorAll('[data-slot="bar-plot"] .spk-chart-mark');
|
|
30
|
+
expect(marks.length).toBeGreaterThan(0);
|
|
31
|
+
await user.hover(marks[0]!);
|
|
32
|
+
expect(screen.getByRole("tooltip")).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("hides a line series from the legend", async () => {
|
|
36
|
+
const user = userEvent.setup();
|
|
37
|
+
render(
|
|
38
|
+
<LineChart
|
|
39
|
+
width={360}
|
|
40
|
+
height={220}
|
|
41
|
+
xAxis={[{ data: months }]}
|
|
42
|
+
series={[
|
|
43
|
+
{ label: "Revenue", data: [2, 4, 3] },
|
|
44
|
+
{ label: "Cost", data: [1, 1, 2] },
|
|
45
|
+
]}
|
|
46
|
+
/>,
|
|
47
|
+
);
|
|
48
|
+
const paths = () => document.querySelectorAll('[data-slot="line-plot"] path');
|
|
49
|
+
const before = paths().length;
|
|
50
|
+
await user.click(screen.getByRole("button", { name: "Cost" }));
|
|
51
|
+
expect(paths().length).toBeLessThan(before);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("renders pie, gauge, radar, scatter, sparkline, and linear gauge", () => {
|
|
55
|
+
const { container } = render(
|
|
56
|
+
<div>
|
|
57
|
+
<PieChart
|
|
58
|
+
width={200}
|
|
59
|
+
height={200}
|
|
60
|
+
series={[{ data: [{ value: 10, label: "A" }, { value: 20, label: "B" }] }]}
|
|
61
|
+
/>
|
|
62
|
+
<Gauge value={40} width={160} height={120} />
|
|
63
|
+
<Gauge
|
|
64
|
+
width={160}
|
|
65
|
+
height={120}
|
|
66
|
+
startAngle={-90}
|
|
67
|
+
endAngle={90}
|
|
68
|
+
sections={[
|
|
69
|
+
{ value: 40, label: "v5" },
|
|
70
|
+
{ value: 35, label: "v6" },
|
|
71
|
+
{ value: 25, label: "v7" },
|
|
72
|
+
]}
|
|
73
|
+
/>
|
|
74
|
+
<LinearGauge value={25} width={200} />
|
|
75
|
+
<RadarChart
|
|
76
|
+
width={220}
|
|
77
|
+
height={220}
|
|
78
|
+
radar={{ metrics: ["A", "B", "C"] }}
|
|
79
|
+
series={[{ label: "One", data: [3, 5, 4] }]}
|
|
80
|
+
/>
|
|
81
|
+
<ScatterChart
|
|
82
|
+
width={220}
|
|
83
|
+
height={180}
|
|
84
|
+
series={[{ label: "Pts", data: [{ x: 1, y: 2, id: 1 }] }]}
|
|
85
|
+
/>
|
|
86
|
+
<SparkLineChart data={[1, 4, 2, 6]} width={160} height={48} />
|
|
87
|
+
</div>,
|
|
88
|
+
);
|
|
89
|
+
expect(container.querySelector('[data-slot="pie-chart"]')).toBeTruthy();
|
|
90
|
+
expect(container.querySelector('[data-slot="gauge"]')).toBeTruthy();
|
|
91
|
+
expect(screen.getByRole("button", { name: "v5" })).toBeInTheDocument();
|
|
92
|
+
expect(container.querySelector('[data-slot="linear-gauge"]')).toBeTruthy();
|
|
93
|
+
expect(container.querySelector('[data-slot="radar-chart"]')).toBeTruthy();
|
|
94
|
+
expect(container.querySelector('[data-slot="scatter-chart"]')).toBeTruthy();
|
|
95
|
+
expect(container.querySelector('[data-slot="sparkline"]')).toBeTruthy();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("renders heatmap, funnel, sankey, treemap, and waterfall", () => {
|
|
99
|
+
const { container } = render(
|
|
100
|
+
<div>
|
|
101
|
+
<Heatmap
|
|
102
|
+
width={240}
|
|
103
|
+
height={160}
|
|
104
|
+
xAxis={[{ data: ["A", "B"] }]}
|
|
105
|
+
yAxis={[{ data: ["1"] }]}
|
|
106
|
+
series={[{ data: [{ x: 0, y: 0, value: 2 }, { x: 1, y: 0, value: 5 }] }]}
|
|
107
|
+
/>
|
|
108
|
+
<FunnelChart
|
|
109
|
+
width={240}
|
|
110
|
+
height={180}
|
|
111
|
+
series={[{ data: [{ label: "Visit", value: 10 }, { label: "Paid", value: 3 }] }]}
|
|
112
|
+
/>
|
|
113
|
+
<SankeyChart
|
|
114
|
+
width={280}
|
|
115
|
+
height={180}
|
|
116
|
+
series={{
|
|
117
|
+
data: [{ id: "a" }, { id: "b" }],
|
|
118
|
+
links: [{ source: "a", target: "b", value: 4 }],
|
|
119
|
+
}}
|
|
120
|
+
/>
|
|
121
|
+
<Treemap
|
|
122
|
+
width={240}
|
|
123
|
+
height={160}
|
|
124
|
+
series={[{ data: [{ label: "A", value: 8 }, { label: "B", value: 4 }] }]}
|
|
125
|
+
/>
|
|
126
|
+
<WaterfallChart
|
|
127
|
+
width={280}
|
|
128
|
+
height={180}
|
|
129
|
+
xAxis={[{ data: ["Start", "Up", "End"] }]}
|
|
130
|
+
series={[{ data: [10, 4, null] }]}
|
|
131
|
+
/>
|
|
132
|
+
</div>,
|
|
133
|
+
);
|
|
134
|
+
expect(container.querySelector('[data-slot="heatmap"]')).toBeTruthy();
|
|
135
|
+
expect(container.querySelector('[data-slot="funnel-chart"]')).toBeTruthy();
|
|
136
|
+
expect(container.querySelector('[data-slot="sankey-chart"]')).toBeTruthy();
|
|
137
|
+
expect(container.querySelector('[data-slot="treemap"]')).toBeTruthy();
|
|
138
|
+
expect(container.querySelector('[data-slot="waterfall-chart"]')).toBeTruthy();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("composes bar and line plots from a dataset with a toolbar", async () => {
|
|
142
|
+
const user = userEvent.setup();
|
|
143
|
+
const { container } = render(
|
|
144
|
+
<ChartContainer
|
|
145
|
+
width={360}
|
|
146
|
+
height={220}
|
|
147
|
+
zoom
|
|
148
|
+
showToolbar
|
|
149
|
+
dataset={[
|
|
150
|
+
{ month: "Jan", views: 4, conv: 1 },
|
|
151
|
+
{ month: "Feb", views: 6, conv: 2 },
|
|
152
|
+
{ month: "Mar", views: 5, conv: 2 },
|
|
153
|
+
]}
|
|
154
|
+
xAxis={[{ dataKey: "month" }]}
|
|
155
|
+
yAxis={[{ id: "left" }, { id: "right", position: "right" }]}
|
|
156
|
+
series={[
|
|
157
|
+
{ type: "bar", dataKey: "views", label: "Views" },
|
|
158
|
+
{ type: "line", dataKey: "conv", label: "Conv", yAxisId: "right" },
|
|
159
|
+
]}
|
|
160
|
+
/>,
|
|
161
|
+
);
|
|
162
|
+
expect(container.querySelector('[data-slot="bar-plot"]')).toBeTruthy();
|
|
163
|
+
expect(container.querySelector('[data-slot="line-plot"]')).toBeTruthy();
|
|
164
|
+
expect(container.querySelector('[data-slot="chart-y-axis-right"]')).toBeTruthy();
|
|
165
|
+
expect(screen.getByRole("toolbar", { name: "Chart tools" })).toBeInTheDocument();
|
|
166
|
+
await user.click(screen.getByRole("button", { name: "Zoom in" }));
|
|
167
|
+
expect(container.querySelector("svg")).toBeTruthy();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("renders a map, isometric 3d charts, and a sparkline bar", () => {
|
|
171
|
+
const { container } = render(
|
|
172
|
+
<div>
|
|
173
|
+
<MapChart
|
|
174
|
+
width={240}
|
|
175
|
+
height={160}
|
|
176
|
+
geoData={{
|
|
177
|
+
type: "FeatureCollection",
|
|
178
|
+
features: [
|
|
179
|
+
{
|
|
180
|
+
type: "Feature",
|
|
181
|
+
id: "a",
|
|
182
|
+
properties: { name: "A" },
|
|
183
|
+
geometry: {
|
|
184
|
+
type: "Polygon",
|
|
185
|
+
coordinates: [
|
|
186
|
+
[
|
|
187
|
+
[0, 0],
|
|
188
|
+
[4, 0],
|
|
189
|
+
[4, 3],
|
|
190
|
+
[0, 3],
|
|
191
|
+
[0, 0],
|
|
192
|
+
],
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
}}
|
|
198
|
+
series={[{ data: [{ id: "a", value: 12, label: "A" }] }]}
|
|
199
|
+
/>
|
|
200
|
+
<BarChart3D
|
|
201
|
+
width={240}
|
|
202
|
+
height={160}
|
|
203
|
+
xAxis={[{ data: ["A", "B"] }]}
|
|
204
|
+
series={[{ label: "Views", data: [3, 5] }]}
|
|
205
|
+
/>
|
|
206
|
+
<PieChart3D
|
|
207
|
+
width={200}
|
|
208
|
+
height={160}
|
|
209
|
+
series={[{ data: [{ value: 2, label: "A" }, { value: 3, label: "B" }] }]}
|
|
210
|
+
/>
|
|
211
|
+
<SparkLineChart data={[1, 3, 2, 5]} plotType="bar" width={120} height={36} />
|
|
212
|
+
<ScatterChart
|
|
213
|
+
width={200}
|
|
214
|
+
height={140}
|
|
215
|
+
renderer="webgl"
|
|
216
|
+
series={[{ label: "Pts", data: [{ x: 1, y: 2, id: 1 }] }]}
|
|
217
|
+
/>
|
|
218
|
+
</div>,
|
|
219
|
+
);
|
|
220
|
+
expect(container.querySelector('[data-slot="map-chart"]')).toBeTruthy();
|
|
221
|
+
expect(container.querySelector('[data-slot="map-chart"] path')).toBeTruthy();
|
|
222
|
+
expect(container.querySelector('[data-slot="bar-chart-3d"]')).toBeTruthy();
|
|
223
|
+
expect(container.querySelector('[data-slot="pie-chart-3d"]')).toBeTruthy();
|
|
224
|
+
expect(container.querySelector('[data-slot="sparkline"] rect')).toBeTruthy();
|
|
225
|
+
expect(container.querySelector('[data-slot="scatter-chart"]')).toBeTruthy();
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it("highlights a chart bar from a selected grid row", async () => {
|
|
229
|
+
const user = userEvent.setup();
|
|
230
|
+
const { container } = render(
|
|
231
|
+
<ChartDataGrid
|
|
232
|
+
height={140}
|
|
233
|
+
categoryField="name"
|
|
234
|
+
valueField="views"
|
|
235
|
+
rows={[
|
|
236
|
+
{ id: "web", name: "Web", views: 10, trend: [1, 2, 3] },
|
|
237
|
+
{ id: "ios", name: "iOS", views: 6, trend: [2, 2, 1] },
|
|
238
|
+
]}
|
|
239
|
+
columns={[
|
|
240
|
+
{ field: "name", headerName: "Channel" },
|
|
241
|
+
{ field: "views", headerName: "Views", type: "number" },
|
|
242
|
+
{ field: "trend", headerName: "Trend", type: "sparkline" },
|
|
243
|
+
]}
|
|
244
|
+
/>,
|
|
245
|
+
);
|
|
246
|
+
expect(container.querySelector('[data-slot="chart-data-grid"]')).toBeTruthy();
|
|
247
|
+
const row = container.querySelector(
|
|
248
|
+
'[data-slot="chart-data-grid"] tbody [data-slot="table-row"]:nth-child(2)',
|
|
249
|
+
);
|
|
250
|
+
expect(row).toBeTruthy();
|
|
251
|
+
await user.click(row!);
|
|
252
|
+
expect(row).toHaveAttribute("data-state", "selected");
|
|
253
|
+
});
|
|
254
|
+
});
|
|
@@ -120,6 +120,20 @@ describe("CoverHero", () => {
|
|
|
120
120
|
expect(screen.getByText("Friday night · Studio district")).toBeInTheDocument();
|
|
121
121
|
expect(screen.getByText("Meetup Story")).toBeInTheDocument();
|
|
122
122
|
expect(screen.getByText("When")).toBeInTheDocument();
|
|
123
|
+
expect(document.querySelector("[data-slot='cover-hero']")).toHaveAttribute(
|
|
124
|
+
"data-cover-bleed",
|
|
125
|
+
"true",
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("keeps the cover inside the frame when bleed is off", () => {
|
|
130
|
+
render(
|
|
131
|
+
<CoverHero title="Coastal Drive" coverSeed="coast" bleed={false} />,
|
|
132
|
+
);
|
|
133
|
+
const hero = document.querySelector("[data-slot='cover-hero']");
|
|
134
|
+
expect(hero).not.toHaveAttribute("data-cover-bleed");
|
|
135
|
+
expect(hero).toHaveClass("overflow-hidden");
|
|
136
|
+
expect(document.querySelector(".cover-chrome-bar")).toBeNull();
|
|
123
137
|
});
|
|
124
138
|
});
|
|
125
139
|
|
|
@@ -132,6 +146,21 @@ describe("ProfileHero", () => {
|
|
|
132
146
|
expect(screen.getByText("Product designer")).toBeInTheDocument();
|
|
133
147
|
expect(container.querySelector(".profile-identity")).toBeTruthy();
|
|
134
148
|
expect(container.querySelector(".profile-identity__plate")).toBeTruthy();
|
|
149
|
+
expect(container.querySelector("[data-slot='profile-hero']")).toHaveAttribute(
|
|
150
|
+
"data-cover-bleed",
|
|
151
|
+
"true",
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("contains the cover when bleed is off", () => {
|
|
156
|
+
const { container } = render(
|
|
157
|
+
<ProfileHero name="Alex Chen" alias="Product designer" coverSeed="alex" bleed={false} />,
|
|
158
|
+
);
|
|
159
|
+
const hero = container.querySelector("[data-slot='profile-hero']");
|
|
160
|
+
expect(hero).not.toHaveAttribute("data-cover-bleed");
|
|
161
|
+
expect(hero).toHaveClass("overflow-hidden");
|
|
162
|
+
expect(hero?.querySelector(".cover-media")).toBeTruthy();
|
|
163
|
+
expect(screen.getByRole("button", { name: "Alex Chen" })).toBeDisabled();
|
|
135
164
|
});
|
|
136
165
|
});
|
|
137
166
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { FunnelChart, Heatmap } from "./flow-charts";
|
|
4
|
+
|
|
5
|
+
describe("FunnelChart", () => {
|
|
6
|
+
it("renders a comparison overlay with inside and outside value labels", () => {
|
|
7
|
+
render(
|
|
8
|
+
<FunnelChart
|
|
9
|
+
width={280}
|
|
10
|
+
height={200}
|
|
11
|
+
valueFormatter={(value) => `${value}%`}
|
|
12
|
+
series={[
|
|
13
|
+
{
|
|
14
|
+
label: "2000",
|
|
15
|
+
data: [
|
|
16
|
+
{ label: "Primary", value: 85 },
|
|
17
|
+
{ label: "Secondary", value: 50 },
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: "2020",
|
|
22
|
+
data: [
|
|
23
|
+
{ label: "Primary", value: 90 },
|
|
24
|
+
{ label: "Secondary", value: 67 },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
]}
|
|
28
|
+
/>,
|
|
29
|
+
);
|
|
30
|
+
expect(screen.getByRole("img", { name: /funnel chart/i })).toBeInTheDocument();
|
|
31
|
+
expect(screen.getByText("85%")).toBeInTheDocument();
|
|
32
|
+
expect(screen.getByText("90%")).toBeInTheDocument();
|
|
33
|
+
expect(screen.getByText("67%")).toBeInTheDocument();
|
|
34
|
+
expect(document.querySelectorAll('[data-slot="funnel-chart"] path').length).toBe(4);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("keeps stage names on a single funnel when the legend is hidden", () => {
|
|
38
|
+
render(
|
|
39
|
+
<FunnelChart
|
|
40
|
+
width={240}
|
|
41
|
+
height={160}
|
|
42
|
+
hideLegend
|
|
43
|
+
series={[{ data: [{ label: "Visit", value: 10 }, { label: "Paid", value: 3 }] }]}
|
|
44
|
+
/>,
|
|
45
|
+
);
|
|
46
|
+
expect(screen.getByText("Visit")).toBeInTheDocument();
|
|
47
|
+
expect(screen.getByText("Paid")).toBeInTheDocument();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("Heatmap", () => {
|
|
52
|
+
it("draws a color scale for the value domain", () => {
|
|
53
|
+
const { container } = render(
|
|
54
|
+
<Heatmap
|
|
55
|
+
width={240}
|
|
56
|
+
height={160}
|
|
57
|
+
xAxis={[{ data: ["A", "B"] }]}
|
|
58
|
+
yAxis={[{ data: ["1"] }]}
|
|
59
|
+
series={[{ data: [{ x: 0, y: 0, value: 2 }, { x: 1, y: 0, value: 8 }] }]}
|
|
60
|
+
/>,
|
|
61
|
+
);
|
|
62
|
+
expect(container.querySelector('[data-slot="heatmap-color-scale"]')).toBeTruthy();
|
|
63
|
+
expect(screen.getByText("8")).toBeInTheDocument();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("hides the color scale when hideLegend is set", () => {
|
|
67
|
+
const { container } = render(
|
|
68
|
+
<Heatmap
|
|
69
|
+
width={240}
|
|
70
|
+
height={160}
|
|
71
|
+
hideLegend
|
|
72
|
+
xAxis={[{ data: ["A"] }]}
|
|
73
|
+
yAxis={[{ data: ["1"] }]}
|
|
74
|
+
series={[{ data: [{ x: 0, y: 0, value: 4 }] }]}
|
|
75
|
+
/>,
|
|
76
|
+
);
|
|
77
|
+
expect(container.querySelector('[data-slot="heatmap-color-scale"]')).toBeNull();
|
|
78
|
+
});
|
|
79
|
+
});
|