/** * 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 landing on rows read a page at a time 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 over paged rows 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 (`.`), 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 resources are the canvas's own rows (#1541): each * landing row, a resources series' or a kinds case's, by its series' key and * the last step of its path. Over rows read whole they are every landing row * of the canvas; over rows read a page at a time, each window's — 200 entries * to a window, as many resources as they nest — read through the root's own * source, with its size and the narrowing its windows belong to; then the range * the canvas reads and its scale's buckets. And it keeps the span store the * canvas writes the paged 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 ScheduleCellKey, type ScheduleCellSpan, type ScheduleCellsRead } from "../../shared/schedule/cells.js"; import type { ScheduleEditing, ScheduleEventDraftsValue } from "../../shared/schedule/editing.js"; import type { PlanRootValue, PlanWireBlock } 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]; /** A series the event kinds land on, as the payload carries it (#1541). */ type Landing = PlanPayloadValue["landings"][number]; /** 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 series the event kinds land on (#1541): their rows are the resources. */ readonly landings: readonly Landing[]; /** * The canvas's own rows (#1541): read whole, every landing row — what a counted kind past the cap shades, or hatches; * a page at a time, the root's source, whose windows' landing rows a kind read by its cells reads the events of. */ readonly rows: PlanRootValue["rows"]; /** The event kinds narrowed through their sources of the slice, and the parts they read through. */ readonly parts: readonly PlanEventPart[]; /** 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 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 resources some rows' events are read by (#1541): each landing row's — a resources series' or a kinds case's — by * its series' key and the last step of its path, in the order the rows draw them; and, of a row beneath a resource * that a kind's `child` lands on, the resource it stands beneath (`readResourceOf`). A resource's own row and the * rows beneath it name it once — and the rows beneath it alone do, where the page draws no row of its own. * * @param blocks - The rows * @param landings - The series the event kinds land on * @returns The resources */ export declare function landingKeysOf(blocks: readonly PlanWireBlock[], landings: readonly Landing[]): ScheduleCellKey[]; /** Each kind's events named at a link's end, by the kind's slot. */ export type PlanLinkEnds = ReadonlyMap; /** * The events of each kind the canvas's links name at their ends, by the kind's slot, kept by identity while they name * the same events: the map held before where no kind's list moved, and within a map that moved each list that did not. * * The canvas makes its links anew whenever what they join is read again — a link kind's links join the root's own each * time its record or its drafts are read. A reader handed new lists for the same ends would read its kinds again, land * the same events, and so have the links made again, without end. * * @param held - The ends held before; `undefined` for none * @param links - The canvas's links * @param slots - The event kinds' slots * @returns The ends, `held` itself while every kind's are the same */ export declare function keptLinkEnds(held: PlanLinkEnds | undefined, links: Links, slots: readonly string[]): PlanLinkEnds; /** * 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, over rows read a page at a * time, 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 landing on rows read a page at * a time, 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 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 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 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