@object-ui/plugin-form 17.5.0 → 17.6.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,95 +1,170 @@
1
1
  import * as e from "react";
2
2
  import t, { useCallback as n, useContext as r, useEffect as i, useId as a, useMemo as o, useRef as s, useState as c } from "react";
3
- import { ComponentRegistry as l, convertSortToQueryParams as u, evalFieldPredicate as d, isMissingForRequired as f, mergeFilterNodes as p, resolveEffectiveCrudAffordances as m, resolveFieldRuleState as h, runBatchTransaction as g, toFilterNode as _ } from "@object-ui/core";
4
- import { ElementDataSourceGate as v, SchemaRenderer as y, SchemaRendererContext as b, usePreviewMode as x, useRecordContext as S, useSafeFieldLabel as C, useSchemaContext as w } from "@object-ui/react";
5
- import { LineItemsField as T, buildValidationRules as E, formatFileSize as D, mapFieldTypeToFormType as O } from "@object-ui/fields";
6
- import { AlertDialog as k, AlertDialogAction as A, AlertDialogCancel as j, AlertDialogContent as M, AlertDialogDescription as N, AlertDialogFooter as P, AlertDialogHeader as F, AlertDialogTitle as ee, Button as I, Card as L, CardContent as R, CardDescription as z, CardHeader as B, CardTitle as V, Dialog as H, DialogDescription as U, DialogHeader as W, DialogTitle as G, MobileDialogContent as K, Sheet as te, SheetContent as ne, SheetDescription as re, SheetHeader as q, SheetTitle as J, Skeleton as ie, buttonVariants as ae, cn as Y, toast as X, useIsMobile as oe } from "@object-ui/components";
7
- import { usePermissions as se } from "@object-ui/permissions";
8
- import { deriveFieldGroupLayout as ce, isRuntimeDefaultToken as Z } from "@objectstack/spec/data";
9
- import { AlertCircle as le, AlertTriangle as ue, Check as de, CheckCircle2 as fe, ChevronDown as pe, ChevronLeft as me, ChevronRight as he, Loader2 as ge, Lock as _e, ShieldCheck as ve } from "lucide-react";
10
- import { createSafeTranslation as ye } from "@object-ui/i18n";
11
- import { Fragment as be, jsx as Q, jsxs as $ } from "react/jsx-runtime";
3
+ import { ComponentRegistry as l, convertSortToQueryParams as u, evalFieldPredicate as d, isMissingForRequired as f, isRuntimeDefault as p, isServerOwnedValue as m, mergeFilterNodes as h, resolveEffectiveCrudAffordances as g, resolveFieldRuleState as _, runBatchTransaction as v, toFilterNode as y } from "@object-ui/core";
4
+ import { ElementDataSourceGate as b, SchemaRenderer as x, SchemaRendererContext as S, noDataSourceMessage as C, useHostNavigation as w, usePreviewMode as T, useRecordContext as E, useResolvedDataSource as D, useSafeFieldLabel as O, useSchemaContext as k } from "@object-ui/react";
5
+ import { LineItemsField as A, buildValidationRules as j, formatFileSize as M, mapFieldTypeToFormType as N } from "@object-ui/fields";
6
+ import { AlertDialog as P, AlertDialogAction as F, AlertDialogCancel as I, AlertDialogContent as ee, AlertDialogDescription as te, AlertDialogFooter as L, AlertDialogHeader as ne, AlertDialogTitle as re, Button as R, Card as z, CardContent as B, CardDescription as V, CardHeader as H, CardTitle as U, Dialog as ie, DialogDescription as W, DialogHeader as G, DialogTitle as ae, MobileDialogContent as K, Sheet as oe, SheetContent as se, SheetDescription as ce, SheetHeader as q, SheetTitle as le, Skeleton as J, buttonVariants as ue, cn as Y, toast as X, useIsMobile as de } from "@object-ui/components";
7
+ import { FormViewSchema as fe } from "@objectstack/spec/ui";
8
+ import { usePermissions as pe } from "@object-ui/permissions";
9
+ import { deriveFieldGroupLayout as me, isCurrentUserDefaultToken as he } from "@objectstack/spec/data";
10
+ import { AlertCircle as ge, AlertTriangle as _e, Check as ve, CheckCircle2 as ye, ChevronDown as be, ChevronLeft as xe, ChevronRight as Se, Loader2 as Ce, Lock as we, ShieldCheck as Te } from "lucide-react";
11
+ import { createSafeTranslation as Ee } from "@object-ui/i18n";
12
+ import { Fragment as De, jsx as Z, jsxs as Q } from "react/jsx-runtime";
12
13
  //#region src/successBehavior.ts
13
- function xe(e) {
14
+ function Oe(e) {
14
15
  try {
15
16
  return typeof window > "u" ? !1 : new URL(e, window.location.href).origin === window.location.origin;
16
17
  } catch {
17
18
  return !1;
18
19
  }
19
20
  }
20
- function Se(e, t) {
21
+ function ke(e, t) {
21
22
  if (!e) return null;
22
23
  let n = t?.id ?? t?.recordId ?? t?._id;
23
24
  if (n == null || n === "") return null;
24
25
  let r = e.replace(/\{(?:id|recordId)\}/g, String(n));
25
- return xe(r) ? r : null;
26
+ return Oe(r) ? r : null;
26
27
  }
27
28
  //#endregion
28
- //#region src/schemaDefaults.ts
29
- function Ce(e) {
30
- return typeof e == "object" && !!e && typeof e.dialect == "string" && typeof e.source == "string";
29
+ //#region src/submitRedirect.ts
30
+ var Ae = /\{\{record\.([a-z_][a-z0-9_]*)\}\}/g;
31
+ function je(e) {
32
+ return e == null ? "" : typeof e == "string" ? e : typeof e == "boolean" || typeof e == "number" && Number.isFinite(e) ? String(e) : "";
31
33
  }
32
- function we(e) {
33
- return Z(e) || Ce(e);
34
+ function Me(e, t) {
35
+ let n = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : {};
36
+ return {
37
+ ...n(e),
38
+ ...n(t)
39
+ };
40
+ }
41
+ function Ne(e, t) {
42
+ let n = fe.safeParse({ submitBehavior: {
43
+ kind: "redirect",
44
+ url: e
45
+ } });
46
+ if (!n.success) return {
47
+ ok: !1,
48
+ refusal: n.error.issues.find((e) => e.path[0] === "submitBehavior" && e.path[1] === "url")?.message ?? n.error.issues[0]?.message ?? `\`submitBehavior.url\` is not a value this contract accepts: ${JSON.stringify(e)}.`
49
+ };
50
+ let r = n.data.submitBehavior, i = (r?.kind === "redirect" ? r.url : e).replace(Ae, (e, n) => encodeURIComponent(je(t[n])));
51
+ return i.includes("{") || i.includes("}") ? {
52
+ ok: !1,
53
+ refusal: `\`submitBehavior.url\` carries an interpolation this renderer could not resolve (${JSON.stringify(e)}). A token names one declared record field, spelled \`{{record.field_name}}\`, and the redirect is refused rather than followed with the token left in it.`
54
+ } : {
55
+ ok: !0,
56
+ url: i
57
+ };
58
+ }
59
+ //#endregion
60
+ //#region src/submitRedirectNavigation.ts
61
+ function Pe(e) {
62
+ let { navigate: t } = w(), n = s(t);
63
+ i(() => {
64
+ n.current = t;
65
+ }, [t]), i(() => {
66
+ if (!e) return;
67
+ let t = setTimeout(() => {
68
+ let t = n.current;
69
+ if (t) {
70
+ t(e.url);
71
+ return;
72
+ }
73
+ window.location.assign(e.url);
74
+ }, e.delayMs);
75
+ return () => clearTimeout(t);
76
+ }, [e]);
77
+ }
78
+ //#endregion
79
+ //#region src/thankYouRedirectNavigation.ts
80
+ var Fe = "https://a.invalid/", Ie = "https://b.invalid/";
81
+ function Le(e) {
82
+ try {
83
+ return new URL(e, Fe).origin === "https://a.invalid" && new URL(e, Ie).origin === "https://b.invalid";
84
+ } catch {
85
+ return !1;
86
+ }
87
+ }
88
+ function Re(e) {
89
+ let { navigate: t } = w(), n = s(t);
90
+ i(() => {
91
+ n.current = t;
92
+ }, [t]), i(() => {
93
+ if (!e) return;
94
+ let t = setTimeout(() => {
95
+ let t = Le(e.url) ? n.current : void 0;
96
+ if (t) {
97
+ t(e.url);
98
+ return;
99
+ }
100
+ window.location.href = e.url;
101
+ }, e.delayMs);
102
+ return () => clearTimeout(t);
103
+ }, [e]);
34
104
  }
35
- function Te(e) {
36
- return e != null && !we(e);
105
+ //#endregion
106
+ //#region src/schemaDefaults.ts
107
+ function ze(e) {
108
+ return e != null && !p(e);
37
109
  }
38
- function Ee(e) {
110
+ function Be(e) {
39
111
  return e?.mode === "create" || !e?.recordId;
40
112
  }
41
- function De(e, t) {
42
- return !(!e?.required || t && we(e.defaultValue));
113
+ function Ve(e, t) {
114
+ return !(!e?.required || t && p(e.defaultValue));
43
115
  }
44
- function Oe(e) {
45
- let t = e?.fields;
46
- if (!t || typeof t != "object") return {};
47
- let n = {};
48
- for (let e of Object.keys(t)) {
49
- let r = t[e]?.defaultValue;
50
- Te(r) && (n[e] = r);
116
+ function He(e, t) {
117
+ let n = e?.fields;
118
+ if (!n || typeof n != "object") return {};
119
+ let r = {};
120
+ for (let e of Object.keys(n)) {
121
+ let i = n[e], a = i?.defaultValue;
122
+ ze(a) ? r[e] = a : Ue(i) && t?.currentUserId && (r[e] = t.currentUserId);
51
123
  }
52
- return n;
124
+ return r;
53
125
  }
54
- function ke(e, t) {
126
+ function Ue(e) {
127
+ return !e || !he(e.defaultValue) ? !1 : e.type === "user" || e.type === "lookup" && (e.reference === "sys_user" || e.reference_to === "sys_user");
128
+ }
129
+ function We(e, t, n) {
55
130
  return {
56
- ...Oe(e),
131
+ ...He(e, n),
57
132
  ...t ?? {}
58
133
  };
59
134
  }
60
- function Ae(e, t) {
135
+ function Ge(e, t) {
61
136
  if (!e || typeof e != "object") return e;
62
137
  let n = t?.fields;
63
138
  if (!n || typeof n != "object") return e;
64
139
  let r = {};
65
- for (let [t, i] of Object.entries(e)) we(n[t]?.defaultValue) && f(i) || (r[t] = i);
140
+ for (let [t, i] of Object.entries(e)) p(n[t]?.defaultValue) && f(i) || (r[t] = i);
66
141
  return r;
67
142
  }
68
143
  //#endregion
69
144
  //#region src/sectionFields.ts
70
- function je(e, t) {
145
+ function Ke(e, t) {
71
146
  return typeof t == "string" && t.trim() || typeof t == "object" && t && typeof t.source == "string" && t.source.trim() ? {
72
147
  ...e,
73
148
  visibleOn: t
74
149
  } : e;
75
150
  }
76
- var Me = /* @__PURE__ */ new Set();
77
- function Ne(e, t) {
151
+ var qe = /* @__PURE__ */ new Set();
152
+ function Je(e, t) {
78
153
  if (typeof e.name != "string" || e.name === e.field) return;
79
154
  let n = `${t}:${e.field}:${e.name}`;
80
- Me.has(n) || (Me.add(n), console.warn(`[object-ui] section field { field: '${e.field}' } also carries name: '${e.name}' — mixed form-field vocabularies. The spec key wins (the runtime name becomes '${e.field}'); drop \`name\` from authored form views.`));
155
+ qe.has(n) || (qe.add(n), console.warn(`[object-ui] section field { field: '${e.field}' } also carries name: '${e.name}' — mixed form-field vocabularies. The spec key wins (the runtime name becomes '${e.field}'); drop \`name\` from authored form views.`));
81
156
  }
82
- function Pe(e, t) {
157
+ function Ye(e, t) {
83
158
  let n = t.objectSchema?.fields?.[e];
84
159
  return n ? {
85
160
  name: e,
86
161
  label: t.fieldLabel(t.objectName, e, n.label || e),
87
- type: O(n.type, { multiple: n.multiple }),
88
- required: De(n, Ee(t)),
162
+ type: N(n.type, { multiple: n.multiple }),
163
+ required: Ve(n, Be(t)),
89
164
  disabled: t.readOnly || t.mode === "view" || n.readonly,
90
165
  placeholder: n.placeholder,
91
166
  description: n.help || n.description,
92
- validation: E(n),
167
+ validation: j(n),
93
168
  field: n,
94
169
  options: n.options,
95
170
  multiple: n.multiple,
@@ -102,35 +177,35 @@ function Pe(e, t) {
102
177
  type: "input"
103
178
  };
104
179
  }
105
- function Fe(e, t) {
180
+ function Xe(e, t) {
106
181
  if (typeof e == "string") {
107
182
  let n = t.objectSchema?.fields?.[e];
108
- return je(Pe(e, t), n?.visible_on ?? n?.visibleOn);
183
+ return Ke(Ye(e, t), n?.visible_on ?? n?.visibleOn);
109
184
  }
110
185
  let n = e;
111
- if (typeof n.field != "string") return je(n, n.visibleOn);
112
- Ne(n, t.objectName);
113
- let r = n.field, i = Pe(r, t);
114
- 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 = De({
186
+ if (typeof n.field != "string") return Ke(n, n.visibleOn);
187
+ Je(n, t.objectName);
188
+ let r = n.field, i = Ye(r, t);
189
+ 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 = Ve({
115
190
  required: n.required,
116
191
  defaultValue: t.objectSchema?.fields?.[r]?.defaultValue
117
- }, Ee(t))), 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);
192
+ }, Be(t))), 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);
118
193
  let a = n.type ?? t.objectSchema?.fields?.[r]?.type;
119
- a != null && (i.type = O(a, { multiple: i.multiple }));
194
+ a != null && (i.type = N(a, { multiple: i.multiple }));
120
195
  let o = n.reference ?? n.reference_to;
121
- return o != null && (i.reference = o, i.reference_to = o), 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), n.dependsOn != null && (i.dependsOn = n.dependsOn), n.keyField != null && (i.keyField = n.keyField), n.disclosure != null && (i.disclosure = n.disclosure), je(i, n.visibleWhen ?? n.visibleOn);
196
+ return o != null && (i.reference = o, i.reference_to = o), 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), n.dependsOn != null && (i.dependsOn = n.dependsOn), n.keyField != null && (i.keyField = n.keyField), n.disclosure != null && (i.disclosure = n.disclosure), Ke(i, n.visibleWhen ?? n.visibleOn);
122
197
  }
123
- function Ie(e, t) {
124
- return (e.fields ?? []).map((e) => Fe(e, t));
198
+ function Ze(e, t) {
199
+ return (e.fields ?? []).map((e) => Xe(e, t));
125
200
  }
126
201
  //#endregion
127
202
  //#region src/autoLayout.ts
128
- var Le = /* @__PURE__ */ new Set([
203
+ var Qe = /* @__PURE__ */ new Set([
129
204
  "field:formula",
130
205
  "field:summary",
131
206
  "field:auto_number",
132
207
  "field:autonumber"
133
- ]), Re = /* @__PURE__ */ new Set([
208
+ ]), $e = /* @__PURE__ */ new Set([
134
209
  "field:textarea",
135
210
  "field:markdown",
136
211
  "field:html",
@@ -141,33 +216,33 @@ var Le = /* @__PURE__ */ new Set([
141
216
  "html",
142
217
  "grid",
143
218
  "richtext"
144
- ]), ze = /* @__PURE__ */ new Set([
219
+ ]), et = /* @__PURE__ */ new Set([
145
220
  "formula",
146
221
  "summary",
147
222
  "auto_number",
148
223
  "autonumber"
149
224
  ]);
150
- function Be(e) {
151
- return Re.has(e);
225
+ function tt(e) {
226
+ return $e.has(e);
152
227
  }
153
- function Ve(e) {
154
- return ze.has(e);
228
+ function nt(e) {
229
+ return et.has(e);
155
230
  }
156
- function He(e) {
231
+ function rt(e) {
157
232
  return e <= 3 ? 1 : e <= 8 ? 2 : e <= 15 ? 3 : 4;
158
233
  }
159
- function Ue(e) {
234
+ function it(e) {
160
235
  return e && e > 0 ? Math.min(Math.floor(e), 4) : 1;
161
236
  }
162
- function We(e, t, n) {
163
- let r = Ue(t);
164
- return r <= 1 ? 1 : e.span === "full" ? r : e.colSpan == null ? e.type && Be(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);
237
+ function at(e, t, n) {
238
+ let r = it(t);
239
+ return r <= 1 ? 1 : e.span === "full" ? r : e.colSpan == null ? e.type && tt(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);
165
240
  }
166
- function Ge(e, t, n) {
167
- let r = Ue(t);
241
+ function $(e, t, n) {
242
+ let r = it(t);
168
243
  return r <= 1 ? e : e.map((e) => {
169
244
  if (e.type === "section-divider") return e;
170
- let t = We(e, r, n);
245
+ let t = at(e, r, n);
171
246
  return t > 1 ? {
172
247
  ...e,
173
248
  colSpan: t
@@ -177,7 +252,7 @@ function Ge(e, t, n) {
177
252
  } : e;
178
253
  });
179
254
  }
180
- var Ke = /* @__PURE__ */ new Set([
255
+ var ot = /* @__PURE__ */ new Set([
181
256
  "id",
182
257
  "created_at",
183
258
  "createdAt",
@@ -204,89 +279,89 @@ var Ke = /* @__PURE__ */ new Set([
204
279
  "_version",
205
280
  "_rev"
206
281
  ]);
207
- function qe(e, t) {
282
+ function st(e, t) {
208
283
  return e.filter((e) => {
209
- if (Ke.has(e.name)) return !1;
284
+ if (ot.has(e.name)) return !1;
210
285
  let n = t?.fields?.[e.name];
211
286
  return n?.hidden !== !0 && n?.readonly !== !0;
212
287
  });
213
288
  }
214
- function Je(e, t) {
289
+ function ct(e, t) {
215
290
  return e.filter((e) => {
216
- if (Ke.has(e.name) || e.type && Le.has(e.type)) return !1;
291
+ if (ot.has(e.name) || e.type && Qe.has(e.type)) return !1;
217
292
  if (!t?.fields) return !0;
218
293
  let n = t.fields[e.name];
219
- return !n || n.readonly !== !0 && !Ve(n.type);
294
+ return !n || n.readonly !== !0 && !nt(n.type);
220
295
  });
221
296
  }
222
- function Ye(e, t) {
297
+ function lt(e, t) {
223
298
  return e.filter((e) => {
224
- if (e.type && Le.has(e.type)) return !1;
299
+ if (e.type && Qe.has(e.type)) return !1;
225
300
  let n = t?.fields?.[e.name];
226
- return !n || !Ve(n.type);
301
+ return !n || !nt(n.type);
227
302
  });
228
303
  }
229
- var Xe = {
304
+ var ut = {
230
305
  1: void 0,
231
306
  2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
232
307
  3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
233
308
  4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
234
309
  };
235
- function Ze(e) {
236
- return Xe[e && e > 0 ? Math.min(Math.floor(e), 4) : 1];
310
+ function dt(e) {
311
+ return ut[e && e > 0 ? Math.min(Math.floor(e), 4) : 1];
237
312
  }
238
- function Qe(e) {
313
+ function ft(e) {
239
314
  return e <= 1 ? "default" : e === 2 ? "xl" : "full";
240
315
  }
241
- function $e(e, t, n, r) {
316
+ function pt(e, t, n, r) {
242
317
  let i = [...e];
243
- if (i = qe(i, t), r === "create" && (i = Ye(i, t)), n !== void 0) return i = Ge(i, n), {
318
+ if (i = st(i, t), r === "create" && (i = lt(i, t)), n !== void 0) return i = $(i, n), {
244
319
  fields: i,
245
320
  columns: n
246
321
  };
247
- let a = He(i.length);
248
- return i = Ge(i, a), {
322
+ let a = rt(i.length);
323
+ return i = $(i, a), {
249
324
  fields: i,
250
325
  columns: a
251
326
  };
252
327
  }
253
328
  //#endregion
254
329
  //#region src/occSave.tsx
255
- var et = ye({
330
+ var mt = Ee({
256
331
  "form.conflictTitle": "Save conflict",
257
332
  "form.conflictMessage": "This record was changed by someone else while you were editing. Overwriting will replace their changes with yours.",
258
333
  "form.conflictLatestVersion": "Their save: {{time}}",
259
334
  "form.conflictOverwrite": "Overwrite",
260
335
  "form.keepEditing": "Keep editing"
261
336
  }, "form.conflictTitle");
262
- function tt(e) {
337
+ function ht(e) {
263
338
  let t = e?.updated_at;
264
339
  return typeof t == "string" && t.length > 0 ? t : void 0;
265
340
  }
266
- function nt(e) {
341
+ function gt(e) {
267
342
  if (!e || typeof e != "object") return !1;
268
343
  let t = e;
269
344
  return t.code === "CONCURRENT_UPDATE" || t.name === "ConcurrentUpdateError";
270
345
  }
271
- function rt(e) {
346
+ function _t(e) {
272
347
  if (!e) return null;
273
348
  let t = /\d{4}-\d{2}-\d{2}[ T]/.test(e) ? e.replace(" ", "T") : e, n = new Date(t);
274
349
  return Number.isNaN(n.getTime()) ? null : n.toLocaleString();
275
350
  }
276
- function it() {
277
- let { t } = et(), [n, r] = e.useState(null), i = e.useRef(null), a = e.useCallback((e) => {
351
+ function vt() {
352
+ let { t } = mt(), [n, r] = e.useState(null), i = e.useRef(null), a = e.useCallback((e) => {
278
353
  i.current?.(e), i.current = null, r(null);
279
354
  }, []);
280
355
  e.useEffect(() => () => i.current?.(!1), []);
281
356
  let o = e.useCallback(async ({ dataSource: e, objectName: t, recordId: n, payload: a, baseRecord: o }) => {
282
- let s = tt(o);
357
+ let s = ht(o);
283
358
  try {
284
359
  return {
285
360
  status: "saved",
286
361
  result: await e.update(t, n, a, s ? { ifMatch: s } : void 0)
287
362
  };
288
363
  } catch (o) {
289
- if (!nt(o)) throw o;
364
+ if (!gt(o)) throw o;
290
365
  let s = o.currentVersion;
291
366
  if (!await new Promise((e) => {
292
367
  i.current = e, r({ currentVersion: typeof s == "string" ? s : void 0 });
@@ -297,31 +372,31 @@ function it() {
297
372
  result: await e.update(t, n, a, c ? { ifMatch: c } : void 0)
298
373
  };
299
374
  }
300
- }, []), s = rt(n?.currentVersion);
375
+ }, []), s = _t(n?.currentVersion);
301
376
  return {
302
377
  saveWithOcc: o,
303
- conflictDialog: /* @__PURE__ */ Q(k, {
378
+ conflictDialog: /* @__PURE__ */ Z(P, {
304
379
  open: !!n,
305
380
  onOpenChange: (e) => {
306
381
  e || a(!1);
307
382
  },
308
- children: /* @__PURE__ */ $(M, { children: [/* @__PURE__ */ $(F, { children: [/* @__PURE__ */ $(ee, {
383
+ children: /* @__PURE__ */ Q(ee, { children: [/* @__PURE__ */ Q(ne, { children: [/* @__PURE__ */ Q(re, {
309
384
  className: "flex items-center gap-2",
310
- children: [/* @__PURE__ */ Q(ue, {
385
+ children: [/* @__PURE__ */ Z(_e, {
311
386
  className: "h-5 w-5 text-amber-500",
312
387
  "aria-hidden": !0
313
388
  }), t("form.conflictTitle")]
314
- }), /* @__PURE__ */ $(N, { children: [t("form.conflictMessage"), s && /* @__PURE__ */ Q("span", {
389
+ }), /* @__PURE__ */ Q(te, { children: [t("form.conflictMessage"), s && /* @__PURE__ */ Z("span", {
315
390
  className: "mt-2 block text-xs text-muted-foreground",
316
391
  children: t("form.conflictLatestVersion", { time: s })
317
- })] })] }), /* @__PURE__ */ $(P, { children: [/* @__PURE__ */ Q("button", {
392
+ })] })] }), /* @__PURE__ */ Q(L, { children: [/* @__PURE__ */ Z("button", {
318
393
  type: "button",
319
- className: Y(ae({ variant: "outline" })),
394
+ className: Y(ue({ variant: "outline" })),
320
395
  onClick: () => a(!1),
321
396
  children: t("form.keepEditing")
322
- }), /* @__PURE__ */ Q("button", {
397
+ }), /* @__PURE__ */ Z("button", {
323
398
  type: "button",
324
- className: Y(ae({ variant: "destructive" })),
399
+ className: Y(ue({ variant: "destructive" })),
325
400
  onClick: () => a(!0),
326
401
  children: t("form.conflictOverwrite")
327
402
  })] })] })
@@ -330,46 +405,46 @@ function it() {
330
405
  }
331
406
  //#endregion
332
407
  //#region src/TabbedForm.tsx
333
- var at = ({ schema: e, dataSource: r, className: i }) => {
334
- let { fieldLabel: a } = C(), [o, l] = c(null), [u, d] = c({}), { saveWithOcc: f, conflictDialog: p } = it(), [m, h] = c(!0), [g, _] = c(null), v = e.defaultTab || e.sections[0]?.name || e.sections[0]?.label || "tab-0";
408
+ var yt = ({ schema: e, dataSource: r, className: i }) => {
409
+ let { fieldLabel: a } = O(), { userId: o } = pe(), [l, u] = c(null), [d, f] = c({}), { saveWithOcc: p, conflictDialog: m } = vt(), [h, g] = c(!0), [_, v] = c(null), y = e.defaultTab || e.sections[0]?.name || e.sections[0]?.label || "tab-0";
335
410
  t.useEffect(() => {
336
411
  (async () => {
337
412
  if (!r) {
338
- h(!1);
413
+ g(!1);
339
414
  return;
340
415
  }
341
416
  try {
342
417
  let t = await r.getObjectSchema(e.objectName);
343
- l(t);
418
+ u(t);
344
419
  } catch (e) {
345
- _(e);
420
+ v(e);
346
421
  }
347
422
  })();
348
423
  }, [e.objectName, r]);
349
424
  let b = s(void 0);
350
425
  t.useEffect(() => {
351
426
  let t = !1;
352
- return (o || !r) && (async () => {
427
+ return (l || !r) && (async () => {
353
428
  if (e.mode === "create" || !e.recordId || !r) {
354
- d(ke(o, e.initialData || e.initialValues)), h(!1);
429
+ f(We(l, e.initialData || e.initialValues, { currentUserId: o })), g(!1);
355
430
  return;
356
431
  }
357
- b.current !== e.recordId && h(!0);
432
+ b.current !== e.recordId && g(!0);
358
433
  try {
359
434
  let n = await r.findOne(e.objectName, e.recordId);
360
435
  if (t) return;
361
- b.current = e.recordId, d(n || {});
436
+ b.current = e.recordId, f(n || {});
362
437
  } catch (e) {
363
438
  if (t) return;
364
- _(e);
439
+ v(e);
365
440
  } finally {
366
- t || h(!1);
441
+ t || g(!1);
367
442
  }
368
443
  })(), () => {
369
444
  t = !0;
370
445
  };
371
446
  }, [
372
- o,
447
+ l,
373
448
  e.mode,
374
449
  e.recordId,
375
450
  e.initialData,
@@ -377,32 +452,32 @@ var at = ({ schema: e, dataSource: r, className: i }) => {
377
452
  r,
378
453
  e.objectName
379
454
  ]);
380
- let x = n((t) => Ie(t, {
381
- objectSchema: o,
455
+ let S = n((t) => Ze(t, {
456
+ objectSchema: l,
382
457
  objectName: e.objectName,
383
458
  readOnly: e.readOnly,
384
459
  mode: e.mode,
385
460
  recordId: e.recordId,
386
461
  fieldLabel: a
387
462
  }), [
388
- o,
463
+ l,
389
464
  e.readOnly,
390
465
  e.mode,
391
466
  e.recordId,
392
467
  e.objectName,
393
468
  a
394
- ]), S = n(async (t) => {
469
+ ]), C = n(async (t) => {
395
470
  if (!r) return e.onSuccess && await e.onSuccess(t), t;
396
471
  try {
397
472
  let n;
398
- if (e.mode === "create") n = await r.create(e.objectName, Ae(t, o));
473
+ if (e.mode === "create") n = await r.create(e.objectName, Ge(t, l));
399
474
  else if (e.mode === "edit" && e.recordId) {
400
- let i = await f({
475
+ let i = await p({
401
476
  dataSource: r,
402
477
  objectName: e.objectName,
403
478
  recordId: e.recordId,
404
479
  payload: t,
405
- baseRecord: u
480
+ baseRecord: d
406
481
  });
407
482
  if (i.status === "cancelled") return;
408
483
  n = i.result;
@@ -414,67 +489,67 @@ var at = ({ schema: e, dataSource: r, className: i }) => {
414
489
  }, [
415
490
  e,
416
491
  r,
417
- f,
418
- u
492
+ p,
493
+ d
419
494
  ]), w = n(() => {
420
495
  e.onCancel && e.onCancel();
421
496
  }, [e]), T = (e, t) => e.name || e.label || `tab-${t}`;
422
- if (g) return /* @__PURE__ */ $("div", {
497
+ if (_) return /* @__PURE__ */ Q("div", {
423
498
  className: "p-4 border border-red-300 bg-red-50 rounded-md",
424
- children: [/* @__PURE__ */ Q("h3", {
499
+ children: [/* @__PURE__ */ Z("h3", {
425
500
  className: "text-red-800 font-semibold",
426
501
  children: "Error loading form"
427
- }), /* @__PURE__ */ Q("p", {
502
+ }), /* @__PURE__ */ Z("p", {
428
503
  className: "text-red-600 text-sm mt-1",
429
- children: g.message
504
+ children: _.message
430
505
  })]
431
506
  });
432
- if (m) return /* @__PURE__ */ $("div", {
507
+ if (h) return /* @__PURE__ */ Q("div", {
433
508
  className: "p-8 text-center",
434
- children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
509
+ children: [/* @__PURE__ */ Z("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Z("p", {
435
510
  className: "mt-2 text-sm text-gray-600",
436
511
  children: "Loading form..."
437
512
  })]
438
513
  });
439
- let E = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, D = e.sections.map((e) => E(e.columns)).filter((e) => e != null), O = E(e.columns) ?? (D.length ? Math.max(...D) : 1), k = Ze(O), A = e.sections.map((e, t) => {
440
- let n = x(e);
514
+ let E = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, D = e.sections.map((e) => E(e.columns)).filter((e) => e != null), k = E(e.columns) ?? (D.length ? Math.max(...D) : 1), A = dt(k), j = e.sections.map((e, t) => {
515
+ let n = S(e);
441
516
  return {
442
517
  key: T(e, t),
443
518
  label: e.label || `Tab ${t + 1}`,
444
519
  description: e.description,
445
520
  containerClass: e.gridClassName,
446
- fields: O > 1 ? Ge(n, O, E(e.columns)) : n
521
+ fields: k > 1 ? $(n, k, E(e.columns)) : n
447
522
  };
448
- }), j = A.flatMap((e) => e.fields);
449
- return /* @__PURE__ */ $("div", {
523
+ }), M = j.flatMap((e) => e.fields);
524
+ return /* @__PURE__ */ Q("div", {
450
525
  className: Y("w-full @container", i, e.className),
451
- children: [/* @__PURE__ */ Q(y, { schema: {
526
+ children: [/* @__PURE__ */ Z(x, { schema: {
452
527
  type: "form",
453
528
  objectName: e.objectName,
454
- fields: j,
455
- columns: O,
456
- ...k ? { fieldContainerClass: k } : {},
529
+ fields: M,
530
+ columns: k,
531
+ ...A ? { fieldContainerClass: A } : {},
457
532
  layout: "vertical",
458
- defaultValues: u,
459
- previousValues: e.mode === "edit" && e.recordId ? u : void 0,
533
+ defaultValues: d,
534
+ previousValues: e.mode === "edit" && e.recordId ? d : void 0,
460
535
  submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
461
536
  cancelLabel: e.cancelText,
462
537
  showSubmit: e.showSubmit !== !1 && e.mode !== "view",
463
538
  showCancel: e.showCancel !== !1,
464
- onSubmit: S,
539
+ onSubmit: C,
465
540
  onCancel: w,
466
- fieldTabs: A.map((e) => ({
541
+ fieldTabs: j.map((e) => ({
467
542
  key: e.key,
468
543
  label: e.label,
469
544
  description: e.description,
470
545
  fields: e.fields.map((e) => e.name),
471
546
  containerClass: e.containerClass
472
547
  })),
473
- defaultFieldTab: v,
548
+ defaultFieldTab: y,
474
549
  fieldTabsPosition: e.tabPosition || "top"
475
- } }), p]
550
+ } }), m]
476
551
  });
477
- }, ot = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: a, className: o, gridClassName: s, showBorder: l }) => {
552
+ }, bt = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: a, className: o, gridClassName: s, showBorder: l }) => {
478
553
  let [u, d] = c(r), f = {
479
554
  1: "grid-cols-1",
480
555
  2: "grid-cols-1 md:grid-cols-2",
@@ -482,73 +557,75 @@ var at = ({ schema: e, dataSource: r, className: i }) => {
482
557
  4: "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
483
558
  }, p = () => {
484
559
  n && d(!u);
485
- }, m = l ?? !!e, h = e || t ? /* @__PURE__ */ $("div", {
560
+ }, m = l ?? !!e, h = e || t ? /* @__PURE__ */ Q("div", {
486
561
  className: Y("flex items-start gap-2", !m && "mb-4", n && "cursor-pointer select-none"),
487
562
  onClick: p,
488
563
  role: n ? "button" : void 0,
489
564
  "aria-expanded": n ? !u : void 0,
490
- children: [n && /* @__PURE__ */ Q("span", {
565
+ children: [n && /* @__PURE__ */ Z("span", {
491
566
  className: "mt-0.5 text-muted-foreground",
492
- children: Q(u ? he : pe, { className: "h-4 w-4" })
493
- }), /* @__PURE__ */ $("div", {
567
+ children: Z(u ? Se : be, { className: "h-4 w-4" })
568
+ }), /* @__PURE__ */ Q("div", {
494
569
  className: "flex-1",
495
- children: [e && /* @__PURE__ */ Q("h3", {
570
+ children: [e && /* @__PURE__ */ Z("h3", {
496
571
  className: "text-sm font-semibold text-foreground",
497
572
  children: e
498
- }), t && /* @__PURE__ */ Q("p", {
573
+ }), t && /* @__PURE__ */ Z("p", {
499
574
  className: "text-sm text-muted-foreground mt-0.5",
500
575
  children: t
501
576
  })]
502
577
  })]
503
- }) : null, g = u ? null : /* @__PURE__ */ Q("div", {
578
+ }) : null, g = u ? null : /* @__PURE__ */ Z("div", {
504
579
  className: Y("grid gap-4", s || f[i]),
505
580
  children: a
506
581
  });
507
- return m ? /* @__PURE__ */ $(L, {
582
+ return m ? /* @__PURE__ */ Q(z, {
508
583
  className: Y("form-section bg-muted/40 shadow-none", o),
509
- children: [h && /* @__PURE__ */ Q(B, {
584
+ children: [h && /* @__PURE__ */ Z(H, {
510
585
  className: "border-b border-border pb-3",
511
586
  children: h
512
- }), g && /* @__PURE__ */ Q(R, {
587
+ }), g && /* @__PURE__ */ Z(B, {
513
588
  className: "pt-4",
514
589
  children: g
515
590
  })]
516
- }) : /* @__PURE__ */ $("div", {
591
+ }) : /* @__PURE__ */ Q("div", {
517
592
  className: Y("form-section", o),
518
593
  children: [h, g]
519
594
  });
520
- }, st = ye({ "wizard.missingRequired": "Please complete the required fields: {{fields}}" }, "wizard.missingRequired"), ct = f, lt = ({ schema: e, dataSource: r, className: i }) => {
521
- let { fieldLabel: a } = C(), { t: s } = st(), [l, u] = c(null), [f, p] = c({}), [m, g] = c(void 0), { saveWithOcc: _, conflictDialog: v } = it(), [b, x] = c(!0), [S, w] = c(null), [T, E] = c(0), [D, O] = c(/* @__PURE__ */ new Set()), [k, A] = c(!1), [j, M] = c(/* @__PURE__ */ new Set()), [N, P] = c(null), F = t.useId(), [ee, L] = c(0), R = t.useRef(!1), z = e.sections.length, B = T === 0, V = T === z - 1;
595
+ }, xt = "The `navigateOnSuccess` destination declared for this form was refused, so the navigation did not happen.", St = Ee({ "wizard.missingRequired": "Please complete the required fields: {{fields}}" }, "wizard.missingRequired"), Ct = f, wt = ({ schema: e, dataSource: r, className: i }) => {
596
+ let { fieldLabel: a } = O(), { userId: s } = pe(), { t: l } = St(), [u, f] = c(null), [p, h] = c({}), [g, v] = c(void 0), { saveWithOcc: y, conflictDialog: b } = vt(), [S, C] = c(!0), [w, T] = c(null), [E, D] = c(0), [k, A] = c(/* @__PURE__ */ new Set()), [j, M] = c(!1), [N, P] = c(/* @__PURE__ */ new Set()), [F, I] = c(null), [ee, te] = c(null);
597
+ Pe(ee);
598
+ let L = t.useId(), [ne, re] = c(0), z = t.useRef(!1), B = e.sections.length, V = E === 0, H = E === B - 1;
522
599
  t.useEffect(() => {
523
600
  (async () => {
524
601
  if (!r) {
525
- x(!1);
602
+ C(!1);
526
603
  return;
527
604
  }
528
605
  try {
529
606
  let t = await r.getObjectSchema(e.objectName);
530
- u(t);
607
+ f(t);
531
608
  } catch (e) {
532
- w(e);
609
+ T(e);
533
610
  }
534
611
  })();
535
612
  }, [e.objectName, r]), t.useEffect(() => {
536
- (l || !r) && (async () => {
613
+ (u || !r) && (async () => {
537
614
  if (e.mode === "create" || !e.recordId || !r) {
538
- R.current ||= (p(ke(l, e.initialData || e.initialValues)), !0), x(!1);
615
+ z.current ||= (h(We(u, e.initialData || e.initialValues, { currentUserId: s })), !0), C(!1);
539
616
  return;
540
617
  }
541
618
  try {
542
619
  let t = await r.findOne(e.objectName, e.recordId);
543
- p(t || {}), g(t || {});
620
+ h(t || {}), v(t || {});
544
621
  } catch (e) {
545
- w(e);
622
+ T(e);
546
623
  } finally {
547
- x(!1);
624
+ C(!1);
548
625
  }
549
626
  })();
550
627
  }, [
551
- l,
628
+ u,
552
629
  e.mode,
553
630
  e.recordId,
554
631
  e.initialData,
@@ -556,194 +633,218 @@ var at = ({ schema: e, dataSource: r, className: i }) => {
556
633
  r,
557
634
  e.objectName
558
635
  ]);
559
- let H = n((t) => Ie(t, {
560
- objectSchema: l,
636
+ let U = n((t) => Ze(t, {
637
+ objectSchema: u,
561
638
  objectName: e.objectName,
562
639
  readOnly: e.readOnly,
563
640
  mode: e.mode,
564
641
  recordId: e.recordId,
565
642
  fieldLabel: a
566
643
  }), [
567
- l,
644
+ u,
568
645
  e.readOnly,
569
646
  e.mode,
570
647
  e.recordId,
571
648
  e.objectName,
572
649
  a
573
- ]), U = o(() => T >= 0 && T < z ? H(e.sections[T]) : [], [
574
- T,
575
- z,
650
+ ]), ie = Be(e), W = o(() => E >= 0 && E < B ? U(e.sections[E]) : [], [
651
+ E,
652
+ B,
576
653
  e.sections,
577
- H
578
- ]), W = n((t) => {
654
+ U
655
+ ]), G = n((t) => {
579
656
  let n = /* @__PURE__ */ new Map();
580
657
  return e.sections.forEach((e, r) => {
581
- for (let i of H(e)) {
658
+ for (let i of U(e)) {
582
659
  let e = i?.name;
583
660
  if (!e || i.hidden === !0) continue;
584
- let a = h({
661
+ let a = _({
585
662
  visibleWhen: i.visibleWhen,
586
663
  readonlyWhen: i.readonlyWhen,
587
664
  requiredWhen: i.requiredWhen
588
665
  }, t, {
589
666
  required: !!i.required,
590
- readonly: i.readonly === !0
667
+ readonly: i.readonly === !0,
668
+ serverOwnedValue: m(i, ie)
591
669
  }, void 0, void 0, `field '${e}'`);
592
- !(i.visibleOn == null || d(i.visibleOn, t, !0, void 0, void 0, { context: `visibleOn of field '${e}'` })) || !a.visible || a.readonly || !a.required || ct(t[e]) && n.set(r, [...n.get(r) ?? [], i.label || e]);
670
+ !(i.visibleOn == null || d(i.visibleOn, t, !0, void 0, void 0, { context: `visibleOn of field '${e}'` })) || !a.visible || a.readonly || !a.required || Ct(t[e]) && n.set(r, [...n.get(r) ?? [], i.label || e]);
593
671
  }
594
672
  }), n;
595
- }, [e.sections, H]), G = n(async (t) => {
673
+ }, [
674
+ e.sections,
675
+ U,
676
+ ie
677
+ ]), ae = n(async (t) => {
596
678
  let n = {
597
- ...f,
679
+ ...p,
598
680
  ...t
599
681
  };
600
- if (p(n), O((e) => new Set(e).add(T)), M((e) => {
601
- if (!e.has(T)) return e;
682
+ if (h(n), A((e) => new Set(e).add(E)), P((e) => {
683
+ if (!e.has(E)) return e;
602
684
  let t = new Set(e);
603
- return t.delete(T), t;
604
- }), V) {
605
- let t = W(n);
685
+ return t.delete(E), t;
686
+ }), H) {
687
+ let t = G(n);
606
688
  if (t.size > 0) {
607
- M(new Set(t.keys()));
689
+ P(new Set(t.keys()));
608
690
  let e = [...t.values()].flat();
609
- X.error(s("wizard.missingRequired", { fields: e.slice(0, 3).join(", ") + (e.length > 3 ? "…" : "") })), K(Math.min(...t.keys()));
691
+ X.error(l("wizard.missingRequired", { fields: e.slice(0, 3).join(", ") + (e.length > 3 ? "…" : "") })), K(Math.min(...t.keys()));
610
692
  return;
611
693
  }
612
- M(/* @__PURE__ */ new Set()), A(!0);
694
+ P(/* @__PURE__ */ new Set()), M(!0);
613
695
  try {
614
696
  if (!r) return e.onSuccess && await e.onSuccess(n), n;
615
697
  let t;
616
- if (e.mode === "create") t = await r.create(e.objectName, Ae(n, l));
698
+ if (e.mode === "create") t = await r.create(e.objectName, Ge(n, u));
617
699
  else if (e.mode === "edit" && e.recordId) {
618
- let i = await _({
700
+ let i = await y({
619
701
  dataSource: r,
620
702
  objectName: e.objectName,
621
703
  recordId: e.recordId,
622
704
  payload: n,
623
- baseRecord: f
705
+ baseRecord: p
624
706
  });
625
707
  if (i.status === "cancelled") return;
626
708
  t = i.result;
627
709
  }
628
710
  if (e.onSuccess) await e.onSuccess(t);
629
711
  else if (e.submitBehavior) {
630
- let t = e.submitBehavior;
631
- switch (t.kind) {
632
- case "redirect":
633
- xe(t.url) && setTimeout(() => window.location.assign(t.url), t.delayMs ?? 0);
712
+ let r = e.submitBehavior;
713
+ switch (r.kind) {
714
+ case "redirect": {
715
+ let i = Ne(r.url, Me(n, t));
716
+ if (!i.ok) {
717
+ X.error(i.refusal), I({
718
+ message: e.successMessage || (e.mode === "create" ? "Created" : "Saved"),
719
+ refusal: i.refusal
720
+ });
721
+ break;
722
+ }
723
+ te({
724
+ url: i.url,
725
+ delayMs: r.delayMs ?? 0
726
+ });
634
727
  break;
728
+ }
635
729
  case "continue":
636
- p(ke(l, e.initialData || e.initialValues)), O(/* @__PURE__ */ new Set()), E(0), L((e) => e + 1);
730
+ h(We(u, e.initialData || e.initialValues, { currentUserId: s })), A(/* @__PURE__ */ new Set()), D(0), re((e) => e + 1);
637
731
  break;
638
732
  default: {
639
- let n = t.kind === "thank-you" && t.message ? t.message : e.successMessage || (e.mode === "create" ? "Created" : "Saved");
640
- X.success(n), P({
641
- title: t.kind === "thank-you" ? t.title : void 0,
642
- message: n
733
+ let t = r.kind === "thank-you" && r.message ? r.message : e.successMessage || (e.mode === "create" ? "Created" : "Saved");
734
+ X.success(t), I({
735
+ title: r.kind === "thank-you" ? r.title : void 0,
736
+ message: t
643
737
  });
644
738
  break;
645
739
  }
646
740
  }
647
741
  } else {
648
- let n = Se(e.navigateOnSuccess, t);
649
- if (n) return window.location.assign(n), t;
650
- X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved")), e.resetOnSuccess && e.mode === "create" && (p(ke(l, e.initialData || e.initialValues)), O(/* @__PURE__ */ new Set()), E(0), L((e) => e + 1));
742
+ let n = ke(e.navigateOnSuccess, t);
743
+ if (n) return Le(n) ? te({
744
+ url: n,
745
+ delayMs: 0
746
+ }) : window.location.assign(n), t;
747
+ e.navigateOnSuccess ? (console.warn("[WizardForm] `navigateOnSuccess` was declared but produced no destination:", e.navigateOnSuccess), X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved"), { description: xt })) : X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved")), e.resetOnSuccess && e.mode === "create" && (h(We(u, e.initialData || e.initialValues, { currentUserId: s })), A(/* @__PURE__ */ new Set()), D(0), re((e) => e + 1));
651
748
  }
652
749
  return t;
653
750
  } catch (t) {
654
751
  throw e.onError && e.onError(t), t;
655
752
  } finally {
656
- A(!1);
753
+ M(!1);
657
754
  }
658
755
  }
659
- K(T + 1);
756
+ K(E + 1);
660
757
  }, [
661
- f,
662
- T,
663
- V,
758
+ p,
759
+ E,
760
+ H,
664
761
  e,
665
- l,
762
+ u,
666
763
  r,
667
- W,
668
- s,
669
- _
764
+ G,
765
+ l,
766
+ y
670
767
  ]), K = n((t) => {
671
- t >= 0 && t < z && (E(t), e.onStepChange && e.onStepChange(t));
672
- }, [z, e]), te = n(() => {
673
- K(T - 1);
674
- }, [T, K]), ne = n(() => {
768
+ t >= 0 && t < B && (D(t), e.onStepChange && e.onStepChange(t));
769
+ }, [B, e]), oe = n(() => {
770
+ K(E - 1);
771
+ }, [E, K]), se = n(() => {
675
772
  e.onCancel && e.onCancel();
676
- }, [e]), re = n((t) => {
677
- (e.allowSkip || D.has(t) || t <= T) && K(t);
773
+ }, [e]), ce = n((t) => {
774
+ (e.allowSkip || k.has(t) || t <= E) && K(t);
678
775
  }, [
679
776
  e.allowSkip,
680
- D,
681
- T,
777
+ k,
778
+ E,
682
779
  K
683
780
  ]);
684
- if (S) return /* @__PURE__ */ $("div", {
781
+ if (w) return /* @__PURE__ */ Q("div", {
685
782
  className: "p-4 border border-red-300 bg-red-50 rounded-md",
686
- children: [/* @__PURE__ */ Q("h3", {
783
+ children: [/* @__PURE__ */ Z("h3", {
687
784
  className: "text-red-800 font-semibold",
688
785
  children: "Error loading form"
689
- }), /* @__PURE__ */ Q("p", {
786
+ }), /* @__PURE__ */ Z("p", {
690
787
  className: "text-red-600 text-sm mt-1",
691
- children: S.message
788
+ children: w.message
692
789
  })]
693
790
  });
694
- if (b) return /* @__PURE__ */ $("div", {
791
+ if (S) return /* @__PURE__ */ Q("div", {
695
792
  className: "p-8 text-center",
696
- children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
793
+ children: [/* @__PURE__ */ Z("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Z("p", {
697
794
  className: "mt-2 text-sm text-gray-600",
698
795
  children: "Loading form..."
699
796
  })]
700
797
  });
701
- if (N) return /* @__PURE__ */ Q("div", {
702
- className: Y("w-full", i, e.className),
703
- children: /* @__PURE__ */ $("div", {
798
+ if (F) return /* @__PURE__ */ Q("div", {
799
+ className: Y("w-full space-y-4", i, e.className),
800
+ children: [/* @__PURE__ */ Q("div", {
704
801
  className: "rounded-md border bg-card p-8 text-center",
705
- children: [/* @__PURE__ */ Q("h3", {
802
+ children: [/* @__PURE__ */ Z("h3", {
706
803
  className: "text-lg font-semibold",
707
- children: N.title ?? "Thanks!"
708
- }), N.message && /* @__PURE__ */ Q("p", {
804
+ children: F.title ?? "Thanks!"
805
+ }), F.message && /* @__PURE__ */ Z("p", {
709
806
  className: "mt-2 text-sm text-muted-foreground",
710
- children: N.message
807
+ children: F.message
711
808
  })]
712
- })
809
+ }), F.refusal && /* @__PURE__ */ Z("div", {
810
+ role: "alert",
811
+ className: "rounded-md border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive",
812
+ children: F.refusal
813
+ })]
713
814
  });
714
- let q = e.sections[T], J = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, ie = J(e.columns) ?? J(q?.columns) ?? 1, ae = Ze(ie);
715
- return /* @__PURE__ */ $("div", {
815
+ let q = e.sections[E], le = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, J = le(e.columns) ?? le(q?.columns) ?? 1, ue = dt(J);
816
+ return /* @__PURE__ */ Q("div", {
716
817
  className: Y("w-full @container", i, e.className),
717
818
  children: [
718
- e.showStepIndicator !== !1 && /* @__PURE__ */ Q("nav", {
819
+ e.showStepIndicator !== !1 && /* @__PURE__ */ Z("nav", {
719
820
  "aria-label": "Progress",
720
821
  className: "mb-8",
721
- children: /* @__PURE__ */ Q("ol", {
822
+ children: /* @__PURE__ */ Z("ol", {
722
823
  className: "flex items-center",
723
824
  children: e.sections.map((t, n) => {
724
- let r = n === T, i = D.has(n), a = e.allowSkip || i || n <= T, o = j.has(n);
725
- return /* @__PURE__ */ $("li", {
726
- className: Y("relative flex-1", n !== z - 1 && "pr-8 sm:pr-12"),
727
- children: [n !== z - 1 && /* @__PURE__ */ Q("div", {
825
+ let r = n === E, i = k.has(n), a = e.allowSkip || i || n <= E, o = N.has(n);
826
+ return /* @__PURE__ */ Q("li", {
827
+ className: Y("relative flex-1", n !== B - 1 && "pr-8 sm:pr-12"),
828
+ children: [n !== B - 1 && /* @__PURE__ */ Z("div", {
728
829
  className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
729
830
  "aria-hidden": "true",
730
- children: /* @__PURE__ */ Q("div", { className: Y("h-full", i ? "bg-primary" : "bg-muted") })
731
- }), /* @__PURE__ */ $("button", {
831
+ children: /* @__PURE__ */ Z("div", { className: Y("h-full", i ? "bg-primary" : "bg-muted") })
832
+ }), /* @__PURE__ */ Q("button", {
732
833
  type: "button",
733
834
  className: Y("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
734
- onClick: () => re(n),
835
+ onClick: () => ce(n),
735
836
  disabled: !a,
736
837
  "data-testid": `wizard-step:${t.name || n}`,
737
838
  "data-error": o || void 0,
738
- children: [/* @__PURE__ */ Q("span", {
839
+ children: [/* @__PURE__ */ Z("span", {
739
840
  className: Y("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", o && "border-2 border-destructive bg-background text-destructive", !o && i && "bg-primary text-primary-foreground", !o && r && !i && "border-2 border-primary bg-background text-primary", !o && !r && !i && "border-2 border-muted bg-background text-muted-foreground"),
740
- children: o ? /* @__PURE__ */ Q(le, {
841
+ children: o ? /* @__PURE__ */ Z(ge, {
741
842
  className: "h-3 w-3 sm:h-4 sm:w-4",
742
843
  "aria-hidden": !0
743
- }) : i ? /* @__PURE__ */ Q(de, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : n + 1
744
- }), /* @__PURE__ */ Q("span", {
844
+ }) : i ? /* @__PURE__ */ Z(ve, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : n + 1
845
+ }), /* @__PURE__ */ Z("span", {
745
846
  className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block",
746
- children: /* @__PURE__ */ Q("span", {
847
+ children: /* @__PURE__ */ Z("span", {
747
848
  className: Y(o ? "text-destructive" : r ? "text-foreground" : "text-muted-foreground"),
748
849
  children: t.label || `Step ${n + 1}`
749
850
  })
@@ -753,125 +854,125 @@ var at = ({ schema: e, dataSource: r, className: i }) => {
753
854
  })
754
855
  })
755
856
  }),
756
- /* @__PURE__ */ Q("div", {
857
+ /* @__PURE__ */ Z("div", {
757
858
  className: "min-h-[200px]",
758
- children: q && /* @__PURE__ */ Q(ot, {
859
+ children: q && /* @__PURE__ */ Z(bt, {
759
860
  label: q.label,
760
861
  description: q.description,
761
862
  columns: 1,
762
863
  className: q.className,
763
864
  gridClassName: q.gridClassName,
764
- children: U.length > 0 ? /* @__PURE__ */ Q(y, { schema: {
865
+ children: W.length > 0 ? /* @__PURE__ */ Z(x, { schema: {
765
866
  type: "form",
766
867
  objectName: e.objectName,
767
- id: F,
768
- fields: ie > 1 ? Ge(U, ie, J(q.columns)) : U,
769
- columns: ie,
770
- ...ae ? { fieldContainerClass: ae } : {},
868
+ id: L,
869
+ fields: J > 1 ? $(W, J, le(q.columns)) : W,
870
+ columns: J,
871
+ ...ue ? { fieldContainerClass: ue } : {},
771
872
  layout: "vertical",
772
- defaultValues: f,
773
- previousValues: e.mode === "edit" ? m : void 0,
873
+ defaultValues: p,
874
+ previousValues: e.mode === "edit" ? g : void 0,
774
875
  showSubmit: !1,
775
876
  showCancel: !1,
776
- onSubmit: G
777
- } }, ee) : /* @__PURE__ */ Q("form", {
778
- id: F,
877
+ onSubmit: ae
878
+ } }, ne) : /* @__PURE__ */ Z("form", {
879
+ id: L,
779
880
  onSubmit: (e) => {
780
- e.preventDefault(), G({});
881
+ e.preventDefault(), ae({});
781
882
  },
782
- children: /* @__PURE__ */ Q("div", {
883
+ children: /* @__PURE__ */ Z("div", {
783
884
  className: "text-center py-8 text-muted-foreground",
784
885
  children: "No fields configured for this step"
785
886
  })
786
887
  })
787
888
  })
788
889
  }),
789
- /* @__PURE__ */ $("div", {
890
+ /* @__PURE__ */ Q("div", {
790
891
  className: "flex items-center justify-between mt-6 pt-4 border-t",
791
- children: [/* @__PURE__ */ Q("div", { children: e.showCancel !== !1 && /* @__PURE__ */ Q(I, {
892
+ children: [/* @__PURE__ */ Z("div", { children: e.showCancel !== !1 && /* @__PURE__ */ Z(R, {
792
893
  variant: "ghost",
793
- onClick: ne,
894
+ onClick: se,
794
895
  children: e.cancelText || "Cancel"
795
- }) }), /* @__PURE__ */ $("div", {
896
+ }) }), /* @__PURE__ */ Q("div", {
796
897
  className: "flex items-center gap-2",
797
898
  children: [
798
- /* @__PURE__ */ $("span", {
899
+ /* @__PURE__ */ Q("span", {
799
900
  className: "text-sm text-muted-foreground mr-2",
800
901
  children: [
801
902
  "Step ",
802
- T + 1,
903
+ E + 1,
803
904
  " of ",
804
- z
905
+ B
805
906
  ]
806
907
  }),
807
- !B && /* @__PURE__ */ $(I, {
908
+ !V && /* @__PURE__ */ Q(R, {
808
909
  variant: "outline",
809
- onClick: te,
810
- children: [/* @__PURE__ */ Q(me, { className: "h-4 w-4 mr-1" }), e.prevText || "Back"]
910
+ onClick: oe,
911
+ children: [/* @__PURE__ */ Z(xe, { className: "h-4 w-4 mr-1" }), e.prevText || "Back"]
811
912
  }),
812
- V ? /* @__PURE__ */ $(I, {
913
+ H ? /* @__PURE__ */ Q(R, {
813
914
  type: "submit",
814
- form: F,
815
- disabled: k || e.mode === "view",
816
- children: [k && /* @__PURE__ */ Q(ge, {
915
+ form: L,
916
+ disabled: j || e.mode === "view",
917
+ children: [j && /* @__PURE__ */ Z(Ce, {
817
918
  className: "mr-2 h-4 w-4 animate-spin",
818
919
  "aria-hidden": !0
819
- }), k ? "Submitting..." : e.submitText || (e.mode === "create" ? "Create" : "Update")]
820
- }) : /* @__PURE__ */ $(I, {
920
+ }), j ? "Submitting..." : e.submitText || (e.mode === "create" ? "Create" : "Update")]
921
+ }) : /* @__PURE__ */ Q(R, {
821
922
  type: "submit",
822
- form: F,
823
- children: [e.nextText || "Next", /* @__PURE__ */ Q(he, { className: "h-4 w-4 ml-1" })]
923
+ form: L,
924
+ children: [e.nextText || "Next", /* @__PURE__ */ Z(Se, { className: "h-4 w-4 ml-1" })]
824
925
  })
825
926
  ]
826
927
  })]
827
928
  }),
828
- v
929
+ b
829
930
  ]
830
931
  });
831
- }, ut = ({ schema: e, dataSource: t, className: r }) => {
832
- let { fieldLabel: a } = C(), [l, u] = c(null), [d, f] = c({}), { saveWithOcc: p, conflictDialog: m } = it(), [h, g] = c(!0), [_, v] = c(null);
932
+ }, Tt = ({ schema: e, dataSource: t, className: r }) => {
933
+ let { fieldLabel: a } = O(), { userId: l } = pe(), [u, d] = c(null), [f, p] = c({}), { saveWithOcc: m, conflictDialog: h } = vt(), [g, _] = c(!0), [v, y] = c(null);
833
934
  i(() => {
834
935
  (async () => {
835
936
  if (!t) {
836
- g(!1);
937
+ _(!1);
837
938
  return;
838
939
  }
839
940
  try {
840
941
  let n = await t.getObjectSchema(e.objectName);
841
- u(n);
942
+ d(n);
842
943
  } catch (e) {
843
- v(e), g(!1);
944
+ y(e), _(!1);
844
945
  }
845
946
  })();
846
947
  }, [e.objectName, t]);
847
948
  let b = s(void 0);
848
949
  i(() => {
849
950
  let n = !1;
850
- return (l || !t) && (async () => {
951
+ return (u || !t) && (async () => {
851
952
  if (e.mode === "create" || !e.recordId) {
852
- f(ke(l, e.initialData || e.initialValues)), g(!1);
953
+ p(We(u, e.initialData || e.initialValues, { currentUserId: l })), _(!1);
853
954
  return;
854
955
  }
855
956
  if (!t) {
856
- f(e.initialData || e.initialValues || {}), g(!1);
957
+ p(e.initialData || e.initialValues || {}), _(!1);
857
958
  return;
858
959
  }
859
- b.current !== e.recordId && g(!0);
960
+ b.current !== e.recordId && _(!0);
860
961
  try {
861
962
  let r = await t.findOne(e.objectName, e.recordId);
862
963
  if (n) return;
863
- b.current = e.recordId, f(r || {});
964
+ b.current = e.recordId, p(r || {});
864
965
  } catch (e) {
865
966
  if (n) return;
866
- v(e);
967
+ y(e);
867
968
  } finally {
868
- n || g(!1);
969
+ n || _(!1);
869
970
  }
870
971
  })(), () => {
871
972
  n = !0;
872
973
  };
873
974
  }, [
874
- l,
975
+ u,
875
976
  e.mode,
876
977
  e.recordId,
877
978
  e.initialData,
@@ -879,32 +980,32 @@ var at = ({ schema: e, dataSource: r, className: i }) => {
879
980
  t,
880
981
  e.objectName
881
982
  ]);
882
- let x = n((t) => Ie(t, {
883
- objectSchema: l,
983
+ let S = n((t) => Ze(t, {
984
+ objectSchema: u,
884
985
  objectName: e.objectName,
885
986
  readOnly: e.readOnly,
886
987
  mode: e.mode,
887
988
  recordId: e.recordId,
888
989
  fieldLabel: a
889
990
  }), [
890
- l,
991
+ u,
891
992
  e.readOnly,
892
993
  e.mode,
893
994
  e.recordId,
894
995
  e.objectName,
895
996
  a
896
- ]), S = n(async (n) => {
997
+ ]), C = n(async (n) => {
897
998
  if (!t) return e.onSuccess && await e.onSuccess(n), n;
898
999
  try {
899
1000
  let r;
900
- if (e.mode === "create") r = await t.create(e.objectName, Ae(n, l));
1001
+ if (e.mode === "create") r = await t.create(e.objectName, Ge(n, u));
901
1002
  else if (e.mode === "edit" && e.recordId) {
902
- let i = await p({
1003
+ let i = await m({
903
1004
  dataSource: t,
904
1005
  objectName: e.objectName,
905
1006
  recordId: e.recordId,
906
1007
  payload: n,
907
- baseRecord: d
1008
+ baseRecord: f
908
1009
  });
909
1010
  if (i.status === "cancelled") return;
910
1011
  r = i.result;
@@ -916,32 +1017,32 @@ var at = ({ schema: e, dataSource: r, className: i }) => {
916
1017
  }, [
917
1018
  e,
918
1019
  t,
919
- p,
920
- d
1020
+ m,
1021
+ f
921
1022
  ]), w = n(() => {
922
1023
  e.onCancel && e.onCancel();
923
- }, [e]), T = (e, t) => e.pane === "primary" || e.pane === "secondary" ? e.pane : t === 0 ? "primary" : "secondary", E = o(() => e.sections.filter((e, t) => T(e, t) === "primary"), [e.sections]), D = o(() => e.sections.filter((e, t) => T(e, t) === "secondary"), [e.sections]), O = e.splitDirection || "horizontal", k = e.splitSize || 50;
924
- if (_) return /* @__PURE__ */ $("div", {
1024
+ }, [e]), T = (e, t) => e.pane === "primary" || e.pane === "secondary" ? e.pane : t === 0 ? "primary" : "secondary", E = o(() => e.sections.filter((e, t) => T(e, t) === "primary"), [e.sections]), D = o(() => e.sections.filter((e, t) => T(e, t) === "secondary"), [e.sections]), k = e.splitDirection || "horizontal", A = e.splitSize || 50;
1025
+ if (v) return /* @__PURE__ */ Q("div", {
925
1026
  className: "p-4 border border-red-300 bg-red-50 rounded-md",
926
- children: [/* @__PURE__ */ Q("h3", {
1027
+ children: [/* @__PURE__ */ Z("h3", {
927
1028
  className: "text-red-800 font-semibold",
928
1029
  children: "Error loading form"
929
- }), /* @__PURE__ */ Q("p", {
1030
+ }), /* @__PURE__ */ Z("p", {
930
1031
  className: "text-red-600 text-sm mt-1",
931
- children: _.message
1032
+ children: v.message
932
1033
  })]
933
1034
  });
934
- if (h) return /* @__PURE__ */ $("div", {
1035
+ if (g) return /* @__PURE__ */ Q("div", {
935
1036
  className: "p-8 text-center",
936
- children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
1037
+ children: [/* @__PURE__ */ Z("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Z("p", {
937
1038
  className: "mt-2 text-sm text-gray-600",
938
1039
  children: "Loading form..."
939
1040
  })]
940
1041
  });
941
- let A = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, j = e.sections.map((e) => A(e.columns)).filter((e) => e != null), M = A(e.columns) ?? (j.length ? Math.max(...j) : 1), N = Ze(M), P = (e, t) => {
1042
+ let j = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, M = e.sections.map((e) => j(e.columns)).filter((e) => e != null), N = j(e.columns) ?? (M.length ? Math.max(...M) : 1), P = dt(N), F = (e, t) => {
942
1043
  let n = [];
943
1044
  return e.forEach((e, r) => {
944
- let i = x(e);
1045
+ let i = S(e);
945
1046
  i.length && ((e.label || e.description) && n.push({
946
1047
  name: `__section_${e.name || `${t}_${r}`}`,
947
1048
  label: e.label,
@@ -949,49 +1050,49 @@ var at = ({ schema: e, dataSource: r, className: i }) => {
949
1050
  type: "section-divider",
950
1051
  colSpan: 4,
951
1052
  className: e.className
952
- }), n.push(...M > 1 ? Ge(i, M, A(e.columns)) : i));
1053
+ }), n.push(...N > 1 ? $(i, N, j(e.columns)) : i));
953
1054
  }), n;
954
- }, F = [{
1055
+ }, I = [{
955
1056
  key: "primary",
956
1057
  sections: E,
957
- defaultSize: k
1058
+ defaultSize: A
958
1059
  }, {
959
1060
  key: "secondary",
960
1061
  sections: D,
961
- defaultSize: 100 - k
1062
+ defaultSize: 100 - A
962
1063
  }].map((e) => ({
963
1064
  ...e,
964
- fields: P(e.sections, e.key),
1065
+ fields: F(e.sections, e.key),
965
1066
  containerClass: e.sections.length === 1 ? e.sections[0].gridClassName : void 0
966
1067
  })).filter((e) => e.fields.length > 0);
967
- return /* @__PURE__ */ $("div", {
1068
+ return /* @__PURE__ */ Q("div", {
968
1069
  className: Y("w-full @container", r, e.className),
969
- children: [/* @__PURE__ */ Q(y, { schema: {
1070
+ children: [/* @__PURE__ */ Z(x, { schema: {
970
1071
  type: "form",
971
1072
  objectName: e.objectName,
972
- fields: F.flatMap((e) => e.fields),
973
- columns: M,
974
- ...N ? { fieldContainerClass: N } : {},
1073
+ fields: I.flatMap((e) => e.fields),
1074
+ columns: N,
1075
+ ...P ? { fieldContainerClass: P } : {},
975
1076
  layout: "vertical",
976
- defaultValues: d,
977
- previousValues: e.mode === "edit" && e.recordId ? d : void 0,
1077
+ defaultValues: f,
1078
+ previousValues: e.mode === "edit" && e.recordId ? f : void 0,
978
1079
  submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
979
1080
  cancelLabel: e.cancelText,
980
1081
  showSubmit: e.showSubmit !== !1 && e.mode !== "view",
981
1082
  showCancel: e.showCancel !== !1,
982
- onSubmit: S,
1083
+ onSubmit: C,
983
1084
  onCancel: w,
984
- fieldPanes: F.map((e) => ({
1085
+ fieldPanes: I.map((e) => ({
985
1086
  key: e.key,
986
1087
  fields: e.fields.map((e) => e.name),
987
1088
  defaultSize: e.defaultSize,
988
1089
  ...e.containerClass ? { containerClass: e.containerClass } : {}
989
1090
  })),
990
- fieldPanesOrientation: O,
1091
+ fieldPanesOrientation: k,
991
1092
  fieldPanesResizable: e.splitResizable !== !1
992
- } }), m]
1093
+ } }), h]
993
1094
  });
994
- }, dt = /* @__PURE__ */ new Set([
1095
+ }, Et = /* @__PURE__ */ new Set([
995
1096
  "id",
996
1097
  "_id",
997
1098
  "created_at",
@@ -1000,7 +1101,7 @@ var at = ({ schema: e, dataSource: r, className: i }) => {
1000
1101
  "updatedAt",
1001
1102
  "organization_id",
1002
1103
  "organizationId"
1003
- ]), ft = /* @__PURE__ */ new Set([
1104
+ ]), Dt = /* @__PURE__ */ new Set([
1004
1105
  "formula",
1005
1106
  "summary",
1006
1107
  "rollup",
@@ -1009,15 +1110,15 @@ var at = ({ schema: e, dataSource: r, className: i }) => {
1009
1110
  "autonumber",
1010
1111
  "computed"
1011
1112
  ]);
1012
- function pt(e, t) {
1113
+ function Ot(e, t) {
1013
1114
  if (!e || typeof e != "object") return e;
1014
1115
  let n = {}, r = t?.fields;
1015
- for (let [t, i] of Object.entries(e)) if (!dt.has(t)) {
1116
+ for (let [t, i] of Object.entries(e)) if (!Et.has(t)) {
1016
1117
  if (r) {
1017
1118
  let e = r[t];
1018
1119
  if (!e) continue;
1019
1120
  let n = String(e.type || "").toLowerCase();
1020
- if (ft.has(n) || e.computed === !0 || e.formula || e.readOnly === !0 || e.readonly === !0) continue;
1121
+ if (Dt.has(n) || e.computed === !0 || e.formula || e.readOnly === !0 || e.readonly === !0) continue;
1021
1122
  }
1022
1123
  n[t] = i;
1023
1124
  }
@@ -1025,31 +1126,31 @@ function pt(e, t) {
1025
1126
  }
1026
1127
  //#endregion
1027
1128
  //#region src/masterDetailTx.ts
1028
- var mt = (e) => e == null ? void 0 : e.id ?? e._id ?? e.recordId, ht = (e, t) => t ? pt(e, t) : e, gt = /* @__PURE__ */ new Set([
1129
+ var kt = (e) => e == null ? void 0 : e.id ?? e._id ?? e.recordId, At = (e, t) => t ? Ot(e, t) : e, jt = /* @__PURE__ */ new Set([
1029
1130
  "id",
1030
1131
  "_id",
1031
1132
  "recordId"
1032
1133
  ]);
1033
- function _t(e, t) {
1034
- return !e || Object.entries(e).every(([e, n]) => e === t || gt.has(e) ? !0 : n == null || n === "");
1134
+ function Mt(e, t) {
1135
+ return !e || Object.entries(e).every(([e, n]) => e === t || jt.has(e) ? !0 : n == null || n === "");
1035
1136
  }
1036
- function vt(e, t, n) {
1137
+ function Nt(e, t, n) {
1037
1138
  let r = [{
1038
1139
  object: e,
1039
1140
  action: "create",
1040
1141
  data: t
1041
1142
  }];
1042
- for (let e of n) for (let t of e.rows) _t(t, e.relationshipField) || r.push({
1143
+ for (let e of n) for (let t of e.rows) Mt(t, e.relationshipField) || r.push({
1043
1144
  object: e.childObject,
1044
1145
  action: "create",
1045
1146
  data: {
1046
- ...ht(t, e.childSchema),
1147
+ ...At(t, e.childSchema),
1047
1148
  [e.relationshipField]: { $ref: 0 }
1048
1149
  }
1049
1150
  });
1050
1151
  return r;
1051
1152
  }
1052
- function yt(e, t, n, r) {
1153
+ function Pt(e, t, n, r) {
1053
1154
  let i = [{
1054
1155
  object: e,
1055
1156
  action: "update",
@@ -1060,21 +1161,21 @@ function yt(e, t, n, r) {
1060
1161
  let n = (e.rows || []).map((n) => ({
1061
1162
  ...n,
1062
1163
  [e.relationshipField]: t
1063
- })), { toCreate: r, toUpdate: a, toDelete: o } = bt(e.original || [], n);
1164
+ })), { toCreate: r, toUpdate: a, toDelete: o } = Ft(e.original || [], n);
1064
1165
  for (let t of r) {
1065
- if (_t(t, e.relationshipField)) continue;
1166
+ if (Mt(t, e.relationshipField)) continue;
1066
1167
  let { id: n, _id: r, recordId: a, ...o } = t;
1067
1168
  i.push({
1068
1169
  object: e.childObject,
1069
1170
  action: "create",
1070
- data: ht(o, e.childSchema)
1171
+ data: At(o, e.childSchema)
1071
1172
  });
1072
1173
  }
1073
1174
  for (let t of a) i.push({
1074
1175
  object: e.childObject,
1075
1176
  action: "update",
1076
- id: mt(t),
1077
- data: ht(t, e.childSchema)
1177
+ id: kt(t),
1178
+ data: At(t, e.childSchema)
1078
1179
  });
1079
1180
  for (let t of o) i.push({
1080
1181
  object: e.childObject,
@@ -1084,15 +1185,15 @@ function yt(e, t, n, r) {
1084
1185
  }
1085
1186
  return i;
1086
1187
  }
1087
- function bt(e, t) {
1088
- let n = new Set(t.map(mt).filter(Boolean));
1188
+ function Ft(e, t) {
1189
+ let n = new Set(t.map(kt).filter(Boolean));
1089
1190
  return {
1090
- toCreate: t.filter((e) => !mt(e)),
1091
- toUpdate: t.filter((e) => mt(e)),
1092
- toDelete: (e || []).map(mt).filter((e) => !!e && !n.has(e))
1191
+ toCreate: t.filter((e) => !kt(e)),
1192
+ toUpdate: t.filter((e) => kt(e)),
1193
+ toDelete: (e || []).map(kt).filter((e) => !!e && !n.has(e))
1093
1194
  };
1094
1195
  }
1095
- function xt(e, t) {
1196
+ function It(e, t) {
1096
1197
  return Array.isArray(e) ? e.reduce((e, n) => {
1097
1198
  let r = Number(n?.[t]);
1098
1199
  return e + (Number.isFinite(r) ? r : 0);
@@ -1100,7 +1201,7 @@ function xt(e, t) {
1100
1201
  }
1101
1202
  //#endregion
1102
1203
  //#region src/deriveMasterDetail.ts
1103
- var St = /* @__PURE__ */ new Set([
1204
+ var Lt = /* @__PURE__ */ new Set([
1104
1205
  "id",
1105
1206
  "_id",
1106
1207
  "recordId",
@@ -1116,14 +1217,14 @@ var St = /* @__PURE__ */ new Set([
1116
1217
  "tenant_id",
1117
1218
  "space",
1118
1219
  "owner"
1119
- ]), Ct = /* @__PURE__ */ new Set([
1220
+ ]), Rt = /* @__PURE__ */ new Set([
1120
1221
  "position",
1121
1222
  "sort_order",
1122
1223
  "sequence",
1123
1224
  "line_no",
1124
1225
  "line_number",
1125
1226
  "sort"
1126
- ]), wt = /* @__PURE__ */ new Set([
1227
+ ]), zt = /* @__PURE__ */ new Set([
1127
1228
  "formula",
1128
1229
  "summary",
1129
1230
  "rollup",
@@ -1139,7 +1240,7 @@ var St = /* @__PURE__ */ new Set([
1139
1240
  "markdown",
1140
1241
  "richtext"
1141
1242
  ]);
1142
- function Tt(e) {
1243
+ function Bt(e) {
1143
1244
  switch (e) {
1144
1245
  case "number":
1145
1246
  case "percent":
@@ -1162,11 +1263,11 @@ function Tt(e) {
1162
1263
  default: return "text";
1163
1264
  }
1164
1265
  }
1165
- var Et = /* @__PURE__ */ new Set(["image", "avatar"]);
1166
- function Dt(e, t) {
1167
- e.multiple == null && t?.multiple && (e.multiple = !0), e.accept ?? (Array.isArray(t?.accept) && t.accept.length > 0 ? e.accept = t.accept : Et.has(t?.type) && (e.accept = ["image/*"]));
1266
+ var Vt = /* @__PURE__ */ new Set(["image", "avatar"]);
1267
+ function Ht(e, t) {
1268
+ e.multiple == null && t?.multiple && (e.multiple = !0), e.accept ?? (Array.isArray(t?.accept) && t.accept.length > 0 ? e.accept = t.accept : Vt.has(t?.type) && (e.accept = ["image/*"]));
1168
1269
  }
1169
- function Ot(e) {
1270
+ function Ut(e) {
1170
1271
  if (e?.type === "boolean" || e?.type === "toggle") return [{
1171
1272
  label: "Yes",
1172
1273
  value: "true"
@@ -1183,7 +1284,7 @@ function Ot(e) {
1183
1284
  value: String(e)
1184
1285
  });
1185
1286
  }
1186
- function kt(e, t) {
1287
+ function Wt(e, t) {
1187
1288
  let n = e?.fields;
1188
1289
  if (!n || typeof n != "object") return;
1189
1290
  let r;
@@ -1196,7 +1297,7 @@ function kt(e, t) {
1196
1297
  }
1197
1298
  return r;
1198
1299
  }
1199
- var At = [
1300
+ var Gt = [
1200
1301
  "name",
1201
1302
  "title",
1202
1303
  "subject",
@@ -1204,7 +1305,7 @@ var At = [
1204
1305
  "full_name",
1205
1306
  "display_name",
1206
1307
  "code"
1207
- ], jt = {
1308
+ ], Kt = {
1208
1309
  select: 0,
1209
1310
  currency: 1,
1210
1311
  number: 1,
@@ -1214,81 +1315,81 @@ var At = [
1214
1315
  time: 3,
1215
1316
  text: 4
1216
1317
  };
1217
- function Mt(e) {
1218
- return (e.type ? jt[e.type] : void 0) ?? 5;
1318
+ function qt(e) {
1319
+ return (e.type ? Kt[e.type] : void 0) ?? 5;
1219
1320
  }
1220
- function Nt(e, t) {
1321
+ function Jt(e, t) {
1221
1322
  if (t <= 0 || e.length <= t) return e;
1222
- let n = /* @__PURE__ */ new Set(), r = e.find((e) => At.includes(e.field)) ?? e[0];
1223
- r && n.add(r.field);
1224
- for (let t of e) t.required && n.add(t.field);
1323
+ let n = /* @__PURE__ */ new Set(), r = e.find((e) => Gt.includes(e.name)) ?? e[0];
1324
+ r && n.add(r.name);
1325
+ for (let t of e) t.required && n.add(t.name);
1225
1326
  let i = e.map((e, t) => ({
1226
1327
  c: e,
1227
1328
  i: t
1228
- })).filter(({ c: e }) => !n.has(e.field)).sort((e, t) => Mt(e.c) - Mt(t.c) || e.i - t.i);
1329
+ })).filter(({ c: e }) => !n.has(e.name)).sort((e, t) => qt(e.c) - qt(t.c) || e.i - t.i);
1229
1330
  for (let { c: e } of i) {
1230
1331
  if (n.size >= t) break;
1231
- n.add(e.field);
1332
+ n.add(e.name);
1232
1333
  }
1233
- return e.map((e) => n.has(e.field) ? e : {
1334
+ return e.map((e) => n.has(e.name) ? e : {
1234
1335
  ...e,
1235
1336
  defaultHidden: !0
1236
1337
  });
1237
1338
  }
1238
- function Pt(e, t = {}) {
1339
+ function Yt(e, t = {}) {
1239
1340
  let n = e?.fields;
1240
1341
  if (!n || typeof n != "object") return [];
1241
1342
  let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
1242
1343
  for (let [e, t] of Object.entries(n)) {
1243
1344
  let n = t;
1244
- if (St.has(e) || r.has(e) || Ct.has(e) || n?.system || n?.readonly || n?.hidden || wt.has(n?.type)) continue;
1345
+ if (Lt.has(e) || r.has(e) || Rt.has(e) || n?.system || n?.readonly || n?.hidden || zt.has(n?.type)) continue;
1245
1346
  let a = {
1246
- field: e,
1347
+ name: e,
1247
1348
  label: n?.label || e,
1248
- type: Tt(n?.type),
1349
+ type: Bt(n?.type),
1249
1350
  required: !!n?.required
1250
- }, o = Ot(n);
1251
- a.type === "select" && o && (a.options = o), a.type === "lookup" && (a.reference = n?.reference, a.displayField = n?.display_field || n?.reference_field), a.type === "file" && Dt(a, n), n?.readonlyWhen && (a.readonlyWhen = n.readonlyWhen), n?.requiredWhen && (a.requiredWhen = n.requiredWhen);
1351
+ }, o = Ut(n);
1352
+ a.type === "select" && o && (a.options = o), a.type === "lookup" && (a.reference = n?.reference, a.displayField = n?.display_field || n?.reference_field), a.type === "file" && Ht(a, n), n?.readonlyWhen && (a.readonlyWhen = n.readonlyWhen), n?.requiredWhen && (a.requiredWhen = n.requiredWhen);
1252
1353
  let s = typeof n?.expression == "string" ? n.expression : n?.expression?.source;
1253
1354
  s && typeof s == "string" && (a.computed = !0, a.expr = s, a.required = !1, typeof n?.scale == "number" && (a.scale = n.scale)), i.push(a);
1254
1355
  }
1255
- return Nt(i, t.maxColumns ?? 6);
1356
+ return Jt(i, t.maxColumns ?? 6);
1256
1357
  }
1257
- function Ft(e, t) {
1358
+ function Xt(e, t) {
1258
1359
  let n = e ?? [], r = t?.fields;
1259
1360
  return !n.length || !r || typeof r != "object" ? n : n.map((e) => {
1260
1361
  if (e.type) return e;
1261
- let t = r[e.field];
1362
+ let t = r[e.name];
1262
1363
  if (!t) return e;
1263
- let n = Tt(t?.type), i = {
1364
+ let n = Bt(t?.type), i = {
1264
1365
  ...e,
1265
1366
  type: n
1266
1367
  };
1267
- i.label ??= t?.label || e.field, i.required ??= !!t?.required;
1268
- let a = Ot(t);
1269
- n === "select" && a && !i.options && (i.options = a), n === "lookup" && (i.reference ??= t?.reference, i.displayField ??= t?.display_field || t?.reference_field), n === "file" && Dt(i, t), i.readonlyWhen == null && t?.readonlyWhen && (i.readonlyWhen = t.readonlyWhen), i.requiredWhen == null && t?.requiredWhen && (i.requiredWhen = t.requiredWhen);
1368
+ i.label ??= t?.label || e.name, i.required ??= !!t?.required;
1369
+ let a = Ut(t);
1370
+ n === "select" && a && !i.options && (i.options = a), n === "lookup" && (i.reference ??= t?.reference, i.displayField ??= t?.display_field || t?.reference_field), n === "file" && Ht(i, t), i.readonlyWhen == null && t?.readonlyWhen && (i.readonlyWhen = t.readonlyWhen), i.requiredWhen == null && t?.requiredWhen && (i.requiredWhen = t.requiredWhen);
1270
1371
  let o = typeof t?.expression == "string" ? t.expression : t?.expression?.source;
1271
1372
  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;
1272
1373
  });
1273
1374
  }
1274
- var It = /* @__PURE__ */ new Set([
1375
+ var Zt = /* @__PURE__ */ new Set([
1275
1376
  "formula",
1276
1377
  "summary",
1277
1378
  "rollup",
1278
1379
  "autonumber",
1279
1380
  "auto_number"
1280
1381
  ]);
1281
- function Lt(e, t = {}) {
1382
+ function Qt(e, t = {}) {
1282
1383
  let n = e?.fields;
1283
1384
  if (!n || typeof n != "object") return [];
1284
1385
  let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
1285
1386
  for (let [e, t] of Object.entries(n)) {
1286
1387
  let n = t;
1287
- St.has(e) || r.has(e) || Ct.has(e) || n?.system || n?.hidden || It.has(n?.type) || i.push(e);
1388
+ Lt.has(e) || r.has(e) || Rt.has(e) || n?.system || n?.hidden || Zt.has(n?.type) || i.push(e);
1288
1389
  }
1289
1390
  return i;
1290
1391
  }
1291
- var Rt = /* @__PURE__ */ new Set([
1392
+ var $t = /* @__PURE__ */ new Set([
1292
1393
  "textarea",
1293
1394
  "richtext",
1294
1395
  "html",
@@ -1297,17 +1398,17 @@ var Rt = /* @__PURE__ */ new Set([
1297
1398
  "json",
1298
1399
  "location",
1299
1400
  "address"
1300
- ]), zt = /* @__PURE__ */ new Set([
1401
+ ]), en = /* @__PURE__ */ new Set([
1301
1402
  "file",
1302
1403
  "image",
1303
1404
  "avatar"
1304
1405
  ]);
1305
- function Bt(e, t, n = {}) {
1406
+ function tn(e, t, n = {}) {
1306
1407
  if (t === "grid" || t === "form") return t;
1307
- let r = e?.fields ?? {}, i = Lt(e, { relationshipField: n.relationshipField });
1308
- return i.some((e) => Rt.has(r[e]?.type)) || i.filter((e) => zt.has(r[e]?.type)).length >= 2 || i.length > 8 ? "form" : "grid";
1408
+ let r = e?.fields ?? {}, i = Qt(e, { relationshipField: n.relationshipField });
1409
+ return i.some((e) => $t.has(r[e]?.type)) || i.filter((e) => en.has(r[e]?.type)).length >= 2 || i.length > 8 ? "form" : "grid";
1309
1410
  }
1310
- var Vt = [
1411
+ var nn = [
1311
1412
  "amount",
1312
1413
  "total",
1313
1414
  "subtotal",
@@ -1315,33 +1416,33 @@ var Vt = [
1315
1416
  "line_amount",
1316
1417
  "net_amount"
1317
1418
  ];
1318
- function Ht(e) {
1419
+ function rn(e) {
1319
1420
  let t = e.filter((e) => e.type === "number" || e.type === "currency");
1320
1421
  if (t.length === 0) return;
1321
1422
  let n = t.find((e) => e.computed);
1322
- if (n) return n.field;
1323
- let r = t.find((e) => Vt.includes(e.field));
1324
- if (r) return r.field;
1423
+ if (n) return n.name;
1424
+ let r = t.find((e) => nn.includes(e.name));
1425
+ if (r) return r.name;
1325
1426
  let i = [...t].reverse().find((e) => e.type === "currency");
1326
- return i ? i.field : t[t.length - 1].field;
1427
+ return i ? i.name : t[t.length - 1].name;
1327
1428
  }
1328
- function Ut(e, t, n, r = {}) {
1329
- let i = r.relationshipField || kt(t, n);
1429
+ function an(e, t, n, r = {}) {
1430
+ let i = r.relationshipField || Wt(t, n);
1330
1431
  if (!i) throw Error(`MasterDetailForm: could not find a lookup/master_detail field on "${e}" referencing "${n}". Set relationshipField explicitly.`);
1331
- let a = r.columns?.length ? Ft(r.columns, t) : Pt(t, { relationshipField: i }), o = r.amountField || Ht(a);
1432
+ let a = r.columns?.length ? Xt(r.columns, t) : Yt(t, { relationshipField: i }), o = r.amountField || rn(a);
1332
1433
  return {
1333
1434
  childObject: e,
1334
1435
  relationshipField: i,
1335
1436
  columns: a,
1336
- formFields: Lt(t, { relationshipField: i }),
1337
- mode: Bt(t, r.inlineEdit ?? (t?.fields)?.[i]?.inlineEdit, { relationshipField: i }),
1437
+ formFields: Qt(t, { relationshipField: i }),
1438
+ mode: tn(t, r.inlineEdit ?? (t?.fields)?.[i]?.inlineEdit, { relationshipField: i }),
1338
1439
  amountField: o,
1339
- sortField: Object.keys(t?.fields ?? {}).find((e) => Ct.has(e))
1440
+ sortField: Object.keys(t?.fields ?? {}).find((e) => Rt.has(e))
1340
1441
  };
1341
1442
  }
1342
1443
  //#endregion
1343
1444
  //#region src/MasterDetailForm.tsx
1344
- function Wt(e) {
1445
+ function on(e) {
1345
1446
  if (!e) return {};
1346
1447
  let t = {};
1347
1448
  return e.querySelectorAll("[name]").forEach((e) => {
@@ -1373,13 +1474,13 @@ function Wt(e) {
1373
1474
  }
1374
1475
  }), t;
1375
1476
  }
1376
- var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, formKey: o, onRowExpand: l, onAddViaForm: u }) => {
1477
+ var sn = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, formKey: o, onRowExpand: l, onAddViaForm: u }) => {
1377
1478
  let [d, f] = c({}), p = s("");
1378
1479
  i(() => {
1379
1480
  let e = r.current;
1380
1481
  if (!e) return;
1381
1482
  let t = () => {
1382
- let t = Wt(e), n;
1483
+ let t = on(e), n;
1383
1484
  try {
1384
1485
  n = JSON.stringify(t);
1385
1486
  } catch {
@@ -1403,16 +1504,16 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1403
1504
  o,
1404
1505
  e.length
1405
1506
  ]);
1406
- let m = d[a], h = m === void 0 ? null : Number.isFinite(Number(m)) ? Number(m) : 0, g = e.reduce((e, n, r) => e + xt(t[r]?.rows ?? [], n.amountField || "amount"), 0), _ = h !== null && e.some((e) => !!e.amountField), v = h ?? 0, y = v / 100 * g, b = g + y, x = (e) => `¥${e.toLocaleString(void 0, {
1507
+ let m = d[a], h = m === void 0 ? null : Number.isFinite(Number(m)) ? Number(m) : 0, g = e.reduce((e, n, r) => e + It(t[r]?.rows ?? [], n.amountField || "amount"), 0), _ = h !== null && e.some((e) => !!e.amountField), v = h ?? 0, y = v / 100 * g, b = g + y, x = (e) => `¥${e.toLocaleString(void 0, {
1407
1508
  minimumFractionDigits: 2,
1408
1509
  maximumFractionDigits: 2
1409
1510
  })}`;
1410
- return /* @__PURE__ */ $(be, { children: [e.map((e, r) => /* @__PURE__ */ $("section", {
1511
+ return /* @__PURE__ */ Q(De, { children: [e.map((e, r) => /* @__PURE__ */ Q("section", {
1411
1512
  className: "space-y-2",
1412
- children: [/* @__PURE__ */ Q("h3", {
1513
+ children: [/* @__PURE__ */ Z("h3", {
1413
1514
  className: "text-sm font-medium text-foreground",
1414
1515
  children: e.title || "Line Items"
1415
- }), e.columns?.length ? /* @__PURE__ */ Q(T, {
1516
+ }), e.columns?.length ? /* @__PURE__ */ Z(A, {
1416
1517
  value: t[r]?.rows ?? [],
1417
1518
  onChange: (e) => n(r, e),
1418
1519
  contextRecord: d,
@@ -1427,45 +1528,45 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1427
1528
  max_rows: e.maxRows,
1428
1529
  add_label: e.inlineMode === "form" ? e.addLabel || "Add" : e.addLabel
1429
1530
  }
1430
- }) : /* @__PURE__ */ Q("p", {
1531
+ }) : /* @__PURE__ */ Z("p", {
1431
1532
  className: "py-4 text-sm text-muted-foreground",
1432
1533
  children: "Loading columns…"
1433
1534
  })]
1434
- }, `${e.childObject}-${r}`)), _ && /* @__PURE__ */ Q("div", {
1535
+ }, `${e.childObject}-${r}`)), _ && /* @__PURE__ */ Z("div", {
1435
1536
  className: "flex justify-end",
1436
- children: /* @__PURE__ */ $("dl", {
1537
+ children: /* @__PURE__ */ Q("dl", {
1437
1538
  className: "w-64 space-y-1.5 text-sm",
1438
1539
  "data-testid": "md-totals",
1439
1540
  children: [
1440
- /* @__PURE__ */ $("div", {
1541
+ /* @__PURE__ */ Q("div", {
1441
1542
  className: "flex items-center justify-between",
1442
- children: [/* @__PURE__ */ Q("dt", {
1543
+ children: [/* @__PURE__ */ Z("dt", {
1443
1544
  className: "text-muted-foreground",
1444
1545
  children: "Subtotal"
1445
- }), /* @__PURE__ */ Q("dd", {
1546
+ }), /* @__PURE__ */ Z("dd", {
1446
1547
  className: "tabular-nums",
1447
1548
  "data-testid": "md-subtotal",
1448
1549
  children: x(g)
1449
1550
  })]
1450
1551
  }),
1451
- /* @__PURE__ */ $("div", {
1552
+ /* @__PURE__ */ Q("div", {
1452
1553
  className: "flex items-center justify-between",
1453
- children: [/* @__PURE__ */ $("dt", {
1554
+ children: [/* @__PURE__ */ Q("dt", {
1454
1555
  className: "text-muted-foreground",
1455
1556
  children: [
1456
1557
  "Tax (",
1457
1558
  v,
1458
1559
  "%)"
1459
1560
  ]
1460
- }), /* @__PURE__ */ Q("dd", {
1561
+ }), /* @__PURE__ */ Z("dd", {
1461
1562
  className: "tabular-nums",
1462
1563
  "data-testid": "md-tax",
1463
1564
  children: x(y)
1464
1565
  })]
1465
1566
  }),
1466
- /* @__PURE__ */ $("div", {
1567
+ /* @__PURE__ */ Q("div", {
1467
1568
  className: "flex items-center justify-between border-t border-border pt-1.5 text-base font-semibold",
1468
- children: [/* @__PURE__ */ Q("dt", { children: "Total" }), /* @__PURE__ */ Q("dd", {
1569
+ children: [/* @__PURE__ */ Z("dt", { children: "Total" }), /* @__PURE__ */ Z("dd", {
1469
1570
  className: "tabular-nums",
1470
1571
  "data-testid": "md-grand-total",
1471
1572
  children: x(b)
@@ -1474,7 +1575,7 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1474
1575
  ]
1475
1576
  })
1476
1577
  })] });
1477
- }, Kt = ({ schema: e, dataSource: t, className: r }) => {
1578
+ }, cn = ({ schema: e, dataSource: t, className: r }) => {
1478
1579
  let a = e.details || [], l = e.mode === "edit" && !!e.recordId, u = a.some((e) => !e.relationshipField || !e.columns?.length || e.columns.some((e) => !e.type)), [d, f] = c(u ? null : a), p = d ?? a;
1479
1580
  i(() => {
1480
1581
  if (!u) {
@@ -1491,9 +1592,9 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1491
1592
  let r = await t.getObjectSchema(n.childObject);
1492
1593
  if (n.relationshipField && n.columns?.length) return {
1493
1594
  ...n,
1494
- columns: Ft(n.columns, r)
1595
+ columns: Xt(n.columns, r)
1495
1596
  };
1496
- let i = Ut(n.childObject, r, e.objectName, {
1597
+ let i = an(n.childObject, r, e.objectName, {
1497
1598
  relationshipField: n.relationshipField,
1498
1599
  columns: n.columns,
1499
1600
  amountField: n.amountField
@@ -1523,9 +1624,9 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1523
1624
  let [m, h] = c(() => a.map(() => ({
1524
1625
  rows: [],
1525
1626
  original: []
1526
- }))), _ = s(m);
1527
- _.current = m;
1528
- let v = s({});
1627
+ }))), g = s(m);
1628
+ g.current = m;
1629
+ let _ = s({});
1529
1630
  i(() => {
1530
1631
  let e = t;
1531
1632
  if (!e || typeof e.getObjectSchema != "function") return;
@@ -1541,7 +1642,7 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1541
1642
  if (n) return;
1542
1643
  let i = {};
1543
1644
  for (let [e, n] of t) n && (i[e] = n);
1544
- v.current = i;
1645
+ _.current = i;
1545
1646
  })(), () => {
1546
1647
  n = !0;
1547
1648
  };
@@ -1628,27 +1729,27 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1628
1729
  e.title,
1629
1730
  p.length,
1630
1731
  T
1631
- ]), ee = n((t) => {
1732
+ ]), I = n((t) => {
1632
1733
  T(), X.error(t?.message || "Save failed"), e.onError?.(t);
1633
- }, [e, T]), z = n(async (n) => {
1734
+ }, [e, T]), ee = n(async (n) => {
1634
1735
  if (!t) throw Error("MasterDetailForm: dataSource is required");
1635
1736
  let r = { ...n };
1636
1737
  p.forEach((e, t) => {
1637
- e.totalField && (r[e.totalField] = xt(_.current[t]?.rows ?? [], e.amountField || "amount"));
1738
+ e.totalField && (r[e.totalField] = It(g.current[t]?.rows ?? [], e.amountField || "amount"));
1638
1739
  });
1639
- let i = l ? yt(e.objectName, String(e.recordId), r, p.filter((e) => e.relationshipField).map((e, t) => ({
1740
+ let i = l ? Pt(e.objectName, String(e.recordId), r, p.filter((e) => e.relationshipField).map((e, t) => ({
1640
1741
  childObject: e.childObject,
1641
1742
  relationshipField: e.relationshipField,
1642
- rows: _.current[t]?.rows ?? [],
1643
- original: _.current[t]?.original ?? [],
1644
- childSchema: v.current[e.childObject]
1645
- }))) : vt(e.objectName, r, p.filter((e) => e.relationshipField).map((e, t) => ({
1743
+ rows: g.current[t]?.rows ?? [],
1744
+ original: g.current[t]?.original ?? [],
1745
+ childSchema: _.current[e.childObject]
1746
+ }))) : Nt(e.objectName, r, p.filter((e) => e.relationshipField).map((e, t) => ({
1646
1747
  childObject: e.childObject,
1647
1748
  relationshipField: e.relationshipField,
1648
- rows: _.current[t]?.rows ?? [],
1649
- childSchema: v.current[e.childObject]
1749
+ rows: g.current[t]?.rows ?? [],
1750
+ childSchema: _.current[e.childObject]
1650
1751
  })));
1651
- return (await g(t, i))?.results?.[0] ?? {
1752
+ return (await v(t, i))?.results?.[0] ?? {
1652
1753
  ...r,
1653
1754
  id: e.recordId
1654
1755
  };
@@ -1658,7 +1759,7 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1658
1759
  e.objectName,
1659
1760
  e.recordId,
1660
1761
  l
1661
- ]), H = o(() => ({
1762
+ ]), te = o(() => ({
1662
1763
  type: "object-form",
1663
1764
  objectName: e.objectName,
1664
1765
  mode: e.mode ?? "create",
@@ -1671,36 +1772,36 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1671
1772
  title: e.title,
1672
1773
  showSubmit: !1,
1673
1774
  showCancel: !1,
1674
- submitHandler: z,
1775
+ submitHandler: ee,
1675
1776
  onSuccess: F,
1676
- onError: ee
1777
+ onError: I
1677
1778
  }), [
1678
1779
  e,
1679
- z,
1780
+ ee,
1680
1781
  F,
1681
- ee
1682
- ]), U = s(null), W = e.submitText ?? (l ? "Save" : "Create"), G = n(() => {
1683
- C.current || U.current?.querySelector("form") && (C.current = !0, S(!0), setTimeout(() => {
1684
- (U.current?.querySelector("form"))?.requestSubmit();
1782
+ I
1783
+ ]), L = s(null), ne = e.submitText ?? (l ? "Save" : "Create"), re = n(() => {
1784
+ C.current || L.current?.querySelector("form") && (C.current = !0, S(!0), setTimeout(() => {
1785
+ (L.current?.querySelector("form"))?.requestSubmit();
1685
1786
  }, 0), w.current = setTimeout(() => T(), 1500));
1686
1787
  }, [T]);
1687
1788
  return i(() => () => {
1688
1789
  w.current && clearTimeout(w.current);
1689
- }, []), /* @__PURE__ */ $("div", {
1790
+ }, []), /* @__PURE__ */ Q("div", {
1690
1791
  className: Y("space-y-6", r, e.className),
1691
1792
  children: [
1692
- /* @__PURE__ */ Q("div", {
1693
- ref: U,
1694
- children: /* @__PURE__ */ Q(tn, {
1695
- schema: H,
1793
+ /* @__PURE__ */ Z("div", {
1794
+ ref: L,
1795
+ children: /* @__PURE__ */ Z(vn, {
1796
+ schema: te,
1696
1797
  dataSource: t
1697
1798
  }, y)
1698
1799
  }),
1699
- /* @__PURE__ */ Q(Gt, {
1800
+ /* @__PURE__ */ Z(sn, {
1700
1801
  details: p,
1701
1802
  state: m,
1702
1803
  setRows: E,
1703
- formHostRef: U,
1804
+ formHostRef: L,
1704
1805
  taxRateField: D,
1705
1806
  formKey: y,
1706
1807
  onRowExpand: (e, t) => k({
@@ -1709,19 +1810,19 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1709
1810
  }),
1710
1811
  onAddViaForm: N
1711
1812
  }),
1712
- O && j && /* @__PURE__ */ $(L, {
1813
+ O && j && /* @__PURE__ */ Q(z, {
1713
1814
  className: "border-primary/40 shadow-none ring-1 ring-primary/10",
1714
1815
  "data-testid": "md-row-form",
1715
- children: [/* @__PURE__ */ $(B, {
1816
+ children: [/* @__PURE__ */ Q(H, {
1716
1817
  className: "pb-2 flex flex-row items-center justify-between gap-2 space-y-0",
1717
- children: [/* @__PURE__ */ $(V, {
1818
+ children: [/* @__PURE__ */ Q(U, {
1718
1819
  className: "text-sm font-medium",
1719
1820
  children: [
1720
1821
  j.title || "Line item",
1721
1822
  " — row ",
1722
1823
  O.rowIdx + 1
1723
1824
  ]
1724
- }), /* @__PURE__ */ Q(I, {
1825
+ }), /* @__PURE__ */ Z(R, {
1725
1826
  type: "button",
1726
1827
  variant: "ghost",
1727
1828
  size: "sm",
@@ -1729,7 +1830,7 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1729
1830
  onClick: P,
1730
1831
  children: "Close"
1731
1832
  })]
1732
- }), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q(tn, {
1833
+ }), /* @__PURE__ */ Z(B, { children: /* @__PURE__ */ Z(vn, {
1733
1834
  schema: {
1734
1835
  type: "object-form",
1735
1836
  objectName: j.childObject,
@@ -1746,38 +1847,77 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1746
1847
  dataSource: t
1747
1848
  }, `row-${O.detailIdx}-${O.rowIdx}`) })]
1748
1849
  }),
1749
- e.showSubmit !== !1 && /* @__PURE__ */ $("div", {
1850
+ e.showSubmit !== !1 && /* @__PURE__ */ Q("div", {
1750
1851
  className: "flex items-center justify-end gap-2 border-t border-border pt-4",
1751
- children: [e.onCancel && /* @__PURE__ */ Q(I, {
1852
+ children: [e.onCancel && /* @__PURE__ */ Z(R, {
1752
1853
  type: "button",
1753
1854
  variant: "outline",
1754
1855
  onClick: e.onCancel,
1755
1856
  disabled: x,
1756
1857
  "data-testid": "md-form-cancel",
1757
1858
  children: e.cancelText ?? "Cancel"
1758
- }), /* @__PURE__ */ Q(I, {
1859
+ }), /* @__PURE__ */ Z(R, {
1759
1860
  type: "button",
1760
- onClick: G,
1861
+ onClick: re,
1761
1862
  disabled: x || u && !d,
1762
1863
  "data-testid": "md-form-submit",
1763
- children: x ? "Saving…" : W
1864
+ children: x ? "Saving…" : ne
1764
1865
  })]
1765
1866
  })
1766
1867
  ]
1767
1868
  });
1768
- }, qt = {
1869
+ };
1870
+ //#endregion
1871
+ //#region src/flatFields.ts
1872
+ function ln(e) {
1873
+ let t = e.fields || Object.keys(e.objectSchema?.fields || {}), n = [];
1874
+ for (let r of t) {
1875
+ let t = typeof r == "string" ? r : r?.name;
1876
+ if (!t) continue;
1877
+ let i = e.objectSchema?.fields?.[t];
1878
+ i && n.push({
1879
+ ...Ye(t, e),
1880
+ group: i.group
1881
+ });
1882
+ }
1883
+ return n;
1884
+ }
1885
+ //#endregion
1886
+ //#region src/fieldGroups.ts
1887
+ function un(e, t) {
1888
+ let n = me({
1889
+ fieldGroups: t,
1890
+ fields: Object.fromEntries(e.map((e) => [e.name, { group: e.group }]))
1891
+ });
1892
+ if (!n) return null;
1893
+ let r = new Set(n.flatMap((e) => e.fields)), i = e.map((e) => e.name).filter((e) => !r.has(e)), a = n.map((e) => ({
1894
+ ...e.key === void 0 ? {} : { name: e.key },
1895
+ ...e.key === void 0 ? {} : { label: e.label ?? e.key },
1896
+ fields: [...e.fields],
1897
+ ...e.collapse === "none" ? {} : { collapsible: !0 },
1898
+ ...e.collapse === "collapsed" ? { collapsed: !0 } : {}
1899
+ }));
1900
+ if (i.length > 0) {
1901
+ let e = a[a.length - 1];
1902
+ e && e.name === void 0 ? e.fields = [...e.fields ?? [], ...i] : a.push({ fields: i });
1903
+ }
1904
+ return a;
1905
+ }
1906
+ //#endregion
1907
+ //#region src/DrawerForm.tsx
1908
+ var dn = {
1769
1909
  1: void 0,
1770
1910
  2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
1771
1911
  3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
1772
1912
  4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
1773
- }, Jt = ye({
1913
+ }, fn = Ee({
1774
1914
  "form.discardTitle": "Discard changes?",
1775
1915
  "form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
1776
1916
  "form.dialogDescriptionFallback": "Complete the form fields, then submit or cancel.",
1777
1917
  "form.keepEditing": "Keep editing",
1778
1918
  "form.discard": "Discard"
1779
- }, "form.discardTitle"), Yt = ({ schema: e, dataSource: t, className: r }) => {
1780
- let { fieldLabel: l } = C(), { t: u } = Jt(), d = x(), [f, p] = c(null), [m, h] = c([]), [g, _] = c({}), [v, b] = c(!0), [S, w] = c(null), [T, D] = c(!1), [L, R] = c(!1), { saveWithOcc: z, conflictDialog: B } = it(), [V, H] = c(!1), U = s(!1), W = e.confirmOnDiscard !== !1, G = e.open !== !1, K = e.drawerSide || "right", ie = a(), [ae, X] = c(() => {
1919
+ }, "form.discardTitle"), pn = ({ schema: e, dataSource: t, className: r }) => {
1920
+ let { fieldLabel: l, sectionLabel: u } = O(), { userId: d } = pe(), { t: f } = fn(), p = T(), [m, h] = c(null), [g, _] = c([]), [v, y] = c({}), [b, S] = c(!0), [C, w] = c(null), [E, D] = c(!1), [k, A] = c(!1), { saveWithOcc: j, conflictDialog: M } = vt(), [N, z] = c(!1), B = s(!1), V = e.confirmOnDiscard !== !1, H = e.open !== !1, U = e.drawerSide || "right", ie = a(), [W, G] = c(() => {
1781
1921
  let t = {};
1782
1922
  return e.sections?.forEach((e, n) => {
1783
1923
  let r = e.name || String(n);
@@ -1787,45 +1927,45 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1787
1927
  i(() => {
1788
1928
  (async () => {
1789
1929
  if (!t) {
1790
- b(!1);
1930
+ S(!1);
1791
1931
  return;
1792
1932
  }
1793
1933
  try {
1794
1934
  let n = await t.getObjectSchema(e.objectName);
1795
- p(n);
1935
+ h(n);
1796
1936
  } catch (e) {
1797
- w(e), b(!1);
1937
+ w(e), S(!1);
1798
1938
  }
1799
1939
  })();
1800
1940
  }, [e.objectName, t]);
1801
- let oe = s(void 0);
1941
+ let ae = s(void 0);
1802
1942
  i(() => {
1803
1943
  let n = !1;
1804
- return (f || !t) && (async () => {
1944
+ return (m || !t) && (async () => {
1805
1945
  if (e.mode === "create" || !e.recordId) {
1806
- _(ke(f, e.initialData || e.initialValues)), b(!1);
1946
+ y(We(m, e.initialData || e.initialValues, { currentUserId: d })), S(!1);
1807
1947
  return;
1808
1948
  }
1809
1949
  if (!t) {
1810
- _(e.initialData || e.initialValues || {}), b(!1);
1950
+ y(e.initialData || e.initialValues || {}), S(!1);
1811
1951
  return;
1812
1952
  }
1813
- oe.current !== e.recordId && (b(!0), D(!1));
1953
+ ae.current !== e.recordId && (S(!0), D(!1));
1814
1954
  try {
1815
1955
  let r = await t.findOne(e.objectName, e.recordId);
1816
1956
  if (n) return;
1817
- oe.current = e.recordId, _(r || {});
1957
+ ae.current = e.recordId, y(r || {});
1818
1958
  } catch (e) {
1819
1959
  if (n) return;
1820
1960
  w(e);
1821
1961
  } finally {
1822
- n || b(!1);
1962
+ n || S(!1);
1823
1963
  }
1824
1964
  })(), () => {
1825
1965
  n = !0;
1826
1966
  };
1827
1967
  }, [
1828
- f,
1968
+ m,
1829
1969
  e.mode,
1830
1970
  e.recordId,
1831
1971
  e.initialData,
@@ -1833,15 +1973,15 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1833
1973
  t,
1834
1974
  e.objectName
1835
1975
  ]);
1836
- let se = n((t) => Ie(t, {
1837
- objectSchema: f,
1976
+ let K = n((t) => Ze(t, {
1977
+ objectSchema: m,
1838
1978
  objectName: e.objectName,
1839
1979
  readOnly: e.readOnly,
1840
1980
  mode: e.mode,
1841
1981
  recordId: e.recordId,
1842
1982
  fieldLabel: l
1843
1983
  }), [
1844
- f,
1984
+ m,
1845
1985
  e.readOnly,
1846
1986
  e.mode,
1847
1987
  e.recordId,
@@ -1849,38 +1989,27 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1849
1989
  l
1850
1990
  ]);
1851
1991
  i(() => {
1852
- if (!f && t) return;
1853
- if (e.customFields?.length) {
1854
- h(e.customFields), b(!1);
1855
- return;
1856
- }
1857
- if (e.sections?.length) {
1858
- b(!1);
1859
- return;
1860
- }
1861
- if (!f) return;
1862
- let n = e.fields || Object.keys(f.fields || {}), r = [];
1863
- for (let t of n) {
1864
- let n = typeof t == "string" ? t : t.name;
1865
- if (!n) continue;
1866
- let i = f.fields?.[n];
1867
- i && r.push({
1868
- name: n,
1869
- label: l(e.objectName, n, i.label || n),
1870
- type: O(i.type, { multiple: i.multiple }),
1871
- required: De(i, Ee(e)),
1872
- disabled: e.readOnly || e.mode === "view" || i.readonly,
1873
- placeholder: i.placeholder,
1874
- description: i.help || i.description,
1875
- validation: E(i),
1876
- field: i,
1877
- options: i.options,
1878
- multiple: i.multiple
1879
- });
1992
+ if (!(!m && t)) {
1993
+ if (e.customFields?.length) {
1994
+ _(e.customFields), S(!1);
1995
+ return;
1996
+ }
1997
+ if (e.sections?.length) {
1998
+ S(!1);
1999
+ return;
2000
+ }
2001
+ m && (_(ln({
2002
+ fields: e.fields,
2003
+ objectSchema: m,
2004
+ objectName: e.objectName,
2005
+ readOnly: e.readOnly,
2006
+ mode: e.mode,
2007
+ recordId: e.recordId,
2008
+ fieldLabel: l
2009
+ })), S(!1));
1880
2010
  }
1881
- h(r), b(!1);
1882
2011
  }, [
1883
- f,
2012
+ m,
1884
2013
  e.fields,
1885
2014
  e.customFields,
1886
2015
  e.sections,
@@ -1888,19 +2017,37 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1888
2017
  e.mode,
1889
2018
  t
1890
2019
  ]);
1891
- let ce = n(async (n) => {
1892
- H(!0);
2020
+ let J = o(() => {
2021
+ if (e.sections?.length || e.customFields?.length) return null;
2022
+ let t = st(g, m);
2023
+ e.mode === "create" && (t = lt(t, m));
2024
+ let n = un(t, m?.fieldGroups);
2025
+ if (!n) return null;
2026
+ let r = e.columns && e.columns > 0 ? Math.min(Math.floor(e.columns), 4) : rt(t.length);
2027
+ return n.map((e) => ({
2028
+ ...e,
2029
+ columns: r
2030
+ }));
2031
+ }, [
2032
+ e.sections,
2033
+ e.customFields,
2034
+ e.columns,
2035
+ e.mode,
2036
+ g,
2037
+ m
2038
+ ]), ue = n(async (n) => {
2039
+ z(!0);
1893
2040
  try {
1894
2041
  if (!t) return e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
1895
- let r, i = pt(n, f);
1896
- if (e.mode === "create") r = await t.create(e.objectName, Ae(i, f));
2042
+ let r, i = Ot(n, m);
2043
+ if (e.mode === "create") r = await t.create(e.objectName, Ge(i, m));
1897
2044
  else if (e.mode === "edit" && e.recordId) {
1898
- let n = await z({
2045
+ let n = await j({
1899
2046
  dataSource: t,
1900
2047
  objectName: e.objectName,
1901
2048
  recordId: e.recordId,
1902
2049
  payload: i,
1903
- baseRecord: g
2050
+ baseRecord: v
1904
2051
  });
1905
2052
  if (n.status === "cancelled") return;
1906
2053
  r = n.result;
@@ -1909,73 +2056,73 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1909
2056
  } catch (t) {
1910
2057
  throw e.onError && e.onError(t), t;
1911
2058
  } finally {
1912
- H(!1);
2059
+ z(!1);
1913
2060
  }
1914
2061
  }, [
1915
2062
  e,
1916
2063
  t,
1917
- f,
1918
- z,
1919
- g
1920
- ]), Z = n(() => {
1921
- R(!1), U.current && (U.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
1922
- }, [e]), le = n((e) => {
1923
- U.current = e, W && T ? R(!0) : Z();
2064
+ m,
2065
+ j,
2066
+ v
2067
+ ]), X = n(() => {
2068
+ A(!1), B.current && (B.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
2069
+ }, [e]), de = n((e) => {
2070
+ B.current = e, V && E ? A(!0) : X();
1924
2071
  }, [
1925
- W,
1926
- T,
1927
- Z
2072
+ V,
2073
+ E,
2074
+ X
1928
2075
  ]);
1929
2076
  i(() => {
1930
- if (!G || !T || !W) return;
2077
+ if (!H || !E || !V) return;
1931
2078
  let e = (e) => {
1932
2079
  e.preventDefault(), e.returnValue = "";
1933
2080
  };
1934
2081
  return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
1935
2082
  }, [
1936
- G,
1937
- T,
1938
- W
2083
+ H,
2084
+ E,
2085
+ V
1939
2086
  ]);
1940
- let ue = n(() => {
1941
- U.current = !0, Z();
1942
- }, [Z]), de = o(() => {
1943
- if (e.drawerWidth) return K === "left" || K === "right" ? {
2087
+ let fe = n(() => {
2088
+ B.current = !0, X();
2089
+ }, [X]), me = o(() => {
2090
+ if (e.drawerWidth) return U === "left" || U === "right" ? {
1944
2091
  width: e.drawerWidth,
1945
2092
  maxWidth: e.drawerWidth
1946
2093
  } : {
1947
2094
  height: e.drawerWidth,
1948
2095
  maxHeight: e.drawerWidth
1949
2096
  };
1950
- }, [e.drawerWidth, K]), fe = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", pe = e.showSubmit !== !1 && e.mode !== "view", me = e.showCancel !== !1, he = e.submitText || (e.mode === "create" ? "Create" : "Update"), _e = e.cancelText || "Cancel", ve = {
2097
+ }, [e.drawerWidth, U]), he = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", ge = e.showSubmit !== !1 && e.mode !== "view", _e = e.showCancel !== !1, ve = e.submitText || (e.mode === "create" ? "Create" : "Update"), ye = e.cancelText || "Cancel", be = {
1951
2098
  type: "form",
1952
2099
  objectName: e.objectName,
1953
- layout: fe,
1954
- defaultValues: g,
1955
- previousValues: e.mode === "edit" && e.recordId ? g : void 0,
1956
- submitLabel: he,
1957
- cancelLabel: _e,
1958
- showSubmit: pe,
1959
- showCancel: me,
1960
- onSubmit: ce,
1961
- onCancel: ue,
2100
+ layout: he,
2101
+ defaultValues: v,
2102
+ previousValues: e.mode === "edit" && e.recordId ? v : void 0,
2103
+ submitLabel: ve,
2104
+ cancelLabel: ye,
2105
+ showSubmit: ge,
2106
+ showCancel: _e,
2107
+ onSubmit: ue,
2108
+ onCancel: fe,
1962
2109
  onDirtyChange: D,
1963
2110
  showActions: !1,
1964
2111
  id: ie
1965
- }, ye = () => {
1966
- if (S) return /* @__PURE__ */ $("div", {
2112
+ }, xe = () => {
2113
+ if (C) return /* @__PURE__ */ Q("div", {
1967
2114
  className: "p-4 border border-red-300 bg-red-50 rounded-md",
1968
- children: [/* @__PURE__ */ Q("h3", {
2115
+ children: [/* @__PURE__ */ Z("h3", {
1969
2116
  className: "text-red-800 font-semibold",
1970
2117
  children: "Error loading form"
1971
- }), /* @__PURE__ */ Q("p", {
2118
+ }), /* @__PURE__ */ Z("p", {
1972
2119
  className: "text-red-600 text-sm mt-1",
1973
- children: S.message
2120
+ children: C.message
1974
2121
  })]
1975
2122
  });
1976
- if (v) return /* @__PURE__ */ $("div", {
2123
+ if (b) return /* @__PURE__ */ Q("div", {
1977
2124
  className: "p-8 text-center",
1978
- children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
2125
+ children: [/* @__PURE__ */ Z("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Z("p", {
1979
2126
  className: "mt-2 text-sm text-gray-600",
1980
2127
  children: "Loading form..."
1981
2128
  })]
@@ -1983,7 +2130,7 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1983
2130
  if (e.sections?.length) {
1984
2131
  let t = [];
1985
2132
  return e.sections.forEach((e, n) => {
1986
- let r = e.name || String(n), i = ae[r] ?? e.collapsed ?? !1;
2133
+ let r = e.name || String(n), i = W[r] ?? e.collapsed ?? !1;
1987
2134
  t.push({
1988
2135
  name: `__section_${r}`,
1989
2136
  label: e.label || "",
@@ -1991,30 +2138,62 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
1991
2138
  colSpan: 4,
1992
2139
  collapsible: e.collapsible,
1993
2140
  collapsed: i,
1994
- onToggle: e.collapsible ? () => X((e) => ({
2141
+ onToggle: e.collapsible ? () => G((e) => ({
1995
2142
  ...e,
1996
2143
  [r]: !i
1997
2144
  })) : void 0,
1998
2145
  className: e.className
1999
2146
  });
2000
- let a = se(e);
2147
+ let a = K(e);
2001
2148
  i ? t.push(...a.map((e) => ({
2002
2149
  ...e,
2003
2150
  hidden: !0
2004
2151
  }))) : t.push(...a);
2005
- }), /* @__PURE__ */ Q(y, { schema: {
2006
- ...ve,
2152
+ }), /* @__PURE__ */ Z(x, { schema: {
2153
+ ...be,
2007
2154
  fields: t
2008
2155
  } });
2009
2156
  }
2010
- let t = $e(m, f, e.columns, e.mode), n = qt[t.columns || 1];
2011
- return /* @__PURE__ */ Q(y, { schema: {
2012
- ...ve,
2157
+ if (J?.length) {
2158
+ let t = Number(J[0]?.columns) || 1, n = [];
2159
+ J.forEach((r, i) => {
2160
+ let a = K(r);
2161
+ if (!a.length) return;
2162
+ let o = r.name || String(i), s = r.collapsible ? W[o] ?? r.collapsed ?? !1 : !1, c = r.name ? u(e.objectName, r.name, r.label || r.name) : r.label;
2163
+ c && n.push({
2164
+ name: `__section_${o}`,
2165
+ label: c,
2166
+ type: "section-divider",
2167
+ colSpan: 4,
2168
+ collapsible: r.collapsible,
2169
+ collapsed: s,
2170
+ onToggle: r.collapsible ? () => G((e) => ({
2171
+ ...e,
2172
+ [o]: !s
2173
+ })) : void 0
2174
+ });
2175
+ let l = t > 1 ? $(a, t) : a;
2176
+ n.push(...s ? l.map((e) => ({
2177
+ ...e,
2178
+ hidden: !0
2179
+ })) : l);
2180
+ });
2181
+ let r = dn[t];
2182
+ return /* @__PURE__ */ Z(x, { schema: {
2183
+ ...be,
2184
+ fields: n,
2185
+ columns: t,
2186
+ ...r ? { fieldContainerClass: r } : {}
2187
+ } });
2188
+ }
2189
+ let t = pt(g, m, e.columns, e.mode), n = dn[t.columns || 1];
2190
+ return /* @__PURE__ */ Z(x, { schema: {
2191
+ ...be,
2013
2192
  fields: t.fields,
2014
2193
  columns: t.columns,
2015
2194
  ...n ? { fieldContainerClass: n } : {}
2016
2195
  } });
2017
- }, be = e.subforms, xe = be?.length && e.mode !== "view" ? /* @__PURE__ */ Q(Kt, {
2196
+ }, Se = e.subforms, we = Se?.length && e.mode !== "view" ? /* @__PURE__ */ Z(cn, {
2018
2197
  schema: {
2019
2198
  type: "object-master-detail-form",
2020
2199
  objectName: e.objectName,
@@ -2023,8 +2202,8 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
2023
2202
  fields: e.fields,
2024
2203
  sections: e.sections,
2025
2204
  submitText: e.submitText,
2026
- cancelText: _e,
2027
- details: be,
2205
+ cancelText: ye,
2206
+ details: Se,
2028
2207
  onSuccess: async (t) => {
2029
2208
  await e.onSuccess?.(t), e.onOpenChange?.(!1);
2030
2209
  },
@@ -2032,117 +2211,93 @@ var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
2032
2211
  onCancel: () => e.onOpenChange?.(!1)
2033
2212
  },
2034
2213
  dataSource: t
2035
- }) : ye();
2036
- return d ? /* @__PURE__ */ $("div", {
2214
+ }) : xe();
2215
+ return p ? /* @__PURE__ */ Q("div", {
2037
2216
  className: "@container rounded-md border bg-card p-4",
2038
- children: [(e.title || e.description) && /* @__PURE__ */ $("div", {
2217
+ children: [(e.title || e.description) && /* @__PURE__ */ Q("div", {
2039
2218
  className: "mb-3 space-y-0.5",
2040
- children: [e.title && /* @__PURE__ */ Q("div", {
2219
+ children: [e.title && /* @__PURE__ */ Z("div", {
2041
2220
  className: "text-sm font-semibold",
2042
2221
  children: e.title
2043
- }), e.description && /* @__PURE__ */ Q("p", {
2222
+ }), e.description && /* @__PURE__ */ Z("p", {
2044
2223
  className: "text-xs text-muted-foreground",
2045
2224
  children: e.description
2046
2225
  })]
2047
- }), xe]
2048
- }) : /* @__PURE__ */ Q(te, {
2049
- open: G,
2226
+ }), we]
2227
+ }) : /* @__PURE__ */ Z(oe, {
2228
+ open: H,
2050
2229
  onOpenChange: (t) => {
2051
2230
  if (t) {
2052
2231
  e.onOpenChange?.(!0);
2053
2232
  return;
2054
2233
  }
2055
- le(!1);
2234
+ de(!1);
2056
2235
  },
2057
- children: /* @__PURE__ */ $(ne, {
2058
- side: K,
2236
+ children: /* @__PURE__ */ Q(se, {
2237
+ side: U,
2059
2238
  className: Y("overflow-y-auto", r, e.className),
2060
- style: de,
2239
+ style: me,
2061
2240
  children: [
2062
- (e.title || e.description) && /* @__PURE__ */ $(q, { children: [e.title && /* @__PURE__ */ Q(J, { children: e.title }), e.description ? /* @__PURE__ */ Q(re, { children: e.description }) : /* @__PURE__ */ Q(re, {
2241
+ (e.title || e.description) && /* @__PURE__ */ Q(q, { children: [e.title && /* @__PURE__ */ Z(le, { children: e.title }), e.description ? /* @__PURE__ */ Z(ce, { children: e.description }) : /* @__PURE__ */ Z(ce, {
2063
2242
  className: "sr-only",
2064
- children: u("form.dialogDescriptionFallback")
2243
+ children: f("form.dialogDescriptionFallback")
2065
2244
  })] }),
2066
- /* @__PURE__ */ Q("div", {
2245
+ /* @__PURE__ */ Z("div", {
2067
2246
  className: "@container py-4",
2068
- children: xe
2247
+ children: we
2069
2248
  }),
2070
- !S && !v && !(be?.length && e.mode !== "view") && (pe || me) && /* @__PURE__ */ Q("div", {
2249
+ !C && !b && !(Se?.length && e.mode !== "view") && (ge || _e) && /* @__PURE__ */ Z("div", {
2071
2250
  className: "shrink-0 border-t px-4 py-3 bg-background",
2072
2251
  "data-testid": "drawer-form-footer",
2073
- children: /* @__PURE__ */ $("div", {
2252
+ children: /* @__PURE__ */ Q("div", {
2074
2253
  className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
2075
- children: [me && /* @__PURE__ */ Q(I, {
2254
+ children: [_e && /* @__PURE__ */ Z(R, {
2076
2255
  type: "button",
2077
2256
  variant: "outline",
2078
- onClick: ue,
2079
- disabled: V,
2257
+ onClick: fe,
2258
+ disabled: N,
2080
2259
  className: "w-full sm:w-auto",
2081
- children: _e
2082
- }), pe && /* @__PURE__ */ $(I, {
2260
+ children: ye
2261
+ }), ge && /* @__PURE__ */ Q(R, {
2083
2262
  type: "submit",
2084
2263
  form: ie,
2085
- disabled: V,
2264
+ disabled: N,
2086
2265
  className: "w-full sm:w-auto",
2087
- children: [V && /* @__PURE__ */ Q(ge, { className: "mr-2 h-4 w-4 animate-spin" }), he]
2266
+ children: [N && /* @__PURE__ */ Z(Ce, { className: "mr-2 h-4 w-4 animate-spin" }), ve]
2088
2267
  })]
2089
2268
  })
2090
2269
  }),
2091
- /* @__PURE__ */ Q(k, {
2092
- open: L,
2093
- onOpenChange: R,
2094
- children: /* @__PURE__ */ $(M, { children: [/* @__PURE__ */ $(F, { children: [/* @__PURE__ */ Q(ee, { children: u("form.discardTitle") }), /* @__PURE__ */ Q(N, { children: u("form.discardMessage") })] }), /* @__PURE__ */ $(P, { children: [/* @__PURE__ */ Q(j, {
2270
+ /* @__PURE__ */ Z(P, {
2271
+ open: k,
2272
+ onOpenChange: A,
2273
+ children: /* @__PURE__ */ Q(ee, { children: [/* @__PURE__ */ Q(ne, { children: [/* @__PURE__ */ Z(re, { children: f("form.discardTitle") }), /* @__PURE__ */ Z(te, { children: f("form.discardMessage") })] }), /* @__PURE__ */ Q(L, { children: [/* @__PURE__ */ Z(I, {
2095
2274
  onClick: () => {
2096
- U.current = !1;
2275
+ B.current = !1;
2097
2276
  },
2098
- children: u("form.keepEditing")
2099
- }), /* @__PURE__ */ Q(A, {
2100
- onClick: Z,
2101
- children: u("form.discard")
2277
+ children: f("form.keepEditing")
2278
+ }), /* @__PURE__ */ Z(F, {
2279
+ onClick: X,
2280
+ children: f("form.discard")
2102
2281
  })] })] })
2103
2282
  }),
2104
- B
2283
+ M
2105
2284
  ]
2106
2285
  })
2107
2286
  });
2108
- };
2109
- //#endregion
2110
- //#region src/fieldGroups.ts
2111
- function Xt(e, t) {
2112
- let n = ce({
2113
- fieldGroups: t,
2114
- fields: Object.fromEntries(e.map((e) => [e.name, { group: e.group }]))
2115
- });
2116
- if (!n) return null;
2117
- let r = new Set(n.flatMap((e) => e.fields)), i = e.map((e) => e.name).filter((e) => !r.has(e)), a = n.map((e) => ({
2118
- ...e.key === void 0 ? {} : { name: e.key },
2119
- ...e.key === void 0 ? {} : { label: e.label ?? e.key },
2120
- fields: [...e.fields],
2121
- ...e.collapse === "none" ? {} : { collapsible: !0 },
2122
- ...e.collapse === "collapsed" ? { collapsed: !0 } : {}
2123
- }));
2124
- if (i.length > 0) {
2125
- let e = a[a.length - 1];
2126
- e && e.name === void 0 ? e.fields = [...e.fields ?? [], ...i] : a.push({ fields: i });
2127
- }
2128
- return a;
2129
- }
2130
- //#endregion
2131
- //#region src/ModalForm.tsx
2132
- var Zt = ye({
2287
+ }, mn = Ee({
2133
2288
  "form.discardTitle": "Discard changes?",
2134
2289
  "form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
2135
2290
  "form.dialogDescriptionFallback": "Complete the form fields, then submit or cancel.",
2136
2291
  "form.keepEditing": "Keep editing",
2137
2292
  "form.discard": "Discard"
2138
- }, "form.discardTitle"), Qt = {
2293
+ }, "form.discardTitle"), hn = {
2139
2294
  sm: "sm:max-w-sm",
2140
2295
  default: "sm:max-w-lg",
2141
2296
  lg: "sm:max-w-2xl",
2142
2297
  xl: "sm:max-w-5xl",
2143
2298
  full: "sm:max-w-[95vw] sm:w-full"
2144
- }, $t = ({ schema: e, dataSource: t, className: r }) => {
2145
- let { fieldLabel: l, sectionLabel: u } = C(), { t: d } = Zt(), f = x(), p = se(), m = n((t) => {
2299
+ }, gn = ({ schema: e, dataSource: t, className: r }) => {
2300
+ let { fieldLabel: l, sectionLabel: u } = O(), { t: d } = mn(), f = T(), p = pe(), m = n((t) => {
2146
2301
  if (!p?.isLoaded) return t;
2147
2302
  let n = [];
2148
2303
  for (let r of t) {
@@ -2161,13 +2316,13 @@ var Zt = ye({
2161
2316
  p,
2162
2317
  e.objectName,
2163
2318
  e.mode
2164
- ]), [h, g] = c(null), [_, v] = c([]), [b, S] = c({}), [w, T] = c(!0), [D, L] = c(null), [R, z] = c(!1), [B, V] = c(!1), [te, ne] = c(!1), { saveWithOcc: re, conflictDialog: q } = it(), J = s(!1), ae = e.confirmOnDiscard !== !1, X = e.open !== !1, oe = a(), ce = o(() => {
2319
+ ]), [h, g] = c(null), [_, v] = c([]), [y, b] = c({}), [S, C] = c(!0), [w, E] = c(null), [D, k] = c(!1), [A, j] = c(!1), [M, N] = c(!1), { saveWithOcc: z, conflictDialog: B } = vt(), V = s(!1), H = e.confirmOnDiscard !== !1, U = e.open !== !1, oe = a(), se = o(() => {
2165
2320
  if (e.sections?.length || e.customFields?.length) return null;
2166
- let t = qe(_, h);
2167
- e.mode === "create" && (t = Ye(t, h));
2168
- let n = Xt(t, h?.fieldGroups);
2321
+ let t = st(_, h);
2322
+ e.mode === "create" && (t = lt(t, h));
2323
+ let n = un(t, h?.fieldGroups);
2169
2324
  if (!n) return null;
2170
- let r = e.columns && e.columns > 0 ? Math.min(Math.floor(e.columns), 4) : He(t.length);
2325
+ let r = e.columns && e.columns > 0 ? Math.min(Math.floor(e.columns), 4) : rt(t.length);
2171
2326
  return n.map((e) => ({
2172
2327
  ...e,
2173
2328
  columns: r
@@ -2179,62 +2334,62 @@ var Zt = ye({
2179
2334
  e.mode,
2180
2335
  _,
2181
2336
  h
2182
- ]), Z = e.sections?.length ? e.sections : ce ?? void 0, le = o(() => Z?.length || e.customFields?.length ? null : $e(_, h, e.columns, e.mode), [
2337
+ ]), ce = e.sections?.length ? e.sections : se ?? void 0, q = o(() => ce?.length || e.customFields?.length ? null : pt(_, h, e.columns, e.mode), [
2183
2338
  _,
2184
2339
  h,
2185
2340
  e.columns,
2186
2341
  e.mode,
2187
- Z,
2342
+ ce,
2188
2343
  e.customFields
2189
- ]), ue = Qt[o(() => {
2344
+ ]), le = hn[o(() => {
2190
2345
  if (e.modalSize) return e.modalSize;
2191
- if (le?.columns && le.columns > 1) return Qe(le.columns);
2192
- if (Z?.length) {
2193
- let e = Math.max(...Z.map((e) => Number(e.columns) || 1));
2194
- if (e > 1) return Qe(e);
2346
+ if (q?.columns && q.columns > 1) return ft(q.columns);
2347
+ if (ce?.length) {
2348
+ let e = Math.max(...ce.map((e) => Number(e.columns) || 1));
2349
+ if (e > 1) return ft(e);
2195
2350
  }
2196
2351
  return "default";
2197
2352
  }, [
2198
2353
  e.modalSize,
2199
- le,
2200
- Z
2201
- ])] || Qt.default;
2354
+ q,
2355
+ ce
2356
+ ])] || hn.default;
2202
2357
  i(() => {
2203
2358
  (async () => {
2204
2359
  if (!t) {
2205
- T(!1);
2360
+ C(!1);
2206
2361
  return;
2207
2362
  }
2208
2363
  try {
2209
2364
  let n = await t.getObjectSchema(e.objectName);
2210
2365
  g(n);
2211
2366
  } catch (e) {
2212
- L(e), T(!1);
2367
+ E(e), C(!1);
2213
2368
  }
2214
2369
  })();
2215
2370
  }, [e.objectName, t]);
2216
- let de = s(void 0);
2371
+ let ue = s(void 0);
2217
2372
  i(() => {
2218
2373
  let n = !1;
2219
2374
  return (h || !t) && (async () => {
2220
2375
  if (e.mode === "create" || !e.recordId) {
2221
- S(ke(h, e.initialData || e.initialValues)), T(!1);
2376
+ b(We(h, e.initialData || e.initialValues, { currentUserId: p.userId })), C(!1);
2222
2377
  return;
2223
2378
  }
2224
2379
  if (!t) {
2225
- S(e.initialData || e.initialValues || {}), T(!1);
2380
+ b(e.initialData || e.initialValues || {}), C(!1);
2226
2381
  return;
2227
2382
  }
2228
- de.current !== e.recordId && (T(!0), V(!1));
2383
+ ue.current !== e.recordId && (C(!0), j(!1));
2229
2384
  try {
2230
2385
  let r = await t.findOne(e.objectName, e.recordId);
2231
2386
  if (n) return;
2232
- de.current = e.recordId, S(r || {});
2387
+ ue.current = e.recordId, b(r || {});
2233
2388
  } catch (e) {
2234
2389
  if (n) return;
2235
- L(e);
2390
+ E(e);
2236
2391
  } finally {
2237
- n || T(!1);
2392
+ n || C(!1);
2238
2393
  }
2239
2394
  })(), () => {
2240
2395
  n = !0;
@@ -2248,7 +2403,7 @@ var Zt = ye({
2248
2403
  t,
2249
2404
  e.objectName
2250
2405
  ]);
2251
- let fe = n((t) => Ie(t, {
2406
+ let X = n((t) => Ze(t, {
2252
2407
  objectSchema: h,
2253
2408
  objectName: e.objectName,
2254
2409
  readOnly: e.readOnly,
@@ -2264,40 +2419,25 @@ var Zt = ye({
2264
2419
  l
2265
2420
  ]);
2266
2421
  i(() => {
2267
- if (!h && t) return;
2268
- if (e.customFields?.length) {
2269
- v(e.customFields), T(!1);
2270
- return;
2271
- }
2272
- if (e.sections?.length) {
2273
- T(!1);
2274
- return;
2275
- }
2276
- if (!h) return;
2277
- let n = e.fields || Object.keys(h.fields || {}), r = [];
2278
- for (let t of n) {
2279
- let n = typeof t == "string" ? t : t.name;
2280
- if (!n) continue;
2281
- let i = h.fields?.[n];
2282
- i && r.push({
2283
- name: n,
2284
- label: l(e.objectName, n, i.label || n),
2285
- type: O(i.type, { multiple: i.multiple }),
2286
- required: De(i, Ee(e)),
2287
- disabled: e.readOnly || e.mode === "view" || i.readonly,
2288
- placeholder: i.placeholder,
2289
- description: i.help || i.description,
2290
- validation: E(i),
2291
- field: i,
2292
- options: i.options,
2293
- multiple: i.multiple,
2294
- visibleWhen: i.visibleWhen,
2295
- readonlyWhen: i.readonlyWhen,
2296
- requiredWhen: i.requiredWhen,
2297
- group: i.group
2298
- });
2422
+ if (!(!h && t)) {
2423
+ if (e.customFields?.length) {
2424
+ v(e.customFields), C(!1);
2425
+ return;
2426
+ }
2427
+ if (e.sections?.length) {
2428
+ C(!1);
2429
+ return;
2430
+ }
2431
+ h && (v(ln({
2432
+ fields: e.fields,
2433
+ objectSchema: h,
2434
+ objectName: e.objectName,
2435
+ readOnly: e.readOnly,
2436
+ mode: e.mode,
2437
+ recordId: e.recordId,
2438
+ fieldLabel: l
2439
+ })), C(!1));
2299
2440
  }
2300
- v(r), T(!1);
2301
2441
  }, [
2302
2442
  h,
2303
2443
  e.fields,
@@ -2307,24 +2447,24 @@ var Zt = ye({
2307
2447
  e.mode,
2308
2448
  t
2309
2449
  ]);
2310
- let pe = n(async (n) => {
2311
- z(!0);
2450
+ let de = n(async (n) => {
2451
+ k(!0);
2312
2452
  try {
2313
2453
  if (!t) return e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
2314
- let r, i = pt(n, h);
2454
+ let r, i = Ot(n, h);
2315
2455
  if (p?.isLoaded) {
2316
2456
  let t = {};
2317
2457
  for (let n of Object.keys(i)) p.checkField(e.objectName, n, "write") && (t[n] = i[n]);
2318
2458
  i = t;
2319
2459
  }
2320
- if (e.mode === "create") r = await t.create(e.objectName, Ae(i, h));
2460
+ if (e.mode === "create") r = await t.create(e.objectName, Ge(i, h));
2321
2461
  else if (e.mode === "edit" && e.recordId) {
2322
- let n = await re({
2462
+ let n = await z({
2323
2463
  dataSource: t,
2324
2464
  objectName: e.objectName,
2325
2465
  recordId: e.recordId,
2326
2466
  payload: i,
2327
- baseRecord: b
2467
+ baseRecord: y
2328
2468
  });
2329
2469
  if (n.status === "cancelled") return;
2330
2470
  r = n.result;
@@ -2333,92 +2473,92 @@ var Zt = ye({
2333
2473
  } catch (t) {
2334
2474
  throw e.onError && e.onError(t), t;
2335
2475
  } finally {
2336
- z(!1);
2476
+ k(!1);
2337
2477
  }
2338
2478
  }, [
2339
2479
  e,
2340
2480
  t,
2341
2481
  h,
2342
2482
  p,
2343
- re,
2344
- b
2345
- ]), me = n(() => {
2346
- ne(!1), J.current && (J.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
2347
- }, [e]), he = n((e) => {
2348
- J.current = e, ae && B ? ne(!0) : me();
2483
+ z,
2484
+ y
2485
+ ]), fe = n(() => {
2486
+ N(!1), V.current && (V.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
2487
+ }, [e]), me = n((e) => {
2488
+ V.current = e, H && A ? N(!0) : fe();
2349
2489
  }, [
2350
- ae,
2351
- B,
2352
- me
2490
+ H,
2491
+ A,
2492
+ fe
2353
2493
  ]);
2354
2494
  i(() => {
2355
- if (!X || !B || !ae) return;
2495
+ if (!U || !A || !H) return;
2356
2496
  let e = (e) => {
2357
2497
  e.preventDefault(), e.returnValue = "";
2358
2498
  };
2359
2499
  return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
2360
2500
  }, [
2361
- X,
2362
- B,
2363
- ae
2501
+ U,
2502
+ A,
2503
+ H
2364
2504
  ]);
2365
- let _e = n(() => {
2366
- J.current = !0, me();
2367
- }, [me]), ve = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", ye = e.showSubmit !== !1 && e.mode !== "view", be = e.showCancel !== !1, xe = e.submitText || (e.mode === "create" ? "Create" : "Update"), Se = e.cancelText || "Cancel", Ce = {
2505
+ let he = n(() => {
2506
+ V.current = !0, fe();
2507
+ }, [fe]), ge = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", _e = e.showSubmit !== !1 && e.mode !== "view", ve = e.showCancel !== !1, ye = e.submitText || (e.mode === "create" ? "Create" : "Update"), be = e.cancelText || "Cancel", xe = {
2368
2508
  type: "form",
2369
2509
  objectName: e.objectName,
2370
- layout: ve,
2371
- defaultValues: b,
2372
- previousValues: e.mode === "edit" && e.recordId ? b : void 0,
2373
- submitLabel: xe,
2374
- cancelLabel: Se,
2375
- showSubmit: ye,
2376
- showCancel: be,
2377
- onSubmit: pe,
2378
- onCancel: _e,
2379
- onDirtyChange: V,
2510
+ layout: ge,
2511
+ defaultValues: y,
2512
+ previousValues: e.mode === "edit" && e.recordId ? y : void 0,
2513
+ submitLabel: ye,
2514
+ cancelLabel: be,
2515
+ showSubmit: _e,
2516
+ showCancel: ve,
2517
+ onSubmit: de,
2518
+ onCancel: he,
2519
+ onDirtyChange: j,
2380
2520
  showActions: !1,
2381
2521
  id: oe
2382
- }, we = () => {
2383
- if (D) return /* @__PURE__ */ $("div", {
2522
+ }, Se = () => {
2523
+ if (w) return /* @__PURE__ */ Q("div", {
2384
2524
  className: "p-4 border border-red-300 bg-red-50 rounded-md",
2385
- children: [/* @__PURE__ */ Q("h3", {
2525
+ children: [/* @__PURE__ */ Z("h3", {
2386
2526
  className: "text-red-800 font-semibold",
2387
2527
  children: "Error loading form"
2388
- }), /* @__PURE__ */ Q("p", {
2528
+ }), /* @__PURE__ */ Z("p", {
2389
2529
  className: "text-red-600 text-sm mt-1",
2390
- children: D.message
2530
+ children: w.message
2391
2531
  })]
2392
2532
  });
2393
- if (w) return /* @__PURE__ */ Q("div", {
2533
+ if (S) return /* @__PURE__ */ Z("div", {
2394
2534
  className: "space-y-4",
2395
2535
  "data-testid": "modal-form-skeleton",
2396
2536
  children: [
2397
2537
  1,
2398
2538
  2,
2399
2539
  3
2400
- ].map((e) => /* @__PURE__ */ $("div", {
2540
+ ].map((e) => /* @__PURE__ */ Q("div", {
2401
2541
  className: "space-y-2",
2402
- children: [/* @__PURE__ */ Q(ie, { className: "h-4 w-24" }), /* @__PURE__ */ Q(ie, { className: "h-10 w-full" })]
2542
+ children: [/* @__PURE__ */ Z(J, { className: "h-4 w-24" }), /* @__PURE__ */ Z(J, { className: "h-10 w-full" })]
2403
2543
  }, e))
2404
2544
  });
2405
2545
  if (e.sections?.length) {
2406
- let t = e.sections, n = (e, t) => e.name || e.label || String(t), r = (t) => t.name ? u(e.objectName, t.name, t.label || t.name) : t.label, i = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, a = t.map((e) => i(e.columns)).filter((e) => e != null), o = i(e.columns) ?? (a.length ? Math.max(...a) : 1), s = Xe[o], c = t.map((e, t) => {
2407
- let a = m(fe(e));
2546
+ let t = e.sections, n = (e, t) => e.name || e.label || String(t), r = (t) => t.name ? u(e.objectName, t.name, t.label || t.name) : t.label, i = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, a = t.map((e) => i(e.columns)).filter((e) => e != null), o = i(e.columns) ?? (a.length ? Math.max(...a) : 1), s = ut[o], c = t.map((e, t) => {
2547
+ let a = m(X(e));
2408
2548
  return {
2409
2549
  key: n(e, t),
2410
2550
  title: r(e),
2411
2551
  description: e.description,
2412
2552
  className: e.className,
2413
2553
  gridClassName: e.gridClassName,
2414
- fields: o > 1 ? Ge(a, o, i(e.columns)) : a
2554
+ fields: o > 1 ? $(a, o, i(e.columns)) : a
2415
2555
  };
2416
2556
  }).filter((e) => e.fields.length > 0), l = {
2417
- ...Ce,
2557
+ ...xe,
2418
2558
  columns: o,
2419
2559
  ...s ? { fieldContainerClass: s } : {}
2420
2560
  };
2421
- if (e.contentLayout === "tabbed" && c.length > 1) return /* @__PURE__ */ Q(y, { schema: {
2561
+ if (e.contentLayout === "tabbed" && c.length > 1) return /* @__PURE__ */ Z(x, { schema: {
2422
2562
  ...l,
2423
2563
  fields: c.flatMap((e) => e.fields),
2424
2564
  fieldTabs: c.map((e, t) => ({
@@ -2439,66 +2579,66 @@ var Zt = ye({
2439
2579
  colSpan: 4,
2440
2580
  className: e.className
2441
2581
  }), d.push(...e.fields);
2442
- }), /* @__PURE__ */ Q(y, { schema: {
2582
+ }), /* @__PURE__ */ Z(x, { schema: {
2443
2583
  ...l,
2444
2584
  fields: d
2445
2585
  } });
2446
2586
  }
2447
- if (ce?.length) {
2448
- let t = Number(ce[0]?.columns) || 1, n = [];
2449
- ce.forEach((r, i) => {
2450
- let a = m(fe(r));
2587
+ if (se?.length) {
2588
+ let t = Number(se[0]?.columns) || 1, n = [];
2589
+ se.forEach((r, i) => {
2590
+ let a = m(X(r));
2451
2591
  if (!a.length) return;
2452
2592
  let o = r.name ? u(e.objectName, r.name, r.label || r.name) : r.label;
2453
2593
  o && n.push({
2454
2594
  name: `__section_${r.name || i}`,
2455
2595
  label: o,
2456
2596
  type: "section-divider"
2457
- }), n.push(...t > 1 ? Ge(a, t) : a);
2597
+ }), n.push(...t > 1 ? $(a, t) : a);
2458
2598
  });
2459
- let r = Xe[t];
2460
- return /* @__PURE__ */ Q(y, { schema: {
2461
- ...Ce,
2599
+ let r = ut[t];
2600
+ return /* @__PURE__ */ Z(x, { schema: {
2601
+ ...xe,
2462
2602
  fields: n,
2463
2603
  columns: t,
2464
2604
  ...r ? { fieldContainerClass: r } : {}
2465
2605
  } });
2466
2606
  }
2467
- let t = le ?? $e(_, h, e.columns, e.mode), n = Xe[t.columns || 1];
2468
- return /* @__PURE__ */ Q(y, { schema: {
2469
- ...Ce,
2607
+ let t = q ?? pt(_, h, e.columns, e.mode), n = ut[t.columns || 1];
2608
+ return /* @__PURE__ */ Z(x, { schema: {
2609
+ ...xe,
2470
2610
  fields: m(t.fields),
2471
2611
  columns: t.columns,
2472
2612
  ...n ? { fieldContainerClass: n } : {}
2473
2613
  } });
2474
- }, Te = e.subforms;
2475
- if (f) return /* @__PURE__ */ $("div", {
2614
+ }, we = e.subforms;
2615
+ if (f) return /* @__PURE__ */ Q("div", {
2476
2616
  className: "@container rounded-md border bg-card p-4",
2477
- children: [(e.title || e.description) && /* @__PURE__ */ $("div", {
2617
+ children: [(e.title || e.description) && /* @__PURE__ */ Q("div", {
2478
2618
  className: "mb-3 space-y-0.5",
2479
- children: [e.title && /* @__PURE__ */ Q("div", {
2619
+ children: [e.title && /* @__PURE__ */ Z("div", {
2480
2620
  className: "text-sm font-semibold",
2481
2621
  children: e.title
2482
- }), e.description && /* @__PURE__ */ Q("p", {
2622
+ }), e.description && /* @__PURE__ */ Z("p", {
2483
2623
  className: "text-xs text-muted-foreground",
2484
2624
  children: e.description
2485
2625
  })]
2486
- }), we()]
2626
+ }), Se()]
2487
2627
  });
2488
- if (Te?.length && e.mode !== "view") return /* @__PURE__ */ Q(H, {
2489
- open: X,
2628
+ if (we?.length && e.mode !== "view") return /* @__PURE__ */ Z(ie, {
2629
+ open: U,
2490
2630
  onOpenChange: e.onOpenChange,
2491
- children: /* @__PURE__ */ $(K, {
2492
- className: Y(ue, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", r, e.className),
2493
- children: [(e.title || e.description) && /* @__PURE__ */ $(W, {
2631
+ children: /* @__PURE__ */ Q(K, {
2632
+ className: Y(le, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", r, e.className),
2633
+ children: [(e.title || e.description) && /* @__PURE__ */ Q(G, {
2494
2634
  className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
2495
- children: [e.title && /* @__PURE__ */ Q(G, { children: e.title }), e.description ? /* @__PURE__ */ Q(U, { children: e.description }) : /* @__PURE__ */ Q(U, {
2635
+ children: [e.title && /* @__PURE__ */ Z(ae, { children: e.title }), e.description ? /* @__PURE__ */ Z(W, { children: e.description }) : /* @__PURE__ */ Z(W, {
2496
2636
  className: "sr-only",
2497
2637
  children: "Enter the record and its line items, then save."
2498
2638
  })]
2499
- }), /* @__PURE__ */ Q("div", {
2639
+ }), /* @__PURE__ */ Z("div", {
2500
2640
  className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
2501
- children: /* @__PURE__ */ Q(Kt, {
2641
+ children: /* @__PURE__ */ Z(cn, {
2502
2642
  schema: {
2503
2643
  type: "object-master-detail-form",
2504
2644
  objectName: e.objectName,
@@ -2508,9 +2648,9 @@ var Zt = ye({
2508
2648
  sections: e.sections,
2509
2649
  initialValues: e.initialValues,
2510
2650
  initialData: e.initialData,
2511
- submitText: xe,
2512
- cancelText: Se,
2513
- details: Te,
2651
+ submitText: ye,
2652
+ cancelText: be,
2653
+ details: we,
2514
2654
  onSuccess: async (t) => {
2515
2655
  await e.onSuccess?.(t), e.onOpenChange?.(!1);
2516
2656
  },
@@ -2522,80 +2662,80 @@ var Zt = ye({
2522
2662
  })]
2523
2663
  })
2524
2664
  });
2525
- let Oe = !w && !D && (ye || be);
2526
- return /* @__PURE__ */ Q(H, {
2527
- open: X,
2665
+ let Te = !S && !w && (_e || ve);
2666
+ return /* @__PURE__ */ Z(ie, {
2667
+ open: U,
2528
2668
  onOpenChange: (t) => {
2529
2669
  if (t) {
2530
2670
  e.onOpenChange?.(!0);
2531
2671
  return;
2532
2672
  }
2533
- he(!1);
2673
+ me(!1);
2534
2674
  },
2535
- children: /* @__PURE__ */ $(K, {
2536
- className: Y(ue, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", r, e.className),
2675
+ children: /* @__PURE__ */ Q(K, {
2676
+ className: Y(le, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", r, e.className),
2537
2677
  children: [
2538
- (e.title || e.description) && /* @__PURE__ */ $(W, {
2678
+ (e.title || e.description) && /* @__PURE__ */ Q(G, {
2539
2679
  className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
2540
- children: [e.title && /* @__PURE__ */ Q(G, { children: e.title }), e.description ? /* @__PURE__ */ Q(U, { children: e.description }) : /* @__PURE__ */ Q(U, {
2680
+ children: [e.title && /* @__PURE__ */ Z(ae, { children: e.title }), e.description ? /* @__PURE__ */ Z(W, { children: e.description }) : /* @__PURE__ */ Z(W, {
2541
2681
  className: "sr-only",
2542
2682
  children: d("form.dialogDescriptionFallback")
2543
2683
  })]
2544
2684
  }),
2545
- /* @__PURE__ */ Q("div", {
2685
+ /* @__PURE__ */ Z("div", {
2546
2686
  className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
2547
- children: we()
2687
+ children: Se()
2548
2688
  }),
2549
- Oe && /* @__PURE__ */ Q("div", {
2689
+ Te && /* @__PURE__ */ Z("div", {
2550
2690
  className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background",
2551
2691
  "data-testid": "modal-form-footer",
2552
- children: /* @__PURE__ */ $("div", {
2692
+ children: /* @__PURE__ */ Q("div", {
2553
2693
  className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
2554
- children: [be && /* @__PURE__ */ Q(I, {
2694
+ children: [ve && /* @__PURE__ */ Z(R, {
2555
2695
  type: "button",
2556
2696
  variant: "outline",
2557
- onClick: _e,
2558
- disabled: R,
2697
+ onClick: he,
2698
+ disabled: D,
2559
2699
  className: "w-full sm:w-auto",
2560
- children: Se
2561
- }), ye && /* @__PURE__ */ $(I, {
2700
+ children: be
2701
+ }), _e && /* @__PURE__ */ Q(R, {
2562
2702
  type: "submit",
2563
2703
  form: oe,
2564
- disabled: R,
2704
+ disabled: D,
2565
2705
  className: "w-full sm:w-auto",
2566
- children: [R && /* @__PURE__ */ Q(ge, { className: "mr-2 h-4 w-4 animate-spin" }), xe]
2706
+ children: [D && /* @__PURE__ */ Z(Ce, { className: "mr-2 h-4 w-4 animate-spin" }), ye]
2567
2707
  })]
2568
2708
  })
2569
2709
  }),
2570
- /* @__PURE__ */ Q(k, {
2571
- open: te,
2572
- onOpenChange: ne,
2573
- children: /* @__PURE__ */ $(M, { children: [/* @__PURE__ */ $(F, { children: [/* @__PURE__ */ Q(ee, { children: d("form.discardTitle") }), /* @__PURE__ */ Q(N, { children: d("form.discardMessage") })] }), /* @__PURE__ */ $(P, { children: [/* @__PURE__ */ Q(j, {
2710
+ /* @__PURE__ */ Z(P, {
2711
+ open: M,
2712
+ onOpenChange: N,
2713
+ children: /* @__PURE__ */ Q(ee, { children: [/* @__PURE__ */ Q(ne, { children: [/* @__PURE__ */ Z(re, { children: d("form.discardTitle") }), /* @__PURE__ */ Z(te, { children: d("form.discardMessage") })] }), /* @__PURE__ */ Q(L, { children: [/* @__PURE__ */ Z(I, {
2574
2714
  onClick: () => {
2575
- J.current = !1;
2715
+ V.current = !1;
2576
2716
  },
2577
2717
  children: d("form.keepEditing")
2578
- }), /* @__PURE__ */ Q(A, {
2579
- onClick: me,
2718
+ }), /* @__PURE__ */ Z(F, {
2719
+ onClick: fe,
2580
2720
  children: d("form.discard")
2581
2721
  })] })] })
2582
2722
  }),
2583
- q
2723
+ B
2584
2724
  ]
2585
2725
  })
2586
2726
  });
2587
2727
  };
2588
2728
  //#endregion
2589
2729
  //#region src/ObjectForm.tsx
2590
- function en(e) {
2730
+ function _n(e) {
2591
2731
  let t = e.buttons, n = e.defaults;
2592
2732
  if (!t && !n) return e;
2593
2733
  let r = e, i = { ...r };
2594
2734
  return t?.submit?.show !== void 0 && r.showSubmit === void 0 && (i.showSubmit = t.submit.show), t?.submit?.label != null && r.submitText === void 0 && (i.submitText = t.submit.label), t?.cancel?.show !== void 0 && r.showCancel === void 0 && (i.showCancel = t.cancel.show), t?.cancel?.label != null && r.cancelText === void 0 && (i.cancelText = t.cancel.label), t?.reset?.show !== void 0 && r.showReset === void 0 && (i.showReset = t.reset.show), n && r.initialValues === void 0 && (i.initialValues = n), i;
2595
2735
  }
2596
- var tn = ({ schema: e, dataSource: t }) => {
2597
- let n = se(), r = o(() => {
2598
- let t = en(e), r = t.groups, i = !t.sections?.length && Array.isArray(r) && r.length ? {
2736
+ var vn = ({ schema: e, dataSource: t }) => {
2737
+ let n = pe(), r = o(() => {
2738
+ let t = _n(e), r = t.groups, i = !t.sections?.length && Array.isArray(r) && r.length ? {
2599
2739
  ...t,
2600
2740
  sections: r.map((e) => ({
2601
2741
  label: e.title ?? e.label,
@@ -2619,8 +2759,8 @@ var tn = ({ schema: e, dataSource: t }) => {
2619
2759
  fields: o(e.fields)
2620
2760
  }))
2621
2761
  };
2622
- }, [e, n]), { sectionLabel: i } = C(), a = (e) => e?.name ? i(r.objectName, e.name, e.label || e.name) : e?.label;
2623
- if (r.subforms?.length && r.mode !== "view" && r.formType !== "drawer" && r.formType !== "modal") return /* @__PURE__ */ Q(Kt, {
2762
+ }, [e, n]), { sectionLabel: i } = O(), a = (e) => e?.name ? i(r.objectName, e.name, e.label || e.name) : e?.label;
2763
+ if (r.subforms?.length && r.mode !== "view" && r.formType !== "drawer" && r.formType !== "modal") return /* @__PURE__ */ Z(cn, {
2624
2764
  schema: {
2625
2765
  type: "object-master-detail-form",
2626
2766
  objectName: r.objectName,
@@ -2643,7 +2783,7 @@ var tn = ({ schema: e, dataSource: t }) => {
2643
2783
  },
2644
2784
  dataSource: t
2645
2785
  });
2646
- if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ Q(at, {
2786
+ if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ Z(yt, {
2647
2787
  schema: {
2648
2788
  ...r,
2649
2789
  formType: "tabbed",
@@ -2662,7 +2802,7 @@ var tn = ({ schema: e, dataSource: t }) => {
2662
2802
  dataSource: t,
2663
2803
  className: r.className
2664
2804
  });
2665
- if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ Q(lt, {
2805
+ if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ Z(wt, {
2666
2806
  schema: {
2667
2807
  ...r,
2668
2808
  formType: "wizard",
@@ -2684,7 +2824,7 @@ var tn = ({ schema: e, dataSource: t }) => {
2684
2824
  dataSource: t,
2685
2825
  className: r.className
2686
2826
  });
2687
- if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ Q(ut, {
2827
+ if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ Z(Tt, {
2688
2828
  schema: {
2689
2829
  ...r,
2690
2830
  formType: "split",
@@ -2707,7 +2847,7 @@ var tn = ({ schema: e, dataSource: t }) => {
2707
2847
  });
2708
2848
  if (r.formType === "drawer") {
2709
2849
  let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
2710
- return /* @__PURE__ */ Q(Yt, {
2850
+ return /* @__PURE__ */ Z(pn, {
2711
2851
  schema: {
2712
2852
  ...n,
2713
2853
  layout: i,
@@ -2733,7 +2873,7 @@ var tn = ({ schema: e, dataSource: t }) => {
2733
2873
  }
2734
2874
  if (r.formType === "modal") {
2735
2875
  let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
2736
- return /* @__PURE__ */ Q($t, {
2876
+ return /* @__PURE__ */ Z(gn, {
2737
2877
  schema: {
2738
2878
  ...n,
2739
2879
  layout: i,
@@ -2756,12 +2896,12 @@ var tn = ({ schema: e, dataSource: t }) => {
2756
2896
  className: r.className
2757
2897
  });
2758
2898
  }
2759
- return /* @__PURE__ */ Q(nn, {
2899
+ return /* @__PURE__ */ Z(yn, {
2760
2900
  schema: r,
2761
2901
  dataSource: t
2762
2902
  });
2763
- }, nn = ({ schema: e, dataSource: r }) => {
2764
- let { fieldLabel: a, sectionLabel: o } = C(), s = oe(), l = se(), u = n((t) => {
2903
+ }, yn = ({ schema: e, dataSource: r }) => {
2904
+ let { fieldLabel: a, sectionLabel: o } = O(), s = de(), l = pe(), u = n((t) => {
2765
2905
  if (!l?.isLoaded) return t;
2766
2906
  let n = [];
2767
2907
  for (let r of t) l.checkField(e.objectName, r.name, "read") && (!l.checkField(e.objectName, r.name, "write") && e.mode !== "view" ? n.push({
@@ -2775,15 +2915,17 @@ var tn = ({ schema: e, dataSource: t }) => {
2775
2915
  l,
2776
2916
  e.objectName,
2777
2917
  e.mode
2778
- ]), [d, f] = c(null), [p, h] = c([]), [g, _] = c(null), [v, b] = c(!0), [x, S] = c(null), [w, T] = c(null), { saveWithOcc: k, conflictDialog: A } = it(), j = e.customFields && e.customFields.length > 0;
2918
+ ]), [d, f] = c(null), [p, m] = c([]), [h, _] = c(null), [v, y] = c(!0), [b, S] = c(null), [C, w] = c(null), [T, E] = c(null);
2919
+ Pe(T);
2920
+ let { saveWithOcc: D, conflictDialog: k } = vt(), A = e.customFields && e.customFields.length > 0;
2779
2921
  i(() => {
2780
- j && (_(e.initialData || e.initialValues || {}), b(!1));
2922
+ A && (_(e.initialData || e.initialValues || {}), y(!1));
2781
2923
  }, [
2782
- j,
2924
+ A,
2783
2925
  e.initialData,
2784
2926
  e.initialValues
2785
2927
  ]), i(() => {
2786
- j ? f({
2928
+ A ? f({
2787
2929
  name: e.objectName,
2788
2930
  fields: {}
2789
2931
  }) : e.objectName && r ? (async () => {
@@ -2793,32 +2935,32 @@ var tn = ({ schema: e, dataSource: t }) => {
2793
2935
  if (!t) throw Error(`No schema found for object "${e.objectName}"`);
2794
2936
  f(t);
2795
2937
  } catch (e) {
2796
- S(e), b(!1);
2938
+ S(e), y(!1);
2797
2939
  }
2798
- })() : j || b(!1);
2940
+ })() : A || y(!1);
2799
2941
  }, [
2800
2942
  e.objectName,
2801
2943
  r,
2802
- j
2944
+ A
2803
2945
  ]), i(() => {
2804
- d && !j && (async () => {
2946
+ d && !A && (async () => {
2805
2947
  if (!e.recordId || e.mode === "create") {
2806
- _(e.initialData || e.initialValues || {}), b(!1);
2948
+ _(e.initialData || e.initialValues || {}), y(!1);
2807
2949
  return;
2808
2950
  }
2809
- if (!j) {
2951
+ if (!A) {
2810
2952
  if (!r) {
2811
- S(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), b(!1);
2953
+ S(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), y(!1);
2812
2954
  return;
2813
2955
  }
2814
- b(!0);
2956
+ y(!0);
2815
2957
  try {
2816
2958
  let t = await r.findOne(e.objectName, e.recordId);
2817
2959
  _(t);
2818
2960
  } catch (e) {
2819
2961
  console.error("Failed to fetch record:", e), S(e);
2820
2962
  } finally {
2821
- b(!1);
2963
+ y(!1);
2822
2964
  }
2823
2965
  }
2824
2966
  })();
@@ -2830,33 +2972,33 @@ var tn = ({ schema: e, dataSource: t }) => {
2830
2972
  e.initialData,
2831
2973
  r,
2832
2974
  d,
2833
- j
2975
+ A
2834
2976
  ]);
2835
- let M = n((e) => e, []);
2977
+ let P = n((e) => e, []);
2836
2978
  i(() => {
2837
- if (j && e.customFields) {
2838
- h(e.customFields.map(M)), b(!1);
2979
+ if (A && e.customFields) {
2980
+ m(e.customFields.map(P)), y(!1);
2839
2981
  return;
2840
2982
  }
2841
2983
  if (!d) return;
2842
- let t = [], n = m(d, l?.getObjectApiOperations?.(e.objectName)), i = !(e.mode === "edit" ? n.edit : e.mode !== "create" || n.create), o = e.fields || Object.keys(d.fields || {});
2984
+ let t = [], n = g(d, l?.getObjectApiOperations?.(e.objectName)), i = !(e.mode === "edit" ? n.edit : e.mode !== "create" || n.create), o = e.fields || Object.keys(d.fields || {});
2843
2985
  (Array.isArray(o) ? o : Object.keys(o)).forEach((n) => {
2844
2986
  let r = typeof n == "string" ? n : n.name;
2845
2987
  if (!r) return;
2846
2988
  let o = d.fields?.[r];
2847
- if (!o && !j) return;
2989
+ if (!o && !A) return;
2848
2990
  let s = e.customFields?.find((e) => e.name === r);
2849
- if (s) t.push(M(s));
2991
+ if (s) t.push(P(s));
2850
2992
  else if (o) {
2851
2993
  let s = {
2852
2994
  name: r,
2853
2995
  label: a(e.objectName, r, o.label || n),
2854
- type: O(o.type, { multiple: o.multiple }),
2855
- required: De(o, Ee(e)),
2996
+ type: N(o.type, { multiple: o.multiple }),
2997
+ required: Ve(o, Be(e)),
2856
2998
  disabled: e.readOnly || e.mode === "view" || o.readonly || i,
2857
2999
  placeholder: o.placeholder,
2858
3000
  description: o.help || o.description,
2859
- validation: E(o),
3001
+ validation: j(o),
2860
3002
  visibleWhen: o.visibleWhen,
2861
3003
  readonlyWhen: o.readonlyWhen,
2862
3004
  requiredWhen: o.requiredWhen,
@@ -2865,12 +3007,12 @@ var tn = ({ schema: e, dataSource: t }) => {
2865
3007
  widget: o.widget
2866
3008
  };
2867
3009
  if ((o.type === "select" || o.type === "lookup" || o.type === "master_detail") && (s.options = o.options || [], s.multiple = o.multiple), (o.type === "number" || o.type === "currency" || o.type === "percent") && (s.inputType = "number", s.min = o.min, s.max = o.max, s.step = o.precision ? 10 ** -o.precision : void 0), o.type === "date" && (s.inputType = "date"), o.type === "datetime" && (s.inputType = "datetime-local"), (o.type === "text" || o.type === "textarea" || o.type === "markdown" || o.type === "html") && (s.maxLength = o.maxLength ?? o.max_length, s.minLength = o.minLength ?? o.min_length), (o.type === "file" || o.type === "image") && (s.inputType = "file", s.multiple = o.multiple, s.accept = o.accept ? o.accept.join(",") : void 0, o.max_size)) {
2868
- let e = `Max size: ${D(o.max_size)}`;
3010
+ let e = `Max size: ${M(o.max_size)}`;
2869
3011
  s.description = s.description ? `${s.description} (${e})` : e;
2870
3012
  }
2871
3013
  o.type === "email" && (s.inputType = "email"), o.type === "phone" && (s.inputType = "tel"), o.type === "url" && (s.inputType = "url"), o.type === "password" && (s.inputType = "password"), o.type === "time" && (s.inputType = "time"), (o.type === "formula" || o.type === "summary" || o.type === "auto_number") && (s.disabled = !0), o.visible_on && (s.visibleOn = o.visible_on), t.push(s);
2872
3014
  }
2873
- }), h(t), !j && e.recordId && e.mode !== "create" && r || b(!1);
3015
+ }), m(t), !A && e.recordId && e.mode !== "create" && r || y(!1);
2874
3016
  }, [
2875
3017
  d,
2876
3018
  e.fields,
@@ -2878,16 +3020,16 @@ var tn = ({ schema: e, dataSource: t }) => {
2878
3020
  e.readOnly,
2879
3021
  e.mode,
2880
3022
  e.objectName,
2881
- j,
3023
+ A,
2882
3024
  e.recordId,
2883
3025
  r,
2884
3026
  l
2885
3027
  ]);
2886
- let N = n(async (t, n) => {
2887
- if (t && (t.nativeEvent || t._reactName === "onSubmit") && (console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."), n === void 0 && (t = {})), j && !r) return e.onSuccess && await e.onSuccess(t), t;
3028
+ let F = n(async (t, n) => {
3029
+ if (t && (t.nativeEvent || t._reactName === "onSubmit") && (console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."), n === void 0 && (t = {})), A && !r) return e.onSuccess && await e.onSuccess(t), t;
2888
3030
  if (!r) throw Error("DataSource is required for form submission (inline mode not configured)");
2889
- let i = pt(t, j ? null : d);
2890
- if (Ee(e) && (i = Ae(i, j ? null : d)), l?.isLoaded && i && typeof i == "object") {
3031
+ let i = Ot(t, A ? null : d);
3032
+ if (Be(e) && (i = Ge(i, A ? null : d)), l?.isLoaded && i && typeof i == "object") {
2891
3033
  let t = {};
2892
3034
  for (let n of Object.keys(i)) l.checkField(e.objectName, n, "write") && (t[n] = i[n]);
2893
3035
  i = t;
@@ -2897,37 +3039,52 @@ var tn = ({ schema: e, dataSource: t }) => {
2897
3039
  if (e.submitHandler) t = await e.submitHandler(i);
2898
3040
  else if (e.mode === "create") t = await r.create(e.objectName, i);
2899
3041
  else if (e.mode === "edit" && e.recordId) {
2900
- let n = await k({
3042
+ let n = await D({
2901
3043
  dataSource: r,
2902
3044
  objectName: e.objectName,
2903
3045
  recordId: e.recordId,
2904
3046
  payload: i,
2905
- baseRecord: g
3047
+ baseRecord: h
2906
3048
  });
2907
3049
  if (n.status === "cancelled") return;
2908
3050
  t = n.result;
2909
3051
  } else throw Error("Invalid form mode or missing record ID");
2910
3052
  if (e.onSuccess) await e.onSuccess(t);
2911
3053
  else if (!e.submitHandler && e.submitBehavior) {
2912
- let t = e.submitBehavior;
2913
- switch (t.kind) {
2914
- case "redirect":
2915
- xe(t.url) && setTimeout(() => window.location.assign(t.url), t.delayMs ?? 0);
3054
+ let n = e.submitBehavior;
3055
+ switch (n.kind) {
3056
+ case "redirect": {
3057
+ let r = Ne(n.url, Me(i, t));
3058
+ if (!r.ok) {
3059
+ X.error(r.refusal), w({
3060
+ message: e.successMessage || (e.mode === "create" ? "Created" : "Saved"),
3061
+ refusal: r.refusal
3062
+ });
3063
+ break;
3064
+ }
3065
+ E({
3066
+ url: r.url,
3067
+ delayMs: n.delayMs ?? 0
3068
+ });
2916
3069
  break;
3070
+ }
2917
3071
  case "continue": break;
2918
3072
  default: {
2919
- let n = t.kind === "thank-you" && t.message ? t.message : e.successMessage || (e.mode === "create" ? "Created" : "Saved");
2920
- X.success(n), T({
2921
- title: t.kind === "thank-you" ? t.title : void 0,
2922
- message: n
3073
+ let t = n.kind === "thank-you" && n.message ? n.message : e.successMessage || (e.mode === "create" ? "Created" : "Saved");
3074
+ X.success(t), w({
3075
+ title: n.kind === "thank-you" ? n.title : void 0,
3076
+ message: t
2923
3077
  });
2924
3078
  break;
2925
3079
  }
2926
3080
  }
2927
3081
  } else if (!e.submitHandler) {
2928
- let n = Se(e.navigateOnSuccess, t);
2929
- if (n) return window.location.assign(n), t;
2930
- X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved"));
3082
+ let n = ke(e.navigateOnSuccess, t);
3083
+ if (n) return Le(n) ? E({
3084
+ url: n,
3085
+ delayMs: 0
3086
+ }) : window.location.assign(n), t;
3087
+ e.navigateOnSuccess ? (console.warn("[ObjectForm] `navigateOnSuccess` was declared but produced no destination:", e.navigateOnSuccess), X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved"), { description: xt })) : X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved"));
2931
3088
  }
2932
3089
  return t;
2933
3090
  } catch (t) {
@@ -2936,59 +3093,73 @@ var tn = ({ schema: e, dataSource: t }) => {
2936
3093
  }, [
2937
3094
  e,
2938
3095
  r,
2939
- j,
3096
+ A,
2940
3097
  l,
2941
3098
  d,
2942
- k,
2943
- g
2944
- ]), P = n(() => {
3099
+ D,
3100
+ h
3101
+ ]), I = n(() => {
2945
3102
  e.onCancel && e.onCancel();
2946
- }, [e]), F = Ee(e), ee = {
2947
- ...t.useMemo(() => F ? Oe(d) : {}, [d, F]),
2948
- ...g
2949
- }, I = e.mode === "edit" && e.recordId && g && typeof g == "object" ? g : void 0, L = t.useMemo(() => {
2950
- let t = qe(p, d);
2951
- return e.mode === "create" && (t = Ye(t, d)), t;
3103
+ }, [e]), ee = Be(e), te = {
3104
+ ...t.useMemo(() => ee ? He(d, { currentUserId: l.userId }) : {}, [
3105
+ d,
3106
+ ee,
3107
+ l.userId
3108
+ ]),
3109
+ ...h
3110
+ }, L = e.mode === "edit" && e.recordId && h && typeof h == "object" ? h : void 0, ne = t.useMemo(() => {
3111
+ let t = st(p, d);
3112
+ return e.mode === "create" && (t = lt(t, d)), t;
2952
3113
  }, [
2953
3114
  p,
2954
3115
  d,
2955
3116
  e.mode
2956
- ]), R = t.useMemo(() => e.sections?.length ? null : Xt(L, d?.fieldGroups), [
3117
+ ]), re = t.useMemo(() => e.sections?.length ? null : un(ne, d?.fieldGroups), [
2957
3118
  e.sections,
2958
- L,
3119
+ ne,
2959
3120
  d
2960
- ]), z = e.sections?.length ? e.sections : R, [B, V] = c({});
2961
- if (x) return /* @__PURE__ */ $("div", {
3121
+ ]), R = e.sections?.length ? e.sections : re, [z, B] = c({});
3122
+ if (b) return /* @__PURE__ */ Q("div", {
2962
3123
  className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
2963
- children: [/* @__PURE__ */ Q("h3", {
3124
+ children: [/* @__PURE__ */ Z("h3", {
2964
3125
  className: "text-red-800 font-semibold",
2965
3126
  children: "Error loading form"
2966
- }), /* @__PURE__ */ Q("p", {
3127
+ }), /* @__PURE__ */ Z("p", {
2967
3128
  className: "text-red-600 text-sm mt-1",
2968
- children: x.message
3129
+ children: b.message
2969
3130
  })]
2970
3131
  });
2971
- if (v) return /* @__PURE__ */ $("div", {
3132
+ if (v) return /* @__PURE__ */ Q("div", {
2972
3133
  className: "p-4 sm:p-8 text-center",
2973
- children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
3134
+ children: [/* @__PURE__ */ Z("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Z("p", {
2974
3135
  className: "mt-2 text-sm text-gray-600",
2975
3136
  children: "Loading form..."
2976
3137
  })]
2977
3138
  });
2978
- if (w) return /* @__PURE__ */ $("div", {
2979
- className: "rounded-md border bg-card p-6 sm:p-8 text-center",
2980
- children: [/* @__PURE__ */ Q("h3", {
2981
- className: "text-lg font-semibold",
2982
- children: w.title ?? "Thanks!"
2983
- }), w.message && /* @__PURE__ */ Q("p", {
2984
- className: "mt-2 text-sm text-muted-foreground",
2985
- children: w.message
2986
- })]
2987
- });
2988
- let H = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical";
2989
- if (z?.length && (!e.formType || e.formType === "simple")) {
2990
- let t = R ? L : p, n = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, r = z.map((e) => n(e.columns)).filter((e) => e != null), i = z.reduce((e, t) => e + (Array.isArray(t.fields) ? t.fields.length : 0), 0), a = n(e.columns) ?? (r.length ? Math.max(...r) : He(i)), s = [];
2991
- z.forEach((r, i) => {
3139
+ if (C) {
3140
+ let e = /* @__PURE__ */ Q("div", {
3141
+ className: "rounded-md border bg-card p-6 sm:p-8 text-center",
3142
+ children: [/* @__PURE__ */ Z("h3", {
3143
+ className: "text-lg font-semibold",
3144
+ children: C.title ?? "Thanks!"
3145
+ }), C.message && /* @__PURE__ */ Z("p", {
3146
+ className: "mt-2 text-sm text-muted-foreground",
3147
+ children: C.message
3148
+ })]
3149
+ });
3150
+ return C.refusal ? /* @__PURE__ */ Q("div", {
3151
+ className: "space-y-4",
3152
+ children: [e, /* @__PURE__ */ Z("div", {
3153
+ role: "alert",
3154
+ className: "rounded-md border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive",
3155
+ children: C.refusal
3156
+ })]
3157
+ }) : e;
3158
+ }
3159
+ let V = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical";
3160
+ if (R?.length && (!e.formType || e.formType === "simple")) {
3161
+ let t = re ? ne : p, n = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, r = R.map((e) => n(e.columns)).filter((e) => e != null), i = R.reduce((e, t) => e + (Array.isArray(t.fields) ? t.fields.length : 0), 0), a = n(e.columns) ?? (r.length ? Math.max(...r) : rt(i)), s = [];
3162
+ R.forEach((r, i) => {
2992
3163
  let c = new Map(r.fields.map((e) => [typeof e == "string" ? e : e.field ?? e.name, e])), l = Array.from(c.keys()), d = u(t.filter((e) => l.includes(e.name))).map((e) => {
2993
3164
  let t = c.get(e.name);
2994
3165
  if (!t || typeof t != "object") return e;
@@ -2996,7 +3167,7 @@ var tn = ({ schema: e, dataSource: t }) => {
2996
3167
  return n.visibleOn != null && (r.visibleOn = n.visibleOn), n.colSpan != null && (r.colSpan = n.colSpan), n.span != null && (r.span = n.span), r;
2997
3168
  });
2998
3169
  if (d.length === 0) return;
2999
- let f = r.name || r.label || String(i), p = r.name ? o(e.objectName, r.name, r.label || r.name) : r.label, m = B[f] ?? r.collapsed ?? !1;
3170
+ let f = r.name || r.label || String(i), p = r.name ? o(e.objectName, r.name, r.label || r.name) : r.label, m = z[f] ?? r.collapsed ?? !1;
3000
3171
  p && s.push({
3001
3172
  name: `__section_${f}`,
3002
3173
  label: p,
@@ -3004,45 +3175,45 @@ var tn = ({ schema: e, dataSource: t }) => {
3004
3175
  colSpan: 4,
3005
3176
  collapsible: r.collapsible,
3006
3177
  collapsed: m,
3007
- onToggle: r.collapsible ? () => V((e) => ({
3178
+ onToggle: r.collapsible ? () => B((e) => ({
3008
3179
  ...e,
3009
3180
  [f]: !m
3010
3181
  })) : void 0,
3011
3182
  className: r.className
3012
3183
  });
3013
- let h = n(r.columns), g = a > 1 ? Ge(d, a, h) : d;
3184
+ let h = n(r.columns), g = a > 1 ? $(d, a, h) : d;
3014
3185
  p && m ? s.push(...g.map((e) => ({
3015
3186
  ...e,
3016
3187
  hidden: !0
3017
3188
  }))) : s.push(...g);
3018
3189
  });
3019
- let c = s, l = Ze(a);
3020
- return /* @__PURE__ */ $("div", {
3190
+ let c = s, l = dt(a);
3191
+ return /* @__PURE__ */ Q("div", {
3021
3192
  className: "w-full @container",
3022
- children: [/* @__PURE__ */ Q(y, { schema: {
3193
+ children: [/* @__PURE__ */ Z(x, { schema: {
3023
3194
  type: "form",
3024
3195
  objectName: e.objectName,
3025
3196
  fields: c,
3026
- layout: H,
3197
+ layout: V,
3027
3198
  columns: a,
3028
3199
  ...l ? { fieldContainerClass: l } : {},
3029
- defaultValues: ee,
3030
- previousValues: I,
3200
+ defaultValues: te,
3201
+ previousValues: L,
3031
3202
  showSubmit: e.showSubmit !== !1 && e.mode !== "view",
3032
3203
  showCancel: e.showCancel !== !1,
3033
3204
  submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
3034
3205
  cancelLabel: e.cancelText,
3035
- onSubmit: N,
3036
- onCancel: P
3037
- } }), A]
3206
+ onSubmit: F,
3207
+ onCancel: I
3208
+ } }), k]
3038
3209
  });
3039
3210
  }
3040
- let U = e.sections?.length, W = u(p), G = U ? {
3041
- fields: W,
3211
+ let H = e.sections?.length, U = u(p), ie = H ? {
3212
+ fields: U,
3042
3213
  columns: e.columns
3043
- } : $e(W, d, e.columns, e.mode), K = e.mobile, te = K?.fullscreenLongText ? G.fields.map((e) => {
3214
+ } : pt(U, d, e.columns, e.mode), W = e.mobile, G = W?.fullscreenLongText ? ie.fields.map((e) => {
3044
3215
  let t = e.type;
3045
- return t !== "textarea" && t !== "field:textarea" && t !== "field:markdown" && t !== "field:html" ? e : e.field ? {
3216
+ return t !== "textarea" && t !== "field:textarea" && t !== "field:markdown" && t !== "field:html" && t !== "field:richtext" ? e : e.field ? {
3046
3217
  ...e,
3047
3218
  field: {
3048
3219
  ...e.field,
@@ -3052,18 +3223,18 @@ var tn = ({ schema: e, dataSource: t }) => {
3052
3223
  ...e,
3053
3224
  mobile_fullscreen: !0
3054
3225
  };
3055
- }) : G.fields, ne = K?.stepper, re = K?.stepperMinFields ?? 8, q = Math.max(1, K?.stepperFieldsPerStep ?? 1);
3056
- if (!e.formType && !U && te.length >= 2 && (ne === !0 || ne === "auto" && s && te.length >= re)) {
3057
- let t = te, n = [];
3058
- for (let e = 0; e < t.length; e += q) {
3059
- let r = t.slice(e, e + q);
3226
+ }) : ie.fields, ae = W?.stepper, K = W?.stepperMinFields ?? 8, oe = Math.max(1, W?.stepperFieldsPerStep ?? 1);
3227
+ if (!e.formType && !H && G.length >= 2 && (ae === !0 || ae === "auto" && s && G.length >= K)) {
3228
+ let t = G, n = [];
3229
+ for (let e = 0; e < t.length; e += oe) {
3230
+ let r = t.slice(e, e + oe);
3060
3231
  n.push({
3061
- name: `step-${Math.floor(e / q) + 1}`,
3062
- label: r[0]?.label || r[0]?.name || `Step ${Math.floor(e / q) + 1}`,
3232
+ name: `step-${Math.floor(e / oe) + 1}`,
3233
+ label: r[0]?.label || r[0]?.name || `Step ${Math.floor(e / oe) + 1}`,
3063
3234
  fields: r
3064
3235
  });
3065
3236
  }
3066
- return /* @__PURE__ */ Q(lt, {
3237
+ return /* @__PURE__ */ Z(wt, {
3067
3238
  schema: {
3068
3239
  ...e,
3069
3240
  formType: "wizard",
@@ -3074,30 +3245,46 @@ var tn = ({ schema: e, dataSource: t }) => {
3074
3245
  className: e.className
3075
3246
  });
3076
3247
  }
3077
- let J = {
3248
+ let se = {
3078
3249
  type: "form",
3079
3250
  objectName: e.objectName,
3080
- fields: te,
3081
- layout: H,
3082
- columns: G.columns,
3251
+ fields: G,
3252
+ layout: V,
3253
+ columns: ie.columns,
3083
3254
  submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
3084
3255
  cancelLabel: e.cancelText,
3085
3256
  showSubmit: e.showSubmit !== !1 && e.mode !== "view",
3086
3257
  showCancel: e.showCancel !== !1,
3087
3258
  resetOnSubmit: e.showReset || e.submitBehavior?.kind === "continue" || !e.submitBehavior && e.resetOnSuccess && e.mode === "create",
3088
- defaultValues: ee,
3089
- previousValues: I,
3090
- onSubmit: N,
3091
- onCancel: P,
3259
+ defaultValues: te,
3260
+ previousValues: L,
3261
+ onSubmit: F,
3262
+ onCancel: I,
3092
3263
  className: e.className,
3093
- mobileStickyActions: !!K?.stickyActions
3264
+ mobileStickyActions: !!W?.stickyActions
3094
3265
  };
3095
- return /* @__PURE__ */ $("div", {
3096
- className: K?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
3097
- "data-mobile-form": K ? "true" : void 0,
3098
- children: [/* @__PURE__ */ Q(y, { schema: J }), A]
3266
+ return /* @__PURE__ */ Q("div", {
3267
+ className: W?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
3268
+ "data-mobile-form": W ? "true" : void 0,
3269
+ children: [/* @__PURE__ */ Z(x, { schema: se }), k]
3099
3270
  });
3100
- }, rn = {
3271
+ }, bn = 1e3;
3272
+ function xn(e) {
3273
+ return e ? Math.max(0, Math.ceil(e.delayMs / 1e3)) : null;
3274
+ }
3275
+ function Sn(e) {
3276
+ let [t, n] = c(e), [r, a] = c(() => xn(e));
3277
+ return e !== t && (n(e), a(xn(e))), i(() => {
3278
+ if (!e) return;
3279
+ let t = setInterval(() => {
3280
+ a((e) => e === null || e <= 1 ? (clearInterval(t), 0) : e - 1);
3281
+ }, bn);
3282
+ return () => clearInterval(t);
3283
+ }, [e]), r;
3284
+ }
3285
+ //#endregion
3286
+ //#region src/EmbeddableForm.tsx
3287
+ var Cn = {
3101
3288
  text: 200,
3102
3289
  email: 254,
3103
3290
  url: 2048,
@@ -3105,8 +3292,8 @@ var tn = ({ schema: e, dataSource: t }) => {
3105
3292
  textarea: 5e3,
3106
3293
  markdown: 5e3,
3107
3294
  html: 5e3
3108
- }, an = "_company_website_2", on = 1500;
3109
- function sn(e, t = []) {
3295
+ }, wn = "_company_website_2", Tn = 1500;
3296
+ function En(e, t = []) {
3110
3297
  try {
3111
3298
  let n = new URL(e, typeof window < "u" ? window.location.href : "http://localhost");
3112
3299
  return typeof window < "u" && n.origin === window.location.origin ? !0 : n.protocol !== "https:" && n.protocol !== "http:" ? !1 : t.some((e) => {
@@ -3121,22 +3308,22 @@ function sn(e, t = []) {
3121
3308
  return !1;
3122
3309
  }
3123
3310
  }
3124
- function cn(e) {
3311
+ function Dn(e) {
3125
3312
  return e && e.map((e) => {
3126
- let t = rn[String(e.type || "").toLowerCase()];
3313
+ let t = Cn[String(e.type || "").toLowerCase()];
3127
3314
  return !t || (e.maxLength ?? e.max_length) ? e : {
3128
3315
  ...e,
3129
3316
  maxLength: t
3130
3317
  };
3131
3318
  });
3132
3319
  }
3133
- var ln = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
3134
- let [l, u] = c(!1), [d, f] = c(!1), [p, m] = c(null), [h, g] = c(!(e.consent?.required ?? !!e.consent)), [_, v] = c(null), y = s(null), b = s(0);
3320
+ var On = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
3321
+ let [l, u] = c(!1), [d, f] = c(!1), [p, m] = c(null), [h, g] = c(!(e.consent?.required ?? !!e.consent)), [_, v] = c(null), [y, b] = c(null), [x, S] = c(!1), C = s(null), w = s(0);
3135
3322
  i(() => {
3136
- l || (b.current = Date.now());
3137
- }, [l]);
3138
- let x = e.honeypot === !1 ? null : e.honeypot || an, S = e.minFillTime ?? on, C = o(() => cn(e.customFields), [e.customFields]), w = o(() => {
3139
- if (!t || C && C.length > 0 || !e.fields || e.fields.length === 0) return;
3323
+ l || (w.current = Date.now());
3324
+ }, [l]), Re(y);
3325
+ let T = Sn(y), E = e.honeypot === !1 ? null : e.honeypot || wn, D = e.minFillTime ?? Tn, O = o(() => Dn(e.customFields), [e.customFields]), k = o(() => {
3326
+ if (!t || O && O.length > 0 || !e.fields || e.fields.length === 0) return;
3140
3327
  let n = async (e, t) => t;
3141
3328
  return {
3142
3329
  ...t,
@@ -3146,9 +3333,9 @@ var ln = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
3146
3333
  };
3147
3334
  }, [
3148
3335
  t,
3149
- C,
3336
+ O,
3150
3337
  e.fields
3151
- ]), T = o(() => {
3338
+ ]), A = o(() => {
3152
3339
  let t = {};
3153
3340
  if (r) for (let [e, n] of Object.entries(r)) t[e] = n;
3154
3341
  if (typeof window < "u" && e.allowedPrefillFields?.length) {
@@ -3158,31 +3345,32 @@ var ln = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
3158
3345
  });
3159
3346
  }
3160
3347
  return Object.keys(t).length > 0 ? t : void 0;
3161
- }, [r, e.allowedPrefillFields]), E = n(async (n) => {
3348
+ }, [r, e.allowedPrefillFields]), j = n(async (n) => {
3162
3349
  if (e.consent?.required && !h) {
3163
3350
  v(e.texts?.consentRequired ?? "Please accept the privacy policy to continue.");
3164
3351
  return;
3165
3352
  }
3166
- if (v(null), x && y.current?.value) {
3353
+ if (v(null), E && C.current?.value) {
3167
3354
  u(!0);
3168
3355
  return;
3169
3356
  }
3170
- if (S > 0 && Date.now() - b.current < S) {
3357
+ if (D > 0 && Date.now() - w.current < D) {
3171
3358
  m(e.texts?.rateLimited ?? "Please take a moment to review your answers before submitting.");
3172
3359
  return;
3173
3360
  }
3174
3361
  let r = { ...n };
3175
- x && delete r[x], e.captchaToken && (r._captcha = e.captchaToken), f(!0), m(null);
3362
+ E && delete r[E], e.captchaToken && (r._captcha = e.captchaToken), f(!0), m(null);
3176
3363
  try {
3177
3364
  t && await t.create(e.objectName, r), u(!0);
3178
3365
  let n = e.thankYouPage?.redirectUrl;
3179
3366
  if (n) {
3180
- if (sn(n, e.allowedRedirectHosts)) {
3367
+ if (En(n, e.allowedRedirectHosts)) {
3181
3368
  let t = e.thankYouPage?.redirectDelay ?? 3e3;
3182
- setTimeout(() => {
3183
- window.location.href = n;
3184
- }, t);
3185
- } else console.warn("[EmbeddableForm] Blocked unsafe redirect target:", n), m(e.texts?.redirectBlocked ?? null);
3369
+ b({
3370
+ url: n,
3371
+ delayMs: t
3372
+ });
3373
+ } else console.warn("[EmbeddableForm] Blocked unsafe redirect target:", n), S(!0);
3186
3374
  }
3187
3375
  } catch (e) {
3188
3376
  m(e instanceof Error ? e.message : "Failed to submit form. Please try again.");
@@ -3193,195 +3381,199 @@ var ln = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
3193
3381
  t,
3194
3382
  e,
3195
3383
  h,
3196
- x,
3197
- S
3198
- ]), D = n(() => {
3199
- u(!1), m(null);
3200
- }, []), O = o(() => {
3384
+ E,
3385
+ D
3386
+ ]), M = n(() => {
3387
+ u(!1), m(null), b(null), S(!1);
3388
+ }, []), N = o(() => {
3201
3389
  let t = {};
3202
3390
  return e.branding?.backgroundColor && (t.backgroundColor = e.branding.backgroundColor), t;
3203
3391
  }, [e.branding]);
3204
3392
  if (l) {
3205
- 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));
3206
- return /* @__PURE__ */ Q("div", {
3393
+ let t = e.thankYouPage, n = e.texts ?? {}, r = y && T !== null ? (n.redirecting ?? "Redirecting in {{seconds}} seconds…").replace("{{seconds}}", String(T)) : null;
3394
+ return /* @__PURE__ */ Z("div", {
3207
3395
  className: `min-h-screen flex items-center justify-center p-4 bg-gradient-to-b from-muted/40 via-background to-background ${a || ""}`,
3208
- style: O,
3209
- children: /* @__PURE__ */ $("div", {
3396
+ style: N,
3397
+ children: /* @__PURE__ */ Q("div", {
3210
3398
  className: "max-w-md w-full bg-card border rounded-xl shadow-sm p-8 text-center space-y-4",
3211
3399
  children: [
3212
- /* @__PURE__ */ Q("div", {
3400
+ /* @__PURE__ */ Z("div", {
3213
3401
  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",
3214
- children: /* @__PURE__ */ Q(fe, {
3402
+ children: /* @__PURE__ */ Z(ye, {
3215
3403
  className: "h-8 w-8",
3216
3404
  "aria-hidden": "true"
3217
3405
  })
3218
3406
  }),
3219
- /* @__PURE__ */ Q("h2", {
3407
+ /* @__PURE__ */ Z("h2", {
3220
3408
  className: "text-xl font-semibold text-foreground",
3221
3409
  children: t?.title || n.thankYouTitle || "Thank You!"
3222
3410
  }),
3223
- /* @__PURE__ */ Q("p", {
3411
+ /* @__PURE__ */ Z("p", {
3224
3412
  className: "text-sm text-muted-foreground",
3225
3413
  children: t?.message || n.thankYouMessage || "Your submission has been received successfully."
3226
3414
  }),
3227
- e.allowMultiple && /* @__PURE__ */ Q(I, {
3415
+ e.allowMultiple && /* @__PURE__ */ Z(R, {
3228
3416
  variant: "outline",
3229
3417
  size: "sm",
3230
- onClick: D,
3418
+ onClick: M,
3231
3419
  className: "mt-2",
3232
3420
  children: n.submitAnother ?? "Submit Another Response"
3233
3421
  }),
3234
- t?.redirectUrl && /* @__PURE__ */ Q("p", {
3422
+ r && /* @__PURE__ */ Z("p", {
3423
+ className: "text-xs text-muted-foreground",
3424
+ children: r
3425
+ }),
3426
+ x && n.redirectBlocked && /* @__PURE__ */ Z("p", {
3235
3427
  className: "text-xs text-muted-foreground",
3236
- children: i
3428
+ children: n.redirectBlocked
3237
3429
  })
3238
3430
  ]
3239
3431
  })
3240
3432
  });
3241
3433
  }
3242
- let k = e.texts ?? {}, A = !!e.consent?.required, j = `${e.formId}-consent`;
3243
- return /* @__PURE__ */ Q("div", {
3434
+ let P = e.texts ?? {}, F = !!e.consent?.required, I = `${e.formId}-consent`;
3435
+ return /* @__PURE__ */ Z("div", {
3244
3436
  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 ${a || ""}`,
3245
- style: O,
3246
- children: /* @__PURE__ */ $("div", {
3437
+ style: N,
3438
+ children: /* @__PURE__ */ Q("div", {
3247
3439
  className: "max-w-2xl w-full bg-card border rounded-xl shadow-sm overflow-hidden",
3248
3440
  children: [
3249
- e.branding?.coverImage && /* @__PURE__ */ Q("div", {
3441
+ e.branding?.coverImage && /* @__PURE__ */ Z("div", {
3250
3442
  className: "h-28 sm:h-32 w-full bg-cover bg-center",
3251
3443
  style: { backgroundImage: `url(${JSON.stringify(e.branding.coverImage)})` },
3252
3444
  role: "presentation"
3253
3445
  }),
3254
- /* @__PURE__ */ $("div", {
3446
+ /* @__PURE__ */ Q("div", {
3255
3447
  className: "px-6 sm:px-8 pt-7 pb-5 border-b bg-muted/20",
3256
3448
  style: e.branding?.primaryColor ? { borderBottomColor: e.branding.primaryColor } : void 0,
3257
3449
  children: [
3258
- e.branding?.logo && /* @__PURE__ */ Q("img", {
3450
+ e.branding?.logo && /* @__PURE__ */ Z("img", {
3259
3451
  src: e.branding.logo,
3260
3452
  alt: "",
3261
3453
  className: "h-8 mb-4"
3262
3454
  }),
3263
- e.title && /* @__PURE__ */ Q("h1", {
3455
+ e.title && /* @__PURE__ */ Z("h1", {
3264
3456
  className: "text-2xl font-semibold tracking-tight text-foreground",
3265
3457
  children: e.title
3266
3458
  }),
3267
- e.description && /* @__PURE__ */ Q("p", {
3459
+ e.description && /* @__PURE__ */ Z("p", {
3268
3460
  className: "text-sm text-muted-foreground mt-2 leading-relaxed",
3269
3461
  children: e.description
3270
3462
  }),
3271
- /* @__PURE__ */ Q("p", {
3463
+ /* @__PURE__ */ Z("p", {
3272
3464
  className: "text-[11px] text-muted-foreground/70 mt-3",
3273
3465
  "aria-hidden": "true",
3274
- children: k.requiredHint ?? "* Required field"
3466
+ children: P.requiredHint ?? "* Required field"
3275
3467
  })
3276
3468
  ]
3277
3469
  }),
3278
- /* @__PURE__ */ $("div", {
3470
+ /* @__PURE__ */ Q("div", {
3279
3471
  className: "relative px-6 sm:px-8 py-6",
3280
3472
  children: [
3281
- p && /* @__PURE__ */ Q("div", {
3473
+ p && /* @__PURE__ */ Z("div", {
3282
3474
  role: "alert",
3283
3475
  "aria-live": "assertive",
3284
3476
  className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
3285
3477
  children: p
3286
3478
  }),
3287
- /* @__PURE__ */ Q(tn, {
3479
+ /* @__PURE__ */ Z(vn, {
3288
3480
  schema: {
3289
3481
  type: "object-form",
3290
3482
  objectName: e.objectName,
3291
3483
  mode: "create",
3292
3484
  fields: e.fields,
3293
- customFields: C,
3294
- initialData: T,
3295
- onSuccess: E,
3296
- submitText: d ? k.submitting ?? "Submitting..." : k.submit ?? "Submit"
3485
+ customFields: O,
3486
+ initialData: A,
3487
+ onSuccess: j,
3488
+ submitText: d ? P.submitting ?? "Submitting..." : P.submit ?? "Submit"
3297
3489
  },
3298
- dataSource: w
3490
+ dataSource: k
3299
3491
  }),
3300
- x && /* @__PURE__ */ $("div", {
3492
+ E && /* @__PURE__ */ Q("div", {
3301
3493
  "aria-hidden": "true",
3302
3494
  className: "absolute left-[-10000px] top-auto h-px w-px overflow-hidden",
3303
- children: [/* @__PURE__ */ Q("label", {
3304
- htmlFor: `${e.formId}-${x}`,
3495
+ children: [/* @__PURE__ */ Z("label", {
3496
+ htmlFor: `${e.formId}-${E}`,
3305
3497
  children: "Do not fill this field"
3306
- }), /* @__PURE__ */ Q("input", {
3307
- ref: y,
3308
- id: `${e.formId}-${x}`,
3498
+ }), /* @__PURE__ */ Z("input", {
3499
+ ref: C,
3500
+ id: `${e.formId}-${E}`,
3309
3501
  type: "text",
3310
- name: x,
3502
+ name: E,
3311
3503
  tabIndex: -1,
3312
3504
  autoComplete: "off",
3313
3505
  defaultValue: ""
3314
3506
  })]
3315
3507
  }),
3316
- e.consent && /* @__PURE__ */ $("div", {
3508
+ e.consent && /* @__PURE__ */ Q("div", {
3317
3509
  className: "mt-4",
3318
- children: [/* @__PURE__ */ $("label", {
3510
+ children: [/* @__PURE__ */ Q("label", {
3319
3511
  className: "flex items-start gap-2 text-sm text-foreground cursor-pointer select-none",
3320
- children: [/* @__PURE__ */ Q("input", {
3512
+ children: [/* @__PURE__ */ Z("input", {
3321
3513
  type: "checkbox",
3322
- id: j,
3514
+ id: I,
3323
3515
  checked: h,
3324
3516
  onChange: (e) => {
3325
3517
  g(e.target.checked), e.target.checked && v(null);
3326
3518
  },
3327
- "aria-required": A || void 0,
3519
+ "aria-required": F || void 0,
3328
3520
  "aria-invalid": _ ? "true" : void 0,
3329
- "aria-describedby": _ ? `${j}-error` : void 0,
3521
+ "aria-describedby": _ ? `${I}-error` : void 0,
3330
3522
  className: "mt-0.5 h-4 w-4 rounded border-input accent-primary"
3331
- }), /* @__PURE__ */ $("span", {
3523
+ }), /* @__PURE__ */ Q("span", {
3332
3524
  className: "leading-relaxed",
3333
3525
  children: [
3334
- e.consent.label ?? k.consentLabelDefault ?? "I agree to the privacy policy.",
3335
- A && /* @__PURE__ */ Q("span", {
3526
+ e.consent.label ?? P.consentLabelDefault ?? "I agree to the privacy policy.",
3527
+ F && /* @__PURE__ */ Z("span", {
3336
3528
  "aria-hidden": "true",
3337
3529
  className: "text-destructive ml-0.5",
3338
3530
  children: "*"
3339
3531
  }),
3340
- e.consent.privacyUrl && /* @__PURE__ */ $(be, { children: [" ", /* @__PURE__ */ Q("a", {
3532
+ e.consent.privacyUrl && /* @__PURE__ */ Q(De, { children: [" ", /* @__PURE__ */ Z("a", {
3341
3533
  href: e.consent.privacyUrl,
3342
3534
  target: "_blank",
3343
3535
  rel: "noopener noreferrer",
3344
3536
  className: "underline text-primary hover:opacity-80",
3345
- children: k.consentLink ?? "Privacy policy"
3537
+ children: P.consentLink ?? "Privacy policy"
3346
3538
  })] })
3347
3539
  ]
3348
3540
  })]
3349
- }), _ && /* @__PURE__ */ Q("p", {
3350
- id: `${j}-error`,
3541
+ }), _ && /* @__PURE__ */ Z("p", {
3542
+ id: `${I}-error`,
3351
3543
  role: "alert",
3352
3544
  className: "mt-1.5 text-xs text-destructive",
3353
3545
  children: _
3354
3546
  })]
3355
3547
  }),
3356
- d && /* @__PURE__ */ $("div", {
3548
+ d && /* @__PURE__ */ Q("div", {
3357
3549
  className: "mt-3 flex items-center gap-2 text-xs text-muted-foreground",
3358
- children: [/* @__PURE__ */ Q(ge, {
3550
+ children: [/* @__PURE__ */ Z(Ce, {
3359
3551
  className: "h-3.5 w-3.5 animate-spin",
3360
3552
  "aria-hidden": "true"
3361
- }), /* @__PURE__ */ Q("span", { children: k.submitting ?? "Submitting…" })]
3553
+ }), /* @__PURE__ */ Z("span", { children: P.submitting ?? "Submitting…" })]
3362
3554
  })
3363
3555
  ]
3364
3556
  }),
3365
- /* @__PURE__ */ $("div", {
3557
+ /* @__PURE__ */ Q("div", {
3366
3558
  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",
3367
- children: [/* @__PURE__ */ $("p", {
3559
+ children: [/* @__PURE__ */ Q("p", {
3368
3560
  className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground",
3369
- children: [/* @__PURE__ */ Q(_e, {
3561
+ children: [/* @__PURE__ */ Z(we, {
3370
3562
  className: "h-3 w-3",
3371
3563
  "aria-hidden": "true"
3372
- }), /* @__PURE__ */ Q("span", { children: k.secureNotice ?? "Your information is transmitted securely and only used to respond to your request." })]
3373
- }), /* @__PURE__ */ $("div", {
3564
+ }), /* @__PURE__ */ Z("span", { children: P.secureNotice ?? "Your information is transmitted securely and only used to respond to your request." })]
3565
+ }), /* @__PURE__ */ Q("div", {
3374
3566
  className: "flex items-center gap-3 text-xs text-muted-foreground/80",
3375
- children: [e.privacyPolicyUrl && /* @__PURE__ */ $("a", {
3567
+ children: [e.privacyPolicyUrl && /* @__PURE__ */ Q("a", {
3376
3568
  href: e.privacyPolicyUrl,
3377
3569
  target: "_blank",
3378
3570
  rel: "noopener noreferrer",
3379
3571
  className: "inline-flex items-center gap-1 underline hover:text-foreground",
3380
- children: [/* @__PURE__ */ Q(ve, {
3572
+ children: [/* @__PURE__ */ Z(Te, {
3381
3573
  className: "h-3 w-3",
3382
3574
  "aria-hidden": "true"
3383
- }), k.consentLink ?? "Privacy policy"]
3384
- }), /* @__PURE__ */ Q("span", { children: k.poweredBy ?? "Powered by ObjectStack" })]
3575
+ }), P.consentLink ?? "Privacy policy"]
3576
+ }), /* @__PURE__ */ Z("span", { children: P.poweredBy ?? "Powered by ObjectStack" })]
3385
3577
  })]
3386
3578
  })
3387
3579
  ]
@@ -3390,96 +3582,96 @@ var ln = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
3390
3582
  };
3391
3583
  //#endregion
3392
3584
  //#region src/FormAnalytics.tsx
3393
- function un(e) {
3585
+ function kn(e) {
3394
3586
  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`;
3395
3587
  }
3396
- var dn = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
3588
+ var An = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
3397
3589
  let i = o(() => {
3398
3590
  if (!n.abandonedSubmissions) return 100;
3399
3591
  let e = n.totalSubmissions + n.abandonedSubmissions;
3400
3592
  return e === 0 ? 0 : Math.round(n.totalSubmissions / e * 100);
3401
3593
  }, [n.totalSubmissions, n.abandonedSubmissions]), a = o(() => n.dailySubmissions?.length ? Math.max(...n.dailySubmissions.map((e) => e.count), 1) : 1, [n.dailySubmissions]);
3402
- return /* @__PURE__ */ $("div", {
3594
+ return /* @__PURE__ */ Q("div", {
3403
3595
  className: `space-y-4 ${r || ""}`,
3404
3596
  children: [
3405
- /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q("h2", {
3597
+ /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z("h2", {
3406
3598
  className: "text-lg font-semibold text-foreground",
3407
3599
  children: t || "Form Analytics"
3408
- }), /* @__PURE__ */ $("p", {
3600
+ }), /* @__PURE__ */ Q("p", {
3409
3601
  className: "text-sm text-muted-foreground",
3410
3602
  children: ["Form ID: ", e]
3411
3603
  })] }),
3412
- /* @__PURE__ */ $("div", {
3604
+ /* @__PURE__ */ Q("div", {
3413
3605
  className: "grid grid-cols-1 sm:grid-cols-3 gap-4",
3414
3606
  children: [
3415
- /* @__PURE__ */ Q(L, { children: /* @__PURE__ */ $(B, {
3607
+ /* @__PURE__ */ Z(z, { children: /* @__PURE__ */ Q(H, {
3416
3608
  className: "pb-2",
3417
- children: [/* @__PURE__ */ Q(z, { children: "Total Submissions" }), /* @__PURE__ */ Q(V, {
3609
+ children: [/* @__PURE__ */ Z(V, { children: "Total Submissions" }), /* @__PURE__ */ Z(U, {
3418
3610
  className: "text-2xl",
3419
3611
  children: n.totalSubmissions.toLocaleString()
3420
3612
  })]
3421
3613
  }) }),
3422
- /* @__PURE__ */ $(L, { children: [/* @__PURE__ */ $(B, {
3614
+ /* @__PURE__ */ Q(z, { children: [/* @__PURE__ */ Q(H, {
3423
3615
  className: "pb-2",
3424
- children: [/* @__PURE__ */ Q(z, { children: "Fill Rate" }), /* @__PURE__ */ $(V, {
3616
+ children: [/* @__PURE__ */ Z(V, { children: "Fill Rate" }), /* @__PURE__ */ Q(U, {
3425
3617
  className: "text-2xl",
3426
3618
  children: [i, "%"]
3427
3619
  })]
3428
- }), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q("div", {
3620
+ }), /* @__PURE__ */ Z(B, { children: /* @__PURE__ */ Z("div", {
3429
3621
  className: "w-full bg-muted rounded-full h-2",
3430
- children: /* @__PURE__ */ Q("div", {
3622
+ children: /* @__PURE__ */ Z("div", {
3431
3623
  className: "bg-primary rounded-full h-2 transition-all",
3432
3624
  style: { width: `${i}%` }
3433
3625
  })
3434
3626
  }) })] }),
3435
- /* @__PURE__ */ Q(L, { children: /* @__PURE__ */ $(B, {
3627
+ /* @__PURE__ */ Z(z, { children: /* @__PURE__ */ Q(H, {
3436
3628
  className: "pb-2",
3437
- children: [/* @__PURE__ */ Q(z, { children: "Avg. Completion Time" }), /* @__PURE__ */ Q(V, {
3629
+ children: [/* @__PURE__ */ Z(V, { children: "Avg. Completion Time" }), /* @__PURE__ */ Z(U, {
3438
3630
  className: "text-2xl",
3439
- children: n.avgCompletionTime ? un(n.avgCompletionTime) : "—"
3631
+ children: n.avgCompletionTime ? kn(n.avgCompletionTime) : "—"
3440
3632
  })]
3441
3633
  }) })
3442
3634
  ]
3443
3635
  }),
3444
- n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ $(L, { children: [/* @__PURE__ */ Q(B, { children: /* @__PURE__ */ Q(V, {
3636
+ n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ Q(z, { children: [/* @__PURE__ */ Z(H, { children: /* @__PURE__ */ Z(U, {
3445
3637
  className: "text-sm font-medium",
3446
3638
  children: "Daily Submissions"
3447
- }) }), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q("div", {
3639
+ }) }), /* @__PURE__ */ Z(B, { children: /* @__PURE__ */ Z("div", {
3448
3640
  className: "flex items-end gap-1 h-32",
3449
- children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ $("div", {
3641
+ children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ Q("div", {
3450
3642
  className: "flex-1 flex flex-col items-center gap-1",
3451
- children: [/* @__PURE__ */ Q("div", {
3643
+ children: [/* @__PURE__ */ Z("div", {
3452
3644
  className: "w-full bg-primary/80 rounded-t transition-all hover:bg-primary",
3453
3645
  style: {
3454
3646
  height: `${e.count / a * 100}%`,
3455
3647
  minHeight: e.count > 0 ? "4px" : "0"
3456
3648
  },
3457
3649
  title: `${e.date}: ${e.count} submissions`
3458
- }), /* @__PURE__ */ Q("span", {
3650
+ }), /* @__PURE__ */ Z("span", {
3459
3651
  className: "text-[10px] text-muted-foreground truncate w-full text-center",
3460
3652
  children: e.date.slice(-5)
3461
3653
  })]
3462
3654
  }, t))
3463
3655
  }) })] }),
3464
- n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ $(L, { children: [/* @__PURE__ */ $(B, { children: [/* @__PURE__ */ Q(V, {
3656
+ n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ Q(z, { children: [/* @__PURE__ */ Q(H, { children: [/* @__PURE__ */ Z(U, {
3465
3657
  className: "text-sm font-medium",
3466
3658
  children: "Field Completion Rates"
3467
- }), /* @__PURE__ */ Q(z, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q("div", {
3659
+ }), /* @__PURE__ */ Z(V, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ Z(B, { children: /* @__PURE__ */ Z("div", {
3468
3660
  className: "space-y-3",
3469
- children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ $("div", {
3661
+ children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ Q("div", {
3470
3662
  className: "space-y-1",
3471
- children: [/* @__PURE__ */ $("div", {
3663
+ children: [/* @__PURE__ */ Q("div", {
3472
3664
  className: "flex justify-between text-sm",
3473
- children: [/* @__PURE__ */ Q("span", {
3665
+ children: [/* @__PURE__ */ Z("span", {
3474
3666
  className: "text-foreground",
3475
3667
  children: e.label
3476
- }), /* @__PURE__ */ $("span", {
3668
+ }), /* @__PURE__ */ Q("span", {
3477
3669
  className: "text-muted-foreground",
3478
3670
  children: [e.completionRate, "%"]
3479
3671
  })]
3480
- }), /* @__PURE__ */ Q("div", {
3672
+ }), /* @__PURE__ */ Z("div", {
3481
3673
  className: "w-full bg-muted rounded-full h-1.5",
3482
- children: /* @__PURE__ */ Q("div", {
3674
+ children: /* @__PURE__ */ Z("div", {
3483
3675
  className: `rounded-full h-1.5 transition-all ${e.completionRate >= 80 ? "bg-green-500" : e.completionRate >= 50 ? "bg-yellow-500" : "bg-destructive"}`,
3484
3676
  style: { width: `${e.completionRate}%` }
3485
3677
  })
@@ -3488,37 +3680,37 @@ var dn = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
3488
3680
  }) })] })
3489
3681
  ]
3490
3682
  });
3491
- }, fn = ({ schema: e }) => {
3492
- let t = w()?.dataSource, r = S(), a = e.parentObject || r?.objectName, s = e.parentId || e.recordId || r?.recordId, [l, d] = c([]), [f, m] = c([]), [h, v] = c(!0), [y, b] = c(!1), [x, C] = c(!1), [E, D] = c(null), [O, k] = c(null);
3683
+ }, jn = ({ schema: e }) => {
3684
+ let t = k()?.dataSource, r = E(), a = e.parentObject || r?.objectName, s = e.parentId || e.recordId || r?.recordId, [l, d] = c([]), [f, p] = c([]), [m, g] = c(!0), [_, b] = c(!1), [x, S] = c(!1), [C, w] = c(null), [T, D] = c(null);
3493
3685
  i(() => {
3494
3686
  let n = t;
3495
3687
  if (!n || typeof n.getObjectSchema != "function") return;
3496
3688
  let r = !1;
3497
3689
  return n.getObjectSchema(e.childObject).then((e) => {
3498
- r || k(e ?? null);
3690
+ r || D(e ?? null);
3499
3691
  }).catch(() => {
3500
- r || k(null);
3692
+ r || D(null);
3501
3693
  }), () => {
3502
3694
  r = !0;
3503
3695
  };
3504
3696
  }, [t, e.childObject]);
3505
- let A = JSON.stringify(e.filter ?? null), j = JSON.stringify(e.sort ?? null), M = o(() => _(e.filter), [A]), N = o(() => u(e.sort), [j]), P = n(async () => {
3697
+ let O = JSON.stringify(e.filter ?? null), j = JSON.stringify(e.sort ?? null), M = o(() => y(e.filter), [O]), N = o(() => u(e.sort), [j]), P = n(async () => {
3506
3698
  if (!t || !s) {
3507
- v(!1);
3699
+ g(!1);
3508
3700
  return;
3509
3701
  }
3510
- v(!0);
3702
+ g(!0);
3511
3703
  try {
3512
3704
  let n = { [e.relationshipField]: s }, r = (await t.find(e.childObject, {
3513
- $filter: M === void 0 ? n : p(n, M),
3705
+ $filter: M === void 0 ? n : h(n, M),
3514
3706
  ...N ? { $orderby: N } : {},
3515
3707
  $top: e.limit ?? 500
3516
3708
  }))?.data ?? [];
3517
- d(r.map((e) => ({ ...e }))), m(r.map((e) => ({ ...e }))), C(!1);
3709
+ d(r.map((e) => ({ ...e }))), p(r.map((e) => ({ ...e }))), S(!1);
3518
3710
  } catch (e) {
3519
- D(e?.message || "Failed to load line items");
3711
+ w(e?.message || "Failed to load line items");
3520
3712
  } finally {
3521
- v(!1);
3713
+ g(!1);
3522
3714
  }
3523
3715
  }, [
3524
3716
  t,
@@ -3533,21 +3725,21 @@ var dn = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
3533
3725
  P();
3534
3726
  }, [P]);
3535
3727
  let F = n((e) => {
3536
- d(e), C(!0);
3537
- }, []), ee = n(async () => {
3728
+ d(e), S(!0);
3729
+ }, []), I = n(async () => {
3538
3730
  if (!(!t || !s)) {
3539
- b(!0), D(null);
3731
+ b(!0), w(null);
3540
3732
  try {
3541
- let n = !!(a && e.totalField), r = n ? { [e.totalField]: xt(l, e.amountField || "amount") } : {}, i = yt(a ?? "", s, r, [{
3733
+ let n = !!(a && e.totalField), r = n ? { [e.totalField]: It(l, e.amountField || "amount") } : {}, i = Pt(a ?? "", s, r, [{
3542
3734
  childObject: e.childObject,
3543
3735
  relationshipField: e.relationshipField,
3544
3736
  rows: l,
3545
3737
  original: f,
3546
- childSchema: O
3738
+ childSchema: T
3547
3739
  }]);
3548
- n || (i = i.slice(1)), i.length && await g(t, i), await P();
3740
+ n || (i = i.slice(1)), i.length && await v(t, i), await P();
3549
3741
  } catch (e) {
3550
- D(e?.message || "Failed to save line items");
3742
+ w(e?.message || "Failed to save line items");
3551
3743
  } finally {
3552
3744
  b(!1);
3553
3745
  }
@@ -3560,8 +3752,8 @@ var dn = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
3560
3752
  e,
3561
3753
  a,
3562
3754
  P,
3563
- O
3564
- ]), z = o(() => ({
3755
+ T
3756
+ ]), ee = o(() => ({
3565
3757
  columns: e.columns,
3566
3758
  total_field: e.totalField ? e.amountField || "amount" : void 0,
3567
3759
  min_rows: e.minRows,
@@ -3569,50 +3761,52 @@ var dn = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
3569
3761
  allow_add: !e.readonly,
3570
3762
  allow_delete: !e.readonly
3571
3763
  }), [e]);
3572
- return /* @__PURE__ */ $(L, {
3764
+ return /* @__PURE__ */ Q(z, {
3573
3765
  className: Y("shadow-none"),
3574
- children: [/* @__PURE__ */ $(B, {
3766
+ children: [/* @__PURE__ */ Q(H, {
3575
3767
  className: "flex-row items-center justify-between gap-2 pb-2",
3576
- children: [/* @__PURE__ */ Q(V, {
3768
+ children: [/* @__PURE__ */ Z(U, {
3577
3769
  className: "text-sm font-medium",
3578
3770
  children: e.title || "Line Items"
3579
- }), !e.readonly && /* @__PURE__ */ Q(I, {
3771
+ }), !e.readonly && /* @__PURE__ */ Z(R, {
3580
3772
  type: "button",
3581
3773
  size: "sm",
3582
- onClick: ee,
3583
- disabled: y || h || !x || !s,
3584
- children: y ? "Saving…" : "Save"
3774
+ onClick: I,
3775
+ disabled: _ || m || !x || !s,
3776
+ children: _ ? "Saving…" : "Save"
3585
3777
  })]
3586
- }), /* @__PURE__ */ $(R, { children: [E && /* @__PURE__ */ Q("p", {
3778
+ }), /* @__PURE__ */ Q(B, { children: [C && /* @__PURE__ */ Z("p", {
3587
3779
  className: "mb-2 text-sm text-destructive",
3588
- children: E
3589
- }), h ? /* @__PURE__ */ Q("p", {
3780
+ children: C
3781
+ }), m ? /* @__PURE__ */ Z("p", {
3590
3782
  className: "py-6 text-center text-sm text-muted-foreground",
3591
3783
  children: "Loading…"
3592
- }) : s ? /* @__PURE__ */ Q(T, {
3784
+ }) : s ? /* @__PURE__ */ Z(A, {
3593
3785
  value: l,
3594
3786
  onChange: F,
3595
- field: z,
3787
+ field: ee,
3596
3788
  readonly: e.readonly
3597
- }) : /* @__PURE__ */ Q("p", {
3789
+ }) : /* @__PURE__ */ Z("p", {
3598
3790
  className: "py-6 text-center text-sm text-muted-foreground",
3599
3791
  children: "Save the record first to add line items."
3600
3792
  })] })]
3601
3793
  });
3602
- }, pn = ({ schema: e }) => {
3603
- let t = r(b)?.dataSource ?? void 0;
3604
- return /* @__PURE__ */ Q(v, {
3794
+ }, Mn = ({ schema: e, dataSource: t }) => {
3795
+ let n = D(t);
3796
+ return /* @__PURE__ */ Z(b, {
3605
3797
  schema: e,
3606
- dataSource: t,
3798
+ dataSource: n,
3607
3799
  testId: "object-form",
3608
3800
  errorTitle: "This form’s data source could not be resolved",
3609
- children: (e) => /* @__PURE__ */ Q(tn, {
3801
+ requiresDataSource: !(e?.customFields?.length > 0) && typeof e?.objectName == "string" && e.objectName.length > 0,
3802
+ noDataSourceMessage: C("object-form", e?.objectName),
3803
+ children: (e) => /* @__PURE__ */ Z(vn, {
3610
3804
  schema: e,
3611
- dataSource: t
3805
+ dataSource: n
3612
3806
  })
3613
3807
  });
3614
3808
  };
3615
- l.register("object-form", pn, {
3809
+ l.register("object-form", Mn, {
3616
3810
  namespace: "plugin-form",
3617
3811
  label: "Object Form",
3618
3812
  category: "plugin",
@@ -3751,9 +3945,125 @@ l.register("object-form", pn, {
3751
3945
  "xl",
3752
3946
  "full"
3753
3947
  ]
3948
+ },
3949
+ {
3950
+ name: "modalCloseButton",
3951
+ type: "boolean",
3952
+ label: "Modal Close Button",
3953
+ description: "Show the modal presentation’s close button. Read at ObjectForm.tsx:361 and honoured by ModalForm."
3954
+ },
3955
+ {
3956
+ name: "contentLayout",
3957
+ type: "enum",
3958
+ label: "Modal Content Layout",
3959
+ enum: ["simple", "tabbed"],
3960
+ description: "How the modal presentation lays out sections. `tabbed` needs more than one section to differ from `simple` (ModalForm.tsx:638)."
3961
+ },
3962
+ {
3963
+ name: "confirmOnDiscard",
3964
+ type: "boolean",
3965
+ label: "Confirm On Discard",
3966
+ description: "Ask before discarding unsaved edits when a drawer/modal form is dismissed. Set `false` to close immediately."
3967
+ },
3968
+ {
3969
+ name: "recordId",
3970
+ type: "string",
3971
+ label: "Record Id",
3972
+ description: "The record to load in `edit` / `view` mode. Leave unset for `create`."
3973
+ },
3974
+ {
3975
+ name: "customFields",
3976
+ type: "array",
3977
+ label: "Custom Fields",
3978
+ description: "Field definitions merged over the set generated from object metadata. With inline definitions and no data source, this becomes the only field source."
3979
+ },
3980
+ {
3981
+ name: "initialValues",
3982
+ type: "object",
3983
+ label: "Initial Values",
3984
+ description: "Values to prefill in `create` mode."
3985
+ },
3986
+ {
3987
+ name: "initialData",
3988
+ type: "object",
3989
+ label: "Initial Data",
3990
+ description: "Alternate spelling of `initialValues` that the drawer/modal presentations read FIRST (`schema.initialData || schema.initialValues`). Prefer `initialValues` in new schemas."
3991
+ },
3992
+ {
3993
+ name: "readOnly",
3994
+ type: "boolean",
3995
+ label: "Read Only",
3996
+ description: "Render every field read-only, whatever `mode` says."
3997
+ },
3998
+ {
3999
+ name: "submitText",
4000
+ type: "string",
4001
+ label: "Submit Button Text"
4002
+ },
4003
+ {
4004
+ name: "cancelText",
4005
+ type: "string",
4006
+ label: "Cancel Button Text"
4007
+ },
4008
+ {
4009
+ name: "nextText",
4010
+ type: "string",
4011
+ label: "Next Button Text",
4012
+ description: "Label of the next-step button (wizard)."
4013
+ },
4014
+ {
4015
+ name: "prevText",
4016
+ type: "string",
4017
+ label: "Previous Button Text",
4018
+ description: "Label of the previous-step button (wizard)."
4019
+ },
4020
+ {
4021
+ name: "showSubmit",
4022
+ type: "boolean",
4023
+ label: "Show Submit Button"
4024
+ },
4025
+ {
4026
+ name: "showCancel",
4027
+ type: "boolean",
4028
+ label: "Show Cancel Button"
4029
+ },
4030
+ {
4031
+ name: "showReset",
4032
+ type: "boolean",
4033
+ label: "Show Reset Button"
4034
+ },
4035
+ {
4036
+ name: "submitBehavior",
4037
+ type: "object",
4038
+ label: "Submit Behavior",
4039
+ description: "Declarative post-submit behaviour, one of `{ kind: \"thank-you\", title?, message? }`, `{ kind: \"redirect\", url, delayMs? }`, `{ kind: \"continue\" }`, `{ kind: \"next-record\" }`. When present it takes precedence over `successMessage` / `navigateOnSuccess` / `resetOnSuccess`."
4040
+ },
4041
+ {
4042
+ name: "successMessage",
4043
+ type: "string",
4044
+ label: "Success Message",
4045
+ description: "Toast shown after a successful submit. Ignored when `submitBehavior` or `navigateOnSuccess` is set."
4046
+ },
4047
+ {
4048
+ name: "navigateOnSuccess",
4049
+ type: "string",
4050
+ label: "Navigate On Success",
4051
+ description: "Path to navigate to after a successful create/update. Supports `{id}` / `{recordId}` interpolation from the saved record and is same-origin-guarded. Takes precedence over `successMessage`."
4052
+ },
4053
+ {
4054
+ name: "resetOnSuccess",
4055
+ type: "boolean",
4056
+ label: "Reset On Success",
4057
+ description: "Clear the form after a successful submit instead of keeping the saved values."
4058
+ },
4059
+ {
4060
+ name: "mobile",
4061
+ type: "object",
4062
+ label: "Mobile Overrides",
4063
+ description: "Phone-only presentation overrides, e.g. `{ stepper: \"auto\", stepperMinFields: 8, fullscreenLongText: true }`."
3754
4064
  }
3755
4065
  ]
3756
- }), l.register("form", pn, {
4066
+ }), l.register("form", Mn, {
3757
4067
  namespace: "view",
3758
4068
  skipFallback: !0,
3759
4069
  label: "Data Form View",
@@ -3782,13 +4092,13 @@ l.register("object-form", pn, {
3782
4092
  }
3783
4093
  ]
3784
4094
  }), l.register("embeddable-form", ({ schema: e }) => {
3785
- let t = r(b);
3786
- return /* @__PURE__ */ Q(v, {
4095
+ let t = r(S);
4096
+ return /* @__PURE__ */ Z(b, {
3787
4097
  schema: e,
3788
4098
  dataSource: t?.dataSource,
3789
4099
  testId: "embeddable-form",
3790
4100
  errorTitle: "This form’s data source could not be resolved",
3791
- children: (e) => /* @__PURE__ */ Q(ln, {
4101
+ children: (e) => /* @__PURE__ */ Z(On, {
3792
4102
  config: e,
3793
4103
  dataSource: t?.dataSource
3794
4104
  })
@@ -3831,7 +4141,7 @@ l.register("object-form", pn, {
3831
4141
  label: "Allow Multiple Submissions"
3832
4142
  }
3833
4143
  ]
3834
- }), l.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ Q(dn, {
4144
+ }), l.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ Z(An, {
3835
4145
  formId: e.formId,
3836
4146
  formTitle: e.formTitle,
3837
4147
  metrics: e.metrics || { totalSubmissions: 0 }
@@ -3858,13 +4168,13 @@ l.register("object-form", pn, {
3858
4168
  }
3859
4169
  ]
3860
4170
  }), l.register("object-master-detail-form", ({ schema: e }) => {
3861
- let t = r(b)?.dataSource ?? void 0;
3862
- return /* @__PURE__ */ Q(v, {
4171
+ let t = r(S)?.dataSource ?? void 0;
4172
+ return /* @__PURE__ */ Z(b, {
3863
4173
  schema: e,
3864
4174
  dataSource: t,
3865
4175
  testId: "object-master-detail-form",
3866
4176
  errorTitle: "This form’s data source could not be resolved",
3867
- children: (e) => /* @__PURE__ */ Q(Kt, {
4177
+ children: (e) => /* @__PURE__ */ Z(cn, {
3868
4178
  schema: e,
3869
4179
  dataSource: t
3870
4180
  })
@@ -3896,21 +4206,78 @@ l.register("object-form", pn, {
3896
4206
  type: "array",
3897
4207
  label: "Detail Collections",
3898
4208
  required: !0
4209
+ },
4210
+ {
4211
+ name: "recordId",
4212
+ type: "string",
4213
+ label: "Parent Record Id",
4214
+ description: "The parent record to load in `edit` mode. Leave unset for `create`."
4215
+ },
4216
+ {
4217
+ name: "formType",
4218
+ type: "string",
4219
+ label: "Parent Form Presentation",
4220
+ description: "How the PARENT half of the form is presented. The detail grids below it are unaffected."
4221
+ },
4222
+ {
4223
+ name: "fields",
4224
+ type: "array",
4225
+ label: "Parent Fields",
4226
+ description: "Which parent fields to show, in order. Ignored when `sections` is given — sections carry their own field lists."
4227
+ },
4228
+ {
4229
+ name: "title",
4230
+ type: "string",
4231
+ label: "Title"
4232
+ },
4233
+ {
4234
+ name: "submitText",
4235
+ type: "string",
4236
+ label: "Submit Button Text",
4237
+ description: "Label of the button that saves the parent and every detail row in one batch."
4238
+ },
4239
+ {
4240
+ name: "cancelText",
4241
+ type: "string",
4242
+ label: "Cancel Button Text"
4243
+ },
4244
+ {
4245
+ name: "showSubmit",
4246
+ type: "boolean",
4247
+ label: "Show Submit Button"
4248
+ },
4249
+ {
4250
+ name: "initialValues",
4251
+ type: "object",
4252
+ label: "Initial Values",
4253
+ description: "Values to prefill on the PARENT record in `create` mode."
4254
+ },
4255
+ {
4256
+ name: "initialData",
4257
+ type: "object",
4258
+ label: "Initial Data",
4259
+ description: "Alternate spelling of `initialValues` the renderer also reads (MasterDetailForm.tsx:602). Prefer `initialValues` in new schemas."
4260
+ },
4261
+ {
4262
+ name: "taxRateField",
4263
+ type: "string",
4264
+ label: "Tax Rate Field",
4265
+ description: "Name of the field ON THE CHILD object that holds each line’s tax rate. Feeds the line-items totals row; leave unset when the detail rows carry no tax."
3899
4266
  }
3900
4267
  ]
3901
4268
  });
3902
- var mn = {
4269
+ var Nn = {
3903
4270
  object: "childObject",
3904
4271
  filter: !0,
3905
4272
  sort: !0,
3906
4273
  limit: "limit"
3907
4274
  };
3908
- l.register("line_items", ({ schema: e }) => /* @__PURE__ */ Q(v, {
4275
+ l.register("line_items", ({ schema: e }) => /* @__PURE__ */ Z(b, {
3909
4276
  schema: e,
3910
- mapping: mn,
4277
+ mapping: Nn,
3911
4278
  testId: "record-line-items",
3912
4279
  errorTitle: "This line-items panel’s data source could not be resolved",
3913
- children: (e) => /* @__PURE__ */ Q(fn, { schema: e })
4280
+ children: (e) => /* @__PURE__ */ Z(jn, { schema: e })
3914
4281
  }), {
3915
4282
  namespace: "record",
3916
4283
  skipFallback: !0,
@@ -3948,4 +4315,4 @@ l.register("line_items", ({ schema: e }) => /* @__PURE__ */ Q(v, {
3948
4315
  ]
3949
4316
  });
3950
4317
  //#endregion
3951
- export { Yt as DrawerForm, ln as EmbeddableForm, dn as FormAnalytics, ot as FormSectionContainer, fn as LineItemsPanel, Kt as MasterDetailForm, $t as ModalForm, tn as ObjectForm, ut as SplitForm, at as TabbedForm, lt as WizardForm, Ge as applyAutoColSpan, $e as applyAutoLayout, Ze as containerGridColsFor, Pt as deriveColumns, Ut as deriveDetail, Lt as deriveFormFields, Ye as filterAutoGeneratedFields, Je as filterCreateModeFields, qe as filterSystemFields, kt as findRelationshipField, He as inferColumns, Qe as inferModalSize, Ve as isAutoGeneratedFieldType, Be as isWideFieldType, Bt as resolveInlineMode };
4318
+ export { pn as DrawerForm, On as EmbeddableForm, An as FormAnalytics, bt as FormSectionContainer, jn as LineItemsPanel, cn as MasterDetailForm, gn as ModalForm, vn as ObjectForm, Tt as SplitForm, yt as TabbedForm, wt as WizardForm, $ as applyAutoColSpan, pt as applyAutoLayout, dt as containerGridColsFor, Yt as deriveColumns, an as deriveDetail, Qt as deriveFormFields, lt as filterAutoGeneratedFields, ct as filterCreateModeFields, st as filterSystemFields, Wt as findRelationshipField, rt as inferColumns, ft as inferModalSize, nt as isAutoGeneratedFieldType, tt as isWideFieldType, tn as resolveInlineMode };