/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import type { EditIssue, HistoryAction } from "@elaraai/east-ui-components"; import type { SheetNotice } from "../sheet/sheet-types.js"; import type { SheetTransactions } from "../sheet/transactions.js"; import { type SheetWords } from "../sheet/words.js"; import { type RecordTally } from "./messages.js"; import type { RecordTicks } from "./ticks.js"; /** The Record's word for its rows, one and many: `person`, `people`. */ export interface RecordNoun { readonly singular: string; readonly plural: string; } /** What a step of the history did (AD4–AD7), or a Duplicate the inspector drafted (IN7), as the status line says it. */ export type RecordStep = { readonly id: "undid" | "redid"; } | { readonly id: "restored"; readonly n: number; } | { readonly id: "discarded"; readonly n: number; } | { readonly id: "applied"; readonly tally: RecordTally; } | { readonly id: "duplicated"; readonly name: string; }; /** A step the status line was told of, and when: each told later than the one before. */ export interface RecordSaid { readonly step: RecordStep; readonly seq: number; } /** The steps the status line is told of, read through `useSyncExternalStore`. */ export interface RecordStatus { /** Hears every step told; returns the call that stops it. */ subscribe: (listener: () => void) => () => void; /** The step told last, if any. */ said: () => RecordSaid | undefined; /** Tells a step. */ say: (step: RecordStep) => void; } /** * Makes a Record's status line's store, no step told. * * @returns The store */ export declare function createRecordStatus(): RecordStatus; /** * What the drafts send as an Apply (AD4): the fields they change on rows the * record holds and on how many, the rows they add, and those they delete — a * new row a draft dropped again none of them. * * @param session - The editing session * @param fields - How many fields a draft changes against the one its entry began from * @returns The tally */ export declare function tallyDrafts(session: SheetTransactions, fields: (before: unknown, current: unknown) => number): RecordTally; /** * What a step of the history will have done, read before it is taken: Undo * of a deletion restores its rows; any other Undo, and any Redo, one change; * Discard drops every draft; Apply sends them. * * @param action - The step * @param session - The editing session, as it stands before the step * @param fields - How many fields a draft changes against the one its entry began from * @returns The step's words' facts; `undefined` for a step the session will not take, and a refresh */ export declare function stepOf(action: HistoryAction, session: SheetTransactions, fields: (before: unknown, current: unknown) => number): RecordStep | undefined; /** * The status line's words for a step of the history. * * @param step - What the step did * @param words - The Sheet's words: the counts in the viewer's language * @param noun - The Record's word for its rows * @returns The words */ export declare function stepText(step: RecordStep, words: SheetWords, noun: RecordNoun): string; /** * The status line's words for the Sheet's notice: the Record's own where it * has them, every other notice in the Sheet's words. * * @param notice - The notice the last gesture left * @param words - The Sheet's words * @param noun - The Record's word for its rows * @param issues - Every issue holding Apply: what an issue gone to counts * @returns The words */ export declare function recordNoticeText(notice: SheetNotice, words: SheetWords, noun: RecordNoun, issues: readonly EditIssue[]): string; /** What {@link useRecordStatusLine} reads. */ export interface RecordStatusInput { /** The steps of the history the Record has told. */ status: RecordStatus; /** The Sheet's notice: the last gesture's words, `null` once a step of the history moved past them. */ notice: SheetNotice | null; /** How many gestures the Sheet has recorded. */ gestures: number; /** The rows ticked. */ ticks: RecordTicks; /** How many of the rows shown are ticked. */ ticked: number; /** How many rows are shown. */ of: number; /** Every issue holding Apply: what the words of an issue gone to count. */ issues: readonly EditIssue[]; /** The Sheet's words. */ words: SheetWords; /** The Record's word for its rows. */ noun: RecordNoun; } /** * The status line's words (FR5): the notice, the step or the ticks — whichever * spoke last and still has words — see the module docs. * * @param input - The voices, and what their words are made of * @returns The words; empty while no voice has any */ export declare function useRecordStatusLine(input: RecordStatusInput): string; //# sourceMappingURL=status.d.ts.map