@ram_28/kf-ai-sdk 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/index.d.ts +3 -3
- package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
- package/dist/components/hooks/useFilter/types.d.ts +83 -109
- 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/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 +6 -46
- 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 +5 -33
- package/dist/components/hooks/useTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useTable/useTable.d.ts +0 -5
- package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.mjs +2130 -2368
- package/dist/types/common.d.ts +35 -26
- package/dist/types/common.d.ts.map +1 -1
- package/package.json +1 -1
- package/sdk/api/index.ts +7 -3
- package/sdk/components/hooks/useFilter/index.ts +19 -18
- package/sdk/components/hooks/useFilter/types.ts +157 -123
- package/sdk/components/hooks/useFilter/useFilter.ts +259 -393
- package/sdk/components/hooks/useKanban/index.ts +0 -1
- package/sdk/components/hooks/useKanban/types.ts +8 -66
- package/sdk/components/hooks/useKanban/useKanban.ts +14 -75
- package/sdk/components/hooks/useTable/types.ts +7 -60
- package/sdk/components/hooks/useTable/useTable.ts +13 -121
- package/sdk/types/common.ts +42 -26
- package/dist/components/hooks/useFilter/payloadBuilder.utils.d.ts +0 -33
- package/dist/components/hooks/useFilter/payloadBuilder.utils.d.ts.map +0 -1
- package/sdk/components/hooks/useFilter/payloadBuilder.utils.ts +0 -298
|
@@ -4,11 +4,8 @@
|
|
|
4
4
|
// Core TypeScript interfaces for the kanban board functionality
|
|
5
5
|
// Following patterns from useTable and useForm
|
|
6
6
|
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
ValidationError,
|
|
10
|
-
} from "../useFilter";
|
|
11
|
-
import type { LogicalOperator } from "../../../types/common";
|
|
7
|
+
import type { Condition, ConditionGroup, UseFilterReturn } from "../useFilter";
|
|
8
|
+
import type { ConditionGroupOperator } from "../../../types/common";
|
|
12
9
|
|
|
13
10
|
// ============================================================
|
|
14
11
|
// CORE DATA STRUCTURES
|
|
@@ -201,9 +198,9 @@ export interface UseKanbanOptions<T> {
|
|
|
201
198
|
/** Initial state */
|
|
202
199
|
initialState?: {
|
|
203
200
|
/** Initial filter conditions */
|
|
204
|
-
filters?:
|
|
205
|
-
/** Initial filter operator */
|
|
206
|
-
filterOperator?:
|
|
201
|
+
filters?: Array<Condition | ConditionGroup>;
|
|
202
|
+
/** Initial filter operator for combining filter conditions */
|
|
203
|
+
filterOperator?: ConditionGroupOperator;
|
|
207
204
|
/** Initial search query */
|
|
208
205
|
search?: string;
|
|
209
206
|
/** Initial column order */
|
|
@@ -226,7 +223,6 @@ export interface UseKanbanOptions<T> {
|
|
|
226
223
|
onCardDelete?: (cardId: string) => void;
|
|
227
224
|
onSuccess?: (data: any) => void;
|
|
228
225
|
onError?: (error: Error) => void;
|
|
229
|
-
onFilterError?: (errors: ValidationError[]) => void;
|
|
230
226
|
}
|
|
231
227
|
|
|
232
228
|
// ============================================================
|
|
@@ -268,60 +264,6 @@ export interface SearchOperations {
|
|
|
268
264
|
clear: () => void;
|
|
269
265
|
}
|
|
270
266
|
|
|
271
|
-
/**
|
|
272
|
-
* Filter functionality interface (reusing from useFilter)
|
|
273
|
-
*/
|
|
274
|
-
export interface FilterOperations {
|
|
275
|
-
/** Current filter conditions */
|
|
276
|
-
conditions: FilterConditionWithId[];
|
|
277
|
-
/** Logical operator for combining conditions */
|
|
278
|
-
logicalOperator: LogicalOperator;
|
|
279
|
-
/** Whether all conditions are valid */
|
|
280
|
-
isValid: boolean;
|
|
281
|
-
/** Current validation errors */
|
|
282
|
-
validationErrors: ValidationError[];
|
|
283
|
-
/** Whether there are any conditions */
|
|
284
|
-
hasConditions: boolean;
|
|
285
|
-
|
|
286
|
-
/** Add a new filter condition */
|
|
287
|
-
addCondition: (
|
|
288
|
-
condition: Omit<FilterConditionWithId, "id" | "isValid">
|
|
289
|
-
) => string;
|
|
290
|
-
/** Update an existing condition */
|
|
291
|
-
updateCondition: (
|
|
292
|
-
id: string,
|
|
293
|
-
updates: Partial<FilterConditionWithId>
|
|
294
|
-
) => boolean;
|
|
295
|
-
/** Remove a condition */
|
|
296
|
-
removeCondition: (id: string) => boolean;
|
|
297
|
-
/** Clear all conditions */
|
|
298
|
-
clearConditions: () => void;
|
|
299
|
-
/** Get a specific condition */
|
|
300
|
-
getCondition: (id: string) => FilterConditionWithId | undefined;
|
|
301
|
-
|
|
302
|
-
/** Set logical operator */
|
|
303
|
-
setLogicalOperator: (operator: LogicalOperator) => void;
|
|
304
|
-
|
|
305
|
-
/** Bulk operations */
|
|
306
|
-
setConditions: (conditions: FilterConditionWithId[]) => void;
|
|
307
|
-
replaceCondition: (
|
|
308
|
-
id: string,
|
|
309
|
-
newCondition: Omit<FilterConditionWithId, "id" | "isValid">
|
|
310
|
-
) => boolean;
|
|
311
|
-
|
|
312
|
-
/** Validation */
|
|
313
|
-
validateCondition: (condition: Partial<FilterConditionWithId>) => any;
|
|
314
|
-
validateAllConditions: () => any;
|
|
315
|
-
|
|
316
|
-
/** State management */
|
|
317
|
-
exportState: () => any;
|
|
318
|
-
importState: (state: any) => void;
|
|
319
|
-
resetToInitial: () => void;
|
|
320
|
-
|
|
321
|
-
/** Utilities */
|
|
322
|
-
getConditionCount: () => number;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
267
|
/**
|
|
326
268
|
* Main return interface for useKanban hook
|
|
327
269
|
* Follows useTable pattern with flat access
|
|
@@ -388,11 +330,11 @@ export interface UseKanbanReturn<T> {
|
|
|
388
330
|
clearSearch: () => void;
|
|
389
331
|
|
|
390
332
|
// ============================================================
|
|
391
|
-
// FILTER (
|
|
333
|
+
// FILTER (Simplified chainable API)
|
|
392
334
|
// ============================================================
|
|
393
335
|
|
|
394
336
|
/** Filter functionality */
|
|
395
|
-
filter:
|
|
337
|
+
filter: UseFilterReturn;
|
|
396
338
|
|
|
397
339
|
// ============================================================
|
|
398
340
|
// DRAG DROP (Flat Access)
|
|
@@ -487,7 +429,7 @@ export interface MoveCardRequest {
|
|
|
487
429
|
*/
|
|
488
430
|
export interface ReorderRequest {
|
|
489
431
|
itemIds: string[];
|
|
490
|
-
containerId?: string;
|
|
432
|
+
containerId?: string;
|
|
491
433
|
}
|
|
492
434
|
|
|
493
435
|
/**
|
|
@@ -34,12 +34,11 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
34
34
|
onCardUpdate,
|
|
35
35
|
onCardDelete,
|
|
36
36
|
onError,
|
|
37
|
-
onFilterError,
|
|
38
37
|
} = options;
|
|
39
38
|
|
|
40
39
|
// Use source or cardSource (backwards compatibility)
|
|
41
40
|
const dataSource = source || cardSource;
|
|
42
|
-
|
|
41
|
+
|
|
43
42
|
if (!dataSource) {
|
|
44
43
|
throw new Error('useKanban requires either "source" or "cardSource" parameter');
|
|
45
44
|
}
|
|
@@ -89,11 +88,9 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
89
88
|
// FILTER INTEGRATION
|
|
90
89
|
// ============================================================
|
|
91
90
|
|
|
92
|
-
const
|
|
91
|
+
const filter = useFilter({
|
|
93
92
|
initialConditions: initialState?.filters,
|
|
94
|
-
|
|
95
|
-
validateOnChange: true,
|
|
96
|
-
onValidationError: onFilterError,
|
|
93
|
+
initialOperator: initialState?.filterOperator || "And",
|
|
97
94
|
});
|
|
98
95
|
|
|
99
96
|
// Helper to generate API options for a specific column
|
|
@@ -107,7 +104,7 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
107
104
|
RHSType: "Constant"
|
|
108
105
|
};
|
|
109
106
|
|
|
110
|
-
const basePayload =
|
|
107
|
+
const basePayload = filter.payload;
|
|
111
108
|
let combinedPayload: any;
|
|
112
109
|
|
|
113
110
|
if (!basePayload) {
|
|
@@ -154,9 +151,9 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
154
151
|
if (search.query) {
|
|
155
152
|
opts.Search = search.query;
|
|
156
153
|
}
|
|
157
|
-
|
|
154
|
+
|
|
158
155
|
return opts;
|
|
159
|
-
}, [
|
|
156
|
+
}, [filter.payload, columnPagination, sorting, search.query]);
|
|
160
157
|
|
|
161
158
|
// ============================================================
|
|
162
159
|
// COLUMN QUERY GENERATION
|
|
@@ -188,21 +185,13 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
188
185
|
await Promise.all(columnQueries.map(q => q.refetch()));
|
|
189
186
|
};
|
|
190
187
|
|
|
191
|
-
// Get total card count (Global count, or sum of columns? Usually global might differ if filters applied)
|
|
192
|
-
// For simplicity, we can fetch global count but restricted by filters?
|
|
193
|
-
// Actually, standard Kanban usually doesn't show "Total Cards" unless it's per column.
|
|
194
|
-
// We will keep the global count query for now but it might be slightly inaccurate if we want "Total Visible".
|
|
195
|
-
// Let's rely on summing up column counts for "Total Visible" and keep this for "Total Database"?
|
|
196
|
-
// Or just query with base filters?
|
|
197
|
-
// Let's keep existing logic but apply ONLY base filters + search.
|
|
198
|
-
|
|
199
188
|
const cardApiOptions = useMemo((): ListOptions => {
|
|
200
189
|
// This is for the GLOBAL count (ignoring column split)
|
|
201
190
|
const opts: ListOptions = {};
|
|
202
191
|
if (search.query) opts.Search = search.query;
|
|
203
|
-
if (
|
|
192
|
+
if (filter.payload) opts.Filter = filter.payload;
|
|
204
193
|
return opts;
|
|
205
|
-
}, [search.query,
|
|
194
|
+
}, [search.query, filter.payload]);
|
|
206
195
|
|
|
207
196
|
const {
|
|
208
197
|
data: countData,
|
|
@@ -230,11 +219,6 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
230
219
|
|
|
231
220
|
const createCardMutation = useMutation({
|
|
232
221
|
mutationFn: async (card: Partial<KanbanCard<T>> & { columnId: string }) => {
|
|
233
|
-
// We need to fetch the current count or max position to append correclty if not provided
|
|
234
|
-
// Simplification: just send position=999999 or let backend handle it?
|
|
235
|
-
// Since we want optimistic UI, we should calculate it.
|
|
236
|
-
// But calculating it from partial data (paginated) is risky.
|
|
237
|
-
// Let's rely on backend or default to top/bottom logic.
|
|
238
222
|
const position = card.position ?? 999999;
|
|
239
223
|
const response = await api<KanbanCard<T>>(dataSource).create({ ...card, position });
|
|
240
224
|
return response._id;
|
|
@@ -249,7 +233,6 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
249
233
|
const previousCards = queryClient.getQueryData<ListResponse<KanbanCard<T>>>(queryKey);
|
|
250
234
|
|
|
251
235
|
if (previousCards) {
|
|
252
|
-
// Determine position
|
|
253
236
|
const currentCards = previousCards.Data;
|
|
254
237
|
const position = newCardVariables.position ?? currentCards.length;
|
|
255
238
|
|
|
@@ -271,7 +254,6 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
271
254
|
return { previousCards, queryKey };
|
|
272
255
|
},
|
|
273
256
|
onSuccess: async (cardId, _variables, context) => {
|
|
274
|
-
// Refetch the specific column
|
|
275
257
|
if (context?.queryKey) {
|
|
276
258
|
await queryClient.invalidateQueries({ queryKey: context.queryKey });
|
|
277
259
|
}
|
|
@@ -299,22 +281,10 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
299
281
|
return { id, updates };
|
|
300
282
|
},
|
|
301
283
|
onMutate: async () => {
|
|
302
|
-
// We don't know the columnId easily without passing it.
|
|
303
|
-
// We can try to finding it in all column queries
|
|
304
|
-
// For now, simpler to just invalidate everything on success/error
|
|
305
|
-
// OR pass columnId in updates if available.
|
|
306
|
-
// If we want optimistic updates, we need to iterate all queries.
|
|
307
|
-
|
|
308
|
-
// Strategy: Invalidate all columns. Optimistic update is hard without knowing columnId.
|
|
309
|
-
// If the user passes columnId in updates, we can optimize.
|
|
310
|
-
|
|
311
284
|
await queryClient.cancelQueries({ queryKey: ["kanban-cards", dataSource] });
|
|
312
285
|
return {};
|
|
313
286
|
},
|
|
314
287
|
onSuccess: async (result) => {
|
|
315
|
-
// Find the card to trigger callback
|
|
316
|
-
// Since we don't have a single list, this is harder.
|
|
317
|
-
// We can skip finding it for now or iterate queries.
|
|
318
288
|
onCardUpdateRef.current?.({ _id: result.id, ...result.updates } as any);
|
|
319
289
|
},
|
|
320
290
|
onError: (error, _variables, _context) => {
|
|
@@ -332,8 +302,6 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
332
302
|
},
|
|
333
303
|
onMutate: async () => {
|
|
334
304
|
await queryClient.cancelQueries({ queryKey: ["kanban-cards", dataSource] });
|
|
335
|
-
// Optimistic delete: Iterate all column queries and remove?
|
|
336
|
-
// For now, simple invalidation
|
|
337
305
|
return {};
|
|
338
306
|
},
|
|
339
307
|
onSuccess: async (id) => {
|
|
@@ -354,7 +322,6 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
354
322
|
return { cardId, fromColumnId, toColumnId, position };
|
|
355
323
|
},
|
|
356
324
|
onMutate: async ({ cardId, fromColumnId, toColumnId, position }) => {
|
|
357
|
-
// Cancel queries for only the affected columns
|
|
358
325
|
const fromOpts = getColumnApiOptions(fromColumnId);
|
|
359
326
|
const toOpts = getColumnApiOptions(toColumnId);
|
|
360
327
|
const fromQueryKey = ["kanban-cards", dataSource, fromColumnId, fromOpts];
|
|
@@ -363,23 +330,18 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
363
330
|
await queryClient.cancelQueries({ queryKey: fromQueryKey });
|
|
364
331
|
await queryClient.cancelQueries({ queryKey: toQueryKey });
|
|
365
332
|
|
|
366
|
-
// Get current data for both columns
|
|
367
333
|
const previousFromData = queryClient.getQueryData<ListResponse<KanbanCard<T>>>(fromQueryKey);
|
|
368
334
|
const previousToData = queryClient.getQueryData<ListResponse<KanbanCard<T>>>(toQueryKey);
|
|
369
335
|
|
|
370
|
-
// Optimistic update: move card between columns
|
|
371
336
|
if (previousFromData && previousToData) {
|
|
372
|
-
// Find the card in the source column
|
|
373
337
|
const cardToMove = previousFromData.Data.find(c => c._id === cardId);
|
|
374
338
|
|
|
375
339
|
if (cardToMove) {
|
|
376
|
-
// Remove card from source column
|
|
377
340
|
const newFromData = {
|
|
378
341
|
...previousFromData,
|
|
379
342
|
Data: previousFromData.Data.filter(c => c._id !== cardId)
|
|
380
343
|
};
|
|
381
344
|
|
|
382
|
-
// Add card to target column with updated columnId
|
|
383
345
|
const movedCard = {
|
|
384
346
|
...cardToMove,
|
|
385
347
|
columnId: toColumnId,
|
|
@@ -392,7 +354,6 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
392
354
|
Data: [...previousToData.Data, movedCard].sort((a, b) => a.position - b.position)
|
|
393
355
|
};
|
|
394
356
|
|
|
395
|
-
// Update cache optimistically
|
|
396
357
|
queryClient.setQueryData(fromQueryKey, newFromData);
|
|
397
358
|
queryClient.setQueryData(toQueryKey, newToData);
|
|
398
359
|
}
|
|
@@ -415,7 +376,6 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
415
376
|
);
|
|
416
377
|
},
|
|
417
378
|
onError: (error, _variables, context) => {
|
|
418
|
-
// Rollback optimistic update on error
|
|
419
379
|
if (context?.previousFromData && context?.fromQueryKey) {
|
|
420
380
|
queryClient.setQueryData(context.fromQueryKey, context.previousFromData);
|
|
421
381
|
}
|
|
@@ -425,7 +385,6 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
425
385
|
onErrorRef.current?.(error as Error);
|
|
426
386
|
},
|
|
427
387
|
onSettled: (_data, _error, variables) => {
|
|
428
|
-
// Invalidate queries to ensure sync with server
|
|
429
388
|
const fromOpts = getColumnApiOptions(variables.fromColumnId);
|
|
430
389
|
const toOpts = getColumnApiOptions(variables.toColumnId);
|
|
431
390
|
queryClient.invalidateQueries({ queryKey: ["kanban-cards", dataSource, variables.fromColumnId, fromOpts] });
|
|
@@ -443,15 +402,12 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
443
402
|
);
|
|
444
403
|
},
|
|
445
404
|
onMutate: async ({ columnId }) => {
|
|
446
|
-
// Optimistic reorder restricted to single column
|
|
447
405
|
const opts = getColumnApiOptions(columnId);
|
|
448
406
|
const queryKey = ["kanban-cards", dataSource, columnId, opts];
|
|
449
407
|
await queryClient.cancelQueries({ queryKey });
|
|
450
|
-
// Can implement optimistic reorder here if we want to parse cardIds
|
|
451
|
-
// But simpler to just invalidate.
|
|
452
408
|
return {};
|
|
453
409
|
},
|
|
454
|
-
onSuccess: () => {},
|
|
410
|
+
onSuccess: () => {},
|
|
455
411
|
onError: (error, _variables, _context) => {
|
|
456
412
|
onErrorRef.current?.(error as Error);
|
|
457
413
|
},
|
|
@@ -472,7 +428,7 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
472
428
|
cardId: card._id,
|
|
473
429
|
fromColumnId,
|
|
474
430
|
toColumnId,
|
|
475
|
-
position: undefined,
|
|
431
|
+
position: undefined,
|
|
476
432
|
});
|
|
477
433
|
} catch (error) {
|
|
478
434
|
// Error already handled in mutation onError
|
|
@@ -482,11 +438,10 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
482
438
|
);
|
|
483
439
|
|
|
484
440
|
// ============================================================
|
|
485
|
-
// COMPUTED VALUES
|
|
441
|
+
// COMPUTED VALUES
|
|
486
442
|
// ============================================================
|
|
487
443
|
|
|
488
444
|
const processedColumns = useMemo(() => {
|
|
489
|
-
// Map column configs to KanbanColumn structure using query results
|
|
490
445
|
return columnConfigs
|
|
491
446
|
.sort((a, b) => a.position - b.position)
|
|
492
447
|
.map((config, index) => {
|
|
@@ -500,7 +455,6 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
500
455
|
color: config.color,
|
|
501
456
|
limit: config.limit,
|
|
502
457
|
cards: cards.sort((a, b) => a.position - b.position),
|
|
503
|
-
// We can expose loading/error state per column here if needed in the future
|
|
504
458
|
_created_at: new Date(),
|
|
505
459
|
_modified_at: new Date(),
|
|
506
460
|
};
|
|
@@ -530,9 +484,7 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
530
484
|
"aria-grabbed": enableDragDrop && dragDropManager.draggedCard?._id === card._id,
|
|
531
485
|
onDragStart: (e: any) => {
|
|
532
486
|
if (!enableDragDrop) return;
|
|
533
|
-
// Abstracting the dataTransfer logic
|
|
534
487
|
e.dataTransfer.setData("text/plain", JSON.stringify(card));
|
|
535
|
-
// Use native event if available (ShadCN/Radix sometimes wraps events) or fallback to e
|
|
536
488
|
const nativeEvent = e.nativeEvent || e;
|
|
537
489
|
dragDropManager.handleDragStart(nativeEvent, card);
|
|
538
490
|
},
|
|
@@ -576,14 +528,6 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
576
528
|
setSearch({ query: "" });
|
|
577
529
|
}, []);
|
|
578
530
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
// ============================================================
|
|
582
|
-
// PROP GETTERS
|
|
583
|
-
// ============================================================
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
531
|
const totalCards = countData?.Count || 0;
|
|
588
532
|
|
|
589
533
|
const isLoading = isLoadingCards || isLoadingCount;
|
|
@@ -656,9 +600,7 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
656
600
|
),
|
|
657
601
|
moveCard: useCallback(
|
|
658
602
|
async (cardId: string, toColumnId: string, position?: number, fromColumnId?: string) => {
|
|
659
|
-
// If fromColumnId is not provided, we need to find it
|
|
660
603
|
if (!fromColumnId) {
|
|
661
|
-
// Find the card in the columns to get its current columnId
|
|
662
604
|
for (const column of processedColumns) {
|
|
663
605
|
const card = column.cards.find(c => c._id === cardId);
|
|
664
606
|
if (card) {
|
|
@@ -686,8 +628,8 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
686
628
|
setSearchQuery,
|
|
687
629
|
clearSearch,
|
|
688
630
|
|
|
689
|
-
// Filter (
|
|
690
|
-
filter
|
|
631
|
+
// Filter (Simplified chainable API)
|
|
632
|
+
filter,
|
|
691
633
|
|
|
692
634
|
// Drag Drop (Flat Access)
|
|
693
635
|
isDragging: enableDragDrop ? dragDropManager.isDragging : false,
|
|
@@ -700,13 +642,10 @@ export function useKanban<T extends Record<string, any> = Record<string, any>>(
|
|
|
700
642
|
handleDrop: enableDragDrop ? dragDropManager.handleDrop : () => {},
|
|
701
643
|
handleDragEnd: enableDragDrop ? dragDropManager.handleDragEnd : () => {},
|
|
702
644
|
handleKeyDown: enableDragDrop ? dragDropManager.handleKeyDown : () => {},
|
|
703
|
-
|
|
704
|
-
// Prop Getters
|
|
645
|
+
|
|
705
646
|
// Prop Getters
|
|
706
647
|
getCardProps: enableDragDrop ? getCardProps : (_card: any) => ({} as any),
|
|
707
648
|
getColumnProps: enableDragDrop ? getColumnProps : (_columnId: string) => ({} as any),
|
|
708
|
-
|
|
709
|
-
|
|
710
649
|
|
|
711
650
|
// Load More (Per Column)
|
|
712
651
|
loadMore: useCallback((columnId: string) => {
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { ListResponse,
|
|
2
|
-
import type {
|
|
3
|
-
FilterConditionWithId,
|
|
4
|
-
TypedFilterConditionInput,
|
|
5
|
-
ValidationError,
|
|
6
|
-
} from "../useFilter";
|
|
1
|
+
import type { ListResponse, ConditionGroupOperator } from "../../../types/common";
|
|
2
|
+
import type { Condition, ConditionGroup, UseFilterReturn } from "../useFilter";
|
|
7
3
|
|
|
8
4
|
// ============================================================
|
|
9
5
|
// TYPE DEFINITIONS
|
|
@@ -36,23 +32,20 @@ export interface UseTableOptions<T> {
|
|
|
36
32
|
/** Initial state */
|
|
37
33
|
initialState?: {
|
|
38
34
|
pagination?: {
|
|
39
|
-
pageNo: number;
|
|
35
|
+
pageNo: number;
|
|
40
36
|
pageSize: number;
|
|
41
37
|
};
|
|
42
38
|
sorting?: {
|
|
43
39
|
field: keyof T;
|
|
44
40
|
direction: "asc" | "desc";
|
|
45
41
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
filterOperator?: LogicalOperator;
|
|
42
|
+
filters?: Array<Condition | ConditionGroup>;
|
|
43
|
+
filterOperator?: ConditionGroupOperator;
|
|
49
44
|
};
|
|
50
45
|
/** Error callback */
|
|
51
46
|
onError?: (error: Error) => void;
|
|
52
47
|
/** Success callback */
|
|
53
48
|
onSuccess?: (data: T[]) => void;
|
|
54
|
-
/** Filter error callback */
|
|
55
|
-
onFilterError?: (errors: ValidationError[]) => void;
|
|
56
49
|
}
|
|
57
50
|
|
|
58
51
|
export interface UseTableReturn<T> {
|
|
@@ -83,54 +76,8 @@ export interface UseTableReturn<T> {
|
|
|
83
76
|
set: (field: keyof T, direction: "asc" | "desc") => void;
|
|
84
77
|
};
|
|
85
78
|
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
value: string;
|
|
89
|
-
setValue: (value: string) => void;
|
|
90
|
-
clear: () => void;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// Advanced Filtering (Filter Conditions) - Type-safe: lhsField constrained to keyof T
|
|
94
|
-
filter: {
|
|
95
|
-
// State
|
|
96
|
-
conditions: FilterConditionWithId[];
|
|
97
|
-
logicalOperator: LogicalOperator;
|
|
98
|
-
isValid: boolean;
|
|
99
|
-
validationErrors: ValidationError[];
|
|
100
|
-
hasConditions: boolean;
|
|
101
|
-
|
|
102
|
-
// Condition Management (type-safe)
|
|
103
|
-
addCondition: (condition: TypedFilterConditionInput<T>) => string;
|
|
104
|
-
updateCondition: (
|
|
105
|
-
id: string,
|
|
106
|
-
updates: Partial<TypedFilterConditionInput<T>>
|
|
107
|
-
) => boolean;
|
|
108
|
-
removeCondition: (id: string) => boolean;
|
|
109
|
-
clearConditions: () => void;
|
|
110
|
-
getCondition: (id: string) => FilterConditionWithId | undefined;
|
|
111
|
-
|
|
112
|
-
// Logical Operator
|
|
113
|
-
setLogicalOperator: (operator: LogicalOperator) => void;
|
|
114
|
-
|
|
115
|
-
// Bulk Operations
|
|
116
|
-
setConditions: (conditions: FilterConditionWithId[]) => void;
|
|
117
|
-
replaceCondition: (
|
|
118
|
-
id: string,
|
|
119
|
-
newCondition: TypedFilterConditionInput<T>
|
|
120
|
-
) => boolean;
|
|
121
|
-
|
|
122
|
-
// Validation
|
|
123
|
-
validateCondition: (condition: Partial<FilterConditionWithId>) => any;
|
|
124
|
-
validateAllConditions: () => any;
|
|
125
|
-
|
|
126
|
-
// State Management
|
|
127
|
-
exportState: () => any;
|
|
128
|
-
importState: (state: any) => void;
|
|
129
|
-
resetToInitial: () => void;
|
|
130
|
-
|
|
131
|
-
// Utilities
|
|
132
|
-
getConditionCount: () => number;
|
|
133
|
-
};
|
|
79
|
+
// Filter (Simplified chainable API)
|
|
80
|
+
filter: UseFilterReturn;
|
|
134
81
|
|
|
135
82
|
// Pagination (Flat Access)
|
|
136
83
|
pagination: {
|