25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
import { orderedListRangeIndices, orderedListSelectionIntent } from "../selection/orderedListSelection";
/** Rows are identified by the server session id, matching the process list grid. */
export interface ProcessListSelectionRow {
id: string | number;
}
export interface ProcessListSelectionState {
selected: Set<string | number>;
anchorId: string | number | null;
}
/**
* Applies a row checkbox click to the current selection.
*
* A plain click toggles the clicked row and moves the anchor; Shift+click applies
* the clicked row's next state to every selectable row between the anchor and the
* clicked row, so long session lists can be selected in one gesture. Rows outside
* the range keep their current state, and an unknown/stale anchor degrades to a
* plain toggle instead of selecting an unexpected range.
*
* The next state is derived from the current selection because the grid binds
* `:checked` without cancelling the native checkbox activation.
*/
export function processListSelectionAfterClick(rows: ProcessListSelectionRow[], state: ProcessListSelectionState, id: string | number, event: Pick<MouseEvent, "shiftKey" | "metaKey" | "ctrlKey">): ProcessListSelectionState {
const targetIndex = rows.findIndex((row) => row.id === id);
if (targetIndex < 0) return state;
const checked = !state.selected.has(id);
const anchorIndex = state.anchorId === null ? -1 : rows.findIndex((row) => row.id === state.anchorId);
if (orderedListSelectionIntent(event) === "range" && anchorIndex >= 0) {
const selected = new Set(state.selected);
for (const index of orderedListRangeIndices(rows.length, anchorIndex, targetIndex)) {
const row = rows[index];
if (!row) continue;
if (checked) selected.add(row.id);
else selected.delete(row.id);
}
return { selected, anchorId: state.anchorId };
}
const selected = new Set(state.selected);
if (checked) selected.add(id);
else selected.delete(id);
return { selected, anchorId: id };
}