/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. * * The Plan's events read by cells, and every other kind counted first (#1039): * the Plan's adapter to the shared reader (`shared/schedule/cells.ts`), which * reads each event kind placed on a paged resource kind a cell at a time — the * events of the resources in view, a level at a time (#1433) — and counts every other kind * before one of its events is read, past `SCHEDULE_EVENT_CAP` of them drawing * none: its rows shade from its source's summary, or are hatched, the frame's * banner saying how many there are. A kind on a paged resource kind is read so * or refused (the Plan's tag, `checkedTilings`). * * The adapter gives the reader what is the Plan's, in the reader's terms: each * event kind as the payload carries it — its slot, its name, the rows its * shading stands in for (`.`, a resource's rows' key), whether its * rows book their buckets, its cells' type, its series key and its count — with * its source of the slice and what the viewer hides of it, and the event ends * the canvas's links name ({@link PlanCellsArgs.links}), which the reader reads * by key so a link finds its row; the resource kinds read whole, their rows' * keys; the payload's paged seam — its keys a window at a time, its size and the * narrowing its windows belong to, 200 resources to a window; the range the * canvas reads and its scale's buckets. And it keeps the span store the canvas * writes the paged kind's rows in view to as its scroll rests * ({@link createCellSpanStore}, {@link cellSpanOf}): the rows its view shows, * never the overscan, the span standing while it shows only rows not read * ({@link shownCellSpan}); the rows' ids name a resource by the last step of * their path. * * A kind read a window at a time — through its source's interval index, or a * day index, one event by its key — gives the reader the stored rows its * window's read holds (`stored`, #1599), which the reader keeps as it keeps a * kind's cells: the rows' read draws the kind from them, so they stand while * they are read again — after a Save, after another session's write — a draft * made meanwhile draws at once, and a gesture finds its event's row among them. * A kind narrowed through its source draws a draft only of an event those rows * hold, or of a new one (`isNew`, #1343), as its window's own read drew them. * The canvas's range is a window panned over its rows, no period: what the last * range held stands while the next is read. * * A Save's confirmation reads its events by their keys, never the cells: what * it landed of a kind the reader gives cells draws as the Save left it over * cells read before the commit, until they are read again — the editing keeps * it for the kinds {@link cellKinds} names ({@link PlanCellsArgs.editing}, the * shared reader's "What a Save landed"). * * @packageDocumentation */ import { type ValueTypeOf } from "@elaraai/east"; import { type PlanPayloadType } from "@elaraai/e3-ui/internal"; import { type ScheduleCellBucket, type ScheduleCellSpan, type ScheduleCellsRead } from "../../shared/schedule/cells.js"; import type { ScheduleEditing, ScheduleEventDraftsValue } from "../../shared/schedule/editing.js"; import type { PlanRootValue } from "../model.js"; import type { PlanScale } from "../scale.js"; import type { PlanEventPart } from "./sources.js"; type PlanPayloadValue = ValueTypeOf; /** One event kind, as the payload carries it. */ type EventKind = PlanPayloadValue["events"][number]; /** One resource kind, as the payload carries it. */ type ResourceKind = PlanPayloadValue["resources"][number]; /** A paged resource kind's rows, as the payload carries them. */ type Paged = Extract["value"]; /** The canvas's links. */ type Links = PlanRootValue["links"]; /** * The buckets a range is cut into at a scale's resolution: the range the * canvas reads starts and ends on whole periods, the window's and those laid * out beyond it. * * @param scale - The canvas's scale * @param from - The range's start * @param to - Its end, exclusive * @returns The buckets, in order */ export declare function bucketsOver(scale: PlanScale, from: Date, to: Date): ScheduleCellBucket[]; /** What {@link usePlanCells} reads over. */ export interface PlanCellsArgs { /** The event kinds, as the payload carries them. */ readonly kinds: readonly EventKind[]; /** The resource kinds, as the payload carries them: a counted kind past the cap shades, or is hatched, over their rows. */ readonly resources: readonly ResourceKind[]; /** The event kinds narrowed through their sources of the slice, and the parts they read through. */ readonly parts: readonly PlanEventPart[]; /** The paged resource kind's rows, when a kind pages. */ readonly paged: Paged | undefined; /** The canvas's scale: its resolution and its buckets. */ readonly scale: PlanScale | undefined; /** The range the canvas reads its events over. */ readonly range: { readonly from: Date; readonly to: Date; } | undefined; /** Every kind's drafts — the same object while they hold. */ readonly drafts: ScheduleEventDraftsValue; /** The ids the viewer hides in the library's Series tab. */ readonly hidden: readonly string[]; /** The paged kind's rows in view, as the canvas last reported them; `undefined` before it has. */ readonly span: ScheduleCellSpan | undefined; /** The canvas's links: an event end the cells do not hold is read by its key. */ readonly links: Links; /** * The editing's say of what confirmed Saves landed of the kinds read by their cells ({@link cellKinds}), and how it is * let go: drawn over a kind's cells read before the commit until they are read again — and the row each drafted * event's session began from, which tells a new event from one the record holds; `undefined` for none. */ readonly editing?: Pick | undefined; } /** * The kinds' cells and counts (see the module docs), read in the component * that reads the event kinds' rows: what the seams draw the kinds from, every * kind's drafts as they take them, what a gesture finds an event's row in, and * which counted kinds the canvas reads over the range itself. * * @param args - What it reads over * @returns What the shared reader read */ export declare function usePlanCells(args: PlanCellsArgs): ScheduleCellsRead; /** * The kinds the reader may give cells: every kind read a window at a time, one * event by its key — by its series index's cells, placed on the paged resource * kind, or its window's own rows (#1599). * * @param kinds - The event kinds, as the payload carries them * @returns The slots of such kinds */ export declare function cellKinds(kinds: readonly EventKind[]): string[]; /** * The kinds a Plan reads by their series index's cells: those whose sources * list a series index of their records — each placed on the paged resource * kind alone, as the Plan holds a series index to. * * @param parts - The event kinds narrowed through their sources * @returns The slots of such kinds */ export declare function seriesKinds(parts: readonly PlanEventPart[]): string[]; /** Where the paged kind's rows in view are, as the canvas reports them to its cells' reader: a store of one span. */ export interface PlanCellSpanStore { /** The span last reported; `undefined` before any is. */ get(): ScheduleCellSpan | undefined; /** Reports the rows in view: a span the store holds already moves nothing. */ set(span: ScheduleCellSpan | undefined): void; /** Listens for a span that moves; returns the unsubscribe. */ subscribe(listener: () => void): () => void; } /** * A store of the paged kind's rows in view (#1039): the canvas writes it as * its scroll comes to rest, and the cells' reader, a component of its own, * reads it — the canvas renders nothing for it. * * @returns The store */ export declare function createCellSpanStore(): PlanCellSpanStore; /** * The paged kind's rows in view among the canvas's items: the first and the * last row a paged window placed, each by its window and its resource's key * — the last step of its path — under the narrowing their windows are. * * @param items - The rows in view, in order: each its key and its id * @param origin - Which window each paged row came from * @param narrowing - The narrowing the windows belong to, as the source names it (#1344); `undefined` for one it names none of * @returns The span; `undefined` when no paged row is in view */ export declare function cellSpanOf(items: readonly { readonly key: string; readonly path: readonly string[]; }[], origin: ReadonlyMap, narrowing: string | undefined): ScheduleCellSpan | undefined; /** * What the canvas reports to its cells' reader as its scroll rests (#1039): * the span of the paged rows the view shows — never the overscan mounted * beside them, which beside a run not read yet that the view rests in is the * last rows read, however far off. A view that shows such a run and no paged * row says nothing of where the rows in view are: the span standing stays — * never the opening's first block, a view away — and the run's rows report * their own once they are drawn. * * @param rows - The rows the view shows, in order: each its key and its id's path * @param unread - Whether the view shows a run of rows not read yet, or a window whose read failed * @param standing - The span reported last * @param origin - Which window each paged row came from * @param narrowing - The narrowing the windows belong to, as the source names it (#1344) * @returns The span to report; `standing` while the view shows rows not read alone */ export declare function shownCellSpan(rows: readonly { readonly key: string; readonly path: readonly string[]; }[], unread: boolean, standing: ScheduleCellSpan | undefined, origin: ReadonlyMap, narrowing: string | undefined): ScheduleCellSpan | undefined; export {}; //# sourceMappingURL=cells.d.ts.map