@object-ui/plugin-form 5.0.1 → 5.1.1
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 +56 -0
- package/dist/index.js +614 -423
- package/dist/index.umd.cjs +1 -1
- package/dist/packages/plugin-form/src/EmbeddableForm.d.ts +68 -1
- package/dist/packages/plugin-form/src/FormSection.d.ts +8 -0
- package/dist/packages/plugin-form/src/index.d.ts +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,48 +1,68 @@
|
|
|
1
|
-
import e, { useCallback as t, useEffect as n, useId as r, useMemo as i,
|
|
2
|
-
import { ComponentRegistry as
|
|
3
|
-
import { SchemaRenderer as
|
|
4
|
-
import { buildValidationRules as
|
|
5
|
-
import { Button as
|
|
6
|
-
import { usePermissions as
|
|
7
|
-
import { Check as
|
|
8
|
-
import { Fragment as
|
|
1
|
+
import e, { useCallback as t, useEffect as n, useId as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
2
|
+
import { ComponentRegistry as s } from "@object-ui/core";
|
|
3
|
+
import { SchemaRenderer as c, useSafeFieldLabel as l } from "@object-ui/react";
|
|
4
|
+
import { buildValidationRules as u, evaluateCondition as d, formatFileSize as f, mapFieldTypeToFormType as p } from "@object-ui/fields";
|
|
5
|
+
import { Button as m, Card as h, CardContent as g, CardDescription as _, CardHeader as v, CardTitle as y, Dialog as b, DialogDescription as x, DialogHeader as S, DialogTitle as C, MobileDialogContent as w, ResizableHandle as T, ResizablePanel as E, ResizablePanelGroup as D, Sheet as O, SheetContent as k, SheetDescription as A, SheetHeader as j, SheetTitle as M, Skeleton as N, Tabs as P, TabsContent as F, TabsList as I, TabsTrigger as L, cn as R, useIsMobile as z } from "@object-ui/components";
|
|
6
|
+
import { usePermissions as B } from "@object-ui/permissions";
|
|
7
|
+
import { Check as ee, CheckCircle2 as V, ChevronDown as H, ChevronLeft as te, ChevronRight as U, Loader2 as ne, Lock as W, ShieldCheck as G } from "lucide-react";
|
|
8
|
+
import { Fragment as K, jsx as q, jsxs as J } from "react/jsx-runtime";
|
|
9
9
|
//#region src/FormSection.tsx
|
|
10
|
-
var
|
|
11
|
-
let [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
10
|
+
var Y = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: a, className: s, gridClassName: c, showBorder: l }) => {
|
|
11
|
+
let [u, d] = o(r), f = {
|
|
12
|
+
1: "grid-cols-1",
|
|
13
|
+
2: "grid-cols-1 md:grid-cols-2",
|
|
14
|
+
3: "grid-cols-1 md:grid-cols-2 lg:grid-cols-3",
|
|
15
|
+
4: "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
|
|
16
|
+
}, p = () => {
|
|
17
|
+
n && d(!u);
|
|
18
|
+
}, m = l ?? !!e, b = e || t ? /* @__PURE__ */ J("div", {
|
|
19
|
+
className: R("flex items-start gap-2", !m && "mb-4", n && "cursor-pointer select-none"),
|
|
20
|
+
onClick: p,
|
|
21
|
+
role: n ? "button" : void 0,
|
|
22
|
+
"aria-expanded": n ? !u : void 0,
|
|
23
|
+
children: [n && /* @__PURE__ */ q("span", {
|
|
24
|
+
className: "mt-0.5 text-muted-foreground",
|
|
25
|
+
children: q(u ? U : H, { className: "h-4 w-4" })
|
|
26
|
+
}), /* @__PURE__ */ J("div", {
|
|
27
|
+
className: "flex-1",
|
|
28
|
+
children: [e && /* @__PURE__ */ q("h3", {
|
|
29
|
+
className: "text-base font-semibold text-foreground",
|
|
30
|
+
children: e
|
|
31
|
+
}), t && /* @__PURE__ */ q("p", {
|
|
32
|
+
className: "text-sm text-muted-foreground mt-0.5",
|
|
33
|
+
children: t
|
|
33
34
|
})]
|
|
34
|
-
}), !l && /* @__PURE__ */ W("div", {
|
|
35
|
-
className: L("grid gap-4", c || {
|
|
36
|
-
1: "grid-cols-1",
|
|
37
|
-
2: "grid-cols-1 md:grid-cols-2",
|
|
38
|
-
3: "grid-cols-1 md:grid-cols-2 lg:grid-cols-3",
|
|
39
|
-
4: "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
|
|
40
|
-
}[i]),
|
|
41
|
-
children: o
|
|
42
35
|
})]
|
|
36
|
+
}) : null, x = u ? null : /* @__PURE__ */ q("div", {
|
|
37
|
+
className: R("grid gap-4", c || f[i]),
|
|
38
|
+
children: a
|
|
39
|
+
});
|
|
40
|
+
return m ? /* @__PURE__ */ J(h, {
|
|
41
|
+
className: R("form-section", s),
|
|
42
|
+
children: [b && /* @__PURE__ */ J(v, {
|
|
43
|
+
className: "pb-3",
|
|
44
|
+
children: [
|
|
45
|
+
e && /* @__PURE__ */ q(y, {
|
|
46
|
+
className: "text-base",
|
|
47
|
+
children: e
|
|
48
|
+
}),
|
|
49
|
+
t && /* @__PURE__ */ q(_, { children: t }),
|
|
50
|
+
n && /* @__PURE__ */ q("button", {
|
|
51
|
+
type: "button",
|
|
52
|
+
className: "absolute right-4 top-4 text-muted-foreground",
|
|
53
|
+
onClick: p,
|
|
54
|
+
"aria-expanded": !u,
|
|
55
|
+
"aria-label": u ? "Expand section" : "Collapse section",
|
|
56
|
+
children: q(u ? U : H, { className: "h-4 w-4" })
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
}), x && /* @__PURE__ */ q(g, { children: x })]
|
|
60
|
+
}) : /* @__PURE__ */ J("div", {
|
|
61
|
+
className: R("form-section", s),
|
|
62
|
+
children: [b, x]
|
|
43
63
|
});
|
|
44
|
-
},
|
|
45
|
-
let { fieldLabel:
|
|
64
|
+
}, X = ({ schema: n, dataSource: r, className: i }) => {
|
|
65
|
+
let { fieldLabel: a } = l(), [s, d] = o(null), [f, m] = o({}), [h, g] = o(!0), [_, v] = o(null), [y, b] = o(n.defaultTab || n.sections[0]?.name || n.sections[0]?.label || "tab-0");
|
|
46
66
|
e.useEffect(() => {
|
|
47
67
|
(async () => {
|
|
48
68
|
if (!r) {
|
|
@@ -56,7 +76,7 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
56
76
|
}
|
|
57
77
|
})();
|
|
58
78
|
}, [n.objectName, r]), e.useEffect(() => {
|
|
59
|
-
(
|
|
79
|
+
(s || !r) && (async () => {
|
|
60
80
|
if (n.mode === "create" || !n.recordId || !r) {
|
|
61
81
|
m(n.initialData || n.initialValues || {}), g(!1);
|
|
62
82
|
return;
|
|
@@ -70,7 +90,7 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
70
90
|
}
|
|
71
91
|
})();
|
|
72
92
|
}, [
|
|
73
|
-
|
|
93
|
+
s,
|
|
74
94
|
n.mode,
|
|
75
95
|
n.recordId,
|
|
76
96
|
n.initialData,
|
|
@@ -83,17 +103,17 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
83
103
|
for (let r of e.fields) {
|
|
84
104
|
let e = typeof r == "string" ? r : r.name;
|
|
85
105
|
if (typeof r == "object") t.push(r);
|
|
86
|
-
else if (
|
|
87
|
-
let r =
|
|
106
|
+
else if (s?.fields?.[e]) {
|
|
107
|
+
let r = s.fields[e];
|
|
88
108
|
t.push({
|
|
89
109
|
name: e,
|
|
90
|
-
label:
|
|
91
|
-
type:
|
|
110
|
+
label: a(n.objectName, e, r.label || e),
|
|
111
|
+
type: p(r.type),
|
|
92
112
|
required: r.required || !1,
|
|
93
113
|
disabled: n.readOnly || n.mode === "view" || r.readonly,
|
|
94
114
|
placeholder: r.placeholder,
|
|
95
115
|
description: r.help || r.description,
|
|
96
|
-
validation:
|
|
116
|
+
validation: u(r),
|
|
97
117
|
field: r,
|
|
98
118
|
options: r.options,
|
|
99
119
|
multiple: r.multiple
|
|
@@ -106,7 +126,7 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
106
126
|
}
|
|
107
127
|
return t;
|
|
108
128
|
}, [
|
|
109
|
-
|
|
129
|
+
s,
|
|
110
130
|
n.readOnly,
|
|
111
131
|
n.mode
|
|
112
132
|
]), S = t(async (e) => {
|
|
@@ -120,19 +140,19 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
120
140
|
}, [n, r]), C = t(() => {
|
|
121
141
|
n.onCancel && n.onCancel();
|
|
122
142
|
}, [n]), w = (e, t) => e.name || e.label || `tab-${t}`;
|
|
123
|
-
if (_) return /* @__PURE__ */
|
|
143
|
+
if (_) return /* @__PURE__ */ J("div", {
|
|
124
144
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
125
|
-
children: [/* @__PURE__ */
|
|
145
|
+
children: [/* @__PURE__ */ q("h3", {
|
|
126
146
|
className: "text-red-800 font-semibold",
|
|
127
147
|
children: "Error loading form"
|
|
128
|
-
}), /* @__PURE__ */
|
|
148
|
+
}), /* @__PURE__ */ q("p", {
|
|
129
149
|
className: "text-red-600 text-sm mt-1",
|
|
130
150
|
children: _.message
|
|
131
151
|
})]
|
|
132
152
|
});
|
|
133
|
-
if (h) return /* @__PURE__ */
|
|
153
|
+
if (h) return /* @__PURE__ */ J("div", {
|
|
134
154
|
className: "p-8 text-center",
|
|
135
|
-
children: [/* @__PURE__ */
|
|
155
|
+
children: [/* @__PURE__ */ q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ q("p", {
|
|
136
156
|
className: "mt-2 text-sm text-gray-600",
|
|
137
157
|
children: "Loading form..."
|
|
138
158
|
})]
|
|
@@ -141,7 +161,7 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
141
161
|
type: "form",
|
|
142
162
|
fields: n.sections.flatMap((e) => x(e)),
|
|
143
163
|
layout: "vertical",
|
|
144
|
-
defaultValues:
|
|
164
|
+
defaultValues: f,
|
|
145
165
|
submitLabel: n.submitText || (n.mode === "create" ? "Create" : "Update"),
|
|
146
166
|
cancelLabel: n.cancelText,
|
|
147
167
|
showSubmit: n.showSubmit !== !1 && n.mode !== "view",
|
|
@@ -149,29 +169,29 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
149
169
|
onSubmit: S,
|
|
150
170
|
onCancel: C
|
|
151
171
|
}, E = n.tabPosition === "left" || n.tabPosition === "right";
|
|
152
|
-
return /* @__PURE__ */
|
|
153
|
-
className:
|
|
154
|
-
children: /* @__PURE__ */
|
|
172
|
+
return /* @__PURE__ */ q("div", {
|
|
173
|
+
className: R("w-full", i, n.className),
|
|
174
|
+
children: /* @__PURE__ */ J(P, {
|
|
155
175
|
value: y,
|
|
156
176
|
onValueChange: b,
|
|
157
177
|
orientation: E ? "vertical" : "horizontal",
|
|
158
|
-
className:
|
|
159
|
-
children: [/* @__PURE__ */
|
|
160
|
-
className:
|
|
161
|
-
children: n.sections.map((e, t) => /* @__PURE__ */
|
|
178
|
+
className: R(E && "flex gap-4"),
|
|
179
|
+
children: [/* @__PURE__ */ q(I, {
|
|
180
|
+
className: R(E ? "flex-col h-auto" : "", n.tabPosition === "bottom" && "order-last", n.tabPosition === "right" && "order-last"),
|
|
181
|
+
children: n.sections.map((e, t) => /* @__PURE__ */ q(L, {
|
|
162
182
|
value: w(e, t),
|
|
163
183
|
className: E ? "w-full justify-start" : "",
|
|
164
184
|
children: e.label || `Tab ${t + 1}`
|
|
165
185
|
}, w(e, t)))
|
|
166
|
-
}), /* @__PURE__ */
|
|
186
|
+
}), /* @__PURE__ */ q("div", {
|
|
167
187
|
className: "flex-1",
|
|
168
|
-
children: n.sections.map((e, t) => /* @__PURE__ */
|
|
188
|
+
children: n.sections.map((e, t) => /* @__PURE__ */ q(F, {
|
|
169
189
|
value: w(e, t),
|
|
170
190
|
className: "mt-0",
|
|
171
|
-
children: /* @__PURE__ */
|
|
191
|
+
children: /* @__PURE__ */ q(Y, {
|
|
172
192
|
description: e.description,
|
|
173
193
|
columns: e.columns || 1,
|
|
174
|
-
children: /* @__PURE__ */
|
|
194
|
+
children: /* @__PURE__ */ q(c, { schema: {
|
|
175
195
|
...T,
|
|
176
196
|
fields: x(e),
|
|
177
197
|
showSubmit: n.showSubmit !== !1 && n.mode !== "view",
|
|
@@ -182,8 +202,8 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
182
202
|
})]
|
|
183
203
|
})
|
|
184
204
|
});
|
|
185
|
-
},
|
|
186
|
-
let { fieldLabel:
|
|
205
|
+
}, Z = ({ schema: n, dataSource: r, className: a }) => {
|
|
206
|
+
let { fieldLabel: s } = l(), [f, h] = o(null), [g, _] = o({}), [v, y] = o(!0), [b, x] = o(null), [S, C] = o(0), [w, T] = o(/* @__PURE__ */ new Set()), [E, D] = o(!1), O = n.sections.length, k = S === 0, A = S === O - 1;
|
|
187
207
|
e.useEffect(() => {
|
|
188
208
|
(async () => {
|
|
189
209
|
if (!r) {
|
|
@@ -197,7 +217,7 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
197
217
|
}
|
|
198
218
|
})();
|
|
199
219
|
}, [n.objectName, r]), e.useEffect(() => {
|
|
200
|
-
(
|
|
220
|
+
(f || !r) && (async () => {
|
|
201
221
|
if (n.mode === "create" || !n.recordId || !r) {
|
|
202
222
|
_(n.initialData || n.initialValues || {}), y(!1);
|
|
203
223
|
return;
|
|
@@ -211,7 +231,7 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
211
231
|
}
|
|
212
232
|
})();
|
|
213
233
|
}, [
|
|
214
|
-
|
|
234
|
+
f,
|
|
215
235
|
n.mode,
|
|
216
236
|
n.recordId,
|
|
217
237
|
n.initialData,
|
|
@@ -222,22 +242,22 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
222
242
|
let j = t((e) => {
|
|
223
243
|
let t = [], r = (e, t) => typeof t == "string" && t.trim() ? {
|
|
224
244
|
...e,
|
|
225
|
-
visible: (e) =>
|
|
245
|
+
visible: (e) => d(t, e)
|
|
226
246
|
} : e;
|
|
227
247
|
for (let i of e.fields) {
|
|
228
248
|
let e = typeof i == "string" ? i : i.name;
|
|
229
249
|
if (typeof i == "object") t.push(r(i, i.visibleOn));
|
|
230
|
-
else if (
|
|
231
|
-
let i =
|
|
250
|
+
else if (f?.fields?.[e]) {
|
|
251
|
+
let i = f.fields[e];
|
|
232
252
|
t.push(r({
|
|
233
253
|
name: e,
|
|
234
|
-
label:
|
|
235
|
-
type:
|
|
254
|
+
label: s(n.objectName, e, i.label || e),
|
|
255
|
+
type: p(i.type),
|
|
236
256
|
required: i.required || !1,
|
|
237
257
|
disabled: n.readOnly || n.mode === "view" || i.readonly,
|
|
238
258
|
placeholder: i.placeholder,
|
|
239
259
|
description: i.help || i.description,
|
|
240
|
-
validation:
|
|
260
|
+
validation: u(i),
|
|
241
261
|
field: i,
|
|
242
262
|
options: i.options,
|
|
243
263
|
multiple: i.multiple
|
|
@@ -250,7 +270,7 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
250
270
|
}
|
|
251
271
|
return t;
|
|
252
272
|
}, [
|
|
253
|
-
|
|
273
|
+
f,
|
|
254
274
|
n.readOnly,
|
|
255
275
|
n.mode,
|
|
256
276
|
n.objectName
|
|
@@ -288,7 +308,7 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
288
308
|
P(S - 1);
|
|
289
309
|
}, [S, P]), I = t(() => {
|
|
290
310
|
n.onCancel && n.onCancel();
|
|
291
|
-
}, [n]),
|
|
311
|
+
}, [n]), L = t((e) => {
|
|
292
312
|
(n.allowSkip || w.has(e) || e <= S) && P(e);
|
|
293
313
|
}, [
|
|
294
314
|
n.allowSkip,
|
|
@@ -296,52 +316,52 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
296
316
|
S,
|
|
297
317
|
P
|
|
298
318
|
]);
|
|
299
|
-
if (b) return /* @__PURE__ */
|
|
319
|
+
if (b) return /* @__PURE__ */ J("div", {
|
|
300
320
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
301
|
-
children: [/* @__PURE__ */
|
|
321
|
+
children: [/* @__PURE__ */ q("h3", {
|
|
302
322
|
className: "text-red-800 font-semibold",
|
|
303
323
|
children: "Error loading form"
|
|
304
|
-
}), /* @__PURE__ */
|
|
324
|
+
}), /* @__PURE__ */ q("p", {
|
|
305
325
|
className: "text-red-600 text-sm mt-1",
|
|
306
326
|
children: b.message
|
|
307
327
|
})]
|
|
308
328
|
});
|
|
309
|
-
if (v) return /* @__PURE__ */
|
|
329
|
+
if (v) return /* @__PURE__ */ J("div", {
|
|
310
330
|
className: "p-8 text-center",
|
|
311
|
-
children: [/* @__PURE__ */
|
|
331
|
+
children: [/* @__PURE__ */ q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ q("p", {
|
|
312
332
|
className: "mt-2 text-sm text-gray-600",
|
|
313
333
|
children: "Loading form..."
|
|
314
334
|
})]
|
|
315
335
|
});
|
|
316
336
|
let z = n.sections[S];
|
|
317
|
-
return /* @__PURE__ */
|
|
318
|
-
className:
|
|
337
|
+
return /* @__PURE__ */ J("div", {
|
|
338
|
+
className: R("w-full", a, n.className),
|
|
319
339
|
children: [
|
|
320
|
-
n.showStepIndicator !== !1 && /* @__PURE__ */
|
|
340
|
+
n.showStepIndicator !== !1 && /* @__PURE__ */ q("nav", {
|
|
321
341
|
"aria-label": "Progress",
|
|
322
342
|
className: "mb-8",
|
|
323
|
-
children: /* @__PURE__ */
|
|
343
|
+
children: /* @__PURE__ */ q("ol", {
|
|
324
344
|
className: "flex items-center",
|
|
325
345
|
children: n.sections.map((e, t) => {
|
|
326
346
|
let r = t === S, i = w.has(t), a = n.allowSkip || i || t <= S;
|
|
327
|
-
return /* @__PURE__ */
|
|
328
|
-
className:
|
|
329
|
-
children: [t !== O - 1 && /* @__PURE__ */
|
|
347
|
+
return /* @__PURE__ */ J("li", {
|
|
348
|
+
className: R("relative flex-1", t !== O - 1 && "pr-8 sm:pr-12"),
|
|
349
|
+
children: [t !== O - 1 && /* @__PURE__ */ q("div", {
|
|
330
350
|
className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
|
|
331
351
|
"aria-hidden": "true",
|
|
332
|
-
children: /* @__PURE__ */
|
|
333
|
-
}), /* @__PURE__ */
|
|
352
|
+
children: /* @__PURE__ */ q("div", { className: R("h-full", i ? "bg-primary" : "bg-muted") })
|
|
353
|
+
}), /* @__PURE__ */ J("button", {
|
|
334
354
|
type: "button",
|
|
335
|
-
className:
|
|
336
|
-
onClick: () =>
|
|
355
|
+
className: R("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
|
|
356
|
+
onClick: () => L(t),
|
|
337
357
|
disabled: !a,
|
|
338
|
-
children: [/* @__PURE__ */
|
|
339
|
-
className:
|
|
340
|
-
children: i ? /* @__PURE__ */
|
|
341
|
-
}), /* @__PURE__ */
|
|
358
|
+
children: [/* @__PURE__ */ q("span", {
|
|
359
|
+
className: R("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"),
|
|
360
|
+
children: i ? /* @__PURE__ */ q(ee, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : t + 1
|
|
361
|
+
}), /* @__PURE__ */ q("span", {
|
|
342
362
|
className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block",
|
|
343
|
-
children: /* @__PURE__ */
|
|
344
|
-
className:
|
|
363
|
+
children: /* @__PURE__ */ q("span", {
|
|
364
|
+
className: R(r ? "text-foreground" : "text-muted-foreground"),
|
|
345
365
|
children: e.label || `Step ${t + 1}`
|
|
346
366
|
})
|
|
347
367
|
})]
|
|
@@ -350,13 +370,13 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
350
370
|
})
|
|
351
371
|
})
|
|
352
372
|
}),
|
|
353
|
-
/* @__PURE__ */
|
|
373
|
+
/* @__PURE__ */ q("div", {
|
|
354
374
|
className: "min-h-[200px]",
|
|
355
|
-
children: z && /* @__PURE__ */
|
|
375
|
+
children: z && /* @__PURE__ */ q(Y, {
|
|
356
376
|
label: z.label,
|
|
357
377
|
description: z.description,
|
|
358
378
|
columns: z.columns || 1,
|
|
359
|
-
children: M.length > 0 ? /* @__PURE__ */
|
|
379
|
+
children: M.length > 0 ? /* @__PURE__ */ q(c, { schema: {
|
|
360
380
|
type: "form",
|
|
361
381
|
fields: M,
|
|
362
382
|
layout: "vertical",
|
|
@@ -364,22 +384,22 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
364
384
|
showSubmit: !1,
|
|
365
385
|
showCancel: !1,
|
|
366
386
|
onSubmit: N
|
|
367
|
-
} }) : /* @__PURE__ */
|
|
387
|
+
} }) : /* @__PURE__ */ q("div", {
|
|
368
388
|
className: "text-center py-8 text-muted-foreground",
|
|
369
389
|
children: "No fields configured for this step"
|
|
370
390
|
})
|
|
371
391
|
})
|
|
372
392
|
}),
|
|
373
|
-
/* @__PURE__ */
|
|
393
|
+
/* @__PURE__ */ J("div", {
|
|
374
394
|
className: "flex items-center justify-between mt-6 pt-4 border-t",
|
|
375
|
-
children: [/* @__PURE__ */
|
|
395
|
+
children: [/* @__PURE__ */ q("div", { children: n.showCancel !== !1 && /* @__PURE__ */ q(m, {
|
|
376
396
|
variant: "ghost",
|
|
377
397
|
onClick: I,
|
|
378
398
|
children: n.cancelText || "Cancel"
|
|
379
|
-
}) }), /* @__PURE__ */
|
|
399
|
+
}) }), /* @__PURE__ */ J("div", {
|
|
380
400
|
className: "flex items-center gap-2",
|
|
381
401
|
children: [
|
|
382
|
-
/* @__PURE__ */
|
|
402
|
+
/* @__PURE__ */ J("span", {
|
|
383
403
|
className: "text-sm text-muted-foreground mr-2",
|
|
384
404
|
children: [
|
|
385
405
|
"Step ",
|
|
@@ -388,26 +408,26 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
388
408
|
O
|
|
389
409
|
]
|
|
390
410
|
}),
|
|
391
|
-
!k && /* @__PURE__ */
|
|
411
|
+
!k && /* @__PURE__ */ J(m, {
|
|
392
412
|
variant: "outline",
|
|
393
413
|
onClick: F,
|
|
394
|
-
children: [/* @__PURE__ */
|
|
414
|
+
children: [/* @__PURE__ */ q(te, { className: "h-4 w-4 mr-1" }), n.prevText || "Back"]
|
|
395
415
|
}),
|
|
396
|
-
A ? /* @__PURE__ */
|
|
416
|
+
A ? /* @__PURE__ */ q(m, {
|
|
397
417
|
onClick: () => N(g),
|
|
398
418
|
disabled: E || n.mode === "view",
|
|
399
419
|
children: E ? "Submitting..." : n.submitText || (n.mode === "create" ? "Create" : "Update")
|
|
400
|
-
}) : /* @__PURE__ */
|
|
420
|
+
}) : /* @__PURE__ */ J(m, {
|
|
401
421
|
onClick: () => N(g),
|
|
402
|
-
children: [n.nextText || "Next", /* @__PURE__ */
|
|
422
|
+
children: [n.nextText || "Next", /* @__PURE__ */ q(U, { className: "h-4 w-4 ml-1" })]
|
|
403
423
|
})
|
|
404
424
|
]
|
|
405
425
|
})]
|
|
406
426
|
})
|
|
407
427
|
]
|
|
408
428
|
});
|
|
409
|
-
},
|
|
410
|
-
let { fieldLabel:
|
|
429
|
+
}, Q = ({ schema: e, dataSource: r, className: a }) => {
|
|
430
|
+
let { fieldLabel: s } = l(), [f, m] = o(null), [h, g] = o({}), [_, v] = o(!0), [y, b] = o(null);
|
|
411
431
|
n(() => {
|
|
412
432
|
(async () => {
|
|
413
433
|
if (!r) {
|
|
@@ -421,7 +441,7 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
421
441
|
}
|
|
422
442
|
})();
|
|
423
443
|
}, [e.objectName, r]), n(() => {
|
|
424
|
-
(
|
|
444
|
+
(f || !r) && (async () => {
|
|
425
445
|
if (e.mode === "create" || !e.recordId) {
|
|
426
446
|
g(e.initialData || e.initialValues || {}), v(!1);
|
|
427
447
|
return;
|
|
@@ -439,7 +459,7 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
439
459
|
}
|
|
440
460
|
})();
|
|
441
461
|
}, [
|
|
442
|
-
|
|
462
|
+
f,
|
|
443
463
|
e.mode,
|
|
444
464
|
e.recordId,
|
|
445
465
|
e.initialData,
|
|
@@ -450,22 +470,22 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
450
470
|
let x = t((t) => {
|
|
451
471
|
let n = [], r = (e, t) => typeof t == "string" && t.trim() ? {
|
|
452
472
|
...e,
|
|
453
|
-
visible: (e) =>
|
|
473
|
+
visible: (e) => d(t, e)
|
|
454
474
|
} : e;
|
|
455
475
|
for (let i of t.fields) {
|
|
456
476
|
let t = typeof i == "string" ? i : i.name;
|
|
457
477
|
if (typeof i == "object") n.push(r(i, i.visibleOn));
|
|
458
|
-
else if (
|
|
459
|
-
let i =
|
|
478
|
+
else if (f?.fields?.[t]) {
|
|
479
|
+
let i = f.fields[t];
|
|
460
480
|
n.push(r({
|
|
461
481
|
name: t,
|
|
462
|
-
label:
|
|
463
|
-
type:
|
|
482
|
+
label: s(e.objectName, t, i.label || t),
|
|
483
|
+
type: p(i.type),
|
|
464
484
|
required: i.required || !1,
|
|
465
485
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
466
486
|
placeholder: i.placeholder,
|
|
467
487
|
description: i.help || i.description,
|
|
468
|
-
validation:
|
|
488
|
+
validation: u(i),
|
|
469
489
|
field: i,
|
|
470
490
|
options: i.options,
|
|
471
491
|
multiple: i.multiple
|
|
@@ -478,7 +498,7 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
478
498
|
}
|
|
479
499
|
return n;
|
|
480
500
|
}, [
|
|
481
|
-
|
|
501
|
+
f,
|
|
482
502
|
e.readOnly,
|
|
483
503
|
e.mode,
|
|
484
504
|
e.objectName
|
|
@@ -492,22 +512,22 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
492
512
|
}
|
|
493
513
|
}, [e, r]), C = t(() => {
|
|
494
514
|
e.onCancel && e.onCancel();
|
|
495
|
-
}, [e]),
|
|
515
|
+
}, [e]), w = i(() => e.sections.slice(0, 1), [e.sections]), O = i(() => e.sections.slice(1), [e.sections]);
|
|
496
516
|
i(() => e.sections.flatMap((e) => x(e)), [e.sections, x]);
|
|
497
517
|
let k = e.splitDirection || "horizontal", A = e.splitSize || 50;
|
|
498
|
-
if (y) return /* @__PURE__ */
|
|
518
|
+
if (y) return /* @__PURE__ */ J("div", {
|
|
499
519
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
500
|
-
children: [/* @__PURE__ */
|
|
520
|
+
children: [/* @__PURE__ */ q("h3", {
|
|
501
521
|
className: "text-red-800 font-semibold",
|
|
502
522
|
children: "Error loading form"
|
|
503
|
-
}), /* @__PURE__ */
|
|
523
|
+
}), /* @__PURE__ */ q("p", {
|
|
504
524
|
className: "text-red-600 text-sm mt-1",
|
|
505
525
|
children: y.message
|
|
506
526
|
})]
|
|
507
527
|
});
|
|
508
|
-
if (_) return /* @__PURE__ */
|
|
528
|
+
if (_) return /* @__PURE__ */ J("div", {
|
|
509
529
|
className: "p-8 text-center",
|
|
510
|
-
children: [/* @__PURE__ */
|
|
530
|
+
children: [/* @__PURE__ */ q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ q("p", {
|
|
511
531
|
className: "mt-2 text-sm text-gray-600",
|
|
512
532
|
children: "Loading form..."
|
|
513
533
|
})]
|
|
@@ -518,13 +538,13 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
518
538
|
defaultValues: h,
|
|
519
539
|
onSubmit: S,
|
|
520
540
|
onCancel: C
|
|
521
|
-
}, M = (t, n) => /* @__PURE__ */
|
|
541
|
+
}, M = (t, n) => /* @__PURE__ */ q("div", {
|
|
522
542
|
className: "space-y-4 p-4",
|
|
523
|
-
children: t.map((t, r) => /* @__PURE__ */
|
|
543
|
+
children: t.map((t, r) => /* @__PURE__ */ q(Y, {
|
|
524
544
|
label: t.label,
|
|
525
545
|
description: t.description,
|
|
526
546
|
columns: t.columns || 1,
|
|
527
|
-
children: /* @__PURE__ */
|
|
547
|
+
children: /* @__PURE__ */ q(c, { schema: {
|
|
528
548
|
...j,
|
|
529
549
|
fields: x(t),
|
|
530
550
|
showSubmit: n && e.showSubmit !== !1 && e.mode !== "view",
|
|
@@ -534,28 +554,28 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
534
554
|
} })
|
|
535
555
|
}, t.name || t.label || r))
|
|
536
556
|
});
|
|
537
|
-
return /* @__PURE__ */
|
|
538
|
-
className:
|
|
539
|
-
children: /* @__PURE__ */
|
|
557
|
+
return /* @__PURE__ */ q("div", {
|
|
558
|
+
className: R("w-full", a, e.className),
|
|
559
|
+
children: /* @__PURE__ */ J(D, {
|
|
540
560
|
orientation: k,
|
|
541
561
|
className: "min-h-[300px] rounded-lg border",
|
|
542
|
-
children: [/* @__PURE__ */
|
|
562
|
+
children: [/* @__PURE__ */ q(E, {
|
|
543
563
|
defaultSize: A,
|
|
544
564
|
minSize: 20,
|
|
545
|
-
children: M(
|
|
546
|
-
}), O.length > 0 && /* @__PURE__ */
|
|
565
|
+
children: M(w, O.length === 0)
|
|
566
|
+
}), O.length > 0 && /* @__PURE__ */ J(K, { children: [/* @__PURE__ */ q(T, { withHandle: e.splitResizable !== !1 }), /* @__PURE__ */ q(E, {
|
|
547
567
|
defaultSize: 100 - A,
|
|
548
568
|
minSize: 20,
|
|
549
569
|
children: M(O, !0)
|
|
550
570
|
})] })]
|
|
551
571
|
})
|
|
552
572
|
});
|
|
553
|
-
},
|
|
573
|
+
}, re = new Set([
|
|
554
574
|
"field:formula",
|
|
555
575
|
"field:summary",
|
|
556
576
|
"field:auto_number",
|
|
557
577
|
"field:autonumber"
|
|
558
|
-
]),
|
|
578
|
+
]), ie = new Set([
|
|
559
579
|
"field:textarea",
|
|
560
580
|
"field:markdown",
|
|
561
581
|
"field:html",
|
|
@@ -566,28 +586,28 @@ var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
566
586
|
"html",
|
|
567
587
|
"grid",
|
|
568
588
|
"rich-text"
|
|
569
|
-
]),
|
|
589
|
+
]), ae = new Set([
|
|
570
590
|
"formula",
|
|
571
591
|
"summary",
|
|
572
592
|
"auto_number",
|
|
573
593
|
"autonumber"
|
|
574
594
|
]);
|
|
575
|
-
function
|
|
576
|
-
return
|
|
595
|
+
function oe(e) {
|
|
596
|
+
return ie.has(e);
|
|
577
597
|
}
|
|
578
|
-
function
|
|
579
|
-
return
|
|
598
|
+
function se(e) {
|
|
599
|
+
return ae.has(e);
|
|
580
600
|
}
|
|
581
|
-
function
|
|
601
|
+
function ce(e) {
|
|
582
602
|
return e <= 3 ? 1 : 2;
|
|
583
603
|
}
|
|
584
|
-
function
|
|
585
|
-
return t <= 1 ? e : e.map((e) => e.colSpan === void 0 && e.type &&
|
|
604
|
+
function le(e, t) {
|
|
605
|
+
return t <= 1 ? e : e.map((e) => e.colSpan === void 0 && e.type && oe(e.type) ? {
|
|
586
606
|
...e,
|
|
587
607
|
colSpan: t
|
|
588
608
|
} : e);
|
|
589
609
|
}
|
|
590
|
-
var
|
|
610
|
+
var ue = new Set([
|
|
591
611
|
"id",
|
|
592
612
|
"created_at",
|
|
593
613
|
"createdAt",
|
|
@@ -614,42 +634,42 @@ var oe = new Set([
|
|
|
614
634
|
"_version",
|
|
615
635
|
"_rev"
|
|
616
636
|
]);
|
|
617
|
-
function
|
|
618
|
-
return e.filter((e) => !(
|
|
637
|
+
function de(e, t) {
|
|
638
|
+
return e.filter((e) => !(ue.has(e.name) || t?.fields?.[e.name]?.readonly === !0));
|
|
619
639
|
}
|
|
620
|
-
function
|
|
640
|
+
function fe(e, t) {
|
|
621
641
|
return e.filter((e) => {
|
|
622
|
-
if (
|
|
642
|
+
if (ue.has(e.name) || e.type && re.has(e.type)) return !1;
|
|
623
643
|
if (!t?.fields) return !0;
|
|
624
644
|
let n = t.fields[e.name];
|
|
625
|
-
return n ? n.readonly === !0 ? !1 : !
|
|
645
|
+
return n ? n.readonly === !0 ? !1 : !se(n.type) : !0;
|
|
626
646
|
});
|
|
627
647
|
}
|
|
628
|
-
function
|
|
648
|
+
function pe(e, t) {
|
|
629
649
|
return e.filter((e) => {
|
|
630
|
-
if (e.type &&
|
|
650
|
+
if (e.type && re.has(e.type)) return !1;
|
|
631
651
|
let n = t?.fields?.[e.name];
|
|
632
|
-
return n ? !
|
|
652
|
+
return n ? !se(n.type) : !0;
|
|
633
653
|
});
|
|
634
654
|
}
|
|
635
|
-
function
|
|
655
|
+
function me(e) {
|
|
636
656
|
return e <= 1 ? "default" : e === 2 ? "xl" : "full";
|
|
637
657
|
}
|
|
638
658
|
function $(e, t, n, r) {
|
|
639
659
|
let i = [...e];
|
|
640
|
-
if (i =
|
|
660
|
+
if (i = de(i, t), r === "create" && (i = pe(i, t)), n !== void 0) return i = le(i, n), {
|
|
641
661
|
fields: i,
|
|
642
662
|
columns: n
|
|
643
663
|
};
|
|
644
|
-
let a =
|
|
645
|
-
return i =
|
|
664
|
+
let a = ce(i.length);
|
|
665
|
+
return i = le(i, a), {
|
|
646
666
|
fields: i,
|
|
647
667
|
columns: a
|
|
648
668
|
};
|
|
649
669
|
}
|
|
650
670
|
//#endregion
|
|
651
671
|
//#region src/sanitize.ts
|
|
652
|
-
var
|
|
672
|
+
var he = new Set([
|
|
653
673
|
"id",
|
|
654
674
|
"_id",
|
|
655
675
|
"created_at",
|
|
@@ -658,7 +678,7 @@ var de = new Set([
|
|
|
658
678
|
"updatedAt",
|
|
659
679
|
"organization_id",
|
|
660
680
|
"organizationId"
|
|
661
|
-
]),
|
|
681
|
+
]), ge = new Set([
|
|
662
682
|
"formula",
|
|
663
683
|
"rollup",
|
|
664
684
|
"lookup_value",
|
|
@@ -666,15 +686,15 @@ var de = new Set([
|
|
|
666
686
|
"autonumber",
|
|
667
687
|
"computed"
|
|
668
688
|
]);
|
|
669
|
-
function
|
|
689
|
+
function _e(e, t) {
|
|
670
690
|
if (!e || typeof e != "object") return e;
|
|
671
691
|
let n = {}, r = t?.fields;
|
|
672
|
-
for (let [t, i] of Object.entries(e)) if (!
|
|
692
|
+
for (let [t, i] of Object.entries(e)) if (!he.has(t)) {
|
|
673
693
|
if (r) {
|
|
674
694
|
let e = r[t];
|
|
675
695
|
if (!e) continue;
|
|
676
696
|
let n = String(e.type || "").toLowerCase();
|
|
677
|
-
if (
|
|
697
|
+
if (ge.has(n) || e.computed === !0 || e.formula || e.readOnly === !0 || e.readonly === !0) continue;
|
|
678
698
|
}
|
|
679
699
|
n[t] = i;
|
|
680
700
|
}
|
|
@@ -682,13 +702,13 @@ function pe(e, t) {
|
|
|
682
702
|
}
|
|
683
703
|
//#endregion
|
|
684
704
|
//#region src/DrawerForm.tsx
|
|
685
|
-
var
|
|
705
|
+
var ve = {
|
|
686
706
|
1: void 0,
|
|
687
707
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
688
708
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
689
709
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
690
|
-
},
|
|
691
|
-
let { fieldLabel:
|
|
710
|
+
}, ye = ({ schema: e, dataSource: r, className: a }) => {
|
|
711
|
+
let { fieldLabel: s } = l(), [d, f] = o(null), [m, h] = o([]), [g, _] = o({}), [v, y] = o(!0), [b, x] = o(null), S = e.open !== !1, C = e.drawerSide || "right", [w, T] = o(() => {
|
|
692
712
|
let t = {};
|
|
693
713
|
return e.sections?.forEach((e, n) => {
|
|
694
714
|
let r = e.name || String(n);
|
|
@@ -702,7 +722,7 @@ var me = {
|
|
|
702
722
|
return;
|
|
703
723
|
}
|
|
704
724
|
try {
|
|
705
|
-
|
|
725
|
+
f(await r.getObjectSchema(e.objectName));
|
|
706
726
|
} catch (e) {
|
|
707
727
|
x(e), y(!1);
|
|
708
728
|
}
|
|
@@ -743,13 +763,13 @@ var me = {
|
|
|
743
763
|
let r = d.fields[t];
|
|
744
764
|
n.push({
|
|
745
765
|
name: t,
|
|
746
|
-
label:
|
|
747
|
-
type:
|
|
766
|
+
label: s(e.objectName, t, r.label || t),
|
|
767
|
+
type: p(r.type),
|
|
748
768
|
required: r.required || !1,
|
|
749
769
|
disabled: e.readOnly || e.mode === "view" || r.readonly,
|
|
750
770
|
placeholder: r.placeholder,
|
|
751
771
|
description: r.help || r.description,
|
|
752
|
-
validation:
|
|
772
|
+
validation: u(r),
|
|
753
773
|
field: r,
|
|
754
774
|
options: r.options,
|
|
755
775
|
multiple: r.multiple
|
|
@@ -784,13 +804,13 @@ var me = {
|
|
|
784
804
|
let i = d.fields?.[t];
|
|
785
805
|
i && n.push({
|
|
786
806
|
name: t,
|
|
787
|
-
label:
|
|
788
|
-
type:
|
|
807
|
+
label: s(e.objectName, t, i.label || t),
|
|
808
|
+
type: p(i.type),
|
|
789
809
|
required: i.required || !1,
|
|
790
810
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
791
811
|
placeholder: i.placeholder,
|
|
792
812
|
description: i.help || i.description,
|
|
793
|
-
validation:
|
|
813
|
+
validation: u(i),
|
|
794
814
|
field: i,
|
|
795
815
|
options: i.options,
|
|
796
816
|
multiple: i.multiple
|
|
@@ -806,10 +826,10 @@ var me = {
|
|
|
806
826
|
e.mode,
|
|
807
827
|
r
|
|
808
828
|
]);
|
|
809
|
-
let
|
|
829
|
+
let D = t(async (t) => {
|
|
810
830
|
if (!r) return e.onSuccess && await e.onSuccess(t), e.onOpenChange?.(!1), t;
|
|
811
831
|
try {
|
|
812
|
-
let n, i =
|
|
832
|
+
let n, i = _e(t, d);
|
|
813
833
|
return e.mode === "create" ? n = await r.create(e.objectName, i) : e.mode === "edit" && e.recordId && (n = await r.update(e.objectName, e.recordId, i)), e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
814
834
|
} catch (t) {
|
|
815
835
|
throw e.onError && e.onError(t), t;
|
|
@@ -836,32 +856,32 @@ var me = {
|
|
|
836
856
|
cancelLabel: e.cancelText,
|
|
837
857
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
838
858
|
showCancel: e.showCancel !== !1,
|
|
839
|
-
onSubmit:
|
|
859
|
+
onSubmit: D,
|
|
840
860
|
onCancel: N
|
|
841
861
|
};
|
|
842
|
-
return /* @__PURE__ */
|
|
862
|
+
return /* @__PURE__ */ q(O, {
|
|
843
863
|
open: S,
|
|
844
864
|
onOpenChange: e.onOpenChange,
|
|
845
|
-
children: /* @__PURE__ */
|
|
865
|
+
children: /* @__PURE__ */ J(k, {
|
|
846
866
|
side: C,
|
|
847
|
-
className:
|
|
867
|
+
className: R("overflow-y-auto", a, e.className),
|
|
848
868
|
style: P,
|
|
849
|
-
children: [(e.title || e.description) && /* @__PURE__ */
|
|
869
|
+
children: [(e.title || e.description) && /* @__PURE__ */ J(j, { children: [e.title && /* @__PURE__ */ q(M, { children: e.title }), e.description && /* @__PURE__ */ q(A, { children: e.description })] }), /* @__PURE__ */ q("div", {
|
|
850
870
|
className: "@container py-4",
|
|
851
871
|
children: (() => {
|
|
852
|
-
if (b) return /* @__PURE__ */
|
|
872
|
+
if (b) return /* @__PURE__ */ J("div", {
|
|
853
873
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
854
|
-
children: [/* @__PURE__ */
|
|
874
|
+
children: [/* @__PURE__ */ q("h3", {
|
|
855
875
|
className: "text-red-800 font-semibold",
|
|
856
876
|
children: "Error loading form"
|
|
857
|
-
}), /* @__PURE__ */
|
|
877
|
+
}), /* @__PURE__ */ q("p", {
|
|
858
878
|
className: "text-red-600 text-sm mt-1",
|
|
859
879
|
children: b.message
|
|
860
880
|
})]
|
|
861
881
|
});
|
|
862
|
-
if (v) return /* @__PURE__ */
|
|
882
|
+
if (v) return /* @__PURE__ */ J("div", {
|
|
863
883
|
className: "p-8 text-center",
|
|
864
|
-
children: [/* @__PURE__ */
|
|
884
|
+
children: [/* @__PURE__ */ q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ q("p", {
|
|
865
885
|
className: "mt-2 text-sm text-gray-600",
|
|
866
886
|
children: "Loading form..."
|
|
867
887
|
})]
|
|
@@ -887,13 +907,13 @@ var me = {
|
|
|
887
907
|
...e,
|
|
888
908
|
hidden: !0
|
|
889
909
|
}))) : t.push(...a);
|
|
890
|
-
}), /* @__PURE__ */
|
|
910
|
+
}), /* @__PURE__ */ q(c, { schema: {
|
|
891
911
|
...F,
|
|
892
912
|
fields: t
|
|
893
913
|
} });
|
|
894
914
|
}
|
|
895
|
-
let t = $(m, d, e.columns, e.mode), n =
|
|
896
|
-
return /* @__PURE__ */
|
|
915
|
+
let t = $(m, d, e.columns, e.mode), n = ve[t.columns || 1];
|
|
916
|
+
return /* @__PURE__ */ q(c, { schema: {
|
|
897
917
|
...F,
|
|
898
918
|
fields: t.fields,
|
|
899
919
|
columns: t.columns,
|
|
@@ -903,19 +923,19 @@ var me = {
|
|
|
903
923
|
})]
|
|
904
924
|
})
|
|
905
925
|
});
|
|
906
|
-
},
|
|
926
|
+
}, be = {
|
|
907
927
|
sm: "sm:max-w-sm",
|
|
908
928
|
default: "sm:max-w-lg",
|
|
909
929
|
lg: "sm:max-w-2xl",
|
|
910
930
|
xl: "sm:max-w-5xl",
|
|
911
931
|
full: "sm:max-w-[95vw] sm:w-full"
|
|
912
|
-
},
|
|
932
|
+
}, xe = {
|
|
913
933
|
1: void 0,
|
|
914
934
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
915
935
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
916
936
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
917
|
-
},
|
|
918
|
-
let { fieldLabel:
|
|
937
|
+
}, Se = ({ schema: e, dataSource: a, className: s }) => {
|
|
938
|
+
let { fieldLabel: f } = l(), h = B(), g = t((t) => {
|
|
919
939
|
if (!h?.isLoaded) return t;
|
|
920
940
|
let n = [];
|
|
921
941
|
for (let r of t) {
|
|
@@ -934,50 +954,50 @@ var me = {
|
|
|
934
954
|
h,
|
|
935
955
|
e.objectName,
|
|
936
956
|
e.mode
|
|
937
|
-
]), [_, v] =
|
|
938
|
-
|
|
957
|
+
]), [_, v] = o(null), [y, T] = o([]), [E, D] = o({}), [O, k] = o(!0), [A, j] = o(null), [M, P] = o(!1), F = e.open !== !1, I = r(), L = i(() => e.sections?.length || e.customFields?.length ? null : $(y, _, e.columns, e.mode), [
|
|
958
|
+
y,
|
|
939
959
|
_,
|
|
940
960
|
e.columns,
|
|
941
961
|
e.mode,
|
|
942
962
|
e.sections,
|
|
943
963
|
e.customFields
|
|
944
|
-
]),
|
|
964
|
+
]), z = be[i(() => {
|
|
945
965
|
if (e.modalSize) return e.modalSize;
|
|
946
|
-
if (
|
|
966
|
+
if (L?.columns && L.columns > 1) return me(L.columns);
|
|
947
967
|
if (e.sections?.length) {
|
|
948
968
|
let t = Math.max(...e.sections.map((e) => Number(e.columns) || 1));
|
|
949
|
-
if (t > 1) return
|
|
969
|
+
if (t > 1) return me(t);
|
|
950
970
|
}
|
|
951
971
|
return "default";
|
|
952
972
|
}, [
|
|
953
973
|
e.modalSize,
|
|
954
|
-
|
|
974
|
+
L,
|
|
955
975
|
e.sections
|
|
956
|
-
])] ||
|
|
976
|
+
])] || be.default;
|
|
957
977
|
n(() => {
|
|
958
978
|
(async () => {
|
|
959
|
-
if (!
|
|
979
|
+
if (!a) {
|
|
960
980
|
k(!1);
|
|
961
981
|
return;
|
|
962
982
|
}
|
|
963
983
|
try {
|
|
964
|
-
v(await
|
|
984
|
+
v(await a.getObjectSchema(e.objectName));
|
|
965
985
|
} catch (e) {
|
|
966
986
|
j(e), k(!1);
|
|
967
987
|
}
|
|
968
988
|
})();
|
|
969
|
-
}, [e.objectName,
|
|
970
|
-
(_ || !
|
|
989
|
+
}, [e.objectName, a]), n(() => {
|
|
990
|
+
(_ || !a) && (async () => {
|
|
971
991
|
if (e.mode === "create" || !e.recordId) {
|
|
972
992
|
D(e.initialData || e.initialValues || {}), k(!1);
|
|
973
993
|
return;
|
|
974
994
|
}
|
|
975
|
-
if (!
|
|
995
|
+
if (!a) {
|
|
976
996
|
D(e.initialData || e.initialValues || {}), k(!1);
|
|
977
997
|
return;
|
|
978
998
|
}
|
|
979
999
|
try {
|
|
980
|
-
D(await
|
|
1000
|
+
D(await a.findOne(e.objectName, e.recordId) || {});
|
|
981
1001
|
} catch (e) {
|
|
982
1002
|
j(e);
|
|
983
1003
|
} finally {
|
|
@@ -990,13 +1010,13 @@ var me = {
|
|
|
990
1010
|
e.recordId,
|
|
991
1011
|
e.initialData,
|
|
992
1012
|
e.initialValues,
|
|
993
|
-
|
|
1013
|
+
a,
|
|
994
1014
|
e.objectName
|
|
995
1015
|
]);
|
|
996
|
-
let
|
|
1016
|
+
let ee = t((t) => {
|
|
997
1017
|
let n = [], r = (e, t) => typeof t == "string" && t.trim() ? {
|
|
998
1018
|
...e,
|
|
999
|
-
visible: (e) =>
|
|
1019
|
+
visible: (e) => d(t, e)
|
|
1000
1020
|
} : e;
|
|
1001
1021
|
for (let i of t.fields) {
|
|
1002
1022
|
let t = typeof i == "string" ? i : i.name;
|
|
@@ -1005,13 +1025,13 @@ var me = {
|
|
|
1005
1025
|
let i = _.fields[t];
|
|
1006
1026
|
n.push(r({
|
|
1007
1027
|
name: t,
|
|
1008
|
-
label:
|
|
1009
|
-
type:
|
|
1028
|
+
label: f(e.objectName, t, i.label || t),
|
|
1029
|
+
type: p(i.type),
|
|
1010
1030
|
required: i.required || !1,
|
|
1011
1031
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
1012
1032
|
placeholder: i.placeholder,
|
|
1013
1033
|
description: i.help || i.description,
|
|
1014
|
-
validation:
|
|
1034
|
+
validation: u(i),
|
|
1015
1035
|
field: i,
|
|
1016
1036
|
options: i.options,
|
|
1017
1037
|
multiple: i.multiple
|
|
@@ -1030,7 +1050,7 @@ var me = {
|
|
|
1030
1050
|
e.objectName
|
|
1031
1051
|
]);
|
|
1032
1052
|
n(() => {
|
|
1033
|
-
if (!_ &&
|
|
1053
|
+
if (!_ && a) return;
|
|
1034
1054
|
if (e.customFields?.length) {
|
|
1035
1055
|
T(e.customFields), k(!1);
|
|
1036
1056
|
return;
|
|
@@ -1047,13 +1067,13 @@ var me = {
|
|
|
1047
1067
|
let i = _.fields?.[t];
|
|
1048
1068
|
i && n.push({
|
|
1049
1069
|
name: t,
|
|
1050
|
-
label:
|
|
1051
|
-
type:
|
|
1070
|
+
label: f(e.objectName, t, i.label || t),
|
|
1071
|
+
type: p(i.type),
|
|
1052
1072
|
required: i.required || !1,
|
|
1053
1073
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
1054
1074
|
placeholder: i.placeholder,
|
|
1055
1075
|
description: i.help || i.description,
|
|
1056
|
-
validation:
|
|
1076
|
+
validation: u(i),
|
|
1057
1077
|
field: i,
|
|
1058
1078
|
options: i.options,
|
|
1059
1079
|
multiple: i.multiple
|
|
@@ -1067,19 +1087,19 @@ var me = {
|
|
|
1067
1087
|
e.sections,
|
|
1068
1088
|
e.readOnly,
|
|
1069
1089
|
e.mode,
|
|
1070
|
-
|
|
1090
|
+
a
|
|
1071
1091
|
]);
|
|
1072
|
-
let
|
|
1092
|
+
let V = t(async (t) => {
|
|
1073
1093
|
P(!0);
|
|
1074
1094
|
try {
|
|
1075
|
-
if (!
|
|
1076
|
-
let n, r =
|
|
1095
|
+
if (!a) return e.onSuccess && await e.onSuccess(t), e.onOpenChange?.(!1), t;
|
|
1096
|
+
let n, r = _e(t, _);
|
|
1077
1097
|
if (h?.isLoaded) {
|
|
1078
1098
|
let t = {};
|
|
1079
1099
|
for (let n of Object.keys(r)) h.checkField(e.objectName, n, "write") && (t[n] = r[n]);
|
|
1080
1100
|
r = t;
|
|
1081
1101
|
}
|
|
1082
|
-
return e.mode === "create" ? n = await
|
|
1102
|
+
return e.mode === "create" ? n = await a.create(e.objectName, r) : e.mode === "edit" && e.recordId && (n = await a.update(e.objectName, e.recordId, r)), e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
1083
1103
|
} catch (t) {
|
|
1084
1104
|
throw e.onError && e.onError(t), t;
|
|
1085
1105
|
} finally {
|
|
@@ -1087,110 +1107,110 @@ var me = {
|
|
|
1087
1107
|
}
|
|
1088
1108
|
}, [
|
|
1089
1109
|
e,
|
|
1090
|
-
|
|
1110
|
+
a,
|
|
1091
1111
|
_,
|
|
1092
1112
|
h
|
|
1093
|
-
]),
|
|
1113
|
+
]), H = t(() => {
|
|
1094
1114
|
e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
|
|
1095
|
-
}, [e]), te = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical",
|
|
1115
|
+
}, [e]), te = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", U = e.showSubmit !== !1 && e.mode !== "view", W = e.showCancel !== !1, G = e.submitText || (e.mode === "create" ? "Create" : "Update"), K = e.cancelText || "Cancel", X = {
|
|
1096
1116
|
type: "form",
|
|
1097
1117
|
layout: te,
|
|
1098
1118
|
defaultValues: E,
|
|
1099
|
-
submitLabel:
|
|
1100
|
-
cancelLabel:
|
|
1101
|
-
showSubmit:
|
|
1102
|
-
showCancel:
|
|
1103
|
-
onSubmit:
|
|
1104
|
-
onCancel:
|
|
1119
|
+
submitLabel: G,
|
|
1120
|
+
cancelLabel: K,
|
|
1121
|
+
showSubmit: U,
|
|
1122
|
+
showCancel: W,
|
|
1123
|
+
onSubmit: V,
|
|
1124
|
+
onCancel: H,
|
|
1105
1125
|
showActions: !1,
|
|
1106
1126
|
id: I
|
|
1107
|
-
},
|
|
1108
|
-
if (A) return /* @__PURE__ */
|
|
1127
|
+
}, Z = () => {
|
|
1128
|
+
if (A) return /* @__PURE__ */ J("div", {
|
|
1109
1129
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1110
|
-
children: [/* @__PURE__ */
|
|
1130
|
+
children: [/* @__PURE__ */ q("h3", {
|
|
1111
1131
|
className: "text-red-800 font-semibold",
|
|
1112
1132
|
children: "Error loading form"
|
|
1113
|
-
}), /* @__PURE__ */
|
|
1133
|
+
}), /* @__PURE__ */ q("p", {
|
|
1114
1134
|
className: "text-red-600 text-sm mt-1",
|
|
1115
1135
|
children: A.message
|
|
1116
1136
|
})]
|
|
1117
1137
|
});
|
|
1118
|
-
if (O) return /* @__PURE__ */
|
|
1138
|
+
if (O) return /* @__PURE__ */ q("div", {
|
|
1119
1139
|
className: "space-y-4",
|
|
1120
1140
|
"data-testid": "modal-form-skeleton",
|
|
1121
1141
|
children: [
|
|
1122
1142
|
1,
|
|
1123
1143
|
2,
|
|
1124
1144
|
3
|
|
1125
|
-
].map((e) => /* @__PURE__ */
|
|
1145
|
+
].map((e) => /* @__PURE__ */ J("div", {
|
|
1126
1146
|
className: "space-y-2",
|
|
1127
|
-
children: [/* @__PURE__ */
|
|
1147
|
+
children: [/* @__PURE__ */ q(N, { className: "h-4 w-24" }), /* @__PURE__ */ q(N, { className: "h-10 w-full" })]
|
|
1128
1148
|
}, e))
|
|
1129
1149
|
});
|
|
1130
|
-
if (e.sections?.length) return /* @__PURE__ */
|
|
1150
|
+
if (e.sections?.length) return /* @__PURE__ */ q("div", {
|
|
1131
1151
|
className: "space-y-6",
|
|
1132
1152
|
children: e.sections.map((e, t) => {
|
|
1133
1153
|
let n = e.columns || 1;
|
|
1134
|
-
return /* @__PURE__ */
|
|
1154
|
+
return /* @__PURE__ */ q(Y, {
|
|
1135
1155
|
label: e.label,
|
|
1136
1156
|
description: e.description,
|
|
1137
1157
|
columns: n,
|
|
1138
|
-
gridClassName:
|
|
1139
|
-
children: /* @__PURE__ */
|
|
1140
|
-
...
|
|
1141
|
-
fields: g(
|
|
1158
|
+
gridClassName: xe[n],
|
|
1159
|
+
children: /* @__PURE__ */ q(c, { schema: {
|
|
1160
|
+
...X,
|
|
1161
|
+
fields: g(ee(e))
|
|
1142
1162
|
} })
|
|
1143
1163
|
}, e.name || e.label || t);
|
|
1144
1164
|
})
|
|
1145
1165
|
});
|
|
1146
|
-
let t =
|
|
1147
|
-
return /* @__PURE__ */
|
|
1148
|
-
...
|
|
1166
|
+
let t = L ?? $(y, _, e.columns, e.mode), n = xe[t.columns || 1];
|
|
1167
|
+
return /* @__PURE__ */ q(c, { schema: {
|
|
1168
|
+
...X,
|
|
1149
1169
|
fields: g(t.fields),
|
|
1150
1170
|
columns: t.columns,
|
|
1151
1171
|
...n ? { fieldContainerClass: n } : {}
|
|
1152
1172
|
} });
|
|
1153
|
-
}, Q = !O && !A && (
|
|
1154
|
-
return /* @__PURE__ */
|
|
1173
|
+
}, Q = !O && !A && (U || W);
|
|
1174
|
+
return /* @__PURE__ */ q(b, {
|
|
1155
1175
|
open: F,
|
|
1156
1176
|
onOpenChange: e.onOpenChange,
|
|
1157
|
-
children: /* @__PURE__ */
|
|
1158
|
-
className:
|
|
1177
|
+
children: /* @__PURE__ */ J(w, {
|
|
1178
|
+
className: R(z, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", s, e.className),
|
|
1159
1179
|
children: [
|
|
1160
|
-
(e.title || e.description) && /* @__PURE__ */
|
|
1180
|
+
(e.title || e.description) && /* @__PURE__ */ J(S, {
|
|
1161
1181
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
1162
|
-
children: [e.title && /* @__PURE__ */
|
|
1182
|
+
children: [e.title && /* @__PURE__ */ q(C, { children: e.title }), e.description && /* @__PURE__ */ q(x, { children: e.description })]
|
|
1163
1183
|
}),
|
|
1164
|
-
/* @__PURE__ */
|
|
1184
|
+
/* @__PURE__ */ q("div", {
|
|
1165
1185
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
1166
|
-
children:
|
|
1186
|
+
children: Z()
|
|
1167
1187
|
}),
|
|
1168
|
-
Q && /* @__PURE__ */
|
|
1188
|
+
Q && /* @__PURE__ */ q("div", {
|
|
1169
1189
|
className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background",
|
|
1170
1190
|
"data-testid": "modal-form-footer",
|
|
1171
|
-
children: /* @__PURE__ */
|
|
1191
|
+
children: /* @__PURE__ */ J("div", {
|
|
1172
1192
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
1173
|
-
children: [
|
|
1193
|
+
children: [W && /* @__PURE__ */ q(m, {
|
|
1174
1194
|
type: "button",
|
|
1175
1195
|
variant: "outline",
|
|
1176
|
-
onClick:
|
|
1177
|
-
disabled:
|
|
1196
|
+
onClick: H,
|
|
1197
|
+
disabled: M,
|
|
1178
1198
|
className: "w-full sm:w-auto",
|
|
1179
|
-
children:
|
|
1180
|
-
}),
|
|
1199
|
+
children: K
|
|
1200
|
+
}), U && /* @__PURE__ */ J(m, {
|
|
1181
1201
|
type: "submit",
|
|
1182
1202
|
form: I,
|
|
1183
|
-
disabled:
|
|
1203
|
+
disabled: M,
|
|
1184
1204
|
className: "w-full sm:w-auto",
|
|
1185
|
-
children: [
|
|
1205
|
+
children: [M && /* @__PURE__ */ q(ne, { className: "mr-2 h-4 w-4 animate-spin" }), G]
|
|
1186
1206
|
})]
|
|
1187
1207
|
})
|
|
1188
1208
|
})
|
|
1189
1209
|
]
|
|
1190
1210
|
})
|
|
1191
1211
|
});
|
|
1192
|
-
},
|
|
1193
|
-
let n =
|
|
1212
|
+
}, Ce = ({ schema: e, dataSource: t }) => {
|
|
1213
|
+
let n = B(), r = i(() => {
|
|
1194
1214
|
if (!n?.isLoaded) return e;
|
|
1195
1215
|
let t = (t) => t?.name ? n.checkField(e.objectName, t.name, "read") ? !n.checkField(e.objectName, t.name, "write") && e.mode !== "view" ? {
|
|
1196
1216
|
...t,
|
|
@@ -1205,8 +1225,8 @@ var me = {
|
|
|
1205
1225
|
fields: r(e.fields)
|
|
1206
1226
|
}))
|
|
1207
1227
|
};
|
|
1208
|
-
}, [e, n]), { sectionLabel: a } =
|
|
1209
|
-
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */
|
|
1228
|
+
}, [e, n]), { sectionLabel: a } = l(), o = (e) => e?.name ? a(r.objectName, e.name, e.label || e.name) : e?.label;
|
|
1229
|
+
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ q(X, {
|
|
1210
1230
|
schema: {
|
|
1211
1231
|
...r,
|
|
1212
1232
|
formType: "tabbed",
|
|
@@ -1223,7 +1243,7 @@ var me = {
|
|
|
1223
1243
|
dataSource: t,
|
|
1224
1244
|
className: r.className
|
|
1225
1245
|
});
|
|
1226
|
-
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */
|
|
1246
|
+
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ q(Z, {
|
|
1227
1247
|
schema: {
|
|
1228
1248
|
...r,
|
|
1229
1249
|
formType: "wizard",
|
|
@@ -1243,7 +1263,7 @@ var me = {
|
|
|
1243
1263
|
dataSource: t,
|
|
1244
1264
|
className: r.className
|
|
1245
1265
|
});
|
|
1246
|
-
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */
|
|
1266
|
+
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ q(Q, {
|
|
1247
1267
|
schema: {
|
|
1248
1268
|
...r,
|
|
1249
1269
|
formType: "split",
|
|
@@ -1263,7 +1283,7 @@ var me = {
|
|
|
1263
1283
|
});
|
|
1264
1284
|
if (r.formType === "drawer") {
|
|
1265
1285
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
1266
|
-
return /* @__PURE__ */
|
|
1286
|
+
return /* @__PURE__ */ q(ye, {
|
|
1267
1287
|
schema: {
|
|
1268
1288
|
...n,
|
|
1269
1289
|
layout: i,
|
|
@@ -1288,7 +1308,7 @@ var me = {
|
|
|
1288
1308
|
}
|
|
1289
1309
|
if (r.formType === "modal") {
|
|
1290
1310
|
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
1291
|
-
return /* @__PURE__ */
|
|
1311
|
+
return /* @__PURE__ */ q(Se, {
|
|
1292
1312
|
schema: {
|
|
1293
1313
|
...n,
|
|
1294
1314
|
layout: i,
|
|
@@ -1309,12 +1329,12 @@ var me = {
|
|
|
1309
1329
|
className: r.className
|
|
1310
1330
|
});
|
|
1311
1331
|
}
|
|
1312
|
-
return /* @__PURE__ */
|
|
1332
|
+
return /* @__PURE__ */ q(we, {
|
|
1313
1333
|
schema: r,
|
|
1314
1334
|
dataSource: t
|
|
1315
1335
|
});
|
|
1316
|
-
},
|
|
1317
|
-
let { fieldLabel:
|
|
1336
|
+
}, we = ({ schema: r, dataSource: i }) => {
|
|
1337
|
+
let { fieldLabel: a, sectionLabel: s } = l(), m = z(), h = B(), g = t((e) => {
|
|
1318
1338
|
if (!h?.isLoaded) return e;
|
|
1319
1339
|
let t = [];
|
|
1320
1340
|
for (let n of e) h.checkField(r.objectName, n.name, "read") && (!h.checkField(r.objectName, n.name, "write") && r.mode !== "view" ? t.push({
|
|
@@ -1328,7 +1348,7 @@ var me = {
|
|
|
1328
1348
|
h,
|
|
1329
1349
|
r.objectName,
|
|
1330
1350
|
r.mode
|
|
1331
|
-
]), [_, v] =
|
|
1351
|
+
]), [_, v] = o(null), [y, b] = o([]), [x, S] = o(null), [C, w] = o(!0), [T, E] = o(null), D = r.customFields && r.customFields.length > 0;
|
|
1332
1352
|
n(() => {
|
|
1333
1353
|
D && (S(r.initialData || r.initialValues || {}), w(!1));
|
|
1334
1354
|
}, [
|
|
@@ -1389,7 +1409,7 @@ var me = {
|
|
|
1389
1409
|
let t = e.visibleOn;
|
|
1390
1410
|
return typeof t == "string" && t.trim() ? {
|
|
1391
1411
|
...e,
|
|
1392
|
-
visible: (e) =>
|
|
1412
|
+
visible: (e) => d(t, e)
|
|
1393
1413
|
} : e;
|
|
1394
1414
|
}, []);
|
|
1395
1415
|
n(() => {
|
|
@@ -1404,27 +1424,27 @@ var me = {
|
|
|
1404
1424
|
if (!n) return;
|
|
1405
1425
|
let i = _.fields?.[n];
|
|
1406
1426
|
if (!i && !D) return;
|
|
1407
|
-
let
|
|
1408
|
-
if (r.mode !== "view" && !
|
|
1427
|
+
let o = !i?.permissions || i?.permissions.write !== !1;
|
|
1428
|
+
if (r.mode !== "view" && !o) return;
|
|
1409
1429
|
let s = r.customFields?.find((e) => e.name === n);
|
|
1410
1430
|
if (s) e.push(O(s));
|
|
1411
1431
|
else if (i) {
|
|
1412
|
-
let
|
|
1432
|
+
let o = {
|
|
1413
1433
|
name: n,
|
|
1414
|
-
label:
|
|
1415
|
-
type:
|
|
1434
|
+
label: a(r.objectName, n, i.label || t),
|
|
1435
|
+
type: p(i.type),
|
|
1416
1436
|
required: i.required || !1,
|
|
1417
1437
|
disabled: r.readOnly || r.mode === "view" || i.readonly || _?.managedBy && _.managedBy !== "platform",
|
|
1418
1438
|
placeholder: i.placeholder,
|
|
1419
1439
|
description: i.help || i.description,
|
|
1420
|
-
validation:
|
|
1440
|
+
validation: u(i),
|
|
1421
1441
|
field: i
|
|
1422
1442
|
};
|
|
1423
|
-
if ((i.type === "select" || i.type === "lookup" || i.type === "master_detail") && (
|
|
1424
|
-
let e = `Max size: ${
|
|
1425
|
-
|
|
1443
|
+
if ((i.type === "select" || i.type === "lookup" || i.type === "master_detail") && (o.options = i.options || [], o.multiple = i.multiple), (i.type === "number" || i.type === "currency" || i.type === "percent") && (o.inputType = "number", o.min = i.min, o.max = i.max, o.step = i.precision ? 10 ** -i.precision : void 0), i.type === "date" && (o.inputType = "date"), i.type === "datetime" && (o.inputType = "datetime-local"), (i.type === "text" || i.type === "textarea" || i.type === "markdown" || i.type === "html") && (o.maxLength = i.max_length, o.minLength = i.min_length), (i.type === "file" || i.type === "image") && (o.inputType = "file", o.multiple = i.multiple, o.accept = i.accept ? i.accept.join(",") : void 0, i.max_size)) {
|
|
1444
|
+
let e = `Max size: ${f(i.max_size)}`;
|
|
1445
|
+
o.description = o.description ? `${o.description} (${e})` : e;
|
|
1426
1446
|
}
|
|
1427
|
-
i.type === "email" && (
|
|
1447
|
+
i.type === "email" && (o.inputType = "email"), i.type === "phone" && (o.inputType = "tel"), i.type === "url" && (o.inputType = "url"), i.type === "password" && (o.inputType = "password"), i.type === "time" && (o.inputType = "time"), (i.type === "formula" || i.type === "summary" || i.type === "auto_number") && (o.disabled = !0), i.visible_on && (o.visible = (e) => d(i.visible_on, e)), e.push(o);
|
|
1428
1448
|
}
|
|
1429
1449
|
}), b(e), !D && r.recordId && r.mode !== "create" && i || w(!1);
|
|
1430
1450
|
}, [
|
|
@@ -1472,35 +1492,36 @@ var me = {
|
|
|
1472
1492
|
}, [_]),
|
|
1473
1493
|
...x
|
|
1474
1494
|
};
|
|
1475
|
-
if (T) return /* @__PURE__ */
|
|
1495
|
+
if (T) return /* @__PURE__ */ J("div", {
|
|
1476
1496
|
className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1477
|
-
children: [/* @__PURE__ */
|
|
1497
|
+
children: [/* @__PURE__ */ q("h3", {
|
|
1478
1498
|
className: "text-red-800 font-semibold",
|
|
1479
1499
|
children: "Error loading form"
|
|
1480
|
-
}), /* @__PURE__ */
|
|
1500
|
+
}), /* @__PURE__ */ q("p", {
|
|
1481
1501
|
className: "text-red-600 text-sm mt-1",
|
|
1482
1502
|
children: T.message
|
|
1483
1503
|
})]
|
|
1484
1504
|
});
|
|
1485
|
-
if (C) return /* @__PURE__ */
|
|
1505
|
+
if (C) return /* @__PURE__ */ J("div", {
|
|
1486
1506
|
className: "p-4 sm:p-8 text-center",
|
|
1487
|
-
children: [/* @__PURE__ */
|
|
1507
|
+
children: [/* @__PURE__ */ q("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ q("p", {
|
|
1488
1508
|
className: "mt-2 text-sm text-gray-600",
|
|
1489
1509
|
children: "Loading form..."
|
|
1490
1510
|
})]
|
|
1491
1511
|
});
|
|
1492
1512
|
let M = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : "vertical";
|
|
1493
|
-
if (r.sections?.length && (!r.formType || r.formType === "simple")) return /* @__PURE__ */
|
|
1513
|
+
if (r.sections?.length && (!r.formType || r.formType === "simple")) return /* @__PURE__ */ q("div", {
|
|
1494
1514
|
className: "w-full space-y-6",
|
|
1495
1515
|
children: r.sections.map((e, t) => {
|
|
1496
1516
|
let n = e.fields.map((e) => typeof e == "string" ? e : e.name), i = g(y.filter((e) => n.includes(e.name)));
|
|
1497
|
-
return /* @__PURE__ */
|
|
1498
|
-
label: e.name ?
|
|
1517
|
+
return /* @__PURE__ */ q(Y, {
|
|
1518
|
+
label: e.name ? s(r.objectName, e.name, e.label || e.name) : e.label,
|
|
1499
1519
|
description: e.description,
|
|
1500
1520
|
collapsible: e.collapsible,
|
|
1501
1521
|
collapsed: e.collapsed,
|
|
1502
1522
|
columns: e.columns,
|
|
1503
|
-
|
|
1523
|
+
showBorder: e.showBorder,
|
|
1524
|
+
children: /* @__PURE__ */ q(c, { schema: {
|
|
1504
1525
|
type: "form",
|
|
1505
1526
|
fields: i,
|
|
1506
1527
|
layout: M,
|
|
@@ -1524,18 +1545,18 @@ var me = {
|
|
|
1524
1545
|
...e,
|
|
1525
1546
|
mobile_fullscreen: !0
|
|
1526
1547
|
} : e;
|
|
1527
|
-
}) : F.fields,
|
|
1528
|
-
if (!r.formType && !N && L.length >= 2 && (
|
|
1548
|
+
}) : F.fields, R = I?.stepper, ee = I?.stepperMinFields ?? 8, V = Math.max(1, I?.stepperFieldsPerStep ?? 1);
|
|
1549
|
+
if (!r.formType && !N && L.length >= 2 && (R === !0 || R === "auto" && m && L.length >= ee)) {
|
|
1529
1550
|
let e = L, t = [];
|
|
1530
|
-
for (let n = 0; n < e.length; n +=
|
|
1531
|
-
let r = e.slice(n, n +
|
|
1551
|
+
for (let n = 0; n < e.length; n += V) {
|
|
1552
|
+
let r = e.slice(n, n + V);
|
|
1532
1553
|
t.push({
|
|
1533
|
-
name: `step-${Math.floor(n /
|
|
1534
|
-
label: r[0]?.label || r[0]?.name || `Step ${Math.floor(n /
|
|
1554
|
+
name: `step-${Math.floor(n / V) + 1}`,
|
|
1555
|
+
label: r[0]?.label || r[0]?.name || `Step ${Math.floor(n / V) + 1}`,
|
|
1535
1556
|
fields: r
|
|
1536
1557
|
});
|
|
1537
1558
|
}
|
|
1538
|
-
return /* @__PURE__ */
|
|
1559
|
+
return /* @__PURE__ */ q(Z, {
|
|
1539
1560
|
schema: {
|
|
1540
1561
|
...r,
|
|
1541
1562
|
formType: "wizard",
|
|
@@ -1546,7 +1567,7 @@ var me = {
|
|
|
1546
1567
|
className: r.className
|
|
1547
1568
|
});
|
|
1548
1569
|
}
|
|
1549
|
-
let
|
|
1570
|
+
let H = {
|
|
1550
1571
|
type: "form",
|
|
1551
1572
|
fields: L,
|
|
1552
1573
|
layout: M,
|
|
@@ -1562,125 +1583,295 @@ var me = {
|
|
|
1562
1583
|
className: r.className,
|
|
1563
1584
|
mobileStickyActions: !!I?.stickyActions
|
|
1564
1585
|
};
|
|
1565
|
-
return /* @__PURE__ */
|
|
1586
|
+
return /* @__PURE__ */ q("div", {
|
|
1566
1587
|
className: I?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
|
|
1567
1588
|
"data-mobile-form": I ? "true" : void 0,
|
|
1568
|
-
children: /* @__PURE__ */
|
|
1589
|
+
children: /* @__PURE__ */ q(c, { schema: H })
|
|
1590
|
+
});
|
|
1591
|
+
}, Te = {
|
|
1592
|
+
text: 200,
|
|
1593
|
+
email: 254,
|
|
1594
|
+
url: 2048,
|
|
1595
|
+
phone: 32,
|
|
1596
|
+
textarea: 5e3,
|
|
1597
|
+
markdown: 5e3,
|
|
1598
|
+
html: 5e3
|
|
1599
|
+
}, Ee = "_company_website_2", De = 1500;
|
|
1600
|
+
function Oe(e, t = []) {
|
|
1601
|
+
try {
|
|
1602
|
+
let n = new URL(e, typeof window < "u" ? window.location.href : "http://localhost");
|
|
1603
|
+
return typeof window < "u" && n.origin === window.location.origin ? !0 : n.protocol !== "https:" && n.protocol !== "http:" ? !1 : t.some((e) => {
|
|
1604
|
+
if (e === n.host) return !0;
|
|
1605
|
+
if (e.startsWith("*.")) {
|
|
1606
|
+
let t = e.slice(1);
|
|
1607
|
+
return n.host.endsWith(t) && n.host.length > t.length;
|
|
1608
|
+
}
|
|
1609
|
+
return !1;
|
|
1610
|
+
});
|
|
1611
|
+
} catch {
|
|
1612
|
+
return !1;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
function ke(e) {
|
|
1616
|
+
return e && e.map((e) => {
|
|
1617
|
+
let t = Te[String(e.type || "").toLowerCase()];
|
|
1618
|
+
return !t || (e.maxLength ?? e.max_length) ? e : {
|
|
1619
|
+
...e,
|
|
1620
|
+
maxLength: t
|
|
1621
|
+
};
|
|
1569
1622
|
});
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1623
|
+
}
|
|
1624
|
+
var Ae = ({ config: e, dataSource: r, prefillParams: s, className: c }) => {
|
|
1625
|
+
let [l, u] = o(!1), [d, f] = o(!1), [p, h] = o(null), [g, _] = o(!(e.consent?.required ?? !!e.consent)), [v, y] = o(null), b = a(null), x = a(Date.now());
|
|
1626
|
+
n(() => {
|
|
1627
|
+
l || (x.current = Date.now());
|
|
1628
|
+
}, [l]);
|
|
1629
|
+
let S = e.honeypot === !1 ? null : e.honeypot || Ee, C = e.minFillTime ?? De, w = i(() => ke(e.customFields), [e.customFields]), T = i(() => {
|
|
1630
|
+
if (!r || w && w.length > 0 || !e.fields || e.fields.length === 0) return;
|
|
1631
|
+
let t = async (e, t) => t;
|
|
1632
|
+
return {
|
|
1633
|
+
...r,
|
|
1634
|
+
create: t,
|
|
1635
|
+
update: (e, t, n) => Promise.resolve(n),
|
|
1636
|
+
delete: () => Promise.reject(/* @__PURE__ */ Error("Not permitted on public form"))
|
|
1637
|
+
};
|
|
1638
|
+
}, [
|
|
1639
|
+
r,
|
|
1640
|
+
w,
|
|
1641
|
+
e.fields
|
|
1642
|
+
]), E = i(() => {
|
|
1643
|
+
let t = {};
|
|
1644
|
+
if (s) for (let [e, n] of Object.entries(s)) t[e] = n;
|
|
1645
|
+
if (typeof window < "u" && e.allowedPrefillFields?.length) {
|
|
1646
|
+
let n = new Set(e.allowedPrefillFields);
|
|
1647
|
+
new URLSearchParams(window.location.search).forEach((e, r) => {
|
|
1648
|
+
n.has(r) && !(r in t) && (t[r] = e);
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
1652
|
+
}, [s, e.allowedPrefillFields]), D = t(async (t) => {
|
|
1653
|
+
if (e.consent?.required && !g) {
|
|
1654
|
+
y(e.texts?.consentRequired ?? "Please accept the privacy policy to continue.");
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
if (y(null), S && b.current?.value) {
|
|
1658
|
+
u(!0);
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
if (C > 0 && Date.now() - x.current < C) {
|
|
1662
|
+
h(e.texts?.rateLimited ?? "Please take a moment to review your answers before submitting.");
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
let n = { ...t };
|
|
1666
|
+
S && delete n[S], e.captchaToken && (n._captcha = e.captchaToken), f(!0), h(null);
|
|
1579
1667
|
try {
|
|
1580
|
-
|
|
1581
|
-
|
|
1668
|
+
r && await r.create(e.objectName, n), u(!0);
|
|
1669
|
+
let t = e.thankYouPage?.redirectUrl;
|
|
1670
|
+
if (t) if (Oe(t, e.allowedRedirectHosts)) {
|
|
1671
|
+
let n = e.thankYouPage?.redirectDelay ?? 3e3;
|
|
1582
1672
|
setTimeout(() => {
|
|
1583
|
-
window.location.href =
|
|
1584
|
-
},
|
|
1585
|
-
}
|
|
1673
|
+
window.location.href = t;
|
|
1674
|
+
}, n);
|
|
1675
|
+
} else console.warn("[EmbeddableForm] Blocked unsafe redirect target:", t), h(e.texts?.redirectBlocked ?? null);
|
|
1586
1676
|
} catch (e) {
|
|
1587
|
-
|
|
1677
|
+
h(e instanceof Error ? e.message : "Failed to submit form. Please try again.");
|
|
1588
1678
|
} finally {
|
|
1589
|
-
|
|
1679
|
+
f(!1);
|
|
1590
1680
|
}
|
|
1591
|
-
}, [
|
|
1592
|
-
|
|
1593
|
-
|
|
1681
|
+
}, [
|
|
1682
|
+
r,
|
|
1683
|
+
e,
|
|
1684
|
+
g,
|
|
1685
|
+
S,
|
|
1686
|
+
C
|
|
1687
|
+
]), O = t(() => {
|
|
1688
|
+
u(!1), h(null);
|
|
1689
|
+
}, []), k = i(() => {
|
|
1594
1690
|
let t = {};
|
|
1595
1691
|
return e.branding?.backgroundColor && (t.backgroundColor = e.branding.backgroundColor), t;
|
|
1596
1692
|
}, [e.branding]);
|
|
1597
|
-
if (
|
|
1598
|
-
let t = e.thankYouPage;
|
|
1599
|
-
return /* @__PURE__ */
|
|
1600
|
-
className: `min-h-screen flex items-center justify-center p-4 ${
|
|
1601
|
-
style:
|
|
1602
|
-
children: /* @__PURE__ */
|
|
1603
|
-
className: "max-w-md w-full bg-card rounded-
|
|
1693
|
+
if (l) {
|
|
1694
|
+
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));
|
|
1695
|
+
return /* @__PURE__ */ q("div", {
|
|
1696
|
+
className: `min-h-screen flex items-center justify-center p-4 bg-gradient-to-b from-muted/40 via-background to-background ${c || ""}`,
|
|
1697
|
+
style: k,
|
|
1698
|
+
children: /* @__PURE__ */ J("div", {
|
|
1699
|
+
className: "max-w-md w-full bg-card border rounded-xl shadow-sm p-8 text-center space-y-4",
|
|
1604
1700
|
children: [
|
|
1605
|
-
/* @__PURE__ */
|
|
1606
|
-
className: "text-
|
|
1607
|
-
children:
|
|
1701
|
+
/* @__PURE__ */ q("div", {
|
|
1702
|
+
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",
|
|
1703
|
+
children: /* @__PURE__ */ q(V, {
|
|
1704
|
+
className: "h-8 w-8",
|
|
1705
|
+
"aria-hidden": "true"
|
|
1706
|
+
})
|
|
1608
1707
|
}),
|
|
1609
|
-
/* @__PURE__ */
|
|
1708
|
+
/* @__PURE__ */ q("h2", {
|
|
1610
1709
|
className: "text-xl font-semibold text-foreground",
|
|
1611
|
-
children: t?.title || "Thank You!"
|
|
1710
|
+
children: t?.title || n.thankYouTitle || "Thank You!"
|
|
1612
1711
|
}),
|
|
1613
|
-
/* @__PURE__ */
|
|
1614
|
-
className: "text-muted-foreground",
|
|
1615
|
-
children: t?.message || "Your submission has been received successfully."
|
|
1712
|
+
/* @__PURE__ */ q("p", {
|
|
1713
|
+
className: "text-sm text-muted-foreground",
|
|
1714
|
+
children: t?.message || n.thankYouMessage || "Your submission has been received successfully."
|
|
1616
1715
|
}),
|
|
1617
|
-
e.allowMultiple && /* @__PURE__ */
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1716
|
+
e.allowMultiple && /* @__PURE__ */ q(m, {
|
|
1717
|
+
variant: "outline",
|
|
1718
|
+
size: "sm",
|
|
1719
|
+
onClick: O,
|
|
1720
|
+
className: "mt-2",
|
|
1721
|
+
children: n.submitAnother ?? "Submit Another Response"
|
|
1621
1722
|
}),
|
|
1622
|
-
t?.redirectUrl && /* @__PURE__ */
|
|
1723
|
+
t?.redirectUrl && /* @__PURE__ */ q("p", {
|
|
1623
1724
|
className: "text-xs text-muted-foreground",
|
|
1624
|
-
children:
|
|
1625
|
-
"Redirecting in ",
|
|
1626
|
-
Math.ceil((t.redirectDelay ?? 3e3) / 1e3),
|
|
1627
|
-
" seconds..."
|
|
1628
|
-
]
|
|
1725
|
+
children: i
|
|
1629
1726
|
})
|
|
1630
1727
|
]
|
|
1631
1728
|
})
|
|
1632
1729
|
});
|
|
1633
1730
|
}
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1731
|
+
let A = e.texts ?? {}, j = !!e.consent?.required, M = `${e.formId}-consent`;
|
|
1732
|
+
return /* @__PURE__ */ q("div", {
|
|
1733
|
+
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 || ""}`,
|
|
1734
|
+
style: k,
|
|
1735
|
+
children: /* @__PURE__ */ J("div", {
|
|
1736
|
+
className: "max-w-2xl w-full bg-card border rounded-xl shadow-sm overflow-hidden",
|
|
1639
1737
|
children: [
|
|
1640
|
-
/* @__PURE__ */
|
|
1641
|
-
className: "
|
|
1738
|
+
e.branding?.coverImage && /* @__PURE__ */ q("div", {
|
|
1739
|
+
className: "h-28 sm:h-32 w-full bg-cover bg-center",
|
|
1740
|
+
style: { backgroundImage: `url(${JSON.stringify(e.branding.coverImage)})` },
|
|
1741
|
+
role: "presentation"
|
|
1742
|
+
}),
|
|
1743
|
+
/* @__PURE__ */ J("div", {
|
|
1744
|
+
className: "px-6 sm:px-8 pt-7 pb-5 border-b bg-muted/20",
|
|
1642
1745
|
style: e.branding?.primaryColor ? { borderBottomColor: e.branding.primaryColor } : void 0,
|
|
1643
1746
|
children: [
|
|
1644
|
-
e.branding?.logo && /* @__PURE__ */
|
|
1747
|
+
e.branding?.logo && /* @__PURE__ */ q("img", {
|
|
1645
1748
|
src: e.branding.logo,
|
|
1646
|
-
alt: "
|
|
1749
|
+
alt: "",
|
|
1647
1750
|
className: "h-8 mb-4"
|
|
1648
1751
|
}),
|
|
1649
|
-
e.title && /* @__PURE__ */
|
|
1650
|
-
className: "text-
|
|
1752
|
+
e.title && /* @__PURE__ */ q("h1", {
|
|
1753
|
+
className: "text-2xl font-semibold tracking-tight text-foreground",
|
|
1651
1754
|
children: e.title
|
|
1652
1755
|
}),
|
|
1653
|
-
e.description && /* @__PURE__ */
|
|
1654
|
-
className: "text-sm text-muted-foreground mt-
|
|
1756
|
+
e.description && /* @__PURE__ */ q("p", {
|
|
1757
|
+
className: "text-sm text-muted-foreground mt-2 leading-relaxed",
|
|
1655
1758
|
children: e.description
|
|
1759
|
+
}),
|
|
1760
|
+
/* @__PURE__ */ q("p", {
|
|
1761
|
+
className: "text-[11px] text-muted-foreground/70 mt-3",
|
|
1762
|
+
"aria-hidden": "true",
|
|
1763
|
+
children: A.requiredHint ?? "* Required field"
|
|
1656
1764
|
})
|
|
1657
1765
|
]
|
|
1658
1766
|
}),
|
|
1659
|
-
/* @__PURE__ */
|
|
1660
|
-
className: "
|
|
1661
|
-
children: [
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1767
|
+
/* @__PURE__ */ J("div", {
|
|
1768
|
+
className: "relative px-6 sm:px-8 py-6",
|
|
1769
|
+
children: [
|
|
1770
|
+
p && /* @__PURE__ */ q("div", {
|
|
1771
|
+
role: "alert",
|
|
1772
|
+
"aria-live": "assertive",
|
|
1773
|
+
className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
|
|
1774
|
+
children: p
|
|
1775
|
+
}),
|
|
1776
|
+
/* @__PURE__ */ q(Ce, {
|
|
1777
|
+
schema: {
|
|
1778
|
+
type: "object-form",
|
|
1779
|
+
objectName: e.objectName,
|
|
1780
|
+
mode: "create",
|
|
1781
|
+
fields: e.fields,
|
|
1782
|
+
customFields: w,
|
|
1783
|
+
initialData: E,
|
|
1784
|
+
onSuccess: D,
|
|
1785
|
+
submitText: d ? A.submitting ?? "Submitting..." : A.submit ?? "Submit"
|
|
1786
|
+
},
|
|
1787
|
+
dataSource: T
|
|
1788
|
+
}),
|
|
1789
|
+
S && /* @__PURE__ */ J("div", {
|
|
1790
|
+
"aria-hidden": "true",
|
|
1791
|
+
className: "absolute left-[-10000px] top-auto h-px w-px overflow-hidden",
|
|
1792
|
+
children: [/* @__PURE__ */ q("label", {
|
|
1793
|
+
htmlFor: `${e.formId}-${S}`,
|
|
1794
|
+
children: "Do not fill this field"
|
|
1795
|
+
}), /* @__PURE__ */ q("input", {
|
|
1796
|
+
ref: b,
|
|
1797
|
+
id: `${e.formId}-${S}`,
|
|
1798
|
+
type: "text",
|
|
1799
|
+
name: S,
|
|
1800
|
+
tabIndex: -1,
|
|
1801
|
+
autoComplete: "off",
|
|
1802
|
+
defaultValue: ""
|
|
1803
|
+
})]
|
|
1804
|
+
}),
|
|
1805
|
+
e.consent && /* @__PURE__ */ J("div", {
|
|
1806
|
+
className: "mt-4",
|
|
1807
|
+
children: [/* @__PURE__ */ J("label", {
|
|
1808
|
+
className: "flex items-start gap-2 text-sm text-foreground cursor-pointer select-none",
|
|
1809
|
+
children: [/* @__PURE__ */ q("input", {
|
|
1810
|
+
type: "checkbox",
|
|
1811
|
+
id: M,
|
|
1812
|
+
checked: g,
|
|
1813
|
+
onChange: (e) => {
|
|
1814
|
+
_(e.target.checked), e.target.checked && y(null);
|
|
1815
|
+
},
|
|
1816
|
+
"aria-required": j || void 0,
|
|
1817
|
+
"aria-invalid": v ? "true" : void 0,
|
|
1818
|
+
"aria-describedby": v ? `${M}-error` : void 0,
|
|
1819
|
+
className: "mt-0.5 h-4 w-4 rounded border-input accent-primary"
|
|
1820
|
+
}), /* @__PURE__ */ J("span", {
|
|
1821
|
+
className: "leading-relaxed",
|
|
1822
|
+
children: [
|
|
1823
|
+
e.consent.label ?? A.consentLabelDefault ?? "I agree to the privacy policy.",
|
|
1824
|
+
j && /* @__PURE__ */ q("span", {
|
|
1825
|
+
"aria-hidden": "true",
|
|
1826
|
+
className: "text-destructive ml-0.5",
|
|
1827
|
+
children: "*"
|
|
1828
|
+
}),
|
|
1829
|
+
e.consent.privacyUrl && /* @__PURE__ */ J(K, { children: [" ", /* @__PURE__ */ q("a", {
|
|
1830
|
+
href: e.consent.privacyUrl,
|
|
1831
|
+
target: "_blank",
|
|
1832
|
+
rel: "noopener noreferrer",
|
|
1833
|
+
className: "underline text-primary hover:opacity-80",
|
|
1834
|
+
children: A.consentLink ?? "Privacy policy"
|
|
1835
|
+
})] })
|
|
1836
|
+
]
|
|
1837
|
+
})]
|
|
1838
|
+
}), v && /* @__PURE__ */ q("p", {
|
|
1839
|
+
id: `${M}-error`,
|
|
1840
|
+
role: "alert",
|
|
1841
|
+
className: "mt-1.5 text-xs text-destructive",
|
|
1842
|
+
children: v
|
|
1843
|
+
})]
|
|
1844
|
+
}),
|
|
1845
|
+
d && /* @__PURE__ */ J("div", {
|
|
1846
|
+
className: "mt-3 flex items-center gap-2 text-xs text-muted-foreground",
|
|
1847
|
+
children: [/* @__PURE__ */ q(ne, {
|
|
1848
|
+
className: "h-3.5 w-3.5 animate-spin",
|
|
1849
|
+
"aria-hidden": "true"
|
|
1850
|
+
}), /* @__PURE__ */ q("span", { children: A.submitting ?? "Submitting…" })]
|
|
1851
|
+
})
|
|
1852
|
+
]
|
|
1677
1853
|
}),
|
|
1678
|
-
/* @__PURE__ */
|
|
1679
|
-
className: "px-6 py-
|
|
1680
|
-
children: /* @__PURE__ */
|
|
1681
|
-
className: "text-xs text-muted-foreground",
|
|
1682
|
-
children:
|
|
1683
|
-
|
|
1854
|
+
/* @__PURE__ */ J("div", {
|
|
1855
|
+
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",
|
|
1856
|
+
children: [/* @__PURE__ */ J("p", {
|
|
1857
|
+
className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground",
|
|
1858
|
+
children: [/* @__PURE__ */ q(W, {
|
|
1859
|
+
className: "h-3 w-3",
|
|
1860
|
+
"aria-hidden": "true"
|
|
1861
|
+
}), /* @__PURE__ */ q("span", { children: A.secureNotice ?? "Your information is transmitted securely and only used to respond to your request." })]
|
|
1862
|
+
}), /* @__PURE__ */ J("div", {
|
|
1863
|
+
className: "flex items-center gap-3 text-xs text-muted-foreground/80",
|
|
1864
|
+
children: [e.privacyPolicyUrl && /* @__PURE__ */ J("a", {
|
|
1865
|
+
href: e.privacyPolicyUrl,
|
|
1866
|
+
target: "_blank",
|
|
1867
|
+
rel: "noopener noreferrer",
|
|
1868
|
+
className: "inline-flex items-center gap-1 underline hover:text-foreground",
|
|
1869
|
+
children: [/* @__PURE__ */ q(G, {
|
|
1870
|
+
className: "h-3 w-3",
|
|
1871
|
+
"aria-hidden": "true"
|
|
1872
|
+
}), A.consentLink ?? "Privacy policy"]
|
|
1873
|
+
}), /* @__PURE__ */ q("span", { children: A.poweredBy ?? "Powered by ObjectStack" })]
|
|
1874
|
+
})]
|
|
1684
1875
|
})
|
|
1685
1876
|
]
|
|
1686
1877
|
})
|
|
@@ -1688,96 +1879,96 @@ var me = {
|
|
|
1688
1879
|
};
|
|
1689
1880
|
//#endregion
|
|
1690
1881
|
//#region src/FormAnalytics.tsx
|
|
1691
|
-
function
|
|
1882
|
+
function je(e) {
|
|
1692
1883
|
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`;
|
|
1693
1884
|
}
|
|
1694
|
-
var
|
|
1885
|
+
var Me = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
1695
1886
|
let a = i(() => {
|
|
1696
1887
|
if (!n.abandonedSubmissions) return 100;
|
|
1697
1888
|
let e = n.totalSubmissions + n.abandonedSubmissions;
|
|
1698
1889
|
return e === 0 ? 0 : Math.round(n.totalSubmissions / e * 100);
|
|
1699
1890
|
}, [n.totalSubmissions, n.abandonedSubmissions]), o = i(() => n.dailySubmissions?.length ? Math.max(...n.dailySubmissions.map((e) => e.count), 1) : 1, [n.dailySubmissions]);
|
|
1700
|
-
return /* @__PURE__ */
|
|
1891
|
+
return /* @__PURE__ */ J("div", {
|
|
1701
1892
|
className: `space-y-4 ${r || ""}`,
|
|
1702
1893
|
children: [
|
|
1703
|
-
/* @__PURE__ */
|
|
1894
|
+
/* @__PURE__ */ J("div", { children: [/* @__PURE__ */ q("h2", {
|
|
1704
1895
|
className: "text-lg font-semibold text-foreground",
|
|
1705
1896
|
children: t || "Form Analytics"
|
|
1706
|
-
}), /* @__PURE__ */
|
|
1897
|
+
}), /* @__PURE__ */ J("p", {
|
|
1707
1898
|
className: "text-sm text-muted-foreground",
|
|
1708
1899
|
children: ["Form ID: ", e]
|
|
1709
1900
|
})] }),
|
|
1710
|
-
/* @__PURE__ */
|
|
1901
|
+
/* @__PURE__ */ J("div", {
|
|
1711
1902
|
className: "grid grid-cols-1 sm:grid-cols-3 gap-4",
|
|
1712
1903
|
children: [
|
|
1713
|
-
/* @__PURE__ */
|
|
1904
|
+
/* @__PURE__ */ q(h, { children: /* @__PURE__ */ J(v, {
|
|
1714
1905
|
className: "pb-2",
|
|
1715
|
-
children: [/* @__PURE__ */
|
|
1906
|
+
children: [/* @__PURE__ */ q(_, { children: "Total Submissions" }), /* @__PURE__ */ q(y, {
|
|
1716
1907
|
className: "text-2xl",
|
|
1717
1908
|
children: n.totalSubmissions.toLocaleString()
|
|
1718
1909
|
})]
|
|
1719
1910
|
}) }),
|
|
1720
|
-
/* @__PURE__ */
|
|
1911
|
+
/* @__PURE__ */ J(h, { children: [/* @__PURE__ */ J(v, {
|
|
1721
1912
|
className: "pb-2",
|
|
1722
|
-
children: [/* @__PURE__ */
|
|
1913
|
+
children: [/* @__PURE__ */ q(_, { children: "Fill Rate" }), /* @__PURE__ */ J(y, {
|
|
1723
1914
|
className: "text-2xl",
|
|
1724
1915
|
children: [a, "%"]
|
|
1725
1916
|
})]
|
|
1726
|
-
}), /* @__PURE__ */
|
|
1917
|
+
}), /* @__PURE__ */ q(g, { children: /* @__PURE__ */ q("div", {
|
|
1727
1918
|
className: "w-full bg-muted rounded-full h-2",
|
|
1728
|
-
children: /* @__PURE__ */
|
|
1919
|
+
children: /* @__PURE__ */ q("div", {
|
|
1729
1920
|
className: "bg-primary rounded-full h-2 transition-all",
|
|
1730
1921
|
style: { width: `${a}%` }
|
|
1731
1922
|
})
|
|
1732
1923
|
}) })] }),
|
|
1733
|
-
/* @__PURE__ */
|
|
1924
|
+
/* @__PURE__ */ q(h, { children: /* @__PURE__ */ J(v, {
|
|
1734
1925
|
className: "pb-2",
|
|
1735
|
-
children: [/* @__PURE__ */
|
|
1926
|
+
children: [/* @__PURE__ */ q(_, { children: "Avg. Completion Time" }), /* @__PURE__ */ q(y, {
|
|
1736
1927
|
className: "text-2xl",
|
|
1737
|
-
children: n.avgCompletionTime ?
|
|
1928
|
+
children: n.avgCompletionTime ? je(n.avgCompletionTime) : "—"
|
|
1738
1929
|
})]
|
|
1739
1930
|
}) })
|
|
1740
1931
|
]
|
|
1741
1932
|
}),
|
|
1742
|
-
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */
|
|
1933
|
+
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ J(h, { children: [/* @__PURE__ */ q(v, { children: /* @__PURE__ */ q(y, {
|
|
1743
1934
|
className: "text-sm font-medium",
|
|
1744
1935
|
children: "Daily Submissions"
|
|
1745
|
-
}) }), /* @__PURE__ */
|
|
1936
|
+
}) }), /* @__PURE__ */ q(g, { children: /* @__PURE__ */ q("div", {
|
|
1746
1937
|
className: "flex items-end gap-1 h-32",
|
|
1747
|
-
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */
|
|
1938
|
+
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ J("div", {
|
|
1748
1939
|
className: "flex-1 flex flex-col items-center gap-1",
|
|
1749
|
-
children: [/* @__PURE__ */
|
|
1940
|
+
children: [/* @__PURE__ */ q("div", {
|
|
1750
1941
|
className: "w-full bg-primary/80 rounded-t transition-all hover:bg-primary",
|
|
1751
1942
|
style: {
|
|
1752
1943
|
height: `${e.count / o * 100}%`,
|
|
1753
1944
|
minHeight: e.count > 0 ? "4px" : "0"
|
|
1754
1945
|
},
|
|
1755
1946
|
title: `${e.date}: ${e.count} submissions`
|
|
1756
|
-
}), /* @__PURE__ */
|
|
1947
|
+
}), /* @__PURE__ */ q("span", {
|
|
1757
1948
|
className: "text-[10px] text-muted-foreground truncate w-full text-center",
|
|
1758
1949
|
children: e.date.slice(-5)
|
|
1759
1950
|
})]
|
|
1760
1951
|
}, t))
|
|
1761
1952
|
}) })] }),
|
|
1762
|
-
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */
|
|
1953
|
+
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ J(h, { children: [/* @__PURE__ */ J(v, { children: [/* @__PURE__ */ q(y, {
|
|
1763
1954
|
className: "text-sm font-medium",
|
|
1764
1955
|
children: "Field Completion Rates"
|
|
1765
|
-
}), /* @__PURE__ */
|
|
1956
|
+
}), /* @__PURE__ */ q(_, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ q(g, { children: /* @__PURE__ */ q("div", {
|
|
1766
1957
|
className: "space-y-3",
|
|
1767
|
-
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */
|
|
1958
|
+
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ J("div", {
|
|
1768
1959
|
className: "space-y-1",
|
|
1769
|
-
children: [/* @__PURE__ */
|
|
1960
|
+
children: [/* @__PURE__ */ J("div", {
|
|
1770
1961
|
className: "flex justify-between text-sm",
|
|
1771
|
-
children: [/* @__PURE__ */
|
|
1962
|
+
children: [/* @__PURE__ */ q("span", {
|
|
1772
1963
|
className: "text-foreground",
|
|
1773
1964
|
children: e.label
|
|
1774
|
-
}), /* @__PURE__ */
|
|
1965
|
+
}), /* @__PURE__ */ J("span", {
|
|
1775
1966
|
className: "text-muted-foreground",
|
|
1776
1967
|
children: [e.completionRate, "%"]
|
|
1777
1968
|
})]
|
|
1778
|
-
}), /* @__PURE__ */
|
|
1969
|
+
}), /* @__PURE__ */ q("div", {
|
|
1779
1970
|
className: "w-full bg-muted rounded-full h-1.5",
|
|
1780
|
-
children: /* @__PURE__ */
|
|
1971
|
+
children: /* @__PURE__ */ q("div", {
|
|
1781
1972
|
className: `rounded-full h-1.5 transition-all ${e.completionRate >= 80 ? "bg-green-500" : e.completionRate >= 50 ? "bg-yellow-500" : "bg-destructive"}`,
|
|
1782
1973
|
style: { width: `${e.completionRate}%` }
|
|
1783
1974
|
})
|
|
@@ -1786,8 +1977,8 @@ var Ce = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
1786
1977
|
}) })] })
|
|
1787
1978
|
]
|
|
1788
1979
|
});
|
|
1789
|
-
},
|
|
1790
|
-
|
|
1980
|
+
}, Ne = ({ schema: e }) => /* @__PURE__ */ q(Ce, { schema: e });
|
|
1981
|
+
s.register("object-form", Ne, {
|
|
1791
1982
|
namespace: "plugin-form",
|
|
1792
1983
|
label: "Object Form",
|
|
1793
1984
|
category: "plugin",
|
|
@@ -1928,7 +2119,7 @@ o.register("object-form", we, {
|
|
|
1928
2119
|
]
|
|
1929
2120
|
}
|
|
1930
2121
|
]
|
|
1931
|
-
}),
|
|
2122
|
+
}), s.register("form", Ne, {
|
|
1932
2123
|
namespace: "view",
|
|
1933
2124
|
skipFallback: !0,
|
|
1934
2125
|
label: "Data Form View",
|
|
@@ -1956,7 +2147,7 @@ o.register("object-form", we, {
|
|
|
1956
2147
|
]
|
|
1957
2148
|
}
|
|
1958
2149
|
]
|
|
1959
|
-
}),
|
|
2150
|
+
}), s.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */ q(Ae, { config: e }), {
|
|
1960
2151
|
namespace: "plugin-form",
|
|
1961
2152
|
label: "Embeddable Form",
|
|
1962
2153
|
category: "plugin",
|
|
@@ -1994,7 +2185,7 @@ o.register("object-form", we, {
|
|
|
1994
2185
|
label: "Allow Multiple Submissions"
|
|
1995
2186
|
}
|
|
1996
2187
|
]
|
|
1997
|
-
}),
|
|
2188
|
+
}), s.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ q(Me, {
|
|
1998
2189
|
formId: e.formId,
|
|
1999
2190
|
formTitle: e.formTitle,
|
|
2000
2191
|
metrics: e.metrics || { totalSubmissions: 0 }
|
|
@@ -2022,4 +2213,4 @@ o.register("object-form", we, {
|
|
|
2022
2213
|
]
|
|
2023
2214
|
});
|
|
2024
2215
|
//#endregion
|
|
2025
|
-
export {
|
|
2216
|
+
export { ye as DrawerForm, Ae as EmbeddableForm, Me as FormAnalytics, Y as FormSection, Se as ModalForm, Ce as ObjectForm, Q as SplitForm, X as TabbedForm, Z as WizardForm, le as applyAutoColSpan, $ as applyAutoLayout, pe as filterAutoGeneratedFields, fe as filterCreateModeFields, de as filterSystemFields, ce as inferColumns, me as inferModalSize, se as isAutoGeneratedFieldType, oe as isWideFieldType };
|