@siberiacancode/reactuse 0.3.4 → 0.3.5
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/dist/cjs/hooks/useDropZone/useDropZone.cjs.map +1 -1
- package/dist/cjs/hooks/useEventSource/useEventSource.cjs +1 -1
- package/dist/cjs/hooks/useEventSource/useEventSource.cjs.map +1 -1
- package/dist/cjs/hooks/useField/useField.cjs +1 -1
- package/dist/cjs/hooks/useField/useField.cjs.map +1 -1
- package/dist/cjs/hooks/useLongPress/useLongPress.cjs +1 -1
- package/dist/cjs/hooks/useLongPress/useLongPress.cjs.map +1 -1
- package/dist/cjs/hooks/useSpeechRecognition/useSpeechRecognition.cjs +1 -1
- package/dist/cjs/hooks/useSpeechRecognition/useSpeechRecognition.cjs.map +1 -1
- package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs +1 -1
- package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs.map +1 -1
- package/dist/cjs/hooks/useStorage/useStorage.cjs +1 -1
- package/dist/cjs/hooks/useStorage/useStorage.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowFocus/useWindowFocus.cjs +1 -1
- package/dist/cjs/hooks/useWindowFocus/useWindowFocus.cjs.map +1 -1
- package/dist/esm/hooks/useDropZone/useDropZone.mjs.map +1 -1
- package/dist/esm/hooks/useEventSource/useEventSource.mjs +33 -34
- package/dist/esm/hooks/useEventSource/useEventSource.mjs.map +1 -1
- package/dist/esm/hooks/useField/useField.mjs +2 -1
- package/dist/esm/hooks/useField/useField.mjs.map +1 -1
- package/dist/esm/hooks/useLongPress/useLongPress.mjs +19 -19
- package/dist/esm/hooks/useLongPress/useLongPress.mjs.map +1 -1
- package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs +20 -21
- package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs.map +1 -1
- package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs +51 -36
- package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs.map +1 -1
- package/dist/esm/hooks/useStorage/useStorage.mjs +39 -36
- package/dist/esm/hooks/useStorage/useStorage.mjs.map +1 -1
- package/dist/esm/hooks/useWindowFocus/useWindowFocus.mjs +1 -1
- package/dist/esm/hooks/useWindowFocus/useWindowFocus.mjs.map +1 -1
- package/dist/types/hooks/useEventSource/useEventSource.d.ts +2 -2
- package/dist/types/hooks/useField/useField.d.ts +3 -0
- package/dist/types/hooks/useSpeechSynthesis/useSpeechSynthesis.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWindowFocus.mjs","sources":["../../../../src/hooks/useWindowFocus/useWindowFocus.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/**\n * @name useWindowFocus\n * @description - Hook that provides the current focus state of the window\n * @category Elements\n * @usage low\n *\n * @returns {boolean} The current focus state of the window\n *\n * @example\n * const focused = useWindowFocus();\n *\n * @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useWindowFocus.html}\n */\nexport const useWindowFocus = () => {\n const [focused, setFocused] = useState(false);\n\n useEffect(() => {\n const onFocus = () => setFocused(true);\n const onBlur = () => setFocused(false);\n\n window.addEventListener('focus', onFocus);\n window.addEventListener('blur', onBlur);\n\n return () => {\n window.removeEventListener('focus', onFocus);\n window.removeEventListener('blur', onBlur);\n };\n });\n\n return focused;\n};\n"],"names":["useWindowFocus","focused","setFocused","useState","useEffect","onFocus","onBlur"],"mappings":";AAeO,MAAMA,IAAiB,MAAM;AAClC,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAS,EAAK;AAE5C,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAU,MAAMH,EAAW,EAAI,GAC/BI,IAAS,MAAMJ,EAAW,EAAK;AAErC,kBAAO,iBAAiB,SAASG,CAAO,GACxC,OAAO,iBAAiB,QAAQC,CAAM,GAE/B,MAAM;AACX,aAAO,oBAAoB,SAASD,CAAO,GAC3C,OAAO,oBAAoB,QAAQC,CAAM;AAAA,IAAA;AAAA,EAC3C,
|
|
1
|
+
{"version":3,"file":"useWindowFocus.mjs","sources":["../../../../src/hooks/useWindowFocus/useWindowFocus.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/**\n * @name useWindowFocus\n * @description - Hook that provides the current focus state of the window\n * @category Elements\n * @usage low\n *\n * @returns {boolean} The current focus state of the window\n *\n * @example\n * const focused = useWindowFocus();\n *\n * @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useWindowFocus.html}\n */\nexport const useWindowFocus = () => {\n const [focused, setFocused] = useState(false);\n\n useEffect(() => {\n const onFocus = () => setFocused(true);\n const onBlur = () => setFocused(false);\n\n window.addEventListener('focus', onFocus);\n window.addEventListener('blur', onBlur);\n\n return () => {\n window.removeEventListener('focus', onFocus);\n window.removeEventListener('blur', onBlur);\n };\n }, []);\n\n return focused;\n};\n"],"names":["useWindowFocus","focused","setFocused","useState","useEffect","onFocus","onBlur"],"mappings":";AAeO,MAAMA,IAAiB,MAAM;AAClC,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAS,EAAK;AAE5C,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAU,MAAMH,EAAW,EAAI,GAC/BI,IAAS,MAAMJ,EAAW,EAAK;AAErC,kBAAO,iBAAiB,SAASG,CAAO,GACxC,OAAO,iBAAiB,QAAQC,CAAM,GAE/B,MAAM;AACX,aAAO,oBAAoB,SAASD,CAAO,GAC3C,OAAO,oBAAoB,QAAQC,CAAM;AAAA,IAAA;AAAA,EAC3C,GACC,EAAE,GAEEL;AACT;"}
|
|
@@ -22,7 +22,7 @@ interface UseEventSourceReturn<Data = any> {
|
|
|
22
22
|
instance?: EventSource;
|
|
23
23
|
isConnecting: boolean;
|
|
24
24
|
isError: boolean;
|
|
25
|
-
|
|
25
|
+
opened: boolean;
|
|
26
26
|
/** Closes the EventSource connection gracefully */
|
|
27
27
|
close: () => void;
|
|
28
28
|
/** Reopen the EventSource connection */
|
|
@@ -42,7 +42,7 @@ interface UseEventSourceReturn<Data = any> {
|
|
|
42
42
|
* @returns {UseEventSourceReturn<Data>} The EventSource state and controls
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
|
-
* const { instance, data,
|
|
45
|
+
* const { instance, data, connecting, opened, isError, close, open } = useEventSource('url', ['message']);
|
|
46
46
|
*/
|
|
47
47
|
export declare const useEventSource: <QueryData = any, Data = QueryData>(url: string | URL, events?: string[], options?: UseEventSourceOptions<QueryData, Data>) => UseEventSourceReturn<Data>;
|
|
48
48
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
1
2
|
/** The use field params type */
|
|
2
3
|
export interface UseFieldParams<Value> {
|
|
3
4
|
/** The auto focus */
|
|
@@ -51,6 +52,8 @@ export interface UseFieldReturn<Value> {
|
|
|
51
52
|
dirty: boolean;
|
|
52
53
|
/** The error state */
|
|
53
54
|
error?: string;
|
|
55
|
+
/** The input ref */
|
|
56
|
+
ref: RefObject<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | null>;
|
|
54
57
|
/** The set error function */
|
|
55
58
|
touched: boolean;
|
|
56
59
|
/** The set error function */
|
|
@@ -26,7 +26,7 @@ export interface UseSpeechSynthesisReturn {
|
|
|
26
26
|
/** Indicates if the SpeechSynthesis API is supported in the current environment. */
|
|
27
27
|
supported: boolean;
|
|
28
28
|
/** The SpeechSynthesisUtterance instance. */
|
|
29
|
-
utterance: SpeechSynthesisUtterance |
|
|
29
|
+
utterance: SpeechSynthesisUtterance | undefined;
|
|
30
30
|
/** Function to pause speech synthesis. */
|
|
31
31
|
pause: () => void;
|
|
32
32
|
/** Function to resume speech synthesis. */
|