MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / toggleSelection

Function toggleSelection

packages/core/src/widgets/table.ts:256–272  ·  view source on GitHub ↗

* Toggle selection of a single row.

(currentSelection: readonly string[], rowKey: string)

Source from the content-addressed store, hash-verified

254 * Toggle selection of a single row.
255 */
256function toggleSelection(currentSelection: readonly string[], rowKey: string): SelectionResult {
257 const isSelected = currentSelection.includes(rowKey);
258
259 if (isSelected) {
260 const newSelection = currentSelection.filter((k) => k !== rowKey);
261 return Object.freeze({
262 selection: Object.freeze(newSelection),
263 changed: true,
264 });
265 }
266
267 const newSelection = [...currentSelection, rowKey];
268 return Object.freeze({
269 selection: Object.freeze(newSelection),
270 changed: true,
271 });
272}
273
274/**
275 * Select all rows.

Callers 1

computeSelectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected