@object-ui/plugin-form 4.3.0 → 4.5.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 +46 -0
- package/dist/index.js +623 -521
- package/dist/index.umd.cjs +1 -1
- package/dist/packages/plugin-form/src/autoLayout.d.ts +14 -0
- package/dist/packages/plugin-form/src/index.d.ts +1 -1
- package/package.json +8 -7
package/dist/index.js
CHANGED
|
@@ -3,34 +3,35 @@ import { ComponentRegistry as o } from "@object-ui/core";
|
|
|
3
3
|
import { SchemaRenderer as s, useSafeFieldLabel as c } from "@object-ui/react";
|
|
4
4
|
import { buildValidationRules as l, evaluateCondition as u, formatFileSize as d, mapFieldTypeToFormType as f } from "@object-ui/fields";
|
|
5
5
|
import { Button as p, Card as m, CardContent as h, CardDescription as g, CardHeader as _, CardTitle as v, Dialog as y, DialogDescription as b, DialogHeader as x, DialogTitle as S, MobileDialogContent as C, ResizableHandle as w, ResizablePanel as T, ResizablePanelGroup as E, Sheet as D, SheetContent as O, SheetDescription as k, SheetHeader as A, SheetTitle as j, Skeleton as M, Tabs as N, TabsContent as P, TabsList as F, TabsTrigger as I, cn as L, useIsMobile as R } from "@object-ui/components";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { usePermissions as z } from "@object-ui/permissions";
|
|
7
|
+
import { Check as B, ChevronDown as V, ChevronLeft as H, ChevronRight as U, Loader2 as ee } from "lucide-react";
|
|
8
|
+
import { Fragment as te, jsx as W, jsxs as G } from "react/jsx-runtime";
|
|
8
9
|
//#region src/FormSection.tsx
|
|
9
|
-
var
|
|
10
|
+
var K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: o, className: s, gridClassName: c }) => {
|
|
10
11
|
let [l, u] = a(r);
|
|
11
|
-
return /* @__PURE__ */
|
|
12
|
+
return /* @__PURE__ */ G("div", {
|
|
12
13
|
className: L("form-section", s),
|
|
13
|
-
children: [(e || t) && /* @__PURE__ */
|
|
14
|
+
children: [(e || t) && /* @__PURE__ */ G("div", {
|
|
14
15
|
className: L("flex items-start gap-2 mb-4", n && "cursor-pointer select-none"),
|
|
15
16
|
onClick: () => {
|
|
16
17
|
n && u(!l);
|
|
17
18
|
},
|
|
18
19
|
role: n ? "button" : void 0,
|
|
19
20
|
"aria-expanded": n ? !l : void 0,
|
|
20
|
-
children: [n && /* @__PURE__ */
|
|
21
|
+
children: [n && /* @__PURE__ */ W("span", {
|
|
21
22
|
className: "mt-0.5 text-muted-foreground",
|
|
22
|
-
children:
|
|
23
|
-
}), /* @__PURE__ */
|
|
23
|
+
children: W(l ? U : V, { className: "h-4 w-4" })
|
|
24
|
+
}), /* @__PURE__ */ G("div", {
|
|
24
25
|
className: "flex-1",
|
|
25
|
-
children: [e && /* @__PURE__ */
|
|
26
|
+
children: [e && /* @__PURE__ */ W("h3", {
|
|
26
27
|
className: "text-base font-semibold text-foreground",
|
|
27
28
|
children: e
|
|
28
|
-
}), t && /* @__PURE__ */
|
|
29
|
+
}), t && /* @__PURE__ */ W("p", {
|
|
29
30
|
className: "text-sm text-muted-foreground mt-0.5",
|
|
30
31
|
children: t
|
|
31
32
|
})]
|
|
32
33
|
})]
|
|
33
|
-
}), !l && /* @__PURE__ */
|
|
34
|
+
}), !l && /* @__PURE__ */ W("div", {
|
|
34
35
|
className: L("grid gap-4", c || {
|
|
35
36
|
1: "grid-cols-1",
|
|
36
37
|
2: "grid-cols-1 md:grid-cols-2",
|
|
@@ -40,7 +41,7 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
40
41
|
children: o
|
|
41
42
|
})]
|
|
42
43
|
});
|
|
43
|
-
},
|
|
44
|
+
}, q = ({ schema: n, dataSource: r, className: i }) => {
|
|
44
45
|
let { fieldLabel: o } = c(), [u, d] = a(null), [p, m] = a({}), [h, g] = a(!0), [_, v] = a(null), [y, b] = a(n.defaultTab || n.sections[0]?.name || n.sections[0]?.label || "tab-0");
|
|
45
46
|
e.useEffect(() => {
|
|
46
47
|
(async () => {
|
|
@@ -119,19 +120,19 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
119
120
|
}, [n, r]), C = t(() => {
|
|
120
121
|
n.onCancel && n.onCancel();
|
|
121
122
|
}, [n]), w = (e, t) => e.name || e.label || `tab-${t}`;
|
|
122
|
-
if (_) return /* @__PURE__ */
|
|
123
|
+
if (_) return /* @__PURE__ */ G("div", {
|
|
123
124
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
124
|
-
children: [/* @__PURE__ */
|
|
125
|
+
children: [/* @__PURE__ */ W("h3", {
|
|
125
126
|
className: "text-red-800 font-semibold",
|
|
126
127
|
children: "Error loading form"
|
|
127
|
-
}), /* @__PURE__ */
|
|
128
|
+
}), /* @__PURE__ */ W("p", {
|
|
128
129
|
className: "text-red-600 text-sm mt-1",
|
|
129
130
|
children: _.message
|
|
130
131
|
})]
|
|
131
132
|
});
|
|
132
|
-
if (h) return /* @__PURE__ */
|
|
133
|
+
if (h) return /* @__PURE__ */ G("div", {
|
|
133
134
|
className: "p-8 text-center",
|
|
134
|
-
children: [/* @__PURE__ */
|
|
135
|
+
children: [/* @__PURE__ */ W("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ W("p", {
|
|
135
136
|
className: "mt-2 text-sm text-gray-600",
|
|
136
137
|
children: "Loading form..."
|
|
137
138
|
})]
|
|
@@ -148,29 +149,29 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
148
149
|
onSubmit: S,
|
|
149
150
|
onCancel: C
|
|
150
151
|
}, E = n.tabPosition === "left" || n.tabPosition === "right";
|
|
151
|
-
return /* @__PURE__ */
|
|
152
|
+
return /* @__PURE__ */ W("div", {
|
|
152
153
|
className: L("w-full", i, n.className),
|
|
153
|
-
children: /* @__PURE__ */
|
|
154
|
+
children: /* @__PURE__ */ G(N, {
|
|
154
155
|
value: y,
|
|
155
156
|
onValueChange: b,
|
|
156
157
|
orientation: E ? "vertical" : "horizontal",
|
|
157
158
|
className: L(E && "flex gap-4"),
|
|
158
|
-
children: [/* @__PURE__ */
|
|
159
|
+
children: [/* @__PURE__ */ W(F, {
|
|
159
160
|
className: L(E ? "flex-col h-auto" : "", n.tabPosition === "bottom" && "order-last", n.tabPosition === "right" && "order-last"),
|
|
160
|
-
children: n.sections.map((e, t) => /* @__PURE__ */
|
|
161
|
+
children: n.sections.map((e, t) => /* @__PURE__ */ W(I, {
|
|
161
162
|
value: w(e, t),
|
|
162
163
|
className: E ? "w-full justify-start" : "",
|
|
163
164
|
children: e.label || `Tab ${t + 1}`
|
|
164
165
|
}, w(e, t)))
|
|
165
|
-
}), /* @__PURE__ */
|
|
166
|
+
}), /* @__PURE__ */ W("div", {
|
|
166
167
|
className: "flex-1",
|
|
167
|
-
children: n.sections.map((e, t) => /* @__PURE__ */
|
|
168
|
+
children: n.sections.map((e, t) => /* @__PURE__ */ W(P, {
|
|
168
169
|
value: w(e, t),
|
|
169
170
|
className: "mt-0",
|
|
170
|
-
children: /* @__PURE__ */
|
|
171
|
+
children: /* @__PURE__ */ W(K, {
|
|
171
172
|
description: e.description,
|
|
172
173
|
columns: e.columns || 1,
|
|
173
|
-
children: /* @__PURE__ */
|
|
174
|
+
children: /* @__PURE__ */ W(s, { schema: {
|
|
174
175
|
...T,
|
|
175
176
|
fields: x(e),
|
|
176
177
|
showSubmit: n.showSubmit !== !1 && n.mode !== "view",
|
|
@@ -181,36 +182,36 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
181
182
|
})]
|
|
182
183
|
})
|
|
183
184
|
});
|
|
184
|
-
},
|
|
185
|
-
let { fieldLabel:
|
|
185
|
+
}, J = ({ schema: n, dataSource: r, className: o }) => {
|
|
186
|
+
let { fieldLabel: d } = c(), [m, h] = a(null), [g, _] = a({}), [v, y] = a(!0), [b, x] = a(null), [S, C] = a(0), [w, T] = a(/* @__PURE__ */ new Set()), [E, D] = a(!1), O = n.sections.length, k = S === 0, A = S === O - 1;
|
|
186
187
|
e.useEffect(() => {
|
|
187
188
|
(async () => {
|
|
188
189
|
if (!r) {
|
|
189
|
-
|
|
190
|
+
y(!1);
|
|
190
191
|
return;
|
|
191
192
|
}
|
|
192
193
|
try {
|
|
193
|
-
|
|
194
|
+
h(await r.getObjectSchema(n.objectName));
|
|
194
195
|
} catch (e) {
|
|
195
|
-
|
|
196
|
+
x(e);
|
|
196
197
|
}
|
|
197
198
|
})();
|
|
198
199
|
}, [n.objectName, r]), e.useEffect(() => {
|
|
199
|
-
(
|
|
200
|
+
(m || !r) && (async () => {
|
|
200
201
|
if (n.mode === "create" || !n.recordId || !r) {
|
|
201
|
-
|
|
202
|
+
_(n.initialData || n.initialValues || {}), y(!1);
|
|
202
203
|
return;
|
|
203
204
|
}
|
|
204
205
|
try {
|
|
205
|
-
|
|
206
|
+
_(await r.findOne(n.objectName, n.recordId) || {});
|
|
206
207
|
} catch (e) {
|
|
207
|
-
|
|
208
|
+
x(e);
|
|
208
209
|
} finally {
|
|
209
|
-
|
|
210
|
+
y(!1);
|
|
210
211
|
}
|
|
211
212
|
})();
|
|
212
213
|
}, [
|
|
213
|
-
|
|
214
|
+
m,
|
|
214
215
|
n.mode,
|
|
215
216
|
n.recordId,
|
|
216
217
|
n.initialData,
|
|
@@ -218,26 +219,29 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
218
219
|
r,
|
|
219
220
|
n.objectName
|
|
220
221
|
]);
|
|
221
|
-
let
|
|
222
|
-
let t = []
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
222
|
+
let j = t((e) => {
|
|
223
|
+
let t = [], r = (e, t) => typeof t == "string" && t.trim() ? {
|
|
224
|
+
...e,
|
|
225
|
+
visible: (e) => u(t, e)
|
|
226
|
+
} : e;
|
|
227
|
+
for (let i of e.fields) {
|
|
228
|
+
let e = typeof i == "string" ? i : i.name;
|
|
229
|
+
if (typeof i == "object") t.push(r(i, i.visibleOn));
|
|
230
|
+
else if (m?.fields?.[e]) {
|
|
231
|
+
let i = m.fields[e];
|
|
232
|
+
t.push(r({
|
|
229
233
|
name: e,
|
|
230
|
-
label:
|
|
231
|
-
type: f(
|
|
232
|
-
required:
|
|
233
|
-
disabled: n.readOnly || n.mode === "view" ||
|
|
234
|
-
placeholder:
|
|
235
|
-
description:
|
|
236
|
-
validation: l(
|
|
237
|
-
field:
|
|
238
|
-
options:
|
|
239
|
-
multiple:
|
|
240
|
-
});
|
|
234
|
+
label: d(n.objectName, e, i.label || e),
|
|
235
|
+
type: f(i.type),
|
|
236
|
+
required: i.required || !1,
|
|
237
|
+
disabled: n.readOnly || n.mode === "view" || i.readonly,
|
|
238
|
+
placeholder: i.placeholder,
|
|
239
|
+
description: i.help || i.description,
|
|
240
|
+
validation: l(i),
|
|
241
|
+
field: i,
|
|
242
|
+
options: i.options,
|
|
243
|
+
multiple: i.multiple
|
|
244
|
+
}, i.visible_on ?? i.visibleOn));
|
|
241
245
|
} else t.push({
|
|
242
246
|
name: e,
|
|
243
247
|
label: e,
|
|
@@ -246,21 +250,22 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
246
250
|
}
|
|
247
251
|
return t;
|
|
248
252
|
}, [
|
|
249
|
-
|
|
253
|
+
m,
|
|
250
254
|
n.readOnly,
|
|
251
|
-
n.mode
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
+
n.mode,
|
|
256
|
+
n.objectName
|
|
257
|
+
]), M = i(() => S >= 0 && S < O ? j(n.sections[S]) : [], [
|
|
258
|
+
S,
|
|
259
|
+
O,
|
|
255
260
|
n.sections,
|
|
256
|
-
|
|
257
|
-
]),
|
|
261
|
+
j
|
|
262
|
+
]), N = t(async (e) => {
|
|
258
263
|
let t = {
|
|
259
|
-
...
|
|
264
|
+
...g,
|
|
260
265
|
...e
|
|
261
266
|
};
|
|
262
|
-
if (
|
|
263
|
-
|
|
267
|
+
if (_(t), T((e) => new Set(e).add(S)), A) {
|
|
268
|
+
D(!0);
|
|
264
269
|
try {
|
|
265
270
|
if (!r) return n.onSuccess && await n.onSuccess(t), t;
|
|
266
271
|
let e;
|
|
@@ -268,74 +273,74 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
268
273
|
} catch (e) {
|
|
269
274
|
throw n.onError && n.onError(e), e;
|
|
270
275
|
} finally {
|
|
271
|
-
|
|
276
|
+
D(!1);
|
|
272
277
|
}
|
|
273
|
-
} else
|
|
278
|
+
} else P(S + 1);
|
|
274
279
|
}, [
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
280
|
+
g,
|
|
281
|
+
S,
|
|
282
|
+
A,
|
|
278
283
|
n,
|
|
279
284
|
r
|
|
280
|
-
]),
|
|
281
|
-
e >= 0 && e <
|
|
282
|
-
}, [
|
|
283
|
-
|
|
284
|
-
}, [
|
|
285
|
+
]), P = t((e) => {
|
|
286
|
+
e >= 0 && e < O && (C(e), n.onStepChange && n.onStepChange(e));
|
|
287
|
+
}, [O, n]), F = t(() => {
|
|
288
|
+
P(S - 1);
|
|
289
|
+
}, [S, P]), I = t(() => {
|
|
285
290
|
n.onCancel && n.onCancel();
|
|
286
|
-
}, [n]),
|
|
287
|
-
(n.allowSkip ||
|
|
291
|
+
}, [n]), R = t((e) => {
|
|
292
|
+
(n.allowSkip || w.has(e) || e <= S) && P(e);
|
|
288
293
|
}, [
|
|
289
294
|
n.allowSkip,
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
295
|
+
w,
|
|
296
|
+
S,
|
|
297
|
+
P
|
|
293
298
|
]);
|
|
294
|
-
if (
|
|
299
|
+
if (b) return /* @__PURE__ */ G("div", {
|
|
295
300
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
296
|
-
children: [/* @__PURE__ */
|
|
301
|
+
children: [/* @__PURE__ */ W("h3", {
|
|
297
302
|
className: "text-red-800 font-semibold",
|
|
298
303
|
children: "Error loading form"
|
|
299
|
-
}), /* @__PURE__ */
|
|
304
|
+
}), /* @__PURE__ */ W("p", {
|
|
300
305
|
className: "text-red-600 text-sm mt-1",
|
|
301
|
-
children:
|
|
306
|
+
children: b.message
|
|
302
307
|
})]
|
|
303
308
|
});
|
|
304
|
-
if (
|
|
309
|
+
if (v) return /* @__PURE__ */ G("div", {
|
|
305
310
|
className: "p-8 text-center",
|
|
306
|
-
children: [/* @__PURE__ */
|
|
311
|
+
children: [/* @__PURE__ */ W("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ W("p", {
|
|
307
312
|
className: "mt-2 text-sm text-gray-600",
|
|
308
313
|
children: "Loading form..."
|
|
309
314
|
})]
|
|
310
315
|
});
|
|
311
|
-
let
|
|
312
|
-
return /* @__PURE__ */
|
|
316
|
+
let z = n.sections[S];
|
|
317
|
+
return /* @__PURE__ */ G("div", {
|
|
313
318
|
className: L("w-full", o, n.className),
|
|
314
319
|
children: [
|
|
315
|
-
n.showStepIndicator !== !1 && /* @__PURE__ */
|
|
320
|
+
n.showStepIndicator !== !1 && /* @__PURE__ */ W("nav", {
|
|
316
321
|
"aria-label": "Progress",
|
|
317
322
|
className: "mb-8",
|
|
318
|
-
children: /* @__PURE__ */
|
|
323
|
+
children: /* @__PURE__ */ W("ol", {
|
|
319
324
|
className: "flex items-center",
|
|
320
325
|
children: n.sections.map((e, t) => {
|
|
321
|
-
let r = t ===
|
|
322
|
-
return /* @__PURE__ */
|
|
323
|
-
className: L("relative flex-1", t !==
|
|
324
|
-
children: [t !==
|
|
326
|
+
let r = t === S, i = w.has(t), a = n.allowSkip || i || t <= S;
|
|
327
|
+
return /* @__PURE__ */ G("li", {
|
|
328
|
+
className: L("relative flex-1", t !== O - 1 && "pr-8 sm:pr-12"),
|
|
329
|
+
children: [t !== O - 1 && /* @__PURE__ */ W("div", {
|
|
325
330
|
className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
|
|
326
331
|
"aria-hidden": "true",
|
|
327
|
-
children: /* @__PURE__ */
|
|
328
|
-
}), /* @__PURE__ */
|
|
332
|
+
children: /* @__PURE__ */ W("div", { className: L("h-full", i ? "bg-primary" : "bg-muted") })
|
|
333
|
+
}), /* @__PURE__ */ G("button", {
|
|
329
334
|
type: "button",
|
|
330
335
|
className: L("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
|
|
331
|
-
onClick: () =>
|
|
336
|
+
onClick: () => R(t),
|
|
332
337
|
disabled: !a,
|
|
333
|
-
children: [/* @__PURE__ */
|
|
338
|
+
children: [/* @__PURE__ */ W("span", {
|
|
334
339
|
className: L("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"),
|
|
335
|
-
children: i ? /* @__PURE__ */
|
|
336
|
-
}), /* @__PURE__ */
|
|
340
|
+
children: i ? /* @__PURE__ */ W(B, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : t + 1
|
|
341
|
+
}), /* @__PURE__ */ W("span", {
|
|
337
342
|
className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block",
|
|
338
|
-
children: /* @__PURE__ */
|
|
343
|
+
children: /* @__PURE__ */ W("span", {
|
|
339
344
|
className: L(r ? "text-foreground" : "text-muted-foreground"),
|
|
340
345
|
children: e.label || `Step ${t + 1}`
|
|
341
346
|
})
|
|
@@ -345,96 +350,96 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
345
350
|
})
|
|
346
351
|
})
|
|
347
352
|
}),
|
|
348
|
-
/* @__PURE__ */
|
|
353
|
+
/* @__PURE__ */ W("div", {
|
|
349
354
|
className: "min-h-[200px]",
|
|
350
|
-
children:
|
|
351
|
-
label:
|
|
352
|
-
description:
|
|
353
|
-
columns:
|
|
354
|
-
children:
|
|
355
|
+
children: z && /* @__PURE__ */ W(K, {
|
|
356
|
+
label: z.label,
|
|
357
|
+
description: z.description,
|
|
358
|
+
columns: z.columns || 1,
|
|
359
|
+
children: M.length > 0 ? /* @__PURE__ */ W(s, { schema: {
|
|
355
360
|
type: "form",
|
|
356
|
-
fields:
|
|
361
|
+
fields: M,
|
|
357
362
|
layout: "vertical",
|
|
358
|
-
defaultValues:
|
|
363
|
+
defaultValues: g,
|
|
359
364
|
showSubmit: !1,
|
|
360
365
|
showCancel: !1,
|
|
361
|
-
onSubmit:
|
|
362
|
-
} }) : /* @__PURE__ */
|
|
366
|
+
onSubmit: N
|
|
367
|
+
} }) : /* @__PURE__ */ W("div", {
|
|
363
368
|
className: "text-center py-8 text-muted-foreground",
|
|
364
369
|
children: "No fields configured for this step"
|
|
365
370
|
})
|
|
366
371
|
})
|
|
367
372
|
}),
|
|
368
|
-
/* @__PURE__ */
|
|
373
|
+
/* @__PURE__ */ G("div", {
|
|
369
374
|
className: "flex items-center justify-between mt-6 pt-4 border-t",
|
|
370
|
-
children: [/* @__PURE__ */
|
|
375
|
+
children: [/* @__PURE__ */ W("div", { children: n.showCancel !== !1 && /* @__PURE__ */ W(p, {
|
|
371
376
|
variant: "ghost",
|
|
372
|
-
onClick:
|
|
377
|
+
onClick: I,
|
|
373
378
|
children: n.cancelText || "Cancel"
|
|
374
|
-
}) }), /* @__PURE__ */
|
|
379
|
+
}) }), /* @__PURE__ */ G("div", {
|
|
375
380
|
className: "flex items-center gap-2",
|
|
376
381
|
children: [
|
|
377
|
-
/* @__PURE__ */
|
|
382
|
+
/* @__PURE__ */ G("span", {
|
|
378
383
|
className: "text-sm text-muted-foreground mr-2",
|
|
379
384
|
children: [
|
|
380
385
|
"Step ",
|
|
381
|
-
|
|
386
|
+
S + 1,
|
|
382
387
|
" of ",
|
|
383
|
-
|
|
388
|
+
O
|
|
384
389
|
]
|
|
385
390
|
}),
|
|
386
|
-
!
|
|
391
|
+
!k && /* @__PURE__ */ G(p, {
|
|
387
392
|
variant: "outline",
|
|
388
|
-
onClick:
|
|
389
|
-
children: [/* @__PURE__ */
|
|
393
|
+
onClick: F,
|
|
394
|
+
children: [/* @__PURE__ */ W(H, { className: "h-4 w-4 mr-1" }), n.prevText || "Back"]
|
|
390
395
|
}),
|
|
391
|
-
|
|
392
|
-
onClick: () =>
|
|
393
|
-
disabled:
|
|
394
|
-
children:
|
|
395
|
-
}) : /* @__PURE__ */
|
|
396
|
-
onClick: () =>
|
|
397
|
-
children: [n.nextText || "Next", /* @__PURE__ */ U
|
|
396
|
+
A ? /* @__PURE__ */ W(p, {
|
|
397
|
+
onClick: () => N(g),
|
|
398
|
+
disabled: E || n.mode === "view",
|
|
399
|
+
children: E ? "Submitting..." : n.submitText || (n.mode === "create" ? "Create" : "Update")
|
|
400
|
+
}) : /* @__PURE__ */ G(p, {
|
|
401
|
+
onClick: () => N(g),
|
|
402
|
+
children: [n.nextText || "Next", /* @__PURE__ */ W(U, { className: "h-4 w-4 ml-1" })]
|
|
398
403
|
})
|
|
399
404
|
]
|
|
400
405
|
})]
|
|
401
406
|
})
|
|
402
407
|
]
|
|
403
408
|
});
|
|
404
|
-
},
|
|
405
|
-
let { fieldLabel:
|
|
409
|
+
}, Y = ({ schema: e, dataSource: r, className: o }) => {
|
|
410
|
+
let { fieldLabel: d } = c(), [p, m] = a(null), [h, g] = a({}), [_, v] = a(!0), [y, b] = a(null);
|
|
406
411
|
n(() => {
|
|
407
412
|
(async () => {
|
|
408
413
|
if (!r) {
|
|
409
|
-
|
|
414
|
+
v(!1);
|
|
410
415
|
return;
|
|
411
416
|
}
|
|
412
417
|
try {
|
|
413
|
-
|
|
418
|
+
m(await r.getObjectSchema(e.objectName));
|
|
414
419
|
} catch (e) {
|
|
415
|
-
|
|
420
|
+
b(e), v(!1);
|
|
416
421
|
}
|
|
417
422
|
})();
|
|
418
423
|
}, [e.objectName, r]), n(() => {
|
|
419
|
-
(
|
|
424
|
+
(p || !r) && (async () => {
|
|
420
425
|
if (e.mode === "create" || !e.recordId) {
|
|
421
|
-
|
|
426
|
+
g(e.initialData || e.initialValues || {}), v(!1);
|
|
422
427
|
return;
|
|
423
428
|
}
|
|
424
429
|
if (!r) {
|
|
425
|
-
|
|
430
|
+
g(e.initialData || e.initialValues || {}), v(!1);
|
|
426
431
|
return;
|
|
427
432
|
}
|
|
428
433
|
try {
|
|
429
|
-
|
|
434
|
+
g(await r.findOne(e.objectName, e.recordId) || {});
|
|
430
435
|
} catch (e) {
|
|
431
|
-
|
|
436
|
+
b(e);
|
|
432
437
|
} finally {
|
|
433
|
-
|
|
438
|
+
v(!1);
|
|
434
439
|
}
|
|
435
440
|
})();
|
|
436
441
|
}, [
|
|
437
|
-
|
|
442
|
+
p,
|
|
438
443
|
e.mode,
|
|
439
444
|
e.recordId,
|
|
440
445
|
e.initialData,
|
|
@@ -442,26 +447,29 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
442
447
|
r,
|
|
443
448
|
e.objectName
|
|
444
449
|
]);
|
|
445
|
-
let
|
|
446
|
-
let n = []
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
450
|
+
let x = t((t) => {
|
|
451
|
+
let n = [], r = (e, t) => typeof t == "string" && t.trim() ? {
|
|
452
|
+
...e,
|
|
453
|
+
visible: (e) => u(t, e)
|
|
454
|
+
} : e;
|
|
455
|
+
for (let i of t.fields) {
|
|
456
|
+
let t = typeof i == "string" ? i : i.name;
|
|
457
|
+
if (typeof i == "object") n.push(r(i, i.visibleOn));
|
|
458
|
+
else if (p?.fields?.[t]) {
|
|
459
|
+
let i = p.fields[t];
|
|
460
|
+
n.push(r({
|
|
453
461
|
name: t,
|
|
454
|
-
label:
|
|
455
|
-
type: f(
|
|
456
|
-
required:
|
|
457
|
-
disabled: e.readOnly || e.mode === "view" ||
|
|
458
|
-
placeholder:
|
|
459
|
-
description:
|
|
460
|
-
validation: l(
|
|
461
|
-
field:
|
|
462
|
-
options:
|
|
463
|
-
multiple:
|
|
464
|
-
});
|
|
462
|
+
label: d(e.objectName, t, i.label || t),
|
|
463
|
+
type: f(i.type),
|
|
464
|
+
required: i.required || !1,
|
|
465
|
+
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
466
|
+
placeholder: i.placeholder,
|
|
467
|
+
description: i.help || i.description,
|
|
468
|
+
validation: l(i),
|
|
469
|
+
field: i,
|
|
470
|
+
options: i.options,
|
|
471
|
+
multiple: i.multiple
|
|
472
|
+
}, i.visible_on ?? i.visibleOn));
|
|
465
473
|
} else n.push({
|
|
466
474
|
name: t,
|
|
467
475
|
label: t,
|
|
@@ -470,10 +478,11 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
470
478
|
}
|
|
471
479
|
return n;
|
|
472
480
|
}, [
|
|
473
|
-
|
|
481
|
+
p,
|
|
474
482
|
e.readOnly,
|
|
475
|
-
e.mode
|
|
476
|
-
|
|
483
|
+
e.mode,
|
|
484
|
+
e.objectName
|
|
485
|
+
]), S = t(async (t) => {
|
|
477
486
|
if (!r) return e.onSuccess && await e.onSuccess(t), t;
|
|
478
487
|
try {
|
|
479
488
|
let n;
|
|
@@ -481,43 +490,43 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
481
490
|
} catch (t) {
|
|
482
491
|
throw e.onError && e.onError(t), t;
|
|
483
492
|
}
|
|
484
|
-
}, [e, r]),
|
|
493
|
+
}, [e, r]), C = t(() => {
|
|
485
494
|
e.onCancel && e.onCancel();
|
|
486
|
-
}, [e]),
|
|
487
|
-
i(() => e.sections.flatMap((e) =>
|
|
488
|
-
let
|
|
489
|
-
if (
|
|
495
|
+
}, [e]), D = i(() => e.sections.slice(0, 1), [e.sections]), O = i(() => e.sections.slice(1), [e.sections]);
|
|
496
|
+
i(() => e.sections.flatMap((e) => x(e)), [e.sections, x]);
|
|
497
|
+
let k = e.splitDirection || "horizontal", A = e.splitSize || 50;
|
|
498
|
+
if (y) return /* @__PURE__ */ G("div", {
|
|
490
499
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
491
|
-
children: [/* @__PURE__ */
|
|
500
|
+
children: [/* @__PURE__ */ W("h3", {
|
|
492
501
|
className: "text-red-800 font-semibold",
|
|
493
502
|
children: "Error loading form"
|
|
494
|
-
}), /* @__PURE__ */
|
|
503
|
+
}), /* @__PURE__ */ W("p", {
|
|
495
504
|
className: "text-red-600 text-sm mt-1",
|
|
496
|
-
children:
|
|
505
|
+
children: y.message
|
|
497
506
|
})]
|
|
498
507
|
});
|
|
499
|
-
if (
|
|
508
|
+
if (_) return /* @__PURE__ */ G("div", {
|
|
500
509
|
className: "p-8 text-center",
|
|
501
|
-
children: [/* @__PURE__ */
|
|
510
|
+
children: [/* @__PURE__ */ W("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ W("p", {
|
|
502
511
|
className: "mt-2 text-sm text-gray-600",
|
|
503
512
|
children: "Loading form..."
|
|
504
513
|
})]
|
|
505
514
|
});
|
|
506
|
-
let
|
|
515
|
+
let j = {
|
|
507
516
|
type: "form",
|
|
508
517
|
layout: "vertical",
|
|
509
|
-
defaultValues:
|
|
510
|
-
onSubmit:
|
|
511
|
-
onCancel:
|
|
512
|
-
},
|
|
518
|
+
defaultValues: h,
|
|
519
|
+
onSubmit: S,
|
|
520
|
+
onCancel: C
|
|
521
|
+
}, M = (t, n) => /* @__PURE__ */ W("div", {
|
|
513
522
|
className: "space-y-4 p-4",
|
|
514
|
-
children: t.map((t, r) => /* @__PURE__ */
|
|
523
|
+
children: t.map((t, r) => /* @__PURE__ */ W(K, {
|
|
515
524
|
label: t.label,
|
|
516
525
|
description: t.description,
|
|
517
526
|
columns: t.columns || 1,
|
|
518
|
-
children: /* @__PURE__ */
|
|
519
|
-
...
|
|
520
|
-
fields:
|
|
527
|
+
children: /* @__PURE__ */ W(s, { schema: {
|
|
528
|
+
...j,
|
|
529
|
+
fields: x(t),
|
|
521
530
|
showSubmit: n && e.showSubmit !== !1 && e.mode !== "view",
|
|
522
531
|
showCancel: n && e.showCancel !== !1,
|
|
523
532
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
@@ -525,28 +534,28 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
525
534
|
} })
|
|
526
535
|
}, t.name || t.label || r))
|
|
527
536
|
});
|
|
528
|
-
return /* @__PURE__ */
|
|
537
|
+
return /* @__PURE__ */ W("div", {
|
|
529
538
|
className: L("w-full", o, e.className),
|
|
530
|
-
children: /* @__PURE__ */
|
|
531
|
-
orientation:
|
|
539
|
+
children: /* @__PURE__ */ G(E, {
|
|
540
|
+
orientation: k,
|
|
532
541
|
className: "min-h-[300px] rounded-lg border",
|
|
533
|
-
children: [/* @__PURE__ */
|
|
534
|
-
defaultSize:
|
|
542
|
+
children: [/* @__PURE__ */ W(T, {
|
|
543
|
+
defaultSize: A,
|
|
535
544
|
minSize: 20,
|
|
536
|
-
children:
|
|
537
|
-
}),
|
|
538
|
-
defaultSize: 100 -
|
|
545
|
+
children: M(D, O.length === 0)
|
|
546
|
+
}), O.length > 0 && /* @__PURE__ */ G(te, { children: [/* @__PURE__ */ W(w, { withHandle: e.splitResizable !== !1 }), /* @__PURE__ */ W(T, {
|
|
547
|
+
defaultSize: 100 - A,
|
|
539
548
|
minSize: 20,
|
|
540
|
-
children:
|
|
549
|
+
children: M(O, !0)
|
|
541
550
|
})] })]
|
|
542
551
|
})
|
|
543
552
|
});
|
|
544
|
-
},
|
|
553
|
+
}, X = new Set([
|
|
545
554
|
"field:formula",
|
|
546
555
|
"field:summary",
|
|
547
556
|
"field:auto_number",
|
|
548
557
|
"field:autonumber"
|
|
549
|
-
]),
|
|
558
|
+
]), Z = new Set([
|
|
550
559
|
"field:textarea",
|
|
551
560
|
"field:markdown",
|
|
552
561
|
"field:html",
|
|
@@ -557,70 +566,90 @@ var G = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, col
|
|
|
557
566
|
"html",
|
|
558
567
|
"grid",
|
|
559
568
|
"rich-text"
|
|
560
|
-
]),
|
|
569
|
+
]), ne = new Set([
|
|
561
570
|
"formula",
|
|
562
571
|
"summary",
|
|
563
572
|
"auto_number",
|
|
564
573
|
"autonumber"
|
|
565
574
|
]);
|
|
566
|
-
function
|
|
567
|
-
return
|
|
575
|
+
function Q(e) {
|
|
576
|
+
return Z.has(e);
|
|
568
577
|
}
|
|
569
|
-
function
|
|
570
|
-
return
|
|
578
|
+
function re(e) {
|
|
579
|
+
return ne.has(e);
|
|
571
580
|
}
|
|
572
|
-
function
|
|
581
|
+
function ie(e) {
|
|
573
582
|
return e <= 3 ? 1 : 2;
|
|
574
583
|
}
|
|
575
|
-
function
|
|
576
|
-
return t <= 1 ? e : e.map((e) => e.colSpan === void 0 && e.type &&
|
|
584
|
+
function ae(e, t) {
|
|
585
|
+
return t <= 1 ? e : e.map((e) => e.colSpan === void 0 && e.type && Q(e.type) ? {
|
|
577
586
|
...e,
|
|
578
587
|
colSpan: t
|
|
579
588
|
} : e);
|
|
580
589
|
}
|
|
581
|
-
var
|
|
590
|
+
var oe = new Set([
|
|
582
591
|
"id",
|
|
583
592
|
"created_at",
|
|
584
593
|
"createdAt",
|
|
585
594
|
"updated_at",
|
|
586
595
|
"updatedAt",
|
|
596
|
+
"last_modified_at",
|
|
597
|
+
"lastModifiedAt",
|
|
587
598
|
"deleted_at",
|
|
588
599
|
"deletedAt",
|
|
589
600
|
"created_by",
|
|
590
601
|
"createdBy",
|
|
591
602
|
"updated_by",
|
|
592
603
|
"updatedBy",
|
|
604
|
+
"last_modified_by",
|
|
605
|
+
"lastModifiedBy",
|
|
606
|
+
"organization_id",
|
|
607
|
+
"organizationId",
|
|
608
|
+
"org_id",
|
|
609
|
+
"orgId",
|
|
610
|
+
"tenant_id",
|
|
611
|
+
"tenantId",
|
|
593
612
|
"owner",
|
|
594
613
|
"owner_id",
|
|
595
614
|
"_version",
|
|
596
615
|
"_rev"
|
|
597
616
|
]);
|
|
598
|
-
function
|
|
617
|
+
function se(e, t) {
|
|
618
|
+
return e.filter((e) => !(oe.has(e.name) || t?.fields?.[e.name]?.readonly === !0));
|
|
619
|
+
}
|
|
620
|
+
function ce(e, t) {
|
|
599
621
|
return e.filter((e) => {
|
|
600
|
-
if (
|
|
622
|
+
if (oe.has(e.name) || e.type && X.has(e.type)) return !1;
|
|
601
623
|
if (!t?.fields) return !0;
|
|
602
624
|
let n = t.fields[e.name];
|
|
603
|
-
return n ? n.readonly === !0 ? !1 : !
|
|
625
|
+
return n ? n.readonly === !0 ? !1 : !re(n.type) : !0;
|
|
604
626
|
});
|
|
605
627
|
}
|
|
606
|
-
function
|
|
628
|
+
function le(e, t) {
|
|
629
|
+
return e.filter((e) => {
|
|
630
|
+
if (e.type && X.has(e.type)) return !1;
|
|
631
|
+
let n = t?.fields?.[e.name];
|
|
632
|
+
return n ? !re(n.type) : !0;
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
function ue(e) {
|
|
607
636
|
return e <= 1 ? "default" : e === 2 ? "xl" : "full";
|
|
608
637
|
}
|
|
609
|
-
function
|
|
638
|
+
function $(e, t, n, r) {
|
|
610
639
|
let i = [...e];
|
|
611
|
-
if (r === "create" && (i = le(i, t)), n !== void 0) return i =
|
|
640
|
+
if (i = se(i, t), r === "create" && (i = le(i, t)), n !== void 0) return i = ae(i, n), {
|
|
612
641
|
fields: i,
|
|
613
642
|
columns: n
|
|
614
643
|
};
|
|
615
|
-
let a =
|
|
616
|
-
return i =
|
|
644
|
+
let a = ie(i.length);
|
|
645
|
+
return i = ae(i, a), {
|
|
617
646
|
fields: i,
|
|
618
647
|
columns: a
|
|
619
648
|
};
|
|
620
649
|
}
|
|
621
650
|
//#endregion
|
|
622
651
|
//#region src/sanitize.ts
|
|
623
|
-
var
|
|
652
|
+
var de = new Set([
|
|
624
653
|
"id",
|
|
625
654
|
"_id",
|
|
626
655
|
"created_at",
|
|
@@ -629,7 +658,7 @@ var ue = new Set([
|
|
|
629
658
|
"updatedAt",
|
|
630
659
|
"organization_id",
|
|
631
660
|
"organizationId"
|
|
632
|
-
]),
|
|
661
|
+
]), fe = new Set([
|
|
633
662
|
"formula",
|
|
634
663
|
"rollup",
|
|
635
664
|
"lookup_value",
|
|
@@ -637,15 +666,15 @@ var ue = new Set([
|
|
|
637
666
|
"autonumber",
|
|
638
667
|
"computed"
|
|
639
668
|
]);
|
|
640
|
-
function
|
|
669
|
+
function pe(e, t) {
|
|
641
670
|
if (!e || typeof e != "object") return e;
|
|
642
671
|
let n = {}, r = t?.fields;
|
|
643
|
-
for (let [t, i] of Object.entries(e)) if (!
|
|
672
|
+
for (let [t, i] of Object.entries(e)) if (!de.has(t)) {
|
|
644
673
|
if (r) {
|
|
645
674
|
let e = r[t];
|
|
646
675
|
if (!e) continue;
|
|
647
676
|
let n = String(e.type || "").toLowerCase();
|
|
648
|
-
if (
|
|
677
|
+
if (fe.has(n) || e.computed === !0 || e.formula || e.readOnly === !0 || e.readonly === !0) continue;
|
|
649
678
|
}
|
|
650
679
|
n[t] = i;
|
|
651
680
|
}
|
|
@@ -653,12 +682,12 @@ function fe(e, t) {
|
|
|
653
682
|
}
|
|
654
683
|
//#endregion
|
|
655
684
|
//#region src/DrawerForm.tsx
|
|
656
|
-
var
|
|
685
|
+
var me = {
|
|
657
686
|
1: void 0,
|
|
658
687
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
659
688
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
660
689
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
661
|
-
},
|
|
690
|
+
}, he = ({ schema: e, dataSource: r, className: o }) => {
|
|
662
691
|
let { fieldLabel: u } = c(), [d, p] = a(null), [m, h] = a([]), [g, _] = a({}), [v, y] = a(!0), [b, x] = a(null), S = e.open !== !1, C = e.drawerSide || "right", [w, T] = a(() => {
|
|
663
692
|
let t = {};
|
|
664
693
|
return e.sections?.forEach((e, n) => {
|
|
@@ -780,7 +809,7 @@ var pe = {
|
|
|
780
809
|
let M = t(async (t) => {
|
|
781
810
|
if (!r) return e.onSuccess && await e.onSuccess(t), e.onOpenChange?.(!1), t;
|
|
782
811
|
try {
|
|
783
|
-
let n, i =
|
|
812
|
+
let n, i = pe(t, d);
|
|
784
813
|
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;
|
|
785
814
|
} catch (t) {
|
|
786
815
|
throw e.onError && e.onError(t), t;
|
|
@@ -810,29 +839,29 @@ var pe = {
|
|
|
810
839
|
onSubmit: M,
|
|
811
840
|
onCancel: N
|
|
812
841
|
};
|
|
813
|
-
return /* @__PURE__ */
|
|
842
|
+
return /* @__PURE__ */ W(D, {
|
|
814
843
|
open: S,
|
|
815
844
|
onOpenChange: e.onOpenChange,
|
|
816
|
-
children: /* @__PURE__ */
|
|
845
|
+
children: /* @__PURE__ */ G(O, {
|
|
817
846
|
side: C,
|
|
818
847
|
className: L("overflow-y-auto", o, e.className),
|
|
819
848
|
style: P,
|
|
820
|
-
children: [(e.title || e.description) && /* @__PURE__ */
|
|
849
|
+
children: [(e.title || e.description) && /* @__PURE__ */ G(A, { children: [e.title && /* @__PURE__ */ W(j, { children: e.title }), e.description && /* @__PURE__ */ W(k, { children: e.description })] }), /* @__PURE__ */ W("div", {
|
|
821
850
|
className: "@container py-4",
|
|
822
851
|
children: (() => {
|
|
823
|
-
if (b) return /* @__PURE__ */
|
|
852
|
+
if (b) return /* @__PURE__ */ G("div", {
|
|
824
853
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
825
|
-
children: [/* @__PURE__ */
|
|
854
|
+
children: [/* @__PURE__ */ W("h3", {
|
|
826
855
|
className: "text-red-800 font-semibold",
|
|
827
856
|
children: "Error loading form"
|
|
828
|
-
}), /* @__PURE__ */
|
|
857
|
+
}), /* @__PURE__ */ W("p", {
|
|
829
858
|
className: "text-red-600 text-sm mt-1",
|
|
830
859
|
children: b.message
|
|
831
860
|
})]
|
|
832
861
|
});
|
|
833
|
-
if (v) return /* @__PURE__ */
|
|
862
|
+
if (v) return /* @__PURE__ */ G("div", {
|
|
834
863
|
className: "p-8 text-center",
|
|
835
|
-
children: [/* @__PURE__ */
|
|
864
|
+
children: [/* @__PURE__ */ W("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ W("p", {
|
|
836
865
|
className: "mt-2 text-sm text-gray-600",
|
|
837
866
|
children: "Loading form..."
|
|
838
867
|
})]
|
|
@@ -858,13 +887,13 @@ var pe = {
|
|
|
858
887
|
...e,
|
|
859
888
|
hidden: !0
|
|
860
889
|
}))) : t.push(...a);
|
|
861
|
-
}), /* @__PURE__ */
|
|
890
|
+
}), /* @__PURE__ */ W(s, { schema: {
|
|
862
891
|
...F,
|
|
863
892
|
fields: t
|
|
864
893
|
} });
|
|
865
894
|
}
|
|
866
|
-
let t =
|
|
867
|
-
return /* @__PURE__ */
|
|
895
|
+
let t = $(m, d, e.columns, e.mode), n = me[t.columns || 1];
|
|
896
|
+
return /* @__PURE__ */ W(s, { schema: {
|
|
868
897
|
...F,
|
|
869
898
|
fields: t.fields,
|
|
870
899
|
columns: t.columns,
|
|
@@ -874,70 +903,89 @@ var pe = {
|
|
|
874
903
|
})]
|
|
875
904
|
})
|
|
876
905
|
});
|
|
877
|
-
},
|
|
906
|
+
}, ge = {
|
|
878
907
|
sm: "sm:max-w-sm",
|
|
879
908
|
default: "sm:max-w-lg",
|
|
880
909
|
lg: "sm:max-w-2xl",
|
|
881
910
|
xl: "sm:max-w-5xl",
|
|
882
911
|
full: "sm:max-w-[95vw] sm:w-full"
|
|
883
|
-
},
|
|
912
|
+
}, _e = {
|
|
884
913
|
1: void 0,
|
|
885
914
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
886
915
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
887
916
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
888
|
-
},
|
|
889
|
-
let { fieldLabel:
|
|
890
|
-
|
|
891
|
-
|
|
917
|
+
}, ve = ({ schema: e, dataSource: o, className: d }) => {
|
|
918
|
+
let { fieldLabel: m } = c(), h = z(), g = t((t) => {
|
|
919
|
+
if (!h?.isLoaded) return t;
|
|
920
|
+
let n = [];
|
|
921
|
+
for (let r of t) {
|
|
922
|
+
if (!r?.name) {
|
|
923
|
+
n.push(r);
|
|
924
|
+
continue;
|
|
925
|
+
}
|
|
926
|
+
h.checkField(e.objectName, r.name, "read") && (!h.checkField(e.objectName, r.name, "write") && e.mode !== "view" ? n.push({
|
|
927
|
+
...r,
|
|
928
|
+
readOnly: !0,
|
|
929
|
+
disabled: !0
|
|
930
|
+
}) : n.push(r));
|
|
931
|
+
}
|
|
932
|
+
return n;
|
|
933
|
+
}, [
|
|
934
|
+
h,
|
|
935
|
+
e.objectName,
|
|
936
|
+
e.mode
|
|
937
|
+
]), [_, v] = a(null), [w, T] = a([]), [E, D] = a({}), [O, k] = a(!0), [A, j] = a(null), [N, P] = a(!1), F = e.open !== !1, I = r(), R = i(() => e.sections?.length || e.customFields?.length ? null : $(w, _, e.columns, e.mode), [
|
|
938
|
+
w,
|
|
939
|
+
_,
|
|
892
940
|
e.columns,
|
|
893
941
|
e.mode,
|
|
894
942
|
e.sections,
|
|
895
943
|
e.customFields
|
|
896
|
-
]),
|
|
944
|
+
]), B = ge[i(() => {
|
|
897
945
|
if (e.modalSize) return e.modalSize;
|
|
898
|
-
if (
|
|
946
|
+
if (R?.columns && R.columns > 1) return ue(R.columns);
|
|
899
947
|
if (e.sections?.length) {
|
|
900
948
|
let t = Math.max(...e.sections.map((e) => Number(e.columns) || 1));
|
|
901
|
-
if (t > 1) return
|
|
949
|
+
if (t > 1) return ue(t);
|
|
902
950
|
}
|
|
903
951
|
return "default";
|
|
904
952
|
}, [
|
|
905
953
|
e.modalSize,
|
|
906
|
-
|
|
954
|
+
R,
|
|
907
955
|
e.sections
|
|
908
|
-
])] ||
|
|
956
|
+
])] || ge.default;
|
|
909
957
|
n(() => {
|
|
910
958
|
(async () => {
|
|
911
959
|
if (!o) {
|
|
912
|
-
|
|
960
|
+
k(!1);
|
|
913
961
|
return;
|
|
914
962
|
}
|
|
915
963
|
try {
|
|
916
|
-
|
|
964
|
+
v(await o.getObjectSchema(e.objectName));
|
|
917
965
|
} catch (e) {
|
|
918
|
-
|
|
966
|
+
j(e), k(!1);
|
|
919
967
|
}
|
|
920
968
|
})();
|
|
921
969
|
}, [e.objectName, o]), n(() => {
|
|
922
|
-
(
|
|
970
|
+
(_ || !o) && (async () => {
|
|
923
971
|
if (e.mode === "create" || !e.recordId) {
|
|
924
|
-
|
|
972
|
+
D(e.initialData || e.initialValues || {}), k(!1);
|
|
925
973
|
return;
|
|
926
974
|
}
|
|
927
975
|
if (!o) {
|
|
928
|
-
|
|
976
|
+
D(e.initialData || e.initialValues || {}), k(!1);
|
|
929
977
|
return;
|
|
930
978
|
}
|
|
931
979
|
try {
|
|
932
|
-
|
|
980
|
+
D(await o.findOne(e.objectName, e.recordId) || {});
|
|
933
981
|
} catch (e) {
|
|
934
|
-
|
|
982
|
+
j(e);
|
|
935
983
|
} finally {
|
|
936
|
-
|
|
984
|
+
k(!1);
|
|
937
985
|
}
|
|
938
986
|
})();
|
|
939
987
|
}, [
|
|
940
|
-
|
|
988
|
+
_,
|
|
941
989
|
e.mode,
|
|
942
990
|
e.recordId,
|
|
943
991
|
e.initialData,
|
|
@@ -945,26 +993,29 @@ var pe = {
|
|
|
945
993
|
o,
|
|
946
994
|
e.objectName
|
|
947
995
|
]);
|
|
948
|
-
let
|
|
949
|
-
let n = []
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
996
|
+
let V = t((t) => {
|
|
997
|
+
let n = [], r = (e, t) => typeof t == "string" && t.trim() ? {
|
|
998
|
+
...e,
|
|
999
|
+
visible: (e) => u(t, e)
|
|
1000
|
+
} : e;
|
|
1001
|
+
for (let i of t.fields) {
|
|
1002
|
+
let t = typeof i == "string" ? i : i.name;
|
|
1003
|
+
if (typeof i == "object") n.push(r(i, i.visibleOn));
|
|
1004
|
+
else if (_?.fields?.[t]) {
|
|
1005
|
+
let i = _.fields[t];
|
|
1006
|
+
n.push(r({
|
|
956
1007
|
name: t,
|
|
957
|
-
label:
|
|
958
|
-
type: f(
|
|
959
|
-
required:
|
|
960
|
-
disabled: e.readOnly || e.mode === "view" ||
|
|
961
|
-
placeholder:
|
|
962
|
-
description:
|
|
963
|
-
validation: l(
|
|
964
|
-
field:
|
|
965
|
-
options:
|
|
966
|
-
multiple:
|
|
967
|
-
});
|
|
1008
|
+
label: m(e.objectName, t, i.label || t),
|
|
1009
|
+
type: f(i.type),
|
|
1010
|
+
required: i.required || !1,
|
|
1011
|
+
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
1012
|
+
placeholder: i.placeholder,
|
|
1013
|
+
description: i.help || i.description,
|
|
1014
|
+
validation: l(i),
|
|
1015
|
+
field: i,
|
|
1016
|
+
options: i.options,
|
|
1017
|
+
multiple: i.multiple
|
|
1018
|
+
}, i.visible_on ?? i.visibleOn));
|
|
968
1019
|
} else n.push({
|
|
969
1020
|
name: t,
|
|
970
1021
|
label: t,
|
|
@@ -973,29 +1024,30 @@ var pe = {
|
|
|
973
1024
|
}
|
|
974
1025
|
return n;
|
|
975
1026
|
}, [
|
|
976
|
-
|
|
1027
|
+
_,
|
|
977
1028
|
e.readOnly,
|
|
978
|
-
e.mode
|
|
1029
|
+
e.mode,
|
|
1030
|
+
e.objectName
|
|
979
1031
|
]);
|
|
980
1032
|
n(() => {
|
|
981
|
-
if (!
|
|
1033
|
+
if (!_ && o) return;
|
|
982
1034
|
if (e.customFields?.length) {
|
|
983
|
-
|
|
1035
|
+
T(e.customFields), k(!1);
|
|
984
1036
|
return;
|
|
985
1037
|
}
|
|
986
1038
|
if (e.sections?.length) {
|
|
987
|
-
|
|
1039
|
+
k(!1);
|
|
988
1040
|
return;
|
|
989
1041
|
}
|
|
990
|
-
if (!
|
|
991
|
-
let t = e.fields || Object.keys(
|
|
1042
|
+
if (!_) return;
|
|
1043
|
+
let t = e.fields || Object.keys(_.fields || {}), n = [];
|
|
992
1044
|
for (let r of t) {
|
|
993
1045
|
let t = typeof r == "string" ? r : r.name;
|
|
994
1046
|
if (!t) continue;
|
|
995
|
-
let i =
|
|
1047
|
+
let i = _.fields?.[t];
|
|
996
1048
|
i && n.push({
|
|
997
1049
|
name: t,
|
|
998
|
-
label:
|
|
1050
|
+
label: m(e.objectName, t, i.label || t),
|
|
999
1051
|
type: f(i.type),
|
|
1000
1052
|
required: i.required || !1,
|
|
1001
1053
|
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
@@ -1007,9 +1059,9 @@ var pe = {
|
|
|
1007
1059
|
multiple: i.multiple
|
|
1008
1060
|
});
|
|
1009
1061
|
}
|
|
1010
|
-
|
|
1062
|
+
T(n), k(!1);
|
|
1011
1063
|
}, [
|
|
1012
|
-
|
|
1064
|
+
_,
|
|
1013
1065
|
e.fields,
|
|
1014
1066
|
e.customFields,
|
|
1015
1067
|
e.sections,
|
|
@@ -1017,239 +1069,274 @@ var pe = {
|
|
|
1017
1069
|
e.mode,
|
|
1018
1070
|
o
|
|
1019
1071
|
]);
|
|
1020
|
-
let
|
|
1021
|
-
|
|
1072
|
+
let H = t(async (t) => {
|
|
1073
|
+
P(!0);
|
|
1022
1074
|
try {
|
|
1023
1075
|
if (!o) return e.onSuccess && await e.onSuccess(t), e.onOpenChange?.(!1), t;
|
|
1024
|
-
let n, r =
|
|
1076
|
+
let n, r = pe(t, _);
|
|
1077
|
+
if (h?.isLoaded) {
|
|
1078
|
+
let t = {};
|
|
1079
|
+
for (let n of Object.keys(r)) h.checkField(e.objectName, n, "write") && (t[n] = r[n]);
|
|
1080
|
+
r = t;
|
|
1081
|
+
}
|
|
1025
1082
|
return e.mode === "create" ? n = await o.create(e.objectName, r) : e.mode === "edit" && e.recordId && (n = await o.update(e.objectName, e.recordId, r)), e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
1026
1083
|
} catch (t) {
|
|
1027
1084
|
throw e.onError && e.onError(t), t;
|
|
1028
1085
|
} finally {
|
|
1029
|
-
|
|
1086
|
+
P(!1);
|
|
1030
1087
|
}
|
|
1031
1088
|
}, [
|
|
1032
1089
|
e,
|
|
1033
1090
|
o,
|
|
1034
|
-
|
|
1035
|
-
|
|
1091
|
+
_,
|
|
1092
|
+
h
|
|
1093
|
+
]), U = t(() => {
|
|
1036
1094
|
e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
|
|
1037
|
-
}, [e]),
|
|
1095
|
+
}, [e]), te = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", q = e.showSubmit !== !1 && e.mode !== "view", J = e.showCancel !== !1, Y = e.submitText || (e.mode === "create" ? "Create" : "Update"), X = e.cancelText || "Cancel", Z = {
|
|
1038
1096
|
type: "form",
|
|
1039
|
-
layout:
|
|
1040
|
-
defaultValues:
|
|
1041
|
-
submitLabel:
|
|
1042
|
-
cancelLabel:
|
|
1043
|
-
showSubmit:
|
|
1044
|
-
showCancel:
|
|
1045
|
-
onSubmit:
|
|
1046
|
-
onCancel:
|
|
1097
|
+
layout: te,
|
|
1098
|
+
defaultValues: E,
|
|
1099
|
+
submitLabel: Y,
|
|
1100
|
+
cancelLabel: X,
|
|
1101
|
+
showSubmit: q,
|
|
1102
|
+
showCancel: J,
|
|
1103
|
+
onSubmit: H,
|
|
1104
|
+
onCancel: U,
|
|
1047
1105
|
showActions: !1,
|
|
1048
|
-
id:
|
|
1049
|
-
},
|
|
1050
|
-
if (
|
|
1106
|
+
id: I
|
|
1107
|
+
}, ne = () => {
|
|
1108
|
+
if (A) return /* @__PURE__ */ G("div", {
|
|
1051
1109
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1052
|
-
children: [/* @__PURE__ */
|
|
1110
|
+
children: [/* @__PURE__ */ W("h3", {
|
|
1053
1111
|
className: "text-red-800 font-semibold",
|
|
1054
1112
|
children: "Error loading form"
|
|
1055
|
-
}), /* @__PURE__ */
|
|
1113
|
+
}), /* @__PURE__ */ W("p", {
|
|
1056
1114
|
className: "text-red-600 text-sm mt-1",
|
|
1057
|
-
children:
|
|
1115
|
+
children: A.message
|
|
1058
1116
|
})]
|
|
1059
1117
|
});
|
|
1060
|
-
if (
|
|
1118
|
+
if (O) return /* @__PURE__ */ W("div", {
|
|
1061
1119
|
className: "space-y-4",
|
|
1062
1120
|
"data-testid": "modal-form-skeleton",
|
|
1063
1121
|
children: [
|
|
1064
1122
|
1,
|
|
1065
1123
|
2,
|
|
1066
1124
|
3
|
|
1067
|
-
].map((e) => /* @__PURE__ */
|
|
1125
|
+
].map((e) => /* @__PURE__ */ G("div", {
|
|
1068
1126
|
className: "space-y-2",
|
|
1069
|
-
children: [/* @__PURE__ */
|
|
1127
|
+
children: [/* @__PURE__ */ W(M, { className: "h-4 w-24" }), /* @__PURE__ */ W(M, { className: "h-10 w-full" })]
|
|
1070
1128
|
}, e))
|
|
1071
1129
|
});
|
|
1072
|
-
if (e.sections?.length) return /* @__PURE__ */
|
|
1130
|
+
if (e.sections?.length) return /* @__PURE__ */ W("div", {
|
|
1073
1131
|
className: "space-y-6",
|
|
1074
1132
|
children: e.sections.map((e, t) => {
|
|
1075
1133
|
let n = e.columns || 1;
|
|
1076
|
-
return /* @__PURE__ */
|
|
1134
|
+
return /* @__PURE__ */ W(K, {
|
|
1077
1135
|
label: e.label,
|
|
1078
1136
|
description: e.description,
|
|
1079
1137
|
columns: n,
|
|
1080
|
-
gridClassName:
|
|
1081
|
-
children: /* @__PURE__ */
|
|
1082
|
-
...
|
|
1083
|
-
fields:
|
|
1138
|
+
gridClassName: _e[n],
|
|
1139
|
+
children: /* @__PURE__ */ W(s, { schema: {
|
|
1140
|
+
...Z,
|
|
1141
|
+
fields: g(V(e))
|
|
1084
1142
|
} })
|
|
1085
1143
|
}, e.name || e.label || t);
|
|
1086
1144
|
})
|
|
1087
1145
|
});
|
|
1088
|
-
let t =
|
|
1089
|
-
return /* @__PURE__ */
|
|
1090
|
-
...
|
|
1091
|
-
fields: t.fields,
|
|
1146
|
+
let t = R ?? $(w, _, e.columns, e.mode), n = _e[t.columns || 1];
|
|
1147
|
+
return /* @__PURE__ */ W(s, { schema: {
|
|
1148
|
+
...Z,
|
|
1149
|
+
fields: g(t.fields),
|
|
1092
1150
|
columns: t.columns,
|
|
1093
1151
|
...n ? { fieldContainerClass: n } : {}
|
|
1094
1152
|
} });
|
|
1095
|
-
},
|
|
1096
|
-
return /* @__PURE__ */
|
|
1097
|
-
open:
|
|
1153
|
+
}, Q = !O && !A && (q || J);
|
|
1154
|
+
return /* @__PURE__ */ W(y, {
|
|
1155
|
+
open: F,
|
|
1098
1156
|
onOpenChange: e.onOpenChange,
|
|
1099
|
-
children: /* @__PURE__ */
|
|
1100
|
-
className: L(
|
|
1157
|
+
children: /* @__PURE__ */ G(C, {
|
|
1158
|
+
className: L(B, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", d, e.className),
|
|
1101
1159
|
children: [
|
|
1102
|
-
(e.title || e.description) && /* @__PURE__ */
|
|
1160
|
+
(e.title || e.description) && /* @__PURE__ */ G(x, {
|
|
1103
1161
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
1104
|
-
children: [e.title && /* @__PURE__ */
|
|
1162
|
+
children: [e.title && /* @__PURE__ */ W(S, { children: e.title }), e.description && /* @__PURE__ */ W(b, { children: e.description })]
|
|
1105
1163
|
}),
|
|
1106
|
-
/* @__PURE__ */
|
|
1164
|
+
/* @__PURE__ */ W("div", {
|
|
1107
1165
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
1108
|
-
children:
|
|
1166
|
+
children: ne()
|
|
1109
1167
|
}),
|
|
1110
|
-
|
|
1168
|
+
Q && /* @__PURE__ */ W("div", {
|
|
1111
1169
|
className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background",
|
|
1112
1170
|
"data-testid": "modal-form-footer",
|
|
1113
|
-
children: /* @__PURE__ */
|
|
1171
|
+
children: /* @__PURE__ */ G("div", {
|
|
1114
1172
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
1115
|
-
children: [
|
|
1173
|
+
children: [J && /* @__PURE__ */ W(p, {
|
|
1116
1174
|
type: "button",
|
|
1117
1175
|
variant: "outline",
|
|
1118
|
-
onClick:
|
|
1119
|
-
disabled:
|
|
1176
|
+
onClick: U,
|
|
1177
|
+
disabled: N,
|
|
1120
1178
|
className: "w-full sm:w-auto",
|
|
1121
|
-
children:
|
|
1122
|
-
}),
|
|
1179
|
+
children: X
|
|
1180
|
+
}), q && /* @__PURE__ */ G(p, {
|
|
1123
1181
|
type: "submit",
|
|
1124
|
-
form:
|
|
1125
|
-
disabled:
|
|
1182
|
+
form: I,
|
|
1183
|
+
disabled: N,
|
|
1126
1184
|
className: "w-full sm:w-auto",
|
|
1127
|
-
children: [
|
|
1185
|
+
children: [N && /* @__PURE__ */ W(ee, { className: "mr-2 h-4 w-4 animate-spin" }), Y]
|
|
1128
1186
|
})]
|
|
1129
1187
|
})
|
|
1130
1188
|
})
|
|
1131
1189
|
]
|
|
1132
1190
|
})
|
|
1133
1191
|
});
|
|
1134
|
-
},
|
|
1135
|
-
let
|
|
1136
|
-
|
|
1137
|
-
|
|
1192
|
+
}, ye = ({ schema: e, dataSource: t }) => {
|
|
1193
|
+
let n = z(), r = i(() => {
|
|
1194
|
+
if (!n?.isLoaded) return e;
|
|
1195
|
+
let t = (t) => t?.name ? n.checkField(e.objectName, t.name, "read") ? !n.checkField(e.objectName, t.name, "write") && e.mode !== "view" ? {
|
|
1196
|
+
...t,
|
|
1197
|
+
readOnly: !0,
|
|
1198
|
+
disabled: !0
|
|
1199
|
+
} : t : null : t, r = (e) => Array.isArray(e) ? e.map(t).filter(Boolean) : e;
|
|
1200
|
+
return {
|
|
1138
1201
|
...e,
|
|
1202
|
+
fields: r(e.fields),
|
|
1203
|
+
sections: e.sections?.map((e) => ({
|
|
1204
|
+
...e,
|
|
1205
|
+
fields: r(e.fields)
|
|
1206
|
+
}))
|
|
1207
|
+
};
|
|
1208
|
+
}, [e, n]), { sectionLabel: a } = c(), o = (e) => e?.name ? a(r.objectName, e.name, e.label || e.name) : e?.label;
|
|
1209
|
+
if (r.formType === "tabbed" && r.sections?.length) return /* @__PURE__ */ W(q, {
|
|
1210
|
+
schema: {
|
|
1211
|
+
...r,
|
|
1139
1212
|
formType: "tabbed",
|
|
1140
|
-
sections:
|
|
1213
|
+
sections: r.sections.map((e) => ({
|
|
1141
1214
|
name: e.name,
|
|
1142
|
-
label:
|
|
1215
|
+
label: o(e),
|
|
1143
1216
|
description: e.description,
|
|
1144
1217
|
columns: e.columns,
|
|
1145
1218
|
fields: e.fields
|
|
1146
1219
|
})),
|
|
1147
|
-
defaultTab:
|
|
1148
|
-
tabPosition:
|
|
1220
|
+
defaultTab: r.defaultTab,
|
|
1221
|
+
tabPosition: r.tabPosition
|
|
1149
1222
|
},
|
|
1150
1223
|
dataSource: t,
|
|
1151
|
-
className:
|
|
1224
|
+
className: r.className
|
|
1152
1225
|
});
|
|
1153
|
-
if (
|
|
1226
|
+
if (r.formType === "wizard" && r.sections?.length) return /* @__PURE__ */ W(J, {
|
|
1154
1227
|
schema: {
|
|
1155
|
-
...
|
|
1228
|
+
...r,
|
|
1156
1229
|
formType: "wizard",
|
|
1157
|
-
sections:
|
|
1230
|
+
sections: r.sections.map((e) => ({
|
|
1158
1231
|
name: e.name,
|
|
1159
|
-
label:
|
|
1232
|
+
label: o(e),
|
|
1160
1233
|
description: e.description,
|
|
1161
1234
|
columns: e.columns,
|
|
1162
1235
|
fields: e.fields
|
|
1163
1236
|
})),
|
|
1164
|
-
allowSkip:
|
|
1165
|
-
showStepIndicator:
|
|
1166
|
-
nextText:
|
|
1167
|
-
prevText:
|
|
1168
|
-
onStepChange:
|
|
1237
|
+
allowSkip: r.allowSkip,
|
|
1238
|
+
showStepIndicator: r.showStepIndicator,
|
|
1239
|
+
nextText: r.nextText,
|
|
1240
|
+
prevText: r.prevText,
|
|
1241
|
+
onStepChange: r.onStepChange
|
|
1169
1242
|
},
|
|
1170
1243
|
dataSource: t,
|
|
1171
|
-
className:
|
|
1244
|
+
className: r.className
|
|
1172
1245
|
});
|
|
1173
|
-
if (
|
|
1246
|
+
if (r.formType === "split" && r.sections?.length) return /* @__PURE__ */ W(Y, {
|
|
1174
1247
|
schema: {
|
|
1175
|
-
...
|
|
1248
|
+
...r,
|
|
1176
1249
|
formType: "split",
|
|
1177
|
-
sections:
|
|
1250
|
+
sections: r.sections.map((e) => ({
|
|
1178
1251
|
name: e.name,
|
|
1179
|
-
label:
|
|
1252
|
+
label: o(e),
|
|
1180
1253
|
description: e.description,
|
|
1181
1254
|
columns: e.columns,
|
|
1182
1255
|
fields: e.fields
|
|
1183
1256
|
})),
|
|
1184
|
-
splitDirection:
|
|
1185
|
-
splitSize:
|
|
1186
|
-
splitResizable:
|
|
1257
|
+
splitDirection: r.splitDirection,
|
|
1258
|
+
splitSize: r.splitSize,
|
|
1259
|
+
splitResizable: r.splitResizable
|
|
1187
1260
|
},
|
|
1188
1261
|
dataSource: t,
|
|
1189
|
-
className:
|
|
1262
|
+
className: r.className
|
|
1190
1263
|
});
|
|
1191
|
-
if (
|
|
1192
|
-
let { layout:
|
|
1193
|
-
return /* @__PURE__ */
|
|
1264
|
+
if (r.formType === "drawer") {
|
|
1265
|
+
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
1266
|
+
return /* @__PURE__ */ W(he, {
|
|
1194
1267
|
schema: {
|
|
1195
|
-
...
|
|
1196
|
-
layout:
|
|
1268
|
+
...n,
|
|
1269
|
+
layout: i,
|
|
1197
1270
|
formType: "drawer",
|
|
1198
|
-
sections:
|
|
1271
|
+
sections: r.sections?.map((e) => ({
|
|
1199
1272
|
name: e.name,
|
|
1200
|
-
label:
|
|
1273
|
+
label: o(e),
|
|
1201
1274
|
description: e.description,
|
|
1202
1275
|
columns: e.columns,
|
|
1203
1276
|
fields: e.fields,
|
|
1204
1277
|
collapsible: e.collapsible,
|
|
1205
1278
|
collapsed: e.collapsed
|
|
1206
1279
|
})),
|
|
1207
|
-
open:
|
|
1208
|
-
onOpenChange:
|
|
1209
|
-
drawerSide:
|
|
1210
|
-
drawerWidth:
|
|
1280
|
+
open: r.open,
|
|
1281
|
+
onOpenChange: r.onOpenChange,
|
|
1282
|
+
drawerSide: r.drawerSide,
|
|
1283
|
+
drawerWidth: r.drawerWidth
|
|
1211
1284
|
},
|
|
1212
1285
|
dataSource: t,
|
|
1213
|
-
className:
|
|
1286
|
+
className: r.className
|
|
1214
1287
|
});
|
|
1215
1288
|
}
|
|
1216
|
-
if (
|
|
1217
|
-
let { layout:
|
|
1218
|
-
return /* @__PURE__ */
|
|
1289
|
+
if (r.formType === "modal") {
|
|
1290
|
+
let { layout: e, ...n } = r, i = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : void 0;
|
|
1291
|
+
return /* @__PURE__ */ W(ve, {
|
|
1219
1292
|
schema: {
|
|
1220
|
-
...
|
|
1221
|
-
layout:
|
|
1293
|
+
...n,
|
|
1294
|
+
layout: i,
|
|
1222
1295
|
formType: "modal",
|
|
1223
|
-
sections:
|
|
1296
|
+
sections: r.sections?.map((e) => ({
|
|
1224
1297
|
name: e.name,
|
|
1225
|
-
label:
|
|
1298
|
+
label: o(e),
|
|
1226
1299
|
description: e.description,
|
|
1227
1300
|
columns: e.columns,
|
|
1228
1301
|
fields: e.fields
|
|
1229
1302
|
})),
|
|
1230
|
-
open:
|
|
1231
|
-
onOpenChange:
|
|
1232
|
-
modalSize:
|
|
1233
|
-
modalCloseButton:
|
|
1303
|
+
open: r.open,
|
|
1304
|
+
onOpenChange: r.onOpenChange,
|
|
1305
|
+
modalSize: r.modalSize,
|
|
1306
|
+
modalCloseButton: r.modalCloseButton
|
|
1234
1307
|
},
|
|
1235
1308
|
dataSource: t,
|
|
1236
|
-
className:
|
|
1309
|
+
className: r.className
|
|
1237
1310
|
});
|
|
1238
1311
|
}
|
|
1239
|
-
return /* @__PURE__ */
|
|
1240
|
-
schema:
|
|
1312
|
+
return /* @__PURE__ */ W(be, {
|
|
1313
|
+
schema: r,
|
|
1241
1314
|
dataSource: t
|
|
1242
1315
|
});
|
|
1243
|
-
},
|
|
1244
|
-
let { fieldLabel: o, sectionLabel: p } = c(), m = R(),
|
|
1316
|
+
}, be = ({ schema: r, dataSource: i }) => {
|
|
1317
|
+
let { fieldLabel: o, sectionLabel: p } = c(), m = R(), h = z(), g = t((e) => {
|
|
1318
|
+
if (!h?.isLoaded) return e;
|
|
1319
|
+
let t = [];
|
|
1320
|
+
for (let n of e) h.checkField(r.objectName, n.name, "read") && (!h.checkField(r.objectName, n.name, "write") && r.mode !== "view" ? t.push({
|
|
1321
|
+
...n,
|
|
1322
|
+
readOnly: !0,
|
|
1323
|
+
disabled: !0,
|
|
1324
|
+
description: n.description ?? "You do not have edit access to this field."
|
|
1325
|
+
}) : t.push(n));
|
|
1326
|
+
return t;
|
|
1327
|
+
}, [
|
|
1328
|
+
h,
|
|
1329
|
+
r.objectName,
|
|
1330
|
+
r.mode
|
|
1331
|
+
]), [_, v] = a(null), [y, b] = a([]), [x, S] = a(null), [C, w] = a(!0), [T, E] = a(null), D = r.customFields && r.customFields.length > 0;
|
|
1245
1332
|
n(() => {
|
|
1246
|
-
|
|
1333
|
+
D && (S(r.initialData || r.initialValues || {}), w(!1));
|
|
1247
1334
|
}, [
|
|
1248
|
-
|
|
1335
|
+
D,
|
|
1249
1336
|
r.initialData,
|
|
1250
1337
|
r.initialValues
|
|
1251
1338
|
]), n(() => {
|
|
1252
|
-
|
|
1339
|
+
D ? v({
|
|
1253
1340
|
name: r.objectName,
|
|
1254
1341
|
fields: {}
|
|
1255
1342
|
}) : r.objectName && i ? (async () => {
|
|
@@ -1257,33 +1344,33 @@ var pe = {
|
|
|
1257
1344
|
if (!i) throw Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");
|
|
1258
1345
|
let e = await i.getObjectSchema(r.objectName);
|
|
1259
1346
|
if (!e) throw Error(`No schema found for object "${r.objectName}"`);
|
|
1260
|
-
|
|
1347
|
+
v(e);
|
|
1261
1348
|
} catch (e) {
|
|
1262
|
-
|
|
1349
|
+
E(e), w(!1);
|
|
1263
1350
|
}
|
|
1264
|
-
})() :
|
|
1351
|
+
})() : D || w(!1);
|
|
1265
1352
|
}, [
|
|
1266
1353
|
r.objectName,
|
|
1267
1354
|
i,
|
|
1268
|
-
|
|
1355
|
+
D
|
|
1269
1356
|
]), n(() => {
|
|
1270
|
-
|
|
1357
|
+
_ && !D && (async () => {
|
|
1271
1358
|
if (!r.recordId || r.mode === "create") {
|
|
1272
|
-
|
|
1359
|
+
S(r.initialData || r.initialValues || {}), w(!1);
|
|
1273
1360
|
return;
|
|
1274
1361
|
}
|
|
1275
|
-
if (!
|
|
1362
|
+
if (!D) {
|
|
1276
1363
|
if (!i) {
|
|
1277
|
-
|
|
1364
|
+
E(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), w(!1);
|
|
1278
1365
|
return;
|
|
1279
1366
|
}
|
|
1280
|
-
|
|
1367
|
+
w(!0);
|
|
1281
1368
|
try {
|
|
1282
|
-
|
|
1369
|
+
S(await i.findOne(r.objectName, r.recordId));
|
|
1283
1370
|
} catch (e) {
|
|
1284
|
-
console.error("Failed to fetch record:", e),
|
|
1371
|
+
console.error("Failed to fetch record:", e), E(e);
|
|
1285
1372
|
} finally {
|
|
1286
|
-
|
|
1373
|
+
w(!1);
|
|
1287
1374
|
}
|
|
1288
1375
|
}
|
|
1289
1376
|
})();
|
|
@@ -1294,31 +1381,40 @@ var pe = {
|
|
|
1294
1381
|
r.initialValues,
|
|
1295
1382
|
r.initialData,
|
|
1296
1383
|
i,
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
])
|
|
1300
|
-
|
|
1301
|
-
|
|
1384
|
+
_,
|
|
1385
|
+
D
|
|
1386
|
+
]);
|
|
1387
|
+
let O = t((e) => {
|
|
1388
|
+
if (!e || typeof e.visible == "function") return e;
|
|
1389
|
+
let t = e.visibleOn;
|
|
1390
|
+
return typeof t == "string" && t.trim() ? {
|
|
1391
|
+
...e,
|
|
1392
|
+
visible: (e) => u(t, e)
|
|
1393
|
+
} : e;
|
|
1394
|
+
}, []);
|
|
1395
|
+
n(() => {
|
|
1396
|
+
if (D && r.customFields) {
|
|
1397
|
+
b(r.customFields.map(O)), w(!1);
|
|
1302
1398
|
return;
|
|
1303
1399
|
}
|
|
1304
|
-
if (!
|
|
1305
|
-
let e = [], t = r.fields || Object.keys(
|
|
1400
|
+
if (!_) return;
|
|
1401
|
+
let e = [], t = r.fields || Object.keys(_.fields || {});
|
|
1306
1402
|
(Array.isArray(t) ? t : Object.keys(t)).forEach((t) => {
|
|
1307
1403
|
let n = typeof t == "string" ? t : t.name;
|
|
1308
1404
|
if (!n) return;
|
|
1309
|
-
let i =
|
|
1310
|
-
if (!i && !
|
|
1405
|
+
let i = _.fields?.[n];
|
|
1406
|
+
if (!i && !D) return;
|
|
1311
1407
|
let a = !i?.permissions || i?.permissions.write !== !1;
|
|
1312
1408
|
if (r.mode !== "view" && !a) return;
|
|
1313
1409
|
let s = r.customFields?.find((e) => e.name === n);
|
|
1314
|
-
if (s) e.push(s);
|
|
1410
|
+
if (s) e.push(O(s));
|
|
1315
1411
|
else if (i) {
|
|
1316
1412
|
let a = {
|
|
1317
1413
|
name: n,
|
|
1318
1414
|
label: o(r.objectName, n, i.label || t),
|
|
1319
1415
|
type: f(i.type),
|
|
1320
1416
|
required: i.required || !1,
|
|
1321
|
-
disabled: r.readOnly || r.mode === "view" || i.readonly ||
|
|
1417
|
+
disabled: r.readOnly || r.mode === "view" || i.readonly || _?.managedBy && _.managedBy !== "platform",
|
|
1322
1418
|
placeholder: i.placeholder,
|
|
1323
1419
|
description: i.help || i.description,
|
|
1324
1420
|
validation: l(i),
|
|
@@ -1330,110 +1426,116 @@ var pe = {
|
|
|
1330
1426
|
}
|
|
1331
1427
|
i.type === "email" && (a.inputType = "email"), i.type === "phone" && (a.inputType = "tel"), i.type === "url" && (a.inputType = "url"), i.type === "password" && (a.inputType = "password"), i.type === "time" && (a.inputType = "time"), (i.type === "formula" || i.type === "summary" || i.type === "auto_number") && (a.disabled = !0), i.visible_on && (a.visible = (e) => u(i.visible_on, e)), e.push(a);
|
|
1332
1428
|
}
|
|
1333
|
-
}),
|
|
1429
|
+
}), b(e), !D && r.recordId && r.mode !== "create" && i || w(!1);
|
|
1334
1430
|
}, [
|
|
1335
|
-
|
|
1431
|
+
_,
|
|
1336
1432
|
r.fields,
|
|
1337
1433
|
r.customFields,
|
|
1338
1434
|
r.readOnly,
|
|
1339
1435
|
r.mode,
|
|
1340
|
-
|
|
1436
|
+
D,
|
|
1341
1437
|
r.recordId,
|
|
1342
1438
|
i
|
|
1343
1439
|
]);
|
|
1344
|
-
let
|
|
1345
|
-
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 && (t = e, e = {})),
|
|
1440
|
+
let k = t(async (e, t) => {
|
|
1441
|
+
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 && (t = e, e = {})), D && !i) return r.onSuccess && await r.onSuccess(e), e;
|
|
1346
1442
|
if (!i) throw Error("DataSource is required for form submission (inline mode not configured)");
|
|
1443
|
+
let n = e;
|
|
1444
|
+
if (h?.isLoaded && e && typeof e == "object") {
|
|
1445
|
+
n = {};
|
|
1446
|
+
for (let t of Object.keys(e)) h.checkField(r.objectName, t, "write") && (n[t] = e[t]);
|
|
1447
|
+
}
|
|
1347
1448
|
try {
|
|
1348
|
-
let
|
|
1349
|
-
if (r.mode === "create")
|
|
1350
|
-
else if (r.mode === "edit" && r.recordId)
|
|
1449
|
+
let e;
|
|
1450
|
+
if (r.mode === "create") e = await i.create(r.objectName, n);
|
|
1451
|
+
else if (r.mode === "edit" && r.recordId) e = await i.update(r.objectName, r.recordId, n);
|
|
1351
1452
|
else throw Error("Invalid form mode or missing record ID");
|
|
1352
|
-
return r.onSuccess && await r.onSuccess(
|
|
1453
|
+
return r.onSuccess && await r.onSuccess(e), e;
|
|
1353
1454
|
} catch (e) {
|
|
1354
1455
|
throw console.error("Failed to submit form:", e), r.onError && r.onError(e), e;
|
|
1355
1456
|
}
|
|
1356
1457
|
}, [
|
|
1357
1458
|
r,
|
|
1358
1459
|
i,
|
|
1359
|
-
|
|
1360
|
-
|
|
1460
|
+
D,
|
|
1461
|
+
h
|
|
1462
|
+
]), A = t(() => {
|
|
1361
1463
|
r.onCancel && r.onCancel();
|
|
1362
|
-
}, [r]),
|
|
1464
|
+
}, [r]), j = {
|
|
1363
1465
|
...e.useMemo(() => {
|
|
1364
|
-
if (!
|
|
1466
|
+
if (!_?.fields) return {};
|
|
1365
1467
|
let e = {};
|
|
1366
|
-
return Object.keys(
|
|
1367
|
-
let n =
|
|
1468
|
+
return Object.keys(_.fields).forEach((t) => {
|
|
1469
|
+
let n = _.fields[t];
|
|
1368
1470
|
n.defaultValue !== void 0 && (e[t] = n.defaultValue);
|
|
1369
1471
|
}), e;
|
|
1370
|
-
}, [
|
|
1371
|
-
...
|
|
1472
|
+
}, [_]),
|
|
1473
|
+
...x
|
|
1372
1474
|
};
|
|
1373
|
-
if (
|
|
1475
|
+
if (T) return /* @__PURE__ */ G("div", {
|
|
1374
1476
|
className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1375
|
-
children: [/* @__PURE__ */
|
|
1477
|
+
children: [/* @__PURE__ */ W("h3", {
|
|
1376
1478
|
className: "text-red-800 font-semibold",
|
|
1377
1479
|
children: "Error loading form"
|
|
1378
|
-
}), /* @__PURE__ */
|
|
1480
|
+
}), /* @__PURE__ */ W("p", {
|
|
1379
1481
|
className: "text-red-600 text-sm mt-1",
|
|
1380
|
-
children:
|
|
1482
|
+
children: T.message
|
|
1381
1483
|
})]
|
|
1382
1484
|
});
|
|
1383
|
-
if (
|
|
1485
|
+
if (C) return /* @__PURE__ */ G("div", {
|
|
1384
1486
|
className: "p-4 sm:p-8 text-center",
|
|
1385
|
-
children: [/* @__PURE__ */
|
|
1487
|
+
children: [/* @__PURE__ */ W("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ W("p", {
|
|
1386
1488
|
className: "mt-2 text-sm text-gray-600",
|
|
1387
1489
|
children: "Loading form..."
|
|
1388
1490
|
})]
|
|
1389
1491
|
});
|
|
1390
|
-
let
|
|
1391
|
-
if (r.sections?.length && (!r.formType || r.formType === "simple")) return /* @__PURE__ */
|
|
1492
|
+
let M = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : "vertical";
|
|
1493
|
+
if (r.sections?.length && (!r.formType || r.formType === "simple")) return /* @__PURE__ */ W("div", {
|
|
1392
1494
|
className: "w-full space-y-6",
|
|
1393
1495
|
children: r.sections.map((e, t) => {
|
|
1394
|
-
let n = e.fields.map((e) => typeof e == "string" ? e : e.name), i =
|
|
1395
|
-
return /* @__PURE__ */
|
|
1496
|
+
let n = e.fields.map((e) => typeof e == "string" ? e : e.name), i = g(y.filter((e) => n.includes(e.name)));
|
|
1497
|
+
return /* @__PURE__ */ W(K, {
|
|
1396
1498
|
label: e.name ? p(r.objectName, e.name, e.label || e.name) : e.label,
|
|
1397
1499
|
description: e.description,
|
|
1398
1500
|
collapsible: e.collapsible,
|
|
1399
1501
|
collapsed: e.collapsed,
|
|
1400
1502
|
columns: e.columns,
|
|
1401
|
-
children: /* @__PURE__ */
|
|
1503
|
+
children: /* @__PURE__ */ W(s, { schema: {
|
|
1402
1504
|
type: "form",
|
|
1403
1505
|
fields: i,
|
|
1404
|
-
layout:
|
|
1405
|
-
defaultValues:
|
|
1506
|
+
layout: M,
|
|
1507
|
+
defaultValues: j,
|
|
1406
1508
|
showSubmit: t === r.sections.length - 1 && r.showSubmit !== !1 && r.mode !== "view",
|
|
1407
1509
|
showCancel: t === r.sections.length - 1 && r.showCancel !== !1,
|
|
1408
1510
|
submitLabel: r.submitText || (r.mode === "create" ? "Create" : "Update"),
|
|
1409
1511
|
cancelLabel: r.cancelText,
|
|
1410
|
-
onSubmit:
|
|
1411
|
-
onCancel:
|
|
1512
|
+
onSubmit: k,
|
|
1513
|
+
onCancel: A
|
|
1412
1514
|
} })
|
|
1413
1515
|
}, e.name || e.label || t);
|
|
1414
1516
|
})
|
|
1415
1517
|
});
|
|
1416
|
-
let
|
|
1417
|
-
fields:
|
|
1518
|
+
let N = r.sections?.length, P = g(y), F = N ? {
|
|
1519
|
+
fields: P,
|
|
1418
1520
|
columns: r.columns
|
|
1419
|
-
} :
|
|
1521
|
+
} : $(P, _, r.columns, r.mode), I = r.mobile, L = I?.fullscreenLongText ? F.fields.map((e) => {
|
|
1420
1522
|
let t = e.type;
|
|
1421
1523
|
return t === "textarea" || t === "field:textarea" || t === "string-multiline" || t === "field:markdown" || t === "field:html" ? {
|
|
1422
1524
|
...e,
|
|
1423
1525
|
mobile_fullscreen: !0
|
|
1424
1526
|
} : e;
|
|
1425
|
-
}) :
|
|
1426
|
-
if (!r.formType && !
|
|
1427
|
-
let e =
|
|
1428
|
-
for (let n = 0; n < e.length; n +=
|
|
1429
|
-
let r = e.slice(n, n +
|
|
1527
|
+
}) : F.fields, B = I?.stepper, V = I?.stepperMinFields ?? 8, H = Math.max(1, I?.stepperFieldsPerStep ?? 1);
|
|
1528
|
+
if (!r.formType && !N && L.length >= 2 && (B === !0 || B === "auto" && m && L.length >= V)) {
|
|
1529
|
+
let e = L, t = [];
|
|
1530
|
+
for (let n = 0; n < e.length; n += H) {
|
|
1531
|
+
let r = e.slice(n, n + H);
|
|
1430
1532
|
t.push({
|
|
1431
|
-
name: `step-${Math.floor(n /
|
|
1432
|
-
label: r[0]?.label || r[0]?.name || `Step ${Math.floor(n /
|
|
1533
|
+
name: `step-${Math.floor(n / H) + 1}`,
|
|
1534
|
+
label: r[0]?.label || r[0]?.name || `Step ${Math.floor(n / H) + 1}`,
|
|
1433
1535
|
fields: r
|
|
1434
1536
|
});
|
|
1435
1537
|
}
|
|
1436
|
-
return /* @__PURE__ */
|
|
1538
|
+
return /* @__PURE__ */ W(J, {
|
|
1437
1539
|
schema: {
|
|
1438
1540
|
...r,
|
|
1439
1541
|
formType: "wizard",
|
|
@@ -1444,28 +1546,28 @@ var pe = {
|
|
|
1444
1546
|
className: r.className
|
|
1445
1547
|
});
|
|
1446
1548
|
}
|
|
1447
|
-
let
|
|
1549
|
+
let U = {
|
|
1448
1550
|
type: "form",
|
|
1449
|
-
fields:
|
|
1450
|
-
layout:
|
|
1451
|
-
columns:
|
|
1551
|
+
fields: L,
|
|
1552
|
+
layout: M,
|
|
1553
|
+
columns: F.columns,
|
|
1452
1554
|
submitLabel: r.submitText || (r.mode === "create" ? "Create" : "Update"),
|
|
1453
1555
|
cancelLabel: r.cancelText,
|
|
1454
1556
|
showSubmit: r.showSubmit !== !1 && r.mode !== "view",
|
|
1455
1557
|
showCancel: r.showCancel !== !1,
|
|
1456
1558
|
resetOnSubmit: r.showReset,
|
|
1457
|
-
defaultValues:
|
|
1458
|
-
onSubmit:
|
|
1459
|
-
onCancel:
|
|
1559
|
+
defaultValues: j,
|
|
1560
|
+
onSubmit: k,
|
|
1561
|
+
onCancel: A,
|
|
1460
1562
|
className: r.className,
|
|
1461
|
-
mobileStickyActions: !!
|
|
1563
|
+
mobileStickyActions: !!I?.stickyActions
|
|
1462
1564
|
};
|
|
1463
|
-
return /* @__PURE__ */
|
|
1464
|
-
className:
|
|
1465
|
-
"data-mobile-form":
|
|
1466
|
-
children: /* @__PURE__ */
|
|
1565
|
+
return /* @__PURE__ */ W("div", {
|
|
1566
|
+
className: I?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
|
|
1567
|
+
"data-mobile-form": I ? "true" : void 0,
|
|
1568
|
+
children: /* @__PURE__ */ W(s, { schema: U })
|
|
1467
1569
|
});
|
|
1468
|
-
},
|
|
1570
|
+
}, xe = ({ config: e, dataSource: n, prefillParams: r, className: o }) => {
|
|
1469
1571
|
let [s, c] = a(!1), [l, u] = a(!1), [d, f] = a(null), p = i(() => {
|
|
1470
1572
|
let e = {};
|
|
1471
1573
|
if (r) for (let [t, n] of Object.entries(r)) e[t] = n;
|
|
@@ -1494,30 +1596,30 @@ var pe = {
|
|
|
1494
1596
|
}, [e.branding]);
|
|
1495
1597
|
if (s) {
|
|
1496
1598
|
let t = e.thankYouPage;
|
|
1497
|
-
return /* @__PURE__ */
|
|
1599
|
+
return /* @__PURE__ */ W("div", {
|
|
1498
1600
|
className: `min-h-screen flex items-center justify-center p-4 ${o || ""}`,
|
|
1499
1601
|
style: g,
|
|
1500
|
-
children: /* @__PURE__ */
|
|
1602
|
+
children: /* @__PURE__ */ G("div", {
|
|
1501
1603
|
className: "max-w-md w-full bg-card rounded-lg shadow-lg p-8 text-center space-y-4",
|
|
1502
1604
|
children: [
|
|
1503
|
-
/* @__PURE__ */
|
|
1605
|
+
/* @__PURE__ */ W("div", {
|
|
1504
1606
|
className: "text-4xl",
|
|
1505
1607
|
children: "✓"
|
|
1506
1608
|
}),
|
|
1507
|
-
/* @__PURE__ */
|
|
1609
|
+
/* @__PURE__ */ W("h2", {
|
|
1508
1610
|
className: "text-xl font-semibold text-foreground",
|
|
1509
1611
|
children: t?.title || "Thank You!"
|
|
1510
1612
|
}),
|
|
1511
|
-
/* @__PURE__ */
|
|
1613
|
+
/* @__PURE__ */ W("p", {
|
|
1512
1614
|
className: "text-muted-foreground",
|
|
1513
1615
|
children: t?.message || "Your submission has been received successfully."
|
|
1514
1616
|
}),
|
|
1515
|
-
e.allowMultiple && /* @__PURE__ */
|
|
1617
|
+
e.allowMultiple && /* @__PURE__ */ W("button", {
|
|
1516
1618
|
onClick: h,
|
|
1517
1619
|
className: "mt-4 px-4 py-2 text-sm font-medium rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors",
|
|
1518
1620
|
children: "Submit Another Response"
|
|
1519
1621
|
}),
|
|
1520
|
-
t?.redirectUrl && /* @__PURE__ */
|
|
1622
|
+
t?.redirectUrl && /* @__PURE__ */ G("p", {
|
|
1521
1623
|
className: "text-xs text-muted-foreground",
|
|
1522
1624
|
children: [
|
|
1523
1625
|
"Redirecting in ",
|
|
@@ -1529,37 +1631,37 @@ var pe = {
|
|
|
1529
1631
|
})
|
|
1530
1632
|
});
|
|
1531
1633
|
}
|
|
1532
|
-
return /* @__PURE__ */
|
|
1634
|
+
return /* @__PURE__ */ W("div", {
|
|
1533
1635
|
className: `min-h-screen flex items-center justify-center p-4 ${o || ""}`,
|
|
1534
1636
|
style: g,
|
|
1535
|
-
children: /* @__PURE__ */
|
|
1637
|
+
children: /* @__PURE__ */ G("div", {
|
|
1536
1638
|
className: "max-w-2xl w-full bg-card rounded-lg shadow-lg overflow-hidden",
|
|
1537
1639
|
children: [
|
|
1538
|
-
/* @__PURE__ */
|
|
1640
|
+
/* @__PURE__ */ G("div", {
|
|
1539
1641
|
className: "p-6 border-b",
|
|
1540
1642
|
style: e.branding?.primaryColor ? { borderBottomColor: e.branding.primaryColor } : void 0,
|
|
1541
1643
|
children: [
|
|
1542
|
-
e.branding?.logo && /* @__PURE__ */
|
|
1644
|
+
e.branding?.logo && /* @__PURE__ */ W("img", {
|
|
1543
1645
|
src: e.branding.logo,
|
|
1544
1646
|
alt: "Logo",
|
|
1545
1647
|
className: "h-8 mb-4"
|
|
1546
1648
|
}),
|
|
1547
|
-
e.title && /* @__PURE__ */
|
|
1649
|
+
e.title && /* @__PURE__ */ W("h1", {
|
|
1548
1650
|
className: "text-xl font-semibold text-foreground",
|
|
1549
1651
|
children: e.title
|
|
1550
1652
|
}),
|
|
1551
|
-
e.description && /* @__PURE__ */
|
|
1653
|
+
e.description && /* @__PURE__ */ W("p", {
|
|
1552
1654
|
className: "text-sm text-muted-foreground mt-1",
|
|
1553
1655
|
children: e.description
|
|
1554
1656
|
})
|
|
1555
1657
|
]
|
|
1556
1658
|
}),
|
|
1557
|
-
/* @__PURE__ */
|
|
1659
|
+
/* @__PURE__ */ G("div", {
|
|
1558
1660
|
className: "p-6",
|
|
1559
|
-
children: [d && /* @__PURE__ */
|
|
1661
|
+
children: [d && /* @__PURE__ */ W("div", {
|
|
1560
1662
|
className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
|
|
1561
1663
|
children: d
|
|
1562
|
-
}), /* @__PURE__ */
|
|
1664
|
+
}), /* @__PURE__ */ W(ye, {
|
|
1563
1665
|
schema: {
|
|
1564
1666
|
type: "object-form",
|
|
1565
1667
|
objectName: e.objectName,
|
|
@@ -1573,9 +1675,9 @@ var pe = {
|
|
|
1573
1675
|
dataSource: n
|
|
1574
1676
|
})]
|
|
1575
1677
|
}),
|
|
1576
|
-
/* @__PURE__ */
|
|
1678
|
+
/* @__PURE__ */ W("div", {
|
|
1577
1679
|
className: "px-6 py-3 border-t bg-muted/20 text-center",
|
|
1578
|
-
children: /* @__PURE__ */
|
|
1680
|
+
children: /* @__PURE__ */ W("p", {
|
|
1579
1681
|
className: "text-xs text-muted-foreground",
|
|
1580
1682
|
children: "Powered by ObjectStack"
|
|
1581
1683
|
})
|
|
@@ -1586,96 +1688,96 @@ var pe = {
|
|
|
1586
1688
|
};
|
|
1587
1689
|
//#endregion
|
|
1588
1690
|
//#region src/FormAnalytics.tsx
|
|
1589
|
-
function
|
|
1691
|
+
function Se(e) {
|
|
1590
1692
|
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`;
|
|
1591
1693
|
}
|
|
1592
|
-
var
|
|
1694
|
+
var Ce = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
1593
1695
|
let a = i(() => {
|
|
1594
1696
|
if (!n.abandonedSubmissions) return 100;
|
|
1595
1697
|
let e = n.totalSubmissions + n.abandonedSubmissions;
|
|
1596
1698
|
return e === 0 ? 0 : Math.round(n.totalSubmissions / e * 100);
|
|
1597
1699
|
}, [n.totalSubmissions, n.abandonedSubmissions]), o = i(() => n.dailySubmissions?.length ? Math.max(...n.dailySubmissions.map((e) => e.count), 1) : 1, [n.dailySubmissions]);
|
|
1598
|
-
return /* @__PURE__ */
|
|
1700
|
+
return /* @__PURE__ */ G("div", {
|
|
1599
1701
|
className: `space-y-4 ${r || ""}`,
|
|
1600
1702
|
children: [
|
|
1601
|
-
/* @__PURE__ */
|
|
1703
|
+
/* @__PURE__ */ G("div", { children: [/* @__PURE__ */ W("h2", {
|
|
1602
1704
|
className: "text-lg font-semibold text-foreground",
|
|
1603
1705
|
children: t || "Form Analytics"
|
|
1604
|
-
}), /* @__PURE__ */
|
|
1706
|
+
}), /* @__PURE__ */ G("p", {
|
|
1605
1707
|
className: "text-sm text-muted-foreground",
|
|
1606
1708
|
children: ["Form ID: ", e]
|
|
1607
1709
|
})] }),
|
|
1608
|
-
/* @__PURE__ */
|
|
1710
|
+
/* @__PURE__ */ G("div", {
|
|
1609
1711
|
className: "grid grid-cols-1 sm:grid-cols-3 gap-4",
|
|
1610
1712
|
children: [
|
|
1611
|
-
/* @__PURE__ */
|
|
1713
|
+
/* @__PURE__ */ W(m, { children: /* @__PURE__ */ G(_, {
|
|
1612
1714
|
className: "pb-2",
|
|
1613
|
-
children: [/* @__PURE__ */
|
|
1715
|
+
children: [/* @__PURE__ */ W(g, { children: "Total Submissions" }), /* @__PURE__ */ W(v, {
|
|
1614
1716
|
className: "text-2xl",
|
|
1615
1717
|
children: n.totalSubmissions.toLocaleString()
|
|
1616
1718
|
})]
|
|
1617
1719
|
}) }),
|
|
1618
|
-
/* @__PURE__ */
|
|
1720
|
+
/* @__PURE__ */ G(m, { children: [/* @__PURE__ */ G(_, {
|
|
1619
1721
|
className: "pb-2",
|
|
1620
|
-
children: [/* @__PURE__ */
|
|
1722
|
+
children: [/* @__PURE__ */ W(g, { children: "Fill Rate" }), /* @__PURE__ */ G(v, {
|
|
1621
1723
|
className: "text-2xl",
|
|
1622
1724
|
children: [a, "%"]
|
|
1623
1725
|
})]
|
|
1624
|
-
}), /* @__PURE__ */
|
|
1726
|
+
}), /* @__PURE__ */ W(h, { children: /* @__PURE__ */ W("div", {
|
|
1625
1727
|
className: "w-full bg-muted rounded-full h-2",
|
|
1626
|
-
children: /* @__PURE__ */
|
|
1728
|
+
children: /* @__PURE__ */ W("div", {
|
|
1627
1729
|
className: "bg-primary rounded-full h-2 transition-all",
|
|
1628
1730
|
style: { width: `${a}%` }
|
|
1629
1731
|
})
|
|
1630
1732
|
}) })] }),
|
|
1631
|
-
/* @__PURE__ */
|
|
1733
|
+
/* @__PURE__ */ W(m, { children: /* @__PURE__ */ G(_, {
|
|
1632
1734
|
className: "pb-2",
|
|
1633
|
-
children: [/* @__PURE__ */
|
|
1735
|
+
children: [/* @__PURE__ */ W(g, { children: "Avg. Completion Time" }), /* @__PURE__ */ W(v, {
|
|
1634
1736
|
className: "text-2xl",
|
|
1635
|
-
children: n.avgCompletionTime ?
|
|
1737
|
+
children: n.avgCompletionTime ? Se(n.avgCompletionTime) : "—"
|
|
1636
1738
|
})]
|
|
1637
1739
|
}) })
|
|
1638
1740
|
]
|
|
1639
1741
|
}),
|
|
1640
|
-
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */
|
|
1742
|
+
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ G(m, { children: [/* @__PURE__ */ W(_, { children: /* @__PURE__ */ W(v, {
|
|
1641
1743
|
className: "text-sm font-medium",
|
|
1642
1744
|
children: "Daily Submissions"
|
|
1643
|
-
}) }), /* @__PURE__ */
|
|
1745
|
+
}) }), /* @__PURE__ */ W(h, { children: /* @__PURE__ */ W("div", {
|
|
1644
1746
|
className: "flex items-end gap-1 h-32",
|
|
1645
|
-
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */
|
|
1747
|
+
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ G("div", {
|
|
1646
1748
|
className: "flex-1 flex flex-col items-center gap-1",
|
|
1647
|
-
children: [/* @__PURE__ */
|
|
1749
|
+
children: [/* @__PURE__ */ W("div", {
|
|
1648
1750
|
className: "w-full bg-primary/80 rounded-t transition-all hover:bg-primary",
|
|
1649
1751
|
style: {
|
|
1650
1752
|
height: `${e.count / o * 100}%`,
|
|
1651
1753
|
minHeight: e.count > 0 ? "4px" : "0"
|
|
1652
1754
|
},
|
|
1653
1755
|
title: `${e.date}: ${e.count} submissions`
|
|
1654
|
-
}), /* @__PURE__ */
|
|
1756
|
+
}), /* @__PURE__ */ W("span", {
|
|
1655
1757
|
className: "text-[10px] text-muted-foreground truncate w-full text-center",
|
|
1656
1758
|
children: e.date.slice(-5)
|
|
1657
1759
|
})]
|
|
1658
1760
|
}, t))
|
|
1659
1761
|
}) })] }),
|
|
1660
|
-
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */
|
|
1762
|
+
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ G(m, { children: [/* @__PURE__ */ G(_, { children: [/* @__PURE__ */ W(v, {
|
|
1661
1763
|
className: "text-sm font-medium",
|
|
1662
1764
|
children: "Field Completion Rates"
|
|
1663
|
-
}), /* @__PURE__ */
|
|
1765
|
+
}), /* @__PURE__ */ W(g, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ W(h, { children: /* @__PURE__ */ W("div", {
|
|
1664
1766
|
className: "space-y-3",
|
|
1665
|
-
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */
|
|
1767
|
+
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ G("div", {
|
|
1666
1768
|
className: "space-y-1",
|
|
1667
|
-
children: [/* @__PURE__ */
|
|
1769
|
+
children: [/* @__PURE__ */ G("div", {
|
|
1668
1770
|
className: "flex justify-between text-sm",
|
|
1669
|
-
children: [/* @__PURE__ */
|
|
1771
|
+
children: [/* @__PURE__ */ W("span", {
|
|
1670
1772
|
className: "text-foreground",
|
|
1671
1773
|
children: e.label
|
|
1672
|
-
}), /* @__PURE__ */
|
|
1774
|
+
}), /* @__PURE__ */ G("span", {
|
|
1673
1775
|
className: "text-muted-foreground",
|
|
1674
1776
|
children: [e.completionRate, "%"]
|
|
1675
1777
|
})]
|
|
1676
|
-
}), /* @__PURE__ */
|
|
1778
|
+
}), /* @__PURE__ */ W("div", {
|
|
1677
1779
|
className: "w-full bg-muted rounded-full h-1.5",
|
|
1678
|
-
children: /* @__PURE__ */
|
|
1780
|
+
children: /* @__PURE__ */ W("div", {
|
|
1679
1781
|
className: `rounded-full h-1.5 transition-all ${e.completionRate >= 80 ? "bg-green-500" : e.completionRate >= 50 ? "bg-yellow-500" : "bg-destructive"}`,
|
|
1680
1782
|
style: { width: `${e.completionRate}%` }
|
|
1681
1783
|
})
|
|
@@ -1684,8 +1786,8 @@ var be = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
1684
1786
|
}) })] })
|
|
1685
1787
|
]
|
|
1686
1788
|
});
|
|
1687
|
-
},
|
|
1688
|
-
o.register("object-form",
|
|
1789
|
+
}, we = ({ schema: e }) => /* @__PURE__ */ W(ye, { schema: e });
|
|
1790
|
+
o.register("object-form", we, {
|
|
1689
1791
|
namespace: "plugin-form",
|
|
1690
1792
|
label: "Object Form",
|
|
1691
1793
|
category: "plugin",
|
|
@@ -1826,7 +1928,7 @@ o.register("object-form", xe, {
|
|
|
1826
1928
|
]
|
|
1827
1929
|
}
|
|
1828
1930
|
]
|
|
1829
|
-
}), o.register("form",
|
|
1931
|
+
}), o.register("form", we, {
|
|
1830
1932
|
namespace: "view",
|
|
1831
1933
|
skipFallback: !0,
|
|
1832
1934
|
label: "Data Form View",
|
|
@@ -1854,7 +1956,7 @@ o.register("object-form", xe, {
|
|
|
1854
1956
|
]
|
|
1855
1957
|
}
|
|
1856
1958
|
]
|
|
1857
|
-
}), o.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */
|
|
1959
|
+
}), o.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */ W(xe, { config: e }), {
|
|
1858
1960
|
namespace: "plugin-form",
|
|
1859
1961
|
label: "Embeddable Form",
|
|
1860
1962
|
category: "plugin",
|
|
@@ -1892,7 +1994,7 @@ o.register("object-form", xe, {
|
|
|
1892
1994
|
label: "Allow Multiple Submissions"
|
|
1893
1995
|
}
|
|
1894
1996
|
]
|
|
1895
|
-
}), o.register("form-analytics", ({ schema: e }) => /* @__PURE__ */
|
|
1997
|
+
}), o.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ W(Ce, {
|
|
1896
1998
|
formId: e.formId,
|
|
1897
1999
|
formTitle: e.formTitle,
|
|
1898
2000
|
metrics: e.metrics || { totalSubmissions: 0 }
|
|
@@ -1920,4 +2022,4 @@ o.register("object-form", xe, {
|
|
|
1920
2022
|
]
|
|
1921
2023
|
});
|
|
1922
2024
|
//#endregion
|
|
1923
|
-
export {
|
|
2025
|
+
export { he as DrawerForm, xe as EmbeddableForm, Ce as FormAnalytics, K as FormSection, ve as ModalForm, ye as ObjectForm, Y as SplitForm, q as TabbedForm, J as WizardForm, ae as applyAutoColSpan, $ as applyAutoLayout, le as filterAutoGeneratedFields, ce as filterCreateModeFields, se as filterSystemFields, ie as inferColumns, ue as inferModalSize, re as isAutoGeneratedFieldType, Q as isWideFieldType };
|