Initial commit

This commit is contained in:
admin
2026-05-26 22:46:00 +02:00
commit 7e2c2ff89c
256 changed files with 51523 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
import { useEffect, type RefObject } from "react";
export function useClickOutside<T extends HTMLElement>(
ref: RefObject<T | null>,
onOutside: () => void,
enabled = true,
) {
useEffect(() => {
if (!enabled) return;
const handler = (e: MouseEvent) => {
if (ref.current && !ref.current.contains(e.target as Node)) onOutside();
};
document.addEventListener("mousedown", handler);
return () => document.removeEventListener("mousedown", handler);
}, [ref, onOutside, enabled]);
}