aihu headless behavior primitives — WAI-ARIA APG patterns as vanilla custom elements, zero CSS.
attachHiddenInputfunction attachHiddenInput(host: HTMLElement, opts: HiddenInputOptions): () => voidAttach a visually-hidden native input to `host`, kept in sync with the provided signals by a single effect.
createCollectionfunction createCollection(): CollectionContextValueThe registration mechanism, usable standalone (roving-focus reuses it).
createDomContextfunction createDomContext<T>(name: string, defaultValue?: T): DomContext<T>Create a context token.
createFocusTrapfunction createFocusTrap(container, options = {})defineButtonfunction defineButton(tag: string): typeof AihuButtonRegister a concrete button tag backed by `AihuButton` (idempotent).
defineCheckboxfunction defineCheckbox(): voidRegister all checkbox custom elements (idempotent).
defineCollectionfunction defineCollection(tag = 'aihu-collection'): voidRegister `<aihu-collection>` (idempotent).
defineConfigProviderfunction defineConfigProvider(tag = 'aihu-config-provider'): voidRegister `<aihu-config-provider>` (idempotent).
defineDialogfunction defineDialog(prefix = 'aihu'): voidRegister all dialog custom elements under `<prefix>-dialog-*` (idempotent per prefix).
defineFormControlfunction defineFormControl(tag = 'aihu-form-control'): voidRegister `<aihu-form-control>` (idempotent).
defineInputfunction defineInput(tag = 'aihu-input'): voidRegister `<aihu-input>` (idempotent).
defineLabelfunction defineLabel(tag = 'aihu-label'): voidRegister `<aihu-label>` (idempotent).
definePopoverfunction definePopover(prefix = 'aihu'): voidRegister all popover custom elements under `<prefix>-popover-*` (idempotent per prefix).
definePresenceGatefunction definePresenceGate(tag = 'aihu-presence-gate'): voidRegister `<aihu-presence-gate>` (idempotent — safe to call repeatedly).
defineRadioGroupfunction defineRadioGroup(): voidRegister all radio-group custom elements (idempotent).
defineRovingFocusfunction defineRovingFocus(tag = 'aihu-roving-focus'): voidRegister `<aihu-roving-focus>` (idempotent).
defineSeparatorfunction defineSeparator(tag = 'aihu-separator'): voidRegister `<aihu-separator>` (idempotent).
defineSliderfunction defineSlider(): voidRegister all slider custom elements (idempotent).
defineSwitchfunction defineSwitch(): voidRegister all switch custom elements (idempotent).
defineTextareafunction defineTextarea(tag = 'aihu-textarea'): voidRegister `<aihu-textarea>` (idempotent).
defineTooltipfunction defineTooltip(prefix = 'aihu'): voidRegister all tooltip custom elements under `<prefix>-tooltip-*` (idempotent per prefix).
injectContextfunction injectContext<T>(from: Element, ctx: DomContext<T>): T | Read<T>Resolve `ctx` for `from` by walking UP the DOM from `from.parentNode`, crossing `ShadowRoot` boundaries (`ShadowRoot → .host`), nearest-wins.
injectValuefunction injectValue<T>(from: Element, ctx: DomContext<T>): TLike `injectContext`, but for the common case where a context carries a raw (non-signal) value — typically an object whose fields are themselves signals.
provideContextfunction provideContext<T>(host: Element, ctx: DomContext<T>, value: T | Read<T>): voidProvide `value` for `ctx` on `host`.
checkboxContextconst checkboxContextcollectionContextconst collectionContextconfigContextconst configContextdialogContextconst dialogContextFocusTrapconst FocusTrapFocusTrapOptionsconst FocusTrapOptionsformControlContextconst formControlContextpopoverContextconst popoverContextpresenceContextconst presenceContextContext carrying the gate's `present` signal to descendants.
radioGroupContextconst radioGroupContextradioGroupItemContextconst radioGroupItemContextsliderContextconst sliderContextswitchContextconst switchContexttooltipContextconst tooltipContextAihuButtonclass AihuButton extends HTMLElementAihuCheckboxIndicatorclass AihuCheckboxIndicator extends HTMLElementPresentational styling hook: mirrors the root's state, hidden from AT.
AihuCheckboxRootclass AihuCheckboxRoot extends HTMLElementAihuCollectionclass AihuCollection extends HTMLElementAihuConfigProviderclass AihuConfigProvider extends HTMLElementAihuDialogBackdropclass AihuDialogBackdrop extends DialogPieceAihuDialogCloseclass AihuDialogClose extends DialogPieceAihuDialogContentclass AihuDialogContent extends DialogPieceAihuDialogDescriptionclass AihuDialogDescription extends DialogPieceAihuDialogRootclass AihuDialogRoot extends HTMLElementAihuDialogTitleclass AihuDialogTitle extends DialogPieceAihuDialogTriggerclass AihuDialogTrigger extends DialogPieceAihuFormControlclass AihuFormControl extends HTMLElementAihuInputclass AihuInput extends AihuTextControlBaseAihuLabelclass AihuLabel extends HTMLElementAihuPopoverContentclass AihuPopoverContent extends PopoverPieceAihuPopoverRootclass AihuPopoverRoot extends HTMLElementAihuPopoverTriggerclass AihuPopoverTrigger extends PopoverPieceAihuPresenceGateclass AihuPresenceGate extends HTMLElementAihuRadioGroupIndicatorclass AihuRadioGroupIndicator extends HTMLElementPresentational styling hook: mirrors its enclosing ITEM's state (nearest `radioGroupItemContext` provider), hidden from AT.
AihuRadioGroupItemclass AihuRadioGroupItem extends HTMLElementAihuRadioGroupRootclass AihuRadioGroupRoot extends AihuRovingFocusAihuRovingFocusclass AihuRovingFocus extends HTMLElementAihuSeparatorclass AihuSeparator extends HTMLElementAihuSliderRootclass AihuSliderRoot extends HTMLElementAihuSwitchRootclass AihuSwitchRoot extends HTMLElementAihuSwitchThumbclass AihuSwitchThumb extends HTMLElementPresentational styling hook: mirrors the root's state, hidden from AT.
AihuTextareaclass AihuTextarea extends AihuTextControlBaseAihuTextControlBaseabstract class AihuTextControlBase extends HTMLElementAihuTooltipContentclass AihuTooltipContent extends HTMLElementAihuTooltipRootclass AihuTooltipRoot extends HTMLElementAihuTooltipTriggerclass AihuTooltipTrigger extends HTMLElementMissingContextErrorclass MissingContextError extends ErrorThrown by `injectContext` when no provider is found and the token has no default.
CheckboxContextValueinterface CheckboxContextValue {
readonly state: Read<CheckboxState>
readonly disabled: Read<boolean>
}CollectionContextValueinterface CollectionContextValue {
/** Register `el`; returns a disposer that unregisters it. */
register(el: Element): () => void
/** Registered descendants, kept in DOM order. */
readonly items: Read<Element[]>
}ConfigContextValueinterface ConfigContextValue {
readonly colorScheme: Read<ColorScheme>
readonly density: Read<Density>
readonly dir: Read<Direction>
}DialogContextValueinterface DialogContextValue {
readonly open: Read<boolean>
readonly modal: Read<boolean>
readonly contentId: Read<string>
readonly titleId: Read<string | null>
readonly descriptionId: Read<string | null>
setTitleId(id: string): void
setDescriptionId(id: string): void
setOpen(next: boolean): void
close(): void
toggle(): void
}DomContextinterface DomContext<T> {
readonly _key: symbol
readonly _name: string
readonly _default: T | undefined
}Opaque token identifying a context slot.
FormControlContextValueinterface FormControlContextValue {
readonly disabled: Read<boolean>
readonly required: Read<boolean>
readonly invalid: Read<boolean>
readonly controlId: Read<string>
readonly describedById: Read<string | null>
readonly labelId: Read<string | null>
}HiddenInputOptionsinterface HiddenInputOptions {
type: 'checkbox' | 'radio'
name: Read<string | null>
value: Read<string>
checked: Read<boolean>
required: Read<boolean>
disabled: Read<boolean>
}PopoverContextValueinterface PopoverContextValue {
readonly open: Read<boolean>
readonly contentId: Read<string>
readonly placement: Read<Placement>
/** Resolved position written by the content after each `position()` call. */
readonly coords: Read<PopoverCoords | null>
setCoords(next: PopoverCoords): void
/** Programmatic write — signal + reflected attribute, does NOT emit. */
setOpen(next: boolean): void
/** User-driven toggle (trigger click / Enter / Space) — emits. */
toggle(): void
/** User-driven close WITHOUT returning focus (outside pointerdown). */
close(): void
/** User-driven close that RETURNS focus to the trigger (Escape). */
dismiss(): void
registerTrigger(el: Element): void
registerContent(el: Element): void
triggerEl(): Element | null
}PopoverCoordsinterface PopoverCoords {
x: number
y: number
placement: Placement
}The position the shim actually applied (post viewport-collision flip).
RadioGroupContextValueinterface RadioGroupContextValue {
/** Currently selected item value; null when nothing is selected. */
readonly value: Read<string | null>
/** Group-effective disabled (own attribute ∥ inherited form-control). */
readonly disabled: Read<boolean>
readonly required: Read<boolean>
/** Programmatic write: signal + reflected `value` attribute. NO event. */
setValue(next: string | null): void
/** USER-driven selection of `item` (click path): moves the tab stop to the
* item WITHOUT stealing focus, selects its value, emits `value-change`. */
selectItem(item: Element): void
}RadioGroupItemContextValueinterface RadioGroupItemContextValue {
readonly checked: Read<boolean>
readonly disabled: Read<boolean>
}Per-item context so `<aihu-radio-group-indicator>` mirrors its OWN item (nearest-provider-wins walk lands on the enclosing item, not the root).
SliderContextValueinterface SliderContextValue {
readonly value: Read<number>
readonly min: Read<number>
readonly max: Read<number>
readonly step: Read<number>
readonly disabled: Read<boolean>
}SwitchContextValueinterface SwitchContextValue {
readonly checked: Read<boolean>
readonly disabled: Read<boolean>
}TooltipContextValueinterface TooltipContextValue {
readonly open: Read<boolean>
readonly contentId: Read<string>
readonly placement: Read<Placement>
readonly openDelay: Read<number>
readonly closeDelay: Read<number>
setOpen(next: boolean): void
/** Schedule open/close honoring the configured delays. */
scheduleOpen(): void
scheduleClose(): void
/** Immediate dismiss (Escape). */
dismiss(): void
registerTrigger(el: Element): void
triggerEl(): Element | null
}TooltipCoordsinterface TooltipCoords {
x: number
y: number
placement: Placement
}ButtonTypetype ButtonType = 'button' | 'submit' | 'reset'CheckboxStatetype CheckboxState = 'checked' | 'unchecked' | 'indeterminate'ColorSchemetype ColorScheme = 'light' | 'dark' | 'system'Densitytype Density = 'comfortable' | 'compact'Directiontype Direction = 'ltr' | 'rtl'Orientationtype Orientation = 'horizontal' | 'vertical' | 'both'SeparatorOrientationtype SeparatorOrientation = 'horizontal' | 'vertical'