@cisri/json-schema-editor 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +303 -538
- package/dist/json-schema-editor.d.ts +1 -9
- package/dist/json-schema-editor.d.ts.map +1 -1
- package/dist/schema-utils.d.ts +24 -0
- package/dist/schema-utils.d.ts.map +1 -0
- package/package.json +16 -30
- package/dist/ui/button.d.ts +0 -12
- package/dist/ui/button.d.ts.map +0 -1
- package/dist/ui/checkbox.d.ts +0 -5
- package/dist/ui/checkbox.d.ts.map +0 -1
- package/dist/ui/input.d.ts +0 -6
- package/dist/ui/input.d.ts.map +0 -1
- package/dist/ui/select.d.ts +0 -10
- package/dist/ui/select.d.ts.map +0 -1
- package/dist/ui/table.d.ts +0 -11
- package/dist/ui/table.d.ts.map +0 -1
- package/dist/ui/textarea.d.ts +0 -6
- package/dist/ui/textarea.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,425 +1,188 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const Ie = Se(
|
|
11
|
-
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
|
|
12
|
-
{
|
|
13
|
-
variants: {
|
|
14
|
-
variant: {
|
|
15
|
-
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
16
|
-
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
17
|
-
outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
18
|
-
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
19
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
20
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
21
|
-
},
|
|
22
|
-
size: {
|
|
23
|
-
default: "h-9 px-4 py-2",
|
|
24
|
-
sm: "h-8 rounded-md px-3 text-xs",
|
|
25
|
-
lg: "h-10 rounded-md px-8",
|
|
26
|
-
icon: "h-9 w-9"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
defaultVariants: {
|
|
30
|
-
variant: "default",
|
|
31
|
-
size: "default"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
), w = h.forwardRef(
|
|
35
|
-
({ className: e, variant: r, size: t, asChild: a = !1, ...o }, c) => /* @__PURE__ */ n(
|
|
36
|
-
a ? ve : "button",
|
|
37
|
-
{
|
|
38
|
-
className: d(Ie({ variant: r, size: t, className: e })),
|
|
39
|
-
ref: c,
|
|
40
|
-
...o
|
|
41
|
-
}
|
|
42
|
-
)
|
|
43
|
-
);
|
|
44
|
-
w.displayName = "Button";
|
|
45
|
-
const W = h.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ n(
|
|
46
|
-
P.Root,
|
|
47
|
-
{
|
|
48
|
-
ref: t,
|
|
49
|
-
className: d(
|
|
50
|
-
"peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
51
|
-
e
|
|
52
|
-
),
|
|
53
|
-
...r,
|
|
54
|
-
children: /* @__PURE__ */ n(
|
|
55
|
-
P.Indicator,
|
|
56
|
-
{
|
|
57
|
-
className: d("flex items-center justify-center text-current"),
|
|
58
|
-
children: /* @__PURE__ */ n(G, { className: "h-4 w-4" })
|
|
59
|
-
}
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
));
|
|
63
|
-
W.displayName = P.Root.displayName;
|
|
64
|
-
const H = h.forwardRef(
|
|
65
|
-
({ className: e, type: r, ...t }, a) => /* @__PURE__ */ n(
|
|
66
|
-
"input",
|
|
67
|
-
{
|
|
68
|
-
type: r,
|
|
69
|
-
className: d(
|
|
70
|
-
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
71
|
-
e
|
|
72
|
-
),
|
|
73
|
-
ref: a,
|
|
74
|
-
...t
|
|
75
|
-
}
|
|
76
|
-
)
|
|
77
|
-
);
|
|
78
|
-
H.displayName = "Input";
|
|
79
|
-
const Ae = f.Root, Fe = f.Value, X = h.forwardRef(({ className: e, children: r, ...t }, a) => /* @__PURE__ */ p(
|
|
80
|
-
f.Trigger,
|
|
81
|
-
{
|
|
82
|
-
ref: a,
|
|
83
|
-
className: d(
|
|
84
|
-
"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span>]:line-clamp-1",
|
|
85
|
-
e
|
|
86
|
-
),
|
|
87
|
-
...t,
|
|
88
|
-
children: [
|
|
89
|
-
r,
|
|
90
|
-
/* @__PURE__ */ n(f.Icon, { asChild: !0, children: /* @__PURE__ */ n(Q, { className: "h-4 w-4 opacity-50" }) })
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
));
|
|
94
|
-
X.displayName = f.Trigger.displayName;
|
|
95
|
-
const Z = h.forwardRef(({ className: e, children: r, position: t = "popper", ...a }, o) => /* @__PURE__ */ n(f.Portal, { children: /* @__PURE__ */ n(
|
|
96
|
-
f.Content,
|
|
97
|
-
{
|
|
98
|
-
ref: o,
|
|
99
|
-
className: d(
|
|
100
|
-
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
101
|
-
t === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
102
|
-
e
|
|
103
|
-
),
|
|
104
|
-
position: t,
|
|
105
|
-
...a,
|
|
106
|
-
children: /* @__PURE__ */ n(
|
|
107
|
-
f.Viewport,
|
|
108
|
-
{
|
|
109
|
-
className: d(
|
|
110
|
-
"p-1",
|
|
111
|
-
t === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
|
112
|
-
),
|
|
113
|
-
children: r
|
|
114
|
-
}
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
) }));
|
|
118
|
-
Z.displayName = f.Content.displayName;
|
|
119
|
-
const ee = h.forwardRef(({ className: e, children: r, ...t }, a) => /* @__PURE__ */ p(
|
|
120
|
-
f.Item,
|
|
121
|
-
{
|
|
122
|
-
ref: a,
|
|
123
|
-
className: d(
|
|
124
|
-
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
125
|
-
e
|
|
126
|
-
),
|
|
127
|
-
...t,
|
|
128
|
-
children: [
|
|
129
|
-
/* @__PURE__ */ n("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ n(f.ItemIndicator, { children: /* @__PURE__ */ n(G, { className: "h-4 w-4" }) }) }),
|
|
130
|
-
/* @__PURE__ */ n(f.ItemText, { children: r })
|
|
131
|
-
]
|
|
132
|
-
}
|
|
133
|
-
));
|
|
134
|
-
ee.displayName = f.Item.displayName;
|
|
135
|
-
const te = h.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ n("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ n(
|
|
136
|
-
"table",
|
|
137
|
-
{
|
|
138
|
-
ref: t,
|
|
139
|
-
className: d("w-full caption-bottom text-sm", e),
|
|
140
|
-
...r
|
|
141
|
-
}
|
|
142
|
-
) }));
|
|
143
|
-
te.displayName = "Table";
|
|
144
|
-
const re = h.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ n("thead", { ref: t, className: d("[&_tr]:border-b", e), ...r }));
|
|
145
|
-
re.displayName = "TableHeader";
|
|
146
|
-
const ne = h.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ n(
|
|
147
|
-
"tbody",
|
|
148
|
-
{
|
|
149
|
-
ref: t,
|
|
150
|
-
className: d("[&_tr:last-child]:border-0", e),
|
|
151
|
-
...r
|
|
152
|
-
}
|
|
153
|
-
));
|
|
154
|
-
ne.displayName = "TableBody";
|
|
155
|
-
const qe = h.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ n(
|
|
156
|
-
"tfoot",
|
|
157
|
-
{
|
|
158
|
-
ref: t,
|
|
159
|
-
className: d(
|
|
160
|
-
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
|
|
161
|
-
e
|
|
162
|
-
),
|
|
163
|
-
...r
|
|
164
|
-
}
|
|
165
|
-
));
|
|
166
|
-
qe.displayName = "TableFooter";
|
|
167
|
-
const U = h.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ n(
|
|
168
|
-
"tr",
|
|
169
|
-
{
|
|
170
|
-
ref: t,
|
|
171
|
-
className: d(
|
|
172
|
-
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
173
|
-
e
|
|
174
|
-
),
|
|
175
|
-
...r
|
|
176
|
-
}
|
|
177
|
-
));
|
|
178
|
-
U.displayName = "TableRow";
|
|
179
|
-
const T = h.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ n(
|
|
180
|
-
"th",
|
|
181
|
-
{
|
|
182
|
-
ref: t,
|
|
183
|
-
className: d(
|
|
184
|
-
"h-9 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
|
185
|
-
e
|
|
186
|
-
),
|
|
187
|
-
...r
|
|
188
|
-
}
|
|
189
|
-
));
|
|
190
|
-
T.displayName = "TableHead";
|
|
191
|
-
const k = h.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ n(
|
|
192
|
-
"td",
|
|
193
|
-
{
|
|
194
|
-
ref: t,
|
|
195
|
-
className: d(
|
|
196
|
-
"p-2 align-middle [&:has([role=checkbox])]:pr-0",
|
|
197
|
-
e
|
|
198
|
-
),
|
|
199
|
-
...r
|
|
200
|
-
}
|
|
201
|
-
));
|
|
202
|
-
k.displayName = "TableCell";
|
|
203
|
-
const Je = h.forwardRef(({ className: e, ...r }, t) => /* @__PURE__ */ n(
|
|
204
|
-
"caption",
|
|
205
|
-
{
|
|
206
|
-
ref: t,
|
|
207
|
-
className: d("mt-4 text-sm text-muted-foreground", e),
|
|
208
|
-
...r
|
|
209
|
-
}
|
|
210
|
-
));
|
|
211
|
-
Je.displayName = "TableCaption";
|
|
212
|
-
const _ = h.forwardRef(
|
|
213
|
-
({ className: e, ...r }, t) => /* @__PURE__ */ n(
|
|
214
|
-
"textarea",
|
|
215
|
-
{
|
|
216
|
-
className: d(
|
|
217
|
-
"flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
218
|
-
e
|
|
219
|
-
),
|
|
220
|
-
ref: t,
|
|
221
|
-
...r
|
|
222
|
-
}
|
|
223
|
-
)
|
|
224
|
-
);
|
|
225
|
-
_.displayName = "Textarea";
|
|
226
|
-
const Ee = [
|
|
227
|
-
"object",
|
|
228
|
-
"array",
|
|
229
|
-
"string",
|
|
230
|
-
"number",
|
|
231
|
-
"integer",
|
|
232
|
-
"boolean"
|
|
233
|
-
];
|
|
234
|
-
let ze = 0;
|
|
235
|
-
function $e() {
|
|
236
|
-
return `sf-${++ze}`;
|
|
1
|
+
import { jsxs as m, jsx as r, Fragment as D } from "react/jsx-runtime";
|
|
2
|
+
import { useState as v, useRef as M, useEffect as A, useMemo as de, useCallback as y } from "react";
|
|
3
|
+
import { Button as x, Textarea as P, Table as le, TableHeader as ue, TableRow as K, TableHead as T, TableBody as he, TableCell as C, Input as U, Checkbox as pe, Select as me, SelectTrigger as be, SelectValue as ye, SelectContent as xe, SelectItem as ge } from "@cisri/shadcn";
|
|
4
|
+
import { cn as S } from "@cisri/core";
|
|
5
|
+
import { Undo2 as fe, Redo2 as we, ChevronDown as Ne, Minus as Se, Plus as je, Trash2 as ve } from "lucide-react";
|
|
6
|
+
import { generateSampleData as H } from "@cisri/json-schema-core";
|
|
7
|
+
let Te = 0;
|
|
8
|
+
function Ce() {
|
|
9
|
+
return `sf-${++Te}`;
|
|
237
10
|
}
|
|
238
|
-
function
|
|
239
|
-
return e === "object" ? [
|
|
11
|
+
function ke(e) {
|
|
12
|
+
return e === "object" ? [f("field1", { type: "string" }, /* @__PURE__ */ new Set())] : e === "array" ? [f("ITEMS", { type: "string" }, /* @__PURE__ */ new Set(), !0)] : [];
|
|
240
13
|
}
|
|
241
|
-
function
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
const
|
|
245
|
-
for (const [
|
|
246
|
-
|
|
247
|
-
} else
|
|
14
|
+
function f(e, t, n, i = !1, o = !1) {
|
|
15
|
+
const a = t.type ?? "object", l = [];
|
|
16
|
+
if (a === "object" && t.properties) {
|
|
17
|
+
const u = new Set(t.required ?? []);
|
|
18
|
+
for (const [p, h] of Object.entries(t.properties))
|
|
19
|
+
l.push(f(p, h, u));
|
|
20
|
+
} else a === "array" && t.items && l.push(f("ITEMS", t.items, /* @__PURE__ */ new Set(), !0));
|
|
248
21
|
return {
|
|
249
|
-
id:
|
|
22
|
+
id: Ce(),
|
|
250
23
|
name: e,
|
|
251
|
-
type:
|
|
252
|
-
required:
|
|
253
|
-
description:
|
|
254
|
-
schema:
|
|
255
|
-
children:
|
|
24
|
+
type: a,
|
|
25
|
+
required: n.has(e),
|
|
26
|
+
description: t.description,
|
|
27
|
+
schema: t,
|
|
28
|
+
children: l,
|
|
256
29
|
expanded: !0,
|
|
257
|
-
isArrayItem:
|
|
30
|
+
isArrayItem: i,
|
|
31
|
+
isRoot: o
|
|
258
32
|
};
|
|
259
33
|
}
|
|
260
|
-
function
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const t = new Set(e.required ?? []);
|
|
264
|
-
return Object.entries(e.properties).map(
|
|
265
|
-
([a, o]) => v(a, o, t)
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
function Oe() {
|
|
269
|
-
return v("", { type: "string" }, /* @__PURE__ */ new Set());
|
|
34
|
+
function O(e) {
|
|
35
|
+
const t = f(e.title ?? "", e, /* @__PURE__ */ new Set(), !1, !0);
|
|
36
|
+
return t.type === "object" && t.children.length === 0 && t.children.push(f("field1", { type: "string" }, /* @__PURE__ */ new Set())), [t];
|
|
270
37
|
}
|
|
271
|
-
function
|
|
272
|
-
return
|
|
38
|
+
function Ie() {
|
|
39
|
+
return f("", { type: "string" }, /* @__PURE__ */ new Set());
|
|
273
40
|
}
|
|
274
|
-
function
|
|
275
|
-
|
|
276
|
-
case "string":
|
|
277
|
-
return "string";
|
|
278
|
-
case "number":
|
|
279
|
-
case "integer":
|
|
280
|
-
return 0;
|
|
281
|
-
case "boolean":
|
|
282
|
-
return !0;
|
|
283
|
-
case "object": {
|
|
284
|
-
const r = {};
|
|
285
|
-
if (e.properties)
|
|
286
|
-
for (const [t, a] of Object.entries(e.properties))
|
|
287
|
-
r[t] = J(a);
|
|
288
|
-
return r;
|
|
289
|
-
}
|
|
290
|
-
case "array":
|
|
291
|
-
return e.items ? [J(e.items)] : [];
|
|
292
|
-
default:
|
|
293
|
-
return null;
|
|
294
|
-
}
|
|
41
|
+
function F(e) {
|
|
42
|
+
return e.length > 0 ? e : [Ie()];
|
|
295
43
|
}
|
|
296
44
|
function R(e) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return {
|
|
301
|
-
type: "object",
|
|
302
|
-
properties: r,
|
|
303
|
-
required: t.length > 0 ? t : void 0
|
|
304
|
-
};
|
|
45
|
+
if (e.length !== 1 || !e[0].isRoot)
|
|
46
|
+
throw new Error("fieldsToSchema expects exactly one root field");
|
|
47
|
+
return V(e[0]);
|
|
305
48
|
}
|
|
306
|
-
function
|
|
307
|
-
const
|
|
49
|
+
function V(e) {
|
|
50
|
+
const t = { ...e.schema };
|
|
308
51
|
if (e.type === "object") {
|
|
309
|
-
const
|
|
52
|
+
const n = Ae(e.children);
|
|
310
53
|
return {
|
|
311
|
-
...
|
|
54
|
+
...t,
|
|
312
55
|
type: e.type,
|
|
56
|
+
title: e.isRoot ? e.name : t.title,
|
|
313
57
|
description: e.description,
|
|
314
|
-
properties:
|
|
315
|
-
required:
|
|
58
|
+
properties: n.properties,
|
|
59
|
+
required: n.required,
|
|
316
60
|
items: void 0
|
|
317
61
|
};
|
|
318
62
|
}
|
|
319
63
|
if (e.type === "array") {
|
|
320
|
-
const
|
|
64
|
+
const n = e.children[0];
|
|
321
65
|
return {
|
|
322
|
-
...
|
|
66
|
+
...t,
|
|
323
67
|
type: e.type,
|
|
68
|
+
title: e.isRoot ? e.name : t.title,
|
|
324
69
|
description: e.description,
|
|
325
|
-
items:
|
|
70
|
+
items: n ? V(n) : { type: "string" },
|
|
326
71
|
properties: void 0,
|
|
327
72
|
required: void 0
|
|
328
73
|
};
|
|
329
74
|
}
|
|
330
75
|
return {
|
|
331
|
-
...
|
|
76
|
+
...t,
|
|
332
77
|
type: e.type,
|
|
78
|
+
title: e.isRoot ? e.name : t.title,
|
|
333
79
|
description: e.description,
|
|
334
80
|
properties: void 0,
|
|
335
81
|
items: void 0,
|
|
336
82
|
required: void 0
|
|
337
83
|
};
|
|
338
84
|
}
|
|
339
|
-
function
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
85
|
+
function Ae(e) {
|
|
86
|
+
const t = {}, n = [];
|
|
87
|
+
for (const i of e)
|
|
88
|
+
t[i.name] = V(i), i.required && n.push(i.name);
|
|
89
|
+
return {
|
|
90
|
+
properties: t,
|
|
91
|
+
required: n.length > 0 ? n : void 0
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const Fe = [
|
|
95
|
+
"object",
|
|
96
|
+
"array",
|
|
97
|
+
"string",
|
|
98
|
+
"number",
|
|
99
|
+
"integer",
|
|
100
|
+
"boolean"
|
|
101
|
+
];
|
|
102
|
+
function _(e, t, n) {
|
|
103
|
+
return e.map((i) => {
|
|
104
|
+
if (i.id === t) {
|
|
105
|
+
const o = { ...i, ...n };
|
|
106
|
+
return n.type && n.type !== i.type && (o.children = ke(n.type)), o;
|
|
344
107
|
}
|
|
345
|
-
return
|
|
346
|
-
...
|
|
347
|
-
children:
|
|
348
|
-
} :
|
|
108
|
+
return i.children.length > 0 ? {
|
|
109
|
+
...i,
|
|
110
|
+
children: _(i.children, t, n)
|
|
111
|
+
} : i;
|
|
349
112
|
});
|
|
350
113
|
}
|
|
351
|
-
function
|
|
352
|
-
const
|
|
353
|
-
if (
|
|
354
|
-
const
|
|
114
|
+
function Y(e, t) {
|
|
115
|
+
const n = e.findIndex((i) => i.id === t);
|
|
116
|
+
if (n !== -1) {
|
|
117
|
+
const i = f(
|
|
355
118
|
`field${e.length + 1}`,
|
|
356
119
|
{ type: "string" },
|
|
357
120
|
/* @__PURE__ */ new Set()
|
|
358
121
|
), o = [...e];
|
|
359
|
-
return o.splice(
|
|
122
|
+
return o.splice(n + 1, 0, i), o;
|
|
360
123
|
}
|
|
361
|
-
for (let
|
|
362
|
-
if (e[
|
|
363
|
-
const o =
|
|
124
|
+
for (let i = 0; i < e.length; i++)
|
|
125
|
+
if (e[i].children.length > 0) {
|
|
126
|
+
const o = Y(e[i].children, t);
|
|
364
127
|
if (o)
|
|
365
128
|
return [
|
|
366
|
-
...e.slice(0,
|
|
367
|
-
{ ...e[
|
|
368
|
-
...e.slice(
|
|
129
|
+
...e.slice(0, i),
|
|
130
|
+
{ ...e[i], children: o },
|
|
131
|
+
...e.slice(i + 1)
|
|
369
132
|
];
|
|
370
133
|
}
|
|
371
134
|
return null;
|
|
372
135
|
}
|
|
373
|
-
function
|
|
374
|
-
return e.filter((
|
|
375
|
-
...
|
|
376
|
-
children:
|
|
136
|
+
function G(e, t) {
|
|
137
|
+
return e.filter((n) => n.id !== t).map((n) => ({
|
|
138
|
+
...n,
|
|
139
|
+
children: G(n.children, t)
|
|
377
140
|
}));
|
|
378
141
|
}
|
|
379
|
-
function
|
|
380
|
-
return e.map((
|
|
381
|
-
...
|
|
382
|
-
children:
|
|
383
|
-
} :
|
|
142
|
+
function Q(e, t) {
|
|
143
|
+
return e.map((n) => n.id === t ? { ...n, expanded: !n.expanded } : n.children.length > 0 ? {
|
|
144
|
+
...n,
|
|
145
|
+
children: Q(n.children, t)
|
|
146
|
+
} : n);
|
|
384
147
|
}
|
|
385
|
-
function E(e,
|
|
386
|
-
if (e ===
|
|
387
|
-
if (typeof e != "object" || typeof
|
|
148
|
+
function E(e, t) {
|
|
149
|
+
if (e === t) return !0;
|
|
150
|
+
if (typeof e != "object" || typeof t != "object" || e == null || t == null)
|
|
388
151
|
return !1;
|
|
389
|
-
const
|
|
390
|
-
if (
|
|
391
|
-
if (
|
|
392
|
-
const
|
|
393
|
-
return
|
|
152
|
+
const n = Array.isArray(e), i = Array.isArray(t);
|
|
153
|
+
if (n !== i) return !1;
|
|
154
|
+
if (n) {
|
|
155
|
+
const p = e, h = t;
|
|
156
|
+
return p.length !== h.length ? !1 : p.every((J, q) => E(J, h[q]));
|
|
394
157
|
}
|
|
395
|
-
const o = e,
|
|
396
|
-
return
|
|
158
|
+
const o = e, a = t, l = Object.keys(o), u = Object.keys(a);
|
|
159
|
+
return l.length !== u.length ? !1 : l.every((p) => E(o[p], a[p]));
|
|
397
160
|
}
|
|
398
|
-
function
|
|
399
|
-
return /* @__PURE__ */
|
|
161
|
+
function Re({ level: e }) {
|
|
162
|
+
return /* @__PURE__ */ r(D, { children: Array.from({ length: e }).map((t, n) => /* @__PURE__ */ r("span", { className: "inline-block w-5 shrink-0" }, n)) });
|
|
400
163
|
}
|
|
401
|
-
function
|
|
164
|
+
function Ee({
|
|
402
165
|
value: e,
|
|
403
|
-
"aria-label":
|
|
404
|
-
disabled:
|
|
405
|
-
onChange:
|
|
166
|
+
"aria-label": t,
|
|
167
|
+
disabled: n,
|
|
168
|
+
onChange: i
|
|
406
169
|
}) {
|
|
407
|
-
return /* @__PURE__ */
|
|
408
|
-
/* @__PURE__ */
|
|
409
|
-
/* @__PURE__ */
|
|
170
|
+
return /* @__PURE__ */ m(me, { value: e, onValueChange: (o) => i(o), disabled: n, children: [
|
|
171
|
+
/* @__PURE__ */ r(be, { "aria-label": t, className: "h-7 w-28 text-xs", children: /* @__PURE__ */ r(ye, {}) }),
|
|
172
|
+
/* @__PURE__ */ r(xe, { children: Fe.map((o) => /* @__PURE__ */ r(ge, { value: o, className: "text-xs", children: o }, o)) })
|
|
410
173
|
] });
|
|
411
174
|
}
|
|
412
|
-
function
|
|
175
|
+
function Je({
|
|
413
176
|
fieldName: e,
|
|
414
|
-
showAdd:
|
|
415
|
-
showDelete:
|
|
416
|
-
disableDelete:
|
|
177
|
+
showAdd: t,
|
|
178
|
+
showDelete: n = !0,
|
|
179
|
+
disableDelete: i,
|
|
417
180
|
onAdd: o,
|
|
418
|
-
onDelete:
|
|
181
|
+
onDelete: a
|
|
419
182
|
}) {
|
|
420
|
-
return /* @__PURE__ */
|
|
421
|
-
|
|
422
|
-
|
|
183
|
+
return /* @__PURE__ */ m("div", { className: "flex items-center justify-end gap-1", children: [
|
|
184
|
+
t && /* @__PURE__ */ r(
|
|
185
|
+
x,
|
|
423
186
|
{
|
|
424
187
|
type: "button",
|
|
425
188
|
variant: "ghost",
|
|
@@ -427,115 +190,115 @@ function De({
|
|
|
427
190
|
className: "h-7 w-7",
|
|
428
191
|
onClick: o,
|
|
429
192
|
"aria-label": `在字段 ${e || "未命名"} 后添加行`,
|
|
430
|
-
children: /* @__PURE__ */
|
|
193
|
+
children: /* @__PURE__ */ r(je, { className: "h-4 w-4" })
|
|
431
194
|
}
|
|
432
195
|
),
|
|
433
|
-
|
|
434
|
-
|
|
196
|
+
n && /* @__PURE__ */ r(
|
|
197
|
+
x,
|
|
435
198
|
{
|
|
436
199
|
type: "button",
|
|
437
200
|
variant: "ghost",
|
|
438
201
|
size: "icon",
|
|
439
202
|
className: "h-7 w-7",
|
|
440
|
-
disabled:
|
|
441
|
-
onClick:
|
|
203
|
+
disabled: i,
|
|
204
|
+
onClick: a,
|
|
442
205
|
"aria-label": `删除字段 ${e || "未命名"}`,
|
|
443
|
-
children: /* @__PURE__ */
|
|
206
|
+
children: /* @__PURE__ */ r(ve, { className: "h-4 w-4 text-destructive" })
|
|
444
207
|
}
|
|
445
208
|
)
|
|
446
209
|
] });
|
|
447
210
|
}
|
|
448
|
-
function
|
|
449
|
-
const
|
|
450
|
-
return /* @__PURE__ */
|
|
451
|
-
/* @__PURE__ */
|
|
452
|
-
/* @__PURE__ */
|
|
453
|
-
/* @__PURE__ */
|
|
454
|
-
|
|
211
|
+
function W({ field: e, level: t, readOnly: n, disableDelete: i, dispatch: o }) {
|
|
212
|
+
const a = e.children.length > 0, l = e.name || "未命名";
|
|
213
|
+
return /* @__PURE__ */ m(D, { children: [
|
|
214
|
+
/* @__PURE__ */ m(K, { className: S(e.isRoot && "bg-muted/30"), children: [
|
|
215
|
+
/* @__PURE__ */ r(C, { children: /* @__PURE__ */ m("div", { className: "flex items-center", children: [
|
|
216
|
+
/* @__PURE__ */ r(Re, { level: t }),
|
|
217
|
+
a ? /* @__PURE__ */ r(
|
|
455
218
|
"button",
|
|
456
219
|
{
|
|
457
220
|
type: "button",
|
|
458
221
|
onClick: () => o({ type: "toggleExpand", id: e.id }),
|
|
459
222
|
className: "mr-1 inline-flex h-3.5 w-3.5 items-center justify-center text-muted-foreground",
|
|
460
223
|
"aria-label": e.expanded ? "折叠" : "展开",
|
|
461
|
-
children: /* @__PURE__ */
|
|
462
|
-
|
|
224
|
+
children: /* @__PURE__ */ r(
|
|
225
|
+
Ne,
|
|
463
226
|
{
|
|
464
|
-
className:
|
|
227
|
+
className: S(
|
|
465
228
|
"h-3.5 w-3.5 transition-transform",
|
|
466
229
|
!e.expanded && "-rotate-90"
|
|
467
230
|
)
|
|
468
231
|
}
|
|
469
232
|
)
|
|
470
233
|
}
|
|
471
|
-
) : /* @__PURE__ */
|
|
472
|
-
/* @__PURE__ */
|
|
473
|
-
|
|
234
|
+
) : /* @__PURE__ */ r(Se, { className: "mr-1 h-3.5 w-3.5 text-muted-foreground/60" }),
|
|
235
|
+
/* @__PURE__ */ r(
|
|
236
|
+
U,
|
|
474
237
|
{
|
|
475
238
|
id: `schema-name-${e.id}`,
|
|
476
239
|
name: `schema-name-${e.id}`,
|
|
477
|
-
"aria-label": `字段 ${
|
|
240
|
+
"aria-label": `字段 ${l} 名称`,
|
|
478
241
|
autoComplete: "off",
|
|
479
|
-
disabled:
|
|
242
|
+
disabled: n || e.isArrayItem,
|
|
480
243
|
className: "h-7 border-transparent bg-transparent px-1 shadow-none focus-visible:bg-background disabled:opacity-100",
|
|
481
244
|
value: e.name,
|
|
482
|
-
onChange: (
|
|
245
|
+
onChange: (u) => o({
|
|
483
246
|
type: "update",
|
|
484
247
|
id: e.id,
|
|
485
|
-
patch: { name:
|
|
248
|
+
patch: { name: u.target.value }
|
|
486
249
|
})
|
|
487
250
|
}
|
|
488
251
|
)
|
|
489
252
|
] }) }),
|
|
490
|
-
/* @__PURE__ */
|
|
491
|
-
|
|
253
|
+
/* @__PURE__ */ r(C, { children: /* @__PURE__ */ r(
|
|
254
|
+
Ee,
|
|
492
255
|
{
|
|
493
256
|
value: e.type,
|
|
494
|
-
"aria-label": `字段 ${
|
|
495
|
-
disabled:
|
|
496
|
-
onChange: (
|
|
257
|
+
"aria-label": `字段 ${l} 类型`,
|
|
258
|
+
disabled: n,
|
|
259
|
+
onChange: (u) => o({ type: "update", id: e.id, patch: { type: u } })
|
|
497
260
|
}
|
|
498
261
|
) }),
|
|
499
|
-
/* @__PURE__ */
|
|
500
|
-
|
|
262
|
+
/* @__PURE__ */ r(C, { children: e.isArrayItem || e.isRoot ? null : /* @__PURE__ */ r(
|
|
263
|
+
pe,
|
|
501
264
|
{
|
|
502
265
|
id: `schema-required-${e.id}`,
|
|
503
266
|
name: `schema-required-${e.id}`,
|
|
504
|
-
"aria-label": `字段 ${
|
|
267
|
+
"aria-label": `字段 ${l} 是否必填`,
|
|
505
268
|
checked: e.required,
|
|
506
|
-
disabled:
|
|
507
|
-
onCheckedChange: (
|
|
269
|
+
disabled: n,
|
|
270
|
+
onCheckedChange: (u) => o({
|
|
508
271
|
type: "update",
|
|
509
272
|
id: e.id,
|
|
510
|
-
patch: { required:
|
|
273
|
+
patch: { required: u === !0 }
|
|
511
274
|
})
|
|
512
275
|
}
|
|
513
276
|
) }),
|
|
514
|
-
/* @__PURE__ */
|
|
515
|
-
|
|
277
|
+
/* @__PURE__ */ r(C, { children: /* @__PURE__ */ r(
|
|
278
|
+
U,
|
|
516
279
|
{
|
|
517
280
|
id: `schema-description-${e.id}`,
|
|
518
281
|
name: `schema-description-${e.id}`,
|
|
519
|
-
"aria-label": `字段 ${
|
|
282
|
+
"aria-label": `字段 ${l} 描述`,
|
|
520
283
|
autoComplete: "off",
|
|
521
|
-
disabled:
|
|
284
|
+
disabled: n,
|
|
522
285
|
className: "h-7 border-transparent bg-transparent px-1 shadow-none focus-visible:bg-background disabled:opacity-100",
|
|
523
286
|
value: e.description ?? "",
|
|
524
|
-
onChange: (
|
|
287
|
+
onChange: (u) => o({
|
|
525
288
|
type: "update",
|
|
526
289
|
id: e.id,
|
|
527
|
-
patch: { description:
|
|
290
|
+
patch: { description: u.target.value }
|
|
528
291
|
})
|
|
529
292
|
}
|
|
530
293
|
) }),
|
|
531
|
-
/* @__PURE__ */
|
|
532
|
-
|
|
294
|
+
/* @__PURE__ */ r(C, { children: !n && !e.isRoot && /* @__PURE__ */ r(
|
|
295
|
+
Je,
|
|
533
296
|
{
|
|
534
297
|
fieldId: e.id,
|
|
535
298
|
fieldName: e.name,
|
|
536
299
|
showAdd: !e.isArrayItem,
|
|
537
300
|
showDelete: !e.isArrayItem,
|
|
538
|
-
disableDelete:
|
|
301
|
+
disableDelete: i,
|
|
539
302
|
onAdd: () => o({
|
|
540
303
|
type: "addSibling",
|
|
541
304
|
id: e.id
|
|
@@ -544,262 +307,264 @@ function ce({ field: e, level: r, readOnly: t, disableDelete: a, dispatch: o })
|
|
|
544
307
|
}
|
|
545
308
|
) })
|
|
546
309
|
] }),
|
|
547
|
-
e.expanded && e.children.map((
|
|
548
|
-
|
|
310
|
+
e.expanded && e.children.map((u) => /* @__PURE__ */ r(
|
|
311
|
+
W,
|
|
549
312
|
{
|
|
550
|
-
field:
|
|
551
|
-
level:
|
|
552
|
-
readOnly:
|
|
313
|
+
field: u,
|
|
314
|
+
level: t + 1,
|
|
315
|
+
readOnly: n,
|
|
553
316
|
disableDelete: e.type === "object" && e.children.length <= 1,
|
|
554
317
|
dispatch: o
|
|
555
318
|
},
|
|
556
|
-
|
|
319
|
+
u.id
|
|
557
320
|
))
|
|
558
321
|
] });
|
|
559
322
|
}
|
|
560
|
-
function
|
|
323
|
+
function De({
|
|
561
324
|
value: e,
|
|
562
|
-
onChange:
|
|
563
|
-
onSave:
|
|
564
|
-
readOnly:
|
|
325
|
+
onChange: t,
|
|
326
|
+
onSave: n,
|
|
327
|
+
readOnly: i,
|
|
565
328
|
className: o
|
|
566
329
|
}) {
|
|
567
|
-
const [
|
|
568
|
-
history: [
|
|
330
|
+
const [a, l] = v(() => ({
|
|
331
|
+
history: [F(O(e))],
|
|
569
332
|
index: 0
|
|
570
|
-
})),
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}, [
|
|
574
|
-
const [
|
|
333
|
+
})), u = a.history[a.index], p = M(a);
|
|
334
|
+
A(() => {
|
|
335
|
+
p.current = a;
|
|
336
|
+
}, [a]);
|
|
337
|
+
const [h, J] = v("table"), [q, k] = v(
|
|
575
338
|
() => JSON.stringify(e, null, 2)
|
|
576
|
-
), [
|
|
577
|
-
|
|
578
|
-
if (!E(e,
|
|
579
|
-
const s =
|
|
580
|
-
|
|
339
|
+
), [L, w] = v(null), [X, $] = v(null), z = M(!1), N = M(e), g = de(() => JSON.stringify(e, null, 2), [e]);
|
|
340
|
+
A(() => {
|
|
341
|
+
if (!E(e, N.current)) {
|
|
342
|
+
const s = F(O(e));
|
|
343
|
+
l({ history: [s], index: 0 }), N.current = e;
|
|
581
344
|
}
|
|
582
|
-
}, [e]),
|
|
583
|
-
|
|
584
|
-
}, [
|
|
585
|
-
|
|
586
|
-
}, [
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
history: [...
|
|
590
|
-
index:
|
|
345
|
+
}, [e]), A(() => {
|
|
346
|
+
z.current || (k(g), w(null));
|
|
347
|
+
}, [g]), A(() => {
|
|
348
|
+
$(null);
|
|
349
|
+
}, [h]);
|
|
350
|
+
const I = y((s) => {
|
|
351
|
+
l((c) => E(c.history[c.index], s) ? c : {
|
|
352
|
+
history: [...c.history.slice(0, c.index + 1), s],
|
|
353
|
+
index: c.index + 1
|
|
591
354
|
});
|
|
592
|
-
}, []),
|
|
355
|
+
}, []), Z = y(
|
|
593
356
|
(s) => {
|
|
594
|
-
const
|
|
595
|
-
|
|
357
|
+
const c = p.current.history[p.current.index], b = c[0];
|
|
358
|
+
if (b && s.id === b.id && (s.type === "delete" || s.type === "addSibling"))
|
|
359
|
+
return;
|
|
360
|
+
let d;
|
|
596
361
|
switch (s.type) {
|
|
597
362
|
case "update":
|
|
598
|
-
|
|
363
|
+
d = _(c, s.id, s.patch);
|
|
599
364
|
break;
|
|
600
365
|
case "addSibling":
|
|
601
|
-
|
|
366
|
+
d = Y(c, s.id) ?? c;
|
|
602
367
|
break;
|
|
603
368
|
case "delete":
|
|
604
|
-
|
|
369
|
+
d = G(c, s.id);
|
|
605
370
|
break;
|
|
606
371
|
case "toggleExpand":
|
|
607
|
-
|
|
372
|
+
d = Q(c, s.id);
|
|
608
373
|
break;
|
|
609
374
|
default:
|
|
610
375
|
return;
|
|
611
376
|
}
|
|
612
|
-
|
|
613
|
-
const
|
|
614
|
-
|
|
377
|
+
d = F(d);
|
|
378
|
+
const j = R(d);
|
|
379
|
+
N.current = j, I(d), t(j);
|
|
615
380
|
},
|
|
616
|
-
[
|
|
617
|
-
),
|
|
618
|
-
const s =
|
|
381
|
+
[t, I]
|
|
382
|
+
), ee = a.index > 0, te = a.index < a.history.length - 1, ne = y(() => {
|
|
383
|
+
const s = p.current;
|
|
619
384
|
if (s.index <= 0) return;
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
}, [
|
|
623
|
-
const s =
|
|
385
|
+
const c = s.index - 1, b = s.history[c], d = R(b);
|
|
386
|
+
l({ ...s, index: c }), N.current = d, t(d);
|
|
387
|
+
}, [t]), re = y(() => {
|
|
388
|
+
const s = p.current;
|
|
624
389
|
if (s.index >= s.history.length - 1) return;
|
|
625
|
-
const
|
|
626
|
-
|
|
627
|
-
}, [
|
|
390
|
+
const c = s.index + 1, b = s.history[c], d = R(b);
|
|
391
|
+
l({ ...s, index: c }), N.current = d, t(d);
|
|
392
|
+
}, [t]), B = y(
|
|
628
393
|
(s) => () => {
|
|
629
|
-
|
|
394
|
+
J(s), s === "json" && (k(g), w(null));
|
|
630
395
|
},
|
|
631
|
-
[
|
|
632
|
-
),
|
|
396
|
+
[g]
|
|
397
|
+
), ie = y(
|
|
633
398
|
(s) => {
|
|
634
|
-
const
|
|
635
|
-
|
|
399
|
+
const c = s.target.value;
|
|
400
|
+
k(c);
|
|
636
401
|
try {
|
|
637
|
-
const
|
|
638
|
-
if (
|
|
639
|
-
const
|
|
640
|
-
|
|
402
|
+
const b = JSON.parse(c);
|
|
403
|
+
if (b && typeof b == "object" && !Array.isArray(b)) {
|
|
404
|
+
const d = F(O(b)), j = R(d);
|
|
405
|
+
N.current = j, I(d), t(j), w(null);
|
|
641
406
|
} else
|
|
642
|
-
|
|
407
|
+
w("请输入有效的 JSON 对象。");
|
|
643
408
|
} catch {
|
|
644
|
-
|
|
409
|
+
w("JSON 解析失败,请检查格式。");
|
|
645
410
|
}
|
|
646
411
|
},
|
|
647
|
-
[
|
|
648
|
-
),
|
|
649
|
-
|
|
650
|
-
}, []),
|
|
651
|
-
|
|
652
|
-
}, [
|
|
412
|
+
[t, I]
|
|
413
|
+
), se = y(() => {
|
|
414
|
+
z.current = !0;
|
|
415
|
+
}, []), oe = y(() => {
|
|
416
|
+
z.current = !1, k(g), w(null);
|
|
417
|
+
}, [g]), ce = y(async () => {
|
|
653
418
|
try {
|
|
654
|
-
let s =
|
|
655
|
-
|
|
419
|
+
let s = g, c = "已复制 json schema";
|
|
420
|
+
h === "preview" && (s = JSON.stringify(H(e), null, 2), c = "已复制 json 示例"), await navigator.clipboard.writeText(s), $(c), window.setTimeout(() => $(null), 1500);
|
|
656
421
|
} catch {
|
|
657
422
|
}
|
|
658
|
-
}, [
|
|
659
|
-
|
|
660
|
-
}, [
|
|
661
|
-
return /* @__PURE__ */
|
|
423
|
+
}, [g, e, h]), ae = y(() => {
|
|
424
|
+
n == null || n(e);
|
|
425
|
+
}, [n, e]);
|
|
426
|
+
return /* @__PURE__ */ m(
|
|
662
427
|
"div",
|
|
663
428
|
{
|
|
664
|
-
className:
|
|
429
|
+
className: S(
|
|
665
430
|
"rounded-md border border-border bg-card text-card-foreground",
|
|
666
431
|
o
|
|
667
432
|
),
|
|
668
433
|
children: [
|
|
669
|
-
/* @__PURE__ */
|
|
670
|
-
/* @__PURE__ */
|
|
671
|
-
/* @__PURE__ */
|
|
672
|
-
|
|
434
|
+
/* @__PURE__ */ m("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border p-2", children: [
|
|
435
|
+
/* @__PURE__ */ m("div", { className: "inline-flex items-center overflow-hidden rounded-md border border-border", children: [
|
|
436
|
+
/* @__PURE__ */ r(
|
|
437
|
+
x,
|
|
673
438
|
{
|
|
674
439
|
type: "button",
|
|
675
440
|
variant: "ghost",
|
|
676
441
|
size: "sm",
|
|
677
|
-
onClick:
|
|
678
|
-
className:
|
|
442
|
+
onClick: B("table"),
|
|
443
|
+
className: S(
|
|
679
444
|
"h-7 rounded-none border-r border-border text-xs",
|
|
680
|
-
|
|
445
|
+
h === "table" && "bg-muted"
|
|
681
446
|
),
|
|
682
447
|
children: "表格视图"
|
|
683
448
|
}
|
|
684
449
|
),
|
|
685
|
-
/* @__PURE__ */
|
|
686
|
-
|
|
450
|
+
/* @__PURE__ */ r(
|
|
451
|
+
x,
|
|
687
452
|
{
|
|
688
453
|
type: "button",
|
|
689
454
|
variant: "ghost",
|
|
690
455
|
size: "sm",
|
|
691
|
-
onClick:
|
|
692
|
-
className:
|
|
456
|
+
onClick: B("json"),
|
|
457
|
+
className: S(
|
|
693
458
|
"h-7 rounded-none border-r border-border text-xs",
|
|
694
|
-
|
|
459
|
+
h === "json" && "bg-muted"
|
|
695
460
|
),
|
|
696
461
|
children: "JSON 视图"
|
|
697
462
|
}
|
|
698
463
|
),
|
|
699
|
-
/* @__PURE__ */
|
|
700
|
-
|
|
464
|
+
/* @__PURE__ */ r(
|
|
465
|
+
x,
|
|
701
466
|
{
|
|
702
467
|
type: "button",
|
|
703
468
|
variant: "ghost",
|
|
704
469
|
size: "sm",
|
|
705
|
-
onClick:
|
|
706
|
-
className:
|
|
470
|
+
onClick: B("preview"),
|
|
471
|
+
className: S(
|
|
707
472
|
"h-7 rounded-none text-xs",
|
|
708
|
-
|
|
473
|
+
h === "preview" && "bg-muted"
|
|
709
474
|
),
|
|
710
475
|
children: "预览"
|
|
711
476
|
}
|
|
712
477
|
)
|
|
713
478
|
] }),
|
|
714
|
-
/* @__PURE__ */
|
|
715
|
-
!
|
|
716
|
-
|
|
479
|
+
/* @__PURE__ */ m("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
480
|
+
!i && n && /* @__PURE__ */ r(
|
|
481
|
+
x,
|
|
717
482
|
{
|
|
718
483
|
type: "button",
|
|
719
484
|
size: "sm",
|
|
720
|
-
onClick:
|
|
485
|
+
onClick: ae,
|
|
721
486
|
className: "h-7 text-xs",
|
|
722
487
|
children: "保存"
|
|
723
488
|
}
|
|
724
489
|
),
|
|
725
|
-
|
|
726
|
-
|
|
490
|
+
h !== "table" && /* @__PURE__ */ r(
|
|
491
|
+
x,
|
|
727
492
|
{
|
|
728
493
|
type: "button",
|
|
729
494
|
variant: "outline",
|
|
730
495
|
size: "sm",
|
|
731
|
-
onClick:
|
|
496
|
+
onClick: ce,
|
|
732
497
|
className: "h-7 text-xs",
|
|
733
|
-
children:
|
|
498
|
+
children: X ?? "复制"
|
|
734
499
|
}
|
|
735
500
|
),
|
|
736
|
-
!
|
|
737
|
-
/* @__PURE__ */
|
|
738
|
-
|
|
501
|
+
!i && /* @__PURE__ */ m(D, { children: [
|
|
502
|
+
/* @__PURE__ */ r(
|
|
503
|
+
x,
|
|
739
504
|
{
|
|
740
505
|
type: "button",
|
|
741
506
|
variant: "ghost",
|
|
742
507
|
size: "icon",
|
|
743
|
-
onClick:
|
|
744
|
-
disabled: !
|
|
508
|
+
onClick: ne,
|
|
509
|
+
disabled: !ee,
|
|
745
510
|
className: "h-7 w-7",
|
|
746
511
|
"aria-label": "撤销",
|
|
747
|
-
children: /* @__PURE__ */
|
|
512
|
+
children: /* @__PURE__ */ r(fe, { className: "h-4 w-4" })
|
|
748
513
|
}
|
|
749
514
|
),
|
|
750
|
-
/* @__PURE__ */
|
|
751
|
-
|
|
515
|
+
/* @__PURE__ */ r(
|
|
516
|
+
x,
|
|
752
517
|
{
|
|
753
518
|
type: "button",
|
|
754
519
|
variant: "ghost",
|
|
755
520
|
size: "icon",
|
|
756
|
-
onClick:
|
|
757
|
-
disabled: !
|
|
521
|
+
onClick: re,
|
|
522
|
+
disabled: !te,
|
|
758
523
|
className: "h-7 w-7",
|
|
759
524
|
"aria-label": "恢复",
|
|
760
|
-
children: /* @__PURE__ */
|
|
525
|
+
children: /* @__PURE__ */ r(we, { className: "h-4 w-4" })
|
|
761
526
|
}
|
|
762
527
|
)
|
|
763
528
|
] })
|
|
764
529
|
] })
|
|
765
530
|
] }),
|
|
766
|
-
|
|
767
|
-
/* @__PURE__ */
|
|
768
|
-
|
|
531
|
+
h === "json" ? /* @__PURE__ */ m("div", { className: "space-y-2 p-2", children: [
|
|
532
|
+
/* @__PURE__ */ r(
|
|
533
|
+
P,
|
|
769
534
|
{
|
|
770
|
-
value:
|
|
771
|
-
onChange:
|
|
772
|
-
onFocus:
|
|
773
|
-
onBlur:
|
|
774
|
-
readOnly:
|
|
535
|
+
value: q,
|
|
536
|
+
onChange: i ? void 0 : ie,
|
|
537
|
+
onFocus: i ? void 0 : se,
|
|
538
|
+
onBlur: i ? void 0 : oe,
|
|
539
|
+
readOnly: i,
|
|
775
540
|
placeholder: "在此编辑或粘贴 JSON Schema...",
|
|
776
541
|
className: "min-h-[320px] font-mono text-xs"
|
|
777
542
|
}
|
|
778
543
|
),
|
|
779
|
-
|
|
780
|
-
] }) :
|
|
781
|
-
|
|
544
|
+
L && /* @__PURE__ */ r("p", { className: "text-xs text-destructive", children: L })
|
|
545
|
+
] }) : h === "preview" ? /* @__PURE__ */ r("div", { className: "p-2", children: /* @__PURE__ */ r(
|
|
546
|
+
P,
|
|
782
547
|
{
|
|
783
|
-
value: JSON.stringify(
|
|
548
|
+
value: JSON.stringify(H(e), null, 2),
|
|
784
549
|
readOnly: !0,
|
|
785
550
|
className: "min-h-[320px] font-mono text-xs"
|
|
786
551
|
}
|
|
787
|
-
) }) : /* @__PURE__ */
|
|
788
|
-
/* @__PURE__ */
|
|
789
|
-
/* @__PURE__ */
|
|
790
|
-
/* @__PURE__ */
|
|
791
|
-
/* @__PURE__ */
|
|
792
|
-
/* @__PURE__ */
|
|
793
|
-
/* @__PURE__ */
|
|
552
|
+
) }) : /* @__PURE__ */ m(le, { children: [
|
|
553
|
+
/* @__PURE__ */ r(ue, { children: /* @__PURE__ */ m(K, { children: [
|
|
554
|
+
/* @__PURE__ */ r(T, { className: "w-[28%]", children: "名称" }),
|
|
555
|
+
/* @__PURE__ */ r(T, { className: "w-[18%]", children: "类型" }),
|
|
556
|
+
/* @__PURE__ */ r(T, { className: "w-[12%]", children: "必填" }),
|
|
557
|
+
/* @__PURE__ */ r(T, { className: "w-[30%]", children: "描述" }),
|
|
558
|
+
/* @__PURE__ */ r(T, { className: "w-[12%]" })
|
|
794
559
|
] }) }),
|
|
795
|
-
/* @__PURE__ */
|
|
796
|
-
|
|
560
|
+
/* @__PURE__ */ r(he, { children: u.map((s) => /* @__PURE__ */ r(
|
|
561
|
+
W,
|
|
797
562
|
{
|
|
798
563
|
field: s,
|
|
799
564
|
level: 0,
|
|
800
|
-
readOnly:
|
|
801
|
-
disableDelete:
|
|
802
|
-
dispatch:
|
|
565
|
+
readOnly: i,
|
|
566
|
+
disableDelete: !0,
|
|
567
|
+
dispatch: Z
|
|
803
568
|
},
|
|
804
569
|
s.id
|
|
805
570
|
)) })
|
|
@@ -809,5 +574,5 @@ function Ye({
|
|
|
809
574
|
);
|
|
810
575
|
}
|
|
811
576
|
export {
|
|
812
|
-
|
|
577
|
+
De as JsonSchemaEditor
|
|
813
578
|
};
|