Skip to main content
cngx-src documentation

CngxOptionInteractionHost

Interface

projects/common/interactive/listbox/option-interaction-host.ts

Referenced by#

Import#

import { CngxOptionInteractionHost } from '@cngx/common/interactive'

Description#

Pull-based contract a parent host (e.g. CngxSelectShell) implements so individual CngxOption instances can resolve their highlight state and route click + hover activations when the option's own inject(CngxActiveDescendant) returns null.

The need arises with content-projected options: at construction time, the option's element-injector chain anchors in the consumer's authoring view - which has no surrounding CngxActiveDescendant. The shell that owns the listbox + AD provides this token via useExisting, and projected options consult it as a fallback.

Splitting the contract into a narrow surface (activeId / activate / highlight) keeps the option agnostic about HOW the host wires its AD - the shell forwards to its inner listbox's AD, a hypothetical custom host could route through telemetry / multi-AD coordination / etc. without changing the option directive.

Index#

Instance Properties#

activeId#Signal
Readonly

Currently active option id, or null when no option is highlighted. The option compares against its own id to drive the cngx-option--highlighted host class.

Methods#

activate#void
activate(value: unknown)

Activate (commit / select) the option carrying the given value. Called from the option's click handler when its own AD inject is null. The host typically routes through its listbox's highlightByValue(value); activateCurrent() pair.

@paramvalueunknown
highlight#void
highlight(value: unknown)

Move the highlight to the option carrying the given value. Called from the option's pointerenter handler. The host typically routes through its listbox's highlightByValue(value).

@paramvalueunknown