@tangle-network/agent-app 0.58.19 → 0.58.20
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/VaultPane-UNX4CWSM.js +7 -0
- package/dist/{chunk-UGPV7VEW.js → chunk-QPMEXMH6.js} +235 -501
- package/dist/chunk-QPMEXMH6.js.map +1 -0
- package/dist/vault/VaultPane.d.ts +1 -1
- package/dist/vault/contracts.d.ts +4 -2
- package/dist/vault/index.d.ts +2 -2
- package/dist/vault/index.js +5 -4
- package/dist/vault/index.js.map +1 -1
- package/dist/vault/lazy.js +1 -1
- package/dist/vault/recent-files.d.ts +10 -0
- package/package.json +3 -3
- package/dist/VaultPane-RIJM452Y.js +0 -7
- package/dist/chunk-UGPV7VEW.js.map +0 -1
- package/dist/vault/VaultTree.d.ts +0 -39
- /package/dist/{VaultPane-RIJM452Y.js.map → VaultPane-UNX4CWSM.js.map} +0 -0
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import {
|
|
3
3
|
Component,
|
|
4
4
|
forwardRef,
|
|
5
|
-
useCallback
|
|
6
|
-
useEffect as
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect as useEffect2,
|
|
7
7
|
useImperativeHandle,
|
|
8
8
|
useLayoutEffect,
|
|
9
9
|
useId,
|
|
10
|
-
useMemo
|
|
11
|
-
useRef as
|
|
12
|
-
useState
|
|
10
|
+
useMemo,
|
|
11
|
+
useRef as useRef2,
|
|
12
|
+
useState
|
|
13
13
|
} from "react";
|
|
14
|
-
import { Download, Folder
|
|
14
|
+
import { Download, FileText, Folder, Plus, RefreshCw, Trash2 } from "lucide-react";
|
|
15
15
|
|
|
16
16
|
// src/vault/ConfirmDialog.tsx
|
|
17
17
|
import { useEffect, useRef } from "react";
|
|
@@ -112,24 +112,10 @@ function ConfirmDialog({
|
|
|
112
112
|
);
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
// src/vault/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
File,
|
|
120
|
-
FileCode,
|
|
121
|
-
FileImage,
|
|
122
|
-
FileJson,
|
|
123
|
-
FileSpreadsheet,
|
|
124
|
-
FileText,
|
|
125
|
-
Folder,
|
|
126
|
-
FolderOpen
|
|
127
|
-
} from "lucide-react";
|
|
128
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
129
|
-
var VAULT_TREE_CHILD_PAGE = 200;
|
|
130
|
-
var STORAGE_PREFIX = "tangle:vault-tree:";
|
|
131
|
-
var STORED_PATH_LIMIT = 1e3;
|
|
132
|
-
function storageFor(key) {
|
|
115
|
+
// src/vault/recent-files.ts
|
|
116
|
+
var PREFIX = "tangle:vault-recent:";
|
|
117
|
+
var RECENT_FILE_LIMIT = 8;
|
|
118
|
+
function storage(key) {
|
|
133
119
|
if (!key || typeof window === "undefined") return null;
|
|
134
120
|
try {
|
|
135
121
|
return window.localStorage;
|
|
@@ -137,307 +123,31 @@ function storageFor(key) {
|
|
|
137
123
|
return null;
|
|
138
124
|
}
|
|
139
125
|
}
|
|
140
|
-
function
|
|
141
|
-
const
|
|
142
|
-
if (!
|
|
143
|
-
try {
|
|
144
|
-
const raw = storage.getItem(STORAGE_PREFIX + key);
|
|
145
|
-
const parsed = raw ? JSON.parse(raw) : [];
|
|
146
|
-
return new Set(Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : []);
|
|
147
|
-
} catch {
|
|
148
|
-
return /* @__PURE__ */ new Set();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
function writeExpanded(key, expanded) {
|
|
152
|
-
const storage = storageFor(key);
|
|
153
|
-
if (!storage) return;
|
|
126
|
+
function readRecentFiles(key) {
|
|
127
|
+
const store = storage(key);
|
|
128
|
+
if (!store) return [];
|
|
154
129
|
try {
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
else storage.setItem(STORAGE_PREFIX + key, JSON.stringify(paths));
|
|
130
|
+
const parsed = JSON.parse(store.getItem(PREFIX + key) ?? "[]");
|
|
131
|
+
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : [];
|
|
158
132
|
} catch {
|
|
133
|
+
return [];
|
|
159
134
|
}
|
|
160
135
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
var FILE_ICONS = {
|
|
170
|
-
md: FileText,
|
|
171
|
-
mdx: FileText,
|
|
172
|
-
txt: FileText,
|
|
173
|
-
pdf: FileText,
|
|
174
|
-
doc: FileText,
|
|
175
|
-
docx: FileText,
|
|
176
|
-
csv: FileSpreadsheet,
|
|
177
|
-
tsv: FileSpreadsheet,
|
|
178
|
-
xls: FileSpreadsheet,
|
|
179
|
-
xlsx: FileSpreadsheet,
|
|
180
|
-
json: FileJson,
|
|
181
|
-
png: FileImage,
|
|
182
|
-
jpg: FileImage,
|
|
183
|
-
jpeg: FileImage,
|
|
184
|
-
gif: FileImage,
|
|
185
|
-
webp: FileImage,
|
|
186
|
-
svg: FileImage,
|
|
187
|
-
ts: FileCode,
|
|
188
|
-
tsx: FileCode,
|
|
189
|
-
js: FileCode,
|
|
190
|
-
jsx: FileCode,
|
|
191
|
-
py: FileCode,
|
|
192
|
-
html: FileCode,
|
|
193
|
-
css: FileCode,
|
|
194
|
-
yaml: FileCode,
|
|
195
|
-
yml: FileCode
|
|
196
|
-
};
|
|
197
|
-
function fileIcon(name) {
|
|
198
|
-
const dot = name.lastIndexOf(".");
|
|
199
|
-
return dot > 0 && FILE_ICONS[name.slice(dot + 1).toLowerCase()] || File;
|
|
200
|
-
}
|
|
201
|
-
function VaultTree({
|
|
202
|
-
root,
|
|
203
|
-
selectedPath,
|
|
204
|
-
activeFolder,
|
|
205
|
-
onSelect,
|
|
206
|
-
onFolderToggle,
|
|
207
|
-
storageKey,
|
|
208
|
-
expandAll = false,
|
|
209
|
-
label = "Files",
|
|
210
|
-
className
|
|
211
|
-
}) {
|
|
212
|
-
const [expansion, setExpansion] = useState(() => ({ key: storageKey, expanded: readExpanded(storageKey) }));
|
|
213
|
-
let keyed = expansion;
|
|
214
|
-
if (expansion.key !== storageKey) {
|
|
215
|
-
keyed = { key: storageKey, expanded: readExpanded(storageKey) };
|
|
216
|
-
setExpansion(keyed);
|
|
217
|
-
}
|
|
218
|
-
const expandedPaths = keyed.expanded;
|
|
219
|
-
const [pageLimits, setPageLimits] = useState(() => /* @__PURE__ */ new Map());
|
|
220
|
-
const [focusedPath, setFocusedPath] = useState(null);
|
|
221
|
-
const rowRefs = useRef2(/* @__PURE__ */ new Map());
|
|
222
|
-
const pendingFocusRef = useRef2(null);
|
|
223
|
-
const pendingRevealRef = useRef2(null);
|
|
224
|
-
const index = useMemo(() => {
|
|
225
|
-
const nodes = /* @__PURE__ */ new Map();
|
|
226
|
-
const parents = /* @__PURE__ */ new Map();
|
|
227
|
-
const children = /* @__PURE__ */ new Map();
|
|
228
|
-
const visit = (node, parent) => {
|
|
229
|
-
nodes.set(node.path, node);
|
|
230
|
-
parents.set(node.path, parent);
|
|
231
|
-
if (node.type === "directory") {
|
|
232
|
-
const sorted = sortChildren(node.children);
|
|
233
|
-
children.set(node.path, sorted);
|
|
234
|
-
for (const child of sorted) visit(child, node.path);
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
const top = sortChildren(root.children);
|
|
238
|
-
children.set(null, top);
|
|
239
|
-
for (const node of top) visit(node, null);
|
|
240
|
-
return { nodes, parents, children };
|
|
241
|
-
}, [root]);
|
|
242
|
-
const isOpen = useCallback(
|
|
243
|
-
(path) => expandAll || expandedPaths.has(path),
|
|
244
|
-
[expandAll, expandedPaths]
|
|
245
|
-
);
|
|
246
|
-
const rows = useMemo(() => {
|
|
247
|
-
const out = [];
|
|
248
|
-
const walk = (parent, depth) => {
|
|
249
|
-
const kids = index.children.get(parent) ?? [];
|
|
250
|
-
const limit = parent === null ? kids.length : Math.max(VAULT_TREE_CHILD_PAGE, pageLimits.get(parent) ?? 0);
|
|
251
|
-
const shown = Math.min(kids.length, limit);
|
|
252
|
-
kids.slice(0, shown).forEach((node, i) => {
|
|
253
|
-
out.push({ kind: "node", node, depth, parent, posInSet: i + 1, setSize: kids.length });
|
|
254
|
-
if (node.type === "directory" && isOpen(node.path)) walk(node.path, depth + 1);
|
|
255
|
-
});
|
|
256
|
-
if (parent !== null && shown < kids.length) {
|
|
257
|
-
out.push({ kind: "more", parent, depth, hidden: kids.length - shown });
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
walk(null, 0);
|
|
261
|
-
return out;
|
|
262
|
-
}, [index, isOpen, pageLimits]);
|
|
263
|
-
const nodeRows = useMemo(
|
|
264
|
-
() => rows.filter((row) => row.kind === "node"),
|
|
265
|
-
[rows]
|
|
266
|
-
);
|
|
267
|
-
const updateExpanded = useCallback((change) => {
|
|
268
|
-
setExpansion((current) => {
|
|
269
|
-
const base = current.key === storageKey ? current.expanded : readExpanded(storageKey);
|
|
270
|
-
const next = new Set(base);
|
|
271
|
-
change(next);
|
|
272
|
-
writeExpanded(storageKey, next);
|
|
273
|
-
return { key: storageKey, expanded: next };
|
|
274
|
-
});
|
|
275
|
-
}, [storageKey]);
|
|
276
|
-
const setFolderOpen = useCallback((path, open) => {
|
|
277
|
-
if (expandAll || expandedPaths.has(path) === open) return;
|
|
278
|
-
updateExpanded((next) => {
|
|
279
|
-
if (open) next.add(path);
|
|
280
|
-
else next.delete(path);
|
|
281
|
-
});
|
|
282
|
-
onFolderToggle?.(path, open);
|
|
283
|
-
}, [expandAll, expandedPaths, updateExpanded, onFolderToggle]);
|
|
284
|
-
useEffect2(() => {
|
|
285
|
-
if (!selectedPath || !index.nodes.has(selectedPath)) return;
|
|
286
|
-
const ancestors = [];
|
|
287
|
-
for (let parent = index.parents.get(selectedPath) ?? null; parent; parent = index.parents.get(parent) ?? null) {
|
|
288
|
-
ancestors.push(parent);
|
|
289
|
-
}
|
|
290
|
-
pendingRevealRef.current = selectedPath;
|
|
291
|
-
if (ancestors.some((path) => !expandedPaths.has(path))) {
|
|
292
|
-
updateExpanded((next) => {
|
|
293
|
-
for (const path of ancestors) next.add(path);
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
}, [selectedPath, index]);
|
|
297
|
-
useEffect2(() => {
|
|
298
|
-
const reveal = pendingRevealRef.current;
|
|
299
|
-
if (reveal && rowRefs.current.has(reveal)) {
|
|
300
|
-
pendingRevealRef.current = null;
|
|
301
|
-
rowRefs.current.get(reveal)?.scrollIntoView?.({ block: "nearest" });
|
|
302
|
-
}
|
|
303
|
-
const focus = pendingFocusRef.current;
|
|
304
|
-
if (focus && rowRefs.current.has(focus)) {
|
|
305
|
-
pendingFocusRef.current = null;
|
|
306
|
-
rowRefs.current.get(focus)?.focus();
|
|
307
|
-
}
|
|
308
|
-
}, [rows]);
|
|
309
|
-
const visiblePaths = useMemo(() => new Set(nodeRows.map((row) => row.node.path)), [nodeRows]);
|
|
310
|
-
const tabStop = focusedPath && visiblePaths.has(focusedPath) && focusedPath || selectedPath && visiblePaths.has(selectedPath) && selectedPath || nodeRows[0]?.node.path || null;
|
|
311
|
-
const focusRow = useCallback((path) => {
|
|
312
|
-
if (!path) return;
|
|
313
|
-
setFocusedPath(path);
|
|
314
|
-
const element = rowRefs.current.get(path);
|
|
315
|
-
if (element) element.focus();
|
|
316
|
-
else pendingFocusRef.current = path;
|
|
317
|
-
}, []);
|
|
318
|
-
const activate = useCallback((node) => {
|
|
319
|
-
setFocusedPath(node.path);
|
|
320
|
-
if (node.type === "directory") setFolderOpen(node.path, !isOpen(node.path));
|
|
321
|
-
else onSelect(node.path);
|
|
322
|
-
}, [isOpen, onSelect, setFolderOpen]);
|
|
323
|
-
const onKeyDown = useCallback((event, node) => {
|
|
324
|
-
const at = nodeRows.findIndex((row) => row.node.path === node.path);
|
|
325
|
-
if (at < 0) return;
|
|
326
|
-
const dir = node.type === "directory";
|
|
327
|
-
const open = dir && isOpen(node.path);
|
|
328
|
-
let handled = true;
|
|
329
|
-
switch (event.key) {
|
|
330
|
-
case "ArrowDown":
|
|
331
|
-
focusRow(nodeRows[at + 1]?.node.path);
|
|
332
|
-
break;
|
|
333
|
-
case "ArrowUp":
|
|
334
|
-
focusRow(nodeRows[at - 1]?.node.path);
|
|
335
|
-
break;
|
|
336
|
-
case "Home":
|
|
337
|
-
focusRow(nodeRows[0]?.node.path);
|
|
338
|
-
break;
|
|
339
|
-
case "End":
|
|
340
|
-
focusRow(nodeRows[nodeRows.length - 1]?.node.path);
|
|
341
|
-
break;
|
|
342
|
-
case "ArrowRight":
|
|
343
|
-
if (dir && !open) setFolderOpen(node.path, true);
|
|
344
|
-
else if (open) {
|
|
345
|
-
const child = nodeRows[at + 1];
|
|
346
|
-
if (child?.parent === node.path) focusRow(child.node.path);
|
|
347
|
-
}
|
|
348
|
-
break;
|
|
349
|
-
case "ArrowLeft":
|
|
350
|
-
if (open && !expandAll) setFolderOpen(node.path, false);
|
|
351
|
-
else focusRow(index.parents.get(node.path));
|
|
352
|
-
break;
|
|
353
|
-
case "Enter":
|
|
354
|
-
case " ":
|
|
355
|
-
activate(node);
|
|
356
|
-
break;
|
|
357
|
-
default:
|
|
358
|
-
handled = false;
|
|
359
|
-
}
|
|
360
|
-
if (handled) {
|
|
361
|
-
event.preventDefault();
|
|
362
|
-
event.stopPropagation();
|
|
363
|
-
}
|
|
364
|
-
}, [nodeRows, isOpen, focusRow, setFolderOpen, expandAll, index, activate]);
|
|
365
|
-
return /* @__PURE__ */ jsx2("div", { role: "tree", "aria-label": label, "data-vault-tree-rows": true, className: `flex flex-col gap-px ${className ?? ""}`, children: rows.map((row) => {
|
|
366
|
-
if (row.kind === "more") {
|
|
367
|
-
return /* @__PURE__ */ jsxs2(
|
|
368
|
-
"button",
|
|
369
|
-
{
|
|
370
|
-
type: "button",
|
|
371
|
-
onClick: () => setPageLimits((current) => {
|
|
372
|
-
const next = new Map(current);
|
|
373
|
-
next.set(row.parent, Math.max(VAULT_TREE_CHILD_PAGE, current.get(row.parent) ?? 0) + VAULT_TREE_CHILD_PAGE);
|
|
374
|
-
return next;
|
|
375
|
-
}),
|
|
376
|
-
style: { paddingInlineStart: `calc(${row.depth} * 1rem + 2.25rem)` },
|
|
377
|
-
className: "flex min-h-8 w-full items-center rounded-md pr-2 text-left text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
|
|
378
|
-
children: [
|
|
379
|
-
"Show ",
|
|
380
|
-
Math.min(row.hidden, VAULT_TREE_CHILD_PAGE),
|
|
381
|
-
" more of ",
|
|
382
|
-
row.hidden
|
|
383
|
-
]
|
|
384
|
-
},
|
|
385
|
-
`more:${row.parent}`
|
|
386
|
-
);
|
|
136
|
+
function recordRecentFile(key, path) {
|
|
137
|
+
const next = [path, ...readRecentFiles(key).filter((item) => item !== path)].slice(0, RECENT_FILE_LIMIT);
|
|
138
|
+
const store = storage(key);
|
|
139
|
+
if (store) {
|
|
140
|
+
try {
|
|
141
|
+
store.setItem(PREFIX + key, JSON.stringify(next));
|
|
142
|
+
} catch {
|
|
387
143
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
const open = dir && isOpen(node.path);
|
|
391
|
-
const selected = !dir && node.path === selectedPath;
|
|
392
|
-
const active = dir && node.path === activeFolder;
|
|
393
|
-
const Icon = dir ? open ? FolderOpen : Folder : fileIcon(node.name);
|
|
394
|
-
return /* @__PURE__ */ jsxs2(
|
|
395
|
-
"div",
|
|
396
|
-
{
|
|
397
|
-
ref: (element) => {
|
|
398
|
-
if (element) rowRefs.current.set(node.path, element);
|
|
399
|
-
else rowRefs.current.delete(node.path);
|
|
400
|
-
},
|
|
401
|
-
role: "treeitem",
|
|
402
|
-
"aria-level": depth + 1,
|
|
403
|
-
"aria-posinset": row.posInSet,
|
|
404
|
-
"aria-setsize": row.setSize,
|
|
405
|
-
"aria-expanded": dir ? open : void 0,
|
|
406
|
-
"aria-selected": dir ? void 0 : selected,
|
|
407
|
-
"aria-current": active ? "true" : void 0,
|
|
408
|
-
tabIndex: node.path === tabStop ? 0 : -1,
|
|
409
|
-
title: node.path,
|
|
410
|
-
"data-vault-tree-item": node.type,
|
|
411
|
-
"data-path": node.path,
|
|
412
|
-
"data-selected": selected ? "true" : void 0,
|
|
413
|
-
onClick: () => activate(node),
|
|
414
|
-
onFocus: () => setFocusedPath(node.path),
|
|
415
|
-
onKeyDown: (event) => onKeyDown(event, node),
|
|
416
|
-
style: { paddingInlineStart: `calc(${depth} * 1rem + 0.25rem)` },
|
|
417
|
-
className: [
|
|
418
|
-
"group flex min-h-8 w-full cursor-pointer select-none items-center gap-1.5 rounded-md pr-2 text-sm transition-colors [@media(pointer:coarse)]:min-h-10",
|
|
419
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
|
|
420
|
-
selected ? "bg-[var(--accent-surface-soft)] font-medium text-[var(--accent-text)]" : active ? "bg-muted font-medium text-foreground" : "text-foreground hover:bg-muted"
|
|
421
|
-
].join(" "),
|
|
422
|
-
children: [
|
|
423
|
-
/* @__PURE__ */ jsx2("span", { "aria-hidden": "true", className: "flex size-4 shrink-0 items-center justify-center text-muted-foreground", children: dir && /* @__PURE__ */ jsx2(ChevronRight, { className: `size-3.5 transition-transform duration-fast ${open ? "rotate-90" : ""}` }) }),
|
|
424
|
-
/* @__PURE__ */ jsx2(
|
|
425
|
-
Icon,
|
|
426
|
-
{
|
|
427
|
-
"aria-hidden": "true",
|
|
428
|
-
className: `size-4 shrink-0 ${selected ? "text-[var(--accent-text)]" : "text-muted-foreground"}`
|
|
429
|
-
}
|
|
430
|
-
),
|
|
431
|
-
/* @__PURE__ */ jsx2("span", { className: "min-w-0 flex-1 truncate", children: node.name })
|
|
432
|
-
]
|
|
433
|
-
},
|
|
434
|
-
node.path
|
|
435
|
-
);
|
|
436
|
-
}) });
|
|
144
|
+
}
|
|
145
|
+
return next;
|
|
437
146
|
}
|
|
438
147
|
|
|
439
148
|
// src/vault/VaultPane.tsx
|
|
440
|
-
import {
|
|
149
|
+
import { filterFileNodes, VaultTree } from "@tangle-network/sandbox-ui/vault-tree";
|
|
150
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
441
151
|
var DOCK_SIDE_MIN_PX = 960;
|
|
442
152
|
var TREE_ICON_BUTTON = "inline-flex size-8 shrink-0 items-center justify-center rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [@media(pointer:coarse)]:size-10";
|
|
443
153
|
var IDENTITY_CODEC = {
|
|
@@ -481,20 +191,6 @@ function findDirectory(nodes, path) {
|
|
|
481
191
|
}
|
|
482
192
|
return null;
|
|
483
193
|
}
|
|
484
|
-
function filterNodes(nodes, q) {
|
|
485
|
-
const out = [];
|
|
486
|
-
for (const node of nodes) {
|
|
487
|
-
if (node.type === "file") {
|
|
488
|
-
if (node.name.toLowerCase().includes(q)) out.push(node);
|
|
489
|
-
} else if (node.name.toLowerCase().includes(q)) {
|
|
490
|
-
out.push(node);
|
|
491
|
-
} else {
|
|
492
|
-
const children = filterNodes(node.children ?? [], q);
|
|
493
|
-
if (children.length > 0) out.push({ ...node, children });
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
return out;
|
|
497
|
-
}
|
|
498
194
|
var EditorErrorBoundary = class extends Component {
|
|
499
195
|
state = { error: null };
|
|
500
196
|
static getDerivedStateFromError(error) {
|
|
@@ -506,13 +202,13 @@ var EditorErrorBoundary = class extends Component {
|
|
|
506
202
|
render() {
|
|
507
203
|
if (this.state.error) {
|
|
508
204
|
const msg = this.state.error instanceof Error ? this.state.error.message : typeof this.state.error === "string" ? this.state.error : `${this.props.label} did not load. Reload the page to try again.`;
|
|
509
|
-
return /* @__PURE__ */
|
|
510
|
-
/* @__PURE__ */
|
|
205
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex h-full flex-1 flex-col items-center justify-center p-8 text-center", children: [
|
|
206
|
+
/* @__PURE__ */ jsxs2("h3", { className: "mb-1 text-sm font-medium text-foreground", children: [
|
|
511
207
|
this.props.label,
|
|
512
208
|
" failed to load"
|
|
513
209
|
] }),
|
|
514
|
-
/* @__PURE__ */
|
|
515
|
-
/* @__PURE__ */
|
|
210
|
+
/* @__PURE__ */ jsx2("p", { className: "mb-4 max-w-xs text-xs text-muted-foreground", children: String(msg) }),
|
|
211
|
+
/* @__PURE__ */ jsx2(
|
|
516
212
|
"button",
|
|
517
213
|
{
|
|
518
214
|
type: "button",
|
|
@@ -530,29 +226,29 @@ var EditorErrorBoundary = class extends Component {
|
|
|
530
226
|
}
|
|
531
227
|
};
|
|
532
228
|
function SkeletonRegion({ label, className, children }) {
|
|
533
|
-
return /* @__PURE__ */
|
|
534
|
-
/* @__PURE__ */
|
|
535
|
-
/* @__PURE__ */
|
|
229
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
230
|
+
/* @__PURE__ */ jsx2("span", { role: "status", "aria-live": "polite", "aria-busy": true, className: "sr-only", children: label }),
|
|
231
|
+
/* @__PURE__ */ jsx2("div", { className, "aria-hidden": "true", children })
|
|
536
232
|
] });
|
|
537
233
|
}
|
|
538
234
|
function TreeSkeleton() {
|
|
539
|
-
return /* @__PURE__ */
|
|
235
|
+
return /* @__PURE__ */ jsx2(SkeletonRegion, { label: "Loading files\u2026", className: "space-y-2 p-4", children: [32, 48, 40, 52].map((w, i) => /* @__PURE__ */ jsx2("div", { className: "h-4 animate-pulse rounded bg-muted", style: { width: `${w * 4}px` } }, i)) });
|
|
540
236
|
}
|
|
541
237
|
function EditorSkeleton() {
|
|
542
|
-
return /* @__PURE__ */
|
|
543
|
-
/* @__PURE__ */
|
|
544
|
-
/* @__PURE__ */
|
|
545
|
-
/* @__PURE__ */
|
|
546
|
-
/* @__PURE__ */
|
|
238
|
+
return /* @__PURE__ */ jsxs2(SkeletonRegion, { label: "Loading file\u2026", className: "space-y-3 p-8", children: [
|
|
239
|
+
/* @__PURE__ */ jsx2("div", { className: "h-5 w-1/2 animate-pulse rounded bg-muted" }),
|
|
240
|
+
/* @__PURE__ */ jsx2("div", { className: "h-4 w-full animate-pulse rounded bg-muted" }),
|
|
241
|
+
/* @__PURE__ */ jsx2("div", { className: "h-4 w-3/4 animate-pulse rounded bg-muted" }),
|
|
242
|
+
/* @__PURE__ */ jsx2("div", { className: "h-4 w-2/3 animate-pulse rounded bg-muted" })
|
|
547
243
|
] });
|
|
548
244
|
}
|
|
549
245
|
function ReadErrorState({ message, onRetry }) {
|
|
550
|
-
return /* @__PURE__ */
|
|
551
|
-
/* @__PURE__ */
|
|
552
|
-
/* @__PURE__ */
|
|
553
|
-
/* @__PURE__ */
|
|
246
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex h-full flex-col items-center justify-center gap-3 p-8 text-center", children: [
|
|
247
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
248
|
+
/* @__PURE__ */ jsx2("h3", { className: "text-sm font-medium text-foreground", children: "Couldn't open this file" }),
|
|
249
|
+
/* @__PURE__ */ jsx2("p", { className: "mt-1 max-w-md text-xs text-muted-foreground", children: message })
|
|
554
250
|
] }),
|
|
555
|
-
/* @__PURE__ */
|
|
251
|
+
/* @__PURE__ */ jsx2(
|
|
556
252
|
"button",
|
|
557
253
|
{
|
|
558
254
|
type: "button",
|
|
@@ -564,15 +260,15 @@ function ReadErrorState({ message, onRetry }) {
|
|
|
564
260
|
] });
|
|
565
261
|
}
|
|
566
262
|
function TreeErrorState({ label, message, onRetry }) {
|
|
567
|
-
return /* @__PURE__ */
|
|
568
|
-
/* @__PURE__ */
|
|
569
|
-
/* @__PURE__ */
|
|
263
|
+
return /* @__PURE__ */ jsxs2("div", { role: "alert", className: "flex h-full flex-col items-center justify-center gap-3 p-6 text-center", children: [
|
|
264
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
265
|
+
/* @__PURE__ */ jsxs2("h3", { className: "text-sm font-medium text-foreground", children: [
|
|
570
266
|
"Couldn't load ",
|
|
571
267
|
label
|
|
572
268
|
] }),
|
|
573
|
-
/* @__PURE__ */
|
|
269
|
+
/* @__PURE__ */ jsx2("p", { className: "mt-1 max-w-xs text-xs text-muted-foreground", children: message })
|
|
574
270
|
] }),
|
|
575
|
-
/* @__PURE__ */
|
|
271
|
+
/* @__PURE__ */ jsx2(
|
|
576
272
|
"button",
|
|
577
273
|
{
|
|
578
274
|
type: "button",
|
|
@@ -584,19 +280,19 @@ function TreeErrorState({ label, message, onRetry }) {
|
|
|
584
280
|
] });
|
|
585
281
|
}
|
|
586
282
|
function TreeEmptyState({ canCreate, onCreate }) {
|
|
587
|
-
return /* @__PURE__ */
|
|
588
|
-
/* @__PURE__ */
|
|
589
|
-
/* @__PURE__ */
|
|
590
|
-
/* @__PURE__ */
|
|
283
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex h-full flex-col items-center justify-center gap-3 p-6 text-center", children: [
|
|
284
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
285
|
+
/* @__PURE__ */ jsx2("h3", { className: "text-sm font-medium text-foreground", children: "No files yet" }),
|
|
286
|
+
/* @__PURE__ */ jsx2("p", { className: "mt-1 max-w-xs text-xs text-muted-foreground", children: canCreate ? "Create a file to start." : "Files appear here once they are added." })
|
|
591
287
|
] }),
|
|
592
|
-
canCreate && /* @__PURE__ */
|
|
288
|
+
canCreate && /* @__PURE__ */ jsxs2(
|
|
593
289
|
"button",
|
|
594
290
|
{
|
|
595
291
|
type: "button",
|
|
596
292
|
onClick: onCreate,
|
|
597
293
|
className: "inline-flex h-8 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90",
|
|
598
294
|
children: [
|
|
599
|
-
/* @__PURE__ */
|
|
295
|
+
/* @__PURE__ */ jsx2(Plus, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
|
|
600
296
|
"New file"
|
|
601
297
|
]
|
|
602
298
|
}
|
|
@@ -604,13 +300,13 @@ function TreeEmptyState({ canCreate, onCreate }) {
|
|
|
604
300
|
] });
|
|
605
301
|
}
|
|
606
302
|
function TreeNoMatchState({ query, onClear }) {
|
|
607
|
-
return /* @__PURE__ */
|
|
608
|
-
/* @__PURE__ */
|
|
303
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center gap-3 p-6 text-center", children: [
|
|
304
|
+
/* @__PURE__ */ jsxs2("p", { className: "max-w-xs break-words text-xs text-muted-foreground", children: [
|
|
609
305
|
"No files match \u201C",
|
|
610
306
|
query,
|
|
611
307
|
"\u201D."
|
|
612
308
|
] }),
|
|
613
|
-
/* @__PURE__ */
|
|
309
|
+
/* @__PURE__ */ jsx2(
|
|
614
310
|
"button",
|
|
615
311
|
{
|
|
616
312
|
type: "button",
|
|
@@ -627,21 +323,54 @@ function OperationErrorAlert({
|
|
|
627
323
|
onRetry,
|
|
628
324
|
onDismiss
|
|
629
325
|
}) {
|
|
630
|
-
return /* @__PURE__ */
|
|
326
|
+
return /* @__PURE__ */ jsxs2(
|
|
631
327
|
"div",
|
|
632
328
|
{
|
|
633
329
|
role: "alert",
|
|
634
330
|
className: "flex shrink-0 items-center justify-between gap-3 border-b border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-[var(--surface-danger-text)]",
|
|
635
331
|
children: [
|
|
636
|
-
/* @__PURE__ */
|
|
637
|
-
/* @__PURE__ */
|
|
638
|
-
/* @__PURE__ */
|
|
639
|
-
/* @__PURE__ */
|
|
332
|
+
/* @__PURE__ */ jsx2("span", { className: "min-w-0 flex-1", children: message }),
|
|
333
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-3", children: [
|
|
334
|
+
/* @__PURE__ */ jsx2("button", { type: "button", "aria-label": retryLabel, onClick: onRetry, className: "font-medium underline-offset-2 hover:underline", children: "Retry" }),
|
|
335
|
+
/* @__PURE__ */ jsx2("button", { type: "button", onClick: onDismiss, className: "underline-offset-2 hover:underline", children: "Dismiss" })
|
|
640
336
|
] })
|
|
641
337
|
]
|
|
642
338
|
}
|
|
643
339
|
);
|
|
644
340
|
}
|
|
341
|
+
var RECENT_SHOWN = 5;
|
|
342
|
+
function DocumentEmptyState({ label, recent, onOpen }) {
|
|
343
|
+
const recentHeadingId = useId();
|
|
344
|
+
return /* @__PURE__ */ jsx2("div", { "data-vault-document-empty": true, className: "flex h-full items-center justify-center overflow-y-auto p-8", children: /* @__PURE__ */ jsxs2("div", { className: "w-full max-w-sm text-center", children: [
|
|
345
|
+
/* @__PURE__ */ jsx2("span", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-muted text-muted-foreground", children: /* @__PURE__ */ jsx2(FileText, { className: "size-5", "aria-hidden": "true" }) }),
|
|
346
|
+
/* @__PURE__ */ jsx2("h3", { className: "mt-4 text-base font-semibold text-foreground", children: "Select a file" }),
|
|
347
|
+
/* @__PURE__ */ jsxs2("p", { className: "mt-1 text-sm text-muted-foreground", children: [
|
|
348
|
+
"Choose a file in ",
|
|
349
|
+
label,
|
|
350
|
+
" to open it here."
|
|
351
|
+
] }),
|
|
352
|
+
recent.length > 0 && /* @__PURE__ */ jsxs2("section", { "aria-labelledby": recentHeadingId, className: "mt-8 text-left", children: [
|
|
353
|
+
/* @__PURE__ */ jsx2("h4", { id: recentHeadingId, className: "text-xs font-medium text-muted-foreground", children: "Recently opened" }),
|
|
354
|
+
/* @__PURE__ */ jsx2("ul", { className: "mt-2 overflow-hidden rounded-xl border border-border bg-card shadow-raised", children: recent.map((path) => {
|
|
355
|
+
const slash = path.lastIndexOf("/");
|
|
356
|
+
return /* @__PURE__ */ jsx2("li", { className: "border-b border-border last:border-b-0", children: /* @__PURE__ */ jsxs2(
|
|
357
|
+
"button",
|
|
358
|
+
{
|
|
359
|
+
type: "button",
|
|
360
|
+
onClick: () => onOpen(path),
|
|
361
|
+
title: path,
|
|
362
|
+
className: "flex min-h-10 w-full items-center gap-2.5 px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
|
|
363
|
+
children: [
|
|
364
|
+
/* @__PURE__ */ jsx2(FileText, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
365
|
+
/* @__PURE__ */ jsx2("span", { className: "min-w-0 truncate font-medium", children: path.slice(slash + 1) }),
|
|
366
|
+
slash > 0 && /* @__PURE__ */ jsx2("span", { className: "ml-auto min-w-0 shrink truncate text-xs text-muted-foreground", children: path.slice(0, slash) })
|
|
367
|
+
]
|
|
368
|
+
}
|
|
369
|
+
) }, path);
|
|
370
|
+
}) })
|
|
371
|
+
] })
|
|
372
|
+
] }) });
|
|
373
|
+
}
|
|
645
374
|
var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
646
375
|
const {
|
|
647
376
|
port,
|
|
@@ -674,21 +403,23 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
674
403
|
const isMarkdownCapable = codec !== void 0;
|
|
675
404
|
const persistentDock = dockToggle === false;
|
|
676
405
|
const dockToggleCfg = dockToggle ? dockToggle : { label: "Discuss", disabledWhenDirty: true };
|
|
677
|
-
const [tree, setTree] =
|
|
678
|
-
const [treeLoading, setTreeLoading] =
|
|
679
|
-
const [treeLoaded, setTreeLoaded] =
|
|
680
|
-
const [treeError, setTreeError] =
|
|
681
|
-
const [internalPath, setInternalPath] =
|
|
406
|
+
const [tree, setTree] = useState([]);
|
|
407
|
+
const [treeLoading, setTreeLoading] = useState(true);
|
|
408
|
+
const [treeLoaded, setTreeLoaded] = useState(false);
|
|
409
|
+
const [treeError, setTreeError] = useState(null);
|
|
410
|
+
const [internalPath, setInternalPath] = useState(null);
|
|
682
411
|
const selectedPath = controlled ? controlledPath ?? null : internalPath;
|
|
683
|
-
const [filesOpen, setFilesOpen] =
|
|
412
|
+
const [filesOpen, setFilesOpen] = useState(false);
|
|
684
413
|
const showFiles = filesOpen || !selectedPath;
|
|
685
|
-
const searchRef =
|
|
686
|
-
const documentRef =
|
|
414
|
+
const searchRef = useRef2(null);
|
|
415
|
+
const documentRef = useRef2(null);
|
|
687
416
|
const treeHeadingId = useId();
|
|
688
|
-
|
|
417
|
+
const [recentFiles, setRecentFiles] = useState(() => ({ key: treeStateKey, paths: readRecentFiles(treeStateKey) }));
|
|
418
|
+
if (recentFiles.key !== treeStateKey) setRecentFiles({ key: treeStateKey, paths: readRecentFiles(treeStateKey) });
|
|
419
|
+
useEffect2(() => {
|
|
689
420
|
setFilesOpen(false);
|
|
690
421
|
}, [selectedPath]);
|
|
691
|
-
const showDocument =
|
|
422
|
+
const showDocument = useCallback(() => {
|
|
692
423
|
const focused = document.activeElement;
|
|
693
424
|
setFilesOpen(false);
|
|
694
425
|
requestAnimationFrame(() => {
|
|
@@ -697,27 +428,27 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
697
428
|
}
|
|
698
429
|
});
|
|
699
430
|
}, []);
|
|
700
|
-
const [selectedFile, setSelectedFile] =
|
|
701
|
-
const [displayReadyPath, setDisplayReadyPath] =
|
|
702
|
-
const [fileLoading, setFileLoading] =
|
|
703
|
-
const [readError, setReadError] =
|
|
704
|
-
const [reloadNonce, setReloadNonce] =
|
|
705
|
-
const [saving, setSaving] =
|
|
706
|
-
const [saveError, setSaveError] =
|
|
707
|
-
const [editorMode, setEditorMode] =
|
|
708
|
-
const [richDraft, setRichDraft] =
|
|
709
|
-
const [sourceDraft, setSourceDraft] =
|
|
710
|
-
const [isDirty, setIsDirty] =
|
|
711
|
-
const [createOpen, setCreateOpen] =
|
|
712
|
-
const [newPath, setNewPath] =
|
|
713
|
-
const [creating, setCreating] =
|
|
714
|
-
const [createError, setCreateError] =
|
|
715
|
-
const [deleteOpen, setDeleteOpen] =
|
|
716
|
-
const [deleting, setDeleting] =
|
|
717
|
-
const [deleteError, setDeleteError] =
|
|
718
|
-
const [dockOpen, setDockOpen] =
|
|
719
|
-
const rootRef =
|
|
720
|
-
const [dockInline, setDockInline] =
|
|
431
|
+
const [selectedFile, setSelectedFile] = useState(null);
|
|
432
|
+
const [displayReadyPath, setDisplayReadyPath] = useState(null);
|
|
433
|
+
const [fileLoading, setFileLoading] = useState(false);
|
|
434
|
+
const [readError, setReadError] = useState(null);
|
|
435
|
+
const [reloadNonce, setReloadNonce] = useState(0);
|
|
436
|
+
const [saving, setSaving] = useState(false);
|
|
437
|
+
const [saveError, setSaveError] = useState(null);
|
|
438
|
+
const [editorMode, setEditorMode] = useState("rich");
|
|
439
|
+
const [richDraft, setRichDraft] = useState("");
|
|
440
|
+
const [sourceDraft, setSourceDraft] = useState("");
|
|
441
|
+
const [isDirty, setIsDirty] = useState(false);
|
|
442
|
+
const [createOpen, setCreateOpen] = useState(false);
|
|
443
|
+
const [newPath, setNewPath] = useState("");
|
|
444
|
+
const [creating, setCreating] = useState(false);
|
|
445
|
+
const [createError, setCreateError] = useState(null);
|
|
446
|
+
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
447
|
+
const [deleting, setDeleting] = useState(false);
|
|
448
|
+
const [deleteError, setDeleteError] = useState(null);
|
|
449
|
+
const [dockOpen, setDockOpen] = useState(false);
|
|
450
|
+
const rootRef = useRef2(null);
|
|
451
|
+
const [dockInline, setDockInline] = useState(false);
|
|
721
452
|
useLayoutEffect(() => {
|
|
722
453
|
const root = rootRef.current;
|
|
723
454
|
if (!root || !renderDock || typeof ResizeObserver === "undefined") return;
|
|
@@ -729,19 +460,19 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
729
460
|
observer.observe(root);
|
|
730
461
|
return () => observer.disconnect();
|
|
731
462
|
}, [renderDock]);
|
|
732
|
-
const [pendingNav, setPendingNav] =
|
|
733
|
-
const [query, setQuery] =
|
|
734
|
-
const [folderPath, setFolderPath] =
|
|
735
|
-
const dirtyRef =
|
|
463
|
+
const [pendingNav, setPendingNav] = useState(null);
|
|
464
|
+
const [query, setQuery] = useState("");
|
|
465
|
+
const [folderPath, setFolderPath] = useState(null);
|
|
466
|
+
const dirtyRef = useRef2(isDirty);
|
|
736
467
|
dirtyRef.current = isDirty;
|
|
737
|
-
const treeRequestRef =
|
|
738
|
-
const savedContentRef =
|
|
739
|
-
const loadedPathRef =
|
|
740
|
-
const onOperationErrorRef =
|
|
468
|
+
const treeRequestRef = useRef2(0);
|
|
469
|
+
const savedContentRef = useRef2("");
|
|
470
|
+
const loadedPathRef = useRef2(null);
|
|
471
|
+
const onOperationErrorRef = useRef2(onOperationError);
|
|
741
472
|
onOperationErrorRef.current = onOperationError;
|
|
742
|
-
const pendingOpenRef =
|
|
743
|
-
const previousPortRef =
|
|
744
|
-
const finishPendingOpen =
|
|
473
|
+
const pendingOpenRef = useRef2(null);
|
|
474
|
+
const previousPortRef = useRef2(port);
|
|
475
|
+
const finishPendingOpen = useCallback((opened, clearNavigation = true) => {
|
|
745
476
|
const pending = pendingOpenRef.current;
|
|
746
477
|
if (!pending) return;
|
|
747
478
|
pendingOpenRef.current = null;
|
|
@@ -750,43 +481,43 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
750
481
|
}
|
|
751
482
|
pending.resolve(opened);
|
|
752
483
|
}, []);
|
|
753
|
-
|
|
754
|
-
|
|
484
|
+
useEffect2(() => () => finishPendingOpen(false, false), [finishPendingOpen]);
|
|
485
|
+
useEffect2(() => {
|
|
755
486
|
if (previousPortRef.current !== port) finishPendingOpen(false);
|
|
756
487
|
previousPortRef.current = port;
|
|
757
488
|
}, [port, finishPendingOpen]);
|
|
758
|
-
|
|
489
|
+
useEffect2(() => {
|
|
759
490
|
const pending = pendingOpenRef.current;
|
|
760
491
|
if (!pending) return;
|
|
761
492
|
if (selectedPath === pending.path) pending.selected = true;
|
|
762
493
|
else if (pending.selected || selectedPath !== pending.fromPath) finishPendingOpen(false);
|
|
763
494
|
}, [selectedPath, finishPendingOpen]);
|
|
764
|
-
const treePaths =
|
|
495
|
+
const treePaths = useMemo(
|
|
765
496
|
() => collectTreePaths(tree, { files: /* @__PURE__ */ new Set(), directories: /* @__PURE__ */ new Set() }),
|
|
766
497
|
[tree]
|
|
767
498
|
);
|
|
768
|
-
const resolvedSelectedPath =
|
|
499
|
+
const resolvedSelectedPath = useMemo(() => {
|
|
769
500
|
if (!selectedPath) return null;
|
|
770
501
|
const listed = resolveTreePath(selectedPath, treePaths);
|
|
771
502
|
if (listed?.type === "directory") return null;
|
|
772
503
|
return listed?.path ?? selectedPath;
|
|
773
504
|
}, [selectedPath, treePaths]);
|
|
774
|
-
const activeFolderNode =
|
|
505
|
+
const activeFolderNode = useMemo(
|
|
775
506
|
() => folderPath ? findDirectory(tree, folderPath) : null,
|
|
776
507
|
[tree, folderPath]
|
|
777
508
|
);
|
|
778
509
|
const activeFolder = activeFolderNode?.path ?? null;
|
|
779
|
-
const treeRoot =
|
|
510
|
+
const treeRoot = useMemo(
|
|
780
511
|
() => ({ name: label, path: "", type: "directory", children: tree }),
|
|
781
512
|
[tree, label]
|
|
782
513
|
);
|
|
783
|
-
const visibleRoot =
|
|
514
|
+
const visibleRoot = useMemo(() => {
|
|
784
515
|
const q = query.trim().toLowerCase();
|
|
785
516
|
if (!q) return treeRoot;
|
|
786
517
|
const base = activeFolderNode ?? treeRoot;
|
|
787
|
-
return { ...base, children:
|
|
518
|
+
return { ...base, children: filterFileNodes(base.children ?? [], q) };
|
|
788
519
|
}, [treeRoot, activeFolderNode, query]);
|
|
789
|
-
const commitPath =
|
|
520
|
+
const commitPath = useCallback(
|
|
790
521
|
(next) => {
|
|
791
522
|
if (controlled) {
|
|
792
523
|
const decision = onSelectedPathChange?.(next);
|
|
@@ -798,7 +529,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
798
529
|
},
|
|
799
530
|
[controlled, onSelectedPathChange]
|
|
800
531
|
);
|
|
801
|
-
const reportFailure =
|
|
532
|
+
const reportFailure = useCallback((operation, phase, error, fallback, path) => {
|
|
802
533
|
const failure = {
|
|
803
534
|
operation,
|
|
804
535
|
phase,
|
|
@@ -813,7 +544,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
813
544
|
}
|
|
814
545
|
return failure;
|
|
815
546
|
}, []);
|
|
816
|
-
const refresh =
|
|
547
|
+
const refresh = useCallback(async (context = LIST_CONTEXT) => {
|
|
817
548
|
const request = ++treeRequestRef.current;
|
|
818
549
|
setTreeLoading(true);
|
|
819
550
|
setTreeError(null);
|
|
@@ -838,25 +569,25 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
838
569
|
if (request === treeRequestRef.current) setTreeLoading(false);
|
|
839
570
|
}
|
|
840
571
|
}, [port, reportFailure, label]);
|
|
841
|
-
|
|
572
|
+
useEffect2(() => {
|
|
842
573
|
setTree([]);
|
|
843
574
|
setTreeLoaded(false);
|
|
844
575
|
setTreeError(null);
|
|
845
576
|
setSelectedFile(null);
|
|
846
577
|
}, [port]);
|
|
847
|
-
|
|
578
|
+
useEffect2(() => {
|
|
848
579
|
void refresh();
|
|
849
580
|
return () => {
|
|
850
581
|
treeRequestRef.current += 1;
|
|
851
582
|
};
|
|
852
583
|
}, [refresh, refreshKey]);
|
|
853
|
-
const retryTree =
|
|
584
|
+
const retryTree = useCallback(async () => {
|
|
854
585
|
if (!treeError) return;
|
|
855
586
|
const { context } = treeError;
|
|
856
587
|
const recovered = await refresh(context);
|
|
857
588
|
if (recovered && context.selectAfterRecovery) commitPath(context.selectAfterRecovery);
|
|
858
589
|
}, [treeError, refresh, commitPath]);
|
|
859
|
-
|
|
590
|
+
useEffect2(() => {
|
|
860
591
|
if (!selectedPath) {
|
|
861
592
|
setSelectedFile(null);
|
|
862
593
|
setFileLoading(false);
|
|
@@ -906,7 +637,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
906
637
|
cancelled = true;
|
|
907
638
|
};
|
|
908
639
|
}, [port, selectedPath, resolvedSelectedPath, treeLoading, treeLoaded, treeError, isDirty, saving, reloadNonce, commitPath, reportFailure, finishPendingOpen]);
|
|
909
|
-
|
|
640
|
+
useEffect2(() => {
|
|
910
641
|
if (!selectedFile) {
|
|
911
642
|
loadedPathRef.current = null;
|
|
912
643
|
setDisplayReadyPath(null);
|
|
@@ -929,13 +660,13 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
929
660
|
setSaveError(null);
|
|
930
661
|
setDockOpen(false);
|
|
931
662
|
}, [selectedFile?.path, selectedFile?.content, activeCodec]);
|
|
932
|
-
|
|
663
|
+
useEffect2(() => {
|
|
933
664
|
const pending = pendingOpenRef.current;
|
|
934
665
|
if (pending?.loaded && pending.path === selectedPath && selectedFile?.path === pending.path && displayReadyPath === pending.path && sourceDraft === selectedFile.content && !fileLoading) {
|
|
935
666
|
finishPendingOpen(true);
|
|
936
667
|
}
|
|
937
668
|
}, [selectedPath, selectedFile, displayReadyPath, sourceDraft, fileLoading, finishPendingOpen]);
|
|
938
|
-
const guardedOpen =
|
|
669
|
+
const guardedOpen = useCallback((rawPath, resolve) => {
|
|
939
670
|
const target = resolveTreePath(rawPath, treePaths);
|
|
940
671
|
if (!rawPath.trim() || target?.type === "directory") {
|
|
941
672
|
resolve?.(false);
|
|
@@ -974,16 +705,16 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
974
705
|
useImperativeHandle(ref, () => ({
|
|
975
706
|
openFile: (path) => new Promise((resolve) => guardedOpen(path, resolve))
|
|
976
707
|
}), [guardedOpen]);
|
|
977
|
-
const toggleFolder =
|
|
708
|
+
const toggleFolder = useCallback((path) => {
|
|
978
709
|
setFolderPath((current) => current === path ? null : path);
|
|
979
710
|
}, []);
|
|
980
|
-
const handleFolderToggle =
|
|
711
|
+
const handleFolderToggle = useCallback((path, expanded) => {
|
|
981
712
|
setFolderPath((current) => {
|
|
982
713
|
if (expanded) return path;
|
|
983
714
|
return current && (current === path || current.startsWith(`${path}/`)) ? null : current;
|
|
984
715
|
});
|
|
985
716
|
}, []);
|
|
986
|
-
const selectFileRef =
|
|
717
|
+
const selectFileRef = useRef2(() => {
|
|
987
718
|
});
|
|
988
719
|
selectFileRef.current = (rawPath) => {
|
|
989
720
|
const target = resolveTreePath(rawPath, treePaths);
|
|
@@ -994,8 +725,8 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
994
725
|
}
|
|
995
726
|
toggleFolder(target.path);
|
|
996
727
|
};
|
|
997
|
-
const handleTreeSelect =
|
|
998
|
-
const confirmDiscard =
|
|
728
|
+
const handleTreeSelect = useCallback((path) => selectFileRef.current(path), []);
|
|
729
|
+
const confirmDiscard = useCallback(() => {
|
|
999
730
|
const nav = pendingNav;
|
|
1000
731
|
setPendingNav(null);
|
|
1001
732
|
if (!nav) return;
|
|
@@ -1007,7 +738,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1007
738
|
setIsDirty(false);
|
|
1008
739
|
showDocument();
|
|
1009
740
|
}, [pendingNav, commitPath, showDocument, finishPendingOpen]);
|
|
1010
|
-
const showRichMode =
|
|
741
|
+
const showRichMode = useCallback(() => {
|
|
1011
742
|
setEditorMode((mode) => {
|
|
1012
743
|
if (mode === "rich") return mode;
|
|
1013
744
|
setRichDraft(activeCodec.parse(sourceDraft));
|
|
@@ -1015,7 +746,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1015
746
|
return "rich";
|
|
1016
747
|
});
|
|
1017
748
|
}, [activeCodec, sourceDraft]);
|
|
1018
|
-
const showSourceMode =
|
|
749
|
+
const showSourceMode = useCallback(() => {
|
|
1019
750
|
setEditorMode((mode) => {
|
|
1020
751
|
if (mode === "source") return mode;
|
|
1021
752
|
const content = isDirty ? activeCodec.serialize(richDraft) : savedContentRef.current;
|
|
@@ -1024,17 +755,17 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1024
755
|
return "source";
|
|
1025
756
|
});
|
|
1026
757
|
}, [activeCodec, isDirty, richDraft]);
|
|
1027
|
-
const onSourceChange =
|
|
758
|
+
const onSourceChange = useCallback((next) => {
|
|
1028
759
|
dirtyRef.current = next !== savedContentRef.current;
|
|
1029
760
|
setSourceDraft(next);
|
|
1030
761
|
setIsDirty(dirtyRef.current);
|
|
1031
762
|
}, []);
|
|
1032
|
-
const onRichChange =
|
|
763
|
+
const onRichChange = useCallback((next) => {
|
|
1033
764
|
dirtyRef.current = activeCodec.serialize(next) !== savedContentRef.current;
|
|
1034
765
|
setRichDraft(next);
|
|
1035
766
|
setIsDirty(dirtyRef.current);
|
|
1036
767
|
}, [activeCodec]);
|
|
1037
|
-
const saveCurrent =
|
|
768
|
+
const saveCurrent = useCallback(async () => {
|
|
1038
769
|
if (!selectedFile) return;
|
|
1039
770
|
const content = editorMode === "source" ? sourceDraft : activeCodec.serialize(richDraft);
|
|
1040
771
|
setSaving(true);
|
|
@@ -1052,7 +783,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1052
783
|
setSaving(false);
|
|
1053
784
|
}
|
|
1054
785
|
}, [selectedFile, editorMode, sourceDraft, richDraft, activeCodec, port, reportFailure]);
|
|
1055
|
-
const handleCreate =
|
|
786
|
+
const handleCreate = useCallback(async () => {
|
|
1056
787
|
const trimmed = newPath.trim();
|
|
1057
788
|
if (!trimmed || !trimmed.split("/").pop()?.trim()) return;
|
|
1058
789
|
setCreating(true);
|
|
@@ -1074,7 +805,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1074
805
|
setCreating(false);
|
|
1075
806
|
}
|
|
1076
807
|
}, [newPath, port, refresh, commitPath, reportFailure]);
|
|
1077
|
-
const handleDelete =
|
|
808
|
+
const handleDelete = useCallback(async () => {
|
|
1078
809
|
if (!selectedFile) return;
|
|
1079
810
|
const path = selectedFile.path;
|
|
1080
811
|
setDeleting(true);
|
|
@@ -1092,6 +823,11 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1092
823
|
setDeleting(false);
|
|
1093
824
|
}
|
|
1094
825
|
}, [selectedFile, port, refresh, commitPath, reportFailure]);
|
|
826
|
+
useEffect2(() => {
|
|
827
|
+
if (!displayReadyPath || !treeStateKey) return;
|
|
828
|
+
setRecentFiles({ key: treeStateKey, paths: recordRecentFile(treeStateKey, displayReadyPath) });
|
|
829
|
+
}, [displayReadyPath, treeStateKey]);
|
|
830
|
+
const recentToOffer = recentFiles.paths.filter((path) => path !== selectedPath && treePaths.files.has(path)).slice(0, RECENT_SHOWN);
|
|
1095
831
|
const createFileName = newPath.trim().split("/").pop()?.trim() ?? "";
|
|
1096
832
|
const dockButtonLabel = persistentDock ? dockLabel : dockToggleCfg.label;
|
|
1097
833
|
const dockBlockedByDraft = !persistentDock && (dockToggleCfg.disabledWhenDirty ?? true) && isDirty;
|
|
@@ -1105,12 +841,12 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1105
841
|
const trimmedQuery = query.trim();
|
|
1106
842
|
let treeContent;
|
|
1107
843
|
if (!treeLoaded && (treeLoading || !treeError)) {
|
|
1108
|
-
treeContent = /* @__PURE__ */
|
|
844
|
+
treeContent = /* @__PURE__ */ jsx2(TreeSkeleton, {});
|
|
1109
845
|
} else if (!treeLoaded && treeError) {
|
|
1110
|
-
treeContent = /* @__PURE__ */
|
|
846
|
+
treeContent = /* @__PURE__ */ jsx2(TreeErrorState, { label, message: treeFailureMessage(treeError.failure, label), onRetry: () => void retryTree() });
|
|
1111
847
|
} else {
|
|
1112
|
-
treeContent = /* @__PURE__ */
|
|
1113
|
-
treeError && /* @__PURE__ */
|
|
848
|
+
treeContent = /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
849
|
+
treeError && /* @__PURE__ */ jsx2(
|
|
1114
850
|
OperationErrorAlert,
|
|
1115
851
|
{
|
|
1116
852
|
message: treeFailureMessage(treeError.failure, label),
|
|
@@ -1119,11 +855,11 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1119
855
|
onDismiss: () => setTreeError(null)
|
|
1120
856
|
}
|
|
1121
857
|
),
|
|
1122
|
-
vaultEmpty && !trimmedQuery ? treeEmptyState !== void 0 ? treeEmptyState : /* @__PURE__ */
|
|
858
|
+
vaultEmpty && !trimmedQuery ? treeEmptyState !== void 0 ? treeEmptyState : /* @__PURE__ */ jsx2(TreeEmptyState, { canCreate, onCreate: openCreate }) : trimmedQuery && (visibleRoot.children?.length ?? 0) === 0 ? /* @__PURE__ */ jsx2(TreeNoMatchState, { query: trimmedQuery, onClear: () => setQuery("") }) : renderTree ? renderTree({
|
|
1123
859
|
root: visibleRoot,
|
|
1124
860
|
selectedPath: resolvedSelectedPath ?? void 0,
|
|
1125
861
|
onSelect: handleTreeSelect
|
|
1126
|
-
}) : /* @__PURE__ */
|
|
862
|
+
}) : /* @__PURE__ */ jsx2(
|
|
1127
863
|
VaultTree,
|
|
1128
864
|
{
|
|
1129
865
|
root: visibleRoot,
|
|
@@ -1138,13 +874,13 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1138
874
|
)
|
|
1139
875
|
] });
|
|
1140
876
|
}
|
|
1141
|
-
return /* @__PURE__ */
|
|
877
|
+
return /* @__PURE__ */ jsx2(EditorErrorBoundary, { label, onReset: () => {
|
|
1142
878
|
commitPath(null);
|
|
1143
879
|
setSelectedFile(null);
|
|
1144
|
-
}, children: /* @__PURE__ */
|
|
1145
|
-
/* @__PURE__ */
|
|
1146
|
-
selectedPath && /* @__PURE__ */
|
|
1147
|
-
/* @__PURE__ */
|
|
880
|
+
}, children: /* @__PURE__ */ jsxs2("div", { ref: rootRef, className: `flex min-h-0 min-w-0 flex-1 overflow-hidden ${className ?? ""}`, children: [
|
|
881
|
+
/* @__PURE__ */ jsxs2("div", { className: "@container/vault flex min-w-0 flex-1 flex-col", children: [
|
|
882
|
+
selectedPath && /* @__PURE__ */ jsxs2("nav", { "aria-label": `${label} navigation`, className: "flex shrink-0 items-center gap-1 border-b border-border p-2 @[45rem]/vault:hidden", children: [
|
|
883
|
+
/* @__PURE__ */ jsx2(
|
|
1148
884
|
"button",
|
|
1149
885
|
{
|
|
1150
886
|
type: "button",
|
|
@@ -1162,7 +898,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1162
898
|
children: "Files"
|
|
1163
899
|
}
|
|
1164
900
|
),
|
|
1165
|
-
selectedPath && /* @__PURE__ */
|
|
901
|
+
selectedPath && /* @__PURE__ */ jsx2(
|
|
1166
902
|
"button",
|
|
1167
903
|
{
|
|
1168
904
|
type: "button",
|
|
@@ -1174,19 +910,19 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1174
910
|
}
|
|
1175
911
|
)
|
|
1176
912
|
] }),
|
|
1177
|
-
/* @__PURE__ */
|
|
1178
|
-
/* @__PURE__ */
|
|
913
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex min-h-0 min-w-0 flex-1", children: [
|
|
914
|
+
/* @__PURE__ */ jsx2("div", { "data-vault-tree": true, className: `${showFiles ? "flex" : "hidden"} min-w-0 flex-1 flex-col p-2 @[45rem]/vault:flex @[45rem]/vault:p-3 ${treeSpansPane ? "" : "@[45rem]/vault:w-[23rem] @[45rem]/vault:min-w-[23rem] @[45rem]/vault:flex-none"}`, children: /* @__PURE__ */ jsxs2(
|
|
1179
915
|
"section",
|
|
1180
916
|
{
|
|
1181
917
|
"aria-labelledby": treeHeadingId,
|
|
1182
918
|
"data-vault-tree-surface": true,
|
|
1183
919
|
className: "flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-raised",
|
|
1184
920
|
children: [
|
|
1185
|
-
/* @__PURE__ */
|
|
1186
|
-
/* @__PURE__ */
|
|
1187
|
-
/* @__PURE__ */
|
|
921
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-2 px-3 pb-2 pt-3", children: [
|
|
922
|
+
/* @__PURE__ */ jsx2("h2", { id: treeHeadingId, className: "min-w-0 flex-1 truncate text-sm font-semibold text-foreground", children: label }),
|
|
923
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
1188
924
|
headerActions,
|
|
1189
|
-
/* @__PURE__ */
|
|
925
|
+
/* @__PURE__ */ jsx2(
|
|
1190
926
|
"button",
|
|
1191
927
|
{
|
|
1192
928
|
type: "button",
|
|
@@ -1194,10 +930,10 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1194
930
|
title: "Refresh",
|
|
1195
931
|
onClick: () => void refresh(),
|
|
1196
932
|
className: `${TREE_ICON_BUTTON} text-muted-foreground hover:bg-muted hover:text-foreground`,
|
|
1197
|
-
children: /* @__PURE__ */
|
|
933
|
+
children: /* @__PURE__ */ jsx2(RefreshCw, { className: "size-4", "aria-hidden": "true" })
|
|
1198
934
|
}
|
|
1199
935
|
),
|
|
1200
|
-
canCreate && /* @__PURE__ */
|
|
936
|
+
canCreate && /* @__PURE__ */ jsx2(
|
|
1201
937
|
"button",
|
|
1202
938
|
{
|
|
1203
939
|
type: "button",
|
|
@@ -1205,12 +941,12 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1205
941
|
"aria-label": activeFolder ? `New file in ${activeFolder}` : "New file",
|
|
1206
942
|
onClick: openCreate,
|
|
1207
943
|
className: `${TREE_ICON_BUTTON} bg-primary text-primary-foreground hover:bg-primary/90`,
|
|
1208
|
-
children: /* @__PURE__ */
|
|
944
|
+
children: /* @__PURE__ */ jsx2(Plus, { className: "size-4", "aria-hidden": "true" })
|
|
1209
945
|
}
|
|
1210
946
|
)
|
|
1211
947
|
] })
|
|
1212
948
|
] }),
|
|
1213
|
-
!vaultEmpty && /* @__PURE__ */
|
|
949
|
+
!vaultEmpty && /* @__PURE__ */ jsx2("div", { className: "shrink-0 px-3 pb-2", children: /* @__PURE__ */ jsx2(
|
|
1214
950
|
"input",
|
|
1215
951
|
{
|
|
1216
952
|
ref: searchRef,
|
|
@@ -1222,10 +958,10 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1222
958
|
className: "h-8 w-full rounded-md border border-border bg-input px-3 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [@media(pointer:coarse)]:h-10 [@media(pointer:coarse)]:text-base"
|
|
1223
959
|
}
|
|
1224
960
|
) }),
|
|
1225
|
-
activeFolder && /* @__PURE__ */
|
|
1226
|
-
/* @__PURE__ */
|
|
1227
|
-
/* @__PURE__ */
|
|
1228
|
-
/* @__PURE__ */
|
|
961
|
+
activeFolder && /* @__PURE__ */ jsxs2("div", { className: "mx-3 mb-2 flex shrink-0 items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-xs", children: [
|
|
962
|
+
/* @__PURE__ */ jsx2(Folder, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
963
|
+
/* @__PURE__ */ jsx2("span", { "data-vault-folder": true, className: "min-w-0 flex-1 truncate font-medium text-foreground", title: activeFolder, children: activeFolder }),
|
|
964
|
+
/* @__PURE__ */ jsx2(
|
|
1229
965
|
"button",
|
|
1230
966
|
{
|
|
1231
967
|
type: "button",
|
|
@@ -1236,11 +972,11 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1236
972
|
}
|
|
1237
973
|
)
|
|
1238
974
|
] }),
|
|
1239
|
-
/* @__PURE__ */
|
|
975
|
+
/* @__PURE__ */ jsx2("div", { className: "min-h-0 flex-1 overflow-y-auto border-t border-border px-1.5 py-1.5", children: treeContent })
|
|
1240
976
|
]
|
|
1241
977
|
}
|
|
1242
978
|
) }),
|
|
1243
|
-
/* @__PURE__ */
|
|
979
|
+
/* @__PURE__ */ jsxs2(
|
|
1244
980
|
"div",
|
|
1245
981
|
{
|
|
1246
982
|
ref: documentRef,
|
|
@@ -1249,11 +985,11 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1249
985
|
tabIndex: -1,
|
|
1250
986
|
className: `${showFiles || treeSpansPane ? "hidden" : "flex"} min-w-0 flex-1 flex-col overflow-hidden ${treeSpansPane ? "" : "@[45rem]/vault:flex"}`,
|
|
1251
987
|
children: [
|
|
1252
|
-
selectedFile && /* @__PURE__ */
|
|
1253
|
-
/* @__PURE__ */
|
|
1254
|
-
/* @__PURE__ */
|
|
1255
|
-
canWrite && isMarkdownCapable && /* @__PURE__ */
|
|
1256
|
-
/* @__PURE__ */
|
|
988
|
+
selectedFile && /* @__PURE__ */ jsxs2("div", { className: `flex h-14 shrink-0 items-center justify-between gap-2 border-b border-border px-4 ${pathBarClassName ?? "bg-card"}`, children: [
|
|
989
|
+
/* @__PURE__ */ jsx2("span", { "data-vault-path": true, className: "min-w-0 flex-1 truncate text-xs font-medium text-foreground", children: selectedFile.path }),
|
|
990
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
991
|
+
canWrite && isMarkdownCapable && /* @__PURE__ */ jsxs2("div", { className: "mr-1 flex items-center gap-1", children: [
|
|
992
|
+
/* @__PURE__ */ jsx2(
|
|
1257
993
|
"button",
|
|
1258
994
|
{
|
|
1259
995
|
type: "button",
|
|
@@ -1264,7 +1000,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1264
1000
|
children: "Rich"
|
|
1265
1001
|
}
|
|
1266
1002
|
),
|
|
1267
|
-
/* @__PURE__ */
|
|
1003
|
+
/* @__PURE__ */ jsx2(
|
|
1268
1004
|
"button",
|
|
1269
1005
|
{
|
|
1270
1006
|
type: "button",
|
|
@@ -1276,7 +1012,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1276
1012
|
}
|
|
1277
1013
|
)
|
|
1278
1014
|
] }),
|
|
1279
|
-
renderDock && (!persistentDock || dockInline) && /* @__PURE__ */
|
|
1015
|
+
renderDock && (!persistentDock || dockInline) && /* @__PURE__ */ jsx2(
|
|
1280
1016
|
"button",
|
|
1281
1017
|
{
|
|
1282
1018
|
type: "button",
|
|
@@ -1290,7 +1026,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1290
1026
|
}
|
|
1291
1027
|
),
|
|
1292
1028
|
fileActions?.(selectedFile),
|
|
1293
|
-
onDownloadFile && /* @__PURE__ */
|
|
1029
|
+
onDownloadFile && /* @__PURE__ */ jsx2(
|
|
1294
1030
|
"button",
|
|
1295
1031
|
{
|
|
1296
1032
|
type: "button",
|
|
@@ -1298,10 +1034,10 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1298
1034
|
title: "Download file",
|
|
1299
1035
|
onClick: () => onDownloadFile(selectedFile),
|
|
1300
1036
|
className: "inline-flex h-7 w-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
1301
|
-
children: /* @__PURE__ */
|
|
1037
|
+
children: /* @__PURE__ */ jsx2(Download, { className: "h-4 w-4" })
|
|
1302
1038
|
}
|
|
1303
1039
|
),
|
|
1304
|
-
canDelete && /* @__PURE__ */
|
|
1040
|
+
canDelete && /* @__PURE__ */ jsx2(
|
|
1305
1041
|
"button",
|
|
1306
1042
|
{
|
|
1307
1043
|
type: "button",
|
|
@@ -1312,12 +1048,12 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1312
1048
|
setDeleteOpen(true);
|
|
1313
1049
|
},
|
|
1314
1050
|
className: "inline-flex h-7 w-7 items-center justify-center rounded text-[var(--surface-danger-text)] transition-colors hover:bg-destructive/10",
|
|
1315
|
-
children: /* @__PURE__ */
|
|
1051
|
+
children: /* @__PURE__ */ jsx2(Trash2, { className: "h-4 w-4" })
|
|
1316
1052
|
}
|
|
1317
1053
|
)
|
|
1318
1054
|
] })
|
|
1319
1055
|
] }),
|
|
1320
|
-
selectedFile && saveError && /* @__PURE__ */
|
|
1056
|
+
selectedFile && saveError && /* @__PURE__ */ jsx2(
|
|
1321
1057
|
OperationErrorAlert,
|
|
1322
1058
|
{
|
|
1323
1059
|
message: saveError.message,
|
|
@@ -1326,7 +1062,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1326
1062
|
onDismiss: () => setSaveError(null)
|
|
1327
1063
|
}
|
|
1328
1064
|
),
|
|
1329
|
-
readError && selectedFile?.path === resolvedSelectedPath && /* @__PURE__ */
|
|
1065
|
+
readError && selectedFile?.path === resolvedSelectedPath && /* @__PURE__ */ jsx2(
|
|
1330
1066
|
OperationErrorAlert,
|
|
1331
1067
|
{
|
|
1332
1068
|
message: readError,
|
|
@@ -1335,7 +1071,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1335
1071
|
onDismiss: () => setReadError(null)
|
|
1336
1072
|
}
|
|
1337
1073
|
),
|
|
1338
|
-
/* @__PURE__ */
|
|
1074
|
+
/* @__PURE__ */ jsx2("div", { className: "flex-1 overflow-hidden", children: fileLoading && selectedFile?.path !== resolvedSelectedPath ? /* @__PURE__ */ jsx2(EditorSkeleton, {}) : readError && selectedFile?.path !== resolvedSelectedPath ? /* @__PURE__ */ jsx2(ReadErrorState, { message: readError, onRetry: () => setReloadNonce((n) => n + 1) }) : selectedFile && renderDock && dockInline && dockOpen ? /* @__PURE__ */ jsx2("div", { "data-vault-dock": "inline", className: "flex h-full min-h-0 flex-col overflow-y-auto", children: renderDock({ file: selectedFile, open: true, onClose: () => setDockOpen(false), placement: "inline" }) }) : selectedFile && canWrite && isMarkdownCapable && editorMode === "source" ? /* @__PURE__ */ jsx2(
|
|
1339
1075
|
SourceEditor,
|
|
1340
1076
|
{
|
|
1341
1077
|
path: selectedFile.path,
|
|
@@ -1354,7 +1090,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1354
1090
|
dirty: isDirty,
|
|
1355
1091
|
onRichChange,
|
|
1356
1092
|
onSave: () => void saveCurrent()
|
|
1357
|
-
}) : emptyState
|
|
1093
|
+
}) : emptyState !== void 0 ? emptyState : /* @__PURE__ */ jsx2(DocumentEmptyState, { label, recent: recentToOffer, onOpen: (path) => guardedOpen(path) }) })
|
|
1358
1094
|
]
|
|
1359
1095
|
}
|
|
1360
1096
|
)
|
|
@@ -1367,7 +1103,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1367
1103
|
} : () => setDockOpen(false),
|
|
1368
1104
|
placement: "side"
|
|
1369
1105
|
}),
|
|
1370
|
-
/* @__PURE__ */
|
|
1106
|
+
/* @__PURE__ */ jsx2(
|
|
1371
1107
|
ConfirmDialog,
|
|
1372
1108
|
{
|
|
1373
1109
|
open: createOpen,
|
|
@@ -1381,8 +1117,8 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1381
1117
|
setNewPath("");
|
|
1382
1118
|
setCreateError(null);
|
|
1383
1119
|
},
|
|
1384
|
-
children: /* @__PURE__ */
|
|
1385
|
-
/* @__PURE__ */
|
|
1120
|
+
children: /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
|
|
1121
|
+
/* @__PURE__ */ jsx2(
|
|
1386
1122
|
"input",
|
|
1387
1123
|
{
|
|
1388
1124
|
value: newPath,
|
|
@@ -1393,11 +1129,11 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1393
1129
|
className: "h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground"
|
|
1394
1130
|
}
|
|
1395
1131
|
),
|
|
1396
|
-
createError && /* @__PURE__ */
|
|
1132
|
+
createError && /* @__PURE__ */ jsx2("p", { role: "alert", className: "text-xs text-[var(--surface-danger-text)]", children: createError.message })
|
|
1397
1133
|
] })
|
|
1398
1134
|
}
|
|
1399
1135
|
),
|
|
1400
|
-
/* @__PURE__ */
|
|
1136
|
+
/* @__PURE__ */ jsx2(
|
|
1401
1137
|
ConfirmDialog,
|
|
1402
1138
|
{
|
|
1403
1139
|
open: deleteOpen,
|
|
@@ -1411,10 +1147,10 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1411
1147
|
setDeleteOpen(false);
|
|
1412
1148
|
setDeleteError(null);
|
|
1413
1149
|
},
|
|
1414
|
-
children: deleteError && /* @__PURE__ */
|
|
1150
|
+
children: deleteError && /* @__PURE__ */ jsx2("p", { role: "alert", className: "text-xs text-[var(--surface-danger-text)]", children: deleteError.message })
|
|
1415
1151
|
}
|
|
1416
1152
|
),
|
|
1417
|
-
/* @__PURE__ */
|
|
1153
|
+
/* @__PURE__ */ jsx2(
|
|
1418
1154
|
ConfirmDialog,
|
|
1419
1155
|
{
|
|
1420
1156
|
open: pendingNav !== null,
|
|
@@ -1439,12 +1175,12 @@ function SourceEditor({
|
|
|
1439
1175
|
onChange,
|
|
1440
1176
|
onSave
|
|
1441
1177
|
}) {
|
|
1442
|
-
return /* @__PURE__ */
|
|
1443
|
-
/* @__PURE__ */
|
|
1444
|
-
/* @__PURE__ */
|
|
1445
|
-
/* @__PURE__ */
|
|
1446
|
-
/* @__PURE__ */
|
|
1447
|
-
/* @__PURE__ */
|
|
1178
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex h-full min-h-0 flex-col bg-background", children: [
|
|
1179
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between gap-2 border-b border-border px-4 py-2", children: [
|
|
1180
|
+
/* @__PURE__ */ jsx2("p", { className: "truncate font-mono text-xs text-muted-foreground", children: path }),
|
|
1181
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
1182
|
+
/* @__PURE__ */ jsx2("span", { className: "rounded-full border border-border bg-background px-2.5 py-1 text-xs text-muted-foreground", children: dirty ? "Unsaved changes" : "Saved" }),
|
|
1183
|
+
/* @__PURE__ */ jsx2(
|
|
1448
1184
|
"button",
|
|
1449
1185
|
{
|
|
1450
1186
|
type: "button",
|
|
@@ -1456,7 +1192,7 @@ function SourceEditor({
|
|
|
1456
1192
|
)
|
|
1457
1193
|
] })
|
|
1458
1194
|
] }),
|
|
1459
|
-
/* @__PURE__ */
|
|
1195
|
+
/* @__PURE__ */ jsx2(
|
|
1460
1196
|
"textarea",
|
|
1461
1197
|
{
|
|
1462
1198
|
value: content,
|
|
@@ -1471,8 +1207,6 @@ function SourceEditor({
|
|
|
1471
1207
|
|
|
1472
1208
|
export {
|
|
1473
1209
|
ConfirmDialog,
|
|
1474
|
-
VAULT_TREE_CHILD_PAGE,
|
|
1475
|
-
VaultTree,
|
|
1476
1210
|
VaultPane
|
|
1477
1211
|
};
|
|
1478
|
-
//# sourceMappingURL=chunk-
|
|
1212
|
+
//# sourceMappingURL=chunk-QPMEXMH6.js.map
|