@sckyzo/cosmos-charts 0.2.0 → 0.3.1
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/CHANGELOG.md +98 -0
- package/README.md +107 -22
- package/THIRD_PARTY_NOTICES.md +81 -0
- package/dist/BarChart.cjs +137 -0
- package/dist/BarChart.cjs.map +1 -0
- package/dist/BarChart.js +135 -0
- package/dist/BarChart.js.map +1 -0
- package/dist/BoxPlotChart.cjs +214 -0
- package/dist/BoxPlotChart.cjs.map +1 -0
- package/dist/BoxPlotChart.js +212 -0
- package/dist/BoxPlotChart.js.map +1 -0
- package/dist/BumpChart.cjs +328 -0
- package/dist/BumpChart.cjs.map +1 -0
- package/dist/BumpChart.js +326 -0
- package/dist/BumpChart.js.map +1 -0
- package/dist/CalendarChart.cjs +218 -0
- package/dist/CalendarChart.cjs.map +1 -0
- package/dist/CalendarChart.js +216 -0
- package/dist/CalendarChart.js.map +1 -0
- package/dist/DonutChart.cjs +122 -0
- package/dist/DonutChart.cjs.map +1 -0
- package/dist/DonutChart.js +120 -0
- package/dist/DonutChart.js.map +1 -0
- package/dist/FunnelChart.cjs +424 -0
- package/dist/FunnelChart.cjs.map +1 -0
- package/dist/FunnelChart.js +422 -0
- package/dist/FunnelChart.js.map +1 -0
- package/dist/GradientRadial.cjs +51 -0
- package/dist/GradientRadial.cjs.map +1 -0
- package/dist/GradientRadial.js +49 -0
- package/dist/GradientRadial.js.map +1 -0
- package/dist/HeatmapChart.cjs +148 -0
- package/dist/HeatmapChart.cjs.map +1 -0
- package/dist/HeatmapChart.js +146 -0
- package/dist/HeatmapChart.js.map +1 -0
- package/dist/LineAreaChart.cjs +98 -0
- package/dist/LineAreaChart.cjs.map +1 -0
- package/dist/LineAreaChart.js +96 -0
- package/dist/LineAreaChart.js.map +1 -0
- package/dist/MixedChart.cjs +195 -0
- package/dist/MixedChart.cjs.map +1 -0
- package/dist/MixedChart.js +193 -0
- package/dist/MixedChart.js.map +1 -0
- package/dist/RadarChart.cjs +109 -0
- package/dist/RadarChart.cjs.map +1 -0
- package/dist/RadarChart.js +107 -0
- package/dist/RadarChart.js.map +1 -0
- package/dist/RadialBarChart.cjs +99 -0
- package/dist/RadialBarChart.cjs.map +1 -0
- package/dist/RadialBarChart.js +97 -0
- package/dist/RadialBarChart.js.map +1 -0
- package/dist/RangeBarChart.cjs +218 -0
- package/dist/RangeBarChart.cjs.map +1 -0
- package/dist/RangeBarChart.js +216 -0
- package/dist/RangeBarChart.js.map +1 -0
- package/dist/RealtimeChart.cjs +173 -0
- package/dist/RealtimeChart.cjs.map +1 -0
- package/dist/RealtimeChart.js +171 -0
- package/dist/RealtimeChart.js.map +1 -0
- package/dist/ScatterChart.cjs +134 -0
- package/dist/ScatterChart.cjs.map +1 -0
- package/dist/ScatterChart.js +131 -0
- package/dist/ScatterChart.js.map +1 -0
- package/dist/SemiCircleGauge.cjs +142 -0
- package/dist/SemiCircleGauge.cjs.map +1 -0
- package/dist/SemiCircleGauge.js +140 -0
- package/dist/SemiCircleGauge.js.map +1 -0
- package/dist/Sparkline.cjs +117 -0
- package/dist/Sparkline.cjs.map +1 -0
- package/dist/Sparkline.js +115 -0
- package/dist/Sparkline.js.map +1 -0
- package/dist/StrokedGauge.cjs +94 -0
- package/dist/StrokedGauge.cjs.map +1 -0
- package/dist/StrokedGauge.js +92 -0
- package/dist/StrokedGauge.js.map +1 -0
- package/dist/TreemapChart.cjs +263 -0
- package/dist/TreemapChart.cjs.map +1 -0
- package/dist/TreemapChart.js +261 -0
- package/dist/TreemapChart.js.map +1 -0
- package/dist/WaterfallChart.cjs +235 -0
- package/dist/WaterfallChart.cjs.map +1 -0
- package/dist/WaterfallChart.js +233 -0
- package/dist/WaterfallChart.js.map +1 -0
- package/dist/WorldMap.cjs +2088 -0
- package/dist/WorldMap.cjs.map +1 -0
- package/dist/WorldMap.js +603 -0
- package/dist/WorldMap.js.map +1 -0
- package/dist/chunk-4AKHZNWP.js +127 -0
- package/dist/chunk-4AKHZNWP.js.map +1 -0
- package/dist/chunk-56WD3OHA.js +62 -0
- package/dist/chunk-56WD3OHA.js.map +1 -0
- package/dist/chunk-5C2RLJYZ.js +11 -0
- package/dist/chunk-5C2RLJYZ.js.map +1 -0
- package/dist/chunk-6FGJZBTC.js +61 -0
- package/dist/chunk-6FGJZBTC.js.map +1 -0
- package/dist/chunk-AAYHG7YK.cjs +30 -0
- package/dist/chunk-AAYHG7YK.cjs.map +1 -0
- package/dist/chunk-AOSO5QHL.js +19 -0
- package/dist/chunk-AOSO5QHL.js.map +1 -0
- package/dist/chunk-BFEDLXVW.js +12 -0
- package/dist/chunk-BFEDLXVW.js.map +1 -0
- package/dist/chunk-CMBNNLIV.cjs +63 -0
- package/dist/chunk-CMBNNLIV.cjs.map +1 -0
- package/dist/chunk-DBZQI4HM.cjs +14 -0
- package/dist/chunk-DBZQI4HM.cjs.map +1 -0
- package/dist/chunk-DI2FBGKM.js +44 -0
- package/dist/chunk-DI2FBGKM.js.map +1 -0
- package/dist/chunk-ESVGCUJN.js +58 -0
- package/dist/chunk-ESVGCUJN.js.map +1 -0
- package/dist/chunk-F2PMFYJ5.cjs +40 -0
- package/dist/chunk-F2PMFYJ5.cjs.map +1 -0
- package/dist/chunk-FUZW3H5X.js +38 -0
- package/dist/chunk-FUZW3H5X.js.map +1 -0
- package/dist/chunk-G4WOPX4D.cjs +51 -0
- package/dist/chunk-G4WOPX4D.cjs.map +1 -0
- package/dist/chunk-GDZLYYL2.js +27 -0
- package/dist/chunk-GDZLYYL2.js.map +1 -0
- package/dist/chunk-GVTMZYOM.cjs +30 -0
- package/dist/chunk-GVTMZYOM.cjs.map +1 -0
- package/dist/chunk-IW6EWB26.cjs +21 -0
- package/dist/chunk-IW6EWB26.cjs.map +1 -0
- package/dist/chunk-K3R7JGOW.cjs +18 -0
- package/dist/chunk-K3R7JGOW.cjs.map +1 -0
- package/dist/chunk-LT3UC65O.cjs +68 -0
- package/dist/chunk-LT3UC65O.cjs.map +1 -0
- package/dist/chunk-OCD6JIIX.js +23 -0
- package/dist/chunk-OCD6JIIX.js.map +1 -0
- package/dist/chunk-RCDTBZC2.cjs +131 -0
- package/dist/chunk-RCDTBZC2.cjs.map +1 -0
- package/dist/chunk-SR2ESX3R.cjs +66 -0
- package/dist/chunk-SR2ESX3R.cjs.map +1 -0
- package/dist/chunk-T3K6Q34U.cjs +82 -0
- package/dist/chunk-T3K6Q34U.cjs.map +1 -0
- package/dist/chunk-TYQWZR3S.cjs +13 -0
- package/dist/chunk-TYQWZR3S.cjs.map +1 -0
- package/dist/chunk-UATB2IRY.js +51 -0
- package/dist/chunk-UATB2IRY.js.map +1 -0
- package/dist/chunk-UJIV5PVI.js +13 -0
- package/dist/chunk-UJIV5PVI.js.map +1 -0
- package/dist/chunk-UL3SNXQR.js +280 -0
- package/dist/chunk-UL3SNXQR.js.map +1 -0
- package/dist/chunk-URNXLVSK.js +44 -0
- package/dist/chunk-URNXLVSK.js.map +1 -0
- package/dist/chunk-VIOSQN4Z.js +79 -0
- package/dist/chunk-VIOSQN4Z.js.map +1 -0
- package/dist/chunk-X3YZP5WF.cjs +46 -0
- package/dist/chunk-X3YZP5WF.cjs.map +1 -0
- package/dist/chunk-XMFBVMW7.cjs +30 -0
- package/dist/chunk-XMFBVMW7.cjs.map +1 -0
- package/dist/chunk-XUGQ6VXO.cjs +60 -0
- package/dist/chunk-XUGQ6VXO.cjs.map +1 -0
- package/dist/chunk-YMRNTIOK.js +27 -0
- package/dist/chunk-YMRNTIOK.js.map +1 -0
- package/dist/chunk-ZWHCUYIN.cjs +282 -0
- package/dist/chunk-ZWHCUYIN.cjs.map +1 -0
- package/dist/index.cjs +154 -1166
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +470 -80
- package/dist/index.d.ts +470 -80
- package/dist/index.js +23 -1144
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs +88 -0
- package/dist/theme.cjs.map +1 -0
- package/dist/theme.js +84 -0
- package/dist/theme.js.map +1 -0
- package/package.json +23 -12
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunkG4WOPX4D_cjs = require('./chunk-G4WOPX4D.cjs');
|
|
5
|
+
var chunkLT3UC65O_cjs = require('./chunk-LT3UC65O.cjs');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
var useHiddenSeries = () => {
|
|
10
|
+
const [hidden, setHidden] = react.useState(/* @__PURE__ */ new Set());
|
|
11
|
+
const toggle = react.useCallback((key) => {
|
|
12
|
+
setHidden((current) => {
|
|
13
|
+
const next = new Set(current);
|
|
14
|
+
if (!next.delete(key)) next.add(key);
|
|
15
|
+
return next;
|
|
16
|
+
});
|
|
17
|
+
}, []);
|
|
18
|
+
return { hidden, toggle };
|
|
19
|
+
};
|
|
20
|
+
var ChartLegend = ({ payload, hidden, onToggle, column, detail }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
21
|
+
"ul",
|
|
22
|
+
{
|
|
23
|
+
style: {
|
|
24
|
+
display: "flex",
|
|
25
|
+
flexDirection: column ? "column" : "row",
|
|
26
|
+
flexWrap: "wrap",
|
|
27
|
+
gap: column ? "0.375rem" : "0.25rem 1rem",
|
|
28
|
+
margin: 0,
|
|
29
|
+
padding: 0,
|
|
30
|
+
listStyle: "none",
|
|
31
|
+
fontSize: chunkG4WOPX4D_cjs.TEXT_SIZE,
|
|
32
|
+
color: chunkLT3UC65O_cjs.MUTED
|
|
33
|
+
},
|
|
34
|
+
children: payload?.map((entry, index) => {
|
|
35
|
+
const key = String(entry.dataKey);
|
|
36
|
+
const figures = detail?.(index);
|
|
37
|
+
const off = hidden.has(key);
|
|
38
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
39
|
+
"button",
|
|
40
|
+
{
|
|
41
|
+
type: "button",
|
|
42
|
+
"aria-pressed": !off,
|
|
43
|
+
onClick: () => onToggle(key),
|
|
44
|
+
className: "focus-visible:focus-indicator",
|
|
45
|
+
style: {
|
|
46
|
+
display: "inline-flex",
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
gap: "0.375rem",
|
|
49
|
+
padding: "0.125rem 0.25rem",
|
|
50
|
+
font: "inherit",
|
|
51
|
+
color: "inherit",
|
|
52
|
+
background: "none",
|
|
53
|
+
border: 0,
|
|
54
|
+
borderRadius: "0.25rem",
|
|
55
|
+
cursor: "pointer",
|
|
56
|
+
textDecoration: off ? "line-through" : void 0,
|
|
57
|
+
// The figures of a column reach its right edge, which aligns them.
|
|
58
|
+
...figures && column ? { display: "flex", width: "100%", gap: "0.75rem" } : {}
|
|
59
|
+
},
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
62
|
+
"span",
|
|
63
|
+
{
|
|
64
|
+
"aria-hidden": true,
|
|
65
|
+
style: {
|
|
66
|
+
width: "0.625rem",
|
|
67
|
+
height: "0.625rem",
|
|
68
|
+
borderRadius: "50%",
|
|
69
|
+
background: entry.color,
|
|
70
|
+
// Text keeps its color: dimming it would fail the contrast check.
|
|
71
|
+
opacity: off ? 0.35 : 1
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
figures ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: column ? { flex: 1, textAlign: "start" } : void 0, children: entry.value }),
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
78
|
+
"span",
|
|
79
|
+
{
|
|
80
|
+
style: {
|
|
81
|
+
color: chunkLT3UC65O_cjs.TEXT,
|
|
82
|
+
fontWeight: 600,
|
|
83
|
+
fontVariantNumeric: "tabular-nums",
|
|
84
|
+
textAlign: "end"
|
|
85
|
+
},
|
|
86
|
+
children: figures.value
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
90
|
+
"span",
|
|
91
|
+
{
|
|
92
|
+
style: {
|
|
93
|
+
minWidth: column ? "3.5ch" : void 0,
|
|
94
|
+
fontVariantNumeric: "tabular-nums",
|
|
95
|
+
textAlign: "end"
|
|
96
|
+
},
|
|
97
|
+
children: figures.share
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
] }) : entry.value
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
) }, key);
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
var GAP = "1rem";
|
|
108
|
+
var legendProps = (position, { hidden, toggle }) => ({
|
|
109
|
+
position,
|
|
110
|
+
itemSorter: null,
|
|
111
|
+
wrapperStyle: {
|
|
112
|
+
top: { width: "100%", paddingBottom: GAP },
|
|
113
|
+
bottom: { width: "100%", paddingTop: GAP },
|
|
114
|
+
left: { paddingRight: GAP },
|
|
115
|
+
right: { paddingLeft: GAP }
|
|
116
|
+
}[position],
|
|
117
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(
|
|
118
|
+
ChartLegend,
|
|
119
|
+
{
|
|
120
|
+
hidden,
|
|
121
|
+
onToggle: toggle,
|
|
122
|
+
column: position === "left" || position === "right"
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
exports.ChartLegend = ChartLegend;
|
|
128
|
+
exports.legendProps = legendProps;
|
|
129
|
+
exports.useHiddenSeries = useHiddenSeries;
|
|
130
|
+
//# sourceMappingURL=chunk-RCDTBZC2.cjs.map
|
|
131
|
+
//# sourceMappingURL=chunk-RCDTBZC2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/ChartLegend.tsx"],"names":["useState","useCallback","jsx","TEXT_SIZE","MUTED","jsxs","Fragment","TEXT"],"mappings":";;;;;;;;AAUO,IAAM,kBAAkB,MAAM;AACnC,EA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AAQ,QAAA,KAAa,MAAA,IAAU,QAAA,KAAa;AAAA;AAAA;AAGlD,CAAA","file":"chunk-RCDTBZC2.cjs","sourcesContent":["import { useCallback, useState, type ReactNode } from 'react';\nimport type { LegendPayload, LegendProps } from 'recharts';\nimport type { ChartLegendPosition } from '../types';\nimport { MUTED, TEXT } from './colors';\nimport { TEXT_SIZE } from './axes';\n\n/**\n * The series a click on the legend hid, and the toggle. A hidden series is\n * passed to its graphical item as `hide`, so the axes fit what is left.\n */\nexport const useHiddenSeries = () => {\n const [hidden, setHidden] = useState<ReadonlySet<string>>(new Set());\n const toggle = useCallback((key: string) => {\n setHidden((current) => {\n const next = new Set(current);\n if (!next.delete(key)) next.add(key);\n return next;\n });\n }, []);\n return { hidden, toggle };\n};\n\ntype ChartLegendProps = {\n /** Given by Recharts: one entry per series, in the order the series are drawn. */\n payload?: readonly LegendPayload[];\n /** The keys of the hidden series. */\n hidden: ReadonlySet<string>;\n onToggle: (key: string) => void;\n /** Items in a column (`left`, `right`) or a row (`top`, `bottom`). */\n column?: boolean;\n /**\n * A figure written after the name of the entry at `index`: a value and its\n * share. In a column the figures sit at the right edge, aligned on their\n * last digit; in a row they follow the name.\n */\n detail?: (index: number) => { value: string; share: string };\n};\n\n/**\n * The legend of every chart: a round chip and the series name in the muted\n * text color, one button per series. A click (or Enter, Space) hides the series\n * and shows it again; the button says which in `aria-pressed`. Pass it as\n * `<Legend content={…} itemSorter={null} />`: Recharts sorts the items by name\n * unless told not to, and the series keep their order.\n */\nexport const ChartLegend = ({ payload, hidden, onToggle, column, detail }: ChartLegendProps) => (\n <ul\n style={{\n display: 'flex',\n flexDirection: column ? 'column' : 'row',\n flexWrap: 'wrap',\n gap: column ? '0.375rem' : '0.25rem 1rem',\n margin: 0,\n padding: 0,\n listStyle: 'none',\n fontSize: TEXT_SIZE,\n color: MUTED,\n }}\n >\n {payload?.map((entry, index) => {\n const key = String(entry.dataKey);\n const figures = detail?.(index);\n const off = hidden.has(key);\n return (\n <li key={key}>\n <button\n type=\"button\"\n aria-pressed={!off}\n onClick={() => onToggle(key)}\n className=\"focus-visible:focus-indicator\"\n style={{\n display: 'inline-flex',\n alignItems: 'center',\n gap: '0.375rem',\n padding: '0.125rem 0.25rem',\n font: 'inherit',\n color: 'inherit',\n background: 'none',\n border: 0,\n borderRadius: '0.25rem',\n cursor: 'pointer',\n textDecoration: off ? 'line-through' : undefined,\n // The figures of a column reach its right edge, which aligns them.\n ...(figures && column ? { display: 'flex', width: '100%', gap: '0.75rem' } : {}),\n }}\n >\n <span\n aria-hidden\n style={{\n width: '0.625rem',\n height: '0.625rem',\n borderRadius: '50%',\n background: entry.color,\n // Text keeps its color: dimming it would fail the contrast check.\n opacity: off ? 0.35 : 1,\n }}\n />\n {figures ? (\n <>\n <span style={column ? { flex: 1, textAlign: 'start' } : undefined}>\n {entry.value as ReactNode}\n </span>\n <span\n style={{\n color: TEXT,\n fontWeight: 600,\n fontVariantNumeric: 'tabular-nums',\n textAlign: 'end',\n }}\n >\n {figures.value}\n </span>\n <span\n style={{\n minWidth: column ? '3.5ch' : undefined,\n fontVariantNumeric: 'tabular-nums',\n textAlign: 'end',\n }}\n >\n {figures.share}\n </span>\n </>\n ) : (\n (entry.value as ReactNode)\n )}\n </button>\n </li>\n );\n })}\n </ul>\n);\n\nconst GAP = '1rem';\n\n/**\n * The props of the `<Legend>` of a chart: on `position`, the chips and names\n * of `ChartLegend`, in series order, a `GAP` away from the plot.\n */\nexport const legendProps = (\n position: ChartLegendPosition,\n { hidden, toggle }: ReturnType<typeof useHiddenSeries>\n): LegendProps => ({\n position,\n itemSorter: null,\n wrapperStyle: {\n top: { width: '100%', paddingBottom: GAP },\n bottom: { width: '100%', paddingTop: GAP },\n left: { paddingRight: GAP },\n right: { paddingLeft: GAP },\n }[position],\n content: (\n <ChartLegend\n hidden={hidden}\n onToggle={toggle}\n column={position === 'left' || position === 'right'}\n />\n ),\n});\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunkLT3UC65O_cjs = require('./chunk-LT3UC65O.cjs');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
var frameProps = ({
|
|
9
|
+
height,
|
|
10
|
+
width = "100%",
|
|
11
|
+
ariaLabel,
|
|
12
|
+
keyboard = true
|
|
13
|
+
}) => ({
|
|
14
|
+
responsive: true,
|
|
15
|
+
accessibilityLayer: keyboard,
|
|
16
|
+
...keyboard ? {} : { role: "img" },
|
|
17
|
+
"aria-label": ariaLabel,
|
|
18
|
+
// `maxWidth`: a chart wider than its parent would widen the page. `direction`: a chart keeps
|
|
19
|
+
// its left-to-right axes under `dir="rtl"`; left alone, the SVG's `text-anchor` would read
|
|
20
|
+
// `start` and `end` from the page and put the labels on the wrong side of their marks.
|
|
21
|
+
style: { width, height, maxWidth: "100%", direction: "ltr" }
|
|
22
|
+
});
|
|
23
|
+
var useFontsLoaded = () => {
|
|
24
|
+
const [loaded, setLoaded] = react.useState(0);
|
|
25
|
+
react.useEffect(() => {
|
|
26
|
+
const fonts = typeof document === "undefined" ? void 0 : document.fonts;
|
|
27
|
+
if (!fonts?.addEventListener) return;
|
|
28
|
+
let active = true;
|
|
29
|
+
const done = () => {
|
|
30
|
+
if (active) setLoaded(1);
|
|
31
|
+
};
|
|
32
|
+
fonts.addEventListener("loadingdone", done);
|
|
33
|
+
if (fonts.status === "loading") void fonts.ready.then(done);
|
|
34
|
+
return () => {
|
|
35
|
+
active = false;
|
|
36
|
+
fonts.removeEventListener("loadingdone", done);
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
39
|
+
return loaded;
|
|
40
|
+
};
|
|
41
|
+
var ChartEmpty = ({ message, ariaLabel, height, width = "100%" }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
role: "group",
|
|
45
|
+
"aria-label": ariaLabel,
|
|
46
|
+
"data-chart-empty": "",
|
|
47
|
+
style: {
|
|
48
|
+
display: "flex",
|
|
49
|
+
alignItems: "center",
|
|
50
|
+
justifyContent: "center",
|
|
51
|
+
width,
|
|
52
|
+
height,
|
|
53
|
+
maxWidth: "100%",
|
|
54
|
+
color: chunkLT3UC65O_cjs.MUTED,
|
|
55
|
+
fontSize: "var(--text-sm, 0.875rem)",
|
|
56
|
+
textAlign: "center"
|
|
57
|
+
},
|
|
58
|
+
children: message
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
exports.ChartEmpty = ChartEmpty;
|
|
63
|
+
exports.frameProps = frameProps;
|
|
64
|
+
exports.useFontsLoaded = useFontsLoaded;
|
|
65
|
+
//# sourceMappingURL=chunk-SR2ESX3R.cjs.map
|
|
66
|
+
//# sourceMappingURL=chunk-SR2ESX3R.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/frame.tsx"],"names":["useState","useEffect","jsx","MUTED"],"mappings":";;;;;;;AAoBO,IAAM,aAAa,CAAC;AAAA,EACzB,MAAA;AAAA,EACA,KAAA,GAAQ,MAAA;AAAA,EACR,SAAA;AAAA,EACA,QAAA,GAAW;AACb,CAAA,MAAqB;AAAA,EACnB,UAAA,EAAY,IAAA;AAAA,EACZ,kBAAA,EAAoB,QAAA;AAAA,EACpB,GAAI,QAAA,GAAW,EAAC,GAAI,EAAE,MAAM,KAAA,EAAM;AAAA,EAClC,YAAA,EAAc,SAAA;AAAA;AAAA;AAAA;AAAA,EAId,OAAO,EAAE,KAAA,EAAO,QAAQ,QAAA,EAAU,MAAA,EAAQ,WAAW,KAAA;AACvD,CAAA;AAWO,IAAM,iBAAiB,MAAa;AACzC,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAIA,eAAgB,CAAC,CAAA;AAC7C,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,KAAA,GAAQ,OAAO,QAAA,KAAa,WAAA,GAAc,SAAY,QAAA,CAAS,KAAA;AACrE,IAAA,IAAI,CAAC,OAAO,gBAAA,EAAkB;AAC9B,IAAA,IAAI,MAAA,GAAS,IAAA;AACb,IAAA,MAAM,OAAO,MAAM;AACjB,MAAA,IAAI,MAAA,YAAkB,CAAC,CAAA;AAAA,IACzB,CAAA;AACA,IAAA,KAAA,CAAM,gBAAA,CAAiB,eAAe,IAAI,CAAA;AAG1C,IAAA,IAAI,MAAM,MAAA,KAAW,SAAA,OAAgB,KAAA,CAAM,KAAA,CAAM,KAAK,IAAI,CAAA;AAC1D,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,GAAS,KAAA;AACT,MAAA,KAAA,CAAM,mBAAA,CAAoB,eAAe,IAAI,CAAA;AAAA,IAC/C,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,MAAA;AACT;AASO,IAAM,UAAA,GAAa,CAAC,EAAE,OAAA,EAAS,WAAW,MAAA,EAAQ,KAAA,GAAQ,QAAO,qBACtEC,cAAA;AAAA,EAAC,KAAA;AAAA,EAAA;AAAA,IACC,IAAA,EAAK,OAAA;AAAA,IACL,YAAA,EAAY,SAAA;AAAA,IACZ,kBAAA,EAAiB,EAAA;AAAA,IACjB,KAAA,EAAO;AAAA,MACL,OAAA,EAAS,MAAA;AAAA,MACT,UAAA,EAAY,QAAA;AAAA,MACZ,cAAA,EAAgB,QAAA;AAAA,MAChB,KAAA;AAAA,MACA,MAAA;AAAA,MACA,QAAA,EAAU,MAAA;AAAA,MACV,KAAA,EAAOC,uBAAA;AAAA,MACP,QAAA,EAAU,0BAAA;AAAA,MACV,SAAA,EAAW;AAAA,KACb;AAAA,IAEC,QAAA,EAAA;AAAA;AACH","file":"chunk-SR2ESX3R.cjs","sourcesContent":["import { useEffect, useState, type CSSProperties } from 'react';\nimport { MUTED } from './colors';\nimport type { ChartSize } from '../types';\n\ntype FrameOptions = ChartSize & {\n ariaLabel: string;\n /**\n * Tab reaches the chart and the arrow keys walk its points (default). Off,\n * the chart is an image out of the tab order: right for a single value.\n */\n keyboard?: boolean;\n};\n\n/**\n * What every Recharts chart takes on its root, spread onto it: it fills the\n * width it is given (`width` default `100%`) at `height`, and is named by\n * `ariaLabel`. With `accessibilityLayer`, Recharts makes the chart an\n * `application` in the tab order, and the arrow keys move the tooltip from\n * point to point.\n */\nexport const frameProps = ({\n height,\n width = '100%',\n ariaLabel,\n keyboard = true,\n}: FrameOptions) => ({\n responsive: true,\n accessibilityLayer: keyboard,\n ...(keyboard ? {} : { role: 'img' }),\n 'aria-label': ariaLabel,\n // `maxWidth`: a chart wider than its parent would widen the page. `direction`: a chart keeps\n // its left-to-right axes under `dir=\"rtl\"`; left alone, the SVG's `text-anchor` would read\n // `start` and `end` from the page and put the labels on the wrong side of their marks.\n style: { width, height, maxWidth: '100%', direction: 'ltr' } satisfies CSSProperties,\n});\n\n/**\n * `0` until a web font finishes loading after the chart mounted, then `1`\n * (one more render of the chart, no more). `YAxis width=\"auto\"` measures its\n * labels once, in the fallback font if the web font is not there yet, and a\n * label set in the real font can overrun the axis: `useAxis` (axes.ts) hands\n * the axes a new object when this turns `1`, and they measure again. A chart\n * that mounts with the font ready never changes, and nothing runs where\n * `document.fonts` is missing (SSR, old browsers).\n */\nexport const useFontsLoaded = (): 0 | 1 => {\n const [loaded, setLoaded] = useState<0 | 1>(0);\n useEffect(() => {\n const fonts = typeof document === 'undefined' ? undefined : document.fonts;\n if (!fonts?.addEventListener) return;\n let active = true;\n const done = () => {\n if (active) setLoaded(1);\n };\n fonts.addEventListener('loadingdone', done);\n // A font already loading when the chart mounts: its event may be on its way\n // or already gone, `ready` settles once it has loaded.\n if (fonts.status === 'loading') void fonts.ready.then(done);\n return () => {\n active = false;\n fonts.removeEventListener('loadingdone', done);\n };\n }, []);\n return loaded;\n};\n\ntype EmptyProps = ChartSize & {\n /** Plain text. An empty string draws nothing. */\n message: string;\n ariaLabel: string;\n};\n\n/** What a chart with no data draws in place of its plot: the message, centered, and nothing around it. */\nexport const ChartEmpty = ({ message, ariaLabel, height, width = '100%' }: EmptyProps) => (\n <div\n role=\"group\"\n aria-label={ariaLabel}\n data-chart-empty=\"\"\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width,\n height,\n maxWidth: '100%',\n color: MUTED,\n fontSize: 'var(--text-sm, 0.875rem)',\n textAlign: 'center',\n }}\n >\n {message}\n </div>\n);\n"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunkLT3UC65O_cjs = require('./chunk-LT3UC65O.cjs');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
var card = {
|
|
8
|
+
minWidth: "9rem",
|
|
9
|
+
padding: "0.625rem 0.75rem",
|
|
10
|
+
fontSize: "var(--text-xs, 0.75rem)",
|
|
11
|
+
color: chunkLT3UC65O_cjs.TEXT,
|
|
12
|
+
background: chunkLT3UC65O_cjs.PANEL,
|
|
13
|
+
border: `1px solid ${chunkLT3UC65O_cjs.BORDER}`,
|
|
14
|
+
borderRadius: "var(--radius-xl, 0.75rem)",
|
|
15
|
+
boxShadow: "var(--shadow-theme-md, 0 4px 8px -2px rgb(16 24 40 / 10%))"
|
|
16
|
+
};
|
|
17
|
+
var TooltipCard = ({ title, rows }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "status", "aria-live": "polite", style: card, children: [
|
|
18
|
+
title !== void 0 && title !== "" && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: "0 0 0.375rem", fontWeight: 600 }, children: title }),
|
|
19
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
20
|
+
"ul",
|
|
21
|
+
{
|
|
22
|
+
style: {
|
|
23
|
+
display: "flex",
|
|
24
|
+
flexDirection: "column",
|
|
25
|
+
gap: "0.25rem",
|
|
26
|
+
margin: 0,
|
|
27
|
+
padding: 0,
|
|
28
|
+
listStyle: "none"
|
|
29
|
+
},
|
|
30
|
+
children: rows.map((row, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
31
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
32
|
+
"span",
|
|
33
|
+
{
|
|
34
|
+
"aria-hidden": true,
|
|
35
|
+
style: {
|
|
36
|
+
flexShrink: 0,
|
|
37
|
+
width: "0.625rem",
|
|
38
|
+
height: "0.625rem",
|
|
39
|
+
borderRadius: "50%",
|
|
40
|
+
background: row.color
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: chunkLT3UC65O_cjs.MUTED }, children: row.name }),
|
|
45
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
46
|
+
"span",
|
|
47
|
+
{
|
|
48
|
+
style: {
|
|
49
|
+
marginLeft: "auto",
|
|
50
|
+
paddingLeft: "1rem",
|
|
51
|
+
fontWeight: 600,
|
|
52
|
+
fontVariantNumeric: "tabular-nums"
|
|
53
|
+
},
|
|
54
|
+
children: row.value
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
] }, i))
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
] });
|
|
61
|
+
var ChartTooltip = ({
|
|
62
|
+
active,
|
|
63
|
+
payload,
|
|
64
|
+
label,
|
|
65
|
+
format = String,
|
|
66
|
+
hideTitle,
|
|
67
|
+
colorOf,
|
|
68
|
+
activeIndex
|
|
69
|
+
}) => {
|
|
70
|
+
if (!active || !payload?.length) return null;
|
|
71
|
+
const rows = payload.map((item) => ({
|
|
72
|
+
name: String(item.name),
|
|
73
|
+
value: format(Number(item.value)),
|
|
74
|
+
color: colorOf?.(Number(item.value), Number(activeIndex)) ?? String(item.color ?? item.payload?.fill ?? item.fill)
|
|
75
|
+
}));
|
|
76
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TooltipCard, { title: hideTitle ? void 0 : label, rows });
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
exports.ChartTooltip = ChartTooltip;
|
|
80
|
+
exports.TooltipCard = TooltipCard;
|
|
81
|
+
//# sourceMappingURL=chunk-T3K6Q34U.cjs.map
|
|
82
|
+
//# sourceMappingURL=chunk-T3K6Q34U.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/ChartTooltip.tsx"],"names":["TEXT","PANEL","BORDER","jsxs","jsx","MUTED"],"mappings":";;;;;;AAIA,IAAM,IAAA,GAAsB;AAAA,EAC1B,QAAA,EAAU,MAAA;AAAA,EACV,OAAA,EAAS,kBAAA;AAAA,EACT,QAAA,EAAU,yBAAA;AAAA,EACV,KAAA,EAAOA,sBAAA;AAAA,EACP,UAAA,EAAYC,uBAAA;AAAA,EACZ,MAAA,EAAQ,aAAaC,wBAAM,CAAA,CAAA;AAAA,EAC3B,YAAA,EAAc,2BAAA;AAAA,EACd,SAAA,EAAW;AACb,CAAA;AAWO,IAAM,WAAA,GAAc,CAAC,EAAE,KAAA,EAAO,IAAA,EAAK,qBACxCC,eAAA,CAAC,KAAA,EAAA,EAAI,IAAA,EAAK,QAAA,EAAS,WAAA,EAAU,QAAA,EAAS,OAAO,IAAA,EAC1C,QAAA,EAAA;AAAA,EAAA,KAAA,KAAU,MAAA,IAAa,KAAA,KAAU,EAAA,oBAChCC,cAAA,CAAC,GAAA,EAAA,EAAE,KAAA,EAAO,EAAE,MAAA,EAAQ,cAAA,EAAgB,UAAA,EAAY,GAAA,EAAI,EAAI,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,kBAEhEA,cAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,MAAA;AAAA,QACT,aAAA,EAAe,QAAA;AAAA,QACf,GAAA,EAAK,SAAA;AAAA,QACL,MAAA,EAAQ,CAAA;AAAA,QACR,OAAA,EA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AA,MAAU;AAAA,IAClC,IAAA,EAAM,MAAA,CAAO,IAAA,CAAK,IAAI,CAAA;AAAA,IACtB,KAAA,EAAO,MAAA,CAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAC,CAAA;AAAA,IAChC,OACE,OAAA,GAAU,MAAA,CAAO,IAAA,CAAK,KAAK,GAAG,MAAA,CAAO,WAAW,CAAC,CAAA,IACjD,OAAO,IAAA,CAAK,KAAA,IAAS,KAAK,OAAA,EAAS,IAAA,IAAQ,KAAK,IAAI;AAAA,GACxD,CAAE,CAAA;AACF,EAAA,sCAAQ,WAAA,EAAA,EAAY,KAAA,EAAO,SAAA,GAAY,MAAA,GAAY,OAAO,IAAA,EAAY,CAAA;AACxE","file":"chunk-T3K6Q34U.cjs","sourcesContent":["import type { CSSProperties, ReactNode } from 'react';\nimport type { TooltipContentProps } from 'recharts';\nimport { BORDER, MUTED, PANEL, TEXT } from './colors';\n\nconst card: CSSProperties = {\n minWidth: '9rem',\n padding: '0.625rem 0.75rem',\n fontSize: 'var(--text-xs, 0.75rem)',\n color: TEXT,\n background: PANEL,\n border: `1px solid ${BORDER}`,\n borderRadius: 'var(--radius-xl, 0.75rem)',\n boxShadow: 'var(--shadow-theme-md, 0 4px 8px -2px rgb(16 24 40 / 10%))',\n};\n\n/** A tooltip row: a chip, a name, a value. */\nexport type TooltipRow = { name: string; value: ReactNode; color: string };\n\n/**\n * The tooltip card of every chart. A polite live region, as Recharts\n * recommends for a custom tooltip, so a screen reader announces the point the\n * keyboard or the pointer is on. Every part is React text: markup in a name or\n * a value shows as written.\n */\nexport const TooltipCard = ({ title, rows }: { title?: ReactNode; rows: TooltipRow[] }) => (\n <div role=\"status\" aria-live=\"polite\" style={card}>\n {title !== undefined && title !== '' && (\n <p style={{ margin: '0 0 0.375rem', fontWeight: 600 }}>{title}</p>\n )}\n <ul\n style={{\n display: 'flex',\n flexDirection: 'column',\n gap: '0.25rem',\n margin: 0,\n padding: 0,\n listStyle: 'none',\n }}\n >\n {rows.map((row, i) => (\n <li key={i} style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>\n <span\n aria-hidden\n style={{\n flexShrink: 0,\n width: '0.625rem',\n height: '0.625rem',\n borderRadius: '50%',\n background: row.color,\n }}\n />\n <span style={{ color: MUTED }}>{row.name}</span>\n <span\n style={{\n marginLeft: 'auto',\n paddingLeft: '1rem',\n fontWeight: 600,\n fontVariantNumeric: 'tabular-nums',\n }}\n >\n {row.value}\n </span>\n </li>\n ))}\n </ul>\n </div>\n);\n\ntype ChartTooltipProps = Partial<TooltipContentProps> & {\n /** Formats each value (default `String`). */\n format?: (value: number) => string;\n /** Leave out the title (the category), for a chart that has no axis to read it from. */\n hideTitle?: boolean;\n /** The color of a row's chip from its value and the index of the point, when a bar has a color of its own. `undefined` keeps the series color. */\n colorOf?: (value: number, index: number) => string | undefined;\n};\n\n/** `<Tooltip content={<ChartTooltip />} />`: the card for the series at the point under the cursor. */\nexport const ChartTooltip = ({\n active,\n payload,\n label,\n format = String,\n hideTitle,\n colorOf,\n activeIndex,\n}: ChartTooltipProps) => {\n if (!active || !payload?.length) return null;\n const rows = payload.map((item) => ({\n name: String(item.name),\n value: format(Number(item.value)),\n color:\n colorOf?.(Number(item.value), Number(activeIndex)) ??\n String(item.color ?? item.payload?.fill ?? item.fill),\n }));\n return <TooltipCard title={hideTitle ? undefined : label} rows={rows} />;\n};\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// src/core/animation.ts
|
|
5
|
+
var ANIMATION = {
|
|
6
|
+
isAnimationActive: "auto",
|
|
7
|
+
animationDuration: 500,
|
|
8
|
+
animationEasing: "ease-out"
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.ANIMATION = ANIMATION;
|
|
12
|
+
//# sourceMappingURL=chunk-TYQWZR3S.cjs.map
|
|
13
|
+
//# sourceMappingURL=chunk-TYQWZR3S.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/animation.ts"],"names":[],"mappings":";;;;AAIO,IAAM,SAAA,GAAY;AAAA,EACvB,iBAAA,EAAmB,MAAA;AAAA,EACnB,iBAAA,EAAmB,GAAA;AAAA,EACnB,eAAA,EAAiB;AACnB","file":"chunk-TYQWZR3S.cjs","sourcesContent":["/**\n * The animation of every series: short, ease-out. `'auto'` is off for\n * `prefers-reduced-motion` and in SSR.\n */\nexport const ANIMATION = {\n isAnimationActive: 'auto' as const,\n animationDuration: 500,\n animationEasing: 'ease-out' as const,\n};\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/core/colors.ts
|
|
3
|
+
var token = (name, fallback) => `var(${name}, ${fallback})`;
|
|
4
|
+
var SERIES_FALLBACKS = [
|
|
5
|
+
"#465fff",
|
|
6
|
+
"#06b6d4",
|
|
7
|
+
"#8b5cf6",
|
|
8
|
+
"#ec4899",
|
|
9
|
+
"#64748b",
|
|
10
|
+
"#f97316",
|
|
11
|
+
"#14b8a6",
|
|
12
|
+
"#84cc16"
|
|
13
|
+
];
|
|
14
|
+
var SERIES_TOKENS = [
|
|
15
|
+
"--color-brand-500",
|
|
16
|
+
...SERIES_FALLBACKS.slice(1).map((_, i) => `--color-chart-${i + 2}`)
|
|
17
|
+
];
|
|
18
|
+
var SERIES = SERIES_TOKENS.map((name, i) => token(name, SERIES_FALLBACKS[i]));
|
|
19
|
+
var seriesColor = (index, colors) => colors?.length ? colors[index % colors.length] : SERIES[index % SERIES.length];
|
|
20
|
+
var SUCCESS = token("--color-success-500", "#12b76a");
|
|
21
|
+
var ERROR = token("--color-error-500", "#f04438");
|
|
22
|
+
var STATUS_WARN = token("--color-status-warn", "#f59e0b");
|
|
23
|
+
var STATUS_CRIT = token("--color-status-crit", "#ef4444");
|
|
24
|
+
var PANEL = token("--color-bg-panel", "#fff");
|
|
25
|
+
var TEXT = token("--color-text-primary", "#101828");
|
|
26
|
+
var MUTED = token("--color-text-muted", "#677185");
|
|
27
|
+
var BORDER = token("--color-border", "#d0d5dd");
|
|
28
|
+
var GRID = `color-mix(in srgb, ${BORDER} 55%, transparent)`;
|
|
29
|
+
var TRACK = `color-mix(in srgb, ${BORDER} 70%, transparent)`;
|
|
30
|
+
var INTENT_COLORS = {
|
|
31
|
+
neutral: MUTED,
|
|
32
|
+
warning: STATUS_WARN,
|
|
33
|
+
danger: STATUS_CRIT,
|
|
34
|
+
success: SUCCESS
|
|
35
|
+
};
|
|
36
|
+
var SEQUENTIAL = [42, 56, 70, 84, 100].map(
|
|
37
|
+
(share) => `color-mix(in oklab, ${SERIES[0]} ${share}%, ${PANEL})`
|
|
38
|
+
);
|
|
39
|
+
var calendarStep = (index, share) => `color-mix(in oklab, ${SERIES[0]} calc(var(--calendar-share-${index}, ${share}) * 1%), ${PANEL})`;
|
|
40
|
+
var CALENDAR_STEPS = [
|
|
41
|
+
TRACK,
|
|
42
|
+
calendarStep(1, 48),
|
|
43
|
+
calendarStep(2, 65),
|
|
44
|
+
calendarStep(3, 82),
|
|
45
|
+
`var(--calendar-top, ${SERIES[0]})`
|
|
46
|
+
];
|
|
47
|
+
var CALENDAR_DARK_CLASS = "dark:[--calendar-share-1:50] dark:[--calendar-share-2:70] dark:[--calendar-share-3:100] dark:[--calendar-top:var(--color-brand-400)]";
|
|
48
|
+
|
|
49
|
+
export { BORDER, CALENDAR_DARK_CLASS, CALENDAR_STEPS, ERROR, GRID, INTENT_COLORS, MUTED, PANEL, SEQUENTIAL, SERIES, STATUS_CRIT, STATUS_WARN, SUCCESS, TEXT, TRACK, seriesColor };
|
|
50
|
+
//# sourceMappingURL=chunk-UATB2IRY.js.map
|
|
51
|
+
//# sourceMappingURL=chunk-UATB2IRY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/colors.ts"],"names":[],"mappings":";;AASA,IAAM,QAAQ,CAAC,IAAA,EAAc,aAAqB,CAAA,IAA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A,kBAAA;AACzC,IAAM,KAAA,GAAQ,sBAAsB,MAAM,CAAA,kBAAA;AAG1C,IAAM,aAAA,GAA6C;AAAA,EACxD,OAAA,EAAS,KAAA;AAAA,EACT,OAAA,EAAS,WAAA;AAAA,EACT,MAAA,EAAQ,WAAA;AAAA,EACR,OAAA,EAAS;AACX;AASO,IAAM,aAAa,CAAC,EAAA,EAAI,IAAI,EAAA,EAAI,EAAA,EAAI,GAAG,CAAA,CAAE,GAAA;AAAA,EAC9C,CAAC,UAAU,CAAA,oBAAA,EAAuB,MAAA,CAAO,CAAC,CAAC,CAAA,CAAA,EAAI,KAAK,CAAA,GAAA,EAAM,KAAK,CAAA,CAAA;AACjE;AAKA,IAAM,YAAA,GAAe,CAAC,KAAA,EAAe,KAAA,KACnC,CAAA,oBAAA,EAAuB,MAAA,CAAO,CAAC,CAAC,CAAA,2BAAA,EAA8B,KAAK,CAAA,EAAA,EAAK,KAAK,YAAY,KAAK,CAAA,CAAA,CAAA;AAUzF,IAAM,cAAA,GAAiB;AAAA,EAC5B,KAAA;AAAA,EACA,YAAA,CAAa,GAAG,EAAE,CAAA;AAAA,EAClB,YAAA,CAAa,GAAG,EAAE,CAAA;AAAA,EAClB,YAAA,CAAa,GAAG,EAAE,CAAA;AAAA,EAClB,CAAA,oBAAA,EAAuB,MAAA,CAAO,CAAC,CAAC,CAAA,CAAA;AAClC;AAGO,IAAM,mBAAA,GACX","file":"chunk-UATB2IRY.js","sourcesContent":["import type { ChartIntent } from '../types';\n\n// The colors every Recharts-based chart draws with. Each one is a CSS variable\n// string handed straight to the SVG (`fill`, `stroke`, `stopColor`, `cursor`):\n// a theme, accent or text size switch on <html> repaints the chart with no\n// observer and no `getComputedStyle`. The hex after the comma is the fallback\n// when the theme CSS isn't loaded or during SSR; with the theme it is never\n// used, since `@sckyzo/cosmos-theme` always emits these variables.\n\nconst token = (name: string, fallback: string) => `var(${name}, ${fallback})`;\n\n/** The hex of each series color in the default theme, series 1 first: the blue accent, then the hues of `--color-chart-2` to `--color-chart-8`. */\nexport const SERIES_FALLBACKS = [\n '#465fff',\n '#06b6d4',\n '#8b5cf6',\n '#ec4899',\n '#64748b',\n '#f97316',\n '#14b8a6',\n '#84cc16',\n];\n\nconst SERIES_TOKENS = [\n '--color-brand-500',\n ...SERIES_FALLBACKS.slice(1).map((_, i) => `--color-chart-${i + 2}`),\n];\n\n/**\n * The categorical palette: the accent, then seven hues. Which hues is decided\n * in the theme CSS: each accent skips the ones that look like it. None of the\n * first four reads as a status (green, amber, red).\n */\nexport const SERIES = SERIES_TOKENS.map((name, i) => token(name, SERIES_FALLBACKS[i]));\n\n/** The color of series `index`: `colors[index]` when given (cycling), the palette otherwise. */\nexport const seriesColor = (index: number, colors?: readonly string[]): string =>\n colors?.length ? colors[index % colors.length] : SERIES[index % SERIES.length];\n\n// A chart whose series are statuses passes these as `colors`.\nexport const SUCCESS = token('--color-success-500', '#12b76a');\nexport const WARNING = token('--color-warning-500', '#f79009');\nexport const ERROR = token('--color-error-500', '#f04438');\n/** The monitoring statuses, for thresholds. */\nexport const STATUS_WARN = token('--color-status-warn', '#f59e0b');\nexport const STATUS_CRIT = token('--color-status-crit', '#ef4444');\n\n/** The card the chart sits on. */\nexport const PANEL = token('--color-bg-panel', '#fff');\nexport const TEXT = token('--color-text-primary', '#101828');\nexport const MUTED = token('--color-text-muted', '#677185');\nexport const BORDER = token('--color-border', '#d0d5dd');\n// One semantic border variable reads right on every theme; the grid and the\n// empty part of a gauge are lighter steps of it.\nexport const GRID = `color-mix(in srgb, ${BORDER} 55%, transparent)`;\nexport const TRACK = `color-mix(in srgb, ${BORDER} 70%, transparent)`;\n\n/** The color of a reference line or band by its meaning: muted text for `neutral`, the status colors otherwise. */\nexport const INTENT_COLORS: Record<ChartIntent, string> = {\n neutral: MUTED,\n warning: STATUS_WARN,\n danger: STATUS_CRIT,\n success: SUCCESS,\n};\n\n/**\n * Five sequential steps of the accent over the card, low to high, on any\n * theme. Mixed in OKLab, which spaces the steps evenly to the eye: against the\n * card, the lowest step stays at 1.5:1 or more in the dark themes whatever the\n * accent (where a 24% share sat at 1.2:1), and two neighbors differ by 1.19:1\n * or more.\n */\nexport const SEQUENTIAL = [42, 56, 70, 84, 100].map(\n (share) => `color-mix(in oklab, ${SERIES[0]} ${share}%, ${PANEL})`\n);\n\n// A calendar step: a share of the accent over the card. The shares and the top\n// step are variables so that the dark themes can set their own on the chart's\n// root (`CalendarChart`); the fallbacks are the light themes' values.\nconst calendarStep = (index: number, share: number) =>\n `color-mix(in oklab, ${SERIES[0]} calc(var(--calendar-share-${index}, ${share}) * 1%), ${PANEL})`;\n\n/**\n * Five steps for a calendar of days: the neutral track for a day with no\n * value, then four of the accent. A day without activity is a cell of its own,\n * not a hole, and the four steps stay apart on any theme and accent. In the\n * light themes they are 48, 65, 82 and 100% of the accent over the card; the\n * dark themes set lower shares and a light accent for the top step through\n * `--calendar-share-1` to `-3` and `--calendar-top`.\n */\nexport const CALENDAR_STEPS = [\n TRACK,\n calendarStep(1, 48),\n calendarStep(2, 65),\n calendarStep(3, 82),\n `var(--calendar-top, ${SERIES[0]})`,\n];\n\n/** Sets the dark themes' calendar scale on the chart's root: Tailwind's `dark:` covers both of them. */\nexport const CALENDAR_DARK_CLASS =\n 'dark:[--calendar-share-1:50] dark:[--calendar-share-2:70] dark:[--calendar-share-3:100] dark:[--calendar-top:var(--color-brand-400)]';\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/core/data.ts
|
|
3
|
+
var seriesKey = (index) => `s${index}`;
|
|
4
|
+
var toRows = (categories, series) => categories.map((category, i) => ({
|
|
5
|
+
category,
|
|
6
|
+
...Object.fromEntries(series.map((s, k) => [seriesKey(k), s.data[i]]))
|
|
7
|
+
}));
|
|
8
|
+
var hasNoData = (series) => series.every((s) => s.data.length === 0);
|
|
9
|
+
var safeId = (id) => id.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
10
|
+
|
|
11
|
+
export { hasNoData, safeId, seriesKey, toRows };
|
|
12
|
+
//# sourceMappingURL=chunk-UJIV5PVI.js.map
|
|
13
|
+
//# sourceMappingURL=chunk-UJIV5PVI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/data.ts"],"names":[],"mappings":";;AAGO,IAAM,SAAA,GAAY,CAAC,KAAA,KAAkB,CAAA,CAAA,EAAI,KAAK,CAAA;AAG9C,IAAM,MAAA,GAAS,CAAC,UAAA,EAA0C,MAAA,KAC/D,WAAW,GAAA,CAAI,CAAC,UAAU,CAAA,MAAO;AAAA,EAC/B,QAAA;AAAA,EACA,GAAG,MAAA,CAAO,WAAA,CAAY,MAAA,CAAO,GAAA,CAAI,CAAC,CAAA,EAAG,CAAA,KAAM,CAAC,SAAA,CAAU,CAAC,CAAA,EAAG,CAAA,CAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACvE,CAAA,CAAE;AAGG,IAAM,SAAA,GAAY,CAAC,MAAA,KACxB,MAAA,CAAO,KAAA,CAAM,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,CAAK,MAAA,KAAW,CAAC;AAGlC,IAAM,SAAS,CAAC,EAAA,KAAe,EAAA,CAAG,OAAA,CAAQ,mBAAmB,EAAE","file":"chunk-UJIV5PVI.js","sourcesContent":["export type SeriesInput = { name: string; data: number[] };\n\n/** The data key of series `index`. Series are keyed by position: a name may hold dots, which Recharts reads as a path. */\nexport const seriesKey = (index: number) => `s${index}`;\n\n/** One row per category, with a value under each series key. */\nexport const toRows = (categories: readonly (string | number)[], series: readonly SeriesInput[]) =>\n categories.map((category, i) => ({\n category,\n ...Object.fromEntries(series.map((s, k) => [seriesKey(k), s.data[i]])),\n }));\n\n/** Whether there is nothing to draw: no series, or only series without a point. */\nexport const hasNoData = (series: readonly { data: readonly unknown[] }[]): boolean =>\n series.every((s) => s.data.length === 0);\n\n/** An id safe in `url(#…)`, from React's `useId` (`:r1:`). */\nexport const safeId = (id: string) => id.replace(/[^a-zA-Z0-9_-]/g, '');\n"]}
|