{"version":3,"file":"MenuSubDropdown.mjs","names":["classes"],"sources":["../../../../src/components/Menu/MenuSubDropdown/MenuSubDropdown.tsx"],"sourcesContent":["import { use, useRef } from 'react';\nimport { useMergedRef } from '@mantine/hooks';\nimport {\n  BoxProps,\n  CompoundStylesApiProps,\n  createEventHandler,\n  ElementProps,\n  factory,\n  Factory,\n  useProps,\n} from '../../../core';\nimport { Popover } from '../../Popover';\nimport { useMenuContext } from '../Menu.context';\nimport { SubMenuContext } from '../MenuSub/MenuSub.context';\nimport { useMenuTypeAhead } from '../use-menu-type-ahead';\nimport classes from '../Menu.module.css';\n\nexport type MenuSubDropdownStylesNames = 'dropdown';\n\nexport interface MenuSubDropdownProps\n  extends BoxProps, CompoundStylesApiProps<MenuSubDropdownFactory>, ElementProps<'div'> {}\n\nexport type MenuSubDropdownFactory = Factory<{\n  props: MenuSubDropdownProps;\n  ref: HTMLDivElement;\n  stylesNames: MenuSubDropdownStylesNames;\n  compound: true;\n}>;\n\nexport const MenuSubDropdown = factory<MenuSubDropdownFactory>((props) => {\n  const {\n    classNames,\n    className,\n    style,\n    styles,\n    vars,\n    onMouseEnter,\n    onMouseLeave,\n    onPointerEnter,\n    onPointerLeave,\n    onKeyDown,\n    children,\n    ref,\n    ...others\n  } = useProps('MenuSubDropdown', null, props);\n\n  const wrapperRef = useRef<HTMLDivElement>(null);\n  const ctx = useMenuContext();\n  const subCtx = use(SubMenuContext);\n\n  const typeAhead = useMenuTypeAhead({\n    enabled: !ctx.hasSearch,\n    opened: subCtx?.opened ?? false,\n    getDropdown: () => wrapperRef.current,\n  });\n\n  const handleKeyDown = createEventHandler<any>(onKeyDown, (event) => {\n    typeAhead(event);\n    if (\n      !event.ctrlKey &&\n      !event.metaKey &&\n      !event.altKey &&\n      event.key.length === 1 &&\n      event.key !== ' '\n    ) {\n      event.stopPropagation();\n    }\n  });\n\n  const floatingProps = subCtx?.getFloatingProps({\n    onMouseEnter,\n    onMouseLeave,\n    onPointerEnter,\n    onPointerLeave,\n  });\n\n  return (\n    <Popover.Dropdown\n      {...others}\n      {...floatingProps}\n      role=\"menu\"\n      aria-orientation=\"vertical\"\n      ref={useMergedRef(ref, wrapperRef, subCtx?.setFloating)}\n      {...ctx.getStyles('dropdown', {\n        className,\n        style,\n        styles,\n        classNames,\n        withStaticClass: false,\n      })}\n      tabIndex={-1}\n      data-menu-dropdown\n      onKeyDown={handleKeyDown}\n    >\n      {children}\n    </Popover.Dropdown>\n  );\n});\n\nMenuSubDropdown.classes = classes;\nMenuSubDropdown.displayName = '@mantine/core/MenuSubDropdown';\n"],"mappings":";;;;;;;;;;;;;AA6BA,MAAa,kBAAkB,SAAiC,UAAU;CACxE,MAAM,EACJ,YACA,WACA,OACA,QACA,MACA,cACA,cACA,gBACA,gBACA,WACA,UACA,KACA,GAAG,WACD,SAAS,mBAAmB,MAAM,KAAK;CAE3C,MAAM,aAAa,OAAuB,IAAI;CAC9C,MAAM,MAAM,eAAe;CAC3B,MAAM,SAAS,IAAI,cAAc;CAEjC,MAAM,YAAY,iBAAiB;EACjC,SAAS,CAAC,IAAI;EACd,QAAQ,QAAQ,UAAU;EAC1B,mBAAmB,WAAW;CAChC,CAAC;CAED,MAAM,gBAAgB,mBAAwB,YAAY,UAAU;EAClE,UAAU,KAAK;EACf,IACE,CAAC,MAAM,WACP,CAAC,MAAM,WACP,CAAC,MAAM,UACP,MAAM,IAAI,WAAW,KACrB,MAAM,QAAQ,KAEd,MAAM,gBAAgB;CAE1B,CAAC;CAED,MAAM,gBAAgB,QAAQ,iBAAiB;EAC7C;EACA;EACA;EACA;CACF,CAAC;CAED,OACE,oBAAC,QAAQ,UAAT;EACE,GAAI;EACJ,GAAI;EACJ,MAAK;EACL,oBAAiB;EACjB,KAAK,aAAa,KAAK,YAAY,QAAQ,WAAW;EACtD,GAAI,IAAI,UAAU,YAAY;GAC5B;GACA;GACA;GACA;GACA,iBAAiB;EACnB,CAAC;EACD,UAAU;EACV,sBAAA;EACA,WAAW;EAEV;CACe,CAAA;AAEtB,CAAC;AAED,gBAAgB,UAAUA;AAC1B,gBAAgB,cAAc"}