@lucasromero/matrix-ui 0.10.0 → 0.12.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/CHANGELOG.md +23 -0
- package/README.md +1 -0
- package/dist/components/AreaChart/AreaChart.d.ts +3 -0
- package/dist/components/AreaChart/AreaChart.js +14 -0
- package/dist/components/AreaChart/index.d.ts +1 -0
- package/dist/components/BarChart/BarChart.d.ts +3 -0
- package/dist/components/BarChart/BarChart.js +134 -0
- package/dist/components/BarChart/index.d.ts +1 -0
- package/dist/components/Chart/ChartAxes.d.ts +2 -0
- package/dist/components/Chart/ChartAxes.js +28 -0
- package/dist/components/Chart/ChartFrame.d.ts +7 -0
- package/dist/components/Chart/ChartFrame.js +108 -0
- package/dist/components/Chart/ChartPatterns.d.ts +3 -0
- package/dist/components/Chart/ChartPatterns.js +27 -0
- package/dist/components/Chart/ChartPlot.d.ts +2 -0
- package/dist/components/Chart/ChartPlot.js +101 -0
- package/dist/components/Chart/LinearChart.d.ts +3 -0
- package/dist/components/Chart/LinearChart.js +133 -0
- package/dist/components/Chart/RadialChart.d.ts +20 -0
- package/dist/components/Chart/RadialChart.js +112 -0
- package/dist/components/Chart/index.module.js +38 -0
- package/dist/components/Chart/math.d.ts +19 -0
- package/dist/components/Chart/math.js +82 -0
- package/dist/components/Chart/useChartSize.d.ts +3 -0
- package/dist/components/Chart/useChartSize.js +24 -0
- package/dist/components/DonutChart/DonutChart.d.ts +19 -0
- package/dist/components/DonutChart/DonutChart.js +12 -0
- package/dist/components/DonutChart/index.d.ts +1 -0
- package/dist/components/LineChart/LineChart.d.ts +3 -0
- package/dist/components/LineChart/LineChart.js +14 -0
- package/dist/components/LineChart/index.d.ts +1 -0
- package/dist/components/PieChart/PieChart.d.ts +17 -0
- package/dist/components/PieChart/PieChart.js +12 -0
- package/dist/components/PieChart/index.d.ts +1 -0
- package/dist/components/Sparkline/Sparkline.d.ts +7 -0
- package/dist/components/Sparkline/Sparkline.js +56 -0
- package/dist/components/Sparkline/index.d.ts +1 -0
- package/dist/components/Sparkline/index.module.js +9 -0
- package/dist/components/Table/Table.js +145 -34
- package/dist/components/Table/TableSelectAll.d.ts +9 -0
- package/dist/components/Table/TableSelectAll.js +18 -0
- package/dist/components/Table/index.module.js +14 -3
- package/dist/index.d.ts +13 -1
- package/dist/index.js +66 -60
- package/dist/styles.css +1 -1
- package/dist/types/areaChartType.d.ts +5 -0
- package/dist/types/barChartType.d.ts +8 -0
- package/dist/types/chartType.d.ts +156 -0
- package/dist/types/donutChartType.d.ts +6 -0
- package/dist/types/index.d.ts +8 -1
- package/dist/types/lineChartType.d.ts +5 -0
- package/dist/types/pieChartType.d.ts +2 -0
- package/dist/types/sparklineType.d.ts +14 -0
- package/dist/types/tableType.d.ts +71 -3
- package/package.json +1 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ChartFrame as e } from "./ChartFrame.js";
|
|
3
|
+
import { ChartPlot as t } from "./ChartPlot.js";
|
|
4
|
+
import { formatNumber as n, seriesColor as r, slicePath as i, toNumber as a } from "./math.js";
|
|
5
|
+
import o from "./index.module.js";
|
|
6
|
+
import { forwardRef as s, useId as c } from "react";
|
|
7
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
|
+
// src/components/Chart/RadialChart.tsx
|
|
9
|
+
var d = (e) => `${Math.round(e * 1e3) / 10}%`, f = s(({ data: s, label: f, innerRatio: p, center: m, height: h = 240, formatValue: g = n, formatShare: _ = d, categoryLabel: v = "Category", valueLabel: y = "Value", shareLabel: b = "Share", showLegend: x = !0, keyboardHint: S = "Use the arrow keys to read each value.", ...C }, w) => {
|
|
10
|
+
let T = c(), E = s.flatMap((e, t) => {
|
|
11
|
+
let n = a(e.value), i = e.color ?? t + 1;
|
|
12
|
+
return n !== null && n > 0 ? [{
|
|
13
|
+
label: e.label,
|
|
14
|
+
value: n,
|
|
15
|
+
slot: i,
|
|
16
|
+
color: r(i)
|
|
17
|
+
}] : [];
|
|
18
|
+
}), D = E.reduce((e, { value: t }) => e + t, 0), O = E.map((e, t) => {
|
|
19
|
+
let n = E.slice(0, t).reduce((e, { value: t }) => e + t, 0);
|
|
20
|
+
return {
|
|
21
|
+
...e,
|
|
22
|
+
share: e.value / D,
|
|
23
|
+
start: n / D,
|
|
24
|
+
end: (n + e.value) / D
|
|
25
|
+
};
|
|
26
|
+
}), k = (e) => {
|
|
27
|
+
let t = Math.max(1, Math.min(e.width, h) / 2 - 6);
|
|
28
|
+
return {
|
|
29
|
+
radius: t,
|
|
30
|
+
middle: {
|
|
31
|
+
x: e.width / 2,
|
|
32
|
+
y: h / 2
|
|
33
|
+
},
|
|
34
|
+
inner: t * p
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ l(e, {
|
|
38
|
+
...C,
|
|
39
|
+
ref: w,
|
|
40
|
+
label: f,
|
|
41
|
+
patternId: T,
|
|
42
|
+
isEmpty: O.length === 0,
|
|
43
|
+
legend: x ? O.map((e) => ({
|
|
44
|
+
label: e.label,
|
|
45
|
+
color: e.color,
|
|
46
|
+
slot: e.slot,
|
|
47
|
+
mark: "fill",
|
|
48
|
+
value: _(e.share)
|
|
49
|
+
})) : [],
|
|
50
|
+
table: {
|
|
51
|
+
headers: [
|
|
52
|
+
v,
|
|
53
|
+
y,
|
|
54
|
+
b
|
|
55
|
+
],
|
|
56
|
+
rows: O.map((e) => [
|
|
57
|
+
e.label,
|
|
58
|
+
g(e.value),
|
|
59
|
+
_(e.share)
|
|
60
|
+
])
|
|
61
|
+
},
|
|
62
|
+
children: /* @__PURE__ */ l(t, {
|
|
63
|
+
label: f,
|
|
64
|
+
height: h,
|
|
65
|
+
hint: S,
|
|
66
|
+
count: O.length,
|
|
67
|
+
patternId: T,
|
|
68
|
+
findIndex: ({ x: e, y: t }, n) => {
|
|
69
|
+
let { radius: r, middle: i, inner: a } = k(n), o = Math.hypot(e - i.x, t - i.y);
|
|
70
|
+
if (o > r || o < a) return null;
|
|
71
|
+
let s = (Math.atan2(t - i.y, e - i.x) / (2 * Math.PI) + .25 + 1) % 1, c = O.findIndex(({ start: e, end: t }) => s >= e && s < t);
|
|
72
|
+
return c === -1 ? null : c;
|
|
73
|
+
},
|
|
74
|
+
getAnchor: (e, t) => {
|
|
75
|
+
let { radius: n, middle: r, inner: i } = k(t), { start: a, end: o } = O[e], s = (a + o) / 2 * 2 * Math.PI - Math.PI / 2, c = (n + i) / 2;
|
|
76
|
+
return {
|
|
77
|
+
x: r.x + c * Math.cos(s),
|
|
78
|
+
y: Math.min(Math.max(0, r.y + c * Math.sin(s) - t.fontSize * 1.5), Math.max(0, h - t.fontSize * 4))
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
getTooltip: (e) => {
|
|
82
|
+
let t = O[e];
|
|
83
|
+
return { rows: [{
|
|
84
|
+
label: `${t.label}, ${_(t.share)}`,
|
|
85
|
+
value: g(t.value),
|
|
86
|
+
color: t.color
|
|
87
|
+
}] };
|
|
88
|
+
},
|
|
89
|
+
overlay: m ? /* @__PURE__ */ l("div", {
|
|
90
|
+
className: o.center,
|
|
91
|
+
children: m
|
|
92
|
+
}) : void 0,
|
|
93
|
+
render: (e, t) => {
|
|
94
|
+
let { radius: n, middle: r, inner: a } = k(e);
|
|
95
|
+
return O.map((e, s) => {
|
|
96
|
+
let c = i(r, a, s === t ? n + 4 : n, e.start, e.end);
|
|
97
|
+
return /* @__PURE__ */ u("g", { children: [/* @__PURE__ */ l("path", {
|
|
98
|
+
className: o.slice,
|
|
99
|
+
style: { fill: e.color },
|
|
100
|
+
d: c
|
|
101
|
+
}), /* @__PURE__ */ l("path", {
|
|
102
|
+
className: o.pattern,
|
|
103
|
+
fill: `url(#${T}-${(e.slot - 1) % 8 + 1})`,
|
|
104
|
+
d: c
|
|
105
|
+
})] }, s);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
f.displayName = "RadialChart";
|
|
112
|
+
export { f as RadialChart };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/components/Chart/index.module.scss
|
|
2
|
+
var e = "matrix-chart-chart", t = "matrix-chart-caption", n = "matrix-chart-label", r = "matrix-chart-hiddenCaption", i = "matrix-chart-hiddenTable", a = "matrix-chart-empty", o = "matrix-chart-legend", s = "matrix-chart-legendItem", c = "matrix-chart-legendValue", l = "matrix-chart-swatch", u = "matrix-chart-plotArea", d = "matrix-chart-plot", f = "matrix-chart-svg", p = "matrix-chart-grid", m = "matrix-chart-baseline", h = "matrix-chart-crosshair", g = "matrix-chart-tick", _ = "matrix-chart-line", v = "matrix-chart-marker", y = "matrix-chart-area", b = "matrix-chart-stackedArea", x = "matrix-chart-band", S = "matrix-chart-slice", C = "matrix-chart-pattern", w = "matrix-chart-withPatterns", T = "matrix-chart-patternLine", E = "matrix-chart-patternDot", D = "matrix-chart-tooltip", O = "matrix-chart-tooltipTitle", k = "matrix-chart-tooltipRow", A = "matrix-chart-tooltipKey", j = "matrix-chart-tooltipValue", M = "matrix-chart-center", N = "matrix-chart-table", P = {
|
|
3
|
+
chart: e,
|
|
4
|
+
caption: t,
|
|
5
|
+
label: n,
|
|
6
|
+
hiddenCaption: r,
|
|
7
|
+
hiddenTable: i,
|
|
8
|
+
empty: a,
|
|
9
|
+
legend: o,
|
|
10
|
+
legendItem: s,
|
|
11
|
+
legendValue: c,
|
|
12
|
+
swatch: l,
|
|
13
|
+
plotArea: u,
|
|
14
|
+
plot: d,
|
|
15
|
+
svg: f,
|
|
16
|
+
grid: p,
|
|
17
|
+
baseline: m,
|
|
18
|
+
crosshair: h,
|
|
19
|
+
tick: g,
|
|
20
|
+
line: _,
|
|
21
|
+
marker: v,
|
|
22
|
+
area: y,
|
|
23
|
+
stackedArea: b,
|
|
24
|
+
band: x,
|
|
25
|
+
slice: S,
|
|
26
|
+
pattern: C,
|
|
27
|
+
withPatterns: w,
|
|
28
|
+
patternLine: T,
|
|
29
|
+
patternDot: E,
|
|
30
|
+
tooltip: D,
|
|
31
|
+
tooltipTitle: O,
|
|
32
|
+
tooltipRow: k,
|
|
33
|
+
tooltipKey: A,
|
|
34
|
+
tooltipValue: j,
|
|
35
|
+
center: M,
|
|
36
|
+
table: N
|
|
37
|
+
};
|
|
38
|
+
export { y as area, x as band, m as baseline, t as caption, M as center, e as chart, h as crosshair, P as default, a as empty, p as grid, r as hiddenCaption, i as hiddenTable, n as label, o as legend, s as legendItem, c as legendValue, _ as line, v as marker, C as pattern, E as patternDot, T as patternLine, d as plot, u as plotArea, S as slice, b as stackedArea, f as svg, l as swatch, N as table, g as tick, D as tooltip, A as tooltipKey, k as tooltipRow, O as tooltipTitle, j as tooltipValue, w as withPatterns };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ChartPoint, ChartScale, ChartSeries, ChartSeriesValues } from "../../types/chartType.js";
|
|
2
|
+
export declare const formatNumber: (value: number) => string;
|
|
3
|
+
export declare const formatTicks: (scale: ChartScale) => (value: number) => string;
|
|
4
|
+
export declare const toNumber: (value: unknown) => number | null;
|
|
5
|
+
export declare const seriesColor: (slot: number) => string;
|
|
6
|
+
export declare const readSeries: <Row extends object>(data: readonly Row[], series: readonly ChartSeries<Row>[]) => ChartSeriesValues[];
|
|
7
|
+
export declare const createScale: (low: number, high: number) => ChartScale;
|
|
8
|
+
export declare const scaleRatio: (value: number, scale: ChartScale) => number;
|
|
9
|
+
export declare const stackSeries: (series: ChartSeriesValues[], count: number) => {
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
}[][];
|
|
13
|
+
export declare const linePath: (points: ChartPoint[]) => string;
|
|
14
|
+
export declare const splitAtGaps: (points: (ChartPoint | null)[]) => ChartPoint[][];
|
|
15
|
+
export declare const markerPath: (slot: number, x: number, y: number, radius: number) => string;
|
|
16
|
+
export declare const barPath: (x: number, y: number, width: number, height: number, roundedSide: "top" | "bottom" | "left" | "right" | "none") => string;
|
|
17
|
+
export declare const slicePath: (center: ChartPoint, innerRadius: number, outerRadius: number, start: number, end: number) => string;
|
|
18
|
+
export declare const textWidth: (text: string, fontSize: number) => number;
|
|
19
|
+
export declare const fitText: (text: string, width: number, fontSize: number) => string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// src/components/Chart/math.ts
|
|
2
|
+
var e = new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }), t = new Intl.NumberFormat("en-US", {
|
|
3
|
+
notation: "compact",
|
|
4
|
+
maximumFractionDigits: 1
|
|
5
|
+
}), n = (t) => e.format(t), r = (e) => Math.max(Math.abs(e.min), Math.abs(e.max)) >= 1e4 ? (e) => t.format(e) : n, i = (e) => typeof e == "number" && Number.isFinite(e) ? e : null, a = (e) => e <= 8 ? `var(--matrix-chart-color-${e})` : "var(--matrix-color-text-subtle)", o = (e, t) => t.map(({ key: t, label: n, color: r }, o) => {
|
|
6
|
+
let s = r ?? o + 1;
|
|
7
|
+
return {
|
|
8
|
+
label: n,
|
|
9
|
+
slot: s,
|
|
10
|
+
color: a(s),
|
|
11
|
+
values: e.map((e) => i(e[t]))
|
|
12
|
+
};
|
|
13
|
+
}), s = (e, t) => {
|
|
14
|
+
let n = e === t ? Math.min(e, 0) : e, r = e === t ? t > 0 ? t : n + 1 : t, i = (r - n) / 4, a = 10 ** Math.floor(Math.log10(i)), o = a * ([
|
|
15
|
+
1,
|
|
16
|
+
2,
|
|
17
|
+
2.5,
|
|
18
|
+
5
|
|
19
|
+
].find((e) => e * a >= i) ?? 10), s = Math.floor(n / o), c = Math.ceil(r / o), l = Array.from({ length: c - s + 1 }, (e, t) => Number(((s + t) * o).toPrecision(12)));
|
|
20
|
+
return {
|
|
21
|
+
min: l[0],
|
|
22
|
+
max: l[l.length - 1],
|
|
23
|
+
ticks: l
|
|
24
|
+
};
|
|
25
|
+
}, c = (e, t) => (e - t.min) / (t.max - t.min), l = (e, t) => {
|
|
26
|
+
let n = Array.from({ length: t }, () => 0), r = Array.from({ length: t }, () => 0);
|
|
27
|
+
return e.map(({ values: e }) => e.map((e, t) => {
|
|
28
|
+
let i = e ?? 0, a = i < 0 ? r : n, o = a[t];
|
|
29
|
+
return a[t] += i, {
|
|
30
|
+
start: o,
|
|
31
|
+
end: a[t]
|
|
32
|
+
};
|
|
33
|
+
}));
|
|
34
|
+
}, u = (e) => e.map(({ x: e, y: t }, n) => `${n === 0 ? "M" : "L"}${e},${t}`).join(""), d = (e) => e.reduce((e, t) => (t ? e[e.length - 1].push(t) : e[e.length - 1].length > 0 && e.push([]), e), [[]]).filter((e) => e.length > 0), f = (e, t, n, r, i) => `${u(Array.from({ length: r }, (a, o) => {
|
|
35
|
+
let s = i + o * 2 * Math.PI / r;
|
|
36
|
+
return {
|
|
37
|
+
x: e + n * Math.cos(s),
|
|
38
|
+
y: t + n * Math.sin(s)
|
|
39
|
+
};
|
|
40
|
+
}))}Z`, p = (e, t, n, r) => {
|
|
41
|
+
let i = -Math.PI / 2;
|
|
42
|
+
switch ((e - 1) % 8) {
|
|
43
|
+
case 1: return f(t, n, r * 1.2, 4, Math.PI / 4);
|
|
44
|
+
case 2: return f(t, n, r * 1.3, 3, i);
|
|
45
|
+
case 3: return f(t, n, r * 1.25, 4, i);
|
|
46
|
+
case 4: return f(t, n, r * 1.3, 3, -i);
|
|
47
|
+
case 5: return f(t, n, r * 1.15, 5, i);
|
|
48
|
+
case 6: return f(t, n, r * 1.15, 6, i);
|
|
49
|
+
case 7: return f(t, n, r * 1.15, 5, -i);
|
|
50
|
+
default: return `M${t - r},${n}a${r},${r} 0 1,0 ${r * 2},0a${r},${r} 0 1,0 ${-r * 2},0Z`;
|
|
51
|
+
}
|
|
52
|
+
}, m = (e, t, n, r, i) => {
|
|
53
|
+
let a = Math.min(4, n / 2, r / 2), o = (...e) => e.includes(i) ? a : 0, s = o("top", "left"), c = o("top", "right"), l = o("bottom", "right"), u = o("bottom", "left"), d = (e, t, n) => e > 0 ? `a${e},${e} 0 0,1 ${t * e},${n * e}` : "";
|
|
54
|
+
return [
|
|
55
|
+
`M${e + s},${t}`,
|
|
56
|
+
`H${e + n - c}`,
|
|
57
|
+
d(c, 1, 1),
|
|
58
|
+
`V${t + r - l}`,
|
|
59
|
+
d(l, -1, 1),
|
|
60
|
+
`H${e + u}`,
|
|
61
|
+
d(u, -1, -1),
|
|
62
|
+
`V${t + s}`,
|
|
63
|
+
d(s, 1, -1),
|
|
64
|
+
"Z"
|
|
65
|
+
].join("");
|
|
66
|
+
}, h = (e, t, n, r, i) => {
|
|
67
|
+
let a = (t, n) => {
|
|
68
|
+
let r = n * 2 * Math.PI - Math.PI / 2;
|
|
69
|
+
return `${e.x + t * Math.cos(r)},${e.y + t * Math.sin(r)}`;
|
|
70
|
+
};
|
|
71
|
+
if (i - r > .9999) {
|
|
72
|
+
let e = (e, t) => `M${a(e, 0)}A${e},${e} 0 1,${t} ${a(e, .5)}A${e},${e} 0 1,${t} ${a(e, 0)}Z`;
|
|
73
|
+
return e(n, 1) + (t > 0 ? e(t, 0) : "");
|
|
74
|
+
}
|
|
75
|
+
let o = +(i - r > .5), s = `M${a(n, r)}A${n},${n} 0 ${o},1 ${a(n, i)}`;
|
|
76
|
+
return t > 0 ? `${s}L${a(t, i)}A${t},${t} 0 ${o},0 ${a(t, r)}Z` : `${s}L${e.x},${e.y}Z`;
|
|
77
|
+
}, g = (e, t) => e.length * t * .58, _ = (e, t, n) => {
|
|
78
|
+
if (g(e, n) <= t) return e;
|
|
79
|
+
let r = Math.max(1, Math.floor(t / (n * .58)) - 1);
|
|
80
|
+
return `${e.slice(0, r).trimEnd()}…`;
|
|
81
|
+
};
|
|
82
|
+
export { m as barPath, s as createScale, _ as fitText, n as formatNumber, r as formatTicks, u as linePath, p as markerPath, o as readSeries, c as scaleRatio, a as seriesColor, h as slicePath, d as splitAtGaps, l as stackSeries, g as textWidth, i as toNumber };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect as e, useLayoutEffect as t, useState as n } from "react";
|
|
3
|
+
// src/components/Chart/useChartSize.ts
|
|
4
|
+
var r = typeof window > "u" ? e : t, i = (e) => {
|
|
5
|
+
let [t, i] = n({
|
|
6
|
+
width: 600,
|
|
7
|
+
fontSize: 13
|
|
8
|
+
});
|
|
9
|
+
return r(() => {
|
|
10
|
+
let t = e.current;
|
|
11
|
+
if (!t) return;
|
|
12
|
+
let n = () => {
|
|
13
|
+
let e = Math.round(t.getBoundingClientRect().width), n = Number.parseFloat(getComputedStyle(t).fontSize) || 13;
|
|
14
|
+
e !== 0 && i((t) => t.width === e && t.fontSize === n ? t : {
|
|
15
|
+
width: e,
|
|
16
|
+
fontSize: n
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
if (n(), typeof ResizeObserver > "u") return;
|
|
20
|
+
let r = new ResizeObserver(n);
|
|
21
|
+
return r.observe(t), () => r.disconnect();
|
|
22
|
+
}, [e]), t;
|
|
23
|
+
};
|
|
24
|
+
export { i as useChartSize };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const DonutChart: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLElement>, "children"> & {
|
|
2
|
+
label: string;
|
|
3
|
+
hideLabel?: boolean;
|
|
4
|
+
height?: number;
|
|
5
|
+
formatValue?: (value: number) => string;
|
|
6
|
+
showTable?: boolean;
|
|
7
|
+
categoryLabel?: string;
|
|
8
|
+
patterns?: boolean;
|
|
9
|
+
emptyMessage?: import("react").ReactNode;
|
|
10
|
+
keyboardHint?: string;
|
|
11
|
+
} & {
|
|
12
|
+
data: readonly import("../../index.js").ChartSlice[];
|
|
13
|
+
valueLabel?: string;
|
|
14
|
+
shareLabel?: string;
|
|
15
|
+
formatShare?: (share: number) => string;
|
|
16
|
+
showLegend?: boolean;
|
|
17
|
+
} & {
|
|
18
|
+
center?: import("react").ReactNode;
|
|
19
|
+
} & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { RadialChart as e } from "../Chart/RadialChart.js";
|
|
3
|
+
import { forwardRef as t } from "react";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
// src/components/DonutChart/DonutChart.tsx
|
|
6
|
+
var r = t((t, r) => /* @__PURE__ */ n(e, {
|
|
7
|
+
...t,
|
|
8
|
+
ref: r,
|
|
9
|
+
innerRatio: .62
|
|
10
|
+
}));
|
|
11
|
+
r.displayName = "DonutChart";
|
|
12
|
+
export { r as DonutChart };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DonutChart } from "./DonutChart.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { LinearChart as e } from "../Chart/LinearChart.js";
|
|
3
|
+
import { forwardRef as t } from "react";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
var r = t(({ includeZero: t = !0, ...r }, i) => /* @__PURE__ */ n(e, {
|
|
6
|
+
...r,
|
|
7
|
+
ref: i,
|
|
8
|
+
kind: "line",
|
|
9
|
+
includeZero: t,
|
|
10
|
+
stacked: !1
|
|
11
|
+
}));
|
|
12
|
+
r.displayName = "LineChart";
|
|
13
|
+
var i = r;
|
|
14
|
+
export { i as LineChart };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LineChart } from "./LineChart.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const PieChart: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLElement>, "children"> & {
|
|
2
|
+
label: string;
|
|
3
|
+
hideLabel?: boolean;
|
|
4
|
+
height?: number;
|
|
5
|
+
formatValue?: (value: number) => string;
|
|
6
|
+
showTable?: boolean;
|
|
7
|
+
categoryLabel?: string;
|
|
8
|
+
patterns?: boolean;
|
|
9
|
+
emptyMessage?: import("react").ReactNode;
|
|
10
|
+
keyboardHint?: string;
|
|
11
|
+
} & {
|
|
12
|
+
data: readonly import("../../index.js").ChartSlice[];
|
|
13
|
+
valueLabel?: string;
|
|
14
|
+
shareLabel?: string;
|
|
15
|
+
formatShare?: (share: number) => string;
|
|
16
|
+
showLegend?: boolean;
|
|
17
|
+
} & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { RadialChart as e } from "../Chart/RadialChart.js";
|
|
3
|
+
import { forwardRef as t } from "react";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
// src/components/PieChart/PieChart.tsx
|
|
6
|
+
var r = t((t, r) => /* @__PURE__ */ n(e, {
|
|
7
|
+
...t,
|
|
8
|
+
ref: r,
|
|
9
|
+
innerRatio: 0
|
|
10
|
+
}));
|
|
11
|
+
r.displayName = "PieChart";
|
|
12
|
+
export { r as PieChart };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PieChart } from "./PieChart.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const Sparkline: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLSpanElement>, "children" | "color"> & {
|
|
2
|
+
data: readonly number[];
|
|
3
|
+
label: string;
|
|
4
|
+
color?: import("../../index.js").ChartColor;
|
|
5
|
+
area?: boolean;
|
|
6
|
+
height?: number;
|
|
7
|
+
} & import("react").RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { linePath as e, seriesColor as t, splitAtGaps as n, toNumber as r } from "../Chart/math.js";
|
|
2
|
+
import i from "./index.module.js";
|
|
3
|
+
import { forwardRef as a } from "react";
|
|
4
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
|
+
// src/components/Sparkline/Sparkline.tsx
|
|
6
|
+
var c = 100, l = a(({ data: a, label: l, color: u = 1, area: d = !1, height: f = 32, className: p, style: m, ...h }, g) => {
|
|
7
|
+
let _ = a.map(r), v = _.filter((e) => e !== null), y = Math.min(...v), b = Math.max(...v) - y, x = _.map((e, t) => e === null ? null : {
|
|
8
|
+
x: _.length === 1 ? c / 2 : t * c / (_.length - 1),
|
|
9
|
+
y: b === 0 ? f / 2 : f - 4 - (e - y) / b * (f - 8)
|
|
10
|
+
}), S = n(x), C = S[S.length - 1]?.[S[S.length - 1].length - 1];
|
|
11
|
+
return /* @__PURE__ */ o("span", {
|
|
12
|
+
...h,
|
|
13
|
+
ref: g,
|
|
14
|
+
role: "img",
|
|
15
|
+
"aria-label": l,
|
|
16
|
+
className: [i.sparkline, p].filter(Boolean).join(" "),
|
|
17
|
+
style: {
|
|
18
|
+
height: f,
|
|
19
|
+
color: t(u),
|
|
20
|
+
...m
|
|
21
|
+
},
|
|
22
|
+
children: /* @__PURE__ */ s("svg", {
|
|
23
|
+
className: i.svg,
|
|
24
|
+
viewBox: `0 0 ${c} ${f}`,
|
|
25
|
+
preserveAspectRatio: "none",
|
|
26
|
+
"aria-hidden": "true",
|
|
27
|
+
focusable: "false",
|
|
28
|
+
children: [
|
|
29
|
+
d && S.map((t, n) => /* @__PURE__ */ o("path", {
|
|
30
|
+
className: i.area,
|
|
31
|
+
d: `${e([
|
|
32
|
+
...t,
|
|
33
|
+
{
|
|
34
|
+
x: t[t.length - 1].x,
|
|
35
|
+
y: f
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
x: t[0].x,
|
|
39
|
+
y: f
|
|
40
|
+
}
|
|
41
|
+
])}Z`
|
|
42
|
+
}, n)),
|
|
43
|
+
S.map((t, n) => /* @__PURE__ */ o("path", {
|
|
44
|
+
className: i.line,
|
|
45
|
+
d: e(t)
|
|
46
|
+
}, n)),
|
|
47
|
+
C && /* @__PURE__ */ o("path", {
|
|
48
|
+
className: i.end,
|
|
49
|
+
d: `M${C.x},${C.y}h0`
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
l.displayName = "Sparkline";
|
|
56
|
+
export { l as Sparkline };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Sparkline } from "./Sparkline.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/components/Sparkline/index.module.scss
|
|
2
|
+
var e = "matrix-sparkline-sparkline", t = "matrix-sparkline-svg", n = "matrix-sparkline-line", r = "matrix-sparkline-end", i = "matrix-sparkline-area", a = {
|
|
3
|
+
sparkline: e,
|
|
4
|
+
svg: t,
|
|
5
|
+
line: n,
|
|
6
|
+
end: r,
|
|
7
|
+
area: i
|
|
8
|
+
};
|
|
9
|
+
export { i as area, a as default, r as end, n as line, e as sparkline, t as svg };
|
|
@@ -1,34 +1,145 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
import { Button as e } from "../Button/Button.js";
|
|
2
|
+
import { Checkbox as t } from "../Checkbox/Checkbox.js";
|
|
3
|
+
import { DropdownMenu as n } from "../DropdownMenu/DropdownMenu.js";
|
|
4
|
+
import { VisuallyHidden as r } from "../VisuallyHidden/VisuallyHidden.js";
|
|
5
|
+
import { TableSelectAll as i } from "./TableSelectAll.js";
|
|
6
|
+
import a from "./index.module.js";
|
|
7
|
+
import { ArrowDown as o, ArrowUp as s, ChevronsUpDown as c, Ellipsis as l } from "lucide-react";
|
|
8
|
+
import { forwardRef as u, useId as d } from "react";
|
|
9
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
10
|
+
// src/components/Table/Table.tsx
|
|
11
|
+
var h = (e, t) => [
|
|
12
|
+
t,
|
|
13
|
+
e.noWrap && a.noWrap,
|
|
14
|
+
e.hideOnMobile && a.hideOnMobile
|
|
15
|
+
].filter(Boolean).join(" "), g = (e, t) => ({
|
|
16
|
+
key: e,
|
|
17
|
+
direction: t?.key === e && t.direction === "ascending" ? "descending" : "ascending"
|
|
18
|
+
}), _ = u(({ caption: u, columns: _, rows: v, getRowKey: y, emptyMessage: b = "No rows to show", sort: x, onSortChange: S, selectedKeys: C = [], onSelectionChange: w, selectAllLabel: T = "Select all rows", getSelectLabel: E, rowActions: D, actionsLabel: O = "Actions", className: k, ...A }, j) => {
|
|
19
|
+
let M = d(), N = w !== void 0, P = _.findIndex((e) => e.rowHeader), F = (e) => `${M}-row-${e}`, I = `${M}-actions`, L = v.map((e, t) => y(e, t)), R = new Set(C), z = L.filter((e) => R.has(e)).length, B = _.length + +!!N + +!!D, V = (e, t) => w?.(t ? [...C, e] : C.filter((t) => t !== e)), H = (e) => w?.(e ? [...C, ...L.filter((e) => !R.has(e))] : C.filter((e) => !L.includes(e)));
|
|
20
|
+
return /* @__PURE__ */ m("table", {
|
|
21
|
+
...A,
|
|
22
|
+
ref: j,
|
|
23
|
+
className: [a.table, k].filter(Boolean).join(" "),
|
|
24
|
+
children: [
|
|
25
|
+
u && /* @__PURE__ */ p("caption", {
|
|
26
|
+
className: a.caption,
|
|
27
|
+
children: u
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ p("thead", { children: /* @__PURE__ */ m("tr", { children: [
|
|
30
|
+
N && /* @__PURE__ */ p("th", {
|
|
31
|
+
scope: "col",
|
|
32
|
+
className: `${a.header} ${a.selectCell}`,
|
|
33
|
+
children: /* @__PURE__ */ p(i, {
|
|
34
|
+
label: T,
|
|
35
|
+
checked: v.length > 0 && z === v.length,
|
|
36
|
+
indeterminate: z > 0 && z < v.length,
|
|
37
|
+
disabled: v.length === 0,
|
|
38
|
+
onChange: H
|
|
39
|
+
})
|
|
40
|
+
}),
|
|
41
|
+
_.map((e) => {
|
|
42
|
+
let t = x?.key === e.key ? x.direction : void 0, n = t === "ascending" ? s : t === "descending" ? o : c;
|
|
43
|
+
return /* @__PURE__ */ p("th", {
|
|
44
|
+
scope: "col",
|
|
45
|
+
"aria-sort": e.sortable ? t ?? "none" : void 0,
|
|
46
|
+
className: h(e, a.header),
|
|
47
|
+
children: e.sortable && S ? /* @__PURE__ */ m("button", {
|
|
48
|
+
type: "button",
|
|
49
|
+
className: a.sortButton,
|
|
50
|
+
onClick: () => S(g(e.key, x)),
|
|
51
|
+
children: [e.header, /* @__PURE__ */ p(n, {
|
|
52
|
+
size: 14,
|
|
53
|
+
strokeWidth: 2,
|
|
54
|
+
"aria-hidden": "true",
|
|
55
|
+
className: t ? a.sortIcon : a.sortIconIdle
|
|
56
|
+
})]
|
|
57
|
+
}) : e.header
|
|
58
|
+
}, e.key);
|
|
59
|
+
}),
|
|
60
|
+
D && /* @__PURE__ */ p("th", {
|
|
61
|
+
scope: "col",
|
|
62
|
+
className: `${a.header} ${a.actionsCell}`,
|
|
63
|
+
children: /* @__PURE__ */ p(r, {
|
|
64
|
+
id: I,
|
|
65
|
+
children: O
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
] }) }),
|
|
69
|
+
/* @__PURE__ */ p("tbody", { children: v.length === 0 ? /* @__PURE__ */ p("tr", { children: /* @__PURE__ */ p("td", {
|
|
70
|
+
colSpan: B,
|
|
71
|
+
className: a.cell,
|
|
72
|
+
children: b
|
|
73
|
+
}) }) : v.map((r, i) => {
|
|
74
|
+
let o = L[i], s = R.has(o), c = P === -1 ? void 0 : F(i), u = D?.(r, i) ?? [];
|
|
75
|
+
return /* @__PURE__ */ m("tr", {
|
|
76
|
+
className: s ? a.selected : void 0,
|
|
77
|
+
children: [
|
|
78
|
+
N && /* @__PURE__ */ p("td", {
|
|
79
|
+
className: `${a.cell} ${a.selectCell}`,
|
|
80
|
+
children: /* @__PURE__ */ p(t, {
|
|
81
|
+
checked: s,
|
|
82
|
+
"aria-label": E ? E(r, i) : c ? void 0 : `Select row ${i + 1}`,
|
|
83
|
+
"aria-labelledby": E ? void 0 : c,
|
|
84
|
+
onChange: (e) => V(o, e.target.checked)
|
|
85
|
+
})
|
|
86
|
+
}),
|
|
87
|
+
_.map((e, t) => e.rowHeader ? /* @__PURE__ */ p("th", {
|
|
88
|
+
id: t === P ? F(i) : void 0,
|
|
89
|
+
scope: "row",
|
|
90
|
+
className: h(e, a.rowHeader),
|
|
91
|
+
children: e.cell(r)
|
|
92
|
+
}, e.key) : /* @__PURE__ */ p("td", {
|
|
93
|
+
className: h(e, a.cell),
|
|
94
|
+
children: e.cell(r)
|
|
95
|
+
}, e.key)),
|
|
96
|
+
D && /* @__PURE__ */ p("td", {
|
|
97
|
+
className: `${a.cell} ${a.actionsCell}`,
|
|
98
|
+
children: u.length > 0 && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("span", {
|
|
99
|
+
className: a.actionsInline,
|
|
100
|
+
children: u.map((t, n) => {
|
|
101
|
+
let r = `${M}-action-${i}-${n}`;
|
|
102
|
+
return /* @__PURE__ */ p(e, {
|
|
103
|
+
id: r,
|
|
104
|
+
variant: "ghost",
|
|
105
|
+
size: "small",
|
|
106
|
+
disabled: t.disabled,
|
|
107
|
+
"aria-labelledby": c ? `${r} ${c}` : void 0,
|
|
108
|
+
className: t.danger ? a.danger : void 0,
|
|
109
|
+
onClick: t.onSelect,
|
|
110
|
+
children: t.label
|
|
111
|
+
}, n);
|
|
112
|
+
})
|
|
113
|
+
}), /* @__PURE__ */ p("span", {
|
|
114
|
+
className: a.actionsMenu,
|
|
115
|
+
children: /* @__PURE__ */ p(n, {
|
|
116
|
+
align: "end",
|
|
117
|
+
items: u.map((e) => ({
|
|
118
|
+
label: e.label,
|
|
119
|
+
onSelect: e.onSelect,
|
|
120
|
+
danger: e.danger,
|
|
121
|
+
disabled: e.disabled
|
|
122
|
+
})),
|
|
123
|
+
children: /* @__PURE__ */ p(e, {
|
|
124
|
+
variant: "ghost",
|
|
125
|
+
size: "small",
|
|
126
|
+
iconOnly: !0,
|
|
127
|
+
"aria-labelledby": c ? `${I} ${c}` : I,
|
|
128
|
+
children: /* @__PURE__ */ p(l, {
|
|
129
|
+
size: 16,
|
|
130
|
+
strokeWidth: 2,
|
|
131
|
+
"aria-hidden": "true"
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
})] })
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
}, o);
|
|
139
|
+
}) })
|
|
140
|
+
]
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
_.displayName = "Table";
|
|
144
|
+
var v = _;
|
|
145
|
+
export { v as Table };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type TableSelectAllProps = {
|
|
2
|
+
label: string;
|
|
3
|
+
checked: boolean;
|
|
4
|
+
indeterminate: boolean;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
onChange: (checked: boolean) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare function TableSelectAll({ label, checked, indeterminate, disabled, onChange, }: TableSelectAllProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|