/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { type EastTypeValue, type option, type ValueTypeOf } from "@elaraai/east"; import { RecordSliceWhereType, type RecordSliceBindType, type RecordSliceFieldType, type RecordSliceIndexType } from "@elaraai/east-ui/internal"; import { type Formatters } from "@elaraai/east-ui-components"; import type { HiddenWords } from "./words.js"; type Where = ValueTypeOf; type Index = ValueTypeOf; type Bind = ValueTypeOf; type Field = ValueTypeOf; /** One question the hidden pick asks of a row: whether a narrowing standing for one of the choices holds it. */ export interface HidingQuestion { /** The choice it asks of, by its field. */ readonly field: string; /** The narrowing asked: the choice alone, or — one the rail lets stand only after the choices before it — with them. */ readonly where: Where; } /** * The questions that tell which of a narrowing's choices hide a row (see the * module docs): each choice alone where the index rules let it stand alone, * else with the choices before it, as the rail holds it. * * @param indexes - The record's indexes, as its source lists them * @param where - The narrowing * @returns One question for each choice, in the narrowing's order */ export declare function hidingQuestions(indexes: readonly Index[], where: Where): HidingQuestion[]; /** Which choices hide a row, by their fields, as its questions' answers say. */ export interface HidingVerdict { /** The choices that hide it, in the narrowing's order. */ readonly by: readonly string[]; /** The choices whose own answer is not known: each asked only beside one that hides the row. */ readonly unknown: readonly string[]; } /** * Which choices hide a row, from whether each question holds it (see the * module docs). A question that holds the row holds it by every choice in it, * a narrowing being all of its choices at once; one that does not, asked of a * choice alone, says that choice hides it, and asked of a choice with others, * says so once every other choice in it holds the row. * * @param questions - The questions, as {@link hidingQuestions} asks them * @param holds - Whether each holds the row, in their order * @returns The choices that hide it, and those that cannot be told apart from them; `undefined` when the answers say * nothing hides it, which a row the narrowing hides cannot be: they were read at another revision */ export declare function hidingOf(questions: readonly HidingQuestion[], holds: readonly boolean[]): HidingVerdict | undefined; /** What e3 said hides a row the narrowing hides, and what a pick of it clears (the hidden pick). */ export interface HiddenAnswer { /** The choices that hide it, by their fields, in the narrowing's order. */ readonly by: readonly string[]; /** * The choices a pick clears beside them, by their fields: each one the rail clears with one of them, as it cannot * stand without it, or one that could not be told apart from them. */ readonly also: readonly string[]; /** The narrowing a pick leaves: every other choice. */ readonly where: Where; } /** * What a pick of a row clears: the choices that hide it, each cleared as the * rail clears a choice — dropping one that cannot stand without it — and any * that could not be told apart from them still standing. * * @param indexes - The record's indexes, as its source lists them * @param where - The narrowing * @param verdict - Which choices hide the row * @returns The answer: what hides it, what a pick clears besides, and the narrowing it leaves */ export declare function clearingOf(indexes: readonly Index[], where: Where, verdict: HidingVerdict): HiddenAnswer; /** The choices that hide a row and those a pick clears with them, each as the rail words it — `Status: Ready`. */ export interface HidingWords { /** The choices that hide it. */ readonly filters: readonly string[]; /** The choices a pick clears with them. */ readonly also: readonly string[]; } /** * What e3 said hides a row, each choice as the rail words it: its field's * label and the choice the narrowing holds of it (`recordChoiceLabel`). * * @param fields - The source's fields, as its part of the slice lists them * @param where - The narrowing the answer was asked of * @param answer - What e3 said hides the row * @param words - The app's formatters, which word a date or a number of a choice * @returns The choices that hide it, and those a pick clears with them */ export declare function hidingWords(fields: readonly Field[], where: Where, answer: HiddenAnswer, words: Formatters): HidingWords; export { hiddenByText, type HiddenWords } from "./words.js"; /** What the narrowing holds of a row it was asked of, and — of one it hides — what e3 said hides it, once it has. */ export type HiddenState = /** The narrowing holds it, or the record holds no row by its key: nothing hides it. */ { readonly hidden: false; } /** The narrowing hides it: what does, `undefined` until e3 has said — or where it could not. */ | { readonly hidden: true; readonly answer: HiddenAnswer | undefined; }; /** What {@link useHiddenRows} asks e3 through. */ export interface HiddenRowsInput { /** Who asks, as its console names it when a read fails: `Sheet`, `Allocation`. */ readonly name: string; /** The source's part of the slice; `undefined` while nothing narrows its rows. */ readonly part: Bind | undefined; /** Its narrowing. */ readonly where: Where | undefined; /** The record's revision the builder reads at: what the answers are kept by, with the source and the narrowing. */ readonly revision: string | undefined; /** A row's record key, by its id: none for an id that names no key. */ readonly keyOf: (id: string) => option; /** A row's id, by its record key. */ readonly idOf: (key: unknown) => string; } /** The hidden pick's reads, and what they have been told. */ export interface HiddenRows { /** * Asks which choices hide the rows a listing of the record holds from its row `from` that the narrowing hides — the * key search's lines: their rows are those the listing read, so nothing is read again for them. * * @param from - The listing's first row, in the record's order * @param ids - Each listed row's id, in order * @param held - Whether the narrowing holds each, as the listing read it */ askListed(from: number, ids: readonly string[], held: readonly boolean[]): void; /** * Asks of some rows by their ids — an issue's, or the rows the key search's lines stand on — whether the narrowing * hides them, and which choices hide those it does: their rows read by their keys in one request, which the narrowing * holds in one more — none more where the builder knows already that it hides them all, as the source's shown keys * have said. * * @param ids - The rows' ids * @param hidden - Whether the narrowing is known to hide every one of them */ askIds(ids: readonly string[], hidden?: boolean): void; /** * What is known of a row at the revision and the narrowing now. * * @param id - The row's id * @returns Its state; `undefined` while it has not been asked of, or is being asked whether the narrowing hides it */ stateOf(id: string): HiddenState | undefined; /** Moves as answers land. */ readonly version: number; } /** * Reads which of a source's choices hide the rows its narrowing hides, for * the rows a builder is asked to say so of — see the module docs. * * @param input - Who asks, the source's part, its narrowing, the record's revision, and its rows' keys * @returns The reads and what they have been told */ export declare function useHiddenRows(input: HiddenRowsInput): HiddenRows; /** * The revision a source's record is read at, tracked: what a builder that * reads the record through its part — not through a lens of its own — keeps * its hidden pick's answers by. * * @param part - The source's part of the slice; `undefined` with none * @returns Its revision; `undefined` while it is not known, or with no part */ export declare function usePartRevision(part: Bind | undefined): string | undefined; /** The hidden pick over one source: what it asks and is told, the source's part, its narrowing and the window it keeps. */ export interface SourceHidden { /** The pick's reads, and what they have been told. */ readonly rows: HiddenRows; /** The source's part of the slice; `undefined` with none. */ readonly part: Bind | undefined; /** Its narrowing now — but the window a builder's navigation writes into it; `undefined` with no part. */ readonly where: Where | undefined; /** * The field of its narrowing a builder's navigation writes — the Calendar's event kinds' range, their window — which * hides no row: left out of what is asked, and kept as a pick clears ({@link clearHidden}); `undefined` with none. */ readonly window: string | undefined; /** * Whether it can ask e3 now — its part, its narrowing and its record's revision known. The pick is another object once * it can, so what asks of it as it renders asks again then. */ readonly ready: boolean; } /** What {@link useHidden} reads a source's rows through: {@link useHiddenRows}' input, and the window the builder keeps. */ export interface SourceHiddenInput extends HiddenRowsInput { /** The field of the source's narrowing the builder's own navigation writes, which hides no row; none by default. */ readonly window?: string | undefined; } /** * The hidden pick over one source, as the builder reads the source's rows — * the Sheet's `rows` source through its lens, at the lens's revision, its rows * keyed by its record's key type ({@link useSourceHidden} for a source read * through its part). * * @param input - Who asks, the source's part, its narrowing, the record's revision, its rows' keys and its window * @returns The pick, the same object while what it has been told, its narrowing and its readiness hold */ export declare function useHidden(input: SourceHiddenInput): SourceHidden; /** * The hidden pick over one source of a builder's `Slice.bindRecords`, read * through its part — never through a lens of its own, as the Sheet's is — its * rows by their ids, each its key's text (#1549): by String, a row's id its * key, as `recordSources` binds every source but the Flowchart's and the * Schematic's, whose records may be keyed by any type, each id read back at it. * Its narrowing followed as a choice moves it, the same object while its * choices hold, its answers kept by its record's revision: the Allocation's * lanes, resources and arrivals, the Roster's people, each of the Calendar's * event and resource kinds, and the Flowchart's and the Schematic's kinds * (`hidden-pick.tsx`' `HideSources`). * * @param name - Who asks, as its console names it when a read fails * @param part - The source's part of the slice; `undefined` with none * @param window - The field of its narrowing the builder's own navigation writes — the Calendar's event kinds' range, * their window — which hides no row: left out of what is asked, and kept as a pick clears ({@link clearHidden}) * @param keyType - Its record's key type, which a row's id is read back at; String by default * @returns The pick */ export declare function useSourceHidden(name: string, part: Bind | undefined, window?: string, keyType?: EastTypeValue): SourceHidden; /** * Clears the choices that hide a row, as the rail clears a choice: those e3 * named — and what goes with them — else, while it has not said, every choice * of the source; the source's narrowing written once, a write of the rail like * a chip's. A window the builder's navigation writes into the source is kept. * * @param part - The source's part of the slice * @param answer - What e3 said hides the row; `undefined` while it has not * @param window - The field of the narrowing that holds the builder's window ({@link useSourceHidden}): kept as it is */ export declare function clearHiding(part: Bind, answer: HiddenAnswer | undefined, window?: string): void; /** * A source a builder reads as hiding a row — as the layout it shows draws the row: the source's hidden pick, and the * source's row the row stands on, by its id — the row itself, or the lane a bin stands in, the resource an event is drawn * on. */ export interface RowHiding { /** The source's hidden pick. */ readonly pick: SourceHidden; /** The source's row the row stands on, by its id. */ readonly id: string; } /** A source that hides a row, as a pick clears it: its hidden pick, and what e3 said hides the row there. */ export interface SourceHiding { /** The source's hidden pick. */ readonly pick: SourceHidden; /** What e3 said hides the source's row; `undefined` until it has — or where it could not — when a pick clears every choice of the source. */ readonly answer: HiddenAnswer | undefined; } /** A source that hides a row: the source's row the row stands on, and what e3 said hides that. */ export interface RowHidden extends RowHiding, SourceHiding { } /** * What hides a row, as far as e3 has said: each source the builder reads as hiding it — but one e3 says holds the * source's row, the builder's reading of what the source shows catching up — with what e3 said hides it there. * * @param hidings - The sources the builder reads as hiding the row, in the order its line names them * @returns Those that hide it; `undefined` where none does */ export declare function hiddenOf(hidings: readonly RowHiding[]): readonly RowHidden[] | undefined; /** * Asks e3 which choices hide some rows the narrowing hides — the rows a list shows, or an issue names — a source at a * time: each source's rows the hidings stand on, each once, in one ask of the source (`askIds`). Nothing a source has * been asked at its revision and narrowing is asked again. * * @param hidings - The sources the builder reads as hiding the rows, each with the source's row a row stands on * @param known - Whether the builder knows already that each source hides its rows — as the source's shown keys, or its * rows' membership, have said — so each row's line says so at once, while e3 is asked which choices hide it */ export declare function askHiding(hidings: readonly RowHiding[], known: boolean): void; /** * Clears what hides a row, as the rail clears a choice — each source's choices e3 named and what goes with them, else, * while it has not said, every choice of the source; each source's window kept — one write of the rail a source. A * source whose narrowing holds no choice hides nothing: nothing of it is written. * * @param hidden - Each source that hides the row, and what e3 said hides it there * @throws {Error} Where a source's narrowing could not be written: the sources before it are cleared */ export declare function clearHidden(hidden: readonly SourceHiding[]): void; /** * What a row's line says of what hides it: that the filters do, until e3 has said for each source that hides it; then * the choices that do, every source's in the order given, each as the rail words it, in the builder's words. * * @param hidden - Each source that hides the row, and what e3 said hides it there: one at least * @param formatters - The app's formatters, which word a date or a number of a choice * @param words - The builder's words for it * @returns The words */ export declare function hiddenLine(hidden: readonly SourceHiding[], formatters: Formatters, words: HiddenWords): string; /** * A count that moves each time one of some values is another object than it was, or their number moves. * * @param values - The values * @returns The count: 0 at first */ export declare function useMoves(values: readonly unknown[]): number; /** * What a key search's box lists its lines again by (`relist`): it moves as what the lines say of a row could — e3 * saying which choices hide a row, a source's narrowing, a source coming to ask — each pick another object then — and as * whatever else the builder's lines read moves: what a source shows, the layout. * * @param picks - The hidden picks the lines read * @param also - What else they read, each another object as it moves * @returns The count */ export declare function useRelist(picks: readonly SourceHidden[], also?: readonly unknown[]): number; //# sourceMappingURL=hidden.d.ts.map