@ram_28/kf-ai-sdk 2.0.17 → 2.0.19

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.
Files changed (35) hide show
  1. package/dist/{FileField-BWrSHNRq.js → FileField-CZjS2uLh.js} +3 -3
  2. package/dist/{FileField-eDeuzln8.cjs → FileField-DU4UWo_t.cjs} +1 -1
  3. package/dist/auth/authClient.d.ts.map +1 -1
  4. package/dist/auth.cjs +1 -1
  5. package/dist/auth.mjs +101 -105
  6. package/dist/bdo/core/Item.d.ts +0 -4
  7. package/dist/bdo/core/Item.d.ts.map +1 -1
  8. package/dist/bdo/fields/ReferenceField.d.ts +1 -1
  9. package/dist/bdo/fields/ReferenceField.d.ts.map +1 -1
  10. package/dist/bdo/fields/SelectField.d.ts +1 -1
  11. package/dist/bdo/fields/SelectField.d.ts.map +1 -1
  12. package/dist/bdo/fields/UserField.d.ts +1 -1
  13. package/dist/bdo/fields/UserField.d.ts.map +1 -1
  14. package/dist/bdo.cjs +1 -1
  15. package/dist/bdo.mjs +52 -61
  16. package/dist/components/hooks/useBDOForm/createItemProxy.d.ts +2 -3
  17. package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -1
  18. package/dist/form.cjs +1 -1
  19. package/dist/form.mjs +226 -243
  20. package/dist/workflow.cjs +1 -1
  21. package/dist/workflow.mjs +1 -1
  22. package/docs/README.md +6 -0
  23. package/docs/examples/fields/complex-fields.md +248 -0
  24. package/docs/examples/fields/primitive-fields.md +217 -0
  25. package/docs/fields/README.md +141 -0
  26. package/docs/fields/api_reference.md +134 -0
  27. package/docs/useActivityForm/README.md +4 -1
  28. package/docs/useBDOForm/README.md +4 -1
  29. package/package.json +1 -1
  30. package/sdk/auth/authClient.ts +15 -21
  31. package/sdk/bdo/core/Item.ts +1 -10
  32. package/sdk/bdo/fields/ReferenceField.ts +1 -1
  33. package/sdk/bdo/fields/SelectField.ts +1 -1
  34. package/sdk/bdo/fields/UserField.ts +1 -1
  35. package/sdk/components/hooks/useBDOForm/createItemProxy.ts +17 -58
package/dist/form.mjs CHANGED
@@ -1,345 +1,328 @@
1
- import { F as he, I as _e, V as we } from "./constants-Cyi942Yr.js";
2
- import { useMemo as b, useEffect as k, useRef as j, useCallback as K } from "react";
1
+ import { F as he, I as _e, V as Ve } from "./constants-Cyi942Yr.js";
2
+ import { useMemo as U, useEffect as k, useRef as j, useCallback as K } from "react";
3
3
  import { v as Z, c as p, a as ee, u as te, b as ae, d as ne, e as se, f as $ } from "./shared-5a7UkED1.js";
4
4
  import { useQuery as J } from "@tanstack/react-query";
5
5
  import { a as y } from "./client-_ayziI1d.js";
6
6
  import { v as G, e as Q } from "./attachment-constants-C2UHWxmp.js";
7
7
  import { g as ie } from "./metadata-Cc1mBcLS.js";
8
- function re(D, a) {
9
- const g = D.getFields(), T = /* @__PURE__ */ new Map(), C = D.getBoId();
10
- let m = null, x = null;
11
- async function R() {
12
- const F = a.getValues("_id");
13
- return F || m || (x || (x = y(C).draftInteraction({}).then((e) => (m = e._id, a.setValue("_id", m, { shouldDirty: !1 }), m)).catch((e) => {
14
- throw x = null, e;
15
- })), x);
16
- }
8
+ function re(v, n) {
9
+ const f = v.getFields(), T = /* @__PURE__ */ new Map(), b = v.getBoId(), c = () => n.getValues("_id") || "draft";
17
10
  return new Proxy({}, {
18
- get(F, e) {
11
+ get(C, e) {
19
12
  if (typeof e == "symbol")
20
13
  return;
21
14
  if (e === "_id")
22
- return a.getValues("_id");
15
+ return n.getValues("_id");
23
16
  if (e === "toJSON")
24
- return () => a.getValues();
17
+ return () => n.getValues();
25
18
  if (e === "validate")
26
- return () => a.trigger();
27
- if (e === "_hasDraft")
28
- return () => !!m;
19
+ return () => n.trigger();
29
20
  if (T.has(e))
30
21
  return T.get(e);
31
- const s = g[e], c = (s == null ? void 0 : s.meta) ?? {
22
+ const i = f[e], o = (i == null ? void 0 : i.meta) ?? {
32
23
  _id: e,
33
24
  Name: e,
34
25
  Type: "String"
35
- }, A = (s == null ? void 0 : s.readOnly) ?? !1, B = () => {
36
- if (!s) return { valid: !0, errors: [] };
37
- let l = a.getValues(e);
38
- if ("integerPart" in s && typeof l == "string" && l !== "") {
39
- const o = Number(l);
40
- isNaN(o) || (l = o, a.setValue(e, o, { shouldDirty: !1 }));
26
+ }, z = (i == null ? void 0 : i.readOnly) ?? !1, w = () => {
27
+ if (!i) return { valid: !0, errors: [] };
28
+ let s = n.getValues(e);
29
+ if ("integerPart" in i && typeof s == "string" && s !== "") {
30
+ const a = Number(s);
31
+ isNaN(a) || (s = a, n.setValue(e, a, { shouldDirty: !1 }));
41
32
  }
42
- if (!s.required && (l == null || l === "" || Array.isArray(l) && l.length === 0))
33
+ if (!i.required && (s == null || s === "" || Array.isArray(s) && s.length === 0))
43
34
  return { valid: !0, errors: [] };
44
- const i = s.validate(l);
45
- if (!i.valid) return i;
46
- const t = Z(s, l);
47
- if (!t.valid) return t;
48
- if (D.hasMetadata()) {
49
- const o = D.validateFieldExpression(
35
+ const l = i.validate(s);
36
+ if (!l.valid) return l;
37
+ const r = Z(i, s);
38
+ if (!r.valid) return r;
39
+ if (v.hasMetadata()) {
40
+ const a = v.validateFieldExpression(
50
41
  e,
51
- l,
52
- a.getValues()
42
+ s,
43
+ n.getValues()
53
44
  );
54
- if (!o.valid) return o;
45
+ if (!a.valid) return a;
55
46
  }
56
47
  return { valid: !0, errors: [] };
57
- }, E = (l) => {
58
- const i = a.getValues(e);
59
- return i ?? l;
48
+ }, x = (s) => {
49
+ const l = n.getValues(e);
50
+ return l ?? s;
60
51
  };
61
- if (!A) {
62
- const l = () => {
63
- const t = a.getValues(e);
64
- return c.Type === "File" ? t ?? [] : t;
65
- }, i = {
66
- label: (s == null ? void 0 : s.label) ?? e,
67
- required: (s == null ? void 0 : s.required) ?? !1,
52
+ if (!z) {
53
+ const s = () => {
54
+ const r = n.getValues(e);
55
+ return o.Type === "File" ? r ?? [] : r;
56
+ }, l = {
57
+ label: (i == null ? void 0 : i.label) ?? e,
58
+ required: (i == null ? void 0 : i.required) ?? !1,
68
59
  readOnly: !1,
69
- defaultValue: s == null ? void 0 : s.defaultValue,
70
- meta: c,
71
- get: l,
72
- getOrDefault: E,
73
- set: (t) => {
74
- a.setValue(e, t, {
60
+ defaultValue: i == null ? void 0 : i.defaultValue,
61
+ meta: o,
62
+ get: s,
63
+ getOrDefault: x,
64
+ set: (r) => {
65
+ n.setValue(e, r, {
75
66
  shouldDirty: !0,
76
67
  shouldTouch: !0,
77
68
  shouldValidate: !1
78
69
  // Let mode control validation timing
79
70
  });
80
71
  },
81
- validate: B
72
+ validate: w
82
73
  };
83
- if (c.Type === "Image" || c.Type === "File") {
84
- const t = C, o = () => {
85
- const n = a.getValues("_id");
86
- if (!n) throw new Error("Save the record before attachment operations");
87
- return n;
88
- };
89
- c.Type === "Image" ? (i.upload = async (n) => {
90
- G(n.name, "Image");
91
- const r = await R(), [u] = await y(t).getUploadUrl(r, e, [
92
- { FileName: n.name, Size: n.size, FileExtension: Q(n.name) }
74
+ if (o.Type === "Image" || o.Type === "File") {
75
+ const r = b;
76
+ o.Type === "Image" ? (l.upload = async (a) => {
77
+ G(a.name, "Image");
78
+ const t = c(), [d] = await y(r).getUploadUrl(t, e, [
79
+ { FileName: a.name, Size: a.size, FileExtension: Q(a.name) }
93
80
  ]);
94
- await fetch(u.UploadUrl.URL, {
81
+ await fetch(d.UploadUrl.URL, {
95
82
  method: "PUT",
96
- headers: { "Content-Type": u.ContentType },
97
- body: n
83
+ headers: { "Content-Type": d.ContentType },
84
+ body: a
98
85
  });
99
- const f = {
100
- _id: u._id,
101
- _name: u._name,
102
- FileName: u.FileName,
103
- FileExtension: u.FileExtension,
104
- Size: u.Size,
105
- ContentType: u.ContentType
86
+ const u = {
87
+ _id: d._id,
88
+ _name: d._name,
89
+ FileName: d.FileName,
90
+ FileExtension: d.FileExtension,
91
+ Size: d.Size,
92
+ ContentType: d.ContentType
106
93
  };
107
- return a.setValue(e, f, { shouldDirty: !0 }), f;
108
- }, i.deleteAttachment = async () => {
109
- const n = a.getValues(e), r = o();
110
- if (!(n != null && n._id)) throw new Error(`${e} has no image to delete`);
111
- await y(t).deleteAttachment(r, e, n._id), a.setValue(e, null, { shouldDirty: !0 });
112
- }, i.getDownloadUrl = async (n) => {
113
- const r = a.getValues(e), u = o();
114
- if (!(r != null && r._id)) throw new Error(`${e} has no image`);
115
- return y(t).getDownloadUrl(u, e, r._id, n);
116
- }) : (i.upload = async (n) => {
117
- for (const _ of n) G(_.name, "File");
118
- const r = await R(), u = n.map((_) => ({
119
- FileName: _.name,
120
- Size: _.size,
121
- FileExtension: Q(_.name)
122
- })), f = await y(t).getUploadUrl(r, e, u), N = await Promise.all(
123
- n.map(async (_, h) => (await fetch(f[h].UploadUrl.URL, {
94
+ return n.setValue(e, u, { shouldDirty: !0 }), u;
95
+ }, l.deleteAttachment = async () => {
96
+ const a = n.getValues(e), t = c();
97
+ if (!(a != null && a._id)) throw new Error(`${e} has no image to delete`);
98
+ await y(r).deleteAttachment(t, e, a._id), n.setValue(e, null, { shouldDirty: !0 });
99
+ }, l.getDownloadUrl = async (a) => {
100
+ const t = n.getValues(e), d = c();
101
+ if (!(t != null && t._id)) throw new Error(`${e} has no image`);
102
+ return y(r).getDownloadUrl(d, e, t._id, a);
103
+ }) : (l.upload = async (a) => {
104
+ for (const h of a) G(h.name, "File");
105
+ const t = c(), d = a.map((h) => ({
106
+ FileName: h.name,
107
+ Size: h.size,
108
+ FileExtension: Q(h.name)
109
+ })), u = await y(r).getUploadUrl(t, e, d), g = await Promise.all(
110
+ a.map(async (h, m) => (await fetch(u[m].UploadUrl.URL, {
124
111
  method: "PUT",
125
- headers: { "Content-Type": f[h].ContentType },
126
- body: _
112
+ headers: { "Content-Type": u[m].ContentType },
113
+ body: h
127
114
  }), {
128
- _id: f[h]._id,
129
- _name: f[h]._name,
130
- FileName: f[h].FileName,
131
- FileExtension: f[h].FileExtension,
132
- Size: f[h].Size,
133
- ContentType: f[h].ContentType
115
+ _id: u[m]._id,
116
+ _name: u[m]._name,
117
+ FileName: u[m].FileName,
118
+ FileExtension: u[m].FileExtension,
119
+ Size: u[m].Size,
120
+ ContentType: u[m].ContentType
134
121
  }))
135
- ), O = a.getValues(e) ?? [];
136
- return a.setValue(e, [...O, ...N], { shouldDirty: !0 }), N;
137
- }, i.deleteAttachment = async (n) => {
138
- const r = a.getValues(e) ?? [], u = o();
139
- await y(t).deleteAttachment(u, e, n), a.setValue(
122
+ ), P = n.getValues(e) ?? [];
123
+ return n.setValue(e, [...P, ...g], { shouldDirty: !0 }), g;
124
+ }, l.deleteAttachment = async (a) => {
125
+ const t = n.getValues(e) ?? [], d = c();
126
+ await y(r).deleteAttachment(d, e, a), n.setValue(
140
127
  e,
141
- r.filter((f) => f._id !== n),
128
+ t.filter((u) => u._id !== a),
142
129
  { shouldDirty: !0 }
143
130
  );
144
- }, i.getDownloadUrl = async (n, r) => {
145
- const u = o();
146
- return y(t).getDownloadUrl(u, e, n, r);
147
- }, i.getDownloadUrls = async (n) => {
148
- const r = o();
149
- return y(t).getDownloadUrls(r, e, n);
131
+ }, l.getDownloadUrl = async (a, t) => {
132
+ const d = c();
133
+ return y(r).getDownloadUrl(d, e, a, t);
134
+ }, l.getDownloadUrls = async (a) => {
135
+ const t = c();
136
+ return y(r).getDownloadUrls(t, e, a);
150
137
  });
151
138
  }
152
- return T.set(e, i), i;
139
+ return T.set(e, l), l;
153
140
  }
154
- const d = () => {
155
- const l = a.getValues(e);
156
- return c.Type === "File" ? l ?? [] : l;
141
+ const A = () => {
142
+ const s = n.getValues(e);
143
+ return o.Type === "File" ? s ?? [] : s;
157
144
  }, I = {
158
- label: (s == null ? void 0 : s.label) ?? e,
159
- required: (s == null ? void 0 : s.required) ?? !1,
145
+ label: (i == null ? void 0 : i.label) ?? e,
146
+ required: (i == null ? void 0 : i.required) ?? !1,
160
147
  readOnly: !0,
161
- defaultValue: s == null ? void 0 : s.defaultValue,
162
- meta: c,
163
- get: d,
164
- getOrDefault: E,
165
- validate: B
148
+ defaultValue: i == null ? void 0 : i.defaultValue,
149
+ meta: o,
150
+ get: A,
151
+ getOrDefault: x,
152
+ validate: w
166
153
  };
167
- if (c.Type === "Image" || c.Type === "File") {
168
- const l = C, i = () => {
169
- const t = a.getValues("_id");
170
- if (!t) throw new Error("Cannot perform attachment operation: item has no _id. Save the item first.");
171
- return t;
172
- };
173
- c.Type === "Image" ? I.getDownloadUrl = async (t) => {
174
- const o = a.getValues(e), n = i();
175
- if (!(o != null && o._id)) throw new Error(`${e} has no image to download`);
176
- return y(l).getDownloadUrl(n, e, o._id, t);
177
- } : (I.getDownloadUrl = async (t, o) => {
178
- const n = i();
179
- return y(l).getDownloadUrl(n, e, t, o);
180
- }, I.getDownloadUrls = async (t) => {
181
- const o = i();
182
- return y(l).getDownloadUrls(o, e, t);
154
+ if (o.Type === "Image" || o.Type === "File") {
155
+ const s = b;
156
+ o.Type === "Image" ? I.getDownloadUrl = async (l) => {
157
+ const r = n.getValues(e), a = c();
158
+ if (!(r != null && r._id)) throw new Error(`${e} has no image to download`);
159
+ return y(s).getDownloadUrl(a, e, r._id, l);
160
+ } : (I.getDownloadUrl = async (l, r) => {
161
+ const a = c();
162
+ return y(s).getDownloadUrl(a, e, l, r);
163
+ }, I.getDownloadUrls = async (l) => {
164
+ const r = c();
165
+ return y(s).getDownloadUrls(r, e, l);
183
166
  });
184
167
  }
185
168
  return T.set(e, I), I;
186
169
  },
187
- has(F, e) {
188
- return typeof e == "symbol" ? !1 : e === "_id" || e === "toJSON" || e === "validate" || e === "_hasDraft" ? !0 : e in g;
170
+ has(C, e) {
171
+ return typeof e == "symbol" ? !1 : e === "_id" || e === "toJSON" || e === "validate" ? !0 : e in f;
189
172
  },
190
- ownKeys(F) {
191
- return [...Object.keys(g), "_id", "toJSON", "validate"];
173
+ ownKeys(C) {
174
+ return [...Object.keys(f), "_id", "toJSON", "validate"];
192
175
  },
193
- getOwnPropertyDescriptor(F, e) {
176
+ getOwnPropertyDescriptor(C, e) {
194
177
  if (typeof e != "symbol")
195
178
  return {
196
179
  configurable: !0,
197
- enumerable: e !== "toJSON" && e !== "validate" && e !== "_hasDraft"
180
+ enumerable: e !== "toJSON" && e !== "validate"
198
181
  };
199
182
  }
200
183
  });
201
184
  }
202
- function ye(D) {
185
+ function fe(v) {
203
186
  const {
204
- bdo: a,
205
- recordId: g,
187
+ bdo: n,
188
+ recordId: f,
206
189
  operation: T,
207
- defaultValues: C,
208
- mode: m = "onBlur",
209
- enableDraft: x = !1,
210
- enableConstraintValidation: R,
211
- enableExpressionValidation: F
212
- } = D, e = T ?? (g ? "update" : "create"), s = b(
213
- () => p(a, { enableConstraintValidation: R }),
214
- [a, R]
190
+ defaultValues: b,
191
+ mode: c = "onBlur",
192
+ enableDraft: C = !1,
193
+ enableConstraintValidation: e,
194
+ enableExpressionValidation: i
195
+ } = v, o = T ?? (f ? "update" : "create"), z = U(
196
+ () => p(n, { enableConstraintValidation: e }),
197
+ [n, e]
215
198
  ), {
216
- data: c,
217
- isLoading: A,
218
- isFetching: B,
219
- error: E
199
+ data: w,
200
+ isLoading: x,
201
+ isFetching: A,
202
+ error: I
220
203
  } = J({
221
- queryKey: ["form-record", a.meta._id, g],
204
+ queryKey: ["form-record", n.meta._id, f],
222
205
  queryFn: async () => {
223
- const w = await a.get(g);
224
- return ee(a.getFields(), w.toJSON());
206
+ const _ = await n.get(f);
207
+ return ee(n.getFields(), _.toJSON());
225
208
  },
226
- enabled: e === "update" && !!g,
209
+ enabled: o === "update" && !!f,
227
210
  staleTime: 0
228
211
  }), {
229
- data: d,
230
- isLoading: I,
231
- error: l
212
+ data: s,
213
+ isLoading: l,
214
+ error: r
232
215
  } = J({
233
- queryKey: ["form-draft", a.meta._id],
234
- queryFn: async () => y(a.meta._id).draftInteraction({}),
235
- enabled: e === "create",
216
+ queryKey: ["form-draft", n.meta._id],
217
+ queryFn: async () => y(n.meta._id).draftInteraction({}),
218
+ enabled: o === "create",
236
219
  staleTime: 1 / 0,
237
220
  gcTime: 0,
238
221
  retry: 1
239
- }), { data: i } = J({
240
- queryKey: ["form-schema", a.meta._id],
241
- queryFn: () => ie(a.meta._id),
222
+ }), { data: a } = J({
223
+ queryKey: ["form-schema", n.meta._id],
224
+ queryFn: () => ie(n.meta._id),
242
225
  staleTime: 30 * 60 * 1e3,
243
226
  gcTime: 60 * 60 * 1e3,
244
- enabled: F !== !1
227
+ enabled: i !== !1
245
228
  });
246
229
  k(() => {
247
- i != null && i.BDOBlob ? a.loadMetadata(i.BDOBlob) : i != null && i.MetaBlob && a.loadMetadata(i.MetaBlob);
248
- }, [i, a]);
230
+ a != null && a.BDOBlob ? n.loadMetadata(a.BDOBlob) : a != null && a.MetaBlob && n.loadMetadata(a.MetaBlob);
231
+ }, [a, n]);
249
232
  const t = te({
250
- mode: m,
251
- resolver: s,
252
- defaultValues: C
233
+ mode: c,
234
+ resolver: z,
235
+ defaultValues: b
253
236
  // NOTE: Don't use `values` prop — it continuously syncs and overrides
254
237
  // setValue() calls for unregistered fields (Image/File attachments).
255
238
  // Instead, we reset once when record arrives (see useEffect below).
256
- }), o = j(null);
239
+ }), d = j(null);
257
240
  k(() => {
258
- e === "update" && c && c !== o.current && (t.reset(c), o.current = c);
259
- }, [c, e, t]), k(() => {
260
- d != null && d._id && t.setValue("_id", d._id);
261
- }, [d, t]);
262
- const n = b(
263
- () => re(a, t),
264
- [a, t]
265
- ), r = a.getFields(), u = j(!1), f = b(
266
- () => Object.keys(r).filter((w) => r[w].readOnly),
267
- [r]
268
- ), N = K(
269
- async (w, V) => {
270
- if (e === "create" && (d != null && d._id))
271
- return y(a.meta._id).draftInteraction({
272
- _id: d._id,
273
- [w]: V
241
+ o === "update" && w && w !== d.current && (t.reset(w), d.current = w);
242
+ }, [w, o, t]), k(() => {
243
+ s != null && s._id && t.setValue("_id", s._id);
244
+ }, [s, t]);
245
+ const u = U(
246
+ () => re(n, t),
247
+ [n, t]
248
+ ), g = n.getFields(), P = j(!1), h = U(
249
+ () => Object.keys(g).filter((_) => g[_].readOnly),
250
+ [g]
251
+ ), m = K(
252
+ async (_, V) => {
253
+ if (o === "create" && (s != null && s._id))
254
+ return y(n.meta._id).draftInteraction({
255
+ _id: s._id,
256
+ [_]: V
274
257
  });
275
- if (e === "update" && g)
276
- return y(a.meta._id).update(g, {
277
- [w]: V
258
+ if (o === "update" && f)
259
+ return y(n.meta._id).update(f, {
260
+ [_]: V
278
261
  });
279
262
  },
280
- [e, d, g, a]
281
- ), O = b(
263
+ [o, s, f, n]
264
+ ), R = U(
282
265
  () => ae({
283
- apiFn: N,
284
- allFields: r,
285
- readonlyFieldNames: f,
266
+ apiFn: m,
267
+ allFields: g,
268
+ readonlyFieldNames: h,
286
269
  rhf: t,
287
- isComputingRef: u
270
+ isComputingRef: P
288
271
  }),
289
- [N, r, f, t]
290
- ), _ = m === "onChange" || m === "all", h = m === "onBlur" || m === "onTouched" || m === "all", H = b(
272
+ [m, g, h, t]
273
+ ), N = c === "onChange" || c === "all", q = c === "onBlur" || c === "onTouched" || c === "all", H = U(
291
274
  () => ne({
292
275
  rhf: t,
293
- allFields: r,
294
- syncField: O,
295
- syncOnBlur: h,
296
- syncOnChange: _
276
+ allFields: g,
277
+ syncField: R,
278
+ syncOnBlur: q,
279
+ syncOnChange: N
297
280
  }),
298
- [t, r, O, h, _]
299
- ), W = b(
281
+ [t, g, R, q, N]
282
+ ), W = U(
300
283
  () => se({
301
284
  control: t.control,
302
- syncField: O,
303
- syncOnBlur: h,
304
- syncOnChange: _
285
+ syncField: R,
286
+ syncOnBlur: q,
287
+ syncOnChange: N
305
288
  }),
306
- [t.control, O, h, _]
289
+ [t.control, R, q, N]
307
290
  ), X = K(
308
- (w, V) => t.handleSubmit(
309
- async (M, z) => {
291
+ (_, V) => t.handleSubmit(
292
+ async (B, E) => {
310
293
  try {
311
- const v = {}, P = t.getValues();
312
- if (e === "create")
313
- for (const [U, S] of Object.entries(r)) {
314
- if (S.readOnly) continue;
315
- const q = P[U] !== void 0 ? P[U] : M[U];
316
- q !== void 0 && (v[U] = $(S, q));
294
+ const S = {}, M = t.getValues();
295
+ if (o === "create")
296
+ for (const [O, F] of Object.entries(g)) {
297
+ if (F.readOnly) continue;
298
+ const D = M[O] !== void 0 ? M[O] : B[O];
299
+ D !== void 0 && (S[O] = $(F, D));
317
300
  }
318
301
  else {
319
- const U = t.formState.dirtyFields;
320
- for (const [S, q] of Object.entries(r)) {
321
- if (q.readOnly || !U[S]) continue;
322
- const Y = P[S] !== void 0 ? P[S] : M[S];
323
- v[S] = $(q, Y);
302
+ const O = t.formState.dirtyFields;
303
+ for (const [F, D] of Object.entries(g)) {
304
+ if (D.readOnly || !O[F]) continue;
305
+ const Y = M[F] !== void 0 ? M[F] : B[F];
306
+ S[F] = $(D, Y);
324
307
  }
325
308
  }
326
309
  let L;
327
- e === "create" ? (v._id = d == null ? void 0 : d._id, L = await y(a.meta._id).draft(v)) : L = await y(a.meta._id).update(g, v), w == null || w(L, z);
328
- } catch (v) {
329
- V == null || V(v, z);
310
+ o === "create" ? (S._id = s == null ? void 0 : s._id, L = await y(n.meta._id).draft(S)) : L = await y(n.meta._id).update(f, S), _ == null || _(L, E);
311
+ } catch (S) {
312
+ V == null || V(S, E);
330
313
  }
331
314
  },
332
- (M, z) => {
333
- V == null || V(M, z);
315
+ (B, E) => {
316
+ V == null || V(B, E);
334
317
  }
335
318
  ),
336
- [t, a, e, g, r, d]
319
+ [t, n, o, f, g, s]
337
320
  );
338
321
  return {
339
- item: n,
340
- bdo: a,
341
- operation: e,
342
- recordId: g,
322
+ item: u,
323
+ bdo: n,
324
+ operation: o,
325
+ recordId: f,
343
326
  register: H,
344
327
  handleSubmit: X,
345
328
  watch: t.watch,
@@ -355,16 +338,16 @@ function ye(D) {
355
338
  isSubmitting: t.formState.isSubmitting,
356
339
  isSubmitSuccessful: t.formState.isSubmitSuccessful,
357
340
  dirtyFields: t.formState.dirtyFields,
358
- isLoading: A || I,
359
- isFetching: B,
360
- loadError: E ?? l,
361
- draftId: d == null ? void 0 : d._id,
362
- isCreatingDraft: I
341
+ isLoading: x || l,
342
+ isFetching: A,
343
+ loadError: I ?? r,
344
+ draftId: s == null ? void 0 : s._id,
345
+ isCreatingDraft: l
363
346
  };
364
347
  }
365
348
  export {
366
349
  he as FormOperation,
367
350
  _e as InteractionMode,
368
- we as ValidationMode,
369
- ye as useBDOForm
351
+ Ve as ValidationMode,
352
+ fe as useBDOForm
370
353
  };