import { type PaginationAtomType } from "../Extended Atoms/paginationAtom"; import { type AtomType } from "./atom"; import { type ListAtomType, type ListItemInput } from "./createListAtom"; import { type ObjectAtomType } from "./createObjectAtom"; export type SortState = { key?: string; dir: "asc" | "desc"; }; export type PaginationStyle = "page" | "lazy"; export type LoadContext = { list: ListAtomType; source: ListAtomType; search: AtomType; searchInput: AtomType; filters: ObjectAtomType; sort: AtomType; page: PaginationAtomType; pageSize: AtomType; total: AtomType; hasMore: AtomType; loading: AtomType; error: AtomType; /** AbortSignal for this request — pass to fetch. */ signal: AbortSignal; }; export type AdvancedListOptions = { keyName?: K; searchDelay?: number; pageSize?: number; paginationStyle?: PaginationStyle; initialSearch?: string; initialFilters?: Record; initialSort?: SortState | null; searchKeys?: Array; filterFn?: (item: T, filters: Record, search: string) => boolean; sortFn?: (a: T, b: T, sort: SortState) => number; load?: (ctx: LoadContext) => Promise | PromiseLike; resetPageOnQueryChange?: boolean; }; export type AdvancedListController = { list: ListAtomType; /** Full dataset (static mode). In dynamic mode starts empty / unused for paging. */ source: ListAtomType; searchInput: AtomType; search: AtomType; filters: ObjectAtomType; sort: AtomType; page: PaginationAtomType; pageSize: AtomType; total: AtomType; hasMore: AtomType; loading: AtomType; error: AtomType; /** Re-run pipeline / fetch with current atom values. */ load: () => Promise; reload: () => Promise; /** Active request signal (same as `LoadContext.signal` while in flight). */ getSignal: () => AbortSignal; dispose: () => void; readonly paginationStyle: PaginationStyle; readonly isDynamic: boolean; }; /** * Composite list controller: local search/filter/sort/pagination, or remote * `load` with page-replace vs lazy-append. * * @example * // Static * const al = advancedList(users, { pageSize: 10, searchKeys: ["name"] }); * al.searchInput.set("ada"); * al.page.next(); * * @example * // Dynamic * const al = advancedList([], { * paginationStyle: "lazy", * load: async ({ page, pageSize, search, signal, total }) => { * const res = await fetch(`/api?q=${search()}&page=${page()}&size=${pageSize()}`, { signal }); * const data = await res.json(); * total.set(data.total); * return data.items; * }, * }); */ export declare function advancedList(initial?: readonly ListItemInput[], options?: AdvancedListOptions): AdvancedListController; //# sourceMappingURL=advancedList.d.ts.map