@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
28 lines (27 loc) • 1.33 kB
JavaScript
"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.context.mjs";
import { useContextMenuHandlers } from "../../../utils/Floating/use-context-menu-handlers.mjs";
import { cloneElement } from "react";
//#region packages/@mantine/core/src/components/Popover/PopoverContextMenu/PopoverContextMenu.tsx
function PopoverContextMenu(props) {
const { children, disabled, longPressDelay } = useProps("PopoverContextMenu", null, props);
const child = getSingleElementChild(children);
if (!child) throw new Error("Popover.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 = usePopoverContext();
return cloneElement(child, useContextMenuHandlers({
childProps: child.props,
disabled: disabled || ctx.disabled,
opened: ctx.opened,
longPressDelay,
setReference: ctx.reference,
open: () => {
if (!ctx.opened) ctx.onToggle();
}
}));
}
PopoverContextMenu.displayName = "@mantine/core/PopoverContextMenu";
//#endregion
export { PopoverContextMenu };
//# sourceMappingURL=PopoverContextMenu.mjs.map