import React, {useContext, useEffect, useState} from 'react';
import PropTypes from 'prop-types';
import ls from './Menu.less';
import AuxWidget from "./AuxWidget";
import cx from 'classnames';
import Fa from './Fa';
import {UISystemContext} from "../../../web/app/cad/dom/components/UISystem";
import {useStream} from "../effects";
export default function Menu({children, x, y, orientationUp, centered, menuId, ...props}) {
return
{children}
;
}
export function MenuSeparator() {
return
}
export function MenuItem({icon, label, hotKey, style, disabled, onClick, children, ...props}) {
const {closeAllUpPopups} = useContext(UISystemContext);
if (hotKey) {
hotKey = hotKey.replace(/\s/g, '');
if (hotKey.length > 15) {
hotKey = null;
}
}
const clickHandler = disabled ? undefined : (e) => {
closeAllUpPopups();
onClick(e);
};
return e.stopPropagation()} style={style} onClick={clickHandler} {...props}>
{icon}
{label}
{hotKey && {hotKey}}
;
}
const ContextMenuContext = React.createContext(null);
export function ContextMenu(props) {
const [state, setState] = useState({
active: false
});
const {onCloseAll} = useContext(UISystemContext);
useEffect(() => onCloseAll.attach(close));
const onClick = e => {
e.preventDefault();
setState({
active: true,
x: e.clientX,
y: e.clientY
});
};
const close = () => {
setState({active: false})
};
return
{props.children}
{state.active && }
;
}
export function ContextMenuItem({onClick, ...props}) {
const closeMenu = useContext(ContextMenuContext);
return