@trackunit/react-widgets 2.0.0 → 2.1.1

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
@@ -245,7 +245,8 @@ const cvaWidgetKPI = cssClassVarianceUtilities.cvaMerge(["w-full", "h-full", "fl
245
245
  const cvaWidgetKPIHeader = cssClassVarianceUtilities.cvaMerge(["flex", "flex-row", "", "place-items-end", "gap-2", "h-10"]);
246
246
  const cvaWidgetKPITitleText = cssClassVarianceUtilities.cvaMerge([
247
247
  "leading-tight",
248
- "break-words",
248
+ "!line-clamp-2",
249
+ "!overflow-hidden",
249
250
  "flex",
250
251
  "items-start",
251
252
  "text-sm",
@@ -255,7 +256,7 @@ const cvaWidgetKPITitleText = cssClassVarianceUtilities.cvaMerge([
255
256
  const cvaWidgetKPIvalueText = cssClassVarianceUtilities.cvaMerge(["truncate", "whitespace-nowrap", "text-3xl", "font-medium"]);
256
257
  const cvaWidgetKPITrendValueText = cssClassVarianceUtilities.cvaMerge([
257
258
  "text-xs",
258
- "font-semibold",
259
+ "font-normal",
259
260
  "whitespace-nowrap",
260
261
  "truncate",
261
262
  "overflow-hidden",
@@ -272,6 +273,7 @@ const cvaWidgetKPITrendPercentage = cssClassVarianceUtilities.cvaMerge(["text-xs
272
273
  color: "success",
273
274
  },
274
275
  });
276
+ const cvaWidgetKPINotice = cssClassVarianceUtilities.cvaMerge(["flex", "items-center", "gap-1", "text-xs", "font-normal"]);
275
277
  const cvaWidgetKPIValueContainer = cssClassVarianceUtilities.cvaMerge(["truncate", "whitespace-nowrap"], {
276
278
  variants: {
277
279
  isDefaultAndHasTrendValue: {
@@ -285,16 +287,16 @@ const cvaWidgetKPIValueContainer = cssClassVarianceUtilities.cvaMerge(["truncate
285
287
  });
286
288
 
287
289
  /**
288
- * The WidgetKPI component is used to display WidgetKPIs.
290
+ * 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.
289
291
  *
290
292
  * @param {WidgetKPIProps} props - The props for the WidgetKPI component
291
293
  * @returns {ReactElement} WidgetKPI component
292
294
  */
293
- const WidgetKPI = ({ title, value, loading, unit, className, dataTestId, tooltipLabel, trend, iconName, iconColor = "info", ...rest }) => {
294
- return (jsxRuntime.jsx("div", { className: cvaWidgetKPI({ className }), "data-testid": dataTestId ? `${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, { height: [16, 24, 16], lines: 3, margin: "6px 0", width: [100, 40, 60] })) : (jsxRuntime.jsx(reactComponents.SkeletonLines, { height: [16, 24], lines: 2, margin: "6px 0", width: [100, 40] })) })) : (jsxRuntime.jsxs("div", { className: "flex h-full flex-col justify-between", children: [jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", 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, { dataTestId: dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: !tooltipLabel, label: tooltipLabel, placement: "bottom", children: jsxRuntime.jsx(reactComponents.Text, { className: cvaWidgetKPITitleText(), dataTestId: dataTestId ? `${dataTestId}-title` : undefined, children: title }) })] }) }), jsxRuntime.jsx("div", { className: "flex items-end", children: jsxRuntime.jsx(reactComponents.Text, { className: cvaWidgetKPIvalueText(), dataTestId: dataTestId ? `${dataTestId}-value` : undefined, type: "div", children: jsxRuntime.jsx("div", { className: cvaWidgetKPIValueContainer({
295
+ const WidgetKPI = ({ title, value, loading, unit, className, dataTestId, tooltipLabel, trend, iconName, iconColor = "info", notice, ...rest }) => {
296
+ return (jsxRuntime.jsx("div", { className: cvaWidgetKPI({ className }), "data-testid": dataTestId ? `${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, { height: [16, 24, 16], lines: 3, margin: "6px 0", width: [100, 40, 60] })) : (jsxRuntime.jsx(reactComponents.SkeletonLines, { height: [16, 24], lines: 2, margin: "6px 0", width: [100, 40] })) })) : (jsxRuntime.jsxs("div", { className: "flex h-full flex-col justify-between", children: [jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", 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, { dataTestId: dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: !tooltipLabel, label: tooltipLabel, placement: "bottom-start", children: jsxRuntime.jsx(reactComponents.Text, { className: cvaWidgetKPITitleText(), dataTestId: dataTestId ? `${dataTestId}-title` : undefined, children: title }) })] }) }), jsxRuntime.jsx("div", { className: "flex items-end", children: jsxRuntime.jsx(reactComponents.Text, { className: cvaWidgetKPIvalueText(), dataTestId: dataTestId ? `${dataTestId}-value` : undefined, type: "div", children: jsxRuntime.jsx("div", { className: cvaWidgetKPIValueContainer({
295
297
  isDefaultAndHasTrendValue: Boolean(trend?.value),
296
298
  className,
297
- }), children: jsxRuntime.jsxs("span", { className: cvaWidgetKPIvalueText(), children: [value, " ", unit] }) }) }) })] }), trend ? (jsxRuntime.jsx("div", { className: "flex items-center gap-1", children: jsxRuntime.jsx(TrendIndicator, { isSmallVariant: false, trend: trend, unit: unit }) })) : null] })) }));
299
+ }), children: jsxRuntime.jsxs("span", { className: cvaWidgetKPIvalueText(), children: [value, " ", unit] }) }) }) })] }), trend ? (jsxRuntime.jsx("div", { className: "flex items-center gap-1", children: jsxRuntime.jsx(TrendIndicator, { isSmallVariant: false, trend: trend, unit: unit }) })) : notice ? (jsxRuntime.jsx("div", { className: cvaWidgetKPINotice(), children: jsxRuntime.jsx("div", { className: "flex flex-1 items-center gap-1", children: notice }) })) : null] })) }));
298
300
  };
299
301
  const TrendIndicator = ({ trend, unit, isSmallVariant }) => {
300
302
  if (!trend) {
package/index.esm.js CHANGED
@@ -243,7 +243,8 @@ const cvaWidgetKPI = cvaMerge(["w-full", "h-full", "flex", "flex-col", "flex-1",
243
243
  const cvaWidgetKPIHeader = cvaMerge(["flex", "flex-row", "", "place-items-end", "gap-2", "h-10"]);
244
244
  const cvaWidgetKPITitleText = cvaMerge([
245
245
  "leading-tight",
246
- "break-words",
246
+ "!line-clamp-2",
247
+ "!overflow-hidden",
247
248
  "flex",
248
249
  "items-start",
249
250
  "text-sm",
@@ -253,7 +254,7 @@ const cvaWidgetKPITitleText = cvaMerge([
253
254
  const cvaWidgetKPIvalueText = cvaMerge(["truncate", "whitespace-nowrap", "text-3xl", "font-medium"]);
254
255
  const cvaWidgetKPITrendValueText = cvaMerge([
255
256
  "text-xs",
256
- "font-semibold",
257
+ "font-normal",
257
258
  "whitespace-nowrap",
258
259
  "truncate",
259
260
  "overflow-hidden",
@@ -270,6 +271,7 @@ const cvaWidgetKPITrendPercentage = cvaMerge(["text-xs", "font-semibold"], {
270
271
  color: "success",
271
272
  },
272
273
  });
274
+ const cvaWidgetKPINotice = cvaMerge(["flex", "items-center", "gap-1", "text-xs", "font-normal"]);
273
275
  const cvaWidgetKPIValueContainer = cvaMerge(["truncate", "whitespace-nowrap"], {
274
276
  variants: {
275
277
  isDefaultAndHasTrendValue: {
@@ -283,16 +285,16 @@ const cvaWidgetKPIValueContainer = cvaMerge(["truncate", "whitespace-nowrap"], {
283
285
  });
284
286
 
285
287
  /**
286
- * The WidgetKPI component is used to display WidgetKPIs.
288
+ * 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.
287
289
  *
288
290
  * @param {WidgetKPIProps} props - The props for the WidgetKPI component
289
291
  * @returns {ReactElement} WidgetKPI component
290
292
  */
291
- const WidgetKPI = ({ title, value, loading, unit, className, dataTestId, tooltipLabel, trend, iconName, iconColor = "info", ...rest }) => {
292
- return (jsx("div", { className: cvaWidgetKPI({ className }), "data-testid": dataTestId ? `${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, { height: [16, 24, 16], lines: 3, margin: "6px 0", width: [100, 40, 60] })) : (jsx(SkeletonLines, { height: [16, 24], lines: 2, margin: "6px 0", width: [100, 40] })) })) : (jsxs("div", { className: "flex h-full flex-col justify-between", children: [jsxs("div", { className: "flex flex-col gap-1", 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, { dataTestId: dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: !tooltipLabel, label: tooltipLabel, placement: "bottom", children: jsx(Text, { className: cvaWidgetKPITitleText(), dataTestId: dataTestId ? `${dataTestId}-title` : undefined, children: title }) })] }) }), jsx("div", { className: "flex items-end", children: jsx(Text, { className: cvaWidgetKPIvalueText(), dataTestId: dataTestId ? `${dataTestId}-value` : undefined, type: "div", children: jsx("div", { className: cvaWidgetKPIValueContainer({
293
+ const WidgetKPI = ({ title, value, loading, unit, className, dataTestId, tooltipLabel, trend, iconName, iconColor = "info", notice, ...rest }) => {
294
+ return (jsx("div", { className: cvaWidgetKPI({ className }), "data-testid": dataTestId ? `${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, { height: [16, 24, 16], lines: 3, margin: "6px 0", width: [100, 40, 60] })) : (jsx(SkeletonLines, { height: [16, 24], lines: 2, margin: "6px 0", width: [100, 40] })) })) : (jsxs("div", { className: "flex h-full flex-col justify-between", children: [jsxs("div", { className: "flex flex-col gap-1", 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, { dataTestId: dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: !tooltipLabel, label: tooltipLabel, placement: "bottom-start", children: jsx(Text, { className: cvaWidgetKPITitleText(), dataTestId: dataTestId ? `${dataTestId}-title` : undefined, children: title }) })] }) }), jsx("div", { className: "flex items-end", children: jsx(Text, { className: cvaWidgetKPIvalueText(), dataTestId: dataTestId ? `${dataTestId}-value` : undefined, type: "div", children: jsx("div", { className: cvaWidgetKPIValueContainer({
293
295
  isDefaultAndHasTrendValue: Boolean(trend?.value),
294
296
  className,
295
- }), children: jsxs("span", { className: cvaWidgetKPIvalueText(), children: [value, " ", unit] }) }) }) })] }), trend ? (jsx("div", { className: "flex items-center gap-1", children: jsx(TrendIndicator, { isSmallVariant: false, trend: trend, unit: unit }) })) : null] })) }));
297
+ }), children: jsxs("span", { className: cvaWidgetKPIvalueText(), children: [value, " ", unit] }) }) }) })] }), trend ? (jsx("div", { className: "flex items-center gap-1", children: jsx(TrendIndicator, { isSmallVariant: false, trend: trend, unit: unit }) })) : notice ? (jsx("div", { className: cvaWidgetKPINotice(), children: jsx("div", { className: "flex flex-1 items-center gap-1", children: notice }) })) : null] })) }));
296
298
  };
297
299
  const TrendIndicator = ({ trend, unit, isSmallVariant }) => {
298
300
  if (!trend) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-widgets",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,15 +8,15 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "react": "19.0.0",
11
- "@trackunit/react-components": "1.6.9",
12
- "@trackunit/iris-app-runtime-core": "1.6.9",
13
- "@trackunit/css-class-variance-utilities": "1.5.8",
14
- "@trackunit/ui-design-tokens": "1.5.8",
15
- "@trackunit/ui-icons": "1.5.8",
16
- "@trackunit/react-table-pagination": "1.5.8",
17
- "@trackunit/shared-utils": "1.7.8",
18
- "@trackunit/i18n-library-translation": "1.5.9",
19
- "@trackunit/react-test-setup": "1.2.8"
11
+ "@trackunit/react-components": "1.7.0",
12
+ "@trackunit/iris-app-runtime-core": "1.7.0",
13
+ "@trackunit/css-class-variance-utilities": "1.6.0",
14
+ "@trackunit/ui-design-tokens": "1.6.0",
15
+ "@trackunit/ui-icons": "1.6.0",
16
+ "@trackunit/react-table-pagination": "1.6.0",
17
+ "@trackunit/shared-utils": "1.8.0",
18
+ "@trackunit/i18n-library-translation": "1.6.0",
19
+ "@trackunit/react-test-setup": "1.3.0"
20
20
  },
21
21
  "module": "./index.esm.js",
22
22
  "main": "./index.cjs.js",
@@ -1,7 +1,7 @@
1
1
  import { CommonProps } 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 } from "react";
4
+ import { ReactElement, ReactNode } from "react";
5
5
  export interface WidgetKPIProps extends CommonProps {
6
6
  /**
7
7
  * The title of the WidgetKPI Card
@@ -57,11 +57,16 @@ export interface WidgetKPIProps extends CommonProps {
57
57
  color?: "success" | "danger" | "neutral";
58
58
  };
59
59
  };
60
+ /**
61
+ * Custom notice or text to display in the trend area
62
+ * If provided, this will override the trend display
63
+ */
64
+ notice?: ReactNode;
60
65
  }
61
66
  /**
62
- * The WidgetKPI component is used to display WidgetKPIs.
67
+ * 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.
63
68
  *
64
69
  * @param {WidgetKPIProps} props - The props for the WidgetKPI component
65
70
  * @returns {ReactElement} WidgetKPI component
66
71
  */
67
- export declare const WidgetKPI: ({ title, value, loading, unit, className, dataTestId, tooltipLabel, trend, iconName, iconColor, ...rest }: WidgetKPIProps) => ReactElement;
72
+ export declare const WidgetKPI: ({ title, value, loading, unit, className, dataTestId, tooltipLabel, trend, iconName, iconColor, notice, ...rest }: WidgetKPIProps) => ReactElement;
@@ -8,6 +8,7 @@ export declare const cvaWidgetKPITrendValueText: (props?: import("class-variance
8
8
  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
+ export declare const cvaWidgetKPINotice: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
11
12
  export declare const cvaWidgetKPIValueContainer: (props?: ({
12
13
  isDefaultAndHasTrendValue?: boolean | null | undefined;
13
14
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;