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