import React from "react"; import { styled } from "../theme"; import { DrawerContext } from "./DrawerRoot"; const NAME = "DrawerCustomTrigger"; const StyledElement = styled("button", {}); type DrawerCustomTriggerProps = React.ComponentPropsWithoutRef< typeof StyledElement > & { as?: string }; export const DrawerCustomTrigger: React.FC = ({ children, ...props }) => { const context = React.useContext(DrawerContext); return ( { context.onOpenChange(true); }} onKeyPress={(event) => { if (event.key === "Enter" || event.key === " ") { event.preventDefault(); context.onOpenChange(true); } }} ref={context.triggerRef} role="button" tabIndex={0} {...props} > {children} ); }; DrawerCustomTrigger.displayName = NAME; export type { DrawerCustomTriggerProps };