@tangle-network/agent-app 0.60.236 → 0.60.238
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/{DesignCanvas-SNE3H3TH.js → DesignCanvas-OW3W2QXW.js} +2 -2
- package/dist/{DesignCanvasEditor-G5O75CUT.js → DesignCanvasEditor-TCHZF25W.js} +3 -3
- package/dist/VaultPane-RXL3WLA2.js +7 -0
- package/dist/assistant/index.js +2 -2
- package/dist/chat-routes/attachment-store.d.ts +28 -2
- package/dist/chat-routes/dispatch-parts.d.ts +12 -1
- package/dist/chat-routes/index.js +41 -2
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/chat-store/index.js +3 -1
- package/dist/chat-store/index.js.map +1 -1
- package/dist/chat-store/parts.d.ts +6 -0
- package/dist/{chunk-BGDQ7245.js → chunk-2UIRJPC6.js} +2 -2
- package/dist/{chunk-I57SNMX4.js → chunk-EWOJATDS.js} +3 -3
- package/dist/{chunk-P2NJIDLE.js → chunk-JH3CKHF4.js} +380 -366
- package/dist/chunk-JH3CKHF4.js.map +1 -0
- package/dist/{chunk-E6UTFXKQ.js → chunk-PYG2N2JX.js} +12 -1
- package/dist/{chunk-E6UTFXKQ.js.map → chunk-PYG2N2JX.js.map} +1 -1
- package/dist/{chunk-MX3RI3MO.js → chunk-QW6PFYJS.js} +2 -2
- package/dist/{chunk-IDQU36M5.js → chunk-RL3Z747H.js} +708 -659
- package/dist/chunk-RL3Z747H.js.map +1 -0
- package/dist/{chunk-3KXYYAY4.js → chunk-VBWYH7UZ.js} +243 -232
- package/dist/chunk-VBWYH7UZ.js.map +1 -0
- package/dist/design-canvas-react/components/Toolbar.d.ts +1 -2
- package/dist/design-canvas-react/components/toolbar-fields.d.ts +65 -0
- package/dist/design-canvas-react/components/toolbar-page-controls.d.ts +20 -0
- package/dist/design-canvas-react/components/toolbar-selection-controls.d.ts +22 -0
- package/dist/design-canvas-react/components/use-workspace-keyboard.d.ts +24 -0
- package/dist/design-canvas-react/components/use-workspace-viewport.d.ts +16 -0
- package/dist/design-canvas-react/components/workspace-gesture-state.d.ts +10 -0
- package/dist/design-canvas-react/index.js +3 -3
- package/dist/design-canvas-react/lazy.js +1 -1
- package/dist/public-consultation/index.d.ts +1 -1
- package/dist/public-consultation/index.js +2 -2
- package/dist/vault/SourceEditor.d.ts +8 -0
- package/dist/vault/VaultCreateDialog.d.ts +14 -0
- package/dist/vault/VaultDocumentToolbar.d.ts +29 -0
- package/dist/vault/VaultPaneNavigation.d.ts +10 -0
- package/dist/vault/VaultPaneStates.d.ts +59 -0
- package/dist/vault/VaultTreePanel.d.ts +19 -0
- package/dist/vault/index.js +1 -1
- package/dist/vault/lazy.js +1 -1
- package/dist/vault/useVaultDockPlacement.d.ts +5 -0
- package/dist/vault/useVaultSearch.d.ts +13 -0
- package/dist/vault/vault-tree-paths.d.ts +12 -0
- package/dist/web-react/index.js +2 -2
- package/package.json +1 -1
- package/dist/VaultPane-QEG35UAZ.js +0 -7
- package/dist/chunk-3KXYYAY4.js.map +0 -1
- package/dist/chunk-IDQU36M5.js.map +0 -1
- package/dist/chunk-P2NJIDLE.js.map +0 -1
- /package/dist/{DesignCanvas-SNE3H3TH.js.map → DesignCanvas-OW3W2QXW.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-G5O75CUT.js.map → DesignCanvasEditor-TCHZF25W.js.map} +0 -0
- /package/dist/{VaultPane-QEG35UAZ.js.map → VaultPane-RXL3WLA2.js.map} +0 -0
- /package/dist/{chunk-BGDQ7245.js.map → chunk-2UIRJPC6.js.map} +0 -0
- /package/dist/{chunk-I57SNMX4.js.map → chunk-EWOJATDS.js.map} +0 -0
- /package/dist/{chunk-MX3RI3MO.js.map → chunk-QW6PFYJS.js.map} +0 -0
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
// src/vault/VaultPane.tsx
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
forwardRef,
|
|
5
|
-
useCallback as useCallback2,
|
|
6
|
-
useEffect as useEffect3,
|
|
7
|
-
useImperativeHandle,
|
|
8
|
-
useLayoutEffect,
|
|
9
|
-
useId as useId3,
|
|
10
|
-
useMemo,
|
|
11
|
-
useRef as useRef2,
|
|
12
|
-
useState as useState2
|
|
13
|
-
} from "react";
|
|
14
|
-
import { Download, FileText as FileText2, Folder, History as History2, Plus, RefreshCw, Trash2 } from "lucide-react";
|
|
2
|
+
import { forwardRef, useCallback as useCallback2, useEffect as useEffect4, useImperativeHandle, useId as useId4, useMemo as useMemo2, useRef as useRef3, useState as useState4 } from "react";
|
|
3
|
+
import { VaultTree } from "@tangle-network/sandbox-ui/vault-tree";
|
|
15
4
|
|
|
16
5
|
// src/vault/ConfirmDialog.tsx
|
|
17
6
|
import { useEffect, useRef } from "react";
|
|
@@ -112,100 +101,63 @@ function ConfirmDialog({
|
|
|
112
101
|
);
|
|
113
102
|
}
|
|
114
103
|
|
|
115
|
-
// src/vault/
|
|
116
|
-
var PREFIX = "tangle:vault-recent:";
|
|
117
|
-
var RECENT_FILE_LIMIT = 8;
|
|
118
|
-
function storage(key) {
|
|
119
|
-
if (!key || typeof window === "undefined") return null;
|
|
120
|
-
try {
|
|
121
|
-
return window.localStorage;
|
|
122
|
-
} catch {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function readRecentFiles(key) {
|
|
127
|
-
const store = storage(key);
|
|
128
|
-
if (!store) return [];
|
|
129
|
-
try {
|
|
130
|
-
const parsed = JSON.parse(store.getItem(PREFIX + key) ?? "[]");
|
|
131
|
-
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : [];
|
|
132
|
-
} catch {
|
|
133
|
-
return [];
|
|
134
|
-
}
|
|
135
|
-
}
|
|
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 {
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return next;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// src/vault/VaultContentResults.tsx
|
|
149
|
-
import { useId } from "react";
|
|
150
|
-
import { FileText } from "lucide-react";
|
|
104
|
+
// src/vault/SourceEditor.tsx
|
|
151
105
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
152
|
-
function
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
parts.push(
|
|
160
|
-
/* @__PURE__ */ jsx2("mark", { className: "rounded-sm bg-[var(--surface-warning-bg)] px-0.5 text-[var(--surface-warning-text)]", children: text.slice(at, at + needle.length) }, at)
|
|
161
|
-
);
|
|
162
|
-
from = at + needle.length;
|
|
163
|
-
}
|
|
164
|
-
if (from < text.length) parts.push(text.slice(from));
|
|
165
|
-
return parts;
|
|
166
|
-
}
|
|
167
|
-
function VaultContentResults({
|
|
168
|
-
state,
|
|
169
|
-
selectedPath,
|
|
170
|
-
onOpen,
|
|
171
|
-
onRetry
|
|
106
|
+
function SourceEditor({
|
|
107
|
+
path,
|
|
108
|
+
content,
|
|
109
|
+
saving,
|
|
110
|
+
dirty,
|
|
111
|
+
onChange,
|
|
112
|
+
onSave
|
|
172
113
|
}) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
114
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex h-full min-h-0 flex-col bg-background", children: [
|
|
115
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between gap-2 border-b border-border px-4 py-2", children: [
|
|
116
|
+
/* @__PURE__ */ jsx2("p", { className: "truncate font-mono text-sm text-muted-foreground", children: path }),
|
|
117
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
118
|
+
/* @__PURE__ */ jsx2(
|
|
119
|
+
"span",
|
|
120
|
+
{
|
|
121
|
+
role: "status",
|
|
122
|
+
"aria-live": "polite",
|
|
123
|
+
className: `rounded-full border px-2.5 py-1 text-sm ${dirty ? "border-[var(--surface-warning-border)] bg-[var(--surface-warning-bg)] text-[var(--surface-warning-text)]" : "border-border bg-background text-muted-foreground"}`,
|
|
124
|
+
children: saving ? "Saving\u2026" : dirty ? "Unsaved changes" : "Saved"
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
(dirty || saving) && /* @__PURE__ */ jsx2(
|
|
128
|
+
"button",
|
|
129
|
+
{
|
|
130
|
+
type: "button",
|
|
131
|
+
onClick: onSave,
|
|
132
|
+
disabled: saving,
|
|
133
|
+
title: "Save (Ctrl+S)",
|
|
134
|
+
className: "inline-flex h-8 items-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",
|
|
135
|
+
children: "Save"
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
] })
|
|
139
|
+
] }),
|
|
140
|
+
/* @__PURE__ */ jsx2(
|
|
141
|
+
"textarea",
|
|
142
|
+
{
|
|
143
|
+
value: content,
|
|
144
|
+
onChange: (event) => onChange(event.target.value),
|
|
145
|
+
onKeyDown: (event) => {
|
|
146
|
+
if ((event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey && event.key.toLowerCase() === "s") {
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
if (dirty && !saving) onSave();
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
spellCheck: false,
|
|
152
|
+
"aria-label": "Source editor",
|
|
153
|
+
className: "min-h-0 flex-1 resize-none border-0 bg-background p-4 font-mono text-sm leading-6 text-foreground focus-visible:[outline-offset:-2px]"
|
|
154
|
+
}
|
|
155
|
+
)
|
|
204
156
|
] });
|
|
205
157
|
}
|
|
206
158
|
|
|
207
159
|
// src/vault/VaultHistoryPanel.tsx
|
|
208
|
-
import { useCallback, useEffect as useEffect2, useId
|
|
160
|
+
import { useCallback, useEffect as useEffect2, useId, useState } from "react";
|
|
209
161
|
import { History, X } from "lucide-react";
|
|
210
162
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
211
163
|
function message(error, fallback) {
|
|
@@ -225,7 +177,7 @@ function VaultHistoryPanel({
|
|
|
225
177
|
onRestore,
|
|
226
178
|
onClose
|
|
227
179
|
}) {
|
|
228
|
-
const listId =
|
|
180
|
+
const listId = useId();
|
|
229
181
|
const [revisions, setRevisions] = useState({ status: "loading" });
|
|
230
182
|
const [listNonce, setListNonce] = useState(0);
|
|
231
183
|
const [selectedId, setSelectedId] = useState(null);
|
|
@@ -373,19 +325,69 @@ function VaultHistoryPanel({
|
|
|
373
325
|
] });
|
|
374
326
|
}
|
|
375
327
|
|
|
376
|
-
// src/vault/
|
|
377
|
-
import {
|
|
378
|
-
import {
|
|
379
|
-
import {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
328
|
+
// src/vault/VaultContentResults.tsx
|
|
329
|
+
import { useId as useId2 } from "react";
|
|
330
|
+
import { FileText } from "lucide-react";
|
|
331
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
332
|
+
function highlight(text, query) {
|
|
333
|
+
const needle = query.toLowerCase();
|
|
334
|
+
const haystack = text.toLowerCase();
|
|
335
|
+
const parts = [];
|
|
336
|
+
let from = 0;
|
|
337
|
+
for (let at = haystack.indexOf(needle); needle && at >= 0; at = haystack.indexOf(needle, from)) {
|
|
338
|
+
if (at > from) parts.push(text.slice(from, at));
|
|
339
|
+
parts.push(
|
|
340
|
+
/* @__PURE__ */ jsx4("mark", { className: "rounded-sm bg-[var(--surface-warning-bg)] px-0.5 text-[var(--surface-warning-text)]", children: text.slice(at, at + needle.length) }, at)
|
|
341
|
+
);
|
|
342
|
+
from = at + needle.length;
|
|
343
|
+
}
|
|
344
|
+
if (from < text.length) parts.push(text.slice(from));
|
|
345
|
+
return parts;
|
|
346
|
+
}
|
|
347
|
+
function VaultContentResults({
|
|
348
|
+
state,
|
|
349
|
+
selectedPath,
|
|
350
|
+
onOpen,
|
|
351
|
+
onRetry
|
|
352
|
+
}) {
|
|
353
|
+
const headingId = useId2();
|
|
354
|
+
return /* @__PURE__ */ jsxs4("section", { "aria-labelledby": headingId, "data-vault-content-results": true, className: "mt-2 border-t border-border px-1.5 pt-3", children: [
|
|
355
|
+
/* @__PURE__ */ jsx4("h3", { id: headingId, className: "px-1.5 text-sm font-medium text-foreground", children: "In file contents" }),
|
|
356
|
+
state.status === "error" ? /* @__PURE__ */ jsxs4("div", { role: "alert", className: "mt-2 space-y-2 px-1.5 text-sm text-[var(--surface-danger-text)]", children: [
|
|
357
|
+
/* @__PURE__ */ jsxs4("p", { children: [
|
|
358
|
+
"Couldn't search file contents. ",
|
|
359
|
+
state.message
|
|
360
|
+
] }),
|
|
361
|
+
/* @__PURE__ */ jsx4("button", { type: "button", onClick: onRetry, className: "font-medium underline-offset-2 hover:underline", children: "Try again" })
|
|
362
|
+
] }) : state.matches.length === 0 ? /* @__PURE__ */ jsx4("p", { role: "status", className: "mt-2 px-1.5 text-sm text-muted-foreground", children: state.status === "loading" ? "Searching file contents\u2026" : `No file contains \u201C${state.query}\u201D.` }) : /* @__PURE__ */ jsx4("ul", { className: "mt-1.5 space-y-0.5", "aria-busy": state.status === "loading", children: state.matches.map((match) => {
|
|
363
|
+
const slash = match.path.lastIndexOf("/");
|
|
364
|
+
const selected = match.path === selectedPath;
|
|
365
|
+
return /* @__PURE__ */ jsx4("li", { children: /* @__PURE__ */ jsxs4(
|
|
366
|
+
"button",
|
|
367
|
+
{
|
|
368
|
+
type: "button",
|
|
369
|
+
onClick: () => onOpen(match.path),
|
|
370
|
+
title: match.path,
|
|
371
|
+
"aria-current": selected ? "true" : void 0,
|
|
372
|
+
className: `w-full rounded-md px-2 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring ${selected ? "bg-muted" : "hover:bg-muted"}`,
|
|
373
|
+
children: [
|
|
374
|
+
/* @__PURE__ */ jsxs4("span", { className: "flex min-w-0 items-center gap-2", children: [
|
|
375
|
+
/* @__PURE__ */ jsx4(FileText, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
376
|
+
/* @__PURE__ */ jsx4("span", { className: "min-w-0 truncate text-sm font-medium text-foreground", children: match.path.slice(slash + 1) }),
|
|
377
|
+
slash > 0 && /* @__PURE__ */ jsx4("span", { className: "ml-auto min-w-0 shrink truncate text-sm text-muted-foreground", children: match.path.slice(0, slash) })
|
|
378
|
+
] }),
|
|
379
|
+
/* @__PURE__ */ jsx4("span", { className: "mt-1 line-clamp-2 block text-sm text-muted-foreground", children: highlight(match.snippet, state.query) })
|
|
380
|
+
]
|
|
381
|
+
}
|
|
382
|
+
) }, match.path);
|
|
383
|
+
}) })
|
|
384
|
+
] });
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// src/vault/VaultPaneStates.tsx
|
|
388
|
+
import { Component, useId as useId3 } from "react";
|
|
389
|
+
import { FileText as FileText2, Plus } from "lucide-react";
|
|
390
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
389
391
|
function operationMessage(error, fallback) {
|
|
390
392
|
return error instanceof Error && error.message ? error.message : fallback;
|
|
391
393
|
}
|
|
@@ -394,34 +396,6 @@ function treeFailureMessage(failure, label) {
|
|
|
394
396
|
const completed = failure.operation === "create" ? "created" : "deleted";
|
|
395
397
|
return `The file was ${completed}, but ${label} couldn't refresh. ${failure.message}`;
|
|
396
398
|
}
|
|
397
|
-
function collectTreePaths(nodes, into) {
|
|
398
|
-
for (const node of nodes) {
|
|
399
|
-
if (node.type === "file") into.files.add(node.path);
|
|
400
|
-
else into.directories.add(node.path);
|
|
401
|
-
if (node.children) collectTreePaths(node.children, into);
|
|
402
|
-
}
|
|
403
|
-
return into;
|
|
404
|
-
}
|
|
405
|
-
function resolveFilePath(rawPath, filePaths) {
|
|
406
|
-
if (filePaths.has(rawPath)) return rawPath;
|
|
407
|
-
const path = rawPath.replace(/^\/+|\/+$/g, "");
|
|
408
|
-
return filePaths.has(path) ? path : null;
|
|
409
|
-
}
|
|
410
|
-
function resolveTreePath(rawPath, paths) {
|
|
411
|
-
const file = resolveFilePath(rawPath, paths.files);
|
|
412
|
-
if (file) return { path: file, type: "file" };
|
|
413
|
-
if (paths.directories.has(rawPath)) return { path: rawPath, type: "directory" };
|
|
414
|
-
const trimmed = rawPath.replace(/^\/+|\/+$/g, "");
|
|
415
|
-
return paths.directories.has(trimmed) ? { path: trimmed, type: "directory" } : null;
|
|
416
|
-
}
|
|
417
|
-
function findDirectory(nodes, path) {
|
|
418
|
-
for (const node of nodes) {
|
|
419
|
-
if (node.type === "directory" && node.path === path) return node;
|
|
420
|
-
const found = node.children ? findDirectory(node.children, path) : null;
|
|
421
|
-
if (found) return found;
|
|
422
|
-
}
|
|
423
|
-
return null;
|
|
424
|
-
}
|
|
425
399
|
var EditorErrorBoundary = class extends Component {
|
|
426
400
|
state = { error: null };
|
|
427
401
|
static getDerivedStateFromError(error) {
|
|
@@ -433,13 +407,13 @@ var EditorErrorBoundary = class extends Component {
|
|
|
433
407
|
render() {
|
|
434
408
|
if (this.state.error) {
|
|
435
409
|
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.`;
|
|
436
|
-
return /* @__PURE__ */
|
|
437
|
-
/* @__PURE__ */
|
|
410
|
+
return /* @__PURE__ */ jsxs5("div", { className: "flex h-full flex-1 flex-col items-center justify-center p-8 text-center", children: [
|
|
411
|
+
/* @__PURE__ */ jsxs5("h3", { className: "mb-1 text-sm font-medium text-foreground", children: [
|
|
438
412
|
this.props.label,
|
|
439
413
|
" failed to load"
|
|
440
414
|
] }),
|
|
441
|
-
/* @__PURE__ */
|
|
442
|
-
/* @__PURE__ */
|
|
415
|
+
/* @__PURE__ */ jsx5("p", { className: "mb-4 max-w-xs text-xs text-muted-foreground", children: String(msg) }),
|
|
416
|
+
/* @__PURE__ */ jsx5(
|
|
443
417
|
"button",
|
|
444
418
|
{
|
|
445
419
|
type: "button",
|
|
@@ -457,151 +431,508 @@ var EditorErrorBoundary = class extends Component {
|
|
|
457
431
|
}
|
|
458
432
|
};
|
|
459
433
|
function SkeletonRegion({ label, className, children }) {
|
|
460
|
-
return /* @__PURE__ */
|
|
461
|
-
/* @__PURE__ */
|
|
462
|
-
/* @__PURE__ */
|
|
434
|
+
return /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
435
|
+
/* @__PURE__ */ jsx5("span", { role: "status", "aria-live": "polite", "aria-busy": true, className: "sr-only", children: label }),
|
|
436
|
+
/* @__PURE__ */ jsx5("div", { className, "aria-hidden": "true", children })
|
|
463
437
|
] });
|
|
464
438
|
}
|
|
465
439
|
function TreeSkeleton() {
|
|
466
|
-
return /* @__PURE__ */
|
|
440
|
+
return /* @__PURE__ */ jsx5(SkeletonRegion, { label: "Loading files\u2026", className: "space-y-2 p-4", children: [32, 48, 40, 52].map((w, i) => /* @__PURE__ */ jsx5("div", { className: "h-4 animate-pulse rounded bg-muted", style: { width: `${w * 4}px` } }, i)) });
|
|
467
441
|
}
|
|
468
442
|
function EditorSkeleton() {
|
|
469
|
-
return /* @__PURE__ */
|
|
470
|
-
/* @__PURE__ */
|
|
471
|
-
/* @__PURE__ */
|
|
472
|
-
/* @__PURE__ */
|
|
473
|
-
/* @__PURE__ */
|
|
443
|
+
return /* @__PURE__ */ jsxs5(SkeletonRegion, { label: "Loading file\u2026", className: "space-y-3 p-8", children: [
|
|
444
|
+
/* @__PURE__ */ jsx5("div", { className: "h-5 w-1/2 animate-pulse rounded bg-muted" }),
|
|
445
|
+
/* @__PURE__ */ jsx5("div", { className: "h-4 w-full animate-pulse rounded bg-muted" }),
|
|
446
|
+
/* @__PURE__ */ jsx5("div", { className: "h-4 w-3/4 animate-pulse rounded bg-muted" }),
|
|
447
|
+
/* @__PURE__ */ jsx5("div", { className: "h-4 w-2/3 animate-pulse rounded bg-muted" })
|
|
474
448
|
] });
|
|
475
449
|
}
|
|
450
|
+
function RetryButton({ onRetry }) {
|
|
451
|
+
return /* @__PURE__ */ jsx5(
|
|
452
|
+
"button",
|
|
453
|
+
{
|
|
454
|
+
type: "button",
|
|
455
|
+
onClick: onRetry,
|
|
456
|
+
className: "inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted",
|
|
457
|
+
children: "Retry"
|
|
458
|
+
}
|
|
459
|
+
);
|
|
460
|
+
}
|
|
476
461
|
function ReadErrorState({ message: message2, onRetry }) {
|
|
477
|
-
return /* @__PURE__ */
|
|
478
|
-
/* @__PURE__ */
|
|
479
|
-
/* @__PURE__ */
|
|
480
|
-
/* @__PURE__ */
|
|
462
|
+
return /* @__PURE__ */ jsxs5("div", { className: "flex h-full flex-col items-center justify-center gap-3 p-8 text-center", children: [
|
|
463
|
+
/* @__PURE__ */ jsxs5("div", { children: [
|
|
464
|
+
/* @__PURE__ */ jsx5("h3", { className: "text-sm font-medium text-foreground", children: "Couldn't open this file" }),
|
|
465
|
+
/* @__PURE__ */ jsx5("p", { className: "mt-1 max-w-md text-xs text-muted-foreground", children: message2 })
|
|
481
466
|
] }),
|
|
482
|
-
/* @__PURE__ */
|
|
483
|
-
"button",
|
|
484
|
-
{
|
|
485
|
-
type: "button",
|
|
486
|
-
onClick: onRetry,
|
|
487
|
-
className: "inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted",
|
|
488
|
-
children: "Retry"
|
|
489
|
-
}
|
|
490
|
-
)
|
|
467
|
+
/* @__PURE__ */ jsx5(RetryButton, { onRetry })
|
|
491
468
|
] });
|
|
492
469
|
}
|
|
493
470
|
function TreeErrorState({ label, message: message2, onRetry }) {
|
|
494
|
-
return /* @__PURE__ */
|
|
495
|
-
/* @__PURE__ */
|
|
496
|
-
/* @__PURE__ */
|
|
471
|
+
return /* @__PURE__ */ jsxs5("div", { role: "alert", className: "flex h-full flex-col items-center justify-center gap-3 p-6 text-center", children: [
|
|
472
|
+
/* @__PURE__ */ jsxs5("div", { children: [
|
|
473
|
+
/* @__PURE__ */ jsxs5("h3", { className: "text-sm font-medium text-foreground", children: [
|
|
497
474
|
"Couldn't load ",
|
|
498
475
|
label
|
|
499
476
|
] }),
|
|
500
|
-
/* @__PURE__ */
|
|
477
|
+
/* @__PURE__ */ jsx5("p", { className: "mt-1 max-w-xs text-xs text-muted-foreground", children: message2 })
|
|
501
478
|
] }),
|
|
502
|
-
/* @__PURE__ */
|
|
503
|
-
"button",
|
|
504
|
-
{
|
|
505
|
-
type: "button",
|
|
506
|
-
onClick: onRetry,
|
|
507
|
-
className: "inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted",
|
|
508
|
-
children: "Retry"
|
|
509
|
-
}
|
|
510
|
-
)
|
|
479
|
+
/* @__PURE__ */ jsx5(RetryButton, { onRetry })
|
|
511
480
|
] });
|
|
512
481
|
}
|
|
513
482
|
function TreeEmptyState({ canCreate, onCreate }) {
|
|
514
|
-
return /* @__PURE__ */
|
|
515
|
-
/* @__PURE__ */
|
|
516
|
-
/* @__PURE__ */
|
|
517
|
-
/* @__PURE__ */
|
|
483
|
+
return /* @__PURE__ */ jsxs5("div", { className: "flex h-full flex-col items-center justify-center gap-3 p-6 text-center", children: [
|
|
484
|
+
/* @__PURE__ */ jsxs5("div", { children: [
|
|
485
|
+
/* @__PURE__ */ jsx5("h3", { className: "text-sm font-medium text-foreground", children: "No files yet" }),
|
|
486
|
+
/* @__PURE__ */ jsx5("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." })
|
|
518
487
|
] }),
|
|
519
|
-
canCreate && /* @__PURE__ */
|
|
488
|
+
canCreate && /* @__PURE__ */ jsxs5(
|
|
520
489
|
"button",
|
|
521
490
|
{
|
|
522
491
|
type: "button",
|
|
523
492
|
onClick: onCreate,
|
|
524
493
|
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",
|
|
525
494
|
children: [
|
|
526
|
-
/* @__PURE__ */
|
|
495
|
+
/* @__PURE__ */ jsx5(Plus, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
|
|
527
496
|
"New file"
|
|
528
497
|
]
|
|
529
498
|
}
|
|
530
499
|
)
|
|
531
500
|
] });
|
|
532
501
|
}
|
|
533
|
-
function TreeNoMatchState({ query, onClear }) {
|
|
534
|
-
return /* @__PURE__ */
|
|
535
|
-
/* @__PURE__ */
|
|
536
|
-
"No files match \u201C",
|
|
537
|
-
query,
|
|
538
|
-
"\u201D."
|
|
539
|
-
] }),
|
|
540
|
-
/* @__PURE__ */
|
|
541
|
-
"button",
|
|
542
|
-
{
|
|
543
|
-
type: "button",
|
|
544
|
-
onClick: onClear,
|
|
545
|
-
className: "inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted",
|
|
546
|
-
children: "Clear search"
|
|
547
|
-
}
|
|
548
|
-
)
|
|
549
|
-
] });
|
|
502
|
+
function TreeNoMatchState({ query, onClear }) {
|
|
503
|
+
return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-center gap-3 p-6 text-center", children: [
|
|
504
|
+
/* @__PURE__ */ jsxs5("p", { className: "max-w-xs break-words text-xs text-muted-foreground", children: [
|
|
505
|
+
"No files match \u201C",
|
|
506
|
+
query,
|
|
507
|
+
"\u201D."
|
|
508
|
+
] }),
|
|
509
|
+
/* @__PURE__ */ jsx5(
|
|
510
|
+
"button",
|
|
511
|
+
{
|
|
512
|
+
type: "button",
|
|
513
|
+
onClick: onClear,
|
|
514
|
+
className: "inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted",
|
|
515
|
+
children: "Clear search"
|
|
516
|
+
}
|
|
517
|
+
)
|
|
518
|
+
] });
|
|
519
|
+
}
|
|
520
|
+
function OperationErrorAlert({
|
|
521
|
+
message: message2,
|
|
522
|
+
retryLabel,
|
|
523
|
+
onRetry,
|
|
524
|
+
onDismiss
|
|
525
|
+
}) {
|
|
526
|
+
return /* @__PURE__ */ jsxs5(
|
|
527
|
+
"div",
|
|
528
|
+
{
|
|
529
|
+
role: "alert",
|
|
530
|
+
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)]",
|
|
531
|
+
children: [
|
|
532
|
+
/* @__PURE__ */ jsx5("span", { className: "min-w-0 flex-1", children: message2 }),
|
|
533
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex shrink-0 items-center gap-3", children: [
|
|
534
|
+
/* @__PURE__ */ jsx5("button", { type: "button", "aria-label": retryLabel, onClick: onRetry, className: "font-medium underline-offset-2 hover:underline", children: "Retry" }),
|
|
535
|
+
/* @__PURE__ */ jsx5("button", { type: "button", onClick: onDismiss, className: "underline-offset-2 hover:underline", children: "Dismiss" })
|
|
536
|
+
] })
|
|
537
|
+
]
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
function DocumentEmptyState({ label, recent, onOpen }) {
|
|
542
|
+
const recentHeadingId = useId3();
|
|
543
|
+
return /* @__PURE__ */ jsx5("div", { "data-vault-document-empty": true, className: "flex h-full items-center justify-center overflow-y-auto p-8", children: /* @__PURE__ */ jsxs5("div", { className: "w-full max-w-sm text-center", children: [
|
|
544
|
+
/* @__PURE__ */ jsx5("span", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-muted text-muted-foreground", children: /* @__PURE__ */ jsx5(FileText2, { className: "size-5", "aria-hidden": "true" }) }),
|
|
545
|
+
/* @__PURE__ */ jsx5("h3", { className: "mt-4 text-base font-semibold text-foreground", children: "Select a file" }),
|
|
546
|
+
/* @__PURE__ */ jsxs5("p", { className: "mt-1 text-sm text-muted-foreground", children: [
|
|
547
|
+
"Choose a file in ",
|
|
548
|
+
label,
|
|
549
|
+
" to open it here."
|
|
550
|
+
] }),
|
|
551
|
+
recent.length > 0 && /* @__PURE__ */ jsxs5("section", { "aria-labelledby": recentHeadingId, className: "mt-8 text-left", children: [
|
|
552
|
+
/* @__PURE__ */ jsx5("h4", { id: recentHeadingId, className: "text-xs font-medium text-muted-foreground", children: "Recently opened" }),
|
|
553
|
+
/* @__PURE__ */ jsx5("ul", { className: "mt-2 overflow-hidden rounded-xl border border-border bg-card shadow-raised", children: recent.map((path) => {
|
|
554
|
+
const slash = path.lastIndexOf("/");
|
|
555
|
+
return /* @__PURE__ */ jsx5("li", { className: "border-b border-border last:border-b-0", children: /* @__PURE__ */ jsxs5(
|
|
556
|
+
"button",
|
|
557
|
+
{
|
|
558
|
+
type: "button",
|
|
559
|
+
onClick: () => onOpen(path),
|
|
560
|
+
title: path,
|
|
561
|
+
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",
|
|
562
|
+
children: [
|
|
563
|
+
/* @__PURE__ */ jsx5(FileText2, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
564
|
+
/* @__PURE__ */ jsx5("span", { className: "min-w-0 truncate font-medium", children: path.slice(slash + 1) }),
|
|
565
|
+
slash > 0 && /* @__PURE__ */ jsx5("span", { className: "ml-auto min-w-0 shrink truncate text-xs text-muted-foreground", children: path.slice(0, slash) })
|
|
566
|
+
]
|
|
567
|
+
}
|
|
568
|
+
) }, path);
|
|
569
|
+
}) })
|
|
570
|
+
] })
|
|
571
|
+
] }) });
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// src/vault/VaultDocumentToolbar.tsx
|
|
575
|
+
import { Download, History as History2, Trash2 } from "lucide-react";
|
|
576
|
+
import { ShellHeader } from "@tangle-network/sandbox-ui/workspace";
|
|
577
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
578
|
+
function VaultDocumentToolbar({ file: selectedFile, className: pathBarClassName, editing, history, dock, onDownloadFile, onDelete, children }) {
|
|
579
|
+
return /* @__PURE__ */ jsxs6(ShellHeader, { className: `justify-between gap-2 px-4 ${pathBarClassName ?? "bg-card"}`, children: [
|
|
580
|
+
/* @__PURE__ */ jsx6("span", { "data-vault-path": true, className: "min-w-0 flex-1 truncate text-sm font-medium text-foreground", children: selectedFile.path }),
|
|
581
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
582
|
+
editing && /* @__PURE__ */ jsxs6("div", { className: "mr-1 flex items-center gap-1", children: [
|
|
583
|
+
/* @__PURE__ */ jsx6(
|
|
584
|
+
"button",
|
|
585
|
+
{
|
|
586
|
+
type: "button",
|
|
587
|
+
"aria-label": "Edit as rich text",
|
|
588
|
+
"aria-pressed": editing.value === "rich",
|
|
589
|
+
onClick: editing.onRich,
|
|
590
|
+
className: `inline-flex h-8 items-center rounded px-2.5 text-sm transition-colors ${editing.value === "rich" ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
|
|
591
|
+
children: "Rich"
|
|
592
|
+
}
|
|
593
|
+
),
|
|
594
|
+
/* @__PURE__ */ jsx6(
|
|
595
|
+
"button",
|
|
596
|
+
{
|
|
597
|
+
type: "button",
|
|
598
|
+
"aria-label": "Edit as source",
|
|
599
|
+
"aria-pressed": editing.value === "source",
|
|
600
|
+
onClick: editing.onSource,
|
|
601
|
+
className: `inline-flex h-8 items-center rounded px-2.5 text-sm transition-colors ${editing.value === "source" ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
|
|
602
|
+
children: "Source"
|
|
603
|
+
}
|
|
604
|
+
)
|
|
605
|
+
] }),
|
|
606
|
+
history && /* @__PURE__ */ jsxs6(
|
|
607
|
+
"button",
|
|
608
|
+
{
|
|
609
|
+
type: "button",
|
|
610
|
+
"aria-pressed": history.open,
|
|
611
|
+
disabled: history.dirty && !history.open,
|
|
612
|
+
title: history.dirty && !history.open ? "Save or discard your edits first" : "Saved versions of this file",
|
|
613
|
+
onClick: history.onToggle,
|
|
614
|
+
className: `inline-flex h-8 items-center gap-1.5 rounded px-2.5 text-sm transition-colors disabled:pointer-events-none disabled:opacity-40 ${history.open ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
|
|
615
|
+
children: [
|
|
616
|
+
/* @__PURE__ */ jsx6(History2, { className: "size-4", "aria-hidden": "true" }),
|
|
617
|
+
"History"
|
|
618
|
+
]
|
|
619
|
+
}
|
|
620
|
+
),
|
|
621
|
+
dock && /* @__PURE__ */ jsx6(
|
|
622
|
+
"button",
|
|
623
|
+
{
|
|
624
|
+
type: "button",
|
|
625
|
+
"aria-label": dock.label,
|
|
626
|
+
"aria-pressed": dock.open,
|
|
627
|
+
disabled: dock.blocked,
|
|
628
|
+
title: dock.blocked ? "Save your changes first" : dock.title,
|
|
629
|
+
onClick: dock.onToggle,
|
|
630
|
+
className: `inline-flex h-8 items-center gap-1 rounded px-2.5 text-sm transition-colors disabled:pointer-events-none disabled:opacity-40 ${dock.open ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
|
|
631
|
+
children: dock.label
|
|
632
|
+
}
|
|
633
|
+
),
|
|
634
|
+
children,
|
|
635
|
+
onDownloadFile && /* @__PURE__ */ jsx6(
|
|
636
|
+
"button",
|
|
637
|
+
{
|
|
638
|
+
type: "button",
|
|
639
|
+
"aria-label": "Download this file",
|
|
640
|
+
title: "Download file",
|
|
641
|
+
onClick: () => onDownloadFile(selectedFile),
|
|
642
|
+
className: "inline-flex h-7 w-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
643
|
+
children: /* @__PURE__ */ jsx6(Download, { className: "h-4 w-4" })
|
|
644
|
+
}
|
|
645
|
+
),
|
|
646
|
+
onDelete && /* @__PURE__ */ jsx6(
|
|
647
|
+
"button",
|
|
648
|
+
{
|
|
649
|
+
type: "button",
|
|
650
|
+
"aria-label": "Delete this file",
|
|
651
|
+
title: "Delete file",
|
|
652
|
+
onClick: onDelete,
|
|
653
|
+
className: "inline-flex h-7 w-7 items-center justify-center rounded text-[var(--surface-danger-text)] transition-colors hover:bg-destructive/10",
|
|
654
|
+
children: /* @__PURE__ */ jsx6(Trash2, { className: "h-4 w-4" })
|
|
655
|
+
}
|
|
656
|
+
)
|
|
657
|
+
] })
|
|
658
|
+
] });
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// src/vault/VaultTreePanel.tsx
|
|
662
|
+
import { Folder, Plus as Plus2, RefreshCw } from "lucide-react";
|
|
663
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
664
|
+
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";
|
|
665
|
+
function VaultTreePanel({ label, treeHeadingId, headerActions, onRefresh, onCreate, activeFolder, onClearFolder, query, onQueryChange, canSearchContent, empty, searchRef, children }) {
|
|
666
|
+
const noun = label.toLowerCase();
|
|
667
|
+
return /* @__PURE__ */ jsxs7(
|
|
668
|
+
"section",
|
|
669
|
+
{
|
|
670
|
+
"aria-labelledby": treeHeadingId,
|
|
671
|
+
"data-vault-tree-surface": true,
|
|
672
|
+
"data-slot": "card",
|
|
673
|
+
className: "flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-raised",
|
|
674
|
+
children: [
|
|
675
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex shrink-0 items-center gap-2 px-3 pb-2 pt-3", children: [
|
|
676
|
+
/* @__PURE__ */ jsx7("h2", { id: treeHeadingId, className: "min-w-0 flex-1 truncate text-sm font-semibold text-foreground", children: label }),
|
|
677
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
678
|
+
headerActions,
|
|
679
|
+
/* @__PURE__ */ jsx7(
|
|
680
|
+
"button",
|
|
681
|
+
{
|
|
682
|
+
type: "button",
|
|
683
|
+
"aria-label": `Refresh ${noun}`,
|
|
684
|
+
title: "Refresh",
|
|
685
|
+
onClick: onRefresh,
|
|
686
|
+
className: `${TREE_ICON_BUTTON} text-muted-foreground hover:bg-muted hover:text-foreground`,
|
|
687
|
+
children: /* @__PURE__ */ jsx7(RefreshCw, { className: "size-4", "aria-hidden": "true" })
|
|
688
|
+
}
|
|
689
|
+
),
|
|
690
|
+
onCreate && /* @__PURE__ */ jsx7(
|
|
691
|
+
"button",
|
|
692
|
+
{
|
|
693
|
+
type: "button",
|
|
694
|
+
title: "New file",
|
|
695
|
+
"aria-label": activeFolder ? `New file in ${activeFolder}` : "New file",
|
|
696
|
+
onClick: onCreate,
|
|
697
|
+
className: `${TREE_ICON_BUTTON} bg-primary text-primary-foreground hover:bg-primary/90`,
|
|
698
|
+
children: /* @__PURE__ */ jsx7(Plus2, { className: "size-4", "aria-hidden": "true" })
|
|
699
|
+
}
|
|
700
|
+
)
|
|
701
|
+
] })
|
|
702
|
+
] }),
|
|
703
|
+
/* @__PURE__ */ jsx7("div", { className: "shrink-0 px-3 pb-2", children: /* @__PURE__ */ jsx7(
|
|
704
|
+
"input",
|
|
705
|
+
{
|
|
706
|
+
ref: searchRef,
|
|
707
|
+
type: "search",
|
|
708
|
+
disabled: empty,
|
|
709
|
+
value: query,
|
|
710
|
+
onChange: (e) => onQueryChange(e.target.value),
|
|
711
|
+
placeholder: canSearchContent ? `Search ${noun} names and text\u2026` : `Search ${noun}\u2026`,
|
|
712
|
+
"aria-label": `Search ${noun}`,
|
|
713
|
+
className: "h-8 w-full rounded-md border border-[var(--field-border,var(--color-border))] bg-[var(--well,var(--color-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"
|
|
714
|
+
}
|
|
715
|
+
) }),
|
|
716
|
+
activeFolder && onCreate && /* @__PURE__ */ jsxs7("div", { className: "mx-3 mb-2 flex shrink-0 items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-sm", children: [
|
|
717
|
+
/* @__PURE__ */ jsx7(Folder, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
718
|
+
/* @__PURE__ */ jsx7("span", { className: "shrink-0 text-muted-foreground", children: "New files go in" }),
|
|
719
|
+
/* @__PURE__ */ jsx7("span", { "data-vault-folder": true, className: "min-w-0 flex-1 truncate font-medium text-foreground", title: activeFolder, children: activeFolder }),
|
|
720
|
+
/* @__PURE__ */ jsx7(
|
|
721
|
+
"button",
|
|
722
|
+
{
|
|
723
|
+
type: "button",
|
|
724
|
+
"aria-label": "Clear the active folder",
|
|
725
|
+
onClick: onClearFolder,
|
|
726
|
+
className: "shrink-0 rounded px-1 text-muted-foreground underline-offset-2 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
727
|
+
children: "Clear"
|
|
728
|
+
}
|
|
729
|
+
)
|
|
730
|
+
] }),
|
|
731
|
+
/* @__PURE__ */ jsx7("div", { className: "min-h-0 flex-1 overflow-y-auto border-t border-border px-1.5 py-1.5", children })
|
|
732
|
+
]
|
|
733
|
+
}
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// src/vault/VaultPaneNavigation.tsx
|
|
738
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
739
|
+
function VaultPaneNavigation({ label, selectedPath, showFiles, onShowFiles, onShowDocument }) {
|
|
740
|
+
return /* @__PURE__ */ jsx8(Fragment2, { children: selectedPath && /* @__PURE__ */ jsxs8("nav", { "aria-label": `${label} navigation`, className: "flex shrink-0 items-center gap-1 border-b border-border p-2 @[60rem]/vault:hidden", children: [
|
|
741
|
+
/* @__PURE__ */ jsx8(
|
|
742
|
+
"button",
|
|
743
|
+
{
|
|
744
|
+
type: "button",
|
|
745
|
+
"aria-pressed": showFiles,
|
|
746
|
+
onClick: onShowFiles,
|
|
747
|
+
className: `shrink-0 rounded-md px-3 py-2 text-sm ${showFiles ? "bg-muted font-medium text-foreground" : "text-muted-foreground hover:bg-muted"}`,
|
|
748
|
+
children: "Files"
|
|
749
|
+
}
|
|
750
|
+
),
|
|
751
|
+
selectedPath && /* @__PURE__ */ jsx8(
|
|
752
|
+
"button",
|
|
753
|
+
{
|
|
754
|
+
type: "button",
|
|
755
|
+
"aria-pressed": !showFiles,
|
|
756
|
+
onClick: onShowDocument,
|
|
757
|
+
title: selectedPath,
|
|
758
|
+
className: `min-w-0 truncate rounded-md px-3 py-2 text-sm ${!showFiles ? "bg-muted font-medium text-foreground" : "text-muted-foreground hover:bg-muted"}`,
|
|
759
|
+
children: selectedPath.split("/").pop()
|
|
760
|
+
}
|
|
761
|
+
)
|
|
762
|
+
] }) });
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// src/vault/VaultCreateDialog.tsx
|
|
766
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
767
|
+
function VaultCreateDialog({ open: createOpen, path: newPath, label, folder: activeFolder, busy: creating, error: createError, onPathChange, onConfirm, onCancel }) {
|
|
768
|
+
const createFileName = newPath.trim().split("/").pop()?.trim() ?? "";
|
|
769
|
+
return /* @__PURE__ */ jsx9(
|
|
770
|
+
ConfirmDialog,
|
|
771
|
+
{
|
|
772
|
+
open: createOpen,
|
|
773
|
+
title: "Create file",
|
|
774
|
+
description: activeFolder ? `Add a new document to ${activeFolder}.` : `Add a new document to ${label}.`,
|
|
775
|
+
confirmLabel: creating ? "Creating\u2026" : "Create",
|
|
776
|
+
confirmDisabled: creating || !createFileName,
|
|
777
|
+
onConfirm,
|
|
778
|
+
onCancel,
|
|
779
|
+
children: /* @__PURE__ */ jsxs9("div", { className: "space-y-2", children: [
|
|
780
|
+
/* @__PURE__ */ jsx9(
|
|
781
|
+
"input",
|
|
782
|
+
{
|
|
783
|
+
value: newPath,
|
|
784
|
+
autoFocus: true,
|
|
785
|
+
onChange: (e) => onPathChange(e.target.value),
|
|
786
|
+
placeholder: "e.g. playbooks/new-strategy.md",
|
|
787
|
+
"aria-label": "New file path",
|
|
788
|
+
className: "h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground"
|
|
789
|
+
}
|
|
790
|
+
),
|
|
791
|
+
createError && /* @__PURE__ */ jsx9("p", { role: "alert", className: "text-xs text-[var(--surface-danger-text)]", children: createError.message })
|
|
792
|
+
] })
|
|
793
|
+
}
|
|
794
|
+
);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// src/vault/useVaultSearch.ts
|
|
798
|
+
import { useEffect as useEffect3, useMemo, useState as useState2 } from "react";
|
|
799
|
+
import { filterFileNodes } from "@tangle-network/sandbox-ui/vault-tree";
|
|
800
|
+
var CONTENT_SEARCH_MIN = 2;
|
|
801
|
+
var CONTENT_SEARCH_DEBOUNCE_MS = 250;
|
|
802
|
+
function useVaultSearch({ port, treeRoot }) {
|
|
803
|
+
const [query, setQuery] = useState2("");
|
|
804
|
+
const [contentSearch, setContentSearch] = useState2({ status: "idle" });
|
|
805
|
+
const [contentSearchNonce, setContentSearchNonce] = useState2(0);
|
|
806
|
+
const visibleRoot = useMemo(() => {
|
|
807
|
+
const q = query.trim().toLowerCase();
|
|
808
|
+
if (!q) return treeRoot;
|
|
809
|
+
return { ...treeRoot, children: filterFileNodes(treeRoot.children ?? [], q) };
|
|
810
|
+
}, [treeRoot, query]);
|
|
811
|
+
const searchQuery = query.trim();
|
|
812
|
+
const canSearchContent = typeof port.searchContent === "function";
|
|
813
|
+
useEffect3(() => {
|
|
814
|
+
if (!canSearchContent || searchQuery.length < CONTENT_SEARCH_MIN) {
|
|
815
|
+
setContentSearch({ status: "idle" });
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
const controller = new AbortController();
|
|
819
|
+
setContentSearch((current) => ({
|
|
820
|
+
status: "loading",
|
|
821
|
+
query: searchQuery,
|
|
822
|
+
matches: current.status !== "idle" && current.status !== "error" && current.query === searchQuery ? current.matches : []
|
|
823
|
+
}));
|
|
824
|
+
const timer = setTimeout(() => {
|
|
825
|
+
port.searchContent(searchQuery, { signal: controller.signal }).then(
|
|
826
|
+
(matches) => {
|
|
827
|
+
if (!controller.signal.aborted) setContentSearch({ status: "done", query: searchQuery, matches });
|
|
828
|
+
},
|
|
829
|
+
(error) => {
|
|
830
|
+
if (!controller.signal.aborted) {
|
|
831
|
+
setContentSearch({ status: "error", query: searchQuery, message: operationMessage(error, "The search did not answer.") });
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
);
|
|
835
|
+
}, CONTENT_SEARCH_DEBOUNCE_MS);
|
|
836
|
+
return () => {
|
|
837
|
+
clearTimeout(timer);
|
|
838
|
+
controller.abort();
|
|
839
|
+
};
|
|
840
|
+
}, [port, canSearchContent, searchQuery, contentSearchNonce]);
|
|
841
|
+
const contentResults = !canSearchContent || searchQuery.length < CONTENT_SEARCH_MIN ? { status: "idle" } : contentSearch.status !== "idle" && contentSearch.query === searchQuery ? contentSearch : { status: "loading", query: searchQuery, matches: [] };
|
|
842
|
+
return { query, onQueryChange: setQuery, visibleRoot, canSearchContent, contentResults, retry: () => setContentSearchNonce((n) => n + 1) };
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
// src/vault/useVaultDockPlacement.ts
|
|
846
|
+
import { useLayoutEffect, useRef as useRef2, useState as useState3 } from "react";
|
|
847
|
+
var DOCK_SIDE_MIN_PX = 960;
|
|
848
|
+
function useVaultDockPlacement(renderDock) {
|
|
849
|
+
const rootRef = useRef2(null);
|
|
850
|
+
const [dockInline, setDockInline] = useState3(false);
|
|
851
|
+
useLayoutEffect(() => {
|
|
852
|
+
const root = rootRef.current;
|
|
853
|
+
if (!root || !renderDock || typeof ResizeObserver === "undefined") return;
|
|
854
|
+
const apply = (width) => {
|
|
855
|
+
if (width > 0) setDockInline(width < DOCK_SIDE_MIN_PX);
|
|
856
|
+
};
|
|
857
|
+
apply(root.getBoundingClientRect().width);
|
|
858
|
+
const observer = new ResizeObserver((entries) => apply(entries[0]?.contentRect.width ?? 0));
|
|
859
|
+
observer.observe(root);
|
|
860
|
+
return () => observer.disconnect();
|
|
861
|
+
}, [renderDock]);
|
|
862
|
+
return { rootRef, dockInline };
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// src/vault/recent-files.ts
|
|
866
|
+
var PREFIX = "tangle:vault-recent:";
|
|
867
|
+
var RECENT_FILE_LIMIT = 8;
|
|
868
|
+
function storage(key) {
|
|
869
|
+
if (!key || typeof window === "undefined") return null;
|
|
870
|
+
try {
|
|
871
|
+
return window.localStorage;
|
|
872
|
+
} catch {
|
|
873
|
+
return null;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
function readRecentFiles(key) {
|
|
877
|
+
const store = storage(key);
|
|
878
|
+
if (!store) return [];
|
|
879
|
+
try {
|
|
880
|
+
const parsed = JSON.parse(store.getItem(PREFIX + key) ?? "[]");
|
|
881
|
+
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : [];
|
|
882
|
+
} catch {
|
|
883
|
+
return [];
|
|
884
|
+
}
|
|
550
885
|
}
|
|
551
|
-
function
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
"div",
|
|
559
|
-
{
|
|
560
|
-
role: "alert",
|
|
561
|
-
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)]",
|
|
562
|
-
children: [
|
|
563
|
-
/* @__PURE__ */ jsx4("span", { className: "min-w-0 flex-1", children: message2 }),
|
|
564
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex shrink-0 items-center gap-3", children: [
|
|
565
|
-
/* @__PURE__ */ jsx4("button", { type: "button", "aria-label": retryLabel, onClick: onRetry, className: "font-medium underline-offset-2 hover:underline", children: "Retry" }),
|
|
566
|
-
/* @__PURE__ */ jsx4("button", { type: "button", onClick: onDismiss, className: "underline-offset-2 hover:underline", children: "Dismiss" })
|
|
567
|
-
] })
|
|
568
|
-
]
|
|
886
|
+
function recordRecentFile(key, path) {
|
|
887
|
+
const next = [path, ...readRecentFiles(key).filter((item) => item !== path)].slice(0, RECENT_FILE_LIMIT);
|
|
888
|
+
const store = storage(key);
|
|
889
|
+
if (store) {
|
|
890
|
+
try {
|
|
891
|
+
store.setItem(PREFIX + key, JSON.stringify(next));
|
|
892
|
+
} catch {
|
|
569
893
|
}
|
|
570
|
-
|
|
894
|
+
}
|
|
895
|
+
return next;
|
|
571
896
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
}) })
|
|
602
|
-
] })
|
|
603
|
-
] }) });
|
|
897
|
+
|
|
898
|
+
// src/vault/vault-tree-paths.ts
|
|
899
|
+
function collectTreePaths(nodes, into) {
|
|
900
|
+
for (const node of nodes) {
|
|
901
|
+
if (node.type === "file") into.files.add(node.path);
|
|
902
|
+
else into.directories.add(node.path);
|
|
903
|
+
if (node.children) collectTreePaths(node.children, into);
|
|
904
|
+
}
|
|
905
|
+
return into;
|
|
906
|
+
}
|
|
907
|
+
function resolveFilePath(rawPath, filePaths) {
|
|
908
|
+
if (filePaths.has(rawPath)) return rawPath;
|
|
909
|
+
const path = rawPath.replace(/^\/+|\/+$/g, "");
|
|
910
|
+
return filePaths.has(path) ? path : null;
|
|
911
|
+
}
|
|
912
|
+
function resolveTreePath(rawPath, paths) {
|
|
913
|
+
const file = resolveFilePath(rawPath, paths.files);
|
|
914
|
+
if (file) return { path: file, type: "file" };
|
|
915
|
+
if (paths.directories.has(rawPath)) return { path: rawPath, type: "directory" };
|
|
916
|
+
const trimmed = rawPath.replace(/^\/+|\/+$/g, "");
|
|
917
|
+
return paths.directories.has(trimmed) ? { path: trimmed, type: "directory" } : null;
|
|
918
|
+
}
|
|
919
|
+
function findDirectory(nodes, path) {
|
|
920
|
+
for (const node of nodes) {
|
|
921
|
+
if (node.type === "directory" && node.path === path) return node;
|
|
922
|
+
const found = node.children ? findDirectory(node.children, path) : null;
|
|
923
|
+
if (found) return found;
|
|
924
|
+
}
|
|
925
|
+
return null;
|
|
604
926
|
}
|
|
927
|
+
|
|
928
|
+
// src/vault/VaultPane.tsx
|
|
929
|
+
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
930
|
+
var IDENTITY_CODEC = {
|
|
931
|
+
parse: (raw) => raw,
|
|
932
|
+
serialize: (parts) => typeof parts === "string" ? parts : String(parts ?? "")
|
|
933
|
+
};
|
|
934
|
+
var LIST_CONTEXT = { operation: "list", phase: "operation" };
|
|
935
|
+
var RECENT_SHOWN = 5;
|
|
605
936
|
var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
606
937
|
const {
|
|
607
938
|
port,
|
|
@@ -634,20 +965,20 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
634
965
|
const isMarkdownCapable = codec !== void 0;
|
|
635
966
|
const persistentDock = dockToggle === false;
|
|
636
967
|
const dockToggleCfg = dockToggle ? dockToggle : { label: "Discuss", disabledWhenDirty: true };
|
|
637
|
-
const [tree, setTree] =
|
|
638
|
-
const [treeLoading, setTreeLoading] =
|
|
639
|
-
const [treeLoaded, setTreeLoaded] =
|
|
640
|
-
const [treeError, setTreeError] =
|
|
641
|
-
const [internalPath, setInternalPath] =
|
|
968
|
+
const [tree, setTree] = useState4([]);
|
|
969
|
+
const [treeLoading, setTreeLoading] = useState4(true);
|
|
970
|
+
const [treeLoaded, setTreeLoaded] = useState4(false);
|
|
971
|
+
const [treeError, setTreeError] = useState4(null);
|
|
972
|
+
const [internalPath, setInternalPath] = useState4(null);
|
|
642
973
|
const selectedPath = controlled ? controlledPath ?? null : internalPath;
|
|
643
|
-
const [filesOpen, setFilesOpen] =
|
|
974
|
+
const [filesOpen, setFilesOpen] = useState4(false);
|
|
644
975
|
const showFiles = filesOpen || !selectedPath;
|
|
645
|
-
const searchRef =
|
|
646
|
-
const documentRef =
|
|
647
|
-
const treeHeadingId =
|
|
648
|
-
const [recentFiles, setRecentFiles] =
|
|
976
|
+
const searchRef = useRef3(null);
|
|
977
|
+
const documentRef = useRef3(null);
|
|
978
|
+
const treeHeadingId = useId4();
|
|
979
|
+
const [recentFiles, setRecentFiles] = useState4(() => ({ key: treeStateKey, paths: readRecentFiles(treeStateKey) }));
|
|
649
980
|
if (recentFiles.key !== treeStateKey) setRecentFiles({ key: treeStateKey, paths: readRecentFiles(treeStateKey) });
|
|
650
|
-
|
|
981
|
+
useEffect4(() => {
|
|
651
982
|
setFilesOpen(false);
|
|
652
983
|
}, [selectedPath]);
|
|
653
984
|
const showDocument = useCallback2(() => {
|
|
@@ -659,73 +990,58 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
659
990
|
}
|
|
660
991
|
});
|
|
661
992
|
}, []);
|
|
662
|
-
const [selectedFile, setSelectedFile] =
|
|
663
|
-
const [displayReadyPath, setDisplayReadyPath] =
|
|
664
|
-
const [fileLoading, setFileLoading] =
|
|
665
|
-
const [readError, setReadError] =
|
|
666
|
-
const [reloadNonce, setReloadNonce] =
|
|
667
|
-
const [saving, setSaving] =
|
|
668
|
-
const [saveError, setSaveError] =
|
|
669
|
-
const [editorMode, setEditorMode] =
|
|
670
|
-
const [richDraft, setRichDraft] =
|
|
671
|
-
const [sourceDraft, setSourceDraft] =
|
|
672
|
-
const [isDirty, setIsDirty] =
|
|
673
|
-
const [createOpen, setCreateOpen] =
|
|
674
|
-
const [newPath, setNewPath] =
|
|
675
|
-
const [creating, setCreating] =
|
|
676
|
-
const [createError, setCreateError] =
|
|
677
|
-
const [deleteOpen, setDeleteOpen] =
|
|
678
|
-
const [deleting, setDeleting] =
|
|
679
|
-
const [deleteError, setDeleteError] =
|
|
680
|
-
const [dockOpen, setDockOpen] =
|
|
681
|
-
const rootRef =
|
|
682
|
-
const [
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
const apply = (width) => {
|
|
687
|
-
if (width > 0) setDockInline(width < DOCK_SIDE_MIN_PX);
|
|
688
|
-
};
|
|
689
|
-
apply(root.getBoundingClientRect().width);
|
|
690
|
-
const observer = new ResizeObserver((entries) => apply(entries[0]?.contentRect.width ?? 0));
|
|
691
|
-
observer.observe(root);
|
|
692
|
-
return () => observer.disconnect();
|
|
693
|
-
}, [renderDock]);
|
|
694
|
-
const [pendingNav, setPendingNav] = useState2(null);
|
|
695
|
-
const [query, setQuery] = useState2("");
|
|
696
|
-
const [folderPath, setFolderPath] = useState2(null);
|
|
697
|
-
const [contentSearch, setContentSearch] = useState2({ status: "idle" });
|
|
698
|
-
const [contentSearchNonce, setContentSearchNonce] = useState2(0);
|
|
699
|
-
const [historyOpen, setHistoryOpen] = useState2(false);
|
|
700
|
-
const dirtyRef = useRef2(isDirty);
|
|
993
|
+
const [selectedFile, setSelectedFile] = useState4(null);
|
|
994
|
+
const [displayReadyPath, setDisplayReadyPath] = useState4(null);
|
|
995
|
+
const [fileLoading, setFileLoading] = useState4(false);
|
|
996
|
+
const [readError, setReadError] = useState4(null);
|
|
997
|
+
const [reloadNonce, setReloadNonce] = useState4(0);
|
|
998
|
+
const [saving, setSaving] = useState4(false);
|
|
999
|
+
const [saveError, setSaveError] = useState4(null);
|
|
1000
|
+
const [editorMode, setEditorMode] = useState4("rich");
|
|
1001
|
+
const [richDraft, setRichDraft] = useState4("");
|
|
1002
|
+
const [sourceDraft, setSourceDraft] = useState4("");
|
|
1003
|
+
const [isDirty, setIsDirty] = useState4(false);
|
|
1004
|
+
const [createOpen, setCreateOpen] = useState4(false);
|
|
1005
|
+
const [newPath, setNewPath] = useState4("");
|
|
1006
|
+
const [creating, setCreating] = useState4(false);
|
|
1007
|
+
const [createError, setCreateError] = useState4(null);
|
|
1008
|
+
const [deleteOpen, setDeleteOpen] = useState4(false);
|
|
1009
|
+
const [deleting, setDeleting] = useState4(false);
|
|
1010
|
+
const [deleteError, setDeleteError] = useState4(null);
|
|
1011
|
+
const [dockOpen, setDockOpen] = useState4(false);
|
|
1012
|
+
const { rootRef, dockInline } = useVaultDockPlacement(renderDock);
|
|
1013
|
+
const [pendingNav, setPendingNav] = useState4(null);
|
|
1014
|
+
const [folderPath, setFolderPath] = useState4(null);
|
|
1015
|
+
const [historyOpen, setHistoryOpen] = useState4(false);
|
|
1016
|
+
const dirtyRef = useRef3(isDirty);
|
|
701
1017
|
dirtyRef.current = isDirty;
|
|
702
|
-
const treeRequestRef =
|
|
703
|
-
const savedContentRef =
|
|
704
|
-
const draftContentRef =
|
|
705
|
-
const savedResultRef =
|
|
706
|
-
const saveRequestRef =
|
|
707
|
-
const saveScopeKey =
|
|
708
|
-
const saveScopeRef =
|
|
1018
|
+
const treeRequestRef = useRef3(0);
|
|
1019
|
+
const savedContentRef = useRef3("");
|
|
1020
|
+
const draftContentRef = useRef3("");
|
|
1021
|
+
const savedResultRef = useRef3(null);
|
|
1022
|
+
const saveRequestRef = useRef3(null);
|
|
1023
|
+
const saveScopeKey = useMemo2(() => ({}), [port, selectedPath, canWrite, historyOpen]);
|
|
1024
|
+
const saveScopeRef = useRef3({ key: saveScopeKey, port, path: selectedPath, canWrite, historyOpen });
|
|
709
1025
|
saveScopeRef.current = { key: saveScopeKey, port, path: selectedPath, canWrite, historyOpen };
|
|
710
|
-
const mountedRef =
|
|
711
|
-
const editorModeRef =
|
|
1026
|
+
const mountedRef = useRef3(true);
|
|
1027
|
+
const editorModeRef = useRef3(editorMode);
|
|
712
1028
|
editorModeRef.current = editorMode;
|
|
713
|
-
|
|
1029
|
+
useEffect4(() => {
|
|
714
1030
|
mountedRef.current = true;
|
|
715
1031
|
return () => {
|
|
716
1032
|
mountedRef.current = false;
|
|
717
1033
|
saveRequestRef.current = null;
|
|
718
1034
|
};
|
|
719
1035
|
}, []);
|
|
720
|
-
const savedRichDraft =
|
|
1036
|
+
const savedRichDraft = useMemo2(
|
|
721
1037
|
() => selectedFile ? activeCodec.parse(selectedFile.content) : void 0,
|
|
722
1038
|
[selectedFile?.content, activeCodec]
|
|
723
1039
|
);
|
|
724
|
-
const loadedPathRef =
|
|
725
|
-
const onOperationErrorRef =
|
|
1040
|
+
const loadedPathRef = useRef3(null);
|
|
1041
|
+
const onOperationErrorRef = useRef3(onOperationError);
|
|
726
1042
|
onOperationErrorRef.current = onOperationError;
|
|
727
|
-
const pendingOpenRef =
|
|
728
|
-
const previousPortRef =
|
|
1043
|
+
const pendingOpenRef = useRef3(null);
|
|
1044
|
+
const previousPortRef = useRef3(port);
|
|
729
1045
|
const finishPendingOpen = useCallback2((opened, clearNavigation = true) => {
|
|
730
1046
|
const pending = pendingOpenRef.current;
|
|
731
1047
|
if (!pending) return;
|
|
@@ -735,72 +1051,37 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
735
1051
|
}
|
|
736
1052
|
pending.resolve(opened);
|
|
737
1053
|
}, []);
|
|
738
|
-
|
|
739
|
-
|
|
1054
|
+
useEffect4(() => () => finishPendingOpen(false, false), [finishPendingOpen]);
|
|
1055
|
+
useEffect4(() => {
|
|
740
1056
|
if (previousPortRef.current !== port) finishPendingOpen(false);
|
|
741
1057
|
previousPortRef.current = port;
|
|
742
1058
|
}, [port, finishPendingOpen]);
|
|
743
|
-
|
|
1059
|
+
useEffect4(() => {
|
|
744
1060
|
const pending = pendingOpenRef.current;
|
|
745
1061
|
if (!pending) return;
|
|
746
1062
|
if (selectedPath === pending.path) pending.selected = true;
|
|
747
1063
|
else if (pending.selected || selectedPath !== pending.fromPath) finishPendingOpen(false);
|
|
748
1064
|
}, [selectedPath, finishPendingOpen]);
|
|
749
|
-
const treePaths =
|
|
1065
|
+
const treePaths = useMemo2(
|
|
750
1066
|
() => collectTreePaths(tree, { files: /* @__PURE__ */ new Set(), directories: /* @__PURE__ */ new Set() }),
|
|
751
1067
|
[tree]
|
|
752
1068
|
);
|
|
753
|
-
const resolvedSelectedPath =
|
|
1069
|
+
const resolvedSelectedPath = useMemo2(() => {
|
|
754
1070
|
if (!selectedPath) return null;
|
|
755
1071
|
const listed = resolveTreePath(selectedPath, treePaths);
|
|
756
1072
|
if (listed?.type === "directory") return null;
|
|
757
1073
|
return listed?.path ?? selectedPath;
|
|
758
1074
|
}, [selectedPath, treePaths]);
|
|
759
|
-
const activeFolderNode =
|
|
1075
|
+
const activeFolderNode = useMemo2(
|
|
760
1076
|
() => folderPath ? findDirectory(tree, folderPath) : null,
|
|
761
1077
|
[tree, folderPath]
|
|
762
1078
|
);
|
|
763
1079
|
const activeFolder = activeFolderNode?.path ?? null;
|
|
764
|
-
const treeRoot =
|
|
1080
|
+
const treeRoot = useMemo2(
|
|
765
1081
|
() => ({ name: label, path: "", type: "directory", children: tree }),
|
|
766
1082
|
[tree, label]
|
|
767
1083
|
);
|
|
768
|
-
const visibleRoot =
|
|
769
|
-
const q = query.trim().toLowerCase();
|
|
770
|
-
if (!q) return treeRoot;
|
|
771
|
-
return { ...treeRoot, children: filterFileNodes(treeRoot.children ?? [], q) };
|
|
772
|
-
}, [treeRoot, query]);
|
|
773
|
-
const searchQuery = query.trim();
|
|
774
|
-
const canSearchContent = typeof port.searchContent === "function";
|
|
775
|
-
useEffect3(() => {
|
|
776
|
-
if (!canSearchContent || searchQuery.length < CONTENT_SEARCH_MIN) {
|
|
777
|
-
setContentSearch({ status: "idle" });
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
|
-
const controller = new AbortController();
|
|
781
|
-
setContentSearch((current) => ({
|
|
782
|
-
status: "loading",
|
|
783
|
-
query: searchQuery,
|
|
784
|
-
matches: current.status !== "idle" && current.status !== "error" && current.query === searchQuery ? current.matches : []
|
|
785
|
-
}));
|
|
786
|
-
const timer = setTimeout(() => {
|
|
787
|
-
port.searchContent(searchQuery, { signal: controller.signal }).then(
|
|
788
|
-
(matches) => {
|
|
789
|
-
if (!controller.signal.aborted) setContentSearch({ status: "done", query: searchQuery, matches });
|
|
790
|
-
},
|
|
791
|
-
(error) => {
|
|
792
|
-
if (!controller.signal.aborted) {
|
|
793
|
-
setContentSearch({ status: "error", query: searchQuery, message: operationMessage(error, "The search did not answer.") });
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
);
|
|
797
|
-
}, CONTENT_SEARCH_DEBOUNCE_MS);
|
|
798
|
-
return () => {
|
|
799
|
-
clearTimeout(timer);
|
|
800
|
-
controller.abort();
|
|
801
|
-
};
|
|
802
|
-
}, [port, canSearchContent, searchQuery, contentSearchNonce]);
|
|
803
|
-
const contentResults = !canSearchContent || searchQuery.length < CONTENT_SEARCH_MIN ? { status: "idle" } : contentSearch.status !== "idle" && contentSearch.query === searchQuery ? contentSearch : { status: "loading", query: searchQuery, matches: [] };
|
|
1084
|
+
const { query, onQueryChange, visibleRoot, canSearchContent, contentResults, retry: retryContentSearch } = useVaultSearch({ port, treeRoot });
|
|
804
1085
|
const commitPath = useCallback2(
|
|
805
1086
|
(next) => {
|
|
806
1087
|
if (controlled) {
|
|
@@ -853,13 +1134,13 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
853
1134
|
if (request === treeRequestRef.current) setTreeLoading(false);
|
|
854
1135
|
}
|
|
855
1136
|
}, [port, reportFailure, label]);
|
|
856
|
-
|
|
1137
|
+
useEffect4(() => {
|
|
857
1138
|
setTree([]);
|
|
858
1139
|
setTreeLoaded(false);
|
|
859
1140
|
setTreeError(null);
|
|
860
1141
|
setSelectedFile(null);
|
|
861
1142
|
}, [port]);
|
|
862
|
-
|
|
1143
|
+
useEffect4(() => {
|
|
863
1144
|
void refresh();
|
|
864
1145
|
return () => {
|
|
865
1146
|
treeRequestRef.current += 1;
|
|
@@ -871,7 +1152,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
871
1152
|
const recovered = await refresh(context);
|
|
872
1153
|
if (recovered && context.selectAfterRecovery) commitPath(context.selectAfterRecovery);
|
|
873
1154
|
}, [treeError, refresh, commitPath]);
|
|
874
|
-
|
|
1155
|
+
useEffect4(() => {
|
|
875
1156
|
if (!selectedPath) {
|
|
876
1157
|
setSelectedFile(null);
|
|
877
1158
|
setFileLoading(false);
|
|
@@ -921,7 +1202,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
921
1202
|
cancelled = true;
|
|
922
1203
|
};
|
|
923
1204
|
}, [port, selectedPath, resolvedSelectedPath, treeLoading, treeLoaded, treeError, isDirty, saving, reloadNonce, commitPath, reportFailure, finishPendingOpen]);
|
|
924
|
-
|
|
1205
|
+
useEffect4(() => {
|
|
925
1206
|
if (!selectedFile) {
|
|
926
1207
|
loadedPathRef.current = null;
|
|
927
1208
|
setDisplayReadyPath(null);
|
|
@@ -950,7 +1231,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
950
1231
|
setSaveError(null);
|
|
951
1232
|
setDockOpen(false);
|
|
952
1233
|
}, [selectedFile?.path, selectedFile?.content, activeCodec]);
|
|
953
|
-
|
|
1234
|
+
useEffect4(() => {
|
|
954
1235
|
const pending = pendingOpenRef.current;
|
|
955
1236
|
if (pending?.loaded && pending.path === selectedPath && selectedFile?.path === pending.path && displayReadyPath === pending.path && sourceDraft === selectedFile.content && !fileLoading) {
|
|
956
1237
|
finishPendingOpen(true);
|
|
@@ -1004,7 +1285,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1004
1285
|
return current && (current === path || current.startsWith(`${path}/`)) ? null : current;
|
|
1005
1286
|
});
|
|
1006
1287
|
}, []);
|
|
1007
|
-
const selectFileRef =
|
|
1288
|
+
const selectFileRef = useRef3(() => {
|
|
1008
1289
|
});
|
|
1009
1290
|
selectFileRef.current = (rawPath) => {
|
|
1010
1291
|
const target = resolveTreePath(rawPath, treePaths);
|
|
@@ -1144,7 +1425,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1144
1425
|
}
|
|
1145
1426
|
}, [selectedFile, port, refresh, commitPath, reportFailure]);
|
|
1146
1427
|
const historyPath = selectedFile?.path ?? null;
|
|
1147
|
-
|
|
1428
|
+
useEffect4(() => {
|
|
1148
1429
|
setHistoryOpen(false);
|
|
1149
1430
|
}, [historyPath]);
|
|
1150
1431
|
const canShowHistory = typeof port.listRevisions === "function" && typeof port.readRevision === "function";
|
|
@@ -1171,12 +1452,11 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1171
1452
|
}
|
|
1172
1453
|
}, [port, selectedFile, saveScopeKey]);
|
|
1173
1454
|
const shownPath = selectedFile?.path ?? null;
|
|
1174
|
-
|
|
1455
|
+
useEffect4(() => {
|
|
1175
1456
|
if (!shownPath || !treeStateKey) return;
|
|
1176
1457
|
setRecentFiles({ key: treeStateKey, paths: recordRecentFile(treeStateKey, shownPath) });
|
|
1177
1458
|
}, [shownPath, treeStateKey]);
|
|
1178
1459
|
const recentToOffer = recentFiles.paths.filter((path) => path !== selectedPath && treePaths.files.has(path)).slice(0, RECENT_SHOWN);
|
|
1179
|
-
const createFileName = newPath.trim().split("/").pop()?.trim() ?? "";
|
|
1180
1460
|
const dockButtonLabel = persistentDock ? dockLabel : dockToggleCfg.label;
|
|
1181
1461
|
const dockBlockedByDraft = !persistentDock && (dockToggleCfg.disabledWhenDirty ?? true) && isDirty;
|
|
1182
1462
|
const openCreate = () => {
|
|
@@ -1187,14 +1467,28 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1187
1467
|
const vaultEmpty = treeLoaded && treePaths.files.size === 0 && treePaths.directories.size === 0;
|
|
1188
1468
|
const trimmedQuery = query.trim();
|
|
1189
1469
|
const nameMatches = (visibleRoot.children?.length ?? 0) > 0;
|
|
1470
|
+
const showFileList = () => {
|
|
1471
|
+
const focused = document.activeElement;
|
|
1472
|
+
setFilesOpen(true);
|
|
1473
|
+
requestAnimationFrame(() => {
|
|
1474
|
+
if (document.activeElement === focused || document.activeElement === document.body) {
|
|
1475
|
+
searchRef.current?.focus();
|
|
1476
|
+
}
|
|
1477
|
+
});
|
|
1478
|
+
};
|
|
1479
|
+
const cancelCreate = () => {
|
|
1480
|
+
setCreateOpen(false);
|
|
1481
|
+
setNewPath("");
|
|
1482
|
+
setCreateError(null);
|
|
1483
|
+
};
|
|
1190
1484
|
let treeContent;
|
|
1191
1485
|
if (!treeLoaded && (treeLoading || !treeError)) {
|
|
1192
|
-
treeContent = /* @__PURE__ */
|
|
1486
|
+
treeContent = /* @__PURE__ */ jsx10(TreeSkeleton, {});
|
|
1193
1487
|
} else if (!treeLoaded && treeError) {
|
|
1194
|
-
treeContent = /* @__PURE__ */
|
|
1488
|
+
treeContent = /* @__PURE__ */ jsx10(TreeErrorState, { label, message: treeFailureMessage(treeError.failure, label), onRetry: () => void retryTree() });
|
|
1195
1489
|
} else {
|
|
1196
|
-
treeContent = /* @__PURE__ */
|
|
1197
|
-
treeError && /* @__PURE__ */
|
|
1490
|
+
treeContent = /* @__PURE__ */ jsxs10(Fragment3, { children: [
|
|
1491
|
+
treeError && /* @__PURE__ */ jsx10(
|
|
1198
1492
|
OperationErrorAlert,
|
|
1199
1493
|
{
|
|
1200
1494
|
message: treeFailureMessage(treeError.failure, label),
|
|
@@ -1203,11 +1497,11 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1203
1497
|
onDismiss: () => setTreeError(null)
|
|
1204
1498
|
}
|
|
1205
1499
|
),
|
|
1206
|
-
vaultEmpty && !trimmedQuery ? treeEmptyState !== void 0 ? treeEmptyState : /* @__PURE__ */
|
|
1500
|
+
vaultEmpty && !trimmedQuery ? treeEmptyState !== void 0 ? treeEmptyState : /* @__PURE__ */ jsx10(TreeEmptyState, { canCreate, onCreate: openCreate }) : trimmedQuery && !nameMatches && (contentResults.status === "idle" || contentResults.status === "done" && contentResults.matches.length === 0) ? /* @__PURE__ */ jsx10(TreeNoMatchState, { query: trimmedQuery, onClear: () => onQueryChange("") }) : trimmedQuery && !nameMatches ? null : renderTree ? renderTree({
|
|
1207
1501
|
root: visibleRoot,
|
|
1208
1502
|
selectedPath: resolvedSelectedPath ?? void 0,
|
|
1209
1503
|
onSelect: handleTreeSelect
|
|
1210
|
-
}) : /* @__PURE__ */
|
|
1504
|
+
}) : /* @__PURE__ */ jsx10(
|
|
1211
1505
|
VaultTree,
|
|
1212
1506
|
{
|
|
1213
1507
|
root: visibleRoot,
|
|
@@ -1220,123 +1514,26 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1220
1514
|
label
|
|
1221
1515
|
}
|
|
1222
1516
|
),
|
|
1223
|
-
trimmedQuery && contentResults.status !== "idle" && /* @__PURE__ */
|
|
1517
|
+
trimmedQuery && contentResults.status !== "idle" && /* @__PURE__ */ jsx10(
|
|
1224
1518
|
VaultContentResults,
|
|
1225
1519
|
{
|
|
1226
1520
|
state: contentResults,
|
|
1227
1521
|
selectedPath: resolvedSelectedPath,
|
|
1228
1522
|
onOpen: (path) => guardedOpen(path),
|
|
1229
|
-
onRetry:
|
|
1523
|
+
onRetry: retryContentSearch
|
|
1230
1524
|
}
|
|
1231
1525
|
)
|
|
1232
1526
|
] });
|
|
1233
1527
|
}
|
|
1234
|
-
return /* @__PURE__ */
|
|
1528
|
+
return /* @__PURE__ */ jsx10(EditorErrorBoundary, { label, onReset: () => {
|
|
1235
1529
|
commitPath(null);
|
|
1236
1530
|
setSelectedFile(null);
|
|
1237
|
-
}, children: /* @__PURE__ */
|
|
1238
|
-
/* @__PURE__ */
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
type: "button",
|
|
1244
|
-
"aria-pressed": showFiles,
|
|
1245
|
-
onClick: () => {
|
|
1246
|
-
const focused = document.activeElement;
|
|
1247
|
-
setFilesOpen(true);
|
|
1248
|
-
requestAnimationFrame(() => {
|
|
1249
|
-
if (document.activeElement === focused || document.activeElement === document.body) {
|
|
1250
|
-
searchRef.current?.focus();
|
|
1251
|
-
}
|
|
1252
|
-
});
|
|
1253
|
-
},
|
|
1254
|
-
className: `shrink-0 rounded-md px-3 py-2 text-sm ${showFiles ? "bg-muted font-medium text-foreground" : "text-muted-foreground hover:bg-muted"}`,
|
|
1255
|
-
children: "Files"
|
|
1256
|
-
}
|
|
1257
|
-
),
|
|
1258
|
-
selectedPath && /* @__PURE__ */ jsx4(
|
|
1259
|
-
"button",
|
|
1260
|
-
{
|
|
1261
|
-
type: "button",
|
|
1262
|
-
"aria-pressed": !showFiles,
|
|
1263
|
-
onClick: showDocument,
|
|
1264
|
-
title: selectedPath,
|
|
1265
|
-
className: `min-w-0 truncate rounded-md px-3 py-2 text-sm ${!showFiles ? "bg-muted font-medium text-foreground" : "text-muted-foreground hover:bg-muted"}`,
|
|
1266
|
-
children: selectedPath.split("/").pop()
|
|
1267
|
-
}
|
|
1268
|
-
)
|
|
1269
|
-
] }),
|
|
1270
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex min-h-0 min-w-0 flex-1", children: [
|
|
1271
|
-
/* @__PURE__ */ jsx4("div", { "data-vault-tree": true, className: `${showFiles ? "flex" : "hidden"} min-w-0 flex-1 flex-col p-2 @[60rem]/vault:flex @[60rem]/vault:p-3 @[60rem]/vault:w-[23rem] @[60rem]/vault:min-w-[23rem] @[60rem]/vault:flex-none`, children: /* @__PURE__ */ jsxs4(
|
|
1272
|
-
"section",
|
|
1273
|
-
{
|
|
1274
|
-
"aria-labelledby": treeHeadingId,
|
|
1275
|
-
"data-vault-tree-surface": true,
|
|
1276
|
-
"data-slot": "card",
|
|
1277
|
-
className: "flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-raised",
|
|
1278
|
-
children: [
|
|
1279
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex shrink-0 items-center gap-2 px-3 pb-2 pt-3", children: [
|
|
1280
|
-
/* @__PURE__ */ jsx4("h2", { id: treeHeadingId, className: "min-w-0 flex-1 truncate text-sm font-semibold text-foreground", children: label }),
|
|
1281
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
1282
|
-
headerActions,
|
|
1283
|
-
/* @__PURE__ */ jsx4(
|
|
1284
|
-
"button",
|
|
1285
|
-
{
|
|
1286
|
-
type: "button",
|
|
1287
|
-
"aria-label": `Refresh ${noun}`,
|
|
1288
|
-
title: "Refresh",
|
|
1289
|
-
onClick: () => void refresh(),
|
|
1290
|
-
className: `${TREE_ICON_BUTTON} text-muted-foreground hover:bg-muted hover:text-foreground`,
|
|
1291
|
-
children: /* @__PURE__ */ jsx4(RefreshCw, { className: "size-4", "aria-hidden": "true" })
|
|
1292
|
-
}
|
|
1293
|
-
),
|
|
1294
|
-
canCreate && /* @__PURE__ */ jsx4(
|
|
1295
|
-
"button",
|
|
1296
|
-
{
|
|
1297
|
-
type: "button",
|
|
1298
|
-
title: "New file",
|
|
1299
|
-
"aria-label": activeFolder ? `New file in ${activeFolder}` : "New file",
|
|
1300
|
-
onClick: openCreate,
|
|
1301
|
-
className: `${TREE_ICON_BUTTON} bg-primary text-primary-foreground hover:bg-primary/90`,
|
|
1302
|
-
children: /* @__PURE__ */ jsx4(Plus, { className: "size-4", "aria-hidden": "true" })
|
|
1303
|
-
}
|
|
1304
|
-
)
|
|
1305
|
-
] })
|
|
1306
|
-
] }),
|
|
1307
|
-
/* @__PURE__ */ jsx4("div", { className: "shrink-0 px-3 pb-2", children: /* @__PURE__ */ jsx4(
|
|
1308
|
-
"input",
|
|
1309
|
-
{
|
|
1310
|
-
ref: searchRef,
|
|
1311
|
-
type: "search",
|
|
1312
|
-
disabled: vaultEmpty,
|
|
1313
|
-
value: query,
|
|
1314
|
-
onChange: (e) => setQuery(e.target.value),
|
|
1315
|
-
placeholder: canSearchContent ? `Search ${noun} names and text\u2026` : `Search ${noun}\u2026`,
|
|
1316
|
-
"aria-label": `Search ${noun}`,
|
|
1317
|
-
className: "h-8 w-full rounded-md border border-[var(--field-border,var(--color-border))] bg-[var(--well,var(--color-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"
|
|
1318
|
-
}
|
|
1319
|
-
) }),
|
|
1320
|
-
activeFolder && canCreate && /* @__PURE__ */ jsxs4("div", { className: "mx-3 mb-2 flex shrink-0 items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-sm", children: [
|
|
1321
|
-
/* @__PURE__ */ jsx4(Folder, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
1322
|
-
/* @__PURE__ */ jsx4("span", { className: "shrink-0 text-muted-foreground", children: "New files go in" }),
|
|
1323
|
-
/* @__PURE__ */ jsx4("span", { "data-vault-folder": true, className: "min-w-0 flex-1 truncate font-medium text-foreground", title: activeFolder, children: activeFolder }),
|
|
1324
|
-
/* @__PURE__ */ jsx4(
|
|
1325
|
-
"button",
|
|
1326
|
-
{
|
|
1327
|
-
type: "button",
|
|
1328
|
-
"aria-label": "Clear the active folder",
|
|
1329
|
-
onClick: () => setFolderPath(null),
|
|
1330
|
-
className: "shrink-0 rounded px-1 text-muted-foreground underline-offset-2 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1331
|
-
children: "Clear"
|
|
1332
|
-
}
|
|
1333
|
-
)
|
|
1334
|
-
] }),
|
|
1335
|
-
/* @__PURE__ */ jsx4("div", { className: "min-h-0 flex-1 overflow-y-auto border-t border-border px-1.5 py-1.5", children: treeContent })
|
|
1336
|
-
]
|
|
1337
|
-
}
|
|
1338
|
-
) }),
|
|
1339
|
-
/* @__PURE__ */ jsxs4(
|
|
1531
|
+
}, children: /* @__PURE__ */ jsxs10("div", { ref: rootRef, className: `flex min-h-0 min-w-0 flex-1 overflow-hidden ${className ?? ""}`, children: [
|
|
1532
|
+
/* @__PURE__ */ jsxs10("div", { className: "@container/vault flex min-w-0 flex-1 flex-col", children: [
|
|
1533
|
+
/* @__PURE__ */ jsx10(VaultPaneNavigation, { label, selectedPath, showFiles, onShowFiles: showFileList, onShowDocument: showDocument }),
|
|
1534
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex min-h-0 min-w-0 flex-1", children: [
|
|
1535
|
+
/* @__PURE__ */ jsx10("div", { "data-vault-tree": true, className: `${showFiles ? "flex" : "hidden"} min-w-0 flex-1 flex-col p-2 @[60rem]/vault:flex @[60rem]/vault:p-3 @[60rem]/vault:w-[23rem] @[60rem]/vault:min-w-[23rem] @[60rem]/vault:flex-none`, children: /* @__PURE__ */ jsx10(VaultTreePanel, { label, treeHeadingId, headerActions, onRefresh: () => void refresh(), onCreate: canCreate ? openCreate : void 0, activeFolder, onClearFolder: () => setFolderPath(null), query, onQueryChange, canSearchContent, empty: vaultEmpty, searchRef, children: treeContent }) }),
|
|
1536
|
+
/* @__PURE__ */ jsxs10(
|
|
1340
1537
|
"div",
|
|
1341
1538
|
{
|
|
1342
1539
|
ref: documentRef,
|
|
@@ -1345,90 +1542,23 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1345
1542
|
tabIndex: -1,
|
|
1346
1543
|
className: `${showFiles ? "hidden" : "flex"} min-w-0 flex-1 flex-col overflow-hidden @[60rem]/vault:flex`,
|
|
1347
1544
|
children: [
|
|
1348
|
-
selectedFile && /* @__PURE__ */
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
{
|
|
1366
|
-
type: "button",
|
|
1367
|
-
"aria-label": "Edit as source",
|
|
1368
|
-
"aria-pressed": editorMode === "source",
|
|
1369
|
-
onClick: showSourceMode,
|
|
1370
|
-
className: `inline-flex h-8 items-center rounded px-2.5 text-sm transition-colors ${editorMode === "source" ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
|
|
1371
|
-
children: "Source"
|
|
1372
|
-
}
|
|
1373
|
-
)
|
|
1374
|
-
] }),
|
|
1375
|
-
canShowHistory && /* @__PURE__ */ jsxs4(
|
|
1376
|
-
"button",
|
|
1377
|
-
{
|
|
1378
|
-
type: "button",
|
|
1379
|
-
"aria-pressed": historyOpen,
|
|
1380
|
-
disabled: isDirty && !historyOpen,
|
|
1381
|
-
title: isDirty && !historyOpen ? "Save or discard your edits first" : "Saved versions of this file",
|
|
1382
|
-
onClick: () => setHistoryOpen((open) => !open),
|
|
1383
|
-
className: `inline-flex h-8 items-center gap-1.5 rounded px-2.5 text-sm transition-colors disabled:pointer-events-none disabled:opacity-40 ${historyOpen ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
|
|
1384
|
-
children: [
|
|
1385
|
-
/* @__PURE__ */ jsx4(History2, { className: "size-4", "aria-hidden": "true" }),
|
|
1386
|
-
"History"
|
|
1387
|
-
]
|
|
1388
|
-
}
|
|
1389
|
-
),
|
|
1390
|
-
renderDock && (!persistentDock || dockInline) && /* @__PURE__ */ jsx4(
|
|
1391
|
-
"button",
|
|
1392
|
-
{
|
|
1393
|
-
type: "button",
|
|
1394
|
-
"aria-label": dockButtonLabel,
|
|
1395
|
-
"aria-pressed": dockOpen,
|
|
1396
|
-
disabled: dockBlockedByDraft,
|
|
1397
|
-
title: dockBlockedByDraft ? "Save your changes first" : persistentDock ? dockLabel : dockToggleCfg.title ?? dockToggleCfg.label,
|
|
1398
|
-
onClick: () => setDockOpen((v) => !v),
|
|
1399
|
-
className: `inline-flex h-8 items-center gap-1 rounded px-2.5 text-sm transition-colors disabled:pointer-events-none disabled:opacity-40 ${dockOpen ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
|
|
1400
|
-
children: dockButtonLabel
|
|
1401
|
-
}
|
|
1402
|
-
),
|
|
1403
|
-
fileActions?.(selectedFile),
|
|
1404
|
-
onDownloadFile && /* @__PURE__ */ jsx4(
|
|
1405
|
-
"button",
|
|
1406
|
-
{
|
|
1407
|
-
type: "button",
|
|
1408
|
-
"aria-label": "Download this file",
|
|
1409
|
-
title: "Download file",
|
|
1410
|
-
onClick: () => onDownloadFile(selectedFile),
|
|
1411
|
-
className: "inline-flex h-7 w-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
1412
|
-
children: /* @__PURE__ */ jsx4(Download, { className: "h-4 w-4" })
|
|
1413
|
-
}
|
|
1414
|
-
),
|
|
1415
|
-
canDelete && /* @__PURE__ */ jsx4(
|
|
1416
|
-
"button",
|
|
1417
|
-
{
|
|
1418
|
-
type: "button",
|
|
1419
|
-
"aria-label": "Delete this file",
|
|
1420
|
-
title: "Delete file",
|
|
1421
|
-
onClick: () => {
|
|
1422
|
-
setDeleteError(null);
|
|
1423
|
-
setDeleteOpen(true);
|
|
1424
|
-
},
|
|
1425
|
-
className: "inline-flex h-7 w-7 items-center justify-center rounded text-[var(--surface-danger-text)] transition-colors hover:bg-destructive/10",
|
|
1426
|
-
children: /* @__PURE__ */ jsx4(Trash2, { className: "h-4 w-4" })
|
|
1427
|
-
}
|
|
1428
|
-
)
|
|
1429
|
-
] })
|
|
1430
|
-
] }),
|
|
1431
|
-
selectedFile && saveError && /* @__PURE__ */ jsx4(
|
|
1545
|
+
selectedFile && /* @__PURE__ */ jsx10(
|
|
1546
|
+
VaultDocumentToolbar,
|
|
1547
|
+
{
|
|
1548
|
+
file: selectedFile,
|
|
1549
|
+
className: pathBarClassName,
|
|
1550
|
+
editing: canWrite && isMarkdownCapable ? { value: editorMode, onRich: showRichMode, onSource: showSourceMode } : void 0,
|
|
1551
|
+
history: canShowHistory ? { open: historyOpen, dirty: isDirty, onToggle: () => setHistoryOpen((open) => !open) } : void 0,
|
|
1552
|
+
dock: renderDock && (!persistentDock || dockInline) ? { label: dockButtonLabel, open: dockOpen, blocked: dockBlockedByDraft, title: persistentDock ? dockLabel : dockToggleCfg.title ?? dockToggleCfg.label, onToggle: () => setDockOpen((v) => !v) } : void 0,
|
|
1553
|
+
onDownloadFile,
|
|
1554
|
+
onDelete: canDelete ? () => {
|
|
1555
|
+
setDeleteError(null);
|
|
1556
|
+
setDeleteOpen(true);
|
|
1557
|
+
} : void 0,
|
|
1558
|
+
children: fileActions?.(selectedFile)
|
|
1559
|
+
}
|
|
1560
|
+
),
|
|
1561
|
+
selectedFile && saveError && /* @__PURE__ */ jsx10(
|
|
1432
1562
|
OperationErrorAlert,
|
|
1433
1563
|
{
|
|
1434
1564
|
message: saveError.message,
|
|
@@ -1437,7 +1567,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1437
1567
|
onDismiss: () => setSaveError(null)
|
|
1438
1568
|
}
|
|
1439
1569
|
),
|
|
1440
|
-
readError && selectedFile?.path === resolvedSelectedPath && /* @__PURE__ */
|
|
1570
|
+
readError && selectedFile?.path === resolvedSelectedPath && /* @__PURE__ */ jsx10(
|
|
1441
1571
|
OperationErrorAlert,
|
|
1442
1572
|
{
|
|
1443
1573
|
message: readError,
|
|
@@ -1446,7 +1576,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1446
1576
|
onDismiss: () => setReadError(null)
|
|
1447
1577
|
}
|
|
1448
1578
|
),
|
|
1449
|
-
/* @__PURE__ */
|
|
1579
|
+
/* @__PURE__ */ jsx10("div", { className: "flex-1 overflow-hidden", children: fileLoading && selectedFile?.path !== resolvedSelectedPath ? /* @__PURE__ */ jsx10(EditorSkeleton, {}) : readError && selectedFile?.path !== resolvedSelectedPath ? /* @__PURE__ */ jsx10(ReadErrorState, { message: readError, onRetry: () => setReloadNonce((n) => n + 1) }) : selectedFile && historyOpen && canShowHistory ? /* @__PURE__ */ jsx10(
|
|
1450
1580
|
VaultHistoryPanel,
|
|
1451
1581
|
{
|
|
1452
1582
|
path: selectedFile.path,
|
|
@@ -1471,7 +1601,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1471
1601
|
onRestore: restoreRevision,
|
|
1472
1602
|
onClose: () => setHistoryOpen(false)
|
|
1473
1603
|
}
|
|
1474
|
-
) : selectedFile && renderDock && dockInline && dockOpen ? /* @__PURE__ */
|
|
1604
|
+
) : selectedFile && renderDock && dockInline && dockOpen ? /* @__PURE__ */ jsx10("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__ */ jsx10(
|
|
1475
1605
|
SourceEditor,
|
|
1476
1606
|
{
|
|
1477
1607
|
path: selectedFile.path,
|
|
@@ -1492,7 +1622,7 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1492
1622
|
onRichChange,
|
|
1493
1623
|
onSave: () => void saveCurrent(),
|
|
1494
1624
|
saving
|
|
1495
|
-
}) : emptyState !== void 0 ? emptyState : /* @__PURE__ */
|
|
1625
|
+
}) : emptyState !== void 0 ? emptyState : /* @__PURE__ */ jsx10(DocumentEmptyState, { label, recent: recentToOffer, onOpen: (path) => guardedOpen(path) }) })
|
|
1496
1626
|
]
|
|
1497
1627
|
}
|
|
1498
1628
|
)
|
|
@@ -1505,37 +1635,8 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1505
1635
|
} : () => setDockOpen(false),
|
|
1506
1636
|
placement: "side"
|
|
1507
1637
|
}),
|
|
1508
|
-
/* @__PURE__ */
|
|
1509
|
-
|
|
1510
|
-
{
|
|
1511
|
-
open: createOpen,
|
|
1512
|
-
title: "Create file",
|
|
1513
|
-
description: activeFolder ? `Add a new document to ${activeFolder}.` : `Add a new document to ${label}.`,
|
|
1514
|
-
confirmLabel: creating ? "Creating\u2026" : "Create",
|
|
1515
|
-
confirmDisabled: creating || !createFileName,
|
|
1516
|
-
onConfirm: () => void handleCreate(),
|
|
1517
|
-
onCancel: () => {
|
|
1518
|
-
setCreateOpen(false);
|
|
1519
|
-
setNewPath("");
|
|
1520
|
-
setCreateError(null);
|
|
1521
|
-
},
|
|
1522
|
-
children: /* @__PURE__ */ jsxs4("div", { className: "space-y-2", children: [
|
|
1523
|
-
/* @__PURE__ */ jsx4(
|
|
1524
|
-
"input",
|
|
1525
|
-
{
|
|
1526
|
-
value: newPath,
|
|
1527
|
-
autoFocus: true,
|
|
1528
|
-
onChange: (e) => setNewPath(e.target.value),
|
|
1529
|
-
placeholder: "e.g. playbooks/new-strategy.md",
|
|
1530
|
-
"aria-label": "New file path",
|
|
1531
|
-
className: "h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground"
|
|
1532
|
-
}
|
|
1533
|
-
),
|
|
1534
|
-
createError && /* @__PURE__ */ jsx4("p", { role: "alert", className: "text-xs text-[var(--surface-danger-text)]", children: createError.message })
|
|
1535
|
-
] })
|
|
1536
|
-
}
|
|
1537
|
-
),
|
|
1538
|
-
/* @__PURE__ */ jsx4(
|
|
1638
|
+
/* @__PURE__ */ jsx10(VaultCreateDialog, { open: createOpen, path: newPath, label, folder: activeFolder, busy: creating, error: createError, onPathChange: setNewPath, onConfirm: () => void handleCreate(), onCancel: cancelCreate }),
|
|
1639
|
+
/* @__PURE__ */ jsx10(
|
|
1539
1640
|
ConfirmDialog,
|
|
1540
1641
|
{
|
|
1541
1642
|
open: deleteOpen,
|
|
@@ -1549,10 +1650,10 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1549
1650
|
setDeleteOpen(false);
|
|
1550
1651
|
setDeleteError(null);
|
|
1551
1652
|
},
|
|
1552
|
-
children: deleteError && /* @__PURE__ */
|
|
1653
|
+
children: deleteError && /* @__PURE__ */ jsx10("p", { role: "alert", className: "text-xs text-[var(--surface-danger-text)]", children: deleteError.message })
|
|
1553
1654
|
}
|
|
1554
1655
|
),
|
|
1555
|
-
/* @__PURE__ */
|
|
1656
|
+
/* @__PURE__ */ jsx10(
|
|
1556
1657
|
ConfirmDialog,
|
|
1557
1658
|
{
|
|
1558
1659
|
open: pendingNav !== null,
|
|
@@ -1569,61 +1670,9 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1569
1670
|
)
|
|
1570
1671
|
] }) });
|
|
1571
1672
|
});
|
|
1572
|
-
function SourceEditor({
|
|
1573
|
-
path,
|
|
1574
|
-
content,
|
|
1575
|
-
saving,
|
|
1576
|
-
dirty,
|
|
1577
|
-
onChange,
|
|
1578
|
-
onSave
|
|
1579
|
-
}) {
|
|
1580
|
-
return /* @__PURE__ */ jsxs4("div", { className: "flex h-full min-h-0 flex-col bg-background", children: [
|
|
1581
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-2 border-b border-border px-4 py-2", children: [
|
|
1582
|
-
/* @__PURE__ */ jsx4("p", { className: "truncate font-mono text-sm text-muted-foreground", children: path }),
|
|
1583
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
1584
|
-
/* @__PURE__ */ jsx4(
|
|
1585
|
-
"span",
|
|
1586
|
-
{
|
|
1587
|
-
role: "status",
|
|
1588
|
-
"aria-live": "polite",
|
|
1589
|
-
className: `rounded-full border px-2.5 py-1 text-sm ${dirty ? "border-[var(--surface-warning-border)] bg-[var(--surface-warning-bg)] text-[var(--surface-warning-text)]" : "border-border bg-background text-muted-foreground"}`,
|
|
1590
|
-
children: saving ? "Saving\u2026" : dirty ? "Unsaved changes" : "Saved"
|
|
1591
|
-
}
|
|
1592
|
-
),
|
|
1593
|
-
(dirty || saving) && /* @__PURE__ */ jsx4(
|
|
1594
|
-
"button",
|
|
1595
|
-
{
|
|
1596
|
-
type: "button",
|
|
1597
|
-
onClick: onSave,
|
|
1598
|
-
disabled: saving,
|
|
1599
|
-
title: "Save (Ctrl+S)",
|
|
1600
|
-
className: "inline-flex h-8 items-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",
|
|
1601
|
-
children: "Save"
|
|
1602
|
-
}
|
|
1603
|
-
)
|
|
1604
|
-
] })
|
|
1605
|
-
] }),
|
|
1606
|
-
/* @__PURE__ */ jsx4(
|
|
1607
|
-
"textarea",
|
|
1608
|
-
{
|
|
1609
|
-
value: content,
|
|
1610
|
-
onChange: (event) => onChange(event.target.value),
|
|
1611
|
-
onKeyDown: (event) => {
|
|
1612
|
-
if ((event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey && event.key.toLowerCase() === "s") {
|
|
1613
|
-
event.preventDefault();
|
|
1614
|
-
if (dirty && !saving) onSave();
|
|
1615
|
-
}
|
|
1616
|
-
},
|
|
1617
|
-
spellCheck: false,
|
|
1618
|
-
"aria-label": "Source editor",
|
|
1619
|
-
className: "min-h-0 flex-1 resize-none border-0 bg-background p-4 font-mono text-sm leading-6 text-foreground focus-visible:[outline-offset:-2px]"
|
|
1620
|
-
}
|
|
1621
|
-
)
|
|
1622
|
-
] });
|
|
1623
|
-
}
|
|
1624
1673
|
|
|
1625
1674
|
export {
|
|
1626
1675
|
ConfirmDialog,
|
|
1627
1676
|
VaultPane
|
|
1628
1677
|
};
|
|
1629
|
-
//# sourceMappingURL=chunk-
|
|
1678
|
+
//# sourceMappingURL=chunk-RL3Z747H.js.map
|