@uipath/apollo-wind 0.7.2-pr188.4865fad

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 (254) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +188 -0
  3. package/dist/components/forms/data-fetcher.cjs +250 -0
  4. package/dist/components/forms/data-fetcher.d.ts +173 -0
  5. package/dist/components/forms/data-fetcher.js +207 -0
  6. package/dist/components/forms/demo-mocks.cjs +1031 -0
  7. package/dist/components/forms/demo-mocks.d.ts +10 -0
  8. package/dist/components/forms/demo-mocks.js +997 -0
  9. package/dist/components/forms/field-renderer.cjs +595 -0
  10. package/dist/components/forms/field-renderer.d.ts +14 -0
  11. package/dist/components/forms/field-renderer.js +561 -0
  12. package/dist/components/forms/form-designer.cjs +2314 -0
  13. package/dist/components/forms/form-designer.d.ts +1 -0
  14. package/dist/components/forms/form-designer.js +2280 -0
  15. package/dist/components/forms/form-examples.cjs +962 -0
  16. package/dist/components/forms/form-examples.d.ts +46 -0
  17. package/dist/components/forms/form-examples.js +907 -0
  18. package/dist/components/forms/form-plugins.cjs +225 -0
  19. package/dist/components/forms/form-plugins.d.ts +11 -0
  20. package/dist/components/forms/form-plugins.js +176 -0
  21. package/dist/components/forms/form-schema.cjs +56 -0
  22. package/dist/components/forms/form-schema.d.ts +324 -0
  23. package/dist/components/forms/form-schema.js +13 -0
  24. package/dist/components/forms/form-state-viewer.cjs +498 -0
  25. package/dist/components/forms/form-state-viewer.d.ts +15 -0
  26. package/dist/components/forms/form-state-viewer.js +464 -0
  27. package/dist/components/forms/index.cjs +103 -0
  28. package/dist/components/forms/index.d.ts +13 -0
  29. package/dist/components/forms/index.js +9 -0
  30. package/dist/components/forms/metadata-form.cjs +400 -0
  31. package/dist/components/forms/metadata-form.d.ts +16 -0
  32. package/dist/components/forms/metadata-form.js +366 -0
  33. package/dist/components/forms/rules-engine.cjs +343 -0
  34. package/dist/components/forms/rules-engine.d.ts +99 -0
  35. package/dist/components/forms/rules-engine.js +293 -0
  36. package/dist/components/forms/schema-serializer.cjs +250 -0
  37. package/dist/components/forms/schema-serializer.d.ts +27 -0
  38. package/dist/components/forms/schema-serializer.js +213 -0
  39. package/dist/components/forms/schema-viewer.cjs +157 -0
  40. package/dist/components/forms/schema-viewer.d.ts +29 -0
  41. package/dist/components/forms/schema-viewer.js +117 -0
  42. package/dist/components/forms/validation-converter.cjs +154 -0
  43. package/dist/components/forms/validation-converter.d.ts +42 -0
  44. package/dist/components/forms/validation-converter.js +114 -0
  45. package/dist/components/ui/accordion.cjs +82 -0
  46. package/dist/components/ui/accordion.d.ts +7 -0
  47. package/dist/components/ui/accordion.js +39 -0
  48. package/dist/components/ui/alert-dialog.cjs +126 -0
  49. package/dist/components/ui/alert-dialog.d.ts +20 -0
  50. package/dist/components/ui/alert-dialog.js +62 -0
  51. package/dist/components/ui/alert.cjs +77 -0
  52. package/dist/components/ui/alert.d.ts +8 -0
  53. package/dist/components/ui/alert.js +37 -0
  54. package/dist/components/ui/aspect-ratio.cjs +38 -0
  55. package/dist/components/ui/aspect-ratio.d.ts +3 -0
  56. package/dist/components/ui/aspect-ratio.js +4 -0
  57. package/dist/components/ui/avatar.cjs +63 -0
  58. package/dist/components/ui/avatar.d.ts +6 -0
  59. package/dist/components/ui/avatar.js +23 -0
  60. package/dist/components/ui/badge.cjs +63 -0
  61. package/dist/components/ui/badge.d.ts +9 -0
  62. package/dist/components/ui/badge.js +26 -0
  63. package/dist/components/ui/breadcrumb.cjs +118 -0
  64. package/dist/components/ui/breadcrumb.d.ts +19 -0
  65. package/dist/components/ui/breadcrumb.js +66 -0
  66. package/dist/components/ui/button-group.cjs +68 -0
  67. package/dist/components/ui/button-group.d.ts +14 -0
  68. package/dist/components/ui/button-group.js +28 -0
  69. package/dist/components/ui/button.cjs +78 -0
  70. package/dist/components/ui/button.d.ts +11 -0
  71. package/dist/components/ui/button.js +41 -0
  72. package/dist/components/ui/calendar.cjs +144 -0
  73. package/dist/components/ui/calendar.d.ts +8 -0
  74. package/dist/components/ui/calendar.js +107 -0
  75. package/dist/components/ui/card.cjs +89 -0
  76. package/dist/components/ui/card.d.ts +8 -0
  77. package/dist/components/ui/card.js +40 -0
  78. package/dist/components/ui/checkbox.cjs +52 -0
  79. package/dist/components/ui/checkbox.d.ts +6 -0
  80. package/dist/components/ui/checkbox.js +18 -0
  81. package/dist/components/ui/collapsible.cjs +45 -0
  82. package/dist/components/ui/collapsible.d.ts +5 -0
  83. package/dist/components/ui/collapsible.js +5 -0
  84. package/dist/components/ui/combobox.cjs +102 -0
  85. package/dist/components/ui/combobox.d.ts +15 -0
  86. package/dist/components/ui/combobox.js +68 -0
  87. package/dist/components/ui/command.cjs +131 -0
  88. package/dist/components/ui/command.d.ts +80 -0
  89. package/dist/components/ui/command.js +73 -0
  90. package/dist/components/ui/context-menu.cjs +173 -0
  91. package/dist/components/ui/context-menu.d.ts +27 -0
  92. package/dist/components/ui/context-menu.js +97 -0
  93. package/dist/components/ui/data-table.cjs +292 -0
  94. package/dist/components/ui/data-table.d.ts +23 -0
  95. package/dist/components/ui/data-table.js +252 -0
  96. package/dist/components/ui/date-picker.cjs +118 -0
  97. package/dist/components/ui/date-picker.d.ts +21 -0
  98. package/dist/components/ui/date-picker.js +81 -0
  99. package/dist/components/ui/datetime-picker.cjs +154 -0
  100. package/dist/components/ui/datetime-picker.d.ts +9 -0
  101. package/dist/components/ui/datetime-picker.js +120 -0
  102. package/dist/components/ui/dialog.cjs +159 -0
  103. package/dist/components/ui/dialog.d.ts +15 -0
  104. package/dist/components/ui/dialog.js +98 -0
  105. package/dist/components/ui/drawer.cjs +116 -0
  106. package/dist/components/ui/drawer.d.ts +18 -0
  107. package/dist/components/ui/drawer.js +55 -0
  108. package/dist/components/ui/dropdown-menu.cjs +174 -0
  109. package/dist/components/ui/dropdown-menu.d.ts +27 -0
  110. package/dist/components/ui/dropdown-menu.js +98 -0
  111. package/dist/components/ui/editable-cell.cjs +256 -0
  112. package/dist/components/ui/editable-cell.d.ts +24 -0
  113. package/dist/components/ui/editable-cell.js +219 -0
  114. package/dist/components/ui/empty-state.cjs +73 -0
  115. package/dist/components/ui/empty-state.d.ts +16 -0
  116. package/dist/components/ui/empty-state.js +39 -0
  117. package/dist/components/ui/file-upload.cjs +236 -0
  118. package/dist/components/ui/file-upload.d.ts +10 -0
  119. package/dist/components/ui/file-upload.js +202 -0
  120. package/dist/components/ui/hover-card.cjs +55 -0
  121. package/dist/components/ui/hover-card.d.ts +6 -0
  122. package/dist/components/ui/hover-card.js +15 -0
  123. package/dist/components/ui/index.cjs +546 -0
  124. package/dist/components/ui/index.d.ts +55 -0
  125. package/dist/components/ui/index.js +55 -0
  126. package/dist/components/ui/input.cjs +45 -0
  127. package/dist/components/ui/input.d.ts +5 -0
  128. package/dist/components/ui/input.js +11 -0
  129. package/dist/components/ui/label.cjs +47 -0
  130. package/dist/components/ui/label.d.ts +7 -0
  131. package/dist/components/ui/label.js +13 -0
  132. package/dist/components/ui/layout/column.cjs +84 -0
  133. package/dist/components/ui/layout/column.d.ts +21 -0
  134. package/dist/components/ui/layout/column.js +50 -0
  135. package/dist/components/ui/layout/grid.cjs +101 -0
  136. package/dist/components/ui/layout/grid.d.ts +22 -0
  137. package/dist/components/ui/layout/grid.js +67 -0
  138. package/dist/components/ui/layout/index.cjs +44 -0
  139. package/dist/components/ui/layout/index.d.ts +7 -0
  140. package/dist/components/ui/layout/index.js +4 -0
  141. package/dist/components/ui/layout/row.cjs +84 -0
  142. package/dist/components/ui/layout/row.d.ts +21 -0
  143. package/dist/components/ui/layout/row.js +50 -0
  144. package/dist/components/ui/layout/types.cjs +18 -0
  145. package/dist/components/ui/layout/types.d.ts +149 -0
  146. package/dist/components/ui/layout/types.js +0 -0
  147. package/dist/components/ui/layout/utils.cjs +324 -0
  148. package/dist/components/ui/layout/utils.d.ts +76 -0
  149. package/dist/components/ui/layout/utils.js +239 -0
  150. package/dist/components/ui/menubar.cjs +210 -0
  151. package/dist/components/ui/menubar.d.ts +28 -0
  152. package/dist/components/ui/menubar.js +131 -0
  153. package/dist/components/ui/multi-select.cjs +187 -0
  154. package/dist/components/ui/multi-select.d.ts +18 -0
  155. package/dist/components/ui/multi-select.js +153 -0
  156. package/dist/components/ui/navigation-menu.cjs +122 -0
  157. package/dist/components/ui/navigation-menu.d.ts +12 -0
  158. package/dist/components/ui/navigation-menu.js +64 -0
  159. package/dist/components/ui/pagination.cjs +131 -0
  160. package/dist/components/ui/pagination.d.ts +28 -0
  161. package/dist/components/ui/pagination.js +79 -0
  162. package/dist/components/ui/popover.cjs +61 -0
  163. package/dist/components/ui/popover.d.ts +7 -0
  164. package/dist/components/ui/popover.js +18 -0
  165. package/dist/components/ui/progress.cjs +51 -0
  166. package/dist/components/ui/progress.d.ts +4 -0
  167. package/dist/components/ui/progress.js +17 -0
  168. package/dist/components/ui/radio-group.cjs +61 -0
  169. package/dist/components/ui/radio-group.d.ts +5 -0
  170. package/dist/components/ui/radio-group.js +24 -0
  171. package/dist/components/ui/resizable.cjs +60 -0
  172. package/dist/components/ui/resizable.d.ts +23 -0
  173. package/dist/components/ui/resizable.js +20 -0
  174. package/dist/components/ui/scroll-area.cjs +67 -0
  175. package/dist/components/ui/scroll-area.d.ts +5 -0
  176. package/dist/components/ui/scroll-area.js +30 -0
  177. package/dist/components/ui/search.cjs +153 -0
  178. package/dist/components/ui/search.d.ts +19 -0
  179. package/dist/components/ui/search.js +116 -0
  180. package/dist/components/ui/select.cjs +151 -0
  181. package/dist/components/ui/select.d.ts +13 -0
  182. package/dist/components/ui/select.js +90 -0
  183. package/dist/components/ui/separator.cjs +47 -0
  184. package/dist/components/ui/separator.d.ts +4 -0
  185. package/dist/components/ui/separator.js +13 -0
  186. package/dist/components/ui/sheet.cjs +142 -0
  187. package/dist/components/ui/sheet.d.ts +25 -0
  188. package/dist/components/ui/sheet.js +81 -0
  189. package/dist/components/ui/skeleton.cjs +43 -0
  190. package/dist/components/ui/skeleton.d.ts +2 -0
  191. package/dist/components/ui/skeleton.js +9 -0
  192. package/dist/components/ui/slider.cjs +63 -0
  193. package/dist/components/ui/slider.d.ts +4 -0
  194. package/dist/components/ui/slider.js +29 -0
  195. package/dist/components/ui/sonner.cjs +76 -0
  196. package/dist/components/ui/sonner.d.ts +4 -0
  197. package/dist/components/ui/sonner.js +39 -0
  198. package/dist/components/ui/spinner.cjs +78 -0
  199. package/dist/components/ui/spinner.d.ts +11 -0
  200. package/dist/components/ui/spinner.js +41 -0
  201. package/dist/components/ui/stats-card.cjs +102 -0
  202. package/dist/components/ui/stats-card.d.ts +15 -0
  203. package/dist/components/ui/stats-card.js +68 -0
  204. package/dist/components/ui/stepper.cjs +99 -0
  205. package/dist/components/ui/stepper.d.ts +14 -0
  206. package/dist/components/ui/stepper.js +65 -0
  207. package/dist/components/ui/switch.cjs +48 -0
  208. package/dist/components/ui/switch.d.ts +4 -0
  209. package/dist/components/ui/switch.js +14 -0
  210. package/dist/components/ui/table.cjs +110 -0
  211. package/dist/components/ui/table.d.ts +10 -0
  212. package/dist/components/ui/table.js +55 -0
  213. package/dist/components/ui/tabs.cjs +67 -0
  214. package/dist/components/ui/tabs.d.ts +7 -0
  215. package/dist/components/ui/tabs.js +24 -0
  216. package/dist/components/ui/textarea.cjs +44 -0
  217. package/dist/components/ui/textarea.d.ts +4 -0
  218. package/dist/components/ui/textarea.js +10 -0
  219. package/dist/components/ui/toggle-group.cjs +73 -0
  220. package/dist/components/ui/toggle-group.d.ts +12 -0
  221. package/dist/components/ui/toggle-group.js +36 -0
  222. package/dist/components/ui/toggle.cjs +71 -0
  223. package/dist/components/ui/toggle.d.ts +12 -0
  224. package/dist/components/ui/toggle.js +34 -0
  225. package/dist/components/ui/tooltip.cjs +58 -0
  226. package/dist/components/ui/tooltip.d.ts +7 -0
  227. package/dist/components/ui/tooltip.js +15 -0
  228. package/dist/examples/admin-layout-example.d.ts +92 -0
  229. package/dist/examples/app-shell-example.d.ts +52 -0
  230. package/dist/examples/dashboard-example.d.ts +11 -0
  231. package/dist/examples/data-management-example.d.ts +1 -0
  232. package/dist/examples/flow-editor-layout-example.d.ts +22 -0
  233. package/dist/examples/flow-start-example.d.ts +30 -0
  234. package/dist/examples/form-builder-example.d.ts +1 -0
  235. package/dist/examples/new-project-example.d.ts +30 -0
  236. package/dist/examples/settings-example.d.ts +1 -0
  237. package/dist/examples/vscode-example.d.ts +80 -0
  238. package/dist/index.cjs +830 -0
  239. package/dist/index.d.ts +86 -0
  240. package/dist/index.js +67 -0
  241. package/dist/lib/index.cjs +42 -0
  242. package/dist/lib/index.d.ts +1 -0
  243. package/dist/lib/index.js +2 -0
  244. package/dist/lib/utils.cjs +70 -0
  245. package/dist/lib/utils.d.ts +14 -0
  246. package/dist/lib/utils.js +30 -0
  247. package/dist/postcss.config.export.cjs +43 -0
  248. package/dist/postcss.config.export.js +9 -0
  249. package/dist/styles.css +6868 -0
  250. package/dist/tailwind.css +239 -0
  251. package/dist/tailwind.preset.cjs +77 -0
  252. package/dist/tailwind.preset.js +43 -0
  253. package/package.json +157 -0
  254. package/postcss.config.export.js +9 -0
@@ -0,0 +1,2314 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ FormDesigner: ()=>FormDesigner
28
+ });
29
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
+ const external_react_namespaceObject = require("react");
31
+ const external_schema_serializer_cjs_namespaceObject = require("./schema-serializer.cjs");
32
+ const external_metadata_form_cjs_namespaceObject = require("./metadata-form.cjs");
33
+ const button_cjs_namespaceObject = require("../ui/button.cjs");
34
+ const input_cjs_namespaceObject = require("../ui/input.cjs");
35
+ const label_cjs_namespaceObject = require("../ui/label.cjs");
36
+ const textarea_cjs_namespaceObject = require("../ui/textarea.cjs");
37
+ const select_cjs_namespaceObject = require("../ui/select.cjs");
38
+ const card_cjs_namespaceObject = require("../ui/card.cjs");
39
+ const tabs_cjs_namespaceObject = require("../ui/tabs.cjs");
40
+ const checkbox_cjs_namespaceObject = require("../ui/checkbox.cjs");
41
+ const switch_cjs_namespaceObject = require("../ui/switch.cjs");
42
+ const external_lucide_react_namespaceObject = require("lucide-react");
43
+ const separator_cjs_namespaceObject = require("../ui/separator.cjs");
44
+ const accordion_cjs_namespaceObject = require("../ui/accordion.cjs");
45
+ const grid_cjs_namespaceObject = require("../ui/layout/grid.cjs");
46
+ const FIELD_TYPE_METADATA = [
47
+ {
48
+ value: 'text',
49
+ label: 'Text',
50
+ category: 'Input',
51
+ description: 'Single-line text input'
52
+ },
53
+ {
54
+ value: 'email',
55
+ label: 'Email',
56
+ category: 'Input',
57
+ description: 'Email with validation'
58
+ },
59
+ {
60
+ value: 'textarea',
61
+ label: 'Textarea',
62
+ category: 'Input',
63
+ description: 'Multi-line text input'
64
+ },
65
+ {
66
+ value: 'number',
67
+ label: 'Number',
68
+ category: 'Input',
69
+ description: 'Numeric input with min/max'
70
+ },
71
+ {
72
+ value: 'date',
73
+ label: 'Date',
74
+ category: 'Input',
75
+ description: 'Date picker'
76
+ },
77
+ {
78
+ value: 'datetime',
79
+ label: 'Date & Time',
80
+ category: 'Input',
81
+ description: 'Date and time picker'
82
+ },
83
+ {
84
+ value: 'file',
85
+ label: 'File Upload',
86
+ category: 'Input',
87
+ description: 'File upload control'
88
+ },
89
+ {
90
+ value: 'select',
91
+ label: 'Select Dropdown',
92
+ category: 'Selection',
93
+ description: 'Single-select dropdown'
94
+ },
95
+ {
96
+ value: 'multiselect',
97
+ label: 'Multi-Select',
98
+ category: 'Selection',
99
+ description: 'Multi-select with search'
100
+ },
101
+ {
102
+ value: 'radio',
103
+ label: 'Radio Group',
104
+ category: 'Selection',
105
+ description: 'Radio button group'
106
+ },
107
+ {
108
+ value: 'checkbox',
109
+ label: 'Checkbox',
110
+ category: 'Boolean',
111
+ description: 'Single checkbox'
112
+ },
113
+ {
114
+ value: 'switch',
115
+ label: 'Switch Toggle',
116
+ category: 'Boolean',
117
+ description: 'Toggle switch'
118
+ },
119
+ {
120
+ value: 'slider',
121
+ label: 'Slider',
122
+ category: 'Input',
123
+ description: 'Range slider'
124
+ },
125
+ {
126
+ value: 'custom',
127
+ label: 'Custom Component',
128
+ category: 'Advanced',
129
+ description: 'Custom field component'
130
+ }
131
+ ];
132
+ function buildValidationConfig(field) {
133
+ const { type, validation, rules } = field;
134
+ const config = {};
135
+ const messages = {};
136
+ const isAlwaysRequired = rules?.some((r)=>true === r.effects.required && 0 === r.conditions.length);
137
+ if (isAlwaysRequired) {
138
+ config.required = true;
139
+ if (validation?.requiredMessage) messages.required = validation.requiredMessage;
140
+ }
141
+ if (!validation && !isAlwaysRequired) return;
142
+ if (validation) {
143
+ if ('text' === type || 'textarea' === type || 'email' === type) {
144
+ const minLen = validation.minLength;
145
+ const maxLen = validation.maxLength;
146
+ const validLengthConstraints = null == minLen || null == maxLen || minLen <= maxLen;
147
+ if (validLengthConstraints) {
148
+ if (null != minLen) {
149
+ config.minLength = minLen;
150
+ if (validation.customMessage) messages.minLength = validation.customMessage;
151
+ }
152
+ if (null != maxLen) {
153
+ config.maxLength = maxLen;
154
+ if (validation.customMessage) messages.maxLength = validation.customMessage;
155
+ }
156
+ }
157
+ if (validation.pattern) try {
158
+ new RegExp(validation.pattern);
159
+ config.pattern = validation.pattern;
160
+ if (validation.patternMessage) messages.pattern = validation.patternMessage;
161
+ else if (validation.customMessage) messages.pattern = validation.customMessage;
162
+ } catch {}
163
+ }
164
+ if ('number' === type || 'slider' === type) {
165
+ if (validation.integer) {
166
+ config.integer = true;
167
+ if (validation.customMessage) messages.integer = validation.customMessage;
168
+ }
169
+ const minVal = field.min;
170
+ const maxVal = field.max;
171
+ const validRangeConstraints = null == minVal || null == maxVal || minVal <= maxVal;
172
+ if (validRangeConstraints) {
173
+ if (null != minVal) {
174
+ config.min = minVal;
175
+ if (validation.customMessage) messages.min = validation.customMessage;
176
+ }
177
+ if (null != maxVal) {
178
+ config.max = maxVal;
179
+ if (validation.customMessage) messages.max = validation.customMessage;
180
+ }
181
+ }
182
+ }
183
+ if ('file' === type) {
184
+ if (null != validation.maxFileSize) config.maxFileSize = validation.maxFileSize;
185
+ if (field.multiple && null != validation.maxFiles) {
186
+ config.maxItems = validation.maxFiles;
187
+ if (validation.customMessage) messages.maxItems = validation.customMessage;
188
+ }
189
+ }
190
+ if (validation.customMessage) messages.custom = validation.customMessage;
191
+ }
192
+ if (Object.keys(messages).length > 0) config.messages = messages;
193
+ return Object.keys(config).length > 0 ? config : void 0;
194
+ }
195
+ const createSectionConfigSchema = (section)=>({
196
+ id: 'section-config',
197
+ title: '',
198
+ sections: [
199
+ {
200
+ id: 'main',
201
+ title: 'Section settings',
202
+ fields: [
203
+ {
204
+ name: 'id',
205
+ type: 'text',
206
+ label: 'Section ID',
207
+ description: 'Unique identifier for this section'
208
+ },
209
+ {
210
+ name: 'title',
211
+ type: 'text',
212
+ label: 'Section title',
213
+ placeholder: 'Enter section title'
214
+ },
215
+ {
216
+ name: "description",
217
+ type: 'textarea',
218
+ label: "Description",
219
+ placeholder: "Optional section description",
220
+ rows: 2
221
+ },
222
+ {
223
+ name: 'collapsible',
224
+ type: 'switch',
225
+ label: 'Collapsible section'
226
+ },
227
+ {
228
+ name: 'defaultExpanded',
229
+ type: 'switch',
230
+ label: 'Expanded by default',
231
+ rules: [
232
+ {
233
+ id: 'show-when-collapsible',
234
+ conditions: [
235
+ {
236
+ when: 'collapsible',
237
+ is: true
238
+ }
239
+ ],
240
+ operator: 'AND',
241
+ effects: {
242
+ visible: true
243
+ }
244
+ }
245
+ ]
246
+ }
247
+ ]
248
+ }
249
+ ],
250
+ initialData: {
251
+ id: section.id,
252
+ title: section.title,
253
+ description: section.description || '',
254
+ collapsible: section.collapsible || false,
255
+ defaultExpanded: false !== section.defaultExpanded
256
+ },
257
+ actions: []
258
+ });
259
+ const createFieldConfigSchema = (field)=>({
260
+ id: 'field-config',
261
+ title: '',
262
+ sections: [
263
+ {
264
+ id: 'basic',
265
+ title: 'Basic settings',
266
+ fields: [
267
+ {
268
+ name: 'name',
269
+ type: 'text',
270
+ label: 'Field name',
271
+ placeholder: 'fieldName',
272
+ description: 'Internal identifier (camelCase recommended)'
273
+ },
274
+ {
275
+ name: 'label',
276
+ type: 'text',
277
+ label: 'Label',
278
+ placeholder: 'Field Label'
279
+ },
280
+ {
281
+ name: 'type',
282
+ type: 'select',
283
+ label: 'Field type',
284
+ options: FIELD_TYPE_METADATA.map((t)=>({
285
+ label: `${t.label} (${t.category})`,
286
+ value: t.value
287
+ }))
288
+ },
289
+ {
290
+ name: 'placeholder',
291
+ type: 'text',
292
+ label: 'Placeholder',
293
+ placeholder: 'Enter placeholder text...'
294
+ },
295
+ {
296
+ name: "description",
297
+ type: 'textarea',
298
+ label: "Description",
299
+ placeholder: 'Help text for this field',
300
+ rows: 2
301
+ }
302
+ ]
303
+ },
304
+ {
305
+ id: 'number-settings',
306
+ title: 'Number settings',
307
+ fields: [
308
+ {
309
+ name: 'min',
310
+ type: 'number',
311
+ label: 'Min'
312
+ },
313
+ {
314
+ name: 'max',
315
+ type: 'number',
316
+ label: 'Max'
317
+ },
318
+ {
319
+ name: 'step',
320
+ type: 'number',
321
+ label: 'Step'
322
+ }
323
+ ],
324
+ conditions: [
325
+ {
326
+ when: 'type',
327
+ in: [
328
+ 'number',
329
+ 'slider'
330
+ ]
331
+ }
332
+ ]
333
+ },
334
+ {
335
+ id: 'file-settings',
336
+ title: 'File settings',
337
+ fields: [
338
+ {
339
+ name: 'accept',
340
+ type: 'text',
341
+ label: 'Accepted file types',
342
+ placeholder: '.pdf,.doc,.docx',
343
+ description: 'Comma-separated file extensions'
344
+ },
345
+ {
346
+ name: 'multiple',
347
+ type: 'checkbox',
348
+ label: 'Allow multiple files'
349
+ }
350
+ ],
351
+ conditions: [
352
+ {
353
+ when: 'type',
354
+ is: 'file'
355
+ }
356
+ ]
357
+ },
358
+ {
359
+ id: 'text-validation',
360
+ title: 'Text validation',
361
+ fields: [
362
+ {
363
+ name: 'validation.minLength',
364
+ type: 'number',
365
+ label: 'Minimum length',
366
+ min: 0,
367
+ placeholder: '0'
368
+ },
369
+ {
370
+ name: 'validation.maxLength',
371
+ type: 'number',
372
+ label: 'Maximum length',
373
+ min: 0,
374
+ placeholder: 'No limit'
375
+ },
376
+ {
377
+ name: 'validation.pattern',
378
+ type: 'text',
379
+ label: 'Pattern (regex)',
380
+ placeholder: '^[A-Za-z]+$',
381
+ description: 'Regular expression pattern'
382
+ },
383
+ {
384
+ name: 'validation.patternMessage',
385
+ type: 'text',
386
+ label: 'Pattern error message',
387
+ placeholder: 'Invalid format',
388
+ rules: [
389
+ {
390
+ id: 'show-when-pattern',
391
+ conditions: [
392
+ {
393
+ when: 'validation.pattern',
394
+ isNot: ''
395
+ }
396
+ ],
397
+ operator: 'AND',
398
+ effects: {
399
+ visible: true
400
+ }
401
+ }
402
+ ]
403
+ }
404
+ ],
405
+ conditions: [
406
+ {
407
+ when: 'type',
408
+ in: [
409
+ 'text',
410
+ 'textarea',
411
+ 'email'
412
+ ]
413
+ }
414
+ ]
415
+ },
416
+ {
417
+ id: 'number-validation',
418
+ title: 'Number validation',
419
+ fields: [
420
+ {
421
+ name: 'validation.integer',
422
+ type: 'switch',
423
+ label: 'Integer only',
424
+ description: 'Only allow whole numbers'
425
+ }
426
+ ],
427
+ conditions: [
428
+ {
429
+ when: 'type',
430
+ in: [
431
+ 'number',
432
+ 'slider'
433
+ ]
434
+ }
435
+ ]
436
+ },
437
+ {
438
+ id: 'file-validation',
439
+ title: 'File validation',
440
+ fields: [
441
+ {
442
+ name: 'validation.maxFileSize',
443
+ type: 'number',
444
+ label: 'Max file size (MB)',
445
+ min: 0,
446
+ step: 0.1,
447
+ placeholder: 'No limit'
448
+ },
449
+ {
450
+ name: 'validation.maxFiles',
451
+ type: 'number',
452
+ label: 'Max number of files',
453
+ min: 1,
454
+ placeholder: 'No limit',
455
+ rules: [
456
+ {
457
+ id: 'show-when-multiple',
458
+ conditions: [
459
+ {
460
+ when: 'multiple',
461
+ is: true
462
+ }
463
+ ],
464
+ operator: 'AND',
465
+ effects: {
466
+ visible: true
467
+ }
468
+ }
469
+ ]
470
+ }
471
+ ],
472
+ conditions: [
473
+ {
474
+ when: 'type',
475
+ is: 'file'
476
+ }
477
+ ]
478
+ }
479
+ ],
480
+ initialData: {
481
+ name: field.name,
482
+ label: field.label,
483
+ type: field.type,
484
+ placeholder: field.placeholder || '',
485
+ description: field.description || '',
486
+ min: field.min,
487
+ max: field.max,
488
+ step: field.step,
489
+ accept: field.accept || '',
490
+ multiple: field.multiple || false,
491
+ validation: {
492
+ minLength: field.validation?.minLength,
493
+ maxLength: field.validation?.maxLength,
494
+ pattern: field.validation?.pattern || '',
495
+ patternMessage: field.validation?.patternMessage || '',
496
+ integer: field.validation?.integer || false,
497
+ maxFileSize: field.validation?.maxFileSize ? field.validation.maxFileSize / 1048576 : void 0,
498
+ maxFiles: field.validation?.maxFiles
499
+ }
500
+ },
501
+ actions: []
502
+ });
503
+ function SectionConfigForm({ section, onUpdate, existingSectionIds }) {
504
+ const [attemptedId, setAttemptedId] = (0, external_react_namespaceObject.useState)(null);
505
+ (0, external_react_namespaceObject.useEffect)(()=>{
506
+ setAttemptedId(null);
507
+ }, [
508
+ section.id
509
+ ]);
510
+ const isDuplicateId = null !== attemptedId && attemptedId !== section.id && existingSectionIds.has(attemptedId);
511
+ const schema = (0, external_react_namespaceObject.useMemo)(()=>createSectionConfigSchema(section), [
512
+ section
513
+ ]);
514
+ const plugins = (0, external_react_namespaceObject.useMemo)(()=>[
515
+ {
516
+ name: 'section-sync',
517
+ onValueChange: (_field, _value, context)=>{
518
+ const values = context.values;
519
+ const newId = values.id;
520
+ setAttemptedId(newId);
521
+ onUpdate({
522
+ id: newId,
523
+ title: values.title,
524
+ description: values.description || void 0,
525
+ collapsible: values.collapsible,
526
+ defaultExpanded: values.defaultExpanded
527
+ });
528
+ }
529
+ }
530
+ ], [
531
+ onUpdate
532
+ ]);
533
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
534
+ className: "space-y-4",
535
+ children: [
536
+ isDuplicateId && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
537
+ className: "flex items-center gap-2 p-2 bg-destructive/10 border border-destructive/20 rounded-md text-destructive text-sm",
538
+ children: [
539
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.AlertTriangle, {
540
+ className: "h-4 w-4 shrink-0"
541
+ }),
542
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
543
+ children: [
544
+ 'Section ID "',
545
+ attemptedId,
546
+ '" already exists. Please use a unique ID.'
547
+ ]
548
+ })
549
+ ]
550
+ }),
551
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_metadata_form_cjs_namespaceObject.MetadataForm, {
552
+ schema: schema,
553
+ plugins: plugins,
554
+ autoComplete: "off"
555
+ }, section.id),
556
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(separator_cjs_namespaceObject.Separator, {}),
557
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
558
+ className: "text-sm text-muted-foreground",
559
+ children: [
560
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("p", {
561
+ children: [
562
+ "This section contains ",
563
+ section.fields.length,
564
+ " field(s)."
565
+ ]
566
+ }),
567
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
568
+ className: "mt-1",
569
+ children: "Click on a field in the left panel to configure it."
570
+ })
571
+ ]
572
+ })
573
+ ]
574
+ });
575
+ }
576
+ function FieldConfigForm({ field, onUpdate, allFields, existingFieldNames }) {
577
+ const [attemptedName, setAttemptedName] = (0, external_react_namespaceObject.useState)(null);
578
+ (0, external_react_namespaceObject.useEffect)(()=>{
579
+ setAttemptedName(null);
580
+ }, [
581
+ field.id
582
+ ]);
583
+ const isDuplicateName = null !== attemptedName && attemptedName !== field.name && existingFieldNames.has(attemptedName);
584
+ const schema = (0, external_react_namespaceObject.useMemo)(()=>createFieldConfigSchema(field), [
585
+ field
586
+ ]);
587
+ const currentTypeRef = (0, external_react_namespaceObject.useMemo)(()=>({
588
+ type: field.type
589
+ }), [
590
+ field.type
591
+ ]);
592
+ const plugins = (0, external_react_namespaceObject.useMemo)(()=>[
593
+ {
594
+ name: 'field-sync',
595
+ onValueChange: (_fieldName, _value, context)=>{
596
+ const values = context.values;
597
+ const newType = values.type;
598
+ const newName = values.name;
599
+ const validationValues = values.validation;
600
+ setAttemptedName(newName);
601
+ const updates = {
602
+ name: newName,
603
+ label: values.label,
604
+ type: newType,
605
+ placeholder: values.placeholder || void 0,
606
+ description: values.description || void 0
607
+ };
608
+ const requiredMessage = validationValues?.requiredMessage || void 0;
609
+ if ('number' === newType || 'slider' === newType) {
610
+ updates.min = values.min;
611
+ updates.max = values.max;
612
+ updates.step = values.step;
613
+ updates.validation = {
614
+ integer: validationValues?.integer,
615
+ requiredMessage
616
+ };
617
+ } else if ('file' === newType) {
618
+ updates.accept = values.accept || void 0;
619
+ updates.multiple = values.multiple;
620
+ const maxFileSizeMB = validationValues?.maxFileSize;
621
+ updates.validation = {
622
+ maxFileSize: maxFileSizeMB ? 1024 * maxFileSizeMB * 1024 : void 0,
623
+ maxFiles: validationValues?.maxFiles,
624
+ requiredMessage
625
+ };
626
+ } else if ('text' === newType || 'textarea' === newType || 'email' === newType) updates.validation = {
627
+ minLength: validationValues?.minLength,
628
+ maxLength: validationValues?.maxLength,
629
+ pattern: validationValues?.pattern || void 0,
630
+ patternMessage: validationValues?.patternMessage || void 0,
631
+ requiredMessage
632
+ };
633
+ else if (requiredMessage) updates.validation = {
634
+ requiredMessage
635
+ };
636
+ if (newType !== currentTypeRef.type) {
637
+ const preservedRequiredMessage = field.validation?.requiredMessage;
638
+ updates.options = void 0;
639
+ updates.min = void 0;
640
+ updates.max = void 0;
641
+ updates.step = void 0;
642
+ updates.accept = void 0;
643
+ updates.multiple = void 0;
644
+ updates.validation = void 0;
645
+ if ('number' === newType || 'slider' === newType) {
646
+ updates.min = values.min;
647
+ updates.max = values.max;
648
+ updates.step = values.step;
649
+ updates.validation = {
650
+ integer: validationValues?.integer,
651
+ requiredMessage: preservedRequiredMessage
652
+ };
653
+ } else if ('file' === newType) {
654
+ updates.accept = values.accept || void 0;
655
+ updates.multiple = values.multiple;
656
+ const maxFileSizeMB = validationValues?.maxFileSize;
657
+ updates.validation = {
658
+ maxFileSize: maxFileSizeMB ? 1024 * maxFileSizeMB * 1024 : void 0,
659
+ maxFiles: validationValues?.maxFiles,
660
+ requiredMessage: preservedRequiredMessage
661
+ };
662
+ } else if ('text' === newType || 'textarea' === newType || 'email' === newType) updates.validation = {
663
+ minLength: validationValues?.minLength,
664
+ maxLength: validationValues?.maxLength,
665
+ pattern: validationValues?.pattern || void 0,
666
+ patternMessage: validationValues?.patternMessage || void 0,
667
+ requiredMessage: preservedRequiredMessage
668
+ };
669
+ else if (preservedRequiredMessage) updates.validation = {
670
+ requiredMessage: preservedRequiredMessage
671
+ };
672
+ currentTypeRef.type = newType;
673
+ }
674
+ onUpdate(updates);
675
+ }
676
+ }
677
+ ], [
678
+ onUpdate,
679
+ currentTypeRef,
680
+ field.validation?.requiredMessage
681
+ ]);
682
+ const needsOptions = [
683
+ 'select',
684
+ 'multiselect',
685
+ 'radio'
686
+ ].includes(field.type);
687
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
688
+ className: "space-y-2",
689
+ children: [
690
+ isDuplicateName && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
691
+ className: "flex items-center gap-2 p-2 bg-destructive/10 border border-destructive/20 rounded-md text-destructive text-sm",
692
+ children: [
693
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.AlertTriangle, {
694
+ className: "h-4 w-4 shrink-0"
695
+ }),
696
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
697
+ children: [
698
+ 'Field name "',
699
+ attemptedName,
700
+ '" already exists. Please use a unique name.'
701
+ ]
702
+ })
703
+ ]
704
+ }),
705
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_metadata_form_cjs_namespaceObject.MetadataForm, {
706
+ schema: schema,
707
+ plugins: plugins,
708
+ autoComplete: "off"
709
+ }, field.id),
710
+ needsOptions && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.Accordion, {
711
+ type: "multiple",
712
+ defaultValue: [
713
+ 'options'
714
+ ],
715
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(accordion_cjs_namespaceObject.AccordionItem, {
716
+ value: "options",
717
+ className: "border rounded-lg px-3",
718
+ children: [
719
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.AccordionTrigger, {
720
+ className: "text-sm font-medium",
721
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
722
+ className: "flex items-center gap-2",
723
+ children: [
724
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Database, {
725
+ className: "h-4 w-4"
726
+ }),
727
+ "Options"
728
+ ]
729
+ })
730
+ }),
731
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.AccordionContent, {
732
+ className: "pt-2",
733
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FieldOptionsEditor, {
734
+ options: field.options || [],
735
+ onChange: (options)=>onUpdate({
736
+ options
737
+ })
738
+ })
739
+ })
740
+ ]
741
+ })
742
+ }),
743
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.Accordion, {
744
+ type: "multiple",
745
+ defaultValue: [
746
+ 'data-source'
747
+ ],
748
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(accordion_cjs_namespaceObject.AccordionItem, {
749
+ value: "data-source",
750
+ className: "border rounded-lg px-3",
751
+ children: [
752
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.AccordionTrigger, {
753
+ className: "text-sm font-medium",
754
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
755
+ className: "flex items-center gap-2",
756
+ children: [
757
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Database, {
758
+ className: "h-4 w-4"
759
+ }),
760
+ "Data source"
761
+ ]
762
+ })
763
+ }),
764
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.AccordionContent, {
765
+ className: "pt-2",
766
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(DataSourceEditor, {
767
+ dataSource: field.dataSource,
768
+ onChange: (dataSource)=>onUpdate({
769
+ dataSource
770
+ })
771
+ })
772
+ })
773
+ ]
774
+ })
775
+ }),
776
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.Accordion, {
777
+ type: "multiple",
778
+ defaultValue: [
779
+ 'rules'
780
+ ],
781
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(accordion_cjs_namespaceObject.AccordionItem, {
782
+ value: "rules",
783
+ className: "border rounded-lg px-3",
784
+ children: [
785
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.AccordionTrigger, {
786
+ className: "text-sm font-medium",
787
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
788
+ className: "flex items-center gap-2",
789
+ children: [
790
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.GitBranch, {
791
+ className: "h-4 w-4"
792
+ }),
793
+ "Rules & conditions"
794
+ ]
795
+ })
796
+ }),
797
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.AccordionContent, {
798
+ className: "pt-2",
799
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RulesEditor, {
800
+ rules: field.rules,
801
+ onChange: (rules)=>onUpdate({
802
+ rules
803
+ }),
804
+ allFields: allFields,
805
+ requiredMessage: field.validation?.requiredMessage,
806
+ onRequiredMessageChange: (message)=>onUpdate({
807
+ validation: {
808
+ ...field.validation,
809
+ requiredMessage: message
810
+ }
811
+ })
812
+ })
813
+ })
814
+ ]
815
+ })
816
+ })
817
+ ]
818
+ });
819
+ }
820
+ function FormDesigner() {
821
+ const [formTitle, setFormTitle] = (0, external_react_namespaceObject.useState)('My Custom Form');
822
+ const [formDescription, setFormDescription] = (0, external_react_namespaceObject.useState)('');
823
+ const [sections, setSections] = (0, external_react_namespaceObject.useState)([
824
+ {
825
+ id: 'section-1',
826
+ title: 'General Information',
827
+ collapsible: false,
828
+ defaultExpanded: true,
829
+ fields: [
830
+ {
831
+ id: '1',
832
+ name: 'fullName',
833
+ type: 'text',
834
+ label: 'Full Name',
835
+ placeholder: 'Enter your name'
836
+ }
837
+ ]
838
+ }
839
+ ]);
840
+ const [selectedSectionId, setSelectedSectionId] = (0, external_react_namespaceObject.useState)('section-1');
841
+ const [selectedFieldId, setSelectedFieldId] = (0, external_react_namespaceObject.useState)('1');
842
+ const [expandedSections, setExpandedSections] = (0, external_react_namespaceObject.useState)([
843
+ 'section-1'
844
+ ]);
845
+ const [previewDisabled, setPreviewDisabled] = (0, external_react_namespaceObject.useState)(false);
846
+ const allFields = sections.flatMap((s)=>s.fields);
847
+ const selectedSection = sections.find((s)=>s.id === selectedSectionId);
848
+ const selectedField = allFields.find((f)=>f.id === selectedFieldId);
849
+ const generatedSchema = {
850
+ id: 'custom-form',
851
+ title: formTitle,
852
+ description: formDescription || void 0,
853
+ mode: 'onChange',
854
+ reValidateMode: 'onChange',
855
+ sections: sections.map((section)=>({
856
+ id: section.id,
857
+ title: section.title,
858
+ description: section.description,
859
+ collapsible: section.collapsible,
860
+ defaultExpanded: section.defaultExpanded,
861
+ fields: section.fields.map((field)=>{
862
+ const { id: _id, validation: _validationConfig, ...fieldMeta } = field;
863
+ const validationConfig = buildValidationConfig(field);
864
+ return {
865
+ ...fieldMeta,
866
+ validation: validationConfig
867
+ };
868
+ })
869
+ }))
870
+ };
871
+ const addSection = ()=>{
872
+ const newSection = {
873
+ id: `section-${Date.now()}`,
874
+ title: `Section ${sections.length + 1}`,
875
+ collapsible: true,
876
+ defaultExpanded: true,
877
+ fields: []
878
+ };
879
+ setSections([
880
+ ...sections,
881
+ newSection
882
+ ]);
883
+ setSelectedSectionId(newSection.id);
884
+ setSelectedFieldId(null);
885
+ setExpandedSections([
886
+ ...expandedSections,
887
+ newSection.id
888
+ ]);
889
+ };
890
+ const removeSection = (id)=>{
891
+ if (sections.length <= 1) return;
892
+ setSections(sections.filter((s)=>s.id !== id));
893
+ setExpandedSections(expandedSections.filter((sId)=>sId !== id));
894
+ if (selectedSectionId === id) {
895
+ setSelectedSectionId(sections[0]?.id || null);
896
+ setSelectedFieldId(null);
897
+ }
898
+ };
899
+ const updateSection = (id, updates)=>{
900
+ let finalUpdates = updates;
901
+ if (updates.id && updates.id !== id) {
902
+ const idExists = sections.some((s)=>s.id === updates.id);
903
+ if (idExists) {
904
+ const { id: _id, ...rest } = updates;
905
+ finalUpdates = rest;
906
+ }
907
+ }
908
+ setSections(sections.map((s)=>s.id === id ? {
909
+ ...s,
910
+ ...finalUpdates
911
+ } : s));
912
+ if (finalUpdates.id && finalUpdates.id !== id) {
913
+ if (selectedSectionId === id) setSelectedSectionId(finalUpdates.id);
914
+ setExpandedSections(expandedSections.map((sId)=>sId === id ? finalUpdates.id : sId));
915
+ }
916
+ };
917
+ const moveSection = (id, direction)=>{
918
+ const index = sections.findIndex((s)=>s.id === id);
919
+ if (-1 === index) return;
920
+ const newSections = [
921
+ ...sections
922
+ ];
923
+ if ('up' === direction && index > 0) [newSections[index - 1], newSections[index]] = [
924
+ newSections[index],
925
+ newSections[index - 1]
926
+ ];
927
+ else if ('down' === direction && index < sections.length - 1) [newSections[index], newSections[index + 1]] = [
928
+ newSections[index + 1],
929
+ newSections[index]
930
+ ];
931
+ setSections(newSections);
932
+ };
933
+ const addField = (sectionId)=>{
934
+ const section = sections.find((s)=>s.id === sectionId);
935
+ if (!section) return;
936
+ const newField = {
937
+ id: Date.now().toString(),
938
+ name: `field_${allFields.length + 1}`,
939
+ type: 'text',
940
+ label: `Field ${allFields.length + 1}`
941
+ };
942
+ setSections(sections.map((s)=>s.id === sectionId ? {
943
+ ...s,
944
+ fields: [
945
+ ...s.fields,
946
+ newField
947
+ ]
948
+ } : s));
949
+ setSelectedSectionId(sectionId);
950
+ setSelectedFieldId(newField.id);
951
+ };
952
+ const removeField = (sectionId, fieldId)=>{
953
+ setSections(sections.map((s)=>s.id === sectionId ? {
954
+ ...s,
955
+ fields: s.fields.filter((f)=>f.id !== fieldId)
956
+ } : s));
957
+ if (selectedFieldId === fieldId) {
958
+ const section = sections.find((s)=>s.id === sectionId);
959
+ setSelectedFieldId(section?.fields[0]?.id || null);
960
+ }
961
+ };
962
+ const updateField = (fieldId, updates)=>{
963
+ setSections((prevSections)=>{
964
+ const prevAllFields = prevSections.flatMap((s)=>s.fields);
965
+ let finalUpdates = updates;
966
+ if (updates.name) {
967
+ const currentField = prevAllFields.find((f)=>f.id === fieldId);
968
+ if (currentField && updates.name !== currentField.name) {
969
+ const nameExists = prevAllFields.some((f)=>f.id !== fieldId && f.name === updates.name);
970
+ if (nameExists) {
971
+ const { name: _name, ...rest } = updates;
972
+ finalUpdates = rest;
973
+ }
974
+ }
975
+ }
976
+ return prevSections.map((s)=>({
977
+ ...s,
978
+ fields: s.fields.map((f)=>f.id === fieldId ? {
979
+ ...f,
980
+ ...finalUpdates
981
+ } : f)
982
+ }));
983
+ });
984
+ };
985
+ const moveField = (sectionId, fieldId, direction)=>{
986
+ const section = sections.find((s)=>s.id === sectionId);
987
+ if (!section) return;
988
+ const index = section.fields.findIndex((f)=>f.id === fieldId);
989
+ if (-1 === index) return;
990
+ const newFields = [
991
+ ...section.fields
992
+ ];
993
+ if ('up' === direction && index > 0) [newFields[index - 1], newFields[index]] = [
994
+ newFields[index],
995
+ newFields[index - 1]
996
+ ];
997
+ else if ('down' === direction && index < newFields.length - 1) [newFields[index], newFields[index + 1]] = [
998
+ newFields[index + 1],
999
+ newFields[index]
1000
+ ];
1001
+ setSections(sections.map((s)=>s.id === sectionId ? {
1002
+ ...s,
1003
+ fields: newFields
1004
+ } : s));
1005
+ };
1006
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(grid_cjs_namespaceObject.Grid, {
1007
+ gap: 3,
1008
+ h: "screen",
1009
+ p: 3,
1010
+ className: "lg:grid-cols-[2fr_3fr_3fr]",
1011
+ children: [
1012
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(card_cjs_namespaceObject.Card, {
1013
+ className: "overflow-hidden flex flex-col",
1014
+ children: [
1015
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(card_cjs_namespaceObject.CardHeader, {
1016
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1017
+ className: "flex items-center justify-between",
1018
+ children: [
1019
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1020
+ children: [
1021
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(card_cjs_namespaceObject.CardTitle, {
1022
+ className: "flex items-center gap-2",
1023
+ children: [
1024
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Layers, {
1025
+ className: "h-4 w-4"
1026
+ }),
1027
+ "Sections"
1028
+ ]
1029
+ }),
1030
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(card_cjs_namespaceObject.CardDescription, {
1031
+ children: "Organize fields into sections"
1032
+ })
1033
+ ]
1034
+ }),
1035
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(button_cjs_namespaceObject.Button, {
1036
+ onClick: addSection,
1037
+ variant: "outline",
1038
+ size: "sm",
1039
+ children: [
1040
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Plus, {
1041
+ className: "h-3 w-3 mr-1"
1042
+ }),
1043
+ "Section"
1044
+ ]
1045
+ })
1046
+ ]
1047
+ })
1048
+ }),
1049
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(card_cjs_namespaceObject.CardContent, {
1050
+ className: "flex-1 overflow-auto px-2 pb-2",
1051
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.Accordion, {
1052
+ type: "multiple",
1053
+ value: expandedSections,
1054
+ onValueChange: setExpandedSections,
1055
+ className: "space-y-1",
1056
+ children: sections.map((section, sectionIndex)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(accordion_cjs_namespaceObject.AccordionItem, {
1057
+ value: section.id,
1058
+ className: `group/section border rounded-lg ${selectedSectionId === section.id && !selectedFieldId ? 'ring-2 ring-primary' : ''}`,
1059
+ children: [
1060
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1061
+ className: "flex items-center gap-1 px-2 py-1.5",
1062
+ children: [
1063
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.AccordionTrigger, {
1064
+ className: "h-5 w-5 p-0 hover:no-underline hover:bg-accent rounded [&>svg]:hidden flex items-center justify-center shrink-0",
1065
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1066
+ className: "flex items-center justify-center",
1067
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronRight, {
1068
+ className: "h-3 w-3 shrink-0 transition-transform duration-200 group-data-[state=open]/section:rotate-90"
1069
+ })
1070
+ })
1071
+ }),
1072
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1073
+ className: "flex-1 min-w-0 cursor-pointer flex items-center gap-1",
1074
+ onClick: ()=>{
1075
+ setSelectedSectionId(section.id);
1076
+ setSelectedFieldId(null);
1077
+ },
1078
+ children: [
1079
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1080
+ className: "text-sm font-medium truncate",
1081
+ children: section.title
1082
+ }),
1083
+ section.collapsible && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1084
+ className: "text-[10px] text-muted-foreground",
1085
+ children: "(collapsible)"
1086
+ })
1087
+ ]
1088
+ }),
1089
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1090
+ className: "flex gap-0.5 opacity-0 group-hover/section:opacity-100 transition-opacity",
1091
+ children: [
1092
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
1093
+ variant: "ghost",
1094
+ size: "sm",
1095
+ className: "h-5 w-5 p-0",
1096
+ onClick: (e)=>{
1097
+ e.stopPropagation();
1098
+ moveSection(section.id, 'up');
1099
+ },
1100
+ disabled: 0 === sectionIndex,
1101
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.MoveUp, {
1102
+ className: "h-2.5 w-2.5"
1103
+ })
1104
+ }),
1105
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
1106
+ variant: "ghost",
1107
+ size: "sm",
1108
+ className: "h-5 w-5 p-0",
1109
+ onClick: (e)=>{
1110
+ e.stopPropagation();
1111
+ moveSection(section.id, 'down');
1112
+ },
1113
+ disabled: sectionIndex === sections.length - 1,
1114
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.MoveDown, {
1115
+ className: "h-2.5 w-2.5"
1116
+ })
1117
+ }),
1118
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
1119
+ variant: "ghost",
1120
+ size: "sm",
1121
+ className: "h-5 w-5 p-0",
1122
+ onClick: (e)=>{
1123
+ e.stopPropagation();
1124
+ removeSection(section.id);
1125
+ },
1126
+ disabled: sections.length <= 1,
1127
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Trash2, {
1128
+ className: "h-2.5 w-2.5 text-destructive"
1129
+ })
1130
+ })
1131
+ ]
1132
+ })
1133
+ ]
1134
+ }),
1135
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.AccordionContent, {
1136
+ className: "px-2 pb-2 pt-0",
1137
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1138
+ className: "space-y-0.5 ml-3 border-l pl-2",
1139
+ children: [
1140
+ section.fields.map((field, fieldIndex)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1141
+ 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' : ''}`,
1142
+ onClick: ()=>{
1143
+ setSelectedSectionId(section.id);
1144
+ setSelectedFieldId(field.id);
1145
+ },
1146
+ children: [
1147
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.GripVertical, {
1148
+ className: "h-3 w-3 text-muted-foreground opacity-0 group-hover/field:opacity-50"
1149
+ }),
1150
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1151
+ className: "flex-1 min-w-0",
1152
+ children: [
1153
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1154
+ className: "flex items-center gap-1",
1155
+ children: [
1156
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1157
+ className: "text-xs font-medium truncate",
1158
+ children: field.label
1159
+ }),
1160
+ field.rules?.some((r)=>r.effects.required) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1161
+ className: "text-[10px] text-destructive",
1162
+ children: "*"
1163
+ })
1164
+ ]
1165
+ }),
1166
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
1167
+ className: "text-[9px] text-muted-foreground",
1168
+ children: field.type
1169
+ })
1170
+ ]
1171
+ }),
1172
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1173
+ className: "flex gap-0.5 opacity-0 group-hover/field:opacity-100 transition-opacity",
1174
+ children: [
1175
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
1176
+ variant: "ghost",
1177
+ size: "sm",
1178
+ className: "h-5 w-5 p-0",
1179
+ onClick: (e)=>{
1180
+ e.stopPropagation();
1181
+ moveField(section.id, field.id, 'up');
1182
+ },
1183
+ disabled: 0 === fieldIndex,
1184
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.MoveUp, {
1185
+ className: "h-2.5 w-2.5"
1186
+ })
1187
+ }),
1188
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
1189
+ variant: "ghost",
1190
+ size: "sm",
1191
+ className: "h-5 w-5 p-0",
1192
+ onClick: (e)=>{
1193
+ e.stopPropagation();
1194
+ moveField(section.id, field.id, 'down');
1195
+ },
1196
+ disabled: fieldIndex === section.fields.length - 1,
1197
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.MoveDown, {
1198
+ className: "h-2.5 w-2.5"
1199
+ })
1200
+ }),
1201
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
1202
+ variant: "ghost",
1203
+ size: "sm",
1204
+ className: "h-5 w-5 p-0",
1205
+ onClick: (e)=>{
1206
+ e.stopPropagation();
1207
+ removeField(section.id, field.id);
1208
+ },
1209
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Trash2, {
1210
+ className: "h-2.5 w-2.5 text-destructive"
1211
+ })
1212
+ })
1213
+ ]
1214
+ })
1215
+ ]
1216
+ }, field.id)),
1217
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(button_cjs_namespaceObject.Button, {
1218
+ onClick: ()=>addField(section.id),
1219
+ variant: "outline",
1220
+ size: "sm",
1221
+ children: [
1222
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Plus, {
1223
+ className: "h-3 w-3 mr-1"
1224
+ }),
1225
+ "Field"
1226
+ ]
1227
+ })
1228
+ ]
1229
+ })
1230
+ })
1231
+ ]
1232
+ }, section.id))
1233
+ })
1234
+ })
1235
+ ]
1236
+ }),
1237
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(card_cjs_namespaceObject.Card, {
1238
+ className: "overflow-hidden flex flex-col",
1239
+ children: [
1240
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(card_cjs_namespaceObject.CardHeader, {
1241
+ children: [
1242
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(card_cjs_namespaceObject.CardTitle, {
1243
+ className: "flex items-center gap-2",
1244
+ children: [
1245
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Settings, {
1246
+ className: "h-4 w-4"
1247
+ }),
1248
+ selectedFieldId ? 'Field configuration' : selectedSectionId ? 'Section configuration' : 'Configuration'
1249
+ ]
1250
+ }),
1251
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(card_cjs_namespaceObject.CardDescription, {
1252
+ children: selectedField ? `Configure "${selectedField.label}"` : selectedSection ? `Configure "${selectedSection.title}" section` : 'Select a section or field to configure'
1253
+ })
1254
+ ]
1255
+ }),
1256
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(card_cjs_namespaceObject.CardContent, {
1257
+ className: "flex-1 overflow-auto",
1258
+ children: selectedField ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FieldConfigForm, {
1259
+ field: selectedField,
1260
+ onUpdate: (updates)=>updateField(selectedField.id, updates),
1261
+ allFields: allFields,
1262
+ existingFieldNames: new Set(allFields.map((f)=>f.name))
1263
+ }) : selectedSection ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SectionConfigForm, {
1264
+ section: selectedSection,
1265
+ onUpdate: (updates)=>updateSection(selectedSection.id, updates),
1266
+ existingSectionIds: new Set(sections.map((s)=>s.id))
1267
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
1268
+ className: "flex items-center justify-center h-full text-muted-foreground",
1269
+ children: "Select a section or field to configure"
1270
+ })
1271
+ })
1272
+ ]
1273
+ }),
1274
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(card_cjs_namespaceObject.Card, {
1275
+ className: "overflow-hidden flex flex-col",
1276
+ children: [
1277
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(card_cjs_namespaceObject.CardHeader, {
1278
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1279
+ className: "space-y-4",
1280
+ children: [
1281
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1282
+ children: [
1283
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(card_cjs_namespaceObject.CardTitle, {
1284
+ className: "flex items-center gap-2",
1285
+ children: [
1286
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.View, {
1287
+ className: "h-4 w-4"
1288
+ }),
1289
+ "Preview & export"
1290
+ ]
1291
+ }),
1292
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(card_cjs_namespaceObject.CardDescription, {
1293
+ children: "See how your form looks"
1294
+ })
1295
+ ]
1296
+ }),
1297
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1298
+ className: "space-y-2",
1299
+ children: [
1300
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
1301
+ htmlFor: "form-title",
1302
+ children: "Form title"
1303
+ }),
1304
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
1305
+ id: "form-title",
1306
+ value: formTitle,
1307
+ onChange: (e)=>setFormTitle(e.target.value)
1308
+ })
1309
+ ]
1310
+ }),
1311
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1312
+ className: "space-y-2",
1313
+ children: [
1314
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
1315
+ htmlFor: "form-description",
1316
+ children: "Form description"
1317
+ }),
1318
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(textarea_cjs_namespaceObject.Textarea, {
1319
+ id: "form-description",
1320
+ value: formDescription,
1321
+ onChange: (e)=>setFormDescription(e.target.value),
1322
+ placeholder: "Optional description",
1323
+ rows: 2
1324
+ })
1325
+ ]
1326
+ })
1327
+ ]
1328
+ })
1329
+ }),
1330
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(card_cjs_namespaceObject.CardContent, {
1331
+ className: "flex-1 overflow-auto",
1332
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(tabs_cjs_namespaceObject.Tabs, {
1333
+ defaultValue: "preview",
1334
+ className: "h-full flex flex-col",
1335
+ children: [
1336
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(tabs_cjs_namespaceObject.TabsList, {
1337
+ className: "grid w-full grid-cols-2",
1338
+ children: [
1339
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(tabs_cjs_namespaceObject.TabsTrigger, {
1340
+ value: "preview",
1341
+ children: [
1342
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Eye, {
1343
+ className: "h-4 w-4 mr-2"
1344
+ }),
1345
+ "Preview"
1346
+ ]
1347
+ }),
1348
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(tabs_cjs_namespaceObject.TabsTrigger, {
1349
+ value: "code",
1350
+ children: [
1351
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Code, {
1352
+ className: "h-4 w-4 mr-2"
1353
+ }),
1354
+ "Schema"
1355
+ ]
1356
+ })
1357
+ ]
1358
+ }),
1359
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(tabs_cjs_namespaceObject.TabsContent, {
1360
+ value: "preview",
1361
+ className: "flex-1 overflow-auto",
1362
+ children: [
1363
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1364
+ className: "flex items-center justify-end gap-2 mb-4 pb-2 border-b",
1365
+ children: [
1366
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
1367
+ htmlFor: "preview-readonly",
1368
+ className: "text-sm text-muted-foreground",
1369
+ children: "Readonly"
1370
+ }),
1371
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(switch_cjs_namespaceObject.Switch, {
1372
+ id: "preview-readonly",
1373
+ checked: previewDisabled,
1374
+ onCheckedChange: setPreviewDisabled
1375
+ })
1376
+ ]
1377
+ }),
1378
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_metadata_form_cjs_namespaceObject.MetadataForm, {
1379
+ schema: generatedSchema,
1380
+ onSubmit: (data)=>{
1381
+ console.log('Form submitted:', data);
1382
+ alert('Form submitted! Check console for data.');
1383
+ },
1384
+ disabled: previewDisabled,
1385
+ autoComplete: "off"
1386
+ }, 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(','))
1387
+ ]
1388
+ }),
1389
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(tabs_cjs_namespaceObject.TabsContent, {
1390
+ value: "code",
1391
+ className: "flex-1 overflow-auto",
1392
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("pre", {
1393
+ className: "text-xs bg-muted p-4 rounded-lg overflow-auto max-h-full",
1394
+ children: (0, external_schema_serializer_cjs_namespaceObject.schemaToJson)(generatedSchema)
1395
+ })
1396
+ })
1397
+ ]
1398
+ })
1399
+ })
1400
+ ]
1401
+ })
1402
+ ]
1403
+ });
1404
+ }
1405
+ function FieldOptionsEditor({ options, onChange }) {
1406
+ const addOption = ()=>{
1407
+ onChange([
1408
+ ...options,
1409
+ {
1410
+ label: `Option ${options.length + 1}`,
1411
+ value: `option${options.length + 1}`
1412
+ }
1413
+ ]);
1414
+ };
1415
+ const updateOption = (index, updates)=>{
1416
+ const newOptions = [
1417
+ ...options
1418
+ ];
1419
+ newOptions[index] = {
1420
+ ...newOptions[index],
1421
+ ...updates
1422
+ };
1423
+ onChange(newOptions);
1424
+ };
1425
+ const removeOption = (index)=>{
1426
+ onChange(options.filter((_, i)=>i !== index));
1427
+ };
1428
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1429
+ className: "space-y-3",
1430
+ children: [
1431
+ options.map((option, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1432
+ className: "flex gap-2 items-center",
1433
+ children: [
1434
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1435
+ className: "flex-1 grid grid-cols-2 gap-2",
1436
+ children: [
1437
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
1438
+ placeholder: "Label",
1439
+ value: option.label,
1440
+ onChange: (e)=>updateOption(index, {
1441
+ label: e.target.value
1442
+ })
1443
+ }),
1444
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
1445
+ placeholder: "Value",
1446
+ value: option.value,
1447
+ onChange: (e)=>updateOption(index, {
1448
+ value: e.target.value
1449
+ })
1450
+ })
1451
+ ]
1452
+ }),
1453
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
1454
+ variant: "ghost",
1455
+ size: "icon",
1456
+ className: "h-8 w-8 text-muted-foreground hover:text-destructive",
1457
+ onClick: ()=>removeOption(index),
1458
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Trash2, {
1459
+ className: "h-4 w-4"
1460
+ })
1461
+ })
1462
+ ]
1463
+ }, index)),
1464
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(button_cjs_namespaceObject.Button, {
1465
+ onClick: addOption,
1466
+ variant: "outline",
1467
+ size: "sm",
1468
+ className: "w-full",
1469
+ children: [
1470
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Plus, {
1471
+ className: "h-3 w-3 mr-2"
1472
+ }),
1473
+ "Add option"
1474
+ ]
1475
+ })
1476
+ ]
1477
+ });
1478
+ }
1479
+ function DataSourceEditor({ dataSource, onChange }) {
1480
+ const [sourceType, setSourceType] = (0, external_react_namespaceObject.useState)(dataSource?.type || 'none');
1481
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1482
+ className: "space-y-4",
1483
+ children: [
1484
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1485
+ className: "space-y-2",
1486
+ children: [
1487
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
1488
+ children: "Data source type"
1489
+ }),
1490
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.Select, {
1491
+ value: sourceType,
1492
+ onValueChange: (value)=>{
1493
+ setSourceType(value);
1494
+ if ('none' === value) onChange(void 0);
1495
+ else if ('static' === value) onChange({
1496
+ type: 'static',
1497
+ options: []
1498
+ });
1499
+ else if ('fetch' === value) onChange({
1500
+ type: 'fetch',
1501
+ url: '',
1502
+ method: 'GET'
1503
+ });
1504
+ else if ('remote' === value) onChange({
1505
+ type: 'remote',
1506
+ endpoint: '',
1507
+ params: {}
1508
+ });
1509
+ else if ('computed' === value) onChange({
1510
+ type: 'computed',
1511
+ dependency: [],
1512
+ compute: ''
1513
+ });
1514
+ },
1515
+ children: [
1516
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectTrigger, {
1517
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectValue, {})
1518
+ }),
1519
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.SelectContent, {
1520
+ children: [
1521
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
1522
+ value: "none",
1523
+ children: "None"
1524
+ }),
1525
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
1526
+ value: "fetch",
1527
+ children: "Fetch (single request)"
1528
+ }),
1529
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
1530
+ value: "remote",
1531
+ children: "Remote (dependent)"
1532
+ }),
1533
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
1534
+ value: "computed",
1535
+ children: "Computed"
1536
+ })
1537
+ ]
1538
+ })
1539
+ ]
1540
+ })
1541
+ ]
1542
+ }),
1543
+ 'fetch' === sourceType && dataSource?.type === 'fetch' && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1544
+ className: "space-y-3",
1545
+ children: [
1546
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1547
+ className: "space-y-2",
1548
+ children: [
1549
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
1550
+ children: "API URL"
1551
+ }),
1552
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
1553
+ placeholder: "/api/data",
1554
+ value: dataSource.url,
1555
+ onChange: (e)=>onChange({
1556
+ ...dataSource,
1557
+ url: e.target.value
1558
+ })
1559
+ })
1560
+ ]
1561
+ }),
1562
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1563
+ className: "space-y-2",
1564
+ children: [
1565
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
1566
+ children: "Transform"
1567
+ }),
1568
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(textarea_cjs_namespaceObject.Textarea, {
1569
+ placeholder: "data.map(item => ({ label: item.name, value: item.id }))",
1570
+ value: dataSource.transform || '',
1571
+ onChange: (e)=>onChange({
1572
+ ...dataSource,
1573
+ transform: e.target.value
1574
+ }),
1575
+ rows: 2
1576
+ })
1577
+ ]
1578
+ })
1579
+ ]
1580
+ }),
1581
+ 'remote' === sourceType && dataSource?.type === 'remote' && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1582
+ className: "space-y-3",
1583
+ children: [
1584
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1585
+ className: "space-y-2",
1586
+ children: [
1587
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
1588
+ children: "Endpoint"
1589
+ }),
1590
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
1591
+ placeholder: "/api/data",
1592
+ value: dataSource.endpoint,
1593
+ onChange: (e)=>onChange({
1594
+ ...dataSource,
1595
+ endpoint: e.target.value
1596
+ })
1597
+ })
1598
+ ]
1599
+ }),
1600
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1601
+ className: "space-y-2",
1602
+ children: [
1603
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
1604
+ children: "Parameters (JSON)"
1605
+ }),
1606
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(textarea_cjs_namespaceObject.Textarea, {
1607
+ placeholder: '{ "fieldName": "$otherField" }',
1608
+ value: JSON.stringify(dataSource.params || {}, null, 2),
1609
+ onChange: (e)=>{
1610
+ try {
1611
+ const params = JSON.parse(e.target.value);
1612
+ onChange({
1613
+ ...dataSource,
1614
+ params
1615
+ });
1616
+ } catch {}
1617
+ },
1618
+ rows: 3
1619
+ })
1620
+ ]
1621
+ })
1622
+ ]
1623
+ }),
1624
+ 'computed' === sourceType && dataSource?.type === 'computed' && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1625
+ className: "space-y-3",
1626
+ children: [
1627
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1628
+ className: "space-y-2",
1629
+ children: [
1630
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
1631
+ children: "Dependencies (comma-separated)"
1632
+ }),
1633
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
1634
+ placeholder: "field1, field2",
1635
+ value: dataSource.dependency.join(', '),
1636
+ onChange: (e)=>onChange({
1637
+ ...dataSource,
1638
+ dependency: e.target.value.split(',').map((s)=>s.trim())
1639
+ })
1640
+ })
1641
+ ]
1642
+ }),
1643
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1644
+ className: "space-y-2",
1645
+ children: [
1646
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
1647
+ children: "Compute expression"
1648
+ }),
1649
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(textarea_cjs_namespaceObject.Textarea, {
1650
+ placeholder: "(field1 || 0) * (field2 || 0)",
1651
+ value: dataSource.compute,
1652
+ onChange: (e)=>onChange({
1653
+ ...dataSource,
1654
+ compute: e.target.value
1655
+ }),
1656
+ rows: 2
1657
+ })
1658
+ ]
1659
+ })
1660
+ ]
1661
+ })
1662
+ ]
1663
+ });
1664
+ }
1665
+ const CONDITION_OPERATORS = [
1666
+ {
1667
+ value: 'is',
1668
+ label: 'equals',
1669
+ description: 'Field value equals'
1670
+ },
1671
+ {
1672
+ value: 'isNot',
1673
+ label: 'not equals',
1674
+ description: 'Field value does not equal'
1675
+ },
1676
+ {
1677
+ value: 'in',
1678
+ label: 'is one of',
1679
+ description: 'Field value is one of'
1680
+ },
1681
+ {
1682
+ value: 'notIn',
1683
+ label: 'is not one of',
1684
+ description: 'Field value is not one of'
1685
+ },
1686
+ {
1687
+ value: 'matches',
1688
+ label: 'matches pattern',
1689
+ description: 'Field value matches regex'
1690
+ }
1691
+ ];
1692
+ const RULE_EFFECTS = [
1693
+ {
1694
+ value: 'show',
1695
+ label: 'Show field',
1696
+ description: 'Show this field when conditions are met',
1697
+ Icon: external_lucide_react_namespaceObject.Eye,
1698
+ color: 'text-green-600 bg-green-50 border-green-200'
1699
+ },
1700
+ {
1701
+ value: 'hide',
1702
+ label: 'Hide field',
1703
+ description: 'Hide this field when conditions are met',
1704
+ Icon: external_lucide_react_namespaceObject.EyeOff,
1705
+ color: 'text-orange-600 bg-orange-50 border-orange-200'
1706
+ },
1707
+ {
1708
+ value: 'require',
1709
+ label: 'Make required',
1710
+ description: 'Require this field when conditions are met',
1711
+ Icon: external_lucide_react_namespaceObject.Asterisk,
1712
+ color: 'text-red-600 bg-red-50 border-red-200'
1713
+ },
1714
+ {
1715
+ value: 'disable',
1716
+ label: 'Disable field',
1717
+ description: 'Disable this field when conditions are met',
1718
+ Icon: external_lucide_react_namespaceObject.Ban,
1719
+ color: 'text-gray-600 bg-gray-50 border-gray-200'
1720
+ }
1721
+ ];
1722
+ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequiredMessageChange }) {
1723
+ const [isAddingRule, setIsAddingRule] = (0, external_react_namespaceObject.useState)(false);
1724
+ const [editingRuleIndex, setEditingRuleIndex] = (0, external_react_namespaceObject.useState)(null);
1725
+ const [selectedEffect, setSelectedEffect] = (0, external_react_namespaceObject.useState)('show');
1726
+ const [conditions, setConditions] = (0, external_react_namespaceObject.useState)([
1727
+ {
1728
+ field: '',
1729
+ operator: 'is',
1730
+ value: ''
1731
+ }
1732
+ ]);
1733
+ const [conditionOperator, setConditionOperator] = (0, external_react_namespaceObject.useState)('AND');
1734
+ const isAlwaysRequired = rules.some((r)=>true === r.effects.required && 0 === r.conditions.length);
1735
+ const resetBuilder = ()=>{
1736
+ setSelectedEffect('show');
1737
+ setConditions([
1738
+ {
1739
+ field: '',
1740
+ operator: 'is',
1741
+ value: ''
1742
+ }
1743
+ ]);
1744
+ setConditionOperator('AND');
1745
+ setIsAddingRule(false);
1746
+ setEditingRuleIndex(null);
1747
+ };
1748
+ const addCondition = ()=>{
1749
+ setConditions([
1750
+ ...conditions,
1751
+ {
1752
+ field: '',
1753
+ operator: 'is',
1754
+ value: ''
1755
+ }
1756
+ ]);
1757
+ };
1758
+ const updateCondition = (index, updates)=>{
1759
+ const newConditions = [
1760
+ ...conditions
1761
+ ];
1762
+ newConditions[index] = {
1763
+ ...newConditions[index],
1764
+ ...updates
1765
+ };
1766
+ setConditions(newConditions);
1767
+ };
1768
+ const removeCondition = (index)=>{
1769
+ if (conditions.length > 1) setConditions(conditions.filter((_, i)=>i !== index));
1770
+ };
1771
+ const buildCondition = (cond)=>{
1772
+ const condition = {
1773
+ when: cond.field
1774
+ };
1775
+ const targetField = allFields.find((f)=>f.name === cond.field);
1776
+ const isNumericField = targetField?.type === 'number' || targetField?.type === 'slider';
1777
+ const isBooleanField = targetField?.type === 'checkbox' || targetField?.type === 'switch';
1778
+ const parseValue = (val)=>{
1779
+ if (isBooleanField) {
1780
+ if ('true' === val.toLowerCase()) return true;
1781
+ if ('false' === val.toLowerCase()) return false;
1782
+ }
1783
+ if (isNumericField) {
1784
+ const num = Number(val);
1785
+ if (!isNaN(num)) return num;
1786
+ }
1787
+ if ('true' === val.toLowerCase()) return true;
1788
+ if ('false' === val.toLowerCase()) return false;
1789
+ return val;
1790
+ };
1791
+ switch(cond.operator){
1792
+ case 'is':
1793
+ condition.is = parseValue(cond.value);
1794
+ break;
1795
+ case 'isNot':
1796
+ condition.isNot = parseValue(cond.value);
1797
+ break;
1798
+ case 'in':
1799
+ condition.in = cond.value.split(',').map((v)=>parseValue(v.trim()));
1800
+ break;
1801
+ case 'notIn':
1802
+ condition.notIn = cond.value.split(',').map((v)=>parseValue(v.trim()));
1803
+ break;
1804
+ case 'matches':
1805
+ condition.matches = cond.value;
1806
+ break;
1807
+ }
1808
+ return condition;
1809
+ };
1810
+ const saveRule = ()=>{
1811
+ const validConditions = conditions.filter((c)=>c.field);
1812
+ if (0 === validConditions.length) return;
1813
+ const newRule = {
1814
+ id: `rule-${Date.now()}`,
1815
+ conditions: validConditions.map(buildCondition),
1816
+ operator: conditionOperator,
1817
+ effects: {}
1818
+ };
1819
+ switch(selectedEffect){
1820
+ case 'show':
1821
+ newRule.effects.visible = true;
1822
+ break;
1823
+ case 'hide':
1824
+ newRule.effects.visible = false;
1825
+ break;
1826
+ case 'require':
1827
+ newRule.effects.required = true;
1828
+ break;
1829
+ case 'disable':
1830
+ newRule.effects.disabled = true;
1831
+ break;
1832
+ }
1833
+ if (null !== editingRuleIndex) {
1834
+ const newRules = [
1835
+ ...rules
1836
+ ];
1837
+ newRules[editingRuleIndex] = newRule;
1838
+ onChange(newRules);
1839
+ } else onChange([
1840
+ ...rules,
1841
+ newRule
1842
+ ]);
1843
+ resetBuilder();
1844
+ };
1845
+ const editRule = (index)=>{
1846
+ const rule = rules[index];
1847
+ if (!rule) return;
1848
+ let effect = 'show';
1849
+ if (true === rule.effects.visible) effect = 'show';
1850
+ else if (false === rule.effects.visible) effect = 'hide';
1851
+ else if (true === rule.effects.required) effect = 'require';
1852
+ else if (true === rule.effects.disabled) effect = 'disable';
1853
+ setSelectedEffect(effect);
1854
+ setConditionOperator(rule.operator || 'AND');
1855
+ const editableConditions = rule.conditions.map((cond)=>{
1856
+ let operator = 'is';
1857
+ let value = '';
1858
+ if (void 0 !== cond.is) {
1859
+ operator = 'is';
1860
+ value = String(cond.is);
1861
+ } else if (void 0 !== cond.isNot) {
1862
+ operator = 'isNot';
1863
+ value = String(cond.isNot);
1864
+ } else if (void 0 !== cond.in) {
1865
+ operator = 'in';
1866
+ value = cond.in.map(String).join(', ');
1867
+ } else if (void 0 !== cond.notIn) {
1868
+ operator = 'notIn';
1869
+ value = cond.notIn.map(String).join(', ');
1870
+ } else if (void 0 !== cond.matches) {
1871
+ operator = 'matches';
1872
+ value = cond.matches;
1873
+ }
1874
+ return {
1875
+ field: cond.when,
1876
+ operator,
1877
+ value
1878
+ };
1879
+ });
1880
+ setConditions(editableConditions.length > 0 ? editableConditions : [
1881
+ {
1882
+ field: '',
1883
+ operator: 'is',
1884
+ value: ''
1885
+ }
1886
+ ]);
1887
+ setEditingRuleIndex(index);
1888
+ setIsAddingRule(true);
1889
+ };
1890
+ const deleteRule = (index)=>{
1891
+ onChange(rules.filter((_, i)=>i !== index));
1892
+ };
1893
+ const getFieldLabel = (fieldName)=>{
1894
+ const field = allFields.find((f)=>f.name === fieldName);
1895
+ return field?.label || fieldName;
1896
+ };
1897
+ const describeRule = (rule)=>{
1898
+ if (0 === rule.conditions.length) {
1899
+ if (rule.effects.required) return 'Always required';
1900
+ return 'Always applies';
1901
+ }
1902
+ const conditionDescriptions = rule.conditions.map((cond)=>{
1903
+ const fieldLabel = getFieldLabel(cond.when);
1904
+ if (void 0 !== cond.is) return `"${fieldLabel}" = ${JSON.stringify(cond.is)}`;
1905
+ if (void 0 !== cond.isNot) return `"${fieldLabel}" ≠ ${JSON.stringify(cond.isNot)}`;
1906
+ if (void 0 !== cond.in) return `"${fieldLabel}" in [${cond.in.map((v)=>JSON.stringify(v)).join(', ')}]`;
1907
+ if (void 0 !== cond.notIn) return `"${fieldLabel}" not in [${cond.notIn.map((v)=>JSON.stringify(v)).join(', ')}]`;
1908
+ if (void 0 !== cond.matches) return `"${fieldLabel}" matches /${cond.matches}/`;
1909
+ return `"${fieldLabel}"`;
1910
+ });
1911
+ const operator = 'OR' === rule.operator ? ' OR ' : ' AND ';
1912
+ return conditionDescriptions.join(operator);
1913
+ };
1914
+ const getEffectDescription = (rule)=>{
1915
+ if (true === rule.effects.visible) return {
1916
+ label: 'Show',
1917
+ color: 'text-green-600 bg-green-50'
1918
+ };
1919
+ if (false === rule.effects.visible) return {
1920
+ label: 'Hide',
1921
+ color: 'text-orange-600 bg-orange-50'
1922
+ };
1923
+ if (true === rule.effects.required) return {
1924
+ label: 'Required',
1925
+ color: 'text-red-600 bg-red-50'
1926
+ };
1927
+ if (true === rule.effects.disabled) return {
1928
+ label: 'Disabled',
1929
+ color: 'text-gray-600 bg-gray-50'
1930
+ };
1931
+ return {
1932
+ label: 'Unknown',
1933
+ color: 'text-muted-foreground bg-muted'
1934
+ };
1935
+ };
1936
+ const getFieldOptions = (fieldName)=>{
1937
+ const field = allFields.find((f)=>f.name === fieldName);
1938
+ return field?.options || [];
1939
+ };
1940
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1941
+ className: "space-y-4",
1942
+ children: [
1943
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1944
+ className: "space-y-3 p-3 border rounded-lg bg-muted/30",
1945
+ children: [
1946
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1947
+ className: "flex items-center justify-between",
1948
+ children: [
1949
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1950
+ className: "flex items-center gap-3",
1951
+ children: [
1952
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Asterisk, {
1953
+ className: "h-5 w-5 text-red-500"
1954
+ }),
1955
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1956
+ children: [
1957
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
1958
+ className: "cursor-pointer font-medium",
1959
+ children: "Always required"
1960
+ }),
1961
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
1962
+ className: "text-xs text-muted-foreground",
1963
+ children: "Field must always have a value"
1964
+ })
1965
+ ]
1966
+ })
1967
+ ]
1968
+ }),
1969
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(checkbox_cjs_namespaceObject.Checkbox, {
1970
+ checked: isAlwaysRequired,
1971
+ onCheckedChange: (checked)=>{
1972
+ if (checked) {
1973
+ const requiredRule = {
1974
+ id: 'always-required',
1975
+ conditions: [],
1976
+ operator: 'AND',
1977
+ effects: {
1978
+ required: true
1979
+ }
1980
+ };
1981
+ onChange([
1982
+ ...rules.filter((r)=>!(r.effects.required && 0 === r.conditions.length)),
1983
+ requiredRule
1984
+ ]);
1985
+ } else {
1986
+ onChange(rules.filter((r)=>!(r.effects.required && 0 === r.conditions.length)));
1987
+ onRequiredMessageChange(void 0);
1988
+ }
1989
+ }
1990
+ })
1991
+ ]
1992
+ }),
1993
+ isAlwaysRequired && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1994
+ className: "space-y-1.5 pl-8",
1995
+ children: [
1996
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
1997
+ htmlFor: "required-message",
1998
+ className: "text-xs text-muted-foreground",
1999
+ children: "Error message"
2000
+ }),
2001
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
2002
+ id: "required-message",
2003
+ placeholder: "This field is required",
2004
+ value: requiredMessage || '',
2005
+ onChange: (e)=>onRequiredMessageChange(e.target.value || void 0),
2006
+ className: "h-8 text-sm"
2007
+ })
2008
+ ]
2009
+ })
2010
+ ]
2011
+ }),
2012
+ rules.filter((r)=>r.conditions.length > 0 || !r.effects.required).length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2013
+ className: "space-y-2",
2014
+ children: [
2015
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
2016
+ className: "text-xs text-muted-foreground uppercase tracking-wide",
2017
+ children: "Conditional rules"
2018
+ }),
2019
+ rules.map((rule, index)=>({
2020
+ rule,
2021
+ index
2022
+ })).filter(({ rule })=>rule.conditions.length > 0 || !rule.effects.required).map(({ rule, index })=>{
2023
+ const effect = getEffectDescription(rule);
2024
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
2025
+ className: "group border rounded-lg p-3 hover:border-primary/50 transition-colors",
2026
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2027
+ className: "flex items-start justify-between gap-2",
2028
+ children: [
2029
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2030
+ className: "flex-1 min-w-0",
2031
+ children: [
2032
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2033
+ className: "flex items-center gap-2 mb-1",
2034
+ children: [
2035
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
2036
+ className: `text-xs font-medium px-2 py-0.5 rounded ${effect.color}`,
2037
+ children: effect.label
2038
+ }),
2039
+ rule.conditions.length > 1 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
2040
+ className: "text-xs text-muted-foreground",
2041
+ children: [
2042
+ "(",
2043
+ rule.operator,
2044
+ ")"
2045
+ ]
2046
+ })
2047
+ ]
2048
+ }),
2049
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
2050
+ className: "text-sm text-muted-foreground truncate",
2051
+ children: describeRule(rule)
2052
+ })
2053
+ ]
2054
+ }),
2055
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2056
+ className: "flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",
2057
+ children: [
2058
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
2059
+ variant: "ghost",
2060
+ size: "sm",
2061
+ className: "h-7 w-7 p-0",
2062
+ onClick: ()=>editRule(index),
2063
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Settings, {
2064
+ className: "h-3.5 w-3.5"
2065
+ })
2066
+ }),
2067
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
2068
+ variant: "ghost",
2069
+ size: "sm",
2070
+ className: "h-7 w-7 p-0 text-destructive hover:text-destructive",
2071
+ onClick: ()=>deleteRule(index),
2072
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Trash2, {
2073
+ className: "h-3.5 w-3.5"
2074
+ })
2075
+ })
2076
+ ]
2077
+ })
2078
+ ]
2079
+ })
2080
+ }, index);
2081
+ })
2082
+ ]
2083
+ }),
2084
+ isAddingRule ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2085
+ className: "border rounded-lg p-4 space-y-4 bg-muted/20",
2086
+ children: [
2087
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2088
+ className: "flex items-center justify-between",
2089
+ children: [
2090
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
2091
+ className: "font-medium",
2092
+ children: null !== editingRuleIndex ? 'Edit rule' : 'New rule'
2093
+ }),
2094
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
2095
+ variant: "ghost",
2096
+ size: "sm",
2097
+ onClick: resetBuilder,
2098
+ children: "Cancel"
2099
+ })
2100
+ ]
2101
+ }),
2102
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2103
+ className: "space-y-2",
2104
+ children: [
2105
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
2106
+ className: "text-xs text-muted-foreground",
2107
+ children: "When conditions are met:"
2108
+ }),
2109
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
2110
+ className: "grid grid-cols-2 gap-2",
2111
+ children: RULE_EFFECTS.map((effect)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("button", {
2112
+ type: "button",
2113
+ 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'}`,
2114
+ onClick: ()=>setSelectedEffect(effect.value),
2115
+ children: [
2116
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(effect.Icon, {
2117
+ className: "h-4 w-4"
2118
+ }),
2119
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
2120
+ className: "font-medium",
2121
+ children: effect.label
2122
+ })
2123
+ ]
2124
+ }, effect.value))
2125
+ })
2126
+ ]
2127
+ }),
2128
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2129
+ className: "space-y-3",
2130
+ children: [
2131
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2132
+ className: "flex items-center justify-between",
2133
+ children: [
2134
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
2135
+ className: "text-xs text-muted-foreground",
2136
+ children: "Conditions:"
2137
+ }),
2138
+ conditions.length > 1 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.Select, {
2139
+ value: conditionOperator,
2140
+ onValueChange: (v)=>setConditionOperator(v),
2141
+ children: [
2142
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectTrigger, {
2143
+ className: "w-24 h-7 text-xs",
2144
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectValue, {})
2145
+ }),
2146
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.SelectContent, {
2147
+ children: [
2148
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
2149
+ value: "AND",
2150
+ children: "Match ALL"
2151
+ }),
2152
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
2153
+ value: "OR",
2154
+ children: "Match ANY"
2155
+ })
2156
+ ]
2157
+ })
2158
+ ]
2159
+ })
2160
+ ]
2161
+ }),
2162
+ conditions.map((cond, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2163
+ className: "space-y-2",
2164
+ children: [
2165
+ index > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2166
+ className: "flex items-center gap-2 text-xs text-muted-foreground",
2167
+ children: [
2168
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(separator_cjs_namespaceObject.Separator, {
2169
+ className: "flex-1"
2170
+ }),
2171
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
2172
+ children: conditionOperator
2173
+ }),
2174
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(separator_cjs_namespaceObject.Separator, {
2175
+ className: "flex-1"
2176
+ })
2177
+ ]
2178
+ }),
2179
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2180
+ className: "flex gap-2 items-start",
2181
+ children: [
2182
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2183
+ className: "flex-1 space-y-2",
2184
+ children: [
2185
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.Select, {
2186
+ value: cond.field,
2187
+ onValueChange: (v)=>updateCondition(index, {
2188
+ field: v
2189
+ }),
2190
+ children: [
2191
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectTrigger, {
2192
+ className: "h-8 text-sm",
2193
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectValue, {
2194
+ placeholder: "Select field..."
2195
+ })
2196
+ }),
2197
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectContent, {
2198
+ children: allFields.map((field)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
2199
+ value: field.name,
2200
+ children: field.label
2201
+ }, field.id))
2202
+ })
2203
+ ]
2204
+ }),
2205
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
2206
+ className: "flex gap-2",
2207
+ children: [
2208
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.Select, {
2209
+ value: cond.operator,
2210
+ onValueChange: (v)=>updateCondition(index, {
2211
+ operator: v
2212
+ }),
2213
+ children: [
2214
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectTrigger, {
2215
+ className: "w-32 h-8 text-sm",
2216
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectValue, {})
2217
+ }),
2218
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectContent, {
2219
+ children: CONDITION_OPERATORS.map((op)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
2220
+ value: op.value,
2221
+ children: op.label
2222
+ }, op.value))
2223
+ })
2224
+ ]
2225
+ }),
2226
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
2227
+ className: "flex-1",
2228
+ children: cond.field && getFieldOptions(cond.field).length > 0 && ('is' === cond.operator || 'isNot' === cond.operator) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.Select, {
2229
+ value: cond.value,
2230
+ onValueChange: (v)=>updateCondition(index, {
2231
+ value: v
2232
+ }),
2233
+ children: [
2234
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectTrigger, {
2235
+ className: "h-8 text-sm",
2236
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectValue, {
2237
+ placeholder: "Select value..."
2238
+ })
2239
+ }),
2240
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectContent, {
2241
+ children: getFieldOptions(cond.field).map((opt)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
2242
+ value: String(opt.value),
2243
+ children: opt.label
2244
+ }, String(opt.value)))
2245
+ })
2246
+ ]
2247
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
2248
+ className: "h-8 text-sm",
2249
+ placeholder: 'in' === cond.operator || 'notIn' === cond.operator ? 'value1, value2, ...' : 'matches' === cond.operator ? 'regex pattern' : 'value',
2250
+ value: cond.value,
2251
+ onChange: (e)=>updateCondition(index, {
2252
+ value: e.target.value
2253
+ })
2254
+ })
2255
+ })
2256
+ ]
2257
+ })
2258
+ ]
2259
+ }),
2260
+ conditions.length > 1 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
2261
+ variant: "ghost",
2262
+ size: "sm",
2263
+ className: "h-8 w-8 p-0 text-muted-foreground",
2264
+ onClick: ()=>removeCondition(index),
2265
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Trash2, {
2266
+ className: "h-3.5 w-3.5"
2267
+ })
2268
+ })
2269
+ ]
2270
+ })
2271
+ ]
2272
+ }, index)),
2273
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(button_cjs_namespaceObject.Button, {
2274
+ variant: "outline",
2275
+ size: "sm",
2276
+ className: "w-full",
2277
+ onClick: addCondition,
2278
+ children: [
2279
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Plus, {
2280
+ className: "h-3 w-3 mr-2"
2281
+ }),
2282
+ "Add condition"
2283
+ ]
2284
+ })
2285
+ ]
2286
+ }),
2287
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
2288
+ className: "w-full",
2289
+ onClick: saveRule,
2290
+ disabled: !conditions.some((c)=>c.field),
2291
+ children: null !== editingRuleIndex ? 'Update rule' : 'Add rule'
2292
+ })
2293
+ ]
2294
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(button_cjs_namespaceObject.Button, {
2295
+ variant: "outline",
2296
+ className: "w-full",
2297
+ onClick: ()=>setIsAddingRule(true),
2298
+ children: [
2299
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Plus, {
2300
+ className: "h-4 w-4 mr-2"
2301
+ }),
2302
+ "Add conditional rule"
2303
+ ]
2304
+ })
2305
+ ]
2306
+ });
2307
+ }
2308
+ exports.FormDesigner = __webpack_exports__.FormDesigner;
2309
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
2310
+ "FormDesigner"
2311
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
2312
+ Object.defineProperty(exports, '__esModule', {
2313
+ value: true
2314
+ });