@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,366 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
+ import { FormProvider, useForm } from "react-hook-form";
4
+ import { z } from "zod/v4";
5
+ import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "../ui/accordion.js";
6
+ import { Button } from "../ui/button.js";
7
+ import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
8
+ import { DataFetcher } from "./data-fetcher.js";
9
+ import { FormFieldRenderer } from "./field-renderer.js";
10
+ import { RulesEngine } from "./rules-engine.js";
11
+ import { validationConfigToZod } from "./validation-converter.js";
12
+ const DEFAULT_PLUGINS = [];
13
+ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className, disabled = false, autoComplete }) {
14
+ const [currentStep, setCurrentStep] = useState(0);
15
+ const [customComponents, setCustomComponents] = useState({});
16
+ const [isInitialized, setIsInitialized] = useState(false);
17
+ const zodSchema = useMemo(()=>buildZodSchema(schema), [
18
+ schema
19
+ ]);
20
+ const form = useForm({
21
+ resolver: standardSchemaResolver(zodSchema),
22
+ mode: schema.mode || 'onSubmit',
23
+ reValidateMode: schema.reValidateMode || 'onChange'
24
+ });
25
+ const { watch, handleSubmit, reset } = form;
26
+ const valuesRef = useRef({});
27
+ const watchedValues = watch();
28
+ valuesRef.current = watchedValues;
29
+ const context = useMemo(()=>({
30
+ schema,
31
+ form,
32
+ get values () {
33
+ return valuesRef.current;
34
+ },
35
+ get errors () {
36
+ return form.formState.errors;
37
+ },
38
+ get isSubmitting () {
39
+ return form.formState.isSubmitting;
40
+ },
41
+ get isDirty () {
42
+ return form.formState.isDirty;
43
+ },
44
+ currentStep: schema.steps ? currentStep : void 0,
45
+ evaluateConditions: (conditions)=>RulesEngine.evaluateConditions(conditions, valuesRef.current, 'AND'),
46
+ fetchData: async (source)=>{
47
+ const result = await DataFetcher.fetch(source, valuesRef.current);
48
+ return result;
49
+ },
50
+ registerCustomComponent: (name, component)=>{
51
+ setCustomComponents((prev)=>({
52
+ ...prev,
53
+ [name]: component
54
+ }));
55
+ }
56
+ }), [
57
+ schema,
58
+ form,
59
+ currentStep
60
+ ]);
61
+ const contextRef = useRef(context);
62
+ contextRef.current = context;
63
+ useEffect(()=>{
64
+ if (isInitialized) return;
65
+ const initializeForm = async ()=>{
66
+ if (schema.initialData) {
67
+ const data = await loadInitialData(schema.initialData, contextRef.current);
68
+ reset(data);
69
+ }
70
+ for (const plugin of plugins)await plugin.onFormInit?.(contextRef.current);
71
+ setIsInitialized(true);
72
+ };
73
+ initializeForm();
74
+ }, [
75
+ isInitialized
76
+ ]);
77
+ useEffect(()=>{
78
+ if (!isInitialized) return;
79
+ const subscription = watch((value, { name })=>{
80
+ if (name) {
81
+ valuesRef.current = value;
82
+ plugins.forEach((plugin)=>{
83
+ plugin.onValueChange?.(name, value[name], contextRef.current);
84
+ });
85
+ }
86
+ });
87
+ return ()=>subscription.unsubscribe();
88
+ }, [
89
+ watch,
90
+ isInitialized,
91
+ plugins
92
+ ]);
93
+ const handleFormSubmit = handleSubmit(async (data)=>{
94
+ let finalData = data;
95
+ for (const plugin of plugins)if (plugin.onSubmit) finalData = await plugin.onSubmit(finalData, context) || finalData;
96
+ if (onSubmit) await onSubmit(finalData);
97
+ });
98
+ const renderContent = ()=>{
99
+ if (schema.steps) return /*#__PURE__*/ jsx(MultiStepForm, {
100
+ schema: schema,
101
+ context: context,
102
+ currentStep: currentStep,
103
+ setCurrentStep: setCurrentStep,
104
+ customComponents: customComponents,
105
+ disabled: disabled
106
+ });
107
+ return /*#__PURE__*/ jsx(SinglePageForm, {
108
+ schema: schema,
109
+ context: context,
110
+ customComponents: customComponents,
111
+ disabled: disabled
112
+ });
113
+ };
114
+ return /*#__PURE__*/ jsx(FormProvider, {
115
+ ...form,
116
+ children: /*#__PURE__*/ jsxs("form", {
117
+ onSubmit: handleFormSubmit,
118
+ className: className,
119
+ autoComplete: autoComplete,
120
+ children: [
121
+ renderContent(),
122
+ !schema.steps && /*#__PURE__*/ jsx(FormActions, {
123
+ schema: schema,
124
+ context: context,
125
+ onReset: ()=>reset()
126
+ })
127
+ ]
128
+ })
129
+ });
130
+ }
131
+ function SinglePageForm({ schema, context, customComponents, disabled }) {
132
+ const sections = schema.sections || [];
133
+ const visibleSections = sections.filter((section)=>!section.conditions || context.evaluateConditions(section.conditions));
134
+ return /*#__PURE__*/ jsx("div", {
135
+ className: "space-y-2",
136
+ children: visibleSections.map((section)=>/*#__PURE__*/ jsx(FormSection, {
137
+ section: section,
138
+ context: context,
139
+ customComponents: customComponents,
140
+ disabled: disabled
141
+ }, section.id))
142
+ });
143
+ }
144
+ function MultiStepForm({ schema, context, currentStep, setCurrentStep, customComponents, disabled }) {
145
+ const steps = schema.steps || [];
146
+ const step = steps[currentStep];
147
+ if (!step) return null;
148
+ if (step.conditions && !context.evaluateConditions(step.conditions)) {
149
+ if (currentStep < steps.length - 1) setCurrentStep(currentStep + 1);
150
+ return null;
151
+ }
152
+ return /*#__PURE__*/ jsxs("div", {
153
+ className: "space-y-6",
154
+ children: [
155
+ /*#__PURE__*/ jsxs("div", {
156
+ className: "flex items-center justify-between",
157
+ children: [
158
+ /*#__PURE__*/ jsxs("div", {
159
+ children: [
160
+ /*#__PURE__*/ jsx("h2", {
161
+ className: "text-2xl font-semibold",
162
+ children: step.title
163
+ }),
164
+ step.description && /*#__PURE__*/ jsx("p", {
165
+ className: "text-muted-foreground mt-1",
166
+ children: step.description
167
+ })
168
+ ]
169
+ }),
170
+ /*#__PURE__*/ jsxs("div", {
171
+ className: "text-sm text-muted-foreground",
172
+ children: [
173
+ "Step ",
174
+ currentStep + 1,
175
+ " of ",
176
+ steps.length
177
+ ]
178
+ })
179
+ ]
180
+ }),
181
+ /*#__PURE__*/ jsx("div", {
182
+ className: "space-y-2",
183
+ children: step.sections.map((section)=>/*#__PURE__*/ jsx(FormSection, {
184
+ section: section,
185
+ context: context,
186
+ customComponents: customComponents,
187
+ disabled: disabled
188
+ }, section.id))
189
+ }),
190
+ /*#__PURE__*/ jsxs("div", {
191
+ className: "flex justify-between pt-6",
192
+ children: [
193
+ /*#__PURE__*/ jsx(Button, {
194
+ type: "button",
195
+ onClick: ()=>setCurrentStep(Math.max(0, currentStep - 1)),
196
+ disabled: 0 === currentStep,
197
+ variant: "secondary",
198
+ children: "Previous"
199
+ }),
200
+ currentStep < steps.length - 1 ? /*#__PURE__*/ jsx(Button, {
201
+ type: "button",
202
+ onClick: ()=>setCurrentStep(currentStep + 1),
203
+ variant: "default",
204
+ children: "Next"
205
+ }) : /*#__PURE__*/ jsx(Button, {
206
+ type: "submit",
207
+ variant: "default",
208
+ children: "Submit"
209
+ })
210
+ ]
211
+ })
212
+ ]
213
+ });
214
+ }
215
+ function FormSection({ section, context, customComponents, disabled }) {
216
+ const gridColumns = context.schema.layout?.columns || 1;
217
+ const gap = context.schema.layout?.gap || 4;
218
+ const fieldsGrid = /*#__PURE__*/ jsx("div", {
219
+ className: "grid",
220
+ style: {
221
+ gridTemplateColumns: `repeat(${gridColumns}, minmax(0, 1fr))`,
222
+ gap: `${0.25 * gap}rem`
223
+ },
224
+ children: section.fields.map((field)=>/*#__PURE__*/ jsx(FormFieldRenderer, {
225
+ field: field,
226
+ context: context,
227
+ customComponents: customComponents,
228
+ disabled: disabled
229
+ }, field.name))
230
+ });
231
+ if (!section.title) return fieldsGrid;
232
+ const innerContent = /*#__PURE__*/ jsxs("div", {
233
+ className: "flex flex-col gap-4",
234
+ children: [
235
+ section.description && /*#__PURE__*/ jsx("p", {
236
+ className: "text-sm text-muted-foreground",
237
+ children: section.description
238
+ }),
239
+ fieldsGrid
240
+ ]
241
+ });
242
+ if (section.collapsible) {
243
+ const defaultValue = false !== section.defaultExpanded ? [
244
+ section.id
245
+ ] : [];
246
+ return /*#__PURE__*/ jsx(Accordion, {
247
+ type: "multiple",
248
+ defaultValue: defaultValue,
249
+ children: /*#__PURE__*/ jsxs(AccordionItem, {
250
+ value: section.id,
251
+ className: "border rounded-lg px-3",
252
+ children: [
253
+ /*#__PURE__*/ jsx(AccordionTrigger, {
254
+ className: "text-sm font-medium",
255
+ children: section.title
256
+ }),
257
+ /*#__PURE__*/ jsx(AccordionContent, {
258
+ children: innerContent
259
+ })
260
+ ]
261
+ })
262
+ });
263
+ }
264
+ return /*#__PURE__*/ jsxs("div", {
265
+ className: "border rounded-lg px-3",
266
+ children: [
267
+ /*#__PURE__*/ jsx("div", {
268
+ className: "flex",
269
+ children: /*#__PURE__*/ jsx("div", {
270
+ className: "flex flex-1 items-center justify-between py-4 text-sm font-medium",
271
+ children: section.title
272
+ })
273
+ }),
274
+ /*#__PURE__*/ jsx("div", {
275
+ className: "text-sm",
276
+ children: /*#__PURE__*/ jsx("div", {
277
+ className: "pb-4 pt-0",
278
+ children: innerContent
279
+ })
280
+ })
281
+ ]
282
+ });
283
+ }
284
+ function FormActions({ schema, context, onReset }) {
285
+ const actions = schema.actions || [
286
+ {
287
+ id: 'submit',
288
+ type: 'submit',
289
+ label: 'Submit',
290
+ variant: 'default'
291
+ }
292
+ ];
293
+ if (0 === actions.length) return null;
294
+ return /*#__PURE__*/ jsx("div", {
295
+ className: "flex gap-2 pt-6",
296
+ children: actions.map((action)=>{
297
+ if (action.conditions && !context.evaluateConditions(action.conditions)) return null;
298
+ if ('reset' === action.type) return /*#__PURE__*/ jsx(Button, {
299
+ type: "button",
300
+ onClick: onReset,
301
+ variant: action.variant || 'secondary',
302
+ disabled: action.disabled,
303
+ children: action.label
304
+ }, action.id);
305
+ return /*#__PURE__*/ jsx(Button, {
306
+ type: 'submit' === action.type ? 'submit' : 'button',
307
+ variant: action.variant || 'default',
308
+ disabled: action.disabled || 'submit' === action.type && context.isSubmitting,
309
+ children: action.loading && context.isSubmitting ? 'Loading...' : action.label
310
+ }, action.id);
311
+ })
312
+ });
313
+ }
314
+ function buildZodSchema(schema) {
315
+ const shape = {};
316
+ const fields = schema.steps ? schema.steps.flatMap((step)=>step.sections.flatMap((s)=>s.fields)) : schema.sections?.flatMap((s)=>s.fields) || [];
317
+ const dynamicValidationFields = [];
318
+ fields.forEach((field)=>{
319
+ const hasUnconditionalRequired = field.rules?.some((rule)=>true === rule.effects.required && 0 === rule.conditions.length);
320
+ const hasConditionalRequired = field.rules?.some((rule)=>true === rule.effects.required && rule.conditions.length > 0);
321
+ const hasVisibilityRules = field.rules?.some((rule)=>void 0 !== rule.effects.visible);
322
+ const hasStaticRequired = field.validation?.required === true;
323
+ const hasAnyRequired = hasStaticRequired || hasUnconditionalRequired || hasConditionalRequired;
324
+ if (field.rules && (hasConditionalRequired || hasAnyRequired && hasVisibilityRules)) dynamicValidationFields.push({
325
+ name: field.name,
326
+ rules: field.rules,
327
+ staticRequired: hasStaticRequired || hasUnconditionalRequired || false,
328
+ customRequiredMessage: field.validation?.messages?.required
329
+ });
330
+ const shouldIncludeRequiredInBase = (hasUnconditionalRequired || hasStaticRequired) && !hasVisibilityRules;
331
+ const validationConfig = field.validation ? {
332
+ ...field.validation,
333
+ required: shouldIncludeRequiredInBase
334
+ } : shouldIncludeRequiredInBase ? {
335
+ required: true
336
+ } : void 0;
337
+ shape[field.name] = validationConfigToZod(validationConfig, field.type);
338
+ });
339
+ const baseSchema = z.object(shape);
340
+ if (0 === dynamicValidationFields.length) return baseSchema;
341
+ return baseSchema.superRefine((data, ctx)=>{
342
+ const values = data;
343
+ for (const { name, rules, staticRequired, customRequiredMessage } of dynamicValidationFields){
344
+ const isVisible = RulesEngine.isFieldVisible(rules, values);
345
+ if (!isVisible) continue;
346
+ const ruleResult = RulesEngine.applyRules(rules, values, {});
347
+ const isRequired = true === ruleResult.required || staticRequired;
348
+ if (isRequired) {
349
+ const value = values[name];
350
+ const isEmpty = null == value || '' === value || Array.isArray(value) && 0 === value.length;
351
+ if (isEmpty) ctx.addIssue({
352
+ code: z.ZodIssueCode.custom,
353
+ message: customRequiredMessage || 'This field is required',
354
+ path: [
355
+ name
356
+ ]
357
+ });
358
+ }
359
+ }
360
+ });
361
+ }
362
+ async function loadInitialData(initialData, _context) {
363
+ if (!initialData) return {};
364
+ return initialData;
365
+ }
366
+ export { MetadataForm };