* Use path instead of alias * Add missing pacakges * Use path in viewers * Use path in contextProviders * Add base to config * Add conditionals for window * Copy config to avoid breaking build * Update and lock versions * Update lock file * Remove scaling config * Fix broken versions of react date * Fix broken dev
27 lines
639 B
JavaScript
27 lines
639 B
JavaScript
export default (element, onClickOutside) => {
|
|
const clickOutsideHandler = event => {
|
|
if (element.current && !element.current.contains(event.target)) {
|
|
onClickOutside();
|
|
if (typeof window !== 'undefined') {
|
|
window.removeEventListener('mousedown', clickOutsideHandler);
|
|
}
|
|
}
|
|
};
|
|
|
|
const add = () => {
|
|
if (typeof window !== 'undefined') {
|
|
window.addEventListener('mousedown', clickOutsideHandler);
|
|
}
|
|
};
|
|
const remove = () => {
|
|
if (typeof window !== 'undefined') {
|
|
window.removeEventListener('mousedown', clickOutsideHandler);
|
|
}
|
|
};
|
|
|
|
return {
|
|
add,
|
|
remove,
|
|
};
|
|
};
|