@ram_28/kf-ai-sdk 1.0.11 → 1.0.12

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 (193) hide show
  1. package/README.md +55 -48
  2. package/dist/api/client.d.ts +14 -14
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/datetime.d.ts +5 -5
  5. package/dist/api/datetime.d.ts.map +1 -1
  6. package/dist/api/index.d.ts +1 -1
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/api/metadata.d.ts +2 -2
  9. package/dist/api/metadata.d.ts.map +1 -1
  10. package/dist/api.cjs +1 -0
  11. package/dist/api.d.ts +4 -0
  12. package/dist/api.d.ts.map +1 -0
  13. package/dist/api.mjs +27 -0
  14. package/dist/api.types.cjs +1 -0
  15. package/dist/api.types.d.ts +4 -0
  16. package/dist/api.types.d.ts.map +1 -0
  17. package/dist/api.types.mjs +1 -0
  18. package/dist/auth/AuthProvider.d.ts +3 -3
  19. package/dist/auth/AuthProvider.d.ts.map +1 -1
  20. package/dist/auth/authClient.d.ts +4 -4
  21. package/dist/auth/authClient.d.ts.map +1 -1
  22. package/dist/auth/authConfig.d.ts +5 -5
  23. package/dist/auth/authConfig.d.ts.map +1 -1
  24. package/dist/auth/index.d.ts +1 -1
  25. package/dist/auth/index.d.ts.map +1 -1
  26. package/dist/auth/types.d.ts +21 -21
  27. package/dist/auth/types.d.ts.map +1 -1
  28. package/dist/auth/useAuth.d.ts +2 -2
  29. package/dist/auth/useAuth.d.ts.map +1 -1
  30. package/dist/auth.cjs +1 -0
  31. package/dist/auth.d.ts +5 -0
  32. package/dist/auth.d.ts.map +1 -0
  33. package/dist/auth.mjs +280 -0
  34. package/dist/auth.types.cjs +1 -0
  35. package/dist/auth.types.d.ts +2 -0
  36. package/dist/auth.types.d.ts.map +1 -0
  37. package/dist/auth.types.mjs +1 -0
  38. package/dist/base-types.d.ts +2 -0
  39. package/dist/base-types.d.ts.map +1 -0
  40. package/dist/client-C15j4O5B.cjs +1 -0
  41. package/dist/client-CfvLiGfP.js +233 -0
  42. package/dist/cn-Dr87sK3i.js +2775 -0
  43. package/dist/cn-mXUIg4vp.cjs +1 -0
  44. package/dist/components/hooks/index.d.ts +3 -3
  45. package/dist/components/hooks/index.d.ts.map +1 -1
  46. package/dist/components/hooks/useFilter/index.d.ts +2 -2
  47. package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
  48. package/dist/components/hooks/useFilter/types.d.ts +19 -31
  49. package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
  50. package/dist/components/hooks/useFilter/useFilter.d.ts +2 -2
  51. package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
  52. package/dist/components/hooks/useForm/apiClient.d.ts +6 -6
  53. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
  54. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +7 -7
  55. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -1
  56. package/dist/components/hooks/useForm/index.d.ts +5 -5
  57. package/dist/components/hooks/useForm/index.d.ts.map +1 -1
  58. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +10 -10
  59. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -1
  60. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +7 -12
  61. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -1
  62. package/dist/components/hooks/useForm/schemaParser.utils.d.ts +7 -7
  63. package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -1
  64. package/dist/components/hooks/useForm/types.d.ts +67 -76
  65. package/dist/components/hooks/useForm/types.d.ts.map +1 -1
  66. package/dist/components/hooks/useForm/useForm.d.ts +2 -2
  67. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
  68. package/dist/components/hooks/useKanban/apiClient.d.ts +16 -16
  69. package/dist/components/hooks/useKanban/apiClient.d.ts.map +1 -1
  70. package/dist/components/hooks/useKanban/context.d.ts +3 -3
  71. package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
  72. package/dist/components/hooks/useKanban/dragDropManager.d.ts +7 -7
  73. package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +1 -1
  74. package/dist/components/hooks/useKanban/index.d.ts +1 -1
  75. package/dist/components/hooks/useKanban/index.d.ts.map +1 -1
  76. package/dist/components/hooks/useKanban/types.d.ts +65 -67
  77. package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
  78. package/dist/components/hooks/useKanban/useKanban.d.ts +2 -2
  79. package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
  80. package/dist/components/hooks/useTable/index.d.ts +1 -1
  81. package/dist/components/hooks/useTable/index.d.ts.map +1 -1
  82. package/dist/components/hooks/useTable/types.d.ts +10 -10
  83. package/dist/components/hooks/useTable/types.d.ts.map +1 -1
  84. package/dist/components/hooks/useTable/useTable.d.ts +2 -2
  85. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
  86. package/dist/filter.cjs +1 -0
  87. package/dist/filter.d.ts +3 -0
  88. package/dist/filter.d.ts.map +1 -0
  89. package/dist/filter.mjs +6 -0
  90. package/dist/filter.types.cjs +1 -0
  91. package/dist/filter.types.d.ts +2 -0
  92. package/dist/filter.types.d.ts.map +1 -0
  93. package/dist/filter.types.mjs +1 -0
  94. package/dist/form.cjs +1 -0
  95. package/dist/form.d.ts +3 -0
  96. package/dist/form.d.ts.map +1 -0
  97. package/dist/form.mjs +1346 -0
  98. package/dist/form.types.cjs +1 -0
  99. package/dist/form.types.d.ts +2 -0
  100. package/dist/form.types.d.ts.map +1 -0
  101. package/dist/form.types.mjs +1 -0
  102. package/dist/jsx-runtime-BYECrxsp.cjs +30 -0
  103. package/dist/jsx-runtime-DGlMoOmv.js +630 -0
  104. package/dist/kanban.cjs +13 -0
  105. package/dist/kanban.d.ts +5 -0
  106. package/dist/kanban.d.ts.map +1 -0
  107. package/dist/kanban.mjs +694 -0
  108. package/dist/kanban.types.cjs +1 -0
  109. package/dist/kanban.types.d.ts +2 -0
  110. package/dist/kanban.types.d.ts.map +1 -0
  111. package/dist/kanban.types.mjs +1 -0
  112. package/dist/kanban.ui.cjs +1 -0
  113. package/dist/kanban.ui.d.ts +2 -0
  114. package/dist/kanban.ui.d.ts.map +1 -0
  115. package/dist/kanban.ui.mjs +104 -0
  116. package/dist/metadata-2FLBsFcf.cjs +1 -0
  117. package/dist/metadata-DBcoDth-.js +43 -0
  118. package/dist/table.cjs +1 -0
  119. package/dist/table.d.ts +2 -0
  120. package/dist/table.d.ts.map +1 -0
  121. package/dist/table.mjs +148 -0
  122. package/dist/table.types.cjs +1 -0
  123. package/dist/table.types.d.ts +2 -0
  124. package/dist/table.types.d.ts.map +1 -0
  125. package/dist/table.types.mjs +1 -0
  126. package/dist/types/base-fields.d.ts +45 -45
  127. package/dist/types/base-fields.d.ts.map +1 -1
  128. package/dist/types/common.d.ts +45 -61
  129. package/dist/types/common.d.ts.map +1 -1
  130. package/dist/types.cjs +1 -0
  131. package/dist/types.mjs +1 -0
  132. package/dist/useFilter-CXFqEHyI.js +129 -0
  133. package/dist/useFilter-D-bCDo6Z.cjs +1 -0
  134. package/dist/utils/formatting.d.ts +4 -4
  135. package/dist/utils/formatting.d.ts.map +1 -1
  136. package/dist/utils.cjs +4 -0
  137. package/dist/utils.d.ts +3 -0
  138. package/dist/utils.d.ts.map +1 -0
  139. package/dist/utils.mjs +105 -0
  140. package/package.json +147 -9
  141. package/sdk/api/client.ts +51 -51
  142. package/sdk/api/datetime.ts +5 -5
  143. package/sdk/api/index.ts +28 -33
  144. package/sdk/api/metadata.ts +4 -4
  145. package/sdk/api.ts +24 -0
  146. package/sdk/api.types.ts +58 -0
  147. package/sdk/auth/AuthProvider.tsx +18 -18
  148. package/sdk/auth/authClient.ts +9 -9
  149. package/sdk/auth/authConfig.ts +9 -9
  150. package/sdk/auth/index.ts +5 -5
  151. package/sdk/auth/types.ts +21 -21
  152. package/sdk/auth/useAuth.ts +2 -2
  153. package/sdk/auth.ts +22 -0
  154. package/sdk/auth.types.ts +28 -0
  155. package/sdk/base-types.ts +45 -0
  156. package/sdk/components/hooks/index.ts +22 -22
  157. package/sdk/components/hooks/useFilter/index.ts +8 -14
  158. package/sdk/components/hooks/useFilter/types.ts +29 -58
  159. package/sdk/components/hooks/useFilter/useFilter.ts +41 -44
  160. package/sdk/components/hooks/useForm/apiClient.ts +8 -8
  161. package/sdk/components/hooks/useForm/expressionValidator.utils.ts +18 -18
  162. package/sdk/components/hooks/useForm/index.ts +24 -24
  163. package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +22 -22
  164. package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +26 -62
  165. package/sdk/components/hooks/useForm/schemaParser.utils.ts +24 -24
  166. package/sdk/components/hooks/useForm/types.ts +66 -82
  167. package/sdk/components/hooks/useForm/useForm.ts +15 -21
  168. package/sdk/components/hooks/useKanban/apiClient.ts +54 -54
  169. package/sdk/components/hooks/useKanban/context.ts +3 -3
  170. package/sdk/components/hooks/useKanban/dragDropManager.ts +19 -19
  171. package/sdk/components/hooks/useKanban/index.ts +26 -26
  172. package/sdk/components/hooks/useKanban/types.ts +69 -71
  173. package/sdk/components/hooks/useKanban/useKanban.ts +43 -51
  174. package/sdk/components/hooks/useKanban/useKanbanSimple.ts +4 -4
  175. package/sdk/components/hooks/useTable/index.ts +5 -1
  176. package/sdk/components/hooks/useTable/types.ts +10 -10
  177. package/sdk/components/hooks/useTable/useTable.ts +10 -10
  178. package/sdk/filter.ts +13 -0
  179. package/sdk/filter.types.ts +17 -0
  180. package/sdk/form.ts +15 -0
  181. package/sdk/form.types.ts +46 -0
  182. package/sdk/kanban.ts +23 -0
  183. package/sdk/kanban.types.ts +50 -0
  184. package/sdk/kanban.ui.ts +16 -0
  185. package/sdk/table.ts +7 -0
  186. package/sdk/table.types.ts +13 -0
  187. package/sdk/types/base-fields.ts +47 -47
  188. package/sdk/types/common.ts +47 -71
  189. package/sdk/types/index.ts +1 -1
  190. package/sdk/utils/formatting.ts +4 -4
  191. package/sdk/utils.ts +10 -0
  192. package/dist/index.cjs +0 -45
  193. package/dist/index.mjs +0 -6387
@@ -0,0 +1,694 @@
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-CXFqEHyI.js";
5
+ const ct = 50, dt = 5, ut = 5;
6
+ function Ft({
7
+ onCardMove: i,
8
+ onError: c,
9
+ columns: d,
10
+ announceMove: a
11
+ }) {
12
+ const [s, O] = G({
13
+ isDragging: !1,
14
+ draggedCard: null,
15
+ dragOverColumn: null,
16
+ dragOverPosition: null,
17
+ dragSourceColumn: null
18
+ }), q = k(null), _ = k(null), K = k(null), b = h(() => {
19
+ O({
20
+ isDragging: !1,
21
+ draggedCard: null,
22
+ dragOverColumn: null,
23
+ dragOverPosition: null,
24
+ 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 };
31
+ }
32
+ return null;
33
+ }, [d]), P = h((u, o) => {
34
+ var g, m;
35
+ try {
36
+ const l = u.target, y = D(o.columnId);
37
+ if (!y)
38
+ 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);
41
+ S.style.cssText = `
42
+ position: fixed;
43
+ top: -1000px;
44
+ left: -1000px;
45
+ opacity: 0.9;
46
+ transform: rotate(-2deg) scale(0.95);
47
+ box-shadow: 0 10px 25px rgba(0,0,0,0.2);
48
+ pointer-events: none;
49
+ z-index: 9999;
50
+ max-width: 300px;
51
+ background: white;
52
+ 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
+ isDragging: !0,
55
+ draggedCard: o,
56
+ dragOverColumn: null,
57
+ dragOverPosition: null,
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();
62
+ }
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,
69
+ dragOverPosition: null
70
+ // 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))
74
+ try {
75
+ const g = s.draggedCard, m = s.dragSourceColumn, l = D(o), y = D(m);
76
+ if (!l || !y)
77
+ throw new Error("Target or source column not found");
78
+ if (m === o) {
79
+ b();
80
+ return;
81
+ }
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"));
87
+ } finally {
88
+ b();
89
+ }
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);
101
+ };
102
+ _.current = setTimeout(S, 100);
103
+ } else
104
+ _.current && (clearTimeout(_.current), _.current = null);
105
+ }, []), L = h((u, o) => {
106
+ if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter", "Space", "Escape"].includes(u.key))
107
+ 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);
112
+ try {
113
+ switch (u.key) {
114
+ 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);
118
+ }
119
+ break;
120
+ 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);
124
+ }
125
+ break;
126
+ case "ArrowUp":
127
+ a == null || a(o, "current position", "position above");
128
+ break;
129
+ case "ArrowDown":
130
+ a == null || a(o, "current position", "position below");
131
+ break;
132
+ case "Enter":
133
+ case "Space":
134
+ a == null || a(o, m.title, "drag mode");
135
+ break;
136
+ case "Escape":
137
+ a == null || a(o, "drag mode", "cancelled");
138
+ break;
139
+ }
140
+ } catch (y) {
141
+ c == null || c(y instanceof Error ? y : new Error("Keyboard navigation failed"));
142
+ }
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
149
+ };
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({
157
+ isDragging: !0,
158
+ draggedCard: l,
159
+ dragOverColumn: null,
160
+ dragOverPosition: null,
161
+ dragSourceColumn: y._id
162
+ }), a == null || a(l, y.title, "being moved");
163
+ }
164
+ }, [D, a]), p = h((u) => {
165
+ if (!s.isDragging || !s.draggedCard || !K.current) {
166
+ K.current = null;
167
+ return;
168
+ }
169
+ 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
+ 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);
177
+ }
178
+ }
179
+ } catch (o) {
180
+ c == null || c(o instanceof Error ? o : new Error("Touch drop failed"));
181
+ } finally {
182
+ K.current = null, b();
183
+ }
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}`);
189
+ }, []);
190
+ return rt(() => () => {
191
+ _.current && clearTimeout(_.current), q.current && document.body.contains(q.current) && document.body.removeChild(q.current);
192
+ }, []), {
193
+ // State
194
+ isDragging: s.isDragging,
195
+ draggedCard: s.draggedCard,
196
+ dragOverColumn: s.dragOverColumn,
197
+ dragOverPosition: s.dragOverPosition,
198
+ dragSourceColumn: s.dragSourceColumn,
199
+ // 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,
208
+ // Utilities
209
+ announceMove: a || T,
210
+ reset: b
211
+ };
212
+ }
213
+ function Xt(i) {
214
+ var at, nt, it;
215
+ const {
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 = {
244
+ LHSField: "columnId",
245
+ Operator: "EQ",
246
+ RHSValue: t,
247
+ RHSType: "Constant"
248
+ }, r = T.payload;
249
+ let n;
250
+ r ? r.Operator === "And" ? n = {
251
+ ...r,
252
+ Condition: [...r.Condition || [], e]
253
+ } : n = {
254
+ Operator: "And",
255
+ Condition: [r, e]
256
+ } : n = {
257
+ Operator: "And",
258
+ Condition: [e]
259
+ };
260
+ const f = {
261
+ Page: 1,
262
+ // Always page 1 due to expanding PageSize strategy
263
+ PageSize: z[t] || 10,
264
+ Filter: n
265
+ };
266
+ return P.field && P.direction ? f.Sort = [
267
+ { [String(P.field)]: P.direction === "asc" ? "ASC" : "DESC" },
268
+ { position: "ASC" }
269
+ ] : f.Sort = [
270
+ { columnId: "ASC" },
271
+ { 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);
276
+ return {
277
+ queryKey: ["kanban-cards", d, t.id, e],
278
+ queryFn: async () => {
279
+ try {
280
+ return await F(d).list(e);
281
+ } catch (r) {
282
+ throw r;
283
+ }
284
+ },
285
+ placeholderData: kt,
286
+ staleTime: 30 * 1e3
287
+ };
288
+ })
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],
300
+ queryFn: async () => {
301
+ try {
302
+ return await F(d).count(S);
303
+ } catch (t) {
304
+ throw C.current && C.current(t), t;
305
+ }
306
+ },
307
+ staleTime: 30 * 1e3,
308
+ gcTime: 60 * 1e3
309
+ }), et = j({
310
+ mutationFn: async (t) => {
311
+ const e = t.position ?? 999999;
312
+ return (await F(d).create({ ...t, position: e }))._id;
313
+ },
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,
323
+ _created_at: /* @__PURE__ */ new Date(),
324
+ _modified_at: /* @__PURE__ */ new Date()
325
+ };
326
+ p.setQueryData(n, {
327
+ ...f,
328
+ Data: [...f.Data, E]
329
+ });
330
+ }
331
+ return { previousCards: f, queryKey: n };
332
+ },
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
338
+ });
339
+ },
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);
343
+ },
344
+ onSettled: (t, e, r) => {
345
+ const n = r.columnId, f = u(n);
346
+ p.invalidateQueries({ queryKey: ["kanban-cards", d, n, f] });
347
+ }
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 });
354
+ },
355
+ onError: (t, e, r) => {
356
+ var n;
357
+ (n = C.current) == null || n.call(C, t);
358
+ },
359
+ onSettled: () => {
360
+ p.invalidateQueries({ queryKey: ["kanban-cards", d] });
361
+ }
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);
368
+ },
369
+ onError: (t, e, r) => {
370
+ var n;
371
+ (n = C.current) == null || n.call(C, t);
372
+ },
373
+ onSettled: () => {
374
+ p.invalidateQueries({ queryKey: ["kanban-cards", d] });
375
+ }
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 };
380
+ },
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,
395
+ _modified_at: /* @__PURE__ */ new Date()
396
+ }, Ot = {
397
+ ...N,
398
+ Data: [...N.Data, St].sort((tt, Kt) => tt.position - Kt.position)
399
+ };
400
+ p.setQueryData(A, M), p.setQueryData(X, Ot);
401
+ }
402
+ }
403
+ return {
404
+ previousFromData: E,
405
+ previousToData: N,
406
+ fromQueryKey: A,
407
+ toQueryKey: X,
408
+ fromColumnId: e,
409
+ toColumnId: r
410
+ };
411
+ },
412
+ onSuccess: async (t) => {
413
+ var e;
414
+ (e = $.current) == null || e.call(
415
+ $,
416
+ { _id: t.cardId },
417
+ t.fromColumnId,
418
+ t.toColumnId
419
+ );
420
+ },
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);
424
+ },
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] });
428
+ }
429
+ }), x = j({
430
+ mutationFn: async ({ cardIds: t, columnId: e }) => {
431
+ const r = t.map((n, f) => ({ id: n, position: f, columnId: e }));
432
+ await Promise.all(
433
+ r.map(
434
+ (n) => F(d).update(n.id, { position: n.position, columnId: n.columnId })
435
+ )
436
+ );
437
+ },
438
+ onMutate: async ({ columnId: t }) => {
439
+ const e = u(t), r = ["kanban-cards", d, t, e];
440
+ return await p.cancelQueries({ queryKey: r }), {};
441
+ },
442
+ onSuccess: () => {
443
+ },
444
+ onError: (t, e, r) => {
445
+ var n;
446
+ (n = C.current) == null || n.call(C, t);
447
+ },
448
+ onSettled: (t, e, r) => {
449
+ const n = u(r.columnId);
450
+ p.invalidateQueries({ queryKey: ["kanban-cards", d, r.columnId, n] });
451
+ }
452
+ }), gt = h(
453
+ async (t, e, r) => {
454
+ try {
455
+ await B.mutateAsync({
456
+ cardId: t._id,
457
+ fromColumnId: e,
458
+ toColumnId: r,
459
+ position: void 0
460
+ });
461
+ } catch {
462
+ }
463
+ },
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) || [];
468
+ return {
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),
475
+ _created_at: /* @__PURE__ */ new Date(),
476
+ _modified_at: /* @__PURE__ */ new Date()
477
+ };
478
+ }), [c, o]), w = Ft({
479
+ onCardMove: gt,
480
+ onError: C.current,
481
+ columns: R,
482
+ announceMove: (t, e, r) => {
483
+ console.log(
484
+ `Kanban: Moved "${t.title}" from ${e} to ${r}`
485
+ );
486
+ }
487
+ }), yt = h(
488
+ (t) => {
489
+ var e, r;
490
+ return {
491
+ draggable: !0,
492
+ 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
+ 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);
500
+ },
501
+ onDragEnd: w.handleDragEnd,
502
+ onKeyDown: (n) => {
503
+ if (!a) return;
504
+ const f = n.nativeEvent || n;
505
+ w.handleKeyDown(f, t);
506
+ }
507
+ };
508
+ },
509
+ [a, w]
510
+ ), mt = h(
511
+ (t) => ({
512
+ "data-column-id": t,
513
+ role: "listbox",
514
+ onDragOver: (e) => {
515
+ if (!a) return;
516
+ const r = e.nativeEvent || e;
517
+ w.handleDragOver(r, t);
518
+ },
519
+ onDrop: (e) => {
520
+ if (!a) return;
521
+ const r = e.nativeEvent || e;
522
+ w.handleDrop(r, t);
523
+ }
524
+ }),
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"
535
+ });
536
+ }, [p]);
537
+ return rt(() => {
538
+ W && C.current && C.current(W);
539
+ }, [W]), {
540
+ // Data
541
+ columns: R,
542
+ totalCards: ht,
543
+ // Loading States
544
+ isLoading: Ct,
545
+ isFetching: Dt,
546
+ isUpdating: wt,
547
+ // Error Handling
548
+ error: W,
549
+ // Card Operations (Flat Access)
550
+ createCard: et.mutateAsync,
551
+ updateCard: h(
552
+ async (t, e) => {
553
+ await Z.mutateAsync({ id: t, updates: e });
554
+ },
555
+ [Z]
556
+ ),
557
+ deleteCard: h(
558
+ async (t) => {
559
+ await v.mutateAsync(t);
560
+ },
561
+ [v]
562
+ ),
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;
569
+ break;
570
+ }
571
+ if (!n)
572
+ throw new Error(`Card ${t} not found in any column`);
573
+ }
574
+ await B.mutateAsync({ cardId: t, fromColumnId: n, toColumnId: e, position: r });
575
+ },
576
+ [B, R]
577
+ ),
578
+ reorderCards: h(
579
+ async (t, e) => {
580
+ await x.mutateAsync({ cardIds: t, columnId: e });
581
+ },
582
+ [x]
583
+ ),
584
+ // Search (Flat Access)
585
+ searchQuery: D.query,
586
+ setSearchQuery: ft,
587
+ clearSearch: pt,
588
+ // Filter (Simplified chainable API)
589
+ filter: T,
590
+ // 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 : () => {
595
+ },
596
+ handleDragOver: a ? w.handleDragOver : () => {
597
+ },
598
+ handleDrop: a ? w.handleDrop : () => {
599
+ },
600
+ handleDragEnd: a ? w.handleDragEnd : () => {
601
+ },
602
+ handleKeyDown: a ? w.handleKeyDown : () => {
603
+ },
604
+ // Prop Getters
605
+ getCardProps: a ? yt : (t) => ({}),
606
+ getColumnProps: a ? mt : (t) => ({}),
607
+ // Load More (Per Column)
608
+ loadMore: h((t) => {
609
+ V((e) => ({
610
+ ...e,
611
+ [t]: (e[t] || 10) + 10
612
+ }));
613
+ }, []),
614
+ // Utilities
615
+ refetch: _t,
616
+ refresh: bt
617
+ };
618
+ }
619
+ const $t = qt(null);
620
+ function Yt() {
621
+ const i = Qt($t);
622
+ if (!i)
623
+ throw new Error(
624
+ "Kanban components must be used within a KanbanBoard component"
625
+ );
626
+ return i;
627
+ }
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)
633
+ }));
634
+ }
635
+ function Nt(i, c) {
636
+ if (i.cards.length === 0)
637
+ 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];
642
+ return Math.max(0, s.position - 1);
643
+ }
644
+ const d = i.cards[c - 1], a = i.cards[c];
645
+ return Math.floor((d.position + a.position) / 2);
646
+ }
647
+ function jt(i, c) {
648
+ if (i.length === 0)
649
+ 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];
654
+ return Math.max(0, s.position - 1);
655
+ }
656
+ const d = i[c - 1], a = i[c];
657
+ return Math.floor((d.position + a.position) / 2);
658
+ }
659
+ function zt(i) {
660
+ return i.sort((c, d) => c.position - d.position).map((c, d) => ({
661
+ ...c,
662
+ position: d
663
+ }));
664
+ }
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`);
668
+ }
669
+ function Rt(i, c) {
670
+ switch (c) {
671
+ case "list":
672
+ return i && Array.isArray(i.Data);
673
+ case "single":
674
+ return i && typeof i == "object";
675
+ case "create":
676
+ return i && typeof i._id == "string";
677
+ case "delete":
678
+ return i && i.status === "success";
679
+ default:
680
+ return !1;
681
+ }
682
+ }
683
+ 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
694
+ };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,2 @@
1
+ export type { UseKanbanOptionsType, UseKanbanReturnType, KanbanCardType, KanbanColumnType, ColumnConfigType, ColumnDefinitionType, BaseKanbanCardType, KanbanCardWithDataType, CardOperationsType, SearchOperationsType, DragDropStateType, DragDropHandlersType, DragDropManagerType, CardApiResponseType, ColumnApiResponseType, MoveCardRequestType, ReorderRequestType, BulkCardUpdateRequestType, BulkColumnUpdateRequestType, ValidationResultType, CardValidationContextType, ColumnValidationContextType, KanbanEventTypeType, KanbanEventType, ExtractCardTypeType, PartialByType, CreateCardInputType, CreateColumnInputType, } from './components/hooks/useKanban/types';
2
+ //# sourceMappingURL=kanban.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kanban.types.d.ts","sourceRoot":"","sources":["../sdk/kanban.types.ts"],"names":[],"mappings":"AAKA,YAAY,EAEV,oBAAoB,EACpB,mBAAmB,EAGnB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EAGtB,kBAAkB,EAClB,oBAAoB,EAGpB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EAGnB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAG3B,oBAAoB,EACpB,yBAAyB,EACzB,2BAA2B,EAG3B,mBAAmB,EACnB,eAAe,EAGf,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC"}
@@ -0,0 +1 @@
1
+