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