UNPKG

right-angled

Version:

Lightweight and easy to use angular data grids. Integrates with your markup and styles rather than generating its own.

179 lines 9.95 kB
import { RTSelectionService } from './selection.service'; import * as i0 from "@angular/core"; /** * Used by {@link SelectionEventsHelper} to determine which key was pressed on keyboard. */ export declare enum KeyCodes { Tab = 9, Enter = 13, Shift = 16, Ctrl = 17, Alt = 18, Esc = 27, ArrowLeft = 37, ArrowUp = 38, ArrowRight = 39, ArrowDown = 40, A = 65 } /** * Used by {@link SelectionEventsHelper} to determine which mouse button is pressed. */ export declare enum MouseButtons { None = 0, Left = 1, Middle = 2, Right = 3 } /** * Helper class that can be used by application-defined UI components for handling keyboard and mouse interaction with component. * * Implements selection model that is similar to Excel or Google Sheets. Concrete handled patterns you can see in concrete methods documentation. * * This implementation doesn't use any browser specific objects such as events and doesn't use any browser API. */ export declare class RTSelectionEventsHelper { preventEventsDefaults: boolean; stopEventsPropagation: boolean; /** * `true` for shifting to next/previous item in list of items by `Left Arrow`/`Right Arrow` keys instead of `Arrow Up`/`Arrow Down` keys. */ horizontal: boolean; /** * `true` to make possible to pick several items in list of items (by clicking range of items with pressed `Shift` key, for example). */ multiple: boolean; /** * If `true`, then next item selection doesn't clear selection of previously selected items. The only way to clean selection is second click on previously selected element. * This can be used to implement accordion-like behavior in application-defined UI component. */ toggleOnly: boolean; /** * Instance of {@link RTSelectionService} to perform actual selection. */ selectionService: RTSelectionService; /** * @param selectionConfig Used for declarative interaction with application-defined UI component and access to it's selection settings * as well as {@link RTSelectionService} implementation, that was configured on it. */ constructor(selectionService: RTSelectionService); /** * Common handler for keyboard events. Depending on specified parameters calls {@link onNextKey}, {@link onPreviousKey}, {@link trySelectPreviousItem}, {@link trySelectNextItem} or {@link trySelectAll} handler. * @param ctrlKeyPressed - `true` if `Ctrl` key was pressed. * @param shiftKeyPressed - `true` if `Shift` key was pressed. * @param keyCode - specifies code of key that was pressed. This method can handle next keys: {@link KeyCodes.ArrowUp}, {@link KeyCodes.ArrowLeft}, {@link KeyCodes.ArrowDown}, {@link KeyCodes.ArrowRight}, * {@link KeyCodes.Tab} and {@link KeyCodes.A}. * @returns `true` if any of executed commands was applied. */ keyboardHandler(ctrlKeyPressed: boolean, shiftKeyPressed: boolean, keyCode: KeyCodes): boolean; /** * Common handler for mouse events. * @param ctrlKeyPressed - `true` if `Ctrl` key was pressed. * @param shiftKeyPressed - `true` if `Shift` key was pressed. * @param mouseButton specifies which mouse button was pressed. * @param itemIndex index of clicked element in {@link RTSelectionService.items} collection. * @returns `true` if any of executed commands was applied. */ mouseHandler(ctrlKeyPressed: boolean, shiftKeyPressed: boolean, mouseButton: MouseButtons, itemIndex: number): boolean; /** * Tries to select all items if `Ctrl+A` combination was pressed. * @param ctrlKeyPressed - `true` if `Ctrl` key was pressed. * @param shiftKeyPressed - `true` if `Shift` key was pressed (with pressed `Shift` this command would not be applied). * @returns `true` if command was applied. */ trySelectAll(ctrlPressed: boolean, shiftPressed: boolean): boolean; /** * Tries to select previous item when `Arrow Up` was pressed (`Arrow Left` if {@link SelectionAreaConfig.horizontal} is `true`). * * If `Shift` was pressed and {@link SelectionAreaConfig.multiple} is 'true' then elements selected before stays selected. * @param shiftKeyPressed - `true` if `Shift` key was pressed. * @returns `true` if command was applied. */ trySelectPreviousItem(shiftKeyPressed: boolean): boolean; /** * Tries to select next item when `Arrow Down` was pressed (`Right Arrow` if {@link SelectionAreaConfig.horizontal} is `true`). * * If `Shift` was pressed and {@link SelectionAreaConfig.multiple} is 'true' then elements selected before stays selected. * @param shiftKeyPressed - `true` if `Shift` key was pressed. * @returns `true` if command was applied. */ trySelectNextItem(shiftKeyPressed: boolean): boolean; /** * Tries to deselect last selected element when `Shift+Arrow Up` combination pressed (`Shift+Arrow Left` if {@link SelectionAreaConfig.horizontal} is `true`). * @param shiftKeyPressed - `true` if `Shift` key was pressed. * @returns `true` if command was applied. */ tryDeselectLastItemInRange(shiftKeyPressed: boolean): boolean; /** * Tries to deselect last selected element when `Shift+Arrow Down` combination pressed (`Shift+Arrow Right` if {@link SelectionAreaConfig.horizontal} is `true`). * @param shiftKeyPressed - `true` if `Shift` key was pressed. * @returns `true` if command was applied. */ tryDeselectLastItemInReversedRange(shiftKeyPressed: boolean): boolean; /** * Tries to select element that is previous to the last processed element and last processed element was deselected. * @param ctrlKeyPressed - `true` if `Ctrl` key was pressed. * @param shiftKeyPressed - `true` if `Shift` key was pressed. * @returns `true` if command was applied. */ tryBuildRangeWithPreviousItemWhenLastItemWasDeselected(ctrlKeyPressed: boolean, shiftKeyPressed: boolean): boolean; /** * Tries to select element that is next to the last processed element and last processed element was deselected. * @param ctrlKeyPressed - `true` if `Ctrl` key was pressed. * @param shiftKeyPressed - `true` if `Shift` key was pressed. * @returns `true` if command was applied. */ tryBuildRangeWithNextItemWhenLastItemWasDeselected(ctrlKeyPressed: boolean, shiftKeyPressed: boolean): boolean; /** * Selects first element in {@link RTSelectionService.items} if nothing was selected before. * @returns `true` if command was applied. */ tryInitialSelectionOfFirstItem(): boolean; /** * Tries to select all elements starting from last selected element up to first element in {@link RTSelectionService.items} when `Ctrl+Shift+Arrow Up` combination was pressed * (`Ctrl+Shift+Arrow Left` if {@link SelectionAreaConfig.horizontal} is `true`). * @param ctrlKeyPressed - `true` if `Ctrl` key was pressed. * @param shiftKeyPressed - `true` if `Shift` key was pressed. * @returns `true` if command was applied. */ trySelectAllItemsUpToFirst(ctrlKeyPressed: boolean, shiftKeyPressed: boolean): boolean; /** * Tries to select all elements starting from last selected element up to last element in {@link RTSelectionService.items} when `Ctrl+Shift+Arrow Down` combination was pressed * (`Ctrl+Shift+Arrow Right` if {@link SelectionAreaConfig.horizontal} is `true`). * @param ctrlKeyPressed - `true` if `Ctrl` key was pressed. * @param shiftKeyPressed - `true` if `Shift` key was pressed. * @returns `true` if command was applied. */ trySelectAllItemsUpToLast(ctrlKeyPressed: boolean, shiftKeyPressed: boolean): boolean; /** * Tries to select first element in {@link RTSelectionService.items} when `Ctrl+Arrow Up` combination was pressed (`Ctrl+Arrow Left` if {@link SelectionAreaConfig.horizontal} is `true`). * @param ctrlKeyPressed - `true` if `Ctrl` key was pressed. * @param shiftKeyPressed - `true` if `Shift` key was pressed (with pressed `Shift` this command would not be applied). * @returns `true` if command was applied. */ trySelectFirstItem(ctrlKeyPressed: boolean, shiftKeyPressed: boolean): boolean; /** * Tries to select last element in {@link RTSelectionService.items} when `Ctrl+Arrow Down` combination was pressed (`Ctrl+Arrow Right` if {@link SelectionAreaConfig.horizontal} is `true`). * @param ctrlKeyPressed - `true` if `Ctrl` key was pressed. * @param shiftKeyPressed - `true` if `Shift` key was pressed (with pressed `Shift` this command would not be applied). * @returns `true` if command was applied. */ trySelectLastItem(ctrlKeyPressed: boolean, shiftKeyPressed: boolean): boolean; /** * Common handler for `Arrow Up` key (`Arrow Left` if {@link SelectionAreaConfig.horizontal} is `true`). Calls applicable handlers one by one until any returns `true`. * @param ctrlKeyPressed - `true` if `Ctrl` key was pressed. * @param shiftKeyPressed - `true` if `Shift` key was pressed. * @returns `true` if any of executed commands was applied. */ onPreviousKey(ctrlKeyPressed: boolean, shiftKeyPressed: boolean): boolean; /** * Common handler for `Arrow Down` key (`Arrow Right` if {@link SelectionAreaConfig.horizontal} is `true`). Calls applicable handlers one by one until any returns `true`. * @param ctrlKeyPressed - `true` if `Ctrl` key was pressed. * @param shiftKeyPressed - `true` if `Shift` key was pressed. * @returns `true` if any of executed commands was applied. */ onNextKey(ctrlKeyPressed: boolean, shiftKeyPressed: boolean): boolean; static ɵfac: i0.ɵɵFactoryDeclaration<RTSelectionEventsHelper, never>; static ɵprov: i0.ɵɵInjectableDeclaration<RTSelectionEventsHelper>; } //# sourceMappingURL=selection-events-helper.d.ts.map