/** * The questions a part's `presentWhen` asks, answered once. * * A condition with no way to decide it is a declaration each renderer interprets for itself, and the * interpretations diverge in the direction nobody measures: `valueIsPresent` meant one thing where * chips are drawn and another where they are not, for as long as nothing here answered it. * * Each takes the narrowest input that decides it rather than a widget state, because a resolver that * takes everything is a resolver a caller cannot use without holding everything. ADR 0169 states * which conditions owe an answer and which do not: `documentDeclaresIt`, `kindOffersIt` and * `pointerIsOnAValue` are decided by facts the renderer already holds, and a function over them would * put a call between a consumer and something in their hand. */ import { type MdyInteractivity } from "@modyra/core"; import type { MdyWidgetKind } from "./catalog/kinds.js"; /** * Whether a kind's value holds anything. * * The emptiness of a value is the kind's, not the language's, and the kind declares it: `nullable` * separates a number field whose empty is `null` from a slider whose empty is where it starts, and * the shape separates a list from the single value it holds. `Boolean(value)` gets both of those * wrong, and three renderers asking it separately get them wrong in three ways — which is how this * condition came to mean one thing where chips are drawn and another where they are not. * * Derived from `MDY_VALUE_CONTRACTS` rather than from a table of empties, so a kind added to the * catalogue is answered without an edit here. Three kinds declare a part under this condition today — * a nullable single value and two lists — and the derivation covers every shape rather than those * three, because the fourth kind to declare it should not have to find this function first. */ export declare function valueIsPresent(kind: MdyWidgetKind, value: unknown): boolean; /** The other side, named because a part declares it: a placeholder is present when the value is not. */ export declare function valueIsAbsent(kind: MdyWidgetKind, value: unknown): boolean; /** * Whether the required marker belongs on the page. * * Not `handle.required()` alone. A field out of play cannot be filled in, so a marker on it asks for * something that cannot be given — and the same asterisk that means "you must" on a live field means * nothing at all on a disabled one, which is worse than absent because it still reads as a demand. */ export declare function fieldIsRequired(field: { readonly required: boolean; readonly interactivity: MdyInteractivity; }): boolean; /** Whether an undo is on offer: a destructive act happened and has not been withdrawn. */ export declare function undoIsOnOffer(state: { readonly wayBack?: unknown; }): boolean; /** Whether the view a part belongs to is the one showing — a calendar draws one of days, months, years. */ export declare function viewIsActive(state: { readonly viewMode?: string; }, view: string): boolean; /** * Whether the last attempt to put something in was refused. * * A refusal has to be visible or it did not happen: a file turned away for its size or its type * leaves the value exactly as it was, so the value cannot say that anything occurred. */ export declare function inputWasRefused(state: { readonly rejected?: readonly unknown[]; }): boolean; /** * Whether the widget is waiting on something. * * Two facts and one question: a validator that has not answered yet, and a list of options still * arriving. A part that says "wait" is right for either, and a renderer asking them separately shows * the spinner for one of the two reasons it exists. */ export declare function workIsInFlight(state: { readonly pending?: boolean; readonly loading?: boolean; }): boolean;