chore(web): prettier (#2821)

Co-authored-by: Thomas Way <thomas@6f.io>
This commit is contained in:
Jason Rasmussen 2023-07-01 00:50:47 -04:00 committed by GitHub
parent 7c2f7d6c51
commit f55b3add80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
242 changed files with 12794 additions and 13426 deletions

View file

@ -1,30 +1,30 @@
import type { ActionReturn } from 'svelte/action';
interface Attributes {
'on:outclick'?: (e: CustomEvent) => void;
'on:outclick'?: (e: CustomEvent) => void;
}
export function clickOutside(node: HTMLElement): ActionReturn<void, Attributes> {
const handleClick = (event: MouseEvent) => {
const targetNode = event.target as Node | null;
if (!node.contains(targetNode)) {
node.dispatchEvent(new CustomEvent('outclick'));
}
};
const handleClick = (event: MouseEvent) => {
const targetNode = event.target as Node | null;
if (!node.contains(targetNode)) {
node.dispatchEvent(new CustomEvent('outclick'));
}
};
const handleKey = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
node.dispatchEvent(new CustomEvent('outclick'));
}
};
const handleKey = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
node.dispatchEvent(new CustomEvent('outclick'));
}
};
document.addEventListener('click', handleClick, true);
document.addEventListener('keydown', handleKey, true);
document.addEventListener('click', handleClick, true);
document.addEventListener('keydown', handleKey, true);
return {
destroy() {
document.removeEventListener('click', handleClick, true);
document.removeEventListener('keydown', handleKey, true);
}
};
return {
destroy() {
document.removeEventListener('click', handleClick, true);
document.removeEventListener('keydown', handleKey, true);
},
};
}