{"version":3,"file":"MenuContextMenu.cjs","names":["useProps","getSingleElementChild","useMenuContext","usePopoverContext","useContextMenuHandlers"],"sources":["../../../../src/components/Menu/MenuContextMenu/MenuContextMenu.tsx"],"sourcesContent":["import { cloneElement } from 'react';\nimport { getSingleElementChild, useProps } from '../../../core';\nimport { useContextMenuHandlers } from '../../../utils/Floating/use-context-menu-handlers';\nimport { usePopoverContext } from '../../Popover';\nimport { useMenuContext } from '../Menu.context';\n\nexport interface MenuContextMenuProps {\n  /** Element that opens the menu when right-clicked. Menu dropdown is positioned at the cursor. The trigger element must not call `event.preventDefault()` in its own `onContextMenu` handler, otherwise the native context menu is not suppressed. */\n  children: React.ReactNode;\n\n  /** If set, the right-click trigger is disabled and the browser's default context menu is shown */\n  disabled?: boolean;\n\n  /** Delay in ms before a touch long-press opens the dropdown on touch devices, `500` by default */\n  longPressDelay?: number;\n}\n\nexport function MenuContextMenu(props: MenuContextMenuProps) {\n  const { children, disabled, longPressDelay } = useProps('MenuContextMenu', null, props);\n\n  const child = getSingleElementChild(children);\n  if (!child) {\n    throw new Error(\n      'Menu.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported'\n    );\n  }\n\n  const ctx = useMenuContext();\n  const popoverCtx = usePopoverContext();\n\n  const handlers = useContextMenuHandlers({\n    childProps: child.props as any,\n    disabled: disabled || popoverCtx.disabled,\n    opened: ctx.opened,\n    longPressDelay,\n    setReference: popoverCtx.reference as unknown as (node: object) => void,\n    open: () => ctx.openDropdown(),\n  });\n\n  return cloneElement(child, handlers as any);\n}\n\nMenuContextMenu.displayName = '@mantine/core/MenuContextMenu';\n"],"mappings":";;;;;;;;AAiBA,SAAgB,gBAAgB,OAA6B;CAC3D,MAAM,EAAE,UAAU,UAAU,mBAAmBA,kBAAAA,SAAS,mBAAmB,MAAM,KAAK;CAEtF,MAAM,QAAQC,iCAAAA,sBAAsB,QAAQ;CAC5C,IAAI,CAAC,OACH,MAAM,IAAI,MACR,oKACF;CAGF,MAAM,MAAMC,qBAAAA,eAAe;CAC3B,MAAM,aAAaC,wBAAAA,kBAAkB;CAWrC,QAAA,GAAA,MAAA,aAAA,CAAoB,OATHC,kCAAAA,uBAAuB;EACtC,YAAY,MAAM;EAClB,UAAU,YAAY,WAAW;EACjC,QAAQ,IAAI;EACZ;EACA,cAAc,WAAW;EACzB,YAAY,IAAI,aAAa;CAC/B,CAEkC,CAAQ;AAC5C;AAEA,gBAAgB,cAAc"}