@object-ui/plugin-form 3.0.3 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +11 -0
- package/dist/index.js +1217 -861
- package/dist/index.umd.cjs +2 -2
- package/dist/plugin-form/src/EmbeddableForm.d.ts +49 -0
- package/dist/plugin-form/src/FormAnalytics.d.ts +38 -0
- package/dist/plugin-form/src/FormSection.d.ts +6 -0
- package/dist/plugin-form/src/autoLayout.d.ts +60 -0
- package/dist/plugin-form/src/index.d.ts +5 -0
- package/package.json +8 -8
- package/src/DrawerForm.tsx +49 -24
- package/src/EmbeddableForm.tsx +240 -0
- package/src/FormAnalytics.tsx +209 -0
- package/src/FormSection.tsx +9 -1
- package/src/ModalForm.tsx +145 -45
- package/src/ObjectForm.tsx +12 -4
- package/src/SplitForm.tsx +3 -2
- package/src/TabbedForm.tsx +3 -2
- package/src/WizardForm.tsx +3 -2
- package/src/__tests__/EmbeddableFormPrefill.test.tsx +186 -0
- package/src/__tests__/MobileUX.test.tsx +433 -0
- package/src/__tests__/NewVariants.test.tsx +196 -0
- package/src/__tests__/autoLayout.test.ts +342 -0
- package/src/autoLayout.ts +168 -0
- package/src/index.tsx +52 -0
package/dist/index.js
CHANGED
|
@@ -1,445 +1,446 @@
|
|
|
1
|
-
import
|
|
1
|
+
import K, { useState as C, useCallback as A, useMemo as G, useEffect as H, useId as Fe } from "react";
|
|
2
2
|
import { ComponentRegistry as ue } from "@object-ui/core";
|
|
3
|
-
import { SchemaRenderer as
|
|
4
|
-
import { buildValidationRules as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { ChevronRight as
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"),
|
|
13
|
-
function
|
|
14
|
-
var
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
for (var E in
|
|
18
|
-
E !== "key" && (
|
|
19
|
-
} else
|
|
20
|
-
return
|
|
3
|
+
import { useSafeFieldLabel as ee, SchemaRenderer as J } from "@object-ui/react";
|
|
4
|
+
import { buildValidationRules as B, mapFieldTypeToFormType as X, formatFileSize as Re, evaluateCondition as De } from "@object-ui/fields";
|
|
5
|
+
import { cn as W, Tabs as ke, TabsList as _e, TabsTrigger as Ie, TabsContent as Le, Button as Z, ResizablePanelGroup as Pe, ResizablePanel as be, ResizableHandle as Ae, Sheet as ze, SheetContent as Ve, SheetHeader as Me, SheetTitle as $e, SheetDescription as qe, Dialog as Ye, MobileDialogContent as We, DialogHeader as Ue, DialogTitle as He, DialogDescription as Ge, Skeleton as xe, Card as re, CardHeader as le, CardDescription as ae, CardTitle as ne, CardContent as me } from "@object-ui/components";
|
|
6
|
+
import { ChevronRight as Te, ChevronDown as Je, Check as Be, ChevronLeft as Xe, Loader2 as Qe } from "lucide-react";
|
|
7
|
+
var de = { exports: {} }, ie = {};
|
|
8
|
+
var ye;
|
|
9
|
+
function Ze() {
|
|
10
|
+
if (ye) return ie;
|
|
11
|
+
ye = 1;
|
|
12
|
+
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), r = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
13
|
+
function i(b, o, p) {
|
|
14
|
+
var x = null;
|
|
15
|
+
if (p !== void 0 && (x = "" + p), o.key !== void 0 && (x = "" + o.key), "key" in o) {
|
|
16
|
+
p = {};
|
|
17
|
+
for (var E in o)
|
|
18
|
+
E !== "key" && (p[E] = o[E]);
|
|
19
|
+
} else p = o;
|
|
20
|
+
return o = p.ref, {
|
|
21
21
|
$$typeof: e,
|
|
22
|
-
type:
|
|
23
|
-
key:
|
|
24
|
-
ref:
|
|
25
|
-
props:
|
|
22
|
+
type: b,
|
|
23
|
+
key: x,
|
|
24
|
+
ref: o !== void 0 ? o : null,
|
|
25
|
+
props: p
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
return
|
|
28
|
+
return ie.Fragment = r, ie.jsx = i, ie.jsxs = i, ie;
|
|
29
29
|
}
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
function
|
|
33
|
-
return
|
|
34
|
-
function e(
|
|
35
|
-
if (
|
|
36
|
-
if (typeof
|
|
37
|
-
return
|
|
38
|
-
if (typeof
|
|
39
|
-
switch (
|
|
40
|
-
case
|
|
30
|
+
var oe = {};
|
|
31
|
+
var ge;
|
|
32
|
+
function Ke() {
|
|
33
|
+
return ge || (ge = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
34
|
+
function e(l) {
|
|
35
|
+
if (l == null) return null;
|
|
36
|
+
if (typeof l == "function")
|
|
37
|
+
return l.$$typeof === y ? null : l.displayName || l.name || null;
|
|
38
|
+
if (typeof l == "string") return l;
|
|
39
|
+
switch (l) {
|
|
40
|
+
case z:
|
|
41
41
|
return "Fragment";
|
|
42
|
-
case
|
|
42
|
+
case k:
|
|
43
43
|
return "Profiler";
|
|
44
|
-
case
|
|
44
|
+
case L:
|
|
45
45
|
return "StrictMode";
|
|
46
|
-
case
|
|
46
|
+
case n:
|
|
47
47
|
return "Suspense";
|
|
48
48
|
case a:
|
|
49
49
|
return "SuspenseList";
|
|
50
|
-
case
|
|
50
|
+
case S:
|
|
51
51
|
return "Activity";
|
|
52
52
|
}
|
|
53
|
-
if (typeof
|
|
54
|
-
switch (typeof
|
|
53
|
+
if (typeof l == "object")
|
|
54
|
+
switch (typeof l.tag == "number" && console.error(
|
|
55
55
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
56
|
-
),
|
|
57
|
-
case
|
|
56
|
+
), l.$$typeof) {
|
|
57
|
+
case D:
|
|
58
58
|
return "Portal";
|
|
59
|
+
case M:
|
|
60
|
+
return l.displayName || "Context";
|
|
61
|
+
case U:
|
|
62
|
+
return (l._context.displayName || "Context") + ".Consumer";
|
|
63
|
+
case f:
|
|
64
|
+
var w = l.render;
|
|
65
|
+
return l = l.displayName, l || (l = w.displayName || w.name || "", l = l !== "" ? "ForwardRef(" + l + ")" : "ForwardRef"), l;
|
|
59
66
|
case s:
|
|
60
|
-
return
|
|
61
|
-
case u:
|
|
62
|
-
return (r._context.displayName || "Context") + ".Consumer";
|
|
63
|
-
case n:
|
|
64
|
-
var m = r.render;
|
|
65
|
-
return r = r.displayName, r || (r = m.displayName || m.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
67
|
+
return w = l.displayName || null, w !== null ? w : e(l.type) || "Memo";
|
|
66
68
|
case c:
|
|
67
|
-
|
|
68
|
-
case i:
|
|
69
|
-
m = r._payload, r = r._init;
|
|
69
|
+
w = l._payload, l = l._init;
|
|
70
70
|
try {
|
|
71
|
-
return e(
|
|
71
|
+
return e(l(w));
|
|
72
72
|
} catch {
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
return null;
|
|
76
76
|
}
|
|
77
|
-
function l
|
|
78
|
-
return "" +
|
|
77
|
+
function r(l) {
|
|
78
|
+
return "" + l;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function i(l) {
|
|
81
81
|
try {
|
|
82
|
-
l
|
|
83
|
-
var
|
|
82
|
+
r(l);
|
|
83
|
+
var w = !1;
|
|
84
84
|
} catch {
|
|
85
|
-
|
|
85
|
+
w = !0;
|
|
86
86
|
}
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
var
|
|
90
|
-
return
|
|
91
|
-
|
|
87
|
+
if (w) {
|
|
88
|
+
w = console;
|
|
89
|
+
var P = w.error, $ = typeof Symbol == "function" && Symbol.toStringTag && l[Symbol.toStringTag] || l.constructor.name || "Object";
|
|
90
|
+
return P.call(
|
|
91
|
+
w,
|
|
92
92
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
93
|
-
|
|
94
|
-
), l
|
|
93
|
+
$
|
|
94
|
+
), r(l);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
if (
|
|
99
|
-
if (typeof
|
|
97
|
+
function b(l) {
|
|
98
|
+
if (l === z) return "<>";
|
|
99
|
+
if (typeof l == "object" && l !== null && l.$$typeof === c)
|
|
100
100
|
return "<...>";
|
|
101
101
|
try {
|
|
102
|
-
var
|
|
103
|
-
return
|
|
102
|
+
var w = e(l);
|
|
103
|
+
return w ? "<" + w + ">" : "<...>";
|
|
104
104
|
} catch {
|
|
105
105
|
return "<...>";
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
var
|
|
110
|
-
return
|
|
108
|
+
function o() {
|
|
109
|
+
var l = d.A;
|
|
110
|
+
return l === null ? null : l.getOwner();
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function p() {
|
|
113
113
|
return Error("react-stack-top-frame");
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
if (
|
|
117
|
-
var
|
|
118
|
-
if (
|
|
115
|
+
function x(l) {
|
|
116
|
+
if (_.call(l, "key")) {
|
|
117
|
+
var w = Object.getOwnPropertyDescriptor(l, "key").get;
|
|
118
|
+
if (w && w.isReactWarning) return !1;
|
|
119
119
|
}
|
|
120
|
-
return
|
|
120
|
+
return l.key !== void 0;
|
|
121
121
|
}
|
|
122
|
-
function E(
|
|
123
|
-
function
|
|
124
|
-
|
|
122
|
+
function E(l, w) {
|
|
123
|
+
function P() {
|
|
124
|
+
g || (g = !0, console.error(
|
|
125
125
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
126
|
-
|
|
126
|
+
w
|
|
127
127
|
));
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
get:
|
|
129
|
+
P.isReactWarning = !0, Object.defineProperty(l, "key", {
|
|
130
|
+
get: P,
|
|
131
131
|
configurable: !0
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
function
|
|
135
|
-
var
|
|
136
|
-
return
|
|
134
|
+
function I() {
|
|
135
|
+
var l = e(this.type);
|
|
136
|
+
return m[l] || (m[l] = !0, console.error(
|
|
137
137
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
138
|
-
)),
|
|
138
|
+
)), l = this.props.ref, l !== void 0 ? l : null;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
var
|
|
142
|
-
return
|
|
143
|
-
$$typeof:
|
|
144
|
-
type:
|
|
145
|
-
key:
|
|
146
|
-
props:
|
|
147
|
-
_owner:
|
|
148
|
-
}, (
|
|
140
|
+
function O(l, w, P, $, se, fe) {
|
|
141
|
+
var q = P.ref;
|
|
142
|
+
return l = {
|
|
143
|
+
$$typeof: v,
|
|
144
|
+
type: l,
|
|
145
|
+
key: w,
|
|
146
|
+
props: P,
|
|
147
|
+
_owner: $
|
|
148
|
+
}, (q !== void 0 ? q : null) !== null ? Object.defineProperty(l, "ref", {
|
|
149
149
|
enumerable: !1,
|
|
150
|
-
get:
|
|
151
|
-
}) : Object.defineProperty(
|
|
150
|
+
get: I
|
|
151
|
+
}) : Object.defineProperty(l, "ref", { enumerable: !1, value: null }), l._store = {}, Object.defineProperty(l._store, "validated", {
|
|
152
152
|
configurable: !1,
|
|
153
153
|
enumerable: !1,
|
|
154
154
|
writable: !0,
|
|
155
155
|
value: 0
|
|
156
|
-
}), Object.defineProperty(
|
|
156
|
+
}), Object.defineProperty(l, "_debugInfo", {
|
|
157
157
|
configurable: !1,
|
|
158
158
|
enumerable: !1,
|
|
159
159
|
writable: !0,
|
|
160
160
|
value: null
|
|
161
|
-
}), Object.defineProperty(
|
|
161
|
+
}), Object.defineProperty(l, "_debugStack", {
|
|
162
162
|
configurable: !1,
|
|
163
163
|
enumerable: !1,
|
|
164
164
|
writable: !0,
|
|
165
|
-
value:
|
|
166
|
-
}), Object.defineProperty(
|
|
165
|
+
value: se
|
|
166
|
+
}), Object.defineProperty(l, "_debugTask", {
|
|
167
167
|
configurable: !1,
|
|
168
168
|
enumerable: !1,
|
|
169
169
|
writable: !0,
|
|
170
|
-
value:
|
|
171
|
-
}), Object.freeze && (Object.freeze(
|
|
170
|
+
value: fe
|
|
171
|
+
}), Object.freeze && (Object.freeze(l.props), Object.freeze(l)), l;
|
|
172
172
|
}
|
|
173
|
-
function
|
|
174
|
-
var
|
|
175
|
-
if (
|
|
176
|
-
if (
|
|
177
|
-
if (
|
|
178
|
-
for (
|
|
179
|
-
|
|
180
|
-
Object.freeze && Object.freeze(
|
|
173
|
+
function F(l, w, P, $, se, fe) {
|
|
174
|
+
var q = w.children;
|
|
175
|
+
if (q !== void 0)
|
|
176
|
+
if ($)
|
|
177
|
+
if (T(q)) {
|
|
178
|
+
for ($ = 0; $ < q.length; $++)
|
|
179
|
+
N(q[$]);
|
|
180
|
+
Object.freeze && Object.freeze(q);
|
|
181
181
|
} else
|
|
182
182
|
console.error(
|
|
183
183
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
184
184
|
);
|
|
185
|
-
else
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
var
|
|
189
|
-
return
|
|
185
|
+
else N(q);
|
|
186
|
+
if (_.call(w, "key")) {
|
|
187
|
+
q = e(l);
|
|
188
|
+
var Q = Object.keys(w).filter(function(Oe) {
|
|
189
|
+
return Oe !== "key";
|
|
190
190
|
});
|
|
191
|
-
|
|
191
|
+
$ = 0 < Q.length ? "{key: someKey, " + Q.join(": ..., ") + ": ...}" : "{key: someKey}", R[q + $] || (Q = 0 < Q.length ? "{" + Q.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
192
192
|
`A props object containing a "key" prop is being spread into JSX:
|
|
193
193
|
let props = %s;
|
|
194
194
|
<%s {...props} />
|
|
195
195
|
React keys must be passed directly to JSX without using spread:
|
|
196
196
|
let props = %s;
|
|
197
197
|
<%s key={someKey} {...props} />`,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
),
|
|
198
|
+
$,
|
|
199
|
+
q,
|
|
200
|
+
Q,
|
|
201
|
+
q
|
|
202
|
+
), R[q + $] = !0);
|
|
203
203
|
}
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
for (var
|
|
207
|
-
|
|
208
|
-
} else
|
|
209
|
-
return
|
|
210
|
-
|
|
211
|
-
typeof
|
|
212
|
-
),
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
204
|
+
if (q = null, P !== void 0 && (i(P), q = "" + P), x(w) && (i(w.key), q = "" + w.key), "key" in w) {
|
|
205
|
+
P = {};
|
|
206
|
+
for (var pe in w)
|
|
207
|
+
pe !== "key" && (P[pe] = w[pe]);
|
|
208
|
+
} else P = w;
|
|
209
|
+
return q && E(
|
|
210
|
+
P,
|
|
211
|
+
typeof l == "function" ? l.displayName || l.name || "Unknown" : l
|
|
212
|
+
), O(
|
|
213
|
+
l,
|
|
214
|
+
q,
|
|
215
|
+
P,
|
|
216
|
+
o(),
|
|
217
|
+
se,
|
|
218
|
+
fe
|
|
219
219
|
);
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
|
|
221
|
+
function N(l) {
|
|
222
|
+
j(l) ? l._store && (l._store.validated = 1) : typeof l == "object" && l !== null && l.$$typeof === c && (l._payload.status === "fulfilled" ? j(l._payload.value) && l._payload.value._store && (l._payload.value._store.validated = 1) : l._store && (l._store.validated = 1));
|
|
223
223
|
}
|
|
224
|
-
function
|
|
225
|
-
return typeof
|
|
224
|
+
function j(l) {
|
|
225
|
+
return typeof l == "object" && l !== null && l.$$typeof === v;
|
|
226
226
|
}
|
|
227
|
-
var
|
|
227
|
+
var h = K, v = /* @__PURE__ */ Symbol.for("react.transitional.element"), D = /* @__PURE__ */ Symbol.for("react.portal"), z = /* @__PURE__ */ Symbol.for("react.fragment"), L = /* @__PURE__ */ Symbol.for("react.strict_mode"), k = /* @__PURE__ */ Symbol.for("react.profiler"), U = /* @__PURE__ */ Symbol.for("react.consumer"), M = /* @__PURE__ */ Symbol.for("react.context"), f = /* @__PURE__ */ Symbol.for("react.forward_ref"), n = /* @__PURE__ */ Symbol.for("react.suspense"), a = /* @__PURE__ */ Symbol.for("react.suspense_list"), s = /* @__PURE__ */ Symbol.for("react.memo"), c = /* @__PURE__ */ Symbol.for("react.lazy"), S = /* @__PURE__ */ Symbol.for("react.activity"), y = /* @__PURE__ */ Symbol.for("react.client.reference"), d = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, _ = Object.prototype.hasOwnProperty, T = Array.isArray, u = console.createTask ? console.createTask : function() {
|
|
228
228
|
return null;
|
|
229
229
|
};
|
|
230
|
-
|
|
231
|
-
react_stack_bottom_frame: function(
|
|
232
|
-
return
|
|
230
|
+
h = {
|
|
231
|
+
react_stack_bottom_frame: function(l) {
|
|
232
|
+
return l();
|
|
233
233
|
}
|
|
234
234
|
};
|
|
235
|
-
var
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
)(),
|
|
239
|
-
|
|
240
|
-
var
|
|
241
|
-
return
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
235
|
+
var g, m = {}, V = h.react_stack_bottom_frame.bind(
|
|
236
|
+
h,
|
|
237
|
+
p
|
|
238
|
+
)(), Y = u(b(p)), R = {};
|
|
239
|
+
oe.Fragment = z, oe.jsx = function(l, w, P) {
|
|
240
|
+
var $ = 1e4 > d.recentlyCreatedOwnerStacks++;
|
|
241
|
+
return F(
|
|
242
|
+
l,
|
|
243
|
+
w,
|
|
244
|
+
P,
|
|
245
245
|
!1,
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
$ ? Error("react-stack-top-frame") : V,
|
|
247
|
+
$ ? u(b(l)) : Y
|
|
248
248
|
);
|
|
249
|
-
},
|
|
250
|
-
var
|
|
251
|
-
return
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
}, oe.jsxs = function(l, w, P) {
|
|
250
|
+
var $ = 1e4 > d.recentlyCreatedOwnerStacks++;
|
|
251
|
+
return F(
|
|
252
|
+
l,
|
|
253
|
+
w,
|
|
254
|
+
P,
|
|
255
255
|
!0,
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
$ ? Error("react-stack-top-frame") : V,
|
|
257
|
+
$ ? u(b(l)) : Y
|
|
258
258
|
);
|
|
259
259
|
};
|
|
260
|
-
})()),
|
|
260
|
+
})()), oe;
|
|
261
261
|
}
|
|
262
|
-
var
|
|
263
|
-
function
|
|
264
|
-
return
|
|
262
|
+
var je;
|
|
263
|
+
function et() {
|
|
264
|
+
return je || (je = 1, process.env.NODE_ENV === "production" ? de.exports = Ze() : de.exports = Ke()), de.exports;
|
|
265
265
|
}
|
|
266
|
-
var t =
|
|
267
|
-
const
|
|
266
|
+
var t = et();
|
|
267
|
+
const te = ({
|
|
268
268
|
label: e,
|
|
269
|
-
description:
|
|
270
|
-
collapsible:
|
|
271
|
-
collapsed:
|
|
272
|
-
columns:
|
|
273
|
-
children:
|
|
274
|
-
className:
|
|
269
|
+
description: r,
|
|
270
|
+
collapsible: i = !1,
|
|
271
|
+
collapsed: b = !1,
|
|
272
|
+
columns: o = 1,
|
|
273
|
+
children: p,
|
|
274
|
+
className: x,
|
|
275
|
+
gridClassName: E
|
|
275
276
|
}) => {
|
|
276
|
-
const [
|
|
277
|
+
const [I, O] = C(b), F = {
|
|
277
278
|
1: "grid-cols-1",
|
|
278
279
|
2: "grid-cols-1 md:grid-cols-2",
|
|
279
280
|
3: "grid-cols-1 md:grid-cols-2 lg:grid-cols-3",
|
|
280
281
|
4: "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
|
|
281
|
-
},
|
|
282
|
-
|
|
282
|
+
}, N = () => {
|
|
283
|
+
i && O(!I);
|
|
283
284
|
};
|
|
284
|
-
return /* @__PURE__ */ t.jsxs("div", { className:
|
|
285
|
-
(e ||
|
|
285
|
+
return /* @__PURE__ */ t.jsxs("div", { className: W("form-section", x), children: [
|
|
286
|
+
(e || r) && /* @__PURE__ */ t.jsxs(
|
|
286
287
|
"div",
|
|
287
288
|
{
|
|
288
|
-
className:
|
|
289
|
+
className: W(
|
|
289
290
|
"flex items-start gap-2 mb-4",
|
|
290
|
-
|
|
291
|
+
i && "cursor-pointer select-none"
|
|
291
292
|
),
|
|
292
|
-
onClick:
|
|
293
|
-
role:
|
|
294
|
-
"aria-expanded":
|
|
293
|
+
onClick: N,
|
|
294
|
+
role: i ? "button" : void 0,
|
|
295
|
+
"aria-expanded": i ? !I : void 0,
|
|
295
296
|
children: [
|
|
296
|
-
|
|
297
|
+
i && /* @__PURE__ */ t.jsx("span", { className: "mt-0.5 text-muted-foreground", children: I ? /* @__PURE__ */ t.jsx(Te, { className: "h-4 w-4" }) : /* @__PURE__ */ t.jsx(Je, { className: "h-4 w-4" }) }),
|
|
297
298
|
/* @__PURE__ */ t.jsxs("div", { className: "flex-1", children: [
|
|
298
299
|
e && /* @__PURE__ */ t.jsx("h3", { className: "text-base font-semibold text-foreground", children: e }),
|
|
299
|
-
|
|
300
|
+
r && /* @__PURE__ */ t.jsx("p", { className: "text-sm text-muted-foreground mt-0.5", children: r })
|
|
300
301
|
] })
|
|
301
302
|
]
|
|
302
303
|
}
|
|
303
304
|
),
|
|
304
|
-
!
|
|
305
|
+
!I && /* @__PURE__ */ t.jsx("div", { className: W("grid gap-4", E || F[o]), children: p })
|
|
305
306
|
] });
|
|
306
|
-
},
|
|
307
|
+
}, tt = ({
|
|
307
308
|
schema: e,
|
|
308
|
-
dataSource:
|
|
309
|
-
className:
|
|
309
|
+
dataSource: r,
|
|
310
|
+
className: i
|
|
310
311
|
}) => {
|
|
311
|
-
const [
|
|
312
|
+
const { fieldLabel: b } = ee(), [o, p] = C(null), [x, E] = C({}), [I, O] = C(!0), [F, N] = C(null), [j, h] = C(
|
|
312
313
|
e.defaultTab || e.sections[0]?.name || e.sections[0]?.label || "tab-0"
|
|
313
314
|
);
|
|
314
|
-
|
|
315
|
+
K.useEffect(() => {
|
|
315
316
|
(async () => {
|
|
316
|
-
if (!
|
|
317
|
-
|
|
317
|
+
if (!r) {
|
|
318
|
+
O(!1);
|
|
318
319
|
return;
|
|
319
320
|
}
|
|
320
321
|
try {
|
|
321
|
-
const n = await
|
|
322
|
-
|
|
322
|
+
const n = await r.getObjectSchema(e.objectName);
|
|
323
|
+
p(n);
|
|
323
324
|
} catch (n) {
|
|
324
|
-
|
|
325
|
+
N(n);
|
|
325
326
|
}
|
|
326
327
|
})();
|
|
327
|
-
}, [e.objectName,
|
|
328
|
-
(
|
|
329
|
-
if (e.mode === "create" || !e.recordId || !
|
|
330
|
-
|
|
328
|
+
}, [e.objectName, r]), K.useEffect(() => {
|
|
329
|
+
(o || !r) && (async () => {
|
|
330
|
+
if (e.mode === "create" || !e.recordId || !r) {
|
|
331
|
+
E(e.initialData || e.initialValues || {}), O(!1);
|
|
331
332
|
return;
|
|
332
333
|
}
|
|
333
334
|
try {
|
|
334
|
-
const n = await
|
|
335
|
-
|
|
335
|
+
const n = await r.findOne(e.objectName, e.recordId);
|
|
336
|
+
E(n || {});
|
|
336
337
|
} catch (n) {
|
|
337
|
-
|
|
338
|
+
N(n);
|
|
338
339
|
} finally {
|
|
339
|
-
|
|
340
|
+
O(!1);
|
|
340
341
|
}
|
|
341
342
|
})();
|
|
342
|
-
}, [
|
|
343
|
-
const
|
|
343
|
+
}, [o, e.mode, e.recordId, e.initialData, e.initialValues, r, e.objectName]);
|
|
344
|
+
const v = A((f) => {
|
|
344
345
|
const n = [];
|
|
345
|
-
for (const
|
|
346
|
-
const
|
|
347
|
-
if (typeof
|
|
348
|
-
n.push(
|
|
349
|
-
else if (
|
|
350
|
-
const c =
|
|
346
|
+
for (const a of f.fields) {
|
|
347
|
+
const s = typeof a == "string" ? a : a.name;
|
|
348
|
+
if (typeof a == "object")
|
|
349
|
+
n.push(a);
|
|
350
|
+
else if (o?.fields?.[s]) {
|
|
351
|
+
const c = o.fields[s];
|
|
351
352
|
n.push({
|
|
352
|
-
name:
|
|
353
|
-
label: c.label ||
|
|
354
|
-
type:
|
|
353
|
+
name: s,
|
|
354
|
+
label: b(e.objectName, s, c.label || s),
|
|
355
|
+
type: X(c.type),
|
|
355
356
|
required: c.required || !1,
|
|
356
357
|
disabled: e.readOnly || e.mode === "view" || c.readonly,
|
|
357
358
|
placeholder: c.placeholder,
|
|
358
359
|
description: c.help || c.description,
|
|
359
|
-
validation:
|
|
360
|
+
validation: B(c),
|
|
360
361
|
field: c,
|
|
361
362
|
options: c.options,
|
|
362
363
|
multiple: c.multiple
|
|
363
364
|
});
|
|
364
365
|
} else
|
|
365
366
|
n.push({
|
|
366
|
-
name:
|
|
367
|
-
label:
|
|
367
|
+
name: s,
|
|
368
|
+
label: s,
|
|
368
369
|
type: "input"
|
|
369
370
|
});
|
|
370
371
|
}
|
|
371
372
|
return n;
|
|
372
|
-
}, [
|
|
373
|
-
if (!
|
|
374
|
-
return e.onSuccess && await e.onSuccess(
|
|
373
|
+
}, [o, e.readOnly, e.mode]), D = A(async (f) => {
|
|
374
|
+
if (!r)
|
|
375
|
+
return e.onSuccess && await e.onSuccess(f), f;
|
|
375
376
|
try {
|
|
376
377
|
let n;
|
|
377
|
-
return e.mode === "create" ? n = await
|
|
378
|
+
return e.mode === "create" ? n = await r.create(e.objectName, f) : e.mode === "edit" && e.recordId && (n = await r.update(e.objectName, e.recordId, f)), e.onSuccess && await e.onSuccess(n), n;
|
|
378
379
|
} catch (n) {
|
|
379
380
|
throw e.onError && e.onError(n), n;
|
|
380
381
|
}
|
|
381
|
-
}, [e,
|
|
382
|
+
}, [e, r]), z = A(() => {
|
|
382
383
|
e.onCancel && e.onCancel();
|
|
383
|
-
}, [e]),
|
|
384
|
-
if (
|
|
384
|
+
}, [e]), L = (f, n) => f.name || f.label || `tab-${n}`;
|
|
385
|
+
if (F)
|
|
385
386
|
return /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
386
387
|
/* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
|
|
387
|
-
/* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children:
|
|
388
|
+
/* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: F.message })
|
|
388
389
|
] });
|
|
389
|
-
if (
|
|
390
|
+
if (I)
|
|
390
391
|
return /* @__PURE__ */ t.jsxs("div", { className: "p-8 text-center", children: [
|
|
391
392
|
/* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
|
|
392
393
|
/* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
|
|
393
394
|
] });
|
|
394
|
-
const
|
|
395
|
+
const U = {
|
|
395
396
|
type: "form",
|
|
396
|
-
fields: e.sections.flatMap((
|
|
397
|
+
fields: e.sections.flatMap((f) => v(f)),
|
|
397
398
|
layout: "vertical",
|
|
398
|
-
defaultValues:
|
|
399
|
+
defaultValues: x,
|
|
399
400
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
400
401
|
cancelLabel: e.cancelText,
|
|
401
402
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
402
403
|
showCancel: e.showCancel !== !1,
|
|
403
|
-
onSubmit:
|
|
404
|
-
onCancel:
|
|
405
|
-
},
|
|
406
|
-
return /* @__PURE__ */ t.jsx("div", { className:
|
|
407
|
-
|
|
404
|
+
onSubmit: D,
|
|
405
|
+
onCancel: z
|
|
406
|
+
}, M = e.tabPosition === "left" || e.tabPosition === "right";
|
|
407
|
+
return /* @__PURE__ */ t.jsx("div", { className: W("w-full", i, e.className), children: /* @__PURE__ */ t.jsxs(
|
|
408
|
+
ke,
|
|
408
409
|
{
|
|
409
|
-
value:
|
|
410
|
-
onValueChange:
|
|
411
|
-
orientation:
|
|
412
|
-
className:
|
|
410
|
+
value: j,
|
|
411
|
+
onValueChange: h,
|
|
412
|
+
orientation: M ? "vertical" : "horizontal",
|
|
413
|
+
className: W(M && "flex gap-4"),
|
|
413
414
|
children: [
|
|
414
|
-
/* @__PURE__ */ t.jsx(
|
|
415
|
-
|
|
415
|
+
/* @__PURE__ */ t.jsx(_e, { className: W(
|
|
416
|
+
M ? "flex-col h-auto" : "",
|
|
416
417
|
e.tabPosition === "bottom" && "order-last",
|
|
417
418
|
e.tabPosition === "right" && "order-last"
|
|
418
|
-
), children: e.sections.map((
|
|
419
|
-
|
|
419
|
+
), children: e.sections.map((f, n) => /* @__PURE__ */ t.jsx(
|
|
420
|
+
Ie,
|
|
420
421
|
{
|
|
421
|
-
value:
|
|
422
|
-
className:
|
|
423
|
-
children:
|
|
422
|
+
value: L(f, n),
|
|
423
|
+
className: M ? "w-full justify-start" : "",
|
|
424
|
+
children: f.label || `Tab ${n + 1}`
|
|
424
425
|
},
|
|
425
|
-
|
|
426
|
+
L(f, n)
|
|
426
427
|
)) }),
|
|
427
|
-
/* @__PURE__ */ t.jsx("div", { className: "flex-1", children: e.sections.map((
|
|
428
|
-
|
|
428
|
+
/* @__PURE__ */ t.jsx("div", { className: "flex-1", children: e.sections.map((f, n) => /* @__PURE__ */ t.jsx(
|
|
429
|
+
Le,
|
|
429
430
|
{
|
|
430
|
-
value:
|
|
431
|
+
value: L(f, n),
|
|
431
432
|
className: "mt-0",
|
|
432
433
|
children: /* @__PURE__ */ t.jsx(
|
|
433
|
-
|
|
434
|
+
te,
|
|
434
435
|
{
|
|
435
|
-
description:
|
|
436
|
-
columns:
|
|
436
|
+
description: f.description,
|
|
437
|
+
columns: f.columns || 1,
|
|
437
438
|
children: /* @__PURE__ */ t.jsx(
|
|
438
|
-
|
|
439
|
+
J,
|
|
439
440
|
{
|
|
440
441
|
schema: {
|
|
441
|
-
...
|
|
442
|
-
fields:
|
|
442
|
+
...U,
|
|
443
|
+
fields: v(f),
|
|
443
444
|
// Only show buttons on the last tab or always visible
|
|
444
445
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
445
446
|
showCancel: e.showCancel !== !1
|
|
@@ -449,123 +450,123 @@ const G = ({
|
|
|
449
450
|
}
|
|
450
451
|
)
|
|
451
452
|
},
|
|
452
|
-
|
|
453
|
+
L(f, n)
|
|
453
454
|
)) })
|
|
454
455
|
]
|
|
455
456
|
}
|
|
456
457
|
) });
|
|
457
|
-
},
|
|
458
|
+
}, rt = ({
|
|
458
459
|
schema: e,
|
|
459
|
-
dataSource:
|
|
460
|
-
className:
|
|
460
|
+
dataSource: r,
|
|
461
|
+
className: i
|
|
461
462
|
}) => {
|
|
462
|
-
const [
|
|
463
|
-
|
|
463
|
+
const { fieldLabel: b } = ee(), [o, p] = C(null), [x, E] = C({}), [I, O] = C(!0), [F, N] = C(null), [j, h] = C(0), [v, D] = C(/* @__PURE__ */ new Set()), [z, L] = C(!1), k = e.sections.length, U = j === 0, M = j === k - 1;
|
|
464
|
+
K.useEffect(() => {
|
|
464
465
|
(async () => {
|
|
465
|
-
if (!
|
|
466
|
-
|
|
466
|
+
if (!r) {
|
|
467
|
+
O(!1);
|
|
467
468
|
return;
|
|
468
469
|
}
|
|
469
470
|
try {
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
} catch (
|
|
473
|
-
|
|
471
|
+
const T = await r.getObjectSchema(e.objectName);
|
|
472
|
+
p(T);
|
|
473
|
+
} catch (T) {
|
|
474
|
+
N(T);
|
|
474
475
|
}
|
|
475
476
|
})();
|
|
476
|
-
}, [e.objectName,
|
|
477
|
-
(
|
|
478
|
-
if (e.mode === "create" || !e.recordId || !
|
|
479
|
-
|
|
477
|
+
}, [e.objectName, r]), K.useEffect(() => {
|
|
478
|
+
(o || !r) && (async () => {
|
|
479
|
+
if (e.mode === "create" || !e.recordId || !r) {
|
|
480
|
+
E(e.initialData || e.initialValues || {}), O(!1);
|
|
480
481
|
return;
|
|
481
482
|
}
|
|
482
483
|
try {
|
|
483
|
-
const
|
|
484
|
-
T
|
|
485
|
-
} catch (
|
|
486
|
-
|
|
484
|
+
const T = await r.findOne(e.objectName, e.recordId);
|
|
485
|
+
E(T || {});
|
|
486
|
+
} catch (T) {
|
|
487
|
+
N(T);
|
|
487
488
|
} finally {
|
|
488
|
-
|
|
489
|
+
O(!1);
|
|
489
490
|
}
|
|
490
491
|
})();
|
|
491
|
-
}, [
|
|
492
|
-
const
|
|
493
|
-
const
|
|
494
|
-
for (const
|
|
495
|
-
const
|
|
496
|
-
if (typeof
|
|
497
|
-
|
|
498
|
-
else if (
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
name:
|
|
502
|
-
label:
|
|
503
|
-
type:
|
|
504
|
-
required:
|
|
505
|
-
disabled: e.readOnly || e.mode === "view" ||
|
|
506
|
-
placeholder:
|
|
507
|
-
description:
|
|
508
|
-
validation:
|
|
509
|
-
field:
|
|
510
|
-
options:
|
|
511
|
-
multiple:
|
|
492
|
+
}, [o, e.mode, e.recordId, e.initialData, e.initialValues, r, e.objectName]);
|
|
493
|
+
const f = A((_) => {
|
|
494
|
+
const T = [];
|
|
495
|
+
for (const u of _.fields) {
|
|
496
|
+
const g = typeof u == "string" ? u : u.name;
|
|
497
|
+
if (typeof u == "object")
|
|
498
|
+
T.push(u);
|
|
499
|
+
else if (o?.fields?.[g]) {
|
|
500
|
+
const m = o.fields[g];
|
|
501
|
+
T.push({
|
|
502
|
+
name: g,
|
|
503
|
+
label: b(e.objectName, g, m.label || g),
|
|
504
|
+
type: X(m.type),
|
|
505
|
+
required: m.required || !1,
|
|
506
|
+
disabled: e.readOnly || e.mode === "view" || m.readonly,
|
|
507
|
+
placeholder: m.placeholder,
|
|
508
|
+
description: m.help || m.description,
|
|
509
|
+
validation: B(m),
|
|
510
|
+
field: m,
|
|
511
|
+
options: m.options,
|
|
512
|
+
multiple: m.multiple
|
|
512
513
|
});
|
|
513
514
|
} else
|
|
514
|
-
|
|
515
|
-
name:
|
|
516
|
-
label:
|
|
515
|
+
T.push({
|
|
516
|
+
name: g,
|
|
517
|
+
label: g,
|
|
517
518
|
type: "input"
|
|
518
519
|
});
|
|
519
520
|
}
|
|
520
|
-
return
|
|
521
|
-
}, [
|
|
522
|
-
const
|
|
523
|
-
if (T
|
|
524
|
-
|
|
521
|
+
return T;
|
|
522
|
+
}, [o, e.readOnly, e.mode]), n = G(() => j >= 0 && j < k ? f(e.sections[j]) : [], [j, k, e.sections, f]), a = A(async (_) => {
|
|
523
|
+
const T = { ...x, ..._ };
|
|
524
|
+
if (E(T), D((u) => new Set(u).add(j)), M) {
|
|
525
|
+
L(!0);
|
|
525
526
|
try {
|
|
526
|
-
if (!
|
|
527
|
-
return e.onSuccess && await e.onSuccess(
|
|
528
|
-
let
|
|
529
|
-
return e.mode === "create" ?
|
|
530
|
-
} catch (
|
|
531
|
-
throw e.onError && e.onError(
|
|
527
|
+
if (!r)
|
|
528
|
+
return e.onSuccess && await e.onSuccess(T), T;
|
|
529
|
+
let u;
|
|
530
|
+
return e.mode === "create" ? u = await r.create(e.objectName, T) : e.mode === "edit" && e.recordId && (u = await r.update(e.objectName, e.recordId, T)), e.onSuccess && await e.onSuccess(u), u;
|
|
531
|
+
} catch (u) {
|
|
532
|
+
throw e.onError && e.onError(u), u;
|
|
532
533
|
} finally {
|
|
533
|
-
|
|
534
|
+
L(!1);
|
|
534
535
|
}
|
|
535
536
|
} else
|
|
536
|
-
|
|
537
|
-
}, [
|
|
538
|
-
|
|
539
|
-
}, [
|
|
540
|
-
|
|
541
|
-
}, [
|
|
537
|
+
s(j + 1);
|
|
538
|
+
}, [x, j, M, e, r]), s = A((_) => {
|
|
539
|
+
_ >= 0 && _ < k && (h(_), e.onStepChange && e.onStepChange(_));
|
|
540
|
+
}, [k, e]), c = A(() => {
|
|
541
|
+
s(j - 1);
|
|
542
|
+
}, [j, s]), S = A(() => {
|
|
542
543
|
e.onCancel && e.onCancel();
|
|
543
|
-
}, [e]),
|
|
544
|
-
(e.allowSkip ||
|
|
545
|
-
}, [e.allowSkip,
|
|
546
|
-
if (
|
|
544
|
+
}, [e]), y = A((_) => {
|
|
545
|
+
(e.allowSkip || v.has(_) || _ <= j) && s(_);
|
|
546
|
+
}, [e.allowSkip, v, j, s]);
|
|
547
|
+
if (F)
|
|
547
548
|
return /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
548
549
|
/* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
|
|
549
|
-
/* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children:
|
|
550
|
+
/* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: F.message })
|
|
550
551
|
] });
|
|
551
|
-
if (
|
|
552
|
+
if (I)
|
|
552
553
|
return /* @__PURE__ */ t.jsxs("div", { className: "p-8 text-center", children: [
|
|
553
554
|
/* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
|
|
554
555
|
/* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
|
|
555
556
|
] });
|
|
556
|
-
const
|
|
557
|
-
return /* @__PURE__ */ t.jsxs("div", { className:
|
|
558
|
-
e.showStepIndicator !== !1 && /* @__PURE__ */ t.jsx("nav", { "aria-label": "Progress", className: "mb-8", children: /* @__PURE__ */ t.jsx("ol", { className: "flex items-center", children: e.sections.map((
|
|
559
|
-
const
|
|
557
|
+
const d = e.sections[j];
|
|
558
|
+
return /* @__PURE__ */ t.jsxs("div", { className: W("w-full", i, e.className), children: [
|
|
559
|
+
e.showStepIndicator !== !1 && /* @__PURE__ */ t.jsx("nav", { "aria-label": "Progress", className: "mb-8", children: /* @__PURE__ */ t.jsx("ol", { className: "flex items-center", children: e.sections.map((_, T) => {
|
|
560
|
+
const u = T === j, g = v.has(T), m = e.allowSkip || g || T <= j;
|
|
560
561
|
return /* @__PURE__ */ t.jsxs(
|
|
561
562
|
"li",
|
|
562
563
|
{
|
|
563
|
-
className:
|
|
564
|
+
className: W(
|
|
564
565
|
"relative flex-1",
|
|
565
|
-
|
|
566
|
+
T !== k - 1 && "pr-8 sm:pr-12"
|
|
566
567
|
),
|
|
567
568
|
children: [
|
|
568
|
-
|
|
569
|
+
T !== k - 1 && /* @__PURE__ */ t.jsx(
|
|
569
570
|
"div",
|
|
570
571
|
{
|
|
571
572
|
className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
|
|
@@ -573,9 +574,9 @@ const G = ({
|
|
|
573
574
|
children: /* @__PURE__ */ t.jsx(
|
|
574
575
|
"div",
|
|
575
576
|
{
|
|
576
|
-
className:
|
|
577
|
+
className: W(
|
|
577
578
|
"h-full",
|
|
578
|
-
|
|
579
|
+
g ? "bg-primary" : "bg-muted"
|
|
579
580
|
)
|
|
580
581
|
}
|
|
581
582
|
)
|
|
@@ -585,32 +586,32 @@ const G = ({
|
|
|
585
586
|
"button",
|
|
586
587
|
{
|
|
587
588
|
type: "button",
|
|
588
|
-
className:
|
|
589
|
+
className: W(
|
|
589
590
|
"group relative flex items-center",
|
|
590
|
-
|
|
591
|
+
m ? "cursor-pointer" : "cursor-not-allowed"
|
|
591
592
|
),
|
|
592
|
-
onClick: () =>
|
|
593
|
-
disabled: !
|
|
593
|
+
onClick: () => y(T),
|
|
594
|
+
disabled: !m,
|
|
594
595
|
children: [
|
|
595
596
|
/* @__PURE__ */ t.jsx(
|
|
596
597
|
"span",
|
|
597
598
|
{
|
|
598
|
-
className:
|
|
599
|
+
className: W(
|
|
599
600
|
"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",
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
!
|
|
601
|
+
g && "bg-primary text-primary-foreground",
|
|
602
|
+
u && !g && "border-2 border-primary bg-background text-primary",
|
|
603
|
+
!u && !g && "border-2 border-muted bg-background text-muted-foreground"
|
|
603
604
|
),
|
|
604
|
-
children:
|
|
605
|
+
children: g ? /* @__PURE__ */ t.jsx(Be, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : T + 1
|
|
605
606
|
}
|
|
606
607
|
),
|
|
607
608
|
/* @__PURE__ */ t.jsx("span", { className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block", children: /* @__PURE__ */ t.jsx(
|
|
608
609
|
"span",
|
|
609
610
|
{
|
|
610
|
-
className:
|
|
611
|
-
|
|
611
|
+
className: W(
|
|
612
|
+
u ? "text-foreground" : "text-muted-foreground"
|
|
612
613
|
),
|
|
613
|
-
children:
|
|
614
|
+
children: _.label || `Step ${T + 1}`
|
|
614
615
|
}
|
|
615
616
|
) })
|
|
616
617
|
]
|
|
@@ -618,26 +619,26 @@ const G = ({
|
|
|
618
619
|
)
|
|
619
620
|
]
|
|
620
621
|
},
|
|
621
|
-
|
|
622
|
+
T
|
|
622
623
|
);
|
|
623
624
|
}) }) }),
|
|
624
|
-
/* @__PURE__ */ t.jsx("div", { className: "min-h-[200px]", children:
|
|
625
|
-
|
|
625
|
+
/* @__PURE__ */ t.jsx("div", { className: "min-h-[200px]", children: d && /* @__PURE__ */ t.jsx(
|
|
626
|
+
te,
|
|
626
627
|
{
|
|
627
|
-
label:
|
|
628
|
-
description:
|
|
629
|
-
columns:
|
|
628
|
+
label: d.label,
|
|
629
|
+
description: d.description,
|
|
630
|
+
columns: d.columns || 1,
|
|
630
631
|
children: n.length > 0 ? /* @__PURE__ */ t.jsx(
|
|
631
|
-
|
|
632
|
+
J,
|
|
632
633
|
{
|
|
633
634
|
schema: {
|
|
634
635
|
type: "form",
|
|
635
636
|
fields: n,
|
|
636
637
|
layout: "vertical",
|
|
637
|
-
defaultValues:
|
|
638
|
+
defaultValues: x,
|
|
638
639
|
showSubmit: !1,
|
|
639
640
|
showCancel: !1,
|
|
640
|
-
onSubmit:
|
|
641
|
+
onSubmit: a
|
|
641
642
|
}
|
|
642
643
|
}
|
|
643
644
|
) : /* @__PURE__ */ t.jsx("div", { className: "text-center py-8 text-muted-foreground", children: "No fields configured for this step" })
|
|
@@ -645,164 +646,164 @@ const G = ({
|
|
|
645
646
|
) }),
|
|
646
647
|
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between mt-6 pt-4 border-t", children: [
|
|
647
648
|
/* @__PURE__ */ t.jsx("div", { children: e.showCancel !== !1 && /* @__PURE__ */ t.jsx(
|
|
648
|
-
|
|
649
|
+
Z,
|
|
649
650
|
{
|
|
650
651
|
variant: "ghost",
|
|
651
|
-
onClick:
|
|
652
|
+
onClick: S,
|
|
652
653
|
children: e.cancelText || "Cancel"
|
|
653
654
|
}
|
|
654
655
|
) }),
|
|
655
656
|
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
656
657
|
/* @__PURE__ */ t.jsxs("span", { className: "text-sm text-muted-foreground mr-2", children: [
|
|
657
658
|
"Step ",
|
|
658
|
-
|
|
659
|
+
j + 1,
|
|
659
660
|
" of ",
|
|
660
|
-
|
|
661
|
+
k
|
|
661
662
|
] }),
|
|
662
|
-
!
|
|
663
|
-
|
|
663
|
+
!U && /* @__PURE__ */ t.jsxs(
|
|
664
|
+
Z,
|
|
664
665
|
{
|
|
665
666
|
variant: "outline",
|
|
666
667
|
onClick: c,
|
|
667
668
|
children: [
|
|
668
|
-
/* @__PURE__ */ t.jsx(
|
|
669
|
+
/* @__PURE__ */ t.jsx(Xe, { className: "h-4 w-4 mr-1" }),
|
|
669
670
|
e.prevText || "Back"
|
|
670
671
|
]
|
|
671
672
|
}
|
|
672
673
|
),
|
|
673
|
-
|
|
674
|
-
|
|
674
|
+
M ? /* @__PURE__ */ t.jsx(
|
|
675
|
+
Z,
|
|
675
676
|
{
|
|
676
|
-
onClick: () =>
|
|
677
|
-
disabled:
|
|
678
|
-
children:
|
|
677
|
+
onClick: () => a(x),
|
|
678
|
+
disabled: z || e.mode === "view",
|
|
679
|
+
children: z ? "Submitting..." : e.submitText || (e.mode === "create" ? "Create" : "Update")
|
|
679
680
|
}
|
|
680
681
|
) : /* @__PURE__ */ t.jsxs(
|
|
681
|
-
|
|
682
|
+
Z,
|
|
682
683
|
{
|
|
683
|
-
onClick: () =>
|
|
684
|
+
onClick: () => a(x),
|
|
684
685
|
children: [
|
|
685
686
|
e.nextText || "Next",
|
|
686
|
-
/* @__PURE__ */ t.jsx(
|
|
687
|
+
/* @__PURE__ */ t.jsx(Te, { className: "h-4 w-4 ml-1" })
|
|
687
688
|
]
|
|
688
689
|
}
|
|
689
690
|
)
|
|
690
691
|
] })
|
|
691
692
|
] })
|
|
692
693
|
] });
|
|
693
|
-
},
|
|
694
|
+
}, lt = ({
|
|
694
695
|
schema: e,
|
|
695
|
-
dataSource:
|
|
696
|
-
className:
|
|
696
|
+
dataSource: r,
|
|
697
|
+
className: i
|
|
697
698
|
}) => {
|
|
698
|
-
const [
|
|
699
|
-
|
|
699
|
+
const { fieldLabel: b } = ee(), [o, p] = C(null), [x, E] = C({}), [I, O] = C(!0), [F, N] = C(null);
|
|
700
|
+
H(() => {
|
|
700
701
|
(async () => {
|
|
701
|
-
if (!
|
|
702
|
-
|
|
702
|
+
if (!r) {
|
|
703
|
+
O(!1);
|
|
703
704
|
return;
|
|
704
705
|
}
|
|
705
706
|
try {
|
|
706
|
-
const n = await
|
|
707
|
-
|
|
707
|
+
const n = await r.getObjectSchema(e.objectName);
|
|
708
|
+
p(n);
|
|
708
709
|
} catch (n) {
|
|
709
|
-
|
|
710
|
+
N(n), O(!1);
|
|
710
711
|
}
|
|
711
712
|
})();
|
|
712
|
-
}, [e.objectName,
|
|
713
|
-
(
|
|
713
|
+
}, [e.objectName, r]), H(() => {
|
|
714
|
+
(o || !r) && (async () => {
|
|
714
715
|
if (e.mode === "create" || !e.recordId) {
|
|
715
|
-
|
|
716
|
+
E(e.initialData || e.initialValues || {}), O(!1);
|
|
716
717
|
return;
|
|
717
718
|
}
|
|
718
|
-
if (!
|
|
719
|
-
|
|
719
|
+
if (!r) {
|
|
720
|
+
E(e.initialData || e.initialValues || {}), O(!1);
|
|
720
721
|
return;
|
|
721
722
|
}
|
|
722
723
|
try {
|
|
723
|
-
const n = await
|
|
724
|
-
|
|
724
|
+
const n = await r.findOne(e.objectName, e.recordId);
|
|
725
|
+
E(n || {});
|
|
725
726
|
} catch (n) {
|
|
726
|
-
|
|
727
|
+
N(n);
|
|
727
728
|
} finally {
|
|
728
|
-
|
|
729
|
+
O(!1);
|
|
729
730
|
}
|
|
730
731
|
})();
|
|
731
|
-
}, [
|
|
732
|
-
const
|
|
732
|
+
}, [o, e.mode, e.recordId, e.initialData, e.initialValues, r, e.objectName]);
|
|
733
|
+
const j = A((f) => {
|
|
733
734
|
const n = [];
|
|
734
|
-
for (const
|
|
735
|
-
const
|
|
736
|
-
if (typeof
|
|
737
|
-
n.push(
|
|
738
|
-
else if (
|
|
739
|
-
const c =
|
|
735
|
+
for (const a of f.fields) {
|
|
736
|
+
const s = typeof a == "string" ? a : a.name;
|
|
737
|
+
if (typeof a == "object")
|
|
738
|
+
n.push(a);
|
|
739
|
+
else if (o?.fields?.[s]) {
|
|
740
|
+
const c = o.fields[s];
|
|
740
741
|
n.push({
|
|
741
|
-
name:
|
|
742
|
-
label: c.label ||
|
|
743
|
-
type:
|
|
742
|
+
name: s,
|
|
743
|
+
label: b(e.objectName, s, c.label || s),
|
|
744
|
+
type: X(c.type),
|
|
744
745
|
required: c.required || !1,
|
|
745
746
|
disabled: e.readOnly || e.mode === "view" || c.readonly,
|
|
746
747
|
placeholder: c.placeholder,
|
|
747
748
|
description: c.help || c.description,
|
|
748
|
-
validation:
|
|
749
|
+
validation: B(c),
|
|
749
750
|
field: c,
|
|
750
751
|
options: c.options,
|
|
751
752
|
multiple: c.multiple
|
|
752
753
|
});
|
|
753
754
|
} else
|
|
754
755
|
n.push({
|
|
755
|
-
name:
|
|
756
|
-
label:
|
|
756
|
+
name: s,
|
|
757
|
+
label: s,
|
|
757
758
|
type: "input"
|
|
758
759
|
});
|
|
759
760
|
}
|
|
760
761
|
return n;
|
|
761
|
-
}, [
|
|
762
|
-
if (!
|
|
763
|
-
return e.onSuccess && await e.onSuccess(
|
|
762
|
+
}, [o, e.readOnly, e.mode]), h = A(async (f) => {
|
|
763
|
+
if (!r)
|
|
764
|
+
return e.onSuccess && await e.onSuccess(f), f;
|
|
764
765
|
try {
|
|
765
766
|
let n;
|
|
766
|
-
return e.mode === "create" ? n = await
|
|
767
|
+
return e.mode === "create" ? n = await r.create(e.objectName, f) : e.mode === "edit" && e.recordId && (n = await r.update(e.objectName, e.recordId, f)), e.onSuccess && await e.onSuccess(n), n;
|
|
767
768
|
} catch (n) {
|
|
768
769
|
throw e.onError && e.onError(n), n;
|
|
769
770
|
}
|
|
770
|
-
}, [e,
|
|
771
|
+
}, [e, r]), v = A(() => {
|
|
771
772
|
e.onCancel && e.onCancel();
|
|
772
|
-
}, [e]),
|
|
773
|
-
|
|
774
|
-
() => e.sections.flatMap((
|
|
775
|
-
[e.sections,
|
|
773
|
+
}, [e]), D = G(() => e.sections.slice(0, 1), [e.sections]), z = G(() => e.sections.slice(1), [e.sections]);
|
|
774
|
+
G(
|
|
775
|
+
() => e.sections.flatMap((f) => j(f)),
|
|
776
|
+
[e.sections, j]
|
|
776
777
|
);
|
|
777
|
-
const
|
|
778
|
-
if (
|
|
778
|
+
const L = e.splitDirection || "horizontal", k = e.splitSize || 50;
|
|
779
|
+
if (F)
|
|
779
780
|
return /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
780
781
|
/* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
|
|
781
|
-
/* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children:
|
|
782
|
+
/* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: F.message })
|
|
782
783
|
] });
|
|
783
|
-
if (
|
|
784
|
+
if (I)
|
|
784
785
|
return /* @__PURE__ */ t.jsxs("div", { className: "p-8 text-center", children: [
|
|
785
786
|
/* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
|
|
786
787
|
/* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
|
|
787
788
|
] });
|
|
788
|
-
const
|
|
789
|
+
const U = {
|
|
789
790
|
type: "form",
|
|
790
791
|
layout: "vertical",
|
|
791
|
-
defaultValues:
|
|
792
|
-
onSubmit:
|
|
793
|
-
onCancel:
|
|
794
|
-
},
|
|
795
|
-
|
|
792
|
+
defaultValues: x,
|
|
793
|
+
onSubmit: h,
|
|
794
|
+
onCancel: v
|
|
795
|
+
}, M = (f, n) => /* @__PURE__ */ t.jsx("div", { className: "space-y-4 p-4", children: f.map((a, s) => /* @__PURE__ */ t.jsx(
|
|
796
|
+
te,
|
|
796
797
|
{
|
|
797
|
-
label:
|
|
798
|
-
description:
|
|
799
|
-
columns:
|
|
798
|
+
label: a.label,
|
|
799
|
+
description: a.description,
|
|
800
|
+
columns: a.columns || 1,
|
|
800
801
|
children: /* @__PURE__ */ t.jsx(
|
|
801
|
-
|
|
802
|
+
J,
|
|
802
803
|
{
|
|
803
804
|
schema: {
|
|
804
|
-
...
|
|
805
|
-
fields:
|
|
805
|
+
...U,
|
|
806
|
+
fields: j(a),
|
|
806
807
|
showSubmit: n && e.showSubmit !== !1 && e.mode !== "view",
|
|
807
808
|
showCancel: n && e.showCancel !== !1,
|
|
808
809
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
@@ -811,395 +812,520 @@ const G = ({
|
|
|
811
812
|
}
|
|
812
813
|
)
|
|
813
814
|
},
|
|
814
|
-
|
|
815
|
+
a.name || a.label || s
|
|
815
816
|
)) });
|
|
816
|
-
return /* @__PURE__ */ t.jsx("div", { className:
|
|
817
|
-
/* @__PURE__ */ t.jsx(
|
|
818
|
-
|
|
819
|
-
/* @__PURE__ */ t.jsx(
|
|
820
|
-
/* @__PURE__ */ t.jsx(
|
|
817
|
+
return /* @__PURE__ */ t.jsx("div", { className: W("w-full", i, e.className), children: /* @__PURE__ */ t.jsxs(Pe, { orientation: L, className: "min-h-[300px] rounded-lg border", children: [
|
|
818
|
+
/* @__PURE__ */ t.jsx(be, { defaultSize: k, minSize: 20, children: M(D, z.length === 0) }),
|
|
819
|
+
z.length > 0 && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
820
|
+
/* @__PURE__ */ t.jsx(Ae, { withHandle: e.splitResizable !== !1 }),
|
|
821
|
+
/* @__PURE__ */ t.jsx(be, { defaultSize: 100 - k, minSize: 20, children: M(z, !0) })
|
|
821
822
|
] })
|
|
822
823
|
] }) });
|
|
823
|
-
},
|
|
824
|
+
}, nt = /* @__PURE__ */ new Set([
|
|
825
|
+
"field:textarea",
|
|
826
|
+
"field:markdown",
|
|
827
|
+
"field:html",
|
|
828
|
+
"field:grid",
|
|
829
|
+
"field:rich-text",
|
|
830
|
+
"textarea",
|
|
831
|
+
"markdown",
|
|
832
|
+
"html",
|
|
833
|
+
"grid",
|
|
834
|
+
"rich-text"
|
|
835
|
+
]), it = /* @__PURE__ */ new Set([
|
|
836
|
+
"formula",
|
|
837
|
+
"summary",
|
|
838
|
+
"auto_number",
|
|
839
|
+
"autonumber"
|
|
840
|
+
]);
|
|
841
|
+
function ot(e) {
|
|
842
|
+
return nt.has(e);
|
|
843
|
+
}
|
|
844
|
+
function st(e) {
|
|
845
|
+
return it.has(e);
|
|
846
|
+
}
|
|
847
|
+
function at(e) {
|
|
848
|
+
return e <= 3 ? 1 : 2;
|
|
849
|
+
}
|
|
850
|
+
function we(e, r) {
|
|
851
|
+
return r <= 1 ? e : e.map((i) => i.colSpan !== void 0 ? i : i.type && ot(i.type) ? { ...i, colSpan: r } : i);
|
|
852
|
+
}
|
|
853
|
+
function dt(e, r) {
|
|
854
|
+
return r?.fields ? e.filter((i) => {
|
|
855
|
+
const b = r.fields[i.name];
|
|
856
|
+
return b ? !st(b.type) : !0;
|
|
857
|
+
}) : e;
|
|
858
|
+
}
|
|
859
|
+
function Ne(e) {
|
|
860
|
+
return e <= 1 ? "default" : e === 2 ? "lg" : e === 3 ? "xl" : "full";
|
|
861
|
+
}
|
|
862
|
+
function ce(e, r, i, b) {
|
|
863
|
+
let o = [...e];
|
|
864
|
+
if (b === "create" && (o = dt(o, r)), i !== void 0)
|
|
865
|
+
return o = we(o, i), { fields: o, columns: i };
|
|
866
|
+
const p = at(o.length);
|
|
867
|
+
return o = we(o, p), { fields: o, columns: p };
|
|
868
|
+
}
|
|
869
|
+
const ve = {
|
|
870
|
+
1: void 0,
|
|
871
|
+
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
872
|
+
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
873
|
+
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
874
|
+
}, ct = ({
|
|
824
875
|
schema: e,
|
|
825
|
-
dataSource:
|
|
826
|
-
className:
|
|
876
|
+
dataSource: r,
|
|
877
|
+
className: i
|
|
827
878
|
}) => {
|
|
828
|
-
const [
|
|
829
|
-
|
|
879
|
+
const { fieldLabel: b } = ee(), [o, p] = C(null), [x, E] = C([]), [I, O] = C({}), [F, N] = C(!0), [j, h] = C(null), v = e.open !== !1, D = e.drawerSide || "right";
|
|
880
|
+
H(() => {
|
|
830
881
|
(async () => {
|
|
831
|
-
if (!
|
|
832
|
-
|
|
882
|
+
if (!r) {
|
|
883
|
+
N(!1);
|
|
833
884
|
return;
|
|
834
885
|
}
|
|
835
886
|
try {
|
|
836
|
-
const
|
|
837
|
-
|
|
838
|
-
} catch (
|
|
839
|
-
|
|
887
|
+
const s = await r.getObjectSchema(e.objectName);
|
|
888
|
+
p(s);
|
|
889
|
+
} catch (s) {
|
|
890
|
+
h(s), N(!1);
|
|
840
891
|
}
|
|
841
892
|
})();
|
|
842
|
-
}, [e.objectName,
|
|
843
|
-
(
|
|
893
|
+
}, [e.objectName, r]), H(() => {
|
|
894
|
+
(o || !r) && (async () => {
|
|
844
895
|
if (e.mode === "create" || !e.recordId) {
|
|
845
|
-
|
|
896
|
+
O(e.initialData || e.initialValues || {}), N(!1);
|
|
846
897
|
return;
|
|
847
898
|
}
|
|
848
|
-
if (!
|
|
849
|
-
|
|
899
|
+
if (!r) {
|
|
900
|
+
O(e.initialData || e.initialValues || {}), N(!1);
|
|
850
901
|
return;
|
|
851
902
|
}
|
|
852
903
|
try {
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
} catch (
|
|
856
|
-
|
|
904
|
+
const s = await r.findOne(e.objectName, e.recordId);
|
|
905
|
+
O(s || {});
|
|
906
|
+
} catch (s) {
|
|
907
|
+
h(s);
|
|
857
908
|
} finally {
|
|
858
|
-
|
|
909
|
+
N(!1);
|
|
859
910
|
}
|
|
860
911
|
})();
|
|
861
|
-
}, [
|
|
862
|
-
const
|
|
863
|
-
const
|
|
864
|
-
for (const c of
|
|
865
|
-
const
|
|
912
|
+
}, [o, e.mode, e.recordId, e.initialData, e.initialValues, r, e.objectName]);
|
|
913
|
+
const z = A((a) => {
|
|
914
|
+
const s = [];
|
|
915
|
+
for (const c of a.fields) {
|
|
916
|
+
const S = typeof c == "string" ? c : c.name;
|
|
866
917
|
if (typeof c == "object")
|
|
867
|
-
|
|
868
|
-
else if (
|
|
869
|
-
const
|
|
870
|
-
|
|
871
|
-
name:
|
|
872
|
-
label:
|
|
873
|
-
type:
|
|
874
|
-
required:
|
|
875
|
-
disabled: e.readOnly || e.mode === "view" ||
|
|
876
|
-
placeholder:
|
|
877
|
-
description:
|
|
878
|
-
validation:
|
|
879
|
-
field:
|
|
880
|
-
options:
|
|
881
|
-
multiple:
|
|
918
|
+
s.push(c);
|
|
919
|
+
else if (o?.fields?.[S]) {
|
|
920
|
+
const y = o.fields[S];
|
|
921
|
+
s.push({
|
|
922
|
+
name: S,
|
|
923
|
+
label: b(e.objectName, S, y.label || S),
|
|
924
|
+
type: X(y.type),
|
|
925
|
+
required: y.required || !1,
|
|
926
|
+
disabled: e.readOnly || e.mode === "view" || y.readonly,
|
|
927
|
+
placeholder: y.placeholder,
|
|
928
|
+
description: y.help || y.description,
|
|
929
|
+
validation: B(y),
|
|
930
|
+
field: y,
|
|
931
|
+
options: y.options,
|
|
932
|
+
multiple: y.multiple
|
|
882
933
|
});
|
|
883
934
|
} else
|
|
884
|
-
|
|
885
|
-
name:
|
|
886
|
-
label:
|
|
935
|
+
s.push({
|
|
936
|
+
name: S,
|
|
937
|
+
label: S,
|
|
887
938
|
type: "input"
|
|
888
939
|
});
|
|
889
940
|
}
|
|
890
|
-
return
|
|
891
|
-
}, [
|
|
892
|
-
|
|
893
|
-
if (!
|
|
941
|
+
return s;
|
|
942
|
+
}, [o, e.readOnly, e.mode]);
|
|
943
|
+
H(() => {
|
|
944
|
+
if (!o && r) return;
|
|
894
945
|
if (e.customFields?.length) {
|
|
895
|
-
|
|
946
|
+
E(e.customFields), N(!1);
|
|
896
947
|
return;
|
|
897
948
|
}
|
|
898
949
|
if (e.sections?.length) {
|
|
899
|
-
|
|
950
|
+
N(!1);
|
|
900
951
|
return;
|
|
901
952
|
}
|
|
902
|
-
if (!
|
|
903
|
-
const
|
|
904
|
-
for (const c of
|
|
905
|
-
const
|
|
906
|
-
if (!
|
|
907
|
-
const
|
|
908
|
-
|
|
909
|
-
name:
|
|
910
|
-
label:
|
|
911
|
-
type:
|
|
912
|
-
required:
|
|
913
|
-
disabled: e.readOnly || e.mode === "view" ||
|
|
914
|
-
placeholder:
|
|
915
|
-
description:
|
|
916
|
-
validation:
|
|
917
|
-
field:
|
|
918
|
-
options:
|
|
919
|
-
multiple:
|
|
953
|
+
if (!o) return;
|
|
954
|
+
const a = e.fields || Object.keys(o.fields || {}), s = [];
|
|
955
|
+
for (const c of a) {
|
|
956
|
+
const S = typeof c == "string" ? c : c.name;
|
|
957
|
+
if (!S) continue;
|
|
958
|
+
const y = o.fields?.[S];
|
|
959
|
+
y && s.push({
|
|
960
|
+
name: S,
|
|
961
|
+
label: b(e.objectName, S, y.label || S),
|
|
962
|
+
type: X(y.type),
|
|
963
|
+
required: y.required || !1,
|
|
964
|
+
disabled: e.readOnly || e.mode === "view" || y.readonly,
|
|
965
|
+
placeholder: y.placeholder,
|
|
966
|
+
description: y.help || y.description,
|
|
967
|
+
validation: B(y),
|
|
968
|
+
field: y,
|
|
969
|
+
options: y.options,
|
|
970
|
+
multiple: y.multiple
|
|
920
971
|
});
|
|
921
972
|
}
|
|
922
|
-
|
|
923
|
-
}, [
|
|
924
|
-
const
|
|
925
|
-
if (!
|
|
926
|
-
return e.onSuccess && await e.onSuccess(
|
|
973
|
+
E(s), N(!1);
|
|
974
|
+
}, [o, e.fields, e.customFields, e.sections, e.readOnly, e.mode, r]);
|
|
975
|
+
const L = A(async (a) => {
|
|
976
|
+
if (!r)
|
|
977
|
+
return e.onSuccess && await e.onSuccess(a), e.onOpenChange?.(!1), a;
|
|
927
978
|
try {
|
|
928
|
-
let
|
|
929
|
-
return e.mode === "create" ?
|
|
930
|
-
} catch (
|
|
931
|
-
throw e.onError && e.onError(
|
|
979
|
+
let s;
|
|
980
|
+
return e.mode === "create" ? s = await r.create(e.objectName, a) : e.mode === "edit" && e.recordId && (s = await r.update(e.objectName, e.recordId, a)), e.onSuccess && await e.onSuccess(s), e.onOpenChange?.(!1), s;
|
|
981
|
+
} catch (s) {
|
|
982
|
+
throw e.onError && e.onError(s), s;
|
|
932
983
|
}
|
|
933
|
-
}, [e,
|
|
984
|
+
}, [e, r]), k = A(() => {
|
|
934
985
|
e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
|
|
935
|
-
}, [e]),
|
|
986
|
+
}, [e]), U = G(() => e.drawerWidth ? D === "left" || D === "right" ? { width: e.drawerWidth, maxWidth: e.drawerWidth } : { height: e.drawerWidth, maxHeight: e.drawerWidth } : void 0, [e.drawerWidth, D]), f = {
|
|
936
987
|
type: "form",
|
|
937
988
|
layout: e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical",
|
|
938
|
-
defaultValues:
|
|
989
|
+
defaultValues: I,
|
|
939
990
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
940
991
|
cancelLabel: e.cancelText,
|
|
941
992
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
942
993
|
showCancel: e.showCancel !== !1,
|
|
943
|
-
onSubmit:
|
|
944
|
-
onCancel:
|
|
945
|
-
}, n = () =>
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
994
|
+
onSubmit: L,
|
|
995
|
+
onCancel: k
|
|
996
|
+
}, n = () => {
|
|
997
|
+
if (j)
|
|
998
|
+
return /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
999
|
+
/* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
|
|
1000
|
+
/* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: j.message })
|
|
1001
|
+
] });
|
|
1002
|
+
if (F)
|
|
1003
|
+
return /* @__PURE__ */ t.jsxs("div", { className: "p-8 text-center", children: [
|
|
1004
|
+
/* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
|
|
1005
|
+
/* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
|
|
1006
|
+
] });
|
|
1007
|
+
if (e.sections?.length)
|
|
1008
|
+
return /* @__PURE__ */ t.jsx("div", { className: "space-y-6", children: e.sections.map((c, S) => {
|
|
1009
|
+
const y = c.columns || 1;
|
|
1010
|
+
return /* @__PURE__ */ t.jsx(
|
|
1011
|
+
te,
|
|
1012
|
+
{
|
|
1013
|
+
label: c.label,
|
|
1014
|
+
description: c.description,
|
|
1015
|
+
columns: y,
|
|
1016
|
+
gridClassName: ve[y],
|
|
1017
|
+
children: /* @__PURE__ */ t.jsx(
|
|
1018
|
+
J,
|
|
1019
|
+
{
|
|
1020
|
+
schema: {
|
|
1021
|
+
...f,
|
|
1022
|
+
fields: z(c),
|
|
1023
|
+
showSubmit: S === e.sections.length - 1 && f.showSubmit,
|
|
1024
|
+
showCancel: S === e.sections.length - 1 && f.showCancel
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
)
|
|
1028
|
+
},
|
|
1029
|
+
c.name || c.label || S
|
|
1030
|
+
);
|
|
1031
|
+
}) });
|
|
1032
|
+
const a = ce(x, o, e.columns, e.mode), s = ve[a.columns || 1];
|
|
1033
|
+
return /* @__PURE__ */ t.jsx(
|
|
1034
|
+
J,
|
|
1035
|
+
{
|
|
1036
|
+
schema: {
|
|
1037
|
+
...f,
|
|
1038
|
+
fields: a.fields,
|
|
1039
|
+
columns: a.columns,
|
|
1040
|
+
...s ? { fieldContainerClass: s } : {}
|
|
966
1041
|
}
|
|
967
|
-
)
|
|
968
|
-
},
|
|
969
|
-
o.name || o.label || a
|
|
970
|
-
)) }) : /* @__PURE__ */ t.jsx(
|
|
971
|
-
M,
|
|
972
|
-
{
|
|
973
|
-
schema: {
|
|
974
|
-
...s,
|
|
975
|
-
fields: b,
|
|
976
|
-
columns: e.columns
|
|
977
1042
|
}
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
return /* @__PURE__ */ t.jsx(
|
|
981
|
-
|
|
1043
|
+
);
|
|
1044
|
+
};
|
|
1045
|
+
return /* @__PURE__ */ t.jsx(ze, { open: v, onOpenChange: e.onOpenChange, children: /* @__PURE__ */ t.jsxs(
|
|
1046
|
+
Ve,
|
|
982
1047
|
{
|
|
983
|
-
side:
|
|
984
|
-
className:
|
|
985
|
-
style:
|
|
1048
|
+
side: D,
|
|
1049
|
+
className: W("overflow-y-auto", i, e.className),
|
|
1050
|
+
style: U,
|
|
986
1051
|
children: [
|
|
987
|
-
(e.title || e.description) && /* @__PURE__ */ t.jsxs(
|
|
988
|
-
e.title && /* @__PURE__ */ t.jsx(
|
|
989
|
-
e.description && /* @__PURE__ */ t.jsx(
|
|
1052
|
+
(e.title || e.description) && /* @__PURE__ */ t.jsxs(Me, { children: [
|
|
1053
|
+
e.title && /* @__PURE__ */ t.jsx($e, { children: e.title }),
|
|
1054
|
+
e.description && /* @__PURE__ */ t.jsx(qe, { children: e.description })
|
|
990
1055
|
] }),
|
|
991
|
-
/* @__PURE__ */ t.jsx("div", { className: "py-4", children: n() })
|
|
1056
|
+
/* @__PURE__ */ t.jsx("div", { className: "@container py-4", children: n() })
|
|
992
1057
|
]
|
|
993
1058
|
}
|
|
994
1059
|
) });
|
|
995
|
-
},
|
|
1060
|
+
}, Se = {
|
|
996
1061
|
sm: "max-w-sm",
|
|
997
1062
|
default: "max-w-lg",
|
|
998
1063
|
lg: "max-w-2xl",
|
|
999
1064
|
xl: "max-w-4xl",
|
|
1000
1065
|
full: "max-w-[95vw] w-full"
|
|
1001
|
-
},
|
|
1066
|
+
}, Ce = {
|
|
1067
|
+
1: void 0,
|
|
1068
|
+
// let the form renderer use its default (space-y-4)
|
|
1069
|
+
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
1070
|
+
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
1071
|
+
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
1072
|
+
}, ut = ({
|
|
1002
1073
|
schema: e,
|
|
1003
|
-
dataSource:
|
|
1004
|
-
className:
|
|
1074
|
+
dataSource: r,
|
|
1075
|
+
className: i
|
|
1005
1076
|
}) => {
|
|
1006
|
-
const [
|
|
1007
|
-
|
|
1077
|
+
const { fieldLabel: b } = ee(), [o, p] = C(null), [x, E] = C([]), [I, O] = C({}), [F, N] = C(!0), [j, h] = C(null), [v, D] = C(!1), z = e.open !== !1, L = Fe(), k = G(() => e.sections?.length || e.customFields?.length ? null : ce(x, o, e.columns, e.mode), [x, o, e.columns, e.mode, e.sections, e.customFields]), U = G(() => {
|
|
1078
|
+
if (e.modalSize) return e.modalSize;
|
|
1079
|
+
if (k?.columns && k.columns > 1)
|
|
1080
|
+
return Ne(k.columns);
|
|
1081
|
+
if (e.sections?.length) {
|
|
1082
|
+
const g = Math.max(...e.sections.map((m) => Number(m.columns) || 1));
|
|
1083
|
+
if (g > 1) return Ne(g);
|
|
1084
|
+
}
|
|
1085
|
+
return "default";
|
|
1086
|
+
}, [e.modalSize, k, e.sections]), M = Se[U] || Se.default;
|
|
1087
|
+
H(() => {
|
|
1008
1088
|
(async () => {
|
|
1009
|
-
if (!
|
|
1010
|
-
|
|
1089
|
+
if (!r) {
|
|
1090
|
+
N(!1);
|
|
1011
1091
|
return;
|
|
1012
1092
|
}
|
|
1013
1093
|
try {
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
} catch (
|
|
1017
|
-
|
|
1094
|
+
const m = await r.getObjectSchema(e.objectName);
|
|
1095
|
+
p(m);
|
|
1096
|
+
} catch (m) {
|
|
1097
|
+
h(m), N(!1);
|
|
1018
1098
|
}
|
|
1019
1099
|
})();
|
|
1020
|
-
}, [e.objectName,
|
|
1021
|
-
(
|
|
1100
|
+
}, [e.objectName, r]), H(() => {
|
|
1101
|
+
(o || !r) && (async () => {
|
|
1022
1102
|
if (e.mode === "create" || !e.recordId) {
|
|
1023
|
-
|
|
1103
|
+
O(e.initialData || e.initialValues || {}), N(!1);
|
|
1024
1104
|
return;
|
|
1025
1105
|
}
|
|
1026
|
-
if (!
|
|
1027
|
-
|
|
1106
|
+
if (!r) {
|
|
1107
|
+
O(e.initialData || e.initialValues || {}), N(!1);
|
|
1028
1108
|
return;
|
|
1029
1109
|
}
|
|
1030
1110
|
try {
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1033
|
-
} catch (
|
|
1034
|
-
|
|
1111
|
+
const m = await r.findOne(e.objectName, e.recordId);
|
|
1112
|
+
O(m || {});
|
|
1113
|
+
} catch (m) {
|
|
1114
|
+
h(m);
|
|
1035
1115
|
} finally {
|
|
1036
|
-
|
|
1116
|
+
N(!1);
|
|
1037
1117
|
}
|
|
1038
1118
|
})();
|
|
1039
|
-
}, [
|
|
1040
|
-
const
|
|
1041
|
-
const
|
|
1042
|
-
for (const
|
|
1043
|
-
const
|
|
1044
|
-
if (typeof
|
|
1045
|
-
|
|
1046
|
-
else if (
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1049
|
-
name:
|
|
1050
|
-
label:
|
|
1051
|
-
type:
|
|
1052
|
-
required:
|
|
1053
|
-
disabled: e.readOnly || e.mode === "view" ||
|
|
1054
|
-
placeholder:
|
|
1055
|
-
description:
|
|
1056
|
-
validation:
|
|
1057
|
-
field:
|
|
1058
|
-
options:
|
|
1059
|
-
multiple:
|
|
1119
|
+
}, [o, e.mode, e.recordId, e.initialData, e.initialValues, r, e.objectName]);
|
|
1120
|
+
const f = A((g) => {
|
|
1121
|
+
const m = [];
|
|
1122
|
+
for (const V of g.fields) {
|
|
1123
|
+
const Y = typeof V == "string" ? V : V.name;
|
|
1124
|
+
if (typeof V == "object")
|
|
1125
|
+
m.push(V);
|
|
1126
|
+
else if (o?.fields?.[Y]) {
|
|
1127
|
+
const R = o.fields[Y];
|
|
1128
|
+
m.push({
|
|
1129
|
+
name: Y,
|
|
1130
|
+
label: b(e.objectName, Y, R.label || Y),
|
|
1131
|
+
type: X(R.type),
|
|
1132
|
+
required: R.required || !1,
|
|
1133
|
+
disabled: e.readOnly || e.mode === "view" || R.readonly,
|
|
1134
|
+
placeholder: R.placeholder,
|
|
1135
|
+
description: R.help || R.description,
|
|
1136
|
+
validation: B(R),
|
|
1137
|
+
field: R,
|
|
1138
|
+
options: R.options,
|
|
1139
|
+
multiple: R.multiple
|
|
1060
1140
|
});
|
|
1061
1141
|
} else
|
|
1062
|
-
|
|
1063
|
-
name:
|
|
1064
|
-
label:
|
|
1142
|
+
m.push({
|
|
1143
|
+
name: Y,
|
|
1144
|
+
label: Y,
|
|
1065
1145
|
type: "input"
|
|
1066
1146
|
});
|
|
1067
1147
|
}
|
|
1068
|
-
return
|
|
1069
|
-
}, [
|
|
1070
|
-
|
|
1071
|
-
if (!
|
|
1148
|
+
return m;
|
|
1149
|
+
}, [o, e.readOnly, e.mode]);
|
|
1150
|
+
H(() => {
|
|
1151
|
+
if (!o && r) return;
|
|
1072
1152
|
if (e.customFields?.length) {
|
|
1073
|
-
|
|
1153
|
+
E(e.customFields), N(!1);
|
|
1074
1154
|
return;
|
|
1075
1155
|
}
|
|
1076
1156
|
if (e.sections?.length) {
|
|
1077
|
-
|
|
1157
|
+
N(!1);
|
|
1078
1158
|
return;
|
|
1079
1159
|
}
|
|
1080
|
-
if (!
|
|
1081
|
-
const
|
|
1082
|
-
for (const
|
|
1083
|
-
const
|
|
1084
|
-
if (!
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
name:
|
|
1088
|
-
label:
|
|
1089
|
-
type:
|
|
1090
|
-
required:
|
|
1091
|
-
disabled: e.readOnly || e.mode === "view" ||
|
|
1092
|
-
placeholder:
|
|
1093
|
-
description:
|
|
1094
|
-
validation:
|
|
1095
|
-
field:
|
|
1096
|
-
options:
|
|
1097
|
-
multiple:
|
|
1160
|
+
if (!o) return;
|
|
1161
|
+
const g = e.fields || Object.keys(o.fields || {}), m = [];
|
|
1162
|
+
for (const V of g) {
|
|
1163
|
+
const Y = typeof V == "string" ? V : V.name;
|
|
1164
|
+
if (!Y) continue;
|
|
1165
|
+
const R = o.fields?.[Y];
|
|
1166
|
+
R && m.push({
|
|
1167
|
+
name: Y,
|
|
1168
|
+
label: b(e.objectName, Y, R.label || Y),
|
|
1169
|
+
type: X(R.type),
|
|
1170
|
+
required: R.required || !1,
|
|
1171
|
+
disabled: e.readOnly || e.mode === "view" || R.readonly,
|
|
1172
|
+
placeholder: R.placeholder,
|
|
1173
|
+
description: R.help || R.description,
|
|
1174
|
+
validation: B(R),
|
|
1175
|
+
field: R,
|
|
1176
|
+
options: R.options,
|
|
1177
|
+
multiple: R.multiple
|
|
1098
1178
|
});
|
|
1099
1179
|
}
|
|
1100
|
-
|
|
1101
|
-
}, [
|
|
1102
|
-
const
|
|
1103
|
-
|
|
1104
|
-
return e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
1180
|
+
E(m), N(!1);
|
|
1181
|
+
}, [o, e.fields, e.customFields, e.sections, e.readOnly, e.mode, r]);
|
|
1182
|
+
const n = A(async (g) => {
|
|
1183
|
+
D(!0);
|
|
1105
1184
|
try {
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1185
|
+
if (!r)
|
|
1186
|
+
return e.onSuccess && await e.onSuccess(g), e.onOpenChange?.(!1), g;
|
|
1187
|
+
let m;
|
|
1188
|
+
return e.mode === "create" ? m = await r.create(e.objectName, g) : e.mode === "edit" && e.recordId && (m = await r.update(e.objectName, e.recordId, g)), e.onSuccess && await e.onSuccess(m), e.onOpenChange?.(!1), m;
|
|
1189
|
+
} catch (m) {
|
|
1190
|
+
throw e.onError && e.onError(m), m;
|
|
1191
|
+
} finally {
|
|
1192
|
+
D(!1);
|
|
1110
1193
|
}
|
|
1111
|
-
}, [e,
|
|
1194
|
+
}, [e, r]), a = A(() => {
|
|
1112
1195
|
e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
|
|
1113
|
-
}, [e]),
|
|
1196
|
+
}, [e]), s = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", c = e.showSubmit !== !1 && e.mode !== "view", S = e.showCancel !== !1, y = e.submitText || (e.mode === "create" ? "Create" : "Update"), d = e.cancelText || "Cancel", _ = {
|
|
1114
1197
|
type: "form",
|
|
1115
|
-
layout:
|
|
1116
|
-
defaultValues:
|
|
1117
|
-
submitLabel:
|
|
1118
|
-
cancelLabel:
|
|
1119
|
-
showSubmit:
|
|
1120
|
-
showCancel:
|
|
1121
|
-
onSubmit:
|
|
1122
|
-
onCancel:
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1198
|
+
layout: s,
|
|
1199
|
+
defaultValues: I,
|
|
1200
|
+
submitLabel: y,
|
|
1201
|
+
cancelLabel: d,
|
|
1202
|
+
showSubmit: c,
|
|
1203
|
+
showCancel: S,
|
|
1204
|
+
onSubmit: n,
|
|
1205
|
+
onCancel: a,
|
|
1206
|
+
showActions: !1,
|
|
1207
|
+
// Hide actions — rendered in sticky footer
|
|
1208
|
+
id: L
|
|
1209
|
+
// Link external submit button via form attribute
|
|
1210
|
+
}, T = () => {
|
|
1211
|
+
if (j)
|
|
1212
|
+
return /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
1213
|
+
/* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
|
|
1214
|
+
/* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: j.message })
|
|
1215
|
+
] });
|
|
1216
|
+
if (F)
|
|
1217
|
+
return /* @__PURE__ */ t.jsx("div", { className: "space-y-4", "data-testid": "modal-form-skeleton", children: [1, 2, 3].map((V) => /* @__PURE__ */ t.jsxs("div", { className: "space-y-2", children: [
|
|
1218
|
+
/* @__PURE__ */ t.jsx(xe, { className: "h-4 w-24" }),
|
|
1219
|
+
/* @__PURE__ */ t.jsx(xe, { className: "h-10 w-full" })
|
|
1220
|
+
] }, V)) });
|
|
1221
|
+
if (e.sections?.length)
|
|
1222
|
+
return /* @__PURE__ */ t.jsx("div", { className: "space-y-6", children: e.sections.map((V, Y) => {
|
|
1223
|
+
const R = V.columns || 1;
|
|
1224
|
+
return /* @__PURE__ */ t.jsx(
|
|
1225
|
+
te,
|
|
1226
|
+
{
|
|
1227
|
+
label: V.label,
|
|
1228
|
+
description: V.description,
|
|
1229
|
+
columns: R,
|
|
1230
|
+
gridClassName: Ce[R],
|
|
1231
|
+
children: /* @__PURE__ */ t.jsx(
|
|
1232
|
+
J,
|
|
1233
|
+
{
|
|
1234
|
+
schema: {
|
|
1235
|
+
..._,
|
|
1236
|
+
fields: f(V)
|
|
1237
|
+
// Actions are in the sticky footer, not inside sections
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
)
|
|
1241
|
+
},
|
|
1242
|
+
V.name || V.label || Y
|
|
1243
|
+
);
|
|
1244
|
+
}) });
|
|
1245
|
+
const g = k ?? ce(x, o, e.columns, e.mode), m = Ce[g.columns || 1];
|
|
1246
|
+
return /* @__PURE__ */ t.jsx(
|
|
1247
|
+
J,
|
|
1248
|
+
{
|
|
1249
|
+
schema: {
|
|
1250
|
+
..._,
|
|
1251
|
+
fields: g.fields,
|
|
1252
|
+
columns: g.columns,
|
|
1253
|
+
...m ? { fieldContainerClass: m } : {}
|
|
1144
1254
|
}
|
|
1145
|
-
)
|
|
1146
|
-
},
|
|
1147
|
-
n.name || n.label || o
|
|
1148
|
-
)) }) : /* @__PURE__ */ t.jsx(
|
|
1149
|
-
M,
|
|
1150
|
-
{
|
|
1151
|
-
schema: {
|
|
1152
|
-
...u,
|
|
1153
|
-
fields: b,
|
|
1154
|
-
columns: e.columns
|
|
1155
1255
|
}
|
|
1156
|
-
|
|
1157
|
-
);
|
|
1158
|
-
return /* @__PURE__ */ t.jsx(
|
|
1159
|
-
(e.title || e.description) && /* @__PURE__ */ t.jsxs(
|
|
1160
|
-
e.title && /* @__PURE__ */ t.jsx(
|
|
1161
|
-
e.description && /* @__PURE__ */ t.jsx(
|
|
1256
|
+
);
|
|
1257
|
+
}, u = !F && !j && (c || S);
|
|
1258
|
+
return /* @__PURE__ */ t.jsx(Ye, { open: z, onOpenChange: e.onOpenChange, children: /* @__PURE__ */ t.jsxs(We, { className: W(M, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", i, e.className), children: [
|
|
1259
|
+
(e.title || e.description) && /* @__PURE__ */ t.jsxs(Ue, { className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b", children: [
|
|
1260
|
+
e.title && /* @__PURE__ */ t.jsx(He, { children: e.title }),
|
|
1261
|
+
e.description && /* @__PURE__ */ t.jsx(Ge, { children: e.description })
|
|
1162
1262
|
] }),
|
|
1163
|
-
/* @__PURE__ */ t.jsx("div", { className: "py-
|
|
1263
|
+
/* @__PURE__ */ t.jsx("div", { className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4", children: T() }),
|
|
1264
|
+
u && /* @__PURE__ */ t.jsx("div", { className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background", "data-testid": "modal-form-footer", children: /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col sm:flex-row gap-2 sm:justify-end", children: [
|
|
1265
|
+
S && /* @__PURE__ */ t.jsx(
|
|
1266
|
+
Z,
|
|
1267
|
+
{
|
|
1268
|
+
type: "button",
|
|
1269
|
+
variant: "outline",
|
|
1270
|
+
onClick: a,
|
|
1271
|
+
disabled: v,
|
|
1272
|
+
className: "w-full sm:w-auto",
|
|
1273
|
+
children: d
|
|
1274
|
+
}
|
|
1275
|
+
),
|
|
1276
|
+
c && /* @__PURE__ */ t.jsxs(
|
|
1277
|
+
Z,
|
|
1278
|
+
{
|
|
1279
|
+
type: "submit",
|
|
1280
|
+
form: L,
|
|
1281
|
+
disabled: v,
|
|
1282
|
+
className: "w-full sm:w-auto",
|
|
1283
|
+
children: [
|
|
1284
|
+
v && /* @__PURE__ */ t.jsx(Qe, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
1285
|
+
y
|
|
1286
|
+
]
|
|
1287
|
+
}
|
|
1288
|
+
)
|
|
1289
|
+
] }) })
|
|
1164
1290
|
] }) });
|
|
1165
|
-
},
|
|
1291
|
+
}, he = ({
|
|
1166
1292
|
schema: e,
|
|
1167
|
-
dataSource:
|
|
1293
|
+
dataSource: r
|
|
1168
1294
|
}) => {
|
|
1169
1295
|
if (e.formType === "tabbed" && e.sections?.length)
|
|
1170
1296
|
return /* @__PURE__ */ t.jsx(
|
|
1171
|
-
|
|
1297
|
+
tt,
|
|
1172
1298
|
{
|
|
1173
1299
|
schema: {
|
|
1174
1300
|
...e,
|
|
1175
1301
|
formType: "tabbed",
|
|
1176
|
-
sections: e.sections.map((
|
|
1177
|
-
name:
|
|
1178
|
-
label:
|
|
1179
|
-
description:
|
|
1180
|
-
columns:
|
|
1181
|
-
fields:
|
|
1302
|
+
sections: e.sections.map((i) => ({
|
|
1303
|
+
name: i.name,
|
|
1304
|
+
label: i.label,
|
|
1305
|
+
description: i.description,
|
|
1306
|
+
columns: i.columns,
|
|
1307
|
+
fields: i.fields
|
|
1182
1308
|
})),
|
|
1183
1309
|
defaultTab: e.defaultTab,
|
|
1184
1310
|
tabPosition: e.tabPosition
|
|
1185
1311
|
},
|
|
1186
|
-
dataSource:
|
|
1312
|
+
dataSource: r,
|
|
1187
1313
|
className: e.className
|
|
1188
1314
|
}
|
|
1189
1315
|
);
|
|
1190
1316
|
if (e.formType === "wizard" && e.sections?.length)
|
|
1191
1317
|
return /* @__PURE__ */ t.jsx(
|
|
1192
|
-
|
|
1318
|
+
rt,
|
|
1193
1319
|
{
|
|
1194
1320
|
schema: {
|
|
1195
1321
|
...e,
|
|
1196
1322
|
formType: "wizard",
|
|
1197
|
-
sections: e.sections.map((
|
|
1198
|
-
name:
|
|
1199
|
-
label:
|
|
1200
|
-
description:
|
|
1201
|
-
columns:
|
|
1202
|
-
fields:
|
|
1323
|
+
sections: e.sections.map((i) => ({
|
|
1324
|
+
name: i.name,
|
|
1325
|
+
label: i.label,
|
|
1326
|
+
description: i.description,
|
|
1327
|
+
columns: i.columns,
|
|
1328
|
+
fields: i.fields
|
|
1203
1329
|
})),
|
|
1204
1330
|
allowSkip: e.allowSkip,
|
|
1205
1331
|
showStepIndicator: e.showStepIndicator,
|
|
@@ -1207,261 +1333,457 @@ const G = ({
|
|
|
1207
1333
|
prevText: e.prevText,
|
|
1208
1334
|
onStepChange: e.onStepChange
|
|
1209
1335
|
},
|
|
1210
|
-
dataSource:
|
|
1336
|
+
dataSource: r,
|
|
1211
1337
|
className: e.className
|
|
1212
1338
|
}
|
|
1213
1339
|
);
|
|
1214
1340
|
if (e.formType === "split" && e.sections?.length)
|
|
1215
1341
|
return /* @__PURE__ */ t.jsx(
|
|
1216
|
-
|
|
1342
|
+
lt,
|
|
1217
1343
|
{
|
|
1218
1344
|
schema: {
|
|
1219
1345
|
...e,
|
|
1220
1346
|
formType: "split",
|
|
1221
|
-
sections: e.sections.map((
|
|
1222
|
-
name:
|
|
1223
|
-
label:
|
|
1224
|
-
description:
|
|
1225
|
-
columns:
|
|
1226
|
-
fields:
|
|
1347
|
+
sections: e.sections.map((i) => ({
|
|
1348
|
+
name: i.name,
|
|
1349
|
+
label: i.label,
|
|
1350
|
+
description: i.description,
|
|
1351
|
+
columns: i.columns,
|
|
1352
|
+
fields: i.fields
|
|
1227
1353
|
})),
|
|
1228
1354
|
splitDirection: e.splitDirection,
|
|
1229
1355
|
splitSize: e.splitSize,
|
|
1230
1356
|
splitResizable: e.splitResizable
|
|
1231
1357
|
},
|
|
1232
|
-
dataSource:
|
|
1358
|
+
dataSource: r,
|
|
1233
1359
|
className: e.className
|
|
1234
1360
|
}
|
|
1235
1361
|
);
|
|
1236
1362
|
if (e.formType === "drawer") {
|
|
1237
|
-
const { layout:
|
|
1363
|
+
const { layout: i, ...b } = e, o = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
|
|
1238
1364
|
return /* @__PURE__ */ t.jsx(
|
|
1239
|
-
|
|
1365
|
+
ct,
|
|
1240
1366
|
{
|
|
1241
1367
|
schema: {
|
|
1242
|
-
...
|
|
1243
|
-
layout:
|
|
1368
|
+
...b,
|
|
1369
|
+
layout: o,
|
|
1244
1370
|
formType: "drawer",
|
|
1245
|
-
sections: e.sections?.map((
|
|
1246
|
-
name:
|
|
1247
|
-
label:
|
|
1248
|
-
description:
|
|
1249
|
-
columns:
|
|
1250
|
-
fields:
|
|
1371
|
+
sections: e.sections?.map((p) => ({
|
|
1372
|
+
name: p.name,
|
|
1373
|
+
label: p.label,
|
|
1374
|
+
description: p.description,
|
|
1375
|
+
columns: p.columns,
|
|
1376
|
+
fields: p.fields
|
|
1251
1377
|
})),
|
|
1252
1378
|
open: e.open,
|
|
1253
1379
|
onOpenChange: e.onOpenChange,
|
|
1254
1380
|
drawerSide: e.drawerSide,
|
|
1255
1381
|
drawerWidth: e.drawerWidth
|
|
1256
1382
|
},
|
|
1257
|
-
dataSource:
|
|
1383
|
+
dataSource: r,
|
|
1258
1384
|
className: e.className
|
|
1259
1385
|
}
|
|
1260
1386
|
);
|
|
1261
1387
|
}
|
|
1262
1388
|
if (e.formType === "modal") {
|
|
1263
|
-
const { layout:
|
|
1389
|
+
const { layout: i, ...b } = e, o = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
|
|
1264
1390
|
return /* @__PURE__ */ t.jsx(
|
|
1265
|
-
|
|
1391
|
+
ut,
|
|
1266
1392
|
{
|
|
1267
1393
|
schema: {
|
|
1268
|
-
...
|
|
1269
|
-
layout:
|
|
1394
|
+
...b,
|
|
1395
|
+
layout: o,
|
|
1270
1396
|
formType: "modal",
|
|
1271
|
-
sections: e.sections?.map((
|
|
1272
|
-
name:
|
|
1273
|
-
label:
|
|
1274
|
-
description:
|
|
1275
|
-
columns:
|
|
1276
|
-
fields:
|
|
1397
|
+
sections: e.sections?.map((p) => ({
|
|
1398
|
+
name: p.name,
|
|
1399
|
+
label: p.label,
|
|
1400
|
+
description: p.description,
|
|
1401
|
+
columns: p.columns,
|
|
1402
|
+
fields: p.fields
|
|
1277
1403
|
})),
|
|
1278
1404
|
open: e.open,
|
|
1279
1405
|
onOpenChange: e.onOpenChange,
|
|
1280
1406
|
modalSize: e.modalSize,
|
|
1281
1407
|
modalCloseButton: e.modalCloseButton
|
|
1282
1408
|
},
|
|
1283
|
-
dataSource:
|
|
1409
|
+
dataSource: r,
|
|
1284
1410
|
className: e.className
|
|
1285
1411
|
}
|
|
1286
1412
|
);
|
|
1287
1413
|
}
|
|
1288
|
-
return /* @__PURE__ */ t.jsx(
|
|
1289
|
-
},
|
|
1414
|
+
return /* @__PURE__ */ t.jsx(ft, { schema: e, dataSource: r });
|
|
1415
|
+
}, ft = ({
|
|
1290
1416
|
schema: e,
|
|
1291
|
-
dataSource:
|
|
1417
|
+
dataSource: r
|
|
1292
1418
|
}) => {
|
|
1293
|
-
const [
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
}, [
|
|
1297
|
-
const
|
|
1419
|
+
const { fieldLabel: i } = ee(), [b, o] = C(null), [p, x] = C([]), [E, I] = C(null), [O, F] = C(!0), [N, j] = C(null), h = e.customFields && e.customFields.length > 0;
|
|
1420
|
+
H(() => {
|
|
1421
|
+
h && (I(e.initialData || e.initialValues || {}), F(!1));
|
|
1422
|
+
}, [h, e.initialData, e.initialValues]), H(() => {
|
|
1423
|
+
const n = async () => {
|
|
1298
1424
|
try {
|
|
1299
|
-
if (!
|
|
1425
|
+
if (!r)
|
|
1300
1426
|
throw new Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");
|
|
1301
|
-
const
|
|
1302
|
-
if (!
|
|
1427
|
+
const a = await r.getObjectSchema(e.objectName);
|
|
1428
|
+
if (!a)
|
|
1303
1429
|
throw new Error(`No schema found for object "${e.objectName}"`);
|
|
1304
|
-
|
|
1305
|
-
} catch (
|
|
1306
|
-
|
|
1430
|
+
o(a);
|
|
1431
|
+
} catch (a) {
|
|
1432
|
+
j(a), F(!1);
|
|
1307
1433
|
}
|
|
1308
1434
|
};
|
|
1309
|
-
|
|
1435
|
+
h ? o({
|
|
1310
1436
|
name: e.objectName,
|
|
1311
1437
|
fields: {}
|
|
1312
|
-
}) : e.objectName &&
|
|
1313
|
-
}, [e.objectName,
|
|
1314
|
-
|
|
1438
|
+
}) : e.objectName && r ? n() : h || F(!1);
|
|
1439
|
+
}, [e.objectName, r, h]), H(() => {
|
|
1440
|
+
b && !h && (async () => {
|
|
1315
1441
|
if (!e.recordId || e.mode === "create") {
|
|
1316
|
-
|
|
1442
|
+
I(e.initialData || e.initialValues || {}), F(!1);
|
|
1317
1443
|
return;
|
|
1318
1444
|
}
|
|
1319
|
-
if (!
|
|
1320
|
-
if (!
|
|
1321
|
-
|
|
1445
|
+
if (!h) {
|
|
1446
|
+
if (!r) {
|
|
1447
|
+
j(new Error("DataSource is required for fetching record data (inline data not provided)")), F(!1);
|
|
1322
1448
|
return;
|
|
1323
1449
|
}
|
|
1324
|
-
|
|
1450
|
+
F(!0);
|
|
1325
1451
|
try {
|
|
1326
|
-
const
|
|
1327
|
-
|
|
1328
|
-
} catch (
|
|
1329
|
-
console.error("Failed to fetch record:",
|
|
1452
|
+
const a = await r.findOne(e.objectName, e.recordId);
|
|
1453
|
+
I(a);
|
|
1454
|
+
} catch (a) {
|
|
1455
|
+
console.error("Failed to fetch record:", a), j(a);
|
|
1330
1456
|
} finally {
|
|
1331
|
-
|
|
1457
|
+
F(!1);
|
|
1332
1458
|
}
|
|
1333
1459
|
}
|
|
1334
1460
|
})();
|
|
1335
|
-
}, [e.objectName, e.recordId, e.mode, e.initialValues, e.initialData,
|
|
1336
|
-
if (
|
|
1337
|
-
|
|
1461
|
+
}, [e.objectName, e.recordId, e.mode, e.initialValues, e.initialData, r, b, h]), H(() => {
|
|
1462
|
+
if (h && e.customFields) {
|
|
1463
|
+
x(e.customFields), F(!1);
|
|
1338
1464
|
return;
|
|
1339
1465
|
}
|
|
1340
|
-
if (!
|
|
1341
|
-
const
|
|
1342
|
-
(Array.isArray(
|
|
1343
|
-
const
|
|
1344
|
-
if (!
|
|
1345
|
-
const
|
|
1346
|
-
if (!
|
|
1347
|
-
const
|
|
1348
|
-
if (e.mode !== "view" && !
|
|
1349
|
-
const
|
|
1350
|
-
if (
|
|
1351
|
-
|
|
1352
|
-
else if (
|
|
1353
|
-
const
|
|
1354
|
-
name:
|
|
1355
|
-
label: i.label ||
|
|
1356
|
-
type:
|
|
1357
|
-
required:
|
|
1358
|
-
disabled: e.readOnly || e.mode === "view" ||
|
|
1359
|
-
placeholder:
|
|
1360
|
-
description:
|
|
1361
|
-
validation:
|
|
1466
|
+
if (!b) return;
|
|
1467
|
+
const n = [], a = e.fields || Object.keys(b.fields || {});
|
|
1468
|
+
(Array.isArray(a) ? a : Object.keys(a)).forEach((S) => {
|
|
1469
|
+
const y = typeof S == "string" ? S : S.name;
|
|
1470
|
+
if (!y) return;
|
|
1471
|
+
const d = b.fields?.[y];
|
|
1472
|
+
if (!d && !h) return;
|
|
1473
|
+
const _ = !d?.permissions || d?.permissions.write !== !1;
|
|
1474
|
+
if (e.mode !== "view" && !_) return;
|
|
1475
|
+
const T = e.customFields?.find((u) => u.name === y);
|
|
1476
|
+
if (T)
|
|
1477
|
+
n.push(T);
|
|
1478
|
+
else if (d) {
|
|
1479
|
+
const u = {
|
|
1480
|
+
name: y,
|
|
1481
|
+
label: i(e.objectName, y, d.label || S),
|
|
1482
|
+
type: X(d.type),
|
|
1483
|
+
required: d.required || !1,
|
|
1484
|
+
disabled: e.readOnly || e.mode === "view" || d.readonly,
|
|
1485
|
+
placeholder: d.placeholder,
|
|
1486
|
+
description: d.help || d.description,
|
|
1487
|
+
validation: B(d),
|
|
1362
1488
|
// Important: Pass the original field metadata so widgets can access properties like precision, currency, etc.
|
|
1363
|
-
field:
|
|
1489
|
+
field: d
|
|
1364
1490
|
};
|
|
1365
|
-
if ((
|
|
1366
|
-
const
|
|
1367
|
-
|
|
1491
|
+
if ((d.type === "select" || d.type === "lookup" || d.type === "master_detail") && (u.options = d.options || [], u.multiple = d.multiple), (d.type === "number" || d.type === "currency" || d.type === "percent") && (u.inputType = "number", u.min = d.min, u.max = d.max, u.step = d.precision ? Math.pow(10, -d.precision) : void 0), d.type === "date" && (u.inputType = "date"), d.type === "datetime" && (u.inputType = "datetime-local"), (d.type === "text" || d.type === "textarea" || d.type === "markdown" || d.type === "html") && (u.maxLength = d.max_length, u.minLength = d.min_length), (d.type === "file" || d.type === "image") && (u.inputType = "file", u.multiple = d.multiple, u.accept = d.accept ? d.accept.join(",") : void 0, d.max_size)) {
|
|
1492
|
+
const g = `Max size: ${Re(d.max_size)}`;
|
|
1493
|
+
u.description = u.description ? `${u.description} (${g})` : g;
|
|
1368
1494
|
}
|
|
1369
|
-
|
|
1495
|
+
d.type === "email" && (u.inputType = "email"), d.type === "phone" && (u.inputType = "tel"), d.type === "url" && (u.inputType = "url"), d.type === "password" && (u.inputType = "password"), d.type === "time" && (u.inputType = "time"), (d.type === "formula" || d.type === "summary" || d.type === "auto_number") && (u.disabled = !0), d.visible_on && (u.visible = (g) => De(d.visible_on, g)), n.push(u);
|
|
1370
1496
|
}
|
|
1371
|
-
}),
|
|
1372
|
-
}, [
|
|
1373
|
-
const
|
|
1374
|
-
if (
|
|
1375
|
-
return e.onSuccess && await e.onSuccess(
|
|
1376
|
-
if (!
|
|
1497
|
+
}), x(n), !h && e.recordId && e.mode !== "create" && r || F(!1);
|
|
1498
|
+
}, [b, e.fields, e.customFields, e.readOnly, e.mode, h, e.recordId, r]);
|
|
1499
|
+
const v = A(async (n, a) => {
|
|
1500
|
+
if (n && (n.nativeEvent || n._reactName === "onSubmit") && (console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."), a === void 0 && (a = n, n = {})), h && !r)
|
|
1501
|
+
return e.onSuccess && await e.onSuccess(n), n;
|
|
1502
|
+
if (!r)
|
|
1377
1503
|
throw new Error("DataSource is required for form submission (inline mode not configured)");
|
|
1378
1504
|
try {
|
|
1379
|
-
let
|
|
1505
|
+
let s;
|
|
1380
1506
|
if (e.mode === "create")
|
|
1381
|
-
|
|
1507
|
+
s = await r.create(e.objectName, n);
|
|
1382
1508
|
else if (e.mode === "edit" && e.recordId)
|
|
1383
|
-
|
|
1509
|
+
s = await r.update(e.objectName, e.recordId, n);
|
|
1384
1510
|
else
|
|
1385
1511
|
throw new Error("Invalid form mode or missing record ID");
|
|
1386
|
-
return e.onSuccess && await e.onSuccess(
|
|
1387
|
-
} catch (
|
|
1388
|
-
throw console.error("Failed to submit form:",
|
|
1512
|
+
return e.onSuccess && await e.onSuccess(s), s;
|
|
1513
|
+
} catch (s) {
|
|
1514
|
+
throw console.error("Failed to submit form:", s), e.onError && e.onError(s), s;
|
|
1389
1515
|
}
|
|
1390
|
-
}, [e,
|
|
1516
|
+
}, [e, r, h]), D = A(() => {
|
|
1391
1517
|
e.onCancel && e.onCancel();
|
|
1392
|
-
}, [e]),
|
|
1393
|
-
...
|
|
1394
|
-
if (!
|
|
1395
|
-
const
|
|
1396
|
-
return Object.keys(
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1399
|
-
}),
|
|
1400
|
-
}, [
|
|
1401
|
-
...
|
|
1518
|
+
}, [e]), L = {
|
|
1519
|
+
...K.useMemo(() => {
|
|
1520
|
+
if (!b?.fields) return {};
|
|
1521
|
+
const n = {};
|
|
1522
|
+
return Object.keys(b.fields).forEach((a) => {
|
|
1523
|
+
const s = b.fields[a];
|
|
1524
|
+
s.defaultValue !== void 0 && (n[a] = s.defaultValue);
|
|
1525
|
+
}), n;
|
|
1526
|
+
}, [b]),
|
|
1527
|
+
...E
|
|
1402
1528
|
};
|
|
1403
|
-
if (
|
|
1529
|
+
if (N)
|
|
1404
1530
|
return /* @__PURE__ */ t.jsxs("div", { className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
1405
1531
|
/* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
|
|
1406
|
-
/* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children:
|
|
1532
|
+
/* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: N.message })
|
|
1407
1533
|
] });
|
|
1408
|
-
if (
|
|
1534
|
+
if (O)
|
|
1409
1535
|
return /* @__PURE__ */ t.jsxs("div", { className: "p-4 sm:p-8 text-center", children: [
|
|
1410
1536
|
/* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
|
|
1411
1537
|
/* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
|
|
1412
1538
|
] });
|
|
1413
|
-
const
|
|
1539
|
+
const k = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical";
|
|
1414
1540
|
if (e.sections?.length && (!e.formType || e.formType === "simple"))
|
|
1415
|
-
return /* @__PURE__ */ t.jsx("div", { className: "w-full space-y-6", children: e.sections.map((
|
|
1416
|
-
const
|
|
1541
|
+
return /* @__PURE__ */ t.jsx("div", { className: "w-full space-y-6", children: e.sections.map((n, a) => {
|
|
1542
|
+
const s = n.fields.map((S) => typeof S == "string" ? S : S.name), c = p.filter((S) => s.includes(S.name));
|
|
1417
1543
|
return /* @__PURE__ */ t.jsx(
|
|
1418
|
-
|
|
1544
|
+
te,
|
|
1419
1545
|
{
|
|
1420
|
-
label:
|
|
1421
|
-
description:
|
|
1422
|
-
collapsible:
|
|
1423
|
-
collapsed:
|
|
1424
|
-
columns:
|
|
1546
|
+
label: n.label,
|
|
1547
|
+
description: n.description,
|
|
1548
|
+
collapsible: n.collapsible,
|
|
1549
|
+
collapsed: n.collapsed,
|
|
1550
|
+
columns: n.columns,
|
|
1425
1551
|
children: /* @__PURE__ */ t.jsx(
|
|
1426
|
-
|
|
1552
|
+
J,
|
|
1427
1553
|
{
|
|
1428
1554
|
schema: {
|
|
1429
1555
|
type: "form",
|
|
1430
|
-
fields:
|
|
1431
|
-
layout:
|
|
1432
|
-
defaultValues:
|
|
1556
|
+
fields: c,
|
|
1557
|
+
layout: k,
|
|
1558
|
+
defaultValues: L,
|
|
1433
1559
|
// Only show action buttons after the last section
|
|
1434
|
-
showSubmit:
|
|
1435
|
-
showCancel:
|
|
1560
|
+
showSubmit: a === e.sections.length - 1 && e.showSubmit !== !1 && e.mode !== "view",
|
|
1561
|
+
showCancel: a === e.sections.length - 1 && e.showCancel !== !1,
|
|
1436
1562
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
1437
1563
|
cancelLabel: e.cancelText,
|
|
1438
|
-
onSubmit:
|
|
1439
|
-
onCancel:
|
|
1564
|
+
onSubmit: v,
|
|
1565
|
+
onCancel: D
|
|
1440
1566
|
}
|
|
1441
1567
|
}
|
|
1442
1568
|
)
|
|
1443
1569
|
},
|
|
1444
|
-
|
|
1570
|
+
n.name || n.label || a
|
|
1445
1571
|
);
|
|
1446
1572
|
}) });
|
|
1447
|
-
const
|
|
1573
|
+
const M = e.sections?.length ? { fields: p, columns: e.columns } : ce(p, b, e.columns, e.mode), f = {
|
|
1448
1574
|
type: "form",
|
|
1449
|
-
fields:
|
|
1450
|
-
layout:
|
|
1451
|
-
columns:
|
|
1575
|
+
fields: M.fields,
|
|
1576
|
+
layout: k,
|
|
1577
|
+
columns: M.columns,
|
|
1452
1578
|
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
1453
1579
|
cancelLabel: e.cancelText,
|
|
1454
1580
|
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
1455
1581
|
showCancel: e.showCancel !== !1,
|
|
1456
1582
|
resetOnSubmit: e.showReset,
|
|
1457
|
-
defaultValues:
|
|
1458
|
-
onSubmit:
|
|
1459
|
-
onCancel:
|
|
1583
|
+
defaultValues: L,
|
|
1584
|
+
onSubmit: v,
|
|
1585
|
+
onCancel: D,
|
|
1460
1586
|
className: e.className
|
|
1461
1587
|
};
|
|
1462
|
-
return /* @__PURE__ */ t.jsx("div", { className: "w-full", children: /* @__PURE__ */ t.jsx(
|
|
1463
|
-
},
|
|
1464
|
-
|
|
1588
|
+
return /* @__PURE__ */ t.jsx("div", { className: "w-full", children: /* @__PURE__ */ t.jsx(J, { schema: f }) });
|
|
1589
|
+
}, pt = ({
|
|
1590
|
+
config: e,
|
|
1591
|
+
dataSource: r,
|
|
1592
|
+
prefillParams: i,
|
|
1593
|
+
className: b
|
|
1594
|
+
}) => {
|
|
1595
|
+
const [o, p] = C(!1), [x, E] = C(!1), [I, O] = C(null), F = G(() => {
|
|
1596
|
+
const v = {};
|
|
1597
|
+
if (i)
|
|
1598
|
+
for (const [D, z] of Object.entries(i))
|
|
1599
|
+
v[D] = z;
|
|
1600
|
+
return typeof window < "u" && new URLSearchParams(window.location.search).forEach((z, L) => {
|
|
1601
|
+
L in v || (v[L] = z);
|
|
1602
|
+
}), Object.keys(v).length > 0 ? v : void 0;
|
|
1603
|
+
}, [i]), N = A(async (v) => {
|
|
1604
|
+
E(!0), O(null);
|
|
1605
|
+
try {
|
|
1606
|
+
if (r && await r.create(e.objectName, v), p(!0), e.thankYouPage?.redirectUrl) {
|
|
1607
|
+
const D = e.thankYouPage.redirectDelay ?? 3e3;
|
|
1608
|
+
setTimeout(() => {
|
|
1609
|
+
window.location.href = e.thankYouPage.redirectUrl;
|
|
1610
|
+
}, D);
|
|
1611
|
+
}
|
|
1612
|
+
} catch (D) {
|
|
1613
|
+
O(D instanceof Error ? D.message : "Failed to submit form. Please try again.");
|
|
1614
|
+
} finally {
|
|
1615
|
+
E(!1);
|
|
1616
|
+
}
|
|
1617
|
+
}, [r, e]), j = A(() => {
|
|
1618
|
+
p(!1), O(null);
|
|
1619
|
+
}, []), h = G(() => {
|
|
1620
|
+
const v = {};
|
|
1621
|
+
return e.branding?.backgroundColor && (v.backgroundColor = e.branding.backgroundColor), v;
|
|
1622
|
+
}, [e.branding]);
|
|
1623
|
+
if (o) {
|
|
1624
|
+
const v = e.thankYouPage;
|
|
1625
|
+
return /* @__PURE__ */ t.jsx(
|
|
1626
|
+
"div",
|
|
1627
|
+
{
|
|
1628
|
+
className: `min-h-screen flex items-center justify-center p-4 ${b || ""}`,
|
|
1629
|
+
style: h,
|
|
1630
|
+
children: /* @__PURE__ */ t.jsxs("div", { className: "max-w-md w-full bg-card rounded-lg shadow-lg p-8 text-center space-y-4", children: [
|
|
1631
|
+
/* @__PURE__ */ t.jsx("div", { className: "text-4xl", children: "✓" }),
|
|
1632
|
+
/* @__PURE__ */ t.jsx("h2", { className: "text-xl font-semibold text-foreground", children: v?.title || "Thank You!" }),
|
|
1633
|
+
/* @__PURE__ */ t.jsx("p", { className: "text-muted-foreground", children: v?.message || "Your submission has been received successfully." }),
|
|
1634
|
+
e.allowMultiple && /* @__PURE__ */ t.jsx(
|
|
1635
|
+
"button",
|
|
1636
|
+
{
|
|
1637
|
+
onClick: j,
|
|
1638
|
+
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",
|
|
1639
|
+
children: "Submit Another Response"
|
|
1640
|
+
}
|
|
1641
|
+
),
|
|
1642
|
+
v?.redirectUrl && /* @__PURE__ */ t.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
1643
|
+
"Redirecting in ",
|
|
1644
|
+
Math.ceil((v.redirectDelay ?? 3e3) / 1e3),
|
|
1645
|
+
" seconds..."
|
|
1646
|
+
] })
|
|
1647
|
+
] })
|
|
1648
|
+
}
|
|
1649
|
+
);
|
|
1650
|
+
}
|
|
1651
|
+
return /* @__PURE__ */ t.jsx(
|
|
1652
|
+
"div",
|
|
1653
|
+
{
|
|
1654
|
+
className: `min-h-screen flex items-center justify-center p-4 ${b || ""}`,
|
|
1655
|
+
style: h,
|
|
1656
|
+
children: /* @__PURE__ */ t.jsxs("div", { className: "max-w-2xl w-full bg-card rounded-lg shadow-lg overflow-hidden", children: [
|
|
1657
|
+
/* @__PURE__ */ t.jsxs(
|
|
1658
|
+
"div",
|
|
1659
|
+
{
|
|
1660
|
+
className: "p-6 border-b",
|
|
1661
|
+
style: e.branding?.primaryColor ? { borderBottomColor: e.branding.primaryColor } : void 0,
|
|
1662
|
+
children: [
|
|
1663
|
+
e.branding?.logo && /* @__PURE__ */ t.jsx(
|
|
1664
|
+
"img",
|
|
1665
|
+
{
|
|
1666
|
+
src: e.branding.logo,
|
|
1667
|
+
alt: "Logo",
|
|
1668
|
+
className: "h-8 mb-4"
|
|
1669
|
+
}
|
|
1670
|
+
),
|
|
1671
|
+
e.title && /* @__PURE__ */ t.jsx("h1", { className: "text-xl font-semibold text-foreground", children: e.title }),
|
|
1672
|
+
e.description && /* @__PURE__ */ t.jsx("p", { className: "text-sm text-muted-foreground mt-1", children: e.description })
|
|
1673
|
+
]
|
|
1674
|
+
}
|
|
1675
|
+
),
|
|
1676
|
+
/* @__PURE__ */ t.jsxs("div", { className: "p-6", children: [
|
|
1677
|
+
I && /* @__PURE__ */ t.jsx("div", { className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive", children: I }),
|
|
1678
|
+
/* @__PURE__ */ t.jsx(
|
|
1679
|
+
he,
|
|
1680
|
+
{
|
|
1681
|
+
schema: {
|
|
1682
|
+
type: "object-form",
|
|
1683
|
+
objectName: e.objectName,
|
|
1684
|
+
mode: "create",
|
|
1685
|
+
fields: e.fields,
|
|
1686
|
+
customFields: e.customFields,
|
|
1687
|
+
initialData: F,
|
|
1688
|
+
onSuccess: N,
|
|
1689
|
+
submitLabel: x ? "Submitting..." : "Submit"
|
|
1690
|
+
},
|
|
1691
|
+
dataSource: r
|
|
1692
|
+
}
|
|
1693
|
+
)
|
|
1694
|
+
] }),
|
|
1695
|
+
/* @__PURE__ */ t.jsx("div", { className: "px-6 py-3 border-t bg-muted/20 text-center", children: /* @__PURE__ */ t.jsx("p", { className: "text-xs text-muted-foreground", children: "Powered by ObjectStack" }) })
|
|
1696
|
+
] })
|
|
1697
|
+
}
|
|
1698
|
+
);
|
|
1699
|
+
};
|
|
1700
|
+
function mt(e) {
|
|
1701
|
+
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`;
|
|
1702
|
+
}
|
|
1703
|
+
const bt = ({
|
|
1704
|
+
formId: e,
|
|
1705
|
+
formTitle: r,
|
|
1706
|
+
metrics: i,
|
|
1707
|
+
className: b
|
|
1708
|
+
}) => {
|
|
1709
|
+
const o = G(() => {
|
|
1710
|
+
if (!i.abandonedSubmissions) return 100;
|
|
1711
|
+
const x = i.totalSubmissions + i.abandonedSubmissions;
|
|
1712
|
+
return x === 0 ? 0 : Math.round(i.totalSubmissions / x * 100);
|
|
1713
|
+
}, [i.totalSubmissions, i.abandonedSubmissions]), p = G(() => i.dailySubmissions?.length ? Math.max(...i.dailySubmissions.map((x) => x.count), 1) : 1, [i.dailySubmissions]);
|
|
1714
|
+
return /* @__PURE__ */ t.jsxs("div", { className: `space-y-4 ${b || ""}`, children: [
|
|
1715
|
+
/* @__PURE__ */ t.jsxs("div", { children: [
|
|
1716
|
+
/* @__PURE__ */ t.jsx("h2", { className: "text-lg font-semibold text-foreground", children: r || "Form Analytics" }),
|
|
1717
|
+
/* @__PURE__ */ t.jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
1718
|
+
"Form ID: ",
|
|
1719
|
+
e
|
|
1720
|
+
] })
|
|
1721
|
+
] }),
|
|
1722
|
+
/* @__PURE__ */ t.jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-3 gap-4", children: [
|
|
1723
|
+
/* @__PURE__ */ t.jsx(re, { children: /* @__PURE__ */ t.jsxs(le, { className: "pb-2", children: [
|
|
1724
|
+
/* @__PURE__ */ t.jsx(ae, { children: "Total Submissions" }),
|
|
1725
|
+
/* @__PURE__ */ t.jsx(ne, { className: "text-2xl", children: i.totalSubmissions.toLocaleString() })
|
|
1726
|
+
] }) }),
|
|
1727
|
+
/* @__PURE__ */ t.jsxs(re, { children: [
|
|
1728
|
+
/* @__PURE__ */ t.jsxs(le, { className: "pb-2", children: [
|
|
1729
|
+
/* @__PURE__ */ t.jsx(ae, { children: "Fill Rate" }),
|
|
1730
|
+
/* @__PURE__ */ t.jsxs(ne, { className: "text-2xl", children: [
|
|
1731
|
+
o,
|
|
1732
|
+
"%"
|
|
1733
|
+
] })
|
|
1734
|
+
] }),
|
|
1735
|
+
/* @__PURE__ */ t.jsx(me, { children: /* @__PURE__ */ t.jsx("div", { className: "w-full bg-muted rounded-full h-2", children: /* @__PURE__ */ t.jsx(
|
|
1736
|
+
"div",
|
|
1737
|
+
{
|
|
1738
|
+
className: "bg-primary rounded-full h-2 transition-all",
|
|
1739
|
+
style: { width: `${o}%` }
|
|
1740
|
+
}
|
|
1741
|
+
) }) })
|
|
1742
|
+
] }),
|
|
1743
|
+
/* @__PURE__ */ t.jsx(re, { children: /* @__PURE__ */ t.jsxs(le, { className: "pb-2", children: [
|
|
1744
|
+
/* @__PURE__ */ t.jsx(ae, { children: "Avg. Completion Time" }),
|
|
1745
|
+
/* @__PURE__ */ t.jsx(ne, { className: "text-2xl", children: i.avgCompletionTime ? mt(i.avgCompletionTime) : "—" })
|
|
1746
|
+
] }) })
|
|
1747
|
+
] }),
|
|
1748
|
+
i.dailySubmissions && i.dailySubmissions.length > 0 && /* @__PURE__ */ t.jsxs(re, { children: [
|
|
1749
|
+
/* @__PURE__ */ t.jsx(le, { children: /* @__PURE__ */ t.jsx(ne, { className: "text-sm font-medium", children: "Daily Submissions" }) }),
|
|
1750
|
+
/* @__PURE__ */ t.jsx(me, { children: /* @__PURE__ */ t.jsx("div", { className: "flex items-end gap-1 h-32", children: i.dailySubmissions.map((x, E) => /* @__PURE__ */ t.jsxs("div", { className: "flex-1 flex flex-col items-center gap-1", children: [
|
|
1751
|
+
/* @__PURE__ */ t.jsx(
|
|
1752
|
+
"div",
|
|
1753
|
+
{
|
|
1754
|
+
className: "w-full bg-primary/80 rounded-t transition-all hover:bg-primary",
|
|
1755
|
+
style: { height: `${x.count / p * 100}%`, minHeight: x.count > 0 ? "4px" : "0" },
|
|
1756
|
+
title: `${x.date}: ${x.count} submissions`
|
|
1757
|
+
}
|
|
1758
|
+
),
|
|
1759
|
+
/* @__PURE__ */ t.jsx("span", { className: "text-[10px] text-muted-foreground truncate w-full text-center", children: x.date.slice(-5) })
|
|
1760
|
+
] }, E)) }) })
|
|
1761
|
+
] }),
|
|
1762
|
+
i.fieldDropOff && i.fieldDropOff.length > 0 && /* @__PURE__ */ t.jsxs(re, { children: [
|
|
1763
|
+
/* @__PURE__ */ t.jsxs(le, { children: [
|
|
1764
|
+
/* @__PURE__ */ t.jsx(ne, { className: "text-sm font-medium", children: "Field Completion Rates" }),
|
|
1765
|
+
/* @__PURE__ */ t.jsx(ae, { children: "Percentage of users who completed each field" })
|
|
1766
|
+
] }),
|
|
1767
|
+
/* @__PURE__ */ t.jsx(me, { children: /* @__PURE__ */ t.jsx("div", { className: "space-y-3", children: i.fieldDropOff.map((x, E) => /* @__PURE__ */ t.jsxs("div", { className: "space-y-1", children: [
|
|
1768
|
+
/* @__PURE__ */ t.jsxs("div", { className: "flex justify-between text-sm", children: [
|
|
1769
|
+
/* @__PURE__ */ t.jsx("span", { className: "text-foreground", children: x.label }),
|
|
1770
|
+
/* @__PURE__ */ t.jsxs("span", { className: "text-muted-foreground", children: [
|
|
1771
|
+
x.completionRate,
|
|
1772
|
+
"%"
|
|
1773
|
+
] })
|
|
1774
|
+
] }),
|
|
1775
|
+
/* @__PURE__ */ t.jsx("div", { className: "w-full bg-muted rounded-full h-1.5", children: /* @__PURE__ */ t.jsx(
|
|
1776
|
+
"div",
|
|
1777
|
+
{
|
|
1778
|
+
className: `rounded-full h-1.5 transition-all ${x.completionRate >= 80 ? "bg-green-500" : x.completionRate >= 50 ? "bg-yellow-500" : "bg-destructive"}`,
|
|
1779
|
+
style: { width: `${x.completionRate}%` }
|
|
1780
|
+
}
|
|
1781
|
+
) })
|
|
1782
|
+
] }, E)) }) })
|
|
1783
|
+
] })
|
|
1784
|
+
] });
|
|
1785
|
+
}, Ee = ({ schema: e }) => /* @__PURE__ */ t.jsx(he, { schema: e });
|
|
1786
|
+
ue.register("object-form", Ee, {
|
|
1465
1787
|
namespace: "plugin-form",
|
|
1466
1788
|
label: "Object Form",
|
|
1467
1789
|
category: "plugin",
|
|
@@ -1492,7 +1814,7 @@ ue.register("object-form", be, {
|
|
|
1492
1814
|
{ name: "modalSize", type: "enum", label: "Modal Size", enum: ["sm", "default", "lg", "xl", "full"] }
|
|
1493
1815
|
]
|
|
1494
1816
|
});
|
|
1495
|
-
ue.register("form",
|
|
1817
|
+
ue.register("form", Ee, {
|
|
1496
1818
|
namespace: "view",
|
|
1497
1819
|
skipFallback: !0,
|
|
1498
1820
|
label: "Data Form View",
|
|
@@ -1503,12 +1825,46 @@ ue.register("form", be, {
|
|
|
1503
1825
|
{ name: "mode", type: "enum", label: "Mode", enum: ["create", "edit", "view"] }
|
|
1504
1826
|
]
|
|
1505
1827
|
});
|
|
1828
|
+
const xt = ({ schema: e }) => /* @__PURE__ */ t.jsx(pt, { config: e });
|
|
1829
|
+
ue.register("embeddable-form", xt, {
|
|
1830
|
+
namespace: "plugin-form",
|
|
1831
|
+
label: "Embeddable Form",
|
|
1832
|
+
category: "plugin",
|
|
1833
|
+
inputs: [
|
|
1834
|
+
{ name: "formId", type: "string", label: "Form ID", required: !0 },
|
|
1835
|
+
{ name: "objectName", type: "string", label: "Object Name", required: !0 },
|
|
1836
|
+
{ name: "title", type: "string", label: "Form Title" },
|
|
1837
|
+
{ name: "description", type: "string", label: "Description" },
|
|
1838
|
+
{ name: "fields", type: "array", label: "Fields" },
|
|
1839
|
+
{ name: "allowMultiple", type: "boolean", label: "Allow Multiple Submissions" }
|
|
1840
|
+
]
|
|
1841
|
+
});
|
|
1842
|
+
const yt = ({ schema: e }) => /* @__PURE__ */ t.jsx(bt, { formId: e.formId, formTitle: e.formTitle, metrics: e.metrics || { totalSubmissions: 0 } });
|
|
1843
|
+
ue.register("form-analytics", yt, {
|
|
1844
|
+
namespace: "plugin-form",
|
|
1845
|
+
label: "Form Analytics",
|
|
1846
|
+
category: "plugin",
|
|
1847
|
+
inputs: [
|
|
1848
|
+
{ name: "formId", type: "string", label: "Form ID", required: !0 },
|
|
1849
|
+
{ name: "formTitle", type: "string", label: "Form Title" },
|
|
1850
|
+
{ name: "metrics", type: "object", label: "Submission Metrics" }
|
|
1851
|
+
]
|
|
1852
|
+
});
|
|
1506
1853
|
export {
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1854
|
+
ct as DrawerForm,
|
|
1855
|
+
pt as EmbeddableForm,
|
|
1856
|
+
bt as FormAnalytics,
|
|
1857
|
+
te as FormSection,
|
|
1858
|
+
ut as ModalForm,
|
|
1859
|
+
he as ObjectForm,
|
|
1860
|
+
lt as SplitForm,
|
|
1861
|
+
tt as TabbedForm,
|
|
1862
|
+
rt as WizardForm,
|
|
1863
|
+
we as applyAutoColSpan,
|
|
1864
|
+
ce as applyAutoLayout,
|
|
1865
|
+
dt as filterCreateModeFields,
|
|
1866
|
+
at as inferColumns,
|
|
1867
|
+
Ne as inferModalSize,
|
|
1868
|
+
st as isAutoGeneratedFieldType,
|
|
1869
|
+
ot as isWideFieldType
|
|
1514
1870
|
};
|