CngxCheckboxGroup
cngx-checkbox-group
projects/common/interactive/checkbox-group/checkbox-group.component.ts
Import#
import { CngxCheckboxGroup } from '@cngx/common/interactive'
Description#
Multi-value checkbox-group molecule. Owns a selectedValues model
(the canonical multi-value source) and exposes membership
derivations (allSelected, someSelected, noneSelected,
selectedCount) plus the toggle-all triad (toggleAll, select,
deselect) every consumer needs to wire a "select all" master
checkbox to the group.
Internals lean on createSelectionController from @cngx/core/utils
for membership tracking - the controller's structural-equality
selected snapshot prevents downstream computed cascades from
thrashing when a re-emission produces the same logical contents
with a different array reference.
value is a structural alias of selectedValues so the group
satisfies CngxControlValue<T[]> without owning two synchronised
models - both names point to the same ModelSignal<T[]> instance.
Per Pillar 1 (Ableitung statt Verwaltung), every derived flag is a
computed() - there is no manual sync between membership and the
exposed flags. Per Pillar 3 (Komposition statt Konfiguration), the
group composes CngxRovingTabindex as a host directive and emits
no implicit children - consumers project <cngx-checkbox> instances
(or any other CNGX_CONTROL_VALUE-bearing leaf) and bind each leaf's
value-tracking themselves.
[allValues] is optional; when supplied, allSelected reflects
"every option ticked" rather than the vacuous "every selected value
is still selected" default. Consumers that wire a master checkbox
pass the full option pool here so toggleAll() can
select-or-clear-all per the user's mental model.
[keyFn] lets consumers with object-typed values map each value
to a stable membership key (typically (v) => v.id). Without it,
membership uses identity / primitive equality - which silently
breaks across re-emissions when the consumer refetches array
elements with the same id but new references.
[state] is an optional CngxAsyncState<unknown> input; when bound,
aria-busy reflects state.status() === 'loading' reactively so AT
announces the busy moment without the consumer wiring the attribute
by hand.
<cngx-checkbox-group
label="Notifications"
[allValues]="options"
[(selectedValues)]="picked"
>
<cngx-checkbox
*ngFor="let opt of options"
[value]="opt"
>{{ opt }}</cngx-checkbox>
</cngx-checkbox-group>Metadata#
Host#
Providers#
CNGX_CONTROL_VALUE- useExisting
CngxCheckboxGroup CNGX_FORM_FIELD_CONTROL- useExisting
CngxCheckboxGroup
Relationships
Index#
Properties
HostBindings
Inputs#
readonly T[] | undefinedstring | nullOptional id of an external error message element. The host emits
aria-errormessage="<id>" only when aria-invalid="true" —
symmetric with the sibling aria-invalid host binding (both gate
on invalid() || errorState()). Consumers MUST render an element
with the supplied id. Default null skips the attribute.
nullBridge-writable invalid state. model<boolean> mirrors disabled
so external integrations (RF/Signal-Forms bridges, custom validity
adapters) can drive it without a parallel API path - consumers
typically read only.
false(value: T) => unknown(v) => vstring | undefinedOutputs#
Bridge-writable invalid state. model<boolean> mirrors disabled
so external integrations (RF/Signal-Forms bridges, custom validity
adapters) can drive it without a parallel API path - consumers
typically read only.
T[]Instance Properties#
Methods#
HostBindings#
| Binding | Expression |
|---|---|
[attr.id] | id() |
[attr.aria-label] | label() |
[attr.aria-disabled] | disabled() ? "true" : null |
[attr.aria-required] | required() ? "true" : null |
[attr.aria-invalid] | ariaInvalid() ? "true" : null |
[attr.aria-errormessage] | ariaInvalid() ? errorMessageId() : null |
[attr.aria-busy] | ariaBusy() ? "true" : null |
[class.cngx-checkbox-group--horizontal] | orientation() === "horizontal" |
HostListeners#
| Event | Handler |
|---|---|
(focusin) | focusin() |
(focusout) | focusout() |
Default visuals for CngxCheckboxGroup. The host carries
.cngx-checkbox-group and frames a flex layout for projected
<cngx-checkbox> children. Stacks vertically by default.
Variants
--horizontal- flips to a row withflex-wrap: wrapso long sets fold to additional lines
Inheritance
Gap cascades through the foundation:
--cngx-checkbox-group-gap->--cngx-space-sm
Layout
*0.5remGap between checkbox children. Falls back to --cngx-space-sm.