Skip to content

Commit f10aa99

Browse files
committed
fix: Add file for constants
1 parent 0e385d6 commit f10aa99

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/components/ContextMenu.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import MenuItem from './MenuItem';
55
import Separator from './Separator';
66
import SubMenu from './SubMenu';
77
import { cloneChildren, getCursorPosition, validateMenuPosition } from '../utils';
8+
import { HIDE_ON_EVENTS } from '../constants';
89
import { Position } from '../types';
910

1011
export interface ContextMenuProps extends HTMLAttributes<HTMLDivElement> {
@@ -32,8 +33,6 @@ interface ContextMenuState {
3233
position: Position;
3334
}
3435

35-
const HIDE_ON_EVENTS: (keyof GlobalEventHandlersEventMap)[] = ['click', 'resize', 'scroll', 'contextmenu'];
36-
3736
const ContextMenu = ({
3837
triggerId,
3938
children,

src/components/SubMenu.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { useState, useEffect, useRef, HTMLAttributes } from 'react';
22
import cx from 'clsx';
33

4-
import { cloneChildren } from '../utils';
54
import { MenuItemExternalProps } from './MenuItem';
5+
import { BOTTOM_CLASS, CLOSE_DELAY, RIGHT_CLASS } from '../constants';
6+
import { cloneChildren } from '../utils';
67

78
export interface SubMenuProps extends HTMLAttributes<HTMLDivElement> {
89
/**
@@ -12,10 +13,6 @@ export interface SubMenuProps extends HTMLAttributes<HTMLDivElement> {
1213
disabled?: boolean;
1314
}
1415

15-
const CLOSE_DELAY = 150;
16-
const RIGHT_CLASS = 'react-context-menu__submenu-right';
17-
const BOTTOM_CLASS = 'react-context-menu__submenu-bottom';
18-
1916
const SubMenu = ({ label, children, className, disabled = false, ...rest }: SubMenuProps) => {
2017
const [active, setActive] = useState(false);
2118

src/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const CLOSE_DELAY = 150;
2+
export const RIGHT_CLASS = 'react-context-menu__submenu-right';
3+
export const BOTTOM_CLASS = 'react-context-menu__submenu-bottom';
4+
5+
export const HIDE_ON_EVENTS: (keyof GlobalEventHandlersEventMap)[] = ['click', 'resize', 'scroll', 'contextmenu'];

0 commit comments

Comments
 (0)