@firecms/core
Version:
Awesome Firebase/Firestore-based headless open-source CMS
61 lines (60 loc) • 2.63 kB
TypeScript
import { Entity, EntityCollection, FilterValues } from "../../types";
/**
* Data state for a single board column
*/
export interface BoardColumnData<M extends Record<string, any> = any> {
/** Entities loaded for this column */
entities: Entity<M>[];
/** Whether the column is currently loading data */
loading: boolean;
/** Whether there are more items to load */
hasMore: boolean;
/** Error if loading failed */
error?: Error;
/** Total count of entities in this column */
totalCount?: number;
}
/**
* Controller for managing per-column data in a Kanban board
*/
export interface BoardDataController<M extends Record<string, any> = any, COLUMN extends string = string> {
/** Data state for each column */
columnData: Record<COLUMN, BoardColumnData<M>>;
/** Load more items for a specific column */
loadMoreColumn: (column: COLUMN) => void;
/** Refresh data for a specific column */
refreshColumn: (column: COLUMN) => void;
/** Refresh all columns */
refreshAll: () => void;
/** Update counts for columns (for optimistic updates when moving items) */
updateColumnCounts: (sourceColumn: COLUMN, targetColumn: COLUMN) => void;
/** Decrement column counts (for optimistic updates when deleting items) */
decrementColumnCounts: (columnDeltas: Record<COLUMN, number>) => void;
/** Whether any column is loading */
loading: boolean;
/** Any error from any column */
error?: Error;
}
export interface UseBoardDataControllerProps<M extends Record<string, any> = any> {
/** Full path to the collection */
fullPath: string;
/** The entity collection configuration */
collection: EntityCollection<M>;
/** Property key used for column assignment */
columnProperty: string;
/** Array of column values (enum values from columnProperty) */
columns: string[];
/** Property key used for ordering within columns */
orderProperty?: string;
/** Number of items to load per page per column */
pageSize?: number;
/** Text search string to filter entities */
searchString?: string;
/** Additional filter values */
filterValues?: FilterValues<string>;
}
/**
* Hook that manages per-column data loading for the Kanban board.
* Each column gets its own independent query to the data source.
*/
export declare function useBoardDataController<M extends Record<string, any> = any, COLUMN extends string = string>({ fullPath, collection, columnProperty, columns, orderProperty, pageSize, searchString, filterValues }: UseBoardDataControllerProps<M>): BoardDataController<M, COLUMN>;