/** * Calendar pattern — remembered per-user preferences. * * SHIPPED runtime module of the calendar pattern: everything exported * here is public API of `@alfadocs/ui-kit/patterns/calendar`. * * The platform stores each user's calendar view and chair/operator * selections server-side (`DoctorAddressUser.calendarView`, * `calendarSelectedChairIds`, `calendarSelectedOperatorIds`, written by * `setCalendarView` and the events-fetch side effect) and its display * knobs in per-user settings. `CalendarPreferenceAdapter` is that seam: * a host passes `CalendarWorkspace` a `preferences` adapter backed by * whatever it already has — a PATCH-on-change client, `localStorage`, * anything with get / set / clear — and the workspace, its surface and * its cog all read and write through it. * * The default is `memoryPreferenceAdapter`, a module-level map: it * survives remounts, re-renders and locale switches within one page * load and resets on reload. Deliberately NOT `localStorage` and not * the kit's `usePersistentState` — an unconfigured host (and every * Storybook story) must not leak one mount's selections into the next, * or into Chromatic. A host that wants durable preferences supplies the * adapter. * * The adapter validates nothing; each call site passes a `read` guard, * so a stale or foreign stored shape falls back to the default rather * than leaking into render. */ import { type Dispatch, type SetStateAction } from 'react'; /** The per-user preference store — the platform's server-side seam. */ export interface CalendarPreferenceAdapter { get(key: string): unknown; set(key: string, value: unknown): void; clear(): void; } /** Session-scoped, per-reload store — the default adapter. */ export declare const memoryPreferenceAdapter: CalendarPreferenceAdapter; /** Forget everything in the default adapter — the tests' `afterEach`. */ export declare function resetCalendarPreferences(): void; /** * The storage keys the workspace remembers, in one place. * * The VALUES are load-bearing: they are what is already sitting in every * host store and browser that has run this workspace. Renaming a key * here silently forgets that user's view, weekend choice, chair and * operator selections and cog settings — change a value only with a * migration. The member names are free to change; the strings are not. */ export declare const CALENDAR_PREFERENCE_KEYS: { readonly view: "calendarWorkspace.view"; readonly display: "calendarWorkspace.display"; readonly showWeekends: "calendarWorkspace.showWeekends"; readonly chairIds: "calendarWorkspace.chairIds"; readonly operatorIds: "calendarWorkspace.operatorIds"; }; /** * `useState` whose value is remembered through the adapter. `read` * validates the stored value — a stale or foreign shape falls back to * `defaultValue` rather than leaking into render. Writes happen on set, * never on mount, so merely opening a story remembers nothing. */ export declare function usePersistedPreference(key: string, defaultValue: T | (() => T), read: (raw: unknown) => T | undefined, adapter?: CalendarPreferenceAdapter): [T, Dispatch>]; /** One of a closed set of string literals, else undefined. */ export declare function readEnum(allowed: readonly T[]): (raw: unknown) => T | undefined; export declare function readBoolean(raw: unknown): boolean | undefined; /** * A remembered id selection, kept to the ids that still exist (a retired * chair or operator drops out silently). Any non-array is rejected; an * empty array is a real "nothing selected" choice. */ export declare function readIdList(known: ReadonlyArray<{ id: string; }>): (raw: unknown) => string[] | undefined; //# sourceMappingURL=calendar.preferences.d.ts.map