1 | import * as React from "react";
|
2 | import { HotkeysDialog2Props } from "../../components/hotkeys/hotkeysDialog2";
|
3 | import { HotkeyConfig } from "../../hooks";
|
4 | interface HotkeysContextState {
|
5 | /** List of hotkeys accessible in the current scope, registered by currently mounted components, can be global or local. */
|
6 | hotkeys: HotkeyConfig[];
|
7 | /** Whether the global hotkeys dialog is open. */
|
8 | isDialogOpen: boolean;
|
9 | }
|
10 | declare type HotkeysAction = {
|
11 | type: "ADD_HOTKEYS" | "REMOVE_HOTKEYS";
|
12 | payload: HotkeyConfig[];
|
13 | } | {
|
14 | type: "CLOSE_DIALOG" | "OPEN_DIALOG";
|
15 | };
|
16 | export declare type HotkeysContextInstance = [HotkeysContextState, React.Dispatch<HotkeysAction>];
|
17 | /**
|
18 | * A React context used to register and deregister hotkeys as components are mounted and unmounted in an application.
|
19 | * Users should take care to make sure that only _one_ of these is instantiated and used within an application, especially
|
20 | * if using global hotkeys.
|
21 | *
|
22 | * You will likely not be using this HotkeysContext directly, except in cases where you need to get a direct handle on an
|
23 | * exisitng context instance for advanced use cases involving nested HotkeysProviders.
|
24 | *
|
25 | * For more information, see the [HotkeysProvider documentation](https://blueprintjs.com/docs/#core/context/hotkeys-provider).
|
26 | */
|
27 | export declare const HotkeysContext: React.Context<HotkeysContextInstance>;
|
28 | export interface HotkeysProviderProps {
|
29 | /** The component subtree which will have access to this hotkeys context. */
|
30 | children: React.ReactChild;
|
31 | /** Optional props to customize the rendered hotkeys dialog. */
|
32 | dialogProps?: Partial<Omit<HotkeysDialog2Props, "hotkeys">>;
|
33 | /** If provided, this dialog render function will be used in place of the default implementation. */
|
34 | renderDialog?: (state: HotkeysContextState, contextActions: {
|
35 | handleDialogClose: () => void;
|
36 | }) => JSX.Element;
|
37 | /** If provided, we will use this context instance instead of generating our own. */
|
38 | value?: HotkeysContextInstance;
|
39 | }
|
40 | /**
|
41 | * Hotkeys context provider, necessary for the `useHotkeys` hook.
|
42 | */
|
43 | export declare const HotkeysProvider: ({ children, dialogProps, renderDialog, value }: HotkeysProviderProps) => JSX.Element;
|
44 | export {};
|