reifyui 0.15.2 → 0.16.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.
@@ -188,3 +188,39 @@ export interface AgentConversationProps extends MarkProps {
188
188
  empty?: ReactNode;
189
189
  }
190
190
  export function AgentConversation(props: AgentConversationProps): ReactElement;
191
+
192
+ export interface ArtifactFile { key: string; name: string; url: string }
193
+ export interface ArtifactPanelProps {
194
+ files: ArtifactFile[];
195
+ /** the key of the file shown (default: the first) */
196
+ active?: string | null;
197
+ onSelect?: (key: string) => void;
198
+ onClose?: () => void;
199
+ /** a drawer over the page from the right (a narrow screen) instead of a docked column */
200
+ overlay?: boolean;
201
+ label?: string;
202
+ fetchFile?: (url: string) => Promise<Response>;
203
+ renderMarkdown?: (text: string) => ReactNode;
204
+ officePdfUrl?: (url: string) => string;
205
+ parseWorkbook?: (buf: ArrayBuffer) => Promise<{ name: string; filled: boolean; rows: unknown[][] }[]>;
206
+ onDownload?: (url: string, name: string) => void;
207
+ className?: string;
208
+ }
209
+ export function ArtifactPanel(props: ArtifactPanelProps): ReactElement | null;
210
+ export interface FileCardProps {
211
+ name: string; origin?: string; bytes?: number;
212
+ onPreview?: () => void; onDownload?: () => void;
213
+ /** copy the file's text; resolve when copied, reject when it could not be */
214
+ onCopy?: () => Promise<void> | void;
215
+ /** the file open in the preview */
216
+ active?: boolean;
217
+ /** an image's own picture (a url the browser can load, e.g. an object url) instead of its kind's icon */
218
+ thumb?: string;
219
+ className?: string;
220
+ }
221
+ export function FileCard(props: FileCardProps): ReactElement;
222
+ export function FilePreview(props: {
223
+ file: { url: string; name: string } | null; onClose?: () => void; fetchFile?: (url: string) => Promise<Response>;
224
+ officePdfUrl?: (url: string) => string; renderMarkdown?: (text: string) => ReactNode;
225
+ parseWorkbook?: ArtifactPanelProps['parseWorkbook']; onDownload?: (url: string, name: string) => void; title?: string; before?: ReactNode;
226
+ }): ReactElement;
@@ -5,6 +5,9 @@ import {
5
5
  CopyButton,
6
6
  DEFAULT_AGENT_LABELS,
7
7
  DiffBadge,
8
+ FileCard,
9
+ FilePreview,
10
+ FileTypeIcon,
8
11
  LinesBlock,
9
12
  StepRow,
10
13
  StreamingText,
@@ -44,8 +47,8 @@ import {
44
47
  useElapsed,
45
48
  useNow,
46
49
  useStickToBottom
47
- } from "./chunk-SF5QML3U.js";
48
- import "./chunk-WAND7AYD.js";
50
+ } from "./chunk-UP3CNKZR.js";
51
+ import "./chunk-QCISEB67.js";
49
52
  import "./chunk-PZ5AY32C.js";
50
53
 
51
54
  // src/agent-chat/marks.js
@@ -104,13 +107,101 @@ function motionFor(base) {
104
107
  const k = String(base || "").toLowerCase().trim();
105
108
  return MARK_MOTIONS[k] || "pulse";
106
109
  }
110
+
111
+ // src/agent-chat/artifacts.jsx
112
+ import React, { useEffect, useRef } from "react";
113
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
114
+ function ArtifactPanel(props) {
115
+ const {
116
+ files = [],
117
+ active,
118
+ onSelect,
119
+ onClose,
120
+ overlay = false,
121
+ label = "Files in this conversation",
122
+ fetchFile,
123
+ renderMarkdown,
124
+ officePdfUrl,
125
+ parseWorkbook,
126
+ onDownload,
127
+ className
128
+ } = props;
129
+ const ref = useRef(null);
130
+ const cur = files.find((f) => f.key === active) || files[0] || null;
131
+ useEffect(() => {
132
+ if (!overlay || !cur) return void 0;
133
+ const back = document.activeElement;
134
+ const t = setTimeout(() => {
135
+ const b = ref.current && ref.current.querySelector("button");
136
+ if (b) b.focus();
137
+ }, 0);
138
+ const key = (e) => {
139
+ if (e.key === "Escape") {
140
+ e.stopPropagation();
141
+ onClose && onClose();
142
+ }
143
+ };
144
+ document.addEventListener("keydown", key);
145
+ return () => {
146
+ clearTimeout(t);
147
+ document.removeEventListener("keydown", key);
148
+ if (back && back.focus) back.focus();
149
+ };
150
+ }, [overlay, !!cur]);
151
+ if (!cur) return null;
152
+ const switcher = files.length > 1 ? /* @__PURE__ */ jsx("nav", { className: "uac-art-files", "aria-label": label, children: files.map((f) => /* @__PURE__ */ jsxs(
153
+ "button",
154
+ {
155
+ type: "button",
156
+ className: "uac-art-file" + (f.key === cur.key ? " is-on" : ""),
157
+ "aria-current": f.key === cur.key ? "true" : void 0,
158
+ title: f.name,
159
+ onClick: () => onSelect && onSelect(f.key),
160
+ children: [
161
+ /* @__PURE__ */ jsx(FileTypeIcon, { name: f.name, size: 14 }),
162
+ /* @__PURE__ */ jsx("span", { children: f.name })
163
+ ]
164
+ },
165
+ f.key
166
+ )) }) : null;
167
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
168
+ overlay ? /* @__PURE__ */ jsx("div", { className: "uac-art-scrim", "aria-hidden": "true", onClick: () => onClose && onClose() }) : null,
169
+ /* @__PURE__ */ jsx(
170
+ "div",
171
+ {
172
+ ref,
173
+ className: "uac-art" + (overlay ? " is-overlay" : "") + (className ? ` ${className}` : ""),
174
+ role: overlay ? "dialog" : void 0,
175
+ "aria-modal": overlay ? "true" : void 0,
176
+ "aria-label": overlay ? `Preview of ${cur.name}` : void 0,
177
+ children: /* @__PURE__ */ jsx(
178
+ FilePreview,
179
+ {
180
+ file: { url: cur.url, name: cur.name },
181
+ onClose,
182
+ before: switcher,
183
+ fetchFile,
184
+ renderMarkdown,
185
+ officePdfUrl,
186
+ parseWorkbook,
187
+ onDownload
188
+ },
189
+ cur.key
190
+ )
191
+ }
192
+ )
193
+ ] });
194
+ }
107
195
  export {
108
196
  AgentComposer,
109
197
  AgentConversation,
110
198
  AgentTurnView,
199
+ ArtifactPanel,
111
200
  CopyButton,
112
201
  DEFAULT_AGENT_LABELS,
113
202
  DiffBadge,
203
+ FileCard,
204
+ FilePreview,
114
205
  LinesBlock,
115
206
  MARK_MOTIONS,
116
207
  MOTIONS,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/agent-chat/marks.js"],"sourcesContent":["// The working mark: each harness's own logo, moving the way that logo suggests.\n//\n// The package ships the MOTIONS (CSS keyframes in styles/agent-chat.css), never the logos: a\n// host passes its official mark as a node and names a motion. motionFor(base) is the house\n// choice for the harnesses we know, picked by looking at each mark:\n//\n// bloom the Claude starburst turns a quarter and breathes, like the CLI's ✻ ✽ ✶ spinner\n// sheen a light passes across the tile (Codex's prompt, Kimi's K, Kilo's grid)\n// glint brightens and swells, a spark catching light (Gemini)\n// flutter a quick wing beat, tilt and lift (Hermes, the messenger)\n// glide a bird's lift and settle (Goose)\n// blink the tile blinks shut and open, a terminal cursor (OpenCode)\n// flip a coin turning on its vertical axis (pi, omp)\n// swim a short wave from nose to tail (DeepSeek's whale)\n// spin a steady revolution, for round marks (Qwen, Grok, System One, OpenSquilla)\n// wave hands waving from the wrist (OpenHands)\n// dash a sprint forward and back (CheetahClaws)\n// scuttle a sideways skitter (ZeroClaw's crab)\n// equalize a level meter rising and falling (MiniMax's waveform)\n// bob a soft hop (robots and app tiles: Cline, Agent Zero, Qoder, nanobot)\n// pulse the default: scale and opacity breathing\n//\n// Every motion stops under prefers-reduced-motion; the mark then stands still and the line's\n// words alone say the work is going on.\n\nexport const MARK_MOTIONS = {\n 'claude-code': 'bloom', claude: 'bloom', anthropic: 'bloom',\n codex: 'sheen', openai: 'sheen',\n gemini: 'glint', 'gemini-cli': 'glint',\n hermes: 'flutter',\n goose: 'glide',\n opencode: 'blink',\n pi: 'flip', omp: 'flip',\n dsh: 'swim', deepseek: 'swim',\n qwen: 'spin', grok: 'spin', systemone: 'spin', opensquilla: 'spin',\n openhands: 'wave',\n cheetahclaws: 'dash',\n zeroclaw: 'scuttle',\n minimax: 'equalize',\n cline: 'bob', agentzero: 'bob', qoder: 'bob', nanobot: 'bob',\n kimi: 'sheen', kilo: 'sheen', jcode: 'pulse', mimo: 'pulse', aider: 'pulse',\n};\n\nexport const MOTIONS = ['bloom', 'sheen', 'glint', 'flutter', 'glide', 'blink', 'flip', 'swim', 'spin', 'wave',\n 'dash', 'scuttle', 'equalize', 'bob', 'pulse', 'dots'];\n\n/** The motion for a base harness id, 'pulse' for one we do not know. */\nexport function motionFor(base) {\n const k = String(base || '').toLowerCase().trim();\n return MARK_MOTIONS[k] || 'pulse';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,IAAM,eAAe;AAAA,EAC1B,eAAe;AAAA,EAAS,QAAQ;AAAA,EAAS,WAAW;AAAA,EACpD,OAAO;AAAA,EAAS,QAAQ;AAAA,EACxB,QAAQ;AAAA,EAAS,cAAc;AAAA,EAC/B,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,UAAU;AAAA,EACV,IAAI;AAAA,EAAQ,KAAK;AAAA,EACjB,KAAK;AAAA,EAAQ,UAAU;AAAA,EACvB,MAAM;AAAA,EAAQ,MAAM;AAAA,EAAQ,WAAW;AAAA,EAAQ,aAAa;AAAA,EAC5D,WAAW;AAAA,EACX,cAAc;AAAA,EACd,UAAU;AAAA,EACV,SAAS;AAAA,EACT,OAAO;AAAA,EAAO,WAAW;AAAA,EAAO,OAAO;AAAA,EAAO,SAAS;AAAA,EACvD,MAAM;AAAA,EAAS,MAAM;AAAA,EAAS,OAAO;AAAA,EAAS,MAAM;AAAA,EAAS,OAAO;AACtE;AAEO,IAAM,UAAU;AAAA,EAAC;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EAAW;AAAA,EAAS;AAAA,EAAS;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAQ;AAAA,EACtG;AAAA,EAAQ;AAAA,EAAW;AAAA,EAAY;AAAA,EAAO;AAAA,EAAS;AAAM;AAGhD,SAAS,UAAU,MAAM;AAC9B,QAAM,IAAI,OAAO,QAAQ,EAAE,EAAE,YAAY,EAAE,KAAK;AAChD,SAAO,aAAa,CAAC,KAAK;AAC5B;","names":[]}
1
+ {"version":3,"sources":["../src/agent-chat/marks.js","../src/agent-chat/artifacts.jsx"],"sourcesContent":["// The working mark: each harness's own logo, moving the way that logo suggests.\n//\n// The package ships the MOTIONS (CSS keyframes in styles/agent-chat.css), never the logos: a\n// host passes its official mark as a node and names a motion. motionFor(base) is the house\n// choice for the harnesses we know, picked by looking at each mark:\n//\n// bloom the Claude starburst turns a quarter and breathes, like the CLI's ✻ ✽ ✶ spinner\n// sheen a light passes across the tile (Codex's prompt, Kimi's K, Kilo's grid)\n// glint brightens and swells, a spark catching light (Gemini)\n// flutter a quick wing beat, tilt and lift (Hermes, the messenger)\n// glide a bird's lift and settle (Goose)\n// blink the tile blinks shut and open, a terminal cursor (OpenCode)\n// flip a coin turning on its vertical axis (pi, omp)\n// swim a short wave from nose to tail (DeepSeek's whale)\n// spin a steady revolution, for round marks (Qwen, Grok, System One, OpenSquilla)\n// wave hands waving from the wrist (OpenHands)\n// dash a sprint forward and back (CheetahClaws)\n// scuttle a sideways skitter (ZeroClaw's crab)\n// equalize a level meter rising and falling (MiniMax's waveform)\n// bob a soft hop (robots and app tiles: Cline, Agent Zero, Qoder, nanobot)\n// pulse the default: scale and opacity breathing\n//\n// Every motion stops under prefers-reduced-motion; the mark then stands still and the line's\n// words alone say the work is going on.\n\nexport const MARK_MOTIONS = {\n 'claude-code': 'bloom', claude: 'bloom', anthropic: 'bloom',\n codex: 'sheen', openai: 'sheen',\n gemini: 'glint', 'gemini-cli': 'glint',\n hermes: 'flutter',\n goose: 'glide',\n opencode: 'blink',\n pi: 'flip', omp: 'flip',\n dsh: 'swim', deepseek: 'swim',\n qwen: 'spin', grok: 'spin', systemone: 'spin', opensquilla: 'spin',\n openhands: 'wave',\n cheetahclaws: 'dash',\n zeroclaw: 'scuttle',\n minimax: 'equalize',\n cline: 'bob', agentzero: 'bob', qoder: 'bob', nanobot: 'bob',\n kimi: 'sheen', kilo: 'sheen', jcode: 'pulse', mimo: 'pulse', aider: 'pulse',\n};\n\nexport const MOTIONS = ['bloom', 'sheen', 'glint', 'flutter', 'glide', 'blink', 'flip', 'swim', 'spin', 'wave',\n 'dash', 'scuttle', 'equalize', 'bob', 'pulse', 'dots'];\n\n/** The motion for a base harness id, 'pulse' for one we do not know. */\nexport function motionFor(base) {\n const k = String(base || '').toLowerCase().trim();\n return MARK_MOTIONS[k] || 'pulse';\n}\n","// The files a turn produced, opened beside the conversation instead of printed into it.\n//\n// In the conversation a file is a card (the package's FileCard: its kind, Copy, Download, and the\n// whole card opens it). Opened, it shows here: the file rendered (Markdown as a document, code\n// highlighted, images, PDFs, sheets), a switcher across every file the conversation made, Copy,\n// Download and Close. Docked, it is a column the host places beside the chat; `overlay` makes it a\n// drawer over the page from the right, which is what a narrow screen gets.\n//\n// Transport and rendering stay the host's, exactly as for FilePreview: `fetchFile` (with the\n// host's auth), `renderMarkdown`, `officePdfUrl`, `parseWorkbook`, `onDownload`.\nimport React, { useEffect, useRef } from 'react';\nimport { FilePreview } from '../components/FilePreview.jsx';\nimport { FileTypeIcon } from '../components/FileTypeIcon.jsx';\n\n/**\n * files: [{ key, name, url }] (key: stable id, e.g. the file id); active: the key shown.\n */\nexport function ArtifactPanel(props) {\n const {\n files = [], active, onSelect, onClose, overlay = false, label = 'Files in this conversation',\n fetchFile, renderMarkdown, officePdfUrl, parseWorkbook, onDownload, className,\n } = props;\n const ref = useRef(null);\n const cur = files.find((f) => f.key === active) || files[0] || null;\n // a drawer takes the focus and gives it back with Escape, like any dialog\n useEffect(() => {\n if (!overlay || !cur) return undefined;\n const back = document.activeElement;\n const t = setTimeout(() => { const b = ref.current && ref.current.querySelector('button'); if (b) b.focus(); }, 0);\n const key = (e) => { if (e.key === 'Escape') { e.stopPropagation(); onClose && onClose(); } };\n document.addEventListener('keydown', key);\n return () => { clearTimeout(t); document.removeEventListener('keydown', key); if (back && back.focus) back.focus(); };\n }, [overlay, !!cur]); // eslint-disable-line react-hooks/exhaustive-deps\n if (!cur) return null;\n const switcher = files.length > 1 ? (\n <nav className=\"uac-art-files\" aria-label={label}>\n {files.map((f) => (\n <button key={f.key} type=\"button\" className={'uac-art-file' + (f.key === cur.key ? ' is-on' : '')}\n aria-current={f.key === cur.key ? 'true' : undefined} title={f.name} onClick={() => onSelect && onSelect(f.key)}>\n <FileTypeIcon name={f.name} size={14} /><span>{f.name}</span>\n </button>\n ))}\n </nav>\n ) : null;\n return (\n <>\n {overlay ? <div className=\"uac-art-scrim\" aria-hidden=\"true\" onClick={() => onClose && onClose()} /> : null}\n <div ref={ref} className={'uac-art' + (overlay ? ' is-overlay' : '') + (className ? ` ${className}` : '')}\n role={overlay ? 'dialog' : undefined} aria-modal={overlay ? 'true' : undefined} aria-label={overlay ? `Preview of ${cur.name}` : undefined}>\n <FilePreview key={cur.key} file={{ url: cur.url, name: cur.name }} onClose={onClose} before={switcher}\n fetchFile={fetchFile} renderMarkdown={renderMarkdown} officePdfUrl={officePdfUrl} parseWorkbook={parseWorkbook} onDownload={onDownload} />\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,IAAM,eAAe;AAAA,EAC1B,eAAe;AAAA,EAAS,QAAQ;AAAA,EAAS,WAAW;AAAA,EACpD,OAAO;AAAA,EAAS,QAAQ;AAAA,EACxB,QAAQ;AAAA,EAAS,cAAc;AAAA,EAC/B,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,UAAU;AAAA,EACV,IAAI;AAAA,EAAQ,KAAK;AAAA,EACjB,KAAK;AAAA,EAAQ,UAAU;AAAA,EACvB,MAAM;AAAA,EAAQ,MAAM;AAAA,EAAQ,WAAW;AAAA,EAAQ,aAAa;AAAA,EAC5D,WAAW;AAAA,EACX,cAAc;AAAA,EACd,UAAU;AAAA,EACV,SAAS;AAAA,EACT,OAAO;AAAA,EAAO,WAAW;AAAA,EAAO,OAAO;AAAA,EAAO,SAAS;AAAA,EACvD,MAAM;AAAA,EAAS,MAAM;AAAA,EAAS,OAAO;AAAA,EAAS,MAAM;AAAA,EAAS,OAAO;AACtE;AAEO,IAAM,UAAU;AAAA,EAAC;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EAAW;AAAA,EAAS;AAAA,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100
 
101
+ // src/components/CodeBlock.jsx
102
+ import React2 from "react";
103
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
104
+ var _hljsPromise = null;
105
+ function loadHljs() {
106
+ if (!_hljsPromise) {
107
+ _hljsPromise = import("highlight.js/lib/core").then((m) => m.default || m);
108
+ }
109
+ return _hljsPromise;
110
+ }
111
+ var GRAMMARS = {
112
+ javascript: () => import("highlight.js/lib/languages/javascript"),
113
+ typescript: () => import("highlight.js/lib/languages/typescript"),
114
+ python: () => import("highlight.js/lib/languages/python"),
115
+ json: () => import("highlight.js/lib/languages/json"),
116
+ bash: () => import("highlight.js/lib/languages/bash"),
117
+ sql: () => import("highlight.js/lib/languages/sql"),
118
+ java: () => import("highlight.js/lib/languages/java"),
119
+ go: () => import("highlight.js/lib/languages/go"),
120
+ rust: () => import("highlight.js/lib/languages/rust"),
121
+ xml: () => import("highlight.js/lib/languages/xml"),
122
+ css: () => import("highlight.js/lib/languages/css"),
123
+ yaml: () => import("highlight.js/lib/languages/yaml"),
124
+ groovy: () => import("highlight.js/lib/languages/groovy")
125
+ };
126
+ var ALIASES = {
127
+ js: "javascript",
128
+ jsx: "javascript",
129
+ mjs: "javascript",
130
+ cjs: "javascript",
131
+ node: "javascript",
132
+ ts: "typescript",
133
+ tsx: "typescript",
134
+ py: "python",
135
+ python3: "python",
136
+ sh: "bash",
137
+ shell: "bash",
138
+ zsh: "bash",
139
+ console: "bash",
140
+ html: "xml",
141
+ xhtml: "xml",
142
+ svg: "xml",
143
+ yml: "yaml",
144
+ golang: "go",
145
+ rs: "rust",
146
+ jsonc: "json",
147
+ postgres: "sql",
148
+ postgresql: "sql",
149
+ mysql: "sql",
150
+ plsql: "sql",
151
+ gremlin: "groovy"
152
+ };
153
+ function canonicalLang(tag) {
154
+ const t = String(tag || "").toLowerCase();
155
+ if (!t) return null;
156
+ const name = ALIASES[t] || t;
157
+ return GRAMMARS[name] ? name : null;
158
+ }
159
+ var _ready = /* @__PURE__ */ new Map();
160
+ function ensureLanguage(name) {
161
+ if (!_ready.has(name)) {
162
+ const p = Promise.all([loadHljs(), GRAMMARS[name]()]).then(([hljs, mod]) => {
163
+ if (!hljs.getLanguage(name)) hljs.registerLanguage(name, mod.default || mod);
164
+ return hljs;
165
+ }).catch(() => null);
166
+ _ready.set(name, p);
167
+ }
168
+ return _ready.get(name);
169
+ }
170
+ function CodeBlock(props) {
171
+ const { code, language, className } = props;
172
+ const src = String(code || "");
173
+ const lang = canonicalLang(language);
174
+ const [hl, setHl] = React2.useState(null);
175
+ React2.useEffect(() => {
176
+ if (!lang || !src) return void 0;
177
+ let cancelled = false;
178
+ const timer = setTimeout(() => {
179
+ ensureLanguage(lang).then((hljs) => {
180
+ if (!hljs || cancelled) return;
181
+ try {
182
+ const out = hljs.highlight(src, { language: lang, ignoreIllegals: true });
183
+ if (!cancelled) setHl({ src, html: out.value });
184
+ } catch {
185
+ }
186
+ });
187
+ }, 200);
188
+ return () => {
189
+ cancelled = true;
190
+ clearTimeout(timer);
191
+ };
192
+ }, [src, lang]);
193
+ const html = hl && hl.src === src ? hl.html : null;
194
+ const label = String(language || "").toLowerCase();
195
+ return /* @__PURE__ */ jsxs2("pre", { className: "wbx-code" + (className ? " " + className : ""), children: [
196
+ label ? /* @__PURE__ */ jsx2("span", { className: "wbx-code-lang", "aria-hidden": "true", children: label }) : null,
197
+ html != null ? /* @__PURE__ */ jsx2("code", { className: "hljs language-" + label, dangerouslySetInnerHTML: { __html: html } }) : /* @__PURE__ */ jsx2("code", { className: label ? "language-" + label : void 0, children: src })
198
+ ] });
199
+ }
200
+
101
201
  export {
102
202
  Svg,
103
203
  Chevron,
@@ -119,6 +219,7 @@ export {
119
219
  IcPaperclip,
120
220
  IcPanelRight,
121
221
  IcDownload,
122
- IcEye
222
+ IcEye,
223
+ CodeBlock
123
224
  };
124
- //# sourceMappingURL=chunk-WAND7AYD.js.map
225
+ //# sourceMappingURL=chunk-QCISEB67.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/icons.jsx","../src/components/CodeBlock.jsx"],"sourcesContent":["// Line-glyph icon set for the conversational surface (16-17px, currentColor stroke) —\n// extracted verbatim from HarnessRouter's workbench. Dependency-free (inline SVG only).\nimport React from 'react';\n\nexport function Svg({ children, s = 16 }) {\n return (\n <svg width={s} height={s} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\"\n strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\">{children}</svg>\n );\n}\n\nexport function Chevron({ dir, size = 16 }) {\n const d = dir === 'left' ? 'M15 18l-6-6 6-6' : dir === 'right' ? 'M9 18l6-6-6-6' : 'M6 9l6 6 6-6';\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\"\n strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d={d} /></svg>\n );\n}\n\n// ── tool-step icons (activity timeline) ──\nexport const IcTool = () => <Svg s={17}><path d=\"M14.7 6.3a4 4 0 0 1-5.4 5.4L4 17v3h3l5.3-5.3a4 4 0 0 1 5.4-5.4l-2.3 2.3-1.7-1.7 2.3-2.3a4 4 0 0 0-1.6 0Z\" /></Svg>;\nexport const IcPlug = () => <Svg s={17}><path d=\"M9 2v6M15 2v6M6 8h12v3a6 6 0 0 1-12 0z\" /><path d=\"M12 17v5\" /></Svg>;\nexport const IcSkill = () => <Svg s={17}><path d=\"M9 18h6M10 22h4\" /><path d=\"M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.3 1 2.1V18h6v-1.2c0-.8.4-1.6 1-2.1A7 7 0 0 0 12 2z\" /></Svg>;\nexport const IcTerminal = () => <Svg s={17}><rect x=\"3\" y=\"4\" width=\"18\" height=\"16\" rx=\"2\" /><path d=\"M7 9l3 3-3 3M13 15h4\" /></Svg>;\nexport const IcDoc = () => <Svg s={17}><path d=\"M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z\" /><path d=\"M14 3v6h6M8 13h8M8 17h6\" /></Svg>;\nexport const IcList = () => <Svg s={17}><path d=\"M8 6h12M8 12h12M8 18h12M3.5 6h.01M3.5 12h.01M3.5 18h.01\" /></Svg>;\nexport const IcGlobe = () => <Svg s={17}><circle cx=\"12\" cy=\"12\" r=\"9\" /><path d=\"M3 12h18M12 3a15 15 0 0 1 0 18a15 15 0 0 1 0-18z\" /></Svg>;\nexport const IcSearch = () => <Svg s={17}><circle cx=\"11\" cy=\"11\" r=\"7\" /><path d=\"m21 21-4.3-4.3\" /></Svg>;\nexport const IcScroll = () => <Svg s={17}><path d=\"M6 3h10a2 2 0 0 1 2 2v12a3 3 0 0 0 3 3H8a2 2 0 0 1-2-2V3z\" /><path d=\"M6 3a2 2 0 0 0-2 2v2h2M10 8h6M10 12h6\" /></Svg>;\nexport const IcSpawn = () => <Svg s={17}><circle cx=\"6\" cy=\"6\" r=\"3\" /><circle cx=\"18\" cy=\"18\" r=\"3\" /><path d=\"M6 9v3a3 3 0 0 0 3 3h6\" /></Svg>;\nexport const IcCheck = () => <Svg s={17}><circle cx=\"12\" cy=\"12\" r=\"9\" /><path d=\"m9 12 2 2 4-4\" /></Svg>;\nexport const IcThink = () => <Svg s={16}><path d=\"M9.5 2a5.5 5.5 0 0 0-3 10.1V15a2 2 0 0 0 2 2h3a2 2 0 0 0 2-2v-2.9A5.5 5.5 0 0 0 9.5 2zM9 20h4M10 22h2\" /></Svg>;\nexport const IcSend = () => <Svg s={16}><path d=\"M12 19V5\" /><path d=\"M5 12l7-7 7 7\" /></Svg>;\n\n// ── chrome glyphs (chat panel, chips, search) ──\n// The package draws its own so a consumer never inherits an icon-library dependency from a\n// component: four apps pull the same four glyphs out of lucide today purely to hand them to a\n// panel that could have drawn them itself.\nexport const IcX = ({ size = 14 }) => <Svg s={size}><path d=\"M18 6 6 18M6 6l12 12\" /></Svg>;\nexport const IcMic = ({ size = 15 }) => <Svg s={size}><rect x=\"9\" y=\"2\" width=\"6\" height=\"12\" rx=\"3\" /><path d=\"M5 11a7 7 0 0 0 14 0M12 18v4M8 22h8\" /></Svg>;\nexport const IcPaperclip = ({ size = 16 }) => <Svg s={size}><path d=\"M21.4 11.1 12.2 20.3a5.5 5.5 0 0 1-7.8-7.8l9.2-9.2a3.7 3.7 0 0 1 5.2 5.2l-9.2 9.2a1.8 1.8 0 0 1-2.6-2.6l8.5-8.5\" /></Svg>;\nexport const IcPanelRight = ({ size = 17 }) => <Svg s={size}><rect x=\"3\" y=\"4\" width=\"18\" height=\"16\" rx=\"2\" /><path d=\"M15 4v16\" /></Svg>;\nexport const IcDownload = ({ size = 16 }) => <Svg s={size}><path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\" /><path d=\"M7 10l5 5 5-5\" /><path d=\"M12 15V3\" /></Svg>;\nexport const IcEye = ({ size = 15 }) => <Svg s={size}><path d=\"M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7z\" /><circle cx=\"12\" cy=\"12\" r=\"3\" /></Svg>;\n","// Fenced code block with language-aware syntax highlighting (highlight.js core).\n//\n// Consumers wire this into their markdown renderer's `pre` override (see the ChatPanel /\n// workbench MD_COMPONENTS): a ```mermaid fence keeps rendering as a diagram; every other fence\n// renders here. Design notes (same lazy pattern as the Mermaid block):\n// - highlight.js is LAZY-loaded (dynamic import) — the core plus exactly one small grammar\n// chunk per language actually used, never the full-language bundle. Until it loads the block\n// renders as plain <pre><code>, byte-identical geometry, so there is no layout shift.\n// - Highlighting is DEBOUNCED: while a fence is still streaming in token by token we render\n// plain text and re-arm the timer; the block highlights once it settles. hljs itself never\n// throws on partial input, the debounce just avoids re-lexing on every token.\n// - Unknown / missing language: NO auto-detect, render plain. Wrong-language colors are worse\n// than none.\n// - `gremlin` maps to the groovy grammar (Gremlin is a Groovy DSL — closest match).\n// - Colors are token-driven: .wbx-code maps hljs classes onto five --uic-code-* custom\n// properties (keyword/string/comment/number/function) with defaults tuned for the dark\n// code-block background. See styles/chat.css + README \"Theming\".\n// highlight.js must be a dependency of the CONSUMING app (the dynamic import resolves in its\n// bundler) — same rule as mermaid.\nimport React from 'react';\n\nlet _hljsPromise = null;\nfunction loadHljs() {\n if (!_hljsPromise) {\n _hljsPromise = import('highlight.js/lib/core').then((m) => m.default || m);\n }\n return _hljsPromise;\n}\n\n// One static dynamic-import per grammar so each becomes its own code-split chunk and only the\n// languages that actually appear in a conversation ever download.\nconst GRAMMARS = {\n javascript: () => import('highlight.js/lib/languages/javascript'),\n typescript: () => import('highlight.js/lib/languages/typescript'),\n python: () => import('highlight.js/lib/languages/python'),\n json: () => import('highlight.js/lib/languages/json'),\n bash: () => import('highlight.js/lib/languages/bash'),\n sql: () => import('highlight.js/lib/languages/sql'),\n java: () => import('highlight.js/lib/languages/java'),\n go: () => import('highlight.js/lib/languages/go'),\n rust: () => import('highlight.js/lib/languages/rust'),\n xml: () => import('highlight.js/lib/languages/xml'),\n css: () => import('highlight.js/lib/languages/css'),\n yaml: () => import('highlight.js/lib/languages/yaml'),\n groovy: () => import('highlight.js/lib/languages/groovy'),\n};\n\n// Fence-tag aliases → canonical grammar name.\nconst ALIASES = {\n js: 'javascript', jsx: 'javascript', mjs: 'javascript', cjs: 'javascript', node: 'javascript',\n ts: 'typescript', tsx: 'typescript',\n py: 'python', python3: 'python',\n sh: 'bash', shell: 'bash', zsh: 'bash', console: 'bash',\n html: 'xml', xhtml: 'xml', svg: 'xml',\n yml: 'yaml',\n golang: 'go',\n rs: 'rust',\n jsonc: 'json',\n postgres: 'sql', postgresql: 'sql', mysql: 'sql', plsql: 'sql',\n gremlin: 'groovy',\n};\n\nfunction canonicalLang(tag) {\n const t = String(tag || '').toLowerCase();\n if (!t) return null;\n const name = ALIASES[t] || t;\n return GRAMMARS[name] ? name : null;\n}\n\n// canonical name -> Promise<hljs | null> (null = load failed; stay plain forever, never retry-loop)\nconst _ready = new Map();\nfunction ensureLanguage(name) {\n if (!_ready.has(name)) {\n const p = Promise.all([loadHljs(), GRAMMARS[name]()])\n .then(([hljs, mod]) => {\n if (!hljs.getLanguage(name)) hljs.registerLanguage(name, mod.default || mod);\n return hljs;\n })\n .catch(() => null);\n _ready.set(name, p);\n }\n return _ready.get(name);\n}\n\nexport function CodeBlock(props) {\n const { code, language, className } = props;\n const src = String(code || '');\n const lang = canonicalLang(language);\n const [hl, setHl] = React.useState(null); // { src, html } — html valid only for exactly that src\n\n React.useEffect(() => {\n if (!lang || !src) return undefined;\n let cancelled = false;\n // Debounce: during streaming the fence grows every few ms — wait for a quiet gap, then\n // highlight the settled source. hljs output is fully HTML-escaped (safe to inject).\n const timer = setTimeout(() => {\n ensureLanguage(lang).then((hljs) => {\n if (!hljs || cancelled) return;\n try {\n const out = hljs.highlight(src, { language: lang, ignoreIllegals: true });\n if (!cancelled) setHl({ src, html: out.value });\n } catch {\n /* stay plain */\n }\n });\n }, 200);\n return () => { cancelled = true; clearTimeout(timer); };\n }, [src, lang]);\n\n const html = hl && hl.src === src ? hl.html : null;\n const label = String(language || '').toLowerCase();\n return (\n <pre className={'wbx-code' + (className ? ' ' + className : '')}>\n {label ? <span className=\"wbx-code-lang\" aria-hidden=\"true\">{label}</span> : null}\n {html != null\n ? <code className={'hljs language-' + label} dangerouslySetInnerHTML={{ __html: html }} />\n : <code className={label ? 'language-' + label : undefined}>{src}</code>}\n </pre>\n );\n}\n"],"mappings":";AAEA,OAAO,WAAW;AAId,cAewB,YAfxB;AAFG,SAAS,IAAI,EAAE,UAAU,IAAI,GAAG,GAAG;AACxC,SACE;AAAA,IAAC;AAAA;AAAA,MAAI,OAAO;AAAA,MAAG,QAAQ;AAAA,MAAG,SAAQ;AAAA,MAAY,MAAK;AAAA,MAAO,QAAO;AAAA,MAC/D,aAAY;AAAA,MAAM,eAAc;AAAA,MAAQ,gBAAe;AAAA,MAAS;AAAA;AAAA,EAAS;AAE/E;AAEO,SAAS,QAAQ,EAAE,KAAK,OAAO,GAAG,GAAG;AAC1C,QAAM,IAAI,QAAQ,SAAS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 useOverlayEscape
6
+ } from "./chunk-J633KV57.js";
7
+
8
+ // src/components/Modal.jsx
9
+ import React, { useCallback, useEffect, useId } from "react";
10
+ import { createPortal } from "react-dom";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ function Modal(props) {
13
+ const {
14
+ open,
15
+ onClose,
16
+ title,
17
+ description,
18
+ actions,
19
+ size = "md",
20
+ width,
21
+ labelledBy,
22
+ children,
23
+ classNames = {}
24
+ } = props;
25
+ const titleId = useId();
26
+ const escape = useCallback(() => onClose?.(), [onClose]);
27
+ useOverlayEscape(open, escape);
28
+ useEffect(() => {
29
+ if (!open || typeof document === "undefined") return void 0;
30
+ const prev = document.body.style.overflow;
31
+ document.body.style.overflow = "hidden";
32
+ return () => {
33
+ document.body.style.overflow = prev;
34
+ };
35
+ }, [open]);
36
+ if (!open || typeof document === "undefined") return null;
37
+ const onBackdrop = (e) => {
38
+ if (e.target === e.currentTarget) onClose?.();
39
+ };
40
+ return createPortal(
41
+ /* @__PURE__ */ jsx(
42
+ "div",
43
+ {
44
+ className: ["uic-modal-backdrop", classNames.backdrop || ""].filter(Boolean).join(" "),
45
+ onMouseDown: onBackdrop,
46
+ children: /* @__PURE__ */ jsxs(
47
+ "div",
48
+ {
49
+ className: ["uic-modal", `is-${size}`, classNames.root || ""].filter(Boolean).join(" "),
50
+ style: width ? { width } : void 0,
51
+ role: "dialog",
52
+ "aria-modal": "true",
53
+ "aria-labelledby": labelledBy || (title ? titleId : void 0),
54
+ children: [
55
+ title || actions ? /* @__PURE__ */ jsxs("div", { className: "uic-modal-h", children: [
56
+ /* @__PURE__ */ jsxs("div", { className: "uic-modal-title", children: [
57
+ title ? /* @__PURE__ */ jsx("h3", { id: titleId, children: title }) : null,
58
+ description ? /* @__PURE__ */ jsx("p", { children: description }) : null
59
+ ] }),
60
+ actions,
61
+ /* @__PURE__ */ jsx("button", { type: "button", className: "uic-modal-x", "aria-label": "Close", onClick: onClose, children: /* @__PURE__ */ jsx(IcX, { size: 18 }) })
62
+ ] }) : null,
63
+ /* @__PURE__ */ jsx("div", { className: ["uic-modal-b", classNames.body || ""].filter(Boolean).join(" "), children })
64
+ ]
65
+ }
66
+ )
67
+ }
68
+ ),
69
+ document.body
70
+ );
71
+ }
72
+
73
+ export {
74
+ Modal
75
+ };
76
+ //# sourceMappingURL=chunk-SPLQ7T6F.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Modal.jsx"],"sourcesContent":["// Modal — a dialog whose body is yours: a preview, a big form, a comparison.\n//\n// useDialog() answers a QUESTION and resolves to a value (confirm/prompt/alert). This is the\n// other half: a surface with arbitrary content that the caller opens and closes itself. Products\n// were re-implementing it per feature, each with its own backdrop mousedown handler and its own\n// document keydown listener.\n//\n// It shares the dialog host's Escape ordering through the package's overlay stack (components/\n// overlay.js), so a Modal opened on top of a confirm takes the key and the confirm does not, and\n// both sit at the same z-index layer (--uic-z-overlay). It does NOT render inside DialogHost's\n// portal: that root is created from the host's private state and only exists while a dialog is\n// open, so there is nothing to render into and no API to reach it with. One stack, two roots, is\n// the honest arrangement — and it means Modal works in an app that never mounted DialogHost.\nimport React, { useCallback, useEffect, useId } from 'react';\nimport { createPortal } from 'react-dom';\nimport { IcX } from './icons.jsx';\nimport { useOverlayEscape } from './overlay.js';\n\n/**\n * open render it\n * onClose Escape, the ✕, or a click on the backdrop itself\n * title the heading (string or node); also names the dialog for assistive tech\n * description one quiet line under the title\n * actions buttons in the header, before the ✕ (e.g. \"Use this template\")\n * size 'sm' | 'md' | 'lg' | 'full' — or pass `width` for an exact px/any CSS width\n * labelledBy id of your own heading, when `title` is not where the name lives\n */\nexport function Modal(props) {\n const { open, onClose, title, description, actions, size = 'md', width,\n labelledBy, children, classNames = {} } = props;\n const titleId = useId();\n\n const escape = useCallback(() => onClose?.(), [onClose]);\n useOverlayEscape(open, escape);\n\n // A modal that leaves the page scrolling behind it drifts under the reader's fingers on a\n // touch device and loses their place in the list they opened it from.\n useEffect(() => {\n if (!open || typeof document === 'undefined') return undefined;\n const prev = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n return () => { document.body.style.overflow = prev; };\n }, [open]);\n\n if (!open || typeof document === 'undefined') return null;\n // mousedown, not click: a press that STARTED inside the card and ended on the backdrop (a drag\n // that overshot, a text selection) would otherwise close it out from under the person.\n const onBackdrop = (e) => { if (e.target === e.currentTarget) onClose?.(); };\n return createPortal(\n <div className={['uic-modal-backdrop', classNames.backdrop || ''].filter(Boolean).join(' ')}\n onMouseDown={onBackdrop}>\n <div className={['uic-modal', `is-${size}`, classNames.root || ''].filter(Boolean).join(' ')}\n style={width ? { width } : undefined}\n role=\"dialog\" aria-modal=\"true\"\n aria-labelledby={labelledBy || (title ? titleId : undefined)}>\n {(title || actions) ? (\n <div className=\"uic-modal-h\">\n <div className=\"uic-modal-title\">\n {title ? <h3 id={titleId}>{title}</h3> : null}\n {description ? <p>{description}</p> : null}\n </div>\n {actions}\n <button type=\"button\" className=\"uic-modal-x\" aria-label=\"Close\" onClick={onClose}>\n <IcX size={18} />\n </button>\n </div>\n ) : null}\n <div className={['uic-modal-b', classNames.body || ''].filter(Boolean).join(' ')}>\n {children}\n </div>\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;AAaA,OAAO,SAAS,aAAa,WAAW,aAAa;AACrD,SAAS,oBAAoB;AA2CjB,SACW,KADX;AA9BL,SAAS,MAAM,OAAO;AAC3B,QAAM;AAAA,IAAE;AAAA,IAAM;AAAA,IAAS;AAAA,IAAO;AAAA,IAAa;AAAA,IAAS,OAAO;AAAA,IAAM;AAAA,IACzD;AAAA,IAAY;AAAA,IAAU,aAAa,CAAC;AAAA,EAAE,IAAI;AAClD,QAAM,UAAU,MAAM;AAEtB,QAAM,SAAS,YAAY,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC;AACvD,mBAAiB,MAAM,MAAM;AAI7B,YAAU,MAAM;AACd,QAAI,CAAC,QAAQ,OAAO,aAAa,YAAa,QAAO;AACrD,UAAM,OAAO,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