@ram_28/kf-ai-sdk 1.0.18 → 1.0.20

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 (77) hide show
  1. package/README.md +45 -12
  2. package/dist/api/client.d.ts.map +1 -1
  3. package/dist/api.cjs +1 -1
  4. package/dist/api.mjs +2 -2
  5. package/dist/auth.cjs +1 -1
  6. package/dist/auth.mjs +1 -1
  7. package/dist/{client-C15j4O5B.cjs → client-DgtkT50N.cjs} +1 -1
  8. package/dist/{client-CfvLiGfP.js → client-V-WzUb8H.js} +9 -5
  9. package/dist/components/hooks/useFilter/types.d.ts +14 -11
  10. package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
  11. package/dist/components/hooks/useFilter/useFilter.d.ts +1 -1
  12. package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
  13. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
  14. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
  15. package/dist/components/hooks/useKanban/context.d.ts +1 -1
  16. package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
  17. package/dist/components/hooks/useKanban/types.d.ts +5 -22
  18. package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
  19. package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
  20. package/dist/components/hooks/useTable/types.d.ts +19 -31
  21. package/dist/components/hooks/useTable/types.d.ts.map +1 -1
  22. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
  23. package/dist/error-handling-CAoD0Kwb.cjs +1 -0
  24. package/dist/error-handling-CrhTtD88.js +14 -0
  25. package/dist/filter.cjs +1 -1
  26. package/dist/filter.mjs +1 -1
  27. package/dist/form.cjs +1 -1
  28. package/dist/form.mjs +825 -814
  29. package/dist/index.d.ts +18 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/kanban.cjs +2 -2
  32. package/dist/kanban.mjs +335 -323
  33. package/dist/{metadata-2FLBsFcf.cjs → metadata-0lZAfuTP.cjs} +1 -1
  34. package/dist/{metadata-DBcoDth-.js → metadata-B88D_pVS.js} +1 -1
  35. package/dist/table.cjs +1 -1
  36. package/dist/table.mjs +113 -96
  37. package/dist/table.types.d.ts +1 -1
  38. package/dist/table.types.d.ts.map +1 -1
  39. package/dist/types/common.d.ts +26 -6
  40. package/dist/types/common.d.ts.map +1 -1
  41. package/dist/useFilter-DzpP_ag0.cjs +1 -0
  42. package/dist/useFilter-H5bgAZQF.js +120 -0
  43. package/dist/utils/api/buildListOptions.d.ts +43 -0
  44. package/dist/utils/api/buildListOptions.d.ts.map +1 -0
  45. package/dist/utils/api/index.d.ts +2 -0
  46. package/dist/utils/api/index.d.ts.map +1 -0
  47. package/dist/utils/error-handling.d.ts +41 -0
  48. package/dist/utils/error-handling.d.ts.map +1 -0
  49. package/dist/utils/index.d.ts +2 -0
  50. package/dist/utils/index.d.ts.map +1 -1
  51. package/docs/QUICK_REFERENCE.md +142 -420
  52. package/docs/useAuth.md +52 -340
  53. package/docs/useFilter.md +858 -162
  54. package/docs/useForm.md +712 -501
  55. package/docs/useKanban.md +534 -279
  56. package/docs/useTable.md +725 -214
  57. package/package.json +1 -1
  58. package/sdk/api/client.ts +7 -1
  59. package/sdk/components/hooks/useFilter/types.ts +14 -11
  60. package/sdk/components/hooks/useFilter/useFilter.ts +20 -18
  61. package/sdk/components/hooks/useForm/apiClient.ts +2 -1
  62. package/sdk/components/hooks/useForm/useForm.ts +47 -13
  63. package/sdk/components/hooks/useKanban/context.ts +5 -3
  64. package/sdk/components/hooks/useKanban/types.ts +7 -23
  65. package/sdk/components/hooks/useKanban/useKanban.ts +54 -18
  66. package/sdk/components/hooks/useTable/types.ts +26 -32
  67. package/sdk/components/hooks/useTable/useTable.llm.txt +8 -22
  68. package/sdk/components/hooks/useTable/useTable.ts +70 -25
  69. package/sdk/index.ts +154 -10
  70. package/sdk/table.types.ts +3 -0
  71. package/sdk/types/common.ts +31 -6
  72. package/sdk/utils/api/buildListOptions.ts +120 -0
  73. package/sdk/utils/api/index.ts +2 -0
  74. package/sdk/utils/error-handling.ts +150 -0
  75. package/sdk/utils/index.ts +6 -0
  76. package/dist/useFilter-Dofowpr_.cjs +0 -1
  77. package/dist/useFilter-Dv-mr9QW.js +0 -117
package/dist/kanban.mjs CHANGED
@@ -1,43 +1,44 @@
1
- import { useState as G, useRef as k, useCallback as h, useEffect as rt, useMemo as ot, createContext as qt, useContext as Qt } from "react";
2
- import { useQueryClient as At, useQueries as Tt, keepPreviousData as kt, useQuery as Pt, useMutation as j } from "@tanstack/react-query";
3
- import { a as F } from "./client-CfvLiGfP.js";
4
- import { u as Et } from "./useFilter-Dv-mr9QW.js";
5
- const ct = 50, dt = 5, ut = 5;
6
- function Ft({
7
- onCardMove: i,
8
- onError: c,
1
+ import { useState as G, useRef as q, useCallback as p, useEffect as V, useMemo as lt, createContext as Pt, useContext as Et } from "react";
2
+ import { useQueryClient as Ft, useQueries as $t, keepPreviousData as Lt, useQuery as It, useMutation as R } from "@tanstack/react-query";
3
+ import { a as F } from "./client-V-WzUb8H.js";
4
+ import { t as k } from "./error-handling-CrhTtD88.js";
5
+ import { u as Ht } from "./useFilter-H5bgAZQF.js";
6
+ const gt = 50, mt = 5, yt = 5;
7
+ function Ut({
8
+ onCardMove: o,
9
+ onError: u,
9
10
  columns: d,
10
11
  announceMove: a
11
12
  }) {
12
- const [s, O] = G({
13
+ const [s, _] = G({
13
14
  isDragging: !1,
14
15
  draggedCard: null,
15
16
  dragOverColumn: null,
16
17
  dragOverPosition: null,
17
18
  dragSourceColumn: null
18
- }), q = k(null), _ = k(null), K = k(null), b = h(() => {
19
- O({
19
+ }), O = q(null), w = q(null), Q = q(null), b = p(() => {
20
+ _({
20
21
  isDragging: !1,
21
22
  draggedCard: null,
22
23
  dragOverColumn: null,
23
24
  dragOverPosition: null,
24
25
  dragSourceColumn: null
25
- }), _.current && (clearTimeout(_.current), _.current = null);
26
- }, []), D = h((u) => d.find((o) => o._id === u) || null, [d]), Y = h((u) => {
27
- for (const o of d) {
28
- const g = o.cards.find((m) => m._id === u);
29
- if (g)
30
- return { card: g, column: o };
26
+ }), w.current && (clearTimeout(w.current), w.current = null);
27
+ }, []), C = p((i) => d.find((c) => c._id === i) || null, [d]), $ = p((i) => {
28
+ for (const c of d) {
29
+ const l = c.cards.find((m) => m._id === i);
30
+ if (l)
31
+ return { card: l, column: c };
31
32
  }
32
33
  return null;
33
- }, [d]), P = h((u, o) => {
34
- var g, m;
34
+ }, [d]), A = p((i, c) => {
35
+ var l, m;
35
36
  try {
36
- const l = u.target, y = D(o.columnId);
37
+ const g = i.target, y = C(c.columnId);
37
38
  if (!y)
38
39
  throw new Error("Source column not found");
39
- (g = u.dataTransfer) == null || g.setData("text/plain", o._id), (m = u.dataTransfer) == null || m.setData("application/json", JSON.stringify(o));
40
- const S = l.cloneNode(!0);
40
+ (l = i.dataTransfer) == null || l.setData("text/plain", c._id), (m = i.dataTransfer) == null || m.setData("application/json", JSON.stringify(c));
41
+ const S = g.cloneNode(!0);
41
42
  S.style.cssText = `
42
43
  position: fixed;
43
44
  top: -1000px;
@@ -50,145 +51,145 @@ function Ft({
50
51
  max-width: 300px;
51
52
  background: white;
52
53
  border-radius: 8px;
53
- `, document.body.appendChild(S), q.current = S, u.dataTransfer && u.dataTransfer.setDragImage(S, u.offsetX || 50, u.offsetY || 20), O({
54
+ `, document.body.appendChild(S), O.current = S, i.dataTransfer && i.dataTransfer.setDragImage(S, i.offsetX || 50, i.offsetY || 20), _({
54
55
  isDragging: !0,
55
- draggedCard: o,
56
+ draggedCard: c,
56
57
  dragOverColumn: null,
57
58
  dragOverPosition: null,
58
59
  dragSourceColumn: y._id
59
- }), a == null || a(o, y.title, "being moved");
60
- } catch (l) {
61
- c == null || c(l instanceof Error ? l : new Error("Drag start failed")), b();
60
+ }), a == null || a(c, y.title, "being moved");
61
+ } catch (g) {
62
+ u == null || u(g instanceof Error ? g : new Error("Drag start failed")), b();
62
63
  }
63
- }, [D, c, b, a]), z = h((u, o) => {
64
- if (u.preventDefault(), !s.isDragging || !s.draggedCard) return;
65
- const g = o ? D(o) : null;
66
- O((m) => ({
64
+ }, [C, u, b, a]), Z = p((i, c) => {
65
+ if (i.preventDefault(), !s.isDragging || !s.draggedCard) return;
66
+ const l = c ? C(c) : null;
67
+ _((m) => ({
67
68
  ...m,
68
- dragOverColumn: (g == null ? void 0 : g._id) || null,
69
+ dragOverColumn: (l == null ? void 0 : l._id) || null,
69
70
  dragOverPosition: null
70
71
  // Will be calculated based on mouse position
71
- })), $(u);
72
- }, [s.isDragging, s.draggedCard, D]), V = h((u, o) => {
73
- if (u.preventDefault(), !(!s.isDragging || !s.draggedCard))
72
+ })), v(i);
73
+ }, [s.isDragging, s.draggedCard, C]), P = p((i, c) => {
74
+ if (i.preventDefault(), !(!s.isDragging || !s.draggedCard))
74
75
  try {
75
- const g = s.draggedCard, m = s.dragSourceColumn, l = D(o), y = D(m);
76
- if (!l || !y)
76
+ const l = s.draggedCard, m = s.dragSourceColumn, g = C(c), y = C(m);
77
+ if (!g || !y)
77
78
  throw new Error("Target or source column not found");
78
- if (m === o) {
79
+ if (m === c) {
79
80
  b();
80
81
  return;
81
82
  }
82
- if (l.limit && l.cards.length >= l.limit)
83
- throw new Error(`Column "${l.title}" has reached its limit of ${l.limit} cards`);
84
- i == null || i(g, m, o), a == null || a(g, y.title, l.title);
85
- } catch (g) {
86
- c == null || c(g instanceof Error ? g : new Error("Drop failed"));
83
+ if (g.limit && g.cards.length >= g.limit)
84
+ throw new Error(`Column "${g.title}" has reached its limit of ${g.limit} cards`);
85
+ o == null || o(l, m, c), a == null || a(l, y.title, g.title);
86
+ } catch (l) {
87
+ u == null || u(l instanceof Error ? l : new Error("Drop failed"));
87
88
  } finally {
88
89
  b();
89
90
  }
90
- }, [s, D, i, c, b, a]), C = h(() => {
91
- q.current && (document.body.removeChild(q.current), q.current = null), b();
92
- }, [b]), $ = h((u) => {
93
- const o = u.target.closest(".kanban-container");
94
- if (!o) return;
95
- const g = o.getBoundingClientRect(), m = u.clientX - g.left, l = g.width;
91
+ }, [s, C, o, u, b, a]), J = p(() => {
92
+ O.current && (document.body.removeChild(O.current), O.current = null), b();
93
+ }, [b]), v = p((i) => {
94
+ const c = i.target.closest(".kanban-container");
95
+ if (!c) return;
96
+ const l = c.getBoundingClientRect(), m = i.clientX - l.left, g = l.width;
96
97
  let y = 0;
97
- if (m < ct ? y = -dt : m > l - ct && (y = dt), y !== 0) {
98
- _.current && clearTimeout(_.current);
98
+ if (m < gt ? y = -mt : m > g - gt && (y = mt), y !== 0) {
99
+ w.current && clearTimeout(w.current);
99
100
  const S = () => {
100
- o.scrollLeft += y, _.current = setTimeout(S, 16);
101
+ c.scrollLeft += y, w.current = setTimeout(S, 16);
101
102
  };
102
- _.current = setTimeout(S, 100);
103
+ w.current = setTimeout(S, 100);
103
104
  } else
104
- _.current && (clearTimeout(_.current), _.current = null);
105
- }, []), L = h((u, o) => {
106
- if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter", "Space", "Escape"].includes(u.key))
105
+ w.current && (clearTimeout(w.current), w.current = null);
106
+ }, []), h = p((i, c) => {
107
+ if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter", "Space", "Escape"].includes(i.key))
107
108
  return;
108
- u.preventDefault();
109
- const g = Y(o._id);
110
- if (!g) return;
111
- const { column: m } = g, l = d.findIndex((y) => y._id === m._id);
109
+ i.preventDefault();
110
+ const l = $(c._id);
111
+ if (!l) return;
112
+ const { column: m } = l, g = d.findIndex((y) => y._id === m._id);
112
113
  try {
113
- switch (u.key) {
114
+ switch (i.key) {
114
115
  case "ArrowLeft":
115
- if (l > 0) {
116
- const y = d[l - 1];
117
- i == null || i(o, m._id, y._id), a == null || a(o, m.title, y.title);
116
+ if (g > 0) {
117
+ const y = d[g - 1];
118
+ o == null || o(c, m._id, y._id), a == null || a(c, m.title, y.title);
118
119
  }
119
120
  break;
120
121
  case "ArrowRight":
121
- if (l < d.length - 1) {
122
- const y = d[l + 1];
123
- i == null || i(o, m._id, y._id), a == null || a(o, m.title, y.title);
122
+ if (g < d.length - 1) {
123
+ const y = d[g + 1];
124
+ o == null || o(c, m._id, y._id), a == null || a(c, m.title, y.title);
124
125
  }
125
126
  break;
126
127
  case "ArrowUp":
127
- a == null || a(o, "current position", "position above");
128
+ a == null || a(c, "current position", "position above");
128
129
  break;
129
130
  case "ArrowDown":
130
- a == null || a(o, "current position", "position below");
131
+ a == null || a(c, "current position", "position below");
131
132
  break;
132
133
  case "Enter":
133
134
  case "Space":
134
- a == null || a(o, m.title, "drag mode");
135
+ a == null || a(c, m.title, "drag mode");
135
136
  break;
136
137
  case "Escape":
137
- a == null || a(o, "drag mode", "cancelled");
138
+ a == null || a(c, "drag mode", "cancelled");
138
139
  break;
139
140
  }
140
141
  } catch (y) {
141
- c == null || c(y instanceof Error ? y : new Error("Keyboard navigation failed"));
142
+ u == null || u(y instanceof Error ? y : new Error("Keyboard navigation failed"));
142
143
  }
143
- }, [Y, d, i, c, a]), I = h((u, o) => {
144
- const g = u.touches[0];
145
- K.current = {
146
- x: g.clientX,
147
- y: g.clientY,
148
- card: o
144
+ }, [$, d, o, u, a]), L = p((i, c) => {
145
+ const l = i.touches[0];
146
+ Q.current = {
147
+ x: l.clientX,
148
+ y: l.clientY,
149
+ card: c
149
150
  };
150
- }, []), H = h((u) => {
151
- if (!K.current) return;
152
- const o = u.touches[0], g = Math.abs(o.clientX - K.current.x), m = Math.abs(o.clientY - K.current.y);
153
- if (g > ut || m > ut) {
154
- const l = K.current.card, y = D(l.columnId);
151
+ }, []), I = p((i) => {
152
+ if (!Q.current) return;
153
+ const c = i.touches[0], l = Math.abs(c.clientX - Q.current.x), m = Math.abs(c.clientY - Q.current.y);
154
+ if (l > yt || m > yt) {
155
+ const g = Q.current.card, y = C(g.columnId);
155
156
  if (!y) return;
156
- O({
157
+ _({
157
158
  isDragging: !0,
158
- draggedCard: l,
159
+ draggedCard: g,
159
160
  dragOverColumn: null,
160
161
  dragOverPosition: null,
161
162
  dragSourceColumn: y._id
162
- }), a == null || a(l, y.title, "being moved");
163
+ }), a == null || a(g, y.title, "being moved");
163
164
  }
164
- }, [D, a]), p = h((u) => {
165
- if (!s.isDragging || !s.draggedCard || !K.current) {
166
- K.current = null;
165
+ }, [C, a]), H = p((i) => {
166
+ if (!s.isDragging || !s.draggedCard || !Q.current) {
167
+ Q.current = null;
167
168
  return;
168
169
  }
169
170
  try {
170
- const o = u.changedTouches[0], g = document.elementFromPoint(o.clientX, o.clientY), m = g == null ? void 0 : g.closest("[data-column-id]");
171
+ const c = i.changedTouches[0], l = document.elementFromPoint(c.clientX, c.clientY), m = l == null ? void 0 : l.closest("[data-column-id]");
171
172
  if (m) {
172
- const l = m.dataset.columnId, y = s.draggedCard, S = s.dragSourceColumn, Q = D(l), J = D(S);
173
- if (Q && J && S !== l) {
174
- if (Q.limit && Q.cards.length >= Q.limit)
175
- throw new Error(`Column "${Q.title}" has reached its limit of ${Q.limit} cards`);
176
- i == null || i(y, S, l), a == null || a(y, J.title, Q.title);
173
+ const g = m.dataset.columnId, y = s.draggedCard, S = s.dragSourceColumn, K = C(g), N = C(S);
174
+ if (K && N && S !== g) {
175
+ if (K.limit && K.cards.length >= K.limit)
176
+ throw new Error(`Column "${K.title}" has reached its limit of ${K.limit} cards`);
177
+ o == null || o(y, S, g), a == null || a(y, N.title, K.title);
177
178
  }
178
179
  }
179
- } catch (o) {
180
- c == null || c(o instanceof Error ? o : new Error("Touch drop failed"));
180
+ } catch (c) {
181
+ u == null || u(c instanceof Error ? c : new Error("Touch drop failed"));
181
182
  } finally {
182
- K.current = null, b();
183
+ Q.current = null, b();
183
184
  }
184
- }, [s, D, i, c, b, a]), T = h((u, o, g) => {
185
- const m = `Moved "${u.title}" from ${o} to ${g}`, l = document.createElement("div");
186
- l.setAttribute("aria-live", "polite"), l.setAttribute("aria-atomic", "true"), l.className = "sr-only", l.textContent = m, document.body.appendChild(l), setTimeout(() => {
187
- document.body.removeChild(l);
185
+ }, [s, C, o, u, b, a]), U = p((i, c, l) => {
186
+ const m = `Moved "${i.title}" from ${c} to ${l}`, g = document.createElement("div");
187
+ g.setAttribute("aria-live", "polite"), g.setAttribute("aria-atomic", "true"), g.className = "sr-only", g.textContent = m, document.body.appendChild(g), setTimeout(() => {
188
+ document.body.removeChild(g);
188
189
  }, 1e3), console.log(`Kanban: ${m}`);
189
190
  }, []);
190
- return rt(() => () => {
191
- _.current && clearTimeout(_.current), q.current && document.body.contains(q.current) && document.body.removeChild(q.current);
191
+ return V(() => () => {
192
+ w.current && clearTimeout(w.current), O.current && document.body.contains(O.current) && document.body.removeChild(O.current);
192
193
  }, []), {
193
194
  // State
194
195
  isDragging: s.isDragging,
@@ -197,55 +198,56 @@ function Ft({
197
198
  dragOverPosition: s.dragOverPosition,
198
199
  dragSourceColumn: s.dragSourceColumn,
199
200
  // Handlers
200
- handleDragStart: P,
201
- handleDragOver: z,
202
- handleDrop: V,
203
- handleDragEnd: C,
204
- handleKeyDown: L,
205
- handleTouchStart: I,
206
- handleTouchMove: H,
207
- handleTouchEnd: p,
201
+ handleDragStart: A,
202
+ handleDragOver: Z,
203
+ handleDrop: P,
204
+ handleDragEnd: J,
205
+ handleKeyDown: h,
206
+ handleTouchStart: L,
207
+ handleTouchMove: I,
208
+ handleTouchEnd: H,
208
209
  // Utilities
209
- announceMove: a || T,
210
+ announceMove: a || U,
210
211
  reset: b
211
212
  };
212
213
  }
213
- function Xt(i) {
214
- var at, nt, it;
214
+ function Rt(o) {
215
+ var it, st, ot, ct, ut;
215
216
  const {
216
- columns: c,
217
+ columns: u,
217
218
  source: d,
218
219
  enableDragDrop: a = !0,
219
220
  initialState: s,
220
- onCardMove: O,
221
- onCardCreate: q,
222
- onCardUpdate: _,
223
- onCardDelete: K,
221
+ onCardMove: _,
222
+ onCardCreate: O,
223
+ onCardUpdate: w,
224
+ onCardDelete: Q,
224
225
  onError: b
225
- } = i, [D, Y] = G({
226
- query: (s == null ? void 0 : s.search) || ""
227
- }), [P] = G({
228
- field: ((at = s == null ? void 0 : s.sorting) == null ? void 0 : at.field) || null,
229
- direction: ((nt = s == null ? void 0 : s.sorting) == null ? void 0 : nt.direction) || null
230
- }), [z, V] = G(() => {
226
+ } = o, [C, $] = G({
227
+ query: (s == null ? void 0 : s.search) || "",
228
+ debouncedQuery: (s == null ? void 0 : s.search) || ""
229
+ }), A = q(null), Z = 300, [P] = G({
230
+ field: ((it = s == null ? void 0 : s.sorting) == null ? void 0 : it.field) || null,
231
+ direction: ((st = s == null ? void 0 : s.sorting) == null ? void 0 : st.direction) || null
232
+ }), [J, v] = G(() => {
231
233
  const t = {};
232
- return c.forEach((e) => {
234
+ return u.forEach((e) => {
233
235
  t[e.id] = 10;
234
236
  }), t;
235
- }), C = k(b), $ = k(O), L = k(q), I = k(_), H = k(K);
236
- rt(() => {
237
- C.current = b, $.current = O, L.current = q, I.current = _, H.current = K;
238
- }, [b, O, q, _, K]);
239
- const p = At(), T = Et({
240
- initialConditions: s == null ? void 0 : s.filters,
241
- initialOperator: (s == null ? void 0 : s.filterOperator) || "And"
242
- }), u = h((t) => {
237
+ }), h = q(b), L = q(_), I = q(O), H = q(w), U = q(Q);
238
+ V(() => {
239
+ h.current = b, L.current = _, I.current = O, H.current = w, U.current = Q;
240
+ }, [b, _, O, w, Q]);
241
+ const i = Ft(), c = Ht({
242
+ conditions: (ot = s == null ? void 0 : s.filter) == null ? void 0 : ot.conditions,
243
+ operator: ((ct = s == null ? void 0 : s.filter) == null ? void 0 : ct.operator) || "And"
244
+ }), l = p((t) => {
243
245
  const e = {
244
246
  LHSField: "columnId",
245
247
  Operator: "EQ",
246
248
  RHSValue: t,
247
249
  RHSType: "Constant"
248
- }, r = T.payload;
250
+ }, r = c.payload;
249
251
  let n;
250
252
  r ? r.Operator === "And" ? n = {
251
253
  ...r,
@@ -260,7 +262,7 @@ function Xt(i) {
260
262
  const f = {
261
263
  Page: 1,
262
264
  // Always page 1 due to expanding PageSize strategy
263
- PageSize: z[t] || 10,
265
+ PageSize: J[t] || 10,
264
266
  Filter: n
265
267
  };
266
268
  return P.field && P.direction ? f.Sort = [
@@ -269,10 +271,10 @@ function Xt(i) {
269
271
  ] : f.Sort = [
270
272
  { columnId: "ASC" },
271
273
  { position: "ASC" }
272
- ], D.query && (f.Search = D.query), f;
273
- }, [T.payload, z, P, D.query]), o = Tt({
274
- queries: c.map((t) => {
275
- const e = u(t.id);
274
+ ], C.debouncedQuery && (f.Search = C.debouncedQuery), f;
275
+ }, [c.payload, J, P, C.debouncedQuery]), m = $t({
276
+ queries: u.map((t) => {
277
+ const e = l(t.id);
276
278
  return {
277
279
  queryKey: ["kanban-cards", d, t.id, e],
278
280
  queryFn: async () => {
@@ -282,48 +284,48 @@ function Xt(i) {
282
284
  throw r;
283
285
  }
284
286
  },
285
- placeholderData: kt,
287
+ placeholderData: Lt,
286
288
  staleTime: 30 * 1e3
287
289
  };
288
290
  })
289
- }), g = o.some((t) => t.isLoading), m = o.some((t) => t.isFetching), l = ((it = o.find((t) => t.error)) == null ? void 0 : it.error) || null, y = async () => {
290
- await Promise.all(o.map((t) => t.refetch()));
291
- }, S = ot(() => {
291
+ }), g = m.some((t) => t.isLoading), y = m.some((t) => t.isFetching), S = ((ut = m.find((t) => t.error)) == null ? void 0 : ut.error) || null, K = async () => {
292
+ await Promise.all(m.map((t) => t.refetch()));
293
+ }, N = lt(() => {
292
294
  const t = {};
293
- return D.query && (t.Search = D.query), T.payload && (t.Filter = T.payload), t;
294
- }, [D.query, T.payload]), {
295
- data: Q,
296
- isLoading: J,
297
- error: lt
298
- } = Pt({
299
- queryKey: ["kanban-count", d, S],
295
+ return C.debouncedQuery && (t.Search = C.debouncedQuery), c.payload && (t.Filter = c.payload), t;
296
+ }, [C.debouncedQuery, c.payload]), {
297
+ data: x,
298
+ isLoading: ft,
299
+ error: pt
300
+ } = It({
301
+ queryKey: ["kanban-count", d, N],
300
302
  queryFn: async () => {
301
303
  try {
302
- return await F(d).count(S);
304
+ return await F(d).count(N);
303
305
  } catch (t) {
304
- throw C.current && C.current(t), t;
306
+ throw h.current && h.current(k(t)), t;
305
307
  }
306
308
  },
307
309
  staleTime: 30 * 1e3,
308
310
  gcTime: 60 * 1e3
309
- }), et = j({
311
+ }), nt = R({
310
312
  mutationFn: async (t) => {
311
313
  const e = t.position ?? 999999;
312
314
  return (await F(d).create({ ...t, position: e }))._id;
313
315
  },
314
316
  onMutate: async (t) => {
315
- const e = t.columnId, r = u(e), n = ["kanban-cards", d, e, r];
316
- await p.cancelQueries({ queryKey: n });
317
- const f = p.getQueryData(n);
317
+ const e = t.columnId, r = l(e), n = ["kanban-cards", d, e, r];
318
+ await i.cancelQueries({ queryKey: n });
319
+ const f = i.getQueryData(n);
318
320
  if (f) {
319
- const U = f.Data, A = t.position ?? U.length, X = `temp-${Date.now()}`, E = {
321
+ const X = f.Data, T = t.position ?? X.length, B = `temp-${Date.now()}`, E = {
320
322
  ...t,
321
- _id: X,
322
- position: A,
323
+ _id: B,
324
+ position: T,
323
325
  _created_at: /* @__PURE__ */ new Date(),
324
326
  _modified_at: /* @__PURE__ */ new Date()
325
327
  };
326
- p.setQueryData(n, {
328
+ i.setQueryData(n, {
327
329
  ...f,
328
330
  Data: [...f.Data, E]
329
331
  });
@@ -332,87 +334,87 @@ function Xt(i) {
332
334
  },
333
335
  onSuccess: async (t, e, r) => {
334
336
  var n;
335
- r != null && r.queryKey && await p.invalidateQueries({ queryKey: r.queryKey }), (n = L.current) == null || n.call(L, {
337
+ r != null && r.queryKey && await i.invalidateQueries({ queryKey: r.queryKey }), (n = I.current) == null || n.call(I, {
336
338
  _id: t,
337
339
  ...e
338
340
  });
339
341
  },
340
342
  onError: (t, e, r) => {
341
343
  var n;
342
- r != null && r.previousCards && (r != null && r.queryKey) && p.setQueryData(r.queryKey, r.previousCards), (n = C.current) == null || n.call(C, t);
344
+ r != null && r.previousCards && (r != null && r.queryKey) && i.setQueryData(r.queryKey, r.previousCards), (n = h.current) == null || n.call(h, k(t));
343
345
  },
344
346
  onSettled: (t, e, r) => {
345
- const n = r.columnId, f = u(n);
346
- p.invalidateQueries({ queryKey: ["kanban-cards", d, n, f] });
347
+ const n = r.columnId, f = l(n);
348
+ i.invalidateQueries({ queryKey: ["kanban-cards", d, n, f] });
347
349
  }
348
- }), Z = j({
350
+ }), M = R({
349
351
  mutationFn: async ({ id: t, updates: e }) => (await F(d).update(t, e), { id: t, updates: e }),
350
- onMutate: async () => (await p.cancelQueries({ queryKey: ["kanban-cards", d] }), {}),
352
+ onMutate: async () => (await i.cancelQueries({ queryKey: ["kanban-cards", d] }), {}),
351
353
  onSuccess: async (t) => {
352
354
  var e;
353
- (e = I.current) == null || e.call(I, { _id: t.id, ...t.updates });
355
+ (e = H.current) == null || e.call(H, { _id: t.id, ...t.updates });
354
356
  },
355
357
  onError: (t, e, r) => {
356
358
  var n;
357
- (n = C.current) == null || n.call(C, t);
359
+ (n = h.current) == null || n.call(h, k(t));
358
360
  },
359
361
  onSettled: () => {
360
- p.invalidateQueries({ queryKey: ["kanban-cards", d] });
362
+ i.invalidateQueries({ queryKey: ["kanban-cards", d] });
361
363
  }
362
- }), v = j({
364
+ }), tt = R({
363
365
  mutationFn: async (t) => (await F(d).delete(t), t),
364
- onMutate: async () => (await p.cancelQueries({ queryKey: ["kanban-cards", d] }), {}),
366
+ onMutate: async () => (await i.cancelQueries({ queryKey: ["kanban-cards", d] }), {}),
365
367
  onSuccess: async (t) => {
366
368
  var e;
367
- (e = H.current) == null || e.call(H, t);
369
+ (e = U.current) == null || e.call(U, t);
368
370
  },
369
371
  onError: (t, e, r) => {
370
372
  var n;
371
- (n = C.current) == null || n.call(C, t);
373
+ (n = h.current) == null || n.call(h, k(t));
372
374
  },
373
375
  onSettled: () => {
374
- p.invalidateQueries({ queryKey: ["kanban-cards", d] });
376
+ i.invalidateQueries({ queryKey: ["kanban-cards", d] });
375
377
  }
376
- }), B = j({
378
+ }), Y = R({
377
379
  mutationFn: async ({ cardId: t, fromColumnId: e, toColumnId: r, position: n }) => {
378
380
  const f = { columnId: r, ...n !== void 0 && { position: n } };
379
381
  return await F(d).update(t, f), { cardId: t, fromColumnId: e, toColumnId: r, position: n };
380
382
  },
381
383
  onMutate: async ({ cardId: t, fromColumnId: e, toColumnId: r, position: n }) => {
382
- const f = u(e), U = u(r), A = ["kanban-cards", d, e, f], X = ["kanban-cards", d, r, U];
383
- await p.cancelQueries({ queryKey: A }), await p.cancelQueries({ queryKey: X });
384
- const E = p.getQueryData(A), N = p.getQueryData(X);
385
- if (E && N) {
386
- const st = E.Data.find((M) => M._id === t);
387
- if (st) {
388
- const M = {
384
+ const f = l(e), X = l(r), T = ["kanban-cards", d, e, f], B = ["kanban-cards", d, r, X];
385
+ await i.cancelQueries({ queryKey: T }), await i.cancelQueries({ queryKey: B });
386
+ const E = i.getQueryData(T), z = i.getQueryData(B);
387
+ if (E && z) {
388
+ const dt = E.Data.find((et) => et._id === t);
389
+ if (dt) {
390
+ const et = {
389
391
  ...E,
390
- Data: E.Data.filter((tt) => tt._id !== t)
391
- }, St = {
392
- ...st,
392
+ Data: E.Data.filter((at) => at._id !== t)
393
+ }, At = {
394
+ ...dt,
393
395
  columnId: r,
394
- position: n ?? N.Data.length,
396
+ position: n ?? z.Data.length,
395
397
  _modified_at: /* @__PURE__ */ new Date()
396
- }, Ot = {
397
- ...N,
398
- Data: [...N.Data, St].sort((tt, Kt) => tt.position - Kt.position)
398
+ }, qt = {
399
+ ...z,
400
+ Data: [...z.Data, At].sort((at, kt) => at.position - kt.position)
399
401
  };
400
- p.setQueryData(A, M), p.setQueryData(X, Ot);
402
+ i.setQueryData(T, et), i.setQueryData(B, qt);
401
403
  }
402
404
  }
403
405
  return {
404
406
  previousFromData: E,
405
- previousToData: N,
406
- fromQueryKey: A,
407
- toQueryKey: X,
407
+ previousToData: z,
408
+ fromQueryKey: T,
409
+ toQueryKey: B,
408
410
  fromColumnId: e,
409
411
  toColumnId: r
410
412
  };
411
413
  },
412
414
  onSuccess: async (t) => {
413
415
  var e;
414
- (e = $.current) == null || e.call(
415
- $,
416
+ (e = L.current) == null || e.call(
417
+ L,
416
418
  { _id: t.cardId },
417
419
  t.fromColumnId,
418
420
  t.toColumnId
@@ -420,13 +422,13 @@ function Xt(i) {
420
422
  },
421
423
  onError: (t, e, r) => {
422
424
  var n;
423
- r != null && r.previousFromData && (r != null && r.fromQueryKey) && p.setQueryData(r.fromQueryKey, r.previousFromData), r != null && r.previousToData && (r != null && r.toQueryKey) && p.setQueryData(r.toQueryKey, r.previousToData), (n = C.current) == null || n.call(C, t);
425
+ r != null && r.previousFromData && (r != null && r.fromQueryKey) && i.setQueryData(r.fromQueryKey, r.previousFromData), r != null && r.previousToData && (r != null && r.toQueryKey) && i.setQueryData(r.toQueryKey, r.previousToData), (n = h.current) == null || n.call(h, k(t));
424
426
  },
425
427
  onSettled: (t, e, r) => {
426
- const n = u(r.fromColumnId), f = u(r.toColumnId);
427
- p.invalidateQueries({ queryKey: ["kanban-cards", d, r.fromColumnId, n] }), p.invalidateQueries({ queryKey: ["kanban-cards", d, r.toColumnId, f] });
428
+ const n = l(r.fromColumnId), f = l(r.toColumnId);
429
+ i.invalidateQueries({ queryKey: ["kanban-cards", d, r.fromColumnId, n] }), i.invalidateQueries({ queryKey: ["kanban-cards", d, r.toColumnId, f] });
428
430
  }
429
- }), x = j({
431
+ }), rt = R({
430
432
  mutationFn: async ({ cardIds: t, columnId: e }) => {
431
433
  const r = t.map((n, f) => ({ id: n, position: f, columnId: e }));
432
434
  await Promise.all(
@@ -436,23 +438,23 @@ function Xt(i) {
436
438
  );
437
439
  },
438
440
  onMutate: async ({ columnId: t }) => {
439
- const e = u(t), r = ["kanban-cards", d, t, e];
440
- return await p.cancelQueries({ queryKey: r }), {};
441
+ const e = l(t), r = ["kanban-cards", d, t, e];
442
+ return await i.cancelQueries({ queryKey: r }), {};
441
443
  },
442
444
  onSuccess: () => {
443
445
  },
444
446
  onError: (t, e, r) => {
445
447
  var n;
446
- (n = C.current) == null || n.call(C, t);
448
+ (n = h.current) == null || n.call(h, k(t));
447
449
  },
448
450
  onSettled: (t, e, r) => {
449
- const n = u(r.columnId);
450
- p.invalidateQueries({ queryKey: ["kanban-cards", d, r.columnId, n] });
451
+ const n = l(r.columnId);
452
+ i.invalidateQueries({ queryKey: ["kanban-cards", d, r.columnId, n] });
451
453
  }
452
- }), gt = h(
454
+ }), ht = p(
453
455
  async (t, e, r) => {
454
456
  try {
455
- await B.mutateAsync({
457
+ await Y.mutateAsync({
456
458
  cardId: t._id,
457
459
  fromColumnId: e,
458
460
  toColumnId: r,
@@ -461,234 +463,244 @@ function Xt(i) {
461
463
  } catch {
462
464
  }
463
465
  },
464
- [B]
465
- ), R = ot(() => c.sort((t, e) => t.position - e.position).map((t, e) => {
466
+ [Y]
467
+ ), W = lt(() => u.sort((t, e) => t.position - e.position).map((t, e) => {
466
468
  var f;
467
- const n = ((f = o[e].data) == null ? void 0 : f.Data) || [];
469
+ const n = ((f = m[e].data) == null ? void 0 : f.Data) || [];
468
470
  return {
469
471
  _id: t.id,
470
472
  title: t.title,
471
473
  position: t.position,
472
474
  color: t.color,
473
475
  limit: t.limit,
474
- cards: n.sort((U, A) => U.position - A.position),
476
+ cards: n.sort((X, T) => X.position - T.position),
475
477
  _created_at: /* @__PURE__ */ new Date(),
476
478
  _modified_at: /* @__PURE__ */ new Date()
477
479
  };
478
- }), [c, o]), w = Ft({
479
- onCardMove: gt,
480
- onError: C.current,
481
- columns: R,
480
+ }), [u, m]), D = Ut({
481
+ onCardMove: ht,
482
+ onError: h.current,
483
+ columns: W,
482
484
  announceMove: (t, e, r) => {
483
485
  console.log(
484
486
  `Kanban: Moved "${t.title}" from ${e} to ${r}`
485
487
  );
486
488
  }
487
- }), yt = h(
489
+ }), Ct = p(
488
490
  (t) => {
489
491
  var e, r;
490
492
  return {
491
493
  draggable: !0,
492
494
  role: "option",
493
- "aria-selected": a && ((e = w.draggedCard) == null ? void 0 : e._id) === t._id,
494
- "aria-grabbed": a && ((r = w.draggedCard) == null ? void 0 : r._id) === t._id,
495
+ "aria-selected": a && ((e = D.draggedCard) == null ? void 0 : e._id) === t._id,
496
+ "aria-grabbed": a && ((r = D.draggedCard) == null ? void 0 : r._id) === t._id,
495
497
  onDragStart: (n) => {
496
498
  if (!a) return;
497
499
  n.dataTransfer.setData("text/plain", JSON.stringify(t));
498
500
  const f = n.nativeEvent || n;
499
- w.handleDragStart(f, t);
501
+ D.handleDragStart(f, t);
500
502
  },
501
- onDragEnd: w.handleDragEnd,
503
+ onDragEnd: D.handleDragEnd,
502
504
  onKeyDown: (n) => {
503
505
  if (!a) return;
504
506
  const f = n.nativeEvent || n;
505
- w.handleKeyDown(f, t);
507
+ D.handleKeyDown(f, t);
506
508
  }
507
509
  };
508
510
  },
509
- [a, w]
510
- ), mt = h(
511
+ [a, D]
512
+ ), Dt = p(
511
513
  (t) => ({
512
514
  "data-column-id": t,
513
515
  role: "listbox",
514
516
  onDragOver: (e) => {
515
517
  if (!a) return;
516
518
  const r = e.nativeEvent || e;
517
- w.handleDragOver(r, t);
519
+ D.handleDragOver(r, t);
518
520
  },
519
521
  onDrop: (e) => {
520
522
  if (!a) return;
521
523
  const r = e.nativeEvent || e;
522
- w.handleDrop(r, t);
524
+ D.handleDrop(r, t);
523
525
  }
524
526
  }),
525
- [a, w]
526
- ), ft = h((t) => {
527
- Y({ query: t });
528
- }, []), pt = h(() => {
529
- Y({ query: "" });
530
- }, []), ht = (Q == null ? void 0 : Q.Count) || 0, Ct = g || J, Dt = m, wt = et.isPending || Z.isPending || v.isPending || B.isPending || x.isPending, W = l || lt, _t = h(async () => {
531
- await y();
532
- }, [y]), bt = h(async () => {
533
- await p.invalidateQueries({
527
+ [a, D]
528
+ ), wt = p((t) => {
529
+ if (t.length > 255) {
530
+ console.warn("Search query exceeds maximum length of 255 characters");
531
+ return;
532
+ }
533
+ $((e) => ({ ...e, query: t })), A.current && clearTimeout(A.current), A.current = setTimeout(() => {
534
+ $((e) => ({ ...e, debouncedQuery: t }));
535
+ }, Z);
536
+ }, []), bt = p(() => {
537
+ A.current && clearTimeout(A.current), $({ query: "", debouncedQuery: "" });
538
+ }, []), _t = (x == null ? void 0 : x.Count) || 0, St = g || ft, Qt = y, Ot = nt.isPending || M.isPending || tt.isPending || Y.isPending || rt.isPending, j = S || pt, Kt = p(async () => {
539
+ await K();
540
+ }, [K]), Tt = p(async () => {
541
+ await i.invalidateQueries({
534
542
  predicate: (t) => t.queryKey[0] === "kanban-cards" || t.queryKey[0] === "kanban-count"
535
543
  });
536
- }, [p]);
537
- return rt(() => {
538
- W && C.current && C.current(W);
539
- }, [W]), {
544
+ }, [i]);
545
+ return V(() => {
546
+ j && h.current && h.current(k(j));
547
+ }, [j]), V(() => () => {
548
+ A.current && clearTimeout(A.current);
549
+ }, []), {
540
550
  // Data
541
- columns: R,
542
- totalCards: ht,
551
+ columns: W,
552
+ totalCards: _t,
543
553
  // Loading States
544
- isLoading: Ct,
545
- isFetching: Dt,
546
- isUpdating: wt,
554
+ isLoading: St,
555
+ isFetching: Qt,
556
+ isUpdating: Ot,
547
557
  // Error Handling
548
- error: W,
558
+ error: j ? k(j) : null,
549
559
  // Card Operations (Flat Access)
550
- createCard: et.mutateAsync,
551
- updateCard: h(
560
+ createCard: nt.mutateAsync,
561
+ updateCard: p(
552
562
  async (t, e) => {
553
- await Z.mutateAsync({ id: t, updates: e });
563
+ await M.mutateAsync({ id: t, updates: e });
554
564
  },
555
- [Z]
565
+ [M]
556
566
  ),
557
- deleteCard: h(
567
+ deleteCard: p(
558
568
  async (t) => {
559
- await v.mutateAsync(t);
569
+ await tt.mutateAsync(t);
560
570
  },
561
- [v]
571
+ [tt]
562
572
  ),
563
- moveCard: h(
573
+ moveCard: p(
564
574
  async (t, e, r, n) => {
565
575
  if (!n) {
566
- for (const f of R)
567
- if (f.cards.find((A) => A._id === t)) {
576
+ for (const f of W)
577
+ if (f.cards.find((T) => T._id === t)) {
568
578
  n = f._id;
569
579
  break;
570
580
  }
571
581
  if (!n)
572
582
  throw new Error(`Card ${t} not found in any column`);
573
583
  }
574
- await B.mutateAsync({ cardId: t, fromColumnId: n, toColumnId: e, position: r });
584
+ await Y.mutateAsync({ cardId: t, fromColumnId: n, toColumnId: e, position: r });
575
585
  },
576
- [B, R]
586
+ [Y, W]
577
587
  ),
578
- reorderCards: h(
588
+ reorderCards: p(
579
589
  async (t, e) => {
580
- await x.mutateAsync({ cardIds: t, columnId: e });
590
+ await rt.mutateAsync({ cardIds: t, columnId: e });
581
591
  },
582
- [x]
592
+ [rt]
583
593
  ),
584
594
  // Search (Flat Access)
585
- searchQuery: D.query,
586
- setSearchQuery: ft,
587
- clearSearch: pt,
595
+ searchQuery: C.query,
596
+ setSearchQuery: wt,
597
+ clearSearch: bt,
588
598
  // Filter (Simplified chainable API)
589
- filter: T,
599
+ filter: c,
590
600
  // Drag Drop (Flat Access)
591
- isDragging: a ? w.isDragging : !1,
592
- draggedCard: a ? w.draggedCard : null,
593
- dragOverColumn: a ? w.dragOverColumn : null,
594
- handleDragStart: a ? w.handleDragStart : () => {
601
+ isDragging: a ? D.isDragging : !1,
602
+ draggedCard: a ? D.draggedCard : null,
603
+ dragOverColumn: a ? D.dragOverColumn : null,
604
+ handleDragStart: a ? D.handleDragStart : () => {
595
605
  },
596
- handleDragOver: a ? w.handleDragOver : () => {
606
+ handleDragOver: a ? D.handleDragOver : () => {
597
607
  },
598
- handleDrop: a ? w.handleDrop : () => {
608
+ handleDrop: a ? D.handleDrop : () => {
599
609
  },
600
- handleDragEnd: a ? w.handleDragEnd : () => {
610
+ handleDragEnd: a ? D.handleDragEnd : () => {
601
611
  },
602
- handleKeyDown: a ? w.handleKeyDown : () => {
612
+ handleKeyDown: a ? D.handleKeyDown : () => {
603
613
  },
604
614
  // Prop Getters
605
- getCardProps: a ? yt : (t) => ({}),
606
- getColumnProps: a ? mt : (t) => ({}),
615
+ getCardProps: a ? Ct : (t) => ({}),
616
+ getColumnProps: a ? Dt : (t) => ({}),
607
617
  // Load More (Per Column)
608
- loadMore: h((t) => {
609
- V((e) => ({
618
+ loadMore: p((t) => {
619
+ v((e) => ({
610
620
  ...e,
611
621
  [t]: (e[t] || 10) + 10
612
622
  }));
613
623
  }, []),
614
624
  // Utilities
615
- refetch: _t,
616
- refresh: bt
625
+ refetch: Kt,
626
+ refresh: Tt
617
627
  };
618
628
  }
619
- const $t = qt(null);
620
- function Yt() {
621
- const i = Qt($t);
622
- if (!i)
629
+ const Xt = Pt(
630
+ null
631
+ );
632
+ function Jt() {
633
+ const o = Et(Xt);
634
+ if (!o)
623
635
  throw new Error(
624
636
  "Kanban components must be used within a KanbanBoard component"
625
637
  );
626
- return i;
638
+ return o;
627
639
  }
628
- function Bt(i, c) {
629
- const d = c.reduce((a, s) => (a[s.columnId] || (a[s.columnId] = []), a[s.columnId].push(s), a), {});
630
- return i.map((a) => ({
640
+ function Wt(o, u) {
641
+ const d = u.reduce((a, s) => (a[s.columnId] || (a[s.columnId] = []), a[s.columnId].push(s), a), {});
642
+ return o.map((a) => ({
631
643
  ...a,
632
- cards: (d[a._id] || []).sort((s, O) => s.position - O.position)
644
+ cards: (d[a._id] || []).sort((s, _) => s.position - _.position)
633
645
  }));
634
646
  }
635
- function Nt(i, c) {
636
- if (i.cards.length === 0)
647
+ function Gt(o, u) {
648
+ if (o.cards.length === 0)
637
649
  return 0;
638
- if (c === void 0 || c >= i.cards.length)
639
- return i.cards[i.cards.length - 1].position + 1;
640
- if (c === 0) {
641
- const s = i.cards[0];
650
+ if (u === void 0 || u >= o.cards.length)
651
+ return o.cards[o.cards.length - 1].position + 1;
652
+ if (u === 0) {
653
+ const s = o.cards[0];
642
654
  return Math.max(0, s.position - 1);
643
655
  }
644
- const d = i.cards[c - 1], a = i.cards[c];
656
+ const d = o.cards[u - 1], a = o.cards[u];
645
657
  return Math.floor((d.position + a.position) / 2);
646
658
  }
647
- function jt(i, c) {
648
- if (i.length === 0)
659
+ function Vt(o, u) {
660
+ if (o.length === 0)
649
661
  return 0;
650
- if (c === void 0 || c >= i.length)
651
- return i[i.length - 1].position + 1;
652
- if (c === 0) {
653
- const s = i[0];
662
+ if (u === void 0 || u >= o.length)
663
+ return o[o.length - 1].position + 1;
664
+ if (u === 0) {
665
+ const s = o[0];
654
666
  return Math.max(0, s.position - 1);
655
667
  }
656
- const d = i[c - 1], a = i[c];
668
+ const d = o[u - 1], a = o[u];
657
669
  return Math.floor((d.position + a.position) / 2);
658
670
  }
659
- function zt(i) {
660
- return i.sort((c, d) => c.position - d.position).map((c, d) => ({
661
- ...c,
671
+ function Zt(o) {
672
+ return o.sort((u, d) => u.position - d.position).map((u, d) => ({
673
+ ...u,
662
674
  position: d
663
675
  }));
664
676
  }
665
- function Jt(i, c, d, a) {
666
- const s = `Failed to ${c} ${d}`, O = a ? ` (ID: ${a})` : "";
667
- return i instanceof Error ? new Error(`${s}${O}: ${i.message}`) : new Error(`${s}${O}: Unknown error`);
677
+ function vt(o, u, d, a) {
678
+ const s = `Failed to ${u} ${d}`, _ = a ? ` (ID: ${a})` : "";
679
+ return o instanceof Error ? new Error(`${s}${_}: ${o.message}`) : new Error(`${s}${_}: Unknown error`);
668
680
  }
669
- function Rt(i, c) {
670
- switch (c) {
681
+ function xt(o, u) {
682
+ switch (u) {
671
683
  case "list":
672
- return i && Array.isArray(i.Data);
684
+ return o && Array.isArray(o.Data);
673
685
  case "single":
674
- return i && typeof i == "object";
686
+ return o && typeof o == "object";
675
687
  case "create":
676
- return i && typeof i._id == "string";
688
+ return o && typeof o._id == "string";
677
689
  case "delete":
678
- return i && i.status === "success";
690
+ return o && o.status === "success";
679
691
  default:
680
692
  return !1;
681
693
  }
682
694
  }
683
695
  export {
684
- $t as KanbanContext,
685
- Nt as calculateCardPosition,
686
- jt as calculateColumnPosition,
687
- Jt as handleKanbanApiError,
688
- Bt as mergeCardsIntoColumns,
689
- zt as normalizePositions,
690
- Ft as useDragDropManager,
691
- Xt as useKanban,
692
- Yt as useKanbanContext,
693
- Rt as validateApiResponse
696
+ Xt as KanbanContext,
697
+ Gt as calculateCardPosition,
698
+ Vt as calculateColumnPosition,
699
+ vt as handleKanbanApiError,
700
+ Wt as mergeCardsIntoColumns,
701
+ Zt as normalizePositions,
702
+ Ut as useDragDropManager,
703
+ Rt as useKanban,
704
+ Jt as useKanbanContext,
705
+ xt as validateApiResponse
694
706
  };