{"size": 653, "ext": "js", "max_stars_repo_path": "src/context-menu/use-create-context-menu-for-mouse-event.js", "max_stars_repo_name": "generativefm/web-ui", "max_stars_repo_stars_event_min_datetime": "2021-05-20T00:33:21.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-13T04:45:20.000Z", "max_issues_repo_path": "src/context-menu/use-create-context-menu-for-mouse-event.js", "max_issues_repo_name": "generative-fm/web-ui", "max_issues_repo_issues_event_min_datetime": "2021-11-29T04:02:38.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-21T19:01:42.000Z", "max_forks_repo_path": "src/context-menu/use-create-context-menu-for-mouse-event.js", "max_forks_repo_name": "generative-fm/web-ui", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 28.3913043478, "max_line_length": 61, "alphanum_fraction": 0.7059724349}
import { useCallback } from 'react';
import useCreateContextMenu from './use-create-context-menu';

const useCreateContextMenuForMouseEvent = (content) => {
  const createContextMenu = useCreateContextMenu();

  const createContextMenuForMouseEvent = useCallback(
    (event) => {
      event.preventDefault();
      event.stopPropagation();
      const { clientX, clientY } = event;
      const x = clientX + window.scrollX;
      const y = clientY + window.scrollY;
      createContextMenu({ x, y, content });
    },
    [createContextMenu, content]
  );

  return createContextMenuForMouseEvent;
};

export default useCreateContextMenuForMouseEvent;
