plushie/selection

Selection state management for list and table widgets.

Supports single, multi, and range selection modes.

Types

Selection state tracking selected items.

pub opaque type Selection

Selection mode.

pub type SelectionMode {
  Single
  Multi
  Range
}

Constructors

  • Single
  • Multi
  • Range

Values

pub fn clear(sel: Selection) -> Selection

Clear all selections.

pub fn deselect(sel: Selection, id: String) -> Selection

Deselect an item.

pub fn is_selected(sel: Selection, id: String) -> Bool

Check if an item is selected.

pub fn mode(sel: Selection) -> SelectionMode

Get the selection mode.

pub fn new(mode: SelectionMode) -> Selection

Create a new empty selection.

pub fn new_with_order(
  mode: SelectionMode,
  order: List(String),
) -> Selection

Create with a known item order (for range selection).

pub fn range_select(sel: Selection, id: String) -> Selection

Select a range from the anchor to the given item (Range mode). Uses the order list to determine which items fall in the range.

pub fn select(
  sel: Selection,
  id: String,
  extend: Bool,
) -> Selection

Select an item. In Single mode, replaces previous. In Multi mode with extend=True, adds to selection.

pub fn selected(sel: Selection) -> set.Set(String)

Get the set of selected IDs.

pub fn toggle(sel: Selection, id: String) -> Selection

Toggle an item’s selection state. In Single mode, toggling off also clears the anchor (consistent with clearing selection).

Search Document