Refactor: add possibility to use different keys or combinations as a key code (#1554)

* feat(keys): support for combinations and multiple possibilites for one action
* refactor(globalKeyHandler): pass deps to useEffect
* refactor(examples): define key codes outside of the component
This commit is contained in:
Moritz Klack
2021-10-05 15:27:07 +02:00
committed by GitHub
parent 654c9e5235
commit be3b451d1d
5 changed files with 97 additions and 29 deletions
-11
View File
@@ -1,16 +1,5 @@
import { DraggableEvent } from 'react-draggable';
import { MouseEvent as ReactMouseEvent } from 'react';
import { Dimensions, XYPosition, NodeExtent } from '../types';
export const isInputDOMNode = (e: ReactMouseEvent | DraggableEvent | KeyboardEvent) => {
const target = e?.target as HTMLElement;
return (
['INPUT', 'SELECT', 'TEXTAREA', 'BUTTON'].includes(target?.nodeName) || target?.hasAttribute('contenteditable')
);
};
export const getDimensions = (node: HTMLDivElement): Dimensions => ({
width: node.offsetWidth,
height: node.offsetHeight,