@1771technologies/lytenyte-pro
Version:
Blazingly fast headless React data grid with 100s of features.
47 lines (46 loc) • 2.24 kB
TypeScript
import type { DataRect } from "../+types.js";
interface SplitCellSelectionRectArgs {
readonly rect: DataRect;
readonly colStartCount: number;
readonly colCenterCount: number;
readonly rowTopCount: number;
readonly rowCenterCount: number;
}
export interface DataRectSplit extends DataRect {
readonly isUnit: boolean;
readonly borderTop?: boolean;
readonly borderBottom?: boolean;
readonly borderStart?: boolean;
readonly borderEnd?: boolean;
}
/**
* Splits a cell selection rectangle into multiple rectangles when it crosses specified boundary regions.
* This is useful for handling selections that span across different grid sections (e.g., fixed columns/rows,
* scrollable areas).
*
* The splitting process happens in two phases:
* 1. Column-wise splitting: Splits rectangles that cross column section boundaries
* 2. Row-wise splitting: Further splits the resulting rectangles if they cross row section boundaries
*
* Splitting does not support full width rows. It is assumed that if full width rows are present then
* the cell selection will just be drawn over them
*
* @example
* // For a grid with 2 fixed start columns and 1 fixed top row:
* const splits = splitCellSelectionRect({
* rect: { columnStart: 0, columnEnd: 3, rowStart: 0, rowEnd: 2 },
* colStartCount: 2, // Number of fixed start columns
* colCenterCount: 10, // Number of scrollable columns
* rowTopCount: 1, // Number of fixed top rows
* rowCenterCount: 50 // Number of scrollable rows
* });
*
* @param rect - The original cell selection rectangle to split
* @param colStartCount - Number of columns in the start (usually fixed) section
* @param colCenterCount - Number of columns in the center (usually scrollable) section
* @param rowTopCount - Number of rows in the top (usually fixed) section
* @param rowCenterCount - Number of rows in the center (usually scrollable) section
* @returns An array of split rectangles. If no splits were necessary, returns an array with just the original rectangle
*/
export declare function splitCellSelectionRect({ rect, colStartCount, colCenterCount, rowTopCount, rowCenterCount, }: SplitCellSelectionRectArgs): DataRectSplit[];
export {};