Skip to content

Commit d436b84

Browse files
committed
Extend menu wrapper, add custom hooks
1 parent 22d66c1 commit d436b84

20 files changed

+2301
-32
lines changed

β€Ž.eslintrc.jsβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
extends: [
77
'eslint:recommended',
88
'plugin:react/recommended',
9+
'plugin:jsx-a11y/recommended',
910
'plugin:import/errors',
1011
'plugin:import/warnings',
1112
'plugin:@typescript-eslint/eslint-recommended',
@@ -24,7 +25,7 @@ module.exports = {
2425
ecmaVersion: 2018,
2526
sourceType: 'module',
2627
},
27-
plugins: ['react', 'import', '@typescript-eslint', 'prettier'],
28+
plugins: ['react', 'react-hooks', 'jsx-a11y', 'import', '@typescript-eslint', 'prettier'],
2829
rules: {
2930
quotes: ['warn', 'single', { allowTemplateLiterals: true }],
3031
'no-console': 'warn',

β€Ž.npmignoreβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.idea/
2+
demo/
3+
src/
4+
.eslintrc.js
5+
.prettierrc.js
6+
tsconfig.json

β€Žlib/ContextMenuWrapper.d.tsβ€Ž

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import React from 'react';
2-
interface ContextMenuWrapperProps {
2+
import { ContextMenuEvent } from './util';
3+
export interface ContextMenuWrapperProps {
34
id?: string;
5+
global?: boolean;
6+
render?: (event: ContextMenuEvent) => React.ElementType;
7+
onShow?: (event: ContextMenuEvent) => void;
8+
onHide?: (event: ContextMenuEvent) => void;
9+
hideOnSelfClick?: boolean;
10+
hideOnOutsideClick?: boolean;
11+
hideOnEscape?: boolean;
12+
hideOnScroll?: boolean;
13+
hideOnWindowResize?: boolean;
414
}
515
export declare const ContextMenuWrapper: React.FC<ContextMenuWrapperProps>;
6-
export {};

β€Žlib/ContextMenuWrapper.jsβ€Ž

Lines changed: 54 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žlib/ContextMenuWrapper.js.mapβ€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žlib/hooks.d.tsβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export interface ContextMenuHandlerObject {
2+
onContextMenu: (event: MouseEvent) => void;
3+
'data-contextmenu-id': string;
4+
'data-contextmenu-data-id'?: string;
5+
}
6+
export declare const useContextMenuHandlers: (menuId: string, data?: any) => ContextMenuHandlerObject;

β€Žlib/hooks.jsβ€Ž

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žlib/hooks.js.mapβ€Ž

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žlib/index.d.tsβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export { ContextMenuWrapper } from './ContextMenuWrapper';
1+
export { ContextMenuWrapper, ContextMenuWrapperProps } from './ContextMenuWrapper';
2+
export { useContextMenuHandlers } from './hooks';
3+
export { ContextMenuEvent } from './util';

β€Žlib/index.jsβ€Ž

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
Β (0)