fixed code

This commit is contained in:
SlimusMinus
2026-08-11 00:24:07 +03:00
parent c50b75eece
commit 7f59ee1f38
95 changed files with 3623 additions and 2830 deletions

View File

@@ -0,0 +1,20 @@
import { useEffect } from "react";
/**
* Вызывает callback при клике вне элемента, на который повешен ref.
* @param {React.RefObject} ref
* @param {Function} onOutsideClick
* @param {boolean} enabled — можно временно отключать слушатель
*/
export function useClickOutside(ref, onOutsideClick, enabled = true) {
useEffect(() => {
if (!enabled) return;
const handleClick = (e) => {
if (ref.current && !ref.current.contains(e.target)) {
onOutsideClick();
}
};
document.addEventListener("mousedown", handleClick);
return () => document.removeEventListener("mousedown", handleClick);
}, [ref, onOutsideClick, enabled]);
}