@ram_28/kf-ai-sdk 2.0.4 → 2.0.6

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 (66) hide show
  1. package/dist/api.mjs +1 -1
  2. package/dist/auth.mjs +1 -1
  3. package/dist/bdo/core/Item.d.ts.map +1 -1
  4. package/dist/bdo/core/types.d.ts +1 -0
  5. package/dist/bdo/core/types.d.ts.map +1 -1
  6. package/dist/bdo.cjs +1 -1
  7. package/dist/bdo.mjs +91 -86
  8. package/dist/components/hooks/useForm/createItemProxy.d.ts.map +1 -1
  9. package/dist/components/hooks/useForm/index.d.ts +1 -1
  10. package/dist/components/hooks/useForm/index.d.ts.map +1 -1
  11. package/dist/components/hooks/useForm/types.d.ts +6 -16
  12. package/dist/components/hooks/useForm/types.d.ts.map +1 -1
  13. package/dist/components/hooks/useForm/useForm.d.ts +0 -1
  14. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
  15. package/dist/components/hooks/useTable/types.d.ts +2 -2
  16. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
  17. package/dist/{constants-BQrBcCON.js → constants-CYJih7y4.js} +2 -2
  18. package/dist/filter.mjs +1 -1
  19. package/dist/form.cjs +1 -1
  20. package/dist/form.mjs +158 -283
  21. package/dist/form.types.d.ts +1 -1
  22. package/dist/form.types.d.ts.map +1 -1
  23. package/dist/table.cjs +1 -1
  24. package/dist/table.mjs +65 -65
  25. package/dist/types/constants.d.ts +11 -11
  26. package/dist/types/constants.d.ts.map +1 -1
  27. package/dist/utils/api/buildListOptions.d.ts +1 -1
  28. package/dist/utils/api/buildListOptions.d.ts.map +1 -1
  29. package/dist/workflow/Activity.d.ts +14 -5
  30. package/dist/workflow/Activity.d.ts.map +1 -1
  31. package/dist/workflow/ActivityInstance.d.ts +1 -1
  32. package/dist/workflow/ActivityInstance.d.ts.map +1 -1
  33. package/dist/workflow/client.d.ts +14 -4
  34. package/dist/workflow/client.d.ts.map +1 -1
  35. package/dist/workflow/components/useActivityForm/createActivityItemProxy.d.ts.map +1 -1
  36. package/dist/workflow/types.d.ts +26 -9
  37. package/dist/workflow/types.d.ts.map +1 -1
  38. package/dist/workflow.cjs +1 -1
  39. package/dist/workflow.mjs +296 -240
  40. package/docs/bdo.md +63 -0
  41. package/docs/useAuth.md +27 -0
  42. package/docs/useFilter.md +67 -0
  43. package/docs/useForm.md +59 -0
  44. package/docs/useTable.md +106 -13
  45. package/docs/workflow.md +93 -49
  46. package/package.json +2 -2
  47. package/sdk/bdo/core/Item.ts +8 -0
  48. package/sdk/bdo/core/types.ts +1 -0
  49. package/sdk/components/hooks/useForm/createItemProxy.ts +8 -0
  50. package/sdk/components/hooks/useForm/index.ts +0 -1
  51. package/sdk/components/hooks/useForm/types.ts +7 -18
  52. package/sdk/components/hooks/useForm/useForm.ts +23 -109
  53. package/sdk/components/hooks/useTable/types.ts +2 -2
  54. package/sdk/components/hooks/useTable/useTable.llm.txt +7 -7
  55. package/sdk/components/hooks/useTable/useTable.ts +9 -8
  56. package/sdk/form.types.ts +0 -1
  57. package/sdk/types/constants.ts +11 -11
  58. package/sdk/utils/api/buildListOptions.ts +2 -3
  59. package/sdk/workflow/Activity.ts +31 -10
  60. package/sdk/workflow/ActivityInstance.ts +1 -1
  61. package/sdk/workflow/client.ts +73 -10
  62. package/sdk/workflow/components/useActivityForm/createActivityItemProxy.ts +4 -0
  63. package/sdk/workflow/types.ts +22 -9
  64. package/dist/components/hooks/useForm/useDraftInteraction.d.ts +0 -26
  65. package/dist/components/hooks/useForm/useDraftInteraction.d.ts.map +0 -1
  66. package/sdk/components/hooks/useForm/useDraftInteraction.ts +0 -251
package/dist/form.mjs CHANGED
@@ -1,65 +1,65 @@
1
- import { F as it, I as st, V as lt } from "./constants-BQrBcCON.js";
2
- import { useState as E, useRef as N, useEffect as P, useCallback as j, useMemo as z } from "react";
3
- import { u as U } from "./index.esm-Cj63v5ny.js";
4
- import { useQuery as K } from "@tanstack/react-query";
5
- import { g as G } from "./metadata-CJuFxytC.js";
6
- function L(i, e) {
7
- const n = [];
8
- if (i.required && (e == null || e === ""))
9
- return n.push(`${i.label} is required`), { valid: !1, errors: n };
1
+ import { F as H, I as U, V as W } from "./constants-CYJih7y4.js";
2
+ import { useMemo as q, useEffect as T, useCallback as M } from "react";
3
+ import { u as j } from "./index.esm-Cj63v5ny.js";
4
+ import { useQuery as w } from "@tanstack/react-query";
5
+ import { g as C } from "./metadata-CJuFxytC.js";
6
+ function $(s, e) {
7
+ const r = [];
8
+ if (s.required && (e == null || e === ""))
9
+ return r.push(`${s.label} is required`), { valid: !1, errors: r };
10
10
  if (e == null || e === "")
11
11
  return { valid: !0, errors: [] };
12
- if ("length" in i && typeof i.length == "number" && typeof e == "string" && e.length > i.length && n.push(`${i.label} must be at most ${i.length} characters`), "integerPart" in i && typeof e == "number") {
13
- const g = Math.floor(Math.abs(e)), c = i.integerPart ?? 9;
14
- g.toString().length > c && n.push(`${i.label} integer part must be at most ${c} digits`);
15
- const t = i.fractionPart;
16
- t !== void 0 && (e.toString().split(".")[1] ?? "").length > t && n.push(`${i.label} can have at most ${t} decimal places`);
12
+ if ("length" in s && typeof s.length == "number" && typeof e == "string" && e.length > s.length && r.push(`${s.label} must be at most ${s.length} characters`), "integerPart" in s && typeof e == "number") {
13
+ const o = Math.floor(Math.abs(e)), c = s.integerPart ?? 9;
14
+ o.toString().length > c && r.push(`${s.label} integer part must be at most ${c} digits`);
15
+ const t = s.fractionPart;
16
+ t !== void 0 && (e.toString().split(".")[1] ?? "").length > t && r.push(`${s.label} can have at most ${t} decimal places`);
17
17
  }
18
- return n.length > 0 ? { valid: !1, errors: n } : { valid: !0, errors: [] };
18
+ return r.length > 0 ? { valid: !1, errors: r } : { valid: !0, errors: [] };
19
19
  }
20
- function H(i, e) {
21
- return async (n, g, c) => {
22
- var R;
23
- const t = {}, r = i.getFields(), V = (c == null ? void 0 : c.names) ?? Object.keys(r);
24
- for (const u of V) {
25
- if (u === "_id" || (R = r[u]) != null && R.readOnly) continue;
26
- const I = r[u];
27
- if (!I) continue;
28
- const s = n[u], l = I.validate(s);
29
- if (!l.valid && l.errors.length > 0) {
30
- t[u] = {
20
+ function J(s, e) {
21
+ return async (r, o, c) => {
22
+ var b;
23
+ const t = {}, a = s.getFields(), y = (c == null ? void 0 : c.names) ?? Object.keys(a);
24
+ for (const n of y) {
25
+ if (n === "_id" || (b = a[n]) != null && b.readOnly) continue;
26
+ const d = a[n];
27
+ if (!d) continue;
28
+ const f = r[n], u = d.validate(f);
29
+ if (!u.valid && u.errors.length > 0) {
30
+ t[n] = {
31
31
  type: "validate",
32
- message: l.errors[0] || `${u} is invalid`
32
+ message: u.errors[0] || `${n} is invalid`
33
33
  };
34
34
  continue;
35
35
  }
36
36
  if ((e == null ? void 0 : e.enableConstraintValidation) !== !1) {
37
- const o = L(I, s);
38
- if (!o.valid && o.errors.length > 0) {
39
- t[u] = {
37
+ const l = $(d, f);
38
+ if (!l.valid && l.errors.length > 0) {
39
+ t[n] = {
40
40
  type: "constraint",
41
- message: o.errors[0]
41
+ message: l.errors[0]
42
42
  };
43
43
  continue;
44
44
  }
45
45
  }
46
- if (i.hasMetadata()) {
47
- const o = i.validateFieldExpression(
48
- u,
49
- s,
50
- n
46
+ if (s.hasMetadata()) {
47
+ const l = s.validateFieldExpression(
48
+ n,
49
+ f,
50
+ r
51
51
  );
52
- !o.valid && o.errors.length > 0 && (t[u] = {
52
+ !l.valid && l.errors.length > 0 && (t[n] = {
53
53
  type: "validate",
54
- message: o.errors[0]
54
+ message: l.errors[0]
55
55
  });
56
56
  }
57
57
  }
58
- return Object.keys(t).length === 0 ? { values: n, errors: {} } : { values: {}, errors: t };
58
+ return Object.keys(t).length === 0 ? { values: r, errors: {} } : { values: {}, errors: t };
59
59
  };
60
60
  }
61
- function W(i, e) {
62
- const n = i.getFields(), g = /* @__PURE__ */ new Map();
61
+ function I(s, e) {
62
+ const r = s.getFields(), o = /* @__PURE__ */ new Map();
63
63
  return new Proxy({}, {
64
64
  get(c, t) {
65
65
  if (typeof t == "symbol")
@@ -70,36 +70,40 @@ function W(i, e) {
70
70
  return () => e.getValues();
71
71
  if (t === "validate")
72
72
  return () => e.trigger();
73
- if (g.has(t))
74
- return g.get(t);
75
- const r = n[t], V = (r == null ? void 0 : r.meta) ?? {
73
+ if (o.has(t))
74
+ return o.get(t);
75
+ const a = r[t], y = (a == null ? void 0 : a.meta) ?? {
76
76
  _id: t,
77
77
  Name: t,
78
78
  Type: "String"
79
- }, R = (r == null ? void 0 : r.readOnly) ?? !1, u = () => {
80
- if (!r) return { valid: !0, errors: [] };
81
- const s = e.getValues(t), l = r.validate(s);
79
+ }, b = (a == null ? void 0 : a.readOnly) ?? !1, n = () => {
80
+ if (!a) return { valid: !0, errors: [] };
81
+ const u = e.getValues(t), l = a.validate(u);
82
82
  if (!l.valid) return l;
83
- const o = L(r, s);
84
- if (!o.valid) return o;
85
- if (i.hasMetadata()) {
86
- const v = i.validateFieldExpression(
83
+ const R = $(a, u);
84
+ if (!R.valid) return R;
85
+ if (s.hasMetadata()) {
86
+ const g = s.validateFieldExpression(
87
87
  t,
88
- s,
88
+ u,
89
89
  e.getValues()
90
90
  );
91
- if (!v.valid) return v;
91
+ if (!g.valid) return g;
92
92
  }
93
93
  return { valid: !0, errors: [] };
94
+ }, d = (u) => {
95
+ const l = e.getValues(t);
96
+ return l ?? u;
94
97
  };
95
- if (!R) {
96
- const s = {
97
- label: (r == null ? void 0 : r.label) ?? t,
98
- required: (r == null ? void 0 : r.required) ?? !1,
98
+ if (!b) {
99
+ const u = {
100
+ label: (a == null ? void 0 : a.label) ?? t,
101
+ required: (a == null ? void 0 : a.required) ?? !1,
99
102
  readOnly: !1,
100
- defaultValue: r == null ? void 0 : r.defaultValue,
101
- meta: V,
103
+ defaultValue: a == null ? void 0 : a.defaultValue,
104
+ meta: y,
102
105
  get: () => e.getValues(t),
106
+ getOrDefault: d,
103
107
  set: (l) => {
104
108
  e.setValue(t, l, {
105
109
  shouldDirty: !0,
@@ -108,26 +112,27 @@ function W(i, e) {
108
112
  // Let mode control validation timing
109
113
  });
110
114
  },
111
- validate: u
115
+ validate: n
112
116
  };
113
- return g.set(t, s), s;
117
+ return o.set(t, u), u;
114
118
  }
115
- const I = {
116
- label: (r == null ? void 0 : r.label) ?? t,
117
- required: (r == null ? void 0 : r.required) ?? !1,
119
+ const f = {
120
+ label: (a == null ? void 0 : a.label) ?? t,
121
+ required: (a == null ? void 0 : a.required) ?? !1,
118
122
  readOnly: !0,
119
- defaultValue: r == null ? void 0 : r.defaultValue,
120
- meta: V,
123
+ defaultValue: a == null ? void 0 : a.defaultValue,
124
+ meta: y,
121
125
  get: () => e.getValues(t),
122
- validate: u
126
+ getOrDefault: d,
127
+ validate: n
123
128
  };
124
- return g.set(t, I), I;
129
+ return o.set(t, f), f;
125
130
  },
126
131
  has(c, t) {
127
- return typeof t == "symbol" ? !1 : t === "_id" || t === "toJSON" || t === "validate" ? !0 : t in n;
132
+ return typeof t == "symbol" ? !1 : t === "_id" || t === "toJSON" || t === "validate" ? !0 : t in r;
128
133
  },
129
134
  ownKeys(c) {
130
- return [...Object.keys(n), "_id", "toJSON", "validate"];
135
+ return [...Object.keys(r), "_id", "toJSON", "validate"];
131
136
  },
132
137
  getOwnPropertyDescriptor(c, t) {
133
138
  if (typeof t != "symbol")
@@ -138,258 +143,128 @@ function W(i, e) {
138
143
  }
139
144
  });
140
145
  }
141
- const X = 300;
142
- function Y(i) {
143
- const { bdo: e, form: n, mode: g, fields: c, enabled: t } = i, [r, V] = E(void 0), [R, u] = E(!1), [I, s] = E(!1), [l, o] = E(null), v = N(0), q = N(!1), C = N(null), $ = N(null);
144
- P(() => {
145
- if (!t) return;
146
- let d = !1;
147
- u(!0);
148
- const D = new AbortController();
149
- return $.current = D, e.draftInteraction({}).then((h) => {
150
- if (d || D.signal.aborted) return;
151
- const M = h._id;
152
- V(M), n.setValue("_id", M, { shouldDirty: !1 }), o(null);
153
- }).catch((h) => {
154
- d || D.signal.aborted || o(h instanceof Error ? h : new Error(String(h)));
155
- }).finally(() => {
156
- d || u(!1);
157
- }), () => {
158
- d = !0, D.abort();
159
- };
160
- }, [t, e, n]);
161
- const O = j(async () => {
162
- if (!t || !r || q.current) return;
163
- const d = n.formState.dirtyFields, D = n.getValues(), h = {};
164
- for (const [f, x] of Object.entries(d))
165
- x && c[f] && !c[f].readOnly && (h[f] = D[f]);
166
- if (Object.keys(h).length === 0) return;
167
- const M = ++v.current;
168
- s(!0);
169
- try {
170
- const f = await e.draftInteraction({
171
- _id: r,
172
- ...h
173
- });
174
- if (M !== v.current) return;
175
- q.current = !0;
176
- try {
177
- for (const [x, F] of Object.entries(f))
178
- x !== "_id" && (d[x] || n.setValue(x, F, {
179
- shouldDirty: !1,
180
- shouldValidate: !1
181
- }));
182
- } finally {
183
- setTimeout(() => {
184
- q.current = !1;
185
- }, 0);
186
- }
187
- o(null);
188
- } catch (f) {
189
- if (M !== v.current) return;
190
- o(f instanceof Error ? f : new Error(String(f)));
191
- } finally {
192
- M === v.current && s(!1);
193
- }
194
- }, [t, r, n, c, e]), a = j(() => {
195
- t && (g === "onChange" || g === "all" ? (C.current && clearTimeout(C.current), C.current = setTimeout(() => {
196
- O();
197
- }, X)) : O());
198
- }, [t, g, O]), m = j(
199
- async (d) => e.draft({
200
- _id: r,
201
- ...d
202
- }),
203
- [e, r]
204
- );
205
- return P(() => () => {
206
- var d;
207
- C.current && clearTimeout(C.current), (d = $.current) == null || d.abort();
208
- }, []), t ? {
209
- draftId: r,
210
- isInitializingDraft: R,
211
- isInteracting: I,
212
- interactionError: l,
213
- triggerInteraction: a,
214
- commitDraft: m
215
- } : {
216
- draftId: void 0,
217
- isInitializingDraft: !1,
218
- isInteracting: !1,
219
- interactionError: null,
220
- triggerInteraction: () => {
221
- },
222
- commitDraft: async () => {
223
- throw new Error("Draft interaction is not enabled");
224
- }
225
- };
226
- }
227
- function rt(i) {
146
+ function z(s) {
228
147
  const {
229
148
  bdo: e,
230
- recordId: n,
231
- operation: g,
149
+ recordId: r,
150
+ operation: o,
232
151
  defaultValues: c,
233
152
  mode: t = "onBlur",
234
- enableDraft: r,
235
- enableConstraintValidation: V,
236
- enableExpressionValidation: R
237
- } = i, s = (i.interactionMode ?? (r === !0 ? "interactive" : r === !1 ? "non-interactive" : "interactive")) === "interactive", l = g ?? (n ? "update" : "create"), o = z(
238
- () => H(e, { enableConstraintValidation: V }),
239
- [e, V]
153
+ enableDraft: a = !1,
154
+ enableConstraintValidation: y,
155
+ enableExpressionValidation: b
156
+ } = s, n = o ?? (r ? "update" : "create"), d = q(
157
+ () => J(e, { enableConstraintValidation: y }),
158
+ [e, y]
240
159
  ), {
241
- data: v,
242
- isLoading: q,
243
- isFetching: C,
244
- error: $
245
- } = K({
246
- queryKey: ["form-record", e.meta._id, n],
247
- queryFn: async () => (await e.get(n)).toJSON(),
248
- enabled: l === "update" && !!n,
160
+ data: f,
161
+ isLoading: u,
162
+ isFetching: l,
163
+ error: R
164
+ } = w({
165
+ queryKey: ["form-record", e.meta._id, r],
166
+ queryFn: async () => (await e.get(r)).toJSON(),
167
+ enabled: n === "update" && !!r,
249
168
  staleTime: 0
250
169
  // Always fetch fresh data for forms
251
- }), { data: O } = K({
170
+ }), { data: g } = w({
252
171
  queryKey: ["form-schema", e.meta._id],
253
- queryFn: () => G(e.meta._id),
172
+ queryFn: () => C(e.meta._id),
254
173
  staleTime: 30 * 60 * 1e3,
255
174
  // Cache for 30 minutes
256
175
  gcTime: 60 * 60 * 1e3,
257
176
  // Keep in cache for 1 hour
258
- enabled: R !== !1
177
+ enabled: b !== !1
259
178
  });
260
- P(() => {
261
- O != null && O.BDOBlob && e.loadMetadata(O.BDOBlob);
262
- }, [O, e]);
263
- const a = U({
179
+ T(() => {
180
+ g != null && g.BDOBlob && e.loadMetadata(g.BDOBlob);
181
+ }, [g, e]);
182
+ const i = j({
264
183
  mode: t,
265
184
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
266
- resolver: o,
185
+ resolver: d,
267
186
  // Validation integrated here!
268
187
  defaultValues: c,
269
188
  // `values` prop reactively updates form when record loads
270
- values: l === "update" && v ? v : void 0
271
- }), m = e.getFields(), {
272
- draftId: d,
273
- isInitializingDraft: D,
274
- isInteracting: h,
275
- interactionError: M,
276
- triggerInteraction: f,
277
- commitDraft: x
278
- } = Y({
279
- bdo: e,
280
- form: a,
281
- mode: t,
282
- fields: m,
283
- enabled: s && l === "create"
284
- }), F = z(
285
- () => W(e, a),
286
- [e, a]
287
- ), A = j(
288
- (_, w) => {
289
- var T;
290
- const y = a.register(_, w);
291
- if ((T = m[_]) != null && T.readOnly)
292
- return { ...y, disabled: !0 };
293
- if (s && (t === "onBlur" || t === "onTouched" || t === "all")) {
294
- const S = y.onBlur;
295
- return {
296
- ...y,
297
- onBlur: async (k) => {
298
- await S(k), f();
299
- }
300
- };
301
- }
302
- return y;
189
+ values: n === "update" && f ? f : void 0
190
+ }), P = q(
191
+ () => I(e, i),
192
+ [e, i]
193
+ ), h = e.getFields(), N = M(
194
+ (v, m) => {
195
+ var S;
196
+ const V = i.register(v, m);
197
+ return (S = h[v]) != null && S.readOnly ? { ...V, disabled: !0 } : V;
303
198
  },
304
- [a, m, s, t, f]
305
- );
306
- P(() => {
307
- if (!s || t !== "onChange" && t !== "all") return;
308
- const _ = a.watch((w, { type: y }) => {
309
- y === "change" && f();
310
- });
311
- return () => _.unsubscribe();
312
- }, [s, t, a, f]);
313
- const Q = j(
314
- (_, w) => a.handleSubmit(
199
+ [i, h]
200
+ ), k = M(
201
+ (v, m) => i.handleSubmit(
315
202
  // onValid - validation passed, make API call
316
- async (y, T) => {
203
+ async (V, S) => {
317
204
  try {
318
- const S = {};
319
- let k;
320
- if (s && l === "create") {
321
- const B = a.formState.dirtyFields;
322
- for (const [b, J] of Object.entries(y))
323
- m[b] && !m[b].readOnly && B[b] && (S[b] = J);
324
- k = await x(S);
325
- } else if (l === "create") {
326
- for (const [B, b] of Object.entries(y))
327
- m[B] && !m[B].readOnly && (S[B] = b);
328
- k = await e.create(
329
- S
330
- );
331
- } else {
332
- const B = a.formState.dirtyFields;
333
- for (const [b, J] of Object.entries(y))
334
- m[b] && !m[b].readOnly && B[b] && (S[b] = J);
335
- k = await e.update(
336
- n,
337
- S
338
- );
205
+ const O = {};
206
+ if (n === "create")
207
+ for (const [x, _] of Object.entries(V))
208
+ h[x] && !h[x].readOnly && (O[x] = _);
209
+ else {
210
+ const x = i.formState.dirtyFields;
211
+ for (const [_, B] of Object.entries(V))
212
+ h[_] && !h[_].readOnly && x[_] && (O[_] = B);
339
213
  }
340
- _ == null || _(k, T);
341
- } catch (S) {
342
- w == null || w(S, T);
214
+ let D;
215
+ n === "create" ? D = await e.create(
216
+ O
217
+ ) : D = await e.update(
218
+ r,
219
+ O
220
+ ), v == null || v(D, S);
221
+ } catch (O) {
222
+ m == null || m(O, S);
343
223
  }
344
224
  },
345
225
  // onInvalid - validation failed
346
- (y, T) => {
347
- w == null || w(y, T);
226
+ (V, S) => {
227
+ m == null || m(V, S);
348
228
  }
349
229
  ),
350
- [a, e, l, n, m, s, x]
230
+ [i, e, n, r, h]
351
231
  );
352
232
  return {
353
233
  // Item - synced with form
354
- item: F,
234
+ item: P,
355
235
  // BDO reference
356
236
  bdo: e,
357
- operation: l,
358
- recordId: n,
237
+ operation: n,
238
+ recordId: r,
359
239
  // Smart register (auto-disables readonly fields)
360
- register: A,
240
+ register: N,
361
241
  // Custom handleSubmit (handles API call + filters payload)
362
- handleSubmit: Q,
242
+ handleSubmit: k,
363
243
  // RHF methods (spread, but handleSubmit is overridden above)
364
- watch: a.watch,
365
- setValue: a.setValue,
366
- getValues: a.getValues,
367
- reset: a.reset,
368
- trigger: a.trigger,
369
- control: a.control,
370
- formState: a.formState,
244
+ watch: i.watch,
245
+ setValue: i.setValue,
246
+ getValues: i.getValues,
247
+ reset: i.reset,
248
+ trigger: i.trigger,
249
+ control: i.control,
250
+ formState: i.formState,
371
251
  // Flattened state for convenience
372
- errors: a.formState.errors,
373
- isDirty: a.formState.isDirty,
374
- isValid: a.formState.isValid,
375
- isSubmitting: a.formState.isSubmitting,
376
- isSubmitSuccessful: a.formState.isSubmitSuccessful,
377
- dirtyFields: a.formState.dirtyFields,
252
+ errors: i.formState.errors,
253
+ isDirty: i.formState.isDirty,
254
+ isValid: i.formState.isValid,
255
+ isSubmitting: i.formState.isSubmitting,
256
+ isSubmitSuccessful: i.formState.isSubmitSuccessful,
257
+ dirtyFields: i.formState.dirtyFields,
378
258
  // Loading states
379
- isLoading: q || D,
380
- isFetching: C,
259
+ isLoading: u,
260
+ isFetching: l,
381
261
  // Error
382
- loadError: $,
383
- // Draft / Interactive mode
384
- draftId: d,
385
- isInitializingDraft: D,
386
- isInteracting: h,
387
- interactionError: M
262
+ loadError: R
388
263
  };
389
264
  }
390
265
  export {
391
- it as FormOperation,
392
- st as InteractionMode,
393
- lt as ValidationMode,
394
- rt as useForm
266
+ H as FormOperation,
267
+ U as InteractionMode,
268
+ W as ValidationMode,
269
+ z as useForm
395
270
  };
@@ -1,2 +1,2 @@
1
- export type { UseFormOptionsType, UseFormReturnType, FormItemType, EditableFormFieldAccessorType, ReadonlyFormFieldAccessorType, FormRegisterType, HandleSubmitType, ExtractEditableType, ExtractReadonlyType, AllFieldsType, InteractiveCreatableBdo, } from "./components/hooks/useForm";
1
+ export type { UseFormOptionsType, UseFormReturnType, FormItemType, EditableFormFieldAccessorType, ReadonlyFormFieldAccessorType, FormRegisterType, HandleSubmitType, ExtractEditableType, ExtractReadonlyType, AllFieldsType, } from "./components/hooks/useForm";
2
2
  //# sourceMappingURL=form.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"form.types.d.ts","sourceRoot":"","sources":["../sdk/form.types.ts"],"names":[],"mappings":"AAKA,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,6BAA6B,EAC7B,6BAA6B,EAC7B,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,uBAAuB,GACxB,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"form.types.d.ts","sourceRoot":"","sources":["../sdk/form.types.ts"],"names":[],"mappings":"AAKA,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,6BAA6B,EAC7B,6BAA6B,EAC7B,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,GACd,MAAM,4BAA4B,CAAC"}
package/dist/table.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),L=require("@tanstack/react-query"),x=require("./client-DtPpfJc1.cjs"),h=require("./error-handling-CAoD0Kwb.cjs"),oe=require("./useFilter-Bg0jvIL6.cjs"),l=require("./constants-D0J69if5.cjs");function ne(o){var k,R,z,M,P,Q,D,w;const[a,C]=r.useState({query:"",debouncedQuery:"",field:null}),c=r.useRef(null),G=300,j=()=>{var t,n;const e=(t=o.initialState)==null?void 0:t.sort;if(e&&e.length>0){const A=e[0],H=Object.keys(A)[0],re=(n=A[H])==null?void 0:n.toLowerCase();return{field:H,direction:re}}return{field:null,direction:null}},[s,b]=r.useState(j),[i,u]=r.useState({pageNo:((R=(k=o.initialState)==null?void 0:k.pagination)==null?void 0:R.pageNo)||1,pageSize:((M=(z=o.initialState)==null?void 0:z.pagination)==null?void 0:M.pageSize)||10}),d=oe.useFilter({conditions:(Q=(P=o.initialState)==null?void 0:P.filter)==null?void 0:Q.conditions,operator:((w=(D=o.initialState)==null?void 0:D.filter)==null?void 0:w.operator)||"And"});r.useEffect(()=>{u(e=>({...e,pageNo:1}))},[d.payload]);const g=r.useMemo(()=>{const e={};let t=d.payload;if(a.debouncedQuery&&a.field){const n={LHSField:a.field,Operator:"Contains",RHSValue:a.debouncedQuery,RHSType:"Constant"};t?t.Operator==="And"?t={...t,Condition:[...t.Condition||[],n]}:t={Operator:"And",Condition:[t,n]}:t={Operator:"And",Condition:[n]}}return t&&(e.Filter=t),e},[a.debouncedQuery,a.field,d.payload]),T=r.useMemo(()=>{const e={...g};return s.field&&s.direction&&(e.Sort=[{[String(s.field)]:s.direction==="asc"?"ASC":"DESC"}]),e.Page=i.pageNo,e.PageSize=i.pageSize,e},[g,s,i]),{data:f,isLoading:I,isFetching:K,error:E,refetch:q}=L.useQuery({queryKey:["table",o.source,T],queryFn:async()=>{try{const e=await x.api(o.source).list(T);return o.onSuccess&&o.onSuccess(e.Data),e}catch(e){throw o.onError&&o.onError(h.toError(e)),e}},staleTime:0,gcTime:30*1e3}),{data:S,isLoading:_,isFetching:B,error:O,refetch:F}=L.useQuery({queryKey:["table-count",o.source,g],queryFn:async()=>{try{return await x.api(o.source).count(g)}catch(e){throw o.onError&&o.onError(h.toError(e)),e}},staleTime:0,gcTime:30*1e3}),U=r.useMemo(()=>(f==null?void 0:f.Data)||[],[f]),p=r.useMemo(()=>(S==null?void 0:S.Count)||0,[S]),y=r.useMemo(()=>Math.ceil(p/i.pageSize),[p,i.pageSize]),V=r.useCallback(e=>{b(t=>{if(t.field===e){if(t.direction==="asc")return{field:e,direction:"desc"};if(t.direction==="desc")return{field:null,direction:null}}return{field:e,direction:"asc"}})},[]),J=r.useCallback(()=>{b({field:null,direction:null})},[]),W=r.useCallback((e,t)=>{b({field:e,direction:t})},[]),X=r.useCallback((e,t)=>{if(t.length>255){console.warn("Search query exceeds maximum length of 255 characters");return}C(n=>({...n,query:t,field:e})),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{C(n=>({...n,debouncedQuery:t})),u(n=>({...n,pageNo:1}))},G)},[]),Y=r.useCallback(()=>{c.current&&clearTimeout(c.current),C({query:"",debouncedQuery:"",field:null}),u(e=>({...e,pageNo:1}))},[]);r.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const m=i.pageNo<y,N=i.pageNo>1,Z=r.useCallback(()=>{m&&u(e=>({...e,pageNo:e.pageNo+1}))},[m]),$=r.useCallback(()=>{N&&u(e=>({...e,pageNo:e.pageNo-1}))},[N]),v=r.useCallback(e=>{const t=Math.max(1,Math.min(e,y));u(n=>({...n,pageNo:t}))},[y]),ee=r.useCallback(e=>{u(t=>({...t,pageSize:e,pageNo:1}))},[]),te=r.useCallback(async()=>{const[e]=await Promise.all([q(),F()]);return e.data||{Data:[]}},[q,F]);return{rows:U,totalItems:p,isLoading:I||_,isFetching:K||B,error:E?h.toError(E):O?h.toError(O):null,search:{query:a.query,field:a.field,set:X,clear:Y},sort:{field:s.field,direction:s.direction,toggle:V,clear:J,set:W},filter:d,pagination:{pageNo:i.pageNo,pageSize:i.pageSize,totalPages:y,totalItems:p,canGoNext:m,canGoPrevious:N,goToNext:Z,goToPrevious:$,goToPage:v,setPageSize:ee},refetch:te}}exports.ConditionOperator=l.ConditionOperator;exports.GroupOperator=l.GroupOperator;exports.RHSType=l.RHSType;exports.SortDirection=l.SortDirection;exports.TableDefaults=l.Defaults;exports.useTable=ne;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),L=require("@tanstack/react-query"),G=require("./client-DtPpfJc1.cjs"),C=require("./error-handling-CAoD0Kwb.cjs"),oe=require("./useFilter-Bg0jvIL6.cjs"),l=require("./constants-D0J69if5.cjs");function ne(o){var A,D,R,z,M,P,Q,w;const[a,h]=r.useState({query:"",debouncedQuery:"",field:null}),c=r.useRef(null),j=300,I=()=>{var t,n;const e=(t=o.initialState)==null?void 0:t.sort;if(e&&e.length>0){const H=e[0],x=Object.keys(H)[0],T=(n=H[x])==null?void 0:n.toUpperCase();return{field:x,direction:T==="ASC"||T==="DESC"?T:"ASC"}}return{field:null,direction:null}},[s,b]=r.useState(I),[i,u]=r.useState({pageNo:((D=(A=o.initialState)==null?void 0:A.pagination)==null?void 0:D.pageNo)||1,pageSize:((z=(R=o.initialState)==null?void 0:R.pagination)==null?void 0:z.pageSize)||10}),d=oe.useFilter({conditions:(P=(M=o.initialState)==null?void 0:M.filter)==null?void 0:P.conditions,operator:((w=(Q=o.initialState)==null?void 0:Q.filter)==null?void 0:w.operator)||"And"});r.useEffect(()=>{u(e=>({...e,pageNo:1}))},[d.payload]);const g=r.useMemo(()=>{const e={};let t=d.payload;if(a.debouncedQuery&&a.field){const n={LHSField:a.field,Operator:"Contains",RHSValue:a.debouncedQuery,RHSType:"Constant"};t?t.Operator==="And"?t={...t,Condition:[...t.Condition||[],n]}:t={Operator:"And",Condition:[t,n]}:t={Operator:"And",Condition:[n]}}return t&&(e.Filter=t),e},[a.debouncedQuery,a.field,d.payload]),E=r.useMemo(()=>{const e={...g};return s.field&&s.direction&&(e.Sort=[{[String(s.field)]:s.direction}]),e.Page=i.pageNo,e.PageSize=i.pageSize,e},[g,s,i]),{data:f,isLoading:K,isFetching:U,error:q,refetch:O}=L.useQuery({queryKey:["table",o.source,E],queryFn:async()=>{try{const e=await G.api(o.source).list(E);return o.onSuccess&&o.onSuccess(e.Data),e}catch(e){throw o.onError&&o.onError(C.toError(e)),e}},staleTime:0,gcTime:30*1e3}),{data:S,isLoading:_,isFetching:B,error:F,refetch:k}=L.useQuery({queryKey:["table-count",o.source,g],queryFn:async()=>{try{return await G.api(o.source).count(g)}catch(e){throw o.onError&&o.onError(C.toError(e)),e}},staleTime:0,gcTime:30*1e3}),V=r.useMemo(()=>(f==null?void 0:f.Data)||[],[f]),p=r.useMemo(()=>(S==null?void 0:S.Count)||0,[S]),y=r.useMemo(()=>Math.ceil(p/i.pageSize),[p,i.pageSize]),J=r.useCallback(e=>{b(t=>{if(t.field===e){if(t.direction==="ASC")return{field:e,direction:"DESC"};if(t.direction==="DESC")return{field:null,direction:null}}return{field:e,direction:"ASC"}})},[]),W=r.useCallback(()=>{b({field:null,direction:null})},[]),X=r.useCallback((e,t)=>{b({field:e,direction:t})},[]),Y=r.useCallback((e,t)=>{if(t.length>255){console.warn("Search query exceeds maximum length of 255 characters");return}h(n=>({...n,query:t,field:e})),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{h(n=>({...n,debouncedQuery:t})),u(n=>({...n,pageNo:1}))},j)},[]),Z=r.useCallback(()=>{c.current&&clearTimeout(c.current),h({query:"",debouncedQuery:"",field:null}),u(e=>({...e,pageNo:1}))},[]);r.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const m=i.pageNo<y,N=i.pageNo>1,$=r.useCallback(()=>{m&&u(e=>({...e,pageNo:e.pageNo+1}))},[m]),v=r.useCallback(()=>{N&&u(e=>({...e,pageNo:e.pageNo-1}))},[N]),ee=r.useCallback(e=>{const t=Math.max(1,Math.min(e,y));u(n=>({...n,pageNo:t}))},[y]),te=r.useCallback(e=>{u(t=>({...t,pageSize:e,pageNo:1}))},[]),re=r.useCallback(async()=>{const[e]=await Promise.all([O(),k()]);return e.data||{Data:[]}},[O,k]);return{rows:V,totalItems:p,isLoading:K||_,isFetching:U||B,error:q?C.toError(q):F?C.toError(F):null,search:{query:a.query,field:a.field,set:Y,clear:Z},sort:{field:s.field,direction:s.direction,toggle:J,clear:W,set:X},filter:d,pagination:{pageNo:i.pageNo,pageSize:i.pageSize,totalPages:y,totalItems:p,canGoNext:m,canGoPrevious:N,goToNext:$,goToPrevious:v,goToPage:ee,setPageSize:te},refetch:re}}exports.ConditionOperator=l.ConditionOperator;exports.GroupOperator=l.GroupOperator;exports.RHSType=l.RHSType;exports.SortDirection=l.SortDirection;exports.TableDefaults=l.Defaults;exports.useTable=ne;