♻️ refactor(ui): Dependencies

This commit is contained in:
web@ppanel
2024-11-14 21:21:00 +07:00
parent 5af60aa4de
commit 727d779b84
187 changed files with 26448 additions and 14037 deletions
@@ -0,0 +1,20 @@
import React, { useEffect } from 'react';
export const useOutsideClick = (ref: React.RefObject<HTMLDivElement>, callback: Function) => {
useEffect(() => {
const listener = (event: any) => {
if (!ref.current || ref.current.contains(event.target)) {
return;
}
callback(event);
};
document.addEventListener('mousedown', listener);
document.addEventListener('touchstart', listener);
return () => {
document.removeEventListener('mousedown', listener);
document.removeEventListener('touchstart', listener);
};
}, [ref, callback]);
};