@alpic-ai/ui 0.0.0-dev.g37dab1d → 0.0.0-dev.g380fab7

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 (109) hide show
  1. package/dist/components/accordion-card.d.mts +5 -5
  2. package/dist/components/accordion.d.mts +5 -5
  3. package/dist/components/alert.d.mts +8 -8
  4. package/dist/components/area-chart.d.mts +62 -0
  5. package/dist/components/area-chart.mjs +269 -0
  6. package/dist/components/attachment-tile.d.mts +1 -1
  7. package/dist/components/avatar.d.mts +7 -7
  8. package/dist/components/badge.d.mts +1 -1
  9. package/dist/components/bar-chart.d.mts +48 -0
  10. package/dist/components/bar-chart.mjs +245 -0
  11. package/dist/components/bar-list.d.mts +28 -0
  12. package/dist/components/bar-list.mjs +98 -0
  13. package/dist/components/breadcrumb.d.mts +10 -10
  14. package/dist/components/button.d.mts +5 -5
  15. package/dist/components/card.d.mts +9 -9
  16. package/dist/components/chart-card.d.mts +25 -0
  17. package/dist/components/chart-card.mjs +48 -0
  18. package/dist/components/chart-container.d.mts +20 -0
  19. package/dist/components/chart-container.mjs +37 -0
  20. package/dist/components/chart-legend.d.mts +16 -0
  21. package/dist/components/chart-legend.mjs +26 -0
  22. package/dist/components/chart-tooltip.d.mts +33 -0
  23. package/dist/components/chart-tooltip.mjs +52 -0
  24. package/dist/components/checkbox.d.mts +2 -2
  25. package/dist/components/collapsible.d.mts +4 -4
  26. package/dist/components/combobox.d.mts +10 -10
  27. package/dist/components/command.d.mts +9 -9
  28. package/dist/components/copyable.d.mts +2 -2
  29. package/dist/components/description-list.d.mts +5 -5
  30. package/dist/components/dialog.d.mts +13 -13
  31. package/dist/components/donut-chart.d.mts +46 -0
  32. package/dist/components/donut-chart.mjs +185 -0
  33. package/dist/components/dropdown-menu.d.mts +17 -17
  34. package/dist/components/form.d.mts +18 -18
  35. package/dist/components/form.mjs +6 -6
  36. package/dist/components/github-button.d.mts +1 -1
  37. package/dist/components/grid-fx.d.mts +13 -0
  38. package/dist/components/grid-fx.mjs +188 -0
  39. package/dist/components/heatmap-chart.d.mts +40 -0
  40. package/dist/components/heatmap-chart.mjs +198 -0
  41. package/dist/components/input-group.d.mts +4 -4
  42. package/dist/components/input.d.mts +4 -4
  43. package/dist/components/input.mjs +2 -2
  44. package/dist/components/label.d.mts +2 -2
  45. package/dist/components/line-chart.d.mts +55 -0
  46. package/dist/components/line-chart.mjs +211 -0
  47. package/dist/components/page-loader.d.mts +1 -1
  48. package/dist/components/pagination.d.mts +3 -3
  49. package/dist/components/popover.d.mts +5 -5
  50. package/dist/components/radio-group.d.mts +3 -3
  51. package/dist/components/scroll-area.d.mts +3 -3
  52. package/dist/components/select.d.mts +9 -9
  53. package/dist/components/separator.d.mts +2 -2
  54. package/dist/components/sheet.d.mts +11 -11
  55. package/dist/components/shimmer-text.d.mts +3 -1
  56. package/dist/components/sidebar.d.mts +33 -33
  57. package/dist/components/sidebar.mjs +10 -10
  58. package/dist/components/skeleton.d.mts +1 -1
  59. package/dist/components/sonner.d.mts +5 -5
  60. package/dist/components/spinner.d.mts +2 -2
  61. package/dist/components/stat.d.mts +30 -0
  62. package/dist/components/stat.mjs +107 -0
  63. package/dist/components/status-dot.d.mts +1 -1
  64. package/dist/components/switch.d.mts +2 -2
  65. package/dist/components/table.d.mts +10 -10
  66. package/dist/components/tabs.d.mts +10 -10
  67. package/dist/components/tag.d.mts +3 -3
  68. package/dist/components/task-progress.d.mts +1 -1
  69. package/dist/components/textarea.d.mts +3 -3
  70. package/dist/components/textarea.mjs +2 -2
  71. package/dist/components/toggle-group.d.mts +3 -3
  72. package/dist/components/toggle-group.mjs +3 -3
  73. package/dist/components/tooltip.d.mts +5 -5
  74. package/dist/components/typography.d.mts +4 -4
  75. package/dist/components/wizard.d.mts +4 -4
  76. package/dist/hooks/use-chart-theme.d.mts +18 -0
  77. package/dist/hooks/use-chart-theme.mjs +57 -0
  78. package/dist/hooks/use-mobile.mjs +3 -3
  79. package/dist/hooks/use-reduced-motion.d.mts +4 -0
  80. package/dist/hooks/use-reduced-motion.mjs +16 -0
  81. package/dist/lib/chart-palette.d.mts +4 -0
  82. package/dist/lib/chart-palette.mjs +95 -0
  83. package/dist/lib/chart.d.mts +14 -0
  84. package/dist/lib/chart.mjs +27 -0
  85. package/package.json +30 -29
  86. package/src/components/area-chart.tsx +339 -0
  87. package/src/components/bar-chart.tsx +300 -0
  88. package/src/components/bar-list.tsx +150 -0
  89. package/src/components/chart-card.tsx +63 -0
  90. package/src/components/chart-container.tsx +49 -0
  91. package/src/components/chart-legend.tsx +41 -0
  92. package/src/components/chart-tooltip.tsx +93 -0
  93. package/src/components/donut-chart.tsx +217 -0
  94. package/src/components/grid-fx.tsx +238 -0
  95. package/src/components/heatmap-chart.tsx +287 -0
  96. package/src/components/line-chart.tsx +264 -0
  97. package/src/components/stat.tsx +109 -0
  98. package/src/hooks/use-chart-theme.ts +75 -0
  99. package/src/hooks/use-reduced-motion.ts +17 -0
  100. package/src/lib/chart-palette.ts +110 -0
  101. package/src/lib/chart.ts +56 -0
  102. package/src/stories/area-chart.stories.tsx +200 -0
  103. package/src/stories/bar-chart.stories.tsx +169 -0
  104. package/src/stories/bar-list.stories.tsx +85 -0
  105. package/src/stories/donut-chart.stories.tsx +112 -0
  106. package/src/stories/heatmap-chart.stories.tsx +107 -0
  107. package/src/stories/line-chart.stories.tsx +146 -0
  108. package/src/stories/stat.stories.tsx +64 -0
  109. package/src/styles/tokens.css +63 -0
@@ -0,0 +1,146 @@
1
+ import type { Story } from "@ladle/react";
2
+
3
+ import { ChartCard } from "../components/chart-card";
4
+ import { GridFx } from "../components/grid-fx";
5
+ import { LineChart } from "../components/line-chart";
6
+ import { Stat } from "../components/stat";
7
+
8
+ export default { title: "Charts/Line Chart" };
9
+
10
+ const mulberry32 = (seed: number) => () => {
11
+ seed |= 0;
12
+ seed = (seed + 0x6d2b79f5) | 0;
13
+ let hash = Math.imul(seed ^ (seed >>> 15), 1 | seed);
14
+ hash = (hash + Math.imul(hash ^ (hash >>> 7), 61 | hash)) ^ hash;
15
+ return ((hash ^ (hash >>> 14)) >>> 0) / 4294967296;
16
+ };
17
+
18
+ const hourLabel = (index: number, length: number) =>
19
+ `${String(Math.round((index / (length - 1)) * 24)).padStart(2, "0")}:00`;
20
+
21
+ const genSeries = (seed: number, scale: number) => {
22
+ const rnd = mulberry32(seed);
23
+ const length = 30;
24
+ let value = scale * 0.6;
25
+ return Array.from({ length }, (_, index) => {
26
+ value = Math.max(scale * 0.12, value + (rnd() - 0.46) * scale * 0.18);
27
+ return { t: hourLabel(index, length), v: Math.round(value * (1 + Math.sin(index / 5) * 0.16)) };
28
+ });
29
+ };
30
+
31
+ const genLatency = (seed: number) => {
32
+ const rnd = mulberry32(seed);
33
+ const length = 30;
34
+ let p50 = 240;
35
+ let p95 = 720;
36
+ return Array.from({ length }, (_, index) => {
37
+ p50 = Math.max(120, p50 + (rnd() - 0.48) * 40);
38
+ p95 = Math.max(p50 + 200, p95 + (rnd() - 0.46) * 120);
39
+ return { t: hourLabel(index, length), p50: Math.round(p50), p95: Math.round(p95 * (index === 19 ? 1.7 : 1)) };
40
+ });
41
+ };
42
+
43
+ const genCompare = (seed: number) => {
44
+ const rnd = mulberry32(seed);
45
+ const length = 30;
46
+ let claude = 60;
47
+ let chatgpt = 80;
48
+ return Array.from({ length }, (_, index) => {
49
+ claude = Math.max(20, claude + (rnd() - 0.42) * 14);
50
+ chatgpt = Math.max(20, chatgpt + (rnd() - 0.5) * 12);
51
+ return { t: hourLabel(index, length), claude: Math.round(claude), chatgpt: Math.round(chatgpt) };
52
+ });
53
+ };
54
+
55
+ const tokens = genSeries(11, 84000);
56
+ const latency = genLatency(31);
57
+ const compare = genCompare(23);
58
+
59
+ const nf = (value: number) => value.toLocaleString("en-US");
60
+ const fmtK = (value: number) => (value >= 1000 ? `${(value / 1000).toFixed(value >= 10000 ? 0 : 1)}k` : `${value}`);
61
+ const ms = (value: number) => `${value}ms`;
62
+
63
+ const tokensSpark = tokens.map((row) => row.v);
64
+ const latencyPeak = latency.reduce((best, row) => (row.p95 > best.p95 ? row : best));
65
+
66
+ export const AllVariants: Story = () => (
67
+ <div className="chart-canvas mx-auto max-w-[1600px] p-8">
68
+ <GridFx />
69
+ <div className="grid grid-cols-1 gap-6 md:grid-cols-2 xl:grid-cols-3">
70
+ <ChartCard
71
+ palette="cyan"
72
+ accent="left"
73
+ kicker="Last 24h"
74
+ title="Sessions"
75
+ description="Full-width · left accent"
76
+ className="md:col-span-2 xl:col-span-3"
77
+ >
78
+ <LineChart
79
+ data={compare}
80
+ index="t"
81
+ series={[
82
+ { key: "claude", name: "Claude" },
83
+ { key: "chatgpt", name: "ChatGPT" },
84
+ ]}
85
+ lastValueLabel
86
+ legend
87
+ valueFormatter={nf}
88
+ />
89
+ </ChartCard>
90
+
91
+ <ChartCard palette="magenta" kicker="Last 24h" title="Output tokens" description="Single series · value flags">
92
+ <Stat value="1.4M" unit="tokens" delta={{ value: 8.1, direction: "up" }} sparkline={tokensSpark} />
93
+ <LineChart data={tokens} index="t" series={[{ key: "v", name: "tokens" }]} valueFlags valueFormatter={fmtK} />
94
+ </ChartCard>
95
+
96
+ <ChartCard palette="magenta" kicker="Last 24h" title="Request latency" description="p50 vs p95 · SLA band + peak">
97
+ <Stat value="240ms" unit="p50 · current" delta={{ value: 4.2, direction: "down", invert: true }} />
98
+ <LineChart
99
+ data={latency}
100
+ index="t"
101
+ series={[
102
+ { key: "p50", name: "p50" },
103
+ { key: "p95", name: "p95", dashed: true, color: "#9b5de5" },
104
+ ]}
105
+ referenceLine={{ y: 1000, label: "SLA 1s", band: true }}
106
+ markers={[{ x: latencyPeak.t, y: latencyPeak.p95, label: "peak", color: "#9b5de5" }]}
107
+ legend
108
+ valueFormatter={ms}
109
+ />
110
+ </ChartCard>
111
+
112
+ <ChartCard palette="cyan" kicker="Last 24h" title="Sessions" description="Claude vs ChatGPT · last values">
113
+ <LineChart
114
+ data={compare}
115
+ index="t"
116
+ series={[
117
+ { key: "claude", name: "Claude" },
118
+ { key: "chatgpt", name: "ChatGPT" },
119
+ ]}
120
+ lastValueLabel
121
+ legend
122
+ valueFormatter={nf}
123
+ />
124
+ </ChartCard>
125
+
126
+ <ChartCard palette="cyan" kicker="Last 24h" title="Throughput" description="Dots · stepped curve">
127
+ <LineChart
128
+ data={tokens}
129
+ index="t"
130
+ series={[{ key: "v", name: "tokens" }]}
131
+ curve="step"
132
+ dots
133
+ valueFormatter={fmtK}
134
+ />
135
+ </ChartCard>
136
+
137
+ <ChartCard palette="magenta" kicker="State" title="Loading" description="Mono spinner placeholder">
138
+ <LineChart data={[]} index="t" series={[{ key: "v", name: "tokens" }]} loading />
139
+ </ChartCard>
140
+
141
+ <ChartCard palette="magenta" kicker="State" title="Empty" description="No data in range">
142
+ <LineChart data={[]} index="t" series={[{ key: "v", name: "tokens" }]} />
143
+ </ChartCard>
144
+ </div>
145
+ </div>
146
+ );
@@ -0,0 +1,64 @@
1
+ import type { Story } from "@ladle/react";
2
+
3
+ import { ChartContainer } from "../components/chart-container";
4
+ import { Stat } from "../components/stat";
5
+
6
+ export default { title: "Charts/Stat" };
7
+
8
+ const mulberry32 = (seed: number) => () => {
9
+ seed |= 0;
10
+ seed = (seed + 0x6d2b79f5) | 0;
11
+ let hash = Math.imul(seed ^ (seed >>> 15), 1 | seed);
12
+ hash = (hash + Math.imul(hash ^ (hash >>> 7), 61 | hash)) ^ hash;
13
+ return ((hash ^ (hash >>> 14)) >>> 0) / 4294967296;
14
+ };
15
+
16
+ const spark = (seed: number, length = 24) => {
17
+ const rnd = mulberry32(seed);
18
+ let value = 40;
19
+ return Array.from({ length }, () => {
20
+ value = Math.max(8, value + (rnd() - 0.45) * 16);
21
+ return Math.round(value);
22
+ });
23
+ };
24
+
25
+ const Row = ({ label, children }: { label: string; children: React.ReactNode }) => (
26
+ <div className="flex flex-col gap-1.5">
27
+ <p className="type-text-xs font-medium text-subtle-foreground">{label}</p>
28
+ {children}
29
+ </div>
30
+ );
31
+
32
+ export const AllVariants: Story = () => (
33
+ <div className="grid max-w-3xl grid-cols-2 gap-8">
34
+ <Row label="Value + unit">
35
+ <Stat value="48,231" unit="sessions · 24h" />
36
+ </Row>
37
+
38
+ <Row label="Positive delta (up = good)">
39
+ <Stat value="1.4M" unit="tokens · 24h" delta={{ value: 8.1, direction: "up" }} />
40
+ </Row>
41
+
42
+ <Row label="Negative delta (down = bad)">
43
+ <Stat value="312" unit="errors · 24h" delta={{ value: 14.2, direction: "up", invert: true }} />
44
+ </Row>
45
+
46
+ <Row label="Inverted: latency down = good">
47
+ <Stat value="240ms" unit="p50 · current" delta={{ value: 4.2, direction: "down", invert: true }} />
48
+ </Row>
49
+
50
+ <Row label="With sparkline">
51
+ <Stat value="48,231" unit="sessions · 24h" delta={{ value: 12.4, direction: "up" }} sparkline={spark(7)} />
52
+ </Row>
53
+
54
+ <Row label="Custom delta label">
55
+ <Stat value="312" unit="errors · 24h" delta={{ value: 0, direction: "up", invert: true, label: "burst 16:00" }} />
56
+ </Row>
57
+
58
+ <Row label="Cyan palette (sparkline lead)">
59
+ <ChartContainer palette="cyan">
60
+ <Stat value="9,204" unit="tasks · 24h" delta={{ value: 22, direction: "up" }} sparkline={spark(53)} />
61
+ </ChartContainer>
62
+ </Row>
63
+ </div>
64
+ );
@@ -4,6 +4,7 @@
4
4
  --font-sans: "Inter", system-ui, sans-serif;
5
5
  --font-display: "Inter", sans-serif;
6
6
  --font-body: "Inter", sans-serif;
7
+ --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
7
8
 
8
9
  --color-background: #ffffff; /* Figma: bg-primary */
9
10
  --color-foreground: #121e1e; /* Figma: fg-primary */
@@ -446,6 +447,68 @@
446
447
  }
447
448
  }
448
449
 
450
+ /* ─── Chart canvas — control-room atmosphere for analytics surfaces ───────────
451
+ Apply `.chart-canvas` to a dashboard/page container holding chart cards: a
452
+ dotted grid faded from the top, plus a dual brand glow in dark mode. The grid
453
+ is masked away so it never bleeds into the cards stacked above it. */
454
+
455
+ .chart-canvas {
456
+ position: relative;
457
+ isolation: isolate;
458
+ }
459
+
460
+ .chart-canvas::before {
461
+ content: "";
462
+ position: absolute;
463
+ inset: 0;
464
+ z-index: -1;
465
+ pointer-events: none;
466
+ background-image:
467
+ linear-gradient(var(--color-sidebar-border) 1px, transparent 1px),
468
+ linear-gradient(90deg, var(--color-sidebar-border) 1px, transparent 1px);
469
+ background-size:
470
+ 46px 46px,
471
+ 46px 46px;
472
+ opacity: 0.65;
473
+ -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 100%);
474
+ mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 100%);
475
+ }
476
+
477
+ .dark .chart-canvas::before {
478
+ background-image:
479
+ radial-gradient(
480
+ 900px 480px at 78% -8%,
481
+ color-mix(in oklab, var(--color-cta-accent) 12%, transparent),
482
+ transparent 60%
483
+ ),
484
+ radial-gradient(820px 520px at 8% 4%, color-mix(in oklab, var(--color-primary) 12%, transparent), transparent 60%),
485
+ linear-gradient(var(--color-sidebar-border) 1px, transparent 1px),
486
+ linear-gradient(90deg, var(--color-sidebar-border) 1px, transparent 1px);
487
+ background-size:
488
+ 100% 100%,
489
+ 100% 100%,
490
+ 46px 46px,
491
+ 46px 46px;
492
+ opacity: 0.6;
493
+ }
494
+
495
+ @media (prefers-reduced-motion: no-preference) {
496
+ .chart-rise {
497
+ animation: chart-rise 0.65s cubic-bezier(0.2, 0.7, 0.2, 1) both;
498
+ }
499
+ }
500
+
501
+ @keyframes chart-rise {
502
+ from {
503
+ opacity: 0;
504
+ transform: translateY(12px);
505
+ }
506
+ to {
507
+ opacity: 1;
508
+ transform: none;
509
+ }
510
+ }
511
+
449
512
  /* ─── Typography ──────────────────────────────────────────────────────────── */
450
513
 
451
514
  :root {