@object-ui/plugin-form 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+
2
+ > @object-ui/plugin-form@0.5.0 build /home/runner/work/objectui/objectui/packages/plugin-form
3
+ > vite build
4
+
5
+ vite v7.3.1 building client environment for production...
6
+ transforming...
7
+ ✓ 11 modules transformed.
8
+ rendering chunks...
9
+ 
10
+ [vite:dts] Start generate declaration files...
11
+ computing gzip size...
12
+ dist/index.js 15.72 kB │ gzip: 5.05 kB
13
+ [vite:dts] Declaration files built in 12353ms.
14
+ 
15
+ No name was provided for external module "@object-ui/core" in "output.globals" – guessing "core".
16
+ No name was provided for external module "@object-ui/react" in "output.globals" – guessing "react".
17
+ No name was provided for external module "@object-ui/fields" in "output.globals" – guessing "fields".
18
+ dist/index.umd.cjs 11.34 kB │ gzip: 4.55 kB
19
+ ✓ built in 13.58s
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # @object-ui/plugin-form
2
+
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Maintenance release - Documentation and build improvements
8
+ - Updated dependencies
9
+ - @object-ui/types@0.3.1
10
+ - @object-ui/core@0.3.1
11
+ - @object-ui/react@0.3.1
12
+ - @object-ui/components@0.3.1
13
+ - @object-ui/fields@0.3.1
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './plugin-form/src/index'
1
+ export * from './packages/plugin-form/src/index'
2
2
  export {}
package/dist/index.js CHANGED
@@ -1,69 +1,69 @@
1
- import ie, { useState as O, useEffect as F, useCallback as X } from "react";
2
- import { ComponentRegistry as Z } from "@object-ui/core";
3
- import { SchemaRenderer as ae } from "@object-ui/react";
4
- import { buildValidationRules as le, mapFieldTypeToFormType as se, formatFileSize as ue, evaluateCondition as ce } from "@object-ui/fields";
5
- var C = { exports: {} }, k = {};
6
- var H;
7
- function fe() {
8
- if (H) return k;
9
- H = 1;
10
- var r = /* @__PURE__ */ Symbol.for("react.transitional.element"), u = /* @__PURE__ */ Symbol.for("react.fragment");
11
- function m(E, d, p) {
12
- var v = null;
13
- if (p !== void 0 && (v = "" + p), d.key !== void 0 && (v = "" + d.key), "key" in d) {
14
- p = {};
15
- for (var b in d)
16
- b !== "key" && (p[b] = d[b]);
17
- } else p = d;
18
- return d = p.ref, {
1
+ import re, { useState as A, useEffect as I, useCallback as Q } from "react";
2
+ import { ComponentRegistry as oe } from "@object-ui/core";
3
+ import { SchemaRenderer as ie } from "@object-ui/react";
4
+ import { buildValidationRules as ae, mapFieldTypeToFormType as le, formatFileSize as se, evaluateCondition as ue } from "@object-ui/fields";
5
+ var D = { exports: {} }, P = {};
6
+ var Z;
7
+ function ce() {
8
+ if (Z) return P;
9
+ Z = 1;
10
+ var r = /* @__PURE__ */ Symbol.for("react.transitional.element"), c = /* @__PURE__ */ Symbol.for("react.fragment");
11
+ function f(_, m, b) {
12
+ var T = null;
13
+ if (b !== void 0 && (T = "" + b), m.key !== void 0 && (T = "" + m.key), "key" in m) {
14
+ b = {};
15
+ for (var y in m)
16
+ y !== "key" && (b[y] = m[y]);
17
+ } else b = m;
18
+ return m = b.ref, {
19
19
  $$typeof: r,
20
- type: E,
21
- key: v,
22
- ref: d !== void 0 ? d : null,
23
- props: p
20
+ type: _,
21
+ key: T,
22
+ ref: m !== void 0 ? m : null,
23
+ props: b
24
24
  };
25
25
  }
26
- return k.Fragment = u, k.jsx = m, k.jsxs = m, k;
26
+ return P.Fragment = c, P.jsx = f, P.jsxs = f, P;
27
27
  }
28
- var S = {};
29
- var B;
30
- function de() {
31
- return B || (B = 1, process.env.NODE_ENV !== "production" && (function() {
28
+ var F = {};
29
+ var K;
30
+ function fe() {
31
+ return K || (K = 1, process.env.NODE_ENV !== "production" && (function() {
32
32
  function r(e) {
33
33
  if (e == null) return null;
34
34
  if (typeof e == "function")
35
- return e.$$typeof === te ? null : e.displayName || e.name || null;
35
+ return e.$$typeof === O ? null : e.displayName || e.name || null;
36
36
  if (typeof e == "string") return e;
37
37
  switch (e) {
38
- case c:
38
+ case N:
39
39
  return "Fragment";
40
- case w:
41
- return "Profiler";
42
40
  case a:
41
+ return "Profiler";
42
+ case $:
43
43
  return "StrictMode";
44
- case o:
44
+ case x:
45
45
  return "Suspense";
46
- case j:
46
+ case t:
47
47
  return "SuspenseList";
48
- case re:
48
+ case o:
49
49
  return "Activity";
50
50
  }
51
51
  if (typeof e == "object")
52
52
  switch (typeof e.tag == "number" && console.error(
53
53
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
54
54
  ), e.$$typeof) {
55
- case I:
55
+ case W:
56
56
  return "Portal";
57
- case D:
57
+ case p:
58
58
  return e.displayName || "Context";
59
- case t:
59
+ case l:
60
60
  return (e._context.displayName || "Context") + ".Consumer";
61
- case A:
61
+ case j:
62
62
  var n = e.render;
63
63
  return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
64
- case ee:
64
+ case V:
65
65
  return n = e.displayName || null, n !== null ? n : r(e.type) || "Memo";
66
- case Y:
66
+ case g:
67
67
  n = e._payload, e = e._init;
68
68
  try {
69
69
  return r(e(n));
@@ -72,29 +72,29 @@ function de() {
72
72
  }
73
73
  return null;
74
74
  }
75
- function u(e) {
75
+ function c(e) {
76
76
  return "" + e;
77
77
  }
78
- function m(e) {
78
+ function f(e) {
79
79
  try {
80
- u(e);
80
+ c(e);
81
81
  var n = !1;
82
82
  } catch {
83
83
  n = !0;
84
84
  }
85
85
  if (n) {
86
86
  n = console;
87
- var i = n.error, l = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
87
+ var i = n.error, s = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
88
88
  return i.call(
89
89
  n,
90
90
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
91
- l
92
- ), u(e);
91
+ s
92
+ ), c(e);
93
93
  }
94
94
  }
95
- function E(e) {
96
- if (e === c) return "<>";
97
- if (typeof e == "object" && e !== null && e.$$typeof === Y)
95
+ function _(e) {
96
+ if (e === N) return "<>";
97
+ if (typeof e == "object" && e !== null && e.$$typeof === g)
98
98
  return "<...>";
99
99
  try {
100
100
  var n = r(e);
@@ -103,23 +103,23 @@ function de() {
103
103
  return "<...>";
104
104
  }
105
105
  }
106
- function d() {
107
- var e = $.A;
106
+ function m() {
107
+ var e = L.A;
108
108
  return e === null ? null : e.getOwner();
109
109
  }
110
- function p() {
110
+ function b() {
111
111
  return Error("react-stack-top-frame");
112
112
  }
113
- function v(e) {
114
- if (z.call(e, "key")) {
113
+ function T(e) {
114
+ if (U.call(e, "key")) {
115
115
  var n = Object.getOwnPropertyDescriptor(e, "key").get;
116
116
  if (n && n.isReactWarning) return !1;
117
117
  }
118
118
  return e.key !== void 0;
119
119
  }
120
- function b(e, n) {
120
+ function y(e, n) {
121
121
  function i() {
122
- M || (M = !0, console.error(
122
+ J || (J = !0, console.error(
123
123
  "%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)",
124
124
  n
125
125
  ));
@@ -129,23 +129,23 @@ function de() {
129
129
  configurable: !0
130
130
  });
131
131
  }
132
- function h() {
132
+ function Y() {
133
133
  var e = r(this.type);
134
- return W[e] || (W[e] = !0, console.error(
134
+ return G[e] || (G[e] = !0, console.error(
135
135
  "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."
136
136
  )), e = this.props.ref, e !== void 0 ? e : null;
137
137
  }
138
- function _(e, n, i, l, P, V) {
139
- var s = i.ref;
138
+ function v(e, n, i, s, C, q) {
139
+ var u = i.ref;
140
140
  return e = {
141
- $$typeof: N,
141
+ $$typeof: h,
142
142
  type: e,
143
143
  key: n,
144
144
  props: i,
145
- _owner: l
146
- }, (s !== void 0 ? s : null) !== null ? Object.defineProperty(e, "ref", {
145
+ _owner: s
146
+ }, (u !== void 0 ? u : null) !== null ? Object.defineProperty(e, "ref", {
147
147
  enumerable: !1,
148
- get: h
148
+ get: Y
149
149
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
150
150
  configurable: !1,
151
151
  enumerable: !1,
@@ -160,219 +160,233 @@ function de() {
160
160
  configurable: !1,
161
161
  enumerable: !1,
162
162
  writable: !0,
163
- value: P
163
+ value: C
164
164
  }), Object.defineProperty(e, "_debugTask", {
165
165
  configurable: !1,
166
166
  enumerable: !1,
167
167
  writable: !0,
168
- value: V
168
+ value: q
169
169
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
170
170
  }
171
- function g(e, n, i, l, P, V) {
172
- var s = n.children;
173
- if (s !== void 0)
174
- if (l)
175
- if (ne(s)) {
176
- for (l = 0; l < s.length; l++)
177
- R(s[l]);
178
- Object.freeze && Object.freeze(s);
171
+ function S(e, n, i, s, C, q) {
172
+ var u = n.children;
173
+ if (u !== void 0)
174
+ if (s)
175
+ if (te(u)) {
176
+ for (s = 0; s < u.length; s++)
177
+ R(u[s]);
178
+ Object.freeze && Object.freeze(u);
179
179
  } else
180
180
  console.error(
181
181
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
182
182
  );
183
- else R(s);
184
- if (z.call(n, "key")) {
185
- s = r(e);
186
- var x = Object.keys(n).filter(function(oe) {
187
- return oe !== "key";
183
+ else R(u);
184
+ if (U.call(n, "key")) {
185
+ u = r(e);
186
+ var k = Object.keys(n).filter(function(ne) {
187
+ return ne !== "key";
188
188
  });
189
- l = 0 < x.length ? "{key: someKey, " + x.join(": ..., ") + ": ...}" : "{key: someKey}", G[s + l] || (x = 0 < x.length ? "{" + x.join(": ..., ") + ": ...}" : "{}", console.error(
189
+ s = 0 < k.length ? "{key: someKey, " + k.join(": ..., ") + ": ...}" : "{key: someKey}", B[u + s] || (k = 0 < k.length ? "{" + k.join(": ..., ") + ": ...}" : "{}", console.error(
190
190
  `A props object containing a "key" prop is being spread into JSX:
191
191
  let props = %s;
192
192
  <%s {...props} />
193
193
  React keys must be passed directly to JSX without using spread:
194
194
  let props = %s;
195
195
  <%s key={someKey} {...props} />`,
196
- l,
197
196
  s,
198
- x,
199
- s
200
- ), G[s + l] = !0);
197
+ u,
198
+ k,
199
+ u
200
+ ), B[u + s] = !0);
201
201
  }
202
- if (s = null, i !== void 0 && (m(i), s = "" + i), v(n) && (m(n.key), s = "" + n.key), "key" in n) {
202
+ if (u = null, i !== void 0 && (f(i), u = "" + i), T(n) && (f(n.key), u = "" + n.key), "key" in n) {
203
203
  i = {};
204
- for (var q in n)
205
- q !== "key" && (i[q] = n[q]);
204
+ for (var z in n)
205
+ z !== "key" && (i[z] = n[z]);
206
206
  } else i = n;
207
- return s && b(
207
+ return u && y(
208
208
  i,
209
209
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
210
- ), _(
210
+ ), v(
211
211
  e,
212
- s,
212
+ u,
213
213
  i,
214
- d(),
215
- P,
216
- V
214
+ m(),
215
+ C,
216
+ q
217
217
  );
218
218
  }
219
219
  function R(e) {
220
- f(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === Y && (e._payload.status === "fulfilled" ? f(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
220
+ d(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === g && (e._payload.status === "fulfilled" ? d(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
221
221
  }
222
- function f(e) {
223
- return typeof e == "object" && e !== null && e.$$typeof === N;
222
+ function d(e) {
223
+ return typeof e == "object" && e !== null && e.$$typeof === h;
224
224
  }
225
- var T = ie, N = /* @__PURE__ */ Symbol.for("react.transitional.element"), I = /* @__PURE__ */ Symbol.for("react.portal"), c = /* @__PURE__ */ Symbol.for("react.fragment"), a = /* @__PURE__ */ Symbol.for("react.strict_mode"), w = /* @__PURE__ */ Symbol.for("react.profiler"), t = /* @__PURE__ */ Symbol.for("react.consumer"), D = /* @__PURE__ */ Symbol.for("react.context"), A = /* @__PURE__ */ Symbol.for("react.forward_ref"), o = /* @__PURE__ */ Symbol.for("react.suspense"), j = /* @__PURE__ */ Symbol.for("react.suspense_list"), ee = /* @__PURE__ */ Symbol.for("react.memo"), Y = /* @__PURE__ */ Symbol.for("react.lazy"), re = /* @__PURE__ */ Symbol.for("react.activity"), te = /* @__PURE__ */ Symbol.for("react.client.reference"), $ = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, z = Object.prototype.hasOwnProperty, ne = Array.isArray, L = console.createTask ? console.createTask : function() {
225
+ var w = re, h = /* @__PURE__ */ Symbol.for("react.transitional.element"), W = /* @__PURE__ */ Symbol.for("react.portal"), N = /* @__PURE__ */ Symbol.for("react.fragment"), $ = /* @__PURE__ */ Symbol.for("react.strict_mode"), a = /* @__PURE__ */ Symbol.for("react.profiler"), l = /* @__PURE__ */ Symbol.for("react.consumer"), p = /* @__PURE__ */ Symbol.for("react.context"), j = /* @__PURE__ */ Symbol.for("react.forward_ref"), x = /* @__PURE__ */ Symbol.for("react.suspense"), t = /* @__PURE__ */ Symbol.for("react.suspense_list"), V = /* @__PURE__ */ Symbol.for("react.memo"), g = /* @__PURE__ */ Symbol.for("react.lazy"), o = /* @__PURE__ */ Symbol.for("react.activity"), O = /* @__PURE__ */ Symbol.for("react.client.reference"), L = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, te = Array.isArray, M = console.createTask ? console.createTask : function() {
226
226
  return null;
227
227
  };
228
- T = {
228
+ w = {
229
229
  react_stack_bottom_frame: function(e) {
230
230
  return e();
231
231
  }
232
232
  };
233
- var M, W = {}, U = T.react_stack_bottom_frame.bind(
234
- T,
235
- p
236
- )(), J = L(E(p)), G = {};
237
- S.Fragment = c, S.jsx = function(e, n, i) {
238
- var l = 1e4 > $.recentlyCreatedOwnerStacks++;
239
- return g(
233
+ var J, G = {}, X = w.react_stack_bottom_frame.bind(
234
+ w,
235
+ b
236
+ )(), H = M(_(b)), B = {};
237
+ F.Fragment = N, F.jsx = function(e, n, i) {
238
+ var s = 1e4 > L.recentlyCreatedOwnerStacks++;
239
+ return S(
240
240
  e,
241
241
  n,
242
242
  i,
243
243
  !1,
244
- l ? Error("react-stack-top-frame") : U,
245
- l ? L(E(e)) : J
244
+ s ? Error("react-stack-top-frame") : X,
245
+ s ? M(_(e)) : H
246
246
  );
247
- }, S.jsxs = function(e, n, i) {
248
- var l = 1e4 > $.recentlyCreatedOwnerStacks++;
249
- return g(
247
+ }, F.jsxs = function(e, n, i) {
248
+ var s = 1e4 > L.recentlyCreatedOwnerStacks++;
249
+ return S(
250
250
  e,
251
251
  n,
252
252
  i,
253
253
  !0,
254
- l ? Error("react-stack-top-frame") : U,
255
- l ? L(E(e)) : J
254
+ s ? Error("react-stack-top-frame") : X,
255
+ s ? M(_(e)) : H
256
256
  );
257
257
  };
258
- })()), S;
258
+ })()), F;
259
259
  }
260
- var Q;
261
- function pe() {
262
- return Q || (Q = 1, process.env.NODE_ENV === "production" ? C.exports = fe() : C.exports = de()), C.exports;
260
+ var ee;
261
+ function de() {
262
+ return ee || (ee = 1, process.env.NODE_ENV === "production" ? D.exports = ce() : D.exports = fe()), D.exports;
263
263
  }
264
- var y = pe();
265
- const me = ({
264
+ var E = de();
265
+ const pe = ({
266
266
  schema: r,
267
- dataSource: u
267
+ dataSource: c
268
268
  }) => {
269
- const [m, E] = O(null), [d, p] = O([]), [v, b] = O(null), [h, _] = O(!0), [g, R] = O(null), f = r.customFields && r.customFields.length > 0;
270
- F(() => {
271
- f && (b(r.initialData || r.initialValues || {}), _(!1));
272
- }, [f, r.initialData, r.initialValues]), F(() => {
273
- const c = async () => {
269
+ const [f, _] = A(null), [m, b] = A([]), [T, y] = A(null), [Y, v] = A(!0), [S, R] = A(null), d = r.customFields && r.customFields.length > 0;
270
+ I(() => {
271
+ d && (y(r.initialData || r.initialValues || {}), v(!1));
272
+ }, [d, r.initialData, r.initialValues]), I(() => {
273
+ const a = async () => {
274
274
  try {
275
- if (!u)
275
+ if (!c)
276
276
  throw new Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");
277
- const a = await u.getObjectSchema(r.objectName);
278
- E(a);
279
- } catch (a) {
280
- console.error("Failed to fetch object schema:", a), R(a);
277
+ const l = await c.getObjectSchema(r.objectName);
278
+ _(l);
279
+ } catch (l) {
280
+ console.error("Failed to fetch object schema:", l), R(l);
281
281
  }
282
282
  };
283
- f ? E({
283
+ d ? _({
284
284
  name: r.objectName,
285
285
  fields: {}
286
- }) : r.objectName && u && c();
287
- }, [r.objectName, u, f]), F(() => {
288
- m && !f && (async () => {
286
+ }) : r.objectName && c && a();
287
+ }, [r.objectName, c, d]), I(() => {
288
+ f && !d && (async () => {
289
289
  if (!r.recordId || r.mode === "create") {
290
- b(r.initialData || r.initialValues || {});
290
+ y(r.initialData || r.initialValues || {}), v(!1);
291
291
  return;
292
292
  }
293
- if (!f) {
294
- if (!u) {
295
- R(new Error("DataSource is required for fetching record data (inline data not provided)")), _(!1);
293
+ if (!d) {
294
+ if (!c) {
295
+ R(new Error("DataSource is required for fetching record data (inline data not provided)")), v(!1);
296
296
  return;
297
297
  }
298
- _(!0);
298
+ v(!0);
299
299
  try {
300
- const a = await u.findOne(r.objectName, r.recordId);
301
- b(a);
302
- } catch (a) {
303
- console.error("Failed to fetch record:", a), R(a);
300
+ const l = await c.findOne(r.objectName, r.recordId);
301
+ y(l);
302
+ } catch (l) {
303
+ console.error("Failed to fetch record:", l), R(l);
304
304
  } finally {
305
- _(!1);
305
+ v(!1);
306
306
  }
307
307
  }
308
308
  })();
309
- }, [r.objectName, r.recordId, r.mode, r.initialValues, r.initialData, u, m, f]), F(() => {
310
- if (f && r.customFields) {
311
- p(r.customFields), _(!1);
309
+ }, [r.objectName, r.recordId, r.mode, r.initialValues, r.initialData, c, f, d]), I(() => {
310
+ if (d && r.customFields) {
311
+ b(r.customFields), v(!1);
312
312
  return;
313
313
  }
314
- if (!m) return;
315
- const c = [];
316
- (r.fields || Object.keys(m.fields || {})).forEach((w) => {
317
- const t = m.fields?.[w];
318
- if (!t) return;
319
- const D = !t.permissions || t.permissions.write !== !1;
320
- if (r.mode !== "view" && !D) return;
321
- const A = r.customFields?.find((o) => o.name === w);
322
- if (A)
323
- c.push(A);
324
- else {
314
+ if (!f) return;
315
+ const a = [], l = r.fields || Object.keys(f.fields || {});
316
+ (Array.isArray(l) ? l : Object.keys(l)).forEach((j) => {
317
+ const x = typeof j == "string" ? j : j.name;
318
+ if (!x) return;
319
+ const t = f.fields?.[x];
320
+ if (!t && !d) return;
321
+ const V = !t?.permissions || t?.permissions.write !== !1;
322
+ if (r.mode !== "view" && !V) return;
323
+ const g = r.customFields?.find((o) => o.name === x);
324
+ if (g)
325
+ a.push(g);
326
+ else if (t) {
325
327
  const o = {
326
- name: w,
327
- label: t.label || w,
328
- type: se(t.type),
328
+ name: x,
329
+ label: t.label || j,
330
+ type: le(t.type),
329
331
  required: t.required || !1,
330
332
  disabled: r.readOnly || r.mode === "view" || t.readonly,
331
333
  placeholder: t.placeholder,
332
334
  description: t.help || t.description,
333
- validation: le(t)
335
+ validation: ae(t),
336
+ // Important: Pass the original field metadata so widgets can access properties like precision, currency, etc.
337
+ field: t
334
338
  };
335
- if ((t.type === "select" || t.type === "lookup" || t.type === "master_detail") && (o.options = t.options || [], o.multiple = t.multiple), (t.type === "number" || t.type === "currency" || t.type === "percent") && (o.min = t.min, o.max = t.max, o.step = t.precision ? Math.pow(10, -t.precision) : void 0), (t.type === "text" || t.type === "textarea" || t.type === "markdown" || t.type === "html") && (o.maxLength = t.max_length, o.minLength = t.min_length), (t.type === "file" || t.type === "image") && (o.multiple = t.multiple, o.accept = t.accept ? t.accept.join(",") : void 0, t.max_size)) {
336
- const j = `Max size: ${ue(t.max_size)}`;
337
- o.description = o.description ? `${o.description} (${j})` : j;
339
+ if ((t.type === "select" || t.type === "lookup" || t.type === "master_detail") && (o.options = t.options || [], o.multiple = t.multiple), (t.type === "number" || t.type === "currency" || t.type === "percent") && (o.inputType = "number", o.min = t.min, o.max = t.max, o.step = t.precision ? Math.pow(10, -t.precision) : void 0), t.type === "date" && (o.inputType = "date"), t.type === "datetime" && (o.inputType = "datetime-local"), (t.type === "text" || t.type === "textarea" || t.type === "markdown" || t.type === "html") && (o.maxLength = t.max_length, o.minLength = t.min_length), (t.type === "file" || t.type === "image") && (o.inputType = "file", o.multiple = t.multiple, o.accept = t.accept ? t.accept.join(",") : void 0, t.max_size)) {
340
+ const O = `Max size: ${se(t.max_size)}`;
341
+ o.description = o.description ? `${o.description} (${O})` : O;
338
342
  }
339
- t.type === "email" && (o.inputType = "email"), t.type === "phone" && (o.inputType = "tel"), t.type === "url" && (o.inputType = "url"), t.type === "password" && (o.inputType = "password"), t.type === "time" && (o.inputType = "time"), (t.type === "formula" || t.type === "summary" || t.type === "auto_number") && (o.disabled = !0), t.visible_on && (o.visible = (j) => ce(t.visible_on, j)), c.push(o);
343
+ t.type === "email" && (o.inputType = "email"), t.type === "phone" && (o.inputType = "tel"), t.type === "url" && (o.inputType = "url"), t.type === "password" && (o.inputType = "password"), t.type === "time" && (o.inputType = "time"), (t.type === "formula" || t.type === "summary" || t.type === "auto_number") && (o.disabled = !0), t.visible_on && (o.visible = (O) => ue(t.visible_on, O)), a.push(o);
340
344
  }
341
- }), p(c), _(!1);
342
- }, [m, r.fields, r.customFields, r.readOnly, r.mode, f]);
343
- const T = X(async (c) => {
344
- if (f && !u)
345
- return r.onSuccess && await r.onSuccess(c), c;
346
- if (!u)
345
+ }), b(a), v(!1);
346
+ }, [f, r.fields, r.customFields, r.readOnly, r.mode, d]);
347
+ const w = Q(async (a, l) => {
348
+ if (a && (a.nativeEvent || a._reactName === "onSubmit") && (console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."), l === void 0 && (l = a, a = {})), d && !c)
349
+ return r.onSuccess && await r.onSuccess(a), a;
350
+ if (!c)
347
351
  throw new Error("DataSource is required for form submission (inline mode not configured)");
348
352
  try {
349
- let a;
353
+ let p;
350
354
  if (r.mode === "create")
351
- a = await u.create(r.objectName, c);
355
+ p = await c.create(r.objectName, a);
352
356
  else if (r.mode === "edit" && r.recordId)
353
- a = await u.update(r.objectName, r.recordId, c);
357
+ p = await c.update(r.objectName, r.recordId, a);
354
358
  else
355
359
  throw new Error("Invalid form mode or missing record ID");
356
- return r.onSuccess && await r.onSuccess(a), a;
357
- } catch (a) {
358
- throw console.error("Failed to submit form:", a), r.onError && r.onError(a), a;
360
+ return r.onSuccess && await r.onSuccess(p), p;
361
+ } catch (p) {
362
+ throw console.error("Failed to submit form:", p), r.onError && r.onError(p), p;
359
363
  }
360
- }, [r, u, f]), N = X(() => {
364
+ }, [r, c, d]), h = Q(() => {
361
365
  r.onCancel && r.onCancel();
362
- }, [r]);
363
- if (g)
364
- return /* @__PURE__ */ y.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
365
- /* @__PURE__ */ y.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
366
- /* @__PURE__ */ y.jsx("p", { className: "text-red-600 text-sm mt-1", children: g.message })
366
+ }, [r]), N = {
367
+ ...re.useMemo(() => {
368
+ if (!f?.fields) return {};
369
+ const a = {};
370
+ return Object.keys(f.fields).forEach((l) => {
371
+ const p = f.fields[l];
372
+ p.defaultValue !== void 0 && (a[l] = p.defaultValue);
373
+ }), a;
374
+ }, [f]),
375
+ ...T
376
+ };
377
+ if (S)
378
+ return /* @__PURE__ */ E.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
379
+ /* @__PURE__ */ E.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
380
+ /* @__PURE__ */ E.jsx("p", { className: "text-red-600 text-sm mt-1", children: S.message })
367
381
  ] });
368
- if (h)
369
- return /* @__PURE__ */ y.jsxs("div", { className: "p-8 text-center", children: [
370
- /* @__PURE__ */ y.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
371
- /* @__PURE__ */ y.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
382
+ if (Y)
383
+ return /* @__PURE__ */ E.jsxs("div", { className: "p-8 text-center", children: [
384
+ /* @__PURE__ */ E.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
385
+ /* @__PURE__ */ E.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
372
386
  ] });
373
- const I = {
387
+ const $ = {
374
388
  type: "form",
375
- fields: d,
389
+ fields: m,
376
390
  layout: r.layout === "vertical" || r.layout === "horizontal" ? r.layout : "vertical",
377
391
  columns: r.columns,
378
392
  submitLabel: r.submitText || (r.mode === "create" ? "Create" : "Update"),
@@ -380,15 +394,16 @@ const me = ({
380
394
  showSubmit: r.showSubmit !== !1 && r.mode !== "view",
381
395
  showCancel: r.showCancel !== !1,
382
396
  resetOnSubmit: r.showReset,
383
- defaultValues: v,
384
- onSubmit: T,
385
- onCancel: N,
397
+ defaultValues: N,
398
+ onSubmit: w,
399
+ onCancel: h,
386
400
  className: r.className
387
401
  };
388
- return /* @__PURE__ */ y.jsx("div", { className: "w-full", children: /* @__PURE__ */ y.jsx(ae, { schema: I }) });
389
- }, K = ({ schema: r }) => /* @__PURE__ */ y.jsx(me, { schema: r });
390
- Z.register("object-form", K);
391
- Z.register("form", K);
402
+ return /* @__PURE__ */ E.jsx("div", { className: "w-full", children: /* @__PURE__ */ E.jsx(ie, { schema: $ }) });
403
+ }, me = ({ schema: r }) => /* @__PURE__ */ E.jsx(pe, { schema: r });
404
+ oe.register("object-form", me, {
405
+ namespace: "plugin-form"
406
+ });
392
407
  export {
393
- me as ObjectForm
408
+ pe as ObjectForm
394
409
  };
@@ -1,6 +1,6 @@
1
- (function(y,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("@object-ui/fields")):typeof define=="function"&&define.amd?define(["exports","react","@object-ui/core","@object-ui/react","@object-ui/fields"],c):(y=typeof globalThis<"u"?globalThis:y||self,c(y.ObjectUIPluginForm={},y.React,y.core,y.react,y.fields))})(this,(function(y,c,W,re,P){"use strict";var A={exports:{}},S={};var J;function te(){if(J)return S;J=1;var r=Symbol.for("react.transitional.element"),u=Symbol.for("react.fragment");function b(v,p,m){var T=null;if(m!==void 0&&(T=""+m),p.key!==void 0&&(T=""+p.key),"key"in p){m={};for(var _ in p)_!=="key"&&(m[_]=p[_])}else m=p;return p=m.ref,{$$typeof:r,type:v,key:T,ref:p!==void 0?p:null,props:m}}return S.Fragment=u,S.jsx=b,S.jsxs=b,S}var k={};var G;function ne(){return G||(G=1,process.env.NODE_ENV!=="production"&&(function(){function r(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===le?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case f:return"Fragment";case x:return"Profiler";case a:return"StrictMode";case o:return"Suspense";case g:return"SuspenseList";case ae:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case D:return"Portal";case Y:return e.displayName||"Context";case t:return(e._context.displayName||"Context")+".Consumer";case h:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ie:return n=e.displayName||null,n!==null?n:r(e.type)||"Memo";case L:n=e._payload,e=e._init;try{return r(e(n))}catch{}}return null}function u(e){return""+e}function b(e){try{u(e);var n=!1}catch{n=!0}if(n){n=console;var i=n.error,l=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",l),u(e)}}function v(e){if(e===f)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===L)return"<...>";try{var n=r(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function p(){var e=M.A;return e===null?null:e.getOwner()}function m(){return Error("react-stack-top-frame")}function T(e){if(B.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function _(e,n){function i(){Q||(Q=!0,console.error("%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)",n))}i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}function I(){var e=r(this.type);return Z[e]||(Z[e]=!0,console.error("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.")),e=this.props.ref,e!==void 0?e:null}function R(e,n,i,l,C,z){var s=i.ref;return e={$$typeof:F,type:e,key:n,props:i,_owner:l},(s!==void 0?s:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:I}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:C}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:z}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function N(e,n,i,l,C,z){var s=n.children;if(s!==void 0)if(l)if(se(s)){for(l=0;l<s.length;l++)j(s[l]);Object.freeze&&Object.freeze(s)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else j(s);if(B.call(n,"key")){s=r(e);var O=Object.keys(n).filter(function(ue){return ue!=="key"});l=0<O.length?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}",ee[s+l]||(O=0<O.length?"{"+O.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(E,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("@object-ui/fields")):typeof define=="function"&&define.amd?define(["exports","react","@object-ui/core","@object-ui/react","@object-ui/fields"],c):(E=typeof globalThis<"u"?globalThis:E||self,c(E.ObjectUIPluginForm={},E.React,E.core,E.react,E.fields))})(this,(function(E,c,re,ne,C){"use strict";var I={exports:{}},A={};var G;function oe(){if(G)return A;G=1;var t=Symbol.for("react.transitional.element"),f=Symbol.for("react.fragment");function d(j,b,y){var R=null;if(y!==void 0&&(R=""+y),b.key!==void 0&&(R=""+b.key),"key"in b){y={};for(var _ in b)_!=="key"&&(y[_]=b[_])}else y=b;return b=y.ref,{$$typeof:t,type:j,key:R,ref:b!==void 0?b:null,props:y}}return A.Fragment=f,A.jsx=d,A.jsxs=d,A}var P={};var X;function ie(){return X||(X=1,process.env.NODE_ENV!=="production"&&(function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===k?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case a:return"Profiler";case L:return"StrictMode";case O:return"Suspense";case r:return"SuspenseList";case o:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case B:return"Portal";case m:return e.displayName||"Context";case l:return(e._context.displayName||"Context")+".Consumer";case g:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case M:return n=e.displayName||null,n!==null?n:t(e.type)||"Memo";case S:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function f(e){return""+e}function d(e){try{f(e);var n=!1}catch{n=!0}if(n){n=console;var i=n.error,s=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",s),f(e)}}function j(e){if(e===F)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===S)return"<...>";try{var n=t(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function b(){var e=z.A;return e===null?null:e.getOwner()}function y(){return Error("react-stack-top-frame")}function R(e){if(Q.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function _(e,n){function i(){Z||(Z=!0,console.error("%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)",n))}i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}function V(){var e=t(this.type);return K[e]||(K[e]=!0,console.error("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.")),e=this.props.ref,e!==void 0?e:null}function T(e,n,i,s,Y,W){var u=i.ref;return e={$$typeof:D,type:e,key:n,props:i,_owner:s},(u!==void 0?u:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:V}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:W}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function h(e,n,i,s,Y,W){var u=n.children;if(u!==void 0)if(s)if(se(u)){for(s=0;s<u.length;s++)w(u[s]);Object.freeze&&Object.freeze(u)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else w(u);if(Q.call(n,"key")){u=t(e);var N=Object.keys(n).filter(function(ue){return ue!=="key"});s=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",te[u+s]||(N=0<N.length?"{"+N.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,l,s,O,s),ee[s+l]=!0)}if(s=null,i!==void 0&&(b(i),s=""+i),T(n)&&(b(n.key),s=""+n.key),"key"in n){i={};for(var U in n)U!=="key"&&(i[U]=n[U])}else i=n;return s&&_(i,typeof e=="function"?e.displayName||e.name||"Unknown":e),R(e,s,i,p(),C,z)}function j(e){d(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===L&&(e._payload.status==="fulfilled"?d(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function d(e){return typeof e=="object"&&e!==null&&e.$$typeof===F}var w=c,F=Symbol.for("react.transitional.element"),D=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),t=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),o=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),ie=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),le=Symbol.for("react.client.reference"),M=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=Object.prototype.hasOwnProperty,se=Array.isArray,V=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(e){return e()}};var Q,Z={},K=w.react_stack_bottom_frame.bind(w,m)(),$=V(v(m)),ee={};k.Fragment=f,k.jsx=function(e,n,i){var l=1e4>M.recentlyCreatedOwnerStacks++;return N(e,n,i,!1,l?Error("react-stack-top-frame"):K,l?V(v(e)):$)},k.jsxs=function(e,n,i){var l=1e4>M.recentlyCreatedOwnerStacks++;return N(e,n,i,!0,l?Error("react-stack-top-frame"):K,l?V(v(e)):$)}})()),k}var q;function oe(){return q||(q=1,process.env.NODE_ENV==="production"?A.exports=te():A.exports=ne()),A.exports}var E=oe();const X=({schema:r,dataSource:u})=>{const[b,v]=c.useState(null),[p,m]=c.useState([]),[T,_]=c.useState(null),[I,R]=c.useState(!0),[N,j]=c.useState(null),d=r.customFields&&r.customFields.length>0;c.useEffect(()=>{d&&(_(r.initialData||r.initialValues||{}),R(!1))},[d,r.initialData,r.initialValues]),c.useEffect(()=>{const f=async()=>{try{if(!u)throw new Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");const a=await u.getObjectSchema(r.objectName);v(a)}catch(a){console.error("Failed to fetch object schema:",a),j(a)}};d?v({name:r.objectName,fields:{}}):r.objectName&&u&&f()},[r.objectName,u,d]),c.useEffect(()=>{b&&!d&&(async()=>{if(!r.recordId||r.mode==="create"){_(r.initialData||r.initialValues||{});return}if(!d){if(!u){j(new Error("DataSource is required for fetching record data (inline data not provided)")),R(!1);return}R(!0);try{const a=await u.findOne(r.objectName,r.recordId);_(a)}catch(a){console.error("Failed to fetch record:",a),j(a)}finally{R(!1)}}})()},[r.objectName,r.recordId,r.mode,r.initialValues,r.initialData,u,b,d]),c.useEffect(()=>{if(d&&r.customFields){m(r.customFields),R(!1);return}if(!b)return;const f=[];(r.fields||Object.keys(b.fields||{})).forEach(x=>{const t=b.fields?.[x];if(!t)return;const Y=!t.permissions||t.permissions.write!==!1;if(r.mode!=="view"&&!Y)return;const h=r.customFields?.find(o=>o.name===x);if(h)f.push(h);else{const o={name:x,label:t.label||x,type:P.mapFieldTypeToFormType(t.type),required:t.required||!1,disabled:r.readOnly||r.mode==="view"||t.readonly,placeholder:t.placeholder,description:t.help||t.description,validation:P.buildValidationRules(t)};if((t.type==="select"||t.type==="lookup"||t.type==="master_detail")&&(o.options=t.options||[],o.multiple=t.multiple),(t.type==="number"||t.type==="currency"||t.type==="percent")&&(o.min=t.min,o.max=t.max,o.step=t.precision?Math.pow(10,-t.precision):void 0),(t.type==="text"||t.type==="textarea"||t.type==="markdown"||t.type==="html")&&(o.maxLength=t.max_length,o.minLength=t.min_length),(t.type==="file"||t.type==="image")&&(o.multiple=t.multiple,o.accept=t.accept?t.accept.join(","):void 0,t.max_size)){const g=`Max size: ${P.formatFileSize(t.max_size)}`;o.description=o.description?`${o.description} (${g})`:g}t.type==="email"&&(o.inputType="email"),t.type==="phone"&&(o.inputType="tel"),t.type==="url"&&(o.inputType="url"),t.type==="password"&&(o.inputType="password"),t.type==="time"&&(o.inputType="time"),(t.type==="formula"||t.type==="summary"||t.type==="auto_number")&&(o.disabled=!0),t.visible_on&&(o.visible=g=>P.evaluateCondition(t.visible_on,g)),f.push(o)}}),m(f),R(!1)},[b,r.fields,r.customFields,r.readOnly,r.mode,d]);const w=c.useCallback(async f=>{if(d&&!u)return r.onSuccess&&await r.onSuccess(f),f;if(!u)throw new Error("DataSource is required for form submission (inline mode not configured)");try{let a;if(r.mode==="create")a=await u.create(r.objectName,f);else if(r.mode==="edit"&&r.recordId)a=await u.update(r.objectName,r.recordId,f);else throw new Error("Invalid form mode or missing record ID");return r.onSuccess&&await r.onSuccess(a),a}catch(a){throw console.error("Failed to submit form:",a),r.onError&&r.onError(a),a}},[r,u,d]),F=c.useCallback(()=>{r.onCancel&&r.onCancel()},[r]);if(N)return E.jsxs("div",{className:"p-4 border border-red-300 bg-red-50 rounded-md",children:[E.jsx("h3",{className:"text-red-800 font-semibold",children:"Error loading form"}),E.jsx("p",{className:"text-red-600 text-sm mt-1",children:N.message})]});if(I)return E.jsxs("div",{className:"p-8 text-center",children:[E.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"}),E.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading form..."})]});const D={type:"form",fields:p,layout:r.layout==="vertical"||r.layout==="horizontal"?r.layout:"vertical",columns:r.columns,submitLabel:r.submitText||(r.mode==="create"?"Create":"Update"),cancelLabel:r.cancelText,showSubmit:r.showSubmit!==!1&&r.mode!=="view",showCancel:r.showCancel!==!1,resetOnSubmit:r.showReset,defaultValues:T,onSubmit:w,onCancel:F,className:r.className};return E.jsx("div",{className:"w-full",children:E.jsx(re.SchemaRenderer,{schema:D})})},H=({schema:r})=>E.jsx(X,{schema:r});W.ComponentRegistry.register("object-form",H),W.ComponentRegistry.register("form",H),y.ObjectForm=X,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
6
+ <%s key={someKey} {...props} />`,s,u,N,u),te[u+s]=!0)}if(u=null,i!==void 0&&(d(i),u=""+i),R(n)&&(d(n.key),u=""+n.key),"key"in n){i={};for(var J in n)J!=="key"&&(i[J]=n[J])}else i=n;return u&&_(i,typeof e=="function"?e.displayName||e.name||"Unknown":e),T(e,u,i,b(),Y,W)}function w(e){p(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===S&&(e._payload.status==="fulfilled"?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e=="object"&&e!==null&&e.$$typeof===D}var x=c,D=Symbol.for("react.transitional.element"),B=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),m=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),r=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),o=Symbol.for("react.activity"),k=Symbol.for("react.client.reference"),z=x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=Object.prototype.hasOwnProperty,se=Array.isArray,U=console.createTask?console.createTask:function(){return null};x={react_stack_bottom_frame:function(e){return e()}};var Z,K={},$=x.react_stack_bottom_frame.bind(x,y)(),ee=U(j(y)),te={};P.Fragment=F,P.jsx=function(e,n,i){var s=1e4>z.recentlyCreatedOwnerStacks++;return h(e,n,i,!1,s?Error("react-stack-top-frame"):$,s?U(j(e)):ee)},P.jsxs=function(e,n,i){var s=1e4>z.recentlyCreatedOwnerStacks++;return h(e,n,i,!0,s?Error("react-stack-top-frame"):$,s?U(j(e)):ee)}})()),P}var q;function ae(){return q||(q=1,process.env.NODE_ENV==="production"?I.exports=oe():I.exports=ie()),I.exports}var v=ae();const H=({schema:t,dataSource:f})=>{const[d,j]=c.useState(null),[b,y]=c.useState([]),[R,_]=c.useState(null),[V,T]=c.useState(!0),[h,w]=c.useState(null),p=t.customFields&&t.customFields.length>0;c.useEffect(()=>{p&&(_(t.initialData||t.initialValues||{}),T(!1))},[p,t.initialData,t.initialValues]),c.useEffect(()=>{const a=async()=>{try{if(!f)throw new Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");const l=await f.getObjectSchema(t.objectName);j(l)}catch(l){console.error("Failed to fetch object schema:",l),w(l)}};p?j({name:t.objectName,fields:{}}):t.objectName&&f&&a()},[t.objectName,f,p]),c.useEffect(()=>{d&&!p&&(async()=>{if(!t.recordId||t.mode==="create"){_(t.initialData||t.initialValues||{}),T(!1);return}if(!p){if(!f){w(new Error("DataSource is required for fetching record data (inline data not provided)")),T(!1);return}T(!0);try{const l=await f.findOne(t.objectName,t.recordId);_(l)}catch(l){console.error("Failed to fetch record:",l),w(l)}finally{T(!1)}}})()},[t.objectName,t.recordId,t.mode,t.initialValues,t.initialData,f,d,p]),c.useEffect(()=>{if(p&&t.customFields){y(t.customFields),T(!1);return}if(!d)return;const a=[],l=t.fields||Object.keys(d.fields||{});(Array.isArray(l)?l:Object.keys(l)).forEach(g=>{const O=typeof g=="string"?g:g.name;if(!O)return;const r=d.fields?.[O];if(!r&&!p)return;const M=!r?.permissions||r?.permissions.write!==!1;if(t.mode!=="view"&&!M)return;const S=t.customFields?.find(o=>o.name===O);if(S)a.push(S);else if(r){const o={name:O,label:r.label||g,type:C.mapFieldTypeToFormType(r.type),required:r.required||!1,disabled:t.readOnly||t.mode==="view"||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:C.buildValidationRules(r),field:r};if((r.type==="select"||r.type==="lookup"||r.type==="master_detail")&&(o.options=r.options||[],o.multiple=r.multiple),(r.type==="number"||r.type==="currency"||r.type==="percent")&&(o.inputType="number",o.min=r.min,o.max=r.max,o.step=r.precision?Math.pow(10,-r.precision):void 0),r.type==="date"&&(o.inputType="date"),r.type==="datetime"&&(o.inputType="datetime-local"),(r.type==="text"||r.type==="textarea"||r.type==="markdown"||r.type==="html")&&(o.maxLength=r.max_length,o.minLength=r.min_length),(r.type==="file"||r.type==="image")&&(o.inputType="file",o.multiple=r.multiple,o.accept=r.accept?r.accept.join(","):void 0,r.max_size)){const k=`Max size: ${C.formatFileSize(r.max_size)}`;o.description=o.description?`${o.description} (${k})`:k}r.type==="email"&&(o.inputType="email"),r.type==="phone"&&(o.inputType="tel"),r.type==="url"&&(o.inputType="url"),r.type==="password"&&(o.inputType="password"),r.type==="time"&&(o.inputType="time"),(r.type==="formula"||r.type==="summary"||r.type==="auto_number")&&(o.disabled=!0),r.visible_on&&(o.visible=k=>C.evaluateCondition(r.visible_on,k)),a.push(o)}}),y(a),T(!1)},[d,t.fields,t.customFields,t.readOnly,t.mode,p]);const x=c.useCallback(async(a,l)=>{if(a&&(a.nativeEvent||a._reactName==="onSubmit")&&(console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."),l===void 0&&(l=a,a={})),p&&!f)return t.onSuccess&&await t.onSuccess(a),a;if(!f)throw new Error("DataSource is required for form submission (inline mode not configured)");try{let m;if(t.mode==="create")m=await f.create(t.objectName,a);else if(t.mode==="edit"&&t.recordId)m=await f.update(t.objectName,t.recordId,a);else throw new Error("Invalid form mode or missing record ID");return t.onSuccess&&await t.onSuccess(m),m}catch(m){throw console.error("Failed to submit form:",m),t.onError&&t.onError(m),m}},[t,f,p]),D=c.useCallback(()=>{t.onCancel&&t.onCancel()},[t]),F={...c.useMemo(()=>{if(!d?.fields)return{};const a={};return Object.keys(d.fields).forEach(l=>{const m=d.fields[l];m.defaultValue!==void 0&&(a[l]=m.defaultValue)}),a},[d]),...R};if(h)return v.jsxs("div",{className:"p-4 border border-red-300 bg-red-50 rounded-md",children:[v.jsx("h3",{className:"text-red-800 font-semibold",children:"Error loading form"}),v.jsx("p",{className:"text-red-600 text-sm mt-1",children:h.message})]});if(V)return v.jsxs("div",{className:"p-8 text-center",children:[v.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"}),v.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Loading form..."})]});const L={type:"form",fields:b,layout:t.layout==="vertical"||t.layout==="horizontal"?t.layout:"vertical",columns:t.columns,submitLabel:t.submitText||(t.mode==="create"?"Create":"Update"),cancelLabel:t.cancelText,showSubmit:t.showSubmit!==!1&&t.mode!=="view",showCancel:t.showCancel!==!1,resetOnSubmit:t.showReset,defaultValues:F,onSubmit:x,onCancel:D,className:t.className};return v.jsx("div",{className:"w-full",children:v.jsx(ne.SchemaRenderer,{schema:L})})},le=({schema:t})=>v.jsx(H,{schema:t});re.ComponentRegistry.register("object-form",le,{namespace:"plugin-form"}),E.ObjectForm=H,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-form",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Form plugin for Object UI",
@@ -16,21 +16,23 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "lucide-react": "^0.563.0",
19
- "@object-ui/components": "0.3.0",
20
- "@object-ui/core": "0.3.0",
21
- "@object-ui/fields": "0.3.0",
22
- "@object-ui/react": "0.3.0",
23
- "@object-ui/types": "0.3.0"
19
+ "@object-ui/components": "0.5.0",
20
+ "@object-ui/core": "0.5.0",
21
+ "@object-ui/fields": "0.5.0",
22
+ "@object-ui/react": "0.5.0",
23
+ "@object-ui/types": "0.5.0"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^18.0.0 || ^19.0.0",
27
27
  "react-dom": "^18.0.0 || ^19.0.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@vitejs/plugin-react": "^4.2.1",
30
+ "@vitejs/plugin-react": "^5.1.3",
31
+ "msw": "^2.12.7",
31
32
  "typescript": "^5.9.3",
32
33
  "vite": "^7.3.1",
33
- "vite-plugin-dts": "^4.5.4"
34
+ "vite-plugin-dts": "^4.5.4",
35
+ "@object-ui/data-objectstack": "0.5.0"
34
36
  },
35
37
  "scripts": {
36
38
  "build": "vite build",
@@ -0,0 +1,129 @@
1
+ import { describe, it, expect, vi, beforeAll, afterAll, afterEach } from 'vitest';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
4
+ import { ObjectForm } from './ObjectForm';
5
+ import { ObjectStackAdapter } from '@object-ui/data-objectstack';
6
+ import { setupServer } from 'msw/node';
7
+ import { http, HttpResponse } from 'msw';
8
+ import { registerAllFields } from '@object-ui/fields';
9
+ import React from 'react';
10
+ import { ContactObject } from '../../../examples/crm/src/objects/contact.object';
11
+
12
+ // Register widget renderers
13
+ registerAllFields();
14
+
15
+ const BASE_URL = process.env.OBJECTSTACK_API_URL || 'http://localhost';
16
+
17
+ // --- Mock Data ---
18
+
19
+ const mockSchema = ContactObject;
20
+
21
+ const mockRecord = {
22
+ _id: '1',
23
+ name: 'Alice Johnson',
24
+ email: 'alice@example.com',
25
+ status: 'Active'
26
+ };
27
+
28
+ // --- MSW Setup ---
29
+
30
+ const handlers = [
31
+ // OPTIONS handler for CORS preflight
32
+ http.options(`${BASE_URL}/*`, () => {
33
+ return new HttpResponse(null, {
34
+ status: 200,
35
+ headers: {
36
+ 'Access-Control-Allow-Origin': '*',
37
+ 'Access-Control-Allow-Methods': 'GET,HEAD,POST,PUT,DELETE,CONNECT,OPTIONS,TRACE,PATCH',
38
+ 'Access-Control-Allow-Headers': 'Content-Type, Authorization',
39
+ },
40
+ });
41
+ }),
42
+
43
+ // Health check / Connection check (ObjectStackClient often pings root or /api/v1)
44
+ http.get(`${BASE_URL}/api/v1`, () => {
45
+ return HttpResponse.json({ status: 'ok', version: '1.0.0' });
46
+ }),
47
+
48
+ // Mock Schema Fetch: GET /api/v1/meta/object/:name
49
+ http.get(`${BASE_URL}/api/v1/meta/object/:name`, ({ params }) => {
50
+ const { name } = params;
51
+ if (name === 'contact') {
52
+ return HttpResponse.json(mockSchema);
53
+ }
54
+ return new HttpResponse(null, { status: 404 });
55
+ }),
56
+
57
+ // Mock Record Fetch: GET /api/v1/data/:object/:id
58
+ http.get(`${BASE_URL}/api/v1/data/:object/:id`, ({ params }) => {
59
+ const { object, id } = params;
60
+ if (object === 'contact' && id === '1') {
61
+ return HttpResponse.json(mockRecord);
62
+ }
63
+ return new HttpResponse(null, { status: 404 });
64
+ })
65
+ ];
66
+
67
+ const server = setupServer(...handlers);
68
+
69
+ // --- Test Suite ---
70
+
71
+ describe('ObjectForm with ObjectStack/MSW', () => {
72
+ // Only start MSW if we are NOT using a real server
73
+ if (!process.env.OBJECTSTACK_API_URL) {
74
+ beforeAll(() => server.listen());
75
+ afterEach(() => server.resetHandlers());
76
+ afterAll(() => server.close());
77
+ }
78
+
79
+ // Create real adapter instance pointing to MSW or Real Server
80
+ const dataSource = new ObjectStackAdapter({
81
+ baseUrl: BASE_URL,
82
+ // Add custom fetch for environment that might need it, or rely on global fetch
83
+ // fetch: global.fetch
84
+ });
85
+
86
+ it('loads schema and renders form fields', async () => {
87
+ render(
88
+ <ObjectForm
89
+ schema={{
90
+ type: 'object-form',
91
+ objectName: 'contact', // Triggers schema fetch
92
+ mode: 'create'
93
+ }}
94
+ dataSource={dataSource} // Logic moves from mock fn to real adapter + MSW
95
+ />
96
+ );
97
+
98
+ // Verify fields appear (async as schema loads via HTTP)
99
+ await waitFor(() => {
100
+ // Changed from 'Full Name' to 'Name' based on CRM example schema
101
+ expect(screen.getByText('Name')).toBeInTheDocument();
102
+ }, { timeout: 2000 }); // Give slight buffer for network mock
103
+ expect(screen.getByText('Email')).toBeInTheDocument();
104
+ expect(screen.getByText('Status')).toBeInTheDocument();
105
+ });
106
+
107
+ it('loads record data in edit mode', async () => {
108
+ render(
109
+ <ObjectForm
110
+ schema={{
111
+ type: 'object-form',
112
+ objectName: 'contact',
113
+ mode: 'edit',
114
+ recordId: '1'
115
+ }}
116
+ dataSource={dataSource}
117
+ />
118
+ );
119
+
120
+ // Initial load of schema logic + data fetch
121
+ await waitFor(() => {
122
+ // Changed from 'Full Name' to 'Name'
123
+ expect(screen.getByRole('textbox', { name: /Name/i })).toHaveValue('Alice Johnson');
124
+ }, { timeout: 2000 }); // Give slight buffer for network mock
125
+
126
+ // Changed from 'Email Address' to 'Email'
127
+ expect(screen.getByRole('textbox', { name: /Email/i })).toHaveValue('alice@example.com');
128
+ });
129
+ });
@@ -0,0 +1,61 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
+ import { ObjectForm } from './ObjectForm';
4
+ import { registerAllFields } from '@object-ui/fields';
5
+ import React from 'react';
6
+
7
+ // Ensure fields are registered
8
+ registerAllFields();
9
+
10
+ describe('ObjectForm Integration', () => {
11
+ const objectSchema = {
12
+ name: 'test_object',
13
+ fields: {
14
+ name: {
15
+ type: 'text',
16
+ label: 'Name'
17
+ },
18
+ price: {
19
+ type: 'currency',
20
+ label: 'Price',
21
+ scale: 2
22
+ }
23
+ }
24
+ };
25
+
26
+ const mockDataSource: any = {
27
+ getObjectSchema: vi.fn().mockResolvedValue(objectSchema),
28
+ createRecord: vi.fn(),
29
+ updateRecord: vi.fn(),
30
+ getRecord: vi.fn(),
31
+ query: vi.fn()
32
+ };
33
+
34
+ it('renders fields using specialized components', async () => {
35
+ render(
36
+ <ObjectForm
37
+ schema={{
38
+ type: 'object-form',
39
+ objectName: 'test_object',
40
+ mode: 'create'
41
+ }}
42
+ dataSource={mockDataSource}
43
+ />
44
+ );
45
+
46
+ // Wait for schema to load (useEffect)
47
+ await waitFor(() => {
48
+ expect(mockDataSource.getObjectSchema).toHaveBeenCalledWith('test_object');
49
+ });
50
+
51
+ // Check if labels are present
52
+ await waitFor(() => {
53
+ expect(screen.queryByText('Name')).toBeTruthy();
54
+ });
55
+ expect(screen.getByText('Price')).toBeTruthy();
56
+
57
+ // Assert input exists
58
+ // Since we don't have getByLabelText working reliably without full accessibility tree in happy-dom sometimes,
59
+ // we can try looking for inputs.
60
+ });
61
+ });
@@ -58,6 +58,7 @@ export const ObjectForm: React.FC<ObjectFormProps> = ({
58
58
  schema,
59
59
  dataSource,
60
60
  }) => {
61
+
61
62
  const [objectSchema, setObjectSchema] = useState<any>(null);
62
63
  const [formFields, setFormFields] = useState<FormField[]>([]);
63
64
  const [initialData, setInitialData] = useState<any>(null);
@@ -107,6 +108,7 @@ export const ObjectForm: React.FC<ObjectFormProps> = ({
107
108
  const fetchInitialData = async () => {
108
109
  if (!schema.recordId || schema.mode === 'create') {
109
110
  setInitialData(schema.initialData || schema.initialValues || {});
111
+ setLoading(false);
110
112
  return;
111
113
  }
112
114
 
@@ -154,23 +156,33 @@ export const ObjectForm: React.FC<ObjectFormProps> = ({
154
156
  // Determine which fields to include
155
157
  const fieldsToShow = schema.fields || Object.keys(objectSchema.fields || {});
156
158
 
157
- fieldsToShow.forEach((fieldName) => {
158
- const field = objectSchema.fields?.[fieldName];
159
- if (!field) return;
159
+ // Support object format for fields in schema (legacy/compat)
160
+ const fieldNames = Array.isArray(fieldsToShow)
161
+ ? fieldsToShow
162
+ : Object.keys(fieldsToShow);
163
+
164
+ fieldNames.forEach((fieldName) => {
165
+ // If fieldsToShow is an array of strings, fieldName is the string
166
+ // If fieldsToShow is array of objects (unlikely but possible in some formats), we need to extract name
167
+ const name = typeof fieldName === 'string' ? fieldName : (fieldName as any).name;
168
+ if (!name) return;
169
+
170
+ const field = objectSchema.fields?.[name];
171
+ if (!field && !hasInlineFields) return; // Skip if not found in object definition unless inline
160
172
 
161
173
  // Check field-level permissions for create/edit modes
162
- const hasWritePermission = !field.permissions || field.permissions.write !== false;
174
+ const hasWritePermission = !field?.permissions || field?.permissions.write !== false;
163
175
  if (schema.mode !== 'view' && !hasWritePermission) return; // Skip fields without write permission
164
176
 
165
177
  // Check if there's a custom field configuration
166
- const customField = schema.customFields?.find(f => f.name === fieldName);
178
+ const customField = schema.customFields?.find(f => f.name === name);
167
179
 
168
180
  if (customField) {
169
181
  generatedFields.push(customField);
170
- } else {
182
+ } else if (field) {
171
183
  // Auto-generate field from schema
172
184
  const formField: FormField = {
173
- name: fieldName,
185
+ name: name,
174
186
  label: field.label || fieldName,
175
187
  type: mapFieldTypeToFormType(field.type),
176
188
  required: field.required || false,
@@ -178,6 +190,8 @@ export const ObjectForm: React.FC<ObjectFormProps> = ({
178
190
  placeholder: field.placeholder,
179
191
  description: field.help || field.description,
180
192
  validation: buildValidationRules(field),
193
+ // Important: Pass the original field metadata so widgets can access properties like precision, currency, etc.
194
+ field: field,
181
195
  };
182
196
 
183
197
  // Add field-specific properties
@@ -187,17 +201,27 @@ export const ObjectForm: React.FC<ObjectFormProps> = ({
187
201
  }
188
202
 
189
203
  if (field.type === 'number' || field.type === 'currency' || field.type === 'percent') {
204
+ formField.inputType = 'number';
190
205
  formField.min = field.min;
191
206
  formField.max = field.max;
192
207
  formField.step = field.precision ? Math.pow(10, -field.precision) : undefined;
193
208
  }
194
209
 
210
+ if (field.type === 'date') {
211
+ formField.inputType = 'date';
212
+ }
213
+
214
+ if (field.type === 'datetime') {
215
+ formField.inputType = 'datetime-local';
216
+ }
217
+
195
218
  if (field.type === 'text' || field.type === 'textarea' || field.type === 'markdown' || field.type === 'html') {
196
219
  formField.maxLength = field.max_length;
197
220
  formField.minLength = field.min_length;
198
221
  }
199
222
 
200
223
  if (field.type === 'file' || field.type === 'image') {
224
+ formField.inputType = 'file';
201
225
  formField.multiple = field.multiple;
202
226
  formField.accept = field.accept ? field.accept.join(',') : undefined;
203
227
  // Add validation hints for file size and dimensions
@@ -250,7 +274,19 @@ export const ObjectForm: React.FC<ObjectFormProps> = ({
250
274
  }, [objectSchema, schema.fields, schema.customFields, schema.readOnly, schema.mode, hasInlineFields]);
251
275
 
252
276
  // Handle form submission
253
- const handleSubmit = useCallback(async (formData: any) => {
277
+ const handleSubmit = useCallback(async (formData: any, e?: any) => {
278
+ // If we receive an event as the first argument, it means the Form renderer passed the event instead of data
279
+ // This happens when react-hook-form's handleSubmit is bypassed or configured incorrectly
280
+ if (formData && (formData.nativeEvent || formData._reactName === 'onSubmit')) {
281
+ console.warn('ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue.');
282
+ // Proceed defensively - we can't do much if we don't have data, but let's try to not crash
283
+ // If we are here, formData is actually the event
284
+ if (e === undefined) {
285
+ e = formData;
286
+ formData = {}; // Reset to empty object or we try to submit the Event object
287
+ }
288
+ }
289
+
254
290
  // For inline fields without a dataSource, just call the success callback
255
291
  if (hasInlineFields && !dataSource) {
256
292
  if (schema.onSuccess) {
@@ -299,6 +335,24 @@ export const ObjectForm: React.FC<ObjectFormProps> = ({
299
335
  }
300
336
  }, [schema]);
301
337
 
338
+ // Calculate default values from schema fields
339
+ const schemaDefaultValues = React.useMemo(() => {
340
+ if (!objectSchema?.fields) return {};
341
+ const defaults: Record<string, any> = {};
342
+ Object.keys(objectSchema.fields).forEach(key => {
343
+ const field = objectSchema.fields[key];
344
+ if (field.defaultValue !== undefined) {
345
+ defaults[key] = field.defaultValue;
346
+ }
347
+ });
348
+ return defaults;
349
+ }, [objectSchema]);
350
+
351
+ const finalDefaultValues = {
352
+ ...schemaDefaultValues,
353
+ ...initialData
354
+ };
355
+
302
356
  // Render error state
303
357
  if (error) {
304
358
  return (
@@ -334,7 +388,7 @@ export const ObjectForm: React.FC<ObjectFormProps> = ({
334
388
  showSubmit: schema.showSubmit !== false && schema.mode !== 'view',
335
389
  showCancel: schema.showCancel !== false,
336
390
  resetOnSubmit: schema.showReset,
337
- defaultValues: initialData,
391
+ defaultValues: finalDefaultValues,
338
392
  onSubmit: handleSubmit,
339
393
  onCancel: handleCancel,
340
394
  className: schema.className,
package/src/index.tsx CHANGED
@@ -18,5 +18,8 @@ const ObjectFormRenderer: React.FC<{ schema: any }> = ({ schema }) => {
18
18
  return <ObjectForm schema={schema} />;
19
19
  };
20
20
 
21
- ComponentRegistry.register('object-form', ObjectFormRenderer);
22
- ComponentRegistry.register('form', ObjectFormRenderer); // Alias
21
+ ComponentRegistry.register('object-form', ObjectFormRenderer, {
22
+ namespace: 'plugin-form'
23
+ });
24
+ // Note: 'form' type is handled by @object-ui/components Form component
25
+ // This plugin only handles 'object-form' which integrates with ObjectQL/ObjectStack
package/vite.config.ts CHANGED
@@ -11,6 +11,18 @@ export default defineConfig({
11
11
  include: ['src'],
12
12
  }),
13
13
  ],
14
+ resolve: {
15
+ alias: {
16
+ '@object-ui/core': resolve(__dirname, '../core/src'),
17
+ '@object-ui/types': resolve(__dirname, '../types/src'),
18
+ '@object-ui/data-objectstack': resolve(__dirname, '../data-objectstack/src'),
19
+ '@object-ui/react': resolve(__dirname, '../react/src'),
20
+ '@object-ui/components': resolve(__dirname, '../components/src'),
21
+ '@object-ui/fields': resolve(__dirname, '../fields/src'),
22
+ '@object-ui/plugin-dashboard': resolve(__dirname, '../plugin-dashboard/src'),
23
+ '@object-ui/plugin-grid': resolve(__dirname, '../plugin-grid/src'),
24
+ }
25
+ },
14
26
  build: {
15
27
  lib: {
16
28
  entry: resolve(__dirname, 'src/index.tsx'),
@@ -36,4 +48,10 @@ export default defineConfig({
36
48
  },
37
49
  },
38
50
  },
51
+ test: {
52
+ globals: true,
53
+ environment: 'happy-dom',
54
+ setupFiles: ['../../vitest.setup.tsx'],
55
+ passWithNoTests: true,
56
+ },
39
57
  });