@uipath/apollo-wind 0.9.0 → 0.10.0-pr257.2a4b17b

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 (145) hide show
  1. package/dist/components/forms/field-renderer.cjs +120 -69
  2. package/dist/components/forms/field-renderer.js +120 -69
  3. package/dist/components/forms/form-designer.cjs +2352 -1488
  4. package/dist/components/forms/form-designer.js +2353 -1489
  5. package/dist/components/forms/form-examples.cjs +10 -10
  6. package/dist/components/forms/form-examples.js +10 -10
  7. package/dist/components/forms/form-state-viewer.cjs +988 -433
  8. package/dist/components/forms/form-state-viewer.js +988 -433
  9. package/dist/components/forms/metadata-form.cjs +446 -170
  10. package/dist/components/forms/metadata-form.js +446 -170
  11. package/dist/components/forms/schema-viewer.cjs +173 -80
  12. package/dist/components/forms/schema-viewer.js +173 -80
  13. package/dist/components/ui/accordion.cjs +131 -27
  14. package/dist/components/ui/accordion.js +131 -27
  15. package/dist/components/ui/alert-dialog.cjs +273 -45
  16. package/dist/components/ui/alert-dialog.js +273 -45
  17. package/dist/components/ui/alert.cjs +106 -17
  18. package/dist/components/ui/alert.js +106 -17
  19. package/dist/components/ui/avatar.cjs +100 -15
  20. package/dist/components/ui/avatar.js +100 -15
  21. package/dist/components/ui/badge.cjs +36 -6
  22. package/dist/components/ui/badge.js +36 -6
  23. package/dist/components/ui/breadcrumb.cjs +258 -52
  24. package/dist/components/ui/breadcrumb.js +258 -52
  25. package/dist/components/ui/button-group.cjs +119 -19
  26. package/dist/components/ui/button-group.js +119 -19
  27. package/dist/components/ui/button.cjs +48 -8
  28. package/dist/components/ui/button.js +48 -8
  29. package/dist/components/ui/calendar.cjs +88 -30
  30. package/dist/components/ui/calendar.js +88 -30
  31. package/dist/components/ui/card.cjs +199 -30
  32. package/dist/components/ui/card.js +199 -30
  33. package/dist/components/ui/checkbox.cjs +42 -8
  34. package/dist/components/ui/checkbox.js +42 -8
  35. package/dist/components/ui/combobox.cjs +150 -53
  36. package/dist/components/ui/combobox.js +150 -53
  37. package/dist/components/ui/command.cjs +291 -53
  38. package/dist/components/ui/command.js +291 -53
  39. package/dist/components/ui/context-menu.cjs +370 -72
  40. package/dist/components/ui/context-menu.js +370 -72
  41. package/dist/components/ui/data-table.cjs +76 -39
  42. package/dist/components/ui/data-table.js +76 -39
  43. package/dist/components/ui/date-picker.cjs +179 -68
  44. package/dist/components/ui/date-picker.js +179 -68
  45. package/dist/components/ui/datetime-picker.cjs +225 -104
  46. package/dist/components/ui/datetime-picker.js +225 -104
  47. package/dist/components/ui/dialog.cjs +290 -78
  48. package/dist/components/ui/dialog.js +290 -78
  49. package/dist/components/ui/drawer.cjs +220 -39
  50. package/dist/components/ui/drawer.js +220 -39
  51. package/dist/components/ui/dropdown-menu.cjs +376 -73
  52. package/dist/components/ui/dropdown-menu.js +376 -73
  53. package/dist/components/ui/editable-cell.cjs +106 -42
  54. package/dist/components/ui/editable-cell.js +106 -42
  55. package/dist/components/ui/empty-state.cjs +106 -33
  56. package/dist/components/ui/empty-state.js +106 -33
  57. package/dist/components/ui/file-upload.cjs +405 -187
  58. package/dist/components/ui/file-upload.d.ts +3 -1
  59. package/dist/components/ui/file-upload.js +405 -187
  60. package/dist/components/ui/hover-card.cjs +46 -7
  61. package/dist/components/ui/hover-card.js +46 -7
  62. package/dist/components/ui/index.cjs +4 -4
  63. package/dist/components/ui/input.cjs +39 -6
  64. package/dist/components/ui/input.js +39 -6
  65. package/dist/components/ui/label.cjs +34 -5
  66. package/dist/components/ui/label.js +34 -5
  67. package/dist/components/ui/layout/column.cjs +209 -41
  68. package/dist/components/ui/layout/column.js +209 -41
  69. package/dist/components/ui/layout/grid.cjs +275 -60
  70. package/dist/components/ui/layout/grid.js +275 -60
  71. package/dist/components/ui/layout/row.cjs +209 -41
  72. package/dist/components/ui/layout/row.js +209 -41
  73. package/dist/components/ui/menubar.cjs +540 -106
  74. package/dist/components/ui/menubar.js +540 -106
  75. package/dist/components/ui/multi-select.cjs +289 -135
  76. package/dist/components/ui/multi-select.js +289 -135
  77. package/dist/components/ui/navigation-menu.cjs +244 -47
  78. package/dist/components/ui/navigation-menu.js +244 -47
  79. package/dist/components/ui/pagination.cjs +301 -65
  80. package/dist/components/ui/pagination.js +301 -65
  81. package/dist/components/ui/popover.cjs +48 -9
  82. package/dist/components/ui/popover.js +48 -9
  83. package/dist/components/ui/progress.cjs +48 -8
  84. package/dist/components/ui/progress.js +48 -8
  85. package/dist/components/ui/radio-group.cjs +74 -12
  86. package/dist/components/ui/radio-group.js +74 -12
  87. package/dist/components/ui/resizable.cjs +75 -10
  88. package/dist/components/ui/resizable.js +75 -10
  89. package/dist/components/ui/scroll-area.cjs +113 -21
  90. package/dist/components/ui/scroll-area.js +113 -21
  91. package/dist/components/ui/search.cjs +280 -98
  92. package/dist/components/ui/search.js +280 -98
  93. package/dist/components/ui/select.cjs +334 -68
  94. package/dist/components/ui/select.js +334 -68
  95. package/dist/components/ui/separator.cjs +48 -7
  96. package/dist/components/ui/separator.js +48 -7
  97. package/dist/components/ui/sheet.cjs +236 -50
  98. package/dist/components/ui/sheet.js +236 -50
  99. package/dist/components/ui/skeleton.cjs +31 -5
  100. package/dist/components/ui/skeleton.js +31 -5
  101. package/dist/components/ui/slider.cjs +71 -21
  102. package/dist/components/ui/slider.js +71 -21
  103. package/dist/components/ui/sonner.cjs +43 -15
  104. package/dist/components/ui/sonner.js +43 -15
  105. package/dist/components/ui/spinner.cjs +83 -21
  106. package/dist/components/ui/spinner.js +83 -21
  107. package/dist/components/ui/stats-card.cjs +169 -60
  108. package/dist/components/ui/stats-card.js +169 -60
  109. package/dist/components/ui/stepper.cjs +126 -57
  110. package/dist/components/ui/stepper.js +126 -57
  111. package/dist/components/ui/switch.cjs +42 -8
  112. package/dist/components/ui/switch.js +42 -8
  113. package/dist/components/ui/table.cjs +267 -42
  114. package/dist/components/ui/table.js +267 -42
  115. package/dist/components/ui/tabs.cjs +100 -15
  116. package/dist/components/ui/tabs.js +100 -15
  117. package/dist/components/ui/textarea.cjs +34 -5
  118. package/dist/components/ui/textarea.js +34 -5
  119. package/dist/components/ui/toggle-group.cjs +112 -19
  120. package/dist/components/ui/toggle-group.js +112 -19
  121. package/dist/components/ui/toggle.cjs +43 -6
  122. package/dist/components/ui/toggle.js +43 -6
  123. package/dist/components/ui/tooltip.cjs +40 -6
  124. package/dist/components/ui/tooltip.js +40 -6
  125. package/dist/examples/admin-layout-example.cjs +879 -347
  126. package/dist/examples/admin-layout-example.js +879 -347
  127. package/dist/examples/app-shell-example.cjs +14 -14
  128. package/dist/examples/app-shell-example.js +14 -14
  129. package/dist/examples/dashboard-example.cjs +495 -334
  130. package/dist/examples/dashboard-example.js +495 -334
  131. package/dist/examples/data-management-example.cjs +501 -303
  132. package/dist/examples/data-management-example.js +502 -304
  133. package/dist/examples/flow-editor-layout-example.cjs +435 -231
  134. package/dist/examples/flow-editor-layout-example.js +436 -232
  135. package/dist/examples/flow-start-example.cjs +508 -251
  136. package/dist/examples/flow-start-example.js +509 -252
  137. package/dist/examples/form-builder-example.cjs +1006 -602
  138. package/dist/examples/form-builder-example.js +1007 -603
  139. package/dist/examples/new-project-example.cjs +806 -474
  140. package/dist/examples/new-project-example.js +807 -475
  141. package/dist/examples/settings-example.cjs +792 -704
  142. package/dist/examples/settings-example.js +792 -704
  143. package/dist/examples/vscode-example.cjs +731 -236
  144. package/dist/examples/vscode-example.js +731 -236
  145. package/package.json +4 -1
@@ -1,5 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useEffect, useMemo, useState } from "react";
2
+ import { c as compiler_runtime_c } from "react/compiler-runtime";
3
+ import { useEffect, useRef, useState } from "react";
3
4
  import { schemaToJson } from "./schema-serializer.js";
4
5
  import { MetadataForm } from "./metadata-form.js";
5
6
  import { Button } from "../ui/button.js";
@@ -472,20 +473,47 @@ const createFieldConfigSchema = (field)=>({
472
473
  },
473
474
  actions: []
474
475
  });
475
- function SectionConfigForm({ section, onUpdate, existingSectionIds }) {
476
+ function SectionConfigForm(t0) {
477
+ const $ = compiler_runtime_c(28);
478
+ const { section, onUpdate, existingSectionIds } = t0;
476
479
  const [attemptedId, setAttemptedId] = useState(null);
477
- useEffect(()=>{
478
- setAttemptedId(null);
479
- }, [
480
- section.id
481
- ]);
482
- const isDuplicateId = null !== attemptedId && attemptedId !== section.id && existingSectionIds.has(attemptedId);
483
- const schema = useMemo(()=>createSectionConfigSchema(section), [
484
- section
485
- ]);
486
- const plugins = useMemo(()=>[
480
+ let t1;
481
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
482
+ t1 = ()=>{
483
+ setAttemptedId(null);
484
+ };
485
+ $[0] = t1;
486
+ } else t1 = $[0];
487
+ let t2;
488
+ if ($[1] !== section.id) {
489
+ t2 = [
490
+ section.id
491
+ ];
492
+ $[1] = section.id;
493
+ $[2] = t2;
494
+ } else t2 = $[2];
495
+ useEffect(t1, t2);
496
+ let t3;
497
+ if ($[3] !== attemptedId || $[4] !== existingSectionIds || $[5] !== section.id) {
498
+ t3 = null !== attemptedId && attemptedId !== section.id && existingSectionIds.has(attemptedId);
499
+ $[3] = attemptedId;
500
+ $[4] = existingSectionIds;
501
+ $[5] = section.id;
502
+ $[6] = t3;
503
+ } else t3 = $[6];
504
+ const isDuplicateId = t3;
505
+ let t4;
506
+ if ($[7] !== section) {
507
+ t4 = createSectionConfigSchema(section);
508
+ $[7] = section;
509
+ $[8] = t4;
510
+ } else t4 = $[8];
511
+ const schema = t4;
512
+ let t5;
513
+ if ($[9] !== onUpdate) {
514
+ t5 = [
487
515
  {
488
- name: 'section-sync',
516
+ name: "section-sync",
489
517
  onValueChange: (_field, _value, context)=>{
490
518
  const values = context.values;
491
519
  const newId = values.id;
@@ -499,908 +527,1528 @@ function SectionConfigForm({ section, onUpdate, existingSectionIds }) {
499
527
  });
500
528
  }
501
529
  }
502
- ], [
503
- onUpdate
504
- ]);
505
- return /*#__PURE__*/ jsxs("div", {
506
- className: "space-y-4",
507
- children: [
508
- isDuplicateId && /*#__PURE__*/ jsxs("div", {
509
- className: "flex items-center gap-2 p-2 bg-destructive/10 border border-destructive/20 rounded-md text-destructive text-sm",
510
- children: [
511
- /*#__PURE__*/ jsx(AlertTriangle, {
512
- className: "h-4 w-4 shrink-0"
513
- }),
514
- /*#__PURE__*/ jsxs("span", {
515
- children: [
516
- 'Section ID "',
517
- attemptedId,
518
- '" already exists. Please use a unique ID.'
519
- ]
520
- })
521
- ]
522
- }),
523
- /*#__PURE__*/ jsx(MetadataForm, {
524
- schema: schema,
525
- plugins: plugins,
526
- autoComplete: "off"
527
- }, section.id),
528
- /*#__PURE__*/ jsx(Separator, {}),
529
- /*#__PURE__*/ jsxs("div", {
530
- className: "text-sm text-muted-foreground",
531
- children: [
532
- /*#__PURE__*/ jsxs("p", {
533
- children: [
534
- "This section contains ",
535
- section.fields.length,
536
- " field(s)."
537
- ]
538
- }),
539
- /*#__PURE__*/ jsx("p", {
540
- className: "mt-1",
541
- children: "Click on a field in the left panel to configure it."
542
- })
543
- ]
544
- })
545
- ]
546
- });
530
+ ];
531
+ $[9] = onUpdate;
532
+ $[10] = t5;
533
+ } else t5 = $[10];
534
+ const plugins = t5;
535
+ let t6;
536
+ if ($[11] !== attemptedId || $[12] !== isDuplicateId) {
537
+ t6 = isDuplicateId && /*#__PURE__*/ jsxs("div", {
538
+ className: "flex items-center gap-2 p-2 bg-destructive/10 border border-destructive/20 rounded-md text-destructive text-sm",
539
+ children: [
540
+ /*#__PURE__*/ jsx(AlertTriangle, {
541
+ className: "h-4 w-4 shrink-0"
542
+ }),
543
+ /*#__PURE__*/ jsxs("span", {
544
+ children: [
545
+ 'Section ID "',
546
+ attemptedId,
547
+ '" already exists. Please use a unique ID.'
548
+ ]
549
+ })
550
+ ]
551
+ });
552
+ $[11] = attemptedId;
553
+ $[12] = isDuplicateId;
554
+ $[13] = t6;
555
+ } else t6 = $[13];
556
+ let t7;
557
+ if ($[14] !== plugins || $[15] !== schema || $[16] !== section.id) {
558
+ t7 = /*#__PURE__*/ jsx(MetadataForm, {
559
+ schema: schema,
560
+ plugins: plugins,
561
+ autoComplete: "off"
562
+ }, section.id);
563
+ $[14] = plugins;
564
+ $[15] = schema;
565
+ $[16] = section.id;
566
+ $[17] = t7;
567
+ } else t7 = $[17];
568
+ let t8;
569
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
570
+ t8 = /*#__PURE__*/ jsx(Separator, {});
571
+ $[18] = t8;
572
+ } else t8 = $[18];
573
+ let t9;
574
+ if ($[19] !== section.fields.length) {
575
+ t9 = /*#__PURE__*/ jsxs("p", {
576
+ children: [
577
+ "This section contains ",
578
+ section.fields.length,
579
+ " field(s)."
580
+ ]
581
+ });
582
+ $[19] = section.fields.length;
583
+ $[20] = t9;
584
+ } else t9 = $[20];
585
+ let t10;
586
+ if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
587
+ t10 = /*#__PURE__*/ jsx("p", {
588
+ className: "mt-1",
589
+ children: "Click on a field in the left panel to configure it."
590
+ });
591
+ $[21] = t10;
592
+ } else t10 = $[21];
593
+ let t11;
594
+ if ($[22] !== t9) {
595
+ t11 = /*#__PURE__*/ jsxs("div", {
596
+ className: "text-sm text-muted-foreground",
597
+ children: [
598
+ t9,
599
+ t10
600
+ ]
601
+ });
602
+ $[22] = t9;
603
+ $[23] = t11;
604
+ } else t11 = $[23];
605
+ let t12;
606
+ if ($[24] !== t11 || $[25] !== t6 || $[26] !== t7) {
607
+ t12 = /*#__PURE__*/ jsxs("div", {
608
+ className: "space-y-4",
609
+ children: [
610
+ t6,
611
+ t7,
612
+ t8,
613
+ t11
614
+ ]
615
+ });
616
+ $[24] = t11;
617
+ $[25] = t6;
618
+ $[26] = t7;
619
+ $[27] = t12;
620
+ } else t12 = $[27];
621
+ return t12;
547
622
  }
548
- function FieldConfigForm({ field, onUpdate, allFields, existingFieldNames }) {
623
+ function FieldConfigForm(t0) {
624
+ const $ = compiler_runtime_c(53);
625
+ const { field, onUpdate, allFields, existingFieldNames } = t0;
549
626
  const [attemptedName, setAttemptedName] = useState(null);
550
- useEffect(()=>{
551
- setAttemptedName(null);
552
- }, [
553
- field.id
554
- ]);
555
- const isDuplicateName = null !== attemptedName && attemptedName !== field.name && existingFieldNames.has(attemptedName);
556
- const schema = useMemo(()=>createFieldConfigSchema(field), [
557
- field
558
- ]);
559
- const currentTypeRef = useMemo(()=>({
560
- type: field.type
561
- }), [
562
- field.type
563
- ]);
564
- const plugins = useMemo(()=>[
565
- {
566
- name: 'field-sync',
567
- onValueChange: (_fieldName, _value, context)=>{
568
- const values = context.values;
569
- const newType = values.type;
570
- const newName = values.name;
571
- const validationValues = values.validation;
572
- setAttemptedName(newName);
573
- const updates = {
574
- name: newName,
575
- label: values.label,
576
- type: newType,
577
- placeholder: values.placeholder || void 0,
578
- description: values.description || void 0
579
- };
580
- const requiredMessage = validationValues?.requiredMessage || void 0;
581
- if ('number' === newType || 'slider' === newType) {
582
- updates.min = values.min;
583
- updates.max = values.max;
584
- updates.step = values.step;
585
- updates.validation = {
586
- integer: validationValues?.integer,
587
- requiredMessage
588
- };
589
- } else if ('file' === newType) {
590
- updates.accept = values.accept || void 0;
591
- updates.multiple = values.multiple;
592
- const maxFileSizeMB = validationValues?.maxFileSize;
593
- updates.validation = {
594
- maxFileSize: maxFileSizeMB ? 1024 * maxFileSizeMB * 1024 : void 0,
595
- maxFiles: validationValues?.maxFiles,
596
- requiredMessage
627
+ let t1;
628
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
629
+ t1 = ()=>{
630
+ setAttemptedName(null);
631
+ };
632
+ $[0] = t1;
633
+ } else t1 = $[0];
634
+ let t2;
635
+ if ($[1] !== field.id) {
636
+ t2 = [
637
+ field.id
638
+ ];
639
+ $[1] = field.id;
640
+ $[2] = t2;
641
+ } else t2 = $[2];
642
+ useEffect(t1, t2);
643
+ let t3;
644
+ if ($[3] !== attemptedName || $[4] !== existingFieldNames || $[5] !== field.name) {
645
+ t3 = null !== attemptedName && attemptedName !== field.name && existingFieldNames.has(attemptedName);
646
+ $[3] = attemptedName;
647
+ $[4] = existingFieldNames;
648
+ $[5] = field.name;
649
+ $[6] = t3;
650
+ } else t3 = $[6];
651
+ const isDuplicateName = t3;
652
+ let t4;
653
+ if ($[7] !== field) {
654
+ t4 = createFieldConfigSchema(field);
655
+ $[7] = field;
656
+ $[8] = t4;
657
+ } else t4 = $[8];
658
+ const schema = t4;
659
+ const currentTypeRef = useRef(field.type);
660
+ let t5;
661
+ let t6;
662
+ if ($[9] !== field.type) {
663
+ t5 = ()=>{
664
+ currentTypeRef.current = field.type;
665
+ };
666
+ t6 = [
667
+ field.type
668
+ ];
669
+ $[9] = field.type;
670
+ $[10] = t5;
671
+ $[11] = t6;
672
+ } else {
673
+ t5 = $[10];
674
+ t6 = $[11];
675
+ }
676
+ useEffect(t5, t6);
677
+ let t7;
678
+ if ($[12] !== field.validation?.requiredMessage || $[13] !== onUpdate) {
679
+ field.validation?.requiredMessage;
680
+ t7 = (()=>[
681
+ {
682
+ name: "field-sync",
683
+ onValueChange: (_fieldName, _value, context)=>{
684
+ const values = context.values;
685
+ const newType = values.type;
686
+ const newName = values.name;
687
+ const validationValues = values.validation;
688
+ setAttemptedName(newName);
689
+ const updates = {
690
+ name: newName,
691
+ label: values.label,
692
+ type: newType,
693
+ placeholder: values.placeholder || void 0,
694
+ description: values.description || void 0
597
695
  };
598
- } else if ('text' === newType || 'textarea' === newType || 'email' === newType) updates.validation = {
599
- minLength: validationValues?.minLength,
600
- maxLength: validationValues?.maxLength,
601
- pattern: validationValues?.pattern || void 0,
602
- patternMessage: validationValues?.patternMessage || void 0,
603
- requiredMessage
604
- };
605
- else if (requiredMessage) updates.validation = {
606
- requiredMessage
607
- };
608
- if (newType !== currentTypeRef.type) {
609
- const preservedRequiredMessage = field.validation?.requiredMessage;
610
- updates.options = void 0;
611
- updates.min = void 0;
612
- updates.max = void 0;
613
- updates.step = void 0;
614
- updates.accept = void 0;
615
- updates.multiple = void 0;
616
- updates.validation = void 0;
617
- if ('number' === newType || 'slider' === newType) {
696
+ const requiredMessage = validationValues?.requiredMessage || void 0;
697
+ if ("number" === newType || "slider" === newType) {
618
698
  updates.min = values.min;
619
699
  updates.max = values.max;
620
700
  updates.step = values.step;
621
701
  updates.validation = {
622
702
  integer: validationValues?.integer,
623
- requiredMessage: preservedRequiredMessage
703
+ requiredMessage
624
704
  };
625
- } else if ('file' === newType) {
705
+ } else if ("file" === newType) {
626
706
  updates.accept = values.accept || void 0;
627
707
  updates.multiple = values.multiple;
628
708
  const maxFileSizeMB = validationValues?.maxFileSize;
629
709
  updates.validation = {
630
710
  maxFileSize: maxFileSizeMB ? 1024 * maxFileSizeMB * 1024 : void 0,
631
711
  maxFiles: validationValues?.maxFiles,
632
- requiredMessage: preservedRequiredMessage
712
+ requiredMessage
633
713
  };
634
- } else if ('text' === newType || 'textarea' === newType || 'email' === newType) updates.validation = {
714
+ } else if ("text" === newType || "textarea" === newType || "email" === newType) updates.validation = {
635
715
  minLength: validationValues?.minLength,
636
716
  maxLength: validationValues?.maxLength,
637
717
  pattern: validationValues?.pattern || void 0,
638
718
  patternMessage: validationValues?.patternMessage || void 0,
639
- requiredMessage: preservedRequiredMessage
719
+ requiredMessage
640
720
  };
641
- else if (preservedRequiredMessage) updates.validation = {
642
- requiredMessage: preservedRequiredMessage
721
+ else if (requiredMessage) updates.validation = {
722
+ requiredMessage
643
723
  };
644
- currentTypeRef.type = newType;
724
+ if (newType !== currentTypeRef.current) {
725
+ const preservedRequiredMessage = field.validation?.requiredMessage;
726
+ updates.options = void 0;
727
+ updates.min = void 0;
728
+ updates.max = void 0;
729
+ updates.step = void 0;
730
+ updates.accept = void 0;
731
+ updates.multiple = void 0;
732
+ updates.validation = void 0;
733
+ if ("number" === newType || "slider" === newType) {
734
+ updates.min = values.min;
735
+ updates.max = values.max;
736
+ updates.step = values.step;
737
+ updates.validation = {
738
+ integer: validationValues?.integer,
739
+ requiredMessage: preservedRequiredMessage
740
+ };
741
+ } else if ("file" === newType) {
742
+ updates.accept = values.accept || void 0;
743
+ updates.multiple = values.multiple;
744
+ const maxFileSizeMB_0 = validationValues?.maxFileSize;
745
+ updates.validation = {
746
+ maxFileSize: maxFileSizeMB_0 ? 1024 * maxFileSizeMB_0 * 1024 : void 0,
747
+ maxFiles: validationValues?.maxFiles,
748
+ requiredMessage: preservedRequiredMessage
749
+ };
750
+ } else if ("text" === newType || "textarea" === newType || "email" === newType) updates.validation = {
751
+ minLength: validationValues?.minLength,
752
+ maxLength: validationValues?.maxLength,
753
+ pattern: validationValues?.pattern || void 0,
754
+ patternMessage: validationValues?.patternMessage || void 0,
755
+ requiredMessage: preservedRequiredMessage
756
+ };
757
+ else if (preservedRequiredMessage) updates.validation = {
758
+ requiredMessage: preservedRequiredMessage
759
+ };
760
+ currentTypeRef.current = newType;
761
+ }
762
+ onUpdate(updates);
645
763
  }
646
- onUpdate(updates);
647
764
  }
648
- }
649
- ], [
650
- onUpdate,
651
- currentTypeRef,
652
- field.validation?.requiredMessage
653
- ]);
654
- const needsOptions = [
655
- 'select',
656
- 'multiselect',
657
- 'radio'
658
- ].includes(field.type);
659
- return /*#__PURE__*/ jsxs("div", {
660
- className: "space-y-2",
661
- children: [
662
- isDuplicateName && /*#__PURE__*/ jsxs("div", {
663
- className: "flex items-center gap-2 p-2 bg-destructive/10 border border-destructive/20 rounded-md text-destructive text-sm",
664
- children: [
665
- /*#__PURE__*/ jsx(AlertTriangle, {
666
- className: "h-4 w-4 shrink-0"
667
- }),
668
- /*#__PURE__*/ jsxs("span", {
669
- children: [
670
- 'Field name "',
671
- attemptedName,
672
- '" already exists. Please use a unique name.'
673
- ]
674
- })
675
- ]
676
- }),
677
- /*#__PURE__*/ jsx(MetadataForm, {
678
- schema: schema,
679
- plugins: plugins,
680
- autoComplete: "off"
681
- }, field.id),
682
- needsOptions && /*#__PURE__*/ jsx(Accordion, {
683
- type: "multiple",
684
- defaultValue: [
685
- 'options'
686
- ],
687
- children: /*#__PURE__*/ jsxs(AccordionItem, {
688
- value: "options",
689
- className: "border rounded-lg px-3",
690
- children: [
691
- /*#__PURE__*/ jsx(AccordionTrigger, {
692
- className: "text-sm font-medium",
693
- children: /*#__PURE__*/ jsxs("div", {
694
- className: "flex items-center gap-2",
695
- children: [
696
- /*#__PURE__*/ jsx(Database, {
697
- className: "h-4 w-4"
698
- }),
699
- "Options"
700
- ]
701
- })
702
- }),
703
- /*#__PURE__*/ jsx(AccordionContent, {
704
- className: "pt-2",
705
- children: /*#__PURE__*/ jsx(FieldOptionsEditor, {
706
- options: field.options || [],
707
- onChange: (options)=>onUpdate({
708
- options
709
- })
710
- })
711
- })
712
- ]
713
- })
714
- }),
715
- /*#__PURE__*/ jsx(Accordion, {
716
- type: "multiple",
717
- defaultValue: [
718
- 'data-source'
719
- ],
720
- children: /*#__PURE__*/ jsxs(AccordionItem, {
721
- value: "data-source",
722
- className: "border rounded-lg px-3",
723
- children: [
724
- /*#__PURE__*/ jsx(AccordionTrigger, {
725
- className: "text-sm font-medium",
726
- children: /*#__PURE__*/ jsxs("div", {
727
- className: "flex items-center gap-2",
728
- children: [
729
- /*#__PURE__*/ jsx(Database, {
730
- className: "h-4 w-4"
731
- }),
732
- "Data source"
733
- ]
734
- })
735
- }),
736
- /*#__PURE__*/ jsx(AccordionContent, {
737
- className: "pt-2",
738
- children: /*#__PURE__*/ jsx(DataSourceEditor, {
739
- dataSource: field.dataSource,
740
- onChange: (dataSource)=>onUpdate({
741
- dataSource
742
- })
743
- })
744
- })
745
- ]
746
- })
747
- }),
748
- /*#__PURE__*/ jsx(Accordion, {
749
- type: "multiple",
750
- defaultValue: [
751
- 'rules'
752
- ],
753
- children: /*#__PURE__*/ jsxs(AccordionItem, {
754
- value: "rules",
755
- className: "border rounded-lg px-3",
765
+ ])();
766
+ $[12] = field.validation?.requiredMessage;
767
+ $[13] = onUpdate;
768
+ $[14] = t7;
769
+ } else t7 = $[14];
770
+ const plugins = t7;
771
+ let t8;
772
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
773
+ t8 = [
774
+ "select",
775
+ "multiselect",
776
+ "radio"
777
+ ];
778
+ $[15] = t8;
779
+ } else t8 = $[15];
780
+ const needsOptions = t8.includes(field.type);
781
+ let t9;
782
+ if ($[16] !== attemptedName || $[17] !== isDuplicateName) {
783
+ t9 = isDuplicateName && /*#__PURE__*/ jsxs("div", {
784
+ className: "flex items-center gap-2 p-2 bg-destructive/10 border border-destructive/20 rounded-md text-destructive text-sm",
785
+ children: [
786
+ /*#__PURE__*/ jsx(AlertTriangle, {
787
+ className: "h-4 w-4 shrink-0"
788
+ }),
789
+ /*#__PURE__*/ jsxs("span", {
756
790
  children: [
757
- /*#__PURE__*/ jsx(AccordionTrigger, {
758
- className: "text-sm font-medium",
759
- children: /*#__PURE__*/ jsxs("div", {
760
- className: "flex items-center gap-2",
761
- children: [
762
- /*#__PURE__*/ jsx(GitBranch, {
763
- className: "h-4 w-4"
764
- }),
765
- "Rules & conditions"
766
- ]
767
- })
768
- }),
769
- /*#__PURE__*/ jsx(AccordionContent, {
770
- className: "pt-2",
771
- children: /*#__PURE__*/ jsx(RulesEditor, {
772
- rules: field.rules,
773
- onChange: (rules)=>onUpdate({
774
- rules
775
- }),
776
- allFields: allFields,
777
- requiredMessage: field.validation?.requiredMessage,
778
- onRequiredMessageChange: (message)=>onUpdate({
779
- validation: {
780
- ...field.validation,
781
- requiredMessage: message
782
- }
783
- })
784
- })
785
- })
791
+ 'Field name "',
792
+ attemptedName,
793
+ '" already exists. Please use a unique name.'
786
794
  ]
787
795
  })
788
- })
789
- ]
790
- });
791
- }
792
- function FormDesigner() {
793
- const [formTitle, setFormTitle] = useState('My Custom Form');
794
- const [formDescription, setFormDescription] = useState('');
795
- const [sections, setSections] = useState([
796
- {
797
- id: 'section-1',
798
- title: 'General Information',
799
- collapsible: false,
800
- defaultExpanded: true,
801
- fields: [
802
- {
803
- id: '1',
804
- name: 'fullName',
805
- type: 'text',
806
- label: 'Full Name',
807
- placeholder: 'Enter your name'
808
- }
809
796
  ]
810
- }
811
- ]);
812
- const [selectedSectionId, setSelectedSectionId] = useState('section-1');
813
- const [selectedFieldId, setSelectedFieldId] = useState('1');
814
- const [expandedSections, setExpandedSections] = useState([
815
- 'section-1'
816
- ]);
817
- const [previewDisabled, setPreviewDisabled] = useState(false);
818
- const allFields = sections.flatMap((s)=>s.fields);
819
- const selectedSection = sections.find((s)=>s.id === selectedSectionId);
820
- const selectedField = allFields.find((f)=>f.id === selectedFieldId);
821
- const generatedSchema = {
822
- id: 'custom-form',
823
- title: formTitle,
824
- description: formDescription || void 0,
825
- mode: 'onChange',
826
- reValidateMode: 'onChange',
827
- sections: sections.map((section)=>({
828
- id: section.id,
829
- title: section.title,
830
- description: section.description,
831
- collapsible: section.collapsible,
832
- defaultExpanded: section.defaultExpanded,
833
- fields: section.fields.map((field)=>{
834
- const { id: _id, validation: _validationConfig, ...fieldMeta } = field;
835
- const validationConfig = buildValidationConfig(field);
836
- return {
837
- ...fieldMeta,
838
- validation: validationConfig
839
- };
840
- })
841
- }))
842
- };
843
- const addSection = ()=>{
844
- const newSection = {
845
- id: `section-${Date.now()}`,
846
- title: `Section ${sections.length + 1}`,
847
- collapsible: true,
848
- defaultExpanded: true,
849
- fields: []
850
- };
851
- setSections([
852
- ...sections,
853
- newSection
854
- ]);
855
- setSelectedSectionId(newSection.id);
856
- setSelectedFieldId(null);
857
- setExpandedSections([
858
- ...expandedSections,
859
- newSection.id
860
- ]);
861
- };
862
- const removeSection = (id)=>{
863
- if (sections.length <= 1) return;
864
- setSections(sections.filter((s)=>s.id !== id));
865
- setExpandedSections(expandedSections.filter((sId)=>sId !== id));
866
- if (selectedSectionId === id) {
867
- setSelectedSectionId(sections[0]?.id || null);
868
- setSelectedFieldId(null);
869
- }
870
- };
871
- const updateSection = (id, updates)=>{
872
- let finalUpdates = updates;
873
- if (updates.id && updates.id !== id) {
874
- const idExists = sections.some((s)=>s.id === updates.id);
875
- if (idExists) {
876
- const { id: _id, ...rest } = updates;
877
- finalUpdates = rest;
878
- }
879
- }
880
- setSections(sections.map((s)=>s.id === id ? {
881
- ...s,
882
- ...finalUpdates
883
- } : s));
884
- if (finalUpdates.id && finalUpdates.id !== id) {
885
- if (selectedSectionId === id) setSelectedSectionId(finalUpdates.id);
886
- setExpandedSections(expandedSections.map((sId)=>sId === id ? finalUpdates.id : sId));
887
- }
888
- };
889
- const moveSection = (id, direction)=>{
890
- const index = sections.findIndex((s)=>s.id === id);
891
- if (-1 === index) return;
892
- const newSections = [
893
- ...sections
894
- ];
895
- if ('up' === direction && index > 0) [newSections[index - 1], newSections[index]] = [
896
- newSections[index],
897
- newSections[index - 1]
898
- ];
899
- else if ('down' === direction && index < sections.length - 1) [newSections[index], newSections[index + 1]] = [
900
- newSections[index + 1],
901
- newSections[index]
902
- ];
903
- setSections(newSections);
904
- };
905
- const addField = (sectionId)=>{
906
- const section = sections.find((s)=>s.id === sectionId);
907
- if (!section) return;
908
- const newField = {
909
- id: Date.now().toString(),
910
- name: `field_${allFields.length + 1}`,
911
- type: 'text',
912
- label: `Field ${allFields.length + 1}`
913
- };
914
- setSections(sections.map((s)=>s.id === sectionId ? {
915
- ...s,
916
- fields: [
917
- ...s.fields,
918
- newField
919
- ]
920
- } : s));
921
- setSelectedSectionId(sectionId);
922
- setSelectedFieldId(newField.id);
923
- };
924
- const removeField = (sectionId, fieldId)=>{
925
- setSections(sections.map((s)=>s.id === sectionId ? {
926
- ...s,
927
- fields: s.fields.filter((f)=>f.id !== fieldId)
928
- } : s));
929
- if (selectedFieldId === fieldId) {
930
- const section = sections.find((s)=>s.id === sectionId);
931
- setSelectedFieldId(section?.fields[0]?.id || null);
932
- }
933
- };
934
- const updateField = (fieldId, updates)=>{
935
- setSections((prevSections)=>{
936
- const prevAllFields = prevSections.flatMap((s)=>s.fields);
937
- let finalUpdates = updates;
938
- if (updates.name) {
939
- const currentField = prevAllFields.find((f)=>f.id === fieldId);
940
- if (currentField && updates.name !== currentField.name) {
941
- const nameExists = prevAllFields.some((f)=>f.id !== fieldId && f.name === updates.name);
942
- if (nameExists) {
943
- const { name: _name, ...rest } = updates;
944
- finalUpdates = rest;
945
- }
946
- }
947
- }
948
- return prevSections.map((s)=>({
949
- ...s,
950
- fields: s.fields.map((f)=>f.id === fieldId ? {
951
- ...f,
952
- ...finalUpdates
953
- } : f)
954
- }));
955
797
  });
956
- };
957
- const moveField = (sectionId, fieldId, direction)=>{
958
- const section = sections.find((s)=>s.id === sectionId);
959
- if (!section) return;
960
- const index = section.fields.findIndex((f)=>f.id === fieldId);
961
- if (-1 === index) return;
962
- const newFields = [
963
- ...section.fields
964
- ];
965
- if ('up' === direction && index > 0) [newFields[index - 1], newFields[index]] = [
966
- newFields[index],
967
- newFields[index - 1]
968
- ];
969
- else if ('down' === direction && index < newFields.length - 1) [newFields[index], newFields[index + 1]] = [
970
- newFields[index + 1],
971
- newFields[index]
972
- ];
973
- setSections(sections.map((s)=>s.id === sectionId ? {
974
- ...s,
975
- fields: newFields
976
- } : s));
977
- };
978
- return /*#__PURE__*/ jsxs(Grid, {
979
- gap: 3,
980
- h: "screen",
981
- p: 3,
982
- className: "lg:grid-cols-[2fr_3fr_3fr]",
983
- children: [
984
- /*#__PURE__*/ jsxs(Card, {
985
- className: "overflow-hidden flex flex-col",
798
+ $[16] = attemptedName;
799
+ $[17] = isDuplicateName;
800
+ $[18] = t9;
801
+ } else t9 = $[18];
802
+ let t10;
803
+ if ($[19] !== field.id || $[20] !== plugins || $[21] !== schema) {
804
+ t10 = /*#__PURE__*/ jsx(MetadataForm, {
805
+ schema: schema,
806
+ plugins: plugins,
807
+ autoComplete: "off"
808
+ }, field.id);
809
+ $[19] = field.id;
810
+ $[20] = plugins;
811
+ $[21] = schema;
812
+ $[22] = t10;
813
+ } else t10 = $[22];
814
+ let t11;
815
+ if ($[23] !== field.options || $[24] !== needsOptions || $[25] !== onUpdate) {
816
+ t11 = needsOptions && /*#__PURE__*/ jsx(Accordion, {
817
+ type: "multiple",
818
+ defaultValue: [
819
+ "options"
820
+ ],
821
+ children: /*#__PURE__*/ jsxs(AccordionItem, {
822
+ value: "options",
823
+ className: "border rounded-lg px-3",
986
824
  children: [
987
- /*#__PURE__*/ jsx(CardHeader, {
825
+ /*#__PURE__*/ jsx(AccordionTrigger, {
826
+ className: "text-sm font-medium",
988
827
  children: /*#__PURE__*/ jsxs("div", {
989
- className: "flex items-center justify-between",
828
+ className: "flex items-center gap-2",
990
829
  children: [
991
- /*#__PURE__*/ jsxs("div", {
992
- children: [
993
- /*#__PURE__*/ jsxs(CardTitle, {
994
- className: "flex items-center gap-2",
995
- children: [
996
- /*#__PURE__*/ jsx(Layers, {
997
- className: "h-4 w-4"
998
- }),
999
- "Sections"
1000
- ]
1001
- }),
1002
- /*#__PURE__*/ jsx(CardDescription, {
1003
- children: "Organize fields into sections"
1004
- })
1005
- ]
830
+ /*#__PURE__*/ jsx(Database, {
831
+ className: "h-4 w-4"
1006
832
  }),
1007
- /*#__PURE__*/ jsxs(Button, {
1008
- onClick: addSection,
1009
- variant: "outline",
1010
- size: "sm",
1011
- children: [
1012
- /*#__PURE__*/ jsx(Plus, {
1013
- className: "h-3 w-3 mr-1"
1014
- }),
1015
- "Section"
1016
- ]
1017
- })
833
+ "Options"
1018
834
  ]
1019
835
  })
1020
836
  }),
1021
- /*#__PURE__*/ jsx(CardContent, {
1022
- className: "flex-1 overflow-auto px-2 pb-2",
1023
- children: /*#__PURE__*/ jsx(Accordion, {
1024
- type: "multiple",
1025
- value: expandedSections,
1026
- onValueChange: setExpandedSections,
1027
- className: "space-y-1",
1028
- children: sections.map((section, sectionIndex)=>/*#__PURE__*/ jsxs(AccordionItem, {
1029
- value: section.id,
1030
- className: `group/section border rounded-lg ${selectedSectionId === section.id && !selectedFieldId ? 'ring-2 ring-primary' : ''}`,
1031
- children: [
1032
- /*#__PURE__*/ jsxs("div", {
1033
- className: "flex items-center gap-1 px-2 py-1.5",
1034
- children: [
1035
- /*#__PURE__*/ jsx(AccordionTrigger, {
1036
- className: "h-5 w-5 p-0 hover:no-underline hover:bg-accent rounded [&>svg]:hidden flex items-center justify-center shrink-0",
1037
- children: /*#__PURE__*/ jsx("span", {
1038
- className: "flex items-center justify-center",
1039
- children: /*#__PURE__*/ jsx(ChevronRight, {
1040
- className: "h-3 w-3 shrink-0 transition-transform duration-200 group-data-[state=open]/section:rotate-90"
1041
- })
1042
- })
1043
- }),
1044
- /*#__PURE__*/ jsxs("div", {
1045
- className: "flex-1 min-w-0 cursor-pointer flex items-center gap-1",
1046
- onClick: ()=>{
1047
- setSelectedSectionId(section.id);
1048
- setSelectedFieldId(null);
1049
- },
1050
- children: [
1051
- /*#__PURE__*/ jsx("span", {
1052
- className: "text-sm font-medium truncate",
1053
- children: section.title
1054
- }),
1055
- section.collapsible && /*#__PURE__*/ jsx("span", {
1056
- className: "text-[10px] text-muted-foreground",
1057
- children: "(collapsible)"
1058
- })
1059
- ]
1060
- }),
1061
- /*#__PURE__*/ jsxs("div", {
1062
- className: "flex gap-0.5 opacity-0 group-hover/section:opacity-100 transition-opacity",
1063
- children: [
1064
- /*#__PURE__*/ jsx(Button, {
1065
- variant: "ghost",
1066
- size: "sm",
1067
- className: "h-5 w-5 p-0",
1068
- onClick: (e)=>{
1069
- e.stopPropagation();
1070
- moveSection(section.id, 'up');
1071
- },
1072
- disabled: 0 === sectionIndex,
1073
- children: /*#__PURE__*/ jsx(MoveUp, {
1074
- className: "h-2.5 w-2.5"
1075
- })
1076
- }),
1077
- /*#__PURE__*/ jsx(Button, {
1078
- variant: "ghost",
1079
- size: "sm",
1080
- className: "h-5 w-5 p-0",
1081
- onClick: (e)=>{
1082
- e.stopPropagation();
1083
- moveSection(section.id, 'down');
1084
- },
1085
- disabled: sectionIndex === sections.length - 1,
1086
- children: /*#__PURE__*/ jsx(MoveDown, {
1087
- className: "h-2.5 w-2.5"
1088
- })
1089
- }),
1090
- /*#__PURE__*/ jsx(Button, {
1091
- variant: "ghost",
1092
- size: "sm",
1093
- className: "h-5 w-5 p-0",
1094
- onClick: (e)=>{
1095
- e.stopPropagation();
1096
- removeSection(section.id);
1097
- },
1098
- disabled: sections.length <= 1,
1099
- children: /*#__PURE__*/ jsx(Trash2, {
1100
- className: "h-2.5 w-2.5 text-destructive"
1101
- })
1102
- })
1103
- ]
1104
- })
1105
- ]
1106
- }),
1107
- /*#__PURE__*/ jsx(AccordionContent, {
1108
- className: "px-2 pb-2 pt-0",
1109
- children: /*#__PURE__*/ jsxs("div", {
1110
- className: "space-y-0.5 ml-3 border-l pl-2",
1111
- children: [
1112
- section.fields.map((field, fieldIndex)=>/*#__PURE__*/ jsxs("div", {
1113
- className: `group/field flex items-center gap-1 px-2 py-1 rounded cursor-pointer hover:bg-accent transition-colors ${selectedFieldId === field.id ? 'bg-accent' : ''}`,
1114
- onClick: ()=>{
1115
- setSelectedSectionId(section.id);
1116
- setSelectedFieldId(field.id);
1117
- },
1118
- children: [
1119
- /*#__PURE__*/ jsx(GripVertical, {
1120
- className: "h-3 w-3 text-muted-foreground opacity-0 group-hover/field:opacity-50"
1121
- }),
1122
- /*#__PURE__*/ jsxs("div", {
1123
- className: "flex-1 min-w-0",
1124
- children: [
1125
- /*#__PURE__*/ jsxs("div", {
1126
- className: "flex items-center gap-1",
1127
- children: [
1128
- /*#__PURE__*/ jsx("span", {
1129
- className: "text-xs font-medium truncate",
1130
- children: field.label
1131
- }),
1132
- field.rules?.some((r)=>r.effects.required) && /*#__PURE__*/ jsx("span", {
1133
- className: "text-[10px] text-destructive",
1134
- children: "*"
1135
- })
1136
- ]
1137
- }),
1138
- /*#__PURE__*/ jsx("div", {
1139
- className: "text-[9px] text-muted-foreground",
1140
- children: field.type
1141
- })
1142
- ]
1143
- }),
1144
- /*#__PURE__*/ jsxs("div", {
1145
- className: "flex gap-0.5 opacity-0 group-hover/field:opacity-100 transition-opacity",
1146
- children: [
1147
- /*#__PURE__*/ jsx(Button, {
1148
- variant: "ghost",
1149
- size: "sm",
1150
- className: "h-5 w-5 p-0",
1151
- onClick: (e)=>{
1152
- e.stopPropagation();
1153
- moveField(section.id, field.id, 'up');
1154
- },
1155
- disabled: 0 === fieldIndex,
1156
- children: /*#__PURE__*/ jsx(MoveUp, {
1157
- className: "h-2.5 w-2.5"
1158
- })
1159
- }),
1160
- /*#__PURE__*/ jsx(Button, {
1161
- variant: "ghost",
1162
- size: "sm",
1163
- className: "h-5 w-5 p-0",
1164
- onClick: (e)=>{
1165
- e.stopPropagation();
1166
- moveField(section.id, field.id, 'down');
1167
- },
1168
- disabled: fieldIndex === section.fields.length - 1,
1169
- children: /*#__PURE__*/ jsx(MoveDown, {
1170
- className: "h-2.5 w-2.5"
1171
- })
1172
- }),
1173
- /*#__PURE__*/ jsx(Button, {
1174
- variant: "ghost",
1175
- size: "sm",
1176
- className: "h-5 w-5 p-0",
1177
- onClick: (e)=>{
1178
- e.stopPropagation();
1179
- removeField(section.id, field.id);
1180
- },
1181
- children: /*#__PURE__*/ jsx(Trash2, {
1182
- className: "h-2.5 w-2.5 text-destructive"
1183
- })
1184
- })
1185
- ]
1186
- })
1187
- ]
1188
- }, field.id)),
1189
- /*#__PURE__*/ jsxs(Button, {
1190
- onClick: ()=>addField(section.id),
1191
- variant: "outline",
1192
- size: "sm",
1193
- children: [
1194
- /*#__PURE__*/ jsx(Plus, {
1195
- className: "h-3 w-3 mr-1"
1196
- }),
1197
- "Field"
1198
- ]
1199
- })
1200
- ]
1201
- })
1202
- })
1203
- ]
1204
- }, section.id))
837
+ /*#__PURE__*/ jsx(AccordionContent, {
838
+ className: "pt-2",
839
+ children: /*#__PURE__*/ jsx(FieldOptionsEditor, {
840
+ options: field.options || [],
841
+ onChange: (options)=>onUpdate({
842
+ options
843
+ })
1205
844
  })
1206
845
  })
1207
846
  ]
1208
- }),
1209
- /*#__PURE__*/ jsxs(Card, {
1210
- className: "overflow-hidden flex flex-col",
847
+ })
848
+ });
849
+ $[23] = field.options;
850
+ $[24] = needsOptions;
851
+ $[25] = onUpdate;
852
+ $[26] = t11;
853
+ } else t11 = $[26];
854
+ let t12;
855
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
856
+ t12 = [
857
+ "data-source"
858
+ ];
859
+ $[27] = t12;
860
+ } else t12 = $[27];
861
+ let t13;
862
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
863
+ t13 = /*#__PURE__*/ jsx(AccordionTrigger, {
864
+ className: "text-sm font-medium",
865
+ children: /*#__PURE__*/ jsxs("div", {
866
+ className: "flex items-center gap-2",
1211
867
  children: [
1212
- /*#__PURE__*/ jsxs(CardHeader, {
1213
- children: [
1214
- /*#__PURE__*/ jsxs(CardTitle, {
1215
- className: "flex items-center gap-2",
1216
- children: [
1217
- /*#__PURE__*/ jsx(Settings, {
1218
- className: "h-4 w-4"
1219
- }),
1220
- selectedFieldId ? 'Field configuration' : selectedSectionId ? 'Section configuration' : 'Configuration'
1221
- ]
1222
- }),
1223
- /*#__PURE__*/ jsx(CardDescription, {
1224
- children: selectedField ? `Configure "${selectedField.label}"` : selectedSection ? `Configure "${selectedSection.title}" section` : 'Select a section or field to configure'
1225
- })
1226
- ]
868
+ /*#__PURE__*/ jsx(Database, {
869
+ className: "h-4 w-4"
1227
870
  }),
1228
- /*#__PURE__*/ jsx(CardContent, {
1229
- className: "flex-1 overflow-auto",
1230
- children: selectedField ? /*#__PURE__*/ jsx(FieldConfigForm, {
1231
- field: selectedField,
1232
- onUpdate: (updates)=>updateField(selectedField.id, updates),
1233
- allFields: allFields,
1234
- existingFieldNames: new Set(allFields.map((f)=>f.name))
1235
- }) : selectedSection ? /*#__PURE__*/ jsx(SectionConfigForm, {
1236
- section: selectedSection,
1237
- onUpdate: (updates)=>updateSection(selectedSection.id, updates),
1238
- existingSectionIds: new Set(sections.map((s)=>s.id))
1239
- }) : /*#__PURE__*/ jsx("div", {
1240
- className: "flex items-center justify-center h-full text-muted-foreground",
1241
- children: "Select a section or field to configure"
871
+ "Data source"
872
+ ]
873
+ })
874
+ });
875
+ $[28] = t13;
876
+ } else t13 = $[28];
877
+ let t14;
878
+ if ($[29] !== onUpdate) {
879
+ t14 = (dataSource)=>onUpdate({
880
+ dataSource
881
+ });
882
+ $[29] = onUpdate;
883
+ $[30] = t14;
884
+ } else t14 = $[30];
885
+ let t15;
886
+ if ($[31] !== field.dataSource || $[32] !== t14) {
887
+ t15 = /*#__PURE__*/ jsx(Accordion, {
888
+ type: "multiple",
889
+ defaultValue: t12,
890
+ children: /*#__PURE__*/ jsxs(AccordionItem, {
891
+ value: "data-source",
892
+ className: "border rounded-lg px-3",
893
+ children: [
894
+ t13,
895
+ /*#__PURE__*/ jsx(AccordionContent, {
896
+ className: "pt-2",
897
+ children: /*#__PURE__*/ jsx(DataSourceEditor, {
898
+ dataSource: field.dataSource,
899
+ onChange: t14
1242
900
  })
1243
901
  })
1244
902
  ]
1245
- }),
1246
- /*#__PURE__*/ jsxs(Card, {
1247
- className: "overflow-hidden flex flex-col",
903
+ })
904
+ });
905
+ $[31] = field.dataSource;
906
+ $[32] = t14;
907
+ $[33] = t15;
908
+ } else t15 = $[33];
909
+ let t16;
910
+ if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
911
+ t16 = [
912
+ "rules"
913
+ ];
914
+ $[34] = t16;
915
+ } else t16 = $[34];
916
+ let t17;
917
+ if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
918
+ t17 = /*#__PURE__*/ jsx(AccordionTrigger, {
919
+ className: "text-sm font-medium",
920
+ children: /*#__PURE__*/ jsxs("div", {
921
+ className: "flex items-center gap-2",
1248
922
  children: [
1249
- /*#__PURE__*/ jsx(CardHeader, {
1250
- children: /*#__PURE__*/ jsxs("div", {
1251
- className: "space-y-4",
1252
- children: [
1253
- /*#__PURE__*/ jsxs("div", {
1254
- children: [
1255
- /*#__PURE__*/ jsxs(CardTitle, {
1256
- className: "flex items-center gap-2",
1257
- children: [
1258
- /*#__PURE__*/ jsx(View, {
1259
- className: "h-4 w-4"
1260
- }),
1261
- "Preview & export"
1262
- ]
1263
- }),
1264
- /*#__PURE__*/ jsx(CardDescription, {
1265
- children: "See how your form looks"
1266
- })
1267
- ]
1268
- }),
1269
- /*#__PURE__*/ jsxs("div", {
1270
- className: "space-y-2",
1271
- children: [
1272
- /*#__PURE__*/ jsx(Label, {
1273
- htmlFor: "form-title",
1274
- children: "Form title"
1275
- }),
1276
- /*#__PURE__*/ jsx(Input, {
1277
- id: "form-title",
1278
- value: formTitle,
1279
- onChange: (e)=>setFormTitle(e.target.value)
1280
- })
1281
- ]
1282
- }),
1283
- /*#__PURE__*/ jsxs("div", {
1284
- className: "space-y-2",
1285
- children: [
1286
- /*#__PURE__*/ jsx(Label, {
1287
- htmlFor: "form-description",
1288
- children: "Form description"
1289
- }),
1290
- /*#__PURE__*/ jsx(Textarea, {
1291
- id: "form-description",
1292
- value: formDescription,
1293
- onChange: (e)=>setFormDescription(e.target.value),
1294
- placeholder: "Optional description",
1295
- rows: 2
1296
- })
1297
- ]
1298
- })
1299
- ]
1300
- })
923
+ /*#__PURE__*/ jsx(GitBranch, {
924
+ className: "h-4 w-4"
1301
925
  }),
1302
- /*#__PURE__*/ jsx(CardContent, {
1303
- className: "flex-1 overflow-auto",
1304
- children: /*#__PURE__*/ jsxs(Tabs, {
1305
- defaultValue: "preview",
1306
- className: "h-full flex flex-col",
1307
- children: [
1308
- /*#__PURE__*/ jsxs(TabsList, {
1309
- className: "grid w-full grid-cols-2",
1310
- children: [
1311
- /*#__PURE__*/ jsxs(TabsTrigger, {
1312
- value: "preview",
1313
- children: [
1314
- /*#__PURE__*/ jsx(Eye, {
1315
- className: "h-4 w-4 mr-2"
1316
- }),
1317
- "Preview"
1318
- ]
1319
- }),
1320
- /*#__PURE__*/ jsxs(TabsTrigger, {
1321
- value: "code",
1322
- children: [
1323
- /*#__PURE__*/ jsx(Code, {
1324
- className: "h-4 w-4 mr-2"
1325
- }),
1326
- "Schema"
1327
- ]
1328
- })
1329
- ]
1330
- }),
1331
- /*#__PURE__*/ jsxs(TabsContent, {
1332
- value: "preview",
1333
- className: "flex-1 overflow-auto",
1334
- children: [
1335
- /*#__PURE__*/ jsxs("div", {
1336
- className: "flex items-center justify-end gap-2 mb-4 pb-2 border-b",
1337
- children: [
1338
- /*#__PURE__*/ jsx(Label, {
1339
- htmlFor: "preview-readonly",
1340
- className: "text-sm text-muted-foreground",
1341
- children: "Readonly"
1342
- }),
1343
- /*#__PURE__*/ jsx(Switch, {
1344
- id: "preview-readonly",
1345
- checked: previewDisabled,
1346
- onCheckedChange: setPreviewDisabled
1347
- })
1348
- ]
1349
- }),
1350
- /*#__PURE__*/ jsx(MetadataForm, {
1351
- schema: generatedSchema,
1352
- onSubmit: (data)=>{
1353
- console.log('Form submitted:', data);
1354
- alert('Form submitted! Check console for data.');
1355
- },
1356
- disabled: previewDisabled,
1357
- autoComplete: "off"
1358
- }, sections.map((s)=>`${s.id}:${s.collapsible}:${s.defaultExpanded}:${s.fields.map((f)=>`${f.id}:${f.type}:${f.name}:${JSON.stringify(f.rules || [])}:${JSON.stringify(f.validation || {})}`).join('-')}`).join(','))
1359
- ]
1360
- }),
1361
- /*#__PURE__*/ jsx(TabsContent, {
1362
- value: "code",
1363
- className: "flex-1 overflow-auto",
1364
- children: /*#__PURE__*/ jsx("pre", {
1365
- className: "text-xs bg-muted p-4 rounded-lg overflow-auto max-h-full",
1366
- children: schemaToJson(generatedSchema)
1367
- })
1368
- })
1369
- ]
926
+ "Rules & conditions"
927
+ ]
928
+ })
929
+ });
930
+ $[35] = t17;
931
+ } else t17 = $[35];
932
+ let t18;
933
+ if ($[36] !== onUpdate) {
934
+ t18 = (rules)=>onUpdate({
935
+ rules
936
+ });
937
+ $[36] = onUpdate;
938
+ $[37] = t18;
939
+ } else t18 = $[37];
940
+ const t19 = field.validation?.requiredMessage;
941
+ let t20;
942
+ if ($[38] !== field.validation || $[39] !== onUpdate) {
943
+ t20 = (message)=>onUpdate({
944
+ validation: {
945
+ ...field.validation,
946
+ requiredMessage: message
947
+ }
948
+ });
949
+ $[38] = field.validation;
950
+ $[39] = onUpdate;
951
+ $[40] = t20;
952
+ } else t20 = $[40];
953
+ let t21;
954
+ if ($[41] !== allFields || $[42] !== field.rules || $[43] !== t18 || $[44] !== t19 || $[45] !== t20) {
955
+ t21 = /*#__PURE__*/ jsx(Accordion, {
956
+ type: "multiple",
957
+ defaultValue: t16,
958
+ children: /*#__PURE__*/ jsxs(AccordionItem, {
959
+ value: "rules",
960
+ className: "border rounded-lg px-3",
961
+ children: [
962
+ t17,
963
+ /*#__PURE__*/ jsx(AccordionContent, {
964
+ className: "pt-2",
965
+ children: /*#__PURE__*/ jsx(RulesEditor, {
966
+ rules: field.rules,
967
+ onChange: t18,
968
+ allFields: allFields,
969
+ requiredMessage: t19,
970
+ onRequiredMessageChange: t20
1370
971
  })
1371
972
  })
1372
973
  ]
1373
974
  })
1374
- ]
1375
- });
975
+ });
976
+ $[41] = allFields;
977
+ $[42] = field.rules;
978
+ $[43] = t18;
979
+ $[44] = t19;
980
+ $[45] = t20;
981
+ $[46] = t21;
982
+ } else t21 = $[46];
983
+ let t22;
984
+ if ($[47] !== t10 || $[48] !== t11 || $[49] !== t15 || $[50] !== t21 || $[51] !== t9) {
985
+ t22 = /*#__PURE__*/ jsxs("div", {
986
+ className: "space-y-2",
987
+ children: [
988
+ t9,
989
+ t10,
990
+ t11,
991
+ t15,
992
+ t21
993
+ ]
994
+ });
995
+ $[47] = t10;
996
+ $[48] = t11;
997
+ $[49] = t15;
998
+ $[50] = t21;
999
+ $[51] = t9;
1000
+ $[52] = t22;
1001
+ } else t22 = $[52];
1002
+ return t22;
1376
1003
  }
1377
- function FieldOptionsEditor({ options, onChange }) {
1378
- const addOption = ()=>{
1379
- onChange([
1380
- ...options,
1004
+ function FormDesigner() {
1005
+ const $ = compiler_runtime_c(143);
1006
+ const [formTitle, setFormTitle] = useState("My Custom Form");
1007
+ const [formDescription, setFormDescription] = useState("");
1008
+ let t0;
1009
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1010
+ t0 = [
1381
1011
  {
1382
- label: `Option ${options.length + 1}`,
1383
- value: `option${options.length + 1}`
1012
+ id: "section-1",
1013
+ title: "General Information",
1014
+ collapsible: false,
1015
+ defaultExpanded: true,
1016
+ fields: [
1017
+ {
1018
+ id: "1",
1019
+ name: "fullName",
1020
+ type: "text",
1021
+ label: "Full Name",
1022
+ placeholder: "Enter your name"
1023
+ }
1024
+ ]
1384
1025
  }
1385
- ]);
1386
- };
1387
- const updateOption = (index, updates)=>{
1388
- const newOptions = [
1389
- ...options
1390
1026
  ];
1391
- newOptions[index] = {
1392
- ...newOptions[index],
1393
- ...updates
1027
+ $[0] = t0;
1028
+ } else t0 = $[0];
1029
+ const [sections, setSections] = useState(t0);
1030
+ const [selectedSectionId, setSelectedSectionId] = useState("section-1");
1031
+ const [selectedFieldId, setSelectedFieldId] = useState("1");
1032
+ let t1;
1033
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
1034
+ t1 = [
1035
+ "section-1"
1036
+ ];
1037
+ $[1] = t1;
1038
+ } else t1 = $[1];
1039
+ const [expandedSections, setExpandedSections] = useState(t1);
1040
+ const [previewDisabled, setPreviewDisabled] = useState(false);
1041
+ let T0;
1042
+ let T1;
1043
+ let T2;
1044
+ let generatedSchema;
1045
+ let t10;
1046
+ let t2;
1047
+ let t3;
1048
+ let t4;
1049
+ let t5;
1050
+ let t6;
1051
+ let t7;
1052
+ let t8;
1053
+ let t9;
1054
+ if ($[2] !== expandedSections || $[3] !== formDescription || $[4] !== formTitle || $[5] !== sections || $[6] !== selectedFieldId || $[7] !== selectedSectionId) {
1055
+ const allFields = sections.flatMap(_temp);
1056
+ let t11;
1057
+ if ($[21] !== sections || $[22] !== selectedSectionId) {
1058
+ let t12;
1059
+ if ($[24] !== selectedSectionId) {
1060
+ t12 = (s_0)=>s_0.id === selectedSectionId;
1061
+ $[24] = selectedSectionId;
1062
+ $[25] = t12;
1063
+ } else t12 = $[25];
1064
+ t11 = sections.find(t12);
1065
+ $[21] = sections;
1066
+ $[22] = selectedSectionId;
1067
+ $[23] = t11;
1068
+ } else t11 = $[23];
1069
+ const selectedSection = t11;
1070
+ let t12;
1071
+ if ($[26] !== selectedFieldId) {
1072
+ t12 = (f)=>f.id === selectedFieldId;
1073
+ $[26] = selectedFieldId;
1074
+ $[27] = t12;
1075
+ } else t12 = $[27];
1076
+ const selectedField = allFields.find(t12);
1077
+ const t13 = formDescription || void 0;
1078
+ let t14;
1079
+ if ($[28] !== sections) {
1080
+ t14 = sections.map(_temp3);
1081
+ $[28] = sections;
1082
+ $[29] = t14;
1083
+ } else t14 = $[29];
1084
+ let t15;
1085
+ if ($[30] !== formTitle || $[31] !== t13 || $[32] !== t14) {
1086
+ t15 = {
1087
+ id: "custom-form",
1088
+ title: formTitle,
1089
+ description: t13,
1090
+ mode: "onChange",
1091
+ reValidateMode: "onChange",
1092
+ sections: t14
1093
+ };
1094
+ $[30] = formTitle;
1095
+ $[31] = t13;
1096
+ $[32] = t14;
1097
+ $[33] = t15;
1098
+ } else t15 = $[33];
1099
+ generatedSchema = t15;
1100
+ let t16;
1101
+ if ($[34] !== expandedSections || $[35] !== sections) {
1102
+ t16 = ()=>{
1103
+ const newSection = {
1104
+ id: `section-${Date.now()}`,
1105
+ title: `Section ${sections.length + 1}`,
1106
+ collapsible: true,
1107
+ defaultExpanded: true,
1108
+ fields: []
1109
+ };
1110
+ setSections([
1111
+ ...sections,
1112
+ newSection
1113
+ ]);
1114
+ setSelectedSectionId(newSection.id);
1115
+ setSelectedFieldId(null);
1116
+ setExpandedSections([
1117
+ ...expandedSections,
1118
+ newSection.id
1119
+ ]);
1120
+ };
1121
+ $[34] = expandedSections;
1122
+ $[35] = sections;
1123
+ $[36] = t16;
1124
+ } else t16 = $[36];
1125
+ const addSection = t16;
1126
+ let t17;
1127
+ if ($[37] !== expandedSections || $[38] !== sections || $[39] !== selectedSectionId) {
1128
+ t17 = (id)=>{
1129
+ if (sections.length <= 1) return;
1130
+ setSections(sections.filter((s_1)=>s_1.id !== id));
1131
+ setExpandedSections(expandedSections.filter((sId)=>sId !== id));
1132
+ if (selectedSectionId === id) {
1133
+ setSelectedSectionId(sections[0]?.id || null);
1134
+ setSelectedFieldId(null);
1135
+ }
1136
+ };
1137
+ $[37] = expandedSections;
1138
+ $[38] = sections;
1139
+ $[39] = selectedSectionId;
1140
+ $[40] = t17;
1141
+ } else t17 = $[40];
1142
+ const removeSection = t17;
1143
+ let t18;
1144
+ if ($[41] !== expandedSections || $[42] !== sections || $[43] !== selectedSectionId) {
1145
+ t18 = (id_0, updates)=>{
1146
+ let finalUpdates = updates;
1147
+ if (updates.id && updates.id !== id_0) {
1148
+ const idExists = sections.some((s_2)=>s_2.id === updates.id);
1149
+ if (idExists) {
1150
+ const { id: _id_0, ...rest } = updates;
1151
+ finalUpdates = rest;
1152
+ }
1153
+ }
1154
+ setSections(sections.map((s_3)=>s_3.id === id_0 ? {
1155
+ ...s_3,
1156
+ ...finalUpdates
1157
+ } : s_3));
1158
+ if (finalUpdates.id && finalUpdates.id !== id_0) {
1159
+ if (selectedSectionId === id_0) setSelectedSectionId(finalUpdates.id);
1160
+ setExpandedSections(expandedSections.map((sId_0)=>sId_0 === id_0 ? finalUpdates.id : sId_0));
1161
+ }
1162
+ };
1163
+ $[41] = expandedSections;
1164
+ $[42] = sections;
1165
+ $[43] = selectedSectionId;
1166
+ $[44] = t18;
1167
+ } else t18 = $[44];
1168
+ const updateSection = t18;
1169
+ let t19;
1170
+ if ($[45] !== sections) {
1171
+ t19 = (id_1, direction)=>{
1172
+ const index = sections.findIndex((s_4)=>s_4.id === id_1);
1173
+ if (-1 === index) return;
1174
+ const newSections = [
1175
+ ...sections
1176
+ ];
1177
+ if ("up" === direction && index > 0) {
1178
+ const [t20, t21] = [
1179
+ newSections[index],
1180
+ newSections[index - 1]
1181
+ ];
1182
+ newSections[index - 1] = t20;
1183
+ newSections[index] = t21;
1184
+ } else if ("down" === direction && index < sections.length - 1) {
1185
+ const [t22, t23] = [
1186
+ newSections[index + 1],
1187
+ newSections[index]
1188
+ ];
1189
+ newSections[index] = t22;
1190
+ newSections[index + 1] = t23;
1191
+ }
1192
+ setSections(newSections);
1193
+ };
1194
+ $[45] = sections;
1195
+ $[46] = t19;
1196
+ } else t19 = $[46];
1197
+ const moveSection = t19;
1198
+ const addField = (sectionId)=>{
1199
+ const section_0 = sections.find((s_5)=>s_5.id === sectionId);
1200
+ if (!section_0) return;
1201
+ const newField = {
1202
+ id: Date.now().toString(),
1203
+ name: `field_${allFields.length + 1}`,
1204
+ type: "text",
1205
+ label: `Field ${allFields.length + 1}`
1206
+ };
1207
+ setSections(sections.map((s_6)=>s_6.id === sectionId ? {
1208
+ ...s_6,
1209
+ fields: [
1210
+ ...s_6.fields,
1211
+ newField
1212
+ ]
1213
+ } : s_6));
1214
+ setSelectedSectionId(sectionId);
1215
+ setSelectedFieldId(newField.id);
1394
1216
  };
1395
- onChange(newOptions);
1217
+ let t20;
1218
+ if ($[47] !== sections || $[48] !== selectedFieldId) {
1219
+ t20 = (sectionId_0, fieldId)=>{
1220
+ setSections(sections.map((s_7)=>s_7.id === sectionId_0 ? {
1221
+ ...s_7,
1222
+ fields: s_7.fields.filter((f_0)=>f_0.id !== fieldId)
1223
+ } : s_7));
1224
+ if (selectedFieldId === fieldId) {
1225
+ const section_1 = sections.find((s_8)=>s_8.id === sectionId_0);
1226
+ setSelectedFieldId(section_1?.fields[0]?.id || null);
1227
+ }
1228
+ };
1229
+ $[47] = sections;
1230
+ $[48] = selectedFieldId;
1231
+ $[49] = t20;
1232
+ } else t20 = $[49];
1233
+ const removeField = t20;
1234
+ let t21;
1235
+ if ($[50] === Symbol.for("react.memo_cache_sentinel")) {
1236
+ t21 = (fieldId_0, updates_0)=>{
1237
+ setSections((prevSections)=>{
1238
+ const prevAllFields = prevSections.flatMap(_temp4);
1239
+ let finalUpdates_0 = updates_0;
1240
+ if (updates_0.name) {
1241
+ const currentField = prevAllFields.find((f_1)=>f_1.id === fieldId_0);
1242
+ if (currentField && updates_0.name !== currentField.name) {
1243
+ const nameExists = prevAllFields.some((f_2)=>f_2.id !== fieldId_0 && f_2.name === updates_0.name);
1244
+ if (nameExists) {
1245
+ const { name: _name, ...rest_0 } = updates_0;
1246
+ finalUpdates_0 = rest_0;
1247
+ }
1248
+ }
1249
+ }
1250
+ return prevSections.map((s_10)=>({
1251
+ ...s_10,
1252
+ fields: s_10.fields.map((f_3)=>f_3.id === fieldId_0 ? {
1253
+ ...f_3,
1254
+ ...finalUpdates_0
1255
+ } : f_3)
1256
+ }));
1257
+ });
1258
+ };
1259
+ $[50] = t21;
1260
+ } else t21 = $[50];
1261
+ const updateField = t21;
1262
+ let t22;
1263
+ if ($[51] !== sections) {
1264
+ t22 = (sectionId_1, fieldId_1, direction_0)=>{
1265
+ const section_2 = sections.find((s_11)=>s_11.id === sectionId_1);
1266
+ if (!section_2) return;
1267
+ const index_0 = section_2.fields.findIndex((f_4)=>f_4.id === fieldId_1);
1268
+ if (-1 === index_0) return;
1269
+ const newFields = [
1270
+ ...section_2.fields
1271
+ ];
1272
+ if ("up" === direction_0 && index_0 > 0) {
1273
+ const [t23, t24] = [
1274
+ newFields[index_0],
1275
+ newFields[index_0 - 1]
1276
+ ];
1277
+ newFields[index_0 - 1] = t23;
1278
+ newFields[index_0] = t24;
1279
+ } else if ("down" === direction_0 && index_0 < newFields.length - 1) {
1280
+ const [t25, t26] = [
1281
+ newFields[index_0 + 1],
1282
+ newFields[index_0]
1283
+ ];
1284
+ newFields[index_0] = t25;
1285
+ newFields[index_0 + 1] = t26;
1286
+ }
1287
+ setSections(sections.map((s_12)=>s_12.id === sectionId_1 ? {
1288
+ ...s_12,
1289
+ fields: newFields
1290
+ } : s_12));
1291
+ };
1292
+ $[51] = sections;
1293
+ $[52] = t22;
1294
+ } else t22 = $[52];
1295
+ const moveField = t22;
1296
+ T2 = Grid;
1297
+ t6 = 3;
1298
+ t7 = "screen";
1299
+ t8 = 3;
1300
+ t9 = "lg:grid-cols-[2fr_3fr_3fr]";
1301
+ let t23;
1302
+ if ($[53] === Symbol.for("react.memo_cache_sentinel")) {
1303
+ t23 = /*#__PURE__*/ jsxs("div", {
1304
+ children: [
1305
+ /*#__PURE__*/ jsxs(CardTitle, {
1306
+ className: "flex items-center gap-2",
1307
+ children: [
1308
+ /*#__PURE__*/ jsx(Layers, {
1309
+ className: "h-4 w-4"
1310
+ }),
1311
+ "Sections"
1312
+ ]
1313
+ }),
1314
+ /*#__PURE__*/ jsx(CardDescription, {
1315
+ children: "Organize fields into sections"
1316
+ })
1317
+ ]
1318
+ });
1319
+ $[53] = t23;
1320
+ } else t23 = $[53];
1321
+ let t24;
1322
+ if ($[54] === Symbol.for("react.memo_cache_sentinel")) {
1323
+ t24 = /*#__PURE__*/ jsx(Plus, {
1324
+ className: "h-3 w-3 mr-1"
1325
+ });
1326
+ $[54] = t24;
1327
+ } else t24 = $[54];
1328
+ let t25;
1329
+ if ($[55] !== addSection) {
1330
+ t25 = /*#__PURE__*/ jsx(CardHeader, {
1331
+ children: /*#__PURE__*/ jsxs("div", {
1332
+ className: "flex items-center justify-between",
1333
+ children: [
1334
+ t23,
1335
+ /*#__PURE__*/ jsxs(Button, {
1336
+ onClick: addSection,
1337
+ variant: "outline",
1338
+ size: "sm",
1339
+ children: [
1340
+ t24,
1341
+ "Section"
1342
+ ]
1343
+ })
1344
+ ]
1345
+ })
1346
+ });
1347
+ $[55] = addSection;
1348
+ $[56] = t25;
1349
+ } else t25 = $[56];
1350
+ let t26;
1351
+ if ($[57] !== addField || $[58] !== moveField || $[59] !== moveSection || $[60] !== removeField || $[61] !== removeSection || $[62] !== sections || $[63] !== selectedFieldId || $[64] !== selectedSectionId) {
1352
+ let t27;
1353
+ if ($[66] !== addField || $[67] !== moveField || $[68] !== moveSection || $[69] !== removeField || $[70] !== removeSection || $[71] !== sections.length || $[72] !== selectedFieldId || $[73] !== selectedSectionId) {
1354
+ t27 = (section_3, sectionIndex)=>/*#__PURE__*/ jsxs(AccordionItem, {
1355
+ value: section_3.id,
1356
+ className: `group/section border rounded-lg ${selectedSectionId === section_3.id && !selectedFieldId ? "ring-2 ring-primary" : ""}`,
1357
+ children: [
1358
+ /*#__PURE__*/ jsxs("div", {
1359
+ className: "flex items-center gap-1 px-2 py-1.5",
1360
+ children: [
1361
+ /*#__PURE__*/ jsx(AccordionTrigger, {
1362
+ className: "h-5 w-5 p-0 hover:no-underline hover:bg-accent rounded [&>svg]:hidden flex items-center justify-center shrink-0",
1363
+ children: /*#__PURE__*/ jsx("span", {
1364
+ className: "flex items-center justify-center",
1365
+ children: /*#__PURE__*/ jsx(ChevronRight, {
1366
+ className: "h-3 w-3 shrink-0 transition-transform duration-200 group-data-[state=open]/section:rotate-90"
1367
+ })
1368
+ })
1369
+ }),
1370
+ /*#__PURE__*/ jsxs("div", {
1371
+ className: "flex-1 min-w-0 cursor-pointer flex items-center gap-1",
1372
+ onClick: ()=>{
1373
+ setSelectedSectionId(section_3.id);
1374
+ setSelectedFieldId(null);
1375
+ },
1376
+ children: [
1377
+ /*#__PURE__*/ jsx("span", {
1378
+ className: "text-sm font-medium truncate",
1379
+ children: section_3.title
1380
+ }),
1381
+ section_3.collapsible && /*#__PURE__*/ jsx("span", {
1382
+ className: "text-[10px] text-muted-foreground",
1383
+ children: "(collapsible)"
1384
+ })
1385
+ ]
1386
+ }),
1387
+ /*#__PURE__*/ jsxs("div", {
1388
+ className: "flex gap-0.5 opacity-0 group-hover/section:opacity-100 transition-opacity",
1389
+ children: [
1390
+ /*#__PURE__*/ jsx(Button, {
1391
+ variant: "ghost",
1392
+ size: "sm",
1393
+ className: "h-5 w-5 p-0",
1394
+ onClick: (e)=>{
1395
+ e.stopPropagation();
1396
+ moveSection(section_3.id, "up");
1397
+ },
1398
+ disabled: 0 === sectionIndex,
1399
+ children: /*#__PURE__*/ jsx(MoveUp, {
1400
+ className: "h-2.5 w-2.5"
1401
+ })
1402
+ }),
1403
+ /*#__PURE__*/ jsx(Button, {
1404
+ variant: "ghost",
1405
+ size: "sm",
1406
+ className: "h-5 w-5 p-0",
1407
+ onClick: (e_0)=>{
1408
+ e_0.stopPropagation();
1409
+ moveSection(section_3.id, "down");
1410
+ },
1411
+ disabled: sectionIndex === sections.length - 1,
1412
+ children: /*#__PURE__*/ jsx(MoveDown, {
1413
+ className: "h-2.5 w-2.5"
1414
+ })
1415
+ }),
1416
+ /*#__PURE__*/ jsx(Button, {
1417
+ variant: "ghost",
1418
+ size: "sm",
1419
+ className: "h-5 w-5 p-0",
1420
+ onClick: (e_1)=>{
1421
+ e_1.stopPropagation();
1422
+ removeSection(section_3.id);
1423
+ },
1424
+ disabled: sections.length <= 1,
1425
+ children: /*#__PURE__*/ jsx(Trash2, {
1426
+ className: "h-2.5 w-2.5 text-destructive"
1427
+ })
1428
+ })
1429
+ ]
1430
+ })
1431
+ ]
1432
+ }),
1433
+ /*#__PURE__*/ jsx(AccordionContent, {
1434
+ className: "px-2 pb-2 pt-0",
1435
+ children: /*#__PURE__*/ jsxs("div", {
1436
+ className: "space-y-0.5 ml-3 border-l pl-2",
1437
+ children: [
1438
+ section_3.fields.map((field_0, fieldIndex)=>/*#__PURE__*/ jsxs("div", {
1439
+ className: `group/field flex items-center gap-1 px-2 py-1 rounded cursor-pointer hover:bg-accent transition-colors ${selectedFieldId === field_0.id ? "bg-accent" : ""}`,
1440
+ onClick: ()=>{
1441
+ setSelectedSectionId(section_3.id);
1442
+ setSelectedFieldId(field_0.id);
1443
+ },
1444
+ children: [
1445
+ /*#__PURE__*/ jsx(GripVertical, {
1446
+ className: "h-3 w-3 text-muted-foreground opacity-0 group-hover/field:opacity-50"
1447
+ }),
1448
+ /*#__PURE__*/ jsxs("div", {
1449
+ className: "flex-1 min-w-0",
1450
+ children: [
1451
+ /*#__PURE__*/ jsxs("div", {
1452
+ className: "flex items-center gap-1",
1453
+ children: [
1454
+ /*#__PURE__*/ jsx("span", {
1455
+ className: "text-xs font-medium truncate",
1456
+ children: field_0.label
1457
+ }),
1458
+ field_0.rules?.some(_temp5) && /*#__PURE__*/ jsx("span", {
1459
+ className: "text-[10px] text-destructive",
1460
+ children: "*"
1461
+ })
1462
+ ]
1463
+ }),
1464
+ /*#__PURE__*/ jsx("div", {
1465
+ className: "text-[9px] text-muted-foreground",
1466
+ children: field_0.type
1467
+ })
1468
+ ]
1469
+ }),
1470
+ /*#__PURE__*/ jsxs("div", {
1471
+ className: "flex gap-0.5 opacity-0 group-hover/field:opacity-100 transition-opacity",
1472
+ children: [
1473
+ /*#__PURE__*/ jsx(Button, {
1474
+ variant: "ghost",
1475
+ size: "sm",
1476
+ className: "h-5 w-5 p-0",
1477
+ onClick: (e_2)=>{
1478
+ e_2.stopPropagation();
1479
+ moveField(section_3.id, field_0.id, "up");
1480
+ },
1481
+ disabled: 0 === fieldIndex,
1482
+ children: /*#__PURE__*/ jsx(MoveUp, {
1483
+ className: "h-2.5 w-2.5"
1484
+ })
1485
+ }),
1486
+ /*#__PURE__*/ jsx(Button, {
1487
+ variant: "ghost",
1488
+ size: "sm",
1489
+ className: "h-5 w-5 p-0",
1490
+ onClick: (e_3)=>{
1491
+ e_3.stopPropagation();
1492
+ moveField(section_3.id, field_0.id, "down");
1493
+ },
1494
+ disabled: fieldIndex === section_3.fields.length - 1,
1495
+ children: /*#__PURE__*/ jsx(MoveDown, {
1496
+ className: "h-2.5 w-2.5"
1497
+ })
1498
+ }),
1499
+ /*#__PURE__*/ jsx(Button, {
1500
+ variant: "ghost",
1501
+ size: "sm",
1502
+ className: "h-5 w-5 p-0",
1503
+ onClick: (e_4)=>{
1504
+ e_4.stopPropagation();
1505
+ removeField(section_3.id, field_0.id);
1506
+ },
1507
+ children: /*#__PURE__*/ jsx(Trash2, {
1508
+ className: "h-2.5 w-2.5 text-destructive"
1509
+ })
1510
+ })
1511
+ ]
1512
+ })
1513
+ ]
1514
+ }, field_0.id)),
1515
+ /*#__PURE__*/ jsxs(Button, {
1516
+ onClick: ()=>addField(section_3.id),
1517
+ variant: "outline",
1518
+ size: "sm",
1519
+ children: [
1520
+ /*#__PURE__*/ jsx(Plus, {
1521
+ className: "h-3 w-3 mr-1"
1522
+ }),
1523
+ "Field"
1524
+ ]
1525
+ })
1526
+ ]
1527
+ })
1528
+ })
1529
+ ]
1530
+ }, section_3.id);
1531
+ $[66] = addField;
1532
+ $[67] = moveField;
1533
+ $[68] = moveSection;
1534
+ $[69] = removeField;
1535
+ $[70] = removeSection;
1536
+ $[71] = sections.length;
1537
+ $[72] = selectedFieldId;
1538
+ $[73] = selectedSectionId;
1539
+ $[74] = t27;
1540
+ } else t27 = $[74];
1541
+ t26 = sections.map(t27);
1542
+ $[57] = addField;
1543
+ $[58] = moveField;
1544
+ $[59] = moveSection;
1545
+ $[60] = removeField;
1546
+ $[61] = removeSection;
1547
+ $[62] = sections;
1548
+ $[63] = selectedFieldId;
1549
+ $[64] = selectedSectionId;
1550
+ $[65] = t26;
1551
+ } else t26 = $[65];
1552
+ let t27;
1553
+ if ($[75] !== expandedSections || $[76] !== t26) {
1554
+ t27 = /*#__PURE__*/ jsx(CardContent, {
1555
+ className: "flex-1 overflow-auto px-2 pb-2",
1556
+ children: /*#__PURE__*/ jsx(Accordion, {
1557
+ type: "multiple",
1558
+ value: expandedSections,
1559
+ onValueChange: setExpandedSections,
1560
+ className: "space-y-1",
1561
+ children: t26
1562
+ })
1563
+ });
1564
+ $[75] = expandedSections;
1565
+ $[76] = t26;
1566
+ $[77] = t27;
1567
+ } else t27 = $[77];
1568
+ if ($[78] !== t25 || $[79] !== t27) {
1569
+ t10 = /*#__PURE__*/ jsxs(Card, {
1570
+ className: "overflow-hidden flex flex-col",
1571
+ children: [
1572
+ t25,
1573
+ t27
1574
+ ]
1575
+ });
1576
+ $[78] = t25;
1577
+ $[79] = t27;
1578
+ $[80] = t10;
1579
+ } else t10 = $[80];
1580
+ T1 = Card;
1581
+ t4 = "overflow-hidden flex flex-col";
1582
+ let t28;
1583
+ if ($[81] === Symbol.for("react.memo_cache_sentinel")) {
1584
+ t28 = /*#__PURE__*/ jsx(Settings, {
1585
+ className: "h-4 w-4"
1586
+ });
1587
+ $[81] = t28;
1588
+ } else t28 = $[81];
1589
+ const t29 = selectedFieldId ? "Field configuration" : selectedSectionId ? "Section configuration" : "Configuration";
1590
+ let t30;
1591
+ if ($[82] !== t29) {
1592
+ t30 = /*#__PURE__*/ jsxs(CardTitle, {
1593
+ className: "flex items-center gap-2",
1594
+ children: [
1595
+ t28,
1596
+ t29
1597
+ ]
1598
+ });
1599
+ $[82] = t29;
1600
+ $[83] = t30;
1601
+ } else t30 = $[83];
1602
+ const t31 = selectedField ? `Configure "${selectedField.label}"` : selectedSection ? `Configure "${selectedSection.title}" section` : "Select a section or field to configure";
1603
+ let t32;
1604
+ if ($[84] !== t31) {
1605
+ t32 = /*#__PURE__*/ jsx(CardDescription, {
1606
+ children: t31
1607
+ });
1608
+ $[84] = t31;
1609
+ $[85] = t32;
1610
+ } else t32 = $[85];
1611
+ if ($[86] !== t30 || $[87] !== t32) {
1612
+ t5 = /*#__PURE__*/ jsxs(CardHeader, {
1613
+ children: [
1614
+ t30,
1615
+ t32
1616
+ ]
1617
+ });
1618
+ $[86] = t30;
1619
+ $[87] = t32;
1620
+ $[88] = t5;
1621
+ } else t5 = $[88];
1622
+ T0 = CardContent;
1623
+ t2 = "flex-1 overflow-auto";
1624
+ t3 = selectedField ? /*#__PURE__*/ jsx(FieldConfigForm, {
1625
+ field: selectedField,
1626
+ onUpdate: (updates_1)=>updateField(selectedField.id, updates_1),
1627
+ allFields: allFields,
1628
+ existingFieldNames: new Set(allFields.map(_temp6))
1629
+ }) : selectedSection ? /*#__PURE__*/ jsx(SectionConfigForm, {
1630
+ section: selectedSection,
1631
+ onUpdate: (updates_2)=>updateSection(selectedSection.id, updates_2),
1632
+ existingSectionIds: new Set(sections.map(_temp7))
1633
+ }) : /*#__PURE__*/ jsx("div", {
1634
+ className: "flex items-center justify-center h-full text-muted-foreground",
1635
+ children: "Select a section or field to configure"
1636
+ });
1637
+ $[2] = expandedSections;
1638
+ $[3] = formDescription;
1639
+ $[4] = formTitle;
1640
+ $[5] = sections;
1641
+ $[6] = selectedFieldId;
1642
+ $[7] = selectedSectionId;
1643
+ $[8] = T0;
1644
+ $[9] = T1;
1645
+ $[10] = T2;
1646
+ $[11] = generatedSchema;
1647
+ $[12] = t10;
1648
+ $[13] = t2;
1649
+ $[14] = t3;
1650
+ $[15] = t4;
1651
+ $[16] = t5;
1652
+ $[17] = t6;
1653
+ $[18] = t7;
1654
+ $[19] = t8;
1655
+ $[20] = t9;
1656
+ } else {
1657
+ T0 = $[8];
1658
+ T1 = $[9];
1659
+ T2 = $[10];
1660
+ generatedSchema = $[11];
1661
+ t10 = $[12];
1662
+ t2 = $[13];
1663
+ t3 = $[14];
1664
+ t4 = $[15];
1665
+ t5 = $[16];
1666
+ t6 = $[17];
1667
+ t7 = $[18];
1668
+ t8 = $[19];
1669
+ t9 = $[20];
1670
+ }
1671
+ let t11;
1672
+ if ($[89] !== T0 || $[90] !== t2 || $[91] !== t3) {
1673
+ t11 = /*#__PURE__*/ jsx(T0, {
1674
+ className: t2,
1675
+ children: t3
1676
+ });
1677
+ $[89] = T0;
1678
+ $[90] = t2;
1679
+ $[91] = t3;
1680
+ $[92] = t11;
1681
+ } else t11 = $[92];
1682
+ let t12;
1683
+ if ($[93] !== T1 || $[94] !== t11 || $[95] !== t4 || $[96] !== t5) {
1684
+ t12 = /*#__PURE__*/ jsxs(T1, {
1685
+ className: t4,
1686
+ children: [
1687
+ t5,
1688
+ t11
1689
+ ]
1690
+ });
1691
+ $[93] = T1;
1692
+ $[94] = t11;
1693
+ $[95] = t4;
1694
+ $[96] = t5;
1695
+ $[97] = t12;
1696
+ } else t12 = $[97];
1697
+ let t13;
1698
+ if ($[98] === Symbol.for("react.memo_cache_sentinel")) {
1699
+ t13 = /*#__PURE__*/ jsxs("div", {
1700
+ children: [
1701
+ /*#__PURE__*/ jsxs(CardTitle, {
1702
+ className: "flex items-center gap-2",
1703
+ children: [
1704
+ /*#__PURE__*/ jsx(View, {
1705
+ className: "h-4 w-4"
1706
+ }),
1707
+ "Preview & export"
1708
+ ]
1709
+ }),
1710
+ /*#__PURE__*/ jsx(CardDescription, {
1711
+ children: "See how your form looks"
1712
+ })
1713
+ ]
1714
+ });
1715
+ $[98] = t13;
1716
+ } else t13 = $[98];
1717
+ let t14;
1718
+ if ($[99] === Symbol.for("react.memo_cache_sentinel")) {
1719
+ t14 = /*#__PURE__*/ jsx(Label, {
1720
+ htmlFor: "form-title",
1721
+ children: "Form title"
1722
+ });
1723
+ $[99] = t14;
1724
+ } else t14 = $[99];
1725
+ let t15;
1726
+ if ($[100] === Symbol.for("react.memo_cache_sentinel")) {
1727
+ t15 = (e_5)=>setFormTitle(e_5.target.value);
1728
+ $[100] = t15;
1729
+ } else t15 = $[100];
1730
+ let t16;
1731
+ if ($[101] !== formTitle) {
1732
+ t16 = /*#__PURE__*/ jsxs("div", {
1733
+ className: "space-y-2",
1734
+ children: [
1735
+ t14,
1736
+ /*#__PURE__*/ jsx(Input, {
1737
+ id: "form-title",
1738
+ value: formTitle,
1739
+ onChange: t15
1740
+ })
1741
+ ]
1742
+ });
1743
+ $[101] = formTitle;
1744
+ $[102] = t16;
1745
+ } else t16 = $[102];
1746
+ let t17;
1747
+ if ($[103] === Symbol.for("react.memo_cache_sentinel")) {
1748
+ t17 = /*#__PURE__*/ jsx(Label, {
1749
+ htmlFor: "form-description",
1750
+ children: "Form description"
1751
+ });
1752
+ $[103] = t17;
1753
+ } else t17 = $[103];
1754
+ let t18;
1755
+ if ($[104] === Symbol.for("react.memo_cache_sentinel")) {
1756
+ t18 = (e_6)=>setFormDescription(e_6.target.value);
1757
+ $[104] = t18;
1758
+ } else t18 = $[104];
1759
+ let t19;
1760
+ if ($[105] !== formDescription) {
1761
+ t19 = /*#__PURE__*/ jsxs("div", {
1762
+ className: "space-y-2",
1763
+ children: [
1764
+ t17,
1765
+ /*#__PURE__*/ jsx(Textarea, {
1766
+ id: "form-description",
1767
+ value: formDescription,
1768
+ onChange: t18,
1769
+ placeholder: "Optional description",
1770
+ rows: 2
1771
+ })
1772
+ ]
1773
+ });
1774
+ $[105] = formDescription;
1775
+ $[106] = t19;
1776
+ } else t19 = $[106];
1777
+ let t20;
1778
+ if ($[107] !== t16 || $[108] !== t19) {
1779
+ t20 = /*#__PURE__*/ jsx(CardHeader, {
1780
+ children: /*#__PURE__*/ jsxs("div", {
1781
+ className: "space-y-4",
1782
+ children: [
1783
+ t13,
1784
+ t16,
1785
+ t19
1786
+ ]
1787
+ })
1788
+ });
1789
+ $[107] = t16;
1790
+ $[108] = t19;
1791
+ $[109] = t20;
1792
+ } else t20 = $[109];
1793
+ let t21;
1794
+ if ($[110] === Symbol.for("react.memo_cache_sentinel")) {
1795
+ t21 = /*#__PURE__*/ jsxs(TabsTrigger, {
1796
+ value: "preview",
1797
+ children: [
1798
+ /*#__PURE__*/ jsx(Eye, {
1799
+ className: "h-4 w-4 mr-2"
1800
+ }),
1801
+ "Preview"
1802
+ ]
1803
+ });
1804
+ $[110] = t21;
1805
+ } else t21 = $[110];
1806
+ let t22;
1807
+ if ($[111] === Symbol.for("react.memo_cache_sentinel")) {
1808
+ t22 = /*#__PURE__*/ jsxs(TabsList, {
1809
+ className: "grid w-full grid-cols-2",
1810
+ children: [
1811
+ t21,
1812
+ /*#__PURE__*/ jsxs(TabsTrigger, {
1813
+ value: "code",
1814
+ children: [
1815
+ /*#__PURE__*/ jsx(Code, {
1816
+ className: "h-4 w-4 mr-2"
1817
+ }),
1818
+ "Schema"
1819
+ ]
1820
+ })
1821
+ ]
1822
+ });
1823
+ $[111] = t22;
1824
+ } else t22 = $[111];
1825
+ let t23;
1826
+ if ($[112] === Symbol.for("react.memo_cache_sentinel")) {
1827
+ t23 = /*#__PURE__*/ jsx(Label, {
1828
+ htmlFor: "preview-readonly",
1829
+ className: "text-sm text-muted-foreground",
1830
+ children: "Readonly"
1831
+ });
1832
+ $[112] = t23;
1833
+ } else t23 = $[112];
1834
+ let t24;
1835
+ if ($[113] !== previewDisabled) {
1836
+ t24 = /*#__PURE__*/ jsxs("div", {
1837
+ className: "flex items-center justify-end gap-2 mb-4 pb-2 border-b",
1838
+ children: [
1839
+ t23,
1840
+ /*#__PURE__*/ jsx(Switch, {
1841
+ id: "preview-readonly",
1842
+ checked: previewDisabled,
1843
+ onCheckedChange: setPreviewDisabled
1844
+ })
1845
+ ]
1846
+ });
1847
+ $[113] = previewDisabled;
1848
+ $[114] = t24;
1849
+ } else t24 = $[114];
1850
+ let t25;
1851
+ if ($[115] !== sections) {
1852
+ t25 = sections.map(_temp9).join(",");
1853
+ $[115] = sections;
1854
+ $[116] = t25;
1855
+ } else t25 = $[116];
1856
+ let t26;
1857
+ if ($[117] !== generatedSchema || $[118] !== previewDisabled || $[119] !== t25) {
1858
+ t26 = /*#__PURE__*/ jsx(MetadataForm, {
1859
+ schema: generatedSchema,
1860
+ onSubmit: _temp0,
1861
+ disabled: previewDisabled,
1862
+ autoComplete: "off"
1863
+ }, t25);
1864
+ $[117] = generatedSchema;
1865
+ $[118] = previewDisabled;
1866
+ $[119] = t25;
1867
+ $[120] = t26;
1868
+ } else t26 = $[120];
1869
+ let t27;
1870
+ if ($[121] !== t24 || $[122] !== t26) {
1871
+ t27 = /*#__PURE__*/ jsxs(TabsContent, {
1872
+ value: "preview",
1873
+ className: "flex-1 overflow-auto",
1874
+ children: [
1875
+ t24,
1876
+ t26
1877
+ ]
1878
+ });
1879
+ $[121] = t24;
1880
+ $[122] = t26;
1881
+ $[123] = t27;
1882
+ } else t27 = $[123];
1883
+ let t28;
1884
+ if ($[124] !== generatedSchema) {
1885
+ t28 = schemaToJson(generatedSchema);
1886
+ $[124] = generatedSchema;
1887
+ $[125] = t28;
1888
+ } else t28 = $[125];
1889
+ let t29;
1890
+ if ($[126] !== t28) {
1891
+ t29 = /*#__PURE__*/ jsx(TabsContent, {
1892
+ value: "code",
1893
+ className: "flex-1 overflow-auto",
1894
+ children: /*#__PURE__*/ jsx("pre", {
1895
+ className: "text-xs bg-muted p-4 rounded-lg overflow-auto max-h-full",
1896
+ children: t28
1897
+ })
1898
+ });
1899
+ $[126] = t28;
1900
+ $[127] = t29;
1901
+ } else t29 = $[127];
1902
+ let t30;
1903
+ if ($[128] !== t27 || $[129] !== t29) {
1904
+ t30 = /*#__PURE__*/ jsx(CardContent, {
1905
+ className: "flex-1 overflow-auto",
1906
+ children: /*#__PURE__*/ jsxs(Tabs, {
1907
+ defaultValue: "preview",
1908
+ className: "h-full flex flex-col",
1909
+ children: [
1910
+ t22,
1911
+ t27,
1912
+ t29
1913
+ ]
1914
+ })
1915
+ });
1916
+ $[128] = t27;
1917
+ $[129] = t29;
1918
+ $[130] = t30;
1919
+ } else t30 = $[130];
1920
+ let t31;
1921
+ if ($[131] !== t20 || $[132] !== t30) {
1922
+ t31 = /*#__PURE__*/ jsxs(Card, {
1923
+ className: "overflow-hidden flex flex-col",
1924
+ children: [
1925
+ t20,
1926
+ t30
1927
+ ]
1928
+ });
1929
+ $[131] = t20;
1930
+ $[132] = t30;
1931
+ $[133] = t31;
1932
+ } else t31 = $[133];
1933
+ let t32;
1934
+ if ($[134] !== T2 || $[135] !== t10 || $[136] !== t12 || $[137] !== t31 || $[138] !== t6 || $[139] !== t7 || $[140] !== t8 || $[141] !== t9) {
1935
+ t32 = /*#__PURE__*/ jsxs(T2, {
1936
+ gap: t6,
1937
+ h: t7,
1938
+ p: t8,
1939
+ className: t9,
1940
+ children: [
1941
+ t10,
1942
+ t12,
1943
+ t31
1944
+ ]
1945
+ });
1946
+ $[134] = T2;
1947
+ $[135] = t10;
1948
+ $[136] = t12;
1949
+ $[137] = t31;
1950
+ $[138] = t6;
1951
+ $[139] = t7;
1952
+ $[140] = t8;
1953
+ $[141] = t9;
1954
+ $[142] = t32;
1955
+ } else t32 = $[142];
1956
+ return t32;
1957
+ }
1958
+ function _temp0(data) {
1959
+ console.log("Form submitted:", data);
1960
+ alert("Form submitted! Check console for data.");
1961
+ }
1962
+ function _temp9(s_14) {
1963
+ return `${s_14.id}:${s_14.collapsible}:${s_14.defaultExpanded}:${s_14.fields.map(_temp8).join("-")}`;
1964
+ }
1965
+ function _temp8(f_6) {
1966
+ return `${f_6.id}:${f_6.type}:${f_6.name}:${JSON.stringify(f_6.rules || [])}:${JSON.stringify(f_6.validation || {})}`;
1967
+ }
1968
+ function _temp7(s_13) {
1969
+ return s_13.id;
1970
+ }
1971
+ function _temp6(f_5) {
1972
+ return f_5.name;
1973
+ }
1974
+ function _temp5(r) {
1975
+ return r.effects.required;
1976
+ }
1977
+ function _temp4(s_9) {
1978
+ return s_9.fields;
1979
+ }
1980
+ function _temp3(section) {
1981
+ return {
1982
+ id: section.id,
1983
+ title: section.title,
1984
+ description: section.description,
1985
+ collapsible: section.collapsible,
1986
+ defaultExpanded: section.defaultExpanded,
1987
+ fields: section.fields.map(_temp2)
1396
1988
  };
1397
- const removeOption = (index)=>{
1398
- onChange(options.filter((_, i)=>i !== index));
1989
+ }
1990
+ function _temp2(field) {
1991
+ const { id: _id, validation: _validationConfig, ...fieldMeta } = field;
1992
+ const validationConfig = buildValidationConfig(field);
1993
+ return {
1994
+ ...fieldMeta,
1995
+ validation: validationConfig
1399
1996
  };
1400
- return /*#__PURE__*/ jsxs("div", {
1401
- className: "space-y-3",
1402
- children: [
1403
- options.map((option, index)=>/*#__PURE__*/ jsxs("div", {
1997
+ }
1998
+ function _temp(s) {
1999
+ return s.fields;
2000
+ }
2001
+ function FieldOptionsEditor(t0) {
2002
+ const $ = compiler_runtime_c(22);
2003
+ const { options, onChange } = t0;
2004
+ let t1;
2005
+ if ($[0] !== onChange || $[1] !== options) {
2006
+ t1 = ()=>{
2007
+ onChange([
2008
+ ...options,
2009
+ {
2010
+ label: `Option ${options.length + 1}`,
2011
+ value: `option${options.length + 1}`
2012
+ }
2013
+ ]);
2014
+ };
2015
+ $[0] = onChange;
2016
+ $[1] = options;
2017
+ $[2] = t1;
2018
+ } else t1 = $[2];
2019
+ const addOption = t1;
2020
+ let t2;
2021
+ if ($[3] !== onChange || $[4] !== options) {
2022
+ t2 = (index, updates)=>{
2023
+ const newOptions = [
2024
+ ...options
2025
+ ];
2026
+ newOptions[index] = {
2027
+ ...newOptions[index],
2028
+ ...updates
2029
+ };
2030
+ onChange(newOptions);
2031
+ };
2032
+ $[3] = onChange;
2033
+ $[4] = options;
2034
+ $[5] = t2;
2035
+ } else t2 = $[5];
2036
+ const updateOption = t2;
2037
+ let t3;
2038
+ if ($[6] !== onChange || $[7] !== options) {
2039
+ t3 = (index_0)=>{
2040
+ onChange(options.filter((_, i)=>i !== index_0));
2041
+ };
2042
+ $[6] = onChange;
2043
+ $[7] = options;
2044
+ $[8] = t3;
2045
+ } else t3 = $[8];
2046
+ const removeOption = t3;
2047
+ let t4;
2048
+ if ($[9] !== options || $[10] !== removeOption || $[11] !== updateOption) {
2049
+ let t5;
2050
+ if ($[13] !== removeOption || $[14] !== updateOption) {
2051
+ t5 = (option, index_1)=>/*#__PURE__*/ jsxs("div", {
1404
2052
  className: "flex gap-2 items-center",
1405
2053
  children: [
1406
2054
  /*#__PURE__*/ jsxs("div", {
@@ -1409,15 +2057,15 @@ function FieldOptionsEditor({ options, onChange }) {
1409
2057
  /*#__PURE__*/ jsx(Input, {
1410
2058
  placeholder: "Label",
1411
2059
  value: option.label,
1412
- onChange: (e)=>updateOption(index, {
2060
+ onChange: (e)=>updateOption(index_1, {
1413
2061
  label: e.target.value
1414
2062
  })
1415
2063
  }),
1416
2064
  /*#__PURE__*/ jsx(Input, {
1417
2065
  placeholder: "Value",
1418
2066
  value: option.value,
1419
- onChange: (e)=>updateOption(index, {
1420
- value: e.target.value
2067
+ onChange: (e_0)=>updateOption(index_1, {
2068
+ value: e_0.target.value
1421
2069
  })
1422
2070
  })
1423
2071
  ]
@@ -1426,213 +2074,311 @@ function FieldOptionsEditor({ options, onChange }) {
1426
2074
  variant: "ghost",
1427
2075
  size: "icon",
1428
2076
  className: "h-8 w-8 text-muted-foreground hover:text-destructive",
1429
- onClick: ()=>removeOption(index),
2077
+ onClick: ()=>removeOption(index_1),
1430
2078
  children: /*#__PURE__*/ jsx(Trash2, {
1431
2079
  className: "h-4 w-4"
1432
2080
  })
1433
2081
  })
1434
2082
  ]
1435
- }, index)),
1436
- /*#__PURE__*/ jsxs(Button, {
1437
- onClick: addOption,
1438
- variant: "outline",
1439
- size: "sm",
1440
- className: "w-full",
1441
- children: [
1442
- /*#__PURE__*/ jsx(Plus, {
1443
- className: "h-3 w-3 mr-2"
1444
- }),
1445
- "Add option"
1446
- ]
1447
- })
1448
- ]
1449
- });
2083
+ }, index_1);
2084
+ $[13] = removeOption;
2085
+ $[14] = updateOption;
2086
+ $[15] = t5;
2087
+ } else t5 = $[15];
2088
+ t4 = options.map(t5);
2089
+ $[9] = options;
2090
+ $[10] = removeOption;
2091
+ $[11] = updateOption;
2092
+ $[12] = t4;
2093
+ } else t4 = $[12];
2094
+ let t5;
2095
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
2096
+ t5 = /*#__PURE__*/ jsx(Plus, {
2097
+ className: "h-3 w-3 mr-2"
2098
+ });
2099
+ $[16] = t5;
2100
+ } else t5 = $[16];
2101
+ let t6;
2102
+ if ($[17] !== addOption) {
2103
+ t6 = /*#__PURE__*/ jsxs(Button, {
2104
+ onClick: addOption,
2105
+ variant: "outline",
2106
+ size: "sm",
2107
+ className: "w-full",
2108
+ children: [
2109
+ t5,
2110
+ "Add option"
2111
+ ]
2112
+ });
2113
+ $[17] = addOption;
2114
+ $[18] = t6;
2115
+ } else t6 = $[18];
2116
+ let t7;
2117
+ if ($[19] !== t4 || $[20] !== t6) {
2118
+ t7 = /*#__PURE__*/ jsxs("div", {
2119
+ className: "space-y-3",
2120
+ children: [
2121
+ t4,
2122
+ t6
2123
+ ]
2124
+ });
2125
+ $[19] = t4;
2126
+ $[20] = t6;
2127
+ $[21] = t7;
2128
+ } else t7 = $[21];
2129
+ return t7;
1450
2130
  }
1451
- function DataSourceEditor({ dataSource, onChange }) {
1452
- const [sourceType, setSourceType] = useState(dataSource?.type || 'none');
1453
- return /*#__PURE__*/ jsxs("div", {
1454
- className: "space-y-4",
1455
- children: [
1456
- /*#__PURE__*/ jsxs("div", {
1457
- className: "space-y-2",
1458
- children: [
1459
- /*#__PURE__*/ jsx(Label, {
1460
- children: "Data source type"
1461
- }),
1462
- /*#__PURE__*/ jsxs(Select, {
1463
- value: sourceType,
1464
- onValueChange: (value)=>{
1465
- setSourceType(value);
1466
- if ('none' === value) onChange(void 0);
1467
- else if ('static' === value) onChange({
1468
- type: 'static',
1469
- options: []
1470
- });
1471
- else if ('fetch' === value) onChange({
1472
- type: 'fetch',
1473
- url: '',
1474
- method: 'GET'
1475
- });
1476
- else if ('remote' === value) onChange({
1477
- type: 'remote',
1478
- endpoint: '',
1479
- params: {}
1480
- });
1481
- else if ('computed' === value) onChange({
1482
- type: 'computed',
1483
- dependency: [],
1484
- compute: ''
1485
- });
1486
- },
1487
- children: [
1488
- /*#__PURE__*/ jsx(SelectTrigger, {
1489
- children: /*#__PURE__*/ jsx(SelectValue, {})
1490
- }),
1491
- /*#__PURE__*/ jsxs(SelectContent, {
1492
- children: [
1493
- /*#__PURE__*/ jsx(SelectItem, {
1494
- value: "none",
1495
- children: "None"
1496
- }),
1497
- /*#__PURE__*/ jsx(SelectItem, {
1498
- value: "fetch",
1499
- children: "Fetch (single request)"
1500
- }),
1501
- /*#__PURE__*/ jsx(SelectItem, {
1502
- value: "remote",
1503
- children: "Remote (dependent)"
1504
- }),
1505
- /*#__PURE__*/ jsx(SelectItem, {
1506
- value: "computed",
1507
- children: "Computed"
1508
- })
1509
- ]
1510
- })
1511
- ]
1512
- })
1513
- ]
1514
- }),
1515
- 'fetch' === sourceType && dataSource?.type === 'fetch' && /*#__PURE__*/ jsxs("div", {
1516
- className: "space-y-3",
1517
- children: [
1518
- /*#__PURE__*/ jsxs("div", {
1519
- className: "space-y-2",
1520
- children: [
1521
- /*#__PURE__*/ jsx(Label, {
1522
- children: "API URL"
1523
- }),
1524
- /*#__PURE__*/ jsx(Input, {
1525
- placeholder: "/api/data",
1526
- value: dataSource.url,
1527
- onChange: (e)=>onChange({
1528
- ...dataSource,
1529
- url: e.target.value
1530
- })
1531
- })
1532
- ]
1533
- }),
1534
- /*#__PURE__*/ jsxs("div", {
1535
- className: "space-y-2",
1536
- children: [
1537
- /*#__PURE__*/ jsx(Label, {
1538
- children: "Transform"
1539
- }),
1540
- /*#__PURE__*/ jsx(Textarea, {
1541
- placeholder: "data.map(item => ({ label: item.name, value: item.id }))",
1542
- value: dataSource.transform || '',
1543
- onChange: (e)=>onChange({
1544
- ...dataSource,
1545
- transform: e.target.value
1546
- }),
1547
- rows: 2
1548
- })
1549
- ]
1550
- })
1551
- ]
1552
- }),
1553
- 'remote' === sourceType && dataSource?.type === 'remote' && /*#__PURE__*/ jsxs("div", {
1554
- className: "space-y-3",
1555
- children: [
1556
- /*#__PURE__*/ jsxs("div", {
1557
- className: "space-y-2",
1558
- children: [
1559
- /*#__PURE__*/ jsx(Label, {
1560
- children: "Endpoint"
1561
- }),
1562
- /*#__PURE__*/ jsx(Input, {
1563
- placeholder: "/api/data",
1564
- value: dataSource.endpoint,
1565
- onChange: (e)=>onChange({
1566
- ...dataSource,
1567
- endpoint: e.target.value
1568
- })
1569
- })
1570
- ]
1571
- }),
1572
- /*#__PURE__*/ jsxs("div", {
1573
- className: "space-y-2",
1574
- children: [
1575
- /*#__PURE__*/ jsx(Label, {
1576
- children: "Parameters (JSON)"
1577
- }),
1578
- /*#__PURE__*/ jsx(Textarea, {
1579
- placeholder: '{ "fieldName": "$otherField" }',
1580
- value: JSON.stringify(dataSource.params || {}, null, 2),
1581
- onChange: (e)=>{
1582
- try {
1583
- const params = JSON.parse(e.target.value);
1584
- onChange({
1585
- ...dataSource,
1586
- params
1587
- });
1588
- } catch {}
1589
- },
1590
- rows: 3
1591
- })
1592
- ]
1593
- })
1594
- ]
1595
- }),
1596
- 'computed' === sourceType && dataSource?.type === 'computed' && /*#__PURE__*/ jsxs("div", {
1597
- className: "space-y-3",
1598
- children: [
1599
- /*#__PURE__*/ jsxs("div", {
1600
- className: "space-y-2",
1601
- children: [
1602
- /*#__PURE__*/ jsx(Label, {
1603
- children: "Dependencies (comma-separated)"
1604
- }),
1605
- /*#__PURE__*/ jsx(Input, {
1606
- placeholder: "field1, field2",
1607
- value: dataSource.dependency.join(', '),
1608
- onChange: (e)=>onChange({
1609
- ...dataSource,
1610
- dependency: e.target.value.split(',').map((s)=>s.trim())
1611
- })
1612
- })
1613
- ]
1614
- }),
1615
- /*#__PURE__*/ jsxs("div", {
1616
- className: "space-y-2",
1617
- children: [
1618
- /*#__PURE__*/ jsx(Label, {
1619
- children: "Compute expression"
1620
- }),
1621
- /*#__PURE__*/ jsx(Textarea, {
1622
- placeholder: "(field1 || 0) * (field2 || 0)",
1623
- value: dataSource.compute,
1624
- onChange: (e)=>onChange({
2131
+ function DataSourceEditor(t0) {
2132
+ const $ = compiler_runtime_c(25);
2133
+ const { dataSource, onChange } = t0;
2134
+ const [sourceType, setSourceType] = useState(dataSource?.type || "none");
2135
+ let t1;
2136
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
2137
+ t1 = /*#__PURE__*/ jsx(Label, {
2138
+ children: "Data source type"
2139
+ });
2140
+ $[0] = t1;
2141
+ } else t1 = $[0];
2142
+ let t2;
2143
+ if ($[1] !== onChange) {
2144
+ t2 = (value)=>{
2145
+ setSourceType(value);
2146
+ if ("none" === value) onChange(void 0);
2147
+ else if ("static" === value) onChange({
2148
+ type: "static",
2149
+ options: []
2150
+ });
2151
+ else if ("fetch" === value) onChange({
2152
+ type: "fetch",
2153
+ url: "",
2154
+ method: "GET"
2155
+ });
2156
+ else if ("remote" === value) onChange({
2157
+ type: "remote",
2158
+ endpoint: "",
2159
+ params: {}
2160
+ });
2161
+ else if ("computed" === value) onChange({
2162
+ type: "computed",
2163
+ dependency: [],
2164
+ compute: ""
2165
+ });
2166
+ };
2167
+ $[1] = onChange;
2168
+ $[2] = t2;
2169
+ } else t2 = $[2];
2170
+ let t3;
2171
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
2172
+ t3 = /*#__PURE__*/ jsx(SelectTrigger, {
2173
+ children: /*#__PURE__*/ jsx(SelectValue, {})
2174
+ });
2175
+ $[3] = t3;
2176
+ } else t3 = $[3];
2177
+ let t4;
2178
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
2179
+ t4 = /*#__PURE__*/ jsxs(SelectContent, {
2180
+ children: [
2181
+ /*#__PURE__*/ jsx(SelectItem, {
2182
+ value: "none",
2183
+ children: "None"
2184
+ }),
2185
+ /*#__PURE__*/ jsx(SelectItem, {
2186
+ value: "fetch",
2187
+ children: "Fetch (single request)"
2188
+ }),
2189
+ /*#__PURE__*/ jsx(SelectItem, {
2190
+ value: "remote",
2191
+ children: "Remote (dependent)"
2192
+ }),
2193
+ /*#__PURE__*/ jsx(SelectItem, {
2194
+ value: "computed",
2195
+ children: "Computed"
2196
+ })
2197
+ ]
2198
+ });
2199
+ $[4] = t4;
2200
+ } else t4 = $[4];
2201
+ let t5;
2202
+ if ($[5] !== sourceType || $[6] !== t2) {
2203
+ t5 = /*#__PURE__*/ jsxs("div", {
2204
+ className: "space-y-2",
2205
+ children: [
2206
+ t1,
2207
+ /*#__PURE__*/ jsxs(Select, {
2208
+ value: sourceType,
2209
+ onValueChange: t2,
2210
+ children: [
2211
+ t3,
2212
+ t4
2213
+ ]
2214
+ })
2215
+ ]
2216
+ });
2217
+ $[5] = sourceType;
2218
+ $[6] = t2;
2219
+ $[7] = t5;
2220
+ } else t5 = $[7];
2221
+ let t6;
2222
+ if ($[8] !== dataSource || $[9] !== onChange || $[10] !== sourceType) {
2223
+ t6 = "fetch" === sourceType && dataSource?.type === "fetch" && /*#__PURE__*/ jsxs("div", {
2224
+ className: "space-y-3",
2225
+ children: [
2226
+ /*#__PURE__*/ jsxs("div", {
2227
+ className: "space-y-2",
2228
+ children: [
2229
+ /*#__PURE__*/ jsx(Label, {
2230
+ children: "API URL"
2231
+ }),
2232
+ /*#__PURE__*/ jsx(Input, {
2233
+ placeholder: "/api/data",
2234
+ value: dataSource.url,
2235
+ onChange: (e)=>onChange({
2236
+ ...dataSource,
2237
+ url: e.target.value
2238
+ })
2239
+ })
2240
+ ]
2241
+ }),
2242
+ /*#__PURE__*/ jsxs("div", {
2243
+ className: "space-y-2",
2244
+ children: [
2245
+ /*#__PURE__*/ jsx(Label, {
2246
+ children: "Transform"
2247
+ }),
2248
+ /*#__PURE__*/ jsx(Textarea, {
2249
+ placeholder: "data.map(item => ({ label: item.name, value: item.id }))",
2250
+ value: dataSource.transform || "",
2251
+ onChange: (e_0)=>onChange({
2252
+ ...dataSource,
2253
+ transform: e_0.target.value
2254
+ }),
2255
+ rows: 2
2256
+ })
2257
+ ]
2258
+ })
2259
+ ]
2260
+ });
2261
+ $[8] = dataSource;
2262
+ $[9] = onChange;
2263
+ $[10] = sourceType;
2264
+ $[11] = t6;
2265
+ } else t6 = $[11];
2266
+ let t7;
2267
+ if ($[12] !== dataSource || $[13] !== onChange || $[14] !== sourceType) {
2268
+ t7 = "remote" === sourceType && dataSource?.type === "remote" && /*#__PURE__*/ jsxs("div", {
2269
+ className: "space-y-3",
2270
+ children: [
2271
+ /*#__PURE__*/ jsxs("div", {
2272
+ className: "space-y-2",
2273
+ children: [
2274
+ /*#__PURE__*/ jsx(Label, {
2275
+ children: "Endpoint"
2276
+ }),
2277
+ /*#__PURE__*/ jsx(Input, {
2278
+ placeholder: "/api/data",
2279
+ value: dataSource.endpoint,
2280
+ onChange: (e_1)=>onChange({
2281
+ ...dataSource,
2282
+ endpoint: e_1.target.value
2283
+ })
2284
+ })
2285
+ ]
2286
+ }),
2287
+ /*#__PURE__*/ jsxs("div", {
2288
+ className: "space-y-2",
2289
+ children: [
2290
+ /*#__PURE__*/ jsx(Label, {
2291
+ children: "Parameters (JSON)"
2292
+ }),
2293
+ /*#__PURE__*/ jsx(Textarea, {
2294
+ placeholder: "{ \"fieldName\": \"$otherField\" }",
2295
+ value: JSON.stringify(dataSource.params || {}, null, 2),
2296
+ onChange: (e_2)=>{
2297
+ try {
2298
+ const params = JSON.parse(e_2.target.value);
2299
+ onChange({
1625
2300
  ...dataSource,
1626
- compute: e.target.value
1627
- }),
1628
- rows: 2
1629
- })
1630
- ]
1631
- })
1632
- ]
1633
- })
1634
- ]
1635
- });
2301
+ params
2302
+ });
2303
+ } catch {}
2304
+ },
2305
+ rows: 3
2306
+ })
2307
+ ]
2308
+ })
2309
+ ]
2310
+ });
2311
+ $[12] = dataSource;
2312
+ $[13] = onChange;
2313
+ $[14] = sourceType;
2314
+ $[15] = t7;
2315
+ } else t7 = $[15];
2316
+ let t8;
2317
+ if ($[16] !== dataSource || $[17] !== onChange || $[18] !== sourceType) {
2318
+ t8 = "computed" === sourceType && dataSource?.type === "computed" && /*#__PURE__*/ jsxs("div", {
2319
+ className: "space-y-3",
2320
+ children: [
2321
+ /*#__PURE__*/ jsxs("div", {
2322
+ className: "space-y-2",
2323
+ children: [
2324
+ /*#__PURE__*/ jsx(Label, {
2325
+ children: "Dependencies (comma-separated)"
2326
+ }),
2327
+ /*#__PURE__*/ jsx(Input, {
2328
+ placeholder: "field1, field2",
2329
+ value: dataSource.dependency.join(", "),
2330
+ onChange: (e_3)=>onChange({
2331
+ ...dataSource,
2332
+ dependency: e_3.target.value.split(",").map(_temp1)
2333
+ })
2334
+ })
2335
+ ]
2336
+ }),
2337
+ /*#__PURE__*/ jsxs("div", {
2338
+ className: "space-y-2",
2339
+ children: [
2340
+ /*#__PURE__*/ jsx(Label, {
2341
+ children: "Compute expression"
2342
+ }),
2343
+ /*#__PURE__*/ jsx(Textarea, {
2344
+ placeholder: "(field1 || 0) * (field2 || 0)",
2345
+ value: dataSource.compute,
2346
+ onChange: (e_4)=>onChange({
2347
+ ...dataSource,
2348
+ compute: e_4.target.value
2349
+ }),
2350
+ rows: 2
2351
+ })
2352
+ ]
2353
+ })
2354
+ ]
2355
+ });
2356
+ $[16] = dataSource;
2357
+ $[17] = onChange;
2358
+ $[18] = sourceType;
2359
+ $[19] = t8;
2360
+ } else t8 = $[19];
2361
+ let t9;
2362
+ if ($[20] !== t5 || $[21] !== t6 || $[22] !== t7 || $[23] !== t8) {
2363
+ t9 = /*#__PURE__*/ jsxs("div", {
2364
+ className: "space-y-4",
2365
+ children: [
2366
+ t5,
2367
+ t6,
2368
+ t7,
2369
+ t8
2370
+ ]
2371
+ });
2372
+ $[20] = t5;
2373
+ $[21] = t6;
2374
+ $[22] = t7;
2375
+ $[23] = t8;
2376
+ $[24] = t9;
2377
+ } else t9 = $[24];
2378
+ return t9;
2379
+ }
2380
+ function _temp1(s) {
2381
+ return s.trim();
1636
2382
  }
1637
2383
  const CONDITION_OPERATORS = [
1638
2384
  {
@@ -1691,96 +2437,135 @@ const RULE_EFFECTS = [
1691
2437
  color: 'text-gray-600 bg-gray-50 border-gray-200'
1692
2438
  }
1693
2439
  ];
1694
- function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequiredMessageChange }) {
2440
+ function RulesEditor(t0) {
2441
+ const $ = compiler_runtime_c(34);
2442
+ const { rules: t1, onChange, allFields, requiredMessage, onRequiredMessageChange } = t0;
2443
+ const rules = void 0 === t1 ? [] : t1;
1695
2444
  const [isAddingRule, setIsAddingRule] = useState(false);
1696
2445
  const [editingRuleIndex, setEditingRuleIndex] = useState(null);
1697
- const [selectedEffect, setSelectedEffect] = useState('show');
1698
- const [conditions, setConditions] = useState([
1699
- {
1700
- field: '',
1701
- operator: 'is',
1702
- value: ''
1703
- }
1704
- ]);
1705
- const [conditionOperator, setConditionOperator] = useState('AND');
1706
- const isAlwaysRequired = rules.some((r)=>true === r.effects.required && 0 === r.conditions.length);
1707
- const resetBuilder = ()=>{
1708
- setSelectedEffect('show');
1709
- setConditions([
1710
- {
1711
- field: '',
1712
- operator: 'is',
1713
- value: ''
1714
- }
1715
- ]);
1716
- setConditionOperator('AND');
1717
- setIsAddingRule(false);
1718
- setEditingRuleIndex(null);
1719
- };
1720
- const addCondition = ()=>{
1721
- setConditions([
1722
- ...conditions,
2446
+ const [selectedEffect, setSelectedEffect] = useState("show");
2447
+ let t2;
2448
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
2449
+ t2 = [
1723
2450
  {
1724
- field: '',
1725
- operator: 'is',
1726
- value: ''
2451
+ field: "",
2452
+ operator: "is",
2453
+ value: ""
1727
2454
  }
1728
- ]);
1729
- };
1730
- const updateCondition = (index, updates)=>{
1731
- const newConditions = [
1732
- ...conditions
1733
2455
  ];
1734
- newConditions[index] = {
1735
- ...newConditions[index],
1736
- ...updates
2456
+ $[0] = t2;
2457
+ } else t2 = $[0];
2458
+ const [conditions, setConditions] = useState(t2);
2459
+ const [conditionOperator, setConditionOperator] = useState("AND");
2460
+ const isAlwaysRequired = rules.some(_temp10);
2461
+ let t3;
2462
+ if ($[1] !== setConditionOperator || $[2] !== setIsAddingRule || $[3] !== setSelectedEffect) {
2463
+ t3 = ()=>{
2464
+ setSelectedEffect("show");
2465
+ setConditions([
2466
+ {
2467
+ field: "",
2468
+ operator: "is",
2469
+ value: ""
2470
+ }
2471
+ ]);
2472
+ setConditionOperator("AND");
2473
+ setIsAddingRule(false);
2474
+ setEditingRuleIndex(null);
1737
2475
  };
1738
- setConditions(newConditions);
1739
- };
1740
- const removeCondition = (index)=>{
1741
- if (conditions.length > 1) setConditions(conditions.filter((_, i)=>i !== index));
1742
- };
1743
- const buildCondition = (cond)=>{
1744
- const condition = {
1745
- when: cond.field
2476
+ $[1] = setConditionOperator;
2477
+ $[2] = setIsAddingRule;
2478
+ $[3] = setSelectedEffect;
2479
+ $[4] = t3;
2480
+ } else t3 = $[4];
2481
+ const resetBuilder = t3;
2482
+ let t4;
2483
+ if ($[5] !== conditions) {
2484
+ t4 = ()=>{
2485
+ setConditions([
2486
+ ...conditions,
2487
+ {
2488
+ field: "",
2489
+ operator: "is",
2490
+ value: ""
2491
+ }
2492
+ ]);
1746
2493
  };
1747
- const targetField = allFields.find((f)=>f.name === cond.field);
1748
- const isNumericField = targetField?.type === 'number' || targetField?.type === 'slider';
1749
- const isBooleanField = targetField?.type === 'checkbox' || targetField?.type === 'switch';
1750
- const parseValue = (val)=>{
1751
- if (isBooleanField) {
1752
- if ('true' === val.toLowerCase()) return true;
1753
- if ('false' === val.toLowerCase()) return false;
1754
- }
1755
- if (isNumericField) {
1756
- const num = Number(val);
1757
- if (!isNaN(num)) return num;
2494
+ $[5] = conditions;
2495
+ $[6] = t4;
2496
+ } else t4 = $[6];
2497
+ const addCondition = t4;
2498
+ let t5;
2499
+ if ($[7] !== conditions) {
2500
+ t5 = (index, updates)=>{
2501
+ const newConditions = [
2502
+ ...conditions
2503
+ ];
2504
+ newConditions[index] = {
2505
+ ...newConditions[index],
2506
+ ...updates
2507
+ };
2508
+ setConditions(newConditions);
2509
+ };
2510
+ $[7] = conditions;
2511
+ $[8] = t5;
2512
+ } else t5 = $[8];
2513
+ const updateCondition = t5;
2514
+ let t6;
2515
+ if ($[9] !== conditions) {
2516
+ t6 = (index_0)=>{
2517
+ if (conditions.length > 1) setConditions(conditions.filter((_, i)=>i !== index_0));
2518
+ };
2519
+ $[9] = conditions;
2520
+ $[10] = t6;
2521
+ } else t6 = $[10];
2522
+ const removeCondition = t6;
2523
+ let t7;
2524
+ if ($[11] !== allFields) {
2525
+ t7 = (cond)=>{
2526
+ const condition = {
2527
+ when: cond.field
2528
+ };
2529
+ const targetField = allFields.find((f)=>f.name === cond.field);
2530
+ const isNumericField = targetField?.type === "number" || targetField?.type === "slider";
2531
+ const isBooleanField = targetField?.type === "checkbox" || targetField?.type === "switch";
2532
+ const parseValue = (val)=>{
2533
+ if (isBooleanField) {
2534
+ if ("true" === val.toLowerCase()) return true;
2535
+ if ("false" === val.toLowerCase()) return false;
2536
+ }
2537
+ if (isNumericField) {
2538
+ const num = Number(val);
2539
+ if (!isNaN(num)) return num;
2540
+ }
2541
+ if ("true" === val.toLowerCase()) return true;
2542
+ if ("false" === val.toLowerCase()) return false;
2543
+ return val;
2544
+ };
2545
+ switch(cond.operator){
2546
+ case "is":
2547
+ condition.is = parseValue(cond.value);
2548
+ break;
2549
+ case "isNot":
2550
+ condition.isNot = parseValue(cond.value);
2551
+ break;
2552
+ case "in":
2553
+ condition.in = cond.value.split(",").map((v_0)=>parseValue(v_0.trim()));
2554
+ break;
2555
+ case "notIn":
2556
+ condition.notIn = cond.value.split(",").map((v)=>parseValue(v.trim()));
2557
+ break;
2558
+ case "matches":
2559
+ condition.matches = cond.value;
1758
2560
  }
1759
- if ('true' === val.toLowerCase()) return true;
1760
- if ('false' === val.toLowerCase()) return false;
1761
- return val;
2561
+ return condition;
1762
2562
  };
1763
- switch(cond.operator){
1764
- case 'is':
1765
- condition.is = parseValue(cond.value);
1766
- break;
1767
- case 'isNot':
1768
- condition.isNot = parseValue(cond.value);
1769
- break;
1770
- case 'in':
1771
- condition.in = cond.value.split(',').map((v)=>parseValue(v.trim()));
1772
- break;
1773
- case 'notIn':
1774
- condition.notIn = cond.value.split(',').map((v)=>parseValue(v.trim()));
1775
- break;
1776
- case 'matches':
1777
- condition.matches = cond.value;
1778
- break;
1779
- }
1780
- return condition;
1781
- };
2563
+ $[11] = allFields;
2564
+ $[12] = t7;
2565
+ } else t7 = $[12];
2566
+ const buildCondition = t7;
1782
2567
  const saveRule = ()=>{
1783
- const validConditions = conditions.filter((c)=>c.field);
2568
+ const validConditions = conditions.filter(_temp11);
1784
2569
  if (0 === validConditions.length) return;
1785
2570
  const newRule = {
1786
2571
  id: `rule-${Date.now()}`,
@@ -1789,18 +2574,17 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
1789
2574
  effects: {}
1790
2575
  };
1791
2576
  switch(selectedEffect){
1792
- case 'show':
2577
+ case "show":
1793
2578
  newRule.effects.visible = true;
1794
2579
  break;
1795
- case 'hide':
2580
+ case "hide":
1796
2581
  newRule.effects.visible = false;
1797
2582
  break;
1798
- case 'require':
2583
+ case "require":
1799
2584
  newRule.effects.required = true;
1800
2585
  break;
1801
- case 'disable':
2586
+ case "disable":
1802
2587
  newRule.effects.disabled = true;
1803
- break;
1804
2588
  }
1805
2589
  if (null !== editingRuleIndex) {
1806
2590
  const newRules = [
@@ -1814,148 +2598,351 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
1814
2598
  ]);
1815
2599
  resetBuilder();
1816
2600
  };
1817
- const editRule = (index)=>{
1818
- const rule = rules[index];
2601
+ const editRule = (index_1)=>{
2602
+ const rule = rules[index_1];
1819
2603
  if (!rule) return;
1820
- let effect = 'show';
1821
- if (true === rule.effects.visible) effect = 'show';
1822
- else if (false === rule.effects.visible) effect = 'hide';
1823
- else if (true === rule.effects.required) effect = 'require';
1824
- else if (true === rule.effects.disabled) effect = 'disable';
2604
+ let effect = "show";
2605
+ if (true === rule.effects.visible) effect = "show";
2606
+ else if (false === rule.effects.visible) effect = "hide";
2607
+ else if (true === rule.effects.required) effect = "require";
2608
+ else if (true === rule.effects.disabled) effect = "disable";
1825
2609
  setSelectedEffect(effect);
1826
- setConditionOperator(rule.operator || 'AND');
1827
- const editableConditions = rule.conditions.map((cond)=>{
1828
- let operator = 'is';
1829
- let value = '';
1830
- if (void 0 !== cond.is) {
1831
- operator = 'is';
1832
- value = String(cond.is);
1833
- } else if (void 0 !== cond.isNot) {
1834
- operator = 'isNot';
1835
- value = String(cond.isNot);
1836
- } else if (void 0 !== cond.in) {
1837
- operator = 'in';
1838
- value = cond.in.map(String).join(', ');
1839
- } else if (void 0 !== cond.notIn) {
1840
- operator = 'notIn';
1841
- value = cond.notIn.map(String).join(', ');
1842
- } else if (void 0 !== cond.matches) {
1843
- operator = 'matches';
1844
- value = cond.matches;
1845
- }
1846
- return {
1847
- field: cond.when,
1848
- operator,
1849
- value
1850
- };
1851
- });
2610
+ setConditionOperator(rule.operator || "AND");
2611
+ const editableConditions = rule.conditions.map(_temp12);
1852
2612
  setConditions(editableConditions.length > 0 ? editableConditions : [
1853
2613
  {
1854
- field: '',
1855
- operator: 'is',
1856
- value: ''
2614
+ field: "",
2615
+ operator: "is",
2616
+ value: ""
1857
2617
  }
1858
2618
  ]);
1859
- setEditingRuleIndex(index);
2619
+ setEditingRuleIndex(index_1);
1860
2620
  setIsAddingRule(true);
1861
2621
  };
1862
- const deleteRule = (index)=>{
1863
- onChange(rules.filter((_, i)=>i !== index));
1864
- };
1865
- const getFieldLabel = (fieldName)=>{
1866
- const field = allFields.find((f)=>f.name === fieldName);
1867
- return field?.label || fieldName;
1868
- };
1869
- const describeRule = (rule)=>{
1870
- if (0 === rule.conditions.length) {
1871
- if (rule.effects.required) return 'Always required';
1872
- return 'Always applies';
1873
- }
1874
- const conditionDescriptions = rule.conditions.map((cond)=>{
1875
- const fieldLabel = getFieldLabel(cond.when);
1876
- if (void 0 !== cond.is) return `"${fieldLabel}" = ${JSON.stringify(cond.is)}`;
1877
- if (void 0 !== cond.isNot) return `"${fieldLabel}" ≠ ${JSON.stringify(cond.isNot)}`;
1878
- if (void 0 !== cond.in) return `"${fieldLabel}" in [${cond.in.map((v)=>JSON.stringify(v)).join(', ')}]`;
1879
- if (void 0 !== cond.notIn) return `"${fieldLabel}" not in [${cond.notIn.map((v)=>JSON.stringify(v)).join(', ')}]`;
1880
- if (void 0 !== cond.matches) return `"${fieldLabel}" matches /${cond.matches}/`;
1881
- return `"${fieldLabel}"`;
1882
- });
1883
- const operator = 'OR' === rule.operator ? ' OR ' : ' AND ';
1884
- return conditionDescriptions.join(operator);
2622
+ const deleteRule = (index_2)=>{
2623
+ onChange(rules.filter((__0, i_0)=>i_0 !== index_2));
1885
2624
  };
1886
- const getEffectDescription = (rule)=>{
1887
- if (true === rule.effects.visible) return {
1888
- label: 'Show',
1889
- color: 'text-green-600 bg-green-50'
1890
- };
1891
- if (false === rule.effects.visible) return {
1892
- label: 'Hide',
1893
- color: 'text-orange-600 bg-orange-50'
2625
+ let t8;
2626
+ if ($[13] !== allFields) {
2627
+ const getFieldLabel = (fieldName)=>{
2628
+ const field = allFields.find((f_0)=>f_0.name === fieldName);
2629
+ return field?.label || fieldName;
1894
2630
  };
1895
- if (true === rule.effects.required) return {
1896
- label: 'Required',
1897
- color: 'text-red-600 bg-red-50'
1898
- };
1899
- if (true === rule.effects.disabled) return {
1900
- label: 'Disabled',
1901
- color: 'text-gray-600 bg-gray-50'
2631
+ t8 = (rule_0)=>{
2632
+ if (0 === rule_0.conditions.length) {
2633
+ if (rule_0.effects.required) return "Always required";
2634
+ return "Always applies";
2635
+ }
2636
+ const conditionDescriptions = rule_0.conditions.map((cond_1)=>{
2637
+ const fieldLabel = getFieldLabel(cond_1.when);
2638
+ if (void 0 !== cond_1.is) return `"${fieldLabel}" = ${JSON.stringify(cond_1.is)}`;
2639
+ if (void 0 !== cond_1.isNot) return `"${fieldLabel}" ≠ ${JSON.stringify(cond_1.isNot)}`;
2640
+ if (void 0 !== cond_1.in) return `"${fieldLabel}" in [${cond_1.in.map(_temp13).join(", ")}]`;
2641
+ if (void 0 !== cond_1.notIn) return `"${fieldLabel}" not in [${cond_1.notIn.map(_temp14).join(", ")}]`;
2642
+ if (void 0 !== cond_1.matches) return `"${fieldLabel}" matches /${cond_1.matches}/`;
2643
+ return `"${fieldLabel}"`;
2644
+ });
2645
+ const operator_0 = "OR" === rule_0.operator ? " OR " : " AND ";
2646
+ return conditionDescriptions.join(operator_0);
1902
2647
  };
1903
- return {
1904
- label: 'Unknown',
1905
- color: 'text-muted-foreground bg-muted'
2648
+ $[13] = allFields;
2649
+ $[14] = t8;
2650
+ } else t8 = $[14];
2651
+ const describeRule = t8;
2652
+ const getEffectDescription = _temp15;
2653
+ let t9;
2654
+ if ($[15] !== allFields) {
2655
+ t9 = (fieldName_0)=>{
2656
+ const field_0 = allFields.find((f_1)=>f_1.name === fieldName_0);
2657
+ return field_0?.options || [];
1906
2658
  };
1907
- };
1908
- const getFieldOptions = (fieldName)=>{
1909
- const field = allFields.find((f)=>f.name === fieldName);
1910
- return field?.options || [];
1911
- };
1912
- return /*#__PURE__*/ jsxs("div", {
1913
- className: "space-y-4",
1914
- children: [
1915
- /*#__PURE__*/ jsxs("div", {
1916
- className: "space-y-3 p-3 border rounded-lg bg-muted/30",
1917
- children: [
1918
- /*#__PURE__*/ jsxs("div", {
1919
- className: "flex items-center justify-between",
1920
- children: [
1921
- /*#__PURE__*/ jsxs("div", {
1922
- className: "flex items-center gap-3",
2659
+ $[15] = allFields;
2660
+ $[16] = t9;
2661
+ } else t9 = $[16];
2662
+ const getFieldOptions = t9;
2663
+ let t10;
2664
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
2665
+ t10 = /*#__PURE__*/ jsxs("div", {
2666
+ className: "flex items-center gap-3",
2667
+ children: [
2668
+ /*#__PURE__*/ jsx(Asterisk, {
2669
+ className: "h-5 w-5 text-red-500"
2670
+ }),
2671
+ /*#__PURE__*/ jsxs("div", {
2672
+ children: [
2673
+ /*#__PURE__*/ jsx(Label, {
2674
+ className: "cursor-pointer font-medium",
2675
+ children: "Always required"
2676
+ }),
2677
+ /*#__PURE__*/ jsx("p", {
2678
+ className: "text-xs text-muted-foreground",
2679
+ children: "Field must always have a value"
2680
+ })
2681
+ ]
2682
+ })
2683
+ ]
2684
+ });
2685
+ $[17] = t10;
2686
+ } else t10 = $[17];
2687
+ let t12;
2688
+ if ($[18] !== addCondition || $[19] !== allFields || $[20] !== conditionOperator || $[21] !== conditions || $[22] !== editingRuleIndex || $[23] !== getFieldOptions || $[24] !== isAddingRule || $[25] !== removeCondition || $[26] !== resetBuilder || $[27] !== saveRule || $[28] !== selectedEffect || $[29] !== setConditionOperator || $[30] !== setIsAddingRule || $[31] !== setSelectedEffect || $[32] !== updateCondition) {
2689
+ t12 = isAddingRule ? /*#__PURE__*/ jsxs("div", {
2690
+ className: "border rounded-lg p-4 space-y-4 bg-muted/20",
2691
+ children: [
2692
+ /*#__PURE__*/ jsxs("div", {
2693
+ className: "flex items-center justify-between",
2694
+ children: [
2695
+ /*#__PURE__*/ jsx(Label, {
2696
+ className: "font-medium",
2697
+ children: null !== editingRuleIndex ? "Edit rule" : "New rule"
2698
+ }),
2699
+ /*#__PURE__*/ jsx(Button, {
2700
+ variant: "ghost",
2701
+ size: "sm",
2702
+ onClick: resetBuilder,
2703
+ children: "Cancel"
2704
+ })
2705
+ ]
2706
+ }),
2707
+ /*#__PURE__*/ jsxs("div", {
2708
+ className: "space-y-2",
2709
+ children: [
2710
+ /*#__PURE__*/ jsx(Label, {
2711
+ className: "text-xs text-muted-foreground",
2712
+ children: "When conditions are met:"
2713
+ }),
2714
+ /*#__PURE__*/ jsx("div", {
2715
+ className: "grid grid-cols-2 gap-2",
2716
+ children: RULE_EFFECTS.map((effect_1)=>/*#__PURE__*/ jsxs("button", {
2717
+ type: "button",
2718
+ className: `flex items-center gap-2 p-2 rounded-lg border text-left text-sm transition-all ${selectedEffect === effect_1.value ? effect_1.color + " border-current" : "hover:bg-muted"}`,
2719
+ onClick: ()=>setSelectedEffect(effect_1.value),
2720
+ children: [
2721
+ /*#__PURE__*/ jsx(effect_1.Icon, {
2722
+ className: "h-4 w-4"
2723
+ }),
2724
+ /*#__PURE__*/ jsx("span", {
2725
+ className: "font-medium",
2726
+ children: effect_1.label
2727
+ })
2728
+ ]
2729
+ }, effect_1.value))
2730
+ })
2731
+ ]
2732
+ }),
2733
+ /*#__PURE__*/ jsxs("div", {
2734
+ className: "space-y-3",
2735
+ children: [
2736
+ /*#__PURE__*/ jsxs("div", {
2737
+ className: "flex items-center justify-between",
2738
+ children: [
2739
+ /*#__PURE__*/ jsx(Label, {
2740
+ className: "text-xs text-muted-foreground",
2741
+ children: "Conditions:"
2742
+ }),
2743
+ conditions.length > 1 && /*#__PURE__*/ jsxs(Select, {
2744
+ value: conditionOperator,
2745
+ onValueChange: (v_3)=>setConditionOperator(v_3),
2746
+ children: [
2747
+ /*#__PURE__*/ jsx(SelectTrigger, {
2748
+ className: "w-24 h-7 text-xs",
2749
+ children: /*#__PURE__*/ jsx(SelectValue, {})
2750
+ }),
2751
+ /*#__PURE__*/ jsxs(SelectContent, {
2752
+ children: [
2753
+ /*#__PURE__*/ jsx(SelectItem, {
2754
+ value: "AND",
2755
+ children: "Match ALL"
2756
+ }),
2757
+ /*#__PURE__*/ jsx(SelectItem, {
2758
+ value: "OR",
2759
+ children: "Match ANY"
2760
+ })
2761
+ ]
2762
+ })
2763
+ ]
2764
+ })
2765
+ ]
2766
+ }),
2767
+ conditions.map((cond_2, index_5)=>/*#__PURE__*/ jsxs("div", {
2768
+ className: "space-y-2",
1923
2769
  children: [
1924
- /*#__PURE__*/ jsx(Asterisk, {
1925
- className: "h-5 w-5 text-red-500"
2770
+ index_5 > 0 && /*#__PURE__*/ jsxs("div", {
2771
+ className: "flex items-center gap-2 text-xs text-muted-foreground",
2772
+ children: [
2773
+ /*#__PURE__*/ jsx(Separator, {
2774
+ className: "flex-1"
2775
+ }),
2776
+ /*#__PURE__*/ jsx("span", {
2777
+ children: conditionOperator
2778
+ }),
2779
+ /*#__PURE__*/ jsx(Separator, {
2780
+ className: "flex-1"
2781
+ })
2782
+ ]
1926
2783
  }),
1927
2784
  /*#__PURE__*/ jsxs("div", {
2785
+ className: "flex gap-2 items-start",
1928
2786
  children: [
1929
- /*#__PURE__*/ jsx(Label, {
1930
- className: "cursor-pointer font-medium",
1931
- children: "Always required"
2787
+ /*#__PURE__*/ jsxs("div", {
2788
+ className: "flex-1 space-y-2",
2789
+ children: [
2790
+ /*#__PURE__*/ jsxs(Select, {
2791
+ value: cond_2.field,
2792
+ onValueChange: (v_4)=>updateCondition(index_5, {
2793
+ field: v_4
2794
+ }),
2795
+ children: [
2796
+ /*#__PURE__*/ jsx(SelectTrigger, {
2797
+ className: "h-8 text-sm",
2798
+ children: /*#__PURE__*/ jsx(SelectValue, {
2799
+ placeholder: "Select field..."
2800
+ })
2801
+ }),
2802
+ /*#__PURE__*/ jsx(SelectContent, {
2803
+ children: allFields.map(_temp21)
2804
+ })
2805
+ ]
2806
+ }),
2807
+ /*#__PURE__*/ jsxs("div", {
2808
+ className: "flex gap-2",
2809
+ children: [
2810
+ /*#__PURE__*/ jsxs(Select, {
2811
+ value: cond_2.operator,
2812
+ onValueChange: (v_5)=>updateCondition(index_5, {
2813
+ operator: v_5
2814
+ }),
2815
+ children: [
2816
+ /*#__PURE__*/ jsx(SelectTrigger, {
2817
+ className: "w-32 h-8 text-sm",
2818
+ children: /*#__PURE__*/ jsx(SelectValue, {})
2819
+ }),
2820
+ /*#__PURE__*/ jsx(SelectContent, {
2821
+ children: CONDITION_OPERATORS.map(_temp22)
2822
+ })
2823
+ ]
2824
+ }),
2825
+ /*#__PURE__*/ jsx("div", {
2826
+ className: "flex-1",
2827
+ children: cond_2.field && getFieldOptions(cond_2.field).length > 0 && ("is" === cond_2.operator || "isNot" === cond_2.operator) ? /*#__PURE__*/ jsxs(Select, {
2828
+ value: cond_2.value,
2829
+ onValueChange: (v_6)=>updateCondition(index_5, {
2830
+ value: v_6
2831
+ }),
2832
+ children: [
2833
+ /*#__PURE__*/ jsx(SelectTrigger, {
2834
+ className: "h-8 text-sm",
2835
+ children: /*#__PURE__*/ jsx(SelectValue, {
2836
+ placeholder: "Select value..."
2837
+ })
2838
+ }),
2839
+ /*#__PURE__*/ jsx(SelectContent, {
2840
+ children: getFieldOptions(cond_2.field).map(_temp23)
2841
+ })
2842
+ ]
2843
+ }) : /*#__PURE__*/ jsx(Input, {
2844
+ className: "h-8 text-sm",
2845
+ placeholder: "in" === cond_2.operator || "notIn" === cond_2.operator ? "value1, value2, ..." : "matches" === cond_2.operator ? "regex pattern" : "value",
2846
+ value: cond_2.value,
2847
+ onChange: (e_0)=>updateCondition(index_5, {
2848
+ value: e_0.target.value
2849
+ })
2850
+ })
2851
+ })
2852
+ ]
2853
+ })
2854
+ ]
1932
2855
  }),
1933
- /*#__PURE__*/ jsx("p", {
1934
- className: "text-xs text-muted-foreground",
1935
- children: "Field must always have a value"
2856
+ conditions.length > 1 && /*#__PURE__*/ jsx(Button, {
2857
+ variant: "ghost",
2858
+ size: "sm",
2859
+ className: "h-8 w-8 p-0 text-muted-foreground",
2860
+ onClick: ()=>removeCondition(index_5),
2861
+ children: /*#__PURE__*/ jsx(Trash2, {
2862
+ className: "h-3.5 w-3.5"
2863
+ })
1936
2864
  })
1937
2865
  ]
1938
2866
  })
1939
2867
  ]
1940
- }),
2868
+ }, index_5)),
2869
+ /*#__PURE__*/ jsxs(Button, {
2870
+ variant: "outline",
2871
+ size: "sm",
2872
+ className: "w-full",
2873
+ onClick: addCondition,
2874
+ children: [
2875
+ /*#__PURE__*/ jsx(Plus, {
2876
+ className: "h-3 w-3 mr-2"
2877
+ }),
2878
+ "Add condition"
2879
+ ]
2880
+ })
2881
+ ]
2882
+ }),
2883
+ /*#__PURE__*/ jsx(Button, {
2884
+ className: "w-full",
2885
+ onClick: saveRule,
2886
+ disabled: !conditions.some(_temp24),
2887
+ children: null !== editingRuleIndex ? "Update rule" : "Add rule"
2888
+ })
2889
+ ]
2890
+ }) : /*#__PURE__*/ jsxs(Button, {
2891
+ variant: "outline",
2892
+ className: "w-full",
2893
+ onClick: ()=>setIsAddingRule(true),
2894
+ children: [
2895
+ /*#__PURE__*/ jsx(Plus, {
2896
+ className: "h-4 w-4 mr-2"
2897
+ }),
2898
+ "Add conditional rule"
2899
+ ]
2900
+ });
2901
+ $[18] = addCondition;
2902
+ $[19] = allFields;
2903
+ $[20] = conditionOperator;
2904
+ $[21] = conditions;
2905
+ $[22] = editingRuleIndex;
2906
+ $[23] = getFieldOptions;
2907
+ $[24] = isAddingRule;
2908
+ $[25] = removeCondition;
2909
+ $[26] = resetBuilder;
2910
+ $[27] = saveRule;
2911
+ $[28] = selectedEffect;
2912
+ $[29] = setConditionOperator;
2913
+ $[30] = setIsAddingRule;
2914
+ $[31] = setSelectedEffect;
2915
+ $[32] = updateCondition;
2916
+ $[33] = t12;
2917
+ } else t12 = $[33];
2918
+ return /*#__PURE__*/ jsxs("div", {
2919
+ className: "space-y-4",
2920
+ children: [
2921
+ /*#__PURE__*/ jsxs("div", {
2922
+ className: "space-y-3 p-3 border rounded-lg bg-muted/30",
2923
+ children: [
2924
+ /*#__PURE__*/ jsxs("div", {
2925
+ className: "flex items-center justify-between",
2926
+ children: [
2927
+ t10,
1941
2928
  /*#__PURE__*/ jsx(Checkbox, {
1942
2929
  checked: isAlwaysRequired,
1943
2930
  onCheckedChange: (checked)=>{
1944
2931
  if (checked) {
1945
2932
  const requiredRule = {
1946
- id: 'always-required',
2933
+ id: "always-required",
1947
2934
  conditions: [],
1948
- operator: 'AND',
2935
+ operator: "AND",
1949
2936
  effects: {
1950
2937
  required: true
1951
2938
  }
1952
2939
  };
1953
2940
  onChange([
1954
- ...rules.filter((r)=>!(r.effects.required && 0 === r.conditions.length)),
2941
+ ...rules.filter(_temp16),
1955
2942
  requiredRule
1956
2943
  ]);
1957
2944
  } else {
1958
- onChange(rules.filter((r)=>!(r.effects.required && 0 === r.conditions.length)));
2945
+ onChange(rules.filter(_temp17));
1959
2946
  onRequiredMessageChange(void 0);
1960
2947
  }
1961
2948
  }
@@ -1973,7 +2960,7 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
1973
2960
  /*#__PURE__*/ jsx(Input, {
1974
2961
  id: "required-message",
1975
2962
  placeholder: "This field is required",
1976
- value: requiredMessage || '',
2963
+ value: requiredMessage || "",
1977
2964
  onChange: (e)=>onRequiredMessageChange(e.target.value || void 0),
1978
2965
  className: "h-8 text-sm"
1979
2966
  })
@@ -1981,18 +2968,16 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
1981
2968
  })
1982
2969
  ]
1983
2970
  }),
1984
- rules.filter((r)=>r.conditions.length > 0 || !r.effects.required).length > 0 && /*#__PURE__*/ jsxs("div", {
2971
+ rules.filter(_temp18).length > 0 && /*#__PURE__*/ jsxs("div", {
1985
2972
  className: "space-y-2",
1986
2973
  children: [
1987
2974
  /*#__PURE__*/ jsx(Label, {
1988
2975
  className: "text-xs text-muted-foreground uppercase tracking-wide",
1989
2976
  children: "Conditional rules"
1990
2977
  }),
1991
- rules.map((rule, index)=>({
1992
- rule,
1993
- index
1994
- })).filter(({ rule })=>rule.conditions.length > 0 || !rule.effects.required).map(({ rule, index })=>{
1995
- const effect = getEffectDescription(rule);
2978
+ rules.map(_temp19).filter(_temp20).map((t11)=>{
2979
+ const { rule: rule_4, index: index_4 } = t11;
2980
+ const effect_0 = getEffectDescription(rule_4);
1996
2981
  return /*#__PURE__*/ jsx("div", {
1997
2982
  className: "group border rounded-lg p-3 hover:border-primary/50 transition-colors",
1998
2983
  children: /*#__PURE__*/ jsxs("div", {
@@ -2005,14 +2990,14 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
2005
2990
  className: "flex items-center gap-2 mb-1",
2006
2991
  children: [
2007
2992
  /*#__PURE__*/ jsx("span", {
2008
- className: `text-xs font-medium px-2 py-0.5 rounded ${effect.color}`,
2009
- children: effect.label
2993
+ className: `text-xs font-medium px-2 py-0.5 rounded ${effect_0.color}`,
2994
+ children: effect_0.label
2010
2995
  }),
2011
- rule.conditions.length > 1 && /*#__PURE__*/ jsxs("span", {
2996
+ rule_4.conditions.length > 1 && /*#__PURE__*/ jsxs("span", {
2012
2997
  className: "text-xs text-muted-foreground",
2013
2998
  children: [
2014
2999
  "(",
2015
- rule.operator,
3000
+ rule_4.operator,
2016
3001
  ")"
2017
3002
  ]
2018
3003
  })
@@ -2020,7 +3005,7 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
2020
3005
  }),
2021
3006
  /*#__PURE__*/ jsx("p", {
2022
3007
  className: "text-sm text-muted-foreground truncate",
2023
- children: describeRule(rule)
3008
+ children: describeRule(rule_4)
2024
3009
  })
2025
3010
  ]
2026
3011
  }),
@@ -2031,7 +3016,7 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
2031
3016
  variant: "ghost",
2032
3017
  size: "sm",
2033
3018
  className: "h-7 w-7 p-0",
2034
- onClick: ()=>editRule(index),
3019
+ onClick: ()=>editRule(index_4),
2035
3020
  children: /*#__PURE__*/ jsx(Settings, {
2036
3021
  className: "h-3.5 w-3.5"
2037
3022
  })
@@ -2040,7 +3025,7 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
2040
3025
  variant: "ghost",
2041
3026
  size: "sm",
2042
3027
  className: "h-7 w-7 p-0 text-destructive hover:text-destructive",
2043
- onClick: ()=>deleteRule(index),
3028
+ onClick: ()=>deleteRule(index_4),
2044
3029
  children: /*#__PURE__*/ jsx(Trash2, {
2045
3030
  className: "h-3.5 w-3.5"
2046
3031
  })
@@ -2049,232 +3034,111 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
2049
3034
  })
2050
3035
  ]
2051
3036
  })
2052
- }, index);
3037
+ }, index_4);
2053
3038
  })
2054
3039
  ]
2055
3040
  }),
2056
- isAddingRule ? /*#__PURE__*/ jsxs("div", {
2057
- className: "border rounded-lg p-4 space-y-4 bg-muted/20",
2058
- children: [
2059
- /*#__PURE__*/ jsxs("div", {
2060
- className: "flex items-center justify-between",
2061
- children: [
2062
- /*#__PURE__*/ jsx(Label, {
2063
- className: "font-medium",
2064
- children: null !== editingRuleIndex ? 'Edit rule' : 'New rule'
2065
- }),
2066
- /*#__PURE__*/ jsx(Button, {
2067
- variant: "ghost",
2068
- size: "sm",
2069
- onClick: resetBuilder,
2070
- children: "Cancel"
2071
- })
2072
- ]
2073
- }),
2074
- /*#__PURE__*/ jsxs("div", {
2075
- className: "space-y-2",
2076
- children: [
2077
- /*#__PURE__*/ jsx(Label, {
2078
- className: "text-xs text-muted-foreground",
2079
- children: "When conditions are met:"
2080
- }),
2081
- /*#__PURE__*/ jsx("div", {
2082
- className: "grid grid-cols-2 gap-2",
2083
- children: RULE_EFFECTS.map((effect)=>/*#__PURE__*/ jsxs("button", {
2084
- type: "button",
2085
- className: `flex items-center gap-2 p-2 rounded-lg border text-left text-sm transition-all ${selectedEffect === effect.value ? effect.color + ' border-current' : 'hover:bg-muted'}`,
2086
- onClick: ()=>setSelectedEffect(effect.value),
2087
- children: [
2088
- /*#__PURE__*/ jsx(effect.Icon, {
2089
- className: "h-4 w-4"
2090
- }),
2091
- /*#__PURE__*/ jsx("span", {
2092
- className: "font-medium",
2093
- children: effect.label
2094
- })
2095
- ]
2096
- }, effect.value))
2097
- })
2098
- ]
2099
- }),
2100
- /*#__PURE__*/ jsxs("div", {
2101
- className: "space-y-3",
2102
- children: [
2103
- /*#__PURE__*/ jsxs("div", {
2104
- className: "flex items-center justify-between",
2105
- children: [
2106
- /*#__PURE__*/ jsx(Label, {
2107
- className: "text-xs text-muted-foreground",
2108
- children: "Conditions:"
2109
- }),
2110
- conditions.length > 1 && /*#__PURE__*/ jsxs(Select, {
2111
- value: conditionOperator,
2112
- onValueChange: (v)=>setConditionOperator(v),
2113
- children: [
2114
- /*#__PURE__*/ jsx(SelectTrigger, {
2115
- className: "w-24 h-7 text-xs",
2116
- children: /*#__PURE__*/ jsx(SelectValue, {})
2117
- }),
2118
- /*#__PURE__*/ jsxs(SelectContent, {
2119
- children: [
2120
- /*#__PURE__*/ jsx(SelectItem, {
2121
- value: "AND",
2122
- children: "Match ALL"
2123
- }),
2124
- /*#__PURE__*/ jsx(SelectItem, {
2125
- value: "OR",
2126
- children: "Match ANY"
2127
- })
2128
- ]
2129
- })
2130
- ]
2131
- })
2132
- ]
2133
- }),
2134
- conditions.map((cond, index)=>/*#__PURE__*/ jsxs("div", {
2135
- className: "space-y-2",
2136
- children: [
2137
- index > 0 && /*#__PURE__*/ jsxs("div", {
2138
- className: "flex items-center gap-2 text-xs text-muted-foreground",
2139
- children: [
2140
- /*#__PURE__*/ jsx(Separator, {
2141
- className: "flex-1"
2142
- }),
2143
- /*#__PURE__*/ jsx("span", {
2144
- children: conditionOperator
2145
- }),
2146
- /*#__PURE__*/ jsx(Separator, {
2147
- className: "flex-1"
2148
- })
2149
- ]
2150
- }),
2151
- /*#__PURE__*/ jsxs("div", {
2152
- className: "flex gap-2 items-start",
2153
- children: [
2154
- /*#__PURE__*/ jsxs("div", {
2155
- className: "flex-1 space-y-2",
2156
- children: [
2157
- /*#__PURE__*/ jsxs(Select, {
2158
- value: cond.field,
2159
- onValueChange: (v)=>updateCondition(index, {
2160
- field: v
2161
- }),
2162
- children: [
2163
- /*#__PURE__*/ jsx(SelectTrigger, {
2164
- className: "h-8 text-sm",
2165
- children: /*#__PURE__*/ jsx(SelectValue, {
2166
- placeholder: "Select field..."
2167
- })
2168
- }),
2169
- /*#__PURE__*/ jsx(SelectContent, {
2170
- children: allFields.map((field)=>/*#__PURE__*/ jsx(SelectItem, {
2171
- value: field.name,
2172
- children: field.label
2173
- }, field.id))
2174
- })
2175
- ]
2176
- }),
2177
- /*#__PURE__*/ jsxs("div", {
2178
- className: "flex gap-2",
2179
- children: [
2180
- /*#__PURE__*/ jsxs(Select, {
2181
- value: cond.operator,
2182
- onValueChange: (v)=>updateCondition(index, {
2183
- operator: v
2184
- }),
2185
- children: [
2186
- /*#__PURE__*/ jsx(SelectTrigger, {
2187
- className: "w-32 h-8 text-sm",
2188
- children: /*#__PURE__*/ jsx(SelectValue, {})
2189
- }),
2190
- /*#__PURE__*/ jsx(SelectContent, {
2191
- children: CONDITION_OPERATORS.map((op)=>/*#__PURE__*/ jsx(SelectItem, {
2192
- value: op.value,
2193
- children: op.label
2194
- }, op.value))
2195
- })
2196
- ]
2197
- }),
2198
- /*#__PURE__*/ jsx("div", {
2199
- className: "flex-1",
2200
- children: cond.field && getFieldOptions(cond.field).length > 0 && ('is' === cond.operator || 'isNot' === cond.operator) ? /*#__PURE__*/ jsxs(Select, {
2201
- value: cond.value,
2202
- onValueChange: (v)=>updateCondition(index, {
2203
- value: v
2204
- }),
2205
- children: [
2206
- /*#__PURE__*/ jsx(SelectTrigger, {
2207
- className: "h-8 text-sm",
2208
- children: /*#__PURE__*/ jsx(SelectValue, {
2209
- placeholder: "Select value..."
2210
- })
2211
- }),
2212
- /*#__PURE__*/ jsx(SelectContent, {
2213
- children: getFieldOptions(cond.field).map((opt)=>/*#__PURE__*/ jsx(SelectItem, {
2214
- value: String(opt.value),
2215
- children: opt.label
2216
- }, String(opt.value)))
2217
- })
2218
- ]
2219
- }) : /*#__PURE__*/ jsx(Input, {
2220
- className: "h-8 text-sm",
2221
- placeholder: 'in' === cond.operator || 'notIn' === cond.operator ? 'value1, value2, ...' : 'matches' === cond.operator ? 'regex pattern' : 'value',
2222
- value: cond.value,
2223
- onChange: (e)=>updateCondition(index, {
2224
- value: e.target.value
2225
- })
2226
- })
2227
- })
2228
- ]
2229
- })
2230
- ]
2231
- }),
2232
- conditions.length > 1 && /*#__PURE__*/ jsx(Button, {
2233
- variant: "ghost",
2234
- size: "sm",
2235
- className: "h-8 w-8 p-0 text-muted-foreground",
2236
- onClick: ()=>removeCondition(index),
2237
- children: /*#__PURE__*/ jsx(Trash2, {
2238
- className: "h-3.5 w-3.5"
2239
- })
2240
- })
2241
- ]
2242
- })
2243
- ]
2244
- }, index)),
2245
- /*#__PURE__*/ jsxs(Button, {
2246
- variant: "outline",
2247
- size: "sm",
2248
- className: "w-full",
2249
- onClick: addCondition,
2250
- children: [
2251
- /*#__PURE__*/ jsx(Plus, {
2252
- className: "h-3 w-3 mr-2"
2253
- }),
2254
- "Add condition"
2255
- ]
2256
- })
2257
- ]
2258
- }),
2259
- /*#__PURE__*/ jsx(Button, {
2260
- className: "w-full",
2261
- onClick: saveRule,
2262
- disabled: !conditions.some((c)=>c.field),
2263
- children: null !== editingRuleIndex ? 'Update rule' : 'Add rule'
2264
- })
2265
- ]
2266
- }) : /*#__PURE__*/ jsxs(Button, {
2267
- variant: "outline",
2268
- className: "w-full",
2269
- onClick: ()=>setIsAddingRule(true),
2270
- children: [
2271
- /*#__PURE__*/ jsx(Plus, {
2272
- className: "h-4 w-4 mr-2"
2273
- }),
2274
- "Add conditional rule"
2275
- ]
2276
- })
3041
+ t12
2277
3042
  ]
2278
3043
  });
2279
3044
  }
3045
+ function _temp24(c_0) {
3046
+ return c_0.field;
3047
+ }
3048
+ function _temp23(opt) {
3049
+ return /*#__PURE__*/ jsx(SelectItem, {
3050
+ value: String(opt.value),
3051
+ children: opt.label
3052
+ }, String(opt.value));
3053
+ }
3054
+ function _temp22(op) {
3055
+ return /*#__PURE__*/ jsx(SelectItem, {
3056
+ value: op.value,
3057
+ children: op.label
3058
+ }, op.value);
3059
+ }
3060
+ function _temp21(field_1) {
3061
+ return /*#__PURE__*/ jsx(SelectItem, {
3062
+ value: field_1.name,
3063
+ children: field_1.label
3064
+ }, field_1.id);
3065
+ }
3066
+ function _temp20(t0) {
3067
+ const { rule: rule_3 } = t0;
3068
+ return rule_3.conditions.length > 0 || !rule_3.effects.required;
3069
+ }
3070
+ function _temp19(rule_2, index_3) {
3071
+ return {
3072
+ rule: rule_2,
3073
+ index: index_3
3074
+ };
3075
+ }
3076
+ function _temp18(r_2) {
3077
+ return r_2.conditions.length > 0 || !r_2.effects.required;
3078
+ }
3079
+ function _temp17(r_1) {
3080
+ return !(r_1.effects.required && 0 === r_1.conditions.length);
3081
+ }
3082
+ function _temp16(r_0) {
3083
+ return !(r_0.effects.required && 0 === r_0.conditions.length);
3084
+ }
3085
+ function _temp15(rule_1) {
3086
+ if (true === rule_1.effects.visible) return {
3087
+ label: "Show",
3088
+ color: "text-green-600 bg-green-50"
3089
+ };
3090
+ if (false === rule_1.effects.visible) return {
3091
+ label: "Hide",
3092
+ color: "text-orange-600 bg-orange-50"
3093
+ };
3094
+ if (true === rule_1.effects.required) return {
3095
+ label: "Required",
3096
+ color: "text-red-600 bg-red-50"
3097
+ };
3098
+ if (true === rule_1.effects.disabled) return {
3099
+ label: "Disabled",
3100
+ color: "text-gray-600 bg-gray-50"
3101
+ };
3102
+ return {
3103
+ label: "Unknown",
3104
+ color: "text-muted-foreground bg-muted"
3105
+ };
3106
+ }
3107
+ function _temp14(v_2) {
3108
+ return JSON.stringify(v_2);
3109
+ }
3110
+ function _temp13(v_1) {
3111
+ return JSON.stringify(v_1);
3112
+ }
3113
+ function _temp12(cond_0) {
3114
+ let operator = "is";
3115
+ let value = "";
3116
+ if (void 0 !== cond_0.is) {
3117
+ operator = "is";
3118
+ value = String(cond_0.is);
3119
+ } else if (void 0 !== cond_0.isNot) {
3120
+ operator = "isNot";
3121
+ value = String(cond_0.isNot);
3122
+ } else if (void 0 !== cond_0.in) {
3123
+ operator = "in";
3124
+ value = cond_0.in.map(String).join(", ");
3125
+ } else if (void 0 !== cond_0.notIn) {
3126
+ operator = "notIn";
3127
+ value = cond_0.notIn.map(String).join(", ");
3128
+ } else if (void 0 !== cond_0.matches) {
3129
+ operator = "matches";
3130
+ value = cond_0.matches;
3131
+ }
3132
+ return {
3133
+ field: cond_0.when,
3134
+ operator,
3135
+ value
3136
+ };
3137
+ }
3138
+ function _temp11(c) {
3139
+ return c.field;
3140
+ }
3141
+ function _temp10(r) {
3142
+ return true === r.effects.required && 0 === r.conditions.length;
3143
+ }
2280
3144
  export { FormDesigner };