@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/dist/index.js CHANGED
@@ -1,445 +1,446 @@
1
- import J, { useState as g, useCallback as k, useMemo as Q, useEffect as W } from "react";
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 M } from "@object-ui/react";
4
- import { buildValidationRules as Y, mapFieldTypeToFormType as U, formatFileSize as ye, evaluateCondition as xe } from "@object-ui/fields";
5
- import { cn as V, Tabs as je, TabsList as ge, TabsTrigger as we, TabsContent as ve, Button as K, ResizablePanelGroup as Ne, ResizablePanel as se, ResizableHandle as Se, Sheet as Te, SheetContent as Ce, SheetHeader as Ee, SheetTitle as Oe, SheetDescription as _e, Dialog as Re, DialogContent as De, DialogHeader as Fe, DialogTitle as ke, DialogDescription as Ie } from "@object-ui/components";
6
- import { ChevronRight as pe, ChevronDown as ze, Check as Pe, ChevronLeft as Le } from "lucide-react";
7
- var ee = { exports: {} }, B = {};
8
- var ae;
9
- function he() {
10
- if (ae) return B;
11
- ae = 1;
12
- var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), l = /* @__PURE__ */ Symbol.for("react.fragment");
13
- function f(d, w, b) {
14
- var T = null;
15
- if (b !== void 0 && (T = "" + b), w.key !== void 0 && (T = "" + w.key), "key" in w) {
16
- b = {};
17
- for (var E in w)
18
- E !== "key" && (b[E] = w[E]);
19
- } else b = w;
20
- return w = b.ref, {
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: d,
23
- key: T,
24
- ref: w !== void 0 ? w : null,
25
- props: b
22
+ type: b,
23
+ key: x,
24
+ ref: o !== void 0 ? o : null,
25
+ props: p
26
26
  };
27
27
  }
28
- return B.Fragment = l, B.jsx = f, B.jsxs = f, B;
28
+ return ie.Fragment = r, ie.jsx = i, ie.jsxs = i, ie;
29
29
  }
30
- var X = {};
31
- var de;
32
- function Ae() {
33
- return de || (de = 1, process.env.NODE_ENV !== "production" && (function() {
34
- function e(r) {
35
- if (r == null) return null;
36
- if (typeof r == "function")
37
- return r.$$typeof === $ ? null : r.displayName || r.name || null;
38
- if (typeof r == "string") return r;
39
- switch (r) {
40
- case F:
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 q:
42
+ case k:
43
43
  return "Profiler";
44
- case _:
44
+ case L:
45
45
  return "StrictMode";
46
- case o:
46
+ case n:
47
47
  return "Suspense";
48
48
  case a:
49
49
  return "SuspenseList";
50
- case v:
50
+ case S:
51
51
  return "Activity";
52
52
  }
53
- if (typeof r == "object")
54
- switch (typeof r.tag == "number" && console.error(
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
- ), r.$$typeof) {
57
- case A:
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 r.displayName || "Context";
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
- return m = r.displayName || null, m !== null ? m : e(r.type) || "Memo";
68
- case i:
69
- m = r._payload, r = r._init;
69
+ w = l._payload, l = l._init;
70
70
  try {
71
- return e(r(m));
71
+ return e(l(w));
72
72
  } catch {
73
73
  }
74
74
  }
75
75
  return null;
76
76
  }
77
- function l(r) {
78
- return "" + r;
77
+ function r(l) {
78
+ return "" + l;
79
79
  }
80
- function f(r) {
80
+ function i(l) {
81
81
  try {
82
- l(r);
83
- var m = !1;
82
+ r(l);
83
+ var w = !1;
84
84
  } catch {
85
- m = !0;
85
+ w = !0;
86
86
  }
87
- if (m) {
88
- m = console;
89
- var O = m.error, I = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
90
- return O.call(
91
- m,
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
- I
94
- ), l(r);
93
+ $
94
+ ), r(l);
95
95
  }
96
96
  }
97
- function d(r) {
98
- if (r === F) return "<>";
99
- if (typeof r == "object" && r !== null && r.$$typeof === i)
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 m = e(r);
103
- return m ? "<" + m + ">" : "<...>";
102
+ var w = e(l);
103
+ return w ? "<" + w + ">" : "<...>";
104
104
  } catch {
105
105
  return "<...>";
106
106
  }
107
107
  }
108
- function w() {
109
- var r = p.A;
110
- return r === null ? null : r.getOwner();
108
+ function o() {
109
+ var l = d.A;
110
+ return l === null ? null : l.getOwner();
111
111
  }
112
- function b() {
112
+ function p() {
113
113
  return Error("react-stack-top-frame");
114
114
  }
115
- function T(r) {
116
- if (x.call(r, "key")) {
117
- var m = Object.getOwnPropertyDescriptor(r, "key").get;
118
- if (m && m.isReactWarning) return !1;
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 r.key !== void 0;
120
+ return l.key !== void 0;
121
121
  }
122
- function E(r, m) {
123
- function O() {
124
- h || (h = !0, console.error(
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
- m
126
+ w
127
127
  ));
128
128
  }
129
- O.isReactWarning = !0, Object.defineProperty(r, "key", {
130
- get: O,
129
+ P.isReactWarning = !0, Object.defineProperty(l, "key", {
130
+ get: P,
131
131
  configurable: !0
132
132
  });
133
133
  }
134
- function S() {
135
- var r = e(this.type);
136
- return le[r] || (le[r] = !0, console.error(
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
- )), r = this.props.ref, r !== void 0 ? r : null;
138
+ )), l = this.props.ref, l !== void 0 ? l : null;
139
139
  }
140
- function C(r, m, O, I, Z, te) {
141
- var z = O.ref;
142
- return r = {
143
- $$typeof: P,
144
- type: r,
145
- key: m,
146
- props: O,
147
- _owner: I
148
- }, (z !== void 0 ? z : null) !== null ? Object.defineProperty(r, "ref", {
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: S
151
- }) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
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(r, "_debugInfo", {
156
+ }), Object.defineProperty(l, "_debugInfo", {
157
157
  configurable: !1,
158
158
  enumerable: !1,
159
159
  writable: !0,
160
160
  value: null
161
- }), Object.defineProperty(r, "_debugStack", {
161
+ }), Object.defineProperty(l, "_debugStack", {
162
162
  configurable: !1,
163
163
  enumerable: !1,
164
164
  writable: !0,
165
- value: Z
166
- }), Object.defineProperty(r, "_debugTask", {
165
+ value: se
166
+ }), Object.defineProperty(l, "_debugTask", {
167
167
  configurable: !1,
168
168
  enumerable: !1,
169
169
  writable: !0,
170
- value: te
171
- }), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
170
+ value: fe
171
+ }), Object.freeze && (Object.freeze(l.props), Object.freeze(l)), l;
172
172
  }
173
- function j(r, m, O, I, Z, te) {
174
- var z = m.children;
175
- if (z !== void 0)
176
- if (I)
177
- if (R(z)) {
178
- for (I = 0; I < z.length; I++)
179
- y(z[I]);
180
- Object.freeze && Object.freeze(z);
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 y(z);
186
- if (x.call(m, "key")) {
187
- z = e(r);
188
- var H = Object.keys(m).filter(function(me) {
189
- return me !== "key";
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
- I = 0 < H.length ? "{key: someKey, " + H.join(": ..., ") + ": ...}" : "{key: someKey}", oe[z + I] || (H = 0 < H.length ? "{" + H.join(": ..., ") + ": ...}" : "{}", console.error(
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
- I,
199
- z,
200
- H,
201
- z
202
- ), oe[z + I] = !0);
198
+ $,
199
+ q,
200
+ Q,
201
+ q
202
+ ), R[q + $] = !0);
203
203
  }
204
- if (z = null, O !== void 0 && (f(O), z = "" + O), T(m) && (f(m.key), z = "" + m.key), "key" in m) {
205
- O = {};
206
- for (var re in m)
207
- re !== "key" && (O[re] = m[re]);
208
- } else O = m;
209
- return z && E(
210
- O,
211
- typeof r == "function" ? r.displayName || r.name || "Unknown" : r
212
- ), C(
213
- r,
214
- z,
215
- O,
216
- w(),
217
- Z,
218
- te
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 y(r) {
222
- N(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === i && (r._payload.status === "fulfilled" ? N(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
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 N(r) {
225
- return typeof r == "object" && r !== null && r.$$typeof === P;
224
+ function j(l) {
225
+ return typeof l == "object" && l !== null && l.$$typeof === v;
226
226
  }
227
- var D = J, P = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), F = /* @__PURE__ */ Symbol.for("react.fragment"), _ = /* @__PURE__ */ Symbol.for("react.strict_mode"), q = /* @__PURE__ */ Symbol.for("react.profiler"), u = /* @__PURE__ */ Symbol.for("react.consumer"), s = /* @__PURE__ */ Symbol.for("react.context"), n = /* @__PURE__ */ Symbol.for("react.forward_ref"), o = /* @__PURE__ */ Symbol.for("react.suspense"), a = /* @__PURE__ */ Symbol.for("react.suspense_list"), c = /* @__PURE__ */ Symbol.for("react.memo"), i = /* @__PURE__ */ Symbol.for("react.lazy"), v = /* @__PURE__ */ Symbol.for("react.activity"), $ = /* @__PURE__ */ Symbol.for("react.client.reference"), p = D.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, x = Object.prototype.hasOwnProperty, R = Array.isArray, L = console.createTask ? console.createTask : function() {
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
- D = {
231
- react_stack_bottom_frame: function(r) {
232
- return r();
230
+ h = {
231
+ react_stack_bottom_frame: function(l) {
232
+ return l();
233
233
  }
234
234
  };
235
- var h, le = {}, ne = D.react_stack_bottom_frame.bind(
236
- D,
237
- b
238
- )(), ie = L(d(b)), oe = {};
239
- X.Fragment = F, X.jsx = function(r, m, O) {
240
- var I = 1e4 > p.recentlyCreatedOwnerStacks++;
241
- return j(
242
- r,
243
- m,
244
- O,
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
- I ? Error("react-stack-top-frame") : ne,
247
- I ? L(d(r)) : ie
246
+ $ ? Error("react-stack-top-frame") : V,
247
+ $ ? u(b(l)) : Y
248
248
  );
249
- }, X.jsxs = function(r, m, O) {
250
- var I = 1e4 > p.recentlyCreatedOwnerStacks++;
251
- return j(
252
- r,
253
- m,
254
- O,
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
- I ? Error("react-stack-top-frame") : ne,
257
- I ? L(d(r)) : ie
256
+ $ ? Error("react-stack-top-frame") : V,
257
+ $ ? u(b(l)) : Y
258
258
  );
259
259
  };
260
- })()), X;
260
+ })()), oe;
261
261
  }
262
- var ce;
263
- function Ve() {
264
- return ce || (ce = 1, process.env.NODE_ENV === "production" ? ee.exports = he() : ee.exports = Ae()), ee.exports;
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 = Ve();
267
- const G = ({
266
+ var t = et();
267
+ const te = ({
268
268
  label: e,
269
- description: l,
270
- collapsible: f = !1,
271
- collapsed: d = !1,
272
- columns: w = 1,
273
- children: b,
274
- className: T
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 [E, S] = g(d), C = {
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
- }, j = () => {
282
- f && S(!E);
282
+ }, N = () => {
283
+ i && O(!I);
283
284
  };
284
- return /* @__PURE__ */ t.jsxs("div", { className: V("form-section", T), children: [
285
- (e || l) && /* @__PURE__ */ t.jsxs(
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: V(
289
+ className: W(
289
290
  "flex items-start gap-2 mb-4",
290
- f && "cursor-pointer select-none"
291
+ i && "cursor-pointer select-none"
291
292
  ),
292
- onClick: j,
293
- role: f ? "button" : void 0,
294
- "aria-expanded": f ? !E : void 0,
293
+ onClick: N,
294
+ role: i ? "button" : void 0,
295
+ "aria-expanded": i ? !I : void 0,
295
296
  children: [
296
- f && /* @__PURE__ */ t.jsx("span", { className: "mt-0.5 text-muted-foreground", children: E ? /* @__PURE__ */ t.jsx(pe, { className: "h-4 w-4" }) : /* @__PURE__ */ t.jsx(ze, { className: "h-4 w-4" }) }),
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
- l && /* @__PURE__ */ t.jsx("p", { className: "text-sm text-muted-foreground mt-0.5", children: l })
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
- !E && /* @__PURE__ */ t.jsx("div", { className: V("grid gap-4", C[w]), children: b })
305
+ !I && /* @__PURE__ */ t.jsx("div", { className: W("grid gap-4", E || F[o]), children: p })
305
306
  ] });
306
- }, qe = ({
307
+ }, tt = ({
307
308
  schema: e,
308
- dataSource: l,
309
- className: f
309
+ dataSource: r,
310
+ className: i
310
311
  }) => {
311
- const [d, w] = g(null), [b, T] = g({}), [E, S] = g(!0), [C, j] = g(null), [y, N] = g(
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
- J.useEffect(() => {
315
+ K.useEffect(() => {
315
316
  (async () => {
316
- if (!l) {
317
- S(!1);
317
+ if (!r) {
318
+ O(!1);
318
319
  return;
319
320
  }
320
321
  try {
321
- const n = await l.getObjectSchema(e.objectName);
322
- w(n);
322
+ const n = await r.getObjectSchema(e.objectName);
323
+ p(n);
323
324
  } catch (n) {
324
- j(n);
325
+ N(n);
325
326
  }
326
327
  })();
327
- }, [e.objectName, l]), J.useEffect(() => {
328
- (d || !l) && (async () => {
329
- if (e.mode === "create" || !e.recordId || !l) {
330
- T(e.initialData || e.initialValues || {}), S(!1);
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 l.findOne(e.objectName, e.recordId);
335
- T(n || {});
335
+ const n = await r.findOne(e.objectName, e.recordId);
336
+ E(n || {});
336
337
  } catch (n) {
337
- j(n);
338
+ N(n);
338
339
  } finally {
339
- S(!1);
340
+ O(!1);
340
341
  }
341
342
  })();
342
- }, [d, e.mode, e.recordId, e.initialData, e.initialValues, l, e.objectName]);
343
- const D = k((s) => {
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 o of s.fields) {
346
- const a = typeof o == "string" ? o : o.name;
347
- if (typeof o == "object")
348
- n.push(o);
349
- else if (d?.fields?.[a]) {
350
- const c = d.fields[a];
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: a,
353
- label: c.label || a,
354
- type: U(c.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: Y(c),
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: a,
367
- label: a,
367
+ name: s,
368
+ label: s,
368
369
  type: "input"
369
370
  });
370
371
  }
371
372
  return n;
372
- }, [d, e.readOnly, e.mode]), P = k(async (s) => {
373
- if (!l)
374
- return e.onSuccess && await e.onSuccess(s), s;
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 l.create(e.objectName, s) : e.mode === "edit" && e.recordId && (n = await l.update(e.objectName, e.recordId, s)), e.onSuccess && await e.onSuccess(n), n;
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, l]), A = k(() => {
382
+ }, [e, r]), z = A(() => {
382
383
  e.onCancel && e.onCancel();
383
- }, [e]), F = (s, n) => s.name || s.label || `tab-${n}`;
384
- if (C)
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: C.message })
388
+ /* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: F.message })
388
389
  ] });
389
- if (E)
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 q = {
395
+ const U = {
395
396
  type: "form",
396
- fields: e.sections.flatMap((s) => D(s)),
397
+ fields: e.sections.flatMap((f) => v(f)),
397
398
  layout: "vertical",
398
- defaultValues: b,
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: P,
404
- onCancel: A
405
- }, u = e.tabPosition === "left" || e.tabPosition === "right";
406
- return /* @__PURE__ */ t.jsx("div", { className: V("w-full", f, e.className), children: /* @__PURE__ */ t.jsxs(
407
- je,
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: y,
410
- onValueChange: N,
411
- orientation: u ? "vertical" : "horizontal",
412
- className: V(u && "flex gap-4"),
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(ge, { className: V(
415
- u ? "flex-col h-auto" : "",
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((s, n) => /* @__PURE__ */ t.jsx(
419
- we,
419
+ ), children: e.sections.map((f, n) => /* @__PURE__ */ t.jsx(
420
+ Ie,
420
421
  {
421
- value: F(s, n),
422
- className: u ? "w-full justify-start" : "",
423
- children: s.label || `Tab ${n + 1}`
422
+ value: L(f, n),
423
+ className: M ? "w-full justify-start" : "",
424
+ children: f.label || `Tab ${n + 1}`
424
425
  },
425
- F(s, n)
426
+ L(f, n)
426
427
  )) }),
427
- /* @__PURE__ */ t.jsx("div", { className: "flex-1", children: e.sections.map((s, n) => /* @__PURE__ */ t.jsx(
428
- ve,
428
+ /* @__PURE__ */ t.jsx("div", { className: "flex-1", children: e.sections.map((f, n) => /* @__PURE__ */ t.jsx(
429
+ Le,
429
430
  {
430
- value: F(s, n),
431
+ value: L(f, n),
431
432
  className: "mt-0",
432
433
  children: /* @__PURE__ */ t.jsx(
433
- G,
434
+ te,
434
435
  {
435
- description: s.description,
436
- columns: s.columns || 1,
436
+ description: f.description,
437
+ columns: f.columns || 1,
437
438
  children: /* @__PURE__ */ t.jsx(
438
- M,
439
+ J,
439
440
  {
440
441
  schema: {
441
- ...q,
442
- fields: D(s),
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
- F(s, n)
453
+ L(f, n)
453
454
  )) })
454
455
  ]
455
456
  }
456
457
  ) });
457
- }, We = ({
458
+ }, rt = ({
458
459
  schema: e,
459
- dataSource: l,
460
- className: f
460
+ dataSource: r,
461
+ className: i
461
462
  }) => {
462
- const [d, w] = g(null), [b, T] = g({}), [E, S] = g(!0), [C, j] = g(null), [y, N] = g(0), [D, P] = g(/* @__PURE__ */ new Set()), [A, F] = g(!1), _ = e.sections.length, q = y === 0, u = y === _ - 1;
463
- J.useEffect(() => {
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 (!l) {
466
- S(!1);
466
+ if (!r) {
467
+ O(!1);
467
468
  return;
468
469
  }
469
470
  try {
470
- const x = await l.getObjectSchema(e.objectName);
471
- w(x);
472
- } catch (x) {
473
- j(x);
471
+ const T = await r.getObjectSchema(e.objectName);
472
+ p(T);
473
+ } catch (T) {
474
+ N(T);
474
475
  }
475
476
  })();
476
- }, [e.objectName, l]), J.useEffect(() => {
477
- (d || !l) && (async () => {
478
- if (e.mode === "create" || !e.recordId || !l) {
479
- T(e.initialData || e.initialValues || {}), S(!1);
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 x = await l.findOne(e.objectName, e.recordId);
484
- T(x || {});
485
- } catch (x) {
486
- j(x);
484
+ const T = await r.findOne(e.objectName, e.recordId);
485
+ E(T || {});
486
+ } catch (T) {
487
+ N(T);
487
488
  } finally {
488
- S(!1);
489
+ O(!1);
489
490
  }
490
491
  })();
491
- }, [d, e.mode, e.recordId, e.initialData, e.initialValues, l, e.objectName]);
492
- const s = k((p) => {
493
- const x = [];
494
- for (const R of p.fields) {
495
- const L = typeof R == "string" ? R : R.name;
496
- if (typeof R == "object")
497
- x.push(R);
498
- else if (d?.fields?.[L]) {
499
- const h = d.fields[L];
500
- x.push({
501
- name: L,
502
- label: h.label || L,
503
- type: U(h.type),
504
- required: h.required || !1,
505
- disabled: e.readOnly || e.mode === "view" || h.readonly,
506
- placeholder: h.placeholder,
507
- description: h.help || h.description,
508
- validation: Y(h),
509
- field: h,
510
- options: h.options,
511
- multiple: h.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
- x.push({
515
- name: L,
516
- label: L,
515
+ T.push({
516
+ name: g,
517
+ label: g,
517
518
  type: "input"
518
519
  });
519
520
  }
520
- return x;
521
- }, [d, e.readOnly, e.mode]), n = Q(() => y >= 0 && y < _ ? s(e.sections[y]) : [], [y, _, e.sections, s]), o = k(async (p) => {
522
- const x = { ...b, ...p };
523
- if (T(x), P((R) => new Set(R).add(y)), u) {
524
- F(!0);
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 (!l)
527
- return e.onSuccess && await e.onSuccess(x), x;
528
- let R;
529
- return e.mode === "create" ? R = await l.create(e.objectName, x) : e.mode === "edit" && e.recordId && (R = await l.update(e.objectName, e.recordId, x)), e.onSuccess && await e.onSuccess(R), R;
530
- } catch (R) {
531
- throw e.onError && e.onError(R), R;
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
- F(!1);
534
+ L(!1);
534
535
  }
535
536
  } else
536
- a(y + 1);
537
- }, [b, y, u, e, l]), a = k((p) => {
538
- p >= 0 && p < _ && (N(p), e.onStepChange && e.onStepChange(p));
539
- }, [_, e]), c = k(() => {
540
- a(y - 1);
541
- }, [y, a]), i = k(() => {
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]), v = k((p) => {
544
- (e.allowSkip || D.has(p) || p <= y) && a(p);
545
- }, [e.allowSkip, D, y, a]);
546
- if (C)
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: C.message })
550
+ /* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: F.message })
550
551
  ] });
551
- if (E)
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 $ = e.sections[y];
557
- return /* @__PURE__ */ t.jsxs("div", { className: V("w-full", f, e.className), children: [
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((p, x) => {
559
- const R = x === y, L = D.has(x), h = e.allowSkip || L || x <= y;
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: V(
564
+ className: W(
564
565
  "relative flex-1",
565
- x !== _ - 1 && "pr-8 sm:pr-12"
566
+ T !== k - 1 && "pr-8 sm:pr-12"
566
567
  ),
567
568
  children: [
568
- x !== _ - 1 && /* @__PURE__ */ t.jsx(
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: V(
577
+ className: W(
577
578
  "h-full",
578
- L ? "bg-primary" : "bg-muted"
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: V(
589
+ className: W(
589
590
  "group relative flex items-center",
590
- h ? "cursor-pointer" : "cursor-not-allowed"
591
+ m ? "cursor-pointer" : "cursor-not-allowed"
591
592
  ),
592
- onClick: () => v(x),
593
- disabled: !h,
593
+ onClick: () => y(T),
594
+ disabled: !m,
594
595
  children: [
595
596
  /* @__PURE__ */ t.jsx(
596
597
  "span",
597
598
  {
598
- className: V(
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
- L && "bg-primary text-primary-foreground",
601
- R && !L && "border-2 border-primary bg-background text-primary",
602
- !R && !L && "border-2 border-muted bg-background text-muted-foreground"
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: L ? /* @__PURE__ */ t.jsx(Pe, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : x + 1
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: V(
611
- R ? "text-foreground" : "text-muted-foreground"
611
+ className: W(
612
+ u ? "text-foreground" : "text-muted-foreground"
612
613
  ),
613
- children: p.label || `Step ${x + 1}`
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
- x
622
+ T
622
623
  );
623
624
  }) }) }),
624
- /* @__PURE__ */ t.jsx("div", { className: "min-h-[200px]", children: $ && /* @__PURE__ */ t.jsx(
625
- G,
625
+ /* @__PURE__ */ t.jsx("div", { className: "min-h-[200px]", children: d && /* @__PURE__ */ t.jsx(
626
+ te,
626
627
  {
627
- label: $.label,
628
- description: $.description,
629
- columns: $.columns || 1,
628
+ label: d.label,
629
+ description: d.description,
630
+ columns: d.columns || 1,
630
631
  children: n.length > 0 ? /* @__PURE__ */ t.jsx(
631
- M,
632
+ J,
632
633
  {
633
634
  schema: {
634
635
  type: "form",
635
636
  fields: n,
636
637
  layout: "vertical",
637
- defaultValues: b,
638
+ defaultValues: x,
638
639
  showSubmit: !1,
639
640
  showCancel: !1,
640
- onSubmit: o
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
- K,
649
+ Z,
649
650
  {
650
651
  variant: "ghost",
651
- onClick: i,
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
- y + 1,
659
+ j + 1,
659
660
  " of ",
660
- _
661
+ k
661
662
  ] }),
662
- !q && /* @__PURE__ */ t.jsxs(
663
- K,
663
+ !U && /* @__PURE__ */ t.jsxs(
664
+ Z,
664
665
  {
665
666
  variant: "outline",
666
667
  onClick: c,
667
668
  children: [
668
- /* @__PURE__ */ t.jsx(Le, { className: "h-4 w-4 mr-1" }),
669
+ /* @__PURE__ */ t.jsx(Xe, { className: "h-4 w-4 mr-1" }),
669
670
  e.prevText || "Back"
670
671
  ]
671
672
  }
672
673
  ),
673
- u ? /* @__PURE__ */ t.jsx(
674
- K,
674
+ M ? /* @__PURE__ */ t.jsx(
675
+ Z,
675
676
  {
676
- onClick: () => o(b),
677
- disabled: A || e.mode === "view",
678
- children: A ? "Submitting..." : e.submitText || (e.mode === "create" ? "Create" : "Update")
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
- K,
682
+ Z,
682
683
  {
683
- onClick: () => o(b),
684
+ onClick: () => a(x),
684
685
  children: [
685
686
  e.nextText || "Next",
686
- /* @__PURE__ */ t.jsx(pe, { className: "h-4 w-4 ml-1" })
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
- }, $e = ({
694
+ }, lt = ({
694
695
  schema: e,
695
- dataSource: l,
696
- className: f
696
+ dataSource: r,
697
+ className: i
697
698
  }) => {
698
- const [d, w] = g(null), [b, T] = g({}), [E, S] = g(!0), [C, j] = g(null);
699
- W(() => {
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 (!l) {
702
- S(!1);
702
+ if (!r) {
703
+ O(!1);
703
704
  return;
704
705
  }
705
706
  try {
706
- const n = await l.getObjectSchema(e.objectName);
707
- w(n);
707
+ const n = await r.getObjectSchema(e.objectName);
708
+ p(n);
708
709
  } catch (n) {
709
- j(n), S(!1);
710
+ N(n), O(!1);
710
711
  }
711
712
  })();
712
- }, [e.objectName, l]), W(() => {
713
- (d || !l) && (async () => {
713
+ }, [e.objectName, r]), H(() => {
714
+ (o || !r) && (async () => {
714
715
  if (e.mode === "create" || !e.recordId) {
715
- T(e.initialData || e.initialValues || {}), S(!1);
716
+ E(e.initialData || e.initialValues || {}), O(!1);
716
717
  return;
717
718
  }
718
- if (!l) {
719
- T(e.initialData || e.initialValues || {}), S(!1);
719
+ if (!r) {
720
+ E(e.initialData || e.initialValues || {}), O(!1);
720
721
  return;
721
722
  }
722
723
  try {
723
- const n = await l.findOne(e.objectName, e.recordId);
724
- T(n || {});
724
+ const n = await r.findOne(e.objectName, e.recordId);
725
+ E(n || {});
725
726
  } catch (n) {
726
- j(n);
727
+ N(n);
727
728
  } finally {
728
- S(!1);
729
+ O(!1);
729
730
  }
730
731
  })();
731
- }, [d, e.mode, e.recordId, e.initialData, e.initialValues, l, e.objectName]);
732
- const y = k((s) => {
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 o of s.fields) {
735
- const a = typeof o == "string" ? o : o.name;
736
- if (typeof o == "object")
737
- n.push(o);
738
- else if (d?.fields?.[a]) {
739
- const c = d.fields[a];
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: a,
742
- label: c.label || a,
743
- type: U(c.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: Y(c),
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: a,
756
- label: a,
756
+ name: s,
757
+ label: s,
757
758
  type: "input"
758
759
  });
759
760
  }
760
761
  return n;
761
- }, [d, e.readOnly, e.mode]), N = k(async (s) => {
762
- if (!l)
763
- return e.onSuccess && await e.onSuccess(s), s;
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 l.create(e.objectName, s) : e.mode === "edit" && e.recordId && (n = await l.update(e.objectName, e.recordId, s)), e.onSuccess && await e.onSuccess(n), n;
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, l]), D = k(() => {
771
+ }, [e, r]), v = A(() => {
771
772
  e.onCancel && e.onCancel();
772
- }, [e]), P = Q(() => e.sections.slice(0, 1), [e.sections]), A = Q(() => e.sections.slice(1), [e.sections]);
773
- Q(
774
- () => e.sections.flatMap((s) => y(s)),
775
- [e.sections, y]
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 F = e.splitDirection || "horizontal", _ = e.splitSize || 50;
778
- if (C)
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: C.message })
782
+ /* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: F.message })
782
783
  ] });
783
- if (E)
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 q = {
789
+ const U = {
789
790
  type: "form",
790
791
  layout: "vertical",
791
- defaultValues: b,
792
- onSubmit: N,
793
- onCancel: D
794
- }, u = (s, n) => /* @__PURE__ */ t.jsx("div", { className: "space-y-4 p-4", children: s.map((o, a) => /* @__PURE__ */ t.jsx(
795
- G,
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: o.label,
798
- description: o.description,
799
- columns: o.columns || 1,
798
+ label: a.label,
799
+ description: a.description,
800
+ columns: a.columns || 1,
800
801
  children: /* @__PURE__ */ t.jsx(
801
- M,
802
+ J,
802
803
  {
803
804
  schema: {
804
- ...q,
805
- fields: y(o),
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
- o.name || o.label || a
815
+ a.name || a.label || s
815
816
  )) });
816
- return /* @__PURE__ */ t.jsx("div", { className: V("w-full", f, e.className), children: /* @__PURE__ */ t.jsxs(Ne, { orientation: F, className: "min-h-[300px] rounded-lg border", children: [
817
- /* @__PURE__ */ t.jsx(se, { defaultSize: _, minSize: 20, children: u(P, A.length === 0) }),
818
- A.length > 0 && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
819
- /* @__PURE__ */ t.jsx(Se, { withHandle: e.splitResizable !== !1 }),
820
- /* @__PURE__ */ t.jsx(se, { defaultSize: 100 - _, minSize: 20, children: u(A, !0) })
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
- }, Me = ({
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: l,
826
- className: f
876
+ dataSource: r,
877
+ className: i
827
878
  }) => {
828
- const [d, w] = g(null), [b, T] = g([]), [E, S] = g({}), [C, j] = g(!0), [y, N] = g(null), D = e.open !== !1, P = e.drawerSide || "right";
829
- W(() => {
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 (!l) {
832
- j(!1);
882
+ if (!r) {
883
+ N(!1);
833
884
  return;
834
885
  }
835
886
  try {
836
- const a = await l.getObjectSchema(e.objectName);
837
- w(a);
838
- } catch (a) {
839
- N(a), j(!1);
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, l]), W(() => {
843
- (d || !l) && (async () => {
893
+ }, [e.objectName, r]), H(() => {
894
+ (o || !r) && (async () => {
844
895
  if (e.mode === "create" || !e.recordId) {
845
- S(e.initialData || e.initialValues || {}), j(!1);
896
+ O(e.initialData || e.initialValues || {}), N(!1);
846
897
  return;
847
898
  }
848
- if (!l) {
849
- S(e.initialData || e.initialValues || {}), j(!1);
899
+ if (!r) {
900
+ O(e.initialData || e.initialValues || {}), N(!1);
850
901
  return;
851
902
  }
852
903
  try {
853
- const a = await l.findOne(e.objectName, e.recordId);
854
- S(a || {});
855
- } catch (a) {
856
- N(a);
904
+ const s = await r.findOne(e.objectName, e.recordId);
905
+ O(s || {});
906
+ } catch (s) {
907
+ h(s);
857
908
  } finally {
858
- j(!1);
909
+ N(!1);
859
910
  }
860
911
  })();
861
- }, [d, e.mode, e.recordId, e.initialData, e.initialValues, l, e.objectName]);
862
- const A = k((o) => {
863
- const a = [];
864
- for (const c of o.fields) {
865
- const i = typeof c == "string" ? c : c.name;
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
- a.push(c);
868
- else if (d?.fields?.[i]) {
869
- const v = d.fields[i];
870
- a.push({
871
- name: i,
872
- label: v.label || i,
873
- type: U(v.type),
874
- required: v.required || !1,
875
- disabled: e.readOnly || e.mode === "view" || v.readonly,
876
- placeholder: v.placeholder,
877
- description: v.help || v.description,
878
- validation: Y(v),
879
- field: v,
880
- options: v.options,
881
- multiple: v.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
- a.push({
885
- name: i,
886
- label: i,
935
+ s.push({
936
+ name: S,
937
+ label: S,
887
938
  type: "input"
888
939
  });
889
940
  }
890
- return a;
891
- }, [d, e.readOnly, e.mode]);
892
- W(() => {
893
- if (!d && l) return;
941
+ return s;
942
+ }, [o, e.readOnly, e.mode]);
943
+ H(() => {
944
+ if (!o && r) return;
894
945
  if (e.customFields?.length) {
895
- T(e.customFields), j(!1);
946
+ E(e.customFields), N(!1);
896
947
  return;
897
948
  }
898
949
  if (e.sections?.length) {
899
- j(!1);
950
+ N(!1);
900
951
  return;
901
952
  }
902
- if (!d) return;
903
- const o = e.fields || Object.keys(d.fields || {}), a = [];
904
- for (const c of o) {
905
- const i = typeof c == "string" ? c : c.name;
906
- if (!i) continue;
907
- const v = d.fields?.[i];
908
- v && a.push({
909
- name: i,
910
- label: v.label || i,
911
- type: U(v.type),
912
- required: v.required || !1,
913
- disabled: e.readOnly || e.mode === "view" || v.readonly,
914
- placeholder: v.placeholder,
915
- description: v.help || v.description,
916
- validation: Y(v),
917
- field: v,
918
- options: v.options,
919
- multiple: v.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
- T(a), j(!1);
923
- }, [d, e.fields, e.customFields, e.sections, e.readOnly, e.mode, l]);
924
- const F = k(async (o) => {
925
- if (!l)
926
- return e.onSuccess && await e.onSuccess(o), e.onOpenChange?.(!1), o;
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 a;
929
- return e.mode === "create" ? a = await l.create(e.objectName, o) : e.mode === "edit" && e.recordId && (a = await l.update(e.objectName, e.recordId, o)), e.onSuccess && await e.onSuccess(a), e.onOpenChange?.(!1), a;
930
- } catch (a) {
931
- throw e.onError && e.onError(a), a;
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, l]), _ = k(() => {
984
+ }, [e, r]), k = A(() => {
934
985
  e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
935
- }, [e]), q = Q(() => e.drawerWidth ? P === "left" || P === "right" ? { width: e.drawerWidth, maxWidth: e.drawerWidth } : { height: e.drawerWidth, maxHeight: e.drawerWidth } : void 0, [e.drawerWidth, P]), s = {
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: E,
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: F,
944
- onCancel: _
945
- }, n = () => y ? /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
946
- /* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
947
- /* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: y.message })
948
- ] }) : C ? /* @__PURE__ */ t.jsxs("div", { className: "p-8 text-center", children: [
949
- /* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
950
- /* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
951
- ] }) : e.sections?.length ? /* @__PURE__ */ t.jsx("div", { className: "space-y-6", children: e.sections.map((o, a) => /* @__PURE__ */ t.jsx(
952
- G,
953
- {
954
- label: o.label,
955
- description: o.description,
956
- columns: o.columns || 1,
957
- children: /* @__PURE__ */ t.jsx(
958
- M,
959
- {
960
- schema: {
961
- ...s,
962
- fields: A(o),
963
- showSubmit: a === e.sections.length - 1 && s.showSubmit,
964
- showCancel: a === e.sections.length - 1 && s.showCancel
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(Te, { open: D, onOpenChange: e.onOpenChange, children: /* @__PURE__ */ t.jsxs(
981
- Ce,
1043
+ );
1044
+ };
1045
+ return /* @__PURE__ */ t.jsx(ze, { open: v, onOpenChange: e.onOpenChange, children: /* @__PURE__ */ t.jsxs(
1046
+ Ve,
982
1047
  {
983
- side: P,
984
- className: V("overflow-y-auto", f, e.className),
985
- style: q,
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(Ee, { children: [
988
- e.title && /* @__PURE__ */ t.jsx(Oe, { children: e.title }),
989
- e.description && /* @__PURE__ */ t.jsx(_e, { children: e.description })
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
- }, fe = {
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
- }, Ye = ({
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: l,
1004
- className: f
1074
+ dataSource: r,
1075
+ className: i
1005
1076
  }) => {
1006
- const [d, w] = g(null), [b, T] = g([]), [E, S] = g({}), [C, j] = g(!0), [y, N] = g(null), D = e.open !== !1, P = fe[e.modalSize || "default"] || fe.default;
1007
- W(() => {
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 (!l) {
1010
- j(!1);
1089
+ if (!r) {
1090
+ N(!1);
1011
1091
  return;
1012
1092
  }
1013
1093
  try {
1014
- const o = await l.getObjectSchema(e.objectName);
1015
- w(o);
1016
- } catch (o) {
1017
- N(o), j(!1);
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, l]), W(() => {
1021
- (d || !l) && (async () => {
1100
+ }, [e.objectName, r]), H(() => {
1101
+ (o || !r) && (async () => {
1022
1102
  if (e.mode === "create" || !e.recordId) {
1023
- S(e.initialData || e.initialValues || {}), j(!1);
1103
+ O(e.initialData || e.initialValues || {}), N(!1);
1024
1104
  return;
1025
1105
  }
1026
- if (!l) {
1027
- S(e.initialData || e.initialValues || {}), j(!1);
1106
+ if (!r) {
1107
+ O(e.initialData || e.initialValues || {}), N(!1);
1028
1108
  return;
1029
1109
  }
1030
1110
  try {
1031
- const o = await l.findOne(e.objectName, e.recordId);
1032
- S(o || {});
1033
- } catch (o) {
1034
- N(o);
1111
+ const m = await r.findOne(e.objectName, e.recordId);
1112
+ O(m || {});
1113
+ } catch (m) {
1114
+ h(m);
1035
1115
  } finally {
1036
- j(!1);
1116
+ N(!1);
1037
1117
  }
1038
1118
  })();
1039
- }, [d, e.mode, e.recordId, e.initialData, e.initialValues, l, e.objectName]);
1040
- const A = k((n) => {
1041
- const o = [];
1042
- for (const a of n.fields) {
1043
- const c = typeof a == "string" ? a : a.name;
1044
- if (typeof a == "object")
1045
- o.push(a);
1046
- else if (d?.fields?.[c]) {
1047
- const i = d.fields[c];
1048
- o.push({
1049
- name: c,
1050
- label: i.label || c,
1051
- type: U(i.type),
1052
- required: i.required || !1,
1053
- disabled: e.readOnly || e.mode === "view" || i.readonly,
1054
- placeholder: i.placeholder,
1055
- description: i.help || i.description,
1056
- validation: Y(i),
1057
- field: i,
1058
- options: i.options,
1059
- multiple: i.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
- o.push({
1063
- name: c,
1064
- label: c,
1142
+ m.push({
1143
+ name: Y,
1144
+ label: Y,
1065
1145
  type: "input"
1066
1146
  });
1067
1147
  }
1068
- return o;
1069
- }, [d, e.readOnly, e.mode]);
1070
- W(() => {
1071
- if (!d && l) return;
1148
+ return m;
1149
+ }, [o, e.readOnly, e.mode]);
1150
+ H(() => {
1151
+ if (!o && r) return;
1072
1152
  if (e.customFields?.length) {
1073
- T(e.customFields), j(!1);
1153
+ E(e.customFields), N(!1);
1074
1154
  return;
1075
1155
  }
1076
1156
  if (e.sections?.length) {
1077
- j(!1);
1157
+ N(!1);
1078
1158
  return;
1079
1159
  }
1080
- if (!d) return;
1081
- const n = e.fields || Object.keys(d.fields || {}), o = [];
1082
- for (const a of n) {
1083
- const c = typeof a == "string" ? a : a.name;
1084
- if (!c) continue;
1085
- const i = d.fields?.[c];
1086
- i && o.push({
1087
- name: c,
1088
- label: i.label || c,
1089
- type: U(i.type),
1090
- required: i.required || !1,
1091
- disabled: e.readOnly || e.mode === "view" || i.readonly,
1092
- placeholder: i.placeholder,
1093
- description: i.help || i.description,
1094
- validation: Y(i),
1095
- field: i,
1096
- options: i.options,
1097
- multiple: i.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
- T(o), j(!1);
1101
- }, [d, e.fields, e.customFields, e.sections, e.readOnly, e.mode, l]);
1102
- const F = k(async (n) => {
1103
- if (!l)
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
- let o;
1107
- return e.mode === "create" ? o = await l.create(e.objectName, n) : e.mode === "edit" && e.recordId && (o = await l.update(e.objectName, e.recordId, n)), e.onSuccess && await e.onSuccess(o), e.onOpenChange?.(!1), o;
1108
- } catch (o) {
1109
- throw e.onError && e.onError(o), o;
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, l]), _ = k(() => {
1194
+ }, [e, r]), a = A(() => {
1112
1195
  e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
1113
- }, [e]), u = {
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: e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical",
1116
- defaultValues: E,
1117
- submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
1118
- cancelLabel: e.cancelText,
1119
- showSubmit: e.showSubmit !== !1 && e.mode !== "view",
1120
- showCancel: e.showCancel !== !1,
1121
- onSubmit: F,
1122
- onCancel: _
1123
- }, s = () => y ? /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
1124
- /* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
1125
- /* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: y.message })
1126
- ] }) : C ? /* @__PURE__ */ t.jsxs("div", { className: "p-8 text-center", children: [
1127
- /* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
1128
- /* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
1129
- ] }) : e.sections?.length ? /* @__PURE__ */ t.jsx("div", { className: "space-y-6", children: e.sections.map((n, o) => /* @__PURE__ */ t.jsx(
1130
- G,
1131
- {
1132
- label: n.label,
1133
- description: n.description,
1134
- columns: n.columns || 1,
1135
- children: /* @__PURE__ */ t.jsx(
1136
- M,
1137
- {
1138
- schema: {
1139
- ...u,
1140
- fields: A(n),
1141
- showSubmit: o === e.sections.length - 1 && u.showSubmit,
1142
- showCancel: o === e.sections.length - 1 && u.showCancel
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(Re, { open: D, onOpenChange: e.onOpenChange, children: /* @__PURE__ */ t.jsxs(De, { className: V(P, "max-h-[90vh] overflow-y-auto", f, e.className), children: [
1159
- (e.title || e.description) && /* @__PURE__ */ t.jsxs(Fe, { children: [
1160
- e.title && /* @__PURE__ */ t.jsx(ke, { children: e.title }),
1161
- e.description && /* @__PURE__ */ t.jsx(Ie, { children: e.description })
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-2", children: s() })
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
- }, Ue = ({
1291
+ }, he = ({
1166
1292
  schema: e,
1167
- dataSource: l
1293
+ dataSource: r
1168
1294
  }) => {
1169
1295
  if (e.formType === "tabbed" && e.sections?.length)
1170
1296
  return /* @__PURE__ */ t.jsx(
1171
- qe,
1297
+ tt,
1172
1298
  {
1173
1299
  schema: {
1174
1300
  ...e,
1175
1301
  formType: "tabbed",
1176
- sections: e.sections.map((f) => ({
1177
- name: f.name,
1178
- label: f.label,
1179
- description: f.description,
1180
- columns: f.columns,
1181
- fields: f.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: l,
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
- We,
1318
+ rt,
1193
1319
  {
1194
1320
  schema: {
1195
1321
  ...e,
1196
1322
  formType: "wizard",
1197
- sections: e.sections.map((f) => ({
1198
- name: f.name,
1199
- label: f.label,
1200
- description: f.description,
1201
- columns: f.columns,
1202
- fields: f.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: l,
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
- $e,
1342
+ lt,
1217
1343
  {
1218
1344
  schema: {
1219
1345
  ...e,
1220
1346
  formType: "split",
1221
- sections: e.sections.map((f) => ({
1222
- name: f.name,
1223
- label: f.label,
1224
- description: f.description,
1225
- columns: f.columns,
1226
- fields: f.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: l,
1358
+ dataSource: r,
1233
1359
  className: e.className
1234
1360
  }
1235
1361
  );
1236
1362
  if (e.formType === "drawer") {
1237
- const { layout: f, ...d } = e, w = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
1363
+ const { layout: i, ...b } = e, o = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
1238
1364
  return /* @__PURE__ */ t.jsx(
1239
- Me,
1365
+ ct,
1240
1366
  {
1241
1367
  schema: {
1242
- ...d,
1243
- layout: w,
1368
+ ...b,
1369
+ layout: o,
1244
1370
  formType: "drawer",
1245
- sections: e.sections?.map((b) => ({
1246
- name: b.name,
1247
- label: b.label,
1248
- description: b.description,
1249
- columns: b.columns,
1250
- fields: b.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: l,
1383
+ dataSource: r,
1258
1384
  className: e.className
1259
1385
  }
1260
1386
  );
1261
1387
  }
1262
1388
  if (e.formType === "modal") {
1263
- const { layout: f, ...d } = e, w = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
1389
+ const { layout: i, ...b } = e, o = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
1264
1390
  return /* @__PURE__ */ t.jsx(
1265
- Ye,
1391
+ ut,
1266
1392
  {
1267
1393
  schema: {
1268
- ...d,
1269
- layout: w,
1394
+ ...b,
1395
+ layout: o,
1270
1396
  formType: "modal",
1271
- sections: e.sections?.map((b) => ({
1272
- name: b.name,
1273
- label: b.label,
1274
- description: b.description,
1275
- columns: b.columns,
1276
- fields: b.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: l,
1409
+ dataSource: r,
1284
1410
  className: e.className
1285
1411
  }
1286
1412
  );
1287
1413
  }
1288
- return /* @__PURE__ */ t.jsx(He, { schema: e, dataSource: l });
1289
- }, He = ({
1414
+ return /* @__PURE__ */ t.jsx(ft, { schema: e, dataSource: r });
1415
+ }, ft = ({
1290
1416
  schema: e,
1291
- dataSource: l
1417
+ dataSource: r
1292
1418
  }) => {
1293
- const [f, d] = g(null), [w, b] = g([]), [T, E] = g(null), [S, C] = g(!0), [j, y] = g(null), N = e.customFields && e.customFields.length > 0;
1294
- W(() => {
1295
- N && (E(e.initialData || e.initialValues || {}), C(!1));
1296
- }, [N, e.initialData, e.initialValues]), W(() => {
1297
- const u = async () => {
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 (!l)
1425
+ if (!r)
1300
1426
  throw new Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");
1301
- const s = await l.getObjectSchema(e.objectName);
1302
- if (!s)
1427
+ const a = await r.getObjectSchema(e.objectName);
1428
+ if (!a)
1303
1429
  throw new Error(`No schema found for object "${e.objectName}"`);
1304
- d(s);
1305
- } catch (s) {
1306
- y(s), C(!1);
1430
+ o(a);
1431
+ } catch (a) {
1432
+ j(a), F(!1);
1307
1433
  }
1308
1434
  };
1309
- N ? d({
1435
+ h ? o({
1310
1436
  name: e.objectName,
1311
1437
  fields: {}
1312
- }) : e.objectName && l ? u() : N || C(!1);
1313
- }, [e.objectName, l, N]), W(() => {
1314
- f && !N && (async () => {
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
- E(e.initialData || e.initialValues || {}), C(!1);
1442
+ I(e.initialData || e.initialValues || {}), F(!1);
1317
1443
  return;
1318
1444
  }
1319
- if (!N) {
1320
- if (!l) {
1321
- y(new Error("DataSource is required for fetching record data (inline data not provided)")), C(!1);
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
- C(!0);
1450
+ F(!0);
1325
1451
  try {
1326
- const s = await l.findOne(e.objectName, e.recordId);
1327
- E(s);
1328
- } catch (s) {
1329
- console.error("Failed to fetch record:", s), y(s);
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
- C(!1);
1457
+ F(!1);
1332
1458
  }
1333
1459
  }
1334
1460
  })();
1335
- }, [e.objectName, e.recordId, e.mode, e.initialValues, e.initialData, l, f, N]), W(() => {
1336
- if (N && e.customFields) {
1337
- b(e.customFields), C(!1);
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 (!f) return;
1341
- const u = [], s = e.fields || Object.keys(f.fields || {});
1342
- (Array.isArray(s) ? s : Object.keys(s)).forEach((a) => {
1343
- const c = typeof a == "string" ? a : a.name;
1344
- if (!c) return;
1345
- const i = f.fields?.[c];
1346
- if (!i && !N) return;
1347
- const v = !i?.permissions || i?.permissions.write !== !1;
1348
- if (e.mode !== "view" && !v) return;
1349
- const $ = e.customFields?.find((p) => p.name === c);
1350
- if ($)
1351
- u.push($);
1352
- else if (i) {
1353
- const p = {
1354
- name: c,
1355
- label: i.label || a,
1356
- type: U(i.type),
1357
- required: i.required || !1,
1358
- disabled: e.readOnly || e.mode === "view" || i.readonly,
1359
- placeholder: i.placeholder,
1360
- description: i.help || i.description,
1361
- validation: Y(i),
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: i
1489
+ field: d
1364
1490
  };
1365
- if ((i.type === "select" || i.type === "lookup" || i.type === "master_detail") && (p.options = i.options || [], p.multiple = i.multiple), (i.type === "number" || i.type === "currency" || i.type === "percent") && (p.inputType = "number", p.min = i.min, p.max = i.max, p.step = i.precision ? Math.pow(10, -i.precision) : void 0), i.type === "date" && (p.inputType = "date"), i.type === "datetime" && (p.inputType = "datetime-local"), (i.type === "text" || i.type === "textarea" || i.type === "markdown" || i.type === "html") && (p.maxLength = i.max_length, p.minLength = i.min_length), (i.type === "file" || i.type === "image") && (p.inputType = "file", p.multiple = i.multiple, p.accept = i.accept ? i.accept.join(",") : void 0, i.max_size)) {
1366
- const x = `Max size: ${ye(i.max_size)}`;
1367
- p.description = p.description ? `${p.description} (${x})` : x;
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
- i.type === "email" && (p.inputType = "email"), i.type === "phone" && (p.inputType = "tel"), i.type === "url" && (p.inputType = "url"), i.type === "password" && (p.inputType = "password"), i.type === "time" && (p.inputType = "time"), (i.type === "formula" || i.type === "summary" || i.type === "auto_number") && (p.disabled = !0), i.visible_on && (p.visible = (x) => xe(i.visible_on, x)), u.push(p);
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
- }), b(u), !N && e.recordId && e.mode !== "create" && l || C(!1);
1372
- }, [f, e.fields, e.customFields, e.readOnly, e.mode, N, e.recordId, l]);
1373
- const D = k(async (u, s) => {
1374
- if (u && (u.nativeEvent || u._reactName === "onSubmit") && (console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."), s === void 0 && (s = u, u = {})), N && !l)
1375
- return e.onSuccess && await e.onSuccess(u), u;
1376
- if (!l)
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 n;
1505
+ let s;
1380
1506
  if (e.mode === "create")
1381
- n = await l.create(e.objectName, u);
1507
+ s = await r.create(e.objectName, n);
1382
1508
  else if (e.mode === "edit" && e.recordId)
1383
- n = await l.update(e.objectName, e.recordId, u);
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(n), n;
1387
- } catch (n) {
1388
- throw console.error("Failed to submit form:", n), e.onError && e.onError(n), n;
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, l, N]), P = k(() => {
1516
+ }, [e, r, h]), D = A(() => {
1391
1517
  e.onCancel && e.onCancel();
1392
- }, [e]), F = {
1393
- ...J.useMemo(() => {
1394
- if (!f?.fields) return {};
1395
- const u = {};
1396
- return Object.keys(f.fields).forEach((s) => {
1397
- const n = f.fields[s];
1398
- n.defaultValue !== void 0 && (u[s] = n.defaultValue);
1399
- }), u;
1400
- }, [f]),
1401
- ...T
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 (j)
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: j.message })
1532
+ /* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: N.message })
1407
1533
  ] });
1408
- if (S)
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 _ = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical";
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((u, s) => {
1416
- const n = u.fields.map((a) => typeof a == "string" ? a : a.name), o = w.filter((a) => n.includes(a.name));
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
- G,
1544
+ te,
1419
1545
  {
1420
- label: u.label,
1421
- description: u.description,
1422
- collapsible: u.collapsible,
1423
- collapsed: u.collapsed,
1424
- columns: u.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
- M,
1552
+ J,
1427
1553
  {
1428
1554
  schema: {
1429
1555
  type: "form",
1430
- fields: o,
1431
- layout: _,
1432
- defaultValues: F,
1556
+ fields: c,
1557
+ layout: k,
1558
+ defaultValues: L,
1433
1559
  // Only show action buttons after the last section
1434
- showSubmit: s === e.sections.length - 1 && e.showSubmit !== !1 && e.mode !== "view",
1435
- showCancel: s === e.sections.length - 1 && e.showCancel !== !1,
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: D,
1439
- onCancel: P
1564
+ onSubmit: v,
1565
+ onCancel: D
1440
1566
  }
1441
1567
  }
1442
1568
  )
1443
1569
  },
1444
- u.name || u.label || s
1570
+ n.name || n.label || a
1445
1571
  );
1446
1572
  }) });
1447
- const q = {
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: w,
1450
- layout: _,
1451
- columns: e.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: F,
1458
- onSubmit: D,
1459
- onCancel: P,
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(M, { schema: q }) });
1463
- }, be = ({ schema: e }) => /* @__PURE__ */ t.jsx(Ue, { schema: e });
1464
- ue.register("object-form", be, {
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", be, {
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
- Me as DrawerForm,
1508
- G as FormSection,
1509
- Ye as ModalForm,
1510
- Ue as ObjectForm,
1511
- $e as SplitForm,
1512
- qe as TabbedForm,
1513
- We as WizardForm
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
  };