mm
This commit is contained in:
@@ -1,25 +1,24 @@
|
||||
import type { ComponentPropsWithoutRef } from "react";
|
||||
|
||||
import { useMenuFloatingContext } from "./use-menu-floating-context";
|
||||
import { Slot } from "../../utils/slot";
|
||||
import { MenuTriggerContext } from "./use-menu-trigger-context";
|
||||
import type { CommonProps } from "../../utils/common-props";
|
||||
import { containerRecipe } from "../../styles/recipes/container-recipe";
|
||||
|
||||
export type MenuTriggerProps = ComponentPropsWithoutRef<"div">;
|
||||
export type MenuTriggerProps = CommonProps;
|
||||
|
||||
export const MenuTrigger = (props: MenuTriggerProps) => {
|
||||
const { children } = props;
|
||||
|
||||
const menuFloatingContext = useMenuFloatingContext();
|
||||
const { refs, setIsOpen, getReferenceProps } = menuFloatingContext!;
|
||||
const { refs, getReferenceProps } = useMenuFloatingContext()!;
|
||||
|
||||
return (
|
||||
<MenuTriggerContext.Provider value={{ isTrigger: true }}>
|
||||
<Slot className={"reset"} ref={refs.setReference} {...getReferenceProps(
|
||||
{ onClick: () => { setIsOpen(true) } }
|
||||
)}>
|
||||
<Slot
|
||||
ref={refs.setReference}
|
||||
{...getReferenceProps()}
|
||||
>
|
||||
{children}
|
||||
</Slot>
|
||||
</MenuTriggerContext.Provider>
|
||||
)
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user