useSelectableCollection
Shared collection and value resolution utilities for compound selection primitives.
selectable-collection is the shared item registry used by compound selection components such as RadioGroup, CheckboxGroup, ToggleGroup, and CommandPalette.
Use it when building a custom compound primitive that needs DOM-order item registration, enabled-item filtering, or consistent fallback selection from highlighted, selected, and first enabled item.
Installation
dgadd is not public on npm yet. Until the first release, pack @diffgazer/add from the repository and install that tarball into this app, which is what puts dgadd on pnpm exec.
The hosted registry is not public yet because r.b4r7.dev does not resolve. Use this source checkout or a local registry preview until the endpoint returns 200.
Diffgazer packages are not yet published to npm. Until the first release, pack @diffgazer/ui and @diffgazer/keys from the repository and install those tarballs.
UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS once packages are available.
In copy mode the item writes three files — lib/selectable-collection.ts, lib/selectable-collection-observer.ts, and lib/selectable-group.ts — and pulls in the @diffgazer-keys/focusable registry item.
API
Usage
Notes
- The collection is sorted by DOM order, so keyboard traversal matches the rendered layout.
- Disabled items and items without mounted elements are excluded by
getEnabledSelectableCollectionItems. resolveSelectableCollectionItemtries candidates in order and falls back to the first enabled item.