@object-ui/plugin-form 3.1.3 → 3.1.4

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.
package/dist/index.js CHANGED
@@ -1,1870 +1,1988 @@
1
- import K, { useState as C, useCallback as A, useMemo as G, useEffect as H, useId as Fe } from "react";
2
- import { ComponentRegistry as ue } from "@object-ui/core";
3
- import { useSafeFieldLabel as ee, SchemaRenderer as J } from "@object-ui/react";
4
- import { buildValidationRules as B, mapFieldTypeToFormType as X, formatFileSize as Re, evaluateCondition as De } from "@object-ui/fields";
5
- import { cn as W, Tabs as ke, TabsList as _e, TabsTrigger as Ie, TabsContent as Le, Button as Z, ResizablePanelGroup as Pe, ResizablePanel as be, ResizableHandle as Ae, Sheet as ze, SheetContent as Ve, SheetHeader as Me, SheetTitle as $e, SheetDescription as qe, Dialog as Ye, MobileDialogContent as We, DialogHeader as Ue, DialogTitle as He, DialogDescription as Ge, Skeleton as xe, Card as re, CardHeader as le, CardDescription as ae, CardTitle as ne, CardContent as me } from "@object-ui/components";
6
- import { ChevronRight as Te, ChevronDown as Je, Check as Be, ChevronLeft as Xe, Loader2 as Qe } from "lucide-react";
7
- var de = { exports: {} }, ie = {};
8
- var ye;
9
- function Ze() {
10
- if (ye) return ie;
11
- ye = 1;
12
- var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), r = /* @__PURE__ */ Symbol.for("react.fragment");
13
- function i(b, o, p) {
14
- var x = null;
15
- if (p !== void 0 && (x = "" + p), o.key !== void 0 && (x = "" + o.key), "key" in o) {
16
- p = {};
17
- for (var E in o)
18
- E !== "key" && (p[E] = o[E]);
19
- } else p = o;
20
- return o = p.ref, {
21
- $$typeof: e,
22
- type: b,
23
- key: x,
24
- ref: o !== void 0 ? o : null,
25
- props: p
26
- };
27
- }
28
- return ie.Fragment = r, ie.jsx = i, ie.jsxs = i, ie;
29
- }
30
- var oe = {};
31
- var ge;
32
- function Ke() {
33
- return ge || (ge = 1, process.env.NODE_ENV !== "production" && (function() {
34
- function e(l) {
35
- if (l == null) return null;
36
- if (typeof l == "function")
37
- return l.$$typeof === y ? null : l.displayName || l.name || null;
38
- if (typeof l == "string") return l;
39
- switch (l) {
40
- case z:
41
- return "Fragment";
42
- case k:
43
- return "Profiler";
44
- case L:
45
- return "StrictMode";
46
- case n:
47
- return "Suspense";
48
- case a:
49
- return "SuspenseList";
50
- case S:
51
- return "Activity";
52
- }
53
- if (typeof l == "object")
54
- switch (typeof l.tag == "number" && console.error(
55
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
56
- ), l.$$typeof) {
57
- case D:
58
- return "Portal";
59
- case M:
60
- return l.displayName || "Context";
61
- case U:
62
- return (l._context.displayName || "Context") + ".Consumer";
63
- case f:
64
- var w = l.render;
65
- return l = l.displayName, l || (l = w.displayName || w.name || "", l = l !== "" ? "ForwardRef(" + l + ")" : "ForwardRef"), l;
66
- case s:
67
- return w = l.displayName || null, w !== null ? w : e(l.type) || "Memo";
68
- case c:
69
- w = l._payload, l = l._init;
70
- try {
71
- return e(l(w));
72
- } catch {
73
- }
74
- }
75
- return null;
76
- }
77
- function r(l) {
78
- return "" + l;
79
- }
80
- function i(l) {
81
- try {
82
- r(l);
83
- var w = !1;
84
- } catch {
85
- w = !0;
86
- }
87
- if (w) {
88
- w = console;
89
- var P = w.error, $ = typeof Symbol == "function" && Symbol.toStringTag && l[Symbol.toStringTag] || l.constructor.name || "Object";
90
- return P.call(
91
- w,
92
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
93
- $
94
- ), r(l);
95
- }
96
- }
97
- function b(l) {
98
- if (l === z) return "<>";
99
- if (typeof l == "object" && l !== null && l.$$typeof === c)
100
- return "<...>";
101
- try {
102
- var w = e(l);
103
- return w ? "<" + w + ">" : "<...>";
104
- } catch {
105
- return "<...>";
106
- }
107
- }
108
- function o() {
109
- var l = d.A;
110
- return l === null ? null : l.getOwner();
111
- }
112
- function p() {
113
- return Error("react-stack-top-frame");
114
- }
115
- function x(l) {
116
- if (_.call(l, "key")) {
117
- var w = Object.getOwnPropertyDescriptor(l, "key").get;
118
- if (w && w.isReactWarning) return !1;
119
- }
120
- return l.key !== void 0;
121
- }
122
- function E(l, w) {
123
- function P() {
124
- g || (g = !0, console.error(
125
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
126
- w
127
- ));
128
- }
129
- P.isReactWarning = !0, Object.defineProperty(l, "key", {
130
- get: P,
131
- configurable: !0
132
- });
133
- }
134
- function I() {
135
- var l = e(this.type);
136
- return m[l] || (m[l] = !0, console.error(
137
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
138
- )), l = this.props.ref, l !== void 0 ? l : null;
139
- }
140
- function O(l, w, P, $, se, fe) {
141
- var q = P.ref;
142
- return l = {
143
- $$typeof: v,
144
- type: l,
145
- key: w,
146
- props: P,
147
- _owner: $
148
- }, (q !== void 0 ? q : null) !== null ? Object.defineProperty(l, "ref", {
149
- enumerable: !1,
150
- get: I
151
- }) : Object.defineProperty(l, "ref", { enumerable: !1, value: null }), l._store = {}, Object.defineProperty(l._store, "validated", {
152
- configurable: !1,
153
- enumerable: !1,
154
- writable: !0,
155
- value: 0
156
- }), Object.defineProperty(l, "_debugInfo", {
157
- configurable: !1,
158
- enumerable: !1,
159
- writable: !0,
160
- value: null
161
- }), Object.defineProperty(l, "_debugStack", {
162
- configurable: !1,
163
- enumerable: !1,
164
- writable: !0,
165
- value: se
166
- }), Object.defineProperty(l, "_debugTask", {
167
- configurable: !1,
168
- enumerable: !1,
169
- writable: !0,
170
- value: fe
171
- }), Object.freeze && (Object.freeze(l.props), Object.freeze(l)), l;
172
- }
173
- function F(l, w, P, $, se, fe) {
174
- var q = w.children;
175
- if (q !== void 0)
176
- if ($)
177
- if (T(q)) {
178
- for ($ = 0; $ < q.length; $++)
179
- N(q[$]);
180
- Object.freeze && Object.freeze(q);
181
- } else
182
- console.error(
183
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
184
- );
185
- else N(q);
186
- if (_.call(w, "key")) {
187
- q = e(l);
188
- var Q = Object.keys(w).filter(function(Oe) {
189
- return Oe !== "key";
190
- });
191
- $ = 0 < Q.length ? "{key: someKey, " + Q.join(": ..., ") + ": ...}" : "{key: someKey}", R[q + $] || (Q = 0 < Q.length ? "{" + Q.join(": ..., ") + ": ...}" : "{}", console.error(
192
- `A props object containing a "key" prop is being spread into JSX:
193
- let props = %s;
194
- <%s {...props} />
195
- React keys must be passed directly to JSX without using spread:
196
- let props = %s;
197
- <%s key={someKey} {...props} />`,
198
- $,
199
- q,
200
- Q,
201
- q
202
- ), R[q + $] = !0);
203
- }
204
- if (q = null, P !== void 0 && (i(P), q = "" + P), x(w) && (i(w.key), q = "" + w.key), "key" in w) {
205
- P = {};
206
- for (var pe in w)
207
- pe !== "key" && (P[pe] = w[pe]);
208
- } else P = w;
209
- return q && E(
210
- P,
211
- typeof l == "function" ? l.displayName || l.name || "Unknown" : l
212
- ), O(
213
- l,
214
- q,
215
- P,
216
- o(),
217
- se,
218
- fe
219
- );
220
- }
221
- function N(l) {
222
- j(l) ? l._store && (l._store.validated = 1) : typeof l == "object" && l !== null && l.$$typeof === c && (l._payload.status === "fulfilled" ? j(l._payload.value) && l._payload.value._store && (l._payload.value._store.validated = 1) : l._store && (l._store.validated = 1));
223
- }
224
- function j(l) {
225
- return typeof l == "object" && l !== null && l.$$typeof === v;
226
- }
227
- var h = K, v = /* @__PURE__ */ Symbol.for("react.transitional.element"), D = /* @__PURE__ */ Symbol.for("react.portal"), z = /* @__PURE__ */ Symbol.for("react.fragment"), L = /* @__PURE__ */ Symbol.for("react.strict_mode"), k = /* @__PURE__ */ Symbol.for("react.profiler"), U = /* @__PURE__ */ Symbol.for("react.consumer"), M = /* @__PURE__ */ Symbol.for("react.context"), f = /* @__PURE__ */ Symbol.for("react.forward_ref"), n = /* @__PURE__ */ Symbol.for("react.suspense"), a = /* @__PURE__ */ Symbol.for("react.suspense_list"), s = /* @__PURE__ */ Symbol.for("react.memo"), c = /* @__PURE__ */ Symbol.for("react.lazy"), S = /* @__PURE__ */ Symbol.for("react.activity"), y = /* @__PURE__ */ Symbol.for("react.client.reference"), d = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, _ = Object.prototype.hasOwnProperty, T = Array.isArray, u = console.createTask ? console.createTask : function() {
228
- return null;
229
- };
230
- h = {
231
- react_stack_bottom_frame: function(l) {
232
- return l();
233
- }
234
- };
235
- var g, m = {}, V = h.react_stack_bottom_frame.bind(
236
- h,
237
- p
238
- )(), Y = u(b(p)), R = {};
239
- oe.Fragment = z, oe.jsx = function(l, w, P) {
240
- var $ = 1e4 > d.recentlyCreatedOwnerStacks++;
241
- return F(
242
- l,
243
- w,
244
- P,
245
- !1,
246
- $ ? Error("react-stack-top-frame") : V,
247
- $ ? u(b(l)) : Y
248
- );
249
- }, oe.jsxs = function(l, w, P) {
250
- var $ = 1e4 > d.recentlyCreatedOwnerStacks++;
251
- return F(
252
- l,
253
- w,
254
- P,
255
- !0,
256
- $ ? Error("react-stack-top-frame") : V,
257
- $ ? u(b(l)) : Y
258
- );
259
- };
260
- })()), oe;
261
- }
262
- var je;
263
- function et() {
264
- return je || (je = 1, process.env.NODE_ENV === "production" ? de.exports = Ze() : de.exports = Ke()), de.exports;
265
- }
266
- var t = et();
267
- const te = ({
268
- label: e,
269
- description: r,
270
- collapsible: i = !1,
271
- collapsed: b = !1,
272
- columns: o = 1,
273
- children: p,
274
- className: x,
275
- gridClassName: E
276
- }) => {
277
- const [I, O] = C(b), F = {
278
- 1: "grid-cols-1",
279
- 2: "grid-cols-1 md:grid-cols-2",
280
- 3: "grid-cols-1 md:grid-cols-2 lg:grid-cols-3",
281
- 4: "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
282
- }, N = () => {
283
- i && O(!I);
284
- };
285
- return /* @__PURE__ */ t.jsxs("div", { className: W("form-section", x), children: [
286
- (e || r) && /* @__PURE__ */ t.jsxs(
287
- "div",
288
- {
289
- className: W(
290
- "flex items-start gap-2 mb-4",
291
- i && "cursor-pointer select-none"
292
- ),
293
- onClick: N,
294
- role: i ? "button" : void 0,
295
- "aria-expanded": i ? !I : void 0,
296
- children: [
297
- i && /* @__PURE__ */ t.jsx("span", { className: "mt-0.5 text-muted-foreground", children: I ? /* @__PURE__ */ t.jsx(Te, { className: "h-4 w-4" }) : /* @__PURE__ */ t.jsx(Je, { className: "h-4 w-4" }) }),
298
- /* @__PURE__ */ t.jsxs("div", { className: "flex-1", children: [
299
- e && /* @__PURE__ */ t.jsx("h3", { className: "text-base font-semibold text-foreground", children: e }),
300
- r && /* @__PURE__ */ t.jsx("p", { className: "text-sm text-muted-foreground mt-0.5", children: r })
301
- ] })
302
- ]
303
- }
304
- ),
305
- !I && /* @__PURE__ */ t.jsx("div", { className: W("grid gap-4", E || F[o]), children: p })
306
- ] });
307
- }, tt = ({
308
- schema: e,
309
- dataSource: r,
310
- className: i
311
- }) => {
312
- const { fieldLabel: b } = ee(), [o, p] = C(null), [x, E] = C({}), [I, O] = C(!0), [F, N] = C(null), [j, h] = C(
313
- e.defaultTab || e.sections[0]?.name || e.sections[0]?.label || "tab-0"
314
- );
315
- K.useEffect(() => {
316
- (async () => {
317
- if (!r) {
318
- O(!1);
319
- return;
320
- }
321
- try {
322
- const n = await r.getObjectSchema(e.objectName);
323
- p(n);
324
- } catch (n) {
325
- N(n);
326
- }
327
- })();
328
- }, [e.objectName, r]), K.useEffect(() => {
329
- (o || !r) && (async () => {
330
- if (e.mode === "create" || !e.recordId || !r) {
331
- E(e.initialData || e.initialValues || {}), O(!1);
332
- return;
333
- }
334
- try {
335
- const n = await r.findOne(e.objectName, e.recordId);
336
- E(n || {});
337
- } catch (n) {
338
- N(n);
339
- } finally {
340
- O(!1);
341
- }
342
- })();
343
- }, [o, e.mode, e.recordId, e.initialData, e.initialValues, r, e.objectName]);
344
- const v = A((f) => {
345
- const n = [];
346
- for (const a of f.fields) {
347
- const s = typeof a == "string" ? a : a.name;
348
- if (typeof a == "object")
349
- n.push(a);
350
- else if (o?.fields?.[s]) {
351
- const c = o.fields[s];
352
- n.push({
353
- name: s,
354
- label: b(e.objectName, s, c.label || s),
355
- type: X(c.type),
356
- required: c.required || !1,
357
- disabled: e.readOnly || e.mode === "view" || c.readonly,
358
- placeholder: c.placeholder,
359
- description: c.help || c.description,
360
- validation: B(c),
361
- field: c,
362
- options: c.options,
363
- multiple: c.multiple
364
- });
365
- } else
366
- n.push({
367
- name: s,
368
- label: s,
369
- type: "input"
370
- });
371
- }
372
- return n;
373
- }, [o, e.readOnly, e.mode]), D = A(async (f) => {
374
- if (!r)
375
- return e.onSuccess && await e.onSuccess(f), f;
376
- try {
377
- let n;
378
- return e.mode === "create" ? n = await r.create(e.objectName, f) : e.mode === "edit" && e.recordId && (n = await r.update(e.objectName, e.recordId, f)), e.onSuccess && await e.onSuccess(n), n;
379
- } catch (n) {
380
- throw e.onError && e.onError(n), n;
381
- }
382
- }, [e, r]), z = A(() => {
383
- e.onCancel && e.onCancel();
384
- }, [e]), L = (f, n) => f.name || f.label || `tab-${n}`;
385
- if (F)
386
- return /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
387
- /* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
388
- /* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: F.message })
389
- ] });
390
- if (I)
391
- return /* @__PURE__ */ t.jsxs("div", { className: "p-8 text-center", children: [
392
- /* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
393
- /* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
394
- ] });
395
- const U = {
396
- type: "form",
397
- fields: e.sections.flatMap((f) => v(f)),
398
- layout: "vertical",
399
- defaultValues: x,
400
- submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
401
- cancelLabel: e.cancelText,
402
- showSubmit: e.showSubmit !== !1 && e.mode !== "view",
403
- showCancel: e.showCancel !== !1,
404
- onSubmit: D,
405
- onCancel: z
406
- }, M = e.tabPosition === "left" || e.tabPosition === "right";
407
- return /* @__PURE__ */ t.jsx("div", { className: W("w-full", i, e.className), children: /* @__PURE__ */ t.jsxs(
408
- ke,
409
- {
410
- value: j,
411
- onValueChange: h,
412
- orientation: M ? "vertical" : "horizontal",
413
- className: W(M && "flex gap-4"),
414
- children: [
415
- /* @__PURE__ */ t.jsx(_e, { className: W(
416
- M ? "flex-col h-auto" : "",
417
- e.tabPosition === "bottom" && "order-last",
418
- e.tabPosition === "right" && "order-last"
419
- ), children: e.sections.map((f, n) => /* @__PURE__ */ t.jsx(
420
- Ie,
421
- {
422
- value: L(f, n),
423
- className: M ? "w-full justify-start" : "",
424
- children: f.label || `Tab ${n + 1}`
425
- },
426
- L(f, n)
427
- )) }),
428
- /* @__PURE__ */ t.jsx("div", { className: "flex-1", children: e.sections.map((f, n) => /* @__PURE__ */ t.jsx(
429
- Le,
430
- {
431
- value: L(f, n),
432
- className: "mt-0",
433
- children: /* @__PURE__ */ t.jsx(
434
- te,
435
- {
436
- description: f.description,
437
- columns: f.columns || 1,
438
- children: /* @__PURE__ */ t.jsx(
439
- J,
440
- {
441
- schema: {
442
- ...U,
443
- fields: v(f),
444
- // Only show buttons on the last tab or always visible
445
- showSubmit: e.showSubmit !== !1 && e.mode !== "view",
446
- showCancel: e.showCancel !== !1
447
- }
448
- }
449
- )
450
- }
451
- )
452
- },
453
- L(f, n)
454
- )) })
455
- ]
456
- }
457
- ) });
458
- }, rt = ({
459
- schema: e,
460
- dataSource: r,
461
- className: i
462
- }) => {
463
- const { fieldLabel: b } = ee(), [o, p] = C(null), [x, E] = C({}), [I, O] = C(!0), [F, N] = C(null), [j, h] = C(0), [v, D] = C(/* @__PURE__ */ new Set()), [z, L] = C(!1), k = e.sections.length, U = j === 0, M = j === k - 1;
464
- K.useEffect(() => {
465
- (async () => {
466
- if (!r) {
467
- O(!1);
468
- return;
469
- }
470
- try {
471
- const T = await r.getObjectSchema(e.objectName);
472
- p(T);
473
- } catch (T) {
474
- N(T);
475
- }
476
- })();
477
- }, [e.objectName, r]), K.useEffect(() => {
478
- (o || !r) && (async () => {
479
- if (e.mode === "create" || !e.recordId || !r) {
480
- E(e.initialData || e.initialValues || {}), O(!1);
481
- return;
482
- }
483
- try {
484
- const T = await r.findOne(e.objectName, e.recordId);
485
- E(T || {});
486
- } catch (T) {
487
- N(T);
488
- } finally {
489
- O(!1);
490
- }
491
- })();
492
- }, [o, e.mode, e.recordId, e.initialData, e.initialValues, r, e.objectName]);
493
- const f = A((_) => {
494
- const T = [];
495
- for (const u of _.fields) {
496
- const g = typeof u == "string" ? u : u.name;
497
- if (typeof u == "object")
498
- T.push(u);
499
- else if (o?.fields?.[g]) {
500
- const m = o.fields[g];
501
- T.push({
502
- name: g,
503
- label: b(e.objectName, g, m.label || g),
504
- type: X(m.type),
505
- required: m.required || !1,
506
- disabled: e.readOnly || e.mode === "view" || m.readonly,
507
- placeholder: m.placeholder,
508
- description: m.help || m.description,
509
- validation: B(m),
510
- field: m,
511
- options: m.options,
512
- multiple: m.multiple
513
- });
514
- } else
515
- T.push({
516
- name: g,
517
- label: g,
518
- type: "input"
519
- });
520
- }
521
- return T;
522
- }, [o, e.readOnly, e.mode]), n = G(() => j >= 0 && j < k ? f(e.sections[j]) : [], [j, k, e.sections, f]), a = A(async (_) => {
523
- const T = { ...x, ..._ };
524
- if (E(T), D((u) => new Set(u).add(j)), M) {
525
- L(!0);
526
- try {
527
- if (!r)
528
- return e.onSuccess && await e.onSuccess(T), T;
529
- let u;
530
- return e.mode === "create" ? u = await r.create(e.objectName, T) : e.mode === "edit" && e.recordId && (u = await r.update(e.objectName, e.recordId, T)), e.onSuccess && await e.onSuccess(u), u;
531
- } catch (u) {
532
- throw e.onError && e.onError(u), u;
533
- } finally {
534
- L(!1);
535
- }
536
- } else
537
- s(j + 1);
538
- }, [x, j, M, e, r]), s = A((_) => {
539
- _ >= 0 && _ < k && (h(_), e.onStepChange && e.onStepChange(_));
540
- }, [k, e]), c = A(() => {
541
- s(j - 1);
542
- }, [j, s]), S = A(() => {
543
- e.onCancel && e.onCancel();
544
- }, [e]), y = A((_) => {
545
- (e.allowSkip || v.has(_) || _ <= j) && s(_);
546
- }, [e.allowSkip, v, j, s]);
547
- if (F)
548
- return /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
549
- /* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
550
- /* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: F.message })
551
- ] });
552
- if (I)
553
- return /* @__PURE__ */ t.jsxs("div", { className: "p-8 text-center", children: [
554
- /* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
555
- /* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
556
- ] });
557
- const d = e.sections[j];
558
- return /* @__PURE__ */ t.jsxs("div", { className: W("w-full", i, e.className), children: [
559
- e.showStepIndicator !== !1 && /* @__PURE__ */ t.jsx("nav", { "aria-label": "Progress", className: "mb-8", children: /* @__PURE__ */ t.jsx("ol", { className: "flex items-center", children: e.sections.map((_, T) => {
560
- const u = T === j, g = v.has(T), m = e.allowSkip || g || T <= j;
561
- return /* @__PURE__ */ t.jsxs(
562
- "li",
563
- {
564
- className: W(
565
- "relative flex-1",
566
- T !== k - 1 && "pr-8 sm:pr-12"
567
- ),
568
- children: [
569
- T !== k - 1 && /* @__PURE__ */ t.jsx(
570
- "div",
571
- {
572
- className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
573
- "aria-hidden": "true",
574
- children: /* @__PURE__ */ t.jsx(
575
- "div",
576
- {
577
- className: W(
578
- "h-full",
579
- g ? "bg-primary" : "bg-muted"
580
- )
581
- }
582
- )
583
- }
584
- ),
585
- /* @__PURE__ */ t.jsxs(
586
- "button",
587
- {
588
- type: "button",
589
- className: W(
590
- "group relative flex items-center",
591
- m ? "cursor-pointer" : "cursor-not-allowed"
592
- ),
593
- onClick: () => y(T),
594
- disabled: !m,
595
- children: [
596
- /* @__PURE__ */ t.jsx(
597
- "span",
598
- {
599
- className: W(
600
- "flex h-6 w-6 sm:h-8 sm:w-8 items-center justify-center rounded-full text-xs sm:text-sm font-medium transition-colors",
601
- g && "bg-primary text-primary-foreground",
602
- u && !g && "border-2 border-primary bg-background text-primary",
603
- !u && !g && "border-2 border-muted bg-background text-muted-foreground"
604
- ),
605
- children: g ? /* @__PURE__ */ t.jsx(Be, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : T + 1
606
- }
607
- ),
608
- /* @__PURE__ */ t.jsx("span", { className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block", children: /* @__PURE__ */ t.jsx(
609
- "span",
610
- {
611
- className: W(
612
- u ? "text-foreground" : "text-muted-foreground"
613
- ),
614
- children: _.label || `Step ${T + 1}`
615
- }
616
- ) })
617
- ]
618
- }
619
- )
620
- ]
621
- },
622
- T
623
- );
624
- }) }) }),
625
- /* @__PURE__ */ t.jsx("div", { className: "min-h-[200px]", children: d && /* @__PURE__ */ t.jsx(
626
- te,
627
- {
628
- label: d.label,
629
- description: d.description,
630
- columns: d.columns || 1,
631
- children: n.length > 0 ? /* @__PURE__ */ t.jsx(
632
- J,
633
- {
634
- schema: {
635
- type: "form",
636
- fields: n,
637
- layout: "vertical",
638
- defaultValues: x,
639
- showSubmit: !1,
640
- showCancel: !1,
641
- onSubmit: a
642
- }
643
- }
644
- ) : /* @__PURE__ */ t.jsx("div", { className: "text-center py-8 text-muted-foreground", children: "No fields configured for this step" })
645
- }
646
- ) }),
647
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between mt-6 pt-4 border-t", children: [
648
- /* @__PURE__ */ t.jsx("div", { children: e.showCancel !== !1 && /* @__PURE__ */ t.jsx(
649
- Z,
650
- {
651
- variant: "ghost",
652
- onClick: S,
653
- children: e.cancelText || "Cancel"
654
- }
655
- ) }),
656
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
657
- /* @__PURE__ */ t.jsxs("span", { className: "text-sm text-muted-foreground mr-2", children: [
658
- "Step ",
659
- j + 1,
660
- " of ",
661
- k
662
- ] }),
663
- !U && /* @__PURE__ */ t.jsxs(
664
- Z,
665
- {
666
- variant: "outline",
667
- onClick: c,
668
- children: [
669
- /* @__PURE__ */ t.jsx(Xe, { className: "h-4 w-4 mr-1" }),
670
- e.prevText || "Back"
671
- ]
672
- }
673
- ),
674
- M ? /* @__PURE__ */ t.jsx(
675
- Z,
676
- {
677
- onClick: () => a(x),
678
- disabled: z || e.mode === "view",
679
- children: z ? "Submitting..." : e.submitText || (e.mode === "create" ? "Create" : "Update")
680
- }
681
- ) : /* @__PURE__ */ t.jsxs(
682
- Z,
683
- {
684
- onClick: () => a(x),
685
- children: [
686
- e.nextText || "Next",
687
- /* @__PURE__ */ t.jsx(Te, { className: "h-4 w-4 ml-1" })
688
- ]
689
- }
690
- )
691
- ] })
692
- ] })
693
- ] });
694
- }, lt = ({
695
- schema: e,
696
- dataSource: r,
697
- className: i
698
- }) => {
699
- const { fieldLabel: b } = ee(), [o, p] = C(null), [x, E] = C({}), [I, O] = C(!0), [F, N] = C(null);
700
- H(() => {
701
- (async () => {
702
- if (!r) {
703
- O(!1);
704
- return;
705
- }
706
- try {
707
- const n = await r.getObjectSchema(e.objectName);
708
- p(n);
709
- } catch (n) {
710
- N(n), O(!1);
711
- }
712
- })();
713
- }, [e.objectName, r]), H(() => {
714
- (o || !r) && (async () => {
715
- if (e.mode === "create" || !e.recordId) {
716
- E(e.initialData || e.initialValues || {}), O(!1);
717
- return;
718
- }
719
- if (!r) {
720
- E(e.initialData || e.initialValues || {}), O(!1);
721
- return;
722
- }
723
- try {
724
- const n = await r.findOne(e.objectName, e.recordId);
725
- E(n || {});
726
- } catch (n) {
727
- N(n);
728
- } finally {
729
- O(!1);
730
- }
731
- })();
732
- }, [o, e.mode, e.recordId, e.initialData, e.initialValues, r, e.objectName]);
733
- const j = A((f) => {
734
- const n = [];
735
- for (const a of f.fields) {
736
- const s = typeof a == "string" ? a : a.name;
737
- if (typeof a == "object")
738
- n.push(a);
739
- else if (o?.fields?.[s]) {
740
- const c = o.fields[s];
741
- n.push({
742
- name: s,
743
- label: b(e.objectName, s, c.label || s),
744
- type: X(c.type),
745
- required: c.required || !1,
746
- disabled: e.readOnly || e.mode === "view" || c.readonly,
747
- placeholder: c.placeholder,
748
- description: c.help || c.description,
749
- validation: B(c),
750
- field: c,
751
- options: c.options,
752
- multiple: c.multiple
753
- });
754
- } else
755
- n.push({
756
- name: s,
757
- label: s,
758
- type: "input"
759
- });
760
- }
761
- return n;
762
- }, [o, e.readOnly, e.mode]), h = A(async (f) => {
763
- if (!r)
764
- return e.onSuccess && await e.onSuccess(f), f;
765
- try {
766
- let n;
767
- return e.mode === "create" ? n = await r.create(e.objectName, f) : e.mode === "edit" && e.recordId && (n = await r.update(e.objectName, e.recordId, f)), e.onSuccess && await e.onSuccess(n), n;
768
- } catch (n) {
769
- throw e.onError && e.onError(n), n;
770
- }
771
- }, [e, r]), v = A(() => {
772
- e.onCancel && e.onCancel();
773
- }, [e]), D = G(() => e.sections.slice(0, 1), [e.sections]), z = G(() => e.sections.slice(1), [e.sections]);
774
- G(
775
- () => e.sections.flatMap((f) => j(f)),
776
- [e.sections, j]
777
- );
778
- const L = e.splitDirection || "horizontal", k = e.splitSize || 50;
779
- if (F)
780
- return /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
781
- /* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
782
- /* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: F.message })
783
- ] });
784
- if (I)
785
- return /* @__PURE__ */ t.jsxs("div", { className: "p-8 text-center", children: [
786
- /* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
787
- /* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
788
- ] });
789
- const U = {
790
- type: "form",
791
- layout: "vertical",
792
- defaultValues: x,
793
- onSubmit: h,
794
- onCancel: v
795
- }, M = (f, n) => /* @__PURE__ */ t.jsx("div", { className: "space-y-4 p-4", children: f.map((a, s) => /* @__PURE__ */ t.jsx(
796
- te,
797
- {
798
- label: a.label,
799
- description: a.description,
800
- columns: a.columns || 1,
801
- children: /* @__PURE__ */ t.jsx(
802
- J,
803
- {
804
- schema: {
805
- ...U,
806
- fields: j(a),
807
- showSubmit: n && e.showSubmit !== !1 && e.mode !== "view",
808
- showCancel: n && e.showCancel !== !1,
809
- submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
810
- cancelLabel: e.cancelText
811
- }
812
- }
813
- )
814
- },
815
- a.name || a.label || s
816
- )) });
817
- return /* @__PURE__ */ t.jsx("div", { className: W("w-full", i, e.className), children: /* @__PURE__ */ t.jsxs(Pe, { orientation: L, className: "min-h-[300px] rounded-lg border", children: [
818
- /* @__PURE__ */ t.jsx(be, { defaultSize: k, minSize: 20, children: M(D, z.length === 0) }),
819
- z.length > 0 && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
820
- /* @__PURE__ */ t.jsx(Ae, { withHandle: e.splitResizable !== !1 }),
821
- /* @__PURE__ */ t.jsx(be, { defaultSize: 100 - k, minSize: 20, children: M(z, !0) })
822
- ] })
823
- ] }) });
824
- }, nt = /* @__PURE__ */ new Set([
825
- "field:textarea",
826
- "field:markdown",
827
- "field:html",
828
- "field:grid",
829
- "field:rich-text",
830
- "textarea",
831
- "markdown",
832
- "html",
833
- "grid",
834
- "rich-text"
835
- ]), it = /* @__PURE__ */ new Set([
836
- "formula",
837
- "summary",
838
- "auto_number",
839
- "autonumber"
1
+ import e, { useCallback as t, useEffect as n, useId as r, useMemo as i, useState as a } from "react";
2
+ import { ComponentRegistry as o } from "@object-ui/core";
3
+ import { SchemaRenderer as s, useSafeFieldLabel as c } from "@object-ui/react";
4
+ import { buildValidationRules as l, evaluateCondition as u, formatFileSize as d, mapFieldTypeToFormType as f } from "@object-ui/fields";
5
+ import { Button as p, Card as m, CardContent as h, CardDescription as g, CardHeader as _, CardTitle as v, Dialog as y, DialogDescription as b, DialogHeader as x, DialogTitle as S, MobileDialogContent as C, ResizableHandle as w, ResizablePanel as T, ResizablePanelGroup as E, Sheet as D, SheetContent as O, SheetDescription as k, SheetHeader as A, SheetTitle as j, Skeleton as M, Tabs as N, TabsContent as P, TabsList as F, TabsTrigger as I, cn as L } from "@object-ui/components";
6
+ import { Check as R, ChevronDown as z, ChevronLeft as B, ChevronRight as V, Loader2 as ee } from "lucide-react";
7
+ //#region \0rolldown/runtime.js
8
+ var H = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), U = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
9
+ if (typeof require < "u") return require.apply(this, arguments);
10
+ throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
11
+ }), W = /* @__PURE__ */ H(((e) => {
12
+ var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
13
+ function r(e, n, r) {
14
+ var i = null;
15
+ if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
16
+ else r = n;
17
+ return n = r.ref, {
18
+ $$typeof: t,
19
+ type: e,
20
+ key: i,
21
+ ref: n === void 0 ? null : n,
22
+ props: r
23
+ };
24
+ }
25
+ e.Fragment = n, e.jsx = r, e.jsxs = r;
26
+ })), G = /* @__PURE__ */ H(((e) => {
27
+ process.env.NODE_ENV !== "production" && (function() {
28
+ function t(e) {
29
+ if (e == null) return null;
30
+ if (typeof e == "function") return e.$$typeof === O ? null : e.displayName || e.name || null;
31
+ if (typeof e == "string") return e;
32
+ switch (e) {
33
+ case _: return "Fragment";
34
+ case y: return "Profiler";
35
+ case v: return "StrictMode";
36
+ case C: return "Suspense";
37
+ case w: return "SuspenseList";
38
+ case D: return "Activity";
39
+ }
40
+ if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
41
+ case g: return "Portal";
42
+ case x: return e.displayName || "Context";
43
+ case b: return (e._context.displayName || "Context") + ".Consumer";
44
+ case S:
45
+ var n = e.render;
46
+ return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
47
+ case T: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
48
+ case E:
49
+ n = e._payload, e = e._init;
50
+ try {
51
+ return t(e(n));
52
+ } catch {}
53
+ }
54
+ return null;
55
+ }
56
+ function n(e) {
57
+ return "" + e;
58
+ }
59
+ function r(e) {
60
+ try {
61
+ n(e);
62
+ var t = !1;
63
+ } catch {
64
+ t = !0;
65
+ }
66
+ if (t) {
67
+ t = console;
68
+ var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
69
+ return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
70
+ }
71
+ }
72
+ function i(e) {
73
+ if (e === _) return "<>";
74
+ if (typeof e == "object" && e && e.$$typeof === E) return "<...>";
75
+ try {
76
+ var n = t(e);
77
+ return n ? "<" + n + ">" : "<...>";
78
+ } catch {
79
+ return "<...>";
80
+ }
81
+ }
82
+ function a() {
83
+ var e = k.A;
84
+ return e === null ? null : e.getOwner();
85
+ }
86
+ function o() {
87
+ return Error("react-stack-top-frame");
88
+ }
89
+ function s(e) {
90
+ if (A.call(e, "key")) {
91
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
92
+ if (t && t.isReactWarning) return !1;
93
+ }
94
+ return e.key !== void 0;
95
+ }
96
+ function c(e, t) {
97
+ function n() {
98
+ N || (N = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
99
+ }
100
+ n.isReactWarning = !0, Object.defineProperty(e, "key", {
101
+ get: n,
102
+ configurable: !0
103
+ });
104
+ }
105
+ function l() {
106
+ var e = t(this.type);
107
+ return P[e] || (P[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
108
+ }
109
+ function u(e, t, n, r, i, a) {
110
+ var o = n.ref;
111
+ return e = {
112
+ $$typeof: h,
113
+ type: e,
114
+ key: t,
115
+ props: n,
116
+ _owner: r
117
+ }, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
118
+ enumerable: !1,
119
+ value: null
120
+ }) : Object.defineProperty(e, "ref", {
121
+ enumerable: !1,
122
+ get: l
123
+ }), e._store = {}, Object.defineProperty(e._store, "validated", {
124
+ configurable: !1,
125
+ enumerable: !1,
126
+ writable: !0,
127
+ value: 0
128
+ }), Object.defineProperty(e, "_debugInfo", {
129
+ configurable: !1,
130
+ enumerable: !1,
131
+ writable: !0,
132
+ value: null
133
+ }), Object.defineProperty(e, "_debugStack", {
134
+ configurable: !1,
135
+ enumerable: !1,
136
+ writable: !0,
137
+ value: i
138
+ }), Object.defineProperty(e, "_debugTask", {
139
+ configurable: !1,
140
+ enumerable: !1,
141
+ writable: !0,
142
+ value: a
143
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
144
+ }
145
+ function d(e, n, i, o, l, d) {
146
+ var p = n.children;
147
+ if (p !== void 0) if (o) if (j(p)) {
148
+ for (o = 0; o < p.length; o++) f(p[o]);
149
+ Object.freeze && Object.freeze(p);
150
+ } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
151
+ else f(p);
152
+ if (A.call(n, "key")) {
153
+ p = t(e);
154
+ var m = Object.keys(n).filter(function(e) {
155
+ return e !== "key";
156
+ });
157
+ o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", L[p + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, p, m, p), L[p + o] = !0);
158
+ }
159
+ if (p = null, i !== void 0 && (r(i), p = "" + i), s(n) && (r(n.key), p = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
160
+ else i = n;
161
+ return p && c(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), u(e, p, i, a(), l, d);
162
+ }
163
+ function f(e) {
164
+ p(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === E && (e._payload.status === "fulfilled" ? p(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
165
+ }
166
+ function p(e) {
167
+ return typeof e == "object" && !!e && e.$$typeof === h;
168
+ }
169
+ var m = U("react"), h = Symbol.for("react.transitional.element"), g = Symbol.for("react.portal"), _ = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), b = Symbol.for("react.consumer"), x = Symbol.for("react.context"), S = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), w = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), D = Symbol.for("react.activity"), O = Symbol.for("react.client.reference"), k = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, A = Object.prototype.hasOwnProperty, j = Array.isArray, M = console.createTask ? console.createTask : function() {
170
+ return null;
171
+ };
172
+ m = { react_stack_bottom_frame: function(e) {
173
+ return e();
174
+ } };
175
+ var N, P = {}, F = m.react_stack_bottom_frame.bind(m, o)(), I = M(i(o)), L = {};
176
+ e.Fragment = _, e.jsx = function(e, t, n) {
177
+ var r = 1e4 > k.recentlyCreatedOwnerStacks++;
178
+ return d(e, t, n, !1, r ? Error("react-stack-top-frame") : F, r ? M(i(e)) : I);
179
+ }, e.jsxs = function(e, t, n) {
180
+ var r = 1e4 > k.recentlyCreatedOwnerStacks++;
181
+ return d(e, t, n, !0, r ? Error("react-stack-top-frame") : F, r ? M(i(e)) : I);
182
+ };
183
+ })();
184
+ })), K = (/* @__PURE__ */ H(((e, t) => {
185
+ process.env.NODE_ENV === "production" ? t.exports = W() : t.exports = G();
186
+ })))(), q = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: o, className: s, gridClassName: c }) => {
187
+ let [l, u] = a(r), d = {
188
+ 1: "grid-cols-1",
189
+ 2: "grid-cols-1 md:grid-cols-2",
190
+ 3: "grid-cols-1 md:grid-cols-2 lg:grid-cols-3",
191
+ 4: "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
192
+ };
193
+ return /* @__PURE__ */ (0, K.jsxs)("div", {
194
+ className: L("form-section", s),
195
+ children: [(e || t) && /* @__PURE__ */ (0, K.jsxs)("div", {
196
+ className: L("flex items-start gap-2 mb-4", n && "cursor-pointer select-none"),
197
+ onClick: () => {
198
+ n && u(!l);
199
+ },
200
+ role: n ? "button" : void 0,
201
+ "aria-expanded": n ? !l : void 0,
202
+ children: [n && /* @__PURE__ */ (0, K.jsx)("span", {
203
+ className: "mt-0.5 text-muted-foreground",
204
+ children: l ? /* @__PURE__ */ (0, K.jsx)(V, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, K.jsx)(z, { className: "h-4 w-4" })
205
+ }), /* @__PURE__ */ (0, K.jsxs)("div", {
206
+ className: "flex-1",
207
+ children: [e && /* @__PURE__ */ (0, K.jsx)("h3", {
208
+ className: "text-base font-semibold text-foreground",
209
+ children: e
210
+ }), t && /* @__PURE__ */ (0, K.jsx)("p", {
211
+ className: "text-sm text-muted-foreground mt-0.5",
212
+ children: t
213
+ })]
214
+ })]
215
+ }), !l && /* @__PURE__ */ (0, K.jsx)("div", {
216
+ className: L("grid gap-4", c || d[i]),
217
+ children: o
218
+ })]
219
+ });
220
+ }, J = ({ schema: n, dataSource: r, className: i }) => {
221
+ let { fieldLabel: o } = c(), [u, d] = a(null), [p, m] = a({}), [h, g] = a(!0), [_, v] = a(null), [y, b] = a(n.defaultTab || n.sections[0]?.name || n.sections[0]?.label || "tab-0");
222
+ e.useEffect(() => {
223
+ (async () => {
224
+ if (!r) {
225
+ g(!1);
226
+ return;
227
+ }
228
+ try {
229
+ d(await r.getObjectSchema(n.objectName));
230
+ } catch (e) {
231
+ v(e);
232
+ }
233
+ })();
234
+ }, [n.objectName, r]), e.useEffect(() => {
235
+ (u || !r) && (async () => {
236
+ if (n.mode === "create" || !n.recordId || !r) {
237
+ m(n.initialData || n.initialValues || {}), g(!1);
238
+ return;
239
+ }
240
+ try {
241
+ m(await r.findOne(n.objectName, n.recordId) || {});
242
+ } catch (e) {
243
+ v(e);
244
+ } finally {
245
+ g(!1);
246
+ }
247
+ })();
248
+ }, [
249
+ u,
250
+ n.mode,
251
+ n.recordId,
252
+ n.initialData,
253
+ n.initialValues,
254
+ r,
255
+ n.objectName
256
+ ]);
257
+ let x = t((e) => {
258
+ let t = [];
259
+ for (let r of e.fields) {
260
+ let e = typeof r == "string" ? r : r.name;
261
+ if (typeof r == "object") t.push(r);
262
+ else if (u?.fields?.[e]) {
263
+ let r = u.fields[e];
264
+ t.push({
265
+ name: e,
266
+ label: o(n.objectName, e, r.label || e),
267
+ type: f(r.type),
268
+ required: r.required || !1,
269
+ disabled: n.readOnly || n.mode === "view" || r.readonly,
270
+ placeholder: r.placeholder,
271
+ description: r.help || r.description,
272
+ validation: l(r),
273
+ field: r,
274
+ options: r.options,
275
+ multiple: r.multiple
276
+ });
277
+ } else t.push({
278
+ name: e,
279
+ label: e,
280
+ type: "input"
281
+ });
282
+ }
283
+ return t;
284
+ }, [
285
+ u,
286
+ n.readOnly,
287
+ n.mode
288
+ ]), S = t(async (e) => {
289
+ if (!r) return n.onSuccess && await n.onSuccess(e), e;
290
+ try {
291
+ let t;
292
+ return n.mode === "create" ? t = await r.create(n.objectName, e) : n.mode === "edit" && n.recordId && (t = await r.update(n.objectName, n.recordId, e)), n.onSuccess && await n.onSuccess(t), t;
293
+ } catch (e) {
294
+ throw n.onError && n.onError(e), e;
295
+ }
296
+ }, [n, r]), C = t(() => {
297
+ n.onCancel && n.onCancel();
298
+ }, [n]), w = (e, t) => e.name || e.label || `tab-${t}`;
299
+ if (_) return /* @__PURE__ */ (0, K.jsxs)("div", {
300
+ className: "p-4 border border-red-300 bg-red-50 rounded-md",
301
+ children: [/* @__PURE__ */ (0, K.jsx)("h3", {
302
+ className: "text-red-800 font-semibold",
303
+ children: "Error loading form"
304
+ }), /* @__PURE__ */ (0, K.jsx)("p", {
305
+ className: "text-red-600 text-sm mt-1",
306
+ children: _.message
307
+ })]
308
+ });
309
+ if (h) return /* @__PURE__ */ (0, K.jsxs)("div", {
310
+ className: "p-8 text-center",
311
+ children: [/* @__PURE__ */ (0, K.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, K.jsx)("p", {
312
+ className: "mt-2 text-sm text-gray-600",
313
+ children: "Loading form..."
314
+ })]
315
+ });
316
+ let T = {
317
+ type: "form",
318
+ fields: n.sections.flatMap((e) => x(e)),
319
+ layout: "vertical",
320
+ defaultValues: p,
321
+ submitLabel: n.submitText || (n.mode === "create" ? "Create" : "Update"),
322
+ cancelLabel: n.cancelText,
323
+ showSubmit: n.showSubmit !== !1 && n.mode !== "view",
324
+ showCancel: n.showCancel !== !1,
325
+ onSubmit: S,
326
+ onCancel: C
327
+ }, E = n.tabPosition === "left" || n.tabPosition === "right";
328
+ return /* @__PURE__ */ (0, K.jsx)("div", {
329
+ className: L("w-full", i, n.className),
330
+ children: /* @__PURE__ */ (0, K.jsxs)(N, {
331
+ value: y,
332
+ onValueChange: b,
333
+ orientation: E ? "vertical" : "horizontal",
334
+ className: L(E && "flex gap-4"),
335
+ children: [/* @__PURE__ */ (0, K.jsx)(F, {
336
+ className: L(E ? "flex-col h-auto" : "", n.tabPosition === "bottom" && "order-last", n.tabPosition === "right" && "order-last"),
337
+ children: n.sections.map((e, t) => /* @__PURE__ */ (0, K.jsx)(I, {
338
+ value: w(e, t),
339
+ className: E ? "w-full justify-start" : "",
340
+ children: e.label || `Tab ${t + 1}`
341
+ }, w(e, t)))
342
+ }), /* @__PURE__ */ (0, K.jsx)("div", {
343
+ className: "flex-1",
344
+ children: n.sections.map((e, t) => /* @__PURE__ */ (0, K.jsx)(P, {
345
+ value: w(e, t),
346
+ className: "mt-0",
347
+ children: /* @__PURE__ */ (0, K.jsx)(q, {
348
+ description: e.description,
349
+ columns: e.columns || 1,
350
+ children: /* @__PURE__ */ (0, K.jsx)(s, { schema: {
351
+ ...T,
352
+ fields: x(e),
353
+ showSubmit: n.showSubmit !== !1 && n.mode !== "view",
354
+ showCancel: n.showCancel !== !1
355
+ } })
356
+ })
357
+ }, w(e, t)))
358
+ })]
359
+ })
360
+ });
361
+ }, Y = ({ schema: n, dataSource: r, className: o }) => {
362
+ let { fieldLabel: u } = c(), [d, m] = a(null), [h, g] = a({}), [_, v] = a(!0), [y, b] = a(null), [x, S] = a(0), [C, w] = a(/* @__PURE__ */ new Set()), [T, E] = a(!1), D = n.sections.length, O = x === 0, k = x === D - 1;
363
+ e.useEffect(() => {
364
+ (async () => {
365
+ if (!r) {
366
+ v(!1);
367
+ return;
368
+ }
369
+ try {
370
+ m(await r.getObjectSchema(n.objectName));
371
+ } catch (e) {
372
+ b(e);
373
+ }
374
+ })();
375
+ }, [n.objectName, r]), e.useEffect(() => {
376
+ (d || !r) && (async () => {
377
+ if (n.mode === "create" || !n.recordId || !r) {
378
+ g(n.initialData || n.initialValues || {}), v(!1);
379
+ return;
380
+ }
381
+ try {
382
+ g(await r.findOne(n.objectName, n.recordId) || {});
383
+ } catch (e) {
384
+ b(e);
385
+ } finally {
386
+ v(!1);
387
+ }
388
+ })();
389
+ }, [
390
+ d,
391
+ n.mode,
392
+ n.recordId,
393
+ n.initialData,
394
+ n.initialValues,
395
+ r,
396
+ n.objectName
397
+ ]);
398
+ let A = t((e) => {
399
+ let t = [];
400
+ for (let r of e.fields) {
401
+ let e = typeof r == "string" ? r : r.name;
402
+ if (typeof r == "object") t.push(r);
403
+ else if (d?.fields?.[e]) {
404
+ let r = d.fields[e];
405
+ t.push({
406
+ name: e,
407
+ label: u(n.objectName, e, r.label || e),
408
+ type: f(r.type),
409
+ required: r.required || !1,
410
+ disabled: n.readOnly || n.mode === "view" || r.readonly,
411
+ placeholder: r.placeholder,
412
+ description: r.help || r.description,
413
+ validation: l(r),
414
+ field: r,
415
+ options: r.options,
416
+ multiple: r.multiple
417
+ });
418
+ } else t.push({
419
+ name: e,
420
+ label: e,
421
+ type: "input"
422
+ });
423
+ }
424
+ return t;
425
+ }, [
426
+ d,
427
+ n.readOnly,
428
+ n.mode
429
+ ]), j = i(() => x >= 0 && x < D ? A(n.sections[x]) : [], [
430
+ x,
431
+ D,
432
+ n.sections,
433
+ A
434
+ ]), M = t(async (e) => {
435
+ let t = {
436
+ ...h,
437
+ ...e
438
+ };
439
+ if (g(t), w((e) => new Set(e).add(x)), k) {
440
+ E(!0);
441
+ try {
442
+ if (!r) return n.onSuccess && await n.onSuccess(t), t;
443
+ let e;
444
+ return n.mode === "create" ? e = await r.create(n.objectName, t) : n.mode === "edit" && n.recordId && (e = await r.update(n.objectName, n.recordId, t)), n.onSuccess && await n.onSuccess(e), e;
445
+ } catch (e) {
446
+ throw n.onError && n.onError(e), e;
447
+ } finally {
448
+ E(!1);
449
+ }
450
+ } else N(x + 1);
451
+ }, [
452
+ h,
453
+ x,
454
+ k,
455
+ n,
456
+ r
457
+ ]), N = t((e) => {
458
+ e >= 0 && e < D && (S(e), n.onStepChange && n.onStepChange(e));
459
+ }, [D, n]), P = t(() => {
460
+ N(x - 1);
461
+ }, [x, N]), F = t(() => {
462
+ n.onCancel && n.onCancel();
463
+ }, [n]), I = t((e) => {
464
+ (n.allowSkip || C.has(e) || e <= x) && N(e);
465
+ }, [
466
+ n.allowSkip,
467
+ C,
468
+ x,
469
+ N
470
+ ]);
471
+ if (y) return /* @__PURE__ */ (0, K.jsxs)("div", {
472
+ className: "p-4 border border-red-300 bg-red-50 rounded-md",
473
+ children: [/* @__PURE__ */ (0, K.jsx)("h3", {
474
+ className: "text-red-800 font-semibold",
475
+ children: "Error loading form"
476
+ }), /* @__PURE__ */ (0, K.jsx)("p", {
477
+ className: "text-red-600 text-sm mt-1",
478
+ children: y.message
479
+ })]
480
+ });
481
+ if (_) return /* @__PURE__ */ (0, K.jsxs)("div", {
482
+ className: "p-8 text-center",
483
+ children: [/* @__PURE__ */ (0, K.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, K.jsx)("p", {
484
+ className: "mt-2 text-sm text-gray-600",
485
+ children: "Loading form..."
486
+ })]
487
+ });
488
+ let z = n.sections[x];
489
+ return /* @__PURE__ */ (0, K.jsxs)("div", {
490
+ className: L("w-full", o, n.className),
491
+ children: [
492
+ n.showStepIndicator !== !1 && /* @__PURE__ */ (0, K.jsx)("nav", {
493
+ "aria-label": "Progress",
494
+ className: "mb-8",
495
+ children: /* @__PURE__ */ (0, K.jsx)("ol", {
496
+ className: "flex items-center",
497
+ children: n.sections.map((e, t) => {
498
+ let r = t === x, i = C.has(t), a = n.allowSkip || i || t <= x;
499
+ return /* @__PURE__ */ (0, K.jsxs)("li", {
500
+ className: L("relative flex-1", t !== D - 1 && "pr-8 sm:pr-12"),
501
+ children: [t !== D - 1 && /* @__PURE__ */ (0, K.jsx)("div", {
502
+ className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
503
+ "aria-hidden": "true",
504
+ children: /* @__PURE__ */ (0, K.jsx)("div", { className: L("h-full", i ? "bg-primary" : "bg-muted") })
505
+ }), /* @__PURE__ */ (0, K.jsxs)("button", {
506
+ type: "button",
507
+ className: L("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
508
+ onClick: () => I(t),
509
+ disabled: !a,
510
+ children: [/* @__PURE__ */ (0, K.jsx)("span", {
511
+ className: L("flex h-6 w-6 sm:h-8 sm:w-8 items-center justify-center rounded-full text-xs sm:text-sm font-medium transition-colors", i && "bg-primary text-primary-foreground", r && !i && "border-2 border-primary bg-background text-primary", !r && !i && "border-2 border-muted bg-background text-muted-foreground"),
512
+ children: i ? /* @__PURE__ */ (0, K.jsx)(R, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : t + 1
513
+ }), /* @__PURE__ */ (0, K.jsx)("span", {
514
+ className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block",
515
+ children: /* @__PURE__ */ (0, K.jsx)("span", {
516
+ className: L(r ? "text-foreground" : "text-muted-foreground"),
517
+ children: e.label || `Step ${t + 1}`
518
+ })
519
+ })]
520
+ })]
521
+ }, t);
522
+ })
523
+ })
524
+ }),
525
+ /* @__PURE__ */ (0, K.jsx)("div", {
526
+ className: "min-h-[200px]",
527
+ children: z && /* @__PURE__ */ (0, K.jsx)(q, {
528
+ label: z.label,
529
+ description: z.description,
530
+ columns: z.columns || 1,
531
+ children: j.length > 0 ? /* @__PURE__ */ (0, K.jsx)(s, { schema: {
532
+ type: "form",
533
+ fields: j,
534
+ layout: "vertical",
535
+ defaultValues: h,
536
+ showSubmit: !1,
537
+ showCancel: !1,
538
+ onSubmit: M
539
+ } }) : /* @__PURE__ */ (0, K.jsx)("div", {
540
+ className: "text-center py-8 text-muted-foreground",
541
+ children: "No fields configured for this step"
542
+ })
543
+ })
544
+ }),
545
+ /* @__PURE__ */ (0, K.jsxs)("div", {
546
+ className: "flex items-center justify-between mt-6 pt-4 border-t",
547
+ children: [/* @__PURE__ */ (0, K.jsx)("div", { children: n.showCancel !== !1 && /* @__PURE__ */ (0, K.jsx)(p, {
548
+ variant: "ghost",
549
+ onClick: F,
550
+ children: n.cancelText || "Cancel"
551
+ }) }), /* @__PURE__ */ (0, K.jsxs)("div", {
552
+ className: "flex items-center gap-2",
553
+ children: [
554
+ /* @__PURE__ */ (0, K.jsxs)("span", {
555
+ className: "text-sm text-muted-foreground mr-2",
556
+ children: [
557
+ "Step ",
558
+ x + 1,
559
+ " of ",
560
+ D
561
+ ]
562
+ }),
563
+ !O && /* @__PURE__ */ (0, K.jsxs)(p, {
564
+ variant: "outline",
565
+ onClick: P,
566
+ children: [/* @__PURE__ */ (0, K.jsx)(B, { className: "h-4 w-4 mr-1" }), n.prevText || "Back"]
567
+ }),
568
+ k ? /* @__PURE__ */ (0, K.jsx)(p, {
569
+ onClick: () => M(h),
570
+ disabled: T || n.mode === "view",
571
+ children: T ? "Submitting..." : n.submitText || (n.mode === "create" ? "Create" : "Update")
572
+ }) : /* @__PURE__ */ (0, K.jsxs)(p, {
573
+ onClick: () => M(h),
574
+ children: [n.nextText || "Next", /* @__PURE__ */ (0, K.jsx)(V, { className: "h-4 w-4 ml-1" })]
575
+ })
576
+ ]
577
+ })]
578
+ })
579
+ ]
580
+ });
581
+ }, te = ({ schema: e, dataSource: r, className: o }) => {
582
+ let { fieldLabel: u } = c(), [d, p] = a(null), [m, h] = a({}), [g, _] = a(!0), [v, y] = a(null);
583
+ n(() => {
584
+ (async () => {
585
+ if (!r) {
586
+ _(!1);
587
+ return;
588
+ }
589
+ try {
590
+ p(await r.getObjectSchema(e.objectName));
591
+ } catch (e) {
592
+ y(e), _(!1);
593
+ }
594
+ })();
595
+ }, [e.objectName, r]), n(() => {
596
+ (d || !r) && (async () => {
597
+ if (e.mode === "create" || !e.recordId) {
598
+ h(e.initialData || e.initialValues || {}), _(!1);
599
+ return;
600
+ }
601
+ if (!r) {
602
+ h(e.initialData || e.initialValues || {}), _(!1);
603
+ return;
604
+ }
605
+ try {
606
+ h(await r.findOne(e.objectName, e.recordId) || {});
607
+ } catch (e) {
608
+ y(e);
609
+ } finally {
610
+ _(!1);
611
+ }
612
+ })();
613
+ }, [
614
+ d,
615
+ e.mode,
616
+ e.recordId,
617
+ e.initialData,
618
+ e.initialValues,
619
+ r,
620
+ e.objectName
621
+ ]);
622
+ let b = t((t) => {
623
+ let n = [];
624
+ for (let r of t.fields) {
625
+ let t = typeof r == "string" ? r : r.name;
626
+ if (typeof r == "object") n.push(r);
627
+ else if (d?.fields?.[t]) {
628
+ let r = d.fields[t];
629
+ n.push({
630
+ name: t,
631
+ label: u(e.objectName, t, r.label || t),
632
+ type: f(r.type),
633
+ required: r.required || !1,
634
+ disabled: e.readOnly || e.mode === "view" || r.readonly,
635
+ placeholder: r.placeholder,
636
+ description: r.help || r.description,
637
+ validation: l(r),
638
+ field: r,
639
+ options: r.options,
640
+ multiple: r.multiple
641
+ });
642
+ } else n.push({
643
+ name: t,
644
+ label: t,
645
+ type: "input"
646
+ });
647
+ }
648
+ return n;
649
+ }, [
650
+ d,
651
+ e.readOnly,
652
+ e.mode
653
+ ]), x = t(async (t) => {
654
+ if (!r) return e.onSuccess && await e.onSuccess(t), t;
655
+ try {
656
+ let n;
657
+ return e.mode === "create" ? n = await r.create(e.objectName, t) : e.mode === "edit" && e.recordId && (n = await r.update(e.objectName, e.recordId, t)), e.onSuccess && await e.onSuccess(n), n;
658
+ } catch (t) {
659
+ throw e.onError && e.onError(t), t;
660
+ }
661
+ }, [e, r]), S = t(() => {
662
+ e.onCancel && e.onCancel();
663
+ }, [e]), C = i(() => e.sections.slice(0, 1), [e.sections]), D = i(() => e.sections.slice(1), [e.sections]);
664
+ i(() => e.sections.flatMap((e) => b(e)), [e.sections, b]);
665
+ let O = e.splitDirection || "horizontal", k = e.splitSize || 50;
666
+ if (v) return /* @__PURE__ */ (0, K.jsxs)("div", {
667
+ className: "p-4 border border-red-300 bg-red-50 rounded-md",
668
+ children: [/* @__PURE__ */ (0, K.jsx)("h3", {
669
+ className: "text-red-800 font-semibold",
670
+ children: "Error loading form"
671
+ }), /* @__PURE__ */ (0, K.jsx)("p", {
672
+ className: "text-red-600 text-sm mt-1",
673
+ children: v.message
674
+ })]
675
+ });
676
+ if (g) return /* @__PURE__ */ (0, K.jsxs)("div", {
677
+ className: "p-8 text-center",
678
+ children: [/* @__PURE__ */ (0, K.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, K.jsx)("p", {
679
+ className: "mt-2 text-sm text-gray-600",
680
+ children: "Loading form..."
681
+ })]
682
+ });
683
+ let A = {
684
+ type: "form",
685
+ layout: "vertical",
686
+ defaultValues: m,
687
+ onSubmit: x,
688
+ onCancel: S
689
+ }, j = (t, n) => /* @__PURE__ */ (0, K.jsx)("div", {
690
+ className: "space-y-4 p-4",
691
+ children: t.map((t, r) => /* @__PURE__ */ (0, K.jsx)(q, {
692
+ label: t.label,
693
+ description: t.description,
694
+ columns: t.columns || 1,
695
+ children: /* @__PURE__ */ (0, K.jsx)(s, { schema: {
696
+ ...A,
697
+ fields: b(t),
698
+ showSubmit: n && e.showSubmit !== !1 && e.mode !== "view",
699
+ showCancel: n && e.showCancel !== !1,
700
+ submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
701
+ cancelLabel: e.cancelText
702
+ } })
703
+ }, t.name || t.label || r))
704
+ });
705
+ return /* @__PURE__ */ (0, K.jsx)("div", {
706
+ className: L("w-full", o, e.className),
707
+ children: /* @__PURE__ */ (0, K.jsxs)(E, {
708
+ orientation: O,
709
+ className: "min-h-[300px] rounded-lg border",
710
+ children: [/* @__PURE__ */ (0, K.jsx)(T, {
711
+ defaultSize: k,
712
+ minSize: 20,
713
+ children: j(C, D.length === 0)
714
+ }), D.length > 0 && /* @__PURE__ */ (0, K.jsxs)(K.Fragment, { children: [/* @__PURE__ */ (0, K.jsx)(w, { withHandle: e.splitResizable !== !1 }), /* @__PURE__ */ (0, K.jsx)(T, {
715
+ defaultSize: 100 - k,
716
+ minSize: 20,
717
+ children: j(D, !0)
718
+ })] })]
719
+ })
720
+ });
721
+ }, ne = new Set([
722
+ "field:textarea",
723
+ "field:markdown",
724
+ "field:html",
725
+ "field:grid",
726
+ "field:rich-text",
727
+ "textarea",
728
+ "markdown",
729
+ "html",
730
+ "grid",
731
+ "rich-text"
732
+ ]), re = new Set([
733
+ "formula",
734
+ "summary",
735
+ "auto_number",
736
+ "autonumber"
840
737
  ]);
841
- function ot(e) {
842
- return nt.has(e);
738
+ function ie(e) {
739
+ return ne.has(e);
843
740
  }
844
- function st(e) {
845
- return it.has(e);
741
+ function ae(e) {
742
+ return re.has(e);
846
743
  }
847
- function at(e) {
848
- return e <= 3 ? 1 : 2;
744
+ function oe(e) {
745
+ return e <= 3 ? 1 : 2;
849
746
  }
850
- function we(e, r) {
851
- return r <= 1 ? e : e.map((i) => i.colSpan !== void 0 ? i : i.type && ot(i.type) ? { ...i, colSpan: r } : i);
747
+ function X(e, t) {
748
+ return t <= 1 ? e : e.map((e) => e.colSpan === void 0 && e.type && ie(e.type) ? {
749
+ ...e,
750
+ colSpan: t
751
+ } : e);
852
752
  }
853
- function dt(e, r) {
854
- return r?.fields ? e.filter((i) => {
855
- const b = r.fields[i.name];
856
- return b ? !st(b.type) : !0;
857
- }) : e;
753
+ function se(e, t) {
754
+ return t?.fields ? e.filter((e) => {
755
+ let n = t.fields[e.name];
756
+ return n ? !ae(n.type) : !0;
757
+ }) : e;
858
758
  }
859
- function Ne(e) {
860
- return e <= 1 ? "default" : e === 2 ? "xl" : "full";
759
+ function Z(e) {
760
+ return e <= 1 ? "default" : e === 2 ? "xl" : "full";
861
761
  }
862
- function ce(e, r, i, b) {
863
- let o = [...e];
864
- if (b === "create" && (o = dt(o, r)), i !== void 0)
865
- return o = we(o, i), { fields: o, columns: i };
866
- const p = at(o.length);
867
- return o = we(o, p), { fields: o, columns: p };
762
+ function Q(e, t, n, r) {
763
+ let i = [...e];
764
+ if (r === "create" && (i = se(i, t)), n !== void 0) return i = X(i, n), {
765
+ fields: i,
766
+ columns: n
767
+ };
768
+ let a = oe(i.length);
769
+ return i = X(i, a), {
770
+ fields: i,
771
+ columns: a
772
+ };
868
773
  }
869
- const ve = {
870
- 1: void 0,
871
- 2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
872
- 3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
873
- 4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
874
- }, ct = ({
875
- schema: e,
876
- dataSource: r,
877
- className: i
878
- }) => {
879
- const { fieldLabel: b } = ee(), [o, p] = C(null), [x, E] = C([]), [I, O] = C({}), [F, N] = C(!0), [j, h] = C(null), v = e.open !== !1, D = e.drawerSide || "right";
880
- H(() => {
881
- (async () => {
882
- if (!r) {
883
- N(!1);
884
- return;
885
- }
886
- try {
887
- const s = await r.getObjectSchema(e.objectName);
888
- p(s);
889
- } catch (s) {
890
- h(s), N(!1);
891
- }
892
- })();
893
- }, [e.objectName, r]), H(() => {
894
- (o || !r) && (async () => {
895
- if (e.mode === "create" || !e.recordId) {
896
- O(e.initialData || e.initialValues || {}), N(!1);
897
- return;
898
- }
899
- if (!r) {
900
- O(e.initialData || e.initialValues || {}), N(!1);
901
- return;
902
- }
903
- try {
904
- const s = await r.findOne(e.objectName, e.recordId);
905
- O(s || {});
906
- } catch (s) {
907
- h(s);
908
- } finally {
909
- N(!1);
910
- }
911
- })();
912
- }, [o, e.mode, e.recordId, e.initialData, e.initialValues, r, e.objectName]);
913
- const z = A((a) => {
914
- const s = [];
915
- for (const c of a.fields) {
916
- const S = typeof c == "string" ? c : c.name;
917
- if (typeof c == "object")
918
- s.push(c);
919
- else if (o?.fields?.[S]) {
920
- const y = o.fields[S];
921
- s.push({
922
- name: S,
923
- label: b(e.objectName, S, y.label || S),
924
- type: X(y.type),
925
- required: y.required || !1,
926
- disabled: e.readOnly || e.mode === "view" || y.readonly,
927
- placeholder: y.placeholder,
928
- description: y.help || y.description,
929
- validation: B(y),
930
- field: y,
931
- options: y.options,
932
- multiple: y.multiple
933
- });
934
- } else
935
- s.push({
936
- name: S,
937
- label: S,
938
- type: "input"
939
- });
940
- }
941
- return s;
942
- }, [o, e.readOnly, e.mode]);
943
- H(() => {
944
- if (!o && r) return;
945
- if (e.customFields?.length) {
946
- E(e.customFields), N(!1);
947
- return;
948
- }
949
- if (e.sections?.length) {
950
- N(!1);
951
- return;
952
- }
953
- if (!o) return;
954
- const a = e.fields || Object.keys(o.fields || {}), s = [];
955
- for (const c of a) {
956
- const S = typeof c == "string" ? c : c.name;
957
- if (!S) continue;
958
- const y = o.fields?.[S];
959
- y && s.push({
960
- name: S,
961
- label: b(e.objectName, S, y.label || S),
962
- type: X(y.type),
963
- required: y.required || !1,
964
- disabled: e.readOnly || e.mode === "view" || y.readonly,
965
- placeholder: y.placeholder,
966
- description: y.help || y.description,
967
- validation: B(y),
968
- field: y,
969
- options: y.options,
970
- multiple: y.multiple
971
- });
972
- }
973
- E(s), N(!1);
974
- }, [o, e.fields, e.customFields, e.sections, e.readOnly, e.mode, r]);
975
- const L = A(async (a) => {
976
- if (!r)
977
- return e.onSuccess && await e.onSuccess(a), e.onOpenChange?.(!1), a;
978
- try {
979
- let s;
980
- return e.mode === "create" ? s = await r.create(e.objectName, a) : e.mode === "edit" && e.recordId && (s = await r.update(e.objectName, e.recordId, a)), e.onSuccess && await e.onSuccess(s), e.onOpenChange?.(!1), s;
981
- } catch (s) {
982
- throw e.onError && e.onError(s), s;
983
- }
984
- }, [e, r]), k = A(() => {
985
- e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
986
- }, [e]), U = G(() => e.drawerWidth ? D === "left" || D === "right" ? { width: e.drawerWidth, maxWidth: e.drawerWidth } : { height: e.drawerWidth, maxHeight: e.drawerWidth } : void 0, [e.drawerWidth, D]), f = {
987
- type: "form",
988
- layout: e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical",
989
- defaultValues: I,
990
- submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
991
- cancelLabel: e.cancelText,
992
- showSubmit: e.showSubmit !== !1 && e.mode !== "view",
993
- showCancel: e.showCancel !== !1,
994
- onSubmit: L,
995
- onCancel: k
996
- }, n = () => {
997
- if (j)
998
- return /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
999
- /* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
1000
- /* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: j.message })
1001
- ] });
1002
- if (F)
1003
- return /* @__PURE__ */ t.jsxs("div", { className: "p-8 text-center", children: [
1004
- /* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
1005
- /* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
1006
- ] });
1007
- if (e.sections?.length)
1008
- return /* @__PURE__ */ t.jsx("div", { className: "space-y-6", children: e.sections.map((c, S) => {
1009
- const y = c.columns || 1;
1010
- return /* @__PURE__ */ t.jsx(
1011
- te,
1012
- {
1013
- label: c.label,
1014
- description: c.description,
1015
- columns: y,
1016
- gridClassName: ve[y],
1017
- children: /* @__PURE__ */ t.jsx(
1018
- J,
1019
- {
1020
- schema: {
1021
- ...f,
1022
- fields: z(c),
1023
- showSubmit: S === e.sections.length - 1 && f.showSubmit,
1024
- showCancel: S === e.sections.length - 1 && f.showCancel
1025
- }
1026
- }
1027
- )
1028
- },
1029
- c.name || c.label || S
1030
- );
1031
- }) });
1032
- const a = ce(x, o, e.columns, e.mode), s = ve[a.columns || 1];
1033
- return /* @__PURE__ */ t.jsx(
1034
- J,
1035
- {
1036
- schema: {
1037
- ...f,
1038
- fields: a.fields,
1039
- columns: a.columns,
1040
- ...s ? { fieldContainerClass: s } : {}
1041
- }
1042
- }
1043
- );
1044
- };
1045
- return /* @__PURE__ */ t.jsx(ze, { open: v, onOpenChange: e.onOpenChange, children: /* @__PURE__ */ t.jsxs(
1046
- Ve,
1047
- {
1048
- side: D,
1049
- className: W("overflow-y-auto", i, e.className),
1050
- style: U,
1051
- children: [
1052
- (e.title || e.description) && /* @__PURE__ */ t.jsxs(Me, { children: [
1053
- e.title && /* @__PURE__ */ t.jsx($e, { children: e.title }),
1054
- e.description && /* @__PURE__ */ t.jsx(qe, { children: e.description })
1055
- ] }),
1056
- /* @__PURE__ */ t.jsx("div", { className: "@container py-4", children: n() })
1057
- ]
1058
- }
1059
- ) });
1060
- }, Se = {
1061
- sm: "sm:max-w-sm",
1062
- default: "sm:max-w-lg",
1063
- lg: "sm:max-w-2xl",
1064
- xl: "sm:max-w-5xl",
1065
- full: "sm:max-w-[95vw] sm:w-full"
1066
- }, Ce = {
1067
- 1: void 0,
1068
- // let the form renderer use its default (space-y-4)
1069
- 2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
1070
- 3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
1071
- 4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
1072
- }, ut = ({
1073
- schema: e,
1074
- dataSource: r,
1075
- className: i
1076
- }) => {
1077
- const { fieldLabel: b } = ee(), [o, p] = C(null), [x, E] = C([]), [I, O] = C({}), [F, N] = C(!0), [j, h] = C(null), [v, D] = C(!1), z = e.open !== !1, L = Fe(), k = G(() => e.sections?.length || e.customFields?.length ? null : ce(x, o, e.columns, e.mode), [x, o, e.columns, e.mode, e.sections, e.customFields]), U = G(() => {
1078
- if (e.modalSize) return e.modalSize;
1079
- if (k?.columns && k.columns > 1)
1080
- return Ne(k.columns);
1081
- if (e.sections?.length) {
1082
- const g = Math.max(...e.sections.map((m) => Number(m.columns) || 1));
1083
- if (g > 1) return Ne(g);
1084
- }
1085
- return "default";
1086
- }, [e.modalSize, k, e.sections]), M = Se[U] || Se.default;
1087
- H(() => {
1088
- (async () => {
1089
- if (!r) {
1090
- N(!1);
1091
- return;
1092
- }
1093
- try {
1094
- const m = await r.getObjectSchema(e.objectName);
1095
- p(m);
1096
- } catch (m) {
1097
- h(m), N(!1);
1098
- }
1099
- })();
1100
- }, [e.objectName, r]), H(() => {
1101
- (o || !r) && (async () => {
1102
- if (e.mode === "create" || !e.recordId) {
1103
- O(e.initialData || e.initialValues || {}), N(!1);
1104
- return;
1105
- }
1106
- if (!r) {
1107
- O(e.initialData || e.initialValues || {}), N(!1);
1108
- return;
1109
- }
1110
- try {
1111
- const m = await r.findOne(e.objectName, e.recordId);
1112
- O(m || {});
1113
- } catch (m) {
1114
- h(m);
1115
- } finally {
1116
- N(!1);
1117
- }
1118
- })();
1119
- }, [o, e.mode, e.recordId, e.initialData, e.initialValues, r, e.objectName]);
1120
- const f = A((g) => {
1121
- const m = [];
1122
- for (const V of g.fields) {
1123
- const Y = typeof V == "string" ? V : V.name;
1124
- if (typeof V == "object")
1125
- m.push(V);
1126
- else if (o?.fields?.[Y]) {
1127
- const R = o.fields[Y];
1128
- m.push({
1129
- name: Y,
1130
- label: b(e.objectName, Y, R.label || Y),
1131
- type: X(R.type),
1132
- required: R.required || !1,
1133
- disabled: e.readOnly || e.mode === "view" || R.readonly,
1134
- placeholder: R.placeholder,
1135
- description: R.help || R.description,
1136
- validation: B(R),
1137
- field: R,
1138
- options: R.options,
1139
- multiple: R.multiple
1140
- });
1141
- } else
1142
- m.push({
1143
- name: Y,
1144
- label: Y,
1145
- type: "input"
1146
- });
1147
- }
1148
- return m;
1149
- }, [o, e.readOnly, e.mode]);
1150
- H(() => {
1151
- if (!o && r) return;
1152
- if (e.customFields?.length) {
1153
- E(e.customFields), N(!1);
1154
- return;
1155
- }
1156
- if (e.sections?.length) {
1157
- N(!1);
1158
- return;
1159
- }
1160
- if (!o) return;
1161
- const g = e.fields || Object.keys(o.fields || {}), m = [];
1162
- for (const V of g) {
1163
- const Y = typeof V == "string" ? V : V.name;
1164
- if (!Y) continue;
1165
- const R = o.fields?.[Y];
1166
- R && m.push({
1167
- name: Y,
1168
- label: b(e.objectName, Y, R.label || Y),
1169
- type: X(R.type),
1170
- required: R.required || !1,
1171
- disabled: e.readOnly || e.mode === "view" || R.readonly,
1172
- placeholder: R.placeholder,
1173
- description: R.help || R.description,
1174
- validation: B(R),
1175
- field: R,
1176
- options: R.options,
1177
- multiple: R.multiple
1178
- });
1179
- }
1180
- E(m), N(!1);
1181
- }, [o, e.fields, e.customFields, e.sections, e.readOnly, e.mode, r]);
1182
- const n = A(async (g) => {
1183
- D(!0);
1184
- try {
1185
- if (!r)
1186
- return e.onSuccess && await e.onSuccess(g), e.onOpenChange?.(!1), g;
1187
- let m;
1188
- return e.mode === "create" ? m = await r.create(e.objectName, g) : e.mode === "edit" && e.recordId && (m = await r.update(e.objectName, e.recordId, g)), e.onSuccess && await e.onSuccess(m), e.onOpenChange?.(!1), m;
1189
- } catch (m) {
1190
- throw e.onError && e.onError(m), m;
1191
- } finally {
1192
- D(!1);
1193
- }
1194
- }, [e, r]), a = A(() => {
1195
- e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
1196
- }, [e]), s = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", c = e.showSubmit !== !1 && e.mode !== "view", S = e.showCancel !== !1, y = e.submitText || (e.mode === "create" ? "Create" : "Update"), d = e.cancelText || "Cancel", _ = {
1197
- type: "form",
1198
- layout: s,
1199
- defaultValues: I,
1200
- submitLabel: y,
1201
- cancelLabel: d,
1202
- showSubmit: c,
1203
- showCancel: S,
1204
- onSubmit: n,
1205
- onCancel: a,
1206
- showActions: !1,
1207
- // Hide actions — rendered in sticky footer
1208
- id: L
1209
- // Link external submit button via form attribute
1210
- }, T = () => {
1211
- if (j)
1212
- return /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
1213
- /* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
1214
- /* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: j.message })
1215
- ] });
1216
- if (F)
1217
- return /* @__PURE__ */ t.jsx("div", { className: "space-y-4", "data-testid": "modal-form-skeleton", children: [1, 2, 3].map((V) => /* @__PURE__ */ t.jsxs("div", { className: "space-y-2", children: [
1218
- /* @__PURE__ */ t.jsx(xe, { className: "h-4 w-24" }),
1219
- /* @__PURE__ */ t.jsx(xe, { className: "h-10 w-full" })
1220
- ] }, V)) });
1221
- if (e.sections?.length)
1222
- return /* @__PURE__ */ t.jsx("div", { className: "space-y-6", children: e.sections.map((V, Y) => {
1223
- const R = V.columns || 1;
1224
- return /* @__PURE__ */ t.jsx(
1225
- te,
1226
- {
1227
- label: V.label,
1228
- description: V.description,
1229
- columns: R,
1230
- gridClassName: Ce[R],
1231
- children: /* @__PURE__ */ t.jsx(
1232
- J,
1233
- {
1234
- schema: {
1235
- ..._,
1236
- fields: f(V)
1237
- // Actions are in the sticky footer, not inside sections
1238
- }
1239
- }
1240
- )
1241
- },
1242
- V.name || V.label || Y
1243
- );
1244
- }) });
1245
- const g = k ?? ce(x, o, e.columns, e.mode), m = Ce[g.columns || 1];
1246
- return /* @__PURE__ */ t.jsx(
1247
- J,
1248
- {
1249
- schema: {
1250
- ..._,
1251
- fields: g.fields,
1252
- columns: g.columns,
1253
- ...m ? { fieldContainerClass: m } : {}
1254
- }
1255
- }
1256
- );
1257
- }, u = !F && !j && (c || S);
1258
- return /* @__PURE__ */ t.jsx(Ye, { open: z, onOpenChange: e.onOpenChange, children: /* @__PURE__ */ t.jsxs(We, { className: W(M, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", i, e.className), children: [
1259
- (e.title || e.description) && /* @__PURE__ */ t.jsxs(Ue, { className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b", children: [
1260
- e.title && /* @__PURE__ */ t.jsx(He, { children: e.title }),
1261
- e.description && /* @__PURE__ */ t.jsx(Ge, { children: e.description })
1262
- ] }),
1263
- /* @__PURE__ */ t.jsx("div", { className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4", children: T() }),
1264
- u && /* @__PURE__ */ t.jsx("div", { className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background", "data-testid": "modal-form-footer", children: /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col sm:flex-row gap-2 sm:justify-end", children: [
1265
- S && /* @__PURE__ */ t.jsx(
1266
- Z,
1267
- {
1268
- type: "button",
1269
- variant: "outline",
1270
- onClick: a,
1271
- disabled: v,
1272
- className: "w-full sm:w-auto",
1273
- children: d
1274
- }
1275
- ),
1276
- c && /* @__PURE__ */ t.jsxs(
1277
- Z,
1278
- {
1279
- type: "submit",
1280
- form: L,
1281
- disabled: v,
1282
- className: "w-full sm:w-auto",
1283
- children: [
1284
- v && /* @__PURE__ */ t.jsx(Qe, { className: "mr-2 h-4 w-4 animate-spin" }),
1285
- y
1286
- ]
1287
- }
1288
- )
1289
- ] }) })
1290
- ] }) });
1291
- }, he = ({
1292
- schema: e,
1293
- dataSource: r
1294
- }) => {
1295
- if (e.formType === "tabbed" && e.sections?.length)
1296
- return /* @__PURE__ */ t.jsx(
1297
- tt,
1298
- {
1299
- schema: {
1300
- ...e,
1301
- formType: "tabbed",
1302
- sections: e.sections.map((i) => ({
1303
- name: i.name,
1304
- label: i.label,
1305
- description: i.description,
1306
- columns: i.columns,
1307
- fields: i.fields
1308
- })),
1309
- defaultTab: e.defaultTab,
1310
- tabPosition: e.tabPosition
1311
- },
1312
- dataSource: r,
1313
- className: e.className
1314
- }
1315
- );
1316
- if (e.formType === "wizard" && e.sections?.length)
1317
- return /* @__PURE__ */ t.jsx(
1318
- rt,
1319
- {
1320
- schema: {
1321
- ...e,
1322
- formType: "wizard",
1323
- sections: e.sections.map((i) => ({
1324
- name: i.name,
1325
- label: i.label,
1326
- description: i.description,
1327
- columns: i.columns,
1328
- fields: i.fields
1329
- })),
1330
- allowSkip: e.allowSkip,
1331
- showStepIndicator: e.showStepIndicator,
1332
- nextText: e.nextText,
1333
- prevText: e.prevText,
1334
- onStepChange: e.onStepChange
1335
- },
1336
- dataSource: r,
1337
- className: e.className
1338
- }
1339
- );
1340
- if (e.formType === "split" && e.sections?.length)
1341
- return /* @__PURE__ */ t.jsx(
1342
- lt,
1343
- {
1344
- schema: {
1345
- ...e,
1346
- formType: "split",
1347
- sections: e.sections.map((i) => ({
1348
- name: i.name,
1349
- label: i.label,
1350
- description: i.description,
1351
- columns: i.columns,
1352
- fields: i.fields
1353
- })),
1354
- splitDirection: e.splitDirection,
1355
- splitSize: e.splitSize,
1356
- splitResizable: e.splitResizable
1357
- },
1358
- dataSource: r,
1359
- className: e.className
1360
- }
1361
- );
1362
- if (e.formType === "drawer") {
1363
- const { layout: i, ...b } = e, o = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
1364
- return /* @__PURE__ */ t.jsx(
1365
- ct,
1366
- {
1367
- schema: {
1368
- ...b,
1369
- layout: o,
1370
- formType: "drawer",
1371
- sections: e.sections?.map((p) => ({
1372
- name: p.name,
1373
- label: p.label,
1374
- description: p.description,
1375
- columns: p.columns,
1376
- fields: p.fields
1377
- })),
1378
- open: e.open,
1379
- onOpenChange: e.onOpenChange,
1380
- drawerSide: e.drawerSide,
1381
- drawerWidth: e.drawerWidth
1382
- },
1383
- dataSource: r,
1384
- className: e.className
1385
- }
1386
- );
1387
- }
1388
- if (e.formType === "modal") {
1389
- const { layout: i, ...b } = e, o = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
1390
- return /* @__PURE__ */ t.jsx(
1391
- ut,
1392
- {
1393
- schema: {
1394
- ...b,
1395
- layout: o,
1396
- formType: "modal",
1397
- sections: e.sections?.map((p) => ({
1398
- name: p.name,
1399
- label: p.label,
1400
- description: p.description,
1401
- columns: p.columns,
1402
- fields: p.fields
1403
- })),
1404
- open: e.open,
1405
- onOpenChange: e.onOpenChange,
1406
- modalSize: e.modalSize,
1407
- modalCloseButton: e.modalCloseButton
1408
- },
1409
- dataSource: r,
1410
- className: e.className
1411
- }
1412
- );
1413
- }
1414
- return /* @__PURE__ */ t.jsx(ft, { schema: e, dataSource: r });
1415
- }, ft = ({
1416
- schema: e,
1417
- dataSource: r
1418
- }) => {
1419
- const { fieldLabel: i } = ee(), [b, o] = C(null), [p, x] = C([]), [E, I] = C(null), [O, F] = C(!0), [N, j] = C(null), h = e.customFields && e.customFields.length > 0;
1420
- H(() => {
1421
- h && (I(e.initialData || e.initialValues || {}), F(!1));
1422
- }, [h, e.initialData, e.initialValues]), H(() => {
1423
- const n = async () => {
1424
- try {
1425
- if (!r)
1426
- throw new Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");
1427
- const a = await r.getObjectSchema(e.objectName);
1428
- if (!a)
1429
- throw new Error(`No schema found for object "${e.objectName}"`);
1430
- o(a);
1431
- } catch (a) {
1432
- j(a), F(!1);
1433
- }
1434
- };
1435
- h ? o({
1436
- name: e.objectName,
1437
- fields: {}
1438
- }) : e.objectName && r ? n() : h || F(!1);
1439
- }, [e.objectName, r, h]), H(() => {
1440
- b && !h && (async () => {
1441
- if (!e.recordId || e.mode === "create") {
1442
- I(e.initialData || e.initialValues || {}), F(!1);
1443
- return;
1444
- }
1445
- if (!h) {
1446
- if (!r) {
1447
- j(new Error("DataSource is required for fetching record data (inline data not provided)")), F(!1);
1448
- return;
1449
- }
1450
- F(!0);
1451
- try {
1452
- const a = await r.findOne(e.objectName, e.recordId);
1453
- I(a);
1454
- } catch (a) {
1455
- console.error("Failed to fetch record:", a), j(a);
1456
- } finally {
1457
- F(!1);
1458
- }
1459
- }
1460
- })();
1461
- }, [e.objectName, e.recordId, e.mode, e.initialValues, e.initialData, r, b, h]), H(() => {
1462
- if (h && e.customFields) {
1463
- x(e.customFields), F(!1);
1464
- return;
1465
- }
1466
- if (!b) return;
1467
- const n = [], a = e.fields || Object.keys(b.fields || {});
1468
- (Array.isArray(a) ? a : Object.keys(a)).forEach((S) => {
1469
- const y = typeof S == "string" ? S : S.name;
1470
- if (!y) return;
1471
- const d = b.fields?.[y];
1472
- if (!d && !h) return;
1473
- const _ = !d?.permissions || d?.permissions.write !== !1;
1474
- if (e.mode !== "view" && !_) return;
1475
- const T = e.customFields?.find((u) => u.name === y);
1476
- if (T)
1477
- n.push(T);
1478
- else if (d) {
1479
- const u = {
1480
- name: y,
1481
- label: i(e.objectName, y, d.label || S),
1482
- type: X(d.type),
1483
- required: d.required || !1,
1484
- disabled: e.readOnly || e.mode === "view" || d.readonly,
1485
- placeholder: d.placeholder,
1486
- description: d.help || d.description,
1487
- validation: B(d),
1488
- // Important: Pass the original field metadata so widgets can access properties like precision, currency, etc.
1489
- field: d
1490
- };
1491
- if ((d.type === "select" || d.type === "lookup" || d.type === "master_detail") && (u.options = d.options || [], u.multiple = d.multiple), (d.type === "number" || d.type === "currency" || d.type === "percent") && (u.inputType = "number", u.min = d.min, u.max = d.max, u.step = d.precision ? Math.pow(10, -d.precision) : void 0), d.type === "date" && (u.inputType = "date"), d.type === "datetime" && (u.inputType = "datetime-local"), (d.type === "text" || d.type === "textarea" || d.type === "markdown" || d.type === "html") && (u.maxLength = d.max_length, u.minLength = d.min_length), (d.type === "file" || d.type === "image") && (u.inputType = "file", u.multiple = d.multiple, u.accept = d.accept ? d.accept.join(",") : void 0, d.max_size)) {
1492
- const g = `Max size: ${Re(d.max_size)}`;
1493
- u.description = u.description ? `${u.description} (${g})` : g;
1494
- }
1495
- d.type === "email" && (u.inputType = "email"), d.type === "phone" && (u.inputType = "tel"), d.type === "url" && (u.inputType = "url"), d.type === "password" && (u.inputType = "password"), d.type === "time" && (u.inputType = "time"), (d.type === "formula" || d.type === "summary" || d.type === "auto_number") && (u.disabled = !0), d.visible_on && (u.visible = (g) => De(d.visible_on, g)), n.push(u);
1496
- }
1497
- }), x(n), !h && e.recordId && e.mode !== "create" && r || F(!1);
1498
- }, [b, e.fields, e.customFields, e.readOnly, e.mode, h, e.recordId, r]);
1499
- const v = A(async (n, a) => {
1500
- if (n && (n.nativeEvent || n._reactName === "onSubmit") && (console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."), a === void 0 && (a = n, n = {})), h && !r)
1501
- return e.onSuccess && await e.onSuccess(n), n;
1502
- if (!r)
1503
- throw new Error("DataSource is required for form submission (inline mode not configured)");
1504
- try {
1505
- let s;
1506
- if (e.mode === "create")
1507
- s = await r.create(e.objectName, n);
1508
- else if (e.mode === "edit" && e.recordId)
1509
- s = await r.update(e.objectName, e.recordId, n);
1510
- else
1511
- throw new Error("Invalid form mode or missing record ID");
1512
- return e.onSuccess && await e.onSuccess(s), s;
1513
- } catch (s) {
1514
- throw console.error("Failed to submit form:", s), e.onError && e.onError(s), s;
1515
- }
1516
- }, [e, r, h]), D = A(() => {
1517
- e.onCancel && e.onCancel();
1518
- }, [e]), L = {
1519
- ...K.useMemo(() => {
1520
- if (!b?.fields) return {};
1521
- const n = {};
1522
- return Object.keys(b.fields).forEach((a) => {
1523
- const s = b.fields[a];
1524
- s.defaultValue !== void 0 && (n[a] = s.defaultValue);
1525
- }), n;
1526
- }, [b]),
1527
- ...E
1528
- };
1529
- if (N)
1530
- return /* @__PURE__ */ t.jsxs("div", { className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md", children: [
1531
- /* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
1532
- /* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: N.message })
1533
- ] });
1534
- if (O)
1535
- return /* @__PURE__ */ t.jsxs("div", { className: "p-4 sm:p-8 text-center", children: [
1536
- /* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
1537
- /* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
1538
- ] });
1539
- const k = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical";
1540
- if (e.sections?.length && (!e.formType || e.formType === "simple"))
1541
- return /* @__PURE__ */ t.jsx("div", { className: "w-full space-y-6", children: e.sections.map((n, a) => {
1542
- const s = n.fields.map((S) => typeof S == "string" ? S : S.name), c = p.filter((S) => s.includes(S.name));
1543
- return /* @__PURE__ */ t.jsx(
1544
- te,
1545
- {
1546
- label: n.label,
1547
- description: n.description,
1548
- collapsible: n.collapsible,
1549
- collapsed: n.collapsed,
1550
- columns: n.columns,
1551
- children: /* @__PURE__ */ t.jsx(
1552
- J,
1553
- {
1554
- schema: {
1555
- type: "form",
1556
- fields: c,
1557
- layout: k,
1558
- defaultValues: L,
1559
- // Only show action buttons after the last section
1560
- showSubmit: a === e.sections.length - 1 && e.showSubmit !== !1 && e.mode !== "view",
1561
- showCancel: a === e.sections.length - 1 && e.showCancel !== !1,
1562
- submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
1563
- cancelLabel: e.cancelText,
1564
- onSubmit: v,
1565
- onCancel: D
1566
- }
1567
- }
1568
- )
1569
- },
1570
- n.name || n.label || a
1571
- );
1572
- }) });
1573
- const M = e.sections?.length ? { fields: p, columns: e.columns } : ce(p, b, e.columns, e.mode), f = {
1574
- type: "form",
1575
- fields: M.fields,
1576
- layout: k,
1577
- columns: M.columns,
1578
- submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
1579
- cancelLabel: e.cancelText,
1580
- showSubmit: e.showSubmit !== !1 && e.mode !== "view",
1581
- showCancel: e.showCancel !== !1,
1582
- resetOnSubmit: e.showReset,
1583
- defaultValues: L,
1584
- onSubmit: v,
1585
- onCancel: D,
1586
- className: e.className
1587
- };
1588
- return /* @__PURE__ */ t.jsx("div", { className: "w-full", children: /* @__PURE__ */ t.jsx(J, { schema: f }) });
1589
- }, pt = ({
1590
- config: e,
1591
- dataSource: r,
1592
- prefillParams: i,
1593
- className: b
1594
- }) => {
1595
- const [o, p] = C(!1), [x, E] = C(!1), [I, O] = C(null), F = G(() => {
1596
- const v = {};
1597
- if (i)
1598
- for (const [D, z] of Object.entries(i))
1599
- v[D] = z;
1600
- return typeof window < "u" && new URLSearchParams(window.location.search).forEach((z, L) => {
1601
- L in v || (v[L] = z);
1602
- }), Object.keys(v).length > 0 ? v : void 0;
1603
- }, [i]), N = A(async (v) => {
1604
- E(!0), O(null);
1605
- try {
1606
- if (r && await r.create(e.objectName, v), p(!0), e.thankYouPage?.redirectUrl) {
1607
- const D = e.thankYouPage.redirectDelay ?? 3e3;
1608
- setTimeout(() => {
1609
- window.location.href = e.thankYouPage.redirectUrl;
1610
- }, D);
1611
- }
1612
- } catch (D) {
1613
- O(D instanceof Error ? D.message : "Failed to submit form. Please try again.");
1614
- } finally {
1615
- E(!1);
1616
- }
1617
- }, [r, e]), j = A(() => {
1618
- p(!1), O(null);
1619
- }, []), h = G(() => {
1620
- const v = {};
1621
- return e.branding?.backgroundColor && (v.backgroundColor = e.branding.backgroundColor), v;
1622
- }, [e.branding]);
1623
- if (o) {
1624
- const v = e.thankYouPage;
1625
- return /* @__PURE__ */ t.jsx(
1626
- "div",
1627
- {
1628
- className: `min-h-screen flex items-center justify-center p-4 ${b || ""}`,
1629
- style: h,
1630
- children: /* @__PURE__ */ t.jsxs("div", { className: "max-w-md w-full bg-card rounded-lg shadow-lg p-8 text-center space-y-4", children: [
1631
- /* @__PURE__ */ t.jsx("div", { className: "text-4xl", children: "✓" }),
1632
- /* @__PURE__ */ t.jsx("h2", { className: "text-xl font-semibold text-foreground", children: v?.title || "Thank You!" }),
1633
- /* @__PURE__ */ t.jsx("p", { className: "text-muted-foreground", children: v?.message || "Your submission has been received successfully." }),
1634
- e.allowMultiple && /* @__PURE__ */ t.jsx(
1635
- "button",
1636
- {
1637
- onClick: j,
1638
- className: "mt-4 px-4 py-2 text-sm font-medium rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors",
1639
- children: "Submit Another Response"
1640
- }
1641
- ),
1642
- v?.redirectUrl && /* @__PURE__ */ t.jsxs("p", { className: "text-xs text-muted-foreground", children: [
1643
- "Redirecting in ",
1644
- Math.ceil((v.redirectDelay ?? 3e3) / 1e3),
1645
- " seconds..."
1646
- ] })
1647
- ] })
1648
- }
1649
- );
1650
- }
1651
- return /* @__PURE__ */ t.jsx(
1652
- "div",
1653
- {
1654
- className: `min-h-screen flex items-center justify-center p-4 ${b || ""}`,
1655
- style: h,
1656
- children: /* @__PURE__ */ t.jsxs("div", { className: "max-w-2xl w-full bg-card rounded-lg shadow-lg overflow-hidden", children: [
1657
- /* @__PURE__ */ t.jsxs(
1658
- "div",
1659
- {
1660
- className: "p-6 border-b",
1661
- style: e.branding?.primaryColor ? { borderBottomColor: e.branding.primaryColor } : void 0,
1662
- children: [
1663
- e.branding?.logo && /* @__PURE__ */ t.jsx(
1664
- "img",
1665
- {
1666
- src: e.branding.logo,
1667
- alt: "Logo",
1668
- className: "h-8 mb-4"
1669
- }
1670
- ),
1671
- e.title && /* @__PURE__ */ t.jsx("h1", { className: "text-xl font-semibold text-foreground", children: e.title }),
1672
- e.description && /* @__PURE__ */ t.jsx("p", { className: "text-sm text-muted-foreground mt-1", children: e.description })
1673
- ]
1674
- }
1675
- ),
1676
- /* @__PURE__ */ t.jsxs("div", { className: "p-6", children: [
1677
- I && /* @__PURE__ */ t.jsx("div", { className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive", children: I }),
1678
- /* @__PURE__ */ t.jsx(
1679
- he,
1680
- {
1681
- schema: {
1682
- type: "object-form",
1683
- objectName: e.objectName,
1684
- mode: "create",
1685
- fields: e.fields,
1686
- customFields: e.customFields,
1687
- initialData: F,
1688
- onSuccess: N,
1689
- submitLabel: x ? "Submitting..." : "Submit"
1690
- },
1691
- dataSource: r
1692
- }
1693
- )
1694
- ] }),
1695
- /* @__PURE__ */ t.jsx("div", { className: "px-6 py-3 border-t bg-muted/20 text-center", children: /* @__PURE__ */ t.jsx("p", { className: "text-xs text-muted-foreground", children: "Powered by ObjectStack" }) })
1696
- ] })
1697
- }
1698
- );
774
+ //#endregion
775
+ //#region src/DrawerForm.tsx
776
+ var ce = {
777
+ 1: void 0,
778
+ 2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
779
+ 3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
780
+ 4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
781
+ }, le = ({ schema: e, dataSource: r, className: o }) => {
782
+ let { fieldLabel: u } = c(), [d, p] = a(null), [m, h] = a([]), [g, _] = a({}), [v, y] = a(!0), [b, x] = a(null), S = e.open !== !1, C = e.drawerSide || "right";
783
+ n(() => {
784
+ (async () => {
785
+ if (!r) {
786
+ y(!1);
787
+ return;
788
+ }
789
+ try {
790
+ p(await r.getObjectSchema(e.objectName));
791
+ } catch (e) {
792
+ x(e), y(!1);
793
+ }
794
+ })();
795
+ }, [e.objectName, r]), n(() => {
796
+ (d || !r) && (async () => {
797
+ if (e.mode === "create" || !e.recordId) {
798
+ _(e.initialData || e.initialValues || {}), y(!1);
799
+ return;
800
+ }
801
+ if (!r) {
802
+ _(e.initialData || e.initialValues || {}), y(!1);
803
+ return;
804
+ }
805
+ try {
806
+ _(await r.findOne(e.objectName, e.recordId) || {});
807
+ } catch (e) {
808
+ x(e);
809
+ } finally {
810
+ y(!1);
811
+ }
812
+ })();
813
+ }, [
814
+ d,
815
+ e.mode,
816
+ e.recordId,
817
+ e.initialData,
818
+ e.initialValues,
819
+ r,
820
+ e.objectName
821
+ ]);
822
+ let w = t((t) => {
823
+ let n = [];
824
+ for (let r of t.fields) {
825
+ let t = typeof r == "string" ? r : r.name;
826
+ if (typeof r == "object") n.push(r);
827
+ else if (d?.fields?.[t]) {
828
+ let r = d.fields[t];
829
+ n.push({
830
+ name: t,
831
+ label: u(e.objectName, t, r.label || t),
832
+ type: f(r.type),
833
+ required: r.required || !1,
834
+ disabled: e.readOnly || e.mode === "view" || r.readonly,
835
+ placeholder: r.placeholder,
836
+ description: r.help || r.description,
837
+ validation: l(r),
838
+ field: r,
839
+ options: r.options,
840
+ multiple: r.multiple
841
+ });
842
+ } else n.push({
843
+ name: t,
844
+ label: t,
845
+ type: "input"
846
+ });
847
+ }
848
+ return n;
849
+ }, [
850
+ d,
851
+ e.readOnly,
852
+ e.mode
853
+ ]);
854
+ n(() => {
855
+ if (!d && r) return;
856
+ if (e.customFields?.length) {
857
+ h(e.customFields), y(!1);
858
+ return;
859
+ }
860
+ if (e.sections?.length) {
861
+ y(!1);
862
+ return;
863
+ }
864
+ if (!d) return;
865
+ let t = e.fields || Object.keys(d.fields || {}), n = [];
866
+ for (let r of t) {
867
+ let t = typeof r == "string" ? r : r.name;
868
+ if (!t) continue;
869
+ let i = d.fields?.[t];
870
+ i && n.push({
871
+ name: t,
872
+ label: u(e.objectName, t, i.label || t),
873
+ type: f(i.type),
874
+ required: i.required || !1,
875
+ disabled: e.readOnly || e.mode === "view" || i.readonly,
876
+ placeholder: i.placeholder,
877
+ description: i.help || i.description,
878
+ validation: l(i),
879
+ field: i,
880
+ options: i.options,
881
+ multiple: i.multiple
882
+ });
883
+ }
884
+ h(n), y(!1);
885
+ }, [
886
+ d,
887
+ e.fields,
888
+ e.customFields,
889
+ e.sections,
890
+ e.readOnly,
891
+ e.mode,
892
+ r
893
+ ]);
894
+ let T = t(async (t) => {
895
+ if (!r) return e.onSuccess && await e.onSuccess(t), e.onOpenChange?.(!1), t;
896
+ try {
897
+ let n;
898
+ return e.mode === "create" ? n = await r.create(e.objectName, t) : e.mode === "edit" && e.recordId && (n = await r.update(e.objectName, e.recordId, t)), e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
899
+ } catch (t) {
900
+ throw e.onError && e.onError(t), t;
901
+ }
902
+ }, [e, r]), E = t(() => {
903
+ e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
904
+ }, [e]), M = i(() => {
905
+ if (e.drawerWidth) return C === "left" || C === "right" ? {
906
+ width: e.drawerWidth,
907
+ maxWidth: e.drawerWidth
908
+ } : {
909
+ height: e.drawerWidth,
910
+ maxHeight: e.drawerWidth
911
+ };
912
+ }, [e.drawerWidth, C]), N = {
913
+ type: "form",
914
+ layout: e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical",
915
+ defaultValues: g,
916
+ submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
917
+ cancelLabel: e.cancelText,
918
+ showSubmit: e.showSubmit !== !1 && e.mode !== "view",
919
+ showCancel: e.showCancel !== !1,
920
+ onSubmit: T,
921
+ onCancel: E
922
+ };
923
+ return /* @__PURE__ */ (0, K.jsx)(D, {
924
+ open: S,
925
+ onOpenChange: e.onOpenChange,
926
+ children: /* @__PURE__ */ (0, K.jsxs)(O, {
927
+ side: C,
928
+ className: L("overflow-y-auto", o, e.className),
929
+ style: M,
930
+ children: [(e.title || e.description) && /* @__PURE__ */ (0, K.jsxs)(A, { children: [e.title && /* @__PURE__ */ (0, K.jsx)(j, { children: e.title }), e.description && /* @__PURE__ */ (0, K.jsx)(k, { children: e.description })] }), /* @__PURE__ */ (0, K.jsx)("div", {
931
+ className: "@container py-4",
932
+ children: (() => {
933
+ if (b) return /* @__PURE__ */ (0, K.jsxs)("div", {
934
+ className: "p-4 border border-red-300 bg-red-50 rounded-md",
935
+ children: [/* @__PURE__ */ (0, K.jsx)("h3", {
936
+ className: "text-red-800 font-semibold",
937
+ children: "Error loading form"
938
+ }), /* @__PURE__ */ (0, K.jsx)("p", {
939
+ className: "text-red-600 text-sm mt-1",
940
+ children: b.message
941
+ })]
942
+ });
943
+ if (v) return /* @__PURE__ */ (0, K.jsxs)("div", {
944
+ className: "p-8 text-center",
945
+ children: [/* @__PURE__ */ (0, K.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, K.jsx)("p", {
946
+ className: "mt-2 text-sm text-gray-600",
947
+ children: "Loading form..."
948
+ })]
949
+ });
950
+ if (e.sections?.length) return /* @__PURE__ */ (0, K.jsx)("div", {
951
+ className: "space-y-6",
952
+ children: e.sections.map((t, n) => {
953
+ let r = t.columns || 1;
954
+ return /* @__PURE__ */ (0, K.jsx)(q, {
955
+ label: t.label,
956
+ description: t.description,
957
+ columns: r,
958
+ gridClassName: ce[r],
959
+ children: /* @__PURE__ */ (0, K.jsx)(s, { schema: {
960
+ ...N,
961
+ fields: w(t),
962
+ showSubmit: n === e.sections.length - 1 && N.showSubmit,
963
+ showCancel: n === e.sections.length - 1 && N.showCancel
964
+ } })
965
+ }, t.name || t.label || n);
966
+ })
967
+ });
968
+ let t = Q(m, d, e.columns, e.mode), n = ce[t.columns || 1];
969
+ return /* @__PURE__ */ (0, K.jsx)(s, { schema: {
970
+ ...N,
971
+ fields: t.fields,
972
+ columns: t.columns,
973
+ ...n ? { fieldContainerClass: n } : {}
974
+ } });
975
+ })()
976
+ })]
977
+ })
978
+ });
979
+ }, ue = {
980
+ sm: "sm:max-w-sm",
981
+ default: "sm:max-w-lg",
982
+ lg: "sm:max-w-2xl",
983
+ xl: "sm:max-w-5xl",
984
+ full: "sm:max-w-[95vw] sm:w-full"
985
+ }, de = {
986
+ 1: void 0,
987
+ 2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
988
+ 3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
989
+ 4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
990
+ }, fe = ({ schema: e, dataSource: o, className: u }) => {
991
+ let { fieldLabel: d } = c(), [m, h] = a(null), [g, _] = a([]), [v, w] = a({}), [T, E] = a(!0), [D, O] = a(null), [k, A] = a(!1), j = e.open !== !1, N = r(), P = i(() => e.sections?.length || e.customFields?.length ? null : Q(g, m, e.columns, e.mode), [
992
+ g,
993
+ m,
994
+ e.columns,
995
+ e.mode,
996
+ e.sections,
997
+ e.customFields
998
+ ]), F = ue[i(() => {
999
+ if (e.modalSize) return e.modalSize;
1000
+ if (P?.columns && P.columns > 1) return Z(P.columns);
1001
+ if (e.sections?.length) {
1002
+ let t = Math.max(...e.sections.map((e) => Number(e.columns) || 1));
1003
+ if (t > 1) return Z(t);
1004
+ }
1005
+ return "default";
1006
+ }, [
1007
+ e.modalSize,
1008
+ P,
1009
+ e.sections
1010
+ ])] || ue.default;
1011
+ n(() => {
1012
+ (async () => {
1013
+ if (!o) {
1014
+ E(!1);
1015
+ return;
1016
+ }
1017
+ try {
1018
+ h(await o.getObjectSchema(e.objectName));
1019
+ } catch (e) {
1020
+ O(e), E(!1);
1021
+ }
1022
+ })();
1023
+ }, [e.objectName, o]), n(() => {
1024
+ (m || !o) && (async () => {
1025
+ if (e.mode === "create" || !e.recordId) {
1026
+ w(e.initialData || e.initialValues || {}), E(!1);
1027
+ return;
1028
+ }
1029
+ if (!o) {
1030
+ w(e.initialData || e.initialValues || {}), E(!1);
1031
+ return;
1032
+ }
1033
+ try {
1034
+ w(await o.findOne(e.objectName, e.recordId) || {});
1035
+ } catch (e) {
1036
+ O(e);
1037
+ } finally {
1038
+ E(!1);
1039
+ }
1040
+ })();
1041
+ }, [
1042
+ m,
1043
+ e.mode,
1044
+ e.recordId,
1045
+ e.initialData,
1046
+ e.initialValues,
1047
+ o,
1048
+ e.objectName
1049
+ ]);
1050
+ let I = t((t) => {
1051
+ let n = [];
1052
+ for (let r of t.fields) {
1053
+ let t = typeof r == "string" ? r : r.name;
1054
+ if (typeof r == "object") n.push(r);
1055
+ else if (m?.fields?.[t]) {
1056
+ let r = m.fields[t];
1057
+ n.push({
1058
+ name: t,
1059
+ label: d(e.objectName, t, r.label || t),
1060
+ type: f(r.type),
1061
+ required: r.required || !1,
1062
+ disabled: e.readOnly || e.mode === "view" || r.readonly,
1063
+ placeholder: r.placeholder,
1064
+ description: r.help || r.description,
1065
+ validation: l(r),
1066
+ field: r,
1067
+ options: r.options,
1068
+ multiple: r.multiple
1069
+ });
1070
+ } else n.push({
1071
+ name: t,
1072
+ label: t,
1073
+ type: "input"
1074
+ });
1075
+ }
1076
+ return n;
1077
+ }, [
1078
+ m,
1079
+ e.readOnly,
1080
+ e.mode
1081
+ ]);
1082
+ n(() => {
1083
+ if (!m && o) return;
1084
+ if (e.customFields?.length) {
1085
+ _(e.customFields), E(!1);
1086
+ return;
1087
+ }
1088
+ if (e.sections?.length) {
1089
+ E(!1);
1090
+ return;
1091
+ }
1092
+ if (!m) return;
1093
+ let t = e.fields || Object.keys(m.fields || {}), n = [];
1094
+ for (let r of t) {
1095
+ let t = typeof r == "string" ? r : r.name;
1096
+ if (!t) continue;
1097
+ let i = m.fields?.[t];
1098
+ i && n.push({
1099
+ name: t,
1100
+ label: d(e.objectName, t, i.label || t),
1101
+ type: f(i.type),
1102
+ required: i.required || !1,
1103
+ disabled: e.readOnly || e.mode === "view" || i.readonly,
1104
+ placeholder: i.placeholder,
1105
+ description: i.help || i.description,
1106
+ validation: l(i),
1107
+ field: i,
1108
+ options: i.options,
1109
+ multiple: i.multiple
1110
+ });
1111
+ }
1112
+ _(n), E(!1);
1113
+ }, [
1114
+ m,
1115
+ e.fields,
1116
+ e.customFields,
1117
+ e.sections,
1118
+ e.readOnly,
1119
+ e.mode,
1120
+ o
1121
+ ]);
1122
+ let R = t(async (t) => {
1123
+ A(!0);
1124
+ try {
1125
+ if (!o) return e.onSuccess && await e.onSuccess(t), e.onOpenChange?.(!1), t;
1126
+ let n;
1127
+ return e.mode === "create" ? n = await o.create(e.objectName, t) : e.mode === "edit" && e.recordId && (n = await o.update(e.objectName, e.recordId, t)), e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
1128
+ } catch (t) {
1129
+ throw e.onError && e.onError(t), t;
1130
+ } finally {
1131
+ A(!1);
1132
+ }
1133
+ }, [e, o]), z = t(() => {
1134
+ e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
1135
+ }, [e]), B = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", V = e.showSubmit !== !1 && e.mode !== "view", H = e.showCancel !== !1, U = e.submitText || (e.mode === "create" ? "Create" : "Update"), W = e.cancelText || "Cancel", G = {
1136
+ type: "form",
1137
+ layout: B,
1138
+ defaultValues: v,
1139
+ submitLabel: U,
1140
+ cancelLabel: W,
1141
+ showSubmit: V,
1142
+ showCancel: H,
1143
+ onSubmit: R,
1144
+ onCancel: z,
1145
+ showActions: !1,
1146
+ id: N
1147
+ }, J = () => {
1148
+ if (D) return /* @__PURE__ */ (0, K.jsxs)("div", {
1149
+ className: "p-4 border border-red-300 bg-red-50 rounded-md",
1150
+ children: [/* @__PURE__ */ (0, K.jsx)("h3", {
1151
+ className: "text-red-800 font-semibold",
1152
+ children: "Error loading form"
1153
+ }), /* @__PURE__ */ (0, K.jsx)("p", {
1154
+ className: "text-red-600 text-sm mt-1",
1155
+ children: D.message
1156
+ })]
1157
+ });
1158
+ if (T) return /* @__PURE__ */ (0, K.jsx)("div", {
1159
+ className: "space-y-4",
1160
+ "data-testid": "modal-form-skeleton",
1161
+ children: [
1162
+ 1,
1163
+ 2,
1164
+ 3
1165
+ ].map((e) => /* @__PURE__ */ (0, K.jsxs)("div", {
1166
+ className: "space-y-2",
1167
+ children: [/* @__PURE__ */ (0, K.jsx)(M, { className: "h-4 w-24" }), /* @__PURE__ */ (0, K.jsx)(M, { className: "h-10 w-full" })]
1168
+ }, e))
1169
+ });
1170
+ if (e.sections?.length) return /* @__PURE__ */ (0, K.jsx)("div", {
1171
+ className: "space-y-6",
1172
+ children: e.sections.map((e, t) => {
1173
+ let n = e.columns || 1;
1174
+ return /* @__PURE__ */ (0, K.jsx)(q, {
1175
+ label: e.label,
1176
+ description: e.description,
1177
+ columns: n,
1178
+ gridClassName: de[n],
1179
+ children: /* @__PURE__ */ (0, K.jsx)(s, { schema: {
1180
+ ...G,
1181
+ fields: I(e)
1182
+ } })
1183
+ }, e.name || e.label || t);
1184
+ })
1185
+ });
1186
+ let t = P ?? Q(g, m, e.columns, e.mode), n = de[t.columns || 1];
1187
+ return /* @__PURE__ */ (0, K.jsx)(s, { schema: {
1188
+ ...G,
1189
+ fields: t.fields,
1190
+ columns: t.columns,
1191
+ ...n ? { fieldContainerClass: n } : {}
1192
+ } });
1193
+ }, Y = !T && !D && (V || H);
1194
+ return /* @__PURE__ */ (0, K.jsx)(y, {
1195
+ open: j,
1196
+ onOpenChange: e.onOpenChange,
1197
+ children: /* @__PURE__ */ (0, K.jsxs)(C, {
1198
+ className: L(F, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", u, e.className),
1199
+ children: [
1200
+ (e.title || e.description) && /* @__PURE__ */ (0, K.jsxs)(x, {
1201
+ className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
1202
+ children: [e.title && /* @__PURE__ */ (0, K.jsx)(S, { children: e.title }), e.description && /* @__PURE__ */ (0, K.jsx)(b, { children: e.description })]
1203
+ }),
1204
+ /* @__PURE__ */ (0, K.jsx)("div", {
1205
+ className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
1206
+ children: J()
1207
+ }),
1208
+ Y && /* @__PURE__ */ (0, K.jsx)("div", {
1209
+ className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background",
1210
+ "data-testid": "modal-form-footer",
1211
+ children: /* @__PURE__ */ (0, K.jsxs)("div", {
1212
+ className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
1213
+ children: [H && /* @__PURE__ */ (0, K.jsx)(p, {
1214
+ type: "button",
1215
+ variant: "outline",
1216
+ onClick: z,
1217
+ disabled: k,
1218
+ className: "w-full sm:w-auto",
1219
+ children: W
1220
+ }), V && /* @__PURE__ */ (0, K.jsxs)(p, {
1221
+ type: "submit",
1222
+ form: N,
1223
+ disabled: k,
1224
+ className: "w-full sm:w-auto",
1225
+ children: [k && /* @__PURE__ */ (0, K.jsx)(ee, { className: "mr-2 h-4 w-4 animate-spin" }), U]
1226
+ })]
1227
+ })
1228
+ })
1229
+ ]
1230
+ })
1231
+ });
1232
+ }, $ = ({ schema: e, dataSource: t }) => {
1233
+ if (e.formType === "tabbed" && e.sections?.length) return /* @__PURE__ */ (0, K.jsx)(J, {
1234
+ schema: {
1235
+ ...e,
1236
+ formType: "tabbed",
1237
+ sections: e.sections.map((e) => ({
1238
+ name: e.name,
1239
+ label: e.label,
1240
+ description: e.description,
1241
+ columns: e.columns,
1242
+ fields: e.fields
1243
+ })),
1244
+ defaultTab: e.defaultTab,
1245
+ tabPosition: e.tabPosition
1246
+ },
1247
+ dataSource: t,
1248
+ className: e.className
1249
+ });
1250
+ if (e.formType === "wizard" && e.sections?.length) return /* @__PURE__ */ (0, K.jsx)(Y, {
1251
+ schema: {
1252
+ ...e,
1253
+ formType: "wizard",
1254
+ sections: e.sections.map((e) => ({
1255
+ name: e.name,
1256
+ label: e.label,
1257
+ description: e.description,
1258
+ columns: e.columns,
1259
+ fields: e.fields
1260
+ })),
1261
+ allowSkip: e.allowSkip,
1262
+ showStepIndicator: e.showStepIndicator,
1263
+ nextText: e.nextText,
1264
+ prevText: e.prevText,
1265
+ onStepChange: e.onStepChange
1266
+ },
1267
+ dataSource: t,
1268
+ className: e.className
1269
+ });
1270
+ if (e.formType === "split" && e.sections?.length) return /* @__PURE__ */ (0, K.jsx)(te, {
1271
+ schema: {
1272
+ ...e,
1273
+ formType: "split",
1274
+ sections: e.sections.map((e) => ({
1275
+ name: e.name,
1276
+ label: e.label,
1277
+ description: e.description,
1278
+ columns: e.columns,
1279
+ fields: e.fields
1280
+ })),
1281
+ splitDirection: e.splitDirection,
1282
+ splitSize: e.splitSize,
1283
+ splitResizable: e.splitResizable
1284
+ },
1285
+ dataSource: t,
1286
+ className: e.className
1287
+ });
1288
+ if (e.formType === "drawer") {
1289
+ let { layout: n, ...r } = e, i = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
1290
+ return /* @__PURE__ */ (0, K.jsx)(le, {
1291
+ schema: {
1292
+ ...r,
1293
+ layout: i,
1294
+ formType: "drawer",
1295
+ sections: e.sections?.map((e) => ({
1296
+ name: e.name,
1297
+ label: e.label,
1298
+ description: e.description,
1299
+ columns: e.columns,
1300
+ fields: e.fields
1301
+ })),
1302
+ open: e.open,
1303
+ onOpenChange: e.onOpenChange,
1304
+ drawerSide: e.drawerSide,
1305
+ drawerWidth: e.drawerWidth
1306
+ },
1307
+ dataSource: t,
1308
+ className: e.className
1309
+ });
1310
+ }
1311
+ if (e.formType === "modal") {
1312
+ let { layout: n, ...r } = e, i = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
1313
+ return /* @__PURE__ */ (0, K.jsx)(fe, {
1314
+ schema: {
1315
+ ...r,
1316
+ layout: i,
1317
+ formType: "modal",
1318
+ sections: e.sections?.map((e) => ({
1319
+ name: e.name,
1320
+ label: e.label,
1321
+ description: e.description,
1322
+ columns: e.columns,
1323
+ fields: e.fields
1324
+ })),
1325
+ open: e.open,
1326
+ onOpenChange: e.onOpenChange,
1327
+ modalSize: e.modalSize,
1328
+ modalCloseButton: e.modalCloseButton
1329
+ },
1330
+ dataSource: t,
1331
+ className: e.className
1332
+ });
1333
+ }
1334
+ return /* @__PURE__ */ (0, K.jsx)(pe, {
1335
+ schema: e,
1336
+ dataSource: t
1337
+ });
1338
+ }, pe = ({ schema: r, dataSource: i }) => {
1339
+ let { fieldLabel: o } = c(), [p, m] = a(null), [h, g] = a([]), [_, v] = a(null), [y, b] = a(!0), [x, S] = a(null), C = r.customFields && r.customFields.length > 0;
1340
+ n(() => {
1341
+ C && (v(r.initialData || r.initialValues || {}), b(!1));
1342
+ }, [
1343
+ C,
1344
+ r.initialData,
1345
+ r.initialValues
1346
+ ]), n(() => {
1347
+ C ? m({
1348
+ name: r.objectName,
1349
+ fields: {}
1350
+ }) : r.objectName && i ? (async () => {
1351
+ try {
1352
+ if (!i) throw Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");
1353
+ let e = await i.getObjectSchema(r.objectName);
1354
+ if (!e) throw Error(`No schema found for object "${r.objectName}"`);
1355
+ m(e);
1356
+ } catch (e) {
1357
+ S(e), b(!1);
1358
+ }
1359
+ })() : C || b(!1);
1360
+ }, [
1361
+ r.objectName,
1362
+ i,
1363
+ C
1364
+ ]), n(() => {
1365
+ p && !C && (async () => {
1366
+ if (!r.recordId || r.mode === "create") {
1367
+ v(r.initialData || r.initialValues || {}), b(!1);
1368
+ return;
1369
+ }
1370
+ if (!C) {
1371
+ if (!i) {
1372
+ S(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), b(!1);
1373
+ return;
1374
+ }
1375
+ b(!0);
1376
+ try {
1377
+ v(await i.findOne(r.objectName, r.recordId));
1378
+ } catch (e) {
1379
+ console.error("Failed to fetch record:", e), S(e);
1380
+ } finally {
1381
+ b(!1);
1382
+ }
1383
+ }
1384
+ })();
1385
+ }, [
1386
+ r.objectName,
1387
+ r.recordId,
1388
+ r.mode,
1389
+ r.initialValues,
1390
+ r.initialData,
1391
+ i,
1392
+ p,
1393
+ C
1394
+ ]), n(() => {
1395
+ if (C && r.customFields) {
1396
+ g(r.customFields), b(!1);
1397
+ return;
1398
+ }
1399
+ if (!p) return;
1400
+ let e = [], t = r.fields || Object.keys(p.fields || {});
1401
+ (Array.isArray(t) ? t : Object.keys(t)).forEach((t) => {
1402
+ let n = typeof t == "string" ? t : t.name;
1403
+ if (!n) return;
1404
+ let i = p.fields?.[n];
1405
+ if (!i && !C) return;
1406
+ let a = !i?.permissions || i?.permissions.write !== !1;
1407
+ if (r.mode !== "view" && !a) return;
1408
+ let s = r.customFields?.find((e) => e.name === n);
1409
+ if (s) e.push(s);
1410
+ else if (i) {
1411
+ let a = {
1412
+ name: n,
1413
+ label: o(r.objectName, n, i.label || t),
1414
+ type: f(i.type),
1415
+ required: i.required || !1,
1416
+ disabled: r.readOnly || r.mode === "view" || i.readonly,
1417
+ placeholder: i.placeholder,
1418
+ description: i.help || i.description,
1419
+ validation: l(i),
1420
+ field: i
1421
+ };
1422
+ if ((i.type === "select" || i.type === "lookup" || i.type === "master_detail") && (a.options = i.options || [], a.multiple = i.multiple), (i.type === "number" || i.type === "currency" || i.type === "percent") && (a.inputType = "number", a.min = i.min, a.max = i.max, a.step = i.precision ? 10 ** -i.precision : void 0), i.type === "date" && (a.inputType = "date"), i.type === "datetime" && (a.inputType = "datetime-local"), (i.type === "text" || i.type === "textarea" || i.type === "markdown" || i.type === "html") && (a.maxLength = i.max_length, a.minLength = i.min_length), (i.type === "file" || i.type === "image") && (a.inputType = "file", a.multiple = i.multiple, a.accept = i.accept ? i.accept.join(",") : void 0, i.max_size)) {
1423
+ let e = `Max size: ${d(i.max_size)}`;
1424
+ a.description = a.description ? `${a.description} (${e})` : e;
1425
+ }
1426
+ i.type === "email" && (a.inputType = "email"), i.type === "phone" && (a.inputType = "tel"), i.type === "url" && (a.inputType = "url"), i.type === "password" && (a.inputType = "password"), i.type === "time" && (a.inputType = "time"), (i.type === "formula" || i.type === "summary" || i.type === "auto_number") && (a.disabled = !0), i.visible_on && (a.visible = (e) => u(i.visible_on, e)), e.push(a);
1427
+ }
1428
+ }), g(e), !C && r.recordId && r.mode !== "create" && i || b(!1);
1429
+ }, [
1430
+ p,
1431
+ r.fields,
1432
+ r.customFields,
1433
+ r.readOnly,
1434
+ r.mode,
1435
+ C,
1436
+ r.recordId,
1437
+ i
1438
+ ]);
1439
+ let w = t(async (e, t) => {
1440
+ if (e && (e.nativeEvent || e._reactName === "onSubmit") && (console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."), t === void 0 && (t = e, e = {})), C && !i) return r.onSuccess && await r.onSuccess(e), e;
1441
+ if (!i) throw Error("DataSource is required for form submission (inline mode not configured)");
1442
+ try {
1443
+ let t;
1444
+ if (r.mode === "create") t = await i.create(r.objectName, e);
1445
+ else if (r.mode === "edit" && r.recordId) t = await i.update(r.objectName, r.recordId, e);
1446
+ else throw Error("Invalid form mode or missing record ID");
1447
+ return r.onSuccess && await r.onSuccess(t), t;
1448
+ } catch (e) {
1449
+ throw console.error("Failed to submit form:", e), r.onError && r.onError(e), e;
1450
+ }
1451
+ }, [
1452
+ r,
1453
+ i,
1454
+ C
1455
+ ]), T = t(() => {
1456
+ r.onCancel && r.onCancel();
1457
+ }, [r]), E = {
1458
+ ...e.useMemo(() => {
1459
+ if (!p?.fields) return {};
1460
+ let e = {};
1461
+ return Object.keys(p.fields).forEach((t) => {
1462
+ let n = p.fields[t];
1463
+ n.defaultValue !== void 0 && (e[t] = n.defaultValue);
1464
+ }), e;
1465
+ }, [p]),
1466
+ ..._
1467
+ };
1468
+ if (x) return /* @__PURE__ */ (0, K.jsxs)("div", {
1469
+ className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
1470
+ children: [/* @__PURE__ */ (0, K.jsx)("h3", {
1471
+ className: "text-red-800 font-semibold",
1472
+ children: "Error loading form"
1473
+ }), /* @__PURE__ */ (0, K.jsx)("p", {
1474
+ className: "text-red-600 text-sm mt-1",
1475
+ children: x.message
1476
+ })]
1477
+ });
1478
+ if (y) return /* @__PURE__ */ (0, K.jsxs)("div", {
1479
+ className: "p-4 sm:p-8 text-center",
1480
+ children: [/* @__PURE__ */ (0, K.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, K.jsx)("p", {
1481
+ className: "mt-2 text-sm text-gray-600",
1482
+ children: "Loading form..."
1483
+ })]
1484
+ });
1485
+ let D = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : "vertical";
1486
+ if (r.sections?.length && (!r.formType || r.formType === "simple")) return /* @__PURE__ */ (0, K.jsx)("div", {
1487
+ className: "w-full space-y-6",
1488
+ children: r.sections.map((e, t) => {
1489
+ let n = e.fields.map((e) => typeof e == "string" ? e : e.name), i = h.filter((e) => n.includes(e.name));
1490
+ return /* @__PURE__ */ (0, K.jsx)(q, {
1491
+ label: e.label,
1492
+ description: e.description,
1493
+ collapsible: e.collapsible,
1494
+ collapsed: e.collapsed,
1495
+ columns: e.columns,
1496
+ children: /* @__PURE__ */ (0, K.jsx)(s, { schema: {
1497
+ type: "form",
1498
+ fields: i,
1499
+ layout: D,
1500
+ defaultValues: E,
1501
+ showSubmit: t === r.sections.length - 1 && r.showSubmit !== !1 && r.mode !== "view",
1502
+ showCancel: t === r.sections.length - 1 && r.showCancel !== !1,
1503
+ submitLabel: r.submitText || (r.mode === "create" ? "Create" : "Update"),
1504
+ cancelLabel: r.cancelText,
1505
+ onSubmit: w,
1506
+ onCancel: T
1507
+ } })
1508
+ }, e.name || e.label || t);
1509
+ })
1510
+ });
1511
+ let O = r.sections?.length ? {
1512
+ fields: h,
1513
+ columns: r.columns
1514
+ } : Q(h, p, r.columns, r.mode);
1515
+ return /* @__PURE__ */ (0, K.jsx)("div", {
1516
+ className: "w-full",
1517
+ children: /* @__PURE__ */ (0, K.jsx)(s, { schema: {
1518
+ type: "form",
1519
+ fields: O.fields,
1520
+ layout: D,
1521
+ columns: O.columns,
1522
+ submitLabel: r.submitText || (r.mode === "create" ? "Create" : "Update"),
1523
+ cancelLabel: r.cancelText,
1524
+ showSubmit: r.showSubmit !== !1 && r.mode !== "view",
1525
+ showCancel: r.showCancel !== !1,
1526
+ resetOnSubmit: r.showReset,
1527
+ defaultValues: E,
1528
+ onSubmit: w,
1529
+ onCancel: T,
1530
+ className: r.className
1531
+ } })
1532
+ });
1533
+ }, me = ({ config: e, dataSource: n, prefillParams: r, className: o }) => {
1534
+ let [s, c] = a(!1), [l, u] = a(!1), [d, f] = a(null), p = i(() => {
1535
+ let e = {};
1536
+ if (r) for (let [t, n] of Object.entries(r)) e[t] = n;
1537
+ return typeof window < "u" && new URLSearchParams(window.location.search).forEach((t, n) => {
1538
+ n in e || (e[n] = t);
1539
+ }), Object.keys(e).length > 0 ? e : void 0;
1540
+ }, [r]), m = t(async (t) => {
1541
+ u(!0), f(null);
1542
+ try {
1543
+ if (n && await n.create(e.objectName, t), c(!0), e.thankYouPage?.redirectUrl) {
1544
+ let t = e.thankYouPage.redirectDelay ?? 3e3;
1545
+ setTimeout(() => {
1546
+ window.location.href = e.thankYouPage.redirectUrl;
1547
+ }, t);
1548
+ }
1549
+ } catch (e) {
1550
+ f(e instanceof Error ? e.message : "Failed to submit form. Please try again.");
1551
+ } finally {
1552
+ u(!1);
1553
+ }
1554
+ }, [n, e]), h = t(() => {
1555
+ c(!1), f(null);
1556
+ }, []), g = i(() => {
1557
+ let t = {};
1558
+ return e.branding?.backgroundColor && (t.backgroundColor = e.branding.backgroundColor), t;
1559
+ }, [e.branding]);
1560
+ if (s) {
1561
+ let t = e.thankYouPage;
1562
+ return /* @__PURE__ */ (0, K.jsx)("div", {
1563
+ className: `min-h-screen flex items-center justify-center p-4 ${o || ""}`,
1564
+ style: g,
1565
+ children: /* @__PURE__ */ (0, K.jsxs)("div", {
1566
+ className: "max-w-md w-full bg-card rounded-lg shadow-lg p-8 text-center space-y-4",
1567
+ children: [
1568
+ /* @__PURE__ */ (0, K.jsx)("div", {
1569
+ className: "text-4xl",
1570
+ children: "✓"
1571
+ }),
1572
+ /* @__PURE__ */ (0, K.jsx)("h2", {
1573
+ className: "text-xl font-semibold text-foreground",
1574
+ children: t?.title || "Thank You!"
1575
+ }),
1576
+ /* @__PURE__ */ (0, K.jsx)("p", {
1577
+ className: "text-muted-foreground",
1578
+ children: t?.message || "Your submission has been received successfully."
1579
+ }),
1580
+ e.allowMultiple && /* @__PURE__ */ (0, K.jsx)("button", {
1581
+ onClick: h,
1582
+ className: "mt-4 px-4 py-2 text-sm font-medium rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors",
1583
+ children: "Submit Another Response"
1584
+ }),
1585
+ t?.redirectUrl && /* @__PURE__ */ (0, K.jsxs)("p", {
1586
+ className: "text-xs text-muted-foreground",
1587
+ children: [
1588
+ "Redirecting in ",
1589
+ Math.ceil((t.redirectDelay ?? 3e3) / 1e3),
1590
+ " seconds..."
1591
+ ]
1592
+ })
1593
+ ]
1594
+ })
1595
+ });
1596
+ }
1597
+ return /* @__PURE__ */ (0, K.jsx)("div", {
1598
+ className: `min-h-screen flex items-center justify-center p-4 ${o || ""}`,
1599
+ style: g,
1600
+ children: /* @__PURE__ */ (0, K.jsxs)("div", {
1601
+ className: "max-w-2xl w-full bg-card rounded-lg shadow-lg overflow-hidden",
1602
+ children: [
1603
+ /* @__PURE__ */ (0, K.jsxs)("div", {
1604
+ className: "p-6 border-b",
1605
+ style: e.branding?.primaryColor ? { borderBottomColor: e.branding.primaryColor } : void 0,
1606
+ children: [
1607
+ e.branding?.logo && /* @__PURE__ */ (0, K.jsx)("img", {
1608
+ src: e.branding.logo,
1609
+ alt: "Logo",
1610
+ className: "h-8 mb-4"
1611
+ }),
1612
+ e.title && /* @__PURE__ */ (0, K.jsx)("h1", {
1613
+ className: "text-xl font-semibold text-foreground",
1614
+ children: e.title
1615
+ }),
1616
+ e.description && /* @__PURE__ */ (0, K.jsx)("p", {
1617
+ className: "text-sm text-muted-foreground mt-1",
1618
+ children: e.description
1619
+ })
1620
+ ]
1621
+ }),
1622
+ /* @__PURE__ */ (0, K.jsxs)("div", {
1623
+ className: "p-6",
1624
+ children: [d && /* @__PURE__ */ (0, K.jsx)("div", {
1625
+ className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
1626
+ children: d
1627
+ }), /* @__PURE__ */ (0, K.jsx)($, {
1628
+ schema: {
1629
+ type: "object-form",
1630
+ objectName: e.objectName,
1631
+ mode: "create",
1632
+ fields: e.fields,
1633
+ customFields: e.customFields,
1634
+ initialData: p,
1635
+ onSuccess: m,
1636
+ submitLabel: l ? "Submitting..." : "Submit"
1637
+ },
1638
+ dataSource: n
1639
+ })]
1640
+ }),
1641
+ /* @__PURE__ */ (0, K.jsx)("div", {
1642
+ className: "px-6 py-3 border-t bg-muted/20 text-center",
1643
+ children: /* @__PURE__ */ (0, K.jsx)("p", {
1644
+ className: "text-xs text-muted-foreground",
1645
+ children: "Powered by ObjectStack"
1646
+ })
1647
+ })
1648
+ ]
1649
+ })
1650
+ });
1699
1651
  };
1700
- function mt(e) {
1701
- return e < 60 ? `${Math.round(e)}s` : e < 3600 ? `${Math.floor(e / 60)}m ${Math.round(e % 60)}s` : `${Math.floor(e / 3600)}h ${Math.floor(e % 3600 / 60)}m`;
1652
+ //#endregion
1653
+ //#region src/FormAnalytics.tsx
1654
+ function he(e) {
1655
+ return e < 60 ? `${Math.round(e)}s` : e < 3600 ? `${Math.floor(e / 60)}m ${Math.round(e % 60)}s` : `${Math.floor(e / 3600)}h ${Math.floor(e % 3600 / 60)}m`;
1702
1656
  }
1703
- const bt = ({
1704
- formId: e,
1705
- formTitle: r,
1706
- metrics: i,
1707
- className: b
1708
- }) => {
1709
- const o = G(() => {
1710
- if (!i.abandonedSubmissions) return 100;
1711
- const x = i.totalSubmissions + i.abandonedSubmissions;
1712
- return x === 0 ? 0 : Math.round(i.totalSubmissions / x * 100);
1713
- }, [i.totalSubmissions, i.abandonedSubmissions]), p = G(() => i.dailySubmissions?.length ? Math.max(...i.dailySubmissions.map((x) => x.count), 1) : 1, [i.dailySubmissions]);
1714
- return /* @__PURE__ */ t.jsxs("div", { className: `space-y-4 ${b || ""}`, children: [
1715
- /* @__PURE__ */ t.jsxs("div", { children: [
1716
- /* @__PURE__ */ t.jsx("h2", { className: "text-lg font-semibold text-foreground", children: r || "Form Analytics" }),
1717
- /* @__PURE__ */ t.jsxs("p", { className: "text-sm text-muted-foreground", children: [
1718
- "Form ID: ",
1719
- e
1720
- ] })
1721
- ] }),
1722
- /* @__PURE__ */ t.jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-3 gap-4", children: [
1723
- /* @__PURE__ */ t.jsx(re, { children: /* @__PURE__ */ t.jsxs(le, { className: "pb-2", children: [
1724
- /* @__PURE__ */ t.jsx(ae, { children: "Total Submissions" }),
1725
- /* @__PURE__ */ t.jsx(ne, { className: "text-2xl", children: i.totalSubmissions.toLocaleString() })
1726
- ] }) }),
1727
- /* @__PURE__ */ t.jsxs(re, { children: [
1728
- /* @__PURE__ */ t.jsxs(le, { className: "pb-2", children: [
1729
- /* @__PURE__ */ t.jsx(ae, { children: "Fill Rate" }),
1730
- /* @__PURE__ */ t.jsxs(ne, { className: "text-2xl", children: [
1731
- o,
1732
- "%"
1733
- ] })
1734
- ] }),
1735
- /* @__PURE__ */ t.jsx(me, { children: /* @__PURE__ */ t.jsx("div", { className: "w-full bg-muted rounded-full h-2", children: /* @__PURE__ */ t.jsx(
1736
- "div",
1737
- {
1738
- className: "bg-primary rounded-full h-2 transition-all",
1739
- style: { width: `${o}%` }
1740
- }
1741
- ) }) })
1742
- ] }),
1743
- /* @__PURE__ */ t.jsx(re, { children: /* @__PURE__ */ t.jsxs(le, { className: "pb-2", children: [
1744
- /* @__PURE__ */ t.jsx(ae, { children: "Avg. Completion Time" }),
1745
- /* @__PURE__ */ t.jsx(ne, { className: "text-2xl", children: i.avgCompletionTime ? mt(i.avgCompletionTime) : "—" })
1746
- ] }) })
1747
- ] }),
1748
- i.dailySubmissions && i.dailySubmissions.length > 0 && /* @__PURE__ */ t.jsxs(re, { children: [
1749
- /* @__PURE__ */ t.jsx(le, { children: /* @__PURE__ */ t.jsx(ne, { className: "text-sm font-medium", children: "Daily Submissions" }) }),
1750
- /* @__PURE__ */ t.jsx(me, { children: /* @__PURE__ */ t.jsx("div", { className: "flex items-end gap-1 h-32", children: i.dailySubmissions.map((x, E) => /* @__PURE__ */ t.jsxs("div", { className: "flex-1 flex flex-col items-center gap-1", children: [
1751
- /* @__PURE__ */ t.jsx(
1752
- "div",
1753
- {
1754
- className: "w-full bg-primary/80 rounded-t transition-all hover:bg-primary",
1755
- style: { height: `${x.count / p * 100}%`, minHeight: x.count > 0 ? "4px" : "0" },
1756
- title: `${x.date}: ${x.count} submissions`
1757
- }
1758
- ),
1759
- /* @__PURE__ */ t.jsx("span", { className: "text-[10px] text-muted-foreground truncate w-full text-center", children: x.date.slice(-5) })
1760
- ] }, E)) }) })
1761
- ] }),
1762
- i.fieldDropOff && i.fieldDropOff.length > 0 && /* @__PURE__ */ t.jsxs(re, { children: [
1763
- /* @__PURE__ */ t.jsxs(le, { children: [
1764
- /* @__PURE__ */ t.jsx(ne, { className: "text-sm font-medium", children: "Field Completion Rates" }),
1765
- /* @__PURE__ */ t.jsx(ae, { children: "Percentage of users who completed each field" })
1766
- ] }),
1767
- /* @__PURE__ */ t.jsx(me, { children: /* @__PURE__ */ t.jsx("div", { className: "space-y-3", children: i.fieldDropOff.map((x, E) => /* @__PURE__ */ t.jsxs("div", { className: "space-y-1", children: [
1768
- /* @__PURE__ */ t.jsxs("div", { className: "flex justify-between text-sm", children: [
1769
- /* @__PURE__ */ t.jsx("span", { className: "text-foreground", children: x.label }),
1770
- /* @__PURE__ */ t.jsxs("span", { className: "text-muted-foreground", children: [
1771
- x.completionRate,
1772
- "%"
1773
- ] })
1774
- ] }),
1775
- /* @__PURE__ */ t.jsx("div", { className: "w-full bg-muted rounded-full h-1.5", children: /* @__PURE__ */ t.jsx(
1776
- "div",
1777
- {
1778
- className: `rounded-full h-1.5 transition-all ${x.completionRate >= 80 ? "bg-green-500" : x.completionRate >= 50 ? "bg-yellow-500" : "bg-destructive"}`,
1779
- style: { width: `${x.completionRate}%` }
1780
- }
1781
- ) })
1782
- ] }, E)) }) })
1783
- ] })
1784
- ] });
1785
- }, Ee = ({ schema: e }) => /* @__PURE__ */ t.jsx(he, { schema: e });
1786
- ue.register("object-form", Ee, {
1787
- namespace: "plugin-form",
1788
- label: "Object Form",
1789
- category: "plugin",
1790
- inputs: [
1791
- { name: "objectName", type: "string", label: "Object Name", required: !0 },
1792
- { name: "fields", type: "array", label: "Fields" },
1793
- { name: "mode", type: "enum", label: "Mode", enum: ["create", "edit", "view"] },
1794
- { name: "formType", type: "enum", label: "Form Type", enum: ["simple", "tabbed", "wizard", "split", "drawer", "modal"] },
1795
- { name: "sections", type: "array", label: "Sections" },
1796
- { name: "title", type: "string", label: "Title" },
1797
- { name: "description", type: "string", label: "Description" },
1798
- { name: "layout", type: "enum", label: "Layout", enum: ["vertical", "horizontal", "inline", "grid"] },
1799
- { name: "columns", type: "number", label: "Columns" },
1800
- // Tabbed
1801
- { name: "defaultTab", type: "string", label: "Default Tab" },
1802
- { name: "tabPosition", type: "enum", label: "Tab Position", enum: ["top", "bottom", "left", "right"] },
1803
- // Wizard
1804
- { name: "allowSkip", type: "boolean", label: "Allow Skip Steps" },
1805
- { name: "showStepIndicator", type: "boolean", label: "Show Step Indicator" },
1806
- // Split
1807
- { name: "splitDirection", type: "enum", label: "Split Direction", enum: ["horizontal", "vertical"] },
1808
- { name: "splitSize", type: "number", label: "Split Panel Size (%)" },
1809
- { name: "splitResizable", type: "boolean", label: "Split Resizable" },
1810
- // Drawer
1811
- { name: "drawerSide", type: "enum", label: "Drawer Side", enum: ["top", "bottom", "left", "right"] },
1812
- { name: "drawerWidth", type: "string", label: "Drawer Width" },
1813
- // Modal
1814
- { name: "modalSize", type: "enum", label: "Modal Size", enum: ["sm", "default", "lg", "xl", "full"] }
1815
- ]
1816
- });
1817
- ue.register("form", Ee, {
1818
- namespace: "view",
1819
- skipFallback: !0,
1820
- label: "Data Form View",
1821
- category: "view",
1822
- inputs: [
1823
- { name: "objectName", type: "string", label: "Object Name", required: !0 },
1824
- { name: "fields", type: "array", label: "Fields" },
1825
- { name: "mode", type: "enum", label: "Mode", enum: ["create", "edit", "view"] }
1826
- ]
1657
+ var ge = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
1658
+ let a = i(() => {
1659
+ if (!n.abandonedSubmissions) return 100;
1660
+ let e = n.totalSubmissions + n.abandonedSubmissions;
1661
+ return e === 0 ? 0 : Math.round(n.totalSubmissions / e * 100);
1662
+ }, [n.totalSubmissions, n.abandonedSubmissions]), o = i(() => n.dailySubmissions?.length ? Math.max(...n.dailySubmissions.map((e) => e.count), 1) : 1, [n.dailySubmissions]);
1663
+ return /* @__PURE__ */ (0, K.jsxs)("div", {
1664
+ className: `space-y-4 ${r || ""}`,
1665
+ children: [
1666
+ /* @__PURE__ */ (0, K.jsxs)("div", { children: [/* @__PURE__ */ (0, K.jsx)("h2", {
1667
+ className: "text-lg font-semibold text-foreground",
1668
+ children: t || "Form Analytics"
1669
+ }), /* @__PURE__ */ (0, K.jsxs)("p", {
1670
+ className: "text-sm text-muted-foreground",
1671
+ children: ["Form ID: ", e]
1672
+ })] }),
1673
+ /* @__PURE__ */ (0, K.jsxs)("div", {
1674
+ className: "grid grid-cols-1 sm:grid-cols-3 gap-4",
1675
+ children: [
1676
+ /* @__PURE__ */ (0, K.jsx)(m, { children: /* @__PURE__ */ (0, K.jsxs)(_, {
1677
+ className: "pb-2",
1678
+ children: [/* @__PURE__ */ (0, K.jsx)(g, { children: "Total Submissions" }), /* @__PURE__ */ (0, K.jsx)(v, {
1679
+ className: "text-2xl",
1680
+ children: n.totalSubmissions.toLocaleString()
1681
+ })]
1682
+ }) }),
1683
+ /* @__PURE__ */ (0, K.jsxs)(m, { children: [/* @__PURE__ */ (0, K.jsxs)(_, {
1684
+ className: "pb-2",
1685
+ children: [/* @__PURE__ */ (0, K.jsx)(g, { children: "Fill Rate" }), /* @__PURE__ */ (0, K.jsxs)(v, {
1686
+ className: "text-2xl",
1687
+ children: [a, "%"]
1688
+ })]
1689
+ }), /* @__PURE__ */ (0, K.jsx)(h, { children: /* @__PURE__ */ (0, K.jsx)("div", {
1690
+ className: "w-full bg-muted rounded-full h-2",
1691
+ children: /* @__PURE__ */ (0, K.jsx)("div", {
1692
+ className: "bg-primary rounded-full h-2 transition-all",
1693
+ style: { width: `${a}%` }
1694
+ })
1695
+ }) })] }),
1696
+ /* @__PURE__ */ (0, K.jsx)(m, { children: /* @__PURE__ */ (0, K.jsxs)(_, {
1697
+ className: "pb-2",
1698
+ children: [/* @__PURE__ */ (0, K.jsx)(g, { children: "Avg. Completion Time" }), /* @__PURE__ */ (0, K.jsx)(v, {
1699
+ className: "text-2xl",
1700
+ children: n.avgCompletionTime ? he(n.avgCompletionTime) : "—"
1701
+ })]
1702
+ }) })
1703
+ ]
1704
+ }),
1705
+ n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ (0, K.jsxs)(m, { children: [/* @__PURE__ */ (0, K.jsx)(_, { children: /* @__PURE__ */ (0, K.jsx)(v, {
1706
+ className: "text-sm font-medium",
1707
+ children: "Daily Submissions"
1708
+ }) }), /* @__PURE__ */ (0, K.jsx)(h, { children: /* @__PURE__ */ (0, K.jsx)("div", {
1709
+ className: "flex items-end gap-1 h-32",
1710
+ children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ (0, K.jsxs)("div", {
1711
+ className: "flex-1 flex flex-col items-center gap-1",
1712
+ children: [/* @__PURE__ */ (0, K.jsx)("div", {
1713
+ className: "w-full bg-primary/80 rounded-t transition-all hover:bg-primary",
1714
+ style: {
1715
+ height: `${e.count / o * 100}%`,
1716
+ minHeight: e.count > 0 ? "4px" : "0"
1717
+ },
1718
+ title: `${e.date}: ${e.count} submissions`
1719
+ }), /* @__PURE__ */ (0, K.jsx)("span", {
1720
+ className: "text-[10px] text-muted-foreground truncate w-full text-center",
1721
+ children: e.date.slice(-5)
1722
+ })]
1723
+ }, t))
1724
+ }) })] }),
1725
+ n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ (0, K.jsxs)(m, { children: [/* @__PURE__ */ (0, K.jsxs)(_, { children: [/* @__PURE__ */ (0, K.jsx)(v, {
1726
+ className: "text-sm font-medium",
1727
+ children: "Field Completion Rates"
1728
+ }), /* @__PURE__ */ (0, K.jsx)(g, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ (0, K.jsx)(h, { children: /* @__PURE__ */ (0, K.jsx)("div", {
1729
+ className: "space-y-3",
1730
+ children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ (0, K.jsxs)("div", {
1731
+ className: "space-y-1",
1732
+ children: [/* @__PURE__ */ (0, K.jsxs)("div", {
1733
+ className: "flex justify-between text-sm",
1734
+ children: [/* @__PURE__ */ (0, K.jsx)("span", {
1735
+ className: "text-foreground",
1736
+ children: e.label
1737
+ }), /* @__PURE__ */ (0, K.jsxs)("span", {
1738
+ className: "text-muted-foreground",
1739
+ children: [e.completionRate, "%"]
1740
+ })]
1741
+ }), /* @__PURE__ */ (0, K.jsx)("div", {
1742
+ className: "w-full bg-muted rounded-full h-1.5",
1743
+ children: /* @__PURE__ */ (0, K.jsx)("div", {
1744
+ className: `rounded-full h-1.5 transition-all ${e.completionRate >= 80 ? "bg-green-500" : e.completionRate >= 50 ? "bg-yellow-500" : "bg-destructive"}`,
1745
+ style: { width: `${e.completionRate}%` }
1746
+ })
1747
+ })]
1748
+ }, t))
1749
+ }) })] })
1750
+ ]
1751
+ });
1752
+ }, _e = ({ schema: e }) => /* @__PURE__ */ (0, K.jsx)($, { schema: e });
1753
+ o.register("object-form", _e, {
1754
+ namespace: "plugin-form",
1755
+ label: "Object Form",
1756
+ category: "plugin",
1757
+ inputs: [
1758
+ {
1759
+ name: "objectName",
1760
+ type: "string",
1761
+ label: "Object Name",
1762
+ required: !0
1763
+ },
1764
+ {
1765
+ name: "fields",
1766
+ type: "array",
1767
+ label: "Fields"
1768
+ },
1769
+ {
1770
+ name: "mode",
1771
+ type: "enum",
1772
+ label: "Mode",
1773
+ enum: [
1774
+ "create",
1775
+ "edit",
1776
+ "view"
1777
+ ]
1778
+ },
1779
+ {
1780
+ name: "formType",
1781
+ type: "enum",
1782
+ label: "Form Type",
1783
+ enum: [
1784
+ "simple",
1785
+ "tabbed",
1786
+ "wizard",
1787
+ "split",
1788
+ "drawer",
1789
+ "modal"
1790
+ ]
1791
+ },
1792
+ {
1793
+ name: "sections",
1794
+ type: "array",
1795
+ label: "Sections"
1796
+ },
1797
+ {
1798
+ name: "title",
1799
+ type: "string",
1800
+ label: "Title"
1801
+ },
1802
+ {
1803
+ name: "description",
1804
+ type: "string",
1805
+ label: "Description"
1806
+ },
1807
+ {
1808
+ name: "layout",
1809
+ type: "enum",
1810
+ label: "Layout",
1811
+ enum: [
1812
+ "vertical",
1813
+ "horizontal",
1814
+ "inline",
1815
+ "grid"
1816
+ ]
1817
+ },
1818
+ {
1819
+ name: "columns",
1820
+ type: "number",
1821
+ label: "Columns"
1822
+ },
1823
+ {
1824
+ name: "defaultTab",
1825
+ type: "string",
1826
+ label: "Default Tab"
1827
+ },
1828
+ {
1829
+ name: "tabPosition",
1830
+ type: "enum",
1831
+ label: "Tab Position",
1832
+ enum: [
1833
+ "top",
1834
+ "bottom",
1835
+ "left",
1836
+ "right"
1837
+ ]
1838
+ },
1839
+ {
1840
+ name: "allowSkip",
1841
+ type: "boolean",
1842
+ label: "Allow Skip Steps"
1843
+ },
1844
+ {
1845
+ name: "showStepIndicator",
1846
+ type: "boolean",
1847
+ label: "Show Step Indicator"
1848
+ },
1849
+ {
1850
+ name: "splitDirection",
1851
+ type: "enum",
1852
+ label: "Split Direction",
1853
+ enum: ["horizontal", "vertical"]
1854
+ },
1855
+ {
1856
+ name: "splitSize",
1857
+ type: "number",
1858
+ label: "Split Panel Size (%)"
1859
+ },
1860
+ {
1861
+ name: "splitResizable",
1862
+ type: "boolean",
1863
+ label: "Split Resizable"
1864
+ },
1865
+ {
1866
+ name: "drawerSide",
1867
+ type: "enum",
1868
+ label: "Drawer Side",
1869
+ enum: [
1870
+ "top",
1871
+ "bottom",
1872
+ "left",
1873
+ "right"
1874
+ ]
1875
+ },
1876
+ {
1877
+ name: "drawerWidth",
1878
+ type: "string",
1879
+ label: "Drawer Width"
1880
+ },
1881
+ {
1882
+ name: "modalSize",
1883
+ type: "enum",
1884
+ label: "Modal Size",
1885
+ enum: [
1886
+ "sm",
1887
+ "default",
1888
+ "lg",
1889
+ "xl",
1890
+ "full"
1891
+ ]
1892
+ }
1893
+ ]
1894
+ }), o.register("form", _e, {
1895
+ namespace: "view",
1896
+ skipFallback: !0,
1897
+ label: "Data Form View",
1898
+ category: "view",
1899
+ inputs: [
1900
+ {
1901
+ name: "objectName",
1902
+ type: "string",
1903
+ label: "Object Name",
1904
+ required: !0
1905
+ },
1906
+ {
1907
+ name: "fields",
1908
+ type: "array",
1909
+ label: "Fields"
1910
+ },
1911
+ {
1912
+ name: "mode",
1913
+ type: "enum",
1914
+ label: "Mode",
1915
+ enum: [
1916
+ "create",
1917
+ "edit",
1918
+ "view"
1919
+ ]
1920
+ }
1921
+ ]
1922
+ }), o.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */ (0, K.jsx)(me, { config: e }), {
1923
+ namespace: "plugin-form",
1924
+ label: "Embeddable Form",
1925
+ category: "plugin",
1926
+ inputs: [
1927
+ {
1928
+ name: "formId",
1929
+ type: "string",
1930
+ label: "Form ID",
1931
+ required: !0
1932
+ },
1933
+ {
1934
+ name: "objectName",
1935
+ type: "string",
1936
+ label: "Object Name",
1937
+ required: !0
1938
+ },
1939
+ {
1940
+ name: "title",
1941
+ type: "string",
1942
+ label: "Form Title"
1943
+ },
1944
+ {
1945
+ name: "description",
1946
+ type: "string",
1947
+ label: "Description"
1948
+ },
1949
+ {
1950
+ name: "fields",
1951
+ type: "array",
1952
+ label: "Fields"
1953
+ },
1954
+ {
1955
+ name: "allowMultiple",
1956
+ type: "boolean",
1957
+ label: "Allow Multiple Submissions"
1958
+ }
1959
+ ]
1960
+ }), o.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ (0, K.jsx)(ge, {
1961
+ formId: e.formId,
1962
+ formTitle: e.formTitle,
1963
+ metrics: e.metrics || { totalSubmissions: 0 }
1964
+ }), {
1965
+ namespace: "plugin-form",
1966
+ label: "Form Analytics",
1967
+ category: "plugin",
1968
+ inputs: [
1969
+ {
1970
+ name: "formId",
1971
+ type: "string",
1972
+ label: "Form ID",
1973
+ required: !0
1974
+ },
1975
+ {
1976
+ name: "formTitle",
1977
+ type: "string",
1978
+ label: "Form Title"
1979
+ },
1980
+ {
1981
+ name: "metrics",
1982
+ type: "object",
1983
+ label: "Submission Metrics"
1984
+ }
1985
+ ]
1827
1986
  });
1828
- const xt = ({ schema: e }) => /* @__PURE__ */ t.jsx(pt, { config: e });
1829
- ue.register("embeddable-form", xt, {
1830
- namespace: "plugin-form",
1831
- label: "Embeddable Form",
1832
- category: "plugin",
1833
- inputs: [
1834
- { name: "formId", type: "string", label: "Form ID", required: !0 },
1835
- { name: "objectName", type: "string", label: "Object Name", required: !0 },
1836
- { name: "title", type: "string", label: "Form Title" },
1837
- { name: "description", type: "string", label: "Description" },
1838
- { name: "fields", type: "array", label: "Fields" },
1839
- { name: "allowMultiple", type: "boolean", label: "Allow Multiple Submissions" }
1840
- ]
1841
- });
1842
- const yt = ({ schema: e }) => /* @__PURE__ */ t.jsx(bt, { formId: e.formId, formTitle: e.formTitle, metrics: e.metrics || { totalSubmissions: 0 } });
1843
- ue.register("form-analytics", yt, {
1844
- namespace: "plugin-form",
1845
- label: "Form Analytics",
1846
- category: "plugin",
1847
- inputs: [
1848
- { name: "formId", type: "string", label: "Form ID", required: !0 },
1849
- { name: "formTitle", type: "string", label: "Form Title" },
1850
- { name: "metrics", type: "object", label: "Submission Metrics" }
1851
- ]
1852
- });
1853
- export {
1854
- ct as DrawerForm,
1855
- pt as EmbeddableForm,
1856
- bt as FormAnalytics,
1857
- te as FormSection,
1858
- ut as ModalForm,
1859
- he as ObjectForm,
1860
- lt as SplitForm,
1861
- tt as TabbedForm,
1862
- rt as WizardForm,
1863
- we as applyAutoColSpan,
1864
- ce as applyAutoLayout,
1865
- dt as filterCreateModeFields,
1866
- at as inferColumns,
1867
- Ne as inferModalSize,
1868
- st as isAutoGeneratedFieldType,
1869
- ot as isWideFieldType
1870
- };
1987
+ //#endregion
1988
+ export { le as DrawerForm, me as EmbeddableForm, ge as FormAnalytics, q as FormSection, fe as ModalForm, $ as ObjectForm, te as SplitForm, J as TabbedForm, Y as WizardForm, X as applyAutoColSpan, Q as applyAutoLayout, se as filterCreateModeFields, oe as inferColumns, Z as inferModalSize, ae as isAutoGeneratedFieldType, ie as isWideFieldType };