@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.
Files changed (160) hide show
  1. package/dist/components/organisms/ai/AIToolCall/AIToolCall.d.ts +9 -3
  2. package/dist/components/organisms/ai/AIToolRun/index.d.ts +1 -1
  3. package/dist/components/organisms/ai/AIToolRun/validation.d.ts +24 -3
  4. package/dist/components/organisms/ai/_shared/format-ai-duration.d.ts +1 -0
  5. package/dist/components/organisms/ai/_shared/workflow-step-renderer.d.ts +1 -0
  6. package/dist/index.js +52 -52
  7. package/dist/index151.js +1 -1
  8. package/dist/index174.js +7 -339
  9. package/dist/index174.js.map +1 -1
  10. package/dist/index175.js +310 -137
  11. package/dist/index175.js.map +1 -1
  12. package/dist/index176.js +148 -174
  13. package/dist/index176.js.map +1 -1
  14. package/dist/index177.js +186 -78
  15. package/dist/index177.js.map +1 -1
  16. package/dist/index178.js +74 -124
  17. package/dist/index178.js.map +1 -1
  18. package/dist/index179.js +133 -1
  19. package/dist/index179.js.map +1 -0
  20. package/dist/index180.js +2 -201
  21. package/dist/index181.js +201 -0
  22. package/dist/{index180.js.map → index181.js.map} +1 -1
  23. package/dist/index183.js +130 -166
  24. package/dist/index183.js.map +1 -1
  25. package/dist/index184.js +195 -983
  26. package/dist/index184.js.map +1 -1
  27. package/dist/index185.js +1069 -369
  28. package/dist/index185.js.map +1 -1
  29. package/dist/index186.js +395 -197
  30. package/dist/index186.js.map +1 -1
  31. package/dist/index187.js +198 -243
  32. package/dist/index187.js.map +1 -1
  33. package/dist/index188.js +263 -3
  34. package/dist/index188.js.map +1 -1
  35. package/dist/index189.js +3 -209
  36. package/dist/index189.js.map +1 -1
  37. package/dist/index190.js +190 -777
  38. package/dist/index190.js.map +1 -1
  39. package/dist/index191.js +771 -252
  40. package/dist/index191.js.map +1 -1
  41. package/dist/index192.js +250 -65
  42. package/dist/index192.js.map +1 -1
  43. package/dist/index193.js +72 -523
  44. package/dist/index193.js.map +1 -1
  45. package/dist/index194.js +537 -144
  46. package/dist/index194.js.map +1 -1
  47. package/dist/index195.js +139 -720
  48. package/dist/index195.js.map +1 -1
  49. package/dist/index196.js +707 -167
  50. package/dist/index196.js.map +1 -1
  51. package/dist/index197.js +175 -151
  52. package/dist/index197.js.map +1 -1
  53. package/dist/index198.js +152 -487
  54. package/dist/index198.js.map +1 -1
  55. package/dist/index199.js +472 -225
  56. package/dist/index199.js.map +1 -1
  57. package/dist/index200.js +236 -260
  58. package/dist/index200.js.map +1 -1
  59. package/dist/index201.js +265 -215
  60. package/dist/index201.js.map +1 -1
  61. package/dist/index202.js +207 -307
  62. package/dist/index202.js.map +1 -1
  63. package/dist/index203.js +302 -135
  64. package/dist/index203.js.map +1 -1
  65. package/dist/index204.js +140 -271
  66. package/dist/index204.js.map +1 -1
  67. package/dist/index205.js +263 -253
  68. package/dist/index205.js.map +1 -1
  69. package/dist/index206.js +244 -137
  70. package/dist/index206.js.map +1 -1
  71. package/dist/index207.js +100 -238
  72. package/dist/index207.js.map +1 -1
  73. package/dist/index208.js +278 -74
  74. package/dist/index208.js.map +1 -1
  75. package/dist/index209.js +56 -97
  76. package/dist/index209.js.map +1 -1
  77. package/dist/index210.js +142 -47
  78. package/dist/index210.js.map +1 -1
  79. package/dist/index211.js +38 -84
  80. package/dist/index211.js.map +1 -1
  81. package/dist/index212.js +72 -252
  82. package/dist/index212.js.map +1 -1
  83. package/dist/index213.js +274 -26
  84. package/dist/index213.js.map +1 -1
  85. package/dist/index214.js +29 -94
  86. package/dist/index214.js.map +1 -1
  87. package/dist/index215.js +98 -25
  88. package/dist/index215.js.map +1 -1
  89. package/dist/index216.js +20 -565
  90. package/dist/index216.js.map +1 -1
  91. package/dist/index217.js +564 -17
  92. package/dist/index217.js.map +1 -1
  93. package/dist/index218.js +20 -23
  94. package/dist/index218.js.map +1 -1
  95. package/dist/index219.js +20 -95
  96. package/dist/index219.js.map +1 -1
  97. package/dist/index220.js +92 -88
  98. package/dist/index220.js.map +1 -1
  99. package/dist/index221.js +97 -29
  100. package/dist/index221.js.map +1 -1
  101. package/dist/index222.js +24 -470
  102. package/dist/index222.js.map +1 -1
  103. package/dist/index223.js +446 -196
  104. package/dist/index223.js.map +1 -1
  105. package/dist/index224.js +199 -729
  106. package/dist/index224.js.map +1 -1
  107. package/dist/index225.js +750 -61
  108. package/dist/index225.js.map +1 -1
  109. package/dist/index226.js +58 -181
  110. package/dist/index226.js.map +1 -1
  111. package/dist/index227.js +175 -259
  112. package/dist/index227.js.map +1 -1
  113. package/dist/index228.js +246 -172
  114. package/dist/index228.js.map +1 -1
  115. package/dist/index229.js +195 -32
  116. package/dist/index229.js.map +1 -1
  117. package/dist/index230.js +12 -40
  118. package/dist/index230.js.map +1 -1
  119. package/dist/index231.js +23 -26
  120. package/dist/index231.js.map +1 -1
  121. package/dist/index232.js +45 -22
  122. package/dist/index232.js.map +1 -1
  123. package/dist/index233.js +27 -48
  124. package/dist/index233.js.map +1 -1
  125. package/dist/index234.js +52 -26
  126. package/dist/index234.js.map +1 -1
  127. package/dist/index235.js +40 -225
  128. package/dist/index235.js.map +1 -1
  129. package/dist/index236.js +217 -39
  130. package/dist/index236.js.map +1 -1
  131. package/dist/index237.js +50 -0
  132. package/dist/index237.js.map +1 -0
  133. package/dist/styles.css +1 -1
  134. package/dist/wc/AIToolCall.js +218 -0
  135. package/dist/wc/AIToolCall.js.map +1 -0
  136. package/dist/wc/hf-ai-tool-call.js +34 -219
  137. package/dist/wc/hf-ai-tool-call.js.map +1 -1
  138. package/dist/wc/hf-ai-tool-run.js +673 -576
  139. package/dist/wc/hf-ai-tool-run.js.map +1 -1
  140. package/dist/wc/workflow-step-renderer.js +79 -78
  141. package/dist/wc/workflow-step-renderer.js.map +1 -1
  142. package/dist/wc-react/AIToolCall.js +218 -0
  143. package/dist/wc-react/AIToolCall.js.map +1 -0
  144. package/dist/wc-react/hf-ai-tool-call.js +32 -217
  145. package/dist/wc-react/hf-ai-tool-call.js.map +1 -1
  146. package/dist/wc-react/hf-ai-tool-run.js +698 -601
  147. package/dist/wc-react/hf-ai-tool-run.js.map +1 -1
  148. package/dist/wc-react/workflow-step-renderer.js +58 -57
  149. package/dist/wc-react/workflow-step-renderer.js.map +1 -1
  150. package/package.json +1 -1
  151. package/skills/humain-ui/SKILL.md +1 -1
  152. package/skills/humain-ui-wc/SKILL.md +1 -1
  153. package/skills/humain-ui-wc.skill +0 -0
  154. package/skills/humain-ui.skill +0 -0
  155. package/dist/index182.js +0 -143
  156. package/dist/index182.js.map +0 -1
  157. package/dist/wc/wrench.js +0 -10
  158. package/dist/wc/wrench.js.map +0 -1
  159. package/dist/wc-react/wrench.js +0 -10
  160. 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 { Button } from "./index5.js";
3
- import { ChartContainer } from "./index22.js";
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 { ArrowUp, ArrowUpRight, Eye, MoreVertical, TrendingUp } from "lucide-react";
7
- import * as React from "react";
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", {
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: { variant: "line" }
15
+ defaultVariants: { size: "md" }
36
16
  });
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]);
58
- return /* @__PURE__ */ jsxs("div", {
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
- 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,
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
- 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: ""
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
- 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",
238
- children: title
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
- ]
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
- "data-slot": "metric-item",
286
- className: cn(metricItemVariants({
287
- type,
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
- 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",
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("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",
321
- children: title
322
- })]
323
- }),
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
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
- 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
- })]
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
- MetricItem.displayName = "MetricItem";
165
+ }
166
+ MetricCard.displayName = "MetricCard";
502
167
  //#endregion
503
- export { MetricChange, MetricItem, MetricMiniChart, metricChangeVariants, metricItemVariants, metricMiniChartVariants };
168
+ export { MetricCard, metricCardVariants };
504
169
 
505
170
  //# sourceMappingURL=index198.js.map