@nocoo/basalt 2.0.0-rc.1 → 2.0.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/dist/charts/area.d.ts +8 -4
- package/dist/charts/area.js +41 -42
- package/dist/charts/area.js.map +1 -1
- package/dist/charts/bar.d.ts +7 -4
- package/dist/charts/bar.js +34 -27
- package/dist/charts/bar.js.map +1 -1
- package/dist/charts/bullet.d.ts +6 -4
- package/dist/charts/bullet.js +18 -23
- package/dist/charts/bullet.js.map +1 -1
- package/dist/charts/chart-colors.d.ts +3 -0
- package/dist/charts/charts.d.ts +6 -4
- package/dist/charts/charts.js +4 -3
- package/dist/charts/charts.js.map +1 -1
- package/dist/charts/config.d.ts +26 -15
- package/dist/charts/config.js +58 -44
- package/dist/charts/config.js.map +1 -1
- package/dist/charts/custom-chart.d.ts +6 -4
- package/dist/charts/custom-chart.js +4 -3
- package/dist/charts/custom-chart.js.map +1 -1
- package/dist/charts/date-navigation.d.ts +5 -0
- package/dist/charts/date-navigation.js.map +1 -1
- package/dist/charts/donut.d.ts +6 -4
- package/dist/charts/donut.js +38 -28
- package/dist/charts/donut.js.map +1 -1
- package/dist/charts/frame.d.ts +7 -3
- package/dist/charts/frame.js +30 -7
- package/dist/charts/frame.js.map +1 -1
- package/dist/charts/funnel.d.ts +6 -4
- package/dist/charts/funnel.js +16 -17
- package/dist/charts/funnel.js.map +1 -1
- package/dist/charts/gauge.d.ts +6 -3
- package/dist/charts/gauge.js +18 -17
- package/dist/charts/gauge.js.map +1 -1
- package/dist/charts/grouped-bar.d.ts +8 -4
- package/dist/charts/grouped-bar.js +36 -29
- package/dist/charts/grouped-bar.js.map +1 -1
- package/dist/charts/heatmap-calendar.d.ts +11 -5
- package/dist/charts/heatmap-calendar.js +25 -20
- package/dist/charts/heatmap-calendar.js.map +1 -1
- package/dist/charts/item-list.d.ts +9 -7
- package/dist/charts/item-list.js +1 -5
- package/dist/charts/item-list.js.map +1 -1
- package/dist/charts/legend.d.ts +7 -0
- package/dist/charts/legend.js +56 -0
- package/dist/charts/legend.js.map +1 -0
- package/dist/charts/line.d.ts +7 -4
- package/dist/charts/line.js +33 -41
- package/dist/charts/line.js.map +1 -1
- package/dist/charts/palette.d.ts +3 -2
- package/dist/charts/palette.js.map +1 -1
- package/dist/charts/radar.d.ts +6 -4
- package/dist/charts/radar.js +18 -18
- package/dist/charts/radar.js.map +1 -1
- package/dist/charts/sample.d.ts +8 -42
- package/dist/charts/sample.js.map +1 -1
- package/dist/charts/sankey.d.ts +5 -4
- package/dist/charts/sankey.js +15 -16
- package/dist/charts/sankey.js.map +1 -1
- package/dist/charts/series.d.ts +48 -0
- package/dist/charts/series.js +19 -0
- package/dist/charts/series.js.map +1 -0
- package/dist/charts/slot-bar.d.ts +12 -5
- package/dist/charts/slot-bar.js +27 -22
- package/dist/charts/slot-bar.js.map +1 -1
- package/dist/charts/sparkline.d.ts +6 -4
- package/dist/charts/sparkline.js +12 -11
- package/dist/charts/sparkline.js.map +1 -1
- package/dist/charts/stacked-bar.d.ts +8 -4
- package/dist/charts/stacked-bar.js +40 -37
- package/dist/charts/stacked-bar.js.map +1 -1
- package/dist/charts/stat-card.d.ts +7 -5
- package/dist/charts/stat-card.js +1 -1
- package/dist/charts/stat-card.js.map +1 -1
- package/dist/charts/timeline.d.ts +15 -8
- package/dist/charts/timeline.js +9 -14
- package/dist/charts/timeline.js.map +1 -1
- package/dist/charts/timeseries.d.ts +6 -4
- package/dist/charts/timeseries.js +4 -3
- package/dist/charts/timeseries.js.map +1 -1
- package/dist/charts/tooltip.d.ts +16 -0
- package/dist/charts/tooltip.js +105 -0
- package/dist/charts/tooltip.js.map +1 -0
- package/dist/components/confirm-dialog.d.ts +5 -1
- package/dist/components/confirm-dialog.js +52 -25
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/delete-resource.d.ts +5 -0
- package/dist/components/delete-resource.js +38 -0
- package/dist/components/delete-resource.js.map +1 -0
- package/dist/components/loading-screen.js +9 -5
- package/dist/components/loading-screen.js.map +1 -1
- package/dist/components/resource-list.d.ts +10 -0
- package/dist/components/resource-list.js +30 -0
- package/dist/components/resource-list.js.map +1 -0
- package/dist/providers/accent.d.ts +22 -0
- package/dist/providers/accent.js +110 -0
- package/dist/providers/accent.js.map +1 -0
- package/dist/styles/standalone.css +5 -19
- package/package.json +1 -1
package/dist/charts/sankey.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { CHART_COLORS as e, chartAxis as t } from "./palette.js";
|
|
3
3
|
import { chartFontSize as n, chartTooltipProps as r } from "./config.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Sankey as c, Tooltip as l } from "recharts";
|
|
4
|
+
import { ChartFrame as i } from "./frame.js";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
import { Sankey as s, Tooltip as c } from "recharts";
|
|
8
7
|
//#region src/charts/sankey.tsx
|
|
9
|
-
function
|
|
10
|
-
return /* @__PURE__ */
|
|
8
|
+
function l({ x: r, y: i, width: s, height: c, payload: l }) {
|
|
9
|
+
return /* @__PURE__ */ o("g", { children: [/* @__PURE__ */ a("rect", {
|
|
11
10
|
x: r,
|
|
12
11
|
y: i,
|
|
13
|
-
width:
|
|
12
|
+
width: s,
|
|
14
13
|
height: c,
|
|
15
14
|
fill: e[2]
|
|
16
|
-
}), /* @__PURE__ */
|
|
17
|
-
x: r +
|
|
15
|
+
}), /* @__PURE__ */ a("text", {
|
|
16
|
+
x: r + s + 6,
|
|
18
17
|
y: i + c / 2,
|
|
19
18
|
dominantBaseline: "middle",
|
|
20
19
|
fontSize: n("axis"),
|
|
@@ -22,11 +21,11 @@ function u({ x: r, y: i, width: a, height: c, payload: l }) {
|
|
|
22
21
|
children: l.name
|
|
23
22
|
})] });
|
|
24
23
|
}
|
|
25
|
-
function
|
|
26
|
-
return /* @__PURE__ */
|
|
24
|
+
function u({ data: t, ariaLabel: n = "Sankey chart", className: o }) {
|
|
25
|
+
return /* @__PURE__ */ a(i, {
|
|
27
26
|
ariaLabel: n,
|
|
28
|
-
className:
|
|
29
|
-
children: /* @__PURE__ */
|
|
27
|
+
className: o,
|
|
28
|
+
children: /* @__PURE__ */ a(s, {
|
|
30
29
|
data: t,
|
|
31
30
|
nodePadding: 16,
|
|
32
31
|
nodeWidth: 12,
|
|
@@ -36,16 +35,16 @@ function d({ data: t = i, ariaLabel: n = "Sankey chart", className: s }) {
|
|
|
36
35
|
bottom: 8,
|
|
37
36
|
left: 8
|
|
38
37
|
},
|
|
39
|
-
node:
|
|
38
|
+
node: l,
|
|
40
39
|
link: {
|
|
41
40
|
stroke: e[0],
|
|
42
41
|
strokeOpacity: .3
|
|
43
42
|
},
|
|
44
|
-
children: /* @__PURE__ */
|
|
43
|
+
children: /* @__PURE__ */ a(c, { ...r({ cursor: !1 }) })
|
|
45
44
|
})
|
|
46
45
|
});
|
|
47
46
|
}
|
|
48
47
|
//#endregion
|
|
49
|
-
export {
|
|
48
|
+
export { u as SankeyChart };
|
|
50
49
|
|
|
51
50
|
//# sourceMappingURL=sankey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sankey.js","names":[],"sources":["../../src/charts/sankey.tsx"],"sourcesContent":["import { Sankey, type SankeyNodeProps, Tooltip } from \"recharts\";\nimport { chartFontSize, chartTooltipProps } from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport { CHART_COLORS, chartAxis } from \"./palette\";\nimport {
|
|
1
|
+
{"version":3,"file":"sankey.js","names":[],"sources":["../../src/charts/sankey.tsx"],"sourcesContent":["import { Sankey, type SankeyNodeProps, Tooltip } from \"recharts\";\nimport { chartFontSize, chartTooltipProps } from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport { CHART_COLORS, chartAxis } from \"./palette\";\nimport type { SankeyData } from \"./series\";\n\nfunction SankeyNode({ x, y, width, height, payload }: SankeyNodeProps) {\n\treturn (\n\t\t<g>\n\t\t\t<rect x={x} y={y} width={width} height={height} fill={CHART_COLORS[2]} />\n\t\t\t<text\n\t\t\t\tx={x + width + 6}\n\t\t\t\ty={y + height / 2}\n\t\t\t\tdominantBaseline=\"middle\"\n\t\t\t\tfontSize={chartFontSize(\"axis\")}\n\t\t\t\tfill={chartAxis}\n\t\t\t>\n\t\t\t\t{payload.name}\n\t\t\t</text>\n\t\t</g>\n\t);\n}\n\nexport type SankeyChartProps = {\n\tdata: SankeyData;\n\tariaLabel?: string;\n\tclassName?: string;\n};\n\nexport function SankeyChart({ data, ariaLabel = \"Sankey chart\", className }: SankeyChartProps) {\n\treturn (\n\t\t<ChartFrame ariaLabel={ariaLabel} className={className}>\n\t\t\t<Sankey\n\t\t\t\tdata={data}\n\t\t\t\tnodePadding={16}\n\t\t\t\tnodeWidth={12}\n\t\t\t\tmargin={{ top: 8, right: 72, bottom: 8, left: 8 }}\n\t\t\t\tnode={SankeyNode}\n\t\t\t\tlink={{ stroke: CHART_COLORS[0], strokeOpacity: 0.3 }}\n\t\t\t>\n\t\t\t\t<Tooltip {...chartTooltipProps({ cursor: false })} />\n\t\t\t</Sankey>\n\t\t</ChartFrame>\n\t);\n}\n"],"mappings":";;;;;;;AAMA,SAAS,EAAW,EAAE,MAAG,MAAG,UAAO,WAAQ,cAA4B;CACtE,OACC,kBAAC,KAAD,EAAA,UAAA,CACC,kBAAC,QAAD;EAAS;EAAM;EAAU;EAAe;EAAQ,MAAM,EAAa;CAAK,CAAA,GACxE,kBAAC,QAAD;EACC,GAAG,IAAI,IAAQ;EACf,GAAG,IAAI,IAAS;EAChB,kBAAiB;EACjB,UAAU,EAAc,MAAM;EAC9B,MAAM;EAEL,UAAA,EAAQ;CACJ,CAAA,CACJ,EAAA,CAAA;AAEL;AAQA,SAAgB,EAAY,EAAE,SAAM,eAAY,gBAAgB,gBAA+B;CAC9F,OACC,kBAAC,GAAD;EAAuB;EAAsB;EAC5C,UAAA,kBAAC,GAAD;GACO;GACN,aAAa;GACb,WAAW;GACX,QAAQ;IAAE,KAAK;IAAG,OAAO;IAAI,QAAQ;IAAG,MAAM;GAAE;GAChD,MAAM;GACN,MAAM;IAAE,QAAQ,EAAa;IAAI,eAAe;GAAI;GAEpD,UAAA,kBAAC,GAAD,EAAS,GAAI,EAAkB,EAAE,QAAQ,GAAM,CAAC,EAAI,CAAA;EAC7C,CAAA;CACG,CAAA;AAEd"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type ChartSeriesDescriptor = {
|
|
2
|
+
key: string;
|
|
3
|
+
label?: string;
|
|
4
|
+
color?: string;
|
|
5
|
+
};
|
|
6
|
+
export type XYSeriesKey = "y" | "y2" | "y3";
|
|
7
|
+
export type XYSeriesDescriptor = ChartSeriesDescriptor & {
|
|
8
|
+
key: XYSeriesKey;
|
|
9
|
+
};
|
|
10
|
+
export type BulletSeriesKey = "value" | "target";
|
|
11
|
+
export type BulletSeriesDescriptor = ChartSeriesDescriptor & {
|
|
12
|
+
key: BulletSeriesKey;
|
|
13
|
+
};
|
|
14
|
+
export type XYPoint = {
|
|
15
|
+
x: string | number;
|
|
16
|
+
y: number;
|
|
17
|
+
y2?: number;
|
|
18
|
+
y3?: number;
|
|
19
|
+
};
|
|
20
|
+
export type NamedValue = {
|
|
21
|
+
name: string;
|
|
22
|
+
value: number;
|
|
23
|
+
};
|
|
24
|
+
export type RadarPoint = {
|
|
25
|
+
subject: string;
|
|
26
|
+
value: number;
|
|
27
|
+
};
|
|
28
|
+
export type BulletPoint = {
|
|
29
|
+
name: string;
|
|
30
|
+
value: number;
|
|
31
|
+
target: number;
|
|
32
|
+
};
|
|
33
|
+
export type SankeyData = {
|
|
34
|
+
nodes: {
|
|
35
|
+
name: string;
|
|
36
|
+
}[];
|
|
37
|
+
links: {
|
|
38
|
+
source: number;
|
|
39
|
+
target: number;
|
|
40
|
+
value: number;
|
|
41
|
+
}[];
|
|
42
|
+
};
|
|
43
|
+
export declare function resolveChartSeries(series: ChartSeriesDescriptor[] | undefined, fallbackKeys: string[]): ChartSeriesDescriptor[];
|
|
44
|
+
export declare function applyLeadColor(items: ChartSeriesDescriptor[], color?: string): ChartSeriesDescriptor[];
|
|
45
|
+
export declare function xyFallbackKeys(data: Array<{
|
|
46
|
+
y2?: number;
|
|
47
|
+
y3?: number;
|
|
48
|
+
}>): string[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region src/charts/series.ts
|
|
3
|
+
function e(e, t) {
|
|
4
|
+
return e && e.length > 0 ? e : t.map((e) => ({ key: e }));
|
|
5
|
+
}
|
|
6
|
+
function t(e, t) {
|
|
7
|
+
return t ? e.map((e, n) => n === 0 ? {
|
|
8
|
+
...e,
|
|
9
|
+
color: e.color ?? t
|
|
10
|
+
} : e) : e;
|
|
11
|
+
}
|
|
12
|
+
function n(e) {
|
|
13
|
+
let t = ["y"];
|
|
14
|
+
return e.some((e) => e.y2 != null) && t.push("y2"), e.some((e) => e.y3 != null) && t.push("y3"), t;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { t as applyLeadColor, e as resolveChartSeries, n as xyFallbackKeys };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=series.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"series.js","names":[],"sources":["../../src/charts/series.ts"],"sourcesContent":["export type ChartSeriesDescriptor = {\n\tkey: string;\n\tlabel?: string;\n\tcolor?: string;\n};\n\nexport type XYSeriesKey = \"y\" | \"y2\" | \"y3\";\nexport type XYSeriesDescriptor = ChartSeriesDescriptor & { key: XYSeriesKey };\nexport type BulletSeriesKey = \"value\" | \"target\";\nexport type BulletSeriesDescriptor = ChartSeriesDescriptor & { key: BulletSeriesKey };\n\nexport type XYPoint = { x: string | number; y: number; y2?: number; y3?: number };\nexport type NamedValue = { name: string; value: number };\nexport type RadarPoint = { subject: string; value: number };\nexport type BulletPoint = { name: string; value: number; target: number };\nexport type SankeyData = {\n\tnodes: { name: string }[];\n\tlinks: { source: number; target: number; value: number }[];\n};\n\nexport function resolveChartSeries(\n\tseries: ChartSeriesDescriptor[] | undefined,\n\tfallbackKeys: string[],\n): ChartSeriesDescriptor[] {\n\tif (series && series.length > 0) {\n\t\treturn series;\n\t}\n\treturn fallbackKeys.map((key) => ({ key }));\n}\n\nexport function applyLeadColor(\n\titems: ChartSeriesDescriptor[],\n\tcolor?: string,\n): ChartSeriesDescriptor[] {\n\tif (!color) {\n\t\treturn items;\n\t}\n\treturn items.map((item, index) => (index === 0 ? { ...item, color: item.color ?? color } : item));\n}\n\nexport function xyFallbackKeys(data: Array<{ y2?: number; y3?: number }>): string[] {\n\tconst keys = [\"y\"];\n\tif (data.some((point) => point.y2 != null)) {\n\t\tkeys.push(\"y2\");\n\t}\n\tif (data.some((point) => point.y3 != null)) {\n\t\tkeys.push(\"y3\");\n\t}\n\treturn keys;\n}\n"],"mappings":";;AAoBA,SAAgB,EACf,GACA,GAC0B;CAI1B,OAHI,KAAU,EAAO,SAAS,IACtB,IAED,EAAa,KAAK,OAAS,EAAE,OAAI,EAAE;AAC3C;AAEA,SAAgB,EACf,GACA,GAC0B;CAI1B,OAHK,IAGE,EAAM,KAAK,GAAM,MAAW,MAAU,IAAI;EAAE,GAAG;EAAM,OAAO,EAAK,SAAS;CAAM,IAAI,CAAK,IAFxF;AAGT;AAEA,SAAgB,EAAe,GAAqD;CACnF,IAAM,IAAO,CAAC,GAAG;CAOjB,OANI,EAAK,MAAM,MAAU,EAAM,MAAM,IAAI,KACxC,EAAK,KAAK,IAAI,GAEX,EAAK,MAAM,MAAU,EAAM,MAAM,IAAI,KACxC,EAAK,KAAK,IAAI,GAER;AACR"}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import { type XYPoint } from "./
|
|
1
|
+
import { type XYPoint, type XYSeriesDescriptor } from "./series.js";
|
|
2
2
|
export type SlotBarItem = {
|
|
3
3
|
color: string;
|
|
4
4
|
height?: number;
|
|
5
5
|
label?: string;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
items?: SlotBarItem[];
|
|
7
|
+
export type SlotBarItemsProps = {
|
|
8
|
+
items: SlotBarItem[];
|
|
10
9
|
ariaLabel?: string;
|
|
11
10
|
heightClass?: string;
|
|
12
11
|
gapClass?: string;
|
|
13
12
|
emptyClass?: string;
|
|
14
13
|
className?: string;
|
|
15
|
-
}
|
|
14
|
+
};
|
|
15
|
+
export type SlotBarDataProps = {
|
|
16
|
+
data: XYPoint[];
|
|
17
|
+
series?: XYSeriesDescriptor[];
|
|
18
|
+
ariaLabel?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
};
|
|
21
|
+
export type SlotBarChartProps = SlotBarItemsProps | SlotBarDataProps;
|
|
22
|
+
export declare function SlotBarChart(props: SlotBarChartProps): import("react").JSX.Element;
|
package/dist/charts/slot-bar.js
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn as e } from "../utils/cn.js";
|
|
3
3
|
import { Tooltip as t, TooltipContent as n, TooltipProvider as r, TooltipTrigger as i } from "../components/tooltip.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { SAMPLE as l } from "./sample.js";
|
|
4
|
+
import { ANIMATION_PROPS as a, BAR_RADIUS as o, cartesianAxisProps as s, seriesColor as c } from "./config.js";
|
|
5
|
+
import { resolveChartSeries as l } from "./series.js";
|
|
7
6
|
import { ChartFrame as u } from "./frame.js";
|
|
8
7
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
8
|
import { Bar as p, BarChart as m, XAxis as h, YAxis as g } from "recharts";
|
|
10
9
|
//#region src/charts/slot-bar.tsx
|
|
11
|
-
function _(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
function _(e) {
|
|
11
|
+
if ("items" in e) {
|
|
12
|
+
let { ariaLabel: t = "Slot bar chart", heightClass: n = "h-6", gapClass: r = "gap-px", emptyClass: i = "bg-basalt-muted", className: a } = e;
|
|
13
|
+
return /* @__PURE__ */ d(v, {
|
|
14
|
+
items: e.items,
|
|
15
|
+
ariaLabel: t,
|
|
16
|
+
heightClass: n,
|
|
17
|
+
gapClass: r,
|
|
18
|
+
emptyClass: i,
|
|
19
|
+
className: a
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
let { series: t, ariaLabel: n = "Slot bar chart", className: r } = e, i = l(t, ["y"]);
|
|
23
|
+
return /* @__PURE__ */ d(u, {
|
|
20
24
|
ariaLabel: n,
|
|
21
|
-
className:
|
|
25
|
+
className: r,
|
|
22
26
|
children: /* @__PURE__ */ f(m, {
|
|
23
|
-
data: e,
|
|
27
|
+
data: e.data,
|
|
24
28
|
children: [
|
|
25
29
|
/* @__PURE__ */ d(h, {
|
|
26
30
|
dataKey: "x",
|
|
27
|
-
...
|
|
31
|
+
...s(!0)
|
|
28
32
|
}),
|
|
29
|
-
/* @__PURE__ */ d(g, { ...
|
|
30
|
-
/* @__PURE__ */ d(p, {
|
|
31
|
-
dataKey:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
/* @__PURE__ */ d(g, { ...s(!0) }),
|
|
34
|
+
i.map((e, t) => /* @__PURE__ */ d(p, {
|
|
35
|
+
dataKey: e.key,
|
|
36
|
+
name: e.label ?? e.key,
|
|
37
|
+
fill: c(e, t),
|
|
38
|
+
radius: o.vertical,
|
|
39
|
+
...a
|
|
40
|
+
}, e.key))
|
|
36
41
|
]
|
|
37
42
|
})
|
|
38
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot-bar.js","names":[],"sources":["../../src/charts/slot-bar.tsx"],"sourcesContent":["import { Bar, BarChart as RechartsBar, XAxis, YAxis } from \"recharts\";\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from \"../components/tooltip\";\nimport { cn } from \"../utils/cn\";\nimport { ANIMATION_PROPS, BAR_RADIUS, cartesianAxisProps } from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport {
|
|
1
|
+
{"version":3,"file":"slot-bar.js","names":[],"sources":["../../src/charts/slot-bar.tsx"],"sourcesContent":["import { Bar, BarChart as RechartsBar, XAxis, YAxis } from \"recharts\";\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from \"../components/tooltip\";\nimport { cn } from \"../utils/cn\";\nimport { ANIMATION_PROPS, BAR_RADIUS, cartesianAxisProps, seriesColor } from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport { resolveChartSeries, type XYPoint, type XYSeriesDescriptor } from \"./series\";\n\nexport type SlotBarItem = {\n\tcolor: string;\n\theight?: number;\n\tlabel?: string;\n};\n\nexport type SlotBarItemsProps = {\n\titems: SlotBarItem[];\n\tariaLabel?: string;\n\theightClass?: string;\n\tgapClass?: string;\n\temptyClass?: string;\n\tclassName?: string;\n};\n\nexport type SlotBarDataProps = {\n\tdata: XYPoint[];\n\tseries?: XYSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n};\n\nexport type SlotBarChartProps = SlotBarItemsProps | SlotBarDataProps;\n\nexport function SlotBarChart(props: SlotBarChartProps) {\n\tif (\"items\" in props) {\n\t\tconst {\n\t\t\tariaLabel = \"Slot bar chart\",\n\t\t\theightClass = \"h-6\",\n\t\t\tgapClass = \"gap-px\",\n\t\t\temptyClass = \"bg-basalt-muted\",\n\t\t\tclassName,\n\t\t} = props;\n\t\treturn (\n\t\t\t<SlotItemBars\n\t\t\t\titems={props.items}\n\t\t\t\tariaLabel={ariaLabel}\n\t\t\t\theightClass={heightClass}\n\t\t\t\tgapClass={gapClass}\n\t\t\t\temptyClass={emptyClass}\n\t\t\t\tclassName={className}\n\t\t\t/>\n\t\t);\n\t}\n\tconst { series, ariaLabel = \"Slot bar chart\", className } = props;\n\tconst bars = resolveChartSeries(series, [\"y\"]);\n\treturn (\n\t\t<ChartFrame ariaLabel={ariaLabel} className={className}>\n\t\t\t<RechartsBar data={props.data}>\n\t\t\t\t<XAxis dataKey=\"x\" {...cartesianAxisProps(true)} />\n\t\t\t\t<YAxis {...cartesianAxisProps(true)} />\n\t\t\t\t{bars.map((item, index) => (\n\t\t\t\t\t<Bar\n\t\t\t\t\t\tkey={item.key}\n\t\t\t\t\t\tdataKey={item.key}\n\t\t\t\t\t\tname={item.label ?? item.key}\n\t\t\t\t\t\tfill={seriesColor(item, index)}\n\t\t\t\t\t\tradius={BAR_RADIUS.vertical}\n\t\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t\t/>\n\t\t\t\t))}\n\t\t\t</RechartsBar>\n\t\t</ChartFrame>\n\t);\n}\n\nfunction SlotItemBars({\n\titems,\n\tariaLabel,\n\theightClass,\n\tgapClass,\n\temptyClass,\n\tclassName,\n}: {\n\titems: SlotBarItem[];\n\tariaLabel: string;\n\theightClass: string;\n\tgapClass: string;\n\temptyClass: string;\n\tclassName?: string;\n}) {\n\tif (items.length === 0) {\n\t\treturn null;\n\t}\n\tconst hasTooltips = items.some((item) => item.label);\n\tfunction renderBar(item: SlotBarItem) {\n\t\tconst heightRatio = item.height ?? 1;\n\t\tconst isEmpty = heightRatio <= 0;\n\t\tconst isTailwindColor = item.color.startsWith(\"bg-\");\n\t\tconst heightPercent = isEmpty ? 100 : Math.max(heightRatio * 100, 10);\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"w-full rounded-sm\",\n\t\t\t\t\tisEmpty ? emptyClass : isTailwindColor ? item.color : undefined,\n\t\t\t\t)}\n\t\t\t\tstyle={{\n\t\t\t\t\theight: `${heightPercent}%`,\n\t\t\t\t\t...(isEmpty || isTailwindColor ? {} : { backgroundColor: item.color }),\n\t\t\t\t}}\n\t\t\t\tdata-testid=\"slot-bar\"\n\t\t\t/>\n\t\t);\n\t}\n\tconst content = items.map((item, index) => {\n\t\tconst bar =\n\t\t\thasTooltips && item.label ? (\n\t\t\t\t<Tooltip>\n\t\t\t\t\t<TooltipTrigger asChild>{renderBar(item)}</TooltipTrigger>\n\t\t\t\t\t<TooltipContent side=\"top\">\n\t\t\t\t\t\t<p>{item.label}</p>\n\t\t\t\t\t</TooltipContent>\n\t\t\t\t</Tooltip>\n\t\t\t) : (\n\t\t\t\trenderBar(item)\n\t\t\t);\n\t\treturn (\n\t\t\t<div\n\t\t\t\tkey={`${item.label ?? item.color}-${index}`}\n\t\t\t\tclassName=\"flex min-h-0 min-w-0 flex-1 items-end self-stretch\"\n\t\t\t>\n\t\t\t\t{bar}\n\t\t\t</div>\n\t\t);\n\t});\n\tconst container = (\n\t\t<div\n\t\t\tclassName={cn(\"flex w-full items-end\", heightClass, gapClass, className)}\n\t\t\trole=\"img\"\n\t\t\taria-label={ariaLabel}\n\t\t>\n\t\t\t{content}\n\t\t</div>\n\t);\n\tif (hasTooltips) {\n\t\treturn <TooltipProvider delayDuration={0}>{container}</TooltipProvider>;\n\t}\n\treturn container;\n}\n"],"mappings":";;;;;;;;;AA+BA,SAAgB,EAAa,GAA0B;CACtD,IAAI,WAAW,GAAO;EACrB,IAAM,EACL,eAAY,kBACZ,iBAAc,OACd,cAAW,UACX,gBAAa,mBACb,iBACG;EACJ,OACC,kBAAC,GAAD;GACC,OAAO,EAAM;GACF;GACE;GACH;GACE;GACD;EACX,CAAA;CAEH;CACA,IAAM,EAAE,WAAQ,eAAY,kBAAkB,iBAAc,GACtD,IAAO,EAAmB,GAAQ,CAAC,GAAG,CAAC;CAC7C,OACC,kBAAC,GAAD;EAAuB;EAAsB;EAC5C,UAAA,kBAAC,GAAD;GAAa,MAAM,EAAM;GAAzB,UAAA;IACC,kBAAC,GAAD;KAAO,SAAQ;KAAI,GAAI,EAAmB,EAAI;IAAI,CAAA;IAClD,kBAAC,GAAD,EAAO,GAAI,EAAmB,EAAI,EAAI,CAAA;IACrC,EAAK,KAAK,GAAM,MAChB,kBAAC,GAAD;KAEC,SAAS,EAAK;KACd,MAAM,EAAK,SAAS,EAAK;KACzB,MAAM,EAAY,GAAM,CAAK;KAC7B,QAAQ,EAAW;KACnB,GAAI;IACJ,GANK,EAAK,GAMV,CACD;GACW;;CACF,CAAA;AAEd;AAEA,SAAS,EAAa,EACrB,UACA,cACA,gBACA,aACA,eACA,gBAQE;CACF,IAAI,EAAM,WAAW,GACpB,OAAO;CAER,IAAM,IAAc,EAAM,MAAM,MAAS,EAAK,KAAK;CACnD,SAAS,EAAU,GAAmB;EACrC,IAAM,IAAc,EAAK,UAAU,GAC7B,IAAU,KAAe,GACzB,IAAkB,EAAK,MAAM,WAAW,KAAK,GAC7C,IAAgB,IAAU,MAAM,KAAK,IAAI,IAAc,KAAK,EAAE;EACpE,OACC,kBAAC,OAAD;GACC,WAAW,EACV,qBACA,IAAU,IAAa,IAAkB,EAAK,QAAQ,KAAA,CACvD;GACA,OAAO;IACN,QAAQ,GAAG,EAAc;IACzB,GAAI,KAAW,IAAkB,CAAC,IAAI,EAAE,iBAAiB,EAAK,MAAM;GACrE;GACA,eAAY;EACZ,CAAA;CAEH;CACA,IAAM,IAAU,EAAM,KAAK,GAAM,MAAU;EAC1C,IAAM,IACL,KAAe,EAAK,QACnB,kBAAC,GAAD,EAAA,UAAA,CACC,kBAAC,GAAD;GAAgB,SAAA;GAAS,UAAA,EAAU,CAAI;EAAkB,CAAA,GACzD,kBAAC,GAAD;GAAgB,MAAK;GACpB,UAAA,kBAAC,KAAD,EAAA,UAAI,EAAK,MAAS,CAAA;EACH,CAAA,CACR,EAAA,CAAA,IAET,EAAU,CAAI;EAEhB,OACC,kBAAC,OAAD;GAEC,WAAU;GAET,UAAA;EACG,GAJC,GAAG,EAAK,SAAS,EAAK,MAAM,GAAG,GAIhC;CAEP,CAAC,GACK,IACL,kBAAC,OAAD;EACC,WAAW,EAAG,yBAAyB,GAAa,GAAU,CAAS;EACvE,MAAK;EACL,cAAY;EAEX,UAAA;CACG,CAAA;CAKN,OAHI,IACI,kBAAC,GAAD;EAAiB,eAAe;EAAI,UAAA;CAA2B,CAAA,IAEhE;AACR"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { type XYPoint } from "./
|
|
2
|
-
export
|
|
3
|
-
data
|
|
1
|
+
import { type XYPoint, type XYSeriesDescriptor } from "./series.js";
|
|
2
|
+
export type SparklineProps = {
|
|
3
|
+
data: XYPoint[];
|
|
4
|
+
series?: XYSeriesDescriptor[];
|
|
4
5
|
ariaLabel?: string;
|
|
5
6
|
className?: string;
|
|
6
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export declare function Sparkline({ data, series, ariaLabel, className }: SparklineProps): import("react").JSX.Element;
|
package/dist/charts/sparkline.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { SAMPLE as n } from "./sample.js";
|
|
2
|
+
import { ANIMATION_PROPS as e, seriesColor as t } from "./config.js";
|
|
3
|
+
import { resolveChartSeries as n } from "./series.js";
|
|
5
4
|
import { ChartFrame as r } from "./frame.js";
|
|
6
5
|
import { jsx as i } from "react/jsx-runtime";
|
|
7
6
|
import { Line as a, LineChart as o } from "recharts";
|
|
8
7
|
//#region src/charts/sparkline.tsx
|
|
9
|
-
function s({ data: s
|
|
8
|
+
function s({ data: s, series: c, ariaLabel: l = "Sparkline", className: u }) {
|
|
9
|
+
let d = n(c, ["y"]);
|
|
10
10
|
return /* @__PURE__ */ i(r, {
|
|
11
|
-
ariaLabel:
|
|
12
|
-
className:
|
|
11
|
+
ariaLabel: l,
|
|
12
|
+
className: u,
|
|
13
13
|
size: "h-10 w-28",
|
|
14
14
|
children: /* @__PURE__ */ i(o, {
|
|
15
15
|
data: s,
|
|
16
|
-
children: /* @__PURE__ */ i(a, {
|
|
16
|
+
children: d.map((n, r) => /* @__PURE__ */ i(a, {
|
|
17
17
|
type: "monotone",
|
|
18
|
-
dataKey:
|
|
19
|
-
|
|
18
|
+
dataKey: n.key,
|
|
19
|
+
name: n.label ?? n.key,
|
|
20
|
+
stroke: t(n, r),
|
|
20
21
|
dot: !1,
|
|
21
|
-
...
|
|
22
|
-
})
|
|
22
|
+
...e
|
|
23
|
+
}, n.key))
|
|
23
24
|
})
|
|
24
25
|
});
|
|
25
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sparkline.js","names":[],"sources":["../../src/charts/sparkline.tsx"],"sourcesContent":["import { Line, LineChart as RechartsLine } from \"recharts\";\nimport { ANIMATION_PROPS } from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport {
|
|
1
|
+
{"version":3,"file":"sparkline.js","names":[],"sources":["../../src/charts/sparkline.tsx"],"sourcesContent":["import { Line, LineChart as RechartsLine } from \"recharts\";\nimport { ANIMATION_PROPS, seriesColor } from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport { resolveChartSeries, type XYPoint, type XYSeriesDescriptor } from \"./series\";\n\nexport type SparklineProps = {\n\tdata: XYPoint[];\n\tseries?: XYSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n};\n\nexport function Sparkline({ data, series, ariaLabel = \"Sparkline\", className }: SparklineProps) {\n\tconst lines = resolveChartSeries(series, [\"y\"]);\n\treturn (\n\t\t<ChartFrame ariaLabel={ariaLabel} className={className} size=\"h-10 w-28\">\n\t\t\t<RechartsLine data={data}>\n\t\t\t\t{lines.map((item, index) => (\n\t\t\t\t\t<Line\n\t\t\t\t\t\tkey={item.key}\n\t\t\t\t\t\ttype=\"monotone\"\n\t\t\t\t\t\tdataKey={item.key}\n\t\t\t\t\t\tname={item.label ?? item.key}\n\t\t\t\t\t\tstroke={seriesColor(item, index)}\n\t\t\t\t\t\tdot={false}\n\t\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t\t/>\n\t\t\t\t))}\n\t\t\t</RechartsLine>\n\t\t</ChartFrame>\n\t);\n}\n"],"mappings":";;;;;;;AAYA,SAAgB,EAAU,EAAE,SAAM,WAAQ,eAAY,aAAa,gBAA6B;CAC/F,IAAM,IAAQ,EAAmB,GAAQ,CAAC,GAAG,CAAC;CAC9C,OACC,kBAAC,GAAD;EAAuB;EAAsB;EAAW,MAAK;EAC5D,UAAA,kBAAC,GAAD;GAAoB;GAClB,UAAA,EAAM,KAAK,GAAM,MACjB,kBAAC,GAAD;IAEC,MAAK;IACL,SAAS,EAAK;IACd,MAAM,EAAK,SAAS,EAAK;IACzB,QAAQ,EAAY,GAAM,CAAK;IAC/B,KAAK;IACL,GAAI;GACJ,GAPK,EAAK,GAOV,CACD;EACY,CAAA;CACH,CAAA;AAEd"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { type XYPoint } from "./
|
|
2
|
-
export
|
|
3
|
-
data
|
|
1
|
+
import { type XYPoint, type XYSeriesDescriptor } from "./series.js";
|
|
2
|
+
export type StackedBarChartProps = {
|
|
3
|
+
data: XYPoint[];
|
|
4
|
+
series?: XYSeriesDescriptor[];
|
|
4
5
|
ariaLabel?: string;
|
|
5
6
|
className?: string;
|
|
6
7
|
showAxes?: boolean;
|
|
7
|
-
|
|
8
|
+
showLegend?: boolean;
|
|
9
|
+
valueFormatter?: (value: number) => string;
|
|
10
|
+
};
|
|
11
|
+
export declare function StackedBarChart({ data, series, ariaLabel, className, showAxes, showLegend, valueFormatter, }: StackedBarChartProps): import("react").JSX.Element;
|
|
@@ -1,51 +1,54 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { jsx as
|
|
7
|
-
import { Bar as
|
|
2
|
+
import { ANIMATION_PROPS as e, BAR_RADIUS as t, CHART_PLOT_MARGIN as n, CHART_PLOT_MARGIN_BARE as r, GRID_PROPS as i, cartesianAxisProps as a, chartTooltipProps as o, seriesColor as s } from "./config.js";
|
|
3
|
+
import { resolveChartSeries as c } from "./series.js";
|
|
4
|
+
import { ChartShell as l } from "./frame.js";
|
|
5
|
+
import { ChartLegend as u } from "./legend.js";
|
|
6
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
7
|
+
import { Bar as p, BarChart as m, CartesianGrid as h, Tooltip as g, XAxis as _, YAxis as v } from "recharts";
|
|
8
8
|
//#region src/charts/stacked-bar.tsx
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
function y({ data: y, series: b, ariaLabel: x = "Stacked bar chart", className: S, showAxes: C = !1, showLegend: w = !1, valueFormatter: T }) {
|
|
10
|
+
let E = c(b, [
|
|
11
|
+
"y",
|
|
12
|
+
"y2",
|
|
13
|
+
"y3"
|
|
14
|
+
]);
|
|
15
|
+
return /* @__PURE__ */ d(l, {
|
|
16
|
+
ariaLabel: x,
|
|
17
|
+
className: S,
|
|
18
|
+
legend: w ? /* @__PURE__ */ d(u, {
|
|
19
|
+
items: E,
|
|
20
|
+
shape: "bar"
|
|
21
|
+
}) : void 0,
|
|
22
|
+
children: /* @__PURE__ */ f(m, {
|
|
23
|
+
data: y,
|
|
24
|
+
margin: C ? n : r,
|
|
15
25
|
children: [
|
|
16
|
-
|
|
17
|
-
/* @__PURE__ */
|
|
26
|
+
C ? /* @__PURE__ */ d(h, { ...i }) : null,
|
|
27
|
+
/* @__PURE__ */ d(_, {
|
|
18
28
|
dataKey: "x",
|
|
19
|
-
...
|
|
29
|
+
...a(!C)
|
|
20
30
|
}),
|
|
21
|
-
/* @__PURE__ */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
dataKey: "y",
|
|
25
|
-
stackId: "stack",
|
|
26
|
-
fill: e[0],
|
|
27
|
-
radius: n.vertical,
|
|
28
|
-
...t
|
|
29
|
-
}),
|
|
30
|
-
/* @__PURE__ */ c(u, {
|
|
31
|
-
dataKey: "y2",
|
|
32
|
-
stackId: "stack",
|
|
33
|
-
fill: e[2],
|
|
34
|
-
radius: n.vertical,
|
|
35
|
-
...t
|
|
31
|
+
/* @__PURE__ */ d(v, {
|
|
32
|
+
...a(!C),
|
|
33
|
+
tickFormatter: T
|
|
36
34
|
}),
|
|
37
|
-
/* @__PURE__ */
|
|
38
|
-
|
|
35
|
+
/* @__PURE__ */ d(g, { ...o({
|
|
36
|
+
formatter: T,
|
|
37
|
+
cursor: "bar"
|
|
38
|
+
}) }),
|
|
39
|
+
E.map((n, r) => /* @__PURE__ */ d(p, {
|
|
40
|
+
dataKey: n.key,
|
|
41
|
+
name: n.label ?? n.key,
|
|
39
42
|
stackId: "stack",
|
|
40
|
-
fill:
|
|
41
|
-
radius:
|
|
42
|
-
...
|
|
43
|
-
})
|
|
43
|
+
fill: s(n, r),
|
|
44
|
+
radius: t.vertical,
|
|
45
|
+
...e
|
|
46
|
+
}, n.key))
|
|
44
47
|
]
|
|
45
48
|
})
|
|
46
49
|
});
|
|
47
50
|
}
|
|
48
51
|
//#endregion
|
|
49
|
-
export {
|
|
52
|
+
export { y as StackedBarChart };
|
|
50
53
|
|
|
51
54
|
//# sourceMappingURL=stacked-bar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stacked-bar.js","names":[],"sources":["../../src/charts/stacked-bar.tsx"],"sourcesContent":["import { Bar, CartesianGrid, BarChart as RechartsBar, Tooltip, XAxis, YAxis } from \"recharts\";\nimport {\n\tANIMATION_PROPS,\n\tBAR_RADIUS,\n\tcartesianAxisProps,\n\tchartTooltipProps,\n\tGRID_PROPS,\n} from \"./config\";\nimport {
|
|
1
|
+
{"version":3,"file":"stacked-bar.js","names":[],"sources":["../../src/charts/stacked-bar.tsx"],"sourcesContent":["import { Bar, CartesianGrid, BarChart as RechartsBar, Tooltip, XAxis, YAxis } from \"recharts\";\nimport {\n\tANIMATION_PROPS,\n\tBAR_RADIUS,\n\tCHART_PLOT_MARGIN,\n\tCHART_PLOT_MARGIN_BARE,\n\tcartesianAxisProps,\n\tchartTooltipProps,\n\tGRID_PROPS,\n\tseriesColor,\n} from \"./config\";\nimport { ChartShell } from \"./frame\";\nimport { ChartLegend } from \"./legend\";\nimport { resolveChartSeries, type XYPoint, type XYSeriesDescriptor } from \"./series\";\n\nexport type StackedBarChartProps = {\n\tdata: XYPoint[];\n\tseries?: XYSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n\tshowAxes?: boolean;\n\tshowLegend?: boolean;\n\tvalueFormatter?: (value: number) => string;\n};\n\nexport function StackedBarChart({\n\tdata,\n\tseries,\n\tariaLabel = \"Stacked bar chart\",\n\tclassName,\n\tshowAxes = false,\n\tshowLegend = false,\n\tvalueFormatter,\n}: StackedBarChartProps) {\n\tconst bars = resolveChartSeries(series, [\"y\", \"y2\", \"y3\"]);\n\treturn (\n\t\t<ChartShell\n\t\t\tariaLabel={ariaLabel}\n\t\t\tclassName={className}\n\t\t\tlegend={showLegend ? <ChartLegend items={bars} shape=\"bar\" /> : undefined}\n\t\t>\n\t\t\t<RechartsBar data={data} margin={showAxes ? CHART_PLOT_MARGIN : CHART_PLOT_MARGIN_BARE}>\n\t\t\t\t{showAxes ? <CartesianGrid {...GRID_PROPS} /> : null}\n\t\t\t\t<XAxis dataKey=\"x\" {...cartesianAxisProps(!showAxes)} />\n\t\t\t\t<YAxis {...cartesianAxisProps(!showAxes)} tickFormatter={valueFormatter} />\n\t\t\t\t<Tooltip {...chartTooltipProps({ formatter: valueFormatter, cursor: \"bar\" })} />\n\t\t\t\t{bars.map((item, index) => (\n\t\t\t\t\t<Bar\n\t\t\t\t\t\tkey={item.key}\n\t\t\t\t\t\tdataKey={item.key}\n\t\t\t\t\t\tname={item.label ?? item.key}\n\t\t\t\t\t\tstackId=\"stack\"\n\t\t\t\t\t\tfill={seriesColor(item, index)}\n\t\t\t\t\t\tradius={BAR_RADIUS.vertical}\n\t\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t\t/>\n\t\t\t\t))}\n\t\t\t</RechartsBar>\n\t\t</ChartShell>\n\t);\n}\n"],"mappings":";;;;;;;;AAyBA,SAAgB,EAAgB,EAC/B,SACA,WACA,eAAY,qBACZ,cACA,cAAW,IACX,gBAAa,IACb,qBACwB;CACxB,IAAM,IAAO,EAAmB,GAAQ;EAAC;EAAK;EAAM;CAAI,CAAC;CACzD,OACC,kBAAC,GAAD;EACY;EACA;EACX,QAAQ,IAAa,kBAAC,GAAD;GAAa,OAAO;GAAM,OAAM;EAAO,CAAA,IAAI,KAAA;EAEhE,UAAA,kBAAC,GAAD;GAAmB;GAAM,QAAQ,IAAW,IAAoB;GAAhE,UAAA;IACE,IAAW,kBAAC,GAAD,EAAe,GAAI,EAAa,CAAA,IAAI;IAChD,kBAAC,GAAD;KAAO,SAAQ;KAAI,GAAI,EAAmB,CAAC,CAAQ;IAAI,CAAA;IACvD,kBAAC,GAAD;KAAO,GAAI,EAAmB,CAAC,CAAQ;KAAG,eAAe;IAAiB,CAAA;IAC1E,kBAAC,GAAD,EAAS,GAAI,EAAkB;KAAE,WAAW;KAAgB,QAAQ;IAAM,CAAC,EAAI,CAAA;IAC9E,EAAK,KAAK,GAAM,MAChB,kBAAC,GAAD;KAEC,SAAS,EAAK;KACd,MAAM,EAAK,SAAS,EAAK;KACzB,SAAQ;KACR,MAAM,EAAY,GAAM,CAAK;KAC7B,QAAQ,EAAW;KACnB,GAAI;IACJ,GAPK,EAAK,GAOV,CACD;GACW;;CACF,CAAA;AAEd"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { LucideIcon } from "lucide-react";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
-
export
|
|
3
|
+
export type StatCardProps = {
|
|
4
4
|
label?: string;
|
|
5
5
|
title?: string;
|
|
6
|
-
value
|
|
6
|
+
value: string | number;
|
|
7
7
|
subtitle?: string;
|
|
8
8
|
icon?: LucideIcon;
|
|
9
9
|
iconColor?: string;
|
|
@@ -13,9 +13,11 @@ export declare function StatCard({ label, title, value, subtitle, icon: Icon, ic
|
|
|
13
13
|
};
|
|
14
14
|
ariaLabel?: string;
|
|
15
15
|
className?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare function
|
|
16
|
+
};
|
|
17
|
+
export declare function StatCard({ label, title, value, subtitle, icon: Icon, iconColor, trend, ariaLabel, className, }: StatCardProps): import("react").JSX.Element;
|
|
18
|
+
export type StatGridProps = {
|
|
18
19
|
children: ReactNode;
|
|
19
20
|
columns?: 2 | 3 | 4;
|
|
20
21
|
className?: string;
|
|
21
|
-
}
|
|
22
|
+
};
|
|
23
|
+
export declare function StatGrid({ children, columns, className }: StatGridProps): import("react").JSX.Element;
|
package/dist/charts/stat-card.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { cn as e } from "../utils/cn.js";
|
|
3
3
|
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
4
4
|
//#region src/charts/stat-card.tsx
|
|
5
|
-
function r({ label: r
|
|
5
|
+
function r({ label: r, title: i, value: a, subtitle: o, icon: s, iconColor: c = "text-basalt-muted-foreground", trend: l, ariaLabel: u, className: d }) {
|
|
6
6
|
let f = i ?? r, p = typeof a == "number" ? a.toLocaleString() : a, m = l && l.value > 0, h = l && l.value < 0, g = u ?? [
|
|
7
7
|
f,
|
|
8
8
|
p,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stat-card.js","names":[],"sources":["../../src/charts/stat-card.tsx"],"sourcesContent":["import type { LucideIcon } from \"lucide-react\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"../utils/cn\";\n\nexport
|
|
1
|
+
{"version":3,"file":"stat-card.js","names":[],"sources":["../../src/charts/stat-card.tsx"],"sourcesContent":["import type { LucideIcon } from \"lucide-react\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"../utils/cn\";\n\nexport type StatCardProps = {\n\tlabel?: string;\n\ttitle?: string;\n\tvalue: string | number;\n\tsubtitle?: string;\n\ticon?: LucideIcon;\n\ticonColor?: string;\n\ttrend?: { value: number; label?: string };\n\tariaLabel?: string;\n\tclassName?: string;\n};\n\nexport function StatCard({\n\tlabel,\n\ttitle,\n\tvalue,\n\tsubtitle,\n\ticon: Icon,\n\ticonColor = \"text-basalt-muted-foreground\",\n\ttrend,\n\tariaLabel,\n\tclassName,\n}: StatCardProps) {\n\tconst heading = title ?? label;\n\tconst display = typeof value === \"number\" ? value.toLocaleString() : value;\n\tconst isPositiveTrend = trend && trend.value > 0;\n\tconst isNegativeTrend = trend && trend.value < 0;\n\tconst named =\n\t\tariaLabel ??\n\t\t[\n\t\t\theading,\n\t\t\tdisplay,\n\t\t\tsubtitle,\n\t\t\ttrend ? `${isPositiveTrend ? \"+\" : \"\"}${trend.value}% ${trend.label ?? \"\"}` : null,\n\t\t]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\" \")\n\t\t\t.trim();\n\treturn (\n\t\t<div\n\t\t\tclassName={cn(\n\t\t\t\t\"rounded-basalt-md border border-basalt-border bg-basalt-secondary p-4\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\trole=\"img\"\n\t\t\taria-label={named}\n\t\t>\n\t\t\t<div className=\"flex items-start justify-between\">\n\t\t\t\t<div className=\"space-y-1\">\n\t\t\t\t\t<p className=\"text-xs text-basalt-muted-foreground md:text-sm\">{heading}</p>\n\t\t\t\t\t<p className=\"font-display text-xl font-semibold tracking-tight text-basalt-foreground md:text-2xl\">\n\t\t\t\t\t\t{display}\n\t\t\t\t\t</p>\n\t\t\t\t\t{subtitle ? <p className=\"text-xs text-basalt-muted-foreground\">{subtitle}</p> : null}\n\t\t\t\t</div>\n\t\t\t\t{Icon ? (\n\t\t\t\t\t<div className={cn(\"rounded-md bg-basalt-card p-2\", iconColor)}>\n\t\t\t\t\t\t<Icon className=\"h-5 w-5\" strokeWidth={1.5} />\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t\t{trend ? (\n\t\t\t\t<div className=\"mt-3 flex items-center gap-1 text-xs\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\"font-medium\",\n\t\t\t\t\t\t\tisPositiveTrend && \"text-basalt-heatmap-green-4\",\n\t\t\t\t\t\t\tisNegativeTrend && \"text-basalt-destructive\",\n\t\t\t\t\t\t\t!isPositiveTrend && !isNegativeTrend && \"text-basalt-muted-foreground\",\n\t\t\t\t\t\t)}\n\t\t\t\t\t>\n\t\t\t\t\t\t{`${isPositiveTrend ? \"+\" : \"\"}${trend.value}%`}\n\t\t\t\t\t</span>\n\t\t\t\t\t{trend.label ? <span className=\"text-basalt-muted-foreground\">{trend.label}</span> : null}\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t);\n}\n\nexport type StatGridProps = {\n\tchildren: ReactNode;\n\tcolumns?: 2 | 3 | 4;\n\tclassName?: string;\n};\n\nexport function StatGrid({ children, columns = 4, className }: StatGridProps) {\n\tconst gridCols = {\n\t\t2: \"grid-cols-1 sm:grid-cols-2\",\n\t\t3: \"grid-cols-1 sm:grid-cols-2 lg:grid-cols-3\",\n\t\t4: \"grid-cols-1 sm:grid-cols-2 lg:grid-cols-4\",\n\t};\n\treturn <div className={cn(\"grid gap-3 md:gap-4\", gridCols[columns], className)}>{children}</div>;\n}\n"],"mappings":";;;;AAgBA,SAAgB,EAAS,EACxB,UACA,UACA,UACA,aACA,MAAM,GACN,eAAY,gCACZ,UACA,cACA,gBACiB;CACjB,IAAM,IAAU,KAAS,GACnB,IAAU,OAAO,KAAU,WAAW,EAAM,eAAe,IAAI,GAC/D,IAAkB,KAAS,EAAM,QAAQ,GACzC,IAAkB,KAAS,EAAM,QAAQ,GACzC,IACL,KACA;EACC;EACA;EACA;EACA,IAAQ,GAAG,IAAkB,MAAM,KAAK,EAAM,MAAM,IAAI,EAAM,SAAS,OAAO;CAC/E,CAAC,CACC,OAAO,OAAO,CAAC,CACf,KAAK,GAAG,CAAC,CACT,KAAK;CACR,OACC,kBAAC,OAAD;EACC,WAAW,EACV,yEACA,CACD;EACA,MAAK;EACL,cAAY;EANb,UAAA,CAQC,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACC,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACC,kBAAC,KAAD;MAAG,WAAU;MAAmD,UAAA;KAAW,CAAA;KAC3E,kBAAC,KAAD;MAAG,WAAU;MACX,UAAA;KACC,CAAA;KACF,IAAW,kBAAC,KAAD;MAAG,WAAU;MAAwC,UAAA;KAAY,CAAA,IAAI;IAC7E;GACJ,CAAA,GAAA,IACA,kBAAC,OAAD;IAAK,WAAW,EAAG,iCAAiC,CAAS;IAC5D,UAAA,kBAAC,GAAD;KAAM,WAAU;KAAU,aAAa;IAAM,CAAA;GACzC,CAAA,IACF,IACA;EACJ,CAAA,GAAA,IACA,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACC,kBAAC,QAAD;IACC,WAAW,EACV,eACA,KAAmB,+BACnB,KAAmB,2BACnB,CAAC,KAAmB,CAAC,KAAmB,8BACzC;IAEC,UAAA,GAAG,IAAkB,MAAM,KAAK,EAAM,MAAM;GACxC,CAAA,GACL,EAAM,QAAQ,kBAAC,QAAD;IAAM,WAAU;IAAgC,UAAA,EAAM;GAAY,CAAA,IAAI,IACjF;EACF,CAAA,IAAA,IACA;;AAEP;AAQA,SAAgB,EAAS,EAAE,aAAU,aAAU,GAAG,gBAA4B;CAM7E,OAAO,kBAAC,OAAD;EAAK,WAAW,EAAG,uBAAuB;GAJhD,GAAG;GACH,GAAG;GACH,GAAG;EAE6C,EAAS,IAAU,CAAS;EAAI;CAAc,CAAA;AAChG"}
|
|
@@ -5,13 +5,20 @@ export type TimelineEvent = {
|
|
|
5
5
|
subtitle?: string;
|
|
6
6
|
color?: string;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
export type TimelineItem = {
|
|
9
|
+
id?: string;
|
|
10
|
+
title: string;
|
|
11
|
+
at?: string;
|
|
12
|
+
};
|
|
13
|
+
export type TimelineItemsProps = {
|
|
14
|
+
items: TimelineItem[];
|
|
15
|
+
ariaLabel?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
export type TimelineEventsProps = {
|
|
19
|
+
events: TimelineEvent[];
|
|
15
20
|
ariaLabel?: string;
|
|
16
21
|
className?: string;
|
|
17
|
-
}
|
|
22
|
+
};
|
|
23
|
+
export type TimelineProps = TimelineItemsProps | TimelineEventsProps;
|
|
24
|
+
export declare function Timeline(props: TimelineProps): import("react").JSX.Element;
|
package/dist/charts/timeline.js
CHANGED
|
@@ -6,21 +6,16 @@ var r = Array.from({ length: 24 }, (e, t) => t);
|
|
|
6
6
|
function i(e) {
|
|
7
7
|
return Number.parseInt(e.split(":")[0] ?? "0", 10);
|
|
8
8
|
}
|
|
9
|
-
function a(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}], events: i, ariaLabel: a = "Timeline", className: s }) {
|
|
16
|
-
return i ? /* @__PURE__ */ t(o, {
|
|
17
|
-
events: i,
|
|
18
|
-
ariaLabel: a,
|
|
19
|
-
className: s
|
|
9
|
+
function a(r) {
|
|
10
|
+
let { ariaLabel: i = "Timeline", className: a } = r;
|
|
11
|
+
return "events" in r ? /* @__PURE__ */ t(o, {
|
|
12
|
+
events: r.events,
|
|
13
|
+
ariaLabel: i,
|
|
14
|
+
className: a
|
|
20
15
|
}) : /* @__PURE__ */ t("ol", {
|
|
21
|
-
className: e("space-y-2 text-sm",
|
|
22
|
-
"aria-label":
|
|
23
|
-
children: r.map((e, r) => /* @__PURE__ */ n("li", {
|
|
16
|
+
className: e("space-y-2 text-sm", a),
|
|
17
|
+
"aria-label": i,
|
|
18
|
+
children: r.items.map((e, r) => /* @__PURE__ */ n("li", {
|
|
24
19
|
className: "flex gap-2",
|
|
25
20
|
children: [/* @__PURE__ */ t("span", {
|
|
26
21
|
className: "text-basalt-muted-foreground",
|