/** * The classes a part carries, asked of the contract rather than spelled by a renderer. * * This sits between the catalog (which parts exist, what they are called, what states they may be * in) and the state vocabulary (how a state is spelled). Keeping it apart from both is what lets the * chip ask for `--selected` without the catalog having to be loaded to answer: the vocabulary * depends on nothing, and only this module needs to know the whole catalog. */ import { type MdyWidgetKind, type MdyWidgetPart } from "./catalog.js"; import { type MdyPartState, type MdyStateName } from "./state.js"; /** * The classes a part carries right now: what it is, then what it is doing. * * Throws when asked for a state the part does not declare. That is a contract violation rather than * a styling accident — a renderer reaching for `--focused` on a part whose theme rule is `--active` * has invented vocabulary, and the point of naming states was to stop exactly that from being * possible to do quietly. */ export declare function partClasses(kind: K, part: MdyWidgetPart, states?: MdyPartState): readonly string[]; /** The states a part declares, for a conformance runner or an audit. */ export declare function partStates(kind: K, part: MdyWidgetPart): readonly MdyStateName[]; /** * Every class the contract can produce for a widget: its parts, and every state each part declares. * * This is what an audit compares the shipped CSS against — a theme rule for a class this set does * not contain is a rule matching nothing, and a renderer emitting one is a renderer off contract. */ export declare function widgetStateClasses(kind: MdyWidgetKind): readonly string[]; /** * Escapes a name for use in a selector — a class or an id, the rule is the same. * * Exported from this module and not from the package's door: it is how a selector is built here, not * a question a consumer asks. * * Hand-rolled rather than `CSS.escape`, which is a browser global this package must not require: * this package loads and computes in a process with no DOM, and a bare `CSS.escape` reference turns * that into a `ReferenceError` the moment a selector is built. */ export declare function escapeForSelector(name: string): string; /** * The CSS selector the contract's declared classes amount to, or `null` where it declares none. * * Moved here from the testing door, which was the only place it was published. Finding a part by its * classes is not a testing question — every renderer asks it, and the ones that could not import it * wrote the class name out as a literal instead. A selector written by hand is a copy of the * vocabulary no rename reaches: the class moves, the selector matches nothing, and the only symptom * is a part that quietly stops being found. * * `null` and not `""` for a part with no classes of its own — five controls have none. An empty * selector string is not "matches nothing", it is a syntax error in `querySelector`. * * `null` too for a part the kind does not have, where `partClasses` raises. A caller asking "where is * this part" is often sweeping every part name there is, and for that question "this kind has no such * part" is an answer rather than a mistake. */ export declare function partSelector(kind: K, part: MdyWidgetPart | string, states?: MdyPartState): string | null;