@object-ui/plugin-form 3.3.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/dist/index.js +310 -280
- package/dist/index.umd.cjs +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import e, { useCallback as t, useEffect as n, useId as r, useMemo as i, useState
|
|
|
2
2
|
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
|
-
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 } from "@object-ui/components";
|
|
6
|
-
import { Check as
|
|
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 { Check as z, ChevronDown as ee, ChevronLeft as B, ChevronRight as V, Loader2 as te } from "lucide-react";
|
|
7
7
|
//#region \0rolldown/runtime.js
|
|
8
8
|
var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), U = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
9
9
|
if (typeof require < "u") return require.apply(this, arguments);
|
|
@@ -23,7 +23,7 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
26
|
-
})),
|
|
26
|
+
})), ne = /* @__PURE__ */ H(((e) => {
|
|
27
27
|
process.env.NODE_ENV !== "production" && (function() {
|
|
28
28
|
function t(e) {
|
|
29
29
|
if (e == null) return null;
|
|
@@ -181,33 +181,33 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
181
181
|
return d(e, t, n, !0, r ? Error("react-stack-top-frame") : F, r ? M(i(e)) : I);
|
|
182
182
|
};
|
|
183
183
|
})();
|
|
184
|
-
})),
|
|
185
|
-
process.env.NODE_ENV === "production" ? t.exports = W() : t.exports =
|
|
186
|
-
})))(),
|
|
184
|
+
})), G = (/* @__PURE__ */ H(((e, t) => {
|
|
185
|
+
process.env.NODE_ENV === "production" ? t.exports = W() : t.exports = ne();
|
|
186
|
+
})))(), K = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: o, className: s, gridClassName: c }) => {
|
|
187
187
|
let [l, u] = a(r);
|
|
188
|
-
return /* @__PURE__ */ (0,
|
|
188
|
+
return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
189
189
|
className: L("form-section", s),
|
|
190
|
-
children: [(e || t) && /* @__PURE__ */ (0,
|
|
190
|
+
children: [(e || t) && /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
191
191
|
className: L("flex items-start gap-2 mb-4", n && "cursor-pointer select-none"),
|
|
192
192
|
onClick: () => {
|
|
193
193
|
n && u(!l);
|
|
194
194
|
},
|
|
195
195
|
role: n ? "button" : void 0,
|
|
196
196
|
"aria-expanded": n ? !l : void 0,
|
|
197
|
-
children: [n && /* @__PURE__ */ (0,
|
|
197
|
+
children: [n && /* @__PURE__ */ (0, G.jsx)("span", {
|
|
198
198
|
className: "mt-0.5 text-muted-foreground",
|
|
199
|
-
children: l ? /* @__PURE__ */ (0,
|
|
200
|
-
}), /* @__PURE__ */ (0,
|
|
199
|
+
children: l ? /* @__PURE__ */ (0, G.jsx)(V, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, G.jsx)(ee, { className: "h-4 w-4" })
|
|
200
|
+
}), /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
201
201
|
className: "flex-1",
|
|
202
|
-
children: [e && /* @__PURE__ */ (0,
|
|
202
|
+
children: [e && /* @__PURE__ */ (0, G.jsx)("h3", {
|
|
203
203
|
className: "text-base font-semibold text-foreground",
|
|
204
204
|
children: e
|
|
205
|
-
}), t && /* @__PURE__ */ (0,
|
|
205
|
+
}), t && /* @__PURE__ */ (0, G.jsx)("p", {
|
|
206
206
|
className: "text-sm text-muted-foreground mt-0.5",
|
|
207
207
|
children: t
|
|
208
208
|
})]
|
|
209
209
|
})]
|
|
210
|
-
}), !l && /* @__PURE__ */ (0,
|
|
210
|
+
}), !l && /* @__PURE__ */ (0, G.jsx)("div", {
|
|
211
211
|
className: L("grid gap-4", c || {
|
|
212
212
|
1: "grid-cols-1",
|
|
213
213
|
2: "grid-cols-1 md:grid-cols-2",
|
|
@@ -217,7 +217,7 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
217
217
|
children: o
|
|
218
218
|
})]
|
|
219
219
|
});
|
|
220
|
-
},
|
|
220
|
+
}, q = ({ schema: n, dataSource: r, className: i }) => {
|
|
221
221
|
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");
|
|
222
222
|
e.useEffect(() => {
|
|
223
223
|
(async () => {
|
|
@@ -296,19 +296,19 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
296
296
|
}, [n, r]), C = t(() => {
|
|
297
297
|
n.onCancel && n.onCancel();
|
|
298
298
|
}, [n]), w = (e, t) => e.name || e.label || `tab-${t}`;
|
|
299
|
-
if (_) return /* @__PURE__ */ (0,
|
|
299
|
+
if (_) return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
300
300
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
301
|
-
children: [/* @__PURE__ */ (0,
|
|
301
|
+
children: [/* @__PURE__ */ (0, G.jsx)("h3", {
|
|
302
302
|
className: "text-red-800 font-semibold",
|
|
303
303
|
children: "Error loading form"
|
|
304
|
-
}), /* @__PURE__ */ (0,
|
|
304
|
+
}), /* @__PURE__ */ (0, G.jsx)("p", {
|
|
305
305
|
className: "text-red-600 text-sm mt-1",
|
|
306
306
|
children: _.message
|
|
307
307
|
})]
|
|
308
308
|
});
|
|
309
|
-
if (h) return /* @__PURE__ */ (0,
|
|
309
|
+
if (h) return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
310
310
|
className: "p-8 text-center",
|
|
311
|
-
children: [/* @__PURE__ */ (0,
|
|
311
|
+
children: [/* @__PURE__ */ (0, G.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, G.jsx)("p", {
|
|
312
312
|
className: "mt-2 text-sm text-gray-600",
|
|
313
313
|
children: "Loading form..."
|
|
314
314
|
})]
|
|
@@ -325,29 +325,29 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
325
325
|
onSubmit: S,
|
|
326
326
|
onCancel: C
|
|
327
327
|
}, E = n.tabPosition === "left" || n.tabPosition === "right";
|
|
328
|
-
return /* @__PURE__ */ (0,
|
|
328
|
+
return /* @__PURE__ */ (0, G.jsx)("div", {
|
|
329
329
|
className: L("w-full", i, n.className),
|
|
330
|
-
children: /* @__PURE__ */ (0,
|
|
330
|
+
children: /* @__PURE__ */ (0, G.jsxs)(N, {
|
|
331
331
|
value: y,
|
|
332
332
|
onValueChange: b,
|
|
333
333
|
orientation: E ? "vertical" : "horizontal",
|
|
334
334
|
className: L(E && "flex gap-4"),
|
|
335
|
-
children: [/* @__PURE__ */ (0,
|
|
335
|
+
children: [/* @__PURE__ */ (0, G.jsx)(F, {
|
|
336
336
|
className: L(E ? "flex-col h-auto" : "", n.tabPosition === "bottom" && "order-last", n.tabPosition === "right" && "order-last"),
|
|
337
|
-
children: n.sections.map((e, t) => /* @__PURE__ */ (0,
|
|
337
|
+
children: n.sections.map((e, t) => /* @__PURE__ */ (0, G.jsx)(I, {
|
|
338
338
|
value: w(e, t),
|
|
339
339
|
className: E ? "w-full justify-start" : "",
|
|
340
340
|
children: e.label || `Tab ${t + 1}`
|
|
341
341
|
}, w(e, t)))
|
|
342
|
-
}), /* @__PURE__ */ (0,
|
|
342
|
+
}), /* @__PURE__ */ (0, G.jsx)("div", {
|
|
343
343
|
className: "flex-1",
|
|
344
|
-
children: n.sections.map((e, t) => /* @__PURE__ */ (0,
|
|
344
|
+
children: n.sections.map((e, t) => /* @__PURE__ */ (0, G.jsx)(P, {
|
|
345
345
|
value: w(e, t),
|
|
346
346
|
className: "mt-0",
|
|
347
|
-
children: /* @__PURE__ */ (0,
|
|
347
|
+
children: /* @__PURE__ */ (0, G.jsx)(K, {
|
|
348
348
|
description: e.description,
|
|
349
349
|
columns: e.columns || 1,
|
|
350
|
-
children: /* @__PURE__ */ (0,
|
|
350
|
+
children: /* @__PURE__ */ (0, G.jsx)(s, { schema: {
|
|
351
351
|
...T,
|
|
352
352
|
fields: x(e),
|
|
353
353
|
showSubmit: n.showSubmit !== !1 && n.mode !== "view",
|
|
@@ -358,7 +358,7 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
358
358
|
})]
|
|
359
359
|
})
|
|
360
360
|
});
|
|
361
|
-
},
|
|
361
|
+
}, J = ({ schema: n, dataSource: r, className: o }) => {
|
|
362
362
|
let { fieldLabel: u } = c(), [d, m] = a(null), [h, g] = a({}), [_, v] = a(!0), [y, b] = a(null), [x, S] = a(0), [C, w] = a(/* @__PURE__ */ new Set()), [T, E] = a(!1), D = n.sections.length, O = x === 0, k = x === D - 1;
|
|
363
363
|
e.useEffect(() => {
|
|
364
364
|
(async () => {
|
|
@@ -468,51 +468,51 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
468
468
|
x,
|
|
469
469
|
N
|
|
470
470
|
]);
|
|
471
|
-
if (y) return /* @__PURE__ */ (0,
|
|
471
|
+
if (y) return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
472
472
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
473
|
-
children: [/* @__PURE__ */ (0,
|
|
473
|
+
children: [/* @__PURE__ */ (0, G.jsx)("h3", {
|
|
474
474
|
className: "text-red-800 font-semibold",
|
|
475
475
|
children: "Error loading form"
|
|
476
|
-
}), /* @__PURE__ */ (0,
|
|
476
|
+
}), /* @__PURE__ */ (0, G.jsx)("p", {
|
|
477
477
|
className: "text-red-600 text-sm mt-1",
|
|
478
478
|
children: y.message
|
|
479
479
|
})]
|
|
480
480
|
});
|
|
481
|
-
if (_) return /* @__PURE__ */ (0,
|
|
481
|
+
if (_) return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
482
482
|
className: "p-8 text-center",
|
|
483
|
-
children: [/* @__PURE__ */ (0,
|
|
483
|
+
children: [/* @__PURE__ */ (0, G.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, G.jsx)("p", {
|
|
484
484
|
className: "mt-2 text-sm text-gray-600",
|
|
485
485
|
children: "Loading form..."
|
|
486
486
|
})]
|
|
487
487
|
});
|
|
488
|
-
let
|
|
489
|
-
return /* @__PURE__ */ (0,
|
|
488
|
+
let R = n.sections[x];
|
|
489
|
+
return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
490
490
|
className: L("w-full", o, n.className),
|
|
491
491
|
children: [
|
|
492
|
-
n.showStepIndicator !== !1 && /* @__PURE__ */ (0,
|
|
492
|
+
n.showStepIndicator !== !1 && /* @__PURE__ */ (0, G.jsx)("nav", {
|
|
493
493
|
"aria-label": "Progress",
|
|
494
494
|
className: "mb-8",
|
|
495
|
-
children: /* @__PURE__ */ (0,
|
|
495
|
+
children: /* @__PURE__ */ (0, G.jsx)("ol", {
|
|
496
496
|
className: "flex items-center",
|
|
497
497
|
children: n.sections.map((e, t) => {
|
|
498
498
|
let r = t === x, i = C.has(t), a = n.allowSkip || i || t <= x;
|
|
499
|
-
return /* @__PURE__ */ (0,
|
|
499
|
+
return /* @__PURE__ */ (0, G.jsxs)("li", {
|
|
500
500
|
className: L("relative flex-1", t !== D - 1 && "pr-8 sm:pr-12"),
|
|
501
|
-
children: [t !== D - 1 && /* @__PURE__ */ (0,
|
|
501
|
+
children: [t !== D - 1 && /* @__PURE__ */ (0, G.jsx)("div", {
|
|
502
502
|
className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
|
|
503
503
|
"aria-hidden": "true",
|
|
504
|
-
children: /* @__PURE__ */ (0,
|
|
505
|
-
}), /* @__PURE__ */ (0,
|
|
504
|
+
children: /* @__PURE__ */ (0, G.jsx)("div", { className: L("h-full", i ? "bg-primary" : "bg-muted") })
|
|
505
|
+
}), /* @__PURE__ */ (0, G.jsxs)("button", {
|
|
506
506
|
type: "button",
|
|
507
507
|
className: L("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
|
|
508
508
|
onClick: () => I(t),
|
|
509
509
|
disabled: !a,
|
|
510
|
-
children: [/* @__PURE__ */ (0,
|
|
510
|
+
children: [/* @__PURE__ */ (0, G.jsx)("span", {
|
|
511
511
|
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"),
|
|
512
|
-
children: i ? /* @__PURE__ */ (0,
|
|
513
|
-
}), /* @__PURE__ */ (0,
|
|
512
|
+
children: i ? /* @__PURE__ */ (0, G.jsx)(z, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : t + 1
|
|
513
|
+
}), /* @__PURE__ */ (0, G.jsx)("span", {
|
|
514
514
|
className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block",
|
|
515
|
-
children: /* @__PURE__ */ (0,
|
|
515
|
+
children: /* @__PURE__ */ (0, G.jsx)("span", {
|
|
516
516
|
className: L(r ? "text-foreground" : "text-muted-foreground"),
|
|
517
517
|
children: e.label || `Step ${t + 1}`
|
|
518
518
|
})
|
|
@@ -522,13 +522,13 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
522
522
|
})
|
|
523
523
|
})
|
|
524
524
|
}),
|
|
525
|
-
/* @__PURE__ */ (0,
|
|
525
|
+
/* @__PURE__ */ (0, G.jsx)("div", {
|
|
526
526
|
className: "min-h-[200px]",
|
|
527
|
-
children:
|
|
528
|
-
label:
|
|
529
|
-
description:
|
|
530
|
-
columns:
|
|
531
|
-
children: j.length > 0 ? /* @__PURE__ */ (0,
|
|
527
|
+
children: R && /* @__PURE__ */ (0, G.jsx)(K, {
|
|
528
|
+
label: R.label,
|
|
529
|
+
description: R.description,
|
|
530
|
+
columns: R.columns || 1,
|
|
531
|
+
children: j.length > 0 ? /* @__PURE__ */ (0, G.jsx)(s, { schema: {
|
|
532
532
|
type: "form",
|
|
533
533
|
fields: j,
|
|
534
534
|
layout: "vertical",
|
|
@@ -536,22 +536,22 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
536
536
|
showSubmit: !1,
|
|
537
537
|
showCancel: !1,
|
|
538
538
|
onSubmit: M
|
|
539
|
-
} }) : /* @__PURE__ */ (0,
|
|
539
|
+
} }) : /* @__PURE__ */ (0, G.jsx)("div", {
|
|
540
540
|
className: "text-center py-8 text-muted-foreground",
|
|
541
541
|
children: "No fields configured for this step"
|
|
542
542
|
})
|
|
543
543
|
})
|
|
544
544
|
}),
|
|
545
|
-
/* @__PURE__ */ (0,
|
|
545
|
+
/* @__PURE__ */ (0, G.jsxs)("div", {
|
|
546
546
|
className: "flex items-center justify-between mt-6 pt-4 border-t",
|
|
547
|
-
children: [/* @__PURE__ */ (0,
|
|
547
|
+
children: [/* @__PURE__ */ (0, G.jsx)("div", { children: n.showCancel !== !1 && /* @__PURE__ */ (0, G.jsx)(p, {
|
|
548
548
|
variant: "ghost",
|
|
549
549
|
onClick: F,
|
|
550
550
|
children: n.cancelText || "Cancel"
|
|
551
|
-
}) }), /* @__PURE__ */ (0,
|
|
551
|
+
}) }), /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
552
552
|
className: "flex items-center gap-2",
|
|
553
553
|
children: [
|
|
554
|
-
/* @__PURE__ */ (0,
|
|
554
|
+
/* @__PURE__ */ (0, G.jsxs)("span", {
|
|
555
555
|
className: "text-sm text-muted-foreground mr-2",
|
|
556
556
|
children: [
|
|
557
557
|
"Step ",
|
|
@@ -560,25 +560,25 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
560
560
|
D
|
|
561
561
|
]
|
|
562
562
|
}),
|
|
563
|
-
!O && /* @__PURE__ */ (0,
|
|
563
|
+
!O && /* @__PURE__ */ (0, G.jsxs)(p, {
|
|
564
564
|
variant: "outline",
|
|
565
565
|
onClick: P,
|
|
566
|
-
children: [/* @__PURE__ */ (0,
|
|
566
|
+
children: [/* @__PURE__ */ (0, G.jsx)(B, { className: "h-4 w-4 mr-1" }), n.prevText || "Back"]
|
|
567
567
|
}),
|
|
568
|
-
k ? /* @__PURE__ */ (0,
|
|
568
|
+
k ? /* @__PURE__ */ (0, G.jsx)(p, {
|
|
569
569
|
onClick: () => M(h),
|
|
570
570
|
disabled: T || n.mode === "view",
|
|
571
571
|
children: T ? "Submitting..." : n.submitText || (n.mode === "create" ? "Create" : "Update")
|
|
572
|
-
}) : /* @__PURE__ */ (0,
|
|
572
|
+
}) : /* @__PURE__ */ (0, G.jsxs)(p, {
|
|
573
573
|
onClick: () => M(h),
|
|
574
|
-
children: [n.nextText || "Next", /* @__PURE__ */ (0,
|
|
574
|
+
children: [n.nextText || "Next", /* @__PURE__ */ (0, G.jsx)(V, { className: "h-4 w-4 ml-1" })]
|
|
575
575
|
})
|
|
576
576
|
]
|
|
577
577
|
})]
|
|
578
578
|
})
|
|
579
579
|
]
|
|
580
580
|
});
|
|
581
|
-
},
|
|
581
|
+
}, re = ({ schema: e, dataSource: r, className: o }) => {
|
|
582
582
|
let { fieldLabel: u } = c(), [d, p] = a(null), [m, h] = a({}), [g, _] = a(!0), [v, y] = a(null);
|
|
583
583
|
n(() => {
|
|
584
584
|
(async () => {
|
|
@@ -663,19 +663,19 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
663
663
|
}, [e]), C = i(() => e.sections.slice(0, 1), [e.sections]), D = i(() => e.sections.slice(1), [e.sections]);
|
|
664
664
|
i(() => e.sections.flatMap((e) => b(e)), [e.sections, b]);
|
|
665
665
|
let O = e.splitDirection || "horizontal", k = e.splitSize || 50;
|
|
666
|
-
if (v) return /* @__PURE__ */ (0,
|
|
666
|
+
if (v) return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
667
667
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
668
|
-
children: [/* @__PURE__ */ (0,
|
|
668
|
+
children: [/* @__PURE__ */ (0, G.jsx)("h3", {
|
|
669
669
|
className: "text-red-800 font-semibold",
|
|
670
670
|
children: "Error loading form"
|
|
671
|
-
}), /* @__PURE__ */ (0,
|
|
671
|
+
}), /* @__PURE__ */ (0, G.jsx)("p", {
|
|
672
672
|
className: "text-red-600 text-sm mt-1",
|
|
673
673
|
children: v.message
|
|
674
674
|
})]
|
|
675
675
|
});
|
|
676
|
-
if (g) return /* @__PURE__ */ (0,
|
|
676
|
+
if (g) return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
677
677
|
className: "p-8 text-center",
|
|
678
|
-
children: [/* @__PURE__ */ (0,
|
|
678
|
+
children: [/* @__PURE__ */ (0, G.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, G.jsx)("p", {
|
|
679
679
|
className: "mt-2 text-sm text-gray-600",
|
|
680
680
|
children: "Loading form..."
|
|
681
681
|
})]
|
|
@@ -686,13 +686,13 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
686
686
|
defaultValues: m,
|
|
687
687
|
onSubmit: x,
|
|
688
688
|
onCancel: S
|
|
689
|
-
}, j = (t, n) => /* @__PURE__ */ (0,
|
|
689
|
+
}, j = (t, n) => /* @__PURE__ */ (0, G.jsx)("div", {
|
|
690
690
|
className: "space-y-4 p-4",
|
|
691
|
-
children: t.map((t, r) => /* @__PURE__ */ (0,
|
|
691
|
+
children: t.map((t, r) => /* @__PURE__ */ (0, G.jsx)(K, {
|
|
692
692
|
label: t.label,
|
|
693
693
|
description: t.description,
|
|
694
694
|
columns: t.columns || 1,
|
|
695
|
-
children: /* @__PURE__ */ (0,
|
|
695
|
+
children: /* @__PURE__ */ (0, G.jsx)(s, { schema: {
|
|
696
696
|
...A,
|
|
697
697
|
fields: b(t),
|
|
698
698
|
showSubmit: n && e.showSubmit !== !1 && e.mode !== "view",
|
|
@@ -702,29 +702,29 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
702
702
|
} })
|
|
703
703
|
}, t.name || t.label || r))
|
|
704
704
|
});
|
|
705
|
-
return /* @__PURE__ */ (0,
|
|
705
|
+
return /* @__PURE__ */ (0, G.jsx)("div", {
|
|
706
706
|
className: L("w-full", o, e.className),
|
|
707
|
-
children: /* @__PURE__ */ (0,
|
|
707
|
+
children: /* @__PURE__ */ (0, G.jsxs)(E, {
|
|
708
708
|
orientation: O,
|
|
709
709
|
className: "min-h-[300px] rounded-lg border",
|
|
710
|
-
children: [/* @__PURE__ */ (0,
|
|
710
|
+
children: [/* @__PURE__ */ (0, G.jsx)(T, {
|
|
711
711
|
defaultSize: k,
|
|
712
712
|
minSize: 20,
|
|
713
713
|
children: j(C, D.length === 0)
|
|
714
|
-
}), D.length > 0 && /* @__PURE__ */ (0,
|
|
714
|
+
}), D.length > 0 && /* @__PURE__ */ (0, G.jsxs)(G.Fragment, { children: [/* @__PURE__ */ (0, G.jsx)(w, { withHandle: e.splitResizable !== !1 }), /* @__PURE__ */ (0, G.jsx)(T, {
|
|
715
715
|
defaultSize: 100 - k,
|
|
716
716
|
minSize: 20,
|
|
717
717
|
children: j(D, !0)
|
|
718
718
|
})] })]
|
|
719
719
|
})
|
|
720
720
|
});
|
|
721
|
-
},
|
|
721
|
+
}, ie = new Set([
|
|
722
722
|
"field:formula",
|
|
723
723
|
"field:summary",
|
|
724
724
|
"field:auto_number",
|
|
725
725
|
"field:autonumber",
|
|
726
726
|
"field:master_detail"
|
|
727
|
-
]),
|
|
727
|
+
]), ae = new Set([
|
|
728
728
|
"field:textarea",
|
|
729
729
|
"field:markdown",
|
|
730
730
|
"field:html",
|
|
@@ -735,7 +735,7 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
735
735
|
"html",
|
|
736
736
|
"grid",
|
|
737
737
|
"rich-text"
|
|
738
|
-
]),
|
|
738
|
+
]), oe = new Set([
|
|
739
739
|
"formula",
|
|
740
740
|
"summary",
|
|
741
741
|
"auto_number",
|
|
@@ -743,22 +743,22 @@ var H = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
743
743
|
"master_detail",
|
|
744
744
|
"masterDetail"
|
|
745
745
|
]);
|
|
746
|
-
function
|
|
747
|
-
return
|
|
746
|
+
function se(e) {
|
|
747
|
+
return ae.has(e);
|
|
748
748
|
}
|
|
749
|
-
function
|
|
750
|
-
return
|
|
749
|
+
function ce(e) {
|
|
750
|
+
return oe.has(e);
|
|
751
751
|
}
|
|
752
|
-
function
|
|
752
|
+
function le(e) {
|
|
753
753
|
return e <= 3 ? 1 : 2;
|
|
754
754
|
}
|
|
755
|
-
function
|
|
756
|
-
return t <= 1 ? e : e.map((e) => e.colSpan === void 0 && e.type &&
|
|
755
|
+
function Y(e, t) {
|
|
756
|
+
return t <= 1 ? e : e.map((e) => e.colSpan === void 0 && e.type && se(e.type) ? {
|
|
757
757
|
...e,
|
|
758
758
|
colSpan: t
|
|
759
759
|
} : e);
|
|
760
760
|
}
|
|
761
|
-
var
|
|
761
|
+
var ue = new Set([
|
|
762
762
|
"id",
|
|
763
763
|
"created_at",
|
|
764
764
|
"createdAt",
|
|
@@ -775,37 +775,37 @@ var ce = new Set([
|
|
|
775
775
|
"_version",
|
|
776
776
|
"_rev"
|
|
777
777
|
]);
|
|
778
|
-
function
|
|
778
|
+
function de(e, t) {
|
|
779
779
|
return e.filter((e) => {
|
|
780
|
-
if (
|
|
780
|
+
if (ue.has(e.name) || e.type && ie.has(e.type)) return !1;
|
|
781
781
|
if (!t?.fields) return !0;
|
|
782
782
|
let n = t.fields[e.name];
|
|
783
|
-
return n ? n.readonly === !0 ? !1 : !
|
|
783
|
+
return n ? n.readonly === !0 ? !1 : !ce(n.type) : !0;
|
|
784
784
|
});
|
|
785
785
|
}
|
|
786
|
-
function
|
|
786
|
+
function X(e) {
|
|
787
787
|
return e <= 1 ? "default" : e === 2 ? "xl" : "full";
|
|
788
788
|
}
|
|
789
|
-
function
|
|
789
|
+
function Z(e, t, n, r) {
|
|
790
790
|
let i = [...e];
|
|
791
|
-
if (r === "create" && (i =
|
|
791
|
+
if (r === "create" && (i = de(i, t)), n !== void 0) return i = Y(i, n), {
|
|
792
792
|
fields: i,
|
|
793
793
|
columns: n
|
|
794
794
|
};
|
|
795
|
-
let a =
|
|
796
|
-
return i =
|
|
795
|
+
let a = le(i.length);
|
|
796
|
+
return i = Y(i, a), {
|
|
797
797
|
fields: i,
|
|
798
798
|
columns: a
|
|
799
799
|
};
|
|
800
800
|
}
|
|
801
801
|
//#endregion
|
|
802
802
|
//#region src/DrawerForm.tsx
|
|
803
|
-
var
|
|
803
|
+
var fe = {
|
|
804
804
|
1: void 0,
|
|
805
805
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
806
806
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
807
807
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
808
|
-
},
|
|
808
|
+
}, pe = ({ schema: e, dataSource: r, className: o }) => {
|
|
809
809
|
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(() => {
|
|
810
810
|
let t = {};
|
|
811
811
|
return e.sections?.forEach((e, n) => {
|
|
@@ -953,29 +953,29 @@ var ue = {
|
|
|
953
953
|
onSubmit: M,
|
|
954
954
|
onCancel: N
|
|
955
955
|
};
|
|
956
|
-
return /* @__PURE__ */ (0,
|
|
956
|
+
return /* @__PURE__ */ (0, G.jsx)(D, {
|
|
957
957
|
open: S,
|
|
958
958
|
onOpenChange: e.onOpenChange,
|
|
959
|
-
children: /* @__PURE__ */ (0,
|
|
959
|
+
children: /* @__PURE__ */ (0, G.jsxs)(O, {
|
|
960
960
|
side: C,
|
|
961
961
|
className: L("overflow-y-auto", o, e.className),
|
|
962
962
|
style: P,
|
|
963
|
-
children: [(e.title || e.description) && /* @__PURE__ */ (0,
|
|
963
|
+
children: [(e.title || e.description) && /* @__PURE__ */ (0, G.jsxs)(A, { children: [e.title && /* @__PURE__ */ (0, G.jsx)(j, { children: e.title }), e.description && /* @__PURE__ */ (0, G.jsx)(k, { children: e.description })] }), /* @__PURE__ */ (0, G.jsx)("div", {
|
|
964
964
|
className: "@container py-4",
|
|
965
965
|
children: (() => {
|
|
966
|
-
if (b) return /* @__PURE__ */ (0,
|
|
966
|
+
if (b) return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
967
967
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
968
|
-
children: [/* @__PURE__ */ (0,
|
|
968
|
+
children: [/* @__PURE__ */ (0, G.jsx)("h3", {
|
|
969
969
|
className: "text-red-800 font-semibold",
|
|
970
970
|
children: "Error loading form"
|
|
971
|
-
}), /* @__PURE__ */ (0,
|
|
971
|
+
}), /* @__PURE__ */ (0, G.jsx)("p", {
|
|
972
972
|
className: "text-red-600 text-sm mt-1",
|
|
973
973
|
children: b.message
|
|
974
974
|
})]
|
|
975
975
|
});
|
|
976
|
-
if (v) return /* @__PURE__ */ (0,
|
|
976
|
+
if (v) return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
977
977
|
className: "p-8 text-center",
|
|
978
|
-
children: [/* @__PURE__ */ (0,
|
|
978
|
+
children: [/* @__PURE__ */ (0, G.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, G.jsx)("p", {
|
|
979
979
|
className: "mt-2 text-sm text-gray-600",
|
|
980
980
|
children: "Loading form..."
|
|
981
981
|
})]
|
|
@@ -1001,13 +1001,13 @@ var ue = {
|
|
|
1001
1001
|
...e,
|
|
1002
1002
|
hidden: !0
|
|
1003
1003
|
}))) : t.push(...a);
|
|
1004
|
-
}), /* @__PURE__ */ (0,
|
|
1004
|
+
}), /* @__PURE__ */ (0, G.jsx)(s, { schema: {
|
|
1005
1005
|
...F,
|
|
1006
1006
|
fields: t
|
|
1007
1007
|
} });
|
|
1008
1008
|
}
|
|
1009
|
-
let t =
|
|
1010
|
-
return /* @__PURE__ */ (0,
|
|
1009
|
+
let t = Z(m, d, e.columns, e.mode), n = fe[t.columns || 1];
|
|
1010
|
+
return /* @__PURE__ */ (0, G.jsx)(s, { schema: {
|
|
1011
1011
|
...F,
|
|
1012
1012
|
fields: t.fields,
|
|
1013
1013
|
columns: t.columns,
|
|
@@ -1017,38 +1017,38 @@ var ue = {
|
|
|
1017
1017
|
})]
|
|
1018
1018
|
})
|
|
1019
1019
|
});
|
|
1020
|
-
},
|
|
1020
|
+
}, me = {
|
|
1021
1021
|
sm: "sm:max-w-sm",
|
|
1022
1022
|
default: "sm:max-w-lg",
|
|
1023
1023
|
lg: "sm:max-w-2xl",
|
|
1024
1024
|
xl: "sm:max-w-5xl",
|
|
1025
1025
|
full: "sm:max-w-[95vw] sm:w-full"
|
|
1026
|
-
},
|
|
1026
|
+
}, Q = {
|
|
1027
1027
|
1: void 0,
|
|
1028
1028
|
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
1029
1029
|
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
1030
1030
|
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
1031
|
-
},
|
|
1032
|
-
let { fieldLabel: d } = c(), [m, h] = a(null), [g, _] = a([]), [v, w] = a({}), [T, E] = a(!0), [D, O] = a(null), [k, A] = a(!1), j = e.open !== !1, N = r(), P = i(() => e.sections?.length || e.customFields?.length ? null :
|
|
1031
|
+
}, he = ({ schema: e, dataSource: o, className: u }) => {
|
|
1032
|
+
let { fieldLabel: d } = c(), [m, h] = a(null), [g, _] = a([]), [v, w] = a({}), [T, E] = a(!0), [D, O] = a(null), [k, A] = a(!1), j = e.open !== !1, N = r(), P = i(() => e.sections?.length || e.customFields?.length ? null : Z(g, m, e.columns, e.mode), [
|
|
1033
1033
|
g,
|
|
1034
1034
|
m,
|
|
1035
1035
|
e.columns,
|
|
1036
1036
|
e.mode,
|
|
1037
1037
|
e.sections,
|
|
1038
1038
|
e.customFields
|
|
1039
|
-
]), F =
|
|
1039
|
+
]), F = me[i(() => {
|
|
1040
1040
|
if (e.modalSize) return e.modalSize;
|
|
1041
|
-
if (P?.columns && P.columns > 1) return
|
|
1041
|
+
if (P?.columns && P.columns > 1) return X(P.columns);
|
|
1042
1042
|
if (e.sections?.length) {
|
|
1043
1043
|
let t = Math.max(...e.sections.map((e) => Number(e.columns) || 1));
|
|
1044
|
-
if (t > 1) return
|
|
1044
|
+
if (t > 1) return X(t);
|
|
1045
1045
|
}
|
|
1046
1046
|
return "default";
|
|
1047
1047
|
}, [
|
|
1048
1048
|
e.modalSize,
|
|
1049
1049
|
P,
|
|
1050
1050
|
e.sections
|
|
1051
|
-
])] ||
|
|
1051
|
+
])] || me.default;
|
|
1052
1052
|
n(() => {
|
|
1053
1053
|
(async () => {
|
|
1054
1054
|
if (!o) {
|
|
@@ -1173,97 +1173,97 @@ var ue = {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
}, [e, o]), z = t(() => {
|
|
1175
1175
|
e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
|
|
1176
|
-
}, [e]),
|
|
1176
|
+
}, [e]), ee = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", B = e.showSubmit !== !1 && e.mode !== "view", V = e.showCancel !== !1, H = e.submitText || (e.mode === "create" ? "Create" : "Update"), U = e.cancelText || "Cancel", W = {
|
|
1177
1177
|
type: "form",
|
|
1178
|
-
layout:
|
|
1178
|
+
layout: ee,
|
|
1179
1179
|
defaultValues: v,
|
|
1180
|
-
submitLabel:
|
|
1181
|
-
cancelLabel:
|
|
1182
|
-
showSubmit:
|
|
1183
|
-
showCancel:
|
|
1180
|
+
submitLabel: H,
|
|
1181
|
+
cancelLabel: U,
|
|
1182
|
+
showSubmit: B,
|
|
1183
|
+
showCancel: V,
|
|
1184
1184
|
onSubmit: R,
|
|
1185
1185
|
onCancel: z,
|
|
1186
1186
|
showActions: !1,
|
|
1187
1187
|
id: N
|
|
1188
|
-
},
|
|
1189
|
-
if (D) return /* @__PURE__ */ (0,
|
|
1188
|
+
}, ne = () => {
|
|
1189
|
+
if (D) return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1190
1190
|
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1191
|
-
children: [/* @__PURE__ */ (0,
|
|
1191
|
+
children: [/* @__PURE__ */ (0, G.jsx)("h3", {
|
|
1192
1192
|
className: "text-red-800 font-semibold",
|
|
1193
1193
|
children: "Error loading form"
|
|
1194
|
-
}), /* @__PURE__ */ (0,
|
|
1194
|
+
}), /* @__PURE__ */ (0, G.jsx)("p", {
|
|
1195
1195
|
className: "text-red-600 text-sm mt-1",
|
|
1196
1196
|
children: D.message
|
|
1197
1197
|
})]
|
|
1198
1198
|
});
|
|
1199
|
-
if (T) return /* @__PURE__ */ (0,
|
|
1199
|
+
if (T) return /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1200
1200
|
className: "space-y-4",
|
|
1201
1201
|
"data-testid": "modal-form-skeleton",
|
|
1202
1202
|
children: [
|
|
1203
1203
|
1,
|
|
1204
1204
|
2,
|
|
1205
1205
|
3
|
|
1206
|
-
].map((e) => /* @__PURE__ */ (0,
|
|
1206
|
+
].map((e) => /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1207
1207
|
className: "space-y-2",
|
|
1208
|
-
children: [/* @__PURE__ */ (0,
|
|
1208
|
+
children: [/* @__PURE__ */ (0, G.jsx)(M, { className: "h-4 w-24" }), /* @__PURE__ */ (0, G.jsx)(M, { className: "h-10 w-full" })]
|
|
1209
1209
|
}, e))
|
|
1210
1210
|
});
|
|
1211
|
-
if (e.sections?.length) return /* @__PURE__ */ (0,
|
|
1211
|
+
if (e.sections?.length) return /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1212
1212
|
className: "space-y-6",
|
|
1213
1213
|
children: e.sections.map((e, t) => {
|
|
1214
1214
|
let n = e.columns || 1;
|
|
1215
|
-
return /* @__PURE__ */ (0,
|
|
1215
|
+
return /* @__PURE__ */ (0, G.jsx)(K, {
|
|
1216
1216
|
label: e.label,
|
|
1217
1217
|
description: e.description,
|
|
1218
1218
|
columns: n,
|
|
1219
|
-
gridClassName:
|
|
1220
|
-
children: /* @__PURE__ */ (0,
|
|
1221
|
-
...
|
|
1219
|
+
gridClassName: Q[n],
|
|
1220
|
+
children: /* @__PURE__ */ (0, G.jsx)(s, { schema: {
|
|
1221
|
+
...W,
|
|
1222
1222
|
fields: I(e)
|
|
1223
1223
|
} })
|
|
1224
1224
|
}, e.name || e.label || t);
|
|
1225
1225
|
})
|
|
1226
1226
|
});
|
|
1227
|
-
let t = P ??
|
|
1228
|
-
return /* @__PURE__ */ (0,
|
|
1229
|
-
...
|
|
1227
|
+
let t = P ?? Z(g, m, e.columns, e.mode), n = Q[t.columns || 1];
|
|
1228
|
+
return /* @__PURE__ */ (0, G.jsx)(s, { schema: {
|
|
1229
|
+
...W,
|
|
1230
1230
|
fields: t.fields,
|
|
1231
1231
|
columns: t.columns,
|
|
1232
1232
|
...n ? { fieldContainerClass: n } : {}
|
|
1233
1233
|
} });
|
|
1234
|
-
},
|
|
1235
|
-
return /* @__PURE__ */ (0,
|
|
1234
|
+
}, q = !T && !D && (B || V);
|
|
1235
|
+
return /* @__PURE__ */ (0, G.jsx)(y, {
|
|
1236
1236
|
open: j,
|
|
1237
1237
|
onOpenChange: e.onOpenChange,
|
|
1238
|
-
children: /* @__PURE__ */ (0,
|
|
1238
|
+
children: /* @__PURE__ */ (0, G.jsxs)(C, {
|
|
1239
1239
|
className: L(F, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", u, e.className),
|
|
1240
1240
|
children: [
|
|
1241
|
-
(e.title || e.description) && /* @__PURE__ */ (0,
|
|
1241
|
+
(e.title || e.description) && /* @__PURE__ */ (0, G.jsxs)(x, {
|
|
1242
1242
|
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
1243
|
-
children: [e.title && /* @__PURE__ */ (0,
|
|
1243
|
+
children: [e.title && /* @__PURE__ */ (0, G.jsx)(S, { children: e.title }), e.description && /* @__PURE__ */ (0, G.jsx)(b, { children: e.description })]
|
|
1244
1244
|
}),
|
|
1245
|
-
/* @__PURE__ */ (0,
|
|
1245
|
+
/* @__PURE__ */ (0, G.jsx)("div", {
|
|
1246
1246
|
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
1247
|
-
children:
|
|
1247
|
+
children: ne()
|
|
1248
1248
|
}),
|
|
1249
|
-
|
|
1249
|
+
q && /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1250
1250
|
className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background",
|
|
1251
1251
|
"data-testid": "modal-form-footer",
|
|
1252
|
-
children: /* @__PURE__ */ (0,
|
|
1252
|
+
children: /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1253
1253
|
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
1254
|
-
children: [
|
|
1254
|
+
children: [V && /* @__PURE__ */ (0, G.jsx)(p, {
|
|
1255
1255
|
type: "button",
|
|
1256
1256
|
variant: "outline",
|
|
1257
1257
|
onClick: z,
|
|
1258
1258
|
disabled: k,
|
|
1259
1259
|
className: "w-full sm:w-auto",
|
|
1260
|
-
children:
|
|
1261
|
-
}),
|
|
1260
|
+
children: U
|
|
1261
|
+
}), B && /* @__PURE__ */ (0, G.jsxs)(p, {
|
|
1262
1262
|
type: "submit",
|
|
1263
1263
|
form: N,
|
|
1264
1264
|
disabled: k,
|
|
1265
1265
|
className: "w-full sm:w-auto",
|
|
1266
|
-
children: [k && /* @__PURE__ */ (0,
|
|
1266
|
+
children: [k && /* @__PURE__ */ (0, G.jsx)(te, { className: "mr-2 h-4 w-4 animate-spin" }), H]
|
|
1267
1267
|
})]
|
|
1268
1268
|
})
|
|
1269
1269
|
})
|
|
@@ -1271,7 +1271,7 @@ var ue = {
|
|
|
1271
1271
|
})
|
|
1272
1272
|
});
|
|
1273
1273
|
}, $ = ({ schema: e, dataSource: t }) => {
|
|
1274
|
-
if (e.formType === "tabbed" && e.sections?.length) return /* @__PURE__ */ (0,
|
|
1274
|
+
if (e.formType === "tabbed" && e.sections?.length) return /* @__PURE__ */ (0, G.jsx)(q, {
|
|
1275
1275
|
schema: {
|
|
1276
1276
|
...e,
|
|
1277
1277
|
formType: "tabbed",
|
|
@@ -1288,7 +1288,7 @@ var ue = {
|
|
|
1288
1288
|
dataSource: t,
|
|
1289
1289
|
className: e.className
|
|
1290
1290
|
});
|
|
1291
|
-
if (e.formType === "wizard" && e.sections?.length) return /* @__PURE__ */ (0,
|
|
1291
|
+
if (e.formType === "wizard" && e.sections?.length) return /* @__PURE__ */ (0, G.jsx)(J, {
|
|
1292
1292
|
schema: {
|
|
1293
1293
|
...e,
|
|
1294
1294
|
formType: "wizard",
|
|
@@ -1308,7 +1308,7 @@ var ue = {
|
|
|
1308
1308
|
dataSource: t,
|
|
1309
1309
|
className: e.className
|
|
1310
1310
|
});
|
|
1311
|
-
if (e.formType === "split" && e.sections?.length) return /* @__PURE__ */ (0,
|
|
1311
|
+
if (e.formType === "split" && e.sections?.length) return /* @__PURE__ */ (0, G.jsx)(re, {
|
|
1312
1312
|
schema: {
|
|
1313
1313
|
...e,
|
|
1314
1314
|
formType: "split",
|
|
@@ -1328,7 +1328,7 @@ var ue = {
|
|
|
1328
1328
|
});
|
|
1329
1329
|
if (e.formType === "drawer") {
|
|
1330
1330
|
let { layout: n, ...r } = e, i = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
|
|
1331
|
-
return /* @__PURE__ */ (0,
|
|
1331
|
+
return /* @__PURE__ */ (0, G.jsx)(pe, {
|
|
1332
1332
|
schema: {
|
|
1333
1333
|
...r,
|
|
1334
1334
|
layout: i,
|
|
@@ -1353,7 +1353,7 @@ var ue = {
|
|
|
1353
1353
|
}
|
|
1354
1354
|
if (e.formType === "modal") {
|
|
1355
1355
|
let { layout: n, ...r } = e, i = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
|
|
1356
|
-
return /* @__PURE__ */ (0,
|
|
1356
|
+
return /* @__PURE__ */ (0, G.jsx)(he, {
|
|
1357
1357
|
schema: {
|
|
1358
1358
|
...r,
|
|
1359
1359
|
layout: i,
|
|
@@ -1374,20 +1374,20 @@ var ue = {
|
|
|
1374
1374
|
className: e.className
|
|
1375
1375
|
});
|
|
1376
1376
|
}
|
|
1377
|
-
return /* @__PURE__ */ (0,
|
|
1377
|
+
return /* @__PURE__ */ (0, G.jsx)(ge, {
|
|
1378
1378
|
schema: e,
|
|
1379
1379
|
dataSource: t
|
|
1380
1380
|
});
|
|
1381
|
-
},
|
|
1382
|
-
let { fieldLabel: o } = c(),
|
|
1381
|
+
}, ge = ({ schema: r, dataSource: i }) => {
|
|
1382
|
+
let { fieldLabel: o } = c(), p = R(), [m, h] = a(null), [g, _] = a([]), [v, y] = a(null), [b, x] = a(!0), [S, C] = a(null), w = r.customFields && r.customFields.length > 0;
|
|
1383
1383
|
n(() => {
|
|
1384
|
-
|
|
1384
|
+
w && (y(r.initialData || r.initialValues || {}), x(!1));
|
|
1385
1385
|
}, [
|
|
1386
|
-
|
|
1386
|
+
w,
|
|
1387
1387
|
r.initialData,
|
|
1388
1388
|
r.initialValues
|
|
1389
1389
|
]), n(() => {
|
|
1390
|
-
|
|
1390
|
+
w ? h({
|
|
1391
1391
|
name: r.objectName,
|
|
1392
1392
|
fields: {}
|
|
1393
1393
|
}) : r.objectName && i ? (async () => {
|
|
@@ -1395,33 +1395,33 @@ var ue = {
|
|
|
1395
1395
|
if (!i) throw Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");
|
|
1396
1396
|
let e = await i.getObjectSchema(r.objectName);
|
|
1397
1397
|
if (!e) throw Error(`No schema found for object "${r.objectName}"`);
|
|
1398
|
-
|
|
1398
|
+
h(e);
|
|
1399
1399
|
} catch (e) {
|
|
1400
|
-
|
|
1400
|
+
C(e), x(!1);
|
|
1401
1401
|
}
|
|
1402
|
-
})() :
|
|
1402
|
+
})() : w || x(!1);
|
|
1403
1403
|
}, [
|
|
1404
1404
|
r.objectName,
|
|
1405
1405
|
i,
|
|
1406
|
-
|
|
1406
|
+
w
|
|
1407
1407
|
]), n(() => {
|
|
1408
|
-
|
|
1408
|
+
m && !w && (async () => {
|
|
1409
1409
|
if (!r.recordId || r.mode === "create") {
|
|
1410
|
-
|
|
1410
|
+
y(r.initialData || r.initialValues || {}), x(!1);
|
|
1411
1411
|
return;
|
|
1412
1412
|
}
|
|
1413
|
-
if (!
|
|
1413
|
+
if (!w) {
|
|
1414
1414
|
if (!i) {
|
|
1415
|
-
|
|
1415
|
+
C(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), x(!1);
|
|
1416
1416
|
return;
|
|
1417
1417
|
}
|
|
1418
|
-
|
|
1418
|
+
x(!0);
|
|
1419
1419
|
try {
|
|
1420
|
-
|
|
1420
|
+
y(await i.findOne(r.objectName, r.recordId));
|
|
1421
1421
|
} catch (e) {
|
|
1422
|
-
console.error("Failed to fetch record:", e),
|
|
1422
|
+
console.error("Failed to fetch record:", e), C(e);
|
|
1423
1423
|
} finally {
|
|
1424
|
-
|
|
1424
|
+
x(!1);
|
|
1425
1425
|
}
|
|
1426
1426
|
}
|
|
1427
1427
|
})();
|
|
@@ -1432,20 +1432,20 @@ var ue = {
|
|
|
1432
1432
|
r.initialValues,
|
|
1433
1433
|
r.initialData,
|
|
1434
1434
|
i,
|
|
1435
|
-
|
|
1436
|
-
|
|
1435
|
+
m,
|
|
1436
|
+
w
|
|
1437
1437
|
]), n(() => {
|
|
1438
|
-
if (
|
|
1439
|
-
|
|
1438
|
+
if (w && r.customFields) {
|
|
1439
|
+
_(r.customFields), x(!1);
|
|
1440
1440
|
return;
|
|
1441
1441
|
}
|
|
1442
|
-
if (!
|
|
1443
|
-
let e = [], t = r.fields || Object.keys(
|
|
1442
|
+
if (!m) return;
|
|
1443
|
+
let e = [], t = r.fields || Object.keys(m.fields || {});
|
|
1444
1444
|
(Array.isArray(t) ? t : Object.keys(t)).forEach((t) => {
|
|
1445
1445
|
let n = typeof t == "string" ? t : t.name;
|
|
1446
1446
|
if (!n) return;
|
|
1447
|
-
let i =
|
|
1448
|
-
if (!i && !
|
|
1447
|
+
let i = m.fields?.[n];
|
|
1448
|
+
if (!i && !w) return;
|
|
1449
1449
|
let a = !i?.permissions || i?.permissions.write !== !1;
|
|
1450
1450
|
if (r.mode !== "view" && !a) return;
|
|
1451
1451
|
let s = r.customFields?.find((e) => e.name === n);
|
|
@@ -1468,19 +1468,19 @@ var ue = {
|
|
|
1468
1468
|
}
|
|
1469
1469
|
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);
|
|
1470
1470
|
}
|
|
1471
|
-
}),
|
|
1471
|
+
}), _(e), !w && r.recordId && r.mode !== "create" && i || x(!1);
|
|
1472
1472
|
}, [
|
|
1473
|
-
|
|
1473
|
+
m,
|
|
1474
1474
|
r.fields,
|
|
1475
1475
|
r.customFields,
|
|
1476
1476
|
r.readOnly,
|
|
1477
1477
|
r.mode,
|
|
1478
|
-
|
|
1478
|
+
w,
|
|
1479
1479
|
r.recordId,
|
|
1480
1480
|
i
|
|
1481
1481
|
]);
|
|
1482
|
-
let
|
|
1483
|
-
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 = {})),
|
|
1482
|
+
let T = t(async (e, t) => {
|
|
1483
|
+
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 = {})), w && !i) return r.onSuccess && await r.onSuccess(e), e;
|
|
1484
1484
|
if (!i) throw Error("DataSource is required for form submission (inline mode not configured)");
|
|
1485
1485
|
try {
|
|
1486
1486
|
let t;
|
|
@@ -1494,86 +1494,116 @@ var ue = {
|
|
|
1494
1494
|
}, [
|
|
1495
1495
|
r,
|
|
1496
1496
|
i,
|
|
1497
|
-
|
|
1498
|
-
]),
|
|
1497
|
+
w
|
|
1498
|
+
]), E = t(() => {
|
|
1499
1499
|
r.onCancel && r.onCancel();
|
|
1500
|
-
}, [r]),
|
|
1500
|
+
}, [r]), D = {
|
|
1501
1501
|
...e.useMemo(() => {
|
|
1502
|
-
if (!
|
|
1502
|
+
if (!m?.fields) return {};
|
|
1503
1503
|
let e = {};
|
|
1504
|
-
return Object.keys(
|
|
1505
|
-
let n =
|
|
1504
|
+
return Object.keys(m.fields).forEach((t) => {
|
|
1505
|
+
let n = m.fields[t];
|
|
1506
1506
|
n.defaultValue !== void 0 && (e[t] = n.defaultValue);
|
|
1507
1507
|
}), e;
|
|
1508
|
-
}, [
|
|
1509
|
-
...
|
|
1508
|
+
}, [m]),
|
|
1509
|
+
...v
|
|
1510
1510
|
};
|
|
1511
|
-
if (
|
|
1511
|
+
if (S) return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1512
1512
|
className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1513
|
-
children: [/* @__PURE__ */ (0,
|
|
1513
|
+
children: [/* @__PURE__ */ (0, G.jsx)("h3", {
|
|
1514
1514
|
className: "text-red-800 font-semibold",
|
|
1515
1515
|
children: "Error loading form"
|
|
1516
|
-
}), /* @__PURE__ */ (0,
|
|
1516
|
+
}), /* @__PURE__ */ (0, G.jsx)("p", {
|
|
1517
1517
|
className: "text-red-600 text-sm mt-1",
|
|
1518
|
-
children:
|
|
1518
|
+
children: S.message
|
|
1519
1519
|
})]
|
|
1520
1520
|
});
|
|
1521
|
-
if (
|
|
1521
|
+
if (b) return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1522
1522
|
className: "p-4 sm:p-8 text-center",
|
|
1523
|
-
children: [/* @__PURE__ */ (0,
|
|
1523
|
+
children: [/* @__PURE__ */ (0, G.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, G.jsx)("p", {
|
|
1524
1524
|
className: "mt-2 text-sm text-gray-600",
|
|
1525
1525
|
children: "Loading form..."
|
|
1526
1526
|
})]
|
|
1527
1527
|
});
|
|
1528
|
-
let
|
|
1529
|
-
if (r.sections?.length && (!r.formType || r.formType === "simple")) return /* @__PURE__ */ (0,
|
|
1528
|
+
let O = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : "vertical";
|
|
1529
|
+
if (r.sections?.length && (!r.formType || r.formType === "simple")) return /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1530
1530
|
className: "w-full space-y-6",
|
|
1531
1531
|
children: r.sections.map((e, t) => {
|
|
1532
|
-
let n = e.fields.map((e) => typeof e == "string" ? e : e.name), i =
|
|
1533
|
-
return /* @__PURE__ */ (0,
|
|
1532
|
+
let n = e.fields.map((e) => typeof e == "string" ? e : e.name), i = g.filter((e) => n.includes(e.name));
|
|
1533
|
+
return /* @__PURE__ */ (0, G.jsx)(K, {
|
|
1534
1534
|
label: e.label,
|
|
1535
1535
|
description: e.description,
|
|
1536
1536
|
collapsible: e.collapsible,
|
|
1537
1537
|
collapsed: e.collapsed,
|
|
1538
1538
|
columns: e.columns,
|
|
1539
|
-
children: /* @__PURE__ */ (0,
|
|
1539
|
+
children: /* @__PURE__ */ (0, G.jsx)(s, { schema: {
|
|
1540
1540
|
type: "form",
|
|
1541
1541
|
fields: i,
|
|
1542
|
-
layout:
|
|
1543
|
-
defaultValues:
|
|
1542
|
+
layout: O,
|
|
1543
|
+
defaultValues: D,
|
|
1544
1544
|
showSubmit: t === r.sections.length - 1 && r.showSubmit !== !1 && r.mode !== "view",
|
|
1545
1545
|
showCancel: t === r.sections.length - 1 && r.showCancel !== !1,
|
|
1546
1546
|
submitLabel: r.submitText || (r.mode === "create" ? "Create" : "Update"),
|
|
1547
1547
|
cancelLabel: r.cancelText,
|
|
1548
|
-
onSubmit:
|
|
1549
|
-
onCancel:
|
|
1548
|
+
onSubmit: T,
|
|
1549
|
+
onCancel: E
|
|
1550
1550
|
} })
|
|
1551
1551
|
}, e.name || e.label || t);
|
|
1552
1552
|
})
|
|
1553
1553
|
});
|
|
1554
|
-
let
|
|
1555
|
-
fields:
|
|
1554
|
+
let k = r.sections?.length, A = k ? {
|
|
1555
|
+
fields: g,
|
|
1556
1556
|
columns: r.columns
|
|
1557
|
-
} :
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1557
|
+
} : Z(g, m, r.columns, r.mode), j = r.mobile, M = j?.fullscreenLongText ? A.fields.map((e) => {
|
|
1558
|
+
let t = e.type;
|
|
1559
|
+
return t === "textarea" || t === "field:textarea" || t === "string-multiline" || t === "field:markdown" || t === "field:html" ? {
|
|
1560
|
+
...e,
|
|
1561
|
+
mobile_fullscreen: !0
|
|
1562
|
+
} : e;
|
|
1563
|
+
}) : A.fields, N = j?.stepper, P = j?.stepperMinFields ?? 8, F = Math.max(1, j?.stepperFieldsPerStep ?? 1);
|
|
1564
|
+
if (!r.formType && !k && M.length >= 2 && (N === !0 || N === "auto" && p && M.length >= P)) {
|
|
1565
|
+
let e = M, t = [];
|
|
1566
|
+
for (let n = 0; n < e.length; n += F) {
|
|
1567
|
+
let r = e.slice(n, n + F);
|
|
1568
|
+
t.push({
|
|
1569
|
+
name: `step-${Math.floor(n / F) + 1}`,
|
|
1570
|
+
label: r[0]?.label || r[0]?.name || `Step ${Math.floor(n / F) + 1}`,
|
|
1571
|
+
fields: r
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
return /* @__PURE__ */ (0, G.jsx)(J, {
|
|
1575
|
+
schema: {
|
|
1576
|
+
...r,
|
|
1577
|
+
formType: "wizard",
|
|
1578
|
+
sections: t,
|
|
1579
|
+
showStepIndicator: !0
|
|
1580
|
+
},
|
|
1581
|
+
dataSource: i,
|
|
1573
1582
|
className: r.className
|
|
1574
|
-
}
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
let I = {
|
|
1586
|
+
type: "form",
|
|
1587
|
+
fields: M,
|
|
1588
|
+
layout: O,
|
|
1589
|
+
columns: A.columns,
|
|
1590
|
+
submitLabel: r.submitText || (r.mode === "create" ? "Create" : "Update"),
|
|
1591
|
+
cancelLabel: r.cancelText,
|
|
1592
|
+
showSubmit: r.showSubmit !== !1 && r.mode !== "view",
|
|
1593
|
+
showCancel: r.showCancel !== !1,
|
|
1594
|
+
resetOnSubmit: r.showReset,
|
|
1595
|
+
defaultValues: D,
|
|
1596
|
+
onSubmit: T,
|
|
1597
|
+
onCancel: E,
|
|
1598
|
+
className: r.className,
|
|
1599
|
+
mobileStickyActions: !!j?.stickyActions
|
|
1600
|
+
};
|
|
1601
|
+
return /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1602
|
+
className: j?.stickyActions ? "w-full pb-20 md:pb-0" : "w-full",
|
|
1603
|
+
"data-mobile-form": j ? "true" : void 0,
|
|
1604
|
+
children: /* @__PURE__ */ (0, G.jsx)(s, { schema: I })
|
|
1575
1605
|
});
|
|
1576
|
-
},
|
|
1606
|
+
}, _e = ({ config: e, dataSource: n, prefillParams: r, className: o }) => {
|
|
1577
1607
|
let [s, c] = a(!1), [l, u] = a(!1), [d, f] = a(null), p = i(() => {
|
|
1578
1608
|
let e = {};
|
|
1579
1609
|
if (r) for (let [t, n] of Object.entries(r)) e[t] = n;
|
|
@@ -1602,30 +1632,30 @@ var ue = {
|
|
|
1602
1632
|
}, [e.branding]);
|
|
1603
1633
|
if (s) {
|
|
1604
1634
|
let t = e.thankYouPage;
|
|
1605
|
-
return /* @__PURE__ */ (0,
|
|
1635
|
+
return /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1606
1636
|
className: `min-h-screen flex items-center justify-center p-4 ${o || ""}`,
|
|
1607
1637
|
style: g,
|
|
1608
|
-
children: /* @__PURE__ */ (0,
|
|
1638
|
+
children: /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1609
1639
|
className: "max-w-md w-full bg-card rounded-lg shadow-lg p-8 text-center space-y-4",
|
|
1610
1640
|
children: [
|
|
1611
|
-
/* @__PURE__ */ (0,
|
|
1641
|
+
/* @__PURE__ */ (0, G.jsx)("div", {
|
|
1612
1642
|
className: "text-4xl",
|
|
1613
1643
|
children: "✓"
|
|
1614
1644
|
}),
|
|
1615
|
-
/* @__PURE__ */ (0,
|
|
1645
|
+
/* @__PURE__ */ (0, G.jsx)("h2", {
|
|
1616
1646
|
className: "text-xl font-semibold text-foreground",
|
|
1617
1647
|
children: t?.title || "Thank You!"
|
|
1618
1648
|
}),
|
|
1619
|
-
/* @__PURE__ */ (0,
|
|
1649
|
+
/* @__PURE__ */ (0, G.jsx)("p", {
|
|
1620
1650
|
className: "text-muted-foreground",
|
|
1621
1651
|
children: t?.message || "Your submission has been received successfully."
|
|
1622
1652
|
}),
|
|
1623
|
-
e.allowMultiple && /* @__PURE__ */ (0,
|
|
1653
|
+
e.allowMultiple && /* @__PURE__ */ (0, G.jsx)("button", {
|
|
1624
1654
|
onClick: h,
|
|
1625
1655
|
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",
|
|
1626
1656
|
children: "Submit Another Response"
|
|
1627
1657
|
}),
|
|
1628
|
-
t?.redirectUrl && /* @__PURE__ */ (0,
|
|
1658
|
+
t?.redirectUrl && /* @__PURE__ */ (0, G.jsxs)("p", {
|
|
1629
1659
|
className: "text-xs text-muted-foreground",
|
|
1630
1660
|
children: [
|
|
1631
1661
|
"Redirecting in ",
|
|
@@ -1637,37 +1667,37 @@ var ue = {
|
|
|
1637
1667
|
})
|
|
1638
1668
|
});
|
|
1639
1669
|
}
|
|
1640
|
-
return /* @__PURE__ */ (0,
|
|
1670
|
+
return /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1641
1671
|
className: `min-h-screen flex items-center justify-center p-4 ${o || ""}`,
|
|
1642
1672
|
style: g,
|
|
1643
|
-
children: /* @__PURE__ */ (0,
|
|
1673
|
+
children: /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1644
1674
|
className: "max-w-2xl w-full bg-card rounded-lg shadow-lg overflow-hidden",
|
|
1645
1675
|
children: [
|
|
1646
|
-
/* @__PURE__ */ (0,
|
|
1676
|
+
/* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1647
1677
|
className: "p-6 border-b",
|
|
1648
1678
|
style: e.branding?.primaryColor ? { borderBottomColor: e.branding.primaryColor } : void 0,
|
|
1649
1679
|
children: [
|
|
1650
|
-
e.branding?.logo && /* @__PURE__ */ (0,
|
|
1680
|
+
e.branding?.logo && /* @__PURE__ */ (0, G.jsx)("img", {
|
|
1651
1681
|
src: e.branding.logo,
|
|
1652
1682
|
alt: "Logo",
|
|
1653
1683
|
className: "h-8 mb-4"
|
|
1654
1684
|
}),
|
|
1655
|
-
e.title && /* @__PURE__ */ (0,
|
|
1685
|
+
e.title && /* @__PURE__ */ (0, G.jsx)("h1", {
|
|
1656
1686
|
className: "text-xl font-semibold text-foreground",
|
|
1657
1687
|
children: e.title
|
|
1658
1688
|
}),
|
|
1659
|
-
e.description && /* @__PURE__ */ (0,
|
|
1689
|
+
e.description && /* @__PURE__ */ (0, G.jsx)("p", {
|
|
1660
1690
|
className: "text-sm text-muted-foreground mt-1",
|
|
1661
1691
|
children: e.description
|
|
1662
1692
|
})
|
|
1663
1693
|
]
|
|
1664
1694
|
}),
|
|
1665
|
-
/* @__PURE__ */ (0,
|
|
1695
|
+
/* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1666
1696
|
className: "p-6",
|
|
1667
|
-
children: [d && /* @__PURE__ */ (0,
|
|
1697
|
+
children: [d && /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1668
1698
|
className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
|
|
1669
1699
|
children: d
|
|
1670
|
-
}), /* @__PURE__ */ (0,
|
|
1700
|
+
}), /* @__PURE__ */ (0, G.jsx)($, {
|
|
1671
1701
|
schema: {
|
|
1672
1702
|
type: "object-form",
|
|
1673
1703
|
objectName: e.objectName,
|
|
@@ -1681,9 +1711,9 @@ var ue = {
|
|
|
1681
1711
|
dataSource: n
|
|
1682
1712
|
})]
|
|
1683
1713
|
}),
|
|
1684
|
-
/* @__PURE__ */ (0,
|
|
1714
|
+
/* @__PURE__ */ (0, G.jsx)("div", {
|
|
1685
1715
|
className: "px-6 py-3 border-t bg-muted/20 text-center",
|
|
1686
|
-
children: /* @__PURE__ */ (0,
|
|
1716
|
+
children: /* @__PURE__ */ (0, G.jsx)("p", {
|
|
1687
1717
|
className: "text-xs text-muted-foreground",
|
|
1688
1718
|
children: "Powered by ObjectStack"
|
|
1689
1719
|
})
|
|
@@ -1694,96 +1724,96 @@ var ue = {
|
|
|
1694
1724
|
};
|
|
1695
1725
|
//#endregion
|
|
1696
1726
|
//#region src/FormAnalytics.tsx
|
|
1697
|
-
function
|
|
1727
|
+
function ve(e) {
|
|
1698
1728
|
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`;
|
|
1699
1729
|
}
|
|
1700
|
-
var
|
|
1730
|
+
var ye = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
1701
1731
|
let a = i(() => {
|
|
1702
1732
|
if (!n.abandonedSubmissions) return 100;
|
|
1703
1733
|
let e = n.totalSubmissions + n.abandonedSubmissions;
|
|
1704
1734
|
return e === 0 ? 0 : Math.round(n.totalSubmissions / e * 100);
|
|
1705
1735
|
}, [n.totalSubmissions, n.abandonedSubmissions]), o = i(() => n.dailySubmissions?.length ? Math.max(...n.dailySubmissions.map((e) => e.count), 1) : 1, [n.dailySubmissions]);
|
|
1706
|
-
return /* @__PURE__ */ (0,
|
|
1736
|
+
return /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1707
1737
|
className: `space-y-4 ${r || ""}`,
|
|
1708
1738
|
children: [
|
|
1709
|
-
/* @__PURE__ */ (0,
|
|
1739
|
+
/* @__PURE__ */ (0, G.jsxs)("div", { children: [/* @__PURE__ */ (0, G.jsx)("h2", {
|
|
1710
1740
|
className: "text-lg font-semibold text-foreground",
|
|
1711
1741
|
children: t || "Form Analytics"
|
|
1712
|
-
}), /* @__PURE__ */ (0,
|
|
1742
|
+
}), /* @__PURE__ */ (0, G.jsxs)("p", {
|
|
1713
1743
|
className: "text-sm text-muted-foreground",
|
|
1714
1744
|
children: ["Form ID: ", e]
|
|
1715
1745
|
})] }),
|
|
1716
|
-
/* @__PURE__ */ (0,
|
|
1746
|
+
/* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1717
1747
|
className: "grid grid-cols-1 sm:grid-cols-3 gap-4",
|
|
1718
1748
|
children: [
|
|
1719
|
-
/* @__PURE__ */ (0,
|
|
1749
|
+
/* @__PURE__ */ (0, G.jsx)(m, { children: /* @__PURE__ */ (0, G.jsxs)(_, {
|
|
1720
1750
|
className: "pb-2",
|
|
1721
|
-
children: [/* @__PURE__ */ (0,
|
|
1751
|
+
children: [/* @__PURE__ */ (0, G.jsx)(g, { children: "Total Submissions" }), /* @__PURE__ */ (0, G.jsx)(v, {
|
|
1722
1752
|
className: "text-2xl",
|
|
1723
1753
|
children: n.totalSubmissions.toLocaleString()
|
|
1724
1754
|
})]
|
|
1725
1755
|
}) }),
|
|
1726
|
-
/* @__PURE__ */ (0,
|
|
1756
|
+
/* @__PURE__ */ (0, G.jsxs)(m, { children: [/* @__PURE__ */ (0, G.jsxs)(_, {
|
|
1727
1757
|
className: "pb-2",
|
|
1728
|
-
children: [/* @__PURE__ */ (0,
|
|
1758
|
+
children: [/* @__PURE__ */ (0, G.jsx)(g, { children: "Fill Rate" }), /* @__PURE__ */ (0, G.jsxs)(v, {
|
|
1729
1759
|
className: "text-2xl",
|
|
1730
1760
|
children: [a, "%"]
|
|
1731
1761
|
})]
|
|
1732
|
-
}), /* @__PURE__ */ (0,
|
|
1762
|
+
}), /* @__PURE__ */ (0, G.jsx)(h, { children: /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1733
1763
|
className: "w-full bg-muted rounded-full h-2",
|
|
1734
|
-
children: /* @__PURE__ */ (0,
|
|
1764
|
+
children: /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1735
1765
|
className: "bg-primary rounded-full h-2 transition-all",
|
|
1736
1766
|
style: { width: `${a}%` }
|
|
1737
1767
|
})
|
|
1738
1768
|
}) })] }),
|
|
1739
|
-
/* @__PURE__ */ (0,
|
|
1769
|
+
/* @__PURE__ */ (0, G.jsx)(m, { children: /* @__PURE__ */ (0, G.jsxs)(_, {
|
|
1740
1770
|
className: "pb-2",
|
|
1741
|
-
children: [/* @__PURE__ */ (0,
|
|
1771
|
+
children: [/* @__PURE__ */ (0, G.jsx)(g, { children: "Avg. Completion Time" }), /* @__PURE__ */ (0, G.jsx)(v, {
|
|
1742
1772
|
className: "text-2xl",
|
|
1743
|
-
children: n.avgCompletionTime ?
|
|
1773
|
+
children: n.avgCompletionTime ? ve(n.avgCompletionTime) : "—"
|
|
1744
1774
|
})]
|
|
1745
1775
|
}) })
|
|
1746
1776
|
]
|
|
1747
1777
|
}),
|
|
1748
|
-
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ (0,
|
|
1778
|
+
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ (0, G.jsxs)(m, { children: [/* @__PURE__ */ (0, G.jsx)(_, { children: /* @__PURE__ */ (0, G.jsx)(v, {
|
|
1749
1779
|
className: "text-sm font-medium",
|
|
1750
1780
|
children: "Daily Submissions"
|
|
1751
|
-
}) }), /* @__PURE__ */ (0,
|
|
1781
|
+
}) }), /* @__PURE__ */ (0, G.jsx)(h, { children: /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1752
1782
|
className: "flex items-end gap-1 h-32",
|
|
1753
|
-
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ (0,
|
|
1783
|
+
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1754
1784
|
className: "flex-1 flex flex-col items-center gap-1",
|
|
1755
|
-
children: [/* @__PURE__ */ (0,
|
|
1785
|
+
children: [/* @__PURE__ */ (0, G.jsx)("div", {
|
|
1756
1786
|
className: "w-full bg-primary/80 rounded-t transition-all hover:bg-primary",
|
|
1757
1787
|
style: {
|
|
1758
1788
|
height: `${e.count / o * 100}%`,
|
|
1759
1789
|
minHeight: e.count > 0 ? "4px" : "0"
|
|
1760
1790
|
},
|
|
1761
1791
|
title: `${e.date}: ${e.count} submissions`
|
|
1762
|
-
}), /* @__PURE__ */ (0,
|
|
1792
|
+
}), /* @__PURE__ */ (0, G.jsx)("span", {
|
|
1763
1793
|
className: "text-[10px] text-muted-foreground truncate w-full text-center",
|
|
1764
1794
|
children: e.date.slice(-5)
|
|
1765
1795
|
})]
|
|
1766
1796
|
}, t))
|
|
1767
1797
|
}) })] }),
|
|
1768
|
-
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ (0,
|
|
1798
|
+
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ (0, G.jsxs)(m, { children: [/* @__PURE__ */ (0, G.jsxs)(_, { children: [/* @__PURE__ */ (0, G.jsx)(v, {
|
|
1769
1799
|
className: "text-sm font-medium",
|
|
1770
1800
|
children: "Field Completion Rates"
|
|
1771
|
-
}), /* @__PURE__ */ (0,
|
|
1801
|
+
}), /* @__PURE__ */ (0, G.jsx)(g, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ (0, G.jsx)(h, { children: /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1772
1802
|
className: "space-y-3",
|
|
1773
|
-
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ (0,
|
|
1803
|
+
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1774
1804
|
className: "space-y-1",
|
|
1775
|
-
children: [/* @__PURE__ */ (0,
|
|
1805
|
+
children: [/* @__PURE__ */ (0, G.jsxs)("div", {
|
|
1776
1806
|
className: "flex justify-between text-sm",
|
|
1777
|
-
children: [/* @__PURE__ */ (0,
|
|
1807
|
+
children: [/* @__PURE__ */ (0, G.jsx)("span", {
|
|
1778
1808
|
className: "text-foreground",
|
|
1779
1809
|
children: e.label
|
|
1780
|
-
}), /* @__PURE__ */ (0,
|
|
1810
|
+
}), /* @__PURE__ */ (0, G.jsxs)("span", {
|
|
1781
1811
|
className: "text-muted-foreground",
|
|
1782
1812
|
children: [e.completionRate, "%"]
|
|
1783
1813
|
})]
|
|
1784
|
-
}), /* @__PURE__ */ (0,
|
|
1814
|
+
}), /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1785
1815
|
className: "w-full bg-muted rounded-full h-1.5",
|
|
1786
|
-
children: /* @__PURE__ */ (0,
|
|
1816
|
+
children: /* @__PURE__ */ (0, G.jsx)("div", {
|
|
1787
1817
|
className: `rounded-full h-1.5 transition-all ${e.completionRate >= 80 ? "bg-green-500" : e.completionRate >= 50 ? "bg-yellow-500" : "bg-destructive"}`,
|
|
1788
1818
|
style: { width: `${e.completionRate}%` }
|
|
1789
1819
|
})
|
|
@@ -1792,8 +1822,8 @@ var ve = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
|
1792
1822
|
}) })] })
|
|
1793
1823
|
]
|
|
1794
1824
|
});
|
|
1795
|
-
},
|
|
1796
|
-
o.register("object-form",
|
|
1825
|
+
}, be = ({ schema: e }) => /* @__PURE__ */ (0, G.jsx)($, { schema: e });
|
|
1826
|
+
o.register("object-form", be, {
|
|
1797
1827
|
namespace: "plugin-form",
|
|
1798
1828
|
label: "Object Form",
|
|
1799
1829
|
category: "plugin",
|
|
@@ -1934,7 +1964,7 @@ o.register("object-form", ye, {
|
|
|
1934
1964
|
]
|
|
1935
1965
|
}
|
|
1936
1966
|
]
|
|
1937
|
-
}), o.register("form",
|
|
1967
|
+
}), o.register("form", be, {
|
|
1938
1968
|
namespace: "view",
|
|
1939
1969
|
skipFallback: !0,
|
|
1940
1970
|
label: "Data Form View",
|
|
@@ -1962,7 +1992,7 @@ o.register("object-form", ye, {
|
|
|
1962
1992
|
]
|
|
1963
1993
|
}
|
|
1964
1994
|
]
|
|
1965
|
-
}), o.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */ (0,
|
|
1995
|
+
}), o.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */ (0, G.jsx)(_e, { config: e }), {
|
|
1966
1996
|
namespace: "plugin-form",
|
|
1967
1997
|
label: "Embeddable Form",
|
|
1968
1998
|
category: "plugin",
|
|
@@ -2000,7 +2030,7 @@ o.register("object-form", ye, {
|
|
|
2000
2030
|
label: "Allow Multiple Submissions"
|
|
2001
2031
|
}
|
|
2002
2032
|
]
|
|
2003
|
-
}), o.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ (0,
|
|
2033
|
+
}), o.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ (0, G.jsx)(ye, {
|
|
2004
2034
|
formId: e.formId,
|
|
2005
2035
|
formTitle: e.formTitle,
|
|
2006
2036
|
metrics: e.metrics || { totalSubmissions: 0 }
|
|
@@ -2028,4 +2058,4 @@ o.register("object-form", ye, {
|
|
|
2028
2058
|
]
|
|
2029
2059
|
});
|
|
2030
2060
|
//#endregion
|
|
2031
|
-
export {
|
|
2061
|
+
export { pe as DrawerForm, _e as EmbeddableForm, ye as FormAnalytics, K as FormSection, he as ModalForm, $ as ObjectForm, re as SplitForm, q as TabbedForm, J as WizardForm, Y as applyAutoColSpan, Z as applyAutoLayout, de as filterCreateModeFields, le as inferColumns, X as inferModalSize, ce as isAutoGeneratedFieldType, se as isWideFieldType };
|