@trackunit/react-components 0.1.341 → 0.1.342
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 +4 -3
- package/index.esm.js +4 -3
- package/package.json +1 -1
- package/src/components/KPICard/KPICard.d.ts +5 -1
package/index.cjs.js
CHANGED
|
@@ -1888,7 +1888,7 @@ const SkeletonLines = React.memo(({ margin = "10px 0", lines = 1, height, width
|
|
|
1888
1888
|
return height;
|
|
1889
1889
|
};
|
|
1890
1890
|
for (let i = 0; i < lines; i++) {
|
|
1891
|
-
skeletonLines.push(jsxRuntime.jsx("div", { className: cvaSkeletonLine({ className }), "data-testid": dataTestId ? `${dataTestId}-${i}` : `skeleton-lines-${i}`, "data-type": "loading-skeleton-line", style: { height: getHeight(i), width: getWidth(i), margin: lines > 1 ? margin : "" }, children: lines > 1 && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "\u00A0" }) }, i));
|
|
1891
|
+
skeletonLines.push(jsxRuntime.jsx("div", { className: cvaSkeletonLine({ className }), "data-testid": dataTestId ? `${dataTestId}-${i}` : `skeleton-lines-${i}`, "data-type": "loading-skeleton-line", style: { height: getHeight(i), width: getWidth(i), margin: lines > 1 && i >= 1 ? margin : "" }, children: lines > 1 && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "\u00A0" }) }, i));
|
|
1892
1892
|
}
|
|
1893
1893
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
1894
1894
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: skeletonLines });
|
|
@@ -3639,6 +3639,7 @@ const cvaKPICardIconContainer = cssClassVarianceUtilities.cvaMerge(["w-7", "h-7"
|
|
|
3639
3639
|
},
|
|
3640
3640
|
});
|
|
3641
3641
|
|
|
3642
|
+
const LoadingContent = () => (jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-3", "data-testid": "kpi-card-loading-content", children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsx(SkeletonLines, { height: 28, lines: 1, width: 28 }) }), jsxRuntime.jsx("div", { className: "w-full", children: jsxRuntime.jsx(SkeletonLines, { height: [18, 20], lines: 2, margin: "3px 0", width: [50, 100] }) })] }));
|
|
3642
3643
|
/**
|
|
3643
3644
|
* The KPICard component is used to display KPIs.
|
|
3644
3645
|
*
|
|
@@ -3646,9 +3647,9 @@ const cvaKPICardIconContainer = cssClassVarianceUtilities.cvaMerge(["w-7", "h-7"
|
|
|
3646
3647
|
* @returns {JSX.Element} KPICard component
|
|
3647
3648
|
*/
|
|
3648
3649
|
const KPICard = (_a) => {
|
|
3649
|
-
var { asChild = false, title, value, unit, iconName, iconBackgroundColor, className, dataTestId } = _a, rest = __rest(_a, ["asChild", "title", "value", "unit", "iconName", "iconBackgroundColor", "className", "dataTestId"]);
|
|
3650
|
+
var { asChild = false, title, value, loading, unit, iconName, iconBackgroundColor, className, dataTestId } = _a, rest = __rest(_a, ["asChild", "title", "value", "loading", "unit", "iconName", "iconBackgroundColor", "className", "dataTestId"]);
|
|
3650
3651
|
const Comp = asChild ? reactSlot.Slot : "div";
|
|
3651
|
-
return (jsxRuntime.jsxs(Comp, Object.assign({ className: cvaKPICardContainer({ className, isClickable: asChild }), "data-testid": `${dataTestId}-comp` }, rest, { children: [jsxRuntime.
|
|
3652
|
+
return (jsxRuntime.jsxs(Comp, Object.assign({ className: cvaKPICardContainer({ className, isClickable: asChild }), "data-testid": `${dataTestId}-comp` }, rest, { children: [jsxRuntime.jsx(Card, { className: cvaKPICard({ isClickable: asChild && !loading }), children: loading ? (jsxRuntime.jsx(LoadingContent, {})) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [iconName ? (jsxRuntime.jsx("div", { className: cvaKPICardIconContainer({ backgroundColor: iconBackgroundColor }), "data-testid": `${dataTestId}-icon-container`, children: jsxRuntime.jsx(Icon, { color: "white", dataTestId: `${dataTestId}-icon`, name: iconName, size: "medium" }) })) : null, jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Text, { dataTestId: `${dataTestId}-title`, subtle: true, weight: "bold", children: title }), jsxRuntime.jsxs(Text, { dataTestId: `${dataTestId}-value`, size: "large", weight: "bold", children: [value, " ", unit] })] })] })) }), !loading && jsxRuntime.jsx(reactSlot.Slottable, { children: rest.children })] })));
|
|
3652
3653
|
};
|
|
3653
3654
|
|
|
3654
3655
|
const cvaMenuItem = cssClassVarianceUtilities.cvaMerge([
|
package/index.esm.js
CHANGED
|
@@ -1857,7 +1857,7 @@ const SkeletonLines = memo(({ margin = "10px 0", lines = 1, height, width = "100
|
|
|
1857
1857
|
return height;
|
|
1858
1858
|
};
|
|
1859
1859
|
for (let i = 0; i < lines; i++) {
|
|
1860
|
-
skeletonLines.push(jsx("div", { className: cvaSkeletonLine({ className }), "data-testid": dataTestId ? `${dataTestId}-${i}` : `skeleton-lines-${i}`, "data-type": "loading-skeleton-line", style: { height: getHeight(i), width: getWidth(i), margin: lines > 1 ? margin : "" }, children: lines > 1 && jsx(Fragment, { children: "\u00A0" }) }, i));
|
|
1860
|
+
skeletonLines.push(jsx("div", { className: cvaSkeletonLine({ className }), "data-testid": dataTestId ? `${dataTestId}-${i}` : `skeleton-lines-${i}`, "data-type": "loading-skeleton-line", style: { height: getHeight(i), width: getWidth(i), margin: lines > 1 && i >= 1 ? margin : "" }, children: lines > 1 && jsx(Fragment, { children: "\u00A0" }) }, i));
|
|
1861
1861
|
}
|
|
1862
1862
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
1863
1863
|
return jsx(Fragment, { children: skeletonLines });
|
|
@@ -3608,6 +3608,7 @@ const cvaKPICardIconContainer = cvaMerge(["w-7", "h-7", "flex", "justify-center"
|
|
|
3608
3608
|
},
|
|
3609
3609
|
});
|
|
3610
3610
|
|
|
3611
|
+
const LoadingContent = () => (jsxs("div", { className: "flex flex-row items-center gap-3", "data-testid": "kpi-card-loading-content", children: [jsx("div", { children: jsx(SkeletonLines, { height: 28, lines: 1, width: 28 }) }), jsx("div", { className: "w-full", children: jsx(SkeletonLines, { height: [18, 20], lines: 2, margin: "3px 0", width: [50, 100] }) })] }));
|
|
3611
3612
|
/**
|
|
3612
3613
|
* The KPICard component is used to display KPIs.
|
|
3613
3614
|
*
|
|
@@ -3615,9 +3616,9 @@ const cvaKPICardIconContainer = cvaMerge(["w-7", "h-7", "flex", "justify-center"
|
|
|
3615
3616
|
* @returns {JSX.Element} KPICard component
|
|
3616
3617
|
*/
|
|
3617
3618
|
const KPICard = (_a) => {
|
|
3618
|
-
var { asChild = false, title, value, unit, iconName, iconBackgroundColor, className, dataTestId } = _a, rest = __rest(_a, ["asChild", "title", "value", "unit", "iconName", "iconBackgroundColor", "className", "dataTestId"]);
|
|
3619
|
+
var { asChild = false, title, value, loading, unit, iconName, iconBackgroundColor, className, dataTestId } = _a, rest = __rest(_a, ["asChild", "title", "value", "loading", "unit", "iconName", "iconBackgroundColor", "className", "dataTestId"]);
|
|
3619
3620
|
const Comp = asChild ? Slot : "div";
|
|
3620
|
-
return (jsxs(Comp, Object.assign({ className: cvaKPICardContainer({ className, isClickable: asChild }), "data-testid": `${dataTestId}-comp` }, rest, { children: [
|
|
3621
|
+
return (jsxs(Comp, Object.assign({ className: cvaKPICardContainer({ className, isClickable: asChild }), "data-testid": `${dataTestId}-comp` }, rest, { children: [jsx(Card, { className: cvaKPICard({ isClickable: asChild && !loading }), children: loading ? (jsx(LoadingContent, {})) : (jsxs(Fragment, { children: [iconName ? (jsx("div", { className: cvaKPICardIconContainer({ backgroundColor: iconBackgroundColor }), "data-testid": `${dataTestId}-icon-container`, children: jsx(Icon, { color: "white", dataTestId: `${dataTestId}-icon`, name: iconName, size: "medium" }) })) : null, jsxs("div", { children: [jsx(Text, { dataTestId: `${dataTestId}-title`, subtle: true, weight: "bold", children: title }), jsxs(Text, { dataTestId: `${dataTestId}-value`, size: "large", weight: "bold", children: [value, " ", unit] })] })] })) }), !loading && jsx(Slottable, { children: rest.children })] })));
|
|
3621
3622
|
};
|
|
3622
3623
|
|
|
3623
3624
|
const cvaMenuItem = cvaMerge([
|
package/package.json
CHANGED
|
@@ -15,6 +15,10 @@ export interface KPICardProps extends CommonProps {
|
|
|
15
15
|
* The unit of the KPI Card
|
|
16
16
|
*/
|
|
17
17
|
unit: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether or not to show the loading state
|
|
20
|
+
*/
|
|
21
|
+
loading?: boolean;
|
|
18
22
|
/**
|
|
19
23
|
* The icon to be displayed in the prefix
|
|
20
24
|
*/
|
|
@@ -44,4 +48,4 @@ export interface KPICardProps extends CommonProps {
|
|
|
44
48
|
* @param {KPICardProps} props - The props for the KPICard component
|
|
45
49
|
* @returns {JSX.Element} KPICard component
|
|
46
50
|
*/
|
|
47
|
-
export declare const KPICard: ({ asChild, title, value, unit, iconName, iconBackgroundColor, className, dataTestId, ...rest }: KPICardProps) => JSX.Element;
|
|
51
|
+
export declare const KPICard: ({ asChild, title, value, loading, unit, iconName, iconBackgroundColor, className, dataTestId, ...rest }: KPICardProps) => JSX.Element;
|