Skip to main content
cngx-src documentation

injectInteractiveGroupHost

Functioncommon/interactivev0.1.0

projects/common/interactive/group-host/group-host.ts

Description#

Shared scaffolding for the interactive form-control hosts (toggle, checkbox, the standalone interactive chip, and the value groups): stable uid, focus tracking, the field-host/aggregator error cascade, the aria-invalid gate, and [state]-wins-over-CNGX_STATEFUL async-state resolution for aria-busy.

Call from a field initializer (injection context required - the factory injects CNGX_FORM_FIELD_HOST, CNGX_ERROR_AGGREGATOR, and CNGX_STATEFUL, each optional). Declare the invalid model and the state input above the call site so the option signals exist when the initializer runs.

The factory is wiring, not a swap point: it deliberately has no DI factory token. Consumers authoring their own form-control atoms get the same field-host, aggregator, and stateful integration by calling it directly.

All host communication stays reactive (Pillar 2): errorState, ariaInvalid, and ariaBusy are computed() members of the returned bundle. resolvedState forwards a stable reference (the bound input value or the provider's state field, never a fresh literal), so Object.is dedupes without an equal fn.

private readonly groupHost = injectInteractiveGroupHost({
  uidPrefix: 'cngx-checkbox-group-',
  invalid: this.invalid,
  state: this.state,
});
readonly id = this.groupHost.id;
readonly focused = this.groupHost.focused;
readonly errorState = this.groupHost.errorState;
protected readonly ariaBusy = this.groupHost.ariaBusy;

Signature#

injectInteractiveGroupHost(options: CngxInteractiveGroupHostOptions)

Parameters#

Returns#

CngxInteractiveGroupHost