@ztwoint/z-ui 0.1.115 → 0.1.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/components/chart/chart.d.ts +4 -0
  2. package/dist/components/chart/chart.js +25 -0
  3. package/dist/components/chart/index.d.ts +2 -0
  4. package/dist/components/chart-card/builders/bar-chart-builder.d.ts +3 -0
  5. package/dist/components/chart-card/builders/bar-chart-builder.js +43 -0
  6. package/dist/components/chart-card/builders/chart-builder-factory.d.ts +5 -0
  7. package/dist/components/chart-card/builders/chart-builder-factory.js +23 -0
  8. package/dist/components/chart-card/builders/line-chart-builder.d.ts +3 -0
  9. package/dist/components/chart-card/builders/line-chart-builder.js +53 -0
  10. package/dist/components/chart-card/builders/pie-chart-builder.d.ts +3 -0
  11. package/dist/components/chart-card/builders/pie-chart-builder.js +71 -0
  12. package/dist/components/chart-card/chart-card-states.d.ts +10 -0
  13. package/dist/components/chart-card/chart-card-states.js +93 -0
  14. package/dist/components/chart-card/chart-card.config.types.d.ts +99 -0
  15. package/dist/components/chart-card/chart-card.d.ts +2 -0
  16. package/dist/components/chart-card/chart-card.js +72 -0
  17. package/dist/components/chart-card/chart-card.types.d.ts +12 -0
  18. package/dist/components/chart-card/config/colors.d.ts +29 -0
  19. package/dist/components/chart-card/config/colors.js +49 -0
  20. package/dist/components/chart-card/config/defaults.d.ts +164 -0
  21. package/dist/components/chart-card/config/defaults.js +156 -0
  22. package/dist/components/chart-card/index.d.ts +10 -0
  23. package/dist/components/chart-card/validators/config-validator.d.ts +7 -0
  24. package/dist/components/chart-card/validators/config-validator.js +40 -0
  25. package/dist/components/table/components/cell/avatar-cell.js +5 -2
  26. package/dist/components/table/table-provider.js +3 -0
  27. package/dist/components/table-card/table-card.js +11 -8
  28. package/dist/css/styles/tailwind.css +1 -1
  29. package/dist/index.d.ts +2 -0
  30. package/dist/index.js +153 -130
  31. package/dist/types/components/chart/chart.d.ts +4 -0
  32. package/dist/types/components/chart/index.d.ts +2 -0
  33. package/dist/types/components/chart-card/builders/bar-chart-builder.d.ts +3 -0
  34. package/dist/types/components/chart-card/builders/chart-builder-factory.d.ts +5 -0
  35. package/dist/types/components/chart-card/builders/line-chart-builder.d.ts +3 -0
  36. package/dist/types/components/chart-card/builders/pie-chart-builder.d.ts +3 -0
  37. package/dist/types/components/chart-card/chart-card-states.d.ts +10 -0
  38. package/dist/types/components/chart-card/chart-card.config.types.d.ts +99 -0
  39. package/dist/types/components/chart-card/chart-card.d.ts +2 -0
  40. package/dist/types/components/chart-card/chart-card.types.d.ts +12 -0
  41. package/dist/types/components/chart-card/config/colors.d.ts +29 -0
  42. package/dist/types/components/chart-card/config/defaults.d.ts +164 -0
  43. package/dist/types/components/chart-card/index.d.ts +10 -0
  44. package/dist/types/components/chart-card/validators/config-validator.d.ts +7 -0
  45. package/dist/types/index.d.ts +2 -0
  46. package/package.json +3 -1
@@ -0,0 +1,4 @@
1
+ import { EChartsReactProps } from 'echarts-for-react';
2
+ import * as React from 'react';
3
+ export type ChartProps = EChartsReactProps;
4
+ export declare const Chart: React.ForwardRefExoticComponent<EChartsReactProps & React.RefAttributes<any>>;
@@ -0,0 +1,25 @@
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import * as t from "react";
3
+ import n from "echarts-for-react";
4
+ const p = t.forwardRef(
5
+ ({ notMerge: e = !0, lazyUpdate: a = !0, opts: r, ...o }, s) => {
6
+ const m = t.useMemo(
7
+ () => ({ renderer: "canvas", ...r ?? {} }),
8
+ [r]
9
+ );
10
+ return /* @__PURE__ */ f(
11
+ n,
12
+ {
13
+ ref: s,
14
+ ...o,
15
+ notMerge: e,
16
+ lazyUpdate: a,
17
+ opts: m
18
+ }
19
+ );
20
+ }
21
+ );
22
+ p.displayName = "Chart";
23
+ export {
24
+ p as Chart
25
+ };
@@ -0,0 +1,2 @@
1
+ export { Chart } from './chart';
2
+ export type { ChartProps } from './chart';
@@ -0,0 +1,3 @@
1
+ import { EChartsOption } from 'echarts';
2
+ import { BarChartConfig, ChartData } from '../chart-card.config.types';
3
+ export declare function buildBarChartOptions(config: BarChartConfig, data: ChartData): EChartsOption;
@@ -0,0 +1,43 @@
1
+ import { buildYAxisConfig as A, buildXAxisConfig as g, buildGridConfig as k, buildLegendConfig as v, buildTooltipConfig as T, buildTitleConfig as B } from "../config/defaults.js";
2
+ import { getThemePalette as L } from "../config/colors.js";
3
+ function D(e, t) {
4
+ var n, o, i, p, l, u, b, c, h, x, S, y;
5
+ const m = L("bar", e.theme), r = t.series.map((C) => C.name), s = !!e.name, a = r.length > 1, d = ((o = (n = e.options) == null ? void 0 : n.legend) == null ? void 0 : o.position) ?? "top";
6
+ return {
7
+ color: m,
8
+ title: s ? B(e.name, (i = e.options) == null ? void 0 : i.title) : void 0,
9
+ tooltip: T((p = e.options) == null ? void 0 : p.tooltip),
10
+ legend: a ? v(r, s, (l = e.options) == null ? void 0 : l.legend) : void 0,
11
+ grid: k(s, a, d, (u = e.options) == null ? void 0 : u.grid),
12
+ xAxis: g(t.labels, !0, (b = e.options) == null ? void 0 : b.xAxis),
13
+ yAxis: A((c = e.options) == null ? void 0 : c.yAxis),
14
+ series: P(e, t),
15
+ animation: ((x = (h = e.options) == null ? void 0 : h.animation) == null ? void 0 : x.enabled) ?? !0,
16
+ animationDuration: ((y = (S = e.options) == null ? void 0 : S.animation) == null ? void 0 : y.duration) ?? 1e3
17
+ };
18
+ }
19
+ function P(e, t) {
20
+ var d, n;
21
+ const r = e.theme === "stacked" && t.series.length > 1 ? "total" : void 0, s = ((d = e.options) == null ? void 0 : d.seriesStyles) ?? {}, a = ((n = e.options) == null ? void 0 : n.defaultSeriesStyle) ?? {};
22
+ return t.series.map((o) => {
23
+ const i = {
24
+ ...a,
25
+ ...s[o.name] ?? {}
26
+ }, p = i.barWidth ?? 40, l = {
27
+ name: o.name,
28
+ type: "bar",
29
+ stack: r,
30
+ emphasis: {
31
+ focus: "series"
32
+ },
33
+ barMaxWidth: p,
34
+ data: o.values
35
+ };
36
+ return i.color && (l.itemStyle = {
37
+ color: i.color
38
+ }), l;
39
+ });
40
+ }
41
+ export {
42
+ D as buildBarChartOptions
43
+ };
@@ -0,0 +1,5 @@
1
+ import { EChartsOption } from 'echarts';
2
+ import { ChartConfig, ChartData, ChartType } from '../chart-card.config.types';
3
+ export declare function buildChartOptions(config: ChartConfig, data: ChartData): EChartsOption;
4
+ export declare function isChartTypeSupported(type: string): type is ChartType;
5
+ export declare const registeredChartTypes: readonly ChartType[];
@@ -0,0 +1,23 @@
1
+ import { buildBarChartOptions as e } from "./bar-chart-builder.js";
2
+ import { buildLineChartOptions as o } from "./line-chart-builder.js";
3
+ import { buildPieChartOptions as p } from "./pie-chart-builder.js";
4
+ const n = {
5
+ line: o,
6
+ bar: e,
7
+ pie: p
8
+ };
9
+ function b(r, i) {
10
+ const t = n[r.type];
11
+ if (!t)
12
+ throw new Error(`Unsupported chart type: ${r.type}`);
13
+ return t(r, i);
14
+ }
15
+ function d(r) {
16
+ return r === "line" || r === "bar" || r === "pie";
17
+ }
18
+ const h = ["line", "bar", "pie"];
19
+ export {
20
+ b as buildChartOptions,
21
+ d as isChartTypeSupported,
22
+ h as registeredChartTypes
23
+ };
@@ -0,0 +1,3 @@
1
+ import { EChartsOption } from 'echarts';
2
+ import { ChartData, LineChartConfig } from '../chart-card.config.types';
3
+ export declare function buildLineChartOptions(config: LineChartConfig, data: ChartData): EChartsOption;
@@ -0,0 +1,53 @@
1
+ import { buildYAxisConfig as g, buildXAxisConfig as f, buildGridConfig as T, buildLegendConfig as v, buildTooltipConfig as w, buildTitleConfig as L } from "../config/defaults.js";
2
+ import { getThemePalette as z } from "../config/colors.js";
3
+ function B(e, i) {
4
+ var o, p, m, d, u, y, t, c, S, b, x, C;
5
+ const h = z("line", e.theme), l = i.series.map((A) => A.name), s = !!e.name, n = l.length > 1, r = ((p = (o = e.options) == null ? void 0 : o.legend) == null ? void 0 : p.position) ?? "top";
6
+ return {
7
+ color: h,
8
+ title: s ? L(e.name, (m = e.options) == null ? void 0 : m.title) : void 0,
9
+ tooltip: w((d = e.options) == null ? void 0 : d.tooltip),
10
+ legend: n ? v(l, s, (u = e.options) == null ? void 0 : u.legend) : void 0,
11
+ grid: T(s, n, r, (y = e.options) == null ? void 0 : y.grid),
12
+ xAxis: f(i.labels, !1, (t = e.options) == null ? void 0 : t.xAxis),
13
+ yAxis: g((c = e.options) == null ? void 0 : c.yAxis),
14
+ series: O(e, i),
15
+ animation: ((b = (S = e.options) == null ? void 0 : S.animation) == null ? void 0 : b.enabled) ?? !0,
16
+ animationDuration: ((C = (x = e.options) == null ? void 0 : x.animation) == null ? void 0 : C.duration) ?? 1e3
17
+ };
18
+ }
19
+ function O(e, i) {
20
+ var n, r;
21
+ const h = e.theme === "smooth", l = ((n = e.options) == null ? void 0 : n.seriesStyles) ?? {}, s = ((r = e.options) == null ? void 0 : r.defaultSeriesStyle) ?? {};
22
+ return i.series.map((a) => {
23
+ const o = {
24
+ ...s,
25
+ ...l[a.name] ?? {}
26
+ }, p = o.smooth ?? h, m = o.lineWidth ?? 2, d = o.pointSize ?? (i.labels.length <= 12 ? 4 : 0), u = o.areaStyle ?? !1, y = o.opacity ?? 0.15, t = {
27
+ name: a.name,
28
+ type: "line",
29
+ smooth: p,
30
+ symbol: "circle",
31
+ symbolSize: d,
32
+ showSymbol: i.labels.length <= 12,
33
+ emphasis: {
34
+ focus: "series"
35
+ },
36
+ lineStyle: {
37
+ width: m
38
+ },
39
+ data: a.values
40
+ };
41
+ return o.color && (t.itemStyle = {
42
+ color: o.color
43
+ }, t.lineStyle = {
44
+ ...t.lineStyle,
45
+ color: o.color
46
+ }), u && (t.areaStyle = {
47
+ opacity: y
48
+ }), t;
49
+ });
50
+ }
51
+ export {
52
+ B as buildLineChartOptions
53
+ };
@@ -0,0 +1,3 @@
1
+ import { EChartsOption } from 'echarts';
2
+ import { ChartData, PieChartConfig } from '../chart-card.config.types';
3
+ export declare function buildPieChartOptions(config: PieChartConfig, data: ChartData): EChartsOption;
@@ -0,0 +1,71 @@
1
+ import { buildLegendConfig as O, buildTooltipConfig as P, buildTitleConfig as T } from "../config/defaults.js";
2
+ import { getThemePalette as D } from "../config/colors.js";
3
+ function j(e, o) {
4
+ var r, u, d, a, m, p, c;
5
+ const b = D("pie", e.theme), n = o.series.map((s) => s.name), l = !!e.name, t = n.length > 1;
6
+ return {
7
+ color: b,
8
+ title: l ? T(e.name, (r = e.options) == null ? void 0 : r.title) : void 0,
9
+ tooltip: P({ ...(u = e.options) == null ? void 0 : u.tooltip, trigger: "item" }),
10
+ legend: t ? O(n, l, (d = e.options) == null ? void 0 : d.legend) : void 0,
11
+ series: v(e, o),
12
+ animation: ((m = (a = e.options) == null ? void 0 : a.animation) == null ? void 0 : m.enabled) ?? !0,
13
+ animationDuration: ((c = (p = e.options) == null ? void 0 : p.animation) == null ? void 0 : c.duration) ?? 1e3
14
+ };
15
+ }
16
+ function v(e, o) {
17
+ var C, w, L, g, R;
18
+ const b = e.theme === "donut", n = ((C = e.options) == null ? void 0 : C.seriesStyles) ?? {}, l = ((w = e.options) == null ? void 0 : w.defaultSeriesStyle) ?? {}, t = ((L = e.options) == null ? void 0 : L.pie) ?? {}, f = ((g = o.series[0]) == null ? void 0 : g.values.map((h, i) => ({
19
+ name: o.labels[i],
20
+ value: h
21
+ }))) ?? [], r = b ? ["40%", "70%"] : ["0%", "70%"], u = t.radius ?? r, d = t.center ?? ["50%", "50%"], a = t.labelPosition ?? "outside", m = t.labelRotate ?? !1, p = t.showLabel ?? !0, c = t.showLabelLine ?? !0, s = {
22
+ name: ((R = o.series[0]) == null ? void 0 : R.name) ?? "Data",
23
+ type: "pie",
24
+ radius: u,
25
+ center: d,
26
+ data: f,
27
+ emphasis: {
28
+ focus: "self",
29
+ itemStyle: {
30
+ shadowBlur: 10,
31
+ shadowOffsetX: 0,
32
+ shadowColor: "rgba(0, 0, 0, 0.5)"
33
+ }
34
+ },
35
+ label: {
36
+ show: p,
37
+ position: a,
38
+ rotate: m,
39
+ formatter: "{b}: {c} ({d}%)",
40
+ fontSize: 12,
41
+ fontFamily: "Inter Variable, sans-serif"
42
+ },
43
+ labelLine: {
44
+ show: c && a === "outside",
45
+ length: 10,
46
+ length2: 5
47
+ },
48
+ itemStyle: {
49
+ borderColor: "#fff",
50
+ borderWidth: 2
51
+ }
52
+ };
53
+ if (Object.keys(n).length > 0) {
54
+ const h = f.map((i) => ({
55
+ ...l,
56
+ ...n[i.name] ?? {}
57
+ }).color).filter(Boolean);
58
+ if (h.length > 0) {
59
+ const i = D("pie", e.theme);
60
+ s.itemStyle = {
61
+ ...s.itemStyle,
62
+ color: (y) => h[y.dataIndex] || i[y.dataIndex % i.length]
63
+ };
64
+ }
65
+ }
66
+ const S = l.pieRadius;
67
+ return S && (s.radius = S), [s];
68
+ }
69
+ export {
70
+ j as buildPieChartOptions
71
+ };
@@ -0,0 +1,10 @@
1
+ export declare function LoadingState({ height }: {
2
+ height: number;
3
+ }): import("react/jsx-runtime").JSX.Element;
4
+ export declare function EmptyState({ height }: {
5
+ height: number;
6
+ }): import("react/jsx-runtime").JSX.Element;
7
+ export declare function ErrorState({ height, message }: {
8
+ height: number;
9
+ message: string;
10
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,93 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ function n({ height: r }) {
3
+ return /* @__PURE__ */ e(
4
+ "div",
5
+ {
6
+ className: "flex items-center justify-center bg-background-neutral-light animate-pulse",
7
+ style: { height: r },
8
+ role: "status",
9
+ "aria-label": "Loading chart",
10
+ children: /* @__PURE__ */ t("div", { className: "flex flex-col items-center gap-2", children: [
11
+ /* @__PURE__ */ e("div", { className: "size-8 border-4 border-surface-accent-default border-t-transparent rounded-full animate-spin" }),
12
+ /* @__PURE__ */ e("p", { className: "text-sm text-neutral-secondary font-medium", children: "Loading chart..." })
13
+ ] })
14
+ }
15
+ );
16
+ }
17
+ function i({ height: r }) {
18
+ return /* @__PURE__ */ e(
19
+ "div",
20
+ {
21
+ className: "flex items-center justify-center bg-background-neutral-light border border-neutral-200 rounded-lg",
22
+ style: { height: r },
23
+ role: "status",
24
+ "aria-label": "No chart data available",
25
+ children: /* @__PURE__ */ t("div", { className: "flex flex-col items-center gap-2 text-center px-4", children: [
26
+ /* @__PURE__ */ e(
27
+ "svg",
28
+ {
29
+ className: "size-12 text-neutral-300",
30
+ fill: "none",
31
+ stroke: "currentColor",
32
+ viewBox: "0 0 24 24",
33
+ "aria-hidden": "true",
34
+ children: /* @__PURE__ */ e(
35
+ "path",
36
+ {
37
+ strokeLinecap: "round",
38
+ strokeLinejoin: "round",
39
+ strokeWidth: 1.5,
40
+ d: "M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"
41
+ }
42
+ )
43
+ }
44
+ ),
45
+ /* @__PURE__ */ t("div", { children: [
46
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium text-neutral-primary", children: "No data available" }),
47
+ /* @__PURE__ */ e("p", { className: "text-xs text-neutral-secondary mt-1", children: "Chart will display when data is provided" })
48
+ ] })
49
+ ] })
50
+ }
51
+ );
52
+ }
53
+ function s({ height: r, message: a }) {
54
+ return /* @__PURE__ */ e(
55
+ "div",
56
+ {
57
+ className: "flex items-center justify-center bg-surface-danger-light border border-red-200 rounded-lg",
58
+ style: { height: r },
59
+ role: "alert",
60
+ "aria-label": `Chart error: ${a}`,
61
+ children: /* @__PURE__ */ t("div", { className: "flex flex-col items-center gap-2 text-center px-4", children: [
62
+ /* @__PURE__ */ e(
63
+ "svg",
64
+ {
65
+ className: "size-12 text-red-500",
66
+ fill: "none",
67
+ stroke: "currentColor",
68
+ viewBox: "0 0 24 24",
69
+ "aria-hidden": "true",
70
+ children: /* @__PURE__ */ e(
71
+ "path",
72
+ {
73
+ strokeLinecap: "round",
74
+ strokeLinejoin: "round",
75
+ strokeWidth: 1.5,
76
+ d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
77
+ }
78
+ )
79
+ }
80
+ ),
81
+ /* @__PURE__ */ t("div", { children: [
82
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium text-red-950", children: "Chart Error" }),
83
+ /* @__PURE__ */ e("p", { className: "text-xs text-red-600 mt-1", children: a })
84
+ ] })
85
+ ] })
86
+ }
87
+ );
88
+ }
89
+ export {
90
+ i as EmptyState,
91
+ s as ErrorState,
92
+ n as LoadingState
93
+ };
@@ -0,0 +1,99 @@
1
+ export type ChartType = 'line' | 'bar' | 'pie';
2
+ export type LineChartTheme = 'basic' | 'smooth';
3
+ export type BarChartTheme = 'basic' | 'stacked';
4
+ export type PieChartTheme = 'basic' | 'donut';
5
+ export type ChartTheme = LineChartTheme | BarChartTheme | PieChartTheme;
6
+ export interface SeriesStyleConfig {
7
+ color?: string;
8
+ lineWidth?: number;
9
+ pointSize?: number;
10
+ smooth?: boolean;
11
+ barWidth?: number;
12
+ areaStyle?: boolean;
13
+ opacity?: number;
14
+ pieRadius?: [string | number, string | number];
15
+ pieLabelPosition?: 'inside' | 'outside';
16
+ pieLabelRotate?: boolean;
17
+ }
18
+ export interface ChartOptions {
19
+ seriesStyles?: Record<string, SeriesStyleConfig>;
20
+ defaultSeriesStyle?: SeriesStyleConfig;
21
+ title?: {
22
+ show?: boolean;
23
+ position?: 'left' | 'center' | 'right';
24
+ fontSize?: number;
25
+ color?: string;
26
+ };
27
+ legend?: {
28
+ show?: boolean;
29
+ position?: 'top' | 'bottom' | 'left' | 'right';
30
+ align?: 'left' | 'center' | 'right';
31
+ orient?: 'horizontal' | 'vertical';
32
+ };
33
+ tooltip?: {
34
+ show?: boolean;
35
+ trigger?: 'axis' | 'item';
36
+ };
37
+ xAxis?: {
38
+ show?: boolean;
39
+ name?: string;
40
+ nameLocation?: 'start' | 'middle' | 'end';
41
+ gridLines?: boolean;
42
+ labelRotate?: number;
43
+ };
44
+ yAxis?: {
45
+ show?: boolean;
46
+ name?: string;
47
+ nameLocation?: 'start' | 'middle' | 'end';
48
+ min?: number | 'auto';
49
+ max?: number | 'auto';
50
+ gridLines?: boolean;
51
+ };
52
+ grid?: {
53
+ top?: number | string;
54
+ bottom?: number | string;
55
+ left?: number | string;
56
+ right?: number | string;
57
+ };
58
+ animation?: {
59
+ enabled?: boolean;
60
+ duration?: number;
61
+ };
62
+ pie?: {
63
+ center?: [string | number, string | number];
64
+ radius?: [string | number, string | number];
65
+ labelPosition?: 'inside' | 'outside';
66
+ labelRotate?: boolean;
67
+ showLabel?: boolean;
68
+ showLabelLine?: boolean;
69
+ };
70
+ }
71
+ interface BaseChartConfig {
72
+ name: string;
73
+ height?: number;
74
+ width?: string | number;
75
+ ariaLabel?: string;
76
+ options?: ChartOptions;
77
+ }
78
+ export interface LineChartConfig extends BaseChartConfig {
79
+ type: 'line';
80
+ theme: LineChartTheme;
81
+ }
82
+ export interface BarChartConfig extends BaseChartConfig {
83
+ type: 'bar';
84
+ theme: BarChartTheme;
85
+ }
86
+ export interface PieChartConfig extends BaseChartConfig {
87
+ type: 'pie';
88
+ theme: PieChartTheme;
89
+ }
90
+ export type ChartConfig = LineChartConfig | BarChartConfig | PieChartConfig;
91
+ export interface ChartSeries {
92
+ name: string;
93
+ values: number[];
94
+ }
95
+ export interface ChartData {
96
+ labels: string[];
97
+ series: ChartSeries[];
98
+ }
99
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ChartCardProps } from './chart-card.types';
2
+ export declare function ChartCard({ config, data, loading, error, className, style, chartProps, }: ChartCardProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,72 @@
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import * as N from "react";
3
+ import { cn as v } from "../../lib/utils.js";
4
+ import { validateChartConfig as p, validateChartData as w } from "./validators/config-validator.js";
5
+ import { buildChartOptions as S } from "./builders/chart-builder-factory.js";
6
+ import { Chart as E } from "../chart/chart.js";
7
+ import { LoadingState as O, ErrorState as l, EmptyState as R } from "./chart-card-states.js";
8
+ function j({
9
+ config: t,
10
+ data: n,
11
+ loading: u = !1,
12
+ error: m,
13
+ className: f,
14
+ style: g,
15
+ chartProps: e
16
+ }) {
17
+ const r = t.height ?? 400, b = N.useMemo(() => {
18
+ if (!e)
19
+ return {};
20
+ const { className: s, style: i, ...C } = e;
21
+ return C;
22
+ }, [e]), c = e == null ? void 0 : e.className, y = e == null ? void 0 : e.style;
23
+ if (u)
24
+ return /* @__PURE__ */ a(O, { height: r });
25
+ if (m)
26
+ return /* @__PURE__ */ a(l, { height: r, message: m });
27
+ const o = p(t);
28
+ if (!o.valid)
29
+ return /* @__PURE__ */ a(l, { height: r, message: o.error || "Invalid configuration" });
30
+ const d = w(n);
31
+ if (!d.valid)
32
+ return /* @__PURE__ */ a(l, { height: r, message: d.error ?? "Invalid data" });
33
+ if (!n.series.some(
34
+ (s) => s.values.some((i) => typeof i == "number" && !Number.isNaN(i) && i !== 0)
35
+ ))
36
+ return /* @__PURE__ */ a(R, { height: r });
37
+ let h;
38
+ try {
39
+ h = S(t, n);
40
+ } catch (s) {
41
+ const i = s instanceof Error ? s.message : "Failed to build chart";
42
+ return /* @__PURE__ */ a(l, { height: r, message: i });
43
+ }
44
+ return /* @__PURE__ */ a(
45
+ "div",
46
+ {
47
+ className: v(
48
+ "w-full rounded-lg bg-background-neutral-default border border-neutral-150 p-4",
49
+ f
50
+ ),
51
+ style: g,
52
+ role: "img",
53
+ "aria-label": t.ariaLabel || `${t.type} chart${t.name ? `: ${t.name}` : ""}`,
54
+ children: /* @__PURE__ */ a(
55
+ E,
56
+ {
57
+ option: h,
58
+ className: c,
59
+ style: {
60
+ height: r,
61
+ width: t.width || "100%",
62
+ ...y
63
+ },
64
+ ...b
65
+ }
66
+ )
67
+ }
68
+ );
69
+ }
70
+ export {
71
+ j as ChartCard
72
+ };
@@ -0,0 +1,12 @@
1
+ import { CSSProperties } from 'react';
2
+ import { EChartsReactProps } from 'echarts-for-react';
3
+ import { ChartConfig, ChartData } from './chart-card.config.types';
4
+ export interface ChartCardProps {
5
+ config: ChartConfig;
6
+ data: ChartData;
7
+ loading?: boolean;
8
+ error?: string;
9
+ className?: string;
10
+ style?: CSSProperties;
11
+ chartProps?: Omit<EChartsReactProps, 'option'>;
12
+ }
@@ -0,0 +1,29 @@
1
+ import { ChartType } from '../chart-card.config.types';
2
+ export declare const COLOR_PALETTES: {
3
+ readonly default: readonly ["#2563eb", "#7c3aed", "#d97706", "#16a34a", "#dc2626", "#0284c7"];
4
+ readonly brand: readonly ["#2563eb", "#3b82f6", "#1d4ed8", "#60a5fa"];
5
+ readonly success: readonly ["#16a34a", "#22c55e", "#15803d", "#4ade80"];
6
+ readonly warning: readonly ["#d97706", "#f59e0b", "#b45309", "#fbbf24"];
7
+ readonly danger: readonly ["#dc2626", "#ef4444", "#b91c1c", "#f87171"];
8
+ readonly purple: readonly ["#7c3aed", "#8b5cf6", "#6d28d9", "#a78bfa"];
9
+ readonly neutral: readonly ["#5d5d5d", "#6d6d6d", "#4f4f4f", "#888888"];
10
+ };
11
+ export declare const CHART_THEME_PALETTES: Record<ChartType, Record<string, ReadonlyArray<string>>>;
12
+ export declare const UI_COLORS: {
13
+ readonly text: {
14
+ readonly primary: "#000000";
15
+ readonly secondary: "#5d5d5d";
16
+ readonly muted: "#888888";
17
+ };
18
+ readonly border: {
19
+ readonly light: "#e7e7e7";
20
+ readonly default: "#d1d1d1";
21
+ readonly medium: "#b0b0b0";
22
+ };
23
+ readonly background: {
24
+ readonly default: "#ffffff";
25
+ readonly light: "#fafafa";
26
+ readonly medium: "#f6f6f6";
27
+ };
28
+ };
29
+ export declare function getThemePalette(type: ChartType, theme: string): string[];
@@ -0,0 +1,49 @@
1
+ const d = {
2
+ default: ["#2563eb", "#7c3aed", "#d97706", "#16a34a", "#dc2626", "#0284c7"],
3
+ brand: ["#2563eb", "#3b82f6", "#1d4ed8", "#60a5fa"],
4
+ success: ["#16a34a", "#22c55e", "#15803d", "#4ade80"],
5
+ warning: ["#d97706", "#f59e0b", "#b45309", "#fbbf24"],
6
+ danger: ["#dc2626", "#ef4444", "#b91c1c", "#f87171"],
7
+ purple: ["#7c3aed", "#8b5cf6", "#6d28d9", "#a78bfa"],
8
+ neutral: ["#5d5d5d", "#6d6d6d", "#4f4f4f", "#888888"]
9
+ }, t = {
10
+ basic: d.default,
11
+ smooth: ["#1d4ed8", "#38bdf8", "#22d3ee", "#6366f1"]
12
+ }, b = {
13
+ basic: d.default,
14
+ stacked: ["#0284c7", "#38bdf8", "#60a5fa", "#93c5fd"]
15
+ }, E = {
16
+ basic: d.default,
17
+ donut: ["#2563eb", "#7c3aed", "#d97706", "#16a34a", "#dc2626", "#0284c7", "#8b5cf6", "#f59e0b"]
18
+ }, n = {
19
+ line: t,
20
+ bar: b,
21
+ pie: E
22
+ }, r = {
23
+ text: {
24
+ primary: "#000000",
25
+ secondary: "#5d5d5d",
26
+ muted: "#888888"
27
+ },
28
+ border: {
29
+ light: "#e7e7e7",
30
+ default: "#d1d1d1",
31
+ medium: "#b0b0b0"
32
+ },
33
+ background: {
34
+ default: "#ffffff",
35
+ light: "#fafafa",
36
+ medium: "#f6f6f6"
37
+ }
38
+ };
39
+ function u(a, f) {
40
+ var e;
41
+ const c = ((e = n[a]) == null ? void 0 : e[f]) ?? d.default;
42
+ return Array.from(c);
43
+ }
44
+ export {
45
+ n as CHART_THEME_PALETTES,
46
+ d as COLOR_PALETTES,
47
+ r as UI_COLORS,
48
+ u as getThemePalette
49
+ };