mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-29 12:43:48 +00:00
* fix: new table design * fix: added trillions * fixing some raw data * fix: trying to fix global+resize * feat: improving design * fix: new styling and lot of reorganizing * title fix * feat: new html * fix: bottom bar * fix: table dates * fix: table html * fix: new filtering * fix: new filtering * fix: long * Lint * Lint again * fix: beautiful james suggestions * fix: some more fixes * fix: typo * fix economy bug * feat: added toast to notify user and some more cleanup * fix: more issues * tests * fix: james updates * fix: added banner to charts as well * fixing title * better fix * feat: added column resizing and any number of columns * auto column width - poc * feat: added colors toggle, support to display source, fixed some more issues * fix: table deploy * fix: table issue * fix header * fix: some fixes * fix: remember pagination and default pagination to 30 * mypy * Colins tests * Fix economy test --------- Co-authored-by: James Maslek <jmaslek11@gmail.com> Co-authored-by: teh_coderer <me@tehcoderer.com> Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com>
23 lines
728 B
TypeScript
Vendored
23 lines
728 B
TypeScript
Vendored
import { RefObject, useEffect } from "react";
|
|
|
|
export default function useOnClickOutside(
|
|
ref: RefObject<HTMLElement>,
|
|
handler: (event: MouseEvent | TouchEvent) => void
|
|
) {
|
|
useEffect(() => {
|
|
const listener = (event: MouseEvent | TouchEvent) => {
|
|
// Do nothing if clicking ref's element or descendent elements
|
|
if (!ref.current || ref.current.contains(event.target as Node)) {
|
|
return;
|
|
}
|
|
handler(event);
|
|
};
|
|
document.addEventListener("mousedown", listener);
|
|
document.addEventListener("touchstart", listener);
|
|
return () => {
|
|
document.removeEventListener("mousedown", listener);
|
|
document.removeEventListener("touchstart", listener);
|
|
};
|
|
}, [ref, handler]);
|
|
}
|