@uifabric/utilities
Version:
Fluent UI React utilities for building components.
56 lines (55 loc) • 1.9 kB
TypeScript
/**
* {@docCategory Selection}
*/
export interface IObjectWithKey {
key?: string | number;
}
export declare const SELECTION_CHANGE = "change";
export declare const SELECTION_ITEMS_CHANGE = "items-change";
/**
* {@docCategory Selection}
*/
export declare enum SelectionMode {
none = 0,
single = 1,
multiple = 2
}
/**
* {@docCategory Selection}
*/
export interface ISelection<TItem = IObjectWithKey> {
count: number;
mode: SelectionMode;
canSelectItem: (item: TItem, index?: number) => boolean;
setChangeEvents(isEnabled: boolean, suppressChange?: boolean): void;
setItems(items: TItem[], shouldClear: boolean): void;
getItems(): TItem[];
getItemIndex?(key: string): number;
getSelection(): TItem[];
getSelectedIndices(): number[];
getSelectedCount(): number;
isRangeSelected(fromIndex: number, count: number): boolean;
isAllSelected(): boolean;
isKeySelected(key: string): boolean;
isIndexSelected(index: number): boolean;
isModal?(): boolean;
setAllSelected(isAllSelected: boolean): void;
setKeySelected(key: string, isSelected: boolean, shouldAnchor: boolean): void;
setIndexSelected(index: number, isSelected: boolean, shouldAnchor: boolean): void;
setRangeSelected?(fromIndex: number, count: number, isSelected: boolean, shouldAnchor: boolean): void;
setModal?(isModal: boolean): void;
selectToKey(key: string, clearSelection?: boolean): void;
selectToIndex(index: number, clearSelection?: boolean): void;
selectToRange?(index: number, count: number, clearSelection?: boolean): void;
toggleAllSelected(): void;
toggleKeySelected(key: string): void;
toggleIndexSelected(index: number): void;
toggleRangeSelected(fromIndex: number, count: number): void;
}
/**
* {@docCategory Selection}
*/
export declare enum SelectionDirection {
horizontal = 0,
vertical = 1
}