@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.
- package/README.md +45 -12
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +2 -2
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/{client-C15j4O5B.cjs → client-DgtkT50N.cjs} +1 -1
- package/dist/{client-CfvLiGfP.js → client-V-WzUb8H.js} +9 -5
- package/dist/components/hooks/useFilter/types.d.ts +14 -11
- package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
- package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/context.d.ts +1 -1
- package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/types.d.ts +5 -22
- package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +19 -31
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/error-handling-CAoD0Kwb.cjs +1 -0
- package/dist/error-handling-CrhTtD88.js +14 -0
- package/dist/filter.cjs +1 -1
- package/dist/filter.mjs +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +825 -814
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/kanban.cjs +2 -2
- package/dist/kanban.mjs +335 -323
- package/dist/{metadata-2FLBsFcf.cjs → metadata-0lZAfuTP.cjs} +1 -1
- package/dist/{metadata-DBcoDth-.js → metadata-B88D_pVS.js} +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.mjs +113 -96
- package/dist/table.types.d.ts +1 -1
- package/dist/table.types.d.ts.map +1 -1
- package/dist/types/common.d.ts +26 -6
- package/dist/types/common.d.ts.map +1 -1
- package/dist/useFilter-DzpP_ag0.cjs +1 -0
- package/dist/useFilter-H5bgAZQF.js +120 -0
- package/dist/utils/api/buildListOptions.d.ts +43 -0
- package/dist/utils/api/buildListOptions.d.ts.map +1 -0
- package/dist/utils/api/index.d.ts +2 -0
- package/dist/utils/api/index.d.ts.map +1 -0
- package/dist/utils/error-handling.d.ts +41 -0
- package/dist/utils/error-handling.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/docs/QUICK_REFERENCE.md +142 -420
- package/docs/useAuth.md +52 -340
- package/docs/useFilter.md +858 -162
- package/docs/useForm.md +712 -501
- package/docs/useKanban.md +534 -279
- package/docs/useTable.md +725 -214
- package/package.json +1 -1
- package/sdk/api/client.ts +7 -1
- package/sdk/components/hooks/useFilter/types.ts +14 -11
- package/sdk/components/hooks/useFilter/useFilter.ts +20 -18
- package/sdk/components/hooks/useForm/apiClient.ts +2 -1
- package/sdk/components/hooks/useForm/useForm.ts +47 -13
- package/sdk/components/hooks/useKanban/context.ts +5 -3
- package/sdk/components/hooks/useKanban/types.ts +7 -23
- package/sdk/components/hooks/useKanban/useKanban.ts +54 -18
- package/sdk/components/hooks/useTable/types.ts +26 -32
- package/sdk/components/hooks/useTable/useTable.llm.txt +8 -22
- package/sdk/components/hooks/useTable/useTable.ts +70 -25
- package/sdk/index.ts +154 -10
- package/sdk/table.types.ts +3 -0
- package/sdk/types/common.ts +31 -6
- package/sdk/utils/api/buildListOptions.ts +120 -0
- package/sdk/utils/api/index.ts +2 -0
- package/sdk/utils/error-handling.ts +150 -0
- package/sdk/utils/index.ts +6 -0
- package/dist/useFilter-Dofowpr_.cjs +0 -1
- package/dist/useFilter-Dv-mr9QW.js +0 -117
package/dist/kanban.mjs
CHANGED
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
import { useState as G, useRef as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { a as F } from "./client-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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,
|
|
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
|
-
}),
|
|
19
|
-
|
|
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
|
-
}),
|
|
26
|
-
}, []),
|
|
27
|
-
for (const
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
return { card:
|
|
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]),
|
|
34
|
-
var
|
|
34
|
+
}, [d]), A = p((i, c) => {
|
|
35
|
+
var l, m;
|
|
35
36
|
try {
|
|
36
|
-
const
|
|
37
|
+
const g = i.target, y = C(c.columnId);
|
|
37
38
|
if (!y)
|
|
38
39
|
throw new Error("Source column not found");
|
|
39
|
-
(
|
|
40
|
-
const S =
|
|
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),
|
|
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:
|
|
56
|
+
draggedCard: c,
|
|
56
57
|
dragOverColumn: null,
|
|
57
58
|
dragOverPosition: null,
|
|
58
59
|
dragSourceColumn: y._id
|
|
59
|
-
}), a == null || a(
|
|
60
|
-
} catch (
|
|
61
|
-
|
|
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
|
-
}, [
|
|
64
|
-
if (
|
|
65
|
-
const
|
|
66
|
-
|
|
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: (
|
|
69
|
+
dragOverColumn: (l == null ? void 0 : l._id) || null,
|
|
69
70
|
dragOverPosition: null
|
|
70
71
|
// Will be calculated based on mouse position
|
|
71
|
-
})),
|
|
72
|
-
}, [s.isDragging, s.draggedCard,
|
|
73
|
-
if (
|
|
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
|
|
76
|
-
if (!
|
|
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 ===
|
|
79
|
+
if (m === c) {
|
|
79
80
|
b();
|
|
80
81
|
return;
|
|
81
82
|
}
|
|
82
|
-
if (
|
|
83
|
-
throw new Error(`Column "${
|
|
84
|
-
|
|
85
|
-
} catch (
|
|
86
|
-
|
|
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,
|
|
91
|
-
|
|
92
|
-
}, [b]),
|
|
93
|
-
const
|
|
94
|
-
if (!
|
|
95
|
-
const
|
|
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 <
|
|
98
|
-
|
|
98
|
+
if (m < gt ? y = -mt : m > g - gt && (y = mt), y !== 0) {
|
|
99
|
+
w.current && clearTimeout(w.current);
|
|
99
100
|
const S = () => {
|
|
100
|
-
|
|
101
|
+
c.scrollLeft += y, w.current = setTimeout(S, 16);
|
|
101
102
|
};
|
|
102
|
-
|
|
103
|
+
w.current = setTimeout(S, 100);
|
|
103
104
|
} else
|
|
104
|
-
|
|
105
|
-
}, []),
|
|
106
|
-
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter", "Space", "Escape"].includes(
|
|
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
|
-
|
|
109
|
-
const
|
|
110
|
-
if (!
|
|
111
|
-
const { column: m } =
|
|
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 (
|
|
114
|
+
switch (i.key) {
|
|
114
115
|
case "ArrowLeft":
|
|
115
|
-
if (
|
|
116
|
-
const y = d[
|
|
117
|
-
|
|
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 (
|
|
122
|
-
const y = d[
|
|
123
|
-
|
|
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(
|
|
128
|
+
a == null || a(c, "current position", "position above");
|
|
128
129
|
break;
|
|
129
130
|
case "ArrowDown":
|
|
130
|
-
a == null || a(
|
|
131
|
+
a == null || a(c, "current position", "position below");
|
|
131
132
|
break;
|
|
132
133
|
case "Enter":
|
|
133
134
|
case "Space":
|
|
134
|
-
a == null || a(
|
|
135
|
+
a == null || a(c, m.title, "drag mode");
|
|
135
136
|
break;
|
|
136
137
|
case "Escape":
|
|
137
|
-
a == null || a(
|
|
138
|
+
a == null || a(c, "drag mode", "cancelled");
|
|
138
139
|
break;
|
|
139
140
|
}
|
|
140
141
|
} catch (y) {
|
|
141
|
-
|
|
142
|
+
u == null || u(y instanceof Error ? y : new Error("Keyboard navigation failed"));
|
|
142
143
|
}
|
|
143
|
-
}, [
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
x:
|
|
147
|
-
y:
|
|
148
|
-
card:
|
|
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
|
-
}, []),
|
|
151
|
-
if (!
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
154
|
-
const
|
|
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
|
-
|
|
157
|
+
_({
|
|
157
158
|
isDragging: !0,
|
|
158
|
-
draggedCard:
|
|
159
|
+
draggedCard: g,
|
|
159
160
|
dragOverColumn: null,
|
|
160
161
|
dragOverPosition: null,
|
|
161
162
|
dragSourceColumn: y._id
|
|
162
|
-
}), a == null || a(
|
|
163
|
+
}), a == null || a(g, y.title, "being moved");
|
|
163
164
|
}
|
|
164
|
-
}, [
|
|
165
|
-
if (!s.isDragging || !s.draggedCard || !
|
|
166
|
-
|
|
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
|
|
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
|
|
173
|
-
if (
|
|
174
|
-
if (
|
|
175
|
-
throw new Error(`Column "${
|
|
176
|
-
|
|
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 (
|
|
180
|
-
|
|
180
|
+
} catch (c) {
|
|
181
|
+
u == null || u(c instanceof Error ? c : new Error("Touch drop failed"));
|
|
181
182
|
} finally {
|
|
182
|
-
|
|
183
|
+
Q.current = null, b();
|
|
183
184
|
}
|
|
184
|
-
}, [s,
|
|
185
|
-
const m = `Moved "${
|
|
186
|
-
|
|
187
|
-
document.body.removeChild(
|
|
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
|
|
191
|
-
|
|
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:
|
|
201
|
-
handleDragOver:
|
|
202
|
-
handleDrop:
|
|
203
|
-
handleDragEnd:
|
|
204
|
-
handleKeyDown:
|
|
205
|
-
handleTouchStart:
|
|
206
|
-
handleTouchMove:
|
|
207
|
-
handleTouchEnd:
|
|
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 ||
|
|
210
|
+
announceMove: a || U,
|
|
210
211
|
reset: b
|
|
211
212
|
};
|
|
212
213
|
}
|
|
213
|
-
function
|
|
214
|
-
var
|
|
214
|
+
function Rt(o) {
|
|
215
|
+
var it, st, ot, ct, ut;
|
|
215
216
|
const {
|
|
216
|
-
columns:
|
|
217
|
+
columns: u,
|
|
217
218
|
source: d,
|
|
218
219
|
enableDragDrop: a = !0,
|
|
219
220
|
initialState: s,
|
|
220
|
-
onCardMove:
|
|
221
|
-
onCardCreate:
|
|
222
|
-
onCardUpdate:
|
|
223
|
-
onCardDelete:
|
|
221
|
+
onCardMove: _,
|
|
222
|
+
onCardCreate: O,
|
|
223
|
+
onCardUpdate: w,
|
|
224
|
+
onCardDelete: Q,
|
|
224
225
|
onError: b
|
|
225
|
-
} =
|
|
226
|
-
query: (s == null ? void 0 : s.search) || ""
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
|
234
|
+
return u.forEach((e) => {
|
|
233
235
|
t[e.id] = 10;
|
|
234
236
|
}), t;
|
|
235
|
-
}),
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}, [b,
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}),
|
|
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 =
|
|
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:
|
|
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
|
-
],
|
|
273
|
-
}, [
|
|
274
|
-
queries:
|
|
275
|
-
const e =
|
|
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:
|
|
287
|
+
placeholderData: Lt,
|
|
286
288
|
staleTime: 30 * 1e3
|
|
287
289
|
};
|
|
288
290
|
})
|
|
289
|
-
}), g =
|
|
290
|
-
await Promise.all(
|
|
291
|
-
},
|
|
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
|
|
294
|
-
}, [
|
|
295
|
-
data:
|
|
296
|
-
isLoading:
|
|
297
|
-
error:
|
|
298
|
-
} =
|
|
299
|
-
queryKey: ["kanban-count", d,
|
|
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(
|
|
304
|
+
return await F(d).count(N);
|
|
303
305
|
} catch (t) {
|
|
304
|
-
throw
|
|
306
|
+
throw h.current && h.current(k(t)), t;
|
|
305
307
|
}
|
|
306
308
|
},
|
|
307
309
|
staleTime: 30 * 1e3,
|
|
308
310
|
gcTime: 60 * 1e3
|
|
309
|
-
}),
|
|
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 =
|
|
316
|
-
await
|
|
317
|
-
const f =
|
|
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
|
|
321
|
+
const X = f.Data, T = t.position ?? X.length, B = `temp-${Date.now()}`, E = {
|
|
320
322
|
...t,
|
|
321
|
-
_id:
|
|
322
|
-
position:
|
|
323
|
+
_id: B,
|
|
324
|
+
position: T,
|
|
323
325
|
_created_at: /* @__PURE__ */ new Date(),
|
|
324
326
|
_modified_at: /* @__PURE__ */ new Date()
|
|
325
327
|
};
|
|
326
|
-
|
|
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
|
|
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) &&
|
|
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 =
|
|
346
|
-
|
|
347
|
+
const n = r.columnId, f = l(n);
|
|
348
|
+
i.invalidateQueries({ queryKey: ["kanban-cards", d, n, f] });
|
|
347
349
|
}
|
|
348
|
-
}),
|
|
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
|
|
352
|
+
onMutate: async () => (await i.cancelQueries({ queryKey: ["kanban-cards", d] }), {}),
|
|
351
353
|
onSuccess: async (t) => {
|
|
352
354
|
var e;
|
|
353
|
-
(e =
|
|
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 =
|
|
359
|
+
(n = h.current) == null || n.call(h, k(t));
|
|
358
360
|
},
|
|
359
361
|
onSettled: () => {
|
|
360
|
-
|
|
362
|
+
i.invalidateQueries({ queryKey: ["kanban-cards", d] });
|
|
361
363
|
}
|
|
362
|
-
}),
|
|
364
|
+
}), tt = R({
|
|
363
365
|
mutationFn: async (t) => (await F(d).delete(t), t),
|
|
364
|
-
onMutate: async () => (await
|
|
366
|
+
onMutate: async () => (await i.cancelQueries({ queryKey: ["kanban-cards", d] }), {}),
|
|
365
367
|
onSuccess: async (t) => {
|
|
366
368
|
var e;
|
|
367
|
-
(e =
|
|
369
|
+
(e = U.current) == null || e.call(U, t);
|
|
368
370
|
},
|
|
369
371
|
onError: (t, e, r) => {
|
|
370
372
|
var n;
|
|
371
|
-
(n =
|
|
373
|
+
(n = h.current) == null || n.call(h, k(t));
|
|
372
374
|
},
|
|
373
375
|
onSettled: () => {
|
|
374
|
-
|
|
376
|
+
i.invalidateQueries({ queryKey: ["kanban-cards", d] });
|
|
375
377
|
}
|
|
376
|
-
}),
|
|
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 =
|
|
383
|
-
await
|
|
384
|
-
const E =
|
|
385
|
-
if (E &&
|
|
386
|
-
const
|
|
387
|
-
if (
|
|
388
|
-
const
|
|
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((
|
|
391
|
-
},
|
|
392
|
-
...
|
|
392
|
+
Data: E.Data.filter((at) => at._id !== t)
|
|
393
|
+
}, At = {
|
|
394
|
+
...dt,
|
|
393
395
|
columnId: r,
|
|
394
|
-
position: n ??
|
|
396
|
+
position: n ?? z.Data.length,
|
|
395
397
|
_modified_at: /* @__PURE__ */ new Date()
|
|
396
|
-
},
|
|
397
|
-
...
|
|
398
|
-
Data: [...
|
|
398
|
+
}, qt = {
|
|
399
|
+
...z,
|
|
400
|
+
Data: [...z.Data, At].sort((at, kt) => at.position - kt.position)
|
|
399
401
|
};
|
|
400
|
-
|
|
402
|
+
i.setQueryData(T, et), i.setQueryData(B, qt);
|
|
401
403
|
}
|
|
402
404
|
}
|
|
403
405
|
return {
|
|
404
406
|
previousFromData: E,
|
|
405
|
-
previousToData:
|
|
406
|
-
fromQueryKey:
|
|
407
|
-
toQueryKey:
|
|
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 =
|
|
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) &&
|
|
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 =
|
|
427
|
-
|
|
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
|
-
}),
|
|
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 =
|
|
440
|
-
return await
|
|
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 =
|
|
448
|
+
(n = h.current) == null || n.call(h, k(t));
|
|
447
449
|
},
|
|
448
450
|
onSettled: (t, e, r) => {
|
|
449
|
-
const n =
|
|
450
|
-
|
|
451
|
+
const n = l(r.columnId);
|
|
452
|
+
i.invalidateQueries({ queryKey: ["kanban-cards", d, r.columnId, n] });
|
|
451
453
|
}
|
|
452
|
-
}),
|
|
454
|
+
}), ht = p(
|
|
453
455
|
async (t, e, r) => {
|
|
454
456
|
try {
|
|
455
|
-
await
|
|
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
|
-
[
|
|
465
|
-
),
|
|
466
|
+
[Y]
|
|
467
|
+
), W = lt(() => u.sort((t, e) => t.position - e.position).map((t, e) => {
|
|
466
468
|
var f;
|
|
467
|
-
const n = ((f =
|
|
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((
|
|
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
|
-
}), [
|
|
479
|
-
onCardMove:
|
|
480
|
-
onError:
|
|
481
|
-
columns:
|
|
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
|
-
}),
|
|
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 =
|
|
494
|
-
"aria-grabbed": a && ((r =
|
|
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
|
-
|
|
501
|
+
D.handleDragStart(f, t);
|
|
500
502
|
},
|
|
501
|
-
onDragEnd:
|
|
503
|
+
onDragEnd: D.handleDragEnd,
|
|
502
504
|
onKeyDown: (n) => {
|
|
503
505
|
if (!a) return;
|
|
504
506
|
const f = n.nativeEvent || n;
|
|
505
|
-
|
|
507
|
+
D.handleKeyDown(f, t);
|
|
506
508
|
}
|
|
507
509
|
};
|
|
508
510
|
},
|
|
509
|
-
[a,
|
|
510
|
-
),
|
|
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
|
-
|
|
519
|
+
D.handleDragOver(r, t);
|
|
518
520
|
},
|
|
519
521
|
onDrop: (e) => {
|
|
520
522
|
if (!a) return;
|
|
521
523
|
const r = e.nativeEvent || e;
|
|
522
|
-
|
|
524
|
+
D.handleDrop(r, t);
|
|
523
525
|
}
|
|
524
526
|
}),
|
|
525
|
-
[a,
|
|
526
|
-
),
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|
-
}, [
|
|
537
|
-
return
|
|
538
|
-
|
|
539
|
-
}, [
|
|
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:
|
|
542
|
-
totalCards:
|
|
551
|
+
columns: W,
|
|
552
|
+
totalCards: _t,
|
|
543
553
|
// Loading States
|
|
544
|
-
isLoading:
|
|
545
|
-
isFetching:
|
|
546
|
-
isUpdating:
|
|
554
|
+
isLoading: St,
|
|
555
|
+
isFetching: Qt,
|
|
556
|
+
isUpdating: Ot,
|
|
547
557
|
// Error Handling
|
|
548
|
-
error:
|
|
558
|
+
error: j ? k(j) : null,
|
|
549
559
|
// Card Operations (Flat Access)
|
|
550
|
-
createCard:
|
|
551
|
-
updateCard:
|
|
560
|
+
createCard: nt.mutateAsync,
|
|
561
|
+
updateCard: p(
|
|
552
562
|
async (t, e) => {
|
|
553
|
-
await
|
|
563
|
+
await M.mutateAsync({ id: t, updates: e });
|
|
554
564
|
},
|
|
555
|
-
[
|
|
565
|
+
[M]
|
|
556
566
|
),
|
|
557
|
-
deleteCard:
|
|
567
|
+
deleteCard: p(
|
|
558
568
|
async (t) => {
|
|
559
|
-
await
|
|
569
|
+
await tt.mutateAsync(t);
|
|
560
570
|
},
|
|
561
|
-
[
|
|
571
|
+
[tt]
|
|
562
572
|
),
|
|
563
|
-
moveCard:
|
|
573
|
+
moveCard: p(
|
|
564
574
|
async (t, e, r, n) => {
|
|
565
575
|
if (!n) {
|
|
566
|
-
for (const f of
|
|
567
|
-
if (f.cards.find((
|
|
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
|
|
584
|
+
await Y.mutateAsync({ cardId: t, fromColumnId: n, toColumnId: e, position: r });
|
|
575
585
|
},
|
|
576
|
-
[
|
|
586
|
+
[Y, W]
|
|
577
587
|
),
|
|
578
|
-
reorderCards:
|
|
588
|
+
reorderCards: p(
|
|
579
589
|
async (t, e) => {
|
|
580
|
-
await
|
|
590
|
+
await rt.mutateAsync({ cardIds: t, columnId: e });
|
|
581
591
|
},
|
|
582
|
-
[
|
|
592
|
+
[rt]
|
|
583
593
|
),
|
|
584
594
|
// Search (Flat Access)
|
|
585
|
-
searchQuery:
|
|
586
|
-
setSearchQuery:
|
|
587
|
-
clearSearch:
|
|
595
|
+
searchQuery: C.query,
|
|
596
|
+
setSearchQuery: wt,
|
|
597
|
+
clearSearch: bt,
|
|
588
598
|
// Filter (Simplified chainable API)
|
|
589
|
-
filter:
|
|
599
|
+
filter: c,
|
|
590
600
|
// Drag Drop (Flat Access)
|
|
591
|
-
isDragging: a ?
|
|
592
|
-
draggedCard: a ?
|
|
593
|
-
dragOverColumn: a ?
|
|
594
|
-
handleDragStart: a ?
|
|
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 ?
|
|
606
|
+
handleDragOver: a ? D.handleDragOver : () => {
|
|
597
607
|
},
|
|
598
|
-
handleDrop: a ?
|
|
608
|
+
handleDrop: a ? D.handleDrop : () => {
|
|
599
609
|
},
|
|
600
|
-
handleDragEnd: a ?
|
|
610
|
+
handleDragEnd: a ? D.handleDragEnd : () => {
|
|
601
611
|
},
|
|
602
|
-
handleKeyDown: a ?
|
|
612
|
+
handleKeyDown: a ? D.handleKeyDown : () => {
|
|
603
613
|
},
|
|
604
614
|
// Prop Getters
|
|
605
|
-
getCardProps: a ?
|
|
606
|
-
getColumnProps: a ?
|
|
615
|
+
getCardProps: a ? Ct : (t) => ({}),
|
|
616
|
+
getColumnProps: a ? Dt : (t) => ({}),
|
|
607
617
|
// Load More (Per Column)
|
|
608
|
-
loadMore:
|
|
609
|
-
|
|
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:
|
|
616
|
-
refresh:
|
|
625
|
+
refetch: Kt,
|
|
626
|
+
refresh: Tt
|
|
617
627
|
};
|
|
618
628
|
}
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
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
|
|
638
|
+
return o;
|
|
627
639
|
}
|
|
628
|
-
function
|
|
629
|
-
const d =
|
|
630
|
-
return
|
|
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,
|
|
644
|
+
cards: (d[a._id] || []).sort((s, _) => s.position - _.position)
|
|
633
645
|
}));
|
|
634
646
|
}
|
|
635
|
-
function
|
|
636
|
-
if (
|
|
647
|
+
function Gt(o, u) {
|
|
648
|
+
if (o.cards.length === 0)
|
|
637
649
|
return 0;
|
|
638
|
-
if (
|
|
639
|
-
return
|
|
640
|
-
if (
|
|
641
|
-
const s =
|
|
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 =
|
|
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
|
|
648
|
-
if (
|
|
659
|
+
function Vt(o, u) {
|
|
660
|
+
if (o.length === 0)
|
|
649
661
|
return 0;
|
|
650
|
-
if (
|
|
651
|
-
return
|
|
652
|
-
if (
|
|
653
|
-
const s =
|
|
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 =
|
|
668
|
+
const d = o[u - 1], a = o[u];
|
|
657
669
|
return Math.floor((d.position + a.position) / 2);
|
|
658
670
|
}
|
|
659
|
-
function
|
|
660
|
-
return
|
|
661
|
-
...
|
|
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
|
|
666
|
-
const s = `Failed to ${
|
|
667
|
-
return
|
|
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
|
|
670
|
-
switch (
|
|
681
|
+
function xt(o, u) {
|
|
682
|
+
switch (u) {
|
|
671
683
|
case "list":
|
|
672
|
-
return
|
|
684
|
+
return o && Array.isArray(o.Data);
|
|
673
685
|
case "single":
|
|
674
|
-
return
|
|
686
|
+
return o && typeof o == "object";
|
|
675
687
|
case "create":
|
|
676
|
-
return
|
|
688
|
+
return o && typeof o._id == "string";
|
|
677
689
|
case "delete":
|
|
678
|
-
return
|
|
690
|
+
return o && o.status === "success";
|
|
679
691
|
default:
|
|
680
692
|
return !1;
|
|
681
693
|
}
|
|
682
694
|
}
|
|
683
695
|
export {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
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
|
};
|