From d940b825021383dac6d788728a11b3e515482406 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Tue, 18 Jun 2024 11:58:17 -0500 Subject: [PATCH] Deserialized types (#201) --- plugins/ui/src/js/src/elements/hooks/useFocusEventCallback.ts | 4 +++- .../ui/src/js/src/elements/hooks/useKeyboardEventCallback.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/ui/src/js/src/elements/hooks/useFocusEventCallback.ts b/plugins/ui/src/js/src/elements/hooks/useFocusEventCallback.ts index 17b480ecc..2a989703d 100644 --- a/plugins/ui/src/js/src/elements/hooks/useFocusEventCallback.ts +++ b/plugins/ui/src/js/src/elements/hooks/useFocusEventCallback.ts @@ -26,6 +26,8 @@ export type SerializedFocusEventCallback = ( event: SerializedFocusEvent ) => void; +export type DeserializedFocusEventCallback = (e: FocusEvent) => void; + /** * Get a callback function to be passed into spectrum components * @param callback FocusEvent callback to be called with the serialized event @@ -33,7 +35,7 @@ export type SerializedFocusEventCallback = ( */ export function useFocusEventCallback( callback?: SerializedFocusEventCallback -): (e: FocusEvent) => void { +): DeserializedFocusEventCallback { return useCallback( (e: FocusEvent) => { callback?.(serializeFocusEvent(e)); diff --git a/plugins/ui/src/js/src/elements/hooks/useKeyboardEventCallback.ts b/plugins/ui/src/js/src/elements/hooks/useKeyboardEventCallback.ts index b04a207ca..770b1d410 100644 --- a/plugins/ui/src/js/src/elements/hooks/useKeyboardEventCallback.ts +++ b/plugins/ui/src/js/src/elements/hooks/useKeyboardEventCallback.ts @@ -26,6 +26,8 @@ export type SerializedKeyboardEventCallback = ( event: SerializedKeyboardEvent ) => void; +export type DeserializedKeyboardEventCallback = (e: KeyboardEvent) => void; + /** * Get a callback function to be passed into spectrum components * @param callback KeyboardEvent callback to be called with the serialized event @@ -33,7 +35,7 @@ export type SerializedKeyboardEventCallback = ( */ export function useKeyboardEventCallback( callback?: SerializedKeyboardEventCallback -): (e: KeyboardEvent) => void { +): DeserializedKeyboardEventCallback { return useCallback( (e: KeyboardEvent) => { callback?.(serializeKeyboardEvent(e));