-
-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a5e136
commit 7721d15
Showing
8 changed files
with
117 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare function doesIdentifierMatchKeyboardEvent(e: KeyboardEvent, identifier: any): boolean; | ||
export { doesIdentifierMatchKeyboardEvent }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function doesIdentifierMatchKeyboardEvent( | ||
e: KeyboardEvent, | ||
identifier | ||
): boolean { | ||
if ( | ||
e.key === identifier || | ||
e.code === identifier || | ||
e.keyCode === identifier || | ||
e.which === identifier || | ||
e.charCode === identifier | ||
) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
export { doesIdentifierMatchKeyboardEvent }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* | ||
* @param {function} callback Callback function to be called on mount | ||
*/ | ||
declare function useDidMount(callback: () => any): void; | ||
export { useDidMount }; | ||
/** | ||
* | ||
* @param {function} callback Callback function to be called on mount | ||
*/ | ||
declare function useDidMount(callback: () => any): void; | ||
export { useDidMount }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
/// <reference types="node" /> | ||
interface IntervalHandlerAsArray extends Array<null | NodeJS.Timeout | (() => void)> { | ||
0: () => void; | ||
1: () => void; | ||
2: NodeJS.Timeout | null; | ||
} | ||
interface IntervalHandler extends IntervalHandlerAsArray { | ||
} | ||
/** | ||
* | ||
* useInterval hook | ||
* | ||
* Declaratively creates a setInterval to run a callback after a fixed | ||
* amount of time | ||
* | ||
*@param {funnction} callback - Callback to be fired | ||
*@param {number} intervalId - Interval duration in milliseconds after which the callback is to be fired | ||
*@param {boolean} startImmediate - Whether the interval should start immediately on initialise | ||
*@return {IntervalHandler} | ||
*/ | ||
declare function useInterval(callback: () => any, intervalDuration: number, startImmediate?: boolean): IntervalHandler; | ||
export { useInterval }; | ||
/// <reference types="node" /> | ||
interface IntervalHandlerAsArray extends Array<null | NodeJS.Timeout | (() => void)> { | ||
0: () => void; | ||
1: () => void; | ||
2: NodeJS.Timeout | null; | ||
} | ||
interface IntervalHandler extends IntervalHandlerAsArray { | ||
} | ||
/** | ||
* | ||
* useInterval hook | ||
* | ||
* Declaratively creates a setInterval to run a callback after a fixed | ||
* amount of time | ||
* | ||
*@param {funnction} callback - Callback to be fired | ||
*@param {number} intervalId - Interval duration in milliseconds after which the callback is to be fired | ||
*@param {boolean} startImmediate - Whether the interval should start immediately on initialise | ||
*@return {IntervalHandler} | ||
*/ | ||
declare function useInterval(callback: () => any, intervalDuration: number, startImmediate?: boolean): IntervalHandler; | ||
export { useInterval }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { MutableRefObject } from "react"; | ||
/** | ||
* | ||
* useMutationObserver hook | ||
* | ||
* Returns a mutation observer for a React Ref and fires a callback | ||
* | ||
* @param {MutableRefObject<HTMLElement | null>} ref React ref on which mutations are to be observed | ||
* @param {MutationCallback} callback Function that needs to be fired on mutation | ||
* @param {MutationObserverInit} options | ||
*/ | ||
declare function useMutationObserver(ref: MutableRefObject<HTMLElement | null>, callback: MutationCallback, options?: MutationObserverInit): void; | ||
export { useMutationObserver }; | ||
import { MutableRefObject } from "react"; | ||
/** | ||
* | ||
* useMutationObserver hook | ||
* | ||
* Returns a mutation observer for a React Ref and fires a callback | ||
* | ||
* @param {MutableRefObject<HTMLElement | null>} ref React ref on which mutations are to be observed | ||
* @param {MutationCallback} callback Function that needs to be fired on mutation | ||
* @param {MutationObserverInit} options | ||
*/ | ||
declare function useMutationObserver(ref: MutableRefObject<HTMLElement | null>, callback: MutationCallback, options?: MutationObserverInit): void; | ||
export { useMutationObserver }; |