@getcatalystiq/agent-plane-ui 0.1.19 → 0.1.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/agent-identity-tab-ETPM6LQN.js +2 -0
- package/dist/agent-identity-tab-F4MU2HP2.cjs +11 -0
- package/dist/chunk-CE2RHDPY.js +422 -0
- package/dist/chunk-CHJL4MZI.cjs +277 -0
- package/dist/chunk-L45SI32F.js +275 -0
- package/dist/chunk-VZ43ATC5.cjs +454 -0
- package/dist/{chunk-OOBDCC6Q.js → chunk-XFI227OB.js} +6 -48
- package/dist/{chunk-VBGYWQUF.cjs → chunk-XXF4U7WL.cjs} +15 -67
- package/dist/editor.cjs +26 -657
- package/dist/editor.js +7 -643
- package/dist/index.cjs +346 -380
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +14 -47
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkCHJL4MZI_cjs = require('./chunk-CHJL4MZI.cjs');
|
|
4
|
+
require('./chunk-XXF4U7WL.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "AgentIdentityTab", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkCHJL4MZI_cjs.AgentIdentityTab; }
|
|
11
|
+
});
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { cn, useAgentPlaneClient, useAuthError, Badge, Button, Input } from './chunk-XFI227OB.js';
|
|
2
|
+
import useSWR from 'swr';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useState, useEffect, useRef, useMemo, useCallback } from 'react';
|
|
5
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
import CodeMirror from '@uiw/react-codemirror';
|
|
7
|
+
import { markdown } from '@codemirror/lang-markdown';
|
|
8
|
+
import { javascript } from '@codemirror/lang-javascript';
|
|
9
|
+
import { json } from '@codemirror/lang-json';
|
|
10
|
+
import { oneDark } from '@codemirror/theme-one-dark';
|
|
11
|
+
|
|
12
|
+
function useApi(key, fetcher, options) {
|
|
13
|
+
const client = useAgentPlaneClient();
|
|
14
|
+
const onAuthError = useAuthError();
|
|
15
|
+
return useSWR(
|
|
16
|
+
key,
|
|
17
|
+
() => fetcher(client),
|
|
18
|
+
{
|
|
19
|
+
revalidateOnFocus: false,
|
|
20
|
+
errorRetryCount: 3,
|
|
21
|
+
onError: (err) => {
|
|
22
|
+
if (onAuthError && err && typeof err === "object" && "status" in err && err.status === 401) {
|
|
23
|
+
onAuthError(err instanceof Error ? err : new Error(String(err)));
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
...options
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
var Card = React.forwardRef(
|
|
31
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("rounded-xl border bg-card text-card-foreground shadow", className), ...props })
|
|
32
|
+
);
|
|
33
|
+
Card.displayName = "Card";
|
|
34
|
+
var CardHeader = React.forwardRef(
|
|
35
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("flex flex-col space-y-1.5 p-6", className), ...props })
|
|
36
|
+
);
|
|
37
|
+
CardHeader.displayName = "CardHeader";
|
|
38
|
+
var CardTitle = React.forwardRef(
|
|
39
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("font-semibold leading-none tracking-tight", className), ...props })
|
|
40
|
+
);
|
|
41
|
+
CardTitle.displayName = "CardTitle";
|
|
42
|
+
var CardDescription = React.forwardRef(
|
|
43
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("text-sm text-muted-foreground", className), ...props })
|
|
44
|
+
);
|
|
45
|
+
CardDescription.displayName = "CardDescription";
|
|
46
|
+
var CardContent = React.forwardRef(
|
|
47
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props })
|
|
48
|
+
);
|
|
49
|
+
CardContent.displayName = "CardContent";
|
|
50
|
+
function Skeleton({ className, ...props }) {
|
|
51
|
+
return /* @__PURE__ */ jsx("div", { className: cn("animate-pulse rounded-md bg-muted/50", className), ...props });
|
|
52
|
+
}
|
|
53
|
+
function getLanguageExtension(filename) {
|
|
54
|
+
const ext = filename.split(".").pop()?.toLowerCase();
|
|
55
|
+
switch (ext) {
|
|
56
|
+
case "md":
|
|
57
|
+
return [markdown()];
|
|
58
|
+
case "json":
|
|
59
|
+
return [json()];
|
|
60
|
+
case "js":
|
|
61
|
+
case "ts":
|
|
62
|
+
case "jsx":
|
|
63
|
+
case "tsx":
|
|
64
|
+
return [javascript({ typescript: ext === "ts" || ext === "tsx", jsx: ext === "jsx" || ext === "tsx" })];
|
|
65
|
+
default:
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function buildTree(files) {
|
|
70
|
+
const rootFiles = [];
|
|
71
|
+
const dirMap = /* @__PURE__ */ new Map();
|
|
72
|
+
function ensureDir(dirPath) {
|
|
73
|
+
const existing = dirMap.get(dirPath);
|
|
74
|
+
if (existing) return existing;
|
|
75
|
+
const parts = dirPath.split("/");
|
|
76
|
+
const node = {
|
|
77
|
+
name: parts[parts.length - 1] ?? dirPath,
|
|
78
|
+
fullPath: dirPath,
|
|
79
|
+
children: [],
|
|
80
|
+
files: []
|
|
81
|
+
};
|
|
82
|
+
dirMap.set(dirPath, node);
|
|
83
|
+
if (parts.length > 1) {
|
|
84
|
+
const parentPath = parts.slice(0, -1).join("/");
|
|
85
|
+
const parent = ensureDir(parentPath);
|
|
86
|
+
if (!parent.children.some((c) => c.fullPath === dirPath)) {
|
|
87
|
+
parent.children.push(node);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return node;
|
|
91
|
+
}
|
|
92
|
+
for (const file of files) {
|
|
93
|
+
const slashIdx = file.path.lastIndexOf("/");
|
|
94
|
+
if (slashIdx === -1) {
|
|
95
|
+
rootFiles.push(file);
|
|
96
|
+
} else {
|
|
97
|
+
const dirPath = file.path.slice(0, slashIdx);
|
|
98
|
+
const dir = ensureDir(dirPath);
|
|
99
|
+
dir.files.push(file);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const topLevel = [];
|
|
103
|
+
for (const node of dirMap.values()) {
|
|
104
|
+
if (!node.fullPath.includes("/")) {
|
|
105
|
+
topLevel.push(node);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function sortNode(node) {
|
|
109
|
+
node.children.sort((a, b) => a.name.localeCompare(b.name));
|
|
110
|
+
node.files.sort((a, b) => a.path.localeCompare(b.path));
|
|
111
|
+
node.children.forEach(sortNode);
|
|
112
|
+
}
|
|
113
|
+
topLevel.forEach(sortNode);
|
|
114
|
+
topLevel.sort((a, b) => a.name.localeCompare(b.name));
|
|
115
|
+
rootFiles.sort((a, b) => a.path.localeCompare(b.path));
|
|
116
|
+
return { rootFiles, rootDirs: topLevel };
|
|
117
|
+
}
|
|
118
|
+
function collectAllDirPaths(nodes) {
|
|
119
|
+
const paths = /* @__PURE__ */ new Set();
|
|
120
|
+
function walk(node) {
|
|
121
|
+
paths.add(node.fullPath);
|
|
122
|
+
node.children.forEach(walk);
|
|
123
|
+
}
|
|
124
|
+
nodes.forEach(walk);
|
|
125
|
+
return paths;
|
|
126
|
+
}
|
|
127
|
+
function FileTreeEditor({
|
|
128
|
+
initialFiles,
|
|
129
|
+
onSave,
|
|
130
|
+
onChange,
|
|
131
|
+
readOnly = false,
|
|
132
|
+
hideSave = false,
|
|
133
|
+
title = "Files",
|
|
134
|
+
saveLabel = "Save",
|
|
135
|
+
addFolderLabel = "Folder",
|
|
136
|
+
newFileTemplate = { filename: "SKILL.md", content: "# New\n\nDescribe this...\n" },
|
|
137
|
+
savedVersion
|
|
138
|
+
}) {
|
|
139
|
+
const [files, setFiles] = useState(initialFiles);
|
|
140
|
+
const [selectedPath, setSelectedPath] = useState(
|
|
141
|
+
initialFiles.length > 0 ? initialFiles[0]?.path ?? null : null
|
|
142
|
+
);
|
|
143
|
+
const [saving, setSaving] = useState(false);
|
|
144
|
+
const [expanded, setExpanded] = useState(() => {
|
|
145
|
+
const { rootDirs } = buildTree(initialFiles);
|
|
146
|
+
return collectAllDirPaths(rootDirs);
|
|
147
|
+
});
|
|
148
|
+
const [showAddFolder, setShowAddFolder] = useState(false);
|
|
149
|
+
const [newFolderName, setNewFolderName] = useState("");
|
|
150
|
+
const [addingFileInDir, setAddingFileInDir] = useState(null);
|
|
151
|
+
const [newFileName, setNewFileName] = useState("");
|
|
152
|
+
const [savedSnapshot, setSavedSnapshot] = useState(() => JSON.stringify(initialFiles));
|
|
153
|
+
useEffect(() => {
|
|
154
|
+
const snap = JSON.stringify(initialFiles);
|
|
155
|
+
setSavedSnapshot(snap);
|
|
156
|
+
setFiles(initialFiles);
|
|
157
|
+
const { rootDirs } = buildTree(initialFiles);
|
|
158
|
+
setExpanded(collectAllDirPaths(rootDirs));
|
|
159
|
+
}, [initialFiles]);
|
|
160
|
+
useEffect(() => {
|
|
161
|
+
if (savedVersion !== void 0 && savedVersion > 0) {
|
|
162
|
+
setSavedSnapshot(JSON.stringify(files));
|
|
163
|
+
}
|
|
164
|
+
}, [savedVersion]);
|
|
165
|
+
const onChangeRef = useRef(onChange);
|
|
166
|
+
onChangeRef.current = onChange;
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (onChangeRef.current && JSON.stringify(files) !== savedSnapshot) {
|
|
169
|
+
onChangeRef.current(files);
|
|
170
|
+
}
|
|
171
|
+
}, [files, savedSnapshot]);
|
|
172
|
+
const isDirty = useMemo(
|
|
173
|
+
() => JSON.stringify(files) !== savedSnapshot,
|
|
174
|
+
[files, savedSnapshot]
|
|
175
|
+
);
|
|
176
|
+
const tree = useMemo(() => buildTree(files), [files]);
|
|
177
|
+
const activeFile = useMemo(
|
|
178
|
+
() => selectedPath ? files.find((f) => f.path === selectedPath) ?? null : null,
|
|
179
|
+
[files, selectedPath]
|
|
180
|
+
);
|
|
181
|
+
const handleEditorChange = useCallback((value) => {
|
|
182
|
+
if (readOnly || !selectedPath) return;
|
|
183
|
+
setFiles((prev) => prev.map((f) => f.path === selectedPath ? { ...f, content: value } : f));
|
|
184
|
+
}, [readOnly, selectedPath]);
|
|
185
|
+
function toggleExpand(dirPath) {
|
|
186
|
+
setExpanded((prev) => {
|
|
187
|
+
const next = new Set(prev);
|
|
188
|
+
if (next.has(dirPath)) {
|
|
189
|
+
next.delete(dirPath);
|
|
190
|
+
} else {
|
|
191
|
+
next.add(dirPath);
|
|
192
|
+
}
|
|
193
|
+
return next;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function addFolder() {
|
|
197
|
+
const name = newFolderName.trim();
|
|
198
|
+
if (!name) return;
|
|
199
|
+
const filePath = `${name}/${newFileTemplate.filename}`;
|
|
200
|
+
if (files.some((f) => f.path === filePath)) return;
|
|
201
|
+
const content = newFileTemplate.content.replace("# New", `# ${name}`);
|
|
202
|
+
setFiles((prev) => [...prev, { path: filePath, content }]);
|
|
203
|
+
setSelectedPath(filePath);
|
|
204
|
+
setExpanded((prev) => /* @__PURE__ */ new Set([...prev, name]));
|
|
205
|
+
setNewFolderName("");
|
|
206
|
+
setShowAddFolder(false);
|
|
207
|
+
}
|
|
208
|
+
function removeDir(dirPath) {
|
|
209
|
+
const prefix = dirPath + "/";
|
|
210
|
+
const affectedFiles = files.filter((f) => f.path.startsWith(prefix));
|
|
211
|
+
if (affectedFiles.length === 0) return;
|
|
212
|
+
if (!confirm(`Remove "${dirPath}" and all ${affectedFiles.length} file(s)?`)) return;
|
|
213
|
+
setFiles((prev) => prev.filter((f) => !f.path.startsWith(prefix)));
|
|
214
|
+
if (selectedPath && selectedPath.startsWith(prefix)) {
|
|
215
|
+
setSelectedPath(null);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function removeFile(filePath) {
|
|
219
|
+
const fileName = filePath.split("/").pop() ?? filePath;
|
|
220
|
+
if (!confirm(`Remove file "${fileName}"?`)) return;
|
|
221
|
+
setFiles((prev) => prev.filter((f) => f.path !== filePath));
|
|
222
|
+
if (selectedPath === filePath) {
|
|
223
|
+
setSelectedPath(null);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function addFileInDir(dirPath) {
|
|
227
|
+
const name = newFileName.trim();
|
|
228
|
+
if (!name) return;
|
|
229
|
+
const filePath = dirPath ? `${dirPath}/${name}` : name;
|
|
230
|
+
if (files.some((f) => f.path === filePath)) return;
|
|
231
|
+
setFiles((prev) => [...prev, { path: filePath, content: "" }]);
|
|
232
|
+
setSelectedPath(filePath);
|
|
233
|
+
setNewFileName("");
|
|
234
|
+
setAddingFileInDir(null);
|
|
235
|
+
}
|
|
236
|
+
async function handleSave() {
|
|
237
|
+
setSaving(true);
|
|
238
|
+
try {
|
|
239
|
+
await onSave(files);
|
|
240
|
+
} finally {
|
|
241
|
+
setSaving(false);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function renderTreeNode(node, depth) {
|
|
245
|
+
const isExpanded = expanded.has(node.fullPath);
|
|
246
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
247
|
+
/* @__PURE__ */ jsxs(
|
|
248
|
+
"div",
|
|
249
|
+
{
|
|
250
|
+
className: `flex items-center justify-between cursor-pointer hover:bg-muted/50 py-1 pr-2`,
|
|
251
|
+
style: { paddingLeft: `${depth * 16 + 8}px` },
|
|
252
|
+
onClick: () => toggleExpand(node.fullPath),
|
|
253
|
+
children: [
|
|
254
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium text-xs truncate flex items-center gap-1", children: [
|
|
255
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: isExpanded ? "\u25BE" : "\u25B8" }),
|
|
256
|
+
node.name,
|
|
257
|
+
"/"
|
|
258
|
+
] }),
|
|
259
|
+
!readOnly && /* @__PURE__ */ jsx(
|
|
260
|
+
"button",
|
|
261
|
+
{
|
|
262
|
+
onClick: (e) => {
|
|
263
|
+
e.stopPropagation();
|
|
264
|
+
removeDir(node.fullPath);
|
|
265
|
+
},
|
|
266
|
+
className: "text-muted-foreground hover:text-destructive text-xs ml-1 shrink-0",
|
|
267
|
+
children: "\xD7"
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
),
|
|
273
|
+
isExpanded && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
274
|
+
node.children.map((child) => renderTreeNode(child, depth + 1)),
|
|
275
|
+
node.files.map((file) => {
|
|
276
|
+
const fileName = file.path.split("/").pop() ?? file.path;
|
|
277
|
+
return /* @__PURE__ */ jsxs(
|
|
278
|
+
"div",
|
|
279
|
+
{
|
|
280
|
+
className: `flex items-center justify-between cursor-pointer hover:bg-muted/30 py-1 pr-2 ${selectedPath === file.path ? "bg-primary/10 text-primary" : ""}`,
|
|
281
|
+
style: { paddingLeft: `${(depth + 1) * 16 + 8}px` },
|
|
282
|
+
onClick: () => setSelectedPath(file.path),
|
|
283
|
+
children: [
|
|
284
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs truncate", children: fileName }),
|
|
285
|
+
!readOnly && /* @__PURE__ */ jsx(
|
|
286
|
+
"button",
|
|
287
|
+
{
|
|
288
|
+
onClick: (e) => {
|
|
289
|
+
e.stopPropagation();
|
|
290
|
+
removeFile(file.path);
|
|
291
|
+
},
|
|
292
|
+
className: "text-muted-foreground hover:text-destructive text-xs ml-1 shrink-0",
|
|
293
|
+
children: "\xD7"
|
|
294
|
+
}
|
|
295
|
+
)
|
|
296
|
+
]
|
|
297
|
+
},
|
|
298
|
+
file.path
|
|
299
|
+
);
|
|
300
|
+
}),
|
|
301
|
+
!readOnly && /* @__PURE__ */ jsx("div", { style: { paddingLeft: `${(depth + 1) * 16 + 8}px` }, className: "py-1 pr-2", children: addingFileInDir === node.fullPath ? /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
|
|
302
|
+
/* @__PURE__ */ jsx(
|
|
303
|
+
Input,
|
|
304
|
+
{
|
|
305
|
+
value: newFileName,
|
|
306
|
+
onChange: (e) => setNewFileName(e.target.value),
|
|
307
|
+
placeholder: "file.md",
|
|
308
|
+
className: "h-6 text-xs",
|
|
309
|
+
onKeyDown: (e) => e.key === "Enter" && addFileInDir(node.fullPath),
|
|
310
|
+
autoFocus: true
|
|
311
|
+
}
|
|
312
|
+
),
|
|
313
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => addFileInDir(node.fullPath), size: "sm", className: "h-6 text-xs px-2", children: "+" })
|
|
314
|
+
] }) : /* @__PURE__ */ jsx(
|
|
315
|
+
"button",
|
|
316
|
+
{
|
|
317
|
+
onClick: () => {
|
|
318
|
+
setAddingFileInDir(node.fullPath);
|
|
319
|
+
setNewFileName("");
|
|
320
|
+
},
|
|
321
|
+
className: "text-xs text-primary hover:underline",
|
|
322
|
+
children: "+ File"
|
|
323
|
+
}
|
|
324
|
+
) })
|
|
325
|
+
] })
|
|
326
|
+
] }, node.fullPath);
|
|
327
|
+
}
|
|
328
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
329
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
|
|
330
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
331
|
+
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: title }),
|
|
332
|
+
isDirty && !readOnly && /* @__PURE__ */ jsx(Badge, { variant: "destructive", className: "text-xs", children: "Unsaved changes" }),
|
|
333
|
+
readOnly && /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: "Read-only" })
|
|
334
|
+
] }),
|
|
335
|
+
!readOnly && !hideSave && /* @__PURE__ */ jsx(Button, { onClick: handleSave, disabled: saving || !isDirty, size: "sm", children: saving ? "Saving..." : saveLabel })
|
|
336
|
+
] }),
|
|
337
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "flex gap-4 min-h-[500px]", children: [
|
|
338
|
+
/* @__PURE__ */ jsxs("div", { className: "w-64 shrink-0 border border-border rounded-md overflow-hidden", children: [
|
|
339
|
+
/* @__PURE__ */ jsxs("div", { className: "p-2 bg-muted/50 border-b border-border flex items-center justify-between", children: [
|
|
340
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: title }),
|
|
341
|
+
!readOnly && /* @__PURE__ */ jsxs(
|
|
342
|
+
"button",
|
|
343
|
+
{
|
|
344
|
+
onClick: () => setShowAddFolder(!showAddFolder),
|
|
345
|
+
className: "text-xs text-primary hover:underline",
|
|
346
|
+
children: [
|
|
347
|
+
"+ ",
|
|
348
|
+
addFolderLabel
|
|
349
|
+
]
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
] }),
|
|
353
|
+
showAddFolder && !readOnly && /* @__PURE__ */ jsxs("div", { className: "p-2 border-b border-border flex gap-1", children: [
|
|
354
|
+
/* @__PURE__ */ jsx(
|
|
355
|
+
Input,
|
|
356
|
+
{
|
|
357
|
+
value: newFolderName,
|
|
358
|
+
onChange: (e) => setNewFolderName(e.target.value),
|
|
359
|
+
placeholder: "folder-name",
|
|
360
|
+
className: "h-7 text-xs",
|
|
361
|
+
onKeyDown: (e) => e.key === "Enter" && addFolder(),
|
|
362
|
+
autoFocus: true
|
|
363
|
+
}
|
|
364
|
+
),
|
|
365
|
+
/* @__PURE__ */ jsx(Button, { onClick: addFolder, size: "sm", className: "h-7 text-xs px-2", children: "Add" })
|
|
366
|
+
] }),
|
|
367
|
+
/* @__PURE__ */ jsxs("div", { className: "text-sm overflow-y-auto", children: [
|
|
368
|
+
tree.rootFiles.map((file) => /* @__PURE__ */ jsxs(
|
|
369
|
+
"div",
|
|
370
|
+
{
|
|
371
|
+
className: `flex items-center justify-between cursor-pointer hover:bg-muted/30 py-1 pr-2 ${selectedPath === file.path ? "bg-primary/10 text-primary" : ""}`,
|
|
372
|
+
style: { paddingLeft: "8px" },
|
|
373
|
+
onClick: () => setSelectedPath(file.path),
|
|
374
|
+
children: [
|
|
375
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs truncate", children: file.path }),
|
|
376
|
+
!readOnly && /* @__PURE__ */ jsx(
|
|
377
|
+
"button",
|
|
378
|
+
{
|
|
379
|
+
onClick: (e) => {
|
|
380
|
+
e.stopPropagation();
|
|
381
|
+
removeFile(file.path);
|
|
382
|
+
},
|
|
383
|
+
className: "text-muted-foreground hover:text-destructive text-xs ml-1 shrink-0",
|
|
384
|
+
children: "\xD7"
|
|
385
|
+
}
|
|
386
|
+
)
|
|
387
|
+
]
|
|
388
|
+
},
|
|
389
|
+
file.path
|
|
390
|
+
)),
|
|
391
|
+
tree.rootDirs.map((node) => renderTreeNode(node, 0)),
|
|
392
|
+
files.length === 0 && /* @__PURE__ */ jsx("p", { className: "p-3 text-xs text-muted-foreground", children: readOnly ? "No files." : `No ${title.toLowerCase()} yet. Add a ${addFolderLabel.toLowerCase()} to get started.` })
|
|
393
|
+
] })
|
|
394
|
+
] }),
|
|
395
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 border border-border rounded-md overflow-hidden", children: activeFile ? /* @__PURE__ */ jsxs("div", { className: "h-full flex flex-col", children: [
|
|
396
|
+
/* @__PURE__ */ jsx("div", { className: "px-3 py-1.5 bg-muted/50 border-b border-border text-xs text-muted-foreground", children: activeFile.path }),
|
|
397
|
+
/* @__PURE__ */ jsx(
|
|
398
|
+
CodeMirror,
|
|
399
|
+
{
|
|
400
|
+
value: activeFile.content,
|
|
401
|
+
onChange: handleEditorChange,
|
|
402
|
+
readOnly,
|
|
403
|
+
theme: oneDark,
|
|
404
|
+
extensions: getLanguageExtension(activeFile.path),
|
|
405
|
+
height: "100%",
|
|
406
|
+
className: "flex-1 overflow-auto",
|
|
407
|
+
basicSetup: {
|
|
408
|
+
lineNumbers: true,
|
|
409
|
+
foldGutter: true,
|
|
410
|
+
bracketMatching: true
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
)
|
|
414
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: [
|
|
415
|
+
"Select a file to ",
|
|
416
|
+
readOnly ? "view" : "edit"
|
|
417
|
+
] }) })
|
|
418
|
+
] }) })
|
|
419
|
+
] });
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export { Card, CardContent, CardDescription, CardHeader, CardTitle, FileTreeEditor, Skeleton, useApi };
|