@ram_28/kf-ai-sdk 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/kanban.mjs CHANGED
@@ -1,410 +1,44 @@
1
- var $t = (a) => {
2
- throw TypeError(a);
3
- };
4
- var St = (a, e, s) => e.has(a) || $t("Cannot " + s);
5
- var l = (a, e, s) => (St(a, e, "read from private field"), s ? s.call(a) : e.get(a)), R = (a, e, s) => e.has(a) ? $t("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(a) : e.set(a, s), v = (a, e, s, t) => (St(a, e, "write to private field"), t ? t.call(a, s) : e.set(a, s), s), F = (a, e, s) => (St(a, e, "access private method"), s);
6
- import * as B from "react";
7
- import { useState as yt, useRef as G, useCallback as _, useEffect as _t, useMemo as Ht, createContext as ge, useContext as fe } from "react";
8
- import { S as Vt, s as Gt, h as It, n as ct, r as pe, Q as Wt, a as kt, b as ye, c as me, e as be, d as Ce, f as De, g as Zt, i as Ut, j as jt, w as we, k as Oe, l as Se, m as _e, u as Qe } from "./useQuery-KpZFg80c.js";
9
- import { a as M } from "./client-CfvLiGfP.js";
10
- import { u as Ee } from "./useFilter-CXFqEHyI.js";
11
- function ve() {
12
- return {
13
- context: void 0,
14
- data: void 0,
15
- error: null,
16
- failureCount: 0,
17
- failureReason: null,
18
- isPaused: !1,
19
- status: "idle",
20
- variables: void 0,
21
- submittedAt: 0
22
- };
23
- }
24
- var z, W, $, N, Y, mt, Qt, Yt, Ke = (Yt = class extends Vt {
25
- constructor(e, s) {
26
- super();
27
- R(this, Y);
28
- R(this, z);
29
- R(this, W);
30
- R(this, $);
31
- R(this, N);
32
- v(this, z, e), this.setOptions(s), this.bindMethods(), F(this, Y, mt).call(this);
33
- }
34
- bindMethods() {
35
- this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
36
- }
37
- setOptions(e) {
38
- var t;
39
- const s = this.options;
40
- this.options = l(this, z).defaultMutationOptions(e), Gt(this.options, s) || l(this, z).getMutationCache().notify({
41
- type: "observerOptionsUpdated",
42
- mutation: l(this, $),
43
- observer: this
44
- }), s != null && s.mutationKey && this.options.mutationKey && It(s.mutationKey) !== It(this.options.mutationKey) ? this.reset() : ((t = l(this, $)) == null ? void 0 : t.state.status) === "pending" && l(this, $).setOptions(this.options);
45
- }
46
- onUnsubscribe() {
47
- var e;
48
- this.hasListeners() || (e = l(this, $)) == null || e.removeObserver(this);
49
- }
50
- onMutationUpdate(e) {
51
- F(this, Y, mt).call(this), F(this, Y, Qt).call(this, e);
52
- }
53
- getCurrentResult() {
54
- return l(this, W);
55
- }
56
- reset() {
57
- var e;
58
- (e = l(this, $)) == null || e.removeObserver(this), v(this, $, void 0), F(this, Y, mt).call(this), F(this, Y, Qt).call(this);
59
- }
60
- mutate(e, s) {
61
- var t;
62
- return v(this, N, s), (t = l(this, $)) == null || t.removeObserver(this), v(this, $, l(this, z).getMutationCache().build(l(this, z), this.options)), l(this, $).addObserver(this), l(this, $).execute(e);
63
- }
64
- }, z = new WeakMap(), W = new WeakMap(), $ = new WeakMap(), N = new WeakMap(), Y = new WeakSet(), mt = function() {
65
- var s;
66
- const e = ((s = l(this, $)) == null ? void 0 : s.state) ?? ve();
67
- v(this, W, {
68
- ...e,
69
- isPending: e.status === "pending",
70
- isSuccess: e.status === "success",
71
- isError: e.status === "error",
72
- isIdle: e.status === "idle",
73
- mutate: this.mutate,
74
- reset: this.reset
75
- });
76
- }, Qt = function(e) {
77
- ct.batch(() => {
78
- var s, t, i, d, f, y, Q, E;
79
- if (l(this, N) && this.hasListeners()) {
80
- const C = l(this, W).variables, O = l(this, W).context, K = {
81
- client: l(this, z),
82
- meta: this.options.meta,
83
- mutationKey: this.options.mutationKey
84
- };
85
- if ((e == null ? void 0 : e.type) === "success") {
86
- try {
87
- (t = (s = l(this, N)).onSuccess) == null || t.call(
88
- s,
89
- e.data,
90
- C,
91
- O,
92
- K
93
- );
94
- } catch (q) {
95
- Promise.reject(q);
96
- }
97
- try {
98
- (d = (i = l(this, N)).onSettled) == null || d.call(
99
- i,
100
- e.data,
101
- null,
102
- C,
103
- O,
104
- K
105
- );
106
- } catch (q) {
107
- Promise.reject(q);
108
- }
109
- } else if ((e == null ? void 0 : e.type) === "error") {
110
- try {
111
- (y = (f = l(this, N)).onError) == null || y.call(
112
- f,
113
- e.error,
114
- C,
115
- O,
116
- K
117
- );
118
- } catch (q) {
119
- Promise.reject(q);
120
- }
121
- try {
122
- (E = (Q = l(this, N)).onSettled) == null || E.call(
123
- Q,
124
- void 0,
125
- e.error,
126
- C,
127
- O,
128
- K
129
- );
130
- } catch (q) {
131
- Promise.reject(q);
132
- }
133
- }
134
- }
135
- this.listeners.forEach((C) => {
136
- C(l(this, W));
137
- });
138
- });
139
- }, Yt);
140
- function Bt(a, e) {
141
- const s = new Set(e);
142
- return a.filter((t) => !s.has(t));
143
- }
144
- function qe(a, e, s) {
145
- const t = a.slice(0);
146
- return t[e] = s, t;
147
- }
148
- var tt, H, it, at, I, Z, lt, dt, ht, T, Et, vt, Kt, qt, Pt, Jt, Pe = (Jt = class extends Vt {
149
- constructor(e, s, t) {
150
- super();
151
- R(this, T);
152
- R(this, tt);
153
- R(this, H);
154
- R(this, it);
155
- R(this, at);
156
- R(this, I);
157
- R(this, Z);
158
- R(this, lt);
159
- R(this, dt);
160
- R(this, ht, []);
161
- v(this, tt, e), v(this, at, t), v(this, it, []), v(this, I, []), v(this, H, []), this.setQueries(s);
162
- }
163
- onSubscribe() {
164
- this.listeners.size === 1 && l(this, I).forEach((e) => {
165
- e.subscribe((s) => {
166
- F(this, T, qt).call(this, e, s);
167
- });
168
- });
169
- }
170
- onUnsubscribe() {
171
- this.listeners.size || this.destroy();
172
- }
173
- destroy() {
174
- this.listeners = /* @__PURE__ */ new Set(), l(this, I).forEach((e) => {
175
- e.destroy();
176
- });
177
- }
178
- setQueries(e, s) {
179
- if (v(this, it, e), v(this, at, s), process.env.NODE_ENV !== "production") {
180
- const t = e.map(
181
- (i) => l(this, tt).defaultQueryOptions(i).queryHash
182
- );
183
- new Set(t).size !== t.length && console.warn(
184
- "[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior."
185
- );
186
- }
187
- ct.batch(() => {
188
- const t = l(this, I), i = F(this, T, Kt).call(this, l(this, it));
189
- i.forEach(
190
- (O) => O.observer.setOptions(O.defaultedQueryOptions)
191
- );
192
- const d = i.map((O) => O.observer), f = d.map(
193
- (O) => O.getCurrentResult()
194
- ), y = t.length !== d.length, Q = d.some(
195
- (O, K) => O !== t[K]
196
- ), E = y || Q, C = E ? !0 : f.some((O, K) => {
197
- const q = l(this, H)[K];
198
- return !q || !Gt(O, q);
199
- });
200
- !E && !C || (E && (v(this, ht, i), v(this, I, d)), v(this, H, f), this.hasListeners() && (E && (Bt(t, d).forEach((O) => {
201
- O.destroy();
202
- }), Bt(d, t).forEach((O) => {
203
- O.subscribe((K) => {
204
- F(this, T, qt).call(this, O, K);
205
- });
206
- })), F(this, T, Pt).call(this)));
207
- });
208
- }
209
- getCurrentResult() {
210
- return l(this, H);
211
- }
212
- getQueries() {
213
- return l(this, I).map((e) => e.getCurrentQuery());
214
- }
215
- getObservers() {
216
- return l(this, I);
217
- }
218
- getOptimisticResult(e, s) {
219
- const t = F(this, T, Kt).call(this, e), i = t.map(
220
- (d) => d.observer.getOptimisticResult(d.defaultedQueryOptions)
221
- );
222
- return [
223
- i,
224
- (d) => F(this, T, vt).call(this, d ?? i, s),
225
- () => F(this, T, Et).call(this, i, t)
226
- ];
227
- }
228
- }, tt = new WeakMap(), H = new WeakMap(), it = new WeakMap(), at = new WeakMap(), I = new WeakMap(), Z = new WeakMap(), lt = new WeakMap(), dt = new WeakMap(), ht = new WeakMap(), T = new WeakSet(), Et = function(e, s) {
229
- return s.map((t, i) => {
230
- const d = e[i];
231
- return t.defaultedQueryOptions.notifyOnChangeProps ? d : t.observer.trackResult(d, (f) => {
232
- s.forEach((y) => {
233
- y.observer.trackProp(f);
234
- });
235
- });
236
- });
237
- }, vt = function(e, s) {
238
- return s ? ((!l(this, Z) || l(this, H) !== l(this, dt) || s !== l(this, lt)) && (v(this, lt, s), v(this, dt, l(this, H)), v(this, Z, pe(
239
- l(this, Z),
240
- s(e)
241
- ))), l(this, Z)) : e;
242
- }, Kt = function(e) {
243
- const s = /* @__PURE__ */ new Map();
244
- l(this, I).forEach((i) => {
245
- const d = i.options.queryHash;
246
- if (!d) return;
247
- const f = s.get(d);
248
- f ? f.push(i) : s.set(d, [i]);
249
- });
250
- const t = [];
251
- return e.forEach((i) => {
252
- var Q;
253
- const d = l(this, tt).defaultQueryOptions(i), y = ((Q = s.get(d.queryHash)) == null ? void 0 : Q.shift()) ?? new Wt(l(this, tt), d);
254
- t.push({
255
- defaultedQueryOptions: d,
256
- observer: y
257
- });
258
- }), t;
259
- }, qt = function(e, s) {
260
- const t = l(this, I).indexOf(e);
261
- t !== -1 && (v(this, H, qe(l(this, H), t, s)), F(this, T, Pt).call(this));
262
- }, Pt = function() {
263
- var e;
264
- if (this.hasListeners()) {
265
- const s = l(this, Z), t = F(this, T, Et).call(this, l(this, H), l(this, ht)), i = F(this, T, vt).call(this, t, (e = l(this, at)) == null ? void 0 : e.combine);
266
- s !== i && ct.batch(() => {
267
- this.listeners.forEach((d) => {
268
- d(l(this, H));
269
- });
270
- });
271
- }
272
- }, Jt);
273
- function ke({
274
- queries: a,
275
- ...e
276
- }, s) {
277
- const t = kt(), i = ye(), d = me(), f = B.useMemo(
278
- () => a.map((g) => {
279
- const P = t.defaultQueryOptions(
280
- g
281
- );
282
- return P._optimisticResults = i ? "isRestoring" : "optimistic", P;
283
- }),
284
- [a, t, i]
285
- );
286
- f.forEach((g) => {
287
- be(g);
288
- const P = t.getQueryCache().get(g.queryHash);
289
- Ce(g, d, P);
290
- }), De(d);
291
- const [y] = B.useState(
292
- () => new Pe(
293
- t,
294
- f,
295
- e
296
- )
297
- ), [Q, E, C] = y.getOptimisticResult(
298
- f,
299
- e.combine
300
- ), O = !i && e.subscribed !== !1;
301
- B.useSyncExternalStore(
302
- B.useCallback(
303
- (g) => O ? y.subscribe(ct.batchCalls(g)) : Zt,
304
- [y, O]
305
- ),
306
- () => y.getCurrentResult(),
307
- () => y.getCurrentResult()
308
- ), B.useEffect(() => {
309
- y.setQueries(
310
- f,
311
- e
312
- );
313
- }, [f, e, y]);
314
- const q = Q.some(
315
- (g, P) => Ut(f[P], g)
316
- ) ? Q.flatMap((g, P) => {
317
- const k = f[P];
318
- if (k) {
319
- const X = new Wt(t, k);
320
- if (Ut(k, g))
321
- return jt(k, X, d);
322
- we(g, i) && jt(k, X, d);
323
- }
324
- return [];
325
- }) : [];
326
- if (q.length > 0)
327
- throw Promise.all(q);
328
- const J = Q.find(
329
- (g, P) => {
330
- const k = f[P];
331
- return k && Oe({
332
- result: g,
333
- errorResetBoundary: d,
334
- throwOnError: k.throwOnError,
335
- query: t.getQueryCache().get(k.queryHash),
336
- suspense: k.suspense
337
- });
338
- }
339
- );
340
- if (J != null && J.error)
341
- throw J.error;
342
- return E(C());
343
- }
344
- function ut(a, e) {
345
- const s = kt(), [t] = B.useState(
346
- () => new Ke(
347
- s,
348
- a
349
- )
350
- );
351
- B.useEffect(() => {
352
- t.setOptions(a);
353
- }, [t, a]);
354
- const i = B.useSyncExternalStore(
355
- B.useCallback(
356
- (f) => t.subscribe(ct.batchCalls(f)),
357
- [t]
358
- ),
359
- () => t.getCurrentResult(),
360
- () => t.getCurrentResult()
361
- ), d = B.useCallback(
362
- (f, y) => {
363
- t.mutate(f, y).catch(Zt);
364
- },
365
- [t]
366
- );
367
- if (i.error && Se(t.options.throwOnError, [i.error]))
368
- throw i.error;
369
- return { ...i, mutate: d, mutateAsync: i.mutate };
370
- }
371
- const Xt = 50, zt = 5, Nt = 5;
372
- function Ae({
373
- onCardMove: a,
374
- onError: e,
375
- columns: s,
376
- announceMove: t
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,
9
+ columns: d,
10
+ announceMove: a
377
11
  }) {
378
- const [i, d] = yt({
12
+ const [s, O] = G({
379
13
  isDragging: !1,
380
14
  draggedCard: null,
381
15
  dragOverColumn: null,
382
16
  dragOverPosition: null,
383
17
  dragSourceColumn: null
384
- }), f = G(null), y = G(null), Q = G(null), E = _(() => {
385
- d({
18
+ }), q = k(null), _ = k(null), K = k(null), b = h(() => {
19
+ O({
386
20
  isDragging: !1,
387
21
  draggedCard: null,
388
22
  dragOverColumn: null,
389
23
  dragOverPosition: null,
390
24
  dragSourceColumn: null
391
- }), y.current && (clearTimeout(y.current), y.current = null);
392
- }, []), C = _((h) => s.find((c) => c._id === h) || null, [s]), O = _((h) => {
393
- for (const c of s) {
394
- const m = c.cards.find((D) => D._id === h);
395
- if (m)
396
- return { card: m, column: c };
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 };
397
31
  }
398
32
  return null;
399
- }, [s]), K = _((h, c) => {
400
- var m, D;
33
+ }, [d]), P = h((u, o) => {
34
+ var g, m;
401
35
  try {
402
- const p = h.target, b = C(c.columnId);
403
- if (!b)
36
+ const l = u.target, y = D(o.columnId);
37
+ if (!y)
404
38
  throw new Error("Source column not found");
405
- (m = h.dataTransfer) == null || m.setData("text/plain", c._id), (D = h.dataTransfer) == null || D.setData("application/json", JSON.stringify(c));
406
- const L = p.cloneNode(!0);
407
- L.style.cssText = `
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);
41
+ S.style.cssText = `
408
42
  position: fixed;
409
43
  top: -1000px;
410
44
  left: -1000px;
@@ -416,645 +50,645 @@ function Ae({
416
50
  max-width: 300px;
417
51
  background: white;
418
52
  border-radius: 8px;
419
- `, document.body.appendChild(L), f.current = L, h.dataTransfer && h.dataTransfer.setDragImage(L, h.offsetX || 50, h.offsetY || 20), d({
53
+ `, document.body.appendChild(S), q.current = S, u.dataTransfer && u.dataTransfer.setDragImage(S, u.offsetX || 50, u.offsetY || 20), O({
420
54
  isDragging: !0,
421
- draggedCard: c,
55
+ draggedCard: o,
422
56
  dragOverColumn: null,
423
57
  dragOverPosition: null,
424
- dragSourceColumn: b._id
425
- }), t == null || t(c, b.title, "being moved");
426
- } catch (p) {
427
- e == null || e(p instanceof Error ? p : new Error("Drag start failed")), E();
58
+ 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();
428
62
  }
429
- }, [C, e, E, t]), q = _((h, c) => {
430
- if (h.preventDefault(), !i.isDragging || !i.draggedCard) return;
431
- const m = c ? C(c) : null;
432
- d((D) => ({
433
- ...D,
434
- dragOverColumn: (m == null ? void 0 : m._id) || null,
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) => ({
67
+ ...m,
68
+ dragOverColumn: (g == null ? void 0 : g._id) || null,
435
69
  dragOverPosition: null
436
70
  // Will be calculated based on mouse position
437
- })), P(h);
438
- }, [i.isDragging, i.draggedCard, C]), J = _((h, c) => {
439
- if (h.preventDefault(), !(!i.isDragging || !i.draggedCard))
71
+ })), $(u);
72
+ }, [s.isDragging, s.draggedCard, D]), V = h((u, o) => {
73
+ if (u.preventDefault(), !(!s.isDragging || !s.draggedCard))
440
74
  try {
441
- const m = i.draggedCard, D = i.dragSourceColumn, p = C(c), b = C(D);
442
- if (!p || !b)
75
+ const g = s.draggedCard, m = s.dragSourceColumn, l = D(o), y = D(m);
76
+ if (!l || !y)
443
77
  throw new Error("Target or source column not found");
444
- if (D === c) {
445
- E();
78
+ if (m === o) {
79
+ b();
446
80
  return;
447
81
  }
448
- if (p.limit && p.cards.length >= p.limit)
449
- throw new Error(`Column "${p.title}" has reached its limit of ${p.limit} cards`);
450
- a == null || a(m, D, c), t == null || t(m, b.title, p.title);
451
- } catch (m) {
452
- e == null || e(m instanceof Error ? m : new Error("Drop failed"));
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"));
453
87
  } finally {
454
- E();
88
+ b();
455
89
  }
456
- }, [i, C, a, e, E, t]), g = _(() => {
457
- f.current && (document.body.removeChild(f.current), f.current = null), E();
458
- }, [E]), P = _((h) => {
459
- const c = h.target.closest(".kanban-container");
460
- if (!c) return;
461
- const m = c.getBoundingClientRect(), D = h.clientX - m.left, p = m.width;
462
- let b = 0;
463
- if (D < Xt ? b = -zt : D > p - Xt && (b = zt), b !== 0) {
464
- y.current && clearTimeout(y.current);
465
- const L = () => {
466
- c.scrollLeft += b, y.current = setTimeout(L, 16);
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;
96
+ let y = 0;
97
+ if (m < ct ? y = -dt : m > l - ct && (y = dt), y !== 0) {
98
+ _.current && clearTimeout(_.current);
99
+ const S = () => {
100
+ o.scrollLeft += y, _.current = setTimeout(S, 16);
467
101
  };
468
- y.current = setTimeout(L, 100);
102
+ _.current = setTimeout(S, 100);
469
103
  } else
470
- y.current && (clearTimeout(y.current), y.current = null);
471
- }, []), k = _((h, c) => {
472
- if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter", "Space", "Escape"].includes(h.key))
104
+ _.current && (clearTimeout(_.current), _.current = null);
105
+ }, []), L = h((u, o) => {
106
+ if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter", "Space", "Escape"].includes(u.key))
473
107
  return;
474
- h.preventDefault();
475
- const m = O(c._id);
476
- if (!m) return;
477
- const { column: D } = m, p = s.findIndex((b) => b._id === D._id);
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);
478
112
  try {
479
- switch (h.key) {
113
+ switch (u.key) {
480
114
  case "ArrowLeft":
481
- if (p > 0) {
482
- const b = s[p - 1];
483
- a == null || a(c, D._id, b._id), t == null || t(c, D.title, b.title);
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);
484
118
  }
485
119
  break;
486
120
  case "ArrowRight":
487
- if (p < s.length - 1) {
488
- const b = s[p + 1];
489
- a == null || a(c, D._id, b._id), t == null || t(c, D.title, b.title);
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);
490
124
  }
491
125
  break;
492
126
  case "ArrowUp":
493
- t == null || t(c, "current position", "position above");
127
+ a == null || a(o, "current position", "position above");
494
128
  break;
495
129
  case "ArrowDown":
496
- t == null || t(c, "current position", "position below");
130
+ a == null || a(o, "current position", "position below");
497
131
  break;
498
132
  case "Enter":
499
133
  case "Space":
500
- t == null || t(c, D.title, "drag mode");
134
+ a == null || a(o, m.title, "drag mode");
501
135
  break;
502
136
  case "Escape":
503
- t == null || t(c, "drag mode", "cancelled");
137
+ a == null || a(o, "drag mode", "cancelled");
504
138
  break;
505
139
  }
506
- } catch (b) {
507
- e == null || e(b instanceof Error ? b : new Error("Keyboard navigation failed"));
140
+ } catch (y) {
141
+ c == null || c(y instanceof Error ? y : new Error("Keyboard navigation failed"));
508
142
  }
509
- }, [O, s, a, e, t]), X = _((h, c) => {
510
- const m = h.touches[0];
511
- Q.current = {
512
- x: m.clientX,
513
- y: m.clientY,
514
- card: c
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
515
149
  };
516
- }, []), et = _((h) => {
517
- if (!Q.current) return;
518
- const c = h.touches[0], m = Math.abs(c.clientX - Q.current.x), D = Math.abs(c.clientY - Q.current.y);
519
- if (m > Nt || D > Nt) {
520
- const p = Q.current.card, b = C(p.columnId);
521
- if (!b) return;
522
- d({
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);
155
+ if (!y) return;
156
+ O({
523
157
  isDragging: !0,
524
- draggedCard: p,
158
+ draggedCard: l,
525
159
  dragOverColumn: null,
526
160
  dragOverPosition: null,
527
- dragSourceColumn: b._id
528
- }), t == null || t(p, b.title, "being moved");
161
+ dragSourceColumn: y._id
162
+ }), a == null || a(l, y.title, "being moved");
529
163
  }
530
- }, [C, t]), S = _((h) => {
531
- if (!i.isDragging || !i.draggedCard || !Q.current) {
532
- Q.current = null;
164
+ }, [D, a]), p = h((u) => {
165
+ if (!s.isDragging || !s.draggedCard || !K.current) {
166
+ K.current = null;
533
167
  return;
534
168
  }
535
169
  try {
536
- const c = h.changedTouches[0], m = document.elementFromPoint(c.clientX, c.clientY), D = m == null ? void 0 : m.closest("[data-column-id]");
537
- if (D) {
538
- const p = D.dataset.columnId, b = i.draggedCard, L = i.dragSourceColumn, U = C(p), gt = C(L);
539
- if (U && gt && L !== p) {
540
- if (U.limit && U.cards.length >= U.limit)
541
- throw new Error(`Column "${U.title}" has reached its limit of ${U.limit} cards`);
542
- a == null || a(b, L, p), t == null || t(b, gt.title, U.title);
170
+ const o = u.changedTouches[0], g = document.elementFromPoint(o.clientX, o.clientY), m = g == null ? void 0 : g.closest("[data-column-id]");
171
+ 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);
543
177
  }
544
178
  }
545
- } catch (c) {
546
- e == null || e(c instanceof Error ? c : new Error("Touch drop failed"));
179
+ } catch (o) {
180
+ c == null || c(o instanceof Error ? o : new Error("Touch drop failed"));
547
181
  } finally {
548
- Q.current = null, E();
182
+ K.current = null, b();
549
183
  }
550
- }, [i, C, a, e, E, t]), V = _((h, c, m) => {
551
- const D = `Moved "${h.title}" from ${c} to ${m}`, p = document.createElement("div");
552
- p.setAttribute("aria-live", "polite"), p.setAttribute("aria-atomic", "true"), p.className = "sr-only", p.textContent = D, document.body.appendChild(p), setTimeout(() => {
553
- document.body.removeChild(p);
554
- }, 1e3), console.log(`Kanban: ${D}`);
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);
188
+ }, 1e3), console.log(`Kanban: ${m}`);
555
189
  }, []);
556
- return _t(() => () => {
557
- y.current && clearTimeout(y.current), f.current && document.body.contains(f.current) && document.body.removeChild(f.current);
190
+ return rt(() => () => {
191
+ _.current && clearTimeout(_.current), q.current && document.body.contains(q.current) && document.body.removeChild(q.current);
558
192
  }, []), {
559
193
  // State
560
- isDragging: i.isDragging,
561
- draggedCard: i.draggedCard,
562
- dragOverColumn: i.dragOverColumn,
563
- dragOverPosition: i.dragOverPosition,
564
- dragSourceColumn: i.dragSourceColumn,
194
+ isDragging: s.isDragging,
195
+ draggedCard: s.draggedCard,
196
+ dragOverColumn: s.dragOverColumn,
197
+ dragOverPosition: s.dragOverPosition,
198
+ dragSourceColumn: s.dragSourceColumn,
565
199
  // Handlers
566
- handleDragStart: K,
567
- handleDragOver: q,
568
- handleDrop: J,
569
- handleDragEnd: g,
570
- handleKeyDown: k,
571
- handleTouchStart: X,
572
- handleTouchMove: et,
573
- handleTouchEnd: S,
200
+ handleDragStart: P,
201
+ handleDragOver: z,
202
+ handleDrop: V,
203
+ handleDragEnd: C,
204
+ handleKeyDown: L,
205
+ handleTouchStart: I,
206
+ handleTouchMove: H,
207
+ handleTouchEnd: p,
574
208
  // Utilities
575
- announceMove: t || V,
576
- reset: E
209
+ announceMove: a || T,
210
+ reset: b
577
211
  };
578
212
  }
579
- function Ie(a) {
580
- var Tt, Rt, Ft;
213
+ function Xt(i) {
214
+ var at, nt, it;
581
215
  const {
582
- columns: e,
583
- source: s,
584
- enableDragDrop: t = !0,
585
- initialState: i,
586
- onCardMove: d,
587
- onCardCreate: f,
588
- onCardUpdate: y,
589
- onCardDelete: Q,
590
- onError: E
591
- } = a, [C, O] = yt({
592
- query: (i == null ? void 0 : i.search) || ""
593
- }), [K] = yt({
594
- field: ((Tt = i == null ? void 0 : i.sorting) == null ? void 0 : Tt.field) || null,
595
- direction: ((Rt = i == null ? void 0 : i.sorting) == null ? void 0 : Rt.direction) || null
596
- }), [q, J] = yt(() => {
597
- const r = {};
598
- return e.forEach((o) => {
599
- r[o.id] = 10;
600
- }), r;
601
- }), g = G(E), P = G(d), k = G(f), X = G(y), et = G(Q);
602
- _t(() => {
603
- g.current = E, P.current = d, k.current = f, X.current = y, et.current = Q;
604
- }, [E, d, f, y, Q]);
605
- const S = kt(), V = Ee({
606
- initialConditions: i == null ? void 0 : i.filters,
607
- initialOperator: (i == null ? void 0 : i.filterOperator) || "And"
608
- }), h = _((r) => {
609
- const o = {
216
+ columns: c,
217
+ source: d,
218
+ enableDragDrop: a = !0,
219
+ initialState: s,
220
+ onCardMove: O,
221
+ onCardCreate: q,
222
+ onCardUpdate: _,
223
+ onCardDelete: K,
224
+ 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(() => {
231
+ const t = {};
232
+ return c.forEach((e) => {
233
+ t[e.id] = 10;
234
+ }), 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) => {
243
+ const e = {
610
244
  LHSField: "columnId",
611
245
  Operator: "EQ",
612
- RHSValue: r,
246
+ RHSValue: t,
613
247
  RHSType: "Constant"
614
- }, n = V.payload;
615
- let u;
616
- n ? n.Operator === "And" ? u = {
617
- ...n,
618
- Condition: [...n.Condition || [], o]
619
- } : u = {
248
+ }, r = T.payload;
249
+ let n;
250
+ r ? r.Operator === "And" ? n = {
251
+ ...r,
252
+ Condition: [...r.Condition || [], e]
253
+ } : n = {
620
254
  Operator: "And",
621
- Condition: [n, o]
622
- } : u = {
255
+ Condition: [r, e]
256
+ } : n = {
623
257
  Operator: "And",
624
- Condition: [o]
258
+ Condition: [e]
625
259
  };
626
- const w = {
260
+ const f = {
627
261
  Page: 1,
628
262
  // Always page 1 due to expanding PageSize strategy
629
- PageSize: q[r] || 10,
630
- Filter: u
263
+ PageSize: z[t] || 10,
264
+ Filter: n
631
265
  };
632
- return K.field && K.direction ? w.Sort = [
633
- { [String(K.field)]: K.direction === "asc" ? "ASC" : "DESC" },
266
+ return P.field && P.direction ? f.Sort = [
267
+ { [String(P.field)]: P.direction === "asc" ? "ASC" : "DESC" },
634
268
  { position: "ASC" }
635
- ] : w.Sort = [
269
+ ] : f.Sort = [
636
270
  { columnId: "ASC" },
637
271
  { position: "ASC" }
638
- ], C.query && (w.Search = C.query), w;
639
- }, [V.payload, q, K, C.query]), c = ke({
640
- queries: e.map((r) => {
641
- const o = h(r.id);
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);
642
276
  return {
643
- queryKey: ["kanban-cards", s, r.id, o],
277
+ queryKey: ["kanban-cards", d, t.id, e],
644
278
  queryFn: async () => {
645
279
  try {
646
- return await M(s).list(o);
647
- } catch (n) {
648
- throw n;
280
+ return await F(d).list(e);
281
+ } catch (r) {
282
+ throw r;
649
283
  }
650
284
  },
651
- placeholderData: _e,
285
+ placeholderData: kt,
652
286
  staleTime: 30 * 1e3
653
287
  };
654
288
  })
655
- }), m = c.some((r) => r.isLoading), D = c.some((r) => r.isFetching), p = ((Ft = c.find((r) => r.error)) == null ? void 0 : Ft.error) || null, b = async () => {
656
- await Promise.all(c.map((r) => r.refetch()));
657
- }, L = Ht(() => {
658
- const r = {};
659
- return C.query && (r.Search = C.query), V.payload && (r.Filter = V.payload), r;
660
- }, [C.query, V.payload]), {
661
- data: U,
662
- isLoading: gt,
663
- error: xt
664
- } = Qe({
665
- queryKey: ["kanban-count", s, L],
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(() => {
292
+ 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],
666
300
  queryFn: async () => {
667
301
  try {
668
- return await M(s).count(L);
669
- } catch (r) {
670
- throw g.current && g.current(r), r;
302
+ return await F(d).count(S);
303
+ } catch (t) {
304
+ throw C.current && C.current(t), t;
671
305
  }
672
306
  },
673
307
  staleTime: 30 * 1e3,
674
308
  gcTime: 60 * 1e3
675
- }), At = ut({
676
- mutationFn: async (r) => {
677
- const o = r.position ?? 999999;
678
- return (await M(s).create({ ...r, position: o }))._id;
309
+ }), et = j({
310
+ mutationFn: async (t) => {
311
+ const e = t.position ?? 999999;
312
+ return (await F(d).create({ ...t, position: e }))._id;
679
313
  },
680
- onMutate: async (r) => {
681
- const o = r.columnId, n = h(o), u = ["kanban-cards", s, o, n];
682
- await S.cancelQueries({ queryKey: u });
683
- const w = S.getQueryData(u);
684
- if (w) {
685
- const rt = w.Data, j = r.position ?? rt.length, st = `temp-${Date.now()}`, x = {
686
- ...r,
687
- _id: st,
688
- position: j,
314
+ 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);
318
+ if (f) {
319
+ const U = f.Data, A = t.position ?? U.length, X = `temp-${Date.now()}`, E = {
320
+ ...t,
321
+ _id: X,
322
+ position: A,
689
323
  _created_at: /* @__PURE__ */ new Date(),
690
324
  _modified_at: /* @__PURE__ */ new Date()
691
325
  };
692
- S.setQueryData(u, {
693
- ...w,
694
- Data: [...w.Data, x]
326
+ p.setQueryData(n, {
327
+ ...f,
328
+ Data: [...f.Data, E]
695
329
  });
696
330
  }
697
- return { previousCards: w, queryKey: u };
331
+ return { previousCards: f, queryKey: n };
698
332
  },
699
- onSuccess: async (r, o, n) => {
700
- var u;
701
- n != null && n.queryKey && await S.invalidateQueries({ queryKey: n.queryKey }), (u = k.current) == null || u.call(k, {
702
- _id: r,
703
- ...o
333
+ onSuccess: async (t, e, r) => {
334
+ var n;
335
+ r != null && r.queryKey && await p.invalidateQueries({ queryKey: r.queryKey }), (n = L.current) == null || n.call(L, {
336
+ _id: t,
337
+ ...e
704
338
  });
705
339
  },
706
- onError: (r, o, n) => {
707
- var u;
708
- n != null && n.previousCards && (n != null && n.queryKey) && S.setQueryData(n.queryKey, n.previousCards), (u = g.current) == null || u.call(g, r);
340
+ onError: (t, e, r) => {
341
+ 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);
709
343
  },
710
- onSettled: (r, o, n) => {
711
- const u = n.columnId, w = h(u);
712
- S.invalidateQueries({ queryKey: ["kanban-cards", s, u, w] });
344
+ onSettled: (t, e, r) => {
345
+ const n = r.columnId, f = u(n);
346
+ p.invalidateQueries({ queryKey: ["kanban-cards", d, n, f] });
713
347
  }
714
- }), bt = ut({
715
- mutationFn: async ({ id: r, updates: o }) => (await M(s).update(r, o), { id: r, updates: o }),
716
- onMutate: async () => (await S.cancelQueries({ queryKey: ["kanban-cards", s] }), {}),
717
- onSuccess: async (r) => {
718
- var o;
719
- (o = X.current) == null || o.call(X, { _id: r.id, ...r.updates });
348
+ }), Z = j({
349
+ 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] }), {}),
351
+ onSuccess: async (t) => {
352
+ var e;
353
+ (e = I.current) == null || e.call(I, { _id: t.id, ...t.updates });
720
354
  },
721
- onError: (r, o, n) => {
722
- var u;
723
- (u = g.current) == null || u.call(g, r);
355
+ onError: (t, e, r) => {
356
+ var n;
357
+ (n = C.current) == null || n.call(C, t);
724
358
  },
725
359
  onSettled: () => {
726
- S.invalidateQueries({ queryKey: ["kanban-cards", s] });
360
+ p.invalidateQueries({ queryKey: ["kanban-cards", d] });
727
361
  }
728
- }), Ct = ut({
729
- mutationFn: async (r) => (await M(s).delete(r), r),
730
- onMutate: async () => (await S.cancelQueries({ queryKey: ["kanban-cards", s] }), {}),
731
- onSuccess: async (r) => {
732
- var o;
733
- (o = et.current) == null || o.call(et, r);
362
+ }), v = j({
363
+ mutationFn: async (t) => (await F(d).delete(t), t),
364
+ onMutate: async () => (await p.cancelQueries({ queryKey: ["kanban-cards", d] }), {}),
365
+ onSuccess: async (t) => {
366
+ var e;
367
+ (e = H.current) == null || e.call(H, t);
734
368
  },
735
- onError: (r, o, n) => {
736
- var u;
737
- (u = g.current) == null || u.call(g, r);
369
+ onError: (t, e, r) => {
370
+ var n;
371
+ (n = C.current) == null || n.call(C, t);
738
372
  },
739
373
  onSettled: () => {
740
- S.invalidateQueries({ queryKey: ["kanban-cards", s] });
374
+ p.invalidateQueries({ queryKey: ["kanban-cards", d] });
741
375
  }
742
- }), nt = ut({
743
- mutationFn: async ({ cardId: r, fromColumnId: o, toColumnId: n, position: u }) => {
744
- const w = { columnId: n, ...u !== void 0 && { position: u } };
745
- return await M(s).update(r, w), { cardId: r, fromColumnId: o, toColumnId: n, position: u };
376
+ }), B = j({
377
+ mutationFn: async ({ cardId: t, fromColumnId: e, toColumnId: r, position: n }) => {
378
+ const f = { columnId: r, ...n !== void 0 && { position: n } };
379
+ return await F(d).update(t, f), { cardId: t, fromColumnId: e, toColumnId: r, position: n };
746
380
  },
747
- onMutate: async ({ cardId: r, fromColumnId: o, toColumnId: n, position: u }) => {
748
- const w = h(o), rt = h(n), j = ["kanban-cards", s, o, w], st = ["kanban-cards", s, n, rt];
749
- await S.cancelQueries({ queryKey: j }), await S.cancelQueries({ queryKey: st });
750
- const x = S.getQueryData(j), ot = S.getQueryData(st);
751
- if (x && ot) {
752
- const Lt = x.Data.find((wt) => wt._id === r);
753
- if (Lt) {
754
- const wt = {
755
- ...x,
756
- Data: x.Data.filter((Ot) => Ot._id !== r)
757
- }, le = {
758
- ...Lt,
759
- columnId: n,
760
- position: u ?? ot.Data.length,
381
+ 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 = {
389
+ ...E,
390
+ Data: E.Data.filter((tt) => tt._id !== t)
391
+ }, St = {
392
+ ...st,
393
+ columnId: r,
394
+ position: n ?? N.Data.length,
761
395
  _modified_at: /* @__PURE__ */ new Date()
762
- }, de = {
763
- ...ot,
764
- Data: [...ot.Data, le].sort((Ot, he) => Ot.position - he.position)
396
+ }, Ot = {
397
+ ...N,
398
+ Data: [...N.Data, St].sort((tt, Kt) => tt.position - Kt.position)
765
399
  };
766
- S.setQueryData(j, wt), S.setQueryData(st, de);
400
+ p.setQueryData(A, M), p.setQueryData(X, Ot);
767
401
  }
768
402
  }
769
403
  return {
770
- previousFromData: x,
771
- previousToData: ot,
772
- fromQueryKey: j,
773
- toQueryKey: st,
774
- fromColumnId: o,
775
- toColumnId: n
404
+ previousFromData: E,
405
+ previousToData: N,
406
+ fromQueryKey: A,
407
+ toQueryKey: X,
408
+ fromColumnId: e,
409
+ toColumnId: r
776
410
  };
777
411
  },
778
- onSuccess: async (r) => {
779
- var o;
780
- (o = P.current) == null || o.call(
781
- P,
782
- { _id: r.cardId },
783
- r.fromColumnId,
784
- r.toColumnId
412
+ onSuccess: async (t) => {
413
+ var e;
414
+ (e = $.current) == null || e.call(
415
+ $,
416
+ { _id: t.cardId },
417
+ t.fromColumnId,
418
+ t.toColumnId
785
419
  );
786
420
  },
787
- onError: (r, o, n) => {
788
- var u;
789
- n != null && n.previousFromData && (n != null && n.fromQueryKey) && S.setQueryData(n.fromQueryKey, n.previousFromData), n != null && n.previousToData && (n != null && n.toQueryKey) && S.setQueryData(n.toQueryKey, n.previousToData), (u = g.current) == null || u.call(g, r);
421
+ onError: (t, e, r) => {
422
+ 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);
790
424
  },
791
- onSettled: (r, o, n) => {
792
- const u = h(n.fromColumnId), w = h(n.toColumnId);
793
- S.invalidateQueries({ queryKey: ["kanban-cards", s, n.fromColumnId, u] }), S.invalidateQueries({ queryKey: ["kanban-cards", s, n.toColumnId, w] });
425
+ 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] });
794
428
  }
795
- }), Dt = ut({
796
- mutationFn: async ({ cardIds: r, columnId: o }) => {
797
- const n = r.map((u, w) => ({ id: u, position: w, columnId: o }));
429
+ }), x = j({
430
+ mutationFn: async ({ cardIds: t, columnId: e }) => {
431
+ const r = t.map((n, f) => ({ id: n, position: f, columnId: e }));
798
432
  await Promise.all(
799
- n.map(
800
- (u) => M(s).update(u.id, { position: u.position, columnId: u.columnId })
433
+ r.map(
434
+ (n) => F(d).update(n.id, { position: n.position, columnId: n.columnId })
801
435
  )
802
436
  );
803
437
  },
804
- onMutate: async ({ columnId: r }) => {
805
- const o = h(r), n = ["kanban-cards", s, r, o];
806
- return await S.cancelQueries({ queryKey: n }), {};
438
+ onMutate: async ({ columnId: t }) => {
439
+ const e = u(t), r = ["kanban-cards", d, t, e];
440
+ return await p.cancelQueries({ queryKey: r }), {};
807
441
  },
808
442
  onSuccess: () => {
809
443
  },
810
- onError: (r, o, n) => {
811
- var u;
812
- (u = g.current) == null || u.call(g, r);
444
+ onError: (t, e, r) => {
445
+ var n;
446
+ (n = C.current) == null || n.call(C, t);
813
447
  },
814
- onSettled: (r, o, n) => {
815
- const u = h(n.columnId);
816
- S.invalidateQueries({ queryKey: ["kanban-cards", s, n.columnId, u] });
448
+ onSettled: (t, e, r) => {
449
+ const n = u(r.columnId);
450
+ p.invalidateQueries({ queryKey: ["kanban-cards", d, r.columnId, n] });
817
451
  }
818
- }), Mt = _(
819
- async (r, o, n) => {
452
+ }), gt = h(
453
+ async (t, e, r) => {
820
454
  try {
821
- await nt.mutateAsync({
822
- cardId: r._id,
823
- fromColumnId: o,
824
- toColumnId: n,
455
+ await B.mutateAsync({
456
+ cardId: t._id,
457
+ fromColumnId: e,
458
+ toColumnId: r,
825
459
  position: void 0
826
460
  });
827
461
  } catch {
828
462
  }
829
463
  },
830
- [nt]
831
- ), ft = Ht(() => e.sort((r, o) => r.position - o.position).map((r, o) => {
832
- var w;
833
- const u = ((w = c[o].data) == null ? void 0 : w.Data) || [];
464
+ [B]
465
+ ), R = ot(() => c.sort((t, e) => t.position - e.position).map((t, e) => {
466
+ var f;
467
+ const n = ((f = o[e].data) == null ? void 0 : f.Data) || [];
834
468
  return {
835
- _id: r.id,
836
- title: r.title,
837
- position: r.position,
838
- color: r.color,
839
- limit: r.limit,
840
- cards: u.sort((rt, j) => rt.position - j.position),
469
+ _id: t.id,
470
+ title: t.title,
471
+ position: t.position,
472
+ color: t.color,
473
+ limit: t.limit,
474
+ cards: n.sort((U, A) => U.position - A.position),
841
475
  _created_at: /* @__PURE__ */ new Date(),
842
476
  _modified_at: /* @__PURE__ */ new Date()
843
477
  };
844
- }), [e, c]), A = Ae({
845
- onCardMove: Mt,
846
- onError: g.current,
847
- columns: ft,
848
- announceMove: (r, o, n) => {
478
+ }), [c, o]), w = Ft({
479
+ onCardMove: gt,
480
+ onError: C.current,
481
+ columns: R,
482
+ announceMove: (t, e, r) => {
849
483
  console.log(
850
- `Kanban: Moved "${r.title}" from ${o} to ${n}`
484
+ `Kanban: Moved "${t.title}" from ${e} to ${r}`
851
485
  );
852
486
  }
853
- }), te = _(
854
- (r) => {
855
- var o, n;
487
+ }), yt = h(
488
+ (t) => {
489
+ var e, r;
856
490
  return {
857
491
  draggable: !0,
858
492
  role: "option",
859
- "aria-selected": t && ((o = A.draggedCard) == null ? void 0 : o._id) === r._id,
860
- "aria-grabbed": t && ((n = A.draggedCard) == null ? void 0 : n._id) === r._id,
861
- onDragStart: (u) => {
862
- if (!t) return;
863
- u.dataTransfer.setData("text/plain", JSON.stringify(r));
864
- const w = u.nativeEvent || u;
865
- A.handleDragStart(w, r);
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
+ onDragStart: (n) => {
496
+ if (!a) return;
497
+ n.dataTransfer.setData("text/plain", JSON.stringify(t));
498
+ const f = n.nativeEvent || n;
499
+ w.handleDragStart(f, t);
866
500
  },
867
- onDragEnd: A.handleDragEnd,
868
- onKeyDown: (u) => {
869
- if (!t) return;
870
- const w = u.nativeEvent || u;
871
- A.handleKeyDown(w, r);
501
+ onDragEnd: w.handleDragEnd,
502
+ onKeyDown: (n) => {
503
+ if (!a) return;
504
+ const f = n.nativeEvent || n;
505
+ w.handleKeyDown(f, t);
872
506
  }
873
507
  };
874
508
  },
875
- [t, A]
876
- ), ee = _(
877
- (r) => ({
878
- "data-column-id": r,
509
+ [a, w]
510
+ ), mt = h(
511
+ (t) => ({
512
+ "data-column-id": t,
879
513
  role: "listbox",
880
- onDragOver: (o) => {
881
- if (!t) return;
882
- const n = o.nativeEvent || o;
883
- A.handleDragOver(n, r);
514
+ onDragOver: (e) => {
515
+ if (!a) return;
516
+ const r = e.nativeEvent || e;
517
+ w.handleDragOver(r, t);
884
518
  },
885
- onDrop: (o) => {
886
- if (!t) return;
887
- const n = o.nativeEvent || o;
888
- A.handleDrop(n, r);
519
+ onDrop: (e) => {
520
+ if (!a) return;
521
+ const r = e.nativeEvent || e;
522
+ w.handleDrop(r, t);
889
523
  }
890
524
  }),
891
- [t, A]
892
- ), re = _((r) => {
893
- O({ query: r });
894
- }, []), se = _(() => {
895
- O({ query: "" });
896
- }, []), ie = (U == null ? void 0 : U.Count) || 0, ae = m || gt, ne = D, oe = At.isPending || bt.isPending || Ct.isPending || nt.isPending || Dt.isPending, pt = p || xt, ue = _(async () => {
897
- await b();
898
- }, [b]), ce = _(async () => {
899
- await S.invalidateQueries({
900
- predicate: (r) => r.queryKey[0] === "kanban-cards" || r.queryKey[0] === "kanban-count"
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({
534
+ predicate: (t) => t.queryKey[0] === "kanban-cards" || t.queryKey[0] === "kanban-count"
901
535
  });
902
- }, [S]);
903
- return _t(() => {
904
- pt && g.current && g.current(pt);
905
- }, [pt]), {
536
+ }, [p]);
537
+ return rt(() => {
538
+ W && C.current && C.current(W);
539
+ }, [W]), {
906
540
  // Data
907
- columns: ft,
908
- totalCards: ie,
541
+ columns: R,
542
+ totalCards: ht,
909
543
  // Loading States
910
- isLoading: ae,
911
- isFetching: ne,
912
- isUpdating: oe,
544
+ isLoading: Ct,
545
+ isFetching: Dt,
546
+ isUpdating: wt,
913
547
  // Error Handling
914
- error: pt,
548
+ error: W,
915
549
  // Card Operations (Flat Access)
916
- createCard: At.mutateAsync,
917
- updateCard: _(
918
- async (r, o) => {
919
- await bt.mutateAsync({ id: r, updates: o });
550
+ createCard: et.mutateAsync,
551
+ updateCard: h(
552
+ async (t, e) => {
553
+ await Z.mutateAsync({ id: t, updates: e });
920
554
  },
921
- [bt]
555
+ [Z]
922
556
  ),
923
- deleteCard: _(
924
- async (r) => {
925
- await Ct.mutateAsync(r);
557
+ deleteCard: h(
558
+ async (t) => {
559
+ await v.mutateAsync(t);
926
560
  },
927
- [Ct]
561
+ [v]
928
562
  ),
929
- moveCard: _(
930
- async (r, o, n, u) => {
931
- if (!u) {
932
- for (const w of ft)
933
- if (w.cards.find((j) => j._id === r)) {
934
- u = w._id;
563
+ moveCard: h(
564
+ async (t, e, r, n) => {
565
+ if (!n) {
566
+ for (const f of R)
567
+ if (f.cards.find((A) => A._id === t)) {
568
+ n = f._id;
935
569
  break;
936
570
  }
937
- if (!u)
938
- throw new Error(`Card ${r} not found in any column`);
571
+ if (!n)
572
+ throw new Error(`Card ${t} not found in any column`);
939
573
  }
940
- await nt.mutateAsync({ cardId: r, fromColumnId: u, toColumnId: o, position: n });
574
+ await B.mutateAsync({ cardId: t, fromColumnId: n, toColumnId: e, position: r });
941
575
  },
942
- [nt, ft]
576
+ [B, R]
943
577
  ),
944
- reorderCards: _(
945
- async (r, o) => {
946
- await Dt.mutateAsync({ cardIds: r, columnId: o });
578
+ reorderCards: h(
579
+ async (t, e) => {
580
+ await x.mutateAsync({ cardIds: t, columnId: e });
947
581
  },
948
- [Dt]
582
+ [x]
949
583
  ),
950
584
  // Search (Flat Access)
951
- searchQuery: C.query,
952
- setSearchQuery: re,
953
- clearSearch: se,
585
+ searchQuery: D.query,
586
+ setSearchQuery: ft,
587
+ clearSearch: pt,
954
588
  // Filter (Simplified chainable API)
955
- filter: V,
589
+ filter: T,
956
590
  // Drag Drop (Flat Access)
957
- isDragging: t ? A.isDragging : !1,
958
- draggedCard: t ? A.draggedCard : null,
959
- dragOverColumn: t ? A.dragOverColumn : null,
960
- handleDragStart: t ? A.handleDragStart : () => {
591
+ isDragging: a ? w.isDragging : !1,
592
+ draggedCard: a ? w.draggedCard : null,
593
+ dragOverColumn: a ? w.dragOverColumn : null,
594
+ handleDragStart: a ? w.handleDragStart : () => {
961
595
  },
962
- handleDragOver: t ? A.handleDragOver : () => {
596
+ handleDragOver: a ? w.handleDragOver : () => {
963
597
  },
964
- handleDrop: t ? A.handleDrop : () => {
598
+ handleDrop: a ? w.handleDrop : () => {
965
599
  },
966
- handleDragEnd: t ? A.handleDragEnd : () => {
600
+ handleDragEnd: a ? w.handleDragEnd : () => {
967
601
  },
968
- handleKeyDown: t ? A.handleKeyDown : () => {
602
+ handleKeyDown: a ? w.handleKeyDown : () => {
969
603
  },
970
604
  // Prop Getters
971
- getCardProps: t ? te : (r) => ({}),
972
- getColumnProps: t ? ee : (r) => ({}),
605
+ getCardProps: a ? yt : (t) => ({}),
606
+ getColumnProps: a ? mt : (t) => ({}),
973
607
  // Load More (Per Column)
974
- loadMore: _((r) => {
975
- J((o) => ({
976
- ...o,
977
- [r]: (o[r] || 10) + 10
608
+ loadMore: h((t) => {
609
+ V((e) => ({
610
+ ...e,
611
+ [t]: (e[t] || 10) + 10
978
612
  }));
979
613
  }, []),
980
614
  // Utilities
981
- refetch: ue,
982
- refresh: ce
615
+ refetch: _t,
616
+ refresh: bt
983
617
  };
984
618
  }
985
- const Te = ge(null);
986
- function Ue() {
987
- const a = fe(Te);
988
- if (!a)
619
+ const $t = qt(null);
620
+ function Yt() {
621
+ const i = Qt($t);
622
+ if (!i)
989
623
  throw new Error(
990
624
  "Kanban components must be used within a KanbanBoard component"
991
625
  );
992
- return a;
626
+ return i;
993
627
  }
994
- function je(a, e) {
995
- const s = e.reduce((t, i) => (t[i.columnId] || (t[i.columnId] = []), t[i.columnId].push(i), t), {});
996
- return a.map((t) => ({
997
- ...t,
998
- cards: (s[t._id] || []).sort((i, d) => i.position - d.position)
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) => ({
631
+ ...a,
632
+ cards: (d[a._id] || []).sort((s, O) => s.position - O.position)
999
633
  }));
1000
634
  }
1001
- function Be(a, e) {
1002
- if (a.cards.length === 0)
635
+ function Nt(i, c) {
636
+ if (i.cards.length === 0)
1003
637
  return 0;
1004
- if (e === void 0 || e >= a.cards.length)
1005
- return a.cards[a.cards.length - 1].position + 1;
1006
- if (e === 0) {
1007
- const i = a.cards[0];
1008
- return Math.max(0, i.position - 1);
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];
642
+ return Math.max(0, s.position - 1);
1009
643
  }
1010
- const s = a.cards[e - 1], t = a.cards[e];
1011
- return Math.floor((s.position + t.position) / 2);
644
+ const d = i.cards[c - 1], a = i.cards[c];
645
+ return Math.floor((d.position + a.position) / 2);
1012
646
  }
1013
- function Xe(a, e) {
1014
- if (a.length === 0)
647
+ function jt(i, c) {
648
+ if (i.length === 0)
1015
649
  return 0;
1016
- if (e === void 0 || e >= a.length)
1017
- return a[a.length - 1].position + 1;
1018
- if (e === 0) {
1019
- const i = a[0];
1020
- return Math.max(0, i.position - 1);
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];
654
+ return Math.max(0, s.position - 1);
1021
655
  }
1022
- const s = a[e - 1], t = a[e];
1023
- return Math.floor((s.position + t.position) / 2);
656
+ const d = i[c - 1], a = i[c];
657
+ return Math.floor((d.position + a.position) / 2);
1024
658
  }
1025
- function ze(a) {
1026
- return a.sort((e, s) => e.position - s.position).map((e, s) => ({
1027
- ...e,
1028
- position: s
659
+ function zt(i) {
660
+ return i.sort((c, d) => c.position - d.position).map((c, d) => ({
661
+ ...c,
662
+ position: d
1029
663
  }));
1030
664
  }
1031
- function Ne(a, e, s, t) {
1032
- const i = `Failed to ${e} ${s}`, d = t ? ` (ID: ${t})` : "";
1033
- return a instanceof Error ? new Error(`${i}${d}: ${a.message}`) : new Error(`${i}${d}: Unknown error`);
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`);
1034
668
  }
1035
- function Ye(a, e) {
1036
- switch (e) {
669
+ function Rt(i, c) {
670
+ switch (c) {
1037
671
  case "list":
1038
- return a && Array.isArray(a.Data);
672
+ return i && Array.isArray(i.Data);
1039
673
  case "single":
1040
- return a && typeof a == "object";
674
+ return i && typeof i == "object";
1041
675
  case "create":
1042
- return a && typeof a._id == "string";
676
+ return i && typeof i._id == "string";
1043
677
  case "delete":
1044
- return a && a.status === "success";
678
+ return i && i.status === "success";
1045
679
  default:
1046
680
  return !1;
1047
681
  }
1048
682
  }
1049
683
  export {
1050
- Te as KanbanContext,
1051
- Be as calculateCardPosition,
1052
- Xe as calculateColumnPosition,
1053
- Ne as handleKanbanApiError,
1054
- je as mergeCardsIntoColumns,
1055
- ze as normalizePositions,
1056
- Ae as useDragDropManager,
1057
- Ie as useKanban,
1058
- Ue as useKanbanContext,
1059
- Ye as validateApiResponse
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
1060
694
  };