UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

28 lines (27 loc) 1.39 kB
"use client"; import { getSingleElementChild } from "../../../core/utils/get-single-element-child/get-single-element-child.mjs"; import { useProps } from "../../../core/MantineProvider/use-props/use-props.mjs"; import { usePopoverContext } from "../../Popover/Popover.context.mjs"; import { useContextMenuHandlers } from "../../../utils/Floating/use-context-menu-handlers.mjs"; import { useMenuContext } from "../Menu.context.mjs"; import { cloneElement } from "react"; //#region packages/@mantine/core/src/components/Menu/MenuContextMenu/MenuContextMenu.tsx function MenuContextMenu(props) { const { children, disabled, longPressDelay } = useProps("MenuContextMenu", null, props); const child = getSingleElementChild(children); if (!child) throw new Error("Menu.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported"); const ctx = useMenuContext(); const popoverCtx = usePopoverContext(); return cloneElement(child, useContextMenuHandlers({ childProps: child.props, disabled: disabled || popoverCtx.disabled, opened: ctx.opened, longPressDelay, setReference: popoverCtx.reference, open: () => ctx.openDropdown() })); } MenuContextMenu.displayName = "@mantine/core/MenuContextMenu"; //#endregion export { MenuContextMenu }; //# sourceMappingURL=MenuContextMenu.mjs.map