@object-ui/plugin-form 17.2.0 → 17.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +681 -0
- package/README.md +65 -11
- package/dist/DrawerForm.d.ts.map +1 -1
- package/dist/LineItemsPanel.d.ts +33 -0
- package/dist/LineItemsPanel.d.ts.map +1 -1
- package/dist/ModalForm.d.ts.map +1 -1
- package/dist/ObjectForm.d.ts.map +1 -1
- package/dist/SplitForm.d.ts.map +1 -1
- package/dist/TabbedForm.d.ts.map +1 -1
- package/dist/WizardForm.d.ts.map +1 -1
- package/dist/autoLayout.d.ts.map +1 -1
- package/dist/deriveMasterDetail.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +873 -757
- package/dist/index.umd.cjs +1 -1
- package/dist/schemaDefaults.d.ts +142 -0
- package/dist/schemaDefaults.d.ts.map +1 -0
- package/dist/sectionFields.d.ts +9 -0
- package/dist/sectionFields.d.ts.map +1 -1
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -1,54 +1,95 @@
|
|
|
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,
|
|
4
|
-
import { SchemaRenderer as
|
|
5
|
-
import { LineItemsField as
|
|
6
|
-
import { AlertDialog as
|
|
7
|
-
import { usePermissions as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
3
|
+
import { ComponentRegistry as l, convertSortToQueryParams as u, evalFieldPredicate as d, isMissingForRequired as f, mergeFilterNodes as p, resolveEffectiveCrudAffordances as m, resolveFieldRuleState as h, runBatchTransaction as g, toFilterNode as _ } from "@object-ui/core";
|
|
4
|
+
import { ElementDataSourceGate as v, SchemaRenderer as y, SchemaRendererContext as b, usePreviewMode as x, useRecordContext as S, useSafeFieldLabel as C, useSchemaContext as w } from "@object-ui/react";
|
|
5
|
+
import { LineItemsField as T, buildValidationRules as E, formatFileSize as D, mapFieldTypeToFormType as O } from "@object-ui/fields";
|
|
6
|
+
import { AlertDialog as k, AlertDialogAction as A, AlertDialogCancel as j, AlertDialogContent as M, AlertDialogDescription as N, AlertDialogFooter as P, AlertDialogHeader as F, AlertDialogTitle as ee, Button as I, Card as L, CardContent as R, CardDescription as z, CardHeader as B, CardTitle as V, Dialog as H, DialogDescription as U, DialogHeader as W, DialogTitle as G, MobileDialogContent as K, Sheet as te, SheetContent as ne, SheetDescription as re, SheetHeader as q, SheetTitle as J, Skeleton as ie, buttonVariants as ae, cn as Y, toast as X, useIsMobile as oe } from "@object-ui/components";
|
|
7
|
+
import { usePermissions as se } from "@object-ui/permissions";
|
|
8
|
+
import { deriveFieldGroupLayout as ce, isRuntimeDefaultToken as Z } from "@objectstack/spec/data";
|
|
9
|
+
import { AlertCircle as le, AlertTriangle as ue, Check as de, CheckCircle2 as fe, ChevronDown as pe, ChevronLeft as me, ChevronRight as he, Loader2 as ge, Lock as _e, ShieldCheck as ve } from "lucide-react";
|
|
10
|
+
import { createSafeTranslation as ye } from "@object-ui/i18n";
|
|
11
|
+
import { Fragment as be, jsx as Q, jsxs as $ } from "react/jsx-runtime";
|
|
12
12
|
//#region src/successBehavior.ts
|
|
13
|
-
function
|
|
13
|
+
function xe(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 Se(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 xe(r) ? r : null;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/schemaDefaults.ts
|
|
29
|
+
function Ce(e) {
|
|
30
|
+
return typeof e == "object" && !!e && typeof e.dialect == "string" && typeof e.source == "string";
|
|
31
|
+
}
|
|
32
|
+
function we(e) {
|
|
33
|
+
return Z(e) || Ce(e);
|
|
34
|
+
}
|
|
35
|
+
function Te(e) {
|
|
36
|
+
return e != null && !we(e);
|
|
37
|
+
}
|
|
38
|
+
function Ee(e) {
|
|
39
|
+
return e?.mode === "create" || !e?.recordId;
|
|
40
|
+
}
|
|
41
|
+
function De(e, t) {
|
|
42
|
+
return !(!e?.required || t && we(e.defaultValue));
|
|
43
|
+
}
|
|
44
|
+
function Oe(e) {
|
|
45
|
+
let t = e?.fields;
|
|
46
|
+
if (!t || typeof t != "object") return {};
|
|
47
|
+
let n = {};
|
|
48
|
+
for (let e of Object.keys(t)) {
|
|
49
|
+
let r = t[e]?.defaultValue;
|
|
50
|
+
Te(r) && (n[e] = r);
|
|
51
|
+
}
|
|
52
|
+
return n;
|
|
53
|
+
}
|
|
54
|
+
function ke(e, t) {
|
|
55
|
+
return {
|
|
56
|
+
...Oe(e),
|
|
57
|
+
...t ?? {}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function Ae(e, t) {
|
|
61
|
+
if (!e || typeof e != "object") return e;
|
|
62
|
+
let n = t?.fields;
|
|
63
|
+
if (!n || typeof n != "object") return e;
|
|
64
|
+
let r = {};
|
|
65
|
+
for (let [t, i] of Object.entries(e)) we(n[t]?.defaultValue) && f(i) || (r[t] = i);
|
|
66
|
+
return r;
|
|
26
67
|
}
|
|
27
68
|
//#endregion
|
|
28
69
|
//#region src/sectionFields.ts
|
|
29
|
-
function
|
|
70
|
+
function je(e, t) {
|
|
30
71
|
return typeof t == "string" && t.trim() || typeof t == "object" && t && typeof t.source == "string" && t.source.trim() ? {
|
|
31
72
|
...e,
|
|
32
73
|
visibleOn: t
|
|
33
74
|
} : e;
|
|
34
75
|
}
|
|
35
|
-
var
|
|
36
|
-
function
|
|
76
|
+
var Me = /* @__PURE__ */ new Set();
|
|
77
|
+
function Ne(e, t) {
|
|
37
78
|
if (typeof e.name != "string" || e.name === e.field) return;
|
|
38
79
|
let n = `${t}:${e.field}:${e.name}`;
|
|
39
|
-
|
|
80
|
+
Me.has(n) || (Me.add(n), console.warn(`[object-ui] section field { field: '${e.field}' } also carries name: '${e.name}' — mixed form-field vocabularies. The spec key wins (the runtime name becomes '${e.field}'); drop \`name\` from authored form views.`));
|
|
40
81
|
}
|
|
41
|
-
function
|
|
82
|
+
function Pe(e, t) {
|
|
42
83
|
let n = t.objectSchema?.fields?.[e];
|
|
43
84
|
return n ? {
|
|
44
85
|
name: e,
|
|
45
86
|
label: t.fieldLabel(t.objectName, e, n.label || e),
|
|
46
|
-
type:
|
|
47
|
-
required: n
|
|
87
|
+
type: O(n.type, { multiple: n.multiple }),
|
|
88
|
+
required: De(n, Ee(t)),
|
|
48
89
|
disabled: t.readOnly || t.mode === "view" || n.readonly,
|
|
49
90
|
placeholder: n.placeholder,
|
|
50
91
|
description: n.help || n.description,
|
|
51
|
-
validation:
|
|
92
|
+
validation: E(n),
|
|
52
93
|
field: n,
|
|
53
94
|
options: n.options,
|
|
54
95
|
multiple: n.multiple,
|
|
@@ -61,67 +102,72 @@ function xe(e, t) {
|
|
|
61
102
|
type: "input"
|
|
62
103
|
};
|
|
63
104
|
}
|
|
64
|
-
function
|
|
105
|
+
function Fe(e, t) {
|
|
65
106
|
if (typeof e == "string") {
|
|
66
107
|
let n = t.objectSchema?.fields?.[e];
|
|
67
|
-
return
|
|
108
|
+
return je(Pe(e, t), n?.visible_on ?? n?.visibleOn);
|
|
68
109
|
}
|
|
69
110
|
let n = e;
|
|
70
|
-
if (typeof n.field != "string") return
|
|
71
|
-
|
|
72
|
-
let r = n.field, i =
|
|
73
|
-
n.
|
|
74
|
-
|
|
75
|
-
|
|
111
|
+
if (typeof n.field != "string") return je(n, n.visibleOn);
|
|
112
|
+
Ne(n, t.objectName);
|
|
113
|
+
let r = n.field, i = Pe(r, t);
|
|
114
|
+
n.widget != null && (i.widget = n.widget), n.label != null && (i.label = n.label), n.placeholder != null && (i.placeholder = n.placeholder), n.helpText != null && (i.description = n.helpText), n.required != null && (i.required = De({
|
|
115
|
+
required: n.required,
|
|
116
|
+
defaultValue: t.objectSchema?.fields?.[r]?.defaultValue
|
|
117
|
+
}, Ee(t))), n.readonly != null && (i.disabled = n.readonly || i.disabled), n.immutable != null && (i.immutable = n.immutable), n.hidden != null && (i.hidden = n.hidden), n.colSpan != null && (i.colSpan = n.colSpan), n.span != null && (i.span = n.span), n.options != null && (i.options = n.options), n.multiple != null && (i.multiple = n.multiple);
|
|
118
|
+
let a = n.type ?? t.objectSchema?.fields?.[r]?.type;
|
|
119
|
+
a != null && (i.type = O(a, { multiple: i.multiple }));
|
|
120
|
+
let o = n.reference ?? n.reference_to;
|
|
121
|
+
return o != null && (i.reference = o, i.reference_to = o), n.maxLength != null && (i.maxLength = n.maxLength), n.minLength != null && (i.minLength = n.minLength), n.min != null && (i.min = n.min), n.max != null && (i.max = n.max), n.precision != null && (i.precision = n.precision), n.scale != null && (i.scale = n.scale), n.language != null && (i.language = n.language), Array.isArray(n.fields) && (i.fields = n.fields), n.dependsOn != null && (i.dependsOn = n.dependsOn), n.keyField != null && (i.keyField = n.keyField), n.disclosure != null && (i.disclosure = n.disclosure), je(i, n.visibleWhen ?? n.visibleOn);
|
|
76
122
|
}
|
|
77
|
-
function
|
|
78
|
-
return (e.fields ?? []).map((e) =>
|
|
123
|
+
function Ie(e, t) {
|
|
124
|
+
return (e.fields ?? []).map((e) => Fe(e, t));
|
|
79
125
|
}
|
|
80
126
|
//#endregion
|
|
81
127
|
//#region src/autoLayout.ts
|
|
82
|
-
var
|
|
128
|
+
var Le = /* @__PURE__ */ new Set([
|
|
83
129
|
"field:formula",
|
|
84
130
|
"field:summary",
|
|
85
131
|
"field:auto_number",
|
|
86
132
|
"field:autonumber"
|
|
87
|
-
]),
|
|
133
|
+
]), Re = /* @__PURE__ */ new Set([
|
|
88
134
|
"field:textarea",
|
|
89
135
|
"field:markdown",
|
|
90
136
|
"field:html",
|
|
91
137
|
"field:grid",
|
|
92
|
-
"field:
|
|
138
|
+
"field:richtext",
|
|
93
139
|
"textarea",
|
|
94
140
|
"markdown",
|
|
95
141
|
"html",
|
|
96
142
|
"grid",
|
|
97
|
-
"
|
|
98
|
-
]),
|
|
143
|
+
"richtext"
|
|
144
|
+
]), ze = /* @__PURE__ */ new Set([
|
|
99
145
|
"formula",
|
|
100
146
|
"summary",
|
|
101
147
|
"auto_number",
|
|
102
148
|
"autonumber"
|
|
103
149
|
]);
|
|
104
|
-
function
|
|
105
|
-
return
|
|
150
|
+
function Be(e) {
|
|
151
|
+
return Re.has(e);
|
|
106
152
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
153
|
+
function Ve(e) {
|
|
154
|
+
return ze.has(e);
|
|
109
155
|
}
|
|
110
|
-
function
|
|
156
|
+
function He(e) {
|
|
111
157
|
return e <= 3 ? 1 : e <= 8 ? 2 : e <= 15 ? 3 : 4;
|
|
112
158
|
}
|
|
113
|
-
function
|
|
159
|
+
function Ue(e) {
|
|
114
160
|
return e && e > 0 ? Math.min(Math.floor(e), 4) : 1;
|
|
115
161
|
}
|
|
116
|
-
function
|
|
117
|
-
let r =
|
|
118
|
-
return r <= 1 ? 1 : e.span === "full" ? r : e.colSpan == null ? e.type &&
|
|
162
|
+
function We(e, t, n) {
|
|
163
|
+
let r = Ue(t);
|
|
164
|
+
return r <= 1 ? 1 : e.span === "full" ? r : e.colSpan == null ? e.type && Be(e.type) ? r : Math.min(r, Math.max(1, Math.round(r / Math.min(Math.max(1, Math.floor(n || r)), r)))) : Math.min(Math.max(1, Math.floor(e.colSpan)), r);
|
|
119
165
|
}
|
|
120
|
-
function
|
|
121
|
-
let r =
|
|
166
|
+
function Ge(e, t, n) {
|
|
167
|
+
let r = Ue(t);
|
|
122
168
|
return r <= 1 ? e : e.map((e) => {
|
|
123
169
|
if (e.type === "section-divider") return e;
|
|
124
|
-
let t =
|
|
170
|
+
let t = We(e, r, n);
|
|
125
171
|
return t > 1 ? {
|
|
126
172
|
...e,
|
|
127
173
|
colSpan: t
|
|
@@ -131,7 +177,7 @@ function Me(e, t, n) {
|
|
|
131
177
|
} : e;
|
|
132
178
|
});
|
|
133
179
|
}
|
|
134
|
-
var
|
|
180
|
+
var Ke = /* @__PURE__ */ new Set([
|
|
135
181
|
"id",
|
|
136
182
|
"created_at",
|
|
137
183
|
"createdAt",
|
|
@@ -158,89 +204,89 @@ var Ne = /* @__PURE__ */ new Set([
|
|
|
158
204
|
"_version",
|
|
159
205
|
"_rev"
|
|
160
206
|
]);
|
|
161
|
-
function
|
|
207
|
+
function qe(e, t) {
|
|
162
208
|
return e.filter((e) => {
|
|
163
|
-
if (
|
|
209
|
+
if (Ke.has(e.name)) return !1;
|
|
164
210
|
let n = t?.fields?.[e.name];
|
|
165
|
-
return
|
|
211
|
+
return n?.hidden !== !0 && n?.readonly !== !0;
|
|
166
212
|
});
|
|
167
213
|
}
|
|
168
|
-
function
|
|
214
|
+
function Je(e, t) {
|
|
169
215
|
return e.filter((e) => {
|
|
170
|
-
if (
|
|
216
|
+
if (Ke.has(e.name) || e.type && Le.has(e.type)) return !1;
|
|
171
217
|
if (!t?.fields) return !0;
|
|
172
218
|
let n = t.fields[e.name];
|
|
173
|
-
return !n || n.readonly !== !0 && !
|
|
219
|
+
return !n || n.readonly !== !0 && !Ve(n.type);
|
|
174
220
|
});
|
|
175
221
|
}
|
|
176
|
-
function
|
|
222
|
+
function Ye(e, t) {
|
|
177
223
|
return e.filter((e) => {
|
|
178
|
-
if (e.type &&
|
|
224
|
+
if (e.type && Le.has(e.type)) return !1;
|
|
179
225
|
let n = t?.fields?.[e.name];
|
|
180
|
-
return !n || !
|
|
226
|
+
return !n || !Ve(n.type);
|
|
181
227
|
});
|
|
182
228
|
}
|
|
183
|
-
var
|
|
229
|
+
var Xe = {
|
|
184
230
|
1: void 0,
|
|
185
231
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
186
232
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
187
233
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
188
234
|
};
|
|
189
|
-
function
|
|
190
|
-
return
|
|
235
|
+
function Ze(e) {
|
|
236
|
+
return Xe[e && e > 0 ? Math.min(Math.floor(e), 4) : 1];
|
|
191
237
|
}
|
|
192
|
-
function
|
|
238
|
+
function Qe(e) {
|
|
193
239
|
return e <= 1 ? "default" : e === 2 ? "xl" : "full";
|
|
194
240
|
}
|
|
195
|
-
function
|
|
241
|
+
function $e(e, t, n, r) {
|
|
196
242
|
let i = [...e];
|
|
197
|
-
if (i =
|
|
243
|
+
if (i = qe(i, t), r === "create" && (i = Ye(i, t)), n !== void 0) return i = Ge(i, n), {
|
|
198
244
|
fields: i,
|
|
199
245
|
columns: n
|
|
200
246
|
};
|
|
201
|
-
let a =
|
|
202
|
-
return i =
|
|
247
|
+
let a = He(i.length);
|
|
248
|
+
return i = Ge(i, a), {
|
|
203
249
|
fields: i,
|
|
204
250
|
columns: a
|
|
205
251
|
};
|
|
206
252
|
}
|
|
207
253
|
//#endregion
|
|
208
254
|
//#region src/occSave.tsx
|
|
209
|
-
var
|
|
255
|
+
var et = ye({
|
|
210
256
|
"form.conflictTitle": "Save conflict",
|
|
211
257
|
"form.conflictMessage": "This record was changed by someone else while you were editing. Overwriting will replace their changes with yours.",
|
|
212
258
|
"form.conflictLatestVersion": "Their save: {{time}}",
|
|
213
259
|
"form.conflictOverwrite": "Overwrite",
|
|
214
260
|
"form.keepEditing": "Keep editing"
|
|
215
261
|
}, "form.conflictTitle");
|
|
216
|
-
function
|
|
262
|
+
function tt(e) {
|
|
217
263
|
let t = e?.updated_at;
|
|
218
264
|
return typeof t == "string" && t.length > 0 ? t : void 0;
|
|
219
265
|
}
|
|
220
|
-
function
|
|
266
|
+
function nt(e) {
|
|
221
267
|
if (!e || typeof e != "object") return !1;
|
|
222
268
|
let t = e;
|
|
223
269
|
return t.code === "CONCURRENT_UPDATE" || t.name === "ConcurrentUpdateError";
|
|
224
270
|
}
|
|
225
|
-
function
|
|
271
|
+
function rt(e) {
|
|
226
272
|
if (!e) return null;
|
|
227
273
|
let t = /\d{4}-\d{2}-\d{2}[ T]/.test(e) ? e.replace(" ", "T") : e, n = new Date(t);
|
|
228
274
|
return Number.isNaN(n.getTime()) ? null : n.toLocaleString();
|
|
229
275
|
}
|
|
230
|
-
function
|
|
231
|
-
let { t } =
|
|
276
|
+
function it() {
|
|
277
|
+
let { t } = et(), [n, r] = e.useState(null), i = e.useRef(null), a = e.useCallback((e) => {
|
|
232
278
|
i.current?.(e), i.current = null, r(null);
|
|
233
279
|
}, []);
|
|
234
280
|
e.useEffect(() => () => i.current?.(!1), []);
|
|
235
281
|
let o = e.useCallback(async ({ dataSource: e, objectName: t, recordId: n, payload: a, baseRecord: o }) => {
|
|
236
|
-
let s =
|
|
282
|
+
let s = tt(o);
|
|
237
283
|
try {
|
|
238
284
|
return {
|
|
239
285
|
status: "saved",
|
|
240
286
|
result: await e.update(t, n, a, s ? { ifMatch: s } : void 0)
|
|
241
287
|
};
|
|
242
288
|
} catch (o) {
|
|
243
|
-
if (!
|
|
289
|
+
if (!nt(o)) throw o;
|
|
244
290
|
let s = o.currentVersion;
|
|
245
291
|
if (!await new Promise((e) => {
|
|
246
292
|
i.current = e, r({ currentVersion: typeof s == "string" ? s : void 0 });
|
|
@@ -251,31 +297,31 @@ function Ge() {
|
|
|
251
297
|
result: await e.update(t, n, a, c ? { ifMatch: c } : void 0)
|
|
252
298
|
};
|
|
253
299
|
}
|
|
254
|
-
}, []), s =
|
|
300
|
+
}, []), s = rt(n?.currentVersion);
|
|
255
301
|
return {
|
|
256
302
|
saveWithOcc: o,
|
|
257
|
-
conflictDialog: /* @__PURE__ */ Q(
|
|
303
|
+
conflictDialog: /* @__PURE__ */ Q(k, {
|
|
258
304
|
open: !!n,
|
|
259
305
|
onOpenChange: (e) => {
|
|
260
306
|
e || a(!1);
|
|
261
307
|
},
|
|
262
|
-
children: /* @__PURE__ */ $(
|
|
308
|
+
children: /* @__PURE__ */ $(M, { children: [/* @__PURE__ */ $(F, { children: [/* @__PURE__ */ $(ee, {
|
|
263
309
|
className: "flex items-center gap-2",
|
|
264
|
-
children: [/* @__PURE__ */ Q(
|
|
310
|
+
children: [/* @__PURE__ */ Q(ue, {
|
|
265
311
|
className: "h-5 w-5 text-amber-500",
|
|
266
312
|
"aria-hidden": !0
|
|
267
313
|
}), t("form.conflictTitle")]
|
|
268
|
-
}), /* @__PURE__ */ $(
|
|
314
|
+
}), /* @__PURE__ */ $(N, { children: [t("form.conflictMessage"), s && /* @__PURE__ */ Q("span", {
|
|
269
315
|
className: "mt-2 block text-xs text-muted-foreground",
|
|
270
316
|
children: t("form.conflictLatestVersion", { time: s })
|
|
271
|
-
})] })] }), /* @__PURE__ */ $(
|
|
317
|
+
})] })] }), /* @__PURE__ */ $(P, { children: [/* @__PURE__ */ Q("button", {
|
|
272
318
|
type: "button",
|
|
273
|
-
className:
|
|
319
|
+
className: Y(ae({ variant: "outline" })),
|
|
274
320
|
onClick: () => a(!1),
|
|
275
321
|
children: t("form.keepEditing")
|
|
276
322
|
}), /* @__PURE__ */ Q("button", {
|
|
277
323
|
type: "button",
|
|
278
|
-
className:
|
|
324
|
+
className: Y(ae({ variant: "destructive" })),
|
|
279
325
|
onClick: () => a(!0),
|
|
280
326
|
children: t("form.conflictOverwrite")
|
|
281
327
|
})] })] })
|
|
@@ -284,40 +330,40 @@ function Ge() {
|
|
|
284
330
|
}
|
|
285
331
|
//#endregion
|
|
286
332
|
//#region src/TabbedForm.tsx
|
|
287
|
-
var
|
|
288
|
-
let { fieldLabel: a } =
|
|
333
|
+
var at = ({ schema: e, dataSource: r, className: i }) => {
|
|
334
|
+
let { fieldLabel: a } = C(), [o, l] = c(null), [u, d] = c({}), { saveWithOcc: f, conflictDialog: p } = it(), [m, h] = c(!0), [g, _] = c(null), v = e.defaultTab || e.sections[0]?.name || e.sections[0]?.label || "tab-0";
|
|
289
335
|
t.useEffect(() => {
|
|
290
336
|
(async () => {
|
|
291
337
|
if (!r) {
|
|
292
|
-
|
|
338
|
+
h(!1);
|
|
293
339
|
return;
|
|
294
340
|
}
|
|
295
341
|
try {
|
|
296
342
|
let t = await r.getObjectSchema(e.objectName);
|
|
297
343
|
l(t);
|
|
298
344
|
} catch (e) {
|
|
299
|
-
|
|
345
|
+
_(e);
|
|
300
346
|
}
|
|
301
347
|
})();
|
|
302
348
|
}, [e.objectName, r]);
|
|
303
|
-
let
|
|
349
|
+
let b = s(void 0);
|
|
304
350
|
t.useEffect(() => {
|
|
305
351
|
let t = !1;
|
|
306
352
|
return (o || !r) && (async () => {
|
|
307
353
|
if (e.mode === "create" || !e.recordId || !r) {
|
|
308
|
-
d(e.initialData || e.initialValues
|
|
354
|
+
d(ke(o, e.initialData || e.initialValues)), h(!1);
|
|
309
355
|
return;
|
|
310
356
|
}
|
|
311
|
-
|
|
357
|
+
b.current !== e.recordId && h(!0);
|
|
312
358
|
try {
|
|
313
359
|
let n = await r.findOne(e.objectName, e.recordId);
|
|
314
360
|
if (t) return;
|
|
315
|
-
|
|
361
|
+
b.current = e.recordId, d(n || {});
|
|
316
362
|
} catch (e) {
|
|
317
363
|
if (t) return;
|
|
318
|
-
|
|
364
|
+
_(e);
|
|
319
365
|
} finally {
|
|
320
|
-
t ||
|
|
366
|
+
t || h(!1);
|
|
321
367
|
}
|
|
322
368
|
})(), () => {
|
|
323
369
|
t = !0;
|
|
@@ -331,23 +377,25 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
331
377
|
r,
|
|
332
378
|
e.objectName
|
|
333
379
|
]);
|
|
334
|
-
let
|
|
380
|
+
let x = n((t) => Ie(t, {
|
|
335
381
|
objectSchema: o,
|
|
336
382
|
objectName: e.objectName,
|
|
337
383
|
readOnly: e.readOnly,
|
|
338
384
|
mode: e.mode,
|
|
385
|
+
recordId: e.recordId,
|
|
339
386
|
fieldLabel: a
|
|
340
387
|
}), [
|
|
341
388
|
o,
|
|
342
389
|
e.readOnly,
|
|
343
390
|
e.mode,
|
|
391
|
+
e.recordId,
|
|
344
392
|
e.objectName,
|
|
345
393
|
a
|
|
346
|
-
]),
|
|
394
|
+
]), S = n(async (t) => {
|
|
347
395
|
if (!r) return e.onSuccess && await e.onSuccess(t), t;
|
|
348
396
|
try {
|
|
349
397
|
let n;
|
|
350
|
-
if (e.mode === "create") n = await r.create(e.objectName, t);
|
|
398
|
+
if (e.mode === "create") n = await r.create(e.objectName, Ae(t, o));
|
|
351
399
|
else if (e.mode === "edit" && e.recordId) {
|
|
352
400
|
let i = await f({
|
|
353
401
|
dataSource: r,
|
|
@@ -371,14 +419,14 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
371
419
|
]), w = n(() => {
|
|
372
420
|
e.onCancel && e.onCancel();
|
|
373
421
|
}, [e]), T = (e, t) => e.name || e.label || `tab-${t}`;
|
|
374
|
-
if (
|
|
422
|
+
if (g) return /* @__PURE__ */ $("div", {
|
|
375
423
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
376
424
|
children: [/* @__PURE__ */ Q("h3", {
|
|
377
425
|
className: "text-red-800 font-semibold",
|
|
378
426
|
children: "Error loading form"
|
|
379
427
|
}), /* @__PURE__ */ Q("p", {
|
|
380
428
|
className: "text-red-600 text-sm mt-1",
|
|
381
|
-
children:
|
|
429
|
+
children: g.message
|
|
382
430
|
})]
|
|
383
431
|
});
|
|
384
432
|
if (m) return /* @__PURE__ */ $("div", {
|
|
@@ -388,19 +436,19 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
388
436
|
children: "Loading form..."
|
|
389
437
|
})]
|
|
390
438
|
});
|
|
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 =
|
|
392
|
-
let n =
|
|
439
|
+
let E = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, D = e.sections.map((e) => E(e.columns)).filter((e) => e != null), O = E(e.columns) ?? (D.length ? Math.max(...D) : 1), k = Ze(O), A = e.sections.map((e, t) => {
|
|
440
|
+
let n = x(e);
|
|
393
441
|
return {
|
|
394
442
|
key: T(e, t),
|
|
395
443
|
label: e.label || `Tab ${t + 1}`,
|
|
396
444
|
description: e.description,
|
|
397
445
|
containerClass: e.gridClassName,
|
|
398
|
-
fields: O > 1 ?
|
|
446
|
+
fields: O > 1 ? Ge(n, O, E(e.columns)) : n
|
|
399
447
|
};
|
|
400
448
|
}), j = A.flatMap((e) => e.fields);
|
|
401
449
|
return /* @__PURE__ */ $("div", {
|
|
402
|
-
className:
|
|
403
|
-
children: [/* @__PURE__ */ Q(
|
|
450
|
+
className: Y("w-full @container", i, e.className),
|
|
451
|
+
children: [/* @__PURE__ */ Q(y, { schema: {
|
|
404
452
|
type: "form",
|
|
405
453
|
objectName: e.objectName,
|
|
406
454
|
fields: j,
|
|
@@ -408,11 +456,12 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
408
456
|
...k ? { fieldContainerClass: k } : {},
|
|
409
457
|
layout: "vertical",
|
|
410
458
|
defaultValues: u,
|
|
459
|
+
previousValues: e.mode === "edit" && e.recordId ? u : void 0,
|
|
411
460
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
412
461
|
cancelLabel: e.cancelText,
|
|
413
462
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
414
463
|
showCancel: e.showCancel !== !1,
|
|
415
|
-
onSubmit:
|
|
464
|
+
onSubmit: S,
|
|
416
465
|
onCancel: w,
|
|
417
466
|
fieldTabs: A.map((e) => ({
|
|
418
467
|
key: e.key,
|
|
@@ -421,11 +470,11 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
421
470
|
fields: e.fields.map((e) => e.name),
|
|
422
471
|
containerClass: e.containerClass
|
|
423
472
|
})),
|
|
424
|
-
defaultFieldTab:
|
|
473
|
+
defaultFieldTab: v,
|
|
425
474
|
fieldTabsPosition: e.tabPosition || "top"
|
|
426
475
|
} }), p]
|
|
427
476
|
});
|
|
428
|
-
},
|
|
477
|
+
}, ot = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: a, className: o, gridClassName: s, showBorder: l }) => {
|
|
429
478
|
let [u, d] = c(r), f = {
|
|
430
479
|
1: "grid-cols-1",
|
|
431
480
|
2: "grid-cols-1 md:grid-cols-2",
|
|
@@ -434,13 +483,13 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
434
483
|
}, p = () => {
|
|
435
484
|
n && d(!u);
|
|
436
485
|
}, m = l ?? !!e, h = e || t ? /* @__PURE__ */ $("div", {
|
|
437
|
-
className:
|
|
486
|
+
className: Y("flex items-start gap-2", !m && "mb-4", n && "cursor-pointer select-none"),
|
|
438
487
|
onClick: p,
|
|
439
488
|
role: n ? "button" : void 0,
|
|
440
489
|
"aria-expanded": n ? !u : void 0,
|
|
441
490
|
children: [n && /* @__PURE__ */ Q("span", {
|
|
442
491
|
className: "mt-0.5 text-muted-foreground",
|
|
443
|
-
children: Q(u ?
|
|
492
|
+
children: Q(u ? he : pe, { className: "h-4 w-4" })
|
|
444
493
|
}), /* @__PURE__ */ $("div", {
|
|
445
494
|
className: "flex-1",
|
|
446
495
|
children: [e && /* @__PURE__ */ Q("h3", {
|
|
@@ -452,50 +501,50 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
452
501
|
})]
|
|
453
502
|
})]
|
|
454
503
|
}) : null, g = u ? null : /* @__PURE__ */ Q("div", {
|
|
455
|
-
className:
|
|
504
|
+
className: Y("grid gap-4", s || f[i]),
|
|
456
505
|
children: a
|
|
457
506
|
});
|
|
458
|
-
return m ? /* @__PURE__ */ $(
|
|
459
|
-
className:
|
|
460
|
-
children: [h && /* @__PURE__ */ Q(
|
|
507
|
+
return m ? /* @__PURE__ */ $(L, {
|
|
508
|
+
className: Y("form-section bg-muted/40 shadow-none", o),
|
|
509
|
+
children: [h && /* @__PURE__ */ Q(B, {
|
|
461
510
|
className: "border-b border-border pb-3",
|
|
462
511
|
children: h
|
|
463
|
-
}), g && /* @__PURE__ */ Q(
|
|
512
|
+
}), g && /* @__PURE__ */ Q(R, {
|
|
464
513
|
className: "pt-4",
|
|
465
514
|
children: g
|
|
466
515
|
})]
|
|
467
516
|
}) : /* @__PURE__ */ $("div", {
|
|
468
|
-
className:
|
|
517
|
+
className: Y("form-section", o),
|
|
469
518
|
children: [h, g]
|
|
470
519
|
});
|
|
471
|
-
},
|
|
472
|
-
let { fieldLabel: a } =
|
|
520
|
+
}, st = ye({ "wizard.missingRequired": "Please complete the required fields: {{fields}}" }, "wizard.missingRequired"), ct = f, lt = ({ schema: e, dataSource: r, className: i }) => {
|
|
521
|
+
let { fieldLabel: a } = C(), { t: s } = st(), [l, u] = c(null), [f, p] = c({}), [m, g] = c(void 0), { saveWithOcc: _, conflictDialog: v } = it(), [b, x] = c(!0), [S, w] = c(null), [T, E] = c(0), [D, O] = c(/* @__PURE__ */ new Set()), [k, A] = c(!1), [j, M] = c(/* @__PURE__ */ new Set()), [N, P] = c(null), F = t.useId(), [ee, L] = c(0), R = t.useRef(!1), z = e.sections.length, B = T === 0, V = T === z - 1;
|
|
473
522
|
t.useEffect(() => {
|
|
474
523
|
(async () => {
|
|
475
524
|
if (!r) {
|
|
476
|
-
|
|
525
|
+
x(!1);
|
|
477
526
|
return;
|
|
478
527
|
}
|
|
479
528
|
try {
|
|
480
529
|
let t = await r.getObjectSchema(e.objectName);
|
|
481
|
-
|
|
530
|
+
u(t);
|
|
482
531
|
} catch (e) {
|
|
483
|
-
|
|
532
|
+
w(e);
|
|
484
533
|
}
|
|
485
534
|
})();
|
|
486
535
|
}, [e.objectName, r]), t.useEffect(() => {
|
|
487
536
|
(l || !r) && (async () => {
|
|
488
537
|
if (e.mode === "create" || !e.recordId || !r) {
|
|
489
|
-
|
|
538
|
+
R.current ||= (p(ke(l, e.initialData || e.initialValues)), !0), x(!1);
|
|
490
539
|
return;
|
|
491
540
|
}
|
|
492
541
|
try {
|
|
493
542
|
let t = await r.findOne(e.objectName, e.recordId);
|
|
494
|
-
|
|
543
|
+
p(t || {}), g(t || {});
|
|
495
544
|
} catch (e) {
|
|
496
|
-
|
|
545
|
+
w(e);
|
|
497
546
|
} finally {
|
|
498
|
-
|
|
547
|
+
x(!1);
|
|
499
548
|
}
|
|
500
549
|
})();
|
|
501
550
|
}, [
|
|
@@ -507,64 +556,66 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
507
556
|
r,
|
|
508
557
|
e.objectName
|
|
509
558
|
]);
|
|
510
|
-
let
|
|
559
|
+
let H = n((t) => Ie(t, {
|
|
511
560
|
objectSchema: l,
|
|
512
561
|
objectName: e.objectName,
|
|
513
562
|
readOnly: e.readOnly,
|
|
514
563
|
mode: e.mode,
|
|
564
|
+
recordId: e.recordId,
|
|
515
565
|
fieldLabel: a
|
|
516
566
|
}), [
|
|
517
567
|
l,
|
|
518
568
|
e.readOnly,
|
|
519
569
|
e.mode,
|
|
570
|
+
e.recordId,
|
|
520
571
|
e.objectName,
|
|
521
572
|
a
|
|
522
|
-
]),
|
|
523
|
-
|
|
524
|
-
|
|
573
|
+
]), U = o(() => T >= 0 && T < z ? H(e.sections[T]) : [], [
|
|
574
|
+
T,
|
|
575
|
+
z,
|
|
525
576
|
e.sections,
|
|
526
|
-
|
|
527
|
-
]),
|
|
577
|
+
H
|
|
578
|
+
]), W = n((t) => {
|
|
528
579
|
let n = /* @__PURE__ */ new Map();
|
|
529
580
|
return e.sections.forEach((e, r) => {
|
|
530
|
-
for (let i of
|
|
581
|
+
for (let i of H(e)) {
|
|
531
582
|
let e = i?.name;
|
|
532
583
|
if (!e || i.hidden === !0) continue;
|
|
533
|
-
let a =
|
|
584
|
+
let a = h({
|
|
534
585
|
visibleWhen: i.visibleWhen,
|
|
535
586
|
readonlyWhen: i.readonlyWhen,
|
|
536
587
|
requiredWhen: i.requiredWhen
|
|
537
588
|
}, t, {
|
|
538
589
|
required: !!i.required,
|
|
539
590
|
readonly: i.readonly === !0
|
|
540
|
-
});
|
|
541
|
-
!(i.visibleOn == null ||
|
|
591
|
+
}, void 0, void 0, `field '${e}'`);
|
|
592
|
+
!(i.visibleOn == null || d(i.visibleOn, t, !0, void 0, void 0, { context: `visibleOn of field '${e}'` })) || !a.visible || a.readonly || !a.required || ct(t[e]) && n.set(r, [...n.get(r) ?? [], i.label || e]);
|
|
542
593
|
}
|
|
543
594
|
}), n;
|
|
544
|
-
}, [e.sections,
|
|
595
|
+
}, [e.sections, H]), G = n(async (t) => {
|
|
545
596
|
let n = {
|
|
546
597
|
...f,
|
|
547
598
|
...t
|
|
548
599
|
};
|
|
549
|
-
if (
|
|
550
|
-
if (!e.has(
|
|
600
|
+
if (p(n), O((e) => new Set(e).add(T)), M((e) => {
|
|
601
|
+
if (!e.has(T)) return e;
|
|
551
602
|
let t = new Set(e);
|
|
552
|
-
return t.delete(
|
|
553
|
-
}),
|
|
554
|
-
let t =
|
|
603
|
+
return t.delete(T), t;
|
|
604
|
+
}), V) {
|
|
605
|
+
let t = W(n);
|
|
555
606
|
if (t.size > 0) {
|
|
556
|
-
|
|
607
|
+
M(new Set(t.keys()));
|
|
557
608
|
let e = [...t.values()].flat();
|
|
558
|
-
|
|
609
|
+
X.error(s("wizard.missingRequired", { fields: e.slice(0, 3).join(", ") + (e.length > 3 ? "…" : "") })), K(Math.min(...t.keys()));
|
|
559
610
|
return;
|
|
560
611
|
}
|
|
561
|
-
|
|
612
|
+
M(/* @__PURE__ */ new Set()), A(!0);
|
|
562
613
|
try {
|
|
563
614
|
if (!r) return e.onSuccess && await e.onSuccess(n), n;
|
|
564
615
|
let t;
|
|
565
|
-
if (e.mode === "create") t = await r.create(e.objectName, n);
|
|
616
|
+
if (e.mode === "create") t = await r.create(e.objectName, Ae(n, l));
|
|
566
617
|
else if (e.mode === "edit" && e.recordId) {
|
|
567
|
-
let i = await
|
|
618
|
+
let i = await _({
|
|
568
619
|
dataSource: r,
|
|
569
620
|
objectName: e.objectName,
|
|
570
621
|
recordId: e.recordId,
|
|
@@ -579,14 +630,14 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
579
630
|
let t = e.submitBehavior;
|
|
580
631
|
switch (t.kind) {
|
|
581
632
|
case "redirect":
|
|
582
|
-
|
|
633
|
+
xe(t.url) && setTimeout(() => window.location.assign(t.url), t.delayMs ?? 0);
|
|
583
634
|
break;
|
|
584
635
|
case "continue":
|
|
585
|
-
|
|
636
|
+
p(ke(l, e.initialData || e.initialValues)), O(/* @__PURE__ */ new Set()), E(0), L((e) => e + 1);
|
|
586
637
|
break;
|
|
587
638
|
default: {
|
|
588
639
|
let n = t.kind === "thank-you" && t.message ? t.message : e.successMessage || (e.mode === "create" ? "Created" : "Saved");
|
|
589
|
-
|
|
640
|
+
X.success(n), P({
|
|
590
641
|
title: t.kind === "thank-you" ? t.title : void 0,
|
|
591
642
|
message: n
|
|
592
643
|
});
|
|
@@ -594,73 +645,75 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
594
645
|
}
|
|
595
646
|
}
|
|
596
647
|
} else {
|
|
597
|
-
let n =
|
|
648
|
+
let n = Se(e.navigateOnSuccess, t);
|
|
598
649
|
if (n) return window.location.assign(n), t;
|
|
599
|
-
|
|
650
|
+
X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved")), e.resetOnSuccess && e.mode === "create" && (p(ke(l, e.initialData || e.initialValues)), O(/* @__PURE__ */ new Set()), E(0), L((e) => e + 1));
|
|
600
651
|
}
|
|
601
652
|
return t;
|
|
602
653
|
} catch (t) {
|
|
603
654
|
throw e.onError && e.onError(t), t;
|
|
604
655
|
} finally {
|
|
605
|
-
|
|
656
|
+
A(!1);
|
|
606
657
|
}
|
|
607
|
-
}
|
|
658
|
+
}
|
|
659
|
+
K(T + 1);
|
|
608
660
|
}, [
|
|
609
661
|
f,
|
|
610
|
-
|
|
611
|
-
|
|
662
|
+
T,
|
|
663
|
+
V,
|
|
612
664
|
e,
|
|
665
|
+
l,
|
|
613
666
|
r,
|
|
614
|
-
|
|
667
|
+
W,
|
|
615
668
|
s,
|
|
616
|
-
|
|
617
|
-
]),
|
|
618
|
-
t >= 0 && t <
|
|
619
|
-
}, [
|
|
620
|
-
|
|
621
|
-
}, [
|
|
669
|
+
_
|
|
670
|
+
]), K = n((t) => {
|
|
671
|
+
t >= 0 && t < z && (E(t), e.onStepChange && e.onStepChange(t));
|
|
672
|
+
}, [z, e]), te = n(() => {
|
|
673
|
+
K(T - 1);
|
|
674
|
+
}, [T, K]), ne = n(() => {
|
|
622
675
|
e.onCancel && e.onCancel();
|
|
623
|
-
}, [e]),
|
|
624
|
-
(e.allowSkip ||
|
|
676
|
+
}, [e]), re = n((t) => {
|
|
677
|
+
(e.allowSkip || D.has(t) || t <= T) && K(t);
|
|
625
678
|
}, [
|
|
626
679
|
e.allowSkip,
|
|
680
|
+
D,
|
|
627
681
|
T,
|
|
628
|
-
|
|
629
|
-
W
|
|
682
|
+
K
|
|
630
683
|
]);
|
|
631
|
-
if (
|
|
684
|
+
if (S) return /* @__PURE__ */ $("div", {
|
|
632
685
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
633
686
|
children: [/* @__PURE__ */ Q("h3", {
|
|
634
687
|
className: "text-red-800 font-semibold",
|
|
635
688
|
children: "Error loading form"
|
|
636
689
|
}), /* @__PURE__ */ Q("p", {
|
|
637
690
|
className: "text-red-600 text-sm mt-1",
|
|
638
|
-
children:
|
|
691
|
+
children: S.message
|
|
639
692
|
})]
|
|
640
693
|
});
|
|
641
|
-
if (
|
|
694
|
+
if (b) return /* @__PURE__ */ $("div", {
|
|
642
695
|
className: "p-8 text-center",
|
|
643
696
|
children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
|
|
644
697
|
className: "mt-2 text-sm text-gray-600",
|
|
645
698
|
children: "Loading form..."
|
|
646
699
|
})]
|
|
647
700
|
});
|
|
648
|
-
if (
|
|
649
|
-
className:
|
|
701
|
+
if (N) return /* @__PURE__ */ Q("div", {
|
|
702
|
+
className: Y("w-full", i, e.className),
|
|
650
703
|
children: /* @__PURE__ */ $("div", {
|
|
651
704
|
className: "rounded-md border bg-card p-8 text-center",
|
|
652
705
|
children: [/* @__PURE__ */ Q("h3", {
|
|
653
706
|
className: "text-lg font-semibold",
|
|
654
|
-
children:
|
|
655
|
-
}),
|
|
707
|
+
children: N.title ?? "Thanks!"
|
|
708
|
+
}), N.message && /* @__PURE__ */ Q("p", {
|
|
656
709
|
className: "mt-2 text-sm text-muted-foreground",
|
|
657
|
-
children:
|
|
710
|
+
children: N.message
|
|
658
711
|
})]
|
|
659
712
|
})
|
|
660
713
|
});
|
|
661
|
-
let
|
|
714
|
+
let q = e.sections[T], J = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, ie = J(e.columns) ?? J(q?.columns) ?? 1, ae = Ze(ie);
|
|
662
715
|
return /* @__PURE__ */ $("div", {
|
|
663
|
-
className:
|
|
716
|
+
className: Y("w-full @container", i, e.className),
|
|
664
717
|
children: [
|
|
665
718
|
e.showStepIndicator !== !1 && /* @__PURE__ */ Q("nav", {
|
|
666
719
|
"aria-label": "Progress",
|
|
@@ -668,30 +721,30 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
668
721
|
children: /* @__PURE__ */ Q("ol", {
|
|
669
722
|
className: "flex items-center",
|
|
670
723
|
children: e.sections.map((t, n) => {
|
|
671
|
-
let r = n ===
|
|
724
|
+
let r = n === T, i = D.has(n), a = e.allowSkip || i || n <= T, o = j.has(n);
|
|
672
725
|
return /* @__PURE__ */ $("li", {
|
|
673
|
-
className:
|
|
674
|
-
children: [n !==
|
|
726
|
+
className: Y("relative flex-1", n !== z - 1 && "pr-8 sm:pr-12"),
|
|
727
|
+
children: [n !== z - 1 && /* @__PURE__ */ Q("div", {
|
|
675
728
|
className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
|
|
676
729
|
"aria-hidden": "true",
|
|
677
|
-
children: /* @__PURE__ */ Q("div", { className:
|
|
730
|
+
children: /* @__PURE__ */ Q("div", { className: Y("h-full", i ? "bg-primary" : "bg-muted") })
|
|
678
731
|
}), /* @__PURE__ */ $("button", {
|
|
679
732
|
type: "button",
|
|
680
|
-
className:
|
|
681
|
-
onClick: () =>
|
|
733
|
+
className: Y("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
|
|
734
|
+
onClick: () => re(n),
|
|
682
735
|
disabled: !a,
|
|
683
736
|
"data-testid": `wizard-step:${t.name || n}`,
|
|
684
737
|
"data-error": o || void 0,
|
|
685
738
|
children: [/* @__PURE__ */ Q("span", {
|
|
686
|
-
className:
|
|
687
|
-
children: o ? /* @__PURE__ */ Q(
|
|
739
|
+
className: Y("flex h-6 w-6 sm:h-8 sm:w-8 items-center justify-center rounded-full text-xs sm:text-sm font-medium transition-colors", o && "border-2 border-destructive bg-background text-destructive", !o && i && "bg-primary text-primary-foreground", !o && r && !i && "border-2 border-primary bg-background text-primary", !o && !r && !i && "border-2 border-muted bg-background text-muted-foreground"),
|
|
740
|
+
children: o ? /* @__PURE__ */ Q(le, {
|
|
688
741
|
className: "h-3 w-3 sm:h-4 sm:w-4",
|
|
689
742
|
"aria-hidden": !0
|
|
690
|
-
}) : i ? /* @__PURE__ */ Q(
|
|
743
|
+
}) : i ? /* @__PURE__ */ Q(de, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : n + 1
|
|
691
744
|
}), /* @__PURE__ */ Q("span", {
|
|
692
745
|
className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block",
|
|
693
746
|
children: /* @__PURE__ */ Q("span", {
|
|
694
|
-
className:
|
|
747
|
+
className: Y(o ? "text-destructive" : r ? "text-foreground" : "text-muted-foreground"),
|
|
695
748
|
children: t.label || `Step ${n + 1}`
|
|
696
749
|
})
|
|
697
750
|
})]
|
|
@@ -702,28 +755,29 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
702
755
|
}),
|
|
703
756
|
/* @__PURE__ */ Q("div", {
|
|
704
757
|
className: "min-h-[200px]",
|
|
705
|
-
children:
|
|
706
|
-
label:
|
|
707
|
-
description:
|
|
758
|
+
children: q && /* @__PURE__ */ Q(ot, {
|
|
759
|
+
label: q.label,
|
|
760
|
+
description: q.description,
|
|
708
761
|
columns: 1,
|
|
709
|
-
className:
|
|
710
|
-
gridClassName:
|
|
711
|
-
children:
|
|
762
|
+
className: q.className,
|
|
763
|
+
gridClassName: q.gridClassName,
|
|
764
|
+
children: U.length > 0 ? /* @__PURE__ */ Q(y, { schema: {
|
|
712
765
|
type: "form",
|
|
713
766
|
objectName: e.objectName,
|
|
714
|
-
id:
|
|
715
|
-
fields:
|
|
716
|
-
columns:
|
|
717
|
-
...
|
|
767
|
+
id: F,
|
|
768
|
+
fields: ie > 1 ? Ge(U, ie, J(q.columns)) : U,
|
|
769
|
+
columns: ie,
|
|
770
|
+
...ae ? { fieldContainerClass: ae } : {},
|
|
718
771
|
layout: "vertical",
|
|
719
772
|
defaultValues: f,
|
|
773
|
+
previousValues: e.mode === "edit" ? m : void 0,
|
|
720
774
|
showSubmit: !1,
|
|
721
775
|
showCancel: !1,
|
|
722
|
-
onSubmit:
|
|
723
|
-
} },
|
|
724
|
-
id:
|
|
776
|
+
onSubmit: G
|
|
777
|
+
} }, ee) : /* @__PURE__ */ Q("form", {
|
|
778
|
+
id: F,
|
|
725
779
|
onSubmit: (e) => {
|
|
726
|
-
e.preventDefault(),
|
|
780
|
+
e.preventDefault(), G({});
|
|
727
781
|
},
|
|
728
782
|
children: /* @__PURE__ */ Q("div", {
|
|
729
783
|
className: "text-center py-8 text-muted-foreground",
|
|
@@ -734,9 +788,9 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
734
788
|
}),
|
|
735
789
|
/* @__PURE__ */ $("div", {
|
|
736
790
|
className: "flex items-center justify-between mt-6 pt-4 border-t",
|
|
737
|
-
children: [/* @__PURE__ */ Q("div", { children: e.showCancel !== !1 && /* @__PURE__ */ Q(
|
|
791
|
+
children: [/* @__PURE__ */ Q("div", { children: e.showCancel !== !1 && /* @__PURE__ */ Q(I, {
|
|
738
792
|
variant: "ghost",
|
|
739
|
-
onClick:
|
|
793
|
+
onClick: ne,
|
|
740
794
|
children: e.cancelText || "Cancel"
|
|
741
795
|
}) }), /* @__PURE__ */ $("div", {
|
|
742
796
|
className: "flex items-center gap-2",
|
|
@@ -745,73 +799,73 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
745
799
|
className: "text-sm text-muted-foreground mr-2",
|
|
746
800
|
children: [
|
|
747
801
|
"Step ",
|
|
748
|
-
|
|
802
|
+
T + 1,
|
|
749
803
|
" of ",
|
|
750
|
-
|
|
804
|
+
z
|
|
751
805
|
]
|
|
752
806
|
}),
|
|
753
|
-
!
|
|
807
|
+
!B && /* @__PURE__ */ $(I, {
|
|
754
808
|
variant: "outline",
|
|
755
|
-
onClick:
|
|
756
|
-
children: [/* @__PURE__ */ Q(
|
|
809
|
+
onClick: te,
|
|
810
|
+
children: [/* @__PURE__ */ Q(me, { className: "h-4 w-4 mr-1" }), e.prevText || "Back"]
|
|
757
811
|
}),
|
|
758
|
-
|
|
812
|
+
V ? /* @__PURE__ */ $(I, {
|
|
759
813
|
type: "submit",
|
|
760
|
-
form:
|
|
761
|
-
disabled:
|
|
762
|
-
children: [
|
|
814
|
+
form: F,
|
|
815
|
+
disabled: k || e.mode === "view",
|
|
816
|
+
children: [k && /* @__PURE__ */ Q(ge, {
|
|
763
817
|
className: "mr-2 h-4 w-4 animate-spin",
|
|
764
818
|
"aria-hidden": !0
|
|
765
|
-
}),
|
|
766
|
-
}) : /* @__PURE__ */ $(
|
|
819
|
+
}), k ? "Submitting..." : e.submitText || (e.mode === "create" ? "Create" : "Update")]
|
|
820
|
+
}) : /* @__PURE__ */ $(I, {
|
|
767
821
|
type: "submit",
|
|
768
|
-
form:
|
|
769
|
-
children: [e.nextText || "Next", /* @__PURE__ */ Q(
|
|
822
|
+
form: F,
|
|
823
|
+
children: [e.nextText || "Next", /* @__PURE__ */ Q(he, { className: "h-4 w-4 ml-1" })]
|
|
770
824
|
})
|
|
771
825
|
]
|
|
772
826
|
})]
|
|
773
827
|
}),
|
|
774
|
-
|
|
828
|
+
v
|
|
775
829
|
]
|
|
776
830
|
});
|
|
777
|
-
},
|
|
778
|
-
let { fieldLabel: a } =
|
|
831
|
+
}, ut = ({ schema: e, dataSource: t, className: r }) => {
|
|
832
|
+
let { fieldLabel: a } = C(), [l, u] = c(null), [d, f] = c({}), { saveWithOcc: p, conflictDialog: m } = it(), [h, g] = c(!0), [_, v] = c(null);
|
|
779
833
|
i(() => {
|
|
780
834
|
(async () => {
|
|
781
835
|
if (!t) {
|
|
782
|
-
|
|
836
|
+
g(!1);
|
|
783
837
|
return;
|
|
784
838
|
}
|
|
785
839
|
try {
|
|
786
840
|
let n = await t.getObjectSchema(e.objectName);
|
|
787
841
|
u(n);
|
|
788
842
|
} catch (e) {
|
|
789
|
-
|
|
843
|
+
v(e), g(!1);
|
|
790
844
|
}
|
|
791
845
|
})();
|
|
792
846
|
}, [e.objectName, t]);
|
|
793
|
-
let
|
|
847
|
+
let b = s(void 0);
|
|
794
848
|
i(() => {
|
|
795
849
|
let n = !1;
|
|
796
850
|
return (l || !t) && (async () => {
|
|
797
851
|
if (e.mode === "create" || !e.recordId) {
|
|
798
|
-
f(e.initialData || e.initialValues
|
|
852
|
+
f(ke(l, e.initialData || e.initialValues)), g(!1);
|
|
799
853
|
return;
|
|
800
854
|
}
|
|
801
855
|
if (!t) {
|
|
802
|
-
f(e.initialData || e.initialValues || {}),
|
|
856
|
+
f(e.initialData || e.initialValues || {}), g(!1);
|
|
803
857
|
return;
|
|
804
858
|
}
|
|
805
|
-
|
|
859
|
+
b.current !== e.recordId && g(!0);
|
|
806
860
|
try {
|
|
807
861
|
let r = await t.findOne(e.objectName, e.recordId);
|
|
808
862
|
if (n) return;
|
|
809
|
-
|
|
863
|
+
b.current = e.recordId, f(r || {});
|
|
810
864
|
} catch (e) {
|
|
811
865
|
if (n) return;
|
|
812
|
-
|
|
866
|
+
v(e);
|
|
813
867
|
} finally {
|
|
814
|
-
n ||
|
|
868
|
+
n || g(!1);
|
|
815
869
|
}
|
|
816
870
|
})(), () => {
|
|
817
871
|
n = !0;
|
|
@@ -825,23 +879,25 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
825
879
|
t,
|
|
826
880
|
e.objectName
|
|
827
881
|
]);
|
|
828
|
-
let
|
|
882
|
+
let x = n((t) => Ie(t, {
|
|
829
883
|
objectSchema: l,
|
|
830
884
|
objectName: e.objectName,
|
|
831
885
|
readOnly: e.readOnly,
|
|
832
886
|
mode: e.mode,
|
|
887
|
+
recordId: e.recordId,
|
|
833
888
|
fieldLabel: a
|
|
834
889
|
}), [
|
|
835
890
|
l,
|
|
836
891
|
e.readOnly,
|
|
837
892
|
e.mode,
|
|
893
|
+
e.recordId,
|
|
838
894
|
e.objectName,
|
|
839
895
|
a
|
|
840
|
-
]),
|
|
896
|
+
]), S = n(async (n) => {
|
|
841
897
|
if (!t) return e.onSuccess && await e.onSuccess(n), n;
|
|
842
898
|
try {
|
|
843
899
|
let r;
|
|
844
|
-
if (e.mode === "create") r = await t.create(e.objectName, n);
|
|
900
|
+
if (e.mode === "create") r = await t.create(e.objectName, Ae(n, l));
|
|
845
901
|
else if (e.mode === "edit" && e.recordId) {
|
|
846
902
|
let i = await p({
|
|
847
903
|
dataSource: t,
|
|
@@ -865,27 +921,27 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
865
921
|
]), w = n(() => {
|
|
866
922
|
e.onCancel && e.onCancel();
|
|
867
923
|
}, [e]), T = (e, t) => e.pane === "primary" || e.pane === "secondary" ? e.pane : t === 0 ? "primary" : "secondary", E = o(() => e.sections.filter((e, t) => T(e, t) === "primary"), [e.sections]), D = o(() => e.sections.filter((e, t) => T(e, t) === "secondary"), [e.sections]), O = e.splitDirection || "horizontal", k = e.splitSize || 50;
|
|
868
|
-
if (
|
|
924
|
+
if (_) return /* @__PURE__ */ $("div", {
|
|
869
925
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
870
926
|
children: [/* @__PURE__ */ Q("h3", {
|
|
871
927
|
className: "text-red-800 font-semibold",
|
|
872
928
|
children: "Error loading form"
|
|
873
929
|
}), /* @__PURE__ */ Q("p", {
|
|
874
930
|
className: "text-red-600 text-sm mt-1",
|
|
875
|
-
children:
|
|
931
|
+
children: _.message
|
|
876
932
|
})]
|
|
877
933
|
});
|
|
878
|
-
if (
|
|
934
|
+
if (h) return /* @__PURE__ */ $("div", {
|
|
879
935
|
className: "p-8 text-center",
|
|
880
936
|
children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
|
|
881
937
|
className: "mt-2 text-sm text-gray-600",
|
|
882
938
|
children: "Loading form..."
|
|
883
939
|
})]
|
|
884
940
|
});
|
|
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 =
|
|
941
|
+
let A = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, j = e.sections.map((e) => A(e.columns)).filter((e) => e != null), M = A(e.columns) ?? (j.length ? Math.max(...j) : 1), N = Ze(M), P = (e, t) => {
|
|
886
942
|
let n = [];
|
|
887
943
|
return e.forEach((e, r) => {
|
|
888
|
-
let i =
|
|
944
|
+
let i = x(e);
|
|
889
945
|
i.length && ((e.label || e.description) && n.push({
|
|
890
946
|
name: `__section_${e.name || `${t}_${r}`}`,
|
|
891
947
|
label: e.label,
|
|
@@ -893,7 +949,7 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
893
949
|
type: "section-divider",
|
|
894
950
|
colSpan: 4,
|
|
895
951
|
className: e.className
|
|
896
|
-
}), n.push(...M > 1 ?
|
|
952
|
+
}), n.push(...M > 1 ? Ge(i, M, A(e.columns)) : i));
|
|
897
953
|
}), n;
|
|
898
954
|
}, F = [{
|
|
899
955
|
key: "primary",
|
|
@@ -909,8 +965,8 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
909
965
|
containerClass: e.sections.length === 1 ? e.sections[0].gridClassName : void 0
|
|
910
966
|
})).filter((e) => e.fields.length > 0);
|
|
911
967
|
return /* @__PURE__ */ $("div", {
|
|
912
|
-
className:
|
|
913
|
-
children: [/* @__PURE__ */ Q(
|
|
968
|
+
className: Y("w-full @container", r, e.className),
|
|
969
|
+
children: [/* @__PURE__ */ Q(y, { schema: {
|
|
914
970
|
type: "form",
|
|
915
971
|
objectName: e.objectName,
|
|
916
972
|
fields: F.flatMap((e) => e.fields),
|
|
@@ -918,11 +974,12 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
918
974
|
...N ? { fieldContainerClass: N } : {},
|
|
919
975
|
layout: "vertical",
|
|
920
976
|
defaultValues: d,
|
|
977
|
+
previousValues: e.mode === "edit" && e.recordId ? d : void 0,
|
|
921
978
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
922
979
|
cancelLabel: e.cancelText,
|
|
923
980
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
924
981
|
showCancel: e.showCancel !== !1,
|
|
925
|
-
onSubmit:
|
|
982
|
+
onSubmit: S,
|
|
926
983
|
onCancel: w,
|
|
927
984
|
fieldPanes: F.map((e) => ({
|
|
928
985
|
key: e.key,
|
|
@@ -934,7 +991,7 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
934
991
|
fieldPanesResizable: e.splitResizable !== !1
|
|
935
992
|
} }), m]
|
|
936
993
|
});
|
|
937
|
-
},
|
|
994
|
+
}, dt = /* @__PURE__ */ new Set([
|
|
938
995
|
"id",
|
|
939
996
|
"_id",
|
|
940
997
|
"created_at",
|
|
@@ -943,7 +1000,7 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
943
1000
|
"updatedAt",
|
|
944
1001
|
"organization_id",
|
|
945
1002
|
"organizationId"
|
|
946
|
-
]),
|
|
1003
|
+
]), ft = /* @__PURE__ */ new Set([
|
|
947
1004
|
"formula",
|
|
948
1005
|
"summary",
|
|
949
1006
|
"rollup",
|
|
@@ -952,15 +1009,15 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
952
1009
|
"autonumber",
|
|
953
1010
|
"computed"
|
|
954
1011
|
]);
|
|
955
|
-
function
|
|
1012
|
+
function pt(e, t) {
|
|
956
1013
|
if (!e || typeof e != "object") return e;
|
|
957
1014
|
let n = {}, r = t?.fields;
|
|
958
|
-
for (let [t, i] of Object.entries(e)) if (!
|
|
1015
|
+
for (let [t, i] of Object.entries(e)) if (!dt.has(t)) {
|
|
959
1016
|
if (r) {
|
|
960
1017
|
let e = r[t];
|
|
961
1018
|
if (!e) continue;
|
|
962
1019
|
let n = String(e.type || "").toLowerCase();
|
|
963
|
-
if (
|
|
1020
|
+
if (ft.has(n) || e.computed === !0 || e.formula || e.readOnly === !0 || e.readonly === !0) continue;
|
|
964
1021
|
}
|
|
965
1022
|
n[t] = i;
|
|
966
1023
|
}
|
|
@@ -968,31 +1025,31 @@ function et(e, t) {
|
|
|
968
1025
|
}
|
|
969
1026
|
//#endregion
|
|
970
1027
|
//#region src/masterDetailTx.ts
|
|
971
|
-
var
|
|
1028
|
+
var mt = (e) => e == null ? void 0 : e.id ?? e._id ?? e.recordId, ht = (e, t) => t ? pt(e, t) : e, gt = /* @__PURE__ */ new Set([
|
|
972
1029
|
"id",
|
|
973
1030
|
"_id",
|
|
974
1031
|
"recordId"
|
|
975
1032
|
]);
|
|
976
|
-
function
|
|
977
|
-
return !e || Object.entries(e).every(([e, n]) => e === t ||
|
|
1033
|
+
function _t(e, t) {
|
|
1034
|
+
return !e || Object.entries(e).every(([e, n]) => e === t || gt.has(e) ? !0 : n == null || n === "");
|
|
978
1035
|
}
|
|
979
|
-
function
|
|
1036
|
+
function vt(e, t, n) {
|
|
980
1037
|
let r = [{
|
|
981
1038
|
object: e,
|
|
982
1039
|
action: "create",
|
|
983
1040
|
data: t
|
|
984
1041
|
}];
|
|
985
|
-
for (let e of n) for (let t of e.rows)
|
|
1042
|
+
for (let e of n) for (let t of e.rows) _t(t, e.relationshipField) || r.push({
|
|
986
1043
|
object: e.childObject,
|
|
987
1044
|
action: "create",
|
|
988
1045
|
data: {
|
|
989
|
-
...
|
|
1046
|
+
...ht(t, e.childSchema),
|
|
990
1047
|
[e.relationshipField]: { $ref: 0 }
|
|
991
1048
|
}
|
|
992
1049
|
});
|
|
993
1050
|
return r;
|
|
994
1051
|
}
|
|
995
|
-
function
|
|
1052
|
+
function yt(e, t, n, r) {
|
|
996
1053
|
let i = [{
|
|
997
1054
|
object: e,
|
|
998
1055
|
action: "update",
|
|
@@ -1003,21 +1060,21 @@ function ot(e, t, n, r) {
|
|
|
1003
1060
|
let n = (e.rows || []).map((n) => ({
|
|
1004
1061
|
...n,
|
|
1005
1062
|
[e.relationshipField]: t
|
|
1006
|
-
})), { toCreate: r, toUpdate: a, toDelete: o } =
|
|
1063
|
+
})), { toCreate: r, toUpdate: a, toDelete: o } = bt(e.original || [], n);
|
|
1007
1064
|
for (let t of r) {
|
|
1008
|
-
if (
|
|
1065
|
+
if (_t(t, e.relationshipField)) continue;
|
|
1009
1066
|
let { id: n, _id: r, recordId: a, ...o } = t;
|
|
1010
1067
|
i.push({
|
|
1011
1068
|
object: e.childObject,
|
|
1012
1069
|
action: "create",
|
|
1013
|
-
data:
|
|
1070
|
+
data: ht(o, e.childSchema)
|
|
1014
1071
|
});
|
|
1015
1072
|
}
|
|
1016
1073
|
for (let t of a) i.push({
|
|
1017
1074
|
object: e.childObject,
|
|
1018
1075
|
action: "update",
|
|
1019
|
-
id:
|
|
1020
|
-
data:
|
|
1076
|
+
id: mt(t),
|
|
1077
|
+
data: ht(t, e.childSchema)
|
|
1021
1078
|
});
|
|
1022
1079
|
for (let t of o) i.push({
|
|
1023
1080
|
object: e.childObject,
|
|
@@ -1027,15 +1084,15 @@ function ot(e, t, n, r) {
|
|
|
1027
1084
|
}
|
|
1028
1085
|
return i;
|
|
1029
1086
|
}
|
|
1030
|
-
function
|
|
1031
|
-
let n = new Set(t.map(
|
|
1087
|
+
function bt(e, t) {
|
|
1088
|
+
let n = new Set(t.map(mt).filter(Boolean));
|
|
1032
1089
|
return {
|
|
1033
|
-
toCreate: t.filter((e) => !
|
|
1034
|
-
toUpdate: t.filter((e) =>
|
|
1035
|
-
toDelete: (e || []).map(
|
|
1090
|
+
toCreate: t.filter((e) => !mt(e)),
|
|
1091
|
+
toUpdate: t.filter((e) => mt(e)),
|
|
1092
|
+
toDelete: (e || []).map(mt).filter((e) => !!e && !n.has(e))
|
|
1036
1093
|
};
|
|
1037
1094
|
}
|
|
1038
|
-
function
|
|
1095
|
+
function xt(e, t) {
|
|
1039
1096
|
return Array.isArray(e) ? e.reduce((e, n) => {
|
|
1040
1097
|
let r = Number(n?.[t]);
|
|
1041
1098
|
return e + (Number.isFinite(r) ? r : 0);
|
|
@@ -1043,7 +1100,7 @@ function ct(e, t) {
|
|
|
1043
1100
|
}
|
|
1044
1101
|
//#endregion
|
|
1045
1102
|
//#region src/deriveMasterDetail.ts
|
|
1046
|
-
var
|
|
1103
|
+
var St = /* @__PURE__ */ new Set([
|
|
1047
1104
|
"id",
|
|
1048
1105
|
"_id",
|
|
1049
1106
|
"recordId",
|
|
@@ -1059,14 +1116,14 @@ var lt = /* @__PURE__ */ new Set([
|
|
|
1059
1116
|
"tenant_id",
|
|
1060
1117
|
"space",
|
|
1061
1118
|
"owner"
|
|
1062
|
-
]),
|
|
1119
|
+
]), Ct = /* @__PURE__ */ new Set([
|
|
1063
1120
|
"position",
|
|
1064
1121
|
"sort_order",
|
|
1065
1122
|
"sequence",
|
|
1066
1123
|
"line_no",
|
|
1067
1124
|
"line_number",
|
|
1068
1125
|
"sort"
|
|
1069
|
-
]),
|
|
1126
|
+
]), wt = /* @__PURE__ */ new Set([
|
|
1070
1127
|
"formula",
|
|
1071
1128
|
"summary",
|
|
1072
1129
|
"rollup",
|
|
@@ -1082,16 +1139,16 @@ var lt = /* @__PURE__ */ new Set([
|
|
|
1082
1139
|
"markdown",
|
|
1083
1140
|
"richtext"
|
|
1084
1141
|
]);
|
|
1085
|
-
function
|
|
1142
|
+
function Tt(e) {
|
|
1086
1143
|
switch (e) {
|
|
1087
1144
|
case "number":
|
|
1088
1145
|
case "percent":
|
|
1089
1146
|
case "rating":
|
|
1090
1147
|
case "slider": return "number";
|
|
1091
1148
|
case "currency": return "currency";
|
|
1092
|
-
case "date":
|
|
1093
|
-
case "datetime":
|
|
1094
|
-
case "time": return "
|
|
1149
|
+
case "date": return "date";
|
|
1150
|
+
case "datetime": return "datetime";
|
|
1151
|
+
case "time": return "time";
|
|
1095
1152
|
case "select":
|
|
1096
1153
|
case "picklist":
|
|
1097
1154
|
case "radio":
|
|
@@ -1105,11 +1162,11 @@ function ft(e) {
|
|
|
1105
1162
|
default: return "text";
|
|
1106
1163
|
}
|
|
1107
1164
|
}
|
|
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 :
|
|
1165
|
+
var Et = /* @__PURE__ */ new Set(["image", "avatar"]);
|
|
1166
|
+
function Dt(e, t) {
|
|
1167
|
+
e.multiple == null && t?.multiple && (e.multiple = !0), e.accept ?? (Array.isArray(t?.accept) && t.accept.length > 0 ? e.accept = t.accept : Et.has(t?.type) && (e.accept = ["image/*"]));
|
|
1111
1168
|
}
|
|
1112
|
-
function
|
|
1169
|
+
function Ot(e) {
|
|
1113
1170
|
if (e?.type === "boolean" || e?.type === "toggle") return [{
|
|
1114
1171
|
label: "Yes",
|
|
1115
1172
|
value: "true"
|
|
@@ -1126,7 +1183,7 @@ function ht(e) {
|
|
|
1126
1183
|
value: String(e)
|
|
1127
1184
|
});
|
|
1128
1185
|
}
|
|
1129
|
-
function
|
|
1186
|
+
function kt(e, t) {
|
|
1130
1187
|
let n = e?.fields;
|
|
1131
1188
|
if (!n || typeof n != "object") return;
|
|
1132
1189
|
let r;
|
|
@@ -1139,7 +1196,7 @@ function gt(e, t) {
|
|
|
1139
1196
|
}
|
|
1140
1197
|
return r;
|
|
1141
1198
|
}
|
|
1142
|
-
var
|
|
1199
|
+
var At = [
|
|
1143
1200
|
"name",
|
|
1144
1201
|
"title",
|
|
1145
1202
|
"subject",
|
|
@@ -1147,26 +1204,28 @@ var _t = [
|
|
|
1147
1204
|
"full_name",
|
|
1148
1205
|
"display_name",
|
|
1149
1206
|
"code"
|
|
1150
|
-
],
|
|
1207
|
+
], jt = {
|
|
1151
1208
|
select: 0,
|
|
1152
1209
|
currency: 1,
|
|
1153
1210
|
number: 1,
|
|
1154
1211
|
lookup: 2,
|
|
1155
1212
|
date: 3,
|
|
1213
|
+
datetime: 3,
|
|
1214
|
+
time: 3,
|
|
1156
1215
|
text: 4
|
|
1157
1216
|
};
|
|
1158
|
-
function
|
|
1159
|
-
return (e.type ?
|
|
1217
|
+
function Mt(e) {
|
|
1218
|
+
return (e.type ? jt[e.type] : void 0) ?? 5;
|
|
1160
1219
|
}
|
|
1161
|
-
function
|
|
1220
|
+
function Nt(e, t) {
|
|
1162
1221
|
if (t <= 0 || e.length <= t) return e;
|
|
1163
|
-
let n = /* @__PURE__ */ new Set(), r = e.find((e) =>
|
|
1222
|
+
let n = /* @__PURE__ */ new Set(), r = e.find((e) => At.includes(e.field)) ?? e[0];
|
|
1164
1223
|
r && n.add(r.field);
|
|
1165
1224
|
for (let t of e) t.required && n.add(t.field);
|
|
1166
1225
|
let i = e.map((e, t) => ({
|
|
1167
1226
|
c: e,
|
|
1168
1227
|
i: t
|
|
1169
|
-
})).filter(({ c: e }) => !n.has(e.field)).sort((e, t) =>
|
|
1228
|
+
})).filter(({ c: e }) => !n.has(e.field)).sort((e, t) => Mt(e.c) - Mt(t.c) || e.i - t.i);
|
|
1170
1229
|
for (let { c: e } of i) {
|
|
1171
1230
|
if (n.size >= t) break;
|
|
1172
1231
|
n.add(e.field);
|
|
@@ -1176,60 +1235,60 @@ function bt(e, t) {
|
|
|
1176
1235
|
defaultHidden: !0
|
|
1177
1236
|
});
|
|
1178
1237
|
}
|
|
1179
|
-
function
|
|
1238
|
+
function Pt(e, t = {}) {
|
|
1180
1239
|
let n = e?.fields;
|
|
1181
1240
|
if (!n || typeof n != "object") return [];
|
|
1182
1241
|
let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
|
|
1183
1242
|
for (let [e, t] of Object.entries(n)) {
|
|
1184
1243
|
let n = t;
|
|
1185
|
-
if (
|
|
1244
|
+
if (St.has(e) || r.has(e) || Ct.has(e) || n?.system || n?.readonly || n?.hidden || wt.has(n?.type)) continue;
|
|
1186
1245
|
let a = {
|
|
1187
1246
|
field: e,
|
|
1188
1247
|
label: n?.label || e,
|
|
1189
|
-
type:
|
|
1248
|
+
type: Tt(n?.type),
|
|
1190
1249
|
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" &&
|
|
1250
|
+
}, o = Ot(n);
|
|
1251
|
+
a.type === "select" && o && (a.options = o), a.type === "lookup" && (a.reference = n?.reference, a.displayField = n?.display_field || n?.reference_field), a.type === "file" && Dt(a, n), n?.readonlyWhen && (a.readonlyWhen = n.readonlyWhen), n?.requiredWhen && (a.requiredWhen = n.requiredWhen);
|
|
1193
1252
|
let s = typeof n?.expression == "string" ? n.expression : n?.expression?.source;
|
|
1194
1253
|
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
1254
|
}
|
|
1196
|
-
return
|
|
1255
|
+
return Nt(i, t.maxColumns ?? 6);
|
|
1197
1256
|
}
|
|
1198
|
-
function
|
|
1257
|
+
function Ft(e, t) {
|
|
1199
1258
|
let n = e ?? [], r = t?.fields;
|
|
1200
1259
|
return !n.length || !r || typeof r != "object" ? n : n.map((e) => {
|
|
1201
1260
|
if (e.type) return e;
|
|
1202
1261
|
let t = r[e.field];
|
|
1203
1262
|
if (!t) return e;
|
|
1204
|
-
let n =
|
|
1263
|
+
let n = Tt(t?.type), i = {
|
|
1205
1264
|
...e,
|
|
1206
1265
|
type: n
|
|
1207
1266
|
};
|
|
1208
1267
|
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" &&
|
|
1268
|
+
let a = Ot(t);
|
|
1269
|
+
n === "select" && a && !i.options && (i.options = a), n === "lookup" && (i.reference ??= t?.reference, i.displayField ??= t?.display_field || t?.reference_field), n === "file" && Dt(i, t), i.readonlyWhen == null && t?.readonlyWhen && (i.readonlyWhen = t.readonlyWhen), i.requiredWhen == null && t?.requiredWhen && (i.requiredWhen = t.requiredWhen);
|
|
1211
1270
|
let o = typeof t?.expression == "string" ? t.expression : t?.expression?.source;
|
|
1212
1271
|
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
1272
|
});
|
|
1214
1273
|
}
|
|
1215
|
-
var
|
|
1274
|
+
var It = /* @__PURE__ */ new Set([
|
|
1216
1275
|
"formula",
|
|
1217
1276
|
"summary",
|
|
1218
1277
|
"rollup",
|
|
1219
1278
|
"autonumber",
|
|
1220
1279
|
"auto_number"
|
|
1221
1280
|
]);
|
|
1222
|
-
function
|
|
1281
|
+
function Lt(e, t = {}) {
|
|
1223
1282
|
let n = e?.fields;
|
|
1224
1283
|
if (!n || typeof n != "object") return [];
|
|
1225
1284
|
let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
|
|
1226
1285
|
for (let [e, t] of Object.entries(n)) {
|
|
1227
1286
|
let n = t;
|
|
1228
|
-
|
|
1287
|
+
St.has(e) || r.has(e) || Ct.has(e) || n?.system || n?.hidden || It.has(n?.type) || i.push(e);
|
|
1229
1288
|
}
|
|
1230
1289
|
return i;
|
|
1231
1290
|
}
|
|
1232
|
-
var
|
|
1291
|
+
var Rt = /* @__PURE__ */ new Set([
|
|
1233
1292
|
"textarea",
|
|
1234
1293
|
"richtext",
|
|
1235
1294
|
"html",
|
|
@@ -1238,17 +1297,17 @@ var Tt = /* @__PURE__ */ new Set([
|
|
|
1238
1297
|
"json",
|
|
1239
1298
|
"location",
|
|
1240
1299
|
"address"
|
|
1241
|
-
]),
|
|
1300
|
+
]), zt = /* @__PURE__ */ new Set([
|
|
1242
1301
|
"file",
|
|
1243
1302
|
"image",
|
|
1244
1303
|
"avatar"
|
|
1245
1304
|
]);
|
|
1246
|
-
function
|
|
1305
|
+
function Bt(e, t, n = {}) {
|
|
1247
1306
|
if (t === "grid" || t === "form") return t;
|
|
1248
|
-
let r = e?.fields ?? {}, i =
|
|
1249
|
-
return i.some((e) =>
|
|
1307
|
+
let r = e?.fields ?? {}, i = Lt(e, { relationshipField: n.relationshipField });
|
|
1308
|
+
return i.some((e) => Rt.has(r[e]?.type)) || i.filter((e) => zt.has(r[e]?.type)).length >= 2 || i.length > 8 ? "form" : "grid";
|
|
1250
1309
|
}
|
|
1251
|
-
var
|
|
1310
|
+
var Vt = [
|
|
1252
1311
|
"amount",
|
|
1253
1312
|
"total",
|
|
1254
1313
|
"subtotal",
|
|
@@ -1256,33 +1315,33 @@ var Ot = [
|
|
|
1256
1315
|
"line_amount",
|
|
1257
1316
|
"net_amount"
|
|
1258
1317
|
];
|
|
1259
|
-
function
|
|
1318
|
+
function Ht(e) {
|
|
1260
1319
|
let t = e.filter((e) => e.type === "number" || e.type === "currency");
|
|
1261
1320
|
if (t.length === 0) return;
|
|
1262
1321
|
let n = t.find((e) => e.computed);
|
|
1263
1322
|
if (n) return n.field;
|
|
1264
|
-
let r = t.find((e) =>
|
|
1323
|
+
let r = t.find((e) => Vt.includes(e.field));
|
|
1265
1324
|
if (r) return r.field;
|
|
1266
1325
|
let i = [...t].reverse().find((e) => e.type === "currency");
|
|
1267
1326
|
return i ? i.field : t[t.length - 1].field;
|
|
1268
1327
|
}
|
|
1269
|
-
function
|
|
1270
|
-
let i = r.relationshipField ||
|
|
1328
|
+
function Ut(e, t, n, r = {}) {
|
|
1329
|
+
let i = r.relationshipField || kt(t, n);
|
|
1271
1330
|
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 ?
|
|
1331
|
+
let a = r.columns?.length ? Ft(r.columns, t) : Pt(t, { relationshipField: i }), o = r.amountField || Ht(a);
|
|
1273
1332
|
return {
|
|
1274
1333
|
childObject: e,
|
|
1275
1334
|
relationshipField: i,
|
|
1276
1335
|
columns: a,
|
|
1277
|
-
formFields:
|
|
1278
|
-
mode:
|
|
1336
|
+
formFields: Lt(t, { relationshipField: i }),
|
|
1337
|
+
mode: Bt(t, r.inlineEdit ?? (t?.fields)?.[i]?.inlineEdit, { relationshipField: i }),
|
|
1279
1338
|
amountField: o,
|
|
1280
|
-
sortField: Object.keys(t?.fields ?? {}).find((e) =>
|
|
1339
|
+
sortField: Object.keys(t?.fields ?? {}).find((e) => Ct.has(e))
|
|
1281
1340
|
};
|
|
1282
1341
|
}
|
|
1283
1342
|
//#endregion
|
|
1284
1343
|
//#region src/MasterDetailForm.tsx
|
|
1285
|
-
function
|
|
1344
|
+
function Wt(e) {
|
|
1286
1345
|
if (!e) return {};
|
|
1287
1346
|
let t = {};
|
|
1288
1347
|
return e.querySelectorAll("[name]").forEach((e) => {
|
|
@@ -1314,13 +1373,13 @@ function jt(e) {
|
|
|
1314
1373
|
}
|
|
1315
1374
|
}), t;
|
|
1316
1375
|
}
|
|
1317
|
-
var
|
|
1376
|
+
var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, formKey: o, onRowExpand: l, onAddViaForm: u }) => {
|
|
1318
1377
|
let [d, f] = c({}), p = s("");
|
|
1319
1378
|
i(() => {
|
|
1320
1379
|
let e = r.current;
|
|
1321
1380
|
if (!e) return;
|
|
1322
1381
|
let t = () => {
|
|
1323
|
-
let t =
|
|
1382
|
+
let t = Wt(e), n;
|
|
1324
1383
|
try {
|
|
1325
1384
|
n = JSON.stringify(t);
|
|
1326
1385
|
} catch {
|
|
@@ -1344,16 +1403,16 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1344
1403
|
o,
|
|
1345
1404
|
e.length
|
|
1346
1405
|
]);
|
|
1347
|
-
let m = d[a], h = m === void 0 ? null : Number.isFinite(Number(m)) ? Number(m) : 0, g = e.reduce((e, n, r) => e +
|
|
1406
|
+
let m = d[a], h = m === void 0 ? null : Number.isFinite(Number(m)) ? Number(m) : 0, g = e.reduce((e, n, r) => e + xt(t[r]?.rows ?? [], n.amountField || "amount"), 0), _ = h !== null && e.some((e) => !!e.amountField), v = h ?? 0, y = v / 100 * g, b = g + y, x = (e) => `¥${e.toLocaleString(void 0, {
|
|
1348
1407
|
minimumFractionDigits: 2,
|
|
1349
1408
|
maximumFractionDigits: 2
|
|
1350
1409
|
})}`;
|
|
1351
|
-
return /* @__PURE__ */ $(
|
|
1410
|
+
return /* @__PURE__ */ $(be, { children: [e.map((e, r) => /* @__PURE__ */ $("section", {
|
|
1352
1411
|
className: "space-y-2",
|
|
1353
1412
|
children: [/* @__PURE__ */ Q("h3", {
|
|
1354
1413
|
className: "text-sm font-medium text-foreground",
|
|
1355
1414
|
children: e.title || "Line Items"
|
|
1356
|
-
}), e.columns?.length ? /* @__PURE__ */ Q(
|
|
1415
|
+
}), e.columns?.length ? /* @__PURE__ */ Q(T, {
|
|
1357
1416
|
value: t[r]?.rows ?? [],
|
|
1358
1417
|
onChange: (e) => n(r, e),
|
|
1359
1418
|
contextRecord: d,
|
|
@@ -1386,7 +1445,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1386
1445
|
}), /* @__PURE__ */ Q("dd", {
|
|
1387
1446
|
className: "tabular-nums",
|
|
1388
1447
|
"data-testid": "md-subtotal",
|
|
1389
|
-
children:
|
|
1448
|
+
children: x(g)
|
|
1390
1449
|
})]
|
|
1391
1450
|
}),
|
|
1392
1451
|
/* @__PURE__ */ $("div", {
|
|
@@ -1401,7 +1460,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1401
1460
|
}), /* @__PURE__ */ Q("dd", {
|
|
1402
1461
|
className: "tabular-nums",
|
|
1403
1462
|
"data-testid": "md-tax",
|
|
1404
|
-
children:
|
|
1463
|
+
children: x(y)
|
|
1405
1464
|
})]
|
|
1406
1465
|
}),
|
|
1407
1466
|
/* @__PURE__ */ $("div", {
|
|
@@ -1409,13 +1468,13 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1409
1468
|
children: [/* @__PURE__ */ Q("dt", { children: "Total" }), /* @__PURE__ */ Q("dd", {
|
|
1410
1469
|
className: "tabular-nums",
|
|
1411
1470
|
"data-testid": "md-grand-total",
|
|
1412
|
-
children:
|
|
1471
|
+
children: x(b)
|
|
1413
1472
|
})]
|
|
1414
1473
|
})
|
|
1415
1474
|
]
|
|
1416
1475
|
})
|
|
1417
1476
|
})] });
|
|
1418
|
-
},
|
|
1477
|
+
}, Kt = ({ schema: e, dataSource: t, className: r }) => {
|
|
1419
1478
|
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
1479
|
i(() => {
|
|
1421
1480
|
if (!u) {
|
|
@@ -1432,9 +1491,9 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1432
1491
|
let r = await t.getObjectSchema(n.childObject);
|
|
1433
1492
|
if (n.relationshipField && n.columns?.length) return {
|
|
1434
1493
|
...n,
|
|
1435
|
-
columns:
|
|
1494
|
+
columns: Ft(n.columns, r)
|
|
1436
1495
|
};
|
|
1437
|
-
let i =
|
|
1496
|
+
let i = Ut(n.childObject, r, e.objectName, {
|
|
1438
1497
|
relationshipField: n.relationshipField,
|
|
1439
1498
|
columns: n.columns,
|
|
1440
1499
|
amountField: n.amountField
|
|
@@ -1461,11 +1520,11 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1461
1520
|
e.objectName,
|
|
1462
1521
|
e.details
|
|
1463
1522
|
]);
|
|
1464
|
-
let [
|
|
1523
|
+
let [m, h] = c(() => a.map(() => ({
|
|
1465
1524
|
rows: [],
|
|
1466
1525
|
original: []
|
|
1467
|
-
}))), _ = s(
|
|
1468
|
-
_.current =
|
|
1526
|
+
}))), _ = s(m);
|
|
1527
|
+
_.current = m;
|
|
1469
1528
|
let v = s({});
|
|
1470
1529
|
i(() => {
|
|
1471
1530
|
let e = t;
|
|
@@ -1518,7 +1577,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1518
1577
|
};
|
|
1519
1578
|
}
|
|
1520
1579
|
}));
|
|
1521
|
-
n ||
|
|
1580
|
+
n || h(r);
|
|
1522
1581
|
})(), () => {
|
|
1523
1582
|
n = !0;
|
|
1524
1583
|
};
|
|
@@ -1529,20 +1588,20 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1529
1588
|
d
|
|
1530
1589
|
]);
|
|
1531
1590
|
let E = n((e, t) => {
|
|
1532
|
-
|
|
1591
|
+
h((n) => n.map((n, r) => r === e ? {
|
|
1533
1592
|
...n,
|
|
1534
1593
|
rows: t
|
|
1535
1594
|
} : n));
|
|
1536
|
-
}, []), D = e.taxRateField || "tax_rate", [O, k] = c(null), A = O ?
|
|
1537
|
-
|
|
1595
|
+
}, []), D = e.taxRateField || "tax_rate", [O, k] = c(null), A = O ? m[O.detailIdx]?.rows?.[O.rowIdx] : void 0, j = O ? p[O.detailIdx] : void 0, M = n((e, t, n) => {
|
|
1596
|
+
h((r) => r.map((r, i) => i === e ? {
|
|
1538
1597
|
...r,
|
|
1539
1598
|
rows: r.rows.map((e, r) => r === t ? {
|
|
1540
1599
|
...e,
|
|
1541
1600
|
...n
|
|
1542
1601
|
} : e)
|
|
1543
1602
|
} : r));
|
|
1544
|
-
}, []),
|
|
1545
|
-
|
|
1603
|
+
}, []), N = n((e) => {
|
|
1604
|
+
h((t) => {
|
|
1546
1605
|
let n = t.map((t, n) => n === e ? {
|
|
1547
1606
|
...t,
|
|
1548
1607
|
rows: [...t.rows, {}]
|
|
@@ -1553,13 +1612,13 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1553
1612
|
isNew: !0
|
|
1554
1613
|
}), n;
|
|
1555
1614
|
});
|
|
1556
|
-
}, []),
|
|
1557
|
-
k((e) => (e?.isNew &&
|
|
1615
|
+
}, []), P = n(() => {
|
|
1616
|
+
k((e) => (e?.isNew && h((t) => t.map((t, n) => n === e.detailIdx ? {
|
|
1558
1617
|
...t,
|
|
1559
1618
|
rows: t.rows.filter((t, n) => n !== e.rowIdx)
|
|
1560
1619
|
} : t)), null));
|
|
1561
|
-
}, []),
|
|
1562
|
-
T(), e.onSuccess ||
|
|
1620
|
+
}, []), F = n(async (t) => {
|
|
1621
|
+
T(), e.onSuccess || X.success(l ? e.title ? `${e.title} saved` : "Saved" : "Created"), l || (h(p.map(() => ({
|
|
1563
1622
|
rows: [],
|
|
1564
1623
|
original: []
|
|
1565
1624
|
}))), b((e) => e + 1)), await e.onSuccess?.(t);
|
|
@@ -1569,25 +1628,27 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1569
1628
|
e.title,
|
|
1570
1629
|
p.length,
|
|
1571
1630
|
T
|
|
1572
|
-
]),
|
|
1573
|
-
T(),
|
|
1574
|
-
}, [e, T]),
|
|
1631
|
+
]), ee = n((t) => {
|
|
1632
|
+
T(), X.error(t?.message || "Save failed"), e.onError?.(t);
|
|
1633
|
+
}, [e, T]), z = n(async (n) => {
|
|
1575
1634
|
if (!t) throw Error("MasterDetailForm: dataSource is required");
|
|
1576
1635
|
let r = { ...n };
|
|
1577
|
-
|
|
1578
|
-
e.totalField && (r[e.totalField] =
|
|
1579
|
-
})
|
|
1636
|
+
p.forEach((e, t) => {
|
|
1637
|
+
e.totalField && (r[e.totalField] = xt(_.current[t]?.rows ?? [], e.amountField || "amount"));
|
|
1638
|
+
});
|
|
1639
|
+
let i = l ? yt(e.objectName, String(e.recordId), r, p.filter((e) => e.relationshipField).map((e, t) => ({
|
|
1580
1640
|
childObject: e.childObject,
|
|
1581
1641
|
relationshipField: e.relationshipField,
|
|
1582
1642
|
rows: _.current[t]?.rows ?? [],
|
|
1583
1643
|
original: _.current[t]?.original ?? [],
|
|
1584
1644
|
childSchema: v.current[e.childObject]
|
|
1585
|
-
}))) :
|
|
1645
|
+
}))) : vt(e.objectName, r, p.filter((e) => e.relationshipField).map((e, t) => ({
|
|
1586
1646
|
childObject: e.childObject,
|
|
1587
1647
|
relationshipField: e.relationshipField,
|
|
1588
1648
|
rows: _.current[t]?.rows ?? [],
|
|
1589
1649
|
childSchema: v.current[e.childObject]
|
|
1590
|
-
})))
|
|
1650
|
+
})));
|
|
1651
|
+
return (await g(t, i))?.results?.[0] ?? {
|
|
1591
1652
|
...r,
|
|
1592
1653
|
id: e.recordId
|
|
1593
1654
|
};
|
|
@@ -1597,7 +1658,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1597
1658
|
e.objectName,
|
|
1598
1659
|
e.recordId,
|
|
1599
1660
|
l
|
|
1600
|
-
]),
|
|
1661
|
+
]), H = o(() => ({
|
|
1601
1662
|
type: "object-form",
|
|
1602
1663
|
objectName: e.objectName,
|
|
1603
1664
|
mode: e.mode ?? "create",
|
|
@@ -1610,14 +1671,14 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1610
1671
|
title: e.title,
|
|
1611
1672
|
showSubmit: !1,
|
|
1612
1673
|
showCancel: !1,
|
|
1613
|
-
submitHandler:
|
|
1614
|
-
onSuccess:
|
|
1615
|
-
onError:
|
|
1674
|
+
submitHandler: z,
|
|
1675
|
+
onSuccess: F,
|
|
1676
|
+
onError: ee
|
|
1616
1677
|
}), [
|
|
1617
1678
|
e,
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1679
|
+
z,
|
|
1680
|
+
F,
|
|
1681
|
+
ee
|
|
1621
1682
|
]), U = s(null), W = e.submitText ?? (l ? "Save" : "Create"), G = n(() => {
|
|
1622
1683
|
C.current || U.current?.querySelector("form") && (C.current = !0, S(!0), setTimeout(() => {
|
|
1623
1684
|
(U.current?.querySelector("form"))?.requestSubmit();
|
|
@@ -1626,18 +1687,18 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1626
1687
|
return i(() => () => {
|
|
1627
1688
|
w.current && clearTimeout(w.current);
|
|
1628
1689
|
}, []), /* @__PURE__ */ $("div", {
|
|
1629
|
-
className:
|
|
1690
|
+
className: Y("space-y-6", r, e.className),
|
|
1630
1691
|
children: [
|
|
1631
1692
|
/* @__PURE__ */ Q("div", {
|
|
1632
1693
|
ref: U,
|
|
1633
|
-
children: /* @__PURE__ */ Q(
|
|
1634
|
-
schema:
|
|
1694
|
+
children: /* @__PURE__ */ Q(tn, {
|
|
1695
|
+
schema: H,
|
|
1635
1696
|
dataSource: t
|
|
1636
1697
|
}, y)
|
|
1637
1698
|
}),
|
|
1638
|
-
/* @__PURE__ */ Q(
|
|
1699
|
+
/* @__PURE__ */ Q(Gt, {
|
|
1639
1700
|
details: p,
|
|
1640
|
-
state:
|
|
1701
|
+
state: m,
|
|
1641
1702
|
setRows: E,
|
|
1642
1703
|
formHostRef: U,
|
|
1643
1704
|
taxRateField: D,
|
|
@@ -1646,29 +1707,29 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1646
1707
|
detailIdx: e,
|
|
1647
1708
|
rowIdx: t
|
|
1648
1709
|
}),
|
|
1649
|
-
onAddViaForm:
|
|
1710
|
+
onAddViaForm: N
|
|
1650
1711
|
}),
|
|
1651
|
-
O && j && /* @__PURE__ */ $(
|
|
1712
|
+
O && j && /* @__PURE__ */ $(L, {
|
|
1652
1713
|
className: "border-primary/40 shadow-none ring-1 ring-primary/10",
|
|
1653
1714
|
"data-testid": "md-row-form",
|
|
1654
|
-
children: [/* @__PURE__ */ $(
|
|
1715
|
+
children: [/* @__PURE__ */ $(B, {
|
|
1655
1716
|
className: "pb-2 flex flex-row items-center justify-between gap-2 space-y-0",
|
|
1656
|
-
children: [/* @__PURE__ */ $(
|
|
1717
|
+
children: [/* @__PURE__ */ $(V, {
|
|
1657
1718
|
className: "text-sm font-medium",
|
|
1658
1719
|
children: [
|
|
1659
1720
|
j.title || "Line item",
|
|
1660
1721
|
" — row ",
|
|
1661
1722
|
O.rowIdx + 1
|
|
1662
1723
|
]
|
|
1663
|
-
}), /* @__PURE__ */ Q(
|
|
1724
|
+
}), /* @__PURE__ */ Q(I, {
|
|
1664
1725
|
type: "button",
|
|
1665
1726
|
variant: "ghost",
|
|
1666
1727
|
size: "sm",
|
|
1667
1728
|
className: "h-7 text-xs text-muted-foreground",
|
|
1668
|
-
onClick:
|
|
1729
|
+
onClick: P,
|
|
1669
1730
|
children: "Close"
|
|
1670
1731
|
})]
|
|
1671
|
-
}), /* @__PURE__ */ Q(
|
|
1732
|
+
}), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q(tn, {
|
|
1672
1733
|
schema: {
|
|
1673
1734
|
type: "object-form",
|
|
1674
1735
|
objectName: j.childObject,
|
|
@@ -1680,21 +1741,21 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1680
1741
|
onSuccess: (e) => {
|
|
1681
1742
|
M(O.detailIdx, O.rowIdx, e), k(null);
|
|
1682
1743
|
},
|
|
1683
|
-
onCancel:
|
|
1744
|
+
onCancel: P
|
|
1684
1745
|
},
|
|
1685
1746
|
dataSource: t
|
|
1686
1747
|
}, `row-${O.detailIdx}-${O.rowIdx}`) })]
|
|
1687
1748
|
}),
|
|
1688
1749
|
e.showSubmit !== !1 && /* @__PURE__ */ $("div", {
|
|
1689
1750
|
className: "flex items-center justify-end gap-2 border-t border-border pt-4",
|
|
1690
|
-
children: [e.onCancel && /* @__PURE__ */ Q(
|
|
1751
|
+
children: [e.onCancel && /* @__PURE__ */ Q(I, {
|
|
1691
1752
|
type: "button",
|
|
1692
1753
|
variant: "outline",
|
|
1693
1754
|
onClick: e.onCancel,
|
|
1694
1755
|
disabled: x,
|
|
1695
1756
|
"data-testid": "md-form-cancel",
|
|
1696
1757
|
children: e.cancelText ?? "Cancel"
|
|
1697
|
-
}), /* @__PURE__ */ Q(
|
|
1758
|
+
}), /* @__PURE__ */ Q(I, {
|
|
1698
1759
|
type: "button",
|
|
1699
1760
|
onClick: G,
|
|
1700
1761
|
disabled: x || u && !d,
|
|
@@ -1704,18 +1765,19 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1704
1765
|
})
|
|
1705
1766
|
]
|
|
1706
1767
|
});
|
|
1707
|
-
},
|
|
1768
|
+
}, qt = {
|
|
1708
1769
|
1: void 0,
|
|
1709
1770
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
1710
1771
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
1711
1772
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
1712
|
-
},
|
|
1773
|
+
}, Jt = ye({
|
|
1713
1774
|
"form.discardTitle": "Discard changes?",
|
|
1714
1775
|
"form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
|
|
1776
|
+
"form.dialogDescriptionFallback": "Complete the form fields, then submit or cancel.",
|
|
1715
1777
|
"form.keepEditing": "Keep editing",
|
|
1716
1778
|
"form.discard": "Discard"
|
|
1717
|
-
}, "form.discardTitle"),
|
|
1718
|
-
let { fieldLabel: l } =
|
|
1779
|
+
}, "form.discardTitle"), Yt = ({ schema: e, dataSource: t, className: r }) => {
|
|
1780
|
+
let { fieldLabel: l } = C(), { t: u } = Jt(), d = x(), [f, p] = c(null), [m, h] = c([]), [g, _] = c({}), [v, b] = c(!0), [S, w] = c(null), [T, D] = c(!1), [L, R] = c(!1), { saveWithOcc: z, conflictDialog: B } = it(), [V, H] = c(!1), U = s(!1), W = e.confirmOnDiscard !== !1, G = e.open !== !1, K = e.drawerSide || "right", ie = a(), [ae, X] = c(() => {
|
|
1719
1781
|
let t = {};
|
|
1720
1782
|
return e.sections?.forEach((e, n) => {
|
|
1721
1783
|
let r = e.name || String(n);
|
|
@@ -1725,14 +1787,14 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1725
1787
|
i(() => {
|
|
1726
1788
|
(async () => {
|
|
1727
1789
|
if (!t) {
|
|
1728
|
-
|
|
1790
|
+
b(!1);
|
|
1729
1791
|
return;
|
|
1730
1792
|
}
|
|
1731
1793
|
try {
|
|
1732
1794
|
let n = await t.getObjectSchema(e.objectName);
|
|
1733
1795
|
p(n);
|
|
1734
1796
|
} catch (e) {
|
|
1735
|
-
|
|
1797
|
+
w(e), b(!1);
|
|
1736
1798
|
}
|
|
1737
1799
|
})();
|
|
1738
1800
|
}, [e.objectName, t]);
|
|
@@ -1741,23 +1803,23 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1741
1803
|
let n = !1;
|
|
1742
1804
|
return (f || !t) && (async () => {
|
|
1743
1805
|
if (e.mode === "create" || !e.recordId) {
|
|
1744
|
-
|
|
1806
|
+
_(ke(f, e.initialData || e.initialValues)), b(!1);
|
|
1745
1807
|
return;
|
|
1746
1808
|
}
|
|
1747
1809
|
if (!t) {
|
|
1748
|
-
|
|
1810
|
+
_(e.initialData || e.initialValues || {}), b(!1);
|
|
1749
1811
|
return;
|
|
1750
1812
|
}
|
|
1751
|
-
oe.current !== e.recordId && (
|
|
1813
|
+
oe.current !== e.recordId && (b(!0), D(!1));
|
|
1752
1814
|
try {
|
|
1753
1815
|
let r = await t.findOne(e.objectName, e.recordId);
|
|
1754
1816
|
if (n) return;
|
|
1755
|
-
oe.current = e.recordId,
|
|
1817
|
+
oe.current = e.recordId, _(r || {});
|
|
1756
1818
|
} catch (e) {
|
|
1757
1819
|
if (n) return;
|
|
1758
|
-
|
|
1820
|
+
w(e);
|
|
1759
1821
|
} finally {
|
|
1760
|
-
n ||
|
|
1822
|
+
n || b(!1);
|
|
1761
1823
|
}
|
|
1762
1824
|
})(), () => {
|
|
1763
1825
|
n = !0;
|
|
@@ -1771,27 +1833,29 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1771
1833
|
t,
|
|
1772
1834
|
e.objectName
|
|
1773
1835
|
]);
|
|
1774
|
-
let se = n((t) =>
|
|
1836
|
+
let se = n((t) => Ie(t, {
|
|
1775
1837
|
objectSchema: f,
|
|
1776
1838
|
objectName: e.objectName,
|
|
1777
1839
|
readOnly: e.readOnly,
|
|
1778
1840
|
mode: e.mode,
|
|
1841
|
+
recordId: e.recordId,
|
|
1779
1842
|
fieldLabel: l
|
|
1780
1843
|
}), [
|
|
1781
1844
|
f,
|
|
1782
1845
|
e.readOnly,
|
|
1783
1846
|
e.mode,
|
|
1847
|
+
e.recordId,
|
|
1784
1848
|
e.objectName,
|
|
1785
1849
|
l
|
|
1786
1850
|
]);
|
|
1787
1851
|
i(() => {
|
|
1788
1852
|
if (!f && t) return;
|
|
1789
1853
|
if (e.customFields?.length) {
|
|
1790
|
-
|
|
1854
|
+
h(e.customFields), b(!1);
|
|
1791
1855
|
return;
|
|
1792
1856
|
}
|
|
1793
1857
|
if (e.sections?.length) {
|
|
1794
|
-
|
|
1858
|
+
b(!1);
|
|
1795
1859
|
return;
|
|
1796
1860
|
}
|
|
1797
1861
|
if (!f) return;
|
|
@@ -1803,18 +1867,18 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1803
1867
|
i && r.push({
|
|
1804
1868
|
name: n,
|
|
1805
1869
|
label: l(e.objectName, n, i.label || n),
|
|
1806
|
-
type:
|
|
1807
|
-
required: i
|
|
1870
|
+
type: O(i.type, { multiple: i.multiple }),
|
|
1871
|
+
required: De(i, Ee(e)),
|
|
1808
1872
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
1809
1873
|
placeholder: i.placeholder,
|
|
1810
1874
|
description: i.help || i.description,
|
|
1811
|
-
validation:
|
|
1875
|
+
validation: E(i),
|
|
1812
1876
|
field: i,
|
|
1813
1877
|
options: i.options,
|
|
1814
1878
|
multiple: i.multiple
|
|
1815
1879
|
});
|
|
1816
1880
|
}
|
|
1817
|
-
|
|
1881
|
+
h(r), b(!1);
|
|
1818
1882
|
}, [
|
|
1819
1883
|
f,
|
|
1820
1884
|
e.fields,
|
|
@@ -1825,18 +1889,18 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1825
1889
|
t
|
|
1826
1890
|
]);
|
|
1827
1891
|
let ce = n(async (n) => {
|
|
1828
|
-
|
|
1892
|
+
H(!0);
|
|
1829
1893
|
try {
|
|
1830
1894
|
if (!t) return e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
1831
|
-
let r, i =
|
|
1832
|
-
if (e.mode === "create") r = await t.create(e.objectName, i);
|
|
1895
|
+
let r, i = pt(n, f);
|
|
1896
|
+
if (e.mode === "create") r = await t.create(e.objectName, Ae(i, f));
|
|
1833
1897
|
else if (e.mode === "edit" && e.recordId) {
|
|
1834
|
-
let n = await
|
|
1898
|
+
let n = await z({
|
|
1835
1899
|
dataSource: t,
|
|
1836
1900
|
objectName: e.objectName,
|
|
1837
1901
|
recordId: e.recordId,
|
|
1838
1902
|
payload: i,
|
|
1839
|
-
baseRecord:
|
|
1903
|
+
baseRecord: g
|
|
1840
1904
|
});
|
|
1841
1905
|
if (n.status === "cancelled") return;
|
|
1842
1906
|
r = n.result;
|
|
@@ -1845,70 +1909,71 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1845
1909
|
} catch (t) {
|
|
1846
1910
|
throw e.onError && e.onError(t), t;
|
|
1847
1911
|
} finally {
|
|
1848
|
-
|
|
1912
|
+
H(!1);
|
|
1849
1913
|
}
|
|
1850
1914
|
}, [
|
|
1851
1915
|
e,
|
|
1852
1916
|
t,
|
|
1853
1917
|
f,
|
|
1854
|
-
|
|
1855
|
-
|
|
1918
|
+
z,
|
|
1919
|
+
g
|
|
1856
1920
|
]), Z = n(() => {
|
|
1857
|
-
|
|
1921
|
+
R(!1), U.current && (U.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
|
|
1858
1922
|
}, [e]), le = n((e) => {
|
|
1859
|
-
|
|
1923
|
+
U.current = e, W && T ? R(!0) : Z();
|
|
1860
1924
|
}, [
|
|
1861
|
-
|
|
1862
|
-
|
|
1925
|
+
W,
|
|
1926
|
+
T,
|
|
1863
1927
|
Z
|
|
1864
1928
|
]);
|
|
1865
1929
|
i(() => {
|
|
1866
|
-
if (!
|
|
1930
|
+
if (!G || !T || !W) return;
|
|
1867
1931
|
let e = (e) => {
|
|
1868
1932
|
e.preventDefault(), e.returnValue = "";
|
|
1869
1933
|
};
|
|
1870
1934
|
return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
1871
1935
|
}, [
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1936
|
+
G,
|
|
1937
|
+
T,
|
|
1938
|
+
W
|
|
1875
1939
|
]);
|
|
1876
|
-
let
|
|
1877
|
-
|
|
1878
|
-
}, [Z]),
|
|
1879
|
-
if (e.drawerWidth) return
|
|
1940
|
+
let ue = n(() => {
|
|
1941
|
+
U.current = !0, Z();
|
|
1942
|
+
}, [Z]), de = o(() => {
|
|
1943
|
+
if (e.drawerWidth) return K === "left" || K === "right" ? {
|
|
1880
1944
|
width: e.drawerWidth,
|
|
1881
1945
|
maxWidth: e.drawerWidth
|
|
1882
1946
|
} : {
|
|
1883
1947
|
height: e.drawerWidth,
|
|
1884
1948
|
maxHeight: e.drawerWidth
|
|
1885
1949
|
};
|
|
1886
|
-
}, [e.drawerWidth,
|
|
1950
|
+
}, [e.drawerWidth, K]), fe = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", pe = e.showSubmit !== !1 && e.mode !== "view", me = e.showCancel !== !1, he = e.submitText || (e.mode === "create" ? "Create" : "Update"), _e = e.cancelText || "Cancel", ve = {
|
|
1887
1951
|
type: "form",
|
|
1888
1952
|
objectName: e.objectName,
|
|
1889
|
-
layout:
|
|
1890
|
-
defaultValues:
|
|
1891
|
-
|
|
1953
|
+
layout: fe,
|
|
1954
|
+
defaultValues: g,
|
|
1955
|
+
previousValues: e.mode === "edit" && e.recordId ? g : void 0,
|
|
1956
|
+
submitLabel: he,
|
|
1892
1957
|
cancelLabel: _e,
|
|
1893
|
-
showSubmit:
|
|
1894
|
-
showCancel:
|
|
1958
|
+
showSubmit: pe,
|
|
1959
|
+
showCancel: me,
|
|
1895
1960
|
onSubmit: ce,
|
|
1896
|
-
onCancel:
|
|
1897
|
-
onDirtyChange:
|
|
1961
|
+
onCancel: ue,
|
|
1962
|
+
onDirtyChange: D,
|
|
1898
1963
|
showActions: !1,
|
|
1899
|
-
id:
|
|
1964
|
+
id: ie
|
|
1900
1965
|
}, ye = () => {
|
|
1901
|
-
if (
|
|
1966
|
+
if (S) return /* @__PURE__ */ $("div", {
|
|
1902
1967
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1903
1968
|
children: [/* @__PURE__ */ Q("h3", {
|
|
1904
1969
|
className: "text-red-800 font-semibold",
|
|
1905
1970
|
children: "Error loading form"
|
|
1906
1971
|
}), /* @__PURE__ */ Q("p", {
|
|
1907
1972
|
className: "text-red-600 text-sm mt-1",
|
|
1908
|
-
children:
|
|
1973
|
+
children: S.message
|
|
1909
1974
|
})]
|
|
1910
1975
|
});
|
|
1911
|
-
if (
|
|
1976
|
+
if (v) return /* @__PURE__ */ $("div", {
|
|
1912
1977
|
className: "p-8 text-center",
|
|
1913
1978
|
children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
|
|
1914
1979
|
className: "mt-2 text-sm text-gray-600",
|
|
@@ -1918,7 +1983,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1918
1983
|
if (e.sections?.length) {
|
|
1919
1984
|
let t = [];
|
|
1920
1985
|
return e.sections.forEach((e, n) => {
|
|
1921
|
-
let r = e.name || String(n), i =
|
|
1986
|
+
let r = e.name || String(n), i = ae[r] ?? e.collapsed ?? !1;
|
|
1922
1987
|
t.push({
|
|
1923
1988
|
name: `__section_${r}`,
|
|
1924
1989
|
label: e.label || "",
|
|
@@ -1926,7 +1991,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1926
1991
|
colSpan: 4,
|
|
1927
1992
|
collapsible: e.collapsible,
|
|
1928
1993
|
collapsed: i,
|
|
1929
|
-
onToggle: e.collapsible ? () =>
|
|
1994
|
+
onToggle: e.collapsible ? () => X((e) => ({
|
|
1930
1995
|
...e,
|
|
1931
1996
|
[r]: !i
|
|
1932
1997
|
})) : void 0,
|
|
@@ -1937,19 +2002,19 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1937
2002
|
...e,
|
|
1938
2003
|
hidden: !0
|
|
1939
2004
|
}))) : t.push(...a);
|
|
1940
|
-
}), /* @__PURE__ */ Q(
|
|
2005
|
+
}), /* @__PURE__ */ Q(y, { schema: {
|
|
1941
2006
|
...ve,
|
|
1942
2007
|
fields: t
|
|
1943
2008
|
} });
|
|
1944
2009
|
}
|
|
1945
|
-
let t =
|
|
1946
|
-
return /* @__PURE__ */ Q(
|
|
2010
|
+
let t = $e(m, f, e.columns, e.mode), n = qt[t.columns || 1];
|
|
2011
|
+
return /* @__PURE__ */ Q(y, { schema: {
|
|
1947
2012
|
...ve,
|
|
1948
2013
|
fields: t.fields,
|
|
1949
2014
|
columns: t.columns,
|
|
1950
2015
|
...n ? { fieldContainerClass: n } : {}
|
|
1951
2016
|
} });
|
|
1952
|
-
}, be = e.subforms, xe = be?.length && e.mode !== "view" ? /* @__PURE__ */ Q(
|
|
2017
|
+
}, be = e.subforms, xe = be?.length && e.mode !== "view" ? /* @__PURE__ */ Q(Kt, {
|
|
1953
2018
|
schema: {
|
|
1954
2019
|
type: "object-master-detail-form",
|
|
1955
2020
|
objectName: e.objectName,
|
|
@@ -1980,8 +2045,8 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1980
2045
|
children: e.description
|
|
1981
2046
|
})]
|
|
1982
2047
|
}), xe]
|
|
1983
|
-
}) : /* @__PURE__ */ Q(
|
|
1984
|
-
open:
|
|
2048
|
+
}) : /* @__PURE__ */ Q(te, {
|
|
2049
|
+
open: G,
|
|
1985
2050
|
onOpenChange: (t) => {
|
|
1986
2051
|
if (t) {
|
|
1987
2052
|
e.onOpenChange?.(!0);
|
|
@@ -1989,62 +2054,62 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1989
2054
|
}
|
|
1990
2055
|
le(!1);
|
|
1991
2056
|
},
|
|
1992
|
-
children: /* @__PURE__ */ $(
|
|
1993
|
-
side:
|
|
1994
|
-
className:
|
|
1995
|
-
style:
|
|
2057
|
+
children: /* @__PURE__ */ $(ne, {
|
|
2058
|
+
side: K,
|
|
2059
|
+
className: Y("overflow-y-auto", r, e.className),
|
|
2060
|
+
style: de,
|
|
1996
2061
|
children: [
|
|
1997
|
-
(e.title || e.description) && /* @__PURE__ */ $(
|
|
2062
|
+
(e.title || e.description) && /* @__PURE__ */ $(q, { children: [e.title && /* @__PURE__ */ Q(J, { children: e.title }), e.description ? /* @__PURE__ */ Q(re, { children: e.description }) : /* @__PURE__ */ Q(re, {
|
|
1998
2063
|
className: "sr-only",
|
|
1999
|
-
children: "
|
|
2064
|
+
children: u("form.dialogDescriptionFallback")
|
|
2000
2065
|
})] }),
|
|
2001
2066
|
/* @__PURE__ */ Q("div", {
|
|
2002
2067
|
className: "@container py-4",
|
|
2003
2068
|
children: xe
|
|
2004
2069
|
}),
|
|
2005
|
-
!
|
|
2070
|
+
!S && !v && !(be?.length && e.mode !== "view") && (pe || me) && /* @__PURE__ */ Q("div", {
|
|
2006
2071
|
className: "shrink-0 border-t px-4 py-3 bg-background",
|
|
2007
2072
|
"data-testid": "drawer-form-footer",
|
|
2008
2073
|
children: /* @__PURE__ */ $("div", {
|
|
2009
2074
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
2010
|
-
children: [
|
|
2075
|
+
children: [me && /* @__PURE__ */ Q(I, {
|
|
2011
2076
|
type: "button",
|
|
2012
2077
|
variant: "outline",
|
|
2013
|
-
onClick:
|
|
2014
|
-
disabled:
|
|
2078
|
+
onClick: ue,
|
|
2079
|
+
disabled: V,
|
|
2015
2080
|
className: "w-full sm:w-auto",
|
|
2016
2081
|
children: _e
|
|
2017
|
-
}),
|
|
2082
|
+
}), pe && /* @__PURE__ */ $(I, {
|
|
2018
2083
|
type: "submit",
|
|
2019
|
-
form:
|
|
2020
|
-
disabled:
|
|
2084
|
+
form: ie,
|
|
2085
|
+
disabled: V,
|
|
2021
2086
|
className: "w-full sm:w-auto",
|
|
2022
|
-
children: [
|
|
2087
|
+
children: [V && /* @__PURE__ */ Q(ge, { className: "mr-2 h-4 w-4 animate-spin" }), he]
|
|
2023
2088
|
})]
|
|
2024
2089
|
})
|
|
2025
2090
|
}),
|
|
2026
|
-
/* @__PURE__ */ Q(
|
|
2027
|
-
open:
|
|
2028
|
-
onOpenChange:
|
|
2029
|
-
children: /* @__PURE__ */ $(
|
|
2091
|
+
/* @__PURE__ */ Q(k, {
|
|
2092
|
+
open: L,
|
|
2093
|
+
onOpenChange: R,
|
|
2094
|
+
children: /* @__PURE__ */ $(M, { children: [/* @__PURE__ */ $(F, { children: [/* @__PURE__ */ Q(ee, { children: u("form.discardTitle") }), /* @__PURE__ */ Q(N, { children: u("form.discardMessage") })] }), /* @__PURE__ */ $(P, { children: [/* @__PURE__ */ Q(j, {
|
|
2030
2095
|
onClick: () => {
|
|
2031
|
-
|
|
2096
|
+
U.current = !1;
|
|
2032
2097
|
},
|
|
2033
2098
|
children: u("form.keepEditing")
|
|
2034
|
-
}), /* @__PURE__ */ Q(
|
|
2099
|
+
}), /* @__PURE__ */ Q(A, {
|
|
2035
2100
|
onClick: Z,
|
|
2036
2101
|
children: u("form.discard")
|
|
2037
2102
|
})] })] })
|
|
2038
2103
|
}),
|
|
2039
|
-
|
|
2104
|
+
B
|
|
2040
2105
|
]
|
|
2041
2106
|
})
|
|
2042
2107
|
});
|
|
2043
2108
|
};
|
|
2044
2109
|
//#endregion
|
|
2045
2110
|
//#region src/fieldGroups.ts
|
|
2046
|
-
function
|
|
2047
|
-
let n =
|
|
2111
|
+
function Xt(e, t) {
|
|
2112
|
+
let n = ce({
|
|
2048
2113
|
fieldGroups: t,
|
|
2049
2114
|
fields: Object.fromEntries(e.map((e) => [e.name, { group: e.group }]))
|
|
2050
2115
|
});
|
|
@@ -2064,19 +2129,20 @@ function Lt(e, t) {
|
|
|
2064
2129
|
}
|
|
2065
2130
|
//#endregion
|
|
2066
2131
|
//#region src/ModalForm.tsx
|
|
2067
|
-
var
|
|
2132
|
+
var Zt = ye({
|
|
2068
2133
|
"form.discardTitle": "Discard changes?",
|
|
2069
2134
|
"form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
|
|
2135
|
+
"form.dialogDescriptionFallback": "Complete the form fields, then submit or cancel.",
|
|
2070
2136
|
"form.keepEditing": "Keep editing",
|
|
2071
2137
|
"form.discard": "Discard"
|
|
2072
|
-
}, "form.discardTitle"),
|
|
2138
|
+
}, "form.discardTitle"), Qt = {
|
|
2073
2139
|
sm: "sm:max-w-sm",
|
|
2074
2140
|
default: "sm:max-w-lg",
|
|
2075
2141
|
lg: "sm:max-w-2xl",
|
|
2076
2142
|
xl: "sm:max-w-5xl",
|
|
2077
2143
|
full: "sm:max-w-[95vw] sm:w-full"
|
|
2078
|
-
},
|
|
2079
|
-
let { fieldLabel: l, sectionLabel: u } =
|
|
2144
|
+
}, $t = ({ schema: e, dataSource: t, className: r }) => {
|
|
2145
|
+
let { fieldLabel: l, sectionLabel: u } = C(), { t: d } = Zt(), f = x(), p = se(), m = n((t) => {
|
|
2080
2146
|
if (!p?.isLoaded) return t;
|
|
2081
2147
|
let n = [];
|
|
2082
2148
|
for (let r of t) {
|
|
@@ -2095,13 +2161,13 @@ var Rt = pe({
|
|
|
2095
2161
|
p,
|
|
2096
2162
|
e.objectName,
|
|
2097
2163
|
e.mode
|
|
2098
|
-
]), [
|
|
2164
|
+
]), [h, g] = c(null), [_, v] = c([]), [b, S] = c({}), [w, T] = c(!0), [D, L] = c(null), [R, z] = c(!1), [B, V] = c(!1), [te, ne] = c(!1), { saveWithOcc: re, conflictDialog: q } = it(), J = s(!1), ae = e.confirmOnDiscard !== !1, X = e.open !== !1, oe = a(), ce = o(() => {
|
|
2099
2165
|
if (e.sections?.length || e.customFields?.length) return null;
|
|
2100
|
-
let t =
|
|
2101
|
-
e.mode === "create" && (t =
|
|
2102
|
-
let n =
|
|
2166
|
+
let t = qe(_, h);
|
|
2167
|
+
e.mode === "create" && (t = Ye(t, h));
|
|
2168
|
+
let n = Xt(t, h?.fieldGroups);
|
|
2103
2169
|
if (!n) return null;
|
|
2104
|
-
let r = e.columns && e.columns > 0 ? Math.min(Math.floor(e.columns), 4) :
|
|
2170
|
+
let r = e.columns && e.columns > 0 ? Math.min(Math.floor(e.columns), 4) : He(t.length);
|
|
2105
2171
|
return n.map((e) => ({
|
|
2106
2172
|
...e,
|
|
2107
2173
|
columns: r
|
|
@@ -2111,70 +2177,70 @@ var Rt = pe({
|
|
|
2111
2177
|
e.customFields,
|
|
2112
2178
|
e.columns,
|
|
2113
2179
|
e.mode,
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
]), Z = e.sections?.length ? e.sections : ce ?? void 0, le = o(() => Z?.length || e.customFields?.length ? null :
|
|
2117
|
-
|
|
2118
|
-
|
|
2180
|
+
_,
|
|
2181
|
+
h
|
|
2182
|
+
]), Z = e.sections?.length ? e.sections : ce ?? void 0, le = o(() => Z?.length || e.customFields?.length ? null : $e(_, h, e.columns, e.mode), [
|
|
2183
|
+
_,
|
|
2184
|
+
h,
|
|
2119
2185
|
e.columns,
|
|
2120
2186
|
e.mode,
|
|
2121
2187
|
Z,
|
|
2122
2188
|
e.customFields
|
|
2123
|
-
]),
|
|
2189
|
+
]), ue = Qt[o(() => {
|
|
2124
2190
|
if (e.modalSize) return e.modalSize;
|
|
2125
|
-
if (le?.columns && le.columns > 1) return
|
|
2191
|
+
if (le?.columns && le.columns > 1) return Qe(le.columns);
|
|
2126
2192
|
if (Z?.length) {
|
|
2127
2193
|
let e = Math.max(...Z.map((e) => Number(e.columns) || 1));
|
|
2128
|
-
if (e > 1) return
|
|
2194
|
+
if (e > 1) return Qe(e);
|
|
2129
2195
|
}
|
|
2130
2196
|
return "default";
|
|
2131
2197
|
}, [
|
|
2132
2198
|
e.modalSize,
|
|
2133
2199
|
le,
|
|
2134
2200
|
Z
|
|
2135
|
-
])] ||
|
|
2201
|
+
])] || Qt.default;
|
|
2136
2202
|
i(() => {
|
|
2137
2203
|
(async () => {
|
|
2138
2204
|
if (!t) {
|
|
2139
|
-
|
|
2205
|
+
T(!1);
|
|
2140
2206
|
return;
|
|
2141
2207
|
}
|
|
2142
2208
|
try {
|
|
2143
2209
|
let n = await t.getObjectSchema(e.objectName);
|
|
2144
|
-
|
|
2210
|
+
g(n);
|
|
2145
2211
|
} catch (e) {
|
|
2146
|
-
|
|
2212
|
+
L(e), T(!1);
|
|
2147
2213
|
}
|
|
2148
2214
|
})();
|
|
2149
2215
|
}, [e.objectName, t]);
|
|
2150
|
-
let
|
|
2216
|
+
let de = s(void 0);
|
|
2151
2217
|
i(() => {
|
|
2152
2218
|
let n = !1;
|
|
2153
|
-
return (
|
|
2219
|
+
return (h || !t) && (async () => {
|
|
2154
2220
|
if (e.mode === "create" || !e.recordId) {
|
|
2155
|
-
|
|
2221
|
+
S(ke(h, e.initialData || e.initialValues)), T(!1);
|
|
2156
2222
|
return;
|
|
2157
2223
|
}
|
|
2158
2224
|
if (!t) {
|
|
2159
|
-
|
|
2225
|
+
S(e.initialData || e.initialValues || {}), T(!1);
|
|
2160
2226
|
return;
|
|
2161
2227
|
}
|
|
2162
|
-
|
|
2228
|
+
de.current !== e.recordId && (T(!0), V(!1));
|
|
2163
2229
|
try {
|
|
2164
2230
|
let r = await t.findOne(e.objectName, e.recordId);
|
|
2165
2231
|
if (n) return;
|
|
2166
|
-
|
|
2232
|
+
de.current = e.recordId, S(r || {});
|
|
2167
2233
|
} catch (e) {
|
|
2168
2234
|
if (n) return;
|
|
2169
|
-
|
|
2235
|
+
L(e);
|
|
2170
2236
|
} finally {
|
|
2171
|
-
n ||
|
|
2237
|
+
n || T(!1);
|
|
2172
2238
|
}
|
|
2173
2239
|
})(), () => {
|
|
2174
2240
|
n = !0;
|
|
2175
2241
|
};
|
|
2176
2242
|
}, [
|
|
2177
|
-
|
|
2243
|
+
h,
|
|
2178
2244
|
e.mode,
|
|
2179
2245
|
e.recordId,
|
|
2180
2246
|
e.initialData,
|
|
@@ -2182,44 +2248,46 @@ var Rt = pe({
|
|
|
2182
2248
|
t,
|
|
2183
2249
|
e.objectName
|
|
2184
2250
|
]);
|
|
2185
|
-
let
|
|
2186
|
-
objectSchema:
|
|
2251
|
+
let fe = n((t) => Ie(t, {
|
|
2252
|
+
objectSchema: h,
|
|
2187
2253
|
objectName: e.objectName,
|
|
2188
2254
|
readOnly: e.readOnly,
|
|
2189
2255
|
mode: e.mode,
|
|
2256
|
+
recordId: e.recordId,
|
|
2190
2257
|
fieldLabel: l
|
|
2191
2258
|
}), [
|
|
2192
|
-
|
|
2259
|
+
h,
|
|
2193
2260
|
e.readOnly,
|
|
2194
2261
|
e.mode,
|
|
2262
|
+
e.recordId,
|
|
2195
2263
|
e.objectName,
|
|
2196
2264
|
l
|
|
2197
2265
|
]);
|
|
2198
2266
|
i(() => {
|
|
2199
|
-
if (!
|
|
2267
|
+
if (!h && t) return;
|
|
2200
2268
|
if (e.customFields?.length) {
|
|
2201
|
-
|
|
2269
|
+
v(e.customFields), T(!1);
|
|
2202
2270
|
return;
|
|
2203
2271
|
}
|
|
2204
2272
|
if (e.sections?.length) {
|
|
2205
|
-
|
|
2273
|
+
T(!1);
|
|
2206
2274
|
return;
|
|
2207
2275
|
}
|
|
2208
|
-
if (!
|
|
2209
|
-
let n = e.fields || Object.keys(
|
|
2276
|
+
if (!h) return;
|
|
2277
|
+
let n = e.fields || Object.keys(h.fields || {}), r = [];
|
|
2210
2278
|
for (let t of n) {
|
|
2211
2279
|
let n = typeof t == "string" ? t : t.name;
|
|
2212
2280
|
if (!n) continue;
|
|
2213
|
-
let i =
|
|
2281
|
+
let i = h.fields?.[n];
|
|
2214
2282
|
i && r.push({
|
|
2215
2283
|
name: n,
|
|
2216
2284
|
label: l(e.objectName, n, i.label || n),
|
|
2217
|
-
type:
|
|
2218
|
-
required: i
|
|
2285
|
+
type: O(i.type, { multiple: i.multiple }),
|
|
2286
|
+
required: De(i, Ee(e)),
|
|
2219
2287
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
2220
2288
|
placeholder: i.placeholder,
|
|
2221
2289
|
description: i.help || i.description,
|
|
2222
|
-
validation:
|
|
2290
|
+
validation: E(i),
|
|
2223
2291
|
field: i,
|
|
2224
2292
|
options: i.options,
|
|
2225
2293
|
multiple: i.multiple,
|
|
@@ -2229,9 +2297,9 @@ var Rt = pe({
|
|
|
2229
2297
|
group: i.group
|
|
2230
2298
|
});
|
|
2231
2299
|
}
|
|
2232
|
-
|
|
2300
|
+
v(r), T(!1);
|
|
2233
2301
|
}, [
|
|
2234
|
-
|
|
2302
|
+
h,
|
|
2235
2303
|
e.fields,
|
|
2236
2304
|
e.customFields,
|
|
2237
2305
|
e.sections,
|
|
@@ -2239,24 +2307,24 @@ var Rt = pe({
|
|
|
2239
2307
|
e.mode,
|
|
2240
2308
|
t
|
|
2241
2309
|
]);
|
|
2242
|
-
let
|
|
2243
|
-
|
|
2310
|
+
let pe = n(async (n) => {
|
|
2311
|
+
z(!0);
|
|
2244
2312
|
try {
|
|
2245
2313
|
if (!t) return e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
2246
|
-
let r, i =
|
|
2314
|
+
let r, i = pt(n, h);
|
|
2247
2315
|
if (p?.isLoaded) {
|
|
2248
2316
|
let t = {};
|
|
2249
2317
|
for (let n of Object.keys(i)) p.checkField(e.objectName, n, "write") && (t[n] = i[n]);
|
|
2250
2318
|
i = t;
|
|
2251
2319
|
}
|
|
2252
|
-
if (e.mode === "create") r = await t.create(e.objectName, i);
|
|
2320
|
+
if (e.mode === "create") r = await t.create(e.objectName, Ae(i, h));
|
|
2253
2321
|
else if (e.mode === "edit" && e.recordId) {
|
|
2254
|
-
let n = await
|
|
2322
|
+
let n = await re({
|
|
2255
2323
|
dataSource: t,
|
|
2256
2324
|
objectName: e.objectName,
|
|
2257
2325
|
recordId: e.recordId,
|
|
2258
2326
|
payload: i,
|
|
2259
|
-
baseRecord:
|
|
2327
|
+
baseRecord: b
|
|
2260
2328
|
});
|
|
2261
2329
|
if (n.status === "cancelled") return;
|
|
2262
2330
|
r = n.result;
|
|
@@ -2265,63 +2333,64 @@ var Rt = pe({
|
|
|
2265
2333
|
} catch (t) {
|
|
2266
2334
|
throw e.onError && e.onError(t), t;
|
|
2267
2335
|
} finally {
|
|
2268
|
-
|
|
2336
|
+
z(!1);
|
|
2269
2337
|
}
|
|
2270
2338
|
}, [
|
|
2271
2339
|
e,
|
|
2272
2340
|
t,
|
|
2273
|
-
|
|
2341
|
+
h,
|
|
2274
2342
|
p,
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
]),
|
|
2278
|
-
|
|
2279
|
-
}, [e]),
|
|
2280
|
-
|
|
2343
|
+
re,
|
|
2344
|
+
b
|
|
2345
|
+
]), me = n(() => {
|
|
2346
|
+
ne(!1), J.current && (J.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
|
|
2347
|
+
}, [e]), he = n((e) => {
|
|
2348
|
+
J.current = e, ae && B ? ne(!0) : me();
|
|
2281
2349
|
}, [
|
|
2282
2350
|
ae,
|
|
2283
|
-
|
|
2284
|
-
|
|
2351
|
+
B,
|
|
2352
|
+
me
|
|
2285
2353
|
]);
|
|
2286
2354
|
i(() => {
|
|
2287
|
-
if (!
|
|
2355
|
+
if (!X || !B || !ae) return;
|
|
2288
2356
|
let e = (e) => {
|
|
2289
2357
|
e.preventDefault(), e.returnValue = "";
|
|
2290
2358
|
};
|
|
2291
2359
|
return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
2292
2360
|
}, [
|
|
2293
|
-
|
|
2294
|
-
|
|
2361
|
+
X,
|
|
2362
|
+
B,
|
|
2295
2363
|
ae
|
|
2296
2364
|
]);
|
|
2297
2365
|
let _e = n(() => {
|
|
2298
|
-
|
|
2299
|
-
}, [
|
|
2366
|
+
J.current = !0, me();
|
|
2367
|
+
}, [me]), ve = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", ye = e.showSubmit !== !1 && e.mode !== "view", be = e.showCancel !== !1, xe = e.submitText || (e.mode === "create" ? "Create" : "Update"), Se = e.cancelText || "Cancel", Ce = {
|
|
2300
2368
|
type: "form",
|
|
2301
2369
|
objectName: e.objectName,
|
|
2302
2370
|
layout: ve,
|
|
2303
|
-
defaultValues:
|
|
2371
|
+
defaultValues: b,
|
|
2372
|
+
previousValues: e.mode === "edit" && e.recordId ? b : void 0,
|
|
2304
2373
|
submitLabel: xe,
|
|
2305
2374
|
cancelLabel: Se,
|
|
2306
2375
|
showSubmit: ye,
|
|
2307
2376
|
showCancel: be,
|
|
2308
|
-
onSubmit:
|
|
2377
|
+
onSubmit: pe,
|
|
2309
2378
|
onCancel: _e,
|
|
2310
|
-
onDirtyChange:
|
|
2379
|
+
onDirtyChange: V,
|
|
2311
2380
|
showActions: !1,
|
|
2312
|
-
id:
|
|
2313
|
-
},
|
|
2314
|
-
if (
|
|
2381
|
+
id: oe
|
|
2382
|
+
}, we = () => {
|
|
2383
|
+
if (D) return /* @__PURE__ */ $("div", {
|
|
2315
2384
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
2316
2385
|
children: [/* @__PURE__ */ Q("h3", {
|
|
2317
2386
|
className: "text-red-800 font-semibold",
|
|
2318
2387
|
children: "Error loading form"
|
|
2319
2388
|
}), /* @__PURE__ */ Q("p", {
|
|
2320
2389
|
className: "text-red-600 text-sm mt-1",
|
|
2321
|
-
children:
|
|
2390
|
+
children: D.message
|
|
2322
2391
|
})]
|
|
2323
2392
|
});
|
|
2324
|
-
if (
|
|
2393
|
+
if (w) return /* @__PURE__ */ Q("div", {
|
|
2325
2394
|
className: "space-y-4",
|
|
2326
2395
|
"data-testid": "modal-form-skeleton",
|
|
2327
2396
|
children: [
|
|
@@ -2330,26 +2399,26 @@ var Rt = pe({
|
|
|
2330
2399
|
3
|
|
2331
2400
|
].map((e) => /* @__PURE__ */ $("div", {
|
|
2332
2401
|
className: "space-y-2",
|
|
2333
|
-
children: [/* @__PURE__ */ Q(
|
|
2402
|
+
children: [/* @__PURE__ */ Q(ie, { className: "h-4 w-24" }), /* @__PURE__ */ Q(ie, { className: "h-10 w-full" })]
|
|
2334
2403
|
}, e))
|
|
2335
2404
|
});
|
|
2336
2405
|
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 = m(
|
|
2406
|
+
let t = e.sections, n = (e, t) => e.name || e.label || String(t), r = (t) => t.name ? u(e.objectName, t.name, t.label || t.name) : t.label, i = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, a = t.map((e) => i(e.columns)).filter((e) => e != null), o = i(e.columns) ?? (a.length ? Math.max(...a) : 1), s = Xe[o], c = t.map((e, t) => {
|
|
2407
|
+
let a = m(fe(e));
|
|
2339
2408
|
return {
|
|
2340
2409
|
key: n(e, t),
|
|
2341
2410
|
title: r(e),
|
|
2342
2411
|
description: e.description,
|
|
2343
2412
|
className: e.className,
|
|
2344
2413
|
gridClassName: e.gridClassName,
|
|
2345
|
-
fields: o > 1 ?
|
|
2414
|
+
fields: o > 1 ? Ge(a, o, i(e.columns)) : a
|
|
2346
2415
|
};
|
|
2347
2416
|
}).filter((e) => e.fields.length > 0), l = {
|
|
2348
|
-
...
|
|
2417
|
+
...Ce,
|
|
2349
2418
|
columns: o,
|
|
2350
2419
|
...s ? { fieldContainerClass: s } : {}
|
|
2351
2420
|
};
|
|
2352
|
-
if (e.contentLayout === "tabbed" && c.length > 1) return /* @__PURE__ */ Q(
|
|
2421
|
+
if (e.contentLayout === "tabbed" && c.length > 1) return /* @__PURE__ */ Q(y, { schema: {
|
|
2353
2422
|
...l,
|
|
2354
2423
|
fields: c.flatMap((e) => e.fields),
|
|
2355
2424
|
fieldTabs: c.map((e, t) => ({
|
|
@@ -2370,7 +2439,7 @@ var Rt = pe({
|
|
|
2370
2439
|
colSpan: 4,
|
|
2371
2440
|
className: e.className
|
|
2372
2441
|
}), d.push(...e.fields);
|
|
2373
|
-
}), /* @__PURE__ */ Q(
|
|
2442
|
+
}), /* @__PURE__ */ Q(y, { schema: {
|
|
2374
2443
|
...l,
|
|
2375
2444
|
fields: d
|
|
2376
2445
|
} });
|
|
@@ -2378,31 +2447,31 @@ var Rt = pe({
|
|
|
2378
2447
|
if (ce?.length) {
|
|
2379
2448
|
let t = Number(ce[0]?.columns) || 1, n = [];
|
|
2380
2449
|
ce.forEach((r, i) => {
|
|
2381
|
-
let a = m(
|
|
2450
|
+
let a = m(fe(r));
|
|
2382
2451
|
if (!a.length) return;
|
|
2383
2452
|
let o = r.name ? u(e.objectName, r.name, r.label || r.name) : r.label;
|
|
2384
2453
|
o && n.push({
|
|
2385
2454
|
name: `__section_${r.name || i}`,
|
|
2386
2455
|
label: o,
|
|
2387
2456
|
type: "section-divider"
|
|
2388
|
-
}), n.push(...t > 1 ?
|
|
2457
|
+
}), n.push(...t > 1 ? Ge(a, t) : a);
|
|
2389
2458
|
});
|
|
2390
|
-
let r =
|
|
2391
|
-
return /* @__PURE__ */ Q(
|
|
2392
|
-
...
|
|
2459
|
+
let r = Xe[t];
|
|
2460
|
+
return /* @__PURE__ */ Q(y, { schema: {
|
|
2461
|
+
...Ce,
|
|
2393
2462
|
fields: n,
|
|
2394
2463
|
columns: t,
|
|
2395
2464
|
...r ? { fieldContainerClass: r } : {}
|
|
2396
2465
|
} });
|
|
2397
2466
|
}
|
|
2398
|
-
let t = le ??
|
|
2399
|
-
return /* @__PURE__ */ Q(
|
|
2400
|
-
...
|
|
2467
|
+
let t = le ?? $e(_, h, e.columns, e.mode), n = Xe[t.columns || 1];
|
|
2468
|
+
return /* @__PURE__ */ Q(y, { schema: {
|
|
2469
|
+
...Ce,
|
|
2401
2470
|
fields: m(t.fields),
|
|
2402
2471
|
columns: t.columns,
|
|
2403
2472
|
...n ? { fieldContainerClass: n } : {}
|
|
2404
2473
|
} });
|
|
2405
|
-
},
|
|
2474
|
+
}, Te = e.subforms;
|
|
2406
2475
|
if (f) return /* @__PURE__ */ $("div", {
|
|
2407
2476
|
className: "@container rounded-md border bg-card p-4",
|
|
2408
2477
|
children: [(e.title || e.description) && /* @__PURE__ */ $("div", {
|
|
@@ -2414,22 +2483,22 @@ var Rt = pe({
|
|
|
2414
2483
|
className: "text-xs text-muted-foreground",
|
|
2415
2484
|
children: e.description
|
|
2416
2485
|
})]
|
|
2417
|
-
}),
|
|
2486
|
+
}), we()]
|
|
2418
2487
|
});
|
|
2419
|
-
if (
|
|
2420
|
-
open:
|
|
2488
|
+
if (Te?.length && e.mode !== "view") return /* @__PURE__ */ Q(H, {
|
|
2489
|
+
open: X,
|
|
2421
2490
|
onOpenChange: e.onOpenChange,
|
|
2422
|
-
children: /* @__PURE__ */ $(
|
|
2423
|
-
className:
|
|
2424
|
-
children: [(e.title || e.description) && /* @__PURE__ */ $(
|
|
2491
|
+
children: /* @__PURE__ */ $(K, {
|
|
2492
|
+
className: Y(ue, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", r, e.className),
|
|
2493
|
+
children: [(e.title || e.description) && /* @__PURE__ */ $(W, {
|
|
2425
2494
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
2426
|
-
children: [e.title && /* @__PURE__ */ Q(
|
|
2495
|
+
children: [e.title && /* @__PURE__ */ Q(G, { children: e.title }), e.description ? /* @__PURE__ */ Q(U, { children: e.description }) : /* @__PURE__ */ Q(U, {
|
|
2427
2496
|
className: "sr-only",
|
|
2428
2497
|
children: "Enter the record and its line items, then save."
|
|
2429
2498
|
})]
|
|
2430
2499
|
}), /* @__PURE__ */ Q("div", {
|
|
2431
2500
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
2432
|
-
children: /* @__PURE__ */ Q(
|
|
2501
|
+
children: /* @__PURE__ */ Q(Kt, {
|
|
2433
2502
|
schema: {
|
|
2434
2503
|
type: "object-master-detail-form",
|
|
2435
2504
|
objectName: e.objectName,
|
|
@@ -2441,7 +2510,7 @@ var Rt = pe({
|
|
|
2441
2510
|
initialData: e.initialData,
|
|
2442
2511
|
submitText: xe,
|
|
2443
2512
|
cancelText: Se,
|
|
2444
|
-
details:
|
|
2513
|
+
details: Te,
|
|
2445
2514
|
onSuccess: async (t) => {
|
|
2446
2515
|
await e.onSuccess?.(t), e.onOpenChange?.(!1);
|
|
2447
2516
|
},
|
|
@@ -2453,80 +2522,80 @@ var Rt = pe({
|
|
|
2453
2522
|
})]
|
|
2454
2523
|
})
|
|
2455
2524
|
});
|
|
2456
|
-
let
|
|
2457
|
-
return /* @__PURE__ */ Q(
|
|
2458
|
-
open:
|
|
2525
|
+
let Oe = !w && !D && (ye || be);
|
|
2526
|
+
return /* @__PURE__ */ Q(H, {
|
|
2527
|
+
open: X,
|
|
2459
2528
|
onOpenChange: (t) => {
|
|
2460
2529
|
if (t) {
|
|
2461
2530
|
e.onOpenChange?.(!0);
|
|
2462
2531
|
return;
|
|
2463
2532
|
}
|
|
2464
|
-
|
|
2533
|
+
he(!1);
|
|
2465
2534
|
},
|
|
2466
|
-
children: /* @__PURE__ */ $(
|
|
2467
|
-
className:
|
|
2535
|
+
children: /* @__PURE__ */ $(K, {
|
|
2536
|
+
className: Y(ue, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", r, e.className),
|
|
2468
2537
|
children: [
|
|
2469
|
-
(e.title || e.description) && /* @__PURE__ */ $(
|
|
2538
|
+
(e.title || e.description) && /* @__PURE__ */ $(W, {
|
|
2470
2539
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
2471
|
-
children: [e.title && /* @__PURE__ */ Q(
|
|
2540
|
+
children: [e.title && /* @__PURE__ */ Q(G, { children: e.title }), e.description ? /* @__PURE__ */ Q(U, { children: e.description }) : /* @__PURE__ */ Q(U, {
|
|
2472
2541
|
className: "sr-only",
|
|
2473
|
-
children: "
|
|
2542
|
+
children: d("form.dialogDescriptionFallback")
|
|
2474
2543
|
})]
|
|
2475
2544
|
}),
|
|
2476
2545
|
/* @__PURE__ */ Q("div", {
|
|
2477
2546
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
2478
|
-
children:
|
|
2547
|
+
children: we()
|
|
2479
2548
|
}),
|
|
2480
|
-
|
|
2549
|
+
Oe && /* @__PURE__ */ Q("div", {
|
|
2481
2550
|
className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background",
|
|
2482
2551
|
"data-testid": "modal-form-footer",
|
|
2483
2552
|
children: /* @__PURE__ */ $("div", {
|
|
2484
2553
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
2485
|
-
children: [be && /* @__PURE__ */ Q(
|
|
2554
|
+
children: [be && /* @__PURE__ */ Q(I, {
|
|
2486
2555
|
type: "button",
|
|
2487
2556
|
variant: "outline",
|
|
2488
2557
|
onClick: _e,
|
|
2489
|
-
disabled:
|
|
2558
|
+
disabled: R,
|
|
2490
2559
|
className: "w-full sm:w-auto",
|
|
2491
2560
|
children: Se
|
|
2492
|
-
}), ye && /* @__PURE__ */ $(
|
|
2561
|
+
}), ye && /* @__PURE__ */ $(I, {
|
|
2493
2562
|
type: "submit",
|
|
2494
|
-
form:
|
|
2495
|
-
disabled:
|
|
2563
|
+
form: oe,
|
|
2564
|
+
disabled: R,
|
|
2496
2565
|
className: "w-full sm:w-auto",
|
|
2497
|
-
children: [
|
|
2566
|
+
children: [R && /* @__PURE__ */ Q(ge, { className: "mr-2 h-4 w-4 animate-spin" }), xe]
|
|
2498
2567
|
})]
|
|
2499
2568
|
})
|
|
2500
2569
|
}),
|
|
2501
|
-
/* @__PURE__ */ Q(
|
|
2502
|
-
open:
|
|
2503
|
-
onOpenChange:
|
|
2504
|
-
children: /* @__PURE__ */ $(
|
|
2570
|
+
/* @__PURE__ */ Q(k, {
|
|
2571
|
+
open: te,
|
|
2572
|
+
onOpenChange: ne,
|
|
2573
|
+
children: /* @__PURE__ */ $(M, { children: [/* @__PURE__ */ $(F, { children: [/* @__PURE__ */ Q(ee, { children: d("form.discardTitle") }), /* @__PURE__ */ Q(N, { children: d("form.discardMessage") })] }), /* @__PURE__ */ $(P, { children: [/* @__PURE__ */ Q(j, {
|
|
2505
2574
|
onClick: () => {
|
|
2506
|
-
|
|
2575
|
+
J.current = !1;
|
|
2507
2576
|
},
|
|
2508
2577
|
children: d("form.keepEditing")
|
|
2509
|
-
}), /* @__PURE__ */ Q(
|
|
2510
|
-
onClick:
|
|
2578
|
+
}), /* @__PURE__ */ Q(A, {
|
|
2579
|
+
onClick: me,
|
|
2511
2580
|
children: d("form.discard")
|
|
2512
2581
|
})] })] })
|
|
2513
2582
|
}),
|
|
2514
|
-
|
|
2583
|
+
q
|
|
2515
2584
|
]
|
|
2516
2585
|
})
|
|
2517
2586
|
});
|
|
2518
2587
|
};
|
|
2519
2588
|
//#endregion
|
|
2520
2589
|
//#region src/ObjectForm.tsx
|
|
2521
|
-
function
|
|
2590
|
+
function en(e) {
|
|
2522
2591
|
let t = e.buttons, n = e.defaults;
|
|
2523
2592
|
if (!t && !n) return e;
|
|
2524
2593
|
let r = e, i = { ...r };
|
|
2525
2594
|
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
2595
|
}
|
|
2527
|
-
var
|
|
2528
|
-
let n =
|
|
2529
|
-
let t =
|
|
2596
|
+
var tn = ({ schema: e, dataSource: t }) => {
|
|
2597
|
+
let n = se(), r = o(() => {
|
|
2598
|
+
let t = en(e), r = t.groups, i = !t.sections?.length && Array.isArray(r) && r.length ? {
|
|
2530
2599
|
...t,
|
|
2531
2600
|
sections: r.map((e) => ({
|
|
2532
2601
|
label: e.title ?? e.label,
|
|
@@ -2550,8 +2619,8 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2550
2619
|
fields: o(e.fields)
|
|
2551
2620
|
}))
|
|
2552
2621
|
};
|
|
2553
|
-
}, [e, n]), { sectionLabel: i } =
|
|
2554
|
-
if (r.subforms?.length && r.mode !== "view" && r.formType !== "drawer" && r.formType !== "modal") return /* @__PURE__ */ Q(
|
|
2622
|
+
}, [e, n]), { sectionLabel: i } = C(), a = (e) => e?.name ? i(r.objectName, e.name, e.label || e.name) : e?.label;
|
|
2623
|
+
if (r.subforms?.length && r.mode !== "view" && r.formType !== "drawer" && r.formType !== "modal") return /* @__PURE__ */ Q(Kt, {
|
|
2555
2624
|
schema: {
|
|
2556
2625
|
type: "object-master-detail-form",
|
|
2557
2626
|
objectName: r.objectName,
|
|
@@ -2574,7 +2643,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2574
2643
|
},
|
|
2575
2644
|
dataSource: t
|
|
2576
2645
|
});
|
|
2577
|
-
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ Q(
|
|
2646
|
+
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ Q(at, {
|
|
2578
2647
|
schema: {
|
|
2579
2648
|
...r,
|
|
2580
2649
|
formType: "tabbed",
|
|
@@ -2593,7 +2662,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2593
2662
|
dataSource: t,
|
|
2594
2663
|
className: r.className
|
|
2595
2664
|
});
|
|
2596
|
-
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ Q(
|
|
2665
|
+
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ Q(lt, {
|
|
2597
2666
|
schema: {
|
|
2598
2667
|
...r,
|
|
2599
2668
|
formType: "wizard",
|
|
@@ -2615,7 +2684,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2615
2684
|
dataSource: t,
|
|
2616
2685
|
className: r.className
|
|
2617
2686
|
});
|
|
2618
|
-
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ Q(
|
|
2687
|
+
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ Q(ut, {
|
|
2619
2688
|
schema: {
|
|
2620
2689
|
...r,
|
|
2621
2690
|
formType: "split",
|
|
@@ -2638,7 +2707,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2638
2707
|
});
|
|
2639
2708
|
if (r.formType === "drawer") {
|
|
2640
2709
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
2641
|
-
return /* @__PURE__ */ Q(
|
|
2710
|
+
return /* @__PURE__ */ Q(Yt, {
|
|
2642
2711
|
schema: {
|
|
2643
2712
|
...n,
|
|
2644
2713
|
layout: i,
|
|
@@ -2664,7 +2733,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2664
2733
|
}
|
|
2665
2734
|
if (r.formType === "modal") {
|
|
2666
2735
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
2667
|
-
return /* @__PURE__ */ Q(
|
|
2736
|
+
return /* @__PURE__ */ Q($t, {
|
|
2668
2737
|
schema: {
|
|
2669
2738
|
...n,
|
|
2670
2739
|
layout: i,
|
|
@@ -2687,12 +2756,12 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2687
2756
|
className: r.className
|
|
2688
2757
|
});
|
|
2689
2758
|
}
|
|
2690
|
-
return /* @__PURE__ */ Q(
|
|
2759
|
+
return /* @__PURE__ */ Q(nn, {
|
|
2691
2760
|
schema: r,
|
|
2692
2761
|
dataSource: t
|
|
2693
2762
|
});
|
|
2694
|
-
},
|
|
2695
|
-
let { fieldLabel: a, sectionLabel: o } =
|
|
2763
|
+
}, nn = ({ schema: e, dataSource: r }) => {
|
|
2764
|
+
let { fieldLabel: a, sectionLabel: o } = C(), s = oe(), l = se(), u = n((t) => {
|
|
2696
2765
|
if (!l?.isLoaded) return t;
|
|
2697
2766
|
let n = [];
|
|
2698
2767
|
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,15 +2775,15 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2706
2775
|
l,
|
|
2707
2776
|
e.objectName,
|
|
2708
2777
|
e.mode
|
|
2709
|
-
]), [d,
|
|
2778
|
+
]), [d, f] = c(null), [p, h] = c([]), [g, _] = c(null), [v, b] = c(!0), [x, S] = c(null), [w, T] = c(null), { saveWithOcc: k, conflictDialog: A } = it(), j = e.customFields && e.customFields.length > 0;
|
|
2710
2779
|
i(() => {
|
|
2711
|
-
j && (
|
|
2780
|
+
j && (_(e.initialData || e.initialValues || {}), b(!1));
|
|
2712
2781
|
}, [
|
|
2713
2782
|
j,
|
|
2714
2783
|
e.initialData,
|
|
2715
2784
|
e.initialValues
|
|
2716
2785
|
]), i(() => {
|
|
2717
|
-
j ?
|
|
2786
|
+
j ? f({
|
|
2718
2787
|
name: e.objectName,
|
|
2719
2788
|
fields: {}
|
|
2720
2789
|
}) : e.objectName && r ? (async () => {
|
|
@@ -2722,11 +2791,11 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2722
2791
|
if (!r) throw Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");
|
|
2723
2792
|
let t = await r.getObjectSchema(e.objectName);
|
|
2724
2793
|
if (!t) throw Error(`No schema found for object "${e.objectName}"`);
|
|
2725
|
-
|
|
2794
|
+
f(t);
|
|
2726
2795
|
} catch (e) {
|
|
2727
|
-
|
|
2796
|
+
S(e), b(!1);
|
|
2728
2797
|
}
|
|
2729
|
-
})() : j ||
|
|
2798
|
+
})() : j || b(!1);
|
|
2730
2799
|
}, [
|
|
2731
2800
|
e.objectName,
|
|
2732
2801
|
r,
|
|
@@ -2734,22 +2803,22 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2734
2803
|
]), i(() => {
|
|
2735
2804
|
d && !j && (async () => {
|
|
2736
2805
|
if (!e.recordId || e.mode === "create") {
|
|
2737
|
-
|
|
2806
|
+
_(e.initialData || e.initialValues || {}), b(!1);
|
|
2738
2807
|
return;
|
|
2739
2808
|
}
|
|
2740
2809
|
if (!j) {
|
|
2741
2810
|
if (!r) {
|
|
2742
|
-
|
|
2811
|
+
S(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), b(!1);
|
|
2743
2812
|
return;
|
|
2744
2813
|
}
|
|
2745
|
-
|
|
2814
|
+
b(!0);
|
|
2746
2815
|
try {
|
|
2747
2816
|
let t = await r.findOne(e.objectName, e.recordId);
|
|
2748
|
-
|
|
2817
|
+
_(t);
|
|
2749
2818
|
} catch (e) {
|
|
2750
|
-
console.error("Failed to fetch record:", e),
|
|
2819
|
+
console.error("Failed to fetch record:", e), S(e);
|
|
2751
2820
|
} finally {
|
|
2752
|
-
|
|
2821
|
+
b(!1);
|
|
2753
2822
|
}
|
|
2754
2823
|
}
|
|
2755
2824
|
})();
|
|
@@ -2766,11 +2835,11 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2766
2835
|
let M = n((e) => e, []);
|
|
2767
2836
|
i(() => {
|
|
2768
2837
|
if (j && e.customFields) {
|
|
2769
|
-
|
|
2838
|
+
h(e.customFields.map(M)), b(!1);
|
|
2770
2839
|
return;
|
|
2771
2840
|
}
|
|
2772
2841
|
if (!d) return;
|
|
2773
|
-
let t = [], n =
|
|
2842
|
+
let t = [], n = m(d, l?.getObjectApiOperations?.(e.objectName)), i = !(e.mode === "edit" ? n.edit : e.mode !== "create" || n.create), o = e.fields || Object.keys(d.fields || {});
|
|
2774
2843
|
(Array.isArray(o) ? o : Object.keys(o)).forEach((n) => {
|
|
2775
2844
|
let r = typeof n == "string" ? n : n.name;
|
|
2776
2845
|
if (!r) return;
|
|
@@ -2782,12 +2851,12 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2782
2851
|
let s = {
|
|
2783
2852
|
name: r,
|
|
2784
2853
|
label: a(e.objectName, r, o.label || n),
|
|
2785
|
-
type:
|
|
2786
|
-
required: o
|
|
2854
|
+
type: O(o.type, { multiple: o.multiple }),
|
|
2855
|
+
required: De(o, Ee(e)),
|
|
2787
2856
|
disabled: e.readOnly || e.mode === "view" || o.readonly || i,
|
|
2788
2857
|
placeholder: o.placeholder,
|
|
2789
2858
|
description: o.help || o.description,
|
|
2790
|
-
validation:
|
|
2859
|
+
validation: E(o),
|
|
2791
2860
|
visibleWhen: o.visibleWhen,
|
|
2792
2861
|
readonlyWhen: o.readonlyWhen,
|
|
2793
2862
|
requiredWhen: o.requiredWhen,
|
|
@@ -2796,12 +2865,12 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2796
2865
|
widget: o.widget
|
|
2797
2866
|
};
|
|
2798
2867
|
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: ${
|
|
2868
|
+
let e = `Max size: ${D(o.max_size)}`;
|
|
2800
2869
|
s.description = s.description ? `${s.description} (${e})` : e;
|
|
2801
2870
|
}
|
|
2802
2871
|
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
2872
|
}
|
|
2804
|
-
}),
|
|
2873
|
+
}), h(t), !j && e.recordId && e.mode !== "create" && r || b(!1);
|
|
2805
2874
|
}, [
|
|
2806
2875
|
d,
|
|
2807
2876
|
e.fields,
|
|
@@ -2817,8 +2886,8 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2817
2886
|
let N = n(async (t, n) => {
|
|
2818
2887
|
if (t && (t.nativeEvent || t._reactName === "onSubmit") && (console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."), n === void 0 && (t = {})), j && !r) return e.onSuccess && await e.onSuccess(t), t;
|
|
2819
2888
|
if (!r) throw Error("DataSource is required for form submission (inline mode not configured)");
|
|
2820
|
-
let i =
|
|
2821
|
-
if (l?.isLoaded && i && typeof i == "object") {
|
|
2889
|
+
let i = pt(t, j ? null : d);
|
|
2890
|
+
if (Ee(e) && (i = Ae(i, j ? null : d)), l?.isLoaded && i && typeof i == "object") {
|
|
2822
2891
|
let t = {};
|
|
2823
2892
|
for (let n of Object.keys(i)) l.checkField(e.objectName, n, "write") && (t[n] = i[n]);
|
|
2824
2893
|
i = t;
|
|
@@ -2833,7 +2902,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2833
2902
|
objectName: e.objectName,
|
|
2834
2903
|
recordId: e.recordId,
|
|
2835
2904
|
payload: i,
|
|
2836
|
-
baseRecord:
|
|
2905
|
+
baseRecord: g
|
|
2837
2906
|
});
|
|
2838
2907
|
if (n.status === "cancelled") return;
|
|
2839
2908
|
t = n.result;
|
|
@@ -2843,12 +2912,12 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2843
2912
|
let t = e.submitBehavior;
|
|
2844
2913
|
switch (t.kind) {
|
|
2845
2914
|
case "redirect":
|
|
2846
|
-
|
|
2915
|
+
xe(t.url) && setTimeout(() => window.location.assign(t.url), t.delayMs ?? 0);
|
|
2847
2916
|
break;
|
|
2848
2917
|
case "continue": break;
|
|
2849
2918
|
default: {
|
|
2850
2919
|
let n = t.kind === "thank-you" && t.message ? t.message : e.successMessage || (e.mode === "create" ? "Created" : "Saved");
|
|
2851
|
-
|
|
2920
|
+
X.success(n), T({
|
|
2852
2921
|
title: t.kind === "thank-you" ? t.title : void 0,
|
|
2853
2922
|
message: n
|
|
2854
2923
|
});
|
|
@@ -2856,9 +2925,9 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2856
2925
|
}
|
|
2857
2926
|
}
|
|
2858
2927
|
} else if (!e.submitHandler) {
|
|
2859
|
-
let n =
|
|
2928
|
+
let n = Se(e.navigateOnSuccess, t);
|
|
2860
2929
|
if (n) return window.location.assign(n), t;
|
|
2861
|
-
|
|
2930
|
+
X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved"));
|
|
2862
2931
|
}
|
|
2863
2932
|
return t;
|
|
2864
2933
|
} catch (t) {
|
|
@@ -2871,62 +2940,55 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2871
2940
|
l,
|
|
2872
2941
|
d,
|
|
2873
2942
|
k,
|
|
2874
|
-
|
|
2943
|
+
g
|
|
2875
2944
|
]), P = n(() => {
|
|
2876
2945
|
e.onCancel && e.onCancel();
|
|
2877
|
-
}, [e]), F = {
|
|
2878
|
-
...t.useMemo(() => {
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
n.defaultValue !== void 0 && (e[t] = n.defaultValue);
|
|
2884
|
-
}), e;
|
|
2885
|
-
}, [d]),
|
|
2886
|
-
..._
|
|
2887
|
-
}, I = t.useMemo(() => {
|
|
2888
|
-
let t = Pe(m, d);
|
|
2889
|
-
return e.mode === "create" && (t = Ie(t, d)), t;
|
|
2946
|
+
}, [e]), F = Ee(e), ee = {
|
|
2947
|
+
...t.useMemo(() => F ? Oe(d) : {}, [d, F]),
|
|
2948
|
+
...g
|
|
2949
|
+
}, I = e.mode === "edit" && e.recordId && g && typeof g == "object" ? g : void 0, L = t.useMemo(() => {
|
|
2950
|
+
let t = qe(p, d);
|
|
2951
|
+
return e.mode === "create" && (t = Ye(t, d)), t;
|
|
2890
2952
|
}, [
|
|
2891
|
-
|
|
2953
|
+
p,
|
|
2892
2954
|
d,
|
|
2893
2955
|
e.mode
|
|
2894
|
-
]),
|
|
2956
|
+
]), R = t.useMemo(() => e.sections?.length ? null : Xt(L, d?.fieldGroups), [
|
|
2895
2957
|
e.sections,
|
|
2896
|
-
|
|
2958
|
+
L,
|
|
2897
2959
|
d
|
|
2898
|
-
]),
|
|
2899
|
-
if (
|
|
2960
|
+
]), z = e.sections?.length ? e.sections : R, [B, V] = c({});
|
|
2961
|
+
if (x) return /* @__PURE__ */ $("div", {
|
|
2900
2962
|
className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
|
|
2901
2963
|
children: [/* @__PURE__ */ Q("h3", {
|
|
2902
2964
|
className: "text-red-800 font-semibold",
|
|
2903
2965
|
children: "Error loading form"
|
|
2904
2966
|
}), /* @__PURE__ */ Q("p", {
|
|
2905
2967
|
className: "text-red-600 text-sm mt-1",
|
|
2906
|
-
children:
|
|
2968
|
+
children: x.message
|
|
2907
2969
|
})]
|
|
2908
2970
|
});
|
|
2909
|
-
if (
|
|
2971
|
+
if (v) return /* @__PURE__ */ $("div", {
|
|
2910
2972
|
className: "p-4 sm:p-8 text-center",
|
|
2911
2973
|
children: [/* @__PURE__ */ Q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Q("p", {
|
|
2912
2974
|
className: "mt-2 text-sm text-gray-600",
|
|
2913
2975
|
children: "Loading form..."
|
|
2914
2976
|
})]
|
|
2915
2977
|
});
|
|
2916
|
-
if (
|
|
2978
|
+
if (w) return /* @__PURE__ */ $("div", {
|
|
2917
2979
|
className: "rounded-md border bg-card p-6 sm:p-8 text-center",
|
|
2918
2980
|
children: [/* @__PURE__ */ Q("h3", {
|
|
2919
2981
|
className: "text-lg font-semibold",
|
|
2920
|
-
children:
|
|
2921
|
-
}),
|
|
2982
|
+
children: w.title ?? "Thanks!"
|
|
2983
|
+
}), w.message && /* @__PURE__ */ Q("p", {
|
|
2922
2984
|
className: "mt-2 text-sm text-muted-foreground",
|
|
2923
|
-
children:
|
|
2985
|
+
children: w.message
|
|
2924
2986
|
})]
|
|
2925
2987
|
});
|
|
2926
|
-
let
|
|
2927
|
-
if (
|
|
2928
|
-
let t =
|
|
2929
|
-
|
|
2988
|
+
let H = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical";
|
|
2989
|
+
if (z?.length && (!e.formType || e.formType === "simple")) {
|
|
2990
|
+
let t = R ? L : p, n = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, r = z.map((e) => n(e.columns)).filter((e) => e != null), i = z.reduce((e, t) => e + (Array.isArray(t.fields) ? t.fields.length : 0), 0), a = n(e.columns) ?? (r.length ? Math.max(...r) : He(i)), s = [];
|
|
2991
|
+
z.forEach((r, i) => {
|
|
2930
2992
|
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
2993
|
let t = c.get(e.name);
|
|
2932
2994
|
if (!t || typeof t != "object") return e;
|
|
@@ -2934,7 +2996,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2934
2996
|
return n.visibleOn != null && (r.visibleOn = n.visibleOn), n.colSpan != null && (r.colSpan = n.colSpan), n.span != null && (r.span = n.span), r;
|
|
2935
2997
|
});
|
|
2936
2998
|
if (d.length === 0) return;
|
|
2937
|
-
let f = r.name || r.label || String(i), p = r.name ? o(e.objectName, r.name, r.label || r.name) : r.label, m =
|
|
2999
|
+
let f = r.name || r.label || String(i), p = r.name ? o(e.objectName, r.name, r.label || r.name) : r.label, m = B[f] ?? r.collapsed ?? !1;
|
|
2938
3000
|
p && s.push({
|
|
2939
3001
|
name: `__section_${f}`,
|
|
2940
3002
|
label: p,
|
|
@@ -2942,29 +3004,30 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2942
3004
|
colSpan: 4,
|
|
2943
3005
|
collapsible: r.collapsible,
|
|
2944
3006
|
collapsed: m,
|
|
2945
|
-
onToggle: r.collapsible ? () =>
|
|
3007
|
+
onToggle: r.collapsible ? () => V((e) => ({
|
|
2946
3008
|
...e,
|
|
2947
3009
|
[f]: !m
|
|
2948
3010
|
})) : void 0,
|
|
2949
3011
|
className: r.className
|
|
2950
3012
|
});
|
|
2951
|
-
let h = n(r.columns), g = a > 1 ?
|
|
3013
|
+
let h = n(r.columns), g = a > 1 ? Ge(d, a, h) : d;
|
|
2952
3014
|
p && m ? s.push(...g.map((e) => ({
|
|
2953
3015
|
...e,
|
|
2954
3016
|
hidden: !0
|
|
2955
3017
|
}))) : s.push(...g);
|
|
2956
3018
|
});
|
|
2957
|
-
let c = s, l =
|
|
3019
|
+
let c = s, l = Ze(a);
|
|
2958
3020
|
return /* @__PURE__ */ $("div", {
|
|
2959
3021
|
className: "w-full @container",
|
|
2960
|
-
children: [/* @__PURE__ */ Q(
|
|
3022
|
+
children: [/* @__PURE__ */ Q(y, { schema: {
|
|
2961
3023
|
type: "form",
|
|
2962
3024
|
objectName: e.objectName,
|
|
2963
3025
|
fields: c,
|
|
2964
|
-
layout:
|
|
3026
|
+
layout: H,
|
|
2965
3027
|
columns: a,
|
|
2966
3028
|
...l ? { fieldContainerClass: l } : {},
|
|
2967
|
-
defaultValues:
|
|
3029
|
+
defaultValues: ee,
|
|
3030
|
+
previousValues: I,
|
|
2968
3031
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
2969
3032
|
showCancel: e.showCancel !== !1,
|
|
2970
3033
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
@@ -2974,27 +3037,33 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2974
3037
|
} }), A]
|
|
2975
3038
|
});
|
|
2976
3039
|
}
|
|
2977
|
-
let
|
|
2978
|
-
fields:
|
|
3040
|
+
let U = e.sections?.length, W = u(p), G = U ? {
|
|
3041
|
+
fields: W,
|
|
2979
3042
|
columns: e.columns
|
|
2980
|
-
} :
|
|
3043
|
+
} : $e(W, d, e.columns, e.mode), K = e.mobile, te = K?.fullscreenLongText ? G.fields.map((e) => {
|
|
2981
3044
|
let t = e.type;
|
|
2982
|
-
return t
|
|
3045
|
+
return t !== "textarea" && t !== "field:textarea" && t !== "field:markdown" && t !== "field:html" ? e : e.field ? {
|
|
3046
|
+
...e,
|
|
3047
|
+
field: {
|
|
3048
|
+
...e.field,
|
|
3049
|
+
mobile_fullscreen: !0
|
|
3050
|
+
}
|
|
3051
|
+
} : {
|
|
2983
3052
|
...e,
|
|
2984
3053
|
mobile_fullscreen: !0
|
|
2985
|
-
}
|
|
2986
|
-
}) :
|
|
2987
|
-
if (!e.formType && !
|
|
2988
|
-
let t =
|
|
2989
|
-
for (let e = 0; e < t.length; e +=
|
|
2990
|
-
let r = t.slice(e, e +
|
|
3054
|
+
};
|
|
3055
|
+
}) : G.fields, ne = K?.stepper, re = K?.stepperMinFields ?? 8, q = Math.max(1, K?.stepperFieldsPerStep ?? 1);
|
|
3056
|
+
if (!e.formType && !U && te.length >= 2 && (ne === !0 || ne === "auto" && s && te.length >= re)) {
|
|
3057
|
+
let t = te, n = [];
|
|
3058
|
+
for (let e = 0; e < t.length; e += q) {
|
|
3059
|
+
let r = t.slice(e, e + q);
|
|
2991
3060
|
n.push({
|
|
2992
|
-
name: `step-${Math.floor(e /
|
|
2993
|
-
label: r[0]?.label || r[0]?.name || `Step ${Math.floor(e /
|
|
3061
|
+
name: `step-${Math.floor(e / q) + 1}`,
|
|
3062
|
+
label: r[0]?.label || r[0]?.name || `Step ${Math.floor(e / q) + 1}`,
|
|
2994
3063
|
fields: r
|
|
2995
3064
|
});
|
|
2996
3065
|
}
|
|
2997
|
-
return /* @__PURE__ */ Q(
|
|
3066
|
+
return /* @__PURE__ */ Q(lt, {
|
|
2998
3067
|
schema: {
|
|
2999
3068
|
...e,
|
|
3000
3069
|
formType: "wizard",
|
|
@@ -3005,29 +3074,30 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
3005
3074
|
className: e.className
|
|
3006
3075
|
});
|
|
3007
3076
|
}
|
|
3008
|
-
let
|
|
3077
|
+
let J = {
|
|
3009
3078
|
type: "form",
|
|
3010
3079
|
objectName: e.objectName,
|
|
3011
|
-
fields:
|
|
3012
|
-
layout:
|
|
3013
|
-
columns:
|
|
3080
|
+
fields: te,
|
|
3081
|
+
layout: H,
|
|
3082
|
+
columns: G.columns,
|
|
3014
3083
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
3015
3084
|
cancelLabel: e.cancelText,
|
|
3016
3085
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
3017
3086
|
showCancel: e.showCancel !== !1,
|
|
3018
3087
|
resetOnSubmit: e.showReset || e.submitBehavior?.kind === "continue" || !e.submitBehavior && e.resetOnSuccess && e.mode === "create",
|
|
3019
|
-
defaultValues:
|
|
3088
|
+
defaultValues: ee,
|
|
3089
|
+
previousValues: I,
|
|
3020
3090
|
onSubmit: N,
|
|
3021
3091
|
onCancel: P,
|
|
3022
3092
|
className: e.className,
|
|
3023
|
-
mobileStickyActions: !!
|
|
3093
|
+
mobileStickyActions: !!K?.stickyActions
|
|
3024
3094
|
};
|
|
3025
3095
|
return /* @__PURE__ */ $("div", {
|
|
3026
|
-
className:
|
|
3027
|
-
"data-mobile-form":
|
|
3028
|
-
children: [/* @__PURE__ */ Q(
|
|
3096
|
+
className: K?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
|
|
3097
|
+
"data-mobile-form": K ? "true" : void 0,
|
|
3098
|
+
children: [/* @__PURE__ */ Q(y, { schema: J }), A]
|
|
3029
3099
|
});
|
|
3030
|
-
},
|
|
3100
|
+
}, rn = {
|
|
3031
3101
|
text: 200,
|
|
3032
3102
|
email: 254,
|
|
3033
3103
|
url: 2048,
|
|
@@ -3035,8 +3105,8 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
3035
3105
|
textarea: 5e3,
|
|
3036
3106
|
markdown: 5e3,
|
|
3037
3107
|
html: 5e3
|
|
3038
|
-
},
|
|
3039
|
-
function
|
|
3108
|
+
}, an = "_company_website_2", on = 1500;
|
|
3109
|
+
function sn(e, t = []) {
|
|
3040
3110
|
try {
|
|
3041
3111
|
let n = new URL(e, typeof window < "u" ? window.location.href : "http://localhost");
|
|
3042
3112
|
return typeof window < "u" && n.origin === window.location.origin ? !0 : n.protocol !== "https:" && n.protocol !== "http:" ? !1 : t.some((e) => {
|
|
@@ -3051,21 +3121,21 @@ function qt(e, t = []) {
|
|
|
3051
3121
|
return !1;
|
|
3052
3122
|
}
|
|
3053
3123
|
}
|
|
3054
|
-
function
|
|
3124
|
+
function cn(e) {
|
|
3055
3125
|
return e && e.map((e) => {
|
|
3056
|
-
let t =
|
|
3126
|
+
let t = rn[String(e.type || "").toLowerCase()];
|
|
3057
3127
|
return !t || (e.maxLength ?? e.max_length) ? e : {
|
|
3058
3128
|
...e,
|
|
3059
3129
|
maxLength: t
|
|
3060
3130
|
};
|
|
3061
3131
|
});
|
|
3062
3132
|
}
|
|
3063
|
-
var
|
|
3133
|
+
var ln = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
3064
3134
|
let [l, u] = c(!1), [d, f] = c(!1), [p, m] = c(null), [h, g] = c(!(e.consent?.required ?? !!e.consent)), [_, v] = c(null), y = s(null), b = s(0);
|
|
3065
3135
|
i(() => {
|
|
3066
3136
|
l || (b.current = Date.now());
|
|
3067
3137
|
}, [l]);
|
|
3068
|
-
let x = e.honeypot === !1 ? null : e.honeypot ||
|
|
3138
|
+
let x = e.honeypot === !1 ? null : e.honeypot || an, S = e.minFillTime ?? on, C = o(() => cn(e.customFields), [e.customFields]), w = o(() => {
|
|
3069
3139
|
if (!t || C && C.length > 0 || !e.fields || e.fields.length === 0) return;
|
|
3070
3140
|
let n = async (e, t) => t;
|
|
3071
3141
|
return {
|
|
@@ -3106,12 +3176,14 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3106
3176
|
try {
|
|
3107
3177
|
t && await t.create(e.objectName, r), u(!0);
|
|
3108
3178
|
let n = e.thankYouPage?.redirectUrl;
|
|
3109
|
-
if (n)
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3179
|
+
if (n) {
|
|
3180
|
+
if (sn(n, e.allowedRedirectHosts)) {
|
|
3181
|
+
let t = e.thankYouPage?.redirectDelay ?? 3e3;
|
|
3182
|
+
setTimeout(() => {
|
|
3183
|
+
window.location.href = n;
|
|
3184
|
+
}, t);
|
|
3185
|
+
} else console.warn("[EmbeddableForm] Blocked unsafe redirect target:", n), m(e.texts?.redirectBlocked ?? null);
|
|
3186
|
+
}
|
|
3115
3187
|
} catch (e) {
|
|
3116
3188
|
m(e instanceof Error ? e.message : "Failed to submit form. Please try again.");
|
|
3117
3189
|
} finally {
|
|
@@ -3139,7 +3211,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3139
3211
|
children: [
|
|
3140
3212
|
/* @__PURE__ */ Q("div", {
|
|
3141
3213
|
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__ */ Q(
|
|
3214
|
+
children: /* @__PURE__ */ Q(fe, {
|
|
3143
3215
|
className: "h-8 w-8",
|
|
3144
3216
|
"aria-hidden": "true"
|
|
3145
3217
|
})
|
|
@@ -3152,7 +3224,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3152
3224
|
className: "text-sm text-muted-foreground",
|
|
3153
3225
|
children: t?.message || n.thankYouMessage || "Your submission has been received successfully."
|
|
3154
3226
|
}),
|
|
3155
|
-
e.allowMultiple && /* @__PURE__ */ Q(
|
|
3227
|
+
e.allowMultiple && /* @__PURE__ */ Q(I, {
|
|
3156
3228
|
variant: "outline",
|
|
3157
3229
|
size: "sm",
|
|
3158
3230
|
onClick: D,
|
|
@@ -3212,7 +3284,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3212
3284
|
className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
|
|
3213
3285
|
children: p
|
|
3214
3286
|
}),
|
|
3215
|
-
/* @__PURE__ */ Q(
|
|
3287
|
+
/* @__PURE__ */ Q(tn, {
|
|
3216
3288
|
schema: {
|
|
3217
3289
|
type: "object-form",
|
|
3218
3290
|
objectName: e.objectName,
|
|
@@ -3265,7 +3337,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3265
3337
|
className: "text-destructive ml-0.5",
|
|
3266
3338
|
children: "*"
|
|
3267
3339
|
}),
|
|
3268
|
-
e.consent.privacyUrl && /* @__PURE__ */ $(
|
|
3340
|
+
e.consent.privacyUrl && /* @__PURE__ */ $(be, { children: [" ", /* @__PURE__ */ Q("a", {
|
|
3269
3341
|
href: e.consent.privacyUrl,
|
|
3270
3342
|
target: "_blank",
|
|
3271
3343
|
rel: "noopener noreferrer",
|
|
@@ -3283,7 +3355,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3283
3355
|
}),
|
|
3284
3356
|
d && /* @__PURE__ */ $("div", {
|
|
3285
3357
|
className: "mt-3 flex items-center gap-2 text-xs text-muted-foreground",
|
|
3286
|
-
children: [/* @__PURE__ */ Q(
|
|
3358
|
+
children: [/* @__PURE__ */ Q(ge, {
|
|
3287
3359
|
className: "h-3.5 w-3.5 animate-spin",
|
|
3288
3360
|
"aria-hidden": "true"
|
|
3289
3361
|
}), /* @__PURE__ */ Q("span", { children: k.submitting ?? "Submitting…" })]
|
|
@@ -3294,7 +3366,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3294
3366
|
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
3367
|
children: [/* @__PURE__ */ $("p", {
|
|
3296
3368
|
className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground",
|
|
3297
|
-
children: [/* @__PURE__ */ Q(
|
|
3369
|
+
children: [/* @__PURE__ */ Q(_e, {
|
|
3298
3370
|
className: "h-3 w-3",
|
|
3299
3371
|
"aria-hidden": "true"
|
|
3300
3372
|
}), /* @__PURE__ */ Q("span", { children: k.secureNotice ?? "Your information is transmitted securely and only used to respond to your request." })]
|
|
@@ -3305,7 +3377,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3305
3377
|
target: "_blank",
|
|
3306
3378
|
rel: "noopener noreferrer",
|
|
3307
3379
|
className: "inline-flex items-center gap-1 underline hover:text-foreground",
|
|
3308
|
-
children: [/* @__PURE__ */ Q(
|
|
3380
|
+
children: [/* @__PURE__ */ Q(ve, {
|
|
3309
3381
|
className: "h-3 w-3",
|
|
3310
3382
|
"aria-hidden": "true"
|
|
3311
3383
|
}), k.consentLink ?? "Privacy policy"]
|
|
@@ -3318,10 +3390,10 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3318
3390
|
};
|
|
3319
3391
|
//#endregion
|
|
3320
3392
|
//#region src/FormAnalytics.tsx
|
|
3321
|
-
function
|
|
3393
|
+
function un(e) {
|
|
3322
3394
|
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
3395
|
}
|
|
3324
|
-
var
|
|
3396
|
+
var dn = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
3325
3397
|
let i = o(() => {
|
|
3326
3398
|
if (!n.abandonedSubmissions) return 100;
|
|
3327
3399
|
let e = n.totalSubmissions + n.abandonedSubmissions;
|
|
@@ -3340,39 +3412,39 @@ var Zt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3340
3412
|
/* @__PURE__ */ $("div", {
|
|
3341
3413
|
className: "grid grid-cols-1 sm:grid-cols-3 gap-4",
|
|
3342
3414
|
children: [
|
|
3343
|
-
/* @__PURE__ */ Q(
|
|
3415
|
+
/* @__PURE__ */ Q(L, { children: /* @__PURE__ */ $(B, {
|
|
3344
3416
|
className: "pb-2",
|
|
3345
|
-
children: [/* @__PURE__ */ Q(
|
|
3417
|
+
children: [/* @__PURE__ */ Q(z, { children: "Total Submissions" }), /* @__PURE__ */ Q(V, {
|
|
3346
3418
|
className: "text-2xl",
|
|
3347
3419
|
children: n.totalSubmissions.toLocaleString()
|
|
3348
3420
|
})]
|
|
3349
3421
|
}) }),
|
|
3350
|
-
/* @__PURE__ */ $(
|
|
3422
|
+
/* @__PURE__ */ $(L, { children: [/* @__PURE__ */ $(B, {
|
|
3351
3423
|
className: "pb-2",
|
|
3352
|
-
children: [/* @__PURE__ */ Q(
|
|
3424
|
+
children: [/* @__PURE__ */ Q(z, { children: "Fill Rate" }), /* @__PURE__ */ $(V, {
|
|
3353
3425
|
className: "text-2xl",
|
|
3354
3426
|
children: [i, "%"]
|
|
3355
3427
|
})]
|
|
3356
|
-
}), /* @__PURE__ */ Q(
|
|
3428
|
+
}), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q("div", {
|
|
3357
3429
|
className: "w-full bg-muted rounded-full h-2",
|
|
3358
3430
|
children: /* @__PURE__ */ Q("div", {
|
|
3359
3431
|
className: "bg-primary rounded-full h-2 transition-all",
|
|
3360
3432
|
style: { width: `${i}%` }
|
|
3361
3433
|
})
|
|
3362
3434
|
}) })] }),
|
|
3363
|
-
/* @__PURE__ */ Q(
|
|
3435
|
+
/* @__PURE__ */ Q(L, { children: /* @__PURE__ */ $(B, {
|
|
3364
3436
|
className: "pb-2",
|
|
3365
|
-
children: [/* @__PURE__ */ Q(
|
|
3437
|
+
children: [/* @__PURE__ */ Q(z, { children: "Avg. Completion Time" }), /* @__PURE__ */ Q(V, {
|
|
3366
3438
|
className: "text-2xl",
|
|
3367
|
-
children: n.avgCompletionTime ?
|
|
3439
|
+
children: n.avgCompletionTime ? un(n.avgCompletionTime) : "—"
|
|
3368
3440
|
})]
|
|
3369
3441
|
}) })
|
|
3370
3442
|
]
|
|
3371
3443
|
}),
|
|
3372
|
-
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ $(
|
|
3444
|
+
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ $(L, { children: [/* @__PURE__ */ Q(B, { children: /* @__PURE__ */ Q(V, {
|
|
3373
3445
|
className: "text-sm font-medium",
|
|
3374
3446
|
children: "Daily Submissions"
|
|
3375
|
-
}) }), /* @__PURE__ */ Q(
|
|
3447
|
+
}) }), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q("div", {
|
|
3376
3448
|
className: "flex items-end gap-1 h-32",
|
|
3377
3449
|
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ $("div", {
|
|
3378
3450
|
className: "flex-1 flex flex-col items-center gap-1",
|
|
@@ -3389,10 +3461,10 @@ var Zt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3389
3461
|
})]
|
|
3390
3462
|
}, t))
|
|
3391
3463
|
}) })] }),
|
|
3392
|
-
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ $(
|
|
3464
|
+
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ $(L, { children: [/* @__PURE__ */ $(B, { children: [/* @__PURE__ */ Q(V, {
|
|
3393
3465
|
className: "text-sm font-medium",
|
|
3394
3466
|
children: "Field Completion Rates"
|
|
3395
|
-
}), /* @__PURE__ */ Q(
|
|
3467
|
+
}), /* @__PURE__ */ Q(z, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q("div", {
|
|
3396
3468
|
className: "space-y-3",
|
|
3397
3469
|
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ $("div", {
|
|
3398
3470
|
className: "space-y-1",
|
|
@@ -3416,76 +3488,80 @@ var Zt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3416
3488
|
}) })] })
|
|
3417
3489
|
]
|
|
3418
3490
|
});
|
|
3419
|
-
},
|
|
3420
|
-
let t =
|
|
3491
|
+
}, fn = ({ schema: e }) => {
|
|
3492
|
+
let t = w()?.dataSource, r = S(), a = e.parentObject || r?.objectName, s = e.parentId || e.recordId || r?.recordId, [l, d] = c([]), [f, m] = c([]), [h, v] = c(!0), [y, b] = c(!1), [x, C] = c(!1), [E, D] = c(null), [O, k] = c(null);
|
|
3421
3493
|
i(() => {
|
|
3422
3494
|
let n = t;
|
|
3423
3495
|
if (!n || typeof n.getObjectSchema != "function") return;
|
|
3424
3496
|
let r = !1;
|
|
3425
3497
|
return n.getObjectSchema(e.childObject).then((e) => {
|
|
3426
|
-
r ||
|
|
3498
|
+
r || k(e ?? null);
|
|
3427
3499
|
}).catch(() => {
|
|
3428
|
-
r ||
|
|
3500
|
+
r || k(null);
|
|
3429
3501
|
}), () => {
|
|
3430
3502
|
r = !0;
|
|
3431
3503
|
};
|
|
3432
3504
|
}, [t, e.childObject]);
|
|
3433
|
-
let
|
|
3505
|
+
let A = JSON.stringify(e.filter ?? null), j = JSON.stringify(e.sort ?? null), M = o(() => _(e.filter), [A]), N = o(() => u(e.sort), [j]), P = n(async () => {
|
|
3434
3506
|
if (!t || !s) {
|
|
3435
|
-
|
|
3507
|
+
v(!1);
|
|
3436
3508
|
return;
|
|
3437
3509
|
}
|
|
3438
|
-
|
|
3510
|
+
v(!0);
|
|
3439
3511
|
try {
|
|
3440
|
-
let n = (await t.find(e.childObject, {
|
|
3441
|
-
$filter:
|
|
3442
|
-
$
|
|
3512
|
+
let n = { [e.relationshipField]: s }, r = (await t.find(e.childObject, {
|
|
3513
|
+
$filter: M === void 0 ? n : p(n, M),
|
|
3514
|
+
...N ? { $orderby: N } : {},
|
|
3515
|
+
$top: e.limit ?? 500
|
|
3443
3516
|
}))?.data ?? [];
|
|
3444
|
-
|
|
3517
|
+
d(r.map((e) => ({ ...e }))), m(r.map((e) => ({ ...e }))), C(!1);
|
|
3445
3518
|
} catch (e) {
|
|
3446
|
-
|
|
3519
|
+
D(e?.message || "Failed to load line items");
|
|
3447
3520
|
} finally {
|
|
3448
|
-
|
|
3521
|
+
v(!1);
|
|
3449
3522
|
}
|
|
3450
3523
|
}, [
|
|
3451
3524
|
t,
|
|
3452
3525
|
s,
|
|
3453
3526
|
e.childObject,
|
|
3454
|
-
e.relationshipField
|
|
3527
|
+
e.relationshipField,
|
|
3528
|
+
e.limit,
|
|
3529
|
+
M,
|
|
3530
|
+
N
|
|
3455
3531
|
]);
|
|
3456
3532
|
i(() => {
|
|
3457
|
-
|
|
3458
|
-
}, [
|
|
3459
|
-
let
|
|
3460
|
-
|
|
3461
|
-
}, []),
|
|
3533
|
+
P();
|
|
3534
|
+
}, [P]);
|
|
3535
|
+
let F = n((e) => {
|
|
3536
|
+
d(e), C(!0);
|
|
3537
|
+
}, []), ee = n(async () => {
|
|
3462
3538
|
if (!(!t || !s)) {
|
|
3463
|
-
|
|
3539
|
+
b(!0), D(null);
|
|
3464
3540
|
try {
|
|
3465
|
-
let n = !!(a && e.totalField), r = n ? { [e.totalField]:
|
|
3541
|
+
let n = !!(a && e.totalField), r = n ? { [e.totalField]: xt(l, e.amountField || "amount") } : {}, i = yt(a ?? "", s, r, [{
|
|
3466
3542
|
childObject: e.childObject,
|
|
3467
3543
|
relationshipField: e.relationshipField,
|
|
3468
3544
|
rows: l,
|
|
3469
|
-
original:
|
|
3470
|
-
childSchema:
|
|
3545
|
+
original: f,
|
|
3546
|
+
childSchema: O
|
|
3471
3547
|
}]);
|
|
3472
|
-
n || (i = i.slice(1)), i.length && await
|
|
3548
|
+
n || (i = i.slice(1)), i.length && await g(t, i), await P();
|
|
3473
3549
|
} catch (e) {
|
|
3474
|
-
|
|
3550
|
+
D(e?.message || "Failed to save line items");
|
|
3475
3551
|
} finally {
|
|
3476
|
-
|
|
3552
|
+
b(!1);
|
|
3477
3553
|
}
|
|
3478
3554
|
}
|
|
3479
3555
|
}, [
|
|
3480
3556
|
t,
|
|
3481
3557
|
s,
|
|
3482
3558
|
l,
|
|
3483
|
-
|
|
3559
|
+
f,
|
|
3484
3560
|
e,
|
|
3485
3561
|
a,
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
]),
|
|
3562
|
+
P,
|
|
3563
|
+
O
|
|
3564
|
+
]), z = o(() => ({
|
|
3489
3565
|
columns: e.columns,
|
|
3490
3566
|
total_field: e.totalField ? e.amountField || "amount" : void 0,
|
|
3491
3567
|
min_rows: e.minRows,
|
|
@@ -3493,41 +3569,50 @@ var Zt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3493
3569
|
allow_add: !e.readonly,
|
|
3494
3570
|
allow_delete: !e.readonly
|
|
3495
3571
|
}), [e]);
|
|
3496
|
-
return /* @__PURE__ */ $(
|
|
3497
|
-
className:
|
|
3498
|
-
children: [/* @__PURE__ */ $(
|
|
3572
|
+
return /* @__PURE__ */ $(L, {
|
|
3573
|
+
className: Y("shadow-none"),
|
|
3574
|
+
children: [/* @__PURE__ */ $(B, {
|
|
3499
3575
|
className: "flex-row items-center justify-between gap-2 pb-2",
|
|
3500
|
-
children: [/* @__PURE__ */ Q(
|
|
3576
|
+
children: [/* @__PURE__ */ Q(V, {
|
|
3501
3577
|
className: "text-sm font-medium",
|
|
3502
3578
|
children: e.title || "Line Items"
|
|
3503
|
-
}), !e.readonly && /* @__PURE__ */ Q(
|
|
3579
|
+
}), !e.readonly && /* @__PURE__ */ Q(I, {
|
|
3504
3580
|
type: "button",
|
|
3505
3581
|
size: "sm",
|
|
3506
|
-
onClick:
|
|
3507
|
-
disabled:
|
|
3508
|
-
children:
|
|
3582
|
+
onClick: ee,
|
|
3583
|
+
disabled: y || h || !x || !s,
|
|
3584
|
+
children: y ? "Saving…" : "Save"
|
|
3509
3585
|
})]
|
|
3510
|
-
}), /* @__PURE__ */ $(
|
|
3586
|
+
}), /* @__PURE__ */ $(R, { children: [E && /* @__PURE__ */ Q("p", {
|
|
3511
3587
|
className: "mb-2 text-sm text-destructive",
|
|
3512
|
-
children:
|
|
3513
|
-
}),
|
|
3588
|
+
children: E
|
|
3589
|
+
}), h ? /* @__PURE__ */ Q("p", {
|
|
3514
3590
|
className: "py-6 text-center text-sm text-muted-foreground",
|
|
3515
3591
|
children: "Loading…"
|
|
3516
|
-
}) : s ? /* @__PURE__ */ Q(
|
|
3592
|
+
}) : s ? /* @__PURE__ */ Q(T, {
|
|
3517
3593
|
value: l,
|
|
3518
|
-
onChange:
|
|
3519
|
-
field:
|
|
3594
|
+
onChange: F,
|
|
3595
|
+
field: z,
|
|
3520
3596
|
readonly: e.readonly
|
|
3521
3597
|
}) : /* @__PURE__ */ Q("p", {
|
|
3522
3598
|
className: "py-6 text-center text-sm text-muted-foreground",
|
|
3523
3599
|
children: "Save the record first to add line items."
|
|
3524
3600
|
})] })]
|
|
3525
3601
|
});
|
|
3526
|
-
},
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3602
|
+
}, pn = ({ schema: e }) => {
|
|
3603
|
+
let t = r(b)?.dataSource ?? void 0;
|
|
3604
|
+
return /* @__PURE__ */ Q(v, {
|
|
3605
|
+
schema: e,
|
|
3606
|
+
dataSource: t,
|
|
3607
|
+
testId: "object-form",
|
|
3608
|
+
errorTitle: "This form’s data source could not be resolved",
|
|
3609
|
+
children: (e) => /* @__PURE__ */ Q(tn, {
|
|
3610
|
+
schema: e,
|
|
3611
|
+
dataSource: t
|
|
3612
|
+
})
|
|
3613
|
+
});
|
|
3614
|
+
};
|
|
3615
|
+
l.register("object-form", pn, {
|
|
3531
3616
|
namespace: "plugin-form",
|
|
3532
3617
|
label: "Object Form",
|
|
3533
3618
|
category: "plugin",
|
|
@@ -3668,7 +3753,7 @@ l.register("object-form", $t, {
|
|
|
3668
3753
|
]
|
|
3669
3754
|
}
|
|
3670
3755
|
]
|
|
3671
|
-
}), l.register("form",
|
|
3756
|
+
}), l.register("form", pn, {
|
|
3672
3757
|
namespace: "view",
|
|
3673
3758
|
skipFallback: !0,
|
|
3674
3759
|
label: "Data Form View",
|
|
@@ -3696,10 +3781,19 @@ l.register("object-form", $t, {
|
|
|
3696
3781
|
]
|
|
3697
3782
|
}
|
|
3698
3783
|
]
|
|
3699
|
-
}), l.register("embeddable-form", ({ schema: e }) =>
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3784
|
+
}), l.register("embeddable-form", ({ schema: e }) => {
|
|
3785
|
+
let t = r(b);
|
|
3786
|
+
return /* @__PURE__ */ Q(v, {
|
|
3787
|
+
schema: e,
|
|
3788
|
+
dataSource: t?.dataSource,
|
|
3789
|
+
testId: "embeddable-form",
|
|
3790
|
+
errorTitle: "This form’s data source could not be resolved",
|
|
3791
|
+
children: (e) => /* @__PURE__ */ Q(ln, {
|
|
3792
|
+
config: e,
|
|
3793
|
+
dataSource: t?.dataSource
|
|
3794
|
+
})
|
|
3795
|
+
});
|
|
3796
|
+
}, {
|
|
3703
3797
|
namespace: "plugin-form",
|
|
3704
3798
|
label: "Embeddable Form",
|
|
3705
3799
|
category: "plugin",
|
|
@@ -3737,7 +3831,7 @@ l.register("object-form", $t, {
|
|
|
3737
3831
|
label: "Allow Multiple Submissions"
|
|
3738
3832
|
}
|
|
3739
3833
|
]
|
|
3740
|
-
}), l.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ Q(
|
|
3834
|
+
}), l.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ Q(dn, {
|
|
3741
3835
|
formId: e.formId,
|
|
3742
3836
|
formTitle: e.formTitle,
|
|
3743
3837
|
metrics: e.metrics || { totalSubmissions: 0 }
|
|
@@ -3763,10 +3857,19 @@ l.register("object-form", $t, {
|
|
|
3763
3857
|
label: "Submission Metrics"
|
|
3764
3858
|
}
|
|
3765
3859
|
]
|
|
3766
|
-
}), l.register("object-master-detail-form", ({ schema: e }) =>
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3860
|
+
}), l.register("object-master-detail-form", ({ schema: e }) => {
|
|
3861
|
+
let t = r(b)?.dataSource ?? void 0;
|
|
3862
|
+
return /* @__PURE__ */ Q(v, {
|
|
3863
|
+
schema: e,
|
|
3864
|
+
dataSource: t,
|
|
3865
|
+
testId: "object-master-detail-form",
|
|
3866
|
+
errorTitle: "This form’s data source could not be resolved",
|
|
3867
|
+
children: (e) => /* @__PURE__ */ Q(Kt, {
|
|
3868
|
+
schema: e,
|
|
3869
|
+
dataSource: t
|
|
3870
|
+
})
|
|
3871
|
+
});
|
|
3872
|
+
}, {
|
|
3770
3873
|
namespace: "plugin-form",
|
|
3771
3874
|
label: "Master-Detail Form",
|
|
3772
3875
|
category: "plugin",
|
|
@@ -3795,7 +3898,20 @@ l.register("object-form", $t, {
|
|
|
3795
3898
|
required: !0
|
|
3796
3899
|
}
|
|
3797
3900
|
]
|
|
3798
|
-
})
|
|
3901
|
+
});
|
|
3902
|
+
var mn = {
|
|
3903
|
+
object: "childObject",
|
|
3904
|
+
filter: !0,
|
|
3905
|
+
sort: !0,
|
|
3906
|
+
limit: "limit"
|
|
3907
|
+
};
|
|
3908
|
+
l.register("line_items", ({ schema: e }) => /* @__PURE__ */ Q(v, {
|
|
3909
|
+
schema: e,
|
|
3910
|
+
mapping: mn,
|
|
3911
|
+
testId: "record-line-items",
|
|
3912
|
+
errorTitle: "This line-items panel’s data source could not be resolved",
|
|
3913
|
+
children: (e) => /* @__PURE__ */ Q(fn, { schema: e })
|
|
3914
|
+
}), {
|
|
3799
3915
|
namespace: "record",
|
|
3800
3916
|
skipFallback: !0,
|
|
3801
3917
|
label: "Line Items",
|
|
@@ -3832,4 +3948,4 @@ l.register("object-form", $t, {
|
|
|
3832
3948
|
]
|
|
3833
3949
|
});
|
|
3834
3950
|
//#endregion
|
|
3835
|
-
export {
|
|
3951
|
+
export { Yt as DrawerForm, ln as EmbeddableForm, dn as FormAnalytics, ot as FormSectionContainer, fn as LineItemsPanel, Kt as MasterDetailForm, $t as ModalForm, tn as ObjectForm, ut as SplitForm, at as TabbedForm, lt as WizardForm, Ge as applyAutoColSpan, $e as applyAutoLayout, Ze as containerGridColsFor, Pt as deriveColumns, Ut as deriveDetail, Lt as deriveFormFields, Ye as filterAutoGeneratedFields, Je as filterCreateModeFields, qe as filterSystemFields, kt as findRelationshipField, He as inferColumns, Qe as inferModalSize, Ve as isAutoGeneratedFieldType, Be as isWideFieldType, Bt as resolveInlineMode };
|