From 187c0f4f9cf5db3808970602b6619e19d5d79a7f Mon Sep 17 00:00:00 2001 From: Hunter Johnston Date: Tue, 8 Oct 2024 19:53:23 -0400 Subject: [PATCH] more --- .../components/drawer/drawer-content.svelte | 10 ++++---- packages/vaul-svelte/src/lib/vaul.svelte.ts | 25 ++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/packages/vaul-svelte/src/lib/components/drawer/drawer-content.svelte b/packages/vaul-svelte/src/lib/components/drawer/drawer-content.svelte index ea2693e..d9aac6e 100644 --- a/packages/vaul-svelte/src/lib/components/drawer/drawer-content.svelte +++ b/packages/vaul-svelte/src/lib/components/drawer/drawer-content.svelte @@ -27,12 +27,12 @@ () => ref, (v) => (ref = v) ), - onContextMenu: box.with(() => oncontextmenu), + onContextMenu: box.with(() => oncontextmenu ?? noop), onInteractOutside: box.with(() => onInteractOutside), - onPointerDown: box.with(() => onpointerdown), - onPointerMove: box.with(() => onpointermove), - onPointerOut: box.with(() => onpointerout), - onPointerUp: box.with(() => onpointerup), + onPointerDown: box.with(() => onpointerdown ?? noop), + onPointerMove: box.with(() => onpointermove ?? noop), + onPointerOut: box.with(() => onpointerout ?? noop), + onPointerUp: box.with(() => onpointerup ?? noop), onOpenAutoFocus: box.with(() => onOpenAutoFocus), }); diff --git a/packages/vaul-svelte/src/lib/vaul.svelte.ts b/packages/vaul-svelte/src/lib/vaul.svelte.ts index 3847168..021908e 100644 --- a/packages/vaul-svelte/src/lib/vaul.svelte.ts +++ b/packages/vaul-svelte/src/lib/vaul.svelte.ts @@ -8,6 +8,7 @@ import { type WritableBoxedValues, afterTick, } from "svelte-toolbelt"; +import type { MouseEventHandler, PointerEventHandler } from "svelte/elements"; import { isInput, isVertical } from "./internal/helpers/is.js"; import { BORDER_RADIUS, @@ -745,12 +746,12 @@ class DrawerOverlayState { type DrawerContentStateProps = WithRefProps & ReadableBoxedValues<{ - onInteractOutside: (e: Event) => void; - onPointerDown: (e: PointerEvent) => void; - onPointerMove: (e: PointerEvent) => void; - onPointerUp: (e: PointerEvent) => void; - onPointerOut: (e: PointerEvent) => void; - onContextMenu: (e: MouseEvent) => void; + onInteractOutside: (e: MouseEvent | TouchEvent | PointerEvent) => void; + onPointerDown: PointerEventHandler; + onPointerMove: PointerEventHandler; + onPointerUp: PointerEventHandler; + onPointerOut: PointerEventHandler; + onContextMenu: MouseEventHandler; onOpenAutoFocus: (e: Event) => void; }>; @@ -854,7 +855,7 @@ class DrawerContentState { // } }; - onInteractOutside = (e: Event) => { + onInteractOutside = (e: MouseEvent | TouchEvent | PointerEvent) => { this.#onInteractOutsideProp.current(e); if (!this.#root.modal.current || e.defaultPrevented) { @@ -873,7 +874,7 @@ class DrawerContentState { } }; - #onpointermove = (e: PointerEvent) => { + #onpointermove: PointerEventHandler = (e) => { this.lastKnownPointerEvent = e; if (this.#root.handleOnly.current) return; this.#onPointerMoveProp.current(e); @@ -898,26 +899,26 @@ class DrawerContentState { } }; - #onpointerup = (e: PointerEvent) => { + #onpointerup: PointerEventHandler = (e) => { this.#onPointerUpProp.current(e); this.pointerStart = null; this.wasBeyondThePoint = false; this.#root.onRelease(e); }; - #onpointerout = (e: PointerEvent) => { + #onpointerout: PointerEventHandler = (e) => { this.#onPointerOutProp.current(e); if (!this.lastKnownPointerEvent) return; this.handleOnPointerUp(this.lastKnownPointerEvent); }; - #oncontextmenu = (e: MouseEvent) => { + #oncontextmenu: MouseEventHandler = (e) => { this.#onContextMenuProp.current(e); if (!this.lastKnownPointerEvent) return; this.handleOnPointerUp(this.lastKnownPointerEvent); }; - #onpointerdown = (e: PointerEvent) => { + #onpointerdown: PointerEventHandler = (e) => { if (this.#root.handleOnly.current) return; this.#onPointerDownProp.current(e); this.pointerStart = { x: e.pageX, y: e.pageY };