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