/** * What a widget can be, and the shape of what a definition says about it. * * The vocabulary and the types only. Everything that reads a definition depends on this and not on * the eight hundred lines that build one. */ import type { MdyMultiselectMode } from "@modyra/core"; import type { MdyPartContract } from "../contract.js"; import type { MdyOutsideDismiss } from "../dismissal.js"; import type { MdyWidgetSemanticElement, MdyWidgetStructure } from "../structure.js"; export declare const MDY_WIDGET_KINDS: readonly ["text", "email", "password", "textarea", "number", "slider", "checkbox", "toggle", "radio", "segmented", "select", "multiselect", "datepicker", "daterange", "timepicker", "file", "colors"]; export type MdyWidgetKind = (typeof MDY_WIDGET_KINDS)[number]; /** * Every configuration a varianted kind may be in, across the whole catalogue. * * An alias of the config's own union rather than a list of its own: the variant key *is* the value a * form document carries, so there is one place these words are defined and no way for the two to * disagree. Closed, so a name nothing describes cannot be asked for — a widget checked against an * anatomy that does not exist is the gap variants were added to close. * * **Two axes now, and the question this comment reserved is answered here.** A multiselect varies by * *mode* — what one choice does — and a select varies by *presentation*: it renders the platform's * own chooser unless it filters, and the two shapes have different anatomies. They are different * questions, and the union carries both. * * One type rather than one per kind, because a variant name is only meaningful for the kind that * declares it: `MDY_WIDGET_CONTRACTS[kind].variants` is what says which names a kind answers to, and * a name it does not declare matches nothing — asking a select about `multi` selects no anatomy * rather than the wrong one. That is what makes the shared vocabulary safe, and it is the property * to keep if a third axis arrives: the union may grow, and a lookup must stay a lookup. */ export type MdyWidgetVariant = MdyMultiselectMode | MdySelectPresentation; /** * The two shapes a select is drawn in. * * A select that does not filter renders the **native** chooser — deliberately, for the platform's * typeahead and its mobile picker — and a native `