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