@trackunit/react-chart-components 2.6.47 → 2.6.49-alpha-7317206cecd.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/index.cjs.js +24 -26
- package/index.esm.js +25 -27
- package/package.json +7 -7
- package/src/LegendItem/LegendItem.variants.d.ts +73 -8
package/index.cjs.js
CHANGED
|
@@ -174,7 +174,7 @@ const EChart = ({ option, style, className, onChartReady, onClick, onEvents, not
|
|
|
174
174
|
}, [option, notMerge]);
|
|
175
175
|
return jsxRuntime.jsx("div", { className: cvaEChart({ className }), "data-testid": dataTestId, ref: containerRef, style: style });
|
|
176
176
|
};
|
|
177
|
-
const cvaEChart = cssClassVarianceUtilities.
|
|
177
|
+
const cvaEChart = cssClassVarianceUtilities.cva({ base: ["w-full", "h-full"] });
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
180
|
* The Chart component is a wrapper component for ECharts, providing a simplified API for rendering interactive charts.
|
|
@@ -229,15 +229,16 @@ const Chart = ({ options, showLoading = false, className, style, onChartReady, o
|
|
|
229
229
|
return (jsxRuntime.jsx("div", { className: "grid h-full w-full grid-cols-1 grid-rows-1 items-center gap-1", "data-testid": dataTestId, ref: ref, style: containerStyle, children: showLoading ? (jsxRuntime.jsxs("div", { className: "grid place-items-center overflow-y-auto", "data-testid": `${dataTestId}-loading`, children: [jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered" }), loadingOption?.text ? (jsxRuntime.jsx(reactComponents.Text, { align: "center", subtle: true, children: loadingOption.text })) : null] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(EChart, { className: className, "data-testid": `${dataTestId}-chart`, notMerge: !merge, onChartReady: onChartReady, onClick: onClick, onEvents: onEvents, option: options, renderer: renderer, style: style }), timezoneLabel] })) }));
|
|
230
230
|
};
|
|
231
231
|
|
|
232
|
-
const cvaLegendItem = cssClassVarianceUtilities.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
232
|
+
const cvaLegendItem = cssClassVarianceUtilities.cva({
|
|
233
|
+
base: [
|
|
234
|
+
"flex",
|
|
235
|
+
"items-center",
|
|
236
|
+
"transition-all",
|
|
237
|
+
"ease-in-out",
|
|
238
|
+
"duration-200",
|
|
239
|
+
"text-neutral-600",
|
|
240
|
+
"hover:text-neutral-900",
|
|
241
|
+
],
|
|
241
242
|
variants: {
|
|
242
243
|
selected: {
|
|
243
244
|
false: "",
|
|
@@ -265,9 +266,11 @@ const cvaLegendItem = cssClassVarianceUtilities.cvaMerge([
|
|
|
265
266
|
isClickable: false,
|
|
266
267
|
},
|
|
267
268
|
});
|
|
268
|
-
const cvaLegendItemIndicator = cssClassVarianceUtilities.
|
|
269
|
-
const cvaLegendItemLineSwatch = cssClassVarianceUtilities.
|
|
270
|
-
|
|
269
|
+
const cvaLegendItemIndicator = cssClassVarianceUtilities.cva({ base: ["w-2.5", "mr-1", "h-2.5", "rounded-[50%]", "flex-none"] });
|
|
270
|
+
const cvaLegendItemLineSwatch = cssClassVarianceUtilities.cva({
|
|
271
|
+
base: ["relative", "mr-1", "h-3", "w-5", "flex-none", "overflow-hidden"],
|
|
272
|
+
});
|
|
273
|
+
const cvaLegendItemLineSvg = cssClassVarianceUtilities.cva({ base: ["h-full", "w-full"] });
|
|
271
274
|
|
|
272
275
|
const LINE_SWATCH_WIDTH = 20;
|
|
273
276
|
const LINE_SWATCH_HEIGHT = 12;
|
|
@@ -568,7 +571,7 @@ const BarChart = ({ series, loading = false, onClick, className, style, "data-te
|
|
|
568
571
|
series: seriesData,
|
|
569
572
|
}, showLoading: loading, style: { height: "100%", minHeight: "150px", width: "100%" } }) })] }));
|
|
570
573
|
};
|
|
571
|
-
const cvaChartRoot$1 = cssClassVarianceUtilities.
|
|
574
|
+
const cvaChartRoot$1 = cssClassVarianceUtilities.cva({ base: ["flex", "flex-col", "items-center", "h-full"] });
|
|
572
575
|
|
|
573
576
|
/**
|
|
574
577
|
* Limits the data set to the given limit.
|
|
@@ -777,17 +780,12 @@ const DonutChart = ({ data, size = "full", loading = false, onClick, className,
|
|
|
777
780
|
}
|
|
778
781
|
return (jsxRuntime.jsxs("div", { className: cvaChartRoot({ className }), "data-testid": dataTestId, ref: mergedRef, style: style, children: [jsxRuntime.jsx("div", { className: cvaChartContainer(), children: jsxRuntime.jsx(Chart, { className: cvaChart({ size }), "data-testid": dataTestId ? `chart-${dataTestId}` : undefined, onChartReady: handleChartReady, onClick: handleChartClick, onEvents: handleChartEvents, options: chartOptions, style: { width: "100%", height: "100%" } }) }), size === "full" && (jsxRuntime.jsx("div", { className: cvaLegend(), "data-testid": "legend", children: limitedData.map((item, index) => (jsxRuntime.jsx(LegendItem, { className: "p-1.5 py-0.5", color: item.color ?? chartColor(index), count: item.value, "data-testid": `legend-${item.id}`, disabled: (item.value ?? 0) === 0, hideValue: hideLegendValues, label: item.name, onClick: onClick ? () => onClick(item) : undefined, onMouseEnter: () => handleLegendMouseEnter(item), onMouseLeave: handleLegendMouseLeave, selected: item.selected, unit: unit }, item.id))) }))] }));
|
|
779
782
|
};
|
|
780
|
-
const cvaChartRoot = cssClassVarianceUtilities.
|
|
781
|
-
"flex",
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
"
|
|
786
|
-
"justify-items-stretch",
|
|
787
|
-
"flex-row",
|
|
788
|
-
]);
|
|
789
|
-
const cvaChartContainer = cssClassVarianceUtilities.cvaMerge(["flex-1", "h-full", "justify-end"]);
|
|
790
|
-
const cvaChart = cssClassVarianceUtilities.cvaMerge(["flex-0", "max-w-[200px]", "max-h-[200px]", "place-self-center"], {
|
|
783
|
+
const cvaChartRoot = cssClassVarianceUtilities.cva({
|
|
784
|
+
base: ["flex", "w-full", "h-full", "gap-4", "items-center", "justify-items-stretch", "flex-row"],
|
|
785
|
+
});
|
|
786
|
+
const cvaChartContainer = cssClassVarianceUtilities.cva({ base: ["flex-1", "h-full", "justify-end"] });
|
|
787
|
+
const cvaChart = cssClassVarianceUtilities.cva({
|
|
788
|
+
base: ["flex-0", "max-w-[200px]", "max-h-[200px]", "place-self-center"],
|
|
791
789
|
variants: {
|
|
792
790
|
size: {
|
|
793
791
|
full: ["min-h-[140px]"],
|
|
@@ -798,7 +796,7 @@ const cvaChart = cssClassVarianceUtilities.cvaMerge(["flex-0", "max-w-[200px]",
|
|
|
798
796
|
size: "full",
|
|
799
797
|
},
|
|
800
798
|
});
|
|
801
|
-
const cvaLegend = cssClassVarianceUtilities.
|
|
799
|
+
const cvaLegend = cssClassVarianceUtilities.cva({ base: ["flex", "overflow-auto", "justify-start", "flex-col", "flex-1"] });
|
|
802
800
|
|
|
803
801
|
exports.BarChart = BarChart;
|
|
804
802
|
exports.Chart = Chart;
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { cva } from '@trackunit/css-class-variance-utilities';
|
|
3
3
|
import { toDateUtil } from '@trackunit/date-and-time-utils';
|
|
4
4
|
import { useLocale, useDateAndTime } from '@trackunit/react-date-and-time-hooks';
|
|
5
5
|
import { DEFAULT_CHART_COLORS, CHART_STATUS_COLORS, fontFamily, DEFAULT_CHART_OTHER } from '@trackunit/ui-design-tokens';
|
|
@@ -153,7 +153,7 @@ const EChart = ({ option, style, className, onChartReady, onClick, onEvents, not
|
|
|
153
153
|
}, [option, notMerge]);
|
|
154
154
|
return jsx("div", { className: cvaEChart({ className }), "data-testid": dataTestId, ref: containerRef, style: style });
|
|
155
155
|
};
|
|
156
|
-
const cvaEChart =
|
|
156
|
+
const cvaEChart = cva({ base: ["w-full", "h-full"] });
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* The Chart component is a wrapper component for ECharts, providing a simplified API for rendering interactive charts.
|
|
@@ -208,15 +208,16 @@ const Chart = ({ options, showLoading = false, className, style, onChartReady, o
|
|
|
208
208
|
return (jsx("div", { className: "grid h-full w-full grid-cols-1 grid-rows-1 items-center gap-1", "data-testid": dataTestId, ref: ref, style: containerStyle, children: showLoading ? (jsxs("div", { className: "grid place-items-center overflow-y-auto", "data-testid": `${dataTestId}-loading`, children: [jsx(Spinner, { centering: "centered" }), loadingOption?.text ? (jsx(Text, { align: "center", subtle: true, children: loadingOption.text })) : null] })) : (jsxs(Fragment, { children: [jsx(EChart, { className: className, "data-testid": `${dataTestId}-chart`, notMerge: !merge, onChartReady: onChartReady, onClick: onClick, onEvents: onEvents, option: options, renderer: renderer, style: style }), timezoneLabel] })) }));
|
|
209
209
|
};
|
|
210
210
|
|
|
211
|
-
const cvaLegendItem =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
211
|
+
const cvaLegendItem = cva({
|
|
212
|
+
base: [
|
|
213
|
+
"flex",
|
|
214
|
+
"items-center",
|
|
215
|
+
"transition-all",
|
|
216
|
+
"ease-in-out",
|
|
217
|
+
"duration-200",
|
|
218
|
+
"text-neutral-600",
|
|
219
|
+
"hover:text-neutral-900",
|
|
220
|
+
],
|
|
220
221
|
variants: {
|
|
221
222
|
selected: {
|
|
222
223
|
false: "",
|
|
@@ -244,9 +245,11 @@ const cvaLegendItem = cvaMerge([
|
|
|
244
245
|
isClickable: false,
|
|
245
246
|
},
|
|
246
247
|
});
|
|
247
|
-
const cvaLegendItemIndicator =
|
|
248
|
-
const cvaLegendItemLineSwatch =
|
|
249
|
-
|
|
248
|
+
const cvaLegendItemIndicator = cva({ base: ["w-2.5", "mr-1", "h-2.5", "rounded-[50%]", "flex-none"] });
|
|
249
|
+
const cvaLegendItemLineSwatch = cva({
|
|
250
|
+
base: ["relative", "mr-1", "h-3", "w-5", "flex-none", "overflow-hidden"],
|
|
251
|
+
});
|
|
252
|
+
const cvaLegendItemLineSvg = cva({ base: ["h-full", "w-full"] });
|
|
250
253
|
|
|
251
254
|
const LINE_SWATCH_WIDTH = 20;
|
|
252
255
|
const LINE_SWATCH_HEIGHT = 12;
|
|
@@ -547,7 +550,7 @@ const BarChart = ({ series, loading = false, onClick, className, style, "data-te
|
|
|
547
550
|
series: seriesData,
|
|
548
551
|
}, showLoading: loading, style: { height: "100%", minHeight: "150px", width: "100%" } }) })] }));
|
|
549
552
|
};
|
|
550
|
-
const cvaChartRoot$1 =
|
|
553
|
+
const cvaChartRoot$1 = cva({ base: ["flex", "flex-col", "items-center", "h-full"] });
|
|
551
554
|
|
|
552
555
|
/**
|
|
553
556
|
* Limits the data set to the given limit.
|
|
@@ -756,17 +759,12 @@ const DonutChart = ({ data, size = "full", loading = false, onClick, className,
|
|
|
756
759
|
}
|
|
757
760
|
return (jsxs("div", { className: cvaChartRoot({ className }), "data-testid": dataTestId, ref: mergedRef, style: style, children: [jsx("div", { className: cvaChartContainer(), children: jsx(Chart, { className: cvaChart({ size }), "data-testid": dataTestId ? `chart-${dataTestId}` : undefined, onChartReady: handleChartReady, onClick: handleChartClick, onEvents: handleChartEvents, options: chartOptions, style: { width: "100%", height: "100%" } }) }), size === "full" && (jsx("div", { className: cvaLegend(), "data-testid": "legend", children: limitedData.map((item, index) => (jsx(LegendItem, { className: "p-1.5 py-0.5", color: item.color ?? chartColor(index), count: item.value, "data-testid": `legend-${item.id}`, disabled: (item.value ?? 0) === 0, hideValue: hideLegendValues, label: item.name, onClick: onClick ? () => onClick(item) : undefined, onMouseEnter: () => handleLegendMouseEnter(item), onMouseLeave: handleLegendMouseLeave, selected: item.selected, unit: unit }, item.id))) }))] }));
|
|
758
761
|
};
|
|
759
|
-
const cvaChartRoot =
|
|
760
|
-
"flex",
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
"
|
|
765
|
-
"justify-items-stretch",
|
|
766
|
-
"flex-row",
|
|
767
|
-
]);
|
|
768
|
-
const cvaChartContainer = cvaMerge(["flex-1", "h-full", "justify-end"]);
|
|
769
|
-
const cvaChart = cvaMerge(["flex-0", "max-w-[200px]", "max-h-[200px]", "place-self-center"], {
|
|
762
|
+
const cvaChartRoot = cva({
|
|
763
|
+
base: ["flex", "w-full", "h-full", "gap-4", "items-center", "justify-items-stretch", "flex-row"],
|
|
764
|
+
});
|
|
765
|
+
const cvaChartContainer = cva({ base: ["flex-1", "h-full", "justify-end"] });
|
|
766
|
+
const cvaChart = cva({
|
|
767
|
+
base: ["flex-0", "max-w-[200px]", "max-h-[200px]", "place-self-center"],
|
|
770
768
|
variants: {
|
|
771
769
|
size: {
|
|
772
770
|
full: ["min-h-[140px]"],
|
|
@@ -777,6 +775,6 @@ const cvaChart = cvaMerge(["flex-0", "max-w-[200px]", "max-h-[200px]", "place-se
|
|
|
777
775
|
size: "full",
|
|
778
776
|
},
|
|
779
777
|
});
|
|
780
|
-
const cvaLegend =
|
|
778
|
+
const cvaLegend = cva({ base: ["flex", "overflow-auto", "justify-start", "flex-col", "flex-1"] });
|
|
781
779
|
|
|
782
780
|
export { BarChart, Chart, DonutChart, EChart, LegendItem, useChartColor, useChartNumberFormat };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-chart-components",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.49-alpha-7317206cecd.0",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"migrations": "./migrations.json",
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"echarts": "5.6.0",
|
|
12
|
-
"@trackunit/date-and-time-utils": "1.14.
|
|
13
|
-
"@trackunit/react-date-and-time-hooks": "2.6.
|
|
14
|
-
"@trackunit/ui-design-tokens": "1.15.
|
|
15
|
-
"@trackunit/shared-utils": "1.16.
|
|
16
|
-
"@trackunit/css-class-variance-utilities": "1.
|
|
17
|
-
"@trackunit/react-components": "2.13.0"
|
|
12
|
+
"@trackunit/date-and-time-utils": "1.14.32-alpha-7317206cecd.0",
|
|
13
|
+
"@trackunit/react-date-and-time-hooks": "2.6.48-alpha-7317206cecd.0",
|
|
14
|
+
"@trackunit/ui-design-tokens": "1.15.21-alpha-7317206cecd.0",
|
|
15
|
+
"@trackunit/shared-utils": "1.16.34-alpha-7317206cecd.0",
|
|
16
|
+
"@trackunit/css-class-variance-utilities": "2.0.1-alpha-7317206cecd.0",
|
|
17
|
+
"@trackunit/react-components": "2.13.2-alpha-7317206cecd.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@apollo/client": "^3.13.8",
|
|
@@ -1,8 +1,73 @@
|
|
|
1
|
-
export declare const cvaLegendItem: (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
export declare const cvaLegendItem: import("cva").CVAComponent<Omit<{
|
|
2
|
+
base: string[];
|
|
3
|
+
variants: {
|
|
4
|
+
selected: {
|
|
5
|
+
false: string;
|
|
6
|
+
true: string[];
|
|
7
|
+
};
|
|
8
|
+
disabled: {
|
|
9
|
+
false: string;
|
|
10
|
+
true: string[];
|
|
11
|
+
};
|
|
12
|
+
isClickable: {
|
|
13
|
+
false: string;
|
|
14
|
+
true: string[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
disabled: false;
|
|
19
|
+
selected: false;
|
|
20
|
+
isClickable: false;
|
|
21
|
+
};
|
|
22
|
+
}, "defaultVariants"> & {
|
|
23
|
+
variants: {
|
|
24
|
+
selected: {
|
|
25
|
+
false: string;
|
|
26
|
+
true: string[];
|
|
27
|
+
};
|
|
28
|
+
disabled: {
|
|
29
|
+
false: string;
|
|
30
|
+
true: string[];
|
|
31
|
+
};
|
|
32
|
+
isClickable: {
|
|
33
|
+
false: string;
|
|
34
|
+
true: string[];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
defaultVariants: Omit<{}, "disabled" | "selected" | "isClickable"> & {
|
|
38
|
+
disabled: false;
|
|
39
|
+
selected: false;
|
|
40
|
+
isClickable: false;
|
|
41
|
+
};
|
|
42
|
+
}, {
|
|
43
|
+
selected: {
|
|
44
|
+
false: string;
|
|
45
|
+
true: string[];
|
|
46
|
+
};
|
|
47
|
+
disabled: {
|
|
48
|
+
false: string;
|
|
49
|
+
true: string[];
|
|
50
|
+
};
|
|
51
|
+
isClickable: {
|
|
52
|
+
false: string;
|
|
53
|
+
true: string[];
|
|
54
|
+
};
|
|
55
|
+
}>;
|
|
56
|
+
export declare const cvaLegendItemIndicator: import("cva").CVAComponent<Omit<{
|
|
57
|
+
base: string[];
|
|
58
|
+
}, "defaultVariants"> & {
|
|
59
|
+
variants: unknown;
|
|
60
|
+
defaultVariants: Omit<{}, never>;
|
|
61
|
+
}, unknown>;
|
|
62
|
+
export declare const cvaLegendItemLineSwatch: import("cva").CVAComponent<Omit<{
|
|
63
|
+
base: string[];
|
|
64
|
+
}, "defaultVariants"> & {
|
|
65
|
+
variants: unknown;
|
|
66
|
+
defaultVariants: Omit<{}, never>;
|
|
67
|
+
}, unknown>;
|
|
68
|
+
export declare const cvaLegendItemLineSvg: import("cva").CVAComponent<Omit<{
|
|
69
|
+
base: string[];
|
|
70
|
+
}, "defaultVariants"> & {
|
|
71
|
+
variants: unknown;
|
|
72
|
+
defaultVariants: Omit<{}, never>;
|
|
73
|
+
}, unknown>;
|