@object-ui/plugin-form 17.3.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 +505 -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 +815 -724
- 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 +13 -13
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
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,
|
|
@@ -413,7 +461,7 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
413
461
|
cancelLabel: e.cancelText,
|
|
414
462
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
415
463
|
showCancel: e.showCancel !== !1,
|
|
416
|
-
onSubmit:
|
|
464
|
+
onSubmit: S,
|
|
417
465
|
onCancel: w,
|
|
418
466
|
fieldTabs: A.map((e) => ({
|
|
419
467
|
key: e.key,
|
|
@@ -422,11 +470,11 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
422
470
|
fields: e.fields.map((e) => e.name),
|
|
423
471
|
containerClass: e.containerClass
|
|
424
472
|
})),
|
|
425
|
-
defaultFieldTab:
|
|
473
|
+
defaultFieldTab: v,
|
|
426
474
|
fieldTabsPosition: e.tabPosition || "top"
|
|
427
475
|
} }), p]
|
|
428
476
|
});
|
|
429
|
-
},
|
|
477
|
+
}, ot = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: a, className: o, gridClassName: s, showBorder: l }) => {
|
|
430
478
|
let [u, d] = c(r), f = {
|
|
431
479
|
1: "grid-cols-1",
|
|
432
480
|
2: "grid-cols-1 md:grid-cols-2",
|
|
@@ -435,13 +483,13 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
435
483
|
}, p = () => {
|
|
436
484
|
n && d(!u);
|
|
437
485
|
}, m = l ?? !!e, h = e || t ? /* @__PURE__ */ $("div", {
|
|
438
|
-
className:
|
|
486
|
+
className: Y("flex items-start gap-2", !m && "mb-4", n && "cursor-pointer select-none"),
|
|
439
487
|
onClick: p,
|
|
440
488
|
role: n ? "button" : void 0,
|
|
441
489
|
"aria-expanded": n ? !u : void 0,
|
|
442
490
|
children: [n && /* @__PURE__ */ Q("span", {
|
|
443
491
|
className: "mt-0.5 text-muted-foreground",
|
|
444
|
-
children: Q(u ?
|
|
492
|
+
children: Q(u ? he : pe, { className: "h-4 w-4" })
|
|
445
493
|
}), /* @__PURE__ */ $("div", {
|
|
446
494
|
className: "flex-1",
|
|
447
495
|
children: [e && /* @__PURE__ */ Q("h3", {
|
|
@@ -453,33 +501,33 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
453
501
|
})]
|
|
454
502
|
})]
|
|
455
503
|
}) : null, g = u ? null : /* @__PURE__ */ Q("div", {
|
|
456
|
-
className:
|
|
504
|
+
className: Y("grid gap-4", s || f[i]),
|
|
457
505
|
children: a
|
|
458
506
|
});
|
|
459
|
-
return m ? /* @__PURE__ */ $(
|
|
460
|
-
className:
|
|
461
|
-
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, {
|
|
462
510
|
className: "border-b border-border pb-3",
|
|
463
511
|
children: h
|
|
464
|
-
}), g && /* @__PURE__ */ Q(
|
|
512
|
+
}), g && /* @__PURE__ */ Q(R, {
|
|
465
513
|
className: "pt-4",
|
|
466
514
|
children: g
|
|
467
515
|
})]
|
|
468
516
|
}) : /* @__PURE__ */ $("div", {
|
|
469
|
-
className:
|
|
517
|
+
className: Y("form-section", o),
|
|
470
518
|
children: [h, g]
|
|
471
519
|
});
|
|
472
|
-
},
|
|
473
|
-
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;
|
|
474
522
|
t.useEffect(() => {
|
|
475
523
|
(async () => {
|
|
476
524
|
if (!r) {
|
|
477
|
-
|
|
525
|
+
x(!1);
|
|
478
526
|
return;
|
|
479
527
|
}
|
|
480
528
|
try {
|
|
481
529
|
let t = await r.getObjectSchema(e.objectName);
|
|
482
|
-
|
|
530
|
+
u(t);
|
|
483
531
|
} catch (e) {
|
|
484
532
|
w(e);
|
|
485
533
|
}
|
|
@@ -487,16 +535,16 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
487
535
|
}, [e.objectName, r]), t.useEffect(() => {
|
|
488
536
|
(l || !r) && (async () => {
|
|
489
537
|
if (e.mode === "create" || !e.recordId || !r) {
|
|
490
|
-
|
|
538
|
+
R.current ||= (p(ke(l, e.initialData || e.initialValues)), !0), x(!1);
|
|
491
539
|
return;
|
|
492
540
|
}
|
|
493
541
|
try {
|
|
494
542
|
let t = await r.findOne(e.objectName, e.recordId);
|
|
495
|
-
|
|
543
|
+
p(t || {}), g(t || {});
|
|
496
544
|
} catch (e) {
|
|
497
545
|
w(e);
|
|
498
546
|
} finally {
|
|
499
|
-
|
|
547
|
+
x(!1);
|
|
500
548
|
}
|
|
501
549
|
})();
|
|
502
550
|
}, [
|
|
@@ -508,30 +556,32 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
508
556
|
r,
|
|
509
557
|
e.objectName
|
|
510
558
|
]);
|
|
511
|
-
let H = n((t) =>
|
|
559
|
+
let H = n((t) => Ie(t, {
|
|
512
560
|
objectSchema: l,
|
|
513
561
|
objectName: e.objectName,
|
|
514
562
|
readOnly: e.readOnly,
|
|
515
563
|
mode: e.mode,
|
|
564
|
+
recordId: e.recordId,
|
|
516
565
|
fieldLabel: a
|
|
517
566
|
}), [
|
|
518
567
|
l,
|
|
519
568
|
e.readOnly,
|
|
520
569
|
e.mode,
|
|
570
|
+
e.recordId,
|
|
521
571
|
e.objectName,
|
|
522
572
|
a
|
|
523
|
-
]), U = o(() => T >= 0 && T <
|
|
573
|
+
]), U = o(() => T >= 0 && T < z ? H(e.sections[T]) : [], [
|
|
524
574
|
T,
|
|
525
|
-
|
|
575
|
+
z,
|
|
526
576
|
e.sections,
|
|
527
577
|
H
|
|
528
|
-
]),
|
|
578
|
+
]), W = n((t) => {
|
|
529
579
|
let n = /* @__PURE__ */ new Map();
|
|
530
580
|
return e.sections.forEach((e, r) => {
|
|
531
581
|
for (let i of H(e)) {
|
|
532
582
|
let e = i?.name;
|
|
533
583
|
if (!e || i.hidden === !0) continue;
|
|
534
|
-
let a =
|
|
584
|
+
let a = h({
|
|
535
585
|
visibleWhen: i.visibleWhen,
|
|
536
586
|
readonlyWhen: i.readonlyWhen,
|
|
537
587
|
requiredWhen: i.requiredWhen
|
|
@@ -539,33 +589,33 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
539
589
|
required: !!i.required,
|
|
540
590
|
readonly: i.readonly === !0
|
|
541
591
|
}, void 0, void 0, `field '${e}'`);
|
|
542
|
-
!(i.visibleOn == null ||
|
|
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]);
|
|
543
593
|
}
|
|
544
594
|
}), n;
|
|
545
|
-
}, [e.sections, H]),
|
|
595
|
+
}, [e.sections, H]), G = n(async (t) => {
|
|
546
596
|
let n = {
|
|
547
597
|
...f,
|
|
548
598
|
...t
|
|
549
599
|
};
|
|
550
|
-
if (
|
|
600
|
+
if (p(n), O((e) => new Set(e).add(T)), M((e) => {
|
|
551
601
|
if (!e.has(T)) return e;
|
|
552
602
|
let t = new Set(e);
|
|
553
603
|
return t.delete(T), t;
|
|
554
604
|
}), V) {
|
|
555
|
-
let t =
|
|
605
|
+
let t = W(n);
|
|
556
606
|
if (t.size > 0) {
|
|
557
607
|
M(new Set(t.keys()));
|
|
558
608
|
let e = [...t.values()].flat();
|
|
559
|
-
|
|
609
|
+
X.error(s("wizard.missingRequired", { fields: e.slice(0, 3).join(", ") + (e.length > 3 ? "…" : "") })), K(Math.min(...t.keys()));
|
|
560
610
|
return;
|
|
561
611
|
}
|
|
562
612
|
M(/* @__PURE__ */ new Set()), A(!0);
|
|
563
613
|
try {
|
|
564
614
|
if (!r) return e.onSuccess && await e.onSuccess(n), n;
|
|
565
615
|
let t;
|
|
566
|
-
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));
|
|
567
617
|
else if (e.mode === "edit" && e.recordId) {
|
|
568
|
-
let i = await
|
|
618
|
+
let i = await _({
|
|
569
619
|
dataSource: r,
|
|
570
620
|
objectName: e.objectName,
|
|
571
621
|
recordId: e.recordId,
|
|
@@ -580,14 +630,14 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
580
630
|
let t = e.submitBehavior;
|
|
581
631
|
switch (t.kind) {
|
|
582
632
|
case "redirect":
|
|
583
|
-
|
|
633
|
+
xe(t.url) && setTimeout(() => window.location.assign(t.url), t.delayMs ?? 0);
|
|
584
634
|
break;
|
|
585
635
|
case "continue":
|
|
586
|
-
|
|
636
|
+
p(ke(l, e.initialData || e.initialValues)), O(/* @__PURE__ */ new Set()), E(0), L((e) => e + 1);
|
|
587
637
|
break;
|
|
588
638
|
default: {
|
|
589
639
|
let n = t.kind === "thank-you" && t.message ? t.message : e.successMessage || (e.mode === "create" ? "Created" : "Saved");
|
|
590
|
-
|
|
640
|
+
X.success(n), P({
|
|
591
641
|
title: t.kind === "thank-you" ? t.title : void 0,
|
|
592
642
|
message: n
|
|
593
643
|
});
|
|
@@ -595,9 +645,9 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
595
645
|
}
|
|
596
646
|
}
|
|
597
647
|
} else {
|
|
598
|
-
let n =
|
|
648
|
+
let n = Se(e.navigateOnSuccess, t);
|
|
599
649
|
if (n) return window.location.assign(n), t;
|
|
600
|
-
|
|
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));
|
|
601
651
|
}
|
|
602
652
|
return t;
|
|
603
653
|
} catch (t) {
|
|
@@ -606,63 +656,64 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
606
656
|
A(!1);
|
|
607
657
|
}
|
|
608
658
|
}
|
|
609
|
-
|
|
659
|
+
K(T + 1);
|
|
610
660
|
}, [
|
|
611
661
|
f,
|
|
612
662
|
T,
|
|
613
663
|
V,
|
|
614
664
|
e,
|
|
665
|
+
l,
|
|
615
666
|
r,
|
|
616
|
-
|
|
667
|
+
W,
|
|
617
668
|
s,
|
|
618
|
-
|
|
619
|
-
]),
|
|
620
|
-
t >= 0 && t <
|
|
621
|
-
}, [
|
|
622
|
-
|
|
623
|
-
}, [T,
|
|
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(() => {
|
|
624
675
|
e.onCancel && e.onCancel();
|
|
625
|
-
}, [e]),
|
|
626
|
-
(e.allowSkip || D.has(t) || t <= T) &&
|
|
676
|
+
}, [e]), re = n((t) => {
|
|
677
|
+
(e.allowSkip || D.has(t) || t <= T) && K(t);
|
|
627
678
|
}, [
|
|
628
679
|
e.allowSkip,
|
|
629
680
|
D,
|
|
630
681
|
T,
|
|
631
|
-
|
|
682
|
+
K
|
|
632
683
|
]);
|
|
633
|
-
if (
|
|
684
|
+
if (S) return /* @__PURE__ */ $("div", {
|
|
634
685
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
635
686
|
children: [/* @__PURE__ */ Q("h3", {
|
|
636
687
|
className: "text-red-800 font-semibold",
|
|
637
688
|
children: "Error loading form"
|
|
638
689
|
}), /* @__PURE__ */ Q("p", {
|
|
639
690
|
className: "text-red-600 text-sm mt-1",
|
|
640
|
-
children:
|
|
691
|
+
children: S.message
|
|
641
692
|
})]
|
|
642
693
|
});
|
|
643
|
-
if (
|
|
694
|
+
if (b) return /* @__PURE__ */ $("div", {
|
|
644
695
|
className: "p-8 text-center",
|
|
645
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", {
|
|
646
697
|
className: "mt-2 text-sm text-gray-600",
|
|
647
698
|
children: "Loading form..."
|
|
648
699
|
})]
|
|
649
700
|
});
|
|
650
|
-
if (
|
|
651
|
-
className:
|
|
701
|
+
if (N) return /* @__PURE__ */ Q("div", {
|
|
702
|
+
className: Y("w-full", i, e.className),
|
|
652
703
|
children: /* @__PURE__ */ $("div", {
|
|
653
704
|
className: "rounded-md border bg-card p-8 text-center",
|
|
654
705
|
children: [/* @__PURE__ */ Q("h3", {
|
|
655
706
|
className: "text-lg font-semibold",
|
|
656
|
-
children:
|
|
657
|
-
}),
|
|
707
|
+
children: N.title ?? "Thanks!"
|
|
708
|
+
}), N.message && /* @__PURE__ */ Q("p", {
|
|
658
709
|
className: "mt-2 text-sm text-muted-foreground",
|
|
659
|
-
children:
|
|
710
|
+
children: N.message
|
|
660
711
|
})]
|
|
661
712
|
})
|
|
662
713
|
});
|
|
663
|
-
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);
|
|
664
715
|
return /* @__PURE__ */ $("div", {
|
|
665
|
-
className:
|
|
716
|
+
className: Y("w-full @container", i, e.className),
|
|
666
717
|
children: [
|
|
667
718
|
e.showStepIndicator !== !1 && /* @__PURE__ */ Q("nav", {
|
|
668
719
|
"aria-label": "Progress",
|
|
@@ -672,28 +723,28 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
672
723
|
children: e.sections.map((t, n) => {
|
|
673
724
|
let r = n === T, i = D.has(n), a = e.allowSkip || i || n <= T, o = j.has(n);
|
|
674
725
|
return /* @__PURE__ */ $("li", {
|
|
675
|
-
className:
|
|
676
|
-
children: [n !==
|
|
726
|
+
className: Y("relative flex-1", n !== z - 1 && "pr-8 sm:pr-12"),
|
|
727
|
+
children: [n !== z - 1 && /* @__PURE__ */ Q("div", {
|
|
677
728
|
className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
|
|
678
729
|
"aria-hidden": "true",
|
|
679
|
-
children: /* @__PURE__ */ Q("div", { className:
|
|
730
|
+
children: /* @__PURE__ */ Q("div", { className: Y("h-full", i ? "bg-primary" : "bg-muted") })
|
|
680
731
|
}), /* @__PURE__ */ $("button", {
|
|
681
732
|
type: "button",
|
|
682
|
-
className:
|
|
683
|
-
onClick: () =>
|
|
733
|
+
className: Y("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
|
|
734
|
+
onClick: () => re(n),
|
|
684
735
|
disabled: !a,
|
|
685
736
|
"data-testid": `wizard-step:${t.name || n}`,
|
|
686
737
|
"data-error": o || void 0,
|
|
687
738
|
children: [/* @__PURE__ */ Q("span", {
|
|
688
|
-
className:
|
|
689
|
-
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, {
|
|
690
741
|
className: "h-3 w-3 sm:h-4 sm:w-4",
|
|
691
742
|
"aria-hidden": !0
|
|
692
|
-
}) : i ? /* @__PURE__ */ Q(
|
|
743
|
+
}) : i ? /* @__PURE__ */ Q(de, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : n + 1
|
|
693
744
|
}), /* @__PURE__ */ Q("span", {
|
|
694
745
|
className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block",
|
|
695
746
|
children: /* @__PURE__ */ Q("span", {
|
|
696
|
-
className:
|
|
747
|
+
className: Y(o ? "text-destructive" : r ? "text-foreground" : "text-muted-foreground"),
|
|
697
748
|
children: t.label || `Step ${n + 1}`
|
|
698
749
|
})
|
|
699
750
|
})]
|
|
@@ -704,29 +755,29 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
704
755
|
}),
|
|
705
756
|
/* @__PURE__ */ Q("div", {
|
|
706
757
|
className: "min-h-[200px]",
|
|
707
|
-
children:
|
|
708
|
-
label:
|
|
709
|
-
description:
|
|
758
|
+
children: q && /* @__PURE__ */ Q(ot, {
|
|
759
|
+
label: q.label,
|
|
760
|
+
description: q.description,
|
|
710
761
|
columns: 1,
|
|
711
|
-
className:
|
|
712
|
-
gridClassName:
|
|
713
|
-
children: U.length > 0 ? /* @__PURE__ */ Q(
|
|
762
|
+
className: q.className,
|
|
763
|
+
gridClassName: q.gridClassName,
|
|
764
|
+
children: U.length > 0 ? /* @__PURE__ */ Q(y, { schema: {
|
|
714
765
|
type: "form",
|
|
715
766
|
objectName: e.objectName,
|
|
716
|
-
id:
|
|
717
|
-
fields:
|
|
718
|
-
columns:
|
|
719
|
-
...
|
|
767
|
+
id: F,
|
|
768
|
+
fields: ie > 1 ? Ge(U, ie, J(q.columns)) : U,
|
|
769
|
+
columns: ie,
|
|
770
|
+
...ae ? { fieldContainerClass: ae } : {},
|
|
720
771
|
layout: "vertical",
|
|
721
772
|
defaultValues: f,
|
|
722
|
-
previousValues: e.mode === "edit" ?
|
|
773
|
+
previousValues: e.mode === "edit" ? m : void 0,
|
|
723
774
|
showSubmit: !1,
|
|
724
775
|
showCancel: !1,
|
|
725
|
-
onSubmit:
|
|
726
|
-
} },
|
|
727
|
-
id:
|
|
776
|
+
onSubmit: G
|
|
777
|
+
} }, ee) : /* @__PURE__ */ Q("form", {
|
|
778
|
+
id: F,
|
|
728
779
|
onSubmit: (e) => {
|
|
729
|
-
e.preventDefault(),
|
|
780
|
+
e.preventDefault(), G({});
|
|
730
781
|
},
|
|
731
782
|
children: /* @__PURE__ */ Q("div", {
|
|
732
783
|
className: "text-center py-8 text-muted-foreground",
|
|
@@ -737,9 +788,9 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
737
788
|
}),
|
|
738
789
|
/* @__PURE__ */ $("div", {
|
|
739
790
|
className: "flex items-center justify-between mt-6 pt-4 border-t",
|
|
740
|
-
children: [/* @__PURE__ */ Q("div", { children: e.showCancel !== !1 && /* @__PURE__ */ Q(
|
|
791
|
+
children: [/* @__PURE__ */ Q("div", { children: e.showCancel !== !1 && /* @__PURE__ */ Q(I, {
|
|
741
792
|
variant: "ghost",
|
|
742
|
-
onClick:
|
|
793
|
+
onClick: ne,
|
|
743
794
|
children: e.cancelText || "Cancel"
|
|
744
795
|
}) }), /* @__PURE__ */ $("div", {
|
|
745
796
|
className: "flex items-center gap-2",
|
|
@@ -750,71 +801,71 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
750
801
|
"Step ",
|
|
751
802
|
T + 1,
|
|
752
803
|
" of ",
|
|
753
|
-
|
|
804
|
+
z
|
|
754
805
|
]
|
|
755
806
|
}),
|
|
756
|
-
!
|
|
807
|
+
!B && /* @__PURE__ */ $(I, {
|
|
757
808
|
variant: "outline",
|
|
758
|
-
onClick:
|
|
759
|
-
children: [/* @__PURE__ */ Q(
|
|
809
|
+
onClick: te,
|
|
810
|
+
children: [/* @__PURE__ */ Q(me, { className: "h-4 w-4 mr-1" }), e.prevText || "Back"]
|
|
760
811
|
}),
|
|
761
|
-
V ? /* @__PURE__ */ $(
|
|
812
|
+
V ? /* @__PURE__ */ $(I, {
|
|
762
813
|
type: "submit",
|
|
763
|
-
form:
|
|
814
|
+
form: F,
|
|
764
815
|
disabled: k || e.mode === "view",
|
|
765
|
-
children: [k && /* @__PURE__ */ Q(
|
|
816
|
+
children: [k && /* @__PURE__ */ Q(ge, {
|
|
766
817
|
className: "mr-2 h-4 w-4 animate-spin",
|
|
767
818
|
"aria-hidden": !0
|
|
768
819
|
}), k ? "Submitting..." : e.submitText || (e.mode === "create" ? "Create" : "Update")]
|
|
769
|
-
}) : /* @__PURE__ */ $(
|
|
820
|
+
}) : /* @__PURE__ */ $(I, {
|
|
770
821
|
type: "submit",
|
|
771
|
-
form:
|
|
772
|
-
children: [e.nextText || "Next", /* @__PURE__ */ Q(
|
|
822
|
+
form: F,
|
|
823
|
+
children: [e.nextText || "Next", /* @__PURE__ */ Q(he, { className: "h-4 w-4 ml-1" })]
|
|
773
824
|
})
|
|
774
825
|
]
|
|
775
826
|
})]
|
|
776
827
|
}),
|
|
777
|
-
|
|
828
|
+
v
|
|
778
829
|
]
|
|
779
830
|
});
|
|
780
|
-
},
|
|
781
|
-
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);
|
|
782
833
|
i(() => {
|
|
783
834
|
(async () => {
|
|
784
835
|
if (!t) {
|
|
785
|
-
|
|
836
|
+
g(!1);
|
|
786
837
|
return;
|
|
787
838
|
}
|
|
788
839
|
try {
|
|
789
840
|
let n = await t.getObjectSchema(e.objectName);
|
|
790
841
|
u(n);
|
|
791
842
|
} catch (e) {
|
|
792
|
-
|
|
843
|
+
v(e), g(!1);
|
|
793
844
|
}
|
|
794
845
|
})();
|
|
795
846
|
}, [e.objectName, t]);
|
|
796
|
-
let
|
|
847
|
+
let b = s(void 0);
|
|
797
848
|
i(() => {
|
|
798
849
|
let n = !1;
|
|
799
850
|
return (l || !t) && (async () => {
|
|
800
851
|
if (e.mode === "create" || !e.recordId) {
|
|
801
|
-
f(e.initialData || e.initialValues
|
|
852
|
+
f(ke(l, e.initialData || e.initialValues)), g(!1);
|
|
802
853
|
return;
|
|
803
854
|
}
|
|
804
855
|
if (!t) {
|
|
805
|
-
f(e.initialData || e.initialValues || {}),
|
|
856
|
+
f(e.initialData || e.initialValues || {}), g(!1);
|
|
806
857
|
return;
|
|
807
858
|
}
|
|
808
|
-
|
|
859
|
+
b.current !== e.recordId && g(!0);
|
|
809
860
|
try {
|
|
810
861
|
let r = await t.findOne(e.objectName, e.recordId);
|
|
811
862
|
if (n) return;
|
|
812
|
-
|
|
863
|
+
b.current = e.recordId, f(r || {});
|
|
813
864
|
} catch (e) {
|
|
814
865
|
if (n) return;
|
|
815
|
-
|
|
866
|
+
v(e);
|
|
816
867
|
} finally {
|
|
817
|
-
n ||
|
|
868
|
+
n || g(!1);
|
|
818
869
|
}
|
|
819
870
|
})(), () => {
|
|
820
871
|
n = !0;
|
|
@@ -828,23 +879,25 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
828
879
|
t,
|
|
829
880
|
e.objectName
|
|
830
881
|
]);
|
|
831
|
-
let
|
|
882
|
+
let x = n((t) => Ie(t, {
|
|
832
883
|
objectSchema: l,
|
|
833
884
|
objectName: e.objectName,
|
|
834
885
|
readOnly: e.readOnly,
|
|
835
886
|
mode: e.mode,
|
|
887
|
+
recordId: e.recordId,
|
|
836
888
|
fieldLabel: a
|
|
837
889
|
}), [
|
|
838
890
|
l,
|
|
839
891
|
e.readOnly,
|
|
840
892
|
e.mode,
|
|
893
|
+
e.recordId,
|
|
841
894
|
e.objectName,
|
|
842
895
|
a
|
|
843
|
-
]),
|
|
896
|
+
]), S = n(async (n) => {
|
|
844
897
|
if (!t) return e.onSuccess && await e.onSuccess(n), n;
|
|
845
898
|
try {
|
|
846
899
|
let r;
|
|
847
|
-
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));
|
|
848
901
|
else if (e.mode === "edit" && e.recordId) {
|
|
849
902
|
let i = await p({
|
|
850
903
|
dataSource: t,
|
|
@@ -868,27 +921,27 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
868
921
|
]), w = n(() => {
|
|
869
922
|
e.onCancel && e.onCancel();
|
|
870
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;
|
|
871
|
-
if (
|
|
924
|
+
if (_) return /* @__PURE__ */ $("div", {
|
|
872
925
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
873
926
|
children: [/* @__PURE__ */ Q("h3", {
|
|
874
927
|
className: "text-red-800 font-semibold",
|
|
875
928
|
children: "Error loading form"
|
|
876
929
|
}), /* @__PURE__ */ Q("p", {
|
|
877
930
|
className: "text-red-600 text-sm mt-1",
|
|
878
|
-
children:
|
|
931
|
+
children: _.message
|
|
879
932
|
})]
|
|
880
933
|
});
|
|
881
|
-
if (
|
|
934
|
+
if (h) return /* @__PURE__ */ $("div", {
|
|
882
935
|
className: "p-8 text-center",
|
|
883
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", {
|
|
884
937
|
className: "mt-2 text-sm text-gray-600",
|
|
885
938
|
children: "Loading form..."
|
|
886
939
|
})]
|
|
887
940
|
});
|
|
888
|
-
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) => {
|
|
889
942
|
let n = [];
|
|
890
943
|
return e.forEach((e, r) => {
|
|
891
|
-
let i =
|
|
944
|
+
let i = x(e);
|
|
892
945
|
i.length && ((e.label || e.description) && n.push({
|
|
893
946
|
name: `__section_${e.name || `${t}_${r}`}`,
|
|
894
947
|
label: e.label,
|
|
@@ -896,7 +949,7 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
896
949
|
type: "section-divider",
|
|
897
950
|
colSpan: 4,
|
|
898
951
|
className: e.className
|
|
899
|
-
}), n.push(...M > 1 ?
|
|
952
|
+
}), n.push(...M > 1 ? Ge(i, M, A(e.columns)) : i));
|
|
900
953
|
}), n;
|
|
901
954
|
}, F = [{
|
|
902
955
|
key: "primary",
|
|
@@ -912,8 +965,8 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
912
965
|
containerClass: e.sections.length === 1 ? e.sections[0].gridClassName : void 0
|
|
913
966
|
})).filter((e) => e.fields.length > 0);
|
|
914
967
|
return /* @__PURE__ */ $("div", {
|
|
915
|
-
className:
|
|
916
|
-
children: [/* @__PURE__ */ Q(
|
|
968
|
+
className: Y("w-full @container", r, e.className),
|
|
969
|
+
children: [/* @__PURE__ */ Q(y, { schema: {
|
|
917
970
|
type: "form",
|
|
918
971
|
objectName: e.objectName,
|
|
919
972
|
fields: F.flatMap((e) => e.fields),
|
|
@@ -926,7 +979,7 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
926
979
|
cancelLabel: e.cancelText,
|
|
927
980
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
928
981
|
showCancel: e.showCancel !== !1,
|
|
929
|
-
onSubmit:
|
|
982
|
+
onSubmit: S,
|
|
930
983
|
onCancel: w,
|
|
931
984
|
fieldPanes: F.map((e) => ({
|
|
932
985
|
key: e.key,
|
|
@@ -938,7 +991,7 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
938
991
|
fieldPanesResizable: e.splitResizable !== !1
|
|
939
992
|
} }), m]
|
|
940
993
|
});
|
|
941
|
-
},
|
|
994
|
+
}, dt = /* @__PURE__ */ new Set([
|
|
942
995
|
"id",
|
|
943
996
|
"_id",
|
|
944
997
|
"created_at",
|
|
@@ -947,7 +1000,7 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
947
1000
|
"updatedAt",
|
|
948
1001
|
"organization_id",
|
|
949
1002
|
"organizationId"
|
|
950
|
-
]),
|
|
1003
|
+
]), ft = /* @__PURE__ */ new Set([
|
|
951
1004
|
"formula",
|
|
952
1005
|
"summary",
|
|
953
1006
|
"rollup",
|
|
@@ -956,15 +1009,15 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
956
1009
|
"autonumber",
|
|
957
1010
|
"computed"
|
|
958
1011
|
]);
|
|
959
|
-
function
|
|
1012
|
+
function pt(e, t) {
|
|
960
1013
|
if (!e || typeof e != "object") return e;
|
|
961
1014
|
let n = {}, r = t?.fields;
|
|
962
|
-
for (let [t, i] of Object.entries(e)) if (!
|
|
1015
|
+
for (let [t, i] of Object.entries(e)) if (!dt.has(t)) {
|
|
963
1016
|
if (r) {
|
|
964
1017
|
let e = r[t];
|
|
965
1018
|
if (!e) continue;
|
|
966
1019
|
let n = String(e.type || "").toLowerCase();
|
|
967
|
-
if (
|
|
1020
|
+
if (ft.has(n) || e.computed === !0 || e.formula || e.readOnly === !0 || e.readonly === !0) continue;
|
|
968
1021
|
}
|
|
969
1022
|
n[t] = i;
|
|
970
1023
|
}
|
|
@@ -972,31 +1025,31 @@ function et(e, t) {
|
|
|
972
1025
|
}
|
|
973
1026
|
//#endregion
|
|
974
1027
|
//#region src/masterDetailTx.ts
|
|
975
|
-
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([
|
|
976
1029
|
"id",
|
|
977
1030
|
"_id",
|
|
978
1031
|
"recordId"
|
|
979
1032
|
]);
|
|
980
|
-
function
|
|
981
|
-
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 === "");
|
|
982
1035
|
}
|
|
983
|
-
function
|
|
1036
|
+
function vt(e, t, n) {
|
|
984
1037
|
let r = [{
|
|
985
1038
|
object: e,
|
|
986
1039
|
action: "create",
|
|
987
1040
|
data: t
|
|
988
1041
|
}];
|
|
989
|
-
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({
|
|
990
1043
|
object: e.childObject,
|
|
991
1044
|
action: "create",
|
|
992
1045
|
data: {
|
|
993
|
-
...
|
|
1046
|
+
...ht(t, e.childSchema),
|
|
994
1047
|
[e.relationshipField]: { $ref: 0 }
|
|
995
1048
|
}
|
|
996
1049
|
});
|
|
997
1050
|
return r;
|
|
998
1051
|
}
|
|
999
|
-
function
|
|
1052
|
+
function yt(e, t, n, r) {
|
|
1000
1053
|
let i = [{
|
|
1001
1054
|
object: e,
|
|
1002
1055
|
action: "update",
|
|
@@ -1007,21 +1060,21 @@ function ot(e, t, n, r) {
|
|
|
1007
1060
|
let n = (e.rows || []).map((n) => ({
|
|
1008
1061
|
...n,
|
|
1009
1062
|
[e.relationshipField]: t
|
|
1010
|
-
})), { toCreate: r, toUpdate: a, toDelete: o } =
|
|
1063
|
+
})), { toCreate: r, toUpdate: a, toDelete: o } = bt(e.original || [], n);
|
|
1011
1064
|
for (let t of r) {
|
|
1012
|
-
if (
|
|
1065
|
+
if (_t(t, e.relationshipField)) continue;
|
|
1013
1066
|
let { id: n, _id: r, recordId: a, ...o } = t;
|
|
1014
1067
|
i.push({
|
|
1015
1068
|
object: e.childObject,
|
|
1016
1069
|
action: "create",
|
|
1017
|
-
data:
|
|
1070
|
+
data: ht(o, e.childSchema)
|
|
1018
1071
|
});
|
|
1019
1072
|
}
|
|
1020
1073
|
for (let t of a) i.push({
|
|
1021
1074
|
object: e.childObject,
|
|
1022
1075
|
action: "update",
|
|
1023
|
-
id:
|
|
1024
|
-
data:
|
|
1076
|
+
id: mt(t),
|
|
1077
|
+
data: ht(t, e.childSchema)
|
|
1025
1078
|
});
|
|
1026
1079
|
for (let t of o) i.push({
|
|
1027
1080
|
object: e.childObject,
|
|
@@ -1031,15 +1084,15 @@ function ot(e, t, n, r) {
|
|
|
1031
1084
|
}
|
|
1032
1085
|
return i;
|
|
1033
1086
|
}
|
|
1034
|
-
function
|
|
1035
|
-
let n = new Set(t.map(
|
|
1087
|
+
function bt(e, t) {
|
|
1088
|
+
let n = new Set(t.map(mt).filter(Boolean));
|
|
1036
1089
|
return {
|
|
1037
|
-
toCreate: t.filter((e) => !
|
|
1038
|
-
toUpdate: t.filter((e) =>
|
|
1039
|
-
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))
|
|
1040
1093
|
};
|
|
1041
1094
|
}
|
|
1042
|
-
function
|
|
1095
|
+
function xt(e, t) {
|
|
1043
1096
|
return Array.isArray(e) ? e.reduce((e, n) => {
|
|
1044
1097
|
let r = Number(n?.[t]);
|
|
1045
1098
|
return e + (Number.isFinite(r) ? r : 0);
|
|
@@ -1047,7 +1100,7 @@ function ct(e, t) {
|
|
|
1047
1100
|
}
|
|
1048
1101
|
//#endregion
|
|
1049
1102
|
//#region src/deriveMasterDetail.ts
|
|
1050
|
-
var
|
|
1103
|
+
var St = /* @__PURE__ */ new Set([
|
|
1051
1104
|
"id",
|
|
1052
1105
|
"_id",
|
|
1053
1106
|
"recordId",
|
|
@@ -1063,14 +1116,14 @@ var lt = /* @__PURE__ */ new Set([
|
|
|
1063
1116
|
"tenant_id",
|
|
1064
1117
|
"space",
|
|
1065
1118
|
"owner"
|
|
1066
|
-
]),
|
|
1119
|
+
]), Ct = /* @__PURE__ */ new Set([
|
|
1067
1120
|
"position",
|
|
1068
1121
|
"sort_order",
|
|
1069
1122
|
"sequence",
|
|
1070
1123
|
"line_no",
|
|
1071
1124
|
"line_number",
|
|
1072
1125
|
"sort"
|
|
1073
|
-
]),
|
|
1126
|
+
]), wt = /* @__PURE__ */ new Set([
|
|
1074
1127
|
"formula",
|
|
1075
1128
|
"summary",
|
|
1076
1129
|
"rollup",
|
|
@@ -1086,16 +1139,16 @@ var lt = /* @__PURE__ */ new Set([
|
|
|
1086
1139
|
"markdown",
|
|
1087
1140
|
"richtext"
|
|
1088
1141
|
]);
|
|
1089
|
-
function
|
|
1142
|
+
function Tt(e) {
|
|
1090
1143
|
switch (e) {
|
|
1091
1144
|
case "number":
|
|
1092
1145
|
case "percent":
|
|
1093
1146
|
case "rating":
|
|
1094
1147
|
case "slider": return "number";
|
|
1095
1148
|
case "currency": return "currency";
|
|
1096
|
-
case "date":
|
|
1097
|
-
case "datetime":
|
|
1098
|
-
case "time": return "
|
|
1149
|
+
case "date": return "date";
|
|
1150
|
+
case "datetime": return "datetime";
|
|
1151
|
+
case "time": return "time";
|
|
1099
1152
|
case "select":
|
|
1100
1153
|
case "picklist":
|
|
1101
1154
|
case "radio":
|
|
@@ -1109,11 +1162,11 @@ function ft(e) {
|
|
|
1109
1162
|
default: return "text";
|
|
1110
1163
|
}
|
|
1111
1164
|
}
|
|
1112
|
-
var
|
|
1113
|
-
function
|
|
1114
|
-
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/*"]));
|
|
1115
1168
|
}
|
|
1116
|
-
function
|
|
1169
|
+
function Ot(e) {
|
|
1117
1170
|
if (e?.type === "boolean" || e?.type === "toggle") return [{
|
|
1118
1171
|
label: "Yes",
|
|
1119
1172
|
value: "true"
|
|
@@ -1130,7 +1183,7 @@ function ht(e) {
|
|
|
1130
1183
|
value: String(e)
|
|
1131
1184
|
});
|
|
1132
1185
|
}
|
|
1133
|
-
function
|
|
1186
|
+
function kt(e, t) {
|
|
1134
1187
|
let n = e?.fields;
|
|
1135
1188
|
if (!n || typeof n != "object") return;
|
|
1136
1189
|
let r;
|
|
@@ -1143,7 +1196,7 @@ function gt(e, t) {
|
|
|
1143
1196
|
}
|
|
1144
1197
|
return r;
|
|
1145
1198
|
}
|
|
1146
|
-
var
|
|
1199
|
+
var At = [
|
|
1147
1200
|
"name",
|
|
1148
1201
|
"title",
|
|
1149
1202
|
"subject",
|
|
@@ -1151,26 +1204,28 @@ var _t = [
|
|
|
1151
1204
|
"full_name",
|
|
1152
1205
|
"display_name",
|
|
1153
1206
|
"code"
|
|
1154
|
-
],
|
|
1207
|
+
], jt = {
|
|
1155
1208
|
select: 0,
|
|
1156
1209
|
currency: 1,
|
|
1157
1210
|
number: 1,
|
|
1158
1211
|
lookup: 2,
|
|
1159
1212
|
date: 3,
|
|
1213
|
+
datetime: 3,
|
|
1214
|
+
time: 3,
|
|
1160
1215
|
text: 4
|
|
1161
1216
|
};
|
|
1162
|
-
function
|
|
1163
|
-
return (e.type ?
|
|
1217
|
+
function Mt(e) {
|
|
1218
|
+
return (e.type ? jt[e.type] : void 0) ?? 5;
|
|
1164
1219
|
}
|
|
1165
|
-
function
|
|
1220
|
+
function Nt(e, t) {
|
|
1166
1221
|
if (t <= 0 || e.length <= t) return e;
|
|
1167
|
-
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];
|
|
1168
1223
|
r && n.add(r.field);
|
|
1169
1224
|
for (let t of e) t.required && n.add(t.field);
|
|
1170
1225
|
let i = e.map((e, t) => ({
|
|
1171
1226
|
c: e,
|
|
1172
1227
|
i: t
|
|
1173
|
-
})).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);
|
|
1174
1229
|
for (let { c: e } of i) {
|
|
1175
1230
|
if (n.size >= t) break;
|
|
1176
1231
|
n.add(e.field);
|
|
@@ -1180,60 +1235,60 @@ function bt(e, t) {
|
|
|
1180
1235
|
defaultHidden: !0
|
|
1181
1236
|
});
|
|
1182
1237
|
}
|
|
1183
|
-
function
|
|
1238
|
+
function Pt(e, t = {}) {
|
|
1184
1239
|
let n = e?.fields;
|
|
1185
1240
|
if (!n || typeof n != "object") return [];
|
|
1186
1241
|
let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
|
|
1187
1242
|
for (let [e, t] of Object.entries(n)) {
|
|
1188
1243
|
let n = t;
|
|
1189
|
-
if (
|
|
1244
|
+
if (St.has(e) || r.has(e) || Ct.has(e) || n?.system || n?.readonly || n?.hidden || wt.has(n?.type)) continue;
|
|
1190
1245
|
let a = {
|
|
1191
1246
|
field: e,
|
|
1192
1247
|
label: n?.label || e,
|
|
1193
|
-
type:
|
|
1248
|
+
type: Tt(n?.type),
|
|
1194
1249
|
required: !!n?.required
|
|
1195
|
-
}, o =
|
|
1196
|
-
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);
|
|
1197
1252
|
let s = typeof n?.expression == "string" ? n.expression : n?.expression?.source;
|
|
1198
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);
|
|
1199
1254
|
}
|
|
1200
|
-
return
|
|
1255
|
+
return Nt(i, t.maxColumns ?? 6);
|
|
1201
1256
|
}
|
|
1202
|
-
function
|
|
1257
|
+
function Ft(e, t) {
|
|
1203
1258
|
let n = e ?? [], r = t?.fields;
|
|
1204
1259
|
return !n.length || !r || typeof r != "object" ? n : n.map((e) => {
|
|
1205
1260
|
if (e.type) return e;
|
|
1206
1261
|
let t = r[e.field];
|
|
1207
1262
|
if (!t) return e;
|
|
1208
|
-
let n =
|
|
1263
|
+
let n = Tt(t?.type), i = {
|
|
1209
1264
|
...e,
|
|
1210
1265
|
type: n
|
|
1211
1266
|
};
|
|
1212
1267
|
i.label ??= t?.label || e.field, i.required ??= !!t?.required;
|
|
1213
|
-
let a =
|
|
1214
|
-
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);
|
|
1215
1270
|
let o = typeof t?.expression == "string" ? t.expression : t?.expression?.source;
|
|
1216
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;
|
|
1217
1272
|
});
|
|
1218
1273
|
}
|
|
1219
|
-
var
|
|
1274
|
+
var It = /* @__PURE__ */ new Set([
|
|
1220
1275
|
"formula",
|
|
1221
1276
|
"summary",
|
|
1222
1277
|
"rollup",
|
|
1223
1278
|
"autonumber",
|
|
1224
1279
|
"auto_number"
|
|
1225
1280
|
]);
|
|
1226
|
-
function
|
|
1281
|
+
function Lt(e, t = {}) {
|
|
1227
1282
|
let n = e?.fields;
|
|
1228
1283
|
if (!n || typeof n != "object") return [];
|
|
1229
1284
|
let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
|
|
1230
1285
|
for (let [e, t] of Object.entries(n)) {
|
|
1231
1286
|
let n = t;
|
|
1232
|
-
|
|
1287
|
+
St.has(e) || r.has(e) || Ct.has(e) || n?.system || n?.hidden || It.has(n?.type) || i.push(e);
|
|
1233
1288
|
}
|
|
1234
1289
|
return i;
|
|
1235
1290
|
}
|
|
1236
|
-
var
|
|
1291
|
+
var Rt = /* @__PURE__ */ new Set([
|
|
1237
1292
|
"textarea",
|
|
1238
1293
|
"richtext",
|
|
1239
1294
|
"html",
|
|
@@ -1242,17 +1297,17 @@ var Tt = /* @__PURE__ */ new Set([
|
|
|
1242
1297
|
"json",
|
|
1243
1298
|
"location",
|
|
1244
1299
|
"address"
|
|
1245
|
-
]),
|
|
1300
|
+
]), zt = /* @__PURE__ */ new Set([
|
|
1246
1301
|
"file",
|
|
1247
1302
|
"image",
|
|
1248
1303
|
"avatar"
|
|
1249
1304
|
]);
|
|
1250
|
-
function
|
|
1305
|
+
function Bt(e, t, n = {}) {
|
|
1251
1306
|
if (t === "grid" || t === "form") return t;
|
|
1252
|
-
let r = e?.fields ?? {}, i =
|
|
1253
|
-
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";
|
|
1254
1309
|
}
|
|
1255
|
-
var
|
|
1310
|
+
var Vt = [
|
|
1256
1311
|
"amount",
|
|
1257
1312
|
"total",
|
|
1258
1313
|
"subtotal",
|
|
@@ -1260,33 +1315,33 @@ var Ot = [
|
|
|
1260
1315
|
"line_amount",
|
|
1261
1316
|
"net_amount"
|
|
1262
1317
|
];
|
|
1263
|
-
function
|
|
1318
|
+
function Ht(e) {
|
|
1264
1319
|
let t = e.filter((e) => e.type === "number" || e.type === "currency");
|
|
1265
1320
|
if (t.length === 0) return;
|
|
1266
1321
|
let n = t.find((e) => e.computed);
|
|
1267
1322
|
if (n) return n.field;
|
|
1268
|
-
let r = t.find((e) =>
|
|
1323
|
+
let r = t.find((e) => Vt.includes(e.field));
|
|
1269
1324
|
if (r) return r.field;
|
|
1270
1325
|
let i = [...t].reverse().find((e) => e.type === "currency");
|
|
1271
1326
|
return i ? i.field : t[t.length - 1].field;
|
|
1272
1327
|
}
|
|
1273
|
-
function
|
|
1274
|
-
let i = r.relationshipField ||
|
|
1328
|
+
function Ut(e, t, n, r = {}) {
|
|
1329
|
+
let i = r.relationshipField || kt(t, n);
|
|
1275
1330
|
if (!i) throw Error(`MasterDetailForm: could not find a lookup/master_detail field on "${e}" referencing "${n}". Set relationshipField explicitly.`);
|
|
1276
|
-
let a = r.columns?.length ?
|
|
1331
|
+
let a = r.columns?.length ? Ft(r.columns, t) : Pt(t, { relationshipField: i }), o = r.amountField || Ht(a);
|
|
1277
1332
|
return {
|
|
1278
1333
|
childObject: e,
|
|
1279
1334
|
relationshipField: i,
|
|
1280
1335
|
columns: a,
|
|
1281
|
-
formFields:
|
|
1282
|
-
mode:
|
|
1336
|
+
formFields: Lt(t, { relationshipField: i }),
|
|
1337
|
+
mode: Bt(t, r.inlineEdit ?? (t?.fields)?.[i]?.inlineEdit, { relationshipField: i }),
|
|
1283
1338
|
amountField: o,
|
|
1284
|
-
sortField: Object.keys(t?.fields ?? {}).find((e) =>
|
|
1339
|
+
sortField: Object.keys(t?.fields ?? {}).find((e) => Ct.has(e))
|
|
1285
1340
|
};
|
|
1286
1341
|
}
|
|
1287
1342
|
//#endregion
|
|
1288
1343
|
//#region src/MasterDetailForm.tsx
|
|
1289
|
-
function
|
|
1344
|
+
function Wt(e) {
|
|
1290
1345
|
if (!e) return {};
|
|
1291
1346
|
let t = {};
|
|
1292
1347
|
return e.querySelectorAll("[name]").forEach((e) => {
|
|
@@ -1318,13 +1373,13 @@ function jt(e) {
|
|
|
1318
1373
|
}
|
|
1319
1374
|
}), t;
|
|
1320
1375
|
}
|
|
1321
|
-
var
|
|
1376
|
+
var Gt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, formKey: o, onRowExpand: l, onAddViaForm: u }) => {
|
|
1322
1377
|
let [d, f] = c({}), p = s("");
|
|
1323
1378
|
i(() => {
|
|
1324
1379
|
let e = r.current;
|
|
1325
1380
|
if (!e) return;
|
|
1326
1381
|
let t = () => {
|
|
1327
|
-
let t =
|
|
1382
|
+
let t = Wt(e), n;
|
|
1328
1383
|
try {
|
|
1329
1384
|
n = JSON.stringify(t);
|
|
1330
1385
|
} catch {
|
|
@@ -1348,16 +1403,16 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1348
1403
|
o,
|
|
1349
1404
|
e.length
|
|
1350
1405
|
]);
|
|
1351
|
-
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, {
|
|
1352
1407
|
minimumFractionDigits: 2,
|
|
1353
1408
|
maximumFractionDigits: 2
|
|
1354
1409
|
})}`;
|
|
1355
|
-
return /* @__PURE__ */ $(
|
|
1410
|
+
return /* @__PURE__ */ $(be, { children: [e.map((e, r) => /* @__PURE__ */ $("section", {
|
|
1356
1411
|
className: "space-y-2",
|
|
1357
1412
|
children: [/* @__PURE__ */ Q("h3", {
|
|
1358
1413
|
className: "text-sm font-medium text-foreground",
|
|
1359
1414
|
children: e.title || "Line Items"
|
|
1360
|
-
}), e.columns?.length ? /* @__PURE__ */ Q(
|
|
1415
|
+
}), e.columns?.length ? /* @__PURE__ */ Q(T, {
|
|
1361
1416
|
value: t[r]?.rows ?? [],
|
|
1362
1417
|
onChange: (e) => n(r, e),
|
|
1363
1418
|
contextRecord: d,
|
|
@@ -1390,7 +1445,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1390
1445
|
}), /* @__PURE__ */ Q("dd", {
|
|
1391
1446
|
className: "tabular-nums",
|
|
1392
1447
|
"data-testid": "md-subtotal",
|
|
1393
|
-
children:
|
|
1448
|
+
children: x(g)
|
|
1394
1449
|
})]
|
|
1395
1450
|
}),
|
|
1396
1451
|
/* @__PURE__ */ $("div", {
|
|
@@ -1405,7 +1460,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1405
1460
|
}), /* @__PURE__ */ Q("dd", {
|
|
1406
1461
|
className: "tabular-nums",
|
|
1407
1462
|
"data-testid": "md-tax",
|
|
1408
|
-
children:
|
|
1463
|
+
children: x(y)
|
|
1409
1464
|
})]
|
|
1410
1465
|
}),
|
|
1411
1466
|
/* @__PURE__ */ $("div", {
|
|
@@ -1413,13 +1468,13 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1413
1468
|
children: [/* @__PURE__ */ Q("dt", { children: "Total" }), /* @__PURE__ */ Q("dd", {
|
|
1414
1469
|
className: "tabular-nums",
|
|
1415
1470
|
"data-testid": "md-grand-total",
|
|
1416
|
-
children:
|
|
1471
|
+
children: x(b)
|
|
1417
1472
|
})]
|
|
1418
1473
|
})
|
|
1419
1474
|
]
|
|
1420
1475
|
})
|
|
1421
1476
|
})] });
|
|
1422
|
-
},
|
|
1477
|
+
}, Kt = ({ schema: e, dataSource: t, className: r }) => {
|
|
1423
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;
|
|
1424
1479
|
i(() => {
|
|
1425
1480
|
if (!u) {
|
|
@@ -1436,9 +1491,9 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1436
1491
|
let r = await t.getObjectSchema(n.childObject);
|
|
1437
1492
|
if (n.relationshipField && n.columns?.length) return {
|
|
1438
1493
|
...n,
|
|
1439
|
-
columns:
|
|
1494
|
+
columns: Ft(n.columns, r)
|
|
1440
1495
|
};
|
|
1441
|
-
let i =
|
|
1496
|
+
let i = Ut(n.childObject, r, e.objectName, {
|
|
1442
1497
|
relationshipField: n.relationshipField,
|
|
1443
1498
|
columns: n.columns,
|
|
1444
1499
|
amountField: n.amountField
|
|
@@ -1465,11 +1520,11 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1465
1520
|
e.objectName,
|
|
1466
1521
|
e.details
|
|
1467
1522
|
]);
|
|
1468
|
-
let [
|
|
1523
|
+
let [m, h] = c(() => a.map(() => ({
|
|
1469
1524
|
rows: [],
|
|
1470
1525
|
original: []
|
|
1471
|
-
}))), _ = s(
|
|
1472
|
-
_.current =
|
|
1526
|
+
}))), _ = s(m);
|
|
1527
|
+
_.current = m;
|
|
1473
1528
|
let v = s({});
|
|
1474
1529
|
i(() => {
|
|
1475
1530
|
let e = t;
|
|
@@ -1522,7 +1577,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1522
1577
|
};
|
|
1523
1578
|
}
|
|
1524
1579
|
}));
|
|
1525
|
-
n ||
|
|
1580
|
+
n || h(r);
|
|
1526
1581
|
})(), () => {
|
|
1527
1582
|
n = !0;
|
|
1528
1583
|
};
|
|
@@ -1533,20 +1588,20 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1533
1588
|
d
|
|
1534
1589
|
]);
|
|
1535
1590
|
let E = n((e, t) => {
|
|
1536
|
-
|
|
1591
|
+
h((n) => n.map((n, r) => r === e ? {
|
|
1537
1592
|
...n,
|
|
1538
1593
|
rows: t
|
|
1539
1594
|
} : n));
|
|
1540
|
-
}, []), D = e.taxRateField || "tax_rate", [O, k] = c(null), A = O ?
|
|
1541
|
-
|
|
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 ? {
|
|
1542
1597
|
...r,
|
|
1543
1598
|
rows: r.rows.map((e, r) => r === t ? {
|
|
1544
1599
|
...e,
|
|
1545
1600
|
...n
|
|
1546
1601
|
} : e)
|
|
1547
1602
|
} : r));
|
|
1548
|
-
}, []),
|
|
1549
|
-
|
|
1603
|
+
}, []), N = n((e) => {
|
|
1604
|
+
h((t) => {
|
|
1550
1605
|
let n = t.map((t, n) => n === e ? {
|
|
1551
1606
|
...t,
|
|
1552
1607
|
rows: [...t.rows, {}]
|
|
@@ -1557,13 +1612,13 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1557
1612
|
isNew: !0
|
|
1558
1613
|
}), n;
|
|
1559
1614
|
});
|
|
1560
|
-
}, []),
|
|
1561
|
-
k((e) => (e?.isNew &&
|
|
1615
|
+
}, []), P = n(() => {
|
|
1616
|
+
k((e) => (e?.isNew && h((t) => t.map((t, n) => n === e.detailIdx ? {
|
|
1562
1617
|
...t,
|
|
1563
1618
|
rows: t.rows.filter((t, n) => n !== e.rowIdx)
|
|
1564
1619
|
} : t)), null));
|
|
1565
|
-
}, []),
|
|
1566
|
-
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(() => ({
|
|
1567
1622
|
rows: [],
|
|
1568
1623
|
original: []
|
|
1569
1624
|
}))), b((e) => e + 1)), await e.onSuccess?.(t);
|
|
@@ -1574,26 +1629,26 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1574
1629
|
p.length,
|
|
1575
1630
|
T
|
|
1576
1631
|
]), ee = n((t) => {
|
|
1577
|
-
T(),
|
|
1578
|
-
}, [e, T]),
|
|
1632
|
+
T(), X.error(t?.message || "Save failed"), e.onError?.(t);
|
|
1633
|
+
}, [e, T]), z = n(async (n) => {
|
|
1579
1634
|
if (!t) throw Error("MasterDetailForm: dataSource is required");
|
|
1580
1635
|
let r = { ...n };
|
|
1581
1636
|
p.forEach((e, t) => {
|
|
1582
|
-
e.totalField && (r[e.totalField] =
|
|
1637
|
+
e.totalField && (r[e.totalField] = xt(_.current[t]?.rows ?? [], e.amountField || "amount"));
|
|
1583
1638
|
});
|
|
1584
|
-
let i = l ?
|
|
1639
|
+
let i = l ? yt(e.objectName, String(e.recordId), r, p.filter((e) => e.relationshipField).map((e, t) => ({
|
|
1585
1640
|
childObject: e.childObject,
|
|
1586
1641
|
relationshipField: e.relationshipField,
|
|
1587
1642
|
rows: _.current[t]?.rows ?? [],
|
|
1588
1643
|
original: _.current[t]?.original ?? [],
|
|
1589
1644
|
childSchema: v.current[e.childObject]
|
|
1590
|
-
}))) :
|
|
1645
|
+
}))) : vt(e.objectName, r, p.filter((e) => e.relationshipField).map((e, t) => ({
|
|
1591
1646
|
childObject: e.childObject,
|
|
1592
1647
|
relationshipField: e.relationshipField,
|
|
1593
1648
|
rows: _.current[t]?.rows ?? [],
|
|
1594
1649
|
childSchema: v.current[e.childObject]
|
|
1595
1650
|
})));
|
|
1596
|
-
return (await
|
|
1651
|
+
return (await g(t, i))?.results?.[0] ?? {
|
|
1597
1652
|
...r,
|
|
1598
1653
|
id: e.recordId
|
|
1599
1654
|
};
|
|
@@ -1616,15 +1671,15 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1616
1671
|
title: e.title,
|
|
1617
1672
|
showSubmit: !1,
|
|
1618
1673
|
showCancel: !1,
|
|
1619
|
-
submitHandler:
|
|
1620
|
-
onSuccess:
|
|
1674
|
+
submitHandler: z,
|
|
1675
|
+
onSuccess: F,
|
|
1621
1676
|
onError: ee
|
|
1622
1677
|
}), [
|
|
1623
1678
|
e,
|
|
1624
|
-
|
|
1625
|
-
|
|
1679
|
+
z,
|
|
1680
|
+
F,
|
|
1626
1681
|
ee
|
|
1627
|
-
]), U = s(null),
|
|
1682
|
+
]), U = s(null), W = e.submitText ?? (l ? "Save" : "Create"), G = n(() => {
|
|
1628
1683
|
C.current || U.current?.querySelector("form") && (C.current = !0, S(!0), setTimeout(() => {
|
|
1629
1684
|
(U.current?.querySelector("form"))?.requestSubmit();
|
|
1630
1685
|
}, 0), w.current = setTimeout(() => T(), 1500));
|
|
@@ -1632,18 +1687,18 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1632
1687
|
return i(() => () => {
|
|
1633
1688
|
w.current && clearTimeout(w.current);
|
|
1634
1689
|
}, []), /* @__PURE__ */ $("div", {
|
|
1635
|
-
className:
|
|
1690
|
+
className: Y("space-y-6", r, e.className),
|
|
1636
1691
|
children: [
|
|
1637
1692
|
/* @__PURE__ */ Q("div", {
|
|
1638
1693
|
ref: U,
|
|
1639
|
-
children: /* @__PURE__ */ Q(
|
|
1694
|
+
children: /* @__PURE__ */ Q(tn, {
|
|
1640
1695
|
schema: H,
|
|
1641
1696
|
dataSource: t
|
|
1642
1697
|
}, y)
|
|
1643
1698
|
}),
|
|
1644
|
-
/* @__PURE__ */ Q(
|
|
1699
|
+
/* @__PURE__ */ Q(Gt, {
|
|
1645
1700
|
details: p,
|
|
1646
|
-
state:
|
|
1701
|
+
state: m,
|
|
1647
1702
|
setRows: E,
|
|
1648
1703
|
formHostRef: U,
|
|
1649
1704
|
taxRateField: D,
|
|
@@ -1652,29 +1707,29 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1652
1707
|
detailIdx: e,
|
|
1653
1708
|
rowIdx: t
|
|
1654
1709
|
}),
|
|
1655
|
-
onAddViaForm:
|
|
1710
|
+
onAddViaForm: N
|
|
1656
1711
|
}),
|
|
1657
|
-
O && j && /* @__PURE__ */ $(
|
|
1712
|
+
O && j && /* @__PURE__ */ $(L, {
|
|
1658
1713
|
className: "border-primary/40 shadow-none ring-1 ring-primary/10",
|
|
1659
1714
|
"data-testid": "md-row-form",
|
|
1660
|
-
children: [/* @__PURE__ */ $(
|
|
1715
|
+
children: [/* @__PURE__ */ $(B, {
|
|
1661
1716
|
className: "pb-2 flex flex-row items-center justify-between gap-2 space-y-0",
|
|
1662
|
-
children: [/* @__PURE__ */ $(
|
|
1717
|
+
children: [/* @__PURE__ */ $(V, {
|
|
1663
1718
|
className: "text-sm font-medium",
|
|
1664
1719
|
children: [
|
|
1665
1720
|
j.title || "Line item",
|
|
1666
1721
|
" — row ",
|
|
1667
1722
|
O.rowIdx + 1
|
|
1668
1723
|
]
|
|
1669
|
-
}), /* @__PURE__ */ Q(
|
|
1724
|
+
}), /* @__PURE__ */ Q(I, {
|
|
1670
1725
|
type: "button",
|
|
1671
1726
|
variant: "ghost",
|
|
1672
1727
|
size: "sm",
|
|
1673
1728
|
className: "h-7 text-xs text-muted-foreground",
|
|
1674
|
-
onClick:
|
|
1729
|
+
onClick: P,
|
|
1675
1730
|
children: "Close"
|
|
1676
1731
|
})]
|
|
1677
|
-
}), /* @__PURE__ */ Q(
|
|
1732
|
+
}), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q(tn, {
|
|
1678
1733
|
schema: {
|
|
1679
1734
|
type: "object-form",
|
|
1680
1735
|
objectName: j.childObject,
|
|
@@ -1686,42 +1741,43 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1686
1741
|
onSuccess: (e) => {
|
|
1687
1742
|
M(O.detailIdx, O.rowIdx, e), k(null);
|
|
1688
1743
|
},
|
|
1689
|
-
onCancel:
|
|
1744
|
+
onCancel: P
|
|
1690
1745
|
},
|
|
1691
1746
|
dataSource: t
|
|
1692
1747
|
}, `row-${O.detailIdx}-${O.rowIdx}`) })]
|
|
1693
1748
|
}),
|
|
1694
1749
|
e.showSubmit !== !1 && /* @__PURE__ */ $("div", {
|
|
1695
1750
|
className: "flex items-center justify-end gap-2 border-t border-border pt-4",
|
|
1696
|
-
children: [e.onCancel && /* @__PURE__ */ Q(
|
|
1751
|
+
children: [e.onCancel && /* @__PURE__ */ Q(I, {
|
|
1697
1752
|
type: "button",
|
|
1698
1753
|
variant: "outline",
|
|
1699
1754
|
onClick: e.onCancel,
|
|
1700
1755
|
disabled: x,
|
|
1701
1756
|
"data-testid": "md-form-cancel",
|
|
1702
1757
|
children: e.cancelText ?? "Cancel"
|
|
1703
|
-
}), /* @__PURE__ */ Q(
|
|
1758
|
+
}), /* @__PURE__ */ Q(I, {
|
|
1704
1759
|
type: "button",
|
|
1705
|
-
onClick:
|
|
1760
|
+
onClick: G,
|
|
1706
1761
|
disabled: x || u && !d,
|
|
1707
1762
|
"data-testid": "md-form-submit",
|
|
1708
|
-
children: x ? "Saving…" :
|
|
1763
|
+
children: x ? "Saving…" : W
|
|
1709
1764
|
})]
|
|
1710
1765
|
})
|
|
1711
1766
|
]
|
|
1712
1767
|
});
|
|
1713
|
-
},
|
|
1768
|
+
}, qt = {
|
|
1714
1769
|
1: void 0,
|
|
1715
1770
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
1716
1771
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
1717
1772
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
1718
|
-
},
|
|
1773
|
+
}, Jt = ye({
|
|
1719
1774
|
"form.discardTitle": "Discard changes?",
|
|
1720
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.",
|
|
1721
1777
|
"form.keepEditing": "Keep editing",
|
|
1722
1778
|
"form.discard": "Discard"
|
|
1723
|
-
}, "form.discardTitle"),
|
|
1724
|
-
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(() => {
|
|
1725
1781
|
let t = {};
|
|
1726
1782
|
return e.sections?.forEach((e, n) => {
|
|
1727
1783
|
let r = e.name || String(n);
|
|
@@ -1731,14 +1787,14 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1731
1787
|
i(() => {
|
|
1732
1788
|
(async () => {
|
|
1733
1789
|
if (!t) {
|
|
1734
|
-
|
|
1790
|
+
b(!1);
|
|
1735
1791
|
return;
|
|
1736
1792
|
}
|
|
1737
1793
|
try {
|
|
1738
1794
|
let n = await t.getObjectSchema(e.objectName);
|
|
1739
1795
|
p(n);
|
|
1740
1796
|
} catch (e) {
|
|
1741
|
-
|
|
1797
|
+
w(e), b(!1);
|
|
1742
1798
|
}
|
|
1743
1799
|
})();
|
|
1744
1800
|
}, [e.objectName, t]);
|
|
@@ -1747,23 +1803,23 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1747
1803
|
let n = !1;
|
|
1748
1804
|
return (f || !t) && (async () => {
|
|
1749
1805
|
if (e.mode === "create" || !e.recordId) {
|
|
1750
|
-
|
|
1806
|
+
_(ke(f, e.initialData || e.initialValues)), b(!1);
|
|
1751
1807
|
return;
|
|
1752
1808
|
}
|
|
1753
1809
|
if (!t) {
|
|
1754
|
-
|
|
1810
|
+
_(e.initialData || e.initialValues || {}), b(!1);
|
|
1755
1811
|
return;
|
|
1756
1812
|
}
|
|
1757
|
-
oe.current !== e.recordId && (
|
|
1813
|
+
oe.current !== e.recordId && (b(!0), D(!1));
|
|
1758
1814
|
try {
|
|
1759
1815
|
let r = await t.findOne(e.objectName, e.recordId);
|
|
1760
1816
|
if (n) return;
|
|
1761
|
-
oe.current = e.recordId,
|
|
1817
|
+
oe.current = e.recordId, _(r || {});
|
|
1762
1818
|
} catch (e) {
|
|
1763
1819
|
if (n) return;
|
|
1764
|
-
|
|
1820
|
+
w(e);
|
|
1765
1821
|
} finally {
|
|
1766
|
-
n ||
|
|
1822
|
+
n || b(!1);
|
|
1767
1823
|
}
|
|
1768
1824
|
})(), () => {
|
|
1769
1825
|
n = !0;
|
|
@@ -1777,27 +1833,29 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1777
1833
|
t,
|
|
1778
1834
|
e.objectName
|
|
1779
1835
|
]);
|
|
1780
|
-
let se = n((t) =>
|
|
1836
|
+
let se = n((t) => Ie(t, {
|
|
1781
1837
|
objectSchema: f,
|
|
1782
1838
|
objectName: e.objectName,
|
|
1783
1839
|
readOnly: e.readOnly,
|
|
1784
1840
|
mode: e.mode,
|
|
1841
|
+
recordId: e.recordId,
|
|
1785
1842
|
fieldLabel: l
|
|
1786
1843
|
}), [
|
|
1787
1844
|
f,
|
|
1788
1845
|
e.readOnly,
|
|
1789
1846
|
e.mode,
|
|
1847
|
+
e.recordId,
|
|
1790
1848
|
e.objectName,
|
|
1791
1849
|
l
|
|
1792
1850
|
]);
|
|
1793
1851
|
i(() => {
|
|
1794
1852
|
if (!f && t) return;
|
|
1795
1853
|
if (e.customFields?.length) {
|
|
1796
|
-
|
|
1854
|
+
h(e.customFields), b(!1);
|
|
1797
1855
|
return;
|
|
1798
1856
|
}
|
|
1799
1857
|
if (e.sections?.length) {
|
|
1800
|
-
|
|
1858
|
+
b(!1);
|
|
1801
1859
|
return;
|
|
1802
1860
|
}
|
|
1803
1861
|
if (!f) return;
|
|
@@ -1809,18 +1867,18 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1809
1867
|
i && r.push({
|
|
1810
1868
|
name: n,
|
|
1811
1869
|
label: l(e.objectName, n, i.label || n),
|
|
1812
|
-
type:
|
|
1813
|
-
required: i
|
|
1870
|
+
type: O(i.type, { multiple: i.multiple }),
|
|
1871
|
+
required: De(i, Ee(e)),
|
|
1814
1872
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
1815
1873
|
placeholder: i.placeholder,
|
|
1816
1874
|
description: i.help || i.description,
|
|
1817
|
-
validation:
|
|
1875
|
+
validation: E(i),
|
|
1818
1876
|
field: i,
|
|
1819
1877
|
options: i.options,
|
|
1820
1878
|
multiple: i.multiple
|
|
1821
1879
|
});
|
|
1822
1880
|
}
|
|
1823
|
-
|
|
1881
|
+
h(r), b(!1);
|
|
1824
1882
|
}, [
|
|
1825
1883
|
f,
|
|
1826
1884
|
e.fields,
|
|
@@ -1834,15 +1892,15 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1834
1892
|
H(!0);
|
|
1835
1893
|
try {
|
|
1836
1894
|
if (!t) return e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
1837
|
-
let r, i =
|
|
1838
|
-
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));
|
|
1839
1897
|
else if (e.mode === "edit" && e.recordId) {
|
|
1840
|
-
let n = await
|
|
1898
|
+
let n = await z({
|
|
1841
1899
|
dataSource: t,
|
|
1842
1900
|
objectName: e.objectName,
|
|
1843
1901
|
recordId: e.recordId,
|
|
1844
1902
|
payload: i,
|
|
1845
|
-
baseRecord:
|
|
1903
|
+
baseRecord: g
|
|
1846
1904
|
});
|
|
1847
1905
|
if (n.status === "cancelled") return;
|
|
1848
1906
|
r = n.result;
|
|
@@ -1857,65 +1915,65 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1857
1915
|
e,
|
|
1858
1916
|
t,
|
|
1859
1917
|
f,
|
|
1860
|
-
|
|
1861
|
-
|
|
1918
|
+
z,
|
|
1919
|
+
g
|
|
1862
1920
|
]), Z = n(() => {
|
|
1863
|
-
|
|
1921
|
+
R(!1), U.current && (U.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
|
|
1864
1922
|
}, [e]), le = n((e) => {
|
|
1865
|
-
|
|
1923
|
+
U.current = e, W && T ? R(!0) : Z();
|
|
1866
1924
|
}, [
|
|
1867
|
-
|
|
1868
|
-
|
|
1925
|
+
W,
|
|
1926
|
+
T,
|
|
1869
1927
|
Z
|
|
1870
1928
|
]);
|
|
1871
1929
|
i(() => {
|
|
1872
|
-
if (!
|
|
1930
|
+
if (!G || !T || !W) return;
|
|
1873
1931
|
let e = (e) => {
|
|
1874
1932
|
e.preventDefault(), e.returnValue = "";
|
|
1875
1933
|
};
|
|
1876
1934
|
return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
1877
1935
|
}, [
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1936
|
+
G,
|
|
1937
|
+
T,
|
|
1938
|
+
W
|
|
1881
1939
|
]);
|
|
1882
|
-
let
|
|
1883
|
-
|
|
1884
|
-
}, [Z]),
|
|
1885
|
-
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" ? {
|
|
1886
1944
|
width: e.drawerWidth,
|
|
1887
1945
|
maxWidth: e.drawerWidth
|
|
1888
1946
|
} : {
|
|
1889
1947
|
height: e.drawerWidth,
|
|
1890
1948
|
maxHeight: e.drawerWidth
|
|
1891
1949
|
};
|
|
1892
|
-
}, [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 = {
|
|
1893
1951
|
type: "form",
|
|
1894
1952
|
objectName: e.objectName,
|
|
1895
|
-
layout:
|
|
1896
|
-
defaultValues:
|
|
1897
|
-
previousValues: e.mode === "edit" && e.recordId ?
|
|
1898
|
-
submitLabel:
|
|
1953
|
+
layout: fe,
|
|
1954
|
+
defaultValues: g,
|
|
1955
|
+
previousValues: e.mode === "edit" && e.recordId ? g : void 0,
|
|
1956
|
+
submitLabel: he,
|
|
1899
1957
|
cancelLabel: _e,
|
|
1900
|
-
showSubmit:
|
|
1901
|
-
showCancel:
|
|
1958
|
+
showSubmit: pe,
|
|
1959
|
+
showCancel: me,
|
|
1902
1960
|
onSubmit: ce,
|
|
1903
|
-
onCancel:
|
|
1904
|
-
onDirtyChange:
|
|
1961
|
+
onCancel: ue,
|
|
1962
|
+
onDirtyChange: D,
|
|
1905
1963
|
showActions: !1,
|
|
1906
1964
|
id: ie
|
|
1907
1965
|
}, ye = () => {
|
|
1908
|
-
if (
|
|
1966
|
+
if (S) return /* @__PURE__ */ $("div", {
|
|
1909
1967
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1910
1968
|
children: [/* @__PURE__ */ Q("h3", {
|
|
1911
1969
|
className: "text-red-800 font-semibold",
|
|
1912
1970
|
children: "Error loading form"
|
|
1913
1971
|
}), /* @__PURE__ */ Q("p", {
|
|
1914
1972
|
className: "text-red-600 text-sm mt-1",
|
|
1915
|
-
children:
|
|
1973
|
+
children: S.message
|
|
1916
1974
|
})]
|
|
1917
1975
|
});
|
|
1918
|
-
if (
|
|
1976
|
+
if (v) return /* @__PURE__ */ $("div", {
|
|
1919
1977
|
className: "p-8 text-center",
|
|
1920
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", {
|
|
1921
1979
|
className: "mt-2 text-sm text-gray-600",
|
|
@@ -1944,19 +2002,19 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1944
2002
|
...e,
|
|
1945
2003
|
hidden: !0
|
|
1946
2004
|
}))) : t.push(...a);
|
|
1947
|
-
}), /* @__PURE__ */ Q(
|
|
2005
|
+
}), /* @__PURE__ */ Q(y, { schema: {
|
|
1948
2006
|
...ve,
|
|
1949
2007
|
fields: t
|
|
1950
2008
|
} });
|
|
1951
2009
|
}
|
|
1952
|
-
let t =
|
|
1953
|
-
return /* @__PURE__ */ Q(
|
|
2010
|
+
let t = $e(m, f, e.columns, e.mode), n = qt[t.columns || 1];
|
|
2011
|
+
return /* @__PURE__ */ Q(y, { schema: {
|
|
1954
2012
|
...ve,
|
|
1955
2013
|
fields: t.fields,
|
|
1956
2014
|
columns: t.columns,
|
|
1957
2015
|
...n ? { fieldContainerClass: n } : {}
|
|
1958
2016
|
} });
|
|
1959
|
-
}, be = e.subforms, xe = be?.length && e.mode !== "view" ? /* @__PURE__ */ Q(
|
|
2017
|
+
}, be = e.subforms, xe = be?.length && e.mode !== "view" ? /* @__PURE__ */ Q(Kt, {
|
|
1960
2018
|
schema: {
|
|
1961
2019
|
type: "object-master-detail-form",
|
|
1962
2020
|
objectName: e.objectName,
|
|
@@ -1987,8 +2045,8 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1987
2045
|
children: e.description
|
|
1988
2046
|
})]
|
|
1989
2047
|
}), xe]
|
|
1990
|
-
}) : /* @__PURE__ */ Q(
|
|
1991
|
-
open:
|
|
2048
|
+
}) : /* @__PURE__ */ Q(te, {
|
|
2049
|
+
open: G,
|
|
1992
2050
|
onOpenChange: (t) => {
|
|
1993
2051
|
if (t) {
|
|
1994
2052
|
e.onOpenChange?.(!0);
|
|
@@ -1996,62 +2054,62 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1996
2054
|
}
|
|
1997
2055
|
le(!1);
|
|
1998
2056
|
},
|
|
1999
|
-
children: /* @__PURE__ */ $(
|
|
2000
|
-
side:
|
|
2001
|
-
className:
|
|
2002
|
-
style:
|
|
2057
|
+
children: /* @__PURE__ */ $(ne, {
|
|
2058
|
+
side: K,
|
|
2059
|
+
className: Y("overflow-y-auto", r, e.className),
|
|
2060
|
+
style: de,
|
|
2003
2061
|
children: [
|
|
2004
|
-
(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, {
|
|
2005
2063
|
className: "sr-only",
|
|
2006
|
-
children: "
|
|
2064
|
+
children: u("form.dialogDescriptionFallback")
|
|
2007
2065
|
})] }),
|
|
2008
2066
|
/* @__PURE__ */ Q("div", {
|
|
2009
2067
|
className: "@container py-4",
|
|
2010
2068
|
children: xe
|
|
2011
2069
|
}),
|
|
2012
|
-
!
|
|
2070
|
+
!S && !v && !(be?.length && e.mode !== "view") && (pe || me) && /* @__PURE__ */ Q("div", {
|
|
2013
2071
|
className: "shrink-0 border-t px-4 py-3 bg-background",
|
|
2014
2072
|
"data-testid": "drawer-form-footer",
|
|
2015
2073
|
children: /* @__PURE__ */ $("div", {
|
|
2016
2074
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
2017
|
-
children: [
|
|
2075
|
+
children: [me && /* @__PURE__ */ Q(I, {
|
|
2018
2076
|
type: "button",
|
|
2019
2077
|
variant: "outline",
|
|
2020
|
-
onClick:
|
|
2078
|
+
onClick: ue,
|
|
2021
2079
|
disabled: V,
|
|
2022
2080
|
className: "w-full sm:w-auto",
|
|
2023
2081
|
children: _e
|
|
2024
|
-
}),
|
|
2082
|
+
}), pe && /* @__PURE__ */ $(I, {
|
|
2025
2083
|
type: "submit",
|
|
2026
2084
|
form: ie,
|
|
2027
2085
|
disabled: V,
|
|
2028
2086
|
className: "w-full sm:w-auto",
|
|
2029
|
-
children: [V && /* @__PURE__ */ Q(
|
|
2087
|
+
children: [V && /* @__PURE__ */ Q(ge, { className: "mr-2 h-4 w-4 animate-spin" }), he]
|
|
2030
2088
|
})]
|
|
2031
2089
|
})
|
|
2032
2090
|
}),
|
|
2033
|
-
/* @__PURE__ */ Q(
|
|
2034
|
-
open:
|
|
2035
|
-
onOpenChange:
|
|
2036
|
-
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, {
|
|
2037
2095
|
onClick: () => {
|
|
2038
|
-
|
|
2096
|
+
U.current = !1;
|
|
2039
2097
|
},
|
|
2040
2098
|
children: u("form.keepEditing")
|
|
2041
|
-
}), /* @__PURE__ */ Q(
|
|
2099
|
+
}), /* @__PURE__ */ Q(A, {
|
|
2042
2100
|
onClick: Z,
|
|
2043
2101
|
children: u("form.discard")
|
|
2044
2102
|
})] })] })
|
|
2045
2103
|
}),
|
|
2046
|
-
|
|
2104
|
+
B
|
|
2047
2105
|
]
|
|
2048
2106
|
})
|
|
2049
2107
|
});
|
|
2050
2108
|
};
|
|
2051
2109
|
//#endregion
|
|
2052
2110
|
//#region src/fieldGroups.ts
|
|
2053
|
-
function
|
|
2054
|
-
let n =
|
|
2111
|
+
function Xt(e, t) {
|
|
2112
|
+
let n = ce({
|
|
2055
2113
|
fieldGroups: t,
|
|
2056
2114
|
fields: Object.fromEntries(e.map((e) => [e.name, { group: e.group }]))
|
|
2057
2115
|
});
|
|
@@ -2071,19 +2129,20 @@ function Lt(e, t) {
|
|
|
2071
2129
|
}
|
|
2072
2130
|
//#endregion
|
|
2073
2131
|
//#region src/ModalForm.tsx
|
|
2074
|
-
var
|
|
2132
|
+
var Zt = ye({
|
|
2075
2133
|
"form.discardTitle": "Discard changes?",
|
|
2076
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.",
|
|
2077
2136
|
"form.keepEditing": "Keep editing",
|
|
2078
2137
|
"form.discard": "Discard"
|
|
2079
|
-
}, "form.discardTitle"),
|
|
2138
|
+
}, "form.discardTitle"), Qt = {
|
|
2080
2139
|
sm: "sm:max-w-sm",
|
|
2081
2140
|
default: "sm:max-w-lg",
|
|
2082
2141
|
lg: "sm:max-w-2xl",
|
|
2083
2142
|
xl: "sm:max-w-5xl",
|
|
2084
2143
|
full: "sm:max-w-[95vw] sm:w-full"
|
|
2085
|
-
},
|
|
2086
|
-
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) => {
|
|
2087
2146
|
if (!p?.isLoaded) return t;
|
|
2088
2147
|
let n = [];
|
|
2089
2148
|
for (let r of t) {
|
|
@@ -2102,13 +2161,13 @@ var Rt = pe({
|
|
|
2102
2161
|
p,
|
|
2103
2162
|
e.objectName,
|
|
2104
2163
|
e.mode
|
|
2105
|
-
]), [
|
|
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(() => {
|
|
2106
2165
|
if (e.sections?.length || e.customFields?.length) return null;
|
|
2107
|
-
let t =
|
|
2108
|
-
e.mode === "create" && (t =
|
|
2109
|
-
let n =
|
|
2166
|
+
let t = qe(_, h);
|
|
2167
|
+
e.mode === "create" && (t = Ye(t, h));
|
|
2168
|
+
let n = Xt(t, h?.fieldGroups);
|
|
2110
2169
|
if (!n) return null;
|
|
2111
|
-
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);
|
|
2112
2171
|
return n.map((e) => ({
|
|
2113
2172
|
...e,
|
|
2114
2173
|
columns: r
|
|
@@ -2118,70 +2177,70 @@ var Rt = pe({
|
|
|
2118
2177
|
e.customFields,
|
|
2119
2178
|
e.columns,
|
|
2120
2179
|
e.mode,
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
]), Z = e.sections?.length ? e.sections : ce ?? void 0, le = o(() => Z?.length || e.customFields?.length ? null :
|
|
2124
|
-
|
|
2125
|
-
|
|
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,
|
|
2126
2185
|
e.columns,
|
|
2127
2186
|
e.mode,
|
|
2128
2187
|
Z,
|
|
2129
2188
|
e.customFields
|
|
2130
|
-
]),
|
|
2189
|
+
]), ue = Qt[o(() => {
|
|
2131
2190
|
if (e.modalSize) return e.modalSize;
|
|
2132
|
-
if (le?.columns && le.columns > 1) return
|
|
2191
|
+
if (le?.columns && le.columns > 1) return Qe(le.columns);
|
|
2133
2192
|
if (Z?.length) {
|
|
2134
2193
|
let e = Math.max(...Z.map((e) => Number(e.columns) || 1));
|
|
2135
|
-
if (e > 1) return
|
|
2194
|
+
if (e > 1) return Qe(e);
|
|
2136
2195
|
}
|
|
2137
2196
|
return "default";
|
|
2138
2197
|
}, [
|
|
2139
2198
|
e.modalSize,
|
|
2140
2199
|
le,
|
|
2141
2200
|
Z
|
|
2142
|
-
])] ||
|
|
2201
|
+
])] || Qt.default;
|
|
2143
2202
|
i(() => {
|
|
2144
2203
|
(async () => {
|
|
2145
2204
|
if (!t) {
|
|
2146
|
-
|
|
2205
|
+
T(!1);
|
|
2147
2206
|
return;
|
|
2148
2207
|
}
|
|
2149
2208
|
try {
|
|
2150
2209
|
let n = await t.getObjectSchema(e.objectName);
|
|
2151
|
-
|
|
2210
|
+
g(n);
|
|
2152
2211
|
} catch (e) {
|
|
2153
|
-
|
|
2212
|
+
L(e), T(!1);
|
|
2154
2213
|
}
|
|
2155
2214
|
})();
|
|
2156
2215
|
}, [e.objectName, t]);
|
|
2157
|
-
let
|
|
2216
|
+
let de = s(void 0);
|
|
2158
2217
|
i(() => {
|
|
2159
2218
|
let n = !1;
|
|
2160
|
-
return (
|
|
2219
|
+
return (h || !t) && (async () => {
|
|
2161
2220
|
if (e.mode === "create" || !e.recordId) {
|
|
2162
|
-
|
|
2221
|
+
S(ke(h, e.initialData || e.initialValues)), T(!1);
|
|
2163
2222
|
return;
|
|
2164
2223
|
}
|
|
2165
2224
|
if (!t) {
|
|
2166
|
-
|
|
2225
|
+
S(e.initialData || e.initialValues || {}), T(!1);
|
|
2167
2226
|
return;
|
|
2168
2227
|
}
|
|
2169
|
-
|
|
2228
|
+
de.current !== e.recordId && (T(!0), V(!1));
|
|
2170
2229
|
try {
|
|
2171
2230
|
let r = await t.findOne(e.objectName, e.recordId);
|
|
2172
2231
|
if (n) return;
|
|
2173
|
-
|
|
2232
|
+
de.current = e.recordId, S(r || {});
|
|
2174
2233
|
} catch (e) {
|
|
2175
2234
|
if (n) return;
|
|
2176
|
-
|
|
2235
|
+
L(e);
|
|
2177
2236
|
} finally {
|
|
2178
|
-
n ||
|
|
2237
|
+
n || T(!1);
|
|
2179
2238
|
}
|
|
2180
2239
|
})(), () => {
|
|
2181
2240
|
n = !0;
|
|
2182
2241
|
};
|
|
2183
2242
|
}, [
|
|
2184
|
-
|
|
2243
|
+
h,
|
|
2185
2244
|
e.mode,
|
|
2186
2245
|
e.recordId,
|
|
2187
2246
|
e.initialData,
|
|
@@ -2189,44 +2248,46 @@ var Rt = pe({
|
|
|
2189
2248
|
t,
|
|
2190
2249
|
e.objectName
|
|
2191
2250
|
]);
|
|
2192
|
-
let
|
|
2193
|
-
objectSchema:
|
|
2251
|
+
let fe = n((t) => Ie(t, {
|
|
2252
|
+
objectSchema: h,
|
|
2194
2253
|
objectName: e.objectName,
|
|
2195
2254
|
readOnly: e.readOnly,
|
|
2196
2255
|
mode: e.mode,
|
|
2256
|
+
recordId: e.recordId,
|
|
2197
2257
|
fieldLabel: l
|
|
2198
2258
|
}), [
|
|
2199
|
-
|
|
2259
|
+
h,
|
|
2200
2260
|
e.readOnly,
|
|
2201
2261
|
e.mode,
|
|
2262
|
+
e.recordId,
|
|
2202
2263
|
e.objectName,
|
|
2203
2264
|
l
|
|
2204
2265
|
]);
|
|
2205
2266
|
i(() => {
|
|
2206
|
-
if (!
|
|
2267
|
+
if (!h && t) return;
|
|
2207
2268
|
if (e.customFields?.length) {
|
|
2208
|
-
|
|
2269
|
+
v(e.customFields), T(!1);
|
|
2209
2270
|
return;
|
|
2210
2271
|
}
|
|
2211
2272
|
if (e.sections?.length) {
|
|
2212
|
-
|
|
2273
|
+
T(!1);
|
|
2213
2274
|
return;
|
|
2214
2275
|
}
|
|
2215
|
-
if (!
|
|
2216
|
-
let n = e.fields || Object.keys(
|
|
2276
|
+
if (!h) return;
|
|
2277
|
+
let n = e.fields || Object.keys(h.fields || {}), r = [];
|
|
2217
2278
|
for (let t of n) {
|
|
2218
2279
|
let n = typeof t == "string" ? t : t.name;
|
|
2219
2280
|
if (!n) continue;
|
|
2220
|
-
let i =
|
|
2281
|
+
let i = h.fields?.[n];
|
|
2221
2282
|
i && r.push({
|
|
2222
2283
|
name: n,
|
|
2223
2284
|
label: l(e.objectName, n, i.label || n),
|
|
2224
|
-
type:
|
|
2225
|
-
required: i
|
|
2285
|
+
type: O(i.type, { multiple: i.multiple }),
|
|
2286
|
+
required: De(i, Ee(e)),
|
|
2226
2287
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
2227
2288
|
placeholder: i.placeholder,
|
|
2228
2289
|
description: i.help || i.description,
|
|
2229
|
-
validation:
|
|
2290
|
+
validation: E(i),
|
|
2230
2291
|
field: i,
|
|
2231
2292
|
options: i.options,
|
|
2232
2293
|
multiple: i.multiple,
|
|
@@ -2236,9 +2297,9 @@ var Rt = pe({
|
|
|
2236
2297
|
group: i.group
|
|
2237
2298
|
});
|
|
2238
2299
|
}
|
|
2239
|
-
|
|
2300
|
+
v(r), T(!1);
|
|
2240
2301
|
}, [
|
|
2241
|
-
|
|
2302
|
+
h,
|
|
2242
2303
|
e.fields,
|
|
2243
2304
|
e.customFields,
|
|
2244
2305
|
e.sections,
|
|
@@ -2246,24 +2307,24 @@ var Rt = pe({
|
|
|
2246
2307
|
e.mode,
|
|
2247
2308
|
t
|
|
2248
2309
|
]);
|
|
2249
|
-
let
|
|
2250
|
-
|
|
2310
|
+
let pe = n(async (n) => {
|
|
2311
|
+
z(!0);
|
|
2251
2312
|
try {
|
|
2252
2313
|
if (!t) return e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
2253
|
-
let r, i =
|
|
2314
|
+
let r, i = pt(n, h);
|
|
2254
2315
|
if (p?.isLoaded) {
|
|
2255
2316
|
let t = {};
|
|
2256
2317
|
for (let n of Object.keys(i)) p.checkField(e.objectName, n, "write") && (t[n] = i[n]);
|
|
2257
2318
|
i = t;
|
|
2258
2319
|
}
|
|
2259
|
-
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));
|
|
2260
2321
|
else if (e.mode === "edit" && e.recordId) {
|
|
2261
|
-
let n = await
|
|
2322
|
+
let n = await re({
|
|
2262
2323
|
dataSource: t,
|
|
2263
2324
|
objectName: e.objectName,
|
|
2264
2325
|
recordId: e.recordId,
|
|
2265
2326
|
payload: i,
|
|
2266
|
-
baseRecord:
|
|
2327
|
+
baseRecord: b
|
|
2267
2328
|
});
|
|
2268
2329
|
if (n.status === "cancelled") return;
|
|
2269
2330
|
r = n.result;
|
|
@@ -2272,64 +2333,64 @@ var Rt = pe({
|
|
|
2272
2333
|
} catch (t) {
|
|
2273
2334
|
throw e.onError && e.onError(t), t;
|
|
2274
2335
|
} finally {
|
|
2275
|
-
|
|
2336
|
+
z(!1);
|
|
2276
2337
|
}
|
|
2277
2338
|
}, [
|
|
2278
2339
|
e,
|
|
2279
2340
|
t,
|
|
2280
|
-
|
|
2341
|
+
h,
|
|
2281
2342
|
p,
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
]),
|
|
2285
|
-
|
|
2286
|
-
}, [e]),
|
|
2287
|
-
|
|
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();
|
|
2288
2349
|
}, [
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2350
|
+
ae,
|
|
2351
|
+
B,
|
|
2352
|
+
me
|
|
2292
2353
|
]);
|
|
2293
2354
|
i(() => {
|
|
2294
|
-
if (!
|
|
2355
|
+
if (!X || !B || !ae) return;
|
|
2295
2356
|
let e = (e) => {
|
|
2296
2357
|
e.preventDefault(), e.returnValue = "";
|
|
2297
2358
|
};
|
|
2298
2359
|
return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
2299
2360
|
}, [
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2361
|
+
X,
|
|
2362
|
+
B,
|
|
2363
|
+
ae
|
|
2303
2364
|
]);
|
|
2304
2365
|
let _e = n(() => {
|
|
2305
|
-
|
|
2306
|
-
}, [
|
|
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 = {
|
|
2307
2368
|
type: "form",
|
|
2308
2369
|
objectName: e.objectName,
|
|
2309
2370
|
layout: ve,
|
|
2310
|
-
defaultValues:
|
|
2311
|
-
previousValues: e.mode === "edit" && e.recordId ?
|
|
2371
|
+
defaultValues: b,
|
|
2372
|
+
previousValues: e.mode === "edit" && e.recordId ? b : void 0,
|
|
2312
2373
|
submitLabel: xe,
|
|
2313
2374
|
cancelLabel: Se,
|
|
2314
2375
|
showSubmit: ye,
|
|
2315
2376
|
showCancel: be,
|
|
2316
|
-
onSubmit:
|
|
2377
|
+
onSubmit: pe,
|
|
2317
2378
|
onCancel: _e,
|
|
2318
|
-
onDirtyChange:
|
|
2379
|
+
onDirtyChange: V,
|
|
2319
2380
|
showActions: !1,
|
|
2320
|
-
id:
|
|
2321
|
-
},
|
|
2322
|
-
if (
|
|
2381
|
+
id: oe
|
|
2382
|
+
}, we = () => {
|
|
2383
|
+
if (D) return /* @__PURE__ */ $("div", {
|
|
2323
2384
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
2324
2385
|
children: [/* @__PURE__ */ Q("h3", {
|
|
2325
2386
|
className: "text-red-800 font-semibold",
|
|
2326
2387
|
children: "Error loading form"
|
|
2327
2388
|
}), /* @__PURE__ */ Q("p", {
|
|
2328
2389
|
className: "text-red-600 text-sm mt-1",
|
|
2329
|
-
children:
|
|
2390
|
+
children: D.message
|
|
2330
2391
|
})]
|
|
2331
2392
|
});
|
|
2332
|
-
if (
|
|
2393
|
+
if (w) return /* @__PURE__ */ Q("div", {
|
|
2333
2394
|
className: "space-y-4",
|
|
2334
2395
|
"data-testid": "modal-form-skeleton",
|
|
2335
2396
|
children: [
|
|
@@ -2338,26 +2399,26 @@ var Rt = pe({
|
|
|
2338
2399
|
3
|
|
2339
2400
|
].map((e) => /* @__PURE__ */ $("div", {
|
|
2340
2401
|
className: "space-y-2",
|
|
2341
|
-
children: [/* @__PURE__ */ Q(
|
|
2402
|
+
children: [/* @__PURE__ */ Q(ie, { className: "h-4 w-24" }), /* @__PURE__ */ Q(ie, { className: "h-10 w-full" })]
|
|
2342
2403
|
}, e))
|
|
2343
2404
|
});
|
|
2344
2405
|
if (e.sections?.length) {
|
|
2345
|
-
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 =
|
|
2346
|
-
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));
|
|
2347
2408
|
return {
|
|
2348
2409
|
key: n(e, t),
|
|
2349
2410
|
title: r(e),
|
|
2350
2411
|
description: e.description,
|
|
2351
2412
|
className: e.className,
|
|
2352
2413
|
gridClassName: e.gridClassName,
|
|
2353
|
-
fields: o > 1 ?
|
|
2414
|
+
fields: o > 1 ? Ge(a, o, i(e.columns)) : a
|
|
2354
2415
|
};
|
|
2355
2416
|
}).filter((e) => e.fields.length > 0), l = {
|
|
2356
|
-
...
|
|
2417
|
+
...Ce,
|
|
2357
2418
|
columns: o,
|
|
2358
2419
|
...s ? { fieldContainerClass: s } : {}
|
|
2359
2420
|
};
|
|
2360
|
-
if (e.contentLayout === "tabbed" && c.length > 1) return /* @__PURE__ */ Q(
|
|
2421
|
+
if (e.contentLayout === "tabbed" && c.length > 1) return /* @__PURE__ */ Q(y, { schema: {
|
|
2361
2422
|
...l,
|
|
2362
2423
|
fields: c.flatMap((e) => e.fields),
|
|
2363
2424
|
fieldTabs: c.map((e, t) => ({
|
|
@@ -2378,7 +2439,7 @@ var Rt = pe({
|
|
|
2378
2439
|
colSpan: 4,
|
|
2379
2440
|
className: e.className
|
|
2380
2441
|
}), d.push(...e.fields);
|
|
2381
|
-
}), /* @__PURE__ */ Q(
|
|
2442
|
+
}), /* @__PURE__ */ Q(y, { schema: {
|
|
2382
2443
|
...l,
|
|
2383
2444
|
fields: d
|
|
2384
2445
|
} });
|
|
@@ -2386,31 +2447,31 @@ var Rt = pe({
|
|
|
2386
2447
|
if (ce?.length) {
|
|
2387
2448
|
let t = Number(ce[0]?.columns) || 1, n = [];
|
|
2388
2449
|
ce.forEach((r, i) => {
|
|
2389
|
-
let a = m(
|
|
2450
|
+
let a = m(fe(r));
|
|
2390
2451
|
if (!a.length) return;
|
|
2391
2452
|
let o = r.name ? u(e.objectName, r.name, r.label || r.name) : r.label;
|
|
2392
2453
|
o && n.push({
|
|
2393
2454
|
name: `__section_${r.name || i}`,
|
|
2394
2455
|
label: o,
|
|
2395
2456
|
type: "section-divider"
|
|
2396
|
-
}), n.push(...t > 1 ?
|
|
2457
|
+
}), n.push(...t > 1 ? Ge(a, t) : a);
|
|
2397
2458
|
});
|
|
2398
|
-
let r =
|
|
2399
|
-
return /* @__PURE__ */ Q(
|
|
2400
|
-
...
|
|
2459
|
+
let r = Xe[t];
|
|
2460
|
+
return /* @__PURE__ */ Q(y, { schema: {
|
|
2461
|
+
...Ce,
|
|
2401
2462
|
fields: n,
|
|
2402
2463
|
columns: t,
|
|
2403
2464
|
...r ? { fieldContainerClass: r } : {}
|
|
2404
2465
|
} });
|
|
2405
2466
|
}
|
|
2406
|
-
let t = le ??
|
|
2407
|
-
return /* @__PURE__ */ Q(
|
|
2408
|
-
...
|
|
2467
|
+
let t = le ?? $e(_, h, e.columns, e.mode), n = Xe[t.columns || 1];
|
|
2468
|
+
return /* @__PURE__ */ Q(y, { schema: {
|
|
2469
|
+
...Ce,
|
|
2409
2470
|
fields: m(t.fields),
|
|
2410
2471
|
columns: t.columns,
|
|
2411
2472
|
...n ? { fieldContainerClass: n } : {}
|
|
2412
2473
|
} });
|
|
2413
|
-
},
|
|
2474
|
+
}, Te = e.subforms;
|
|
2414
2475
|
if (f) return /* @__PURE__ */ $("div", {
|
|
2415
2476
|
className: "@container rounded-md border bg-card p-4",
|
|
2416
2477
|
children: [(e.title || e.description) && /* @__PURE__ */ $("div", {
|
|
@@ -2422,22 +2483,22 @@ var Rt = pe({
|
|
|
2422
2483
|
className: "text-xs text-muted-foreground",
|
|
2423
2484
|
children: e.description
|
|
2424
2485
|
})]
|
|
2425
|
-
}),
|
|
2486
|
+
}), we()]
|
|
2426
2487
|
});
|
|
2427
|
-
if (
|
|
2428
|
-
open:
|
|
2488
|
+
if (Te?.length && e.mode !== "view") return /* @__PURE__ */ Q(H, {
|
|
2489
|
+
open: X,
|
|
2429
2490
|
onOpenChange: e.onOpenChange,
|
|
2430
|
-
children: /* @__PURE__ */ $(
|
|
2431
|
-
className:
|
|
2432
|
-
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, {
|
|
2433
2494
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
2434
|
-
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, {
|
|
2435
2496
|
className: "sr-only",
|
|
2436
2497
|
children: "Enter the record and its line items, then save."
|
|
2437
2498
|
})]
|
|
2438
2499
|
}), /* @__PURE__ */ Q("div", {
|
|
2439
2500
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
2440
|
-
children: /* @__PURE__ */ Q(
|
|
2501
|
+
children: /* @__PURE__ */ Q(Kt, {
|
|
2441
2502
|
schema: {
|
|
2442
2503
|
type: "object-master-detail-form",
|
|
2443
2504
|
objectName: e.objectName,
|
|
@@ -2449,7 +2510,7 @@ var Rt = pe({
|
|
|
2449
2510
|
initialData: e.initialData,
|
|
2450
2511
|
submitText: xe,
|
|
2451
2512
|
cancelText: Se,
|
|
2452
|
-
details:
|
|
2513
|
+
details: Te,
|
|
2453
2514
|
onSuccess: async (t) => {
|
|
2454
2515
|
await e.onSuccess?.(t), e.onOpenChange?.(!1);
|
|
2455
2516
|
},
|
|
@@ -2461,80 +2522,80 @@ var Rt = pe({
|
|
|
2461
2522
|
})]
|
|
2462
2523
|
})
|
|
2463
2524
|
});
|
|
2464
|
-
let
|
|
2465
|
-
return /* @__PURE__ */ Q(
|
|
2466
|
-
open:
|
|
2525
|
+
let Oe = !w && !D && (ye || be);
|
|
2526
|
+
return /* @__PURE__ */ Q(H, {
|
|
2527
|
+
open: X,
|
|
2467
2528
|
onOpenChange: (t) => {
|
|
2468
2529
|
if (t) {
|
|
2469
2530
|
e.onOpenChange?.(!0);
|
|
2470
2531
|
return;
|
|
2471
2532
|
}
|
|
2472
|
-
|
|
2533
|
+
he(!1);
|
|
2473
2534
|
},
|
|
2474
|
-
children: /* @__PURE__ */ $(
|
|
2475
|
-
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),
|
|
2476
2537
|
children: [
|
|
2477
|
-
(e.title || e.description) && /* @__PURE__ */ $(
|
|
2538
|
+
(e.title || e.description) && /* @__PURE__ */ $(W, {
|
|
2478
2539
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
2479
|
-
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, {
|
|
2480
2541
|
className: "sr-only",
|
|
2481
|
-
children: "
|
|
2542
|
+
children: d("form.dialogDescriptionFallback")
|
|
2482
2543
|
})]
|
|
2483
2544
|
}),
|
|
2484
2545
|
/* @__PURE__ */ Q("div", {
|
|
2485
2546
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
2486
|
-
children:
|
|
2547
|
+
children: we()
|
|
2487
2548
|
}),
|
|
2488
|
-
|
|
2549
|
+
Oe && /* @__PURE__ */ Q("div", {
|
|
2489
2550
|
className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background",
|
|
2490
2551
|
"data-testid": "modal-form-footer",
|
|
2491
2552
|
children: /* @__PURE__ */ $("div", {
|
|
2492
2553
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
2493
|
-
children: [be && /* @__PURE__ */ Q(
|
|
2554
|
+
children: [be && /* @__PURE__ */ Q(I, {
|
|
2494
2555
|
type: "button",
|
|
2495
2556
|
variant: "outline",
|
|
2496
2557
|
onClick: _e,
|
|
2497
|
-
disabled:
|
|
2558
|
+
disabled: R,
|
|
2498
2559
|
className: "w-full sm:w-auto",
|
|
2499
2560
|
children: Se
|
|
2500
|
-
}), ye && /* @__PURE__ */ $(
|
|
2561
|
+
}), ye && /* @__PURE__ */ $(I, {
|
|
2501
2562
|
type: "submit",
|
|
2502
|
-
form:
|
|
2503
|
-
disabled:
|
|
2563
|
+
form: oe,
|
|
2564
|
+
disabled: R,
|
|
2504
2565
|
className: "w-full sm:w-auto",
|
|
2505
|
-
children: [
|
|
2566
|
+
children: [R && /* @__PURE__ */ Q(ge, { className: "mr-2 h-4 w-4 animate-spin" }), xe]
|
|
2506
2567
|
})]
|
|
2507
2568
|
})
|
|
2508
2569
|
}),
|
|
2509
|
-
/* @__PURE__ */ Q(
|
|
2510
|
-
open:
|
|
2511
|
-
onOpenChange:
|
|
2512
|
-
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, {
|
|
2513
2574
|
onClick: () => {
|
|
2514
|
-
|
|
2575
|
+
J.current = !1;
|
|
2515
2576
|
},
|
|
2516
2577
|
children: d("form.keepEditing")
|
|
2517
|
-
}), /* @__PURE__ */ Q(
|
|
2518
|
-
onClick:
|
|
2578
|
+
}), /* @__PURE__ */ Q(A, {
|
|
2579
|
+
onClick: me,
|
|
2519
2580
|
children: d("form.discard")
|
|
2520
2581
|
})] })] })
|
|
2521
2582
|
}),
|
|
2522
|
-
|
|
2583
|
+
q
|
|
2523
2584
|
]
|
|
2524
2585
|
})
|
|
2525
2586
|
});
|
|
2526
2587
|
};
|
|
2527
2588
|
//#endregion
|
|
2528
2589
|
//#region src/ObjectForm.tsx
|
|
2529
|
-
function
|
|
2590
|
+
function en(e) {
|
|
2530
2591
|
let t = e.buttons, n = e.defaults;
|
|
2531
2592
|
if (!t && !n) return e;
|
|
2532
2593
|
let r = e, i = { ...r };
|
|
2533
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;
|
|
2534
2595
|
}
|
|
2535
|
-
var
|
|
2536
|
-
let n =
|
|
2537
|
-
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 ? {
|
|
2538
2599
|
...t,
|
|
2539
2600
|
sections: r.map((e) => ({
|
|
2540
2601
|
label: e.title ?? e.label,
|
|
@@ -2558,8 +2619,8 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2558
2619
|
fields: o(e.fields)
|
|
2559
2620
|
}))
|
|
2560
2621
|
};
|
|
2561
|
-
}, [e, n]), { sectionLabel: i } =
|
|
2562
|
-
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, {
|
|
2563
2624
|
schema: {
|
|
2564
2625
|
type: "object-master-detail-form",
|
|
2565
2626
|
objectName: r.objectName,
|
|
@@ -2582,7 +2643,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2582
2643
|
},
|
|
2583
2644
|
dataSource: t
|
|
2584
2645
|
});
|
|
2585
|
-
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ Q(
|
|
2646
|
+
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ Q(at, {
|
|
2586
2647
|
schema: {
|
|
2587
2648
|
...r,
|
|
2588
2649
|
formType: "tabbed",
|
|
@@ -2601,7 +2662,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2601
2662
|
dataSource: t,
|
|
2602
2663
|
className: r.className
|
|
2603
2664
|
});
|
|
2604
|
-
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ Q(
|
|
2665
|
+
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ Q(lt, {
|
|
2605
2666
|
schema: {
|
|
2606
2667
|
...r,
|
|
2607
2668
|
formType: "wizard",
|
|
@@ -2623,7 +2684,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2623
2684
|
dataSource: t,
|
|
2624
2685
|
className: r.className
|
|
2625
2686
|
});
|
|
2626
|
-
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ Q(
|
|
2687
|
+
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ Q(ut, {
|
|
2627
2688
|
schema: {
|
|
2628
2689
|
...r,
|
|
2629
2690
|
formType: "split",
|
|
@@ -2646,7 +2707,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2646
2707
|
});
|
|
2647
2708
|
if (r.formType === "drawer") {
|
|
2648
2709
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
2649
|
-
return /* @__PURE__ */ Q(
|
|
2710
|
+
return /* @__PURE__ */ Q(Yt, {
|
|
2650
2711
|
schema: {
|
|
2651
2712
|
...n,
|
|
2652
2713
|
layout: i,
|
|
@@ -2672,7 +2733,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2672
2733
|
}
|
|
2673
2734
|
if (r.formType === "modal") {
|
|
2674
2735
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
2675
|
-
return /* @__PURE__ */ Q(
|
|
2736
|
+
return /* @__PURE__ */ Q($t, {
|
|
2676
2737
|
schema: {
|
|
2677
2738
|
...n,
|
|
2678
2739
|
layout: i,
|
|
@@ -2695,12 +2756,12 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2695
2756
|
className: r.className
|
|
2696
2757
|
});
|
|
2697
2758
|
}
|
|
2698
|
-
return /* @__PURE__ */ Q(
|
|
2759
|
+
return /* @__PURE__ */ Q(nn, {
|
|
2699
2760
|
schema: r,
|
|
2700
2761
|
dataSource: t
|
|
2701
2762
|
});
|
|
2702
|
-
},
|
|
2703
|
-
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) => {
|
|
2704
2765
|
if (!l?.isLoaded) return t;
|
|
2705
2766
|
let n = [];
|
|
2706
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({
|
|
@@ -2714,15 +2775,15 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2714
2775
|
l,
|
|
2715
2776
|
e.objectName,
|
|
2716
2777
|
e.mode
|
|
2717
|
-
]), [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;
|
|
2718
2779
|
i(() => {
|
|
2719
|
-
j && (
|
|
2780
|
+
j && (_(e.initialData || e.initialValues || {}), b(!1));
|
|
2720
2781
|
}, [
|
|
2721
2782
|
j,
|
|
2722
2783
|
e.initialData,
|
|
2723
2784
|
e.initialValues
|
|
2724
2785
|
]), i(() => {
|
|
2725
|
-
j ?
|
|
2786
|
+
j ? f({
|
|
2726
2787
|
name: e.objectName,
|
|
2727
2788
|
fields: {}
|
|
2728
2789
|
}) : e.objectName && r ? (async () => {
|
|
@@ -2730,11 +2791,11 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2730
2791
|
if (!r) throw Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");
|
|
2731
2792
|
let t = await r.getObjectSchema(e.objectName);
|
|
2732
2793
|
if (!t) throw Error(`No schema found for object "${e.objectName}"`);
|
|
2733
|
-
|
|
2794
|
+
f(t);
|
|
2734
2795
|
} catch (e) {
|
|
2735
|
-
|
|
2796
|
+
S(e), b(!1);
|
|
2736
2797
|
}
|
|
2737
|
-
})() : j ||
|
|
2798
|
+
})() : j || b(!1);
|
|
2738
2799
|
}, [
|
|
2739
2800
|
e.objectName,
|
|
2740
2801
|
r,
|
|
@@ -2742,22 +2803,22 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2742
2803
|
]), i(() => {
|
|
2743
2804
|
d && !j && (async () => {
|
|
2744
2805
|
if (!e.recordId || e.mode === "create") {
|
|
2745
|
-
|
|
2806
|
+
_(e.initialData || e.initialValues || {}), b(!1);
|
|
2746
2807
|
return;
|
|
2747
2808
|
}
|
|
2748
2809
|
if (!j) {
|
|
2749
2810
|
if (!r) {
|
|
2750
|
-
|
|
2811
|
+
S(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), b(!1);
|
|
2751
2812
|
return;
|
|
2752
2813
|
}
|
|
2753
|
-
|
|
2814
|
+
b(!0);
|
|
2754
2815
|
try {
|
|
2755
2816
|
let t = await r.findOne(e.objectName, e.recordId);
|
|
2756
|
-
|
|
2817
|
+
_(t);
|
|
2757
2818
|
} catch (e) {
|
|
2758
|
-
console.error("Failed to fetch record:", e),
|
|
2819
|
+
console.error("Failed to fetch record:", e), S(e);
|
|
2759
2820
|
} finally {
|
|
2760
|
-
|
|
2821
|
+
b(!1);
|
|
2761
2822
|
}
|
|
2762
2823
|
}
|
|
2763
2824
|
})();
|
|
@@ -2774,11 +2835,11 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2774
2835
|
let M = n((e) => e, []);
|
|
2775
2836
|
i(() => {
|
|
2776
2837
|
if (j && e.customFields) {
|
|
2777
|
-
|
|
2838
|
+
h(e.customFields.map(M)), b(!1);
|
|
2778
2839
|
return;
|
|
2779
2840
|
}
|
|
2780
2841
|
if (!d) return;
|
|
2781
|
-
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 || {});
|
|
2782
2843
|
(Array.isArray(o) ? o : Object.keys(o)).forEach((n) => {
|
|
2783
2844
|
let r = typeof n == "string" ? n : n.name;
|
|
2784
2845
|
if (!r) return;
|
|
@@ -2790,12 +2851,12 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2790
2851
|
let s = {
|
|
2791
2852
|
name: r,
|
|
2792
2853
|
label: a(e.objectName, r, o.label || n),
|
|
2793
|
-
type:
|
|
2794
|
-
required: o
|
|
2854
|
+
type: O(o.type, { multiple: o.multiple }),
|
|
2855
|
+
required: De(o, Ee(e)),
|
|
2795
2856
|
disabled: e.readOnly || e.mode === "view" || o.readonly || i,
|
|
2796
2857
|
placeholder: o.placeholder,
|
|
2797
2858
|
description: o.help || o.description,
|
|
2798
|
-
validation:
|
|
2859
|
+
validation: E(o),
|
|
2799
2860
|
visibleWhen: o.visibleWhen,
|
|
2800
2861
|
readonlyWhen: o.readonlyWhen,
|
|
2801
2862
|
requiredWhen: o.requiredWhen,
|
|
@@ -2804,12 +2865,12 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2804
2865
|
widget: o.widget
|
|
2805
2866
|
};
|
|
2806
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)) {
|
|
2807
|
-
let e = `Max size: ${
|
|
2868
|
+
let e = `Max size: ${D(o.max_size)}`;
|
|
2808
2869
|
s.description = s.description ? `${s.description} (${e})` : e;
|
|
2809
2870
|
}
|
|
2810
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);
|
|
2811
2872
|
}
|
|
2812
|
-
}),
|
|
2873
|
+
}), h(t), !j && e.recordId && e.mode !== "create" && r || b(!1);
|
|
2813
2874
|
}, [
|
|
2814
2875
|
d,
|
|
2815
2876
|
e.fields,
|
|
@@ -2825,8 +2886,8 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2825
2886
|
let N = n(async (t, n) => {
|
|
2826
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;
|
|
2827
2888
|
if (!r) throw Error("DataSource is required for form submission (inline mode not configured)");
|
|
2828
|
-
let i =
|
|
2829
|
-
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") {
|
|
2830
2891
|
let t = {};
|
|
2831
2892
|
for (let n of Object.keys(i)) l.checkField(e.objectName, n, "write") && (t[n] = i[n]);
|
|
2832
2893
|
i = t;
|
|
@@ -2841,7 +2902,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2841
2902
|
objectName: e.objectName,
|
|
2842
2903
|
recordId: e.recordId,
|
|
2843
2904
|
payload: i,
|
|
2844
|
-
baseRecord:
|
|
2905
|
+
baseRecord: g
|
|
2845
2906
|
});
|
|
2846
2907
|
if (n.status === "cancelled") return;
|
|
2847
2908
|
t = n.result;
|
|
@@ -2851,12 +2912,12 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2851
2912
|
let t = e.submitBehavior;
|
|
2852
2913
|
switch (t.kind) {
|
|
2853
2914
|
case "redirect":
|
|
2854
|
-
|
|
2915
|
+
xe(t.url) && setTimeout(() => window.location.assign(t.url), t.delayMs ?? 0);
|
|
2855
2916
|
break;
|
|
2856
2917
|
case "continue": break;
|
|
2857
2918
|
default: {
|
|
2858
2919
|
let n = t.kind === "thank-you" && t.message ? t.message : e.successMessage || (e.mode === "create" ? "Created" : "Saved");
|
|
2859
|
-
|
|
2920
|
+
X.success(n), T({
|
|
2860
2921
|
title: t.kind === "thank-you" ? t.title : void 0,
|
|
2861
2922
|
message: n
|
|
2862
2923
|
});
|
|
@@ -2864,9 +2925,9 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2864
2925
|
}
|
|
2865
2926
|
}
|
|
2866
2927
|
} else if (!e.submitHandler) {
|
|
2867
|
-
let n =
|
|
2928
|
+
let n = Se(e.navigateOnSuccess, t);
|
|
2868
2929
|
if (n) return window.location.assign(n), t;
|
|
2869
|
-
|
|
2930
|
+
X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved"));
|
|
2870
2931
|
}
|
|
2871
2932
|
return t;
|
|
2872
2933
|
} catch (t) {
|
|
@@ -2879,61 +2940,54 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2879
2940
|
l,
|
|
2880
2941
|
d,
|
|
2881
2942
|
k,
|
|
2882
|
-
|
|
2943
|
+
g
|
|
2883
2944
|
]), P = n(() => {
|
|
2884
2945
|
e.onCancel && e.onCancel();
|
|
2885
|
-
}, [e]), F = {
|
|
2886
|
-
...t.useMemo(() => {
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
n.defaultValue !== void 0 && (e[t] = n.defaultValue);
|
|
2892
|
-
}), e;
|
|
2893
|
-
}, [d]),
|
|
2894
|
-
..._
|
|
2895
|
-
}, I = e.mode === "edit" && e.recordId && _ && typeof _ == "object" ? _ : void 0, L = t.useMemo(() => {
|
|
2896
|
-
let t = Pe(m, d);
|
|
2897
|
-
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;
|
|
2898
2952
|
}, [
|
|
2899
|
-
|
|
2953
|
+
p,
|
|
2900
2954
|
d,
|
|
2901
2955
|
e.mode
|
|
2902
|
-
]), R = t.useMemo(() => e.sections?.length ? null :
|
|
2956
|
+
]), R = t.useMemo(() => e.sections?.length ? null : Xt(L, d?.fieldGroups), [
|
|
2903
2957
|
e.sections,
|
|
2904
2958
|
L,
|
|
2905
2959
|
d
|
|
2906
|
-
]), z = e.sections?.length ? e.sections : R, [B,
|
|
2907
|
-
if (
|
|
2960
|
+
]), z = e.sections?.length ? e.sections : R, [B, V] = c({});
|
|
2961
|
+
if (x) return /* @__PURE__ */ $("div", {
|
|
2908
2962
|
className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
|
|
2909
2963
|
children: [/* @__PURE__ */ Q("h3", {
|
|
2910
2964
|
className: "text-red-800 font-semibold",
|
|
2911
2965
|
children: "Error loading form"
|
|
2912
2966
|
}), /* @__PURE__ */ Q("p", {
|
|
2913
2967
|
className: "text-red-600 text-sm mt-1",
|
|
2914
|
-
children:
|
|
2968
|
+
children: x.message
|
|
2915
2969
|
})]
|
|
2916
2970
|
});
|
|
2917
|
-
if (
|
|
2971
|
+
if (v) return /* @__PURE__ */ $("div", {
|
|
2918
2972
|
className: "p-4 sm:p-8 text-center",
|
|
2919
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", {
|
|
2920
2974
|
className: "mt-2 text-sm text-gray-600",
|
|
2921
2975
|
children: "Loading form..."
|
|
2922
2976
|
})]
|
|
2923
2977
|
});
|
|
2924
|
-
if (
|
|
2978
|
+
if (w) return /* @__PURE__ */ $("div", {
|
|
2925
2979
|
className: "rounded-md border bg-card p-6 sm:p-8 text-center",
|
|
2926
2980
|
children: [/* @__PURE__ */ Q("h3", {
|
|
2927
2981
|
className: "text-lg font-semibold",
|
|
2928
|
-
children:
|
|
2929
|
-
}),
|
|
2982
|
+
children: w.title ?? "Thanks!"
|
|
2983
|
+
}), w.message && /* @__PURE__ */ Q("p", {
|
|
2930
2984
|
className: "mt-2 text-sm text-muted-foreground",
|
|
2931
|
-
children:
|
|
2985
|
+
children: w.message
|
|
2932
2986
|
})]
|
|
2933
2987
|
});
|
|
2934
|
-
let
|
|
2988
|
+
let H = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical";
|
|
2935
2989
|
if (z?.length && (!e.formType || e.formType === "simple")) {
|
|
2936
|
-
let t = R ? L :
|
|
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 = [];
|
|
2937
2991
|
z.forEach((r, i) => {
|
|
2938
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) => {
|
|
2939
2993
|
let t = c.get(e.name);
|
|
@@ -2950,29 +3004,29 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2950
3004
|
colSpan: 4,
|
|
2951
3005
|
collapsible: r.collapsible,
|
|
2952
3006
|
collapsed: m,
|
|
2953
|
-
onToggle: r.collapsible ? () =>
|
|
3007
|
+
onToggle: r.collapsible ? () => V((e) => ({
|
|
2954
3008
|
...e,
|
|
2955
3009
|
[f]: !m
|
|
2956
3010
|
})) : void 0,
|
|
2957
3011
|
className: r.className
|
|
2958
3012
|
});
|
|
2959
|
-
let h = n(r.columns), g = a > 1 ?
|
|
3013
|
+
let h = n(r.columns), g = a > 1 ? Ge(d, a, h) : d;
|
|
2960
3014
|
p && m ? s.push(...g.map((e) => ({
|
|
2961
3015
|
...e,
|
|
2962
3016
|
hidden: !0
|
|
2963
3017
|
}))) : s.push(...g);
|
|
2964
3018
|
});
|
|
2965
|
-
let c = s, l =
|
|
3019
|
+
let c = s, l = Ze(a);
|
|
2966
3020
|
return /* @__PURE__ */ $("div", {
|
|
2967
3021
|
className: "w-full @container",
|
|
2968
|
-
children: [/* @__PURE__ */ Q(
|
|
3022
|
+
children: [/* @__PURE__ */ Q(y, { schema: {
|
|
2969
3023
|
type: "form",
|
|
2970
3024
|
objectName: e.objectName,
|
|
2971
3025
|
fields: c,
|
|
2972
|
-
layout:
|
|
3026
|
+
layout: H,
|
|
2973
3027
|
columns: a,
|
|
2974
3028
|
...l ? { fieldContainerClass: l } : {},
|
|
2975
|
-
defaultValues:
|
|
3029
|
+
defaultValues: ee,
|
|
2976
3030
|
previousValues: I,
|
|
2977
3031
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
2978
3032
|
showCancel: e.showCancel !== !1,
|
|
@@ -2983,10 +3037,10 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2983
3037
|
} }), A]
|
|
2984
3038
|
});
|
|
2985
3039
|
}
|
|
2986
|
-
let
|
|
2987
|
-
fields:
|
|
3040
|
+
let U = e.sections?.length, W = u(p), G = U ? {
|
|
3041
|
+
fields: W,
|
|
2988
3042
|
columns: e.columns
|
|
2989
|
-
} :
|
|
3043
|
+
} : $e(W, d, e.columns, e.mode), K = e.mobile, te = K?.fullscreenLongText ? G.fields.map((e) => {
|
|
2990
3044
|
let t = e.type;
|
|
2991
3045
|
return t !== "textarea" && t !== "field:textarea" && t !== "field:markdown" && t !== "field:html" ? e : e.field ? {
|
|
2992
3046
|
...e,
|
|
@@ -2998,18 +3052,18 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2998
3052
|
...e,
|
|
2999
3053
|
mobile_fullscreen: !0
|
|
3000
3054
|
};
|
|
3001
|
-
}) :
|
|
3002
|
-
if (!e.formType && !
|
|
3003
|
-
let t =
|
|
3004
|
-
for (let e = 0; e < t.length; e +=
|
|
3005
|
-
let r = t.slice(e, e +
|
|
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);
|
|
3006
3060
|
n.push({
|
|
3007
|
-
name: `step-${Math.floor(e /
|
|
3008
|
-
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}`,
|
|
3009
3063
|
fields: r
|
|
3010
3064
|
});
|
|
3011
3065
|
}
|
|
3012
|
-
return /* @__PURE__ */ Q(
|
|
3066
|
+
return /* @__PURE__ */ Q(lt, {
|
|
3013
3067
|
schema: {
|
|
3014
3068
|
...e,
|
|
3015
3069
|
formType: "wizard",
|
|
@@ -3020,30 +3074,30 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
3020
3074
|
className: e.className
|
|
3021
3075
|
});
|
|
3022
3076
|
}
|
|
3023
|
-
let
|
|
3077
|
+
let J = {
|
|
3024
3078
|
type: "form",
|
|
3025
3079
|
objectName: e.objectName,
|
|
3026
|
-
fields:
|
|
3027
|
-
layout:
|
|
3028
|
-
columns:
|
|
3080
|
+
fields: te,
|
|
3081
|
+
layout: H,
|
|
3082
|
+
columns: G.columns,
|
|
3029
3083
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
3030
3084
|
cancelLabel: e.cancelText,
|
|
3031
3085
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
3032
3086
|
showCancel: e.showCancel !== !1,
|
|
3033
3087
|
resetOnSubmit: e.showReset || e.submitBehavior?.kind === "continue" || !e.submitBehavior && e.resetOnSuccess && e.mode === "create",
|
|
3034
|
-
defaultValues:
|
|
3088
|
+
defaultValues: ee,
|
|
3035
3089
|
previousValues: I,
|
|
3036
3090
|
onSubmit: N,
|
|
3037
3091
|
onCancel: P,
|
|
3038
3092
|
className: e.className,
|
|
3039
|
-
mobileStickyActions: !!
|
|
3093
|
+
mobileStickyActions: !!K?.stickyActions
|
|
3040
3094
|
};
|
|
3041
3095
|
return /* @__PURE__ */ $("div", {
|
|
3042
|
-
className:
|
|
3043
|
-
"data-mobile-form":
|
|
3044
|
-
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]
|
|
3045
3099
|
});
|
|
3046
|
-
},
|
|
3100
|
+
}, rn = {
|
|
3047
3101
|
text: 200,
|
|
3048
3102
|
email: 254,
|
|
3049
3103
|
url: 2048,
|
|
@@ -3051,8 +3105,8 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
3051
3105
|
textarea: 5e3,
|
|
3052
3106
|
markdown: 5e3,
|
|
3053
3107
|
html: 5e3
|
|
3054
|
-
},
|
|
3055
|
-
function
|
|
3108
|
+
}, an = "_company_website_2", on = 1500;
|
|
3109
|
+
function sn(e, t = []) {
|
|
3056
3110
|
try {
|
|
3057
3111
|
let n = new URL(e, typeof window < "u" ? window.location.href : "http://localhost");
|
|
3058
3112
|
return typeof window < "u" && n.origin === window.location.origin ? !0 : n.protocol !== "https:" && n.protocol !== "http:" ? !1 : t.some((e) => {
|
|
@@ -3067,21 +3121,21 @@ function qt(e, t = []) {
|
|
|
3067
3121
|
return !1;
|
|
3068
3122
|
}
|
|
3069
3123
|
}
|
|
3070
|
-
function
|
|
3124
|
+
function cn(e) {
|
|
3071
3125
|
return e && e.map((e) => {
|
|
3072
|
-
let t =
|
|
3126
|
+
let t = rn[String(e.type || "").toLowerCase()];
|
|
3073
3127
|
return !t || (e.maxLength ?? e.max_length) ? e : {
|
|
3074
3128
|
...e,
|
|
3075
3129
|
maxLength: t
|
|
3076
3130
|
};
|
|
3077
3131
|
});
|
|
3078
3132
|
}
|
|
3079
|
-
var
|
|
3133
|
+
var ln = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
3080
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);
|
|
3081
3135
|
i(() => {
|
|
3082
3136
|
l || (b.current = Date.now());
|
|
3083
3137
|
}, [l]);
|
|
3084
|
-
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(() => {
|
|
3085
3139
|
if (!t || C && C.length > 0 || !e.fields || e.fields.length === 0) return;
|
|
3086
3140
|
let n = async (e, t) => t;
|
|
3087
3141
|
return {
|
|
@@ -3122,12 +3176,14 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3122
3176
|
try {
|
|
3123
3177
|
t && await t.create(e.objectName, r), u(!0);
|
|
3124
3178
|
let n = e.thankYouPage?.redirectUrl;
|
|
3125
|
-
if (n)
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
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
|
+
}
|
|
3131
3187
|
} catch (e) {
|
|
3132
3188
|
m(e instanceof Error ? e.message : "Failed to submit form. Please try again.");
|
|
3133
3189
|
} finally {
|
|
@@ -3155,7 +3211,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3155
3211
|
children: [
|
|
3156
3212
|
/* @__PURE__ */ Q("div", {
|
|
3157
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",
|
|
3158
|
-
children: /* @__PURE__ */ Q(
|
|
3214
|
+
children: /* @__PURE__ */ Q(fe, {
|
|
3159
3215
|
className: "h-8 w-8",
|
|
3160
3216
|
"aria-hidden": "true"
|
|
3161
3217
|
})
|
|
@@ -3168,7 +3224,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3168
3224
|
className: "text-sm text-muted-foreground",
|
|
3169
3225
|
children: t?.message || n.thankYouMessage || "Your submission has been received successfully."
|
|
3170
3226
|
}),
|
|
3171
|
-
e.allowMultiple && /* @__PURE__ */ Q(
|
|
3227
|
+
e.allowMultiple && /* @__PURE__ */ Q(I, {
|
|
3172
3228
|
variant: "outline",
|
|
3173
3229
|
size: "sm",
|
|
3174
3230
|
onClick: D,
|
|
@@ -3228,7 +3284,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3228
3284
|
className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
|
|
3229
3285
|
children: p
|
|
3230
3286
|
}),
|
|
3231
|
-
/* @__PURE__ */ Q(
|
|
3287
|
+
/* @__PURE__ */ Q(tn, {
|
|
3232
3288
|
schema: {
|
|
3233
3289
|
type: "object-form",
|
|
3234
3290
|
objectName: e.objectName,
|
|
@@ -3281,7 +3337,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3281
3337
|
className: "text-destructive ml-0.5",
|
|
3282
3338
|
children: "*"
|
|
3283
3339
|
}),
|
|
3284
|
-
e.consent.privacyUrl && /* @__PURE__ */ $(
|
|
3340
|
+
e.consent.privacyUrl && /* @__PURE__ */ $(be, { children: [" ", /* @__PURE__ */ Q("a", {
|
|
3285
3341
|
href: e.consent.privacyUrl,
|
|
3286
3342
|
target: "_blank",
|
|
3287
3343
|
rel: "noopener noreferrer",
|
|
@@ -3299,7 +3355,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3299
3355
|
}),
|
|
3300
3356
|
d && /* @__PURE__ */ $("div", {
|
|
3301
3357
|
className: "mt-3 flex items-center gap-2 text-xs text-muted-foreground",
|
|
3302
|
-
children: [/* @__PURE__ */ Q(
|
|
3358
|
+
children: [/* @__PURE__ */ Q(ge, {
|
|
3303
3359
|
className: "h-3.5 w-3.5 animate-spin",
|
|
3304
3360
|
"aria-hidden": "true"
|
|
3305
3361
|
}), /* @__PURE__ */ Q("span", { children: k.submitting ?? "Submitting…" })]
|
|
@@ -3310,7 +3366,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3310
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",
|
|
3311
3367
|
children: [/* @__PURE__ */ $("p", {
|
|
3312
3368
|
className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground",
|
|
3313
|
-
children: [/* @__PURE__ */ Q(
|
|
3369
|
+
children: [/* @__PURE__ */ Q(_e, {
|
|
3314
3370
|
className: "h-3 w-3",
|
|
3315
3371
|
"aria-hidden": "true"
|
|
3316
3372
|
}), /* @__PURE__ */ Q("span", { children: k.secureNotice ?? "Your information is transmitted securely and only used to respond to your request." })]
|
|
@@ -3321,7 +3377,7 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3321
3377
|
target: "_blank",
|
|
3322
3378
|
rel: "noopener noreferrer",
|
|
3323
3379
|
className: "inline-flex items-center gap-1 underline hover:text-foreground",
|
|
3324
|
-
children: [/* @__PURE__ */ Q(
|
|
3380
|
+
children: [/* @__PURE__ */ Q(ve, {
|
|
3325
3381
|
className: "h-3 w-3",
|
|
3326
3382
|
"aria-hidden": "true"
|
|
3327
3383
|
}), k.consentLink ?? "Privacy policy"]
|
|
@@ -3334,10 +3390,10 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3334
3390
|
};
|
|
3335
3391
|
//#endregion
|
|
3336
3392
|
//#region src/FormAnalytics.tsx
|
|
3337
|
-
function
|
|
3393
|
+
function un(e) {
|
|
3338
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`;
|
|
3339
3395
|
}
|
|
3340
|
-
var
|
|
3396
|
+
var dn = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
3341
3397
|
let i = o(() => {
|
|
3342
3398
|
if (!n.abandonedSubmissions) return 100;
|
|
3343
3399
|
let e = n.totalSubmissions + n.abandonedSubmissions;
|
|
@@ -3356,39 +3412,39 @@ var Zt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3356
3412
|
/* @__PURE__ */ $("div", {
|
|
3357
3413
|
className: "grid grid-cols-1 sm:grid-cols-3 gap-4",
|
|
3358
3414
|
children: [
|
|
3359
|
-
/* @__PURE__ */ Q(
|
|
3415
|
+
/* @__PURE__ */ Q(L, { children: /* @__PURE__ */ $(B, {
|
|
3360
3416
|
className: "pb-2",
|
|
3361
|
-
children: [/* @__PURE__ */ Q(
|
|
3417
|
+
children: [/* @__PURE__ */ Q(z, { children: "Total Submissions" }), /* @__PURE__ */ Q(V, {
|
|
3362
3418
|
className: "text-2xl",
|
|
3363
3419
|
children: n.totalSubmissions.toLocaleString()
|
|
3364
3420
|
})]
|
|
3365
3421
|
}) }),
|
|
3366
|
-
/* @__PURE__ */ $(
|
|
3422
|
+
/* @__PURE__ */ $(L, { children: [/* @__PURE__ */ $(B, {
|
|
3367
3423
|
className: "pb-2",
|
|
3368
|
-
children: [/* @__PURE__ */ Q(
|
|
3424
|
+
children: [/* @__PURE__ */ Q(z, { children: "Fill Rate" }), /* @__PURE__ */ $(V, {
|
|
3369
3425
|
className: "text-2xl",
|
|
3370
3426
|
children: [i, "%"]
|
|
3371
3427
|
})]
|
|
3372
|
-
}), /* @__PURE__ */ Q(
|
|
3428
|
+
}), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q("div", {
|
|
3373
3429
|
className: "w-full bg-muted rounded-full h-2",
|
|
3374
3430
|
children: /* @__PURE__ */ Q("div", {
|
|
3375
3431
|
className: "bg-primary rounded-full h-2 transition-all",
|
|
3376
3432
|
style: { width: `${i}%` }
|
|
3377
3433
|
})
|
|
3378
3434
|
}) })] }),
|
|
3379
|
-
/* @__PURE__ */ Q(
|
|
3435
|
+
/* @__PURE__ */ Q(L, { children: /* @__PURE__ */ $(B, {
|
|
3380
3436
|
className: "pb-2",
|
|
3381
|
-
children: [/* @__PURE__ */ Q(
|
|
3437
|
+
children: [/* @__PURE__ */ Q(z, { children: "Avg. Completion Time" }), /* @__PURE__ */ Q(V, {
|
|
3382
3438
|
className: "text-2xl",
|
|
3383
|
-
children: n.avgCompletionTime ?
|
|
3439
|
+
children: n.avgCompletionTime ? un(n.avgCompletionTime) : "—"
|
|
3384
3440
|
})]
|
|
3385
3441
|
}) })
|
|
3386
3442
|
]
|
|
3387
3443
|
}),
|
|
3388
|
-
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ $(
|
|
3444
|
+
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ $(L, { children: [/* @__PURE__ */ Q(B, { children: /* @__PURE__ */ Q(V, {
|
|
3389
3445
|
className: "text-sm font-medium",
|
|
3390
3446
|
children: "Daily Submissions"
|
|
3391
|
-
}) }), /* @__PURE__ */ Q(
|
|
3447
|
+
}) }), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q("div", {
|
|
3392
3448
|
className: "flex items-end gap-1 h-32",
|
|
3393
3449
|
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ $("div", {
|
|
3394
3450
|
className: "flex-1 flex flex-col items-center gap-1",
|
|
@@ -3405,10 +3461,10 @@ var Zt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3405
3461
|
})]
|
|
3406
3462
|
}, t))
|
|
3407
3463
|
}) })] }),
|
|
3408
|
-
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ $(
|
|
3464
|
+
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ $(L, { children: [/* @__PURE__ */ $(B, { children: [/* @__PURE__ */ Q(V, {
|
|
3409
3465
|
className: "text-sm font-medium",
|
|
3410
3466
|
children: "Field Completion Rates"
|
|
3411
|
-
}), /* @__PURE__ */ Q(
|
|
3467
|
+
}), /* @__PURE__ */ Q(z, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ Q(R, { children: /* @__PURE__ */ Q("div", {
|
|
3412
3468
|
className: "space-y-3",
|
|
3413
3469
|
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ $("div", {
|
|
3414
3470
|
className: "space-y-1",
|
|
@@ -3432,76 +3488,80 @@ var Zt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3432
3488
|
}) })] })
|
|
3433
3489
|
]
|
|
3434
3490
|
});
|
|
3435
|
-
},
|
|
3436
|
-
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);
|
|
3437
3493
|
i(() => {
|
|
3438
3494
|
let n = t;
|
|
3439
3495
|
if (!n || typeof n.getObjectSchema != "function") return;
|
|
3440
3496
|
let r = !1;
|
|
3441
3497
|
return n.getObjectSchema(e.childObject).then((e) => {
|
|
3442
|
-
r ||
|
|
3498
|
+
r || k(e ?? null);
|
|
3443
3499
|
}).catch(() => {
|
|
3444
|
-
r ||
|
|
3500
|
+
r || k(null);
|
|
3445
3501
|
}), () => {
|
|
3446
3502
|
r = !0;
|
|
3447
3503
|
};
|
|
3448
3504
|
}, [t, e.childObject]);
|
|
3449
|
-
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 () => {
|
|
3450
3506
|
if (!t || !s) {
|
|
3451
|
-
|
|
3507
|
+
v(!1);
|
|
3452
3508
|
return;
|
|
3453
3509
|
}
|
|
3454
|
-
|
|
3510
|
+
v(!0);
|
|
3455
3511
|
try {
|
|
3456
|
-
let n = (await t.find(e.childObject, {
|
|
3457
|
-
$filter:
|
|
3458
|
-
$
|
|
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
|
|
3459
3516
|
}))?.data ?? [];
|
|
3460
|
-
|
|
3517
|
+
d(r.map((e) => ({ ...e }))), m(r.map((e) => ({ ...e }))), C(!1);
|
|
3461
3518
|
} catch (e) {
|
|
3462
|
-
|
|
3519
|
+
D(e?.message || "Failed to load line items");
|
|
3463
3520
|
} finally {
|
|
3464
|
-
|
|
3521
|
+
v(!1);
|
|
3465
3522
|
}
|
|
3466
3523
|
}, [
|
|
3467
3524
|
t,
|
|
3468
3525
|
s,
|
|
3469
3526
|
e.childObject,
|
|
3470
|
-
e.relationshipField
|
|
3527
|
+
e.relationshipField,
|
|
3528
|
+
e.limit,
|
|
3529
|
+
M,
|
|
3530
|
+
N
|
|
3471
3531
|
]);
|
|
3472
3532
|
i(() => {
|
|
3473
|
-
|
|
3474
|
-
}, [
|
|
3475
|
-
let
|
|
3476
|
-
|
|
3477
|
-
}, []),
|
|
3533
|
+
P();
|
|
3534
|
+
}, [P]);
|
|
3535
|
+
let F = n((e) => {
|
|
3536
|
+
d(e), C(!0);
|
|
3537
|
+
}, []), ee = n(async () => {
|
|
3478
3538
|
if (!(!t || !s)) {
|
|
3479
|
-
|
|
3539
|
+
b(!0), D(null);
|
|
3480
3540
|
try {
|
|
3481
|
-
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, [{
|
|
3482
3542
|
childObject: e.childObject,
|
|
3483
3543
|
relationshipField: e.relationshipField,
|
|
3484
3544
|
rows: l,
|
|
3485
|
-
original:
|
|
3486
|
-
childSchema:
|
|
3545
|
+
original: f,
|
|
3546
|
+
childSchema: O
|
|
3487
3547
|
}]);
|
|
3488
|
-
n || (i = i.slice(1)), i.length && await
|
|
3548
|
+
n || (i = i.slice(1)), i.length && await g(t, i), await P();
|
|
3489
3549
|
} catch (e) {
|
|
3490
|
-
|
|
3550
|
+
D(e?.message || "Failed to save line items");
|
|
3491
3551
|
} finally {
|
|
3492
|
-
|
|
3552
|
+
b(!1);
|
|
3493
3553
|
}
|
|
3494
3554
|
}
|
|
3495
3555
|
}, [
|
|
3496
3556
|
t,
|
|
3497
3557
|
s,
|
|
3498
3558
|
l,
|
|
3499
|
-
|
|
3559
|
+
f,
|
|
3500
3560
|
e,
|
|
3501
3561
|
a,
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
]),
|
|
3562
|
+
P,
|
|
3563
|
+
O
|
|
3564
|
+
]), z = o(() => ({
|
|
3505
3565
|
columns: e.columns,
|
|
3506
3566
|
total_field: e.totalField ? e.amountField || "amount" : void 0,
|
|
3507
3567
|
min_rows: e.minRows,
|
|
@@ -3509,44 +3569,50 @@ var Zt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3509
3569
|
allow_add: !e.readonly,
|
|
3510
3570
|
allow_delete: !e.readonly
|
|
3511
3571
|
}), [e]);
|
|
3512
|
-
return /* @__PURE__ */ $(
|
|
3513
|
-
className:
|
|
3514
|
-
children: [/* @__PURE__ */ $(
|
|
3572
|
+
return /* @__PURE__ */ $(L, {
|
|
3573
|
+
className: Y("shadow-none"),
|
|
3574
|
+
children: [/* @__PURE__ */ $(B, {
|
|
3515
3575
|
className: "flex-row items-center justify-between gap-2 pb-2",
|
|
3516
|
-
children: [/* @__PURE__ */ Q(
|
|
3576
|
+
children: [/* @__PURE__ */ Q(V, {
|
|
3517
3577
|
className: "text-sm font-medium",
|
|
3518
3578
|
children: e.title || "Line Items"
|
|
3519
|
-
}), !e.readonly && /* @__PURE__ */ Q(
|
|
3579
|
+
}), !e.readonly && /* @__PURE__ */ Q(I, {
|
|
3520
3580
|
type: "button",
|
|
3521
3581
|
size: "sm",
|
|
3522
|
-
onClick:
|
|
3523
|
-
disabled:
|
|
3524
|
-
children:
|
|
3582
|
+
onClick: ee,
|
|
3583
|
+
disabled: y || h || !x || !s,
|
|
3584
|
+
children: y ? "Saving…" : "Save"
|
|
3525
3585
|
})]
|
|
3526
|
-
}), /* @__PURE__ */ $(
|
|
3586
|
+
}), /* @__PURE__ */ $(R, { children: [E && /* @__PURE__ */ Q("p", {
|
|
3527
3587
|
className: "mb-2 text-sm text-destructive",
|
|
3528
|
-
children:
|
|
3529
|
-
}),
|
|
3588
|
+
children: E
|
|
3589
|
+
}), h ? /* @__PURE__ */ Q("p", {
|
|
3530
3590
|
className: "py-6 text-center text-sm text-muted-foreground",
|
|
3531
3591
|
children: "Loading…"
|
|
3532
|
-
}) : s ? /* @__PURE__ */ Q(
|
|
3592
|
+
}) : s ? /* @__PURE__ */ Q(T, {
|
|
3533
3593
|
value: l,
|
|
3534
|
-
onChange:
|
|
3535
|
-
field:
|
|
3594
|
+
onChange: F,
|
|
3595
|
+
field: z,
|
|
3536
3596
|
readonly: e.readonly
|
|
3537
3597
|
}) : /* @__PURE__ */ Q("p", {
|
|
3538
3598
|
className: "py-6 text-center text-sm text-muted-foreground",
|
|
3539
3599
|
children: "Save the record first to add line items."
|
|
3540
3600
|
})] })]
|
|
3541
3601
|
});
|
|
3542
|
-
},
|
|
3543
|
-
let t = r(
|
|
3544
|
-
return /* @__PURE__ */ Q(
|
|
3602
|
+
}, pn = ({ schema: e }) => {
|
|
3603
|
+
let t = r(b)?.dataSource ?? void 0;
|
|
3604
|
+
return /* @__PURE__ */ Q(v, {
|
|
3545
3605
|
schema: e,
|
|
3546
|
-
dataSource: t
|
|
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
|
+
})
|
|
3547
3613
|
});
|
|
3548
3614
|
};
|
|
3549
|
-
l.register("object-form",
|
|
3615
|
+
l.register("object-form", pn, {
|
|
3550
3616
|
namespace: "plugin-form",
|
|
3551
3617
|
label: "Object Form",
|
|
3552
3618
|
category: "plugin",
|
|
@@ -3687,7 +3753,7 @@ l.register("object-form", $t, {
|
|
|
3687
3753
|
]
|
|
3688
3754
|
}
|
|
3689
3755
|
]
|
|
3690
|
-
}), l.register("form",
|
|
3756
|
+
}), l.register("form", pn, {
|
|
3691
3757
|
namespace: "view",
|
|
3692
3758
|
skipFallback: !0,
|
|
3693
3759
|
label: "Data Form View",
|
|
@@ -3716,10 +3782,16 @@ l.register("object-form", $t, {
|
|
|
3716
3782
|
}
|
|
3717
3783
|
]
|
|
3718
3784
|
}), l.register("embeddable-form", ({ schema: e }) => {
|
|
3719
|
-
let t = r(
|
|
3720
|
-
return /* @__PURE__ */ Q(
|
|
3721
|
-
|
|
3722
|
-
dataSource: t?.dataSource
|
|
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
|
+
})
|
|
3723
3795
|
});
|
|
3724
3796
|
}, {
|
|
3725
3797
|
namespace: "plugin-form",
|
|
@@ -3759,7 +3831,7 @@ l.register("object-form", $t, {
|
|
|
3759
3831
|
label: "Allow Multiple Submissions"
|
|
3760
3832
|
}
|
|
3761
3833
|
]
|
|
3762
|
-
}), l.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ Q(
|
|
3834
|
+
}), l.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ Q(dn, {
|
|
3763
3835
|
formId: e.formId,
|
|
3764
3836
|
formTitle: e.formTitle,
|
|
3765
3837
|
metrics: e.metrics || { totalSubmissions: 0 }
|
|
@@ -3786,10 +3858,16 @@ l.register("object-form", $t, {
|
|
|
3786
3858
|
}
|
|
3787
3859
|
]
|
|
3788
3860
|
}), l.register("object-master-detail-form", ({ schema: e }) => {
|
|
3789
|
-
let t = r(
|
|
3790
|
-
return /* @__PURE__ */ Q(
|
|
3861
|
+
let t = r(b)?.dataSource ?? void 0;
|
|
3862
|
+
return /* @__PURE__ */ Q(v, {
|
|
3791
3863
|
schema: e,
|
|
3792
|
-
dataSource: t
|
|
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
|
+
})
|
|
3793
3871
|
});
|
|
3794
3872
|
}, {
|
|
3795
3873
|
namespace: "plugin-form",
|
|
@@ -3820,7 +3898,20 @@ l.register("object-form", $t, {
|
|
|
3820
3898
|
required: !0
|
|
3821
3899
|
}
|
|
3822
3900
|
]
|
|
3823
|
-
})
|
|
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
|
+
}), {
|
|
3824
3915
|
namespace: "record",
|
|
3825
3916
|
skipFallback: !0,
|
|
3826
3917
|
label: "Line Items",
|
|
@@ -3857,4 +3948,4 @@ l.register("object-form", $t, {
|
|
|
3857
3948
|
]
|
|
3858
3949
|
});
|
|
3859
3950
|
//#endregion
|
|
3860
|
-
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 };
|