import { type Dispatch, type SetStateAction } from "react"; import type { SortState } from "./sort_header"; /** How one value survives a reload. `read` is REQUIRED and not optional: what * comes back out of storage was written by some earlier version of this page, * in some browser, possibly by hand — `JSON.parse` typed as `T` is a lie, and * the lie surfaces later as a filter set to a value nothing matches. Validate * the shape and return `undefined` to fall back. `write` is only needed when * `T` is not something `JSON.stringify` round-trips (a `Set`, a `Map`, a * `Date`). */ export interface PersistedCodec { read: (raw: unknown) => T | undefined; write?: (value: T) => unknown; } /** * `useState` that REMEMBERS — for the things a reader arranged and would have to * arrange again: which filters are on, how the register is grouped, which bands * are folded. Same signature as `useState` (the functional updater included), so * a screen adopts it by swapping the call. * * Storage is per browser and per origin, and every app is served from its own * origin, so what a screen stores is private to that app on that machine. It * never reaches another viewer, the same person's other device, or the server — * which is exactly why this is for CONVENIENCE and never for anything the work * depends on. A shared or durable fact belongs in a record. * * Every access is wrapped: storage can be absent, full, or throw on the accessor * itself (a private window, a browser set to block site data, a screenshot * runner). The screen must render correctly with nothing stored, which is what * `fallback` is for — so a failure here costs the arrangement and nothing else. */ export declare function usePersistedState(key: string, fallback: T, codec: PersistedCodec): [T, Dispatch>]; /** The codec for a plain string that must be one of a KNOWN set — a select * option key, a grouping dimension. An allowlist rather than a `typeof` check, * because a stored key whose option was deleted filters the register down to * nothing and looks like missing data. `""` is always allowed: it is how every * filter in the kit spells "off". */ export declare function oneOf(allowed: readonly T[]): PersistedCodec; /** The codec for free text a reader typed. */ export declare const asText: PersistedCodec; /** The codec for a `Set` of strings — stored as an array, since `JSON` has no * set. Used for the folded bands of a grouped register. */ export declare const asStringSet: PersistedCodec>; /** The codec for a `Table`'s single-column sort. Takes the columns that are * actually sortable, so a stored key from a column since renamed or removed * falls back to the register's own order instead of sorting on a field the * screen no longer reads. */ export declare function asSortState(keys: readonly string[]): PersistedCodec;