@object-ui/plugin-form 11.4.0 → 13.1.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
@@ -2,7 +2,7 @@ import e, { useCallback as t, useContext as n, useEffect as r, useId as i, useMe
2
2
  import { ComponentRegistry as c } from "@object-ui/core";
3
3
  import { SchemaRenderer as l, SchemaRendererContext as u, usePreviewMode as d, useRecordContext as f, useSafeFieldLabel as p, useSchemaContext as m } from "@object-ui/react";
4
4
  import { LineItemsField as h, buildValidationRules as g, formatFileSize as _, mapFieldTypeToFormType as v } from "@object-ui/fields";
5
- import { AlertDialog as y, AlertDialogAction as b, AlertDialogCancel as x, AlertDialogContent as S, AlertDialogDescription as C, AlertDialogFooter as w, AlertDialogHeader as T, AlertDialogTitle as E, Button as D, Card as O, CardContent as k, CardDescription as A, CardHeader as j, CardTitle as M, Dialog as N, DialogDescription as P, DialogHeader as F, DialogTitle as I, MobileDialogContent as ee, ResizableHandle as L, ResizablePanel as R, ResizablePanelGroup as z, Sheet as B, SheetContent as V, SheetDescription as te, SheetHeader as H, SheetTitle as ne, Skeleton as U, Tabs as W, TabsContent as re, TabsList as ie, TabsTrigger as ae, cn as G, toast as K, useIsMobile as oe } from "@object-ui/components";
5
+ import { AlertDialog as y, AlertDialogAction as b, AlertDialogCancel as x, AlertDialogContent as S, AlertDialogDescription as C, AlertDialogFooter as w, AlertDialogHeader as T, AlertDialogTitle as E, Button as D, Card as O, CardContent as k, CardDescription as A, CardHeader as j, CardTitle as M, Dialog as N, DialogDescription as P, DialogHeader as F, DialogTitle as ee, MobileDialogContent as I, ResizableHandle as L, ResizablePanel as R, ResizablePanelGroup as z, Sheet as B, SheetContent as V, SheetDescription as H, SheetHeader as te, SheetTitle as ne, Skeleton as U, Tabs as W, TabsContent as re, TabsList as ie, TabsTrigger as ae, cn as G, toast as K, useIsMobile as oe } from "@object-ui/components";
6
6
  import { usePermissions as se } from "@object-ui/permissions";
7
7
  import { Check as ce, CheckCircle2 as le, ChevronDown as q, ChevronLeft as ue, ChevronRight as de, Loader2 as fe, Lock as pe, ShieldCheck as me } from "lucide-react";
8
8
  import { Fragment as J, jsx as Y, jsxs as X } from "react/jsx-runtime";
@@ -44,7 +44,7 @@ var ve = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, co
44
44
  }), /* @__PURE__ */ X("div", {
45
45
  className: "flex-1",
46
46
  children: [e && /* @__PURE__ */ Y("h3", {
47
- className: "text-base font-semibold text-foreground",
47
+ className: "text-sm font-semibold text-foreground",
48
48
  children: e
49
49
  }), t && /* @__PURE__ */ Y("p", {
50
50
  className: "text-sm text-muted-foreground mt-0.5",
@@ -56,25 +56,14 @@ var ve = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, co
56
56
  children: a
57
57
  });
58
58
  return m ? /* @__PURE__ */ X(O, {
59
- className: G("form-section", o),
60
- children: [h && /* @__PURE__ */ X(j, {
61
- className: "pb-3",
62
- children: [
63
- e && /* @__PURE__ */ Y(M, {
64
- className: "text-base",
65
- children: e
66
- }),
67
- t && /* @__PURE__ */ Y(A, { children: t }),
68
- n && /* @__PURE__ */ Y("button", {
69
- type: "button",
70
- className: "absolute right-4 top-4 text-muted-foreground",
71
- onClick: p,
72
- "aria-expanded": !u,
73
- "aria-label": u ? "Expand section" : "Collapse section",
74
- children: Y(u ? de : q, { className: "h-4 w-4" })
75
- })
76
- ]
77
- }), g && /* @__PURE__ */ Y(k, { children: g })]
59
+ className: G("form-section bg-muted/40 shadow-none", o),
60
+ children: [h && /* @__PURE__ */ Y(j, {
61
+ className: "border-b border-border pb-3",
62
+ children: h
63
+ }), g && /* @__PURE__ */ Y(k, {
64
+ className: "pt-4",
65
+ children: g
66
+ })]
78
67
  }) : /* @__PURE__ */ X("div", {
79
68
  className: G("form-section", o),
80
69
  children: [h, g]
@@ -271,7 +260,8 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
271
260
  return;
272
261
  }
273
262
  try {
274
- c(await r.getObjectSchema(n.objectName));
263
+ let e = await r.getObjectSchema(n.objectName);
264
+ c(e);
275
265
  } catch (e) {
276
266
  g(e);
277
267
  }
@@ -283,7 +273,8 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
283
273
  return;
284
274
  }
285
275
  try {
286
- d(await r.findOne(n.objectName, n.recordId) || {});
276
+ let e = await r.findOne(n.objectName, n.recordId);
277
+ d(e || {});
287
278
  } catch (e) {
288
279
  g(e);
289
280
  } finally {
@@ -373,6 +364,8 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
373
364
  children: /* @__PURE__ */ Y(ve, {
374
365
  description: e.description,
375
366
  columns: 1,
367
+ className: e.className,
368
+ gridClassName: e.gridClassName,
376
369
  children: /* @__PURE__ */ Y(l, { schema: {
377
370
  ...C,
378
371
  ...Le(y(e), e.columns || 1),
@@ -385,7 +378,7 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
385
378
  })
386
379
  });
387
380
  }, Ve = ({ schema: n, dataSource: r, className: i }) => {
388
- let { fieldLabel: o } = p(), [c, u] = s(null), [d, f] = s({}), [m, h] = s(!0), [g, _] = s(null), [v, y] = s(0), [b, x] = s(/* @__PURE__ */ new Set()), [S, C] = s(!1), w = e.useId(), [T, E] = s(0), O = e.useRef(!1), k = n.sections.length, A = v === 0, j = v === k - 1;
381
+ let { fieldLabel: o } = p(), [c, u] = s(null), [d, f] = s({}), [m, h] = s(!0), [g, _] = s(null), [v, y] = s(0), [b, x] = s(/* @__PURE__ */ new Set()), [S, C] = s(!1), [w, T] = s(null), E = e.useId(), [O, k] = s(0), A = e.useRef(!1), j = n.sections.length, M = v === 0, N = v === j - 1;
389
382
  e.useEffect(() => {
390
383
  (async () => {
391
384
  if (!r) {
@@ -393,7 +386,8 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
393
386
  return;
394
387
  }
395
388
  try {
396
- u(await r.getObjectSchema(n.objectName));
389
+ let e = await r.getObjectSchema(n.objectName);
390
+ u(e);
397
391
  } catch (e) {
398
392
  _(e);
399
393
  }
@@ -401,11 +395,12 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
401
395
  }, [n.objectName, r]), e.useEffect(() => {
402
396
  (c || !r) && (async () => {
403
397
  if (n.mode === "create" || !n.recordId || !r) {
404
- O.current ||= (f(n.initialData || n.initialValues || {}), !0), h(!1);
398
+ A.current ||= (f(n.initialData || n.initialValues || {}), !0), h(!1);
405
399
  return;
406
400
  }
407
401
  try {
408
- f(await r.findOne(n.objectName, n.recordId) || {});
402
+ let e = await r.findOne(n.objectName, n.recordId);
403
+ f(e || {});
409
404
  } catch (e) {
410
405
  _(e);
411
406
  } finally {
@@ -421,7 +416,7 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
421
416
  r,
422
417
  n.objectName
423
418
  ]);
424
- let M = t((e) => xe(e, {
419
+ let P = t((e) => xe(e, {
425
420
  objectSchema: c,
426
421
  objectName: n.objectName,
427
422
  readOnly: n.readOnly,
@@ -433,26 +428,44 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
433
428
  n.mode,
434
429
  n.objectName,
435
430
  o
436
- ]), N = a(() => v >= 0 && v < k ? M(n.sections[v]) : [], [
431
+ ]), F = a(() => v >= 0 && v < j ? P(n.sections[v]) : [], [
437
432
  v,
438
- k,
433
+ j,
439
434
  n.sections,
440
- M
441
- ]), P = t(async (e) => {
435
+ P
436
+ ]), ee = t(async (e) => {
442
437
  let t = {
443
438
  ...d,
444
439
  ...e
445
440
  };
446
- if (f(t), x((e) => new Set(e).add(v)), j) {
441
+ if (f(t), x((e) => new Set(e).add(v)), N) {
447
442
  C(!0);
448
443
  try {
449
444
  if (!r) return n.onSuccess && await n.onSuccess(t), t;
450
445
  let e;
451
446
  if (n.mode === "create" ? e = await r.create(n.objectName, t) : n.mode === "edit" && n.recordId && (e = await r.update(n.objectName, n.recordId, t)), n.onSuccess) await n.onSuccess(e);
452
- else {
447
+ else if (n.submitBehavior) {
448
+ let e = n.submitBehavior;
449
+ switch (e.kind) {
450
+ case "redirect":
451
+ ge(e.url) && setTimeout(() => window.location.assign(e.url), e.delayMs ?? 0);
452
+ break;
453
+ case "continue":
454
+ f({}), x(/* @__PURE__ */ new Set()), y(0), k((e) => e + 1);
455
+ break;
456
+ default: {
457
+ let t = e.kind === "thank-you" && e.message ? e.message : n.successMessage || (n.mode === "create" ? "Created" : "Saved");
458
+ K.success(t), T({
459
+ title: e.kind === "thank-you" ? e.title : void 0,
460
+ message: t
461
+ });
462
+ break;
463
+ }
464
+ }
465
+ } else {
453
466
  let t = _e(n.navigateOnSuccess, e);
454
467
  if (t) return window.location.assign(t), e;
455
- K.success(n.successMessage || (n.mode === "create" ? "Created" : "Saved")), n.resetOnSuccess && n.mode === "create" && (f({}), x(/* @__PURE__ */ new Set()), y(0), E((e) => e + 1));
468
+ K.success(n.successMessage || (n.mode === "create" ? "Created" : "Saved")), n.resetOnSuccess && n.mode === "create" && (f({}), x(/* @__PURE__ */ new Set()), y(0), k((e) => e + 1));
456
469
  }
457
470
  return e;
458
471
  } catch (e) {
@@ -460,26 +473,26 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
460
473
  } finally {
461
474
  C(!1);
462
475
  }
463
- } else F(v + 1);
476
+ } else I(v + 1);
464
477
  }, [
465
478
  d,
466
479
  v,
467
- j,
480
+ N,
468
481
  n,
469
482
  r
470
- ]), F = t((e) => {
471
- e >= 0 && e < k && (y(e), n.onStepChange && n.onStepChange(e));
472
- }, [k, n]), I = t(() => {
473
- F(v - 1);
474
- }, [v, F]), ee = t(() => {
483
+ ]), I = t((e) => {
484
+ e >= 0 && e < j && (y(e), n.onStepChange && n.onStepChange(e));
485
+ }, [j, n]), L = t(() => {
486
+ I(v - 1);
487
+ }, [v, I]), R = t(() => {
475
488
  n.onCancel && n.onCancel();
476
- }, [n]), L = t((e) => {
477
- (n.allowSkip || b.has(e) || e <= v) && F(e);
489
+ }, [n]), z = t((e) => {
490
+ (n.allowSkip || b.has(e) || e <= v) && I(e);
478
491
  }, [
479
492
  n.allowSkip,
480
493
  b,
481
494
  v,
482
- F
495
+ I
483
496
  ]);
484
497
  if (g) return /* @__PURE__ */ X("div", {
485
498
  className: "p-4 border border-red-300 bg-red-50 rounded-md",
@@ -498,7 +511,20 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
498
511
  children: "Loading form..."
499
512
  })]
500
513
  });
501
- let R = n.sections[v];
514
+ if (w) return /* @__PURE__ */ Y("div", {
515
+ className: G("w-full", i, n.className),
516
+ children: /* @__PURE__ */ X("div", {
517
+ className: "rounded-md border bg-card p-8 text-center",
518
+ children: [/* @__PURE__ */ Y("h3", {
519
+ className: "text-lg font-semibold",
520
+ children: w.title ?? "Thanks!"
521
+ }), w.message && /* @__PURE__ */ Y("p", {
522
+ className: "mt-2 text-sm text-muted-foreground",
523
+ children: w.message
524
+ })]
525
+ })
526
+ });
527
+ let B = n.sections[v];
502
528
  return /* @__PURE__ */ X("div", {
503
529
  className: G("w-full", i, n.className),
504
530
  children: [
@@ -510,15 +536,15 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
510
536
  children: n.sections.map((e, t) => {
511
537
  let r = t === v, i = b.has(t), a = n.allowSkip || i || t <= v;
512
538
  return /* @__PURE__ */ X("li", {
513
- className: G("relative flex-1", t !== k - 1 && "pr-8 sm:pr-12"),
514
- children: [t !== k - 1 && /* @__PURE__ */ Y("div", {
539
+ className: G("relative flex-1", t !== j - 1 && "pr-8 sm:pr-12"),
540
+ children: [t !== j - 1 && /* @__PURE__ */ Y("div", {
515
541
  className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
516
542
  "aria-hidden": "true",
517
543
  children: /* @__PURE__ */ Y("div", { className: G("h-full", i ? "bg-primary" : "bg-muted") })
518
544
  }), /* @__PURE__ */ X("button", {
519
545
  type: "button",
520
546
  className: G("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
521
- onClick: () => L(t),
547
+ onClick: () => z(t),
522
548
  disabled: !a,
523
549
  children: [/* @__PURE__ */ Y("span", {
524
550
  className: G("flex h-6 w-6 sm:h-8 sm:w-8 items-center justify-center rounded-full text-xs sm:text-sm font-medium transition-colors", i && "bg-primary text-primary-foreground", r && !i && "border-2 border-primary bg-background text-primary", !r && !i && "border-2 border-muted bg-background text-muted-foreground"),
@@ -537,21 +563,23 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
537
563
  }),
538
564
  /* @__PURE__ */ Y("div", {
539
565
  className: "min-h-[200px]",
540
- children: R && /* @__PURE__ */ Y(ve, {
541
- label: R.label,
542
- description: R.description,
566
+ children: B && /* @__PURE__ */ Y(ve, {
567
+ label: B.label,
568
+ description: B.description,
543
569
  columns: 1,
544
- children: N.length > 0 ? /* @__PURE__ */ Y(l, { schema: {
570
+ className: B.className,
571
+ gridClassName: B.gridClassName,
572
+ children: F.length > 0 ? /* @__PURE__ */ Y(l, { schema: {
545
573
  type: "form",
546
574
  objectName: n.objectName,
547
- id: w,
548
- ...Le(N, R.columns || 1),
575
+ id: E,
576
+ ...Le(F, B.columns || 1),
549
577
  layout: "vertical",
550
578
  defaultValues: d,
551
579
  showSubmit: !1,
552
580
  showCancel: !1,
553
- onSubmit: P
554
- } }, T) : /* @__PURE__ */ Y("div", {
581
+ onSubmit: ee
582
+ } }, O) : /* @__PURE__ */ Y("div", {
555
583
  className: "text-center py-8 text-muted-foreground",
556
584
  children: "No fields configured for this step"
557
585
  })
@@ -561,7 +589,7 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
561
589
  className: "flex items-center justify-between mt-6 pt-4 border-t",
562
590
  children: [/* @__PURE__ */ Y("div", { children: n.showCancel !== !1 && /* @__PURE__ */ Y(D, {
563
591
  variant: "ghost",
564
- onClick: ee,
592
+ onClick: R,
565
593
  children: n.cancelText || "Cancel"
566
594
  }) }), /* @__PURE__ */ X("div", {
567
595
  className: "flex items-center gap-2",
@@ -572,17 +600,17 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
572
600
  "Step ",
573
601
  v + 1,
574
602
  " of ",
575
- k
603
+ j
576
604
  ]
577
605
  }),
578
- !A && /* @__PURE__ */ X(D, {
606
+ !M && /* @__PURE__ */ X(D, {
579
607
  variant: "outline",
580
- onClick: I,
608
+ onClick: L,
581
609
  children: [/* @__PURE__ */ Y(ue, { className: "h-4 w-4 mr-1" }), n.prevText || "Back"]
582
610
  }),
583
- j ? /* @__PURE__ */ X(D, {
611
+ N ? /* @__PURE__ */ X(D, {
584
612
  type: "submit",
585
- form: w,
613
+ form: E,
586
614
  disabled: S || n.mode === "view",
587
615
  children: [S && /* @__PURE__ */ Y(fe, {
588
616
  className: "mr-2 h-4 w-4 animate-spin",
@@ -590,7 +618,7 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
590
618
  }), S ? "Submitting..." : n.submitText || (n.mode === "create" ? "Create" : "Update")]
591
619
  }) : /* @__PURE__ */ X(D, {
592
620
  type: "submit",
593
- form: w,
621
+ form: E,
594
622
  children: [n.nextText || "Next", /* @__PURE__ */ Y(de, { className: "h-4 w-4 ml-1" })]
595
623
  })
596
624
  ]
@@ -607,7 +635,8 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
607
635
  return;
608
636
  }
609
637
  try {
610
- u(await n.getObjectSchema(e.objectName));
638
+ let t = await n.getObjectSchema(e.objectName);
639
+ u(t);
611
640
  } catch (e) {
612
641
  _(e), h(!1);
613
642
  }
@@ -623,7 +652,8 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
623
652
  return;
624
653
  }
625
654
  try {
626
- f(await n.findOne(e.objectName, e.recordId) || {});
655
+ let t = await n.findOne(e.objectName, e.recordId);
656
+ f(t || {});
627
657
  } catch (e) {
628
658
  _(e);
629
659
  } finally {
@@ -689,11 +719,13 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
689
719
  onSubmit: y,
690
720
  onCancel: b
691
721
  }, E = (t, n) => /* @__PURE__ */ Y("div", {
692
- className: "space-y-4 p-4",
722
+ className: "space-y-6 p-4",
693
723
  children: t.map((t, r) => /* @__PURE__ */ Y(ve, {
694
724
  label: t.label,
695
725
  description: t.description,
696
726
  columns: 1,
727
+ className: t.className,
728
+ gridClassName: t.gridClassName,
697
729
  children: /* @__PURE__ */ Y(l, { schema: {
698
730
  ...T,
699
731
  ...Le(v(t), t.columns || 1),
@@ -1349,7 +1381,7 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1349
1381
  ...n,
1350
1382
  rows: t
1351
1383
  } : n));
1352
- }, []), E = e.taxRateField || "tax_rate", [A, N] = s(null), P = A ? m[A.detailIdx]?.rows?.[A.rowIdx] : void 0, F = A ? p[A.detailIdx] : void 0, I = t((e, t, n) => {
1384
+ }, []), E = e.taxRateField || "tax_rate", [A, N] = s(null), P = A ? m[A.detailIdx]?.rows?.[A.rowIdx] : void 0, F = A ? p[A.detailIdx] : void 0, ee = t((e, t, n) => {
1353
1385
  h((r) => r.map((r, i) => i === e ? {
1354
1386
  ...r,
1355
1387
  rows: r.rows.map((e, r) => r === t ? {
@@ -1357,15 +1389,15 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1357
1389
  ...n
1358
1390
  } : e)
1359
1391
  } : r));
1360
- }, []), ee = t((e) => {
1392
+ }, []), I = t((e) => {
1361
1393
  h((t) => {
1362
1394
  let n = t.map((t, n) => n === e ? {
1363
1395
  ...t,
1364
1396
  rows: [...t.rows, {}]
1365
- } : t);
1397
+ } : t), r = n[e].rows.length - 1;
1366
1398
  return N({
1367
1399
  detailIdx: e,
1368
- rowIdx: n[e].rows.length - 1,
1400
+ rowIdx: r,
1369
1401
  isNew: !0
1370
1402
  }), n;
1371
1403
  });
@@ -1375,7 +1407,7 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1375
1407
  rows: t.rows.filter((t, n) => n !== e.rowIdx)
1376
1408
  } : t)), null));
1377
1409
  }, []), R = t(async (t) => {
1378
- w(), K.success(l ? e.title ? `${e.title} saved` : "Saved" : "Created"), l || (h(p.map(() => ({
1410
+ w(), e.onSuccess || K.success(l ? e.title ? `${e.title} saved` : "Saved" : "Created"), l || (h(p.map(() => ({
1379
1411
  rows: [],
1380
1412
  original: []
1381
1413
  }))), y((e) => e + 1)), await e.onSuccess?.(t);
@@ -1426,7 +1458,7 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1426
1458
  B,
1427
1459
  e,
1428
1460
  R
1429
- ]), te = typeof n?.batchTransaction == "function", H = t(async (t) => {
1461
+ ]), H = typeof n?.batchTransaction == "function", te = t(async (t) => {
1430
1462
  let r = n, i = { ...t };
1431
1463
  p.forEach((e, t) => {
1432
1464
  e.totalField && (i[e.totalField] = Qe(g.current[t]?.rows ?? [], e.amountField || "amount"));
@@ -1466,16 +1498,16 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1466
1498
  title: e.title,
1467
1499
  showSubmit: !1,
1468
1500
  showCancel: !1,
1469
- ...te ? {
1470
- submitHandler: H,
1501
+ ...H ? {
1502
+ submitHandler: te,
1471
1503
  onSuccess: R
1472
1504
  } : { onSuccess: V },
1473
1505
  onError: z
1474
1506
  }), [
1475
1507
  e,
1476
1508
  V,
1477
- te,
1478
1509
  H,
1510
+ te,
1479
1511
  R,
1480
1512
  z
1481
1513
  ]), U = o(null), W = e.submitText ?? (l ? "Save" : "Create"), re = t(() => {
@@ -1506,7 +1538,7 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1506
1538
  detailIdx: e,
1507
1539
  rowIdx: t
1508
1540
  }),
1509
- onAddViaForm: ee
1541
+ onAddViaForm: I
1510
1542
  }),
1511
1543
  A && F && /* @__PURE__ */ X(O, {
1512
1544
  className: "border-primary/40 shadow-none ring-1 ring-primary/10",
@@ -1538,7 +1570,7 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1538
1570
  submitText: "Apply",
1539
1571
  submitHandler: async (e) => e,
1540
1572
  onSuccess: (e) => {
1541
- I(A.detailIdx, A.rowIdx, e), N(null);
1573
+ ee(A.detailIdx, A.rowIdx, e), N(null);
1542
1574
  },
1543
1575
  onCancel: L
1544
1576
  },
@@ -1553,7 +1585,7 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1553
1585
  onClick: e.onCancel,
1554
1586
  disabled: b,
1555
1587
  "data-testid": "md-form-cancel",
1556
- children: "Cancel"
1588
+ children: e.cancelText ?? "Cancel"
1557
1589
  }), /* @__PURE__ */ Y(D, {
1558
1590
  type: "button",
1559
1591
  onClick: re,
@@ -1575,7 +1607,7 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1575
1607
  "form.keepEditing": "Keep editing",
1576
1608
  "form.discard": "Discard"
1577
1609
  }, "form.discardTitle"), Tt = ({ schema: e, dataSource: n, className: c }) => {
1578
- let { fieldLabel: u } = p(), { t: f } = wt(), m = d(), [h, _] = s(null), [O, k] = s([]), [A, j] = s({}), [M, N] = s(!0), [P, F] = s(null), [I, ee] = s(!1), [L, R] = s(!1), [z, U] = s(!1), W = o(!1), re = e.confirmOnDiscard !== !1, ie = e.open !== !1, ae = e.drawerSide || "right", K = i(), [oe, se] = s(() => {
1610
+ let { fieldLabel: u } = p(), { t: f } = wt(), m = d(), [h, _] = s(null), [O, k] = s([]), [A, j] = s({}), [M, N] = s(!0), [P, F] = s(null), [ee, I] = s(!1), [L, R] = s(!1), [z, U] = s(!1), W = o(!1), re = e.confirmOnDiscard !== !1, ie = e.open !== !1, ae = e.drawerSide || "right", K = i(), [oe, se] = s(() => {
1579
1611
  let t = {};
1580
1612
  return e.sections?.forEach((e, n) => {
1581
1613
  let r = e.name || String(n);
@@ -1589,7 +1621,8 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1589
1621
  return;
1590
1622
  }
1591
1623
  try {
1592
- _(await n.getObjectSchema(e.objectName));
1624
+ let t = await n.getObjectSchema(e.objectName);
1625
+ _(t);
1593
1626
  } catch (e) {
1594
1627
  F(e), N(!1);
1595
1628
  }
@@ -1605,7 +1638,8 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1605
1638
  return;
1606
1639
  }
1607
1640
  try {
1608
- j(await n.findOne(e.objectName, e.recordId) || {});
1641
+ let t = await n.findOne(e.objectName, e.recordId);
1642
+ j(t || {});
1609
1643
  } catch (e) {
1610
1644
  F(e);
1611
1645
  } finally {
@@ -1692,10 +1726,10 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1692
1726
  ]), q = t(() => {
1693
1727
  R(!1), W.current && (W.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
1694
1728
  }, [e]), ue = t((e) => {
1695
- W.current = e, re && I ? R(!0) : q();
1729
+ W.current = e, re && ee ? R(!0) : q();
1696
1730
  }, [
1697
1731
  re,
1698
- I,
1732
+ ee,
1699
1733
  q
1700
1734
  ]), de = t(() => {
1701
1735
  W.current = !0, q();
@@ -1718,7 +1752,7 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1718
1752
  showCancel: Z,
1719
1753
  onSubmit: le,
1720
1754
  onCancel: de,
1721
- onDirtyChange: ee,
1755
+ onDirtyChange: I,
1722
1756
  showActions: !1,
1723
1757
  id: K
1724
1758
  }, ve = () => {
@@ -1753,7 +1787,8 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1753
1787
  onToggle: e.collapsible ? () => se((e) => ({
1754
1788
  ...e,
1755
1789
  [r]: !i
1756
- })) : void 0
1790
+ })) : void 0,
1791
+ className: e.className
1757
1792
  });
1758
1793
  let a = ce(e);
1759
1794
  i ? t.push(...a.map((e) => ({
@@ -1781,6 +1816,7 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1781
1816
  fields: e.fields,
1782
1817
  sections: e.sections,
1783
1818
  submitText: e.submitText,
1819
+ cancelText: ge,
1784
1820
  details: Q,
1785
1821
  onSuccess: async (t) => {
1786
1822
  await e.onSuccess?.(t), e.onOpenChange?.(!1);
@@ -1816,7 +1852,7 @@ var xt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
1816
1852
  className: G("overflow-y-auto", c, e.className),
1817
1853
  style: pe,
1818
1854
  children: [
1819
- (e.title || e.description) && /* @__PURE__ */ X(H, { children: [e.title && /* @__PURE__ */ Y(ne, { children: e.title }), e.description ? /* @__PURE__ */ Y(te, { children: e.description }) : /* @__PURE__ */ Y(te, {
1855
+ (e.title || e.description) && /* @__PURE__ */ X(te, { children: [e.title && /* @__PURE__ */ Y(ne, { children: e.title }), e.description ? /* @__PURE__ */ Y(H, { children: e.description }) : /* @__PURE__ */ Y(H, {
1820
1856
  className: "sr-only",
1821
1857
  children: "Complete the form fields, then submit or cancel."
1822
1858
  })] }),
@@ -1916,7 +1952,7 @@ var Dt = Z({
1916
1952
  _,
1917
1953
  e.objectName,
1918
1954
  e.mode
1919
- ]), [k, A] = s(null), [j, M] = s([]), [L, R] = s({}), [z, B] = s(!0), [V, te] = s(null), [H, ne] = s(!1), [K, oe] = s(!1), [ce, le] = s(!1), q = o(!1), ue = e.confirmOnDiscard !== !1, de = e.open !== !1, pe = i(), me = a(() => {
1955
+ ]), [k, A] = s(null), [j, M] = s([]), [L, R] = s({}), [z, B] = s(!0), [V, H] = s(null), [te, ne] = s(!1), [K, oe] = s(!1), [ce, le] = s(!1), q = o(!1), ue = e.confirmOnDiscard !== !1, de = e.open !== !1, pe = i(), me = a(() => {
1920
1956
  if (e.sections?.length || e.customFields?.length) return null;
1921
1957
  let t = Me(j, k);
1922
1958
  e.mode === "create" && (t = Pe(t, k));
@@ -1961,9 +1997,10 @@ var Dt = Z({
1961
1997
  return;
1962
1998
  }
1963
1999
  try {
1964
- A(await n.getObjectSchema(e.objectName));
2000
+ let t = await n.getObjectSchema(e.objectName);
2001
+ A(t);
1965
2002
  } catch (e) {
1966
- te(e), B(!1);
2003
+ H(e), B(!1);
1967
2004
  }
1968
2005
  })();
1969
2006
  }, [e.objectName, n]), r(() => {
@@ -1977,9 +2014,10 @@ var Dt = Z({
1977
2014
  return;
1978
2015
  }
1979
2016
  try {
1980
- R(await n.findOne(e.objectName, e.recordId) || {});
2017
+ let t = await n.findOne(e.objectName, e.recordId);
2018
+ R(t || {});
1981
2019
  } catch (e) {
1982
- te(e);
2020
+ H(e);
1983
2021
  } finally {
1984
2022
  B(!1);
1985
2023
  }
@@ -2137,6 +2175,8 @@ var Dt = Z({
2137
2175
  children: /* @__PURE__ */ Y(ve, {
2138
2176
  description: e.description,
2139
2177
  columns: 1,
2178
+ className: e.className,
2179
+ gridClassName: e.gridClassName,
2140
2180
  children: i(e)
2141
2181
  })
2142
2182
  }, n(e, t)))]
@@ -2146,6 +2186,8 @@ var Dt = Z({
2146
2186
  label: r(e),
2147
2187
  description: e.description,
2148
2188
  columns: 1,
2189
+ className: e.className,
2190
+ gridClassName: e.gridClassName,
2149
2191
  children: i(e)
2150
2192
  }, n(e, t)))
2151
2193
  });
@@ -2194,11 +2236,11 @@ var Dt = Z({
2194
2236
  if (je?.length && e.mode !== "view") return /* @__PURE__ */ Y(N, {
2195
2237
  open: de,
2196
2238
  onOpenChange: e.onOpenChange,
2197
- children: /* @__PURE__ */ X(ee, {
2239
+ children: /* @__PURE__ */ X(I, {
2198
2240
  className: G(he, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", c, e.className),
2199
2241
  children: [(e.title || e.description) && /* @__PURE__ */ X(F, {
2200
2242
  className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
2201
- children: [e.title && /* @__PURE__ */ Y(I, { children: e.title }), e.description ? /* @__PURE__ */ Y(P, { children: e.description }) : /* @__PURE__ */ Y(P, {
2243
+ children: [e.title && /* @__PURE__ */ Y(ee, { children: e.title }), e.description ? /* @__PURE__ */ Y(P, { children: e.description }) : /* @__PURE__ */ Y(P, {
2202
2244
  className: "sr-only",
2203
2245
  children: "Enter the record and its line items, then save."
2204
2246
  })]
@@ -2212,7 +2254,10 @@ var Dt = Z({
2212
2254
  recordId: e.recordId,
2213
2255
  fields: e.fields,
2214
2256
  sections: e.sections,
2257
+ initialValues: e.initialValues,
2258
+ initialData: e.initialData,
2215
2259
  submitText: Te,
2260
+ cancelText: Ee,
2216
2261
  details: je,
2217
2262
  onSuccess: async (t) => {
2218
2263
  await e.onSuccess?.(t), e.onOpenChange?.(!1);
@@ -2235,12 +2280,12 @@ var Dt = Z({
2235
2280
  }
2236
2281
  ye(!1);
2237
2282
  },
2238
- children: /* @__PURE__ */ X(ee, {
2283
+ children: /* @__PURE__ */ X(I, {
2239
2284
  className: G(he, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", c, e.className),
2240
2285
  children: [
2241
2286
  (e.title || e.description) && /* @__PURE__ */ X(F, {
2242
2287
  className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
2243
- children: [e.title && /* @__PURE__ */ Y(I, { children: e.title }), e.description ? /* @__PURE__ */ Y(P, { children: e.description }) : /* @__PURE__ */ Y(P, {
2288
+ children: [e.title && /* @__PURE__ */ Y(ee, { children: e.title }), e.description ? /* @__PURE__ */ Y(P, { children: e.description }) : /* @__PURE__ */ Y(P, {
2244
2289
  className: "sr-only",
2245
2290
  children: "Complete the form fields, then submit or cancel."
2246
2291
  })]
@@ -2258,15 +2303,15 @@ var Dt = Z({
2258
2303
  type: "button",
2259
2304
  variant: "outline",
2260
2305
  onClick: be,
2261
- disabled: H,
2306
+ disabled: te,
2262
2307
  className: "w-full sm:w-auto",
2263
2308
  children: Ee
2264
2309
  }), Ce && /* @__PURE__ */ X(D, {
2265
2310
  type: "submit",
2266
2311
  form: pe,
2267
- disabled: H,
2312
+ disabled: te,
2268
2313
  className: "w-full sm:w-auto",
2269
- children: [H && /* @__PURE__ */ Y(fe, { className: "mr-2 h-4 w-4 animate-spin" }), Te]
2314
+ children: [te && /* @__PURE__ */ Y(fe, { className: "mr-2 h-4 w-4 animate-spin" }), Te]
2270
2315
  })]
2271
2316
  })
2272
2317
  }),
@@ -2316,6 +2361,7 @@ var Dt = Z({
2316
2361
  fields: r.fields,
2317
2362
  title: r.title,
2318
2363
  submitText: r.submitText,
2364
+ cancelText: r.cancelText,
2319
2365
  showSubmit: r.showSubmit,
2320
2366
  details: r.subforms,
2321
2367
  onSuccess: r.onSuccess,
@@ -2334,7 +2380,9 @@ var Dt = Z({
2334
2380
  label: o(e),
2335
2381
  description: e.description,
2336
2382
  columns: e.columns,
2337
- fields: e.fields
2383
+ fields: e.fields,
2384
+ className: e.className,
2385
+ gridClassName: e.gridClassName
2338
2386
  })),
2339
2387
  defaultTab: r.defaultTab,
2340
2388
  tabPosition: r.tabPosition
@@ -2351,7 +2399,9 @@ var Dt = Z({
2351
2399
  label: o(e),
2352
2400
  description: e.description,
2353
2401
  columns: e.columns,
2354
- fields: e.fields
2402
+ fields: e.fields,
2403
+ className: e.className,
2404
+ gridClassName: e.gridClassName
2355
2405
  })),
2356
2406
  allowSkip: r.allowSkip,
2357
2407
  showStepIndicator: r.showStepIndicator,
@@ -2371,7 +2421,9 @@ var Dt = Z({
2371
2421
  label: o(e),
2372
2422
  description: e.description,
2373
2423
  columns: e.columns,
2374
- fields: e.fields
2424
+ fields: e.fields,
2425
+ className: e.className,
2426
+ gridClassName: e.gridClassName
2375
2427
  })),
2376
2428
  splitDirection: r.splitDirection,
2377
2429
  splitSize: r.splitSize,
@@ -2394,7 +2446,8 @@ var Dt = Z({
2394
2446
  columns: e.columns,
2395
2447
  fields: e.fields,
2396
2448
  collapsible: e.collapsible,
2397
- collapsed: e.collapsed
2449
+ collapsed: e.collapsed,
2450
+ className: e.className
2398
2451
  })),
2399
2452
  open: r.open,
2400
2453
  onOpenChange: r.onOpenChange,
@@ -2417,7 +2470,9 @@ var Dt = Z({
2417
2470
  label: o(e),
2418
2471
  description: e.description,
2419
2472
  columns: e.columns,
2420
- fields: e.fields
2473
+ fields: e.fields,
2474
+ className: e.className,
2475
+ gridClassName: e.gridClassName
2421
2476
  })),
2422
2477
  open: r.open,
2423
2478
  onOpenChange: r.onOpenChange,
@@ -2447,15 +2502,15 @@ var Dt = Z({
2447
2502
  u,
2448
2503
  n.objectName,
2449
2504
  n.mode
2450
- ]), [f, m] = s(null), [h, y] = s([]), [b, x] = s(null), [S, C] = s(!0), [w, T] = s(null), E = n.customFields && n.customFields.length > 0;
2505
+ ]), [f, m] = s(null), [h, y] = s([]), [b, x] = s(null), [S, C] = s(!0), [w, T] = s(null), [E, D] = s(null), O = n.customFields && n.customFields.length > 0;
2451
2506
  r(() => {
2452
- E && (x(n.initialData || n.initialValues || {}), C(!1));
2507
+ O && (x(n.initialData || n.initialValues || {}), C(!1));
2453
2508
  }, [
2454
- E,
2509
+ O,
2455
2510
  n.initialData,
2456
2511
  n.initialValues
2457
2512
  ]), r(() => {
2458
- E ? m({
2513
+ O ? m({
2459
2514
  name: n.objectName,
2460
2515
  fields: {}
2461
2516
  }) : n.objectName && i ? (async () => {
@@ -2467,25 +2522,26 @@ var Dt = Z({
2467
2522
  } catch (e) {
2468
2523
  T(e), C(!1);
2469
2524
  }
2470
- })() : E || C(!1);
2525
+ })() : O || C(!1);
2471
2526
  }, [
2472
2527
  n.objectName,
2473
2528
  i,
2474
- E
2529
+ O
2475
2530
  ]), r(() => {
2476
- f && !E && (async () => {
2531
+ f && !O && (async () => {
2477
2532
  if (!n.recordId || n.mode === "create") {
2478
2533
  x(n.initialData || n.initialValues || {}), C(!1);
2479
2534
  return;
2480
2535
  }
2481
- if (!E) {
2536
+ if (!O) {
2482
2537
  if (!i) {
2483
2538
  T(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), C(!1);
2484
2539
  return;
2485
2540
  }
2486
2541
  C(!0);
2487
2542
  try {
2488
- x(await i.findOne(n.objectName, n.recordId));
2543
+ let e = await i.findOne(n.objectName, n.recordId);
2544
+ x(e);
2489
2545
  } catch (e) {
2490
2546
  console.error("Failed to fetch record:", e), T(e);
2491
2547
  } finally {
@@ -2501,12 +2557,12 @@ var Dt = Z({
2501
2557
  n.initialData,
2502
2558
  i,
2503
2559
  f,
2504
- E
2560
+ O
2505
2561
  ]);
2506
- let D = t((e) => e, []);
2562
+ let k = t((e) => e, []);
2507
2563
  r(() => {
2508
- if (E && n.customFields) {
2509
- y(n.customFields.map(D)), C(!1);
2564
+ if (O && n.customFields) {
2565
+ y(n.customFields.map(k)), C(!1);
2510
2566
  return;
2511
2567
  }
2512
2568
  if (!f) return;
@@ -2515,11 +2571,11 @@ var Dt = Z({
2515
2571
  let r = typeof t == "string" ? t : t.name;
2516
2572
  if (!r) return;
2517
2573
  let i = f.fields?.[r];
2518
- if (!i && !E) return;
2574
+ if (!i && !O) return;
2519
2575
  let o = !i?.permissions || i?.permissions.write !== !1;
2520
2576
  if (n.mode !== "view" && !o) return;
2521
2577
  let s = n.customFields?.find((e) => e.name === r);
2522
- if (s) e.push(D(s));
2578
+ if (s) e.push(k(s));
2523
2579
  else if (i) {
2524
2580
  let o = {
2525
2581
  name: r,
@@ -2542,21 +2598,21 @@ var Dt = Z({
2542
2598
  }
2543
2599
  i.type === "email" && (o.inputType = "email"), i.type === "phone" && (o.inputType = "tel"), i.type === "url" && (o.inputType = "url"), i.type === "password" && (o.inputType = "password"), i.type === "time" && (o.inputType = "time"), (i.type === "formula" || i.type === "summary" || i.type === "auto_number") && (o.disabled = !0), i.visible_on && (o.visibleOn = i.visible_on), e.push(o);
2544
2600
  }
2545
- }), y(e), !E && n.recordId && n.mode !== "create" && i || C(!1);
2601
+ }), y(e), !O && n.recordId && n.mode !== "create" && i || C(!1);
2546
2602
  }, [
2547
2603
  f,
2548
2604
  n.fields,
2549
2605
  n.customFields,
2550
2606
  n.readOnly,
2551
2607
  n.mode,
2552
- E,
2608
+ O,
2553
2609
  n.recordId,
2554
2610
  i
2555
2611
  ]);
2556
- let O = t(async (e, t) => {
2557
- if (e && (e.nativeEvent || e._reactName === "onSubmit") && (console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."), t === void 0 && (e = {})), E && !i) return n.onSuccess && await n.onSuccess(e), e;
2612
+ let A = t(async (e, t) => {
2613
+ if (e && (e.nativeEvent || e._reactName === "onSubmit") && (console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."), t === void 0 && (e = {})), O && !i) return n.onSuccess && await n.onSuccess(e), e;
2558
2614
  if (!i) throw Error("DataSource is required for form submission (inline mode not configured)");
2559
- let r = Ge(e, E ? null : f);
2615
+ let r = Ge(e, O ? null : f);
2560
2616
  if (u?.isLoaded && r && typeof r == "object") {
2561
2617
  let e = {};
2562
2618
  for (let t of Object.keys(r)) u.checkField(n.objectName, t, "write") && (e[t] = r[t]);
@@ -2569,7 +2625,23 @@ var Dt = Z({
2569
2625
  else if (n.mode === "edit" && n.recordId) e = await i.update(n.objectName, n.recordId, r);
2570
2626
  else throw Error("Invalid form mode or missing record ID");
2571
2627
  if (n.onSuccess) await n.onSuccess(e);
2572
- else if (!n.submitHandler) {
2628
+ else if (!n.submitHandler && n.submitBehavior) {
2629
+ let e = n.submitBehavior;
2630
+ switch (e.kind) {
2631
+ case "redirect":
2632
+ ge(e.url) && setTimeout(() => window.location.assign(e.url), e.delayMs ?? 0);
2633
+ break;
2634
+ case "continue": break;
2635
+ default: {
2636
+ let t = e.kind === "thank-you" && e.message ? e.message : n.successMessage || (n.mode === "create" ? "Created" : "Saved");
2637
+ K.success(t), D({
2638
+ title: e.kind === "thank-you" ? e.title : void 0,
2639
+ message: t
2640
+ });
2641
+ break;
2642
+ }
2643
+ }
2644
+ } else if (!n.submitHandler) {
2573
2645
  let t = _e(n.navigateOnSuccess, e);
2574
2646
  if (t) return window.location.assign(t), e;
2575
2647
  K.success(n.successMessage || (n.mode === "create" ? "Created" : "Saved"));
@@ -2581,12 +2653,12 @@ var Dt = Z({
2581
2653
  }, [
2582
2654
  n,
2583
2655
  i,
2584
- E,
2656
+ O,
2585
2657
  u,
2586
2658
  f
2587
- ]), k = t(() => {
2659
+ ]), j = t(() => {
2588
2660
  n.onCancel && n.onCancel();
2589
- }, [n]), A = {
2661
+ }, [n]), M = {
2590
2662
  ...e.useMemo(() => {
2591
2663
  if (!f?.fields) return {};
2592
2664
  let e = {};
@@ -2596,18 +2668,18 @@ var Dt = Z({
2596
2668
  }), e;
2597
2669
  }, [f]),
2598
2670
  ...b
2599
- }, j = e.useMemo(() => {
2671
+ }, N = e.useMemo(() => {
2600
2672
  let e = Me(h, f);
2601
2673
  return n.mode === "create" && (e = Pe(e, f)), e;
2602
2674
  }, [
2603
2675
  h,
2604
2676
  f,
2605
2677
  n.mode
2606
- ]), M = e.useMemo(() => n.sections?.length ? null : Et(j, f?.fieldGroups), [
2678
+ ]), P = e.useMemo(() => n.sections?.length ? null : Et(N, f?.fieldGroups), [
2607
2679
  n.sections,
2608
- j,
2680
+ N,
2609
2681
  f
2610
- ]), N = n.sections?.length ? n.sections : M, [P, F] = s({});
2682
+ ]), F = n.sections?.length ? n.sections : P, [ee, I] = s({});
2611
2683
  if (w) return /* @__PURE__ */ X("div", {
2612
2684
  className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
2613
2685
  children: [/* @__PURE__ */ Y("h3", {
@@ -2625,10 +2697,20 @@ var Dt = Z({
2625
2697
  children: "Loading form..."
2626
2698
  })]
2627
2699
  });
2628
- let I = n.layout === "vertical" || n.layout === "horizontal" ? n.layout : "vertical";
2629
- if (N?.length && (!n.formType || n.formType === "simple")) {
2630
- let e = M ? j : h, t = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, r = N.map((e) => t(e.columns)).filter((e) => e != null), i = N.reduce((e, t) => e + (Array.isArray(t.fields) ? t.fields.length : 0), 0), a = t(n.columns) ?? (r.length ? Math.max(...r) : De(i)), s = [];
2631
- N.forEach((r, i) => {
2700
+ if (E) return /* @__PURE__ */ X("div", {
2701
+ className: "rounded-md border bg-card p-6 sm:p-8 text-center",
2702
+ children: [/* @__PURE__ */ Y("h3", {
2703
+ className: "text-lg font-semibold",
2704
+ children: E.title ?? "Thanks!"
2705
+ }), E.message && /* @__PURE__ */ Y("p", {
2706
+ className: "mt-2 text-sm text-muted-foreground",
2707
+ children: E.message
2708
+ })]
2709
+ });
2710
+ let L = n.layout === "vertical" || n.layout === "horizontal" ? n.layout : "vertical";
2711
+ if (F?.length && (!n.formType || n.formType === "simple")) {
2712
+ let e = P ? N : h, t = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, r = F.map((e) => t(e.columns)).filter((e) => e != null), i = F.reduce((e, t) => e + (Array.isArray(t.fields) ? t.fields.length : 0), 0), a = t(n.columns) ?? (r.length ? Math.max(...r) : De(i)), s = [];
2713
+ F.forEach((r, i) => {
2632
2714
  let c = new Map(r.fields.map((e) => [typeof e == "string" ? e : e.field ?? e.name, e])), l = Array.from(c.keys()), u = d(e.filter((e) => l.includes(e.name))).map((e) => {
2633
2715
  let t = c.get(e.name);
2634
2716
  if (!t || typeof t != "object") return e;
@@ -2636,7 +2718,7 @@ var Dt = Z({
2636
2718
  return n.visibleOn != null && (r.visibleOn = n.visibleOn), n.colSpan != null && (r.colSpan = n.colSpan), n.span != null && (r.span = n.span), r;
2637
2719
  });
2638
2720
  if (u.length === 0) return;
2639
- let f = r.name || r.label || String(i), p = r.name ? o(n.objectName, r.name, r.label || r.name) : r.label, m = P[f] ?? r.collapsed ?? !1;
2721
+ let f = r.name || r.label || String(i), p = r.name ? o(n.objectName, r.name, r.label || r.name) : r.label, m = ee[f] ?? r.collapsed ?? !1;
2640
2722
  p && s.push({
2641
2723
  name: `__section_${f}`,
2642
2724
  label: p,
@@ -2644,10 +2726,11 @@ var Dt = Z({
2644
2726
  colSpan: 4,
2645
2727
  collapsible: r.collapsible,
2646
2728
  collapsed: m,
2647
- onToggle: r.collapsible ? () => F((e) => ({
2729
+ onToggle: r.collapsible ? () => I((e) => ({
2648
2730
  ...e,
2649
2731
  [f]: !m
2650
- })) : void 0
2732
+ })) : void 0,
2733
+ className: r.className
2651
2734
  });
2652
2735
  let h = t(r.columns), g = a > 1 ? Ae(u, a, h) : u;
2653
2736
  p && m ? s.push(...g.map((e) => ({
@@ -2662,36 +2745,36 @@ var Dt = Z({
2662
2745
  type: "form",
2663
2746
  objectName: n.objectName,
2664
2747
  fields: c,
2665
- layout: I,
2748
+ layout: L,
2666
2749
  columns: a,
2667
2750
  ...u ? { fieldContainerClass: u } : {},
2668
- defaultValues: A,
2751
+ defaultValues: M,
2669
2752
  showSubmit: n.showSubmit !== !1 && n.mode !== "view",
2670
2753
  showCancel: n.showCancel !== !1,
2671
2754
  submitLabel: n.submitText || (n.mode === "create" ? "Create" : "Update"),
2672
2755
  cancelLabel: n.cancelText,
2673
- onSubmit: O,
2674
- onCancel: k
2756
+ onSubmit: A,
2757
+ onCancel: j
2675
2758
  } })
2676
2759
  });
2677
2760
  }
2678
- let ee = n.sections?.length, L = d(h), R = ee ? {
2679
- fields: L,
2761
+ let R = n.sections?.length, z = d(h), B = R ? {
2762
+ fields: z,
2680
2763
  columns: n.columns
2681
- } : ze(L, f, n.columns, n.mode), z = n.mobile, B = z?.fullscreenLongText ? R.fields.map((e) => {
2764
+ } : ze(z, f, n.columns, n.mode), V = n.mobile, H = V?.fullscreenLongText ? B.fields.map((e) => {
2682
2765
  let t = e.type;
2683
2766
  return t === "textarea" || t === "field:textarea" || t === "string-multiline" || t === "field:markdown" || t === "field:html" ? {
2684
2767
  ...e,
2685
2768
  mobile_fullscreen: !0
2686
2769
  } : e;
2687
- }) : R.fields, V = z?.stepper, te = z?.stepperMinFields ?? 8, H = Math.max(1, z?.stepperFieldsPerStep ?? 1);
2688
- if (!n.formType && !ee && B.length >= 2 && (V === !0 || V === "auto" && c && B.length >= te)) {
2689
- let e = B, t = [];
2690
- for (let n = 0; n < e.length; n += H) {
2691
- let r = e.slice(n, n + H);
2770
+ }) : B.fields, te = V?.stepper, ne = V?.stepperMinFields ?? 8, U = Math.max(1, V?.stepperFieldsPerStep ?? 1);
2771
+ if (!n.formType && !R && H.length >= 2 && (te === !0 || te === "auto" && c && H.length >= ne)) {
2772
+ let e = H, t = [];
2773
+ for (let n = 0; n < e.length; n += U) {
2774
+ let r = e.slice(n, n + U);
2692
2775
  t.push({
2693
- name: `step-${Math.floor(n / H) + 1}`,
2694
- label: r[0]?.label || r[0]?.name || `Step ${Math.floor(n / H) + 1}`,
2776
+ name: `step-${Math.floor(n / U) + 1}`,
2777
+ label: r[0]?.label || r[0]?.name || `Step ${Math.floor(n / U) + 1}`,
2695
2778
  fields: r
2696
2779
  });
2697
2780
  }
@@ -2706,27 +2789,27 @@ var Dt = Z({
2706
2789
  className: n.className
2707
2790
  });
2708
2791
  }
2709
- let ne = {
2792
+ let W = {
2710
2793
  type: "form",
2711
2794
  objectName: n.objectName,
2712
- fields: B,
2713
- layout: I,
2714
- columns: R.columns,
2795
+ fields: H,
2796
+ layout: L,
2797
+ columns: B.columns,
2715
2798
  submitLabel: n.submitText || (n.mode === "create" ? "Create" : "Update"),
2716
2799
  cancelLabel: n.cancelText,
2717
2800
  showSubmit: n.showSubmit !== !1 && n.mode !== "view",
2718
2801
  showCancel: n.showCancel !== !1,
2719
- resetOnSubmit: n.showReset || n.resetOnSuccess && n.mode === "create",
2720
- defaultValues: A,
2721
- onSubmit: O,
2722
- onCancel: k,
2802
+ resetOnSubmit: n.showReset || n.submitBehavior?.kind === "continue" || !n.submitBehavior && n.resetOnSuccess && n.mode === "create",
2803
+ defaultValues: M,
2804
+ onSubmit: A,
2805
+ onCancel: j,
2723
2806
  className: n.className,
2724
- mobileStickyActions: !!z?.stickyActions
2807
+ mobileStickyActions: !!V?.stickyActions
2725
2808
  };
2726
2809
  return /* @__PURE__ */ Y("div", {
2727
- className: z?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
2728
- "data-mobile-form": z ? "true" : void 0,
2729
- children: /* @__PURE__ */ Y(l, { schema: ne })
2810
+ className: V?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
2811
+ "data-mobile-form": V ? "true" : void 0,
2812
+ children: /* @__PURE__ */ Y(l, { schema: W })
2730
2813
  });
2731
2814
  }, Mt = {
2732
2815
  text: 200,
@@ -3531,4 +3614,4 @@ c.register("object-form", Vt, {
3531
3614
  ]
3532
3615
  });
3533
3616
  //#endregion
3534
- export { Tt as DrawerForm, Lt as EmbeddableForm, zt as FormAnalytics, ve as FormSection, Bt as LineItemsPanel, St as MasterDetailForm, kt as ModalForm, At as ObjectForm, He as SplitForm, Be as TabbedForm, Ve as WizardForm, Ae as applyAutoColSpan, ze as applyAutoLayout, dt as deriveColumns, yt as deriveDetail, mt as deriveFormFields, Pe as filterAutoGeneratedFields, Ne as filterCreateModeFields, Me as filterSystemFields, st as findRelationshipField, De as inferColumns, Re as inferModalSize, Ee as isAutoGeneratedFieldType, Te as isWideFieldType, gt as resolveInlineMode };
3617
+ export { Tt as DrawerForm, Lt as EmbeddableForm, zt as FormAnalytics, ve as FormSection, Bt as LineItemsPanel, St as MasterDetailForm, kt as ModalForm, At as ObjectForm, He as SplitForm, Be as TabbedForm, Ve as WizardForm, Ae as applyAutoColSpan, ze as applyAutoLayout, Ie as containerGridColsFor, dt as deriveColumns, yt as deriveDetail, mt as deriveFormFields, Pe as filterAutoGeneratedFields, Ne as filterCreateModeFields, Me as filterSystemFields, st as findRelationshipField, De as inferColumns, Re as inferModalSize, Ee as isAutoGeneratedFieldType, Te as isWideFieldType, gt as resolveInlineMode };