@trackunit/react-components 0.1.291 → 0.1.293

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
@@ -2984,6 +2984,54 @@ const Indicator = (_a) => {
2984
2984
  return (jsxRuntime.jsx(Tooltip, { className: className, disabled: withLabel, label: label, placement: "bottom", children: jsxRuntime.jsxs("div", Object.assign({ "aria-label": label, className: cvaIndicator(), "data-testid": dataTestId }, rest, { children: [jsxRuntime.jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping ? (jsxRuntime.jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })) : null, icon] }), label !== undefined && withLabel ? (jsxRuntime.jsx("div", { className: cvaIndicatorLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label", children: label })) : null] })) }));
2985
2985
  };
2986
2986
 
2987
+ const cvaKPICardContainer = cssClassVarianceUtilities.cvaMerge(["inline-flex"], {
2988
+ variants: {
2989
+ isClickable: {
2990
+ true: ["cursor-pointer"],
2991
+ false: [],
2992
+ },
2993
+ },
2994
+ defaultVariants: {
2995
+ isClickable: false,
2996
+ },
2997
+ });
2998
+ const cvaKPICard = cssClassVarianceUtilities.cvaMerge(["w-full", "bg-white", "p-6", "py-4", "flex", "flex-row", "items-center", "gap-3"], {
2999
+ variants: {
3000
+ isClickable: {
3001
+ true: ["hover:bg-slate-50"],
3002
+ false: [],
3003
+ },
3004
+ },
3005
+ defaultVariants: {
3006
+ isClickable: false,
3007
+ },
3008
+ });
3009
+ const cvaKPICardIconContainer = cssClassVarianceUtilities.cvaMerge(["w-7", "h-7", "flex", "justify-center", "items-center", "rounded"], {
3010
+ variants: {
3011
+ backgroundColor: {
3012
+ info: "bg-primary-500",
3013
+ success: "bg-secondary-500",
3014
+ warning: "bg-yellow-500",
3015
+ danger: "bg-red-500",
3016
+ },
3017
+ },
3018
+ defaultVariants: {
3019
+ backgroundColor: "info",
3020
+ },
3021
+ });
3022
+
3023
+ /**
3024
+ * The KPICard component is used to display KPIs.
3025
+ *
3026
+ * @param {KPICardProps} props - The props for the KPICard component
3027
+ * @returns {JSX.Element} KPICard component
3028
+ */
3029
+ const KPICard = (_a) => {
3030
+ var { asChild = false, title, value, unit, iconName, iconBackgroundColor, className, dataTestId } = _a, rest = __rest(_a, ["asChild", "title", "value", "unit", "iconName", "iconBackgroundColor", "className", "dataTestId"]);
3031
+ const Comp = asChild ? reactSlot.Slot : "div";
3032
+ return (jsxRuntime.jsxs(Comp, Object.assign({ className: cvaKPICardContainer({ className, isClickable: asChild }), "data-testid": `${dataTestId}-comp` }, rest, { children: [jsxRuntime.jsxs(Card, { className: cvaKPICard({ isClickable: asChild }), 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] })] })] }), jsxRuntime.jsx(reactSlot.Slottable, { children: rest.children })] })));
3033
+ };
3034
+
2987
3035
  const cvaMenuItem = cssClassVarianceUtilities.cvaMerge([
2988
3036
  "py-2",
2989
3037
  "pl-2",
@@ -4480,6 +4528,7 @@ exports.Heading = Heading;
4480
4528
  exports.Icon = Icon;
4481
4529
  exports.IconButton = IconButton;
4482
4530
  exports.Indicator = Indicator;
4531
+ exports.KPICard = KPICard;
4483
4532
  exports.MenuItem = MenuItem;
4484
4533
  exports.MenuList = MenuList;
4485
4534
  exports.Modal = Modal;
package/index.esm.js CHANGED
@@ -2953,6 +2953,54 @@ const Indicator = (_a) => {
2953
2953
  return (jsx(Tooltip, { className: className, disabled: withLabel, label: label, placement: "bottom", children: jsxs("div", Object.assign({ "aria-label": label, className: cvaIndicator(), "data-testid": dataTestId }, rest, { children: [jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping ? (jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })) : null, icon] }), label !== undefined && withLabel ? (jsx("div", { className: cvaIndicatorLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label", children: label })) : null] })) }));
2954
2954
  };
2955
2955
 
2956
+ const cvaKPICardContainer = cvaMerge(["inline-flex"], {
2957
+ variants: {
2958
+ isClickable: {
2959
+ true: ["cursor-pointer"],
2960
+ false: [],
2961
+ },
2962
+ },
2963
+ defaultVariants: {
2964
+ isClickable: false,
2965
+ },
2966
+ });
2967
+ const cvaKPICard = cvaMerge(["w-full", "bg-white", "p-6", "py-4", "flex", "flex-row", "items-center", "gap-3"], {
2968
+ variants: {
2969
+ isClickable: {
2970
+ true: ["hover:bg-slate-50"],
2971
+ false: [],
2972
+ },
2973
+ },
2974
+ defaultVariants: {
2975
+ isClickable: false,
2976
+ },
2977
+ });
2978
+ const cvaKPICardIconContainer = cvaMerge(["w-7", "h-7", "flex", "justify-center", "items-center", "rounded"], {
2979
+ variants: {
2980
+ backgroundColor: {
2981
+ info: "bg-primary-500",
2982
+ success: "bg-secondary-500",
2983
+ warning: "bg-yellow-500",
2984
+ danger: "bg-red-500",
2985
+ },
2986
+ },
2987
+ defaultVariants: {
2988
+ backgroundColor: "info",
2989
+ },
2990
+ });
2991
+
2992
+ /**
2993
+ * The KPICard component is used to display KPIs.
2994
+ *
2995
+ * @param {KPICardProps} props - The props for the KPICard component
2996
+ * @returns {JSX.Element} KPICard component
2997
+ */
2998
+ const KPICard = (_a) => {
2999
+ var { asChild = false, title, value, unit, iconName, iconBackgroundColor, className, dataTestId } = _a, rest = __rest(_a, ["asChild", "title", "value", "unit", "iconName", "iconBackgroundColor", "className", "dataTestId"]);
3000
+ const Comp = asChild ? Slot : "div";
3001
+ return (jsxs(Comp, Object.assign({ className: cvaKPICardContainer({ className, isClickable: asChild }), "data-testid": `${dataTestId}-comp` }, rest, { children: [jsxs(Card, { className: cvaKPICard({ isClickable: asChild }), 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] })] })] }), jsx(Slottable, { children: rest.children })] })));
3002
+ };
3003
+
2956
3004
  const cvaMenuItem = cvaMerge([
2957
3005
  "py-2",
2958
3006
  "pl-2",
@@ -4431,4 +4479,4 @@ const useVisibilityChange = ({ onChange, targetState = "hidden" }) => {
4431
4479
  }, [onChange, targetState]);
4432
4480
  };
4433
4481
 
4434
- export { Alert, Badge, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CopyableText, DayPicker, DayRangePicker, Drawer, EmptyState, ExternalLink, Heading, Icon, IconButton, Indicator, MenuItem, MenuList, Modal, ModalBackdrop, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, Timeline, TimelineElement, Tooltip, ValueBar, VirtualizedList, WidgetBody, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaIconButton, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContainerProps, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useModal, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useSelfUpdatingRef, useTimeout, useVisibilityChange };
4482
+ export { Alert, Badge, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CopyableText, DayPicker, DayRangePicker, Drawer, EmptyState, ExternalLink, Heading, Icon, IconButton, Indicator, KPICard, MenuItem, MenuList, Modal, ModalBackdrop, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, Timeline, TimelineElement, Tooltip, ValueBar, VirtualizedList, WidgetBody, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaIconButton, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContainerProps, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useModal, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useSelfUpdatingRef, useTimeout, useVisibilityChange };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.1.291",
3
+ "version": "0.1.293",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -0,0 +1,47 @@
1
+ import { IntentColors } from "@trackunit/ui-design-tokens";
2
+ import { IconName } from "@trackunit/ui-icons";
3
+ import { ReactNode } from "react";
4
+ import { CommonProps } from "../../common";
5
+ export interface KPICardProps extends CommonProps {
6
+ /**
7
+ * The title of the KPI Card
8
+ */
9
+ title: string;
10
+ /**
11
+ * The value of the KPI Card
12
+ */
13
+ value: string | number;
14
+ /**
15
+ * The unit of the KPI Card
16
+ */
17
+ unit: string;
18
+ /**
19
+ * The icon to be displayed in the prefix
20
+ */
21
+ iconName?: IconName;
22
+ /**
23
+ * The icon to be displayed in the prefix
24
+ */
25
+ iconBackgroundColor?: IntentColors;
26
+ /**
27
+ * Use asChild to render the KPICard as another component
28
+ */
29
+ asChild?: boolean;
30
+ /**
31
+ * Only add when asChild is true.
32
+ * The child element is used to wrap the KPICard component to set it to another HTML element.
33
+ *
34
+ * @example
35
+ * <KPICard {...props}>
36
+ * <Link to="/" />
37
+ * </KPICard>
38
+ */
39
+ children?: ReactNode;
40
+ }
41
+ /**
42
+ * The KPICard component is used to display KPIs.
43
+ *
44
+ * @param {KPICardProps} props - The props for the KPICard component
45
+ * @returns {JSX.Element} KPICard component
46
+ */
47
+ export declare const KPICard: ({ asChild, title, value, unit, iconName, iconBackgroundColor, className, dataTestId, ...rest }: KPICardProps) => JSX.Element;
@@ -0,0 +1,9 @@
1
+ export declare const cvaKPICardContainer: (props?: ({
2
+ isClickable?: boolean | null | undefined;
3
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
4
+ export declare const cvaKPICard: (props?: ({
5
+ isClickable?: boolean | null | undefined;
6
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
+ export declare const cvaKPICardIconContainer: (props?: ({
8
+ backgroundColor?: "info" | "success" | "warning" | "danger" | null | undefined;
9
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
@@ -10,6 +10,7 @@ export * from "./ExternalLink/ExternalLink";
10
10
  export * from "./Heading";
11
11
  export * from "./Icon/Icon";
12
12
  export * from "./Indicator";
13
+ export * from "./KPICard/KPICard";
13
14
  export * from "./Menu";
14
15
  export * from "./Modal";
15
16
  export * from "./Notice";