import { ReadonlySignal, Signal } from "@preact/signals-core"; import type { ApiError, Item } from "@swishapp/api-client"; import type { SwishApp } from "../swish"; import { ListContext, ListContextInput } from "./list-context-signal"; export type ItemsSort = "recently_saved" | "custom"; export interface ItemsOptions { /** Items per page. Defaults to 24, matching the built-in grids. */ limit?: number; /** Sort order for `all` and `user` lists. Smart lists ignore it. */ sort?: ItemsSort; } export interface ItemsState { /** Every item loaded so far, first page first. */ items: Item[]; /** Total across all pages, or `null` before the first page lands. */ totalCount: number | null; /** Whether `loadMore()` has another page to fetch. */ hasMore: boolean; /** `true` while the first page of the current context is in flight. */ loading: boolean; /** `true` while `loadMore()` is in flight. */ loadingMore: boolean; /** `true` while `refresh()` (or an event-driven refresh) is in flight. */ refetching: boolean; error: ApiError | null; } export type ItemsSignal = ReadonlySignal & { loadMore: () => Promise; refresh: () => Promise; dispose: () => void; }; export declare const itemsSignal: (swish: SwishApp) => (contextInput: Signal | ListContextInput, options?: ItemsOptions) => ItemsSignal;