/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import type { Formatters, TickFormatOpt } from "@elaraai/east-ui-components"; import type { TimeResolution } from "../../shared/time/calendar-math.js"; import type { PlanInstantValue } from "../instant.js"; import type { RowKey } from "../plan-state.js"; /** A cell a typed number goes into: its row, its position among the row's table series, and its bucket as `data-cell` names it. */ export interface PlanTypingCell { readonly rowKey: RowKey; readonly position: number; readonly cell: string; } /** The input open on a cell, and the key that opened it, typed in as it opens. */ export interface PlanTypingOpen extends PlanTypingCell { readonly seed: string | undefined; } /** A number typed into a cell, or the cell cleared — what the canvas's session drafts as one gesture. */ export interface PlanTypedValue { readonly rowKey: RowKey; readonly position: number; /** The date the value is written under: the one value the bucket held, so it replaces it; else the bucket's start. */ readonly at: PlanInstantValue; /** The bucket as words, as the history's step names it. */ readonly bucket: string; /** The number, or `undefined` to clear the cell. */ readonly value: number | undefined; /** The number as the cell prints it. */ readonly text: string; } /** The canvas's typing, as its table rows reach it (`PlanEditContextValue.typing`). */ export interface PlanTyping { /** The one input. */ readonly store: PlanTypingStore; /** * Draft a typed number, or a cleared cell, as one step of the session's history. * * @returns Whether the session took it */ readonly type: (typed: PlanTypedValue) => boolean; /** Whether a tap on a cell opens the input in a popover anchored to it: below 480px of main. */ readonly popover: boolean; /** The resolutions the Plan zooms to, finest first ({@link planZooms}): none, where its axis states none. */ readonly zooms: readonly TimeResolution[]; } /** A cell focus goes to once a zoom lands: a row's, at the instant its bucket holds, at a resolution. */ export interface PlanTypingFocus { readonly rowKey: RowKey; /** The instant, in the axis's numbers. */ readonly at: number; readonly resolution: TimeResolution; } /** The canvas's one input: the cell it is open on, if any. */ export declare class PlanTypingStore { #private; /** * Focus a row's cell as it draws at a resolution: the cell that holds the * instant — once a zoom lands, where a double click or Enter on a coarser * cell zooms to edit it (#1438), or once the window holds it, where a * conflict's Go to moves the window over it. The row hears it, and draws * again to take it. * * @param focus - The row, the instant and the resolution */ focusOnZoom(focus: PlanTypingFocus): void; /** The focus a row's cells wait to take, if any ({@link takeFocus}). */ get focusing(): PlanTypingFocus | null; /** * The focus a row's cells take as they draw at a resolution, taken once: * the instant its cell holds, where the zoom landed on that row — once * its window holds the instant, where a Go to moved the window over it. * * @param rowKey - The row drawing * @param resolution - The resolution it draws at * @param holds - Whether the row's window holds an instant: until it does, the focus waits * @returns The instant, or `undefined` where no focus waits for it */ takeFocus(rowKey: RowKey, resolution: TimeResolution | undefined, holds?: (at: number) => boolean): number | undefined; /** The cell the input is open on. */ get open(): PlanTypingOpen | null; /** * Hear the input open, move or close. * * @param listener - Called on each change * @returns The unsubscribe */ readonly subscribe: (listener: () => void) => (() => void); /** * Open the input on a cell. * * @param cell - The cell * @param seed - The key that opened it, typed in as it opens */ openAt(cell: PlanTypingCell, seed?: string): void; /** Close the input. */ close(): void; } /** * The input, while a row holds it. * * @param store - The canvas's input, or `undefined` while it takes no typing * @param rowKey - The row * @returns The open input, or `null` for every row but the one it is open on */ export declare function usePlanTypingOpen(store: PlanTypingStore | undefined, rowKey: RowKey): PlanTypingOpen | null; /** * The focus a row's cells wait to take: what draws the row again as a focus * is asked of it, so it takes it as it draws ({@link PlanTypingStore.takeFocus}). * * @param store - The canvas's input, or `undefined` while it takes no typing * @param rowKey - The row * @returns The focus asked of the row, or `null` */ export declare function usePlanTypingFocus(store: PlanTypingStore | undefined, rowKey: RowKey): PlanTypingFocus | null; /** * The text a cell's input opens on: its value as its format reads it — a * percent's `0.82` as `82` — bare, in the viewer's language, never grouped. * * @param value - The cell's value, or `undefined` for an empty cell * @param format - Its position's format * @param words - The canvas's formatters * @returns The text */ export declare function typedText(value: number | undefined, format: TickFormatOpt, words: Formatters): string; /** * What a cell's typed text writes: the number its format reads it as — a * percent's `82` or `82%` as `0.82` — through the Sheet's grammar in the * viewer's language (#852). * * @param text - The typed text * @param format - Its position's format * @param words - The canvas's formatters * @returns The number, `undefined` for no text (the cell cleared), or `null` for text that is no number */ export declare function readTyped(text: string, format: TickFormatOpt, words: Formatters): number | null | undefined; /** * The resolution a position's values are at, from the least gap between two * of them — what a bucket folding several of them names, so its tooltip says * where they take typing. * * @param instants - The values' instants, in epoch milliseconds, in their keys' order * @returns The resolution, or `undefined` with fewer than two of them */ export declare function resolutionOfValues(instants: readonly number[]): TimeResolution | undefined; /** * The resolutions a Plan zooms to (#1438): its resolution segment's, and the * one its axis opens at — but `auto`, which is none of them. * * @param segment - The resolution segment's resolutions * @param opened - The resolution the axis opens at * @returns Them, the finest first */ export declare function planZooms(segment: readonly string[], opened: string | undefined): readonly TimeResolution[]; /** * Whether a table cell takes a typed number at a zoom (#1438): at the Plan's * finest zoom alone, where a cell holds at most the values of its own bucket. * A coarser cell is a summary of the values beneath it — a number typed there * would stand for none of them — so it takes none. On an axis of no * resolution, every cell takes one. * * @param zoom - The resolution the Plan shows * @param zooms - The resolutions it zooms to, the finest first * @returns Whether its cells take one */ export declare function typesAt(zoom: TimeResolution | undefined, zooms: readonly TimeResolution[]): boolean; /** * The zoom a bucket folding values one each `each` shows them apart at, of * the Plan's (#1438): the coarsest no coarser than they are. None where none * is, so a bucket never names a zoom the Plan lacks. * * @param each - The resolution the values are at * @param zooms - The resolutions the Plan zooms to, the finest first * @returns The zoom, or `undefined` where no zoom of the Plan's shows them apart */ export declare function zoomApart(each: TimeResolution | undefined, zooms: readonly TimeResolution[]): TimeResolution | undefined; //# sourceMappingURL=typing.d.ts.map