UNPKG

@limetech/lime-elements

Version:
80 lines 2.46 kB
/** * Contains changes made to a selection */ export interface SelectionChangeSet { /** * Tells whether the items were selected or deselected */ selected: boolean; /** * Gets the affected items */ items: any[]; /** * Gets the indexes of the affected items */ indexes: number[]; } /** * Contains a set of selected data objects with methods for adding and removing * items to the selection by referring to them by their index/position. * Maintains a memory of the last toggled item which can be used to select or * deselect a range of items between the last toggled item and a given item. */ export declare class Selection { private getDataByIndex; private selectedItems; private lastToggledIndex; /** * Creates an instance of the Selection class. * The provided function `getDataByIndex` is used to provide data for the * selected items when selection is toggled by using the item index, * which can be the row position in a table. * * @param getDataByIndex - A function that returns the data at the given index */ constructor(getDataByIndex: (index: number) => any); /** * @returns The size of the selection */ get size(): number; /** * @returns The selected items */ get items(): any[]; /** * @param items - The selected items */ set items(items: any[]); /** * Checks whether the given item exist in the selection * * @param data - The data to look up * @returns `true` if the given data exist in the selection, otherwise `false` */ has(data: any): boolean; /** * Toggles the item at the given index in the selection * * @param index - The index of the item to toggle * @returns The changes made to the selection */ toggleSelection(index: number): SelectionChangeSet; /** * Toggles the items from the last toggled index to the given index in the selection. * The toggled items will be toggled as the item at the given index no matter * their current state in the selection. * Initially, when no last toggled index exist, this function behaves like * `toggleSelection`. * * @param index - The index of the item to toggle * @returns The changes made to the selection */ toggleSelectionFromLastIndex(index: number): SelectionChangeSet; /** * Clears the current selection and resets last toggled index */ clear(): void; private toggleRange; } //# sourceMappingURL=selection.d.ts.map