json-schema-builder-react 0.0.7 → 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/README.md +9 -5
- 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 +14 -13
- 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 -2
- package/dist-lib/index.js +746 -683
- package/dist-lib/lib/file-utils.d.ts +2 -2
- package/package.json +12 -13
- 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
|
-
import * as
|
|
12
|
-
import * as
|
|
13
|
-
import * as
|
|
14
|
-
function
|
|
15
|
-
return
|
|
11
|
+
import * as L from "@radix-ui/react-dialog";
|
|
12
|
+
import * as pe from "@radix-ui/react-label";
|
|
13
|
+
import * as U from "@radix-ui/react-checkbox";
|
|
14
|
+
function h(...t) {
|
|
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,266 +38,266 @@ const He = de(
|
|
|
38
38
|
size: "default"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
), S =
|
|
42
|
-
({ className: t, variant: i, size: a, asChild:
|
|
43
|
-
|
|
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:
|
|
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
51
|
S.displayName = "Button";
|
|
52
|
-
const
|
|
53
|
-
({ className: t, type: i, ...a },
|
|
52
|
+
const T = x.forwardRef(
|
|
53
|
+
({ className: t, type: i, ...a }, l) => /* @__PURE__ */ e(
|
|
54
54
|
"input",
|
|
55
55
|
{
|
|
56
56
|
type: i,
|
|
57
|
-
className:
|
|
57
|
+
className: h(
|
|
58
58
|
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
59
59
|
t
|
|
60
60
|
),
|
|
61
|
-
ref:
|
|
61
|
+
ref: l,
|
|
62
62
|
...a
|
|
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
|
-
ref:
|
|
70
|
+
ref: l,
|
|
71
71
|
sideOffset: i,
|
|
72
|
-
className:
|
|
72
|
+
className: h(
|
|
73
73
|
"z-50 overflow-hidden rounded-md bg-popover px-3 py-1.5 text-xs text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 origin-[--radix-tooltip-content-transform-origin]",
|
|
74
74
|
t
|
|
75
75
|
),
|
|
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
|
-
ref:
|
|
84
|
-
className:
|
|
83
|
+
ref: l,
|
|
84
|
+
className: h(
|
|
85
85
|
"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 data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
|
86
86
|
t
|
|
87
87
|
),
|
|
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,
|
|
100
|
-
className:
|
|
100
|
+
className: h(
|
|
101
101
|
"flex cursor-default items-center justify-center py-1",
|
|
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,
|
|
113
|
-
className:
|
|
113
|
+
className: h(
|
|
114
114
|
"flex cursor-default items-center justify-center py-1",
|
|
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,
|
|
126
|
-
className:
|
|
126
|
+
className: h(
|
|
127
127
|
"relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-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 origin-[--radix-select-content-transform-origin]",
|
|
128
128
|
a === "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",
|
|
129
129
|
t
|
|
130
130
|
),
|
|
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
|
{
|
|
138
|
-
className:
|
|
138
|
+
className: h(
|
|
139
139
|
"p-1",
|
|
140
140
|
a === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
|
141
141
|
),
|
|
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,
|
|
154
|
-
className:
|
|
154
|
+
className: h("px-2 py-1.5 text-sm font-semibold", t),
|
|
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
|
-
ref:
|
|
163
|
-
className:
|
|
162
|
+
ref: l,
|
|
163
|
+
className: h(
|
|
164
164
|
"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",
|
|
165
165
|
t
|
|
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,
|
|
179
|
-
className:
|
|
179
|
+
className: h("-mx-1 my-1 h-px bg-muted", t),
|
|
180
180
|
...i
|
|
181
181
|
}
|
|
182
182
|
));
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
|
|
183
|
+
tt.displayName = w.Separator.displayName;
|
|
184
|
+
const at = L.Root, it = L.Portal, xe = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
185
|
+
L.Overlay,
|
|
186
186
|
{
|
|
187
187
|
ref: a,
|
|
188
|
-
className:
|
|
188
|
+
className: h(
|
|
189
189
|
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
190
190
|
t
|
|
191
191
|
),
|
|
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
|
{
|
|
201
|
-
ref:
|
|
202
|
-
className:
|
|
201
|
+
ref: l,
|
|
202
|
+
className: h(
|
|
203
203
|
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
204
204
|
t
|
|
205
205
|
),
|
|
206
206
|
...a,
|
|
207
207
|
children: [
|
|
208
208
|
i,
|
|
209
|
-
/* @__PURE__ */ s(
|
|
210
|
-
/* @__PURE__ */ e(
|
|
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(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(
|
|
222
222
|
"div",
|
|
223
223
|
{
|
|
224
|
-
className:
|
|
224
|
+
className: h(
|
|
225
225
|
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
226
226
|
t
|
|
227
227
|
),
|
|
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(
|
|
236
236
|
"div",
|
|
237
237
|
{
|
|
238
|
-
className:
|
|
238
|
+
className: h(
|
|
239
239
|
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
240
240
|
t
|
|
241
241
|
),
|
|
242
242
|
...i
|
|
243
243
|
}
|
|
244
244
|
);
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
|
|
245
|
+
we.displayName = "DialogFooter";
|
|
246
|
+
const Ce = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
247
|
+
L.Title,
|
|
248
248
|
{
|
|
249
249
|
ref: a,
|
|
250
|
-
className:
|
|
250
|
+
className: h(
|
|
251
251
|
"text-lg font-semibold leading-none tracking-tight",
|
|
252
252
|
t
|
|
253
253
|
),
|
|
254
254
|
...i
|
|
255
255
|
}
|
|
256
256
|
));
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
|
|
257
|
+
Ce.displayName = L.Title.displayName;
|
|
258
|
+
const nt = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
259
|
+
L.Description,
|
|
260
260
|
{
|
|
261
261
|
ref: a,
|
|
262
|
-
className:
|
|
262
|
+
className: h("text-sm text-muted-foreground", t),
|
|
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:
|
|
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
|
-
className:
|
|
282
|
+
className: h(
|
|
283
283
|
"grid place-content-center 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",
|
|
284
284
|
t
|
|
285
285
|
),
|
|
286
286
|
...i,
|
|
287
287
|
children: /* @__PURE__ */ e(
|
|
288
|
-
|
|
288
|
+
U.Indicator,
|
|
289
289
|
{
|
|
290
|
-
className:
|
|
291
|
-
children: /* @__PURE__ */ e(
|
|
290
|
+
className: h("grid place-content-center text-current"),
|
|
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
|
-
className:
|
|
300
|
+
className: h(
|
|
301
301
|
"flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base 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 md:text-sm",
|
|
302
302
|
t
|
|
303
303
|
),
|
|
@@ -305,33 +305,33 @@ const te = y.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 ||
|
|
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,60 +340,68 @@ const tt = (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 ke
|
|
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
|
-
onSave:
|
|
370
|
+
onSave: l,
|
|
362
371
|
isArrayItem: n = !1,
|
|
363
|
-
isNewProperty:
|
|
364
|
-
propertyLabel: r
|
|
365
|
-
showRegex:
|
|
366
|
-
keyEditable:
|
|
372
|
+
isNewProperty: o = !1,
|
|
373
|
+
propertyLabel: r,
|
|
374
|
+
showRegex: m,
|
|
375
|
+
keyEditable: D,
|
|
376
|
+
typeLabels: p
|
|
367
377
|
}) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
i && v(t);
|
|
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:
|
|
383
|
+
handleTitleChange: E,
|
|
384
|
+
handleTitleBlur: R,
|
|
376
385
|
handleKeyChange: f,
|
|
377
|
-
handleFieldChange:
|
|
378
|
-
handleConstraintChange:
|
|
379
|
-
} =
|
|
386
|
+
handleFieldChange: O,
|
|
387
|
+
handleConstraintChange: C
|
|
388
|
+
} = lt(
|
|
389
|
+
d,
|
|
390
|
+
k,
|
|
380
391
|
o,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
(m = o.title) != null && m.trim() && (d(o), a(!1));
|
|
387
|
-
}, h = () => {
|
|
388
|
-
v(t), a(!1);
|
|
392
|
+
y
|
|
393
|
+
), H = () => {
|
|
394
|
+
d.title?.trim() && (l(d), a(!1));
|
|
395
|
+
}, _ = () => {
|
|
396
|
+
k(t), a(!1);
|
|
389
397
|
};
|
|
390
|
-
return /* @__PURE__ */ e(
|
|
391
|
-
|
|
398
|
+
return /* @__PURE__ */ e(at, { open: i, onOpenChange: a, children: /* @__PURE__ */ s(
|
|
399
|
+
be,
|
|
392
400
|
{
|
|
393
401
|
className: "max-w-2xl max-h-[80vh] flex flex-col gap-0 p-0",
|
|
394
402
|
"data-testid": "dialog-edit-property",
|
|
395
403
|
children: [
|
|
396
|
-
/* @__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}` }) }),
|
|
397
405
|
/* @__PURE__ */ s("div", { className: "space-y-6 px-6 pb-4 overflow-y-auto flex-1 min-h-0", children: [
|
|
398
406
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
399
407
|
/* @__PURE__ */ s(N, { className: "flex items-center gap-1.5", children: [
|
|
@@ -401,22 +409,22 @@ function G({
|
|
|
401
409
|
"Type"
|
|
402
410
|
] }),
|
|
403
411
|
/* @__PURE__ */ s(
|
|
404
|
-
|
|
412
|
+
X,
|
|
405
413
|
{
|
|
406
|
-
value:
|
|
407
|
-
onValueChange: (
|
|
414
|
+
value: d.type,
|
|
415
|
+
onValueChange: (c) => O("type", c),
|
|
408
416
|
"data-testid": "select-type-dialog",
|
|
409
417
|
children: [
|
|
410
|
-
/* @__PURE__ */ e(
|
|
411
|
-
/* @__PURE__ */ s(
|
|
412
|
-
/* @__PURE__ */ e(
|
|
413
|
-
/* @__PURE__ */ e(
|
|
414
|
-
/* @__PURE__ */ e(
|
|
415
|
-
/* @__PURE__ */ e(
|
|
416
|
-
/* @__PURE__ */ e(
|
|
417
|
-
/* @__PURE__ */ e(
|
|
418
|
-
/* @__PURE__ */ e(
|
|
419
|
-
/* @__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 })
|
|
420
428
|
] })
|
|
421
429
|
]
|
|
422
430
|
}
|
|
@@ -428,77 +436,77 @@ function G({
|
|
|
428
436
|
"Title"
|
|
429
437
|
] }),
|
|
430
438
|
/* @__PURE__ */ e(
|
|
431
|
-
|
|
439
|
+
T,
|
|
432
440
|
{
|
|
433
|
-
value:
|
|
434
|
-
onChange: (
|
|
435
|
-
onBlur:
|
|
441
|
+
value: d.title || "",
|
|
442
|
+
onChange: (c) => E(c.target.value),
|
|
443
|
+
onBlur: R,
|
|
436
444
|
placeholder: "Property Title",
|
|
437
445
|
"data-testid": "input-title-dialog",
|
|
438
446
|
required: !0
|
|
439
447
|
}
|
|
440
448
|
),
|
|
441
|
-
!
|
|
449
|
+
!o && d.key && /* @__PURE__ */ s("p", { className: "text-xs text-muted-foreground font-mono", children: [
|
|
442
450
|
"Key: ",
|
|
443
|
-
|
|
451
|
+
d.key
|
|
444
452
|
] })
|
|
445
453
|
] }),
|
|
446
|
-
(
|
|
454
|
+
(o || y) && /* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
447
455
|
/* @__PURE__ */ e(N, { children: "Key" }),
|
|
448
456
|
/* @__PURE__ */ e(
|
|
449
|
-
|
|
457
|
+
T,
|
|
450
458
|
{
|
|
451
|
-
value:
|
|
452
|
-
onChange: (
|
|
459
|
+
value: d.key,
|
|
460
|
+
onChange: (c) => f(c.target.value),
|
|
453
461
|
placeholder: "property_key",
|
|
454
462
|
"data-testid": "input-key-dialog"
|
|
455
463
|
}
|
|
456
464
|
),
|
|
457
|
-
!
|
|
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" })
|
|
458
466
|
] }),
|
|
459
467
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
460
468
|
/* @__PURE__ */ e(N, { children: "Description" }),
|
|
461
469
|
/* @__PURE__ */ e(
|
|
462
|
-
|
|
470
|
+
ne,
|
|
463
471
|
{
|
|
464
472
|
placeholder: "Optional description",
|
|
465
|
-
value:
|
|
466
|
-
onChange: (
|
|
473
|
+
value: d.description || "",
|
|
474
|
+
onChange: (c) => O("description", c.target.value),
|
|
467
475
|
rows: 2,
|
|
468
476
|
"data-testid": "input-edit-description"
|
|
469
477
|
}
|
|
470
478
|
)
|
|
471
479
|
] }),
|
|
472
|
-
|
|
480
|
+
d.type === "array" && /* @__PURE__ */ s("div", { className: "space-y-2 border-l-2 border-border pl-4 mt-2", children: [
|
|
473
481
|
/* @__PURE__ */ s(N, { className: "font-semibold text-xs text-muted-foreground", children: [
|
|
474
|
-
|
|
482
|
+
u.array,
|
|
475
483
|
" Items"
|
|
476
484
|
] }),
|
|
477
|
-
|
|
485
|
+
d.items ? /* @__PURE__ */ s("div", { className: "bg-muted/40 p-2 rounded", children: [
|
|
478
486
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
479
487
|
/* @__PURE__ */ e(N, { children: "Item Type" }),
|
|
480
488
|
/* @__PURE__ */ s(
|
|
481
|
-
|
|
489
|
+
X,
|
|
482
490
|
{
|
|
483
|
-
value:
|
|
484
|
-
onValueChange: (
|
|
485
|
-
...
|
|
491
|
+
value: d.items.type,
|
|
492
|
+
onValueChange: (c) => k({
|
|
493
|
+
...d,
|
|
486
494
|
items: {
|
|
487
|
-
...
|
|
488
|
-
type:
|
|
495
|
+
...d.items,
|
|
496
|
+
type: c
|
|
489
497
|
}
|
|
490
498
|
}),
|
|
491
499
|
children: [
|
|
492
|
-
/* @__PURE__ */ e(
|
|
493
|
-
/* @__PURE__ */ s(
|
|
494
|
-
/* @__PURE__ */ e(
|
|
495
|
-
/* @__PURE__ */ e(
|
|
496
|
-
/* @__PURE__ */ e(
|
|
497
|
-
/* @__PURE__ */ e(
|
|
498
|
-
/* @__PURE__ */ e(
|
|
499
|
-
/* @__PURE__ */ e(
|
|
500
|
-
/* @__PURE__ */ e(
|
|
501
|
-
/* @__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 })
|
|
502
510
|
] })
|
|
503
511
|
]
|
|
504
512
|
}
|
|
@@ -507,14 +515,14 @@ function G({
|
|
|
507
515
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
508
516
|
/* @__PURE__ */ e(N, { children: "Item Title" }),
|
|
509
517
|
/* @__PURE__ */ e(
|
|
510
|
-
|
|
518
|
+
T,
|
|
511
519
|
{
|
|
512
|
-
value:
|
|
513
|
-
onChange: (
|
|
514
|
-
...
|
|
520
|
+
value: d.items.title || "",
|
|
521
|
+
onChange: (c) => k({
|
|
522
|
+
...d,
|
|
515
523
|
items: {
|
|
516
|
-
...
|
|
517
|
-
title:
|
|
524
|
+
...d.items,
|
|
525
|
+
title: c.target.value
|
|
518
526
|
}
|
|
519
527
|
}),
|
|
520
528
|
placeholder: "Item Title"
|
|
@@ -527,10 +535,10 @@ function G({
|
|
|
527
535
|
variant: "ghost",
|
|
528
536
|
size: "sm",
|
|
529
537
|
className: "mt-2",
|
|
530
|
-
onClick: () =>
|
|
538
|
+
onClick: () => k({ ...d, items: void 0 }),
|
|
531
539
|
children: [
|
|
532
540
|
"Remove ",
|
|
533
|
-
|
|
541
|
+
u.array,
|
|
534
542
|
" Item Schema"
|
|
535
543
|
]
|
|
536
544
|
}
|
|
@@ -541,8 +549,8 @@ function G({
|
|
|
541
549
|
variant: "outline",
|
|
542
550
|
size: "sm",
|
|
543
551
|
onClick: () => {
|
|
544
|
-
|
|
545
|
-
...
|
|
552
|
+
k({
|
|
553
|
+
...d,
|
|
546
554
|
items: {
|
|
547
555
|
id: Date.now().toString() + Math.random(),
|
|
548
556
|
key: "item",
|
|
@@ -553,7 +561,7 @@ function G({
|
|
|
553
561
|
},
|
|
554
562
|
children: [
|
|
555
563
|
"Add ",
|
|
556
|
-
|
|
564
|
+
u.array,
|
|
557
565
|
" Item Schema"
|
|
558
566
|
]
|
|
559
567
|
}
|
|
@@ -561,19 +569,19 @@ function G({
|
|
|
561
569
|
] }),
|
|
562
570
|
!n && /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
563
571
|
/* @__PURE__ */ e(
|
|
564
|
-
|
|
572
|
+
Q,
|
|
565
573
|
{
|
|
566
574
|
id: "prop-required",
|
|
567
|
-
checked:
|
|
568
|
-
onCheckedChange: (
|
|
575
|
+
checked: d.required,
|
|
576
|
+
onCheckedChange: (c) => O("required", c),
|
|
569
577
|
"data-testid": "checkbox-edit-required"
|
|
570
578
|
}
|
|
571
579
|
),
|
|
572
580
|
/* @__PURE__ */ e(N, { htmlFor: "prop-required", className: "cursor-pointer", children: "Required field" })
|
|
573
581
|
] }),
|
|
574
|
-
|
|
582
|
+
d.type === "string" && /* @__PURE__ */ s("details", { className: "border rounded-md", children: [
|
|
575
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: [
|
|
576
|
-
|
|
584
|
+
u.string,
|
|
577
585
|
" Constraints"
|
|
578
586
|
] }) }),
|
|
579
587
|
/* @__PURE__ */ s("div", { className: "space-y-4 p-4 pt-0", children: [
|
|
@@ -581,15 +589,15 @@ function G({
|
|
|
581
589
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
582
590
|
/* @__PURE__ */ e(N, { htmlFor: "min-length", children: "Minimum Length" }),
|
|
583
591
|
/* @__PURE__ */ e(
|
|
584
|
-
|
|
592
|
+
T,
|
|
585
593
|
{
|
|
586
594
|
id: "min-length",
|
|
587
595
|
type: "number",
|
|
588
596
|
placeholder: "0",
|
|
589
|
-
value:
|
|
590
|
-
onChange: (
|
|
597
|
+
value: d.minLength || "",
|
|
598
|
+
onChange: (c) => C(
|
|
591
599
|
"minLength",
|
|
592
|
-
|
|
600
|
+
c.target.value ? parseInt(c.target.value) : void 0
|
|
593
601
|
),
|
|
594
602
|
"data-testid": "input-edit-minlength"
|
|
595
603
|
}
|
|
@@ -598,30 +606,30 @@ function G({
|
|
|
598
606
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
599
607
|
/* @__PURE__ */ e(N, { htmlFor: "max-length", children: "Maximum Length" }),
|
|
600
608
|
/* @__PURE__ */ e(
|
|
601
|
-
|
|
609
|
+
T,
|
|
602
610
|
{
|
|
603
611
|
id: "max-length",
|
|
604
612
|
type: "number",
|
|
605
613
|
placeholder: "∞",
|
|
606
|
-
value:
|
|
607
|
-
onChange: (
|
|
614
|
+
value: d.maxLength || "",
|
|
615
|
+
onChange: (c) => C(
|
|
608
616
|
"maxLength",
|
|
609
|
-
|
|
617
|
+
c.target.value ? parseInt(c.target.value) : void 0
|
|
610
618
|
),
|
|
611
619
|
"data-testid": "input-edit-maxlength"
|
|
612
620
|
}
|
|
613
621
|
)
|
|
614
622
|
] })
|
|
615
623
|
] }),
|
|
616
|
-
|
|
624
|
+
v && /* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
617
625
|
/* @__PURE__ */ e(N, { htmlFor: "pattern", children: "Pattern (regex)" }),
|
|
618
626
|
/* @__PURE__ */ e(
|
|
619
|
-
|
|
627
|
+
T,
|
|
620
628
|
{
|
|
621
629
|
id: "pattern",
|
|
622
630
|
placeholder: "^[a-z]+$",
|
|
623
|
-
value:
|
|
624
|
-
onChange: (
|
|
631
|
+
value: d.pattern || "",
|
|
632
|
+
onChange: (c) => C("pattern", c.target.value),
|
|
625
633
|
className: "font-mono text-sm",
|
|
626
634
|
"data-testid": "input-edit-pattern"
|
|
627
635
|
}
|
|
@@ -629,57 +637,54 @@ function G({
|
|
|
629
637
|
] }),
|
|
630
638
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
631
639
|
/* @__PURE__ */ e(N, { children: "Enum Values" }),
|
|
632
|
-
/* @__PURE__ */ e("div", { className: "space-y-2", children: [...
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
value
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
);
|
|
657
|
-
}
|
|
658
|
-
},
|
|
659
|
-
"data-testid": `input-edit-enum-${j}`
|
|
640
|
+
/* @__PURE__ */ e("div", { className: "space-y-2", children: [...d.enum || [], ""].map((c, j) => /* @__PURE__ */ e(
|
|
641
|
+
T,
|
|
642
|
+
{
|
|
643
|
+
placeholder: j === (d.enum?.length || 0) ? "Add new value..." : "Enum value",
|
|
644
|
+
value: c,
|
|
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()
|
|
651
|
+
]);
|
|
652
|
+
else if (A.trim()) {
|
|
653
|
+
const z = [...M];
|
|
654
|
+
z[j] = A.trim(), C("enum", z);
|
|
655
|
+
} else {
|
|
656
|
+
const z = M.filter(
|
|
657
|
+
(wt, De) => De !== j
|
|
658
|
+
);
|
|
659
|
+
C(
|
|
660
|
+
"enum",
|
|
661
|
+
z.length > 0 ? z : void 0
|
|
662
|
+
);
|
|
663
|
+
}
|
|
660
664
|
},
|
|
661
|
-
j
|
|
662
|
-
|
|
663
|
-
|
|
665
|
+
"data-testid": `input-edit-enum-${j}`
|
|
666
|
+
},
|
|
667
|
+
j
|
|
668
|
+
)) }),
|
|
664
669
|
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: "Enter allowed values (empty fields will be removed)" })
|
|
665
670
|
] })
|
|
666
671
|
] })
|
|
667
672
|
] }),
|
|
668
|
-
(
|
|
673
|
+
(d.type === "number" || d.type === "integer") && /* @__PURE__ */ s("details", { className: "border rounded-md", children: [
|
|
669
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" }) }),
|
|
670
675
|
/* @__PURE__ */ e("div", { className: "space-y-4 p-4 pt-0", children: /* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
671
676
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
672
677
|
/* @__PURE__ */ e(N, { htmlFor: "minimum", children: "Minimum Value" }),
|
|
673
678
|
/* @__PURE__ */ e(
|
|
674
|
-
|
|
679
|
+
T,
|
|
675
680
|
{
|
|
676
681
|
id: "minimum",
|
|
677
682
|
type: "number",
|
|
678
683
|
placeholder: "-∞",
|
|
679
|
-
value:
|
|
680
|
-
onChange: (
|
|
684
|
+
value: d.minimum ?? "",
|
|
685
|
+
onChange: (c) => C(
|
|
681
686
|
"minimum",
|
|
682
|
-
|
|
687
|
+
c.target.value ? parseFloat(c.target.value) : void 0
|
|
683
688
|
),
|
|
684
689
|
"data-testid": "input-edit-minimum"
|
|
685
690
|
}
|
|
@@ -688,15 +693,15 @@ function G({
|
|
|
688
693
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
689
694
|
/* @__PURE__ */ e(N, { htmlFor: "maximum", children: "Maximum Value" }),
|
|
690
695
|
/* @__PURE__ */ e(
|
|
691
|
-
|
|
696
|
+
T,
|
|
692
697
|
{
|
|
693
698
|
id: "maximum",
|
|
694
699
|
type: "number",
|
|
695
700
|
placeholder: "∞",
|
|
696
|
-
value:
|
|
697
|
-
onChange: (
|
|
701
|
+
value: d.maximum ?? "",
|
|
702
|
+
onChange: (c) => C(
|
|
698
703
|
"maximum",
|
|
699
|
-
|
|
704
|
+
c.target.value ? parseFloat(c.target.value) : void 0
|
|
700
705
|
),
|
|
701
706
|
"data-testid": "input-edit-maximum"
|
|
702
707
|
}
|
|
@@ -704,9 +709,9 @@ function G({
|
|
|
704
709
|
] })
|
|
705
710
|
] }) })
|
|
706
711
|
] }),
|
|
707
|
-
|
|
712
|
+
d.type === "array" && /* @__PURE__ */ s("details", { className: "border rounded-md", children: [
|
|
708
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: [
|
|
709
|
-
|
|
714
|
+
u.array,
|
|
710
715
|
" Constraints"
|
|
711
716
|
] }) }),
|
|
712
717
|
/* @__PURE__ */ s("div", { className: "space-y-4 p-4 pt-0", children: [
|
|
@@ -714,15 +719,15 @@ function G({
|
|
|
714
719
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
715
720
|
/* @__PURE__ */ e(N, { htmlFor: "min-items", children: "Minimum Items" }),
|
|
716
721
|
/* @__PURE__ */ e(
|
|
717
|
-
|
|
722
|
+
T,
|
|
718
723
|
{
|
|
719
724
|
id: "min-items",
|
|
720
725
|
type: "number",
|
|
721
726
|
placeholder: "0",
|
|
722
|
-
value:
|
|
723
|
-
onChange: (
|
|
727
|
+
value: d.minItems || "",
|
|
728
|
+
onChange: (c) => C(
|
|
724
729
|
"minItems",
|
|
725
|
-
|
|
730
|
+
c.target.value ? parseInt(c.target.value) : void 0
|
|
726
731
|
),
|
|
727
732
|
"data-testid": "input-edit-minitems"
|
|
728
733
|
}
|
|
@@ -731,15 +736,15 @@ function G({
|
|
|
731
736
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
732
737
|
/* @__PURE__ */ e(N, { htmlFor: "max-items", children: "Maximum Items" }),
|
|
733
738
|
/* @__PURE__ */ e(
|
|
734
|
-
|
|
739
|
+
T,
|
|
735
740
|
{
|
|
736
741
|
id: "max-items",
|
|
737
742
|
type: "number",
|
|
738
743
|
placeholder: "∞",
|
|
739
|
-
value:
|
|
740
|
-
onChange: (
|
|
744
|
+
value: d.maxItems || "",
|
|
745
|
+
onChange: (c) => C(
|
|
741
746
|
"maxItems",
|
|
742
|
-
|
|
747
|
+
c.target.value ? parseInt(c.target.value) : void 0
|
|
743
748
|
),
|
|
744
749
|
"data-testid": "input-edit-maxitems"
|
|
745
750
|
}
|
|
@@ -748,11 +753,11 @@ function G({
|
|
|
748
753
|
] }),
|
|
749
754
|
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
750
755
|
/* @__PURE__ */ e(
|
|
751
|
-
|
|
756
|
+
Q,
|
|
752
757
|
{
|
|
753
758
|
id: "unique-items",
|
|
754
|
-
checked:
|
|
755
|
-
onCheckedChange: (
|
|
759
|
+
checked: d.uniqueItems || !1,
|
|
760
|
+
onCheckedChange: (c) => C("uniqueItems", c),
|
|
756
761
|
"data-testid": "checkbox-edit-unique"
|
|
757
762
|
}
|
|
758
763
|
),
|
|
@@ -761,12 +766,12 @@ function G({
|
|
|
761
766
|
] })
|
|
762
767
|
] })
|
|
763
768
|
] }),
|
|
764
|
-
/* @__PURE__ */ s(
|
|
769
|
+
/* @__PURE__ */ s(we, { className: "px-6 py-4 border-t bg-background shrink-0", children: [
|
|
765
770
|
/* @__PURE__ */ e(
|
|
766
771
|
S,
|
|
767
772
|
{
|
|
768
773
|
variant: "outline",
|
|
769
|
-
onClick:
|
|
774
|
+
onClick: _,
|
|
770
775
|
"data-testid": "button-cancel",
|
|
771
776
|
children: "Cancel"
|
|
772
777
|
}
|
|
@@ -774,9 +779,9 @@ function G({
|
|
|
774
779
|
/* @__PURE__ */ e(
|
|
775
780
|
S,
|
|
776
781
|
{
|
|
777
|
-
onClick:
|
|
782
|
+
onClick: H,
|
|
778
783
|
"data-testid": "button-save",
|
|
779
|
-
disabled: !
|
|
784
|
+
disabled: !d.title?.trim(),
|
|
780
785
|
children: "Save Changes"
|
|
781
786
|
}
|
|
782
787
|
)
|
|
@@ -785,42 +790,42 @@ function G({
|
|
|
785
790
|
}
|
|
786
791
|
) });
|
|
787
792
|
}
|
|
788
|
-
function
|
|
789
|
-
const { allowEmpty:
|
|
790
|
-
|
|
791
|
-
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);
|
|
792
797
|
}, [t, r]);
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
},
|
|
796
|
-
|
|
797
|
-
},
|
|
798
|
-
const
|
|
799
|
-
if (!
|
|
800
|
-
|
|
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);
|
|
801
806
|
return;
|
|
802
807
|
}
|
|
803
|
-
|
|
808
|
+
y !== t && i(y), m(!1);
|
|
804
809
|
};
|
|
805
810
|
return {
|
|
806
811
|
isEditing: r,
|
|
807
|
-
value:
|
|
808
|
-
startEdit:
|
|
809
|
-
handleChange:
|
|
810
|
-
handleBlur:
|
|
811
|
-
handleKeyDown: (
|
|
812
|
-
|
|
812
|
+
value: D,
|
|
813
|
+
startEdit: g,
|
|
814
|
+
handleChange: u,
|
|
815
|
+
handleBlur: b,
|
|
816
|
+
handleKeyDown: (y) => {
|
|
817
|
+
y.key === "Enter" ? b() : y.key === "Escape" && (p(t), m(!1), o?.());
|
|
813
818
|
}
|
|
814
819
|
};
|
|
815
820
|
}
|
|
816
|
-
function
|
|
817
|
-
const [a,
|
|
821
|
+
function dt(t, i) {
|
|
822
|
+
const [a, l] = q(!1);
|
|
818
823
|
return {
|
|
819
824
|
isChangingType: a,
|
|
820
|
-
setIsChangingType:
|
|
825
|
+
setIsChangingType: l,
|
|
821
826
|
handleTypeChange: (r) => {
|
|
822
|
-
const
|
|
823
|
-
r !== "string" && (delete
|
|
827
|
+
const m = { ...t, type: r };
|
|
828
|
+
r !== "string" && (delete m.minLength, delete m.maxLength, delete m.pattern, delete m.enum), r !== "number" && r !== "integer" && (delete m.minimum, delete m.maximum), r !== "array" && (delete m.minItems, delete m.maxItems, delete m.uniqueItems, delete m.items), r !== "object" && delete m.children, i(m), l(!1);
|
|
824
829
|
},
|
|
825
830
|
availableTypes: [
|
|
826
831
|
"string",
|
|
@@ -833,52 +838,52 @@ function nt(t, i) {
|
|
|
833
838
|
]
|
|
834
839
|
};
|
|
835
840
|
}
|
|
836
|
-
const
|
|
837
|
-
function
|
|
838
|
-
const { onConfirm: i, onCancel: a, createInitialData:
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
},
|
|
842
|
-
|
|
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?.();
|
|
843
848
|
};
|
|
844
849
|
return {
|
|
845
850
|
isOpen: n,
|
|
846
851
|
data: r,
|
|
847
|
-
open:
|
|
848
|
-
close:
|
|
849
|
-
confirm: (
|
|
850
|
-
i
|
|
852
|
+
open: D,
|
|
853
|
+
close: p,
|
|
854
|
+
confirm: (b) => {
|
|
855
|
+
i?.(b), o(!1), m(null);
|
|
851
856
|
},
|
|
852
|
-
setIsOpen: (
|
|
853
|
-
|
|
857
|
+
setIsOpen: (b) => {
|
|
858
|
+
b ? o(!0) : p();
|
|
854
859
|
}
|
|
855
860
|
};
|
|
856
861
|
}
|
|
857
|
-
function
|
|
858
|
-
const a =
|
|
862
|
+
function ct(t, i) {
|
|
863
|
+
const a = re({
|
|
859
864
|
createInitialData: () => ({
|
|
860
|
-
id:
|
|
865
|
+
id: se(),
|
|
861
866
|
key: "",
|
|
862
867
|
type: "string",
|
|
863
868
|
required: !1
|
|
864
869
|
}),
|
|
865
|
-
onConfirm: (
|
|
870
|
+
onConfirm: (o) => {
|
|
866
871
|
i({
|
|
867
872
|
...t,
|
|
868
|
-
children: [...t.children || [],
|
|
873
|
+
children: [...t.children || [], o]
|
|
869
874
|
});
|
|
870
875
|
}
|
|
871
876
|
});
|
|
872
877
|
return {
|
|
873
878
|
addChild: () => a.open(),
|
|
874
|
-
updateChild: (
|
|
875
|
-
const
|
|
876
|
-
(
|
|
879
|
+
updateChild: (o, r) => {
|
|
880
|
+
const m = t.children.map(
|
|
881
|
+
(D) => D.id === o ? r : D
|
|
877
882
|
);
|
|
878
|
-
i({ ...t, children:
|
|
883
|
+
i({ ...t, children: m });
|
|
879
884
|
},
|
|
880
|
-
deleteChild: (
|
|
881
|
-
const r = t.children.filter((
|
|
885
|
+
deleteChild: (o) => {
|
|
886
|
+
const r = t.children.filter((m) => m.id !== o);
|
|
882
887
|
i({ ...t, children: r });
|
|
883
888
|
},
|
|
884
889
|
addChildDialog: {
|
|
@@ -889,31 +894,36 @@ function st(t, i) {
|
|
|
889
894
|
}
|
|
890
895
|
};
|
|
891
896
|
}
|
|
892
|
-
function
|
|
897
|
+
function Z({
|
|
893
898
|
property: t,
|
|
894
899
|
onUpdate: i,
|
|
895
900
|
onDelete: a,
|
|
896
|
-
level:
|
|
897
|
-
isArrayItem: n = !1
|
|
898
|
-
showRegex: l = !1,
|
|
899
|
-
keyEditable: r = !1
|
|
901
|
+
level: l = 1,
|
|
902
|
+
isArrayItem: n = !1
|
|
900
903
|
}) {
|
|
901
|
-
const { getTypeLabel:
|
|
904
|
+
const { getTypeLabel: o, typeLabels: r, showRegex: m, keyEditable: D } = Ie(), p = re(), g = ce(
|
|
902
905
|
t.title || t.key || "",
|
|
903
|
-
(
|
|
906
|
+
(f) => i({ ...t, title: f }),
|
|
904
907
|
{ allowEmpty: !1 }
|
|
905
|
-
),
|
|
908
|
+
), u = ce(
|
|
906
909
|
t.description || "",
|
|
907
|
-
(
|
|
910
|
+
(f) => i({ ...t, description: f || void 0 }),
|
|
908
911
|
{ allowEmpty: !0 }
|
|
909
|
-
),
|
|
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 = {
|
|
910
913
|
1: "text-lg font-semibold",
|
|
911
914
|
2: "text-base",
|
|
912
915
|
3: "text-base",
|
|
913
916
|
4: "text-base",
|
|
914
917
|
5: "text-sm",
|
|
915
918
|
6: "text-sm"
|
|
916
|
-
}[
|
|
919
|
+
}[l] || "text-sm", R = {
|
|
920
|
+
1: "h-5 w-5",
|
|
921
|
+
2: "h-4 w-4",
|
|
922
|
+
3: "h-4 w-4",
|
|
923
|
+
4: "h-4 w-4",
|
|
924
|
+
5: "h-4 w-4",
|
|
925
|
+
6: "h-4 w-4"
|
|
926
|
+
}[l] || "h-5 w-5";
|
|
917
927
|
return /* @__PURE__ */ s("div", { className: "group", children: [
|
|
918
928
|
/* @__PURE__ */ s("div", { className: "flex gap-4 items-center rounded-md -mx-2 px-2 py-1 transition-colors hover:bg-accent/50", children: [
|
|
919
929
|
/* @__PURE__ */ e("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ s("div", { className: "flex items-start gap-3", children: [
|
|
@@ -921,64 +931,126 @@ function Q({
|
|
|
921
931
|
"button",
|
|
922
932
|
{
|
|
923
933
|
onClick: () => i({ ...t, required: !t.required }),
|
|
924
|
-
className: "shrink-0 transition-all hover:scale-110 mt-
|
|
934
|
+
className: "shrink-0 transition-all hover:scale-110 -mt-[3px]",
|
|
925
935
|
title: t.required ? "Required field - click to make optional" : "Optional field - click to make required",
|
|
926
|
-
children: t.required ?
|
|
936
|
+
children: t.required ? (
|
|
937
|
+
// <span className="block w-4 h-4 rounded-full bg-primary"></span>
|
|
938
|
+
/* @__PURE__ */ e(oe, { className: "w-6 h-6 text-primary" })
|
|
939
|
+
) : (
|
|
940
|
+
// <span className="block w-4 h-4 rounded-full border border-dashed border-gray-400"></span>
|
|
941
|
+
/* @__PURE__ */ e(oe, { className: "w-6 h-6 text-border" })
|
|
942
|
+
)
|
|
927
943
|
}
|
|
928
944
|
),
|
|
929
|
-
|
|
930
|
-
|
|
945
|
+
g.isEditing ? /* @__PURE__ */ e(
|
|
946
|
+
T,
|
|
931
947
|
{
|
|
932
|
-
value:
|
|
933
|
-
onChange: (
|
|
934
|
-
onBlur:
|
|
935
|
-
onKeyDown:
|
|
948
|
+
value: g.value,
|
|
949
|
+
onChange: (f) => g.handleChange(f.target.value),
|
|
950
|
+
onBlur: g.handleBlur,
|
|
951
|
+
onKeyDown: g.handleKeyDown,
|
|
936
952
|
autoFocus: !0,
|
|
937
|
-
className:
|
|
953
|
+
className: E,
|
|
938
954
|
placeholder: "Enter title"
|
|
939
955
|
}
|
|
940
956
|
) : /* @__PURE__ */ s("div", { className: "flex gap-2 flex-wrap flex-1", children: [
|
|
941
957
|
/* @__PURE__ */ s("div", { className: "flex items-start gap-2", children: [
|
|
942
958
|
/* @__PURE__ */ e(
|
|
943
|
-
|
|
959
|
+
y,
|
|
944
960
|
{
|
|
945
|
-
className: `${
|
|
946
|
-
onClick:
|
|
961
|
+
className: `${E} cursor-pointer hover:text-primary transition-colors leading-none`,
|
|
962
|
+
onClick: g.startEdit,
|
|
947
963
|
children: t.title || t.key || /* @__PURE__ */ e("span", { className: "text-muted-foreground italic", children: "unnamed" })
|
|
948
964
|
}
|
|
949
965
|
),
|
|
950
|
-
|
|
951
|
-
|
|
966
|
+
b.isChangingType ? /* @__PURE__ */ s(
|
|
967
|
+
X,
|
|
952
968
|
{
|
|
953
969
|
value: t.type,
|
|
954
|
-
onValueChange: (
|
|
955
|
-
open:
|
|
956
|
-
onOpenChange:
|
|
970
|
+
onValueChange: (f) => b.handleTypeChange(f),
|
|
971
|
+
open: b.isChangingType,
|
|
972
|
+
onOpenChange: b.setIsChangingType,
|
|
957
973
|
children: [
|
|
958
|
-
/* @__PURE__ */ e(
|
|
959
|
-
/* @__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)) })
|
|
960
976
|
]
|
|
961
977
|
}
|
|
962
|
-
) : /* @__PURE__ */ e(
|
|
963
|
-
/* @__PURE__ */ e(
|
|
978
|
+
) : /* @__PURE__ */ e(We, { children: /* @__PURE__ */ s(Ye, { children: [
|
|
979
|
+
/* @__PURE__ */ e(Ze, { asChild: !0, children: /* @__PURE__ */ s(
|
|
964
980
|
"button",
|
|
965
981
|
{
|
|
966
|
-
onClick: () =>
|
|
967
|
-
className: "cursor-pointer hover:bg-accent rounded p-0.5 transition-colors",
|
|
982
|
+
onClick: () => b.setIsChangingType(!0),
|
|
983
|
+
className: "cursor-pointer hover:bg-accent rounded p-0.5 -mt-0.5 transition-colors",
|
|
968
984
|
children: [
|
|
969
|
-
t.type === "string" && /* @__PURE__ */ e(
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
985
|
+
t.type === "string" && /* @__PURE__ */ e(
|
|
986
|
+
ze,
|
|
987
|
+
{
|
|
988
|
+
className: h(
|
|
989
|
+
R,
|
|
990
|
+
"text-muted-foreground"
|
|
991
|
+
)
|
|
992
|
+
}
|
|
993
|
+
),
|
|
994
|
+
t.type === "number" && /* @__PURE__ */ e(
|
|
995
|
+
de,
|
|
996
|
+
{
|
|
997
|
+
className: h(
|
|
998
|
+
R,
|
|
999
|
+
"text-muted-foreground"
|
|
1000
|
+
)
|
|
1001
|
+
}
|
|
1002
|
+
),
|
|
1003
|
+
t.type === "integer" && /* @__PURE__ */ e(
|
|
1004
|
+
de,
|
|
1005
|
+
{
|
|
1006
|
+
className: h(
|
|
1007
|
+
R,
|
|
1008
|
+
"text-muted-foreground"
|
|
1009
|
+
)
|
|
1010
|
+
}
|
|
1011
|
+
),
|
|
1012
|
+
t.type === "boolean" && /* @__PURE__ */ e(
|
|
1013
|
+
Be,
|
|
1014
|
+
{
|
|
1015
|
+
className: h(
|
|
1016
|
+
R,
|
|
1017
|
+
"text-muted-foreground"
|
|
1018
|
+
)
|
|
1019
|
+
}
|
|
1020
|
+
),
|
|
1021
|
+
t.type === "object" && /* @__PURE__ */ e(
|
|
1022
|
+
Ae,
|
|
1023
|
+
{
|
|
1024
|
+
className: h(
|
|
1025
|
+
R,
|
|
1026
|
+
"text-muted-foreground"
|
|
1027
|
+
)
|
|
1028
|
+
}
|
|
1029
|
+
),
|
|
1030
|
+
t.type === "array" && /* @__PURE__ */ e(
|
|
1031
|
+
Me,
|
|
1032
|
+
{
|
|
1033
|
+
className: h(
|
|
1034
|
+
R,
|
|
1035
|
+
"text-muted-foreground"
|
|
1036
|
+
)
|
|
1037
|
+
}
|
|
1038
|
+
),
|
|
1039
|
+
t.type === "file" && /* @__PURE__ */ e(
|
|
1040
|
+
$e,
|
|
1041
|
+
{
|
|
1042
|
+
className: h(
|
|
1043
|
+
R,
|
|
1044
|
+
"text-muted-foreground"
|
|
1045
|
+
)
|
|
1046
|
+
}
|
|
1047
|
+
)
|
|
976
1048
|
]
|
|
977
1049
|
}
|
|
978
1050
|
) }),
|
|
979
|
-
/* @__PURE__ */ s(
|
|
980
|
-
|
|
981
|
-
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)}` : "",
|
|
982
1054
|
/* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground mt-1", children: "Click to change type" })
|
|
983
1055
|
] })
|
|
984
1056
|
] }) }),
|
|
@@ -987,37 +1059,37 @@ function Q({
|
|
|
987
1059
|
{
|
|
988
1060
|
variant: "ghost",
|
|
989
1061
|
size: "icon",
|
|
990
|
-
className: "
|
|
991
|
-
onClick:
|
|
1062
|
+
className: "h-4 w-4",
|
|
1063
|
+
onClick: v.addChild,
|
|
992
1064
|
"data-testid": `button-add-child-${t.id}`,
|
|
993
|
-
children: /* @__PURE__ */ e(B, {
|
|
1065
|
+
children: /* @__PURE__ */ e(B, {})
|
|
994
1066
|
}
|
|
995
1067
|
)
|
|
996
1068
|
] }),
|
|
997
|
-
/* @__PURE__ */ e("div", { className: "flex-1", children:
|
|
998
|
-
|
|
1069
|
+
/* @__PURE__ */ e("div", { className: "flex-1", children: u.isEditing ? /* @__PURE__ */ e(
|
|
1070
|
+
T,
|
|
999
1071
|
{
|
|
1000
|
-
value:
|
|
1001
|
-
onChange: (
|
|
1002
|
-
onBlur:
|
|
1003
|
-
onKeyDown:
|
|
1072
|
+
value: u.value,
|
|
1073
|
+
onChange: (f) => u.handleChange(f.target.value),
|
|
1074
|
+
onBlur: u.handleBlur,
|
|
1075
|
+
onKeyDown: u.handleKeyDown,
|
|
1004
1076
|
autoFocus: !0,
|
|
1005
1077
|
className: "text-sm flex-1",
|
|
1006
1078
|
placeholder: "Enter description"
|
|
1007
1079
|
}
|
|
1008
|
-
) : /* @__PURE__ */ e(
|
|
1080
|
+
) : /* @__PURE__ */ e(me, { children: t.description ? /* @__PURE__ */ e(
|
|
1009
1081
|
"p",
|
|
1010
1082
|
{
|
|
1011
1083
|
className: "text-sm text-muted-foreground flex-1 min-w-[200px] cursor-pointer hover:text-foreground transition-colors",
|
|
1012
1084
|
"data-testid": `text-description-${t.id}`,
|
|
1013
|
-
onClick:
|
|
1085
|
+
onClick: u.startEdit,
|
|
1014
1086
|
children: t.description
|
|
1015
1087
|
}
|
|
1016
1088
|
) : /* @__PURE__ */ e(
|
|
1017
1089
|
"p",
|
|
1018
1090
|
{
|
|
1019
1091
|
className: "text-sm text-muted-foreground/50 flex-1 min-w-[200px] cursor-pointer hover:text-muted-foreground italic transition-colors",
|
|
1020
|
-
onClick:
|
|
1092
|
+
onClick: u.startEdit,
|
|
1021
1093
|
children: "Add description..."
|
|
1022
1094
|
}
|
|
1023
1095
|
) }) })
|
|
@@ -1030,18 +1102,18 @@ function Q({
|
|
|
1030
1102
|
variant: "ghost",
|
|
1031
1103
|
size: "icon",
|
|
1032
1104
|
className: "h-7 w-7",
|
|
1033
|
-
onClick: () =>
|
|
1105
|
+
onClick: () => p.open(t),
|
|
1034
1106
|
"data-testid": `button-edit-${t.id}`,
|
|
1035
|
-
children: /* @__PURE__ */ e(
|
|
1107
|
+
children: /* @__PURE__ */ e(Ke, { className: "w-3 h-3" })
|
|
1036
1108
|
}
|
|
1037
1109
|
),
|
|
1038
|
-
|
|
1110
|
+
d && t.type !== "object" && /* @__PURE__ */ e(
|
|
1039
1111
|
S,
|
|
1040
1112
|
{
|
|
1041
1113
|
variant: "ghost",
|
|
1042
1114
|
size: "icon",
|
|
1043
1115
|
className: "h-7 w-7",
|
|
1044
|
-
onClick:
|
|
1116
|
+
onClick: v.addChild,
|
|
1045
1117
|
"data-testid": `button-add-child-${t.id}`,
|
|
1046
1118
|
children: /* @__PURE__ */ e(B, { className: "w-3 h-3" })
|
|
1047
1119
|
}
|
|
@@ -1054,158 +1126,145 @@ function Q({
|
|
|
1054
1126
|
className: "h-7 w-7 text-muted-foreground hover:text-destructive",
|
|
1055
1127
|
onClick: a,
|
|
1056
1128
|
"data-testid": `button-delete-${t.id}`,
|
|
1057
|
-
children: /* @__PURE__ */ e(
|
|
1129
|
+
children: /* @__PURE__ */ e(fe, { className: "w-3 h-3" })
|
|
1058
1130
|
}
|
|
1059
1131
|
)
|
|
1060
1132
|
] })
|
|
1061
1133
|
] }),
|
|
1062
|
-
|
|
1134
|
+
k && /* @__PURE__ */ e(
|
|
1063
1135
|
"div",
|
|
1064
1136
|
{
|
|
1065
|
-
className:
|
|
1066
|
-
children: t.children.map((
|
|
1067
|
-
|
|
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",
|
|
1138
|
+
children: t.children.map((f) => /* @__PURE__ */ e(
|
|
1139
|
+
Z,
|
|
1068
1140
|
{
|
|
1069
|
-
property:
|
|
1070
|
-
onUpdate: (
|
|
1071
|
-
onDelete: () =>
|
|
1072
|
-
level:
|
|
1073
|
-
showRegex: l,
|
|
1074
|
-
keyEditable: r
|
|
1141
|
+
property: f,
|
|
1142
|
+
onUpdate: (O) => v.updateChild(f.id, O),
|
|
1143
|
+
onDelete: () => v.deleteChild(f.id),
|
|
1144
|
+
level: l + 1
|
|
1075
1145
|
},
|
|
1076
|
-
|
|
1146
|
+
f.id
|
|
1077
1147
|
))
|
|
1078
1148
|
}
|
|
1079
1149
|
),
|
|
1080
1150
|
t.type === "array" && t.items && /* @__PURE__ */ s(
|
|
1081
1151
|
"div",
|
|
1082
1152
|
{
|
|
1083
|
-
className:
|
|
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",
|
|
1084
1154
|
children: [
|
|
1085
1155
|
/* @__PURE__ */ s("div", { className: "mb-2 text-xs text-muted-foreground font-semibold uppercase", children: [
|
|
1086
|
-
|
|
1156
|
+
o("array"),
|
|
1087
1157
|
" Items"
|
|
1088
1158
|
] }),
|
|
1089
1159
|
/* @__PURE__ */ e(
|
|
1090
|
-
|
|
1160
|
+
Z,
|
|
1091
1161
|
{
|
|
1092
1162
|
property: t.items,
|
|
1093
|
-
onUpdate: (
|
|
1163
|
+
onUpdate: (f) => i({ ...t, items: f }),
|
|
1094
1164
|
onDelete: () => i({ ...t, items: void 0 }),
|
|
1095
|
-
level:
|
|
1096
|
-
isArrayItem: !0
|
|
1097
|
-
showRegex: l,
|
|
1098
|
-
keyEditable: r
|
|
1165
|
+
level: l + 1,
|
|
1166
|
+
isArrayItem: !0
|
|
1099
1167
|
}
|
|
1100
1168
|
)
|
|
1101
1169
|
]
|
|
1102
1170
|
}
|
|
1103
1171
|
),
|
|
1104
1172
|
/* @__PURE__ */ e(
|
|
1105
|
-
|
|
1173
|
+
Y,
|
|
1106
1174
|
{
|
|
1107
|
-
property:
|
|
1108
|
-
open:
|
|
1109
|
-
onOpenChange:
|
|
1110
|
-
onSave: (
|
|
1111
|
-
i(
|
|
1175
|
+
property: p.data || t,
|
|
1176
|
+
open: p.isOpen,
|
|
1177
|
+
onOpenChange: p.setIsOpen,
|
|
1178
|
+
onSave: (f) => {
|
|
1179
|
+
i(f), p.close();
|
|
1112
1180
|
},
|
|
1113
1181
|
isArrayItem: n,
|
|
1114
|
-
isNewProperty: !1
|
|
1115
|
-
showRegex: l,
|
|
1116
|
-
keyEditable: r
|
|
1182
|
+
isNewProperty: !1
|
|
1117
1183
|
}
|
|
1118
1184
|
),
|
|
1119
|
-
|
|
1120
|
-
|
|
1185
|
+
v.addChildDialog.isOpen && v.addChildDialog.data && /* @__PURE__ */ e(
|
|
1186
|
+
Y,
|
|
1121
1187
|
{
|
|
1122
|
-
property:
|
|
1123
|
-
open:
|
|
1188
|
+
property: v.addChildDialog.data,
|
|
1189
|
+
open: v.addChildDialog.isOpen,
|
|
1124
1190
|
isNewProperty: !0,
|
|
1125
|
-
onOpenChange:
|
|
1126
|
-
onSave:
|
|
1127
|
-
showRegex: l,
|
|
1128
|
-
keyEditable: r
|
|
1191
|
+
onOpenChange: v.addChildDialog.setIsOpen,
|
|
1192
|
+
onSave: v.addChildDialog.confirm
|
|
1129
1193
|
}
|
|
1130
1194
|
)
|
|
1131
1195
|
] });
|
|
1132
1196
|
}
|
|
1133
|
-
const
|
|
1197
|
+
const le = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
1134
1198
|
"div",
|
|
1135
1199
|
{
|
|
1136
1200
|
ref: a,
|
|
1137
|
-
className:
|
|
1138
|
-
"rounded-xl border bg-card text-card-foreground shadow",
|
|
1139
|
-
t
|
|
1140
|
-
),
|
|
1201
|
+
className: h("rounded-xl border bg-card text-card-foreground", t),
|
|
1141
1202
|
...i
|
|
1142
1203
|
}
|
|
1143
1204
|
));
|
|
1144
|
-
|
|
1145
|
-
const
|
|
1205
|
+
le.displayName = "Card";
|
|
1206
|
+
const mt = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
1146
1207
|
"div",
|
|
1147
1208
|
{
|
|
1148
1209
|
ref: a,
|
|
1149
|
-
className:
|
|
1210
|
+
className: h("flex flex-col space-y-1.5 p-6", t),
|
|
1150
1211
|
...i
|
|
1151
1212
|
}
|
|
1152
1213
|
));
|
|
1153
|
-
|
|
1154
|
-
const
|
|
1214
|
+
mt.displayName = "CardHeader";
|
|
1215
|
+
const ut = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
1155
1216
|
"div",
|
|
1156
1217
|
{
|
|
1157
1218
|
ref: a,
|
|
1158
|
-
className:
|
|
1219
|
+
className: h("font-semibold leading-none tracking-tight", t),
|
|
1159
1220
|
...i
|
|
1160
1221
|
}
|
|
1161
1222
|
));
|
|
1162
|
-
|
|
1163
|
-
const
|
|
1223
|
+
ut.displayName = "CardTitle";
|
|
1224
|
+
const ht = x.forwardRef(({ className: t, ...i }, a) => /* @__PURE__ */ e(
|
|
1164
1225
|
"div",
|
|
1165
1226
|
{
|
|
1166
1227
|
ref: a,
|
|
1167
|
-
className:
|
|
1228
|
+
className: h("text-sm text-muted-foreground", t),
|
|
1168
1229
|
...i
|
|
1169
1230
|
}
|
|
1170
1231
|
));
|
|
1171
|
-
|
|
1172
|
-
const
|
|
1173
|
-
|
|
1174
|
-
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(
|
|
1175
1236
|
"div",
|
|
1176
1237
|
{
|
|
1177
1238
|
ref: a,
|
|
1178
|
-
className:
|
|
1239
|
+
className: h("flex items-center p-6 pt-0", t),
|
|
1179
1240
|
...i
|
|
1180
1241
|
}
|
|
1181
1242
|
));
|
|
1182
|
-
|
|
1183
|
-
const
|
|
1243
|
+
pt.displayName = "CardFooter";
|
|
1244
|
+
const gt = () => new Promise((t, i) => {
|
|
1184
1245
|
const a = document.createElement("input");
|
|
1185
|
-
a.type = "file", a.accept = ".json", a.onchange = (
|
|
1186
|
-
|
|
1187
|
-
const n = (r = d.target.files) == null ? void 0 : r[0];
|
|
1246
|
+
a.type = "file", a.accept = ".json", a.onchange = (l) => {
|
|
1247
|
+
const n = l.target.files?.[0];
|
|
1188
1248
|
if (!n) {
|
|
1189
1249
|
i(new Error("No file selected"));
|
|
1190
1250
|
return;
|
|
1191
1251
|
}
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
var C;
|
|
1252
|
+
const o = new FileReader();
|
|
1253
|
+
o.onload = (r) => {
|
|
1195
1254
|
try {
|
|
1196
|
-
const
|
|
1197
|
-
t(
|
|
1255
|
+
const m = JSON.parse(r.target?.result);
|
|
1256
|
+
t(m);
|
|
1198
1257
|
} catch {
|
|
1199
1258
|
i(new Error("Invalid JSON file"));
|
|
1200
1259
|
}
|
|
1201
|
-
},
|
|
1260
|
+
}, o.onerror = () => i(new Error("Failed to read file")), o.readAsText(n);
|
|
1202
1261
|
}, a.click();
|
|
1203
|
-
}),
|
|
1204
|
-
const a = JSON.stringify(t, null, 2),
|
|
1205
|
-
|
|
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);
|
|
1206
1265
|
};
|
|
1207
|
-
function
|
|
1208
|
-
const [i, a] =
|
|
1266
|
+
function yt({ schema: t }) {
|
|
1267
|
+
const [i, a] = q(!1), l = JSON.stringify(t, null, 2);
|
|
1209
1268
|
return /* @__PURE__ */ s("div", { className: "h-full flex flex-col", children: [
|
|
1210
1269
|
/* @__PURE__ */ s("div", { className: "flex items-center justify-between p-4 border-b", children: [
|
|
1211
1270
|
/* @__PURE__ */ e("h2", { className: "text-sm font-medium", children: "JSON Schema Output" }),
|
|
@@ -1216,10 +1275,10 @@ function ut({ schema: t }) {
|
|
|
1216
1275
|
variant: "outline",
|
|
1217
1276
|
size: "sm",
|
|
1218
1277
|
onClick: async () => {
|
|
1219
|
-
await navigator.clipboard.writeText(
|
|
1278
|
+
await navigator.clipboard.writeText(l), a(!0), setTimeout(() => a(!1), 2e3);
|
|
1220
1279
|
},
|
|
1221
1280
|
"data-testid": "button-copy",
|
|
1222
|
-
children: i ? /* @__PURE__ */ e(
|
|
1281
|
+
children: i ? /* @__PURE__ */ e(Je, { className: "w-4 h-4" }) : /* @__PURE__ */ e(Ve, { className: "w-4 h-4" })
|
|
1223
1282
|
}
|
|
1224
1283
|
),
|
|
1225
1284
|
/* @__PURE__ */ e(
|
|
@@ -1228,42 +1287,42 @@ function ut({ schema: t }) {
|
|
|
1228
1287
|
variant: "outline",
|
|
1229
1288
|
size: "sm",
|
|
1230
1289
|
onClick: () => {
|
|
1231
|
-
|
|
1290
|
+
Se(t, "schema.json");
|
|
1232
1291
|
},
|
|
1233
1292
|
"data-testid": "button-download",
|
|
1234
|
-
children: /* @__PURE__ */ e(
|
|
1293
|
+
children: /* @__PURE__ */ e(He, { className: "w-4 h-4" })
|
|
1235
1294
|
}
|
|
1236
1295
|
)
|
|
1237
1296
|
] })
|
|
1238
1297
|
] }),
|
|
1239
|
-
/* @__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(
|
|
1240
1299
|
"pre",
|
|
1241
1300
|
{
|
|
1242
1301
|
className: "p-6 text-xs font-mono overflow-auto",
|
|
1243
1302
|
"data-testid": "text-json-output",
|
|
1244
|
-
children: /* @__PURE__ */ e("code", { children:
|
|
1303
|
+
children: /* @__PURE__ */ e("code", { children: l })
|
|
1245
1304
|
}
|
|
1246
1305
|
) }) })
|
|
1247
1306
|
] });
|
|
1248
1307
|
}
|
|
1249
|
-
function
|
|
1308
|
+
function vt({
|
|
1250
1309
|
title: t,
|
|
1251
1310
|
description: i,
|
|
1252
1311
|
version: a,
|
|
1253
|
-
onUpdate:
|
|
1312
|
+
onUpdate: l
|
|
1254
1313
|
}) {
|
|
1255
|
-
const [n,
|
|
1256
|
-
return /* @__PURE__ */ s(
|
|
1314
|
+
const [n, o] = q(!1);
|
|
1315
|
+
return /* @__PURE__ */ s(le, { className: "p-4", children: [
|
|
1257
1316
|
/* @__PURE__ */ s(
|
|
1258
1317
|
S,
|
|
1259
1318
|
{
|
|
1260
1319
|
variant: "ghost",
|
|
1261
|
-
onClick: () =>
|
|
1320
|
+
onClick: () => o(!n),
|
|
1262
1321
|
className: "w-full justify-between px-2 h-auto hover:bg-transparent",
|
|
1263
1322
|
"data-testid": "button-toggle-metadata",
|
|
1264
1323
|
children: [
|
|
1265
1324
|
/* @__PURE__ */ e("h3", { className: "text-sm font-medium", children: "Schema Metadata" }),
|
|
1266
|
-
n ? /* @__PURE__ */ e(
|
|
1325
|
+
n ? /* @__PURE__ */ e(ie, { className: "w-4 h-4" }) : /* @__PURE__ */ e(_e, { className: "w-4 h-4" })
|
|
1267
1326
|
]
|
|
1268
1327
|
}
|
|
1269
1328
|
),
|
|
@@ -1278,12 +1337,12 @@ function ht({
|
|
|
1278
1337
|
}
|
|
1279
1338
|
),
|
|
1280
1339
|
/* @__PURE__ */ e(
|
|
1281
|
-
|
|
1340
|
+
T,
|
|
1282
1341
|
{
|
|
1283
1342
|
id: "schema-title",
|
|
1284
1343
|
placeholder: "My Schema",
|
|
1285
1344
|
value: t,
|
|
1286
|
-
onChange: (r) =>
|
|
1345
|
+
onChange: (r) => l("title", r.target.value),
|
|
1287
1346
|
"data-testid": "input-title"
|
|
1288
1347
|
}
|
|
1289
1348
|
)
|
|
@@ -1298,12 +1357,12 @@ function ht({
|
|
|
1298
1357
|
}
|
|
1299
1358
|
),
|
|
1300
1359
|
/* @__PURE__ */ e(
|
|
1301
|
-
|
|
1360
|
+
ne,
|
|
1302
1361
|
{
|
|
1303
1362
|
id: "schema-description",
|
|
1304
1363
|
placeholder: "Describe your schema...",
|
|
1305
1364
|
value: i,
|
|
1306
|
-
onChange: (r) =>
|
|
1365
|
+
onChange: (r) => l("description", r.target.value),
|
|
1307
1366
|
className: "resize-none",
|
|
1308
1367
|
rows: 3,
|
|
1309
1368
|
"data-testid": "input-schema-description"
|
|
@@ -1320,12 +1379,12 @@ function ht({
|
|
|
1320
1379
|
}
|
|
1321
1380
|
),
|
|
1322
1381
|
/* @__PURE__ */ e(
|
|
1323
|
-
|
|
1382
|
+
T,
|
|
1324
1383
|
{
|
|
1325
1384
|
id: "schema-version",
|
|
1326
1385
|
placeholder: "1.0.0",
|
|
1327
1386
|
value: a,
|
|
1328
|
-
onChange: (r) =>
|
|
1387
|
+
onChange: (r) => l("version", r.target.value),
|
|
1329
1388
|
"data-testid": "input-version"
|
|
1330
1389
|
}
|
|
1331
1390
|
)
|
|
@@ -1333,30 +1392,30 @@ function ht({
|
|
|
1333
1392
|
] })
|
|
1334
1393
|
] });
|
|
1335
1394
|
}
|
|
1336
|
-
const
|
|
1337
|
-
const
|
|
1395
|
+
const $ = (t, i, a = !0) => {
|
|
1396
|
+
const l = {
|
|
1338
1397
|
type: "object"
|
|
1339
1398
|
};
|
|
1340
|
-
a && i && (i.title && (
|
|
1341
|
-
const n =
|
|
1342
|
-
Object.keys(n).length > 0 && (
|
|
1343
|
-
const
|
|
1344
|
-
return
|
|
1345
|
-
},
|
|
1399
|
+
a && i && (i.title && (l.title = i.title), i.description && (l.description = i.description));
|
|
1400
|
+
const n = ee(t);
|
|
1401
|
+
Object.keys(n).length > 0 && (l.properties = n);
|
|
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) => {
|
|
1346
1405
|
const i = {};
|
|
1347
1406
|
return t.forEach((a) => {
|
|
1348
1407
|
if (!a.key) return;
|
|
1349
1408
|
const n = { type: a.type === "file" ? "string" : a.type };
|
|
1350
|
-
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] || {
|
|
1351
1410
|
type: a.items.type
|
|
1352
1411
|
})), a.type === "object" && a.children && a.children.length > 0) {
|
|
1353
|
-
n.properties =
|
|
1354
|
-
const
|
|
1355
|
-
|
|
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);
|
|
1356
1415
|
}
|
|
1357
1416
|
i[a.key] = n;
|
|
1358
1417
|
}), i;
|
|
1359
|
-
},
|
|
1418
|
+
}, xt = (t) => {
|
|
1360
1419
|
const i = {
|
|
1361
1420
|
properties: []
|
|
1362
1421
|
};
|
|
@@ -1365,103 +1424,103 @@ const M = (t, i, a = !0) => {
|
|
|
1365
1424
|
description: typeof t.description == "string" ? t.description : "",
|
|
1366
1425
|
version: "1.0.0"
|
|
1367
1426
|
// Default version
|
|
1368
|
-
}), t.properties && typeof t.properties == "object" && (i.properties =
|
|
1427
|
+
}), t.properties && typeof t.properties == "object" && (i.properties = te(
|
|
1369
1428
|
t.properties,
|
|
1370
1429
|
Array.isArray(t.required) ? t.required : []
|
|
1371
1430
|
)), i;
|
|
1372
|
-
},
|
|
1373
|
-
const n =
|
|
1374
|
-
let
|
|
1375
|
-
|
|
1431
|
+
}, te = (t, i = []) => t ? Object.entries(t).filter(([, a]) => typeof a == "object").map(([a, l]) => {
|
|
1432
|
+
const n = l;
|
|
1433
|
+
let o = typeof n.type == "string" ? n.type : "string";
|
|
1434
|
+
o === "string" && n.format === "filename" && (o = "file");
|
|
1376
1435
|
const r = {
|
|
1377
|
-
id:
|
|
1436
|
+
id: se(),
|
|
1378
1437
|
key: a,
|
|
1379
1438
|
title: typeof n.title == "string" ? n.title : void 0,
|
|
1380
|
-
type:
|
|
1439
|
+
type: o,
|
|
1381
1440
|
description: typeof n.description == "string" ? n.description : void 0,
|
|
1382
1441
|
required: i.includes(a)
|
|
1383
1442
|
};
|
|
1384
|
-
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(
|
|
1385
1444
|
{ item: n.items },
|
|
1386
1445
|
[]
|
|
1387
|
-
).find((
|
|
1446
|
+
).find((m) => m.key === "item")), n.properties && typeof n.properties == "object" && (r.children = te(
|
|
1388
1447
|
n.properties,
|
|
1389
1448
|
Array.isArray(n.required) ? n.required : []
|
|
1390
1449
|
)), r;
|
|
1391
|
-
}) : [],
|
|
1450
|
+
}) : [], bt = ({
|
|
1392
1451
|
schema: t,
|
|
1393
1452
|
onChange: i,
|
|
1394
1453
|
includeMetadata: a = !0
|
|
1395
1454
|
}) => {
|
|
1396
|
-
const { properties:
|
|
1397
|
-
() =>
|
|
1455
|
+
const { properties: l, metadata: n } = Le(
|
|
1456
|
+
() => xt(t),
|
|
1398
1457
|
[t]
|
|
1399
|
-
),
|
|
1458
|
+
), o = l, r = n || {
|
|
1400
1459
|
title: "",
|
|
1401
1460
|
description: "",
|
|
1402
1461
|
version: ""
|
|
1403
|
-
},
|
|
1404
|
-
id:
|
|
1462
|
+
}, m = P(() => ({
|
|
1463
|
+
id: se(),
|
|
1405
1464
|
key: "",
|
|
1406
1465
|
type: "string",
|
|
1407
1466
|
required: !1
|
|
1408
|
-
}), []),
|
|
1409
|
-
(
|
|
1410
|
-
const
|
|
1411
|
-
let
|
|
1412
|
-
|
|
1413
|
-
const
|
|
1414
|
-
|
|
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,
|
|
1415
1474
|
r,
|
|
1416
1475
|
a
|
|
1417
1476
|
);
|
|
1418
|
-
i(
|
|
1477
|
+
i(R);
|
|
1419
1478
|
},
|
|
1420
|
-
[
|
|
1421
|
-
),
|
|
1422
|
-
(
|
|
1423
|
-
const
|
|
1424
|
-
|
|
1479
|
+
[o, r, a, i]
|
|
1480
|
+
), p = P(
|
|
1481
|
+
(y) => {
|
|
1482
|
+
const d = o.filter((E) => E.id !== y), k = $(
|
|
1483
|
+
d,
|
|
1425
1484
|
r,
|
|
1426
1485
|
a
|
|
1427
1486
|
);
|
|
1428
|
-
i(
|
|
1487
|
+
i(k);
|
|
1429
1488
|
},
|
|
1430
|
-
[
|
|
1431
|
-
),
|
|
1432
|
-
const
|
|
1433
|
-
i(
|
|
1434
|
-
}, [a, i]),
|
|
1435
|
-
(
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1438
|
-
|
|
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,
|
|
1439
1498
|
a
|
|
1440
1499
|
);
|
|
1441
|
-
i(
|
|
1500
|
+
i(E);
|
|
1442
1501
|
},
|
|
1443
|
-
[
|
|
1444
|
-
),
|
|
1445
|
-
const
|
|
1446
|
-
i(
|
|
1447
|
-
}, [i]),
|
|
1448
|
-
|
|
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");
|
|
1449
1508
|
}, [t]);
|
|
1450
1509
|
return {
|
|
1451
|
-
properties:
|
|
1510
|
+
properties: o,
|
|
1452
1511
|
metadata: r,
|
|
1453
|
-
addProperty:
|
|
1454
|
-
updateProperty:
|
|
1455
|
-
deleteProperty:
|
|
1456
|
-
clearAll:
|
|
1457
|
-
updateMetadata:
|
|
1458
|
-
importSchema:
|
|
1459
|
-
downloadSchema:
|
|
1512
|
+
addProperty: m,
|
|
1513
|
+
updateProperty: D,
|
|
1514
|
+
deleteProperty: p,
|
|
1515
|
+
clearAll: g,
|
|
1516
|
+
updateMetadata: u,
|
|
1517
|
+
importSchema: b,
|
|
1518
|
+
downloadSchema: v
|
|
1460
1519
|
};
|
|
1461
1520
|
};
|
|
1462
|
-
function
|
|
1463
|
-
const [t, i] =
|
|
1464
|
-
return
|
|
1521
|
+
function Nt() {
|
|
1522
|
+
const [t, i] = q("light");
|
|
1523
|
+
return ae(() => {
|
|
1465
1524
|
const n = localStorage.getItem("theme") || (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
|
1466
1525
|
i(n), document.documentElement.classList.toggle("dark", n === "dark");
|
|
1467
1526
|
}, []), /* @__PURE__ */ e(
|
|
@@ -1470,173 +1529,177 @@ function gt() {
|
|
|
1470
1529
|
variant: "ghost",
|
|
1471
1530
|
size: "icon",
|
|
1472
1531
|
onClick: () => {
|
|
1473
|
-
const
|
|
1474
|
-
i(
|
|
1532
|
+
const l = t === "light" ? "dark" : "light";
|
|
1533
|
+
i(l), localStorage.setItem("theme", l), document.documentElement.classList.toggle("dark", l === "dark");
|
|
1475
1534
|
},
|
|
1476
1535
|
"data-testid": "button-theme-toggle",
|
|
1477
|
-
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" })
|
|
1478
1537
|
}
|
|
1479
1538
|
);
|
|
1480
1539
|
}
|
|
1481
|
-
function
|
|
1540
|
+
function Rt({
|
|
1482
1541
|
schema: t,
|
|
1483
1542
|
onChange: i,
|
|
1484
1543
|
showMetadata: a = !1,
|
|
1485
|
-
showImport:
|
|
1544
|
+
showImport: l = !0,
|
|
1486
1545
|
showClear: n = !0,
|
|
1487
|
-
showOutput:
|
|
1546
|
+
showOutput: o = !0,
|
|
1488
1547
|
showHeader: r = !0,
|
|
1489
|
-
className:
|
|
1490
|
-
showSummary:
|
|
1491
|
-
typeLabels:
|
|
1492
|
-
propertyLabel:
|
|
1493
|
-
showRegex:
|
|
1494
|
-
keyEditable:
|
|
1548
|
+
className: m = "",
|
|
1549
|
+
showSummary: D = !1,
|
|
1550
|
+
typeLabels: p,
|
|
1551
|
+
propertyLabel: g = { singular: "property", plural: "properties" },
|
|
1552
|
+
showRegex: u = !1,
|
|
1553
|
+
keyEditable: b = !1
|
|
1495
1554
|
}) {
|
|
1496
1555
|
const {
|
|
1497
|
-
properties:
|
|
1498
|
-
metadata:
|
|
1499
|
-
addProperty:
|
|
1500
|
-
updateProperty:
|
|
1501
|
-
deleteProperty:
|
|
1502
|
-
clearAll:
|
|
1503
|
-
updateMetadata:
|
|
1504
|
-
importSchema:
|
|
1505
|
-
} =
|
|
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({
|
|
1506
1565
|
schema: t,
|
|
1507
1566
|
onChange: i,
|
|
1508
1567
|
includeMetadata: a
|
|
1509
|
-
}),
|
|
1510
|
-
createInitialData: () =>
|
|
1511
|
-
onConfirm: (
|
|
1512
|
-
|
|
1568
|
+
}), C = re({
|
|
1569
|
+
createInitialData: () => d(),
|
|
1570
|
+
onConfirm: (c) => {
|
|
1571
|
+
k(c.id, c);
|
|
1513
1572
|
}
|
|
1514
|
-
}),
|
|
1515
|
-
|
|
1516
|
-
},
|
|
1517
|
-
await
|
|
1573
|
+
}), H = () => {
|
|
1574
|
+
R();
|
|
1575
|
+
}, _ = async () => {
|
|
1576
|
+
await O();
|
|
1518
1577
|
};
|
|
1519
|
-
return /* @__PURE__ */ e(
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
S,
|
|
1533
|
-
{
|
|
1534
|
-
variant: "outline",
|
|
1535
|
-
size: "sm",
|
|
1536
|
-
onClick: A,
|
|
1537
|
-
disabled: g.length === 0,
|
|
1538
|
-
"data-testid": "button-clear",
|
|
1539
|
-
children: /* @__PURE__ */ e(ce, { className: "w-4 h-4" })
|
|
1540
|
-
}
|
|
1541
|
-
),
|
|
1542
|
-
/* @__PURE__ */ e(gt, {})
|
|
1543
|
-
] }) }),
|
|
1544
|
-
/* @__PURE__ */ s("div", { className: "flex-1 flex overflow-hidden", children: [
|
|
1545
|
-
/* @__PURE__ */ e("div", { className: l ? "w-3/5 border-r" : "w-full", children: /* @__PURE__ */ s("div", { className: "h-full flex flex-col", children: [
|
|
1546
|
-
/* @__PURE__ */ s("div", { className: "flex-1 overflow-auto p-2 space-y-4", children: [
|
|
1547
|
-
a && /* @__PURE__ */ e(
|
|
1548
|
-
ht,
|
|
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,
|
|
1549
1591
|
{
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1592
|
+
variant: "outline",
|
|
1593
|
+
size: "sm",
|
|
1594
|
+
onClick: _,
|
|
1595
|
+
"data-testid": "button-import",
|
|
1596
|
+
children: /* @__PURE__ */ e(Ge, { className: "w-4 h-4" })
|
|
1554
1597
|
}
|
|
1555
1598
|
),
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
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
|
+
] })
|
|
1567
1670
|
] }),
|
|
1568
|
-
/* @__PURE__ */ s(
|
|
1671
|
+
v.length > 0 && /* @__PURE__ */ e("div", { className: "border-t p-2 pt-4 bg-background", children: /* @__PURE__ */ s(
|
|
1569
1672
|
S,
|
|
1570
1673
|
{
|
|
1571
|
-
onClick: () =>
|
|
1572
|
-
|
|
1674
|
+
onClick: () => C.open(),
|
|
1675
|
+
className: "w-full",
|
|
1676
|
+
variant: "outline",
|
|
1677
|
+
"data-testid": "button-add-property",
|
|
1573
1678
|
children: [
|
|
1574
|
-
/* @__PURE__ */ e(B, { className: "w-4 h-4
|
|
1679
|
+
/* @__PURE__ */ e(B, { className: "w-4 h-4" }),
|
|
1575
1680
|
"Add ",
|
|
1576
|
-
|
|
1681
|
+
g.singular
|
|
1577
1682
|
]
|
|
1578
1683
|
}
|
|
1579
|
-
)
|
|
1580
|
-
] })
|
|
1581
|
-
|
|
1582
|
-
Q,
|
|
1583
|
-
{
|
|
1584
|
-
property: T,
|
|
1585
|
-
onUpdate: (R) => b(T.id, R),
|
|
1586
|
-
onDelete: () => q(T.id),
|
|
1587
|
-
showRegex: v,
|
|
1588
|
-
keyEditable: x
|
|
1589
|
-
},
|
|
1590
|
-
T.id
|
|
1591
|
-
)) }),
|
|
1592
|
-
C && /* @__PURE__ */ s("div", { className: "pt-4 border-t flex items-center justify-between text-sm text-muted-foreground", children: [
|
|
1593
|
-
/* @__PURE__ */ s("span", { children: [
|
|
1594
|
-
g.length,
|
|
1595
|
-
" ",
|
|
1596
|
-
g.length === 1 ? o.singular : o.plural
|
|
1597
|
-
] }),
|
|
1598
|
-
/* @__PURE__ */ s("span", { children: [
|
|
1599
|
-
g.filter((T) => T.required).length,
|
|
1600
|
-
" required"
|
|
1601
|
-
] })
|
|
1602
|
-
] })
|
|
1603
|
-
] })
|
|
1684
|
+
) })
|
|
1685
|
+
] }) }),
|
|
1686
|
+
o && /* @__PURE__ */ e("div", { className: "w-2/5", children: /* @__PURE__ */ e(yt, { schema: t }) })
|
|
1604
1687
|
] }),
|
|
1605
|
-
|
|
1606
|
-
|
|
1688
|
+
C.isOpen && C.data && /* @__PURE__ */ e(
|
|
1689
|
+
Y,
|
|
1607
1690
|
{
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
/* @__PURE__ */ e(B, { className: "w-4 h-4" }),
|
|
1614
|
-
"Add ",
|
|
1615
|
-
o.singular
|
|
1616
|
-
]
|
|
1691
|
+
property: C.data,
|
|
1692
|
+
open: C.isOpen,
|
|
1693
|
+
isNewProperty: !0,
|
|
1694
|
+
onOpenChange: C.setIsOpen,
|
|
1695
|
+
onSave: C.confirm
|
|
1617
1696
|
}
|
|
1618
|
-
)
|
|
1619
|
-
] })
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
j.isOpen && j.data && /* @__PURE__ */ e(
|
|
1623
|
-
G,
|
|
1624
|
-
{
|
|
1625
|
-
property: j.data,
|
|
1626
|
-
open: j.isOpen,
|
|
1627
|
-
isNewProperty: !0,
|
|
1628
|
-
onOpenChange: j.setIsOpen,
|
|
1629
|
-
propertyLabel: o,
|
|
1630
|
-
onSave: j.confirm,
|
|
1631
|
-
showRegex: v,
|
|
1632
|
-
keyEditable: x
|
|
1633
|
-
}
|
|
1634
|
-
)
|
|
1635
|
-
] }) });
|
|
1697
|
+
)
|
|
1698
|
+
] })
|
|
1699
|
+
}
|
|
1700
|
+
);
|
|
1636
1701
|
}
|
|
1637
1702
|
export {
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
it as TypeLabelsProvider
|
|
1703
|
+
Rt as JsonSchemaBuilder,
|
|
1704
|
+
Y as PropertyEditDialog
|
|
1641
1705
|
};
|
|
1642
|
-
//# sourceMappingURL=index.js.map
|