import classNames from "classnames" ; import * as React from "react" ; import { polyfill } from "react-lifecycles-compat" ; import { AbstractPureComponent2 , Classes , DISPLAYNAME_PREFIX , Props } from "../../common" ; import { HotkeyConfig } from "../../hooks" ; import { KeyCombo } from "./keyCombo" ; export type IHotkeyProps = Props & HotkeyConfig ; @ polyfill export class Hotkey extends AbstractPureComponent2 < IHotkeyProps > { public static displayName = `${ DISPLAYNAME_PREFIX }.Hotkey` ; public static defaultProps = { allowInInput : false , disabled : false , global : false , preventDefault : false , stopPropagation : false , } ; public render ( ) { const { label , className , ... spreadableProps } = this . props ; const rootClasses = classNames ( Classes . HOTKEY , className ) ; return ( < div className = { rootClasses } > < div className = { Classes . HOTKEY_LABEL } > { label } < /div> < KeyCombo { ... spreadableProps } /> < /div>); } protected validateProps ( props ) { if ( props . global !== true && props . group == null ) { console . error ( "non-global <Hotkey>s must define a group" ) ; } } }