hightable
Version:
A dynamic windowed scrolling table component for react
61 lines (60 loc) • 1.79 kB
TypeScript
/**
* A selection is modelled as an array of ordered and non-overlapping ranges.
* The ranges are separated, ie. the end of one range is strictly less than the start of the next range.
*/
interface Range {
start: number;
end: number;
}
export type Ranges = Range[];
export interface Selection {
ranges: Ranges;
anchor?: number;
}
export declare function getDefaultSelection(): Selection;
export declare function isValidIndex(index: number): boolean;
export declare function isValidRange(range: Range): boolean;
export declare function areValidRanges(ranges: Ranges): boolean;
export declare function isSelected({ ranges, index }: {
ranges: Ranges;
index: number;
}): boolean;
export declare function selectRange({ ranges, range }: {
ranges: Ranges;
range: Range;
}): Ranges;
export declare function selectIndex({ ranges, index }: {
ranges: Ranges;
index: number;
}): Ranges;
export declare function unselectIndex({ ranges, index }: {
ranges: Ranges;
index: number;
}): Ranges;
export declare function unselectRange({ ranges, range }: {
ranges: Ranges;
range: Range;
}): Ranges;
export declare function toggleIndex({ ranges, index }: {
ranges: Ranges;
index: number;
}): Ranges;
/**
* Toggle the selection state of a single index.
*
* The anchor is updated to the index.
*
* @param {Object} params
* @param {Selection} params.selection - The current selection state.
* @param {number} params.index - The index to toggle.
*
* @returns {Selection} The new selection state.
*/
export declare function toggleIndexInSelection({ selection, index }: {
selection: Selection;
index: number;
}): Selection;
export declare function countSelectedRows({ selection }: {
selection: Selection;
}): number;
export {};