@object-ui/plugin-form 11.3.0 → 11.5.0

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,30 +1,31 @@
1
1
  import e, { useCallback as t, useContext as n, useEffect as r, useId as i, useMemo as a, useRef as o, useState as s } from "react";
2
2
  import { ComponentRegistry as c } from "@object-ui/core";
3
3
  import { SchemaRenderer as l, SchemaRendererContext as u, usePreviewMode as d, useRecordContext as f, useSafeFieldLabel as p, useSchemaContext as m } from "@object-ui/react";
4
- import { LineItemsField as h, buildValidationRules as g, evaluateCondition as _, formatFileSize as v, mapFieldTypeToFormType as y } from "@object-ui/fields";
5
- import { AlertDialog as b, AlertDialogAction as x, AlertDialogCancel as S, AlertDialogContent as C, AlertDialogDescription as w, AlertDialogFooter as T, AlertDialogHeader as E, AlertDialogTitle as D, Button as O, Card as k, CardContent as A, CardDescription as j, CardHeader as M, CardTitle as N, Dialog as P, DialogDescription as F, DialogHeader as I, DialogTitle as L, MobileDialogContent as R, ResizableHandle as z, ResizablePanel as B, ResizablePanelGroup as V, Sheet as ee, SheetContent as te, SheetDescription as H, SheetHeader as U, SheetTitle as ne, Skeleton as W, Tabs as re, TabsContent as ie, TabsList as ae, TabsTrigger as oe, cn as G, toast as se, useIsMobile as ce } from "@object-ui/components";
6
- import { usePermissions as le } from "@object-ui/permissions";
7
- import { Check as K, CheckCircle2 as q, ChevronDown as ue, ChevronLeft as de, ChevronRight as J, Loader2 as fe, Lock as pe, ShieldCheck as me } from "lucide-react";
8
- import { Fragment as Y, jsx as X, jsxs as Z } from "react/jsx-runtime";
9
- import { createSafeTranslation as Q } from "@object-ui/i18n";
4
+ import { LineItemsField as h, buildValidationRules as g, formatFileSize as _, mapFieldTypeToFormType as v } from "@object-ui/fields";
5
+ import { AlertDialog as y, AlertDialogAction as b, AlertDialogCancel as x, AlertDialogContent as S, AlertDialogDescription as C, AlertDialogFooter as w, AlertDialogHeader as T, AlertDialogTitle as E, Button as D, Card as O, CardContent as k, CardDescription as A, CardHeader as j, CardTitle as M, Dialog as N, DialogDescription as P, DialogHeader as F, DialogTitle as ee, MobileDialogContent as I, ResizableHandle as L, ResizablePanel as R, ResizablePanelGroup as z, Sheet as B, SheetContent as V, SheetDescription as H, SheetHeader as te, SheetTitle as ne, Skeleton as U, Tabs as W, TabsContent as re, TabsList as ie, TabsTrigger as ae, cn as G, toast as K, useIsMobile as oe } from "@object-ui/components";
6
+ import { usePermissions as se } from "@object-ui/permissions";
7
+ import { Check as ce, CheckCircle2 as le, ChevronDown as q, ChevronLeft as ue, ChevronRight as de, Loader2 as fe, Lock as pe, ShieldCheck as me } from "lucide-react";
8
+ import { Fragment as J, jsx as Y, jsxs as X } from "react/jsx-runtime";
9
+ import { createSafeTranslation as Z } from "@object-ui/i18n";
10
+ import { deriveFieldGroupLayout as he } from "@objectstack/spec/data";
10
11
  //#region src/successBehavior.ts
11
- function he(e) {
12
+ function ge(e) {
12
13
  try {
13
14
  return typeof window > "u" ? !1 : new URL(e, window.location.href).origin === window.location.origin;
14
15
  } catch {
15
16
  return !1;
16
17
  }
17
18
  }
18
- function ge(e, t) {
19
+ function _e(e, t) {
19
20
  if (!e) return null;
20
21
  let n = t?.id ?? t?.recordId ?? t?._id;
21
22
  if (n == null || n === "") return null;
22
23
  let r = e.replace(/\{(?:id|recordId)\}/g, String(n));
23
- return he(r) ? r : null;
24
+ return ge(r) ? r : null;
24
25
  }
25
26
  //#endregion
26
27
  //#region src/FormSection.tsx
27
- var _e = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: a, className: o, gridClassName: c, showBorder: l }) => {
28
+ var ve = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: a, className: o, gridClassName: c, showBorder: l }) => {
28
29
  let [u, d] = s(r), f = {
29
30
  1: "grid-cols-1",
30
31
  2: "grid-cols-1 md:grid-cols-2",
@@ -32,59 +33,59 @@ var _e = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, co
32
33
  4: "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
33
34
  }, p = () => {
34
35
  n && d(!u);
35
- }, m = l ?? !!e, h = e || t ? /* @__PURE__ */ Z("div", {
36
+ }, m = l ?? !!e, h = e || t ? /* @__PURE__ */ X("div", {
36
37
  className: G("flex items-start gap-2", !m && "mb-4", n && "cursor-pointer select-none"),
37
38
  onClick: p,
38
39
  role: n ? "button" : void 0,
39
40
  "aria-expanded": n ? !u : void 0,
40
- children: [n && /* @__PURE__ */ X("span", {
41
+ children: [n && /* @__PURE__ */ Y("span", {
41
42
  className: "mt-0.5 text-muted-foreground",
42
- children: X(u ? J : ue, { className: "h-4 w-4" })
43
- }), /* @__PURE__ */ Z("div", {
43
+ children: Y(u ? de : q, { className: "h-4 w-4" })
44
+ }), /* @__PURE__ */ X("div", {
44
45
  className: "flex-1",
45
- children: [e && /* @__PURE__ */ X("h3", {
46
+ children: [e && /* @__PURE__ */ Y("h3", {
46
47
  className: "text-base font-semibold text-foreground",
47
48
  children: e
48
- }), t && /* @__PURE__ */ X("p", {
49
+ }), t && /* @__PURE__ */ Y("p", {
49
50
  className: "text-sm text-muted-foreground mt-0.5",
50
51
  children: t
51
52
  })]
52
53
  })]
53
- }) : null, g = u ? null : /* @__PURE__ */ X("div", {
54
+ }) : null, g = u ? null : /* @__PURE__ */ Y("div", {
54
55
  className: G("grid gap-4", c || f[i]),
55
56
  children: a
56
57
  });
57
- return m ? /* @__PURE__ */ Z(k, {
58
+ return m ? /* @__PURE__ */ X(O, {
58
59
  className: G("form-section", o),
59
- children: [h && /* @__PURE__ */ Z(M, {
60
+ children: [h && /* @__PURE__ */ X(j, {
60
61
  className: "pb-3",
61
62
  children: [
62
- e && /* @__PURE__ */ X(N, {
63
+ e && /* @__PURE__ */ Y(M, {
63
64
  className: "text-base",
64
65
  children: e
65
66
  }),
66
- t && /* @__PURE__ */ X(j, { children: t }),
67
- n && /* @__PURE__ */ X("button", {
67
+ t && /* @__PURE__ */ Y(A, { children: t }),
68
+ n && /* @__PURE__ */ Y("button", {
68
69
  type: "button",
69
70
  className: "absolute right-4 top-4 text-muted-foreground",
70
71
  onClick: p,
71
72
  "aria-expanded": !u,
72
73
  "aria-label": u ? "Expand section" : "Collapse section",
73
- children: X(u ? J : ue, { className: "h-4 w-4" })
74
+ children: Y(u ? de : q, { className: "h-4 w-4" })
74
75
  })
75
76
  ]
76
- }), g && /* @__PURE__ */ X(A, { children: g })]
77
- }) : /* @__PURE__ */ Z("div", {
77
+ }), g && /* @__PURE__ */ Y(k, { children: g })]
78
+ }) : /* @__PURE__ */ X("div", {
78
79
  className: G("form-section", o),
79
80
  children: [h, g]
80
81
  });
81
82
  };
82
83
  //#endregion
83
84
  //#region src/sectionFields.ts
84
- function ve(e, t) {
85
- return typeof t == "string" && t.trim() ? {
85
+ function Q(e, t) {
86
+ return typeof t == "string" && t.trim() || typeof t == "object" && t && typeof t.source == "string" && t.source.trim() ? {
86
87
  ...e,
87
- visible: (e) => _(t, e)
88
+ visibleOn: t
88
89
  } : e;
89
90
  }
90
91
  function ye(e, t) {
@@ -92,7 +93,7 @@ function ye(e, t) {
92
93
  return n ? {
93
94
  name: e,
94
95
  label: t.fieldLabel(t.objectName, e, n.label || e),
95
- type: y(n.type),
96
+ type: v(n.type),
96
97
  required: n.required || !1,
97
98
  disabled: t.readOnly || t.mode === "view" || n.readonly,
98
99
  placeholder: n.placeholder,
@@ -100,7 +101,11 @@ function ye(e, t) {
100
101
  validation: g(n),
101
102
  field: n,
102
103
  options: n.options,
103
- multiple: n.multiple
104
+ multiple: n.multiple,
105
+ visibleWhen: n.visibleWhen,
106
+ readonlyWhen: n.readonlyWhen,
107
+ requiredWhen: n.requiredWhen,
108
+ conditionalRequired: n.conditionalRequired
104
109
  } : {
105
110
  name: e,
106
111
  label: e,
@@ -110,19 +115,154 @@ function ye(e, t) {
110
115
  function be(e, t) {
111
116
  if (typeof e == "string") {
112
117
  let n = t.objectSchema?.fields?.[e];
113
- return ve(ye(e, t), n?.visible_on ?? n?.visibleOn);
118
+ return Q(ye(e, t), n?.visible_on ?? n?.visibleOn);
114
119
  }
115
120
  let n = e;
116
- if (typeof n.field != "string") return ve(n, n.visibleOn);
121
+ if (typeof n.field != "string") return Q(n, n.visibleOn);
117
122
  let r = n.field, i = ye(r, t);
118
- return n.type != null && (i.type = y(n.type)), n.widget != null && (i.widget = n.widget), n.label != null && (i.label = n.label), n.placeholder != null && (i.placeholder = n.placeholder), n.helpText != null && (i.description = n.helpText), n.required != null && (i.required = n.required), n.readonly != null && (i.disabled = n.readonly || i.disabled), n.immutable != null && (i.immutable = n.immutable), n.hidden != null && (i.hidden = n.hidden), n.colSpan != null && (i.colSpan = n.colSpan), n.options != null && (i.options = n.options), n.multiple != null && (i.multiple = n.multiple), n.reference != null && (i.reference = n.reference), n.maxLength != null && (i.maxLength = n.maxLength), n.minLength != null && (i.minLength = n.minLength), n.min != null && (i.min = n.min), n.max != null && (i.max = n.max), n.precision != null && (i.precision = n.precision), n.scale != null && (i.scale = n.scale), n.language != null && (i.language = n.language), Array.isArray(n.fields) && (i.fields = n.fields), ve(i, n.visibleOn);
123
+ return n.type != null && (i.type = v(n.type)), n.widget != null && (i.widget = n.widget), n.label != null && (i.label = n.label), n.placeholder != null && (i.placeholder = n.placeholder), n.helpText != null && (i.description = n.helpText), n.required != null && (i.required = n.required), n.readonly != null && (i.disabled = n.readonly || i.disabled), n.immutable != null && (i.immutable = n.immutable), n.hidden != null && (i.hidden = n.hidden), n.colSpan != null && (i.colSpan = n.colSpan), n.span != null && (i.span = n.span), n.options != null && (i.options = n.options), n.multiple != null && (i.multiple = n.multiple), n.reference != null && (i.reference = n.reference), n.maxLength != null && (i.maxLength = n.maxLength), n.minLength != null && (i.minLength = n.minLength), n.min != null && (i.min = n.min), n.max != null && (i.max = n.max), n.precision != null && (i.precision = n.precision), n.scale != null && (i.scale = n.scale), n.language != null && (i.language = n.language), Array.isArray(n.fields) && (i.fields = n.fields), Q(i, n.visibleOn);
119
124
  }
120
125
  function xe(e, t) {
121
126
  return (e.fields ?? []).map((e) => be(e, t));
122
127
  }
123
128
  //#endregion
129
+ //#region src/autoLayout.ts
130
+ var Se = /* @__PURE__ */ new Set([
131
+ "field:formula",
132
+ "field:summary",
133
+ "field:auto_number",
134
+ "field:autonumber"
135
+ ]), Ce = /* @__PURE__ */ new Set([
136
+ "field:textarea",
137
+ "field:markdown",
138
+ "field:html",
139
+ "field:grid",
140
+ "field:rich-text",
141
+ "textarea",
142
+ "markdown",
143
+ "html",
144
+ "grid",
145
+ "rich-text"
146
+ ]), we = /* @__PURE__ */ new Set([
147
+ "formula",
148
+ "summary",
149
+ "auto_number",
150
+ "autonumber"
151
+ ]);
152
+ function Te(e) {
153
+ return Ce.has(e);
154
+ }
155
+ function Ee(e) {
156
+ return we.has(e);
157
+ }
158
+ function De(e) {
159
+ return e <= 3 ? 1 : e <= 8 ? 2 : e <= 15 ? 3 : 4;
160
+ }
161
+ function Oe(e) {
162
+ return e && e > 0 ? Math.min(Math.floor(e), 4) : 1;
163
+ }
164
+ function ke(e, t, n) {
165
+ let r = Oe(t);
166
+ return r <= 1 ? 1 : e.span === "full" ? r : e.colSpan == null ? e.type && Te(e.type) ? r : Math.min(r, Math.max(1, Math.round(r / Math.min(Math.max(1, Math.floor(n || r)), r)))) : Math.min(Math.max(1, Math.floor(e.colSpan)), r);
167
+ }
168
+ function Ae(e, t, n) {
169
+ let r = Oe(t);
170
+ return r <= 1 ? e : e.map((e) => {
171
+ if (e.type === "section-divider") return e;
172
+ let t = ke(e, r, n);
173
+ return t > 1 ? {
174
+ ...e,
175
+ colSpan: t
176
+ } : e.colSpan != null && e.colSpan !== 1 ? {
177
+ ...e,
178
+ colSpan: 1
179
+ } : e;
180
+ });
181
+ }
182
+ var je = /* @__PURE__ */ new Set([
183
+ "id",
184
+ "created_at",
185
+ "createdAt",
186
+ "updated_at",
187
+ "updatedAt",
188
+ "last_modified_at",
189
+ "lastModifiedAt",
190
+ "deleted_at",
191
+ "deletedAt",
192
+ "created_by",
193
+ "createdBy",
194
+ "updated_by",
195
+ "updatedBy",
196
+ "last_modified_by",
197
+ "lastModifiedBy",
198
+ "organization_id",
199
+ "organizationId",
200
+ "org_id",
201
+ "orgId",
202
+ "tenant_id",
203
+ "tenantId",
204
+ "owner",
205
+ "owner_id",
206
+ "_version",
207
+ "_rev"
208
+ ]);
209
+ function Me(e, t) {
210
+ return e.filter((e) => {
211
+ if (je.has(e.name)) return !1;
212
+ let n = t?.fields?.[e.name];
213
+ return !(n?.hidden === !0 || n?.readonly === !0);
214
+ });
215
+ }
216
+ function Ne(e, t) {
217
+ return e.filter((e) => {
218
+ if (je.has(e.name) || e.type && Se.has(e.type)) return !1;
219
+ if (!t?.fields) return !0;
220
+ let n = t.fields[e.name];
221
+ return n ? n.readonly === !0 ? !1 : !Ee(n.type) : !0;
222
+ });
223
+ }
224
+ function Pe(e, t) {
225
+ return e.filter((e) => {
226
+ if (e.type && Se.has(e.type)) return !1;
227
+ let n = t?.fields?.[e.name];
228
+ return n ? !Ee(n.type) : !0;
229
+ });
230
+ }
231
+ var Fe = {
232
+ 1: void 0,
233
+ 2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
234
+ 3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
235
+ 4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
236
+ };
237
+ function Ie(e) {
238
+ return Fe[e && e > 0 ? Math.min(Math.floor(e), 4) : 1];
239
+ }
240
+ function Le(e, t) {
241
+ let n = t && t > 1 ? Math.min(Math.floor(t), 4) : 1, r = n > 1 ? Ae(e, n) : e, i = Ie(n);
242
+ return {
243
+ fields: r,
244
+ columns: n,
245
+ ...i ? { fieldContainerClass: i } : {}
246
+ };
247
+ }
248
+ function Re(e) {
249
+ return e <= 1 ? "default" : e === 2 ? "xl" : "full";
250
+ }
251
+ function ze(e, t, n, r) {
252
+ let i = [...e];
253
+ if (i = Me(i, t), r === "create" && (i = Pe(i, t)), n !== void 0) return i = Ae(i, n), {
254
+ fields: i,
255
+ columns: n
256
+ };
257
+ let a = De(i.length);
258
+ return i = Ae(i, a), {
259
+ fields: i,
260
+ columns: a
261
+ };
262
+ }
263
+ //#endregion
124
264
  //#region src/TabbedForm.tsx
125
- var Se = ({ schema: n, dataSource: r, className: i }) => {
265
+ var Be = ({ schema: n, dataSource: r, className: i }) => {
126
266
  let { fieldLabel: a } = p(), [o, c] = s(null), [u, d] = s({}), [f, m] = s(!0), [h, g] = s(null), [_, v] = s(n.defaultTab || n.sections[0]?.name || n.sections[0]?.label || "tab-0");
127
267
  e.useEffect(() => {
128
268
  (async () => {
@@ -182,19 +322,19 @@ var Se = ({ schema: n, dataSource: r, className: i }) => {
182
322
  }, [n, r]), x = t(() => {
183
323
  n.onCancel && n.onCancel();
184
324
  }, [n]), S = (e, t) => e.name || e.label || `tab-${t}`;
185
- if (h) return /* @__PURE__ */ Z("div", {
325
+ if (h) return /* @__PURE__ */ X("div", {
186
326
  className: "p-4 border border-red-300 bg-red-50 rounded-md",
187
- children: [/* @__PURE__ */ X("h3", {
327
+ children: [/* @__PURE__ */ Y("h3", {
188
328
  className: "text-red-800 font-semibold",
189
329
  children: "Error loading form"
190
- }), /* @__PURE__ */ X("p", {
330
+ }), /* @__PURE__ */ Y("p", {
191
331
  className: "text-red-600 text-sm mt-1",
192
332
  children: h.message
193
333
  })]
194
334
  });
195
- if (f) return /* @__PURE__ */ Z("div", {
335
+ if (f) return /* @__PURE__ */ X("div", {
196
336
  className: "p-8 text-center",
197
- children: [/* @__PURE__ */ X("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ X("p", {
337
+ children: [/* @__PURE__ */ Y("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Y("p", {
198
338
  className: "mt-2 text-sm text-gray-600",
199
339
  children: "Loading form..."
200
340
  })]
@@ -211,31 +351,31 @@ var Se = ({ schema: n, dataSource: r, className: i }) => {
211
351
  onSubmit: b,
212
352
  onCancel: x
213
353
  }, w = n.tabPosition === "left" || n.tabPosition === "right";
214
- return /* @__PURE__ */ X("div", {
354
+ return /* @__PURE__ */ Y("div", {
215
355
  className: G("w-full", i, n.className),
216
- children: /* @__PURE__ */ Z(re, {
356
+ children: /* @__PURE__ */ X(W, {
217
357
  value: _,
218
358
  onValueChange: v,
219
359
  orientation: w ? "vertical" : "horizontal",
220
360
  className: G(w && "flex gap-4"),
221
- children: [/* @__PURE__ */ X(ae, {
361
+ children: [/* @__PURE__ */ Y(ie, {
222
362
  className: G(w ? "flex-col h-auto" : "", n.tabPosition === "bottom" && "order-last", n.tabPosition === "right" && "order-last"),
223
- children: n.sections.map((e, t) => /* @__PURE__ */ X(oe, {
363
+ children: n.sections.map((e, t) => /* @__PURE__ */ Y(ae, {
224
364
  value: S(e, t),
225
365
  className: w ? "w-full justify-start" : "",
226
366
  children: e.label || `Tab ${t + 1}`
227
367
  }, S(e, t)))
228
- }), /* @__PURE__ */ X("div", {
368
+ }), /* @__PURE__ */ Y("div", {
229
369
  className: "flex-1",
230
- children: n.sections.map((e, t) => /* @__PURE__ */ X(ie, {
370
+ children: n.sections.map((e, t) => /* @__PURE__ */ Y(re, {
231
371
  value: S(e, t),
232
372
  className: "mt-0",
233
- children: /* @__PURE__ */ X(_e, {
373
+ children: /* @__PURE__ */ Y(ve, {
234
374
  description: e.description,
235
- columns: e.columns || 1,
236
- children: /* @__PURE__ */ X(l, { schema: {
375
+ columns: 1,
376
+ children: /* @__PURE__ */ Y(l, { schema: {
237
377
  ...C,
238
- fields: y(e),
378
+ ...Le(y(e), e.columns || 1),
239
379
  showSubmit: n.showSubmit !== !1 && n.mode !== "view",
240
380
  showCancel: n.showCancel !== !1
241
381
  } })
@@ -244,8 +384,8 @@ var Se = ({ schema: n, dataSource: r, className: i }) => {
244
384
  })]
245
385
  })
246
386
  });
247
- }, Ce = ({ schema: n, dataSource: r, className: i }) => {
248
- let { fieldLabel: o } = p(), [c, u] = s(null), [d, f] = s({}), [m, h] = s(!0), [g, _] = s(null), [v, y] = s(0), [b, x] = s(/* @__PURE__ */ new Set()), [S, C] = s(!1), w = e.useId(), [T, E] = s(0), D = e.useRef(!1), k = n.sections.length, A = v === 0, j = v === k - 1;
387
+ }, Ve = ({ schema: n, dataSource: r, className: i }) => {
388
+ let { fieldLabel: o } = p(), [c, u] = s(null), [d, f] = s({}), [m, h] = s(!0), [g, _] = s(null), [v, y] = s(0), [b, x] = s(/* @__PURE__ */ new Set()), [S, C] = s(!1), [w, T] = s(null), E = e.useId(), [O, k] = s(0), A = e.useRef(!1), j = n.sections.length, M = v === 0, N = v === j - 1;
249
389
  e.useEffect(() => {
250
390
  (async () => {
251
391
  if (!r) {
@@ -261,7 +401,7 @@ var Se = ({ schema: n, dataSource: r, className: i }) => {
261
401
  }, [n.objectName, r]), e.useEffect(() => {
262
402
  (c || !r) && (async () => {
263
403
  if (n.mode === "create" || !n.recordId || !r) {
264
- D.current ||= (f(n.initialData || n.initialValues || {}), !0), h(!1);
404
+ A.current ||= (f(n.initialData || n.initialValues || {}), !0), h(!1);
265
405
  return;
266
406
  }
267
407
  try {
@@ -281,7 +421,7 @@ var Se = ({ schema: n, dataSource: r, className: i }) => {
281
421
  r,
282
422
  n.objectName
283
423
  ]);
284
- let M = t((e) => xe(e, {
424
+ let P = t((e) => xe(e, {
285
425
  objectSchema: c,
286
426
  objectName: n.objectName,
287
427
  readOnly: n.readOnly,
@@ -293,26 +433,44 @@ var Se = ({ schema: n, dataSource: r, className: i }) => {
293
433
  n.mode,
294
434
  n.objectName,
295
435
  o
296
- ]), N = a(() => v >= 0 && v < k ? M(n.sections[v]) : [], [
436
+ ]), F = a(() => v >= 0 && v < j ? P(n.sections[v]) : [], [
297
437
  v,
298
- k,
438
+ j,
299
439
  n.sections,
300
- M
301
- ]), P = t(async (e) => {
440
+ P
441
+ ]), ee = t(async (e) => {
302
442
  let t = {
303
443
  ...d,
304
444
  ...e
305
445
  };
306
- if (f(t), x((e) => new Set(e).add(v)), j) {
446
+ if (f(t), x((e) => new Set(e).add(v)), N) {
307
447
  C(!0);
308
448
  try {
309
449
  if (!r) return n.onSuccess && await n.onSuccess(t), t;
310
450
  let e;
311
451
  if (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);
312
- else {
313
- let t = ge(n.navigateOnSuccess, e);
452
+ else if (n.submitBehavior) {
453
+ let e = n.submitBehavior;
454
+ switch (e.kind) {
455
+ case "redirect":
456
+ ge(e.url) && setTimeout(() => window.location.assign(e.url), e.delayMs ?? 0);
457
+ break;
458
+ case "continue":
459
+ f({}), x(/* @__PURE__ */ new Set()), y(0), k((e) => e + 1);
460
+ break;
461
+ default: {
462
+ let t = e.kind === "thank-you" && e.message ? e.message : n.successMessage || (n.mode === "create" ? "Created" : "Saved");
463
+ K.success(t), T({
464
+ title: e.kind === "thank-you" ? e.title : void 0,
465
+ message: t
466
+ });
467
+ break;
468
+ }
469
+ }
470
+ } else {
471
+ let t = _e(n.navigateOnSuccess, e);
314
472
  if (t) return window.location.assign(t), e;
315
- se.success(n.successMessage || (n.mode === "create" ? "Created" : "Saved")), n.resetOnSuccess && n.mode === "create" && (f({}), x(/* @__PURE__ */ new Set()), y(0), E((e) => e + 1));
473
+ K.success(n.successMessage || (n.mode === "create" ? "Created" : "Saved")), n.resetOnSuccess && n.mode === "create" && (f({}), x(/* @__PURE__ */ new Set()), y(0), k((e) => e + 1));
316
474
  }
317
475
  return e;
318
476
  } catch (e) {
@@ -320,72 +478,85 @@ var Se = ({ schema: n, dataSource: r, className: i }) => {
320
478
  } finally {
321
479
  C(!1);
322
480
  }
323
- } else F(v + 1);
481
+ } else I(v + 1);
324
482
  }, [
325
483
  d,
326
484
  v,
327
- j,
485
+ N,
328
486
  n,
329
487
  r
330
- ]), F = t((e) => {
331
- e >= 0 && e < k && (y(e), n.onStepChange && n.onStepChange(e));
332
- }, [k, n]), I = t(() => {
333
- F(v - 1);
334
- }, [v, F]), L = t(() => {
488
+ ]), I = t((e) => {
489
+ e >= 0 && e < j && (y(e), n.onStepChange && n.onStepChange(e));
490
+ }, [j, n]), L = t(() => {
491
+ I(v - 1);
492
+ }, [v, I]), R = t(() => {
335
493
  n.onCancel && n.onCancel();
336
- }, [n]), R = t((e) => {
337
- (n.allowSkip || b.has(e) || e <= v) && F(e);
494
+ }, [n]), z = t((e) => {
495
+ (n.allowSkip || b.has(e) || e <= v) && I(e);
338
496
  }, [
339
497
  n.allowSkip,
340
498
  b,
341
499
  v,
342
- F
500
+ I
343
501
  ]);
344
- if (g) return /* @__PURE__ */ Z("div", {
502
+ if (g) return /* @__PURE__ */ X("div", {
345
503
  className: "p-4 border border-red-300 bg-red-50 rounded-md",
346
- children: [/* @__PURE__ */ X("h3", {
504
+ children: [/* @__PURE__ */ Y("h3", {
347
505
  className: "text-red-800 font-semibold",
348
506
  children: "Error loading form"
349
- }), /* @__PURE__ */ X("p", {
507
+ }), /* @__PURE__ */ Y("p", {
350
508
  className: "text-red-600 text-sm mt-1",
351
509
  children: g.message
352
510
  })]
353
511
  });
354
- if (m) return /* @__PURE__ */ Z("div", {
512
+ if (m) return /* @__PURE__ */ X("div", {
355
513
  className: "p-8 text-center",
356
- children: [/* @__PURE__ */ X("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ X("p", {
514
+ children: [/* @__PURE__ */ Y("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Y("p", {
357
515
  className: "mt-2 text-sm text-gray-600",
358
516
  children: "Loading form..."
359
517
  })]
360
518
  });
361
- let z = n.sections[v];
362
- return /* @__PURE__ */ Z("div", {
519
+ if (w) return /* @__PURE__ */ Y("div", {
520
+ className: G("w-full", i, n.className),
521
+ children: /* @__PURE__ */ X("div", {
522
+ className: "rounded-md border bg-card p-8 text-center",
523
+ children: [/* @__PURE__ */ Y("h3", {
524
+ className: "text-lg font-semibold",
525
+ children: w.title ?? "Thanks!"
526
+ }), w.message && /* @__PURE__ */ Y("p", {
527
+ className: "mt-2 text-sm text-muted-foreground",
528
+ children: w.message
529
+ })]
530
+ })
531
+ });
532
+ let B = n.sections[v];
533
+ return /* @__PURE__ */ X("div", {
363
534
  className: G("w-full", i, n.className),
364
535
  children: [
365
- n.showStepIndicator !== !1 && /* @__PURE__ */ X("nav", {
536
+ n.showStepIndicator !== !1 && /* @__PURE__ */ Y("nav", {
366
537
  "aria-label": "Progress",
367
538
  className: "mb-8",
368
- children: /* @__PURE__ */ X("ol", {
539
+ children: /* @__PURE__ */ Y("ol", {
369
540
  className: "flex items-center",
370
541
  children: n.sections.map((e, t) => {
371
542
  let r = t === v, i = b.has(t), a = n.allowSkip || i || t <= v;
372
- return /* @__PURE__ */ Z("li", {
373
- className: G("relative flex-1", t !== k - 1 && "pr-8 sm:pr-12"),
374
- children: [t !== k - 1 && /* @__PURE__ */ X("div", {
543
+ return /* @__PURE__ */ X("li", {
544
+ className: G("relative flex-1", t !== j - 1 && "pr-8 sm:pr-12"),
545
+ children: [t !== j - 1 && /* @__PURE__ */ Y("div", {
375
546
  className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
376
547
  "aria-hidden": "true",
377
- children: /* @__PURE__ */ X("div", { className: G("h-full", i ? "bg-primary" : "bg-muted") })
378
- }), /* @__PURE__ */ Z("button", {
548
+ children: /* @__PURE__ */ Y("div", { className: G("h-full", i ? "bg-primary" : "bg-muted") })
549
+ }), /* @__PURE__ */ X("button", {
379
550
  type: "button",
380
551
  className: G("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
381
- onClick: () => R(t),
552
+ onClick: () => z(t),
382
553
  disabled: !a,
383
- children: [/* @__PURE__ */ X("span", {
554
+ children: [/* @__PURE__ */ Y("span", {
384
555
  className: G("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"),
385
- children: i ? /* @__PURE__ */ X(K, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : t + 1
386
- }), /* @__PURE__ */ X("span", {
556
+ children: i ? /* @__PURE__ */ Y(ce, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : t + 1
557
+ }), /* @__PURE__ */ Y("span", {
387
558
  className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block",
388
- children: /* @__PURE__ */ X("span", {
559
+ children: /* @__PURE__ */ Y("span", {
389
560
  className: G(r ? "text-foreground" : "text-muted-foreground"),
390
561
  children: e.label || `Step ${t + 1}`
391
562
  })
@@ -395,70 +566,70 @@ var Se = ({ schema: n, dataSource: r, className: i }) => {
395
566
  })
396
567
  })
397
568
  }),
398
- /* @__PURE__ */ X("div", {
569
+ /* @__PURE__ */ Y("div", {
399
570
  className: "min-h-[200px]",
400
- children: z && /* @__PURE__ */ X(_e, {
401
- label: z.label,
402
- description: z.description,
403
- columns: z.columns || 1,
404
- children: N.length > 0 ? /* @__PURE__ */ X(l, { schema: {
571
+ children: B && /* @__PURE__ */ Y(ve, {
572
+ label: B.label,
573
+ description: B.description,
574
+ columns: 1,
575
+ children: F.length > 0 ? /* @__PURE__ */ Y(l, { schema: {
405
576
  type: "form",
406
577
  objectName: n.objectName,
407
- id: w,
408
- fields: N,
578
+ id: E,
579
+ ...Le(F, B.columns || 1),
409
580
  layout: "vertical",
410
581
  defaultValues: d,
411
582
  showSubmit: !1,
412
583
  showCancel: !1,
413
- onSubmit: P
414
- } }, T) : /* @__PURE__ */ X("div", {
584
+ onSubmit: ee
585
+ } }, O) : /* @__PURE__ */ Y("div", {
415
586
  className: "text-center py-8 text-muted-foreground",
416
587
  children: "No fields configured for this step"
417
588
  })
418
589
  })
419
590
  }),
420
- /* @__PURE__ */ Z("div", {
591
+ /* @__PURE__ */ X("div", {
421
592
  className: "flex items-center justify-between mt-6 pt-4 border-t",
422
- children: [/* @__PURE__ */ X("div", { children: n.showCancel !== !1 && /* @__PURE__ */ X(O, {
593
+ children: [/* @__PURE__ */ Y("div", { children: n.showCancel !== !1 && /* @__PURE__ */ Y(D, {
423
594
  variant: "ghost",
424
- onClick: L,
595
+ onClick: R,
425
596
  children: n.cancelText || "Cancel"
426
- }) }), /* @__PURE__ */ Z("div", {
597
+ }) }), /* @__PURE__ */ X("div", {
427
598
  className: "flex items-center gap-2",
428
599
  children: [
429
- /* @__PURE__ */ Z("span", {
600
+ /* @__PURE__ */ X("span", {
430
601
  className: "text-sm text-muted-foreground mr-2",
431
602
  children: [
432
603
  "Step ",
433
604
  v + 1,
434
605
  " of ",
435
- k
606
+ j
436
607
  ]
437
608
  }),
438
- !A && /* @__PURE__ */ Z(O, {
609
+ !M && /* @__PURE__ */ X(D, {
439
610
  variant: "outline",
440
- onClick: I,
441
- children: [/* @__PURE__ */ X(de, { className: "h-4 w-4 mr-1" }), n.prevText || "Back"]
611
+ onClick: L,
612
+ children: [/* @__PURE__ */ Y(ue, { className: "h-4 w-4 mr-1" }), n.prevText || "Back"]
442
613
  }),
443
- j ? /* @__PURE__ */ Z(O, {
614
+ N ? /* @__PURE__ */ X(D, {
444
615
  type: "submit",
445
- form: w,
616
+ form: E,
446
617
  disabled: S || n.mode === "view",
447
- children: [S && /* @__PURE__ */ X(fe, {
618
+ children: [S && /* @__PURE__ */ Y(fe, {
448
619
  className: "mr-2 h-4 w-4 animate-spin",
449
620
  "aria-hidden": !0
450
621
  }), S ? "Submitting..." : n.submitText || (n.mode === "create" ? "Create" : "Update")]
451
- }) : /* @__PURE__ */ Z(O, {
622
+ }) : /* @__PURE__ */ X(D, {
452
623
  type: "submit",
453
- form: w,
454
- children: [n.nextText || "Next", /* @__PURE__ */ X(J, { className: "h-4 w-4 ml-1" })]
624
+ form: E,
625
+ children: [n.nextText || "Next", /* @__PURE__ */ Y(de, { className: "h-4 w-4 ml-1" })]
455
626
  })
456
627
  ]
457
628
  })]
458
629
  })
459
630
  ]
460
631
  });
461
- }, we = ({ schema: e, dataSource: n, className: i }) => {
632
+ }, He = ({ schema: e, dataSource: n, className: i }) => {
462
633
  let { fieldLabel: o } = p(), [c, u] = s(null), [d, f] = s({}), [m, h] = s(!0), [g, _] = s(null);
463
634
  r(() => {
464
635
  (async () => {
@@ -524,19 +695,19 @@ var Se = ({ schema: n, dataSource: r, className: i }) => {
524
695
  }, [e]), x = a(() => e.sections.slice(0, 1), [e.sections]), S = a(() => e.sections.slice(1), [e.sections]);
525
696
  a(() => e.sections.flatMap((e) => v(e)), [e.sections, v]);
526
697
  let C = e.splitDirection || "horizontal", w = e.splitSize || 50;
527
- if (g) return /* @__PURE__ */ Z("div", {
698
+ if (g) return /* @__PURE__ */ X("div", {
528
699
  className: "p-4 border border-red-300 bg-red-50 rounded-md",
529
- children: [/* @__PURE__ */ X("h3", {
700
+ children: [/* @__PURE__ */ Y("h3", {
530
701
  className: "text-red-800 font-semibold",
531
702
  children: "Error loading form"
532
- }), /* @__PURE__ */ X("p", {
703
+ }), /* @__PURE__ */ Y("p", {
533
704
  className: "text-red-600 text-sm mt-1",
534
705
  children: g.message
535
706
  })]
536
707
  });
537
- if (m) return /* @__PURE__ */ Z("div", {
708
+ if (m) return /* @__PURE__ */ X("div", {
538
709
  className: "p-8 text-center",
539
- children: [/* @__PURE__ */ X("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ X("p", {
710
+ children: [/* @__PURE__ */ Y("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Y("p", {
540
711
  className: "mt-2 text-sm text-gray-600",
541
712
  children: "Loading form..."
542
713
  })]
@@ -548,15 +719,15 @@ var Se = ({ schema: n, dataSource: r, className: i }) => {
548
719
  defaultValues: d,
549
720
  onSubmit: y,
550
721
  onCancel: b
551
- }, E = (t, n) => /* @__PURE__ */ X("div", {
722
+ }, E = (t, n) => /* @__PURE__ */ Y("div", {
552
723
  className: "space-y-4 p-4",
553
- children: t.map((t, r) => /* @__PURE__ */ X(_e, {
724
+ children: t.map((t, r) => /* @__PURE__ */ Y(ve, {
554
725
  label: t.label,
555
726
  description: t.description,
556
- columns: t.columns || 1,
557
- children: /* @__PURE__ */ X(l, { schema: {
727
+ columns: 1,
728
+ children: /* @__PURE__ */ Y(l, { schema: {
558
729
  ...T,
559
- fields: v(t),
730
+ ...Le(v(t), t.columns || 1),
560
731
  showSubmit: n && e.showSubmit !== !1 && e.mode !== "view",
561
732
  showCancel: n && e.showCancel !== !1,
562
733
  submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
@@ -564,47 +735,81 @@ var Se = ({ schema: n, dataSource: r, className: i }) => {
564
735
  } })
565
736
  }, t.name || t.label || r))
566
737
  });
567
- return /* @__PURE__ */ X("div", {
738
+ return /* @__PURE__ */ Y("div", {
568
739
  className: G("w-full", i, e.className),
569
- children: /* @__PURE__ */ Z(V, {
740
+ children: /* @__PURE__ */ X(z, {
570
741
  orientation: C,
571
742
  className: "min-h-[300px] rounded-lg border",
572
- children: [/* @__PURE__ */ X(B, {
743
+ children: [/* @__PURE__ */ Y(R, {
573
744
  defaultSize: w,
574
745
  minSize: 20,
575
746
  children: E(x, S.length === 0)
576
- }), S.length > 0 && /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X(z, { withHandle: e.splitResizable !== !1 }), /* @__PURE__ */ X(B, {
747
+ }), S.length > 0 && /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(L, { withHandle: e.splitResizable !== !1 }), /* @__PURE__ */ Y(R, {
577
748
  defaultSize: 100 - w,
578
749
  minSize: 20,
579
750
  children: E(S, !0)
580
751
  })] })]
581
752
  })
582
753
  });
583
- }, $ = (e) => e == null ? void 0 : e.id ?? e._id ?? e.recordId, Te = /* @__PURE__ */ new Set([
754
+ }, Ue = /* @__PURE__ */ new Set([
755
+ "id",
756
+ "_id",
757
+ "created_at",
758
+ "updated_at",
759
+ "createdAt",
760
+ "updatedAt",
761
+ "organization_id",
762
+ "organizationId"
763
+ ]), We = /* @__PURE__ */ new Set([
764
+ "formula",
765
+ "summary",
766
+ "rollup",
767
+ "lookup_value",
768
+ "auto_number",
769
+ "autonumber",
770
+ "computed"
771
+ ]);
772
+ function Ge(e, t) {
773
+ if (!e || typeof e != "object") return e;
774
+ let n = {}, r = t?.fields;
775
+ for (let [t, i] of Object.entries(e)) if (!Ue.has(t)) {
776
+ if (r) {
777
+ let e = r[t];
778
+ if (!e) continue;
779
+ let n = String(e.type || "").toLowerCase();
780
+ if (We.has(n) || e.computed === !0 || e.formula || e.readOnly === !0 || e.readonly === !0) continue;
781
+ }
782
+ n[t] = i;
783
+ }
784
+ return n;
785
+ }
786
+ //#endregion
787
+ //#region src/masterDetailTx.ts
788
+ var $ = (e) => e == null ? void 0 : e.id ?? e._id ?? e.recordId, Ke = (e, t) => t ? Ge(e, t) : e, qe = /* @__PURE__ */ new Set([
584
789
  "id",
585
790
  "_id",
586
791
  "recordId"
587
792
  ]);
588
- function Ee(e, t) {
589
- return e ? Object.entries(e).every(([e, n]) => e === t || Te.has(e) ? !0 : n == null || n === "") : !0;
793
+ function Je(e, t) {
794
+ return e ? Object.entries(e).every(([e, n]) => e === t || qe.has(e) ? !0 : n == null || n === "") : !0;
590
795
  }
591
- function De(e, t, n) {
796
+ function Ye(e, t, n) {
592
797
  let r = [{
593
798
  object: e,
594
799
  action: "create",
595
800
  data: t
596
801
  }];
597
- for (let e of n) for (let t of e.rows) Ee(t, e.relationshipField) || r.push({
802
+ for (let e of n) for (let t of e.rows) Je(t, e.relationshipField) || r.push({
598
803
  object: e.childObject,
599
804
  action: "create",
600
805
  data: {
601
- ...t,
806
+ ...Ke(t, e.childSchema),
602
807
  [e.relationshipField]: { $ref: 0 }
603
808
  }
604
809
  });
605
810
  return r;
606
811
  }
607
- function Oe(e, t, n, r) {
812
+ function Xe(e, t, n, r) {
608
813
  let i = [{
609
814
  object: e,
610
815
  action: "update",
@@ -615,21 +820,21 @@ function Oe(e, t, n, r) {
615
820
  let n = (e.rows || []).map((n) => ({
616
821
  ...n,
617
822
  [e.relationshipField]: t
618
- })), { toCreate: r, toUpdate: a, toDelete: o } = ke(e.original || [], n);
823
+ })), { toCreate: r, toUpdate: a, toDelete: o } = Ze(e.original || [], n);
619
824
  for (let t of r) {
620
- if (Ee(t, e.relationshipField)) continue;
825
+ if (Je(t, e.relationshipField)) continue;
621
826
  let { id: n, _id: r, recordId: a, ...o } = t;
622
827
  i.push({
623
828
  object: e.childObject,
624
829
  action: "create",
625
- data: o
830
+ data: Ke(o, e.childSchema)
626
831
  });
627
832
  }
628
833
  for (let t of a) i.push({
629
834
  object: e.childObject,
630
835
  action: "update",
631
836
  id: $(t),
632
- data: t
837
+ data: Ke(t, e.childSchema)
633
838
  });
634
839
  for (let t of o) i.push({
635
840
  object: e.childObject,
@@ -639,7 +844,7 @@ function Oe(e, t, n, r) {
639
844
  }
640
845
  return i;
641
846
  }
642
- function ke(e, t) {
847
+ function Ze(e, t) {
643
848
  let n = new Set(t.map($).filter(Boolean));
644
849
  return {
645
850
  toCreate: t.filter((e) => !$(e)),
@@ -647,25 +852,25 @@ function ke(e, t) {
647
852
  toDelete: (e || []).map($).filter((e) => !!e && !n.has(e))
648
853
  };
649
854
  }
650
- function Ae(e, t) {
855
+ function Qe(e, t) {
651
856
  return Array.isArray(e) ? e.reduce((e, n) => {
652
857
  let r = Number(n?.[t]);
653
858
  return e + (Number.isFinite(r) ? r : 0);
654
859
  }, 0) : 0;
655
860
  }
656
- function je(e) {
861
+ function $e(e) {
657
862
  return Array.isArray(e) ? e : e && Array.isArray(e.records) ? e.records : e && Array.isArray(e.data) ? e.data : e && (e.id || e._id) ? [e] : [];
658
863
  }
659
- async function Me(e, t, n) {
660
- return n.length === 0 ? [] : typeof e.bulk == "function" ? je(await e.bulk(t, "create", n)) : je(await Promise.all(n.map((n) => e.create(t, n))));
864
+ async function et(e, t, n) {
865
+ return n.length === 0 ? [] : typeof e.bulk == "function" ? $e(await e.bulk(t, "create", n)) : $e(await Promise.all(n.map((n) => e.create(t, n))));
661
866
  }
662
- async function Ne(e, t, n, r) {
663
- let i = [], a = r.rows.filter((e) => $(e) || !Ee(e, r.relationshipField)).map((e) => ({
867
+ async function tt(e, t, n, r) {
868
+ let i = [], a = r.rows.filter((e) => $(e) || !Je(e, r.relationshipField)).map((e) => ({
664
869
  ...e,
665
870
  [r.relationshipField]: n
666
871
  }));
667
872
  if (r.original !== void 0) {
668
- let { toCreate: t, toUpdate: n, toDelete: o } = ke(r.original, a), s = await Me(e, r.childObject, t);
873
+ let { toCreate: t, toUpdate: n, toDelete: o } = Ze(r.original, a), s = await et(e, r.childObject, t.map((e) => Ke(e, r.childSchema)));
669
874
  for (let e of s) {
670
875
  let t = $(e);
671
876
  t && i.push({
@@ -673,9 +878,9 @@ async function Ne(e, t, n, r) {
673
878
  id: t
674
879
  });
675
880
  }
676
- await Promise.all(n.map((t) => e.update(r.childObject, $(t), t))), await Promise.all(o.map((t) => e.delete(r.childObject, t)));
881
+ await Promise.all(n.map((t) => e.update(r.childObject, $(t), Ke(t, r.childSchema)))), await Promise.all(o.map((t) => e.delete(r.childObject, t)));
677
882
  } else {
678
- let t = await Me(e, r.childObject, a);
883
+ let t = await et(e, r.childObject, a.map((e) => Ke(e, r.childSchema)));
679
884
  for (let e of t) {
680
885
  let t = $(e);
681
886
  t && i.push({
@@ -685,14 +890,14 @@ async function Ne(e, t, n, r) {
685
890
  }
686
891
  }
687
892
  if (r.totalField) {
688
- let i = Ae(r.rows, r.amountField || "amount");
893
+ let i = Qe(r.rows, r.amountField || "amount");
689
894
  await e.update(t, n, { [r.totalField]: i });
690
895
  }
691
896
  return { created: i };
692
897
  }
693
898
  //#endregion
694
899
  //#region src/deriveMasterDetail.ts
695
- var Pe = /* @__PURE__ */ new Set([
900
+ var nt = /* @__PURE__ */ new Set([
696
901
  "id",
697
902
  "_id",
698
903
  "recordId",
@@ -708,14 +913,14 @@ var Pe = /* @__PURE__ */ new Set([
708
913
  "tenant_id",
709
914
  "space",
710
915
  "owner"
711
- ]), Fe = /* @__PURE__ */ new Set([
916
+ ]), rt = /* @__PURE__ */ new Set([
712
917
  "position",
713
918
  "sort_order",
714
919
  "sequence",
715
920
  "line_no",
716
921
  "line_number",
717
922
  "sort"
718
- ]), Ie = /* @__PURE__ */ new Set([
923
+ ]), it = /* @__PURE__ */ new Set([
719
924
  "formula",
720
925
  "summary",
721
926
  "rollup",
@@ -734,7 +939,7 @@ var Pe = /* @__PURE__ */ new Set([
734
939
  "markdown",
735
940
  "richtext"
736
941
  ]);
737
- function Le(e) {
942
+ function at(e) {
738
943
  switch (e) {
739
944
  case "number":
740
945
  case "percent":
@@ -754,7 +959,7 @@ function Le(e) {
754
959
  default: return "text";
755
960
  }
756
961
  }
757
- function Re(e) {
962
+ function ot(e) {
758
963
  if (e?.type === "boolean" || e?.type === "toggle") return [{
759
964
  label: "Yes",
760
965
  value: "true"
@@ -771,7 +976,7 @@ function Re(e) {
771
976
  value: String(e)
772
977
  });
773
978
  }
774
- function ze(e, t) {
979
+ function st(e, t) {
775
980
  let n = e?.fields;
776
981
  if (!n || typeof n != "object") return;
777
982
  let r;
@@ -784,7 +989,7 @@ function ze(e, t) {
784
989
  }
785
990
  return r;
786
991
  }
787
- var Be = [
992
+ var ct = [
788
993
  "name",
789
994
  "title",
790
995
  "subject",
@@ -792,7 +997,7 @@ var Be = [
792
997
  "full_name",
793
998
  "display_name",
794
999
  "code"
795
- ], Ve = {
1000
+ ], lt = {
796
1001
  select: 0,
797
1002
  currency: 1,
798
1003
  number: 1,
@@ -800,15 +1005,15 @@ var Be = [
800
1005
  date: 3,
801
1006
  text: 4
802
1007
  };
803
- function He(e, t) {
1008
+ function ut(e, t) {
804
1009
  if (t <= 0 || e.length <= t) return e;
805
- let n = /* @__PURE__ */ new Set(), r = e.find((e) => Be.includes(e.field)) ?? e[0];
1010
+ let n = /* @__PURE__ */ new Set(), r = e.find((e) => ct.includes(e.field)) ?? e[0];
806
1011
  r && n.add(r.field);
807
1012
  for (let t of e) t.required && n.add(t.field);
808
1013
  let i = e.map((e, t) => ({
809
1014
  c: e,
810
1015
  i: t
811
- })).filter(({ c: e }) => !n.has(e.field)).sort((e, t) => (Ve[e.c.type] ?? 5) - (Ve[t.c.type] ?? 5) || e.i - t.i);
1016
+ })).filter(({ c: e }) => !n.has(e.field)).sort((e, t) => (lt[e.c.type] ?? 5) - (lt[t.c.type] ?? 5) || e.i - t.i);
812
1017
  for (let { c: e } of i) {
813
1018
  if (n.size >= t) break;
814
1019
  n.add(e.field);
@@ -818,43 +1023,60 @@ function He(e, t) {
818
1023
  defaultHidden: !0
819
1024
  });
820
1025
  }
821
- function Ue(e, t = {}) {
1026
+ function dt(e, t = {}) {
822
1027
  let n = e?.fields;
823
1028
  if (!n || typeof n != "object") return [];
824
1029
  let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
825
1030
  for (let [e, t] of Object.entries(n)) {
826
1031
  let n = t;
827
- if (Pe.has(e) || r.has(e) || Fe.has(e) || n?.system || n?.readonly || n?.hidden || Ie.has(n?.type)) continue;
1032
+ if (nt.has(e) || r.has(e) || rt.has(e) || n?.system || n?.readonly || n?.hidden || it.has(n?.type)) continue;
828
1033
  let a = {
829
1034
  field: e,
830
1035
  label: n?.label || e,
831
- type: Le(n?.type),
1036
+ type: at(n?.type),
832
1037
  required: !!n?.required
833
- }, o = Re(n);
1038
+ }, o = ot(n);
834
1039
  a.type === "select" && o && (a.options = o), a.type === "lookup" && (a.reference = n?.reference, a.displayField = n?.display_field || n?.reference_field), n?.readonlyWhen && (a.readonlyWhen = n.readonlyWhen), (n?.requiredWhen ?? n?.conditionalRequired) && (a.requiredWhen = n.requiredWhen ?? n.conditionalRequired);
835
1040
  let s = typeof n?.expression == "string" ? n.expression : n?.expression?.source;
836
1041
  s && typeof s == "string" && (a.computed = !0, a.expr = s, a.required = !1, typeof n?.scale == "number" && (a.scale = n.scale)), i.push(a);
837
1042
  }
838
- return He(i, t.maxColumns ?? 6);
1043
+ return ut(i, t.maxColumns ?? 6);
1044
+ }
1045
+ function ft(e, t) {
1046
+ let n = e ?? [], r = t?.fields;
1047
+ return !n.length || !r || typeof r != "object" ? n : n.map((e) => {
1048
+ if (e.type) return e;
1049
+ let t = r[e.field];
1050
+ if (!t) return e;
1051
+ let n = at(t?.type), i = {
1052
+ ...e,
1053
+ type: n
1054
+ };
1055
+ i.label ??= t?.label || e.field, i.required ??= !!t?.required;
1056
+ let a = ot(t);
1057
+ n === "select" && a && !i.options && (i.options = a), n === "lookup" && (i.reference ??= t?.reference, i.displayField ??= t?.display_field || t?.reference_field), i.readonlyWhen == null && t?.readonlyWhen && (i.readonlyWhen = t.readonlyWhen), i.requiredWhen == null && (t?.requiredWhen ?? t?.conditionalRequired) && (i.requiredWhen = t.requiredWhen ?? t.conditionalRequired);
1058
+ let o = typeof t?.expression == "string" ? t.expression : t?.expression?.source;
1059
+ return !i.computed && o && typeof o == "string" && (i.computed = !0, i.expr = o, i.required = !1, typeof t?.scale == "number" && (i.scale = t.scale)), i;
1060
+ });
839
1061
  }
840
- var We = /* @__PURE__ */ new Set([
1062
+ var pt = /* @__PURE__ */ new Set([
841
1063
  "formula",
842
1064
  "summary",
843
1065
  "rollup",
844
1066
  "autonumber",
845
1067
  "auto_number"
846
1068
  ]);
847
- function Ge(e, t = {}) {
1069
+ function mt(e, t = {}) {
848
1070
  let n = e?.fields;
849
1071
  if (!n || typeof n != "object") return [];
850
1072
  let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
851
1073
  for (let [e, t] of Object.entries(n)) {
852
1074
  let n = t;
853
- Pe.has(e) || r.has(e) || Fe.has(e) || n?.system || n?.hidden || We.has(n?.type) || i.push(e);
1075
+ nt.has(e) || r.has(e) || rt.has(e) || n?.system || n?.hidden || pt.has(n?.type) || i.push(e);
854
1076
  }
855
1077
  return i;
856
1078
  }
857
- var Ke = /* @__PURE__ */ new Set([
1079
+ var ht = /* @__PURE__ */ new Set([
858
1080
  "textarea",
859
1081
  "richtext",
860
1082
  "html",
@@ -868,12 +1090,12 @@ var Ke = /* @__PURE__ */ new Set([
868
1090
  "location",
869
1091
  "address"
870
1092
  ]);
871
- function qe(e, t, n = {}) {
1093
+ function gt(e, t, n = {}) {
872
1094
  if (t === "grid" || t === "form") return t;
873
- let r = e?.fields ?? {}, i = Ge(e, { relationshipField: n.relationshipField });
874
- return i.some((e) => Ke.has(r[e]?.type)) || i.length > 8 ? "form" : "grid";
1095
+ let r = e?.fields ?? {}, i = mt(e, { relationshipField: n.relationshipField });
1096
+ return i.some((e) => ht.has(r[e]?.type)) || i.length > 8 ? "form" : "grid";
875
1097
  }
876
- var Je = [
1098
+ var _t = [
877
1099
  "amount",
878
1100
  "total",
879
1101
  "subtotal",
@@ -881,33 +1103,33 @@ var Je = [
881
1103
  "line_amount",
882
1104
  "net_amount"
883
1105
  ];
884
- function Ye(e) {
1106
+ function vt(e) {
885
1107
  let t = e.filter((e) => e.type === "number" || e.type === "currency");
886
1108
  if (t.length === 0) return;
887
1109
  let n = t.find((e) => e.computed);
888
1110
  if (n) return n.field;
889
- let r = t.find((e) => Je.includes(e.field));
1111
+ let r = t.find((e) => _t.includes(e.field));
890
1112
  if (r) return r.field;
891
1113
  let i = [...t].reverse().find((e) => e.type === "currency");
892
1114
  return i ? i.field : t[t.length - 1].field;
893
1115
  }
894
- function Xe(e, t, n, r = {}) {
895
- let i = r.relationshipField || ze(t, n);
1116
+ function yt(e, t, n, r = {}) {
1117
+ let i = r.relationshipField || st(t, n);
896
1118
  if (!i) throw Error(`MasterDetailForm: could not find a lookup/master_detail field on "${e}" referencing "${n}". Set relationshipField explicitly.`);
897
- let a = r.columns?.length ? r.columns : Ue(t, { relationshipField: i }), o = r.amountField || Ye(a);
1119
+ let a = r.columns?.length ? ft(r.columns, t) : dt(t, { relationshipField: i }), o = r.amountField || vt(a);
898
1120
  return {
899
1121
  childObject: e,
900
1122
  relationshipField: i,
901
1123
  columns: a,
902
- formFields: Ge(t, { relationshipField: i }),
903
- mode: qe(t, r.inlineEdit ?? (t?.fields)?.[i]?.inlineEdit, { relationshipField: i }),
1124
+ formFields: mt(t, { relationshipField: i }),
1125
+ mode: gt(t, r.inlineEdit ?? (t?.fields)?.[i]?.inlineEdit, { relationshipField: i }),
904
1126
  amountField: o,
905
- sortField: Object.keys(t?.fields ?? {}).find((e) => Fe.has(e))
1127
+ sortField: Object.keys(t?.fields ?? {}).find((e) => rt.has(e))
906
1128
  };
907
1129
  }
908
1130
  //#endregion
909
1131
  //#region src/MasterDetailForm.tsx
910
- function Ze(e) {
1132
+ function bt(e) {
911
1133
  if (!e) return {};
912
1134
  let t = {};
913
1135
  return e.querySelectorAll("[name]").forEach((e) => {
@@ -939,13 +1161,13 @@ function Ze(e) {
939
1161
  }
940
1162
  }), t;
941
1163
  }
942
- var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, formKey: c, onRowExpand: l, onAddViaForm: u }) => {
1164
+ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, formKey: c, onRowExpand: l, onAddViaForm: u }) => {
943
1165
  let [d, f] = s({}), p = o("");
944
1166
  r(() => {
945
1167
  let e = i.current;
946
1168
  if (!e) return;
947
1169
  let t = () => {
948
- let t = Ze(e), n;
1170
+ let t = bt(e), n;
949
1171
  try {
950
1172
  n = JSON.stringify(t);
951
1173
  } catch {
@@ -969,16 +1191,16 @@ var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
969
1191
  c,
970
1192
  e.length
971
1193
  ]);
972
- let m = d[a], g = m === void 0 ? null : Number.isFinite(Number(m)) ? Number(m) : 0, _ = e.reduce((e, n, r) => e + Ae(t[r]?.rows ?? [], n.amountField || "amount"), 0), v = g !== null && e.some((e) => !!e.amountField), y = g ?? 0, b = y / 100 * _, x = _ + b, S = (e) => `¥${e.toLocaleString(void 0, {
1194
+ let m = d[a], g = m === void 0 ? null : Number.isFinite(Number(m)) ? Number(m) : 0, _ = e.reduce((e, n, r) => e + Qe(t[r]?.rows ?? [], n.amountField || "amount"), 0), v = g !== null && e.some((e) => !!e.amountField), y = g ?? 0, b = y / 100 * _, x = _ + b, S = (e) => `¥${e.toLocaleString(void 0, {
973
1195
  minimumFractionDigits: 2,
974
1196
  maximumFractionDigits: 2
975
1197
  })}`;
976
- return /* @__PURE__ */ Z(Y, { children: [e.map((e, r) => /* @__PURE__ */ Z("section", {
1198
+ return /* @__PURE__ */ X(J, { children: [e.map((e, r) => /* @__PURE__ */ X("section", {
977
1199
  className: "space-y-2",
978
- children: [/* @__PURE__ */ X("h3", {
1200
+ children: [/* @__PURE__ */ Y("h3", {
979
1201
  className: "text-sm font-medium text-foreground",
980
1202
  children: e.title || "Line Items"
981
- }), e.columns?.length ? /* @__PURE__ */ X(h, {
1203
+ }), e.columns?.length ? /* @__PURE__ */ Y(h, {
982
1204
  value: t[r]?.rows ?? [],
983
1205
  onChange: (e) => n(r, e),
984
1206
  contextRecord: d,
@@ -993,45 +1215,45 @@ var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
993
1215
  max_rows: e.maxRows,
994
1216
  add_label: e.inlineMode === "form" ? e.addLabel || "Add" : e.addLabel
995
1217
  }
996
- }) : /* @__PURE__ */ X("p", {
1218
+ }) : /* @__PURE__ */ Y("p", {
997
1219
  className: "py-4 text-sm text-muted-foreground",
998
1220
  children: "Loading columns…"
999
1221
  })]
1000
- }, `${e.childObject}-${r}`)), v && /* @__PURE__ */ X("div", {
1222
+ }, `${e.childObject}-${r}`)), v && /* @__PURE__ */ Y("div", {
1001
1223
  className: "flex justify-end",
1002
- children: /* @__PURE__ */ Z("dl", {
1224
+ children: /* @__PURE__ */ X("dl", {
1003
1225
  className: "w-64 space-y-1.5 text-sm",
1004
1226
  "data-testid": "md-totals",
1005
1227
  children: [
1006
- /* @__PURE__ */ Z("div", {
1228
+ /* @__PURE__ */ X("div", {
1007
1229
  className: "flex items-center justify-between",
1008
- children: [/* @__PURE__ */ X("dt", {
1230
+ children: [/* @__PURE__ */ Y("dt", {
1009
1231
  className: "text-muted-foreground",
1010
1232
  children: "Subtotal"
1011
- }), /* @__PURE__ */ X("dd", {
1233
+ }), /* @__PURE__ */ Y("dd", {
1012
1234
  className: "tabular-nums",
1013
1235
  "data-testid": "md-subtotal",
1014
1236
  children: S(_)
1015
1237
  })]
1016
1238
  }),
1017
- /* @__PURE__ */ Z("div", {
1239
+ /* @__PURE__ */ X("div", {
1018
1240
  className: "flex items-center justify-between",
1019
- children: [/* @__PURE__ */ Z("dt", {
1241
+ children: [/* @__PURE__ */ X("dt", {
1020
1242
  className: "text-muted-foreground",
1021
1243
  children: [
1022
1244
  "Tax (",
1023
1245
  y,
1024
1246
  "%)"
1025
1247
  ]
1026
- }), /* @__PURE__ */ X("dd", {
1248
+ }), /* @__PURE__ */ Y("dd", {
1027
1249
  className: "tabular-nums",
1028
1250
  "data-testid": "md-tax",
1029
1251
  children: S(b)
1030
1252
  })]
1031
1253
  }),
1032
- /* @__PURE__ */ Z("div", {
1254
+ /* @__PURE__ */ X("div", {
1033
1255
  className: "flex items-center justify-between border-t border-border pt-1.5 text-base font-semibold",
1034
- children: [/* @__PURE__ */ X("dt", { children: "Total" }), /* @__PURE__ */ X("dd", {
1256
+ children: [/* @__PURE__ */ Y("dt", { children: "Total" }), /* @__PURE__ */ Y("dd", {
1035
1257
  className: "tabular-nums",
1036
1258
  "data-testid": "md-grand-total",
1037
1259
  children: S(x)
@@ -1040,8 +1262,8 @@ var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1040
1262
  ]
1041
1263
  })
1042
1264
  })] });
1043
- }, $e = ({ schema: e, dataSource: n, className: i }) => {
1044
- let c = e.details || [], l = e.mode === "edit" && !!e.recordId, u = c.some((e) => !e.relationshipField || !e.columns?.length), [d, f] = s(u ? null : c), p = d ?? c;
1265
+ }, St = ({ schema: e, dataSource: n, className: i }) => {
1266
+ let c = e.details || [], l = e.mode === "edit" && !!e.recordId, u = c.some((e) => !e.relationshipField || !e.columns?.length || e.columns.some((e) => !e.type)), [d, f] = s(u ? null : c), p = d ?? c;
1045
1267
  r(() => {
1046
1268
  if (!u) {
1047
1269
  f(c);
@@ -1051,9 +1273,15 @@ var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1051
1273
  let t = !1;
1052
1274
  return (async () => {
1053
1275
  let r = await Promise.all(c.map(async (t) => {
1054
- if (t.relationshipField && t.columns?.length) return t;
1276
+ let r = t.columns?.length ? t.columns.every((e) => !!e.type) : !1;
1277
+ if (t.relationshipField && r) return t;
1055
1278
  try {
1056
- let r = await n.getObjectSchema(t.childObject), i = Xe(t.childObject, r, e.objectName, {
1279
+ let r = await n.getObjectSchema(t.childObject);
1280
+ if (t.relationshipField && t.columns?.length) return {
1281
+ ...t,
1282
+ columns: ft(t.columns, r)
1283
+ };
1284
+ let i = yt(t.childObject, r, e.objectName, {
1057
1285
  relationshipField: t.relationshipField,
1058
1286
  columns: t.columns,
1059
1287
  amountField: t.amountField
@@ -1085,8 +1313,33 @@ var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1085
1313
  original: []
1086
1314
  }))), g = o(m);
1087
1315
  g.current = m;
1088
- let [_, v] = s(0), [y, b] = s(!1), x = o(!1), S = o(null), C = t(() => {
1089
- x.current = !1, b(!1), S.current &&= (clearTimeout(S.current), null);
1316
+ let _ = o({});
1317
+ r(() => {
1318
+ let e = n;
1319
+ if (!e || typeof e.getObjectSchema != "function") return;
1320
+ let t = !1, r = Array.from(new Set(c.map((e) => e.childObject).filter(Boolean)));
1321
+ return (async () => {
1322
+ let n = await Promise.all(r.map(async (t) => {
1323
+ try {
1324
+ return [t, await e.getObjectSchema(t)];
1325
+ } catch {
1326
+ return [t, null];
1327
+ }
1328
+ }));
1329
+ if (t) return;
1330
+ let i = {};
1331
+ for (let [e, t] of n) t && (i[e] = t);
1332
+ _.current = i;
1333
+ })(), () => {
1334
+ t = !0;
1335
+ };
1336
+ }, [
1337
+ n,
1338
+ e.objectName,
1339
+ e.details
1340
+ ]);
1341
+ let [v, y] = s(0), [b, x] = s(!1), S = o(!1), C = o(null), w = t(() => {
1342
+ S.current = !1, x(!1), C.current &&= (clearTimeout(C.current), null);
1090
1343
  }, []);
1091
1344
  r(() => {
1092
1345
  let t = !1;
@@ -1122,12 +1375,12 @@ var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1122
1375
  e.recordId,
1123
1376
  d
1124
1377
  ]);
1125
- let w = t((e, t) => {
1378
+ let T = t((e, t) => {
1126
1379
  h((n) => n.map((n, r) => r === e ? {
1127
1380
  ...n,
1128
1381
  rows: t
1129
1382
  } : n));
1130
- }, []), T = e.taxRateField || "tax_rate", [E, D] = s(null), j = E ? m[E.detailIdx]?.rows?.[E.rowIdx] : void 0, P = E ? p[E.detailIdx] : void 0, F = t((e, t, n) => {
1383
+ }, []), E = e.taxRateField || "tax_rate", [A, N] = s(null), P = A ? m[A.detailIdx]?.rows?.[A.rowIdx] : void 0, F = A ? p[A.detailIdx] : void 0, ee = t((e, t, n) => {
1131
1384
  h((r) => r.map((r, i) => i === e ? {
1132
1385
  ...r,
1133
1386
  rows: r.rows.map((e, r) => r === t ? {
@@ -1141,42 +1394,43 @@ var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1141
1394
  ...t,
1142
1395
  rows: [...t.rows, {}]
1143
1396
  } : t);
1144
- return D({
1397
+ return N({
1145
1398
  detailIdx: e,
1146
1399
  rowIdx: n[e].rows.length - 1,
1147
1400
  isNew: !0
1148
1401
  }), n;
1149
1402
  });
1150
1403
  }, []), L = t(() => {
1151
- D((e) => (e?.isNew && h((t) => t.map((t, n) => n === e.detailIdx ? {
1404
+ N((e) => (e?.isNew && h((t) => t.map((t, n) => n === e.detailIdx ? {
1152
1405
  ...t,
1153
1406
  rows: t.rows.filter((t, n) => n !== e.rowIdx)
1154
1407
  } : t)), null));
1155
1408
  }, []), R = t(async (t) => {
1156
- C(), se.success(l ? e.title ? `${e.title} saved` : "Saved" : "Created"), l || (h(p.map(() => ({
1409
+ w(), e.onSuccess || K.success(l ? e.title ? `${e.title} saved` : "Saved" : "Created"), l || (h(p.map(() => ({
1157
1410
  rows: [],
1158
1411
  original: []
1159
- }))), v((e) => e + 1)), await e.onSuccess?.(t);
1412
+ }))), y((e) => e + 1)), await e.onSuccess?.(t);
1160
1413
  }, [
1161
1414
  l,
1162
1415
  e.onSuccess,
1163
1416
  e.title,
1164
1417
  p.length,
1165
- C
1418
+ w
1166
1419
  ]), z = t((t) => {
1167
- C(), se.error(t?.message || "Save failed"), e.onError?.(t);
1168
- }, [e, C]), B = t(async (t) => {
1420
+ w(), K.error(t?.message || "Save failed"), e.onError?.(t);
1421
+ }, [e, w]), B = t(async (t) => {
1169
1422
  let r = [];
1170
1423
  for (let i = 0; i < p.length; i++) {
1171
1424
  let a = p[i], { rows: o, original: s } = g.current[i];
1172
1425
  if (!a.relationshipField) continue;
1173
- let { created: c } = await Ne(n, e.objectName, t, {
1426
+ let { created: c } = await tt(n, e.objectName, t, {
1174
1427
  childObject: a.childObject,
1175
1428
  relationshipField: a.relationshipField,
1176
1429
  rows: o,
1177
1430
  original: l ? s : void 0,
1178
1431
  amountField: a.amountField,
1179
- totalField: a.totalField
1432
+ totalField: a.totalField,
1433
+ childSchema: _.current[a.childObject]
1180
1434
  });
1181
1435
  r.push(...c);
1182
1436
  }
@@ -1203,20 +1457,22 @@ var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1203
1457
  B,
1204
1458
  e,
1205
1459
  R
1206
- ]), ee = typeof n?.batchTransaction == "function", te = t(async (t) => {
1460
+ ]), H = typeof n?.batchTransaction == "function", te = t(async (t) => {
1207
1461
  let r = n, i = { ...t };
1208
1462
  p.forEach((e, t) => {
1209
- e.totalField && (i[e.totalField] = Ae(g.current[t]?.rows ?? [], e.amountField || "amount"));
1463
+ e.totalField && (i[e.totalField] = Qe(g.current[t]?.rows ?? [], e.amountField || "amount"));
1210
1464
  });
1211
- let a = l ? Oe(e.objectName, e.recordId, i, p.filter((e) => e.relationshipField).map((e, t) => ({
1465
+ let a = l ? Xe(e.objectName, e.recordId, i, p.filter((e) => e.relationshipField).map((e, t) => ({
1212
1466
  childObject: e.childObject,
1213
1467
  relationshipField: e.relationshipField,
1214
1468
  rows: g.current[t]?.rows ?? [],
1215
- original: g.current[t]?.original ?? []
1216
- }))) : De(e.objectName, i, p.filter((e) => e.relationshipField).map((e, t) => ({
1469
+ original: g.current[t]?.original ?? [],
1470
+ childSchema: _.current[e.childObject]
1471
+ }))) : Ye(e.objectName, i, p.filter((e) => e.relationshipField).map((e, t) => ({
1217
1472
  childObject: e.childObject,
1218
1473
  relationshipField: e.relationshipField,
1219
- rows: g.current[t]?.rows ?? []
1474
+ rows: g.current[t]?.rows ?? [],
1475
+ childSchema: _.current[e.childObject]
1220
1476
  })));
1221
1477
  return (await r.batchTransaction(a))?.results?.[0] ?? {
1222
1478
  ...i,
@@ -1228,7 +1484,7 @@ var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1228
1484
  e.objectName,
1229
1485
  e.recordId,
1230
1486
  l
1231
- ]), H = a(() => ({
1487
+ ]), ne = a(() => ({
1232
1488
  type: "object-form",
1233
1489
  objectName: e.objectName,
1234
1490
  mode: e.mode ?? "create",
@@ -1241,7 +1497,7 @@ var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1241
1497
  title: e.title,
1242
1498
  showSubmit: !1,
1243
1499
  showCancel: !1,
1244
- ...ee ? {
1500
+ ...H ? {
1245
1501
  submitHandler: te,
1246
1502
  onSuccess: R
1247
1503
  } : { onSuccess: V },
@@ -1249,53 +1505,53 @@ var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1249
1505
  }), [
1250
1506
  e,
1251
1507
  V,
1252
- ee,
1508
+ H,
1253
1509
  te,
1254
1510
  R,
1255
1511
  z
1256
- ]), U = o(null), ne = e.submitText ?? (l ? "Save" : "Create"), W = t(() => {
1257
- x.current || U.current?.querySelector("form") && (x.current = !0, b(!0), setTimeout(() => {
1512
+ ]), U = o(null), W = e.submitText ?? (l ? "Save" : "Create"), re = t(() => {
1513
+ S.current || U.current?.querySelector("form") && (S.current = !0, x(!0), setTimeout(() => {
1258
1514
  (U.current?.querySelector("form"))?.requestSubmit();
1259
- }, 0), S.current = setTimeout(() => C(), 1500));
1260
- }, [C]);
1515
+ }, 0), C.current = setTimeout(() => w(), 1500));
1516
+ }, [w]);
1261
1517
  return r(() => () => {
1262
- S.current && clearTimeout(S.current);
1263
- }, []), /* @__PURE__ */ Z("div", {
1518
+ C.current && clearTimeout(C.current);
1519
+ }, []), /* @__PURE__ */ X("div", {
1264
1520
  className: G("space-y-6", i, e.className),
1265
1521
  children: [
1266
- /* @__PURE__ */ X("div", {
1522
+ /* @__PURE__ */ Y("div", {
1267
1523
  ref: U,
1268
- children: /* @__PURE__ */ X(Tt, {
1269
- schema: H,
1524
+ children: /* @__PURE__ */ Y(At, {
1525
+ schema: ne,
1270
1526
  dataSource: n
1271
- }, _)
1527
+ }, v)
1272
1528
  }),
1273
- /* @__PURE__ */ X(Qe, {
1529
+ /* @__PURE__ */ Y(xt, {
1274
1530
  details: p,
1275
1531
  state: m,
1276
- setRows: w,
1532
+ setRows: T,
1277
1533
  formHostRef: U,
1278
- taxRateField: T,
1279
- formKey: _,
1280
- onRowExpand: (e, t) => D({
1534
+ taxRateField: E,
1535
+ formKey: v,
1536
+ onRowExpand: (e, t) => N({
1281
1537
  detailIdx: e,
1282
1538
  rowIdx: t
1283
1539
  }),
1284
1540
  onAddViaForm: I
1285
1541
  }),
1286
- E && P && /* @__PURE__ */ Z(k, {
1542
+ A && F && /* @__PURE__ */ X(O, {
1287
1543
  className: "border-primary/40 shadow-none ring-1 ring-primary/10",
1288
1544
  "data-testid": "md-row-form",
1289
- children: [/* @__PURE__ */ Z(M, {
1545
+ children: [/* @__PURE__ */ X(j, {
1290
1546
  className: "pb-2 flex flex-row items-center justify-between gap-2 space-y-0",
1291
- children: [/* @__PURE__ */ Z(N, {
1547
+ children: [/* @__PURE__ */ X(M, {
1292
1548
  className: "text-sm font-medium",
1293
1549
  children: [
1294
- P.title || "Line item",
1550
+ F.title || "Line item",
1295
1551
  " — row ",
1296
- E.rowIdx + 1
1552
+ A.rowIdx + 1
1297
1553
  ]
1298
- }), /* @__PURE__ */ X(O, {
1554
+ }), /* @__PURE__ */ Y(D, {
1299
1555
  type: "button",
1300
1556
  variant: "ghost",
1301
1557
  size: "sm",
@@ -1303,190 +1559,54 @@ var Qe = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1303
1559
  onClick: L,
1304
1560
  children: "Close"
1305
1561
  })]
1306
- }), /* @__PURE__ */ X(A, { children: /* @__PURE__ */ X(Tt, {
1562
+ }), /* @__PURE__ */ Y(k, { children: /* @__PURE__ */ Y(At, {
1307
1563
  schema: {
1308
1564
  type: "object-form",
1309
- objectName: P.childObject,
1565
+ objectName: F.childObject,
1310
1566
  mode: "edit",
1311
- initialData: j ?? {},
1312
- ...P.formFields?.length ? { fields: P.formFields } : {},
1567
+ initialData: P ?? {},
1568
+ ...F.formFields?.length ? { fields: F.formFields } : {},
1313
1569
  submitText: "Apply",
1314
1570
  submitHandler: async (e) => e,
1315
1571
  onSuccess: (e) => {
1316
- F(E.detailIdx, E.rowIdx, e), D(null);
1572
+ ee(A.detailIdx, A.rowIdx, e), N(null);
1317
1573
  },
1318
1574
  onCancel: L
1319
1575
  },
1320
1576
  dataSource: n
1321
- }, `row-${E.detailIdx}-${E.rowIdx}`) })]
1577
+ }, `row-${A.detailIdx}-${A.rowIdx}`) })]
1322
1578
  }),
1323
- e.showSubmit !== !1 && /* @__PURE__ */ Z("div", {
1579
+ e.showSubmit !== !1 && /* @__PURE__ */ X("div", {
1324
1580
  className: "flex items-center justify-end gap-2 border-t border-border pt-4",
1325
- children: [e.onCancel && /* @__PURE__ */ X(O, {
1581
+ children: [e.onCancel && /* @__PURE__ */ Y(D, {
1326
1582
  type: "button",
1327
1583
  variant: "outline",
1328
1584
  onClick: e.onCancel,
1329
- disabled: y,
1585
+ disabled: b,
1330
1586
  "data-testid": "md-form-cancel",
1331
- children: "Cancel"
1332
- }), /* @__PURE__ */ X(O, {
1587
+ children: e.cancelText ?? "Cancel"
1588
+ }), /* @__PURE__ */ Y(D, {
1333
1589
  type: "button",
1334
- onClick: W,
1335
- disabled: y || u && !d,
1590
+ onClick: re,
1591
+ disabled: b || u && !d,
1336
1592
  "data-testid": "md-form-submit",
1337
- children: y ? "Saving…" : ne
1593
+ children: b ? "Saving…" : W
1338
1594
  })]
1339
1595
  })
1340
1596
  ]
1341
1597
  });
1342
- }, et = /* @__PURE__ */ new Set([
1343
- "field:formula",
1344
- "field:summary",
1345
- "field:auto_number",
1346
- "field:autonumber"
1347
- ]), tt = /* @__PURE__ */ new Set([
1348
- "field:textarea",
1349
- "field:markdown",
1350
- "field:html",
1351
- "field:grid",
1352
- "field:rich-text",
1353
- "textarea",
1354
- "markdown",
1355
- "html",
1356
- "grid",
1357
- "rich-text"
1358
- ]), nt = /* @__PURE__ */ new Set([
1359
- "formula",
1360
- "summary",
1361
- "auto_number",
1362
- "autonumber"
1363
- ]);
1364
- function rt(e) {
1365
- return tt.has(e);
1366
- }
1367
- function it(e) {
1368
- return nt.has(e);
1369
- }
1370
- function at(e) {
1371
- return e <= 3 ? 1 : 2;
1372
- }
1373
- function ot(e, t) {
1374
- return t <= 1 ? e : e.map((e) => e.colSpan === void 0 && e.type && rt(e.type) ? {
1375
- ...e,
1376
- colSpan: t
1377
- } : e);
1378
- }
1379
- var st = /* @__PURE__ */ new Set([
1380
- "id",
1381
- "created_at",
1382
- "createdAt",
1383
- "updated_at",
1384
- "updatedAt",
1385
- "last_modified_at",
1386
- "lastModifiedAt",
1387
- "deleted_at",
1388
- "deletedAt",
1389
- "created_by",
1390
- "createdBy",
1391
- "updated_by",
1392
- "updatedBy",
1393
- "last_modified_by",
1394
- "lastModifiedBy",
1395
- "organization_id",
1396
- "organizationId",
1397
- "org_id",
1398
- "orgId",
1399
- "tenant_id",
1400
- "tenantId",
1401
- "owner",
1402
- "owner_id",
1403
- "_version",
1404
- "_rev"
1405
- ]);
1406
- function ct(e, t) {
1407
- return e.filter((e) => {
1408
- if (st.has(e.name)) return !1;
1409
- let n = t?.fields?.[e.name];
1410
- return !(n?.hidden === !0 || n?.readonly === !0);
1411
- });
1412
- }
1413
- function lt(e, t) {
1414
- return e.filter((e) => {
1415
- if (st.has(e.name) || e.type && et.has(e.type)) return !1;
1416
- if (!t?.fields) return !0;
1417
- let n = t.fields[e.name];
1418
- return n ? n.readonly === !0 ? !1 : !it(n.type) : !0;
1419
- });
1420
- }
1421
- function ut(e, t) {
1422
- return e.filter((e) => {
1423
- if (e.type && et.has(e.type)) return !1;
1424
- let n = t?.fields?.[e.name];
1425
- return n ? !it(n.type) : !0;
1426
- });
1427
- }
1428
- function dt(e) {
1429
- return e <= 1 ? "default" : e === 2 ? "xl" : "full";
1430
- }
1431
- function ft(e, t, n, r) {
1432
- let i = [...e];
1433
- if (i = ct(i, t), r === "create" && (i = ut(i, t)), n !== void 0) return i = ot(i, n), {
1434
- fields: i,
1435
- columns: n
1436
- };
1437
- let a = at(i.length);
1438
- return i = ot(i, a), {
1439
- fields: i,
1440
- columns: a
1441
- };
1442
- }
1443
- //#endregion
1444
- //#region src/sanitize.ts
1445
- var pt = /* @__PURE__ */ new Set([
1446
- "id",
1447
- "_id",
1448
- "created_at",
1449
- "updated_at",
1450
- "createdAt",
1451
- "updatedAt",
1452
- "organization_id",
1453
- "organizationId"
1454
- ]), mt = /* @__PURE__ */ new Set([
1455
- "formula",
1456
- "rollup",
1457
- "lookup_value",
1458
- "auto_number",
1459
- "autonumber",
1460
- "computed"
1461
- ]);
1462
- function ht(e, t) {
1463
- if (!e || typeof e != "object") return e;
1464
- let n = {}, r = t?.fields;
1465
- for (let [t, i] of Object.entries(e)) if (!pt.has(t)) {
1466
- if (r) {
1467
- let e = r[t];
1468
- if (!e) continue;
1469
- let n = String(e.type || "").toLowerCase();
1470
- if (mt.has(n) || e.computed === !0 || e.formula || e.readOnly === !0 || e.readonly === !0) continue;
1471
- }
1472
- n[t] = i;
1473
- }
1474
- return n;
1475
- }
1476
- //#endregion
1477
- //#region src/DrawerForm.tsx
1478
- var gt = {
1598
+ }, Ct = {
1479
1599
  1: void 0,
1480
1600
  2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
1481
1601
  3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
1482
1602
  4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
1483
- }, _t = Q({
1603
+ }, wt = Z({
1484
1604
  "form.discardTitle": "Discard changes?",
1485
1605
  "form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
1486
1606
  "form.keepEditing": "Keep editing",
1487
1607
  "form.discard": "Discard"
1488
- }, "form.discardTitle"), vt = ({ schema: e, dataSource: n, className: c }) => {
1489
- let { fieldLabel: u } = p(), { t: f } = _t(), m = d(), [h, _] = s(null), [v, k] = s([]), [A, j] = s({}), [M, N] = s(!0), [P, F] = s(null), [I, L] = s(!1), [R, z] = s(!1), [B, V] = s(!1), W = o(!1), re = e.confirmOnDiscard !== !1, ie = e.open !== !1, ae = e.drawerSide || "right", oe = i(), [se, ce] = s(() => {
1608
+ }, "form.discardTitle"), Tt = ({ schema: e, dataSource: n, className: c }) => {
1609
+ let { fieldLabel: u } = p(), { t: f } = wt(), m = d(), [h, _] = s(null), [O, k] = s([]), [A, j] = s({}), [M, N] = s(!0), [P, F] = s(null), [ee, I] = s(!1), [L, R] = s(!1), [z, U] = s(!1), W = o(!1), re = e.confirmOnDiscard !== !1, ie = e.open !== !1, ae = e.drawerSide || "right", K = i(), [oe, se] = s(() => {
1490
1610
  let t = {};
1491
1611
  return e.sections?.forEach((e, n) => {
1492
1612
  let r = e.name || String(n);
@@ -1532,7 +1652,7 @@ var gt = {
1532
1652
  n,
1533
1653
  e.objectName
1534
1654
  ]);
1535
- let le = t((t) => xe(t, {
1655
+ let ce = t((t) => xe(t, {
1536
1656
  objectSchema: h,
1537
1657
  objectName: e.objectName,
1538
1658
  readOnly: e.readOnly,
@@ -1564,7 +1684,7 @@ var gt = {
1564
1684
  i && r.push({
1565
1685
  name: t,
1566
1686
  label: u(e.objectName, t, i.label || t),
1567
- type: y(i.type),
1687
+ type: v(i.type),
1568
1688
  required: i.required || !1,
1569
1689
  disabled: e.readOnly || e.mode === "view" || i.readonly,
1570
1690
  placeholder: i.placeholder,
@@ -1585,32 +1705,32 @@ var gt = {
1585
1705
  e.mode,
1586
1706
  n
1587
1707
  ]);
1588
- let K = t(async (t) => {
1589
- V(!0);
1708
+ let le = t(async (t) => {
1709
+ U(!0);
1590
1710
  try {
1591
1711
  if (!n) return e.onSuccess && await e.onSuccess(t), e.onOpenChange?.(!1), t;
1592
- let r, i = ht(t, h);
1712
+ let r, i = Ge(t, h);
1593
1713
  return e.mode === "create" ? r = await n.create(e.objectName, i) : e.mode === "edit" && e.recordId && (r = await n.update(e.objectName, e.recordId, i)), e.onSuccess && await e.onSuccess(r), e.onOpenChange?.(!1), r;
1594
1714
  } catch (t) {
1595
1715
  throw e.onError && e.onError(t), t;
1596
1716
  } finally {
1597
- V(!1);
1717
+ U(!1);
1598
1718
  }
1599
1719
  }, [
1600
1720
  e,
1601
1721
  n,
1602
1722
  h
1603
1723
  ]), q = t(() => {
1604
- z(!1), W.current && (W.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
1724
+ R(!1), W.current && (W.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
1605
1725
  }, [e]), ue = t((e) => {
1606
- W.current = e, re && I ? z(!0) : q();
1726
+ W.current = e, re && ee ? R(!0) : q();
1607
1727
  }, [
1608
1728
  re,
1609
- I,
1729
+ ee,
1610
1730
  q
1611
1731
  ]), de = t(() => {
1612
1732
  W.current = !0, q();
1613
- }, [q]), J = a(() => {
1733
+ }, [q]), pe = a(() => {
1614
1734
  if (e.drawerWidth) return ae === "left" || ae === "right" ? {
1615
1735
  width: e.drawerWidth,
1616
1736
  maxWidth: e.drawerWidth
@@ -1618,34 +1738,34 @@ var gt = {
1618
1738
  height: e.drawerWidth,
1619
1739
  maxHeight: e.drawerWidth
1620
1740
  };
1621
- }, [e.drawerWidth, ae]), pe = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", me = e.showSubmit !== !1 && e.mode !== "view", Y = e.showCancel !== !1, Q = e.submitText || (e.mode === "create" ? "Create" : "Update"), he = e.cancelText || "Cancel", ge = {
1741
+ }, [e.drawerWidth, ae]), me = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", J = e.showSubmit !== !1 && e.mode !== "view", Z = e.showCancel !== !1, he = e.submitText || (e.mode === "create" ? "Create" : "Update"), ge = e.cancelText || "Cancel", _e = {
1622
1742
  type: "form",
1623
1743
  objectName: e.objectName,
1624
- layout: pe,
1744
+ layout: me,
1625
1745
  defaultValues: A,
1626
- submitLabel: Q,
1627
- cancelLabel: he,
1628
- showSubmit: me,
1629
- showCancel: Y,
1630
- onSubmit: K,
1746
+ submitLabel: he,
1747
+ cancelLabel: ge,
1748
+ showSubmit: J,
1749
+ showCancel: Z,
1750
+ onSubmit: le,
1631
1751
  onCancel: de,
1632
- onDirtyChange: L,
1752
+ onDirtyChange: I,
1633
1753
  showActions: !1,
1634
- id: oe
1635
- }, _e = () => {
1636
- if (P) return /* @__PURE__ */ Z("div", {
1754
+ id: K
1755
+ }, ve = () => {
1756
+ if (P) return /* @__PURE__ */ X("div", {
1637
1757
  className: "p-4 border border-red-300 bg-red-50 rounded-md",
1638
- children: [/* @__PURE__ */ X("h3", {
1758
+ children: [/* @__PURE__ */ Y("h3", {
1639
1759
  className: "text-red-800 font-semibold",
1640
1760
  children: "Error loading form"
1641
- }), /* @__PURE__ */ X("p", {
1761
+ }), /* @__PURE__ */ Y("p", {
1642
1762
  className: "text-red-600 text-sm mt-1",
1643
1763
  children: P.message
1644
1764
  })]
1645
1765
  });
1646
- if (M) return /* @__PURE__ */ Z("div", {
1766
+ if (M) return /* @__PURE__ */ X("div", {
1647
1767
  className: "p-8 text-center",
1648
- children: [/* @__PURE__ */ X("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ X("p", {
1768
+ children: [/* @__PURE__ */ Y("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Y("p", {
1649
1769
  className: "mt-2 text-sm text-gray-600",
1650
1770
  children: "Loading form..."
1651
1771
  })]
@@ -1653,7 +1773,7 @@ var gt = {
1653
1773
  if (e.sections?.length) {
1654
1774
  let t = [];
1655
1775
  return e.sections.forEach((e, n) => {
1656
- let r = e.name || String(n), i = se[r] ?? e.collapsed ?? !1;
1776
+ let r = e.name || String(n), i = oe[r] ?? e.collapsed ?? !1;
1657
1777
  t.push({
1658
1778
  name: `__section_${r}`,
1659
1779
  label: e.label || "",
@@ -1661,29 +1781,29 @@ var gt = {
1661
1781
  colSpan: 4,
1662
1782
  collapsible: e.collapsible,
1663
1783
  collapsed: i,
1664
- onToggle: e.collapsible ? () => ce((e) => ({
1784
+ onToggle: e.collapsible ? () => se((e) => ({
1665
1785
  ...e,
1666
1786
  [r]: !i
1667
1787
  })) : void 0
1668
1788
  });
1669
- let a = le(e);
1789
+ let a = ce(e);
1670
1790
  i ? t.push(...a.map((e) => ({
1671
1791
  ...e,
1672
1792
  hidden: !0
1673
1793
  }))) : t.push(...a);
1674
- }), /* @__PURE__ */ X(l, { schema: {
1675
- ...ge,
1794
+ }), /* @__PURE__ */ Y(l, { schema: {
1795
+ ..._e,
1676
1796
  fields: t
1677
1797
  } });
1678
1798
  }
1679
- let t = ft(v, h, e.columns, e.mode), n = gt[t.columns || 1];
1680
- return /* @__PURE__ */ X(l, { schema: {
1681
- ...ge,
1799
+ let t = ze(O, h, e.columns, e.mode), n = Ct[t.columns || 1];
1800
+ return /* @__PURE__ */ Y(l, { schema: {
1801
+ ..._e,
1682
1802
  fields: t.fields,
1683
1803
  columns: t.columns,
1684
1804
  ...n ? { fieldContainerClass: n } : {}
1685
1805
  } });
1686
- }, ve = e.subforms, ye = ve?.length && e.mode !== "view" ? /* @__PURE__ */ X($e, {
1806
+ }, Q = e.subforms, ye = Q?.length && e.mode !== "view" ? /* @__PURE__ */ Y(St, {
1687
1807
  schema: {
1688
1808
  type: "object-master-detail-form",
1689
1809
  objectName: e.objectName,
@@ -1692,7 +1812,8 @@ var gt = {
1692
1812
  fields: e.fields,
1693
1813
  sections: e.sections,
1694
1814
  submitText: e.submitText,
1695
- details: ve,
1815
+ cancelText: ge,
1816
+ details: Q,
1696
1817
  onSuccess: async (t) => {
1697
1818
  await e.onSuccess?.(t), e.onOpenChange?.(!1);
1698
1819
  },
@@ -1700,20 +1821,20 @@ var gt = {
1700
1821
  onCancel: () => e.onOpenChange?.(!1)
1701
1822
  },
1702
1823
  dataSource: n
1703
- }) : _e();
1704
- return m ? /* @__PURE__ */ Z("div", {
1824
+ }) : ve();
1825
+ return m ? /* @__PURE__ */ X("div", {
1705
1826
  className: "@container rounded-md border bg-card p-4",
1706
- children: [(e.title || e.description) && /* @__PURE__ */ Z("div", {
1827
+ children: [(e.title || e.description) && /* @__PURE__ */ X("div", {
1707
1828
  className: "mb-3 space-y-0.5",
1708
- children: [e.title && /* @__PURE__ */ X("div", {
1829
+ children: [e.title && /* @__PURE__ */ Y("div", {
1709
1830
  className: "text-sm font-semibold",
1710
1831
  children: e.title
1711
- }), e.description && /* @__PURE__ */ X("p", {
1832
+ }), e.description && /* @__PURE__ */ Y("p", {
1712
1833
  className: "text-xs text-muted-foreground",
1713
1834
  children: e.description
1714
1835
  })]
1715
1836
  }), ye]
1716
- }) : /* @__PURE__ */ X(ee, {
1837
+ }) : /* @__PURE__ */ Y(B, {
1717
1838
  open: ie,
1718
1839
  onOpenChange: (t) => {
1719
1840
  if (t) {
@@ -1722,49 +1843,49 @@ var gt = {
1722
1843
  }
1723
1844
  ue(!1);
1724
1845
  },
1725
- children: /* @__PURE__ */ Z(te, {
1846
+ children: /* @__PURE__ */ X(V, {
1726
1847
  side: ae,
1727
1848
  className: G("overflow-y-auto", c, e.className),
1728
- style: J,
1849
+ style: pe,
1729
1850
  children: [
1730
- (e.title || e.description) && /* @__PURE__ */ Z(U, { children: [e.title && /* @__PURE__ */ X(ne, { children: e.title }), e.description ? /* @__PURE__ */ X(H, { children: e.description }) : /* @__PURE__ */ X(H, {
1851
+ (e.title || e.description) && /* @__PURE__ */ X(te, { children: [e.title && /* @__PURE__ */ Y(ne, { children: e.title }), e.description ? /* @__PURE__ */ Y(H, { children: e.description }) : /* @__PURE__ */ Y(H, {
1731
1852
  className: "sr-only",
1732
1853
  children: "Complete the form fields, then submit or cancel."
1733
1854
  })] }),
1734
- /* @__PURE__ */ X("div", {
1855
+ /* @__PURE__ */ Y("div", {
1735
1856
  className: "@container py-4",
1736
1857
  children: ye
1737
1858
  }),
1738
- !P && !M && !(ve?.length && e.mode !== "view") && (me || Y) && /* @__PURE__ */ X("div", {
1859
+ !P && !M && !(Q?.length && e.mode !== "view") && (J || Z) && /* @__PURE__ */ Y("div", {
1739
1860
  className: "shrink-0 border-t px-4 py-3 bg-background",
1740
1861
  "data-testid": "drawer-form-footer",
1741
- children: /* @__PURE__ */ Z("div", {
1862
+ children: /* @__PURE__ */ X("div", {
1742
1863
  className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
1743
- children: [Y && /* @__PURE__ */ X(O, {
1864
+ children: [Z && /* @__PURE__ */ Y(D, {
1744
1865
  type: "button",
1745
1866
  variant: "outline",
1746
1867
  onClick: de,
1747
- disabled: B,
1868
+ disabled: z,
1748
1869
  className: "w-full sm:w-auto",
1749
- children: he
1750
- }), me && /* @__PURE__ */ Z(O, {
1870
+ children: ge
1871
+ }), J && /* @__PURE__ */ X(D, {
1751
1872
  type: "submit",
1752
- form: oe,
1753
- disabled: B,
1873
+ form: K,
1874
+ disabled: z,
1754
1875
  className: "w-full sm:w-auto",
1755
- children: [B && /* @__PURE__ */ X(fe, { className: "mr-2 h-4 w-4 animate-spin" }), Q]
1876
+ children: [z && /* @__PURE__ */ Y(fe, { className: "mr-2 h-4 w-4 animate-spin" }), he]
1756
1877
  })]
1757
1878
  })
1758
1879
  }),
1759
- /* @__PURE__ */ X(b, {
1760
- open: R,
1761
- onOpenChange: z,
1762
- children: /* @__PURE__ */ Z(C, { children: [/* @__PURE__ */ Z(E, { children: [/* @__PURE__ */ X(D, { children: f("form.discardTitle") }), /* @__PURE__ */ X(w, { children: f("form.discardMessage") })] }), /* @__PURE__ */ Z(T, { children: [/* @__PURE__ */ X(S, {
1880
+ /* @__PURE__ */ Y(y, {
1881
+ open: L,
1882
+ onOpenChange: R,
1883
+ children: /* @__PURE__ */ X(S, { children: [/* @__PURE__ */ X(T, { children: [/* @__PURE__ */ Y(E, { children: f("form.discardTitle") }), /* @__PURE__ */ Y(C, { children: f("form.discardMessage") })] }), /* @__PURE__ */ X(w, { children: [/* @__PURE__ */ Y(x, {
1763
1884
  onClick: () => {
1764
1885
  W.current = !1;
1765
1886
  },
1766
1887
  children: f("form.keepEditing")
1767
- }), /* @__PURE__ */ X(x, {
1888
+ }), /* @__PURE__ */ Y(b, {
1768
1889
  onClick: q,
1769
1890
  children: f("form.discard")
1770
1891
  })] })] })
@@ -1772,32 +1893,51 @@ var gt = {
1772
1893
  ]
1773
1894
  })
1774
1895
  });
1775
- }, yt = Q({
1896
+ };
1897
+ //#endregion
1898
+ //#region src/fieldGroups.ts
1899
+ function Et(e, t) {
1900
+ let n = he({
1901
+ fieldGroups: t,
1902
+ fields: Object.fromEntries(e.map((e) => [e.name, { group: e.group }]))
1903
+ });
1904
+ if (!n) return null;
1905
+ let r = new Set(n.flatMap((e) => e.fields)), i = e.map((e) => e.name).filter((e) => !r.has(e)), a = n.map((e) => ({
1906
+ ...e.key === void 0 ? {} : { name: e.key },
1907
+ ...e.key === void 0 ? {} : { label: e.label ?? e.key },
1908
+ fields: [...e.fields],
1909
+ ...e.collapse === "none" ? {} : { collapsible: !0 },
1910
+ ...e.collapse === "collapsed" ? { collapsed: !0 } : {}
1911
+ }));
1912
+ if (i.length > 0) {
1913
+ let e = a[a.length - 1];
1914
+ e && e.name === void 0 ? e.fields = [...e.fields ?? [], ...i] : a.push({ fields: i });
1915
+ }
1916
+ return a;
1917
+ }
1918
+ //#endregion
1919
+ //#region src/ModalForm.tsx
1920
+ var Dt = Z({
1776
1921
  "form.discardTitle": "Discard changes?",
1777
1922
  "form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
1778
1923
  "form.keepEditing": "Keep editing",
1779
1924
  "form.discard": "Discard"
1780
- }, "form.discardTitle"), bt = {
1925
+ }, "form.discardTitle"), Ot = {
1781
1926
  sm: "sm:max-w-sm",
1782
1927
  default: "sm:max-w-lg",
1783
1928
  lg: "sm:max-w-2xl",
1784
1929
  xl: "sm:max-w-5xl",
1785
1930
  full: "sm:max-w-[95vw] sm:w-full"
1786
- }, xt = {
1787
- 1: void 0,
1788
- 2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
1789
- 3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
1790
- 4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
1791
- }, St = ({ schema: e, dataSource: n, className: c }) => {
1792
- let { fieldLabel: u } = p(), { t: f } = yt(), m = d(), h = le(), _ = t((t) => {
1793
- if (!h?.isLoaded) return t;
1931
+ }, kt = ({ schema: e, dataSource: n, className: c }) => {
1932
+ let { fieldLabel: u, sectionLabel: f } = p(), { t: m } = Dt(), h = d(), _ = se(), O = t((t) => {
1933
+ if (!_?.isLoaded) return t;
1794
1934
  let n = [];
1795
1935
  for (let r of t) {
1796
1936
  if (!r?.name) {
1797
1937
  n.push(r);
1798
1938
  continue;
1799
1939
  }
1800
- h.checkField(e.objectName, r.name, "read") && (!h.checkField(e.objectName, r.name, "write") && e.mode !== "view" ? n.push({
1940
+ _.checkField(e.objectName, r.name, "read") && (!_.checkField(e.objectName, r.name, "write") && e.mode !== "view" ? n.push({
1801
1941
  ...r,
1802
1942
  readOnly: !0,
1803
1943
  disabled: !0
@@ -1805,29 +1945,47 @@ var gt = {
1805
1945
  }
1806
1946
  return n;
1807
1947
  }, [
1808
- h,
1948
+ _,
1809
1949
  e.objectName,
1810
1950
  e.mode
1811
- ]), [v, k] = s(null), [A, j] = s([]), [M, N] = s({}), [z, B] = s(!0), [V, ee] = s(null), [te, H] = s(!1), [U, ne] = s(!1), [se, ce] = s(!1), K = o(!1), q = e.confirmOnDiscard !== !1, ue = e.open !== !1, de = i(), J = a(() => e.sections?.length || e.customFields?.length ? null : ft(A, v, e.columns, e.mode), [
1812
- A,
1813
- v,
1951
+ ]), [k, A] = s(null), [j, M] = s([]), [L, R] = s({}), [z, B] = s(!0), [V, H] = s(null), [te, ne] = s(!1), [K, oe] = s(!1), [ce, le] = s(!1), q = o(!1), ue = e.confirmOnDiscard !== !1, de = e.open !== !1, pe = i(), me = a(() => {
1952
+ if (e.sections?.length || e.customFields?.length) return null;
1953
+ let t = Me(j, k);
1954
+ e.mode === "create" && (t = Pe(t, k));
1955
+ let n = Et(t, k?.fieldGroups);
1956
+ if (!n) return null;
1957
+ let r = e.columns && e.columns > 0 ? Math.min(Math.floor(e.columns), 4) : De(t.length);
1958
+ return n.map((e) => ({
1959
+ ...e,
1960
+ columns: r
1961
+ }));
1962
+ }, [
1963
+ e.sections,
1964
+ e.customFields,
1814
1965
  e.columns,
1815
1966
  e.mode,
1816
- e.sections,
1967
+ j,
1968
+ k
1969
+ ]), J = e.sections?.length ? e.sections : me ?? void 0, Z = a(() => J?.length || e.customFields?.length ? null : ze(j, k, e.columns, e.mode), [
1970
+ j,
1971
+ k,
1972
+ e.columns,
1973
+ e.mode,
1974
+ J,
1817
1975
  e.customFields
1818
- ]), pe = bt[a(() => {
1976
+ ]), he = Ot[a(() => {
1819
1977
  if (e.modalSize) return e.modalSize;
1820
- if (J?.columns && J.columns > 1) return dt(J.columns);
1821
- if (e.sections?.length) {
1822
- let t = Math.max(...e.sections.map((e) => Number(e.columns) || 1));
1823
- if (t > 1) return dt(t);
1978
+ if (Z?.columns && Z.columns > 1) return Re(Z.columns);
1979
+ if (J?.length) {
1980
+ let e = Math.max(...J.map((e) => Number(e.columns) || 1));
1981
+ if (e > 1) return Re(e);
1824
1982
  }
1825
1983
  return "default";
1826
1984
  }, [
1827
1985
  e.modalSize,
1828
- J,
1829
- e.sections
1830
- ])] || bt.default;
1986
+ Z,
1987
+ J
1988
+ ])] || Ot.default;
1831
1989
  r(() => {
1832
1990
  (async () => {
1833
1991
  if (!n) {
@@ -1835,31 +1993,31 @@ var gt = {
1835
1993
  return;
1836
1994
  }
1837
1995
  try {
1838
- k(await n.getObjectSchema(e.objectName));
1996
+ A(await n.getObjectSchema(e.objectName));
1839
1997
  } catch (e) {
1840
- ee(e), B(!1);
1998
+ H(e), B(!1);
1841
1999
  }
1842
2000
  })();
1843
2001
  }, [e.objectName, n]), r(() => {
1844
- (v || !n) && (async () => {
2002
+ (k || !n) && (async () => {
1845
2003
  if (e.mode === "create" || !e.recordId) {
1846
- N(e.initialData || e.initialValues || {}), B(!1);
2004
+ R(e.initialData || e.initialValues || {}), B(!1);
1847
2005
  return;
1848
2006
  }
1849
2007
  if (!n) {
1850
- N(e.initialData || e.initialValues || {}), B(!1);
2008
+ R(e.initialData || e.initialValues || {}), B(!1);
1851
2009
  return;
1852
2010
  }
1853
2011
  try {
1854
- N(await n.findOne(e.objectName, e.recordId) || {});
2012
+ R(await n.findOne(e.objectName, e.recordId) || {});
1855
2013
  } catch (e) {
1856
- ee(e);
2014
+ H(e);
1857
2015
  } finally {
1858
2016
  B(!1);
1859
2017
  }
1860
2018
  })();
1861
2019
  }, [
1862
- v,
2020
+ k,
1863
2021
  e.mode,
1864
2022
  e.recordId,
1865
2023
  e.initialData,
@@ -1867,39 +2025,39 @@ var gt = {
1867
2025
  n,
1868
2026
  e.objectName
1869
2027
  ]);
1870
- let me = t((t) => xe(t, {
1871
- objectSchema: v,
2028
+ let ge = t((t) => xe(t, {
2029
+ objectSchema: k,
1872
2030
  objectName: e.objectName,
1873
2031
  readOnly: e.readOnly,
1874
2032
  mode: e.mode,
1875
2033
  fieldLabel: u
1876
2034
  }), [
1877
- v,
2035
+ k,
1878
2036
  e.readOnly,
1879
2037
  e.mode,
1880
2038
  e.objectName,
1881
2039
  u
1882
2040
  ]);
1883
2041
  r(() => {
1884
- if (!v && n) return;
2042
+ if (!k && n) return;
1885
2043
  if (e.customFields?.length) {
1886
- j(e.customFields), B(!1);
2044
+ M(e.customFields), B(!1);
1887
2045
  return;
1888
2046
  }
1889
2047
  if (e.sections?.length) {
1890
2048
  B(!1);
1891
2049
  return;
1892
2050
  }
1893
- if (!v) return;
1894
- let t = e.fields || Object.keys(v.fields || {}), r = [];
2051
+ if (!k) return;
2052
+ let t = e.fields || Object.keys(k.fields || {}), r = [];
1895
2053
  for (let n of t) {
1896
2054
  let t = typeof n == "string" ? n : n.name;
1897
2055
  if (!t) continue;
1898
- let i = v.fields?.[t];
2056
+ let i = k.fields?.[t];
1899
2057
  i && r.push({
1900
2058
  name: t,
1901
2059
  label: u(e.objectName, t, i.label || t),
1902
- type: y(i.type),
2060
+ type: v(i.type),
1903
2061
  required: i.required || !1,
1904
2062
  disabled: e.readOnly || e.mode === "view" || i.readonly,
1905
2063
  placeholder: i.placeholder,
@@ -1907,12 +2065,16 @@ var gt = {
1907
2065
  validation: g(i),
1908
2066
  field: i,
1909
2067
  options: i.options,
1910
- multiple: i.multiple
2068
+ multiple: i.multiple,
2069
+ visibleWhen: i.visibleWhen,
2070
+ readonlyWhen: i.readonlyWhen,
2071
+ requiredWhen: i.requiredWhen ?? i.conditionalRequired,
2072
+ group: i.group
1911
2073
  });
1912
2074
  }
1913
- j(r), B(!1);
2075
+ M(r), B(!1);
1914
2076
  }, [
1915
- v,
2077
+ k,
1916
2078
  e.fields,
1917
2079
  e.customFields,
1918
2080
  e.sections,
@@ -1920,143 +2082,161 @@ var gt = {
1920
2082
  e.mode,
1921
2083
  n
1922
2084
  ]);
1923
- let Y = t(async (t) => {
1924
- H(!0);
2085
+ let _e = t(async (t) => {
2086
+ ne(!0);
1925
2087
  try {
1926
2088
  if (!n) return e.onSuccess && await e.onSuccess(t), e.onOpenChange?.(!1), t;
1927
- let r, i = ht(t, v);
1928
- if (h?.isLoaded) {
2089
+ let r, i = Ge(t, k);
2090
+ if (_?.isLoaded) {
1929
2091
  let t = {};
1930
- for (let n of Object.keys(i)) h.checkField(e.objectName, n, "write") && (t[n] = i[n]);
2092
+ for (let n of Object.keys(i)) _.checkField(e.objectName, n, "write") && (t[n] = i[n]);
1931
2093
  i = t;
1932
2094
  }
1933
2095
  return e.mode === "create" ? r = await n.create(e.objectName, i) : e.mode === "edit" && e.recordId && (r = await n.update(e.objectName, e.recordId, i)), e.onSuccess && await e.onSuccess(r), e.onOpenChange?.(!1), r;
1934
2096
  } catch (t) {
1935
2097
  throw e.onError && e.onError(t), t;
1936
2098
  } finally {
1937
- H(!1);
2099
+ ne(!1);
1938
2100
  }
1939
2101
  }, [
1940
2102
  e,
1941
2103
  n,
1942
- v,
1943
- h
2104
+ k,
2105
+ _
1944
2106
  ]), Q = t(() => {
1945
- ce(!1), K.current && (K.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
1946
- }, [e]), he = t((e) => {
1947
- K.current = e, q && U ? ce(!0) : Q();
2107
+ le(!1), q.current && (q.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
2108
+ }, [e]), ye = t((e) => {
2109
+ q.current = e, ue && K ? le(!0) : Q();
1948
2110
  }, [
1949
- q,
1950
- U,
2111
+ ue,
2112
+ K,
1951
2113
  Q
1952
- ]), ge = t(() => {
1953
- K.current = !0, Q();
1954
- }, [Q]), ve = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", ye = e.showSubmit !== !1 && e.mode !== "view", be = e.showCancel !== !1, Se = e.submitText || (e.mode === "create" ? "Create" : "Update"), Ce = e.cancelText || "Cancel", we = {
2114
+ ]), be = t(() => {
2115
+ q.current = !0, Q();
2116
+ }, [Q]), Se = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", Ce = e.showSubmit !== !1 && e.mode !== "view", we = e.showCancel !== !1, Te = e.submitText || (e.mode === "create" ? "Create" : "Update"), Ee = e.cancelText || "Cancel", Oe = {
1955
2117
  type: "form",
1956
2118
  objectName: e.objectName,
1957
- layout: ve,
1958
- defaultValues: M,
1959
- submitLabel: Se,
1960
- cancelLabel: Ce,
1961
- showSubmit: ye,
1962
- showCancel: be,
1963
- onSubmit: Y,
1964
- onCancel: ge,
1965
- onDirtyChange: ne,
2119
+ layout: Se,
2120
+ defaultValues: L,
2121
+ submitLabel: Te,
2122
+ cancelLabel: Ee,
2123
+ showSubmit: Ce,
2124
+ showCancel: we,
2125
+ onSubmit: _e,
2126
+ onCancel: be,
2127
+ onDirtyChange: oe,
1966
2128
  showActions: !1,
1967
- id: de
1968
- }, $ = () => {
1969
- if (V) return /* @__PURE__ */ Z("div", {
2129
+ id: pe
2130
+ }, ke = () => {
2131
+ if (V) return /* @__PURE__ */ X("div", {
1970
2132
  className: "p-4 border border-red-300 bg-red-50 rounded-md",
1971
- children: [/* @__PURE__ */ X("h3", {
2133
+ children: [/* @__PURE__ */ Y("h3", {
1972
2134
  className: "text-red-800 font-semibold",
1973
2135
  children: "Error loading form"
1974
- }), /* @__PURE__ */ X("p", {
2136
+ }), /* @__PURE__ */ Y("p", {
1975
2137
  className: "text-red-600 text-sm mt-1",
1976
2138
  children: V.message
1977
2139
  })]
1978
2140
  });
1979
- if (z) return /* @__PURE__ */ X("div", {
2141
+ if (z) return /* @__PURE__ */ Y("div", {
1980
2142
  className: "space-y-4",
1981
2143
  "data-testid": "modal-form-skeleton",
1982
2144
  children: [
1983
2145
  1,
1984
2146
  2,
1985
2147
  3
1986
- ].map((e) => /* @__PURE__ */ Z("div", {
2148
+ ].map((e) => /* @__PURE__ */ X("div", {
1987
2149
  className: "space-y-2",
1988
- children: [/* @__PURE__ */ X(W, { className: "h-4 w-24" }), /* @__PURE__ */ X(W, { className: "h-10 w-full" })]
2150
+ children: [/* @__PURE__ */ Y(U, { className: "h-4 w-24" }), /* @__PURE__ */ Y(U, { className: "h-10 w-full" })]
1989
2151
  }, e))
1990
2152
  });
1991
2153
  if (e.sections?.length) {
1992
- let t = e.sections, n = (e, t) => e.name || e.label || String(t), r = (e) => /* @__PURE__ */ X(l, { schema: {
1993
- ...we,
1994
- fields: _(me(e))
2154
+ let t = e.sections, n = (e, t) => e.name || e.label || String(t), r = (t) => t.name ? f(e.objectName, t.name, t.label || t.name) : t.label, i = (e) => /* @__PURE__ */ Y(l, { schema: {
2155
+ ...Oe,
2156
+ ...Le(O(ge(e)), e.columns || 1)
1995
2157
  } });
1996
- return e.contentLayout === "tabbed" && t.length > 1 ? /* @__PURE__ */ Z(re, {
2158
+ return e.contentLayout === "tabbed" && t.length > 1 ? /* @__PURE__ */ X(W, {
1997
2159
  defaultValue: n(t[0], 0),
1998
2160
  className: "w-full",
1999
- children: [/* @__PURE__ */ X(ae, {
2161
+ children: [/* @__PURE__ */ Y(ie, {
2000
2162
  className: "mb-4",
2001
- children: t.map((e, t) => /* @__PURE__ */ X(oe, {
2163
+ children: t.map((e, t) => /* @__PURE__ */ Y(ae, {
2002
2164
  value: n(e, t),
2003
- children: e.label || `Section ${t + 1}`
2165
+ children: r(e) || `Section ${t + 1}`
2004
2166
  }, n(e, t)))
2005
- }), t.map((e, t) => /* @__PURE__ */ X(ie, {
2167
+ }), t.map((e, t) => /* @__PURE__ */ Y(re, {
2006
2168
  value: n(e, t),
2007
- children: /* @__PURE__ */ X(_e, {
2169
+ children: /* @__PURE__ */ Y(ve, {
2008
2170
  description: e.description,
2009
- columns: e.columns || 1,
2010
- gridClassName: xt[e.columns || 1],
2011
- children: r(e)
2171
+ columns: 1,
2172
+ children: i(e)
2012
2173
  })
2013
2174
  }, n(e, t)))]
2014
- }) : /* @__PURE__ */ X("div", {
2175
+ }) : /* @__PURE__ */ Y("div", {
2015
2176
  className: "space-y-6",
2016
- children: t.map((e, t) => /* @__PURE__ */ X(_e, {
2017
- label: e.label,
2177
+ children: t.map((e, t) => /* @__PURE__ */ Y(ve, {
2178
+ label: r(e),
2018
2179
  description: e.description,
2019
- columns: e.columns || 1,
2020
- gridClassName: xt[e.columns || 1],
2021
- children: r(e)
2180
+ columns: 1,
2181
+ children: i(e)
2022
2182
  }, n(e, t)))
2023
2183
  });
2024
2184
  }
2025
- let t = J ?? ft(A, v, e.columns, e.mode), n = xt[t.columns || 1];
2026
- return /* @__PURE__ */ X(l, { schema: {
2027
- ...we,
2028
- fields: _(t.fields),
2185
+ if (me?.length) {
2186
+ let t = Number(me[0]?.columns) || 1, n = [];
2187
+ me.forEach((r, i) => {
2188
+ let a = O(ge(r));
2189
+ if (!a.length) return;
2190
+ let o = r.name ? f(e.objectName, r.name, r.label || r.name) : r.label;
2191
+ o && n.push({
2192
+ name: `__section_${r.name || i}`,
2193
+ label: o,
2194
+ type: "section-divider"
2195
+ }), n.push(...t > 1 ? Ae(a, t) : a);
2196
+ });
2197
+ let r = Fe[t];
2198
+ return /* @__PURE__ */ Y(l, { schema: {
2199
+ ...Oe,
2200
+ fields: n,
2201
+ columns: t,
2202
+ ...r ? { fieldContainerClass: r } : {}
2203
+ } });
2204
+ }
2205
+ let t = Z ?? ze(j, k, e.columns, e.mode), n = Fe[t.columns || 1];
2206
+ return /* @__PURE__ */ Y(l, { schema: {
2207
+ ...Oe,
2208
+ fields: O(t.fields),
2029
2209
  columns: t.columns,
2030
2210
  ...n ? { fieldContainerClass: n } : {}
2031
2211
  } });
2032
- }, Te = e.subforms;
2033
- if (m) return /* @__PURE__ */ Z("div", {
2212
+ }, je = e.subforms;
2213
+ if (h) return /* @__PURE__ */ X("div", {
2034
2214
  className: "@container rounded-md border bg-card p-4",
2035
- children: [(e.title || e.description) && /* @__PURE__ */ Z("div", {
2215
+ children: [(e.title || e.description) && /* @__PURE__ */ X("div", {
2036
2216
  className: "mb-3 space-y-0.5",
2037
- children: [e.title && /* @__PURE__ */ X("div", {
2217
+ children: [e.title && /* @__PURE__ */ Y("div", {
2038
2218
  className: "text-sm font-semibold",
2039
2219
  children: e.title
2040
- }), e.description && /* @__PURE__ */ X("p", {
2220
+ }), e.description && /* @__PURE__ */ Y("p", {
2041
2221
  className: "text-xs text-muted-foreground",
2042
2222
  children: e.description
2043
2223
  })]
2044
- }), $()]
2224
+ }), ke()]
2045
2225
  });
2046
- if (Te?.length && e.mode !== "view") return /* @__PURE__ */ X(P, {
2047
- open: ue,
2226
+ if (je?.length && e.mode !== "view") return /* @__PURE__ */ Y(N, {
2227
+ open: de,
2048
2228
  onOpenChange: e.onOpenChange,
2049
- children: /* @__PURE__ */ Z(R, {
2050
- className: G(pe, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", c, e.className),
2051
- children: [(e.title || e.description) && /* @__PURE__ */ Z(I, {
2229
+ children: /* @__PURE__ */ X(I, {
2230
+ className: G(he, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", c, e.className),
2231
+ children: [(e.title || e.description) && /* @__PURE__ */ X(F, {
2052
2232
  className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
2053
- children: [e.title && /* @__PURE__ */ X(L, { children: e.title }), e.description ? /* @__PURE__ */ X(F, { children: e.description }) : /* @__PURE__ */ X(F, {
2233
+ children: [e.title && /* @__PURE__ */ Y(ee, { children: e.title }), e.description ? /* @__PURE__ */ Y(P, { children: e.description }) : /* @__PURE__ */ Y(P, {
2054
2234
  className: "sr-only",
2055
2235
  children: "Enter the record and its line items, then save."
2056
2236
  })]
2057
- }), /* @__PURE__ */ X("div", {
2237
+ }), /* @__PURE__ */ Y("div", {
2058
2238
  className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
2059
- children: /* @__PURE__ */ X($e, {
2239
+ children: /* @__PURE__ */ Y(St, {
2060
2240
  schema: {
2061
2241
  type: "object-master-detail-form",
2062
2242
  objectName: e.objectName,
@@ -2064,8 +2244,11 @@ var gt = {
2064
2244
  recordId: e.recordId,
2065
2245
  fields: e.fields,
2066
2246
  sections: e.sections,
2067
- submitText: Se,
2068
- details: Te,
2247
+ initialValues: e.initialValues,
2248
+ initialData: e.initialData,
2249
+ submitText: Te,
2250
+ cancelText: Ee,
2251
+ details: je,
2069
2252
  onSuccess: async (t) => {
2070
2253
  await e.onSuccess?.(t), e.onOpenChange?.(!1);
2071
2254
  },
@@ -2077,110 +2260,69 @@ var gt = {
2077
2260
  })]
2078
2261
  })
2079
2262
  });
2080
- let Ee = !z && !V && (ye || be);
2081
- return /* @__PURE__ */ X(P, {
2082
- open: ue,
2263
+ let Ne = !z && !V && (Ce || we);
2264
+ return /* @__PURE__ */ Y(N, {
2265
+ open: de,
2083
2266
  onOpenChange: (t) => {
2084
2267
  if (t) {
2085
2268
  e.onOpenChange?.(!0);
2086
2269
  return;
2087
2270
  }
2088
- he(!1);
2271
+ ye(!1);
2089
2272
  },
2090
- children: /* @__PURE__ */ Z(R, {
2091
- className: G(pe, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", c, e.className),
2273
+ children: /* @__PURE__ */ X(I, {
2274
+ className: G(he, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", c, e.className),
2092
2275
  children: [
2093
- (e.title || e.description) && /* @__PURE__ */ Z(I, {
2276
+ (e.title || e.description) && /* @__PURE__ */ X(F, {
2094
2277
  className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
2095
- children: [e.title && /* @__PURE__ */ X(L, { children: e.title }), e.description ? /* @__PURE__ */ X(F, { children: e.description }) : /* @__PURE__ */ X(F, {
2278
+ children: [e.title && /* @__PURE__ */ Y(ee, { children: e.title }), e.description ? /* @__PURE__ */ Y(P, { children: e.description }) : /* @__PURE__ */ Y(P, {
2096
2279
  className: "sr-only",
2097
2280
  children: "Complete the form fields, then submit or cancel."
2098
2281
  })]
2099
2282
  }),
2100
- /* @__PURE__ */ X("div", {
2283
+ /* @__PURE__ */ Y("div", {
2101
2284
  className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
2102
- children: $()
2285
+ children: ke()
2103
2286
  }),
2104
- Ee && /* @__PURE__ */ X("div", {
2287
+ Ne && /* @__PURE__ */ Y("div", {
2105
2288
  className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background",
2106
2289
  "data-testid": "modal-form-footer",
2107
- children: /* @__PURE__ */ Z("div", {
2290
+ children: /* @__PURE__ */ X("div", {
2108
2291
  className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
2109
- children: [be && /* @__PURE__ */ X(O, {
2292
+ children: [we && /* @__PURE__ */ Y(D, {
2110
2293
  type: "button",
2111
2294
  variant: "outline",
2112
- onClick: ge,
2295
+ onClick: be,
2113
2296
  disabled: te,
2114
2297
  className: "w-full sm:w-auto",
2115
- children: Ce
2116
- }), ye && /* @__PURE__ */ Z(O, {
2298
+ children: Ee
2299
+ }), Ce && /* @__PURE__ */ X(D, {
2117
2300
  type: "submit",
2118
- form: de,
2301
+ form: pe,
2119
2302
  disabled: te,
2120
2303
  className: "w-full sm:w-auto",
2121
- children: [te && /* @__PURE__ */ X(fe, { className: "mr-2 h-4 w-4 animate-spin" }), Se]
2304
+ children: [te && /* @__PURE__ */ Y(fe, { className: "mr-2 h-4 w-4 animate-spin" }), Te]
2122
2305
  })]
2123
2306
  })
2124
2307
  }),
2125
- /* @__PURE__ */ X(b, {
2126
- open: se,
2127
- onOpenChange: ce,
2128
- children: /* @__PURE__ */ Z(C, { children: [/* @__PURE__ */ Z(E, { children: [/* @__PURE__ */ X(D, { children: f("form.discardTitle") }), /* @__PURE__ */ X(w, { children: f("form.discardMessage") })] }), /* @__PURE__ */ Z(T, { children: [/* @__PURE__ */ X(S, {
2308
+ /* @__PURE__ */ Y(y, {
2309
+ open: ce,
2310
+ onOpenChange: le,
2311
+ children: /* @__PURE__ */ X(S, { children: [/* @__PURE__ */ X(T, { children: [/* @__PURE__ */ Y(E, { children: m("form.discardTitle") }), /* @__PURE__ */ Y(C, { children: m("form.discardMessage") })] }), /* @__PURE__ */ X(w, { children: [/* @__PURE__ */ Y(x, {
2129
2312
  onClick: () => {
2130
- K.current = !1;
2313
+ q.current = !1;
2131
2314
  },
2132
- children: f("form.keepEditing")
2133
- }), /* @__PURE__ */ X(x, {
2315
+ children: m("form.keepEditing")
2316
+ }), /* @__PURE__ */ Y(b, {
2134
2317
  onClick: Q,
2135
- children: f("form.discard")
2318
+ children: m("form.discard")
2136
2319
  })] })] })
2137
2320
  })
2138
2321
  ]
2139
2322
  })
2140
2323
  });
2141
- };
2142
- //#endregion
2143
- //#region src/fieldGroups.ts
2144
- function Ct(e) {
2145
- return Array.isArray(e) ? e.filter((e) => !!e && typeof e == "object").map((e) => ({
2146
- key: typeof e.key == "string" ? e.key : "",
2147
- label: typeof e.label == "string" ? e.label : void 0,
2148
- collapsible: typeof e.collapsible == "boolean" ? e.collapsible : void 0,
2149
- collapsed: typeof e.collapsed == "boolean" ? e.collapsed : void 0
2150
- })).filter((e) => e.key) : [];
2151
- }
2152
- function wt(e, t) {
2153
- let n = Ct(t);
2154
- if (n.length === 0) return null;
2155
- let r = new Set(n.map((e) => e.key)), i = (e) => {
2156
- let t = e.group;
2157
- return typeof t == "string" && r.has(t) ? t : null;
2158
- };
2159
- if (!e.some((e) => i(e) !== null)) return null;
2160
- let a = /* @__PURE__ */ new Map();
2161
- for (let e of n) a.set(e.key, []);
2162
- let o = [];
2163
- for (let t of e) {
2164
- let e = i(t);
2165
- e ? a.get(e).push(t) : o.push(t);
2166
- }
2167
- let s = [];
2168
- for (let e of n) {
2169
- let t = a.get(e.key);
2170
- t.length !== 0 && s.push({
2171
- name: e.key,
2172
- label: e.label ?? e.key,
2173
- fields: t.map((e) => e.name),
2174
- ...e.collapsible === void 0 ? {} : { collapsible: e.collapsible },
2175
- ...e.collapsed === void 0 ? {} : { collapsed: e.collapsed }
2176
- });
2177
- }
2178
- return o.length > 0 && s.push({ fields: o.map((e) => e.name) }), s;
2179
- }
2180
- //#endregion
2181
- //#region src/ObjectForm.tsx
2182
- var Tt = ({ schema: e, dataSource: t }) => {
2183
- let n = le(), r = a(() => {
2324
+ }, At = ({ schema: e, dataSource: t }) => {
2325
+ let n = se(), r = a(() => {
2184
2326
  if (!n?.isLoaded) return e;
2185
2327
  let t = (t) => t?.name ? n.checkField(e.objectName, t.name, "read") ? !n.checkField(e.objectName, t.name, "write") && e.mode !== "view" ? {
2186
2328
  ...t,
@@ -2196,7 +2338,7 @@ var Tt = ({ schema: e, dataSource: t }) => {
2196
2338
  }))
2197
2339
  };
2198
2340
  }, [e, n]), { sectionLabel: i } = p(), o = (e) => e?.name ? i(r.objectName, e.name, e.label || e.name) : e?.label;
2199
- if (r.subforms?.length && r.mode !== "view" && r.formType !== "drawer" && r.formType !== "modal") return /* @__PURE__ */ X($e, {
2341
+ if (r.subforms?.length && r.mode !== "view" && r.formType !== "drawer" && r.formType !== "modal") return /* @__PURE__ */ Y(St, {
2200
2342
  schema: {
2201
2343
  type: "object-master-detail-form",
2202
2344
  objectName: r.objectName,
@@ -2209,6 +2351,7 @@ var Tt = ({ schema: e, dataSource: t }) => {
2209
2351
  fields: r.fields,
2210
2352
  title: r.title,
2211
2353
  submitText: r.submitText,
2354
+ cancelText: r.cancelText,
2212
2355
  showSubmit: r.showSubmit,
2213
2356
  details: r.subforms,
2214
2357
  onSuccess: r.onSuccess,
@@ -2218,7 +2361,7 @@ var Tt = ({ schema: e, dataSource: t }) => {
2218
2361
  },
2219
2362
  dataSource: t
2220
2363
  });
2221
- if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ X(Se, {
2364
+ if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ Y(Be, {
2222
2365
  schema: {
2223
2366
  ...r,
2224
2367
  formType: "tabbed",
@@ -2235,7 +2378,7 @@ var Tt = ({ schema: e, dataSource: t }) => {
2235
2378
  dataSource: t,
2236
2379
  className: r.className
2237
2380
  });
2238
- if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ X(Ce, {
2381
+ if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ Y(Ve, {
2239
2382
  schema: {
2240
2383
  ...r,
2241
2384
  formType: "wizard",
@@ -2255,7 +2398,7 @@ var Tt = ({ schema: e, dataSource: t }) => {
2255
2398
  dataSource: t,
2256
2399
  className: r.className
2257
2400
  });
2258
- if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ X(we, {
2401
+ if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ Y(He, {
2259
2402
  schema: {
2260
2403
  ...r,
2261
2404
  formType: "split",
@@ -2275,7 +2418,7 @@ var Tt = ({ schema: e, dataSource: t }) => {
2275
2418
  });
2276
2419
  if (r.formType === "drawer") {
2277
2420
  let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
2278
- return /* @__PURE__ */ X(vt, {
2421
+ return /* @__PURE__ */ Y(Tt, {
2279
2422
  schema: {
2280
2423
  ...n,
2281
2424
  layout: i,
@@ -2300,7 +2443,7 @@ var Tt = ({ schema: e, dataSource: t }) => {
2300
2443
  }
2301
2444
  if (r.formType === "modal") {
2302
2445
  let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
2303
- return /* @__PURE__ */ X(St, {
2446
+ return /* @__PURE__ */ Y(kt, {
2304
2447
  schema: {
2305
2448
  ...n,
2306
2449
  layout: i,
@@ -2321,12 +2464,12 @@ var Tt = ({ schema: e, dataSource: t }) => {
2321
2464
  className: r.className
2322
2465
  });
2323
2466
  }
2324
- return /* @__PURE__ */ X(Et, {
2467
+ return /* @__PURE__ */ Y(jt, {
2325
2468
  schema: r,
2326
2469
  dataSource: t
2327
2470
  });
2328
- }, Et = ({ schema: n, dataSource: i }) => {
2329
- let { fieldLabel: a, sectionLabel: o } = p(), c = ce(), u = le(), d = t((e) => {
2471
+ }, jt = ({ schema: n, dataSource: i }) => {
2472
+ let { fieldLabel: a, sectionLabel: o } = p(), c = oe(), u = se(), d = t((e) => {
2330
2473
  if (!u?.isLoaded) return e;
2331
2474
  let t = [];
2332
2475
  for (let r of e) u.checkField(n.objectName, r.name, "read") && (!u.checkField(n.objectName, r.name, "write") && n.mode !== "view" ? t.push({
@@ -2340,15 +2483,15 @@ var Tt = ({ schema: e, dataSource: t }) => {
2340
2483
  u,
2341
2484
  n.objectName,
2342
2485
  n.mode
2343
- ]), [f, m] = s(null), [h, b] = s([]), [x, S] = s(null), [C, w] = s(!0), [T, E] = s(null), D = n.customFields && n.customFields.length > 0;
2486
+ ]), [f, m] = s(null), [h, y] = s([]), [b, x] = s(null), [S, C] = s(!0), [w, T] = s(null), [E, D] = s(null), O = n.customFields && n.customFields.length > 0;
2344
2487
  r(() => {
2345
- D && (S(n.initialData || n.initialValues || {}), w(!1));
2488
+ O && (x(n.initialData || n.initialValues || {}), C(!1));
2346
2489
  }, [
2347
- D,
2490
+ O,
2348
2491
  n.initialData,
2349
2492
  n.initialValues
2350
2493
  ]), r(() => {
2351
- D ? m({
2494
+ O ? m({
2352
2495
  name: n.objectName,
2353
2496
  fields: {}
2354
2497
  }) : n.objectName && i ? (async () => {
@@ -2358,31 +2501,31 @@ var Tt = ({ schema: e, dataSource: t }) => {
2358
2501
  if (!e) throw Error(`No schema found for object "${n.objectName}"`);
2359
2502
  m(e);
2360
2503
  } catch (e) {
2361
- E(e), w(!1);
2504
+ T(e), C(!1);
2362
2505
  }
2363
- })() : D || w(!1);
2506
+ })() : O || C(!1);
2364
2507
  }, [
2365
2508
  n.objectName,
2366
2509
  i,
2367
- D
2510
+ O
2368
2511
  ]), r(() => {
2369
- f && !D && (async () => {
2512
+ f && !O && (async () => {
2370
2513
  if (!n.recordId || n.mode === "create") {
2371
- S(n.initialData || n.initialValues || {}), w(!1);
2514
+ x(n.initialData || n.initialValues || {}), C(!1);
2372
2515
  return;
2373
2516
  }
2374
- if (!D) {
2517
+ if (!O) {
2375
2518
  if (!i) {
2376
- E(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), w(!1);
2519
+ T(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), C(!1);
2377
2520
  return;
2378
2521
  }
2379
- w(!0);
2522
+ C(!0);
2380
2523
  try {
2381
- S(await i.findOne(n.objectName, n.recordId));
2524
+ x(await i.findOne(n.objectName, n.recordId));
2382
2525
  } catch (e) {
2383
- console.error("Failed to fetch record:", e), E(e);
2526
+ console.error("Failed to fetch record:", e), T(e);
2384
2527
  } finally {
2385
- w(!1);
2528
+ C(!1);
2386
2529
  }
2387
2530
  }
2388
2531
  })();
@@ -2394,19 +2537,12 @@ var Tt = ({ schema: e, dataSource: t }) => {
2394
2537
  n.initialData,
2395
2538
  i,
2396
2539
  f,
2397
- D
2540
+ O
2398
2541
  ]);
2399
- let O = t((e) => {
2400
- if (!e || typeof e.visible == "function") return e;
2401
- let t = e.visibleOn;
2402
- return typeof t == "string" && t.trim() ? {
2403
- ...e,
2404
- visible: (e) => _(t, e)
2405
- } : e;
2406
- }, []);
2542
+ let k = t((e) => e, []);
2407
2543
  r(() => {
2408
- if (D && n.customFields) {
2409
- b(n.customFields.map(O)), w(!1);
2544
+ if (O && n.customFields) {
2545
+ y(n.customFields.map(k)), C(!1);
2410
2546
  return;
2411
2547
  }
2412
2548
  if (!f) return;
@@ -2415,16 +2551,16 @@ var Tt = ({ schema: e, dataSource: t }) => {
2415
2551
  let r = typeof t == "string" ? t : t.name;
2416
2552
  if (!r) return;
2417
2553
  let i = f.fields?.[r];
2418
- if (!i && !D) return;
2554
+ if (!i && !O) return;
2419
2555
  let o = !i?.permissions || i?.permissions.write !== !1;
2420
2556
  if (n.mode !== "view" && !o) return;
2421
2557
  let s = n.customFields?.find((e) => e.name === r);
2422
- if (s) e.push(O(s));
2558
+ if (s) e.push(k(s));
2423
2559
  else if (i) {
2424
2560
  let o = {
2425
2561
  name: r,
2426
2562
  label: a(n.objectName, r, i.label || t),
2427
- type: y(i.type),
2563
+ type: v(i.type),
2428
2564
  required: i.required || !1,
2429
2565
  disabled: n.readOnly || n.mode === "view" || i.readonly || f?.managedBy && f.managedBy !== "platform",
2430
2566
  placeholder: i.placeholder,
@@ -2437,29 +2573,30 @@ var Tt = ({ schema: e, dataSource: t }) => {
2437
2573
  field: i
2438
2574
  };
2439
2575
  if ((i.type === "select" || i.type === "lookup" || i.type === "master_detail") && (o.options = i.options || [], o.multiple = i.multiple), (i.type === "number" || i.type === "currency" || i.type === "percent") && (o.inputType = "number", o.min = i.min, o.max = i.max, o.step = i.precision ? 10 ** -i.precision : void 0), i.type === "date" && (o.inputType = "date"), i.type === "datetime" && (o.inputType = "datetime-local"), (i.type === "text" || i.type === "textarea" || i.type === "markdown" || i.type === "html") && (o.maxLength = i.max_length, o.minLength = i.min_length), (i.type === "file" || i.type === "image") && (o.inputType = "file", o.multiple = i.multiple, o.accept = i.accept ? i.accept.join(",") : void 0, i.max_size)) {
2440
- let e = `Max size: ${v(i.max_size)}`;
2576
+ let e = `Max size: ${_(i.max_size)}`;
2441
2577
  o.description = o.description ? `${o.description} (${e})` : e;
2442
2578
  }
2443
- i.type === "email" && (o.inputType = "email"), i.type === "phone" && (o.inputType = "tel"), i.type === "url" && (o.inputType = "url"), i.type === "password" && (o.inputType = "password"), i.type === "time" && (o.inputType = "time"), (i.type === "formula" || i.type === "summary" || i.type === "auto_number") && (o.disabled = !0), i.visible_on && (o.visible = (e) => _(i.visible_on, e)), e.push(o);
2579
+ i.type === "email" && (o.inputType = "email"), i.type === "phone" && (o.inputType = "tel"), i.type === "url" && (o.inputType = "url"), i.type === "password" && (o.inputType = "password"), i.type === "time" && (o.inputType = "time"), (i.type === "formula" || i.type === "summary" || i.type === "auto_number") && (o.disabled = !0), i.visible_on && (o.visibleOn = i.visible_on), e.push(o);
2444
2580
  }
2445
- }), b(e), !D && n.recordId && n.mode !== "create" && i || w(!1);
2581
+ }), y(e), !O && n.recordId && n.mode !== "create" && i || C(!1);
2446
2582
  }, [
2447
2583
  f,
2448
2584
  n.fields,
2449
2585
  n.customFields,
2450
2586
  n.readOnly,
2451
2587
  n.mode,
2452
- D,
2588
+ O,
2453
2589
  n.recordId,
2454
2590
  i
2455
2591
  ]);
2456
- let k = t(async (e, t) => {
2457
- 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 && (e = {})), D && !i) return n.onSuccess && await n.onSuccess(e), e;
2592
+ let A = t(async (e, t) => {
2593
+ 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 && (e = {})), O && !i) return n.onSuccess && await n.onSuccess(e), e;
2458
2594
  if (!i) throw Error("DataSource is required for form submission (inline mode not configured)");
2459
- let r = e;
2460
- if (u?.isLoaded && e && typeof e == "object") {
2461
- r = {};
2462
- for (let t of Object.keys(e)) u.checkField(n.objectName, t, "write") && (r[t] = e[t]);
2595
+ let r = Ge(e, O ? null : f);
2596
+ if (u?.isLoaded && r && typeof r == "object") {
2597
+ let e = {};
2598
+ for (let t of Object.keys(r)) u.checkField(n.objectName, t, "write") && (e[t] = r[t]);
2599
+ r = e;
2463
2600
  }
2464
2601
  try {
2465
2602
  let e;
@@ -2468,10 +2605,26 @@ var Tt = ({ schema: e, dataSource: t }) => {
2468
2605
  else if (n.mode === "edit" && n.recordId) e = await i.update(n.objectName, n.recordId, r);
2469
2606
  else throw Error("Invalid form mode or missing record ID");
2470
2607
  if (n.onSuccess) await n.onSuccess(e);
2471
- else if (!n.submitHandler) {
2472
- let t = ge(n.navigateOnSuccess, e);
2608
+ else if (!n.submitHandler && n.submitBehavior) {
2609
+ let e = n.submitBehavior;
2610
+ switch (e.kind) {
2611
+ case "redirect":
2612
+ ge(e.url) && setTimeout(() => window.location.assign(e.url), e.delayMs ?? 0);
2613
+ break;
2614
+ case "continue": break;
2615
+ default: {
2616
+ let t = e.kind === "thank-you" && e.message ? e.message : n.successMessage || (n.mode === "create" ? "Created" : "Saved");
2617
+ K.success(t), D({
2618
+ title: e.kind === "thank-you" ? e.title : void 0,
2619
+ message: t
2620
+ });
2621
+ break;
2622
+ }
2623
+ }
2624
+ } else if (!n.submitHandler) {
2625
+ let t = _e(n.navigateOnSuccess, e);
2473
2626
  if (t) return window.location.assign(t), e;
2474
- se.success(n.successMessage || (n.mode === "create" ? "Created" : "Saved"));
2627
+ K.success(n.successMessage || (n.mode === "create" ? "Created" : "Saved"));
2475
2628
  }
2476
2629
  return e;
2477
2630
  } catch (e) {
@@ -2480,11 +2633,12 @@ var Tt = ({ schema: e, dataSource: t }) => {
2480
2633
  }, [
2481
2634
  n,
2482
2635
  i,
2483
- D,
2484
- u
2485
- ]), A = t(() => {
2636
+ O,
2637
+ u,
2638
+ f
2639
+ ]), j = t(() => {
2486
2640
  n.onCancel && n.onCancel();
2487
- }, [n]), j = {
2641
+ }, [n]), M = {
2488
2642
  ...e.useMemo(() => {
2489
2643
  if (!f?.fields) return {};
2490
2644
  let e = {};
@@ -2493,89 +2647,117 @@ var Tt = ({ schema: e, dataSource: t }) => {
2493
2647
  n.defaultValue !== void 0 && (e[t] = n.defaultValue);
2494
2648
  }), e;
2495
2649
  }, [f]),
2496
- ...x
2497
- }, M = e.useMemo(() => n.sections?.length ? null : wt(h, f?.fieldGroups), [
2498
- n.sections,
2650
+ ...b
2651
+ }, N = e.useMemo(() => {
2652
+ let e = Me(h, f);
2653
+ return n.mode === "create" && (e = Pe(e, f)), e;
2654
+ }, [
2499
2655
  h,
2656
+ f,
2657
+ n.mode
2658
+ ]), P = e.useMemo(() => n.sections?.length ? null : Et(N, f?.fieldGroups), [
2659
+ n.sections,
2660
+ N,
2500
2661
  f
2501
- ]), N = n.sections?.length ? n.sections : M, [P, F] = s({});
2502
- if (T) return /* @__PURE__ */ Z("div", {
2662
+ ]), F = n.sections?.length ? n.sections : P, [ee, I] = s({});
2663
+ if (w) return /* @__PURE__ */ X("div", {
2503
2664
  className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
2504
- children: [/* @__PURE__ */ X("h3", {
2665
+ children: [/* @__PURE__ */ Y("h3", {
2505
2666
  className: "text-red-800 font-semibold",
2506
2667
  children: "Error loading form"
2507
- }), /* @__PURE__ */ X("p", {
2668
+ }), /* @__PURE__ */ Y("p", {
2508
2669
  className: "text-red-600 text-sm mt-1",
2509
- children: T.message
2670
+ children: w.message
2510
2671
  })]
2511
2672
  });
2512
- if (C) return /* @__PURE__ */ Z("div", {
2673
+ if (S) return /* @__PURE__ */ X("div", {
2513
2674
  className: "p-4 sm:p-8 text-center",
2514
- children: [/* @__PURE__ */ X("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ X("p", {
2675
+ children: [/* @__PURE__ */ Y("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Y("p", {
2515
2676
  className: "mt-2 text-sm text-gray-600",
2516
2677
  children: "Loading form..."
2517
2678
  })]
2518
2679
  });
2519
- let I = n.layout === "vertical" || n.layout === "horizontal" ? n.layout : "vertical";
2520
- if (N?.length && (!n.formType || n.formType === "simple")) {
2521
- let e = [];
2522
- return N.forEach((t, r) => {
2523
- let i = t.fields.map((e) => typeof e == "string" ? e : e.field ?? e.name), a = d(h.filter((e) => i.includes(e.name)));
2524
- if (a.length === 0) return;
2525
- let s = t.name || t.label || String(r), c = t.name ? o(n.objectName, t.name, t.label || t.name) : t.label, l = P[s] ?? t.collapsed ?? !1;
2526
- c && e.push({
2527
- name: `__section_${s}`,
2528
- label: c,
2680
+ if (E) return /* @__PURE__ */ X("div", {
2681
+ className: "rounded-md border bg-card p-6 sm:p-8 text-center",
2682
+ children: [/* @__PURE__ */ Y("h3", {
2683
+ className: "text-lg font-semibold",
2684
+ children: E.title ?? "Thanks!"
2685
+ }), E.message && /* @__PURE__ */ Y("p", {
2686
+ className: "mt-2 text-sm text-muted-foreground",
2687
+ children: E.message
2688
+ })]
2689
+ });
2690
+ let L = n.layout === "vertical" || n.layout === "horizontal" ? n.layout : "vertical";
2691
+ if (F?.length && (!n.formType || n.formType === "simple")) {
2692
+ let e = P ? N : h, t = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, r = F.map((e) => t(e.columns)).filter((e) => e != null), i = F.reduce((e, t) => e + (Array.isArray(t.fields) ? t.fields.length : 0), 0), a = t(n.columns) ?? (r.length ? Math.max(...r) : De(i)), s = [];
2693
+ F.forEach((r, i) => {
2694
+ let c = new Map(r.fields.map((e) => [typeof e == "string" ? e : e.field ?? e.name, e])), l = Array.from(c.keys()), u = d(e.filter((e) => l.includes(e.name))).map((e) => {
2695
+ let t = c.get(e.name);
2696
+ if (!t || typeof t != "object") return e;
2697
+ let n = t, r = { ...e };
2698
+ return n.visibleOn != null && (r.visibleOn = n.visibleOn), n.colSpan != null && (r.colSpan = n.colSpan), n.span != null && (r.span = n.span), r;
2699
+ });
2700
+ if (u.length === 0) return;
2701
+ let f = r.name || r.label || String(i), p = r.name ? o(n.objectName, r.name, r.label || r.name) : r.label, m = ee[f] ?? r.collapsed ?? !1;
2702
+ p && s.push({
2703
+ name: `__section_${f}`,
2704
+ label: p,
2529
2705
  type: "section-divider",
2530
2706
  colSpan: 4,
2531
- collapsible: t.collapsible,
2532
- collapsed: l,
2533
- onToggle: t.collapsible ? () => F((e) => ({
2707
+ collapsible: r.collapsible,
2708
+ collapsed: m,
2709
+ onToggle: r.collapsible ? () => I((e) => ({
2534
2710
  ...e,
2535
- [s]: !l
2711
+ [f]: !m
2536
2712
  })) : void 0
2537
- }), c && l ? e.push(...a.map((e) => ({
2713
+ });
2714
+ let h = t(r.columns), g = a > 1 ? Ae(u, a, h) : u;
2715
+ p && m ? s.push(...g.map((e) => ({
2538
2716
  ...e,
2539
2717
  hidden: !0
2540
- }))) : e.push(...a);
2541
- }), /* @__PURE__ */ X("div", {
2542
- className: "w-full",
2543
- children: /* @__PURE__ */ X(l, { schema: {
2718
+ }))) : s.push(...g);
2719
+ });
2720
+ let c = s, u = Ie(a);
2721
+ return /* @__PURE__ */ Y("div", {
2722
+ className: "w-full @container",
2723
+ children: /* @__PURE__ */ Y(l, { schema: {
2544
2724
  type: "form",
2545
2725
  objectName: n.objectName,
2546
- fields: e,
2547
- layout: I,
2548
- defaultValues: j,
2726
+ fields: c,
2727
+ layout: L,
2728
+ columns: a,
2729
+ ...u ? { fieldContainerClass: u } : {},
2730
+ defaultValues: M,
2549
2731
  showSubmit: n.showSubmit !== !1 && n.mode !== "view",
2550
2732
  showCancel: n.showCancel !== !1,
2551
2733
  submitLabel: n.submitText || (n.mode === "create" ? "Create" : "Update"),
2552
2734
  cancelLabel: n.cancelText,
2553
- onSubmit: k,
2554
- onCancel: A
2735
+ onSubmit: A,
2736
+ onCancel: j
2555
2737
  } })
2556
2738
  });
2557
2739
  }
2558
- let L = n.sections?.length, R = d(h), z = L ? {
2559
- fields: R,
2740
+ let R = n.sections?.length, z = d(h), B = R ? {
2741
+ fields: z,
2560
2742
  columns: n.columns
2561
- } : ft(R, f, n.columns, n.mode), B = n.mobile, V = B?.fullscreenLongText ? z.fields.map((e) => {
2743
+ } : ze(z, f, n.columns, n.mode), V = n.mobile, H = V?.fullscreenLongText ? B.fields.map((e) => {
2562
2744
  let t = e.type;
2563
2745
  return t === "textarea" || t === "field:textarea" || t === "string-multiline" || t === "field:markdown" || t === "field:html" ? {
2564
2746
  ...e,
2565
2747
  mobile_fullscreen: !0
2566
2748
  } : e;
2567
- }) : z.fields, ee = B?.stepper, te = B?.stepperMinFields ?? 8, H = Math.max(1, B?.stepperFieldsPerStep ?? 1);
2568
- if (!n.formType && !L && V.length >= 2 && (ee === !0 || ee === "auto" && c && V.length >= te)) {
2569
- let e = V, t = [];
2570
- for (let n = 0; n < e.length; n += H) {
2571
- let r = e.slice(n, n + H);
2749
+ }) : B.fields, te = V?.stepper, ne = V?.stepperMinFields ?? 8, U = Math.max(1, V?.stepperFieldsPerStep ?? 1);
2750
+ if (!n.formType && !R && H.length >= 2 && (te === !0 || te === "auto" && c && H.length >= ne)) {
2751
+ let e = H, t = [];
2752
+ for (let n = 0; n < e.length; n += U) {
2753
+ let r = e.slice(n, n + U);
2572
2754
  t.push({
2573
- name: `step-${Math.floor(n / H) + 1}`,
2574
- label: r[0]?.label || r[0]?.name || `Step ${Math.floor(n / H) + 1}`,
2755
+ name: `step-${Math.floor(n / U) + 1}`,
2756
+ label: r[0]?.label || r[0]?.name || `Step ${Math.floor(n / U) + 1}`,
2575
2757
  fields: r
2576
2758
  });
2577
2759
  }
2578
- return /* @__PURE__ */ X(Ce, {
2760
+ return /* @__PURE__ */ Y(Ve, {
2579
2761
  schema: {
2580
2762
  ...n,
2581
2763
  formType: "wizard",
@@ -2586,29 +2768,29 @@ var Tt = ({ schema: e, dataSource: t }) => {
2586
2768
  className: n.className
2587
2769
  });
2588
2770
  }
2589
- let U = {
2771
+ let W = {
2590
2772
  type: "form",
2591
2773
  objectName: n.objectName,
2592
- fields: V,
2593
- layout: I,
2594
- columns: z.columns,
2774
+ fields: H,
2775
+ layout: L,
2776
+ columns: B.columns,
2595
2777
  submitLabel: n.submitText || (n.mode === "create" ? "Create" : "Update"),
2596
2778
  cancelLabel: n.cancelText,
2597
2779
  showSubmit: n.showSubmit !== !1 && n.mode !== "view",
2598
2780
  showCancel: n.showCancel !== !1,
2599
- resetOnSubmit: n.showReset || n.resetOnSuccess && n.mode === "create",
2600
- defaultValues: j,
2601
- onSubmit: k,
2602
- onCancel: A,
2781
+ resetOnSubmit: n.showReset || n.submitBehavior?.kind === "continue" || !n.submitBehavior && n.resetOnSuccess && n.mode === "create",
2782
+ defaultValues: M,
2783
+ onSubmit: A,
2784
+ onCancel: j,
2603
2785
  className: n.className,
2604
- mobileStickyActions: !!B?.stickyActions
2786
+ mobileStickyActions: !!V?.stickyActions
2605
2787
  };
2606
- return /* @__PURE__ */ X("div", {
2607
- className: B?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
2608
- "data-mobile-form": B ? "true" : void 0,
2609
- children: /* @__PURE__ */ X(l, { schema: U })
2788
+ return /* @__PURE__ */ Y("div", {
2789
+ className: V?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
2790
+ "data-mobile-form": V ? "true" : void 0,
2791
+ children: /* @__PURE__ */ Y(l, { schema: W })
2610
2792
  });
2611
- }, Dt = {
2793
+ }, Mt = {
2612
2794
  text: 200,
2613
2795
  email: 254,
2614
2796
  url: 2048,
@@ -2616,8 +2798,8 @@ var Tt = ({ schema: e, dataSource: t }) => {
2616
2798
  textarea: 5e3,
2617
2799
  markdown: 5e3,
2618
2800
  html: 5e3
2619
- }, Ot = "_company_website_2", kt = 1500;
2620
- function At(e, t = []) {
2801
+ }, Nt = "_company_website_2", Pt = 1500;
2802
+ function Ft(e, t = []) {
2621
2803
  try {
2622
2804
  let n = new URL(e, typeof window < "u" ? window.location.href : "http://localhost");
2623
2805
  return typeof window < "u" && n.origin === window.location.origin ? !0 : n.protocol !== "https:" && n.protocol !== "http:" ? !1 : t.some((e) => {
@@ -2632,21 +2814,21 @@ function At(e, t = []) {
2632
2814
  return !1;
2633
2815
  }
2634
2816
  }
2635
- function jt(e) {
2817
+ function It(e) {
2636
2818
  return e && e.map((e) => {
2637
- let t = Dt[String(e.type || "").toLowerCase()];
2819
+ let t = Mt[String(e.type || "").toLowerCase()];
2638
2820
  return !t || (e.maxLength ?? e.max_length) ? e : {
2639
2821
  ...e,
2640
2822
  maxLength: t
2641
2823
  };
2642
2824
  });
2643
2825
  }
2644
- var Mt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
2826
+ var Lt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
2645
2827
  let [l, u] = s(!1), [d, f] = s(!1), [p, m] = s(null), [h, g] = s(!(e.consent?.required ?? !!e.consent)), [_, v] = s(null), y = o(null), b = o(0);
2646
2828
  r(() => {
2647
2829
  l || (b.current = Date.now());
2648
2830
  }, [l]);
2649
- let x = e.honeypot === !1 ? null : e.honeypot || Ot, S = e.minFillTime ?? kt, C = a(() => jt(e.customFields), [e.customFields]), w = a(() => {
2831
+ let x = e.honeypot === !1 ? null : e.honeypot || Nt, S = e.minFillTime ?? Pt, C = a(() => It(e.customFields), [e.customFields]), w = a(() => {
2650
2832
  if (!n || C && C.length > 0 || !e.fields || e.fields.length === 0) return;
2651
2833
  let t = async (e, t) => t;
2652
2834
  return {
@@ -2687,7 +2869,7 @@ var Mt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
2687
2869
  try {
2688
2870
  n && await n.create(e.objectName, r), u(!0);
2689
2871
  let t = e.thankYouPage?.redirectUrl;
2690
- if (t) if (At(t, e.allowedRedirectHosts)) {
2872
+ if (t) if (Ft(t, e.allowedRedirectHosts)) {
2691
2873
  let n = e.thankYouPage?.redirectDelay ?? 3e3;
2692
2874
  setTimeout(() => {
2693
2875
  window.location.href = t;
@@ -2704,7 +2886,7 @@ var Mt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
2704
2886
  h,
2705
2887
  x,
2706
2888
  S
2707
- ]), D = t(() => {
2889
+ ]), O = t(() => {
2708
2890
  u(!1), m(null);
2709
2891
  }, []), k = a(() => {
2710
2892
  let t = {};
@@ -2712,35 +2894,35 @@ var Mt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
2712
2894
  }, [e.branding]);
2713
2895
  if (l) {
2714
2896
  let t = e.thankYouPage, n = e.texts ?? {}, r = Math.ceil((t?.redirectDelay ?? 3e3) / 1e3), i = (n.redirecting ?? "Redirecting in {{seconds}} seconds…").replace("{{seconds}}", String(r));
2715
- return /* @__PURE__ */ X("div", {
2897
+ return /* @__PURE__ */ Y("div", {
2716
2898
  className: `min-h-screen flex items-center justify-center p-4 bg-gradient-to-b from-muted/40 via-background to-background ${c || ""}`,
2717
2899
  style: k,
2718
- children: /* @__PURE__ */ Z("div", {
2900
+ children: /* @__PURE__ */ X("div", {
2719
2901
  className: "max-w-md w-full bg-card border rounded-xl shadow-sm p-8 text-center space-y-4",
2720
2902
  children: [
2721
- /* @__PURE__ */ X("div", {
2903
+ /* @__PURE__ */ Y("div", {
2722
2904
  className: "mx-auto inline-flex h-14 w-14 items-center justify-center rounded-full bg-emerald-50 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400",
2723
- children: /* @__PURE__ */ X(q, {
2905
+ children: /* @__PURE__ */ Y(le, {
2724
2906
  className: "h-8 w-8",
2725
2907
  "aria-hidden": "true"
2726
2908
  })
2727
2909
  }),
2728
- /* @__PURE__ */ X("h2", {
2910
+ /* @__PURE__ */ Y("h2", {
2729
2911
  className: "text-xl font-semibold text-foreground",
2730
2912
  children: t?.title || n.thankYouTitle || "Thank You!"
2731
2913
  }),
2732
- /* @__PURE__ */ X("p", {
2914
+ /* @__PURE__ */ Y("p", {
2733
2915
  className: "text-sm text-muted-foreground",
2734
2916
  children: t?.message || n.thankYouMessage || "Your submission has been received successfully."
2735
2917
  }),
2736
- e.allowMultiple && /* @__PURE__ */ X(O, {
2918
+ e.allowMultiple && /* @__PURE__ */ Y(D, {
2737
2919
  variant: "outline",
2738
2920
  size: "sm",
2739
- onClick: D,
2921
+ onClick: O,
2740
2922
  className: "mt-2",
2741
2923
  children: n.submitAnother ?? "Submit Another Response"
2742
2924
  }),
2743
- t?.redirectUrl && /* @__PURE__ */ X("p", {
2925
+ t?.redirectUrl && /* @__PURE__ */ Y("p", {
2744
2926
  className: "text-xs text-muted-foreground",
2745
2927
  children: i
2746
2928
  })
@@ -2749,51 +2931,51 @@ var Mt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
2749
2931
  });
2750
2932
  }
2751
2933
  let A = e.texts ?? {}, j = !!e.consent?.required, M = `${e.formId}-consent`;
2752
- return /* @__PURE__ */ X("div", {
2934
+ return /* @__PURE__ */ Y("div", {
2753
2935
  className: `min-h-screen flex items-center justify-center p-4 sm:p-6 bg-gradient-to-b from-muted/40 via-background to-background ${c || ""}`,
2754
2936
  style: k,
2755
- children: /* @__PURE__ */ Z("div", {
2937
+ children: /* @__PURE__ */ X("div", {
2756
2938
  className: "max-w-2xl w-full bg-card border rounded-xl shadow-sm overflow-hidden",
2757
2939
  children: [
2758
- e.branding?.coverImage && /* @__PURE__ */ X("div", {
2940
+ e.branding?.coverImage && /* @__PURE__ */ Y("div", {
2759
2941
  className: "h-28 sm:h-32 w-full bg-cover bg-center",
2760
2942
  style: { backgroundImage: `url(${JSON.stringify(e.branding.coverImage)})` },
2761
2943
  role: "presentation"
2762
2944
  }),
2763
- /* @__PURE__ */ Z("div", {
2945
+ /* @__PURE__ */ X("div", {
2764
2946
  className: "px-6 sm:px-8 pt-7 pb-5 border-b bg-muted/20",
2765
2947
  style: e.branding?.primaryColor ? { borderBottomColor: e.branding.primaryColor } : void 0,
2766
2948
  children: [
2767
- e.branding?.logo && /* @__PURE__ */ X("img", {
2949
+ e.branding?.logo && /* @__PURE__ */ Y("img", {
2768
2950
  src: e.branding.logo,
2769
2951
  alt: "",
2770
2952
  className: "h-8 mb-4"
2771
2953
  }),
2772
- e.title && /* @__PURE__ */ X("h1", {
2954
+ e.title && /* @__PURE__ */ Y("h1", {
2773
2955
  className: "text-2xl font-semibold tracking-tight text-foreground",
2774
2956
  children: e.title
2775
2957
  }),
2776
- e.description && /* @__PURE__ */ X("p", {
2958
+ e.description && /* @__PURE__ */ Y("p", {
2777
2959
  className: "text-sm text-muted-foreground mt-2 leading-relaxed",
2778
2960
  children: e.description
2779
2961
  }),
2780
- /* @__PURE__ */ X("p", {
2962
+ /* @__PURE__ */ Y("p", {
2781
2963
  className: "text-[11px] text-muted-foreground/70 mt-3",
2782
2964
  "aria-hidden": "true",
2783
2965
  children: A.requiredHint ?? "* Required field"
2784
2966
  })
2785
2967
  ]
2786
2968
  }),
2787
- /* @__PURE__ */ Z("div", {
2969
+ /* @__PURE__ */ X("div", {
2788
2970
  className: "relative px-6 sm:px-8 py-6",
2789
2971
  children: [
2790
- p && /* @__PURE__ */ X("div", {
2972
+ p && /* @__PURE__ */ Y("div", {
2791
2973
  role: "alert",
2792
2974
  "aria-live": "assertive",
2793
2975
  className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
2794
2976
  children: p
2795
2977
  }),
2796
- /* @__PURE__ */ X(Tt, {
2978
+ /* @__PURE__ */ Y(At, {
2797
2979
  schema: {
2798
2980
  type: "object-form",
2799
2981
  objectName: e.objectName,
@@ -2806,13 +2988,13 @@ var Mt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
2806
2988
  },
2807
2989
  dataSource: w
2808
2990
  }),
2809
- x && /* @__PURE__ */ Z("div", {
2991
+ x && /* @__PURE__ */ X("div", {
2810
2992
  "aria-hidden": "true",
2811
2993
  className: "absolute left-[-10000px] top-auto h-px w-px overflow-hidden",
2812
- children: [/* @__PURE__ */ X("label", {
2994
+ children: [/* @__PURE__ */ Y("label", {
2813
2995
  htmlFor: `${e.formId}-${x}`,
2814
2996
  children: "Do not fill this field"
2815
- }), /* @__PURE__ */ X("input", {
2997
+ }), /* @__PURE__ */ Y("input", {
2816
2998
  ref: y,
2817
2999
  id: `${e.formId}-${x}`,
2818
3000
  type: "text",
@@ -2822,11 +3004,11 @@ var Mt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
2822
3004
  defaultValue: ""
2823
3005
  })]
2824
3006
  }),
2825
- e.consent && /* @__PURE__ */ Z("div", {
3007
+ e.consent && /* @__PURE__ */ X("div", {
2826
3008
  className: "mt-4",
2827
- children: [/* @__PURE__ */ Z("label", {
3009
+ children: [/* @__PURE__ */ X("label", {
2828
3010
  className: "flex items-start gap-2 text-sm text-foreground cursor-pointer select-none",
2829
- children: [/* @__PURE__ */ X("input", {
3011
+ children: [/* @__PURE__ */ Y("input", {
2830
3012
  type: "checkbox",
2831
3013
  id: M,
2832
3014
  checked: h,
@@ -2837,16 +3019,16 @@ var Mt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
2837
3019
  "aria-invalid": _ ? "true" : void 0,
2838
3020
  "aria-describedby": _ ? `${M}-error` : void 0,
2839
3021
  className: "mt-0.5 h-4 w-4 rounded border-input accent-primary"
2840
- }), /* @__PURE__ */ Z("span", {
3022
+ }), /* @__PURE__ */ X("span", {
2841
3023
  className: "leading-relaxed",
2842
3024
  children: [
2843
3025
  e.consent.label ?? A.consentLabelDefault ?? "I agree to the privacy policy.",
2844
- j && /* @__PURE__ */ X("span", {
3026
+ j && /* @__PURE__ */ Y("span", {
2845
3027
  "aria-hidden": "true",
2846
3028
  className: "text-destructive ml-0.5",
2847
3029
  children: "*"
2848
3030
  }),
2849
- e.consent.privacyUrl && /* @__PURE__ */ Z(Y, { children: [" ", /* @__PURE__ */ X("a", {
3031
+ e.consent.privacyUrl && /* @__PURE__ */ X(J, { children: [" ", /* @__PURE__ */ Y("a", {
2850
3032
  href: e.consent.privacyUrl,
2851
3033
  target: "_blank",
2852
3034
  rel: "noopener noreferrer",
@@ -2855,42 +3037,42 @@ var Mt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
2855
3037
  })] })
2856
3038
  ]
2857
3039
  })]
2858
- }), _ && /* @__PURE__ */ X("p", {
3040
+ }), _ && /* @__PURE__ */ Y("p", {
2859
3041
  id: `${M}-error`,
2860
3042
  role: "alert",
2861
3043
  className: "mt-1.5 text-xs text-destructive",
2862
3044
  children: _
2863
3045
  })]
2864
3046
  }),
2865
- d && /* @__PURE__ */ Z("div", {
3047
+ d && /* @__PURE__ */ X("div", {
2866
3048
  className: "mt-3 flex items-center gap-2 text-xs text-muted-foreground",
2867
- children: [/* @__PURE__ */ X(fe, {
3049
+ children: [/* @__PURE__ */ Y(fe, {
2868
3050
  className: "h-3.5 w-3.5 animate-spin",
2869
3051
  "aria-hidden": "true"
2870
- }), /* @__PURE__ */ X("span", { children: A.submitting ?? "Submitting…" })]
3052
+ }), /* @__PURE__ */ Y("span", { children: A.submitting ?? "Submitting…" })]
2871
3053
  })
2872
3054
  ]
2873
3055
  }),
2874
- /* @__PURE__ */ Z("div", {
3056
+ /* @__PURE__ */ X("div", {
2875
3057
  className: "px-6 sm:px-8 py-4 border-t bg-muted/20 flex flex-col sm:flex-row items-center justify-between gap-2",
2876
- children: [/* @__PURE__ */ Z("p", {
3058
+ children: [/* @__PURE__ */ X("p", {
2877
3059
  className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground",
2878
- children: [/* @__PURE__ */ X(pe, {
3060
+ children: [/* @__PURE__ */ Y(pe, {
2879
3061
  className: "h-3 w-3",
2880
3062
  "aria-hidden": "true"
2881
- }), /* @__PURE__ */ X("span", { children: A.secureNotice ?? "Your information is transmitted securely and only used to respond to your request." })]
2882
- }), /* @__PURE__ */ Z("div", {
3063
+ }), /* @__PURE__ */ Y("span", { children: A.secureNotice ?? "Your information is transmitted securely and only used to respond to your request." })]
3064
+ }), /* @__PURE__ */ X("div", {
2883
3065
  className: "flex items-center gap-3 text-xs text-muted-foreground/80",
2884
- children: [e.privacyPolicyUrl && /* @__PURE__ */ Z("a", {
3066
+ children: [e.privacyPolicyUrl && /* @__PURE__ */ X("a", {
2885
3067
  href: e.privacyPolicyUrl,
2886
3068
  target: "_blank",
2887
3069
  rel: "noopener noreferrer",
2888
3070
  className: "inline-flex items-center gap-1 underline hover:text-foreground",
2889
- children: [/* @__PURE__ */ X(me, {
3071
+ children: [/* @__PURE__ */ Y(me, {
2890
3072
  className: "h-3 w-3",
2891
3073
  "aria-hidden": "true"
2892
3074
  }), A.consentLink ?? "Privacy policy"]
2893
- }), /* @__PURE__ */ X("span", { children: A.poweredBy ?? "Powered by ObjectStack" })]
3075
+ }), /* @__PURE__ */ Y("span", { children: A.poweredBy ?? "Powered by ObjectStack" })]
2894
3076
  })]
2895
3077
  })
2896
3078
  ]
@@ -2899,96 +3081,96 @@ var Mt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
2899
3081
  };
2900
3082
  //#endregion
2901
3083
  //#region src/FormAnalytics.tsx
2902
- function Nt(e) {
3084
+ function Rt(e) {
2903
3085
  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`;
2904
3086
  }
2905
- var Pt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
3087
+ var zt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
2906
3088
  let i = a(() => {
2907
3089
  if (!n.abandonedSubmissions) return 100;
2908
3090
  let e = n.totalSubmissions + n.abandonedSubmissions;
2909
3091
  return e === 0 ? 0 : Math.round(n.totalSubmissions / e * 100);
2910
3092
  }, [n.totalSubmissions, n.abandonedSubmissions]), o = a(() => n.dailySubmissions?.length ? Math.max(...n.dailySubmissions.map((e) => e.count), 1) : 1, [n.dailySubmissions]);
2911
- return /* @__PURE__ */ Z("div", {
3093
+ return /* @__PURE__ */ X("div", {
2912
3094
  className: `space-y-4 ${r || ""}`,
2913
3095
  children: [
2914
- /* @__PURE__ */ Z("div", { children: [/* @__PURE__ */ X("h2", {
3096
+ /* @__PURE__ */ X("div", { children: [/* @__PURE__ */ Y("h2", {
2915
3097
  className: "text-lg font-semibold text-foreground",
2916
3098
  children: t || "Form Analytics"
2917
- }), /* @__PURE__ */ Z("p", {
3099
+ }), /* @__PURE__ */ X("p", {
2918
3100
  className: "text-sm text-muted-foreground",
2919
3101
  children: ["Form ID: ", e]
2920
3102
  })] }),
2921
- /* @__PURE__ */ Z("div", {
3103
+ /* @__PURE__ */ X("div", {
2922
3104
  className: "grid grid-cols-1 sm:grid-cols-3 gap-4",
2923
3105
  children: [
2924
- /* @__PURE__ */ X(k, { children: /* @__PURE__ */ Z(M, {
3106
+ /* @__PURE__ */ Y(O, { children: /* @__PURE__ */ X(j, {
2925
3107
  className: "pb-2",
2926
- children: [/* @__PURE__ */ X(j, { children: "Total Submissions" }), /* @__PURE__ */ X(N, {
3108
+ children: [/* @__PURE__ */ Y(A, { children: "Total Submissions" }), /* @__PURE__ */ Y(M, {
2927
3109
  className: "text-2xl",
2928
3110
  children: n.totalSubmissions.toLocaleString()
2929
3111
  })]
2930
3112
  }) }),
2931
- /* @__PURE__ */ Z(k, { children: [/* @__PURE__ */ Z(M, {
3113
+ /* @__PURE__ */ X(O, { children: [/* @__PURE__ */ X(j, {
2932
3114
  className: "pb-2",
2933
- children: [/* @__PURE__ */ X(j, { children: "Fill Rate" }), /* @__PURE__ */ Z(N, {
3115
+ children: [/* @__PURE__ */ Y(A, { children: "Fill Rate" }), /* @__PURE__ */ X(M, {
2934
3116
  className: "text-2xl",
2935
3117
  children: [i, "%"]
2936
3118
  })]
2937
- }), /* @__PURE__ */ X(A, { children: /* @__PURE__ */ X("div", {
3119
+ }), /* @__PURE__ */ Y(k, { children: /* @__PURE__ */ Y("div", {
2938
3120
  className: "w-full bg-muted rounded-full h-2",
2939
- children: /* @__PURE__ */ X("div", {
3121
+ children: /* @__PURE__ */ Y("div", {
2940
3122
  className: "bg-primary rounded-full h-2 transition-all",
2941
3123
  style: { width: `${i}%` }
2942
3124
  })
2943
3125
  }) })] }),
2944
- /* @__PURE__ */ X(k, { children: /* @__PURE__ */ Z(M, {
3126
+ /* @__PURE__ */ Y(O, { children: /* @__PURE__ */ X(j, {
2945
3127
  className: "pb-2",
2946
- children: [/* @__PURE__ */ X(j, { children: "Avg. Completion Time" }), /* @__PURE__ */ X(N, {
3128
+ children: [/* @__PURE__ */ Y(A, { children: "Avg. Completion Time" }), /* @__PURE__ */ Y(M, {
2947
3129
  className: "text-2xl",
2948
- children: n.avgCompletionTime ? Nt(n.avgCompletionTime) : "—"
3130
+ children: n.avgCompletionTime ? Rt(n.avgCompletionTime) : "—"
2949
3131
  })]
2950
3132
  }) })
2951
3133
  ]
2952
3134
  }),
2953
- n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ Z(k, { children: [/* @__PURE__ */ X(M, { children: /* @__PURE__ */ X(N, {
3135
+ n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ X(O, { children: [/* @__PURE__ */ Y(j, { children: /* @__PURE__ */ Y(M, {
2954
3136
  className: "text-sm font-medium",
2955
3137
  children: "Daily Submissions"
2956
- }) }), /* @__PURE__ */ X(A, { children: /* @__PURE__ */ X("div", {
3138
+ }) }), /* @__PURE__ */ Y(k, { children: /* @__PURE__ */ Y("div", {
2957
3139
  className: "flex items-end gap-1 h-32",
2958
- children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ Z("div", {
3140
+ children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ X("div", {
2959
3141
  className: "flex-1 flex flex-col items-center gap-1",
2960
- children: [/* @__PURE__ */ X("div", {
3142
+ children: [/* @__PURE__ */ Y("div", {
2961
3143
  className: "w-full bg-primary/80 rounded-t transition-all hover:bg-primary",
2962
3144
  style: {
2963
3145
  height: `${e.count / o * 100}%`,
2964
3146
  minHeight: e.count > 0 ? "4px" : "0"
2965
3147
  },
2966
3148
  title: `${e.date}: ${e.count} submissions`
2967
- }), /* @__PURE__ */ X("span", {
3149
+ }), /* @__PURE__ */ Y("span", {
2968
3150
  className: "text-[10px] text-muted-foreground truncate w-full text-center",
2969
3151
  children: e.date.slice(-5)
2970
3152
  })]
2971
3153
  }, t))
2972
3154
  }) })] }),
2973
- n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ Z(k, { children: [/* @__PURE__ */ Z(M, { children: [/* @__PURE__ */ X(N, {
3155
+ n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ X(O, { children: [/* @__PURE__ */ X(j, { children: [/* @__PURE__ */ Y(M, {
2974
3156
  className: "text-sm font-medium",
2975
3157
  children: "Field Completion Rates"
2976
- }), /* @__PURE__ */ X(j, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ X(A, { children: /* @__PURE__ */ X("div", {
3158
+ }), /* @__PURE__ */ Y(A, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ Y(k, { children: /* @__PURE__ */ Y("div", {
2977
3159
  className: "space-y-3",
2978
- children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ Z("div", {
3160
+ children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ X("div", {
2979
3161
  className: "space-y-1",
2980
- children: [/* @__PURE__ */ Z("div", {
3162
+ children: [/* @__PURE__ */ X("div", {
2981
3163
  className: "flex justify-between text-sm",
2982
- children: [/* @__PURE__ */ X("span", {
3164
+ children: [/* @__PURE__ */ Y("span", {
2983
3165
  className: "text-foreground",
2984
3166
  children: e.label
2985
- }), /* @__PURE__ */ Z("span", {
3167
+ }), /* @__PURE__ */ X("span", {
2986
3168
  className: "text-muted-foreground",
2987
3169
  children: [e.completionRate, "%"]
2988
3170
  })]
2989
- }), /* @__PURE__ */ X("div", {
3171
+ }), /* @__PURE__ */ Y("div", {
2990
3172
  className: "w-full bg-muted rounded-full h-1.5",
2991
- children: /* @__PURE__ */ X("div", {
3173
+ children: /* @__PURE__ */ Y("div", {
2992
3174
  className: `rounded-full h-1.5 transition-all ${e.completionRate >= 80 ? "bg-green-500" : e.completionRate >= 50 ? "bg-yellow-500" : "bg-destructive"}`,
2993
3175
  style: { width: `${e.completionRate}%` }
2994
3176
  })
@@ -2997,8 +3179,21 @@ var Pt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
2997
3179
  }) })] })
2998
3180
  ]
2999
3181
  });
3000
- }, Ft = ({ schema: e }) => {
3001
- let n = m()?.dataSource, i = f(), o = e.parentObject || i?.objectName, c = e.parentId || e.recordId || i?.recordId, [l, u] = s([]), [d, p] = s([]), [g, _] = s(!0), [v, y] = s(!1), [b, x] = s(!1), [S, C] = s(null), w = t(async () => {
3182
+ }, Bt = ({ schema: e }) => {
3183
+ let n = m()?.dataSource, i = f(), o = e.parentObject || i?.objectName, c = e.parentId || e.recordId || i?.recordId, [l, u] = s([]), [d, p] = s([]), [g, _] = s(!0), [v, y] = s(!1), [b, x] = s(!1), [S, C] = s(null), [w, T] = s(null);
3184
+ r(() => {
3185
+ let t = n;
3186
+ if (!t || typeof t.getObjectSchema != "function") return;
3187
+ let r = !1;
3188
+ return t.getObjectSchema(e.childObject).then((e) => {
3189
+ r || T(e ?? null);
3190
+ }).catch(() => {
3191
+ r || T(null);
3192
+ }), () => {
3193
+ r = !0;
3194
+ };
3195
+ }, [n, e.childObject]);
3196
+ let E = t(async () => {
3002
3197
  if (!n || !c) {
3003
3198
  _(!1);
3004
3199
  return;
@@ -3022,22 +3217,23 @@ var Pt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
3022
3217
  e.relationshipField
3023
3218
  ]);
3024
3219
  r(() => {
3025
- w();
3026
- }, [w]);
3027
- let T = t((e) => {
3220
+ E();
3221
+ }, [E]);
3222
+ let A = t((e) => {
3028
3223
  u(e), x(!0);
3029
- }, []), E = t(async () => {
3224
+ }, []), N = t(async () => {
3030
3225
  if (!(!n || !c)) {
3031
3226
  y(!0), C(null);
3032
3227
  try {
3033
- await Ne(n, o || e.childObject, c, {
3228
+ await tt(n, o || e.childObject, c, {
3034
3229
  childObject: e.childObject,
3035
3230
  relationshipField: e.relationshipField,
3036
3231
  rows: l,
3037
3232
  original: d,
3038
3233
  amountField: e.amountField,
3039
- totalField: o ? e.totalField : void 0
3040
- }), await w();
3234
+ totalField: o ? e.totalField : void 0,
3235
+ childSchema: w
3236
+ }), await E();
3041
3237
  } catch (e) {
3042
3238
  C(e?.message || "Failed to save line items");
3043
3239
  } finally {
@@ -3051,8 +3247,9 @@ var Pt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
3051
3247
  d,
3052
3248
  e,
3053
3249
  o,
3250
+ E,
3054
3251
  w
3055
- ]), D = a(() => ({
3252
+ ]), P = a(() => ({
3056
3253
  columns: e.columns,
3057
3254
  total_field: e.totalField ? e.amountField || "amount" : void 0,
3058
3255
  min_rows: e.minRows,
@@ -3060,41 +3257,41 @@ var Pt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
3060
3257
  allow_add: !e.readonly,
3061
3258
  allow_delete: !e.readonly
3062
3259
  }), [e]);
3063
- return /* @__PURE__ */ Z(k, {
3260
+ return /* @__PURE__ */ X(O, {
3064
3261
  className: G("shadow-none"),
3065
- children: [/* @__PURE__ */ Z(M, {
3262
+ children: [/* @__PURE__ */ X(j, {
3066
3263
  className: "flex-row items-center justify-between gap-2 pb-2",
3067
- children: [/* @__PURE__ */ X(N, {
3264
+ children: [/* @__PURE__ */ Y(M, {
3068
3265
  className: "text-sm font-medium",
3069
3266
  children: e.title || "Line Items"
3070
- }), !e.readonly && /* @__PURE__ */ X(O, {
3267
+ }), !e.readonly && /* @__PURE__ */ Y(D, {
3071
3268
  type: "button",
3072
3269
  size: "sm",
3073
- onClick: E,
3270
+ onClick: N,
3074
3271
  disabled: v || g || !b || !c,
3075
3272
  children: v ? "Saving…" : "Save"
3076
3273
  })]
3077
- }), /* @__PURE__ */ Z(A, { children: [S && /* @__PURE__ */ X("p", {
3274
+ }), /* @__PURE__ */ X(k, { children: [S && /* @__PURE__ */ Y("p", {
3078
3275
  className: "mb-2 text-sm text-destructive",
3079
3276
  children: S
3080
- }), g ? /* @__PURE__ */ X("p", {
3277
+ }), g ? /* @__PURE__ */ Y("p", {
3081
3278
  className: "py-6 text-center text-sm text-muted-foreground",
3082
3279
  children: "Loading…"
3083
- }) : c ? /* @__PURE__ */ X(h, {
3280
+ }) : c ? /* @__PURE__ */ Y(h, {
3084
3281
  value: l,
3085
- onChange: T,
3086
- field: D,
3282
+ onChange: A,
3283
+ field: P,
3087
3284
  readonly: e.readonly
3088
- }) : /* @__PURE__ */ X("p", {
3285
+ }) : /* @__PURE__ */ Y("p", {
3089
3286
  className: "py-6 text-center text-sm text-muted-foreground",
3090
3287
  children: "Save the record first to add line items."
3091
3288
  })] })]
3092
3289
  });
3093
- }, It = ({ schema: e }) => /* @__PURE__ */ X(Tt, {
3290
+ }, Vt = ({ schema: e }) => /* @__PURE__ */ Y(At, {
3094
3291
  schema: e,
3095
3292
  dataSource: n(u)?.dataSource ?? void 0
3096
3293
  });
3097
- c.register("object-form", It, {
3294
+ c.register("object-form", Vt, {
3098
3295
  namespace: "plugin-form",
3099
3296
  label: "Object Form",
3100
3297
  category: "plugin",
@@ -3235,7 +3432,7 @@ c.register("object-form", It, {
3235
3432
  ]
3236
3433
  }
3237
3434
  ]
3238
- }), c.register("form", It, {
3435
+ }), c.register("form", Vt, {
3239
3436
  namespace: "view",
3240
3437
  skipFallback: !0,
3241
3438
  label: "Data Form View",
@@ -3263,7 +3460,7 @@ c.register("object-form", It, {
3263
3460
  ]
3264
3461
  }
3265
3462
  ]
3266
- }), c.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */ X(Mt, { config: e }), {
3463
+ }), c.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */ Y(Lt, { config: e }), {
3267
3464
  namespace: "plugin-form",
3268
3465
  label: "Embeddable Form",
3269
3466
  category: "plugin",
@@ -3301,7 +3498,7 @@ c.register("object-form", It, {
3301
3498
  label: "Allow Multiple Submissions"
3302
3499
  }
3303
3500
  ]
3304
- }), c.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ X(Pt, {
3501
+ }), c.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ Y(zt, {
3305
3502
  formId: e.formId,
3306
3503
  formTitle: e.formTitle,
3307
3504
  metrics: e.metrics || { totalSubmissions: 0 }
@@ -3327,7 +3524,7 @@ c.register("object-form", It, {
3327
3524
  label: "Submission Metrics"
3328
3525
  }
3329
3526
  ]
3330
- }), c.register("object-master-detail-form", ({ schema: e }) => /* @__PURE__ */ X($e, {
3527
+ }), c.register("object-master-detail-form", ({ schema: e }) => /* @__PURE__ */ Y(St, {
3331
3528
  schema: e,
3332
3529
  dataSource: n(u)?.dataSource ?? void 0
3333
3530
  }), {
@@ -3359,7 +3556,7 @@ c.register("object-form", It, {
3359
3556
  required: !0
3360
3557
  }
3361
3558
  ]
3362
- }), c.register("line_items", ({ schema: e }) => /* @__PURE__ */ X(Ft, { schema: e }), {
3559
+ }), c.register("line_items", ({ schema: e }) => /* @__PURE__ */ Y(Bt, { schema: e }), {
3363
3560
  namespace: "record",
3364
3561
  skipFallback: !0,
3365
3562
  label: "Line Items",
@@ -3396,4 +3593,4 @@ c.register("object-form", It, {
3396
3593
  ]
3397
3594
  });
3398
3595
  //#endregion
3399
- export { vt as DrawerForm, Mt as EmbeddableForm, Pt as FormAnalytics, _e as FormSection, Ft as LineItemsPanel, $e as MasterDetailForm, St as ModalForm, Tt as ObjectForm, we as SplitForm, Se as TabbedForm, Ce as WizardForm, ot as applyAutoColSpan, ft as applyAutoLayout, Ue as deriveColumns, Xe as deriveDetail, Ge as deriveFormFields, ut as filterAutoGeneratedFields, lt as filterCreateModeFields, ct as filterSystemFields, ze as findRelationshipField, at as inferColumns, dt as inferModalSize, it as isAutoGeneratedFieldType, rt as isWideFieldType, qe as resolveInlineMode };
3596
+ export { Tt as DrawerForm, Lt as EmbeddableForm, zt as FormAnalytics, ve as FormSection, Bt as LineItemsPanel, St as MasterDetailForm, kt as ModalForm, At as ObjectForm, He as SplitForm, Be as TabbedForm, Ve as WizardForm, Ae as applyAutoColSpan, ze as applyAutoLayout, dt as deriveColumns, yt as deriveDetail, mt as deriveFormFields, Pe as filterAutoGeneratedFields, Ne as filterCreateModeFields, Me as filterSystemFields, st as findRelationshipField, De as inferColumns, Re as inferModalSize, Ee as isAutoGeneratedFieldType, Te as isWideFieldType, gt as resolveInlineMode };