@alexgorbatchev/shadcn 0.0.103 → 0.0.105

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.
@@ -26,10 +26,12 @@ import {
26
26
  PaginationPrevious2,
27
27
  PaginationNext2,
28
28
  PaginationEllipsis2
29
- } from "../../chunk-n593jqmw.js";
29
+ } from "../../chunk-19bkeafb.js";
30
30
  import {
31
31
  MenuPopup,
32
32
  MenuItem2,
33
+ MenuRadioGroup2,
34
+ MenuRadioItem2,
33
35
  DropdownMenu2,
34
36
  DropdownMenuTrigger2
35
37
  } from "../../chunk-dbxmw9ya.js";
@@ -166,7 +168,7 @@ import {
166
168
  } from "../../chunk-2jsgsjas.js";
167
169
  import {
168
170
  componentDefinitions2
169
- } from "../../chunk-p8bdmafq.js";
171
+ } from "../../chunk-j7fvvgyp.js";
170
172
  import"../../chunk-5mydsjp3.js";
171
173
 
172
174
  // src/components/json-render/JsonCard.tsx
@@ -266,7 +268,109 @@ var JsonSeparator = ({ props }) => {
266
268
  // src/components/json-render/JsonTabs.tsx
267
269
  import { useState } from "react";
268
270
  import { useBoundProp } from "@json-render/react";
271
+
272
+ // src/components/json-render/JsonForm.tsx
273
+ import { createContext, use, useCallback, useId, useMemo } from "react";
269
274
  import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
275
+ var JsonFormContext = createContext(undefined);
276
+ var noErrors = {};
277
+ function JsonFormProvider({ mode = "edit", errors = noErrors, children }) {
278
+ const value = useMemo(() => ({ mode, errors }), [mode, errors]);
279
+ return /* @__PURE__ */ jsx5(JsonFormContext, {
280
+ value,
281
+ children
282
+ });
283
+ }
284
+ function useJsonForm() {
285
+ return use(JsonFormContext);
286
+ }
287
+ var JsonRevealContext = createContext(() => {});
288
+ function JsonRevealScope({ onReveal, children }) {
289
+ const parent = use(JsonRevealContext);
290
+ const reveal = useCallback(() => {
291
+ parent();
292
+ onReveal();
293
+ }, [parent, onReveal]);
294
+ return /* @__PURE__ */ jsx5(JsonRevealContext, {
295
+ value: reveal,
296
+ children
297
+ });
298
+ }
299
+ function useJsonReveal() {
300
+ return use(JsonRevealContext);
301
+ }
302
+ function stripRequiredMark(label) {
303
+ return label.replace(/\s*\*+\s*$/, "");
304
+ }
305
+ function useJsonField({ path, label, checks, ownErrors = [] }) {
306
+ const form = useJsonForm();
307
+ const messageId = useId();
308
+ const isRequired = (checks ?? []).some((check) => check.type === "required");
309
+ const error = form ? path ? form.errors[path] : undefined : ownErrors[0];
310
+ return {
311
+ label: stripRequiredMark(label ?? ""),
312
+ isRequired,
313
+ error,
314
+ mode: form?.mode ?? "edit",
315
+ messageId,
316
+ controlProps: {
317
+ "aria-required": isRequired ? true : undefined,
318
+ "aria-invalid": error ? true : undefined,
319
+ "aria-describedby": error ? messageId : undefined
320
+ }
321
+ };
322
+ }
323
+ function JsonFieldLabel({ field, id, htmlFor }) {
324
+ if (!field.label && !field.isRequired)
325
+ return null;
326
+ return /* @__PURE__ */ jsxs2("div", {
327
+ "data-slot": "json-field-label",
328
+ className: "flex flex-wrap items-center gap-2",
329
+ children: [
330
+ field.label && /* @__PURE__ */ jsx5(Label2, {
331
+ id,
332
+ htmlFor,
333
+ children: field.label
334
+ }),
335
+ field.isRequired && /* @__PURE__ */ jsx5(Badge2, {
336
+ variant: "outline",
337
+ children: "Required"
338
+ })
339
+ ]
340
+ });
341
+ }
342
+ function JsonFieldMessage({ field }) {
343
+ if (!field.error)
344
+ return null;
345
+ return /* @__PURE__ */ jsx5("p", {
346
+ id: field.messageId,
347
+ "data-slot": "json-field-message",
348
+ className: "text-sm text-destructive",
349
+ children: field.error
350
+ });
351
+ }
352
+ function JsonFieldValue({ field, text }) {
353
+ const labelId = useId();
354
+ return /* @__PURE__ */ jsxs2("div", {
355
+ role: "group",
356
+ "aria-labelledby": field.label ? labelId : undefined,
357
+ "data-slot": "json-field-value",
358
+ className: "flex w-full flex-col gap-1",
359
+ children: [
360
+ /* @__PURE__ */ jsx5(JsonFieldLabel, {
361
+ field,
362
+ id: labelId
363
+ }),
364
+ /* @__PURE__ */ jsx5("p", {
365
+ className: text ? "text-sm whitespace-pre-wrap" : "text-sm text-muted-foreground",
366
+ children: text || "No answer"
367
+ })
368
+ ]
369
+ });
370
+ }
371
+
372
+ // src/components/json-render/JsonTabs.tsx
373
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
270
374
  function toChildList(children) {
271
375
  if (Array.isArray(children))
272
376
  return children;
@@ -282,23 +386,26 @@ var JsonTabs = ({ props, children, bindings, emit }) => {
282
386
  const childList = toChildList(children);
283
387
  const hasPanels = childList.length > 0;
284
388
  const extraChildren = childList.slice(tabs.length);
285
- return /* @__PURE__ */ jsxs2(Tabs2, {
389
+ return /* @__PURE__ */ jsxs3(Tabs2, {
286
390
  value,
287
391
  onValueChange: (v) => {
288
392
  setValue(v);
289
393
  emit("change");
290
394
  },
291
395
  children: [
292
- /* @__PURE__ */ jsx5(TabsList2, {
293
- children: tabs.map((tab) => /* @__PURE__ */ jsx5(TabsTrigger2, {
396
+ /* @__PURE__ */ jsx6(TabsList2, {
397
+ children: tabs.map((tab) => /* @__PURE__ */ jsx6(TabsTrigger2, {
294
398
  value: tab.value,
295
399
  children: tab.label
296
400
  }, tab.value))
297
401
  }),
298
- hasPanels && tabs.map((tab, index) => /* @__PURE__ */ jsx5(TabsContent2, {
402
+ hasPanels && tabs.map((tab, index) => /* @__PURE__ */ jsx6(TabsContent2, {
299
403
  value: tab.value,
300
404
  keepMounted: true,
301
- children: childList[index]
405
+ children: /* @__PURE__ */ jsx6(JsonRevealScope, {
406
+ onReveal: () => setValue(tab.value),
407
+ children: childList[index]
408
+ })
302
409
  }, tab.value)),
303
410
  extraChildren
304
411
  ]
@@ -306,29 +413,29 @@ var JsonTabs = ({ props, children, bindings, emit }) => {
306
413
  };
307
414
 
308
415
  // src/components/json-render/JsonAccordion.tsx
309
- import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
416
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
310
417
  var JsonAccordion = ({ props }) => {
311
418
  const items = props.items ?? [];
312
419
  const isMultiple = props.type === "multiple";
313
- const itemElements = items.map((item, i) => /* @__PURE__ */ jsxs3(AccordionItem2, {
420
+ const itemElements = items.map((item, i) => /* @__PURE__ */ jsxs4(AccordionItem2, {
314
421
  value: `item-${i}`,
315
422
  children: [
316
- /* @__PURE__ */ jsx6(AccordionTrigger2, {
423
+ /* @__PURE__ */ jsx7(AccordionTrigger2, {
317
424
  children: item.title
318
425
  }),
319
- /* @__PURE__ */ jsx6(AccordionContent2, {
426
+ /* @__PURE__ */ jsx7(AccordionContent2, {
320
427
  children: item.content
321
428
  })
322
429
  ]
323
430
  }, i));
324
431
  if (isMultiple) {
325
- return /* @__PURE__ */ jsx6(Accordion2, {
432
+ return /* @__PURE__ */ jsx7(Accordion2, {
326
433
  multiple: true,
327
434
  className: "w-full",
328
435
  children: itemElements
329
436
  });
330
437
  }
331
- return /* @__PURE__ */ jsx6(Accordion2, {
438
+ return /* @__PURE__ */ jsx7(Accordion2, {
332
439
  multiple: false,
333
440
  className: "w-full",
334
441
  children: itemElements
@@ -336,30 +443,31 @@ var JsonAccordion = ({ props }) => {
336
443
  };
337
444
 
338
445
  // src/components/json-render/JsonCollapsible.tsx
339
- import { useState as useState2 } from "react";
340
- import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
446
+ import { useCallback as useCallback2, useState as useState2 } from "react";
447
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
341
448
  var JsonCollapsible = ({ props, children }) => {
342
449
  const [open, setOpen] = useState2(props.defaultOpen ?? false);
343
- return /* @__PURE__ */ jsxs4(Collapsible2, {
450
+ const reveal = useCallback2(() => setOpen(true), []);
451
+ return /* @__PURE__ */ jsxs5(Collapsible2, {
344
452
  open,
345
453
  onOpenChange: setOpen,
346
454
  className: "w-full",
347
455
  children: [
348
- /* @__PURE__ */ jsxs4(CollapsibleTrigger2, {
349
- render: /* @__PURE__ */ jsx7(Button2, {
456
+ /* @__PURE__ */ jsxs5(CollapsibleTrigger2, {
457
+ render: /* @__PURE__ */ jsx8(Button2, {
350
458
  variant: "outline",
351
459
  fullWidth: true,
352
460
  align: "start"
353
461
  }),
354
462
  children: [
355
463
  props.title,
356
- /* @__PURE__ */ jsx7("svg", {
464
+ /* @__PURE__ */ jsx8("svg", {
357
465
  className: `h-4 w-4 transition-transform ${open ? "rotate-180" : ""}`,
358
466
  fill: "none",
359
467
  viewBox: "0 0 24 24",
360
468
  stroke: "currentColor",
361
469
  strokeWidth: 2,
362
- children: /* @__PURE__ */ jsx7("path", {
470
+ children: /* @__PURE__ */ jsx8("path", {
363
471
  strokeLinecap: "round",
364
472
  strokeLinejoin: "round",
365
473
  d: "M19 9l-7 7-7-7"
@@ -367,9 +475,13 @@ var JsonCollapsible = ({ props, children }) => {
367
475
  })
368
476
  ]
369
477
  }),
370
- /* @__PURE__ */ jsx7(CollapsibleContent2, {
478
+ /* @__PURE__ */ jsx8(CollapsibleContent2, {
371
479
  className: "pt-2",
372
- children
480
+ keepMounted: true,
481
+ children: /* @__PURE__ */ jsx8(JsonRevealScope, {
482
+ onReveal: reveal,
483
+ children
484
+ })
373
485
  })
374
486
  ]
375
487
  });
@@ -377,20 +489,20 @@ var JsonCollapsible = ({ props, children }) => {
377
489
 
378
490
  // src/components/json-render/JsonDialog.tsx
379
491
  import { useStateBinding } from "@json-render/react";
380
- import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
492
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
381
493
  var JsonDialog = ({ props, children }) => {
382
494
  const [open, setOpen] = useStateBinding(props.openPath ?? "");
383
- return /* @__PURE__ */ jsx8(Dialog2, {
495
+ return /* @__PURE__ */ jsx9(Dialog2, {
384
496
  open: open ?? false,
385
497
  onOpenChange: (v) => setOpen(v),
386
- children: /* @__PURE__ */ jsxs5(DialogContent2, {
498
+ children: /* @__PURE__ */ jsxs6(DialogContent2, {
387
499
  children: [
388
- /* @__PURE__ */ jsxs5(DialogHeader2, {
500
+ /* @__PURE__ */ jsxs6(DialogHeader2, {
389
501
  children: [
390
- /* @__PURE__ */ jsx8(DialogTitle2, {
502
+ /* @__PURE__ */ jsx9(DialogTitle2, {
391
503
  children: props.title
392
504
  }),
393
- props.description && /* @__PURE__ */ jsx8(DialogDescription2, {
505
+ props.description && /* @__PURE__ */ jsx9(DialogDescription2, {
394
506
  children: props.description
395
507
  })
396
508
  ]
@@ -403,25 +515,25 @@ var JsonDialog = ({ props, children }) => {
403
515
 
404
516
  // src/components/json-render/JsonDrawer.tsx
405
517
  import { useStateBinding as useStateBinding2 } from "@json-render/react";
406
- import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
518
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
407
519
  var JsonDrawer = ({ props, children }) => {
408
520
  const [open, setOpen] = useStateBinding2(props.openPath ?? "");
409
- return /* @__PURE__ */ jsx9(Drawer2, {
521
+ return /* @__PURE__ */ jsx10(Drawer2, {
410
522
  open: open ?? false,
411
523
  onOpenChange: (v) => setOpen(v),
412
- children: /* @__PURE__ */ jsxs6(DrawerContent2, {
524
+ children: /* @__PURE__ */ jsxs7(DrawerContent2, {
413
525
  children: [
414
- /* @__PURE__ */ jsxs6(DrawerHeader2, {
526
+ /* @__PURE__ */ jsxs7(DrawerHeader2, {
415
527
  children: [
416
- /* @__PURE__ */ jsx9(DrawerTitle2, {
528
+ /* @__PURE__ */ jsx10(DrawerTitle2, {
417
529
  children: props.title
418
530
  }),
419
- props.description && /* @__PURE__ */ jsx9(DrawerDescription2, {
531
+ props.description && /* @__PURE__ */ jsx10(DrawerDescription2, {
420
532
  children: props.description
421
533
  })
422
534
  ]
423
535
  }),
424
- /* @__PURE__ */ jsx9("div", {
536
+ /* @__PURE__ */ jsx10("div", {
425
537
  className: "p-4",
426
538
  children
427
539
  })
@@ -431,23 +543,23 @@ var JsonDrawer = ({ props, children }) => {
431
543
  };
432
544
 
433
545
  // src/components/json-render/JsonCarousel.tsx
434
- import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
546
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
435
547
  var JsonCarousel = ({ props }) => {
436
548
  const items = props.items ?? [];
437
- return /* @__PURE__ */ jsxs7(Carousel2, {
549
+ return /* @__PURE__ */ jsxs8(Carousel2, {
438
550
  className: "w-full",
439
551
  children: [
440
- /* @__PURE__ */ jsx10(CarouselContent2, {
441
- children: items.map((item, i) => /* @__PURE__ */ jsx10(CarouselItem2, {
552
+ /* @__PURE__ */ jsx11(CarouselContent2, {
553
+ children: items.map((item, i) => /* @__PURE__ */ jsx11(CarouselItem2, {
442
554
  className: "basis-3/4 md:basis-1/2 lg:basis-1/3",
443
- children: /* @__PURE__ */ jsxs7("div", {
555
+ children: /* @__PURE__ */ jsxs8("div", {
444
556
  className: "border border-border rounded-lg p-4 bg-card h-full",
445
557
  children: [
446
- item.title && /* @__PURE__ */ jsx10("h4", {
558
+ item.title && /* @__PURE__ */ jsx11("h4", {
447
559
  className: "font-semibold text-sm mb-1",
448
560
  children: item.title
449
561
  }),
450
- item.description && /* @__PURE__ */ jsx10("p", {
562
+ item.description && /* @__PURE__ */ jsx11("p", {
451
563
  className: "text-sm text-muted-foreground",
452
564
  children: item.description
453
565
  })
@@ -455,34 +567,34 @@ var JsonCarousel = ({ props }) => {
455
567
  })
456
568
  }, i))
457
569
  }),
458
- /* @__PURE__ */ jsx10(CarouselPrevious2, {}),
459
- /* @__PURE__ */ jsx10(CarouselNext2, {})
570
+ /* @__PURE__ */ jsx11(CarouselPrevious2, {}),
571
+ /* @__PURE__ */ jsx11(CarouselNext2, {})
460
572
  ]
461
573
  });
462
574
  };
463
575
 
464
576
  // src/components/json-render/JsonTable.tsx
465
- import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
577
+ import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
466
578
  var JsonTable = ({ props }) => {
467
579
  const columns = props.columns ?? [];
468
580
  const rows = (props.rows ?? []).map((row) => row.map(String));
469
- return /* @__PURE__ */ jsx11("div", {
581
+ return /* @__PURE__ */ jsx12("div", {
470
582
  className: "w-full min-w-0 rounded-md border border-border overflow-hidden",
471
- children: /* @__PURE__ */ jsxs8(Table2, {
583
+ children: /* @__PURE__ */ jsxs9(Table2, {
472
584
  children: [
473
- props.caption && /* @__PURE__ */ jsx11(TableCaption2, {
585
+ props.caption && /* @__PURE__ */ jsx12(TableCaption2, {
474
586
  children: props.caption
475
587
  }),
476
- /* @__PURE__ */ jsx11(TableHeader2, {
477
- children: /* @__PURE__ */ jsx11(TableRow2, {
478
- children: columns.map((col) => /* @__PURE__ */ jsx11(TableHead2, {
588
+ /* @__PURE__ */ jsx12(TableHeader2, {
589
+ children: /* @__PURE__ */ jsx12(TableRow2, {
590
+ children: columns.map((col) => /* @__PURE__ */ jsx12(TableHead2, {
479
591
  children: col
480
592
  }, col))
481
593
  })
482
594
  }),
483
- /* @__PURE__ */ jsx11(TableBody2, {
484
- children: rows.map((row, i) => /* @__PURE__ */ jsx11(TableRow2, {
485
- children: row.map((cell, j) => /* @__PURE__ */ jsx11(TableCell2, {
595
+ /* @__PURE__ */ jsx12(TableBody2, {
596
+ children: rows.map((row, i) => /* @__PURE__ */ jsx12(TableRow2, {
597
+ children: row.map((cell, j) => /* @__PURE__ */ jsx12(TableCell2, {
486
598
  children: cell
487
599
  }, j))
488
600
  }, i))
@@ -493,59 +605,59 @@ var JsonTable = ({ props }) => {
493
605
  };
494
606
 
495
607
  // src/components/json-render/JsonHeading.tsx
496
- import { jsx as jsx12 } from "react/jsx-runtime";
608
+ import { jsx as jsx13 } from "react/jsx-runtime";
497
609
  var JsonHeading = ({ props }) => {
498
610
  const level = props.level ?? "h2";
499
611
  const headingClass = level === "h1" ? "text-2xl font-bold" : level === "h3" ? "text-base font-semibold" : level === "h4" ? "text-sm font-semibold" : "text-lg font-semibold";
500
612
  if (level === "h1")
501
- return /* @__PURE__ */ jsx12("h1", {
613
+ return /* @__PURE__ */ jsx13("h1", {
502
614
  className: `${headingClass} text-left`,
503
615
  children: props.text
504
616
  });
505
617
  if (level === "h3")
506
- return /* @__PURE__ */ jsx12("h3", {
618
+ return /* @__PURE__ */ jsx13("h3", {
507
619
  className: `${headingClass} text-left`,
508
620
  children: props.text
509
621
  });
510
622
  if (level === "h4")
511
- return /* @__PURE__ */ jsx12("h4", {
623
+ return /* @__PURE__ */ jsx13("h4", {
512
624
  className: `${headingClass} text-left`,
513
625
  children: props.text
514
626
  });
515
- return /* @__PURE__ */ jsx12("h2", {
627
+ return /* @__PURE__ */ jsx13("h2", {
516
628
  className: `${headingClass} text-left`,
517
629
  children: props.text
518
630
  });
519
631
  };
520
632
 
521
633
  // src/components/json-render/JsonText.tsx
522
- import { jsx as jsx13 } from "react/jsx-runtime";
634
+ import { jsx as jsx14 } from "react/jsx-runtime";
523
635
  var JsonText = ({ props }) => {
524
636
  const textClass = props.variant === "caption" ? "text-xs" : props.variant === "muted" ? "text-sm text-muted-foreground" : props.variant === "lead" ? "text-xl text-muted-foreground" : props.variant === "code" ? "font-mono text-sm bg-muted px-1.5 py-0.5 rounded" : "text-sm";
525
637
  if (props.variant === "code") {
526
- return /* @__PURE__ */ jsx13("code", {
638
+ return /* @__PURE__ */ jsx14("code", {
527
639
  className: `${textClass} text-left`,
528
640
  children: props.text
529
641
  });
530
642
  }
531
- return /* @__PURE__ */ jsx13("p", {
643
+ return /* @__PURE__ */ jsx14("p", {
532
644
  className: `${textClass} text-left`,
533
645
  children: props.text
534
646
  });
535
647
  };
536
648
 
537
649
  // src/components/json-render/JsonImage.tsx
538
- import { jsx as jsx14 } from "react/jsx-runtime";
650
+ import { jsx as jsx15 } from "react/jsx-runtime";
539
651
  var JsonImage = ({ props }) => {
540
652
  if (props.src) {
541
- return /* @__PURE__ */ jsx14(FramedImage2, {
653
+ return /* @__PURE__ */ jsx15(FramedImage2, {
542
654
  src: props.src,
543
655
  alt: props.alt ?? "",
544
656
  width: props.width ?? undefined,
545
657
  height: props.height ?? undefined
546
658
  });
547
659
  }
548
- return /* @__PURE__ */ jsx14("div", {
660
+ return /* @__PURE__ */ jsx15("div", {
549
661
  className: "bg-muted border border-border rounded flex items-center justify-center text-xs text-muted-foreground",
550
662
  style: { width: props.width ?? 80, height: props.height ?? 60 },
551
663
  children: props.alt || "img"
@@ -553,19 +665,19 @@ var JsonImage = ({ props }) => {
553
665
  };
554
666
 
555
667
  // src/components/json-render/JsonAvatar.tsx
556
- import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
668
+ import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
557
669
  var JsonAvatar = ({ props }) => {
558
670
  const name = props.name || "?";
559
671
  const initials = name.split(" ").map((n) => n[0]).join("").slice(0, 2).toUpperCase();
560
672
  const sizeClass = props.size === "lg" ? "h-12 w-12" : props.size === "sm" ? "h-8 w-8" : "h-10 w-10";
561
- return /* @__PURE__ */ jsxs9(Avatar2, {
673
+ return /* @__PURE__ */ jsxs10(Avatar2, {
562
674
  className: sizeClass,
563
675
  children: [
564
- props.src && /* @__PURE__ */ jsx15(AvatarImage2, {
676
+ props.src && /* @__PURE__ */ jsx16(AvatarImage2, {
565
677
  src: props.src,
566
678
  alt: name
567
679
  }),
568
- /* @__PURE__ */ jsx15(AvatarFallback2, {
680
+ /* @__PURE__ */ jsx16(AvatarFallback2, {
569
681
  children: initials
570
682
  })
571
683
  ]
@@ -573,24 +685,24 @@ var JsonAvatar = ({ props }) => {
573
685
  };
574
686
 
575
687
  // src/components/json-render/JsonBadge.tsx
576
- import { jsx as jsx16 } from "react/jsx-runtime";
688
+ import { jsx as jsx17 } from "react/jsx-runtime";
577
689
  var JsonBadge = ({ props }) => {
578
- return /* @__PURE__ */ jsx16(Badge2, {
690
+ return /* @__PURE__ */ jsx17(Badge2, {
579
691
  variant: props.variant ?? "default",
580
692
  children: props.text
581
693
  });
582
694
  };
583
695
 
584
696
  // src/components/json-render/JsonAlert.tsx
585
- import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
697
+ import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
586
698
  var JsonAlert = ({ props }) => {
587
- return /* @__PURE__ */ jsxs10(Alert2, {
699
+ return /* @__PURE__ */ jsxs11(Alert2, {
588
700
  variant: props.type === "error" ? "destructive" : props.type ?? "default",
589
701
  children: [
590
- /* @__PURE__ */ jsx17(AlertTitle2, {
702
+ /* @__PURE__ */ jsx18(AlertTitle2, {
591
703
  children: props.title
592
704
  }),
593
- props.message && /* @__PURE__ */ jsx17(AlertDescription2, {
705
+ props.message && /* @__PURE__ */ jsx18(AlertDescription2, {
594
706
  children: props.message
595
707
  })
596
708
  ]
@@ -598,17 +710,17 @@ var JsonAlert = ({ props }) => {
598
710
  };
599
711
 
600
712
  // src/components/json-render/JsonProgress.tsx
601
- import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
713
+ import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
602
714
  var JsonProgress = ({ props }) => {
603
715
  const value = Math.min(100, Math.max(0, props.value || 0));
604
- return /* @__PURE__ */ jsxs11("div", {
716
+ return /* @__PURE__ */ jsxs12("div", {
605
717
  className: "space-y-2",
606
718
  children: [
607
- props.label && /* @__PURE__ */ jsx18(Label2, {
719
+ props.label && /* @__PURE__ */ jsx19(Label2, {
608
720
  className: "text-sm text-muted-foreground",
609
721
  children: props.label
610
722
  }),
611
- /* @__PURE__ */ jsx18(Progress2, {
723
+ /* @__PURE__ */ jsx19(Progress2, {
612
724
  value
613
725
  })
614
726
  ]
@@ -616,9 +728,9 @@ var JsonProgress = ({ props }) => {
616
728
  };
617
729
 
618
730
  // src/components/json-render/JsonSkeleton.tsx
619
- import { jsx as jsx19 } from "react/jsx-runtime";
731
+ import { jsx as jsx20 } from "react/jsx-runtime";
620
732
  var JsonSkeleton = ({ props }) => {
621
- return /* @__PURE__ */ jsx19(Skeleton2, {
733
+ return /* @__PURE__ */ jsx20(Skeleton2, {
622
734
  className: props.rounded ? "rounded-full" : "rounded-md",
623
735
  style: {
624
736
  width: props.width ?? "100%",
@@ -628,28 +740,28 @@ var JsonSkeleton = ({ props }) => {
628
740
  };
629
741
 
630
742
  // src/components/json-render/JsonSpinner.tsx
631
- import { jsx as jsx20 } from "react/jsx-runtime";
743
+ import { jsx as jsx21 } from "react/jsx-runtime";
632
744
  var JsonSpinner = ({ props }) => {
633
- return /* @__PURE__ */ jsx20(Spinner2, {
745
+ return /* @__PURE__ */ jsx21(Spinner2, {
634
746
  "aria-label": props.label ?? "Loading",
635
747
  className: props.size === "lg" ? "size-8" : props.size === "sm" ? "size-4" : "size-6"
636
748
  });
637
749
  };
638
750
 
639
751
  // src/components/json-render/JsonTooltip.tsx
640
- import { jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
752
+ import { jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
641
753
  var JsonTooltip = ({ props }) => {
642
- return /* @__PURE__ */ jsx21(TooltipProvider2, {
643
- children: /* @__PURE__ */ jsxs12(Tooltip2, {
754
+ return /* @__PURE__ */ jsx22(TooltipProvider2, {
755
+ children: /* @__PURE__ */ jsxs13(Tooltip2, {
644
756
  children: [
645
- /* @__PURE__ */ jsx21(TooltipTrigger2, {
646
- render: /* @__PURE__ */ jsx21(Button2, {
757
+ /* @__PURE__ */ jsx22(TooltipTrigger2, {
758
+ render: /* @__PURE__ */ jsx22(Button2, {
647
759
  variant: "link"
648
760
  }),
649
761
  children: props.text
650
762
  }),
651
- /* @__PURE__ */ jsx21(TooltipContent2, {
652
- children: /* @__PURE__ */ jsx21("p", {
763
+ /* @__PURE__ */ jsx22(TooltipContent2, {
764
+ children: /* @__PURE__ */ jsx22("p", {
653
765
  children: props.content
654
766
  })
655
767
  })
@@ -659,19 +771,19 @@ var JsonTooltip = ({ props }) => {
659
771
  };
660
772
 
661
773
  // src/components/json-render/JsonPopover.tsx
662
- import { jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
774
+ import { jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
663
775
  var JsonPopover = ({ props }) => {
664
- return /* @__PURE__ */ jsxs13(Popover2, {
776
+ return /* @__PURE__ */ jsxs14(Popover2, {
665
777
  children: [
666
- /* @__PURE__ */ jsx22(PopoverTrigger2, {
667
- render: /* @__PURE__ */ jsx22(Button2, {
778
+ /* @__PURE__ */ jsx23(PopoverTrigger2, {
779
+ render: /* @__PURE__ */ jsx23(Button2, {
668
780
  variant: "outline"
669
781
  }),
670
782
  children: props.trigger
671
783
  }),
672
- /* @__PURE__ */ jsx22(PopoverContent2, {
784
+ /* @__PURE__ */ jsx23(PopoverContent2, {
673
785
  className: "w-64",
674
- children: /* @__PURE__ */ jsx22("p", {
786
+ children: /* @__PURE__ */ jsx23("p", {
675
787
  className: "text-sm",
676
788
  children: props.content
677
789
  })
@@ -681,33 +793,42 @@ var JsonPopover = ({ props }) => {
681
793
  };
682
794
 
683
795
  // src/components/json-render/JsonInput.tsx
684
- import { useId, useState as useState3 } from "react";
796
+ import { useId as useId2, useState as useState3 } from "react";
685
797
  import { useBoundProp as useBoundProp2 } from "@json-render/react";
686
798
  import { useFieldValidation } from "@json-render/react";
687
- import { jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
799
+ import { jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
688
800
  var JsonInput = ({ props, bindings, emit }) => {
689
- const id = useId();
801
+ const id = useId2();
802
+ const form = useJsonForm();
690
803
  const [boundValue, setBoundValue] = useBoundProp2(props.value ?? undefined, bindings?.value);
691
804
  const [localValue, setLocalValue] = useState3(props.value ?? "");
692
805
  const isBound = !!bindings?.value;
693
806
  const value = isBound ? boundValue ?? "" : localValue;
694
807
  const setValue = isBound ? setBoundValue : setLocalValue;
695
808
  const validateOn = props.validateOn ?? "blur";
696
- const hasValidation = !!(bindings?.value && props.checks?.length);
809
+ const hasValidation = !!(bindings?.value && props.checks?.length) && !form;
697
810
  const { errors, validate } = useFieldValidation(bindings?.value ?? "", hasValidation ? { checks: props.checks ?? [], validateOn } : undefined);
698
- return /* @__PURE__ */ jsxs14("div", {
811
+ const field = useJsonField({ path: bindings?.value, label: props.label, checks: props.checks, ownErrors: errors });
812
+ if (field.mode === "values")
813
+ return /* @__PURE__ */ jsx24(JsonFieldValue, {
814
+ field,
815
+ text: value
816
+ });
817
+ return /* @__PURE__ */ jsxs15("div", {
699
818
  className: "w-full space-y-2",
700
819
  children: [
701
- props.label && /* @__PURE__ */ jsx23(Label2, {
702
- htmlFor: id,
703
- children: props.label
820
+ /* @__PURE__ */ jsx24(JsonFieldLabel, {
821
+ field,
822
+ htmlFor: id
704
823
  }),
705
- /* @__PURE__ */ jsx23(Input2, {
824
+ /* @__PURE__ */ jsx24(Input2, {
706
825
  id,
707
826
  name: props.name ?? undefined,
708
827
  type: props.type ?? "text",
709
828
  placeholder: props.placeholder ?? "",
710
829
  value,
830
+ disabled: field.mode === "locked",
831
+ ...field.controlProps,
711
832
  onChange: (e) => {
712
833
  setValue(e.target.value);
713
834
  if (hasValidation && validateOn === "change")
@@ -724,42 +845,50 @@ var JsonInput = ({ props, bindings, emit }) => {
724
845
  emit("blur");
725
846
  }
726
847
  }),
727
- errors.length > 0 && /* @__PURE__ */ jsx23("p", {
728
- className: "text-sm text-destructive",
729
- children: errors[0]
848
+ /* @__PURE__ */ jsx24(JsonFieldMessage, {
849
+ field
730
850
  })
731
851
  ]
732
852
  });
733
853
  };
734
854
 
735
855
  // src/components/json-render/JsonTextarea.tsx
736
- import { useId as useId2, useState as useState4 } from "react";
856
+ import { useId as useId3, useState as useState4 } from "react";
737
857
  import { useBoundProp as useBoundProp3 } from "@json-render/react";
738
858
  import { useFieldValidation as useFieldValidation2 } from "@json-render/react";
739
- import { jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
859
+ import { jsx as jsx25, jsxs as jsxs16 } from "react/jsx-runtime";
740
860
  var JsonTextarea = ({ props, bindings }) => {
741
- const id = useId2();
861
+ const id = useId3();
862
+ const form = useJsonForm();
742
863
  const [boundValue, setBoundValue] = useBoundProp3(props.value ?? undefined, bindings?.value);
743
864
  const [localValue, setLocalValue] = useState4(props.value ?? "");
744
865
  const isBound = !!bindings?.value;
745
866
  const value = isBound ? boundValue ?? "" : localValue;
746
867
  const setValue = isBound ? setBoundValue : setLocalValue;
747
868
  const validateOn = props.validateOn ?? "blur";
748
- const hasValidation = !!(bindings?.value && props.checks?.length);
869
+ const hasValidation = !!(bindings?.value && props.checks?.length) && !form;
749
870
  const { errors, validate } = useFieldValidation2(bindings?.value ?? "", hasValidation ? { checks: props.checks ?? [], validateOn } : undefined);
750
- return /* @__PURE__ */ jsxs15("div", {
871
+ const field = useJsonField({ path: bindings?.value, label: props.label, checks: props.checks, ownErrors: errors });
872
+ if (field.mode === "values")
873
+ return /* @__PURE__ */ jsx25(JsonFieldValue, {
874
+ field,
875
+ text: value
876
+ });
877
+ return /* @__PURE__ */ jsxs16("div", {
751
878
  className: "w-full space-y-2",
752
879
  children: [
753
- props.label && /* @__PURE__ */ jsx24(Label2, {
754
- htmlFor: id,
755
- children: props.label
880
+ /* @__PURE__ */ jsx25(JsonFieldLabel, {
881
+ field,
882
+ htmlFor: id
756
883
  }),
757
- /* @__PURE__ */ jsx24(Textarea2, {
884
+ /* @__PURE__ */ jsx25(Textarea2, {
758
885
  id,
759
886
  name: props.name ?? undefined,
760
887
  placeholder: props.placeholder ?? "",
761
888
  rows: props.rows ?? 3,
762
889
  value,
890
+ disabled: field.mode === "locked",
891
+ ...field.controlProps,
763
892
  onChange: (e) => {
764
893
  setValue(e.target.value);
765
894
  if (hasValidation && validateOn === "change")
@@ -770,21 +899,21 @@ var JsonTextarea = ({ props, bindings }) => {
770
899
  validate();
771
900
  }
772
901
  }),
773
- errors.length > 0 && /* @__PURE__ */ jsx24("p", {
774
- className: "text-sm text-destructive",
775
- children: errors[0]
902
+ /* @__PURE__ */ jsx25(JsonFieldMessage, {
903
+ field
776
904
  })
777
905
  ]
778
906
  });
779
907
  };
780
908
 
781
909
  // src/components/json-render/JsonSelect.tsx
782
- import { useId as useId3, useState as useState5 } from "react";
910
+ import { useId as useId4, useState as useState5 } from "react";
783
911
  import { useBoundProp as useBoundProp4 } from "@json-render/react";
784
912
  import { useFieldValidation as useFieldValidation3 } from "@json-render/react";
785
- import { jsx as jsx25, jsxs as jsxs16 } from "react/jsx-runtime";
913
+ import { jsx as jsx26, jsxs as jsxs17 } from "react/jsx-runtime";
786
914
  var JsonSelect = ({ props, bindings, emit }) => {
787
- const id = useId3();
915
+ const id = useId4();
916
+ const form = useJsonForm();
788
917
  const [boundValue, setBoundValue] = useBoundProp4(props.value ?? undefined, bindings?.value);
789
918
  const [localValue, setLocalValue] = useState5(props.value ?? "");
790
919
  const isBound = !!bindings?.value;
@@ -793,17 +922,24 @@ var JsonSelect = ({ props, bindings, emit }) => {
793
922
  const rawOptions = props.options ?? [];
794
923
  const options = rawOptions.map((opt) => typeof opt === "string" ? opt : String(opt ?? ""));
795
924
  const validateOn = props.validateOn ?? "change";
796
- const hasValidation = !!(bindings?.value && props.checks?.length);
925
+ const hasValidation = !!(bindings?.value && props.checks?.length) && !form;
797
926
  const { errors, validate } = useFieldValidation3(bindings?.value ?? "", hasValidation ? { checks: props.checks ?? [], validateOn } : undefined);
798
- return /* @__PURE__ */ jsxs16("div", {
927
+ const field = useJsonField({ path: bindings?.value, label: props.label, checks: props.checks, ownErrors: errors });
928
+ if (field.mode === "values")
929
+ return /* @__PURE__ */ jsx26(JsonFieldValue, {
930
+ field,
931
+ text: value
932
+ });
933
+ return /* @__PURE__ */ jsxs17("div", {
799
934
  className: "space-y-2",
800
935
  children: [
801
- /* @__PURE__ */ jsx25(Label2, {
802
- htmlFor: id,
803
- children: props.label
936
+ /* @__PURE__ */ jsx26(JsonFieldLabel, {
937
+ field,
938
+ htmlFor: id
804
939
  }),
805
- /* @__PURE__ */ jsxs16(Select2, {
940
+ /* @__PURE__ */ jsxs17(Select2, {
806
941
  value,
942
+ disabled: field.mode === "locked",
807
943
  onValueChange: (v) => {
808
944
  setValue(v ?? "");
809
945
  if (hasValidation && validateOn === "change")
@@ -811,53 +947,62 @@ var JsonSelect = ({ props, bindings, emit }) => {
811
947
  emit("change");
812
948
  },
813
949
  children: [
814
- /* @__PURE__ */ jsx25(SelectTrigger2, {
950
+ /* @__PURE__ */ jsx26(SelectTrigger2, {
815
951
  id,
816
952
  className: "w-full",
817
- children: /* @__PURE__ */ jsx25(SelectValue2, {
953
+ ...field.controlProps,
954
+ children: /* @__PURE__ */ jsx26(SelectValue2, {
818
955
  placeholder: props.placeholder ?? "Select..."
819
956
  })
820
957
  }),
821
- /* @__PURE__ */ jsx25(SelectContent2, {
822
- children: options.map((opt, idx) => /* @__PURE__ */ jsx25(SelectItem2, {
958
+ /* @__PURE__ */ jsx26(SelectContent2, {
959
+ children: options.map((opt, idx) => /* @__PURE__ */ jsx26(SelectItem2, {
823
960
  value: opt || `option-${idx}`,
824
961
  children: opt
825
962
  }, `${idx}-${opt}`))
826
963
  })
827
964
  ]
828
965
  }),
829
- errors.length > 0 && /* @__PURE__ */ jsx25("p", {
830
- className: "text-sm text-destructive",
831
- children: errors[0]
966
+ /* @__PURE__ */ jsx26(JsonFieldMessage, {
967
+ field
832
968
  })
833
969
  ]
834
970
  });
835
971
  };
836
972
 
837
973
  // src/components/json-render/JsonCheckbox.tsx
838
- import { useId as useId4, useState as useState6 } from "react";
974
+ import { useId as useId5, useState as useState6 } from "react";
839
975
  import { useBoundProp as useBoundProp5 } from "@json-render/react";
840
976
  import { useFieldValidation as useFieldValidation4 } from "@json-render/react";
841
- import { jsx as jsx26, jsxs as jsxs17 } from "react/jsx-runtime";
977
+ import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
842
978
  var JsonCheckbox = ({ props, bindings, emit }) => {
843
- const id = useId4();
979
+ const id = useId5();
980
+ const form = useJsonForm();
844
981
  const [boundChecked, setBoundChecked] = useBoundProp5(props.checked ?? undefined, bindings?.checked);
845
982
  const [localChecked, setLocalChecked] = useState6(!!props.checked);
846
983
  const isBound = !!bindings?.checked;
847
984
  const checked = isBound ? boundChecked ?? false : localChecked;
848
985
  const setChecked = isBound ? setBoundChecked : setLocalChecked;
849
986
  const validateOn = props.validateOn ?? "change";
850
- const hasValidation = !!(bindings?.checked && props.checks?.length);
987
+ const hasValidation = !!(bindings?.checked && props.checks?.length) && !form;
851
988
  const { errors, validate } = useFieldValidation4(bindings?.checked ?? "", hasValidation ? { checks: props.checks ?? [], validateOn } : undefined);
852
- return /* @__PURE__ */ jsxs17("div", {
989
+ const field = useJsonField({ path: bindings?.checked, label: props.label, checks: props.checks, ownErrors: errors });
990
+ if (field.mode === "values")
991
+ return /* @__PURE__ */ jsx27(JsonFieldValue, {
992
+ field,
993
+ text: checked ? "Yes" : "No"
994
+ });
995
+ return /* @__PURE__ */ jsxs18("div", {
853
996
  className: "space-y-1",
854
997
  children: [
855
- /* @__PURE__ */ jsxs17(Field2, {
998
+ /* @__PURE__ */ jsxs18(Field2, {
856
999
  orientation: "horizontal",
857
1000
  children: [
858
- /* @__PURE__ */ jsx26(Checkbox2, {
1001
+ /* @__PURE__ */ jsx27(Checkbox2, {
859
1002
  id,
860
1003
  checked,
1004
+ disabled: field.mode === "locked",
1005
+ ...field.controlProps,
861
1006
  onCheckedChange: (c) => {
862
1007
  setChecked(c === true);
863
1008
  if (hasValidation && validateOn === "change")
@@ -865,27 +1010,31 @@ var JsonCheckbox = ({ props, bindings, emit }) => {
865
1010
  emit("change");
866
1011
  }
867
1012
  }),
868
- /* @__PURE__ */ jsx26(FieldLabel2, {
1013
+ /* @__PURE__ */ jsx27(FieldLabel2, {
869
1014
  htmlFor: id,
870
- children: props.label
1015
+ children: field.label
1016
+ }),
1017
+ field.isRequired && /* @__PURE__ */ jsx27(Badge2, {
1018
+ variant: "outline",
1019
+ children: "Required"
871
1020
  })
872
1021
  ]
873
1022
  }),
874
- errors.length > 0 && /* @__PURE__ */ jsx26("p", {
875
- className: "text-sm text-destructive",
876
- children: errors[0]
1023
+ /* @__PURE__ */ jsx27(JsonFieldMessage, {
1024
+ field
877
1025
  })
878
1026
  ]
879
1027
  });
880
1028
  };
881
1029
 
882
1030
  // src/components/json-render/JsonRadio.tsx
883
- import { useId as useId5, useState as useState7 } from "react";
1031
+ import { useId as useId6, useState as useState7 } from "react";
884
1032
  import { useBoundProp as useBoundProp6 } from "@json-render/react";
885
1033
  import { useFieldValidation as useFieldValidation5 } from "@json-render/react";
886
- import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
1034
+ import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
887
1035
  var JsonRadio = ({ props, bindings, emit }) => {
888
- const id = useId5();
1036
+ const id = useId6();
1037
+ const form = useJsonForm();
889
1038
  const rawOptions = props.options ?? [];
890
1039
  const options = rawOptions.map((opt) => typeof opt === "string" ? opt : String(opt ?? ""));
891
1040
  const [boundValue, setBoundValue] = useBoundProp6(props.value ?? undefined, bindings?.value);
@@ -894,74 +1043,95 @@ var JsonRadio = ({ props, bindings, emit }) => {
894
1043
  const value = isBound ? boundValue ?? "" : localValue;
895
1044
  const setValue = isBound ? setBoundValue : setLocalValue;
896
1045
  const validateOn = props.validateOn ?? "change";
897
- const hasValidation = !!(bindings?.value && props.checks?.length);
1046
+ const hasValidation = !!(bindings?.value && props.checks?.length) && !form;
898
1047
  const { errors, validate } = useFieldValidation5(bindings?.value ?? "", hasValidation ? { checks: props.checks ?? [], validateOn } : undefined);
899
- return /* @__PURE__ */ jsxs18("div", {
1048
+ const field = useJsonField({ path: bindings?.value, label: props.label, checks: props.checks, ownErrors: errors });
1049
+ if (field.mode === "values")
1050
+ return /* @__PURE__ */ jsx28(JsonFieldValue, {
1051
+ field,
1052
+ text: value
1053
+ });
1054
+ return /* @__PURE__ */ jsxs19("div", {
900
1055
  className: "space-y-2",
901
1056
  children: [
902
- props.label && /* @__PURE__ */ jsx27(Label2, {
903
- id,
904
- children: props.label
1057
+ /* @__PURE__ */ jsx28(JsonFieldLabel, {
1058
+ field,
1059
+ id
905
1060
  }),
906
- /* @__PURE__ */ jsx27(RadioGroup2, {
907
- "aria-labelledby": props.label ? id : undefined,
1061
+ /* @__PURE__ */ jsx28(RadioGroup2, {
1062
+ "aria-labelledby": field.label ? id : undefined,
1063
+ tabIndex: -1,
908
1064
  value,
1065
+ disabled: field.mode === "locked",
1066
+ ...field.controlProps,
909
1067
  onValueChange: (v) => {
910
1068
  setValue(v);
911
1069
  if (hasValidation && validateOn === "change")
912
1070
  validate();
913
1071
  emit("change");
914
1072
  },
915
- children: options.map((opt, idx) => /* @__PURE__ */ jsxs18(Field2, {
1073
+ children: options.map((opt, idx) => /* @__PURE__ */ jsxs19(Field2, {
916
1074
  orientation: "horizontal",
917
1075
  children: [
918
- /* @__PURE__ */ jsx27(RadioGroupItem2, {
1076
+ /* @__PURE__ */ jsx28(RadioGroupItem2, {
919
1077
  value: opt || `option-${idx}`,
920
1078
  id: `${id}-${idx}`
921
1079
  }),
922
- /* @__PURE__ */ jsx27(FieldLabel2, {
1080
+ /* @__PURE__ */ jsx28(FieldLabel2, {
923
1081
  htmlFor: `${id}-${idx}`,
924
1082
  children: opt
925
1083
  })
926
1084
  ]
927
1085
  }, `${idx}-${opt}`))
928
1086
  }),
929
- errors.length > 0 && /* @__PURE__ */ jsx27("p", {
930
- className: "text-sm text-destructive",
931
- children: errors[0]
1087
+ /* @__PURE__ */ jsx28(JsonFieldMessage, {
1088
+ field
932
1089
  })
933
1090
  ]
934
1091
  });
935
1092
  };
936
1093
 
937
1094
  // src/components/json-render/JsonSwitch.tsx
938
- import { useId as useId6, useState as useState8 } from "react";
1095
+ import { useId as useId7, useState as useState8 } from "react";
939
1096
  import { useBoundProp as useBoundProp7 } from "@json-render/react";
940
1097
  import { useFieldValidation as useFieldValidation6 } from "@json-render/react";
941
- import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
1098
+ import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
942
1099
  var JsonSwitch = ({ props, bindings, emit }) => {
943
- const id = useId6();
1100
+ const id = useId7();
1101
+ const form = useJsonForm();
944
1102
  const [boundChecked, setBoundChecked] = useBoundProp7(props.checked ?? undefined, bindings?.checked);
945
1103
  const [localChecked, setLocalChecked] = useState8(!!props.checked);
946
1104
  const isBound = !!bindings?.checked;
947
1105
  const checked = isBound ? boundChecked ?? false : localChecked;
948
1106
  const setChecked = isBound ? setBoundChecked : setLocalChecked;
949
1107
  const validateOn = props.validateOn ?? "change";
950
- const hasValidation = !!(bindings?.checked && props.checks?.length);
1108
+ const hasValidation = !!(bindings?.checked && props.checks?.length) && !form;
951
1109
  const { errors, validate } = useFieldValidation6(bindings?.checked ?? "", hasValidation ? { checks: props.checks ?? [], validateOn } : undefined);
952
- return /* @__PURE__ */ jsxs19("div", {
1110
+ const field = useJsonField({ path: bindings?.checked, label: props.label, checks: props.checks, ownErrors: errors });
1111
+ if (field.mode === "values")
1112
+ return /* @__PURE__ */ jsx29(JsonFieldValue, {
1113
+ field,
1114
+ text: checked ? "On" : "Off"
1115
+ });
1116
+ return /* @__PURE__ */ jsxs20("div", {
953
1117
  className: "space-y-1",
954
1118
  children: [
955
- /* @__PURE__ */ jsxs19(Field2, {
1119
+ /* @__PURE__ */ jsxs20(Field2, {
956
1120
  orientation: "horizontal",
957
1121
  children: [
958
- /* @__PURE__ */ jsx28(FieldLabel2, {
1122
+ /* @__PURE__ */ jsx29(FieldLabel2, {
959
1123
  htmlFor: id,
960
- children: props.label
1124
+ children: field.label
961
1125
  }),
962
- /* @__PURE__ */ jsx28(Switch2, {
1126
+ field.isRequired && /* @__PURE__ */ jsx29(Badge2, {
1127
+ variant: "outline",
1128
+ children: "Required"
1129
+ }),
1130
+ /* @__PURE__ */ jsx29(Switch2, {
963
1131
  id,
964
1132
  checked,
1133
+ disabled: field.mode === "locked",
1134
+ ...field.controlProps,
965
1135
  onCheckedChange: (c) => {
966
1136
  setChecked(c);
967
1137
  if (hasValidation && validateOn === "change")
@@ -971,48 +1141,54 @@ var JsonSwitch = ({ props, bindings, emit }) => {
971
1141
  })
972
1142
  ]
973
1143
  }),
974
- errors.length > 0 && /* @__PURE__ */ jsx28("p", {
975
- className: "text-sm text-destructive",
976
- children: errors[0]
1144
+ /* @__PURE__ */ jsx29(JsonFieldMessage, {
1145
+ field
977
1146
  })
978
1147
  ]
979
1148
  });
980
1149
  };
981
1150
 
982
1151
  // src/components/json-render/JsonSlider.tsx
983
- import { useId as useId7, useState as useState9 } from "react";
1152
+ import { useId as useId8, useState as useState9 } from "react";
984
1153
  import { useBoundProp as useBoundProp8 } from "@json-render/react";
985
- import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
1154
+ import { jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
986
1155
  var JsonSlider = ({ props, bindings, emit }) => {
987
- const id = useId7();
1156
+ const id = useId8();
988
1157
  const [boundValue, setBoundValue] = useBoundProp8(props.value ?? undefined, bindings?.value);
989
1158
  const [localValue, setLocalValue] = useState9(props.value ?? props.min ?? 0);
990
1159
  const isBound = !!bindings?.value;
991
1160
  const value = isBound ? boundValue ?? props.min ?? 0 : localValue;
992
1161
  const setValue = isBound ? setBoundValue : setLocalValue;
993
- return /* @__PURE__ */ jsxs20("div", {
1162
+ const field = useJsonField({ path: bindings?.value, label: props.label });
1163
+ if (field.mode === "values")
1164
+ return /* @__PURE__ */ jsx30(JsonFieldValue, {
1165
+ field,
1166
+ text: String(value)
1167
+ });
1168
+ return /* @__PURE__ */ jsxs21("div", {
994
1169
  className: "space-y-2",
995
1170
  children: [
996
- props.label && /* @__PURE__ */ jsxs20("div", {
1171
+ field.label && /* @__PURE__ */ jsxs21("div", {
997
1172
  className: "flex justify-between",
998
1173
  children: [
999
- /* @__PURE__ */ jsx29(Label2, {
1174
+ /* @__PURE__ */ jsx30(Label2, {
1000
1175
  id,
1001
1176
  className: "text-sm",
1002
- children: props.label
1177
+ children: field.label
1003
1178
  }),
1004
- /* @__PURE__ */ jsx29("span", {
1179
+ /* @__PURE__ */ jsx30("span", {
1005
1180
  className: "text-sm text-muted-foreground",
1006
1181
  children: value
1007
1182
  })
1008
1183
  ]
1009
1184
  }),
1010
- /* @__PURE__ */ jsx29(Slider2, {
1011
- getAriaLabel: () => props.label ?? "Value",
1185
+ /* @__PURE__ */ jsx30(Slider2, {
1186
+ getAriaLabel: () => field.label || "Value",
1012
1187
  value: [value],
1013
1188
  min: props.min ?? 0,
1014
1189
  max: props.max ?? 100,
1015
1190
  step: props.step ?? 1,
1191
+ disabled: field.mode === "locked",
1016
1192
  onValueChange: (v) => {
1017
1193
  setValue(v[0] ?? 0);
1018
1194
  emit("change");
@@ -1023,10 +1199,10 @@ var JsonSlider = ({ props, bindings, emit }) => {
1023
1199
  };
1024
1200
 
1025
1201
  // src/components/json-render/JsonButton.tsx
1026
- import { jsx as jsx30 } from "react/jsx-runtime";
1202
+ import { jsx as jsx31 } from "react/jsx-runtime";
1027
1203
  var JsonButton = ({ props, emit }) => {
1028
1204
  const variant = props.variant === "danger" ? "destructive" : props.variant === "secondary" ? "secondary" : "default";
1029
- return /* @__PURE__ */ jsx30(Button2, {
1205
+ return /* @__PURE__ */ jsx31(Button2, {
1030
1206
  variant,
1031
1207
  disabled: props.disabled ?? false,
1032
1208
  onClick: () => emit("press"),
@@ -1035,9 +1211,9 @@ var JsonButton = ({ props, emit }) => {
1035
1211
  };
1036
1212
 
1037
1213
  // src/components/json-render/JsonLink.tsx
1038
- import { jsx as jsx31 } from "react/jsx-runtime";
1214
+ import { jsx as jsx32 } from "react/jsx-runtime";
1039
1215
  var JsonLink = ({ props, on }) => {
1040
- return /* @__PURE__ */ jsx31(ButtonLink2, {
1216
+ return /* @__PURE__ */ jsx32(ButtonLink2, {
1041
1217
  variant: "link",
1042
1218
  size: "inline",
1043
1219
  href: props.href ?? "#",
@@ -1052,27 +1228,75 @@ var JsonLink = ({ props, on }) => {
1052
1228
  };
1053
1229
 
1054
1230
  // src/components/json-render/JsonDropdownMenu.tsx
1231
+ import { useId as useId9 } from "react";
1055
1232
  import { useBoundProp as useBoundProp9 } from "@json-render/react";
1056
- import { jsx as jsx32, jsxs as jsxs21 } from "react/jsx-runtime";
1233
+ import { jsx as jsx33, jsxs as jsxs22 } from "react/jsx-runtime";
1057
1234
  var JsonDropdownMenu = ({ props, bindings, emit }) => {
1235
+ const labelId = useId9();
1058
1236
  const items = props.items ?? [];
1059
- const [, setBoundValue] = useBoundProp9(props.value ?? undefined, bindings?.value);
1060
- return /* @__PURE__ */ jsxs21(DropdownMenu2, {
1061
- children: [
1062
- /* @__PURE__ */ jsx32(DropdownMenuTrigger2, {
1063
- render: /* @__PURE__ */ jsx32(Button2, {
1064
- variant: "outline"
1237
+ const [boundValue, setBoundValue] = useBoundProp9(props.value ?? undefined, bindings?.value);
1238
+ const field = useJsonField({ path: bindings?.value, label: props.label });
1239
+ if (!bindings?.value)
1240
+ return /* @__PURE__ */ jsxs22(DropdownMenu2, {
1241
+ children: [
1242
+ /* @__PURE__ */ jsx33(DropdownMenuTrigger2, {
1243
+ render: /* @__PURE__ */ jsx33(Button2, {
1244
+ variant: "outline"
1245
+ }),
1246
+ children: props.label
1065
1247
  }),
1066
- children: props.label
1248
+ /* @__PURE__ */ jsx33(MenuPopup, {
1249
+ children: items.map((item) => /* @__PURE__ */ jsx33(MenuItem2, {
1250
+ onClick: () => {
1251
+ setBoundValue(item.value);
1252
+ emit("select");
1253
+ },
1254
+ children: item.label
1255
+ }, item.value))
1256
+ })
1257
+ ]
1258
+ });
1259
+ const chosen = items.find((item) => item.value === boundValue);
1260
+ if (field.mode === "values")
1261
+ return /* @__PURE__ */ jsx33(JsonFieldValue, {
1262
+ field,
1263
+ text: chosen?.label ?? ""
1264
+ });
1265
+ return /* @__PURE__ */ jsxs22("div", {
1266
+ className: "space-y-2",
1267
+ children: [
1268
+ /* @__PURE__ */ jsx33(JsonFieldLabel, {
1269
+ field,
1270
+ id: labelId
1067
1271
  }),
1068
- /* @__PURE__ */ jsx32(MenuPopup, {
1069
- children: items.map((item) => /* @__PURE__ */ jsx32(MenuItem2, {
1070
- onClick: () => {
1071
- setBoundValue(item.value);
1072
- emit("select");
1073
- },
1074
- children: item.label
1075
- }, item.value))
1272
+ /* @__PURE__ */ jsxs22(DropdownMenu2, {
1273
+ children: [
1274
+ /* @__PURE__ */ jsx33(DropdownMenuTrigger2, {
1275
+ render: /* @__PURE__ */ jsx33(Button2, {
1276
+ variant: "outline"
1277
+ }),
1278
+ disabled: field.mode === "locked",
1279
+ "aria-labelledby": field.label ? `${labelId} ${labelId}-value` : undefined,
1280
+ children: /* @__PURE__ */ jsx33("span", {
1281
+ id: `${labelId}-value`,
1282
+ children: chosen?.label ?? "Choose…"
1283
+ })
1284
+ }),
1285
+ /* @__PURE__ */ jsx33(MenuPopup, {
1286
+ children: /* @__PURE__ */ jsx33(MenuRadioGroup2, {
1287
+ value: chosen?.value ?? "",
1288
+ onValueChange: (value) => {
1289
+ setBoundValue(value);
1290
+ emit("select");
1291
+ },
1292
+ children: items.map((item) => /* @__PURE__ */ jsx33(MenuRadioItem2, {
1293
+ value: item.value,
1294
+ closeOnClick: true,
1295
+ children: item.label
1296
+ }, item.value))
1297
+ })
1298
+ })
1299
+ ]
1076
1300
  })
1077
1301
  ]
1078
1302
  });
@@ -1081,16 +1305,24 @@ var JsonDropdownMenu = ({ props, bindings, emit }) => {
1081
1305
  // src/components/json-render/JsonToggle.tsx
1082
1306
  import { useState as useState10 } from "react";
1083
1307
  import { useBoundProp as useBoundProp10 } from "@json-render/react";
1084
- import { jsx as jsx33 } from "react/jsx-runtime";
1308
+ import { jsx as jsx34 } from "react/jsx-runtime";
1085
1309
  var JsonToggle = ({ props, bindings, emit }) => {
1086
1310
  const [boundPressed, setBoundPressed] = useBoundProp10(props.pressed ?? undefined, bindings?.pressed);
1087
1311
  const [localPressed, setLocalPressed] = useState10(props.pressed ?? false);
1088
1312
  const isBound = !!bindings?.pressed;
1089
1313
  const pressed = isBound ? boundPressed ?? false : localPressed;
1090
1314
  const setPressed = isBound ? setBoundPressed : setLocalPressed;
1091
- return /* @__PURE__ */ jsx33(Toggle2, {
1315
+ const field = useJsonField({ path: bindings?.pressed, label: props.label });
1316
+ const mode = isBound ? field.mode : "edit";
1317
+ if (mode === "values")
1318
+ return /* @__PURE__ */ jsx34(JsonFieldValue, {
1319
+ field,
1320
+ text: pressed ? "On" : "Off"
1321
+ });
1322
+ return /* @__PURE__ */ jsx34(Toggle2, {
1092
1323
  variant: props.variant ?? "default",
1093
1324
  pressed,
1325
+ disabled: mode === "locked",
1094
1326
  onPressedChange: (v) => {
1095
1327
  setPressed(v);
1096
1328
  emit("change");
@@ -1102,7 +1334,7 @@ var JsonToggle = ({ props, bindings, emit }) => {
1102
1334
  // src/components/json-render/JsonToggleGroup.tsx
1103
1335
  import { useState as useState11 } from "react";
1104
1336
  import { useBoundProp as useBoundProp11 } from "@json-render/react";
1105
- import { jsx as jsx34 } from "react/jsx-runtime";
1337
+ import { jsx as jsx35 } from "react/jsx-runtime";
1106
1338
  var JsonToggleGroup = ({ props, bindings, emit }) => {
1107
1339
  const type = props.type ?? "single";
1108
1340
  const items = props.items ?? [];
@@ -1111,14 +1343,23 @@ var JsonToggleGroup = ({ props, bindings, emit }) => {
1111
1343
  const isBound = !!bindings?.value;
1112
1344
  const value = isBound ? boundValue ?? "" : localValue;
1113
1345
  const setValue = isBound ? setBoundValue : setLocalValue;
1114
- return /* @__PURE__ */ jsx34(ToggleGroup2, {
1346
+ const field = useJsonField({ path: bindings?.value });
1347
+ const mode = isBound ? field.mode : "edit";
1348
+ const selected = value ? value.split(",") : [];
1349
+ if (mode === "values")
1350
+ return /* @__PURE__ */ jsx35(JsonFieldValue, {
1351
+ field,
1352
+ text: items.filter((item) => selected.includes(item.value)).map((item) => item.label).join(", ")
1353
+ });
1354
+ return /* @__PURE__ */ jsx35(ToggleGroup2, {
1115
1355
  multiple: type === "multiple",
1116
- value: value ? value.split(",") : [],
1356
+ disabled: mode === "locked",
1357
+ value: selected,
1117
1358
  onValueChange: (values) => {
1118
1359
  setValue(values.join(","));
1119
1360
  emit("change");
1120
1361
  },
1121
- children: items.map((item) => /* @__PURE__ */ jsx34(ToggleGroupItem2, {
1362
+ children: items.map((item) => /* @__PURE__ */ jsx35(ToggleGroupItem2, {
1122
1363
  value: item.value,
1123
1364
  children: item.label
1124
1365
  }, item.value))
@@ -1128,7 +1369,7 @@ var JsonToggleGroup = ({ props, bindings, emit }) => {
1128
1369
  // src/components/json-render/JsonButtonGroup.tsx
1129
1370
  import { useState as useState12 } from "react";
1130
1371
  import { useBoundProp as useBoundProp12 } from "@json-render/react";
1131
- import { jsx as jsx35 } from "react/jsx-runtime";
1372
+ import { jsx as jsx36 } from "react/jsx-runtime";
1132
1373
  var JsonButtonGroup = ({ props, bindings, emit }) => {
1133
1374
  const buttons = props.buttons ?? [];
1134
1375
  const [boundSelected, setBoundSelected] = useBoundProp12(props.selected ?? undefined, bindings?.selected);
@@ -1136,15 +1377,23 @@ var JsonButtonGroup = ({ props, bindings, emit }) => {
1136
1377
  const isBound = !!bindings?.selected;
1137
1378
  const value = isBound ? boundSelected ?? "" : localValue;
1138
1379
  const setValue = isBound ? setBoundSelected : setLocalValue;
1139
- return /* @__PURE__ */ jsx35(ToggleGroup2, {
1380
+ const field = useJsonField({ path: bindings?.selected });
1381
+ const mode = isBound ? field.mode : "edit";
1382
+ if (mode === "values")
1383
+ return /* @__PURE__ */ jsx36(JsonFieldValue, {
1384
+ field,
1385
+ text: buttons.find((button) => button.value === value)?.label ?? ""
1386
+ });
1387
+ return /* @__PURE__ */ jsx36(ToggleGroup2, {
1140
1388
  variant: "outline",
1141
1389
  spacing: 0,
1390
+ disabled: mode === "locked",
1142
1391
  value: value ? [value] : [],
1143
1392
  onValueChange: (values) => {
1144
1393
  setValue(values[0] ?? "");
1145
1394
  emit("change");
1146
1395
  },
1147
- children: buttons.map((button) => /* @__PURE__ */ jsx35(ToggleGroupItem2, {
1396
+ children: buttons.map((button) => /* @__PURE__ */ jsx36(ToggleGroupItem2, {
1148
1397
  value: button.value,
1149
1398
  children: button.label
1150
1399
  }, button.value))
@@ -1178,7 +1427,7 @@ function getPaginationRange(current, total) {
1178
1427
  }
1179
1428
 
1180
1429
  // src/components/json-render/JsonPagination.tsx
1181
- import { jsx as jsx36, jsxs as jsxs22 } from "react/jsx-runtime";
1430
+ import { jsx as jsx37, jsxs as jsxs23 } from "react/jsx-runtime";
1182
1431
  var JsonPagination = ({ props, bindings, emit }) => {
1183
1432
  const [boundPage, setBoundPage] = useBoundProp13(props.page ?? undefined, bindings?.page);
1184
1433
  const [localPage, setLocalPage] = useState13(props.page ?? 1);
@@ -1186,11 +1435,11 @@ var JsonPagination = ({ props, bindings, emit }) => {
1186
1435
  const setPage = bindings?.page ? setBoundPage : setLocalPage;
1187
1436
  const totalPages = props.totalPages ?? 1;
1188
1437
  const pages = getPaginationRange(currentPage, totalPages);
1189
- return /* @__PURE__ */ jsx36(Pagination2, {
1190
- children: /* @__PURE__ */ jsxs22(PaginationContent2, {
1438
+ return /* @__PURE__ */ jsx37(Pagination2, {
1439
+ children: /* @__PURE__ */ jsxs23(PaginationContent2, {
1191
1440
  children: [
1192
- /* @__PURE__ */ jsx36(PaginationItem2, {
1193
- children: /* @__PURE__ */ jsx36(PaginationPrevious2, {
1441
+ /* @__PURE__ */ jsx37(PaginationItem2, {
1442
+ children: /* @__PURE__ */ jsx37(PaginationPrevious2, {
1194
1443
  href: "#",
1195
1444
  onClick: (e) => {
1196
1445
  e.preventDefault();
@@ -1201,10 +1450,10 @@ var JsonPagination = ({ props, bindings, emit }) => {
1201
1450
  }
1202
1451
  })
1203
1452
  }),
1204
- pages.map((page, idx) => page === "ellipsis" ? /* @__PURE__ */ jsx36(PaginationItem2, {
1205
- children: /* @__PURE__ */ jsx36(PaginationEllipsis2, {})
1206
- }, `ellipsis-${idx}`) : /* @__PURE__ */ jsx36(PaginationItem2, {
1207
- children: /* @__PURE__ */ jsx36(PaginationLink2, {
1453
+ pages.map((page, idx) => page === "ellipsis" ? /* @__PURE__ */ jsx37(PaginationItem2, {
1454
+ children: /* @__PURE__ */ jsx37(PaginationEllipsis2, {})
1455
+ }, `ellipsis-${idx}`) : /* @__PURE__ */ jsx37(PaginationItem2, {
1456
+ children: /* @__PURE__ */ jsx37(PaginationLink2, {
1208
1457
  href: "#",
1209
1458
  isActive: page === currentPage,
1210
1459
  onClick: (e) => {
@@ -1215,8 +1464,8 @@ var JsonPagination = ({ props, bindings, emit }) => {
1215
1464
  children: page
1216
1465
  })
1217
1466
  }, page)),
1218
- /* @__PURE__ */ jsx36(PaginationItem2, {
1219
- children: /* @__PURE__ */ jsx36(PaginationNext2, {
1467
+ /* @__PURE__ */ jsx37(PaginationItem2, {
1468
+ children: /* @__PURE__ */ jsx37(PaginationNext2, {
1220
1469
  href: "#",
1221
1470
  onClick: (e) => {
1222
1471
  e.preventDefault();
@@ -1272,6 +1521,15 @@ var components = {
1272
1521
  Pagination: JsonPagination
1273
1522
  };
1274
1523
  export {
1524
+ JsonFieldLabel,
1525
+ JsonFieldMessage,
1526
+ JsonFieldValue,
1527
+ JsonFormProvider,
1528
+ JsonRevealScope,
1275
1529
  componentDefinitions2 as componentDefinitions,
1276
- components
1530
+ components,
1531
+ stripRequiredMark,
1532
+ useJsonField,
1533
+ useJsonForm,
1534
+ useJsonReveal
1277
1535
  };