@object-ui/plugin-form 14.1.0 → 16.0.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/CHANGELOG.md +68 -0
- package/dist/deriveMasterDetail.d.ts +7 -2
- package/dist/index.js +155 -156
- package/dist/index.umd.cjs +1 -1
- package/package.json +10 -10
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 ee, MobileDialogContent as I, ResizableHandle as
|
|
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 te, ResizablePanel as L, ResizablePanelGroup as R, Sheet as z, SheetContent as B, SheetDescription as V, 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";
|
|
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";
|
|
@@ -484,11 +484,11 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
|
|
|
484
484
|
r
|
|
485
485
|
]), I = t((e) => {
|
|
486
486
|
e >= 0 && e < j && (y(e), n.onStepChange && n.onStepChange(e));
|
|
487
|
-
}, [j, n]),
|
|
487
|
+
}, [j, n]), te = t(() => {
|
|
488
488
|
I(v - 1);
|
|
489
|
-
}, [v, I]),
|
|
489
|
+
}, [v, I]), L = t(() => {
|
|
490
490
|
n.onCancel && n.onCancel();
|
|
491
|
-
}, [n]),
|
|
491
|
+
}, [n]), R = t((e) => {
|
|
492
492
|
(n.allowSkip || b.has(e) || e <= v) && I(e);
|
|
493
493
|
}, [
|
|
494
494
|
n.allowSkip,
|
|
@@ -526,7 +526,7 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
|
|
|
526
526
|
})]
|
|
527
527
|
})
|
|
528
528
|
});
|
|
529
|
-
let
|
|
529
|
+
let z = n.sections[v];
|
|
530
530
|
return /* @__PURE__ */ X("div", {
|
|
531
531
|
className: G("w-full", i, n.className),
|
|
532
532
|
children: [
|
|
@@ -546,7 +546,7 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
|
|
|
546
546
|
}), /* @__PURE__ */ X("button", {
|
|
547
547
|
type: "button",
|
|
548
548
|
className: G("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
|
|
549
|
-
onClick: () =>
|
|
549
|
+
onClick: () => R(t),
|
|
550
550
|
disabled: !a,
|
|
551
551
|
children: [/* @__PURE__ */ Y("span", {
|
|
552
552
|
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"),
|
|
@@ -565,17 +565,17 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
|
|
|
565
565
|
}),
|
|
566
566
|
/* @__PURE__ */ Y("div", {
|
|
567
567
|
className: "min-h-[200px]",
|
|
568
|
-
children:
|
|
569
|
-
label:
|
|
570
|
-
description:
|
|
568
|
+
children: z && /* @__PURE__ */ Y(ve, {
|
|
569
|
+
label: z.label,
|
|
570
|
+
description: z.description,
|
|
571
571
|
columns: 1,
|
|
572
|
-
className:
|
|
573
|
-
gridClassName:
|
|
572
|
+
className: z.className,
|
|
573
|
+
gridClassName: z.gridClassName,
|
|
574
574
|
children: F.length > 0 ? /* @__PURE__ */ Y(l, { schema: {
|
|
575
575
|
type: "form",
|
|
576
576
|
objectName: n.objectName,
|
|
577
577
|
id: E,
|
|
578
|
-
...Le(F,
|
|
578
|
+
...Le(F, z.columns || 1),
|
|
579
579
|
layout: "vertical",
|
|
580
580
|
defaultValues: d,
|
|
581
581
|
showSubmit: !1,
|
|
@@ -591,7 +591,7 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
|
|
|
591
591
|
className: "flex items-center justify-between mt-6 pt-4 border-t",
|
|
592
592
|
children: [/* @__PURE__ */ Y("div", { children: n.showCancel !== !1 && /* @__PURE__ */ Y(D, {
|
|
593
593
|
variant: "ghost",
|
|
594
|
-
onClick:
|
|
594
|
+
onClick: L,
|
|
595
595
|
children: n.cancelText || "Cancel"
|
|
596
596
|
}) }), /* @__PURE__ */ X("div", {
|
|
597
597
|
className: "flex items-center gap-2",
|
|
@@ -607,7 +607,7 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
|
|
|
607
607
|
}),
|
|
608
608
|
!M && /* @__PURE__ */ X(D, {
|
|
609
609
|
variant: "outline",
|
|
610
|
-
onClick:
|
|
610
|
+
onClick: te,
|
|
611
611
|
children: [/* @__PURE__ */ Y(ue, { className: "h-4 w-4 mr-1" }), n.prevText || "Back"]
|
|
612
612
|
}),
|
|
613
613
|
N ? /* @__PURE__ */ X(D, {
|
|
@@ -740,14 +740,14 @@ var Be = ({ schema: n, dataSource: r, className: i }) => {
|
|
|
740
740
|
});
|
|
741
741
|
return /* @__PURE__ */ Y("div", {
|
|
742
742
|
className: G("w-full", i, e.className),
|
|
743
|
-
children: /* @__PURE__ */ X(
|
|
743
|
+
children: /* @__PURE__ */ X(R, {
|
|
744
744
|
orientation: C,
|
|
745
745
|
className: "min-h-[300px] rounded-lg border",
|
|
746
|
-
children: [/* @__PURE__ */ Y(
|
|
746
|
+
children: [/* @__PURE__ */ Y(L, {
|
|
747
747
|
defaultSize: w,
|
|
748
748
|
minSize: 20,
|
|
749
749
|
children: E(x, S.length === 0)
|
|
750
|
-
}), S.length > 0 && /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(
|
|
750
|
+
}), S.length > 0 && /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(te, { withHandle: e.splitResizable !== !1 }), /* @__PURE__ */ Y(L, {
|
|
751
751
|
defaultSize: 100 - w,
|
|
752
752
|
minSize: 20,
|
|
753
753
|
children: E(S, !0)
|
|
@@ -958,8 +958,7 @@ function at(e) {
|
|
|
958
958
|
case "master_detail": return "lookup";
|
|
959
959
|
case "file":
|
|
960
960
|
case "image":
|
|
961
|
-
case "avatar":
|
|
962
|
-
case "attachment": return "file";
|
|
961
|
+
case "avatar": return "file";
|
|
963
962
|
default: return "text";
|
|
964
963
|
}
|
|
965
964
|
}
|
|
@@ -1090,20 +1089,20 @@ var _t = /* @__PURE__ */ new Set([
|
|
|
1090
1089
|
"html",
|
|
1091
1090
|
"markdown",
|
|
1092
1091
|
"rich-text",
|
|
1093
|
-
"file",
|
|
1094
|
-
"image",
|
|
1095
|
-
"avatar",
|
|
1096
|
-
"attachment",
|
|
1097
1092
|
"json",
|
|
1098
1093
|
"location",
|
|
1099
1094
|
"address"
|
|
1095
|
+
]), vt = /* @__PURE__ */ new Set([
|
|
1096
|
+
"file",
|
|
1097
|
+
"image",
|
|
1098
|
+
"avatar"
|
|
1100
1099
|
]);
|
|
1101
|
-
function
|
|
1100
|
+
function yt(e, t, n = {}) {
|
|
1102
1101
|
if (t === "grid" || t === "form") return t;
|
|
1103
1102
|
let r = e?.fields ?? {}, i = gt(e, { relationshipField: n.relationshipField });
|
|
1104
|
-
return i.some((e) => _t.has(r[e]?.type)) || i.length > 8 ? "form" : "grid";
|
|
1103
|
+
return i.some((e) => _t.has(r[e]?.type)) || i.filter((e) => vt.has(r[e]?.type)).length >= 2 || i.length > 8 ? "form" : "grid";
|
|
1105
1104
|
}
|
|
1106
|
-
var
|
|
1105
|
+
var bt = [
|
|
1107
1106
|
"amount",
|
|
1108
1107
|
"total",
|
|
1109
1108
|
"subtotal",
|
|
@@ -1111,33 +1110,33 @@ var yt = [
|
|
|
1111
1110
|
"line_amount",
|
|
1112
1111
|
"net_amount"
|
|
1113
1112
|
];
|
|
1114
|
-
function
|
|
1113
|
+
function xt(e) {
|
|
1115
1114
|
let t = e.filter((e) => e.type === "number" || e.type === "currency");
|
|
1116
1115
|
if (t.length === 0) return;
|
|
1117
1116
|
let n = t.find((e) => e.computed);
|
|
1118
1117
|
if (n) return n.field;
|
|
1119
|
-
let r = t.find((e) =>
|
|
1118
|
+
let r = t.find((e) => bt.includes(e.field));
|
|
1120
1119
|
if (r) return r.field;
|
|
1121
1120
|
let i = [...t].reverse().find((e) => e.type === "currency");
|
|
1122
1121
|
return i ? i.field : t[t.length - 1].field;
|
|
1123
1122
|
}
|
|
1124
|
-
function
|
|
1123
|
+
function St(e, t, n, r = {}) {
|
|
1125
1124
|
let i = r.relationshipField || lt(t, n);
|
|
1126
1125
|
if (!i) throw Error(`MasterDetailForm: could not find a lookup/master_detail field on "${e}" referencing "${n}". Set relationshipField explicitly.`);
|
|
1127
|
-
let a = r.columns?.length ? mt(r.columns, t) : pt(t, { relationshipField: i }), o = r.amountField ||
|
|
1126
|
+
let a = r.columns?.length ? mt(r.columns, t) : pt(t, { relationshipField: i }), o = r.amountField || xt(a);
|
|
1128
1127
|
return {
|
|
1129
1128
|
childObject: e,
|
|
1130
1129
|
relationshipField: i,
|
|
1131
1130
|
columns: a,
|
|
1132
1131
|
formFields: gt(t, { relationshipField: i }),
|
|
1133
|
-
mode:
|
|
1132
|
+
mode: yt(t, r.inlineEdit ?? (t?.fields)?.[i]?.inlineEdit, { relationshipField: i }),
|
|
1134
1133
|
amountField: o,
|
|
1135
1134
|
sortField: Object.keys(t?.fields ?? {}).find((e) => rt.has(e))
|
|
1136
1135
|
};
|
|
1137
1136
|
}
|
|
1138
1137
|
//#endregion
|
|
1139
1138
|
//#region src/MasterDetailForm.tsx
|
|
1140
|
-
function
|
|
1139
|
+
function Ct(e) {
|
|
1141
1140
|
if (!e) return {};
|
|
1142
1141
|
let t = {};
|
|
1143
1142
|
return e.querySelectorAll("[name]").forEach((e) => {
|
|
@@ -1169,13 +1168,13 @@ function St(e) {
|
|
|
1169
1168
|
}
|
|
1170
1169
|
}), t;
|
|
1171
1170
|
}
|
|
1172
|
-
var
|
|
1171
|
+
var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, formKey: c, onRowExpand: l, onAddViaForm: u }) => {
|
|
1173
1172
|
let [d, f] = s({}), p = o("");
|
|
1174
1173
|
r(() => {
|
|
1175
1174
|
let e = i.current;
|
|
1176
1175
|
if (!e) return;
|
|
1177
1176
|
let t = () => {
|
|
1178
|
-
let t =
|
|
1177
|
+
let t = Ct(e), n;
|
|
1179
1178
|
try {
|
|
1180
1179
|
n = JSON.stringify(t);
|
|
1181
1180
|
} catch {
|
|
@@ -1270,7 +1269,7 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1270
1269
|
]
|
|
1271
1270
|
})
|
|
1272
1271
|
})] });
|
|
1273
|
-
},
|
|
1272
|
+
}, Tt = ({ schema: e, dataSource: n, className: i }) => {
|
|
1274
1273
|
let c = e.details || [], l = e.mode === "edit" && !!e.recordId, u = c.some((e) => !e.relationshipField || !e.columns?.length || e.columns.some((e) => !e.type)), [d, f] = s(u ? null : c), p = d ?? c;
|
|
1275
1274
|
r(() => {
|
|
1276
1275
|
if (!u) {
|
|
@@ -1289,7 +1288,7 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1289
1288
|
...t,
|
|
1290
1289
|
columns: mt(t.columns, r)
|
|
1291
1290
|
};
|
|
1292
|
-
let i =
|
|
1291
|
+
let i = St(t.childObject, r, e.objectName, {
|
|
1293
1292
|
relationshipField: t.relationshipField,
|
|
1294
1293
|
columns: t.columns,
|
|
1295
1294
|
amountField: t.amountField
|
|
@@ -1408,12 +1407,12 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1408
1407
|
isNew: !0
|
|
1409
1408
|
}), n;
|
|
1410
1409
|
});
|
|
1411
|
-
}, []),
|
|
1410
|
+
}, []), te = t(() => {
|
|
1412
1411
|
N((e) => (e?.isNew && h((t) => t.map((t, n) => n === e.detailIdx ? {
|
|
1413
1412
|
...t,
|
|
1414
1413
|
rows: t.rows.filter((t, n) => n !== e.rowIdx)
|
|
1415
1414
|
} : t)), null));
|
|
1416
|
-
}, []),
|
|
1415
|
+
}, []), L = t(async (t) => {
|
|
1417
1416
|
w(), e.onSuccess || K.success(l ? e.title ? `${e.title} saved` : "Saved" : "Created"), l || (h(p.map(() => ({
|
|
1418
1417
|
rows: [],
|
|
1419
1418
|
original: []
|
|
@@ -1424,9 +1423,9 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1424
1423
|
e.title,
|
|
1425
1424
|
p.length,
|
|
1426
1425
|
w
|
|
1427
|
-
]),
|
|
1426
|
+
]), R = t((t) => {
|
|
1428
1427
|
w(), K.error(t?.message || "Save failed"), e.onError?.(t);
|
|
1429
|
-
}, [e, w]),
|
|
1428
|
+
}, [e, w]), z = t(async (t) => {
|
|
1430
1429
|
let r = [];
|
|
1431
1430
|
for (let i = 0; i < p.length; i++) {
|
|
1432
1431
|
let a = p[i], { rows: o, original: s } = g.current[i];
|
|
@@ -1448,24 +1447,24 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1448
1447
|
l,
|
|
1449
1448
|
n,
|
|
1450
1449
|
e.objectName
|
|
1451
|
-
]),
|
|
1450
|
+
]), B = t(async (t) => {
|
|
1452
1451
|
let r = $(t) ?? e.recordId;
|
|
1453
1452
|
if (!r) throw Error("MasterDetailForm: parent record has no id after save");
|
|
1454
1453
|
if (!n) throw Error("MasterDetailForm: dataSource is required");
|
|
1455
1454
|
let i = [];
|
|
1456
1455
|
try {
|
|
1457
|
-
i = await
|
|
1456
|
+
i = await z(r);
|
|
1458
1457
|
} catch (t) {
|
|
1459
1458
|
throw l || await Promise.allSettled([...i.map((e) => n.delete(e.object, e.id)), n.delete(e.objectName, r)]), t;
|
|
1460
1459
|
}
|
|
1461
|
-
await
|
|
1460
|
+
await L(t);
|
|
1462
1461
|
}, [
|
|
1463
1462
|
n,
|
|
1464
1463
|
l,
|
|
1465
|
-
|
|
1464
|
+
z,
|
|
1466
1465
|
e,
|
|
1467
|
-
|
|
1468
|
-
]),
|
|
1466
|
+
L
|
|
1467
|
+
]), V = typeof n?.batchTransaction == "function", H = t(async (t) => {
|
|
1469
1468
|
let r = n, i = { ...t };
|
|
1470
1469
|
p.forEach((e, t) => {
|
|
1471
1470
|
e.totalField && (i[e.totalField] = Qe(g.current[t]?.rows ?? [], e.amountField || "amount"));
|
|
@@ -1505,18 +1504,18 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1505
1504
|
title: e.title,
|
|
1506
1505
|
showSubmit: !1,
|
|
1507
1506
|
showCancel: !1,
|
|
1508
|
-
...
|
|
1509
|
-
submitHandler:
|
|
1510
|
-
onSuccess:
|
|
1511
|
-
} : { onSuccess:
|
|
1512
|
-
onError:
|
|
1507
|
+
...V ? {
|
|
1508
|
+
submitHandler: H,
|
|
1509
|
+
onSuccess: L
|
|
1510
|
+
} : { onSuccess: B },
|
|
1511
|
+
onError: R
|
|
1513
1512
|
}), [
|
|
1514
1513
|
e,
|
|
1514
|
+
B,
|
|
1515
1515
|
V,
|
|
1516
1516
|
H,
|
|
1517
|
-
|
|
1518
|
-
R
|
|
1519
|
-
z
|
|
1517
|
+
L,
|
|
1518
|
+
R
|
|
1520
1519
|
]), U = o(null), W = e.submitText ?? (l ? "Save" : "Create"), re = t(() => {
|
|
1521
1520
|
S.current || U.current?.querySelector("form") && (S.current = !0, x(!0), setTimeout(() => {
|
|
1522
1521
|
(U.current?.querySelector("form"))?.requestSubmit();
|
|
@@ -1529,12 +1528,12 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1529
1528
|
children: [
|
|
1530
1529
|
/* @__PURE__ */ Y("div", {
|
|
1531
1530
|
ref: U,
|
|
1532
|
-
children: /* @__PURE__ */ Y(
|
|
1531
|
+
children: /* @__PURE__ */ Y(Nt, {
|
|
1533
1532
|
schema: ne,
|
|
1534
1533
|
dataSource: n
|
|
1535
1534
|
}, v)
|
|
1536
1535
|
}),
|
|
1537
|
-
/* @__PURE__ */ Y(
|
|
1536
|
+
/* @__PURE__ */ Y(wt, {
|
|
1538
1537
|
details: p,
|
|
1539
1538
|
state: m,
|
|
1540
1539
|
setRows: T,
|
|
@@ -1564,10 +1563,10 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1564
1563
|
variant: "ghost",
|
|
1565
1564
|
size: "sm",
|
|
1566
1565
|
className: "h-7 text-xs text-muted-foreground",
|
|
1567
|
-
onClick:
|
|
1566
|
+
onClick: te,
|
|
1568
1567
|
children: "Close"
|
|
1569
1568
|
})]
|
|
1570
|
-
}), /* @__PURE__ */ Y(k, { children: /* @__PURE__ */ Y(
|
|
1569
|
+
}), /* @__PURE__ */ Y(k, { children: /* @__PURE__ */ Y(Nt, {
|
|
1571
1570
|
schema: {
|
|
1572
1571
|
type: "object-form",
|
|
1573
1572
|
objectName: F.childObject,
|
|
@@ -1579,7 +1578,7 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1579
1578
|
onSuccess: (e) => {
|
|
1580
1579
|
ee(A.detailIdx, A.rowIdx, e), N(null);
|
|
1581
1580
|
},
|
|
1582
|
-
onCancel:
|
|
1581
|
+
onCancel: te
|
|
1583
1582
|
},
|
|
1584
1583
|
dataSource: n
|
|
1585
1584
|
}, `row-${A.detailIdx}-${A.rowIdx}`) })]
|
|
@@ -1603,18 +1602,18 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1603
1602
|
})
|
|
1604
1603
|
]
|
|
1605
1604
|
});
|
|
1606
|
-
},
|
|
1605
|
+
}, Et = {
|
|
1607
1606
|
1: void 0,
|
|
1608
1607
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
1609
1608
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
1610
1609
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
1611
|
-
},
|
|
1610
|
+
}, Dt = Z({
|
|
1612
1611
|
"form.discardTitle": "Discard changes?",
|
|
1613
1612
|
"form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
|
|
1614
1613
|
"form.keepEditing": "Keep editing",
|
|
1615
1614
|
"form.discard": "Discard"
|
|
1616
|
-
}, "form.discardTitle"),
|
|
1617
|
-
let { fieldLabel: u } = p(), { t: f } =
|
|
1615
|
+
}, "form.discardTitle"), Ot = ({ schema: e, dataSource: n, className: c }) => {
|
|
1616
|
+
let { fieldLabel: u } = p(), { t: f } = Dt(), m = d(), [h, _] = s(null), [O, k] = s([]), [A, j] = s({}), [M, N] = s(!0), [P, F] = s(null), [ee, I] = s(!1), [te, L] = s(!1), [R, U] = s(!1), W = o(!1), re = e.confirmOnDiscard !== !1, ie = e.open !== !1, ae = e.drawerSide || "right", K = i(), [oe, se] = s(() => {
|
|
1618
1617
|
let t = {};
|
|
1619
1618
|
return e.sections?.forEach((e, n) => {
|
|
1620
1619
|
let r = e.name || String(n);
|
|
@@ -1731,9 +1730,9 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1731
1730
|
n,
|
|
1732
1731
|
h
|
|
1733
1732
|
]), q = t(() => {
|
|
1734
|
-
|
|
1733
|
+
L(!1), W.current && (W.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
|
|
1735
1734
|
}, [e]), ue = t((e) => {
|
|
1736
|
-
W.current = e, re && ee ?
|
|
1735
|
+
W.current = e, re && ee ? L(!0) : q();
|
|
1737
1736
|
}, [
|
|
1738
1737
|
re,
|
|
1739
1738
|
ee,
|
|
@@ -1807,14 +1806,14 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1807
1806
|
fields: t
|
|
1808
1807
|
} });
|
|
1809
1808
|
}
|
|
1810
|
-
let t = ze(O, h, e.columns, e.mode), n =
|
|
1809
|
+
let t = ze(O, h, e.columns, e.mode), n = Et[t.columns || 1];
|
|
1811
1810
|
return /* @__PURE__ */ Y(l, { schema: {
|
|
1812
1811
|
..._e,
|
|
1813
1812
|
fields: t.fields,
|
|
1814
1813
|
columns: t.columns,
|
|
1815
1814
|
...n ? { fieldContainerClass: n } : {}
|
|
1816
1815
|
} });
|
|
1817
|
-
}, Q = e.subforms, ye = Q?.length && e.mode !== "view" ? /* @__PURE__ */ Y(
|
|
1816
|
+
}, Q = e.subforms, ye = Q?.length && e.mode !== "view" ? /* @__PURE__ */ Y(Tt, {
|
|
1818
1817
|
schema: {
|
|
1819
1818
|
type: "object-master-detail-form",
|
|
1820
1819
|
objectName: e.objectName,
|
|
@@ -1845,7 +1844,7 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1845
1844
|
children: e.description
|
|
1846
1845
|
})]
|
|
1847
1846
|
}), ye]
|
|
1848
|
-
}) : /* @__PURE__ */ Y(
|
|
1847
|
+
}) : /* @__PURE__ */ Y(z, {
|
|
1849
1848
|
open: ie,
|
|
1850
1849
|
onOpenChange: (t) => {
|
|
1851
1850
|
if (t) {
|
|
@@ -1854,12 +1853,12 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1854
1853
|
}
|
|
1855
1854
|
ue(!1);
|
|
1856
1855
|
},
|
|
1857
|
-
children: /* @__PURE__ */ X(
|
|
1856
|
+
children: /* @__PURE__ */ X(B, {
|
|
1858
1857
|
side: ae,
|
|
1859
1858
|
className: G("overflow-y-auto", c, e.className),
|
|
1860
1859
|
style: pe,
|
|
1861
1860
|
children: [
|
|
1862
|
-
(e.title || e.description) && /* @__PURE__ */ X(
|
|
1861
|
+
(e.title || e.description) && /* @__PURE__ */ X(H, { children: [e.title && /* @__PURE__ */ Y(ne, { children: e.title }), e.description ? /* @__PURE__ */ Y(V, { children: e.description }) : /* @__PURE__ */ Y(V, {
|
|
1863
1862
|
className: "sr-only",
|
|
1864
1863
|
children: "Complete the form fields, then submit or cancel."
|
|
1865
1864
|
})] }),
|
|
@@ -1876,21 +1875,21 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1876
1875
|
type: "button",
|
|
1877
1876
|
variant: "outline",
|
|
1878
1877
|
onClick: de,
|
|
1879
|
-
disabled:
|
|
1878
|
+
disabled: R,
|
|
1880
1879
|
className: "w-full sm:w-auto",
|
|
1881
1880
|
children: ge
|
|
1882
1881
|
}), J && /* @__PURE__ */ X(D, {
|
|
1883
1882
|
type: "submit",
|
|
1884
1883
|
form: K,
|
|
1885
|
-
disabled:
|
|
1884
|
+
disabled: R,
|
|
1886
1885
|
className: "w-full sm:w-auto",
|
|
1887
|
-
children: [
|
|
1886
|
+
children: [R && /* @__PURE__ */ Y(fe, { className: "mr-2 h-4 w-4 animate-spin" }), he]
|
|
1888
1887
|
})]
|
|
1889
1888
|
})
|
|
1890
1889
|
}),
|
|
1891
1890
|
/* @__PURE__ */ Y(y, {
|
|
1892
|
-
open:
|
|
1893
|
-
onOpenChange:
|
|
1891
|
+
open: te,
|
|
1892
|
+
onOpenChange: L,
|
|
1894
1893
|
children: /* @__PURE__ */ X(S, { children: [/* @__PURE__ */ X(T, { children: [/* @__PURE__ */ Y(E, { children: f("form.discardTitle") }), /* @__PURE__ */ Y(C, { children: f("form.discardMessage") })] }), /* @__PURE__ */ X(w, { children: [/* @__PURE__ */ Y(x, {
|
|
1895
1894
|
onClick: () => {
|
|
1896
1895
|
W.current = !1;
|
|
@@ -1907,7 +1906,7 @@ var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1907
1906
|
};
|
|
1908
1907
|
//#endregion
|
|
1909
1908
|
//#region src/fieldGroups.ts
|
|
1910
|
-
function
|
|
1909
|
+
function kt(e, t) {
|
|
1911
1910
|
let n = he({
|
|
1912
1911
|
fieldGroups: t,
|
|
1913
1912
|
fields: Object.fromEntries(e.map((e) => [e.name, { group: e.group }]))
|
|
@@ -1928,19 +1927,19 @@ function Ot(e, t) {
|
|
|
1928
1927
|
}
|
|
1929
1928
|
//#endregion
|
|
1930
1929
|
//#region src/ModalForm.tsx
|
|
1931
|
-
var
|
|
1930
|
+
var At = Z({
|
|
1932
1931
|
"form.discardTitle": "Discard changes?",
|
|
1933
1932
|
"form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
|
|
1934
1933
|
"form.keepEditing": "Keep editing",
|
|
1935
1934
|
"form.discard": "Discard"
|
|
1936
|
-
}, "form.discardTitle"),
|
|
1935
|
+
}, "form.discardTitle"), jt = {
|
|
1937
1936
|
sm: "sm:max-w-sm",
|
|
1938
1937
|
default: "sm:max-w-lg",
|
|
1939
1938
|
lg: "sm:max-w-2xl",
|
|
1940
1939
|
xl: "sm:max-w-5xl",
|
|
1941
1940
|
full: "sm:max-w-[95vw] sm:w-full"
|
|
1942
|
-
},
|
|
1943
|
-
let { fieldLabel: u, sectionLabel: f } = p(), { t: m } =
|
|
1941
|
+
}, Mt = ({ schema: e, dataSource: n, className: c }) => {
|
|
1942
|
+
let { fieldLabel: u, sectionLabel: f } = p(), { t: m } = At(), h = d(), _ = se(), O = t((t) => {
|
|
1944
1943
|
if (!_?.isLoaded) return t;
|
|
1945
1944
|
let n = [];
|
|
1946
1945
|
for (let r of t) {
|
|
@@ -1959,11 +1958,11 @@ var kt = Z({
|
|
|
1959
1958
|
_,
|
|
1960
1959
|
e.objectName,
|
|
1961
1960
|
e.mode
|
|
1962
|
-
]), [k, A] = s(null), [j, M] = s([]), [
|
|
1961
|
+
]), [k, A] = s(null), [j, M] = s([]), [te, L] = s({}), [R, z] = s(!0), [B, V] = 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(() => {
|
|
1963
1962
|
if (e.sections?.length || e.customFields?.length) return null;
|
|
1964
1963
|
let t = Me(j, k);
|
|
1965
1964
|
e.mode === "create" && (t = Pe(t, k));
|
|
1966
|
-
let n =
|
|
1965
|
+
let n = kt(t, k?.fieldGroups);
|
|
1967
1966
|
if (!n) return null;
|
|
1968
1967
|
let r = e.columns && e.columns > 0 ? Math.min(Math.floor(e.columns), 4) : De(t.length);
|
|
1969
1968
|
return n.map((e) => ({
|
|
@@ -1984,7 +1983,7 @@ var kt = Z({
|
|
|
1984
1983
|
e.mode,
|
|
1985
1984
|
J,
|
|
1986
1985
|
e.customFields
|
|
1987
|
-
]), he =
|
|
1986
|
+
]), he = jt[a(() => {
|
|
1988
1987
|
if (e.modalSize) return e.modalSize;
|
|
1989
1988
|
if (Z?.columns && Z.columns > 1) return Re(Z.columns);
|
|
1990
1989
|
if (J?.length) {
|
|
@@ -1996,37 +1995,37 @@ var kt = Z({
|
|
|
1996
1995
|
e.modalSize,
|
|
1997
1996
|
Z,
|
|
1998
1997
|
J
|
|
1999
|
-
])] ||
|
|
1998
|
+
])] || jt.default;
|
|
2000
1999
|
r(() => {
|
|
2001
2000
|
(async () => {
|
|
2002
2001
|
if (!n) {
|
|
2003
|
-
|
|
2002
|
+
z(!1);
|
|
2004
2003
|
return;
|
|
2005
2004
|
}
|
|
2006
2005
|
try {
|
|
2007
2006
|
let t = await n.getObjectSchema(e.objectName);
|
|
2008
2007
|
A(t);
|
|
2009
2008
|
} catch (e) {
|
|
2010
|
-
|
|
2009
|
+
V(e), z(!1);
|
|
2011
2010
|
}
|
|
2012
2011
|
})();
|
|
2013
2012
|
}, [e.objectName, n]), r(() => {
|
|
2014
2013
|
(k || !n) && (async () => {
|
|
2015
2014
|
if (e.mode === "create" || !e.recordId) {
|
|
2016
|
-
|
|
2015
|
+
L(e.initialData || e.initialValues || {}), z(!1);
|
|
2017
2016
|
return;
|
|
2018
2017
|
}
|
|
2019
2018
|
if (!n) {
|
|
2020
|
-
|
|
2019
|
+
L(e.initialData || e.initialValues || {}), z(!1);
|
|
2021
2020
|
return;
|
|
2022
2021
|
}
|
|
2023
2022
|
try {
|
|
2024
2023
|
let t = await n.findOne(e.objectName, e.recordId);
|
|
2025
|
-
|
|
2024
|
+
L(t || {});
|
|
2026
2025
|
} catch (e) {
|
|
2027
|
-
|
|
2026
|
+
V(e);
|
|
2028
2027
|
} finally {
|
|
2029
|
-
|
|
2028
|
+
z(!1);
|
|
2030
2029
|
}
|
|
2031
2030
|
})();
|
|
2032
2031
|
}, [
|
|
@@ -2054,11 +2053,11 @@ var kt = Z({
|
|
|
2054
2053
|
r(() => {
|
|
2055
2054
|
if (!k && n) return;
|
|
2056
2055
|
if (e.customFields?.length) {
|
|
2057
|
-
M(e.customFields),
|
|
2056
|
+
M(e.customFields), z(!1);
|
|
2058
2057
|
return;
|
|
2059
2058
|
}
|
|
2060
2059
|
if (e.sections?.length) {
|
|
2061
|
-
|
|
2060
|
+
z(!1);
|
|
2062
2061
|
return;
|
|
2063
2062
|
}
|
|
2064
2063
|
if (!k) return;
|
|
@@ -2085,7 +2084,7 @@ var kt = Z({
|
|
|
2085
2084
|
group: i.group
|
|
2086
2085
|
});
|
|
2087
2086
|
}
|
|
2088
|
-
M(r),
|
|
2087
|
+
M(r), z(!1);
|
|
2089
2088
|
}, [
|
|
2090
2089
|
k,
|
|
2091
2090
|
e.fields,
|
|
@@ -2130,7 +2129,7 @@ var kt = Z({
|
|
|
2130
2129
|
type: "form",
|
|
2131
2130
|
objectName: e.objectName,
|
|
2132
2131
|
layout: Se,
|
|
2133
|
-
defaultValues:
|
|
2132
|
+
defaultValues: te,
|
|
2134
2133
|
submitLabel: Te,
|
|
2135
2134
|
cancelLabel: Ee,
|
|
2136
2135
|
showSubmit: Ce,
|
|
@@ -2141,17 +2140,17 @@ var kt = Z({
|
|
|
2141
2140
|
showActions: !1,
|
|
2142
2141
|
id: pe
|
|
2143
2142
|
}, ke = () => {
|
|
2144
|
-
if (
|
|
2143
|
+
if (B) return /* @__PURE__ */ X("div", {
|
|
2145
2144
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
2146
2145
|
children: [/* @__PURE__ */ Y("h3", {
|
|
2147
2146
|
className: "text-red-800 font-semibold",
|
|
2148
2147
|
children: "Error loading form"
|
|
2149
2148
|
}), /* @__PURE__ */ Y("p", {
|
|
2150
2149
|
className: "text-red-600 text-sm mt-1",
|
|
2151
|
-
children:
|
|
2150
|
+
children: B.message
|
|
2152
2151
|
})]
|
|
2153
2152
|
});
|
|
2154
|
-
if (
|
|
2153
|
+
if (R) return /* @__PURE__ */ Y("div", {
|
|
2155
2154
|
className: "space-y-4",
|
|
2156
2155
|
"data-testid": "modal-form-skeleton",
|
|
2157
2156
|
children: [
|
|
@@ -2253,7 +2252,7 @@ var kt = Z({
|
|
|
2253
2252
|
})]
|
|
2254
2253
|
}), /* @__PURE__ */ Y("div", {
|
|
2255
2254
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
2256
|
-
children: /* @__PURE__ */ Y(
|
|
2255
|
+
children: /* @__PURE__ */ Y(Tt, {
|
|
2257
2256
|
schema: {
|
|
2258
2257
|
type: "object-master-detail-form",
|
|
2259
2258
|
objectName: e.objectName,
|
|
@@ -2277,7 +2276,7 @@ var kt = Z({
|
|
|
2277
2276
|
})]
|
|
2278
2277
|
})
|
|
2279
2278
|
});
|
|
2280
|
-
let Ne = !
|
|
2279
|
+
let Ne = !R && !B && (Ce || we);
|
|
2281
2280
|
return /* @__PURE__ */ Y(N, {
|
|
2282
2281
|
open: de,
|
|
2283
2282
|
onOpenChange: (t) => {
|
|
@@ -2310,15 +2309,15 @@ var kt = Z({
|
|
|
2310
2309
|
type: "button",
|
|
2311
2310
|
variant: "outline",
|
|
2312
2311
|
onClick: be,
|
|
2313
|
-
disabled:
|
|
2312
|
+
disabled: H,
|
|
2314
2313
|
className: "w-full sm:w-auto",
|
|
2315
2314
|
children: Ee
|
|
2316
2315
|
}), Ce && /* @__PURE__ */ X(D, {
|
|
2317
2316
|
type: "submit",
|
|
2318
2317
|
form: pe,
|
|
2319
|
-
disabled:
|
|
2318
|
+
disabled: H,
|
|
2320
2319
|
className: "w-full sm:w-auto",
|
|
2321
|
-
children: [
|
|
2320
|
+
children: [H && /* @__PURE__ */ Y(fe, { className: "mr-2 h-4 w-4 animate-spin" }), Te]
|
|
2322
2321
|
})]
|
|
2323
2322
|
})
|
|
2324
2323
|
}),
|
|
@@ -2338,7 +2337,7 @@ var kt = Z({
|
|
|
2338
2337
|
]
|
|
2339
2338
|
})
|
|
2340
2339
|
});
|
|
2341
|
-
},
|
|
2340
|
+
}, Nt = ({ schema: e, dataSource: t }) => {
|
|
2342
2341
|
let n = se(), r = a(() => {
|
|
2343
2342
|
let t = e.groups, r = !e.sections?.length && Array.isArray(t) && t.length ? {
|
|
2344
2343
|
...e,
|
|
@@ -2365,7 +2364,7 @@ var kt = Z({
|
|
|
2365
2364
|
}))
|
|
2366
2365
|
};
|
|
2367
2366
|
}, [e, n]), { sectionLabel: i } = p(), o = (e) => e?.name ? i(r.objectName, e.name, e.label || e.name) : e?.label;
|
|
2368
|
-
if (r.subforms?.length && r.mode !== "view" && r.formType !== "drawer" && r.formType !== "modal") return /* @__PURE__ */ Y(
|
|
2367
|
+
if (r.subforms?.length && r.mode !== "view" && r.formType !== "drawer" && r.formType !== "modal") return /* @__PURE__ */ Y(Tt, {
|
|
2369
2368
|
schema: {
|
|
2370
2369
|
type: "object-master-detail-form",
|
|
2371
2370
|
objectName: r.objectName,
|
|
@@ -2451,7 +2450,7 @@ var kt = Z({
|
|
|
2451
2450
|
});
|
|
2452
2451
|
if (r.formType === "drawer") {
|
|
2453
2452
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
2454
|
-
return /* @__PURE__ */ Y(
|
|
2453
|
+
return /* @__PURE__ */ Y(Ot, {
|
|
2455
2454
|
schema: {
|
|
2456
2455
|
...n,
|
|
2457
2456
|
layout: i,
|
|
@@ -2477,7 +2476,7 @@ var kt = Z({
|
|
|
2477
2476
|
}
|
|
2478
2477
|
if (r.formType === "modal") {
|
|
2479
2478
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
2480
|
-
return /* @__PURE__ */ Y(
|
|
2479
|
+
return /* @__PURE__ */ Y(Mt, {
|
|
2481
2480
|
schema: {
|
|
2482
2481
|
...n,
|
|
2483
2482
|
layout: i,
|
|
@@ -2500,11 +2499,11 @@ var kt = Z({
|
|
|
2500
2499
|
className: r.className
|
|
2501
2500
|
});
|
|
2502
2501
|
}
|
|
2503
|
-
return /* @__PURE__ */ Y(
|
|
2502
|
+
return /* @__PURE__ */ Y(Pt, {
|
|
2504
2503
|
schema: r,
|
|
2505
2504
|
dataSource: t
|
|
2506
2505
|
});
|
|
2507
|
-
},
|
|
2506
|
+
}, Pt = ({ schema: n, dataSource: i }) => {
|
|
2508
2507
|
let { fieldLabel: a, sectionLabel: o } = p(), c = oe(), u = se(), d = t((e) => {
|
|
2509
2508
|
if (!u?.isLoaded) return e;
|
|
2510
2509
|
let t = [];
|
|
@@ -2583,23 +2582,23 @@ var kt = Z({
|
|
|
2583
2582
|
return;
|
|
2584
2583
|
}
|
|
2585
2584
|
if (!f) return;
|
|
2586
|
-
let e = [], t = !!f?.managedBy && f.managedBy !== "platform", r = n.mode === "edit" ?
|
|
2587
|
-
(Array.isArray(
|
|
2585
|
+
let e = [], t = !!f?.managedBy && f.managedBy !== "platform", r = f?.userActions?.edit, o = r === !0 || typeof r == "object" && !!r && r.enabled === !0, s = n.mode === "edit" ? o : n.mode === "create" && f?.userActions?.create === !0, c = t && !s, l = n.fields || Object.keys(f.fields || {});
|
|
2586
|
+
(Array.isArray(l) ? l : Object.keys(l)).forEach((t) => {
|
|
2588
2587
|
let r = typeof t == "string" ? t : t.name;
|
|
2589
2588
|
if (!r) return;
|
|
2590
2589
|
let i = f.fields?.[r];
|
|
2591
2590
|
if (!i && !O) return;
|
|
2592
|
-
let
|
|
2593
|
-
if (n.mode !== "view" && !
|
|
2594
|
-
let
|
|
2595
|
-
if (
|
|
2591
|
+
let o = !i?.permissions || i?.permissions.write !== !1;
|
|
2592
|
+
if (n.mode !== "view" && !o) return;
|
|
2593
|
+
let s = n.customFields?.find((e) => e.name === r);
|
|
2594
|
+
if (s) e.push(k(s));
|
|
2596
2595
|
else if (i) {
|
|
2597
|
-
let
|
|
2596
|
+
let o = {
|
|
2598
2597
|
name: r,
|
|
2599
2598
|
label: a(n.objectName, r, i.label || t),
|
|
2600
2599
|
type: v(i.type),
|
|
2601
2600
|
required: i.required || !1,
|
|
2602
|
-
disabled: n.readOnly || n.mode === "view" || i.readonly ||
|
|
2601
|
+
disabled: n.readOnly || n.mode === "view" || i.readonly || c,
|
|
2603
2602
|
placeholder: i.placeholder,
|
|
2604
2603
|
description: i.help || i.description,
|
|
2605
2604
|
validation: g(i),
|
|
@@ -2610,11 +2609,11 @@ var kt = Z({
|
|
|
2610
2609
|
field: i,
|
|
2611
2610
|
widget: i.widget
|
|
2612
2611
|
};
|
|
2613
|
-
if ((i.type === "select" || i.type === "lookup" || i.type === "master_detail") && (
|
|
2612
|
+
if ((i.type === "select" || i.type === "lookup" || i.type === "master_detail") && (o.options = i.options || [], o.multiple = i.multiple), (i.type === "number" || i.type === "currency" || i.type === "percent") && (o.inputType = "number", o.min = i.min, o.max = i.max, o.step = i.precision ? 10 ** -i.precision : void 0), i.type === "date" && (o.inputType = "date"), i.type === "datetime" && (o.inputType = "datetime-local"), (i.type === "text" || i.type === "textarea" || i.type === "markdown" || i.type === "html") && (o.maxLength = i.max_length, o.minLength = i.min_length), (i.type === "file" || i.type === "image") && (o.inputType = "file", o.multiple = i.multiple, o.accept = i.accept ? i.accept.join(",") : void 0, i.max_size)) {
|
|
2614
2613
|
let e = `Max size: ${_(i.max_size)}`;
|
|
2615
|
-
|
|
2614
|
+
o.description = o.description ? `${o.description} (${e})` : e;
|
|
2616
2615
|
}
|
|
2617
|
-
i.type === "email" && (
|
|
2616
|
+
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);
|
|
2618
2617
|
}
|
|
2619
2618
|
}), y(e), !O && n.recordId && n.mode !== "create" && i || C(!1);
|
|
2620
2619
|
}, [
|
|
@@ -2693,7 +2692,7 @@ var kt = Z({
|
|
|
2693
2692
|
h,
|
|
2694
2693
|
f,
|
|
2695
2694
|
n.mode
|
|
2696
|
-
]), P = e.useMemo(() => n.sections?.length ? null :
|
|
2695
|
+
]), P = e.useMemo(() => n.sections?.length ? null : kt(N, f?.fieldGroups), [
|
|
2697
2696
|
n.sections,
|
|
2698
2697
|
N,
|
|
2699
2698
|
f
|
|
@@ -2725,7 +2724,7 @@ var kt = Z({
|
|
|
2725
2724
|
children: E.message
|
|
2726
2725
|
})]
|
|
2727
2726
|
});
|
|
2728
|
-
let
|
|
2727
|
+
let te = n.layout === "vertical" || n.layout === "horizontal" ? n.layout : "vertical";
|
|
2729
2728
|
if (F?.length && (!n.formType || n.formType === "simple")) {
|
|
2730
2729
|
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 = [];
|
|
2731
2730
|
F.forEach((r, i) => {
|
|
@@ -2763,7 +2762,7 @@ var kt = Z({
|
|
|
2763
2762
|
type: "form",
|
|
2764
2763
|
objectName: n.objectName,
|
|
2765
2764
|
fields: c,
|
|
2766
|
-
layout:
|
|
2765
|
+
layout: te,
|
|
2767
2766
|
columns: a,
|
|
2768
2767
|
...u ? { fieldContainerClass: u } : {},
|
|
2769
2768
|
defaultValues: M,
|
|
@@ -2776,18 +2775,18 @@ var kt = Z({
|
|
|
2776
2775
|
} })
|
|
2777
2776
|
});
|
|
2778
2777
|
}
|
|
2779
|
-
let
|
|
2780
|
-
fields:
|
|
2778
|
+
let L = n.sections?.length, R = d(h), z = L ? {
|
|
2779
|
+
fields: R,
|
|
2781
2780
|
columns: n.columns
|
|
2782
|
-
} : ze(
|
|
2781
|
+
} : ze(R, f, n.columns, n.mode), B = n.mobile, V = B?.fullscreenLongText ? z.fields.map((e) => {
|
|
2783
2782
|
let t = e.type;
|
|
2784
2783
|
return t === "textarea" || t === "field:textarea" || t === "string-multiline" || t === "field:markdown" || t === "field:html" ? {
|
|
2785
2784
|
...e,
|
|
2786
2785
|
mobile_fullscreen: !0
|
|
2787
2786
|
} : e;
|
|
2788
|
-
}) :
|
|
2789
|
-
if (!n.formType && !
|
|
2790
|
-
let e =
|
|
2787
|
+
}) : z.fields, H = B?.stepper, ne = B?.stepperMinFields ?? 8, U = Math.max(1, B?.stepperFieldsPerStep ?? 1);
|
|
2788
|
+
if (!n.formType && !L && V.length >= 2 && (H === !0 || H === "auto" && c && V.length >= ne)) {
|
|
2789
|
+
let e = V, t = [];
|
|
2791
2790
|
for (let n = 0; n < e.length; n += U) {
|
|
2792
2791
|
let r = e.slice(n, n + U);
|
|
2793
2792
|
t.push({
|
|
@@ -2810,9 +2809,9 @@ var kt = Z({
|
|
|
2810
2809
|
let W = {
|
|
2811
2810
|
type: "form",
|
|
2812
2811
|
objectName: n.objectName,
|
|
2813
|
-
fields:
|
|
2814
|
-
layout:
|
|
2815
|
-
columns:
|
|
2812
|
+
fields: V,
|
|
2813
|
+
layout: te,
|
|
2814
|
+
columns: z.columns,
|
|
2816
2815
|
submitLabel: n.submitText || (n.mode === "create" ? "Create" : "Update"),
|
|
2817
2816
|
cancelLabel: n.cancelText,
|
|
2818
2817
|
showSubmit: n.showSubmit !== !1 && n.mode !== "view",
|
|
@@ -2822,14 +2821,14 @@ var kt = Z({
|
|
|
2822
2821
|
onSubmit: A,
|
|
2823
2822
|
onCancel: j,
|
|
2824
2823
|
className: n.className,
|
|
2825
|
-
mobileStickyActions: !!
|
|
2824
|
+
mobileStickyActions: !!B?.stickyActions
|
|
2826
2825
|
};
|
|
2827
2826
|
return /* @__PURE__ */ Y("div", {
|
|
2828
|
-
className:
|
|
2829
|
-
"data-mobile-form":
|
|
2827
|
+
className: B?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
|
|
2828
|
+
"data-mobile-form": B ? "true" : void 0,
|
|
2830
2829
|
children: /* @__PURE__ */ Y(l, { schema: W })
|
|
2831
2830
|
});
|
|
2832
|
-
},
|
|
2831
|
+
}, Ft = {
|
|
2833
2832
|
text: 200,
|
|
2834
2833
|
email: 254,
|
|
2835
2834
|
url: 2048,
|
|
@@ -2837,8 +2836,8 @@ var kt = Z({
|
|
|
2837
2836
|
textarea: 5e3,
|
|
2838
2837
|
markdown: 5e3,
|
|
2839
2838
|
html: 5e3
|
|
2840
|
-
},
|
|
2841
|
-
function
|
|
2839
|
+
}, It = "_company_website_2", Lt = 1500;
|
|
2840
|
+
function Rt(e, t = []) {
|
|
2842
2841
|
try {
|
|
2843
2842
|
let n = new URL(e, typeof window < "u" ? window.location.href : "http://localhost");
|
|
2844
2843
|
return typeof window < "u" && n.origin === window.location.origin ? !0 : n.protocol !== "https:" && n.protocol !== "http:" ? !1 : t.some((e) => {
|
|
@@ -2853,21 +2852,21 @@ function Lt(e, t = []) {
|
|
|
2853
2852
|
return !1;
|
|
2854
2853
|
}
|
|
2855
2854
|
}
|
|
2856
|
-
function
|
|
2855
|
+
function zt(e) {
|
|
2857
2856
|
return e && e.map((e) => {
|
|
2858
|
-
let t =
|
|
2857
|
+
let t = Ft[String(e.type || "").toLowerCase()];
|
|
2859
2858
|
return !t || (e.maxLength ?? e.max_length) ? e : {
|
|
2860
2859
|
...e,
|
|
2861
2860
|
maxLength: t
|
|
2862
2861
|
};
|
|
2863
2862
|
});
|
|
2864
2863
|
}
|
|
2865
|
-
var
|
|
2864
|
+
var Bt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
2866
2865
|
let [l, u] = s(!1), [d, f] = s(!1), [p, m] = s(null), [h, g] = s(!(e.consent?.required ?? !!e.consent)), [_, v] = s(null), y = o(null), b = o(0);
|
|
2867
2866
|
r(() => {
|
|
2868
2867
|
l || (b.current = Date.now());
|
|
2869
2868
|
}, [l]);
|
|
2870
|
-
let x = e.honeypot === !1 ? null : e.honeypot ||
|
|
2869
|
+
let x = e.honeypot === !1 ? null : e.honeypot || It, S = e.minFillTime ?? Lt, C = a(() => zt(e.customFields), [e.customFields]), w = a(() => {
|
|
2871
2870
|
if (!n || C && C.length > 0 || !e.fields || e.fields.length === 0) return;
|
|
2872
2871
|
let t = async (e, t) => t;
|
|
2873
2872
|
return {
|
|
@@ -2908,7 +2907,7 @@ var zt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
|
2908
2907
|
try {
|
|
2909
2908
|
n && await n.create(e.objectName, r), u(!0);
|
|
2910
2909
|
let t = e.thankYouPage?.redirectUrl;
|
|
2911
|
-
if (t) if (
|
|
2910
|
+
if (t) if (Rt(t, e.allowedRedirectHosts)) {
|
|
2912
2911
|
let n = e.thankYouPage?.redirectDelay ?? 3e3;
|
|
2913
2912
|
setTimeout(() => {
|
|
2914
2913
|
window.location.href = t;
|
|
@@ -3014,7 +3013,7 @@ var zt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
|
3014
3013
|
className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
|
|
3015
3014
|
children: p
|
|
3016
3015
|
}),
|
|
3017
|
-
/* @__PURE__ */ Y(
|
|
3016
|
+
/* @__PURE__ */ Y(Nt, {
|
|
3018
3017
|
schema: {
|
|
3019
3018
|
type: "object-form",
|
|
3020
3019
|
objectName: e.objectName,
|
|
@@ -3120,10 +3119,10 @@ var zt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
|
3120
3119
|
};
|
|
3121
3120
|
//#endregion
|
|
3122
3121
|
//#region src/FormAnalytics.tsx
|
|
3123
|
-
function
|
|
3122
|
+
function Vt(e) {
|
|
3124
3123
|
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`;
|
|
3125
3124
|
}
|
|
3126
|
-
var
|
|
3125
|
+
var Ht = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
3127
3126
|
let i = a(() => {
|
|
3128
3127
|
if (!n.abandonedSubmissions) return 100;
|
|
3129
3128
|
let e = n.totalSubmissions + n.abandonedSubmissions;
|
|
@@ -3166,7 +3165,7 @@ var Vt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3166
3165
|
className: "pb-2",
|
|
3167
3166
|
children: [/* @__PURE__ */ Y(A, { children: "Avg. Completion Time" }), /* @__PURE__ */ Y(M, {
|
|
3168
3167
|
className: "text-2xl",
|
|
3169
|
-
children: n.avgCompletionTime ?
|
|
3168
|
+
children: n.avgCompletionTime ? Vt(n.avgCompletionTime) : "—"
|
|
3170
3169
|
})]
|
|
3171
3170
|
}) })
|
|
3172
3171
|
]
|
|
@@ -3218,7 +3217,7 @@ var Vt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3218
3217
|
}) })] })
|
|
3219
3218
|
]
|
|
3220
3219
|
});
|
|
3221
|
-
},
|
|
3220
|
+
}, Ut = ({ schema: e }) => {
|
|
3222
3221
|
let n = m()?.dataSource, i = f(), o = e.parentObject || i?.objectName, c = e.parentId || e.recordId || i?.recordId, [l, u] = s([]), [d, p] = s([]), [g, _] = s(!0), [v, y] = s(!1), [b, x] = s(!1), [S, C] = s(null), [w, T] = s(null);
|
|
3223
3222
|
r(() => {
|
|
3224
3223
|
let t = n;
|
|
@@ -3326,11 +3325,11 @@ var Vt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3326
3325
|
children: "Save the record first to add line items."
|
|
3327
3326
|
})] })]
|
|
3328
3327
|
});
|
|
3329
|
-
},
|
|
3328
|
+
}, Wt = ({ schema: e }) => /* @__PURE__ */ Y(Nt, {
|
|
3330
3329
|
schema: e,
|
|
3331
3330
|
dataSource: n(u)?.dataSource ?? void 0
|
|
3332
3331
|
});
|
|
3333
|
-
c.register("object-form",
|
|
3332
|
+
c.register("object-form", Wt, {
|
|
3334
3333
|
namespace: "plugin-form",
|
|
3335
3334
|
label: "Object Form",
|
|
3336
3335
|
category: "plugin",
|
|
@@ -3471,7 +3470,7 @@ c.register("object-form", Ut, {
|
|
|
3471
3470
|
]
|
|
3472
3471
|
}
|
|
3473
3472
|
]
|
|
3474
|
-
}), c.register("form",
|
|
3473
|
+
}), c.register("form", Wt, {
|
|
3475
3474
|
namespace: "view",
|
|
3476
3475
|
skipFallback: !0,
|
|
3477
3476
|
label: "Data Form View",
|
|
@@ -3499,7 +3498,7 @@ c.register("object-form", Ut, {
|
|
|
3499
3498
|
]
|
|
3500
3499
|
}
|
|
3501
3500
|
]
|
|
3502
|
-
}), c.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */ Y(
|
|
3501
|
+
}), c.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */ Y(Bt, { config: e }), {
|
|
3503
3502
|
namespace: "plugin-form",
|
|
3504
3503
|
label: "Embeddable Form",
|
|
3505
3504
|
category: "plugin",
|
|
@@ -3537,7 +3536,7 @@ c.register("object-form", Ut, {
|
|
|
3537
3536
|
label: "Allow Multiple Submissions"
|
|
3538
3537
|
}
|
|
3539
3538
|
]
|
|
3540
|
-
}), c.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ Y(
|
|
3539
|
+
}), c.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ Y(Ht, {
|
|
3541
3540
|
formId: e.formId,
|
|
3542
3541
|
formTitle: e.formTitle,
|
|
3543
3542
|
metrics: e.metrics || { totalSubmissions: 0 }
|
|
@@ -3563,7 +3562,7 @@ c.register("object-form", Ut, {
|
|
|
3563
3562
|
label: "Submission Metrics"
|
|
3564
3563
|
}
|
|
3565
3564
|
]
|
|
3566
|
-
}), c.register("object-master-detail-form", ({ schema: e }) => /* @__PURE__ */ Y(
|
|
3565
|
+
}), c.register("object-master-detail-form", ({ schema: e }) => /* @__PURE__ */ Y(Tt, {
|
|
3567
3566
|
schema: e,
|
|
3568
3567
|
dataSource: n(u)?.dataSource ?? void 0
|
|
3569
3568
|
}), {
|
|
@@ -3595,7 +3594,7 @@ c.register("object-form", Ut, {
|
|
|
3595
3594
|
required: !0
|
|
3596
3595
|
}
|
|
3597
3596
|
]
|
|
3598
|
-
}), c.register("line_items", ({ schema: e }) => /* @__PURE__ */ Y(
|
|
3597
|
+
}), c.register("line_items", ({ schema: e }) => /* @__PURE__ */ Y(Ut, { schema: e }), {
|
|
3599
3598
|
namespace: "record",
|
|
3600
3599
|
skipFallback: !0,
|
|
3601
3600
|
label: "Line Items",
|
|
@@ -3632,4 +3631,4 @@ c.register("object-form", Ut, {
|
|
|
3632
3631
|
]
|
|
3633
3632
|
});
|
|
3634
3633
|
//#endregion
|
|
3635
|
-
export {
|
|
3634
|
+
export { Ot as DrawerForm, Bt as EmbeddableForm, Ht as FormAnalytics, ve as FormSection, Ut as LineItemsPanel, Tt as MasterDetailForm, Mt as ModalForm, Nt as ObjectForm, He as SplitForm, Be as TabbedForm, Ve as WizardForm, Ae as applyAutoColSpan, ze as applyAutoLayout, Ie as containerGridColsFor, pt as deriveColumns, St as deriveDetail, gt as deriveFormFields, Pe as filterAutoGeneratedFields, Ne as filterCreateModeFields, Me as filterSystemFields, lt as findRelationshipField, De as inferColumns, Re as inferModalSize, Ee as isAutoGeneratedFieldType, Te as isWideFieldType, yt as resolveInlineMode };
|