fix: use asChild in drawer components

This commit is contained in:
p-sw 2024-06-14 22:54:32 +09:00
parent 5254a49ebe
commit e15fe48ec8

View File

@ -404,8 +404,11 @@ const DrawerHeader = forwardRef<HTMLDivElement, DrawerHeaderProps>(
const [variantProps, restPropsCompressed] = const [variantProps, restPropsCompressed] =
resolveDrawerHeaderVariantProps(props); resolveDrawerHeaderVariantProps(props);
const { asChild, ...restPropsExtracted } = restPropsCompressed; const { asChild, ...restPropsExtracted } = restPropsCompressed;
const Comp = asChild ? Slot : "div";
return ( return (
<div <Comp
{...restPropsExtracted} {...restPropsExtracted}
className={drawerHeaderVariant(variantProps)} className={drawerHeaderVariant(variantProps)}
ref={ref} ref={ref}
@ -429,8 +432,11 @@ const DrawerBody = forwardRef<HTMLDivElement, DrawerBodyProps>((props, ref) => {
const [variantProps, restPropsCompressed] = const [variantProps, restPropsCompressed] =
resolveDrawerBodyVariantProps(props); resolveDrawerBodyVariantProps(props);
const { asChild, ...restPropsExtracted } = restPropsCompressed; const { asChild, ...restPropsExtracted } = restPropsCompressed;
const Comp = asChild ? Slot : "div";
return ( return (
<div <Comp
{...restPropsExtracted} {...restPropsExtracted}
className={drawerBodyVariant(variantProps)} className={drawerBodyVariant(variantProps)}
ref={ref} ref={ref}
@ -454,8 +460,11 @@ const DrawerFooter = forwardRef<HTMLDivElement, DrawerFooterProps>(
const [variantProps, restPropsCompressed] = const [variantProps, restPropsCompressed] =
resolveDrawerFooterVariantProps(props); resolveDrawerFooterVariantProps(props);
const { asChild, ...restPropsExtracted } = restPropsCompressed; const { asChild, ...restPropsExtracted } = restPropsCompressed;
const Comp = asChild ? Slot : "div";
return ( return (
<div <Comp
{...restPropsExtracted} {...restPropsExtracted}
className={drawerFooterVariant(variantProps)} className={drawerFooterVariant(variantProps)}
ref={ref} ref={ref}