@ramme-io/ui 4.2.9 → 5.0.0

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 (48) hide show
  1. package/README.md +3 -9
  2. package/bin/ramme-ui.mjs +364 -0
  3. package/dist/blocks/iot/DeviceCard.d.ts +5 -0
  4. package/dist/blocks/iot/DeviceCard.js +29 -28
  5. package/dist/component-registry.js +384 -409
  6. package/dist/components/ai/AIChatThread/AIChatThread.d.ts +10 -2
  7. package/dist/components/ai/AIChatThread/AIChatThread.js +106 -119
  8. package/dist/components/ai/cardState.d.ts +19 -0
  9. package/dist/components/data-display/DocumentScanView.d.ts +81 -0
  10. package/dist/components/data-display/DocumentScanView.js +79 -0
  11. package/dist/components/data-display/Gallery.d.ts +49 -0
  12. package/dist/components/data-display/Gallery.js +95 -0
  13. package/dist/components/theme/ThemeSynthesizer.d.ts +2 -0
  14. package/dist/components/theme/ThemeSynthesizer.js +16 -15
  15. package/dist/components/ui/icon-loader.d.ts +1 -1
  16. package/dist/contexts/ThemeContext.d.ts +3 -0
  17. package/dist/contexts/ThemeContext.js +32 -30
  18. package/dist/index.d.ts +4 -9
  19. package/dist/index.js +252 -265
  20. package/dist/wizardManifest.js +123 -166
  21. package/package.json +7 -3
  22. package/src/wizardManifest.ts +123 -166
  23. package/tailwind.preset.js +17 -0
  24. package/dist/blocks/engines/WatchlistEngine.d.ts +0 -37
  25. package/dist/blocks/engines/WatchlistEngine.js +0 -130
  26. package/dist/components/ai/ArchitectureReferenceCard/ArchitectureReferenceCard.d.ts +0 -28
  27. package/dist/components/ai/ArchitectureReferenceCard/ArchitectureReferenceCard.js +0 -71
  28. package/dist/components/ai/ArchitectureReferenceCard/index.d.ts +0 -2
  29. package/dist/components/ai/CompanyProfileCard/CompanyProfileCard.d.ts +0 -15
  30. package/dist/components/ai/CompanyProfileCard/CompanyProfileCard.js +0 -110
  31. package/dist/components/ai/CompanyProfileCard/index.d.ts +0 -1
  32. package/dist/components/ai/CounterpartyGraphCard/CounterpartyGraphCard.d.ts +0 -30
  33. package/dist/components/ai/CounterpartyGraphCard/CounterpartyGraphCard.js +0 -83
  34. package/dist/components/ai/CounterpartyGraphCard/index.d.ts +0 -2
  35. package/dist/components/ai/DivergenceMetricsCard/DivergenceMetricsCard.d.ts +0 -29
  36. package/dist/components/ai/DivergenceMetricsCard/DivergenceMetricsCard.js +0 -70
  37. package/dist/components/ai/DivergenceMetricsCard/index.d.ts +0 -2
  38. package/dist/components/ai/LiveQuoteCard/LiveQuoteCard.d.ts +0 -27
  39. package/dist/components/ai/LiveQuoteCard/LiveQuoteCard.js +0 -73
  40. package/dist/components/ai/LiveQuoteCard/index.d.ts +0 -2
  41. package/dist/components/ai/NewsSummaryCard/NewsSummaryCard.d.ts +0 -27
  42. package/dist/components/ai/NewsSummaryCard/NewsSummaryCard.js +0 -78
  43. package/dist/components/ai/NewsSummaryCard/index.d.ts +0 -2
  44. package/dist/components/ai/StockChart/StockChart.d.ts +0 -34
  45. package/dist/components/ai/StockChart/StockChart.js +0 -199
  46. package/dist/components/ai/StockChart/index.d.ts +0 -2
  47. package/dist/utils/apiBaseUrl.d.ts +0 -1
  48. package/dist/utils/apiBaseUrl.js +0 -10
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  /**
3
3
  * Tool call object (matches @ramme-io/kernel's ToolCall interface).
4
4
  */
5
- interface ToolCall {
5
+ export interface AIChatToolCall {
6
6
  name: string;
7
7
  arguments: Record<string, any>;
8
8
  id?: string;
@@ -14,7 +14,7 @@ interface ToolCall {
14
14
  interface ChatMessage {
15
15
  role: 'user' | 'assistant' | 'system';
16
16
  content: string;
17
- toolCall?: ToolCall;
17
+ toolCall?: AIChatToolCall;
18
18
  }
19
19
  export type ChatConnectionStatus = 'idle' | 'streaming' | 'error';
20
20
  /**
@@ -66,6 +66,14 @@ export interface AIChatThreadProps {
66
66
  suggestions?: string[];
67
67
  /** Called with the suggestion text when a chip is clicked. Defaults to `onSubmit` if omitted. */
68
68
  onSuggestionClick?: (suggestion: string) => void;
69
+ /**
70
+ * Renders a tool call as generative UI. Return `undefined` to fall through
71
+ * to the thread's built-in cards.
72
+ *
73
+ * A product passes its own renderer here, and its cards fetch their own
74
+ * data, so this package does not fetch anything itself (#85).
75
+ */
76
+ renderToolCall?: (toolCall: AIChatToolCall) => React.ReactNode | undefined;
69
77
  }
70
78
  export declare const AIChatThread: React.FC<AIChatThreadProps>;
71
79
  export {};
@@ -1,51 +1,44 @@
1
- import { jsxs as c, jsx as e, Fragment as w } from "react/jsx-runtime";
2
- import { useState as B, useRef as R, useEffect as D, useCallback as g } from "react";
3
- import { CodeBlock as G } from "../../data-display/CodeBlock.js";
4
- import { Icon as N } from "../../ui/Icon.js";
5
- import { PromptInput as $ } from "../../../blocks/ai/PromptInput.js";
6
- import { Actions as E, Suggestion as F } from "../../../blocks/ai/Actions.js";
7
- import { cn as p } from "../../../utils/cn.js";
8
- import { TelemetryGraph as S } from "../TelemetryGraph/TelemetryGraph.js";
9
- import { StockChart as V } from "../StockChart/StockChart.js";
10
- import { LiveQuoteCard as z } from "../LiveQuoteCard/LiveQuoteCard.js";
11
- import { NewsSummaryCard as M } from "../NewsSummaryCard/NewsSummaryCard.js";
12
- import { CompanyProfileCard as O } from "../CompanyProfileCard/CompanyProfileCard.js";
13
- import { CounterpartyGraphCard as U } from "../CounterpartyGraphCard/CounterpartyGraphCard.js";
14
- import { DivergenceMetricsCard as q } from "../DivergenceMetricsCard/DivergenceMetricsCard.js";
15
- import { ArchitectureReferenceCard as L } from "../ArchitectureReferenceCard/ArchitectureReferenceCard.js";
16
- function Q(t) {
17
- if (!t) return null;
18
- const l = t.split(/(```[\w]*\n[\s\S]*?```)/g);
19
- return /* @__PURE__ */ e(w, { children: l.map((o, a) => {
20
- const n = o.match(/^```([\w]*)\n([\s\S]*?)```$/);
21
- if (n) {
22
- const i = n[1] || "text", d = n[2].replace(/\n$/, "");
23
- return /* @__PURE__ */ e("div", { className: "my-3", children: /* @__PURE__ */ e(G, { language: i, code: d }) }, a);
1
+ import { jsxs as s, jsx as t, Fragment as k } from "react/jsx-runtime";
2
+ import { useState as _, useRef as $, useEffect as D, useCallback as g } from "react";
3
+ import { CodeBlock as E } from "../../data-display/CodeBlock.js";
4
+ import { Icon as C } from "../../ui/Icon.js";
5
+ import { PromptInput as F } from "../../../blocks/ai/PromptInput.js";
6
+ import { Actions as G, Suggestion as V } from "../../../blocks/ai/Actions.js";
7
+ import { cn as h } from "../../../utils/cn.js";
8
+ import { TelemetryGraph as z } from "../TelemetryGraph/TelemetryGraph.js";
9
+ function O(e) {
10
+ if (!e) return null;
11
+ const n = e.split(/(```[\w]*\n[\s\S]*?```)/g);
12
+ return /* @__PURE__ */ t(k, { children: n.map((r, o) => {
13
+ const a = r.match(/^```([\w]*)\n([\s\S]*?)```$/);
14
+ if (a) {
15
+ const c = a[1] || "text", i = a[2].replace(/\n$/, "");
16
+ return /* @__PURE__ */ t("div", { className: "my-3", children: /* @__PURE__ */ t(E, { language: c, code: i }) }, o);
24
17
  }
25
- return o ? /* @__PURE__ */ e("p", { className: "whitespace-pre-wrap text-sm leading-relaxed", children: o }, a) : null;
18
+ return r ? /* @__PURE__ */ t("p", { className: "whitespace-pre-wrap text-sm leading-relaxed", children: r }, o) : null;
26
19
  }) });
27
20
  }
28
- const W = () => /* @__PURE__ */ e("div", { className: "flex items-center gap-1 px-1 py-0.5", "aria-label": "Assistant is typing", children: [0, 1, 2].map((t) => /* @__PURE__ */ e(
21
+ const U = () => /* @__PURE__ */ t("div", { className: "flex items-center gap-1 px-1 py-0.5", "aria-label": "Assistant is typing", children: [0, 1, 2].map((e) => /* @__PURE__ */ t(
29
22
  "span",
30
23
  {
31
24
  className: "w-1.5 h-1.5 rounded-full bg-muted-foreground/60 animate-bounce",
32
- style: { animationDelay: `${t * 0.15}s`, animationDuration: "0.9s" }
25
+ style: { animationDelay: `${e * 0.15}s`, animationDuration: "0.9s" }
33
26
  },
34
- t
35
- )) }), H = ({ message: t, isLastAssistant: l, isStreaming: o, renderContent: a }) => {
36
- var h, s;
37
- const n = t.role === "user", i = !t.content && !t.toolCall && l && o, d = !n && t.toolCall, u = ((h = t.content) == null ? void 0 : h.trim()) && t.content.trim().length > 0, f = !d && (u || i);
38
- return /* @__PURE__ */ c("div", { className: p("flex flex-col gap-2 mb-4", n ? "items-end" : "items-start"), children: [
39
- f && /* @__PURE__ */ e("div", { className: p("flex w-full", n ? "justify-end" : "justify-start"), children: /* @__PURE__ */ e(
27
+ e
28
+ )) }), M = ({ message: e, isLastAssistant: n, isStreaming: r, renderContent: o, renderToolCall: a }) => {
29
+ var f;
30
+ const c = e.role === "user", i = !e.content && !e.toolCall && n && r, d = !c && e.toolCall, m = d && e.toolCall ? a == null ? void 0 : a(e.toolCall) : void 0, b = ((f = e.content) == null ? void 0 : f.trim()) && e.content.trim().length > 0, p = !d && (b || i);
31
+ return /* @__PURE__ */ s("div", { className: h("flex flex-col gap-2 mb-4", c ? "items-end" : "items-start"), children: [
32
+ p && /* @__PURE__ */ t("div", { className: h("flex w-full", c ? "justify-end" : "justify-start"), children: /* @__PURE__ */ t(
40
33
  "div",
41
34
  {
42
- className: p(
35
+ className: h(
43
36
  "relative text-sm",
44
- n ? "max-w-[80%] rounded-2xl rounded-br-sm bg-primary px-4 py-2.5 text-primary-foreground" : "w-full text-foreground"
37
+ c ? "max-w-[80%] rounded-2xl rounded-br-sm bg-primary px-4 py-2.5 text-primary-foreground" : "w-full text-foreground"
45
38
  ),
46
- children: n ? /* @__PURE__ */ e("p", { className: "whitespace-pre-wrap leading-relaxed", children: t.content }) : i ? /* @__PURE__ */ e(W, {}) : /* @__PURE__ */ c(w, { children: [
47
- a ? a(t.content) : Q(t.content),
48
- l && o && t.content && !t.toolCall && /* @__PURE__ */ e(
39
+ children: c ? /* @__PURE__ */ t("p", { className: "whitespace-pre-wrap leading-relaxed", children: e.content }) : i ? /* @__PURE__ */ t(U, {}) : /* @__PURE__ */ s(k, { children: [
40
+ o ? o(e.content) : O(e.content),
41
+ n && r && e.content && !e.toolCall && /* @__PURE__ */ t(
49
42
  "span",
50
43
  {
51
44
  className: "inline-block w-[2px] h-[1em] bg-current ml-0.5 align-middle animate-pulse",
@@ -55,118 +48,112 @@ const W = () => /* @__PURE__ */ e("div", { className: "flex items-center gap-1 p
55
48
  ] })
56
49
  }
57
50
  ) }),
58
- d && t.toolCall && /* @__PURE__ */ c("div", { className: "w-full", children: [
59
- t.toolCall.name === "get_telemetry_graph" && /* @__PURE__ */ e(S, { params: t.toolCall.arguments }),
60
- t.toolCall.name === "get_stock_chart" && /* @__PURE__ */ e(V, { params: t.toolCall.arguments }),
61
- t.toolCall.name === "get_live_quote" && /* @__PURE__ */ e(z, { params: t.toolCall.arguments }),
62
- t.toolCall.name === "get_company_news" && /* @__PURE__ */ e(M, { params: t.toolCall.arguments }),
63
- t.toolCall.name === "get_company_profile" && /* @__PURE__ */ e(O, { ticker: (s = t.toolCall.arguments) == null ? void 0 : s.ticker }),
64
- t.toolCall.name === "get_counterparty_graph" && /* @__PURE__ */ e(U, { params: t.toolCall.arguments }),
65
- t.toolCall.name === "get_divergence_metrics" && /* @__PURE__ */ e(q, { params: t.toolCall.arguments }),
66
- t.toolCall.name === "get_architecture_reference" && /* @__PURE__ */ e(L, {})
67
- ] })
51
+ m !== void 0 && /* @__PURE__ */ t("div", { className: "w-full", children: m }),
52
+ d && e.toolCall && m === void 0 && /* @__PURE__ */ t("div", { className: "w-full", children: e.toolCall.name === "get_telemetry_graph" && /* @__PURE__ */ t(z, { params: e.toolCall.arguments }) })
68
53
  ] });
69
- }, J = {
54
+ }, S = {
70
55
  idle: { dot: "bg-emerald-500", label: "Ready" },
71
56
  streaming: { dot: "bg-amber-500 animate-pulse", label: "Generating…" },
72
57
  error: { dot: "bg-red-500", label: "Error" }
73
- }, K = ({ status: t, provider: l, model: o }) => {
74
- const { dot: a, label: n } = J[t];
75
- return /* @__PURE__ */ c("div", { className: "shrink-0 flex items-center justify-between px-3 py-1.5 border-b border-border/50 bg-muted/20", children: [
76
- /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
77
- /* @__PURE__ */ e("span", { className: `w-2 h-2 rounded-full ${a}` }),
78
- /* @__PURE__ */ e("span", { className: "text-[10px] font-semibold uppercase tracking-widest opacity-60", children: n })
58
+ }, W = ({ status: e, provider: n, model: r }) => {
59
+ const { dot: o, label: a } = S[e];
60
+ return /* @__PURE__ */ s("div", { className: "shrink-0 flex items-center justify-between px-3 py-1.5 border-b border-border/50 bg-muted/20", children: [
61
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
62
+ /* @__PURE__ */ t("span", { className: `w-2 h-2 rounded-full ${o}` }),
63
+ /* @__PURE__ */ t("span", { className: "text-[10px] font-semibold uppercase tracking-widest opacity-60", children: a })
79
64
  ] }),
80
- (l || o) && /* @__PURE__ */ e("span", { className: "text-[10px] font-mono opacity-50 truncate max-w-[200px]", children: [l, o].filter(Boolean).join(" · ") })
65
+ (n || r) && /* @__PURE__ */ t("span", { className: "text-[10px] font-mono opacity-50 truncate max-w-[200px]", children: [n, r].filter(Boolean).join(" · ") })
81
66
  ] });
82
- }, mt = ({
83
- messages: t,
84
- isStreaming: l,
85
- onSubmit: o,
86
- error: a = null,
87
- activeProvider: n,
88
- activeModel: i,
89
- connectionStatus: d,
90
- renderMessage: u,
91
- placeholder: f = "Ask AI…",
92
- className: h,
93
- suggestions: s,
94
- onSuggestionClick: k
67
+ }, Z = ({
68
+ messages: e,
69
+ isStreaming: n,
70
+ onSubmit: r,
71
+ error: o = null,
72
+ activeProvider: a,
73
+ activeModel: c,
74
+ connectionStatus: i,
75
+ renderMessage: d,
76
+ placeholder: m = "Ask AI…",
77
+ className: b,
78
+ suggestions: p,
79
+ onSuggestionClick: f,
80
+ renderToolCall: I
95
81
  }) => {
96
- const _ = d ?? (a ? "error" : l ? "streaming" : "idle"), [b, C] = B(""), y = R(null);
82
+ const A = i ?? (o ? "error" : n ? "streaming" : "idle"), [x, y] = _(""), N = $(null);
97
83
  D(() => {
98
- var r;
99
- (r = y.current) == null || r.scrollIntoView({ behavior: "smooth", block: "end" });
100
- }, [t.length, l]);
101
- const I = g(
102
- (r) => C(r.target.value),
84
+ var l;
85
+ (l = N.current) == null || l.scrollIntoView({ behavior: "smooth", block: "end" });
86
+ }, [e.length, n]);
87
+ const j = g(
88
+ (l) => y(l.target.value),
103
89
  []
104
- ), A = g(
105
- (r) => {
106
- r.preventDefault();
107
- const m = b.trim();
108
- !m || l || (o(m), C(""));
90
+ ), B = g(
91
+ (l) => {
92
+ l.preventDefault();
93
+ const u = x.trim();
94
+ !u || n || (r(u), y(""));
109
95
  },
110
- [b, l, o]
111
- ), j = t.reduce(
112
- (r, m, x) => m.role === "assistant" ? x : r,
96
+ [x, n, r]
97
+ ), R = e.reduce(
98
+ (l, u, v) => u.role === "assistant" ? v : l,
113
99
  -1
114
- ), v = t.filter((r) => r.role !== "system");
115
- return /* @__PURE__ */ c(
100
+ ), w = e.filter((l) => l.role !== "system");
101
+ return /* @__PURE__ */ s(
116
102
  "div",
117
103
  {
118
- className: p(
104
+ className: h(
119
105
  "flex flex-col h-full bg-background text-foreground overflow-hidden",
120
- h
106
+ b
121
107
  ),
122
108
  children: [
123
- (n || i || l || a) && /* @__PURE__ */ e(
124
- K,
109
+ (a || c || n || o) && /* @__PURE__ */ t(
110
+ W,
125
111
  {
126
- status: _,
127
- provider: n,
128
- model: i
112
+ status: A,
113
+ provider: a,
114
+ model: c
129
115
  }
130
116
  ),
131
- /* @__PURE__ */ c("div", { className: "flex-1 overflow-y-auto px-4 py-4 scroll-smooth [scrollbar-width:thin] [scrollbar-color:hsl(var(--border))_transparent]", children: [
132
- v.length === 0 && /* @__PURE__ */ c("div", { className: "flex flex-col items-center justify-center h-full gap-2 text-muted-foreground/50 select-none", children: [
133
- /* @__PURE__ */ e(N, { name: "sparkles", size: 28 }),
134
- /* @__PURE__ */ e("p", { className: "text-sm", children: "Start a conversation" }),
135
- s && s.length > 0 && /* @__PURE__ */ e("div", { className: "mt-2 select-auto", children: /* @__PURE__ */ e(E, { children: s.map((r) => /* @__PURE__ */ e(F, { onClick: () => (k ?? o)(r), children: r }, r)) }) })
117
+ /* @__PURE__ */ s("div", { className: "flex-1 overflow-y-auto px-4 py-4 scroll-smooth [scrollbar-width:thin] [scrollbar-color:hsl(var(--border))_transparent]", children: [
118
+ w.length === 0 && /* @__PURE__ */ s("div", { className: "flex flex-col items-center justify-center h-full gap-2 text-muted-foreground/50 select-none", children: [
119
+ /* @__PURE__ */ t(C, { name: "sparkles", size: 28 }),
120
+ /* @__PURE__ */ t("p", { className: "text-sm", children: "Start a conversation" }),
121
+ p && p.length > 0 && /* @__PURE__ */ t("div", { className: "mt-2 select-auto", children: /* @__PURE__ */ t(G, { children: p.map((l) => /* @__PURE__ */ t(V, { onClick: () => (f ?? r)(l), children: l }, l)) }) })
136
122
  ] }),
137
- v.map((r, m) => {
138
- const x = t.indexOf(r);
139
- return /* @__PURE__ */ e(
140
- H,
123
+ w.map((l, u) => {
124
+ const v = e.indexOf(l);
125
+ return /* @__PURE__ */ t(
126
+ M,
141
127
  {
142
- message: r,
143
- isLastAssistant: x === j,
144
- isStreaming: l,
145
- renderContent: u ? (T) => u(T, r.role) : void 0
128
+ message: l,
129
+ isLastAssistant: v === R,
130
+ isStreaming: n,
131
+ renderContent: d ? (T) => d(T, l.role) : void 0,
132
+ renderToolCall: I
146
133
  },
147
- m
134
+ u
148
135
  );
149
136
  }),
150
- /* @__PURE__ */ e("div", { ref: y })
137
+ /* @__PURE__ */ t("div", { ref: N })
151
138
  ] }),
152
- a && /* @__PURE__ */ c("div", { className: "shrink-0 mx-3 mb-2 flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: [
153
- /* @__PURE__ */ e(N, { name: "alert-circle", size: 14, className: "mt-px shrink-0" }),
154
- /* @__PURE__ */ e("span", { className: "leading-snug", children: a })
139
+ o && /* @__PURE__ */ s("div", { className: "shrink-0 mx-3 mb-2 flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: [
140
+ /* @__PURE__ */ t(C, { name: "alert-circle", size: 14, className: "mt-px shrink-0" }),
141
+ /* @__PURE__ */ t("span", { className: "leading-snug", children: o })
155
142
  ] }),
156
- /* @__PURE__ */ e(
143
+ /* @__PURE__ */ t(
157
144
  "div",
158
145
  {
159
- className: p(
146
+ className: h(
160
147
  "shrink-0 border-t border-border/60 bg-background/80 backdrop-blur-sm transition-opacity",
161
- l && "opacity-70"
148
+ n && "opacity-70"
162
149
  ),
163
- children: /* @__PURE__ */ e(
164
- $,
150
+ children: /* @__PURE__ */ t(
151
+ F,
165
152
  {
166
- value: b,
167
- onChange: I,
168
- onSubmit: A,
169
- placeholder: l ? "Waiting for response…" : f
153
+ value: x,
154
+ onChange: j,
155
+ onSubmit: B,
156
+ placeholder: n ? "Waiting for response…" : m
170
157
  }
171
158
  )
172
159
  }
@@ -176,5 +163,5 @@ const W = () => /* @__PURE__ */ e("div", { className: "flex items-center gap-1 p
176
163
  );
177
164
  };
178
165
  export {
179
- mt as AIChatThread
166
+ Z as AIChatThread
180
167
  };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * What a data-driven AI card is showing: still loading, failed, or ready.
3
+ *
4
+ * A data-driven card takes this as a `state` prop and renders it; whatever
5
+ * fetches the data lives outside this presentational package (#85).
6
+ *
7
+ * `sample` marks data from the demo lake, so a card can say so. A demo number
8
+ * that looks like a real quote is worse than no number.
9
+ */
10
+ export type CardState<T> = {
11
+ status: 'loading';
12
+ } | {
13
+ status: 'error';
14
+ message: string;
15
+ } | {
16
+ status: 'ready';
17
+ data: T;
18
+ sample?: boolean;
19
+ };
@@ -0,0 +1,81 @@
1
+ import React from 'react';
2
+ export type DocumentScanMode = 'idle' | 'tracking' | 'looping' | 'done' | 'error';
3
+ export interface DocumentScanBox {
4
+ /** Left edge, as a fraction of the page width (0–1). */
5
+ x: number;
6
+ /** Top edge, as a fraction of the page height (0–1), measured from the top. */
7
+ y: number;
8
+ /** Width, as a fraction of the page width. */
9
+ w: number;
10
+ /** Height, as a fraction of the page height. */
11
+ h: number;
12
+ /** Optional words on the box, e.g. "Table · 4 × 3". */
13
+ label?: string;
14
+ }
15
+ export interface DocumentScanViewProps {
16
+ /** The page image. Until it loads, the frame holds its shape so nothing below moves. */
17
+ src?: string | null;
18
+ /** Which page is shown, counted from 1. */
19
+ page: number;
20
+ /** How many pages the document has, when known. */
21
+ pageCount?: number | null;
22
+ /**
23
+ * What the parser is doing.
24
+ * - `tracking`: progress is real (pages are reported as they finish); the sweep runs over the page being read.
25
+ * - `looping`: the parser reports no progress (a cloud job); the sweep loops until the result lands.
26
+ * - `done` / `error` / `idle`: no sweep.
27
+ */
28
+ mode: DocumentScanMode;
29
+ /** Share of the document finished, 0–1. Shown as a bar in `tracking` mode. */
30
+ progress?: number;
31
+ /** Regions found on this page — tables, usually — drawn where they sit. */
32
+ boxes?: DocumentScanBox[];
33
+ /** Heading above the page, e.g. "Docling · local". */
34
+ title?: string;
35
+ /** One line under the page: what is happening, in words. Announced to screen readers. */
36
+ status?: string;
37
+ /** Width ÷ height of a page, used before the image loads. Defaults to US Letter. */
38
+ aspectRatio?: number;
39
+ className?: string;
40
+ }
41
+ /**
42
+ * @wizard
43
+ * @name DocumentScanView
44
+ * @description A document page with a scanning sweep while a parser reads it, and the regions it found outlined where they sit on the page. Strategic purpose: makes a slow, invisible job legible — in `tracking` mode the page and the progress bar follow real progress; in `looping` mode it says plainly that the parser reports none. Built for comparing parsers side by side.
45
+ * @tags document, pdf, scan, parser, ocr, progress, compare, viewer
46
+ * @category data-display
47
+ * @props
48
+ * - name: src
49
+ * type: string | null
50
+ * description: The page image URL (a blob URL works). The frame keeps its aspect ratio before it loads, so nothing below it moves.
51
+ * - name: page
52
+ * type: number
53
+ * description: The page shown, counted from 1.
54
+ * - name: pageCount
55
+ * type: number | null
56
+ * description: Total pages, when known.
57
+ * - name: mode
58
+ * type: 'idle' | 'tracking' | 'looping' | 'done' | 'error'
59
+ * description: tracking = real progress, sweep over the page being read; looping = no progress reported, sweep loops; done/error/idle = no sweep.
60
+ * - name: progress
61
+ * type: number
62
+ * description: Share of the document finished, 0–1, shown as a bar in tracking mode.
63
+ * - name: boxes
64
+ * type: DocumentScanBox[]
65
+ * description: Regions found on this page as fractions of the page ({ x, y, w, h, label? }), top-left origin.
66
+ * - name: title
67
+ * type: string
68
+ * description: Heading above the page.
69
+ * - name: status
70
+ * type: string
71
+ * description: One line describing what is happening; announced politely to screen readers.
72
+ * - name: aspectRatio
73
+ * type: number
74
+ * description: Page width ÷ height before the image loads.
75
+ * default: 0.7727 (US Letter)
76
+ * - name: className
77
+ * type: string
78
+ * description: Additional classes for the outer element.
79
+ * @id document-scan-view
80
+ */
81
+ export declare const DocumentScanView: React.FC<DocumentScanViewProps>;
@@ -0,0 +1,79 @@
1
+ import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
+ import { cn as l } from "../../utils/cn.js";
3
+ const N = ({
4
+ src: s,
5
+ page: o,
6
+ pageCount: d,
7
+ mode: r,
8
+ progress: g,
9
+ boxes: n = [],
10
+ title: i,
11
+ status: c,
12
+ aspectRatio: f = 8.5 / 11,
13
+ className: p
14
+ }) => {
15
+ const h = r === "tracking" || r === "looping", m = Math.round(Math.min(1, Math.max(0, g ?? 0)) * 100), u = d ? `Page ${o} of ${d}` : `Page ${o}`, b = n.length === 1 ? "1 region found" : `${n.length} regions found`;
16
+ return /* @__PURE__ */ t("figure", { className: l("flex flex-col gap-2", p), children: [
17
+ (i || r === "tracking") && /* @__PURE__ */ t("figcaption", { className: "flex items-center justify-between gap-2 text-sm", children: [
18
+ i && /* @__PURE__ */ e("span", { className: "font-semibold text-foreground", children: i }),
19
+ /* @__PURE__ */ t("span", { className: "tabular-nums text-muted-foreground", children: [
20
+ u,
21
+ r === "tracking" ? ` · ${m}%` : ""
22
+ ] })
23
+ ] }),
24
+ /* @__PURE__ */ t(
25
+ "div",
26
+ {
27
+ className: "relative w-full overflow-hidden rounded-md border border-border bg-surface-muted aspect-[var(--page-ratio)]",
28
+ style: { "--page-ratio": String(f) },
29
+ role: "img",
30
+ "aria-label": `${u}${n.length ? `, ${b}` : ""}`,
31
+ children: [
32
+ s && /* @__PURE__ */ e("img", { src: s, alt: "", className: "absolute inset-0 h-full w-full object-contain", draggable: !1 }),
33
+ n.map((a, x) => /* @__PURE__ */ e(
34
+ "div",
35
+ {
36
+ className: "absolute rounded-sm bg-primary/10 ring-2 ring-primary transition-opacity duration-300",
37
+ style: { left: `${a.x * 100}%`, top: `${a.y * 100}%`, width: `${a.w * 100}%`, height: `${a.h * 100}%` },
38
+ children: a.label && /* @__PURE__ */ e(
39
+ "span",
40
+ {
41
+ className: l(
42
+ "absolute left-0 whitespace-nowrap rounded-sm bg-primary px-1.5 py-0.5 text-xs text-primary-foreground",
43
+ // Above the box normally; inside it when the box touches the
44
+ // top of the page, where a label above would be clipped.
45
+ a.y < 0.06 ? "top-1 left-1" : "-top-6"
46
+ ),
47
+ children: a.label
48
+ }
49
+ )
50
+ },
51
+ x
52
+ )),
53
+ h && /* @__PURE__ */ t("div", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 animate-scan-sweep motion-reduce:hidden", children: [
54
+ /* @__PURE__ */ e("div", { className: "absolute inset-x-0 bottom-0 h-1/4 bg-gradient-to-b from-transparent to-primary/25" }),
55
+ /* @__PURE__ */ e("div", { className: "absolute inset-x-0 bottom-0 h-0.5 bg-primary" })
56
+ ] })
57
+ ]
58
+ }
59
+ ),
60
+ r === "tracking" && /* @__PURE__ */ e("div", { className: "h-1 w-full overflow-hidden rounded-full bg-surface-muted", "aria-hidden": "true", children: /* @__PURE__ */ e(
61
+ "div",
62
+ {
63
+ className: "h-full origin-left rounded-full bg-primary transition-transform duration-300",
64
+ style: { transform: `scaleX(${m / 100})` }
65
+ }
66
+ ) }),
67
+ c && /* @__PURE__ */ e(
68
+ "p",
69
+ {
70
+ className: l("text-sm", r === "error" ? "text-destructive" : "text-muted-foreground"),
71
+ "aria-live": "polite",
72
+ children: c
73
+ }
74
+ )
75
+ ] });
76
+ };
77
+ export {
78
+ N as DocumentScanView
79
+ };
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ export interface GalleryItem {
3
+ /** The image. Leave it out for a slot whose photo has not been taken yet: a placeholder holds its place. */
4
+ src?: string;
5
+ /** Widths of the same image, as an `<img srcset>` ("a-640.webp 640w, a-1280.webp 1280w"), so a phone fetches the small one. */
6
+ srcSet?: string;
7
+ /** A small copy for the thumbnail row. Without it the thumbnail loads `src`. */
8
+ thumbSrc?: string;
9
+ /** Says what the image shows. Also names the placeholder, so it says what is missing. */
10
+ alt: string;
11
+ /** One line under the main image while this item is showing. */
12
+ caption?: string;
13
+ /** Drawn content instead of an image — an SVG figure, a live preview. Wins over `src`. */
14
+ content?: React.ReactNode;
15
+ /** What the thumbnail shows for a `content` item. An image item uses its own `src`. */
16
+ thumb?: React.ReactNode;
17
+ }
18
+ export interface GalleryProps {
19
+ items: GalleryItem[];
20
+ /** Names the gallery for assistive technology, e.g. "Photos of the yellow board". */
21
+ label: string;
22
+ /** The main frame's aspect ratio, as CSS. Every slide shares it, so nothing moves as images load. */
23
+ aspectRatio?: string;
24
+ /** How wide the gallery renders, as an `<img sizes>` value, so the browser picks the right `srcSet` width. Defaults to the full viewport. */
25
+ sizes?: string;
26
+ className?: string;
27
+ }
28
+ /**
29
+ * @wizard
30
+ * @name Gallery
31
+ * @description A main image with a row of thumbnails beneath it. Swipe the main image on a phone (native CSS scroll-snap, no library), use the arrow keys when it has focus, or tap a thumbnail. Every slide shares one aspect ratio, so the frame reserves its space before any image loads and nothing below it moves. An item with no `src` shows a labelled placeholder, so a page can ship before its photos exist. Strategic purpose: product and detail pages that show a physical thing from several sides. Use DataTable or Table for data, not this.
32
+ * @tags gallery, carousel, images, photos, media, slideshow
33
+ * @props
34
+ * - name: items
35
+ * type: "{ src?: string; srcSet?: string; thumbSrc?: string; alt: string; caption?: string; content?: ReactNode; thumb?: ReactNode }[]"
36
+ * description: The slides, in order. Leave out `src` for a placeholder; pass `content` to show a drawing instead of a photo; give `srcSet` and `thumbSrc` so a phone downloads small files.
37
+ * - name: label
38
+ * type: string
39
+ * description: An accessible name for the gallery.
40
+ * - name: aspectRatio
41
+ * type: string
42
+ * description: The CSS aspect ratio of the main frame. Defaults to "4 / 3".
43
+ * - name: sizes
44
+ * type: string
45
+ * description: The rendered width as an img `sizes` value, so the browser picks the right srcSet width.
46
+ * @category data-display
47
+ * @id gallery
48
+ */
49
+ export declare const Gallery: React.FC<GalleryProps>;