@object-ui/plugin-form 16.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 +108 -0
- package/dist/index.js +847 -929
- 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
|
-
}, [n]),
|
|
492
|
-
(n.allowSkip || b.has(e) || e <= v) &&
|
|
491
|
+
}, [n]), z = t((e) => {
|
|
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
|
-
let
|
|
530
|
-
return /* @__PURE__ */
|
|
529
|
+
let B = n.sections[v];
|
|
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
|
-
onClick: () =>
|
|
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:
|
|
569
|
-
label:
|
|
570
|
-
description:
|
|
568
|
+
children: B && /* @__PURE__ */ X($, {
|
|
569
|
+
label: B.label,
|
|
570
|
+
description: B.description,
|
|
571
571
|
columns: 1,
|
|
572
|
-
className:
|
|
573
|
-
gridClassName:
|
|
574
|
-
children: F.length > 0 ? /* @__PURE__ */
|
|
572
|
+
className: B.className,
|
|
573
|
+
gridClassName: B.gridClassName,
|
|
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
|
-
onClick:
|
|
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":
|
|
@@ -962,11 +925,11 @@ function at(e) {
|
|
|
962
925
|
default: return "text";
|
|
963
926
|
}
|
|
964
927
|
}
|
|
965
|
-
var
|
|
966
|
-
function
|
|
967
|
-
e.multiple == null && t?.multiple && (e.multiple = !0), e.accept ?? (Array.isArray(t?.accept) && t.accept.length > 0 ? e.accept = t.accept :
|
|
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/*"]));
|
|
968
931
|
}
|
|
969
|
-
function
|
|
932
|
+
function st(e) {
|
|
970
933
|
if (e?.type === "boolean" || e?.type === "toggle") return [{
|
|
971
934
|
label: "Yes",
|
|
972
935
|
value: "true"
|
|
@@ -983,7 +946,7 @@ function ct(e) {
|
|
|
983
946
|
value: String(e)
|
|
984
947
|
});
|
|
985
948
|
}
|
|
986
|
-
function
|
|
949
|
+
function ct(e, t) {
|
|
987
950
|
let n = e?.fields;
|
|
988
951
|
if (!n || typeof n != "object") return;
|
|
989
952
|
let r;
|
|
@@ -996,7 +959,7 @@ function lt(e, t) {
|
|
|
996
959
|
}
|
|
997
960
|
return r;
|
|
998
961
|
}
|
|
999
|
-
var
|
|
962
|
+
var lt = [
|
|
1000
963
|
"name",
|
|
1001
964
|
"title",
|
|
1002
965
|
"subject",
|
|
@@ -1004,7 +967,7 @@ var ut = [
|
|
|
1004
967
|
"full_name",
|
|
1005
968
|
"display_name",
|
|
1006
969
|
"code"
|
|
1007
|
-
],
|
|
970
|
+
], ut = {
|
|
1008
971
|
select: 0,
|
|
1009
972
|
currency: 1,
|
|
1010
973
|
number: 1,
|
|
@@ -1012,15 +975,15 @@ var ut = [
|
|
|
1012
975
|
date: 3,
|
|
1013
976
|
text: 4
|
|
1014
977
|
};
|
|
1015
|
-
function
|
|
978
|
+
function dt(e, t) {
|
|
1016
979
|
if (t <= 0 || e.length <= t) return e;
|
|
1017
|
-
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];
|
|
1018
981
|
r && n.add(r.field);
|
|
1019
982
|
for (let t of e) t.required && n.add(t.field);
|
|
1020
983
|
let i = e.map((e, t) => ({
|
|
1021
984
|
c: e,
|
|
1022
985
|
i: t
|
|
1023
|
-
})).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);
|
|
1024
987
|
for (let { c: e } of i) {
|
|
1025
988
|
if (n.size >= t) break;
|
|
1026
989
|
n.add(e.field);
|
|
@@ -1030,60 +993,60 @@ function ft(e, t) {
|
|
|
1030
993
|
defaultHidden: !0
|
|
1031
994
|
});
|
|
1032
995
|
}
|
|
1033
|
-
function
|
|
996
|
+
function ft(e, t = {}) {
|
|
1034
997
|
let n = e?.fields;
|
|
1035
998
|
if (!n || typeof n != "object") return [];
|
|
1036
999
|
let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
|
|
1037
1000
|
for (let [e, t] of Object.entries(n)) {
|
|
1038
1001
|
let n = t;
|
|
1039
|
-
if (
|
|
1002
|
+
if (tt.has(e) || r.has(e) || nt.has(e) || n?.system || n?.readonly || n?.hidden || rt.has(n?.type)) continue;
|
|
1040
1003
|
let a = {
|
|
1041
1004
|
field: e,
|
|
1042
1005
|
label: n?.label || e,
|
|
1043
|
-
type:
|
|
1006
|
+
type: it(n?.type),
|
|
1044
1007
|
required: !!n?.required
|
|
1045
|
-
}, o =
|
|
1046
|
-
a.type === "select" && o && (a.options = o), a.type === "lookup" && (a.reference = n?.reference, a.displayField = n?.display_field || n?.reference_field), a.type === "file" &&
|
|
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);
|
|
1047
1010
|
let s = typeof n?.expression == "string" ? n.expression : n?.expression?.source;
|
|
1048
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);
|
|
1049
1012
|
}
|
|
1050
|
-
return
|
|
1013
|
+
return dt(i, t.maxColumns ?? 6);
|
|
1051
1014
|
}
|
|
1052
|
-
function
|
|
1015
|
+
function pt(e, t) {
|
|
1053
1016
|
let n = e ?? [], r = t?.fields;
|
|
1054
1017
|
return !n.length || !r || typeof r != "object" ? n : n.map((e) => {
|
|
1055
1018
|
if (e.type) return e;
|
|
1056
1019
|
let t = r[e.field];
|
|
1057
1020
|
if (!t) return e;
|
|
1058
|
-
let n =
|
|
1021
|
+
let n = it(t?.type), i = {
|
|
1059
1022
|
...e,
|
|
1060
1023
|
type: n
|
|
1061
1024
|
};
|
|
1062
1025
|
i.label ??= t?.label || e.field, i.required ??= !!t?.required;
|
|
1063
|
-
let a =
|
|
1064
|
-
n === "select" && a && !i.options && (i.options = a), n === "lookup" && (i.reference ??= t?.reference, i.displayField ??= t?.display_field || t?.reference_field), n === "file" &&
|
|
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);
|
|
1065
1028
|
let o = typeof t?.expression == "string" ? t.expression : t?.expression?.source;
|
|
1066
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;
|
|
1067
1030
|
});
|
|
1068
1031
|
}
|
|
1069
|
-
var
|
|
1032
|
+
var mt = /* @__PURE__ */ new Set([
|
|
1070
1033
|
"formula",
|
|
1071
1034
|
"summary",
|
|
1072
1035
|
"rollup",
|
|
1073
1036
|
"autonumber",
|
|
1074
1037
|
"auto_number"
|
|
1075
1038
|
]);
|
|
1076
|
-
function
|
|
1039
|
+
function ht(e, t = {}) {
|
|
1077
1040
|
let n = e?.fields;
|
|
1078
1041
|
if (!n || typeof n != "object") return [];
|
|
1079
1042
|
let r = /* @__PURE__ */ new Set([...t.exclude ?? [], ...t.relationshipField ? [t.relationshipField] : []]), i = [];
|
|
1080
1043
|
for (let [e, t] of Object.entries(n)) {
|
|
1081
1044
|
let n = t;
|
|
1082
|
-
|
|
1045
|
+
tt.has(e) || r.has(e) || nt.has(e) || n?.system || n?.hidden || mt.has(n?.type) || i.push(e);
|
|
1083
1046
|
}
|
|
1084
1047
|
return i;
|
|
1085
1048
|
}
|
|
1086
|
-
var
|
|
1049
|
+
var gt = /* @__PURE__ */ new Set([
|
|
1087
1050
|
"textarea",
|
|
1088
1051
|
"richtext",
|
|
1089
1052
|
"html",
|
|
@@ -1092,17 +1055,17 @@ var _t = /* @__PURE__ */ new Set([
|
|
|
1092
1055
|
"json",
|
|
1093
1056
|
"location",
|
|
1094
1057
|
"address"
|
|
1095
|
-
]),
|
|
1058
|
+
]), _t = /* @__PURE__ */ new Set([
|
|
1096
1059
|
"file",
|
|
1097
1060
|
"image",
|
|
1098
1061
|
"avatar"
|
|
1099
1062
|
]);
|
|
1100
|
-
function
|
|
1063
|
+
function vt(e, t, n = {}) {
|
|
1101
1064
|
if (t === "grid" || t === "form") return t;
|
|
1102
|
-
let r = e?.fields ?? {}, i =
|
|
1103
|
-
return i.some((e) =>
|
|
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";
|
|
1104
1067
|
}
|
|
1105
|
-
var
|
|
1068
|
+
var yt = [
|
|
1106
1069
|
"amount",
|
|
1107
1070
|
"total",
|
|
1108
1071
|
"subtotal",
|
|
@@ -1110,33 +1073,33 @@ var bt = [
|
|
|
1110
1073
|
"line_amount",
|
|
1111
1074
|
"net_amount"
|
|
1112
1075
|
];
|
|
1113
|
-
function
|
|
1076
|
+
function bt(e) {
|
|
1114
1077
|
let t = e.filter((e) => e.type === "number" || e.type === "currency");
|
|
1115
1078
|
if (t.length === 0) return;
|
|
1116
1079
|
let n = t.find((e) => e.computed);
|
|
1117
1080
|
if (n) return n.field;
|
|
1118
|
-
let r = t.find((e) =>
|
|
1081
|
+
let r = t.find((e) => yt.includes(e.field));
|
|
1119
1082
|
if (r) return r.field;
|
|
1120
1083
|
let i = [...t].reverse().find((e) => e.type === "currency");
|
|
1121
1084
|
return i ? i.field : t[t.length - 1].field;
|
|
1122
1085
|
}
|
|
1123
|
-
function
|
|
1124
|
-
let i = r.relationshipField ||
|
|
1086
|
+
function xt(e, t, n, r = {}) {
|
|
1087
|
+
let i = r.relationshipField || ct(t, n);
|
|
1125
1088
|
if (!i) throw Error(`MasterDetailForm: could not find a lookup/master_detail field on "${e}" referencing "${n}". Set relationshipField explicitly.`);
|
|
1126
|
-
let a = r.columns?.length ?
|
|
1089
|
+
let a = r.columns?.length ? pt(r.columns, t) : ft(t, { relationshipField: i }), o = r.amountField || bt(a);
|
|
1127
1090
|
return {
|
|
1128
1091
|
childObject: e,
|
|
1129
1092
|
relationshipField: i,
|
|
1130
1093
|
columns: a,
|
|
1131
|
-
formFields:
|
|
1132
|
-
mode:
|
|
1094
|
+
formFields: ht(t, { relationshipField: i }),
|
|
1095
|
+
mode: vt(t, r.inlineEdit ?? (t?.fields)?.[i]?.inlineEdit, { relationshipField: i }),
|
|
1133
1096
|
amountField: o,
|
|
1134
|
-
sortField: Object.keys(t?.fields ?? {}).find((e) =>
|
|
1097
|
+
sortField: Object.keys(t?.fields ?? {}).find((e) => nt.has(e))
|
|
1135
1098
|
};
|
|
1136
1099
|
}
|
|
1137
1100
|
//#endregion
|
|
1138
1101
|
//#region src/MasterDetailForm.tsx
|
|
1139
|
-
function
|
|
1102
|
+
function St(e) {
|
|
1140
1103
|
if (!e) return {};
|
|
1141
1104
|
let t = {};
|
|
1142
1105
|
return e.querySelectorAll("[name]").forEach((e) => {
|
|
@@ -1168,13 +1131,13 @@ function Ct(e) {
|
|
|
1168
1131
|
}
|
|
1169
1132
|
}), t;
|
|
1170
1133
|
}
|
|
1171
|
-
var
|
|
1134
|
+
var Ct = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, formKey: c, onRowExpand: l, onAddViaForm: u }) => {
|
|
1172
1135
|
let [d, f] = s({}), p = o("");
|
|
1173
1136
|
r(() => {
|
|
1174
1137
|
let e = i.current;
|
|
1175
1138
|
if (!e) return;
|
|
1176
1139
|
let t = () => {
|
|
1177
|
-
let t =
|
|
1140
|
+
let t = St(e), n;
|
|
1178
1141
|
try {
|
|
1179
1142
|
n = JSON.stringify(t);
|
|
1180
1143
|
} catch {
|
|
@@ -1198,16 +1161,16 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1198
1161
|
c,
|
|
1199
1162
|
e.length
|
|
1200
1163
|
]);
|
|
1201
|
-
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, {
|
|
1202
1165
|
minimumFractionDigits: 2,
|
|
1203
1166
|
maximumFractionDigits: 2
|
|
1204
1167
|
})}`;
|
|
1205
|
-
return /* @__PURE__ */
|
|
1168
|
+
return /* @__PURE__ */ Z(he, { children: [e.map((e, r) => /* @__PURE__ */ Z("section", {
|
|
1206
1169
|
className: "space-y-2",
|
|
1207
|
-
children: [/* @__PURE__ */
|
|
1170
|
+
children: [/* @__PURE__ */ X("h3", {
|
|
1208
1171
|
className: "text-sm font-medium text-foreground",
|
|
1209
1172
|
children: e.title || "Line Items"
|
|
1210
|
-
}), e.columns?.length ? /* @__PURE__ */
|
|
1173
|
+
}), e.columns?.length ? /* @__PURE__ */ X(_, {
|
|
1211
1174
|
value: t[r]?.rows ?? [],
|
|
1212
1175
|
onChange: (e) => n(r, e),
|
|
1213
1176
|
contextRecord: d,
|
|
@@ -1222,45 +1185,45 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1222
1185
|
max_rows: e.maxRows,
|
|
1223
1186
|
add_label: e.inlineMode === "form" ? e.addLabel || "Add" : e.addLabel
|
|
1224
1187
|
}
|
|
1225
|
-
}) : /* @__PURE__ */
|
|
1188
|
+
}) : /* @__PURE__ */ X("p", {
|
|
1226
1189
|
className: "py-4 text-sm text-muted-foreground",
|
|
1227
1190
|
children: "Loading columns…"
|
|
1228
1191
|
})]
|
|
1229
|
-
}, `${e.childObject}-${r}`)), v && /* @__PURE__ */
|
|
1192
|
+
}, `${e.childObject}-${r}`)), v && /* @__PURE__ */ X("div", {
|
|
1230
1193
|
className: "flex justify-end",
|
|
1231
|
-
children: /* @__PURE__ */
|
|
1194
|
+
children: /* @__PURE__ */ Z("dl", {
|
|
1232
1195
|
className: "w-64 space-y-1.5 text-sm",
|
|
1233
1196
|
"data-testid": "md-totals",
|
|
1234
1197
|
children: [
|
|
1235
|
-
/* @__PURE__ */
|
|
1198
|
+
/* @__PURE__ */ Z("div", {
|
|
1236
1199
|
className: "flex items-center justify-between",
|
|
1237
|
-
children: [/* @__PURE__ */
|
|
1200
|
+
children: [/* @__PURE__ */ X("dt", {
|
|
1238
1201
|
className: "text-muted-foreground",
|
|
1239
1202
|
children: "Subtotal"
|
|
1240
|
-
}), /* @__PURE__ */
|
|
1203
|
+
}), /* @__PURE__ */ X("dd", {
|
|
1241
1204
|
className: "tabular-nums",
|
|
1242
1205
|
"data-testid": "md-subtotal",
|
|
1243
|
-
children: S(
|
|
1206
|
+
children: S(g)
|
|
1244
1207
|
})]
|
|
1245
1208
|
}),
|
|
1246
|
-
/* @__PURE__ */
|
|
1209
|
+
/* @__PURE__ */ Z("div", {
|
|
1247
1210
|
className: "flex items-center justify-between",
|
|
1248
|
-
children: [/* @__PURE__ */
|
|
1211
|
+
children: [/* @__PURE__ */ Z("dt", {
|
|
1249
1212
|
className: "text-muted-foreground",
|
|
1250
1213
|
children: [
|
|
1251
1214
|
"Tax (",
|
|
1252
1215
|
y,
|
|
1253
1216
|
"%)"
|
|
1254
1217
|
]
|
|
1255
|
-
}), /* @__PURE__ */
|
|
1218
|
+
}), /* @__PURE__ */ X("dd", {
|
|
1256
1219
|
className: "tabular-nums",
|
|
1257
1220
|
"data-testid": "md-tax",
|
|
1258
1221
|
children: S(b)
|
|
1259
1222
|
})]
|
|
1260
1223
|
}),
|
|
1261
|
-
/* @__PURE__ */
|
|
1224
|
+
/* @__PURE__ */ Z("div", {
|
|
1262
1225
|
className: "flex items-center justify-between border-t border-border pt-1.5 text-base font-semibold",
|
|
1263
|
-
children: [/* @__PURE__ */
|
|
1226
|
+
children: [/* @__PURE__ */ X("dt", { children: "Total" }), /* @__PURE__ */ X("dd", {
|
|
1264
1227
|
className: "tabular-nums",
|
|
1265
1228
|
"data-testid": "md-grand-total",
|
|
1266
1229
|
children: S(x)
|
|
@@ -1269,11 +1232,11 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1269
1232
|
]
|
|
1270
1233
|
})
|
|
1271
1234
|
})] });
|
|
1272
|
-
},
|
|
1273
|
-
let c = e.details || [], l = e.mode === "edit" && !!e.recordId,
|
|
1235
|
+
}, wt = ({ schema: e, dataSource: n, className: i }) => {
|
|
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;
|
|
1274
1237
|
r(() => {
|
|
1275
|
-
if (!
|
|
1276
|
-
|
|
1238
|
+
if (!d) {
|
|
1239
|
+
p(c);
|
|
1277
1240
|
return;
|
|
1278
1241
|
}
|
|
1279
1242
|
if (!n || typeof n.getObjectSchema != "function") return;
|
|
@@ -1286,9 +1249,9 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1286
1249
|
let r = await n.getObjectSchema(t.childObject);
|
|
1287
1250
|
if (t.relationshipField && t.columns?.length) return {
|
|
1288
1251
|
...t,
|
|
1289
|
-
columns:
|
|
1252
|
+
columns: pt(t.columns, r)
|
|
1290
1253
|
};
|
|
1291
|
-
let i =
|
|
1254
|
+
let i = xt(t.childObject, r, e.objectName, {
|
|
1292
1255
|
relationshipField: t.relationshipField,
|
|
1293
1256
|
columns: t.columns,
|
|
1294
1257
|
amountField: t.amountField
|
|
@@ -1306,7 +1269,7 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1306
1269
|
return t;
|
|
1307
1270
|
}
|
|
1308
1271
|
}));
|
|
1309
|
-
t ||
|
|
1272
|
+
t || p(r);
|
|
1310
1273
|
})(), () => {
|
|
1311
1274
|
t = !0;
|
|
1312
1275
|
};
|
|
@@ -1315,12 +1278,12 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1315
1278
|
e.objectName,
|
|
1316
1279
|
e.details
|
|
1317
1280
|
]);
|
|
1318
|
-
let [
|
|
1281
|
+
let [h, g] = s(() => c.map(() => ({
|
|
1319
1282
|
rows: [],
|
|
1320
1283
|
original: []
|
|
1321
|
-
}))),
|
|
1322
|
-
|
|
1323
|
-
let
|
|
1284
|
+
}))), _ = o(h);
|
|
1285
|
+
_.current = h;
|
|
1286
|
+
let v = o({});
|
|
1324
1287
|
r(() => {
|
|
1325
1288
|
let e = n;
|
|
1326
1289
|
if (!e || typeof e.getObjectSchema != "function") return;
|
|
@@ -1336,7 +1299,7 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1336
1299
|
if (t) return;
|
|
1337
1300
|
let i = {};
|
|
1338
1301
|
for (let [e, t] of n) t && (i[e] = t);
|
|
1339
|
-
|
|
1302
|
+
v.current = i;
|
|
1340
1303
|
})(), () => {
|
|
1341
1304
|
t = !0;
|
|
1342
1305
|
};
|
|
@@ -1345,13 +1308,13 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1345
1308
|
e.objectName,
|
|
1346
1309
|
e.details
|
|
1347
1310
|
]);
|
|
1348
|
-
let [
|
|
1349
|
-
|
|
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);
|
|
1350
1313
|
}, []);
|
|
1351
1314
|
r(() => {
|
|
1352
1315
|
let t = !1;
|
|
1353
1316
|
if (!(!l || !n)) return (async () => {
|
|
1354
|
-
let r = await Promise.all(
|
|
1317
|
+
let r = await Promise.all(m.map(async (t) => {
|
|
1355
1318
|
if (!t.relationshipField) return {
|
|
1356
1319
|
rows: [],
|
|
1357
1320
|
original: []
|
|
@@ -1372,7 +1335,7 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1372
1335
|
};
|
|
1373
1336
|
}
|
|
1374
1337
|
}));
|
|
1375
|
-
t ||
|
|
1338
|
+
t || g(r);
|
|
1376
1339
|
})(), () => {
|
|
1377
1340
|
t = !0;
|
|
1378
1341
|
};
|
|
@@ -1380,118 +1343,78 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1380
1343
|
l,
|
|
1381
1344
|
n,
|
|
1382
1345
|
e.recordId,
|
|
1383
|
-
|
|
1346
|
+
f
|
|
1384
1347
|
]);
|
|
1385
|
-
let
|
|
1386
|
-
|
|
1348
|
+
let E = t((e, t) => {
|
|
1349
|
+
g((n) => n.map((n, r) => r === e ? {
|
|
1387
1350
|
...n,
|
|
1388
1351
|
rows: t
|
|
1389
1352
|
} : n));
|
|
1390
|
-
}, []),
|
|
1391
|
-
|
|
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 ? {
|
|
1392
1355
|
...r,
|
|
1393
1356
|
rows: r.rows.map((e, r) => r === t ? {
|
|
1394
1357
|
...e,
|
|
1395
1358
|
...n
|
|
1396
1359
|
} : e)
|
|
1397
1360
|
} : r));
|
|
1398
|
-
}, []),
|
|
1399
|
-
|
|
1361
|
+
}, []), ee = t((e) => {
|
|
1362
|
+
g((t) => {
|
|
1400
1363
|
let n = t.map((t, n) => n === e ? {
|
|
1401
1364
|
...t,
|
|
1402
1365
|
rows: [...t.rows, {}]
|
|
1403
1366
|
} : t), r = n[e].rows.length - 1;
|
|
1404
|
-
return
|
|
1367
|
+
return M({
|
|
1405
1368
|
detailIdx: e,
|
|
1406
1369
|
rowIdx: r,
|
|
1407
1370
|
isNew: !0
|
|
1408
1371
|
}), n;
|
|
1409
1372
|
});
|
|
1410
|
-
}, []),
|
|
1411
|
-
|
|
1373
|
+
}, []), R = t(() => {
|
|
1374
|
+
M((e) => (e?.isNew && g((t) => t.map((t, n) => n === e.detailIdx ? {
|
|
1412
1375
|
...t,
|
|
1413
1376
|
rows: t.rows.filter((t, n) => n !== e.rowIdx)
|
|
1414
1377
|
} : t)), null));
|
|
1415
|
-
}, []),
|
|
1416
|
-
|
|
1378
|
+
}, []), z = t(async (t) => {
|
|
1379
|
+
T(), e.onSuccess || K.success(l ? e.title ? `${e.title} saved` : "Saved" : "Created"), l || (g(m.map(() => ({
|
|
1417
1380
|
rows: [],
|
|
1418
1381
|
original: []
|
|
1419
|
-
}))),
|
|
1382
|
+
}))), b((e) => e + 1)), await e.onSuccess?.(t);
|
|
1420
1383
|
}, [
|
|
1421
1384
|
l,
|
|
1422
1385
|
e.onSuccess,
|
|
1423
1386
|
e.title,
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
]),
|
|
1427
|
-
|
|
1428
|
-
}, [e,
|
|
1429
|
-
let r = [];
|
|
1430
|
-
for (let i = 0; i < p.length; i++) {
|
|
1431
|
-
let a = p[i], { rows: o, original: s } = g.current[i];
|
|
1432
|
-
if (!a.relationshipField) continue;
|
|
1433
|
-
let { created: c } = await tt(n, e.objectName, t, {
|
|
1434
|
-
childObject: a.childObject,
|
|
1435
|
-
relationshipField: a.relationshipField,
|
|
1436
|
-
rows: o,
|
|
1437
|
-
original: l ? s : void 0,
|
|
1438
|
-
amountField: a.amountField,
|
|
1439
|
-
totalField: a.totalField,
|
|
1440
|
-
childSchema: _.current[a.childObject]
|
|
1441
|
-
});
|
|
1442
|
-
r.push(...c);
|
|
1443
|
-
}
|
|
1444
|
-
return r;
|
|
1445
|
-
}, [
|
|
1446
|
-
p,
|
|
1447
|
-
l,
|
|
1448
|
-
n,
|
|
1449
|
-
e.objectName
|
|
1450
|
-
]), B = t(async (t) => {
|
|
1451
|
-
let r = $(t) ?? e.recordId;
|
|
1452
|
-
if (!r) throw Error("MasterDetailForm: parent record has no id after save");
|
|
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) => {
|
|
1453
1392
|
if (!n) throw Error("MasterDetailForm: dataSource is required");
|
|
1454
|
-
let
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
}
|
|
1458
|
-
throw l || await Promise.allSettled([...i.map((e) => n.delete(e.object, e.id)), n.delete(e.objectName, r)]), t;
|
|
1459
|
-
}
|
|
1460
|
-
await L(t);
|
|
1461
|
-
}, [
|
|
1462
|
-
n,
|
|
1463
|
-
l,
|
|
1464
|
-
z,
|
|
1465
|
-
e,
|
|
1466
|
-
L
|
|
1467
|
-
]), V = typeof n?.batchTransaction == "function", H = t(async (t) => {
|
|
1468
|
-
let r = n, i = { ...t };
|
|
1469
|
-
p.forEach((e, t) => {
|
|
1470
|
-
e.totalField && (i[e.totalField] = Qe(g.current[t]?.rows ?? [], e.amountField || "amount"));
|
|
1471
|
-
});
|
|
1472
|
-
let a = l ? Xe(e.objectName, e.recordId, i, p.filter((e) => e.relationshipField).map((e, t) => ({
|
|
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) => ({
|
|
1473
1397
|
childObject: e.childObject,
|
|
1474
1398
|
relationshipField: e.relationshipField,
|
|
1475
|
-
rows:
|
|
1476
|
-
original:
|
|
1477
|
-
childSchema:
|
|
1478
|
-
}))) :
|
|
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) => ({
|
|
1479
1403
|
childObject: e.childObject,
|
|
1480
1404
|
relationshipField: e.relationshipField,
|
|
1481
|
-
rows:
|
|
1482
|
-
childSchema:
|
|
1483
|
-
})))
|
|
1484
|
-
|
|
1485
|
-
...i,
|
|
1405
|
+
rows: _.current[t]?.rows ?? [],
|
|
1406
|
+
childSchema: v.current[e.childObject]
|
|
1407
|
+
})))))?.results?.[0] ?? {
|
|
1408
|
+
...r,
|
|
1486
1409
|
id: e.recordId
|
|
1487
1410
|
};
|
|
1488
1411
|
}, [
|
|
1489
1412
|
n,
|
|
1490
|
-
|
|
1413
|
+
m,
|
|
1491
1414
|
e.objectName,
|
|
1492
1415
|
e.recordId,
|
|
1493
1416
|
l
|
|
1494
|
-
]),
|
|
1417
|
+
]), H = a(() => ({
|
|
1495
1418
|
type: "object-form",
|
|
1496
1419
|
objectName: e.objectName,
|
|
1497
1420
|
mode: e.mode ?? "create",
|
|
@@ -1504,116 +1427,112 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1504
1427
|
title: e.title,
|
|
1505
1428
|
showSubmit: !1,
|
|
1506
1429
|
showCancel: !1,
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
} : { onSuccess: B },
|
|
1511
|
-
onError: R
|
|
1430
|
+
submitHandler: V,
|
|
1431
|
+
onSuccess: z,
|
|
1432
|
+
onError: B
|
|
1512
1433
|
}), [
|
|
1513
1434
|
e,
|
|
1514
|
-
B,
|
|
1515
1435
|
V,
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
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(() => {
|
|
1521
1440
|
(U.current?.querySelector("form"))?.requestSubmit();
|
|
1522
|
-
}, 0),
|
|
1523
|
-
}, [
|
|
1441
|
+
}, 0), w.current = setTimeout(() => T(), 1500));
|
|
1442
|
+
}, [T]);
|
|
1524
1443
|
return r(() => () => {
|
|
1525
|
-
|
|
1526
|
-
}, []), /* @__PURE__ */
|
|
1444
|
+
w.current && clearTimeout(w.current);
|
|
1445
|
+
}, []), /* @__PURE__ */ Z("div", {
|
|
1527
1446
|
className: G("space-y-6", i, e.className),
|
|
1528
1447
|
children: [
|
|
1529
|
-
/* @__PURE__ */
|
|
1448
|
+
/* @__PURE__ */ X("div", {
|
|
1530
1449
|
ref: U,
|
|
1531
|
-
children: /* @__PURE__ */
|
|
1532
|
-
schema:
|
|
1450
|
+
children: /* @__PURE__ */ X(Mt, {
|
|
1451
|
+
schema: H,
|
|
1533
1452
|
dataSource: n
|
|
1534
|
-
},
|
|
1453
|
+
}, y)
|
|
1535
1454
|
}),
|
|
1536
|
-
/* @__PURE__ */
|
|
1537
|
-
details:
|
|
1538
|
-
state:
|
|
1539
|
-
setRows:
|
|
1455
|
+
/* @__PURE__ */ X(Ct, {
|
|
1456
|
+
details: m,
|
|
1457
|
+
state: h,
|
|
1458
|
+
setRows: E,
|
|
1540
1459
|
formHostRef: U,
|
|
1541
|
-
taxRateField:
|
|
1542
|
-
formKey:
|
|
1543
|
-
onRowExpand: (e, t) =>
|
|
1460
|
+
taxRateField: D,
|
|
1461
|
+
formKey: y,
|
|
1462
|
+
onRowExpand: (e, t) => M({
|
|
1544
1463
|
detailIdx: e,
|
|
1545
1464
|
rowIdx: t
|
|
1546
1465
|
}),
|
|
1547
|
-
onAddViaForm:
|
|
1466
|
+
onAddViaForm: ee
|
|
1548
1467
|
}),
|
|
1549
|
-
|
|
1468
|
+
O && I && /* @__PURE__ */ Z(A, {
|
|
1550
1469
|
className: "border-primary/40 shadow-none ring-1 ring-primary/10",
|
|
1551
1470
|
"data-testid": "md-row-form",
|
|
1552
|
-
children: [/* @__PURE__ */
|
|
1471
|
+
children: [/* @__PURE__ */ Z(N, {
|
|
1553
1472
|
className: "pb-2 flex flex-row items-center justify-between gap-2 space-y-0",
|
|
1554
|
-
children: [/* @__PURE__ */
|
|
1473
|
+
children: [/* @__PURE__ */ Z(P, {
|
|
1555
1474
|
className: "text-sm font-medium",
|
|
1556
1475
|
children: [
|
|
1557
|
-
|
|
1476
|
+
I.title || "Line item",
|
|
1558
1477
|
" — row ",
|
|
1559
|
-
|
|
1478
|
+
O.rowIdx + 1
|
|
1560
1479
|
]
|
|
1561
|
-
}), /* @__PURE__ */
|
|
1480
|
+
}), /* @__PURE__ */ X(k, {
|
|
1562
1481
|
type: "button",
|
|
1563
1482
|
variant: "ghost",
|
|
1564
1483
|
size: "sm",
|
|
1565
1484
|
className: "h-7 text-xs text-muted-foreground",
|
|
1566
|
-
onClick:
|
|
1485
|
+
onClick: R,
|
|
1567
1486
|
children: "Close"
|
|
1568
1487
|
})]
|
|
1569
|
-
}), /* @__PURE__ */
|
|
1488
|
+
}), /* @__PURE__ */ X(j, { children: /* @__PURE__ */ X(Mt, {
|
|
1570
1489
|
schema: {
|
|
1571
1490
|
type: "object-form",
|
|
1572
|
-
objectName:
|
|
1491
|
+
objectName: I.childObject,
|
|
1573
1492
|
mode: "edit",
|
|
1574
|
-
initialData:
|
|
1575
|
-
...
|
|
1493
|
+
initialData: F ?? {},
|
|
1494
|
+
...I.formFields?.length ? { fields: I.formFields } : {},
|
|
1576
1495
|
submitText: "Apply",
|
|
1577
1496
|
submitHandler: async (e) => e,
|
|
1578
1497
|
onSuccess: (e) => {
|
|
1579
|
-
|
|
1498
|
+
L(O.detailIdx, O.rowIdx, e), M(null);
|
|
1580
1499
|
},
|
|
1581
|
-
onCancel:
|
|
1500
|
+
onCancel: R
|
|
1582
1501
|
},
|
|
1583
1502
|
dataSource: n
|
|
1584
|
-
}, `row-${
|
|
1503
|
+
}, `row-${O.detailIdx}-${O.rowIdx}`) })]
|
|
1585
1504
|
}),
|
|
1586
|
-
e.showSubmit !== !1 && /* @__PURE__ */
|
|
1505
|
+
e.showSubmit !== !1 && /* @__PURE__ */ Z("div", {
|
|
1587
1506
|
className: "flex items-center justify-end gap-2 border-t border-border pt-4",
|
|
1588
|
-
children: [e.onCancel && /* @__PURE__ */
|
|
1507
|
+
children: [e.onCancel && /* @__PURE__ */ X(k, {
|
|
1589
1508
|
type: "button",
|
|
1590
1509
|
variant: "outline",
|
|
1591
1510
|
onClick: e.onCancel,
|
|
1592
|
-
disabled:
|
|
1511
|
+
disabled: x,
|
|
1593
1512
|
"data-testid": "md-form-cancel",
|
|
1594
1513
|
children: e.cancelText ?? "Cancel"
|
|
1595
|
-
}), /* @__PURE__ */
|
|
1514
|
+
}), /* @__PURE__ */ X(k, {
|
|
1596
1515
|
type: "button",
|
|
1597
|
-
onClick:
|
|
1598
|
-
disabled:
|
|
1516
|
+
onClick: te,
|
|
1517
|
+
disabled: x || d && !f,
|
|
1599
1518
|
"data-testid": "md-form-submit",
|
|
1600
|
-
children:
|
|
1519
|
+
children: x ? "Saving…" : W
|
|
1601
1520
|
})]
|
|
1602
1521
|
})
|
|
1603
1522
|
]
|
|
1604
1523
|
});
|
|
1605
|
-
},
|
|
1524
|
+
}, Tt = {
|
|
1606
1525
|
1: void 0,
|
|
1607
1526
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
1608
1527
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
1609
1528
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
1610
|
-
},
|
|
1529
|
+
}, Et = ge({
|
|
1611
1530
|
"form.discardTitle": "Discard changes?",
|
|
1612
1531
|
"form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
|
|
1613
1532
|
"form.keepEditing": "Keep editing",
|
|
1614
1533
|
"form.discard": "Discard"
|
|
1615
|
-
}, "form.discardTitle"),
|
|
1616
|
-
let { fieldLabel:
|
|
1534
|
+
}, "form.discardTitle"), Dt = ({ schema: e, dataSource: n, className: c }) => {
|
|
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(() => {
|
|
1617
1536
|
let t = {};
|
|
1618
1537
|
return e.sections?.forEach((e, n) => {
|
|
1619
1538
|
let r = e.name || String(n);
|
|
@@ -1628,13 +1547,13 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1628
1547
|
}
|
|
1629
1548
|
try {
|
|
1630
1549
|
let t = await n.getObjectSchema(e.objectName);
|
|
1631
|
-
|
|
1550
|
+
g(t);
|
|
1632
1551
|
} catch (e) {
|
|
1633
1552
|
F(e), N(!1);
|
|
1634
1553
|
}
|
|
1635
1554
|
})();
|
|
1636
1555
|
}, [e.objectName, n]), r(() => {
|
|
1637
|
-
(
|
|
1556
|
+
(m || !n) && (async () => {
|
|
1638
1557
|
if (e.mode === "create" || !e.recordId) {
|
|
1639
1558
|
j(e.initialData || e.initialValues || {}), N(!1);
|
|
1640
1559
|
return;
|
|
@@ -1653,7 +1572,7 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1653
1572
|
}
|
|
1654
1573
|
})();
|
|
1655
1574
|
}, [
|
|
1656
|
-
|
|
1575
|
+
m,
|
|
1657
1576
|
e.mode,
|
|
1658
1577
|
e.recordId,
|
|
1659
1578
|
e.initialData,
|
|
@@ -1661,52 +1580,52 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1661
1580
|
n,
|
|
1662
1581
|
e.objectName
|
|
1663
1582
|
]);
|
|
1664
|
-
let ce = t((t) =>
|
|
1665
|
-
objectSchema:
|
|
1583
|
+
let ce = t((t) => Se(t, {
|
|
1584
|
+
objectSchema: m,
|
|
1666
1585
|
objectName: e.objectName,
|
|
1667
1586
|
readOnly: e.readOnly,
|
|
1668
1587
|
mode: e.mode,
|
|
1669
|
-
fieldLabel:
|
|
1588
|
+
fieldLabel: l
|
|
1670
1589
|
}), [
|
|
1671
|
-
|
|
1590
|
+
m,
|
|
1672
1591
|
e.readOnly,
|
|
1673
1592
|
e.mode,
|
|
1674
1593
|
e.objectName,
|
|
1675
|
-
|
|
1594
|
+
l
|
|
1676
1595
|
]);
|
|
1677
1596
|
r(() => {
|
|
1678
|
-
if (!
|
|
1597
|
+
if (!m && n) return;
|
|
1679
1598
|
if (e.customFields?.length) {
|
|
1680
|
-
|
|
1599
|
+
y(e.customFields), N(!1);
|
|
1681
1600
|
return;
|
|
1682
1601
|
}
|
|
1683
1602
|
if (e.sections?.length) {
|
|
1684
1603
|
N(!1);
|
|
1685
1604
|
return;
|
|
1686
1605
|
}
|
|
1687
|
-
if (!
|
|
1688
|
-
let t = e.fields || Object.keys(
|
|
1606
|
+
if (!m) return;
|
|
1607
|
+
let t = e.fields || Object.keys(m.fields || {}), r = [];
|
|
1689
1608
|
for (let n of t) {
|
|
1690
1609
|
let t = typeof n == "string" ? n : n.name;
|
|
1691
1610
|
if (!t) continue;
|
|
1692
|
-
let i =
|
|
1611
|
+
let i = m.fields?.[t];
|
|
1693
1612
|
i && r.push({
|
|
1694
1613
|
name: t,
|
|
1695
|
-
label:
|
|
1696
|
-
type:
|
|
1614
|
+
label: l(e.objectName, t, i.label || t),
|
|
1615
|
+
type: b(i.type),
|
|
1697
1616
|
required: i.required || !1,
|
|
1698
1617
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
1699
1618
|
placeholder: i.placeholder,
|
|
1700
1619
|
description: i.help || i.description,
|
|
1701
|
-
validation:
|
|
1620
|
+
validation: v(i),
|
|
1702
1621
|
field: i,
|
|
1703
1622
|
options: i.options,
|
|
1704
1623
|
multiple: i.multiple
|
|
1705
1624
|
});
|
|
1706
1625
|
}
|
|
1707
|
-
|
|
1626
|
+
y(r), N(!1);
|
|
1708
1627
|
}, [
|
|
1709
|
-
|
|
1628
|
+
m,
|
|
1710
1629
|
e.fields,
|
|
1711
1630
|
e.customFields,
|
|
1712
1631
|
e.sections,
|
|
@@ -1715,31 +1634,31 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1715
1634
|
n
|
|
1716
1635
|
]);
|
|
1717
1636
|
let le = t(async (t) => {
|
|
1718
|
-
|
|
1637
|
+
B(!0);
|
|
1719
1638
|
try {
|
|
1720
1639
|
if (!n) return e.onSuccess && await e.onSuccess(t), e.onOpenChange?.(!1), t;
|
|
1721
|
-
let r, i =
|
|
1640
|
+
let r, i = Ke(t, m);
|
|
1722
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;
|
|
1723
1642
|
} catch (t) {
|
|
1724
1643
|
throw e.onError && e.onError(t), t;
|
|
1725
1644
|
} finally {
|
|
1726
|
-
|
|
1645
|
+
B(!1);
|
|
1727
1646
|
}
|
|
1728
1647
|
}, [
|
|
1729
1648
|
e,
|
|
1730
1649
|
n,
|
|
1731
|
-
|
|
1650
|
+
m
|
|
1732
1651
|
]), q = t(() => {
|
|
1733
|
-
|
|
1652
|
+
R(!1), V.current && (V.current = !1, e.onCancel?.()), e.onOpenChange?.(!1);
|
|
1734
1653
|
}, [e]), ue = t((e) => {
|
|
1735
|
-
|
|
1654
|
+
V.current = e, re && I ? R(!0) : q();
|
|
1736
1655
|
}, [
|
|
1737
1656
|
re,
|
|
1738
|
-
|
|
1657
|
+
I,
|
|
1739
1658
|
q
|
|
1740
1659
|
]), de = t(() => {
|
|
1741
|
-
|
|
1742
|
-
}, [q]),
|
|
1660
|
+
V.current = !0, q();
|
|
1661
|
+
}, [q]), fe = a(() => {
|
|
1743
1662
|
if (e.drawerWidth) return ae === "left" || ae === "right" ? {
|
|
1744
1663
|
width: e.drawerWidth,
|
|
1745
1664
|
maxWidth: e.drawerWidth
|
|
@@ -1747,34 +1666,34 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1747
1666
|
height: e.drawerWidth,
|
|
1748
1667
|
maxHeight: e.drawerWidth
|
|
1749
1668
|
};
|
|
1750
|
-
}, [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 = {
|
|
1751
1670
|
type: "form",
|
|
1752
1671
|
objectName: e.objectName,
|
|
1753
|
-
layout:
|
|
1672
|
+
layout: pe,
|
|
1754
1673
|
defaultValues: A,
|
|
1755
1674
|
submitLabel: he,
|
|
1756
1675
|
cancelLabel: ge,
|
|
1757
1676
|
showSubmit: J,
|
|
1758
|
-
showCancel:
|
|
1677
|
+
showCancel: Y,
|
|
1759
1678
|
onSubmit: le,
|
|
1760
1679
|
onCancel: de,
|
|
1761
|
-
onDirtyChange:
|
|
1680
|
+
onDirtyChange: L,
|
|
1762
1681
|
showActions: !1,
|
|
1763
|
-
id:
|
|
1764
|
-
},
|
|
1765
|
-
if (P) return /* @__PURE__ */
|
|
1682
|
+
id: oe
|
|
1683
|
+
}, Q = () => {
|
|
1684
|
+
if (P) return /* @__PURE__ */ Z("div", {
|
|
1766
1685
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1767
|
-
children: [/* @__PURE__ */
|
|
1686
|
+
children: [/* @__PURE__ */ X("h3", {
|
|
1768
1687
|
className: "text-red-800 font-semibold",
|
|
1769
1688
|
children: "Error loading form"
|
|
1770
|
-
}), /* @__PURE__ */
|
|
1689
|
+
}), /* @__PURE__ */ X("p", {
|
|
1771
1690
|
className: "text-red-600 text-sm mt-1",
|
|
1772
1691
|
children: P.message
|
|
1773
1692
|
})]
|
|
1774
1693
|
});
|
|
1775
|
-
if (M) return /* @__PURE__ */
|
|
1694
|
+
if (M) return /* @__PURE__ */ Z("div", {
|
|
1776
1695
|
className: "p-8 text-center",
|
|
1777
|
-
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", {
|
|
1778
1697
|
className: "mt-2 text-sm text-gray-600",
|
|
1779
1698
|
children: "Loading form..."
|
|
1780
1699
|
})]
|
|
@@ -1782,7 +1701,7 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1782
1701
|
if (e.sections?.length) {
|
|
1783
1702
|
let t = [];
|
|
1784
1703
|
return e.sections.forEach((e, n) => {
|
|
1785
|
-
let r = e.name || String(n), i =
|
|
1704
|
+
let r = e.name || String(n), i = se[r] ?? e.collapsed ?? !1;
|
|
1786
1705
|
t.push({
|
|
1787
1706
|
name: `__section_${r}`,
|
|
1788
1707
|
label: e.label || "",
|
|
@@ -1790,7 +1709,7 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1790
1709
|
colSpan: 4,
|
|
1791
1710
|
collapsible: e.collapsible,
|
|
1792
1711
|
collapsed: i,
|
|
1793
|
-
onToggle: e.collapsible ? () =>
|
|
1712
|
+
onToggle: e.collapsible ? () => K((e) => ({
|
|
1794
1713
|
...e,
|
|
1795
1714
|
[r]: !i
|
|
1796
1715
|
})) : void 0,
|
|
@@ -1801,19 +1720,19 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1801
1720
|
...e,
|
|
1802
1721
|
hidden: !0
|
|
1803
1722
|
}))) : t.push(...a);
|
|
1804
|
-
}), /* @__PURE__ */
|
|
1723
|
+
}), /* @__PURE__ */ X(d, { schema: {
|
|
1805
1724
|
..._e,
|
|
1806
1725
|
fields: t
|
|
1807
1726
|
} });
|
|
1808
1727
|
}
|
|
1809
|
-
let t =
|
|
1810
|
-
return /* @__PURE__ */
|
|
1728
|
+
let t = Be(_, m, e.columns, e.mode), n = Tt[t.columns || 1];
|
|
1729
|
+
return /* @__PURE__ */ X(d, { schema: {
|
|
1811
1730
|
..._e,
|
|
1812
1731
|
fields: t.fields,
|
|
1813
1732
|
columns: t.columns,
|
|
1814
1733
|
...n ? { fieldContainerClass: n } : {}
|
|
1815
1734
|
} });
|
|
1816
|
-
},
|
|
1735
|
+
}, ve = e.subforms, $ = ve?.length && e.mode !== "view" ? /* @__PURE__ */ X(wt, {
|
|
1817
1736
|
schema: {
|
|
1818
1737
|
type: "object-master-detail-form",
|
|
1819
1738
|
objectName: e.objectName,
|
|
@@ -1823,7 +1742,7 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1823
1742
|
sections: e.sections,
|
|
1824
1743
|
submitText: e.submitText,
|
|
1825
1744
|
cancelText: ge,
|
|
1826
|
-
details:
|
|
1745
|
+
details: ve,
|
|
1827
1746
|
onSuccess: async (t) => {
|
|
1828
1747
|
await e.onSuccess?.(t), e.onOpenChange?.(!1);
|
|
1829
1748
|
},
|
|
@@ -1831,20 +1750,20 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1831
1750
|
onCancel: () => e.onOpenChange?.(!1)
|
|
1832
1751
|
},
|
|
1833
1752
|
dataSource: n
|
|
1834
|
-
}) :
|
|
1835
|
-
return
|
|
1753
|
+
}) : Q();
|
|
1754
|
+
return f ? /* @__PURE__ */ Z("div", {
|
|
1836
1755
|
className: "@container rounded-md border bg-card p-4",
|
|
1837
|
-
children: [(e.title || e.description) && /* @__PURE__ */
|
|
1756
|
+
children: [(e.title || e.description) && /* @__PURE__ */ Z("div", {
|
|
1838
1757
|
className: "mb-3 space-y-0.5",
|
|
1839
|
-
children: [e.title && /* @__PURE__ */
|
|
1758
|
+
children: [e.title && /* @__PURE__ */ X("div", {
|
|
1840
1759
|
className: "text-sm font-semibold",
|
|
1841
1760
|
children: e.title
|
|
1842
|
-
}), e.description && /* @__PURE__ */
|
|
1761
|
+
}), e.description && /* @__PURE__ */ X("p", {
|
|
1843
1762
|
className: "text-xs text-muted-foreground",
|
|
1844
1763
|
children: e.description
|
|
1845
1764
|
})]
|
|
1846
|
-
}),
|
|
1847
|
-
}) : /* @__PURE__ */
|
|
1765
|
+
}), $]
|
|
1766
|
+
}) : /* @__PURE__ */ X(H, {
|
|
1848
1767
|
open: ie,
|
|
1849
1768
|
onOpenChange: (t) => {
|
|
1850
1769
|
if (t) {
|
|
@@ -1853,51 +1772,51 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1853
1772
|
}
|
|
1854
1773
|
ue(!1);
|
|
1855
1774
|
},
|
|
1856
|
-
children: /* @__PURE__ */
|
|
1775
|
+
children: /* @__PURE__ */ Z(U, {
|
|
1857
1776
|
side: ae,
|
|
1858
1777
|
className: G("overflow-y-auto", c, e.className),
|
|
1859
|
-
style:
|
|
1778
|
+
style: fe,
|
|
1860
1779
|
children: [
|
|
1861
|
-
(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, {
|
|
1862
1781
|
className: "sr-only",
|
|
1863
1782
|
children: "Complete the form fields, then submit or cancel."
|
|
1864
1783
|
})] }),
|
|
1865
|
-
/* @__PURE__ */
|
|
1784
|
+
/* @__PURE__ */ X("div", {
|
|
1866
1785
|
className: "@container py-4",
|
|
1867
|
-
children:
|
|
1786
|
+
children: $
|
|
1868
1787
|
}),
|
|
1869
|
-
!P && !M && !(
|
|
1788
|
+
!P && !M && !(ve?.length && e.mode !== "view") && (J || Y) && /* @__PURE__ */ X("div", {
|
|
1870
1789
|
className: "shrink-0 border-t px-4 py-3 bg-background",
|
|
1871
1790
|
"data-testid": "drawer-form-footer",
|
|
1872
|
-
children: /* @__PURE__ */
|
|
1791
|
+
children: /* @__PURE__ */ Z("div", {
|
|
1873
1792
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
1874
|
-
children: [
|
|
1793
|
+
children: [Y && /* @__PURE__ */ X(k, {
|
|
1875
1794
|
type: "button",
|
|
1876
1795
|
variant: "outline",
|
|
1877
1796
|
onClick: de,
|
|
1878
|
-
disabled:
|
|
1797
|
+
disabled: z,
|
|
1879
1798
|
className: "w-full sm:w-auto",
|
|
1880
1799
|
children: ge
|
|
1881
|
-
}), J && /* @__PURE__ */
|
|
1800
|
+
}), J && /* @__PURE__ */ Z(k, {
|
|
1882
1801
|
type: "submit",
|
|
1883
|
-
form:
|
|
1884
|
-
disabled:
|
|
1802
|
+
form: oe,
|
|
1803
|
+
disabled: z,
|
|
1885
1804
|
className: "w-full sm:w-auto",
|
|
1886
|
-
children: [
|
|
1805
|
+
children: [z && /* @__PURE__ */ X(me, { className: "mr-2 h-4 w-4 animate-spin" }), he]
|
|
1887
1806
|
})]
|
|
1888
1807
|
})
|
|
1889
1808
|
}),
|
|
1890
|
-
/* @__PURE__ */
|
|
1891
|
-
open:
|
|
1892
|
-
onOpenChange:
|
|
1893
|
-
children: /* @__PURE__ */
|
|
1809
|
+
/* @__PURE__ */ X(x, {
|
|
1810
|
+
open: ee,
|
|
1811
|
+
onOpenChange: R,
|
|
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, {
|
|
1894
1813
|
onClick: () => {
|
|
1895
|
-
|
|
1814
|
+
V.current = !1;
|
|
1896
1815
|
},
|
|
1897
|
-
children:
|
|
1898
|
-
}), /* @__PURE__ */
|
|
1816
|
+
children: u("form.keepEditing")
|
|
1817
|
+
}), /* @__PURE__ */ X(S, {
|
|
1899
1818
|
onClick: q,
|
|
1900
|
-
children:
|
|
1819
|
+
children: u("form.discard")
|
|
1901
1820
|
})] })] })
|
|
1902
1821
|
})
|
|
1903
1822
|
]
|
|
@@ -1906,8 +1825,8 @@ var wt = ({ details: e, state: t, setRows: n, formHostRef: i, taxRateField: a, f
|
|
|
1906
1825
|
};
|
|
1907
1826
|
//#endregion
|
|
1908
1827
|
//#region src/fieldGroups.ts
|
|
1909
|
-
function
|
|
1910
|
-
let n =
|
|
1828
|
+
function Ot(e, t) {
|
|
1829
|
+
let n = _e({
|
|
1911
1830
|
fieldGroups: t,
|
|
1912
1831
|
fields: Object.fromEntries(e.map((e) => [e.name, { group: e.group }]))
|
|
1913
1832
|
});
|
|
@@ -1927,27 +1846,27 @@ function kt(e, t) {
|
|
|
1927
1846
|
}
|
|
1928
1847
|
//#endregion
|
|
1929
1848
|
//#region src/ModalForm.tsx
|
|
1930
|
-
var
|
|
1849
|
+
var kt = ge({
|
|
1931
1850
|
"form.discardTitle": "Discard changes?",
|
|
1932
1851
|
"form.discardMessage": "You have unsaved changes. If you close this form now, your edits will be lost.",
|
|
1933
1852
|
"form.keepEditing": "Keep editing",
|
|
1934
1853
|
"form.discard": "Discard"
|
|
1935
|
-
}, "form.discardTitle"),
|
|
1854
|
+
}, "form.discardTitle"), At = {
|
|
1936
1855
|
sm: "sm:max-w-sm",
|
|
1937
1856
|
default: "sm:max-w-lg",
|
|
1938
1857
|
lg: "sm:max-w-2xl",
|
|
1939
1858
|
xl: "sm:max-w-5xl",
|
|
1940
1859
|
full: "sm:max-w-[95vw] sm:w-full"
|
|
1941
|
-
},
|
|
1942
|
-
let { fieldLabel:
|
|
1943
|
-
if (!
|
|
1860
|
+
}, jt = ({ schema: e, dataSource: n, className: c }) => {
|
|
1861
|
+
let { fieldLabel: l, sectionLabel: u } = h(), { t: f } = kt(), m = p(), g = le(), _ = t((t) => {
|
|
1862
|
+
if (!g?.isLoaded) return t;
|
|
1944
1863
|
let n = [];
|
|
1945
1864
|
for (let r of t) {
|
|
1946
1865
|
if (!r?.name) {
|
|
1947
1866
|
n.push(r);
|
|
1948
1867
|
continue;
|
|
1949
1868
|
}
|
|
1950
|
-
|
|
1869
|
+
g.checkField(e.objectName, r.name, "read") && (!g.checkField(e.objectName, r.name, "write") && e.mode !== "view" ? n.push({
|
|
1951
1870
|
...r,
|
|
1952
1871
|
readOnly: !0,
|
|
1953
1872
|
disabled: !0
|
|
@@ -1955,16 +1874,16 @@ var At = Z({
|
|
|
1955
1874
|
}
|
|
1956
1875
|
return n;
|
|
1957
1876
|
}, [
|
|
1958
|
-
|
|
1877
|
+
g,
|
|
1959
1878
|
e.objectName,
|
|
1960
1879
|
e.mode
|
|
1961
|
-
]), [
|
|
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(() => {
|
|
1962
1881
|
if (e.sections?.length || e.customFields?.length) return null;
|
|
1963
|
-
let t =
|
|
1964
|
-
e.mode === "create" && (t =
|
|
1965
|
-
let n =
|
|
1882
|
+
let t = Ne(j, y);
|
|
1883
|
+
e.mode === "create" && (t = Fe(t, y));
|
|
1884
|
+
let n = Ot(t, y?.fieldGroups);
|
|
1966
1885
|
if (!n) return null;
|
|
1967
|
-
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);
|
|
1968
1887
|
return n.map((e) => ({
|
|
1969
1888
|
...e,
|
|
1970
1889
|
columns: r
|
|
@@ -1975,61 +1894,61 @@ var At = Z({
|
|
|
1975
1894
|
e.columns,
|
|
1976
1895
|
e.mode,
|
|
1977
1896
|
j,
|
|
1978
|
-
|
|
1979
|
-
]), 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), [
|
|
1980
1899
|
j,
|
|
1981
|
-
|
|
1900
|
+
y,
|
|
1982
1901
|
e.columns,
|
|
1983
1902
|
e.mode,
|
|
1984
1903
|
J,
|
|
1985
1904
|
e.customFields
|
|
1986
|
-
]), he =
|
|
1905
|
+
]), he = At[a(() => {
|
|
1987
1906
|
if (e.modalSize) return e.modalSize;
|
|
1988
|
-
if (
|
|
1907
|
+
if (Y?.columns && Y.columns > 1) return ze(Y.columns);
|
|
1989
1908
|
if (J?.length) {
|
|
1990
1909
|
let e = Math.max(...J.map((e) => Number(e.columns) || 1));
|
|
1991
|
-
if (e > 1) return
|
|
1910
|
+
if (e > 1) return ze(e);
|
|
1992
1911
|
}
|
|
1993
1912
|
return "default";
|
|
1994
1913
|
}, [
|
|
1995
1914
|
e.modalSize,
|
|
1996
|
-
|
|
1915
|
+
Y,
|
|
1997
1916
|
J
|
|
1998
|
-
])] ||
|
|
1917
|
+
])] || At.default;
|
|
1999
1918
|
r(() => {
|
|
2000
1919
|
(async () => {
|
|
2001
1920
|
if (!n) {
|
|
2002
|
-
|
|
1921
|
+
B(!1);
|
|
2003
1922
|
return;
|
|
2004
1923
|
}
|
|
2005
1924
|
try {
|
|
2006
1925
|
let t = await n.getObjectSchema(e.objectName);
|
|
2007
1926
|
A(t);
|
|
2008
1927
|
} catch (e) {
|
|
2009
|
-
|
|
1928
|
+
H(e), B(!1);
|
|
2010
1929
|
}
|
|
2011
1930
|
})();
|
|
2012
1931
|
}, [e.objectName, n]), r(() => {
|
|
2013
|
-
(
|
|
1932
|
+
(y || !n) && (async () => {
|
|
2014
1933
|
if (e.mode === "create" || !e.recordId) {
|
|
2015
|
-
|
|
1934
|
+
P(e.initialData || e.initialValues || {}), B(!1);
|
|
2016
1935
|
return;
|
|
2017
1936
|
}
|
|
2018
1937
|
if (!n) {
|
|
2019
|
-
|
|
1938
|
+
P(e.initialData || e.initialValues || {}), B(!1);
|
|
2020
1939
|
return;
|
|
2021
1940
|
}
|
|
2022
1941
|
try {
|
|
2023
1942
|
let t = await n.findOne(e.objectName, e.recordId);
|
|
2024
|
-
|
|
1943
|
+
P(t || {});
|
|
2025
1944
|
} catch (e) {
|
|
2026
|
-
|
|
1945
|
+
H(e);
|
|
2027
1946
|
} finally {
|
|
2028
|
-
|
|
1947
|
+
B(!1);
|
|
2029
1948
|
}
|
|
2030
1949
|
})();
|
|
2031
1950
|
}, [
|
|
2032
|
-
|
|
1951
|
+
y,
|
|
2033
1952
|
e.mode,
|
|
2034
1953
|
e.recordId,
|
|
2035
1954
|
e.initialData,
|
|
@@ -2037,44 +1956,44 @@ var At = Z({
|
|
|
2037
1956
|
n,
|
|
2038
1957
|
e.objectName
|
|
2039
1958
|
]);
|
|
2040
|
-
let ge = t((t) =>
|
|
2041
|
-
objectSchema:
|
|
1959
|
+
let ge = t((t) => Se(t, {
|
|
1960
|
+
objectSchema: y,
|
|
2042
1961
|
objectName: e.objectName,
|
|
2043
1962
|
readOnly: e.readOnly,
|
|
2044
1963
|
mode: e.mode,
|
|
2045
|
-
fieldLabel:
|
|
1964
|
+
fieldLabel: l
|
|
2046
1965
|
}), [
|
|
2047
|
-
|
|
1966
|
+
y,
|
|
2048
1967
|
e.readOnly,
|
|
2049
1968
|
e.mode,
|
|
2050
1969
|
e.objectName,
|
|
2051
|
-
|
|
1970
|
+
l
|
|
2052
1971
|
]);
|
|
2053
1972
|
r(() => {
|
|
2054
|
-
if (!
|
|
1973
|
+
if (!y && n) return;
|
|
2055
1974
|
if (e.customFields?.length) {
|
|
2056
|
-
M(e.customFields),
|
|
1975
|
+
M(e.customFields), B(!1);
|
|
2057
1976
|
return;
|
|
2058
1977
|
}
|
|
2059
1978
|
if (e.sections?.length) {
|
|
2060
|
-
|
|
1979
|
+
B(!1);
|
|
2061
1980
|
return;
|
|
2062
1981
|
}
|
|
2063
|
-
if (!
|
|
2064
|
-
let t = e.fields || Object.keys(
|
|
1982
|
+
if (!y) return;
|
|
1983
|
+
let t = e.fields || Object.keys(y.fields || {}), r = [];
|
|
2065
1984
|
for (let n of t) {
|
|
2066
1985
|
let t = typeof n == "string" ? n : n.name;
|
|
2067
1986
|
if (!t) continue;
|
|
2068
|
-
let i =
|
|
1987
|
+
let i = y.fields?.[t];
|
|
2069
1988
|
i && r.push({
|
|
2070
1989
|
name: t,
|
|
2071
|
-
label:
|
|
2072
|
-
type:
|
|
1990
|
+
label: l(e.objectName, t, i.label || t),
|
|
1991
|
+
type: b(i.type),
|
|
2073
1992
|
required: i.required || !1,
|
|
2074
1993
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
2075
1994
|
placeholder: i.placeholder,
|
|
2076
1995
|
description: i.help || i.description,
|
|
2077
|
-
validation:
|
|
1996
|
+
validation: v(i),
|
|
2078
1997
|
field: i,
|
|
2079
1998
|
options: i.options,
|
|
2080
1999
|
multiple: i.multiple,
|
|
@@ -2084,9 +2003,9 @@ var At = Z({
|
|
|
2084
2003
|
group: i.group
|
|
2085
2004
|
});
|
|
2086
2005
|
}
|
|
2087
|
-
M(r),
|
|
2006
|
+
M(r), B(!1);
|
|
2088
2007
|
}, [
|
|
2089
|
-
|
|
2008
|
+
y,
|
|
2090
2009
|
e.fields,
|
|
2091
2010
|
e.customFields,
|
|
2092
2011
|
e.sections,
|
|
@@ -2095,90 +2014,90 @@ var At = Z({
|
|
|
2095
2014
|
n
|
|
2096
2015
|
]);
|
|
2097
2016
|
let _e = t(async (t) => {
|
|
2098
|
-
|
|
2017
|
+
W(!0);
|
|
2099
2018
|
try {
|
|
2100
2019
|
if (!n) return e.onSuccess && await e.onSuccess(t), e.onOpenChange?.(!1), t;
|
|
2101
|
-
let r, i =
|
|
2102
|
-
if (
|
|
2020
|
+
let r, i = Ke(t, y);
|
|
2021
|
+
if (g?.isLoaded) {
|
|
2103
2022
|
let t = {};
|
|
2104
|
-
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]);
|
|
2105
2024
|
i = t;
|
|
2106
2025
|
}
|
|
2107
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;
|
|
2108
2027
|
} catch (t) {
|
|
2109
2028
|
throw e.onError && e.onError(t), t;
|
|
2110
2029
|
} finally {
|
|
2111
|
-
|
|
2030
|
+
W(!1);
|
|
2112
2031
|
}
|
|
2113
2032
|
}, [
|
|
2114
2033
|
e,
|
|
2115
2034
|
n,
|
|
2116
|
-
|
|
2117
|
-
|
|
2035
|
+
y,
|
|
2036
|
+
g
|
|
2118
2037
|
]), Q = t(() => {
|
|
2119
|
-
|
|
2120
|
-
}, [e]),
|
|
2121
|
-
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();
|
|
2122
2041
|
}, [
|
|
2123
2042
|
ue,
|
|
2124
|
-
|
|
2043
|
+
te,
|
|
2125
2044
|
Q
|
|
2126
|
-
]),
|
|
2045
|
+
]), ye = t(() => {
|
|
2127
2046
|
q.current = !0, Q();
|
|
2128
|
-
}, [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 = {
|
|
2129
2048
|
type: "form",
|
|
2130
2049
|
objectName: e.objectName,
|
|
2131
|
-
layout:
|
|
2132
|
-
defaultValues:
|
|
2133
|
-
submitLabel:
|
|
2134
|
-
cancelLabel:
|
|
2135
|
-
showSubmit:
|
|
2136
|
-
showCancel:
|
|
2050
|
+
layout: be,
|
|
2051
|
+
defaultValues: N,
|
|
2052
|
+
submitLabel: we,
|
|
2053
|
+
cancelLabel: Te,
|
|
2054
|
+
showSubmit: xe,
|
|
2055
|
+
showCancel: Ce,
|
|
2137
2056
|
onSubmit: _e,
|
|
2138
|
-
onCancel:
|
|
2139
|
-
onDirtyChange:
|
|
2057
|
+
onCancel: ye,
|
|
2058
|
+
onDirtyChange: ne,
|
|
2140
2059
|
showActions: !1,
|
|
2141
|
-
id:
|
|
2142
|
-
},
|
|
2143
|
-
if (
|
|
2060
|
+
id: fe
|
|
2061
|
+
}, De = () => {
|
|
2062
|
+
if (V) return /* @__PURE__ */ Z("div", {
|
|
2144
2063
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
2145
|
-
children: [/* @__PURE__ */
|
|
2064
|
+
children: [/* @__PURE__ */ X("h3", {
|
|
2146
2065
|
className: "text-red-800 font-semibold",
|
|
2147
2066
|
children: "Error loading form"
|
|
2148
|
-
}), /* @__PURE__ */
|
|
2067
|
+
}), /* @__PURE__ */ X("p", {
|
|
2149
2068
|
className: "text-red-600 text-sm mt-1",
|
|
2150
|
-
children:
|
|
2069
|
+
children: V.message
|
|
2151
2070
|
})]
|
|
2152
2071
|
});
|
|
2153
|
-
if (
|
|
2072
|
+
if (z) return /* @__PURE__ */ X("div", {
|
|
2154
2073
|
className: "space-y-4",
|
|
2155
2074
|
"data-testid": "modal-form-skeleton",
|
|
2156
2075
|
children: [
|
|
2157
2076
|
1,
|
|
2158
2077
|
2,
|
|
2159
2078
|
3
|
|
2160
|
-
].map((e) => /* @__PURE__ */
|
|
2079
|
+
].map((e) => /* @__PURE__ */ Z("div", {
|
|
2161
2080
|
className: "space-y-2",
|
|
2162
|
-
children: [/* @__PURE__ */
|
|
2081
|
+
children: [/* @__PURE__ */ X(re, { className: "h-4 w-24" }), /* @__PURE__ */ X(re, { className: "h-10 w-full" })]
|
|
2163
2082
|
}, e))
|
|
2164
2083
|
});
|
|
2165
2084
|
if (e.sections?.length) {
|
|
2166
|
-
let t = e.sections, n = (e, t) => e.name || e.label || String(t), r = (t) => t.name ?
|
|
2167
|
-
...
|
|
2168
|
-
...
|
|
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)
|
|
2169
2088
|
} });
|
|
2170
|
-
return e.contentLayout === "tabbed" && t.length > 1 ? /* @__PURE__ */
|
|
2089
|
+
return e.contentLayout === "tabbed" && t.length > 1 ? /* @__PURE__ */ Z(ie, {
|
|
2171
2090
|
defaultValue: n(t[0], 0),
|
|
2172
2091
|
className: "w-full",
|
|
2173
|
-
children: [/* @__PURE__ */
|
|
2092
|
+
children: [/* @__PURE__ */ X(oe, {
|
|
2174
2093
|
className: "mb-4",
|
|
2175
|
-
children: t.map((e, t) => /* @__PURE__ */
|
|
2094
|
+
children: t.map((e, t) => /* @__PURE__ */ X(se, {
|
|
2176
2095
|
value: n(e, t),
|
|
2177
2096
|
children: r(e) || `Section ${t + 1}`
|
|
2178
2097
|
}, n(e, t)))
|
|
2179
|
-
}), t.map((e, t) => /* @__PURE__ */
|
|
2098
|
+
}), t.map((e, t) => /* @__PURE__ */ X(ae, {
|
|
2180
2099
|
value: n(e, t),
|
|
2181
|
-
children: /* @__PURE__ */
|
|
2100
|
+
children: /* @__PURE__ */ X($, {
|
|
2182
2101
|
description: e.description,
|
|
2183
2102
|
columns: 1,
|
|
2184
2103
|
className: e.className,
|
|
@@ -2186,9 +2105,9 @@ var At = Z({
|
|
|
2186
2105
|
children: i(e)
|
|
2187
2106
|
})
|
|
2188
2107
|
}, n(e, t)))]
|
|
2189
|
-
}) : /* @__PURE__ */
|
|
2108
|
+
}) : /* @__PURE__ */ X("div", {
|
|
2190
2109
|
className: "space-y-6",
|
|
2191
|
-
children: t.map((e, t) => /* @__PURE__ */
|
|
2110
|
+
children: t.map((e, t) => /* @__PURE__ */ X($, {
|
|
2192
2111
|
label: r(e),
|
|
2193
2112
|
description: e.description,
|
|
2194
2113
|
columns: 1,
|
|
@@ -2198,61 +2117,61 @@ var At = Z({
|
|
|
2198
2117
|
}, n(e, t)))
|
|
2199
2118
|
});
|
|
2200
2119
|
}
|
|
2201
|
-
if (
|
|
2202
|
-
let t = Number(
|
|
2203
|
-
|
|
2204
|
-
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));
|
|
2205
2124
|
if (!a.length) return;
|
|
2206
|
-
let o = r.name ?
|
|
2125
|
+
let o = r.name ? u(e.objectName, r.name, r.label || r.name) : r.label;
|
|
2207
2126
|
o && n.push({
|
|
2208
2127
|
name: `__section_${r.name || i}`,
|
|
2209
2128
|
label: o,
|
|
2210
2129
|
type: "section-divider"
|
|
2211
|
-
}), n.push(...t > 1 ?
|
|
2130
|
+
}), n.push(...t > 1 ? je(a, t) : a);
|
|
2212
2131
|
});
|
|
2213
|
-
let r =
|
|
2214
|
-
return /* @__PURE__ */
|
|
2215
|
-
...
|
|
2132
|
+
let r = Ie[t];
|
|
2133
|
+
return /* @__PURE__ */ X(d, { schema: {
|
|
2134
|
+
...Ee,
|
|
2216
2135
|
fields: n,
|
|
2217
2136
|
columns: t,
|
|
2218
2137
|
...r ? { fieldContainerClass: r } : {}
|
|
2219
2138
|
} });
|
|
2220
2139
|
}
|
|
2221
|
-
let t =
|
|
2222
|
-
return /* @__PURE__ */
|
|
2223
|
-
...
|
|
2224
|
-
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),
|
|
2225
2144
|
columns: t.columns,
|
|
2226
2145
|
...n ? { fieldContainerClass: n } : {}
|
|
2227
2146
|
} });
|
|
2228
|
-
},
|
|
2229
|
-
if (
|
|
2147
|
+
}, ke = e.subforms;
|
|
2148
|
+
if (m) return /* @__PURE__ */ Z("div", {
|
|
2230
2149
|
className: "@container rounded-md border bg-card p-4",
|
|
2231
|
-
children: [(e.title || e.description) && /* @__PURE__ */
|
|
2150
|
+
children: [(e.title || e.description) && /* @__PURE__ */ Z("div", {
|
|
2232
2151
|
className: "mb-3 space-y-0.5",
|
|
2233
|
-
children: [e.title && /* @__PURE__ */
|
|
2152
|
+
children: [e.title && /* @__PURE__ */ X("div", {
|
|
2234
2153
|
className: "text-sm font-semibold",
|
|
2235
2154
|
children: e.title
|
|
2236
|
-
}), e.description && /* @__PURE__ */
|
|
2155
|
+
}), e.description && /* @__PURE__ */ X("p", {
|
|
2237
2156
|
className: "text-xs text-muted-foreground",
|
|
2238
2157
|
children: e.description
|
|
2239
2158
|
})]
|
|
2240
|
-
}),
|
|
2159
|
+
}), De()]
|
|
2241
2160
|
});
|
|
2242
|
-
if (
|
|
2161
|
+
if (ke?.length && e.mode !== "view") return /* @__PURE__ */ X(F, {
|
|
2243
2162
|
open: de,
|
|
2244
2163
|
onOpenChange: e.onOpenChange,
|
|
2245
|
-
children: /* @__PURE__ */
|
|
2164
|
+
children: /* @__PURE__ */ Z(R, {
|
|
2246
2165
|
className: G(he, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", c, e.className),
|
|
2247
|
-
children: [(e.title || e.description) && /* @__PURE__ */
|
|
2166
|
+
children: [(e.title || e.description) && /* @__PURE__ */ Z(L, {
|
|
2248
2167
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
2249
|
-
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, {
|
|
2250
2169
|
className: "sr-only",
|
|
2251
2170
|
children: "Enter the record and its line items, then save."
|
|
2252
2171
|
})]
|
|
2253
|
-
}), /* @__PURE__ */
|
|
2172
|
+
}), /* @__PURE__ */ X("div", {
|
|
2254
2173
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
2255
|
-
children: /* @__PURE__ */
|
|
2174
|
+
children: /* @__PURE__ */ X(wt, {
|
|
2256
2175
|
schema: {
|
|
2257
2176
|
type: "object-master-detail-form",
|
|
2258
2177
|
objectName: e.objectName,
|
|
@@ -2262,9 +2181,9 @@ var At = Z({
|
|
|
2262
2181
|
sections: e.sections,
|
|
2263
2182
|
initialValues: e.initialValues,
|
|
2264
2183
|
initialData: e.initialData,
|
|
2265
|
-
submitText:
|
|
2266
|
-
cancelText:
|
|
2267
|
-
details:
|
|
2184
|
+
submitText: we,
|
|
2185
|
+
cancelText: Te,
|
|
2186
|
+
details: ke,
|
|
2268
2187
|
onSuccess: async (t) => {
|
|
2269
2188
|
await e.onSuccess?.(t), e.onOpenChange?.(!1);
|
|
2270
2189
|
},
|
|
@@ -2276,69 +2195,69 @@ var At = Z({
|
|
|
2276
2195
|
})]
|
|
2277
2196
|
})
|
|
2278
2197
|
});
|
|
2279
|
-
let
|
|
2280
|
-
return /* @__PURE__ */
|
|
2198
|
+
let Ae = !z && !V && (xe || Ce);
|
|
2199
|
+
return /* @__PURE__ */ X(F, {
|
|
2281
2200
|
open: de,
|
|
2282
2201
|
onOpenChange: (t) => {
|
|
2283
2202
|
if (t) {
|
|
2284
2203
|
e.onOpenChange?.(!0);
|
|
2285
2204
|
return;
|
|
2286
2205
|
}
|
|
2287
|
-
|
|
2206
|
+
ve(!1);
|
|
2288
2207
|
},
|
|
2289
|
-
children: /* @__PURE__ */
|
|
2208
|
+
children: /* @__PURE__ */ Z(R, {
|
|
2290
2209
|
className: G(he, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", c, e.className),
|
|
2291
2210
|
children: [
|
|
2292
|
-
(e.title || e.description) && /* @__PURE__ */
|
|
2211
|
+
(e.title || e.description) && /* @__PURE__ */ Z(L, {
|
|
2293
2212
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
2294
|
-
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, {
|
|
2295
2214
|
className: "sr-only",
|
|
2296
2215
|
children: "Complete the form fields, then submit or cancel."
|
|
2297
2216
|
})]
|
|
2298
2217
|
}),
|
|
2299
|
-
/* @__PURE__ */
|
|
2218
|
+
/* @__PURE__ */ X("div", {
|
|
2300
2219
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
2301
|
-
children:
|
|
2220
|
+
children: De()
|
|
2302
2221
|
}),
|
|
2303
|
-
|
|
2222
|
+
Ae && /* @__PURE__ */ X("div", {
|
|
2304
2223
|
className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background",
|
|
2305
2224
|
"data-testid": "modal-form-footer",
|
|
2306
|
-
children: /* @__PURE__ */
|
|
2225
|
+
children: /* @__PURE__ */ Z("div", {
|
|
2307
2226
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
2308
|
-
children: [
|
|
2227
|
+
children: [Ce && /* @__PURE__ */ X(k, {
|
|
2309
2228
|
type: "button",
|
|
2310
2229
|
variant: "outline",
|
|
2311
|
-
onClick:
|
|
2312
|
-
disabled:
|
|
2230
|
+
onClick: ye,
|
|
2231
|
+
disabled: U,
|
|
2313
2232
|
className: "w-full sm:w-auto",
|
|
2314
|
-
children:
|
|
2315
|
-
}),
|
|
2233
|
+
children: Te
|
|
2234
|
+
}), xe && /* @__PURE__ */ Z(k, {
|
|
2316
2235
|
type: "submit",
|
|
2317
|
-
form:
|
|
2318
|
-
disabled:
|
|
2236
|
+
form: fe,
|
|
2237
|
+
disabled: U,
|
|
2319
2238
|
className: "w-full sm:w-auto",
|
|
2320
|
-
children: [
|
|
2239
|
+
children: [U && /* @__PURE__ */ X(me, { className: "mr-2 h-4 w-4 animate-spin" }), we]
|
|
2321
2240
|
})]
|
|
2322
2241
|
})
|
|
2323
2242
|
}),
|
|
2324
|
-
/* @__PURE__ */
|
|
2325
|
-
open:
|
|
2326
|
-
onOpenChange:
|
|
2327
|
-
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, {
|
|
2328
2247
|
onClick: () => {
|
|
2329
2248
|
q.current = !1;
|
|
2330
2249
|
},
|
|
2331
|
-
children:
|
|
2332
|
-
}), /* @__PURE__ */
|
|
2250
|
+
children: f("form.keepEditing")
|
|
2251
|
+
}), /* @__PURE__ */ X(S, {
|
|
2333
2252
|
onClick: Q,
|
|
2334
|
-
children:
|
|
2253
|
+
children: f("form.discard")
|
|
2335
2254
|
})] })] })
|
|
2336
2255
|
})
|
|
2337
2256
|
]
|
|
2338
2257
|
})
|
|
2339
2258
|
});
|
|
2340
|
-
},
|
|
2341
|
-
let n =
|
|
2259
|
+
}, Mt = ({ schema: e, dataSource: t }) => {
|
|
2260
|
+
let n = le(), r = a(() => {
|
|
2342
2261
|
let t = e.groups, r = !e.sections?.length && Array.isArray(t) && t.length ? {
|
|
2343
2262
|
...e,
|
|
2344
2263
|
sections: t.map((e) => ({
|
|
@@ -2363,8 +2282,8 @@ var At = Z({
|
|
|
2363
2282
|
fields: a(e.fields)
|
|
2364
2283
|
}))
|
|
2365
2284
|
};
|
|
2366
|
-
}, [e, n]), { sectionLabel: i } =
|
|
2367
|
-
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, {
|
|
2368
2287
|
schema: {
|
|
2369
2288
|
type: "object-master-detail-form",
|
|
2370
2289
|
objectName: r.objectName,
|
|
@@ -2387,7 +2306,7 @@ var At = Z({
|
|
|
2387
2306
|
},
|
|
2388
2307
|
dataSource: t
|
|
2389
2308
|
});
|
|
2390
|
-
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */
|
|
2309
|
+
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ X(Ve, {
|
|
2391
2310
|
schema: {
|
|
2392
2311
|
...r,
|
|
2393
2312
|
formType: "tabbed",
|
|
@@ -2406,7 +2325,7 @@ var At = Z({
|
|
|
2406
2325
|
dataSource: t,
|
|
2407
2326
|
className: r.className
|
|
2408
2327
|
});
|
|
2409
|
-
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */
|
|
2328
|
+
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ X(He, {
|
|
2410
2329
|
schema: {
|
|
2411
2330
|
...r,
|
|
2412
2331
|
formType: "wizard",
|
|
@@ -2428,7 +2347,7 @@ var At = Z({
|
|
|
2428
2347
|
dataSource: t,
|
|
2429
2348
|
className: r.className
|
|
2430
2349
|
});
|
|
2431
|
-
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */
|
|
2350
|
+
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ X(Ue, {
|
|
2432
2351
|
schema: {
|
|
2433
2352
|
...r,
|
|
2434
2353
|
formType: "split",
|
|
@@ -2450,7 +2369,7 @@ var At = Z({
|
|
|
2450
2369
|
});
|
|
2451
2370
|
if (r.formType === "drawer") {
|
|
2452
2371
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
2453
|
-
return /* @__PURE__ */
|
|
2372
|
+
return /* @__PURE__ */ X(Dt, {
|
|
2454
2373
|
schema: {
|
|
2455
2374
|
...n,
|
|
2456
2375
|
layout: i,
|
|
@@ -2476,7 +2395,7 @@ var At = Z({
|
|
|
2476
2395
|
}
|
|
2477
2396
|
if (r.formType === "modal") {
|
|
2478
2397
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
2479
|
-
return /* @__PURE__ */
|
|
2398
|
+
return /* @__PURE__ */ X(jt, {
|
|
2480
2399
|
schema: {
|
|
2481
2400
|
...n,
|
|
2482
2401
|
layout: i,
|
|
@@ -2499,12 +2418,12 @@ var At = Z({
|
|
|
2499
2418
|
className: r.className
|
|
2500
2419
|
});
|
|
2501
2420
|
}
|
|
2502
|
-
return /* @__PURE__ */
|
|
2421
|
+
return /* @__PURE__ */ X(Nt, {
|
|
2503
2422
|
schema: r,
|
|
2504
2423
|
dataSource: t
|
|
2505
2424
|
});
|
|
2506
|
-
},
|
|
2507
|
-
let { fieldLabel: a, sectionLabel: o } =
|
|
2425
|
+
}, Nt = ({ schema: n, dataSource: i }) => {
|
|
2426
|
+
let { fieldLabel: a, sectionLabel: o } = h(), c = ce(), u = le(), f = t((e) => {
|
|
2508
2427
|
if (!u?.isLoaded) return e;
|
|
2509
2428
|
let t = [];
|
|
2510
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({
|
|
@@ -2518,15 +2437,15 @@ var At = Z({
|
|
|
2518
2437
|
u,
|
|
2519
2438
|
n.objectName,
|
|
2520
2439
|
n.mode
|
|
2521
|
-
]), [
|
|
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;
|
|
2522
2441
|
r(() => {
|
|
2523
|
-
|
|
2442
|
+
k && (S(n.initialData || n.initialValues || {}), w(!1));
|
|
2524
2443
|
}, [
|
|
2525
|
-
|
|
2444
|
+
k,
|
|
2526
2445
|
n.initialData,
|
|
2527
2446
|
n.initialValues
|
|
2528
2447
|
]), r(() => {
|
|
2529
|
-
|
|
2448
|
+
k ? m({
|
|
2530
2449
|
name: n.objectName,
|
|
2531
2450
|
fields: {}
|
|
2532
2451
|
}) : n.objectName && i ? (async () => {
|
|
@@ -2536,32 +2455,32 @@ var At = Z({
|
|
|
2536
2455
|
if (!e) throw Error(`No schema found for object "${n.objectName}"`);
|
|
2537
2456
|
m(e);
|
|
2538
2457
|
} catch (e) {
|
|
2539
|
-
|
|
2458
|
+
E(e), w(!1);
|
|
2540
2459
|
}
|
|
2541
|
-
})() :
|
|
2460
|
+
})() : k || w(!1);
|
|
2542
2461
|
}, [
|
|
2543
2462
|
n.objectName,
|
|
2544
2463
|
i,
|
|
2545
|
-
|
|
2464
|
+
k
|
|
2546
2465
|
]), r(() => {
|
|
2547
|
-
|
|
2466
|
+
p && !k && (async () => {
|
|
2548
2467
|
if (!n.recordId || n.mode === "create") {
|
|
2549
|
-
|
|
2468
|
+
S(n.initialData || n.initialValues || {}), w(!1);
|
|
2550
2469
|
return;
|
|
2551
2470
|
}
|
|
2552
|
-
if (!
|
|
2471
|
+
if (!k) {
|
|
2553
2472
|
if (!i) {
|
|
2554
|
-
|
|
2473
|
+
E(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), w(!1);
|
|
2555
2474
|
return;
|
|
2556
2475
|
}
|
|
2557
|
-
|
|
2476
|
+
w(!0);
|
|
2558
2477
|
try {
|
|
2559
2478
|
let e = await i.findOne(n.objectName, n.recordId);
|
|
2560
|
-
|
|
2479
|
+
S(e);
|
|
2561
2480
|
} catch (e) {
|
|
2562
|
-
console.error("Failed to fetch record:", e),
|
|
2481
|
+
console.error("Failed to fetch record:", e), E(e);
|
|
2563
2482
|
} finally {
|
|
2564
|
-
|
|
2483
|
+
w(!1);
|
|
2565
2484
|
}
|
|
2566
2485
|
}
|
|
2567
2486
|
})();
|
|
@@ -2572,64 +2491,64 @@ var At = Z({
|
|
|
2572
2491
|
n.initialValues,
|
|
2573
2492
|
n.initialData,
|
|
2574
2493
|
i,
|
|
2575
|
-
|
|
2576
|
-
|
|
2494
|
+
p,
|
|
2495
|
+
k
|
|
2577
2496
|
]);
|
|
2578
|
-
let
|
|
2497
|
+
let A = t((e) => e, []);
|
|
2579
2498
|
r(() => {
|
|
2580
|
-
if (
|
|
2581
|
-
|
|
2499
|
+
if (k && n.customFields) {
|
|
2500
|
+
_(n.customFields.map(A)), w(!1);
|
|
2582
2501
|
return;
|
|
2583
2502
|
}
|
|
2584
|
-
if (!
|
|
2585
|
-
let e = [], t =
|
|
2586
|
-
(Array.isArray(
|
|
2587
|
-
let
|
|
2588
|
-
if (!
|
|
2589
|
-
let
|
|
2590
|
-
if (!
|
|
2591
|
-
let
|
|
2592
|
-
if (n.mode !== "view" && !
|
|
2593
|
-
let
|
|
2594
|
-
if (
|
|
2595
|
-
else if (
|
|
2596
|
-
let
|
|
2597
|
-
name:
|
|
2598
|
-
label: a(n.objectName,
|
|
2599
|
-
type:
|
|
2600
|
-
required:
|
|
2601
|
-
disabled: n.readOnly || n.mode === "view" ||
|
|
2602
|
-
placeholder:
|
|
2603
|
-
description:
|
|
2604
|
-
validation:
|
|
2605
|
-
visibleWhen:
|
|
2606
|
-
readonlyWhen:
|
|
2607
|
-
requiredWhen:
|
|
2608
|
-
group:
|
|
2609
|
-
field:
|
|
2610
|
-
widget:
|
|
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;
|
|
2511
|
+
if (n.mode !== "view" && !s) return;
|
|
2512
|
+
let c = n.customFields?.find((e) => e.name === i);
|
|
2513
|
+
if (c) e.push(A(c));
|
|
2514
|
+
else if (o) {
|
|
2515
|
+
let s = {
|
|
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
|
|
2611
2530
|
};
|
|
2612
|
-
if ((
|
|
2613
|
-
let e = `Max size: ${
|
|
2614
|
-
|
|
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)}`;
|
|
2533
|
+
s.description = s.description ? `${s.description} (${e})` : e;
|
|
2615
2534
|
}
|
|
2616
|
-
|
|
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);
|
|
2617
2536
|
}
|
|
2618
|
-
}),
|
|
2537
|
+
}), _(e), !k && n.recordId && n.mode !== "create" && i || w(!1);
|
|
2619
2538
|
}, [
|
|
2620
|
-
|
|
2539
|
+
p,
|
|
2621
2540
|
n.fields,
|
|
2622
2541
|
n.customFields,
|
|
2623
2542
|
n.readOnly,
|
|
2624
2543
|
n.mode,
|
|
2625
|
-
|
|
2544
|
+
k,
|
|
2626
2545
|
n.recordId,
|
|
2627
2546
|
i
|
|
2628
2547
|
]);
|
|
2629
|
-
let
|
|
2630
|
-
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;
|
|
2631
2550
|
if (!i) throw Error("DataSource is required for form submission (inline mode not configured)");
|
|
2632
|
-
let r =
|
|
2551
|
+
let r = Ke(e, k ? null : p);
|
|
2633
2552
|
if (u?.isLoaded && r && typeof r == "object") {
|
|
2634
2553
|
let e = {};
|
|
2635
2554
|
for (let t of Object.keys(r)) u.checkField(n.objectName, t, "write") && (e[t] = r[t]);
|
|
@@ -2646,12 +2565,12 @@ var At = Z({
|
|
|
2646
2565
|
let e = n.submitBehavior;
|
|
2647
2566
|
switch (e.kind) {
|
|
2648
2567
|
case "redirect":
|
|
2649
|
-
|
|
2568
|
+
Q(e.url) && setTimeout(() => window.location.assign(e.url), e.delayMs ?? 0);
|
|
2650
2569
|
break;
|
|
2651
2570
|
case "continue": break;
|
|
2652
2571
|
default: {
|
|
2653
2572
|
let t = e.kind === "thank-you" && e.message ? e.message : n.successMessage || (n.mode === "create" ? "Created" : "Saved");
|
|
2654
|
-
K.success(t),
|
|
2573
|
+
K.success(t), O({
|
|
2655
2574
|
title: e.kind === "thank-you" ? e.title : void 0,
|
|
2656
2575
|
message: t
|
|
2657
2576
|
});
|
|
@@ -2659,7 +2578,7 @@ var At = Z({
|
|
|
2659
2578
|
}
|
|
2660
2579
|
}
|
|
2661
2580
|
} else if (!n.submitHandler) {
|
|
2662
|
-
let t =
|
|
2581
|
+
let t = ve(n.navigateOnSuccess, e);
|
|
2663
2582
|
if (t) return window.location.assign(t), e;
|
|
2664
2583
|
K.success(n.successMessage || (n.mode === "create" ? "Created" : "Saved"));
|
|
2665
2584
|
}
|
|
@@ -2670,132 +2589,132 @@ var At = Z({
|
|
|
2670
2589
|
}, [
|
|
2671
2590
|
n,
|
|
2672
2591
|
i,
|
|
2673
|
-
|
|
2592
|
+
k,
|
|
2674
2593
|
u,
|
|
2675
|
-
|
|
2676
|
-
]),
|
|
2594
|
+
p
|
|
2595
|
+
]), M = t(() => {
|
|
2677
2596
|
n.onCancel && n.onCancel();
|
|
2678
|
-
}, [n]),
|
|
2597
|
+
}, [n]), N = {
|
|
2679
2598
|
...e.useMemo(() => {
|
|
2680
|
-
if (!
|
|
2599
|
+
if (!p?.fields) return {};
|
|
2681
2600
|
let e = {};
|
|
2682
|
-
return Object.keys(
|
|
2683
|
-
let n =
|
|
2601
|
+
return Object.keys(p.fields).forEach((t) => {
|
|
2602
|
+
let n = p.fields[t];
|
|
2684
2603
|
n.defaultValue !== void 0 && (e[t] = n.defaultValue);
|
|
2685
2604
|
}), e;
|
|
2686
|
-
}, [
|
|
2687
|
-
...
|
|
2688
|
-
},
|
|
2689
|
-
let e =
|
|
2690
|
-
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;
|
|
2691
2610
|
}, [
|
|
2692
|
-
|
|
2693
|
-
|
|
2611
|
+
g,
|
|
2612
|
+
p,
|
|
2694
2613
|
n.mode
|
|
2695
|
-
]),
|
|
2614
|
+
]), F = e.useMemo(() => n.sections?.length ? null : Ot(P, p?.fieldGroups), [
|
|
2696
2615
|
n.sections,
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
]),
|
|
2700
|
-
if (
|
|
2616
|
+
P,
|
|
2617
|
+
p
|
|
2618
|
+
]), I = n.sections?.length ? n.sections : F, [L, ee] = s({});
|
|
2619
|
+
if (T) return /* @__PURE__ */ Z("div", {
|
|
2701
2620
|
className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
|
|
2702
|
-
children: [/* @__PURE__ */
|
|
2621
|
+
children: [/* @__PURE__ */ X("h3", {
|
|
2703
2622
|
className: "text-red-800 font-semibold",
|
|
2704
2623
|
children: "Error loading form"
|
|
2705
|
-
}), /* @__PURE__ */
|
|
2624
|
+
}), /* @__PURE__ */ X("p", {
|
|
2706
2625
|
className: "text-red-600 text-sm mt-1",
|
|
2707
|
-
children:
|
|
2626
|
+
children: T.message
|
|
2708
2627
|
})]
|
|
2709
2628
|
});
|
|
2710
|
-
if (
|
|
2629
|
+
if (C) return /* @__PURE__ */ Z("div", {
|
|
2711
2630
|
className: "p-4 sm:p-8 text-center",
|
|
2712
|
-
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", {
|
|
2713
2632
|
className: "mt-2 text-sm text-gray-600",
|
|
2714
2633
|
children: "Loading form..."
|
|
2715
2634
|
})]
|
|
2716
2635
|
});
|
|
2717
|
-
if (
|
|
2636
|
+
if (D) return /* @__PURE__ */ Z("div", {
|
|
2718
2637
|
className: "rounded-md border bg-card p-6 sm:p-8 text-center",
|
|
2719
|
-
children: [/* @__PURE__ */
|
|
2638
|
+
children: [/* @__PURE__ */ X("h3", {
|
|
2720
2639
|
className: "text-lg font-semibold",
|
|
2721
|
-
children:
|
|
2722
|
-
}),
|
|
2640
|
+
children: D.title ?? "Thanks!"
|
|
2641
|
+
}), D.message && /* @__PURE__ */ X("p", {
|
|
2723
2642
|
className: "mt-2 text-sm text-muted-foreground",
|
|
2724
|
-
children:
|
|
2643
|
+
children: D.message
|
|
2725
2644
|
})]
|
|
2726
2645
|
});
|
|
2727
|
-
let
|
|
2728
|
-
if (
|
|
2729
|
-
let e =
|
|
2730
|
-
|
|
2731
|
-
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) => {
|
|
2732
2651
|
let t = c.get(e.name);
|
|
2733
2652
|
if (!t || typeof t != "object") return e;
|
|
2734
2653
|
let n = t, r = { ...e };
|
|
2735
2654
|
return n.visibleOn != null && (r.visibleOn = n.visibleOn), n.colSpan != null && (r.colSpan = n.colSpan), n.span != null && (r.span = n.span), r;
|
|
2736
2655
|
});
|
|
2737
2656
|
if (u.length === 0) return;
|
|
2738
|
-
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;
|
|
2739
2658
|
p && s.push({
|
|
2740
|
-
name: `__section_${
|
|
2659
|
+
name: `__section_${d}`,
|
|
2741
2660
|
label: p,
|
|
2742
2661
|
type: "section-divider",
|
|
2743
2662
|
colSpan: 4,
|
|
2744
2663
|
collapsible: r.collapsible,
|
|
2745
2664
|
collapsed: m,
|
|
2746
|
-
onToggle: r.collapsible ? () =>
|
|
2665
|
+
onToggle: r.collapsible ? () => ee((e) => ({
|
|
2747
2666
|
...e,
|
|
2748
|
-
[
|
|
2667
|
+
[d]: !m
|
|
2749
2668
|
})) : void 0,
|
|
2750
2669
|
className: r.className
|
|
2751
2670
|
});
|
|
2752
|
-
let h = t(r.columns), g = a > 1 ?
|
|
2671
|
+
let h = t(r.columns), g = a > 1 ? je(u, a, h) : u;
|
|
2753
2672
|
p && m ? s.push(...g.map((e) => ({
|
|
2754
2673
|
...e,
|
|
2755
2674
|
hidden: !0
|
|
2756
2675
|
}))) : s.push(...g);
|
|
2757
2676
|
});
|
|
2758
|
-
let c = s,
|
|
2759
|
-
return /* @__PURE__ */
|
|
2677
|
+
let c = s, l = Le(a);
|
|
2678
|
+
return /* @__PURE__ */ X("div", {
|
|
2760
2679
|
className: "w-full @container",
|
|
2761
|
-
children: /* @__PURE__ */
|
|
2680
|
+
children: /* @__PURE__ */ X(d, { schema: {
|
|
2762
2681
|
type: "form",
|
|
2763
2682
|
objectName: n.objectName,
|
|
2764
2683
|
fields: c,
|
|
2765
|
-
layout:
|
|
2684
|
+
layout: R,
|
|
2766
2685
|
columns: a,
|
|
2767
|
-
...
|
|
2768
|
-
defaultValues:
|
|
2686
|
+
...l ? { fieldContainerClass: l } : {},
|
|
2687
|
+
defaultValues: N,
|
|
2769
2688
|
showSubmit: n.showSubmit !== !1 && n.mode !== "view",
|
|
2770
2689
|
showCancel: n.showCancel !== !1,
|
|
2771
2690
|
submitLabel: n.submitText || (n.mode === "create" ? "Create" : "Update"),
|
|
2772
2691
|
cancelLabel: n.cancelText,
|
|
2773
|
-
onSubmit:
|
|
2774
|
-
onCancel:
|
|
2692
|
+
onSubmit: j,
|
|
2693
|
+
onCancel: M
|
|
2775
2694
|
} })
|
|
2776
2695
|
});
|
|
2777
2696
|
}
|
|
2778
|
-
let
|
|
2779
|
-
fields:
|
|
2697
|
+
let z = n.sections?.length, B = f(g), V = z ? {
|
|
2698
|
+
fields: B,
|
|
2780
2699
|
columns: n.columns
|
|
2781
|
-
} :
|
|
2700
|
+
} : Be(B, p, n.columns, n.mode), H = n.mobile, U = H?.fullscreenLongText ? V.fields.map((e) => {
|
|
2782
2701
|
let t = e.type;
|
|
2783
2702
|
return t === "textarea" || t === "field:textarea" || t === "string-multiline" || t === "field:markdown" || t === "field:html" ? {
|
|
2784
2703
|
...e,
|
|
2785
2704
|
mobile_fullscreen: !0
|
|
2786
2705
|
} : e;
|
|
2787
|
-
}) :
|
|
2788
|
-
if (!n.formType && !
|
|
2789
|
-
let e =
|
|
2790
|
-
for (let n = 0; n < e.length; n +=
|
|
2791
|
-
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);
|
|
2792
2711
|
t.push({
|
|
2793
|
-
name: `step-${Math.floor(n /
|
|
2794
|
-
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}`,
|
|
2795
2714
|
fields: r
|
|
2796
2715
|
});
|
|
2797
2716
|
}
|
|
2798
|
-
return /* @__PURE__ */
|
|
2717
|
+
return /* @__PURE__ */ X(He, {
|
|
2799
2718
|
schema: {
|
|
2800
2719
|
...n,
|
|
2801
2720
|
formType: "wizard",
|
|
@@ -2806,29 +2725,29 @@ var At = Z({
|
|
|
2806
2725
|
className: n.className
|
|
2807
2726
|
});
|
|
2808
2727
|
}
|
|
2809
|
-
let
|
|
2728
|
+
let re = {
|
|
2810
2729
|
type: "form",
|
|
2811
2730
|
objectName: n.objectName,
|
|
2812
|
-
fields:
|
|
2813
|
-
layout:
|
|
2814
|
-
columns:
|
|
2731
|
+
fields: U,
|
|
2732
|
+
layout: R,
|
|
2733
|
+
columns: V.columns,
|
|
2815
2734
|
submitLabel: n.submitText || (n.mode === "create" ? "Create" : "Update"),
|
|
2816
2735
|
cancelLabel: n.cancelText,
|
|
2817
2736
|
showSubmit: n.showSubmit !== !1 && n.mode !== "view",
|
|
2818
2737
|
showCancel: n.showCancel !== !1,
|
|
2819
2738
|
resetOnSubmit: n.showReset || n.submitBehavior?.kind === "continue" || !n.submitBehavior && n.resetOnSuccess && n.mode === "create",
|
|
2820
|
-
defaultValues:
|
|
2821
|
-
onSubmit:
|
|
2822
|
-
onCancel:
|
|
2739
|
+
defaultValues: N,
|
|
2740
|
+
onSubmit: j,
|
|
2741
|
+
onCancel: M,
|
|
2823
2742
|
className: n.className,
|
|
2824
|
-
mobileStickyActions: !!
|
|
2743
|
+
mobileStickyActions: !!H?.stickyActions
|
|
2825
2744
|
};
|
|
2826
|
-
return /* @__PURE__ */
|
|
2827
|
-
className:
|
|
2828
|
-
"data-mobile-form":
|
|
2829
|
-
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 })
|
|
2830
2749
|
});
|
|
2831
|
-
},
|
|
2750
|
+
}, Pt = {
|
|
2832
2751
|
text: 200,
|
|
2833
2752
|
email: 254,
|
|
2834
2753
|
url: 2048,
|
|
@@ -2836,8 +2755,8 @@ var At = Z({
|
|
|
2836
2755
|
textarea: 5e3,
|
|
2837
2756
|
markdown: 5e3,
|
|
2838
2757
|
html: 5e3
|
|
2839
|
-
},
|
|
2840
|
-
function
|
|
2758
|
+
}, Ft = "_company_website_2", It = 1500;
|
|
2759
|
+
function Lt(e, t = []) {
|
|
2841
2760
|
try {
|
|
2842
2761
|
let n = new URL(e, typeof window < "u" ? window.location.href : "http://localhost");
|
|
2843
2762
|
return typeof window < "u" && n.origin === window.location.origin ? !0 : n.protocol !== "https:" && n.protocol !== "http:" ? !1 : t.some((e) => {
|
|
@@ -2852,21 +2771,21 @@ function Rt(e, t = []) {
|
|
|
2852
2771
|
return !1;
|
|
2853
2772
|
}
|
|
2854
2773
|
}
|
|
2855
|
-
function
|
|
2774
|
+
function Rt(e) {
|
|
2856
2775
|
return e && e.map((e) => {
|
|
2857
|
-
let t =
|
|
2776
|
+
let t = Pt[String(e.type || "").toLowerCase()];
|
|
2858
2777
|
return !t || (e.maxLength ?? e.max_length) ? e : {
|
|
2859
2778
|
...e,
|
|
2860
2779
|
maxLength: t
|
|
2861
2780
|
};
|
|
2862
2781
|
});
|
|
2863
2782
|
}
|
|
2864
|
-
var
|
|
2783
|
+
var zt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
2865
2784
|
let [l, u] = s(!1), [d, f] = s(!1), [p, m] = s(null), [h, g] = s(!(e.consent?.required ?? !!e.consent)), [_, v] = s(null), y = o(null), b = o(0);
|
|
2866
2785
|
r(() => {
|
|
2867
2786
|
l || (b.current = Date.now());
|
|
2868
2787
|
}, [l]);
|
|
2869
|
-
let x = e.honeypot === !1 ? null : e.honeypot ||
|
|
2788
|
+
let x = e.honeypot === !1 ? null : e.honeypot || Ft, S = e.minFillTime ?? It, C = a(() => Rt(e.customFields), [e.customFields]), w = a(() => {
|
|
2870
2789
|
if (!n || C && C.length > 0 || !e.fields || e.fields.length === 0) return;
|
|
2871
2790
|
let t = async (e, t) => t;
|
|
2872
2791
|
return {
|
|
@@ -2907,7 +2826,7 @@ var Bt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
|
2907
2826
|
try {
|
|
2908
2827
|
n && await n.create(e.objectName, r), u(!0);
|
|
2909
2828
|
let t = e.thankYouPage?.redirectUrl;
|
|
2910
|
-
if (t) if (
|
|
2829
|
+
if (t) if (Lt(t, e.allowedRedirectHosts)) {
|
|
2911
2830
|
let n = e.thankYouPage?.redirectDelay ?? 3e3;
|
|
2912
2831
|
setTimeout(() => {
|
|
2913
2832
|
window.location.href = t;
|
|
@@ -2924,43 +2843,43 @@ var Bt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
|
2924
2843
|
h,
|
|
2925
2844
|
x,
|
|
2926
2845
|
S
|
|
2927
|
-
]),
|
|
2846
|
+
]), D = t(() => {
|
|
2928
2847
|
u(!1), m(null);
|
|
2929
|
-
}, []),
|
|
2848
|
+
}, []), O = a(() => {
|
|
2930
2849
|
let t = {};
|
|
2931
2850
|
return e.branding?.backgroundColor && (t.backgroundColor = e.branding.backgroundColor), t;
|
|
2932
2851
|
}, [e.branding]);
|
|
2933
2852
|
if (l) {
|
|
2934
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));
|
|
2935
|
-
return /* @__PURE__ */
|
|
2854
|
+
return /* @__PURE__ */ X("div", {
|
|
2936
2855
|
className: `min-h-screen flex items-center justify-center p-4 bg-gradient-to-b from-muted/40 via-background to-background ${c || ""}`,
|
|
2937
|
-
style:
|
|
2938
|
-
children: /* @__PURE__ */
|
|
2856
|
+
style: O,
|
|
2857
|
+
children: /* @__PURE__ */ Z("div", {
|
|
2939
2858
|
className: "max-w-md w-full bg-card border rounded-xl shadow-sm p-8 text-center space-y-4",
|
|
2940
2859
|
children: [
|
|
2941
|
-
/* @__PURE__ */
|
|
2860
|
+
/* @__PURE__ */ X("div", {
|
|
2942
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",
|
|
2943
|
-
children: /* @__PURE__ */
|
|
2862
|
+
children: /* @__PURE__ */ X(ue, {
|
|
2944
2863
|
className: "h-8 w-8",
|
|
2945
2864
|
"aria-hidden": "true"
|
|
2946
2865
|
})
|
|
2947
2866
|
}),
|
|
2948
|
-
/* @__PURE__ */
|
|
2867
|
+
/* @__PURE__ */ X("h2", {
|
|
2949
2868
|
className: "text-xl font-semibold text-foreground",
|
|
2950
2869
|
children: t?.title || n.thankYouTitle || "Thank You!"
|
|
2951
2870
|
}),
|
|
2952
|
-
/* @__PURE__ */
|
|
2871
|
+
/* @__PURE__ */ X("p", {
|
|
2953
2872
|
className: "text-sm text-muted-foreground",
|
|
2954
2873
|
children: t?.message || n.thankYouMessage || "Your submission has been received successfully."
|
|
2955
2874
|
}),
|
|
2956
|
-
e.allowMultiple && /* @__PURE__ */
|
|
2875
|
+
e.allowMultiple && /* @__PURE__ */ X(k, {
|
|
2957
2876
|
variant: "outline",
|
|
2958
2877
|
size: "sm",
|
|
2959
|
-
onClick:
|
|
2878
|
+
onClick: D,
|
|
2960
2879
|
className: "mt-2",
|
|
2961
2880
|
children: n.submitAnother ?? "Submit Another Response"
|
|
2962
2881
|
}),
|
|
2963
|
-
t?.redirectUrl && /* @__PURE__ */
|
|
2882
|
+
t?.redirectUrl && /* @__PURE__ */ X("p", {
|
|
2964
2883
|
className: "text-xs text-muted-foreground",
|
|
2965
2884
|
children: i
|
|
2966
2885
|
})
|
|
@@ -2969,51 +2888,51 @@ var Bt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
|
2969
2888
|
});
|
|
2970
2889
|
}
|
|
2971
2890
|
let A = e.texts ?? {}, j = !!e.consent?.required, M = `${e.formId}-consent`;
|
|
2972
|
-
return /* @__PURE__ */
|
|
2891
|
+
return /* @__PURE__ */ X("div", {
|
|
2973
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 || ""}`,
|
|
2974
|
-
style:
|
|
2975
|
-
children: /* @__PURE__ */
|
|
2893
|
+
style: O,
|
|
2894
|
+
children: /* @__PURE__ */ Z("div", {
|
|
2976
2895
|
className: "max-w-2xl w-full bg-card border rounded-xl shadow-sm overflow-hidden",
|
|
2977
2896
|
children: [
|
|
2978
|
-
e.branding?.coverImage && /* @__PURE__ */
|
|
2897
|
+
e.branding?.coverImage && /* @__PURE__ */ X("div", {
|
|
2979
2898
|
className: "h-28 sm:h-32 w-full bg-cover bg-center",
|
|
2980
2899
|
style: { backgroundImage: `url(${JSON.stringify(e.branding.coverImage)})` },
|
|
2981
2900
|
role: "presentation"
|
|
2982
2901
|
}),
|
|
2983
|
-
/* @__PURE__ */
|
|
2902
|
+
/* @__PURE__ */ Z("div", {
|
|
2984
2903
|
className: "px-6 sm:px-8 pt-7 pb-5 border-b bg-muted/20",
|
|
2985
2904
|
style: e.branding?.primaryColor ? { borderBottomColor: e.branding.primaryColor } : void 0,
|
|
2986
2905
|
children: [
|
|
2987
|
-
e.branding?.logo && /* @__PURE__ */
|
|
2906
|
+
e.branding?.logo && /* @__PURE__ */ X("img", {
|
|
2988
2907
|
src: e.branding.logo,
|
|
2989
2908
|
alt: "",
|
|
2990
2909
|
className: "h-8 mb-4"
|
|
2991
2910
|
}),
|
|
2992
|
-
e.title && /* @__PURE__ */
|
|
2911
|
+
e.title && /* @__PURE__ */ X("h1", {
|
|
2993
2912
|
className: "text-2xl font-semibold tracking-tight text-foreground",
|
|
2994
2913
|
children: e.title
|
|
2995
2914
|
}),
|
|
2996
|
-
e.description && /* @__PURE__ */
|
|
2915
|
+
e.description && /* @__PURE__ */ X("p", {
|
|
2997
2916
|
className: "text-sm text-muted-foreground mt-2 leading-relaxed",
|
|
2998
2917
|
children: e.description
|
|
2999
2918
|
}),
|
|
3000
|
-
/* @__PURE__ */
|
|
2919
|
+
/* @__PURE__ */ X("p", {
|
|
3001
2920
|
className: "text-[11px] text-muted-foreground/70 mt-3",
|
|
3002
2921
|
"aria-hidden": "true",
|
|
3003
2922
|
children: A.requiredHint ?? "* Required field"
|
|
3004
2923
|
})
|
|
3005
2924
|
]
|
|
3006
2925
|
}),
|
|
3007
|
-
/* @__PURE__ */
|
|
2926
|
+
/* @__PURE__ */ Z("div", {
|
|
3008
2927
|
className: "relative px-6 sm:px-8 py-6",
|
|
3009
2928
|
children: [
|
|
3010
|
-
p && /* @__PURE__ */
|
|
2929
|
+
p && /* @__PURE__ */ X("div", {
|
|
3011
2930
|
role: "alert",
|
|
3012
2931
|
"aria-live": "assertive",
|
|
3013
2932
|
className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
|
|
3014
2933
|
children: p
|
|
3015
2934
|
}),
|
|
3016
|
-
/* @__PURE__ */
|
|
2935
|
+
/* @__PURE__ */ X(Mt, {
|
|
3017
2936
|
schema: {
|
|
3018
2937
|
type: "object-form",
|
|
3019
2938
|
objectName: e.objectName,
|
|
@@ -3026,13 +2945,13 @@ var Bt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
|
3026
2945
|
},
|
|
3027
2946
|
dataSource: w
|
|
3028
2947
|
}),
|
|
3029
|
-
x && /* @__PURE__ */
|
|
2948
|
+
x && /* @__PURE__ */ Z("div", {
|
|
3030
2949
|
"aria-hidden": "true",
|
|
3031
2950
|
className: "absolute left-[-10000px] top-auto h-px w-px overflow-hidden",
|
|
3032
|
-
children: [/* @__PURE__ */
|
|
2951
|
+
children: [/* @__PURE__ */ X("label", {
|
|
3033
2952
|
htmlFor: `${e.formId}-${x}`,
|
|
3034
2953
|
children: "Do not fill this field"
|
|
3035
|
-
}), /* @__PURE__ */
|
|
2954
|
+
}), /* @__PURE__ */ X("input", {
|
|
3036
2955
|
ref: y,
|
|
3037
2956
|
id: `${e.formId}-${x}`,
|
|
3038
2957
|
type: "text",
|
|
@@ -3042,11 +2961,11 @@ var Bt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
|
3042
2961
|
defaultValue: ""
|
|
3043
2962
|
})]
|
|
3044
2963
|
}),
|
|
3045
|
-
e.consent && /* @__PURE__ */
|
|
2964
|
+
e.consent && /* @__PURE__ */ Z("div", {
|
|
3046
2965
|
className: "mt-4",
|
|
3047
|
-
children: [/* @__PURE__ */
|
|
2966
|
+
children: [/* @__PURE__ */ Z("label", {
|
|
3048
2967
|
className: "flex items-start gap-2 text-sm text-foreground cursor-pointer select-none",
|
|
3049
|
-
children: [/* @__PURE__ */
|
|
2968
|
+
children: [/* @__PURE__ */ X("input", {
|
|
3050
2969
|
type: "checkbox",
|
|
3051
2970
|
id: M,
|
|
3052
2971
|
checked: h,
|
|
@@ -3057,16 +2976,16 @@ var Bt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
|
3057
2976
|
"aria-invalid": _ ? "true" : void 0,
|
|
3058
2977
|
"aria-describedby": _ ? `${M}-error` : void 0,
|
|
3059
2978
|
className: "mt-0.5 h-4 w-4 rounded border-input accent-primary"
|
|
3060
|
-
}), /* @__PURE__ */
|
|
2979
|
+
}), /* @__PURE__ */ Z("span", {
|
|
3061
2980
|
className: "leading-relaxed",
|
|
3062
2981
|
children: [
|
|
3063
2982
|
e.consent.label ?? A.consentLabelDefault ?? "I agree to the privacy policy.",
|
|
3064
|
-
j && /* @__PURE__ */
|
|
2983
|
+
j && /* @__PURE__ */ X("span", {
|
|
3065
2984
|
"aria-hidden": "true",
|
|
3066
2985
|
className: "text-destructive ml-0.5",
|
|
3067
2986
|
children: "*"
|
|
3068
2987
|
}),
|
|
3069
|
-
e.consent.privacyUrl && /* @__PURE__ */
|
|
2988
|
+
e.consent.privacyUrl && /* @__PURE__ */ Z(he, { children: [" ", /* @__PURE__ */ X("a", {
|
|
3070
2989
|
href: e.consent.privacyUrl,
|
|
3071
2990
|
target: "_blank",
|
|
3072
2991
|
rel: "noopener noreferrer",
|
|
@@ -3075,42 +2994,42 @@ var Bt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
|
3075
2994
|
})] })
|
|
3076
2995
|
]
|
|
3077
2996
|
})]
|
|
3078
|
-
}), _ && /* @__PURE__ */
|
|
2997
|
+
}), _ && /* @__PURE__ */ X("p", {
|
|
3079
2998
|
id: `${M}-error`,
|
|
3080
2999
|
role: "alert",
|
|
3081
3000
|
className: "mt-1.5 text-xs text-destructive",
|
|
3082
3001
|
children: _
|
|
3083
3002
|
})]
|
|
3084
3003
|
}),
|
|
3085
|
-
d && /* @__PURE__ */
|
|
3004
|
+
d && /* @__PURE__ */ Z("div", {
|
|
3086
3005
|
className: "mt-3 flex items-center gap-2 text-xs text-muted-foreground",
|
|
3087
|
-
children: [/* @__PURE__ */
|
|
3006
|
+
children: [/* @__PURE__ */ X(me, {
|
|
3088
3007
|
className: "h-3.5 w-3.5 animate-spin",
|
|
3089
3008
|
"aria-hidden": "true"
|
|
3090
|
-
}), /* @__PURE__ */
|
|
3009
|
+
}), /* @__PURE__ */ X("span", { children: A.submitting ?? "Submitting…" })]
|
|
3091
3010
|
})
|
|
3092
3011
|
]
|
|
3093
3012
|
}),
|
|
3094
|
-
/* @__PURE__ */
|
|
3013
|
+
/* @__PURE__ */ Z("div", {
|
|
3095
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",
|
|
3096
|
-
children: [/* @__PURE__ */
|
|
3015
|
+
children: [/* @__PURE__ */ Z("p", {
|
|
3097
3016
|
className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground",
|
|
3098
|
-
children: [/* @__PURE__ */
|
|
3017
|
+
children: [/* @__PURE__ */ X(J, {
|
|
3099
3018
|
className: "h-3 w-3",
|
|
3100
3019
|
"aria-hidden": "true"
|
|
3101
|
-
}), /* @__PURE__ */
|
|
3102
|
-
}), /* @__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", {
|
|
3103
3022
|
className: "flex items-center gap-3 text-xs text-muted-foreground/80",
|
|
3104
|
-
children: [e.privacyPolicyUrl && /* @__PURE__ */
|
|
3023
|
+
children: [e.privacyPolicyUrl && /* @__PURE__ */ Z("a", {
|
|
3105
3024
|
href: e.privacyPolicyUrl,
|
|
3106
3025
|
target: "_blank",
|
|
3107
3026
|
rel: "noopener noreferrer",
|
|
3108
3027
|
className: "inline-flex items-center gap-1 underline hover:text-foreground",
|
|
3109
|
-
children: [/* @__PURE__ */ Y
|
|
3028
|
+
children: [/* @__PURE__ */ X(Y, {
|
|
3110
3029
|
className: "h-3 w-3",
|
|
3111
3030
|
"aria-hidden": "true"
|
|
3112
3031
|
}), A.consentLink ?? "Privacy policy"]
|
|
3113
|
-
}), /* @__PURE__ */
|
|
3032
|
+
}), /* @__PURE__ */ X("span", { children: A.poweredBy ?? "Powered by ObjectStack" })]
|
|
3114
3033
|
})]
|
|
3115
3034
|
})
|
|
3116
3035
|
]
|
|
@@ -3119,96 +3038,96 @@ var Bt = ({ config: e, dataSource: n, prefillParams: i, className: c }) => {
|
|
|
3119
3038
|
};
|
|
3120
3039
|
//#endregion
|
|
3121
3040
|
//#region src/FormAnalytics.tsx
|
|
3122
|
-
function
|
|
3041
|
+
function Bt(e) {
|
|
3123
3042
|
return e < 60 ? `${Math.round(e)}s` : e < 3600 ? `${Math.floor(e / 60)}m ${Math.round(e % 60)}s` : `${Math.floor(e / 3600)}h ${Math.floor(e % 3600 / 60)}m`;
|
|
3124
3043
|
}
|
|
3125
|
-
var
|
|
3044
|
+
var Vt = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
3126
3045
|
let i = a(() => {
|
|
3127
3046
|
if (!n.abandonedSubmissions) return 100;
|
|
3128
3047
|
let e = n.totalSubmissions + n.abandonedSubmissions;
|
|
3129
3048
|
return e === 0 ? 0 : Math.round(n.totalSubmissions / e * 100);
|
|
3130
3049
|
}, [n.totalSubmissions, n.abandonedSubmissions]), o = a(() => n.dailySubmissions?.length ? Math.max(...n.dailySubmissions.map((e) => e.count), 1) : 1, [n.dailySubmissions]);
|
|
3131
|
-
return /* @__PURE__ */
|
|
3050
|
+
return /* @__PURE__ */ Z("div", {
|
|
3132
3051
|
className: `space-y-4 ${r || ""}`,
|
|
3133
3052
|
children: [
|
|
3134
|
-
/* @__PURE__ */
|
|
3053
|
+
/* @__PURE__ */ Z("div", { children: [/* @__PURE__ */ X("h2", {
|
|
3135
3054
|
className: "text-lg font-semibold text-foreground",
|
|
3136
3055
|
children: t || "Form Analytics"
|
|
3137
|
-
}), /* @__PURE__ */
|
|
3056
|
+
}), /* @__PURE__ */ Z("p", {
|
|
3138
3057
|
className: "text-sm text-muted-foreground",
|
|
3139
3058
|
children: ["Form ID: ", e]
|
|
3140
3059
|
})] }),
|
|
3141
|
-
/* @__PURE__ */
|
|
3060
|
+
/* @__PURE__ */ Z("div", {
|
|
3142
3061
|
className: "grid grid-cols-1 sm:grid-cols-3 gap-4",
|
|
3143
3062
|
children: [
|
|
3144
|
-
/* @__PURE__ */
|
|
3063
|
+
/* @__PURE__ */ X(A, { children: /* @__PURE__ */ Z(N, {
|
|
3145
3064
|
className: "pb-2",
|
|
3146
|
-
children: [/* @__PURE__ */
|
|
3065
|
+
children: [/* @__PURE__ */ X(M, { children: "Total Submissions" }), /* @__PURE__ */ X(P, {
|
|
3147
3066
|
className: "text-2xl",
|
|
3148
3067
|
children: n.totalSubmissions.toLocaleString()
|
|
3149
3068
|
})]
|
|
3150
3069
|
}) }),
|
|
3151
|
-
/* @__PURE__ */
|
|
3070
|
+
/* @__PURE__ */ Z(A, { children: [/* @__PURE__ */ Z(N, {
|
|
3152
3071
|
className: "pb-2",
|
|
3153
|
-
children: [/* @__PURE__ */
|
|
3072
|
+
children: [/* @__PURE__ */ X(M, { children: "Fill Rate" }), /* @__PURE__ */ Z(P, {
|
|
3154
3073
|
className: "text-2xl",
|
|
3155
3074
|
children: [i, "%"]
|
|
3156
3075
|
})]
|
|
3157
|
-
}), /* @__PURE__ */
|
|
3076
|
+
}), /* @__PURE__ */ X(j, { children: /* @__PURE__ */ X("div", {
|
|
3158
3077
|
className: "w-full bg-muted rounded-full h-2",
|
|
3159
|
-
children: /* @__PURE__ */
|
|
3078
|
+
children: /* @__PURE__ */ X("div", {
|
|
3160
3079
|
className: "bg-primary rounded-full h-2 transition-all",
|
|
3161
3080
|
style: { width: `${i}%` }
|
|
3162
3081
|
})
|
|
3163
3082
|
}) })] }),
|
|
3164
|
-
/* @__PURE__ */
|
|
3083
|
+
/* @__PURE__ */ X(A, { children: /* @__PURE__ */ Z(N, {
|
|
3165
3084
|
className: "pb-2",
|
|
3166
|
-
children: [/* @__PURE__ */
|
|
3085
|
+
children: [/* @__PURE__ */ X(M, { children: "Avg. Completion Time" }), /* @__PURE__ */ X(P, {
|
|
3167
3086
|
className: "text-2xl",
|
|
3168
|
-
children: n.avgCompletionTime ?
|
|
3087
|
+
children: n.avgCompletionTime ? Bt(n.avgCompletionTime) : "—"
|
|
3169
3088
|
})]
|
|
3170
3089
|
}) })
|
|
3171
3090
|
]
|
|
3172
3091
|
}),
|
|
3173
|
-
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, {
|
|
3174
3093
|
className: "text-sm font-medium",
|
|
3175
3094
|
children: "Daily Submissions"
|
|
3176
|
-
}) }), /* @__PURE__ */
|
|
3095
|
+
}) }), /* @__PURE__ */ X(j, { children: /* @__PURE__ */ X("div", {
|
|
3177
3096
|
className: "flex items-end gap-1 h-32",
|
|
3178
|
-
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */
|
|
3097
|
+
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ Z("div", {
|
|
3179
3098
|
className: "flex-1 flex flex-col items-center gap-1",
|
|
3180
|
-
children: [/* @__PURE__ */
|
|
3099
|
+
children: [/* @__PURE__ */ X("div", {
|
|
3181
3100
|
className: "w-full bg-primary/80 rounded-t transition-all hover:bg-primary",
|
|
3182
3101
|
style: {
|
|
3183
3102
|
height: `${e.count / o * 100}%`,
|
|
3184
3103
|
minHeight: e.count > 0 ? "4px" : "0"
|
|
3185
3104
|
},
|
|
3186
3105
|
title: `${e.date}: ${e.count} submissions`
|
|
3187
|
-
}), /* @__PURE__ */
|
|
3106
|
+
}), /* @__PURE__ */ X("span", {
|
|
3188
3107
|
className: "text-[10px] text-muted-foreground truncate w-full text-center",
|
|
3189
3108
|
children: e.date.slice(-5)
|
|
3190
3109
|
})]
|
|
3191
3110
|
}, t))
|
|
3192
3111
|
}) })] }),
|
|
3193
|
-
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, {
|
|
3194
3113
|
className: "text-sm font-medium",
|
|
3195
3114
|
children: "Field Completion Rates"
|
|
3196
|
-
}), /* @__PURE__ */
|
|
3115
|
+
}), /* @__PURE__ */ X(M, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ X(j, { children: /* @__PURE__ */ X("div", {
|
|
3197
3116
|
className: "space-y-3",
|
|
3198
|
-
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */
|
|
3117
|
+
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ Z("div", {
|
|
3199
3118
|
className: "space-y-1",
|
|
3200
|
-
children: [/* @__PURE__ */
|
|
3119
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
3201
3120
|
className: "flex justify-between text-sm",
|
|
3202
|
-
children: [/* @__PURE__ */
|
|
3121
|
+
children: [/* @__PURE__ */ X("span", {
|
|
3203
3122
|
className: "text-foreground",
|
|
3204
3123
|
children: e.label
|
|
3205
|
-
}), /* @__PURE__ */
|
|
3124
|
+
}), /* @__PURE__ */ Z("span", {
|
|
3206
3125
|
className: "text-muted-foreground",
|
|
3207
3126
|
children: [e.completionRate, "%"]
|
|
3208
3127
|
})]
|
|
3209
|
-
}), /* @__PURE__ */
|
|
3128
|
+
}), /* @__PURE__ */ X("div", {
|
|
3210
3129
|
className: "w-full bg-muted rounded-full h-1.5",
|
|
3211
|
-
children: /* @__PURE__ */
|
|
3130
|
+
children: /* @__PURE__ */ X("div", {
|
|
3212
3131
|
className: `rounded-full h-1.5 transition-all ${e.completionRate >= 80 ? "bg-green-500" : e.completionRate >= 50 ? "bg-yellow-500" : "bg-destructive"}`,
|
|
3213
3132
|
style: { width: `${e.completionRate}%` }
|
|
3214
3133
|
})
|
|
@@ -3217,36 +3136,36 @@ var Ht = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3217
3136
|
}) })] })
|
|
3218
3137
|
]
|
|
3219
3138
|
});
|
|
3220
|
-
},
|
|
3221
|
-
let n =
|
|
3139
|
+
}, Ht = ({ schema: e }) => {
|
|
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);
|
|
3222
3141
|
r(() => {
|
|
3223
3142
|
let t = n;
|
|
3224
3143
|
if (!t || typeof t.getObjectSchema != "function") return;
|
|
3225
3144
|
let r = !1;
|
|
3226
3145
|
return t.getObjectSchema(e.childObject).then((e) => {
|
|
3227
|
-
r ||
|
|
3146
|
+
r || E(e ?? null);
|
|
3228
3147
|
}).catch(() => {
|
|
3229
|
-
r ||
|
|
3148
|
+
r || E(null);
|
|
3230
3149
|
}), () => {
|
|
3231
3150
|
r = !0;
|
|
3232
3151
|
};
|
|
3233
3152
|
}, [n, e.childObject]);
|
|
3234
|
-
let
|
|
3153
|
+
let D = t(async () => {
|
|
3235
3154
|
if (!n || !c) {
|
|
3236
|
-
|
|
3155
|
+
v(!1);
|
|
3237
3156
|
return;
|
|
3238
3157
|
}
|
|
3239
|
-
|
|
3158
|
+
v(!0);
|
|
3240
3159
|
try {
|
|
3241
3160
|
let t = (await n.find(e.childObject, {
|
|
3242
3161
|
$filter: { [e.relationshipField]: c },
|
|
3243
3162
|
$top: 500
|
|
3244
3163
|
}))?.data ?? [];
|
|
3245
|
-
|
|
3164
|
+
d(t.map((e) => ({ ...e }))), p(t.map((e) => ({ ...e }))), S(!1);
|
|
3246
3165
|
} catch (e) {
|
|
3247
|
-
|
|
3166
|
+
w(e?.message || "Failed to load line items");
|
|
3248
3167
|
} finally {
|
|
3249
|
-
|
|
3168
|
+
v(!1);
|
|
3250
3169
|
}
|
|
3251
3170
|
}, [
|
|
3252
3171
|
n,
|
|
@@ -3255,39 +3174,38 @@ var Ht = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3255
3174
|
e.relationshipField
|
|
3256
3175
|
]);
|
|
3257
3176
|
r(() => {
|
|
3258
|
-
|
|
3259
|
-
}, [
|
|
3260
|
-
let
|
|
3261
|
-
|
|
3262
|
-
}, []),
|
|
3177
|
+
D();
|
|
3178
|
+
}, [D]);
|
|
3179
|
+
let O = t((e) => {
|
|
3180
|
+
d(e), S(!0);
|
|
3181
|
+
}, []), M = t(async () => {
|
|
3263
3182
|
if (!(!n || !c)) {
|
|
3264
|
-
|
|
3183
|
+
b(!0), w(null);
|
|
3265
3184
|
try {
|
|
3266
|
-
|
|
3185
|
+
let t = !!(o && e.totalField), r = t ? { [e.totalField]: et(l, e.amountField || "amount") } : {}, i = Qe(o ?? "", c, r, [{
|
|
3267
3186
|
childObject: e.childObject,
|
|
3268
3187
|
relationshipField: e.relationshipField,
|
|
3269
3188
|
rows: l,
|
|
3270
|
-
original:
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
}), await E();
|
|
3189
|
+
original: f,
|
|
3190
|
+
childSchema: T
|
|
3191
|
+
}]);
|
|
3192
|
+
t || (i = i.slice(1)), i.length && await u(n, i), await D();
|
|
3275
3193
|
} catch (e) {
|
|
3276
|
-
|
|
3194
|
+
w(e?.message || "Failed to save line items");
|
|
3277
3195
|
} finally {
|
|
3278
|
-
|
|
3196
|
+
b(!1);
|
|
3279
3197
|
}
|
|
3280
3198
|
}
|
|
3281
3199
|
}, [
|
|
3282
3200
|
n,
|
|
3283
3201
|
c,
|
|
3284
3202
|
l,
|
|
3285
|
-
|
|
3203
|
+
f,
|
|
3286
3204
|
e,
|
|
3287
3205
|
o,
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
]),
|
|
3206
|
+
D,
|
|
3207
|
+
T
|
|
3208
|
+
]), F = a(() => ({
|
|
3291
3209
|
columns: e.columns,
|
|
3292
3210
|
total_field: e.totalField ? e.amountField || "amount" : void 0,
|
|
3293
3211
|
min_rows: e.minRows,
|
|
@@ -3295,41 +3213,41 @@ var Ht = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
3295
3213
|
allow_add: !e.readonly,
|
|
3296
3214
|
allow_delete: !e.readonly
|
|
3297
3215
|
}), [e]);
|
|
3298
|
-
return /* @__PURE__ */
|
|
3216
|
+
return /* @__PURE__ */ Z(A, {
|
|
3299
3217
|
className: G("shadow-none"),
|
|
3300
|
-
children: [/* @__PURE__ */
|
|
3218
|
+
children: [/* @__PURE__ */ Z(N, {
|
|
3301
3219
|
className: "flex-row items-center justify-between gap-2 pb-2",
|
|
3302
|
-
children: [/* @__PURE__ */
|
|
3220
|
+
children: [/* @__PURE__ */ X(P, {
|
|
3303
3221
|
className: "text-sm font-medium",
|
|
3304
3222
|
children: e.title || "Line Items"
|
|
3305
|
-
}), !e.readonly && /* @__PURE__ */
|
|
3223
|
+
}), !e.readonly && /* @__PURE__ */ X(k, {
|
|
3306
3224
|
type: "button",
|
|
3307
3225
|
size: "sm",
|
|
3308
|
-
onClick:
|
|
3309
|
-
disabled:
|
|
3310
|
-
children:
|
|
3226
|
+
onClick: M,
|
|
3227
|
+
disabled: y || h || !x || !c,
|
|
3228
|
+
children: y ? "Saving…" : "Save"
|
|
3311
3229
|
})]
|
|
3312
|
-
}), /* @__PURE__ */
|
|
3230
|
+
}), /* @__PURE__ */ Z(j, { children: [C && /* @__PURE__ */ X("p", {
|
|
3313
3231
|
className: "mb-2 text-sm text-destructive",
|
|
3314
|
-
children:
|
|
3315
|
-
}),
|
|
3232
|
+
children: C
|
|
3233
|
+
}), h ? /* @__PURE__ */ X("p", {
|
|
3316
3234
|
className: "py-6 text-center text-sm text-muted-foreground",
|
|
3317
3235
|
children: "Loading…"
|
|
3318
|
-
}) : c ? /* @__PURE__ */
|
|
3236
|
+
}) : c ? /* @__PURE__ */ X(_, {
|
|
3319
3237
|
value: l,
|
|
3320
|
-
onChange:
|
|
3321
|
-
field:
|
|
3238
|
+
onChange: O,
|
|
3239
|
+
field: F,
|
|
3322
3240
|
readonly: e.readonly
|
|
3323
|
-
}) : /* @__PURE__ */
|
|
3241
|
+
}) : /* @__PURE__ */ X("p", {
|
|
3324
3242
|
className: "py-6 text-center text-sm text-muted-foreground",
|
|
3325
3243
|
children: "Save the record first to add line items."
|
|
3326
3244
|
})] })]
|
|
3327
3245
|
});
|
|
3328
|
-
},
|
|
3246
|
+
}, Ut = ({ schema: e }) => /* @__PURE__ */ X(Mt, {
|
|
3329
3247
|
schema: e,
|
|
3330
|
-
dataSource: n(
|
|
3248
|
+
dataSource: n(f)?.dataSource ?? void 0
|
|
3331
3249
|
});
|
|
3332
|
-
c.register("object-form",
|
|
3250
|
+
c.register("object-form", Ut, {
|
|
3333
3251
|
namespace: "plugin-form",
|
|
3334
3252
|
label: "Object Form",
|
|
3335
3253
|
category: "plugin",
|
|
@@ -3470,7 +3388,7 @@ c.register("object-form", Wt, {
|
|
|
3470
3388
|
]
|
|
3471
3389
|
}
|
|
3472
3390
|
]
|
|
3473
|
-
}), c.register("form",
|
|
3391
|
+
}), c.register("form", Ut, {
|
|
3474
3392
|
namespace: "view",
|
|
3475
3393
|
skipFallback: !0,
|
|
3476
3394
|
label: "Data Form View",
|
|
@@ -3498,7 +3416,7 @@ c.register("object-form", Wt, {
|
|
|
3498
3416
|
]
|
|
3499
3417
|
}
|
|
3500
3418
|
]
|
|
3501
|
-
}), c.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */
|
|
3419
|
+
}), c.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */ X(zt, { config: e }), {
|
|
3502
3420
|
namespace: "plugin-form",
|
|
3503
3421
|
label: "Embeddable Form",
|
|
3504
3422
|
category: "plugin",
|
|
@@ -3536,7 +3454,7 @@ c.register("object-form", Wt, {
|
|
|
3536
3454
|
label: "Allow Multiple Submissions"
|
|
3537
3455
|
}
|
|
3538
3456
|
]
|
|
3539
|
-
}), c.register("form-analytics", ({ schema: e }) => /* @__PURE__ */
|
|
3457
|
+
}), c.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ X(Vt, {
|
|
3540
3458
|
formId: e.formId,
|
|
3541
3459
|
formTitle: e.formTitle,
|
|
3542
3460
|
metrics: e.metrics || { totalSubmissions: 0 }
|
|
@@ -3562,9 +3480,9 @@ c.register("object-form", Wt, {
|
|
|
3562
3480
|
label: "Submission Metrics"
|
|
3563
3481
|
}
|
|
3564
3482
|
]
|
|
3565
|
-
}), c.register("object-master-detail-form", ({ schema: e }) => /* @__PURE__ */
|
|
3483
|
+
}), c.register("object-master-detail-form", ({ schema: e }) => /* @__PURE__ */ X(wt, {
|
|
3566
3484
|
schema: e,
|
|
3567
|
-
dataSource: n(
|
|
3485
|
+
dataSource: n(f)?.dataSource ?? void 0
|
|
3568
3486
|
}), {
|
|
3569
3487
|
namespace: "plugin-form",
|
|
3570
3488
|
label: "Master-Detail Form",
|
|
@@ -3594,7 +3512,7 @@ c.register("object-form", Wt, {
|
|
|
3594
3512
|
required: !0
|
|
3595
3513
|
}
|
|
3596
3514
|
]
|
|
3597
|
-
}), c.register("line_items", ({ schema: e }) => /* @__PURE__ */
|
|
3515
|
+
}), c.register("line_items", ({ schema: e }) => /* @__PURE__ */ X(Ht, { schema: e }), {
|
|
3598
3516
|
namespace: "record",
|
|
3599
3517
|
skipFallback: !0,
|
|
3600
3518
|
label: "Line Items",
|
|
@@ -3631,4 +3549,4 @@ c.register("object-form", Wt, {
|
|
|
3631
3549
|
]
|
|
3632
3550
|
});
|
|
3633
3551
|
//#endregion
|
|
3634
|
-
export {
|
|
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 };
|