SelectionState

Observable single + multi selection model used by the editor's master pane (scenario workflow §6) and any other list-or-table surface that wants standard click semantics:

  • Clickselect — replaces the selection with the clicked item; sets the anchor for future range extends.

  • ⌘ / Ctrl-clicktoggle — adds or removes the item; resets the anchor.

  • Shift-clickextend — selects the range between the current anchor and the target within the provided ordered list. When no anchor is set, falls back to select.

Generic in T: any equatable selection-element type works. Scenarios identify rows by name or by ScenarioId; bundle-ref panels identify rows by bundleId.

Survives data mutations through pruneRemoved: when the underlying list drops items, the editor passes the removed set to drop them from the selection in one shot.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val anchor: T?

The most recently anchored item, or null when the selection was cleared.

Link copied to clipboard
val selection: StateFlow<List<T>>

Observable selection, in the order items were added.

Functions

Link copied to clipboard
fun clear()

Empties the selection and clears the anchor.

Link copied to clipboard
fun extend(target: T, orderedItems: List<T>)

Selects the contiguous range between the current anchor and target within orderedItems. When no anchor is set or either endpoint isn't in the ordered list, falls back to select. The anchor stays put so subsequent shift-clicks re-extend from the same starting point.

Link copied to clipboard
fun isSelected(item: T): Boolean

Whether item is currently selected.

Link copied to clipboard
fun pruneRemoved(removed: Collection<T>)

Drops every entry in removed from the selection in one shot. When the anchor is among the removed items, falls back to the most recent surviving selection (or null if the selection emptied). Called by editors when their underlying list mutates.

Link copied to clipboard
fun select(item: T)

Replaces the selection with just item and sets the anchor. Standard click semantics.

Link copied to clipboard
fun set(items: List<T>)

Replaces the selection wholesale. The anchor is set to the last item in items, or null when items is empty.

Link copied to clipboard
fun toggle(item: T)

Toggles whether item is selected and resets the anchor to item (or to null if the item was deselected to empty). Standard ⌘ / Ctrl-click semantics.