@siberiacancode/reactuse 0.2.18 → 0.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -71
- package/dist/cjs/hooks/useAudio/useAudio.cjs +2 -0
- package/dist/cjs/hooks/useAudio/useAudio.cjs.map +1 -0
- package/dist/cjs/hooks/useCopy/useCopy.cjs +1 -1
- package/dist/cjs/hooks/useCopy/useCopy.cjs.map +1 -1
- package/dist/cjs/hooks/useCssVar/useCssVar.cjs +1 -1
- package/dist/cjs/hooks/useCssVar/useCssVar.cjs.map +1 -1
- package/dist/cjs/hooks/useDebounceCallback/useDebounceCallback.cjs +1 -1
- package/dist/cjs/hooks/useDebounceCallback/useDebounceCallback.cjs.map +1 -1
- package/dist/cjs/hooks/useDeviceMotion/useDeviceMotion.cjs.map +1 -1
- package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs +1 -1
- package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs.map +1 -1
- package/dist/cjs/hooks/useHash/useHash.cjs +1 -1
- package/dist/cjs/hooks/useHash/useHash.cjs.map +1 -1
- package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs +2 -0
- package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs.map +1 -0
- package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs +2 -0
- package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs.map +1 -0
- package/dist/cjs/hooks/useQuery/useQuery.cjs.map +1 -1
- package/dist/cjs/hooks/useShallowEffect/useShallowEffect.cjs +2 -0
- package/dist/cjs/hooks/useShallowEffect/useShallowEffect.cjs.map +1 -0
- package/dist/cjs/hooks/useStorage/useStorage.cjs.map +1 -1
- package/dist/cjs/hooks/useThrottleCallback/useThrottleCallback.cjs +1 -1
- package/dist/cjs/hooks/useThrottleCallback/useThrottleCallback.cjs.map +1 -1
- package/dist/cjs/hooks/useWizard/useWizard.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/hooks/useAudio/useAudio.mjs +50 -0
- package/dist/esm/hooks/useAudio/useAudio.mjs.map +1 -0
- package/dist/esm/hooks/useCopy/useCopy.mjs +1 -1
- package/dist/esm/hooks/useCopy/useCopy.mjs.map +1 -1
- package/dist/esm/hooks/useCssVar/useCssVar.mjs +23 -26
- package/dist/esm/hooks/useCssVar/useCssVar.mjs.map +1 -1
- package/dist/esm/hooks/useDebounceCallback/useDebounceCallback.mjs +8 -8
- package/dist/esm/hooks/useDebounceCallback/useDebounceCallback.mjs.map +1 -1
- package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs.map +1 -1
- package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs +1 -0
- package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs.map +1 -1
- package/dist/esm/hooks/useHash/useHash.mjs +9 -8
- package/dist/esm/hooks/useHash/useHash.mjs.map +1 -1
- package/dist/esm/hooks/useMediaControls/useMediaControls.mjs +70 -0
- package/dist/esm/hooks/useMediaControls/useMediaControls.mjs.map +1 -0
- package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs +26 -0
- package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs.map +1 -0
- package/dist/esm/hooks/useQuery/useQuery.mjs.map +1 -1
- package/dist/esm/hooks/useShallowEffect/useShallowEffect.mjs +23 -0
- package/dist/esm/hooks/useShallowEffect/useShallowEffect.mjs.map +1 -0
- package/dist/esm/hooks/useStorage/useStorage.mjs +6 -1
- package/dist/esm/hooks/useStorage/useStorage.mjs.map +1 -1
- package/dist/esm/hooks/useThrottleCallback/useThrottleCallback.mjs +13 -6
- package/dist/esm/hooks/useThrottleCallback/useThrottleCallback.mjs.map +1 -1
- package/dist/esm/hooks/useWizard/useWizard.mjs.map +1 -1
- package/dist/esm/index.mjs +336 -325
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/hooks/index.d.ts +4 -0
- package/dist/types/hooks/useAudio/useAudio.d.ts +58 -0
- package/dist/types/hooks/useCopy/useCopy.d.ts +1 -1
- package/dist/types/hooks/useCssVar/useCssVar.d.ts +6 -4
- package/dist/types/hooks/useDoubleClick/useDoubleClick.d.ts +4 -0
- package/dist/types/hooks/useHash/useHash.d.ts +3 -2
- package/dist/types/hooks/useMediaControls/useMediaControls.d.ts +101 -0
- package/dist/types/hooks/usePictureInPicture/usePictureInPicture.d.ts +53 -0
- package/dist/types/hooks/useShallowEffect/useShallowEffect.d.ts +14 -0
- package/dist/types/hooks/useStorage/useStorage.d.ts +1 -5
- package/dist/types/hooks/useThrottleCallback/useThrottleCallback.d.ts +4 -1
- package/dist/types/hooks/useWizard/useWizard.d.ts +1 -1
- package/package.json +3 -3
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './useActiveElement/useActiveElement';
|
|
2
2
|
export * from './useAsync/useAsync';
|
|
3
|
+
export * from './useAudio/useAudio';
|
|
3
4
|
export * from './useBattery/useBattery';
|
|
4
5
|
export * from './useBluetooth/useBluetooth';
|
|
5
6
|
export * from './useBoolean/useBoolean';
|
|
@@ -65,6 +66,7 @@ export * from './useLogger/useLogger';
|
|
|
65
66
|
export * from './useLongPress/useLongPress';
|
|
66
67
|
export * from './useMap/useMap';
|
|
67
68
|
export * from './useMeasure/useMeasure';
|
|
69
|
+
export * from './useMediaControls/useMediaControls';
|
|
68
70
|
export * from './useMediaQuery/useMediaQuery';
|
|
69
71
|
export * from './useMemory/useMemory';
|
|
70
72
|
export * from './useMount/useMount';
|
|
@@ -84,6 +86,7 @@ export * from './usePaint/usePaint';
|
|
|
84
86
|
export * from './useParallax/useParallax';
|
|
85
87
|
export * from './usePerformanceObserver/usePerformanceObserver';
|
|
86
88
|
export * from './usePermission/usePermission';
|
|
89
|
+
export * from './usePictureInPicture/usePictureInPicture';
|
|
87
90
|
export * from './usePointerLock/usePointerLock';
|
|
88
91
|
export * from './usePostMessage/usePostMessage';
|
|
89
92
|
export * from './usePreferredColorScheme/usePreferredColorScheme';
|
|
@@ -108,6 +111,7 @@ export * from './useScrollIntoView/useScrollIntoView';
|
|
|
108
111
|
export * from './useScrollTo/useScrollTo';
|
|
109
112
|
export * from './useSessionStorage/useSessionStorage';
|
|
110
113
|
export * from './useSet/useSet';
|
|
114
|
+
export * from './useShallowEffect/useShallowEffect';
|
|
111
115
|
export * from './useShare/useShare';
|
|
112
116
|
export * from './useSpeechRecognition/useSpeechRecognition';
|
|
113
117
|
export * from './useSpeechSynthesis/useSpeechSynthesis';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Type sprite map */
|
|
2
|
+
export interface SpriteMap {
|
|
3
|
+
/** [start time in seconds, end time in seconds] */
|
|
4
|
+
[key: string]: [number, number];
|
|
5
|
+
}
|
|
6
|
+
/** Type use audio options */
|
|
7
|
+
export interface UseAudioOptions {
|
|
8
|
+
/** Whether audio playback is initially enabled */
|
|
9
|
+
immediately?: boolean;
|
|
10
|
+
/** Whether to stop current playback when starting a new one */
|
|
11
|
+
interrupt?: boolean;
|
|
12
|
+
/** Initial playback speed (0.5 to 2) */
|
|
13
|
+
playbackRate?: number;
|
|
14
|
+
/** Map of named audio segments for sprite-based playback */
|
|
15
|
+
sprite?: SpriteMap;
|
|
16
|
+
/** Initial volume level (0 to 1) */
|
|
17
|
+
volume?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Type use audio return type */
|
|
20
|
+
export interface UseAudioReturn {
|
|
21
|
+
/** Current playback speed (0.5 to 2) */
|
|
22
|
+
playbackRate: number;
|
|
23
|
+
/** Whether audio is currently playing */
|
|
24
|
+
playing: boolean;
|
|
25
|
+
/** Current volume level (0 to 1) */
|
|
26
|
+
volume: number;
|
|
27
|
+
/** Set playback speed (0.5 to 2) */
|
|
28
|
+
changePlaybackRate: (value: number) => void;
|
|
29
|
+
/** Pause audio playback at current position */
|
|
30
|
+
pause: () => void;
|
|
31
|
+
/** Start audio playback from the beginning or specified sprite segment */
|
|
32
|
+
play: (sprite?: string) => Promise<void>;
|
|
33
|
+
/** Set audio volume level (0 to 1) */
|
|
34
|
+
setVolume: (value: number) => void;
|
|
35
|
+
/** Stop audio playback and reset position to start */
|
|
36
|
+
stop: () => void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @name useAudio
|
|
40
|
+
* @description - Hook that manages audio playback with sprite support
|
|
41
|
+
* @category Browser
|
|
42
|
+
*
|
|
43
|
+
* @browserapi Audio https://developer.mozilla.org/en-US/docs/Web/API/Audio
|
|
44
|
+
*
|
|
45
|
+
* @template Value The type of the value
|
|
46
|
+
* @param {string} url The URL of the audio file to play
|
|
47
|
+
* @param {UseAudioOptions} [options] Audio configuration options
|
|
48
|
+
* @param {number} [options.volume=1] Initial volume level (0 to 1)
|
|
49
|
+
* @param {number} [options.playbackRate=1] Initial playback speed (0.5 to 2)
|
|
50
|
+
* @param {boolean} [options.interrupt=false] Whether to stop current playback when starting a new one
|
|
51
|
+
* @param {boolean} [options.soundEnabled=true] Whether audio playback is initially enabled
|
|
52
|
+
* @param {SpriteMap} [options.sprite] Map of named audio segments for sprite-based playback
|
|
53
|
+
* @returns {UseAudioReturn} An object containing audio controls and state
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const audio = useAudio("/path/to/sound.mp3");
|
|
57
|
+
*/
|
|
58
|
+
export declare const useAudio: (src: string, options?: UseAudioOptions) => UseAudioReturn;
|
|
@@ -4,12 +4,14 @@ import { StateRef } from '../useRefState/useRefState';
|
|
|
4
4
|
export interface UseCssVarReturn {
|
|
5
5
|
/** The value of the CSS variable */
|
|
6
6
|
value: string;
|
|
7
|
+
/** Remove the value of the CSS variable */
|
|
8
|
+
remove: () => void;
|
|
7
9
|
/** Set the value of the CSS variable */
|
|
8
10
|
set: (value: string) => void;
|
|
9
11
|
}
|
|
10
12
|
export interface UseCssVar {
|
|
11
|
-
(key: string, initialValue?: string): UseCssVarReturn & {
|
|
12
|
-
ref: StateRef<
|
|
13
|
+
<Target extends HTMLElement>(key: string, initialValue?: string): UseCssVarReturn & {
|
|
14
|
+
ref: StateRef<Target>;
|
|
13
15
|
};
|
|
14
16
|
(target: HookTarget, key: string, initialValue?: string): UseCssVarReturn;
|
|
15
17
|
}
|
|
@@ -24,7 +26,7 @@ export interface UseCssVar {
|
|
|
24
26
|
* @returns {UseCssVarReturn & { ref: StateRef<Element> }} The object containing the value of the CSS variable and ref
|
|
25
27
|
*
|
|
26
28
|
* @example
|
|
27
|
-
* const { ref, value, set } = useCssVar('--color', 'red');
|
|
29
|
+
* const { ref, value, set, remove } = useCssVar('--color', 'red');
|
|
28
30
|
*
|
|
29
31
|
* @overload
|
|
30
32
|
* @param {HookTarget} target The target element
|
|
@@ -33,6 +35,6 @@ export interface UseCssVar {
|
|
|
33
35
|
* @returns {UseCssVarReturn} The object containing the value of the CSS variable
|
|
34
36
|
*
|
|
35
37
|
* @example
|
|
36
|
-
* const { value, set } = useCssVar(ref, '--color', 'red');
|
|
38
|
+
* const { value, set, remove } = useCssVar(ref, '--color', 'red');
|
|
37
39
|
*/
|
|
38
40
|
export declare const useCssVar: UseCssVar;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { HookTarget } from '../../utils/helpers';
|
|
2
2
|
import { StateRef } from '../useRefState/useRefState';
|
|
3
3
|
export type DoubleClickEvents = MouseEvent | TouchEvent;
|
|
4
|
+
/** The use double click options type */
|
|
4
5
|
export interface UseDoubleClickOptions {
|
|
6
|
+
/** The threshold time in milliseconds between clicks */
|
|
5
7
|
threshold?: number;
|
|
8
|
+
/** The callback function to be invoked on single click */
|
|
6
9
|
onSingleClick?: (event: DoubleClickEvents) => void;
|
|
7
10
|
}
|
|
8
11
|
export interface UseDoubleClick {
|
|
9
12
|
(target: HookTarget, callback: (event: DoubleClickEvents) => void, options?: UseDoubleClickOptions): boolean;
|
|
10
13
|
<Target extends Element>(callback: (event: DoubleClickEvents) => void, options?: UseDoubleClickOptions, target?: never): StateRef<Target>;
|
|
11
14
|
}
|
|
15
|
+
export declare const DEFAULT_THRESHOLD_TIME = 300;
|
|
12
16
|
/**
|
|
13
17
|
* @name useDoubleClick
|
|
14
18
|
* @description - Hook that defines the logic when double clicking an element
|
|
@@ -5,10 +5,11 @@ type UseHashReturn = [string, (value: string) => void];
|
|
|
5
5
|
* @description - Hook that manages the hash value
|
|
6
6
|
* @category Browser
|
|
7
7
|
*
|
|
8
|
+
* @param {string} [initialValue] The initial hash value if no hash exists
|
|
8
9
|
* @returns {UseHashReturn} An array containing the hash value and a function to set the hash value
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
11
|
-
* const [hash, setHash] = useHash();
|
|
12
|
+
* const [hash, setHash] = useHash("initial");
|
|
12
13
|
*/
|
|
13
|
-
export declare const useHash: () => UseHashReturn;
|
|
14
|
+
export declare const useHash: (initialValue?: string, mode?: "initial" | "replace") => UseHashReturn;
|
|
14
15
|
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { HookTarget } from '../../utils/helpers';
|
|
2
|
+
import { StateRef } from '../useRefState/useRefState';
|
|
3
|
+
export declare const timeRangeToArray: (timeRanges: TimeRanges) => [number, number][];
|
|
4
|
+
/** The media source configuration type */
|
|
5
|
+
export interface UseMediaSource {
|
|
6
|
+
/** The media attribute of the media */
|
|
7
|
+
media?: string;
|
|
8
|
+
/** The source URL of the media */
|
|
9
|
+
src: string;
|
|
10
|
+
/** The MIME type of the media */
|
|
11
|
+
type?: string;
|
|
12
|
+
}
|
|
13
|
+
/** The media controls return type */
|
|
14
|
+
export interface UseMediaControlsReturn {
|
|
15
|
+
/** Whether the media is currently buffering */
|
|
16
|
+
buffered: [number, number][];
|
|
17
|
+
/** The current playback position in seconds */
|
|
18
|
+
currentTime: number;
|
|
19
|
+
/** The total duration of the media in seconds */
|
|
20
|
+
duration: number;
|
|
21
|
+
/** Whether the media has ended */
|
|
22
|
+
ended: boolean;
|
|
23
|
+
/** Whether the media is currently muted */
|
|
24
|
+
muted: boolean;
|
|
25
|
+
/** The current playback rate (1.0 is normal speed) */
|
|
26
|
+
playbackRate: number;
|
|
27
|
+
/** Whether the media is currently playing */
|
|
28
|
+
playing: boolean;
|
|
29
|
+
/** Whether the media is currently seeking */
|
|
30
|
+
seeking: boolean;
|
|
31
|
+
/** Whether the media is currently stalled */
|
|
32
|
+
stalled: boolean;
|
|
33
|
+
/** The current volume level (0.0 to 1.0) */
|
|
34
|
+
volume: number;
|
|
35
|
+
/** Whether the media is currently waiting */
|
|
36
|
+
waiting: boolean;
|
|
37
|
+
/** Set the playback rate */
|
|
38
|
+
changePlaybackRate: (rate: number) => void;
|
|
39
|
+
/** Set the volume level (0.0 to 1.0) */
|
|
40
|
+
changeVolume: (volume: number) => void;
|
|
41
|
+
/** Set the muted state */
|
|
42
|
+
mute: () => void;
|
|
43
|
+
/** Pause the media */
|
|
44
|
+
pause: () => void;
|
|
45
|
+
/** Start playing the media */
|
|
46
|
+
play: () => Promise<void>;
|
|
47
|
+
/** Seek to a specific time in seconds */
|
|
48
|
+
seek: (time: number) => void;
|
|
49
|
+
/** Toggle between play and pause */
|
|
50
|
+
toggle: () => Promise<void>;
|
|
51
|
+
/** Set the unmuted state */
|
|
52
|
+
unmute: () => void;
|
|
53
|
+
}
|
|
54
|
+
export interface UseMediaControls {
|
|
55
|
+
(target: HookTarget, src: string): UseMediaControlsReturn;
|
|
56
|
+
(target: HookTarget, options: UseMediaSource): UseMediaControlsReturn;
|
|
57
|
+
<Target extends HTMLMediaElement>(src: string): UseMediaControlsReturn & {
|
|
58
|
+
ref: StateRef<Target>;
|
|
59
|
+
};
|
|
60
|
+
<Target extends HTMLMediaElement>(options: UseMediaSource): UseMediaControlsReturn & {
|
|
61
|
+
ref: StateRef<Target>;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @name useMediaControls
|
|
66
|
+
* @description Hook that provides controls for HTML media elements (audio/video)
|
|
67
|
+
* @category Browser
|
|
68
|
+
*
|
|
69
|
+
* @overload
|
|
70
|
+
* @param {HookTarget} target The target media element
|
|
71
|
+
* @param {string} src The source URL of the media
|
|
72
|
+
* @returns {UseMediaControlsReturn} An object containing media controls and state
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* const { playing, play, pause } = useMediaControls(videoRef, 'video.mp4');
|
|
76
|
+
*
|
|
77
|
+
* @overload
|
|
78
|
+
* @param {HookTarget} target The target media element
|
|
79
|
+
* @param {UseMediaSource} options The media source configuration
|
|
80
|
+
* @returns {UseMediaControlsReturn} An object containing media controls and state
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* const { playing, play, pause } = useMediaControls(audioRef, { src: 'audio.mp3', type: 'audio/mp3' });
|
|
84
|
+
*
|
|
85
|
+
* @overload
|
|
86
|
+
* @template Target The target media element type
|
|
87
|
+
* @param {string} src The source URL of the media
|
|
88
|
+
* @returns {UseMediaControlsReturn & { ref: StateRef<Target> }} An object containing media controls, state and ref
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* const { ref, playing, play, pause } = useMediaControls<HTMLVideoElement>('video.mp4');
|
|
92
|
+
*
|
|
93
|
+
* @overload
|
|
94
|
+
* @template Target The target media element type
|
|
95
|
+
* @param {UseMediaSource} options The media source configuration
|
|
96
|
+
* @returns {UseMediaControlsReturn & { ref: StateRef<Target> }} An object containing media controls, state and ref
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* const { ref, playing, play, pause } = useMediaControls<HTMLVideoElement>({ src: 'video.mp4', type: 'video/mp4' });
|
|
100
|
+
*/
|
|
101
|
+
export declare const useMediaControls: UseMediaControls;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { HookTarget } from '../../utils/helpers';
|
|
2
|
+
import { StateRef } from '../useRefState/useRefState';
|
|
3
|
+
/** The use picture in picture options type */
|
|
4
|
+
export interface UsePictureInPictureOptions {
|
|
5
|
+
/** The callback when Picture-in-Picture mode is entered */
|
|
6
|
+
onEnter?: () => void;
|
|
7
|
+
/** The callback when Picture-in-Picture mode is exited */
|
|
8
|
+
onExit?: () => void;
|
|
9
|
+
}
|
|
10
|
+
/** The use picture in picture return type */
|
|
11
|
+
export interface UsePictureInPictureReturn {
|
|
12
|
+
/** Whether Picture-in-Picture mode is currently active */
|
|
13
|
+
open: boolean;
|
|
14
|
+
/** Whether Picture-in-Picture mode is supported by the browser */
|
|
15
|
+
supported: boolean;
|
|
16
|
+
/** Request to enter Picture-in-Picture mode */
|
|
17
|
+
enter: () => Promise<void>;
|
|
18
|
+
/** Request to exit Picture-in-Picture mode */
|
|
19
|
+
exit: () => Promise<void>;
|
|
20
|
+
/** Toggle Picture-in-Picture mode */
|
|
21
|
+
toggle: () => Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export interface UsePictureInPicture {
|
|
24
|
+
(target: HookTarget, options?: UsePictureInPictureOptions): UsePictureInPictureReturn;
|
|
25
|
+
(options?: UsePictureInPictureOptions): UsePictureInPictureReturn & {
|
|
26
|
+
ref: StateRef<HTMLVideoElement>;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @name usePictureInPicture
|
|
31
|
+
* @description - Hook that provides Picture-in-Picture functionality for video elements
|
|
32
|
+
* @category Browser
|
|
33
|
+
*
|
|
34
|
+
* @browserapi window.PictureInPicture https://developer.mozilla.org/en-US/docs/Web/API/Picture-in-Picture_API
|
|
35
|
+
*
|
|
36
|
+
* @overload
|
|
37
|
+
* @param {HookTarget} target The target video element
|
|
38
|
+
* @param {() => void} [options.onEnter] Callback when Picture-in-Picture mode is entered
|
|
39
|
+
* @param {() => void} [options.onExit] Callback when Picture-in-Picture mode is exited
|
|
40
|
+
* @returns {UsePictureInPictureReturn} An object containing Picture-in-Picture state and controls
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* const { open, supported, enter, exit, toggle } = usePictureInPicture(videoRef);
|
|
44
|
+
*
|
|
45
|
+
* @overload
|
|
46
|
+
* @param {() => void} [options.onEnter] Callback when Picture-in-Picture mode is entered
|
|
47
|
+
* @param {() => void} [options.onExit] Callback when Picture-in-Picture mode is exited
|
|
48
|
+
* @returns {UsePictureInPictureReturn & { ref: StateRef<HTMLVideoElement> }} An object containing Picture-in-Picture state, controls and ref
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* const { ref, open, supported, enter, exit, toggle } = usePictureInPicture();
|
|
52
|
+
*/
|
|
53
|
+
export declare const usePictureInPicture: UsePictureInPicture;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DependencyList, EffectCallback } from 'react';
|
|
2
|
+
export declare const deepEqual: (a: any, b: any) => boolean;
|
|
3
|
+
/**
|
|
4
|
+
* @name useShallowEffect
|
|
5
|
+
* @description - Hook that executes an effect only when dependencies change shallowly or deeply.
|
|
6
|
+
* @category Lifecycle
|
|
7
|
+
*
|
|
8
|
+
* @param {EffectCallback} effect The effect callback
|
|
9
|
+
* @param {DependencyList} [deps] The dependencies list for the effect
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* useShallowEffect(() => console.log("effect"), [user]);
|
|
13
|
+
*/
|
|
14
|
+
export declare const useShallowEffect: (effect: EffectCallback, deps?: DependencyList) => void;
|
|
@@ -11,12 +11,8 @@ export interface UseStorageReturn<Value> {
|
|
|
11
11
|
set: (value: Value) => void;
|
|
12
12
|
}
|
|
13
13
|
export interface UseStorage {
|
|
14
|
-
<Value>(key: string, options: UseStorageOptions<Value> & {
|
|
15
|
-
initialValue: UseStorageInitialValue<Value>;
|
|
16
|
-
}): UseStorageReturn<Value>;
|
|
17
14
|
<Value>(key: string, options?: UseStorageOptions<Value>): UseStorageReturn<Value | undefined>;
|
|
18
|
-
<Value>(key: string, initialValue
|
|
19
|
-
<Value>(key: string): UseStorageReturn<Value | undefined>;
|
|
15
|
+
<Value>(key: string, initialValue?: UseStorageInitialValue<Value>): UseStorageReturn<Value | undefined>;
|
|
20
16
|
}
|
|
21
17
|
export declare const STORAGE_EVENT = "reactuse-storage";
|
|
22
18
|
export declare const dispatchStorageEvent: (params: Partial<StorageEvent>) => boolean;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export type ThrottledCallback<Params extends unknown[]> = ((...args: Params) => void) & {
|
|
2
|
+
cancel: () => void;
|
|
3
|
+
};
|
|
1
4
|
/**
|
|
2
5
|
* @name useThrottleCallback
|
|
3
6
|
* @description - Hook that creates a throttled callback
|
|
@@ -12,4 +15,4 @@
|
|
|
12
15
|
* @example
|
|
13
16
|
* const throttled = useThrottleCallback(() => console.log('callback'), 500);
|
|
14
17
|
*/
|
|
15
|
-
export declare const useThrottleCallback: <Params extends unknown[], Return>(callback: (...args: Params) => Return, delay: number) =>
|
|
18
|
+
export declare const useThrottleCallback: <Params extends unknown[], Return>(callback: (...args: Params) => Return, delay: number) => ThrottledCallback<Params>;
|
|
@@ -12,7 +12,7 @@ export interface WizardItem<WizardStepId> {
|
|
|
12
12
|
* @returns {UseWizardReturn<WizardStepId>} An object containing the current step id and functions to interact with the wizard
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
|
-
* const { currentStepId, set, reset, back, history } = useWizard([
|
|
15
|
+
* const { currentStepId, set, reset, back, next, history } = useWizard([
|
|
16
16
|
* { id: 'step1', nodes: ['step2', 'step3'] },
|
|
17
17
|
* { id: 'step2', nodes: ['step3'] },
|
|
18
18
|
* { id: 'step3', nodes: [] },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siberiacancode/reactuse",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.20",
|
|
4
4
|
"description": "The ultimate collection of react hooks",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "SIBERIA CAN CODE 🧊",
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
"@types/react-dom": "^19.1.6",
|
|
73
73
|
"@types/web-bluetooth": "^0.0.21",
|
|
74
74
|
"@vitejs/plugin-react": "^4.6.0",
|
|
75
|
-
"core-js": "^3.
|
|
75
|
+
"core-js": "^3.44.0",
|
|
76
76
|
"react": "^19.1.0",
|
|
77
77
|
"react-dom": "^19.1.0",
|
|
78
78
|
"shx": "^0.4.0",
|
|
79
|
-
"vite": "^7.0.
|
|
79
|
+
"vite": "^7.0.4",
|
|
80
80
|
"vite-plugin-dts": "^4.5.4",
|
|
81
81
|
"vitest": "^3.2.4"
|
|
82
82
|
},
|