@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.
Files changed (105) hide show
  1. package/README.md +8 -16
  2. package/dist/{FileField-CZjS2uLh.js → FileField-BWrSHNRq.js} +3 -3
  3. package/dist/{FileField-DU4UWo_t.cjs → FileField-eDeuzln8.cjs} +1 -1
  4. package/dist/api.cjs +1 -1
  5. package/dist/api.mjs +1 -1
  6. package/dist/auth/authConfig.d.ts +1 -1
  7. package/dist/auth/types.d.ts +1 -1
  8. package/dist/auth/types.d.ts.map +1 -1
  9. package/dist/auth.cjs +1 -1
  10. package/dist/auth.mjs +1 -1
  11. package/dist/bdo/core/Item.d.ts +4 -0
  12. package/dist/bdo/core/Item.d.ts.map +1 -1
  13. package/dist/bdo/fields/ReferenceField.d.ts +1 -1
  14. package/dist/bdo/fields/ReferenceField.d.ts.map +1 -1
  15. package/dist/bdo/fields/SelectField.d.ts +1 -1
  16. package/dist/bdo/fields/SelectField.d.ts.map +1 -1
  17. package/dist/bdo/fields/UserField.d.ts +1 -1
  18. package/dist/bdo/fields/UserField.d.ts.map +1 -1
  19. package/dist/bdo.cjs +1 -1
  20. package/dist/bdo.mjs +62 -53
  21. package/dist/components/hooks/useActivityForm/types.d.ts +5 -4
  22. package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -1
  23. package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -1
  24. package/dist/components/hooks/useActivityTable/types.d.ts +4 -5
  25. package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -1
  26. package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -1
  27. package/dist/components/hooks/useBDOForm/createItemProxy.d.ts +3 -2
  28. package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -1
  29. package/dist/components/hooks/useBDOTable/types.d.ts +12 -20
  30. package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -1
  31. package/dist/components/hooks/useBDOTable/useBDOTable.d.ts +2 -2
  32. package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -1
  33. package/dist/{constants-Cyi942Yr.js → constants-ConHc1oS.js} +5 -5
  34. package/dist/constants-QX2RX-wu.cjs +1 -0
  35. package/dist/filter.cjs +1 -1
  36. package/dist/filter.mjs +1 -1
  37. package/dist/form.cjs +1 -1
  38. package/dist/form.mjs +243 -226
  39. package/dist/table.cjs +1 -1
  40. package/dist/table.mjs +16 -15
  41. package/dist/table.types.d.ts +1 -1
  42. package/dist/table.types.d.ts.map +1 -1
  43. package/dist/types/constants.d.ts +1 -1
  44. package/dist/workflow/Activity.d.ts +5 -8
  45. package/dist/workflow/Activity.d.ts.map +1 -1
  46. package/dist/workflow.cjs +1 -1
  47. package/dist/workflow.mjs +476 -461
  48. package/docs/api.md +95 -0
  49. package/docs/bdo.md +224 -0
  50. package/docs/gaps.md +360 -0
  51. package/docs/useActivityForm.md +393 -0
  52. package/docs/useActivityTable.md +418 -0
  53. package/docs/useBDOForm.md +498 -0
  54. package/docs/useBDOTable.md +284 -0
  55. package/docs/useFilter.md +188 -0
  56. package/docs/workflow.md +560 -0
  57. package/package.json +14 -15
  58. package/sdk/auth/authConfig.ts +1 -1
  59. package/sdk/auth/types.ts +1 -1
  60. package/sdk/bdo/core/Item.ts +10 -1
  61. package/sdk/bdo/fields/ReferenceField.ts +1 -1
  62. package/sdk/bdo/fields/SelectField.ts +1 -1
  63. package/sdk/bdo/fields/UserField.ts +1 -1
  64. package/sdk/components/hooks/useActivityForm/types.ts +6 -4
  65. package/sdk/components/hooks/useActivityForm/useActivityForm.ts +73 -10
  66. package/sdk/components/hooks/useActivityTable/types.ts +5 -4
  67. package/sdk/components/hooks/useActivityTable/useActivityTable.ts +8 -10
  68. package/sdk/components/hooks/useBDOForm/createItemProxy.ts +58 -17
  69. package/sdk/components/hooks/useBDOTable/types.ts +10 -20
  70. package/sdk/components/hooks/useBDOTable/useBDOTable.ts +8 -12
  71. package/sdk/table.types.ts +0 -2
  72. package/sdk/types/constants.ts +1 -1
  73. package/sdk/workflow/Activity.ts +7 -39
  74. package/dist/constants-DEmYwKfC.cjs +0 -1
  75. package/docs/README.md +0 -57
  76. package/docs/bdo/README.md +0 -161
  77. package/docs/bdo/api_reference.md +0 -281
  78. package/docs/examples/bdo/create-product.md +0 -69
  79. package/docs/examples/bdo/edit-product-dialog.md +0 -95
  80. package/docs/examples/bdo/filtered-product-table.md +0 -100
  81. package/docs/examples/bdo/product-listing.md +0 -73
  82. package/docs/examples/bdo/supplier-dropdown.md +0 -60
  83. package/docs/examples/fields/complex-fields.md +0 -248
  84. package/docs/examples/fields/primitive-fields.md +0 -217
  85. package/docs/examples/workflow/approve-leave-request.md +0 -76
  86. package/docs/examples/workflow/filtered-activity-table.md +0 -101
  87. package/docs/examples/workflow/my-pending-requests.md +0 -90
  88. package/docs/examples/workflow/start-new-workflow.md +0 -47
  89. package/docs/examples/workflow/submit-leave-request.md +0 -72
  90. package/docs/examples/workflow/workflow-progress.md +0 -49
  91. package/docs/fields/README.md +0 -141
  92. package/docs/fields/api_reference.md +0 -134
  93. package/docs/useActivityForm/README.md +0 -244
  94. package/docs/useActivityForm/api_reference.md +0 -279
  95. package/docs/useActivityTable/README.md +0 -263
  96. package/docs/useActivityTable/api_reference.md +0 -294
  97. package/docs/useBDOForm/README.md +0 -175
  98. package/docs/useBDOForm/api_reference.md +0 -244
  99. package/docs/useBDOTable/README.md +0 -242
  100. package/docs/useBDOTable/api_reference.md +0 -253
  101. package/docs/useFilter/README.md +0 -323
  102. package/docs/useFilter/api_reference.md +0 -228
  103. package/docs/workflow/README.md +0 -158
  104. package/docs/workflow/api_reference.md +0 -161
  105. /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 Ve } from "./constants-Cyi942Yr.js";
2
- import { useMemo as U, useEffect as k, useRef as j, useCallback as K } from "react";
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(v, n) {
9
- const f = v.getFields(), T = /* @__PURE__ */ new Map(), b = v.getBoId(), c = () => n.getValues("_id") || "draft";
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(C, e) {
18
+ get(F, e) {
12
19
  if (typeof e == "symbol")
13
20
  return;
14
21
  if (e === "_id")
15
- return n.getValues("_id");
22
+ return a.getValues("_id");
16
23
  if (e === "toJSON")
17
- return () => n.getValues();
24
+ return () => a.getValues();
18
25
  if (e === "validate")
19
- return () => n.trigger();
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 i = f[e], o = (i == null ? void 0 : i.meta) ?? {
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
- }, 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 }));
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 (!i.required && (s == null || s === "" || Array.isArray(s) && s.length === 0))
42
+ if (!s.required && (l == null || l === "" || Array.isArray(l) && l.length === 0))
34
43
  return { valid: !0, errors: [] };
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(
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
- s,
43
- n.getValues()
51
+ l,
52
+ a.getValues()
44
53
  );
45
- if (!a.valid) return a;
54
+ if (!o.valid) return o;
46
55
  }
47
56
  return { valid: !0, errors: [] };
48
- }, x = (s) => {
49
- const l = n.getValues(e);
50
- return l ?? s;
57
+ }, E = (l) => {
58
+ const i = a.getValues(e);
59
+ return i ?? l;
51
60
  };
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,
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: i == null ? void 0 : i.defaultValue,
61
- meta: o,
62
- get: s,
63
- getOrDefault: x,
64
- set: (r) => {
65
- n.setValue(e, r, {
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: w
81
+ validate: B
73
82
  };
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) }
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(d.UploadUrl.URL, {
94
+ await fetch(u.UploadUrl.URL, {
82
95
  method: "PUT",
83
- headers: { "Content-Type": d.ContentType },
84
- body: a
96
+ headers: { "Content-Type": u.ContentType },
97
+ body: n
85
98
  });
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
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 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, {
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": u[m].ContentType },
113
- body: h
125
+ headers: { "Content-Type": f[h].ContentType },
126
+ body: _
114
127
  }), {
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
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
- ), 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(
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
- t.filter((u) => u._id !== a),
141
+ r.filter((f) => f._id !== n),
129
142
  { shouldDirty: !0 }
130
143
  );
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);
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, l), l;
152
+ return T.set(e, i), i;
140
153
  }
141
- const A = () => {
142
- const s = n.getValues(e);
143
- return o.Type === "File" ? s ?? [] : s;
154
+ const d = () => {
155
+ const l = a.getValues(e);
156
+ return c.Type === "File" ? l ?? [] : l;
144
157
  }, I = {
145
- label: (i == null ? void 0 : i.label) ?? e,
146
- required: (i == null ? void 0 : i.required) ?? !1,
158
+ label: (s == null ? void 0 : s.label) ?? e,
159
+ required: (s == null ? void 0 : s.required) ?? !1,
147
160
  readOnly: !0,
148
- defaultValue: i == null ? void 0 : i.defaultValue,
149
- meta: o,
150
- get: A,
151
- getOrDefault: x,
152
- validate: w
161
+ defaultValue: s == null ? void 0 : s.defaultValue,
162
+ meta: c,
163
+ get: d,
164
+ getOrDefault: E,
165
+ validate: B
153
166
  };
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);
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(C, e) {
171
- return typeof e == "symbol" ? !1 : e === "_id" || e === "toJSON" || e === "validate" ? !0 : e in f;
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(C) {
174
- return [...Object.keys(f), "_id", "toJSON", "validate"];
190
+ ownKeys(F) {
191
+ return [...Object.keys(g), "_id", "toJSON", "validate"];
175
192
  },
176
- getOwnPropertyDescriptor(C, e) {
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 fe(v) {
202
+ function ye(D) {
186
203
  const {
187
- bdo: n,
188
- recordId: f,
204
+ bdo: a,
205
+ recordId: g,
189
206
  operation: T,
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]
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: w,
200
- isLoading: x,
201
- isFetching: A,
202
- error: I
216
+ data: c,
217
+ isLoading: A,
218
+ isFetching: B,
219
+ error: E
203
220
  } = J({
204
- queryKey: ["form-record", n.meta._id, f],
221
+ queryKey: ["form-record", a.meta._id, g],
205
222
  queryFn: async () => {
206
- const _ = await n.get(f);
207
- return ee(n.getFields(), _.toJSON());
223
+ const w = await a.get(g);
224
+ return ee(a.getFields(), w.toJSON());
208
225
  },
209
- enabled: o === "update" && !!f,
226
+ enabled: e === "update" && !!g,
210
227
  staleTime: 0
211
228
  }), {
212
- data: s,
213
- isLoading: l,
214
- error: r
229
+ data: d,
230
+ isLoading: I,
231
+ error: l
215
232
  } = J({
216
- queryKey: ["form-draft", n.meta._id],
217
- queryFn: async () => y(n.meta._id).draftInteraction({}),
218
- enabled: o === "create",
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: a } = J({
223
- queryKey: ["form-schema", n.meta._id],
224
- queryFn: () => ie(n.meta._id),
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: i !== !1
244
+ enabled: F !== !1
228
245
  });
229
246
  k(() => {
230
- a != null && a.BDOBlob ? n.loadMetadata(a.BDOBlob) : a != null && a.MetaBlob && n.loadMetadata(a.MetaBlob);
231
- }, [a, n]);
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: c,
234
- resolver: z,
235
- defaultValues: b
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
- }), d = j(null);
256
+ }), o = j(null);
240
257
  k(() => {
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
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 (o === "update" && f)
259
- return y(n.meta._id).update(f, {
260
- [_]: V
275
+ if (e === "update" && g)
276
+ return y(a.meta._id).update(g, {
277
+ [w]: V
261
278
  });
262
279
  },
263
- [o, s, f, n]
264
- ), R = U(
280
+ [e, d, g, a]
281
+ ), O = b(
265
282
  () => ae({
266
- apiFn: m,
267
- allFields: g,
268
- readonlyFieldNames: h,
283
+ apiFn: N,
284
+ allFields: r,
285
+ readonlyFieldNames: f,
269
286
  rhf: t,
270
- isComputingRef: P
287
+ isComputingRef: u
271
288
  }),
272
- [m, g, h, t]
273
- ), N = c === "onChange" || c === "all", q = c === "onBlur" || c === "onTouched" || c === "all", H = U(
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: g,
277
- syncField: R,
278
- syncOnBlur: q,
279
- syncOnChange: N
293
+ allFields: r,
294
+ syncField: O,
295
+ syncOnBlur: h,
296
+ syncOnChange: _
280
297
  }),
281
- [t, g, R, q, N]
282
- ), W = U(
298
+ [t, r, O, h, _]
299
+ ), W = b(
283
300
  () => se({
284
301
  control: t.control,
285
- syncField: R,
286
- syncOnBlur: q,
287
- syncOnChange: N
302
+ syncField: O,
303
+ syncOnBlur: h,
304
+ syncOnChange: _
288
305
  }),
289
- [t.control, R, q, N]
306
+ [t.control, O, h, _]
290
307
  ), X = K(
291
- (_, V) => t.handleSubmit(
292
- async (B, E) => {
308
+ (w, V) => t.handleSubmit(
309
+ async (M, z) => {
293
310
  try {
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));
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 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);
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
- 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);
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
- (B, E) => {
316
- V == null || V(B, E);
332
+ (M, z) => {
333
+ V == null || V(M, z);
317
334
  }
318
335
  ),
319
- [t, n, o, f, g, s]
336
+ [t, a, e, g, r, d]
320
337
  );
321
338
  return {
322
- item: u,
323
- bdo: n,
324
- operation: o,
325
- recordId: f,
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: x || l,
342
- isFetching: A,
343
- loadError: I ?? r,
344
- draftId: s == null ? void 0 : s._id,
345
- isCreatingDraft: l
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
- Ve as ValidationMode,
352
- fe as useBDOForm
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 a=require("./useTable-CeRklbdT.cjs"),e=require("./constants-DEmYwKfC.cjs");function u(r){const{bdo:t,...n}=r;return a.useTable({queryKey:["table",t.meta._id],listFn:async o=>({Data:await t.list(o)}),countFn:async o=>({Count:await t.count(o)}),...n})}exports.useTable=a.useTable;exports.ConditionOperator=e.ConditionOperator;exports.GroupOperator=e.GroupOperator;exports.RHSType=e.RHSType;exports.SortDirection=e.SortDirection;exports.TableDefaults=e.Defaults;exports.useBDOTable=u;
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 r } from "./useTable-DS0-WInw.js";
2
- import { C as c, G as l, R as p, S as b, D as y } from "./constants-Cyi942Yr.js";
3
- function n(e) {
4
- const { bdo: t, ...o } = e;
5
- return r({
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: async (a) => ({ Data: await t.list(a) }),
8
- countFn: async (a) => ({ Count: await t.count(a) }),
9
- ...o
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
- c as ConditionOperator,
14
- l as GroupOperator,
15
- p as RHSType,
16
- b as SortDirection,
17
- y as TableDefaults,
18
- n as useBDOTable,
19
- r as useTable
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
  };
@@ -1,3 +1,3 @@
1
1
  export type { UseTableOptionsType, UseTableReturnType, PaginationStateType, } from './components/hooks/useTable/types';
2
- export type { BDOTableSourceType, BDORowType, UseBDOTableOptionsType, UseBDOTableReturnType, } from './components/hooks/useBDOTable/types';
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,kBAAkB,EAClB,UAAU,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,sCAAsC,CAAC"}
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"}