/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { type ScheduleCellResources, type ScheduleCellsRead } from "../shared/schedule/cells.js"; import { type ScheduleEditing } from "../shared/schedule/editing.js"; import { type CalendarBucket } from "./cells.js"; import { type CalendarItem, type CalendarRange, type CalendarRow, type CalendarValue, type CalendarView } from "./model.js"; import type { CalendarPagedDemand, CalendarPages } from "./pages.js"; /** A window read: every kind's events over it. */ export interface CalendarData { items: CalendarItem[]; loading: boolean; saved: Date | undefined; /** * The kinds past the cap over the window (#1424): none of their events is read or drawn but their drafts, so no * figure the Calendar says counts them — it says they are not counted, never 0. */ capped: ReadonlySet; /** * What the shared reader read of the kinds as this read took it (#1424) — the resources' shading and the notices of * the kinds past the cap — held with the events, so the frame hears of them as it hears of the window, whole; * `undefined` before a read. */ cells: ScheduleCellsRead | undefined; } /** * The backlog of every kind whose backlog follows no window, read apart from * the window: its last complete read, which stands while another is in flight. */ export interface CalendarApartBacklog { /** Its rows, in the kinds' order: none before its first read lands. */ readonly items: readonly CalendarItem[]; /** Whether a read of it has completed. */ readonly ready: boolean; /** Whether a read of it is in flight. */ readonly loading: boolean; /** Why its latest read failed. */ readonly error: string | undefined; } /** What the frame shows of the window read: the last complete read, its range, and whether a newer one is in flight or failed. */ export interface CalendarDataState extends CalendarData { /** The range the held read covers. */ range: CalendarRange; /** Whether any read has completed. */ ready: boolean; /** * Whether what it holds stands in for other choices of the same period (`../shared/view-read.ts`): the last choices' * events, retained until the new ones' land. A read again of the view shown is no filtering. */ filtering: boolean; /** Why the latest read failed. */ error: string | undefined; /** The backlog of each kind that reads its backlog apart from the window. */ apart: CalendarApartBacklog; } /** * The frame's data before its reader first reports: nothing held, a read in flight. * * @param range - The range the frame reads * @returns The state */ export declare function initialCalendarData(range: CalendarRange): CalendarDataState; /** * Install (or clear) the read-ahead probe. Test use only. * * @param fn - Called with a period each time it is read ahead; `undefined` clears it */ export declare function setCalendarReadAheadProbe(fn: ((next: CalendarRange) => void) | undefined): void; /** * The kinds whose backlog is paged through their sources (#1424): each backlog kind narrowed through its source of the * slice (#1343) — read a page at a time by the Backlog tab, through the source with its start Unset (`backlog-pages.ts`). * Every other reads its backlog whole or through its backlog index, apart from the window. * * @param value - The payload * @returns Their slots */ export declare function windowedBacklogKinds(value: CalendarValue): ReadonlySet; /** * The window's read and the backlog's apart from it (see the module docs), and once the window lands, what a step goes * to read ahead. * * @param value - The payload * @param range - The window shown * @param editing - The editing whose drafts the reads hold * @param view - The view: what a step from it goes to is read ahead * @param cells - What the shared reader read of the kinds (#1424, #1599): a kind it gives cells — its series index's, or * its window's own rows; past the cap, none — is read from them; a kind read a window at a time it has given none yet * waits on it; a kind read whole is counted over the window and read only within the cap * @returns What the frame shows */ export declare function useCalendarData(value: CalendarValue, range: CalendarRange, editing: ScheduleEditing | undefined, view: CalendarView, cells: ScheduleCellsRead): CalendarDataState; /** * The window read, in a component of its own (#1343): each search that lands re-runs it alone, and it hands the frame * its data only when what the frame shows moves. A kind narrowed through an interval index lands some fifty-five * searches before its count is known, and each would otherwise re-render the whole frame. The kinds' counts, and past * the cap their shading and their notices, are read here too, by the shared reader (#1424) — and where the view lays out * the paged resource kind's resources, the cells of a kind placed on it, around the rows the views say they show, which * they report to a store this component alone hears: a scroll renders nothing of the frame. * * @param props - The payload, the range read, the editing whose drafts the read holds, the view (what a step from it goes * to is read ahead once the window lands); the resource kinds the view lays out, each its rows the rail shows, and the * periods a resource's shading is cut into — none in a view with no resource axis; what the frame holds of the paged * resource kind and where the views report its places they show; and where the data goes * @returns Nothing: it reads */ export declare function CalendarDataReader({ value, range, editing, view, resources, bucket, pages, demand, onData }: { value: CalendarValue; range: CalendarRange; editing: ScheduleEditing | undefined; view: CalendarView; resources: readonly ScheduleCellResources[]; bucket: CalendarBucket | undefined; pages: CalendarPages | undefined; demand: CalendarPagedDemand | undefined; onData: (data: CalendarDataState) => void; }): null; /** Named resource rows, preserving the author's declaration order. */ export declare function resourceRows(resources: CalendarValue["resources"]): CalendarRow[]; //# sourceMappingURL=data.d.ts.map