CngxFormFieldHostContract
projects/core/tokens/form-field-host.token.ts
Referenced by#
Import#
import { CngxFormFieldHostContract } from '@cngx/core/tokens'
Description#
Narrow back-channel a form-field-aware host (typically
CngxFormFieldPresenter) exposes to the bound control.
Two required pieces plus one optional naming channel:
showError: Signal<boolean>- the resolved "should errors be visible right now" flag. Combinesinvalid()with the configured visibility gate (touched,dirty,submitted, custom strategy, ambient reveal-scope). The control reads this to decide whether to paint its own error skin (aria-invalid,.cngx-...--error).markAsTouched(): void- invoked by the control on focus-out so the surrounding field's "touched" state advances without the control importing the concrete presenter or field-state shape.labelId?: Signal<string>- stable id of the field's label element. Group-role atoms (radiogroup/group/listbox/toolbar) reference it viaaria-labelledbywhen no explicitlabelinput is set; group roles take no name from content, so this channel is what names them inside acngx-form-field.skin?: Signal<CngxFieldSkin | undefined>- the field's own, unresolved appearance value. The host publishes what was bound to it and nothing else; resolving the cascade is the reader's job.
Deliberately scoped to these members. The full presenter exposes
many more signals (constraints, ARIA IDs, dirty / pending / readonly /
submitting); pulling all of them through a token would over-couple the
control surface to the presenter's evolution. Anything richer lives
inside the form-field bridge directives in @cngx/forms/field, not
inside the control atoms themselves.
Layer note. Lives in @cngx/core/tokens (Level 1) so Level-2 atoms
in @cngx/common/* can read the contract without importing from the
Level-3 @cngx/forms/field library. Mirrors CNGX_FORM_FIELD_CONTROL
(atom-side contract) on the host side; together the two tokens form a
Sheriff-clean parent-child interaction surface.
Index#
Methods
Instance Properties#
SignalStable id of the field's label element (CngxLabel), when the host
renders one. Optional so hosts without a label surface keep
satisfying the contract; consumers read it as
host.labelId?.() ?? null.
The appearance bound on the host itself, unresolved. undefined
means the host was given no skin, not that it wants 'outline' -
the config default still has to win in that case. Optional so hosts
without an appearance surface keep satisfying the contract;
consumers read it as host.skin?.() ?? config.skin ?? 'outline' and
own the fallback.