@alpic-ai/ui 1.164.0 → 1.165.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ interface StatDelta {
10
10
  label?: React$1.ReactNode;
11
11
  indicator?: "arrow" | "sign";
12
12
  }
13
- interface StatProps extends React$1.ComponentProps<"div"> {
13
+ interface StatProps extends Omit<React$1.HTMLAttributes<HTMLElement>, "onClick"> {
14
14
  value: React$1.ReactNode;
15
15
  unit?: string;
16
16
  delta?: StatDelta | null;
@@ -19,8 +19,9 @@ interface StatProps extends React$1.ComponentProps<"div"> {
19
19
  }>;
20
20
  semantic?: "error" | "warning" | "success";
21
21
  compact?: boolean;
22
+ onClick?: () => void;
22
23
  }
23
- declare function Stat({ value, unit, delta, sparkline, semantic, compact, className, ...props }: StatProps): React$1.JSX.Element;
24
+ declare function Stat({ value, unit, delta, sparkline, semantic, compact, className, onClick, ...props }: StatProps): React$1.JSX.Element;
24
25
  declare function StatSparkline({ sparkline, semantic, className }: Pick<StatProps, "sparkline" | "semantic"> & {
25
26
  className?: string;
26
27
  }): React$1.JSX.Element | null;
@@ -26,11 +26,14 @@ const SEMANTIC_KEY = {
26
26
  warning: "warning",
27
27
  success: "success"
28
28
  };
29
- function Stat({ value, unit, delta, sparkline, semantic, compact = false, className, ...props }) {
29
+ const STAT_INTERACTIVE_CLASS = "rounded-sm text-left outline-none transition-opacity focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card";
30
+ function Stat({ value, unit, delta, sparkline, semantic, compact = false, className, onClick, ...props }) {
30
31
  const sentiment = delta && (delta.invert ? delta.direction === "down" : delta.direction === "up") ? "positive" : "negative";
31
- return /* @__PURE__ */ jsxs("div", {
32
+ return /* @__PURE__ */ jsxs(onClick ? "button" : "div", {
32
33
  "data-slot": "stat",
33
- className: cn("flex min-w-0 flex-col gap-2.5", className),
34
+ type: onClick ? "button" : void 0,
35
+ onClick,
36
+ className: cn("flex min-w-0 flex-col gap-2.5", onClick && STAT_INTERACTIVE_CLASS, className),
34
37
  ...props,
35
38
  children: [/* @__PURE__ */ jsxs("div", {
36
39
  className: cn("flex min-w-0 items-baseline gap-x-2.5", compact && "gap-x-1.5"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpic-ai/ui",
3
- "version": "1.164.0",
3
+ "version": "1.165.1",
4
4
  "description": "Alpic design system — shared UI components",
5
5
  "type": "module",
6
6
  "exports": {
@@ -29,13 +29,14 @@ export interface StatDelta {
29
29
  indicator?: "arrow" | "sign";
30
30
  }
31
31
 
32
- export interface StatProps extends React.ComponentProps<"div"> {
32
+ export interface StatProps extends Omit<React.HTMLAttributes<HTMLElement>, "onClick"> {
33
33
  value: React.ReactNode;
34
34
  unit?: string;
35
35
  delta?: StatDelta | null;
36
36
  sparkline?: number[] | Array<{ value: number }>;
37
37
  semantic?: "error" | "warning" | "success";
38
38
  compact?: boolean;
39
+ onClick?: () => void;
39
40
  }
40
41
 
41
42
  const toSparkData = (sparkline: StatProps["sparkline"]) =>
@@ -45,12 +46,22 @@ const toSparkData = (sparkline: StatProps["sparkline"]) =>
45
46
 
46
47
  const SEMANTIC_KEY = { error: "destructive", warning: "warning", success: "success" } as const;
47
48
 
48
- function Stat({ value, unit, delta, sparkline, semantic, compact = false, className, ...props }: StatProps) {
49
+ const STAT_INTERACTIVE_CLASS =
50
+ "rounded-sm text-left outline-none transition-opacity focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card";
51
+
52
+ function Stat({ value, unit, delta, sparkline, semantic, compact = false, className, onClick, ...props }: StatProps) {
49
53
  const sentiment =
50
54
  delta && (delta.invert ? delta.direction === "down" : delta.direction === "up") ? "positive" : "negative";
55
+ const Root = onClick ? "button" : "div";
51
56
 
52
57
  return (
53
- <div data-slot="stat" className={cn("flex min-w-0 flex-col gap-2.5", className)} {...props}>
58
+ <Root
59
+ data-slot="stat"
60
+ type={onClick ? "button" : undefined}
61
+ onClick={onClick}
62
+ className={cn("flex min-w-0 flex-col gap-2.5", onClick && STAT_INTERACTIVE_CLASS, className)}
63
+ {...props}
64
+ >
54
65
  <div className={cn("flex min-w-0 items-baseline gap-x-2.5", compact && "gap-x-1.5")}>
55
66
  <span
56
67
  className={cn(
@@ -78,7 +89,7 @@ function Stat({ value, unit, delta, sparkline, semantic, compact = false, classN
78
89
  )}
79
90
  </div>
80
91
  <StatSparkline sparkline={sparkline} semantic={semantic} />
81
- </div>
92
+ </Root>
82
93
  );
83
94
  }
84
95