@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.
- package/dist/{FileField-BWrSHNRq.js → FileField-CZjS2uLh.js} +3 -3
- package/dist/{FileField-eDeuzln8.cjs → FileField-DU4UWo_t.cjs} +1 -1
- package/dist/auth/authClient.d.ts.map +1 -1
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +101 -105
- package/dist/bdo/core/Item.d.ts +0 -4
- package/dist/bdo/core/Item.d.ts.map +1 -1
- package/dist/bdo/fields/ReferenceField.d.ts +1 -1
- package/dist/bdo/fields/ReferenceField.d.ts.map +1 -1
- package/dist/bdo/fields/SelectField.d.ts +1 -1
- package/dist/bdo/fields/SelectField.d.ts.map +1 -1
- package/dist/bdo/fields/UserField.d.ts +1 -1
- package/dist/bdo/fields/UserField.d.ts.map +1 -1
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.mjs +52 -61
- package/dist/components/hooks/useBDOForm/createItemProxy.d.ts +2 -3
- package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +226 -243
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.mjs +1 -1
- package/docs/README.md +6 -0
- package/docs/examples/fields/complex-fields.md +248 -0
- package/docs/examples/fields/primitive-fields.md +217 -0
- package/docs/fields/README.md +141 -0
- package/docs/fields/api_reference.md +134 -0
- package/docs/useActivityForm/README.md +4 -1
- package/docs/useBDOForm/README.md +4 -1
- package/package.json +1 -1
- package/sdk/auth/authClient.ts +15 -21
- package/sdk/bdo/core/Item.ts +1 -10
- package/sdk/bdo/fields/ReferenceField.ts +1 -1
- package/sdk/bdo/fields/SelectField.ts +1 -1
- package/sdk/bdo/fields/UserField.ts +1 -1
- 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
|
|
2
|
-
import { useMemo as
|
|
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(
|
|
9
|
-
const
|
|
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(
|
|
11
|
+
get(C, e) {
|
|
19
12
|
if (typeof e == "symbol")
|
|
20
13
|
return;
|
|
21
14
|
if (e === "_id")
|
|
22
|
-
return
|
|
15
|
+
return n.getValues("_id");
|
|
23
16
|
if (e === "toJSON")
|
|
24
|
-
return () =>
|
|
17
|
+
return () => n.getValues();
|
|
25
18
|
if (e === "validate")
|
|
26
|
-
return () =>
|
|
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
|
|
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
|
-
},
|
|
36
|
-
if (!
|
|
37
|
-
let
|
|
38
|
-
if ("integerPart" in
|
|
39
|
-
const
|
|
40
|
-
isNaN(
|
|
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 (!
|
|
33
|
+
if (!i.required && (s == null || s === "" || Array.isArray(s) && s.length === 0))
|
|
43
34
|
return { valid: !0, errors: [] };
|
|
44
|
-
const
|
|
45
|
-
if (!
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
48
|
-
if (
|
|
49
|
-
const
|
|
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
|
-
|
|
52
|
-
|
|
42
|
+
s,
|
|
43
|
+
n.getValues()
|
|
53
44
|
);
|
|
54
|
-
if (!
|
|
45
|
+
if (!a.valid) return a;
|
|
55
46
|
}
|
|
56
47
|
return { valid: !0, errors: [] };
|
|
57
|
-
},
|
|
58
|
-
const
|
|
59
|
-
return
|
|
48
|
+
}, x = (s) => {
|
|
49
|
+
const l = n.getValues(e);
|
|
50
|
+
return l ?? s;
|
|
60
51
|
};
|
|
61
|
-
if (!
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
return
|
|
65
|
-
},
|
|
66
|
-
label: (
|
|
67
|
-
required: (
|
|
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:
|
|
70
|
-
meta:
|
|
71
|
-
get:
|
|
72
|
-
getOrDefault:
|
|
73
|
-
set: (
|
|
74
|
-
|
|
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:
|
|
72
|
+
validate: w
|
|
82
73
|
};
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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(
|
|
81
|
+
await fetch(d.UploadUrl.URL, {
|
|
95
82
|
method: "PUT",
|
|
96
|
-
headers: { "Content-Type":
|
|
97
|
-
body:
|
|
83
|
+
headers: { "Content-Type": d.ContentType },
|
|
84
|
+
body: a
|
|
98
85
|
});
|
|
99
|
-
const
|
|
100
|
-
_id:
|
|
101
|
-
_name:
|
|
102
|
-
FileName:
|
|
103
|
-
FileExtension:
|
|
104
|
-
Size:
|
|
105
|
-
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
|
|
108
|
-
},
|
|
109
|
-
const
|
|
110
|
-
if (!(
|
|
111
|
-
await y(
|
|
112
|
-
},
|
|
113
|
-
const
|
|
114
|
-
if (!(
|
|
115
|
-
return y(
|
|
116
|
-
}) : (
|
|
117
|
-
for (const
|
|
118
|
-
const
|
|
119
|
-
FileName:
|
|
120
|
-
Size:
|
|
121
|
-
FileExtension: Q(
|
|
122
|
-
})),
|
|
123
|
-
|
|
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":
|
|
126
|
-
body:
|
|
112
|
+
headers: { "Content-Type": u[m].ContentType },
|
|
113
|
+
body: h
|
|
127
114
|
}), {
|
|
128
|
-
_id:
|
|
129
|
-
_name:
|
|
130
|
-
FileName:
|
|
131
|
-
FileExtension:
|
|
132
|
-
Size:
|
|
133
|
-
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
|
-
),
|
|
136
|
-
return
|
|
137
|
-
},
|
|
138
|
-
const
|
|
139
|
-
await y(
|
|
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
|
-
|
|
128
|
+
t.filter((u) => u._id !== a),
|
|
142
129
|
{ shouldDirty: !0 }
|
|
143
130
|
);
|
|
144
|
-
},
|
|
145
|
-
const
|
|
146
|
-
return y(
|
|
147
|
-
},
|
|
148
|
-
const
|
|
149
|
-
return y(
|
|
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,
|
|
139
|
+
return T.set(e, l), l;
|
|
153
140
|
}
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
return
|
|
141
|
+
const A = () => {
|
|
142
|
+
const s = n.getValues(e);
|
|
143
|
+
return o.Type === "File" ? s ?? [] : s;
|
|
157
144
|
}, I = {
|
|
158
|
-
label: (
|
|
159
|
-
required: (
|
|
145
|
+
label: (i == null ? void 0 : i.label) ?? e,
|
|
146
|
+
required: (i == null ? void 0 : i.required) ?? !1,
|
|
160
147
|
readOnly: !0,
|
|
161
|
-
defaultValue:
|
|
162
|
-
meta:
|
|
163
|
-
get:
|
|
164
|
-
getOrDefault:
|
|
165
|
-
validate:
|
|
148
|
+
defaultValue: i == null ? void 0 : i.defaultValue,
|
|
149
|
+
meta: o,
|
|
150
|
+
get: A,
|
|
151
|
+
getOrDefault: x,
|
|
152
|
+
validate: w
|
|
166
153
|
};
|
|
167
|
-
if (
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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(
|
|
188
|
-
return typeof e == "symbol" ? !1 : e === "_id" || e === "toJSON" || e === "validate"
|
|
170
|
+
has(C, e) {
|
|
171
|
+
return typeof e == "symbol" ? !1 : e === "_id" || e === "toJSON" || e === "validate" ? !0 : e in f;
|
|
189
172
|
},
|
|
190
|
-
ownKeys(
|
|
191
|
-
return [...Object.keys(
|
|
173
|
+
ownKeys(C) {
|
|
174
|
+
return [...Object.keys(f), "_id", "toJSON", "validate"];
|
|
192
175
|
},
|
|
193
|
-
getOwnPropertyDescriptor(
|
|
176
|
+
getOwnPropertyDescriptor(C, e) {
|
|
194
177
|
if (typeof e != "symbol")
|
|
195
178
|
return {
|
|
196
179
|
configurable: !0,
|
|
197
|
-
enumerable: e !== "toJSON" && e !== "validate"
|
|
180
|
+
enumerable: e !== "toJSON" && e !== "validate"
|
|
198
181
|
};
|
|
199
182
|
}
|
|
200
183
|
});
|
|
201
184
|
}
|
|
202
|
-
function
|
|
185
|
+
function fe(v) {
|
|
203
186
|
const {
|
|
204
|
-
bdo:
|
|
205
|
-
recordId:
|
|
187
|
+
bdo: n,
|
|
188
|
+
recordId: f,
|
|
206
189
|
operation: T,
|
|
207
|
-
defaultValues:
|
|
208
|
-
mode:
|
|
209
|
-
enableDraft:
|
|
210
|
-
enableConstraintValidation:
|
|
211
|
-
enableExpressionValidation:
|
|
212
|
-
} =
|
|
213
|
-
() => p(
|
|
214
|
-
[
|
|
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:
|
|
217
|
-
isLoading:
|
|
218
|
-
isFetching:
|
|
219
|
-
error:
|
|
199
|
+
data: w,
|
|
200
|
+
isLoading: x,
|
|
201
|
+
isFetching: A,
|
|
202
|
+
error: I
|
|
220
203
|
} = J({
|
|
221
|
-
queryKey: ["form-record",
|
|
204
|
+
queryKey: ["form-record", n.meta._id, f],
|
|
222
205
|
queryFn: async () => {
|
|
223
|
-
const
|
|
224
|
-
return ee(
|
|
206
|
+
const _ = await n.get(f);
|
|
207
|
+
return ee(n.getFields(), _.toJSON());
|
|
225
208
|
},
|
|
226
|
-
enabled:
|
|
209
|
+
enabled: o === "update" && !!f,
|
|
227
210
|
staleTime: 0
|
|
228
211
|
}), {
|
|
229
|
-
data:
|
|
230
|
-
isLoading:
|
|
231
|
-
error:
|
|
212
|
+
data: s,
|
|
213
|
+
isLoading: l,
|
|
214
|
+
error: r
|
|
232
215
|
} = J({
|
|
233
|
-
queryKey: ["form-draft",
|
|
234
|
-
queryFn: async () => y(
|
|
235
|
-
enabled:
|
|
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:
|
|
240
|
-
queryKey: ["form-schema",
|
|
241
|
-
queryFn: () => ie(
|
|
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:
|
|
227
|
+
enabled: i !== !1
|
|
245
228
|
});
|
|
246
229
|
k(() => {
|
|
247
|
-
|
|
248
|
-
}, [
|
|
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:
|
|
251
|
-
resolver:
|
|
252
|
-
defaultValues:
|
|
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
|
-
}),
|
|
239
|
+
}), d = j(null);
|
|
257
240
|
k(() => {
|
|
258
|
-
|
|
259
|
-
}, [
|
|
260
|
-
|
|
261
|
-
}, [
|
|
262
|
-
const
|
|
263
|
-
() => re(
|
|
264
|
-
[
|
|
265
|
-
),
|
|
266
|
-
() => Object.keys(
|
|
267
|
-
[
|
|
268
|
-
),
|
|
269
|
-
async (
|
|
270
|
-
if (
|
|
271
|
-
return y(
|
|
272
|
-
_id:
|
|
273
|
-
[
|
|
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 (
|
|
276
|
-
return y(
|
|
277
|
-
[
|
|
258
|
+
if (o === "update" && f)
|
|
259
|
+
return y(n.meta._id).update(f, {
|
|
260
|
+
[_]: V
|
|
278
261
|
});
|
|
279
262
|
},
|
|
280
|
-
[
|
|
281
|
-
),
|
|
263
|
+
[o, s, f, n]
|
|
264
|
+
), R = U(
|
|
282
265
|
() => ae({
|
|
283
|
-
apiFn:
|
|
284
|
-
allFields:
|
|
285
|
-
readonlyFieldNames:
|
|
266
|
+
apiFn: m,
|
|
267
|
+
allFields: g,
|
|
268
|
+
readonlyFieldNames: h,
|
|
286
269
|
rhf: t,
|
|
287
|
-
isComputingRef:
|
|
270
|
+
isComputingRef: P
|
|
288
271
|
}),
|
|
289
|
-
[
|
|
290
|
-
),
|
|
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:
|
|
294
|
-
syncField:
|
|
295
|
-
syncOnBlur:
|
|
296
|
-
syncOnChange:
|
|
276
|
+
allFields: g,
|
|
277
|
+
syncField: R,
|
|
278
|
+
syncOnBlur: q,
|
|
279
|
+
syncOnChange: N
|
|
297
280
|
}),
|
|
298
|
-
[t,
|
|
299
|
-
), W =
|
|
281
|
+
[t, g, R, q, N]
|
|
282
|
+
), W = U(
|
|
300
283
|
() => se({
|
|
301
284
|
control: t.control,
|
|
302
|
-
syncField:
|
|
303
|
-
syncOnBlur:
|
|
304
|
-
syncOnChange:
|
|
285
|
+
syncField: R,
|
|
286
|
+
syncOnBlur: q,
|
|
287
|
+
syncOnChange: N
|
|
305
288
|
}),
|
|
306
|
-
[t.control,
|
|
289
|
+
[t.control, R, q, N]
|
|
307
290
|
), X = K(
|
|
308
|
-
(
|
|
309
|
-
async (
|
|
291
|
+
(_, V) => t.handleSubmit(
|
|
292
|
+
async (B, E) => {
|
|
310
293
|
try {
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
313
|
-
for (const [
|
|
314
|
-
if (
|
|
315
|
-
const
|
|
316
|
-
|
|
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
|
|
320
|
-
for (const [
|
|
321
|
-
if (
|
|
322
|
-
const Y =
|
|
323
|
-
|
|
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
|
-
|
|
328
|
-
} catch (
|
|
329
|
-
V == null || V(
|
|
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
|
-
(
|
|
333
|
-
V == null || V(
|
|
315
|
+
(B, E) => {
|
|
316
|
+
V == null || V(B, E);
|
|
334
317
|
}
|
|
335
318
|
),
|
|
336
|
-
[t,
|
|
319
|
+
[t, n, o, f, g, s]
|
|
337
320
|
);
|
|
338
321
|
return {
|
|
339
|
-
item:
|
|
340
|
-
bdo:
|
|
341
|
-
operation:
|
|
342
|
-
recordId:
|
|
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:
|
|
359
|
-
isFetching:
|
|
360
|
-
loadError:
|
|
361
|
-
draftId:
|
|
362
|
-
isCreatingDraft:
|
|
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
|
-
|
|
369
|
-
|
|
351
|
+
Ve as ValidationMode,
|
|
352
|
+
fe as useBDOForm
|
|
370
353
|
};
|