rift-ds 1.0.1 → 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.
Files changed (51) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +8 -2
  3. package/components/AppLayout/AppLayout.css +13 -3
  4. package/components/AppLayout/AppLayout.d.ts +5 -1
  5. package/components/AppLayout/AppLayout.js +4 -0
  6. package/components/AppSidebar/AppSidebar.css +237 -0
  7. package/components/AppSidebar/AppSidebar.d.ts +32 -3
  8. package/components/AppSidebar/AppSidebar.js +187 -16
  9. package/components/BottomNav/BottomNav.css +417 -0
  10. package/components/BottomNav/BottomNav.d.ts +73 -0
  11. package/components/BottomNav/BottomNav.js +100 -0
  12. package/components/Chart/AreaChart.js +67 -56
  13. package/components/Chart/BarChart.js +67 -56
  14. package/components/Chart/ComboChart.js +93 -82
  15. package/components/Chart/LineChart.js +59 -48
  16. package/components/Chart/PieChart.js +56 -45
  17. package/components/Chart/RadarChart.js +60 -49
  18. package/components/Chart/RadialChart.js +70 -59
  19. package/components/Chart/ScatterChart.js +61 -50
  20. package/components/Chart/StackedBarChart.js +64 -53
  21. package/components/Chart/Treemap.js +34 -23
  22. package/components/Inspector/Inspector.css +511 -0
  23. package/components/Inspector/InspectorDropdown.d.ts +39 -0
  24. package/components/Inspector/InspectorDropdown.js +68 -0
  25. package/components/Inspector/InspectorInput.d.ts +32 -0
  26. package/components/Inspector/InspectorInput.js +52 -0
  27. package/components/Inspector/InspectorSection.d.ts +32 -0
  28. package/components/Inspector/InspectorSection.js +70 -0
  29. package/components/Inspector/InspectorSegmentedControl.d.ts +46 -0
  30. package/components/Inspector/InspectorSegmentedControl.js +62 -0
  31. package/components/Inspector/InspectorSlider.d.ts +41 -0
  32. package/components/Inspector/InspectorSlider.js +81 -0
  33. package/components/Inspector/InspectorToggleSwitch.d.ts +29 -0
  34. package/components/Inspector/InspectorToggleSwitch.js +51 -0
  35. package/components/Nav/Nav.d.ts +11 -3
  36. package/components/Nav/Nav.js +3 -2
  37. package/components/SegmentedControl/SegmentedControl.css +7 -5
  38. package/components/SidebarPanel/SidebarPanel.css +291 -0
  39. package/components/SidebarPanel/SidebarPanel.d.ts +45 -0
  40. package/components/SidebarPanel/SidebarPanel.js +166 -0
  41. package/components/Stepper/Stepper.d.ts +3 -1
  42. package/components/Stepper/Stepper.js +1 -1
  43. package/components/TopAppBar/TopAppBar.css +464 -0
  44. package/components/TopAppBar/TopAppBar.d.ts +80 -0
  45. package/components/TopAppBar/TopAppBar.js +138 -0
  46. package/components/registry.json +84 -1
  47. package/components/registry.json.d.ts +84 -1
  48. package/components/registry.json.js +2 -2
  49. package/index.d.ts +9 -0
  50. package/index.js +18 -0
  51. package/package.json +5 -1
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useCallback } from "react";
2
+ import { useId, useCallback } from "react";
3
3
  import { ResponsiveContainer, PieChart as PieChart$1, Pie, Cell, Tooltip, Legend } from "recharts";
4
4
  import { getChartSeriesColors } from "./palette.js";
5
5
  import "./Chart.css";
@@ -33,6 +33,8 @@ const PieChart = ({
33
33
  bare = false,
34
34
  className = ""
35
35
  }) => {
36
+ const titleId = useId();
37
+ const subtitleId = useId();
36
38
  const baseClass = "ds-chart";
37
39
  const classes = [baseClass, bare ? `${baseClass}--bare` : "", className].filter(Boolean).join(" ");
38
40
  const defaultColors = getChartSeriesColors();
@@ -42,51 +44,60 @@ const PieChart = ({
42
44
  (props) => /* @__PURE__ */ jsx(PieChartTooltip, { ...props }),
43
45
  []
44
46
  );
45
- return /* @__PURE__ */ jsxs("div", { className: classes, children: [
46
- (title || subtitle || summaryItems) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
47
- /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header-text`, children: [
48
- title && /* @__PURE__ */ jsx("h3", { className: `${baseClass}__title`, children: title }),
49
- subtitle && /* @__PURE__ */ jsx("p", { className: `${baseClass}__subtitle`, children: subtitle })
50
- ] }),
51
- summaryItems && summaryItems.length > 0 && /* @__PURE__ */ jsx("div", { className: `${baseClass}__summary`, children: summaryItems.map((item, i) => /* @__PURE__ */ jsxs("div", { className: `${baseClass}__summary-item`, children: [
52
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-label`, children: item.label }),
53
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? item.value.toLocaleString() : item.value })
54
- ] }, i)) })
55
- ] }),
56
- /* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(PieChart$1, { children: [
57
- /* @__PURE__ */ jsx(
58
- Pie,
59
- {
60
- data,
61
- dataKey: "value",
62
- nameKey: "name",
63
- cx: "50%",
64
- cy: "50%",
65
- innerRadius,
66
- outerRadius,
67
- strokeWidth: 2,
68
- stroke: "var(--color-bg-container-primary)",
69
- children: data.map((slice, i) => /* @__PURE__ */ jsx(
70
- Cell,
47
+ return /* @__PURE__ */ jsxs(
48
+ "div",
49
+ {
50
+ className: classes,
51
+ role: "figure",
52
+ "aria-labelledby": title ? titleId : void 0,
53
+ "aria-describedby": subtitle ? subtitleId : void 0,
54
+ children: [
55
+ (title || subtitle || summaryItems) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
56
+ /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header-text`, children: [
57
+ title && /* @__PURE__ */ jsx("h3", { id: titleId, className: `${baseClass}__title`, children: title }),
58
+ subtitle && /* @__PURE__ */ jsx("p", { id: subtitleId, className: `${baseClass}__subtitle`, children: subtitle })
59
+ ] }),
60
+ summaryItems && summaryItems.length > 0 && /* @__PURE__ */ jsx("div", { className: `${baseClass}__summary`, children: summaryItems.map((item, i) => /* @__PURE__ */ jsxs("div", { className: `${baseClass}__summary-item`, children: [
61
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-label`, children: item.label }),
62
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? item.value.toLocaleString() : item.value })
63
+ ] }, i)) })
64
+ ] }),
65
+ /* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(PieChart$1, { children: [
66
+ /* @__PURE__ */ jsx(
67
+ Pie,
71
68
  {
72
- fill: slice.color || defaultColors[i % defaultColors.length]
73
- },
74
- slice.name
75
- ))
76
- }
77
- ),
78
- /* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
79
- showLegend && /* @__PURE__ */ jsx(
80
- Legend,
81
- {
82
- verticalAlign: "bottom",
83
- iconType: "circle",
84
- iconSize: 8,
85
- formatter: (value) => /* @__PURE__ */ jsx("span", { style: { color: textSecondary, fontSize: 12 }, children: value })
86
- }
87
- )
88
- ] }) }) })
89
- ] });
69
+ data,
70
+ dataKey: "value",
71
+ nameKey: "name",
72
+ cx: "50%",
73
+ cy: "50%",
74
+ innerRadius,
75
+ outerRadius,
76
+ strokeWidth: 2,
77
+ stroke: "var(--color-bg-container-primary)",
78
+ children: data.map((slice, i) => /* @__PURE__ */ jsx(
79
+ Cell,
80
+ {
81
+ fill: slice.color || defaultColors[i % defaultColors.length]
82
+ },
83
+ slice.name
84
+ ))
85
+ }
86
+ ),
87
+ /* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
88
+ showLegend && /* @__PURE__ */ jsx(
89
+ Legend,
90
+ {
91
+ verticalAlign: "bottom",
92
+ iconType: "circle",
93
+ iconSize: 8,
94
+ formatter: (value) => /* @__PURE__ */ jsx("span", { style: { color: textSecondary, fontSize: 12 }, children: value })
95
+ }
96
+ )
97
+ ] }) }) })
98
+ ]
99
+ }
100
+ );
90
101
  };
91
102
  export {
92
103
  PieChart
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useCallback } from "react";
2
+ import { useId, useCallback } from "react";
3
3
  import { ResponsiveContainer, RadarChart as RadarChart$1, PolarGrid, PolarAngleAxis, PolarRadiusAxis, Tooltip, Radar, Legend } from "recharts";
4
4
  import { getChartSeriesColors } from "./palette.js";
5
5
  import "./Chart.css";
@@ -28,6 +28,8 @@ const RadarChart = ({
28
28
  bare = false,
29
29
  className = ""
30
30
  }) => {
31
+ const titleId = useId();
32
+ const subtitleId = useId();
31
33
  const baseClass = "ds-chart";
32
34
  const classes = [baseClass, bare ? `${baseClass}--bare` : "", className].filter(Boolean).join(" ");
33
35
  const textSecondary = getCSSVar("--color-text-secondary", "#303030");
@@ -38,54 +40,63 @@ const RadarChart = ({
38
40
  (props) => /* @__PURE__ */ jsx(RadarTooltip, { ...props }),
39
41
  []
40
42
  );
41
- return /* @__PURE__ */ jsxs("div", { className: classes, children: [
42
- (title || subtitle || summaryItems) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
43
- /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header-text`, children: [
44
- title && /* @__PURE__ */ jsx("h3", { className: `${baseClass}__title`, children: title }),
45
- subtitle && /* @__PURE__ */ jsx("p", { className: `${baseClass}__subtitle`, children: subtitle })
46
- ] }),
47
- summaryItems && summaryItems.length > 0 && /* @__PURE__ */ jsx("div", { className: `${baseClass}__summary`, children: summaryItems.map((item, i) => /* @__PURE__ */ jsxs("div", { className: `${baseClass}__summary-item`, children: [
48
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-label`, children: item.label }),
49
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? item.value.toLocaleString() : item.value })
50
- ] }, i)) })
51
- ] }),
52
- /* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(RadarChart$1, { data, cx: "50%", cy: "50%", outerRadius: "70%", children: [
53
- /* @__PURE__ */ jsx(PolarGrid, { stroke: gridColor }),
54
- /* @__PURE__ */ jsx(
55
- PolarAngleAxis,
56
- {
57
- dataKey: categoryKey,
58
- tick: { fill: textSecondary, fontSize: 12 }
59
- }
60
- ),
61
- /* @__PURE__ */ jsx(
62
- PolarRadiusAxis,
63
- {
64
- tick: { fill: textSecondary, fontSize: 10 },
65
- axisLine: false,
66
- tickCount: 5
67
- }
68
- ),
69
- /* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
70
- series.map((s, i) => /* @__PURE__ */ jsx(
71
- Radar,
72
- {
73
- name: s.label,
74
- dataKey: s.dataKey,
75
- stroke: s.color || seriesColors[i % seriesColors.length],
76
- fill: s.color || seriesColors[i % seriesColors.length],
77
- fillOpacity: s.fillOpacity ?? 0.3
78
- },
79
- s.dataKey
80
- )),
81
- series.length > 1 && /* @__PURE__ */ jsx(
82
- Legend,
83
- {
84
- wrapperStyle: { color: textSecondary, fontSize: 12 }
85
- }
86
- )
87
- ] }) }) })
88
- ] });
43
+ return /* @__PURE__ */ jsxs(
44
+ "div",
45
+ {
46
+ className: classes,
47
+ role: "figure",
48
+ "aria-labelledby": title ? titleId : void 0,
49
+ "aria-describedby": subtitle ? subtitleId : void 0,
50
+ children: [
51
+ (title || subtitle || summaryItems) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
52
+ /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header-text`, children: [
53
+ title && /* @__PURE__ */ jsx("h3", { id: titleId, className: `${baseClass}__title`, children: title }),
54
+ subtitle && /* @__PURE__ */ jsx("p", { id: subtitleId, className: `${baseClass}__subtitle`, children: subtitle })
55
+ ] }),
56
+ summaryItems && summaryItems.length > 0 && /* @__PURE__ */ jsx("div", { className: `${baseClass}__summary`, children: summaryItems.map((item, i) => /* @__PURE__ */ jsxs("div", { className: `${baseClass}__summary-item`, children: [
57
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-label`, children: item.label }),
58
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? item.value.toLocaleString() : item.value })
59
+ ] }, i)) })
60
+ ] }),
61
+ /* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(RadarChart$1, { data, cx: "50%", cy: "50%", outerRadius: "70%", children: [
62
+ /* @__PURE__ */ jsx(PolarGrid, { stroke: gridColor }),
63
+ /* @__PURE__ */ jsx(
64
+ PolarAngleAxis,
65
+ {
66
+ dataKey: categoryKey,
67
+ tick: { fill: textSecondary, fontSize: 12 }
68
+ }
69
+ ),
70
+ /* @__PURE__ */ jsx(
71
+ PolarRadiusAxis,
72
+ {
73
+ tick: { fill: textSecondary, fontSize: 10 },
74
+ axisLine: false,
75
+ tickCount: 5
76
+ }
77
+ ),
78
+ /* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
79
+ series.map((s, i) => /* @__PURE__ */ jsx(
80
+ Radar,
81
+ {
82
+ name: s.label,
83
+ dataKey: s.dataKey,
84
+ stroke: s.color || seriesColors[i % seriesColors.length],
85
+ fill: s.color || seriesColors[i % seriesColors.length],
86
+ fillOpacity: s.fillOpacity ?? 0.3
87
+ },
88
+ s.dataKey
89
+ )),
90
+ series.length > 1 && /* @__PURE__ */ jsx(
91
+ Legend,
92
+ {
93
+ wrapperStyle: { color: textSecondary, fontSize: 12 }
94
+ }
95
+ )
96
+ ] }) }) })
97
+ ]
98
+ }
99
+ );
89
100
  };
90
101
  export {
91
102
  RadarChart
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useCallback } from "react";
2
+ import { useId, useCallback } from "react";
3
3
  import { ResponsiveContainer, RadialBarChart, PolarAngleAxis, RadialBar, Tooltip, Legend } from "recharts";
4
4
  import { getChartSeriesColors } from "./palette.js";
5
5
  import "./Chart.css";
@@ -36,6 +36,8 @@ const RadialChart = ({
36
36
  bare = false,
37
37
  className = ""
38
38
  }) => {
39
+ const titleId = useId();
40
+ const subtitleId = useId();
39
41
  const baseClass = "ds-chart";
40
42
  const classes = [baseClass, bare ? `${baseClass}--bare` : "", className].filter(Boolean).join(" ");
41
43
  const defaultColors = getChartSeriesColors();
@@ -50,64 +52,73 @@ const RadialChart = ({
50
52
  (props) => /* @__PURE__ */ jsx(RadialTooltip, { ...props }),
51
53
  []
52
54
  );
53
- return /* @__PURE__ */ jsxs("div", { className: classes, children: [
54
- (title || subtitle || summaryItems) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
55
- /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header-text`, children: [
56
- title && /* @__PURE__ */ jsx("h3", { className: `${baseClass}__title`, children: title }),
57
- subtitle && /* @__PURE__ */ jsx("p", { className: `${baseClass}__subtitle`, children: subtitle })
58
- ] }),
59
- summaryItems && summaryItems.length > 0 && /* @__PURE__ */ jsx("div", { className: `${baseClass}__summary`, children: summaryItems.map((item, i) => /* @__PURE__ */ jsxs("div", { className: `${baseClass}__summary-item`, children: [
60
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-label`, children: item.label }),
61
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? item.value.toLocaleString() : item.value })
62
- ] }, i)) })
63
- ] }),
64
- /* @__PURE__ */ jsxs("div", { className: `${baseClass}__body`, children: [
65
- /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(
66
- RadialBarChart,
67
- {
68
- cx: "50%",
69
- cy: "50%",
70
- innerRadius,
71
- outerRadius,
72
- data: chartData,
73
- startAngle: 90,
74
- endAngle: -270,
75
- barSize: 16,
76
- children: [
77
- /* @__PURE__ */ jsx(PolarAngleAxis, { type: "number", domain: [0, maxValue], tick: false }),
78
- /* @__PURE__ */ jsx(
79
- RadialBar,
80
- {
81
- background: { fill: bgColor },
82
- dataKey: "value",
83
- cornerRadius: 8
84
- }
85
- ),
86
- /* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
87
- showLegend && /* @__PURE__ */ jsx(
88
- Legend,
89
- {
90
- verticalAlign: "bottom",
91
- iconType: "circle",
92
- iconSize: 8,
93
- ...{ payload: chartData.map((d) => ({
94
- value: d.name,
95
- type: "circle",
96
- color: d.fill
97
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
98
- })) },
99
- formatter: (value) => /* @__PURE__ */ jsx("span", { style: { color: textSecondary, fontSize: 12 }, children: value })
100
- }
101
- )
102
- ]
103
- }
104
- ) }),
105
- centerLabel && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__radial-center`, children: [
106
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__radial-center-value`, children: centerLabel }),
107
- centerSublabel && /* @__PURE__ */ jsx("span", { className: `${baseClass}__radial-center-sub`, children: centerSublabel })
108
- ] })
109
- ] })
110
- ] });
55
+ return /* @__PURE__ */ jsxs(
56
+ "div",
57
+ {
58
+ className: classes,
59
+ role: "figure",
60
+ "aria-labelledby": title ? titleId : void 0,
61
+ "aria-describedby": subtitle ? subtitleId : void 0,
62
+ children: [
63
+ (title || subtitle || summaryItems) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
64
+ /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header-text`, children: [
65
+ title && /* @__PURE__ */ jsx("h3", { id: titleId, className: `${baseClass}__title`, children: title }),
66
+ subtitle && /* @__PURE__ */ jsx("p", { id: subtitleId, className: `${baseClass}__subtitle`, children: subtitle })
67
+ ] }),
68
+ summaryItems && summaryItems.length > 0 && /* @__PURE__ */ jsx("div", { className: `${baseClass}__summary`, children: summaryItems.map((item, i) => /* @__PURE__ */ jsxs("div", { className: `${baseClass}__summary-item`, children: [
69
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-label`, children: item.label }),
70
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? item.value.toLocaleString() : item.value })
71
+ ] }, i)) })
72
+ ] }),
73
+ /* @__PURE__ */ jsxs("div", { className: `${baseClass}__body`, children: [
74
+ /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(
75
+ RadialBarChart,
76
+ {
77
+ cx: "50%",
78
+ cy: "50%",
79
+ innerRadius,
80
+ outerRadius,
81
+ data: chartData,
82
+ startAngle: 90,
83
+ endAngle: -270,
84
+ barSize: 16,
85
+ children: [
86
+ /* @__PURE__ */ jsx(PolarAngleAxis, { type: "number", domain: [0, maxValue], tick: false }),
87
+ /* @__PURE__ */ jsx(
88
+ RadialBar,
89
+ {
90
+ background: { fill: bgColor },
91
+ dataKey: "value",
92
+ cornerRadius: 8
93
+ }
94
+ ),
95
+ /* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
96
+ showLegend && /* @__PURE__ */ jsx(
97
+ Legend,
98
+ {
99
+ verticalAlign: "bottom",
100
+ iconType: "circle",
101
+ iconSize: 8,
102
+ ...{ payload: chartData.map((d) => ({
103
+ value: d.name,
104
+ type: "circle",
105
+ color: d.fill
106
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
107
+ })) },
108
+ formatter: (value) => /* @__PURE__ */ jsx("span", { style: { color: textSecondary, fontSize: 12 }, children: value })
109
+ }
110
+ )
111
+ ]
112
+ }
113
+ ) }),
114
+ centerLabel && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__radial-center`, children: [
115
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__radial-center-value`, children: centerLabel }),
116
+ centerSublabel && /* @__PURE__ */ jsx("span", { className: `${baseClass}__radial-center-sub`, children: centerSublabel })
117
+ ] })
118
+ ] })
119
+ ]
120
+ }
121
+ );
111
122
  };
112
123
  export {
113
124
  RadialChart
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useCallback } from "react";
2
+ import { useId, useCallback } from "react";
3
3
  import { ResponsiveContainer, ScatterChart as ScatterChart$1, CartesianGrid, XAxis, YAxis, ZAxis, Tooltip, Scatter, Legend } from "recharts";
4
4
  import { getChartSeriesColors } from "./palette.js";
5
5
  import "./Chart.css";
@@ -34,6 +34,8 @@ const ScatterChart = ({
34
34
  bare = false,
35
35
  className = ""
36
36
  }) => {
37
+ const titleId = useId();
38
+ const subtitleId = useId();
37
39
  const baseClass = "ds-chart";
38
40
  const classes = [baseClass, bare ? `${baseClass}--bare` : "", className].filter(Boolean).join(" ");
39
41
  const seriesColors = getChartSeriesColors();
@@ -44,55 +46,64 @@ const ScatterChart = ({
44
46
  (props) => /* @__PURE__ */ jsx(ScatterTooltip, { ...props, xLabel, yLabel }),
45
47
  [xLabel, yLabel]
46
48
  );
47
- return /* @__PURE__ */ jsxs("div", { className: classes, children: [
48
- (title || subtitle || summaryItems) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
49
- /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header-text`, children: [
50
- title && /* @__PURE__ */ jsx("h3", { className: `${baseClass}__title`, children: title }),
51
- subtitle && /* @__PURE__ */ jsx("p", { className: `${baseClass}__subtitle`, children: subtitle })
52
- ] }),
53
- summaryItems && summaryItems.length > 0 && /* @__PURE__ */ jsx("div", { className: `${baseClass}__summary`, children: summaryItems.map((item, i) => /* @__PURE__ */ jsxs("div", { className: `${baseClass}__summary-item`, children: [
54
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-label`, children: item.label }),
55
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? item.value.toLocaleString() : item.value })
56
- ] }, i)) })
57
- ] }),
58
- /* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(ScatterChart$1, { margin: { top: 8, right: 4, bottom: 0, left: -12 }, children: [
59
- /* @__PURE__ */ jsx(CartesianGrid, { stroke: gridColor }),
60
- /* @__PURE__ */ jsx(
61
- XAxis,
62
- {
63
- type: "number",
64
- dataKey: xKey,
65
- name: xLabel,
66
- tick: { fill: textSecondary, fontSize: 12 },
67
- tickLine: false,
68
- axisLine: { stroke: gridColor }
69
- }
70
- ),
71
- /* @__PURE__ */ jsx(
72
- YAxis,
73
- {
74
- type: "number",
75
- dataKey: yKey,
76
- name: yLabel,
77
- tick: { fill: textSecondary, fontSize: 12 },
78
- tickLine: false,
79
- axisLine: false
80
- }
81
- ),
82
- /* @__PURE__ */ jsx(ZAxis, { range: [48, 48] }),
83
- /* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
84
- datasets.map((ds, i) => /* @__PURE__ */ jsx(
85
- Scatter,
86
- {
87
- name: ds.name,
88
- data: ds.data,
89
- fill: ds.color || seriesColors[i % seriesColors.length]
90
- },
91
- ds.name
92
- )),
93
- datasets.length > 1 && /* @__PURE__ */ jsx(Legend, { wrapperStyle: { color: textSecondary, fontSize: 12 } })
94
- ] }) }) })
95
- ] });
49
+ return /* @__PURE__ */ jsxs(
50
+ "div",
51
+ {
52
+ className: classes,
53
+ role: "figure",
54
+ "aria-labelledby": title ? titleId : void 0,
55
+ "aria-describedby": subtitle ? subtitleId : void 0,
56
+ children: [
57
+ (title || subtitle || summaryItems) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
58
+ /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header-text`, children: [
59
+ title && /* @__PURE__ */ jsx("h3", { id: titleId, className: `${baseClass}__title`, children: title }),
60
+ subtitle && /* @__PURE__ */ jsx("p", { id: subtitleId, className: `${baseClass}__subtitle`, children: subtitle })
61
+ ] }),
62
+ summaryItems && summaryItems.length > 0 && /* @__PURE__ */ jsx("div", { className: `${baseClass}__summary`, children: summaryItems.map((item, i) => /* @__PURE__ */ jsxs("div", { className: `${baseClass}__summary-item`, children: [
63
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-label`, children: item.label }),
64
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__summary-value`, children: typeof item.value === "number" ? item.value.toLocaleString() : item.value })
65
+ ] }, i)) })
66
+ ] }),
67
+ /* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(ScatterChart$1, { margin: { top: 8, right: 4, bottom: 0, left: -12 }, children: [
68
+ /* @__PURE__ */ jsx(CartesianGrid, { stroke: gridColor }),
69
+ /* @__PURE__ */ jsx(
70
+ XAxis,
71
+ {
72
+ type: "number",
73
+ dataKey: xKey,
74
+ name: xLabel,
75
+ tick: { fill: textSecondary, fontSize: 12 },
76
+ tickLine: false,
77
+ axisLine: { stroke: gridColor }
78
+ }
79
+ ),
80
+ /* @__PURE__ */ jsx(
81
+ YAxis,
82
+ {
83
+ type: "number",
84
+ dataKey: yKey,
85
+ name: yLabel,
86
+ tick: { fill: textSecondary, fontSize: 12 },
87
+ tickLine: false,
88
+ axisLine: false
89
+ }
90
+ ),
91
+ /* @__PURE__ */ jsx(ZAxis, { range: [48, 48] }),
92
+ /* @__PURE__ */ jsx(Tooltip, { content: renderTooltip }),
93
+ datasets.map((ds, i) => /* @__PURE__ */ jsx(
94
+ Scatter,
95
+ {
96
+ name: ds.name,
97
+ data: ds.data,
98
+ fill: ds.color || seriesColors[i % seriesColors.length]
99
+ },
100
+ ds.name
101
+ )),
102
+ datasets.length > 1 && /* @__PURE__ */ jsx(Legend, { wrapperStyle: { color: textSecondary, fontSize: 12 } })
103
+ ] }) }) })
104
+ ]
105
+ }
106
+ );
96
107
  };
97
108
  export {
98
109
  ScatterChart