Takes a list of items and handles selection for them.

Type Parameters

  • T

Constructors

  • Type Parameters

    • T

    Parameters

    • items: T[]

      List of original items to set up selection for.

    • pkField: keyof T = ...

      Item unique property key to store selection by.

    • pksSelected: PK[] = []

      List of item PKs that are selected.

    Returns Selection<T>

Properties

deselected: number = 0

Number of deselected items.

indeterminate: boolean = false

Is selection indeterminate?

items: T[]

List of original items to set up selection for.

onChange: EventEmitter<void> = ...

Triggers whenever any selection change happen.

onDeselect: EventEmitter<T> = ...

Triggers when an item is deselected.

onDeselectAll: EventEmitter<T> = ...

Triggers when all items are deselected. Only when Selection.deselectAll is called.

onSelect: EventEmitter<T> = ...

Triggers when an item is selected.

onSelectAll: EventEmitter<T> = ...

Triggers when all items are selected. Only when Selection.selectAll is called.

pkField: keyof T = ...

Item unique property key to store selection by.

selected: number = 0

Number of selected items.

selection: Record<PK, boolean> = {}

Selection dict.

This is where we keep which item is selected (value true) and which item is not (value not true).

Accessors

Methods

  • Update selected and deselected numbers. Also update indeterminate status.

    Returns void

  • Deselect an item.

    Parameters

    • item: T

      to deselect.

    • count: boolean = true

      Whether to generate counts (default is true).

    Returns void

  • Select an item.

    Parameters

    • item: T

      to select.

    • count: boolean = true

      Whether to generate counts (default is true).

    Returns void

  • Select all if selection is indeterminate or no item is selected otherwise deselect all.

    Returns void

  • Toggle an item selection status.

    Parameters

    • item: T

      to toggle selection.

    • count: boolean = true

      Whether to generate counts (default is true).

    Returns void