/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { StringType, type ArrayType, type option, type ValueTypeOf } from "@elaraai/east"; import type { RowSourceType } from "@elaraai/east-ui"; import { type RecordSliceBindType } from "@elaraai/east-ui/internal"; /** What a builder's payload says about which rows show. */ export interface KeyVisibilityInput { /** The narrowed rows' keys, paged through a record Slice; `none` with no record Slice. */ visibleSource: option>>> | undefined; /** The keys to show when no record Slice narrows: a Set, or `none` for every row. */ visible: option>; /** Every row, in its order: what shows when nothing narrows. */ rows: readonly { key: string; }[]; /** The record Slice chrome, whose Retry a failed narrowing offers. */ recordSlice: option<{ slice: { retry: () => void; }; }> | undefined; } /** The words a failed narrowing says. */ export interface KeyVisibilityWords { /** The results moved while they were read (`Staff results changed; retry the narrowing.`). */ changed: string; /** The results could not be read (`Could not load staff results`). */ failed: string; } /** Which rows show, and the narrowing's state. */ export interface KeyVisibility { /** The keys to show: `none` for every row. */ keys: option>; /** * Whether a choice of the viewer's narrows what shows (#1621): what a count of it says `N of M` for, and what Clear * filters clears. A page's scope is none: the rows it holds are the source's whole, though `keys` holds them. */ chosen: boolean; /** * How many rows the source's page holds, where its scope narrows it (#1621): what a count of what shows is out of — * `none` while it is read; `undefined` on a page with no scope, which holds every row. */ held: option | undefined; /** Whether a complete membership has resolved yet. */ ready: boolean; /** Whether a new narrowing is resolving (the previous membership still shows). */ loading: boolean; /** Why the narrowing could not be read. */ error: string | undefined; /** Read the narrowing again. */ retry: () => void; } /** * Which rows show (see the module docs). * * @param value - What the payload says about which rows show * @param words - What a failed narrowing says * @returns The keys to show, and the narrowing's state */ export declare function useKeyVisibility(value: KeyVisibilityInput, words: KeyVisibilityWords): KeyVisibility; /** * What a count of a source's shown rows is out of (#1621): the rows its page holds, where its scope narrows it — none * while that count is read — else every row of the source. Never the record's whole beyond the page. * * @param shown - The source's visibility: how many rows its page holds (`held`; left out with no scope) * @param every - How many rows the source has * @returns The count's whole; `undefined` while the page's count is read */ export declare function shownWhole(shown: { readonly held?: option | undefined; }, every: number): number | undefined; /** A Slice over several records' chrome, as a builder's payload carries it: each source's part. */ export interface SourcesChrome { slice: { parts: readonly { source: string; slice: ValueTypeOf; }[]; }; } /** * One source's part of a Slice over several records (#1339). * * @param chrome - The payload's chrome; `undefined` with no slice * @param source - The source's name (`resources`) * @returns Its record Slice's controls, if the slice has the source */ export declare function sourcePart(chrome: SourcesChrome | undefined, source: string): ValueTypeOf | undefined; /** * Which of a source's rows show (#1339): the keys its part of a Slice over * several records narrows to while a choice or its page's scope (#1621) * narrows it, every row — and no read — while nothing does. Every place a * builder shows the source's rows reads these keys, so one choice narrows them * all, and a scoped source shows the scope's rows alone. Beside them it says * whether a choice of the viewer's narrows them — a page's scope is none — and, * on a scoped page, how many rows the page holds: what a count of what shows is * out of, never the record's whole. * * @param chrome - The payload's chrome; `undefined` with no slice * @param source - The source's name (`resources`) * @param keys - The source's narrowed keys, paged through its part, as the payload carries them * @param rows - Every row of the source, in order * @param words - What a failed narrowing says * @returns The keys to show, and the narrowing's state */ export declare function useSourceVisibility(chrome: SourcesChrome | undefined, source: string, keys: option>>>, rows: readonly { key: string; }[], words: KeyVisibilityWords): KeyVisibility; //# sourceMappingURL=visibility.d.ts.map