@humain/ui 2.1.63 → 2.1.65
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/dist/components/organisms/ai/AIToolCall/AIToolCall.d.ts +9 -3
- package/dist/components/organisms/ai/AIToolRun/index.d.ts +1 -1
- package/dist/components/organisms/ai/AIToolRun/validation.d.ts +24 -3
- package/dist/components/organisms/ai/_shared/format-ai-duration.d.ts +1 -0
- package/dist/components/organisms/ai/_shared/workflow-step-renderer.d.ts +1 -0
- package/dist/index.js +52 -52
- package/dist/index151.js +1 -1
- package/dist/index174.js +7 -339
- package/dist/index174.js.map +1 -1
- package/dist/index175.js +310 -137
- package/dist/index175.js.map +1 -1
- package/dist/index176.js +148 -174
- package/dist/index176.js.map +1 -1
- package/dist/index177.js +186 -78
- package/dist/index177.js.map +1 -1
- package/dist/index178.js +74 -124
- package/dist/index178.js.map +1 -1
- package/dist/index179.js +133 -1
- package/dist/index179.js.map +1 -0
- package/dist/index180.js +2 -201
- package/dist/index181.js +201 -0
- package/dist/{index180.js.map → index181.js.map} +1 -1
- package/dist/index183.js +130 -166
- package/dist/index183.js.map +1 -1
- package/dist/index184.js +195 -983
- package/dist/index184.js.map +1 -1
- package/dist/index185.js +1069 -369
- package/dist/index185.js.map +1 -1
- package/dist/index186.js +395 -197
- package/dist/index186.js.map +1 -1
- package/dist/index187.js +198 -243
- package/dist/index187.js.map +1 -1
- package/dist/index188.js +263 -3
- package/dist/index188.js.map +1 -1
- package/dist/index189.js +3 -209
- package/dist/index189.js.map +1 -1
- package/dist/index190.js +190 -777
- package/dist/index190.js.map +1 -1
- package/dist/index191.js +771 -252
- package/dist/index191.js.map +1 -1
- package/dist/index192.js +250 -65
- package/dist/index192.js.map +1 -1
- package/dist/index193.js +72 -523
- package/dist/index193.js.map +1 -1
- package/dist/index194.js +537 -144
- package/dist/index194.js.map +1 -1
- package/dist/index195.js +139 -720
- package/dist/index195.js.map +1 -1
- package/dist/index196.js +707 -167
- package/dist/index196.js.map +1 -1
- package/dist/index197.js +175 -151
- package/dist/index197.js.map +1 -1
- package/dist/index198.js +152 -487
- package/dist/index198.js.map +1 -1
- package/dist/index199.js +472 -225
- package/dist/index199.js.map +1 -1
- package/dist/index200.js +236 -260
- package/dist/index200.js.map +1 -1
- package/dist/index201.js +265 -215
- package/dist/index201.js.map +1 -1
- package/dist/index202.js +207 -307
- package/dist/index202.js.map +1 -1
- package/dist/index203.js +302 -135
- package/dist/index203.js.map +1 -1
- package/dist/index204.js +140 -271
- package/dist/index204.js.map +1 -1
- package/dist/index205.js +263 -253
- package/dist/index205.js.map +1 -1
- package/dist/index206.js +244 -137
- package/dist/index206.js.map +1 -1
- package/dist/index207.js +100 -238
- package/dist/index207.js.map +1 -1
- package/dist/index208.js +278 -74
- package/dist/index208.js.map +1 -1
- package/dist/index209.js +56 -97
- package/dist/index209.js.map +1 -1
- package/dist/index210.js +142 -47
- package/dist/index210.js.map +1 -1
- package/dist/index211.js +38 -84
- package/dist/index211.js.map +1 -1
- package/dist/index212.js +72 -252
- package/dist/index212.js.map +1 -1
- package/dist/index213.js +274 -26
- package/dist/index213.js.map +1 -1
- package/dist/index214.js +29 -94
- package/dist/index214.js.map +1 -1
- package/dist/index215.js +98 -25
- package/dist/index215.js.map +1 -1
- package/dist/index216.js +20 -565
- package/dist/index216.js.map +1 -1
- package/dist/index217.js +564 -17
- package/dist/index217.js.map +1 -1
- package/dist/index218.js +20 -23
- package/dist/index218.js.map +1 -1
- package/dist/index219.js +20 -95
- package/dist/index219.js.map +1 -1
- package/dist/index220.js +92 -88
- package/dist/index220.js.map +1 -1
- package/dist/index221.js +97 -29
- package/dist/index221.js.map +1 -1
- package/dist/index222.js +24 -470
- package/dist/index222.js.map +1 -1
- package/dist/index223.js +446 -196
- package/dist/index223.js.map +1 -1
- package/dist/index224.js +199 -729
- package/dist/index224.js.map +1 -1
- package/dist/index225.js +750 -61
- package/dist/index225.js.map +1 -1
- package/dist/index226.js +58 -181
- package/dist/index226.js.map +1 -1
- package/dist/index227.js +175 -259
- package/dist/index227.js.map +1 -1
- package/dist/index228.js +246 -172
- package/dist/index228.js.map +1 -1
- package/dist/index229.js +195 -32
- package/dist/index229.js.map +1 -1
- package/dist/index230.js +12 -40
- package/dist/index230.js.map +1 -1
- package/dist/index231.js +23 -26
- package/dist/index231.js.map +1 -1
- package/dist/index232.js +45 -22
- package/dist/index232.js.map +1 -1
- package/dist/index233.js +27 -48
- package/dist/index233.js.map +1 -1
- package/dist/index234.js +52 -26
- package/dist/index234.js.map +1 -1
- package/dist/index235.js +40 -225
- package/dist/index235.js.map +1 -1
- package/dist/index236.js +217 -39
- package/dist/index236.js.map +1 -1
- package/dist/index237.js +50 -0
- package/dist/index237.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/wc/AIToolCall.js +218 -0
- package/dist/wc/AIToolCall.js.map +1 -0
- package/dist/wc/hf-ai-tool-call.js +34 -219
- package/dist/wc/hf-ai-tool-call.js.map +1 -1
- package/dist/wc/hf-ai-tool-run.js +673 -576
- package/dist/wc/hf-ai-tool-run.js.map +1 -1
- package/dist/wc/workflow-step-renderer.js +79 -78
- package/dist/wc/workflow-step-renderer.js.map +1 -1
- package/dist/wc-react/AIToolCall.js +218 -0
- package/dist/wc-react/AIToolCall.js.map +1 -0
- package/dist/wc-react/hf-ai-tool-call.js +32 -217
- package/dist/wc-react/hf-ai-tool-call.js.map +1 -1
- package/dist/wc-react/hf-ai-tool-run.js +698 -601
- package/dist/wc-react/hf-ai-tool-run.js.map +1 -1
- package/dist/wc-react/workflow-step-renderer.js +58 -57
- package/dist/wc-react/workflow-step-renderer.js.map +1 -1
- package/package.json +1 -1
- package/skills/humain-ui/SKILL.md +1 -1
- package/skills/humain-ui-wc/SKILL.md +1 -1
- package/skills/humain-ui-wc.skill +0 -0
- package/skills/humain-ui.skill +0 -0
- package/dist/index182.js +0 -143
- package/dist/index182.js.map +0 -1
- package/dist/wc/wrench.js +0 -10
- package/dist/wc/wrench.js.map +0 -1
- package/dist/wc-react/wrench.js +0 -10
- package/dist/wc-react/wrench.js.map +0 -1
package/dist/index199.js
CHANGED
|
@@ -1,258 +1,505 @@
|
|
|
1
1
|
import { cn } from "./index2.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Button } from "./index5.js";
|
|
3
|
+
import { ChartContainer } from "./index22.js";
|
|
4
|
+
import { useReducedMotion } from "./index61.js";
|
|
4
5
|
import { cva } from "class-variance-authority";
|
|
5
|
-
import {
|
|
6
|
+
import { ArrowUp, ArrowUpRight, Eye, MoreVertical, TrendingUp } from "lucide-react";
|
|
6
7
|
import * as React from "react";
|
|
7
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Area, AreaChart, Line, LineChart } from "recharts";
|
|
10
|
+
//#region src/components/organisms/content/MetricItem/MetricItem.tsx
|
|
11
|
+
var MINI_CHART_MARGIN = {
|
|
12
|
+
top: 0,
|
|
13
|
+
right: 0,
|
|
14
|
+
bottom: 0,
|
|
15
|
+
left: 0
|
|
16
|
+
};
|
|
17
|
+
function getFiniteMetricNumber(value, fallback = 0) {
|
|
18
|
+
return Number.isFinite(value) ? value : fallback;
|
|
19
|
+
}
|
|
20
|
+
function getFinitePositiveMetricNumber(value, fallback) {
|
|
21
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
22
|
+
}
|
|
23
|
+
function getFinitePositiveMetricNumberOrUndefined(value) {
|
|
24
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
25
|
+
}
|
|
26
|
+
function formatMetricValue(value) {
|
|
27
|
+
return typeof value === "number" ? getFiniteMetricNumber(value).toLocaleString() : value;
|
|
28
|
+
}
|
|
29
|
+
var metricMiniChartVariants = cva("relative shrink-0", {
|
|
24
30
|
variants: { variant: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
error: "border-destructive text-destructive"
|
|
31
|
+
line: "",
|
|
32
|
+
area: "",
|
|
33
|
+
layers: ""
|
|
29
34
|
} },
|
|
30
|
-
defaultVariants: { variant: "
|
|
35
|
+
defaultVariants: { variant: "line" }
|
|
31
36
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
54
|
-
className: "text-secondary-foreground",
|
|
55
|
-
children
|
|
56
|
-
})
|
|
57
|
-
});
|
|
58
|
-
/** Close button */
|
|
59
|
-
var CloseButton = ({ onClick }) => /* @__PURE__ */ jsx("button", {
|
|
60
|
-
type: "button",
|
|
61
|
-
onClick,
|
|
62
|
-
className: "absolute end-1 top-1 flex size-11 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-muted-foreground",
|
|
63
|
-
"aria-label": "Close notification",
|
|
64
|
-
children: /* @__PURE__ */ jsx(X, { className: "size-5" })
|
|
65
|
-
});
|
|
66
|
-
/** Action buttons */
|
|
67
|
-
var ActionButtons = ({ primaryAction, secondaryAction, stacked = false }) => {
|
|
68
|
-
if (!primaryAction && !secondaryAction) return null;
|
|
69
|
-
if (stacked) return /* @__PURE__ */ jsxs("div", {
|
|
70
|
-
className: "flex flex-col gap-2",
|
|
71
|
-
children: [primaryAction && /* @__PURE__ */ jsx("button", {
|
|
72
|
-
type: "button",
|
|
73
|
-
onClick: primaryAction.onClick,
|
|
74
|
-
className: "w-full rounded-lg bg-primary px-3 py-2 text-sm font-semibold text-primary-foreground hover:bg-primary/90 transition-colors duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
75
|
-
children: primaryAction.label
|
|
76
|
-
}), secondaryAction && /* @__PURE__ */ jsx("button", {
|
|
77
|
-
type: "button",
|
|
78
|
-
onClick: secondaryAction.onClick,
|
|
79
|
-
className: "w-full rounded-lg border border-border bg-card px-3 py-2 text-sm font-semibold text-secondary-foreground hover:bg-surface-2 transition-colors duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
80
|
-
children: secondaryAction.label
|
|
81
|
-
})]
|
|
82
|
-
});
|
|
37
|
+
function MetricMiniChart({ data, color, width, height = 56, variant = "line", showMarker = true, trend = "positive", className, ...props }) {
|
|
38
|
+
const gradientId = React.useId();
|
|
39
|
+
const shouldAnimate = !useReducedMotion();
|
|
40
|
+
const chartColor = color || (trend === "positive" ? "var(--success)" : "var(--destructive)");
|
|
41
|
+
const chartWidth = getFinitePositiveMetricNumberOrUndefined(width);
|
|
42
|
+
const chartHeight = getFinitePositiveMetricNumber(height, 56);
|
|
43
|
+
const safeData = React.useMemo(() => data.map((value) => getFiniteMetricNumber(value)), [data]);
|
|
44
|
+
const chartData = React.useMemo(() => safeData.map((value, index) => ({
|
|
45
|
+
index,
|
|
46
|
+
value
|
|
47
|
+
})), [safeData]);
|
|
48
|
+
const chartConfig = React.useMemo(() => ({ value: { color: chartColor } }), [chartColor]);
|
|
49
|
+
const lastValue = safeData[safeData.length - 1] ?? 0;
|
|
50
|
+
const markerTop = React.useMemo(() => {
|
|
51
|
+
const maxValue = safeData.length > 0 ? Math.max(...safeData) : 0;
|
|
52
|
+
return maxValue <= 0 ? 50 : Math.max(10, Math.min(90, 100 - lastValue / maxValue * 100));
|
|
53
|
+
}, [safeData, lastValue]);
|
|
54
|
+
const rootStyle = React.useMemo(() => ({
|
|
55
|
+
width: chartWidth,
|
|
56
|
+
height: chartHeight
|
|
57
|
+
}), [chartHeight, chartWidth]);
|
|
83
58
|
return /* @__PURE__ */ jsxs("div", {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
59
|
+
"data-slot": "metric-mini-chart",
|
|
60
|
+
"aria-hidden": "true",
|
|
61
|
+
inert: true,
|
|
62
|
+
className: cn(metricMiniChartVariants({ variant }), className),
|
|
63
|
+
style: rootStyle,
|
|
64
|
+
...props,
|
|
65
|
+
children: [/* @__PURE__ */ jsx(ChartContainer, {
|
|
66
|
+
config: chartConfig,
|
|
67
|
+
className: "size-full",
|
|
68
|
+
children: variant === "layers" ? /* @__PURE__ */ jsxs(AreaChart, {
|
|
69
|
+
data: chartData,
|
|
70
|
+
margin: MINI_CHART_MARGIN,
|
|
71
|
+
children: [/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", {
|
|
72
|
+
id: `fillArea${gradientId}`,
|
|
73
|
+
x1: "0",
|
|
74
|
+
y1: "0",
|
|
75
|
+
x2: "0",
|
|
76
|
+
y2: "1",
|
|
77
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
78
|
+
offset: "0%",
|
|
79
|
+
stopColor: chartColor,
|
|
80
|
+
stopOpacity: .3
|
|
81
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
82
|
+
offset: "100%",
|
|
83
|
+
stopColor: chartColor,
|
|
84
|
+
stopOpacity: .05
|
|
85
|
+
})]
|
|
86
|
+
}) }), /* @__PURE__ */ jsx(Area, {
|
|
87
|
+
type: "monotone",
|
|
88
|
+
dataKey: "value",
|
|
89
|
+
stroke: chartColor,
|
|
90
|
+
strokeWidth: 2,
|
|
91
|
+
fill: `url(#fillArea${gradientId})`,
|
|
92
|
+
isAnimationActive: shouldAnimate
|
|
93
|
+
})]
|
|
94
|
+
}) : /* @__PURE__ */ jsxs(LineChart, {
|
|
95
|
+
data: chartData,
|
|
96
|
+
margin: MINI_CHART_MARGIN,
|
|
97
|
+
children: [variant === "area" && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", {
|
|
98
|
+
id: `fillLine${gradientId}`,
|
|
99
|
+
x1: "0",
|
|
100
|
+
y1: "0",
|
|
101
|
+
x2: "0",
|
|
102
|
+
y2: "1",
|
|
103
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
104
|
+
offset: "0%",
|
|
105
|
+
stopColor: chartColor,
|
|
106
|
+
stopOpacity: .15
|
|
107
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
108
|
+
offset: "100%",
|
|
109
|
+
stopColor: chartColor,
|
|
110
|
+
stopOpacity: .02
|
|
111
|
+
})]
|
|
112
|
+
}) }), /* @__PURE__ */ jsx(Area, {
|
|
113
|
+
type: "monotone",
|
|
114
|
+
dataKey: "value",
|
|
115
|
+
stroke: "none",
|
|
116
|
+
fill: `url(#fillLine${gradientId})`,
|
|
117
|
+
isAnimationActive: shouldAnimate
|
|
118
|
+
})] }), /* @__PURE__ */ jsx(Line, {
|
|
119
|
+
type: "monotone",
|
|
120
|
+
dataKey: "value",
|
|
121
|
+
stroke: chartColor,
|
|
122
|
+
strokeWidth: 2,
|
|
123
|
+
dot: false,
|
|
124
|
+
isAnimationActive: shouldAnimate
|
|
125
|
+
})]
|
|
126
|
+
})
|
|
127
|
+
}), showMarker && variant === "line" && /* @__PURE__ */ jsxs("div", {
|
|
128
|
+
className: "absolute",
|
|
129
|
+
style: {
|
|
130
|
+
right: 0,
|
|
131
|
+
top: `${markerTop}%`,
|
|
132
|
+
transform: "translate(50%, -50%)"
|
|
133
|
+
},
|
|
134
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
135
|
+
className: "size-[19px] rounded-full opacity-20",
|
|
136
|
+
style: { backgroundColor: chartColor }
|
|
137
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
138
|
+
className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 size-[10px] rounded-full bg-background border-2",
|
|
139
|
+
style: { borderColor: chartColor }
|
|
140
|
+
})]
|
|
95
141
|
})]
|
|
96
142
|
});
|
|
97
|
-
};
|
|
98
|
-
function NotificationLeadingElement({ variant, icon, avatarProps, imageSrc, imageAlt }) {
|
|
99
|
-
switch (variant) {
|
|
100
|
-
case "primary":
|
|
101
|
-
case "success":
|
|
102
|
-
case "warning":
|
|
103
|
-
case "error": return /* @__PURE__ */ jsx(OutlineIcon, { variant });
|
|
104
|
-
case "gray": return icon ? /* @__PURE__ */ jsx(BoxedIcon, { children: icon }) : /* @__PURE__ */ jsx(BoxedIcon, { children: /* @__PURE__ */ jsx(Info, { className: "size-5" }) });
|
|
105
|
-
case "avatar": return /* @__PURE__ */ jsx("div", {
|
|
106
|
-
className: "relative",
|
|
107
|
-
children: /* @__PURE__ */ jsx(Avatar, {
|
|
108
|
-
size: "md",
|
|
109
|
-
indicator: "online",
|
|
110
|
-
...avatarProps
|
|
111
|
-
})
|
|
112
|
-
});
|
|
113
|
-
case "image": return imageSrc ? /* @__PURE__ */ jsx("div", {
|
|
114
|
-
className: "size-[72px] shrink-0 overflow-hidden rounded-lg",
|
|
115
|
-
children: /* @__PURE__ */ jsx("img", {
|
|
116
|
-
src: imageSrc,
|
|
117
|
-
alt: imageAlt || "Notification image",
|
|
118
|
-
loading: "lazy",
|
|
119
|
-
className: "size-full object-cover"
|
|
120
|
-
})
|
|
121
|
-
}) : null;
|
|
122
|
-
case "progress": return icon ? /* @__PURE__ */ jsx(BoxedIcon, { children: icon }) : /* @__PURE__ */ jsx(BoxedIcon, { children: /* @__PURE__ */ jsx(Info, { className: "size-5" }) });
|
|
123
|
-
default: return null;
|
|
124
|
-
}
|
|
125
143
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
144
|
+
MetricMiniChart.displayName = "MetricMiniChart";
|
|
145
|
+
var metricChangeVariants = cva("inline-flex items-center gap-0.5", {
|
|
146
|
+
variants: {
|
|
147
|
+
variant: {
|
|
148
|
+
default: "",
|
|
149
|
+
badge: "bg-background border border-border rounded-md shadow-xs px-1.5 py-0.5"
|
|
150
|
+
},
|
|
151
|
+
trend: {
|
|
152
|
+
positive: "",
|
|
153
|
+
negative: ""
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
defaultVariants: {
|
|
157
|
+
variant: "default",
|
|
158
|
+
trend: "positive"
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
function MetricChange({ value, variant = "default", trend = "positive", icon = "arrow", className, ...props }) {
|
|
162
|
+
const iconColor = trend === "positive" ? "var(--success)" : "var(--destructive)";
|
|
163
|
+
const textColor = variant === "badge" ? "text-secondary-foreground" : trend === "positive" ? "text-success" : "text-destructive";
|
|
164
|
+
const IconComponent = icon === "none" ? null : icon === "trend" ? TrendingUp : icon === "arrow-right" ? ArrowUpRight : ArrowUp;
|
|
165
|
+
const iconSize = variant === "badge" ? 12 : 16;
|
|
166
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
167
|
+
className: cn(metricChangeVariants({
|
|
168
|
+
variant,
|
|
169
|
+
trend
|
|
170
|
+
}), className),
|
|
171
|
+
...props,
|
|
130
172
|
children: [
|
|
131
|
-
/* @__PURE__ */
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
className: "text-sm text-secondary-foreground",
|
|
138
|
-
children: supportingText
|
|
139
|
-
})]
|
|
173
|
+
IconComponent && /* @__PURE__ */ jsx(IconComponent, {
|
|
174
|
+
"aria-hidden": "true",
|
|
175
|
+
width: iconSize,
|
|
176
|
+
height: iconSize,
|
|
177
|
+
color: iconColor,
|
|
178
|
+
className: cn(trend === "negative" && "rotate-180")
|
|
140
179
|
}),
|
|
141
|
-
/* @__PURE__ */ jsx(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
showValue: true,
|
|
145
|
-
labelPosition: "inline",
|
|
146
|
-
valueFormat: (value) => progressLabel || `${value}%`
|
|
180
|
+
/* @__PURE__ */ jsx("span", {
|
|
181
|
+
className: "sr-only",
|
|
182
|
+
children: trend === "positive" ? "Increased" : "Decreased"
|
|
147
183
|
}),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
stacked: stackedActions
|
|
184
|
+
/* @__PURE__ */ jsx("span", {
|
|
185
|
+
className: cn("text-sm font-medium", textColor),
|
|
186
|
+
children: value
|
|
152
187
|
})
|
|
153
188
|
]
|
|
154
189
|
});
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
190
|
+
}
|
|
191
|
+
MetricChange.displayName = "MetricChange";
|
|
192
|
+
var metricItemVariants = cva("relative flex flex-col gap-2 p-5 bg-background rounded-xl border border-border shadow-xs transition-shadow duration-200 ease-out hover:shadow-sm motion-reduce:transition-none", {
|
|
193
|
+
variants: {
|
|
194
|
+
type: {
|
|
195
|
+
simple: "",
|
|
196
|
+
"icon-01": "",
|
|
197
|
+
"icon-02": "",
|
|
198
|
+
"icon-03": "",
|
|
199
|
+
"icon-04": "flex-row items-center",
|
|
200
|
+
"chart-01": "",
|
|
201
|
+
"chart-02": "",
|
|
202
|
+
"chart-03": "",
|
|
203
|
+
"chart-04": "p-0 bg-transparent border-0 shadow-none"
|
|
204
|
+
},
|
|
205
|
+
breakpoint: {
|
|
206
|
+
desktop: "",
|
|
207
|
+
mobile: ""
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
defaultVariants: {
|
|
211
|
+
type: "simple",
|
|
212
|
+
breakpoint: "desktop"
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
var MetricItem = React.memo(function MetricItem({ title, value, changeValue, changeTrend = "positive", changeIcon, comparisonText, subtitle, showDropdown = false, showActions = false, onViewReport, onDropdownClick, icon, iconBgColor, iconColor, chartData, featuredIconVariant = "circle", type = "simple", breakpoint = "desktop", className, children, ...props }) {
|
|
216
|
+
const displayIcon = icon || /* @__PURE__ */ jsx(TrendingUp, {
|
|
217
|
+
width: 24,
|
|
218
|
+
height: 24
|
|
219
|
+
});
|
|
220
|
+
const displayValue = formatMetricValue(value);
|
|
221
|
+
const defaultIconBgColor = type === "icon-01" ? featuredIconVariant === "modern" ? "var(--muted)" : "var(--success-muted)" : type === "icon-02" || type === "icon-03" || type === "icon-04" ? "var(--muted)" : "var(--success-muted)";
|
|
222
|
+
const defaultIconColor = type === "icon-01" ? featuredIconVariant === "modern" ? "var(--secondary-foreground)" : "var(--success)" : type === "icon-02" ? "var(--secondary-foreground)" : "var(--success)";
|
|
223
|
+
const finalIconBgColor = iconBgColor || defaultIconBgColor;
|
|
224
|
+
const finalIconColor = iconColor || defaultIconColor;
|
|
225
|
+
if (type === "chart-04") return /* @__PURE__ */ jsx("div", {
|
|
226
|
+
"data-slot": "metric-item",
|
|
227
|
+
className: cn(metricItemVariants({
|
|
228
|
+
type,
|
|
229
|
+
breakpoint
|
|
230
|
+
}), className),
|
|
231
|
+
...props,
|
|
232
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
233
|
+
className: "flex flex-col gap-0.5 w-full",
|
|
234
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
235
|
+
className: "flex items-center px-5 pt-3 pb-2 w-full",
|
|
236
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
237
|
+
className: "flex-1 text-sm font-semibold text-foreground",
|
|
163
238
|
children: title
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
239
|
+
})
|
|
240
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
241
|
+
className: "relative bg-background border border-border rounded-xl shadow-xs p-5 flex flex-col gap-5",
|
|
242
|
+
children: [
|
|
243
|
+
/* @__PURE__ */ jsxs("div", {
|
|
244
|
+
className: "flex flex-wrap items-center gap-3",
|
|
245
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
246
|
+
className: "text-display-sm font-semibold text-foreground",
|
|
247
|
+
children: displayValue
|
|
248
|
+
}), changeValue && /* @__PURE__ */ jsxs("div", {
|
|
249
|
+
className: "flex items-center gap-2",
|
|
250
|
+
children: [/* @__PURE__ */ jsx(MetricChange, {
|
|
251
|
+
value: changeValue,
|
|
252
|
+
trend: changeTrend,
|
|
253
|
+
icon: changeIcon ?? "trend"
|
|
254
|
+
}), comparisonText && /* @__PURE__ */ jsx("span", {
|
|
255
|
+
className: "text-sm font-medium text-muted-foreground",
|
|
256
|
+
children: comparisonText
|
|
257
|
+
})]
|
|
258
|
+
})]
|
|
259
|
+
}),
|
|
260
|
+
children ? children : chartData ? /* @__PURE__ */ jsx(MetricMiniChart, {
|
|
261
|
+
data: chartData,
|
|
262
|
+
width: void 0,
|
|
263
|
+
height: 56,
|
|
264
|
+
variant: "line",
|
|
265
|
+
showMarker: false,
|
|
266
|
+
trend: changeTrend,
|
|
267
|
+
className: "w-full"
|
|
268
|
+
}) : null,
|
|
269
|
+
showDropdown && /* @__PURE__ */ jsx("button", {
|
|
270
|
+
type: "button",
|
|
271
|
+
"aria-label": "More options",
|
|
272
|
+
className: "absolute top-2 end-2 p-3 cursor-pointer rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background transition-colors duration-150 ease-out hover:text-foreground",
|
|
273
|
+
onClick: onDropdownClick,
|
|
274
|
+
children: /* @__PURE__ */ jsx(MoreVertical, {
|
|
275
|
+
width: 20,
|
|
276
|
+
height: 20,
|
|
277
|
+
className: "text-muted-foreground"
|
|
278
|
+
})
|
|
279
|
+
})
|
|
280
|
+
]
|
|
171
281
|
})]
|
|
172
|
-
})
|
|
173
|
-
primaryAction,
|
|
174
|
-
secondaryAction,
|
|
175
|
-
stacked: stackedActions
|
|
176
|
-
})]
|
|
282
|
+
})
|
|
177
283
|
});
|
|
178
|
-
|
|
179
|
-
|
|
284
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
285
|
+
"data-slot": "metric-item",
|
|
286
|
+
className: cn(metricItemVariants({
|
|
287
|
+
type,
|
|
288
|
+
breakpoint
|
|
289
|
+
}), className),
|
|
290
|
+
...props,
|
|
180
291
|
children: [
|
|
181
|
-
/* @__PURE__ */ jsxs("div", {
|
|
182
|
-
className: "flex
|
|
183
|
-
|
|
184
|
-
|
|
292
|
+
type === "icon-01" && /* @__PURE__ */ jsxs("div", {
|
|
293
|
+
className: cn("flex items-center justify-center shrink-0 relative overflow-clip", featuredIconVariant === "modern" ? "rounded-[10px] border border-border shadow-xs" : featuredIconVariant === "square" ? "rounded-[10px] border border-border shadow-xs" : "rounded-full"),
|
|
294
|
+
style: {
|
|
295
|
+
width: 48,
|
|
296
|
+
height: 48,
|
|
297
|
+
backgroundColor: finalIconBgColor,
|
|
298
|
+
color: finalIconColor
|
|
299
|
+
},
|
|
300
|
+
children: [displayIcon, featuredIconVariant === "modern" && /* @__PURE__ */ jsx("div", {
|
|
301
|
+
className: "absolute inset-0 pointer-events-none rounded-[10px]",
|
|
302
|
+
style: { boxShadow: "var(--shadow-inset-ring)" }
|
|
303
|
+
})]
|
|
304
|
+
}),
|
|
305
|
+
(type === "icon-02" || type === "icon-03") && /* @__PURE__ */ jsxs("div", {
|
|
306
|
+
className: "flex items-center gap-3 w-full",
|
|
307
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
308
|
+
className: cn("flex items-center justify-center shrink-0", type === "icon-02" ? "rounded-full" : "rounded-lg border border-border shadow-xs"),
|
|
309
|
+
style: {
|
|
310
|
+
width: 48,
|
|
311
|
+
height: 48,
|
|
312
|
+
backgroundColor: finalIconBgColor,
|
|
313
|
+
color: finalIconColor
|
|
314
|
+
},
|
|
315
|
+
children: icon || /* @__PURE__ */ jsx(Eye, {
|
|
316
|
+
width: 24,
|
|
317
|
+
height: 24
|
|
318
|
+
})
|
|
319
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
320
|
+
className: "flex-1 text-base font-semibold text-foreground",
|
|
185
321
|
children: title
|
|
186
|
-
}), supportingText && /* @__PURE__ */ jsx("p", {
|
|
187
|
-
className: "text-sm text-secondary-foreground",
|
|
188
|
-
children: supportingText
|
|
189
322
|
})]
|
|
190
323
|
}),
|
|
191
|
-
|
|
192
|
-
className: "
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
324
|
+
type === "icon-04" && /* @__PURE__ */ jsx("div", {
|
|
325
|
+
className: cn("flex items-center justify-center shrink-0 rounded-md border border-border shadow-xs"),
|
|
326
|
+
style: {
|
|
327
|
+
width: 40,
|
|
328
|
+
height: 40,
|
|
329
|
+
backgroundColor: finalIconBgColor,
|
|
330
|
+
color: finalIconColor
|
|
331
|
+
},
|
|
332
|
+
children: icon || /* @__PURE__ */ jsx(TrendingUp, {
|
|
333
|
+
width: 20,
|
|
334
|
+
height: 20
|
|
198
335
|
})
|
|
199
336
|
}),
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
337
|
+
type !== "icon-02" && type !== "icon-03" && /* @__PURE__ */ jsxs("div", {
|
|
338
|
+
className: cn("flex flex-col gap-2", type === "icon-04" ? "flex-1 min-w-0" : "w-full"),
|
|
339
|
+
children: [type === "chart-01" || type === "chart-02" ? /* @__PURE__ */ jsx("p", {
|
|
340
|
+
className: "text-base font-semibold text-foreground",
|
|
341
|
+
children: title
|
|
342
|
+
}) : type === "icon-04" || type === "icon-01" ? /* @__PURE__ */ jsx("p", {
|
|
343
|
+
className: "text-sm font-semibold text-muted-foreground",
|
|
344
|
+
children: title
|
|
345
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
346
|
+
className: "text-sm font-medium text-muted-foreground",
|
|
347
|
+
children: title
|
|
348
|
+
}), type === "simple" || type === "icon-01" || type === "icon-04" ? /* @__PURE__ */ jsxs("div", {
|
|
349
|
+
className: "flex flex-wrap items-center justify-between gap-3 w-full",
|
|
350
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
351
|
+
className: "text-display-sm font-semibold text-foreground",
|
|
352
|
+
children: displayValue
|
|
353
|
+
}), changeValue && comparisonText ? /* @__PURE__ */ jsxs("div", {
|
|
354
|
+
className: "flex items-center gap-2",
|
|
355
|
+
children: [/* @__PURE__ */ jsx(MetricChange, {
|
|
356
|
+
value: changeValue,
|
|
357
|
+
trend: changeTrend,
|
|
358
|
+
icon: "arrow"
|
|
359
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
360
|
+
className: "text-sm font-medium text-muted-foreground",
|
|
361
|
+
children: comparisonText
|
|
362
|
+
})]
|
|
363
|
+
}) : changeValue ? /* @__PURE__ */ jsx(MetricChange, {
|
|
364
|
+
value: changeValue,
|
|
365
|
+
trend: changeTrend,
|
|
366
|
+
icon: changeIcon ?? "arrow-right",
|
|
367
|
+
variant: "badge"
|
|
368
|
+
}) : subtitle ? /* @__PURE__ */ jsx("span", {
|
|
369
|
+
className: "text-sm font-medium text-muted-foreground",
|
|
370
|
+
children: subtitle
|
|
371
|
+
}) : null]
|
|
372
|
+
}) : null]
|
|
373
|
+
}),
|
|
374
|
+
type === "chart-01" && /* @__PURE__ */ jsxs("div", {
|
|
375
|
+
className: "flex items-end gap-4 w-full",
|
|
376
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
377
|
+
className: "flex-1 flex flex-col gap-3",
|
|
378
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
379
|
+
className: "text-display-sm font-semibold text-foreground",
|
|
380
|
+
children: displayValue
|
|
381
|
+
}), (changeValue || comparisonText) && /* @__PURE__ */ jsxs("div", {
|
|
382
|
+
className: "flex items-center gap-2",
|
|
383
|
+
children: [changeValue && /* @__PURE__ */ jsx(MetricChange, {
|
|
384
|
+
value: changeValue,
|
|
385
|
+
trend: changeTrend,
|
|
386
|
+
icon: "arrow"
|
|
387
|
+
}), comparisonText && /* @__PURE__ */ jsx("span", {
|
|
388
|
+
className: "text-sm font-medium text-muted-foreground truncate",
|
|
389
|
+
children: comparisonText
|
|
390
|
+
})]
|
|
391
|
+
})]
|
|
392
|
+
}), chartData && /* @__PURE__ */ jsx(MetricMiniChart, {
|
|
393
|
+
data: chartData,
|
|
394
|
+
width: 112,
|
|
395
|
+
height: 56,
|
|
396
|
+
variant: "line",
|
|
397
|
+
trend: changeTrend
|
|
398
|
+
})]
|
|
236
399
|
}),
|
|
237
|
-
/* @__PURE__ */
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
400
|
+
type === "chart-02" && /* @__PURE__ */ jsxs("div", {
|
|
401
|
+
className: "flex items-end gap-4 w-full",
|
|
402
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
403
|
+
className: "flex-1 flex items-start gap-2",
|
|
404
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
405
|
+
className: "text-display-md font-semibold text-foreground",
|
|
406
|
+
children: displayValue
|
|
407
|
+
}), changeValue && /* @__PURE__ */ jsx(MetricChange, {
|
|
408
|
+
value: changeValue,
|
|
409
|
+
trend: changeTrend,
|
|
410
|
+
icon: "trend"
|
|
411
|
+
})]
|
|
412
|
+
}), chartData && /* @__PURE__ */ jsx(MetricMiniChart, {
|
|
413
|
+
data: chartData,
|
|
414
|
+
width: 128,
|
|
415
|
+
height: 56,
|
|
416
|
+
variant: "layers",
|
|
417
|
+
showMarker: false,
|
|
418
|
+
trend: changeTrend
|
|
419
|
+
})]
|
|
249
420
|
}),
|
|
250
|
-
|
|
421
|
+
type === "chart-03" && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
422
|
+
className: "flex flex-col gap-2 w-full",
|
|
423
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
424
|
+
className: "text-sm font-medium text-muted-foreground",
|
|
425
|
+
children: title
|
|
426
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
427
|
+
className: "flex flex-wrap items-center justify-between gap-3 w-full",
|
|
428
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
429
|
+
className: "text-display-sm font-semibold text-foreground",
|
|
430
|
+
children: displayValue
|
|
431
|
+
}), (changeValue || comparisonText) && /* @__PURE__ */ jsxs("div", {
|
|
432
|
+
className: "flex items-center gap-2",
|
|
433
|
+
children: [changeValue && /* @__PURE__ */ jsx(MetricChange, {
|
|
434
|
+
value: changeValue,
|
|
435
|
+
trend: changeTrend,
|
|
436
|
+
icon: "trend"
|
|
437
|
+
}), comparisonText && /* @__PURE__ */ jsx("span", {
|
|
438
|
+
className: "text-sm font-medium text-muted-foreground",
|
|
439
|
+
children: comparisonText
|
|
440
|
+
})]
|
|
441
|
+
})]
|
|
442
|
+
})]
|
|
443
|
+
}), chartData && /* @__PURE__ */ jsx(MetricMiniChart, {
|
|
444
|
+
data: chartData,
|
|
445
|
+
height: 72,
|
|
446
|
+
variant: "area",
|
|
447
|
+
showMarker: false,
|
|
448
|
+
trend: changeTrend,
|
|
449
|
+
className: "w-full"
|
|
450
|
+
})] }),
|
|
451
|
+
(type === "icon-02" || type === "icon-03") && /* @__PURE__ */ jsxs("div", {
|
|
452
|
+
className: "flex items-end gap-4 w-full",
|
|
453
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
454
|
+
className: "flex-1 flex flex-col gap-3",
|
|
455
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
456
|
+
className: "text-display-md font-semibold text-foreground",
|
|
457
|
+
children: displayValue
|
|
458
|
+
}), (changeValue || comparisonText) && /* @__PURE__ */ jsxs("div", {
|
|
459
|
+
className: "flex items-center gap-2",
|
|
460
|
+
children: [changeValue && /* @__PURE__ */ jsx(MetricChange, {
|
|
461
|
+
value: changeValue,
|
|
462
|
+
trend: changeTrend,
|
|
463
|
+
icon: type === "icon-03" ? "trend" : "arrow"
|
|
464
|
+
}), comparisonText && /* @__PURE__ */ jsx("span", {
|
|
465
|
+
className: "text-sm font-medium text-muted-foreground truncate",
|
|
466
|
+
children: comparisonText
|
|
467
|
+
})]
|
|
468
|
+
})]
|
|
469
|
+
}), chartData && /* @__PURE__ */ jsx(MetricMiniChart, {
|
|
470
|
+
data: chartData,
|
|
471
|
+
width: 112,
|
|
472
|
+
height: 56,
|
|
473
|
+
variant: "line",
|
|
474
|
+
trend: changeTrend
|
|
475
|
+
})]
|
|
476
|
+
}),
|
|
477
|
+
showDropdown && /* @__PURE__ */ jsx("button", {
|
|
478
|
+
type: "button",
|
|
479
|
+
"aria-label": "More options",
|
|
480
|
+
className: "absolute top-2 end-2 cursor-pointer rounded-sm p-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background transition-colors duration-150 ease-out hover:text-foreground",
|
|
481
|
+
onClick: onDropdownClick,
|
|
482
|
+
children: /* @__PURE__ */ jsx(MoreVertical, {
|
|
483
|
+
width: 20,
|
|
484
|
+
height: 20,
|
|
485
|
+
className: "text-muted-foreground"
|
|
486
|
+
})
|
|
487
|
+
}),
|
|
488
|
+
showActions && /* @__PURE__ */ jsx("div", {
|
|
489
|
+
className: "flex items-center gap-2 pt-2",
|
|
490
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
491
|
+
appearance: "outline",
|
|
492
|
+
variant: "secondary",
|
|
493
|
+
size: "sm",
|
|
494
|
+
onClick: onViewReport,
|
|
495
|
+
children: "View report"
|
|
496
|
+
})
|
|
497
|
+
})
|
|
251
498
|
]
|
|
252
499
|
});
|
|
253
500
|
});
|
|
254
|
-
|
|
501
|
+
MetricItem.displayName = "MetricItem";
|
|
255
502
|
//#endregion
|
|
256
|
-
export {
|
|
503
|
+
export { MetricChange, MetricItem, MetricMiniChart, metricChangeVariants, metricItemVariants, metricMiniChartVariants };
|
|
257
504
|
|
|
258
505
|
//# sourceMappingURL=index199.js.map
|