Skip to content

@jsvision/datagrid / triState

Function: triState()

triState(current, displayKeys): TriState

Defined in: datagrid/src/selection.ts:148

The header select-all tri-state over the displayed rows.

Counts how many of displayKeys are in current: none when zero (or nothing is displayed), all when every displayed row is selected, some otherwise. Keys in current that are not displayed (e.g. selected then filtered out) do not affect the result.

Parameters

current

ReadonlySet<Key>

The current selection.

displayKeys

readonly Key[]

The current display order mapped to keys.

Returns

TriState

'none', 'some', or 'all'.

Example

ts
import { triState } from '@jsvision/datagrid';
const display = ['a', 'b', 'c'];
triState(new Set(['a', 'b']), display);      // 'some'
triState(new Set(['a', 'b', 'c']), display);  // 'all'
triState(new Set(), display);                 // 'none'