import * as React from "react"; import type { DrawerItemOwnProps } from "./types"; import type { PolymorphicWithRef } from "../types"; import BaseDrawerItem from "./BaseDrawerItem"; import { LabelTypography } from "../LabelTypography"; import { Icon } from "../Icon"; import { useEventListener } from "../hooks"; import rippleEffect from "../utils/events/rippleEffect"; type LabelProps = React.ComponentProps & { labelText?: string; }; type DrawerItemProps = PolymorphicWithRef< T, DrawerItemOwnProps >; type DrawerItemElement = ( props: DrawerItemProps ) => React.ReactElement>; const DrawerItem: DrawerItemElement = React.forwardRef( ( props: DrawerItemProps, innerRef: typeof props.ref ) => { const { component = "li", ...rest } = props; const itemRef = React.useRef(null); // forwarding the ref using imperative API React.useImperativeHandle(innerRef, () => itemRef.current); // useEventListener to add ripple effect useEventListener( "mousedown", (event) => rippleEffect(event, itemRef), itemRef ); return ; } ); export default Object.assign(DrawerItem, { Label: (props: LabelProps) => React.cloneElement(, props, [props.labelText]), Icon: Icon, });