UNPKG

@ctodev/cclibrary-typings

Version:

Library typings for use with CLARC INFINITY

140 lines (139 loc) 4.58 kB
import { Router } from '@angular/router'; import { Observable, Subject } from 'rxjs'; import { TccSingleton } from '../../models/tcc-singleton.model'; import { TccShortcutHintsService, TccShortcutService } from '../tcc-shortcut-hints/tcc-shortcut-hints.service'; export declare namespace TccKeypressServiceNamespace { enum keys { ctrl = "ctrl",// strg alt = "alt", altGraph = "altgraph",// alt gr shift = "shift", capslock = "capslock", pagedown = "pagedown", pageup = "pageup", delete = "delete",// entfernen insert = "insert",// einfügen end = "end", home = "home",// pos1 enter = "enter", backspace = "backspace", numpadEnter = "numpadenter", numpadAdd = "numpadAdd", numpadSubtract = "numpadSubtract", numpadMultiply = "numpadMultiply", numpad0 = "numpad0", numpad1 = "numpad1", numpad2 = "numpad2", numpad3 = "numpad3", numpad4 = "numpad4", numpad5 = "numpad5", numpad6 = "numpad6", numpad7 = "numpad7", numpad8 = "numpad8", numpad9 = "numpad9", arrowUp = "arrowup", arrowDown = "arrowdown", arrowLeft = "arrowleft", arrowRight = "arrowright", F1 = "f1", F2 = "f2", F3 = "f3", F4 = "f4", F5 = "f5", F6 = "f6", F7 = "f7", F8 = "f8", F9 = "f9", F10 = "f10", F11 = "f11", F12 = "f12" } const keyTranslations: Readonly<{ ctrl: string; alt: string; altgraph: string; shift: string; capslock: string; pagedown: string; pageup: string; delete: string; insert: string; end: string; home: string; enter: string; backspace: string; numpadenter: string; numpadAdd: string; numpadSubtract: string; numpadMultiply: string; numpad0: string; numpad1: string; numpad2: string; numpad3: string; numpad4: string; numpad5: string; numpad6: string; numpad7: string; numpad8: string; numpad9: string; arrowup: string; arrowdown: string; arrowleft: string; arrowright: string; f1: string; f2: string; f3: string; f4: string; f5: string; f6: string; f7: string; f8: string; f9: string; f10: string; f11: string; f12: string; }>; interface options { stopPropagation?: boolean; stopImmediatePropagation?: boolean; preventDefault?: boolean; } interface shortcutHint { title: string; description: string; advanced?: boolean; standardOptions?: TccShortcutService.standardOptions[]; } } export declare class TccKeypressService implements TccSingleton { private shortcutHintsService; private keypressServiceUnsubscribe; obs: Subject<{ key: string[]; event: KeyboardEvent; }>; constructor(router: Router, shortcutHintsService: TccShortcutHintsService); init(): void; reset(): void; /** * returns the Observable * * @param {Array<string>} key the keys, on which the Observable should be triggered. Can contain ctrl, shift, alt (one or more of them) and ONE more key. Must be lower case. */ getExecObserver(key?: string[], options?: TccKeypressServiceNamespace.options): Observable<KeyboardEvent>; /** * takes keypressFunctionkeypressFunction and calls it every time key is pressed. Unsubscribes if route is changed or unsubscribeAll() is called. * * @param {(event: KeyboardEvent) => void} keypressFunction Function, that will be called * @param {Array<string>} key the keys, on which the Observable should be triggered. Can contain ctrl, shift, alt (one or more of them) and ONE more key. Must be lower case. * @param {string} description description shown in shortcut hints * @param {TccKeypressServiceNamespace.options>} options */ setKeypressFunction(keypressFunction: (event: KeyboardEvent) => void, keys: string[], shortcutHint: TccKeypressServiceNamespace.shortcutHint, options?: TccKeypressServiceNamespace.options): void; /** * unsubscribes all Subscriptions on the execObserver (no matter the component) */ unsubscribeAll(): void; private handleOptions; private normalizeOptions; }