UNPKG

@1771technologies/lytenyte-pro

Version:

Blazingly fast headless React data grid with 100s of features.

22 lines (21 loc) 600 B
import { getTreeNodeId } from "./get-tree-node-id.js"; export function toggleSelection(el, ctx) { const id = getTreeNodeId(el); if (ctx.selectionMode === "single") { if (ctx.selection.has(id)) ctx.onSelectionChange(new Set()); else ctx.onSelectionChange(new Set([id])); return; } const next = new Set(ctx.selection); if (next.has(id)) { next.delete(id); ctx.selectionPivotRef.current = null; } else { next.add(id); ctx.selectionPivotRef.current = id; } ctx.onSelectionChange(next); }