@yamada-ui/use-event-listener
Advanced tools
Comparing version 1.0.21 to 1.0.22-dev-20241006000212
@@ -1,8 +0,8 @@ | ||
type Events = keyof DocumentEventMap | keyof WindowEventMap | keyof GlobalEventHandlersEventMap; | ||
type Target = EventTarget | null | (() => EventTarget | null); | ||
type Options = boolean | AddEventListenerOptions; | ||
type Events = keyof DocumentEventMap | keyof GlobalEventHandlersEventMap | keyof WindowEventMap; | ||
type Target = (() => EventTarget | null) | EventTarget | null; | ||
type Options = AddEventListenerOptions | boolean; | ||
type Handler<E extends Events> = E extends keyof DocumentEventMap ? (event: DocumentEventMap[E]) => void : E extends keyof WindowEventMap ? (event: WindowEventMap[E]) => void : E extends keyof GlobalEventHandlersEventMap ? (event: GlobalEventHandlersEventMap[E]) => void : ((event: Event) => void) | undefined; | ||
declare const useEventListener: <E extends Events>(target: Target, event: E, handler: Handler<E>, options?: Options) => () => void; | ||
declare const useEventListeners: () => { | ||
add: <E extends Events>(el: EventTarget, event: E, listener: any, options: boolean | AddEventListenerOptions) => void; | ||
add: <E extends Events>(el: EventTarget, event: E, listener: any, options: AddEventListenerOptions | boolean) => void; | ||
remove: <E extends Events>(el: EventTarget, event: E, listener: any, options: boolean | EventListenerOptions) => void; | ||
@@ -9,0 +9,0 @@ }; |
@@ -34,3 +34,3 @@ "use client" | ||
const el = typeof target === "function" ? target() : target != null ? target : document; | ||
if (!handler || !el) return; | ||
if (!el) return; | ||
el.addEventListener( | ||
@@ -63,3 +63,3 @@ event, | ||
(el, event, listener, options) => { | ||
listeners.current.set(listener, { event, el, options }); | ||
listeners.current.set(listener, { el, event, options }); | ||
el.addEventListener( | ||
@@ -66,0 +66,0 @@ event, |
{ | ||
"name": "@yamada-ui/use-event-listener", | ||
"version": "1.0.21", | ||
"version": "1.0.22-dev-20241006000212", | ||
"description": "Yamada UI useEventListener custom hook", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@yamada-ui/utils": "1.5.2" | ||
"@yamada-ui/utils": "1.5.3-dev-20241006000212" | ||
}, | ||
@@ -31,0 +31,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17645
1
+ Added@yamada-ui/utils@1.5.3-dev-20241006000212(transitive)
- Removed@yamada-ui/utils@1.5.2(transitive)