@humain/ui 2.1.62 → 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 +10 -333
- 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 +94 -86
- 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 +76 -68
- 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/index198.js
CHANGED
|
@@ -1,505 +1,170 @@
|
|
|
1
1
|
import { cn } from "./index2.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useReducedMotion } from "./index61.js";
|
|
2
|
+
import { LineChart } from "./index64.js";
|
|
3
|
+
import { BarChart } from "./index65.js";
|
|
5
4
|
import { cva } from "class-variance-authority";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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", {
|
|
30
|
-
variants: { variant: {
|
|
31
|
-
line: "",
|
|
32
|
-
area: "",
|
|
33
|
-
layers: ""
|
|
5
|
+
import { ArrowDown, ArrowUp } from "lucide-react";
|
|
6
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/organisms/content/MetricCard/MetricCard.tsx
|
|
9
|
+
var metricCardVariants = cva("bg-background border border-border rounded-xl shadow-sm flex flex-col w-full", {
|
|
10
|
+
variants: { size: {
|
|
11
|
+
sm: "gap-3 p-3",
|
|
12
|
+
md: "gap-5 p-5",
|
|
13
|
+
lg: "gap-6 p-6"
|
|
34
14
|
} },
|
|
35
|
-
defaultVariants: {
|
|
15
|
+
defaultVariants: { size: "md" }
|
|
36
16
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return
|
|
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
|
-
})]
|
|
141
|
-
})]
|
|
142
|
-
});
|
|
17
|
+
var titleSizeClasses = {
|
|
18
|
+
sm: "text-sm",
|
|
19
|
+
md: "text-md",
|
|
20
|
+
lg: "text-lg"
|
|
21
|
+
};
|
|
22
|
+
var valueSizeClasses = {
|
|
23
|
+
sm: "text-display-xs",
|
|
24
|
+
md: "text-display-sm",
|
|
25
|
+
lg: "text-display-md"
|
|
26
|
+
};
|
|
27
|
+
var changeSizeClasses = {
|
|
28
|
+
sm: "text-xs",
|
|
29
|
+
md: "text-sm",
|
|
30
|
+
lg: "text-base"
|
|
31
|
+
};
|
|
32
|
+
var changeSentimentColors = {
|
|
33
|
+
positive: "text-success",
|
|
34
|
+
negative: "text-destructive",
|
|
35
|
+
neutral: "text-muted-foreground"
|
|
36
|
+
};
|
|
37
|
+
function getFiniteMetricValue(value) {
|
|
38
|
+
return Number.isFinite(value) ? value : 0;
|
|
143
39
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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,
|
|
172
|
-
children: [
|
|
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")
|
|
179
|
-
}),
|
|
180
|
-
/* @__PURE__ */ jsx("span", {
|
|
181
|
-
className: "sr-only",
|
|
182
|
-
children: trend === "positive" ? "Increased" : "Decreased"
|
|
183
|
-
}),
|
|
184
|
-
/* @__PURE__ */ jsx("span", {
|
|
185
|
-
className: cn("text-sm font-medium", textColor),
|
|
186
|
-
children: value
|
|
187
|
-
})
|
|
188
|
-
]
|
|
40
|
+
function MetricCardMiniChart({ data, series, chartType, strokeWidth, showArea, showDots, curveType }) {
|
|
41
|
+
if (!data || !series) return null;
|
|
42
|
+
const sharedProps = {
|
|
43
|
+
data,
|
|
44
|
+
series,
|
|
45
|
+
size: "sm",
|
|
46
|
+
showYAxis: false,
|
|
47
|
+
showXAxis: false,
|
|
48
|
+
showTooltip: false,
|
|
49
|
+
className: "h-14 w-28"
|
|
50
|
+
};
|
|
51
|
+
if (chartType === "bar") return /* @__PURE__ */ jsx(BarChart, { ...sharedProps });
|
|
52
|
+
return /* @__PURE__ */ jsx(LineChart, {
|
|
53
|
+
...sharedProps,
|
|
54
|
+
strokeWidth,
|
|
55
|
+
showDots,
|
|
56
|
+
curveType,
|
|
57
|
+
showArea: chartType === "area" || showArea
|
|
189
58
|
});
|
|
190
59
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
"chart-03": "",
|
|
203
|
-
"chart-04": "p-0 bg-transparent border-0 shadow-none"
|
|
204
|
-
},
|
|
205
|
-
breakpoint: {
|
|
206
|
-
desktop: "",
|
|
207
|
-
mobile: ""
|
|
60
|
+
function MetricCard({ value, title, description = "vs last month", change, changeOverride, changeSentiment = "neutral", data, series, chartType = "line", strokeWidth = 2, showArea = true, showDots = false, curveType = "smooth", valueFormatter = (n) => n.toLocaleString(), changeFormatter = (n) => {
|
|
61
|
+
return `${Math.abs(n).toFixed(0)}%`;
|
|
62
|
+
}, size = "md", className, ...props }) {
|
|
63
|
+
const safeValue = getFiniteMetricValue(value);
|
|
64
|
+
const [displayValue, setDisplayValue] = useState(0);
|
|
65
|
+
const hasAnimated = useRef(false);
|
|
66
|
+
const rootRef = useRef(null);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (hasAnimated.current) {
|
|
69
|
+
setDisplayValue(safeValue);
|
|
70
|
+
return;
|
|
208
71
|
}
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
]
|
|
281
|
-
})]
|
|
282
|
-
})
|
|
283
|
-
});
|
|
72
|
+
hasAnimated.current = true;
|
|
73
|
+
const win = rootRef.current?.ownerDocument.defaultView;
|
|
74
|
+
if (!win) {
|
|
75
|
+
setDisplayValue(safeValue);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (win.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
79
|
+
setDisplayValue(safeValue);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const duration = 600;
|
|
83
|
+
const startTime = win.performance.now();
|
|
84
|
+
let frameId;
|
|
85
|
+
const animate = (now) => {
|
|
86
|
+
const elapsed = now - startTime;
|
|
87
|
+
const progress = Math.min(elapsed / duration, 1);
|
|
88
|
+
const eased = 1 - (1 - progress) ** 3;
|
|
89
|
+
setDisplayValue(Math.round(eased * safeValue));
|
|
90
|
+
if (progress < 1) frameId = win.requestAnimationFrame(animate);
|
|
91
|
+
else setDisplayValue(safeValue);
|
|
92
|
+
};
|
|
93
|
+
frameId = win.requestAnimationFrame(animate);
|
|
94
|
+
return () => win.cancelAnimationFrame(frameId);
|
|
95
|
+
}, [safeValue]);
|
|
96
|
+
const calculatedChange = useMemo(() => {
|
|
97
|
+
if (changeOverride !== void 0) return getFiniteMetricValue(changeOverride);
|
|
98
|
+
if (change !== void 0) return getFiniteMetricValue(change);
|
|
99
|
+
if (!data || data.length < 2 || !series || series.length === 0) return void 0;
|
|
100
|
+
const seriesId = series[0].id;
|
|
101
|
+
const firstValue = data[0].values[seriesId];
|
|
102
|
+
const lastValue = data[data.length - 1].values[seriesId];
|
|
103
|
+
if (firstValue === 0 || firstValue === void 0 || !Number.isFinite(firstValue) || !Number.isFinite(lastValue)) return void 0;
|
|
104
|
+
return (lastValue - firstValue) / firstValue * 100;
|
|
105
|
+
}, [
|
|
106
|
+
data,
|
|
107
|
+
series,
|
|
108
|
+
change,
|
|
109
|
+
changeOverride
|
|
110
|
+
]);
|
|
111
|
+
const changeDirection = calculatedChange && calculatedChange > 0 ? "up" : "down";
|
|
284
112
|
return /* @__PURE__ */ jsxs("div", {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
breakpoint
|
|
289
|
-
}), className),
|
|
113
|
+
ref: rootRef,
|
|
114
|
+
"data-slot": "metric-card",
|
|
115
|
+
className: cn(metricCardVariants({ size }), "transition-shadow duration-200 ease-out hover:shadow-md motion-reduce:transition-none", className),
|
|
290
116
|
...props,
|
|
291
|
-
children: [
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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",
|
|
117
|
+
children: [title && /* @__PURE__ */ jsx("h3", {
|
|
118
|
+
className: cn("font-semibold text-foreground", titleSizeClasses[size || "md"]),
|
|
119
|
+
children: title
|
|
120
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
121
|
+
className: "flex items-end gap-4",
|
|
122
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
123
|
+
className: "flex flex-col gap-3 flex-1 min-w-0",
|
|
307
124
|
children: [/* @__PURE__ */ jsx("div", {
|
|
308
|
-
className: cn("
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
},
|
|
332
|
-
children: icon || /* @__PURE__ */ jsx(TrendingUp, {
|
|
333
|
-
width: 20,
|
|
334
|
-
height: 20
|
|
335
|
-
})
|
|
336
|
-
}),
|
|
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
|
-
})]
|
|
125
|
+
className: cn("font-semibold text-foreground", valueSizeClasses[size || "md"]),
|
|
126
|
+
children: valueFormatter(displayValue)
|
|
127
|
+
}), calculatedChange !== void 0 && /* @__PURE__ */ jsxs("div", {
|
|
128
|
+
className: "flex items-center gap-2",
|
|
129
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
130
|
+
className: cn("inline-flex items-center gap-0.5 font-medium", changeSizeClasses[size || "md"], changeSentimentColors[changeSentiment]),
|
|
131
|
+
children: [
|
|
132
|
+
changeDirection === "up" ? /* @__PURE__ */ jsx(ArrowUp, {
|
|
133
|
+
className: "size-4",
|
|
134
|
+
"aria-hidden": "true"
|
|
135
|
+
}) : /* @__PURE__ */ jsx(ArrowDown, {
|
|
136
|
+
className: "size-4",
|
|
137
|
+
"aria-hidden": "true"
|
|
138
|
+
}),
|
|
139
|
+
/* @__PURE__ */ jsx("span", {
|
|
140
|
+
className: "sr-only",
|
|
141
|
+
children: changeDirection === "up" ? "Increased" : "Decreased"
|
|
142
|
+
}),
|
|
143
|
+
/* @__PURE__ */ jsx("span", { children: changeFormatter(calculatedChange) })
|
|
144
|
+
]
|
|
145
|
+
}), description && /* @__PURE__ */ jsx("span", {
|
|
146
|
+
className: cn("font-medium text-muted-foreground", changeSizeClasses[size || "md"]),
|
|
147
|
+
children: description
|
|
391
148
|
})]
|
|
392
|
-
}), chartData && /* @__PURE__ */ jsx(MetricMiniChart, {
|
|
393
|
-
data: chartData,
|
|
394
|
-
width: 112,
|
|
395
|
-
height: 56,
|
|
396
|
-
variant: "line",
|
|
397
|
-
trend: changeTrend
|
|
398
149
|
})]
|
|
399
|
-
}),
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
children:
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
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
|
-
})]
|
|
420
|
-
}),
|
|
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"
|
|
150
|
+
}), data && series && /* @__PURE__ */ jsx("div", {
|
|
151
|
+
"aria-hidden": "true",
|
|
152
|
+
inert: true,
|
|
153
|
+
children: /* @__PURE__ */ jsx(MetricCardMiniChart, {
|
|
154
|
+
data,
|
|
155
|
+
series,
|
|
156
|
+
chartType,
|
|
157
|
+
strokeWidth,
|
|
158
|
+
showArea,
|
|
159
|
+
showDots,
|
|
160
|
+
curveType
|
|
496
161
|
})
|
|
497
|
-
})
|
|
498
|
-
]
|
|
162
|
+
})]
|
|
163
|
+
})]
|
|
499
164
|
});
|
|
500
|
-
}
|
|
501
|
-
|
|
165
|
+
}
|
|
166
|
+
MetricCard.displayName = "MetricCard";
|
|
502
167
|
//#endregion
|
|
503
|
-
export {
|
|
168
|
+
export { MetricCard, metricCardVariants };
|
|
504
169
|
|
|
505
170
|
//# sourceMappingURL=index198.js.map
|