Latest changes

This commit is contained in:
Hein
2026-02-16 22:48:48 +02:00
parent 391450f615
commit 78468455eb
15 changed files with 1713 additions and 214 deletions

View File

@@ -20,6 +20,7 @@ import type {
PaginationConfig,
SearchConfig,
SelectionConfig,
TreeConfig,
} from './types';
// ─── Store State ─────────────────────────────────────────────────────────────
@@ -85,6 +86,12 @@ export interface GriddyStoreState extends GriddyUIState {
showToolbar?: boolean;
sorting?: SortingState;
// ─── Tree/Hierarchical Data ───
tree?: TreeConfig<any>;
treeLoadingNodes: Set<string>;
treeChildrenCache: Map<string, any[]>;
setTreeLoadingNode: (nodeId: string, loading: boolean) => void;
setTreeChildrenCache: (nodeId: string, children: any[]) => void;
// ─── Synced from GriddyProps (written by $sync) ───
uniqueId?: string;
}
@@ -144,6 +151,25 @@ export const { Provider: GriddyProvider, useStore: useGriddyStore } = createSync
setTotalRows: (count) => set({ totalRows: count }),
setVirtualizer: (virtualizer) => set({ _virtualizer: virtualizer }),
// ─── Tree State ───
treeLoadingNodes: new Set(),
treeChildrenCache: new Map(),
setTreeLoadingNode: (nodeId, loading) =>
set((state) => {
const newSet = new Set(state.treeLoadingNodes);
if (loading) {
newSet.add(nodeId);
} else {
newSet.delete(nodeId);
}
return { treeLoadingNodes: newSet };
}),
setTreeChildrenCache: (nodeId, children) =>
set((state) => {
const newMap = new Map(state.treeChildrenCache);
newMap.set(nodeId, children);
return { treeChildrenCache: newMap };
}),
// ─── Row Count ───
totalRows: 0,
}));