@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.
- package/README.md +55 -48
- package/dist/api/client.d.ts +14 -14
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/datetime.d.ts +5 -5
- package/dist/api/datetime.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/metadata.d.ts +2 -2
- package/dist/api/metadata.d.ts.map +1 -1
- package/dist/api.cjs +1 -0
- package/dist/api.d.ts +4 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.mjs +27 -0
- package/dist/api.types.cjs +1 -0
- package/dist/api.types.d.ts +4 -0
- package/dist/api.types.d.ts.map +1 -0
- package/dist/api.types.mjs +1 -0
- package/dist/auth/AuthProvider.d.ts +3 -3
- package/dist/auth/AuthProvider.d.ts.map +1 -1
- package/dist/auth/authClient.d.ts +4 -4
- package/dist/auth/authClient.d.ts.map +1 -1
- package/dist/auth/authConfig.d.ts +5 -5
- package/dist/auth/authConfig.d.ts.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/types.d.ts +21 -21
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/useAuth.d.ts +2 -2
- package/dist/auth/useAuth.d.ts.map +1 -1
- package/dist/auth.cjs +1 -0
- package/dist/auth.d.ts +5 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.mjs +280 -0
- package/dist/auth.types.cjs +1 -0
- package/dist/auth.types.d.ts +2 -0
- package/dist/auth.types.d.ts.map +1 -0
- package/dist/auth.types.mjs +1 -0
- package/dist/base-types.d.ts +2 -0
- package/dist/base-types.d.ts.map +1 -0
- package/dist/client-C15j4O5B.cjs +1 -0
- package/dist/client-CfvLiGfP.js +233 -0
- package/dist/cn-Dr87sK3i.js +2775 -0
- package/dist/cn-mXUIg4vp.cjs +1 -0
- package/dist/components/hooks/index.d.ts +3 -3
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/index.d.ts +2 -2
- package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/types.d.ts +19 -31
- package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/useFilter.d.ts +2 -2
- package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
- package/dist/components/hooks/useForm/apiClient.d.ts +6 -6
- package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +7 -7
- package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/index.d.ts +5 -5
- package/dist/components/hooks/useForm/index.d.ts.map +1 -1
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +10 -10
- package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +7 -12
- package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts +7 -7
- package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -1
- package/dist/components/hooks/useForm/types.d.ts +67 -76
- package/dist/components/hooks/useForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts +2 -2
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/apiClient.d.ts +16 -16
- package/dist/components/hooks/useKanban/apiClient.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/context.d.ts +3 -3
- package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/dragDropManager.d.ts +7 -7
- package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/index.d.ts +1 -1
- package/dist/components/hooks/useKanban/index.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/types.d.ts +65 -67
- package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
- package/dist/components/hooks/useKanban/useKanban.d.ts +2 -2
- package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
- package/dist/components/hooks/useTable/index.d.ts +1 -1
- package/dist/components/hooks/useTable/index.d.ts.map +1 -1
- package/dist/components/hooks/useTable/types.d.ts +10 -10
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts +2 -2
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/filter.cjs +1 -0
- package/dist/filter.d.ts +3 -0
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.mjs +6 -0
- package/dist/filter.types.cjs +1 -0
- package/dist/filter.types.d.ts +2 -0
- package/dist/filter.types.d.ts.map +1 -0
- package/dist/filter.types.mjs +1 -0
- package/dist/form.cjs +1 -0
- package/dist/form.d.ts +3 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.mjs +1346 -0
- package/dist/form.types.cjs +1 -0
- package/dist/form.types.d.ts +2 -0
- package/dist/form.types.d.ts.map +1 -0
- package/dist/form.types.mjs +1 -0
- package/dist/jsx-runtime-BYECrxsp.cjs +30 -0
- package/dist/jsx-runtime-DGlMoOmv.js +630 -0
- package/dist/kanban.cjs +13 -0
- package/dist/kanban.d.ts +5 -0
- package/dist/kanban.d.ts.map +1 -0
- package/dist/kanban.mjs +694 -0
- package/dist/kanban.types.cjs +1 -0
- package/dist/kanban.types.d.ts +2 -0
- package/dist/kanban.types.d.ts.map +1 -0
- package/dist/kanban.types.mjs +1 -0
- package/dist/kanban.ui.cjs +1 -0
- package/dist/kanban.ui.d.ts +2 -0
- package/dist/kanban.ui.d.ts.map +1 -0
- package/dist/kanban.ui.mjs +104 -0
- package/dist/metadata-2FLBsFcf.cjs +1 -0
- package/dist/metadata-DBcoDth-.js +43 -0
- package/dist/table.cjs +1 -0
- package/dist/table.d.ts +2 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.mjs +148 -0
- package/dist/table.types.cjs +1 -0
- package/dist/table.types.d.ts +2 -0
- package/dist/table.types.d.ts.map +1 -0
- package/dist/table.types.mjs +1 -0
- package/dist/types/base-fields.d.ts +45 -45
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/types/common.d.ts +45 -61
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types.cjs +1 -0
- package/dist/types.mjs +1 -0
- package/dist/useFilter-CXFqEHyI.js +129 -0
- package/dist/useFilter-D-bCDo6Z.cjs +1 -0
- package/dist/utils/formatting.d.ts +4 -4
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils.cjs +4 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.mjs +105 -0
- package/package.json +147 -9
- package/sdk/api/client.ts +51 -51
- package/sdk/api/datetime.ts +5 -5
- package/sdk/api/index.ts +28 -33
- package/sdk/api/metadata.ts +4 -4
- package/sdk/api.ts +24 -0
- package/sdk/api.types.ts +58 -0
- package/sdk/auth/AuthProvider.tsx +18 -18
- package/sdk/auth/authClient.ts +9 -9
- package/sdk/auth/authConfig.ts +9 -9
- package/sdk/auth/index.ts +5 -5
- package/sdk/auth/types.ts +21 -21
- package/sdk/auth/useAuth.ts +2 -2
- package/sdk/auth.ts +22 -0
- package/sdk/auth.types.ts +28 -0
- package/sdk/base-types.ts +45 -0
- package/sdk/components/hooks/index.ts +22 -22
- package/sdk/components/hooks/useFilter/index.ts +8 -14
- package/sdk/components/hooks/useFilter/types.ts +29 -58
- package/sdk/components/hooks/useFilter/useFilter.ts +41 -44
- package/sdk/components/hooks/useForm/apiClient.ts +8 -8
- package/sdk/components/hooks/useForm/expressionValidator.utils.ts +18 -18
- package/sdk/components/hooks/useForm/index.ts +24 -24
- package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +22 -22
- package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +26 -62
- package/sdk/components/hooks/useForm/schemaParser.utils.ts +24 -24
- package/sdk/components/hooks/useForm/types.ts +66 -82
- package/sdk/components/hooks/useForm/useForm.ts +15 -21
- package/sdk/components/hooks/useKanban/apiClient.ts +54 -54
- package/sdk/components/hooks/useKanban/context.ts +3 -3
- package/sdk/components/hooks/useKanban/dragDropManager.ts +19 -19
- package/sdk/components/hooks/useKanban/index.ts +26 -26
- package/sdk/components/hooks/useKanban/types.ts +69 -71
- package/sdk/components/hooks/useKanban/useKanban.ts +43 -51
- package/sdk/components/hooks/useKanban/useKanbanSimple.ts +4 -4
- package/sdk/components/hooks/useTable/index.ts +5 -1
- package/sdk/components/hooks/useTable/types.ts +10 -10
- package/sdk/components/hooks/useTable/useTable.ts +10 -10
- package/sdk/filter.ts +13 -0
- package/sdk/filter.types.ts +17 -0
- package/sdk/form.ts +15 -0
- package/sdk/form.types.ts +46 -0
- package/sdk/kanban.ts +23 -0
- package/sdk/kanban.types.ts +50 -0
- package/sdk/kanban.ui.ts +16 -0
- package/sdk/table.ts +7 -0
- package/sdk/table.types.ts +13 -0
- package/sdk/types/base-fields.ts +47 -47
- package/sdk/types/common.ts +47 -71
- package/sdk/types/index.ts +1 -1
- package/sdk/utils/formatting.ts +4 -4
- package/sdk/utils.ts +10 -0
- package/dist/index.cjs +0 -45
- package/dist/index.mjs +0 -6387
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
// Follows the same structure as useForm and useTable API clients
|
|
6
6
|
|
|
7
7
|
import { api } from "../../../api";
|
|
8
|
-
import type {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
import type {
|
|
9
|
+
ListOptionsType,
|
|
10
|
+
ListResponseType,
|
|
11
|
+
CreateUpdateResponseType,
|
|
12
|
+
DeleteResponseType,
|
|
13
|
+
CountResponseType
|
|
14
14
|
} from "../../../types/common";
|
|
15
15
|
import type {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
KanbanCardType,
|
|
17
|
+
KanbanColumnType,
|
|
18
|
+
BulkCardUpdateRequestType,
|
|
19
|
+
BulkColumnUpdateRequestType
|
|
20
20
|
} from "./types";
|
|
21
21
|
|
|
22
22
|
// ============================================================
|
|
@@ -28,18 +28,18 @@ import type {
|
|
|
28
28
|
*/
|
|
29
29
|
export async function fetchColumns<T>(
|
|
30
30
|
source: string,
|
|
31
|
-
options?:
|
|
32
|
-
): Promise<
|
|
33
|
-
const client = api<
|
|
31
|
+
options?: ListOptionsType
|
|
32
|
+
): Promise<KanbanColumnType<T>[]> {
|
|
33
|
+
const client = api<KanbanColumnType<T>>(source);
|
|
34
34
|
|
|
35
35
|
// Build API options for columns query
|
|
36
|
-
const apiOptions:
|
|
36
|
+
const apiOptions: ListOptionsType = {
|
|
37
37
|
...options,
|
|
38
38
|
// Default sort by position if no sort specified - using correct API format
|
|
39
39
|
Sort: options?.Sort || [{ position: "ASC" }]
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
const response:
|
|
42
|
+
const response: ListResponseType<KanbanColumnType<T>> = await client.list(apiOptions);
|
|
43
43
|
|
|
44
44
|
// Initialize empty cards array for each column
|
|
45
45
|
// Cards will be fetched separately and merged
|
|
@@ -54,14 +54,14 @@ export async function fetchColumns<T>(
|
|
|
54
54
|
*/
|
|
55
55
|
export async function createColumn<T>(
|
|
56
56
|
source: string,
|
|
57
|
-
column: Partial<
|
|
57
|
+
column: Partial<KanbanColumnType<T>>
|
|
58
58
|
): Promise<string> {
|
|
59
|
-
const client = api<
|
|
59
|
+
const client = api<KanbanColumnType<T>>(source);
|
|
60
60
|
|
|
61
61
|
// Exclude cards array from creation payload
|
|
62
62
|
const { cards, ...columnData } = column;
|
|
63
63
|
|
|
64
|
-
const response:
|
|
64
|
+
const response: CreateUpdateResponseType = await client.create(columnData);
|
|
65
65
|
return response._id;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -71,9 +71,9 @@ export async function createColumn<T>(
|
|
|
71
71
|
export async function updateColumn<T>(
|
|
72
72
|
source: string,
|
|
73
73
|
id: string,
|
|
74
|
-
updates: Partial<
|
|
74
|
+
updates: Partial<KanbanColumnType<T>>
|
|
75
75
|
): Promise<void> {
|
|
76
|
-
const client = api<
|
|
76
|
+
const client = api<KanbanColumnType<T>>(source);
|
|
77
77
|
|
|
78
78
|
// Exclude cards array from update payload
|
|
79
79
|
const { cards, ...columnUpdates } = updates;
|
|
@@ -99,7 +99,7 @@ export async function reorderColumns<T>(
|
|
|
99
99
|
source: string,
|
|
100
100
|
columnIds: string[]
|
|
101
101
|
): Promise<void> {
|
|
102
|
-
const client = api<
|
|
102
|
+
const client = api<KanbanColumnType<T>>(source);
|
|
103
103
|
|
|
104
104
|
// Update position for each column
|
|
105
105
|
const updates = columnIds.map((id, index) => ({
|
|
@@ -124,12 +124,12 @@ export async function reorderColumns<T>(
|
|
|
124
124
|
*/
|
|
125
125
|
export async function fetchCards<T>(
|
|
126
126
|
source: string,
|
|
127
|
-
options?:
|
|
128
|
-
): Promise<
|
|
129
|
-
const client = api<
|
|
127
|
+
options?: ListOptionsType
|
|
128
|
+
): Promise<KanbanCardType<T>[]> {
|
|
129
|
+
const client = api<KanbanCardType<T>>(source);
|
|
130
130
|
|
|
131
131
|
// Build API options for cards query
|
|
132
|
-
const apiOptions:
|
|
132
|
+
const apiOptions: ListOptionsType = {
|
|
133
133
|
...options,
|
|
134
134
|
// Default sort by column and position if no sort specified - using correct API format
|
|
135
135
|
Sort: options?.Sort || [
|
|
@@ -138,7 +138,7 @@ export async function fetchCards<T>(
|
|
|
138
138
|
]
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
const response:
|
|
141
|
+
const response: ListResponseType<KanbanCardType<T>> = await client.list(apiOptions);
|
|
142
142
|
return response.Data;
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -147,11 +147,11 @@ export async function fetchCards<T>(
|
|
|
147
147
|
*/
|
|
148
148
|
export async function createCard<T>(
|
|
149
149
|
source: string,
|
|
150
|
-
card: Partial<
|
|
150
|
+
card: Partial<KanbanCardType<T>> & { columnId: string }
|
|
151
151
|
): Promise<string> {
|
|
152
|
-
const client = api<
|
|
152
|
+
const client = api<KanbanCardType<T>>(source);
|
|
153
153
|
|
|
154
|
-
const response:
|
|
154
|
+
const response: CreateUpdateResponseType = await client.create(card);
|
|
155
155
|
return response._id;
|
|
156
156
|
}
|
|
157
157
|
|
|
@@ -161,9 +161,9 @@ export async function createCard<T>(
|
|
|
161
161
|
export async function updateCard<T>(
|
|
162
162
|
source: string,
|
|
163
163
|
id: string,
|
|
164
|
-
updates: Partial<
|
|
164
|
+
updates: Partial<KanbanCardType<T>>
|
|
165
165
|
): Promise<void> {
|
|
166
|
-
const client = api<
|
|
166
|
+
const client = api<KanbanCardType<T>>(source);
|
|
167
167
|
await client.update(id, updates);
|
|
168
168
|
}
|
|
169
169
|
|
|
@@ -187,7 +187,7 @@ export async function moveCard<T>(
|
|
|
187
187
|
toColumnId: string,
|
|
188
188
|
position?: number
|
|
189
189
|
): Promise<void> {
|
|
190
|
-
const client = api<
|
|
190
|
+
const client = api<KanbanCardType<T>>(source);
|
|
191
191
|
|
|
192
192
|
const updates: any = {
|
|
193
193
|
columnId: toColumnId,
|
|
@@ -205,7 +205,7 @@ export async function reorderCards<T>(
|
|
|
205
205
|
cardIds: string[],
|
|
206
206
|
columnId: string
|
|
207
207
|
): Promise<void> {
|
|
208
|
-
const client = api<
|
|
208
|
+
const client = api<KanbanCardType<T>>(source);
|
|
209
209
|
|
|
210
210
|
// Update position for each card
|
|
211
211
|
const updates = cardIds.map((id, index) => ({
|
|
@@ -230,9 +230,9 @@ export async function reorderCards<T>(
|
|
|
230
230
|
*/
|
|
231
231
|
export async function bulkUpdateCards<T>(
|
|
232
232
|
source: string,
|
|
233
|
-
request:
|
|
233
|
+
request: BulkCardUpdateRequestType<T>
|
|
234
234
|
): Promise<void> {
|
|
235
|
-
const client = api<
|
|
235
|
+
const client = api<KanbanCardType<T>>(source);
|
|
236
236
|
|
|
237
237
|
await Promise.all(
|
|
238
238
|
request.updates.map(update =>
|
|
@@ -246,9 +246,9 @@ export async function bulkUpdateCards<T>(
|
|
|
246
246
|
*/
|
|
247
247
|
export async function bulkUpdateColumns<T>(
|
|
248
248
|
source: string,
|
|
249
|
-
request:
|
|
249
|
+
request: BulkColumnUpdateRequestType<T>
|
|
250
250
|
): Promise<void> {
|
|
251
|
-
const client = api<
|
|
251
|
+
const client = api<KanbanColumnType<T>>(source);
|
|
252
252
|
|
|
253
253
|
await Promise.all(
|
|
254
254
|
request.updates.map(update =>
|
|
@@ -266,7 +266,7 @@ export async function bulkMoveCards<T>(
|
|
|
266
266
|
toColumnId: string,
|
|
267
267
|
startPosition = 0
|
|
268
268
|
): Promise<void> {
|
|
269
|
-
const client = api<
|
|
269
|
+
const client = api<KanbanCardType<T>>(cardSource);
|
|
270
270
|
|
|
271
271
|
const updates = cardIds.map((cardId, index) => ({
|
|
272
272
|
cardId,
|
|
@@ -296,7 +296,7 @@ export async function getCardCount(
|
|
|
296
296
|
): Promise<number> {
|
|
297
297
|
const client = api(source);
|
|
298
298
|
|
|
299
|
-
const options:
|
|
299
|
+
const options: ListOptionsType = {
|
|
300
300
|
Filter: {
|
|
301
301
|
Operator: "And",
|
|
302
302
|
Condition: [
|
|
@@ -310,7 +310,7 @@ export async function getCardCount(
|
|
|
310
310
|
}
|
|
311
311
|
};
|
|
312
312
|
|
|
313
|
-
const response:
|
|
313
|
+
const response: CountResponseType = await client.count(options);
|
|
314
314
|
return response.Count;
|
|
315
315
|
}
|
|
316
316
|
|
|
@@ -319,10 +319,10 @@ export async function getCardCount(
|
|
|
319
319
|
*/
|
|
320
320
|
export async function getTotalCardCount(
|
|
321
321
|
source: string,
|
|
322
|
-
options?:
|
|
322
|
+
options?: ListOptionsType
|
|
323
323
|
): Promise<number> {
|
|
324
324
|
const client = api(source);
|
|
325
|
-
const response:
|
|
325
|
+
const response: CountResponseType = await client.count(options);
|
|
326
326
|
return response.Count;
|
|
327
327
|
}
|
|
328
328
|
|
|
@@ -332,11 +332,11 @@ export async function getTotalCardCount(
|
|
|
332
332
|
export async function searchCards<T>(
|
|
333
333
|
source: string,
|
|
334
334
|
searchQuery: string,
|
|
335
|
-
additionalOptions?:
|
|
336
|
-
): Promise<
|
|
337
|
-
const client = api<
|
|
335
|
+
additionalOptions?: ListOptionsType
|
|
336
|
+
): Promise<KanbanCardType<T>[]> {
|
|
337
|
+
const client = api<KanbanCardType<T>>(source);
|
|
338
338
|
|
|
339
|
-
const options:
|
|
339
|
+
const options: ListOptionsType = {
|
|
340
340
|
...additionalOptions,
|
|
341
341
|
Search: searchQuery,
|
|
342
342
|
Sort: additionalOptions?.Sort || [
|
|
@@ -345,7 +345,7 @@ export async function searchCards<T>(
|
|
|
345
345
|
]
|
|
346
346
|
};
|
|
347
347
|
|
|
348
|
-
const response:
|
|
348
|
+
const response: ListResponseType<KanbanCardType<T>> = await client.list(options);
|
|
349
349
|
return response.Data;
|
|
350
350
|
}
|
|
351
351
|
|
|
@@ -357,9 +357,9 @@ export async function searchCards<T>(
|
|
|
357
357
|
* Merge cards into their respective columns
|
|
358
358
|
*/
|
|
359
359
|
export function mergeCardsIntoColumns<T>(
|
|
360
|
-
columns:
|
|
361
|
-
cards:
|
|
362
|
-
):
|
|
360
|
+
columns: KanbanColumnType<T>[],
|
|
361
|
+
cards: KanbanCardType<T>[]
|
|
362
|
+
): KanbanColumnType<T>[] {
|
|
363
363
|
// Group cards by columnId
|
|
364
364
|
const cardsByColumn = cards.reduce((acc, card) => {
|
|
365
365
|
if (!acc[card.columnId]) {
|
|
@@ -367,7 +367,7 @@ export function mergeCardsIntoColumns<T>(
|
|
|
367
367
|
}
|
|
368
368
|
acc[card.columnId].push(card);
|
|
369
369
|
return acc;
|
|
370
|
-
}, {} as Record<string,
|
|
370
|
+
}, {} as Record<string, KanbanCardType<T>[]>);
|
|
371
371
|
|
|
372
372
|
// Assign cards to their respective columns
|
|
373
373
|
return columns.map(column => ({
|
|
@@ -381,7 +381,7 @@ export function mergeCardsIntoColumns<T>(
|
|
|
381
381
|
* Calculate optimal position for inserting a new card
|
|
382
382
|
*/
|
|
383
383
|
export function calculateCardPosition<T>(
|
|
384
|
-
column:
|
|
384
|
+
column: KanbanColumnType<T>,
|
|
385
385
|
insertIndex?: number
|
|
386
386
|
): number {
|
|
387
387
|
if (column.cards.length === 0) {
|
|
@@ -410,7 +410,7 @@ export function calculateCardPosition<T>(
|
|
|
410
410
|
* Calculate optimal position for inserting a new column
|
|
411
411
|
*/
|
|
412
412
|
export function calculateColumnPosition<T>(
|
|
413
|
-
columns:
|
|
413
|
+
columns: KanbanColumnType<T>[],
|
|
414
414
|
insertIndex?: number
|
|
415
415
|
): number {
|
|
416
416
|
if (columns.length === 0) {
|
|
@@ -478,7 +478,7 @@ export function handleKanbanApiError(
|
|
|
478
478
|
export function validateApiResponse<T>(
|
|
479
479
|
response: any,
|
|
480
480
|
expectedType: 'list' | 'single' | 'create' | 'delete'
|
|
481
|
-
): response is
|
|
481
|
+
): response is ListResponseType<T> | T | CreateUpdateResponseType | DeleteResponseType {
|
|
482
482
|
switch (expectedType) {
|
|
483
483
|
case 'list':
|
|
484
484
|
return response && Array.isArray(response.Data);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { UseKanbanReturnType } from "./types";
|
|
3
3
|
|
|
4
|
-
export const KanbanContext = createContext<
|
|
4
|
+
export const KanbanContext = createContext<UseKanbanReturnType<any> | null>(null);
|
|
5
5
|
|
|
6
6
|
export function useKanbanContext<T extends Record<string, any> = any>() {
|
|
7
7
|
const context = useContext(KanbanContext);
|
|
@@ -10,5 +10,5 @@ export function useKanbanContext<T extends Record<string, any> = any>() {
|
|
|
10
10
|
"Kanban components must be used within a KanbanBoard component"
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
|
-
return context as
|
|
13
|
+
return context as UseKanbanReturnType<T>;
|
|
14
14
|
}
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
import { useState, useCallback, useRef, useEffect } from "react";
|
|
8
8
|
import type {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
KanbanCardType,
|
|
10
|
+
KanbanColumnType,
|
|
11
|
+
DragDropStateType,
|
|
12
|
+
DragDropManagerType
|
|
13
13
|
} from "./types";
|
|
14
14
|
|
|
15
15
|
// ============================================================
|
|
@@ -30,17 +30,17 @@ export function useDragDropManager<T>({
|
|
|
30
30
|
columns,
|
|
31
31
|
announceMove
|
|
32
32
|
}: {
|
|
33
|
-
onCardMove?: (card:
|
|
33
|
+
onCardMove?: (card: KanbanCardType<T>, fromColumnId: string, toColumnId: string) => void;
|
|
34
34
|
onError?: (error: Error) => void;
|
|
35
|
-
columns:
|
|
36
|
-
announceMove?: (card:
|
|
37
|
-
}):
|
|
35
|
+
columns: KanbanColumnType<T>[];
|
|
36
|
+
announceMove?: (card: KanbanCardType<T>, fromColumn: string, toColumn: string) => void;
|
|
37
|
+
}): DragDropManagerType<T> {
|
|
38
38
|
|
|
39
39
|
// ============================================================
|
|
40
40
|
// STATE MANAGEMENT
|
|
41
41
|
// ============================================================
|
|
42
42
|
|
|
43
|
-
const [dragState, setDragState] = useState<
|
|
43
|
+
const [dragState, setDragState] = useState<DragDropStateType<T>>({
|
|
44
44
|
isDragging: false,
|
|
45
45
|
draggedCard: null,
|
|
46
46
|
dragOverColumn: null,
|
|
@@ -51,7 +51,7 @@ export function useDragDropManager<T>({
|
|
|
51
51
|
// Refs for managing drag operations
|
|
52
52
|
const dragImageRef = useRef<HTMLElement | null>(null);
|
|
53
53
|
const autoScrollTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
54
|
-
const touchStartRef = useRef<{ x: number; y: number; card:
|
|
54
|
+
const touchStartRef = useRef<{ x: number; y: number; card: KanbanCardType<T> } | null>(null);
|
|
55
55
|
|
|
56
56
|
// ============================================================
|
|
57
57
|
// UTILITY FUNCTIONS
|
|
@@ -73,11 +73,11 @@ export function useDragDropManager<T>({
|
|
|
73
73
|
}
|
|
74
74
|
}, []);
|
|
75
75
|
|
|
76
|
-
const findColumnById = useCallback((columnId: string):
|
|
76
|
+
const findColumnById = useCallback((columnId: string): KanbanColumnType<T> | null => {
|
|
77
77
|
return columns.find(col => col._id === columnId) || null;
|
|
78
78
|
}, [columns]);
|
|
79
79
|
|
|
80
|
-
const findCardById = useCallback((cardId: string): { card:
|
|
80
|
+
const findCardById = useCallback((cardId: string): { card: KanbanCardType<T>; column: KanbanColumnType<T> } | null => {
|
|
81
81
|
for (const column of columns) {
|
|
82
82
|
const card = column.cards.find(c => c._id === cardId);
|
|
83
83
|
if (card) {
|
|
@@ -91,7 +91,7 @@ export function useDragDropManager<T>({
|
|
|
91
91
|
// MOUSE DRAG HANDLERS
|
|
92
92
|
// ============================================================
|
|
93
93
|
|
|
94
|
-
const handleDragStart = useCallback((event: DragEvent, card:
|
|
94
|
+
const handleDragStart = useCallback((event: DragEvent, card: KanbanCardType<T>) => {
|
|
95
95
|
try {
|
|
96
96
|
const cardElement = event.target as HTMLElement;
|
|
97
97
|
const sourceColumn = findColumnById(card.columnId);
|
|
@@ -260,7 +260,7 @@ export function useDragDropManager<T>({
|
|
|
260
260
|
// KEYBOARD NAVIGATION
|
|
261
261
|
// ============================================================
|
|
262
262
|
|
|
263
|
-
const handleKeyDown = useCallback((event: KeyboardEvent, card:
|
|
263
|
+
const handleKeyDown = useCallback((event: KeyboardEvent, card: KanbanCardType<T>) => {
|
|
264
264
|
if (!['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Enter', 'Space', 'Escape'].includes(event.key)) {
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
@@ -323,7 +323,7 @@ export function useDragDropManager<T>({
|
|
|
323
323
|
// TOUCH HANDLERS
|
|
324
324
|
// ============================================================
|
|
325
325
|
|
|
326
|
-
const handleTouchStart = useCallback((event: TouchEvent, card:
|
|
326
|
+
const handleTouchStart = useCallback((event: TouchEvent, card: KanbanCardType<T>) => {
|
|
327
327
|
const touch = event.touches[0];
|
|
328
328
|
touchStartRef.current = {
|
|
329
329
|
x: touch.clientX,
|
|
@@ -399,7 +399,7 @@ export function useDragDropManager<T>({
|
|
|
399
399
|
// ACCESSIBILITY ANNOUNCEMENTS
|
|
400
400
|
// ============================================================
|
|
401
401
|
|
|
402
|
-
const defaultAnnounceMove = useCallback((card:
|
|
402
|
+
const defaultAnnounceMove = useCallback((card: KanbanCardType<T>, fromColumn: string, toColumn: string) => {
|
|
403
403
|
const message = `Moved "${card.title}" from ${fromColumn} to ${toColumn}`;
|
|
404
404
|
|
|
405
405
|
// Create live region announcement
|
|
@@ -474,7 +474,7 @@ export function useDragDropManager<T>({
|
|
|
474
474
|
*/
|
|
475
475
|
export function calculateDropPosition<T>(
|
|
476
476
|
event: DragEvent,
|
|
477
|
-
column:
|
|
477
|
+
column: KanbanColumnType<T>,
|
|
478
478
|
cardHeight = 80
|
|
479
479
|
): number {
|
|
480
480
|
const columnElement = (event.target as HTMLElement).closest('.kanban-column');
|
|
@@ -511,8 +511,8 @@ export function removeDragFeedback(element: HTMLElement) {
|
|
|
511
511
|
* Check if a column can accept a drop
|
|
512
512
|
*/
|
|
513
513
|
export function canAcceptDrop<T>(
|
|
514
|
-
column:
|
|
515
|
-
draggedCard:
|
|
514
|
+
column: KanbanColumnType<T>,
|
|
515
|
+
draggedCard: KanbanCardType<T>
|
|
516
516
|
): { canDrop: boolean; reason?: string } {
|
|
517
517
|
// Check if column has a limit
|
|
518
518
|
if (column.limit && column.cards.length >= column.limit && draggedCard.columnId !== column._id) {
|
|
@@ -7,44 +7,44 @@ export { KanbanContext, useKanbanContext } from './context';
|
|
|
7
7
|
|
|
8
8
|
export type {
|
|
9
9
|
// Core interfaces
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
UseKanbanOptionsType,
|
|
11
|
+
UseKanbanReturnType,
|
|
12
|
+
KanbanCardType,
|
|
13
|
+
KanbanColumnType,
|
|
14
|
+
ColumnConfigType,
|
|
15
|
+
ColumnDefinitionType,
|
|
16
16
|
|
|
17
17
|
// Operations
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
CardOperationsType,
|
|
19
|
+
SearchOperationsType,
|
|
20
20
|
|
|
21
21
|
// Drag & Drop
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
DragDropStateType,
|
|
23
|
+
DragDropHandlersType,
|
|
24
|
+
DragDropManagerType,
|
|
25
25
|
|
|
26
26
|
// API Types
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
CardApiResponseType,
|
|
28
|
+
ColumnApiResponseType,
|
|
29
|
+
MoveCardRequestType,
|
|
30
|
+
ReorderRequestType,
|
|
31
|
+
BulkCardUpdateRequestType,
|
|
32
|
+
BulkColumnUpdateRequestType,
|
|
33
33
|
|
|
34
34
|
// Validation
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
ValidationResultType,
|
|
36
|
+
CardValidationContextType,
|
|
37
|
+
ColumnValidationContextType,
|
|
38
38
|
|
|
39
39
|
// Events
|
|
40
|
+
KanbanEventTypeType,
|
|
40
41
|
KanbanEventType,
|
|
41
|
-
KanbanEvent,
|
|
42
42
|
|
|
43
43
|
// Utility Types
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
ExtractCardTypeType,
|
|
45
|
+
PartialByType,
|
|
46
|
+
CreateCardInputType,
|
|
47
|
+
CreateColumnInputType,
|
|
48
48
|
} from './types';
|
|
49
49
|
|
|
50
50
|
// Export utility functions for advanced use cases
|
|
@@ -59,4 +59,4 @@ export {
|
|
|
59
59
|
|
|
60
60
|
export {
|
|
61
61
|
useDragDropManager
|
|
62
|
-
} from './dragDropManager';
|
|
62
|
+
} from './dragDropManager';
|