@object-ui/plugin-form 17.3.0 → 17.6.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 +1159 -0
- package/README.md +494 -77
- package/dist/DrawerForm.d.ts.map +1 -1
- package/dist/EmbeddableForm.d.ts.map +1 -1
- package/dist/LineItemsPanel.d.ts +33 -0
- package/dist/LineItemsPanel.d.ts.map +1 -1
- package/dist/MasterDetailForm.d.ts.map +1 -1
- package/dist/ModalForm.d.ts.map +1 -1
- package/dist/ObjectForm.d.ts +18 -2
- 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 +33 -0
- package/dist/WizardForm.d.ts.map +1 -1
- package/dist/autoLayout.d.ts.map +1 -1
- package/dist/deriveMasterDetail.d.ts +1 -1
- package/dist/deriveMasterDetail.d.ts.map +1 -1
- package/dist/flatFields.d.ts +21 -0
- package/dist/flatFields.d.ts.map +1 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1570 -1112
- 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 +18 -0
- package/dist/sectionFields.d.ts.map +1 -1
- package/dist/submitRedirect.d.ts +148 -0
- package/dist/submitRedirect.d.ts.map +1 -0
- package/dist/submitRedirectNavigation.d.ts +82 -0
- package/dist/submitRedirectNavigation.d.ts.map +1 -0
- package/dist/successBehavior.d.ts +18 -1
- package/dist/successBehavior.d.ts.map +1 -1
- package/dist/thankYouRedirectCountdown.d.ts +17 -0
- package/dist/thankYouRedirectCountdown.d.ts.map +1 -0
- package/dist/thankYouRedirectNavigation.d.ts +111 -0
- package/dist/thankYouRedirectNavigation.d.ts.map +1 -0
- package/package.json +13 -13
package/dist/index.js
CHANGED
|
@@ -1,54 +1,170 @@
|
|
|
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 {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
3
|
+
import { ComponentRegistry as l, convertSortToQueryParams as u, evalFieldPredicate as d, isMissingForRequired as f, isRuntimeDefault as p, isServerOwnedValue as m, mergeFilterNodes as h, resolveEffectiveCrudAffordances as g, resolveFieldRuleState as _, runBatchTransaction as v, toFilterNode as y } from "@object-ui/core";
|
|
4
|
+
import { ElementDataSourceGate as b, SchemaRenderer as x, SchemaRendererContext as S, noDataSourceMessage as C, useHostNavigation as w, usePreviewMode as T, useRecordContext as E, useResolvedDataSource as D, useSafeFieldLabel as O, useSchemaContext as k } from "@object-ui/react";
|
|
5
|
+
import { LineItemsField as A, buildValidationRules as j, formatFileSize as M, mapFieldTypeToFormType as N } from "@object-ui/fields";
|
|
6
|
+
import { AlertDialog as P, AlertDialogAction as F, AlertDialogCancel as I, AlertDialogContent as ee, AlertDialogDescription as te, AlertDialogFooter as L, AlertDialogHeader as ne, AlertDialogTitle as re, Button as R, Card as z, CardContent as B, CardDescription as V, CardHeader as H, CardTitle as U, Dialog as ie, DialogDescription as W, DialogHeader as G, DialogTitle as ae, MobileDialogContent as K, Sheet as oe, SheetContent as se, SheetDescription as ce, SheetHeader as q, SheetTitle as le, Skeleton as J, buttonVariants as ue, cn as Y, toast as X, useIsMobile as de } from "@object-ui/components";
|
|
7
|
+
import { FormViewSchema as fe } from "@objectstack/spec/ui";
|
|
8
|
+
import { usePermissions as pe } from "@object-ui/permissions";
|
|
9
|
+
import { deriveFieldGroupLayout as me, isCurrentUserDefaultToken as he } from "@objectstack/spec/data";
|
|
10
|
+
import { AlertCircle as ge, AlertTriangle as _e, Check as ve, CheckCircle2 as ye, ChevronDown as be, ChevronLeft as xe, ChevronRight as Se, Loader2 as Ce, Lock as we, ShieldCheck as Te } from "lucide-react";
|
|
11
|
+
import { createSafeTranslation as Ee } from "@object-ui/i18n";
|
|
12
|
+
import { Fragment as De, jsx as Z, jsxs as Q } from "react/jsx-runtime";
|
|
12
13
|
//#region src/successBehavior.ts
|
|
13
|
-
function
|
|
14
|
+
function Oe(e) {
|
|
14
15
|
try {
|
|
15
16
|
return typeof window > "u" ? !1 : new URL(e, window.location.href).origin === window.location.origin;
|
|
16
17
|
} catch {
|
|
17
18
|
return !1;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
+
function ke(e, t) {
|
|
21
22
|
if (!e) return null;
|
|
22
23
|
let n = t?.id ?? t?.recordId ?? t?._id;
|
|
23
24
|
if (n == null || n === "") return null;
|
|
24
25
|
let r = e.replace(/\{(?:id|recordId)\}/g, String(n));
|
|
25
|
-
return
|
|
26
|
+
return Oe(r) ? r : null;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/submitRedirect.ts
|
|
30
|
+
var Ae = /\{\{record\.([a-z_][a-z0-9_]*)\}\}/g;
|
|
31
|
+
function je(e) {
|
|
32
|
+
return e == null ? "" : typeof e == "string" ? e : typeof e == "boolean" || typeof e == "number" && Number.isFinite(e) ? String(e) : "";
|
|
33
|
+
}
|
|
34
|
+
function Me(e, t) {
|
|
35
|
+
let n = (e) => e && typeof e == "object" && !Array.isArray(e) ? e : {};
|
|
36
|
+
return {
|
|
37
|
+
...n(e),
|
|
38
|
+
...n(t)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function Ne(e, t) {
|
|
42
|
+
let n = fe.safeParse({ submitBehavior: {
|
|
43
|
+
kind: "redirect",
|
|
44
|
+
url: e
|
|
45
|
+
} });
|
|
46
|
+
if (!n.success) return {
|
|
47
|
+
ok: !1,
|
|
48
|
+
refusal: n.error.issues.find((e) => e.path[0] === "submitBehavior" && e.path[1] === "url")?.message ?? n.error.issues[0]?.message ?? `\`submitBehavior.url\` is not a value this contract accepts: ${JSON.stringify(e)}.`
|
|
49
|
+
};
|
|
50
|
+
let r = n.data.submitBehavior, i = (r?.kind === "redirect" ? r.url : e).replace(Ae, (e, n) => encodeURIComponent(je(t[n])));
|
|
51
|
+
return i.includes("{") || i.includes("}") ? {
|
|
52
|
+
ok: !1,
|
|
53
|
+
refusal: `\`submitBehavior.url\` carries an interpolation this renderer could not resolve (${JSON.stringify(e)}). A token names one declared record field, spelled \`{{record.field_name}}\`, and the redirect is refused rather than followed with the token left in it.`
|
|
54
|
+
} : {
|
|
55
|
+
ok: !0,
|
|
56
|
+
url: i
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/submitRedirectNavigation.ts
|
|
61
|
+
function Pe(e) {
|
|
62
|
+
let { navigate: t } = w(), n = s(t);
|
|
63
|
+
i(() => {
|
|
64
|
+
n.current = t;
|
|
65
|
+
}, [t]), i(() => {
|
|
66
|
+
if (!e) return;
|
|
67
|
+
let t = setTimeout(() => {
|
|
68
|
+
let t = n.current;
|
|
69
|
+
if (t) {
|
|
70
|
+
t(e.url);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
window.location.assign(e.url);
|
|
74
|
+
}, e.delayMs);
|
|
75
|
+
return () => clearTimeout(t);
|
|
76
|
+
}, [e]);
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/thankYouRedirectNavigation.ts
|
|
80
|
+
var Fe = "https://a.invalid/", Ie = "https://b.invalid/";
|
|
81
|
+
function Le(e) {
|
|
82
|
+
try {
|
|
83
|
+
return new URL(e, Fe).origin === "https://a.invalid" && new URL(e, Ie).origin === "https://b.invalid";
|
|
84
|
+
} catch {
|
|
85
|
+
return !1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function Re(e) {
|
|
89
|
+
let { navigate: t } = w(), n = s(t);
|
|
90
|
+
i(() => {
|
|
91
|
+
n.current = t;
|
|
92
|
+
}, [t]), i(() => {
|
|
93
|
+
if (!e) return;
|
|
94
|
+
let t = setTimeout(() => {
|
|
95
|
+
let t = Le(e.url) ? n.current : void 0;
|
|
96
|
+
if (t) {
|
|
97
|
+
t(e.url);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
window.location.href = e.url;
|
|
101
|
+
}, e.delayMs);
|
|
102
|
+
return () => clearTimeout(t);
|
|
103
|
+
}, [e]);
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/schemaDefaults.ts
|
|
107
|
+
function ze(e) {
|
|
108
|
+
return e != null && !p(e);
|
|
109
|
+
}
|
|
110
|
+
function Be(e) {
|
|
111
|
+
return e?.mode === "create" || !e?.recordId;
|
|
112
|
+
}
|
|
113
|
+
function Ve(e, t) {
|
|
114
|
+
return !(!e?.required || t && p(e.defaultValue));
|
|
115
|
+
}
|
|
116
|
+
function He(e, t) {
|
|
117
|
+
let n = e?.fields;
|
|
118
|
+
if (!n || typeof n != "object") return {};
|
|
119
|
+
let r = {};
|
|
120
|
+
for (let e of Object.keys(n)) {
|
|
121
|
+
let i = n[e], a = i?.defaultValue;
|
|
122
|
+
ze(a) ? r[e] = a : Ue(i) && t?.currentUserId && (r[e] = t.currentUserId);
|
|
123
|
+
}
|
|
124
|
+
return r;
|
|
125
|
+
}
|
|
126
|
+
function Ue(e) {
|
|
127
|
+
return !e || !he(e.defaultValue) ? !1 : e.type === "user" || e.type === "lookup" && (e.reference === "sys_user" || e.reference_to === "sys_user");
|
|
128
|
+
}
|
|
129
|
+
function We(e, t, n) {
|
|
130
|
+
return {
|
|
131
|
+
...He(e, n),
|
|
132
|
+
...t ?? {}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function Ge(e, t) {
|
|
136
|
+
if (!e || typeof e != "object") return e;
|
|
137
|
+
let n = t?.fields;
|
|
138
|
+
if (!n || typeof n != "object") return e;
|
|
139
|
+
let r = {};
|
|
140
|
+
for (let [t, i] of Object.entries(e)) p(n[t]?.defaultValue) && f(i) || (r[t] = i);
|
|
141
|
+
return r;
|
|
26
142
|
}
|
|
27
143
|
//#endregion
|
|
28
144
|
//#region src/sectionFields.ts
|
|
29
|
-
function
|
|
145
|
+
function Ke(e, t) {
|
|
30
146
|
return typeof t == "string" && t.trim() || typeof t == "object" && t && typeof t.source == "string" && t.source.trim() ? {
|
|
31
147
|
...e,
|
|
32
148
|
visibleOn: t
|
|
33
149
|
} : e;
|
|
34
150
|
}
|
|
35
|
-
var
|
|
36
|
-
function
|
|
151
|
+
var qe = /* @__PURE__ */ new Set();
|
|
152
|
+
function Je(e, t) {
|
|
37
153
|
if (typeof e.name != "string" || e.name === e.field) return;
|
|
38
154
|
let n = `${t}:${e.field}:${e.name}`;
|
|
39
|
-
|
|
155
|
+
qe.has(n) || (qe.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
156
|
}
|
|
41
|
-
function
|
|
157
|
+
function Ye(e, t) {
|
|
42
158
|
let n = t.objectSchema?.fields?.[e];
|
|
43
159
|
return n ? {
|
|
44
160
|
name: e,
|
|
45
161
|
label: t.fieldLabel(t.objectName, e, n.label || e),
|
|
46
|
-
type:
|
|
47
|
-
required: n
|
|
162
|
+
type: N(n.type, { multiple: n.multiple }),
|
|
163
|
+
required: Ve(n, Be(t)),
|
|
48
164
|
disabled: t.readOnly || t.mode === "view" || n.readonly,
|
|
49
165
|
placeholder: n.placeholder,
|
|
50
166
|
description: n.help || n.description,
|
|
51
|
-
validation:
|
|
167
|
+
validation: j(n),
|
|
52
168
|
field: n,
|
|
53
169
|
options: n.options,
|
|
54
170
|
multiple: n.multiple,
|
|
@@ -61,67 +177,72 @@ function xe(e, t) {
|
|
|
61
177
|
type: "input"
|
|
62
178
|
};
|
|
63
179
|
}
|
|
64
|
-
function
|
|
180
|
+
function Xe(e, t) {
|
|
65
181
|
if (typeof e == "string") {
|
|
66
182
|
let n = t.objectSchema?.fields?.[e];
|
|
67
|
-
return
|
|
183
|
+
return Ke(Ye(e, t), n?.visible_on ?? n?.visibleOn);
|
|
68
184
|
}
|
|
69
185
|
let n = e;
|
|
70
|
-
if (typeof n.field != "string") return
|
|
71
|
-
|
|
72
|
-
let r = n.field, i =
|
|
73
|
-
n.
|
|
74
|
-
|
|
75
|
-
|
|
186
|
+
if (typeof n.field != "string") return Ke(n, n.visibleOn);
|
|
187
|
+
Je(n, t.objectName);
|
|
188
|
+
let r = n.field, i = Ye(r, t);
|
|
189
|
+
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 = Ve({
|
|
190
|
+
required: n.required,
|
|
191
|
+
defaultValue: t.objectSchema?.fields?.[r]?.defaultValue
|
|
192
|
+
}, Be(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);
|
|
193
|
+
let a = n.type ?? t.objectSchema?.fields?.[r]?.type;
|
|
194
|
+
a != null && (i.type = N(a, { multiple: i.multiple }));
|
|
195
|
+
let o = n.reference ?? n.reference_to;
|
|
196
|
+
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), Ke(i, n.visibleWhen ?? n.visibleOn);
|
|
76
197
|
}
|
|
77
|
-
function
|
|
78
|
-
return (e.fields ?? []).map((e) =>
|
|
198
|
+
function Ze(e, t) {
|
|
199
|
+
return (e.fields ?? []).map((e) => Xe(e, t));
|
|
79
200
|
}
|
|
80
201
|
//#endregion
|
|
81
202
|
//#region src/autoLayout.ts
|
|
82
|
-
var
|
|
203
|
+
var Qe = /* @__PURE__ */ new Set([
|
|
83
204
|
"field:formula",
|
|
84
205
|
"field:summary",
|
|
85
206
|
"field:auto_number",
|
|
86
207
|
"field:autonumber"
|
|
87
|
-
]),
|
|
208
|
+
]), $e = /* @__PURE__ */ new Set([
|
|
88
209
|
"field:textarea",
|
|
89
210
|
"field:markdown",
|
|
90
211
|
"field:html",
|
|
91
212
|
"field:grid",
|
|
92
|
-
"field:
|
|
213
|
+
"field:richtext",
|
|
93
214
|
"textarea",
|
|
94
215
|
"markdown",
|
|
95
216
|
"html",
|
|
96
217
|
"grid",
|
|
97
|
-
"
|
|
98
|
-
]),
|
|
218
|
+
"richtext"
|
|
219
|
+
]), et = /* @__PURE__ */ new Set([
|
|
99
220
|
"formula",
|
|
100
221
|
"summary",
|
|
101
222
|
"auto_number",
|
|
102
223
|
"autonumber"
|
|
103
224
|
]);
|
|
104
|
-
function
|
|
105
|
-
return
|
|
225
|
+
function tt(e) {
|
|
226
|
+
return $e.has(e);
|
|
106
227
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
228
|
+
function nt(e) {
|
|
229
|
+
return et.has(e);
|
|
109
230
|
}
|
|
110
|
-
function
|
|
231
|
+
function rt(e) {
|
|
111
232
|
return e <= 3 ? 1 : e <= 8 ? 2 : e <= 15 ? 3 : 4;
|
|
112
233
|
}
|
|
113
|
-
function
|
|
234
|
+
function it(e) {
|
|
114
235
|
return e && e > 0 ? Math.min(Math.floor(e), 4) : 1;
|
|
115
236
|
}
|
|
116
|
-
function
|
|
117
|
-
let r =
|
|
118
|
-
return r <= 1 ? 1 : e.span === "full" ? r : e.colSpan == null ? e.type &&
|
|
237
|
+
function at(e, t, n) {
|
|
238
|
+
let r = it(t);
|
|
239
|
+
return r <= 1 ? 1 : e.span === "full" ? r : e.colSpan == null ? e.type && tt(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
240
|
}
|
|
120
|
-
function
|
|
121
|
-
let r =
|
|
241
|
+
function $(e, t, n) {
|
|
242
|
+
let r = it(t);
|
|
122
243
|
return r <= 1 ? e : e.map((e) => {
|
|
123
244
|
if (e.type === "section-divider") return e;
|
|
124
|
-
let t =
|
|
245
|
+
let t = at(e, r, n);
|
|
125
246
|
return t > 1 ? {
|
|
126
247
|
...e,
|
|
127
248
|
colSpan: t
|
|
@@ -131,7 +252,7 @@ function Me(e, t, n) {
|
|
|
131
252
|
} : e;
|
|
132
253
|
});
|
|
133
254
|
}
|
|
134
|
-
var
|
|
255
|
+
var ot = /* @__PURE__ */ new Set([
|
|
135
256
|
"id",
|
|
136
257
|
"created_at",
|
|
137
258
|
"createdAt",
|
|
@@ -158,89 +279,89 @@ var Ne = /* @__PURE__ */ new Set([
|
|
|
158
279
|
"_version",
|
|
159
280
|
"_rev"
|
|
160
281
|
]);
|
|
161
|
-
function
|
|
282
|
+
function st(e, t) {
|
|
162
283
|
return e.filter((e) => {
|
|
163
|
-
if (
|
|
284
|
+
if (ot.has(e.name)) return !1;
|
|
164
285
|
let n = t?.fields?.[e.name];
|
|
165
286
|
return n?.hidden !== !0 && n?.readonly !== !0;
|
|
166
287
|
});
|
|
167
288
|
}
|
|
168
|
-
function
|
|
289
|
+
function ct(e, t) {
|
|
169
290
|
return e.filter((e) => {
|
|
170
|
-
if (
|
|
291
|
+
if (ot.has(e.name) || e.type && Qe.has(e.type)) return !1;
|
|
171
292
|
if (!t?.fields) return !0;
|
|
172
293
|
let n = t.fields[e.name];
|
|
173
|
-
return !n || n.readonly !== !0 && !
|
|
294
|
+
return !n || n.readonly !== !0 && !nt(n.type);
|
|
174
295
|
});
|
|
175
296
|
}
|
|
176
|
-
function
|
|
297
|
+
function lt(e, t) {
|
|
177
298
|
return e.filter((e) => {
|
|
178
|
-
if (e.type &&
|
|
299
|
+
if (e.type && Qe.has(e.type)) return !1;
|
|
179
300
|
let n = t?.fields?.[e.name];
|
|
180
|
-
return !n || !
|
|
301
|
+
return !n || !nt(n.type);
|
|
181
302
|
});
|
|
182
303
|
}
|
|
183
|
-
var
|
|
304
|
+
var ut = {
|
|
184
305
|
1: void 0,
|
|
185
306
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
186
307
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
187
308
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
188
309
|
};
|
|
189
|
-
function
|
|
190
|
-
return
|
|
310
|
+
function dt(e) {
|
|
311
|
+
return ut[e && e > 0 ? Math.min(Math.floor(e), 4) : 1];
|
|
191
312
|
}
|
|
192
|
-
function
|
|
313
|
+
function ft(e) {
|
|
193
314
|
return e <= 1 ? "default" : e === 2 ? "xl" : "full";
|
|
194
315
|
}
|
|
195
|
-
function
|
|
316
|
+
function pt(e, t, n, r) {
|
|
196
317
|
let i = [...e];
|
|
197
|
-
if (i =
|
|
318
|
+
if (i = st(i, t), r === "create" && (i = lt(i, t)), n !== void 0) return i = $(i, n), {
|
|
198
319
|
fields: i,
|
|
199
320
|
columns: n
|
|
200
321
|
};
|
|
201
|
-
let a =
|
|
202
|
-
return i =
|
|
322
|
+
let a = rt(i.length);
|
|
323
|
+
return i = $(i, a), {
|
|
203
324
|
fields: i,
|
|
204
325
|
columns: a
|
|
205
326
|
};
|
|
206
327
|
}
|
|
207
328
|
//#endregion
|
|
208
329
|
//#region src/occSave.tsx
|
|
209
|
-
var
|
|
330
|
+
var mt = Ee({
|
|
210
331
|
"form.conflictTitle": "Save conflict",
|
|
211
332
|
"form.conflictMessage": "This record was changed by someone else while you were editing. Overwriting will replace their changes with yours.",
|
|
212
333
|
"form.conflictLatestVersion": "Their save: {{time}}",
|
|
213
334
|
"form.conflictOverwrite": "Overwrite",
|
|
214
335
|
"form.keepEditing": "Keep editing"
|
|
215
336
|
}, "form.conflictTitle");
|
|
216
|
-
function
|
|
337
|
+
function ht(e) {
|
|
217
338
|
let t = e?.updated_at;
|
|
218
339
|
return typeof t == "string" && t.length > 0 ? t : void 0;
|
|
219
340
|
}
|
|
220
|
-
function
|
|
341
|
+
function gt(e) {
|
|
221
342
|
if (!e || typeof e != "object") return !1;
|
|
222
343
|
let t = e;
|
|
223
344
|
return t.code === "CONCURRENT_UPDATE" || t.name === "ConcurrentUpdateError";
|
|
224
345
|
}
|
|
225
|
-
function
|
|
346
|
+
function _t(e) {
|
|
226
347
|
if (!e) return null;
|
|
227
348
|
let t = /\d{4}-\d{2}-\d{2}[ T]/.test(e) ? e.replace(" ", "T") : e, n = new Date(t);
|
|
228
349
|
return Number.isNaN(n.getTime()) ? null : n.toLocaleString();
|
|
229
350
|
}
|
|
230
|
-
function
|
|
231
|
-
let { t } =
|
|
351
|
+
function vt() {
|
|
352
|
+
let { t } = mt(), [n, r] = e.useState(null), i = e.useRef(null), a = e.useCallback((e) => {
|
|
232
353
|
i.current?.(e), i.current = null, r(null);
|
|
233
354
|
}, []);
|
|
234
355
|
e.useEffect(() => () => i.current?.(!1), []);
|
|
235
356
|
let o = e.useCallback(async ({ dataSource: e, objectName: t, recordId: n, payload: a, baseRecord: o }) => {
|
|
236
|
-
let s =
|
|
357
|
+
let s = ht(o);
|
|
237
358
|
try {
|
|
238
359
|
return {
|
|
239
360
|
status: "saved",
|
|
240
361
|
result: await e.update(t, n, a, s ? { ifMatch: s } : void 0)
|
|
241
362
|
};
|
|
242
363
|
} catch (o) {
|
|
243
|
-
if (!
|
|
364
|
+
if (!gt(o)) throw o;
|
|
244
365
|
let s = o.currentVersion;
|
|
245
366
|
if (!await new Promise((e) => {
|
|
246
367
|
i.current = e, r({ currentVersion: typeof s == "string" ? s : void 0 });
|
|
@@ -251,31 +372,31 @@ function Ge() {
|
|
|
251
372
|
result: await e.update(t, n, a, c ? { ifMatch: c } : void 0)
|
|
252
373
|
};
|
|
253
374
|
}
|
|
254
|
-
}, []), s =
|
|
375
|
+
}, []), s = _t(n?.currentVersion);
|
|
255
376
|
return {
|
|
256
377
|
saveWithOcc: o,
|
|
257
|
-
conflictDialog: /* @__PURE__ */
|
|
378
|
+
conflictDialog: /* @__PURE__ */ Z(P, {
|
|
258
379
|
open: !!n,
|
|
259
380
|
onOpenChange: (e) => {
|
|
260
381
|
e || a(!1);
|
|
261
382
|
},
|
|
262
|
-
children: /* @__PURE__ */
|
|
383
|
+
children: /* @__PURE__ */ Q(ee, { children: [/* @__PURE__ */ Q(ne, { children: [/* @__PURE__ */ Q(re, {
|
|
263
384
|
className: "flex items-center gap-2",
|
|
264
|
-
children: [/* @__PURE__ */
|
|
385
|
+
children: [/* @__PURE__ */ Z(_e, {
|
|
265
386
|
className: "h-5 w-5 text-amber-500",
|
|
266
387
|
"aria-hidden": !0
|
|
267
388
|
}), t("form.conflictTitle")]
|
|
268
|
-
}), /* @__PURE__ */
|
|
389
|
+
}), /* @__PURE__ */ Q(te, { children: [t("form.conflictMessage"), s && /* @__PURE__ */ Z("span", {
|
|
269
390
|
className: "mt-2 block text-xs text-muted-foreground",
|
|
270
391
|
children: t("form.conflictLatestVersion", { time: s })
|
|
271
|
-
})] })] }), /* @__PURE__ */
|
|
392
|
+
})] })] }), /* @__PURE__ */ Q(L, { children: [/* @__PURE__ */ Z("button", {
|
|
272
393
|
type: "button",
|
|
273
|
-
className:
|
|
394
|
+
className: Y(ue({ variant: "outline" })),
|
|
274
395
|
onClick: () => a(!1),
|
|
275
396
|
children: t("form.keepEditing")
|
|
276
|
-
}), /* @__PURE__ */
|
|
397
|
+
}), /* @__PURE__ */ Z("button", {
|
|
277
398
|
type: "button",
|
|
278
|
-
className:
|
|
399
|
+
className: Y(ue({ variant: "destructive" })),
|
|
279
400
|
onClick: () => a(!0),
|
|
280
401
|
children: t("form.conflictOverwrite")
|
|
281
402
|
})] })] })
|
|
@@ -284,8 +405,8 @@ function Ge() {
|
|
|
284
405
|
}
|
|
285
406
|
//#endregion
|
|
286
407
|
//#region src/TabbedForm.tsx
|
|
287
|
-
var
|
|
288
|
-
let { fieldLabel: a } =
|
|
408
|
+
var yt = ({ schema: e, dataSource: r, className: i }) => {
|
|
409
|
+
let { fieldLabel: a } = O(), { userId: o } = pe(), [l, u] = c(null), [d, f] = c({}), { saveWithOcc: p, conflictDialog: m } = vt(), [h, g] = c(!0), [_, v] = c(null), y = e.defaultTab || e.sections[0]?.name || e.sections[0]?.label || "tab-0";
|
|
289
410
|
t.useEffect(() => {
|
|
290
411
|
(async () => {
|
|
291
412
|
if (!r) {
|
|
@@ -294,25 +415,25 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
294
415
|
}
|
|
295
416
|
try {
|
|
296
417
|
let t = await r.getObjectSchema(e.objectName);
|
|
297
|
-
|
|
418
|
+
u(t);
|
|
298
419
|
} catch (e) {
|
|
299
420
|
v(e);
|
|
300
421
|
}
|
|
301
422
|
})();
|
|
302
423
|
}, [e.objectName, r]);
|
|
303
|
-
let
|
|
424
|
+
let b = s(void 0);
|
|
304
425
|
t.useEffect(() => {
|
|
305
426
|
let t = !1;
|
|
306
|
-
return (
|
|
427
|
+
return (l || !r) && (async () => {
|
|
307
428
|
if (e.mode === "create" || !e.recordId || !r) {
|
|
308
|
-
|
|
429
|
+
f(We(l, e.initialData || e.initialValues, { currentUserId: o })), g(!1);
|
|
309
430
|
return;
|
|
310
431
|
}
|
|
311
|
-
|
|
432
|
+
b.current !== e.recordId && g(!0);
|
|
312
433
|
try {
|
|
313
434
|
let n = await r.findOne(e.objectName, e.recordId);
|
|
314
435
|
if (t) return;
|
|
315
|
-
|
|
436
|
+
b.current = e.recordId, f(n || {});
|
|
316
437
|
} catch (e) {
|
|
317
438
|
if (t) return;
|
|
318
439
|
v(e);
|
|
@@ -323,7 +444,7 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
323
444
|
t = !0;
|
|
324
445
|
};
|
|
325
446
|
}, [
|
|
326
|
-
|
|
447
|
+
l,
|
|
327
448
|
e.mode,
|
|
328
449
|
e.recordId,
|
|
329
450
|
e.initialData,
|
|
@@ -331,30 +452,32 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
331
452
|
r,
|
|
332
453
|
e.objectName
|
|
333
454
|
]);
|
|
334
|
-
let S = n((t) =>
|
|
335
|
-
objectSchema:
|
|
455
|
+
let S = n((t) => Ze(t, {
|
|
456
|
+
objectSchema: l,
|
|
336
457
|
objectName: e.objectName,
|
|
337
458
|
readOnly: e.readOnly,
|
|
338
459
|
mode: e.mode,
|
|
460
|
+
recordId: e.recordId,
|
|
339
461
|
fieldLabel: a
|
|
340
462
|
}), [
|
|
341
|
-
|
|
463
|
+
l,
|
|
342
464
|
e.readOnly,
|
|
343
465
|
e.mode,
|
|
466
|
+
e.recordId,
|
|
344
467
|
e.objectName,
|
|
345
468
|
a
|
|
346
469
|
]), C = n(async (t) => {
|
|
347
470
|
if (!r) return e.onSuccess && await e.onSuccess(t), t;
|
|
348
471
|
try {
|
|
349
472
|
let n;
|
|
350
|
-
if (e.mode === "create") n = await r.create(e.objectName, t);
|
|
473
|
+
if (e.mode === "create") n = await r.create(e.objectName, Ge(t, l));
|
|
351
474
|
else if (e.mode === "edit" && e.recordId) {
|
|
352
|
-
let i = await
|
|
475
|
+
let i = await p({
|
|
353
476
|
dataSource: r,
|
|
354
477
|
objectName: e.objectName,
|
|
355
478
|
recordId: e.recordId,
|
|
356
479
|
payload: t,
|
|
357
|
-
baseRecord:
|
|
480
|
+
baseRecord: d
|
|
358
481
|
});
|
|
359
482
|
if (i.status === "cancelled") return;
|
|
360
483
|
n = i.result;
|
|
@@ -366,67 +489,67 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
366
489
|
}, [
|
|
367
490
|
e,
|
|
368
491
|
r,
|
|
369
|
-
|
|
370
|
-
|
|
492
|
+
p,
|
|
493
|
+
d
|
|
371
494
|
]), w = n(() => {
|
|
372
495
|
e.onCancel && e.onCancel();
|
|
373
496
|
}, [e]), T = (e, t) => e.name || e.label || `tab-${t}`;
|
|
374
|
-
if (_) return /* @__PURE__ */
|
|
497
|
+
if (_) return /* @__PURE__ */ Q("div", {
|
|
375
498
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
376
|
-
children: [/* @__PURE__ */
|
|
499
|
+
children: [/* @__PURE__ */ Z("h3", {
|
|
377
500
|
className: "text-red-800 font-semibold",
|
|
378
501
|
children: "Error loading form"
|
|
379
|
-
}), /* @__PURE__ */
|
|
502
|
+
}), /* @__PURE__ */ Z("p", {
|
|
380
503
|
className: "text-red-600 text-sm mt-1",
|
|
381
504
|
children: _.message
|
|
382
505
|
})]
|
|
383
506
|
});
|
|
384
|
-
if (
|
|
507
|
+
if (h) return /* @__PURE__ */ Q("div", {
|
|
385
508
|
className: "p-8 text-center",
|
|
386
|
-
children: [/* @__PURE__ */
|
|
509
|
+
children: [/* @__PURE__ */ Z("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Z("p", {
|
|
387
510
|
className: "mt-2 text-sm text-gray-600",
|
|
388
511
|
children: "Loading form..."
|
|
389
512
|
})]
|
|
390
513
|
});
|
|
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),
|
|
514
|
+
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), k = E(e.columns) ?? (D.length ? Math.max(...D) : 1), A = dt(k), j = e.sections.map((e, t) => {
|
|
392
515
|
let n = S(e);
|
|
393
516
|
return {
|
|
394
517
|
key: T(e, t),
|
|
395
518
|
label: e.label || `Tab ${t + 1}`,
|
|
396
519
|
description: e.description,
|
|
397
520
|
containerClass: e.gridClassName,
|
|
398
|
-
fields:
|
|
521
|
+
fields: k > 1 ? $(n, k, E(e.columns)) : n
|
|
399
522
|
};
|
|
400
|
-
}),
|
|
401
|
-
return /* @__PURE__ */
|
|
402
|
-
className:
|
|
403
|
-
children: [/* @__PURE__ */
|
|
523
|
+
}), M = j.flatMap((e) => e.fields);
|
|
524
|
+
return /* @__PURE__ */ Q("div", {
|
|
525
|
+
className: Y("w-full @container", i, e.className),
|
|
526
|
+
children: [/* @__PURE__ */ Z(x, { schema: {
|
|
404
527
|
type: "form",
|
|
405
528
|
objectName: e.objectName,
|
|
406
|
-
fields:
|
|
407
|
-
columns:
|
|
408
|
-
...
|
|
529
|
+
fields: M,
|
|
530
|
+
columns: k,
|
|
531
|
+
...A ? { fieldContainerClass: A } : {},
|
|
409
532
|
layout: "vertical",
|
|
410
|
-
defaultValues:
|
|
411
|
-
previousValues: e.mode === "edit" && e.recordId ?
|
|
533
|
+
defaultValues: d,
|
|
534
|
+
previousValues: e.mode === "edit" && e.recordId ? d : void 0,
|
|
412
535
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
413
536
|
cancelLabel: e.cancelText,
|
|
414
537
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
415
538
|
showCancel: e.showCancel !== !1,
|
|
416
539
|
onSubmit: C,
|
|
417
540
|
onCancel: w,
|
|
418
|
-
fieldTabs:
|
|
541
|
+
fieldTabs: j.map((e) => ({
|
|
419
542
|
key: e.key,
|
|
420
543
|
label: e.label,
|
|
421
544
|
description: e.description,
|
|
422
545
|
fields: e.fields.map((e) => e.name),
|
|
423
546
|
containerClass: e.containerClass
|
|
424
547
|
})),
|
|
425
|
-
defaultFieldTab:
|
|
548
|
+
defaultFieldTab: y,
|
|
426
549
|
fieldTabsPosition: e.tabPosition || "top"
|
|
427
|
-
} }),
|
|
550
|
+
} }), m]
|
|
428
551
|
});
|
|
429
|
-
},
|
|
552
|
+
}, bt = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: a, className: o, gridClassName: s, showBorder: l }) => {
|
|
430
553
|
let [u, d] = c(r), f = {
|
|
431
554
|
1: "grid-cols-1",
|
|
432
555
|
2: "grid-cols-1 md:grid-cols-2",
|
|
@@ -434,73 +557,75 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
434
557
|
4: "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
|
|
435
558
|
}, p = () => {
|
|
436
559
|
n && d(!u);
|
|
437
|
-
}, m = l ?? !!e, h = e || t ? /* @__PURE__ */
|
|
438
|
-
className:
|
|
560
|
+
}, m = l ?? !!e, h = e || t ? /* @__PURE__ */ Q("div", {
|
|
561
|
+
className: Y("flex items-start gap-2", !m && "mb-4", n && "cursor-pointer select-none"),
|
|
439
562
|
onClick: p,
|
|
440
563
|
role: n ? "button" : void 0,
|
|
441
564
|
"aria-expanded": n ? !u : void 0,
|
|
442
|
-
children: [n && /* @__PURE__ */
|
|
565
|
+
children: [n && /* @__PURE__ */ Z("span", {
|
|
443
566
|
className: "mt-0.5 text-muted-foreground",
|
|
444
|
-
children:
|
|
445
|
-
}), /* @__PURE__ */
|
|
567
|
+
children: Z(u ? Se : be, { className: "h-4 w-4" })
|
|
568
|
+
}), /* @__PURE__ */ Q("div", {
|
|
446
569
|
className: "flex-1",
|
|
447
|
-
children: [e && /* @__PURE__ */
|
|
570
|
+
children: [e && /* @__PURE__ */ Z("h3", {
|
|
448
571
|
className: "text-sm font-semibold text-foreground",
|
|
449
572
|
children: e
|
|
450
|
-
}), t && /* @__PURE__ */
|
|
573
|
+
}), t && /* @__PURE__ */ Z("p", {
|
|
451
574
|
className: "text-sm text-muted-foreground mt-0.5",
|
|
452
575
|
children: t
|
|
453
576
|
})]
|
|
454
577
|
})]
|
|
455
|
-
}) : null, g = u ? null : /* @__PURE__ */
|
|
456
|
-
className:
|
|
578
|
+
}) : null, g = u ? null : /* @__PURE__ */ Z("div", {
|
|
579
|
+
className: Y("grid gap-4", s || f[i]),
|
|
457
580
|
children: a
|
|
458
581
|
});
|
|
459
|
-
return m ? /* @__PURE__ */
|
|
460
|
-
className:
|
|
461
|
-
children: [h && /* @__PURE__ */
|
|
582
|
+
return m ? /* @__PURE__ */ Q(z, {
|
|
583
|
+
className: Y("form-section bg-muted/40 shadow-none", o),
|
|
584
|
+
children: [h && /* @__PURE__ */ Z(H, {
|
|
462
585
|
className: "border-b border-border pb-3",
|
|
463
586
|
children: h
|
|
464
|
-
}), g && /* @__PURE__ */
|
|
587
|
+
}), g && /* @__PURE__ */ Z(B, {
|
|
465
588
|
className: "pt-4",
|
|
466
589
|
children: g
|
|
467
590
|
})]
|
|
468
|
-
}) : /* @__PURE__ */
|
|
469
|
-
className:
|
|
591
|
+
}) : /* @__PURE__ */ Q("div", {
|
|
592
|
+
className: Y("form-section", o),
|
|
470
593
|
children: [h, g]
|
|
471
594
|
});
|
|
472
|
-
},
|
|
473
|
-
let { fieldLabel: a } =
|
|
595
|
+
}, xt = "The `navigateOnSuccess` destination declared for this form was refused, so the navigation did not happen.", St = Ee({ "wizard.missingRequired": "Please complete the required fields: {{fields}}" }, "wizard.missingRequired"), Ct = f, wt = ({ schema: e, dataSource: r, className: i }) => {
|
|
596
|
+
let { fieldLabel: a } = O(), { userId: s } = pe(), { t: l } = St(), [u, f] = c(null), [p, h] = c({}), [g, v] = c(void 0), { saveWithOcc: y, conflictDialog: b } = vt(), [S, C] = c(!0), [w, T] = c(null), [E, D] = c(0), [k, A] = c(/* @__PURE__ */ new Set()), [j, M] = c(!1), [N, P] = c(/* @__PURE__ */ new Set()), [F, I] = c(null), [ee, te] = c(null);
|
|
597
|
+
Pe(ee);
|
|
598
|
+
let L = t.useId(), [ne, re] = c(0), z = t.useRef(!1), B = e.sections.length, V = E === 0, H = E === B - 1;
|
|
474
599
|
t.useEffect(() => {
|
|
475
600
|
(async () => {
|
|
476
601
|
if (!r) {
|
|
477
|
-
|
|
602
|
+
C(!1);
|
|
478
603
|
return;
|
|
479
604
|
}
|
|
480
605
|
try {
|
|
481
606
|
let t = await r.getObjectSchema(e.objectName);
|
|
482
|
-
|
|
607
|
+
f(t);
|
|
483
608
|
} catch (e) {
|
|
484
|
-
|
|
609
|
+
T(e);
|
|
485
610
|
}
|
|
486
611
|
})();
|
|
487
612
|
}, [e.objectName, r]), t.useEffect(() => {
|
|
488
|
-
(
|
|
613
|
+
(u || !r) && (async () => {
|
|
489
614
|
if (e.mode === "create" || !e.recordId || !r) {
|
|
490
|
-
z.current ||= (
|
|
615
|
+
z.current ||= (h(We(u, e.initialData || e.initialValues, { currentUserId: s })), !0), C(!1);
|
|
491
616
|
return;
|
|
492
617
|
}
|
|
493
618
|
try {
|
|
494
619
|
let t = await r.findOne(e.objectName, e.recordId);
|
|
495
|
-
|
|
620
|
+
h(t || {}), v(t || {});
|
|
496
621
|
} catch (e) {
|
|
497
|
-
|
|
622
|
+
T(e);
|
|
498
623
|
} finally {
|
|
499
|
-
|
|
624
|
+
C(!1);
|
|
500
625
|
}
|
|
501
626
|
})();
|
|
502
627
|
}, [
|
|
503
|
-
|
|
628
|
+
u,
|
|
504
629
|
e.mode,
|
|
505
630
|
e.recordId,
|
|
506
631
|
e.initialData,
|
|
@@ -508,192 +633,219 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
508
633
|
r,
|
|
509
634
|
e.objectName
|
|
510
635
|
]);
|
|
511
|
-
let
|
|
512
|
-
objectSchema:
|
|
636
|
+
let U = n((t) => Ze(t, {
|
|
637
|
+
objectSchema: u,
|
|
513
638
|
objectName: e.objectName,
|
|
514
639
|
readOnly: e.readOnly,
|
|
515
640
|
mode: e.mode,
|
|
641
|
+
recordId: e.recordId,
|
|
516
642
|
fieldLabel: a
|
|
517
643
|
}), [
|
|
518
|
-
|
|
644
|
+
u,
|
|
519
645
|
e.readOnly,
|
|
520
646
|
e.mode,
|
|
647
|
+
e.recordId,
|
|
521
648
|
e.objectName,
|
|
522
649
|
a
|
|
523
|
-
]),
|
|
524
|
-
|
|
650
|
+
]), ie = Be(e), W = o(() => E >= 0 && E < B ? U(e.sections[E]) : [], [
|
|
651
|
+
E,
|
|
525
652
|
B,
|
|
526
653
|
e.sections,
|
|
527
|
-
|
|
528
|
-
]),
|
|
654
|
+
U
|
|
655
|
+
]), G = n((t) => {
|
|
529
656
|
let n = /* @__PURE__ */ new Map();
|
|
530
657
|
return e.sections.forEach((e, r) => {
|
|
531
|
-
for (let i of
|
|
658
|
+
for (let i of U(e)) {
|
|
532
659
|
let e = i?.name;
|
|
533
660
|
if (!e || i.hidden === !0) continue;
|
|
534
|
-
let a =
|
|
661
|
+
let a = _({
|
|
535
662
|
visibleWhen: i.visibleWhen,
|
|
536
663
|
readonlyWhen: i.readonlyWhen,
|
|
537
664
|
requiredWhen: i.requiredWhen
|
|
538
665
|
}, t, {
|
|
539
666
|
required: !!i.required,
|
|
540
|
-
readonly: i.readonly === !0
|
|
667
|
+
readonly: i.readonly === !0,
|
|
668
|
+
serverOwnedValue: m(i, ie)
|
|
541
669
|
}, void 0, void 0, `field '${e}'`);
|
|
542
|
-
!(i.visibleOn == null ||
|
|
670
|
+
!(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
671
|
}
|
|
544
672
|
}), n;
|
|
545
|
-
}, [
|
|
673
|
+
}, [
|
|
674
|
+
e.sections,
|
|
675
|
+
U,
|
|
676
|
+
ie
|
|
677
|
+
]), ae = n(async (t) => {
|
|
546
678
|
let n = {
|
|
547
|
-
...
|
|
679
|
+
...p,
|
|
548
680
|
...t
|
|
549
681
|
};
|
|
550
|
-
if (
|
|
551
|
-
if (!e.has(
|
|
682
|
+
if (h(n), A((e) => new Set(e).add(E)), P((e) => {
|
|
683
|
+
if (!e.has(E)) return e;
|
|
552
684
|
let t = new Set(e);
|
|
553
|
-
return t.delete(
|
|
554
|
-
}),
|
|
555
|
-
let t =
|
|
685
|
+
return t.delete(E), t;
|
|
686
|
+
}), H) {
|
|
687
|
+
let t = G(n);
|
|
556
688
|
if (t.size > 0) {
|
|
557
|
-
|
|
689
|
+
P(new Set(t.keys()));
|
|
558
690
|
let e = [...t.values()].flat();
|
|
559
|
-
|
|
691
|
+
X.error(l("wizard.missingRequired", { fields: e.slice(0, 3).join(", ") + (e.length > 3 ? "…" : "") })), K(Math.min(...t.keys()));
|
|
560
692
|
return;
|
|
561
693
|
}
|
|
562
|
-
|
|
694
|
+
P(/* @__PURE__ */ new Set()), M(!0);
|
|
563
695
|
try {
|
|
564
696
|
if (!r) return e.onSuccess && await e.onSuccess(n), n;
|
|
565
697
|
let t;
|
|
566
|
-
if (e.mode === "create") t = await r.create(e.objectName, n);
|
|
698
|
+
if (e.mode === "create") t = await r.create(e.objectName, Ge(n, u));
|
|
567
699
|
else if (e.mode === "edit" && e.recordId) {
|
|
568
|
-
let i = await
|
|
700
|
+
let i = await y({
|
|
569
701
|
dataSource: r,
|
|
570
702
|
objectName: e.objectName,
|
|
571
703
|
recordId: e.recordId,
|
|
572
704
|
payload: n,
|
|
573
|
-
baseRecord:
|
|
705
|
+
baseRecord: p
|
|
574
706
|
});
|
|
575
707
|
if (i.status === "cancelled") return;
|
|
576
708
|
t = i.result;
|
|
577
709
|
}
|
|
578
710
|
if (e.onSuccess) await e.onSuccess(t);
|
|
579
711
|
else if (e.submitBehavior) {
|
|
580
|
-
let
|
|
581
|
-
switch (
|
|
582
|
-
case "redirect":
|
|
583
|
-
|
|
712
|
+
let r = e.submitBehavior;
|
|
713
|
+
switch (r.kind) {
|
|
714
|
+
case "redirect": {
|
|
715
|
+
let i = Ne(r.url, Me(n, t));
|
|
716
|
+
if (!i.ok) {
|
|
717
|
+
X.error(i.refusal), I({
|
|
718
|
+
message: e.successMessage || (e.mode === "create" ? "Created" : "Saved"),
|
|
719
|
+
refusal: i.refusal
|
|
720
|
+
});
|
|
721
|
+
break;
|
|
722
|
+
}
|
|
723
|
+
te({
|
|
724
|
+
url: i.url,
|
|
725
|
+
delayMs: r.delayMs ?? 0
|
|
726
|
+
});
|
|
584
727
|
break;
|
|
728
|
+
}
|
|
585
729
|
case "continue":
|
|
586
|
-
|
|
730
|
+
h(We(u, e.initialData || e.initialValues, { currentUserId: s })), A(/* @__PURE__ */ new Set()), D(0), re((e) => e + 1);
|
|
587
731
|
break;
|
|
588
732
|
default: {
|
|
589
|
-
let
|
|
590
|
-
|
|
591
|
-
title:
|
|
592
|
-
message:
|
|
733
|
+
let t = r.kind === "thank-you" && r.message ? r.message : e.successMessage || (e.mode === "create" ? "Created" : "Saved");
|
|
734
|
+
X.success(t), I({
|
|
735
|
+
title: r.kind === "thank-you" ? r.title : void 0,
|
|
736
|
+
message: t
|
|
593
737
|
});
|
|
594
738
|
break;
|
|
595
739
|
}
|
|
596
740
|
}
|
|
597
741
|
} else {
|
|
598
|
-
let n =
|
|
599
|
-
if (n) return
|
|
600
|
-
|
|
742
|
+
let n = ke(e.navigateOnSuccess, t);
|
|
743
|
+
if (n) return Le(n) ? te({
|
|
744
|
+
url: n,
|
|
745
|
+
delayMs: 0
|
|
746
|
+
}) : window.location.assign(n), t;
|
|
747
|
+
e.navigateOnSuccess ? (console.warn("[WizardForm] `navigateOnSuccess` was declared but produced no destination:", e.navigateOnSuccess), X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved"), { description: xt })) : X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved")), e.resetOnSuccess && e.mode === "create" && (h(We(u, e.initialData || e.initialValues, { currentUserId: s })), A(/* @__PURE__ */ new Set()), D(0), re((e) => e + 1));
|
|
601
748
|
}
|
|
602
749
|
return t;
|
|
603
750
|
} catch (t) {
|
|
604
751
|
throw e.onError && e.onError(t), t;
|
|
605
752
|
} finally {
|
|
606
|
-
|
|
753
|
+
M(!1);
|
|
607
754
|
}
|
|
608
755
|
}
|
|
609
|
-
|
|
756
|
+
K(E + 1);
|
|
610
757
|
}, [
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
758
|
+
p,
|
|
759
|
+
E,
|
|
760
|
+
H,
|
|
614
761
|
e,
|
|
762
|
+
u,
|
|
615
763
|
r,
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
]),
|
|
620
|
-
t >= 0 && t < B && (
|
|
621
|
-
}, [B, e]),
|
|
622
|
-
|
|
623
|
-
}, [
|
|
764
|
+
G,
|
|
765
|
+
l,
|
|
766
|
+
y
|
|
767
|
+
]), K = n((t) => {
|
|
768
|
+
t >= 0 && t < B && (D(t), e.onStepChange && e.onStepChange(t));
|
|
769
|
+
}, [B, e]), oe = n(() => {
|
|
770
|
+
K(E - 1);
|
|
771
|
+
}, [E, K]), se = n(() => {
|
|
624
772
|
e.onCancel && e.onCancel();
|
|
625
|
-
}, [e]),
|
|
626
|
-
(e.allowSkip ||
|
|
773
|
+
}, [e]), ce = n((t) => {
|
|
774
|
+
(e.allowSkip || k.has(t) || t <= E) && K(t);
|
|
627
775
|
}, [
|
|
628
776
|
e.allowSkip,
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
777
|
+
k,
|
|
778
|
+
E,
|
|
779
|
+
K
|
|
632
780
|
]);
|
|
633
|
-
if (
|
|
781
|
+
if (w) return /* @__PURE__ */ Q("div", {
|
|
634
782
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
635
|
-
children: [/* @__PURE__ */
|
|
783
|
+
children: [/* @__PURE__ */ Z("h3", {
|
|
636
784
|
className: "text-red-800 font-semibold",
|
|
637
785
|
children: "Error loading form"
|
|
638
|
-
}), /* @__PURE__ */
|
|
786
|
+
}), /* @__PURE__ */ Z("p", {
|
|
639
787
|
className: "text-red-600 text-sm mt-1",
|
|
640
|
-
children:
|
|
788
|
+
children: w.message
|
|
641
789
|
})]
|
|
642
790
|
});
|
|
643
|
-
if (
|
|
791
|
+
if (S) return /* @__PURE__ */ Q("div", {
|
|
644
792
|
className: "p-8 text-center",
|
|
645
|
-
children: [/* @__PURE__ */
|
|
793
|
+
children: [/* @__PURE__ */ Z("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Z("p", {
|
|
646
794
|
className: "mt-2 text-sm text-gray-600",
|
|
647
795
|
children: "Loading form..."
|
|
648
796
|
})]
|
|
649
797
|
});
|
|
650
|
-
if (
|
|
651
|
-
className:
|
|
652
|
-
children: /* @__PURE__ */
|
|
798
|
+
if (F) return /* @__PURE__ */ Q("div", {
|
|
799
|
+
className: Y("w-full space-y-4", i, e.className),
|
|
800
|
+
children: [/* @__PURE__ */ Q("div", {
|
|
653
801
|
className: "rounded-md border bg-card p-8 text-center",
|
|
654
|
-
children: [/* @__PURE__ */
|
|
802
|
+
children: [/* @__PURE__ */ Z("h3", {
|
|
655
803
|
className: "text-lg font-semibold",
|
|
656
|
-
children:
|
|
657
|
-
}),
|
|
804
|
+
children: F.title ?? "Thanks!"
|
|
805
|
+
}), F.message && /* @__PURE__ */ Z("p", {
|
|
658
806
|
className: "mt-2 text-sm text-muted-foreground",
|
|
659
|
-
children:
|
|
807
|
+
children: F.message
|
|
660
808
|
})]
|
|
661
|
-
})
|
|
809
|
+
}), F.refusal && /* @__PURE__ */ Z("div", {
|
|
810
|
+
role: "alert",
|
|
811
|
+
className: "rounded-md border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive",
|
|
812
|
+
children: F.refusal
|
|
813
|
+
})]
|
|
662
814
|
});
|
|
663
|
-
let
|
|
664
|
-
return /* @__PURE__ */
|
|
665
|
-
className:
|
|
815
|
+
let q = e.sections[E], le = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, J = le(e.columns) ?? le(q?.columns) ?? 1, ue = dt(J);
|
|
816
|
+
return /* @__PURE__ */ Q("div", {
|
|
817
|
+
className: Y("w-full @container", i, e.className),
|
|
666
818
|
children: [
|
|
667
|
-
e.showStepIndicator !== !1 && /* @__PURE__ */
|
|
819
|
+
e.showStepIndicator !== !1 && /* @__PURE__ */ Z("nav", {
|
|
668
820
|
"aria-label": "Progress",
|
|
669
821
|
className: "mb-8",
|
|
670
|
-
children: /* @__PURE__ */
|
|
822
|
+
children: /* @__PURE__ */ Z("ol", {
|
|
671
823
|
className: "flex items-center",
|
|
672
824
|
children: e.sections.map((t, n) => {
|
|
673
|
-
let r = n ===
|
|
674
|
-
return /* @__PURE__ */
|
|
675
|
-
className:
|
|
676
|
-
children: [n !== B - 1 && /* @__PURE__ */
|
|
825
|
+
let r = n === E, i = k.has(n), a = e.allowSkip || i || n <= E, o = N.has(n);
|
|
826
|
+
return /* @__PURE__ */ Q("li", {
|
|
827
|
+
className: Y("relative flex-1", n !== B - 1 && "pr-8 sm:pr-12"),
|
|
828
|
+
children: [n !== B - 1 && /* @__PURE__ */ Z("div", {
|
|
677
829
|
className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
|
|
678
830
|
"aria-hidden": "true",
|
|
679
|
-
children: /* @__PURE__ */
|
|
680
|
-
}), /* @__PURE__ */
|
|
831
|
+
children: /* @__PURE__ */ Z("div", { className: Y("h-full", i ? "bg-primary" : "bg-muted") })
|
|
832
|
+
}), /* @__PURE__ */ Q("button", {
|
|
681
833
|
type: "button",
|
|
682
|
-
className:
|
|
683
|
-
onClick: () =>
|
|
834
|
+
className: Y("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
|
|
835
|
+
onClick: () => ce(n),
|
|
684
836
|
disabled: !a,
|
|
685
837
|
"data-testid": `wizard-step:${t.name || n}`,
|
|
686
838
|
"data-error": o || void 0,
|
|
687
|
-
children: [/* @__PURE__ */
|
|
688
|
-
className:
|
|
689
|
-
children: o ? /* @__PURE__ */
|
|
839
|
+
children: [/* @__PURE__ */ Z("span", {
|
|
840
|
+
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"),
|
|
841
|
+
children: o ? /* @__PURE__ */ Z(ge, {
|
|
690
842
|
className: "h-3 w-3 sm:h-4 sm:w-4",
|
|
691
843
|
"aria-hidden": !0
|
|
692
|
-
}) : i ? /* @__PURE__ */
|
|
693
|
-
}), /* @__PURE__ */
|
|
844
|
+
}) : i ? /* @__PURE__ */ Z(ve, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : n + 1
|
|
845
|
+
}), /* @__PURE__ */ Z("span", {
|
|
694
846
|
className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block",
|
|
695
|
-
children: /* @__PURE__ */
|
|
696
|
-
className:
|
|
847
|
+
children: /* @__PURE__ */ Z("span", {
|
|
848
|
+
className: Y(o ? "text-destructive" : r ? "text-foreground" : "text-muted-foreground"),
|
|
697
849
|
children: t.label || `Step ${n + 1}`
|
|
698
850
|
})
|
|
699
851
|
})]
|
|
@@ -702,74 +854,74 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
702
854
|
})
|
|
703
855
|
})
|
|
704
856
|
}),
|
|
705
|
-
/* @__PURE__ */
|
|
857
|
+
/* @__PURE__ */ Z("div", {
|
|
706
858
|
className: "min-h-[200px]",
|
|
707
|
-
children:
|
|
708
|
-
label:
|
|
709
|
-
description:
|
|
859
|
+
children: q && /* @__PURE__ */ Z(bt, {
|
|
860
|
+
label: q.label,
|
|
861
|
+
description: q.description,
|
|
710
862
|
columns: 1,
|
|
711
|
-
className:
|
|
712
|
-
gridClassName:
|
|
713
|
-
children:
|
|
863
|
+
className: q.className,
|
|
864
|
+
gridClassName: q.gridClassName,
|
|
865
|
+
children: W.length > 0 ? /* @__PURE__ */ Z(x, { schema: {
|
|
714
866
|
type: "form",
|
|
715
867
|
objectName: e.objectName,
|
|
716
|
-
id:
|
|
717
|
-
fields:
|
|
718
|
-
columns:
|
|
719
|
-
...
|
|
868
|
+
id: L,
|
|
869
|
+
fields: J > 1 ? $(W, J, le(q.columns)) : W,
|
|
870
|
+
columns: J,
|
|
871
|
+
...ue ? { fieldContainerClass: ue } : {},
|
|
720
872
|
layout: "vertical",
|
|
721
|
-
defaultValues:
|
|
873
|
+
defaultValues: p,
|
|
722
874
|
previousValues: e.mode === "edit" ? g : void 0,
|
|
723
875
|
showSubmit: !1,
|
|
724
876
|
showCancel: !1,
|
|
725
|
-
onSubmit:
|
|
726
|
-
} },
|
|
727
|
-
id:
|
|
877
|
+
onSubmit: ae
|
|
878
|
+
} }, ne) : /* @__PURE__ */ Z("form", {
|
|
879
|
+
id: L,
|
|
728
880
|
onSubmit: (e) => {
|
|
729
|
-
e.preventDefault(),
|
|
881
|
+
e.preventDefault(), ae({});
|
|
730
882
|
},
|
|
731
|
-
children: /* @__PURE__ */
|
|
883
|
+
children: /* @__PURE__ */ Z("div", {
|
|
732
884
|
className: "text-center py-8 text-muted-foreground",
|
|
733
885
|
children: "No fields configured for this step"
|
|
734
886
|
})
|
|
735
887
|
})
|
|
736
888
|
})
|
|
737
889
|
}),
|
|
738
|
-
/* @__PURE__ */
|
|
890
|
+
/* @__PURE__ */ Q("div", {
|
|
739
891
|
className: "flex items-center justify-between mt-6 pt-4 border-t",
|
|
740
|
-
children: [/* @__PURE__ */
|
|
892
|
+
children: [/* @__PURE__ */ Z("div", { children: e.showCancel !== !1 && /* @__PURE__ */ Z(R, {
|
|
741
893
|
variant: "ghost",
|
|
742
|
-
onClick:
|
|
894
|
+
onClick: se,
|
|
743
895
|
children: e.cancelText || "Cancel"
|
|
744
|
-
}) }), /* @__PURE__ */
|
|
896
|
+
}) }), /* @__PURE__ */ Q("div", {
|
|
745
897
|
className: "flex items-center gap-2",
|
|
746
898
|
children: [
|
|
747
|
-
/* @__PURE__ */
|
|
899
|
+
/* @__PURE__ */ Q("span", {
|
|
748
900
|
className: "text-sm text-muted-foreground mr-2",
|
|
749
901
|
children: [
|
|
750
902
|
"Step ",
|
|
751
|
-
|
|
903
|
+
E + 1,
|
|
752
904
|
" of ",
|
|
753
905
|
B
|
|
754
906
|
]
|
|
755
907
|
}),
|
|
756
|
-
!
|
|
908
|
+
!V && /* @__PURE__ */ Q(R, {
|
|
757
909
|
variant: "outline",
|
|
758
|
-
onClick:
|
|
759
|
-
children: [/* @__PURE__ */
|
|
910
|
+
onClick: oe,
|
|
911
|
+
children: [/* @__PURE__ */ Z(xe, { className: "h-4 w-4 mr-1" }), e.prevText || "Back"]
|
|
760
912
|
}),
|
|
761
|
-
|
|
913
|
+
H ? /* @__PURE__ */ Q(R, {
|
|
762
914
|
type: "submit",
|
|
763
|
-
form:
|
|
764
|
-
disabled:
|
|
765
|
-
children: [
|
|
915
|
+
form: L,
|
|
916
|
+
disabled: j || e.mode === "view",
|
|
917
|
+
children: [j && /* @__PURE__ */ Z(Ce, {
|
|
766
918
|
className: "mr-2 h-4 w-4 animate-spin",
|
|
767
919
|
"aria-hidden": !0
|
|
768
|
-
}),
|
|
769
|
-
}) : /* @__PURE__ */
|
|
920
|
+
}), j ? "Submitting..." : e.submitText || (e.mode === "create" ? "Create" : "Update")]
|
|
921
|
+
}) : /* @__PURE__ */ Q(R, {
|
|
770
922
|
type: "submit",
|
|
771
|
-
form:
|
|
772
|
-
children: [e.nextText || "Next", /* @__PURE__ */
|
|
923
|
+
form: L,
|
|
924
|
+
children: [e.nextText || "Next", /* @__PURE__ */ Z(Se, { className: "h-4 w-4 ml-1" })]
|
|
773
925
|
})
|
|
774
926
|
]
|
|
775
927
|
})]
|
|
@@ -777,8 +929,8 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
777
929
|
b
|
|
778
930
|
]
|
|
779
931
|
});
|
|
780
|
-
},
|
|
781
|
-
let { fieldLabel: a } =
|
|
932
|
+
}, Tt = ({ schema: e, dataSource: t, className: r }) => {
|
|
933
|
+
let { fieldLabel: a } = O(), { userId: l } = pe(), [u, d] = c(null), [f, p] = c({}), { saveWithOcc: m, conflictDialog: h } = vt(), [g, _] = c(!0), [v, y] = c(null);
|
|
782
934
|
i(() => {
|
|
783
935
|
(async () => {
|
|
784
936
|
if (!t) {
|
|
@@ -787,32 +939,32 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
787
939
|
}
|
|
788
940
|
try {
|
|
789
941
|
let n = await t.getObjectSchema(e.objectName);
|
|
790
|
-
|
|
942
|
+
d(n);
|
|
791
943
|
} catch (e) {
|
|
792
|
-
|
|
944
|
+
y(e), _(!1);
|
|
793
945
|
}
|
|
794
946
|
})();
|
|
795
947
|
}, [e.objectName, t]);
|
|
796
|
-
let
|
|
948
|
+
let b = s(void 0);
|
|
797
949
|
i(() => {
|
|
798
950
|
let n = !1;
|
|
799
|
-
return (
|
|
951
|
+
return (u || !t) && (async () => {
|
|
800
952
|
if (e.mode === "create" || !e.recordId) {
|
|
801
|
-
|
|
953
|
+
p(We(u, e.initialData || e.initialValues, { currentUserId: l })), _(!1);
|
|
802
954
|
return;
|
|
803
955
|
}
|
|
804
956
|
if (!t) {
|
|
805
|
-
|
|
957
|
+
p(e.initialData || e.initialValues || {}), _(!1);
|
|
806
958
|
return;
|
|
807
959
|
}
|
|
808
|
-
|
|
960
|
+
b.current !== e.recordId && _(!0);
|
|
809
961
|
try {
|
|
810
962
|
let r = await t.findOne(e.objectName, e.recordId);
|
|
811
963
|
if (n) return;
|
|
812
|
-
|
|
964
|
+
b.current = e.recordId, p(r || {});
|
|
813
965
|
} catch (e) {
|
|
814
966
|
if (n) return;
|
|
815
|
-
|
|
967
|
+
y(e);
|
|
816
968
|
} finally {
|
|
817
969
|
n || _(!1);
|
|
818
970
|
}
|
|
@@ -820,7 +972,7 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
820
972
|
n = !0;
|
|
821
973
|
};
|
|
822
974
|
}, [
|
|
823
|
-
|
|
975
|
+
u,
|
|
824
976
|
e.mode,
|
|
825
977
|
e.recordId,
|
|
826
978
|
e.initialData,
|
|
@@ -828,30 +980,32 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
828
980
|
t,
|
|
829
981
|
e.objectName
|
|
830
982
|
]);
|
|
831
|
-
let S = n((t) =>
|
|
832
|
-
objectSchema:
|
|
983
|
+
let S = n((t) => Ze(t, {
|
|
984
|
+
objectSchema: u,
|
|
833
985
|
objectName: e.objectName,
|
|
834
986
|
readOnly: e.readOnly,
|
|
835
987
|
mode: e.mode,
|
|
988
|
+
recordId: e.recordId,
|
|
836
989
|
fieldLabel: a
|
|
837
990
|
}), [
|
|
838
|
-
|
|
991
|
+
u,
|
|
839
992
|
e.readOnly,
|
|
840
993
|
e.mode,
|
|
994
|
+
e.recordId,
|
|
841
995
|
e.objectName,
|
|
842
996
|
a
|
|
843
997
|
]), C = n(async (n) => {
|
|
844
998
|
if (!t) return e.onSuccess && await e.onSuccess(n), n;
|
|
845
999
|
try {
|
|
846
1000
|
let r;
|
|
847
|
-
if (e.mode === "create") r = await t.create(e.objectName, n);
|
|
1001
|
+
if (e.mode === "create") r = await t.create(e.objectName, Ge(n, u));
|
|
848
1002
|
else if (e.mode === "edit" && e.recordId) {
|
|
849
|
-
let i = await
|
|
1003
|
+
let i = await m({
|
|
850
1004
|
dataSource: t,
|
|
851
1005
|
objectName: e.objectName,
|
|
852
1006
|
recordId: e.recordId,
|
|
853
1007
|
payload: n,
|
|
854
|
-
baseRecord:
|
|
1008
|
+
baseRecord: f
|
|
855
1009
|
});
|
|
856
1010
|
if (i.status === "cancelled") return;
|
|
857
1011
|
r = i.result;
|
|
@@ -863,29 +1017,29 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
863
1017
|
}, [
|
|
864
1018
|
e,
|
|
865
1019
|
t,
|
|
866
|
-
|
|
867
|
-
|
|
1020
|
+
m,
|
|
1021
|
+
f
|
|
868
1022
|
]), w = n(() => {
|
|
869
1023
|
e.onCancel && e.onCancel();
|
|
870
|
-
}, [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]),
|
|
871
|
-
if (v) return /* @__PURE__ */
|
|
1024
|
+
}, [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]), k = e.splitDirection || "horizontal", A = e.splitSize || 50;
|
|
1025
|
+
if (v) return /* @__PURE__ */ Q("div", {
|
|
872
1026
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
873
|
-
children: [/* @__PURE__ */
|
|
1027
|
+
children: [/* @__PURE__ */ Z("h3", {
|
|
874
1028
|
className: "text-red-800 font-semibold",
|
|
875
1029
|
children: "Error loading form"
|
|
876
|
-
}), /* @__PURE__ */
|
|
1030
|
+
}), /* @__PURE__ */ Z("p", {
|
|
877
1031
|
className: "text-red-600 text-sm mt-1",
|
|
878
1032
|
children: v.message
|
|
879
1033
|
})]
|
|
880
1034
|
});
|
|
881
|
-
if (g) return /* @__PURE__ */
|
|
1035
|
+
if (g) return /* @__PURE__ */ Q("div", {
|
|
882
1036
|
className: "p-8 text-center",
|
|
883
|
-
children: [/* @__PURE__ */
|
|
1037
|
+
children: [/* @__PURE__ */ Z("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Z("p", {
|
|
884
1038
|
className: "mt-2 text-sm text-gray-600",
|
|
885
1039
|
children: "Loading form..."
|
|
886
1040
|
})]
|
|
887
1041
|
});
|
|
888
|
-
let
|
|
1042
|
+
let j = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, M = e.sections.map((e) => j(e.columns)).filter((e) => e != null), N = j(e.columns) ?? (M.length ? Math.max(...M) : 1), P = dt(N), F = (e, t) => {
|
|
889
1043
|
let n = [];
|
|
890
1044
|
return e.forEach((e, r) => {
|
|
891
1045
|
let i = S(e);
|
|
@@ -896,49 +1050,49 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
896
1050
|
type: "section-divider",
|
|
897
1051
|
colSpan: 4,
|
|
898
1052
|
className: e.className
|
|
899
|
-
}), n.push(...
|
|
1053
|
+
}), n.push(...N > 1 ? $(i, N, j(e.columns)) : i));
|
|
900
1054
|
}), n;
|
|
901
|
-
},
|
|
1055
|
+
}, I = [{
|
|
902
1056
|
key: "primary",
|
|
903
1057
|
sections: E,
|
|
904
|
-
defaultSize:
|
|
1058
|
+
defaultSize: A
|
|
905
1059
|
}, {
|
|
906
1060
|
key: "secondary",
|
|
907
1061
|
sections: D,
|
|
908
|
-
defaultSize: 100 -
|
|
1062
|
+
defaultSize: 100 - A
|
|
909
1063
|
}].map((e) => ({
|
|
910
1064
|
...e,
|
|
911
|
-
fields:
|
|
1065
|
+
fields: F(e.sections, e.key),
|
|
912
1066
|
containerClass: e.sections.length === 1 ? e.sections[0].gridClassName : void 0
|
|
913
1067
|
})).filter((e) => e.fields.length > 0);
|
|
914
|
-
return /* @__PURE__ */
|
|
915
|
-
className:
|
|
916
|
-
children: [/* @__PURE__ */
|
|
1068
|
+
return /* @__PURE__ */ Q("div", {
|
|
1069
|
+
className: Y("w-full @container", r, e.className),
|
|
1070
|
+
children: [/* @__PURE__ */ Z(x, { schema: {
|
|
917
1071
|
type: "form",
|
|
918
1072
|
objectName: e.objectName,
|
|
919
|
-
fields:
|
|
920
|
-
columns:
|
|
921
|
-
...
|
|
1073
|
+
fields: I.flatMap((e) => e.fields),
|
|
1074
|
+
columns: N,
|
|
1075
|
+
...P ? { fieldContainerClass: P } : {},
|
|
922
1076
|
layout: "vertical",
|
|
923
|
-
defaultValues:
|
|
924
|
-
previousValues: e.mode === "edit" && e.recordId ?
|
|
1077
|
+
defaultValues: f,
|
|
1078
|
+
previousValues: e.mode === "edit" && e.recordId ? f : void 0,
|
|
925
1079
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
926
1080
|
cancelLabel: e.cancelText,
|
|
927
1081
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
928
1082
|
showCancel: e.showCancel !== !1,
|
|
929
1083
|
onSubmit: C,
|
|
930
1084
|
onCancel: w,
|
|
931
|
-
fieldPanes:
|
|
1085
|
+
fieldPanes: I.map((e) => ({
|
|
932
1086
|
key: e.key,
|
|
933
1087
|
fields: e.fields.map((e) => e.name),
|
|
934
1088
|
defaultSize: e.defaultSize,
|
|
935
1089
|
...e.containerClass ? { containerClass: e.containerClass } : {}
|
|
936
1090
|
})),
|
|
937
|
-
fieldPanesOrientation:
|
|
1091
|
+
fieldPanesOrientation: k,
|
|
938
1092
|
fieldPanesResizable: e.splitResizable !== !1
|
|
939
|
-
} }),
|
|
1093
|
+
} }), h]
|
|
940
1094
|
});
|
|
941
|
-
},
|
|
1095
|
+
}, Et = /* @__PURE__ */ new Set([
|
|
942
1096
|
"id",
|
|
943
1097
|
"_id",
|
|
944
1098
|
"created_at",
|
|
@@ -947,7 +1101,7 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
947
1101
|
"updatedAt",
|
|
948
1102
|
"organization_id",
|
|
949
1103
|
"organizationId"
|
|
950
|
-
]),
|
|
1104
|
+
]), Dt = /* @__PURE__ */ new Set([
|
|
951
1105
|
"formula",
|
|
952
1106
|
"summary",
|
|
953
1107
|
"rollup",
|
|
@@ -956,15 +1110,15 @@ var Ke = ({ schema: e, dataSource: r, className: i }) => {
|
|
|
956
1110
|
"autonumber",
|
|
957
1111
|
"computed"
|
|
958
1112
|
]);
|
|
959
|
-
function
|
|
1113
|
+
function Ot(e, t) {
|
|
960
1114
|
if (!e || typeof e != "object") return e;
|
|
961
1115
|
let n = {}, r = t?.fields;
|
|
962
|
-
for (let [t, i] of Object.entries(e)) if (!
|
|
1116
|
+
for (let [t, i] of Object.entries(e)) if (!Et.has(t)) {
|
|
963
1117
|
if (r) {
|
|
964
1118
|
let e = r[t];
|
|
965
1119
|
if (!e) continue;
|
|
966
1120
|
let n = String(e.type || "").toLowerCase();
|
|
967
|
-
if (
|
|
1121
|
+
if (Dt.has(n) || e.computed === !0 || e.formula || e.readOnly === !0 || e.readonly === !0) continue;
|
|
968
1122
|
}
|
|
969
1123
|
n[t] = i;
|
|
970
1124
|
}
|
|
@@ -972,31 +1126,31 @@ function et(e, t) {
|
|
|
972
1126
|
}
|
|
973
1127
|
//#endregion
|
|
974
1128
|
//#region src/masterDetailTx.ts
|
|
975
|
-
var
|
|
1129
|
+
var kt = (e) => e == null ? void 0 : e.id ?? e._id ?? e.recordId, At = (e, t) => t ? Ot(e, t) : e, jt = /* @__PURE__ */ new Set([
|
|
976
1130
|
"id",
|
|
977
1131
|
"_id",
|
|
978
1132
|
"recordId"
|
|
979
1133
|
]);
|
|
980
|
-
function
|
|
981
|
-
return !e || Object.entries(e).every(([e, n]) => e === t ||
|
|
1134
|
+
function Mt(e, t) {
|
|
1135
|
+
return !e || Object.entries(e).every(([e, n]) => e === t || jt.has(e) ? !0 : n == null || n === "");
|
|
982
1136
|
}
|
|
983
|
-
function
|
|
1137
|
+
function Nt(e, t, n) {
|
|
984
1138
|
let r = [{
|
|
985
1139
|
object: e,
|
|
986
1140
|
action: "create",
|
|
987
1141
|
data: t
|
|
988
1142
|
}];
|
|
989
|
-
for (let e of n) for (let t of e.rows)
|
|
1143
|
+
for (let e of n) for (let t of e.rows) Mt(t, e.relationshipField) || r.push({
|
|
990
1144
|
object: e.childObject,
|
|
991
1145
|
action: "create",
|
|
992
1146
|
data: {
|
|
993
|
-
...
|
|
1147
|
+
...At(t, e.childSchema),
|
|
994
1148
|
[e.relationshipField]: { $ref: 0 }
|
|
995
1149
|
}
|
|
996
1150
|
});
|
|
997
1151
|
return r;
|
|
998
1152
|
}
|
|
999
|
-
function
|
|
1153
|
+
function Pt(e, t, n, r) {
|
|
1000
1154
|
let i = [{
|
|
1001
1155
|
object: e,
|
|
1002
1156
|
action: "update",
|
|
@@ -1007,21 +1161,21 @@ function ot(e, t, n, r) {
|
|
|
1007
1161
|
let n = (e.rows || []).map((n) => ({
|
|
1008
1162
|
...n,
|
|
1009
1163
|
[e.relationshipField]: t
|
|
1010
|
-
})), { toCreate: r, toUpdate: a, toDelete: o } =
|
|
1164
|
+
})), { toCreate: r, toUpdate: a, toDelete: o } = Ft(e.original || [], n);
|
|
1011
1165
|
for (let t of r) {
|
|
1012
|
-
if (
|
|
1166
|
+
if (Mt(t, e.relationshipField)) continue;
|
|
1013
1167
|
let { id: n, _id: r, recordId: a, ...o } = t;
|
|
1014
1168
|
i.push({
|
|
1015
1169
|
object: e.childObject,
|
|
1016
1170
|
action: "create",
|
|
1017
|
-
data:
|
|
1171
|
+
data: At(o, e.childSchema)
|
|
1018
1172
|
});
|
|
1019
1173
|
}
|
|
1020
1174
|
for (let t of a) i.push({
|
|
1021
1175
|
object: e.childObject,
|
|
1022
1176
|
action: "update",
|
|
1023
|
-
id:
|
|
1024
|
-
data:
|
|
1177
|
+
id: kt(t),
|
|
1178
|
+
data: At(t, e.childSchema)
|
|
1025
1179
|
});
|
|
1026
1180
|
for (let t of o) i.push({
|
|
1027
1181
|
object: e.childObject,
|
|
@@ -1031,15 +1185,15 @@ function ot(e, t, n, r) {
|
|
|
1031
1185
|
}
|
|
1032
1186
|
return i;
|
|
1033
1187
|
}
|
|
1034
|
-
function
|
|
1035
|
-
let n = new Set(t.map(
|
|
1188
|
+
function Ft(e, t) {
|
|
1189
|
+
let n = new Set(t.map(kt).filter(Boolean));
|
|
1036
1190
|
return {
|
|
1037
|
-
toCreate: t.filter((e) => !
|
|
1038
|
-
toUpdate: t.filter((e) =>
|
|
1039
|
-
toDelete: (e || []).map(
|
|
1191
|
+
toCreate: t.filter((e) => !kt(e)),
|
|
1192
|
+
toUpdate: t.filter((e) => kt(e)),
|
|
1193
|
+
toDelete: (e || []).map(kt).filter((e) => !!e && !n.has(e))
|
|
1040
1194
|
};
|
|
1041
1195
|
}
|
|
1042
|
-
function
|
|
1196
|
+
function It(e, t) {
|
|
1043
1197
|
return Array.isArray(e) ? e.reduce((e, n) => {
|
|
1044
1198
|
let r = Number(n?.[t]);
|
|
1045
1199
|
return e + (Number.isFinite(r) ? r : 0);
|
|
@@ -1047,7 +1201,7 @@ function ct(e, t) {
|
|
|
1047
1201
|
}
|
|
1048
1202
|
//#endregion
|
|
1049
1203
|
//#region src/deriveMasterDetail.ts
|
|
1050
|
-
var
|
|
1204
|
+
var Lt = /* @__PURE__ */ new Set([
|
|
1051
1205
|
"id",
|
|
1052
1206
|
"_id",
|
|
1053
1207
|
"recordId",
|
|
@@ -1063,14 +1217,14 @@ var lt = /* @__PURE__ */ new Set([
|
|
|
1063
1217
|
"tenant_id",
|
|
1064
1218
|
"space",
|
|
1065
1219
|
"owner"
|
|
1066
|
-
]),
|
|
1220
|
+
]), Rt = /* @__PURE__ */ new Set([
|
|
1067
1221
|
"position",
|
|
1068
1222
|
"sort_order",
|
|
1069
1223
|
"sequence",
|
|
1070
1224
|
"line_no",
|
|
1071
1225
|
"line_number",
|
|
1072
1226
|
"sort"
|
|
1073
|
-
]),
|
|
1227
|
+
]), zt = /* @__PURE__ */ new Set([
|
|
1074
1228
|
"formula",
|
|
1075
1229
|
"summary",
|
|
1076
1230
|
"rollup",
|
|
@@ -1086,16 +1240,16 @@ var lt = /* @__PURE__ */ new Set([
|
|
|
1086
1240
|
"markdown",
|
|
1087
1241
|
"richtext"
|
|
1088
1242
|
]);
|
|
1089
|
-
function
|
|
1243
|
+
function Bt(e) {
|
|
1090
1244
|
switch (e) {
|
|
1091
1245
|
case "number":
|
|
1092
1246
|
case "percent":
|
|
1093
1247
|
case "rating":
|
|
1094
1248
|
case "slider": return "number";
|
|
1095
1249
|
case "currency": return "currency";
|
|
1096
|
-
case "date":
|
|
1097
|
-
case "datetime":
|
|
1098
|
-
case "time": return "
|
|
1250
|
+
case "date": return "date";
|
|
1251
|
+
case "datetime": return "datetime";
|
|
1252
|
+
case "time": return "time";
|
|
1099
1253
|
case "select":
|
|
1100
1254
|
case "picklist":
|
|
1101
1255
|
case "radio":
|
|
@@ -1109,11 +1263,11 @@ function ft(e) {
|
|
|
1109
1263
|
default: return "text";
|
|
1110
1264
|
}
|
|
1111
1265
|
}
|
|
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 :
|
|
1266
|
+
var Vt = /* @__PURE__ */ new Set(["image", "avatar"]);
|
|
1267
|
+
function Ht(e, t) {
|
|
1268
|
+
e.multiple == null && t?.multiple && (e.multiple = !0), e.accept ?? (Array.isArray(t?.accept) && t.accept.length > 0 ? e.accept = t.accept : Vt.has(t?.type) && (e.accept = ["image/*"]));
|
|
1115
1269
|
}
|
|
1116
|
-
function
|
|
1270
|
+
function Ut(e) {
|
|
1117
1271
|
if (e?.type === "boolean" || e?.type === "toggle") return [{
|
|
1118
1272
|
label: "Yes",
|
|
1119
1273
|
value: "true"
|
|
@@ -1130,7 +1284,7 @@ function ht(e) {
|
|
|
1130
1284
|
value: String(e)
|
|
1131
1285
|
});
|
|
1132
1286
|
}
|
|
1133
|
-
function
|
|
1287
|
+
function Wt(e, t) {
|
|
1134
1288
|
let n = e?.fields;
|
|
1135
1289
|
if (!n || typeof n != "object") return;
|
|
1136
1290
|
let r;
|
|
@@ -1143,7 +1297,7 @@ function gt(e, t) {
|
|
|
1143
1297
|
}
|
|
1144
1298
|
return r;
|
|
1145
1299
|
}
|
|
1146
|
-
var
|
|
1300
|
+
var Gt = [
|
|
1147
1301
|
"name",
|
|
1148
1302
|
"title",
|
|
1149
1303
|
"subject",
|
|
@@ -1151,89 +1305,91 @@ var _t = [
|
|
|
1151
1305
|
"full_name",
|
|
1152
1306
|
"display_name",
|
|
1153
1307
|
"code"
|
|
1154
|
-
],
|
|
1308
|
+
], Kt = {
|
|
1155
1309
|
select: 0,
|
|
1156
1310
|
currency: 1,
|
|
1157
1311
|
number: 1,
|
|
1158
1312
|
lookup: 2,
|
|
1159
1313
|
date: 3,
|
|
1314
|
+
datetime: 3,
|
|
1315
|
+
time: 3,
|
|
1160
1316
|
text: 4
|
|
1161
1317
|
};
|
|
1162
|
-
function
|
|
1163
|
-
return (e.type ?
|
|
1318
|
+
function qt(e) {
|
|
1319
|
+
return (e.type ? Kt[e.type] : void 0) ?? 5;
|
|
1164
1320
|
}
|
|
1165
|
-
function
|
|
1321
|
+
function Jt(e, t) {
|
|
1166
1322
|
if (t <= 0 || e.length <= t) return e;
|
|
1167
|
-
let n = /* @__PURE__ */ new Set(), r = e.find((e) =>
|
|
1168
|
-
r && n.add(r.
|
|
1169
|
-
for (let t of e) t.required && n.add(t.
|
|
1323
|
+
let n = /* @__PURE__ */ new Set(), r = e.find((e) => Gt.includes(e.name)) ?? e[0];
|
|
1324
|
+
r && n.add(r.name);
|
|
1325
|
+
for (let t of e) t.required && n.add(t.name);
|
|
1170
1326
|
let i = e.map((e, t) => ({
|
|
1171
1327
|
c: e,
|
|
1172
1328
|
i: t
|
|
1173
|
-
})).filter(({ c: e }) => !n.has(e.
|
|
1329
|
+
})).filter(({ c: e }) => !n.has(e.name)).sort((e, t) => qt(e.c) - qt(t.c) || e.i - t.i);
|
|
1174
1330
|
for (let { c: e } of i) {
|
|
1175
1331
|
if (n.size >= t) break;
|
|
1176
|
-
n.add(e.
|
|
1332
|
+
n.add(e.name);
|
|
1177
1333
|
}
|
|
1178
|
-
return e.map((e) => n.has(e.
|
|
1334
|
+
return e.map((e) => n.has(e.name) ? e : {
|
|
1179
1335
|
...e,
|
|
1180
1336
|
defaultHidden: !0
|
|
1181
1337
|
});
|
|
1182
1338
|
}
|
|
1183
|
-
function
|
|
1339
|
+
function Yt(e, t = {}) {
|
|
1184
1340
|
let n = e?.fields;
|
|
1185
1341
|
if (!n || typeof n != "object") return [];
|
|
1186
1342
|
let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
|
|
1187
1343
|
for (let [e, t] of Object.entries(n)) {
|
|
1188
1344
|
let n = t;
|
|
1189
|
-
if (
|
|
1345
|
+
if (Lt.has(e) || r.has(e) || Rt.has(e) || n?.system || n?.readonly || n?.hidden || zt.has(n?.type)) continue;
|
|
1190
1346
|
let a = {
|
|
1191
|
-
|
|
1347
|
+
name: e,
|
|
1192
1348
|
label: n?.label || e,
|
|
1193
|
-
type:
|
|
1349
|
+
type: Bt(n?.type),
|
|
1194
1350
|
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" &&
|
|
1351
|
+
}, o = Ut(n);
|
|
1352
|
+
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" && Ht(a, n), n?.readonlyWhen && (a.readonlyWhen = n.readonlyWhen), n?.requiredWhen && (a.requiredWhen = n.requiredWhen);
|
|
1197
1353
|
let s = typeof n?.expression == "string" ? n.expression : n?.expression?.source;
|
|
1198
1354
|
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
1355
|
}
|
|
1200
|
-
return
|
|
1356
|
+
return Jt(i, t.maxColumns ?? 6);
|
|
1201
1357
|
}
|
|
1202
|
-
function
|
|
1358
|
+
function Xt(e, t) {
|
|
1203
1359
|
let n = e ?? [], r = t?.fields;
|
|
1204
1360
|
return !n.length || !r || typeof r != "object" ? n : n.map((e) => {
|
|
1205
1361
|
if (e.type) return e;
|
|
1206
|
-
let t = r[e.
|
|
1362
|
+
let t = r[e.name];
|
|
1207
1363
|
if (!t) return e;
|
|
1208
|
-
let n =
|
|
1364
|
+
let n = Bt(t?.type), i = {
|
|
1209
1365
|
...e,
|
|
1210
1366
|
type: n
|
|
1211
1367
|
};
|
|
1212
|
-
i.label ??= t?.label || e.
|
|
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" &&
|
|
1368
|
+
i.label ??= t?.label || e.name, i.required ??= !!t?.required;
|
|
1369
|
+
let a = Ut(t);
|
|
1370
|
+
n === "select" && a && !i.options && (i.options = a), n === "lookup" && (i.reference ??= t?.reference, i.displayField ??= t?.display_field || t?.reference_field), n === "file" && Ht(i, t), i.readonlyWhen == null && t?.readonlyWhen && (i.readonlyWhen = t.readonlyWhen), i.requiredWhen == null && t?.requiredWhen && (i.requiredWhen = t.requiredWhen);
|
|
1215
1371
|
let o = typeof t?.expression == "string" ? t.expression : t?.expression?.source;
|
|
1216
1372
|
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
1373
|
});
|
|
1218
1374
|
}
|
|
1219
|
-
var
|
|
1375
|
+
var Zt = /* @__PURE__ */ new Set([
|
|
1220
1376
|
"formula",
|
|
1221
1377
|
"summary",
|
|
1222
1378
|
"rollup",
|
|
1223
1379
|
"autonumber",
|
|
1224
1380
|
"auto_number"
|
|
1225
1381
|
]);
|
|
1226
|
-
function
|
|
1382
|
+
function Qt(e, t = {}) {
|
|
1227
1383
|
let n = e?.fields;
|
|
1228
1384
|
if (!n || typeof n != "object") return [];
|
|
1229
1385
|
let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
|
|
1230
1386
|
for (let [e, t] of Object.entries(n)) {
|
|
1231
1387
|
let n = t;
|
|
1232
|
-
|
|
1388
|
+
Lt.has(e) || r.has(e) || Rt.has(e) || n?.system || n?.hidden || Zt.has(n?.type) || i.push(e);
|
|
1233
1389
|
}
|
|
1234
1390
|
return i;
|
|
1235
1391
|
}
|
|
1236
|
-
var
|
|
1392
|
+
var $t = /* @__PURE__ */ new Set([
|
|
1237
1393
|
"textarea",
|
|
1238
1394
|
"richtext",
|
|
1239
1395
|
"html",
|
|
@@ -1242,17 +1398,17 @@ var Tt = /* @__PURE__ */ new Set([
|
|
|
1242
1398
|
"json",
|
|
1243
1399
|
"location",
|
|
1244
1400
|
"address"
|
|
1245
|
-
]),
|
|
1401
|
+
]), en = /* @__PURE__ */ new Set([
|
|
1246
1402
|
"file",
|
|
1247
1403
|
"image",
|
|
1248
1404
|
"avatar"
|
|
1249
1405
|
]);
|
|
1250
|
-
function
|
|
1406
|
+
function tn(e, t, n = {}) {
|
|
1251
1407
|
if (t === "grid" || t === "form") return t;
|
|
1252
|
-
let r = e?.fields ?? {}, i =
|
|
1253
|
-
return i.some((e) =>
|
|
1408
|
+
let r = e?.fields ?? {}, i = Qt(e, { relationshipField: n.relationshipField });
|
|
1409
|
+
return i.some((e) => $t.has(r[e]?.type)) || i.filter((e) => en.has(r[e]?.type)).length >= 2 || i.length > 8 ? "form" : "grid";
|
|
1254
1410
|
}
|
|
1255
|
-
var
|
|
1411
|
+
var nn = [
|
|
1256
1412
|
"amount",
|
|
1257
1413
|
"total",
|
|
1258
1414
|
"subtotal",
|
|
@@ -1260,33 +1416,33 @@ var Ot = [
|
|
|
1260
1416
|
"line_amount",
|
|
1261
1417
|
"net_amount"
|
|
1262
1418
|
];
|
|
1263
|
-
function
|
|
1419
|
+
function rn(e) {
|
|
1264
1420
|
let t = e.filter((e) => e.type === "number" || e.type === "currency");
|
|
1265
1421
|
if (t.length === 0) return;
|
|
1266
1422
|
let n = t.find((e) => e.computed);
|
|
1267
|
-
if (n) return n.
|
|
1268
|
-
let r = t.find((e) =>
|
|
1269
|
-
if (r) return r.
|
|
1423
|
+
if (n) return n.name;
|
|
1424
|
+
let r = t.find((e) => nn.includes(e.name));
|
|
1425
|
+
if (r) return r.name;
|
|
1270
1426
|
let i = [...t].reverse().find((e) => e.type === "currency");
|
|
1271
|
-
return i ? i.
|
|
1427
|
+
return i ? i.name : t[t.length - 1].name;
|
|
1272
1428
|
}
|
|
1273
|
-
function
|
|
1274
|
-
let i = r.relationshipField ||
|
|
1429
|
+
function an(e, t, n, r = {}) {
|
|
1430
|
+
let i = r.relationshipField || Wt(t, n);
|
|
1275
1431
|
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 ?
|
|
1432
|
+
let a = r.columns?.length ? Xt(r.columns, t) : Yt(t, { relationshipField: i }), o = r.amountField || rn(a);
|
|
1277
1433
|
return {
|
|
1278
1434
|
childObject: e,
|
|
1279
1435
|
relationshipField: i,
|
|
1280
1436
|
columns: a,
|
|
1281
|
-
formFields:
|
|
1282
|
-
mode:
|
|
1437
|
+
formFields: Qt(t, { relationshipField: i }),
|
|
1438
|
+
mode: tn(t, r.inlineEdit ?? (t?.fields)?.[i]?.inlineEdit, { relationshipField: i }),
|
|
1283
1439
|
amountField: o,
|
|
1284
|
-
sortField: Object.keys(t?.fields ?? {}).find((e) =>
|
|
1440
|
+
sortField: Object.keys(t?.fields ?? {}).find((e) => Rt.has(e))
|
|
1285
1441
|
};
|
|
1286
1442
|
}
|
|
1287
1443
|
//#endregion
|
|
1288
1444
|
//#region src/MasterDetailForm.tsx
|
|
1289
|
-
function
|
|
1445
|
+
function on(e) {
|
|
1290
1446
|
if (!e) return {};
|
|
1291
1447
|
let t = {};
|
|
1292
1448
|
return e.querySelectorAll("[name]").forEach((e) => {
|
|
@@ -1318,13 +1474,13 @@ function jt(e) {
|
|
|
1318
1474
|
}
|
|
1319
1475
|
}), t;
|
|
1320
1476
|
}
|
|
1321
|
-
var
|
|
1477
|
+
var sn = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, formKey: o, onRowExpand: l, onAddViaForm: u }) => {
|
|
1322
1478
|
let [d, f] = c({}), p = s("");
|
|
1323
1479
|
i(() => {
|
|
1324
1480
|
let e = r.current;
|
|
1325
1481
|
if (!e) return;
|
|
1326
1482
|
let t = () => {
|
|
1327
|
-
let t =
|
|
1483
|
+
let t = on(e), n;
|
|
1328
1484
|
try {
|
|
1329
1485
|
n = JSON.stringify(t);
|
|
1330
1486
|
} catch {
|
|
@@ -1348,16 +1504,16 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1348
1504
|
o,
|
|
1349
1505
|
e.length
|
|
1350
1506
|
]);
|
|
1351
|
-
let m = d[a], h = m === void 0 ? null : Number.isFinite(Number(m)) ? Number(m) : 0, g = e.reduce((e, n, r) => e +
|
|
1507
|
+
let m = d[a], h = m === void 0 ? null : Number.isFinite(Number(m)) ? Number(m) : 0, g = e.reduce((e, n, r) => e + It(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
1508
|
minimumFractionDigits: 2,
|
|
1353
1509
|
maximumFractionDigits: 2
|
|
1354
1510
|
})}`;
|
|
1355
|
-
return /* @__PURE__ */
|
|
1511
|
+
return /* @__PURE__ */ Q(De, { children: [e.map((e, r) => /* @__PURE__ */ Q("section", {
|
|
1356
1512
|
className: "space-y-2",
|
|
1357
|
-
children: [/* @__PURE__ */
|
|
1513
|
+
children: [/* @__PURE__ */ Z("h3", {
|
|
1358
1514
|
className: "text-sm font-medium text-foreground",
|
|
1359
1515
|
children: e.title || "Line Items"
|
|
1360
|
-
}), e.columns?.length ? /* @__PURE__ */
|
|
1516
|
+
}), e.columns?.length ? /* @__PURE__ */ Z(A, {
|
|
1361
1517
|
value: t[r]?.rows ?? [],
|
|
1362
1518
|
onChange: (e) => n(r, e),
|
|
1363
1519
|
contextRecord: d,
|
|
@@ -1372,54 +1528,54 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1372
1528
|
max_rows: e.maxRows,
|
|
1373
1529
|
add_label: e.inlineMode === "form" ? e.addLabel || "Add" : e.addLabel
|
|
1374
1530
|
}
|
|
1375
|
-
}) : /* @__PURE__ */
|
|
1531
|
+
}) : /* @__PURE__ */ Z("p", {
|
|
1376
1532
|
className: "py-4 text-sm text-muted-foreground",
|
|
1377
1533
|
children: "Loading columns…"
|
|
1378
1534
|
})]
|
|
1379
|
-
}, `${e.childObject}-${r}`)), _ && /* @__PURE__ */
|
|
1535
|
+
}, `${e.childObject}-${r}`)), _ && /* @__PURE__ */ Z("div", {
|
|
1380
1536
|
className: "flex justify-end",
|
|
1381
|
-
children: /* @__PURE__ */
|
|
1537
|
+
children: /* @__PURE__ */ Q("dl", {
|
|
1382
1538
|
className: "w-64 space-y-1.5 text-sm",
|
|
1383
1539
|
"data-testid": "md-totals",
|
|
1384
1540
|
children: [
|
|
1385
|
-
/* @__PURE__ */
|
|
1541
|
+
/* @__PURE__ */ Q("div", {
|
|
1386
1542
|
className: "flex items-center justify-between",
|
|
1387
|
-
children: [/* @__PURE__ */
|
|
1543
|
+
children: [/* @__PURE__ */ Z("dt", {
|
|
1388
1544
|
className: "text-muted-foreground",
|
|
1389
1545
|
children: "Subtotal"
|
|
1390
|
-
}), /* @__PURE__ */
|
|
1546
|
+
}), /* @__PURE__ */ Z("dd", {
|
|
1391
1547
|
className: "tabular-nums",
|
|
1392
1548
|
"data-testid": "md-subtotal",
|
|
1393
|
-
children:
|
|
1549
|
+
children: x(g)
|
|
1394
1550
|
})]
|
|
1395
1551
|
}),
|
|
1396
|
-
/* @__PURE__ */
|
|
1552
|
+
/* @__PURE__ */ Q("div", {
|
|
1397
1553
|
className: "flex items-center justify-between",
|
|
1398
|
-
children: [/* @__PURE__ */
|
|
1554
|
+
children: [/* @__PURE__ */ Q("dt", {
|
|
1399
1555
|
className: "text-muted-foreground",
|
|
1400
1556
|
children: [
|
|
1401
1557
|
"Tax (",
|
|
1402
1558
|
v,
|
|
1403
1559
|
"%)"
|
|
1404
1560
|
]
|
|
1405
|
-
}), /* @__PURE__ */
|
|
1561
|
+
}), /* @__PURE__ */ Z("dd", {
|
|
1406
1562
|
className: "tabular-nums",
|
|
1407
1563
|
"data-testid": "md-tax",
|
|
1408
|
-
children:
|
|
1564
|
+
children: x(y)
|
|
1409
1565
|
})]
|
|
1410
1566
|
}),
|
|
1411
|
-
/* @__PURE__ */
|
|
1567
|
+
/* @__PURE__ */ Q("div", {
|
|
1412
1568
|
className: "flex items-center justify-between border-t border-border pt-1.5 text-base font-semibold",
|
|
1413
|
-
children: [/* @__PURE__ */
|
|
1569
|
+
children: [/* @__PURE__ */ Z("dt", { children: "Total" }), /* @__PURE__ */ Z("dd", {
|
|
1414
1570
|
className: "tabular-nums",
|
|
1415
1571
|
"data-testid": "md-grand-total",
|
|
1416
|
-
children:
|
|
1572
|
+
children: x(b)
|
|
1417
1573
|
})]
|
|
1418
1574
|
})
|
|
1419
1575
|
]
|
|
1420
1576
|
})
|
|
1421
1577
|
})] });
|
|
1422
|
-
},
|
|
1578
|
+
}, cn = ({ schema: e, dataSource: t, className: r }) => {
|
|
1423
1579
|
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
1580
|
i(() => {
|
|
1425
1581
|
if (!u) {
|
|
@@ -1436,9 +1592,9 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1436
1592
|
let r = await t.getObjectSchema(n.childObject);
|
|
1437
1593
|
if (n.relationshipField && n.columns?.length) return {
|
|
1438
1594
|
...n,
|
|
1439
|
-
columns:
|
|
1595
|
+
columns: Xt(n.columns, r)
|
|
1440
1596
|
};
|
|
1441
|
-
let i =
|
|
1597
|
+
let i = an(n.childObject, r, e.objectName, {
|
|
1442
1598
|
relationshipField: n.relationshipField,
|
|
1443
1599
|
columns: n.columns,
|
|
1444
1600
|
amountField: n.amountField
|
|
@@ -1465,12 +1621,12 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1465
1621
|
e.objectName,
|
|
1466
1622
|
e.details
|
|
1467
1623
|
]);
|
|
1468
|
-
let [
|
|
1624
|
+
let [m, h] = c(() => a.map(() => ({
|
|
1469
1625
|
rows: [],
|
|
1470
1626
|
original: []
|
|
1471
|
-
}))),
|
|
1472
|
-
|
|
1473
|
-
let
|
|
1627
|
+
}))), g = s(m);
|
|
1628
|
+
g.current = m;
|
|
1629
|
+
let _ = s({});
|
|
1474
1630
|
i(() => {
|
|
1475
1631
|
let e = t;
|
|
1476
1632
|
if (!e || typeof e.getObjectSchema != "function") return;
|
|
@@ -1486,7 +1642,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1486
1642
|
if (n) return;
|
|
1487
1643
|
let i = {};
|
|
1488
1644
|
for (let [e, n] of t) n && (i[e] = n);
|
|
1489
|
-
|
|
1645
|
+
_.current = i;
|
|
1490
1646
|
})(), () => {
|
|
1491
1647
|
n = !0;
|
|
1492
1648
|
};
|
|
@@ -1522,7 +1678,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1522
1678
|
};
|
|
1523
1679
|
}
|
|
1524
1680
|
}));
|
|
1525
|
-
n ||
|
|
1681
|
+
n || h(r);
|
|
1526
1682
|
})(), () => {
|
|
1527
1683
|
n = !0;
|
|
1528
1684
|
};
|
|
@@ -1533,20 +1689,20 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1533
1689
|
d
|
|
1534
1690
|
]);
|
|
1535
1691
|
let E = n((e, t) => {
|
|
1536
|
-
|
|
1692
|
+
h((n) => n.map((n, r) => r === e ? {
|
|
1537
1693
|
...n,
|
|
1538
1694
|
rows: t
|
|
1539
1695
|
} : n));
|
|
1540
|
-
}, []), D = e.taxRateField || "tax_rate", [O, k] = c(null), A = O ?
|
|
1541
|
-
|
|
1696
|
+
}, []), 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) => {
|
|
1697
|
+
h((r) => r.map((r, i) => i === e ? {
|
|
1542
1698
|
...r,
|
|
1543
1699
|
rows: r.rows.map((e, r) => r === t ? {
|
|
1544
1700
|
...e,
|
|
1545
1701
|
...n
|
|
1546
1702
|
} : e)
|
|
1547
1703
|
} : r));
|
|
1548
|
-
}, []),
|
|
1549
|
-
|
|
1704
|
+
}, []), N = n((e) => {
|
|
1705
|
+
h((t) => {
|
|
1550
1706
|
let n = t.map((t, n) => n === e ? {
|
|
1551
1707
|
...t,
|
|
1552
1708
|
rows: [...t.rows, {}]
|
|
@@ -1557,13 +1713,13 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1557
1713
|
isNew: !0
|
|
1558
1714
|
}), n;
|
|
1559
1715
|
});
|
|
1560
|
-
}, []),
|
|
1561
|
-
k((e) => (e?.isNew &&
|
|
1716
|
+
}, []), P = n(() => {
|
|
1717
|
+
k((e) => (e?.isNew && h((t) => t.map((t, n) => n === e.detailIdx ? {
|
|
1562
1718
|
...t,
|
|
1563
1719
|
rows: t.rows.filter((t, n) => n !== e.rowIdx)
|
|
1564
1720
|
} : t)), null));
|
|
1565
|
-
}, []),
|
|
1566
|
-
T(), e.onSuccess ||
|
|
1721
|
+
}, []), F = n(async (t) => {
|
|
1722
|
+
T(), e.onSuccess || X.success(l ? e.title ? `${e.title} saved` : "Saved" : "Created"), l || (h(p.map(() => ({
|
|
1567
1723
|
rows: [],
|
|
1568
1724
|
original: []
|
|
1569
1725
|
}))), b((e) => e + 1)), await e.onSuccess?.(t);
|
|
@@ -1573,27 +1729,27 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1573
1729
|
e.title,
|
|
1574
1730
|
p.length,
|
|
1575
1731
|
T
|
|
1576
|
-
]),
|
|
1577
|
-
T(),
|
|
1578
|
-
}, [e, T]),
|
|
1732
|
+
]), I = n((t) => {
|
|
1733
|
+
T(), X.error(t?.message || "Save failed"), e.onError?.(t);
|
|
1734
|
+
}, [e, T]), ee = n(async (n) => {
|
|
1579
1735
|
if (!t) throw Error("MasterDetailForm: dataSource is required");
|
|
1580
1736
|
let r = { ...n };
|
|
1581
1737
|
p.forEach((e, t) => {
|
|
1582
|
-
e.totalField && (r[e.totalField] =
|
|
1738
|
+
e.totalField && (r[e.totalField] = It(g.current[t]?.rows ?? [], e.amountField || "amount"));
|
|
1583
1739
|
});
|
|
1584
|
-
let i = l ?
|
|
1740
|
+
let i = l ? Pt(e.objectName, String(e.recordId), r, p.filter((e) => e.relationshipField).map((e, t) => ({
|
|
1585
1741
|
childObject: e.childObject,
|
|
1586
1742
|
relationshipField: e.relationshipField,
|
|
1587
|
-
rows:
|
|
1588
|
-
original:
|
|
1589
|
-
childSchema:
|
|
1590
|
-
}))) :
|
|
1743
|
+
rows: g.current[t]?.rows ?? [],
|
|
1744
|
+
original: g.current[t]?.original ?? [],
|
|
1745
|
+
childSchema: _.current[e.childObject]
|
|
1746
|
+
}))) : Nt(e.objectName, r, p.filter((e) => e.relationshipField).map((e, t) => ({
|
|
1591
1747
|
childObject: e.childObject,
|
|
1592
1748
|
relationshipField: e.relationshipField,
|
|
1593
|
-
rows:
|
|
1594
|
-
childSchema:
|
|
1749
|
+
rows: g.current[t]?.rows ?? [],
|
|
1750
|
+
childSchema: _.current[e.childObject]
|
|
1595
1751
|
})));
|
|
1596
|
-
return (await
|
|
1752
|
+
return (await v(t, i))?.results?.[0] ?? {
|
|
1597
1753
|
...r,
|
|
1598
1754
|
id: e.recordId
|
|
1599
1755
|
};
|
|
@@ -1603,7 +1759,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1603
1759
|
e.objectName,
|
|
1604
1760
|
e.recordId,
|
|
1605
1761
|
l
|
|
1606
|
-
]),
|
|
1762
|
+
]), te = o(() => ({
|
|
1607
1763
|
type: "object-form",
|
|
1608
1764
|
objectName: e.objectName,
|
|
1609
1765
|
mode: e.mode ?? "create",
|
|
@@ -1616,65 +1772,65 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1616
1772
|
title: e.title,
|
|
1617
1773
|
showSubmit: !1,
|
|
1618
1774
|
showCancel: !1,
|
|
1619
|
-
submitHandler:
|
|
1620
|
-
onSuccess:
|
|
1621
|
-
onError:
|
|
1775
|
+
submitHandler: ee,
|
|
1776
|
+
onSuccess: F,
|
|
1777
|
+
onError: I
|
|
1622
1778
|
}), [
|
|
1623
1779
|
e,
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
]),
|
|
1628
|
-
C.current ||
|
|
1629
|
-
(
|
|
1780
|
+
ee,
|
|
1781
|
+
F,
|
|
1782
|
+
I
|
|
1783
|
+
]), L = s(null), ne = e.submitText ?? (l ? "Save" : "Create"), re = n(() => {
|
|
1784
|
+
C.current || L.current?.querySelector("form") && (C.current = !0, S(!0), setTimeout(() => {
|
|
1785
|
+
(L.current?.querySelector("form"))?.requestSubmit();
|
|
1630
1786
|
}, 0), w.current = setTimeout(() => T(), 1500));
|
|
1631
1787
|
}, [T]);
|
|
1632
1788
|
return i(() => () => {
|
|
1633
1789
|
w.current && clearTimeout(w.current);
|
|
1634
|
-
}, []), /* @__PURE__ */
|
|
1635
|
-
className:
|
|
1790
|
+
}, []), /* @__PURE__ */ Q("div", {
|
|
1791
|
+
className: Y("space-y-6", r, e.className),
|
|
1636
1792
|
children: [
|
|
1637
|
-
/* @__PURE__ */
|
|
1638
|
-
ref:
|
|
1639
|
-
children: /* @__PURE__ */
|
|
1640
|
-
schema:
|
|
1793
|
+
/* @__PURE__ */ Z("div", {
|
|
1794
|
+
ref: L,
|
|
1795
|
+
children: /* @__PURE__ */ Z(vn, {
|
|
1796
|
+
schema: te,
|
|
1641
1797
|
dataSource: t
|
|
1642
1798
|
}, y)
|
|
1643
1799
|
}),
|
|
1644
|
-
/* @__PURE__ */
|
|
1800
|
+
/* @__PURE__ */ Z(sn, {
|
|
1645
1801
|
details: p,
|
|
1646
|
-
state:
|
|
1802
|
+
state: m,
|
|
1647
1803
|
setRows: E,
|
|
1648
|
-
formHostRef:
|
|
1804
|
+
formHostRef: L,
|
|
1649
1805
|
taxRateField: D,
|
|
1650
1806
|
formKey: y,
|
|
1651
1807
|
onRowExpand: (e, t) => k({
|
|
1652
1808
|
detailIdx: e,
|
|
1653
1809
|
rowIdx: t
|
|
1654
1810
|
}),
|
|
1655
|
-
onAddViaForm:
|
|
1811
|
+
onAddViaForm: N
|
|
1656
1812
|
}),
|
|
1657
|
-
O && j && /* @__PURE__ */
|
|
1813
|
+
O && j && /* @__PURE__ */ Q(z, {
|
|
1658
1814
|
className: "border-primary/40 shadow-none ring-1 ring-primary/10",
|
|
1659
1815
|
"data-testid": "md-row-form",
|
|
1660
|
-
children: [/* @__PURE__ */
|
|
1816
|
+
children: [/* @__PURE__ */ Q(H, {
|
|
1661
1817
|
className: "pb-2 flex flex-row items-center justify-between gap-2 space-y-0",
|
|
1662
|
-
children: [/* @__PURE__ */
|
|
1818
|
+
children: [/* @__PURE__ */ Q(U, {
|
|
1663
1819
|
className: "text-sm font-medium",
|
|
1664
1820
|
children: [
|
|
1665
1821
|
j.title || "Line item",
|
|
1666
1822
|
" — row ",
|
|
1667
1823
|
O.rowIdx + 1
|
|
1668
1824
|
]
|
|
1669
|
-
}), /* @__PURE__ */
|
|
1825
|
+
}), /* @__PURE__ */ Z(R, {
|
|
1670
1826
|
type: "button",
|
|
1671
1827
|
variant: "ghost",
|
|
1672
1828
|
size: "sm",
|
|
1673
1829
|
className: "h-7 text-xs text-muted-foreground",
|
|
1674
|
-
onClick:
|
|
1830
|
+
onClick: P,
|
|
1675
1831
|
children: "Close"
|
|
1676
1832
|
})]
|
|
1677
|
-
}), /* @__PURE__ */
|
|
1833
|
+
}), /* @__PURE__ */ Z(B, { children: /* @__PURE__ */ Z(vn, {
|
|
1678
1834
|
schema: {
|
|
1679
1835
|
type: "object-form",
|
|
1680
1836
|
objectName: j.childObject,
|
|
@@ -1686,42 +1842,82 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1686
1842
|
onSuccess: (e) => {
|
|
1687
1843
|
M(O.detailIdx, O.rowIdx, e), k(null);
|
|
1688
1844
|
},
|
|
1689
|
-
onCancel:
|
|
1845
|
+
onCancel: P
|
|
1690
1846
|
},
|
|
1691
1847
|
dataSource: t
|
|
1692
1848
|
}, `row-${O.detailIdx}-${O.rowIdx}`) })]
|
|
1693
1849
|
}),
|
|
1694
|
-
e.showSubmit !== !1 && /* @__PURE__ */
|
|
1850
|
+
e.showSubmit !== !1 && /* @__PURE__ */ Q("div", {
|
|
1695
1851
|
className: "flex items-center justify-end gap-2 border-t border-border pt-4",
|
|
1696
|
-
children: [e.onCancel && /* @__PURE__ */
|
|
1852
|
+
children: [e.onCancel && /* @__PURE__ */ Z(R, {
|
|
1697
1853
|
type: "button",
|
|
1698
1854
|
variant: "outline",
|
|
1699
1855
|
onClick: e.onCancel,
|
|
1700
1856
|
disabled: x,
|
|
1701
1857
|
"data-testid": "md-form-cancel",
|
|
1702
1858
|
children: e.cancelText ?? "Cancel"
|
|
1703
|
-
}), /* @__PURE__ */
|
|
1859
|
+
}), /* @__PURE__ */ Z(R, {
|
|
1704
1860
|
type: "button",
|
|
1705
|
-
onClick:
|
|
1861
|
+
onClick: re,
|
|
1706
1862
|
disabled: x || u && !d,
|
|
1707
1863
|
"data-testid": "md-form-submit",
|
|
1708
|
-
children: x ? "Saving…" :
|
|
1864
|
+
children: x ? "Saving…" : ne
|
|
1709
1865
|
})]
|
|
1710
1866
|
})
|
|
1711
1867
|
]
|
|
1712
1868
|
});
|
|
1713
|
-
}
|
|
1869
|
+
};
|
|
1870
|
+
//#endregion
|
|
1871
|
+
//#region src/flatFields.ts
|
|
1872
|
+
function ln(e) {
|
|
1873
|
+
let t = e.fields || Object.keys(e.objectSchema?.fields || {}), n = [];
|
|
1874
|
+
for (let r of t) {
|
|
1875
|
+
let t = typeof r == "string" ? r : r?.name;
|
|
1876
|
+
if (!t) continue;
|
|
1877
|
+
let i = e.objectSchema?.fields?.[t];
|
|
1878
|
+
i && n.push({
|
|
1879
|
+
...Ye(t, e),
|
|
1880
|
+
group: i.group
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
return n;
|
|
1884
|
+
}
|
|
1885
|
+
//#endregion
|
|
1886
|
+
//#region src/fieldGroups.ts
|
|
1887
|
+
function un(e, t) {
|
|
1888
|
+
let n = me({
|
|
1889
|
+
fieldGroups: t,
|
|
1890
|
+
fields: Object.fromEntries(e.map((e) => [e.name, { group: e.group }]))
|
|
1891
|
+
});
|
|
1892
|
+
if (!n) return null;
|
|
1893
|
+
let r = new Set(n.flatMap((e) => e.fields)), i = e.map((e) => e.name).filter((e) => !r.has(e)), a = n.map((e) => ({
|
|
1894
|
+
...e.key === void 0 ? {} : { name: e.key },
|
|
1895
|
+
...e.key === void 0 ? {} : { label: e.label ?? e.key },
|
|
1896
|
+
fields: [...e.fields],
|
|
1897
|
+
...e.collapse === "none" ? {} : { collapsible: !0 },
|
|
1898
|
+
...e.collapse === "collapsed" ? { collapsed: !0 } : {}
|
|
1899
|
+
}));
|
|
1900
|
+
if (i.length > 0) {
|
|
1901
|
+
let e = a[a.length - 1];
|
|
1902
|
+
e && e.name === void 0 ? e.fields = [...e.fields ?? [], ...i] : a.push({ fields: i });
|
|
1903
|
+
}
|
|
1904
|
+
return a;
|
|
1905
|
+
}
|
|
1906
|
+
//#endregion
|
|
1907
|
+
//#region src/DrawerForm.tsx
|
|
1908
|
+
var dn = {
|
|
1714
1909
|
1: void 0,
|
|
1715
1910
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
1716
1911
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
1717
1912
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
1718
|
-
},
|
|
1913
|
+
}, fn = Ee({
|
|
1719
1914
|
"form.discardTitle": "Discard changes?",
|
|
1720
1915
|
"form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
|
|
1916
|
+
"form.dialogDescriptionFallback": "Complete the form fields, then submit or cancel.",
|
|
1721
1917
|
"form.keepEditing": "Keep editing",
|
|
1722
1918
|
"form.discard": "Discard"
|
|
1723
|
-
}, "form.discardTitle"),
|
|
1724
|
-
let { fieldLabel: l } =
|
|
1919
|
+
}, "form.discardTitle"), pn = ({ schema: e, dataSource: t, className: r }) => {
|
|
1920
|
+
let { fieldLabel: l, sectionLabel: u } = O(), { userId: d } = pe(), { t: f } = fn(), p = T(), [m, h] = c(null), [g, _] = c([]), [v, y] = c({}), [b, S] = c(!0), [C, w] = c(null), [E, D] = c(!1), [k, A] = c(!1), { saveWithOcc: j, conflictDialog: M } = vt(), [N, z] = c(!1), B = s(!1), V = e.confirmOnDiscard !== !1, H = e.open !== !1, U = e.drawerSide || "right", ie = a(), [W, G] = c(() => {
|
|
1725
1921
|
let t = {};
|
|
1726
1922
|
return e.sections?.forEach((e, n) => {
|
|
1727
1923
|
let r = e.name || String(n);
|
|
@@ -1731,45 +1927,45 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1731
1927
|
i(() => {
|
|
1732
1928
|
(async () => {
|
|
1733
1929
|
if (!t) {
|
|
1734
|
-
|
|
1930
|
+
S(!1);
|
|
1735
1931
|
return;
|
|
1736
1932
|
}
|
|
1737
1933
|
try {
|
|
1738
1934
|
let n = await t.getObjectSchema(e.objectName);
|
|
1739
|
-
|
|
1935
|
+
h(n);
|
|
1740
1936
|
} catch (e) {
|
|
1741
|
-
|
|
1937
|
+
w(e), S(!1);
|
|
1742
1938
|
}
|
|
1743
1939
|
})();
|
|
1744
1940
|
}, [e.objectName, t]);
|
|
1745
|
-
let
|
|
1941
|
+
let ae = s(void 0);
|
|
1746
1942
|
i(() => {
|
|
1747
1943
|
let n = !1;
|
|
1748
|
-
return (
|
|
1944
|
+
return (m || !t) && (async () => {
|
|
1749
1945
|
if (e.mode === "create" || !e.recordId) {
|
|
1750
|
-
|
|
1946
|
+
y(We(m, e.initialData || e.initialValues, { currentUserId: d })), S(!1);
|
|
1751
1947
|
return;
|
|
1752
1948
|
}
|
|
1753
1949
|
if (!t) {
|
|
1754
|
-
|
|
1950
|
+
y(e.initialData || e.initialValues || {}), S(!1);
|
|
1755
1951
|
return;
|
|
1756
1952
|
}
|
|
1757
|
-
|
|
1953
|
+
ae.current !== e.recordId && (S(!0), D(!1));
|
|
1758
1954
|
try {
|
|
1759
1955
|
let r = await t.findOne(e.objectName, e.recordId);
|
|
1760
1956
|
if (n) return;
|
|
1761
|
-
|
|
1957
|
+
ae.current = e.recordId, y(r || {});
|
|
1762
1958
|
} catch (e) {
|
|
1763
1959
|
if (n) return;
|
|
1764
|
-
|
|
1960
|
+
w(e);
|
|
1765
1961
|
} finally {
|
|
1766
|
-
n ||
|
|
1962
|
+
n || S(!1);
|
|
1767
1963
|
}
|
|
1768
1964
|
})(), () => {
|
|
1769
1965
|
n = !0;
|
|
1770
1966
|
};
|
|
1771
1967
|
}, [
|
|
1772
|
-
|
|
1968
|
+
m,
|
|
1773
1969
|
e.mode,
|
|
1774
1970
|
e.recordId,
|
|
1775
1971
|
e.initialData,
|
|
@@ -1777,52 +1973,43 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1777
1973
|
t,
|
|
1778
1974
|
e.objectName
|
|
1779
1975
|
]);
|
|
1780
|
-
let
|
|
1781
|
-
objectSchema:
|
|
1976
|
+
let K = n((t) => Ze(t, {
|
|
1977
|
+
objectSchema: m,
|
|
1782
1978
|
objectName: e.objectName,
|
|
1783
1979
|
readOnly: e.readOnly,
|
|
1784
1980
|
mode: e.mode,
|
|
1981
|
+
recordId: e.recordId,
|
|
1785
1982
|
fieldLabel: l
|
|
1786
1983
|
}), [
|
|
1787
|
-
|
|
1984
|
+
m,
|
|
1788
1985
|
e.readOnly,
|
|
1789
1986
|
e.mode,
|
|
1987
|
+
e.recordId,
|
|
1790
1988
|
e.objectName,
|
|
1791
1989
|
l
|
|
1792
1990
|
]);
|
|
1793
1991
|
i(() => {
|
|
1794
|
-
if (!
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
type: w(i.type),
|
|
1813
|
-
required: i.required || !1,
|
|
1814
|
-
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
1815
|
-
placeholder: i.placeholder,
|
|
1816
|
-
description: i.help || i.description,
|
|
1817
|
-
validation: S(i),
|
|
1818
|
-
field: i,
|
|
1819
|
-
options: i.options,
|
|
1820
|
-
multiple: i.multiple
|
|
1821
|
-
});
|
|
1992
|
+
if (!(!m && t)) {
|
|
1993
|
+
if (e.customFields?.length) {
|
|
1994
|
+
_(e.customFields), S(!1);
|
|
1995
|
+
return;
|
|
1996
|
+
}
|
|
1997
|
+
if (e.sections?.length) {
|
|
1998
|
+
S(!1);
|
|
1999
|
+
return;
|
|
2000
|
+
}
|
|
2001
|
+
m && (_(ln({
|
|
2002
|
+
fields: e.fields,
|
|
2003
|
+
objectSchema: m,
|
|
2004
|
+
objectName: e.objectName,
|
|
2005
|
+
readOnly: e.readOnly,
|
|
2006
|
+
mode: e.mode,
|
|
2007
|
+
recordId: e.recordId,
|
|
2008
|
+
fieldLabel: l
|
|
2009
|
+
})), S(!1));
|
|
1822
2010
|
}
|
|
1823
|
-
g(r), C(!1);
|
|
1824
2011
|
}, [
|
|
1825
|
-
|
|
2012
|
+
m,
|
|
1826
2013
|
e.fields,
|
|
1827
2014
|
e.customFields,
|
|
1828
2015
|
e.sections,
|
|
@@ -1830,14 +2017,32 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1830
2017
|
e.mode,
|
|
1831
2018
|
t
|
|
1832
2019
|
]);
|
|
1833
|
-
let
|
|
1834
|
-
|
|
2020
|
+
let J = o(() => {
|
|
2021
|
+
if (e.sections?.length || e.customFields?.length) return null;
|
|
2022
|
+
let t = st(g, m);
|
|
2023
|
+
e.mode === "create" && (t = lt(t, m));
|
|
2024
|
+
let n = un(t, m?.fieldGroups);
|
|
2025
|
+
if (!n) return null;
|
|
2026
|
+
let r = e.columns && e.columns > 0 ? Math.min(Math.floor(e.columns), 4) : rt(t.length);
|
|
2027
|
+
return n.map((e) => ({
|
|
2028
|
+
...e,
|
|
2029
|
+
columns: r
|
|
2030
|
+
}));
|
|
2031
|
+
}, [
|
|
2032
|
+
e.sections,
|
|
2033
|
+
e.customFields,
|
|
2034
|
+
e.columns,
|
|
2035
|
+
e.mode,
|
|
2036
|
+
g,
|
|
2037
|
+
m
|
|
2038
|
+
]), ue = n(async (n) => {
|
|
2039
|
+
z(!0);
|
|
1835
2040
|
try {
|
|
1836
2041
|
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);
|
|
2042
|
+
let r, i = Ot(n, m);
|
|
2043
|
+
if (e.mode === "create") r = await t.create(e.objectName, Ge(i, m));
|
|
1839
2044
|
else if (e.mode === "edit" && e.recordId) {
|
|
1840
|
-
let n = await
|
|
2045
|
+
let n = await j({
|
|
1841
2046
|
dataSource: t,
|
|
1842
2047
|
objectName: e.objectName,
|
|
1843
2048
|
recordId: e.recordId,
|
|
@@ -1851,73 +2056,73 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1851
2056
|
} catch (t) {
|
|
1852
2057
|
throw e.onError && e.onError(t), t;
|
|
1853
2058
|
} finally {
|
|
1854
|
-
|
|
2059
|
+
z(!1);
|
|
1855
2060
|
}
|
|
1856
2061
|
}, [
|
|
1857
2062
|
e,
|
|
1858
2063
|
t,
|
|
1859
|
-
|
|
1860
|
-
|
|
2064
|
+
m,
|
|
2065
|
+
j,
|
|
1861
2066
|
v
|
|
1862
|
-
]),
|
|
1863
|
-
|
|
1864
|
-
}, [e]),
|
|
1865
|
-
|
|
2067
|
+
]), X = n(() => {
|
|
2068
|
+
A(!1), B.current && (B.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
|
|
2069
|
+
}, [e]), de = n((e) => {
|
|
2070
|
+
B.current = e, V && E ? A(!0) : X();
|
|
1866
2071
|
}, [
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
2072
|
+
V,
|
|
2073
|
+
E,
|
|
2074
|
+
X
|
|
1870
2075
|
]);
|
|
1871
2076
|
i(() => {
|
|
1872
|
-
if (!
|
|
2077
|
+
if (!H || !E || !V) return;
|
|
1873
2078
|
let e = (e) => {
|
|
1874
2079
|
e.preventDefault(), e.returnValue = "";
|
|
1875
2080
|
};
|
|
1876
2081
|
return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
1877
2082
|
}, [
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
2083
|
+
H,
|
|
2084
|
+
E,
|
|
2085
|
+
V
|
|
1881
2086
|
]);
|
|
1882
|
-
let
|
|
1883
|
-
|
|
1884
|
-
}, [
|
|
1885
|
-
if (e.drawerWidth) return
|
|
2087
|
+
let fe = n(() => {
|
|
2088
|
+
B.current = !0, X();
|
|
2089
|
+
}, [X]), me = o(() => {
|
|
2090
|
+
if (e.drawerWidth) return U === "left" || U === "right" ? {
|
|
1886
2091
|
width: e.drawerWidth,
|
|
1887
2092
|
maxWidth: e.drawerWidth
|
|
1888
2093
|
} : {
|
|
1889
2094
|
height: e.drawerWidth,
|
|
1890
2095
|
maxHeight: e.drawerWidth
|
|
1891
2096
|
};
|
|
1892
|
-
}, [e.drawerWidth,
|
|
2097
|
+
}, [e.drawerWidth, U]), he = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", ge = e.showSubmit !== !1 && e.mode !== "view", _e = e.showCancel !== !1, ve = e.submitText || (e.mode === "create" ? "Create" : "Update"), ye = e.cancelText || "Cancel", be = {
|
|
1893
2098
|
type: "form",
|
|
1894
2099
|
objectName: e.objectName,
|
|
1895
|
-
layout:
|
|
2100
|
+
layout: he,
|
|
1896
2101
|
defaultValues: v,
|
|
1897
2102
|
previousValues: e.mode === "edit" && e.recordId ? v : void 0,
|
|
1898
|
-
submitLabel:
|
|
1899
|
-
cancelLabel:
|
|
1900
|
-
showSubmit:
|
|
1901
|
-
showCancel:
|
|
1902
|
-
onSubmit:
|
|
1903
|
-
onCancel:
|
|
1904
|
-
onDirtyChange:
|
|
2103
|
+
submitLabel: ve,
|
|
2104
|
+
cancelLabel: ye,
|
|
2105
|
+
showSubmit: ge,
|
|
2106
|
+
showCancel: _e,
|
|
2107
|
+
onSubmit: ue,
|
|
2108
|
+
onCancel: fe,
|
|
2109
|
+
onDirtyChange: D,
|
|
1905
2110
|
showActions: !1,
|
|
1906
2111
|
id: ie
|
|
1907
|
-
},
|
|
1908
|
-
if (
|
|
2112
|
+
}, xe = () => {
|
|
2113
|
+
if (C) return /* @__PURE__ */ Q("div", {
|
|
1909
2114
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1910
|
-
children: [/* @__PURE__ */
|
|
2115
|
+
children: [/* @__PURE__ */ Z("h3", {
|
|
1911
2116
|
className: "text-red-800 font-semibold",
|
|
1912
2117
|
children: "Error loading form"
|
|
1913
|
-
}), /* @__PURE__ */
|
|
2118
|
+
}), /* @__PURE__ */ Z("p", {
|
|
1914
2119
|
className: "text-red-600 text-sm mt-1",
|
|
1915
|
-
children:
|
|
2120
|
+
children: C.message
|
|
1916
2121
|
})]
|
|
1917
2122
|
});
|
|
1918
|
-
if (
|
|
2123
|
+
if (b) return /* @__PURE__ */ Q("div", {
|
|
1919
2124
|
className: "p-8 text-center",
|
|
1920
|
-
children: [/* @__PURE__ */
|
|
2125
|
+
children: [/* @__PURE__ */ Z("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Z("p", {
|
|
1921
2126
|
className: "mt-2 text-sm text-gray-600",
|
|
1922
2127
|
children: "Loading form..."
|
|
1923
2128
|
})]
|
|
@@ -1925,7 +2130,7 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1925
2130
|
if (e.sections?.length) {
|
|
1926
2131
|
let t = [];
|
|
1927
2132
|
return e.sections.forEach((e, n) => {
|
|
1928
|
-
let r = e.name || String(n), i =
|
|
2133
|
+
let r = e.name || String(n), i = W[r] ?? e.collapsed ?? !1;
|
|
1929
2134
|
t.push({
|
|
1930
2135
|
name: `__section_${r}`,
|
|
1931
2136
|
label: e.label || "",
|
|
@@ -1933,30 +2138,62 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1933
2138
|
colSpan: 4,
|
|
1934
2139
|
collapsible: e.collapsible,
|
|
1935
2140
|
collapsed: i,
|
|
1936
|
-
onToggle: e.collapsible ? () =>
|
|
2141
|
+
onToggle: e.collapsible ? () => G((e) => ({
|
|
1937
2142
|
...e,
|
|
1938
2143
|
[r]: !i
|
|
1939
2144
|
})) : void 0,
|
|
1940
2145
|
className: e.className
|
|
1941
2146
|
});
|
|
1942
|
-
let a =
|
|
2147
|
+
let a = K(e);
|
|
1943
2148
|
i ? t.push(...a.map((e) => ({
|
|
1944
2149
|
...e,
|
|
1945
2150
|
hidden: !0
|
|
1946
2151
|
}))) : t.push(...a);
|
|
1947
|
-
}), /* @__PURE__ */
|
|
1948
|
-
...
|
|
2152
|
+
}), /* @__PURE__ */ Z(x, { schema: {
|
|
2153
|
+
...be,
|
|
1949
2154
|
fields: t
|
|
1950
2155
|
} });
|
|
1951
2156
|
}
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
2157
|
+
if (J?.length) {
|
|
2158
|
+
let t = Number(J[0]?.columns) || 1, n = [];
|
|
2159
|
+
J.forEach((r, i) => {
|
|
2160
|
+
let a = K(r);
|
|
2161
|
+
if (!a.length) return;
|
|
2162
|
+
let o = r.name || String(i), s = r.collapsible ? W[o] ?? r.collapsed ?? !1 : !1, c = r.name ? u(e.objectName, r.name, r.label || r.name) : r.label;
|
|
2163
|
+
c && n.push({
|
|
2164
|
+
name: `__section_${o}`,
|
|
2165
|
+
label: c,
|
|
2166
|
+
type: "section-divider",
|
|
2167
|
+
colSpan: 4,
|
|
2168
|
+
collapsible: r.collapsible,
|
|
2169
|
+
collapsed: s,
|
|
2170
|
+
onToggle: r.collapsible ? () => G((e) => ({
|
|
2171
|
+
...e,
|
|
2172
|
+
[o]: !s
|
|
2173
|
+
})) : void 0
|
|
2174
|
+
});
|
|
2175
|
+
let l = t > 1 ? $(a, t) : a;
|
|
2176
|
+
n.push(...s ? l.map((e) => ({
|
|
2177
|
+
...e,
|
|
2178
|
+
hidden: !0
|
|
2179
|
+
})) : l);
|
|
2180
|
+
});
|
|
2181
|
+
let r = dn[t];
|
|
2182
|
+
return /* @__PURE__ */ Z(x, { schema: {
|
|
2183
|
+
...be,
|
|
2184
|
+
fields: n,
|
|
2185
|
+
columns: t,
|
|
2186
|
+
...r ? { fieldContainerClass: r } : {}
|
|
2187
|
+
} });
|
|
2188
|
+
}
|
|
2189
|
+
let t = pt(g, m, e.columns, e.mode), n = dn[t.columns || 1];
|
|
2190
|
+
return /* @__PURE__ */ Z(x, { schema: {
|
|
2191
|
+
...be,
|
|
1955
2192
|
fields: t.fields,
|
|
1956
2193
|
columns: t.columns,
|
|
1957
2194
|
...n ? { fieldContainerClass: n } : {}
|
|
1958
2195
|
} });
|
|
1959
|
-
},
|
|
2196
|
+
}, Se = e.subforms, we = Se?.length && e.mode !== "view" ? /* @__PURE__ */ Z(cn, {
|
|
1960
2197
|
schema: {
|
|
1961
2198
|
type: "object-master-detail-form",
|
|
1962
2199
|
objectName: e.objectName,
|
|
@@ -1965,8 +2202,8 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1965
2202
|
fields: e.fields,
|
|
1966
2203
|
sections: e.sections,
|
|
1967
2204
|
submitText: e.submitText,
|
|
1968
|
-
cancelText:
|
|
1969
|
-
details:
|
|
2205
|
+
cancelText: ye,
|
|
2206
|
+
details: Se,
|
|
1970
2207
|
onSuccess: async (t) => {
|
|
1971
2208
|
await e.onSuccess?.(t), e.onOpenChange?.(!1);
|
|
1972
2209
|
},
|
|
@@ -1974,116 +2211,93 @@ var Mt = ({ details: e, state: t, setRows: n, formHostRef: r, taxRateField: a, f
|
|
|
1974
2211
|
onCancel: () => e.onOpenChange?.(!1)
|
|
1975
2212
|
},
|
|
1976
2213
|
dataSource: t
|
|
1977
|
-
}) :
|
|
1978
|
-
return
|
|
2214
|
+
}) : xe();
|
|
2215
|
+
return p ? /* @__PURE__ */ Q("div", {
|
|
1979
2216
|
className: "@container rounded-md border bg-card p-4",
|
|
1980
|
-
children: [(e.title || e.description) && /* @__PURE__ */
|
|
2217
|
+
children: [(e.title || e.description) && /* @__PURE__ */ Q("div", {
|
|
1981
2218
|
className: "mb-3 space-y-0.5",
|
|
1982
|
-
children: [e.title && /* @__PURE__ */
|
|
2219
|
+
children: [e.title && /* @__PURE__ */ Z("div", {
|
|
1983
2220
|
className: "text-sm font-semibold",
|
|
1984
2221
|
children: e.title
|
|
1985
|
-
}), e.description && /* @__PURE__ */
|
|
2222
|
+
}), e.description && /* @__PURE__ */ Z("p", {
|
|
1986
2223
|
className: "text-xs text-muted-foreground",
|
|
1987
2224
|
children: e.description
|
|
1988
2225
|
})]
|
|
1989
|
-
}),
|
|
1990
|
-
}) : /* @__PURE__ */
|
|
1991
|
-
open:
|
|
2226
|
+
}), we]
|
|
2227
|
+
}) : /* @__PURE__ */ Z(oe, {
|
|
2228
|
+
open: H,
|
|
1992
2229
|
onOpenChange: (t) => {
|
|
1993
2230
|
if (t) {
|
|
1994
2231
|
e.onOpenChange?.(!0);
|
|
1995
2232
|
return;
|
|
1996
2233
|
}
|
|
1997
|
-
|
|
2234
|
+
de(!1);
|
|
1998
2235
|
},
|
|
1999
|
-
children: /* @__PURE__ */
|
|
2000
|
-
side:
|
|
2001
|
-
className:
|
|
2002
|
-
style:
|
|
2236
|
+
children: /* @__PURE__ */ Q(se, {
|
|
2237
|
+
side: U,
|
|
2238
|
+
className: Y("overflow-y-auto", r, e.className),
|
|
2239
|
+
style: me,
|
|
2003
2240
|
children: [
|
|
2004
|
-
(e.title || e.description) && /* @__PURE__ */
|
|
2241
|
+
(e.title || e.description) && /* @__PURE__ */ Q(q, { children: [e.title && /* @__PURE__ */ Z(le, { children: e.title }), e.description ? /* @__PURE__ */ Z(ce, { children: e.description }) : /* @__PURE__ */ Z(ce, {
|
|
2005
2242
|
className: "sr-only",
|
|
2006
|
-
children: "
|
|
2243
|
+
children: f("form.dialogDescriptionFallback")
|
|
2007
2244
|
})] }),
|
|
2008
|
-
/* @__PURE__ */
|
|
2245
|
+
/* @__PURE__ */ Z("div", {
|
|
2009
2246
|
className: "@container py-4",
|
|
2010
|
-
children:
|
|
2247
|
+
children: we
|
|
2011
2248
|
}),
|
|
2012
|
-
!
|
|
2249
|
+
!C && !b && !(Se?.length && e.mode !== "view") && (ge || _e) && /* @__PURE__ */ Z("div", {
|
|
2013
2250
|
className: "shrink-0 border-t px-4 py-3 bg-background",
|
|
2014
2251
|
"data-testid": "drawer-form-footer",
|
|
2015
|
-
children: /* @__PURE__ */
|
|
2252
|
+
children: /* @__PURE__ */ Q("div", {
|
|
2016
2253
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
2017
|
-
children: [
|
|
2254
|
+
children: [_e && /* @__PURE__ */ Z(R, {
|
|
2018
2255
|
type: "button",
|
|
2019
2256
|
variant: "outline",
|
|
2020
|
-
onClick:
|
|
2021
|
-
disabled:
|
|
2257
|
+
onClick: fe,
|
|
2258
|
+
disabled: N,
|
|
2022
2259
|
className: "w-full sm:w-auto",
|
|
2023
|
-
children:
|
|
2024
|
-
}),
|
|
2260
|
+
children: ye
|
|
2261
|
+
}), ge && /* @__PURE__ */ Q(R, {
|
|
2025
2262
|
type: "submit",
|
|
2026
2263
|
form: ie,
|
|
2027
|
-
disabled:
|
|
2264
|
+
disabled: N,
|
|
2028
2265
|
className: "w-full sm:w-auto",
|
|
2029
|
-
children: [
|
|
2266
|
+
children: [N && /* @__PURE__ */ Z(Ce, { className: "mr-2 h-4 w-4 animate-spin" }), ve]
|
|
2030
2267
|
})]
|
|
2031
2268
|
})
|
|
2032
2269
|
}),
|
|
2033
|
-
/* @__PURE__ */
|
|
2034
|
-
open:
|
|
2035
|
-
onOpenChange:
|
|
2036
|
-
children: /* @__PURE__ */
|
|
2270
|
+
/* @__PURE__ */ Z(P, {
|
|
2271
|
+
open: k,
|
|
2272
|
+
onOpenChange: A,
|
|
2273
|
+
children: /* @__PURE__ */ Q(ee, { children: [/* @__PURE__ */ Q(ne, { children: [/* @__PURE__ */ Z(re, { children: f("form.discardTitle") }), /* @__PURE__ */ Z(te, { children: f("form.discardMessage") })] }), /* @__PURE__ */ Q(L, { children: [/* @__PURE__ */ Z(I, {
|
|
2037
2274
|
onClick: () => {
|
|
2038
|
-
|
|
2275
|
+
B.current = !1;
|
|
2039
2276
|
},
|
|
2040
|
-
children:
|
|
2041
|
-
}), /* @__PURE__ */
|
|
2042
|
-
onClick:
|
|
2043
|
-
children:
|
|
2277
|
+
children: f("form.keepEditing")
|
|
2278
|
+
}), /* @__PURE__ */ Z(F, {
|
|
2279
|
+
onClick: X,
|
|
2280
|
+
children: f("form.discard")
|
|
2044
2281
|
})] })] })
|
|
2045
2282
|
}),
|
|
2046
|
-
|
|
2283
|
+
M
|
|
2047
2284
|
]
|
|
2048
2285
|
})
|
|
2049
2286
|
});
|
|
2050
|
-
}
|
|
2051
|
-
//#endregion
|
|
2052
|
-
//#region src/fieldGroups.ts
|
|
2053
|
-
function Lt(e, t) {
|
|
2054
|
-
let n = he({
|
|
2055
|
-
fieldGroups: t,
|
|
2056
|
-
fields: Object.fromEntries(e.map((e) => [e.name, { group: e.group }]))
|
|
2057
|
-
});
|
|
2058
|
-
if (!n) return null;
|
|
2059
|
-
let r = new Set(n.flatMap((e) => e.fields)), i = e.map((e) => e.name).filter((e) => !r.has(e)), a = n.map((e) => ({
|
|
2060
|
-
...e.key === void 0 ? {} : { name: e.key },
|
|
2061
|
-
...e.key === void 0 ? {} : { label: e.label ?? e.key },
|
|
2062
|
-
fields: [...e.fields],
|
|
2063
|
-
...e.collapse === "none" ? {} : { collapsible: !0 },
|
|
2064
|
-
...e.collapse === "collapsed" ? { collapsed: !0 } : {}
|
|
2065
|
-
}));
|
|
2066
|
-
if (i.length > 0) {
|
|
2067
|
-
let e = a[a.length - 1];
|
|
2068
|
-
e && e.name === void 0 ? e.fields = [...e.fields ?? [], ...i] : a.push({ fields: i });
|
|
2069
|
-
}
|
|
2070
|
-
return a;
|
|
2071
|
-
}
|
|
2072
|
-
//#endregion
|
|
2073
|
-
//#region src/ModalForm.tsx
|
|
2074
|
-
var Rt = pe({
|
|
2287
|
+
}, mn = Ee({
|
|
2075
2288
|
"form.discardTitle": "Discard changes?",
|
|
2076
2289
|
"form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
|
|
2290
|
+
"form.dialogDescriptionFallback": "Complete the form fields, then submit or cancel.",
|
|
2077
2291
|
"form.keepEditing": "Keep editing",
|
|
2078
2292
|
"form.discard": "Discard"
|
|
2079
|
-
}, "form.discardTitle"),
|
|
2293
|
+
}, "form.discardTitle"), hn = {
|
|
2080
2294
|
sm: "sm:max-w-sm",
|
|
2081
2295
|
default: "sm:max-w-lg",
|
|
2082
2296
|
lg: "sm:max-w-2xl",
|
|
2083
2297
|
xl: "sm:max-w-5xl",
|
|
2084
2298
|
full: "sm:max-w-[95vw] sm:w-full"
|
|
2085
|
-
},
|
|
2086
|
-
let { fieldLabel: l, sectionLabel: u } =
|
|
2299
|
+
}, gn = ({ schema: e, dataSource: t, className: r }) => {
|
|
2300
|
+
let { fieldLabel: l, sectionLabel: u } = O(), { t: d } = mn(), f = T(), p = pe(), m = n((t) => {
|
|
2087
2301
|
if (!p?.isLoaded) return t;
|
|
2088
2302
|
let n = [];
|
|
2089
2303
|
for (let r of t) {
|
|
@@ -2102,13 +2316,13 @@ var Rt = pe({
|
|
|
2102
2316
|
p,
|
|
2103
2317
|
e.objectName,
|
|
2104
2318
|
e.mode
|
|
2105
|
-
]), [
|
|
2319
|
+
]), [h, g] = c(null), [_, v] = c([]), [y, b] = c({}), [S, C] = c(!0), [w, E] = c(null), [D, k] = c(!1), [A, j] = c(!1), [M, N] = c(!1), { saveWithOcc: z, conflictDialog: B } = vt(), V = s(!1), H = e.confirmOnDiscard !== !1, U = e.open !== !1, oe = a(), se = o(() => {
|
|
2106
2320
|
if (e.sections?.length || e.customFields?.length) return null;
|
|
2107
|
-
let t =
|
|
2108
|
-
e.mode === "create" && (t =
|
|
2109
|
-
let n =
|
|
2321
|
+
let t = st(_, h);
|
|
2322
|
+
e.mode === "create" && (t = lt(t, h));
|
|
2323
|
+
let n = un(t, h?.fieldGroups);
|
|
2110
2324
|
if (!n) return null;
|
|
2111
|
-
let r = e.columns && e.columns > 0 ? Math.min(Math.floor(e.columns), 4) :
|
|
2325
|
+
let r = e.columns && e.columns > 0 ? Math.min(Math.floor(e.columns), 4) : rt(t.length);
|
|
2112
2326
|
return n.map((e) => ({
|
|
2113
2327
|
...e,
|
|
2114
2328
|
columns: r
|
|
@@ -2118,70 +2332,70 @@ var Rt = pe({
|
|
|
2118
2332
|
e.customFields,
|
|
2119
2333
|
e.columns,
|
|
2120
2334
|
e.mode,
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
]),
|
|
2124
|
-
|
|
2125
|
-
|
|
2335
|
+
_,
|
|
2336
|
+
h
|
|
2337
|
+
]), ce = e.sections?.length ? e.sections : se ?? void 0, q = o(() => ce?.length || e.customFields?.length ? null : pt(_, h, e.columns, e.mode), [
|
|
2338
|
+
_,
|
|
2339
|
+
h,
|
|
2126
2340
|
e.columns,
|
|
2127
2341
|
e.mode,
|
|
2128
|
-
|
|
2342
|
+
ce,
|
|
2129
2343
|
e.customFields
|
|
2130
|
-
]),
|
|
2344
|
+
]), le = hn[o(() => {
|
|
2131
2345
|
if (e.modalSize) return e.modalSize;
|
|
2132
|
-
if (
|
|
2133
|
-
if (
|
|
2134
|
-
let e = Math.max(...
|
|
2135
|
-
if (e > 1) return
|
|
2346
|
+
if (q?.columns && q.columns > 1) return ft(q.columns);
|
|
2347
|
+
if (ce?.length) {
|
|
2348
|
+
let e = Math.max(...ce.map((e) => Number(e.columns) || 1));
|
|
2349
|
+
if (e > 1) return ft(e);
|
|
2136
2350
|
}
|
|
2137
2351
|
return "default";
|
|
2138
2352
|
}, [
|
|
2139
2353
|
e.modalSize,
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
])] ||
|
|
2354
|
+
q,
|
|
2355
|
+
ce
|
|
2356
|
+
])] || hn.default;
|
|
2143
2357
|
i(() => {
|
|
2144
2358
|
(async () => {
|
|
2145
2359
|
if (!t) {
|
|
2146
|
-
|
|
2360
|
+
C(!1);
|
|
2147
2361
|
return;
|
|
2148
2362
|
}
|
|
2149
2363
|
try {
|
|
2150
2364
|
let n = await t.getObjectSchema(e.objectName);
|
|
2151
|
-
|
|
2365
|
+
g(n);
|
|
2152
2366
|
} catch (e) {
|
|
2153
|
-
|
|
2367
|
+
E(e), C(!1);
|
|
2154
2368
|
}
|
|
2155
2369
|
})();
|
|
2156
2370
|
}, [e.objectName, t]);
|
|
2157
|
-
let
|
|
2371
|
+
let ue = s(void 0);
|
|
2158
2372
|
i(() => {
|
|
2159
2373
|
let n = !1;
|
|
2160
|
-
return (
|
|
2374
|
+
return (h || !t) && (async () => {
|
|
2161
2375
|
if (e.mode === "create" || !e.recordId) {
|
|
2162
|
-
|
|
2376
|
+
b(We(h, e.initialData || e.initialValues, { currentUserId: p.userId })), C(!1);
|
|
2163
2377
|
return;
|
|
2164
2378
|
}
|
|
2165
2379
|
if (!t) {
|
|
2166
|
-
|
|
2380
|
+
b(e.initialData || e.initialValues || {}), C(!1);
|
|
2167
2381
|
return;
|
|
2168
2382
|
}
|
|
2169
|
-
|
|
2383
|
+
ue.current !== e.recordId && (C(!0), j(!1));
|
|
2170
2384
|
try {
|
|
2171
2385
|
let r = await t.findOne(e.objectName, e.recordId);
|
|
2172
2386
|
if (n) return;
|
|
2173
|
-
|
|
2387
|
+
ue.current = e.recordId, b(r || {});
|
|
2174
2388
|
} catch (e) {
|
|
2175
2389
|
if (n) return;
|
|
2176
|
-
|
|
2390
|
+
E(e);
|
|
2177
2391
|
} finally {
|
|
2178
|
-
n ||
|
|
2392
|
+
n || C(!1);
|
|
2179
2393
|
}
|
|
2180
2394
|
})(), () => {
|
|
2181
2395
|
n = !0;
|
|
2182
2396
|
};
|
|
2183
2397
|
}, [
|
|
2184
|
-
|
|
2398
|
+
h,
|
|
2185
2399
|
e.mode,
|
|
2186
2400
|
e.recordId,
|
|
2187
2401
|
e.initialData,
|
|
@@ -2189,56 +2403,43 @@ var Rt = pe({
|
|
|
2189
2403
|
t,
|
|
2190
2404
|
e.objectName
|
|
2191
2405
|
]);
|
|
2192
|
-
let
|
|
2193
|
-
objectSchema:
|
|
2406
|
+
let X = n((t) => Ze(t, {
|
|
2407
|
+
objectSchema: h,
|
|
2194
2408
|
objectName: e.objectName,
|
|
2195
2409
|
readOnly: e.readOnly,
|
|
2196
2410
|
mode: e.mode,
|
|
2411
|
+
recordId: e.recordId,
|
|
2197
2412
|
fieldLabel: l
|
|
2198
2413
|
}), [
|
|
2199
|
-
|
|
2414
|
+
h,
|
|
2200
2415
|
e.readOnly,
|
|
2201
2416
|
e.mode,
|
|
2417
|
+
e.recordId,
|
|
2202
2418
|
e.objectName,
|
|
2203
2419
|
l
|
|
2204
2420
|
]);
|
|
2205
2421
|
i(() => {
|
|
2206
|
-
if (!
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
type: w(i.type),
|
|
2225
|
-
required: i.required || !1,
|
|
2226
|
-
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
2227
|
-
placeholder: i.placeholder,
|
|
2228
|
-
description: i.help || i.description,
|
|
2229
|
-
validation: S(i),
|
|
2230
|
-
field: i,
|
|
2231
|
-
options: i.options,
|
|
2232
|
-
multiple: i.multiple,
|
|
2233
|
-
visibleWhen: i.visibleWhen,
|
|
2234
|
-
readonlyWhen: i.readonlyWhen,
|
|
2235
|
-
requiredWhen: i.requiredWhen,
|
|
2236
|
-
group: i.group
|
|
2237
|
-
});
|
|
2422
|
+
if (!(!h && t)) {
|
|
2423
|
+
if (e.customFields?.length) {
|
|
2424
|
+
v(e.customFields), C(!1);
|
|
2425
|
+
return;
|
|
2426
|
+
}
|
|
2427
|
+
if (e.sections?.length) {
|
|
2428
|
+
C(!1);
|
|
2429
|
+
return;
|
|
2430
|
+
}
|
|
2431
|
+
h && (v(ln({
|
|
2432
|
+
fields: e.fields,
|
|
2433
|
+
objectSchema: h,
|
|
2434
|
+
objectName: e.objectName,
|
|
2435
|
+
readOnly: e.readOnly,
|
|
2436
|
+
mode: e.mode,
|
|
2437
|
+
recordId: e.recordId,
|
|
2438
|
+
fieldLabel: l
|
|
2439
|
+
})), C(!1));
|
|
2238
2440
|
}
|
|
2239
|
-
x(r), I(!1);
|
|
2240
2441
|
}, [
|
|
2241
|
-
|
|
2442
|
+
h,
|
|
2242
2443
|
e.fields,
|
|
2243
2444
|
e.customFields,
|
|
2244
2445
|
e.sections,
|
|
@@ -2246,24 +2447,24 @@ var Rt = pe({
|
|
|
2246
2447
|
e.mode,
|
|
2247
2448
|
t
|
|
2248
2449
|
]);
|
|
2249
|
-
let
|
|
2250
|
-
|
|
2450
|
+
let de = n(async (n) => {
|
|
2451
|
+
k(!0);
|
|
2251
2452
|
try {
|
|
2252
2453
|
if (!t) return e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
2253
|
-
let r, i =
|
|
2454
|
+
let r, i = Ot(n, h);
|
|
2254
2455
|
if (p?.isLoaded) {
|
|
2255
2456
|
let t = {};
|
|
2256
2457
|
for (let n of Object.keys(i)) p.checkField(e.objectName, n, "write") && (t[n] = i[n]);
|
|
2257
2458
|
i = t;
|
|
2258
2459
|
}
|
|
2259
|
-
if (e.mode === "create") r = await t.create(e.objectName, i);
|
|
2460
|
+
if (e.mode === "create") r = await t.create(e.objectName, Ge(i, h));
|
|
2260
2461
|
else if (e.mode === "edit" && e.recordId) {
|
|
2261
|
-
let n = await
|
|
2462
|
+
let n = await z({
|
|
2262
2463
|
dataSource: t,
|
|
2263
2464
|
objectName: e.objectName,
|
|
2264
2465
|
recordId: e.recordId,
|
|
2265
2466
|
payload: i,
|
|
2266
|
-
baseRecord:
|
|
2467
|
+
baseRecord: y
|
|
2267
2468
|
});
|
|
2268
2469
|
if (n.status === "cancelled") return;
|
|
2269
2470
|
r = n.result;
|
|
@@ -2272,92 +2473,92 @@ var Rt = pe({
|
|
|
2272
2473
|
} catch (t) {
|
|
2273
2474
|
throw e.onError && e.onError(t), t;
|
|
2274
2475
|
} finally {
|
|
2275
|
-
|
|
2476
|
+
k(!1);
|
|
2276
2477
|
}
|
|
2277
2478
|
}, [
|
|
2278
2479
|
e,
|
|
2279
2480
|
t,
|
|
2280
|
-
|
|
2481
|
+
h,
|
|
2281
2482
|
p,
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
]),
|
|
2285
|
-
|
|
2286
|
-
}, [e]),
|
|
2287
|
-
|
|
2483
|
+
z,
|
|
2484
|
+
y
|
|
2485
|
+
]), fe = n(() => {
|
|
2486
|
+
N(!1), V.current && (V.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
|
|
2487
|
+
}, [e]), me = n((e) => {
|
|
2488
|
+
V.current = e, H && A ? N(!0) : fe();
|
|
2288
2489
|
}, [
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2490
|
+
H,
|
|
2491
|
+
A,
|
|
2492
|
+
fe
|
|
2292
2493
|
]);
|
|
2293
2494
|
i(() => {
|
|
2294
|
-
if (!
|
|
2495
|
+
if (!U || !A || !H) return;
|
|
2295
2496
|
let e = (e) => {
|
|
2296
2497
|
e.preventDefault(), e.returnValue = "";
|
|
2297
2498
|
};
|
|
2298
2499
|
return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
2299
2500
|
}, [
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2501
|
+
U,
|
|
2502
|
+
A,
|
|
2503
|
+
H
|
|
2303
2504
|
]);
|
|
2304
|
-
let
|
|
2305
|
-
|
|
2306
|
-
}, [
|
|
2505
|
+
let he = n(() => {
|
|
2506
|
+
V.current = !0, fe();
|
|
2507
|
+
}, [fe]), ge = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", _e = e.showSubmit !== !1 && e.mode !== "view", ve = e.showCancel !== !1, ye = e.submitText || (e.mode === "create" ? "Create" : "Update"), be = e.cancelText || "Cancel", xe = {
|
|
2307
2508
|
type: "form",
|
|
2308
2509
|
objectName: e.objectName,
|
|
2309
|
-
layout:
|
|
2310
|
-
defaultValues:
|
|
2311
|
-
previousValues: e.mode === "edit" && e.recordId ?
|
|
2312
|
-
submitLabel:
|
|
2313
|
-
cancelLabel:
|
|
2314
|
-
showSubmit:
|
|
2315
|
-
showCancel:
|
|
2316
|
-
onSubmit:
|
|
2317
|
-
onCancel:
|
|
2318
|
-
onDirtyChange:
|
|
2510
|
+
layout: ge,
|
|
2511
|
+
defaultValues: y,
|
|
2512
|
+
previousValues: e.mode === "edit" && e.recordId ? y : void 0,
|
|
2513
|
+
submitLabel: ye,
|
|
2514
|
+
cancelLabel: be,
|
|
2515
|
+
showSubmit: _e,
|
|
2516
|
+
showCancel: ve,
|
|
2517
|
+
onSubmit: de,
|
|
2518
|
+
onCancel: he,
|
|
2519
|
+
onDirtyChange: j,
|
|
2319
2520
|
showActions: !1,
|
|
2320
|
-
id:
|
|
2321
|
-
},
|
|
2322
|
-
if (
|
|
2521
|
+
id: oe
|
|
2522
|
+
}, Se = () => {
|
|
2523
|
+
if (w) return /* @__PURE__ */ Q("div", {
|
|
2323
2524
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
2324
|
-
children: [/* @__PURE__ */
|
|
2525
|
+
children: [/* @__PURE__ */ Z("h3", {
|
|
2325
2526
|
className: "text-red-800 font-semibold",
|
|
2326
2527
|
children: "Error loading form"
|
|
2327
|
-
}), /* @__PURE__ */
|
|
2528
|
+
}), /* @__PURE__ */ Z("p", {
|
|
2328
2529
|
className: "text-red-600 text-sm mt-1",
|
|
2329
|
-
children:
|
|
2530
|
+
children: w.message
|
|
2330
2531
|
})]
|
|
2331
2532
|
});
|
|
2332
|
-
if (
|
|
2533
|
+
if (S) return /* @__PURE__ */ Z("div", {
|
|
2333
2534
|
className: "space-y-4",
|
|
2334
2535
|
"data-testid": "modal-form-skeleton",
|
|
2335
2536
|
children: [
|
|
2336
2537
|
1,
|
|
2337
2538
|
2,
|
|
2338
2539
|
3
|
|
2339
|
-
].map((e) => /* @__PURE__ */
|
|
2540
|
+
].map((e) => /* @__PURE__ */ Q("div", {
|
|
2340
2541
|
className: "space-y-2",
|
|
2341
|
-
children: [/* @__PURE__ */
|
|
2542
|
+
children: [/* @__PURE__ */ Z(J, { className: "h-4 w-24" }), /* @__PURE__ */ Z(J, { className: "h-10 w-full" })]
|
|
2342
2543
|
}, e))
|
|
2343
2544
|
});
|
|
2344
2545
|
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(
|
|
2546
|
+
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 = ut[o], c = t.map((e, t) => {
|
|
2547
|
+
let a = m(X(e));
|
|
2347
2548
|
return {
|
|
2348
2549
|
key: n(e, t),
|
|
2349
2550
|
title: r(e),
|
|
2350
2551
|
description: e.description,
|
|
2351
2552
|
className: e.className,
|
|
2352
2553
|
gridClassName: e.gridClassName,
|
|
2353
|
-
fields: o > 1 ?
|
|
2554
|
+
fields: o > 1 ? $(a, o, i(e.columns)) : a
|
|
2354
2555
|
};
|
|
2355
2556
|
}).filter((e) => e.fields.length > 0), l = {
|
|
2356
|
-
...
|
|
2557
|
+
...xe,
|
|
2357
2558
|
columns: o,
|
|
2358
2559
|
...s ? { fieldContainerClass: s } : {}
|
|
2359
2560
|
};
|
|
2360
|
-
if (e.contentLayout === "tabbed" && c.length > 1) return /* @__PURE__ */
|
|
2561
|
+
if (e.contentLayout === "tabbed" && c.length > 1) return /* @__PURE__ */ Z(x, { schema: {
|
|
2361
2562
|
...l,
|
|
2362
2563
|
fields: c.flatMap((e) => e.fields),
|
|
2363
2564
|
fieldTabs: c.map((e, t) => ({
|
|
@@ -2378,66 +2579,66 @@ var Rt = pe({
|
|
|
2378
2579
|
colSpan: 4,
|
|
2379
2580
|
className: e.className
|
|
2380
2581
|
}), d.push(...e.fields);
|
|
2381
|
-
}), /* @__PURE__ */
|
|
2582
|
+
}), /* @__PURE__ */ Z(x, { schema: {
|
|
2382
2583
|
...l,
|
|
2383
2584
|
fields: d
|
|
2384
2585
|
} });
|
|
2385
2586
|
}
|
|
2386
|
-
if (
|
|
2387
|
-
let t = Number(
|
|
2388
|
-
|
|
2389
|
-
let a = m(
|
|
2587
|
+
if (se?.length) {
|
|
2588
|
+
let t = Number(se[0]?.columns) || 1, n = [];
|
|
2589
|
+
se.forEach((r, i) => {
|
|
2590
|
+
let a = m(X(r));
|
|
2390
2591
|
if (!a.length) return;
|
|
2391
2592
|
let o = r.name ? u(e.objectName, r.name, r.label || r.name) : r.label;
|
|
2392
2593
|
o && n.push({
|
|
2393
2594
|
name: `__section_${r.name || i}`,
|
|
2394
2595
|
label: o,
|
|
2395
2596
|
type: "section-divider"
|
|
2396
|
-
}), n.push(...t > 1 ?
|
|
2597
|
+
}), n.push(...t > 1 ? $(a, t) : a);
|
|
2397
2598
|
});
|
|
2398
|
-
let r =
|
|
2399
|
-
return /* @__PURE__ */
|
|
2400
|
-
...
|
|
2599
|
+
let r = ut[t];
|
|
2600
|
+
return /* @__PURE__ */ Z(x, { schema: {
|
|
2601
|
+
...xe,
|
|
2401
2602
|
fields: n,
|
|
2402
2603
|
columns: t,
|
|
2403
2604
|
...r ? { fieldContainerClass: r } : {}
|
|
2404
2605
|
} });
|
|
2405
2606
|
}
|
|
2406
|
-
let t =
|
|
2407
|
-
return /* @__PURE__ */
|
|
2408
|
-
...
|
|
2607
|
+
let t = q ?? pt(_, h, e.columns, e.mode), n = ut[t.columns || 1];
|
|
2608
|
+
return /* @__PURE__ */ Z(x, { schema: {
|
|
2609
|
+
...xe,
|
|
2409
2610
|
fields: m(t.fields),
|
|
2410
2611
|
columns: t.columns,
|
|
2411
2612
|
...n ? { fieldContainerClass: n } : {}
|
|
2412
2613
|
} });
|
|
2413
|
-
},
|
|
2414
|
-
if (f) return /* @__PURE__ */
|
|
2614
|
+
}, we = e.subforms;
|
|
2615
|
+
if (f) return /* @__PURE__ */ Q("div", {
|
|
2415
2616
|
className: "@container rounded-md border bg-card p-4",
|
|
2416
|
-
children: [(e.title || e.description) && /* @__PURE__ */
|
|
2617
|
+
children: [(e.title || e.description) && /* @__PURE__ */ Q("div", {
|
|
2417
2618
|
className: "mb-3 space-y-0.5",
|
|
2418
|
-
children: [e.title && /* @__PURE__ */
|
|
2619
|
+
children: [e.title && /* @__PURE__ */ Z("div", {
|
|
2419
2620
|
className: "text-sm font-semibold",
|
|
2420
2621
|
children: e.title
|
|
2421
|
-
}), e.description && /* @__PURE__ */
|
|
2622
|
+
}), e.description && /* @__PURE__ */ Z("p", {
|
|
2422
2623
|
className: "text-xs text-muted-foreground",
|
|
2423
2624
|
children: e.description
|
|
2424
2625
|
})]
|
|
2425
|
-
}),
|
|
2626
|
+
}), Se()]
|
|
2426
2627
|
});
|
|
2427
|
-
if (
|
|
2428
|
-
open:
|
|
2628
|
+
if (we?.length && e.mode !== "view") return /* @__PURE__ */ Z(ie, {
|
|
2629
|
+
open: U,
|
|
2429
2630
|
onOpenChange: e.onOpenChange,
|
|
2430
|
-
children: /* @__PURE__ */
|
|
2431
|
-
className:
|
|
2432
|
-
children: [(e.title || e.description) && /* @__PURE__ */
|
|
2631
|
+
children: /* @__PURE__ */ Q(K, {
|
|
2632
|
+
className: Y(le, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", r, e.className),
|
|
2633
|
+
children: [(e.title || e.description) && /* @__PURE__ */ Q(G, {
|
|
2433
2634
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
2434
|
-
children: [e.title && /* @__PURE__ */
|
|
2635
|
+
children: [e.title && /* @__PURE__ */ Z(ae, { children: e.title }), e.description ? /* @__PURE__ */ Z(W, { children: e.description }) : /* @__PURE__ */ Z(W, {
|
|
2435
2636
|
className: "sr-only",
|
|
2436
2637
|
children: "Enter the record and its line items, then save."
|
|
2437
2638
|
})]
|
|
2438
|
-
}), /* @__PURE__ */
|
|
2639
|
+
}), /* @__PURE__ */ Z("div", {
|
|
2439
2640
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
2440
|
-
children: /* @__PURE__ */
|
|
2641
|
+
children: /* @__PURE__ */ Z(cn, {
|
|
2441
2642
|
schema: {
|
|
2442
2643
|
type: "object-master-detail-form",
|
|
2443
2644
|
objectName: e.objectName,
|
|
@@ -2447,9 +2648,9 @@ var Rt = pe({
|
|
|
2447
2648
|
sections: e.sections,
|
|
2448
2649
|
initialValues: e.initialValues,
|
|
2449
2650
|
initialData: e.initialData,
|
|
2450
|
-
submitText:
|
|
2451
|
-
cancelText:
|
|
2452
|
-
details:
|
|
2651
|
+
submitText: ye,
|
|
2652
|
+
cancelText: be,
|
|
2653
|
+
details: we,
|
|
2453
2654
|
onSuccess: async (t) => {
|
|
2454
2655
|
await e.onSuccess?.(t), e.onOpenChange?.(!1);
|
|
2455
2656
|
},
|
|
@@ -2461,80 +2662,80 @@ var Rt = pe({
|
|
|
2461
2662
|
})]
|
|
2462
2663
|
})
|
|
2463
2664
|
});
|
|
2464
|
-
let
|
|
2465
|
-
return /* @__PURE__ */
|
|
2466
|
-
open:
|
|
2665
|
+
let Te = !S && !w && (_e || ve);
|
|
2666
|
+
return /* @__PURE__ */ Z(ie, {
|
|
2667
|
+
open: U,
|
|
2467
2668
|
onOpenChange: (t) => {
|
|
2468
2669
|
if (t) {
|
|
2469
2670
|
e.onOpenChange?.(!0);
|
|
2470
2671
|
return;
|
|
2471
2672
|
}
|
|
2472
|
-
|
|
2673
|
+
me(!1);
|
|
2473
2674
|
},
|
|
2474
|
-
children: /* @__PURE__ */
|
|
2475
|
-
className:
|
|
2675
|
+
children: /* @__PURE__ */ Q(K, {
|
|
2676
|
+
className: Y(le, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", r, e.className),
|
|
2476
2677
|
children: [
|
|
2477
|
-
(e.title || e.description) && /* @__PURE__ */
|
|
2678
|
+
(e.title || e.description) && /* @__PURE__ */ Q(G, {
|
|
2478
2679
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
2479
|
-
children: [e.title && /* @__PURE__ */
|
|
2680
|
+
children: [e.title && /* @__PURE__ */ Z(ae, { children: e.title }), e.description ? /* @__PURE__ */ Z(W, { children: e.description }) : /* @__PURE__ */ Z(W, {
|
|
2480
2681
|
className: "sr-only",
|
|
2481
|
-
children: "
|
|
2682
|
+
children: d("form.dialogDescriptionFallback")
|
|
2482
2683
|
})]
|
|
2483
2684
|
}),
|
|
2484
|
-
/* @__PURE__ */
|
|
2685
|
+
/* @__PURE__ */ Z("div", {
|
|
2485
2686
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
2486
|
-
children:
|
|
2687
|
+
children: Se()
|
|
2487
2688
|
}),
|
|
2488
|
-
|
|
2689
|
+
Te && /* @__PURE__ */ Z("div", {
|
|
2489
2690
|
className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background",
|
|
2490
2691
|
"data-testid": "modal-form-footer",
|
|
2491
|
-
children: /* @__PURE__ */
|
|
2692
|
+
children: /* @__PURE__ */ Q("div", {
|
|
2492
2693
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
2493
|
-
children: [
|
|
2694
|
+
children: [ve && /* @__PURE__ */ Z(R, {
|
|
2494
2695
|
type: "button",
|
|
2495
2696
|
variant: "outline",
|
|
2496
|
-
onClick:
|
|
2497
|
-
disabled:
|
|
2697
|
+
onClick: he,
|
|
2698
|
+
disabled: D,
|
|
2498
2699
|
className: "w-full sm:w-auto",
|
|
2499
|
-
children:
|
|
2500
|
-
}),
|
|
2700
|
+
children: be
|
|
2701
|
+
}), _e && /* @__PURE__ */ Q(R, {
|
|
2501
2702
|
type: "submit",
|
|
2502
|
-
form:
|
|
2503
|
-
disabled:
|
|
2703
|
+
form: oe,
|
|
2704
|
+
disabled: D,
|
|
2504
2705
|
className: "w-full sm:w-auto",
|
|
2505
|
-
children: [
|
|
2706
|
+
children: [D && /* @__PURE__ */ Z(Ce, { className: "mr-2 h-4 w-4 animate-spin" }), ye]
|
|
2506
2707
|
})]
|
|
2507
2708
|
})
|
|
2508
2709
|
}),
|
|
2509
|
-
/* @__PURE__ */
|
|
2510
|
-
open:
|
|
2511
|
-
onOpenChange:
|
|
2512
|
-
children: /* @__PURE__ */
|
|
2710
|
+
/* @__PURE__ */ Z(P, {
|
|
2711
|
+
open: M,
|
|
2712
|
+
onOpenChange: N,
|
|
2713
|
+
children: /* @__PURE__ */ Q(ee, { children: [/* @__PURE__ */ Q(ne, { children: [/* @__PURE__ */ Z(re, { children: d("form.discardTitle") }), /* @__PURE__ */ Z(te, { children: d("form.discardMessage") })] }), /* @__PURE__ */ Q(L, { children: [/* @__PURE__ */ Z(I, {
|
|
2513
2714
|
onClick: () => {
|
|
2514
|
-
|
|
2715
|
+
V.current = !1;
|
|
2515
2716
|
},
|
|
2516
2717
|
children: d("form.keepEditing")
|
|
2517
|
-
}), /* @__PURE__ */
|
|
2518
|
-
onClick:
|
|
2718
|
+
}), /* @__PURE__ */ Z(F, {
|
|
2719
|
+
onClick: fe,
|
|
2519
2720
|
children: d("form.discard")
|
|
2520
2721
|
})] })] })
|
|
2521
2722
|
}),
|
|
2522
|
-
|
|
2723
|
+
B
|
|
2523
2724
|
]
|
|
2524
2725
|
})
|
|
2525
2726
|
});
|
|
2526
2727
|
};
|
|
2527
2728
|
//#endregion
|
|
2528
2729
|
//#region src/ObjectForm.tsx
|
|
2529
|
-
function
|
|
2730
|
+
function _n(e) {
|
|
2530
2731
|
let t = e.buttons, n = e.defaults;
|
|
2531
2732
|
if (!t && !n) return e;
|
|
2532
2733
|
let r = e, i = { ...r };
|
|
2533
2734
|
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
2735
|
}
|
|
2535
|
-
var
|
|
2536
|
-
let n =
|
|
2537
|
-
let t =
|
|
2736
|
+
var vn = ({ schema: e, dataSource: t }) => {
|
|
2737
|
+
let n = pe(), r = o(() => {
|
|
2738
|
+
let t = _n(e), r = t.groups, i = !t.sections?.length && Array.isArray(r) && r.length ? {
|
|
2538
2739
|
...t,
|
|
2539
2740
|
sections: r.map((e) => ({
|
|
2540
2741
|
label: e.title ?? e.label,
|
|
@@ -2558,8 +2759,8 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2558
2759
|
fields: o(e.fields)
|
|
2559
2760
|
}))
|
|
2560
2761
|
};
|
|
2561
|
-
}, [e, n]), { sectionLabel: i } =
|
|
2562
|
-
if (r.subforms?.length && r.mode !== "view" && r.formType !== "drawer" && r.formType !== "modal") return /* @__PURE__ */
|
|
2762
|
+
}, [e, n]), { sectionLabel: i } = O(), a = (e) => e?.name ? i(r.objectName, e.name, e.label || e.name) : e?.label;
|
|
2763
|
+
if (r.subforms?.length && r.mode !== "view" && r.formType !== "drawer" && r.formType !== "modal") return /* @__PURE__ */ Z(cn, {
|
|
2563
2764
|
schema: {
|
|
2564
2765
|
type: "object-master-detail-form",
|
|
2565
2766
|
objectName: r.objectName,
|
|
@@ -2582,7 +2783,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2582
2783
|
},
|
|
2583
2784
|
dataSource: t
|
|
2584
2785
|
});
|
|
2585
|
-
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */
|
|
2786
|
+
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ Z(yt, {
|
|
2586
2787
|
schema: {
|
|
2587
2788
|
...r,
|
|
2588
2789
|
formType: "tabbed",
|
|
@@ -2601,7 +2802,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2601
2802
|
dataSource: t,
|
|
2602
2803
|
className: r.className
|
|
2603
2804
|
});
|
|
2604
|
-
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */
|
|
2805
|
+
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ Z(wt, {
|
|
2605
2806
|
schema: {
|
|
2606
2807
|
...r,
|
|
2607
2808
|
formType: "wizard",
|
|
@@ -2623,7 +2824,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2623
2824
|
dataSource: t,
|
|
2624
2825
|
className: r.className
|
|
2625
2826
|
});
|
|
2626
|
-
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */
|
|
2827
|
+
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ Z(Tt, {
|
|
2627
2828
|
schema: {
|
|
2628
2829
|
...r,
|
|
2629
2830
|
formType: "split",
|
|
@@ -2646,7 +2847,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2646
2847
|
});
|
|
2647
2848
|
if (r.formType === "drawer") {
|
|
2648
2849
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
2649
|
-
return /* @__PURE__ */
|
|
2850
|
+
return /* @__PURE__ */ Z(pn, {
|
|
2650
2851
|
schema: {
|
|
2651
2852
|
...n,
|
|
2652
2853
|
layout: i,
|
|
@@ -2672,7 +2873,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2672
2873
|
}
|
|
2673
2874
|
if (r.formType === "modal") {
|
|
2674
2875
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
2675
|
-
return /* @__PURE__ */
|
|
2876
|
+
return /* @__PURE__ */ Z(gn, {
|
|
2676
2877
|
schema: {
|
|
2677
2878
|
...n,
|
|
2678
2879
|
layout: i,
|
|
@@ -2695,12 +2896,12 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2695
2896
|
className: r.className
|
|
2696
2897
|
});
|
|
2697
2898
|
}
|
|
2698
|
-
return /* @__PURE__ */
|
|
2899
|
+
return /* @__PURE__ */ Z(yn, {
|
|
2699
2900
|
schema: r,
|
|
2700
2901
|
dataSource: t
|
|
2701
2902
|
});
|
|
2702
|
-
},
|
|
2703
|
-
let { fieldLabel: a, sectionLabel: o } =
|
|
2903
|
+
}, yn = ({ schema: e, dataSource: r }) => {
|
|
2904
|
+
let { fieldLabel: a, sectionLabel: o } = O(), s = de(), l = pe(), u = n((t) => {
|
|
2704
2905
|
if (!l?.isLoaded) return t;
|
|
2705
2906
|
let n = [];
|
|
2706
2907
|
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 +2915,17 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2714
2915
|
l,
|
|
2715
2916
|
e.objectName,
|
|
2716
2917
|
e.mode
|
|
2717
|
-
]), [d,
|
|
2918
|
+
]), [d, f] = c(null), [p, m] = c([]), [h, _] = c(null), [v, y] = c(!0), [b, S] = c(null), [C, w] = c(null), [T, E] = c(null);
|
|
2919
|
+
Pe(T);
|
|
2920
|
+
let { saveWithOcc: D, conflictDialog: k } = vt(), A = e.customFields && e.customFields.length > 0;
|
|
2718
2921
|
i(() => {
|
|
2719
|
-
|
|
2922
|
+
A && (_(e.initialData || e.initialValues || {}), y(!1));
|
|
2720
2923
|
}, [
|
|
2721
|
-
|
|
2924
|
+
A,
|
|
2722
2925
|
e.initialData,
|
|
2723
2926
|
e.initialValues
|
|
2724
2927
|
]), i(() => {
|
|
2725
|
-
|
|
2928
|
+
A ? f({
|
|
2726
2929
|
name: e.objectName,
|
|
2727
2930
|
fields: {}
|
|
2728
2931
|
}) : e.objectName && r ? (async () => {
|
|
@@ -2730,34 +2933,34 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2730
2933
|
if (!r) throw Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");
|
|
2731
2934
|
let t = await r.getObjectSchema(e.objectName);
|
|
2732
2935
|
if (!t) throw Error(`No schema found for object "${e.objectName}"`);
|
|
2733
|
-
|
|
2936
|
+
f(t);
|
|
2734
2937
|
} catch (e) {
|
|
2735
|
-
|
|
2938
|
+
S(e), y(!1);
|
|
2736
2939
|
}
|
|
2737
|
-
})() :
|
|
2940
|
+
})() : A || y(!1);
|
|
2738
2941
|
}, [
|
|
2739
2942
|
e.objectName,
|
|
2740
2943
|
r,
|
|
2741
|
-
|
|
2944
|
+
A
|
|
2742
2945
|
]), i(() => {
|
|
2743
|
-
d && !
|
|
2946
|
+
d && !A && (async () => {
|
|
2744
2947
|
if (!e.recordId || e.mode === "create") {
|
|
2745
|
-
|
|
2948
|
+
_(e.initialData || e.initialValues || {}), y(!1);
|
|
2746
2949
|
return;
|
|
2747
2950
|
}
|
|
2748
|
-
if (!
|
|
2951
|
+
if (!A) {
|
|
2749
2952
|
if (!r) {
|
|
2750
|
-
|
|
2953
|
+
S(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), y(!1);
|
|
2751
2954
|
return;
|
|
2752
2955
|
}
|
|
2753
|
-
|
|
2956
|
+
y(!0);
|
|
2754
2957
|
try {
|
|
2755
2958
|
let t = await r.findOne(e.objectName, e.recordId);
|
|
2756
|
-
|
|
2959
|
+
_(t);
|
|
2757
2960
|
} catch (e) {
|
|
2758
|
-
console.error("Failed to fetch record:", e),
|
|
2961
|
+
console.error("Failed to fetch record:", e), S(e);
|
|
2759
2962
|
} finally {
|
|
2760
|
-
|
|
2963
|
+
y(!1);
|
|
2761
2964
|
}
|
|
2762
2965
|
}
|
|
2763
2966
|
})();
|
|
@@ -2769,33 +2972,33 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2769
2972
|
e.initialData,
|
|
2770
2973
|
r,
|
|
2771
2974
|
d,
|
|
2772
|
-
|
|
2975
|
+
A
|
|
2773
2976
|
]);
|
|
2774
|
-
let
|
|
2977
|
+
let P = n((e) => e, []);
|
|
2775
2978
|
i(() => {
|
|
2776
|
-
if (
|
|
2777
|
-
|
|
2979
|
+
if (A && e.customFields) {
|
|
2980
|
+
m(e.customFields.map(P)), y(!1);
|
|
2778
2981
|
return;
|
|
2779
2982
|
}
|
|
2780
2983
|
if (!d) return;
|
|
2781
|
-
let t = [], n =
|
|
2984
|
+
let t = [], n = g(d, l?.getObjectApiOperations?.(e.objectName)), i = !(e.mode === "edit" ? n.edit : e.mode !== "create" || n.create), o = e.fields || Object.keys(d.fields || {});
|
|
2782
2985
|
(Array.isArray(o) ? o : Object.keys(o)).forEach((n) => {
|
|
2783
2986
|
let r = typeof n == "string" ? n : n.name;
|
|
2784
2987
|
if (!r) return;
|
|
2785
2988
|
let o = d.fields?.[r];
|
|
2786
|
-
if (!o && !
|
|
2989
|
+
if (!o && !A) return;
|
|
2787
2990
|
let s = e.customFields?.find((e) => e.name === r);
|
|
2788
|
-
if (s) t.push(
|
|
2991
|
+
if (s) t.push(P(s));
|
|
2789
2992
|
else if (o) {
|
|
2790
2993
|
let s = {
|
|
2791
2994
|
name: r,
|
|
2792
2995
|
label: a(e.objectName, r, o.label || n),
|
|
2793
|
-
type:
|
|
2794
|
-
required: o
|
|
2996
|
+
type: N(o.type, { multiple: o.multiple }),
|
|
2997
|
+
required: Ve(o, Be(e)),
|
|
2795
2998
|
disabled: e.readOnly || e.mode === "view" || o.readonly || i,
|
|
2796
2999
|
placeholder: o.placeholder,
|
|
2797
3000
|
description: o.help || o.description,
|
|
2798
|
-
validation:
|
|
3001
|
+
validation: j(o),
|
|
2799
3002
|
visibleWhen: o.visibleWhen,
|
|
2800
3003
|
readonlyWhen: o.readonlyWhen,
|
|
2801
3004
|
requiredWhen: o.requiredWhen,
|
|
@@ -2804,12 +3007,12 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2804
3007
|
widget: o.widget
|
|
2805
3008
|
};
|
|
2806
3009
|
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: ${
|
|
3010
|
+
let e = `Max size: ${M(o.max_size)}`;
|
|
2808
3011
|
s.description = s.description ? `${s.description} (${e})` : e;
|
|
2809
3012
|
}
|
|
2810
3013
|
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
3014
|
}
|
|
2812
|
-
}),
|
|
3015
|
+
}), m(t), !A && e.recordId && e.mode !== "create" && r || y(!1);
|
|
2813
3016
|
}, [
|
|
2814
3017
|
d,
|
|
2815
3018
|
e.fields,
|
|
@@ -2817,16 +3020,16 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2817
3020
|
e.readOnly,
|
|
2818
3021
|
e.mode,
|
|
2819
3022
|
e.objectName,
|
|
2820
|
-
|
|
3023
|
+
A,
|
|
2821
3024
|
e.recordId,
|
|
2822
3025
|
r,
|
|
2823
3026
|
l
|
|
2824
3027
|
]);
|
|
2825
|
-
let
|
|
2826
|
-
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 = {})),
|
|
3028
|
+
let F = n(async (t, n) => {
|
|
3029
|
+
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 = {})), A && !r) return e.onSuccess && await e.onSuccess(t), t;
|
|
2827
3030
|
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") {
|
|
3031
|
+
let i = Ot(t, A ? null : d);
|
|
3032
|
+
if (Be(e) && (i = Ge(i, A ? null : d)), l?.isLoaded && i && typeof i == "object") {
|
|
2830
3033
|
let t = {};
|
|
2831
3034
|
for (let n of Object.keys(i)) l.checkField(e.objectName, n, "write") && (t[n] = i[n]);
|
|
2832
3035
|
i = t;
|
|
@@ -2836,37 +3039,52 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2836
3039
|
if (e.submitHandler) t = await e.submitHandler(i);
|
|
2837
3040
|
else if (e.mode === "create") t = await r.create(e.objectName, i);
|
|
2838
3041
|
else if (e.mode === "edit" && e.recordId) {
|
|
2839
|
-
let n = await
|
|
3042
|
+
let n = await D({
|
|
2840
3043
|
dataSource: r,
|
|
2841
3044
|
objectName: e.objectName,
|
|
2842
3045
|
recordId: e.recordId,
|
|
2843
3046
|
payload: i,
|
|
2844
|
-
baseRecord:
|
|
3047
|
+
baseRecord: h
|
|
2845
3048
|
});
|
|
2846
3049
|
if (n.status === "cancelled") return;
|
|
2847
3050
|
t = n.result;
|
|
2848
3051
|
} else throw Error("Invalid form mode or missing record ID");
|
|
2849
3052
|
if (e.onSuccess) await e.onSuccess(t);
|
|
2850
3053
|
else if (!e.submitHandler && e.submitBehavior) {
|
|
2851
|
-
let
|
|
2852
|
-
switch (
|
|
2853
|
-
case "redirect":
|
|
2854
|
-
|
|
3054
|
+
let n = e.submitBehavior;
|
|
3055
|
+
switch (n.kind) {
|
|
3056
|
+
case "redirect": {
|
|
3057
|
+
let r = Ne(n.url, Me(i, t));
|
|
3058
|
+
if (!r.ok) {
|
|
3059
|
+
X.error(r.refusal), w({
|
|
3060
|
+
message: e.successMessage || (e.mode === "create" ? "Created" : "Saved"),
|
|
3061
|
+
refusal: r.refusal
|
|
3062
|
+
});
|
|
3063
|
+
break;
|
|
3064
|
+
}
|
|
3065
|
+
E({
|
|
3066
|
+
url: r.url,
|
|
3067
|
+
delayMs: n.delayMs ?? 0
|
|
3068
|
+
});
|
|
2855
3069
|
break;
|
|
3070
|
+
}
|
|
2856
3071
|
case "continue": break;
|
|
2857
3072
|
default: {
|
|
2858
|
-
let
|
|
2859
|
-
|
|
2860
|
-
title:
|
|
2861
|
-
message:
|
|
3073
|
+
let t = n.kind === "thank-you" && n.message ? n.message : e.successMessage || (e.mode === "create" ? "Created" : "Saved");
|
|
3074
|
+
X.success(t), w({
|
|
3075
|
+
title: n.kind === "thank-you" ? n.title : void 0,
|
|
3076
|
+
message: t
|
|
2862
3077
|
});
|
|
2863
3078
|
break;
|
|
2864
3079
|
}
|
|
2865
3080
|
}
|
|
2866
3081
|
} else if (!e.submitHandler) {
|
|
2867
|
-
let n =
|
|
2868
|
-
if (n) return
|
|
2869
|
-
|
|
3082
|
+
let n = ke(e.navigateOnSuccess, t);
|
|
3083
|
+
if (n) return Le(n) ? E({
|
|
3084
|
+
url: n,
|
|
3085
|
+
delayMs: 0
|
|
3086
|
+
}) : window.location.assign(n), t;
|
|
3087
|
+
e.navigateOnSuccess ? (console.warn("[ObjectForm] `navigateOnSuccess` was declared but produced no destination:", e.navigateOnSuccess), X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved"), { description: xt })) : X.success(e.successMessage || (e.mode === "create" ? "Created" : "Saved"));
|
|
2870
3088
|
}
|
|
2871
3089
|
return t;
|
|
2872
3090
|
} catch (t) {
|
|
@@ -2875,66 +3093,73 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2875
3093
|
}, [
|
|
2876
3094
|
e,
|
|
2877
3095
|
r,
|
|
2878
|
-
|
|
3096
|
+
A,
|
|
2879
3097
|
l,
|
|
2880
3098
|
d,
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
]),
|
|
3099
|
+
D,
|
|
3100
|
+
h
|
|
3101
|
+
]), I = n(() => {
|
|
2884
3102
|
e.onCancel && e.onCancel();
|
|
2885
|
-
}, [e]),
|
|
2886
|
-
...t.useMemo(() => {
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
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;
|
|
3103
|
+
}, [e]), ee = Be(e), te = {
|
|
3104
|
+
...t.useMemo(() => ee ? He(d, { currentUserId: l.userId }) : {}, [
|
|
3105
|
+
d,
|
|
3106
|
+
ee,
|
|
3107
|
+
l.userId
|
|
3108
|
+
]),
|
|
3109
|
+
...h
|
|
3110
|
+
}, L = e.mode === "edit" && e.recordId && h && typeof h == "object" ? h : void 0, ne = t.useMemo(() => {
|
|
3111
|
+
let t = st(p, d);
|
|
3112
|
+
return e.mode === "create" && (t = lt(t, d)), t;
|
|
2898
3113
|
}, [
|
|
2899
|
-
|
|
3114
|
+
p,
|
|
2900
3115
|
d,
|
|
2901
3116
|
e.mode
|
|
2902
|
-
]),
|
|
3117
|
+
]), re = t.useMemo(() => e.sections?.length ? null : un(ne, d?.fieldGroups), [
|
|
2903
3118
|
e.sections,
|
|
2904
|
-
|
|
3119
|
+
ne,
|
|
2905
3120
|
d
|
|
2906
|
-
]),
|
|
2907
|
-
if (
|
|
3121
|
+
]), R = e.sections?.length ? e.sections : re, [z, B] = c({});
|
|
3122
|
+
if (b) return /* @__PURE__ */ Q("div", {
|
|
2908
3123
|
className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
|
|
2909
|
-
children: [/* @__PURE__ */
|
|
3124
|
+
children: [/* @__PURE__ */ Z("h3", {
|
|
2910
3125
|
className: "text-red-800 font-semibold",
|
|
2911
3126
|
children: "Error loading form"
|
|
2912
|
-
}), /* @__PURE__ */
|
|
3127
|
+
}), /* @__PURE__ */ Z("p", {
|
|
2913
3128
|
className: "text-red-600 text-sm mt-1",
|
|
2914
|
-
children:
|
|
3129
|
+
children: b.message
|
|
2915
3130
|
})]
|
|
2916
3131
|
});
|
|
2917
|
-
if (
|
|
3132
|
+
if (v) return /* @__PURE__ */ Q("div", {
|
|
2918
3133
|
className: "p-4 sm:p-8 text-center",
|
|
2919
|
-
children: [/* @__PURE__ */
|
|
3134
|
+
children: [/* @__PURE__ */ Z("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ Z("p", {
|
|
2920
3135
|
className: "mt-2 text-sm text-gray-600",
|
|
2921
3136
|
children: "Loading form..."
|
|
2922
3137
|
})]
|
|
2923
3138
|
});
|
|
2924
|
-
if (
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
3139
|
+
if (C) {
|
|
3140
|
+
let e = /* @__PURE__ */ Q("div", {
|
|
3141
|
+
className: "rounded-md border bg-card p-6 sm:p-8 text-center",
|
|
3142
|
+
children: [/* @__PURE__ */ Z("h3", {
|
|
3143
|
+
className: "text-lg font-semibold",
|
|
3144
|
+
children: C.title ?? "Thanks!"
|
|
3145
|
+
}), C.message && /* @__PURE__ */ Z("p", {
|
|
3146
|
+
className: "mt-2 text-sm text-muted-foreground",
|
|
3147
|
+
children: C.message
|
|
3148
|
+
})]
|
|
3149
|
+
});
|
|
3150
|
+
return C.refusal ? /* @__PURE__ */ Q("div", {
|
|
3151
|
+
className: "space-y-4",
|
|
3152
|
+
children: [e, /* @__PURE__ */ Z("div", {
|
|
3153
|
+
role: "alert",
|
|
3154
|
+
className: "rounded-md border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive",
|
|
3155
|
+
children: C.refusal
|
|
3156
|
+
})]
|
|
3157
|
+
}) : e;
|
|
3158
|
+
}
|
|
2934
3159
|
let V = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical";
|
|
2935
|
-
if (
|
|
2936
|
-
let t =
|
|
2937
|
-
|
|
3160
|
+
if (R?.length && (!e.formType || e.formType === "simple")) {
|
|
3161
|
+
let t = re ? ne : p, n = (e) => typeof e == "number" && e > 0 ? Math.min(Math.floor(e), 4) : void 0, r = R.map((e) => n(e.columns)).filter((e) => e != null), i = R.reduce((e, t) => e + (Array.isArray(t.fields) ? t.fields.length : 0), 0), a = n(e.columns) ?? (r.length ? Math.max(...r) : rt(i)), s = [];
|
|
3162
|
+
R.forEach((r, i) => {
|
|
2938
3163
|
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
3164
|
let t = c.get(e.name);
|
|
2940
3165
|
if (!t || typeof t != "object") return e;
|
|
@@ -2942,7 +3167,7 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2942
3167
|
return n.visibleOn != null && (r.visibleOn = n.visibleOn), n.colSpan != null && (r.colSpan = n.colSpan), n.span != null && (r.span = n.span), r;
|
|
2943
3168
|
});
|
|
2944
3169
|
if (d.length === 0) return;
|
|
2945
|
-
let f = r.name || r.label || String(i), p = r.name ? o(e.objectName, r.name, r.label || r.name) : r.label, m =
|
|
3170
|
+
let f = r.name || r.label || String(i), p = r.name ? o(e.objectName, r.name, r.label || r.name) : r.label, m = z[f] ?? r.collapsed ?? !1;
|
|
2946
3171
|
p && s.push({
|
|
2947
3172
|
name: `__section_${f}`,
|
|
2948
3173
|
label: p,
|
|
@@ -2950,45 +3175,45 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2950
3175
|
colSpan: 4,
|
|
2951
3176
|
collapsible: r.collapsible,
|
|
2952
3177
|
collapsed: m,
|
|
2953
|
-
onToggle: r.collapsible ? () =>
|
|
3178
|
+
onToggle: r.collapsible ? () => B((e) => ({
|
|
2954
3179
|
...e,
|
|
2955
3180
|
[f]: !m
|
|
2956
3181
|
})) : void 0,
|
|
2957
3182
|
className: r.className
|
|
2958
3183
|
});
|
|
2959
|
-
let h = n(r.columns), g = a > 1 ?
|
|
3184
|
+
let h = n(r.columns), g = a > 1 ? $(d, a, h) : d;
|
|
2960
3185
|
p && m ? s.push(...g.map((e) => ({
|
|
2961
3186
|
...e,
|
|
2962
3187
|
hidden: !0
|
|
2963
3188
|
}))) : s.push(...g);
|
|
2964
3189
|
});
|
|
2965
|
-
let c = s, l =
|
|
2966
|
-
return /* @__PURE__ */
|
|
3190
|
+
let c = s, l = dt(a);
|
|
3191
|
+
return /* @__PURE__ */ Q("div", {
|
|
2967
3192
|
className: "w-full @container",
|
|
2968
|
-
children: [/* @__PURE__ */
|
|
3193
|
+
children: [/* @__PURE__ */ Z(x, { schema: {
|
|
2969
3194
|
type: "form",
|
|
2970
3195
|
objectName: e.objectName,
|
|
2971
3196
|
fields: c,
|
|
2972
3197
|
layout: V,
|
|
2973
3198
|
columns: a,
|
|
2974
3199
|
...l ? { fieldContainerClass: l } : {},
|
|
2975
|
-
defaultValues:
|
|
2976
|
-
previousValues:
|
|
3200
|
+
defaultValues: te,
|
|
3201
|
+
previousValues: L,
|
|
2977
3202
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
2978
3203
|
showCancel: e.showCancel !== !1,
|
|
2979
3204
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
2980
3205
|
cancelLabel: e.cancelText,
|
|
2981
|
-
onSubmit:
|
|
2982
|
-
onCancel:
|
|
2983
|
-
} }),
|
|
3206
|
+
onSubmit: F,
|
|
3207
|
+
onCancel: I
|
|
3208
|
+
} }), k]
|
|
2984
3209
|
});
|
|
2985
3210
|
}
|
|
2986
|
-
let H = e.sections?.length, U = u(
|
|
3211
|
+
let H = e.sections?.length, U = u(p), ie = H ? {
|
|
2987
3212
|
fields: U,
|
|
2988
3213
|
columns: e.columns
|
|
2989
|
-
} :
|
|
3214
|
+
} : pt(U, d, e.columns, e.mode), W = e.mobile, G = W?.fullscreenLongText ? ie.fields.map((e) => {
|
|
2990
3215
|
let t = e.type;
|
|
2991
|
-
return t !== "textarea" && t !== "field:textarea" && t !== "field:markdown" && t !== "field:html" ? e : e.field ? {
|
|
3216
|
+
return t !== "textarea" && t !== "field:textarea" && t !== "field:markdown" && t !== "field:html" && t !== "field:richtext" ? e : e.field ? {
|
|
2992
3217
|
...e,
|
|
2993
3218
|
field: {
|
|
2994
3219
|
...e.field,
|
|
@@ -2998,18 +3223,18 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
2998
3223
|
...e,
|
|
2999
3224
|
mobile_fullscreen: !0
|
|
3000
3225
|
};
|
|
3001
|
-
}) :
|
|
3002
|
-
if (!e.formType && !H && G.length >= 2 && (
|
|
3226
|
+
}) : ie.fields, ae = W?.stepper, K = W?.stepperMinFields ?? 8, oe = Math.max(1, W?.stepperFieldsPerStep ?? 1);
|
|
3227
|
+
if (!e.formType && !H && G.length >= 2 && (ae === !0 || ae === "auto" && s && G.length >= K)) {
|
|
3003
3228
|
let t = G, n = [];
|
|
3004
|
-
for (let e = 0; e < t.length; e +=
|
|
3005
|
-
let r = t.slice(e, e +
|
|
3229
|
+
for (let e = 0; e < t.length; e += oe) {
|
|
3230
|
+
let r = t.slice(e, e + oe);
|
|
3006
3231
|
n.push({
|
|
3007
|
-
name: `step-${Math.floor(e /
|
|
3008
|
-
label: r[0]?.label || r[0]?.name || `Step ${Math.floor(e /
|
|
3232
|
+
name: `step-${Math.floor(e / oe) + 1}`,
|
|
3233
|
+
label: r[0]?.label || r[0]?.name || `Step ${Math.floor(e / oe) + 1}`,
|
|
3009
3234
|
fields: r
|
|
3010
3235
|
});
|
|
3011
3236
|
}
|
|
3012
|
-
return /* @__PURE__ */
|
|
3237
|
+
return /* @__PURE__ */ Z(wt, {
|
|
3013
3238
|
schema: {
|
|
3014
3239
|
...e,
|
|
3015
3240
|
formType: "wizard",
|
|
@@ -3020,30 +3245,46 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
3020
3245
|
className: e.className
|
|
3021
3246
|
});
|
|
3022
3247
|
}
|
|
3023
|
-
let
|
|
3248
|
+
let se = {
|
|
3024
3249
|
type: "form",
|
|
3025
3250
|
objectName: e.objectName,
|
|
3026
3251
|
fields: G,
|
|
3027
3252
|
layout: V,
|
|
3028
|
-
columns:
|
|
3253
|
+
columns: ie.columns,
|
|
3029
3254
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
3030
3255
|
cancelLabel: e.cancelText,
|
|
3031
3256
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
3032
3257
|
showCancel: e.showCancel !== !1,
|
|
3033
3258
|
resetOnSubmit: e.showReset || e.submitBehavior?.kind === "continue" || !e.submitBehavior && e.resetOnSuccess && e.mode === "create",
|
|
3034
|
-
defaultValues:
|
|
3035
|
-
previousValues:
|
|
3036
|
-
onSubmit:
|
|
3037
|
-
onCancel:
|
|
3259
|
+
defaultValues: te,
|
|
3260
|
+
previousValues: L,
|
|
3261
|
+
onSubmit: F,
|
|
3262
|
+
onCancel: I,
|
|
3038
3263
|
className: e.className,
|
|
3039
3264
|
mobileStickyActions: !!W?.stickyActions
|
|
3040
3265
|
};
|
|
3041
|
-
return /* @__PURE__ */
|
|
3266
|
+
return /* @__PURE__ */ Q("div", {
|
|
3042
3267
|
className: W?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
|
|
3043
3268
|
"data-mobile-form": W ? "true" : void 0,
|
|
3044
|
-
children: [/* @__PURE__ */
|
|
3269
|
+
children: [/* @__PURE__ */ Z(x, { schema: se }), k]
|
|
3045
3270
|
});
|
|
3046
|
-
},
|
|
3271
|
+
}, bn = 1e3;
|
|
3272
|
+
function xn(e) {
|
|
3273
|
+
return e ? Math.max(0, Math.ceil(e.delayMs / 1e3)) : null;
|
|
3274
|
+
}
|
|
3275
|
+
function Sn(e) {
|
|
3276
|
+
let [t, n] = c(e), [r, a] = c(() => xn(e));
|
|
3277
|
+
return e !== t && (n(e), a(xn(e))), i(() => {
|
|
3278
|
+
if (!e) return;
|
|
3279
|
+
let t = setInterval(() => {
|
|
3280
|
+
a((e) => e === null || e <= 1 ? (clearInterval(t), 0) : e - 1);
|
|
3281
|
+
}, bn);
|
|
3282
|
+
return () => clearInterval(t);
|
|
3283
|
+
}, [e]), r;
|
|
3284
|
+
}
|
|
3285
|
+
//#endregion
|
|
3286
|
+
//#region src/EmbeddableForm.tsx
|
|
3287
|
+
var Cn = {
|
|
3047
3288
|
text: 200,
|
|
3048
3289
|
email: 254,
|
|
3049
3290
|
url: 2048,
|
|
@@ -3051,8 +3292,8 @@ var Ht = ({ schema: e, dataSource: t }) => {
|
|
|
3051
3292
|
textarea: 5e3,
|
|
3052
3293
|
markdown: 5e3,
|
|
3053
3294
|
html: 5e3
|
|
3054
|
-
},
|
|
3055
|
-
function
|
|
3295
|
+
}, wn = "_company_website_2", Tn = 1500;
|
|
3296
|
+
function En(e, t = []) {
|
|
3056
3297
|
try {
|
|
3057
3298
|
let n = new URL(e, typeof window < "u" ? window.location.href : "http://localhost");
|
|
3058
3299
|
return typeof window < "u" && n.origin === window.location.origin ? !0 : n.protocol !== "https:" && n.protocol !== "http:" ? !1 : t.some((e) => {
|
|
@@ -3067,22 +3308,22 @@ function qt(e, t = []) {
|
|
|
3067
3308
|
return !1;
|
|
3068
3309
|
}
|
|
3069
3310
|
}
|
|
3070
|
-
function
|
|
3311
|
+
function Dn(e) {
|
|
3071
3312
|
return e && e.map((e) => {
|
|
3072
|
-
let t =
|
|
3313
|
+
let t = Cn[String(e.type || "").toLowerCase()];
|
|
3073
3314
|
return !t || (e.maxLength ?? e.max_length) ? e : {
|
|
3074
3315
|
...e,
|
|
3075
3316
|
maxLength: t
|
|
3076
3317
|
};
|
|
3077
3318
|
});
|
|
3078
3319
|
}
|
|
3079
|
-
var
|
|
3080
|
-
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),
|
|
3320
|
+
var On = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
3321
|
+
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, b] = c(null), [x, S] = c(!1), C = s(null), w = s(0);
|
|
3081
3322
|
i(() => {
|
|
3082
|
-
l || (
|
|
3083
|
-
}, [l]);
|
|
3084
|
-
let
|
|
3085
|
-
if (!t ||
|
|
3323
|
+
l || (w.current = Date.now());
|
|
3324
|
+
}, [l]), Re(y);
|
|
3325
|
+
let T = Sn(y), E = e.honeypot === !1 ? null : e.honeypot || wn, D = e.minFillTime ?? Tn, O = o(() => Dn(e.customFields), [e.customFields]), k = o(() => {
|
|
3326
|
+
if (!t || O && O.length > 0 || !e.fields || e.fields.length === 0) return;
|
|
3086
3327
|
let n = async (e, t) => t;
|
|
3087
3328
|
return {
|
|
3088
3329
|
...t,
|
|
@@ -3092,9 +3333,9 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3092
3333
|
};
|
|
3093
3334
|
}, [
|
|
3094
3335
|
t,
|
|
3095
|
-
|
|
3336
|
+
O,
|
|
3096
3337
|
e.fields
|
|
3097
|
-
]),
|
|
3338
|
+
]), A = o(() => {
|
|
3098
3339
|
let t = {};
|
|
3099
3340
|
if (r) for (let [e, n] of Object.entries(r)) t[e] = n;
|
|
3100
3341
|
if (typeof window < "u" && e.allowedPrefillFields?.length) {
|
|
@@ -3104,30 +3345,33 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3104
3345
|
});
|
|
3105
3346
|
}
|
|
3106
3347
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
3107
|
-
}, [r, e.allowedPrefillFields]),
|
|
3348
|
+
}, [r, e.allowedPrefillFields]), j = n(async (n) => {
|
|
3108
3349
|
if (e.consent?.required && !h) {
|
|
3109
3350
|
v(e.texts?.consentRequired ?? "Please accept the privacy policy to continue.");
|
|
3110
3351
|
return;
|
|
3111
3352
|
}
|
|
3112
|
-
if (v(null),
|
|
3353
|
+
if (v(null), E && C.current?.value) {
|
|
3113
3354
|
u(!0);
|
|
3114
3355
|
return;
|
|
3115
3356
|
}
|
|
3116
|
-
if (
|
|
3357
|
+
if (D > 0 && Date.now() - w.current < D) {
|
|
3117
3358
|
m(e.texts?.rateLimited ?? "Please take a moment to review your answers before submitting.");
|
|
3118
3359
|
return;
|
|
3119
3360
|
}
|
|
3120
3361
|
let r = { ...n };
|
|
3121
|
-
|
|
3362
|
+
E && delete r[E], e.captchaToken && (r._captcha = e.captchaToken), f(!0), m(null);
|
|
3122
3363
|
try {
|
|
3123
3364
|
t && await t.create(e.objectName, r), u(!0);
|
|
3124
3365
|
let n = e.thankYouPage?.redirectUrl;
|
|
3125
|
-
if (n)
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3366
|
+
if (n) {
|
|
3367
|
+
if (En(n, e.allowedRedirectHosts)) {
|
|
3368
|
+
let t = e.thankYouPage?.redirectDelay ?? 3e3;
|
|
3369
|
+
b({
|
|
3370
|
+
url: n,
|
|
3371
|
+
delayMs: t
|
|
3372
|
+
});
|
|
3373
|
+
} else console.warn("[EmbeddableForm] Blocked unsafe redirect target:", n), S(!0);
|
|
3374
|
+
}
|
|
3131
3375
|
} catch (e) {
|
|
3132
3376
|
m(e instanceof Error ? e.message : "Failed to submit form. Please try again.");
|
|
3133
3377
|
} finally {
|
|
@@ -3137,195 +3381,199 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3137
3381
|
t,
|
|
3138
3382
|
e,
|
|
3139
3383
|
h,
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
]),
|
|
3143
|
-
u(!1), m(null);
|
|
3144
|
-
}, []),
|
|
3384
|
+
E,
|
|
3385
|
+
D
|
|
3386
|
+
]), M = n(() => {
|
|
3387
|
+
u(!1), m(null), b(null), S(!1);
|
|
3388
|
+
}, []), N = o(() => {
|
|
3145
3389
|
let t = {};
|
|
3146
3390
|
return e.branding?.backgroundColor && (t.backgroundColor = e.branding.backgroundColor), t;
|
|
3147
3391
|
}, [e.branding]);
|
|
3148
3392
|
if (l) {
|
|
3149
|
-
let t = e.thankYouPage, n = e.texts ?? {}, r =
|
|
3150
|
-
return /* @__PURE__ */
|
|
3393
|
+
let t = e.thankYouPage, n = e.texts ?? {}, r = y && T !== null ? (n.redirecting ?? "Redirecting in {{seconds}} seconds…").replace("{{seconds}}", String(T)) : null;
|
|
3394
|
+
return /* @__PURE__ */ Z("div", {
|
|
3151
3395
|
className: `min-h-screen flex items-center justify-center p-4 bg-gradient-to-b from-muted/40 via-background to-background ${a || ""}`,
|
|
3152
|
-
style:
|
|
3153
|
-
children: /* @__PURE__ */
|
|
3396
|
+
style: N,
|
|
3397
|
+
children: /* @__PURE__ */ Q("div", {
|
|
3154
3398
|
className: "max-w-md w-full bg-card border rounded-xl shadow-sm p-8 text-center space-y-4",
|
|
3155
3399
|
children: [
|
|
3156
|
-
/* @__PURE__ */
|
|
3400
|
+
/* @__PURE__ */ Z("div", {
|
|
3157
3401
|
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__ */
|
|
3402
|
+
children: /* @__PURE__ */ Z(ye, {
|
|
3159
3403
|
className: "h-8 w-8",
|
|
3160
3404
|
"aria-hidden": "true"
|
|
3161
3405
|
})
|
|
3162
3406
|
}),
|
|
3163
|
-
/* @__PURE__ */
|
|
3407
|
+
/* @__PURE__ */ Z("h2", {
|
|
3164
3408
|
className: "text-xl font-semibold text-foreground",
|
|
3165
3409
|
children: t?.title || n.thankYouTitle || "Thank You!"
|
|
3166
3410
|
}),
|
|
3167
|
-
/* @__PURE__ */
|
|
3411
|
+
/* @__PURE__ */ Z("p", {
|
|
3168
3412
|
className: "text-sm text-muted-foreground",
|
|
3169
3413
|
children: t?.message || n.thankYouMessage || "Your submission has been received successfully."
|
|
3170
3414
|
}),
|
|
3171
|
-
e.allowMultiple && /* @__PURE__ */
|
|
3415
|
+
e.allowMultiple && /* @__PURE__ */ Z(R, {
|
|
3172
3416
|
variant: "outline",
|
|
3173
3417
|
size: "sm",
|
|
3174
|
-
onClick:
|
|
3418
|
+
onClick: M,
|
|
3175
3419
|
className: "mt-2",
|
|
3176
3420
|
children: n.submitAnother ?? "Submit Another Response"
|
|
3177
3421
|
}),
|
|
3178
|
-
|
|
3422
|
+
r && /* @__PURE__ */ Z("p", {
|
|
3179
3423
|
className: "text-xs text-muted-foreground",
|
|
3180
|
-
children:
|
|
3424
|
+
children: r
|
|
3425
|
+
}),
|
|
3426
|
+
x && n.redirectBlocked && /* @__PURE__ */ Z("p", {
|
|
3427
|
+
className: "text-xs text-muted-foreground",
|
|
3428
|
+
children: n.redirectBlocked
|
|
3181
3429
|
})
|
|
3182
3430
|
]
|
|
3183
3431
|
})
|
|
3184
3432
|
});
|
|
3185
3433
|
}
|
|
3186
|
-
let
|
|
3187
|
-
return /* @__PURE__ */
|
|
3434
|
+
let P = e.texts ?? {}, F = !!e.consent?.required, I = `${e.formId}-consent`;
|
|
3435
|
+
return /* @__PURE__ */ Z("div", {
|
|
3188
3436
|
className: `min-h-screen flex items-center justify-center p-4 sm:p-6 bg-gradient-to-b from-muted/40 via-background to-background ${a || ""}`,
|
|
3189
|
-
style:
|
|
3190
|
-
children: /* @__PURE__ */
|
|
3437
|
+
style: N,
|
|
3438
|
+
children: /* @__PURE__ */ Q("div", {
|
|
3191
3439
|
className: "max-w-2xl w-full bg-card border rounded-xl shadow-sm overflow-hidden",
|
|
3192
3440
|
children: [
|
|
3193
|
-
e.branding?.coverImage && /* @__PURE__ */
|
|
3441
|
+
e.branding?.coverImage && /* @__PURE__ */ Z("div", {
|
|
3194
3442
|
className: "h-28 sm:h-32 w-full bg-cover bg-center",
|
|
3195
3443
|
style: { backgroundImage: `url(${JSON.stringify(e.branding.coverImage)})` },
|
|
3196
3444
|
role: "presentation"
|
|
3197
3445
|
}),
|
|
3198
|
-
/* @__PURE__ */
|
|
3446
|
+
/* @__PURE__ */ Q("div", {
|
|
3199
3447
|
className: "px-6 sm:px-8 pt-7 pb-5 border-b bg-muted/20",
|
|
3200
3448
|
style: e.branding?.primaryColor ? { borderBottomColor: e.branding.primaryColor } : void 0,
|
|
3201
3449
|
children: [
|
|
3202
|
-
e.branding?.logo && /* @__PURE__ */
|
|
3450
|
+
e.branding?.logo && /* @__PURE__ */ Z("img", {
|
|
3203
3451
|
src: e.branding.logo,
|
|
3204
3452
|
alt: "",
|
|
3205
3453
|
className: "h-8 mb-4"
|
|
3206
3454
|
}),
|
|
3207
|
-
e.title && /* @__PURE__ */
|
|
3455
|
+
e.title && /* @__PURE__ */ Z("h1", {
|
|
3208
3456
|
className: "text-2xl font-semibold tracking-tight text-foreground",
|
|
3209
3457
|
children: e.title
|
|
3210
3458
|
}),
|
|
3211
|
-
e.description && /* @__PURE__ */
|
|
3459
|
+
e.description && /* @__PURE__ */ Z("p", {
|
|
3212
3460
|
className: "text-sm text-muted-foreground mt-2 leading-relaxed",
|
|
3213
3461
|
children: e.description
|
|
3214
3462
|
}),
|
|
3215
|
-
/* @__PURE__ */
|
|
3463
|
+
/* @__PURE__ */ Z("p", {
|
|
3216
3464
|
className: "text-[11px] text-muted-foreground/70 mt-3",
|
|
3217
3465
|
"aria-hidden": "true",
|
|
3218
|
-
children:
|
|
3466
|
+
children: P.requiredHint ?? "* Required field"
|
|
3219
3467
|
})
|
|
3220
3468
|
]
|
|
3221
3469
|
}),
|
|
3222
|
-
/* @__PURE__ */
|
|
3470
|
+
/* @__PURE__ */ Q("div", {
|
|
3223
3471
|
className: "relative px-6 sm:px-8 py-6",
|
|
3224
3472
|
children: [
|
|
3225
|
-
p && /* @__PURE__ */
|
|
3473
|
+
p && /* @__PURE__ */ Z("div", {
|
|
3226
3474
|
role: "alert",
|
|
3227
3475
|
"aria-live": "assertive",
|
|
3228
3476
|
className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
|
|
3229
3477
|
children: p
|
|
3230
3478
|
}),
|
|
3231
|
-
/* @__PURE__ */
|
|
3479
|
+
/* @__PURE__ */ Z(vn, {
|
|
3232
3480
|
schema: {
|
|
3233
3481
|
type: "object-form",
|
|
3234
3482
|
objectName: e.objectName,
|
|
3235
3483
|
mode: "create",
|
|
3236
3484
|
fields: e.fields,
|
|
3237
|
-
customFields:
|
|
3238
|
-
initialData:
|
|
3239
|
-
onSuccess:
|
|
3240
|
-
submitText: d ?
|
|
3485
|
+
customFields: O,
|
|
3486
|
+
initialData: A,
|
|
3487
|
+
onSuccess: j,
|
|
3488
|
+
submitText: d ? P.submitting ?? "Submitting..." : P.submit ?? "Submit"
|
|
3241
3489
|
},
|
|
3242
|
-
dataSource:
|
|
3490
|
+
dataSource: k
|
|
3243
3491
|
}),
|
|
3244
|
-
|
|
3492
|
+
E && /* @__PURE__ */ Q("div", {
|
|
3245
3493
|
"aria-hidden": "true",
|
|
3246
3494
|
className: "absolute left-[-10000px] top-auto h-px w-px overflow-hidden",
|
|
3247
|
-
children: [/* @__PURE__ */
|
|
3248
|
-
htmlFor: `${e.formId}-${
|
|
3495
|
+
children: [/* @__PURE__ */ Z("label", {
|
|
3496
|
+
htmlFor: `${e.formId}-${E}`,
|
|
3249
3497
|
children: "Do not fill this field"
|
|
3250
|
-
}), /* @__PURE__ */
|
|
3251
|
-
ref:
|
|
3252
|
-
id: `${e.formId}-${
|
|
3498
|
+
}), /* @__PURE__ */ Z("input", {
|
|
3499
|
+
ref: C,
|
|
3500
|
+
id: `${e.formId}-${E}`,
|
|
3253
3501
|
type: "text",
|
|
3254
|
-
name:
|
|
3502
|
+
name: E,
|
|
3255
3503
|
tabIndex: -1,
|
|
3256
3504
|
autoComplete: "off",
|
|
3257
3505
|
defaultValue: ""
|
|
3258
3506
|
})]
|
|
3259
3507
|
}),
|
|
3260
|
-
e.consent && /* @__PURE__ */
|
|
3508
|
+
e.consent && /* @__PURE__ */ Q("div", {
|
|
3261
3509
|
className: "mt-4",
|
|
3262
|
-
children: [/* @__PURE__ */
|
|
3510
|
+
children: [/* @__PURE__ */ Q("label", {
|
|
3263
3511
|
className: "flex items-start gap-2 text-sm text-foreground cursor-pointer select-none",
|
|
3264
|
-
children: [/* @__PURE__ */
|
|
3512
|
+
children: [/* @__PURE__ */ Z("input", {
|
|
3265
3513
|
type: "checkbox",
|
|
3266
|
-
id:
|
|
3514
|
+
id: I,
|
|
3267
3515
|
checked: h,
|
|
3268
3516
|
onChange: (e) => {
|
|
3269
3517
|
g(e.target.checked), e.target.checked && v(null);
|
|
3270
3518
|
},
|
|
3271
|
-
"aria-required":
|
|
3519
|
+
"aria-required": F || void 0,
|
|
3272
3520
|
"aria-invalid": _ ? "true" : void 0,
|
|
3273
|
-
"aria-describedby": _ ? `${
|
|
3521
|
+
"aria-describedby": _ ? `${I}-error` : void 0,
|
|
3274
3522
|
className: "mt-0.5 h-4 w-4 rounded border-input accent-primary"
|
|
3275
|
-
}), /* @__PURE__ */
|
|
3523
|
+
}), /* @__PURE__ */ Q("span", {
|
|
3276
3524
|
className: "leading-relaxed",
|
|
3277
3525
|
children: [
|
|
3278
|
-
e.consent.label ??
|
|
3279
|
-
|
|
3526
|
+
e.consent.label ?? P.consentLabelDefault ?? "I agree to the privacy policy.",
|
|
3527
|
+
F && /* @__PURE__ */ Z("span", {
|
|
3280
3528
|
"aria-hidden": "true",
|
|
3281
3529
|
className: "text-destructive ml-0.5",
|
|
3282
3530
|
children: "*"
|
|
3283
3531
|
}),
|
|
3284
|
-
e.consent.privacyUrl && /* @__PURE__ */
|
|
3532
|
+
e.consent.privacyUrl && /* @__PURE__ */ Q(De, { children: [" ", /* @__PURE__ */ Z("a", {
|
|
3285
3533
|
href: e.consent.privacyUrl,
|
|
3286
3534
|
target: "_blank",
|
|
3287
3535
|
rel: "noopener noreferrer",
|
|
3288
3536
|
className: "underline text-primary hover:opacity-80",
|
|
3289
|
-
children:
|
|
3537
|
+
children: P.consentLink ?? "Privacy policy"
|
|
3290
3538
|
})] })
|
|
3291
3539
|
]
|
|
3292
3540
|
})]
|
|
3293
|
-
}), _ && /* @__PURE__ */
|
|
3294
|
-
id: `${
|
|
3541
|
+
}), _ && /* @__PURE__ */ Z("p", {
|
|
3542
|
+
id: `${I}-error`,
|
|
3295
3543
|
role: "alert",
|
|
3296
3544
|
className: "mt-1.5 text-xs text-destructive",
|
|
3297
3545
|
children: _
|
|
3298
3546
|
})]
|
|
3299
3547
|
}),
|
|
3300
|
-
d && /* @__PURE__ */
|
|
3548
|
+
d && /* @__PURE__ */ Q("div", {
|
|
3301
3549
|
className: "mt-3 flex items-center gap-2 text-xs text-muted-foreground",
|
|
3302
|
-
children: [/* @__PURE__ */
|
|
3550
|
+
children: [/* @__PURE__ */ Z(Ce, {
|
|
3303
3551
|
className: "h-3.5 w-3.5 animate-spin",
|
|
3304
3552
|
"aria-hidden": "true"
|
|
3305
|
-
}), /* @__PURE__ */
|
|
3553
|
+
}), /* @__PURE__ */ Z("span", { children: P.submitting ?? "Submitting…" })]
|
|
3306
3554
|
})
|
|
3307
3555
|
]
|
|
3308
3556
|
}),
|
|
3309
|
-
/* @__PURE__ */
|
|
3557
|
+
/* @__PURE__ */ Q("div", {
|
|
3310
3558
|
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
|
-
children: [/* @__PURE__ */
|
|
3559
|
+
children: [/* @__PURE__ */ Q("p", {
|
|
3312
3560
|
className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground",
|
|
3313
|
-
children: [/* @__PURE__ */
|
|
3561
|
+
children: [/* @__PURE__ */ Z(we, {
|
|
3314
3562
|
className: "h-3 w-3",
|
|
3315
3563
|
"aria-hidden": "true"
|
|
3316
|
-
}), /* @__PURE__ */
|
|
3317
|
-
}), /* @__PURE__ */
|
|
3564
|
+
}), /* @__PURE__ */ Z("span", { children: P.secureNotice ?? "Your information is transmitted securely and only used to respond to your request." })]
|
|
3565
|
+
}), /* @__PURE__ */ Q("div", {
|
|
3318
3566
|
className: "flex items-center gap-3 text-xs text-muted-foreground/80",
|
|
3319
|
-
children: [e.privacyPolicyUrl && /* @__PURE__ */
|
|
3567
|
+
children: [e.privacyPolicyUrl && /* @__PURE__ */ Q("a", {
|
|
3320
3568
|
href: e.privacyPolicyUrl,
|
|
3321
3569
|
target: "_blank",
|
|
3322
3570
|
rel: "noopener noreferrer",
|
|
3323
3571
|
className: "inline-flex items-center gap-1 underline hover:text-foreground",
|
|
3324
|
-
children: [/* @__PURE__ */
|
|
3572
|
+
children: [/* @__PURE__ */ Z(Te, {
|
|
3325
3573
|
className: "h-3 w-3",
|
|
3326
3574
|
"aria-hidden": "true"
|
|
3327
|
-
}),
|
|
3328
|
-
}), /* @__PURE__ */
|
|
3575
|
+
}), P.consentLink ?? "Privacy policy"]
|
|
3576
|
+
}), /* @__PURE__ */ Z("span", { children: P.poweredBy ?? "Powered by ObjectStack" })]
|
|
3329
3577
|
})]
|
|
3330
3578
|
})
|
|
3331
3579
|
]
|
|
@@ -3334,96 +3582,96 @@ var Yt = ({ config: e, dataSource: t, prefillParams: r, className: a }) => {
|
|
|
3334
3582
|
};
|
|
3335
3583
|
//#endregion
|
|
3336
3584
|
//#region src/FormAnalytics.tsx
|
|
3337
|
-
function
|
|
3585
|
+
function kn(e) {
|
|
3338
3586
|
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
3587
|
}
|
|
3340
|
-
var
|
|
3588
|
+
var An = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
3341
3589
|
let i = o(() => {
|
|
3342
3590
|
if (!n.abandonedSubmissions) return 100;
|
|
3343
3591
|
let e = n.totalSubmissions + n.abandonedSubmissions;
|
|
3344
3592
|
return e === 0 ? 0 : Math.round(n.totalSubmissions / e * 100);
|
|
3345
3593
|
}, [n.totalSubmissions, n.abandonedSubmissions]), a = o(() => n.dailySubmissions?.length ? Math.max(...n.dailySubmissions.map((e) => e.count), 1) : 1, [n.dailySubmissions]);
|
|
3346
|
-
return /* @__PURE__ */
|
|
3594
|
+
return /* @__PURE__ */ Q("div", {
|
|
3347
3595
|
className: `space-y-4 ${r || ""}`,
|
|
3348
3596
|
children: [
|
|
3349
|
-
/* @__PURE__ */
|
|
3597
|
+
/* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z("h2", {
|
|
3350
3598
|
className: "text-lg font-semibold text-foreground",
|
|
3351
3599
|
children: t || "Form Analytics"
|
|
3352
|
-
}), /* @__PURE__ */
|
|
3600
|
+
}), /* @__PURE__ */ Q("p", {
|
|
3353
3601
|
className: "text-sm text-muted-foreground",
|
|
3354
3602
|
children: ["Form ID: ", e]
|
|
3355
3603
|
})] }),
|
|
3356
|
-
/* @__PURE__ */
|
|
3604
|
+
/* @__PURE__ */ Q("div", {
|
|
3357
3605
|
className: "grid grid-cols-1 sm:grid-cols-3 gap-4",
|
|
3358
3606
|
children: [
|
|
3359
|
-
/* @__PURE__ */
|
|
3607
|
+
/* @__PURE__ */ Z(z, { children: /* @__PURE__ */ Q(H, {
|
|
3360
3608
|
className: "pb-2",
|
|
3361
|
-
children: [/* @__PURE__ */
|
|
3609
|
+
children: [/* @__PURE__ */ Z(V, { children: "Total Submissions" }), /* @__PURE__ */ Z(U, {
|
|
3362
3610
|
className: "text-2xl",
|
|
3363
3611
|
children: n.totalSubmissions.toLocaleString()
|
|
3364
3612
|
})]
|
|
3365
3613
|
}) }),
|
|
3366
|
-
/* @__PURE__ */
|
|
3614
|
+
/* @__PURE__ */ Q(z, { children: [/* @__PURE__ */ Q(H, {
|
|
3367
3615
|
className: "pb-2",
|
|
3368
|
-
children: [/* @__PURE__ */
|
|
3616
|
+
children: [/* @__PURE__ */ Z(V, { children: "Fill Rate" }), /* @__PURE__ */ Q(U, {
|
|
3369
3617
|
className: "text-2xl",
|
|
3370
3618
|
children: [i, "%"]
|
|
3371
3619
|
})]
|
|
3372
|
-
}), /* @__PURE__ */
|
|
3620
|
+
}), /* @__PURE__ */ Z(B, { children: /* @__PURE__ */ Z("div", {
|
|
3373
3621
|
className: "w-full bg-muted rounded-full h-2",
|
|
3374
|
-
children: /* @__PURE__ */
|
|
3622
|
+
children: /* @__PURE__ */ Z("div", {
|
|
3375
3623
|
className: "bg-primary rounded-full h-2 transition-all",
|
|
3376
3624
|
style: { width: `${i}%` }
|
|
3377
3625
|
})
|
|
3378
3626
|
}) })] }),
|
|
3379
|
-
/* @__PURE__ */
|
|
3627
|
+
/* @__PURE__ */ Z(z, { children: /* @__PURE__ */ Q(H, {
|
|
3380
3628
|
className: "pb-2",
|
|
3381
|
-
children: [/* @__PURE__ */
|
|
3629
|
+
children: [/* @__PURE__ */ Z(V, { children: "Avg. Completion Time" }), /* @__PURE__ */ Z(U, {
|
|
3382
3630
|
className: "text-2xl",
|
|
3383
|
-
children: n.avgCompletionTime ?
|
|
3631
|
+
children: n.avgCompletionTime ? kn(n.avgCompletionTime) : "—"
|
|
3384
3632
|
})]
|
|
3385
3633
|
}) })
|
|
3386
3634
|
]
|
|
3387
3635
|
}),
|
|
3388
|
-
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */
|
|
3636
|
+
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ Q(z, { children: [/* @__PURE__ */ Z(H, { children: /* @__PURE__ */ Z(U, {
|
|
3389
3637
|
className: "text-sm font-medium",
|
|
3390
3638
|
children: "Daily Submissions"
|
|
3391
|
-
}) }), /* @__PURE__ */
|
|
3639
|
+
}) }), /* @__PURE__ */ Z(B, { children: /* @__PURE__ */ Z("div", {
|
|
3392
3640
|
className: "flex items-end gap-1 h-32",
|
|
3393
|
-
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */
|
|
3641
|
+
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ Q("div", {
|
|
3394
3642
|
className: "flex-1 flex flex-col items-center gap-1",
|
|
3395
|
-
children: [/* @__PURE__ */
|
|
3643
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
3396
3644
|
className: "w-full bg-primary/80 rounded-t transition-all hover:bg-primary",
|
|
3397
3645
|
style: {
|
|
3398
3646
|
height: `${e.count / a * 100}%`,
|
|
3399
3647
|
minHeight: e.count > 0 ? "4px" : "0"
|
|
3400
3648
|
},
|
|
3401
3649
|
title: `${e.date}: ${e.count} submissions`
|
|
3402
|
-
}), /* @__PURE__ */
|
|
3650
|
+
}), /* @__PURE__ */ Z("span", {
|
|
3403
3651
|
className: "text-[10px] text-muted-foreground truncate w-full text-center",
|
|
3404
3652
|
children: e.date.slice(-5)
|
|
3405
3653
|
})]
|
|
3406
3654
|
}, t))
|
|
3407
3655
|
}) })] }),
|
|
3408
|
-
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */
|
|
3656
|
+
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ Q(z, { children: [/* @__PURE__ */ Q(H, { children: [/* @__PURE__ */ Z(U, {
|
|
3409
3657
|
className: "text-sm font-medium",
|
|
3410
3658
|
children: "Field Completion Rates"
|
|
3411
|
-
}), /* @__PURE__ */
|
|
3659
|
+
}), /* @__PURE__ */ Z(V, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ Z(B, { children: /* @__PURE__ */ Z("div", {
|
|
3412
3660
|
className: "space-y-3",
|
|
3413
|
-
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */
|
|
3661
|
+
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ Q("div", {
|
|
3414
3662
|
className: "space-y-1",
|
|
3415
|
-
children: [/* @__PURE__ */
|
|
3663
|
+
children: [/* @__PURE__ */ Q("div", {
|
|
3416
3664
|
className: "flex justify-between text-sm",
|
|
3417
|
-
children: [/* @__PURE__ */
|
|
3665
|
+
children: [/* @__PURE__ */ Z("span", {
|
|
3418
3666
|
className: "text-foreground",
|
|
3419
3667
|
children: e.label
|
|
3420
|
-
}), /* @__PURE__ */
|
|
3668
|
+
}), /* @__PURE__ */ Q("span", {
|
|
3421
3669
|
className: "text-muted-foreground",
|
|
3422
3670
|
children: [e.completionRate, "%"]
|
|
3423
3671
|
})]
|
|
3424
|
-
}), /* @__PURE__ */
|
|
3672
|
+
}), /* @__PURE__ */ Z("div", {
|
|
3425
3673
|
className: "w-full bg-muted rounded-full h-1.5",
|
|
3426
|
-
children: /* @__PURE__ */
|
|
3674
|
+
children: /* @__PURE__ */ Z("div", {
|
|
3427
3675
|
className: `rounded-full h-1.5 transition-all ${e.completionRate >= 80 ? "bg-green-500" : e.completionRate >= 50 ? "bg-yellow-500" : "bg-destructive"}`,
|
|
3428
3676
|
style: { width: `${e.completionRate}%` }
|
|
3429
3677
|
})
|
|
@@ -3432,76 +3680,80 @@ var Zt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3432
3680
|
}) })] })
|
|
3433
3681
|
]
|
|
3434
3682
|
});
|
|
3435
|
-
},
|
|
3436
|
-
let t =
|
|
3683
|
+
}, jn = ({ schema: e }) => {
|
|
3684
|
+
let t = k()?.dataSource, r = E(), a = e.parentObject || r?.objectName, s = e.parentId || e.recordId || r?.recordId, [l, d] = c([]), [f, p] = c([]), [m, g] = c(!0), [_, b] = c(!1), [x, S] = c(!1), [C, w] = c(null), [T, D] = c(null);
|
|
3437
3685
|
i(() => {
|
|
3438
3686
|
let n = t;
|
|
3439
3687
|
if (!n || typeof n.getObjectSchema != "function") return;
|
|
3440
3688
|
let r = !1;
|
|
3441
3689
|
return n.getObjectSchema(e.childObject).then((e) => {
|
|
3442
|
-
r ||
|
|
3690
|
+
r || D(e ?? null);
|
|
3443
3691
|
}).catch(() => {
|
|
3444
|
-
r ||
|
|
3692
|
+
r || D(null);
|
|
3445
3693
|
}), () => {
|
|
3446
3694
|
r = !0;
|
|
3447
3695
|
};
|
|
3448
3696
|
}, [t, e.childObject]);
|
|
3449
|
-
let
|
|
3697
|
+
let O = JSON.stringify(e.filter ?? null), j = JSON.stringify(e.sort ?? null), M = o(() => y(e.filter), [O]), N = o(() => u(e.sort), [j]), P = n(async () => {
|
|
3450
3698
|
if (!t || !s) {
|
|
3451
|
-
|
|
3699
|
+
g(!1);
|
|
3452
3700
|
return;
|
|
3453
3701
|
}
|
|
3454
|
-
|
|
3702
|
+
g(!0);
|
|
3455
3703
|
try {
|
|
3456
|
-
let n = (await t.find(e.childObject, {
|
|
3457
|
-
$filter:
|
|
3458
|
-
$
|
|
3704
|
+
let n = { [e.relationshipField]: s }, r = (await t.find(e.childObject, {
|
|
3705
|
+
$filter: M === void 0 ? n : h(n, M),
|
|
3706
|
+
...N ? { $orderby: N } : {},
|
|
3707
|
+
$top: e.limit ?? 500
|
|
3459
3708
|
}))?.data ?? [];
|
|
3460
|
-
|
|
3709
|
+
d(r.map((e) => ({ ...e }))), p(r.map((e) => ({ ...e }))), S(!1);
|
|
3461
3710
|
} catch (e) {
|
|
3462
3711
|
w(e?.message || "Failed to load line items");
|
|
3463
3712
|
} finally {
|
|
3464
|
-
|
|
3713
|
+
g(!1);
|
|
3465
3714
|
}
|
|
3466
3715
|
}, [
|
|
3467
3716
|
t,
|
|
3468
3717
|
s,
|
|
3469
3718
|
e.childObject,
|
|
3470
|
-
e.relationshipField
|
|
3719
|
+
e.relationshipField,
|
|
3720
|
+
e.limit,
|
|
3721
|
+
M,
|
|
3722
|
+
N
|
|
3471
3723
|
]);
|
|
3472
3724
|
i(() => {
|
|
3473
|
-
|
|
3474
|
-
}, [
|
|
3475
|
-
let
|
|
3476
|
-
|
|
3477
|
-
}, []),
|
|
3725
|
+
P();
|
|
3726
|
+
}, [P]);
|
|
3727
|
+
let F = n((e) => {
|
|
3728
|
+
d(e), S(!0);
|
|
3729
|
+
}, []), I = n(async () => {
|
|
3478
3730
|
if (!(!t || !s)) {
|
|
3479
|
-
|
|
3731
|
+
b(!0), w(null);
|
|
3480
3732
|
try {
|
|
3481
|
-
let n = !!(a && e.totalField), r = n ? { [e.totalField]:
|
|
3733
|
+
let n = !!(a && e.totalField), r = n ? { [e.totalField]: It(l, e.amountField || "amount") } : {}, i = Pt(a ?? "", s, r, [{
|
|
3482
3734
|
childObject: e.childObject,
|
|
3483
3735
|
relationshipField: e.relationshipField,
|
|
3484
3736
|
rows: l,
|
|
3485
|
-
original:
|
|
3737
|
+
original: f,
|
|
3486
3738
|
childSchema: T
|
|
3487
3739
|
}]);
|
|
3488
|
-
n || (i = i.slice(1)), i.length && await
|
|
3740
|
+
n || (i = i.slice(1)), i.length && await v(t, i), await P();
|
|
3489
3741
|
} catch (e) {
|
|
3490
3742
|
w(e?.message || "Failed to save line items");
|
|
3491
3743
|
} finally {
|
|
3492
|
-
|
|
3744
|
+
b(!1);
|
|
3493
3745
|
}
|
|
3494
3746
|
}
|
|
3495
3747
|
}, [
|
|
3496
3748
|
t,
|
|
3497
3749
|
s,
|
|
3498
3750
|
l,
|
|
3499
|
-
|
|
3751
|
+
f,
|
|
3500
3752
|
e,
|
|
3501
3753
|
a,
|
|
3502
|
-
|
|
3754
|
+
P,
|
|
3503
3755
|
T
|
|
3504
|
-
]),
|
|
3756
|
+
]), ee = o(() => ({
|
|
3505
3757
|
columns: e.columns,
|
|
3506
3758
|
total_field: e.totalField ? e.amountField || "amount" : void 0,
|
|
3507
3759
|
min_rows: e.minRows,
|
|
@@ -3509,44 +3761,52 @@ var Zt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3509
3761
|
allow_add: !e.readonly,
|
|
3510
3762
|
allow_delete: !e.readonly
|
|
3511
3763
|
}), [e]);
|
|
3512
|
-
return /* @__PURE__ */
|
|
3513
|
-
className:
|
|
3514
|
-
children: [/* @__PURE__ */
|
|
3764
|
+
return /* @__PURE__ */ Q(z, {
|
|
3765
|
+
className: Y("shadow-none"),
|
|
3766
|
+
children: [/* @__PURE__ */ Q(H, {
|
|
3515
3767
|
className: "flex-row items-center justify-between gap-2 pb-2",
|
|
3516
|
-
children: [/* @__PURE__ */
|
|
3768
|
+
children: [/* @__PURE__ */ Z(U, {
|
|
3517
3769
|
className: "text-sm font-medium",
|
|
3518
3770
|
children: e.title || "Line Items"
|
|
3519
|
-
}), !e.readonly && /* @__PURE__ */
|
|
3771
|
+
}), !e.readonly && /* @__PURE__ */ Z(R, {
|
|
3520
3772
|
type: "button",
|
|
3521
3773
|
size: "sm",
|
|
3522
|
-
onClick:
|
|
3523
|
-
disabled:
|
|
3524
|
-
children:
|
|
3774
|
+
onClick: I,
|
|
3775
|
+
disabled: _ || m || !x || !s,
|
|
3776
|
+
children: _ ? "Saving…" : "Save"
|
|
3525
3777
|
})]
|
|
3526
|
-
}), /* @__PURE__ */
|
|
3778
|
+
}), /* @__PURE__ */ Q(B, { children: [C && /* @__PURE__ */ Z("p", {
|
|
3527
3779
|
className: "mb-2 text-sm text-destructive",
|
|
3528
3780
|
children: C
|
|
3529
|
-
}),
|
|
3781
|
+
}), m ? /* @__PURE__ */ Z("p", {
|
|
3530
3782
|
className: "py-6 text-center text-sm text-muted-foreground",
|
|
3531
3783
|
children: "Loading…"
|
|
3532
|
-
}) : s ? /* @__PURE__ */
|
|
3784
|
+
}) : s ? /* @__PURE__ */ Z(A, {
|
|
3533
3785
|
value: l,
|
|
3534
|
-
onChange:
|
|
3535
|
-
field:
|
|
3786
|
+
onChange: F,
|
|
3787
|
+
field: ee,
|
|
3536
3788
|
readonly: e.readonly
|
|
3537
|
-
}) : /* @__PURE__ */
|
|
3789
|
+
}) : /* @__PURE__ */ Z("p", {
|
|
3538
3790
|
className: "py-6 text-center text-sm text-muted-foreground",
|
|
3539
3791
|
children: "Save the record first to add line items."
|
|
3540
3792
|
})] })]
|
|
3541
3793
|
});
|
|
3542
|
-
},
|
|
3543
|
-
let
|
|
3544
|
-
return /* @__PURE__ */
|
|
3794
|
+
}, Mn = ({ schema: e, dataSource: t }) => {
|
|
3795
|
+
let n = D(t);
|
|
3796
|
+
return /* @__PURE__ */ Z(b, {
|
|
3545
3797
|
schema: e,
|
|
3546
|
-
dataSource:
|
|
3798
|
+
dataSource: n,
|
|
3799
|
+
testId: "object-form",
|
|
3800
|
+
errorTitle: "This form’s data source could not be resolved",
|
|
3801
|
+
requiresDataSource: !(e?.customFields?.length > 0) && typeof e?.objectName == "string" && e.objectName.length > 0,
|
|
3802
|
+
noDataSourceMessage: C("object-form", e?.objectName),
|
|
3803
|
+
children: (e) => /* @__PURE__ */ Z(vn, {
|
|
3804
|
+
schema: e,
|
|
3805
|
+
dataSource: n
|
|
3806
|
+
})
|
|
3547
3807
|
});
|
|
3548
3808
|
};
|
|
3549
|
-
l.register("object-form",
|
|
3809
|
+
l.register("object-form", Mn, {
|
|
3550
3810
|
namespace: "plugin-form",
|
|
3551
3811
|
label: "Object Form",
|
|
3552
3812
|
category: "plugin",
|
|
@@ -3685,9 +3945,125 @@ l.register("object-form", $t, {
|
|
|
3685
3945
|
"xl",
|
|
3686
3946
|
"full"
|
|
3687
3947
|
]
|
|
3948
|
+
},
|
|
3949
|
+
{
|
|
3950
|
+
name: "modalCloseButton",
|
|
3951
|
+
type: "boolean",
|
|
3952
|
+
label: "Modal Close Button",
|
|
3953
|
+
description: "Show the modal presentation’s close button. Read at ObjectForm.tsx:361 and honoured by ModalForm."
|
|
3954
|
+
},
|
|
3955
|
+
{
|
|
3956
|
+
name: "contentLayout",
|
|
3957
|
+
type: "enum",
|
|
3958
|
+
label: "Modal Content Layout",
|
|
3959
|
+
enum: ["simple", "tabbed"],
|
|
3960
|
+
description: "How the modal presentation lays out sections. `tabbed` needs more than one section to differ from `simple` (ModalForm.tsx:638)."
|
|
3961
|
+
},
|
|
3962
|
+
{
|
|
3963
|
+
name: "confirmOnDiscard",
|
|
3964
|
+
type: "boolean",
|
|
3965
|
+
label: "Confirm On Discard",
|
|
3966
|
+
description: "Ask before discarding unsaved edits when a drawer/modal form is dismissed. Set `false` to close immediately."
|
|
3967
|
+
},
|
|
3968
|
+
{
|
|
3969
|
+
name: "recordId",
|
|
3970
|
+
type: "string",
|
|
3971
|
+
label: "Record Id",
|
|
3972
|
+
description: "The record to load in `edit` / `view` mode. Leave unset for `create`."
|
|
3973
|
+
},
|
|
3974
|
+
{
|
|
3975
|
+
name: "customFields",
|
|
3976
|
+
type: "array",
|
|
3977
|
+
label: "Custom Fields",
|
|
3978
|
+
description: "Field definitions merged over the set generated from object metadata. With inline definitions and no data source, this becomes the only field source."
|
|
3979
|
+
},
|
|
3980
|
+
{
|
|
3981
|
+
name: "initialValues",
|
|
3982
|
+
type: "object",
|
|
3983
|
+
label: "Initial Values",
|
|
3984
|
+
description: "Values to prefill in `create` mode."
|
|
3985
|
+
},
|
|
3986
|
+
{
|
|
3987
|
+
name: "initialData",
|
|
3988
|
+
type: "object",
|
|
3989
|
+
label: "Initial Data",
|
|
3990
|
+
description: "Alternate spelling of `initialValues` that the drawer/modal presentations read FIRST (`schema.initialData || schema.initialValues`). Prefer `initialValues` in new schemas."
|
|
3991
|
+
},
|
|
3992
|
+
{
|
|
3993
|
+
name: "readOnly",
|
|
3994
|
+
type: "boolean",
|
|
3995
|
+
label: "Read Only",
|
|
3996
|
+
description: "Render every field read-only, whatever `mode` says."
|
|
3997
|
+
},
|
|
3998
|
+
{
|
|
3999
|
+
name: "submitText",
|
|
4000
|
+
type: "string",
|
|
4001
|
+
label: "Submit Button Text"
|
|
4002
|
+
},
|
|
4003
|
+
{
|
|
4004
|
+
name: "cancelText",
|
|
4005
|
+
type: "string",
|
|
4006
|
+
label: "Cancel Button Text"
|
|
4007
|
+
},
|
|
4008
|
+
{
|
|
4009
|
+
name: "nextText",
|
|
4010
|
+
type: "string",
|
|
4011
|
+
label: "Next Button Text",
|
|
4012
|
+
description: "Label of the next-step button (wizard)."
|
|
4013
|
+
},
|
|
4014
|
+
{
|
|
4015
|
+
name: "prevText",
|
|
4016
|
+
type: "string",
|
|
4017
|
+
label: "Previous Button Text",
|
|
4018
|
+
description: "Label of the previous-step button (wizard)."
|
|
4019
|
+
},
|
|
4020
|
+
{
|
|
4021
|
+
name: "showSubmit",
|
|
4022
|
+
type: "boolean",
|
|
4023
|
+
label: "Show Submit Button"
|
|
4024
|
+
},
|
|
4025
|
+
{
|
|
4026
|
+
name: "showCancel",
|
|
4027
|
+
type: "boolean",
|
|
4028
|
+
label: "Show Cancel Button"
|
|
4029
|
+
},
|
|
4030
|
+
{
|
|
4031
|
+
name: "showReset",
|
|
4032
|
+
type: "boolean",
|
|
4033
|
+
label: "Show Reset Button"
|
|
4034
|
+
},
|
|
4035
|
+
{
|
|
4036
|
+
name: "submitBehavior",
|
|
4037
|
+
type: "object",
|
|
4038
|
+
label: "Submit Behavior",
|
|
4039
|
+
description: "Declarative post-submit behaviour, one of `{ kind: \"thank-you\", title?, message? }`, `{ kind: \"redirect\", url, delayMs? }`, `{ kind: \"continue\" }`, `{ kind: \"next-record\" }`. When present it takes precedence over `successMessage` / `navigateOnSuccess` / `resetOnSuccess`."
|
|
4040
|
+
},
|
|
4041
|
+
{
|
|
4042
|
+
name: "successMessage",
|
|
4043
|
+
type: "string",
|
|
4044
|
+
label: "Success Message",
|
|
4045
|
+
description: "Toast shown after a successful submit. Ignored when `submitBehavior` or `navigateOnSuccess` is set."
|
|
4046
|
+
},
|
|
4047
|
+
{
|
|
4048
|
+
name: "navigateOnSuccess",
|
|
4049
|
+
type: "string",
|
|
4050
|
+
label: "Navigate On Success",
|
|
4051
|
+
description: "Path to navigate to after a successful create/update. Supports `{id}` / `{recordId}` interpolation from the saved record and is same-origin-guarded. Takes precedence over `successMessage`."
|
|
4052
|
+
},
|
|
4053
|
+
{
|
|
4054
|
+
name: "resetOnSuccess",
|
|
4055
|
+
type: "boolean",
|
|
4056
|
+
label: "Reset On Success",
|
|
4057
|
+
description: "Clear the form after a successful submit instead of keeping the saved values."
|
|
4058
|
+
},
|
|
4059
|
+
{
|
|
4060
|
+
name: "mobile",
|
|
4061
|
+
type: "object",
|
|
4062
|
+
label: "Mobile Overrides",
|
|
4063
|
+
description: "Phone-only presentation overrides, e.g. `{ stepper: \"auto\", stepperMinFields: 8, fullscreenLongText: true }`."
|
|
3688
4064
|
}
|
|
3689
4065
|
]
|
|
3690
|
-
}), l.register("form",
|
|
4066
|
+
}), l.register("form", Mn, {
|
|
3691
4067
|
namespace: "view",
|
|
3692
4068
|
skipFallback: !0,
|
|
3693
4069
|
label: "Data Form View",
|
|
@@ -3716,10 +4092,16 @@ l.register("object-form", $t, {
|
|
|
3716
4092
|
}
|
|
3717
4093
|
]
|
|
3718
4094
|
}), l.register("embeddable-form", ({ schema: e }) => {
|
|
3719
|
-
let t = r(
|
|
3720
|
-
return /* @__PURE__ */
|
|
3721
|
-
|
|
3722
|
-
dataSource: t?.dataSource
|
|
4095
|
+
let t = r(S);
|
|
4096
|
+
return /* @__PURE__ */ Z(b, {
|
|
4097
|
+
schema: e,
|
|
4098
|
+
dataSource: t?.dataSource,
|
|
4099
|
+
testId: "embeddable-form",
|
|
4100
|
+
errorTitle: "This form’s data source could not be resolved",
|
|
4101
|
+
children: (e) => /* @__PURE__ */ Z(On, {
|
|
4102
|
+
config: e,
|
|
4103
|
+
dataSource: t?.dataSource
|
|
4104
|
+
})
|
|
3723
4105
|
});
|
|
3724
4106
|
}, {
|
|
3725
4107
|
namespace: "plugin-form",
|
|
@@ -3759,7 +4141,7 @@ l.register("object-form", $t, {
|
|
|
3759
4141
|
label: "Allow Multiple Submissions"
|
|
3760
4142
|
}
|
|
3761
4143
|
]
|
|
3762
|
-
}), l.register("form-analytics", ({ schema: e }) => /* @__PURE__ */
|
|
4144
|
+
}), l.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ Z(An, {
|
|
3763
4145
|
formId: e.formId,
|
|
3764
4146
|
formTitle: e.formTitle,
|
|
3765
4147
|
metrics: e.metrics || { totalSubmissions: 0 }
|
|
@@ -3786,10 +4168,16 @@ l.register("object-form", $t, {
|
|
|
3786
4168
|
}
|
|
3787
4169
|
]
|
|
3788
4170
|
}), l.register("object-master-detail-form", ({ schema: e }) => {
|
|
3789
|
-
let t = r(
|
|
3790
|
-
return /* @__PURE__ */
|
|
4171
|
+
let t = r(S)?.dataSource ?? void 0;
|
|
4172
|
+
return /* @__PURE__ */ Z(b, {
|
|
3791
4173
|
schema: e,
|
|
3792
|
-
dataSource: t
|
|
4174
|
+
dataSource: t,
|
|
4175
|
+
testId: "object-master-detail-form",
|
|
4176
|
+
errorTitle: "This form’s data source could not be resolved",
|
|
4177
|
+
children: (e) => /* @__PURE__ */ Z(cn, {
|
|
4178
|
+
schema: e,
|
|
4179
|
+
dataSource: t
|
|
4180
|
+
})
|
|
3793
4181
|
});
|
|
3794
4182
|
}, {
|
|
3795
4183
|
namespace: "plugin-form",
|
|
@@ -3818,9 +4206,79 @@ l.register("object-form", $t, {
|
|
|
3818
4206
|
type: "array",
|
|
3819
4207
|
label: "Detail Collections",
|
|
3820
4208
|
required: !0
|
|
4209
|
+
},
|
|
4210
|
+
{
|
|
4211
|
+
name: "recordId",
|
|
4212
|
+
type: "string",
|
|
4213
|
+
label: "Parent Record Id",
|
|
4214
|
+
description: "The parent record to load in `edit` mode. Leave unset for `create`."
|
|
4215
|
+
},
|
|
4216
|
+
{
|
|
4217
|
+
name: "formType",
|
|
4218
|
+
type: "string",
|
|
4219
|
+
label: "Parent Form Presentation",
|
|
4220
|
+
description: "How the PARENT half of the form is presented. The detail grids below it are unaffected."
|
|
4221
|
+
},
|
|
4222
|
+
{
|
|
4223
|
+
name: "fields",
|
|
4224
|
+
type: "array",
|
|
4225
|
+
label: "Parent Fields",
|
|
4226
|
+
description: "Which parent fields to show, in order. Ignored when `sections` is given — sections carry their own field lists."
|
|
4227
|
+
},
|
|
4228
|
+
{
|
|
4229
|
+
name: "title",
|
|
4230
|
+
type: "string",
|
|
4231
|
+
label: "Title"
|
|
4232
|
+
},
|
|
4233
|
+
{
|
|
4234
|
+
name: "submitText",
|
|
4235
|
+
type: "string",
|
|
4236
|
+
label: "Submit Button Text",
|
|
4237
|
+
description: "Label of the button that saves the parent and every detail row in one batch."
|
|
4238
|
+
},
|
|
4239
|
+
{
|
|
4240
|
+
name: "cancelText",
|
|
4241
|
+
type: "string",
|
|
4242
|
+
label: "Cancel Button Text"
|
|
4243
|
+
},
|
|
4244
|
+
{
|
|
4245
|
+
name: "showSubmit",
|
|
4246
|
+
type: "boolean",
|
|
4247
|
+
label: "Show Submit Button"
|
|
4248
|
+
},
|
|
4249
|
+
{
|
|
4250
|
+
name: "initialValues",
|
|
4251
|
+
type: "object",
|
|
4252
|
+
label: "Initial Values",
|
|
4253
|
+
description: "Values to prefill on the PARENT record in `create` mode."
|
|
4254
|
+
},
|
|
4255
|
+
{
|
|
4256
|
+
name: "initialData",
|
|
4257
|
+
type: "object",
|
|
4258
|
+
label: "Initial Data",
|
|
4259
|
+
description: "Alternate spelling of `initialValues` the renderer also reads (MasterDetailForm.tsx:602). Prefer `initialValues` in new schemas."
|
|
4260
|
+
},
|
|
4261
|
+
{
|
|
4262
|
+
name: "taxRateField",
|
|
4263
|
+
type: "string",
|
|
4264
|
+
label: "Tax Rate Field",
|
|
4265
|
+
description: "Name of the field ON THE CHILD object that holds each line’s tax rate. Feeds the line-items totals row; leave unset when the detail rows carry no tax."
|
|
3821
4266
|
}
|
|
3822
4267
|
]
|
|
3823
|
-
})
|
|
4268
|
+
});
|
|
4269
|
+
var Nn = {
|
|
4270
|
+
object: "childObject",
|
|
4271
|
+
filter: !0,
|
|
4272
|
+
sort: !0,
|
|
4273
|
+
limit: "limit"
|
|
4274
|
+
};
|
|
4275
|
+
l.register("line_items", ({ schema: e }) => /* @__PURE__ */ Z(b, {
|
|
4276
|
+
schema: e,
|
|
4277
|
+
mapping: Nn,
|
|
4278
|
+
testId: "record-line-items",
|
|
4279
|
+
errorTitle: "This line-items panel’s data source could not be resolved",
|
|
4280
|
+
children: (e) => /* @__PURE__ */ Z(jn, { schema: e })
|
|
4281
|
+
}), {
|
|
3824
4282
|
namespace: "record",
|
|
3825
4283
|
skipFallback: !0,
|
|
3826
4284
|
label: "Line Items",
|
|
@@ -3857,4 +4315,4 @@ l.register("object-form", $t, {
|
|
|
3857
4315
|
]
|
|
3858
4316
|
});
|
|
3859
4317
|
//#endregion
|
|
3860
|
-
export {
|
|
4318
|
+
export { pn as DrawerForm, On as EmbeddableForm, An as FormAnalytics, bt as FormSectionContainer, jn as LineItemsPanel, cn as MasterDetailForm, gn as ModalForm, vn as ObjectForm, Tt as SplitForm, yt as TabbedForm, wt as WizardForm, $ as applyAutoColSpan, pt as applyAutoLayout, dt as containerGridColsFor, Yt as deriveColumns, an as deriveDetail, Qt as deriveFormFields, lt as filterAutoGeneratedFields, ct as filterCreateModeFields, st as filterSystemFields, Wt as findRelationshipField, rt as inferColumns, ft as inferModalSize, nt as isAutoGeneratedFieldType, tt as isWideFieldType, tn as resolveInlineMode };
|