feat: update component to latest

This commit is contained in:
p-sw 2024-06-15 04:56:30 +09:00
parent 0bf6367339
commit ab26ec1287

View File

@ -49,13 +49,15 @@ const DrawerRoot = ({ children, closeThreshold, opened }: DrawerRootProps) => {
opened: opened ?? DrawerContextInitial.opened, opened: opened ?? DrawerContextInitial.opened,
closeThreshold: closeThreshold ?? DrawerContextInitial.closeThreshold, closeThreshold: closeThreshold ?? DrawerContextInitial.closeThreshold,
}); });
const setState = state[1];
useEffect(() => { useEffect(() => {
state[1]((prev) => ({ setState((prev) => ({
...prev, ...prev,
opened: opened ?? prev.opened, opened: opened ?? prev.opened,
closeThreshold: closeThreshold ?? prev.closeThreshold, closeThreshold: closeThreshold ?? prev.closeThreshold,
})); }));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [closeThreshold, opened]); }, [closeThreshold, opened]);
return ( return (
@ -300,7 +302,8 @@ const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(
window.removeEventListener("touchmove", onMouseMove); window.removeEventListener("touchmove", onMouseMove);
window.removeEventListener("touchend", onMouseUp); window.removeEventListener("touchend", onMouseUp);
}; };
}, [state, dragState]); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [state, dragState, position]);
return ( return (
<div <div
@ -346,7 +349,7 @@ const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(
transitionDuration: dragState.isDragging ? "0s" : undefined, transitionDuration: dragState.isDragging ? "0s" : undefined,
userSelect: dragState.isDragging ? "none" : undefined, userSelect: dragState.isDragging ? "none" : undefined,
}} }}
ref={(el) => { ref={(el: HTMLDivElement | null) => {
internalRef.current = el; internalRef.current = el;
if (typeof ref === "function") { if (typeof ref === "function") {
ref(el); ref(el);
@ -404,8 +407,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 +435,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 +463,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}