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