Skip to main content
cngx-src documentation

CngxFormFieldHostContract

Interface

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 pieces:

  • showError: Signal<boolean> - the resolved "should errors be visible right now" flag. Combines invalid() 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.

Deliberately scoped to these two 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#

Properties

Instance Properties#

showError#Signal
Readonly

True when errors should be visible to the user.

Methods#

markAsTouched#void

Marks the surrounding field as touched. Typically called from a control's focusout host listener.