UNPKG

@twilio/flex-ui

Version:

Twilio Flex UI

160 lines (159 loc) 5.45 kB
import { EventEmitter } from "eventemitter3"; import { orderedTaskList } from "./internal-flex-commons/src"; export { orderedTaskList }; /** * Keyboard shortcuts - including a key to be passed and the Keyboard Shortcut object * * @typedef {object} KeyboardShortcuts * @property {string} key The key to be associated with the keyboard shortcut * @property {KeyboardShortcut} shortcut The keyboard shortcut object * @memberof KeyboardShortcutManager */ export interface KeyboardShortcuts { [key: string]: KeyboardShortcut; } /** * Keyboard shortcut object containing the action, name and optional throttle * * @typedef {object} KeyboardShortcut * @property {Function} action The action which is triggered by the shortcut * @property {string} name The name of the shortcut which will be displayed in error messages if a shortcut does not work * @property {number} [throttle] The optional throttle time in ms which can be set to prevent the shortcut from being triggered again within the set amount of time. A notification will show if a shortcut is used repeatedly within the throttle limit time * @memberof KeyboardShortcutManager * @example * { * action: Flex.defaultActions.toggleActivityMenu, * name: "Toggle Activity Menu", * throttle: 100 * } */ export interface KeyboardShortcut { action: Function; name: string; throttle?: number; } export declare const logout: () => void; export declare const endSelectedTask: () => void; export declare const acceptTask: () => void; export declare const rejectTask: () => void; export declare const selectNextTask: () => void; export declare const selectPreviousTask: () => void; export declare const toggleActivityMenu: () => void; export declare const toggleHold: () => void; export declare const toggleMute: () => void; export declare const returnToCall: () => void; export declare const defaultActions: { logout: () => void; endSelectedTask: () => void; acceptTask: () => void; rejectTask: () => void; selectNextTask: () => void; selectPreviousTask: () => void; toggleActivityMenu: () => void; toggleHold: () => void; toggleMute: () => void; returnToCall: () => void; }; export declare const defaultKeyboardShortcuts: { 1: { action: () => void; name: string; throttle: number; }; L: { action: () => void; name: string; }; A: { action: () => void; name: string; }; R: { action: () => void; name: string; }; T: { action: () => void; name: string; }; Y: { action: () => void; name: string; }; S: { action: () => void; name: string; }; H: { action: () => void; name: string; }; M: { action: () => void; name: string; }; C: { action: () => void; name: string; }; }; /** * @alias KeyboardShortcutManager * @classdesc Keyboard shortcut manager which can be used to edit or disable Flex UI keyboard shortcuts. * @hideconstructor * @category Keyboard Shortcuts */ declare class KeyboardShortcutManagerImpl { keyboardShortcuts: KeyboardShortcuts; eventEmitter: undefined | InstanceType<typeof EventEmitter>; init(keyboardShortcuts: KeyboardShortcuts): void; private reportTelemetryEvent; /** * Add new keyboard shortcuts alongside the default shortcuts provided. * * @param {KeyboardShortcuts} newKeyboardShortcuts The object containing keyboard shortcuts to be added * @returns {void} * @example * Flex.KeyboardShortcutManager.addShortcuts({ * 5: { action: () => console.log("hello"), name: "Hello" }, * D: { action: toggleDialpad, name: "Toggle dialpad", throttle: 100 } * }); */ addShortcuts(newKeyboardShortcuts: KeyboardShortcuts): void; /** * Delete keyboard shortcuts from the default shortcuts provided. * * @param {Array<string>} keys An array containing one or more keys corresponding to the shortcuts to be deleted * @returns {void} * @example * Flex.KeyboardShortcutManager.deleteShortcuts(["S", "A", "1"]); */ deleteShortcuts(keys: string[]): void; /** * Remap a keyboard shortcut from the default key provided to another chosen key. This should be repeated for each shortcut which need to be remapped. * * @param {string} oldKey The letter of the key which the default shortcut corresponds to * @param {string} newKey The new key to assign to the shortcut * @param {KeyboardShortcut} [shortcut] An optional object to be passed if any modifications need to be made to the shortcut itself * @returns {void} * @example * Flex.KeyboardShortcutManager.remapShortcut("S", "K"); * Flex.KeyboardShortcutManager.remapShortcut("S", "K", { * action: Flex.defaultActions.toggleActivityMenu, * name: "Toggle Activity Menu", * throttle: 1000 * }); */ remapShortcut(oldKey: string, newKey: string, shortcut?: KeyboardShortcut): void; /** * Disable keyboard shortcuts entirely for Flex UI. * * @returns {void} * @example * Flex.KeyboardShortcutManager.disableShortcuts(); */ disableShortcuts(): void; private timeShortcutLastUsed; private keydownHandler; } export declare const KeyboardShortcutManager: KeyboardShortcutManagerImpl;