@object-ui/plugin-form 17.1.0 → 17.2.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 +227 -0
- package/dist/FormSection.d.ts +6 -6
- package/dist/FormSection.d.ts.map +1 -1
- package/dist/WizardForm.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +671 -668
- package/dist/index.umd.cjs +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
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, evalFieldPredicate as u,
|
|
4
|
-
import { SchemaRenderer as
|
|
5
|
-
import { LineItemsField as
|
|
6
|
-
import { AlertDialog as
|
|
7
|
-
import { usePermissions as
|
|
8
|
-
import { AlertCircle as ie, AlertTriangle as ae, Check as oe, CheckCircle2 as se, ChevronDown as ce, ChevronLeft as
|
|
3
|
+
import { ComponentRegistry as l, evalFieldPredicate as u, isMissingForRequired as d, resolveEffectiveCrudAffordances as f, resolveFieldRuleState as p, runBatchTransaction as m } from "@object-ui/core";
|
|
4
|
+
import { SchemaRenderer as h, SchemaRendererContext as g, usePreviewMode as _, useRecordContext as v, useSafeFieldLabel as y, useSchemaContext as b } from "@object-ui/react";
|
|
5
|
+
import { LineItemsField as x, buildValidationRules as S, formatFileSize as C, mapFieldTypeToFormType as w } from "@object-ui/fields";
|
|
6
|
+
import { AlertDialog as T, AlertDialogAction as E, AlertDialogCancel as D, AlertDialogContent as O, AlertDialogDescription as k, AlertDialogFooter as A, AlertDialogHeader as j, AlertDialogTitle as M, Button as N, Card as P, CardContent as F, CardDescription as I, CardHeader as L, CardTitle as R, Dialog as z, DialogDescription as B, DialogHeader as V, DialogTitle as H, MobileDialogContent as ee, Sheet as U, SheetContent as W, SheetDescription as G, SheetHeader as te, SheetTitle as ne, Skeleton as K, buttonVariants as q, cn as J, toast as Y, useIsMobile as X } from "@object-ui/components";
|
|
7
|
+
import { usePermissions as re } from "@object-ui/permissions";
|
|
8
|
+
import { AlertCircle as ie, AlertTriangle as ae, Check as oe, CheckCircle2 as se, ChevronDown as ce, ChevronLeft as Z, ChevronRight as le, Loader2 as ue, Lock as de, ShieldCheck as fe } from "lucide-react";
|
|
9
9
|
import { createSafeTranslation as pe } from "@object-ui/i18n";
|
|
10
|
-
import { Fragment as me, jsx as
|
|
10
|
+
import { Fragment as me, jsx as Q, jsxs as $ } from "react/jsx-runtime";
|
|
11
11
|
import { deriveFieldGroupLayout as he } from "@objectstack/spec/data";
|
|
12
12
|
//#region src/successBehavior.ts
|
|
13
|
-
function
|
|
13
|
+
function ge(e) {
|
|
14
14
|
try {
|
|
15
15
|
return typeof window > "u" ? !1 : new URL(e, window.location.href).origin === window.location.origin;
|
|
16
16
|
} catch {
|
|
17
17
|
return !1;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function _e(e, t) {
|
|
21
21
|
if (!e) return null;
|
|
22
22
|
let n = t?.id ?? t?.recordId ?? t?._id;
|
|
23
23
|
if (n == null || n === "") return null;
|
|
24
24
|
let r = e.replace(/\{(?:id|recordId)\}/g, String(n));
|
|
25
|
-
return
|
|
25
|
+
return ge(r) ? r : null;
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/sectionFields.ts
|
|
29
|
-
function
|
|
29
|
+
function ve(e, t) {
|
|
30
30
|
return typeof t == "string" && t.trim() || typeof t == "object" && t && typeof t.source == "string" && t.source.trim() ? {
|
|
31
31
|
...e,
|
|
32
32
|
visibleOn: t
|
|
33
33
|
} : e;
|
|
34
34
|
}
|
|
35
|
-
var
|
|
36
|
-
function
|
|
35
|
+
var ye = /* @__PURE__ */ new Set();
|
|
36
|
+
function be(e, t) {
|
|
37
37
|
if (typeof e.name != "string" || e.name === e.field) return;
|
|
38
38
|
let n = `${t}:${e.field}:${e.name}`;
|
|
39
|
-
|
|
39
|
+
ye.has(n) || (ye.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.`));
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function xe(e, t) {
|
|
42
42
|
let n = t.objectSchema?.fields?.[e];
|
|
43
43
|
return n ? {
|
|
44
44
|
name: e,
|
|
45
45
|
label: t.fieldLabel(t.objectName, e, n.label || e),
|
|
46
|
-
type:
|
|
46
|
+
type: w(n.type),
|
|
47
47
|
required: n.required || !1,
|
|
48
48
|
disabled: t.readOnly || t.mode === "view" || n.readonly,
|
|
49
49
|
placeholder: n.placeholder,
|
|
50
50
|
description: n.help || n.description,
|
|
51
|
-
validation:
|
|
51
|
+
validation: S(n),
|
|
52
52
|
field: n,
|
|
53
53
|
options: n.options,
|
|
54
54
|
multiple: n.multiple,
|
|
@@ -61,30 +61,30 @@ function be(e, t) {
|
|
|
61
61
|
type: "input"
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function Se(e, t) {
|
|
65
65
|
if (typeof e == "string") {
|
|
66
66
|
let n = t.objectSchema?.fields?.[e];
|
|
67
|
-
return
|
|
67
|
+
return ve(xe(e, t), n?.visible_on ?? n?.visibleOn);
|
|
68
68
|
}
|
|
69
69
|
let n = e;
|
|
70
|
-
if (typeof n.field != "string") return
|
|
71
|
-
|
|
72
|
-
let r = n.field, i =
|
|
73
|
-
n.type != null && (i.type =
|
|
70
|
+
if (typeof n.field != "string") return ve(n, n.visibleOn);
|
|
71
|
+
be(n, t.objectName);
|
|
72
|
+
let r = n.field, i = xe(r, t);
|
|
73
|
+
n.type != null && (i.type = w(n.type)), n.widget != null && (i.widget = n.widget), n.label != null && (i.label = n.label), n.placeholder != null && (i.placeholder = n.placeholder), n.helpText != null && (i.description = n.helpText), n.required != null && (i.required = n.required), n.readonly != null && (i.disabled = n.readonly || i.disabled), n.immutable != null && (i.immutable = n.immutable), n.hidden != null && (i.hidden = n.hidden), n.colSpan != null && (i.colSpan = n.colSpan), n.span != null && (i.span = n.span), n.options != null && (i.options = n.options), n.multiple != null && (i.multiple = n.multiple);
|
|
74
74
|
let a = n.reference ?? n.reference_to;
|
|
75
|
-
return a != null && (i.reference = a, i.reference_to = a), 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),
|
|
75
|
+
return a != null && (i.reference = a, i.reference_to = a), 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), ve(i, n.visibleWhen ?? n.visibleOn);
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
return (e.fields ?? []).map((e) =>
|
|
77
|
+
function Ce(e, t) {
|
|
78
|
+
return (e.fields ?? []).map((e) => Se(e, t));
|
|
79
79
|
}
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/autoLayout.ts
|
|
82
|
-
var
|
|
82
|
+
var we = /* @__PURE__ */ new Set([
|
|
83
83
|
"field:formula",
|
|
84
84
|
"field:summary",
|
|
85
85
|
"field:auto_number",
|
|
86
86
|
"field:autonumber"
|
|
87
|
-
]),
|
|
87
|
+
]), Te = /* @__PURE__ */ new Set([
|
|
88
88
|
"field:textarea",
|
|
89
89
|
"field:markdown",
|
|
90
90
|
"field:html",
|
|
@@ -95,33 +95,33 @@ var Ce = /* @__PURE__ */ new Set([
|
|
|
95
95
|
"html",
|
|
96
96
|
"grid",
|
|
97
97
|
"rich-text"
|
|
98
|
-
]),
|
|
98
|
+
]), Ee = /* @__PURE__ */ new Set([
|
|
99
99
|
"formula",
|
|
100
100
|
"summary",
|
|
101
101
|
"auto_number",
|
|
102
102
|
"autonumber"
|
|
103
103
|
]);
|
|
104
|
-
function Ee(e) {
|
|
105
|
-
return we.has(e);
|
|
106
|
-
}
|
|
107
104
|
function De(e) {
|
|
108
105
|
return Te.has(e);
|
|
109
106
|
}
|
|
110
107
|
function Oe(e) {
|
|
111
|
-
return e
|
|
108
|
+
return Ee.has(e);
|
|
112
109
|
}
|
|
113
110
|
function ke(e) {
|
|
114
|
-
return e
|
|
111
|
+
return e <= 3 ? 1 : e <= 8 ? 2 : e <= 15 ? 3 : 4;
|
|
115
112
|
}
|
|
116
|
-
function Ae(e
|
|
117
|
-
|
|
118
|
-
return r <= 1 ? 1 : e.span === "full" ? r : e.colSpan == null ? e.type && Ee(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);
|
|
113
|
+
function Ae(e) {
|
|
114
|
+
return e && e > 0 ? Math.min(Math.floor(e), 4) : 1;
|
|
119
115
|
}
|
|
120
116
|
function je(e, t, n) {
|
|
121
|
-
let r =
|
|
117
|
+
let r = Ae(t);
|
|
118
|
+
return r <= 1 ? 1 : e.span === "full" ? r : e.colSpan == null ? e.type && De(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);
|
|
119
|
+
}
|
|
120
|
+
function Me(e, t, n) {
|
|
121
|
+
let r = Ae(t);
|
|
122
122
|
return r <= 1 ? e : e.map((e) => {
|
|
123
123
|
if (e.type === "section-divider") return e;
|
|
124
|
-
let t =
|
|
124
|
+
let t = je(e, r, n);
|
|
125
125
|
return t > 1 ? {
|
|
126
126
|
...e,
|
|
127
127
|
colSpan: t
|
|
@@ -131,7 +131,7 @@ function je(e, t, n) {
|
|
|
131
131
|
} : e;
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
var
|
|
134
|
+
var Ne = /* @__PURE__ */ new Set([
|
|
135
135
|
"id",
|
|
136
136
|
"created_at",
|
|
137
137
|
"createdAt",
|
|
@@ -158,89 +158,89 @@ var Me = /* @__PURE__ */ new Set([
|
|
|
158
158
|
"_version",
|
|
159
159
|
"_rev"
|
|
160
160
|
]);
|
|
161
|
-
function
|
|
161
|
+
function Pe(e, t) {
|
|
162
162
|
return e.filter((e) => {
|
|
163
|
-
if (
|
|
163
|
+
if (Ne.has(e.name)) return !1;
|
|
164
164
|
let n = t?.fields?.[e.name];
|
|
165
165
|
return !(n?.hidden === !0 || n?.readonly === !0);
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function Fe(e, t) {
|
|
169
169
|
return e.filter((e) => {
|
|
170
|
-
if (
|
|
170
|
+
if (Ne.has(e.name) || e.type && we.has(e.type)) return !1;
|
|
171
171
|
if (!t?.fields) return !0;
|
|
172
172
|
let n = t.fields[e.name];
|
|
173
|
-
return !n || n.readonly !== !0 && !
|
|
173
|
+
return !n || n.readonly !== !0 && !Oe(n.type);
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function Ie(e, t) {
|
|
177
177
|
return e.filter((e) => {
|
|
178
|
-
if (e.type &&
|
|
178
|
+
if (e.type && we.has(e.type)) return !1;
|
|
179
179
|
let n = t?.fields?.[e.name];
|
|
180
|
-
return !n || !
|
|
180
|
+
return !n || !Oe(n.type);
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
|
-
var
|
|
183
|
+
var Le = {
|
|
184
184
|
1: void 0,
|
|
185
185
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
186
186
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
187
187
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
188
188
|
};
|
|
189
|
-
function Le(e) {
|
|
190
|
-
return Ie[e && e > 0 ? Math.min(Math.floor(e), 4) : 1];
|
|
191
|
-
}
|
|
192
189
|
function Re(e) {
|
|
190
|
+
return Le[e && e > 0 ? Math.min(Math.floor(e), 4) : 1];
|
|
191
|
+
}
|
|
192
|
+
function ze(e) {
|
|
193
193
|
return e <= 1 ? "default" : e === 2 ? "xl" : "full";
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function Be(e, t, n, r) {
|
|
196
196
|
let i = [...e];
|
|
197
|
-
if (i =
|
|
197
|
+
if (i = Pe(i, t), r === "create" && (i = Ie(i, t)), n !== void 0) return i = Me(i, n), {
|
|
198
198
|
fields: i,
|
|
199
199
|
columns: n
|
|
200
200
|
};
|
|
201
|
-
let a =
|
|
202
|
-
return i =
|
|
201
|
+
let a = ke(i.length);
|
|
202
|
+
return i = Me(i, a), {
|
|
203
203
|
fields: i,
|
|
204
204
|
columns: a
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
207
|
//#endregion
|
|
208
208
|
//#region src/occSave.tsx
|
|
209
|
-
var
|
|
209
|
+
var Ve = pe({
|
|
210
210
|
"form.conflictTitle": "Save conflict",
|
|
211
211
|
"form.conflictMessage": "This record was changed by someone else while you were editing. Overwriting will replace their changes with yours.",
|
|
212
212
|
"form.conflictLatestVersion": "Their save: {{time}}",
|
|
213
213
|
"form.conflictOverwrite": "Overwrite",
|
|
214
214
|
"form.keepEditing": "Keep editing"
|
|
215
215
|
}, "form.conflictTitle");
|
|
216
|
-
function
|
|
216
|
+
function He(e) {
|
|
217
217
|
let t = e?.updated_at;
|
|
218
218
|
return typeof t == "string" && t.length > 0 ? t : void 0;
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function Ue(e) {
|
|
221
221
|
if (!e || typeof e != "object") return !1;
|
|
222
222
|
let t = e;
|
|
223
223
|
return t.code === "CONCURRENT_UPDATE" || t.name === "ConcurrentUpdateError";
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function We(e) {
|
|
226
226
|
if (!e) return null;
|
|
227
227
|
let t = /\d{4}-\d{2}-\d{2}[ T]/.test(e) ? e.replace(" ", "T") : e, n = new Date(t);
|
|
228
228
|
return Number.isNaN(n.getTime()) ? null : n.toLocaleString();
|
|
229
229
|
}
|
|
230
|
-
function
|
|
231
|
-
let { t } =
|
|
230
|
+
function Ge() {
|
|
231
|
+
let { t } = Ve(), [n, r] = e.useState(null), i = e.useRef(null), a = e.useCallback((e) => {
|
|
232
232
|
i.current?.(e), i.current = null, r(null);
|
|
233
233
|
}, []);
|
|
234
234
|
e.useEffect(() => () => i.current?.(!1), []);
|
|
235
235
|
let o = e.useCallback(async ({ dataSource: e, objectName: t, recordId: n, payload: a, baseRecord: o }) => {
|
|
236
|
-
let s =
|
|
236
|
+
let s = He(o);
|
|
237
237
|
try {
|
|
238
238
|
return {
|
|
239
239
|
status: "saved",
|
|
240
240
|
result: await e.update(t, n, a, s ? { ifMatch: s } : void 0)
|
|
241
241
|
};
|
|
242
242
|
} catch (o) {
|
|
243
|
-
if (!
|
|
243
|
+
if (!Ue(o)) throw o;
|
|
244
244
|
let s = o.currentVersion;
|
|
245
245
|
if (!await new Promise((e) => {
|
|
246
246
|
i.current = e, r({ currentVersion: typeof s == "string" ? s : void 0 });
|
|
@@ -251,31 +251,31 @@ function We() {
|
|
|
251
251
|
result: await e.update(t, n, a, c ? { ifMatch: c } : void 0)
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
|
-
}, []), s =
|
|
254
|
+
}, []), s = We(n?.currentVersion);
|
|
255
255
|
return {
|
|
256
256
|
saveWithOcc: o,
|
|
257
|
-
conflictDialog: /* @__PURE__ */
|
|
257
|
+
conflictDialog: /* @__PURE__ */ Q(T, {
|
|
258
258
|
open: !!n,
|
|
259
259
|
onOpenChange: (e) => {
|
|
260
260
|
e || a(!1);
|
|
261
261
|
},
|
|
262
|
-
children: /* @__PURE__ */
|
|
262
|
+
children: /* @__PURE__ */ $(O, { children: [/* @__PURE__ */ $(j, { children: [/* @__PURE__ */ $(M, {
|
|
263
263
|
className: "flex items-center gap-2",
|
|
264
|
-
children: [/* @__PURE__ */
|
|
264
|
+
children: [/* @__PURE__ */ Q(ae, {
|
|
265
265
|
className: "h-5 w-5 text-amber-500",
|
|
266
266
|
"aria-hidden": !0
|
|
267
267
|
}), t("form.conflictTitle")]
|
|
268
|
-
}), /* @__PURE__ */
|
|
268
|
+
}), /* @__PURE__ */ $(k, { children: [t("form.conflictMessage"), s && /* @__PURE__ */ Q("span", {
|
|
269
269
|
className: "mt-2 block text-xs text-muted-foreground",
|
|
270
270
|
children: t("form.conflictLatestVersion", { time: s })
|
|
271
|
-
})] })] }), /* @__PURE__ */
|
|
271
|
+
})] })] }), /* @__PURE__ */ $(A, { children: [/* @__PURE__ */ Q("button", {
|
|
272
272
|
type: "button",
|
|
273
|
-
className: q(
|
|
273
|
+
className: J(q({ variant: "outline" })),
|
|
274
274
|
onClick: () => a(!1),
|
|
275
275
|
children: t("form.keepEditing")
|
|
276
|
-
}), /* @__PURE__ */
|
|
276
|
+
}), /* @__PURE__ */ Q("button", {
|
|
277
277
|
type: "button",
|
|
278
|
-
className: q(
|
|
278
|
+
className: J(q({ variant: "destructive" })),
|
|
279
279
|
onClick: () => a(!0),
|
|
280
280
|
children: t("form.conflictOverwrite")
|
|
281
281
|
})] })] })
|
|
@@ -284,8 +284,8 @@ function We() {
|
|
|
284
284
|
}
|
|
285
285
|
//#endregion
|
|
286
286
|
//#region src/TabbedForm.tsx
|
|
287
|
-
var
|
|
288
|
-
let { fieldLabel: a } =
|
|
287
|
+
var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
288
|
+
let { fieldLabel: a } = y(), [o, l] = c(null), [u, d] = c({}), { saveWithOcc: f, conflictDialog: p } = Ge(), [m, g] = c(!0), [_, v] = c(null), b = e.defaultTab || e.sections[0]?.name || e.sections[0]?.label || "tab-0";
|
|
289
289
|
t.useEffect(() => {
|
|
290
290
|
(async () => {
|
|
291
291
|
if (!r) {
|
|
@@ -296,7 +296,7 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
296
296
|
let t = await r.getObjectSchema(e.objectName);
|
|
297
297
|
l(t);
|
|
298
298
|
} catch (e) {
|
|
299
|
-
|
|
299
|
+
v(e);
|
|
300
300
|
}
|
|
301
301
|
})();
|
|
302
302
|
}, [e.objectName, r]);
|
|
@@ -315,7 +315,7 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
315
315
|
x.current = e.recordId, d(n || {});
|
|
316
316
|
} catch (e) {
|
|
317
317
|
if (t) return;
|
|
318
|
-
|
|
318
|
+
v(e);
|
|
319
319
|
} finally {
|
|
320
320
|
t || g(!1);
|
|
321
321
|
}
|
|
@@ -331,7 +331,7 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
331
331
|
r,
|
|
332
332
|
e.objectName
|
|
333
333
|
]);
|
|
334
|
-
let S = n((t) =>
|
|
334
|
+
let S = n((t) => Ce(t, {
|
|
335
335
|
objectSchema: o,
|
|
336
336
|
objectName: e.objectName,
|
|
337
337
|
readOnly: e.readOnly,
|
|
@@ -371,36 +371,36 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
371
371
|
]), w = n(() => {
|
|
372
372
|
e.onCancel && e.onCancel();
|
|
373
373
|
}, [e]), T = (e, t) => e.name || e.label || `tab-${t}`;
|
|
374
|
-
if (_) return /* @__PURE__ */
|
|
374
|
+
if (_) return /* @__PURE__ */ $("div", {
|
|
375
375
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
376
|
-
children: [/* @__PURE__ */
|
|
376
|
+
children: [/* @__PURE__ */ Q("h3", {
|
|
377
377
|
className: "text-red-800 font-semibold",
|
|
378
378
|
children: "Error loading form"
|
|
379
|
-
}), /* @__PURE__ */
|
|
379
|
+
}), /* @__PURE__ */ Q("p", {
|
|
380
380
|
className: "text-red-600 text-sm mt-1",
|
|
381
381
|
children: _.message
|
|
382
382
|
})]
|
|
383
383
|
});
|
|
384
|
-
if (
|
|
384
|
+
if (m) return /* @__PURE__ */ $("div", {
|
|
385
385
|
className: "p-8 text-center",
|
|
386
|
-
children: [/* @__PURE__ */
|
|
386
|
+
children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
|
|
387
387
|
className: "mt-2 text-sm text-gray-600",
|
|
388
388
|
children: "Loading form..."
|
|
389
389
|
})]
|
|
390
390
|
});
|
|
391
|
-
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 =
|
|
391
|
+
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 = Re(O), A = e.sections.map((e, t) => {
|
|
392
392
|
let n = S(e);
|
|
393
393
|
return {
|
|
394
394
|
key: T(e, t),
|
|
395
395
|
label: e.label || `Tab ${t + 1}`,
|
|
396
396
|
description: e.description,
|
|
397
397
|
containerClass: e.gridClassName,
|
|
398
|
-
fields: O > 1 ?
|
|
398
|
+
fields: O > 1 ? Me(n, O, E(e.columns)) : n
|
|
399
399
|
};
|
|
400
400
|
}), j = A.flatMap((e) => e.fields);
|
|
401
|
-
return /* @__PURE__ */
|
|
402
|
-
className:
|
|
403
|
-
children: [/* @__PURE__ */
|
|
401
|
+
return /* @__PURE__ */ $("div", {
|
|
402
|
+
className: J("w-full @container", i, e.className),
|
|
403
|
+
children: [/* @__PURE__ */ Q(h, { schema: {
|
|
404
404
|
type: "form",
|
|
405
405
|
objectName: e.objectName,
|
|
406
406
|
fields: j,
|
|
@@ -425,7 +425,7 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
425
425
|
fieldTabsPosition: e.tabPosition || "top"
|
|
426
426
|
} }), p]
|
|
427
427
|
});
|
|
428
|
-
},
|
|
428
|
+
}, qe = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: a, className: o, gridClassName: s, showBorder: l }) => {
|
|
429
429
|
let [u, d] = c(r), f = {
|
|
430
430
|
1: "grid-cols-1",
|
|
431
431
|
2: "grid-cols-1 md:grid-cols-2",
|
|
@@ -433,43 +433,43 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
433
433
|
4: "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
|
|
434
434
|
}, p = () => {
|
|
435
435
|
n && d(!u);
|
|
436
|
-
}, m = l ?? !!e, h = e || t ? /* @__PURE__ */
|
|
437
|
-
className:
|
|
436
|
+
}, m = l ?? !!e, h = e || t ? /* @__PURE__ */ $("div", {
|
|
437
|
+
className: J("flex items-start gap-2", !m && "mb-4", n && "cursor-pointer select-none"),
|
|
438
438
|
onClick: p,
|
|
439
439
|
role: n ? "button" : void 0,
|
|
440
440
|
"aria-expanded": n ? !u : void 0,
|
|
441
|
-
children: [n && /* @__PURE__ */
|
|
441
|
+
children: [n && /* @__PURE__ */ Q("span", {
|
|
442
442
|
className: "mt-0.5 text-muted-foreground",
|
|
443
|
-
children:
|
|
444
|
-
}), /* @__PURE__ */
|
|
443
|
+
children: Q(u ? le : ce, { className: "h-4 w-4" })
|
|
444
|
+
}), /* @__PURE__ */ $("div", {
|
|
445
445
|
className: "flex-1",
|
|
446
|
-
children: [e && /* @__PURE__ */
|
|
446
|
+
children: [e && /* @__PURE__ */ Q("h3", {
|
|
447
447
|
className: "text-sm font-semibold text-foreground",
|
|
448
448
|
children: e
|
|
449
|
-
}), t && /* @__PURE__ */
|
|
449
|
+
}), t && /* @__PURE__ */ Q("p", {
|
|
450
450
|
className: "text-sm text-muted-foreground mt-0.5",
|
|
451
451
|
children: t
|
|
452
452
|
})]
|
|
453
453
|
})]
|
|
454
|
-
}) : null, g = u ? null : /* @__PURE__ */
|
|
455
|
-
className:
|
|
454
|
+
}) : null, g = u ? null : /* @__PURE__ */ Q("div", {
|
|
455
|
+
className: J("grid gap-4", s || f[i]),
|
|
456
456
|
children: a
|
|
457
457
|
});
|
|
458
|
-
return m ? /* @__PURE__ */
|
|
459
|
-
className:
|
|
460
|
-
children: [h && /* @__PURE__ */
|
|
458
|
+
return m ? /* @__PURE__ */ $(P, {
|
|
459
|
+
className: J("form-section bg-muted/40 shadow-none", o),
|
|
460
|
+
children: [h && /* @__PURE__ */ Q(L, {
|
|
461
461
|
className: "border-b border-border pb-3",
|
|
462
462
|
children: h
|
|
463
|
-
}), g && /* @__PURE__ */
|
|
463
|
+
}), g && /* @__PURE__ */ Q(F, {
|
|
464
464
|
className: "pt-4",
|
|
465
465
|
children: g
|
|
466
466
|
})]
|
|
467
|
-
}) : /* @__PURE__ */
|
|
468
|
-
className:
|
|
467
|
+
}) : /* @__PURE__ */ $("div", {
|
|
468
|
+
className: J("form-section", o),
|
|
469
469
|
children: [h, g]
|
|
470
470
|
});
|
|
471
|
-
},
|
|
472
|
-
let { fieldLabel: a } =
|
|
471
|
+
}, Je = pe({ "wizard.missingRequired": "Please complete the required fields: {{fields}}" }, "wizard.missingRequired"), Ye = d, Xe = ({ schema: e, dataSource: r, className: i }) => {
|
|
472
|
+
let { fieldLabel: a } = y(), { t: s } = Je(), [l, d] = c(null), [f, m] = c({}), { saveWithOcc: g, conflictDialog: _ } = Ge(), [v, b] = c(!0), [x, S] = c(null), [C, w] = c(0), [T, E] = c(/* @__PURE__ */ new Set()), [D, O] = c(!1), [k, A] = c(/* @__PURE__ */ new Set()), [j, M] = c(null), P = t.useId(), [F, I] = c(0), L = t.useRef(!1), R = e.sections.length, z = C === 0, B = C === R - 1;
|
|
473
473
|
t.useEffect(() => {
|
|
474
474
|
(async () => {
|
|
475
475
|
if (!r) {
|
|
@@ -486,12 +486,12 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
486
486
|
}, [e.objectName, r]), t.useEffect(() => {
|
|
487
487
|
(l || !r) && (async () => {
|
|
488
488
|
if (e.mode === "create" || !e.recordId || !r) {
|
|
489
|
-
L.current ||= (
|
|
489
|
+
L.current ||= (m(e.initialData || e.initialValues || {}), !0), b(!1);
|
|
490
490
|
return;
|
|
491
491
|
}
|
|
492
492
|
try {
|
|
493
493
|
let t = await r.findOne(e.objectName, e.recordId);
|
|
494
|
-
|
|
494
|
+
m(t || {});
|
|
495
495
|
} catch (e) {
|
|
496
496
|
S(e);
|
|
497
497
|
} finally {
|
|
@@ -507,7 +507,7 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
507
507
|
r,
|
|
508
508
|
e.objectName
|
|
509
509
|
]);
|
|
510
|
-
let V = n((t) =>
|
|
510
|
+
let V = n((t) => Ce(t, {
|
|
511
511
|
objectSchema: l,
|
|
512
512
|
objectName: e.objectName,
|
|
513
513
|
readOnly: e.readOnly,
|
|
@@ -530,7 +530,7 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
530
530
|
for (let i of V(e)) {
|
|
531
531
|
let e = i?.name;
|
|
532
532
|
if (!e || i.hidden === !0) continue;
|
|
533
|
-
let a =
|
|
533
|
+
let a = p({
|
|
534
534
|
visibleWhen: i.visibleWhen,
|
|
535
535
|
readonlyWhen: i.readonlyWhen,
|
|
536
536
|
requiredWhen: i.requiredWhen
|
|
@@ -538,15 +538,15 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
538
538
|
required: !!i.required,
|
|
539
539
|
readonly: i.readonly === !0
|
|
540
540
|
});
|
|
541
|
-
!(i.visibleOn == null || u(i.visibleOn, t, !0)) || !a.visible || a.readonly || !a.required ||
|
|
541
|
+
!(i.visibleOn == null || u(i.visibleOn, t, !0)) || !a.visible || a.readonly || !a.required || Ye(t[e]) && n.set(r, [...n.get(r) ?? [], i.label || e]);
|
|
542
542
|
}
|
|
543
543
|
}), n;
|
|
544
544
|
}, [e.sections, V]), U = n(async (t) => {
|
|
545
545
|
let n = {
|
|
546
|
-
...
|
|
546
|
+
...f,
|
|
547
547
|
...t
|
|
548
548
|
};
|
|
549
|
-
if (
|
|
549
|
+
if (m(n), E((e) => new Set(e).add(C)), A((e) => {
|
|
550
550
|
if (!e.has(C)) return e;
|
|
551
551
|
let t = new Set(e);
|
|
552
552
|
return t.delete(C), t;
|
|
@@ -555,7 +555,7 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
555
555
|
if (t.size > 0) {
|
|
556
556
|
A(new Set(t.keys()));
|
|
557
557
|
let e = [...t.values()].flat();
|
|
558
|
-
|
|
558
|
+
Y.error(s("wizard.missingRequired", { fields: e.slice(0, 3).join(", ") + (e.length > 3 ? "…" : "") })), W(Math.min(...t.keys()));
|
|
559
559
|
return;
|
|
560
560
|
}
|
|
561
561
|
A(/* @__PURE__ */ new Set()), O(!0);
|
|
@@ -569,7 +569,7 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
569
569
|
objectName: e.objectName,
|
|
570
570
|
recordId: e.recordId,
|
|
571
571
|
payload: n,
|
|
572
|
-
baseRecord:
|
|
572
|
+
baseRecord: f
|
|
573
573
|
});
|
|
574
574
|
if (i.status === "cancelled") return;
|
|
575
575
|
t = i.result;
|
|
@@ -579,14 +579,14 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
579
579
|
let t = e.submitBehavior;
|
|
580
580
|
switch (t.kind) {
|
|
581
581
|
case "redirect":
|
|
582
|
-
|
|
582
|
+
ge(t.url) && setTimeout(() => window.location.assign(t.url), t.delayMs ?? 0);
|
|
583
583
|
break;
|
|
584
584
|
case "continue":
|
|
585
|
-
|
|
585
|
+
m({}), E(/* @__PURE__ */ new Set()), w(0), I((e) => e + 1);
|
|
586
586
|
break;
|
|
587
587
|
default: {
|
|
588
588
|
let n = t.kind === "thank-you" && t.message ? t.message : e.successMessage || (e.mode === "create" ? "Created" : "Saved");
|
|
589
|
-
|
|
589
|
+
Y.success(n), M({
|
|
590
590
|
title: t.kind === "thank-you" ? t.title : void 0,
|
|
591
591
|
message: n
|
|
592
592
|
});
|
|
@@ -594,9 +594,9 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
594
594
|
}
|
|
595
595
|
}
|
|
596
596
|
} else {
|
|
597
|
-
let n =
|
|
597
|
+
let n = _e(e.navigateOnSuccess, t);
|
|
598
598
|
if (n) return window.location.assign(n), t;
|
|
599
|
-
|
|
599
|
+
Y.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved")), e.resetOnSuccess && e.mode === "create" && (m({}), E(/* @__PURE__ */ new Set()), w(0), I((e) => e + 1));
|
|
600
600
|
}
|
|
601
601
|
return t;
|
|
602
602
|
} catch (t) {
|
|
@@ -606,7 +606,7 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
606
606
|
}
|
|
607
607
|
} else W(C + 1);
|
|
608
608
|
}, [
|
|
609
|
-
|
|
609
|
+
f,
|
|
610
610
|
C,
|
|
611
611
|
B,
|
|
612
612
|
e,
|
|
@@ -628,70 +628,70 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
628
628
|
C,
|
|
629
629
|
W
|
|
630
630
|
]);
|
|
631
|
-
if (x) return /* @__PURE__ */
|
|
631
|
+
if (x) return /* @__PURE__ */ $("div", {
|
|
632
632
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
633
|
-
children: [/* @__PURE__ */
|
|
633
|
+
children: [/* @__PURE__ */ Q("h3", {
|
|
634
634
|
className: "text-red-800 font-semibold",
|
|
635
635
|
children: "Error loading form"
|
|
636
|
-
}), /* @__PURE__ */
|
|
636
|
+
}), /* @__PURE__ */ Q("p", {
|
|
637
637
|
className: "text-red-600 text-sm mt-1",
|
|
638
638
|
children: x.message
|
|
639
639
|
})]
|
|
640
640
|
});
|
|
641
|
-
if (
|
|
641
|
+
if (v) return /* @__PURE__ */ $("div", {
|
|
642
642
|
className: "p-8 text-center",
|
|
643
|
-
children: [/* @__PURE__ */
|
|
643
|
+
children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
|
|
644
644
|
className: "mt-2 text-sm text-gray-600",
|
|
645
645
|
children: "Loading form..."
|
|
646
646
|
})]
|
|
647
647
|
});
|
|
648
|
-
if (j) return /* @__PURE__ */
|
|
649
|
-
className:
|
|
650
|
-
children: /* @__PURE__ */
|
|
648
|
+
if (j) return /* @__PURE__ */ Q("div", {
|
|
649
|
+
className: J("w-full", i, e.className),
|
|
650
|
+
children: /* @__PURE__ */ $("div", {
|
|
651
651
|
className: "rounded-md border bg-card p-8 text-center",
|
|
652
|
-
children: [/* @__PURE__ */
|
|
652
|
+
children: [/* @__PURE__ */ Q("h3", {
|
|
653
653
|
className: "text-lg font-semibold",
|
|
654
654
|
children: j.title ?? "Thanks!"
|
|
655
|
-
}), j.message && /* @__PURE__ */
|
|
655
|
+
}), j.message && /* @__PURE__ */ Q("p", {
|
|
656
656
|
className: "mt-2 text-sm text-muted-foreground",
|
|
657
657
|
children: j.message
|
|
658
658
|
})]
|
|
659
659
|
})
|
|
660
660
|
});
|
|
661
|
-
let K = e.sections[C],
|
|
662
|
-
return /* @__PURE__ */
|
|
663
|
-
className:
|
|
661
|
+
let K = e.sections[C], q = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, X = q(e.columns) ?? q(K?.columns) ?? 1, re = Re(X);
|
|
662
|
+
return /* @__PURE__ */ $("div", {
|
|
663
|
+
className: J("w-full @container", i, e.className),
|
|
664
664
|
children: [
|
|
665
|
-
e.showStepIndicator !== !1 && /* @__PURE__ */
|
|
665
|
+
e.showStepIndicator !== !1 && /* @__PURE__ */ Q("nav", {
|
|
666
666
|
"aria-label": "Progress",
|
|
667
667
|
className: "mb-8",
|
|
668
|
-
children: /* @__PURE__ */
|
|
668
|
+
children: /* @__PURE__ */ Q("ol", {
|
|
669
669
|
className: "flex items-center",
|
|
670
670
|
children: e.sections.map((t, n) => {
|
|
671
671
|
let r = n === C, i = T.has(n), a = e.allowSkip || i || n <= C, o = k.has(n);
|
|
672
|
-
return /* @__PURE__ */
|
|
673
|
-
className:
|
|
674
|
-
children: [n !== R - 1 && /* @__PURE__ */
|
|
672
|
+
return /* @__PURE__ */ $("li", {
|
|
673
|
+
className: J("relative flex-1", n !== R - 1 && "pr-8 sm:pr-12"),
|
|
674
|
+
children: [n !== R - 1 && /* @__PURE__ */ Q("div", {
|
|
675
675
|
className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
|
|
676
676
|
"aria-hidden": "true",
|
|
677
|
-
children: /* @__PURE__ */
|
|
678
|
-
}), /* @__PURE__ */
|
|
677
|
+
children: /* @__PURE__ */ Q("div", { className: J("h-full", i ? "bg-primary" : "bg-muted") })
|
|
678
|
+
}), /* @__PURE__ */ $("button", {
|
|
679
679
|
type: "button",
|
|
680
|
-
className:
|
|
680
|
+
className: J("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
|
|
681
681
|
onClick: () => ne(n),
|
|
682
682
|
disabled: !a,
|
|
683
683
|
"data-testid": `wizard-step:${t.name || n}`,
|
|
684
684
|
"data-error": o || void 0,
|
|
685
|
-
children: [/* @__PURE__ */
|
|
686
|
-
className:
|
|
687
|
-
children: o ? /* @__PURE__ */
|
|
685
|
+
children: [/* @__PURE__ */ Q("span", {
|
|
686
|
+
className: J("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"),
|
|
687
|
+
children: o ? /* @__PURE__ */ Q(ie, {
|
|
688
688
|
className: "h-3 w-3 sm:h-4 sm:w-4",
|
|
689
689
|
"aria-hidden": !0
|
|
690
|
-
}) : i ? /* @__PURE__ */
|
|
691
|
-
}), /* @__PURE__ */
|
|
690
|
+
}) : i ? /* @__PURE__ */ Q(oe, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : n + 1
|
|
691
|
+
}), /* @__PURE__ */ Q("span", {
|
|
692
692
|
className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block",
|
|
693
|
-
children: /* @__PURE__ */
|
|
694
|
-
className:
|
|
693
|
+
children: /* @__PURE__ */ Q("span", {
|
|
694
|
+
className: J(o ? "text-destructive" : r ? "text-foreground" : "text-muted-foreground"),
|
|
695
695
|
children: t.label || `Step ${n + 1}`
|
|
696
696
|
})
|
|
697
697
|
})]
|
|
@@ -700,48 +700,48 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
700
700
|
})
|
|
701
701
|
})
|
|
702
702
|
}),
|
|
703
|
-
/* @__PURE__ */
|
|
703
|
+
/* @__PURE__ */ Q("div", {
|
|
704
704
|
className: "min-h-[200px]",
|
|
705
|
-
children: K && /* @__PURE__ */
|
|
705
|
+
children: K && /* @__PURE__ */ Q(qe, {
|
|
706
706
|
label: K.label,
|
|
707
707
|
description: K.description,
|
|
708
708
|
columns: 1,
|
|
709
709
|
className: K.className,
|
|
710
710
|
gridClassName: K.gridClassName,
|
|
711
|
-
children: H.length > 0 ? /* @__PURE__ */
|
|
711
|
+
children: H.length > 0 ? /* @__PURE__ */ Q(h, { schema: {
|
|
712
712
|
type: "form",
|
|
713
713
|
objectName: e.objectName,
|
|
714
714
|
id: P,
|
|
715
|
-
fields:
|
|
716
|
-
columns:
|
|
717
|
-
...
|
|
715
|
+
fields: X > 1 ? Me(H, X, q(K.columns)) : H,
|
|
716
|
+
columns: X,
|
|
717
|
+
...re ? { fieldContainerClass: re } : {},
|
|
718
718
|
layout: "vertical",
|
|
719
|
-
defaultValues:
|
|
719
|
+
defaultValues: f,
|
|
720
720
|
showSubmit: !1,
|
|
721
721
|
showCancel: !1,
|
|
722
722
|
onSubmit: U
|
|
723
|
-
} }, F) : /* @__PURE__ */
|
|
723
|
+
} }, F) : /* @__PURE__ */ Q("form", {
|
|
724
724
|
id: P,
|
|
725
725
|
onSubmit: (e) => {
|
|
726
726
|
e.preventDefault(), U({});
|
|
727
727
|
},
|
|
728
|
-
children: /* @__PURE__ */
|
|
728
|
+
children: /* @__PURE__ */ Q("div", {
|
|
729
729
|
className: "text-center py-8 text-muted-foreground",
|
|
730
730
|
children: "No fields configured for this step"
|
|
731
731
|
})
|
|
732
732
|
})
|
|
733
733
|
})
|
|
734
734
|
}),
|
|
735
|
-
/* @__PURE__ */
|
|
735
|
+
/* @__PURE__ */ $("div", {
|
|
736
736
|
className: "flex items-center justify-between mt-6 pt-4 border-t",
|
|
737
|
-
children: [/* @__PURE__ */
|
|
737
|
+
children: [/* @__PURE__ */ Q("div", { children: e.showCancel !== !1 && /* @__PURE__ */ Q(N, {
|
|
738
738
|
variant: "ghost",
|
|
739
739
|
onClick: te,
|
|
740
740
|
children: e.cancelText || "Cancel"
|
|
741
|
-
}) }), /* @__PURE__ */
|
|
741
|
+
}) }), /* @__PURE__ */ $("div", {
|
|
742
742
|
className: "flex items-center gap-2",
|
|
743
743
|
children: [
|
|
744
|
-
/* @__PURE__ */
|
|
744
|
+
/* @__PURE__ */ $("span", {
|
|
745
745
|
className: "text-sm text-muted-foreground mr-2",
|
|
746
746
|
children: [
|
|
747
747
|
"Step ",
|
|
@@ -750,23 +750,23 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
750
750
|
R
|
|
751
751
|
]
|
|
752
752
|
}),
|
|
753
|
-
!z && /* @__PURE__ */
|
|
753
|
+
!z && /* @__PURE__ */ $(N, {
|
|
754
754
|
variant: "outline",
|
|
755
755
|
onClick: G,
|
|
756
|
-
children: [/* @__PURE__ */ Z
|
|
756
|
+
children: [/* @__PURE__ */ Q(Z, { className: "h-4 w-4 mr-1" }), e.prevText || "Back"]
|
|
757
757
|
}),
|
|
758
|
-
B ? /* @__PURE__ */
|
|
758
|
+
B ? /* @__PURE__ */ $(N, {
|
|
759
759
|
type: "submit",
|
|
760
760
|
form: P,
|
|
761
761
|
disabled: D || e.mode === "view",
|
|
762
|
-
children: [D && /* @__PURE__ */
|
|
762
|
+
children: [D && /* @__PURE__ */ Q(ue, {
|
|
763
763
|
className: "mr-2 h-4 w-4 animate-spin",
|
|
764
764
|
"aria-hidden": !0
|
|
765
765
|
}), D ? "Submitting..." : e.submitText || (e.mode === "create" ? "Create" : "Update")]
|
|
766
|
-
}) : /* @__PURE__ */
|
|
766
|
+
}) : /* @__PURE__ */ $(N, {
|
|
767
767
|
type: "submit",
|
|
768
768
|
form: P,
|
|
769
|
-
children: [e.nextText || "Next", /* @__PURE__ */
|
|
769
|
+
children: [e.nextText || "Next", /* @__PURE__ */ Q(le, { className: "h-4 w-4 ml-1" })]
|
|
770
770
|
})
|
|
771
771
|
]
|
|
772
772
|
})]
|
|
@@ -774,8 +774,8 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
774
774
|
_
|
|
775
775
|
]
|
|
776
776
|
});
|
|
777
|
-
},
|
|
778
|
-
let { fieldLabel: a } =
|
|
777
|
+
}, Ze = ({ schema: e, dataSource: t, className: r }) => {
|
|
778
|
+
let { fieldLabel: a } = y(), [l, u] = c(null), [d, f] = c({}), { saveWithOcc: p, conflictDialog: m } = Ge(), [g, _] = c(!0), [v, b] = c(null);
|
|
779
779
|
i(() => {
|
|
780
780
|
(async () => {
|
|
781
781
|
if (!t) {
|
|
@@ -825,7 +825,7 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
825
825
|
t,
|
|
826
826
|
e.objectName
|
|
827
827
|
]);
|
|
828
|
-
let S = n((t) =>
|
|
828
|
+
let S = n((t) => Ce(t, {
|
|
829
829
|
objectSchema: l,
|
|
830
830
|
objectName: e.objectName,
|
|
831
831
|
readOnly: e.readOnly,
|
|
@@ -865,24 +865,24 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
865
865
|
]), w = n(() => {
|
|
866
866
|
e.onCancel && e.onCancel();
|
|
867
867
|
}, [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;
|
|
868
|
-
if (
|
|
868
|
+
if (v) return /* @__PURE__ */ $("div", {
|
|
869
869
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
870
|
-
children: [/* @__PURE__ */
|
|
870
|
+
children: [/* @__PURE__ */ Q("h3", {
|
|
871
871
|
className: "text-red-800 font-semibold",
|
|
872
872
|
children: "Error loading form"
|
|
873
|
-
}), /* @__PURE__ */
|
|
873
|
+
}), /* @__PURE__ */ Q("p", {
|
|
874
874
|
className: "text-red-600 text-sm mt-1",
|
|
875
|
-
children:
|
|
875
|
+
children: v.message
|
|
876
876
|
})]
|
|
877
877
|
});
|
|
878
|
-
if (g) return /* @__PURE__ */
|
|
878
|
+
if (g) return /* @__PURE__ */ $("div", {
|
|
879
879
|
className: "p-8 text-center",
|
|
880
|
-
children: [/* @__PURE__ */
|
|
880
|
+
children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
|
|
881
881
|
className: "mt-2 text-sm text-gray-600",
|
|
882
882
|
children: "Loading form..."
|
|
883
883
|
})]
|
|
884
884
|
});
|
|
885
|
-
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 =
|
|
885
|
+
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 = Re(M), P = (e, t) => {
|
|
886
886
|
let n = [];
|
|
887
887
|
return e.forEach((e, r) => {
|
|
888
888
|
let i = S(e);
|
|
@@ -893,7 +893,7 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
893
893
|
type: "section-divider",
|
|
894
894
|
colSpan: 4,
|
|
895
895
|
className: e.className
|
|
896
|
-
}), n.push(...M > 1 ?
|
|
896
|
+
}), n.push(...M > 1 ? Me(i, M, A(e.columns)) : i));
|
|
897
897
|
}), n;
|
|
898
898
|
}, F = [{
|
|
899
899
|
key: "primary",
|
|
@@ -908,9 +908,9 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
908
908
|
fields: P(e.sections, e.key),
|
|
909
909
|
containerClass: e.sections.length === 1 ? e.sections[0].gridClassName : void 0
|
|
910
910
|
})).filter((e) => e.fields.length > 0);
|
|
911
|
-
return /* @__PURE__ */
|
|
912
|
-
className:
|
|
913
|
-
children: [/* @__PURE__ */
|
|
911
|
+
return /* @__PURE__ */ $("div", {
|
|
912
|
+
className: J("w-full @container", r, e.className),
|
|
913
|
+
children: [/* @__PURE__ */ Q(h, { schema: {
|
|
914
914
|
type: "form",
|
|
915
915
|
objectName: e.objectName,
|
|
916
916
|
fields: F.flatMap((e) => e.fields),
|
|
@@ -932,9 +932,9 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
932
932
|
})),
|
|
933
933
|
fieldPanesOrientation: O,
|
|
934
934
|
fieldPanesResizable: e.splitResizable !== !1
|
|
935
|
-
} }),
|
|
935
|
+
} }), m]
|
|
936
936
|
});
|
|
937
|
-
},
|
|
937
|
+
}, Qe = /* @__PURE__ */ new Set([
|
|
938
938
|
"id",
|
|
939
939
|
"_id",
|
|
940
940
|
"created_at",
|
|
@@ -943,7 +943,7 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
943
943
|
"updatedAt",
|
|
944
944
|
"organization_id",
|
|
945
945
|
"organizationId"
|
|
946
|
-
]),
|
|
946
|
+
]), $e = /* @__PURE__ */ new Set([
|
|
947
947
|
"formula",
|
|
948
948
|
"summary",
|
|
949
949
|
"rollup",
|
|
@@ -952,15 +952,15 @@ var Ge = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
952
952
|
"autonumber",
|
|
953
953
|
"computed"
|
|
954
954
|
]);
|
|
955
|
-
function
|
|
955
|
+
function et(e, t) {
|
|
956
956
|
if (!e || typeof e != "object") return e;
|
|
957
957
|
let n = {}, r = t?.fields;
|
|
958
|
-
for (let [t, i] of Object.entries(e)) if (!
|
|
958
|
+
for (let [t, i] of Object.entries(e)) if (!Qe.has(t)) {
|
|
959
959
|
if (r) {
|
|
960
960
|
let e = r[t];
|
|
961
961
|
if (!e) continue;
|
|
962
962
|
let n = String(e.type || "").toLowerCase();
|
|
963
|
-
if (
|
|
963
|
+
if ($e.has(n) || e.computed === !0 || e.formula || e.readOnly === !0 || e.readonly === !0) continue;
|
|
964
964
|
}
|
|
965
965
|
n[t] = i;
|
|
966
966
|
}
|
|
@@ -968,31 +968,31 @@ function $e(e, t) {
|
|
|
968
968
|
}
|
|
969
969
|
//#endregion
|
|
970
970
|
//#region src/masterDetailTx.ts
|
|
971
|
-
var
|
|
971
|
+
var tt = (e) => e == null ? void 0 : e.id ?? e._id ?? e.recordId, nt = (e, t) => t ? et(e, t) : e, rt = /* @__PURE__ */ new Set([
|
|
972
972
|
"id",
|
|
973
973
|
"_id",
|
|
974
974
|
"recordId"
|
|
975
975
|
]);
|
|
976
|
-
function
|
|
977
|
-
return !e || Object.entries(e).every(([e, n]) => e === t ||
|
|
976
|
+
function it(e, t) {
|
|
977
|
+
return !e || Object.entries(e).every(([e, n]) => e === t || rt.has(e) ? !0 : n == null || n === "");
|
|
978
978
|
}
|
|
979
|
-
function
|
|
979
|
+
function at(e, t, n) {
|
|
980
980
|
let r = [{
|
|
981
981
|
object: e,
|
|
982
982
|
action: "create",
|
|
983
983
|
data: t
|
|
984
984
|
}];
|
|
985
|
-
for (let e of n) for (let t of e.rows)
|
|
985
|
+
for (let e of n) for (let t of e.rows) it(t, e.relationshipField) || r.push({
|
|
986
986
|
object: e.childObject,
|
|
987
987
|
action: "create",
|
|
988
988
|
data: {
|
|
989
|
-
...
|
|
989
|
+
...nt(t, e.childSchema),
|
|
990
990
|
[e.relationshipField]: { $ref: 0 }
|
|
991
991
|
}
|
|
992
992
|
});
|
|
993
993
|
return r;
|
|
994
994
|
}
|
|
995
|
-
function
|
|
995
|
+
function ot(e, t, n, r) {
|
|
996
996
|
let i = [{
|
|
997
997
|
object: e,
|
|
998
998
|
action: "update",
|
|
@@ -1003,21 +1003,21 @@ function at(e, t, n, r) {
|
|
|
1003
1003
|
let n = (e.rows || []).map((n) => ({
|
|
1004
1004
|
...n,
|
|
1005
1005
|
[e.relationshipField]: t
|
|
1006
|
-
})), { toCreate: r, toUpdate: a, toDelete: o } =
|
|
1006
|
+
})), { toCreate: r, toUpdate: a, toDelete: o } = st(e.original || [], n);
|
|
1007
1007
|
for (let t of r) {
|
|
1008
|
-
if (
|
|
1008
|
+
if (it(t, e.relationshipField)) continue;
|
|
1009
1009
|
let { id: n, _id: r, recordId: a, ...o } = t;
|
|
1010
1010
|
i.push({
|
|
1011
1011
|
object: e.childObject,
|
|
1012
1012
|
action: "create",
|
|
1013
|
-
data:
|
|
1013
|
+
data: nt(o, e.childSchema)
|
|
1014
1014
|
});
|
|
1015
1015
|
}
|
|
1016
1016
|
for (let t of a) i.push({
|
|
1017
1017
|
object: e.childObject,
|
|
1018
1018
|
action: "update",
|
|
1019
|
-
id:
|
|
1020
|
-
data:
|
|
1019
|
+
id: tt(t),
|
|
1020
|
+
data: nt(t, e.childSchema)
|
|
1021
1021
|
});
|
|
1022
1022
|
for (let t of o) i.push({
|
|
1023
1023
|
object: e.childObject,
|
|
@@ -1027,15 +1027,15 @@ function at(e, t, n, r) {
|
|
|
1027
1027
|
}
|
|
1028
1028
|
return i;
|
|
1029
1029
|
}
|
|
1030
|
-
function
|
|
1031
|
-
let n = new Set(t.map(
|
|
1030
|
+
function st(e, t) {
|
|
1031
|
+
let n = new Set(t.map(tt).filter(Boolean));
|
|
1032
1032
|
return {
|
|
1033
|
-
toCreate: t.filter((e) => !
|
|
1034
|
-
toUpdate: t.filter((e) =>
|
|
1035
|
-
toDelete: (e || []).map(
|
|
1033
|
+
toCreate: t.filter((e) => !tt(e)),
|
|
1034
|
+
toUpdate: t.filter((e) => tt(e)),
|
|
1035
|
+
toDelete: (e || []).map(tt).filter((e) => !!e && !n.has(e))
|
|
1036
1036
|
};
|
|
1037
1037
|
}
|
|
1038
|
-
function
|
|
1038
|
+
function ct(e, t) {
|
|
1039
1039
|
return Array.isArray(e) ? e.reduce((e, n) => {
|
|
1040
1040
|
let r = Number(n?.[t]);
|
|
1041
1041
|
return e + (Number.isFinite(r) ? r : 0);
|
|
@@ -1043,7 +1043,7 @@ function st(e, t) {
|
|
|
1043
1043
|
}
|
|
1044
1044
|
//#endregion
|
|
1045
1045
|
//#region src/deriveMasterDetail.ts
|
|
1046
|
-
var
|
|
1046
|
+
var lt = /* @__PURE__ */ new Set([
|
|
1047
1047
|
"id",
|
|
1048
1048
|
"_id",
|
|
1049
1049
|
"recordId",
|
|
@@ -1059,14 +1059,14 @@ var ct = /* @__PURE__ */ new Set([
|
|
|
1059
1059
|
"tenant_id",
|
|
1060
1060
|
"space",
|
|
1061
1061
|
"owner"
|
|
1062
|
-
]),
|
|
1062
|
+
]), ut = /* @__PURE__ */ new Set([
|
|
1063
1063
|
"position",
|
|
1064
1064
|
"sort_order",
|
|
1065
1065
|
"sequence",
|
|
1066
1066
|
"line_no",
|
|
1067
1067
|
"line_number",
|
|
1068
1068
|
"sort"
|
|
1069
|
-
]),
|
|
1069
|
+
]), dt = /* @__PURE__ */ new Set([
|
|
1070
1070
|
"formula",
|
|
1071
1071
|
"summary",
|
|
1072
1072
|
"rollup",
|
|
@@ -1082,7 +1082,7 @@ var ct = /* @__PURE__ */ new Set([
|
|
|
1082
1082
|
"markdown",
|
|
1083
1083
|
"richtext"
|
|
1084
1084
|
]);
|
|
1085
|
-
function
|
|
1085
|
+
function ft(e) {
|
|
1086
1086
|
switch (e) {
|
|
1087
1087
|
case "number":
|
|
1088
1088
|
case "percent":
|
|
@@ -1105,11 +1105,11 @@ function dt(e) {
|
|
|
1105
1105
|
default: return "text";
|
|
1106
1106
|
}
|
|
1107
1107
|
}
|
|
1108
|
-
var
|
|
1109
|
-
function
|
|
1110
|
-
e.multiple == null && t?.multiple && (e.multiple = !0), e.accept ?? (Array.isArray(t?.accept) && t.accept.length > 0 ? e.accept = t.accept :
|
|
1108
|
+
var pt = /* @__PURE__ */ new Set(["image", "avatar"]);
|
|
1109
|
+
function mt(e, t) {
|
|
1110
|
+
e.multiple == null && t?.multiple && (e.multiple = !0), e.accept ?? (Array.isArray(t?.accept) && t.accept.length > 0 ? e.accept = t.accept : pt.has(t?.type) && (e.accept = ["image/*"]));
|
|
1111
1111
|
}
|
|
1112
|
-
function
|
|
1112
|
+
function ht(e) {
|
|
1113
1113
|
if (e?.type === "boolean" || e?.type === "toggle") return [{
|
|
1114
1114
|
label: "Yes",
|
|
1115
1115
|
value: "true"
|
|
@@ -1126,7 +1126,7 @@ function mt(e) {
|
|
|
1126
1126
|
value: String(e)
|
|
1127
1127
|
});
|
|
1128
1128
|
}
|
|
1129
|
-
function
|
|
1129
|
+
function gt(e, t) {
|
|
1130
1130
|
let n = e?.fields;
|
|
1131
1131
|
if (!n || typeof n != "object") return;
|
|
1132
1132
|
let r;
|
|
@@ -1139,7 +1139,7 @@ function ht(e, t) {
|
|
|
1139
1139
|
}
|
|
1140
1140
|
return r;
|
|
1141
1141
|
}
|
|
1142
|
-
var
|
|
1142
|
+
var _t = [
|
|
1143
1143
|
"name",
|
|
1144
1144
|
"title",
|
|
1145
1145
|
"subject",
|
|
@@ -1147,7 +1147,7 @@ var gt = [
|
|
|
1147
1147
|
"full_name",
|
|
1148
1148
|
"display_name",
|
|
1149
1149
|
"code"
|
|
1150
|
-
],
|
|
1150
|
+
], vt = {
|
|
1151
1151
|
select: 0,
|
|
1152
1152
|
currency: 1,
|
|
1153
1153
|
number: 1,
|
|
@@ -1155,18 +1155,18 @@ var gt = [
|
|
|
1155
1155
|
date: 3,
|
|
1156
1156
|
text: 4
|
|
1157
1157
|
};
|
|
1158
|
-
function
|
|
1159
|
-
return (e.type ?
|
|
1158
|
+
function yt(e) {
|
|
1159
|
+
return (e.type ? vt[e.type] : void 0) ?? 5;
|
|
1160
1160
|
}
|
|
1161
|
-
function
|
|
1161
|
+
function bt(e, t) {
|
|
1162
1162
|
if (t <= 0 || e.length <= t) return e;
|
|
1163
|
-
let n = /* @__PURE__ */ new Set(), r = e.find((e) =>
|
|
1163
|
+
let n = /* @__PURE__ */ new Set(), r = e.find((e) => _t.includes(e.field)) ?? e[0];
|
|
1164
1164
|
r && n.add(r.field);
|
|
1165
1165
|
for (let t of e) t.required && n.add(t.field);
|
|
1166
1166
|
let i = e.map((e, t) => ({
|
|
1167
1167
|
c: e,
|
|
1168
1168
|
i: t
|
|
1169
|
-
})).filter(({ c: e }) => !n.has(e.field)).sort((e, t) =>
|
|
1169
|
+
})).filter(({ c: e }) => !n.has(e.field)).sort((e, t) => yt(e.c) - yt(t.c) || e.i - t.i);
|
|
1170
1170
|
for (let { c: e } of i) {
|
|
1171
1171
|
if (n.size >= t) break;
|
|
1172
1172
|
n.add(e.field);
|
|
@@ -1176,60 +1176,60 @@ function yt(e, t) {
|
|
|
1176
1176
|
defaultHidden: !0
|
|
1177
1177
|
});
|
|
1178
1178
|
}
|
|
1179
|
-
function
|
|
1179
|
+
function xt(e, t = {}) {
|
|
1180
1180
|
let n = e?.fields;
|
|
1181
1181
|
if (!n || typeof n != "object") return [];
|
|
1182
1182
|
let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
|
|
1183
1183
|
for (let [e, t] of Object.entries(n)) {
|
|
1184
1184
|
let n = t;
|
|
1185
|
-
if (
|
|
1185
|
+
if (lt.has(e) || r.has(e) || ut.has(e) || n?.system || n?.readonly || n?.hidden || dt.has(n?.type)) continue;
|
|
1186
1186
|
let a = {
|
|
1187
1187
|
field: e,
|
|
1188
1188
|
label: n?.label || e,
|
|
1189
|
-
type:
|
|
1189
|
+
type: ft(n?.type),
|
|
1190
1190
|
required: !!n?.required
|
|
1191
|
-
}, o =
|
|
1192
|
-
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" &&
|
|
1191
|
+
}, o = ht(n);
|
|
1192
|
+
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" && mt(a, n), n?.readonlyWhen && (a.readonlyWhen = n.readonlyWhen), n?.requiredWhen && (a.requiredWhen = n.requiredWhen);
|
|
1193
1193
|
let s = typeof n?.expression == "string" ? n.expression : n?.expression?.source;
|
|
1194
1194
|
s && typeof s == "string" && (a.computed = !0, a.expr = s, a.required = !1, typeof n?.scale == "number" && (a.scale = n.scale)), i.push(a);
|
|
1195
1195
|
}
|
|
1196
|
-
return
|
|
1196
|
+
return bt(i, t.maxColumns ?? 6);
|
|
1197
1197
|
}
|
|
1198
|
-
function
|
|
1198
|
+
function St(e, t) {
|
|
1199
1199
|
let n = e ?? [], r = t?.fields;
|
|
1200
1200
|
return !n.length || !r || typeof r != "object" ? n : n.map((e) => {
|
|
1201
1201
|
if (e.type) return e;
|
|
1202
1202
|
let t = r[e.field];
|
|
1203
1203
|
if (!t) return e;
|
|
1204
|
-
let n =
|
|
1204
|
+
let n = ft(t?.type), i = {
|
|
1205
1205
|
...e,
|
|
1206
1206
|
type: n
|
|
1207
1207
|
};
|
|
1208
1208
|
i.label ??= t?.label || e.field, i.required ??= !!t?.required;
|
|
1209
|
-
let a =
|
|
1210
|
-
n === "select" && a && !i.options && (i.options = a), n === "lookup" && (i.reference ??= t?.reference, i.displayField ??= t?.display_field || t?.reference_field), n === "file" &&
|
|
1209
|
+
let a = ht(t);
|
|
1210
|
+
n === "select" && a && !i.options && (i.options = a), n === "lookup" && (i.reference ??= t?.reference, i.displayField ??= t?.display_field || t?.reference_field), n === "file" && mt(i, t), i.readonlyWhen == null && t?.readonlyWhen && (i.readonlyWhen = t.readonlyWhen), i.requiredWhen == null && t?.requiredWhen && (i.requiredWhen = t.requiredWhen);
|
|
1211
1211
|
let o = typeof t?.expression == "string" ? t.expression : t?.expression?.source;
|
|
1212
1212
|
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;
|
|
1213
1213
|
});
|
|
1214
1214
|
}
|
|
1215
|
-
var
|
|
1215
|
+
var Ct = /* @__PURE__ */ new Set([
|
|
1216
1216
|
"formula",
|
|
1217
1217
|
"summary",
|
|
1218
1218
|
"rollup",
|
|
1219
1219
|
"autonumber",
|
|
1220
1220
|
"auto_number"
|
|
1221
1221
|
]);
|
|
1222
|
-
function
|
|
1222
|
+
function wt(e, t = {}) {
|
|
1223
1223
|
let n = e?.fields;
|
|
1224
1224
|
if (!n || typeof n != "object") return [];
|
|
1225
1225
|
let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
|
|
1226
1226
|
for (let [e, t] of Object.entries(n)) {
|
|
1227
1227
|
let n = t;
|
|
1228
|
-
|
|
1228
|
+
lt.has(e) || r.has(e) || ut.has(e) || n?.system || n?.hidden || Ct.has(n?.type) || i.push(e);
|
|
1229
1229
|
}
|
|
1230
1230
|
return i;
|
|
1231
1231
|
}
|
|
1232
|
-
var
|
|
1232
|
+
var Tt = /* @__PURE__ */ new Set([
|
|
1233
1233
|
"textarea",
|
|
1234
1234
|
"richtext",
|
|
1235
1235
|
"html",
|
|
@@ -1238,17 +1238,17 @@ var wt = /* @__PURE__ */ new Set([
|
|
|
1238
1238
|
"json",
|
|
1239
1239
|
"location",
|
|
1240
1240
|
"address"
|
|
1241
|
-
]),
|
|
1241
|
+
]), Et = /* @__PURE__ */ new Set([
|
|
1242
1242
|
"file",
|
|
1243
1243
|
"image",
|
|
1244
1244
|
"avatar"
|
|
1245
1245
|
]);
|
|
1246
|
-
function
|
|
1246
|
+
function Dt(e, t, n = {}) {
|
|
1247
1247
|
if (t === "grid" || t === "form") return t;
|
|
1248
|
-
let r = e?.fields ?? {}, i =
|
|
1249
|
-
return i.some((e) =>
|
|
1248
|
+
let r = e?.fields ?? {}, i = wt(e, { relationshipField: n.relationshipField });
|
|
1249
|
+
return i.some((e) => Tt.has(r[e]?.type)) || i.filter((e) => Et.has(r[e]?.type)).length >= 2 || i.length > 8 ? "form" : "grid";
|
|
1250
1250
|
}
|
|
1251
|
-
var
|
|
1251
|
+
var Ot = [
|
|
1252
1252
|
"amount",
|
|
1253
1253
|
"total",
|
|
1254
1254
|
"subtotal",
|
|
@@ -1256,33 +1256,33 @@ var Dt = [
|
|
|
1256
1256
|
"line_amount",
|
|
1257
1257
|
"net_amount"
|
|
1258
1258
|
];
|
|
1259
|
-
function
|
|
1259
|
+
function kt(e) {
|
|
1260
1260
|
let t = e.filter((e) => e.type === "number" || e.type === "currency");
|
|
1261
1261
|
if (t.length === 0) return;
|
|
1262
1262
|
let n = t.find((e) => e.computed);
|
|
1263
1263
|
if (n) return n.field;
|
|
1264
|
-
let r = t.find((e) =>
|
|
1264
|
+
let r = t.find((e) => Ot.includes(e.field));
|
|
1265
1265
|
if (r) return r.field;
|
|
1266
1266
|
let i = [...t].reverse().find((e) => e.type === "currency");
|
|
1267
1267
|
return i ? i.field : t[t.length - 1].field;
|
|
1268
1268
|
}
|
|
1269
|
-
function
|
|
1270
|
-
let i = r.relationshipField ||
|
|
1269
|
+
function At(e, t, n, r = {}) {
|
|
1270
|
+
let i = r.relationshipField || gt(t, n);
|
|
1271
1271
|
if (!i) throw Error(`MasterDetailForm: could not find a lookup/master_detail field on "${e}" referencing "${n}". Set relationshipField explicitly.`);
|
|
1272
|
-
let a = r.columns?.length ?
|
|
1272
|
+
let a = r.columns?.length ? St(r.columns, t) : xt(t, { relationshipField: i }), o = r.amountField || kt(a);
|
|
1273
1273
|
return {
|
|
1274
1274
|
childObject: e,
|
|
1275
1275
|
relationshipField: i,
|
|
1276
1276
|
columns: a,
|
|
1277
|
-
formFields:
|
|
1278
|
-
mode:
|
|
1277
|
+
formFields: wt(t, { relationshipField: i }),
|
|
1278
|
+
mode: Dt(t, r.inlineEdit ?? (t?.fields)?.[i]?.inlineEdit, { relationshipField: i }),
|
|
1279
1279
|
amountField: o,
|
|
1280
|
-
sortField: Object.keys(t?.fields ?? {}).find((e) =>
|
|
1280
|
+
sortField: Object.keys(t?.fields ?? {}).find((e) => ut.has(e))
|
|
1281
1281
|
};
|
|
1282
1282
|
}
|
|
1283
1283
|
//#endregion
|
|
1284
1284
|
//#region src/MasterDetailForm.tsx
|
|
1285
|
-
function
|
|
1285
|
+
function jt(e) {
|
|
1286
1286
|
if (!e) return {};
|
|
1287
1287
|
let t = {};
|
|
1288
1288
|
return e.querySelectorAll("[name]").forEach((e) => {
|
|
@@ -1314,13 +1314,13 @@ function At(e) {
|
|
|
1314
1314
|
}
|
|
1315
1315
|
}), t;
|
|
1316
1316
|
}
|
|
1317
|
-
var
|
|
1317
|
+
var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, formKey: o, onRowExpand: l, onAddViaForm: u }) => {
|
|
1318
1318
|
let [d, f] = c({}), p = s("");
|
|
1319
1319
|
i(() => {
|
|
1320
1320
|
let e = r.current;
|
|
1321
1321
|
if (!e) return;
|
|
1322
1322
|
let t = () => {
|
|
1323
|
-
let t =
|
|
1323
|
+
let t = jt(e), n;
|
|
1324
1324
|
try {
|
|
1325
1325
|
n = JSON.stringify(t);
|
|
1326
1326
|
} catch {
|
|
@@ -1344,16 +1344,16 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1344
1344
|
o,
|
|
1345
1345
|
e.length
|
|
1346
1346
|
]);
|
|
1347
|
-
let m = d[a], h = m === void 0 ? null : Number.isFinite(Number(m)) ? Number(m) : 0, g = e.reduce((e, n, r) => e +
|
|
1347
|
+
let m = d[a], h = m === void 0 ? null : Number.isFinite(Number(m)) ? Number(m) : 0, g = e.reduce((e, n, r) => e + ct(t[r]?.rows ?? [], n.amountField || "amount"), 0), _ = h !== null && e.some((e) => !!e.amountField), v = h ?? 0, y = v / 100 * g, b = g + y, S = (e) => `¥${e.toLocaleString(void 0, {
|
|
1348
1348
|
minimumFractionDigits: 2,
|
|
1349
1349
|
maximumFractionDigits: 2
|
|
1350
1350
|
})}`;
|
|
1351
|
-
return /* @__PURE__ */
|
|
1351
|
+
return /* @__PURE__ */ $(me, { children: [e.map((e, r) => /* @__PURE__ */ $("section", {
|
|
1352
1352
|
className: "space-y-2",
|
|
1353
|
-
children: [/* @__PURE__ */
|
|
1353
|
+
children: [/* @__PURE__ */ Q("h3", {
|
|
1354
1354
|
className: "text-sm font-medium text-foreground",
|
|
1355
1355
|
children: e.title || "Line Items"
|
|
1356
|
-
}), e.columns?.length ? /* @__PURE__ */
|
|
1356
|
+
}), e.columns?.length ? /* @__PURE__ */ Q(x, {
|
|
1357
1357
|
value: t[r]?.rows ?? [],
|
|
1358
1358
|
onChange: (e) => n(r, e),
|
|
1359
1359
|
contextRecord: d,
|
|
@@ -1368,55 +1368,55 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1368
1368
|
max_rows: e.maxRows,
|
|
1369
1369
|
add_label: e.inlineMode === "form" ? e.addLabel || "Add" : e.addLabel
|
|
1370
1370
|
}
|
|
1371
|
-
}) : /* @__PURE__ */
|
|
1371
|
+
}) : /* @__PURE__ */ Q("p", {
|
|
1372
1372
|
className: "py-4 text-sm text-muted-foreground",
|
|
1373
1373
|
children: "Loading columns…"
|
|
1374
1374
|
})]
|
|
1375
|
-
}, `${e.childObject}-${r}`)), _ && /* @__PURE__ */
|
|
1375
|
+
}, `${e.childObject}-${r}`)), _ && /* @__PURE__ */ Q("div", {
|
|
1376
1376
|
className: "flex justify-end",
|
|
1377
|
-
children: /* @__PURE__ */
|
|
1377
|
+
children: /* @__PURE__ */ $("dl", {
|
|
1378
1378
|
className: "w-64 space-y-1.5 text-sm",
|
|
1379
1379
|
"data-testid": "md-totals",
|
|
1380
1380
|
children: [
|
|
1381
|
-
/* @__PURE__ */
|
|
1381
|
+
/* @__PURE__ */ $("div", {
|
|
1382
1382
|
className: "flex items-center justify-between",
|
|
1383
|
-
children: [/* @__PURE__ */
|
|
1383
|
+
children: [/* @__PURE__ */ Q("dt", {
|
|
1384
1384
|
className: "text-muted-foreground",
|
|
1385
1385
|
children: "Subtotal"
|
|
1386
|
-
}), /* @__PURE__ */
|
|
1386
|
+
}), /* @__PURE__ */ Q("dd", {
|
|
1387
1387
|
className: "tabular-nums",
|
|
1388
1388
|
"data-testid": "md-subtotal",
|
|
1389
1389
|
children: S(g)
|
|
1390
1390
|
})]
|
|
1391
1391
|
}),
|
|
1392
|
-
/* @__PURE__ */
|
|
1392
|
+
/* @__PURE__ */ $("div", {
|
|
1393
1393
|
className: "flex items-center justify-between",
|
|
1394
|
-
children: [/* @__PURE__ */
|
|
1394
|
+
children: [/* @__PURE__ */ $("dt", {
|
|
1395
1395
|
className: "text-muted-foreground",
|
|
1396
1396
|
children: [
|
|
1397
1397
|
"Tax (",
|
|
1398
1398
|
v,
|
|
1399
1399
|
"%)"
|
|
1400
1400
|
]
|
|
1401
|
-
}), /* @__PURE__ */
|
|
1401
|
+
}), /* @__PURE__ */ Q("dd", {
|
|
1402
1402
|
className: "tabular-nums",
|
|
1403
1403
|
"data-testid": "md-tax",
|
|
1404
1404
|
children: S(y)
|
|
1405
1405
|
})]
|
|
1406
1406
|
}),
|
|
1407
|
-
/* @__PURE__ */
|
|
1407
|
+
/* @__PURE__ */ $("div", {
|
|
1408
1408
|
className: "flex items-center justify-between border-t border-border pt-1.5 text-base font-semibold",
|
|
1409
|
-
children: [/* @__PURE__ */
|
|
1409
|
+
children: [/* @__PURE__ */ Q("dt", { children: "Total" }), /* @__PURE__ */ Q("dd", {
|
|
1410
1410
|
className: "tabular-nums",
|
|
1411
1411
|
"data-testid": "md-grand-total",
|
|
1412
|
-
children: S(
|
|
1412
|
+
children: S(b)
|
|
1413
1413
|
})]
|
|
1414
1414
|
})
|
|
1415
1415
|
]
|
|
1416
1416
|
})
|
|
1417
1417
|
})] });
|
|
1418
|
-
},
|
|
1419
|
-
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),
|
|
1418
|
+
}, Nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
1419
|
+
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;
|
|
1420
1420
|
i(() => {
|
|
1421
1421
|
if (!u) {
|
|
1422
1422
|
f(a);
|
|
@@ -1432,9 +1432,9 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1432
1432
|
let r = await t.getObjectSchema(n.childObject);
|
|
1433
1433
|
if (n.relationshipField && n.columns?.length) return {
|
|
1434
1434
|
...n,
|
|
1435
|
-
columns:
|
|
1435
|
+
columns: St(n.columns, r)
|
|
1436
1436
|
};
|
|
1437
|
-
let i =
|
|
1437
|
+
let i = At(n.childObject, r, e.objectName, {
|
|
1438
1438
|
relationshipField: n.relationshipField,
|
|
1439
1439
|
columns: n.columns,
|
|
1440
1440
|
amountField: n.amountField
|
|
@@ -1497,7 +1497,7 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1497
1497
|
i(() => {
|
|
1498
1498
|
let n = !1;
|
|
1499
1499
|
if (!(!l || !t)) return (async () => {
|
|
1500
|
-
let r = await Promise.all(
|
|
1500
|
+
let r = await Promise.all(p.map(async (n) => {
|
|
1501
1501
|
if (!n.relationshipField) return {
|
|
1502
1502
|
rows: [],
|
|
1503
1503
|
original: []
|
|
@@ -1533,7 +1533,7 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1533
1533
|
...n,
|
|
1534
1534
|
rows: t
|
|
1535
1535
|
} : n));
|
|
1536
|
-
}, []), D = e.taxRateField || "tax_rate", [O, k] = c(null), A = O ? h[O.detailIdx]?.rows?.[O.rowIdx] : void 0, j = O ?
|
|
1536
|
+
}, []), D = e.taxRateField || "tax_rate", [O, k] = c(null), A = O ? h[O.detailIdx]?.rows?.[O.rowIdx] : void 0, j = O ? p[O.detailIdx] : void 0, M = n((e, t, n) => {
|
|
1537
1537
|
g((r) => r.map((r, i) => i === e ? {
|
|
1538
1538
|
...r,
|
|
1539
1539
|
rows: r.rows.map((e, r) => r === t ? {
|
|
@@ -1541,7 +1541,7 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1541
1541
|
...n
|
|
1542
1542
|
} : e)
|
|
1543
1543
|
} : r));
|
|
1544
|
-
}, []),
|
|
1544
|
+
}, []), I = n((e) => {
|
|
1545
1545
|
g((t) => {
|
|
1546
1546
|
let n = t.map((t, n) => n === e ? {
|
|
1547
1547
|
...t,
|
|
@@ -1559,7 +1559,7 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1559
1559
|
rows: t.rows.filter((t, n) => n !== e.rowIdx)
|
|
1560
1560
|
} : t)), null));
|
|
1561
1561
|
}, []), B = n(async (t) => {
|
|
1562
|
-
T(), e.onSuccess ||
|
|
1562
|
+
T(), e.onSuccess || Y.success(l ? e.title ? `${e.title} saved` : "Saved" : "Created"), l || (g(p.map(() => ({
|
|
1563
1563
|
rows: [],
|
|
1564
1564
|
original: []
|
|
1565
1565
|
}))), b((e) => e + 1)), await e.onSuccess?.(t);
|
|
@@ -1567,22 +1567,22 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1567
1567
|
l,
|
|
1568
1568
|
e.onSuccess,
|
|
1569
1569
|
e.title,
|
|
1570
|
-
|
|
1570
|
+
p.length,
|
|
1571
1571
|
T
|
|
1572
1572
|
]), V = n((t) => {
|
|
1573
|
-
T(),
|
|
1573
|
+
T(), Y.error(t?.message || "Save failed"), e.onError?.(t);
|
|
1574
1574
|
}, [e, T]), H = n(async (n) => {
|
|
1575
1575
|
if (!t) throw Error("MasterDetailForm: dataSource is required");
|
|
1576
1576
|
let r = { ...n };
|
|
1577
|
-
return
|
|
1578
|
-
e.totalField && (r[e.totalField] =
|
|
1579
|
-
}), (await
|
|
1577
|
+
return p.forEach((e, t) => {
|
|
1578
|
+
e.totalField && (r[e.totalField] = ct(_.current[t]?.rows ?? [], e.amountField || "amount"));
|
|
1579
|
+
}), (await m(t, l ? ot(e.objectName, String(e.recordId), r, p.filter((e) => e.relationshipField).map((e, t) => ({
|
|
1580
1580
|
childObject: e.childObject,
|
|
1581
1581
|
relationshipField: e.relationshipField,
|
|
1582
1582
|
rows: _.current[t]?.rows ?? [],
|
|
1583
1583
|
original: _.current[t]?.original ?? [],
|
|
1584
1584
|
childSchema: v.current[e.childObject]
|
|
1585
|
-
}))) :
|
|
1585
|
+
}))) : at(e.objectName, r, p.filter((e) => e.relationshipField).map((e, t) => ({
|
|
1586
1586
|
childObject: e.childObject,
|
|
1587
1587
|
relationshipField: e.relationshipField,
|
|
1588
1588
|
rows: _.current[t]?.rows ?? [],
|
|
@@ -1593,7 +1593,7 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1593
1593
|
};
|
|
1594
1594
|
}, [
|
|
1595
1595
|
t,
|
|
1596
|
-
|
|
1596
|
+
p,
|
|
1597
1597
|
e.objectName,
|
|
1598
1598
|
e.recordId,
|
|
1599
1599
|
l
|
|
@@ -1625,18 +1625,18 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1625
1625
|
}, [T]);
|
|
1626
1626
|
return i(() => () => {
|
|
1627
1627
|
w.current && clearTimeout(w.current);
|
|
1628
|
-
}, []), /* @__PURE__ */
|
|
1629
|
-
className:
|
|
1628
|
+
}, []), /* @__PURE__ */ $("div", {
|
|
1629
|
+
className: J("space-y-6", r, e.className),
|
|
1630
1630
|
children: [
|
|
1631
|
-
/* @__PURE__ */
|
|
1631
|
+
/* @__PURE__ */ Q("div", {
|
|
1632
1632
|
ref: U,
|
|
1633
|
-
children: /* @__PURE__ */
|
|
1633
|
+
children: /* @__PURE__ */ Q(Ht, {
|
|
1634
1634
|
schema: ee,
|
|
1635
1635
|
dataSource: t
|
|
1636
1636
|
}, y)
|
|
1637
1637
|
}),
|
|
1638
|
-
/* @__PURE__ */
|
|
1639
|
-
details:
|
|
1638
|
+
/* @__PURE__ */ Q(Mt, {
|
|
1639
|
+
details: p,
|
|
1640
1640
|
state: h,
|
|
1641
1641
|
setRows: E,
|
|
1642
1642
|
formHostRef: U,
|
|
@@ -1646,21 +1646,21 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1646
1646
|
detailIdx: e,
|
|
1647
1647
|
rowIdx: t
|
|
1648
1648
|
}),
|
|
1649
|
-
onAddViaForm:
|
|
1649
|
+
onAddViaForm: I
|
|
1650
1650
|
}),
|
|
1651
|
-
O && j && /* @__PURE__ */
|
|
1651
|
+
O && j && /* @__PURE__ */ $(P, {
|
|
1652
1652
|
className: "border-primary/40 shadow-none ring-1 ring-primary/10",
|
|
1653
1653
|
"data-testid": "md-row-form",
|
|
1654
|
-
children: [/* @__PURE__ */
|
|
1654
|
+
children: [/* @__PURE__ */ $(L, {
|
|
1655
1655
|
className: "pb-2 flex flex-row items-center justify-between gap-2 space-y-0",
|
|
1656
|
-
children: [/* @__PURE__ */
|
|
1656
|
+
children: [/* @__PURE__ */ $(R, {
|
|
1657
1657
|
className: "text-sm font-medium",
|
|
1658
1658
|
children: [
|
|
1659
1659
|
j.title || "Line item",
|
|
1660
1660
|
" — row ",
|
|
1661
1661
|
O.rowIdx + 1
|
|
1662
1662
|
]
|
|
1663
|
-
}), /* @__PURE__ */
|
|
1663
|
+
}), /* @__PURE__ */ Q(N, {
|
|
1664
1664
|
type: "button",
|
|
1665
1665
|
variant: "ghost",
|
|
1666
1666
|
size: "sm",
|
|
@@ -1668,7 +1668,7 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1668
1668
|
onClick: z,
|
|
1669
1669
|
children: "Close"
|
|
1670
1670
|
})]
|
|
1671
|
-
}), /* @__PURE__ */
|
|
1671
|
+
}), /* @__PURE__ */ Q(F, { children: /* @__PURE__ */ Q(Ht, {
|
|
1672
1672
|
schema: {
|
|
1673
1673
|
type: "object-form",
|
|
1674
1674
|
objectName: j.childObject,
|
|
@@ -1678,23 +1678,23 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1678
1678
|
submitText: "Apply",
|
|
1679
1679
|
submitHandler: async (e) => e,
|
|
1680
1680
|
onSuccess: (e) => {
|
|
1681
|
-
|
|
1681
|
+
M(O.detailIdx, O.rowIdx, e), k(null);
|
|
1682
1682
|
},
|
|
1683
1683
|
onCancel: z
|
|
1684
1684
|
},
|
|
1685
1685
|
dataSource: t
|
|
1686
1686
|
}, `row-${O.detailIdx}-${O.rowIdx}`) })]
|
|
1687
1687
|
}),
|
|
1688
|
-
e.showSubmit !== !1 && /* @__PURE__ */
|
|
1688
|
+
e.showSubmit !== !1 && /* @__PURE__ */ $("div", {
|
|
1689
1689
|
className: "flex items-center justify-end gap-2 border-t border-border pt-4",
|
|
1690
|
-
children: [e.onCancel && /* @__PURE__ */
|
|
1690
|
+
children: [e.onCancel && /* @__PURE__ */ Q(N, {
|
|
1691
1691
|
type: "button",
|
|
1692
1692
|
variant: "outline",
|
|
1693
1693
|
onClick: e.onCancel,
|
|
1694
1694
|
disabled: x,
|
|
1695
1695
|
"data-testid": "md-form-cancel",
|
|
1696
1696
|
children: e.cancelText ?? "Cancel"
|
|
1697
|
-
}), /* @__PURE__ */
|
|
1697
|
+
}), /* @__PURE__ */ Q(N, {
|
|
1698
1698
|
type: "button",
|
|
1699
1699
|
onClick: G,
|
|
1700
1700
|
disabled: x || u && !d,
|
|
@@ -1704,18 +1704,18 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1704
1704
|
})
|
|
1705
1705
|
]
|
|
1706
1706
|
});
|
|
1707
|
-
},
|
|
1707
|
+
}, Pt = {
|
|
1708
1708
|
1: void 0,
|
|
1709
1709
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
1710
1710
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
1711
1711
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
1712
|
-
},
|
|
1712
|
+
}, Ft = pe({
|
|
1713
1713
|
"form.discardTitle": "Discard changes?",
|
|
1714
1714
|
"form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
|
|
1715
1715
|
"form.keepEditing": "Keep editing",
|
|
1716
1716
|
"form.discard": "Discard"
|
|
1717
|
-
}, "form.discardTitle"),
|
|
1718
|
-
let { fieldLabel: l } =
|
|
1717
|
+
}, "form.discardTitle"), It = ({ schema: e, dataSource: t, className: r }) => {
|
|
1718
|
+
let { fieldLabel: l } = y(), { t: u } = Ft(), d = _(), [f, p] = c(null), [m, g] = c([]), [v, b] = c({}), [x, C] = c(!0), [P, F] = c(null), [I, L] = c(!1), [R, z] = c(!1), { saveWithOcc: B, conflictDialog: V } = Ge(), [H, ee] = c(!1), K = s(!1), q = e.confirmOnDiscard !== !1, Y = e.open !== !1, X = e.drawerSide || "right", re = a(), [ie, ae] = c(() => {
|
|
1719
1719
|
let t = {};
|
|
1720
1720
|
return e.sections?.forEach((e, n) => {
|
|
1721
1721
|
let r = e.name || String(n);
|
|
@@ -1725,39 +1725,39 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1725
1725
|
i(() => {
|
|
1726
1726
|
(async () => {
|
|
1727
1727
|
if (!t) {
|
|
1728
|
-
|
|
1728
|
+
C(!1);
|
|
1729
1729
|
return;
|
|
1730
1730
|
}
|
|
1731
1731
|
try {
|
|
1732
1732
|
let n = await t.getObjectSchema(e.objectName);
|
|
1733
1733
|
p(n);
|
|
1734
1734
|
} catch (e) {
|
|
1735
|
-
F(e),
|
|
1735
|
+
F(e), C(!1);
|
|
1736
1736
|
}
|
|
1737
1737
|
})();
|
|
1738
1738
|
}, [e.objectName, t]);
|
|
1739
|
-
let
|
|
1739
|
+
let oe = s(void 0);
|
|
1740
1740
|
i(() => {
|
|
1741
1741
|
let n = !1;
|
|
1742
1742
|
return (f || !t) && (async () => {
|
|
1743
1743
|
if (e.mode === "create" || !e.recordId) {
|
|
1744
|
-
b(e.initialData || e.initialValues || {}),
|
|
1744
|
+
b(e.initialData || e.initialValues || {}), C(!1);
|
|
1745
1745
|
return;
|
|
1746
1746
|
}
|
|
1747
1747
|
if (!t) {
|
|
1748
|
-
b(e.initialData || e.initialValues || {}),
|
|
1748
|
+
b(e.initialData || e.initialValues || {}), C(!1);
|
|
1749
1749
|
return;
|
|
1750
1750
|
}
|
|
1751
|
-
|
|
1751
|
+
oe.current !== e.recordId && (C(!0), L(!1));
|
|
1752
1752
|
try {
|
|
1753
1753
|
let r = await t.findOne(e.objectName, e.recordId);
|
|
1754
1754
|
if (n) return;
|
|
1755
|
-
|
|
1755
|
+
oe.current = e.recordId, b(r || {});
|
|
1756
1756
|
} catch (e) {
|
|
1757
1757
|
if (n) return;
|
|
1758
1758
|
F(e);
|
|
1759
1759
|
} finally {
|
|
1760
|
-
n ||
|
|
1760
|
+
n || C(!1);
|
|
1761
1761
|
}
|
|
1762
1762
|
})(), () => {
|
|
1763
1763
|
n = !0;
|
|
@@ -1771,7 +1771,7 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1771
1771
|
t,
|
|
1772
1772
|
e.objectName
|
|
1773
1773
|
]);
|
|
1774
|
-
let
|
|
1774
|
+
let se = n((t) => Ce(t, {
|
|
1775
1775
|
objectSchema: f,
|
|
1776
1776
|
objectName: e.objectName,
|
|
1777
1777
|
readOnly: e.readOnly,
|
|
@@ -1787,11 +1787,11 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1787
1787
|
i(() => {
|
|
1788
1788
|
if (!f && t) return;
|
|
1789
1789
|
if (e.customFields?.length) {
|
|
1790
|
-
|
|
1790
|
+
g(e.customFields), C(!1);
|
|
1791
1791
|
return;
|
|
1792
1792
|
}
|
|
1793
1793
|
if (e.sections?.length) {
|
|
1794
|
-
|
|
1794
|
+
C(!1);
|
|
1795
1795
|
return;
|
|
1796
1796
|
}
|
|
1797
1797
|
if (!f) return;
|
|
@@ -1803,18 +1803,18 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1803
1803
|
i && r.push({
|
|
1804
1804
|
name: n,
|
|
1805
1805
|
label: l(e.objectName, n, i.label || n),
|
|
1806
|
-
type:
|
|
1806
|
+
type: w(i.type),
|
|
1807
1807
|
required: i.required || !1,
|
|
1808
1808
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
1809
1809
|
placeholder: i.placeholder,
|
|
1810
1810
|
description: i.help || i.description,
|
|
1811
|
-
validation:
|
|
1811
|
+
validation: S(i),
|
|
1812
1812
|
field: i,
|
|
1813
1813
|
options: i.options,
|
|
1814
1814
|
multiple: i.multiple
|
|
1815
1815
|
});
|
|
1816
1816
|
}
|
|
1817
|
-
|
|
1817
|
+
g(r), C(!1);
|
|
1818
1818
|
}, [
|
|
1819
1819
|
f,
|
|
1820
1820
|
e.fields,
|
|
@@ -1824,11 +1824,11 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1824
1824
|
e.mode,
|
|
1825
1825
|
t
|
|
1826
1826
|
]);
|
|
1827
|
-
let
|
|
1828
|
-
|
|
1827
|
+
let ce = n(async (n) => {
|
|
1828
|
+
ee(!0);
|
|
1829
1829
|
try {
|
|
1830
1830
|
if (!t) return e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
1831
|
-
let r, i =
|
|
1831
|
+
let r, i = et(n, f);
|
|
1832
1832
|
if (e.mode === "create") r = await t.create(e.objectName, i);
|
|
1833
1833
|
else if (e.mode === "edit" && e.recordId) {
|
|
1834
1834
|
let n = await B({
|
|
@@ -1836,7 +1836,7 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1836
1836
|
objectName: e.objectName,
|
|
1837
1837
|
recordId: e.recordId,
|
|
1838
1838
|
payload: i,
|
|
1839
|
-
baseRecord:
|
|
1839
|
+
baseRecord: v
|
|
1840
1840
|
});
|
|
1841
1841
|
if (n.status === "cancelled") return;
|
|
1842
1842
|
r = n.result;
|
|
@@ -1845,72 +1845,72 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1845
1845
|
} catch (t) {
|
|
1846
1846
|
throw e.onError && e.onError(t), t;
|
|
1847
1847
|
} finally {
|
|
1848
|
-
|
|
1848
|
+
ee(!1);
|
|
1849
1849
|
}
|
|
1850
1850
|
}, [
|
|
1851
1851
|
e,
|
|
1852
1852
|
t,
|
|
1853
1853
|
f,
|
|
1854
1854
|
B,
|
|
1855
|
-
|
|
1856
|
-
]),
|
|
1855
|
+
v
|
|
1856
|
+
]), Z = n(() => {
|
|
1857
1857
|
z(!1), K.current && (K.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
|
|
1858
|
-
}, [e]),
|
|
1859
|
-
K.current = e,
|
|
1858
|
+
}, [e]), le = n((e) => {
|
|
1859
|
+
K.current = e, q && I ? z(!0) : Z();
|
|
1860
1860
|
}, [
|
|
1861
|
-
|
|
1861
|
+
q,
|
|
1862
1862
|
I,
|
|
1863
|
-
|
|
1863
|
+
Z
|
|
1864
1864
|
]);
|
|
1865
1865
|
i(() => {
|
|
1866
|
-
if (!
|
|
1866
|
+
if (!Y || !I || !q) return;
|
|
1867
1867
|
let e = (e) => {
|
|
1868
1868
|
e.preventDefault(), e.returnValue = "";
|
|
1869
1869
|
};
|
|
1870
1870
|
return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
1871
1871
|
}, [
|
|
1872
|
-
|
|
1872
|
+
Y,
|
|
1873
1873
|
I,
|
|
1874
|
-
|
|
1874
|
+
q
|
|
1875
1875
|
]);
|
|
1876
|
-
let
|
|
1877
|
-
K.current = !0,
|
|
1878
|
-
}, [
|
|
1879
|
-
if (e.drawerWidth) return
|
|
1876
|
+
let de = n(() => {
|
|
1877
|
+
K.current = !0, Z();
|
|
1878
|
+
}, [Z]), fe = o(() => {
|
|
1879
|
+
if (e.drawerWidth) return X === "left" || X === "right" ? {
|
|
1880
1880
|
width: e.drawerWidth,
|
|
1881
1881
|
maxWidth: e.drawerWidth
|
|
1882
1882
|
} : {
|
|
1883
1883
|
height: e.drawerWidth,
|
|
1884
1884
|
maxHeight: e.drawerWidth
|
|
1885
1885
|
};
|
|
1886
|
-
}, [e.drawerWidth,
|
|
1886
|
+
}, [e.drawerWidth, X]), pe = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", me = e.showSubmit !== !1 && e.mode !== "view", he = e.showCancel !== !1, ge = e.submitText || (e.mode === "create" ? "Create" : "Update"), _e = e.cancelText || "Cancel", ve = {
|
|
1887
1887
|
type: "form",
|
|
1888
1888
|
objectName: e.objectName,
|
|
1889
|
-
layout:
|
|
1890
|
-
defaultValues:
|
|
1889
|
+
layout: pe,
|
|
1890
|
+
defaultValues: v,
|
|
1891
1891
|
submitLabel: ge,
|
|
1892
1892
|
cancelLabel: _e,
|
|
1893
|
-
showSubmit:
|
|
1894
|
-
showCancel:
|
|
1895
|
-
onSubmit:
|
|
1896
|
-
onCancel:
|
|
1893
|
+
showSubmit: me,
|
|
1894
|
+
showCancel: he,
|
|
1895
|
+
onSubmit: ce,
|
|
1896
|
+
onCancel: de,
|
|
1897
1897
|
onDirtyChange: L,
|
|
1898
1898
|
showActions: !1,
|
|
1899
|
-
id:
|
|
1899
|
+
id: re
|
|
1900
1900
|
}, ye = () => {
|
|
1901
|
-
if (P) return /* @__PURE__ */
|
|
1901
|
+
if (P) return /* @__PURE__ */ $("div", {
|
|
1902
1902
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1903
|
-
children: [/* @__PURE__ */
|
|
1903
|
+
children: [/* @__PURE__ */ Q("h3", {
|
|
1904
1904
|
className: "text-red-800 font-semibold",
|
|
1905
1905
|
children: "Error loading form"
|
|
1906
|
-
}), /* @__PURE__ */
|
|
1906
|
+
}), /* @__PURE__ */ Q("p", {
|
|
1907
1907
|
className: "text-red-600 text-sm mt-1",
|
|
1908
1908
|
children: P.message
|
|
1909
1909
|
})]
|
|
1910
1910
|
});
|
|
1911
|
-
if (
|
|
1911
|
+
if (x) return /* @__PURE__ */ $("div", {
|
|
1912
1912
|
className: "p-8 text-center",
|
|
1913
|
-
children: [/* @__PURE__ */
|
|
1913
|
+
children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
|
|
1914
1914
|
className: "mt-2 text-sm text-gray-600",
|
|
1915
1915
|
children: "Loading form..."
|
|
1916
1916
|
})]
|
|
@@ -1918,7 +1918,7 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1918
1918
|
if (e.sections?.length) {
|
|
1919
1919
|
let t = [];
|
|
1920
1920
|
return e.sections.forEach((e, n) => {
|
|
1921
|
-
let r = e.name || String(n), i =
|
|
1921
|
+
let r = e.name || String(n), i = ie[r] ?? e.collapsed ?? !1;
|
|
1922
1922
|
t.push({
|
|
1923
1923
|
name: `__section_${r}`,
|
|
1924
1924
|
label: e.label || "",
|
|
@@ -1926,30 +1926,30 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1926
1926
|
colSpan: 4,
|
|
1927
1927
|
collapsible: e.collapsible,
|
|
1928
1928
|
collapsed: i,
|
|
1929
|
-
onToggle: e.collapsible ? () =>
|
|
1929
|
+
onToggle: e.collapsible ? () => ae((e) => ({
|
|
1930
1930
|
...e,
|
|
1931
1931
|
[r]: !i
|
|
1932
1932
|
})) : void 0,
|
|
1933
1933
|
className: e.className
|
|
1934
1934
|
});
|
|
1935
|
-
let a =
|
|
1935
|
+
let a = se(e);
|
|
1936
1936
|
i ? t.push(...a.map((e) => ({
|
|
1937
1937
|
...e,
|
|
1938
1938
|
hidden: !0
|
|
1939
1939
|
}))) : t.push(...a);
|
|
1940
|
-
}), /* @__PURE__ */
|
|
1940
|
+
}), /* @__PURE__ */ Q(h, { schema: {
|
|
1941
1941
|
...ve,
|
|
1942
1942
|
fields: t
|
|
1943
1943
|
} });
|
|
1944
1944
|
}
|
|
1945
|
-
let t =
|
|
1946
|
-
return /* @__PURE__ */
|
|
1945
|
+
let t = Be(m, f, e.columns, e.mode), n = Pt[t.columns || 1];
|
|
1946
|
+
return /* @__PURE__ */ Q(h, { schema: {
|
|
1947
1947
|
...ve,
|
|
1948
1948
|
fields: t.fields,
|
|
1949
1949
|
columns: t.columns,
|
|
1950
1950
|
...n ? { fieldContainerClass: n } : {}
|
|
1951
1951
|
} });
|
|
1952
|
-
}, be = e.subforms, xe = be?.length && e.mode !== "view" ? /* @__PURE__ */
|
|
1952
|
+
}, be = e.subforms, xe = be?.length && e.mode !== "view" ? /* @__PURE__ */ Q(Nt, {
|
|
1953
1953
|
schema: {
|
|
1954
1954
|
type: "object-master-detail-form",
|
|
1955
1955
|
objectName: e.objectName,
|
|
@@ -1968,71 +1968,71 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1968
1968
|
},
|
|
1969
1969
|
dataSource: t
|
|
1970
1970
|
}) : ye();
|
|
1971
|
-
return d ? /* @__PURE__ */
|
|
1971
|
+
return d ? /* @__PURE__ */ $("div", {
|
|
1972
1972
|
className: "@container rounded-md border bg-card p-4",
|
|
1973
|
-
children: [(e.title || e.description) && /* @__PURE__ */
|
|
1973
|
+
children: [(e.title || e.description) && /* @__PURE__ */ $("div", {
|
|
1974
1974
|
className: "mb-3 space-y-0.5",
|
|
1975
|
-
children: [e.title && /* @__PURE__ */
|
|
1975
|
+
children: [e.title && /* @__PURE__ */ Q("div", {
|
|
1976
1976
|
className: "text-sm font-semibold",
|
|
1977
1977
|
children: e.title
|
|
1978
|
-
}), e.description && /* @__PURE__ */
|
|
1978
|
+
}), e.description && /* @__PURE__ */ Q("p", {
|
|
1979
1979
|
className: "text-xs text-muted-foreground",
|
|
1980
1980
|
children: e.description
|
|
1981
1981
|
})]
|
|
1982
1982
|
}), xe]
|
|
1983
|
-
}) : /* @__PURE__ */
|
|
1984
|
-
open:
|
|
1983
|
+
}) : /* @__PURE__ */ Q(U, {
|
|
1984
|
+
open: Y,
|
|
1985
1985
|
onOpenChange: (t) => {
|
|
1986
1986
|
if (t) {
|
|
1987
1987
|
e.onOpenChange?.(!0);
|
|
1988
1988
|
return;
|
|
1989
1989
|
}
|
|
1990
|
-
|
|
1990
|
+
le(!1);
|
|
1991
1991
|
},
|
|
1992
|
-
children: /* @__PURE__ */
|
|
1993
|
-
side:
|
|
1994
|
-
className:
|
|
1995
|
-
style:
|
|
1992
|
+
children: /* @__PURE__ */ $(W, {
|
|
1993
|
+
side: X,
|
|
1994
|
+
className: J("overflow-y-auto", r, e.className),
|
|
1995
|
+
style: fe,
|
|
1996
1996
|
children: [
|
|
1997
|
-
(e.title || e.description) && /* @__PURE__ */
|
|
1997
|
+
(e.title || e.description) && /* @__PURE__ */ $(te, { children: [e.title && /* @__PURE__ */ Q(ne, { children: e.title }), e.description ? /* @__PURE__ */ Q(G, { children: e.description }) : /* @__PURE__ */ Q(G, {
|
|
1998
1998
|
className: "sr-only",
|
|
1999
1999
|
children: "Complete the form fields, then submit or cancel."
|
|
2000
2000
|
})] }),
|
|
2001
|
-
/* @__PURE__ */
|
|
2001
|
+
/* @__PURE__ */ Q("div", {
|
|
2002
2002
|
className: "@container py-4",
|
|
2003
2003
|
children: xe
|
|
2004
2004
|
}),
|
|
2005
|
-
!P && !
|
|
2005
|
+
!P && !x && !(be?.length && e.mode !== "view") && (me || he) && /* @__PURE__ */ Q("div", {
|
|
2006
2006
|
className: "shrink-0 border-t px-4 py-3 bg-background",
|
|
2007
2007
|
"data-testid": "drawer-form-footer",
|
|
2008
|
-
children: /* @__PURE__ */
|
|
2008
|
+
children: /* @__PURE__ */ $("div", {
|
|
2009
2009
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
2010
|
-
children: [
|
|
2010
|
+
children: [he && /* @__PURE__ */ Q(N, {
|
|
2011
2011
|
type: "button",
|
|
2012
2012
|
variant: "outline",
|
|
2013
|
-
onClick:
|
|
2013
|
+
onClick: de,
|
|
2014
2014
|
disabled: H,
|
|
2015
2015
|
className: "w-full sm:w-auto",
|
|
2016
2016
|
children: _e
|
|
2017
|
-
}),
|
|
2017
|
+
}), me && /* @__PURE__ */ $(N, {
|
|
2018
2018
|
type: "submit",
|
|
2019
|
-
form:
|
|
2019
|
+
form: re,
|
|
2020
2020
|
disabled: H,
|
|
2021
2021
|
className: "w-full sm:w-auto",
|
|
2022
|
-
children: [H && /* @__PURE__ */
|
|
2022
|
+
children: [H && /* @__PURE__ */ Q(ue, { className: "mr-2 h-4 w-4 animate-spin" }), ge]
|
|
2023
2023
|
})]
|
|
2024
2024
|
})
|
|
2025
2025
|
}),
|
|
2026
|
-
/* @__PURE__ */
|
|
2026
|
+
/* @__PURE__ */ Q(T, {
|
|
2027
2027
|
open: R,
|
|
2028
2028
|
onOpenChange: z,
|
|
2029
|
-
children: /* @__PURE__ */
|
|
2029
|
+
children: /* @__PURE__ */ $(O, { children: [/* @__PURE__ */ $(j, { children: [/* @__PURE__ */ Q(M, { children: u("form.discardTitle") }), /* @__PURE__ */ Q(k, { children: u("form.discardMessage") })] }), /* @__PURE__ */ $(A, { children: [/* @__PURE__ */ Q(D, {
|
|
2030
2030
|
onClick: () => {
|
|
2031
2031
|
K.current = !1;
|
|
2032
2032
|
},
|
|
2033
2033
|
children: u("form.keepEditing")
|
|
2034
|
-
}), /* @__PURE__ */
|
|
2035
|
-
onClick:
|
|
2034
|
+
}), /* @__PURE__ */ Q(E, {
|
|
2035
|
+
onClick: Z,
|
|
2036
2036
|
children: u("form.discard")
|
|
2037
2037
|
})] })] })
|
|
2038
2038
|
}),
|
|
@@ -2043,7 +2043,7 @@ var jt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
2043
2043
|
};
|
|
2044
2044
|
//#endregion
|
|
2045
2045
|
//#region src/fieldGroups.ts
|
|
2046
|
-
function
|
|
2046
|
+
function Lt(e, t) {
|
|
2047
2047
|
let n = he({
|
|
2048
2048
|
fieldGroups: t,
|
|
2049
2049
|
fields: Object.fromEntries(e.map((e) => [e.name, { group: e.group }]))
|
|
@@ -2064,19 +2064,19 @@ function It(e, t) {
|
|
|
2064
2064
|
}
|
|
2065
2065
|
//#endregion
|
|
2066
2066
|
//#region src/ModalForm.tsx
|
|
2067
|
-
var
|
|
2067
|
+
var Rt = pe({
|
|
2068
2068
|
"form.discardTitle": "Discard changes?",
|
|
2069
2069
|
"form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
|
|
2070
2070
|
"form.keepEditing": "Keep editing",
|
|
2071
2071
|
"form.discard": "Discard"
|
|
2072
|
-
}, "form.discardTitle"),
|
|
2072
|
+
}, "form.discardTitle"), zt = {
|
|
2073
2073
|
sm: "sm:max-w-sm",
|
|
2074
2074
|
default: "sm:max-w-lg",
|
|
2075
2075
|
lg: "sm:max-w-2xl",
|
|
2076
2076
|
xl: "sm:max-w-5xl",
|
|
2077
2077
|
full: "sm:max-w-[95vw] sm:w-full"
|
|
2078
|
-
},
|
|
2079
|
-
let { fieldLabel: l, sectionLabel: u } =
|
|
2078
|
+
}, Bt = ({ schema: e, dataSource: t, className: r }) => {
|
|
2079
|
+
let { fieldLabel: l, sectionLabel: u } = y(), { t: d } = Rt(), f = _(), p = re(), m = n((t) => {
|
|
2080
2080
|
if (!p?.isLoaded) return t;
|
|
2081
2081
|
let n = [];
|
|
2082
2082
|
for (let r of t) {
|
|
@@ -2095,13 +2095,13 @@ var Lt = pe({
|
|
|
2095
2095
|
p,
|
|
2096
2096
|
e.objectName,
|
|
2097
2097
|
e.mode
|
|
2098
|
-
]), [
|
|
2098
|
+
]), [g, v] = c(null), [b, x] = c([]), [C, P] = c({}), [F, I] = c(!0), [L, R] = c(null), [U, W] = c(!1), [G, te] = c(!1), [ne, q] = c(!1), { saveWithOcc: Y, conflictDialog: X } = Ge(), ie = s(!1), ae = e.confirmOnDiscard !== !1, oe = e.open !== !1, se = a(), ce = o(() => {
|
|
2099
2099
|
if (e.sections?.length || e.customFields?.length) return null;
|
|
2100
|
-
let t =
|
|
2101
|
-
e.mode === "create" && (t =
|
|
2102
|
-
let n =
|
|
2100
|
+
let t = Pe(b, g);
|
|
2101
|
+
e.mode === "create" && (t = Ie(t, g));
|
|
2102
|
+
let n = Lt(t, g?.fieldGroups);
|
|
2103
2103
|
if (!n) return null;
|
|
2104
|
-
let r = e.columns && e.columns > 0 ? Math.min(Math.floor(e.columns), 4) :
|
|
2104
|
+
let r = e.columns && e.columns > 0 ? Math.min(Math.floor(e.columns), 4) : ke(t.length);
|
|
2105
2105
|
return n.map((e) => ({
|
|
2106
2106
|
...e,
|
|
2107
2107
|
columns: r
|
|
@@ -2112,27 +2112,27 @@ var Lt = pe({
|
|
|
2112
2112
|
e.columns,
|
|
2113
2113
|
e.mode,
|
|
2114
2114
|
b,
|
|
2115
|
-
|
|
2116
|
-
]),
|
|
2115
|
+
g
|
|
2116
|
+
]), Z = e.sections?.length ? e.sections : ce ?? void 0, le = o(() => Z?.length || e.customFields?.length ? null : Be(b, g, e.columns, e.mode), [
|
|
2117
2117
|
b,
|
|
2118
|
-
|
|
2118
|
+
g,
|
|
2119
2119
|
e.columns,
|
|
2120
2120
|
e.mode,
|
|
2121
|
-
|
|
2121
|
+
Z,
|
|
2122
2122
|
e.customFields
|
|
2123
|
-
]),
|
|
2123
|
+
]), de = zt[o(() => {
|
|
2124
2124
|
if (e.modalSize) return e.modalSize;
|
|
2125
|
-
if (
|
|
2126
|
-
if (
|
|
2127
|
-
let e = Math.max(...
|
|
2128
|
-
if (e > 1) return
|
|
2125
|
+
if (le?.columns && le.columns > 1) return ze(le.columns);
|
|
2126
|
+
if (Z?.length) {
|
|
2127
|
+
let e = Math.max(...Z.map((e) => Number(e.columns) || 1));
|
|
2128
|
+
if (e > 1) return ze(e);
|
|
2129
2129
|
}
|
|
2130
2130
|
return "default";
|
|
2131
2131
|
}, [
|
|
2132
2132
|
e.modalSize,
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
])] ||
|
|
2133
|
+
le,
|
|
2134
|
+
Z
|
|
2135
|
+
])] || zt.default;
|
|
2136
2136
|
i(() => {
|
|
2137
2137
|
(async () => {
|
|
2138
2138
|
if (!t) {
|
|
@@ -2141,16 +2141,16 @@ var Lt = pe({
|
|
|
2141
2141
|
}
|
|
2142
2142
|
try {
|
|
2143
2143
|
let n = await t.getObjectSchema(e.objectName);
|
|
2144
|
-
|
|
2144
|
+
v(n);
|
|
2145
2145
|
} catch (e) {
|
|
2146
|
-
|
|
2146
|
+
R(e), I(!1);
|
|
2147
2147
|
}
|
|
2148
2148
|
})();
|
|
2149
2149
|
}, [e.objectName, t]);
|
|
2150
|
-
let
|
|
2150
|
+
let fe = s(void 0);
|
|
2151
2151
|
i(() => {
|
|
2152
2152
|
let n = !1;
|
|
2153
|
-
return (
|
|
2153
|
+
return (g || !t) && (async () => {
|
|
2154
2154
|
if (e.mode === "create" || !e.recordId) {
|
|
2155
2155
|
P(e.initialData || e.initialValues || {}), I(!1);
|
|
2156
2156
|
return;
|
|
@@ -2159,14 +2159,14 @@ var Lt = pe({
|
|
|
2159
2159
|
P(e.initialData || e.initialValues || {}), I(!1);
|
|
2160
2160
|
return;
|
|
2161
2161
|
}
|
|
2162
|
-
|
|
2162
|
+
fe.current !== e.recordId && (I(!0), te(!1));
|
|
2163
2163
|
try {
|
|
2164
2164
|
let r = await t.findOne(e.objectName, e.recordId);
|
|
2165
2165
|
if (n) return;
|
|
2166
|
-
|
|
2166
|
+
fe.current = e.recordId, P(r || {});
|
|
2167
2167
|
} catch (e) {
|
|
2168
2168
|
if (n) return;
|
|
2169
|
-
|
|
2169
|
+
R(e);
|
|
2170
2170
|
} finally {
|
|
2171
2171
|
n || I(!1);
|
|
2172
2172
|
}
|
|
@@ -2174,7 +2174,7 @@ var Lt = pe({
|
|
|
2174
2174
|
n = !0;
|
|
2175
2175
|
};
|
|
2176
2176
|
}, [
|
|
2177
|
-
|
|
2177
|
+
g,
|
|
2178
2178
|
e.mode,
|
|
2179
2179
|
e.recordId,
|
|
2180
2180
|
e.initialData,
|
|
@@ -2182,44 +2182,44 @@ var Lt = pe({
|
|
|
2182
2182
|
t,
|
|
2183
2183
|
e.objectName
|
|
2184
2184
|
]);
|
|
2185
|
-
let
|
|
2186
|
-
objectSchema:
|
|
2185
|
+
let pe = n((t) => Ce(t, {
|
|
2186
|
+
objectSchema: g,
|
|
2187
2187
|
objectName: e.objectName,
|
|
2188
2188
|
readOnly: e.readOnly,
|
|
2189
2189
|
mode: e.mode,
|
|
2190
2190
|
fieldLabel: l
|
|
2191
2191
|
}), [
|
|
2192
|
-
|
|
2192
|
+
g,
|
|
2193
2193
|
e.readOnly,
|
|
2194
2194
|
e.mode,
|
|
2195
2195
|
e.objectName,
|
|
2196
2196
|
l
|
|
2197
2197
|
]);
|
|
2198
2198
|
i(() => {
|
|
2199
|
-
if (!
|
|
2199
|
+
if (!g && t) return;
|
|
2200
2200
|
if (e.customFields?.length) {
|
|
2201
|
-
|
|
2201
|
+
x(e.customFields), I(!1);
|
|
2202
2202
|
return;
|
|
2203
2203
|
}
|
|
2204
2204
|
if (e.sections?.length) {
|
|
2205
2205
|
I(!1);
|
|
2206
2206
|
return;
|
|
2207
2207
|
}
|
|
2208
|
-
if (!
|
|
2209
|
-
let n = e.fields || Object.keys(
|
|
2208
|
+
if (!g) return;
|
|
2209
|
+
let n = e.fields || Object.keys(g.fields || {}), r = [];
|
|
2210
2210
|
for (let t of n) {
|
|
2211
2211
|
let n = typeof t == "string" ? t : t.name;
|
|
2212
2212
|
if (!n) continue;
|
|
2213
|
-
let i =
|
|
2213
|
+
let i = g.fields?.[n];
|
|
2214
2214
|
i && r.push({
|
|
2215
2215
|
name: n,
|
|
2216
2216
|
label: l(e.objectName, n, i.label || n),
|
|
2217
|
-
type:
|
|
2217
|
+
type: w(i.type),
|
|
2218
2218
|
required: i.required || !1,
|
|
2219
2219
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
2220
2220
|
placeholder: i.placeholder,
|
|
2221
2221
|
description: i.help || i.description,
|
|
2222
|
-
validation:
|
|
2222
|
+
validation: S(i),
|
|
2223
2223
|
field: i,
|
|
2224
2224
|
options: i.options,
|
|
2225
2225
|
multiple: i.multiple,
|
|
@@ -2229,9 +2229,9 @@ var Lt = pe({
|
|
|
2229
2229
|
group: i.group
|
|
2230
2230
|
});
|
|
2231
2231
|
}
|
|
2232
|
-
|
|
2232
|
+
x(r), I(!1);
|
|
2233
2233
|
}, [
|
|
2234
|
-
|
|
2234
|
+
g,
|
|
2235
2235
|
e.fields,
|
|
2236
2236
|
e.customFields,
|
|
2237
2237
|
e.sections,
|
|
@@ -2239,11 +2239,11 @@ var Lt = pe({
|
|
|
2239
2239
|
e.mode,
|
|
2240
2240
|
t
|
|
2241
2241
|
]);
|
|
2242
|
-
let
|
|
2242
|
+
let me = n(async (n) => {
|
|
2243
2243
|
W(!0);
|
|
2244
2244
|
try {
|
|
2245
2245
|
if (!t) return e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
2246
|
-
let r, i =
|
|
2246
|
+
let r, i = et(n, g);
|
|
2247
2247
|
if (p?.isLoaded) {
|
|
2248
2248
|
let t = {};
|
|
2249
2249
|
for (let n of Object.keys(i)) p.checkField(e.objectName, n, "write") && (t[n] = i[n]);
|
|
@@ -2251,12 +2251,12 @@ var Lt = pe({
|
|
|
2251
2251
|
}
|
|
2252
2252
|
if (e.mode === "create") r = await t.create(e.objectName, i);
|
|
2253
2253
|
else if (e.mode === "edit" && e.recordId) {
|
|
2254
|
-
let n = await
|
|
2254
|
+
let n = await Y({
|
|
2255
2255
|
dataSource: t,
|
|
2256
2256
|
objectName: e.objectName,
|
|
2257
2257
|
recordId: e.recordId,
|
|
2258
2258
|
payload: i,
|
|
2259
|
-
baseRecord:
|
|
2259
|
+
baseRecord: C
|
|
2260
2260
|
});
|
|
2261
2261
|
if (n.status === "cancelled") return;
|
|
2262
2262
|
r = n.result;
|
|
@@ -2270,86 +2270,86 @@ var Lt = pe({
|
|
|
2270
2270
|
}, [
|
|
2271
2271
|
e,
|
|
2272
2272
|
t,
|
|
2273
|
-
|
|
2273
|
+
g,
|
|
2274
2274
|
p,
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
]),
|
|
2278
|
-
|
|
2275
|
+
Y,
|
|
2276
|
+
C
|
|
2277
|
+
]), he = n(() => {
|
|
2278
|
+
q(!1), ie.current && (ie.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
|
|
2279
2279
|
}, [e]), ge = n((e) => {
|
|
2280
|
-
|
|
2280
|
+
ie.current = e, ae && G ? q(!0) : he();
|
|
2281
2281
|
}, [
|
|
2282
|
-
|
|
2282
|
+
ae,
|
|
2283
2283
|
G,
|
|
2284
|
-
|
|
2284
|
+
he
|
|
2285
2285
|
]);
|
|
2286
2286
|
i(() => {
|
|
2287
|
-
if (!
|
|
2287
|
+
if (!oe || !G || !ae) return;
|
|
2288
2288
|
let e = (e) => {
|
|
2289
2289
|
e.preventDefault(), e.returnValue = "";
|
|
2290
2290
|
};
|
|
2291
2291
|
return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
2292
2292
|
}, [
|
|
2293
|
-
|
|
2293
|
+
oe,
|
|
2294
2294
|
G,
|
|
2295
|
-
|
|
2295
|
+
ae
|
|
2296
2296
|
]);
|
|
2297
2297
|
let _e = n(() => {
|
|
2298
|
-
|
|
2299
|
-
}, [
|
|
2298
|
+
ie.current = !0, he();
|
|
2299
|
+
}, [he]), 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", we = {
|
|
2300
2300
|
type: "form",
|
|
2301
2301
|
objectName: e.objectName,
|
|
2302
2302
|
layout: ve,
|
|
2303
|
-
defaultValues:
|
|
2303
|
+
defaultValues: C,
|
|
2304
2304
|
submitLabel: xe,
|
|
2305
|
-
cancelLabel:
|
|
2305
|
+
cancelLabel: Se,
|
|
2306
2306
|
showSubmit: ye,
|
|
2307
2307
|
showCancel: be,
|
|
2308
|
-
onSubmit:
|
|
2308
|
+
onSubmit: me,
|
|
2309
2309
|
onCancel: _e,
|
|
2310
2310
|
onDirtyChange: te,
|
|
2311
2311
|
showActions: !1,
|
|
2312
|
-
id:
|
|
2312
|
+
id: se
|
|
2313
2313
|
}, Te = () => {
|
|
2314
|
-
if (L) return /* @__PURE__ */
|
|
2314
|
+
if (L) return /* @__PURE__ */ $("div", {
|
|
2315
2315
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
2316
|
-
children: [/* @__PURE__ */
|
|
2316
|
+
children: [/* @__PURE__ */ Q("h3", {
|
|
2317
2317
|
className: "text-red-800 font-semibold",
|
|
2318
2318
|
children: "Error loading form"
|
|
2319
|
-
}), /* @__PURE__ */
|
|
2319
|
+
}), /* @__PURE__ */ Q("p", {
|
|
2320
2320
|
className: "text-red-600 text-sm mt-1",
|
|
2321
2321
|
children: L.message
|
|
2322
2322
|
})]
|
|
2323
2323
|
});
|
|
2324
|
-
if (F) return /* @__PURE__ */
|
|
2324
|
+
if (F) return /* @__PURE__ */ Q("div", {
|
|
2325
2325
|
className: "space-y-4",
|
|
2326
2326
|
"data-testid": "modal-form-skeleton",
|
|
2327
2327
|
children: [
|
|
2328
2328
|
1,
|
|
2329
2329
|
2,
|
|
2330
2330
|
3
|
|
2331
|
-
].map((e) => /* @__PURE__ */
|
|
2331
|
+
].map((e) => /* @__PURE__ */ $("div", {
|
|
2332
2332
|
className: "space-y-2",
|
|
2333
|
-
children: [/* @__PURE__ */
|
|
2333
|
+
children: [/* @__PURE__ */ Q(K, { className: "h-4 w-24" }), /* @__PURE__ */ Q(K, { className: "h-10 w-full" })]
|
|
2334
2334
|
}, e))
|
|
2335
2335
|
});
|
|
2336
2336
|
if (e.sections?.length) {
|
|
2337
|
-
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 =
|
|
2338
|
-
let a =
|
|
2337
|
+
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 = Le[o], c = t.map((e, t) => {
|
|
2338
|
+
let a = m(pe(e));
|
|
2339
2339
|
return {
|
|
2340
2340
|
key: n(e, t),
|
|
2341
2341
|
title: r(e),
|
|
2342
2342
|
description: e.description,
|
|
2343
2343
|
className: e.className,
|
|
2344
2344
|
gridClassName: e.gridClassName,
|
|
2345
|
-
fields: o > 1 ?
|
|
2345
|
+
fields: o > 1 ? Me(a, o, i(e.columns)) : a
|
|
2346
2346
|
};
|
|
2347
2347
|
}).filter((e) => e.fields.length > 0), l = {
|
|
2348
2348
|
...we,
|
|
2349
2349
|
columns: o,
|
|
2350
2350
|
...s ? { fieldContainerClass: s } : {}
|
|
2351
2351
|
};
|
|
2352
|
-
if (e.contentLayout === "tabbed" && c.length > 1) return /* @__PURE__ */
|
|
2352
|
+
if (e.contentLayout === "tabbed" && c.length > 1) return /* @__PURE__ */ Q(h, { schema: {
|
|
2353
2353
|
...l,
|
|
2354
2354
|
fields: c.flatMap((e) => e.fields),
|
|
2355
2355
|
fieldTabs: c.map((e, t) => ({
|
|
@@ -2370,66 +2370,66 @@ var Lt = pe({
|
|
|
2370
2370
|
colSpan: 4,
|
|
2371
2371
|
className: e.className
|
|
2372
2372
|
}), d.push(...e.fields);
|
|
2373
|
-
}), /* @__PURE__ */
|
|
2373
|
+
}), /* @__PURE__ */ Q(h, { schema: {
|
|
2374
2374
|
...l,
|
|
2375
2375
|
fields: d
|
|
2376
2376
|
} });
|
|
2377
2377
|
}
|
|
2378
|
-
if (
|
|
2379
|
-
let t = Number(
|
|
2380
|
-
|
|
2381
|
-
let a =
|
|
2378
|
+
if (ce?.length) {
|
|
2379
|
+
let t = Number(ce[0]?.columns) || 1, n = [];
|
|
2380
|
+
ce.forEach((r, i) => {
|
|
2381
|
+
let a = m(pe(r));
|
|
2382
2382
|
if (!a.length) return;
|
|
2383
2383
|
let o = r.name ? u(e.objectName, r.name, r.label || r.name) : r.label;
|
|
2384
2384
|
o && n.push({
|
|
2385
2385
|
name: `__section_${r.name || i}`,
|
|
2386
2386
|
label: o,
|
|
2387
2387
|
type: "section-divider"
|
|
2388
|
-
}), n.push(...t > 1 ?
|
|
2388
|
+
}), n.push(...t > 1 ? Me(a, t) : a);
|
|
2389
2389
|
});
|
|
2390
|
-
let r =
|
|
2391
|
-
return /* @__PURE__ */
|
|
2390
|
+
let r = Le[t];
|
|
2391
|
+
return /* @__PURE__ */ Q(h, { schema: {
|
|
2392
2392
|
...we,
|
|
2393
2393
|
fields: n,
|
|
2394
2394
|
columns: t,
|
|
2395
2395
|
...r ? { fieldContainerClass: r } : {}
|
|
2396
2396
|
} });
|
|
2397
2397
|
}
|
|
2398
|
-
let t =
|
|
2399
|
-
return /* @__PURE__ */
|
|
2398
|
+
let t = le ?? Be(b, g, e.columns, e.mode), n = Le[t.columns || 1];
|
|
2399
|
+
return /* @__PURE__ */ Q(h, { schema: {
|
|
2400
2400
|
...we,
|
|
2401
|
-
fields:
|
|
2401
|
+
fields: m(t.fields),
|
|
2402
2402
|
columns: t.columns,
|
|
2403
2403
|
...n ? { fieldContainerClass: n } : {}
|
|
2404
2404
|
} });
|
|
2405
2405
|
}, Ee = e.subforms;
|
|
2406
|
-
if (f) return /* @__PURE__ */
|
|
2406
|
+
if (f) return /* @__PURE__ */ $("div", {
|
|
2407
2407
|
className: "@container rounded-md border bg-card p-4",
|
|
2408
|
-
children: [(e.title || e.description) && /* @__PURE__ */
|
|
2408
|
+
children: [(e.title || e.description) && /* @__PURE__ */ $("div", {
|
|
2409
2409
|
className: "mb-3 space-y-0.5",
|
|
2410
|
-
children: [e.title && /* @__PURE__ */
|
|
2410
|
+
children: [e.title && /* @__PURE__ */ Q("div", {
|
|
2411
2411
|
className: "text-sm font-semibold",
|
|
2412
2412
|
children: e.title
|
|
2413
|
-
}), e.description && /* @__PURE__ */
|
|
2413
|
+
}), e.description && /* @__PURE__ */ Q("p", {
|
|
2414
2414
|
className: "text-xs text-muted-foreground",
|
|
2415
2415
|
children: e.description
|
|
2416
2416
|
})]
|
|
2417
2417
|
}), Te()]
|
|
2418
2418
|
});
|
|
2419
|
-
if (Ee?.length && e.mode !== "view") return /* @__PURE__ */
|
|
2420
|
-
open:
|
|
2419
|
+
if (Ee?.length && e.mode !== "view") return /* @__PURE__ */ Q(z, {
|
|
2420
|
+
open: oe,
|
|
2421
2421
|
onOpenChange: e.onOpenChange,
|
|
2422
|
-
children: /* @__PURE__ */
|
|
2423
|
-
className:
|
|
2424
|
-
children: [(e.title || e.description) && /* @__PURE__ */
|
|
2422
|
+
children: /* @__PURE__ */ $(ee, {
|
|
2423
|
+
className: J(de, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", r, e.className),
|
|
2424
|
+
children: [(e.title || e.description) && /* @__PURE__ */ $(V, {
|
|
2425
2425
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
2426
|
-
children: [e.title && /* @__PURE__ */
|
|
2426
|
+
children: [e.title && /* @__PURE__ */ Q(H, { children: e.title }), e.description ? /* @__PURE__ */ Q(B, { children: e.description }) : /* @__PURE__ */ Q(B, {
|
|
2427
2427
|
className: "sr-only",
|
|
2428
2428
|
children: "Enter the record and its line items, then save."
|
|
2429
2429
|
})]
|
|
2430
|
-
}), /* @__PURE__ */
|
|
2430
|
+
}), /* @__PURE__ */ Q("div", {
|
|
2431
2431
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
2432
|
-
children: /* @__PURE__ */
|
|
2432
|
+
children: /* @__PURE__ */ Q(Nt, {
|
|
2433
2433
|
schema: {
|
|
2434
2434
|
type: "object-master-detail-form",
|
|
2435
2435
|
objectName: e.objectName,
|
|
@@ -2440,7 +2440,7 @@ var Lt = pe({
|
|
|
2440
2440
|
initialValues: e.initialValues,
|
|
2441
2441
|
initialData: e.initialData,
|
|
2442
2442
|
submitText: xe,
|
|
2443
|
-
cancelText:
|
|
2443
|
+
cancelText: Se,
|
|
2444
2444
|
details: Ee,
|
|
2445
2445
|
onSuccess: async (t) => {
|
|
2446
2446
|
await e.onSuccess?.(t), e.onOpenChange?.(!1);
|
|
@@ -2454,8 +2454,8 @@ var Lt = pe({
|
|
|
2454
2454
|
})
|
|
2455
2455
|
});
|
|
2456
2456
|
let De = !F && !L && (ye || be);
|
|
2457
|
-
return /* @__PURE__ */
|
|
2458
|
-
open:
|
|
2457
|
+
return /* @__PURE__ */ Q(z, {
|
|
2458
|
+
open: oe,
|
|
2459
2459
|
onOpenChange: (t) => {
|
|
2460
2460
|
if (t) {
|
|
2461
2461
|
e.onOpenChange?.(!0);
|
|
@@ -2463,70 +2463,70 @@ var Lt = pe({
|
|
|
2463
2463
|
}
|
|
2464
2464
|
ge(!1);
|
|
2465
2465
|
},
|
|
2466
|
-
children: /* @__PURE__ */
|
|
2467
|
-
className:
|
|
2466
|
+
children: /* @__PURE__ */ $(ee, {
|
|
2467
|
+
className: J(de, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", r, e.className),
|
|
2468
2468
|
children: [
|
|
2469
|
-
(e.title || e.description) && /* @__PURE__ */
|
|
2469
|
+
(e.title || e.description) && /* @__PURE__ */ $(V, {
|
|
2470
2470
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
2471
|
-
children: [e.title && /* @__PURE__ */
|
|
2471
|
+
children: [e.title && /* @__PURE__ */ Q(H, { children: e.title }), e.description ? /* @__PURE__ */ Q(B, { children: e.description }) : /* @__PURE__ */ Q(B, {
|
|
2472
2472
|
className: "sr-only",
|
|
2473
2473
|
children: "Complete the form fields, then submit or cancel."
|
|
2474
2474
|
})]
|
|
2475
2475
|
}),
|
|
2476
|
-
/* @__PURE__ */
|
|
2476
|
+
/* @__PURE__ */ Q("div", {
|
|
2477
2477
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
2478
2478
|
children: Te()
|
|
2479
2479
|
}),
|
|
2480
|
-
De && /* @__PURE__ */
|
|
2480
|
+
De && /* @__PURE__ */ Q("div", {
|
|
2481
2481
|
className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background",
|
|
2482
2482
|
"data-testid": "modal-form-footer",
|
|
2483
|
-
children: /* @__PURE__ */
|
|
2483
|
+
children: /* @__PURE__ */ $("div", {
|
|
2484
2484
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
2485
|
-
children: [be && /* @__PURE__ */
|
|
2485
|
+
children: [be && /* @__PURE__ */ Q(N, {
|
|
2486
2486
|
type: "button",
|
|
2487
2487
|
variant: "outline",
|
|
2488
2488
|
onClick: _e,
|
|
2489
2489
|
disabled: U,
|
|
2490
2490
|
className: "w-full sm:w-auto",
|
|
2491
|
-
children:
|
|
2492
|
-
}), ye && /* @__PURE__ */
|
|
2491
|
+
children: Se
|
|
2492
|
+
}), ye && /* @__PURE__ */ $(N, {
|
|
2493
2493
|
type: "submit",
|
|
2494
|
-
form:
|
|
2494
|
+
form: se,
|
|
2495
2495
|
disabled: U,
|
|
2496
2496
|
className: "w-full sm:w-auto",
|
|
2497
|
-
children: [U && /* @__PURE__ */
|
|
2497
|
+
children: [U && /* @__PURE__ */ Q(ue, { className: "mr-2 h-4 w-4 animate-spin" }), xe]
|
|
2498
2498
|
})]
|
|
2499
2499
|
})
|
|
2500
2500
|
}),
|
|
2501
|
-
/* @__PURE__ */
|
|
2502
|
-
open:
|
|
2503
|
-
onOpenChange:
|
|
2504
|
-
children: /* @__PURE__ */
|
|
2501
|
+
/* @__PURE__ */ Q(T, {
|
|
2502
|
+
open: ne,
|
|
2503
|
+
onOpenChange: q,
|
|
2504
|
+
children: /* @__PURE__ */ $(O, { children: [/* @__PURE__ */ $(j, { children: [/* @__PURE__ */ Q(M, { children: d("form.discardTitle") }), /* @__PURE__ */ Q(k, { children: d("form.discardMessage") })] }), /* @__PURE__ */ $(A, { children: [/* @__PURE__ */ Q(D, {
|
|
2505
2505
|
onClick: () => {
|
|
2506
|
-
|
|
2506
|
+
ie.current = !1;
|
|
2507
2507
|
},
|
|
2508
2508
|
children: d("form.keepEditing")
|
|
2509
|
-
}), /* @__PURE__ */
|
|
2510
|
-
onClick:
|
|
2509
|
+
}), /* @__PURE__ */ Q(E, {
|
|
2510
|
+
onClick: he,
|
|
2511
2511
|
children: d("form.discard")
|
|
2512
2512
|
})] })] })
|
|
2513
2513
|
}),
|
|
2514
|
-
|
|
2514
|
+
X
|
|
2515
2515
|
]
|
|
2516
2516
|
})
|
|
2517
2517
|
});
|
|
2518
2518
|
};
|
|
2519
2519
|
//#endregion
|
|
2520
2520
|
//#region src/ObjectForm.tsx
|
|
2521
|
-
function
|
|
2521
|
+
function Vt(e) {
|
|
2522
2522
|
let t = e.buttons, n = e.defaults;
|
|
2523
2523
|
if (!t && !n) return e;
|
|
2524
2524
|
let r = e, i = { ...r };
|
|
2525
2525
|
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;
|
|
2526
2526
|
}
|
|
2527
|
-
var
|
|
2528
|
-
let n =
|
|
2529
|
-
let t =
|
|
2527
|
+
var Ht = ({ schema: e, dataSource: t }) => {
|
|
2528
|
+
let n = re(), r = o(() => {
|
|
2529
|
+
let t = Vt(e), r = t.groups, i = !t.sections?.length && Array.isArray(r) && r.length ? {
|
|
2530
2530
|
...t,
|
|
2531
2531
|
sections: r.map((e) => ({
|
|
2532
2532
|
label: e.title ?? e.label,
|
|
@@ -2550,8 +2550,8 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2550
2550
|
fields: o(e.fields)
|
|
2551
2551
|
}))
|
|
2552
2552
|
};
|
|
2553
|
-
}, [e, n]), { sectionLabel: i } =
|
|
2554
|
-
if (r.subforms?.length && r.mode !== "view" && r.formType !== "drawer" && r.formType !== "modal") return /* @__PURE__ */
|
|
2553
|
+
}, [e, n]), { sectionLabel: i } = y(), a = (e) => e?.name ? i(r.objectName, e.name, e.label || e.name) : e?.label;
|
|
2554
|
+
if (r.subforms?.length && r.mode !== "view" && r.formType !== "drawer" && r.formType !== "modal") return /* @__PURE__ */ Q(Nt, {
|
|
2555
2555
|
schema: {
|
|
2556
2556
|
type: "object-master-detail-form",
|
|
2557
2557
|
objectName: r.objectName,
|
|
@@ -2574,7 +2574,7 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2574
2574
|
},
|
|
2575
2575
|
dataSource: t
|
|
2576
2576
|
});
|
|
2577
|
-
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */
|
|
2577
|
+
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ Q(Ke, {
|
|
2578
2578
|
schema: {
|
|
2579
2579
|
...r,
|
|
2580
2580
|
formType: "tabbed",
|
|
@@ -2593,7 +2593,7 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2593
2593
|
dataSource: t,
|
|
2594
2594
|
className: r.className
|
|
2595
2595
|
});
|
|
2596
|
-
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */
|
|
2596
|
+
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ Q(Xe, {
|
|
2597
2597
|
schema: {
|
|
2598
2598
|
...r,
|
|
2599
2599
|
formType: "wizard",
|
|
@@ -2615,7 +2615,7 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2615
2615
|
dataSource: t,
|
|
2616
2616
|
className: r.className
|
|
2617
2617
|
});
|
|
2618
|
-
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */
|
|
2618
|
+
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ Q(Ze, {
|
|
2619
2619
|
schema: {
|
|
2620
2620
|
...r,
|
|
2621
2621
|
formType: "split",
|
|
@@ -2638,7 +2638,7 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2638
2638
|
});
|
|
2639
2639
|
if (r.formType === "drawer") {
|
|
2640
2640
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
2641
|
-
return /* @__PURE__ */
|
|
2641
|
+
return /* @__PURE__ */ Q(It, {
|
|
2642
2642
|
schema: {
|
|
2643
2643
|
...n,
|
|
2644
2644
|
layout: i,
|
|
@@ -2664,7 +2664,7 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2664
2664
|
}
|
|
2665
2665
|
if (r.formType === "modal") {
|
|
2666
2666
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
2667
|
-
return /* @__PURE__ */
|
|
2667
|
+
return /* @__PURE__ */ Q(Bt, {
|
|
2668
2668
|
schema: {
|
|
2669
2669
|
...n,
|
|
2670
2670
|
layout: i,
|
|
@@ -2687,12 +2687,12 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2687
2687
|
className: r.className
|
|
2688
2688
|
});
|
|
2689
2689
|
}
|
|
2690
|
-
return /* @__PURE__ */
|
|
2690
|
+
return /* @__PURE__ */ Q(Ut, {
|
|
2691
2691
|
schema: r,
|
|
2692
2692
|
dataSource: t
|
|
2693
2693
|
});
|
|
2694
|
-
},
|
|
2695
|
-
let { fieldLabel: a, sectionLabel: o } =
|
|
2694
|
+
}, Ut = ({ schema: e, dataSource: r }) => {
|
|
2695
|
+
let { fieldLabel: a, sectionLabel: o } = y(), s = X(), l = re(), u = n((t) => {
|
|
2696
2696
|
if (!l?.isLoaded) return t;
|
|
2697
2697
|
let n = [];
|
|
2698
2698
|
for (let r of t) l.checkField(e.objectName, r.name, "read") && (!l.checkField(e.objectName, r.name, "write") && e.mode !== "view" ? n.push({
|
|
@@ -2706,9 +2706,9 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2706
2706
|
l,
|
|
2707
2707
|
e.objectName,
|
|
2708
2708
|
e.mode
|
|
2709
|
-
]), [
|
|
2709
|
+
]), [d, p] = c(null), [m, g] = c([]), [_, v] = c(null), [b, x] = c(!0), [T, E] = c(null), [D, O] = c(null), { saveWithOcc: k, conflictDialog: A } = Ge(), j = e.customFields && e.customFields.length > 0;
|
|
2710
2710
|
i(() => {
|
|
2711
|
-
j && (
|
|
2711
|
+
j && (v(e.initialData || e.initialValues || {}), x(!1));
|
|
2712
2712
|
}, [
|
|
2713
2713
|
j,
|
|
2714
2714
|
e.initialData,
|
|
@@ -2724,32 +2724,32 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2724
2724
|
if (!t) throw Error(`No schema found for object "${e.objectName}"`);
|
|
2725
2725
|
p(t);
|
|
2726
2726
|
} catch (e) {
|
|
2727
|
-
E(e),
|
|
2727
|
+
E(e), x(!1);
|
|
2728
2728
|
}
|
|
2729
|
-
})() : j ||
|
|
2729
|
+
})() : j || x(!1);
|
|
2730
2730
|
}, [
|
|
2731
2731
|
e.objectName,
|
|
2732
2732
|
r,
|
|
2733
2733
|
j
|
|
2734
2734
|
]), i(() => {
|
|
2735
|
-
|
|
2735
|
+
d && !j && (async () => {
|
|
2736
2736
|
if (!e.recordId || e.mode === "create") {
|
|
2737
|
-
|
|
2737
|
+
v(e.initialData || e.initialValues || {}), x(!1);
|
|
2738
2738
|
return;
|
|
2739
2739
|
}
|
|
2740
2740
|
if (!j) {
|
|
2741
2741
|
if (!r) {
|
|
2742
|
-
E(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")),
|
|
2742
|
+
E(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), x(!1);
|
|
2743
2743
|
return;
|
|
2744
2744
|
}
|
|
2745
|
-
|
|
2745
|
+
x(!0);
|
|
2746
2746
|
try {
|
|
2747
2747
|
let t = await r.findOne(e.objectName, e.recordId);
|
|
2748
|
-
|
|
2748
|
+
v(t);
|
|
2749
2749
|
} catch (e) {
|
|
2750
2750
|
console.error("Failed to fetch record:", e), E(e);
|
|
2751
2751
|
} finally {
|
|
2752
|
-
|
|
2752
|
+
x(!1);
|
|
2753
2753
|
}
|
|
2754
2754
|
}
|
|
2755
2755
|
})();
|
|
@@ -2760,21 +2760,21 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2760
2760
|
e.initialValues,
|
|
2761
2761
|
e.initialData,
|
|
2762
2762
|
r,
|
|
2763
|
-
|
|
2763
|
+
d,
|
|
2764
2764
|
j
|
|
2765
2765
|
]);
|
|
2766
2766
|
let M = n((e) => e, []);
|
|
2767
2767
|
i(() => {
|
|
2768
2768
|
if (j && e.customFields) {
|
|
2769
|
-
g(e.customFields.map(M)),
|
|
2769
|
+
g(e.customFields.map(M)), x(!1);
|
|
2770
2770
|
return;
|
|
2771
2771
|
}
|
|
2772
|
-
if (!
|
|
2773
|
-
let t = [], n = d
|
|
2772
|
+
if (!d) return;
|
|
2773
|
+
let t = [], n = f(d, l?.getObjectApiOperations?.(e.objectName)), i = !(e.mode === "edit" ? n.edit : e.mode !== "create" || n.create), o = e.fields || Object.keys(d.fields || {});
|
|
2774
2774
|
(Array.isArray(o) ? o : Object.keys(o)).forEach((n) => {
|
|
2775
2775
|
let r = typeof n == "string" ? n : n.name;
|
|
2776
2776
|
if (!r) return;
|
|
2777
|
-
let o =
|
|
2777
|
+
let o = d.fields?.[r];
|
|
2778
2778
|
if (!o && !j) return;
|
|
2779
2779
|
let s = e.customFields?.find((e) => e.name === r);
|
|
2780
2780
|
if (s) t.push(M(s));
|
|
@@ -2782,12 +2782,12 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2782
2782
|
let s = {
|
|
2783
2783
|
name: r,
|
|
2784
2784
|
label: a(e.objectName, r, o.label || n),
|
|
2785
|
-
type:
|
|
2785
|
+
type: w(o.type),
|
|
2786
2786
|
required: o.required || !1,
|
|
2787
2787
|
disabled: e.readOnly || e.mode === "view" || o.readonly || i,
|
|
2788
2788
|
placeholder: o.placeholder,
|
|
2789
2789
|
description: o.help || o.description,
|
|
2790
|
-
validation:
|
|
2790
|
+
validation: S(o),
|
|
2791
2791
|
visibleWhen: o.visibleWhen,
|
|
2792
2792
|
readonlyWhen: o.readonlyWhen,
|
|
2793
2793
|
requiredWhen: o.requiredWhen,
|
|
@@ -2796,14 +2796,14 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2796
2796
|
widget: o.widget
|
|
2797
2797
|
};
|
|
2798
2798
|
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)) {
|
|
2799
|
-
let e = `Max size: ${
|
|
2799
|
+
let e = `Max size: ${C(o.max_size)}`;
|
|
2800
2800
|
s.description = s.description ? `${s.description} (${e})` : e;
|
|
2801
2801
|
}
|
|
2802
2802
|
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);
|
|
2803
2803
|
}
|
|
2804
|
-
}), g(t), !j && e.recordId && e.mode !== "create" && r ||
|
|
2804
|
+
}), g(t), !j && e.recordId && e.mode !== "create" && r || x(!1);
|
|
2805
2805
|
}, [
|
|
2806
|
-
|
|
2806
|
+
d,
|
|
2807
2807
|
e.fields,
|
|
2808
2808
|
e.customFields,
|
|
2809
2809
|
e.readOnly,
|
|
@@ -2817,7 +2817,7 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2817
2817
|
let N = n(async (t, n) => {
|
|
2818
2818
|
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;
|
|
2819
2819
|
if (!r) throw Error("DataSource is required for form submission (inline mode not configured)");
|
|
2820
|
-
let i =
|
|
2820
|
+
let i = et(t, j ? null : d);
|
|
2821
2821
|
if (l?.isLoaded && i && typeof i == "object") {
|
|
2822
2822
|
let t = {};
|
|
2823
2823
|
for (let n of Object.keys(i)) l.checkField(e.objectName, n, "write") && (t[n] = i[n]);
|
|
@@ -2843,12 +2843,12 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2843
2843
|
let t = e.submitBehavior;
|
|
2844
2844
|
switch (t.kind) {
|
|
2845
2845
|
case "redirect":
|
|
2846
|
-
|
|
2846
|
+
ge(t.url) && setTimeout(() => window.location.assign(t.url), t.delayMs ?? 0);
|
|
2847
2847
|
break;
|
|
2848
2848
|
case "continue": break;
|
|
2849
2849
|
default: {
|
|
2850
2850
|
let n = t.kind === "thank-you" && t.message ? t.message : e.successMessage || (e.mode === "create" ? "Created" : "Saved");
|
|
2851
|
-
|
|
2851
|
+
Y.success(n), O({
|
|
2852
2852
|
title: t.kind === "thank-you" ? t.title : void 0,
|
|
2853
2853
|
message: n
|
|
2854
2854
|
});
|
|
@@ -2856,9 +2856,9 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2856
2856
|
}
|
|
2857
2857
|
}
|
|
2858
2858
|
} else if (!e.submitHandler) {
|
|
2859
|
-
let n =
|
|
2859
|
+
let n = _e(e.navigateOnSuccess, t);
|
|
2860
2860
|
if (n) return window.location.assign(n), t;
|
|
2861
|
-
|
|
2861
|
+
Y.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved"));
|
|
2862
2862
|
}
|
|
2863
2863
|
return t;
|
|
2864
2864
|
} catch (t) {
|
|
@@ -2869,63 +2869,63 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2869
2869
|
r,
|
|
2870
2870
|
j,
|
|
2871
2871
|
l,
|
|
2872
|
-
|
|
2872
|
+
d,
|
|
2873
2873
|
k,
|
|
2874
2874
|
_
|
|
2875
2875
|
]), P = n(() => {
|
|
2876
2876
|
e.onCancel && e.onCancel();
|
|
2877
2877
|
}, [e]), F = {
|
|
2878
2878
|
...t.useMemo(() => {
|
|
2879
|
-
if (!
|
|
2879
|
+
if (!d?.fields) return {};
|
|
2880
2880
|
let e = {};
|
|
2881
|
-
return Object.keys(
|
|
2882
|
-
let n =
|
|
2881
|
+
return Object.keys(d.fields).forEach((t) => {
|
|
2882
|
+
let n = d.fields[t];
|
|
2883
2883
|
n.defaultValue !== void 0 && (e[t] = n.defaultValue);
|
|
2884
2884
|
}), e;
|
|
2885
|
-
}, [
|
|
2885
|
+
}, [d]),
|
|
2886
2886
|
..._
|
|
2887
2887
|
}, I = t.useMemo(() => {
|
|
2888
|
-
let t =
|
|
2889
|
-
return e.mode === "create" && (t =
|
|
2888
|
+
let t = Pe(m, d);
|
|
2889
|
+
return e.mode === "create" && (t = Ie(t, d)), t;
|
|
2890
2890
|
}, [
|
|
2891
|
-
|
|
2892
|
-
|
|
2891
|
+
m,
|
|
2892
|
+
d,
|
|
2893
2893
|
e.mode
|
|
2894
|
-
]), L = t.useMemo(() => e.sections?.length ? null :
|
|
2894
|
+
]), L = t.useMemo(() => e.sections?.length ? null : Lt(I, d?.fieldGroups), [
|
|
2895
2895
|
e.sections,
|
|
2896
2896
|
I,
|
|
2897
|
-
|
|
2897
|
+
d
|
|
2898
2898
|
]), R = e.sections?.length ? e.sections : L, [z, B] = c({});
|
|
2899
|
-
if (T) return /* @__PURE__ */
|
|
2899
|
+
if (T) return /* @__PURE__ */ $("div", {
|
|
2900
2900
|
className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
|
|
2901
|
-
children: [/* @__PURE__ */
|
|
2901
|
+
children: [/* @__PURE__ */ Q("h3", {
|
|
2902
2902
|
className: "text-red-800 font-semibold",
|
|
2903
2903
|
children: "Error loading form"
|
|
2904
|
-
}), /* @__PURE__ */
|
|
2904
|
+
}), /* @__PURE__ */ Q("p", {
|
|
2905
2905
|
className: "text-red-600 text-sm mt-1",
|
|
2906
2906
|
children: T.message
|
|
2907
2907
|
})]
|
|
2908
2908
|
});
|
|
2909
|
-
if (b) return /* @__PURE__ */
|
|
2909
|
+
if (b) return /* @__PURE__ */ $("div", {
|
|
2910
2910
|
className: "p-4 sm:p-8 text-center",
|
|
2911
|
-
children: [/* @__PURE__ */
|
|
2911
|
+
children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
|
|
2912
2912
|
className: "mt-2 text-sm text-gray-600",
|
|
2913
2913
|
children: "Loading form..."
|
|
2914
2914
|
})]
|
|
2915
2915
|
});
|
|
2916
|
-
if (D) return /* @__PURE__ */
|
|
2916
|
+
if (D) return /* @__PURE__ */ $("div", {
|
|
2917
2917
|
className: "rounded-md border bg-card p-6 sm:p-8 text-center",
|
|
2918
|
-
children: [/* @__PURE__ */
|
|
2918
|
+
children: [/* @__PURE__ */ Q("h3", {
|
|
2919
2919
|
className: "text-lg font-semibold",
|
|
2920
2920
|
children: D.title ?? "Thanks!"
|
|
2921
|
-
}), D.message && /* @__PURE__ */
|
|
2921
|
+
}), D.message && /* @__PURE__ */ Q("p", {
|
|
2922
2922
|
className: "mt-2 text-sm text-muted-foreground",
|
|
2923
2923
|
children: D.message
|
|
2924
2924
|
})]
|
|
2925
2925
|
});
|
|
2926
2926
|
let V = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical";
|
|
2927
2927
|
if (R?.length && (!e.formType || e.formType === "simple")) {
|
|
2928
|
-
let t = L ? I :
|
|
2928
|
+
let t = L ? I : m, 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) : ke(i)), s = [];
|
|
2929
2929
|
R.forEach((r, i) => {
|
|
2930
2930
|
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) => {
|
|
2931
2931
|
let t = c.get(e.name);
|
|
@@ -2948,16 +2948,16 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2948
2948
|
})) : void 0,
|
|
2949
2949
|
className: r.className
|
|
2950
2950
|
});
|
|
2951
|
-
let h = n(r.columns), g = a > 1 ?
|
|
2951
|
+
let h = n(r.columns), g = a > 1 ? Me(d, a, h) : d;
|
|
2952
2952
|
p && m ? s.push(...g.map((e) => ({
|
|
2953
2953
|
...e,
|
|
2954
2954
|
hidden: !0
|
|
2955
2955
|
}))) : s.push(...g);
|
|
2956
2956
|
});
|
|
2957
|
-
let c = s, l =
|
|
2958
|
-
return /* @__PURE__ */
|
|
2957
|
+
let c = s, l = Re(a);
|
|
2958
|
+
return /* @__PURE__ */ $("div", {
|
|
2959
2959
|
className: "w-full @container",
|
|
2960
|
-
children: [/* @__PURE__ */
|
|
2960
|
+
children: [/* @__PURE__ */ Q(h, { schema: {
|
|
2961
2961
|
type: "form",
|
|
2962
2962
|
objectName: e.objectName,
|
|
2963
2963
|
fields: c,
|
|
@@ -2974,10 +2974,10 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2974
2974
|
} }), A]
|
|
2975
2975
|
});
|
|
2976
2976
|
}
|
|
2977
|
-
let H = e.sections?.length, ee = u(
|
|
2977
|
+
let H = e.sections?.length, ee = u(m), U = H ? {
|
|
2978
2978
|
fields: ee,
|
|
2979
2979
|
columns: e.columns
|
|
2980
|
-
} :
|
|
2980
|
+
} : Be(ee, d, e.columns, e.mode), W = e.mobile, G = W?.fullscreenLongText ? U.fields.map((e) => {
|
|
2981
2981
|
let t = e.type;
|
|
2982
2982
|
return t === "textarea" || t === "field:textarea" || t === "string-multiline" || t === "field:markdown" || t === "field:html" ? {
|
|
2983
2983
|
...e,
|
|
@@ -2994,7 +2994,7 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
2994
2994
|
fields: r
|
|
2995
2995
|
});
|
|
2996
2996
|
}
|
|
2997
|
-
return /* @__PURE__ */
|
|
2997
|
+
return /* @__PURE__ */ Q(Xe, {
|
|
2998
2998
|
schema: {
|
|
2999
2999
|
...e,
|
|
3000
3000
|
formType: "wizard",
|
|
@@ -3022,12 +3022,12 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
3022
3022
|
className: e.className,
|
|
3023
3023
|
mobileStickyActions: !!W?.stickyActions
|
|
3024
3024
|
};
|
|
3025
|
-
return /* @__PURE__ */
|
|
3025
|
+
return /* @__PURE__ */ $("div", {
|
|
3026
3026
|
className: W?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
|
|
3027
3027
|
"data-mobile-form": W ? "true" : void 0,
|
|
3028
|
-
children: [/* @__PURE__ */
|
|
3028
|
+
children: [/* @__PURE__ */ Q(h, { schema: q }), A]
|
|
3029
3029
|
});
|
|
3030
|
-
},
|
|
3030
|
+
}, Wt = {
|
|
3031
3031
|
text: 200,
|
|
3032
3032
|
email: 254,
|
|
3033
3033
|
url: 2048,
|
|
@@ -3035,8 +3035,8 @@ var Vt = ({ schema: e, dataSource: t }) => {
|
|
|
3035
3035
|
textarea: 5e3,
|
|
3036
3036
|
markdown: 5e3,
|
|
3037
3037
|
html: 5e3
|
|
3038
|
-
},
|
|
3039
|
-
function
|
|
3038
|
+
}, Gt = "_company_website_2", Kt = 1500;
|
|
3039
|
+
function qt(e, t = []) {
|
|
3040
3040
|
try {
|
|
3041
3041
|
let n = new URL(e, typeof window < "u" ? window.location.href : "http://localhost");
|
|
3042
3042
|
return typeof window < "u" && n.origin === window.location.origin ? !0 : n.protocol !== "https:" && n.protocol !== "http:" ? !1 : t.some((e) => {
|
|
@@ -3051,21 +3051,21 @@ function Kt(e, t = []) {
|
|
|
3051
3051
|
return !1;
|
|
3052
3052
|
}
|
|
3053
3053
|
}
|
|
3054
|
-
function
|
|
3054
|
+
function Jt(e) {
|
|
3055
3055
|
return e && e.map((e) => {
|
|
3056
|
-
let t =
|
|
3056
|
+
let t = Wt[String(e.type || "").toLowerCase()];
|
|
3057
3057
|
return !t || (e.maxLength ?? e.max_length) ? e : {
|
|
3058
3058
|
...e,
|
|
3059
3059
|
maxLength: t
|
|
3060
3060
|
};
|
|
3061
3061
|
});
|
|
3062
3062
|
}
|
|
3063
|
-
var
|
|
3063
|
+
var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
3064
3064
|
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);
|
|
3065
3065
|
i(() => {
|
|
3066
3066
|
l || (b.current = Date.now());
|
|
3067
3067
|
}, [l]);
|
|
3068
|
-
let x = e.honeypot === !1 ? null : e.honeypot ||
|
|
3068
|
+
let x = e.honeypot === !1 ? null : e.honeypot || Gt, S = e.minFillTime ?? Kt, C = o(() => Jt(e.customFields), [e.customFields]), w = o(() => {
|
|
3069
3069
|
if (!t || C && C.length > 0 || !e.fields || e.fields.length === 0) return;
|
|
3070
3070
|
let n = async (e, t) => t;
|
|
3071
3071
|
return {
|
|
@@ -3106,7 +3106,7 @@ var Jt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3106
3106
|
try {
|
|
3107
3107
|
t && await t.create(e.objectName, r), u(!0);
|
|
3108
3108
|
let n = e.thankYouPage?.redirectUrl;
|
|
3109
|
-
if (n) if (
|
|
3109
|
+
if (n) if (qt(n, e.allowedRedirectHosts)) {
|
|
3110
3110
|
let t = e.thankYouPage?.redirectDelay ?? 3e3;
|
|
3111
3111
|
setTimeout(() => {
|
|
3112
3112
|
window.location.href = n;
|
|
@@ -3131,35 +3131,35 @@ var Jt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3131
3131
|
}, [e.branding]);
|
|
3132
3132
|
if (l) {
|
|
3133
3133
|
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));
|
|
3134
|
-
return /* @__PURE__ */
|
|
3134
|
+
return /* @__PURE__ */ Q("div", {
|
|
3135
3135
|
className: `min-h-screen flex items-center justify-center p-4 bg-gradient-to-b from-muted/40 via-background to-background ${a || ""}`,
|
|
3136
3136
|
style: O,
|
|
3137
|
-
children: /* @__PURE__ */
|
|
3137
|
+
children: /* @__PURE__ */ $("div", {
|
|
3138
3138
|
className: "max-w-md w-full bg-card border rounded-xl shadow-sm p-8 text-center space-y-4",
|
|
3139
3139
|
children: [
|
|
3140
|
-
/* @__PURE__ */
|
|
3140
|
+
/* @__PURE__ */ Q("div", {
|
|
3141
3141
|
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",
|
|
3142
|
-
children: /* @__PURE__ */
|
|
3142
|
+
children: /* @__PURE__ */ Q(se, {
|
|
3143
3143
|
className: "h-8 w-8",
|
|
3144
3144
|
"aria-hidden": "true"
|
|
3145
3145
|
})
|
|
3146
3146
|
}),
|
|
3147
|
-
/* @__PURE__ */
|
|
3147
|
+
/* @__PURE__ */ Q("h2", {
|
|
3148
3148
|
className: "text-xl font-semibold text-foreground",
|
|
3149
3149
|
children: t?.title || n.thankYouTitle || "Thank You!"
|
|
3150
3150
|
}),
|
|
3151
|
-
/* @__PURE__ */
|
|
3151
|
+
/* @__PURE__ */ Q("p", {
|
|
3152
3152
|
className: "text-sm text-muted-foreground",
|
|
3153
3153
|
children: t?.message || n.thankYouMessage || "Your submission has been received successfully."
|
|
3154
3154
|
}),
|
|
3155
|
-
e.allowMultiple && /* @__PURE__ */
|
|
3155
|
+
e.allowMultiple && /* @__PURE__ */ Q(N, {
|
|
3156
3156
|
variant: "outline",
|
|
3157
3157
|
size: "sm",
|
|
3158
3158
|
onClick: D,
|
|
3159
3159
|
className: "mt-2",
|
|
3160
3160
|
children: n.submitAnother ?? "Submit Another Response"
|
|
3161
3161
|
}),
|
|
3162
|
-
t?.redirectUrl && /* @__PURE__ */
|
|
3162
|
+
t?.redirectUrl && /* @__PURE__ */ Q("p", {
|
|
3163
3163
|
className: "text-xs text-muted-foreground",
|
|
3164
3164
|
children: i
|
|
3165
3165
|
})
|
|
@@ -3168,51 +3168,51 @@ var Jt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3168
3168
|
});
|
|
3169
3169
|
}
|
|
3170
3170
|
let k = e.texts ?? {}, A = !!e.consent?.required, j = `${e.formId}-consent`;
|
|
3171
|
-
return /* @__PURE__ */
|
|
3171
|
+
return /* @__PURE__ */ Q("div", {
|
|
3172
3172
|
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 || ""}`,
|
|
3173
3173
|
style: O,
|
|
3174
|
-
children: /* @__PURE__ */
|
|
3174
|
+
children: /* @__PURE__ */ $("div", {
|
|
3175
3175
|
className: "max-w-2xl w-full bg-card border rounded-xl shadow-sm overflow-hidden",
|
|
3176
3176
|
children: [
|
|
3177
|
-
e.branding?.coverImage && /* @__PURE__ */
|
|
3177
|
+
e.branding?.coverImage && /* @__PURE__ */ Q("div", {
|
|
3178
3178
|
className: "h-28 sm:h-32 w-full bg-cover bg-center",
|
|
3179
3179
|
style: { backgroundImage: `url(${JSON.stringify(e.branding.coverImage)})` },
|
|
3180
3180
|
role: "presentation"
|
|
3181
3181
|
}),
|
|
3182
|
-
/* @__PURE__ */
|
|
3182
|
+
/* @__PURE__ */ $("div", {
|
|
3183
3183
|
className: "px-6 sm:px-8 pt-7 pb-5 border-b bg-muted/20",
|
|
3184
3184
|
style: e.branding?.primaryColor ? { borderBottomColor: e.branding.primaryColor } : void 0,
|
|
3185
3185
|
children: [
|
|
3186
|
-
e.branding?.logo && /* @__PURE__ */
|
|
3186
|
+
e.branding?.logo && /* @__PURE__ */ Q("img", {
|
|
3187
3187
|
src: e.branding.logo,
|
|
3188
3188
|
alt: "",
|
|
3189
3189
|
className: "h-8 mb-4"
|
|
3190
3190
|
}),
|
|
3191
|
-
e.title && /* @__PURE__ */
|
|
3191
|
+
e.title && /* @__PURE__ */ Q("h1", {
|
|
3192
3192
|
className: "text-2xl font-semibold tracking-tight text-foreground",
|
|
3193
3193
|
children: e.title
|
|
3194
3194
|
}),
|
|
3195
|
-
e.description && /* @__PURE__ */
|
|
3195
|
+
e.description && /* @__PURE__ */ Q("p", {
|
|
3196
3196
|
className: "text-sm text-muted-foreground mt-2 leading-relaxed",
|
|
3197
3197
|
children: e.description
|
|
3198
3198
|
}),
|
|
3199
|
-
/* @__PURE__ */
|
|
3199
|
+
/* @__PURE__ */ Q("p", {
|
|
3200
3200
|
className: "text-[11px] text-muted-foreground/70 mt-3",
|
|
3201
3201
|
"aria-hidden": "true",
|
|
3202
3202
|
children: k.requiredHint ?? "* Required field"
|
|
3203
3203
|
})
|
|
3204
3204
|
]
|
|
3205
3205
|
}),
|
|
3206
|
-
/* @__PURE__ */
|
|
3206
|
+
/* @__PURE__ */ $("div", {
|
|
3207
3207
|
className: "relative px-6 sm:px-8 py-6",
|
|
3208
3208
|
children: [
|
|
3209
|
-
p && /* @__PURE__ */
|
|
3209
|
+
p && /* @__PURE__ */ Q("div", {
|
|
3210
3210
|
role: "alert",
|
|
3211
3211
|
"aria-live": "assertive",
|
|
3212
3212
|
className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
|
|
3213
3213
|
children: p
|
|
3214
3214
|
}),
|
|
3215
|
-
/* @__PURE__ */
|
|
3215
|
+
/* @__PURE__ */ Q(Ht, {
|
|
3216
3216
|
schema: {
|
|
3217
3217
|
type: "object-form",
|
|
3218
3218
|
objectName: e.objectName,
|
|
@@ -3225,13 +3225,13 @@ var Jt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3225
3225
|
},
|
|
3226
3226
|
dataSource: w
|
|
3227
3227
|
}),
|
|
3228
|
-
x && /* @__PURE__ */
|
|
3228
|
+
x && /* @__PURE__ */ $("div", {
|
|
3229
3229
|
"aria-hidden": "true",
|
|
3230
3230
|
className: "absolute left-[-10000px] top-auto h-px w-px overflow-hidden",
|
|
3231
|
-
children: [/* @__PURE__ */
|
|
3231
|
+
children: [/* @__PURE__ */ Q("label", {
|
|
3232
3232
|
htmlFor: `${e.formId}-${x}`,
|
|
3233
3233
|
children: "Do not fill this field"
|
|
3234
|
-
}), /* @__PURE__ */
|
|
3234
|
+
}), /* @__PURE__ */ Q("input", {
|
|
3235
3235
|
ref: y,
|
|
3236
3236
|
id: `${e.formId}-${x}`,
|
|
3237
3237
|
type: "text",
|
|
@@ -3241,11 +3241,11 @@ var Jt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3241
3241
|
defaultValue: ""
|
|
3242
3242
|
})]
|
|
3243
3243
|
}),
|
|
3244
|
-
e.consent && /* @__PURE__ */
|
|
3244
|
+
e.consent && /* @__PURE__ */ $("div", {
|
|
3245
3245
|
className: "mt-4",
|
|
3246
|
-
children: [/* @__PURE__ */
|
|
3246
|
+
children: [/* @__PURE__ */ $("label", {
|
|
3247
3247
|
className: "flex items-start gap-2 text-sm text-foreground cursor-pointer select-none",
|
|
3248
|
-
children: [/* @__PURE__ */
|
|
3248
|
+
children: [/* @__PURE__ */ Q("input", {
|
|
3249
3249
|
type: "checkbox",
|
|
3250
3250
|
id: j,
|
|
3251
3251
|
checked: h,
|
|
@@ -3256,16 +3256,16 @@ var Jt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3256
3256
|
"aria-invalid": _ ? "true" : void 0,
|
|
3257
3257
|
"aria-describedby": _ ? `${j}-error` : void 0,
|
|
3258
3258
|
className: "mt-0.5 h-4 w-4 rounded border-input accent-primary"
|
|
3259
|
-
}), /* @__PURE__ */
|
|
3259
|
+
}), /* @__PURE__ */ $("span", {
|
|
3260
3260
|
className: "leading-relaxed",
|
|
3261
3261
|
children: [
|
|
3262
3262
|
e.consent.label ?? k.consentLabelDefault ?? "I agree to the privacy policy.",
|
|
3263
|
-
A && /* @__PURE__ */
|
|
3263
|
+
A && /* @__PURE__ */ Q("span", {
|
|
3264
3264
|
"aria-hidden": "true",
|
|
3265
3265
|
className: "text-destructive ml-0.5",
|
|
3266
3266
|
children: "*"
|
|
3267
3267
|
}),
|
|
3268
|
-
e.consent.privacyUrl && /* @__PURE__ */
|
|
3268
|
+
e.consent.privacyUrl && /* @__PURE__ */ $(me, { children: [" ", /* @__PURE__ */ Q("a", {
|
|
3269
3269
|
href: e.consent.privacyUrl,
|
|
3270
3270
|
target: "_blank",
|
|
3271
3271
|
rel: "noopener noreferrer",
|
|
@@ -3274,42 +3274,42 @@ var Jt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3274
3274
|
})] })
|
|
3275
3275
|
]
|
|
3276
3276
|
})]
|
|
3277
|
-
}), _ && /* @__PURE__ */
|
|
3277
|
+
}), _ && /* @__PURE__ */ Q("p", {
|
|
3278
3278
|
id: `${j}-error`,
|
|
3279
3279
|
role: "alert",
|
|
3280
3280
|
className: "mt-1.5 text-xs text-destructive",
|
|
3281
3281
|
children: _
|
|
3282
3282
|
})]
|
|
3283
3283
|
}),
|
|
3284
|
-
d && /* @__PURE__ */
|
|
3284
|
+
d && /* @__PURE__ */ $("div", {
|
|
3285
3285
|
className: "mt-3 flex items-center gap-2 text-xs text-muted-foreground",
|
|
3286
|
-
children: [/* @__PURE__ */
|
|
3286
|
+
children: [/* @__PURE__ */ Q(ue, {
|
|
3287
3287
|
className: "h-3.5 w-3.5 animate-spin",
|
|
3288
3288
|
"aria-hidden": "true"
|
|
3289
|
-
}), /* @__PURE__ */
|
|
3289
|
+
}), /* @__PURE__ */ Q("span", { children: k.submitting ?? "Submitting…" })]
|
|
3290
3290
|
})
|
|
3291
3291
|
]
|
|
3292
3292
|
}),
|
|
3293
|
-
/* @__PURE__ */
|
|
3293
|
+
/* @__PURE__ */ $("div", {
|
|
3294
3294
|
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",
|
|
3295
|
-
children: [/* @__PURE__ */
|
|
3295
|
+
children: [/* @__PURE__ */ $("p", {
|
|
3296
3296
|
className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground",
|
|
3297
|
-
children: [/* @__PURE__ */
|
|
3297
|
+
children: [/* @__PURE__ */ Q(de, {
|
|
3298
3298
|
className: "h-3 w-3",
|
|
3299
3299
|
"aria-hidden": "true"
|
|
3300
|
-
}), /* @__PURE__ */
|
|
3301
|
-
}), /* @__PURE__ */
|
|
3300
|
+
}), /* @__PURE__ */ Q("span", { children: k.secureNotice ?? "Your information is transmitted securely and only used to respond to your request." })]
|
|
3301
|
+
}), /* @__PURE__ */ $("div", {
|
|
3302
3302
|
className: "flex items-center gap-3 text-xs text-muted-foreground/80",
|
|
3303
|
-
children: [e.privacyPolicyUrl && /* @__PURE__ */
|
|
3303
|
+
children: [e.privacyPolicyUrl && /* @__PURE__ */ $("a", {
|
|
3304
3304
|
href: e.privacyPolicyUrl,
|
|
3305
3305
|
target: "_blank",
|
|
3306
3306
|
rel: "noopener noreferrer",
|
|
3307
3307
|
className: "inline-flex items-center gap-1 underline hover:text-foreground",
|
|
3308
|
-
children: [/* @__PURE__ */
|
|
3308
|
+
children: [/* @__PURE__ */ Q(fe, {
|
|
3309
3309
|
className: "h-3 w-3",
|
|
3310
3310
|
"aria-hidden": "true"
|
|
3311
3311
|
}), k.consentLink ?? "Privacy policy"]
|
|
3312
|
-
}), /* @__PURE__ */
|
|
3312
|
+
}), /* @__PURE__ */ Q("span", { children: k.poweredBy ?? "Powered by ObjectStack" })]
|
|
3313
3313
|
})]
|
|
3314
3314
|
})
|
|
3315
3315
|
]
|
|
@@ -3318,96 +3318,96 @@ var Jt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3318
3318
|
};
|
|
3319
3319
|
//#endregion
|
|
3320
3320
|
//#region src/FormAnalytics.tsx
|
|
3321
|
-
function
|
|
3321
|
+
function Xt(e) {
|
|
3322
3322
|
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`;
|
|
3323
3323
|
}
|
|
3324
|
-
var
|
|
3324
|
+
var Zt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
3325
3325
|
let i = o(() => {
|
|
3326
3326
|
if (!n.abandonedSubmissions) return 100;
|
|
3327
3327
|
let e = n.totalSubmissions + n.abandonedSubmissions;
|
|
3328
3328
|
return e === 0 ? 0 : Math.round(n.totalSubmissions / e * 100);
|
|
3329
3329
|
}, [n.totalSubmissions, n.abandonedSubmissions]), a = o(() => n.dailySubmissions?.length ? Math.max(...n.dailySubmissions.map((e) => e.count), 1) : 1, [n.dailySubmissions]);
|
|
3330
|
-
return /* @__PURE__ */
|
|
3330
|
+
return /* @__PURE__ */ $("div", {
|
|
3331
3331
|
className: `space-y-4 ${r || ""}`,
|
|
3332
3332
|
children: [
|
|
3333
|
-
/* @__PURE__ */
|
|
3333
|
+
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q("h2", {
|
|
3334
3334
|
className: "text-lg font-semibold text-foreground",
|
|
3335
3335
|
children: t || "Form Analytics"
|
|
3336
|
-
}), /* @__PURE__ */
|
|
3336
|
+
}), /* @__PURE__ */ $("p", {
|
|
3337
3337
|
className: "text-sm text-muted-foreground",
|
|
3338
3338
|
children: ["Form ID: ", e]
|
|
3339
3339
|
})] }),
|
|
3340
|
-
/* @__PURE__ */
|
|
3340
|
+
/* @__PURE__ */ $("div", {
|
|
3341
3341
|
className: "grid grid-cols-1 sm:grid-cols-3 gap-4",
|
|
3342
3342
|
children: [
|
|
3343
|
-
/* @__PURE__ */
|
|
3343
|
+
/* @__PURE__ */ Q(P, { children: /* @__PURE__ */ $(L, {
|
|
3344
3344
|
className: "pb-2",
|
|
3345
|
-
children: [/* @__PURE__ */
|
|
3345
|
+
children: [/* @__PURE__ */ Q(I, { children: "Total Submissions" }), /* @__PURE__ */ Q(R, {
|
|
3346
3346
|
className: "text-2xl",
|
|
3347
3347
|
children: n.totalSubmissions.toLocaleString()
|
|
3348
3348
|
})]
|
|
3349
3349
|
}) }),
|
|
3350
|
-
/* @__PURE__ */
|
|
3350
|
+
/* @__PURE__ */ $(P, { children: [/* @__PURE__ */ $(L, {
|
|
3351
3351
|
className: "pb-2",
|
|
3352
|
-
children: [/* @__PURE__ */
|
|
3352
|
+
children: [/* @__PURE__ */ Q(I, { children: "Fill Rate" }), /* @__PURE__ */ $(R, {
|
|
3353
3353
|
className: "text-2xl",
|
|
3354
3354
|
children: [i, "%"]
|
|
3355
3355
|
})]
|
|
3356
|
-
}), /* @__PURE__ */
|
|
3356
|
+
}), /* @__PURE__ */ Q(F, { children: /* @__PURE__ */ Q("div", {
|
|
3357
3357
|
className: "w-full bg-muted rounded-full h-2",
|
|
3358
|
-
children: /* @__PURE__ */
|
|
3358
|
+
children: /* @__PURE__ */ Q("div", {
|
|
3359
3359
|
className: "bg-primary rounded-full h-2 transition-all",
|
|
3360
3360
|
style: { width: `${i}%` }
|
|
3361
3361
|
})
|
|
3362
3362
|
}) })] }),
|
|
3363
|
-
/* @__PURE__ */
|
|
3363
|
+
/* @__PURE__ */ Q(P, { children: /* @__PURE__ */ $(L, {
|
|
3364
3364
|
className: "pb-2",
|
|
3365
|
-
children: [/* @__PURE__ */
|
|
3365
|
+
children: [/* @__PURE__ */ Q(I, { children: "Avg. Completion Time" }), /* @__PURE__ */ Q(R, {
|
|
3366
3366
|
className: "text-2xl",
|
|
3367
|
-
children: n.avgCompletionTime ?
|
|
3367
|
+
children: n.avgCompletionTime ? Xt(n.avgCompletionTime) : "—"
|
|
3368
3368
|
})]
|
|
3369
3369
|
}) })
|
|
3370
3370
|
]
|
|
3371
3371
|
}),
|
|
3372
|
-
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */
|
|
3372
|
+
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ $(P, { children: [/* @__PURE__ */ Q(L, { children: /* @__PURE__ */ Q(R, {
|
|
3373
3373
|
className: "text-sm font-medium",
|
|
3374
3374
|
children: "Daily Submissions"
|
|
3375
|
-
}) }), /* @__PURE__ */
|
|
3375
|
+
}) }), /* @__PURE__ */ Q(F, { children: /* @__PURE__ */ Q("div", {
|
|
3376
3376
|
className: "flex items-end gap-1 h-32",
|
|
3377
|
-
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */
|
|
3377
|
+
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ $("div", {
|
|
3378
3378
|
className: "flex-1 flex flex-col items-center gap-1",
|
|
3379
|
-
children: [/* @__PURE__ */
|
|
3379
|
+
children: [/* @__PURE__ */ Q("div", {
|
|
3380
3380
|
className: "w-full bg-primary/80 rounded-t transition-all hover:bg-primary",
|
|
3381
3381
|
style: {
|
|
3382
3382
|
height: `${e.count / a * 100}%`,
|
|
3383
3383
|
minHeight: e.count > 0 ? "4px" : "0"
|
|
3384
3384
|
},
|
|
3385
3385
|
title: `${e.date}: ${e.count} submissions`
|
|
3386
|
-
}), /* @__PURE__ */
|
|
3386
|
+
}), /* @__PURE__ */ Q("span", {
|
|
3387
3387
|
className: "text-[10px] text-muted-foreground truncate w-full text-center",
|
|
3388
3388
|
children: e.date.slice(-5)
|
|
3389
3389
|
})]
|
|
3390
3390
|
}, t))
|
|
3391
3391
|
}) })] }),
|
|
3392
|
-
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */
|
|
3392
|
+
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ $(P, { children: [/* @__PURE__ */ $(L, { children: [/* @__PURE__ */ Q(R, {
|
|
3393
3393
|
className: "text-sm font-medium",
|
|
3394
3394
|
children: "Field Completion Rates"
|
|
3395
|
-
}), /* @__PURE__ */
|
|
3395
|
+
}), /* @__PURE__ */ Q(I, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ Q(F, { children: /* @__PURE__ */ Q("div", {
|
|
3396
3396
|
className: "space-y-3",
|
|
3397
|
-
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */
|
|
3397
|
+
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ $("div", {
|
|
3398
3398
|
className: "space-y-1",
|
|
3399
|
-
children: [/* @__PURE__ */
|
|
3399
|
+
children: [/* @__PURE__ */ $("div", {
|
|
3400
3400
|
className: "flex justify-between text-sm",
|
|
3401
|
-
children: [/* @__PURE__ */
|
|
3401
|
+
children: [/* @__PURE__ */ Q("span", {
|
|
3402
3402
|
className: "text-foreground",
|
|
3403
3403
|
children: e.label
|
|
3404
|
-
}), /* @__PURE__ */
|
|
3404
|
+
}), /* @__PURE__ */ $("span", {
|
|
3405
3405
|
className: "text-muted-foreground",
|
|
3406
3406
|
children: [e.completionRate, "%"]
|
|
3407
3407
|
})]
|
|
3408
|
-
}), /* @__PURE__ */
|
|
3408
|
+
}), /* @__PURE__ */ Q("div", {
|
|
3409
3409
|
className: "w-full bg-muted rounded-full h-1.5",
|
|
3410
|
-
children: /* @__PURE__ */
|
|
3410
|
+
children: /* @__PURE__ */ Q("div", {
|
|
3411
3411
|
className: `rounded-full h-1.5 transition-all ${e.completionRate >= 80 ? "bg-green-500" : e.completionRate >= 50 ? "bg-yellow-500" : "bg-destructive"}`,
|
|
3412
3412
|
style: { width: `${e.completionRate}%` }
|
|
3413
3413
|
})
|
|
@@ -3416,8 +3416,8 @@ var Xt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3416
3416
|
}) })] })
|
|
3417
3417
|
]
|
|
3418
3418
|
});
|
|
3419
|
-
},
|
|
3420
|
-
let t =
|
|
3419
|
+
}, Qt = ({ schema: e }) => {
|
|
3420
|
+
let t = b()?.dataSource, r = v(), a = e.parentObject || r?.objectName, s = e.parentId || e.recordId || r?.recordId, [l, u] = c([]), [d, f] = c([]), [p, h] = c(!0), [g, _] = c(!1), [y, S] = c(!1), [C, w] = c(null), [T, E] = c(null);
|
|
3421
3421
|
i(() => {
|
|
3422
3422
|
let n = t;
|
|
3423
3423
|
if (!n || typeof n.getObjectSchema != "function") return;
|
|
@@ -3460,20 +3460,20 @@ var Xt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3460
3460
|
u(e), S(!0);
|
|
3461
3461
|
}, []), k = n(async () => {
|
|
3462
3462
|
if (!(!t || !s)) {
|
|
3463
|
-
|
|
3463
|
+
_(!0), w(null);
|
|
3464
3464
|
try {
|
|
3465
|
-
let n = !!(a && e.totalField), r = n ? { [e.totalField]:
|
|
3465
|
+
let n = !!(a && e.totalField), r = n ? { [e.totalField]: ct(l, e.amountField || "amount") } : {}, i = ot(a ?? "", s, r, [{
|
|
3466
3466
|
childObject: e.childObject,
|
|
3467
3467
|
relationshipField: e.relationshipField,
|
|
3468
3468
|
rows: l,
|
|
3469
3469
|
original: d,
|
|
3470
3470
|
childSchema: T
|
|
3471
3471
|
}]);
|
|
3472
|
-
n || (i = i.slice(1)), i.length && await
|
|
3472
|
+
n || (i = i.slice(1)), i.length && await m(t, i), await D();
|
|
3473
3473
|
} catch (e) {
|
|
3474
3474
|
w(e?.message || "Failed to save line items");
|
|
3475
3475
|
} finally {
|
|
3476
|
-
|
|
3476
|
+
_(!1);
|
|
3477
3477
|
}
|
|
3478
3478
|
}
|
|
3479
3479
|
}, [
|
|
@@ -3493,41 +3493,41 @@ var Xt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3493
3493
|
allow_add: !e.readonly,
|
|
3494
3494
|
allow_delete: !e.readonly
|
|
3495
3495
|
}), [e]);
|
|
3496
|
-
return /* @__PURE__ */
|
|
3497
|
-
className:
|
|
3498
|
-
children: [/* @__PURE__ */
|
|
3496
|
+
return /* @__PURE__ */ $(P, {
|
|
3497
|
+
className: J("shadow-none"),
|
|
3498
|
+
children: [/* @__PURE__ */ $(L, {
|
|
3499
3499
|
className: "flex-row items-center justify-between gap-2 pb-2",
|
|
3500
|
-
children: [/* @__PURE__ */
|
|
3500
|
+
children: [/* @__PURE__ */ Q(R, {
|
|
3501
3501
|
className: "text-sm font-medium",
|
|
3502
3502
|
children: e.title || "Line Items"
|
|
3503
|
-
}), !e.readonly && /* @__PURE__ */
|
|
3503
|
+
}), !e.readonly && /* @__PURE__ */ Q(N, {
|
|
3504
3504
|
type: "button",
|
|
3505
3505
|
size: "sm",
|
|
3506
3506
|
onClick: k,
|
|
3507
|
-
disabled: g ||
|
|
3507
|
+
disabled: g || p || !y || !s,
|
|
3508
3508
|
children: g ? "Saving…" : "Save"
|
|
3509
3509
|
})]
|
|
3510
|
-
}), /* @__PURE__ */
|
|
3510
|
+
}), /* @__PURE__ */ $(F, { children: [C && /* @__PURE__ */ Q("p", {
|
|
3511
3511
|
className: "mb-2 text-sm text-destructive",
|
|
3512
3512
|
children: C
|
|
3513
|
-
}),
|
|
3513
|
+
}), p ? /* @__PURE__ */ Q("p", {
|
|
3514
3514
|
className: "py-6 text-center text-sm text-muted-foreground",
|
|
3515
3515
|
children: "Loading…"
|
|
3516
|
-
}) : s ? /* @__PURE__ */
|
|
3516
|
+
}) : s ? /* @__PURE__ */ Q(x, {
|
|
3517
3517
|
value: l,
|
|
3518
3518
|
onChange: O,
|
|
3519
3519
|
field: A,
|
|
3520
3520
|
readonly: e.readonly
|
|
3521
|
-
}) : /* @__PURE__ */
|
|
3521
|
+
}) : /* @__PURE__ */ Q("p", {
|
|
3522
3522
|
className: "py-6 text-center text-sm text-muted-foreground",
|
|
3523
3523
|
children: "Save the record first to add line items."
|
|
3524
3524
|
})] })]
|
|
3525
3525
|
});
|
|
3526
|
-
},
|
|
3526
|
+
}, $t = ({ schema: e }) => /* @__PURE__ */ Q(Ht, {
|
|
3527
3527
|
schema: e,
|
|
3528
|
-
dataSource: r(
|
|
3528
|
+
dataSource: r(g)?.dataSource ?? void 0
|
|
3529
3529
|
});
|
|
3530
|
-
l.register("object-form",
|
|
3530
|
+
l.register("object-form", $t, {
|
|
3531
3531
|
namespace: "plugin-form",
|
|
3532
3532
|
label: "Object Form",
|
|
3533
3533
|
category: "plugin",
|
|
@@ -3668,7 +3668,7 @@ l.register("object-form", Qt, {
|
|
|
3668
3668
|
]
|
|
3669
3669
|
}
|
|
3670
3670
|
]
|
|
3671
|
-
}), l.register("form",
|
|
3671
|
+
}), l.register("form", $t, {
|
|
3672
3672
|
namespace: "view",
|
|
3673
3673
|
skipFallback: !0,
|
|
3674
3674
|
label: "Data Form View",
|
|
@@ -3696,7 +3696,10 @@ l.register("object-form", Qt, {
|
|
|
3696
3696
|
]
|
|
3697
3697
|
}
|
|
3698
3698
|
]
|
|
3699
|
-
}), l.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */
|
|
3699
|
+
}), l.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */ Q(Yt, {
|
|
3700
|
+
config: e,
|
|
3701
|
+
dataSource: r(g)?.dataSource
|
|
3702
|
+
}), {
|
|
3700
3703
|
namespace: "plugin-form",
|
|
3701
3704
|
label: "Embeddable Form",
|
|
3702
3705
|
category: "plugin",
|
|
@@ -3734,7 +3737,7 @@ l.register("object-form", Qt, {
|
|
|
3734
3737
|
label: "Allow Multiple Submissions"
|
|
3735
3738
|
}
|
|
3736
3739
|
]
|
|
3737
|
-
}), l.register("form-analytics", ({ schema: e }) => /* @__PURE__ */
|
|
3740
|
+
}), l.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ Q(Zt, {
|
|
3738
3741
|
formId: e.formId,
|
|
3739
3742
|
formTitle: e.formTitle,
|
|
3740
3743
|
metrics: e.metrics || { totalSubmissions: 0 }
|
|
@@ -3760,9 +3763,9 @@ l.register("object-form", Qt, {
|
|
|
3760
3763
|
label: "Submission Metrics"
|
|
3761
3764
|
}
|
|
3762
3765
|
]
|
|
3763
|
-
}), l.register("object-master-detail-form", ({ schema: e }) => /* @__PURE__ */
|
|
3766
|
+
}), l.register("object-master-detail-form", ({ schema: e }) => /* @__PURE__ */ Q(Nt, {
|
|
3764
3767
|
schema: e,
|
|
3765
|
-
dataSource: r(
|
|
3768
|
+
dataSource: r(g)?.dataSource ?? void 0
|
|
3766
3769
|
}), {
|
|
3767
3770
|
namespace: "plugin-form",
|
|
3768
3771
|
label: "Master-Detail Form",
|
|
@@ -3792,7 +3795,7 @@ l.register("object-form", Qt, {
|
|
|
3792
3795
|
required: !0
|
|
3793
3796
|
}
|
|
3794
3797
|
]
|
|
3795
|
-
}), l.register("line_items", ({ schema: e }) => /* @__PURE__ */
|
|
3798
|
+
}), l.register("line_items", ({ schema: e }) => /* @__PURE__ */ Q(Qt, { schema: e }), {
|
|
3796
3799
|
namespace: "record",
|
|
3797
3800
|
skipFallback: !0,
|
|
3798
3801
|
label: "Line Items",
|
|
@@ -3829,4 +3832,4 @@ l.register("object-form", Qt, {
|
|
|
3829
3832
|
]
|
|
3830
3833
|
});
|
|
3831
3834
|
//#endregion
|
|
3832
|
-
export {
|
|
3835
|
+
export { It as DrawerForm, Yt as EmbeddableForm, Zt as FormAnalytics, qe as FormSectionContainer, Qt as LineItemsPanel, Nt as MasterDetailForm, Bt as ModalForm, Ht as ObjectForm, Ze as SplitForm, Ke as TabbedForm, Xe as WizardForm, Me as applyAutoColSpan, Be as applyAutoLayout, Re as containerGridColsFor, xt as deriveColumns, At as deriveDetail, wt as deriveFormFields, Ie as filterAutoGeneratedFields, Fe as filterCreateModeFields, Pe as filterSystemFields, gt as findRelationshipField, ke as inferColumns, ze as inferModalSize, Oe as isAutoGeneratedFieldType, De as isWideFieldType, Dt as resolveInlineMode };
|