@trackunit/react-chart-components 0.0.76 → 0.0.78
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 +80 -49
- package/index.js +80 -49
- package/package.json +5 -5
- package/src/Chart/Chart.stories.d.ts +0 -1
- package/src/KPI/Kpi.stories.d.ts +0 -1
- package/src/KPI/Kpi.variants.d.ts +9 -0
- package/src/LegendItem/LegendItem.variants.d.ts +8 -0
package/index.cjs
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
|
|
6
7
|
var reactComponents = require('@trackunit/react-components');
|
|
7
|
-
var tailwindStyledComponents = require('@trackunit/tailwind-styled-components');
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var uiDesignTokens = require('@trackunit/ui-design-tokens');
|
|
10
10
|
|
|
@@ -96679,14 +96679,10 @@ const Chart = ({ options, showLoading, className, style, onChartReady, onClick,
|
|
|
96679
96679
|
}
|
|
96680
96680
|
};
|
|
96681
96681
|
}, [onClick, echartsRef]);
|
|
96682
|
-
return (jsxRuntime.jsx(
|
|
96682
|
+
return (jsxRuntime.jsx("div", { className: cvaChartContainer(), style: { height: (_a = style === null || style === void 0 ? void 0 : style.height) !== null && _a !== void 0 ? _a : "300px", width: (_b = style === null || style === void 0 ? void 0 : style.width) !== null && _b !== void 0 ? _b : "100%" }, "data-testid": dataTestId, children: showLoading ? (jsxRuntime.jsxs("div", { className: cvaChartSpinnerContainer(), "data-testid": `${dataTestId}-loading`, children: [jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered" }), (loadingOption === null || loadingOption === void 0 ? void 0 : loadingOption.text) && (jsxRuntime.jsx(reactComponents.Text, { align: "center", subtle: true, children: loadingOption.text }))] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(EChartsReact, { ref: echartsRef, option: options, opts: { width: "auto", height: "auto", renderer: renderer }, notMerge: !merge, onEvents: eventHandlers, className: className, style: style, onChartReady: onChartReady }), timezoneLabel] })) }));
|
|
96683
96683
|
};
|
|
96684
|
-
const
|
|
96685
|
-
|
|
96686
|
-
`;
|
|
96687
|
-
const ChartContainer = tailwindStyledComponents.tw.div `
|
|
96688
|
-
tu-chart-container
|
|
96689
|
-
`;
|
|
96684
|
+
const cvaChartContainer = cssClassVarianceUtilities.cvaMerge(["grid", "gap-1", "grid-rows-1", "grid-cols-1", "h-full", "w-full", "items-center"]);
|
|
96685
|
+
const cvaChartSpinnerContainer = cssClassVarianceUtilities.cvaMerge(["grid", "place-items-center", "overflow-y-auto"]);
|
|
96690
96686
|
|
|
96691
96687
|
/**
|
|
96692
96688
|
|
|
@@ -96735,6 +96731,28 @@ const KPIDonutChart = ({ dataTestId, loading, countColor, totalCountColor, count
|
|
|
96735
96731
|
} }));
|
|
96736
96732
|
};
|
|
96737
96733
|
|
|
96734
|
+
const cvaKpi = cssClassVarianceUtilities.cvaMerge(["flex", "flex-row", "gap-1", "leading-none", "items-center"]);
|
|
96735
|
+
const cvaKpiCountContainer = cssClassVarianceUtilities.cvaMerge(["flex", "gap-1", "items-baseline"]);
|
|
96736
|
+
const cvaKpiDescription = cssClassVarianceUtilities.cvaMerge(["font-normal", "text-base"]);
|
|
96737
|
+
const cvaKpiCount = cssClassVarianceUtilities.cvaMerge(["font-semibold", "text-xl"]);
|
|
96738
|
+
const cvaKpiSuffix = cssClassVarianceUtilities.cvaMerge(["font-normal", "text-base"]);
|
|
96739
|
+
const cvaKpiContainer = cssClassVarianceUtilities.cvaMerge(["flex", "flex-col", "items-baseline"], {
|
|
96740
|
+
variants: {
|
|
96741
|
+
inline: {
|
|
96742
|
+
false: "",
|
|
96743
|
+
true: ["flex-row", "gap-1", "justify-start"],
|
|
96744
|
+
},
|
|
96745
|
+
showChart: {
|
|
96746
|
+
false: "",
|
|
96747
|
+
true: ["gap-0 ", "items-center"],
|
|
96748
|
+
},
|
|
96749
|
+
},
|
|
96750
|
+
defaultVariants: {
|
|
96751
|
+
inline: false,
|
|
96752
|
+
showChart: false,
|
|
96753
|
+
},
|
|
96754
|
+
});
|
|
96755
|
+
|
|
96738
96756
|
/**
|
|
96739
96757
|
* - A KPI component to display a value and its description.
|
|
96740
96758
|
* - It can also display a donut chart to show the value and its total.
|
|
@@ -96750,18 +96768,51 @@ const KPIDonutChart = ({ dataTestId, loading, countColor, totalCountColor, count
|
|
|
96750
96768
|
* @returns {JSX.Element} Kpi component
|
|
96751
96769
|
*/
|
|
96752
96770
|
const Kpi = ({ className, dataTestId, showChart = false, count, description, totalCount, countColor, totalCountColor, suffix, inline = false, loading = false, }) => {
|
|
96753
|
-
return (jsxRuntime.jsxs(
|
|
96771
|
+
return (jsxRuntime.jsxs("div", { className: cvaKpi({ className }), "data-testid": dataTestId, children: [showChart && (jsxRuntime.jsx(KPIDonutChart, { dataTestId: dataTestId && dataTestId + "-donut-chart", loading: loading, count: Number(count), totalCount: totalCount, countColor: countColor, totalCountColor: totalCountColor })), loading ? (jsxRuntime.jsxs("div", { className: cvaKpiContainer({ inline }), "data-testid": dataTestId && `${dataTestId}-skeleton-lines`, children: [jsxRuntime.jsx(reactComponents.SkeletonLines, { lines: 1, width: 20 }), jsxRuntime.jsx(reactComponents.SkeletonLines, { lines: 1, width: 50 })] })) : (jsxRuntime.jsxs("div", { className: cvaKpiContainer({ inline, showChart }), "data-testid": dataTestId && `${dataTestId}-container`, children: [jsxRuntime.jsxs("span", { className: cvaKpiCountContainer(), children: [jsxRuntime.jsx("span", { className: cvaKpiCount(), children: count }), suffix && (jsxRuntime.jsx("span", { className: cvaKpiSuffix(), "data-testid": dataTestId && `${dataTestId}-suffix`, children: suffix }))] }), jsxRuntime.jsx("span", { className: cvaKpiDescription(), children: description })] }))] }));
|
|
96754
96772
|
};
|
|
96755
|
-
|
|
96756
|
-
const
|
|
96757
|
-
|
|
96758
|
-
|
|
96759
|
-
|
|
96760
|
-
|
|
96761
|
-
|
|
96762
|
-
|
|
96763
|
-
|
|
96764
|
-
|
|
96773
|
+
|
|
96774
|
+
const cvaLegendItem = cssClassVarianceUtilities.cvaMerge([
|
|
96775
|
+
"inline-flex",
|
|
96776
|
+
"items-center",
|
|
96777
|
+
"transition-all",
|
|
96778
|
+
"ease-in-out",
|
|
96779
|
+
"duration-200",
|
|
96780
|
+
"text-neutral-500",
|
|
96781
|
+
"hover:text-neutral-700",
|
|
96782
|
+
"text-sm",
|
|
96783
|
+
"gap-2",
|
|
96784
|
+
], {
|
|
96785
|
+
variants: {
|
|
96786
|
+
selected: {
|
|
96787
|
+
false: "",
|
|
96788
|
+
true: "font-medium text-black",
|
|
96789
|
+
},
|
|
96790
|
+
disabled: {
|
|
96791
|
+
false: "",
|
|
96792
|
+
true: "text-neutral-300",
|
|
96793
|
+
},
|
|
96794
|
+
isClickable: {
|
|
96795
|
+
false: "cursor-default",
|
|
96796
|
+
true: "cursor-pointer",
|
|
96797
|
+
},
|
|
96798
|
+
},
|
|
96799
|
+
defaultVariants: {
|
|
96800
|
+
disabled: false,
|
|
96801
|
+
selected: false,
|
|
96802
|
+
isClickable: false,
|
|
96803
|
+
},
|
|
96804
|
+
});
|
|
96805
|
+
const cvaLegendItemIndicator = cssClassVarianceUtilities.cvaMerge(["w-3", "h-3", "rounded-[50%]"], {
|
|
96806
|
+
variants: {
|
|
96807
|
+
selected: {
|
|
96808
|
+
false: "",
|
|
96809
|
+
true: "border border-black border-opacity-50",
|
|
96810
|
+
},
|
|
96811
|
+
},
|
|
96812
|
+
defaultVariants: {
|
|
96813
|
+
selected: false,
|
|
96814
|
+
},
|
|
96815
|
+
});
|
|
96765
96816
|
|
|
96766
96817
|
/**
|
|
96767
96818
|
* The LegendItem component is used to show form legends.
|
|
@@ -96771,28 +96822,8 @@ const Container = tailwindStyledComponents.tw.div `
|
|
|
96771
96822
|
*/
|
|
96772
96823
|
const LegendItem = ({ className, label, disabled, selected, onClick, color, dataTestId }) => {
|
|
96773
96824
|
const handleOnClick = onClick && !disabled ? () => onClick() : undefined;
|
|
96774
|
-
return (jsxRuntime.jsxs(
|
|
96825
|
+
return (jsxRuntime.jsxs("div", { "data-testid": dataTestId, onClick: handleOnClick, className: cvaLegendItem({ disabled, selected, isClickable: Boolean(onClick), className }), children: [jsxRuntime.jsx("div", { className: cvaLegendItemIndicator({ selected }), style: { backgroundColor: color } }), label && jsxRuntime.jsx("p", { children: label })] }));
|
|
96775
96826
|
};
|
|
96776
|
-
const Root = tailwindStyledComponents.tw.div `
|
|
96777
|
-
inline-flex
|
|
96778
|
-
items-center
|
|
96779
|
-
transition-all
|
|
96780
|
-
ease-in-out
|
|
96781
|
-
duration-200
|
|
96782
|
-
text-neutral-500
|
|
96783
|
-
hover:text-neutral-700
|
|
96784
|
-
text-sm
|
|
96785
|
-
gap-2
|
|
96786
|
-
${p => (p.$disabled ? tailwindStyledComponents.tws `text-neutral-300` : p.$selected ? tailwindStyledComponents.tws `text-black` : "")}
|
|
96787
|
-
${p => (p.$selected ? tailwindStyledComponents.tws `font-medium` : null)}
|
|
96788
|
-
${p => (p.onClick ? tailwindStyledComponents.tws `cursor-pointer` : tailwindStyledComponents.tws `cursor-default`)}
|
|
96789
|
-
`;
|
|
96790
|
-
const Indicator = tailwindStyledComponents.tw.div `
|
|
96791
|
-
w-3
|
|
96792
|
-
h-3
|
|
96793
|
-
rounded-[50%]
|
|
96794
|
-
${p => (p.$selected ? tailwindStyledComponents.tws `border border-black border-opacity-50` : null)}
|
|
96795
|
-
`;
|
|
96796
96827
|
|
|
96797
96828
|
/**
|
|
96798
96829
|
* Create a PieChart with legends based on our current Chart component
|
|
@@ -96800,7 +96831,7 @@ const Indicator = tailwindStyledComponents.tw.div `
|
|
|
96800
96831
|
* @param {PieChartProps} props - The props for the Chart component
|
|
96801
96832
|
* @returns {JSX.Element} Chart component
|
|
96802
96833
|
*/
|
|
96803
|
-
const PieChart = ({ data, size = "full", loading, onClick, className, dataTestId, }) => (jsxRuntime.jsxs(
|
|
96834
|
+
const PieChart = ({ data, size = "full", loading, onClick, className, dataTestId, }) => (jsxRuntime.jsxs("div", { className: cvaChartRoot({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx("div", { children: size === "full" && (jsxRuntime.jsx("div", { className: "flex flex-col", "data-testid": "legend", children: data === null || data === void 0 ? void 0 : data.map(item => (jsxRuntime.jsx(LegendItem, { dataTestId: `legend-${item.id}`, label: (item === null || item === void 0 ? void 0 : item.count) !== undefined ? `${item.name} (${item.count})` : item.name, onClick: onClick ? () => onClick(item) : undefined, selected: item.selected, color: item.color }, item.id))) })) }), jsxRuntime.jsx(Chart, { dataTestId: "pie-chart", showLoading: loading, style: size === "full" ? { height: 110, width: 110 } : { height: 60, width: 60 }, onClick: evt => {
|
|
96804
96835
|
const clickedEntry = data === null || data === void 0 ? void 0 : data.find(x => x.id === evt.data.id);
|
|
96805
96836
|
if (onClick && clickedEntry) {
|
|
96806
96837
|
onClick(clickedEntry);
|
|
@@ -96851,14 +96882,14 @@ const PieChart = ({ data, size = "full", loading, onClick, className, dataTestId
|
|
|
96851
96882
|
},
|
|
96852
96883
|
],
|
|
96853
96884
|
} })] }));
|
|
96854
|
-
const
|
|
96855
|
-
|
|
96856
|
-
|
|
96857
|
-
|
|
96858
|
-
|
|
96859
|
-
|
|
96860
|
-
|
|
96861
|
-
|
|
96885
|
+
const cvaChartRoot = cssClassVarianceUtilities.cvaMerge([
|
|
96886
|
+
"flex",
|
|
96887
|
+
"flex-direction-col",
|
|
96888
|
+
"flex-wrap-reverse",
|
|
96889
|
+
"justify-between",
|
|
96890
|
+
"items-center",
|
|
96891
|
+
"h-full",
|
|
96892
|
+
]);
|
|
96862
96893
|
|
|
96863
96894
|
exports.Chart = Chart;
|
|
96864
96895
|
exports.Kpi = Kpi;
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
2
3
|
import { Spinner, Text, SkeletonLines } from '@trackunit/react-components';
|
|
3
|
-
import { tw, tws } from '@trackunit/tailwind-styled-components';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import React__default, { PureComponent } from 'react';
|
|
6
6
|
import { DEFAULT_CHART_COLORS } from '@trackunit/ui-design-tokens';
|
|
@@ -96653,14 +96653,10 @@ const Chart = ({ options, showLoading, className, style, onChartReady, onClick,
|
|
|
96653
96653
|
}
|
|
96654
96654
|
};
|
|
96655
96655
|
}, [onClick, echartsRef]);
|
|
96656
|
-
return (jsx(
|
|
96656
|
+
return (jsx("div", { className: cvaChartContainer(), style: { height: (_a = style === null || style === void 0 ? void 0 : style.height) !== null && _a !== void 0 ? _a : "300px", width: (_b = style === null || style === void 0 ? void 0 : style.width) !== null && _b !== void 0 ? _b : "100%" }, "data-testid": dataTestId, children: showLoading ? (jsxs("div", { className: cvaChartSpinnerContainer(), "data-testid": `${dataTestId}-loading`, children: [jsx(Spinner, { centering: "centered" }), (loadingOption === null || loadingOption === void 0 ? void 0 : loadingOption.text) && (jsx(Text, { align: "center", subtle: true, children: loadingOption.text }))] })) : (jsxs(Fragment, { children: [jsx(EChartsReact, { ref: echartsRef, option: options, opts: { width: "auto", height: "auto", renderer: renderer }, notMerge: !merge, onEvents: eventHandlers, className: className, style: style, onChartReady: onChartReady }), timezoneLabel] })) }));
|
|
96657
96657
|
};
|
|
96658
|
-
const
|
|
96659
|
-
|
|
96660
|
-
`;
|
|
96661
|
-
const ChartContainer = tw.div `
|
|
96662
|
-
tu-chart-container
|
|
96663
|
-
`;
|
|
96658
|
+
const cvaChartContainer = cvaMerge(["grid", "gap-1", "grid-rows-1", "grid-cols-1", "h-full", "w-full", "items-center"]);
|
|
96659
|
+
const cvaChartSpinnerContainer = cvaMerge(["grid", "place-items-center", "overflow-y-auto"]);
|
|
96664
96660
|
|
|
96665
96661
|
/**
|
|
96666
96662
|
|
|
@@ -96709,6 +96705,28 @@ const KPIDonutChart = ({ dataTestId, loading, countColor, totalCountColor, count
|
|
|
96709
96705
|
} }));
|
|
96710
96706
|
};
|
|
96711
96707
|
|
|
96708
|
+
const cvaKpi = cvaMerge(["flex", "flex-row", "gap-1", "leading-none", "items-center"]);
|
|
96709
|
+
const cvaKpiCountContainer = cvaMerge(["flex", "gap-1", "items-baseline"]);
|
|
96710
|
+
const cvaKpiDescription = cvaMerge(["font-normal", "text-base"]);
|
|
96711
|
+
const cvaKpiCount = cvaMerge(["font-semibold", "text-xl"]);
|
|
96712
|
+
const cvaKpiSuffix = cvaMerge(["font-normal", "text-base"]);
|
|
96713
|
+
const cvaKpiContainer = cvaMerge(["flex", "flex-col", "items-baseline"], {
|
|
96714
|
+
variants: {
|
|
96715
|
+
inline: {
|
|
96716
|
+
false: "",
|
|
96717
|
+
true: ["flex-row", "gap-1", "justify-start"],
|
|
96718
|
+
},
|
|
96719
|
+
showChart: {
|
|
96720
|
+
false: "",
|
|
96721
|
+
true: ["gap-0 ", "items-center"],
|
|
96722
|
+
},
|
|
96723
|
+
},
|
|
96724
|
+
defaultVariants: {
|
|
96725
|
+
inline: false,
|
|
96726
|
+
showChart: false,
|
|
96727
|
+
},
|
|
96728
|
+
});
|
|
96729
|
+
|
|
96712
96730
|
/**
|
|
96713
96731
|
* - A KPI component to display a value and its description.
|
|
96714
96732
|
* - It can also display a donut chart to show the value and its total.
|
|
@@ -96724,18 +96742,51 @@ const KPIDonutChart = ({ dataTestId, loading, countColor, totalCountColor, count
|
|
|
96724
96742
|
* @returns {JSX.Element} Kpi component
|
|
96725
96743
|
*/
|
|
96726
96744
|
const Kpi = ({ className, dataTestId, showChart = false, count, description, totalCount, countColor, totalCountColor, suffix, inline = false, loading = false, }) => {
|
|
96727
|
-
return (jsxs(
|
|
96745
|
+
return (jsxs("div", { className: cvaKpi({ className }), "data-testid": dataTestId, children: [showChart && (jsx(KPIDonutChart, { dataTestId: dataTestId && dataTestId + "-donut-chart", loading: loading, count: Number(count), totalCount: totalCount, countColor: countColor, totalCountColor: totalCountColor })), loading ? (jsxs("div", { className: cvaKpiContainer({ inline }), "data-testid": dataTestId && `${dataTestId}-skeleton-lines`, children: [jsx(SkeletonLines, { lines: 1, width: 20 }), jsx(SkeletonLines, { lines: 1, width: 50 })] })) : (jsxs("div", { className: cvaKpiContainer({ inline, showChart }), "data-testid": dataTestId && `${dataTestId}-container`, children: [jsxs("span", { className: cvaKpiCountContainer(), children: [jsx("span", { className: cvaKpiCount(), children: count }), suffix && (jsx("span", { className: cvaKpiSuffix(), "data-testid": dataTestId && `${dataTestId}-suffix`, children: suffix }))] }), jsx("span", { className: cvaKpiDescription(), children: description })] }))] }));
|
|
96728
96746
|
};
|
|
96729
|
-
|
|
96730
|
-
const
|
|
96731
|
-
|
|
96732
|
-
|
|
96733
|
-
|
|
96734
|
-
|
|
96735
|
-
|
|
96736
|
-
|
|
96737
|
-
|
|
96738
|
-
|
|
96747
|
+
|
|
96748
|
+
const cvaLegendItem = cvaMerge([
|
|
96749
|
+
"inline-flex",
|
|
96750
|
+
"items-center",
|
|
96751
|
+
"transition-all",
|
|
96752
|
+
"ease-in-out",
|
|
96753
|
+
"duration-200",
|
|
96754
|
+
"text-neutral-500",
|
|
96755
|
+
"hover:text-neutral-700",
|
|
96756
|
+
"text-sm",
|
|
96757
|
+
"gap-2",
|
|
96758
|
+
], {
|
|
96759
|
+
variants: {
|
|
96760
|
+
selected: {
|
|
96761
|
+
false: "",
|
|
96762
|
+
true: "font-medium text-black",
|
|
96763
|
+
},
|
|
96764
|
+
disabled: {
|
|
96765
|
+
false: "",
|
|
96766
|
+
true: "text-neutral-300",
|
|
96767
|
+
},
|
|
96768
|
+
isClickable: {
|
|
96769
|
+
false: "cursor-default",
|
|
96770
|
+
true: "cursor-pointer",
|
|
96771
|
+
},
|
|
96772
|
+
},
|
|
96773
|
+
defaultVariants: {
|
|
96774
|
+
disabled: false,
|
|
96775
|
+
selected: false,
|
|
96776
|
+
isClickable: false,
|
|
96777
|
+
},
|
|
96778
|
+
});
|
|
96779
|
+
const cvaLegendItemIndicator = cvaMerge(["w-3", "h-3", "rounded-[50%]"], {
|
|
96780
|
+
variants: {
|
|
96781
|
+
selected: {
|
|
96782
|
+
false: "",
|
|
96783
|
+
true: "border border-black border-opacity-50",
|
|
96784
|
+
},
|
|
96785
|
+
},
|
|
96786
|
+
defaultVariants: {
|
|
96787
|
+
selected: false,
|
|
96788
|
+
},
|
|
96789
|
+
});
|
|
96739
96790
|
|
|
96740
96791
|
/**
|
|
96741
96792
|
* The LegendItem component is used to show form legends.
|
|
@@ -96745,28 +96796,8 @@ const Container = tw.div `
|
|
|
96745
96796
|
*/
|
|
96746
96797
|
const LegendItem = ({ className, label, disabled, selected, onClick, color, dataTestId }) => {
|
|
96747
96798
|
const handleOnClick = onClick && !disabled ? () => onClick() : undefined;
|
|
96748
|
-
return (jsxs(
|
|
96799
|
+
return (jsxs("div", { "data-testid": dataTestId, onClick: handleOnClick, className: cvaLegendItem({ disabled, selected, isClickable: Boolean(onClick), className }), children: [jsx("div", { className: cvaLegendItemIndicator({ selected }), style: { backgroundColor: color } }), label && jsx("p", { children: label })] }));
|
|
96749
96800
|
};
|
|
96750
|
-
const Root = tw.div `
|
|
96751
|
-
inline-flex
|
|
96752
|
-
items-center
|
|
96753
|
-
transition-all
|
|
96754
|
-
ease-in-out
|
|
96755
|
-
duration-200
|
|
96756
|
-
text-neutral-500
|
|
96757
|
-
hover:text-neutral-700
|
|
96758
|
-
text-sm
|
|
96759
|
-
gap-2
|
|
96760
|
-
${p => (p.$disabled ? tws `text-neutral-300` : p.$selected ? tws `text-black` : "")}
|
|
96761
|
-
${p => (p.$selected ? tws `font-medium` : null)}
|
|
96762
|
-
${p => (p.onClick ? tws `cursor-pointer` : tws `cursor-default`)}
|
|
96763
|
-
`;
|
|
96764
|
-
const Indicator = tw.div `
|
|
96765
|
-
w-3
|
|
96766
|
-
h-3
|
|
96767
|
-
rounded-[50%]
|
|
96768
|
-
${p => (p.$selected ? tws `border border-black border-opacity-50` : null)}
|
|
96769
|
-
`;
|
|
96770
96801
|
|
|
96771
96802
|
/**
|
|
96772
96803
|
* Create a PieChart with legends based on our current Chart component
|
|
@@ -96774,7 +96805,7 @@ const Indicator = tw.div `
|
|
|
96774
96805
|
* @param {PieChartProps} props - The props for the Chart component
|
|
96775
96806
|
* @returns {JSX.Element} Chart component
|
|
96776
96807
|
*/
|
|
96777
|
-
const PieChart = ({ data, size = "full", loading, onClick, className, dataTestId, }) => (jsxs(
|
|
96808
|
+
const PieChart = ({ data, size = "full", loading, onClick, className, dataTestId, }) => (jsxs("div", { className: cvaChartRoot({ className }), "data-testid": dataTestId, children: [jsx("div", { children: size === "full" && (jsx("div", { className: "flex flex-col", "data-testid": "legend", children: data === null || data === void 0 ? void 0 : data.map(item => (jsx(LegendItem, { dataTestId: `legend-${item.id}`, label: (item === null || item === void 0 ? void 0 : item.count) !== undefined ? `${item.name} (${item.count})` : item.name, onClick: onClick ? () => onClick(item) : undefined, selected: item.selected, color: item.color }, item.id))) })) }), jsx(Chart, { dataTestId: "pie-chart", showLoading: loading, style: size === "full" ? { height: 110, width: 110 } : { height: 60, width: 60 }, onClick: evt => {
|
|
96778
96809
|
const clickedEntry = data === null || data === void 0 ? void 0 : data.find(x => x.id === evt.data.id);
|
|
96779
96810
|
if (onClick && clickedEntry) {
|
|
96780
96811
|
onClick(clickedEntry);
|
|
@@ -96825,13 +96856,13 @@ const PieChart = ({ data, size = "full", loading, onClick, className, dataTestId
|
|
|
96825
96856
|
},
|
|
96826
96857
|
],
|
|
96827
96858
|
} })] }));
|
|
96828
|
-
const
|
|
96829
|
-
|
|
96830
|
-
|
|
96831
|
-
|
|
96832
|
-
|
|
96833
|
-
|
|
96834
|
-
|
|
96835
|
-
|
|
96859
|
+
const cvaChartRoot = cvaMerge([
|
|
96860
|
+
"flex",
|
|
96861
|
+
"flex-direction-col",
|
|
96862
|
+
"flex-wrap-reverse",
|
|
96863
|
+
"justify-between",
|
|
96864
|
+
"items-center",
|
|
96865
|
+
"h-full",
|
|
96866
|
+
]);
|
|
96836
96867
|
|
|
96837
96868
|
export { Chart, Kpi, LegendItem, PieChart };
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-chart-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.78",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=
|
|
7
|
+
"node": ">=18.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/
|
|
11
|
-
"@trackunit/
|
|
12
|
-
"@trackunit/ui-design-tokens": "0.0.
|
|
10
|
+
"@trackunit/css-class-variance-utilities": "0.0.11",
|
|
11
|
+
"@trackunit/react-components": "0.1.133",
|
|
12
|
+
"@trackunit/ui-design-tokens": "0.0.74",
|
|
13
13
|
"echarts": "5.4.0",
|
|
14
14
|
"echarts-for-react": "3.0.2",
|
|
15
15
|
"react": "18.2.0"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Story } from "@storybook/react";
|
|
2
2
|
import { ChartProps } from "./Chart";
|
|
3
|
-
import "./Chart.css";
|
|
4
3
|
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, ChartProps>;
|
|
5
4
|
export default _default;
|
|
6
5
|
export declare const Default: Story<ChartProps>;
|
package/src/KPI/Kpi.stories.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Story } from "@storybook/react";
|
|
2
2
|
import { KpiProps } from "./Kpi";
|
|
3
|
-
import "./Kpi.css";
|
|
4
3
|
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, KpiProps>;
|
|
5
4
|
export default _default;
|
|
6
5
|
export declare const Default: Story<KpiProps>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const cvaKpi: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
2
|
+
export declare const cvaKpiCountContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
3
|
+
export declare const cvaKpiDescription: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
4
|
+
export declare const cvaKpiCount: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
5
|
+
export declare const cvaKpiSuffix: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
6
|
+
export declare const cvaKpiContainer: (props?: ({
|
|
7
|
+
inline?: boolean | null | undefined;
|
|
8
|
+
showChart?: boolean | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const cvaLegendItem: (props?: ({
|
|
2
|
+
selected?: boolean | null | undefined;
|
|
3
|
+
disabled?: boolean | null | undefined;
|
|
4
|
+
isClickable?: boolean | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
6
|
+
export declare const cvaLegendItemIndicator: (props?: ({
|
|
7
|
+
selected?: boolean | null | undefined;
|
|
8
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|