@uiw/react-amap-context-menu
Version:
地图图面一种特殊的信息窗体,即右键菜单。
31 lines (30 loc) • 1.04 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
/// <reference types="@uiw/react-amap-types" />
import React, { useImperativeHandle, Fragment } from 'react';
import { useContextMenu } from "./useContextMenu.js";
import Item from "./Item.js";
import { jsx as _jsx } from "react/jsx-runtime";
export * from "./useContextMenu.js";
export * from "./Item.js";
var ContextMenuCompound = /*#__PURE__*/React.forwardRef((props, ref) => {
var {
contextMenu
} = useContextMenu(props);
useImperativeHandle(ref, () => _extends({}, props, {
contextMenu
}));
var childs = React.Children.toArray(props.children);
return /*#__PURE__*/_jsx(Fragment, {
children: AMap && contextMenu && childs.map((child, key) => {
if (! /*#__PURE__*/React.isValidElement(child)) return null;
return /*#__PURE__*/React.cloneElement(child, _extends({}, child.props, {
AMap,
map: props.map,
contextMenu,
key
}));
})
});
});
export var ContextMenu = ContextMenuCompound;
ContextMenu.Item = Item;