// This file is auto-generated by "@aria-ui/cli". Do not edit this file directly. import { registerMenuPopupElement, type MenuPopupElement, type MenuPopupProps as MenuPopupElementProps } from '@prosekit/web/menu'; import { createElement, forwardRef, useCallback, useRef, type ForwardedRef, type ForwardRefExoticComponent, type HTMLAttributes, type RefAttributes, useLayoutEffect } from 'react'; /** Props for the {@link MenuPopup} React component. */ export interface MenuPopupProps { /** * By default, the MenuPopup element will listen for keydown events. * You can pass a different element to listen for keydown events. * * @default null */ eventTarget?: MenuPopupElementProps['eventTarget']; } function MenuPopupComponent(props: MenuPopupProps, forwardedRef: ForwardedRef) { registerMenuPopupElement(); const elementRef = useRef(null); const { eventTarget: p0, ...restProps } = props; useLayoutEffect(() => { const element = elementRef.current as Record | null; if (!element) return; Object.assign(element, { eventTarget: p0 }); }); const mergedRef = useCallback( (element: MenuPopupElement | null) => { elementRef.current = element; if (typeof forwardedRef === 'function') { forwardedRef(element); } else if (forwardedRef) { forwardedRef.current = element; } }, [forwardedRef], ); return createElement('prosekit-menu-popup', { ...restProps, ref: mergedRef, suppressHydrationWarning: true }); } /** A React component that renders an `prosekit-menu-popup` custom element. */ export const MenuPopup: ForwardRefExoticComponent & RefAttributes> = /* @__PURE__ */ forwardRef(MenuPopupComponent);