@elqnt/workflow 2.1.4 → 2.2.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.
Files changed (45) hide show
  1. package/README.md +6 -0
  2. package/SKILL.md +442 -0
  3. package/dist/api/index.js +3 -4
  4. package/dist/api/index.js.map +1 -1
  5. package/dist/api/index.mjs +1 -2
  6. package/dist/chunk-3GG6KTGJ.js +998 -0
  7. package/dist/chunk-3GG6KTGJ.js.map +1 -0
  8. package/dist/{chunk-UE4ZBFLG.mjs → chunk-4AUWFGQK.mjs} +1 -3
  9. package/dist/{chunk-UE4ZBFLG.mjs.map → chunk-4AUWFGQK.mjs.map} +1 -1
  10. package/dist/{chunk-H24IF5AA.js → chunk-6DV2LPSN.js} +2 -4
  11. package/dist/chunk-6DV2LPSN.js.map +1 -0
  12. package/dist/chunk-AXXQSYT7.mjs +998 -0
  13. package/dist/chunk-AXXQSYT7.mjs.map +1 -0
  14. package/dist/{chunk-YCEGKVXP.mjs → chunk-IY5JCMLA.mjs} +1 -3
  15. package/dist/{chunk-YCEGKVXP.mjs.map → chunk-IY5JCMLA.mjs.map} +1 -1
  16. package/dist/{chunk-JES2EBNO.js → chunk-YCO5IFZK.js} +2 -4
  17. package/dist/chunk-YCO5IFZK.js.map +1 -0
  18. package/dist/components/index.d.mts +245 -0
  19. package/dist/components/index.d.ts +245 -0
  20. package/dist/components/index.js +10 -0
  21. package/dist/components/index.js.map +1 -0
  22. package/dist/components/index.mjs +10 -0
  23. package/dist/components/index.mjs.map +1 -0
  24. package/dist/hooks/index.d.mts +72 -27
  25. package/dist/hooks/index.d.ts +72 -27
  26. package/dist/hooks/index.js +397 -5
  27. package/dist/hooks/index.js.map +1 -1
  28. package/dist/hooks/index.mjs +401 -9
  29. package/dist/hooks/index.mjs.map +1 -1
  30. package/dist/index.d.mts +4 -246
  31. package/dist/index.d.ts +4 -246
  32. package/dist/index.js +8 -1012
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.mjs +5 -1009
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/models/index.js +3 -4
  37. package/dist/models/index.js.map +1 -1
  38. package/dist/models/index.mjs +1 -2
  39. package/package.json +12 -6
  40. package/dist/chunk-H24IF5AA.js.map +0 -1
  41. package/dist/chunk-JES2EBNO.js.map +0 -1
  42. package/dist/chunk-KWWX35B4.js +0 -413
  43. package/dist/chunk-KWWX35B4.js.map +0 -1
  44. package/dist/chunk-WDERYFU3.mjs +0 -413
  45. package/dist/chunk-WDERYFU3.mjs.map +0 -1
@@ -0,0 +1,998 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// components/dynamic-schema-form.tsx
2
+ var _react = require('react');
3
+ var _jsxruntime = require('react/jsx-runtime');
4
+ function DynamicSchemaForm({
5
+ schema,
6
+ value = {},
7
+ onChange,
8
+ disabled = false,
9
+ path = [],
10
+ components,
11
+ variables = [],
12
+ showVariablePicker = false
13
+ }) {
14
+ const [collapsedSections, setCollapsedSections] = _react.useState.call(void 0,
15
+ /* @__PURE__ */ new Set()
16
+ );
17
+ const [openVariablePickers, setOpenVariablePickers] = _react.useState.call(void 0,
18
+ /* @__PURE__ */ new Set()
19
+ );
20
+ const [openRichTextDialogs, setOpenRichTextDialogs] = _react.useState.call(void 0,
21
+ /* @__PURE__ */ new Set()
22
+ );
23
+ const [richTextDraftValues, setRichTextDraftValues] = _react.useState.call(void 0, {});
24
+ const {
25
+ Input,
26
+ Label,
27
+ Textarea,
28
+ Checkbox,
29
+ Select,
30
+ SelectTrigger,
31
+ SelectValue,
32
+ SelectContent,
33
+ SelectItem,
34
+ Button,
35
+ Card,
36
+ PlusIcon,
37
+ TrashIcon,
38
+ ChevronDownIcon,
39
+ ChevronRightIcon,
40
+ VariableIcon,
41
+ CheckIcon,
42
+ EditIcon,
43
+ Popover,
44
+ PopoverTrigger,
45
+ PopoverContent,
46
+ Dialog,
47
+ DialogContent,
48
+ DialogHeader,
49
+ DialogTitle,
50
+ DialogFooter,
51
+ ScrollArea,
52
+ MarkdownEditor,
53
+ cn
54
+ } = components;
55
+ const isVariableReference = (val) => {
56
+ return typeof val === "string" && val.startsWith("{{") && val.endsWith("}}");
57
+ };
58
+ const getMatchingVariables = (fieldType) => {
59
+ if (!fieldType) return variables;
60
+ const compatibleTypes = {
61
+ string: ["string"],
62
+ number: ["number", "integer"],
63
+ integer: ["number", "integer"],
64
+ boolean: ["boolean"],
65
+ object: ["object"],
66
+ array: ["array"]
67
+ };
68
+ const compatible = compatibleTypes[fieldType] || [fieldType];
69
+ return variables.filter((v) => compatible.includes(v.type));
70
+ };
71
+ const toggleVariablePicker = (fieldPath) => {
72
+ setOpenVariablePickers((prev) => {
73
+ const next = new Set(prev);
74
+ if (next.has(fieldPath)) {
75
+ next.delete(fieldPath);
76
+ } else {
77
+ next.add(fieldPath);
78
+ }
79
+ return next;
80
+ });
81
+ };
82
+ const renderVariablePicker = (fieldName, fieldType, fieldPath, onSelect) => {
83
+ if (!showVariablePicker) {
84
+ return null;
85
+ }
86
+ if (!VariableIcon || !Popover || !PopoverTrigger || !PopoverContent) {
87
+ return null;
88
+ }
89
+ const matchingVars = getMatchingVariables(fieldType);
90
+ const isOpen = openVariablePickers.has(fieldPath);
91
+ const currentValue = value[fieldName];
92
+ const isVariable = isVariableReference(currentValue);
93
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
94
+ Popover,
95
+ {
96
+ open: isOpen,
97
+ onOpenChange: (open) => {
98
+ if (open) {
99
+ setOpenVariablePickers((prev) => new Set(prev).add(fieldPath));
100
+ } else {
101
+ setOpenVariablePickers((prev) => {
102
+ const next = new Set(prev);
103
+ next.delete(fieldPath);
104
+ return next;
105
+ });
106
+ }
107
+ },
108
+ children: [
109
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
110
+ Button,
111
+ {
112
+ type: "button",
113
+ variant: "outline",
114
+ size: "sm",
115
+ className: cn(
116
+ "h-8 px-2 shrink-0",
117
+ isVariable && "border-primary text-primary"
118
+ ),
119
+ disabled,
120
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, VariableIcon, { className: "h-3.5 w-3.5" })
121
+ }
122
+ ) }),
123
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, PopoverContent, { className: "w-56 p-1", align: "end", children: [
124
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-xs font-medium text-muted-foreground px-2 py-1.5", children: [
125
+ "Select Variable (",
126
+ fieldType || "any",
127
+ ")"
128
+ ] }),
129
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "max-h-48 overflow-y-auto", children: matchingVars.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "px-2 py-3 text-xs text-muted-foreground text-center", children: [
130
+ "No variables available.",
131
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "br", {}),
132
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-[10px]", children: "Add variables in Workflow Settings \u2192 Variables" })
133
+ ] }) : matchingVars.map((variable) => {
134
+ const varRef = `{{${variable.path}}}`;
135
+ const isSelected = currentValue === varRef;
136
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
137
+ "button",
138
+ {
139
+ type: "button",
140
+ className: cn(
141
+ "w-full text-left px-2 py-1.5 text-xs rounded hover:bg-accent flex items-center justify-between",
142
+ isSelected && "bg-accent"
143
+ ),
144
+ onClick: () => {
145
+ onSelect(varRef);
146
+ setOpenVariablePickers((prev) => {
147
+ const next = new Set(prev);
148
+ next.delete(fieldPath);
149
+ return next;
150
+ });
151
+ },
152
+ children: [
153
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
154
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "font-medium", children: variable.title || variable.name }),
155
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-[10px] text-muted-foreground font-mono", children: variable.path })
156
+ ] }),
157
+ isSelected && CheckIcon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckIcon, { className: "h-3 w-3" })
158
+ ]
159
+ },
160
+ variable.path
161
+ );
162
+ }) })
163
+ ] })
164
+ ]
165
+ }
166
+ );
167
+ };
168
+ const toggleSection = (key) => {
169
+ setCollapsedSections((prev) => {
170
+ const next = new Set(prev);
171
+ if (next.has(key)) {
172
+ next.delete(key);
173
+ } else {
174
+ next.add(key);
175
+ }
176
+ return next;
177
+ });
178
+ };
179
+ const handleFieldChange = (fieldName, fieldValue) => {
180
+ onChange({
181
+ ...value,
182
+ [fieldName]: fieldValue
183
+ });
184
+ };
185
+ const renderField = (fieldSchema, fieldName, fieldValue) => {
186
+ const fieldPath = [...path, fieldName].join(".");
187
+ const isRequired = _optionalChain([schema, 'access', _2 => _2.required, 'optionalAccess', _3 => _3.includes, 'call', _4 => _4(fieldName)]);
188
+ if (fieldSchema.enum) {
189
+ const labels = fieldSchema["x-enumLabels"] || fieldSchema.enum;
190
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-1.5", children: [
191
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Label, { className: "text-xs font-medium", children: [
192
+ fieldSchema.title || fieldName,
193
+ isRequired && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-red-500 ml-0.5", children: "*" })
194
+ ] }),
195
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
196
+ Select,
197
+ {
198
+ value: fieldValue || "",
199
+ onValueChange: (v) => handleFieldChange(fieldName, v),
200
+ disabled,
201
+ children: [
202
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
203
+ SelectValue,
204
+ {
205
+ placeholder: `Select ${fieldSchema.title || fieldName}`
206
+ }
207
+ ) }),
208
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectContent, { children: fieldSchema.enum.map((option, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectItem, { value: option, className: "text-xs", children: labels[idx] || option }, option)) })
209
+ ]
210
+ }
211
+ ),
212
+ fieldSchema.description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description })
213
+ ] }, fieldPath);
214
+ }
215
+ if (fieldSchema.type === "object" && fieldSchema.properties) {
216
+ const isCollapsed = collapsedSections.has(fieldPath);
217
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
218
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
219
+ "button",
220
+ {
221
+ type: "button",
222
+ onClick: () => toggleSection(fieldPath),
223
+ className: "flex items-center gap-1 text-xs font-medium text-gray-700 hover:text-gray-900",
224
+ children: [
225
+ isCollapsed ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChevronRightIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChevronDownIcon, { className: "h-3 w-3" }),
226
+ fieldSchema.title || fieldName
227
+ ]
228
+ }
229
+ ),
230
+ !isCollapsed && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Card, { className: "p-3 bg-gray-50/50", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
231
+ DynamicSchemaForm,
232
+ {
233
+ schema: fieldSchema,
234
+ value: fieldValue || {},
235
+ onChange: (v) => handleFieldChange(fieldName, v),
236
+ disabled,
237
+ path: [...path, fieldName],
238
+ components,
239
+ variables,
240
+ showVariablePicker
241
+ }
242
+ ) })
243
+ ] }, fieldPath);
244
+ }
245
+ if (fieldSchema.type === "array" && fieldSchema.items) {
246
+ const arrayValue = Array.isArray(fieldValue) ? fieldValue : [];
247
+ const itemSchema = fieldSchema.items;
248
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
249
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between", children: [
250
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Label, { className: "text-xs font-medium", children: [
251
+ fieldSchema.title || fieldName,
252
+ isRequired && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-red-500 ml-0.5", children: "*" })
253
+ ] }),
254
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
255
+ Button,
256
+ {
257
+ type: "button",
258
+ variant: "outline",
259
+ size: "sm",
260
+ className: "h-6 text-xs px-2",
261
+ onClick: () => {
262
+ const newItem = itemSchema.type === "object" ? {} : "";
263
+ handleFieldChange(fieldName, [...arrayValue, newItem]);
264
+ },
265
+ disabled,
266
+ children: [
267
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PlusIcon, { className: "h-3 w-3 mr-1" }),
268
+ "Add"
269
+ ]
270
+ }
271
+ )
272
+ ] }),
273
+ fieldSchema.description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description }),
274
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-2", children: arrayValue.map((item, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-2 items-start", children: [
275
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1", children: itemSchema.type === "object" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Card, { className: "p-2 bg-gray-50/50", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
276
+ DynamicSchemaForm,
277
+ {
278
+ schema: itemSchema,
279
+ value: item,
280
+ onChange: (v) => {
281
+ const newArray = [...arrayValue];
282
+ newArray[index] = v;
283
+ handleFieldChange(fieldName, newArray);
284
+ },
285
+ disabled,
286
+ path: [...path, fieldName, String(index)],
287
+ components,
288
+ variables,
289
+ showVariablePicker
290
+ }
291
+ ) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
292
+ Input,
293
+ {
294
+ value: item || "",
295
+ onChange: (e) => {
296
+ const newArray = [...arrayValue];
297
+ newArray[index] = e.target.value;
298
+ handleFieldChange(fieldName, newArray);
299
+ },
300
+ disabled,
301
+ className: "h-8 text-xs"
302
+ }
303
+ ) }),
304
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
305
+ Button,
306
+ {
307
+ type: "button",
308
+ variant: "ghost",
309
+ size: "sm",
310
+ className: "h-8 w-8 p-0 text-red-500 hover:text-red-700",
311
+ onClick: () => {
312
+ const newArray = arrayValue.filter(
313
+ (_, i) => i !== index
314
+ );
315
+ handleFieldChange(fieldName, newArray);
316
+ },
317
+ disabled,
318
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TrashIcon, { className: "h-3 w-3" })
319
+ }
320
+ )
321
+ ] }, index)) })
322
+ ] }, fieldPath);
323
+ }
324
+ if (fieldSchema.type === "boolean") {
325
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-2", children: [
326
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
327
+ Checkbox,
328
+ {
329
+ id: fieldPath,
330
+ checked: !!fieldValue,
331
+ onCheckedChange: (checked) => handleFieldChange(fieldName, checked),
332
+ disabled
333
+ }
334
+ ),
335
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Label, { htmlFor: fieldPath, className: "text-xs font-normal", children: [
336
+ fieldSchema.title || fieldName,
337
+ isRequired && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-red-500 ml-0.5", children: "*" })
338
+ ] }),
339
+ fieldSchema.description && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "text-[10px] text-muted-foreground ml-2", children: [
340
+ "(",
341
+ fieldSchema.description,
342
+ ")"
343
+ ] })
344
+ ] }, fieldPath);
345
+ }
346
+ if (fieldSchema.type === "number" || fieldSchema.type === "integer") {
347
+ const isVarValue = isVariableReference(fieldValue);
348
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-1.5", children: [
349
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Label, { className: "text-xs font-medium", children: [
350
+ fieldSchema.title || fieldName,
351
+ isRequired && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-red-500 ml-0.5", children: "*" })
352
+ ] }),
353
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-1.5", children: [
354
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
355
+ Input,
356
+ {
357
+ type: isVarValue ? "text" : "number",
358
+ value: _nullishCoalesce(fieldValue, () => ( "")),
359
+ onChange: (e) => {
360
+ if (isVariableReference(e.target.value)) {
361
+ handleFieldChange(fieldName, e.target.value);
362
+ } else {
363
+ const val = e.target.value === "" ? void 0 : Number(e.target.value);
364
+ handleFieldChange(fieldName, val);
365
+ }
366
+ },
367
+ min: fieldSchema.minimum,
368
+ max: fieldSchema.maximum,
369
+ step: fieldSchema.type === "integer" ? 1 : "any",
370
+ disabled,
371
+ className: cn("h-8 text-xs flex-1", isVarValue && "font-mono text-primary")
372
+ }
373
+ ),
374
+ renderVariablePicker(
375
+ fieldName,
376
+ fieldSchema.type,
377
+ fieldPath,
378
+ (varPath) => handleFieldChange(fieldName, varPath)
379
+ )
380
+ ] }),
381
+ fieldSchema.description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description })
382
+ ] }, fieldPath);
383
+ }
384
+ if (fieldSchema.type === "string") {
385
+ if (fieldSchema.format === "richtext") {
386
+ const isDialogOpen = openRichTextDialogs.has(fieldPath);
387
+ const draftValue = _nullishCoalesce(_nullishCoalesce(richTextDraftValues[fieldPath], () => ( fieldValue)), () => ( ""));
388
+ const previewText = (fieldValue || "").replace(/<[^>]*>/g, "").slice(0, 50);
389
+ const matchingVars = getMatchingVariables("string");
390
+ if (!Dialog || !DialogContent || !DialogHeader || !DialogTitle || !DialogFooter) {
391
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-1.5", children: [
392
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between", children: [
393
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Label, { className: "text-xs font-medium", children: [
394
+ fieldSchema.title || fieldName,
395
+ isRequired && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-red-500 ml-0.5", children: "*" })
396
+ ] }),
397
+ renderVariablePicker(
398
+ fieldName,
399
+ "string",
400
+ fieldPath,
401
+ (varPath) => handleFieldChange(fieldName, (fieldValue || "") + varPath)
402
+ )
403
+ ] }),
404
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
405
+ Textarea,
406
+ {
407
+ value: fieldValue || "",
408
+ onChange: (e) => handleFieldChange(fieldName, e.target.value),
409
+ disabled,
410
+ rows: 3,
411
+ className: "text-xs",
412
+ placeholder: fieldSchema.description
413
+ }
414
+ )
415
+ ] }, fieldPath);
416
+ }
417
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-1.5", children: [
418
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Label, { className: "text-xs font-medium", children: [
419
+ fieldSchema.title || fieldName,
420
+ isRequired && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-red-500 ml-0.5", children: "*" })
421
+ ] }),
422
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-1.5", children: [
423
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 min-w-0 px-2 py-1.5 bg-muted/50 rounded text-xs text-muted-foreground truncate border", children: previewText || /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "italic", children: "Click edit to add content..." }) }),
424
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
425
+ Button,
426
+ {
427
+ type: "button",
428
+ variant: "outline",
429
+ size: "sm",
430
+ className: "h-8 px-2 shrink-0",
431
+ onClick: () => {
432
+ setRichTextDraftValues((prev) => ({ ...prev, [fieldPath]: fieldValue || "" }));
433
+ setOpenRichTextDialogs((prev) => new Set(prev).add(fieldPath));
434
+ },
435
+ disabled,
436
+ children: EditIcon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EditIcon, { className: "h-3.5 w-3.5" }) : "Edit"
437
+ }
438
+ )
439
+ ] }),
440
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
441
+ Dialog,
442
+ {
443
+ open: isDialogOpen,
444
+ onOpenChange: (open) => {
445
+ if (!open) {
446
+ setOpenRichTextDialogs((prev) => {
447
+ const next = new Set(prev);
448
+ next.delete(fieldPath);
449
+ return next;
450
+ });
451
+ }
452
+ },
453
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogContent, { className: "max-w-3xl max-h-[85vh] flex flex-col", children: [
454
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogHeader, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogTitle, { children: [
455
+ "Edit ",
456
+ fieldSchema.title || fieldName
457
+ ] }) }),
458
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 overflow-hidden flex flex-col min-h-0", children: MarkdownEditor ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
459
+ MarkdownEditor,
460
+ {
461
+ content: draftValue,
462
+ onChange: (value2) => {
463
+ setRichTextDraftValues((prev) => ({ ...prev, [fieldPath]: value2 }));
464
+ },
465
+ placeholder: "Enter content... Use {{variables.name}} for dynamic values",
466
+ minHeight: "300px",
467
+ variables: showVariablePicker ? matchingVars : []
468
+ }
469
+ ) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
470
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
471
+ Textarea,
472
+ {
473
+ value: draftValue,
474
+ onChange: (e) => {
475
+ setRichTextDraftValues((prev) => ({ ...prev, [fieldPath]: e.target.value }));
476
+ },
477
+ rows: 12,
478
+ className: "flex-1 text-sm font-mono resize-none",
479
+ placeholder: "Enter content... Use {{variables.name}} for dynamic values"
480
+ }
481
+ ),
482
+ showVariablePicker && matchingVars.length > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "border rounded-md p-2 bg-muted/30 mt-3", children: [
483
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs font-medium mb-2", children: "Insert Variable:" }),
484
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-wrap gap-1", children: matchingVars.map((variable) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
485
+ Button,
486
+ {
487
+ type: "button",
488
+ variant: "outline",
489
+ size: "sm",
490
+ className: "h-6 text-xs px-2",
491
+ onClick: () => {
492
+ const varRef = `{{${variable.path}}}`;
493
+ setRichTextDraftValues((prev) => ({
494
+ ...prev,
495
+ [fieldPath]: (prev[fieldPath] || "") + varRef
496
+ }));
497
+ },
498
+ children: variable.title || variable.name
499
+ },
500
+ variable.path
501
+ )) })
502
+ ] })
503
+ ] }) }),
504
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogFooter, { children: [
505
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
506
+ Button,
507
+ {
508
+ type: "button",
509
+ variant: "outline",
510
+ onClick: () => {
511
+ setOpenRichTextDialogs((prev) => {
512
+ const next = new Set(prev);
513
+ next.delete(fieldPath);
514
+ return next;
515
+ });
516
+ },
517
+ children: "Cancel"
518
+ }
519
+ ),
520
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
521
+ Button,
522
+ {
523
+ type: "button",
524
+ onClick: () => {
525
+ handleFieldChange(fieldName, draftValue);
526
+ setOpenRichTextDialogs((prev) => {
527
+ const next = new Set(prev);
528
+ next.delete(fieldPath);
529
+ return next;
530
+ });
531
+ },
532
+ children: "Save"
533
+ }
534
+ )
535
+ ] })
536
+ ] })
537
+ }
538
+ )
539
+ ] }, fieldPath);
540
+ }
541
+ if (fieldSchema.format === "multiline" || fieldSchema.format === "textarea") {
542
+ const isVarValue2 = isVariableReference(fieldValue);
543
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-1.5", children: [
544
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between", children: [
545
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Label, { className: "text-xs font-medium", children: [
546
+ fieldSchema.title || fieldName,
547
+ isRequired && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-red-500 ml-0.5", children: "*" })
548
+ ] }),
549
+ renderVariablePicker(
550
+ fieldName,
551
+ "string",
552
+ fieldPath,
553
+ (varPath) => handleFieldChange(fieldName, (fieldValue || "") + varPath)
554
+ )
555
+ ] }),
556
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
557
+ Textarea,
558
+ {
559
+ value: fieldValue || "",
560
+ onChange: (e) => handleFieldChange(fieldName, e.target.value),
561
+ disabled,
562
+ rows: 3,
563
+ className: cn("text-xs", isVarValue2 && "font-mono text-primary"),
564
+ placeholder: fieldSchema.description
565
+ }
566
+ ),
567
+ fieldSchema.description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description })
568
+ ] }, fieldPath);
569
+ }
570
+ const inputType = fieldSchema.format === "email" ? "email" : fieldSchema.format === "uri" || fieldSchema.format === "url" ? "url" : fieldSchema.format === "password" ? "password" : "text";
571
+ const isVarValue = isVariableReference(fieldValue);
572
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-1.5", children: [
573
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Label, { className: "text-xs font-medium", children: [
574
+ fieldSchema.title || fieldName,
575
+ isRequired && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-red-500 ml-0.5", children: "*" })
576
+ ] }),
577
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-1.5", children: [
578
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
579
+ Input,
580
+ {
581
+ type: inputType,
582
+ value: fieldValue || "",
583
+ onChange: (e) => handleFieldChange(fieldName, e.target.value),
584
+ disabled,
585
+ className: cn("h-8 text-xs flex-1", isVarValue && "font-mono text-primary"),
586
+ placeholder: fieldSchema.description
587
+ }
588
+ ),
589
+ renderVariablePicker(
590
+ fieldName,
591
+ "string",
592
+ fieldPath,
593
+ (varPath) => handleFieldChange(fieldName, (fieldValue || "") + varPath)
594
+ )
595
+ ] }),
596
+ fieldSchema.description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description })
597
+ ] }, fieldPath);
598
+ }
599
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-1.5", children: [
600
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Label, { className: "text-xs font-medium", children: [
601
+ fieldSchema.title || fieldName,
602
+ isRequired && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-red-500 ml-0.5", children: "*" })
603
+ ] }),
604
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
605
+ Input,
606
+ {
607
+ value: typeof fieldValue === "object" ? JSON.stringify(fieldValue) : fieldValue || "",
608
+ onChange: (e) => {
609
+ try {
610
+ const parsed = JSON.parse(e.target.value);
611
+ handleFieldChange(fieldName, parsed);
612
+ } catch (e2) {
613
+ handleFieldChange(fieldName, e.target.value);
614
+ }
615
+ },
616
+ disabled,
617
+ className: "h-8 text-xs font-mono"
618
+ }
619
+ ),
620
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-[10px] text-muted-foreground", children: [
621
+ "Type: ",
622
+ fieldSchema.type || "unknown"
623
+ ] })
624
+ ] }, fieldPath);
625
+ };
626
+ if (schema.type === "object" && schema.properties) {
627
+ const sortedProperties = Object.entries(schema.properties).sort(
628
+ ([, a], [, b]) => {
629
+ const orderA = _nullishCoalesce(a["x-displayOrder"], () => ( 999));
630
+ const orderB = _nullishCoalesce(b["x-displayOrder"], () => ( 999));
631
+ return orderA - orderB;
632
+ }
633
+ );
634
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-3", children: sortedProperties.map(
635
+ ([fieldName, fieldSchema]) => renderField(fieldSchema, fieldName, value[fieldName])
636
+ ) });
637
+ }
638
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground text-center py-4", children: "No configuration required for this node." });
639
+ }
640
+
641
+ // components/schema-builder.tsx
642
+
643
+
644
+ var FIELD_TYPES = [
645
+ { value: "string", label: "Text" },
646
+ { value: "number", label: "Number" },
647
+ { value: "integer", label: "Integer" },
648
+ { value: "boolean", label: "Boolean" },
649
+ { value: "array", label: "Array" },
650
+ { value: "object", label: "Object" }
651
+ ];
652
+ var STRING_FORMATS = [
653
+ { value: "plain", label: "Plain Text" },
654
+ { value: "email", label: "Email" },
655
+ { value: "uri", label: "URL" },
656
+ { value: "date", label: "Date" },
657
+ { value: "date-time", label: "Date & Time" },
658
+ { value: "multiline", label: "Multiline Text" }
659
+ ];
660
+ function SchemaBuilder({
661
+ schema,
662
+ onChange,
663
+ disabled = false,
664
+ components
665
+ }) {
666
+ const [expandedFields, setExpandedFields] = _react.useState.call(void 0, /* @__PURE__ */ new Set());
667
+ const {
668
+ Input,
669
+ Label,
670
+ Checkbox,
671
+ Select,
672
+ SelectTrigger,
673
+ SelectValue,
674
+ SelectContent,
675
+ SelectItem,
676
+ Button,
677
+ Card,
678
+ PlusIcon,
679
+ TrashIcon,
680
+ GripVerticalIcon,
681
+ ChevronDownIcon,
682
+ ChevronRightIcon
683
+ } = components;
684
+ const getFieldsFromSchema = () => {
685
+ if (!_optionalChain([schema, 'optionalAccess', _5 => _5.properties])) return [];
686
+ return Object.entries(schema.properties).map(([name, prop]) => {
687
+ const fieldSchema = prop;
688
+ return {
689
+ name,
690
+ type: fieldSchema.type || "string",
691
+ title: fieldSchema.title || name,
692
+ description: fieldSchema.description || "",
693
+ required: _optionalChain([schema, 'access', _6 => _6.required, 'optionalAccess', _7 => _7.includes, 'call', _8 => _8(name)]) || false,
694
+ format: fieldSchema.format,
695
+ enum: fieldSchema.enum,
696
+ items: fieldSchema.items
697
+ };
698
+ });
699
+ };
700
+ const fields = getFieldsFromSchema();
701
+ const updateSchema = (newFields) => {
702
+ const properties = {};
703
+ const required = [];
704
+ newFields.forEach((field) => {
705
+ if (!field.name) return;
706
+ const fieldSchema = {
707
+ type: field.type,
708
+ title: field.title || field.name
709
+ };
710
+ if (field.description) {
711
+ fieldSchema.description = field.description;
712
+ }
713
+ if (field.format && field.format !== "plain") {
714
+ fieldSchema.format = field.format;
715
+ }
716
+ if (field.enum && field.enum.length > 0) {
717
+ fieldSchema.enum = field.enum;
718
+ }
719
+ if (field.type === "array" && field.items) {
720
+ fieldSchema.items = field.items;
721
+ }
722
+ properties[field.name] = fieldSchema;
723
+ if (field.required) {
724
+ required.push(field.name);
725
+ }
726
+ });
727
+ onChange({
728
+ type: "object",
729
+ properties,
730
+ required: required.length > 0 ? required : void 0
731
+ });
732
+ };
733
+ const addField = () => {
734
+ const newFieldName = `field_${fields.length + 1}`;
735
+ const newFields = [
736
+ ...fields,
737
+ {
738
+ name: newFieldName,
739
+ type: "string",
740
+ title: "",
741
+ description: "",
742
+ required: false
743
+ }
744
+ ];
745
+ updateSchema(newFields);
746
+ setExpandedFields((prev) => /* @__PURE__ */ new Set([...prev, newFieldName]));
747
+ };
748
+ const updateField = (index, updates) => {
749
+ const newFields = [...fields];
750
+ newFields[index] = { ...newFields[index], ...updates };
751
+ updateSchema(newFields);
752
+ };
753
+ const removeField = (index) => {
754
+ const newFields = fields.filter((_, i) => i !== index);
755
+ updateSchema(newFields);
756
+ };
757
+ const toggleExpand = (name) => {
758
+ setExpandedFields((prev) => {
759
+ const next = new Set(prev);
760
+ if (next.has(name)) {
761
+ next.delete(name);
762
+ } else {
763
+ next.add(name);
764
+ }
765
+ return next;
766
+ });
767
+ };
768
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
769
+ fields.length === 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-muted-foreground italic py-3", children: 'No fields defined. Click "Add Field" to create one.' }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-3", children: fields.map((field, index) => {
770
+ const isExpanded = expandedFields.has(field.name);
771
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Card, { className: "p-3 bg-gray-50/50", children: [
772
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2 mb-2", children: [
773
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GripVerticalIcon, { className: "h-4 w-4 text-gray-300 flex-shrink-0 cursor-grab" }),
774
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
775
+ "button",
776
+ {
777
+ type: "button",
778
+ onClick: () => toggleExpand(field.name),
779
+ className: "flex-shrink-0 p-1 hover:bg-gray-200 rounded",
780
+ children: isExpanded ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChevronDownIcon, { className: "h-4 w-4 text-gray-500" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChevronRightIcon, { className: "h-4 w-4 text-gray-500" })
781
+ }
782
+ ),
783
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
784
+ Input,
785
+ {
786
+ value: field.name,
787
+ onChange: (e) => {
788
+ const oldName = field.name;
789
+ const newName = e.target.value.toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, "");
790
+ updateField(index, { name: newName });
791
+ if (expandedFields.has(oldName)) {
792
+ setExpandedFields((prev) => {
793
+ const next = new Set(prev);
794
+ next.delete(oldName);
795
+ next.add(newName);
796
+ return next;
797
+ });
798
+ }
799
+ },
800
+ placeholder: "field_name",
801
+ className: "h-9 text-sm font-mono",
802
+ disabled
803
+ }
804
+ ) }),
805
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
806
+ Button,
807
+ {
808
+ type: "button",
809
+ variant: "ghost",
810
+ size: "sm",
811
+ className: "h-9 w-9 p-0 text-red-500 hover:text-red-700 hover:bg-red-50 flex-shrink-0",
812
+ onClick: () => removeField(index),
813
+ disabled,
814
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TrashIcon, { className: "h-4 w-4" })
815
+ }
816
+ )
817
+ ] }),
818
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-3 pl-10", children: [
819
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
820
+ Select,
821
+ {
822
+ value: field.type,
823
+ onValueChange: (v) => updateField(index, { type: v }),
824
+ disabled,
825
+ children: [
826
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectTrigger, { className: "h-9 text-sm", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectValue, {}) }),
827
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectContent, { children: FIELD_TYPES.map((type) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectItem, { value: type.value, children: type.label }, type.value)) })
828
+ ]
829
+ }
830
+ ) }),
831
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2 flex-shrink-0", children: [
832
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
833
+ Checkbox,
834
+ {
835
+ id: `required-${index}`,
836
+ checked: field.required,
837
+ onCheckedChange: (checked) => updateField(index, { required: !!checked }),
838
+ disabled
839
+ }
840
+ ),
841
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
842
+ Label,
843
+ {
844
+ htmlFor: `required-${index}`,
845
+ className: "text-sm text-muted-foreground",
846
+ children: "Required"
847
+ }
848
+ )
849
+ ] })
850
+ ] }),
851
+ isExpanded && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-3 pt-3 border-t space-y-3 pl-10", children: [
852
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-1", children: [
853
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Label, { className: "text-xs text-muted-foreground", children: "Display Title" }),
854
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
855
+ Input,
856
+ {
857
+ value: field.title,
858
+ onChange: (e) => updateField(index, { title: e.target.value }),
859
+ placeholder: "Human readable title",
860
+ className: "h-9 text-sm",
861
+ disabled
862
+ }
863
+ )
864
+ ] }),
865
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-1", children: [
866
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Label, { className: "text-xs text-muted-foreground", children: "Description" }),
867
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
868
+ Input,
869
+ {
870
+ value: field.description,
871
+ onChange: (e) => updateField(index, { description: e.target.value }),
872
+ placeholder: "Help text for this field",
873
+ className: "h-9 text-sm",
874
+ disabled
875
+ }
876
+ )
877
+ ] }),
878
+ field.type === "string" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-1", children: [
879
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Label, { className: "text-xs text-muted-foreground", children: "Format" }),
880
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
881
+ Select,
882
+ {
883
+ value: field.format || "plain",
884
+ onValueChange: (v) => updateField(index, { format: v }),
885
+ disabled,
886
+ children: [
887
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectTrigger, { className: "h-9 text-sm", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectValue, {}) }),
888
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectContent, { children: STRING_FORMATS.map((format) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectItem, { value: format.value, children: format.label }, format.value)) })
889
+ ]
890
+ }
891
+ )
892
+ ] }),
893
+ field.type === "array" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-1", children: [
894
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Label, { className: "text-xs text-muted-foreground", children: "Item Type" }),
895
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
896
+ Select,
897
+ {
898
+ value: _optionalChain([field, 'access', _9 => _9.items, 'optionalAccess', _10 => _10.type]) || "string",
899
+ onValueChange: (v) => updateField(index, { items: { type: v } }),
900
+ disabled,
901
+ children: [
902
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectTrigger, { className: "h-9 text-sm", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectValue, {}) }),
903
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectContent, { children: FIELD_TYPES.filter((t) => t.value !== "array").map(
904
+ (type) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectItem, { value: type.value, children: type.label }, type.value)
905
+ ) })
906
+ ]
907
+ }
908
+ )
909
+ ] }),
910
+ field.type === "string" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-2", children: [
911
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between", children: [
912
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Label, { className: "text-xs text-muted-foreground", children: "Dropdown Options (optional)" }),
913
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
914
+ Button,
915
+ {
916
+ type: "button",
917
+ variant: "outline",
918
+ size: "sm",
919
+ className: "h-7 text-xs",
920
+ onClick: () => {
921
+ const currentEnum = field.enum || [];
922
+ updateField(index, {
923
+ enum: [
924
+ ...currentEnum,
925
+ `option_${currentEnum.length + 1}`
926
+ ]
927
+ });
928
+ },
929
+ disabled,
930
+ children: [
931
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PlusIcon, { className: "h-3 w-3 mr-1" }),
932
+ "Add Option"
933
+ ]
934
+ }
935
+ )
936
+ ] }),
937
+ field.enum && field.enum.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-2", children: field.enum.map((option, optIdx) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
938
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
939
+ Input,
940
+ {
941
+ value: option,
942
+ onChange: (e) => {
943
+ const newEnum = [...field.enum || []];
944
+ newEnum[optIdx] = e.target.value;
945
+ updateField(index, { enum: newEnum });
946
+ },
947
+ placeholder: `Option ${optIdx + 1}`,
948
+ className: "h-8 text-sm flex-1",
949
+ disabled
950
+ }
951
+ ),
952
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
953
+ Button,
954
+ {
955
+ type: "button",
956
+ variant: "ghost",
957
+ size: "sm",
958
+ className: "h-8 w-8 p-0 text-red-400 hover:text-red-600",
959
+ onClick: () => {
960
+ const newEnum = (field.enum || []).filter(
961
+ (_, i) => i !== optIdx
962
+ );
963
+ updateField(index, {
964
+ enum: newEnum.length > 0 ? newEnum : void 0
965
+ });
966
+ },
967
+ disabled,
968
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TrashIcon, { className: "h-3 w-3" })
969
+ }
970
+ )
971
+ ] }, optIdx)) })
972
+ ] })
973
+ ] })
974
+ ] }, index);
975
+ }) }),
976
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
977
+ Button,
978
+ {
979
+ type: "button",
980
+ variant: "outline",
981
+ size: "sm",
982
+ className: "w-full h-9 text-sm",
983
+ onClick: addField,
984
+ disabled,
985
+ children: [
986
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PlusIcon, { className: "h-4 w-4 mr-2" }),
987
+ "Add Field"
988
+ ]
989
+ }
990
+ )
991
+ ] });
992
+ }
993
+
994
+
995
+
996
+
997
+ exports.DynamicSchemaForm = DynamicSchemaForm; exports.SchemaBuilder = SchemaBuilder;
998
+ //# sourceMappingURL=chunk-3GG6KTGJ.js.map