UNPKG

nuqs

Version:

Type-safe search params state manager for React - Like useState, but stored in the URL query string

44 lines (43 loc) 1.69 kB
import { i as Options } from "./defs-DVjFg2Y1.js"; import { Context, ProviderProps, ReactElement, ReactNode } from "react"; //#region src/adapters/lib/defs.d.ts type AdapterOptions = Pick<Options, "history" | "scroll" | "shallow">; type UpdateUrlFunction = (search: URLSearchParams, options: Required<AdapterOptions>) => void; type UseAdapterHook = (watchKeys: string[]) => AdapterInterface; type AdapterInterface = { searchParams: URLSearchParams; updateUrl: UpdateUrlFunction; getSearchParamsSnapshot?: () => URLSearchParams; rateLimitFactor?: number; autoResetQueueOnUpdate?: boolean; }; //#endregion //#region src/adapters/lib/context.d.ts type AdapterProps = { defaultOptions?: Partial<Pick<Options, "shallow" | "clearOnDefault" | "scroll" | "limitUrlUpdates">>; processUrlSearchParams?: (search: URLSearchParams) => URLSearchParams; }; type AdapterContext = AdapterProps & { useAdapter: UseAdapterHook; }; declare const context: Context<AdapterContext>; declare global { interface Window { __NuqsAdapterContext?: typeof context; } } type AdapterProvider = (props: AdapterProps & { children: ReactNode; }) => ReactElement<ProviderProps<AdapterContext>>; /** * Create a custom adapter (context provider) for nuqs to work with your framework / router. * * Adapters are based on React Context, * * @param useAdapter * @returns */ declare function createAdapterProvider(useAdapter: UseAdapterHook): AdapterProvider; //#endregion export { AdapterInterface as a, UseAdapterHook as c, createAdapterProvider as i, AdapterProps as n, AdapterOptions as o, AdapterProvider as r, UpdateUrlFunction as s, AdapterContext as t }; //# sourceMappingURL=context-BE-tNWKb.d.ts.map