@ram_28/kf-ai-sdk 2.0.16 → 2.0.18

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 +16 -8
  2. package/dist/{FileField-BWrSHNRq.js → FileField-CZjS2uLh.js} +3 -3
  3. package/dist/{FileField-eDeuzln8.cjs → FileField-DU4UWo_t.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 +0 -4
  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 +53 -62
  21. package/dist/components/hooks/useActivityForm/types.d.ts +4 -5
  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 +5 -4
  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 +2 -3
  28. package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -1
  29. package/dist/components/hooks/useBDOTable/types.d.ts +20 -12
  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-ConHc1oS.js → constants-Cyi942Yr.js} +5 -5
  34. package/dist/constants-DEmYwKfC.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 +226 -243
  39. package/dist/table.cjs +1 -1
  40. package/dist/table.mjs +15 -16
  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 +8 -5
  45. package/dist/workflow/Activity.d.ts.map +1 -1
  46. package/dist/workflow.cjs +1 -1
  47. package/dist/workflow.mjs +461 -476
  48. package/docs/README.md +57 -0
  49. package/docs/bdo/README.md +161 -0
  50. package/docs/bdo/api_reference.md +281 -0
  51. package/docs/examples/bdo/create-product.md +69 -0
  52. package/docs/examples/bdo/edit-product-dialog.md +95 -0
  53. package/docs/examples/bdo/filtered-product-table.md +100 -0
  54. package/docs/examples/bdo/product-listing.md +73 -0
  55. package/docs/examples/bdo/supplier-dropdown.md +60 -0
  56. package/docs/examples/fields/complex-fields.md +248 -0
  57. package/docs/examples/fields/primitive-fields.md +217 -0
  58. package/docs/examples/workflow/approve-leave-request.md +76 -0
  59. package/docs/examples/workflow/filtered-activity-table.md +101 -0
  60. package/docs/examples/workflow/my-pending-requests.md +90 -0
  61. package/docs/examples/workflow/start-new-workflow.md +47 -0
  62. package/docs/examples/workflow/submit-leave-request.md +72 -0
  63. package/docs/examples/workflow/workflow-progress.md +49 -0
  64. package/docs/fields/README.md +141 -0
  65. package/docs/fields/api_reference.md +134 -0
  66. package/docs/useActivityForm/README.md +244 -0
  67. package/docs/useActivityForm/api_reference.md +279 -0
  68. package/docs/useActivityTable/README.md +263 -0
  69. package/docs/useActivityTable/api_reference.md +294 -0
  70. package/docs/useBDOForm/README.md +175 -0
  71. package/docs/useBDOForm/api_reference.md +244 -0
  72. package/docs/useBDOTable/README.md +242 -0
  73. package/docs/useBDOTable/api_reference.md +253 -0
  74. package/docs/useFilter/README.md +323 -0
  75. package/docs/useFilter/api_reference.md +228 -0
  76. package/docs/workflow/README.md +158 -0
  77. package/docs/workflow/api_reference.md +161 -0
  78. package/package.json +1 -1
  79. package/sdk/auth/authConfig.ts +1 -1
  80. package/sdk/auth/types.ts +1 -1
  81. package/sdk/bdo/core/Item.ts +1 -10
  82. package/sdk/bdo/fields/ReferenceField.ts +1 -1
  83. package/sdk/bdo/fields/SelectField.ts +1 -1
  84. package/sdk/bdo/fields/UserField.ts +1 -1
  85. package/sdk/components/hooks/useActivityForm/types.ts +4 -6
  86. package/sdk/components/hooks/useActivityForm/useActivityForm.ts +10 -73
  87. package/sdk/components/hooks/useActivityTable/types.ts +4 -5
  88. package/sdk/components/hooks/useActivityTable/useActivityTable.ts +10 -8
  89. package/sdk/components/hooks/useBDOForm/createItemProxy.ts +17 -58
  90. package/sdk/components/hooks/useBDOTable/types.ts +20 -10
  91. package/sdk/components/hooks/useBDOTable/useBDOTable.ts +12 -8
  92. package/sdk/table.types.ts +2 -0
  93. package/sdk/types/constants.ts +1 -1
  94. package/sdk/workflow/Activity.ts +39 -7
  95. package/dist/constants-QX2RX-wu.cjs +0 -1
  96. package/docs/api.md +0 -95
  97. package/docs/bdo.md +0 -224
  98. package/docs/gaps.md +0 -360
  99. package/docs/useActivityForm.md +0 -393
  100. package/docs/useActivityTable.md +0 -418
  101. package/docs/useBDOForm.md +0 -376
  102. package/docs/useBDOTable.md +0 -284
  103. package/docs/useFilter.md +0 -188
  104. package/docs/workflow.md +0 -560
  105. /package/docs/{useAuth.md → useAuth/README.md} +0 -0
package/dist/form.mjs CHANGED
@@ -1,345 +1,328 @@
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";
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
  };
package/dist/table.cjs CHANGED
@@ -1 +1 @@
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;
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;
package/dist/table.mjs CHANGED
@@ -1,21 +1,20 @@
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({
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({
7
6
  queryKey: ["table", t.meta._id],
8
- listFn: (e) => a(t.meta._id).list(e),
9
- countFn: (e) => a(t.meta._id).count(e),
10
- ...r
7
+ listFn: async (a) => ({ Data: await t.list(a) }),
8
+ countFn: async (a) => ({ Count: await t.count(a) }),
9
+ ...o
11
10
  });
12
11
  }
13
12
  export {
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
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
21
20
  };
@@ -1,3 +1,3 @@
1
1
  export type { UseTableOptionsType, UseTableReturnType, PaginationStateType, } from './components/hooks/useTable/types';
2
- export type { UseBDOTableOptionsType, UseBDOTableReturnType, } from './components/hooks/useBDOTable/types';
2
+ export type { BDOTableSourceType, BDORowType, 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,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,kBAAkB,EAClB,UAAU,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,sCAAsC,CAAC"}