reifyui 0.16.0 → 0.17.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.
- package/dist/agent-chat.cjs +224 -23
- package/dist/agent-chat.cjs.map +1 -1
- package/dist/agent-chat.d.ts +22 -1
- package/dist/agent-chat.js +212 -19
- package/dist/agent-chat.js.map +1 -1
- package/dist/{chunk-4SVQGVJH.js → chunk-6HGZN2SQ.js} +17 -7
- package/dist/chunk-6HGZN2SQ.js.map +1 -0
- package/dist/index.cjs +5 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/agent-chat/artifacts.jsx +160 -19
- package/src/agent-chat/index.d.ts +22 -1
- package/src/agent-chat/index.js +1 -1
- package/src/components/FileCard.jsx +4 -2
- package/src/components/FilePreview.jsx +3 -2
- package/styles/agent-chat.css +41 -7
- package/styles/file.css +2 -0
- package/dist/chunk-4SVQGVJH.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reifyui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "The open-source rendering & interaction layer for agentic applications. Stream and render any agent's output as polished, application-native UI — model-agnostic, framework-agnostic, design-system-native. The foundation for building generative-UI and agent products.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -1,23 +1,173 @@
|
|
|
1
1
|
// The files a turn produced, opened beside the conversation instead of printed into it.
|
|
2
2
|
//
|
|
3
3
|
// In the conversation a file is a card (the package's FileCard: its kind, Copy, Download, and the
|
|
4
|
-
// whole card opens it). Opened, it shows here: the file
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
4
|
+
// whole card opens it). Opened, it shows here, under ONE header row: the file's kind, its name as a
|
|
5
|
+
// switcher (a dropdown of every file of the conversation, grouped by folder, filterable when there are
|
|
6
|
+
// many, keyboard driven), then Copy, Download and Close. Below, the file rendered (Markdown as a
|
|
7
|
+
// document, code highlighted, images, PDFs, sheets). Docked, it is a column the host places beside the
|
|
8
|
+
// chat; `overlay` makes it a drawer over the page from the right, and on a phone the dropdown is a
|
|
9
|
+
// sheet from the bottom.
|
|
8
10
|
//
|
|
9
11
|
// Transport and rendering stay the host's, exactly as for FilePreview: `fetchFile` (with the
|
|
10
12
|
// host's auth), `renderMarkdown`, `officePdfUrl`, `parseWorkbook`, `onDownload`.
|
|
11
|
-
import React, { useEffect, useRef } from 'react';
|
|
13
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
12
14
|
import { FilePreview } from '../components/FilePreview.jsx';
|
|
13
15
|
import { FileTypeIcon } from '../components/FileTypeIcon.jsx';
|
|
16
|
+
import { bytesLabel } from '../format.js';
|
|
17
|
+
|
|
18
|
+
const FILTER_AT = 8; // more files than this, and the list opens with a filter box
|
|
19
|
+
|
|
20
|
+
/** "epsilla-enterprise-subscr…store-v2.png": the start and the end, which is where names differ. */
|
|
21
|
+
export function middleEllipsis(name, max = 40) {
|
|
22
|
+
const s = String(name || '');
|
|
23
|
+
if (s.length <= max) return s;
|
|
24
|
+
const tail = Math.min(Math.max(10, Math.floor(max * 0.45)), max - 4);
|
|
25
|
+
return `${s.slice(0, max - tail - 1)}…${s.slice(-tail)}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** A name that truncates in the MIDDLE at whatever width it gets: the start shrinks with an ellipsis,
|
|
29
|
+
* the end (where similar names differ: "-v2", the extension) always shows. */
|
|
30
|
+
export function MidName(props) {
|
|
31
|
+
const { name, className } = props;
|
|
32
|
+
const s = String(name || '');
|
|
33
|
+
const cut = s.length > 16 ? s.length - Math.min(14, Math.floor(s.length / 2)) : s.length;
|
|
34
|
+
return (
|
|
35
|
+
<span className={'uac-mid' + (className ? ` ${className}` : '')}>
|
|
36
|
+
<span className="uac-mid-h">{s.slice(0, cut)}</span>{cut < s.length ? <span className="uac-mid-t">{s.slice(cut)}</span> : null}
|
|
37
|
+
</span>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function dirOf(path) {
|
|
42
|
+
const p = String(path || '');
|
|
43
|
+
const i = p.lastIndexOf('/');
|
|
44
|
+
return i > 0 ? p.slice(0, i) : '';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function Check() {
|
|
48
|
+
return (
|
|
49
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
50
|
+
<path d="M5 12l5 5L20 7" />
|
|
51
|
+
</svg>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The name in the header, as a dropdown of every file. `files`: [{key, name, path?, size?, turn?}]. */
|
|
56
|
+
export function FileSwitcher(props) {
|
|
57
|
+
const { files, current, onSelect, label = 'Files in this conversation', turnLabel = (n) => `Turn ${n}` } = props;
|
|
58
|
+
const [open, setOpen] = useState(false);
|
|
59
|
+
const [q, setQ] = useState('');
|
|
60
|
+
const [hi, setHi] = useState(0);
|
|
61
|
+
const root = useRef(null);
|
|
62
|
+
const list = useRef(null);
|
|
63
|
+
const input = useRef(null);
|
|
64
|
+
const btn = useRef(null);
|
|
65
|
+
const id = useRef(`uac-fs-${Math.random().toString(36).slice(2, 9)}`).current;
|
|
66
|
+
const cur = files.find((f) => f.key === current) || files[0];
|
|
67
|
+
const needle = q.trim().toLowerCase();
|
|
68
|
+
const shown = useMemo(() => files.filter((f) => !needle || String(f.path || f.name).toLowerCase().includes(needle)), [files, needle]);
|
|
69
|
+
// by folder, in the order folders first appear; the root (no folder) first
|
|
70
|
+
const groups = useMemo(() => {
|
|
71
|
+
const by = new Map();
|
|
72
|
+
for (const f of shown) {
|
|
73
|
+
const d = dirOf(f.path);
|
|
74
|
+
if (!by.has(d)) by.set(d, []);
|
|
75
|
+
by.get(d).push(f);
|
|
76
|
+
}
|
|
77
|
+
return [...by.entries()].sort((a, b) => (a[0] === '' ? -1 : b[0] === '' ? 1 : 0));
|
|
78
|
+
}, [shown]);
|
|
79
|
+
const flat = groups.flatMap(([, fs]) => fs);
|
|
80
|
+
const grouped = groups.length > 1 || (groups.length === 1 && groups[0][0] !== '');
|
|
81
|
+
const many = files.length > FILTER_AT;
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!open) return undefined;
|
|
85
|
+
setHi(Math.max(0, flat.findIndex((f) => f.key === (cur && cur.key))));
|
|
86
|
+
const t = setTimeout(() => { if (many && input.current) input.current.focus(); else if (list.current) list.current.focus(); }, 0);
|
|
87
|
+
const away = (e) => { if (root.current && !root.current.contains(e.target)) setOpen(false); };
|
|
88
|
+
document.addEventListener('mousedown', away);
|
|
89
|
+
document.addEventListener('touchstart', away);
|
|
90
|
+
return () => { clearTimeout(t); document.removeEventListener('mousedown', away); document.removeEventListener('touchstart', away); };
|
|
91
|
+
}, [open]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
92
|
+
useEffect(() => { setHi(0); }, [needle]);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (!open || !list.current) return;
|
|
95
|
+
const el = list.current.querySelector(`[data-i="${hi}"]`);
|
|
96
|
+
if (el && el.scrollIntoView) el.scrollIntoView({ block: 'nearest' });
|
|
97
|
+
}, [hi, open]);
|
|
98
|
+
|
|
99
|
+
if (!cur) return null;
|
|
100
|
+
const pick = (f) => { setOpen(false); setQ(''); if (f && onSelect) onSelect(f.key); if (btn.current) btn.current.focus(); };
|
|
101
|
+
const keys = (e) => {
|
|
102
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); setHi((i) => Math.min(flat.length - 1, i + 1)); }
|
|
103
|
+
else if (e.key === 'ArrowUp') { e.preventDefault(); setHi((i) => Math.max(0, i - 1)); }
|
|
104
|
+
else if (e.key === 'Home') { e.preventDefault(); setHi(0); }
|
|
105
|
+
else if (e.key === 'End') { e.preventDefault(); setHi(flat.length - 1); }
|
|
106
|
+
else if (e.key === 'Enter') { e.preventDefault(); pick(flat[hi]); }
|
|
107
|
+
else if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); setOpen(false); if (btn.current) btn.current.focus(); }
|
|
108
|
+
else if (e.key === 'Tab') setOpen(false);
|
|
109
|
+
};
|
|
110
|
+
const single = files.length < 2;
|
|
111
|
+
let i = -1;
|
|
112
|
+
return (
|
|
113
|
+
<div ref={root} className={'uac-fs' + (open ? ' is-open' : '')}>
|
|
114
|
+
<button ref={btn} type="button" className="uac-fs-btn" title={cur.path || cur.name} disabled={single}
|
|
115
|
+
aria-haspopup={single ? undefined : 'listbox'} aria-expanded={single ? undefined : open} aria-controls={single ? undefined : id}
|
|
116
|
+
onClick={() => setOpen((v) => !v)}
|
|
117
|
+
onKeyDown={(e) => { if (!single && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) { e.preventDefault(); setOpen(true); } }}>
|
|
118
|
+
<MidName name={cur.name} className="uac-fs-name" />
|
|
119
|
+
{single ? null : (
|
|
120
|
+
<svg className="uac-fs-chev" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M6 9l6 6 6-6" /></svg>
|
|
121
|
+
)}
|
|
122
|
+
</button>
|
|
123
|
+
{open ? (
|
|
124
|
+
<>
|
|
125
|
+
<div className="uac-fs-scrim" aria-hidden="true" onClick={() => setOpen(false)} />
|
|
126
|
+
<div className="uac-fs-pop" onKeyDown={keys}>
|
|
127
|
+
<div className="uac-fs-head"><span>{label}</span><span className="uac-fs-count">{files.length}</span></div>
|
|
128
|
+
{many ? (
|
|
129
|
+
<input ref={input} className="uac-fs-q" type="search" placeholder="Find a file" value={q} autoComplete="off" spellCheck={false}
|
|
130
|
+
aria-label="Find a file" aria-controls={id} onChange={(e) => setQ(e.target.value)} />
|
|
131
|
+
) : null}
|
|
132
|
+
<div ref={list} id={id} className="uac-fs-list" role="listbox" tabIndex={-1} aria-label={label}
|
|
133
|
+
aria-activedescendant={flat[hi] ? `${id}-${hi}` : undefined}>
|
|
134
|
+
{groups.map(([dir, fs]) => (
|
|
135
|
+
<div key={dir || '.'} role="group" aria-label={dir || 'Top level'}>
|
|
136
|
+
{grouped ? <div className="uac-fs-dir" aria-hidden="true">{dir || 'Top level'}</div> : null}
|
|
137
|
+
{fs.map((f) => {
|
|
138
|
+
i += 1;
|
|
139
|
+
const n = i;
|
|
140
|
+
const on = f.key === cur.key;
|
|
141
|
+
const meta = [f.size != null ? bytesLabel(f.size) : '', f.turn != null ? turnLabel(f.turn) : ''].filter(Boolean).join(' · ');
|
|
142
|
+
return (
|
|
143
|
+
<div key={f.key} id={`${id}-${n}`} data-i={n} role="option" aria-selected={on}
|
|
144
|
+
className={'uac-fs-opt' + (on ? ' is-on' : '') + (n === hi ? ' is-hi' : '')}
|
|
145
|
+
title={f.path || f.name} onMouseEnter={() => setHi(n)} onClick={() => pick(f)}>
|
|
146
|
+
<FileTypeIcon name={f.name} size={16} />
|
|
147
|
+
<MidName name={f.name} className="uac-fs-on" />
|
|
148
|
+
{meta ? <span className="uac-fs-meta">{meta}</span> : null}
|
|
149
|
+
<span className="uac-fs-ck">{on ? <Check /> : null}</span>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
})}
|
|
153
|
+
</div>
|
|
154
|
+
))}
|
|
155
|
+
{!flat.length ? <div className="uac-fs-none">No file matches.</div> : null}
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
</>
|
|
159
|
+
) : null}
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
14
163
|
|
|
15
164
|
/**
|
|
16
|
-
* files: [{ key, name, url }] (key: stable id, e.g. the file id
|
|
165
|
+
* files: [{ key, name, url, path?, size?, turn? }] (key: stable id, e.g. the file id; path: where it
|
|
166
|
+
* sits in the workspace, for folders; size in bytes and the turn that made it, when known).
|
|
17
167
|
*/
|
|
18
168
|
export function ArtifactPanel(props) {
|
|
19
169
|
const {
|
|
20
|
-
files = [], active, onSelect, onClose, overlay = false, label = 'Files in this conversation',
|
|
170
|
+
files = [], active, onSelect, onClose, overlay = false, label = 'Files in this conversation', turnLabel,
|
|
21
171
|
fetchFile, renderMarkdown, officePdfUrl, parseWorkbook, onDownload, className,
|
|
22
172
|
} = props;
|
|
23
173
|
const ref = useRef(null);
|
|
@@ -27,27 +177,18 @@ export function ArtifactPanel(props) {
|
|
|
27
177
|
if (!overlay || !cur) return undefined;
|
|
28
178
|
const back = document.activeElement;
|
|
29
179
|
const t = setTimeout(() => { const b = ref.current && ref.current.querySelector('button'); if (b) b.focus(); }, 0);
|
|
30
|
-
const key = (e) => { if (e.key === 'Escape') { e.stopPropagation(); onClose && onClose(); } };
|
|
180
|
+
const key = (e) => { if (e.key === 'Escape' && !e.defaultPrevented) { e.stopPropagation(); onClose && onClose(); } };
|
|
31
181
|
document.addEventListener('keydown', key);
|
|
32
182
|
return () => { clearTimeout(t); document.removeEventListener('keydown', key); if (back && back.focus) back.focus(); };
|
|
33
183
|
}, [overlay, !!cur]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
34
184
|
if (!cur) return null;
|
|
35
|
-
const switcher = files.
|
|
36
|
-
<nav className="uac-art-files" aria-label={label}>
|
|
37
|
-
{files.map((f) => (
|
|
38
|
-
<button key={f.key} type="button" className={'uac-art-file' + (f.key === cur.key ? ' is-on' : '')}
|
|
39
|
-
aria-current={f.key === cur.key ? 'true' : undefined} title={f.name} onClick={() => onSelect && onSelect(f.key)}>
|
|
40
|
-
<FileTypeIcon name={f.name} size={14} /><span>{f.name}</span>
|
|
41
|
-
</button>
|
|
42
|
-
))}
|
|
43
|
-
</nav>
|
|
44
|
-
) : null;
|
|
185
|
+
const switcher = <FileSwitcher files={files} current={cur.key} onSelect={onSelect} label={label} turnLabel={turnLabel} />;
|
|
45
186
|
return (
|
|
46
187
|
<>
|
|
47
188
|
{overlay ? <div className="uac-art-scrim" aria-hidden="true" onClick={() => onClose && onClose()} /> : null}
|
|
48
189
|
<div ref={ref} className={'uac-art' + (overlay ? ' is-overlay' : '') + (className ? ` ${className}` : '')}
|
|
49
190
|
role={overlay ? 'dialog' : undefined} aria-modal={overlay ? 'true' : undefined} aria-label={overlay ? `Preview of ${cur.name}` : undefined}>
|
|
50
|
-
<FilePreview key={cur.key} file={{ url: cur.url, name: cur.name }} onClose={onClose}
|
|
191
|
+
<FilePreview key={cur.key} file={{ url: cur.url, name: cur.name }} onClose={onClose} nameSlot={switcher}
|
|
51
192
|
fetchFile={fetchFile} renderMarkdown={renderMarkdown} officePdfUrl={officePdfUrl} parseWorkbook={parseWorkbook} onDownload={onDownload} />
|
|
52
193
|
</div>
|
|
53
194
|
</>
|
|
@@ -189,7 +189,15 @@ export interface AgentConversationProps extends MarkProps {
|
|
|
189
189
|
}
|
|
190
190
|
export function AgentConversation(props: AgentConversationProps): ReactElement;
|
|
191
191
|
|
|
192
|
-
export interface ArtifactFile {
|
|
192
|
+
export interface ArtifactFile {
|
|
193
|
+
key: string; name: string; url: string;
|
|
194
|
+
/** where it sits in the workspace (files are grouped by its folder) */
|
|
195
|
+
path?: string;
|
|
196
|
+
/** bytes, when known */
|
|
197
|
+
size?: number;
|
|
198
|
+
/** the turn that made it (1-based), when known */
|
|
199
|
+
turn?: number;
|
|
200
|
+
}
|
|
193
201
|
export interface ArtifactPanelProps {
|
|
194
202
|
files: ArtifactFile[];
|
|
195
203
|
/** the key of the file shown (default: the first) */
|
|
@@ -199,6 +207,8 @@ export interface ArtifactPanelProps {
|
|
|
199
207
|
/** a drawer over the page from the right (a narrow screen) instead of a docked column */
|
|
200
208
|
overlay?: boolean;
|
|
201
209
|
label?: string;
|
|
210
|
+
/** the words for "made in turn n" in the file list (default "Turn n") */
|
|
211
|
+
turnLabel?: (n: number) => string;
|
|
202
212
|
fetchFile?: (url: string) => Promise<Response>;
|
|
203
213
|
renderMarkdown?: (text: string) => ReactNode;
|
|
204
214
|
officePdfUrl?: (url: string) => string;
|
|
@@ -207,6 +217,13 @@ export interface ArtifactPanelProps {
|
|
|
207
217
|
className?: string;
|
|
208
218
|
}
|
|
209
219
|
export function ArtifactPanel(props: ArtifactPanelProps): ReactElement | null;
|
|
220
|
+
/** The preview header's file name as a dropdown of every file (ArtifactPanel uses it). */
|
|
221
|
+
export function FileSwitcher(props: { files: Omit<ArtifactFile, 'url'>[]; current: string; onSelect?: (key: string) => void; label?: string;
|
|
222
|
+
turnLabel?: (n: number) => string }): ReactElement | null;
|
|
223
|
+
/** "epsilla-enterprise-subscr…store-v2.png": the start and the end of a long name. */
|
|
224
|
+
export function middleEllipsis(name: string, max?: number): string;
|
|
225
|
+
/** A name truncated in the middle at whatever width it is given: the end always shows. */
|
|
226
|
+
export function MidName(props: { name: string; className?: string }): ReactElement;
|
|
210
227
|
export interface FileCardProps {
|
|
211
228
|
name: string; origin?: string; bytes?: number;
|
|
212
229
|
onPreview?: () => void; onDownload?: () => void;
|
|
@@ -214,6 +231,8 @@ export interface FileCardProps {
|
|
|
214
231
|
onCopy?: () => Promise<void> | void;
|
|
215
232
|
/** the file open in the preview */
|
|
216
233
|
active?: boolean;
|
|
234
|
+
/** an image's own picture (a url the browser can load, e.g. an object url) instead of its kind's icon */
|
|
235
|
+
thumb?: string;
|
|
217
236
|
className?: string;
|
|
218
237
|
}
|
|
219
238
|
export function FileCard(props: FileCardProps): ReactElement;
|
|
@@ -221,4 +240,6 @@ export function FilePreview(props: {
|
|
|
221
240
|
file: { url: string; name: string } | null; onClose?: () => void; fetchFile?: (url: string) => Promise<Response>;
|
|
222
241
|
officePdfUrl?: (url: string) => string; renderMarkdown?: (text: string) => ReactNode;
|
|
223
242
|
parseWorkbook?: ArtifactPanelProps['parseWorkbook']; onDownload?: (url: string, name: string) => void; title?: string; before?: ReactNode;
|
|
243
|
+
/** a control in the name's place in the header row (a file switcher) */
|
|
244
|
+
nameSlot?: ReactNode;
|
|
224
245
|
}): ReactElement;
|
package/src/agent-chat/index.js
CHANGED
|
@@ -24,6 +24,6 @@ export { AgentConversation, AgentTurnView, WorkGroup, StepRow, ThinkingRow, Todo
|
|
|
24
24
|
StreamingText, TurnOutcome, UserBubble, AgentComposer, CopyButton, DiffBadge, LinesBlock, useStickToBottom,
|
|
25
25
|
DEFAULT_AGENT_LABELS } from './components.jsx';
|
|
26
26
|
// the files a turn made: cards in the conversation (FileCard), opened beside it (ArtifactPanel)
|
|
27
|
-
export { ArtifactPanel } from './artifacts.jsx';
|
|
27
|
+
export { ArtifactPanel, FileSwitcher, MidName, middleEllipsis } from './artifacts.jsx';
|
|
28
28
|
export { FileCard } from '../components/FileCard.jsx';
|
|
29
29
|
export { FilePreview } from '../components/FilePreview.jsx';
|
|
@@ -30,7 +30,7 @@ export function bytesLabel(n) {
|
|
|
30
30
|
return `${(n / 1048576).toFixed(1)} MB`;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export function FileCard({ name, origin = 'output', bytes, onPreview, onDownload, onCopy, active = false, className = '' }) {
|
|
33
|
+
export function FileCard({ name, origin = 'output', bytes, onPreview, onDownload, onCopy, active = false, thumb, className = '' }) {
|
|
34
34
|
// Copy: the host copies the file's text (it owns the read); the card says it did, briefly.
|
|
35
35
|
const [copied, setCopied] = useState('');
|
|
36
36
|
useEffect(() => { if (!copied) return undefined; const t = setTimeout(() => setCopied(''), 1600); return () => clearTimeout(t); }, [copied]);
|
|
@@ -45,7 +45,9 @@ export function FileCard({ name, origin = 'output', bytes, onPreview, onDownload
|
|
|
45
45
|
tabIndex={open ? 0 : undefined}
|
|
46
46
|
onKeyDown={open ? (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); open(e); } } : undefined}
|
|
47
47
|
title={name}>
|
|
48
|
-
|
|
48
|
+
{/* an image shows itself (the host hands a url it can read, e.g. an object url); else its kind */}
|
|
49
|
+
{thumb ? <span className="uic-filecard-thumb"><img src={thumb} alt="" /></span>
|
|
50
|
+
: <span className="uic-filecard-ic"><FileTypeIcon name={name} size={32} /></span>}
|
|
49
51
|
<span className="uic-filecard-meta">
|
|
50
52
|
<span className="uic-filecard-name">{name}</span>
|
|
51
53
|
<span className="uic-filecard-sub">{subtitle(name, origin, bytes)}</span>
|
|
@@ -95,7 +95,7 @@ const defaultDownload = (url, name) => {
|
|
|
95
95
|
* all. Async, so the caller can load its spreadsheet library lazily.
|
|
96
96
|
*/
|
|
97
97
|
export function FilePreview({
|
|
98
|
-
file, onClose, fetchFile, officePdfUrl, renderMarkdown, parseWorkbook, onDownload, title, before,
|
|
98
|
+
file, onClose, fetchFile, officePdfUrl, renderMarkdown, parseWorkbook, onDownload, title, before, nameSlot,
|
|
99
99
|
}) {
|
|
100
100
|
const { url, name } = file || {};
|
|
101
101
|
const [st, setSt] = useState({ kind: 'loading' });
|
|
@@ -175,7 +175,8 @@ export function FilePreview({
|
|
|
175
175
|
{before}
|
|
176
176
|
<header className="uic-fp-head">
|
|
177
177
|
<span className="uic-fp-ic"><FileTypeIcon name={name} size={20} /></span>
|
|
178
|
-
|
|
178
|
+
{/* nameSlot: the host's own control in the name's place (a file switcher), in the same row */}
|
|
179
|
+
{nameSlot || <span className="uic-fp-name" title={name}>{name}</span>}
|
|
179
180
|
{st.kind === 'html' && (
|
|
180
181
|
<div className="uic-fp-seg" role="tablist" aria-label="Show the page or its source">
|
|
181
182
|
{[['preview', 'Preview'], ['source', 'Source']].map(([id, label]) => (
|
package/styles/agent-chat.css
CHANGED
|
@@ -283,13 +283,46 @@
|
|
|
283
283
|
styles are reifyui/styles/file.css) ─────────────────────────────────────────────────── */
|
|
284
284
|
.uac-art { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; background: var(--_surface); color: var(--_ink); }
|
|
285
285
|
.uac-art > .uic-fp { flex: 1; min-height: 0; height: 100%; display: flex; flex-direction: column; }
|
|
286
|
-
.uac-art-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
.uac-
|
|
290
|
-
.
|
|
291
|
-
.uac-
|
|
292
|
-
.uac-
|
|
286
|
+
.uac-art .uic-fp-head { position: relative; gap: 8px; }
|
|
287
|
+
/* the file name in the header is a switcher: a dropdown of every file of the conversation */
|
|
288
|
+
.uac-fs { position: relative; flex: 1 1 auto; min-width: 0; display: flex; }
|
|
289
|
+
.uac-fs-btn { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-width: 0; margin: 0; padding: 4px 6px 4px 4px; border: 0; border-radius: 8px;
|
|
290
|
+
background: none; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--_ink); cursor: pointer; text-align: left; }
|
|
291
|
+
.uac-fs-btn:hover:not(:disabled), .uac-fs.is-open .uac-fs-btn { background: var(--_hover); }
|
|
292
|
+
.uac-fs-btn:disabled { cursor: default; opacity: 1; }
|
|
293
|
+
.uac-fs-btn:focus-visible { outline: 2px solid var(--_brand); outline-offset: 1px; }
|
|
294
|
+
.uac-mid { display: inline-flex; min-width: 0; max-width: 100%; white-space: nowrap; }
|
|
295
|
+
.uac-mid-h { min-width: 1ch; overflow: hidden; text-overflow: ellipsis; }
|
|
296
|
+
.uac-mid-t { flex: none; }
|
|
297
|
+
.uac-fs-name { min-width: 0; }
|
|
298
|
+
.uac-fs-chev { flex: none; color: var(--_faint); transition: transform .15s; }
|
|
299
|
+
.uac-fs.is-open .uac-fs-chev { transform: rotate(180deg); }
|
|
300
|
+
.uac-fs-scrim { display: none; }
|
|
301
|
+
.uac-fs-pop { position: absolute; top: calc(100% + 6px); left: -32px; z-index: 30; width: min(440px, calc(100vw - 24px)); max-height: min(60vh, 520px);
|
|
302
|
+
display: flex; flex-direction: column; background: var(--_surface); color: var(--_ink); border: 1px solid var(--_line); border-radius: 12px;
|
|
303
|
+
box-shadow: 0 16px 40px -14px rgba(15, 23, 42, .35); overflow: hidden; }
|
|
304
|
+
.uac-fs-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px; font-size: 11px; font-weight: 600;
|
|
305
|
+
letter-spacing: .06em; text-transform: uppercase; color: var(--_faint); }
|
|
306
|
+
.uac-fs-count { font-variant-numeric: tabular-nums; }
|
|
307
|
+
.uac-fs-q { margin: 2px 10px 6px; padding: 7px 10px; border: 1px solid var(--_line); border-radius: 8px; background: var(--_surface-2); font: inherit;
|
|
308
|
+
font-size: 13px; color: var(--_ink); outline: 0; }
|
|
309
|
+
.uac-fs-q:focus { border-color: color-mix(in srgb, var(--_brand) 45%, var(--_line)); }
|
|
310
|
+
.uac-fs-list { flex: 1; min-height: 0; overflow: auto; padding: 2px 6px 8px; outline: 0; }
|
|
311
|
+
.uac-fs-dir { padding: 8px 8px 3px; font-size: 11.5px; color: var(--_faint); font-family: var(--_mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
312
|
+
.uac-fs-opt { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--_ink-2); min-width: 0; }
|
|
313
|
+
.uac-fs-opt.is-hi { background: var(--_hover); }
|
|
314
|
+
.uac-fs-opt.is-on { color: var(--_ink); font-weight: 600; }
|
|
315
|
+
.uac-fs-on { flex: 1; min-width: 0; }
|
|
316
|
+
.uac-fs-meta { flex: none; font-size: 11.5px; font-weight: 400; color: var(--_faint); font-variant-numeric: tabular-nums; }
|
|
317
|
+
.uac-fs-ck { flex: none; width: 16px; display: grid; place-items: center; color: var(--_brand); }
|
|
318
|
+
.uac-fs-none { padding: 12px 10px; font-size: 13px; color: var(--_faint); }
|
|
319
|
+
/* a phone: the list is a sheet from the bottom of the screen */
|
|
320
|
+
@media (max-width: 560px) {
|
|
321
|
+
.uac-fs-scrim { display: block; position: fixed; inset: 0; z-index: calc(var(--uac-z-overlay, 60) + 1); background: var(--uic-scrim, rgba(17, 24, 39, .42)); }
|
|
322
|
+
.uac-fs-pop { position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 75vh; z-index: calc(var(--uac-z-overlay, 60) + 2);
|
|
323
|
+
border-radius: 16px 16px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
|
|
324
|
+
.uac-fs-opt { padding: 11px 10px; font-size: 14px; }
|
|
325
|
+
}
|
|
293
326
|
.uac-art.is-overlay { position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 100vw); height: auto; z-index: var(--uac-z-overlay, 60);
|
|
294
327
|
box-shadow: -16px 0 40px rgba(15, 23, 42, .22); padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
|
|
295
328
|
animation: uac-art-in .18s ease-out; }
|
|
@@ -320,5 +353,6 @@
|
|
|
320
353
|
.uac-ring::before { border-color: var(--_brand); }
|
|
321
354
|
.uac-composer, .uac-send { transition: none; }
|
|
322
355
|
.uac-art.is-overlay { animation: none; }
|
|
356
|
+
.uac-fs-chev { transition: none; }
|
|
323
357
|
}
|
|
324
358
|
.uac-mark.is-still .uac-mark-in, .uac-mark.is-still .uac-mark-aura, .uac-mark.is-still i { animation: none; }
|
package/styles/file.css
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
/* the file open in a preview beside the conversation */
|
|
17
17
|
.uic-filecard.is-active { border-color: var(--uic-brand, #285AFF); box-shadow: 0 0 0 3px var(--uic-focus-ring, rgba(40, 90, 255, .14)); }
|
|
18
18
|
.uic-filecard-ic { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
|
|
19
|
+
.uic-filecard-thumb { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 8px; overflow: hidden; background: var(--uic-surface-2, #F7F8FA); border: 1px solid var(--uic-line, #DDDFE6); }
|
|
20
|
+
.uic-filecard-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
|
|
19
21
|
.uic-filecard-meta { flex: 1 1 auto; min-width: 0; }
|
|
20
22
|
.uic-filecard-name {
|
|
21
23
|
display: block; font-size: 13.5px; font-weight: 600; color: var(--uic-ink, #111317);
|