/** * @fileoverview Generic React hook for any entity table adapter. * * Per-entity hooks (`useCustomerTable`, `usePolicyTable`, …) are thin * wrappers around this primitive. The primitive owns the React-specific * lifecycle (Strict Mode double-invoke handling, useSyncExternalStore * subscription, cleanup on unmount). */ import type { Table } from '@tanstack/react-table'; import type { AdapterState } from '@insurup/table-adapter-core'; /** * Minimal shape `useTable` requires — a covariant subset of `TableApi`. * Any entity's `TableApi` structurally satisfies this. */ interface TableApiMin { subscribe(listener: () => void): () => void; getSnapshot(): AdapterState; getServerSnapshot(): AdapterState; getTable(): Table; destroy(): void; } export interface UseTableResult> { /** Current adapter state (loading, error, rows, pageCount, …). */ state: AdapterState; /** TanStack Table instance with all table methods. */ table: Table; /** Raw adapter for advanced use (setFilter, invalidate, …). */ adapter: TAdapter; } /** * Create and manage any entity table adapter with React lifecycle. * * Pass a thunk that builds the adapter — `useTable` runs it once, keeps the * adapter stable across re-renders (including Strict Mode's double-invoke), * subscribes via `useSyncExternalStore`, and destroys on unmount. * * @example * ```tsx * const { state, table, adapter } = useTable(() => * createCustomerTable({ columns, fetch, autoFetch: true }) * ); * ``` */ export declare function useTable>(createAdapter: () => TAdapter): UseTableResult; export {}; //# sourceMappingURL=use-table.d.ts.map