@datenlotse/jsonjoy-builder 0.4.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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +203 -0
  3. package/dist/components/SchemaEditor/AddFieldButton.js +312 -0
  4. package/dist/components/SchemaEditor/JsonSchemaEditor.js +166 -0
  5. package/dist/components/SchemaEditor/JsonSchemaVisualizer.js +96 -0
  6. package/dist/components/SchemaEditor/SchemaField.js +104 -0
  7. package/dist/components/SchemaEditor/SchemaFieldList.js +84 -0
  8. package/dist/components/SchemaEditor/SchemaPropertyEditor.js +249 -0
  9. package/dist/components/SchemaEditor/SchemaTypeSelector.js +55 -0
  10. package/dist/components/SchemaEditor/SchemaVisualEditor.js +77 -0
  11. package/dist/components/SchemaEditor/TypeDropdown.js +72 -0
  12. package/dist/components/SchemaEditor/TypeEditor.js +71 -0
  13. package/dist/components/SchemaEditor/types/ArrayEditor.js +173 -0
  14. package/dist/components/SchemaEditor/types/BooleanEditor.js +107 -0
  15. package/dist/components/SchemaEditor/types/NumberEditor.js +583 -0
  16. package/dist/components/SchemaEditor/types/ObjectEditor.js +90 -0
  17. package/dist/components/SchemaEditor/types/StringEditor.js +542 -0
  18. package/dist/components/features/JsonValidator.js +239 -0
  19. package/dist/components/features/SchemaInferencer.js +107 -0
  20. package/dist/components/ui/badge.js +25 -0
  21. package/dist/components/ui/button.js +41 -0
  22. package/dist/components/ui/dialog.js +73 -0
  23. package/dist/components/ui/input.js +11 -0
  24. package/dist/components/ui/label.js +13 -0
  25. package/dist/components/ui/select.js +90 -0
  26. package/dist/components/ui/switch.js +14 -0
  27. package/dist/components/ui/tabs.js +24 -0
  28. package/dist/components/ui/tooltip.js +15 -0
  29. package/dist/hooks/use-monaco-theme.js +197 -0
  30. package/dist/hooks/use-translation.js +14 -0
  31. package/dist/i18n/locales/de.js +143 -0
  32. package/dist/i18n/locales/en.js +143 -0
  33. package/dist/i18n/locales/es.js +143 -0
  34. package/dist/i18n/locales/fr.js +143 -0
  35. package/dist/i18n/locales/ru.js +143 -0
  36. package/dist/i18n/locales/uk.js +143 -0
  37. package/dist/i18n/locales/zh.js +143 -0
  38. package/dist/i18n/translation-context.js +4 -0
  39. package/dist/i18n/translation-keys.js +0 -0
  40. package/dist/index.css +3830 -0
  41. package/dist/index.d.ts +995 -0
  42. package/dist/index.js +10 -0
  43. package/dist/lib/schema-inference.js +266 -0
  44. package/dist/lib/schemaCompile.js +113 -0
  45. package/dist/lib/schemaEditor.js +167 -0
  46. package/dist/lib/utils.js +40 -0
  47. package/dist/types/jsonSchema.js +98 -0
  48. package/dist/types/validation.js +215 -0
  49. package/dist/utils/jsonValidator.js +162 -0
  50. package/package.json +112 -0
@@ -0,0 +1,583 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { X } from "lucide-react";
3
+ import { useEffect, useId, useMemo, useState } from "react";
4
+ import { Input } from "../../ui/input.js";
5
+ import { Label } from "../../ui/label.js";
6
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../ui/select.js";
7
+ import { useTranslation } from "../../../hooks/use-translation.js";
8
+ import { getEligibleEnumControllingProperties } from "../../../lib/schemaEditor.js";
9
+ import { cn } from "../../../lib/utils.js";
10
+ import { isBooleanSchema, withObjectSchema } from "../../../types/jsonSchema.js";
11
+ const NumberEditor = ({ schema, validationNode, onChange, integer = false, readOnly = false, parentSchema, propertyName })=>{
12
+ const [enumValue, setEnumValue] = useState("");
13
+ const [dependentEnumValue, setDependentEnumValue] = useState({});
14
+ const [selectedControllingValue, setSelectedControllingValue] = useState("");
15
+ const t = useTranslation();
16
+ const eligibleControllers = useMemo(()=>parentSchema && propertyName ? getEligibleEnumControllingProperties(parentSchema, propertyName) : [], [
17
+ parentSchema,
18
+ propertyName
19
+ ]);
20
+ const dependentEnum = withObjectSchema(schema, (s)=>s.$dependentEnum, void 0);
21
+ const enumMode = null != dependentEnum ? "depends" : "static";
22
+ const controllingProperty = dependentEnum?.property;
23
+ const dependentValuesMap = dependentEnum?.values ?? {};
24
+ const currentController = useMemo(()=>eligibleControllers.find((c)=>c.name === controllingProperty), [
25
+ eligibleControllers,
26
+ controllingProperty
27
+ ]);
28
+ const controllingValues = currentController?.values ?? [];
29
+ const activeKey = useMemo(()=>{
30
+ if (0 === controllingValues.length) return "";
31
+ const first = String(controllingValues[0]);
32
+ if (selectedControllingValue && controllingValues.some((v)=>String(v) === selectedControllingValue)) return selectedControllingValue;
33
+ return first;
34
+ }, [
35
+ controllingValues,
36
+ selectedControllingValue
37
+ ]);
38
+ useEffect(()=>{
39
+ if ("depends" === enumMode && controllingValues.length > 0) {
40
+ const valid = selectedControllingValue && controllingValues.some((v)=>String(v) === selectedControllingValue);
41
+ if (!valid) setSelectedControllingValue(String(controllingValues[0]));
42
+ }
43
+ }, [
44
+ enumMode,
45
+ controllingProperty,
46
+ controllingValues,
47
+ selectedControllingValue
48
+ ]);
49
+ const maximumId = useId();
50
+ const minimumId = useId();
51
+ const exclusiveMinimumId = useId();
52
+ const exclusiveMaximumId = useId();
53
+ const multipleOfId = useId();
54
+ const minimum = withObjectSchema(schema, (s)=>s.minimum, void 0);
55
+ const maximum = withObjectSchema(schema, (s)=>s.maximum, void 0);
56
+ const exclusiveMinimum = withObjectSchema(schema, (s)=>s.exclusiveMinimum, void 0);
57
+ const exclusiveMaximum = withObjectSchema(schema, (s)=>s.exclusiveMaximum, void 0);
58
+ const multipleOf = withObjectSchema(schema, (s)=>s.multipleOf, void 0);
59
+ const enumValues = withObjectSchema(schema, (s)=>s.enum || [], []);
60
+ const basePropertiesForValidation = useMemo(()=>{
61
+ const base = {
62
+ type: integer ? "integer" : "number"
63
+ };
64
+ if (!isBooleanSchema(schema)) {
65
+ if (void 0 !== schema.minimum) base.minimum = schema.minimum;
66
+ if (void 0 !== schema.maximum) base.maximum = schema.maximum;
67
+ if (void 0 !== schema.exclusiveMinimum) base.exclusiveMinimum = schema.exclusiveMinimum;
68
+ if (void 0 !== schema.exclusiveMaximum) base.exclusiveMaximum = schema.exclusiveMaximum;
69
+ if (void 0 !== schema.multipleOf) base.multipleOf = schema.multipleOf;
70
+ if (void 0 !== schema.enum) base.enum = schema.enum;
71
+ if (void 0 !== schema.$dependentEnum) base.$dependentEnum = schema.$dependentEnum;
72
+ }
73
+ return base;
74
+ }, [
75
+ schema,
76
+ integer
77
+ ]);
78
+ const handleValidationChange = (property, value)=>{
79
+ const baseProperties = {
80
+ ...basePropertiesForValidation
81
+ };
82
+ if ("$dependentEnum" === property) {
83
+ if (null != value) {
84
+ baseProperties.$dependentEnum = value;
85
+ delete baseProperties.enum;
86
+ } else delete baseProperties.$dependentEnum;
87
+ onChange(baseProperties);
88
+ return;
89
+ }
90
+ if ("enum" === property) delete baseProperties.$dependentEnum;
91
+ if (void 0 !== value) {
92
+ if ("minimum" === property) baseProperties.minimum = value;
93
+ else if ("maximum" === property) baseProperties.maximum = value;
94
+ else if ("exclusiveMinimum" === property) baseProperties.exclusiveMinimum = value;
95
+ else if ("exclusiveMaximum" === property) baseProperties.exclusiveMaximum = value;
96
+ else if ("multipleOf" === property) baseProperties.multipleOf = value;
97
+ else if ("enum" === property) baseProperties.enum = value;
98
+ onChange(baseProperties);
99
+ return;
100
+ }
101
+ if ("minimum" === property) {
102
+ const { minimum: _, ...rest } = baseProperties;
103
+ onChange(rest);
104
+ return;
105
+ }
106
+ if ("maximum" === property) {
107
+ const { maximum: _, ...rest } = baseProperties;
108
+ onChange(rest);
109
+ return;
110
+ }
111
+ if ("exclusiveMinimum" === property) {
112
+ const { exclusiveMinimum: _, ...rest } = baseProperties;
113
+ onChange(rest);
114
+ return;
115
+ }
116
+ if ("exclusiveMaximum" === property) {
117
+ const { exclusiveMaximum: _, ...rest } = baseProperties;
118
+ onChange(rest);
119
+ return;
120
+ }
121
+ if ("multipleOf" === property) {
122
+ const { multipleOf: _, ...rest } = baseProperties;
123
+ onChange(rest);
124
+ return;
125
+ }
126
+ if ("enum" === property) {
127
+ const { enum: _, ...rest } = baseProperties;
128
+ onChange(rest);
129
+ return;
130
+ }
131
+ onChange(baseProperties);
132
+ };
133
+ const handleSetEnumMode = (mode, controllerName)=>{
134
+ if ("static" === mode) {
135
+ const { $dependentEnum: _, ...rest } = basePropertiesForValidation;
136
+ onChange({
137
+ ...rest,
138
+ type: integer ? "integer" : "number"
139
+ });
140
+ } else if (controllerName && eligibleControllers.some((c)=>c.name === controllerName)) {
141
+ const controller = eligibleControllers.find((c)=>c.name === controllerName);
142
+ const values = {};
143
+ for (const v of controller.values){
144
+ const key = String(v);
145
+ values[key] = (dependentValuesMap[key] ?? []).slice();
146
+ }
147
+ handleValidationChange("$dependentEnum", {
148
+ property: controllerName,
149
+ values
150
+ });
151
+ }
152
+ };
153
+ const handleDependentEnumValuesChange = (controllingValue, newList)=>{
154
+ const prop = dependentEnum?.property;
155
+ if (!prop) return;
156
+ const next = {
157
+ ...dependentValuesMap,
158
+ [controllingValue]: newList
159
+ };
160
+ if (0 === newList.length) {
161
+ const { [controllingValue]: _, ...rest } = next;
162
+ if (0 === Object.keys(rest).length) return void handleValidationChange("$dependentEnum", void 0);
163
+ handleValidationChange("$dependentEnum", {
164
+ property: prop,
165
+ values: rest
166
+ });
167
+ } else handleValidationChange("$dependentEnum", {
168
+ property: prop,
169
+ values: next
170
+ });
171
+ };
172
+ const handleAddEnumValue = ()=>{
173
+ if (!enumValue.trim()) return;
174
+ const numValue = Number(enumValue);
175
+ if (Number.isNaN(numValue)) return;
176
+ const validValue = integer ? Math.floor(numValue) : numValue;
177
+ if (!enumValues.includes(validValue)) handleValidationChange("enum", [
178
+ ...enumValues,
179
+ validValue
180
+ ]);
181
+ setEnumValue("");
182
+ };
183
+ const handleRemoveEnumValue = (index)=>{
184
+ const newEnumValues = [
185
+ ...enumValues
186
+ ];
187
+ newEnumValues.splice(index, 1);
188
+ 0 === newEnumValues.length ? handleValidationChange("enum", void 0) : handleValidationChange("enum", newEnumValues);
189
+ };
190
+ const minMaxError = useMemo(()=>validationNode?.validation.errors?.find((err)=>"minMax" === err.path[0])?.message, [
191
+ validationNode
192
+ ]);
193
+ const redundantMinError = useMemo(()=>validationNode?.validation.errors?.find((err)=>"redundantMinimum" === err.path[0])?.message, [
194
+ validationNode
195
+ ]);
196
+ const redundantMaxError = useMemo(()=>validationNode?.validation.errors?.find((err)=>"redundantMaximum" === err.path[0])?.message, [
197
+ validationNode
198
+ ]);
199
+ const enumError = useMemo(()=>validationNode?.validation.errors?.find((err)=>"enum" === err.path[0])?.message, [
200
+ validationNode
201
+ ]);
202
+ const multipleOfError = useMemo(()=>validationNode?.validation.errors?.find((err)=>"multipleOf" === err.path[0])?.message, [
203
+ validationNode
204
+ ]);
205
+ const hasConstraint = !!minimum || !!maximum || !!exclusiveMinimum || !!exclusiveMaximum || !!multipleOf || enumValues.length > 0 || null != dependentEnum && Object.keys(dependentValuesMap).length > 0;
206
+ return /*#__PURE__*/ jsxs("div", {
207
+ className: "space-y-4",
208
+ children: [
209
+ readOnly && !hasConstraint && /*#__PURE__*/ jsx("p", {
210
+ className: "text-sm text-muted-foreground italic",
211
+ children: t.numberNoConstraint
212
+ }),
213
+ (!readOnly || hasConstraint) && /*#__PURE__*/ jsxs("div", {
214
+ className: "grid grid-cols-1 md:grid-cols-2 gap-4",
215
+ children: [
216
+ /*#__PURE__*/ jsxs("div", {
217
+ className: "space-y-0 md:col-span-2",
218
+ children: [
219
+ !!minMaxError && /*#__PURE__*/ jsx("div", {
220
+ className: "text-xs text-destructive italic",
221
+ children: minMaxError
222
+ }),
223
+ !!redundantMinError && /*#__PURE__*/ jsx("div", {
224
+ className: "text-xs text-destructive italic",
225
+ children: redundantMinError
226
+ }),
227
+ !!redundantMaxError && /*#__PURE__*/ jsx("div", {
228
+ className: "text-xs text-destructive italic",
229
+ children: redundantMaxError
230
+ }),
231
+ !!enumError && /*#__PURE__*/ jsx("div", {
232
+ className: "text-xs text-destructive italic",
233
+ children: enumError
234
+ })
235
+ ]
236
+ }),
237
+ (!readOnly || !!minimum) && /*#__PURE__*/ jsxs("div", {
238
+ className: "space-y-2",
239
+ children: [
240
+ /*#__PURE__*/ jsx(Label, {
241
+ htmlFor: minimumId,
242
+ className: void 0 !== minimum && (!!minMaxError || !!redundantMinError) && "text-destructive",
243
+ children: t.numberMinimumLabel
244
+ }),
245
+ /*#__PURE__*/ jsx(Input, {
246
+ id: minimumId,
247
+ type: "number",
248
+ value: void 0 !== minimum ? minimum : "",
249
+ onChange: (e)=>{
250
+ const value = e.target.value ? Number(e.target.value) : void 0;
251
+ handleValidationChange("minimum", value);
252
+ },
253
+ placeholder: t.numberMinimumPlaceholder,
254
+ className: cn("h-8", void 0 !== minimum && (!!minMaxError || !!redundantMinError) && "border-destructive"),
255
+ step: integer ? 1 : "any"
256
+ })
257
+ ]
258
+ }),
259
+ (!readOnly || !!maximum) && /*#__PURE__*/ jsxs("div", {
260
+ className: "space-y-2",
261
+ children: [
262
+ /*#__PURE__*/ jsx(Label, {
263
+ htmlFor: maximumId,
264
+ className: void 0 !== maximum && (!!minMaxError || !!redundantMaxError) && "text-destructive",
265
+ children: t.numberMaximumLabel
266
+ }),
267
+ /*#__PURE__*/ jsx(Input, {
268
+ id: maximumId,
269
+ type: "number",
270
+ value: maximum ?? "",
271
+ onChange: (e)=>{
272
+ const value = e.target.value ? Number(e.target.value) : void 0;
273
+ handleValidationChange("maximum", value);
274
+ },
275
+ placeholder: t.numberMaximumPlaceholder,
276
+ className: cn("h-8", void 0 !== maximum && (!!minMaxError || !!redundantMaxError) && "border-destructive"),
277
+ step: integer ? 1 : "any"
278
+ })
279
+ ]
280
+ })
281
+ ]
282
+ }),
283
+ (!readOnly || !!exclusiveMaximum || !!exclusiveMinimum) && /*#__PURE__*/ jsxs("div", {
284
+ className: "grid grid-cols-1 md:grid-cols-2 gap-4",
285
+ children: [
286
+ (!readOnly || !!exclusiveMinimum) && /*#__PURE__*/ jsxs("div", {
287
+ className: "space-y-2",
288
+ children: [
289
+ /*#__PURE__*/ jsx(Label, {
290
+ htmlFor: exclusiveMinimumId,
291
+ className: void 0 !== exclusiveMinimum && (!!minMaxError || !!redundantMinError) && "text-destructive",
292
+ children: t.numberExclusiveMinimumLabel
293
+ }),
294
+ /*#__PURE__*/ jsx(Input, {
295
+ id: exclusiveMinimumId,
296
+ type: "number",
297
+ value: exclusiveMinimum ?? "",
298
+ onChange: (e)=>{
299
+ const value = e.target.value ? Number(e.target.value) : void 0;
300
+ handleValidationChange("exclusiveMinimum", value);
301
+ },
302
+ placeholder: t.numberExclusiveMinimumPlaceholder,
303
+ className: cn("h-8", void 0 !== exclusiveMinimum && (!!minMaxError || !!redundantMinError) && "border-destructive"),
304
+ step: integer ? 1 : "any"
305
+ })
306
+ ]
307
+ }),
308
+ (!readOnly || !!exclusiveMaximum) && /*#__PURE__*/ jsxs("div", {
309
+ className: "space-y-2",
310
+ children: [
311
+ /*#__PURE__*/ jsx(Label, {
312
+ htmlFor: exclusiveMaximumId,
313
+ className: void 0 !== exclusiveMaximum && (!!minMaxError || !!redundantMaxError) && "text-destructive",
314
+ children: t.numberExclusiveMaximumLabel
315
+ }),
316
+ /*#__PURE__*/ jsx(Input, {
317
+ id: exclusiveMaximumId,
318
+ type: "number",
319
+ value: exclusiveMaximum ?? "",
320
+ onChange: (e)=>{
321
+ const value = e.target.value ? Number(e.target.value) : void 0;
322
+ handleValidationChange("exclusiveMaximum", value);
323
+ },
324
+ placeholder: t.numberExclusiveMaximumPlaceholder,
325
+ className: cn("h-8", void 0 !== exclusiveMaximum && (!!minMaxError || !!redundantMaxError) && "border-destructive"),
326
+ step: integer ? 1 : "any"
327
+ })
328
+ ]
329
+ })
330
+ ]
331
+ }),
332
+ (!readOnly || !!multipleOf) && /*#__PURE__*/ jsxs("div", {
333
+ className: "space-y-2",
334
+ children: [
335
+ /*#__PURE__*/ jsx(Label, {
336
+ htmlFor: multipleOfId,
337
+ className: !!multipleOfError && "text-destructive",
338
+ children: t.numberMultipleOfLabel
339
+ }),
340
+ /*#__PURE__*/ jsx(Input, {
341
+ id: multipleOfId,
342
+ type: "number",
343
+ value: multipleOf ?? "",
344
+ onChange: (e)=>{
345
+ const value = e.target.value ? Number(e.target.value) : void 0;
346
+ handleValidationChange("multipleOf", value);
347
+ },
348
+ placeholder: t.numberMultipleOfPlaceholder,
349
+ className: cn("h-8", !!multipleOfError && "border-destructive"),
350
+ min: 0,
351
+ step: integer ? 1 : "any"
352
+ }),
353
+ !!multipleOfError && /*#__PURE__*/ jsx("div", {
354
+ className: "text-xs text-destructive italic whitespace-pre-line",
355
+ children: multipleOfError
356
+ })
357
+ ]
358
+ }),
359
+ (!readOnly || enumValues.length > 0 || null != dependentEnum) && /*#__PURE__*/ jsxs("div", {
360
+ className: "space-y-2 pt-2 border-t border-border/40",
361
+ children: [
362
+ /*#__PURE__*/ jsx(Label, {
363
+ className: !!enumError && "text-destructive",
364
+ children: t.numberAllowedValuesEnumLabel
365
+ }),
366
+ eligibleControllers.length > 0 && !readOnly && /*#__PURE__*/ jsxs("div", {
367
+ className: "flex flex-wrap items-center gap-2 mb-2",
368
+ children: [
369
+ /*#__PURE__*/ jsxs(Label, {
370
+ className: "text-xs text-muted-foreground",
371
+ children: [
372
+ t.enumModeDependsOn,
373
+ ":"
374
+ ]
375
+ }),
376
+ /*#__PURE__*/ jsxs(Select, {
377
+ value: "depends" === enumMode ? controllingProperty ?? "" : "__static__",
378
+ onValueChange: (v)=>{
379
+ "__static__" === v ? handleSetEnumMode("static") : handleSetEnumMode("depends", v);
380
+ },
381
+ children: [
382
+ /*#__PURE__*/ jsx(SelectTrigger, {
383
+ className: "h-8 w-[180px]",
384
+ children: /*#__PURE__*/ jsx(SelectValue, {
385
+ placeholder: t.enumDependsOnPlaceholder
386
+ })
387
+ }),
388
+ /*#__PURE__*/ jsxs(SelectContent, {
389
+ children: [
390
+ /*#__PURE__*/ jsx(SelectItem, {
391
+ value: "__static__",
392
+ children: t.enumModeStatic
393
+ }),
394
+ eligibleControllers.map((c)=>/*#__PURE__*/ jsx(SelectItem, {
395
+ value: c.name,
396
+ children: c.name
397
+ }, c.name))
398
+ ]
399
+ })
400
+ ]
401
+ })
402
+ ]
403
+ }),
404
+ "static" === enumMode && /*#__PURE__*/ jsxs(Fragment, {
405
+ children: [
406
+ /*#__PURE__*/ jsx("div", {
407
+ className: "flex flex-wrap gap-2 mb-4",
408
+ children: enumValues.length > 0 ? enumValues.map((value, index)=>/*#__PURE__*/ jsxs("div", {
409
+ className: "flex items-center bg-muted/40 border rounded-md px-2 py-1 text-xs",
410
+ children: [
411
+ /*#__PURE__*/ jsx("span", {
412
+ className: "mr-1",
413
+ children: value
414
+ }),
415
+ !readOnly && /*#__PURE__*/ jsx("button", {
416
+ type: "button",
417
+ onClick: ()=>handleRemoveEnumValue(index),
418
+ className: "text-muted-foreground hover:text-destructive",
419
+ children: /*#__PURE__*/ jsx(X, {
420
+ size: 12
421
+ })
422
+ })
423
+ ]
424
+ }, `enum-number-${value}`)) : /*#__PURE__*/ jsx("p", {
425
+ className: "text-xs text-muted-foreground italic",
426
+ children: t.numberAllowedValuesEnumNone
427
+ })
428
+ }),
429
+ !readOnly && /*#__PURE__*/ jsxs("div", {
430
+ className: "flex items-center gap-2",
431
+ children: [
432
+ /*#__PURE__*/ jsx(Input, {
433
+ type: "number",
434
+ value: enumValue,
435
+ onChange: (e)=>setEnumValue(e.target.value),
436
+ placeholder: t.numberAllowedValuesEnumAddPlaceholder,
437
+ className: "h-8 text-xs flex-1",
438
+ onKeyDown: (e)=>"Enter" === e.key && handleAddEnumValue(),
439
+ step: integer ? 1 : "any"
440
+ }),
441
+ /*#__PURE__*/ jsx("button", {
442
+ type: "button",
443
+ onClick: handleAddEnumValue,
444
+ className: "px-3 py-1 h-8 rounded-md bg-secondary text-xs font-medium hover:bg-secondary/80",
445
+ children: t.numberAllowedValuesEnumAddLabel
446
+ })
447
+ ]
448
+ })
449
+ ]
450
+ }),
451
+ "depends" === enumMode && controllingProperty && currentController && controllingValues.length > 0 && /*#__PURE__*/ jsxs("div", {
452
+ className: "space-y-3",
453
+ children: [
454
+ /*#__PURE__*/ jsxs("div", {
455
+ className: "flex flex-wrap items-center gap-2",
456
+ children: [
457
+ /*#__PURE__*/ jsx(Label, {
458
+ className: "text-xs text-muted-foreground",
459
+ children: t.whenPropertyEquals.replace("{property}", controllingProperty).replace("{value}", "")
460
+ }),
461
+ /*#__PURE__*/ jsxs(Select, {
462
+ value: activeKey || void 0,
463
+ onValueChange: (value)=>setSelectedControllingValue(value ?? ""),
464
+ children: [
465
+ /*#__PURE__*/ jsx(SelectTrigger, {
466
+ className: "h-8 w-[160px] text-xs",
467
+ children: /*#__PURE__*/ jsx(SelectValue, {
468
+ placeholder: t.whenPropertyEquals.replace("{property}", controllingProperty).replace("{value}", "")
469
+ })
470
+ }),
471
+ /*#__PURE__*/ jsx(SelectContent, {
472
+ children: controllingValues.map((v)=>/*#__PURE__*/ jsx(SelectItem, {
473
+ value: String(v),
474
+ children: String(v)
475
+ }, String(v)))
476
+ })
477
+ ]
478
+ })
479
+ ]
480
+ }),
481
+ activeKey && /*#__PURE__*/ jsxs("div", {
482
+ className: "space-y-1",
483
+ children: [
484
+ /*#__PURE__*/ jsx("span", {
485
+ className: "text-xs font-medium text-muted-foreground",
486
+ children: t.whenPropertyEquals.replace("{property}", controllingProperty).replace("{value}", activeKey)
487
+ }),
488
+ /*#__PURE__*/ jsxs("div", {
489
+ className: "flex flex-wrap gap-2",
490
+ children: [
491
+ (dependentValuesMap[activeKey] ?? []).map((v)=>/*#__PURE__*/ jsxs("div", {
492
+ className: "flex items-center bg-muted/40 border rounded-md px-2 py-1 text-xs",
493
+ children: [
494
+ /*#__PURE__*/ jsx("span", {
495
+ className: "mr-1",
496
+ children: v
497
+ }),
498
+ !readOnly && /*#__PURE__*/ jsx("button", {
499
+ type: "button",
500
+ onClick: ()=>{
501
+ const list = dependentValuesMap[activeKey] ?? [];
502
+ const next = list.filter((x)=>x !== v);
503
+ handleDependentEnumValuesChange(activeKey, next);
504
+ },
505
+ className: "text-muted-foreground hover:text-destructive",
506
+ children: /*#__PURE__*/ jsx(X, {
507
+ size: 12
508
+ })
509
+ })
510
+ ]
511
+ }, v)),
512
+ 0 === (dependentValuesMap[activeKey] ?? []).length && readOnly && /*#__PURE__*/ jsx("p", {
513
+ className: "text-xs text-muted-foreground italic",
514
+ children: t.numberAllowedValuesEnumNone
515
+ })
516
+ ]
517
+ }),
518
+ !readOnly && /*#__PURE__*/ jsxs("div", {
519
+ className: "flex items-center gap-2",
520
+ children: [
521
+ /*#__PURE__*/ jsx(Input, {
522
+ type: "number",
523
+ value: dependentEnumValue[activeKey] ?? "",
524
+ onChange: (e)=>setDependentEnumValue((prev)=>({
525
+ ...prev,
526
+ [activeKey]: e.target.value
527
+ })),
528
+ placeholder: t.numberAllowedValuesEnumAddPlaceholder,
529
+ className: "h-8 text-xs flex-1",
530
+ step: integer ? 1 : "any",
531
+ onKeyDown: (e)=>{
532
+ if ("Enter" === e.key) {
533
+ const list = dependentValuesMap[activeKey] ?? [];
534
+ const raw = (dependentEnumValue[activeKey] ?? "").trim();
535
+ const num = Number(raw);
536
+ if ("" !== raw && !Number.isNaN(num) && !list.includes(integer ? Math.floor(num) : num)) {
537
+ const valid = integer ? Math.floor(num) : num;
538
+ handleDependentEnumValuesChange(activeKey, [
539
+ ...list,
540
+ valid
541
+ ]);
542
+ setDependentEnumValue((prev)=>({
543
+ ...prev,
544
+ [activeKey]: ""
545
+ }));
546
+ }
547
+ }
548
+ }
549
+ }),
550
+ /*#__PURE__*/ jsx("button", {
551
+ type: "button",
552
+ onClick: ()=>{
553
+ const list = dependentValuesMap[activeKey] ?? [];
554
+ const raw = (dependentEnumValue[activeKey] ?? "").trim();
555
+ const num = Number(raw);
556
+ if ("" !== raw && !Number.isNaN(num) && !list.includes(integer ? Math.floor(num) : num)) {
557
+ const valid = integer ? Math.floor(num) : num;
558
+ handleDependentEnumValuesChange(activeKey, [
559
+ ...list,
560
+ valid
561
+ ]);
562
+ setDependentEnumValue((prev)=>({
563
+ ...prev,
564
+ [activeKey]: ""
565
+ }));
566
+ }
567
+ },
568
+ className: "px-3 py-1 h-8 rounded-md bg-secondary text-xs font-medium hover:bg-secondary/80",
569
+ children: t.numberAllowedValuesEnumAddLabel
570
+ })
571
+ ]
572
+ })
573
+ ]
574
+ })
575
+ ]
576
+ })
577
+ ]
578
+ })
579
+ ]
580
+ });
581
+ };
582
+ const types_NumberEditor = NumberEditor;
583
+ export { types_NumberEditor as default };