@trackunit/react-widgets 2.4.14 → 2.5.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 CHANGED
@@ -256,14 +256,14 @@ const cvaWidgetKPIvalueText = cssClassVarianceUtilities.cvaMerge([
256
256
  "font-medium",
257
257
  "!leading-none",
258
258
  ]);
259
- const cvaWidgetKPITrendValueText = cssClassVarianceUtilities.cvaMerge([
259
+ cssClassVarianceUtilities.cvaMerge([
260
260
  "text-xs",
261
261
  "font-normal",
262
262
  "whitespace-nowrap",
263
263
  "truncate",
264
264
  "overflow-hidden",
265
265
  ]);
266
- const cvaWidgetKPITrendPercentage = cssClassVarianceUtilities.cvaMerge(["text-xs", "font-semibold"], {
266
+ cssClassVarianceUtilities.cvaMerge(["text-xs", "font-semibold"], {
267
267
  variants: {
268
268
  color: {
269
269
  success: ["text-success-600"],
@@ -275,7 +275,7 @@ const cvaWidgetKPITrendPercentage = cssClassVarianceUtilities.cvaMerge(["text-xs
275
275
  color: "success",
276
276
  },
277
277
  });
278
- const cvaWidgetKPINotice = cssClassVarianceUtilities.cvaMerge([
278
+ cssClassVarianceUtilities.cvaMerge([
279
279
  "flex",
280
280
  "items-center",
281
281
  "gap-1",
@@ -286,17 +286,6 @@ const cvaWidgetKPINotice = cssClassVarianceUtilities.cvaMerge([
286
286
  "*:truncate",
287
287
  "**:truncate",
288
288
  ]);
289
- const cvaWidgetKPIValueContainer = cssClassVarianceUtilities.cvaMerge(["truncate", "whitespace-nowrap"], {
290
- variants: {
291
- isDefaultAndHasTrendValue: {
292
- true: [],
293
- false: ["flex", "flex-row", "gap-1"],
294
- },
295
- },
296
- defaultVariants: {
297
- isDefaultAndHasTrendValue: true,
298
- },
299
- });
300
289
 
301
290
  /**
302
291
  * The KPI Widget is a compact and flexible component designed to surface key metrics in a clear, impactful way. It provides at-a-glance insights through bold values, concise labels, and optional contextual elements such as trend indicators or time zones. Its goal is to drive user attention toward meaningful data that prompts action.
@@ -304,17 +293,8 @@ const cvaWidgetKPIValueContainer = cssClassVarianceUtilities.cvaMerge(["truncate
304
293
  * @param {WidgetKPIProps} props - The props for the WidgetKPI component
305
294
  * @returns {ReactElement} WidgetKPI component
306
295
  */
307
- const WidgetKPI = ({ title, value, loading = false, unit, className, "data-testid": dataTestId, tooltipLabel, trend, iconName, iconColor = "info", notice, ...rest }) => {
308
- return (jsxRuntime.jsx("div", { className: cvaWidgetKPI({ className }), "data-testid": dataTestId ?? undefined, ...rest, children: loading ? (jsxRuntime.jsx("div", { className: "flex flex-col gap-2 pt-6", "data-testid": dataTestId ? `${dataTestId}-loading` : "WidgetKPI-loading", children: trend ? (jsxRuntime.jsx(reactComponents.SkeletonLines, { gap: 6, height: [16, 24, 16], lines: 3, width: [100, 40, 60] })) : (jsxRuntime.jsx(reactComponents.SkeletonLines, { gap: 6, height: [16, 24], lines: 2, width: [100, 40] })) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col justify-center gap-0.5", children: [jsxRuntime.jsx("div", { className: cvaWidgetKPIHeader(), children: jsxRuntime.jsxs("div", { className: "flex items-start gap-1", children: [iconName ? (jsxRuntime.jsx(reactComponents.Icon, { className: "flex-shrink-0 py-0.5", color: iconColor, name: iconName, size: "small" })) : null, jsxRuntime.jsx(reactComponents.Tooltip, { "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: !tooltipLabel, label: tooltipLabel, placement: "bottom-start", children: jsxRuntime.jsx(reactComponents.Text, { className: cvaWidgetKPITitleText(), "data-testid": dataTestId ? `${dataTestId}-title` : undefined, children: title }) })] }) }), jsxRuntime.jsx("div", { className: "flex items-baseline justify-start", children: jsxRuntime.jsx(reactComponents.Text, { className: cvaWidgetKPIvalueText(), "data-testid": dataTestId ? `${dataTestId}-value` : undefined, type: "div", children: jsxRuntime.jsx("div", { className: cvaWidgetKPIValueContainer({
309
- isDefaultAndHasTrendValue: Boolean(trend?.value),
310
- className,
311
- }), children: jsxRuntime.jsxs("span", { className: cvaWidgetKPIvalueText(), children: [value, " ", unit] }) }) }) })] }), jsxRuntime.jsx("div", { className: "flex min-h-[1lh] items-center gap-1 overflow-hidden", children: trend ? (jsxRuntime.jsx(TrendIndicator, { isSmallVariant: false, trend: trend, unit: unit })) : notice !== undefined ? (jsxRuntime.jsx("div", { className: cvaWidgetKPINotice(), children: typeof notice === "string" || typeof notice === "number" ? jsxRuntime.jsx("span", { children: notice }) : notice })) : null })] })) }));
312
- };
313
- const TrendIndicator = ({ trend, unit, isSmallVariant }) => {
314
- if (!trend) {
315
- return null;
316
- }
317
- return (jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-0.5 overflow-hidden", "data-testid": "trend-indicator", children: [!isSmallVariant && trend.value ? (jsxRuntime.jsxs(reactComponents.Text, { className: cvaWidgetKPITrendValueText(), "data-testid": "trend-value", size: "small", weight: "normal", children: [trend.value, " ", unit] })) : null, trend.variant?.icon ? jsxRuntime.jsx(reactComponents.Icon, { color: trend.variant.color, name: trend.variant.icon, size: "small" }) : null, trend.percentage ? (jsxRuntime.jsxs(reactComponents.Text, { className: cvaWidgetKPITrendPercentage({ color: trend.variant?.color }), children: [trend.percentage, "%"] })) : null] }));
296
+ const WidgetKPI = ({ title, value, loading = false, unit, className, "data-testid": dataTestId, tooltipLabel, trends, iconName = undefined, iconColor = "info", notice, ...rest }) => {
297
+ return (jsxRuntime.jsx("div", { className: cvaWidgetKPI({ className }), "data-testid": dataTestId ?? undefined, ...rest, children: loading ? (jsxRuntime.jsx("div", { className: "flex flex-col gap-2 pt-6", "data-testid": dataTestId ? `${dataTestId}-loading` : "WidgetKPI-loading", children: trends ? (jsxRuntime.jsx(reactComponents.SkeletonLines, { gap: 6, height: [16, 24, 16], lines: 3, width: [100, 40, 60] })) : (jsxRuntime.jsx(reactComponents.SkeletonLines, { gap: 6, height: [16, 24], lines: 2, width: [100, 40] })) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col justify-center gap-0.5", children: [jsxRuntime.jsx("div", { className: cvaWidgetKPIHeader(), children: jsxRuntime.jsxs("div", { className: "flex items-start gap-1", children: [iconName ? (jsxRuntime.jsx(reactComponents.Icon, { className: "flex-shrink-0 py-0.5", color: iconColor, name: iconName, size: "small" })) : null, jsxRuntime.jsx(reactComponents.Tooltip, { "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: !tooltipLabel, label: tooltipLabel, placement: "bottom-start", children: jsxRuntime.jsx(reactComponents.Text, { className: cvaWidgetKPITitleText(), "data-testid": dataTestId ? `${dataTestId}-title` : undefined, children: title }) })] }) }), jsxRuntime.jsx("div", { className: "flex items-baseline justify-start", children: jsxRuntime.jsx(reactComponents.Text, { className: cvaWidgetKPIvalueText(), "data-testid": dataTestId ? `${dataTestId}-value` : undefined, type: "div", children: jsxRuntime.jsxs("div", { className: cvaWidgetKPIvalueText(), children: [value, " ", unit] }) }) })] }), jsxRuntime.jsx("div", { className: "flex min-h-[1lh] items-center gap-1 overflow-hidden", children: trends ? (jsxRuntime.jsx(reactComponents.TrendIndicators, { "data-testid": dataTestId ? `${dataTestId}-trend-indicators` : undefined, trends: trends })) : notice !== undefined ? (jsxRuntime.jsx(reactComponents.Notice, { "data-testid": dataTestId ? `${dataTestId}-notice` : undefined, size: "small", ...notice, className: "block", iconSize: "small" })) : null })] })) }));
318
298
  };
319
299
 
320
300
  /*
package/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
3
- import { EmptyState, Card, CardHeader, CardBody, CardFooter, Button, SkeletonLines, Icon, Tooltip, Text } from '@trackunit/react-components';
3
+ import { EmptyState, Card, CardHeader, CardBody, CardFooter, Button, SkeletonLines, Icon, Tooltip, Text, TrendIndicators, Notice } from '@trackunit/react-components';
4
4
  import { useState } from 'react';
5
5
  import { WidgetConfigRuntime } from '@trackunit/iris-app-runtime-core';
6
6
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
@@ -254,14 +254,14 @@ const cvaWidgetKPIvalueText = cvaMerge([
254
254
  "font-medium",
255
255
  "!leading-none",
256
256
  ]);
257
- const cvaWidgetKPITrendValueText = cvaMerge([
257
+ cvaMerge([
258
258
  "text-xs",
259
259
  "font-normal",
260
260
  "whitespace-nowrap",
261
261
  "truncate",
262
262
  "overflow-hidden",
263
263
  ]);
264
- const cvaWidgetKPITrendPercentage = cvaMerge(["text-xs", "font-semibold"], {
264
+ cvaMerge(["text-xs", "font-semibold"], {
265
265
  variants: {
266
266
  color: {
267
267
  success: ["text-success-600"],
@@ -273,7 +273,7 @@ const cvaWidgetKPITrendPercentage = cvaMerge(["text-xs", "font-semibold"], {
273
273
  color: "success",
274
274
  },
275
275
  });
276
- const cvaWidgetKPINotice = cvaMerge([
276
+ cvaMerge([
277
277
  "flex",
278
278
  "items-center",
279
279
  "gap-1",
@@ -284,17 +284,6 @@ const cvaWidgetKPINotice = cvaMerge([
284
284
  "*:truncate",
285
285
  "**:truncate",
286
286
  ]);
287
- const cvaWidgetKPIValueContainer = cvaMerge(["truncate", "whitespace-nowrap"], {
288
- variants: {
289
- isDefaultAndHasTrendValue: {
290
- true: [],
291
- false: ["flex", "flex-row", "gap-1"],
292
- },
293
- },
294
- defaultVariants: {
295
- isDefaultAndHasTrendValue: true,
296
- },
297
- });
298
287
 
299
288
  /**
300
289
  * The KPI Widget is a compact and flexible component designed to surface key metrics in a clear, impactful way. It provides at-a-glance insights through bold values, concise labels, and optional contextual elements such as trend indicators or time zones. Its goal is to drive user attention toward meaningful data that prompts action.
@@ -302,17 +291,8 @@ const cvaWidgetKPIValueContainer = cvaMerge(["truncate", "whitespace-nowrap"], {
302
291
  * @param {WidgetKPIProps} props - The props for the WidgetKPI component
303
292
  * @returns {ReactElement} WidgetKPI component
304
293
  */
305
- const WidgetKPI = ({ title, value, loading = false, unit, className, "data-testid": dataTestId, tooltipLabel, trend, iconName, iconColor = "info", notice, ...rest }) => {
306
- return (jsx("div", { className: cvaWidgetKPI({ className }), "data-testid": dataTestId ?? undefined, ...rest, children: loading ? (jsx("div", { className: "flex flex-col gap-2 pt-6", "data-testid": dataTestId ? `${dataTestId}-loading` : "WidgetKPI-loading", children: trend ? (jsx(SkeletonLines, { gap: 6, height: [16, 24, 16], lines: 3, width: [100, 40, 60] })) : (jsx(SkeletonLines, { gap: 6, height: [16, 24], lines: 2, width: [100, 40] })) })) : (jsxs(Fragment, { children: [jsxs("div", { className: "flex flex-1 flex-col justify-center gap-0.5", children: [jsx("div", { className: cvaWidgetKPIHeader(), children: jsxs("div", { className: "flex items-start gap-1", children: [iconName ? (jsx(Icon, { className: "flex-shrink-0 py-0.5", color: iconColor, name: iconName, size: "small" })) : null, jsx(Tooltip, { "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: !tooltipLabel, label: tooltipLabel, placement: "bottom-start", children: jsx(Text, { className: cvaWidgetKPITitleText(), "data-testid": dataTestId ? `${dataTestId}-title` : undefined, children: title }) })] }) }), jsx("div", { className: "flex items-baseline justify-start", children: jsx(Text, { className: cvaWidgetKPIvalueText(), "data-testid": dataTestId ? `${dataTestId}-value` : undefined, type: "div", children: jsx("div", { className: cvaWidgetKPIValueContainer({
307
- isDefaultAndHasTrendValue: Boolean(trend?.value),
308
- className,
309
- }), children: jsxs("span", { className: cvaWidgetKPIvalueText(), children: [value, " ", unit] }) }) }) })] }), jsx("div", { className: "flex min-h-[1lh] items-center gap-1 overflow-hidden", children: trend ? (jsx(TrendIndicator, { isSmallVariant: false, trend: trend, unit: unit })) : notice !== undefined ? (jsx("div", { className: cvaWidgetKPINotice(), children: typeof notice === "string" || typeof notice === "number" ? jsx("span", { children: notice }) : notice })) : null })] })) }));
310
- };
311
- const TrendIndicator = ({ trend, unit, isSmallVariant }) => {
312
- if (!trend) {
313
- return null;
314
- }
315
- return (jsxs("div", { className: "flex flex-row items-center gap-0.5 overflow-hidden", "data-testid": "trend-indicator", children: [!isSmallVariant && trend.value ? (jsxs(Text, { className: cvaWidgetKPITrendValueText(), "data-testid": "trend-value", size: "small", weight: "normal", children: [trend.value, " ", unit] })) : null, trend.variant?.icon ? jsx(Icon, { color: trend.variant.color, name: trend.variant.icon, size: "small" }) : null, trend.percentage ? (jsxs(Text, { className: cvaWidgetKPITrendPercentage({ color: trend.variant?.color }), children: [trend.percentage, "%"] })) : null] }));
294
+ const WidgetKPI = ({ title, value, loading = false, unit, className, "data-testid": dataTestId, tooltipLabel, trends, iconName = undefined, iconColor = "info", notice, ...rest }) => {
295
+ return (jsx("div", { className: cvaWidgetKPI({ className }), "data-testid": dataTestId ?? undefined, ...rest, children: loading ? (jsx("div", { className: "flex flex-col gap-2 pt-6", "data-testid": dataTestId ? `${dataTestId}-loading` : "WidgetKPI-loading", children: trends ? (jsx(SkeletonLines, { gap: 6, height: [16, 24, 16], lines: 3, width: [100, 40, 60] })) : (jsx(SkeletonLines, { gap: 6, height: [16, 24], lines: 2, width: [100, 40] })) })) : (jsxs(Fragment, { children: [jsxs("div", { className: "flex flex-1 flex-col justify-center gap-0.5", children: [jsx("div", { className: cvaWidgetKPIHeader(), children: jsxs("div", { className: "flex items-start gap-1", children: [iconName ? (jsx(Icon, { className: "flex-shrink-0 py-0.5", color: iconColor, name: iconName, size: "small" })) : null, jsx(Tooltip, { "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: !tooltipLabel, label: tooltipLabel, placement: "bottom-start", children: jsx(Text, { className: cvaWidgetKPITitleText(), "data-testid": dataTestId ? `${dataTestId}-title` : undefined, children: title }) })] }) }), jsx("div", { className: "flex items-baseline justify-start", children: jsx(Text, { className: cvaWidgetKPIvalueText(), "data-testid": dataTestId ? `${dataTestId}-value` : undefined, type: "div", children: jsxs("div", { className: cvaWidgetKPIvalueText(), children: [value, " ", unit] }) }) })] }), jsx("div", { className: "flex min-h-[1lh] items-center gap-1 overflow-hidden", children: trends ? (jsx(TrendIndicators, { "data-testid": dataTestId ? `${dataTestId}-trend-indicators` : undefined, trends: trends })) : notice !== undefined ? (jsx(Notice, { "data-testid": dataTestId ? `${dataTestId}-notice` : undefined, size: "small", ...notice, className: "block", iconSize: "small" })) : null })] })) }));
316
296
  };
317
297
 
318
298
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-widgets",
3
- "version": "2.4.14",
3
+ "version": "2.5.0",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,12 +8,12 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "react": "19.0.0",
11
- "@trackunit/react-components": "1.12.13",
12
- "@trackunit/iris-app-runtime-core": "1.10.12",
13
- "@trackunit/css-class-variance-utilities": "1.9.9",
14
- "@trackunit/ui-design-tokens": "1.9.9",
15
- "@trackunit/ui-icons": "1.9.9",
16
- "@trackunit/i18n-library-translation": "1.9.12"
11
+ "@trackunit/react-components": "1.13.0",
12
+ "@trackunit/iris-app-runtime-core": "1.10.13",
13
+ "@trackunit/css-class-variance-utilities": "1.9.10",
14
+ "@trackunit/ui-design-tokens": "1.9.10",
15
+ "@trackunit/ui-icons": "1.9.10",
16
+ "@trackunit/i18n-library-translation": "1.9.13"
17
17
  },
18
18
  "module": "./index.esm.js",
19
19
  "main": "./index.cjs.js",
@@ -1,7 +1,7 @@
1
- import { CommonProps } from "@trackunit/react-components";
1
+ import { CommonProps, NoticeProps, TrendIndicatorProps } from "@trackunit/react-components";
2
2
  import { ActivityColors, CriticalityColors, IntentColors } from "@trackunit/ui-design-tokens";
3
3
  import { IconName } from "@trackunit/ui-icons";
4
- import { ReactElement, ReactNode } from "react";
4
+ import { ReactElement } from "react";
5
5
  export interface WidgetKPIProps extends CommonProps {
6
6
  /**
7
7
  * The title of the WidgetKPI Card
@@ -34,35 +34,13 @@ export interface WidgetKPIProps extends CommonProps {
34
34
  /**
35
35
  * The trend of the WidgetKPI Card
36
36
  */
37
- trend?: {
38
- /**
39
- * The value of the trend
40
- */
41
- value?: number | string;
42
- /**
43
- * The percentage of the trend
44
- */
45
- percentage?: number | string;
46
- /**
47
- * The variant of the trend
48
- */
49
- variant?: {
50
- /**
51
- * The icon of the trend
52
- */
53
- icon?: "ArrowUp" | "ArrowDown" | "ArrowTrendingUp" | "ArrowTrendingDown";
54
- /**
55
- * The color of the trend
56
- */
57
- color?: "success" | "danger" | "neutral";
58
- };
59
- };
37
+ trends?: Array<Omit<TrendIndicatorProps, "className" | "dataTestId">>;
60
38
  /**
61
39
  * Custom notice or text to display in the trend area
62
40
  * If provided, this will override the trend display
63
41
  * Text will be truncated to fit on a single line
64
42
  */
65
- notice?: ReactNode;
43
+ notice?: Pick<NoticeProps, "label" | "iconName" | "iconColor">;
66
44
  }
67
45
  /**
68
46
  * The KPI Widget is a compact and flexible component designed to surface key metrics in a clear, impactful way. It provides at-a-glance insights through bold values, concise labels, and optional contextual elements such as trend indicators or time zones. Its goal is to drive user attention toward meaningful data that prompts action.
@@ -70,4 +48,4 @@ export interface WidgetKPIProps extends CommonProps {
70
48
  * @param {WidgetKPIProps} props - The props for the WidgetKPI component
71
49
  * @returns {ReactElement} WidgetKPI component
72
50
  */
73
- export declare const WidgetKPI: ({ title, value, loading, unit, className, "data-testid": dataTestId, tooltipLabel, trend, iconName, iconColor, notice, ...rest }: WidgetKPIProps) => ReactElement;
51
+ export declare const WidgetKPI: ({ title, value, loading, unit, className, "data-testid": dataTestId, tooltipLabel, trends, iconName, iconColor, notice, ...rest }: WidgetKPIProps) => ReactElement;
@@ -9,6 +9,3 @@ export declare const cvaWidgetKPITrendPercentage: (props?: ({
9
9
  color?: "success" | "danger" | "neutral" | null | undefined;
10
10
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
11
11
  export declare const cvaWidgetKPINotice: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
12
- export declare const cvaWidgetKPIValueContainer: (props?: ({
13
- isDefaultAndHasTrendValue?: boolean | null | undefined;
14
- } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;