@siberiacancode/reactuse 0.3.4 → 0.3.6
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/helpers/createStore/createStore.cjs +1 -1
- package/dist/cjs/helpers/createStore/createStore.cjs.map +1 -1
- package/dist/cjs/hooks/useBatchedCallback/useBatchedCallback.cjs +2 -0
- package/dist/cjs/hooks/useBatchedCallback/useBatchedCallback.cjs.map +1 -0
- package/dist/cjs/hooks/useDropZone/useDropZone.cjs.map +1 -1
- package/dist/cjs/hooks/useEventListener/useEventListener.cjs +1 -1
- package/dist/cjs/hooks/useEventListener/useEventListener.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/useOtpCredential/useOtpCredential.cjs +1 -1
- package/dist/cjs/hooks/useOtpCredential/useOtpCredential.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/useTextareaAutosize/useTextareaAutosize.cjs +1 -1
- package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.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/cjs/index.cjs +1 -1
- package/dist/esm/helpers/createStore/createStore.mjs +10 -9
- package/dist/esm/helpers/createStore/createStore.mjs.map +1 -1
- package/dist/esm/hooks/useBatchedCallback/useBatchedCallback.mjs +20 -0
- package/dist/esm/hooks/useBatchedCallback/useBatchedCallback.mjs.map +1 -0
- package/dist/esm/hooks/useDropZone/useDropZone.mjs.map +1 -1
- package/dist/esm/hooks/useEventListener/useEventListener.mjs +8 -8
- package/dist/esm/hooks/useEventListener/useEventListener.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/useOtpCredential/useOtpCredential.mjs +14 -12
- package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs.map +1 -1
- package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs +19 -22
- 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/useTextareaAutosize/useTextareaAutosize.mjs +36 -41
- package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.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/esm/index.mjs +53 -51
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/helpers/createStore/createStore.d.ts +5 -12
- package/dist/types/hooks/useBatchedCallback/useBatchedCallback.d.ts +19 -0
- package/dist/types/hooks/useEventSource/useEventSource.d.ts +2 -2
- package/dist/types/hooks/useField/useField.d.ts +3 -0
- package/dist/types/hooks/useOtpCredential/useOtpCredential.d.ts +2 -3
- package/dist/types/hooks/useSpeechRecognition/useSpeechRecognition.d.ts +1 -1
- package/dist/types/hooks/useSpeechSynthesis/useSpeechSynthesis.d.ts +1 -1
- package/dist/types/hooks/useTextareaAutosize/useTextareaAutosize.d.ts +10 -1
- package/dist/types/hooks/utilities.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,58 +1,53 @@
|
|
|
1
|
-
import { useState as
|
|
1
|
+
import { useState as y, useRef as v, useEffect as R } from "react";
|
|
2
2
|
import { useRefState as V } from "../useRefState/useRefState.mjs";
|
|
3
3
|
import { isTarget as f } from "../../utils/helpers/isTarget.mjs";
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const e =
|
|
4
|
+
const p = ((...t) => {
|
|
5
|
+
const n = f(t[0]) ? t[0] : void 0, o = n ? typeof t[1] == "object" ? t[1] : { initialValue: t[1] } : typeof t[0] == "object" ? t[0] : { initialValue: t[0] }, [g, h] = y(o?.initialValue ?? ""), s = V(), l = v(null), m = v(0), a = () => {
|
|
6
|
+
const e = l.current;
|
|
7
7
|
if (!e) return;
|
|
8
|
-
const
|
|
8
|
+
const i = e.style.minHeight, u = e.style.maxHeight;
|
|
9
9
|
e.style.height = "auto", e.style.minHeight = "auto", e.style.maxHeight = "none";
|
|
10
|
-
const
|
|
11
|
-
e.style.height = `${
|
|
10
|
+
const r = e.scrollHeight;
|
|
11
|
+
e.style.height = `${r}px`, e.style.minHeight = i, e.style.maxHeight = u, r !== m.current && o?.onResize?.(), m.current = r;
|
|
12
|
+
}, c = (e) => {
|
|
13
|
+
h(e);
|
|
14
|
+
const i = l.current;
|
|
15
|
+
i && (i.value = e, requestAnimationFrame(() => {
|
|
16
|
+
a();
|
|
17
|
+
}));
|
|
12
18
|
};
|
|
13
|
-
|
|
14
|
-
if (!
|
|
15
|
-
const e =
|
|
19
|
+
R(() => {
|
|
20
|
+
if (!n && !s.state) return;
|
|
21
|
+
const e = n ? f.getElement(n) : s.current;
|
|
16
22
|
if (!e) return;
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
c(
|
|
21
|
-
|
|
23
|
+
l.current = e, o?.initialValue && (e.value = o.initialValue), a();
|
|
24
|
+
const i = (r) => {
|
|
25
|
+
const H = r.target.value;
|
|
26
|
+
c(H), requestAnimationFrame(() => {
|
|
27
|
+
a();
|
|
22
28
|
});
|
|
23
|
-
},
|
|
29
|
+
}, u = () => {
|
|
24
30
|
requestAnimationFrame(() => {
|
|
25
|
-
|
|
31
|
+
a();
|
|
26
32
|
});
|
|
27
33
|
};
|
|
28
|
-
return e.addEventListener("input",
|
|
29
|
-
e.removeEventListener("input",
|
|
34
|
+
return e.addEventListener("input", i), e.addEventListener("resize", u), () => {
|
|
35
|
+
e.removeEventListener("input", i), e.removeEventListener("resize", u);
|
|
30
36
|
};
|
|
31
|
-
}, [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const m = (e) => {
|
|
38
|
-
c(e);
|
|
39
|
-
const n = u.current;
|
|
40
|
-
n && (n.value = e, requestAnimationFrame(() => {
|
|
41
|
-
s();
|
|
42
|
-
}));
|
|
43
|
-
}, h = () => c("");
|
|
44
|
-
return t ? {
|
|
45
|
-
value: a,
|
|
46
|
-
setValue: m,
|
|
47
|
-
clear: h
|
|
37
|
+
}, [n, s.state, f.getRefState(n)]);
|
|
38
|
+
const x = () => h("");
|
|
39
|
+
return n ? {
|
|
40
|
+
value: g,
|
|
41
|
+
set: c,
|
|
42
|
+
clear: x
|
|
48
43
|
} : {
|
|
49
|
-
ref:
|
|
50
|
-
value:
|
|
51
|
-
|
|
52
|
-
clear:
|
|
44
|
+
ref: s,
|
|
45
|
+
value: g,
|
|
46
|
+
set: c,
|
|
47
|
+
clear: x
|
|
53
48
|
};
|
|
54
49
|
});
|
|
55
50
|
export {
|
|
56
|
-
|
|
51
|
+
p as useTextareaAutosize
|
|
57
52
|
};
|
|
58
53
|
//# sourceMappingURL=useTextareaAutosize.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextareaAutosize.mjs","sources":["../../../../src/hooks/useTextareaAutosize/useTextareaAutosize.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The use textarea autosize options */\nexport interface UseTextareaAutosizeOptions {\n /** The initial value for the textarea */\n initialValue?: string;\n /** Callback function called when the textarea size changes */\n onResize?: () => void;\n}\n\n/** The use textarea autosize return type */\nexport interface UseTextareaAutosizeReturn {\n /** The current value of the textarea */\n value: string;\n /** Function to clear the textarea value */\n clear: () => void;\n /** Function to set the textarea value */\n
|
|
1
|
+
{"version":3,"file":"useTextareaAutosize.mjs","sources":["../../../../src/hooks/useTextareaAutosize/useTextareaAutosize.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The use textarea autosize options */\nexport interface UseTextareaAutosizeOptions {\n /** The initial value for the textarea */\n initialValue?: string;\n /** Callback function called when the textarea size changes */\n onResize?: () => void;\n}\n\n/** The use textarea autosize return type */\nexport interface UseTextareaAutosizeReturn {\n /** The current value of the textarea */\n value: string;\n /** Function to clear the textarea value */\n clear: () => void;\n /** Function to set the textarea value */\n set: (value: string) => void;\n}\n\nexport interface UseTextareaAutosize {\n (target: HookTarget, options?: UseTextareaAutosizeOptions): UseTextareaAutosizeReturn;\n\n (target: HookTarget, initialValue: string): UseTextareaAutosizeReturn;\n\n <Target extends HTMLTextAreaElement = HTMLTextAreaElement>(\n initialValue: string,\n target?: never\n ): UseTextareaAutosizeReturn & {\n ref: StateRef<Target>;\n };\n\n <Target extends HTMLTextAreaElement = HTMLTextAreaElement>(\n options?: UseTextareaAutosizeOptions,\n target?: never\n ): UseTextareaAutosizeReturn & {\n ref: StateRef<Target>;\n };\n}\n\n/**\n * @name useTextareaAutosize\n * @description - Hook that automatically adjusts textarea height based on content\n * @category Elements\n * @usage medium\n *\n * @overload\n * @param {HookTarget} target The target textarea element\n * @param {string} [options.initialValue] The initial value for the textarea\n * @param {Function} [options.onResize] Callback function called when the textarea size changes\n * @returns {UseTextareaAutosizeReturn} An object containing value, setValue and clear\n *\n * @example\n * const { value, setValue, clear } = useTextareaAutosize(ref);\n *\n * @overload\n * @param {HookTarget} target The target textarea element\n * @param {string} initialValue The initial value for the textarea\n * @returns {UseTextareaAutosizeReturn} An object containing value, setValue and clear\n *\n * @example\n * const { value, setValue, clear } = useTextareaAutosize(ref, 'initial');\n *\n * @overload\n * @template Target The textarea element type\n * @param {string} initialValue The initial value for the textarea\n * @returns {UseTextareaAutosizeReturn & { ref: StateRef<Target> }} An object containing ref, value, setValue and clear\n *\n * @example\n * const { ref, value, setValue, clear } = useTextareaAutosize('initial');\n *\n * @overload\n * @template Target The textarea element type\n * @param {string} [options.initialValue] The initial value for the textarea\n * @param {Function} [options.onResize] Callback function called when the textarea size changes\n * @returns {UseTextareaAutosizeReturn & { ref: StateRef<Target> }} An object containing ref, value, setValue and clear\n *\n * @example\n * const { ref, value, setValue, clear } = useTextareaAutosize();\n */\nexport const useTextareaAutosize = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n\n const options = (\n target\n ? typeof params[1] === 'object'\n ? params[1]\n : { initialValue: params[1] }\n : typeof params[0] === 'object'\n ? params[0]\n : { initialValue: params[0] }\n ) as UseTextareaAutosizeOptions | undefined;\n\n const [value, setValue] = useState(options?.initialValue ?? '');\n const internalRef = useRefState<HTMLTextAreaElement>();\n const textareaRef = useRef<HTMLTextAreaElement | null>(null);\n const scrollHeightRef = useRef(0);\n\n const onTextareaResize = () => {\n const textarea = textareaRef.current;\n if (!textarea) return;\n\n const originalMinHeight = textarea.style.minHeight;\n const originalMaxHeight = textarea.style.maxHeight;\n\n textarea.style.height = 'auto';\n textarea.style.minHeight = 'auto';\n textarea.style.maxHeight = 'none';\n\n const scrollHeight = textarea.scrollHeight;\n\n textarea.style.height = `${scrollHeight}px`;\n textarea.style.minHeight = originalMinHeight;\n textarea.style.maxHeight = originalMaxHeight;\n\n if (scrollHeight !== scrollHeightRef.current) options?.onResize?.();\n scrollHeightRef.current = scrollHeight;\n };\n\n const setTextareaValue = (newValue: string) => {\n setValue(newValue);\n const textarea = textareaRef.current;\n if (!textarea) return;\n textarea.value = newValue;\n requestAnimationFrame(() => {\n onTextareaResize();\n });\n };\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = (\n target ? isTarget.getElement(target) : internalRef.current\n ) as HTMLTextAreaElement;\n if (!element) return;\n\n textareaRef.current = element;\n if (options?.initialValue) element.value = options.initialValue;\n\n onTextareaResize();\n\n const onInput = (event: InputEvent) => {\n const newValue = (event.target as HTMLTextAreaElement).value;\n setTextareaValue(newValue);\n\n requestAnimationFrame(() => {\n onTextareaResize();\n });\n };\n\n const onResize = () => {\n requestAnimationFrame(() => {\n onTextareaResize();\n });\n };\n\n element.addEventListener('input', onInput as EventListener);\n element.addEventListener('resize', onResize as EventListener);\n\n return () => {\n element.removeEventListener('input', onInput as EventListener);\n element.removeEventListener('resize', onResize as EventListener);\n };\n }, [target, internalRef.state, isTarget.getRefState(target)]);\n\n const clear = () => setValue('');\n\n if (target)\n return {\n value,\n set: setTextareaValue,\n clear\n };\n return {\n ref: internalRef,\n value,\n set: setTextareaValue,\n clear\n };\n}) as UseTextareaAutosize;\n"],"names":["useTextareaAutosize","params","target","isTarget","options","value","setValue","useState","internalRef","useRefState","textareaRef","useRef","scrollHeightRef","onTextareaResize","textarea","originalMinHeight","originalMaxHeight","scrollHeight","setTextareaValue","newValue","useEffect","element","onInput","event","onResize","clear"],"mappings":";;;AAwFO,MAAMA,KAAuB,IAAIC,MAAkB;AACxD,QAAMC,IAAUC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAE5CG,IACJF,IACI,OAAOD,EAAO,CAAC,KAAM,WACnBA,EAAO,CAAC,IACR,EAAE,cAAcA,EAAO,CAAC,EAAA,IAC1B,OAAOA,EAAO,CAAC,KAAM,WACnBA,EAAO,CAAC,IACR,EAAE,cAAcA,EAAO,CAAC,EAAA,GAG1B,CAACI,GAAOC,CAAQ,IAAIC,EAASH,GAAS,gBAAgB,EAAE,GACxDI,IAAcC,EAAA,GACdC,IAAcC,EAAmC,IAAI,GACrDC,IAAkBD,EAAO,CAAC,GAE1BE,IAAmB,MAAM;AAC7B,UAAMC,IAAWJ,EAAY;AAC7B,QAAI,CAACI,EAAU;AAEf,UAAMC,IAAoBD,EAAS,MAAM,WACnCE,IAAoBF,EAAS,MAAM;AAEzC,IAAAA,EAAS,MAAM,SAAS,QACxBA,EAAS,MAAM,YAAY,QAC3BA,EAAS,MAAM,YAAY;AAE3B,UAAMG,IAAeH,EAAS;AAE9B,IAAAA,EAAS,MAAM,SAAS,GAAGG,CAAY,MACvCH,EAAS,MAAM,YAAYC,GAC3BD,EAAS,MAAM,YAAYE,GAEvBC,MAAiBL,EAAgB,WAASR,GAAS,WAAA,GACvDQ,EAAgB,UAAUK;AAAA,EAAA,GAGtBC,IAAmB,CAACC,MAAqB;AAC7C,IAAAb,EAASa,CAAQ;AACjB,UAAML,IAAWJ,EAAY;AAC7B,IAAKI,MACLA,EAAS,QAAQK,GACjB,sBAAsB,MAAM;AAC1B,MAAAN,EAAA;AAAA,IAAiB,CAClB;AAAA,EAAA;AAGH,EAAAO,EAAU,MAAM;AACd,QAAI,CAAClB,KAAU,CAACM,EAAY,MAAO;AAEnC,UAAMa,IACJnB,IAASC,EAAS,WAAWD,CAAM,IAAIM,EAAY;AAErD,QAAI,CAACa,EAAS;AAEd,IAAAX,EAAY,UAAUW,GAClBjB,GAAS,iBAAciB,EAAQ,QAAQjB,EAAQ,eAEnDS,EAAA;AAEA,UAAMS,IAAU,CAACC,MAAsB;AACrC,YAAMJ,IAAYI,EAAM,OAA+B;AACvD,MAAAL,EAAiBC,CAAQ,GAEzB,sBAAsB,MAAM;AAC1B,QAAAN,EAAA;AAAA,MAAiB,CAClB;AAAA,IAAA,GAGGW,IAAW,MAAM;AACrB,4BAAsB,MAAM;AAC1B,QAAAX,EAAA;AAAA,MAAiB,CAClB;AAAA,IAAA;AAGH,WAAAQ,EAAQ,iBAAiB,SAASC,CAAwB,GAC1DD,EAAQ,iBAAiB,UAAUG,CAAyB,GAErD,MAAM;AACX,MAAAH,EAAQ,oBAAoB,SAASC,CAAwB,GAC7DD,EAAQ,oBAAoB,UAAUG,CAAyB;AAAA,IAAA;AAAA,EACjE,GACC,CAACtB,GAAQM,EAAY,OAAOL,EAAS,YAAYD,CAAM,CAAC,CAAC;AAE5D,QAAMuB,IAAQ,MAAMnB,EAAS,EAAE;AAE/B,SAAIJ,IACK;AAAA,IACL,OAAAG;AAAA,IACA,KAAKa;AAAA,IACL,OAAAO;AAAA,EAAA,IAEG;AAAA,IACL,KAAKjB;AAAA,IACL,OAAAH;AAAA,IACA,KAAKa;AAAA,IACL,OAAAO;AAAA,EAAA;AAEJ;"}
|
|
@@ -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;"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { useBluetooth as I } from "./hooks/useBluetooth/useBluetooth.mjs";
|
|
|
13
13
|
import { useBroadcastChannel as O } from "./hooks/useBroadcastChannel/useBroadcastChannel.mjs";
|
|
14
14
|
import { useClipboard as h } from "./hooks/useClipboard/useClipboard.mjs";
|
|
15
15
|
import { useCopy as _ } from "./hooks/useCopy/useCopy.mjs";
|
|
16
|
-
import { useCssVar as
|
|
16
|
+
import { useCssVar as D } from "./hooks/useCssVar/useCssVar.mjs";
|
|
17
17
|
import { useDisplayMedia as M } from "./hooks/useDisplayMedia/useDisplayMedia.mjs";
|
|
18
18
|
import { useDocumentTitle as B } from "./hooks/useDocumentTitle/useDocumentTitle.mjs";
|
|
19
19
|
import { useEventSource as F } from "./hooks/useEventSource/useEventSource.mjs";
|
|
@@ -38,7 +38,7 @@ import { getSpeechRecognition as Ae, useSpeechRecognition as Ie } from "./hooks/
|
|
|
38
38
|
import { useSpeechSynthesis as Oe } from "./hooks/useSpeechSynthesis/useSpeechSynthesis.mjs";
|
|
39
39
|
import { useVibrate as he } from "./hooks/useVibrate/useVibrate.mjs";
|
|
40
40
|
import { useVirtualKeyboard as _e } from "./hooks/useVirtualKeyboard/useVirtualKeyboard.mjs";
|
|
41
|
-
import { useWakeLock as
|
|
41
|
+
import { useWakeLock as De } from "./hooks/useWakeLock/useWakeLock.mjs";
|
|
42
42
|
import { useWebSocket as Me } from "./hooks/useWebSocket/useWebSocket.mjs";
|
|
43
43
|
import { useLogger as Be } from "./hooks/useLogger/useLogger.mjs";
|
|
44
44
|
import { useRenderCount as Fe } from "./hooks/useRenderCount/useRenderCount.mjs";
|
|
@@ -62,7 +62,7 @@ import { useSticky as Io } from "./hooks/useSticky/useSticky.mjs";
|
|
|
62
62
|
import { useTextareaAutosize as Oo } from "./hooks/useTextareaAutosize/useTextareaAutosize.mjs";
|
|
63
63
|
import { useTextDirection as ho } from "./hooks/useTextDirection/useTextDirection.mjs";
|
|
64
64
|
import { useFul as _o } from "./hooks/useFul/useFul.mjs";
|
|
65
|
-
import { useLess as
|
|
65
|
+
import { useLess as Do } from "./hooks/useLess/useLess.mjs";
|
|
66
66
|
import { useOnce as Mo } from "./hooks/useOnce/useOnce.mjs";
|
|
67
67
|
import { useAsyncEffect as Bo } from "./hooks/useAsyncEffect/useAsyncEffect.mjs";
|
|
68
68
|
import { useDidUpdate as Fo } from "./hooks/useDidUpdate/useDidUpdate.mjs";
|
|
@@ -83,7 +83,7 @@ import { isHotkeyMatch as Pr, useHotkeys as Ar } from "./hooks/useHotkeys/useHot
|
|
|
83
83
|
import { useIdle as yr } from "./hooks/useIdle/useIdle.mjs";
|
|
84
84
|
import { useInfiniteScroll as kr } from "./hooks/useInfiniteScroll/useInfiniteScroll.mjs";
|
|
85
85
|
import { useIntersectionObserver as vr } from "./hooks/useIntersectionObserver/useIntersectionObserver.mjs";
|
|
86
|
-
import { useKeyboard as
|
|
86
|
+
import { useKeyboard as br } from "./hooks/useKeyboard/useKeyboard.mjs";
|
|
87
87
|
import { useKeyPress as Lr } from "./hooks/useKeyPress/useKeyPress.mjs";
|
|
88
88
|
import { useKeyPressEvent as Nr } from "./hooks/useKeyPressEvent/useKeyPressEvent.mjs";
|
|
89
89
|
import { useKeysPressed as Kr } from "./hooks/useKeysPressed/useKeysPressed.mjs";
|
|
@@ -108,7 +108,7 @@ import { scrollTo as dt, useWindowScroll as Ct } from "./hooks/useWindowScroll/u
|
|
|
108
108
|
import { useWindowSize as At } from "./hooks/useWindowSize/useWindowSize.mjs";
|
|
109
109
|
import { useBoolean as yt } from "./hooks/useBoolean/useBoolean.mjs";
|
|
110
110
|
import { useControllableState as kt } from "./hooks/useControllableState/useControllableState.mjs";
|
|
111
|
-
import { COOKIE_EVENT as vt, dispatchCookieEvent as _t, getCookie as
|
|
111
|
+
import { COOKIE_EVENT as vt, dispatchCookieEvent as _t, getCookie as bt, getCookies as Dt, removeCookie as Lt, removeCookieItem as Mt, setCookie as Nt, setCookieItem as Bt, useCookie as Kt } from "./hooks/useCookie/useCookie.mjs";
|
|
112
112
|
import { clearCookies as Ut, useCookies as Vt } from "./hooks/useCookies/useCookies.mjs";
|
|
113
113
|
import { useCounter as wt } from "./hooks/useCounter/useCounter.mjs";
|
|
114
114
|
import { useDefault as zt } from "./hooks/useDefault/useDefault.mjs";
|
|
@@ -128,7 +128,7 @@ import { useSet as ds } from "./hooks/useSet/useSet.mjs";
|
|
|
128
128
|
import { stateHistoryReducer as Ps, useStateHistory as As } from "./hooks/useStateHistory/useStateHistory.mjs";
|
|
129
129
|
import { useStep as ys } from "./hooks/useStep/useStep.mjs";
|
|
130
130
|
import { STORAGE_EVENT as ks, dispatchStorageEvent as hs, useStorage as vs } from "./hooks/useStorage/useStorage.mjs";
|
|
131
|
-
import { useToggle as
|
|
131
|
+
import { useToggle as bs } from "./hooks/useToggle/useToggle.mjs";
|
|
132
132
|
import { URL_SEARCH_PARAMS_EVENT as Ls, createQueryString as Ms, dispatchUrlSearchParamsEvent as Ns, getUrlSearchParams as Bs, useUrlSearchParam as Ks } from "./hooks/useUrlSearchParam/useUrlSearchParam.mjs";
|
|
133
133
|
import { useUrlSearchParams as Us } from "./hooks/useUrlSearchParams/useUrlSearchParams.mjs";
|
|
134
134
|
import { useWizard as Hs } from "./hooks/useWizard/useWizard.mjs";
|
|
@@ -144,23 +144,24 @@ import { usePreferredContrast as pu } from "./hooks/usePreferredContrast/usePref
|
|
|
144
144
|
import { usePreferredDark as xu } from "./hooks/usePreferredDark/usePreferredDark.mjs";
|
|
145
145
|
import { usePreferredLanguages as iu } from "./hooks/usePreferredLanguages/usePreferredLanguages.mjs";
|
|
146
146
|
import { usePreferredReducedMotion as cu } from "./hooks/usePreferredReducedMotion/usePreferredReducedMotion.mjs";
|
|
147
|
-
import {
|
|
148
|
-
import {
|
|
149
|
-
import {
|
|
150
|
-
import {
|
|
151
|
-
import {
|
|
152
|
-
import {
|
|
153
|
-
import {
|
|
154
|
-
import {
|
|
155
|
-
import {
|
|
156
|
-
import {
|
|
157
|
-
import {
|
|
158
|
-
import {
|
|
159
|
-
import {
|
|
160
|
-
import {
|
|
161
|
-
import {
|
|
162
|
-
import {
|
|
163
|
-
import {
|
|
147
|
+
import { useBatchedCallback as Su } from "./hooks/useBatchedCallback/useBatchedCallback.mjs";
|
|
148
|
+
import { useConst as Tu } from "./hooks/useConst/useConst.mjs";
|
|
149
|
+
import { useDebounceCallback as Ru } from "./hooks/useDebounceCallback/useDebounceCallback.mjs";
|
|
150
|
+
import { useDebounceState as Cu } from "./hooks/useDebounceState/useDebounceState.mjs";
|
|
151
|
+
import { useDebounceValue as Au } from "./hooks/useDebounceValue/useDebounceValue.mjs";
|
|
152
|
+
import { useEvent as yu } from "./hooks/useEvent/useEvent.mjs";
|
|
153
|
+
import { useLastChanged as ku } from "./hooks/useLastChanged/useLastChanged.mjs";
|
|
154
|
+
import { useLatest as vu } from "./hooks/useLatest/useLatest.mjs";
|
|
155
|
+
import { usePrevious as bu } from "./hooks/usePrevious/usePrevious.mjs";
|
|
156
|
+
import { useThrottleCallback as Lu } from "./hooks/useThrottleCallback/useThrottleCallback.mjs";
|
|
157
|
+
import { useThrottleState as Nu } from "./hooks/useThrottleState/useThrottleState.mjs";
|
|
158
|
+
import { useThrottleValue as Ku } from "./hooks/useThrottleValue/useThrottleValue.mjs";
|
|
159
|
+
import { copy as Uu, legacyCopyToClipboard as Vu } from "./utils/helpers/copy.mjs";
|
|
160
|
+
import { debounce as wu } from "./utils/helpers/debounce.mjs";
|
|
161
|
+
import { getDate as zu } from "./utils/helpers/getDate.mjs";
|
|
162
|
+
import { getRetry as Qu } from "./utils/helpers/getRetry.mjs";
|
|
163
|
+
import { getRefState as qu, isTarget as Zu, target as ju, targetSymbol as Ju } from "./utils/helpers/isTarget.mjs";
|
|
164
|
+
import { throttle as $u } from "./utils/helpers/throttle.mjs";
|
|
164
165
|
export {
|
|
165
166
|
Jo as BREAKPOINTS_ANT_DESIGN,
|
|
166
167
|
Yo as BREAKPOINTS_BOOTSTRAP_V5,
|
|
@@ -181,33 +182,33 @@ export {
|
|
|
181
182
|
Ls as URL_SEARCH_PARAMS_EVENT,
|
|
182
183
|
us as assignRef,
|
|
183
184
|
Ut as clearCookies,
|
|
184
|
-
|
|
185
|
+
Uu as copy,
|
|
185
186
|
r as createContext,
|
|
186
187
|
s as createEventEmitter,
|
|
187
188
|
Ms as createQueryString,
|
|
188
189
|
m as createReactiveContext,
|
|
189
190
|
Ss as createRefState,
|
|
190
191
|
f as createStore,
|
|
191
|
-
|
|
192
|
+
wu as debounce,
|
|
192
193
|
Qo as deepEqual,
|
|
193
194
|
_t as dispatchCookieEvent,
|
|
194
195
|
hs as dispatchStorageEvent,
|
|
195
196
|
Ns as dispatchUrlSearchParamsEvent,
|
|
196
197
|
se as getConnection,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
bt as getCookie,
|
|
199
|
+
Dt as getCookies,
|
|
200
|
+
zu as getDate,
|
|
200
201
|
jt as getHash,
|
|
201
202
|
ru as getOperatingSystem,
|
|
202
203
|
it as getRangesSelection,
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
qu as getRefState,
|
|
205
|
+
Qu as getRetry,
|
|
205
206
|
Ae as getSpeechRecognition,
|
|
206
207
|
Js as getTimeFromSeconds,
|
|
207
208
|
Bs as getUrlSearchParams,
|
|
208
209
|
Pr as isHotkeyMatch,
|
|
209
|
-
|
|
210
|
-
|
|
210
|
+
Zu as isTarget,
|
|
211
|
+
Vu as legacyCopyToClipboard,
|
|
211
212
|
q as mapGamepadToXbox360Controller,
|
|
212
213
|
ms as mergeRefs,
|
|
213
214
|
Lt as removeCookie,
|
|
@@ -216,15 +217,16 @@ export {
|
|
|
216
217
|
Nt as setCookie,
|
|
217
218
|
Bt as setCookieItem,
|
|
218
219
|
Ps as stateHistoryReducer,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
ju as target,
|
|
221
|
+
Ju as targetSymbol,
|
|
222
|
+
$u as throttle,
|
|
222
223
|
$ as timeRangeToArray,
|
|
223
224
|
ze as useActiveElement,
|
|
224
225
|
a as useAsync,
|
|
225
226
|
Bo as useAsyncEffect,
|
|
226
227
|
d as useAudio,
|
|
227
228
|
Qe as useAutoScroll,
|
|
229
|
+
Su as useBatchedCallback,
|
|
228
230
|
P as useBattery,
|
|
229
231
|
I as useBluetooth,
|
|
230
232
|
yt as useBoolean,
|
|
@@ -233,16 +235,16 @@ export {
|
|
|
233
235
|
eu as useBrowserLanguage,
|
|
234
236
|
qe as useClickOutside,
|
|
235
237
|
h as useClipboard,
|
|
236
|
-
|
|
238
|
+
Tu as useConst,
|
|
237
239
|
kt as useControllableState,
|
|
238
240
|
Kt as useCookie,
|
|
239
241
|
Vt as useCookies,
|
|
240
242
|
_ as useCopy,
|
|
241
243
|
wt as useCounter,
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
D as useCssVar,
|
|
245
|
+
Ru as useDebounceCallback,
|
|
246
|
+
Cu as useDebounceState,
|
|
247
|
+
Au as useDebounceValue,
|
|
246
248
|
zt as useDefault,
|
|
247
249
|
fr as useDeviceMotion,
|
|
248
250
|
ar as useDeviceOrientation,
|
|
@@ -256,7 +258,7 @@ export {
|
|
|
256
258
|
Je as useDoubleClick,
|
|
257
259
|
$e as useDropZone,
|
|
258
260
|
gr as useElementSize,
|
|
259
|
-
|
|
261
|
+
yu as useEvent,
|
|
260
262
|
dr as useEventListener,
|
|
261
263
|
F as useEventSource,
|
|
262
264
|
V as useEyeDropper,
|
|
@@ -282,11 +284,11 @@ export {
|
|
|
282
284
|
wo as useIsomorphicLayoutEffect,
|
|
283
285
|
Lr as useKeyPress,
|
|
284
286
|
Nr as useKeyPressEvent,
|
|
285
|
-
|
|
287
|
+
br as useKeyboard,
|
|
286
288
|
Kr as useKeysPressed,
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
289
|
+
ku as useLastChanged,
|
|
290
|
+
vu as useLatest,
|
|
291
|
+
Do as useLess,
|
|
290
292
|
$t as useList,
|
|
291
293
|
os as useLocalStorage,
|
|
292
294
|
n as useLockCallback,
|
|
@@ -324,7 +326,7 @@ export {
|
|
|
324
326
|
xu as usePreferredDark,
|
|
325
327
|
iu as usePreferredLanguages,
|
|
326
328
|
cu as usePreferredReducedMotion,
|
|
327
|
-
|
|
329
|
+
bu as usePrevious,
|
|
328
330
|
g as useQuery,
|
|
329
331
|
is as useQueue,
|
|
330
332
|
Re as useRaf,
|
|
@@ -353,20 +355,20 @@ export {
|
|
|
353
355
|
ho as useTextDirection,
|
|
354
356
|
nt as useTextSelection,
|
|
355
357
|
Oo as useTextareaAutosize,
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
358
|
+
Lu as useThrottleCallback,
|
|
359
|
+
Nu as useThrottleState,
|
|
360
|
+
Ku as useThrottleValue,
|
|
359
361
|
Xs as useTime,
|
|
360
362
|
Zs as useTimeout,
|
|
361
363
|
Ys as useTimer,
|
|
362
|
-
|
|
364
|
+
bs as useToggle,
|
|
363
365
|
Zo as useUnmount,
|
|
364
366
|
Ks as useUrlSearchParam,
|
|
365
367
|
Us as useUrlSearchParams,
|
|
366
368
|
he as useVibrate,
|
|
367
369
|
_e as useVirtualKeyboard,
|
|
368
370
|
lt as useVisibility,
|
|
369
|
-
|
|
371
|
+
De as useWakeLock,
|
|
370
372
|
Me as useWebSocket,
|
|
371
373
|
Et as useWindowEvent,
|
|
372
374
|
gt as useWindowFocus,
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,10 +2,11 @@ type StoreSetAction<Value> = ((prev: Value) => Partial<Value>) | Partial<Value>;
|
|
|
2
2
|
type StoreListener<Value> = (state: Value, prevState: Value) => void;
|
|
3
3
|
type StoreCreator<Value> = (set: (action: StoreSetAction<Value>) => void, get: () => Value) => Value;
|
|
4
4
|
export interface StoreApi<Value> {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
get: () => Value;
|
|
6
|
+
getInitial: () => Value;
|
|
7
|
+
set: (action: StoreSetAction<Value>) => void;
|
|
8
8
|
subscribe: (listener: StoreListener<Value>) => () => void;
|
|
9
|
+
use: (() => Value) & (<Selected>(selector: (state: Value) => Selected) => Selected) & (<Selected>(selector?: (state: Value) => Selected) => Selected | Value);
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* @name createStore
|
|
@@ -23,13 +24,5 @@ export interface StoreApi<Value> {
|
|
|
23
24
|
* increment: () => set(state => ({ count: state.count + 1 }))
|
|
24
25
|
* }));
|
|
25
26
|
*/
|
|
26
|
-
export declare const createStore: <Value>(createState: StoreCreator<Value> | Value) =>
|
|
27
|
-
set: (action: StoreSetAction<Value>) => void;
|
|
28
|
-
get: () => Value;
|
|
29
|
-
use: {
|
|
30
|
-
(): Value;
|
|
31
|
-
<Selected>(selector: (state: Value) => Selected): Selected;
|
|
32
|
-
};
|
|
33
|
-
subscribe: (listener: StoreListener<Value>) => () => boolean;
|
|
34
|
-
};
|
|
27
|
+
export declare const createStore: <Value>(createState: StoreCreator<Value> | Value) => StoreApi<Value>;
|
|
35
28
|
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type BatchedCallback<Params extends unknown[]> = ((...args: Params) => void) & {
|
|
2
|
+
flush: () => void;
|
|
3
|
+
cancel: () => void;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* @name useBatchedCallback
|
|
7
|
+
* @description - Hook that batches calls and forwards them to a callback
|
|
8
|
+
* @category Utilities
|
|
9
|
+
* @usage medium
|
|
10
|
+
*
|
|
11
|
+
* @template Params The type of the params
|
|
12
|
+
* @param {(batch: Params[]) => void} callback The callback that receives a batch of calls
|
|
13
|
+
* @param {number} batchSize The maximum size of a batch before it is flushed
|
|
14
|
+
* @returns {BatchedCallback<Params>} The batched callback with flush and cancel helpers
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const batched = useBatchedCallback((batch) => console.log(batch), 5);
|
|
18
|
+
*/
|
|
19
|
+
export declare const useBatchedCallback: <Params extends unknown[]>(callback: (batch: Params[]) => void, size: number) => BatchedCallback<Params>;
|
|
@@ -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 */
|
|
@@ -11,12 +11,11 @@ declare global {
|
|
|
11
11
|
}
|
|
12
12
|
export type UseOtpCredentialCallback = (otp: Credential | null) => void;
|
|
13
13
|
export interface UseOtpCredentialParams {
|
|
14
|
-
onError
|
|
15
|
-
onSuccess
|
|
14
|
+
onError?: (error: any) => void;
|
|
15
|
+
onSuccess?: (credential: Credential | null) => void;
|
|
16
16
|
}
|
|
17
17
|
export interface UseOtpCredentialReturn {
|
|
18
18
|
abort: AbortController['abort'];
|
|
19
|
-
aborted: boolean;
|
|
20
19
|
supported: boolean;
|
|
21
20
|
get: () => Promise<Credential | null>;
|
|
22
21
|
}
|
|
@@ -28,7 +28,7 @@ interface UseSpeechRecognitionReturn {
|
|
|
28
28
|
/** Whether the hook is currently listening for speech */
|
|
29
29
|
listening: boolean;
|
|
30
30
|
/** The speech recognition instance */
|
|
31
|
-
recognition
|
|
31
|
+
recognition?: SpeechRecognition;
|
|
32
32
|
/** Whether the current browser supports the Web Speech API */
|
|
33
33
|
supported: boolean;
|
|
34
34
|
/** The current transcript */
|
|
@@ -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. */
|
|
@@ -14,10 +14,11 @@ export interface UseTextareaAutosizeReturn {
|
|
|
14
14
|
/** Function to clear the textarea value */
|
|
15
15
|
clear: () => void;
|
|
16
16
|
/** Function to set the textarea value */
|
|
17
|
-
|
|
17
|
+
set: (value: string) => void;
|
|
18
18
|
}
|
|
19
19
|
export interface UseTextareaAutosize {
|
|
20
20
|
(target: HookTarget, options?: UseTextareaAutosizeOptions): UseTextareaAutosizeReturn;
|
|
21
|
+
(target: HookTarget, initialValue: string): UseTextareaAutosizeReturn;
|
|
21
22
|
<Target extends HTMLTextAreaElement = HTMLTextAreaElement>(initialValue: string, target?: never): UseTextareaAutosizeReturn & {
|
|
22
23
|
ref: StateRef<Target>;
|
|
23
24
|
};
|
|
@@ -41,6 +42,14 @@ export interface UseTextareaAutosize {
|
|
|
41
42
|
* const { value, setValue, clear } = useTextareaAutosize(ref);
|
|
42
43
|
*
|
|
43
44
|
* @overload
|
|
45
|
+
* @param {HookTarget} target The target textarea element
|
|
46
|
+
* @param {string} initialValue The initial value for the textarea
|
|
47
|
+
* @returns {UseTextareaAutosizeReturn} An object containing value, setValue and clear
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* const { value, setValue, clear } = useTextareaAutosize(ref, 'initial');
|
|
51
|
+
*
|
|
52
|
+
* @overload
|
|
44
53
|
* @template Target The textarea element type
|
|
45
54
|
* @param {string} initialValue The initial value for the textarea
|
|
46
55
|
* @returns {UseTextareaAutosizeReturn & { ref: StateRef<Target> }} An object containing ref, value, setValue and clear
|