Skip to main content
cngx-src documentation

createFilterBuilderState

Functionforms/filter-builder/state

projects/forms/filter-builder/filter-builder-state.ts

Description#

Default factory behind CNGX_FILTER_BUILDER_STATE_FACTORY. Wraps one writable FilterGroup signal as the canonical tree and returns the CngxFilterBuilderState the presenter drives:

  • read-only tree / fieldMap / isEmpty signals
  • path-keyed mutators (addExpression, setLogic, removeNode, clear, ...)
  • the lastMutation event the announcer formats into live-region text

Two-way binding: pass the presenter's model<FilterGroup>() as source, so every mutator write emits through the consumer's [(value)]. Uncontrolled callers omit source and the factory creates its own signal from initial ?? EMPTY_ROOT.

Plain TS, no inject() - testable without TestBed. Override the token to wrap this (logging, undo) rather than reimplementing the mutators.

Signature#

createFilterBuilderState(opts: CngxFilterBuilderStateOptions)

Parameters#

Returns#

CngxFilterBuilderState