office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
60 lines (59 loc) • 2.49 kB
TypeScript
import { IObjectWithKey, ISelection, SelectionMode } from './interfaces';
export interface ISelectionOptions {
onSelectionChanged?: () => void;
getKey?: (item: IObjectWithKey, index?: number) => string | number;
canSelectItem?: (item: IObjectWithKey, index?: number) => boolean;
selectionMode?: SelectionMode;
}
export declare class Selection implements ISelection {
count: number;
readonly mode: SelectionMode;
private _getKey;
private _canSelectItem;
private _changeEventSuppressionCount;
private _items;
private _selectedItems;
private _selectedIndices;
private _isAllSelected;
private _exemptedIndices;
private _exemptedCount;
private _keyToIndexMap;
private _anchoredIndex;
private _onSelectionChanged;
private _hasChanged;
private _unselectableIndices;
private _unselectableCount;
private _isModal;
constructor(options?: ISelectionOptions);
canSelectItem(item: IObjectWithKey, index?: number): boolean;
getKey(item: IObjectWithKey, index?: number): string;
setChangeEvents(isEnabled: boolean, suppressChange?: boolean): void;
isModal(): boolean;
setModal(isModal: boolean): void;
/**
* Selection needs the items, call this method to set them. If the set
* of items is the same, this will re-evaluate selection and index maps.
* Otherwise, shouldClear should be set to true, so that selection is
* cleared.
*/
setItems(items: IObjectWithKey[], shouldClear?: boolean): void;
getItems(): IObjectWithKey[];
getSelection(): IObjectWithKey[];
getSelectedCount(): number;
getSelectedIndices(): number[];
isRangeSelected(fromIndex: number, count: number): boolean;
isAllSelected(): boolean;
isKeySelected(key: string): boolean;
isIndexSelected(index: number): boolean;
setAllSelected(isAllSelected: boolean): void;
setKeySelected(key: string, isSelected: boolean, shouldAnchor: boolean): void;
setIndexSelected(index: number, isSelected: boolean, shouldAnchor: boolean): void;
selectToKey(key: string, clearSelection?: boolean): void;
selectToIndex(index: number, clearSelection?: boolean): void;
toggleAllSelected(): void;
toggleKeySelected(key: string): void;
toggleIndexSelected(index: number): void;
toggleRangeSelected(fromIndex: number, count: number): void;
private _updateCount();
private _change();
}