/** * Synchronously read all cached preferences for a `tableId` so the parent * can seed its own initial state from cache. This is the canonical way for * a parent component to consume cached table state — the storybook child * components (`GenericFilter`, `CustomDataGrid`) only hydrate their own * internal state from cache and do not push values up to the parent. * * Call this hook at the top of the parent and feed the returned snapshot * into your `useState` initializers so the parent's first render — and * therefore its first API call — already includes the restored values. * * Usage: * * const restored = useRestoredInitialState("my-table", { * filters: initialFormikValues, * page: 1, // 1-based grid page * pageSize: 20, * sortKey: "updatedAt", * direction: "Descending", * }); * * const [filterState, setFilterState] = useState({ * appliedFilters: restored.filters, * activeCount: restored.activeCount, * ... * }); * * @param {string} tableId * @param {object} [defaults] * @param {object} [defaults.filters] initialFormikValues shape * @param {number} [defaults.page] 1-based page to use when none is stored * @param {boolean} [defaults.persistPage=true] false to ignore any stored page * @param {number} [defaults.pageSize] * @param {string} [defaults.sortKey] * @param {string} [defaults.direction] "Ascending" | "Descending" * * @returns {{ * filters: object, * page: number|undefined, 1-based; convert for 0-based APIs (page - 1) * pageSize: number|undefined, * sortKey: string|undefined, * direction: string|undefined, * activeCount: number, * hasCachedFilters: boolean, * hasCachedGridState: boolean, * }} */ export function useRestoredInitialState(tableId: string, defaults?: { filters?: object; page?: number; persistPage?: boolean; pageSize?: number; sortKey?: string; direction?: string; }): { filters: object; page: number | undefined; };