json-schema-builder-react 0.0.8 → 0.0.9
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-lib/components/JsonSchemaBuilder.d.ts +1 -1
- package/dist-lib/components/PropertyDocument.d.ts +1 -3
- package/dist-lib/components/PropertyEditDialog.d.ts +2 -2
- package/dist-lib/contexts/SchemaBuilderContext.d.ts +31 -0
- package/dist-lib/hooks/usePropertyEditor.d.ts +2 -2
- package/dist-lib/index.cjs +1 -2
- package/dist-lib/index.d.ts +1 -1
- package/dist-lib/index.js +597 -593
- package/dist-lib/lib/file-utils.d.ts +2 -2
- package/package.json +1 -1
- package/dist-lib/index.cjs.map +0 -1
- package/dist-lib/index.js.map +0 -1
package/dist-lib/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsx as e, jsxs as s, Fragment as
|
|
2
|
-
import * as
|
|
3
|
-
import { useContext as
|
|
4
|
-
import { Slot as
|
|
5
|
-
import { cva as
|
|
6
|
-
import { clsx as
|
|
7
|
-
import { twMerge as
|
|
8
|
-
import { ChevronDown as
|
|
1
|
+
import { jsx as e, jsxs as s, Fragment as me } from "react/jsx-runtime";
|
|
2
|
+
import * as x from "react";
|
|
3
|
+
import { useContext as Ee, createContext as Re, useState as q, useEffect as ae, useMemo as Le, useCallback as P } from "react";
|
|
4
|
+
import { Slot as je } from "@radix-ui/react-slot";
|
|
5
|
+
import { cva as ue } from "class-variance-authority";
|
|
6
|
+
import { clsx as qe } from "clsx";
|
|
7
|
+
import { twMerge as Oe } from "tailwind-merge";
|
|
8
|
+
import { ChevronDown as ie, Check as he, ChevronUp as Pe, X as Fe, Asterisk as oe, Type as ze, Hash as de, CheckSquare as Be, Braces as Ae, List as Me, FileText as $e, Plus as B, Pencil as Ke, Trash2 as fe, CheckCircle2 as Je, Copy as Ve, Download as He, ChevronRight as _e, Moon as Ue, Sun as Xe, Upload as Ge } from "lucide-react";
|
|
9
9
|
import * as F from "@radix-ui/react-tooltip";
|
|
10
10
|
import * as w from "@radix-ui/react-select";
|
|
11
11
|
import * as L from "@radix-ui/react-dialog";
|
|
12
|
-
import * as
|
|
13
|
-
import * as
|
|
12
|
+
import * as pe from "@radix-ui/react-label";
|
|
13
|
+
import * as U from "@radix-ui/react-checkbox";
|
|
14
14
|
function h(...t) {
|
|
15
|
-
return qe(
|
|
15
|
+
return Oe(qe(t));
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const Qe = ue(
|
|
18
18
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full 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 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
19
19
|
{
|
|
20
20
|
variants: {
|
|
@@ -38,18 +38,18 @@ const _e = oe(
|
|
|
38
38
|
size: "default"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
),
|
|
42
|
-
({ className: t, variant: i, size: a, asChild: l = !1, ...n },
|
|
43
|
-
l ?
|
|
41
|
+
), S = x.forwardRef(
|
|
42
|
+
({ className: t, variant: i, size: a, asChild: l = !1, ...n }, o) => /* @__PURE__ */ e(
|
|
43
|
+
l ? je : "button",
|
|
44
44
|
{
|
|
45
|
-
className: h(
|
|
46
|
-
ref:
|
|
45
|
+
className: h(Qe({ variant: i, size: a, className: t })),
|
|
46
|
+
ref: o,
|
|
47
47
|
...n
|
|
48
48
|
}
|
|
49
49
|
)
|
|
50
50
|
);
|
|
51
|
-
|
|
52
|
-
const
|
|
51
|
+
S.displayName = "Button";
|
|
52
|
+
const T = x.forwardRef(
|
|
53
53
|
({ className: t, type: i, ...a }, l) => /* @__PURE__ */ e(
|
|
54
54
|
"input",
|
|
55
55
|
{
|
|
@@ -63,8 +63,8 @@ const D = b.forwardRef(
|
|
|
63
63
|
}
|
|
64
64
|
)
|
|
65
65
|
);
|
|
66
|
-
|
|
67
|
-
const
|
|
66
|
+
T.displayName = "Input";
|
|
67
|
+
const We = F.Provider, Ye = F.Root, Ze = F.Trigger, ge = x.forwardRef(({ className: t, sideOffset: i = 4, ...a }, l) => /* @__PURE__ */ e(F.Portal, { children: /* @__PURE__ */ e(
|
|
68
68
|
F.Content,
|
|
69
69
|
{
|
|
70
70
|
ref: l,
|
|
@@ -76,8 +76,8 @@ const Ue = F.Provider, Xe = F.Root, Ge = F.Trigger, he = b.forwardRef(({ classNa
|
|
|
76
76
|
...a
|
|
77
77
|
}
|
|
78
78
|
) }));
|
|
79
|
-
|
|
80
|
-
const
|
|
79
|
+
ge.displayName = F.Content.displayName;
|
|
80
|
+
const X = w.Root, G = w.Value, J = x.forwardRef(({ className: t, children: i, ...a }, l) => /* @__PURE__ */ s(
|
|
81
81
|
w.Trigger,
|
|
82
82
|
{
|
|
83
83
|
ref: l,
|
|
@@ -88,12 +88,12 @@ const H = w.Root, _ = w.Value, $ = b.forwardRef(({ className: t, children: i, ..
|
|
|
88
88
|
...a,
|
|
89
89
|
children: [
|
|
90
90
|
i,
|
|
91
|
-
/* @__PURE__ */ e(w.Icon, { asChild: !0, children: /* @__PURE__ */ e(
|
|
91
|
+
/* @__PURE__ */ e(w.Icon, { asChild: !0, children: /* @__PURE__ */ e(ie, { className: "h-4 w-4 opacity-50" }) })
|
|
92
92
|
]
|
|
93
93
|
}
|
|
94
94
|
));
|
|
95
|
-
|
|
96
|
-
const
|
|
95
|
+
J.displayName = w.Trigger.displayName;
|
|
96
|
+
const ye = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
97
97
|
w.ScrollUpButton,
|
|
98
98
|
{
|
|
99
99
|
ref: a,
|
|
@@ -102,11 +102,11 @@ const fe = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
102
102
|
t
|
|
103
103
|
),
|
|
104
104
|
...i,
|
|
105
|
-
children: /* @__PURE__ */ e(
|
|
105
|
+
children: /* @__PURE__ */ e(Pe, { className: "h-4 w-4" })
|
|
106
106
|
}
|
|
107
107
|
));
|
|
108
|
-
|
|
109
|
-
const
|
|
108
|
+
ye.displayName = w.ScrollUpButton.displayName;
|
|
109
|
+
const ve = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
110
110
|
w.ScrollDownButton,
|
|
111
111
|
{
|
|
112
112
|
ref: a,
|
|
@@ -115,11 +115,11 @@ const pe = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
115
115
|
t
|
|
116
116
|
),
|
|
117
117
|
...i,
|
|
118
|
-
children: /* @__PURE__ */ e(
|
|
118
|
+
children: /* @__PURE__ */ e(ie, { className: "h-4 w-4" })
|
|
119
119
|
}
|
|
120
120
|
));
|
|
121
|
-
|
|
122
|
-
const
|
|
121
|
+
ve.displayName = w.ScrollDownButton.displayName;
|
|
122
|
+
const V = x.forwardRef(({ className: t, children: i, position: a = "popper", ...l }, n) => /* @__PURE__ */ e(w.Portal, { children: /* @__PURE__ */ s(
|
|
123
123
|
w.Content,
|
|
124
124
|
{
|
|
125
125
|
ref: n,
|
|
@@ -131,7 +131,7 @@ const K = b.forwardRef(({ className: t, children: i, position: a = "popper", ...
|
|
|
131
131
|
position: a,
|
|
132
132
|
...l,
|
|
133
133
|
children: [
|
|
134
|
-
/* @__PURE__ */ e(
|
|
134
|
+
/* @__PURE__ */ e(ye, {}),
|
|
135
135
|
/* @__PURE__ */ e(
|
|
136
136
|
w.Viewport,
|
|
137
137
|
{
|
|
@@ -142,12 +142,12 @@ const K = b.forwardRef(({ className: t, children: i, position: a = "popper", ...
|
|
|
142
142
|
children: i
|
|
143
143
|
}
|
|
144
144
|
),
|
|
145
|
-
/* @__PURE__ */ e(
|
|
145
|
+
/* @__PURE__ */ e(ve, {})
|
|
146
146
|
]
|
|
147
147
|
}
|
|
148
148
|
) }));
|
|
149
|
-
|
|
150
|
-
const
|
|
149
|
+
V.displayName = w.Content.displayName;
|
|
150
|
+
const et = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
151
151
|
w.Label,
|
|
152
152
|
{
|
|
153
153
|
ref: a,
|
|
@@ -155,8 +155,8 @@ const Qe = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
155
155
|
...i
|
|
156
156
|
}
|
|
157
157
|
));
|
|
158
|
-
|
|
159
|
-
const
|
|
158
|
+
et.displayName = w.Label.displayName;
|
|
159
|
+
const I = x.forwardRef(({ className: t, children: i, ...a }, l) => /* @__PURE__ */ s(
|
|
160
160
|
w.Item,
|
|
161
161
|
{
|
|
162
162
|
ref: l,
|
|
@@ -166,13 +166,13 @@ const C = b.forwardRef(({ className: t, children: i, ...a }, l) => /* @__PURE__
|
|
|
166
166
|
),
|
|
167
167
|
...a,
|
|
168
168
|
children: [
|
|
169
|
-
/* @__PURE__ */ e("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ e(w.ItemIndicator, { children: /* @__PURE__ */ e(
|
|
169
|
+
/* @__PURE__ */ e("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ e(w.ItemIndicator, { children: /* @__PURE__ */ e(he, { className: "h-4 w-4" }) }) }),
|
|
170
170
|
/* @__PURE__ */ e(w.ItemText, { children: i })
|
|
171
171
|
]
|
|
172
172
|
}
|
|
173
173
|
));
|
|
174
|
-
|
|
175
|
-
const
|
|
174
|
+
I.displayName = w.Item.displayName;
|
|
175
|
+
const tt = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
176
176
|
w.Separator,
|
|
177
177
|
{
|
|
178
178
|
ref: a,
|
|
@@ -180,8 +180,8 @@ const We = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
180
180
|
...i
|
|
181
181
|
}
|
|
182
182
|
));
|
|
183
|
-
|
|
184
|
-
const
|
|
183
|
+
tt.displayName = w.Separator.displayName;
|
|
184
|
+
const at = L.Root, it = L.Portal, xe = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
185
185
|
L.Overlay,
|
|
186
186
|
{
|
|
187
187
|
ref: a,
|
|
@@ -192,9 +192,9 @@ const Ye = L.Root, Ze = L.Portal, ge = b.forwardRef(({ className: t, ...i }, a)
|
|
|
192
192
|
...i
|
|
193
193
|
}
|
|
194
194
|
));
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
/* @__PURE__ */ e(
|
|
195
|
+
xe.displayName = L.Overlay.displayName;
|
|
196
|
+
const be = x.forwardRef(({ className: t, children: i, ...a }, l) => /* @__PURE__ */ s(it, { children: [
|
|
197
|
+
/* @__PURE__ */ e(xe, {}),
|
|
198
198
|
/* @__PURE__ */ s(
|
|
199
199
|
L.Content,
|
|
200
200
|
{
|
|
@@ -207,15 +207,15 @@ const ve = b.forwardRef(({ className: t, children: i, ...a }, l) => /* @__PURE__
|
|
|
207
207
|
children: [
|
|
208
208
|
i,
|
|
209
209
|
/* @__PURE__ */ s(L.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
|
|
210
|
-
/* @__PURE__ */ e(
|
|
210
|
+
/* @__PURE__ */ e(Fe, { className: "h-4 w-4" }),
|
|
211
211
|
/* @__PURE__ */ e("span", { className: "sr-only", children: "Close" })
|
|
212
212
|
] })
|
|
213
213
|
]
|
|
214
214
|
}
|
|
215
215
|
)
|
|
216
216
|
] }));
|
|
217
|
-
|
|
218
|
-
const
|
|
217
|
+
be.displayName = L.Content.displayName;
|
|
218
|
+
const Ne = ({
|
|
219
219
|
className: t,
|
|
220
220
|
...i
|
|
221
221
|
}) => /* @__PURE__ */ e(
|
|
@@ -228,8 +228,8 @@ const ye = ({
|
|
|
228
228
|
...i
|
|
229
229
|
}
|
|
230
230
|
);
|
|
231
|
-
|
|
232
|
-
const
|
|
231
|
+
Ne.displayName = "DialogHeader";
|
|
232
|
+
const we = ({
|
|
233
233
|
className: t,
|
|
234
234
|
...i
|
|
235
235
|
}) => /* @__PURE__ */ e(
|
|
@@ -242,8 +242,8 @@ const xe = ({
|
|
|
242
242
|
...i
|
|
243
243
|
}
|
|
244
244
|
);
|
|
245
|
-
|
|
246
|
-
const
|
|
245
|
+
we.displayName = "DialogFooter";
|
|
246
|
+
const Ce = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
247
247
|
L.Title,
|
|
248
248
|
{
|
|
249
249
|
ref: a,
|
|
@@ -254,8 +254,8 @@ const be = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
254
254
|
...i
|
|
255
255
|
}
|
|
256
256
|
));
|
|
257
|
-
|
|
258
|
-
const
|
|
257
|
+
Ce.displayName = L.Title.displayName;
|
|
258
|
+
const nt = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
259
259
|
L.Description,
|
|
260
260
|
{
|
|
261
261
|
ref: a,
|
|
@@ -263,20 +263,20 @@ const et = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
263
263
|
...i
|
|
264
264
|
}
|
|
265
265
|
));
|
|
266
|
-
|
|
267
|
-
const
|
|
266
|
+
nt.displayName = L.Description.displayName;
|
|
267
|
+
const st = ue(
|
|
268
268
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
269
|
-
), N =
|
|
270
|
-
|
|
269
|
+
), N = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
270
|
+
pe.Root,
|
|
271
271
|
{
|
|
272
272
|
ref: a,
|
|
273
|
-
className: h(
|
|
273
|
+
className: h(st(), t),
|
|
274
274
|
...i
|
|
275
275
|
}
|
|
276
276
|
));
|
|
277
|
-
N.displayName =
|
|
278
|
-
const
|
|
279
|
-
|
|
277
|
+
N.displayName = pe.Root.displayName;
|
|
278
|
+
const Q = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
279
|
+
U.Root,
|
|
280
280
|
{
|
|
281
281
|
ref: a,
|
|
282
282
|
className: h(
|
|
@@ -285,16 +285,16 @@ const U = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
285
285
|
),
|
|
286
286
|
...i,
|
|
287
287
|
children: /* @__PURE__ */ e(
|
|
288
|
-
|
|
288
|
+
U.Indicator,
|
|
289
289
|
{
|
|
290
290
|
className: h("grid place-content-center text-current"),
|
|
291
|
-
children: /* @__PURE__ */ e(
|
|
291
|
+
children: /* @__PURE__ */ e(he, { className: "h-4 w-4" })
|
|
292
292
|
}
|
|
293
293
|
)
|
|
294
294
|
}
|
|
295
295
|
));
|
|
296
|
-
|
|
297
|
-
const
|
|
296
|
+
Q.displayName = U.Root.displayName;
|
|
297
|
+
const ne = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
298
298
|
"textarea",
|
|
299
299
|
{
|
|
300
300
|
className: h(
|
|
@@ -305,33 +305,33 @@ const te = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
305
305
|
...i
|
|
306
306
|
}
|
|
307
307
|
));
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
const n = (
|
|
311
|
-
i({ ...t, [
|
|
308
|
+
ne.displayName = "Textarea";
|
|
309
|
+
const rt = (t) => t.trim().toLowerCase().replace(/[^\w\s]/g, "").replace(/\s+/g, "_"), lt = (t, i, a = !1, l = !1) => {
|
|
310
|
+
const n = (p, g) => {
|
|
311
|
+
i({ ...t, [p]: g });
|
|
312
312
|
};
|
|
313
313
|
return {
|
|
314
|
-
handleTitleChange: (
|
|
315
|
-
n("title",
|
|
314
|
+
handleTitleChange: (p) => {
|
|
315
|
+
n("title", p);
|
|
316
316
|
},
|
|
317
317
|
handleTitleBlur: () => {
|
|
318
318
|
if (a && t.title) {
|
|
319
|
-
const
|
|
320
|
-
n("key",
|
|
319
|
+
const p = rt(t.title);
|
|
320
|
+
n("key", p);
|
|
321
321
|
}
|
|
322
322
|
},
|
|
323
|
-
handleKeyChange: (
|
|
324
|
-
(a || l) && n("key",
|
|
323
|
+
handleKeyChange: (p) => {
|
|
324
|
+
(a || l) && n("key", p);
|
|
325
325
|
},
|
|
326
326
|
handleFieldChange: n,
|
|
327
|
-
handleConstraintChange: (
|
|
327
|
+
handleConstraintChange: (p, g) => {
|
|
328
328
|
i({
|
|
329
329
|
...t,
|
|
330
|
-
[
|
|
330
|
+
[p]: g
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
333
|
};
|
|
334
|
-
},
|
|
334
|
+
}, W = {
|
|
335
335
|
string: "String",
|
|
336
336
|
number: "Number",
|
|
337
337
|
integer: "Integer",
|
|
@@ -340,59 +340,68 @@ const at = (t) => t.trim().toLowerCase().replace(/[^\w\s]/g, "").replace(/\s+/g,
|
|
|
340
340
|
array: "Array",
|
|
341
341
|
null: "Null",
|
|
342
342
|
file: "File"
|
|
343
|
-
},
|
|
344
|
-
getTypeLabel: (t) =>
|
|
345
|
-
typeLabels:
|
|
346
|
-
}
|
|
347
|
-
|
|
343
|
+
}, K = {
|
|
344
|
+
getTypeLabel: (t) => W[t],
|
|
345
|
+
typeLabels: W,
|
|
346
|
+
propertyLabel: { singular: "property", plural: "properties" },
|
|
347
|
+
showRegex: !1,
|
|
348
|
+
keyEditable: !1
|
|
349
|
+
}, ke = Re(K);
|
|
350
|
+
function ot({
|
|
348
351
|
children: t,
|
|
349
|
-
|
|
352
|
+
config: i = {}
|
|
350
353
|
}) {
|
|
351
|
-
const a = { ...
|
|
352
|
-
return /* @__PURE__ */ e(
|
|
354
|
+
const a = { ...W, ...i.typeLabels }, l = i.propertyLabel || K.propertyLabel, n = i.showRegex ?? K.showRegex, o = i.keyEditable ?? K.keyEditable, r = (m) => a[m] || m;
|
|
355
|
+
return /* @__PURE__ */ e(
|
|
356
|
+
ke.Provider,
|
|
357
|
+
{
|
|
358
|
+
value: { getTypeLabel: r, typeLabels: a, propertyLabel: l, showRegex: n, keyEditable: o },
|
|
359
|
+
children: t
|
|
360
|
+
}
|
|
361
|
+
);
|
|
353
362
|
}
|
|
354
|
-
function
|
|
355
|
-
return
|
|
363
|
+
function Ie() {
|
|
364
|
+
return Ee(ke);
|
|
356
365
|
}
|
|
357
|
-
function
|
|
366
|
+
function Y({
|
|
358
367
|
property: t,
|
|
359
368
|
open: i,
|
|
360
369
|
onOpenChange: a,
|
|
361
370
|
onSave: l,
|
|
362
371
|
isArrayItem: n = !1,
|
|
363
|
-
isNewProperty:
|
|
364
|
-
propertyLabel: r
|
|
365
|
-
showRegex: m
|
|
366
|
-
keyEditable:
|
|
367
|
-
typeLabels:
|
|
372
|
+
isNewProperty: o = !1,
|
|
373
|
+
propertyLabel: r,
|
|
374
|
+
showRegex: m,
|
|
375
|
+
keyEditable: D,
|
|
376
|
+
typeLabels: p
|
|
368
377
|
}) {
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
i &&
|
|
378
|
+
const g = Ie(), u = p || g.typeLabels, b = r || g.propertyLabel, v = m ?? g.showRegex, y = D ?? g.keyEditable, [d, k] = q(t);
|
|
379
|
+
ae(() => {
|
|
380
|
+
i && k(t);
|
|
372
381
|
}, [t, i]);
|
|
373
382
|
const {
|
|
374
|
-
handleTitleChange:
|
|
375
|
-
handleTitleBlur:
|
|
376
|
-
handleKeyChange:
|
|
377
|
-
handleFieldChange:
|
|
378
|
-
handleConstraintChange:
|
|
379
|
-
} =
|
|
380
|
-
o,
|
|
381
|
-
f,
|
|
383
|
+
handleTitleChange: E,
|
|
384
|
+
handleTitleBlur: R,
|
|
385
|
+
handleKeyChange: f,
|
|
386
|
+
handleFieldChange: O,
|
|
387
|
+
handleConstraintChange: C
|
|
388
|
+
} = lt(
|
|
382
389
|
d,
|
|
383
|
-
k
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
390
|
+
k,
|
|
391
|
+
o,
|
|
392
|
+
y
|
|
393
|
+
), H = () => {
|
|
394
|
+
d.title?.trim() && (l(d), a(!1));
|
|
395
|
+
}, _ = () => {
|
|
396
|
+
k(t), a(!1);
|
|
388
397
|
};
|
|
389
|
-
return /* @__PURE__ */ e(
|
|
390
|
-
|
|
398
|
+
return /* @__PURE__ */ e(at, { open: i, onOpenChange: a, children: /* @__PURE__ */ s(
|
|
399
|
+
be,
|
|
391
400
|
{
|
|
392
401
|
className: "max-w-2xl max-h-[80vh] flex flex-col gap-0 p-0",
|
|
393
402
|
"data-testid": "dialog-edit-property",
|
|
394
403
|
children: [
|
|
395
|
-
/* @__PURE__ */ e(
|
|
404
|
+
/* @__PURE__ */ e(Ne, { className: "px-6 pt-6 pb-4 shrink-0", children: /* @__PURE__ */ e(Ce, { children: o ? `Add ${b.singular}` : `Edit ${b.singular}` }) }),
|
|
396
405
|
/* @__PURE__ */ s("div", { className: "space-y-6 px-6 pb-4 overflow-y-auto flex-1 min-h-0", children: [
|
|
397
406
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
398
407
|
/* @__PURE__ */ s(N, { className: "flex items-center gap-1.5", children: [
|
|
@@ -400,22 +409,22 @@ function G({
|
|
|
400
409
|
"Type"
|
|
401
410
|
] }),
|
|
402
411
|
/* @__PURE__ */ s(
|
|
403
|
-
|
|
412
|
+
X,
|
|
404
413
|
{
|
|
405
|
-
value:
|
|
406
|
-
onValueChange: (c) =>
|
|
414
|
+
value: d.type,
|
|
415
|
+
onValueChange: (c) => O("type", c),
|
|
407
416
|
"data-testid": "select-type-dialog",
|
|
408
417
|
children: [
|
|
409
|
-
/* @__PURE__ */ e(
|
|
410
|
-
/* @__PURE__ */ s(
|
|
411
|
-
/* @__PURE__ */ e(
|
|
412
|
-
/* @__PURE__ */ e(
|
|
413
|
-
/* @__PURE__ */ e(
|
|
414
|
-
/* @__PURE__ */ e(
|
|
415
|
-
/* @__PURE__ */ e(
|
|
416
|
-
/* @__PURE__ */ e(
|
|
417
|
-
/* @__PURE__ */ e(
|
|
418
|
-
/* @__PURE__ */ e(
|
|
418
|
+
/* @__PURE__ */ e(J, { children: /* @__PURE__ */ e(G, {}) }),
|
|
419
|
+
/* @__PURE__ */ s(V, { children: [
|
|
420
|
+
/* @__PURE__ */ e(I, { value: "string", children: u.string }),
|
|
421
|
+
/* @__PURE__ */ e(I, { value: "number", children: u.number }),
|
|
422
|
+
/* @__PURE__ */ e(I, { value: "integer", children: u.integer }),
|
|
423
|
+
/* @__PURE__ */ e(I, { value: "boolean", children: u.boolean }),
|
|
424
|
+
/* @__PURE__ */ e(I, { value: "object", children: u.object }),
|
|
425
|
+
/* @__PURE__ */ e(I, { value: "array", children: u.array }),
|
|
426
|
+
/* @__PURE__ */ e(I, { value: "file", children: u.file }),
|
|
427
|
+
/* @__PURE__ */ e(I, { value: "null", children: u.null })
|
|
419
428
|
] })
|
|
420
429
|
]
|
|
421
430
|
}
|
|
@@ -427,77 +436,77 @@ function G({
|
|
|
427
436
|
"Title"
|
|
428
437
|
] }),
|
|
429
438
|
/* @__PURE__ */ e(
|
|
430
|
-
|
|
439
|
+
T,
|
|
431
440
|
{
|
|
432
|
-
value:
|
|
433
|
-
onChange: (c) =>
|
|
434
|
-
onBlur:
|
|
441
|
+
value: d.title || "",
|
|
442
|
+
onChange: (c) => E(c.target.value),
|
|
443
|
+
onBlur: R,
|
|
435
444
|
placeholder: "Property Title",
|
|
436
445
|
"data-testid": "input-title-dialog",
|
|
437
446
|
required: !0
|
|
438
447
|
}
|
|
439
448
|
),
|
|
440
|
-
!
|
|
449
|
+
!o && d.key && /* @__PURE__ */ s("p", { className: "text-xs text-muted-foreground font-mono", children: [
|
|
441
450
|
"Key: ",
|
|
442
|
-
|
|
451
|
+
d.key
|
|
443
452
|
] })
|
|
444
453
|
] }),
|
|
445
|
-
(
|
|
454
|
+
(o || y) && /* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
446
455
|
/* @__PURE__ */ e(N, { children: "Key" }),
|
|
447
456
|
/* @__PURE__ */ e(
|
|
448
|
-
|
|
457
|
+
T,
|
|
449
458
|
{
|
|
450
|
-
value:
|
|
451
|
-
onChange: (c) =>
|
|
459
|
+
value: d.key,
|
|
460
|
+
onChange: (c) => f(c.target.value),
|
|
452
461
|
placeholder: "property_key",
|
|
453
462
|
"data-testid": "input-key-dialog"
|
|
454
463
|
}
|
|
455
464
|
),
|
|
456
|
-
!
|
|
465
|
+
!o && /* @__PURE__ */ e("p", { className: "text-xs text-yellow-600 dark:text-yellow-500", children: "⚠️ Changing the key may break existing references to this property" })
|
|
457
466
|
] }),
|
|
458
467
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
459
468
|
/* @__PURE__ */ e(N, { children: "Description" }),
|
|
460
469
|
/* @__PURE__ */ e(
|
|
461
|
-
|
|
470
|
+
ne,
|
|
462
471
|
{
|
|
463
472
|
placeholder: "Optional description",
|
|
464
|
-
value:
|
|
465
|
-
onChange: (c) =>
|
|
473
|
+
value: d.description || "",
|
|
474
|
+
onChange: (c) => O("description", c.target.value),
|
|
466
475
|
rows: 2,
|
|
467
476
|
"data-testid": "input-edit-description"
|
|
468
477
|
}
|
|
469
478
|
)
|
|
470
479
|
] }),
|
|
471
|
-
|
|
480
|
+
d.type === "array" && /* @__PURE__ */ s("div", { className: "space-y-2 border-l-2 border-border pl-4 mt-2", children: [
|
|
472
481
|
/* @__PURE__ */ s(N, { className: "font-semibold text-xs text-muted-foreground", children: [
|
|
473
482
|
u.array,
|
|
474
483
|
" Items"
|
|
475
484
|
] }),
|
|
476
|
-
|
|
485
|
+
d.items ? /* @__PURE__ */ s("div", { className: "bg-muted/40 p-2 rounded", children: [
|
|
477
486
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
478
487
|
/* @__PURE__ */ e(N, { children: "Item Type" }),
|
|
479
488
|
/* @__PURE__ */ s(
|
|
480
|
-
|
|
489
|
+
X,
|
|
481
490
|
{
|
|
482
|
-
value:
|
|
483
|
-
onValueChange: (c) =>
|
|
484
|
-
...
|
|
491
|
+
value: d.items.type,
|
|
492
|
+
onValueChange: (c) => k({
|
|
493
|
+
...d,
|
|
485
494
|
items: {
|
|
486
|
-
...
|
|
495
|
+
...d.items,
|
|
487
496
|
type: c
|
|
488
497
|
}
|
|
489
498
|
}),
|
|
490
499
|
children: [
|
|
491
|
-
/* @__PURE__ */ e(
|
|
492
|
-
/* @__PURE__ */ s(
|
|
493
|
-
/* @__PURE__ */ e(
|
|
494
|
-
/* @__PURE__ */ e(
|
|
495
|
-
/* @__PURE__ */ e(
|
|
496
|
-
/* @__PURE__ */ e(
|
|
497
|
-
/* @__PURE__ */ e(
|
|
498
|
-
/* @__PURE__ */ e(
|
|
499
|
-
/* @__PURE__ */ e(
|
|
500
|
-
/* @__PURE__ */ e(
|
|
500
|
+
/* @__PURE__ */ e(J, { children: /* @__PURE__ */ e(G, {}) }),
|
|
501
|
+
/* @__PURE__ */ s(V, { children: [
|
|
502
|
+
/* @__PURE__ */ e(I, { value: "string", children: u.string }),
|
|
503
|
+
/* @__PURE__ */ e(I, { value: "number", children: u.number }),
|
|
504
|
+
/* @__PURE__ */ e(I, { value: "integer", children: u.integer }),
|
|
505
|
+
/* @__PURE__ */ e(I, { value: "boolean", children: u.boolean }),
|
|
506
|
+
/* @__PURE__ */ e(I, { value: "object", children: u.object }),
|
|
507
|
+
/* @__PURE__ */ e(I, { value: "array", children: u.array }),
|
|
508
|
+
/* @__PURE__ */ e(I, { value: "file", children: u.file }),
|
|
509
|
+
/* @__PURE__ */ e(I, { value: "null", children: u.null })
|
|
501
510
|
] })
|
|
502
511
|
]
|
|
503
512
|
}
|
|
@@ -506,13 +515,13 @@ function G({
|
|
|
506
515
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
507
516
|
/* @__PURE__ */ e(N, { children: "Item Title" }),
|
|
508
517
|
/* @__PURE__ */ e(
|
|
509
|
-
|
|
518
|
+
T,
|
|
510
519
|
{
|
|
511
|
-
value:
|
|
512
|
-
onChange: (c) =>
|
|
513
|
-
...
|
|
520
|
+
value: d.items.title || "",
|
|
521
|
+
onChange: (c) => k({
|
|
522
|
+
...d,
|
|
514
523
|
items: {
|
|
515
|
-
...
|
|
524
|
+
...d.items,
|
|
516
525
|
title: c.target.value
|
|
517
526
|
}
|
|
518
527
|
}),
|
|
@@ -521,12 +530,12 @@ function G({
|
|
|
521
530
|
)
|
|
522
531
|
] }),
|
|
523
532
|
/* @__PURE__ */ s(
|
|
524
|
-
|
|
533
|
+
S,
|
|
525
534
|
{
|
|
526
535
|
variant: "ghost",
|
|
527
536
|
size: "sm",
|
|
528
537
|
className: "mt-2",
|
|
529
|
-
onClick: () =>
|
|
538
|
+
onClick: () => k({ ...d, items: void 0 }),
|
|
530
539
|
children: [
|
|
531
540
|
"Remove ",
|
|
532
541
|
u.array,
|
|
@@ -535,13 +544,13 @@ function G({
|
|
|
535
544
|
}
|
|
536
545
|
)
|
|
537
546
|
] }) : /* @__PURE__ */ s(
|
|
538
|
-
|
|
547
|
+
S,
|
|
539
548
|
{
|
|
540
549
|
variant: "outline",
|
|
541
550
|
size: "sm",
|
|
542
551
|
onClick: () => {
|
|
543
|
-
|
|
544
|
-
...
|
|
552
|
+
k({
|
|
553
|
+
...d,
|
|
545
554
|
items: {
|
|
546
555
|
id: Date.now().toString() + Math.random(),
|
|
547
556
|
key: "item",
|
|
@@ -560,17 +569,17 @@ function G({
|
|
|
560
569
|
] }),
|
|
561
570
|
!n && /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
562
571
|
/* @__PURE__ */ e(
|
|
563
|
-
|
|
572
|
+
Q,
|
|
564
573
|
{
|
|
565
574
|
id: "prop-required",
|
|
566
|
-
checked:
|
|
567
|
-
onCheckedChange: (c) =>
|
|
575
|
+
checked: d.required,
|
|
576
|
+
onCheckedChange: (c) => O("required", c),
|
|
568
577
|
"data-testid": "checkbox-edit-required"
|
|
569
578
|
}
|
|
570
579
|
),
|
|
571
580
|
/* @__PURE__ */ e(N, { htmlFor: "prop-required", className: "cursor-pointer", children: "Required field" })
|
|
572
581
|
] }),
|
|
573
|
-
|
|
582
|
+
d.type === "string" && /* @__PURE__ */ s("details", { className: "border rounded-md", children: [
|
|
574
583
|
/* @__PURE__ */ e("summary", { className: "p-4 cursor-pointer hover:bg-accent/50 transition-colors", children: /* @__PURE__ */ s("h4", { className: "text-sm font-medium inline", children: [
|
|
575
584
|
u.string,
|
|
576
585
|
" Constraints"
|
|
@@ -580,13 +589,13 @@ function G({
|
|
|
580
589
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
581
590
|
/* @__PURE__ */ e(N, { htmlFor: "min-length", children: "Minimum Length" }),
|
|
582
591
|
/* @__PURE__ */ e(
|
|
583
|
-
|
|
592
|
+
T,
|
|
584
593
|
{
|
|
585
594
|
id: "min-length",
|
|
586
595
|
type: "number",
|
|
587
596
|
placeholder: "0",
|
|
588
|
-
value:
|
|
589
|
-
onChange: (c) =>
|
|
597
|
+
value: d.minLength || "",
|
|
598
|
+
onChange: (c) => C(
|
|
590
599
|
"minLength",
|
|
591
600
|
c.target.value ? parseInt(c.target.value) : void 0
|
|
592
601
|
),
|
|
@@ -597,13 +606,13 @@ function G({
|
|
|
597
606
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
598
607
|
/* @__PURE__ */ e(N, { htmlFor: "max-length", children: "Maximum Length" }),
|
|
599
608
|
/* @__PURE__ */ e(
|
|
600
|
-
|
|
609
|
+
T,
|
|
601
610
|
{
|
|
602
611
|
id: "max-length",
|
|
603
612
|
type: "number",
|
|
604
613
|
placeholder: "∞",
|
|
605
|
-
value:
|
|
606
|
-
onChange: (c) =>
|
|
614
|
+
value: d.maxLength || "",
|
|
615
|
+
onChange: (c) => C(
|
|
607
616
|
"maxLength",
|
|
608
617
|
c.target.value ? parseInt(c.target.value) : void 0
|
|
609
618
|
),
|
|
@@ -612,15 +621,15 @@ function G({
|
|
|
612
621
|
)
|
|
613
622
|
] })
|
|
614
623
|
] }),
|
|
615
|
-
|
|
624
|
+
v && /* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
616
625
|
/* @__PURE__ */ e(N, { htmlFor: "pattern", children: "Pattern (regex)" }),
|
|
617
626
|
/* @__PURE__ */ e(
|
|
618
|
-
|
|
627
|
+
T,
|
|
619
628
|
{
|
|
620
629
|
id: "pattern",
|
|
621
630
|
placeholder: "^[a-z]+$",
|
|
622
|
-
value:
|
|
623
|
-
onChange: (c) =>
|
|
631
|
+
value: d.pattern || "",
|
|
632
|
+
onChange: (c) => C("pattern", c.target.value),
|
|
624
633
|
className: "font-mono text-sm",
|
|
625
634
|
"data-testid": "input-edit-pattern"
|
|
626
635
|
}
|
|
@@ -628,52 +637,52 @@ function G({
|
|
|
628
637
|
] }),
|
|
629
638
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
630
639
|
/* @__PURE__ */ e(N, { children: "Enum Values" }),
|
|
631
|
-
/* @__PURE__ */ e("div", { className: "space-y-2", children: [...
|
|
632
|
-
|
|
640
|
+
/* @__PURE__ */ e("div", { className: "space-y-2", children: [...d.enum || [], ""].map((c, j) => /* @__PURE__ */ e(
|
|
641
|
+
T,
|
|
633
642
|
{
|
|
634
|
-
placeholder:
|
|
643
|
+
placeholder: j === (d.enum?.length || 0) ? "Add new value..." : "Enum value",
|
|
635
644
|
value: c,
|
|
636
|
-
onChange: (
|
|
637
|
-
const
|
|
638
|
-
if (
|
|
639
|
-
|
|
640
|
-
...
|
|
641
|
-
|
|
645
|
+
onChange: (Te) => {
|
|
646
|
+
const A = Te.target.value, M = d.enum || [];
|
|
647
|
+
if (j === M.length)
|
|
648
|
+
A.trim() && C("enum", [
|
|
649
|
+
...M,
|
|
650
|
+
A.trim()
|
|
642
651
|
]);
|
|
643
|
-
else if (
|
|
644
|
-
const
|
|
645
|
-
|
|
652
|
+
else if (A.trim()) {
|
|
653
|
+
const z = [...M];
|
|
654
|
+
z[j] = A.trim(), C("enum", z);
|
|
646
655
|
} else {
|
|
647
|
-
const
|
|
648
|
-
(
|
|
656
|
+
const z = M.filter(
|
|
657
|
+
(wt, De) => De !== j
|
|
649
658
|
);
|
|
650
|
-
|
|
659
|
+
C(
|
|
651
660
|
"enum",
|
|
652
|
-
|
|
661
|
+
z.length > 0 ? z : void 0
|
|
653
662
|
);
|
|
654
663
|
}
|
|
655
664
|
},
|
|
656
|
-
"data-testid": `input-edit-enum-${
|
|
665
|
+
"data-testid": `input-edit-enum-${j}`
|
|
657
666
|
},
|
|
658
|
-
|
|
667
|
+
j
|
|
659
668
|
)) }),
|
|
660
669
|
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: "Enter allowed values (empty fields will be removed)" })
|
|
661
670
|
] })
|
|
662
671
|
] })
|
|
663
672
|
] }),
|
|
664
|
-
(
|
|
673
|
+
(d.type === "number" || d.type === "integer") && /* @__PURE__ */ s("details", { className: "border rounded-md", children: [
|
|
665
674
|
/* @__PURE__ */ e("summary", { className: "p-4 cursor-pointer hover:bg-accent/50 transition-colors", children: /* @__PURE__ */ e("h4", { className: "text-sm font-medium inline", children: "Numeric Constraints" }) }),
|
|
666
675
|
/* @__PURE__ */ e("div", { className: "space-y-4 p-4 pt-0", children: /* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
667
676
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
668
677
|
/* @__PURE__ */ e(N, { htmlFor: "minimum", children: "Minimum Value" }),
|
|
669
678
|
/* @__PURE__ */ e(
|
|
670
|
-
|
|
679
|
+
T,
|
|
671
680
|
{
|
|
672
681
|
id: "minimum",
|
|
673
682
|
type: "number",
|
|
674
683
|
placeholder: "-∞",
|
|
675
|
-
value:
|
|
676
|
-
onChange: (c) =>
|
|
684
|
+
value: d.minimum ?? "",
|
|
685
|
+
onChange: (c) => C(
|
|
677
686
|
"minimum",
|
|
678
687
|
c.target.value ? parseFloat(c.target.value) : void 0
|
|
679
688
|
),
|
|
@@ -684,13 +693,13 @@ function G({
|
|
|
684
693
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
685
694
|
/* @__PURE__ */ e(N, { htmlFor: "maximum", children: "Maximum Value" }),
|
|
686
695
|
/* @__PURE__ */ e(
|
|
687
|
-
|
|
696
|
+
T,
|
|
688
697
|
{
|
|
689
698
|
id: "maximum",
|
|
690
699
|
type: "number",
|
|
691
700
|
placeholder: "∞",
|
|
692
|
-
value:
|
|
693
|
-
onChange: (c) =>
|
|
701
|
+
value: d.maximum ?? "",
|
|
702
|
+
onChange: (c) => C(
|
|
694
703
|
"maximum",
|
|
695
704
|
c.target.value ? parseFloat(c.target.value) : void 0
|
|
696
705
|
),
|
|
@@ -700,7 +709,7 @@ function G({
|
|
|
700
709
|
] })
|
|
701
710
|
] }) })
|
|
702
711
|
] }),
|
|
703
|
-
|
|
712
|
+
d.type === "array" && /* @__PURE__ */ s("details", { className: "border rounded-md", children: [
|
|
704
713
|
/* @__PURE__ */ e("summary", { className: "p-4 cursor-pointer hover:bg-accent/50 transition-colors", children: /* @__PURE__ */ s("h4", { className: "text-sm font-medium inline", children: [
|
|
705
714
|
u.array,
|
|
706
715
|
" Constraints"
|
|
@@ -710,13 +719,13 @@ function G({
|
|
|
710
719
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
711
720
|
/* @__PURE__ */ e(N, { htmlFor: "min-items", children: "Minimum Items" }),
|
|
712
721
|
/* @__PURE__ */ e(
|
|
713
|
-
|
|
722
|
+
T,
|
|
714
723
|
{
|
|
715
724
|
id: "min-items",
|
|
716
725
|
type: "number",
|
|
717
726
|
placeholder: "0",
|
|
718
|
-
value:
|
|
719
|
-
onChange: (c) =>
|
|
727
|
+
value: d.minItems || "",
|
|
728
|
+
onChange: (c) => C(
|
|
720
729
|
"minItems",
|
|
721
730
|
c.target.value ? parseInt(c.target.value) : void 0
|
|
722
731
|
),
|
|
@@ -727,13 +736,13 @@ function G({
|
|
|
727
736
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
728
737
|
/* @__PURE__ */ e(N, { htmlFor: "max-items", children: "Maximum Items" }),
|
|
729
738
|
/* @__PURE__ */ e(
|
|
730
|
-
|
|
739
|
+
T,
|
|
731
740
|
{
|
|
732
741
|
id: "max-items",
|
|
733
742
|
type: "number",
|
|
734
743
|
placeholder: "∞",
|
|
735
|
-
value:
|
|
736
|
-
onChange: (c) =>
|
|
744
|
+
value: d.maxItems || "",
|
|
745
|
+
onChange: (c) => C(
|
|
737
746
|
"maxItems",
|
|
738
747
|
c.target.value ? parseInt(c.target.value) : void 0
|
|
739
748
|
),
|
|
@@ -744,11 +753,11 @@ function G({
|
|
|
744
753
|
] }),
|
|
745
754
|
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
746
755
|
/* @__PURE__ */ e(
|
|
747
|
-
|
|
756
|
+
Q,
|
|
748
757
|
{
|
|
749
758
|
id: "unique-items",
|
|
750
|
-
checked:
|
|
751
|
-
onCheckedChange: (c) =>
|
|
759
|
+
checked: d.uniqueItems || !1,
|
|
760
|
+
onCheckedChange: (c) => C("uniqueItems", c),
|
|
752
761
|
"data-testid": "checkbox-edit-unique"
|
|
753
762
|
}
|
|
754
763
|
),
|
|
@@ -757,22 +766,22 @@ function G({
|
|
|
757
766
|
] })
|
|
758
767
|
] })
|
|
759
768
|
] }),
|
|
760
|
-
/* @__PURE__ */ s(
|
|
769
|
+
/* @__PURE__ */ s(we, { className: "px-6 py-4 border-t bg-background shrink-0", children: [
|
|
761
770
|
/* @__PURE__ */ e(
|
|
762
|
-
|
|
771
|
+
S,
|
|
763
772
|
{
|
|
764
773
|
variant: "outline",
|
|
765
|
-
onClick:
|
|
774
|
+
onClick: _,
|
|
766
775
|
"data-testid": "button-cancel",
|
|
767
776
|
children: "Cancel"
|
|
768
777
|
}
|
|
769
778
|
),
|
|
770
779
|
/* @__PURE__ */ e(
|
|
771
|
-
|
|
780
|
+
S,
|
|
772
781
|
{
|
|
773
|
-
onClick:
|
|
782
|
+
onClick: H,
|
|
774
783
|
"data-testid": "button-save",
|
|
775
|
-
disabled: !
|
|
784
|
+
disabled: !d.title?.trim(),
|
|
776
785
|
children: "Save Changes"
|
|
777
786
|
}
|
|
778
787
|
)
|
|
@@ -781,36 +790,36 @@ function G({
|
|
|
781
790
|
}
|
|
782
791
|
) });
|
|
783
792
|
}
|
|
784
|
-
function
|
|
785
|
-
const { allowEmpty: l = !1, onEditStart: n, onEditCancel:
|
|
786
|
-
|
|
787
|
-
r ||
|
|
793
|
+
function ce(t, i, a = {}) {
|
|
794
|
+
const { allowEmpty: l = !1, onEditStart: n, onEditCancel: o } = a, [r, m] = q(!1), [D, p] = q(t);
|
|
795
|
+
ae(() => {
|
|
796
|
+
r || p(t);
|
|
788
797
|
}, [t, r]);
|
|
789
|
-
const
|
|
790
|
-
|
|
791
|
-
}, u = (
|
|
792
|
-
|
|
793
|
-
},
|
|
794
|
-
const
|
|
795
|
-
if (!l && !
|
|
796
|
-
|
|
798
|
+
const g = () => {
|
|
799
|
+
p(t), m(!0), n?.();
|
|
800
|
+
}, u = (y) => {
|
|
801
|
+
p(y);
|
|
802
|
+
}, b = () => {
|
|
803
|
+
const y = D.trim();
|
|
804
|
+
if (!l && !y) {
|
|
805
|
+
p(t), m(!1);
|
|
797
806
|
return;
|
|
798
807
|
}
|
|
799
|
-
|
|
808
|
+
y !== t && i(y), m(!1);
|
|
800
809
|
};
|
|
801
810
|
return {
|
|
802
811
|
isEditing: r,
|
|
803
|
-
value:
|
|
804
|
-
startEdit:
|
|
812
|
+
value: D,
|
|
813
|
+
startEdit: g,
|
|
805
814
|
handleChange: u,
|
|
806
|
-
handleBlur:
|
|
807
|
-
handleKeyDown: (
|
|
808
|
-
|
|
815
|
+
handleBlur: b,
|
|
816
|
+
handleKeyDown: (y) => {
|
|
817
|
+
y.key === "Enter" ? b() : y.key === "Escape" && (p(t), m(!1), o?.());
|
|
809
818
|
}
|
|
810
819
|
};
|
|
811
820
|
}
|
|
812
|
-
function
|
|
813
|
-
const [a, l] =
|
|
821
|
+
function dt(t, i) {
|
|
822
|
+
const [a, l] = q(!1);
|
|
814
823
|
return {
|
|
815
824
|
isChangingType: a,
|
|
816
825
|
setIsChangingType: l,
|
|
@@ -829,52 +838,52 @@ function st(t, i) {
|
|
|
829
838
|
]
|
|
830
839
|
};
|
|
831
840
|
}
|
|
832
|
-
const
|
|
833
|
-
function
|
|
834
|
-
const { onConfirm: i, onCancel: a, createInitialData: l } = t, [n,
|
|
835
|
-
const
|
|
836
|
-
m(
|
|
837
|
-
},
|
|
838
|
-
|
|
841
|
+
const se = () => `${Date.now()}-${Math.random()}`;
|
|
842
|
+
function re(t = {}) {
|
|
843
|
+
const { onConfirm: i, onCancel: a, createInitialData: l } = t, [n, o] = q(!1), [r, m] = q(null), D = (b) => {
|
|
844
|
+
const v = b ?? (l ? l() : null);
|
|
845
|
+
m(v), o(!0);
|
|
846
|
+
}, p = () => {
|
|
847
|
+
o(!1), m(null), a?.();
|
|
839
848
|
};
|
|
840
849
|
return {
|
|
841
850
|
isOpen: n,
|
|
842
851
|
data: r,
|
|
843
|
-
open:
|
|
844
|
-
close:
|
|
845
|
-
confirm: (
|
|
846
|
-
i?.(
|
|
852
|
+
open: D,
|
|
853
|
+
close: p,
|
|
854
|
+
confirm: (b) => {
|
|
855
|
+
i?.(b), o(!1), m(null);
|
|
847
856
|
},
|
|
848
|
-
setIsOpen: (
|
|
849
|
-
|
|
857
|
+
setIsOpen: (b) => {
|
|
858
|
+
b ? o(!0) : p();
|
|
850
859
|
}
|
|
851
860
|
};
|
|
852
861
|
}
|
|
853
|
-
function
|
|
854
|
-
const a =
|
|
862
|
+
function ct(t, i) {
|
|
863
|
+
const a = re({
|
|
855
864
|
createInitialData: () => ({
|
|
856
|
-
id:
|
|
865
|
+
id: se(),
|
|
857
866
|
key: "",
|
|
858
867
|
type: "string",
|
|
859
868
|
required: !1
|
|
860
869
|
}),
|
|
861
|
-
onConfirm: (
|
|
870
|
+
onConfirm: (o) => {
|
|
862
871
|
i({
|
|
863
872
|
...t,
|
|
864
|
-
children: [...t.children || [],
|
|
873
|
+
children: [...t.children || [], o]
|
|
865
874
|
});
|
|
866
875
|
}
|
|
867
876
|
});
|
|
868
877
|
return {
|
|
869
878
|
addChild: () => a.open(),
|
|
870
|
-
updateChild: (
|
|
879
|
+
updateChild: (o, r) => {
|
|
871
880
|
const m = t.children.map(
|
|
872
|
-
(
|
|
881
|
+
(D) => D.id === o ? r : D
|
|
873
882
|
);
|
|
874
883
|
i({ ...t, children: m });
|
|
875
884
|
},
|
|
876
|
-
deleteChild: (
|
|
877
|
-
const r = t.children.filter((m) => m.id !==
|
|
885
|
+
deleteChild: (o) => {
|
|
886
|
+
const r = t.children.filter((m) => m.id !== o);
|
|
878
887
|
i({ ...t, children: r });
|
|
879
888
|
},
|
|
880
889
|
addChildDialog: {
|
|
@@ -885,31 +894,29 @@ function rt(t, i) {
|
|
|
885
894
|
}
|
|
886
895
|
};
|
|
887
896
|
}
|
|
888
|
-
function
|
|
897
|
+
function Z({
|
|
889
898
|
property: t,
|
|
890
899
|
onUpdate: i,
|
|
891
900
|
onDelete: a,
|
|
892
901
|
level: l = 1,
|
|
893
|
-
isArrayItem: n = !1
|
|
894
|
-
showRegex: d = !1,
|
|
895
|
-
keyEditable: r = !1
|
|
902
|
+
isArrayItem: n = !1
|
|
896
903
|
}) {
|
|
897
|
-
const { getTypeLabel:
|
|
904
|
+
const { getTypeLabel: o, typeLabels: r, showRegex: m, keyEditable: D } = Ie(), p = re(), g = ce(
|
|
898
905
|
t.title || t.key || "",
|
|
899
|
-
(
|
|
906
|
+
(f) => i({ ...t, title: f }),
|
|
900
907
|
{ allowEmpty: !1 }
|
|
901
|
-
), u =
|
|
908
|
+
), u = ce(
|
|
902
909
|
t.description || "",
|
|
903
|
-
(
|
|
910
|
+
(f) => i({ ...t, description: f || void 0 }),
|
|
904
911
|
{ allowEmpty: !0 }
|
|
905
|
-
),
|
|
912
|
+
), b = dt(t, i), v = ct(t, i), y = `h${Math.min(l, 6)}`, d = t.type === "object", k = d && t.children && t.children.length > 0, E = {
|
|
906
913
|
1: "text-lg font-semibold",
|
|
907
914
|
2: "text-base",
|
|
908
915
|
3: "text-base",
|
|
909
916
|
4: "text-base",
|
|
910
917
|
5: "text-sm",
|
|
911
918
|
6: "text-sm"
|
|
912
|
-
}[l] || "text-sm",
|
|
919
|
+
}[l] || "text-sm", R = {
|
|
913
920
|
1: "h-5 w-5",
|
|
914
921
|
2: "h-4 w-4",
|
|
915
922
|
3: "h-4 w-4",
|
|
@@ -928,112 +935,112 @@ function Q({
|
|
|
928
935
|
title: t.required ? "Required field - click to make optional" : "Optional field - click to make required",
|
|
929
936
|
children: t.required ? (
|
|
930
937
|
// <span className="block w-4 h-4 rounded-full bg-primary"></span>
|
|
931
|
-
/* @__PURE__ */ e(
|
|
938
|
+
/* @__PURE__ */ e(oe, { className: "w-6 h-6 text-primary" })
|
|
932
939
|
) : (
|
|
933
940
|
// <span className="block w-4 h-4 rounded-full border border-dashed border-gray-400"></span>
|
|
934
|
-
/* @__PURE__ */ e(
|
|
941
|
+
/* @__PURE__ */ e(oe, { className: "w-6 h-6 text-border" })
|
|
935
942
|
)
|
|
936
943
|
}
|
|
937
944
|
),
|
|
938
|
-
|
|
939
|
-
|
|
945
|
+
g.isEditing ? /* @__PURE__ */ e(
|
|
946
|
+
T,
|
|
940
947
|
{
|
|
941
|
-
value:
|
|
942
|
-
onChange: (
|
|
943
|
-
onBlur:
|
|
944
|
-
onKeyDown:
|
|
948
|
+
value: g.value,
|
|
949
|
+
onChange: (f) => g.handleChange(f.target.value),
|
|
950
|
+
onBlur: g.handleBlur,
|
|
951
|
+
onKeyDown: g.handleKeyDown,
|
|
945
952
|
autoFocus: !0,
|
|
946
|
-
className:
|
|
953
|
+
className: E,
|
|
947
954
|
placeholder: "Enter title"
|
|
948
955
|
}
|
|
949
956
|
) : /* @__PURE__ */ s("div", { className: "flex gap-2 flex-wrap flex-1", children: [
|
|
950
957
|
/* @__PURE__ */ s("div", { className: "flex items-start gap-2", children: [
|
|
951
958
|
/* @__PURE__ */ e(
|
|
952
|
-
|
|
959
|
+
y,
|
|
953
960
|
{
|
|
954
|
-
className: `${
|
|
955
|
-
onClick:
|
|
961
|
+
className: `${E} cursor-pointer hover:text-primary transition-colors leading-none`,
|
|
962
|
+
onClick: g.startEdit,
|
|
956
963
|
children: t.title || t.key || /* @__PURE__ */ e("span", { className: "text-muted-foreground italic", children: "unnamed" })
|
|
957
964
|
}
|
|
958
965
|
),
|
|
959
|
-
|
|
960
|
-
|
|
966
|
+
b.isChangingType ? /* @__PURE__ */ s(
|
|
967
|
+
X,
|
|
961
968
|
{
|
|
962
969
|
value: t.type,
|
|
963
|
-
onValueChange: (
|
|
964
|
-
open:
|
|
965
|
-
onOpenChange:
|
|
970
|
+
onValueChange: (f) => b.handleTypeChange(f),
|
|
971
|
+
open: b.isChangingType,
|
|
972
|
+
onOpenChange: b.setIsChangingType,
|
|
966
973
|
children: [
|
|
967
|
-
/* @__PURE__ */ e(
|
|
968
|
-
/* @__PURE__ */ e(
|
|
974
|
+
/* @__PURE__ */ e(J, { className: "w-[140px] h-7", children: /* @__PURE__ */ e(G, {}) }),
|
|
975
|
+
/* @__PURE__ */ e(V, { children: b.availableTypes.map((f) => /* @__PURE__ */ e(I, { value: f, children: r[f] }, f)) })
|
|
969
976
|
]
|
|
970
977
|
}
|
|
971
|
-
) : /* @__PURE__ */ e(
|
|
972
|
-
/* @__PURE__ */ e(
|
|
978
|
+
) : /* @__PURE__ */ e(We, { children: /* @__PURE__ */ s(Ye, { children: [
|
|
979
|
+
/* @__PURE__ */ e(Ze, { asChild: !0, children: /* @__PURE__ */ s(
|
|
973
980
|
"button",
|
|
974
981
|
{
|
|
975
|
-
onClick: () =>
|
|
982
|
+
onClick: () => b.setIsChangingType(!0),
|
|
976
983
|
className: "cursor-pointer hover:bg-accent rounded p-0.5 -mt-0.5 transition-colors",
|
|
977
984
|
children: [
|
|
978
985
|
t.type === "string" && /* @__PURE__ */ e(
|
|
979
|
-
|
|
986
|
+
ze,
|
|
980
987
|
{
|
|
981
988
|
className: h(
|
|
982
|
-
|
|
989
|
+
R,
|
|
983
990
|
"text-muted-foreground"
|
|
984
991
|
)
|
|
985
992
|
}
|
|
986
993
|
),
|
|
987
994
|
t.type === "number" && /* @__PURE__ */ e(
|
|
988
|
-
|
|
995
|
+
de,
|
|
989
996
|
{
|
|
990
997
|
className: h(
|
|
991
|
-
|
|
998
|
+
R,
|
|
992
999
|
"text-muted-foreground"
|
|
993
1000
|
)
|
|
994
1001
|
}
|
|
995
1002
|
),
|
|
996
1003
|
t.type === "integer" && /* @__PURE__ */ e(
|
|
997
|
-
|
|
1004
|
+
de,
|
|
998
1005
|
{
|
|
999
1006
|
className: h(
|
|
1000
|
-
|
|
1007
|
+
R,
|
|
1001
1008
|
"text-muted-foreground"
|
|
1002
1009
|
)
|
|
1003
1010
|
}
|
|
1004
1011
|
),
|
|
1005
1012
|
t.type === "boolean" && /* @__PURE__ */ e(
|
|
1006
|
-
|
|
1013
|
+
Be,
|
|
1007
1014
|
{
|
|
1008
1015
|
className: h(
|
|
1009
|
-
|
|
1016
|
+
R,
|
|
1010
1017
|
"text-muted-foreground"
|
|
1011
1018
|
)
|
|
1012
1019
|
}
|
|
1013
1020
|
),
|
|
1014
1021
|
t.type === "object" && /* @__PURE__ */ e(
|
|
1015
|
-
|
|
1022
|
+
Ae,
|
|
1016
1023
|
{
|
|
1017
1024
|
className: h(
|
|
1018
|
-
|
|
1025
|
+
R,
|
|
1019
1026
|
"text-muted-foreground"
|
|
1020
1027
|
)
|
|
1021
1028
|
}
|
|
1022
1029
|
),
|
|
1023
1030
|
t.type === "array" && /* @__PURE__ */ e(
|
|
1024
|
-
|
|
1031
|
+
Me,
|
|
1025
1032
|
{
|
|
1026
1033
|
className: h(
|
|
1027
|
-
|
|
1034
|
+
R,
|
|
1028
1035
|
"text-muted-foreground"
|
|
1029
1036
|
)
|
|
1030
1037
|
}
|
|
1031
1038
|
),
|
|
1032
1039
|
t.type === "file" && /* @__PURE__ */ e(
|
|
1033
|
-
|
|
1040
|
+
$e,
|
|
1034
1041
|
{
|
|
1035
1042
|
className: h(
|
|
1036
|
-
|
|
1043
|
+
R,
|
|
1037
1044
|
"text-muted-foreground"
|
|
1038
1045
|
)
|
|
1039
1046
|
}
|
|
@@ -1041,36 +1048,36 @@ function Q({
|
|
|
1041
1048
|
]
|
|
1042
1049
|
}
|
|
1043
1050
|
) }),
|
|
1044
|
-
/* @__PURE__ */ s(
|
|
1045
|
-
|
|
1046
|
-
t.type === "array" && t.items ? ` of ${
|
|
1051
|
+
/* @__PURE__ */ s(ge, { children: [
|
|
1052
|
+
o(t.type),
|
|
1053
|
+
t.type === "array" && t.items ? ` of ${o(t.items.type)}` : "",
|
|
1047
1054
|
/* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground mt-1", children: "Click to change type" })
|
|
1048
1055
|
] })
|
|
1049
1056
|
] }) }),
|
|
1050
1057
|
t.type === "object" && /* @__PURE__ */ e(
|
|
1051
|
-
|
|
1058
|
+
S,
|
|
1052
1059
|
{
|
|
1053
1060
|
variant: "ghost",
|
|
1054
1061
|
size: "icon",
|
|
1055
1062
|
className: "h-4 w-4",
|
|
1056
|
-
onClick:
|
|
1063
|
+
onClick: v.addChild,
|
|
1057
1064
|
"data-testid": `button-add-child-${t.id}`,
|
|
1058
1065
|
children: /* @__PURE__ */ e(B, {})
|
|
1059
1066
|
}
|
|
1060
1067
|
)
|
|
1061
1068
|
] }),
|
|
1062
1069
|
/* @__PURE__ */ e("div", { className: "flex-1", children: u.isEditing ? /* @__PURE__ */ e(
|
|
1063
|
-
|
|
1070
|
+
T,
|
|
1064
1071
|
{
|
|
1065
1072
|
value: u.value,
|
|
1066
|
-
onChange: (
|
|
1073
|
+
onChange: (f) => u.handleChange(f.target.value),
|
|
1067
1074
|
onBlur: u.handleBlur,
|
|
1068
1075
|
onKeyDown: u.handleKeyDown,
|
|
1069
1076
|
autoFocus: !0,
|
|
1070
1077
|
className: "text-sm flex-1",
|
|
1071
1078
|
placeholder: "Enter description"
|
|
1072
1079
|
}
|
|
1073
|
-
) : /* @__PURE__ */ e(
|
|
1080
|
+
) : /* @__PURE__ */ e(me, { children: t.description ? /* @__PURE__ */ e(
|
|
1074
1081
|
"p",
|
|
1075
1082
|
{
|
|
1076
1083
|
className: "text-sm text-muted-foreground flex-1 min-w-[200px] cursor-pointer hover:text-foreground transition-colors",
|
|
@@ -1090,55 +1097,53 @@ function Q({
|
|
|
1090
1097
|
] }) }),
|
|
1091
1098
|
/* @__PURE__ */ s("div", { className: "flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0", children: [
|
|
1092
1099
|
/* @__PURE__ */ e(
|
|
1093
|
-
|
|
1100
|
+
S,
|
|
1094
1101
|
{
|
|
1095
1102
|
variant: "ghost",
|
|
1096
1103
|
size: "icon",
|
|
1097
1104
|
className: "h-7 w-7",
|
|
1098
|
-
onClick: () =>
|
|
1105
|
+
onClick: () => p.open(t),
|
|
1099
1106
|
"data-testid": `button-edit-${t.id}`,
|
|
1100
|
-
children: /* @__PURE__ */ e(
|
|
1107
|
+
children: /* @__PURE__ */ e(Ke, { className: "w-3 h-3" })
|
|
1101
1108
|
}
|
|
1102
1109
|
),
|
|
1103
|
-
|
|
1104
|
-
|
|
1110
|
+
d && t.type !== "object" && /* @__PURE__ */ e(
|
|
1111
|
+
S,
|
|
1105
1112
|
{
|
|
1106
1113
|
variant: "ghost",
|
|
1107
1114
|
size: "icon",
|
|
1108
1115
|
className: "h-7 w-7",
|
|
1109
|
-
onClick:
|
|
1116
|
+
onClick: v.addChild,
|
|
1110
1117
|
"data-testid": `button-add-child-${t.id}`,
|
|
1111
1118
|
children: /* @__PURE__ */ e(B, { className: "w-3 h-3" })
|
|
1112
1119
|
}
|
|
1113
1120
|
),
|
|
1114
1121
|
/* @__PURE__ */ e(
|
|
1115
|
-
|
|
1122
|
+
S,
|
|
1116
1123
|
{
|
|
1117
1124
|
variant: "ghost",
|
|
1118
1125
|
size: "icon",
|
|
1119
1126
|
className: "h-7 w-7 text-muted-foreground hover:text-destructive",
|
|
1120
1127
|
onClick: a,
|
|
1121
1128
|
"data-testid": `button-delete-${t.id}`,
|
|
1122
|
-
children: /* @__PURE__ */ e(
|
|
1129
|
+
children: /* @__PURE__ */ e(fe, { className: "w-3 h-3" })
|
|
1123
1130
|
}
|
|
1124
1131
|
)
|
|
1125
1132
|
] })
|
|
1126
1133
|
] }),
|
|
1127
|
-
|
|
1134
|
+
k && /* @__PURE__ */ e(
|
|
1128
1135
|
"div",
|
|
1129
1136
|
{
|
|
1130
1137
|
className: l === 1 ? "ml-6 mt-1 border-l-2 border-border pl-6" : "ml-4 mt-1 border-l border-border pl-4",
|
|
1131
|
-
children: t.children.map((
|
|
1132
|
-
|
|
1138
|
+
children: t.children.map((f) => /* @__PURE__ */ e(
|
|
1139
|
+
Z,
|
|
1133
1140
|
{
|
|
1134
|
-
property:
|
|
1135
|
-
onUpdate: (
|
|
1136
|
-
onDelete: () =>
|
|
1137
|
-
level: l + 1
|
|
1138
|
-
showRegex: d,
|
|
1139
|
-
keyEditable: r
|
|
1141
|
+
property: f,
|
|
1142
|
+
onUpdate: (O) => v.updateChild(f.id, O),
|
|
1143
|
+
onDelete: () => v.deleteChild(f.id),
|
|
1144
|
+
level: l + 1
|
|
1140
1145
|
},
|
|
1141
|
-
|
|
1146
|
+
f.id
|
|
1142
1147
|
))
|
|
1143
1148
|
}
|
|
1144
1149
|
),
|
|
@@ -1148,54 +1153,48 @@ function Q({
|
|
|
1148
1153
|
className: l === 1 ? "ml-6 mt-1 border-l-2 border-border pl-6" : "ml-4 mt-1 border-l border-border pl-4",
|
|
1149
1154
|
children: [
|
|
1150
1155
|
/* @__PURE__ */ s("div", { className: "mb-2 text-xs text-muted-foreground font-semibold uppercase", children: [
|
|
1151
|
-
|
|
1156
|
+
o("array"),
|
|
1152
1157
|
" Items"
|
|
1153
1158
|
] }),
|
|
1154
1159
|
/* @__PURE__ */ e(
|
|
1155
|
-
|
|
1160
|
+
Z,
|
|
1156
1161
|
{
|
|
1157
1162
|
property: t.items,
|
|
1158
|
-
onUpdate: (
|
|
1163
|
+
onUpdate: (f) => i({ ...t, items: f }),
|
|
1159
1164
|
onDelete: () => i({ ...t, items: void 0 }),
|
|
1160
1165
|
level: l + 1,
|
|
1161
|
-
isArrayItem: !0
|
|
1162
|
-
showRegex: d,
|
|
1163
|
-
keyEditable: r
|
|
1166
|
+
isArrayItem: !0
|
|
1164
1167
|
}
|
|
1165
1168
|
)
|
|
1166
1169
|
]
|
|
1167
1170
|
}
|
|
1168
1171
|
),
|
|
1169
1172
|
/* @__PURE__ */ e(
|
|
1170
|
-
|
|
1173
|
+
Y,
|
|
1171
1174
|
{
|
|
1172
|
-
property:
|
|
1173
|
-
open:
|
|
1174
|
-
onOpenChange:
|
|
1175
|
-
onSave: (
|
|
1176
|
-
i(
|
|
1175
|
+
property: p.data || t,
|
|
1176
|
+
open: p.isOpen,
|
|
1177
|
+
onOpenChange: p.setIsOpen,
|
|
1178
|
+
onSave: (f) => {
|
|
1179
|
+
i(f), p.close();
|
|
1177
1180
|
},
|
|
1178
1181
|
isArrayItem: n,
|
|
1179
|
-
isNewProperty: !1
|
|
1180
|
-
showRegex: d,
|
|
1181
|
-
keyEditable: r
|
|
1182
|
+
isNewProperty: !1
|
|
1182
1183
|
}
|
|
1183
1184
|
),
|
|
1184
|
-
|
|
1185
|
-
|
|
1185
|
+
v.addChildDialog.isOpen && v.addChildDialog.data && /* @__PURE__ */ e(
|
|
1186
|
+
Y,
|
|
1186
1187
|
{
|
|
1187
|
-
property:
|
|
1188
|
-
open:
|
|
1188
|
+
property: v.addChildDialog.data,
|
|
1189
|
+
open: v.addChildDialog.isOpen,
|
|
1189
1190
|
isNewProperty: !0,
|
|
1190
|
-
onOpenChange:
|
|
1191
|
-
onSave:
|
|
1192
|
-
showRegex: d,
|
|
1193
|
-
keyEditable: r
|
|
1191
|
+
onOpenChange: v.addChildDialog.setIsOpen,
|
|
1192
|
+
onSave: v.addChildDialog.confirm
|
|
1194
1193
|
}
|
|
1195
1194
|
)
|
|
1196
1195
|
] });
|
|
1197
1196
|
}
|
|
1198
|
-
const
|
|
1197
|
+
const le = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
1199
1198
|
"div",
|
|
1200
1199
|
{
|
|
1201
1200
|
ref: a,
|
|
@@ -1203,8 +1202,8 @@ const ne = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
1203
1202
|
...i
|
|
1204
1203
|
}
|
|
1205
1204
|
));
|
|
1206
|
-
|
|
1207
|
-
const
|
|
1205
|
+
le.displayName = "Card";
|
|
1206
|
+
const mt = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
1208
1207
|
"div",
|
|
1209
1208
|
{
|
|
1210
1209
|
ref: a,
|
|
@@ -1212,8 +1211,8 @@ const lt = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
1212
1211
|
...i
|
|
1213
1212
|
}
|
|
1214
1213
|
));
|
|
1215
|
-
|
|
1216
|
-
const
|
|
1214
|
+
mt.displayName = "CardHeader";
|
|
1215
|
+
const ut = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
1217
1216
|
"div",
|
|
1218
1217
|
{
|
|
1219
1218
|
ref: a,
|
|
@@ -1221,8 +1220,8 @@ const dt = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
1221
1220
|
...i
|
|
1222
1221
|
}
|
|
1223
1222
|
));
|
|
1224
|
-
|
|
1225
|
-
const
|
|
1223
|
+
ut.displayName = "CardTitle";
|
|
1224
|
+
const ht = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
1226
1225
|
"div",
|
|
1227
1226
|
{
|
|
1228
1227
|
ref: a,
|
|
@@ -1230,10 +1229,10 @@ const ot = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
1230
1229
|
...i
|
|
1231
1230
|
}
|
|
1232
1231
|
));
|
|
1233
|
-
|
|
1234
|
-
const
|
|
1235
|
-
|
|
1236
|
-
const
|
|
1232
|
+
ht.displayName = "CardDescription";
|
|
1233
|
+
const ft = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e("div", { ref: a, className: h("p-6 pt-0", t), ...i }));
|
|
1234
|
+
ft.displayName = "CardContent";
|
|
1235
|
+
const pt = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
1237
1236
|
"div",
|
|
1238
1237
|
{
|
|
1239
1238
|
ref: a,
|
|
@@ -1241,8 +1240,8 @@ const mt = b.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
|
1241
1240
|
...i
|
|
1242
1241
|
}
|
|
1243
1242
|
));
|
|
1244
|
-
|
|
1245
|
-
const
|
|
1243
|
+
pt.displayName = "CardFooter";
|
|
1244
|
+
const gt = () => new Promise((t, i) => {
|
|
1246
1245
|
const a = document.createElement("input");
|
|
1247
1246
|
a.type = "file", a.accept = ".json", a.onchange = (l) => {
|
|
1248
1247
|
const n = l.target.files?.[0];
|
|
@@ -1250,28 +1249,28 @@ const ut = () => new Promise((t, i) => {
|
|
|
1250
1249
|
i(new Error("No file selected"));
|
|
1251
1250
|
return;
|
|
1252
1251
|
}
|
|
1253
|
-
const
|
|
1254
|
-
|
|
1252
|
+
const o = new FileReader();
|
|
1253
|
+
o.onload = (r) => {
|
|
1255
1254
|
try {
|
|
1256
1255
|
const m = JSON.parse(r.target?.result);
|
|
1257
1256
|
t(m);
|
|
1258
1257
|
} catch {
|
|
1259
1258
|
i(new Error("Invalid JSON file"));
|
|
1260
1259
|
}
|
|
1261
|
-
},
|
|
1260
|
+
}, o.onerror = () => i(new Error("Failed to read file")), o.readAsText(n);
|
|
1262
1261
|
}, a.click();
|
|
1263
|
-
}),
|
|
1264
|
-
const a = JSON.stringify(t, null, 2), l = new Blob([a], { type: "application/json" }), n = URL.createObjectURL(l),
|
|
1265
|
-
|
|
1262
|
+
}), Se = (t, i = "schema.json") => {
|
|
1263
|
+
const a = JSON.stringify(t, null, 2), l = new Blob([a], { type: "application/json" }), n = URL.createObjectURL(l), o = document.createElement("a");
|
|
1264
|
+
o.href = n, o.download = i, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(n);
|
|
1266
1265
|
};
|
|
1267
|
-
function
|
|
1268
|
-
const [i, a] =
|
|
1266
|
+
function yt({ schema: t }) {
|
|
1267
|
+
const [i, a] = q(!1), l = JSON.stringify(t, null, 2);
|
|
1269
1268
|
return /* @__PURE__ */ s("div", { className: "h-full flex flex-col", children: [
|
|
1270
1269
|
/* @__PURE__ */ s("div", { className: "flex items-center justify-between p-4 border-b", children: [
|
|
1271
1270
|
/* @__PURE__ */ e("h2", { className: "text-sm font-medium", children: "JSON Schema Output" }),
|
|
1272
1271
|
/* @__PURE__ */ s("div", { className: "flex gap-2", children: [
|
|
1273
1272
|
/* @__PURE__ */ e(
|
|
1274
|
-
|
|
1273
|
+
S,
|
|
1275
1274
|
{
|
|
1276
1275
|
variant: "outline",
|
|
1277
1276
|
size: "sm",
|
|
@@ -1279,24 +1278,24 @@ function ht({ schema: t }) {
|
|
|
1279
1278
|
await navigator.clipboard.writeText(l), a(!0), setTimeout(() => a(!1), 2e3);
|
|
1280
1279
|
},
|
|
1281
1280
|
"data-testid": "button-copy",
|
|
1282
|
-
children: i ? /* @__PURE__ */ e(
|
|
1281
|
+
children: i ? /* @__PURE__ */ e(Je, { className: "w-4 h-4" }) : /* @__PURE__ */ e(Ve, { className: "w-4 h-4" })
|
|
1283
1282
|
}
|
|
1284
1283
|
),
|
|
1285
1284
|
/* @__PURE__ */ e(
|
|
1286
|
-
|
|
1285
|
+
S,
|
|
1287
1286
|
{
|
|
1288
1287
|
variant: "outline",
|
|
1289
1288
|
size: "sm",
|
|
1290
1289
|
onClick: () => {
|
|
1291
|
-
|
|
1290
|
+
Se(t, "schema.json");
|
|
1292
1291
|
},
|
|
1293
1292
|
"data-testid": "button-download",
|
|
1294
|
-
children: /* @__PURE__ */ e(
|
|
1293
|
+
children: /* @__PURE__ */ e(He, { className: "w-4 h-4" })
|
|
1295
1294
|
}
|
|
1296
1295
|
)
|
|
1297
1296
|
] })
|
|
1298
1297
|
] }),
|
|
1299
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: /* @__PURE__ */ e(
|
|
1298
|
+
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: /* @__PURE__ */ e(le, { className: "m-4 bg-muted/30", children: /* @__PURE__ */ e(
|
|
1300
1299
|
"pre",
|
|
1301
1300
|
{
|
|
1302
1301
|
className: "p-6 text-xs font-mono overflow-auto",
|
|
@@ -1306,24 +1305,24 @@ function ht({ schema: t }) {
|
|
|
1306
1305
|
) }) })
|
|
1307
1306
|
] });
|
|
1308
1307
|
}
|
|
1309
|
-
function
|
|
1308
|
+
function vt({
|
|
1310
1309
|
title: t,
|
|
1311
1310
|
description: i,
|
|
1312
1311
|
version: a,
|
|
1313
1312
|
onUpdate: l
|
|
1314
1313
|
}) {
|
|
1315
|
-
const [n,
|
|
1316
|
-
return /* @__PURE__ */ s(
|
|
1314
|
+
const [n, o] = q(!1);
|
|
1315
|
+
return /* @__PURE__ */ s(le, { className: "p-4", children: [
|
|
1317
1316
|
/* @__PURE__ */ s(
|
|
1318
|
-
|
|
1317
|
+
S,
|
|
1319
1318
|
{
|
|
1320
1319
|
variant: "ghost",
|
|
1321
|
-
onClick: () =>
|
|
1320
|
+
onClick: () => o(!n),
|
|
1322
1321
|
className: "w-full justify-between px-2 h-auto hover:bg-transparent",
|
|
1323
1322
|
"data-testid": "button-toggle-metadata",
|
|
1324
1323
|
children: [
|
|
1325
1324
|
/* @__PURE__ */ e("h3", { className: "text-sm font-medium", children: "Schema Metadata" }),
|
|
1326
|
-
n ? /* @__PURE__ */ e(
|
|
1325
|
+
n ? /* @__PURE__ */ e(ie, { className: "w-4 h-4" }) : /* @__PURE__ */ e(_e, { className: "w-4 h-4" })
|
|
1327
1326
|
]
|
|
1328
1327
|
}
|
|
1329
1328
|
),
|
|
@@ -1338,7 +1337,7 @@ function ft({
|
|
|
1338
1337
|
}
|
|
1339
1338
|
),
|
|
1340
1339
|
/* @__PURE__ */ e(
|
|
1341
|
-
|
|
1340
|
+
T,
|
|
1342
1341
|
{
|
|
1343
1342
|
id: "schema-title",
|
|
1344
1343
|
placeholder: "My Schema",
|
|
@@ -1358,7 +1357,7 @@ function ft({
|
|
|
1358
1357
|
}
|
|
1359
1358
|
),
|
|
1360
1359
|
/* @__PURE__ */ e(
|
|
1361
|
-
|
|
1360
|
+
ne,
|
|
1362
1361
|
{
|
|
1363
1362
|
id: "schema-description",
|
|
1364
1363
|
placeholder: "Describe your schema...",
|
|
@@ -1380,7 +1379,7 @@ function ft({
|
|
|
1380
1379
|
}
|
|
1381
1380
|
),
|
|
1382
1381
|
/* @__PURE__ */ e(
|
|
1383
|
-
|
|
1382
|
+
T,
|
|
1384
1383
|
{
|
|
1385
1384
|
id: "schema-version",
|
|
1386
1385
|
placeholder: "1.0.0",
|
|
@@ -1393,30 +1392,30 @@ function ft({
|
|
|
1393
1392
|
] })
|
|
1394
1393
|
] });
|
|
1395
1394
|
}
|
|
1396
|
-
const
|
|
1395
|
+
const $ = (t, i, a = !0) => {
|
|
1397
1396
|
const l = {
|
|
1398
1397
|
type: "object"
|
|
1399
1398
|
};
|
|
1400
1399
|
a && i && (i.title && (l.title = i.title), i.description && (l.description = i.description));
|
|
1401
|
-
const n =
|
|
1400
|
+
const n = ee(t);
|
|
1402
1401
|
Object.keys(n).length > 0 && (l.properties = n);
|
|
1403
|
-
const
|
|
1404
|
-
return
|
|
1405
|
-
},
|
|
1402
|
+
const o = t.filter((r) => r.required && r.key).map((r) => r.key);
|
|
1403
|
+
return o.length > 0 && (l.required = o), l;
|
|
1404
|
+
}, ee = (t) => {
|
|
1406
1405
|
const i = {};
|
|
1407
1406
|
return t.forEach((a) => {
|
|
1408
1407
|
if (!a.key) return;
|
|
1409
1408
|
const n = { type: a.type === "file" ? "string" : a.type };
|
|
1410
|
-
if (a.title && (n.title = a.title), a.description && (n.description = a.description), a.type === "file" && (n.format = "filename"), a.type === "string" && (a.minLength !== void 0 && (n.minLength = a.minLength), a.maxLength !== void 0 && (n.maxLength = a.maxLength), a.pattern && (n.pattern = a.pattern), a.enum && a.enum.length > 0 && (n.enum = a.enum)), (a.type === "number" || a.type === "integer") && (a.minimum !== void 0 && (n.minimum = a.minimum), a.maximum !== void 0 && (n.maximum = a.maximum)), a.type === "array" && (a.minItems !== void 0 && (n.minItems = a.minItems), a.maxItems !== void 0 && (n.maxItems = a.maxItems), a.uniqueItems && (n.uniqueItems = a.uniqueItems), a.items && (n.items =
|
|
1409
|
+
if (a.title && (n.title = a.title), a.description && (n.description = a.description), a.type === "file" && (n.format = "filename"), a.type === "string" && (a.minLength !== void 0 && (n.minLength = a.minLength), a.maxLength !== void 0 && (n.maxLength = a.maxLength), a.pattern && (n.pattern = a.pattern), a.enum && a.enum.length > 0 && (n.enum = a.enum)), (a.type === "number" || a.type === "integer") && (a.minimum !== void 0 && (n.minimum = a.minimum), a.maximum !== void 0 && (n.maximum = a.maximum)), a.type === "array" && (a.minItems !== void 0 && (n.minItems = a.minItems), a.maxItems !== void 0 && (n.maxItems = a.maxItems), a.uniqueItems && (n.uniqueItems = a.uniqueItems), a.items && (n.items = ee([a.items])[a.items.key] || {
|
|
1411
1410
|
type: a.items.type
|
|
1412
1411
|
})), a.type === "object" && a.children && a.children.length > 0) {
|
|
1413
|
-
n.properties =
|
|
1414
|
-
const
|
|
1415
|
-
|
|
1412
|
+
n.properties = ee(a.children);
|
|
1413
|
+
const o = a.children.filter((r) => r.required && r.key).map((r) => r.key);
|
|
1414
|
+
o.length > 0 && (n.required = o);
|
|
1416
1415
|
}
|
|
1417
1416
|
i[a.key] = n;
|
|
1418
1417
|
}), i;
|
|
1419
|
-
},
|
|
1418
|
+
}, xt = (t) => {
|
|
1420
1419
|
const i = {
|
|
1421
1420
|
properties: []
|
|
1422
1421
|
};
|
|
@@ -1425,107 +1424,107 @@ const M = (t, i, a = !0) => {
|
|
|
1425
1424
|
description: typeof t.description == "string" ? t.description : "",
|
|
1426
1425
|
version: "1.0.0"
|
|
1427
1426
|
// Default version
|
|
1428
|
-
}), t.properties && typeof t.properties == "object" && (i.properties =
|
|
1427
|
+
}), t.properties && typeof t.properties == "object" && (i.properties = te(
|
|
1429
1428
|
t.properties,
|
|
1430
1429
|
Array.isArray(t.required) ? t.required : []
|
|
1431
1430
|
)), i;
|
|
1432
|
-
},
|
|
1431
|
+
}, te = (t, i = []) => t ? Object.entries(t).filter(([, a]) => typeof a == "object").map(([a, l]) => {
|
|
1433
1432
|
const n = l;
|
|
1434
|
-
let
|
|
1435
|
-
|
|
1433
|
+
let o = typeof n.type == "string" ? n.type : "string";
|
|
1434
|
+
o === "string" && n.format === "filename" && (o = "file");
|
|
1436
1435
|
const r = {
|
|
1437
|
-
id:
|
|
1436
|
+
id: se(),
|
|
1438
1437
|
key: a,
|
|
1439
1438
|
title: typeof n.title == "string" ? n.title : void 0,
|
|
1440
|
-
type:
|
|
1439
|
+
type: o,
|
|
1441
1440
|
description: typeof n.description == "string" ? n.description : void 0,
|
|
1442
1441
|
required: i.includes(a)
|
|
1443
1442
|
};
|
|
1444
|
-
return n.minLength !== void 0 && (r.minLength = n.minLength), n.maxLength !== void 0 && (r.maxLength = n.maxLength), n.pattern && (r.pattern = n.pattern), n.enum && Array.isArray(n.enum) && (r.enum = n.enum), n.minimum !== void 0 && (r.minimum = n.minimum), n.maximum !== void 0 && (r.maximum = n.maximum), n.minItems !== void 0 && (r.minItems = n.minItems), n.maxItems !== void 0 && (r.maxItems = n.maxItems), n.uniqueItems && (r.uniqueItems = n.uniqueItems), r.type === "array" && n.items && typeof n.items == "object" && !Array.isArray(n.items) && (r.items =
|
|
1443
|
+
return n.minLength !== void 0 && (r.minLength = n.minLength), n.maxLength !== void 0 && (r.maxLength = n.maxLength), n.pattern && (r.pattern = n.pattern), n.enum && Array.isArray(n.enum) && (r.enum = n.enum), n.minimum !== void 0 && (r.minimum = n.minimum), n.maximum !== void 0 && (r.maximum = n.maximum), n.minItems !== void 0 && (r.minItems = n.minItems), n.maxItems !== void 0 && (r.maxItems = n.maxItems), n.uniqueItems && (r.uniqueItems = n.uniqueItems), r.type === "array" && n.items && typeof n.items == "object" && !Array.isArray(n.items) && (r.items = te(
|
|
1445
1444
|
{ item: n.items },
|
|
1446
1445
|
[]
|
|
1447
|
-
).find((m) => m.key === "item")), n.properties && typeof n.properties == "object" && (r.children =
|
|
1446
|
+
).find((m) => m.key === "item")), n.properties && typeof n.properties == "object" && (r.children = te(
|
|
1448
1447
|
n.properties,
|
|
1449
1448
|
Array.isArray(n.required) ? n.required : []
|
|
1450
1449
|
)), r;
|
|
1451
|
-
}) : [],
|
|
1450
|
+
}) : [], bt = ({
|
|
1452
1451
|
schema: t,
|
|
1453
1452
|
onChange: i,
|
|
1454
1453
|
includeMetadata: a = !0
|
|
1455
1454
|
}) => {
|
|
1456
|
-
const { properties: l, metadata: n } =
|
|
1457
|
-
() =>
|
|
1455
|
+
const { properties: l, metadata: n } = Le(
|
|
1456
|
+
() => xt(t),
|
|
1458
1457
|
[t]
|
|
1459
|
-
),
|
|
1458
|
+
), o = l, r = n || {
|
|
1460
1459
|
title: "",
|
|
1461
1460
|
description: "",
|
|
1462
1461
|
version: ""
|
|
1463
|
-
}, m =
|
|
1464
|
-
id:
|
|
1462
|
+
}, m = P(() => ({
|
|
1463
|
+
id: se(),
|
|
1465
1464
|
key: "",
|
|
1466
1465
|
type: "string",
|
|
1467
1466
|
required: !1
|
|
1468
|
-
}), []),
|
|
1469
|
-
(
|
|
1470
|
-
const
|
|
1471
|
-
let
|
|
1472
|
-
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1467
|
+
}), []), D = P(
|
|
1468
|
+
(y, d) => {
|
|
1469
|
+
const k = o.some((f) => f.id === y);
|
|
1470
|
+
let E;
|
|
1471
|
+
k ? E = o.map((f) => f.id === y ? d : f) : E = [...o, d];
|
|
1472
|
+
const R = $(
|
|
1473
|
+
E,
|
|
1475
1474
|
r,
|
|
1476
1475
|
a
|
|
1477
1476
|
);
|
|
1478
|
-
i(
|
|
1477
|
+
i(R);
|
|
1479
1478
|
},
|
|
1480
|
-
[
|
|
1481
|
-
),
|
|
1482
|
-
(
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1479
|
+
[o, r, a, i]
|
|
1480
|
+
), p = P(
|
|
1481
|
+
(y) => {
|
|
1482
|
+
const d = o.filter((E) => E.id !== y), k = $(
|
|
1483
|
+
d,
|
|
1485
1484
|
r,
|
|
1486
1485
|
a
|
|
1487
1486
|
);
|
|
1488
|
-
i(
|
|
1487
|
+
i(k);
|
|
1489
1488
|
},
|
|
1490
|
-
[
|
|
1491
|
-
),
|
|
1492
|
-
const
|
|
1493
|
-
i(
|
|
1494
|
-
}, [a, i]), u =
|
|
1495
|
-
(
|
|
1496
|
-
const
|
|
1497
|
-
|
|
1498
|
-
|
|
1489
|
+
[o, r, a, i]
|
|
1490
|
+
), g = P(() => {
|
|
1491
|
+
const d = $([], { title: "", description: "" }, a);
|
|
1492
|
+
i(d);
|
|
1493
|
+
}, [a, i]), u = P(
|
|
1494
|
+
(y, d) => {
|
|
1495
|
+
const k = { ...r, [y]: d }, E = $(
|
|
1496
|
+
o,
|
|
1497
|
+
k,
|
|
1499
1498
|
a
|
|
1500
1499
|
);
|
|
1501
|
-
i(
|
|
1500
|
+
i(E);
|
|
1502
1501
|
},
|
|
1503
|
-
[
|
|
1504
|
-
),
|
|
1505
|
-
const
|
|
1506
|
-
i(
|
|
1507
|
-
}, [i]),
|
|
1508
|
-
|
|
1502
|
+
[o, r, a, i]
|
|
1503
|
+
), b = P(async () => {
|
|
1504
|
+
const y = await gt();
|
|
1505
|
+
i(y);
|
|
1506
|
+
}, [i]), v = P(() => {
|
|
1507
|
+
Se(t, "schema.json");
|
|
1509
1508
|
}, [t]);
|
|
1510
1509
|
return {
|
|
1511
|
-
properties:
|
|
1510
|
+
properties: o,
|
|
1512
1511
|
metadata: r,
|
|
1513
1512
|
addProperty: m,
|
|
1514
|
-
updateProperty:
|
|
1515
|
-
deleteProperty:
|
|
1516
|
-
clearAll:
|
|
1513
|
+
updateProperty: D,
|
|
1514
|
+
deleteProperty: p,
|
|
1515
|
+
clearAll: g,
|
|
1517
1516
|
updateMetadata: u,
|
|
1518
|
-
importSchema:
|
|
1519
|
-
downloadSchema:
|
|
1517
|
+
importSchema: b,
|
|
1518
|
+
downloadSchema: v
|
|
1520
1519
|
};
|
|
1521
1520
|
};
|
|
1522
|
-
function
|
|
1523
|
-
const [t, i] =
|
|
1524
|
-
return
|
|
1521
|
+
function Nt() {
|
|
1522
|
+
const [t, i] = q("light");
|
|
1523
|
+
return ae(() => {
|
|
1525
1524
|
const n = localStorage.getItem("theme") || (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
|
1526
1525
|
i(n), document.documentElement.classList.toggle("dark", n === "dark");
|
|
1527
1526
|
}, []), /* @__PURE__ */ e(
|
|
1528
|
-
|
|
1527
|
+
S,
|
|
1529
1528
|
{
|
|
1530
1529
|
variant: "ghost",
|
|
1531
1530
|
size: "icon",
|
|
@@ -1534,168 +1533,173 @@ function vt() {
|
|
|
1534
1533
|
i(l), localStorage.setItem("theme", l), document.documentElement.classList.toggle("dark", l === "dark");
|
|
1535
1534
|
},
|
|
1536
1535
|
"data-testid": "button-theme-toggle",
|
|
1537
|
-
children: t === "light" ? /* @__PURE__ */ e(
|
|
1536
|
+
children: t === "light" ? /* @__PURE__ */ e(Ue, { className: "w-4 h-4" }) : /* @__PURE__ */ e(Xe, { className: "w-4 h-4" })
|
|
1538
1537
|
}
|
|
1539
1538
|
);
|
|
1540
1539
|
}
|
|
1541
|
-
function
|
|
1540
|
+
function Rt({
|
|
1542
1541
|
schema: t,
|
|
1543
1542
|
onChange: i,
|
|
1544
1543
|
showMetadata: a = !1,
|
|
1545
1544
|
showImport: l = !0,
|
|
1546
1545
|
showClear: n = !0,
|
|
1547
|
-
showOutput:
|
|
1546
|
+
showOutput: o = !0,
|
|
1548
1547
|
showHeader: r = !0,
|
|
1549
1548
|
className: m = "",
|
|
1550
|
-
showSummary:
|
|
1551
|
-
typeLabels:
|
|
1552
|
-
propertyLabel:
|
|
1549
|
+
showSummary: D = !1,
|
|
1550
|
+
typeLabels: p,
|
|
1551
|
+
propertyLabel: g = { singular: "property", plural: "properties" },
|
|
1553
1552
|
showRegex: u = !1,
|
|
1554
|
-
keyEditable:
|
|
1553
|
+
keyEditable: b = !1
|
|
1555
1554
|
}) {
|
|
1556
1555
|
const {
|
|
1557
|
-
properties:
|
|
1558
|
-
metadata:
|
|
1559
|
-
addProperty:
|
|
1560
|
-
updateProperty:
|
|
1561
|
-
deleteProperty:
|
|
1562
|
-
clearAll:
|
|
1563
|
-
updateMetadata:
|
|
1564
|
-
importSchema:
|
|
1565
|
-
} =
|
|
1556
|
+
properties: v,
|
|
1557
|
+
metadata: y,
|
|
1558
|
+
addProperty: d,
|
|
1559
|
+
updateProperty: k,
|
|
1560
|
+
deleteProperty: E,
|
|
1561
|
+
clearAll: R,
|
|
1562
|
+
updateMetadata: f,
|
|
1563
|
+
importSchema: O
|
|
1564
|
+
} = bt({
|
|
1566
1565
|
schema: t,
|
|
1567
1566
|
onChange: i,
|
|
1568
1567
|
includeMetadata: a
|
|
1569
|
-
}),
|
|
1570
|
-
createInitialData: () =>
|
|
1571
|
-
onConfirm: (
|
|
1572
|
-
|
|
1568
|
+
}), C = re({
|
|
1569
|
+
createInitialData: () => d(),
|
|
1570
|
+
onConfirm: (c) => {
|
|
1571
|
+
k(c.id, c);
|
|
1573
1572
|
}
|
|
1574
|
-
}),
|
|
1575
|
-
|
|
1576
|
-
},
|
|
1577
|
-
await
|
|
1573
|
+
}), H = () => {
|
|
1574
|
+
R();
|
|
1575
|
+
}, _ = async () => {
|
|
1576
|
+
await O();
|
|
1578
1577
|
};
|
|
1579
|
-
return /* @__PURE__ */ e(
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
I,
|
|
1593
|
-
{
|
|
1594
|
-
variant: "outline",
|
|
1595
|
-
size: "sm",
|
|
1596
|
-
onClick: O,
|
|
1597
|
-
disabled: f.length === 0,
|
|
1598
|
-
"data-testid": "button-clear",
|
|
1599
|
-
children: /* @__PURE__ */ e(me, { className: "w-4 h-4" })
|
|
1600
|
-
}
|
|
1601
|
-
),
|
|
1602
|
-
/* @__PURE__ */ e(vt, {})
|
|
1603
|
-
] }) }),
|
|
1604
|
-
/* @__PURE__ */ s("div", { className: "flex-1 flex overflow-hidden", children: [
|
|
1605
|
-
/* @__PURE__ */ e("div", { className: d ? "w-3/5 border-r" : "w-full", children: /* @__PURE__ */ s("div", { className: "h-full flex flex-col", children: [
|
|
1606
|
-
/* @__PURE__ */ s("div", { className: "flex-1 overflow-auto p-2 space-y-4", children: [
|
|
1607
|
-
a && /* @__PURE__ */ e(
|
|
1608
|
-
ft,
|
|
1578
|
+
return /* @__PURE__ */ e(
|
|
1579
|
+
ot,
|
|
1580
|
+
{
|
|
1581
|
+
config: {
|
|
1582
|
+
typeLabels: p,
|
|
1583
|
+
propertyLabel: g,
|
|
1584
|
+
showRegex: u,
|
|
1585
|
+
keyEditable: b
|
|
1586
|
+
},
|
|
1587
|
+
children: /* @__PURE__ */ s("div", { className: `${m} flex flex-col json-schema-builder-react`, children: [
|
|
1588
|
+
r && /* @__PURE__ */ e("header", { className: "h-16 border-b flex items-center justify-between px-6", children: /* @__PURE__ */ s("div", { className: "flex items-center gap-3", children: [
|
|
1589
|
+
l && /* @__PURE__ */ e(
|
|
1590
|
+
S,
|
|
1609
1591
|
{
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1592
|
+
variant: "outline",
|
|
1593
|
+
size: "sm",
|
|
1594
|
+
onClick: _,
|
|
1595
|
+
"data-testid": "button-import",
|
|
1596
|
+
children: /* @__PURE__ */ e(Ge, { className: "w-4 h-4" })
|
|
1614
1597
|
}
|
|
1615
1598
|
),
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1599
|
+
n && /* @__PURE__ */ e(
|
|
1600
|
+
S,
|
|
1601
|
+
{
|
|
1602
|
+
variant: "outline",
|
|
1603
|
+
size: "sm",
|
|
1604
|
+
onClick: H,
|
|
1605
|
+
disabled: v.length === 0,
|
|
1606
|
+
"data-testid": "button-clear",
|
|
1607
|
+
children: /* @__PURE__ */ e(fe, { className: "w-4 h-4" })
|
|
1608
|
+
}
|
|
1609
|
+
),
|
|
1610
|
+
/* @__PURE__ */ e(Nt, {})
|
|
1611
|
+
] }) }),
|
|
1612
|
+
/* @__PURE__ */ s("div", { className: "flex-1 flex overflow-hidden", children: [
|
|
1613
|
+
/* @__PURE__ */ e("div", { className: o ? "w-3/5 border-r" : "w-full", children: /* @__PURE__ */ s("div", { className: "h-full flex flex-col", children: [
|
|
1614
|
+
/* @__PURE__ */ s("div", { className: "flex-1 overflow-auto p-2 space-y-4", children: [
|
|
1615
|
+
a && /* @__PURE__ */ e(
|
|
1616
|
+
vt,
|
|
1617
|
+
{
|
|
1618
|
+
title: y.title,
|
|
1619
|
+
description: y.description,
|
|
1620
|
+
version: y.version,
|
|
1621
|
+
onUpdate: (c, j) => f(c, j)
|
|
1622
|
+
}
|
|
1623
|
+
),
|
|
1624
|
+
v.length === 0 ? /* @__PURE__ */ s("div", { className: "flex flex-col items-center justify-center py-16 text-center", children: [
|
|
1625
|
+
/* @__PURE__ */ e("div", { className: "w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4", children: /* @__PURE__ */ e(B, { className: "w-8 h-8 text-muted-foreground" }) }),
|
|
1626
|
+
/* @__PURE__ */ s("h2", { className: "text-lg font-medium mb-2", children: [
|
|
1627
|
+
"No ",
|
|
1628
|
+
g.plural,
|
|
1629
|
+
" yet"
|
|
1630
|
+
] }),
|
|
1631
|
+
/* @__PURE__ */ s("p", { className: "text-sm text-muted-foreground mb-6 max-w-sm", children: [
|
|
1632
|
+
"Start building your JSON schema by adding your first",
|
|
1633
|
+
" ",
|
|
1634
|
+
g.singular
|
|
1635
|
+
] }),
|
|
1636
|
+
/* @__PURE__ */ s(
|
|
1637
|
+
S,
|
|
1638
|
+
{
|
|
1639
|
+
onClick: () => C.open(),
|
|
1640
|
+
"data-testid": "button-add-first",
|
|
1641
|
+
children: [
|
|
1642
|
+
/* @__PURE__ */ e(B, { className: "w-4 h-4 mr-2" }),
|
|
1643
|
+
"Add ",
|
|
1644
|
+
g.singular
|
|
1645
|
+
]
|
|
1646
|
+
}
|
|
1647
|
+
)
|
|
1648
|
+
] }) : /* @__PURE__ */ s(me, { children: [
|
|
1649
|
+
/* @__PURE__ */ e("div", { className: "space-y-1", children: v.map((c) => /* @__PURE__ */ e(
|
|
1650
|
+
Z,
|
|
1651
|
+
{
|
|
1652
|
+
property: c,
|
|
1653
|
+
onUpdate: (j) => k(c.id, j),
|
|
1654
|
+
onDelete: () => E(c.id)
|
|
1655
|
+
},
|
|
1656
|
+
c.id
|
|
1657
|
+
)) }),
|
|
1658
|
+
D && /* @__PURE__ */ s("div", { className: "pt-4 border-t flex items-center justify-between text-sm text-muted-foreground", children: [
|
|
1659
|
+
/* @__PURE__ */ s("span", { children: [
|
|
1660
|
+
v.length,
|
|
1661
|
+
" ",
|
|
1662
|
+
v.length === 1 ? g.singular : g.plural
|
|
1663
|
+
] }),
|
|
1664
|
+
/* @__PURE__ */ s("span", { children: [
|
|
1665
|
+
v.filter((c) => c.required).length,
|
|
1666
|
+
" required"
|
|
1667
|
+
] })
|
|
1668
|
+
] })
|
|
1669
|
+
] })
|
|
1627
1670
|
] }),
|
|
1628
|
-
/* @__PURE__ */ s(
|
|
1629
|
-
|
|
1671
|
+
v.length > 0 && /* @__PURE__ */ e("div", { className: "border-t p-2 pt-4 bg-background", children: /* @__PURE__ */ s(
|
|
1672
|
+
S,
|
|
1630
1673
|
{
|
|
1631
|
-
onClick: () =>
|
|
1632
|
-
|
|
1674
|
+
onClick: () => C.open(),
|
|
1675
|
+
className: "w-full",
|
|
1676
|
+
variant: "outline",
|
|
1677
|
+
"data-testid": "button-add-property",
|
|
1633
1678
|
children: [
|
|
1634
|
-
/* @__PURE__ */ e(B, { className: "w-4 h-4
|
|
1679
|
+
/* @__PURE__ */ e(B, { className: "w-4 h-4" }),
|
|
1635
1680
|
"Add ",
|
|
1636
|
-
|
|
1681
|
+
g.singular
|
|
1637
1682
|
]
|
|
1638
1683
|
}
|
|
1639
|
-
)
|
|
1640
|
-
] })
|
|
1641
|
-
|
|
1642
|
-
Q,
|
|
1643
|
-
{
|
|
1644
|
-
property: T,
|
|
1645
|
-
onUpdate: (R) => q(T.id, R),
|
|
1646
|
-
onDelete: () => S(T.id),
|
|
1647
|
-
showRegex: u,
|
|
1648
|
-
keyEditable: o
|
|
1649
|
-
},
|
|
1650
|
-
T.id
|
|
1651
|
-
)) }),
|
|
1652
|
-
k && /* @__PURE__ */ s("div", { className: "pt-4 border-t flex items-center justify-between text-sm text-muted-foreground", children: [
|
|
1653
|
-
/* @__PURE__ */ s("span", { children: [
|
|
1654
|
-
f.length,
|
|
1655
|
-
" ",
|
|
1656
|
-
f.length === 1 ? y.singular : y.plural
|
|
1657
|
-
] }),
|
|
1658
|
-
/* @__PURE__ */ s("span", { children: [
|
|
1659
|
-
f.filter((T) => T.required).length,
|
|
1660
|
-
" required"
|
|
1661
|
-
] })
|
|
1662
|
-
] })
|
|
1663
|
-
] })
|
|
1684
|
+
) })
|
|
1685
|
+
] }) }),
|
|
1686
|
+
o && /* @__PURE__ */ e("div", { className: "w-2/5", children: /* @__PURE__ */ e(yt, { schema: t }) })
|
|
1664
1687
|
] }),
|
|
1665
|
-
|
|
1666
|
-
|
|
1688
|
+
C.isOpen && C.data && /* @__PURE__ */ e(
|
|
1689
|
+
Y,
|
|
1667
1690
|
{
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
/* @__PURE__ */ e(B, { className: "w-4 h-4" }),
|
|
1674
|
-
"Add ",
|
|
1675
|
-
y.singular
|
|
1676
|
-
]
|
|
1691
|
+
property: C.data,
|
|
1692
|
+
open: C.isOpen,
|
|
1693
|
+
isNewProperty: !0,
|
|
1694
|
+
onOpenChange: C.setIsOpen,
|
|
1695
|
+
onSave: C.confirm
|
|
1677
1696
|
}
|
|
1678
|
-
)
|
|
1679
|
-
] })
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
c.isOpen && c.data && /* @__PURE__ */ e(
|
|
1683
|
-
G,
|
|
1684
|
-
{
|
|
1685
|
-
property: c.data,
|
|
1686
|
-
open: c.isOpen,
|
|
1687
|
-
isNewProperty: !0,
|
|
1688
|
-
onOpenChange: c.setIsOpen,
|
|
1689
|
-
propertyLabel: y,
|
|
1690
|
-
onSave: c.confirm,
|
|
1691
|
-
showRegex: u,
|
|
1692
|
-
keyEditable: o
|
|
1693
|
-
}
|
|
1694
|
-
)
|
|
1695
|
-
] }) });
|
|
1697
|
+
)
|
|
1698
|
+
] })
|
|
1699
|
+
}
|
|
1700
|
+
);
|
|
1696
1701
|
}
|
|
1697
1702
|
export {
|
|
1698
|
-
|
|
1699
|
-
|
|
1703
|
+
Rt as JsonSchemaBuilder,
|
|
1704
|
+
Y as PropertyEditDialog
|
|
1700
1705
|
};
|
|
1701
|
-
//# sourceMappingURL=index.js.map
|