Skip to content

Commit

Permalink
Merge pull request #274 from EmaSuriano/bump-deps
Browse files Browse the repository at this point in the history
feat: bump deps
  • Loading branch information
EmaSuriano authored Mar 15, 2021
2 parents 5c437e5 + 7c05e0e commit d1428c3
Show file tree
Hide file tree
Showing 5 changed files with 1,905 additions and 3,369 deletions.
5 changes: 2 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
"prettier"
],
"plugins": ["react", "@typescript-eslint", "prettier"],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off"
"@typescript-eslint/explicit-module-boundary-types": "off"
},
"settings": {
"react": {
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,22 @@
"@types/jest": "^26.0.20",
"@types/mousetrap": "^1.6.3",
"@types/node": "^14.0.6",
"@types/react": "^16.9.25",
"@typescript-eslint/eslint-plugin": "^2.26.0",
"@typescript-eslint/parser": "^2.26.0",
"@types/react": "^17.0.3",
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"babel-jest": "^26.6.3",
"babel-loader": "^8.1.0",
"babel-preset-react": "^6.24.1",
"babel-preset-react-app": "^10.0.0",
"eslint": "^6.0.0",
"eslint-config-prettier": "^6.10.1",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.14.2",
"prettier": "^2.0.1",
"react": "^16.13.1",
"prettier-eslint": "^12.0.0",
"react": "^17.0.1",
"react-docgen-typescript-loader": "^3.7.1",
"react-dom": "^16.7.0",
"react-dom": "^17.0.1",
"react-test-renderer": "^17.0.1",
"typeface-roboto": "^1.1.13",
"typescript": "^4.0.2"
Expand Down
11 changes: 7 additions & 4 deletions src/Hotkey/Hotkey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function usePrevious<T>(value: T) {
});
return ref.current;
}

/**
* Component responsible for positioning the tooltip in the application and calling the action
*/
Expand All @@ -30,8 +31,7 @@ const Hotkey = ({ disabled, children, combination, onPress }: Props) => {
HotKeyContext,
);

// const [currentCombination, setCurrentCombination] = useState(combination);
const elementRef = useRef<Element>();
const elementRef = useRef<HTMLElement>();
const previousCombination = usePrevious(combination);

const onPressHotkey = (evt: Event) => {
Expand All @@ -40,13 +40,16 @@ const Hotkey = ({ disabled, children, combination, onPress }: Props) => {
if (typeof onPress === 'function') return onPress(evt);

if (elementRef && elementRef.current) {
if (typeof (elementRef.current as any)[onPress] !== 'function') {
const onPressCb =
elementRef.current[onPress as keyof GlobalEventHandlers];

if (typeof onPressCb !== 'function') {
throw new Error(
`ERROR: The method of ${onPress} is not present in the DOMNode of the child, please check render.`,
);
}

((elementRef.current as any)[onPress] as Function)(evt);
(onPressCb as (evt: Event) => void)(evt);
}
};

Expand Down
4 changes: 4 additions & 0 deletions src/utils/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@ export const bindHoldCombination = (
) => {
mousetrap.bindGlobal(combination, cb(true), 'keydown');
mousetrap.bindGlobal(combination, cb(false), 'keyup');
return;
};

export const bindCombination = (combination: string, cb: Handler) => {
mousetrap.bindGlobal(combination, cb);
return;
};

export const unbindHoldCombination = (combination: string) => {
mousetrap.unbind(combination, 'keydown');
mousetrap.unbind(combination, 'keyup');
return;
};

export const unbindCombination = (combination: string) => {
mousetrap.unbind(combination);
return;
};
Loading

0 comments on commit d1428c3

Please sign in to comment.