@siberiacancode/reactuse 0.2.18 → 0.2.19
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/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/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/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/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 +252 -248
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/hooks/index.d.ts +1 -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/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 +1 -1
package/README.md
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<a href="https://reactuse.dev">
|
|
3
|
-
<picture>
|
|
4
|
-
<img alt="React Use logo" src="https://siberiacancode.github.io/reactuse/logo.svg" height="128">
|
|
5
|
-
</picture>
|
|
6
|
-
</a>
|
|
7
|
-
<h1>React Use</h1>
|
|
8
|
-
|
|
9
|
-
<a href="https://www.npmjs.com/package/@siberiacancode/reactuse"><img alt="NPM version" src="https://img.shields.io/npm/v/@siberiacancode/reactuse.svg?style=for-the-badge&labelColor=000000"></a>
|
|
10
|
-
<a href="https://github.com/siberiacancode/reactuse/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@siberiacancode/reactuse.svg?style=for-the-badge&labelColor=000000"></a>
|
|
11
|
-
<a href="https://github.com/siberiacancode/reactuse/discussions"><img alt="Join the community on GitHub" src="https://img.shields.io/badge/Join%20the%20community-blueviolet.svg?style=for-the-badge&logo=React&labelColor=000000&logoWidth=20"></a>
|
|
12
|
-
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
React Use delivers **production-ready hooks** that solve real-world problems. Built with **TypeScript-first** approach, **SSR compatibility**, and **tree-shaking optimization** - everything you need to build modern React applications. Improve your react applications with our library 📦 designed for comfort and speed.
|
|
16
|
-
|
|
17
|
-
## Documentation
|
|
18
|
-
|
|
19
|
-
Visit https://siberiacancode.github.io/reactuse to view the full documentation.
|
|
20
|
-
|
|
21
|
-
## Getting Started
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm install @siberiacancode/reactuse
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
```tsx
|
|
28
|
-
import { useCounter } from
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const counter = useCounter(0);
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div>
|
|
35
|
-
<h1>Count: {counter.value}</h1>
|
|
36
|
-
<button onClick={() => counter.inc()}>+1</button>
|
|
37
|
-
<button onClick={() => counter.dec()}>-1</button>
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## CLI installation
|
|
44
|
-
|
|
45
|
-
Use the CLI to add hooks to your project with [useverse](https://www.npmjs.com/package/useverse).
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npx useverse@latest init
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npx useverse@latest add [hook]
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
You will be presented with a list of hooks to choose from:
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
Which hooks would you like to add? › Space to select. A to toggle all.
|
|
59
|
-
Enter to submit.
|
|
60
|
-
|
|
61
|
-
◯ useActiveElement
|
|
62
|
-
◯ useAsync
|
|
63
|
-
◯ useBattery
|
|
64
|
-
◯ useBluetooth
|
|
65
|
-
◯ useBoolean
|
|
66
|
-
◯ useBreakpoints
|
|
67
|
-
◯ useBrowserLanguage
|
|
68
|
-
◯ useClickOutside
|
|
69
|
-
◯ useClipboard
|
|
70
|
-
◯ useConst
|
|
71
|
-
```
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://reactuse.dev">
|
|
3
|
+
<picture>
|
|
4
|
+
<img alt="React Use logo" src="https://siberiacancode.github.io/reactuse/logo.svg" height="128">
|
|
5
|
+
</picture>
|
|
6
|
+
</a>
|
|
7
|
+
<h1>React Use</h1>
|
|
8
|
+
|
|
9
|
+
<a href="https://www.npmjs.com/package/@siberiacancode/reactuse"><img alt="NPM version" src="https://img.shields.io/npm/v/@siberiacancode/reactuse.svg?style=for-the-badge&labelColor=000000"></a>
|
|
10
|
+
<a href="https://github.com/siberiacancode/reactuse/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@siberiacancode/reactuse.svg?style=for-the-badge&labelColor=000000"></a>
|
|
11
|
+
<a href="https://github.com/siberiacancode/reactuse/discussions"><img alt="Join the community on GitHub" src="https://img.shields.io/badge/Join%20the%20community-blueviolet.svg?style=for-the-badge&logo=React&labelColor=000000&logoWidth=20"></a>
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
React Use delivers **production-ready hooks** that solve real-world problems. Built with **TypeScript-first** approach, **SSR compatibility**, and **tree-shaking optimization** - everything you need to build modern React applications. Improve your react applications with our library 📦 designed for comfort and speed.
|
|
16
|
+
|
|
17
|
+
## Documentation
|
|
18
|
+
|
|
19
|
+
Visit https://siberiacancode.github.io/reactuse to view the full documentation.
|
|
20
|
+
|
|
21
|
+
## Getting Started
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @siberiacancode/reactuse
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { useCounter } from '@siberiacancode/reactuse';
|
|
29
|
+
|
|
30
|
+
const App = () => {
|
|
31
|
+
const counter = useCounter(0);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div>
|
|
35
|
+
<h1>Count: {counter.value}</h1>
|
|
36
|
+
<button onClick={() => counter.inc()}>+1</button>
|
|
37
|
+
<button onClick={() => counter.dec()}>-1</button>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## CLI installation
|
|
44
|
+
|
|
45
|
+
Use the CLI to add hooks to your project with [useverse](https://www.npmjs.com/package/useverse).
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx useverse@latest init
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npx useverse@latest add [hook]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
You will be presented with a list of hooks to choose from:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
Which hooks would you like to add? › Space to select. A to toggle all.
|
|
59
|
+
Enter to submit.
|
|
60
|
+
|
|
61
|
+
◯ useActiveElement
|
|
62
|
+
◯ useAsync
|
|
63
|
+
◯ useBattery
|
|
64
|
+
◯ useBluetooth
|
|
65
|
+
◯ useBoolean
|
|
66
|
+
◯ useBreakpoints
|
|
67
|
+
◯ useBrowserLanguage
|
|
68
|
+
◯ useClickOutside
|
|
69
|
+
◯ useClipboard
|
|
70
|
+
◯ useConst
|
|
71
|
+
```
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),u=require("../../utils/helpers/copy.cjs"),p=(s=1e3)=>{const[c,a]=t.useState(),[r,e]=t.useState(!1);return{value:c,copied:r,copy:async o=>{await u.copy(o),a(o),e(!0),setTimeout(()=>e(!1),s)}}};exports.useCopy=p;
|
|
2
2
|
//# sourceMappingURL=useCopy.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCopy.cjs","sources":["../../../../src/hooks/useCopy/useCopy.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { copy } from '@/utils/helpers';\n\n/** The use copy return type */\nexport interface UseCopyReturn {\n /** Whether copy is in progress */\n copied: boolean;\n /** The copied value */\n value
|
|
1
|
+
{"version":3,"file":"useCopy.cjs","sources":["../../../../src/hooks/useCopy/useCopy.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { copy } from '@/utils/helpers';\n\n/** The use copy return type */\nexport interface UseCopyReturn {\n /** Whether copy is in progress */\n copied: boolean;\n /** The copied value */\n value?: string;\n /** Function to copy text */\n copy: (value: string) => Promise<void>;\n}\n\n/** The use copy params type */\nexport interface UseCopyParams {\n /** Reset delay in milliseconds */\n resetDelay?: number;\n}\n\n/**\n * @name useCopy\n * @description - Hook that manages copying text with status reset\n * @category Browser\n *\n * @browserapi navigator.clipboard https://developer.mozilla.org/en-US/docs/Web/API/Navigator/clipboard\n *\n * @param {number} [delay=1000] Delay in ms before resetting copied status\n * @returns {UseCopyReturn} An object containing the copied value, status and copy function\n *\n * @example\n * const { copied, value, copy } = useCopy();\n */\nexport const useCopy = (delay: number = 1000): UseCopyReturn => {\n const [value, setValue] = useState<string | undefined>();\n const [copied, setCopied] = useState(false);\n\n const copyToClipboard = async (text: string) => {\n await copy(text);\n setValue(text);\n setCopied(true);\n setTimeout(() => setCopied(false), delay);\n };\n\n return { value, copied, copy: copyToClipboard };\n};\n"],"names":["useCopy","delay","value","setValue","useState","copied","setCopied","text","copy"],"mappings":"mJAiCaA,EAAU,CAACC,EAAgB,MAAwB,CAC9D,KAAM,CAACC,EAAOC,CAAQ,EAAIC,WAAA,EACpB,CAACC,EAAQC,CAAS,EAAIF,EAAAA,SAAS,EAAK,EAS1C,MAAO,CAAE,MAAAF,EAAO,OAAAG,EAAQ,KAPA,MAAOE,GAAiB,CAC9C,MAAMC,EAAAA,KAAKD,CAAI,EACfJ,EAASI,CAAI,EACbD,EAAU,EAAI,EACd,WAAW,IAAMA,EAAU,EAAK,EAAGL,CAAK,CAAA,CAGZ,CAChC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),d=require("../useRefState/useRefState.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),d=require("../useRefState/useRefState.cjs"),v=require("../../utils/helpers/isTarget.cjs"),f=require("../../utils/helpers/getElement.cjs"),E=(...n)=>{const e=v.isTarget(n[0])?n[0]:void 0,u=e?n[1]:n[0],o=e?n[2]:n[1],[a,c]=l.useState(o??""),r=d.useRefState(window.document.documentElement),i=t=>{const s=e?f.getElement(e):r.current;!s||!s.style||(s.style.setProperty(u,t),c(t))},g=()=>{const t=e?f.getElement(e):r.current;!t||!t.style||(t.style.removeProperty(u),c(""))};return l.useEffect(()=>{o&&i(o)},[]),l.useEffect(()=>{if(!e&&!r.state)return;const t=e?f.getElement(e):r.current;if(!t)return;const s=()=>{const m=window.getComputedStyle(t).getPropertyValue(u)?.trim();c(m??o)},y=new MutationObserver(s);return y.observe(t,{attributeFilter:["style","class"]}),()=>{y.disconnect()}},[e,r.state]),e?{value:a,set:i,remove:g}:{ref:r,value:a,set:i,remove:g}};exports.useCssVar=E;
|
|
2
2
|
//# sourceMappingURL=useCssVar.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCssVar.cjs","sources":["../../../../src/hooks/useCssVar/useCssVar.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The css variable return type */\nexport interface UseCssVarReturn {\n /** The value of the CSS variable */\n value: string;\n /** Set the value of the CSS variable */\n set: (value: string) => void;\n}\n\nexport interface UseCssVar {\n (key: string
|
|
1
|
+
{"version":3,"file":"useCssVar.cjs","sources":["../../../../src/hooks/useCssVar/useCssVar.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The css variable return type */\nexport interface UseCssVarReturn {\n /** The value of the CSS variable */\n value: string;\n /** Remove the value of the CSS variable */\n remove: () => void;\n /** Set the value of the CSS variable */\n set: (value: string) => void;\n}\n\nexport interface UseCssVar {\n <Target extends HTMLElement>(\n key: string,\n initialValue?: string\n ): UseCssVarReturn & {\n ref: StateRef<Target>;\n };\n\n (target: HookTarget, key: string, initialValue?: string): UseCssVarReturn;\n}\n\n/**\n * @name useCssVar\n * @description - Hook that returns the value of a css variable\n * @category Utilities\n *\n * @overload\n * @param {string} key The CSS variable key\n * @param {string} initialValue The initial value of the CSS variable\n * @returns {UseCssVarReturn & { ref: StateRef<Element> }} The object containing the value of the CSS variable and ref\n *\n * @example\n * const { ref, value, set, remove } = useCssVar('--color', 'red');\n *\n * @overload\n * @param {HookTarget} target The target element\n * @param {string} key The CSS variable key\n * @param {string} initialValue The initial value of the CSS variable\n * @returns {UseCssVarReturn} The object containing the value of the CSS variable\n *\n * @example\n * const { value, set, remove } = useCssVar(ref, '--color', 'red');\n */\nexport const useCssVar = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const key = (target ? params[1] : params[0]) as string;\n const initialValue = (target ? params[2] : params[1]) as string | undefined;\n\n const [value, setValue] = useState(initialValue ?? '');\n const internalRef = useRefState<HTMLElement>(window.document.documentElement);\n\n const set = (value: string) => {\n const element = (target ? getElement(target) : internalRef.current) as HTMLElement;\n\n if (!element || !element.style) return;\n\n element.style.setProperty(key, value);\n setValue(value);\n };\n\n const remove = () => {\n const element = (target ? getElement(target) : internalRef.current) as HTMLElement;\n\n if (!element || !element.style) return;\n\n element.style.removeProperty(key);\n setValue('');\n };\n\n useEffect(() => {\n if (initialValue) set(initialValue);\n }, []);\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = (target ? getElement(target) : internalRef.current) as HTMLElement;\n\n if (!element) return;\n\n const onChange = () => {\n const value = window.getComputedStyle(element).getPropertyValue(key)?.trim();\n\n setValue(value ?? initialValue);\n };\n\n const observer = new MutationObserver(onChange);\n\n observer.observe(element, { attributeFilter: ['style', 'class'] });\n\n return () => {\n observer.disconnect();\n };\n }, [target, internalRef.state]);\n\n if (target) return { value, set, remove };\n return { ref: internalRef, value, set, remove };\n}) as UseCssVar;\n"],"names":["useCssVar","params","target","isTarget","key","initialValue","value","setValue","useState","internalRef","useRefState","set","element","getElement","remove","useEffect","onChange","observer"],"mappings":"mPAqDaA,EAAa,IAAIC,IAAkB,CAC9C,MAAMC,EAAUC,EAAAA,SAASF,EAAO,CAAC,CAAC,EAAIA,EAAO,CAAC,EAAI,OAC5CG,EAAOF,EAASD,EAAO,CAAC,EAAIA,EAAO,CAAC,EACpCI,EAAgBH,EAASD,EAAO,CAAC,EAAIA,EAAO,CAAC,EAE7C,CAACK,EAAOC,CAAQ,EAAIC,EAAAA,SAASH,GAAgB,EAAE,EAC/CI,EAAcC,EAAAA,YAAyB,OAAO,SAAS,eAAe,EAEtEC,EAAOL,GAAkB,CAC7B,MAAMM,EAAWV,EAASW,EAAAA,WAAWX,CAAM,EAAIO,EAAY,QAEvD,CAACG,GAAW,CAACA,EAAQ,QAEzBA,EAAQ,MAAM,YAAYR,EAAKE,CAAK,EACpCC,EAASD,CAAK,EAAA,EAGVQ,EAAS,IAAM,CACnB,MAAMF,EAAWV,EAASW,EAAAA,WAAWX,CAAM,EAAIO,EAAY,QAEvD,CAACG,GAAW,CAACA,EAAQ,QAEzBA,EAAQ,MAAM,eAAeR,CAAG,EAChCG,EAAS,EAAE,EAAA,EA6Bb,OA1BAQ,EAAAA,UAAU,IAAM,CACVV,KAAkBA,CAAY,CAAA,EACjC,EAAE,EAELU,EAAAA,UAAU,IAAM,CACd,GAAI,CAACb,GAAU,CAACO,EAAY,MAAO,OAEnC,MAAMG,EAAWV,EAASW,EAAAA,WAAWX,CAAM,EAAIO,EAAY,QAE3D,GAAI,CAACG,EAAS,OAEd,MAAMI,EAAW,IAAM,CACrB,MAAMV,EAAQ,OAAO,iBAAiBM,CAAO,EAAE,iBAAiBR,CAAG,GAAG,KAAA,EAEtEG,EAASD,GAASD,CAAY,CAAA,EAG1BY,EAAW,IAAI,iBAAiBD,CAAQ,EAE9C,OAAAC,EAAS,QAAQL,EAAS,CAAE,gBAAiB,CAAC,QAAS,OAAO,EAAG,EAE1D,IAAM,CACXK,EAAS,WAAA,CAAW,CACtB,EACC,CAACf,EAAQO,EAAY,KAAK,CAAC,EAE1BP,EAAe,CAAE,MAAAI,EAAO,IAAAK,EAAK,OAAAG,CAAA,EAC1B,CAAE,IAAKL,EAAa,MAAAH,EAAO,IAAAK,EAAK,OAAAG,CAAA,CACzC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),a=(t,c)=>{const r=n.useRef(t),e=n.useRef(null),u=n.useRef(c);return r.current=t,u.current=c,n.useMemo(()=>{const o=()=>{e.current&&(clearTimeout(e.current),e.current=null)},l=function(...s){o(),e.current=setTimeout(()=>{r.current.apply(this,s)},u.current)};return l.cancel=o,l},[])};exports.useDebounceCallback=a;
|
|
2
2
|
//# sourceMappingURL=useDebounceCallback.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDebounceCallback.cjs","sources":["../../../../src/hooks/useDebounceCallback/useDebounceCallback.ts"],"sourcesContent":["import { useMemo, useRef } from 'react';\n\nexport type DebouncedCallback<Params extends unknown[]> = ((...args: Params) => void) & {\n cancel: () => void;\n};\n\n/**\n * @name useDebounceCallback\n * @description - Hook that creates a debounced callback\n * @category Utilities\n *\n * @template Params The type of the params\n * @template Return The type of the return\n * @param {(...args: Params) => Return} callback The callback function\n * @param {number} delay The delay in milliseconds\n * @returns {(...args: Params) => Return} The callback with debounce\n *\n * @example\n * const debouncedCallback = useDebounceCallback(() => console.log('callback'), 500);\n */\nexport const useDebounceCallback = <Params extends unknown[], Return>(\n callback: (...args: Params) => Return,\n delay: number\n): DebouncedCallback<Params> => {\n const internalCallbackRef = useRef(callback);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const delayRef = useRef(delay);\n\n internalCallbackRef.current = callback;\n delayRef.current = delay;\n\n const debounced = useMemo(() => {\n const cancel = () => {\n if (timerRef.current)
|
|
1
|
+
{"version":3,"file":"useDebounceCallback.cjs","sources":["../../../../src/hooks/useDebounceCallback/useDebounceCallback.ts"],"sourcesContent":["import { useMemo, useRef } from 'react';\n\nexport type DebouncedCallback<Params extends unknown[]> = ((...args: Params) => void) & {\n cancel: () => void;\n};\n\n/**\n * @name useDebounceCallback\n * @description - Hook that creates a debounced callback\n * @category Utilities\n *\n * @template Params The type of the params\n * @template Return The type of the return\n * @param {(...args: Params) => Return} callback The callback function\n * @param {number} delay The delay in milliseconds\n * @returns {(...args: Params) => Return} The callback with debounce\n *\n * @example\n * const debouncedCallback = useDebounceCallback(() => console.log('callback'), 500);\n */\nexport const useDebounceCallback = <Params extends unknown[], Return>(\n callback: (...args: Params) => Return,\n delay: number\n): DebouncedCallback<Params> => {\n const internalCallbackRef = useRef(callback);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const delayRef = useRef(delay);\n\n internalCallbackRef.current = callback;\n delayRef.current = delay;\n\n const debounced = useMemo(() => {\n const cancel = () => {\n if (!timerRef.current) return;\n clearTimeout(timerRef.current);\n timerRef.current = null;\n };\n\n const debouncedCallback = function (this: any, ...args: Params) {\n cancel();\n timerRef.current = setTimeout(() => {\n internalCallbackRef.current.apply(this, args);\n }, delayRef.current);\n };\n\n debouncedCallback.cancel = cancel;\n\n return debouncedCallback;\n }, []);\n\n return debounced;\n};\n"],"names":["useDebounceCallback","callback","delay","internalCallbackRef","useRef","timerRef","delayRef","useMemo","cancel","debouncedCallback","args"],"mappings":"yGAoBaA,EAAsB,CACjCC,EACAC,IAC8B,CAC9B,MAAMC,EAAsBC,EAAAA,OAAOH,CAAQ,EACrCI,EAAWD,EAAAA,OAA6C,IAAI,EAC5DE,EAAWF,EAAAA,OAAOF,CAAK,EAE7B,OAAAC,EAAoB,QAAUF,EAC9BK,EAAS,QAAUJ,EAEDK,EAAAA,QAAQ,IAAM,CAC9B,MAAMC,EAAS,IAAM,CACdH,EAAS,UACd,aAAaA,EAAS,OAAO,EAC7BA,EAAS,QAAU,KAAA,EAGfI,EAAoB,YAAwBC,EAAc,CAC9DF,EAAA,EACAH,EAAS,QAAU,WAAW,IAAM,CAClCF,EAAoB,QAAQ,MAAM,KAAMO,CAAI,CAAA,EAC3CJ,EAAS,OAAO,CAAA,EAGrB,OAAAG,EAAkB,OAASD,EAEpBC,CAAA,EACN,EAAE,CAGP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeviceMotion.cjs","sources":["../../../../src/hooks/useDeviceMotion/useDeviceMotion.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport { throttle } from '@/utils/helpers';\n\nexport interface UseDeviceMotionReturn {\n acceleration: DeviceMotionEventAcceleration;\n accelerationIncludingGravity: DeviceMotionEventAcceleration;\n interval: DeviceMotionEvent['interval'];\n rotationRate: DeviceMotionEventRotationRate;\n}\n\nexport interface UseDeviceMotionParams {\n /** The delay in milliseconds */\n delay?: number;\n /** Whether to enable the hook */\n enabled?: boolean;\n /** The callback function to be invoked */\n callback?: (event: DeviceMotionEvent) => void;\n}\n\n/**\n * @name useDeviceMotion\n * @description - Hook that work with device motion\n * @category Utilities\n *\n * @browserapi DeviceMotionEvent https://developer.mozilla.org/en-US/docs/Web/API/Window/DeviceMotionEvent\n *\n * @param {number} [delay=1000] The delay in milliseconds\n * @param {(event: DeviceMotionEvent) => void} [callback] The callback function to be invoked\n * @param {boolean} [enabled=true] Whether to enable the hook\n * @returns {UseDeviceMotionReturn} The device motion data and interval\n *\n * @example\n * const { interval, rotationRate, acceleration, accelerationIncludingGravity } = useDeviceMotion();\n */\nexport const useDeviceMotion = (params?: UseDeviceMotionParams) => {\n const enabled = params?.enabled ?? true;\n const delay = params?.delay ?? 1000;\n const [value, setValue] = useState<UseDeviceMotionReturn>({\n interval: 0,\n rotationRate: { alpha: null, beta: null, gamma: null },\n acceleration: { x: null, y: null, z: null },\n accelerationIncludingGravity: { x: null, y: null, z: null }\n });\n const internalCallbackRef = useRef(params?.callback);\n internalCallbackRef.current = params?.callback;\n\n useEffect(() => {\n if (!enabled) return;\n\n const onDeviceMotion = throttle<[DeviceMotionEvent]>((event) => {\n internalCallbackRef.current?.(event);\n setValue({\n interval: event.interval,\n rotationRate: {\n ...value.rotationRate,\n ...event.rotationRate\n },\n acceleration: {\n ...value.acceleration,\n ...event.acceleration\n },\n accelerationIncludingGravity: {\n ...value.accelerationIncludingGravity,\n ...event.accelerationIncludingGravity\n }\n });\n }, delay);\n\n window.addEventListener('devicemotion', onDeviceMotion);\n\n return () => {\n window.removeEventListener('devicemotion', onDeviceMotion);\n };\n }, [delay, enabled]);\n\n return value;\n};\n"],"names":["useDeviceMotion","params","enabled","delay","value","setValue","useState","internalCallbackRef","useRef","useEffect","onDeviceMotion","throttle","event"],"mappings":"uJAmCaA,EAAmBC,GAAmC,CACjE,MAAMC,EAAUD,GAAQ,SAAW,GAC7BE,EAAQF,GAAQ,OAAS,IACzB,CAACG,EAAOC,CAAQ,EAAIC,WAAgC,CACxD,SAAU,EACV,aAAc,CAAE,MAAO,KAAM,KAAM,KAAM,MAAO,IAAA,EAChD,aAAc,CAAE,EAAG,KAAM,EAAG,KAAM,EAAG,IAAA,EACrC,6BAA8B,CAAE,EAAG,KAAM,EAAG,KAAM,EAAG,IAAA,CAAK,CAC3D,EACKC,EAAsBC,EAAAA,OAAOP,GAAQ,QAAQ,EACnD,OAAAM,EAAoB,QAAUN,GAAQ,SAEtCQ,EAAAA,UAAU,IAAM,CACd,GAAI,CAACP,EAAS,OAEd,MAAMQ,EAAiBC,WAA+BC,GAAU,CAC9DL,EAAoB,UAAUK,CAAK,
|
|
1
|
+
{"version":3,"file":"useDeviceMotion.cjs","sources":["../../../../src/hooks/useDeviceMotion/useDeviceMotion.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport { throttle } from '@/utils/helpers';\n\nexport interface UseDeviceMotionReturn {\n acceleration: DeviceMotionEventAcceleration;\n accelerationIncludingGravity: DeviceMotionEventAcceleration;\n interval: DeviceMotionEvent['interval'];\n rotationRate: DeviceMotionEventRotationRate;\n}\n\nexport interface UseDeviceMotionParams {\n /** The delay in milliseconds */\n delay?: number;\n /** Whether to enable the hook */\n enabled?: boolean;\n /** The callback function to be invoked */\n callback?: (event: DeviceMotionEvent) => void;\n}\n\n/**\n * @name useDeviceMotion\n * @description - Hook that work with device motion\n * @category Utilities\n *\n * @browserapi DeviceMotionEvent https://developer.mozilla.org/en-US/docs/Web/API/Window/DeviceMotionEvent\n *\n * @param {number} [delay=1000] The delay in milliseconds\n * @param {(event: DeviceMotionEvent) => void} [callback] The callback function to be invoked\n * @param {boolean} [enabled=true] Whether to enable the hook\n * @returns {UseDeviceMotionReturn} The device motion data and interval\n *\n * @example\n * const { interval, rotationRate, acceleration, accelerationIncludingGravity } = useDeviceMotion();\n */\nexport const useDeviceMotion = (params?: UseDeviceMotionParams) => {\n const enabled = params?.enabled ?? true;\n const delay = params?.delay ?? 1000;\n const [value, setValue] = useState<UseDeviceMotionReturn>({\n interval: 0,\n rotationRate: { alpha: null, beta: null, gamma: null },\n acceleration: { x: null, y: null, z: null },\n accelerationIncludingGravity: { x: null, y: null, z: null }\n });\n const internalCallbackRef = useRef(params?.callback);\n internalCallbackRef.current = params?.callback;\n\n useEffect(() => {\n if (!enabled) return;\n\n const onDeviceMotion = throttle<[DeviceMotionEvent]>((event) => {\n internalCallbackRef.current?.(event);\n\n setValue({\n interval: event.interval,\n rotationRate: {\n ...value.rotationRate,\n ...event.rotationRate\n },\n acceleration: {\n ...value.acceleration,\n ...event.acceleration\n },\n accelerationIncludingGravity: {\n ...value.accelerationIncludingGravity,\n ...event.accelerationIncludingGravity\n }\n });\n }, delay);\n\n window.addEventListener('devicemotion', onDeviceMotion);\n\n return () => {\n window.removeEventListener('devicemotion', onDeviceMotion);\n };\n }, [delay, enabled]);\n\n return value;\n};\n"],"names":["useDeviceMotion","params","enabled","delay","value","setValue","useState","internalCallbackRef","useRef","useEffect","onDeviceMotion","throttle","event"],"mappings":"uJAmCaA,EAAmBC,GAAmC,CACjE,MAAMC,EAAUD,GAAQ,SAAW,GAC7BE,EAAQF,GAAQ,OAAS,IACzB,CAACG,EAAOC,CAAQ,EAAIC,WAAgC,CACxD,SAAU,EACV,aAAc,CAAE,MAAO,KAAM,KAAM,KAAM,MAAO,IAAA,EAChD,aAAc,CAAE,EAAG,KAAM,EAAG,KAAM,EAAG,IAAA,EACrC,6BAA8B,CAAE,EAAG,KAAM,EAAG,KAAM,EAAG,IAAA,CAAK,CAC3D,EACKC,EAAsBC,EAAAA,OAAOP,GAAQ,QAAQ,EACnD,OAAAM,EAAoB,QAAUN,GAAQ,SAEtCQ,EAAAA,UAAU,IAAM,CACd,GAAI,CAACP,EAAS,OAEd,MAAMQ,EAAiBC,WAA+BC,GAAU,CAC9DL,EAAoB,UAAUK,CAAK,EAEnCP,EAAS,CACP,SAAUO,EAAM,SAChB,aAAc,CACZ,GAAGR,EAAM,aACT,GAAGQ,EAAM,YAAA,EAEX,aAAc,CACZ,GAAGR,EAAM,aACT,GAAGQ,EAAM,YAAA,EAEX,6BAA8B,CAC5B,GAAGR,EAAM,6BACT,GAAGQ,EAAM,4BAAA,CACX,CACD,CAAA,EACAT,CAAK,EAER,cAAO,iBAAiB,eAAgBO,CAAc,EAE/C,IAAM,CACX,OAAO,oBAAoB,eAAgBA,CAAc,CAAA,CAC3D,EACC,CAACP,EAAOD,CAAO,CAAC,EAEZE,CACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),d=require("../useRefState/useRefState.cjs"),T=require("../../utils/helpers/isTarget.cjs"),g=require("../../utils/helpers/getElement.cjs"),R=300,k=(...t)=>{const e=T.isTarget(t[0])?t[0]:void 0,l=e?t[1]:t[0],f=e?t[2]:t[1],u=c.useRef(void 0),r=c.useRef(0),o=d.useRefState(),a=c.useRef(l);a.current=l;const i=c.useRef(f);if(i.current=f,c.useEffect(()=>{if(!e&&!o.state)return;const n=e?g.getElement(e):o.current;if(!n)return;const s=E=>{r.current+=1,r.current===1&&(u.current=setTimeout(()=>{i.current?.onSingleClick&&i.current.onSingleClick(E),r.current=0},i.current?.threshold??R)),r.current===2&&(clearTimeout(u.current),a.current(E),r.current=0)};return n.addEventListener("mousedown",s),n.addEventListener("touchstart",s),()=>{n.removeEventListener("mousedown",s),n.removeEventListener("touchstart",s),u.current&&clearTimeout(u.current)}},[e,o.state]),!e)return o};exports.DEFAULT_THRESHOLD_TIME=R;exports.useDoubleClick=k;
|
|
2
2
|
//# sourceMappingURL=useDoubleClick.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDoubleClick.cjs","sources":["../../../../src/hooks/useDoubleClick/useDoubleClick.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\nexport type DoubleClickEvents = MouseEvent | TouchEvent;\n\n
|
|
1
|
+
{"version":3,"file":"useDoubleClick.cjs","sources":["../../../../src/hooks/useDoubleClick/useDoubleClick.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\nexport type DoubleClickEvents = MouseEvent | TouchEvent;\n\n/** The use double click options type */\nexport interface UseDoubleClickOptions {\n /** The threshold time in milliseconds between clicks */\n threshold?: number;\n /** The callback function to be invoked on single click */\n onSingleClick?: (event: DoubleClickEvents) => void;\n}\n\nexport interface UseDoubleClick {\n (\n target: HookTarget,\n callback: (event: DoubleClickEvents) => void,\n options?: UseDoubleClickOptions\n ): boolean;\n\n <Target extends Element>(\n callback: (event: DoubleClickEvents) => void,\n options?: UseDoubleClickOptions,\n target?: never\n ): StateRef<Target>;\n}\n\nexport const DEFAULT_THRESHOLD_TIME = 300;\n\n/**\n * @name useDoubleClick\n * @description - Hook that defines the logic when double clicking an element\n * @category Sensors\n *\n * @overload\n * @param {HookTarget} target The target element to be double clicked\n * @param {(event: DoubleClickEvents) => void} callback The callback function to be invoked on double click\n * @param {UseDoubleClickOptions} [options] The options for the double click\n * @returns {boolean} The double clicking state\n *\n * @example\n * useDoubleClick(ref, () => console.log('double clicked'));\n *\n * @overload\n * @template Target The target element\n * @param {(event: DoubleClickEvents) => void} callback The callback function to be invoked on double click\n * @param {UseDoubleClickOptions} [options] The options for the double click\n * @returns {boolean} The double clicking state\n *\n * @example\n * const ref = useDoubleClick(() => console.log('double clicked'));\n *\n * @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useDoubleClick.html}\n */\nexport const useDoubleClick = ((...params: any[]): any => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const callback = (target ? params[1] : params[0]) as (event: DoubleClickEvents) => void;\n const options = (target ? params[2] : params[1]) as UseDoubleClickOptions | undefined;\n\n const timeoutIdRef = useRef<ReturnType<typeof setTimeout>>(undefined);\n const clickCountRef = useRef(0);\n const internalRef = useRefState<Element>();\n\n const internalCallbackRef = useRef(callback);\n internalCallbackRef.current = callback;\n const internalOptionsRef = useRef(options);\n internalOptionsRef.current = options;\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = target ? getElement(target) : internalRef.current;\n if (!element) return;\n\n const onClick = (event: DoubleClickEvents) => {\n clickCountRef.current += 1;\n\n if (clickCountRef.current === 1) {\n timeoutIdRef.current = setTimeout(() => {\n if (internalOptionsRef.current?.onSingleClick)\n internalOptionsRef.current.onSingleClick(event);\n clickCountRef.current = 0;\n }, internalOptionsRef.current?.threshold ?? DEFAULT_THRESHOLD_TIME);\n }\n\n if (clickCountRef.current === 2) {\n clearTimeout(timeoutIdRef.current);\n internalCallbackRef.current(event);\n clickCountRef.current = 0;\n }\n };\n\n element.addEventListener('mousedown', onClick as EventListener);\n element.addEventListener('touchstart', onClick as EventListener);\n\n return () => {\n element.removeEventListener('mousedown', onClick as EventListener);\n element.removeEventListener('touchstart', onClick as EventListener);\n if (timeoutIdRef.current) clearTimeout(timeoutIdRef.current);\n };\n }, [target, internalRef.state]);\n\n if (target) return;\n return internalRef;\n}) as UseDoubleClick;\n"],"names":["DEFAULT_THRESHOLD_TIME","useDoubleClick","params","target","isTarget","callback","options","timeoutIdRef","useRef","clickCountRef","internalRef","useRefState","internalCallbackRef","internalOptionsRef","useEffect","element","getElement","onClick","event"],"mappings":"mPAkCaA,EAAyB,IA2BzBC,EAAkB,IAAIC,IAAuB,CACxD,MAAMC,EAAUC,EAAAA,SAASF,EAAO,CAAC,CAAC,EAAIA,EAAO,CAAC,EAAI,OAC5CG,EAAYF,EAASD,EAAO,CAAC,EAAIA,EAAO,CAAC,EACzCI,EAAWH,EAASD,EAAO,CAAC,EAAIA,EAAO,CAAC,EAExCK,EAAeC,EAAAA,OAAsC,MAAS,EAC9DC,EAAgBD,EAAAA,OAAO,CAAC,EACxBE,EAAcC,EAAAA,YAAA,EAEdC,EAAsBJ,EAAAA,OAAOH,CAAQ,EAC3CO,EAAoB,QAAUP,EAC9B,MAAMQ,EAAqBL,EAAAA,OAAOF,CAAO,EAqCzC,GApCAO,EAAmB,QAAUP,EAE7BQ,EAAAA,UAAU,IAAM,CACd,GAAI,CAACX,GAAU,CAACO,EAAY,MAAO,OAEnC,MAAMK,EAAUZ,EAASa,EAAAA,WAAWb,CAAM,EAAIO,EAAY,QAC1D,GAAI,CAACK,EAAS,OAEd,MAAME,EAAWC,GAA6B,CAC5CT,EAAc,SAAW,EAErBA,EAAc,UAAY,IAC5BF,EAAa,QAAU,WAAW,IAAM,CAClCM,EAAmB,SAAS,eAC9BA,EAAmB,QAAQ,cAAcK,CAAK,EAChDT,EAAc,QAAU,CAAA,EACvBI,EAAmB,SAAS,WAAab,CAAsB,GAGhES,EAAc,UAAY,IAC5B,aAAaF,EAAa,OAAO,EACjCK,EAAoB,QAAQM,CAAK,EACjCT,EAAc,QAAU,EAC1B,EAGF,OAAAM,EAAQ,iBAAiB,YAAaE,CAAwB,EAC9DF,EAAQ,iBAAiB,aAAcE,CAAwB,EAExD,IAAM,CACXF,EAAQ,oBAAoB,YAAaE,CAAwB,EACjEF,EAAQ,oBAAoB,aAAcE,CAAwB,EAC9DV,EAAa,SAAS,aAAaA,EAAa,OAAO,CAAA,CAC7D,EACC,CAACJ,EAAQO,EAAY,KAAK,CAAC,EAE1B,CAAAP,EACJ,OAAOO,CACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),a=()=>decodeURIComponent(window.location.hash.replace("#","")),c=(n="",r="replace")=>{const[t,o]=s.useState(()=>typeof window>"u"?n:a()||n),h=e=>{window.location.hash=e,o(e)};return s.useEffect(()=>{r==="replace"&&(window.location.hash=t);const e=()=>o(a());return window.addEventListener("hashchange",e),()=>{window.removeEventListener("hashchange",e)}},[]),[t,h]};exports.useHash=c;
|
|
2
2
|
//# sourceMappingURL=useHash.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHash.cjs","sources":["../../../../src/hooks/useHash/useHash.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst getHash = () => decodeURIComponent(window.location.hash.replace('#', ''));\n\n/** The use hash return type */\ntype UseHashReturn = [string, (value: string) => void];\n\n/**\n * @name useHash\n * @description - Hook that manages the hash value\n * @category Browser\n *\n * @returns {UseHashReturn} An array containing the hash value and a function to set the hash value\n *\n * @example\n * const [hash, setHash] = useHash();\n */\nexport const useHash = (): UseHashReturn => {\n const [hash, setHash] = useState(window
|
|
1
|
+
{"version":3,"file":"useHash.cjs","sources":["../../../../src/hooks/useHash/useHash.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst getHash = () => decodeURIComponent(window.location.hash.replace('#', ''));\n\n/** The use hash return type */\ntype UseHashReturn = [string, (value: string) => void];\n\n/**\n * @name useHash\n * @description - Hook that manages the hash value\n * @category Browser\n *\n * @param {string} [initialValue] The initial hash value if no hash exists\n * @returns {UseHashReturn} An array containing the hash value and a function to set the hash value\n *\n * @example\n * const [hash, setHash] = useHash(\"initial\");\n */\nexport const useHash = (\n initialValue = '',\n mode: 'initial' | 'replace' = 'replace'\n): UseHashReturn => {\n const [hash, setHash] = useState(() => {\n if (typeof window === 'undefined') return initialValue;\n return getHash() || initialValue;\n });\n\n const set = (value: string) => {\n window.location.hash = value;\n setHash(value);\n };\n\n useEffect(() => {\n if (mode === 'replace') window.location.hash = hash;\n\n const onHashChange = () => setHash(getHash());\n window.addEventListener('hashchange', onHashChange);\n return () => {\n window.removeEventListener('hashchange', onHashChange);\n };\n }, []);\n\n return [hash, set] as const;\n};\n"],"names":["getHash","useHash","initialValue","mode","hash","setHash","useState","set","value","useEffect","onHashChange"],"mappings":"yGAEMA,EAAU,IAAM,mBAAmB,OAAO,SAAS,KAAK,QAAQ,IAAK,EAAE,CAAC,EAgBjEC,EAAU,CACrBC,EAAe,GACfC,EAA8B,YACZ,CAClB,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAAS,IAC3B,OAAO,OAAW,IAAoBJ,EACnCF,KAAaE,CACrB,EAEKK,EAAOC,GAAkB,CAC7B,OAAO,SAAS,KAAOA,EACvBH,EAAQG,CAAK,CAAA,EAGfC,OAAAA,EAAAA,UAAU,IAAM,CACVN,IAAS,YAAW,OAAO,SAAS,KAAOC,GAE/C,MAAMM,EAAe,IAAML,EAAQL,GAAS,EAC5C,cAAO,iBAAiB,aAAcU,CAAY,EAC3C,IAAM,CACX,OAAO,oBAAoB,aAAcA,CAAY,CAAA,CACvD,EACC,EAAE,EAEE,CAACN,EAAMG,CAAG,CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.cjs","sources":["../../../../src/hooks/useQuery/useQuery.ts"],"sourcesContent":["import type { DependencyList } from 'react';\
|
|
1
|
+
{"version":3,"file":"useQuery.cjs","sources":["../../../../src/hooks/useQuery/useQuery.ts"],"sourcesContent":["import type { DependencyList } from 'react';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { getRetry } from '@/utils/helpers';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\nimport { useMount } from '../useMount/useMount';\n\n/* The use query return type */\nexport interface UseQueryOptions<QueryData, Data> {\n /* The enabled state of the query */\n enabled?: boolean;\n /* The depends for the hook */\n keys?: DependencyList;\n /* The placeholder data for the hook */\n placeholderData?: (() => Data) | Data;\n /* The refetch interval */\n refetchInterval?: number;\n /* The retry count of requests */\n retry?: boolean | number;\n /* The retry delay of requests */\n retryDelay?: ((retry: number, error: Error) => number) | number;\n /* The callback function to be invoked on error */\n onError?: (error: Error) => void;\n /* The callback function to be invoked on success */\n onSuccess?: (data: Data) => void;\n /* The select function to be invoked */\n select?: (data: QueryData) => Data;\n}\n\ninterface UseQueryCallbackParams {\n /* The depends for the hook */\n keys: DependencyList;\n /* The abort signal */\n signal: AbortSignal;\n}\n\n/* The use query return type */\nexport interface UseQueryReturn<Data> {\n /* The abort function */\n abort: AbortController['abort'];\n /* The state of the query */\n data?: Data;\n /* The success state of the query */\n error?: Error;\n /* The error state of the query */\n isError: boolean;\n /* The fetching state of the query */\n isFetching: boolean;\n /* The loading state of the query */\n isLoading: boolean;\n /* The refetching state of the query */\n isRefetching: boolean;\n /* The success state of the query */\n isSuccess: boolean;\n /* The refetch function */\n refetch: () => void;\n}\n\n/**\n * @name useQuery\n * @description - Hook that defines the logic when query data\n * @category Utilities\n *\n * @template Data The type of the data\n * @param {() => Promise<Data>} callback The callback function to be invoked\n * @param {DependencyList} [options.keys] The dependencies for the hook\n * @param {(data: Data) => void} [options.onSuccess] The callback function to be invoked on success\n * @param {(error: Error) => void} [options.onError] The callback function to be invoked on error\n * @param {UseQueryOptionsSelect<Data>} [options.select] The select function to be invoked\n * @param {Data | (() => Data)} [options.initialData] The initial data for the hook\n * @param {Data | (() => Data)} [options.placeholderData] The placeholder data for the hook\n * @param {number} [options.refetchInterval] The refetch interval\n * @param {boolean | number} [options.retry] The retry count of requests\n * @returns {UseQueryReturn<Data>} An object with the state of the query\n *\n * @example\n * const { data, isFetching, isLoading, isError, isSuccess, error, refetch, isRefetching, abort, aborted } = useQuery(() => fetch('url'));\n */\nexport const useQuery = <QueryData, Data = QueryData>(\n callback: (params: UseQueryCallbackParams) => Promise<QueryData>,\n options?: UseQueryOptions<QueryData, Data>\n): UseQueryReturn<Data> => {\n const enabled = options?.enabled ?? true;\n const retryCountRef = useRef(options?.retry ? getRetry(options.retry) : 0);\n const alreadyRequested = useRef(false);\n\n const [isFetching, setIsFetching] = useState(false);\n const [isLoading, setIsLoading] = useState(false);\n const [isError, setIsError] = useState(false);\n const [isRefetching, setIsRefetching] = useState(false);\n const [isSuccess, setIsSuccess] = useState(!!options?.placeholderData);\n\n const [error, setError] = useState<Error | undefined>(undefined);\n const [data, setData] = useState<Data | undefined>(options?.placeholderData);\n\n const abortControllerRef = useRef<AbortController>(new AbortController());\n const intervalIdRef = useRef<ReturnType<typeof setInterval>>(undefined);\n\n const keys = options?.keys ?? [];\n\n const abort = () => {\n abortControllerRef.current.abort();\n abortControllerRef.current = new AbortController();\n };\n\n const request = (action: 'init' | 'refetch') => {\n abort();\n\n setIsFetching(true);\n if (action === 'init') {\n alreadyRequested.current = true;\n setIsLoading(true);\n }\n if (action === 'refetch') setIsRefetching(true);\n callback({ signal: abortControllerRef.current.signal, keys })\n .then((response) => {\n const data = options?.select ? options?.select(response) : response;\n options?.onSuccess?.(data as Data);\n setData(data as Data);\n setIsSuccess(true);\n setError(undefined);\n setIsError(false);\n setIsFetching(false);\n if (action === 'init') setIsLoading(false);\n if (action === 'refetch') setIsRefetching(false);\n })\n .catch((error: Error) => {\n if (retryCountRef.current > 0) {\n retryCountRef.current -= 1;\n const retryDelay =\n typeof options?.retryDelay === 'function'\n ? options?.retryDelay(retryCountRef.current, error)\n : options?.retryDelay;\n\n if (retryDelay) {\n setTimeout(() => request(action), retryDelay);\n return;\n }\n\n return request(action);\n }\n options?.onError?.(error);\n setData(undefined);\n setIsSuccess(false);\n setError(error);\n setIsError(true);\n setIsFetching(false);\n if (action === 'init') setIsLoading(false);\n if (action === 'refetch') setIsRefetching(false);\n retryCountRef.current = options?.retry ? getRetry(options.retry) : 0;\n })\n .finally(() => {\n if (options?.refetchInterval) {\n const interval = setInterval(() => {\n clearInterval(interval);\n request('refetch');\n }, options?.refetchInterval);\n intervalIdRef.current = interval;\n }\n });\n };\n\n useMount(() => {\n if (!enabled) return;\n request('init');\n });\n\n useDidUpdate(() => {\n if (!enabled) return;\n request(alreadyRequested.current ? 'refetch' : 'init');\n }, [enabled, ...keys]);\n\n useEffect(() => {\n return () => {\n clearInterval(intervalIdRef.current);\n };\n }, [enabled, options?.refetchInterval, options?.retry, ...keys]);\n\n const refetch = () => request('refetch');\n\n return {\n abort,\n data,\n error,\n refetch,\n isFetching,\n isLoading,\n isError,\n isSuccess,\n isRefetching\n };\n};\n"],"names":["useQuery","callback","options","enabled","retryCountRef","useRef","getRetry","alreadyRequested","isFetching","setIsFetching","useState","isLoading","setIsLoading","isError","setIsError","isRefetching","setIsRefetching","isSuccess","setIsSuccess","error","setError","data","setData","abortControllerRef","intervalIdRef","keys","abort","request","action","response","retryDelay","interval","useMount","useDidUpdate","useEffect"],"mappings":"2OAgFaA,EAAW,CACtBC,EACAC,IACyB,CACzB,MAAMC,EAAUD,GAAS,SAAW,GAC9BE,EAAgBC,EAAAA,OAAOH,GAAS,MAAQI,EAAAA,SAASJ,EAAQ,KAAK,EAAI,CAAC,EACnEK,EAAmBF,EAAAA,OAAO,EAAK,EAE/B,CAACG,EAAYC,CAAa,EAAIC,EAAAA,SAAS,EAAK,EAC5C,CAACC,EAAWC,CAAY,EAAIF,EAAAA,SAAS,EAAK,EAC1C,CAACG,EAASC,CAAU,EAAIJ,EAAAA,SAAS,EAAK,EACtC,CAACK,EAAcC,CAAe,EAAIN,EAAAA,SAAS,EAAK,EAChD,CAACO,EAAWC,CAAY,EAAIR,EAAAA,SAAS,CAAC,CAACR,GAAS,eAAe,EAE/D,CAACiB,EAAOC,CAAQ,EAAIV,EAAAA,SAA4B,MAAS,EACzD,CAACW,EAAMC,CAAO,EAAIZ,EAAAA,SAA2BR,GAAS,eAAe,EAErEqB,EAAqBlB,EAAAA,OAAwB,IAAI,eAAiB,EAClEmB,EAAgBnB,EAAAA,OAAuC,MAAS,EAEhEoB,EAAOvB,GAAS,MAAQ,CAAA,EAExBwB,EAAQ,IAAM,CAClBH,EAAmB,QAAQ,MAAA,EAC3BA,EAAmB,QAAU,IAAI,eAAgB,EAG7CI,EAAWC,GAA+B,CAC9CF,EAAA,EAEAjB,EAAc,EAAI,EACdmB,IAAW,SACbrB,EAAiB,QAAU,GAC3BK,EAAa,EAAI,GAEfgB,IAAW,WAAWZ,EAAgB,EAAI,EAC9Cf,EAAS,CAAE,OAAQsB,EAAmB,QAAQ,OAAQ,KAAAE,EAAM,EACzD,KAAMI,GAAa,CAClB,MAAMR,EAAOnB,GAAS,OAASA,GAAS,OAAO2B,CAAQ,EAAIA,EAC3D3B,GAAS,YAAYmB,CAAY,EACjCC,EAAQD,CAAY,EACpBH,EAAa,EAAI,EACjBE,EAAS,MAAS,EAClBN,EAAW,EAAK,EAChBL,EAAc,EAAK,EACfmB,IAAW,QAAQhB,EAAa,EAAK,EACrCgB,IAAW,WAAWZ,EAAgB,EAAK,CAAA,CAChD,EACA,MAAOG,GAAiB,CACvB,GAAIf,EAAc,QAAU,EAAG,CAC7BA,EAAc,SAAW,EACzB,MAAM0B,EACJ,OAAO5B,GAAS,YAAe,WAC3BA,GAAS,WAAWE,EAAc,QAASe,CAAK,EAChDjB,GAAS,WAEf,GAAI4B,EAAY,CACd,WAAW,IAAMH,EAAQC,CAAM,EAAGE,CAAU,EAC5C,MAAA,CAGF,OAAOH,EAAQC,CAAM,CAAA,CAEvB1B,GAAS,UAAUiB,CAAK,EACxBG,EAAQ,MAAS,EACjBJ,EAAa,EAAK,EAClBE,EAASD,CAAK,EACdL,EAAW,EAAI,EACfL,EAAc,EAAK,EACfmB,IAAW,QAAQhB,EAAa,EAAK,EACrCgB,IAAW,WAAWZ,EAAgB,EAAK,EAC/CZ,EAAc,QAAUF,GAAS,MAAQI,EAAAA,SAASJ,EAAQ,KAAK,EAAI,CAAA,CACpE,EACA,QAAQ,IAAM,CACb,GAAIA,GAAS,gBAAiB,CAC5B,MAAM6B,EAAW,YAAY,IAAM,CACjC,cAAcA,CAAQ,EACtBJ,EAAQ,SAAS,CAAA,EAChBzB,GAAS,eAAe,EAC3BsB,EAAc,QAAUO,CAAA,CAC1B,CACD,CAAA,EAGLC,OAAAA,EAAAA,SAAS,IAAM,CACR7B,GACLwB,EAAQ,MAAM,CAAA,CACf,EAEDM,EAAAA,aAAa,IAAM,CACZ9B,GACLwB,EAAQpB,EAAiB,QAAU,UAAY,MAAM,CAAA,EACpD,CAACJ,EAAS,GAAGsB,CAAI,CAAC,EAErBS,EAAAA,UAAU,IACD,IAAM,CACX,cAAcV,EAAc,OAAO,CAAA,EAEpC,CAACrB,EAASD,GAAS,gBAAiBA,GAAS,MAAO,GAAGuB,CAAI,CAAC,EAIxD,CACL,MAAAC,EACA,KAAAL,EACA,MAAAF,EACA,QANc,IAAMQ,EAAQ,SAAS,EAOrC,WAAAnB,EACA,UAAAG,EACA,QAAAE,EACA,UAAAI,EACA,aAAAF,CAAA,CAEJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),f=(e,r)=>{if(e===r)return!0;if(e==null||r==null)return e===r;if(typeof e!=typeof r)return!1;if(typeof e!="object")return e===r;if(Array.isArray(e)!==Array.isArray(r))return!1;if(Array.isArray(e))return e.length===r.length&&e.every((n,l)=>f(n,r[l]));const t=Object.keys(e),u=Object.keys(r);if(t.length!==u.length)return!1;for(const n of t)if(!u.includes(n)||!f(e[n],r[n]))return!1;return!0},c=(e,r)=>{const t=s.useRef(r);(!t.current||!f(r,t.current))&&(t.current=r),s.useEffect(e,t.current)};exports.deepEqual=f;exports.useShallowEffect=c;
|
|
2
|
+
//# sourceMappingURL=useShallowEffect.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useShallowEffect.cjs","sources":["../../../../src/hooks/useShallowEffect/useShallowEffect.ts"],"sourcesContent":["import type { DependencyList, EffectCallback } from 'react';\n\nimport { useEffect, useRef } from 'react';\n\nexport const deepEqual = (a: any, b: any): boolean => {\n if (a === b) return true;\n if (a == null || b == null) return a === b;\n if (typeof a !== typeof b) return false;\n if (typeof a !== 'object') return a === b;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n if (Array.isArray(a))\n return a.length === b.length && a.every((value, index) => deepEqual(value, b[index]));\n\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (!keysB.includes(key)) return false;\n if (!deepEqual(a[key], b[key])) return false;\n }\n\n return true;\n};\n\n/**\n * @name useShallowEffect\n * @description - Hook that executes an effect only when dependencies change shallowly or deeply.\n * @category Lifecycle\n *\n * @param {EffectCallback} effect The effect callback\n * @param {DependencyList} [deps] The dependencies list for the effect\n *\n * @example\n * useShallowEffect(() => console.log(\"effect\"), [user]);\n */\nexport const useShallowEffect = (effect: EffectCallback, deps?: DependencyList) => {\n const depsRef = useRef<DependencyList>(deps);\n\n if (!depsRef.current || !deepEqual(deps, depsRef.current)) {\n depsRef.current = deps;\n }\n\n useEffect(effect, depsRef.current);\n};\n"],"names":["deepEqual","a","b","value","index","keysA","keysB","key","useShallowEffect","effect","deps","depsRef","useRef","useEffect"],"mappings":"yGAIaA,EAAY,CAACC,EAAQC,IAAoB,CACpD,GAAID,IAAMC,EAAG,MAAO,GACpB,GAAID,GAAK,MAAQC,GAAK,YAAaD,IAAMC,EACzC,GAAI,OAAOD,GAAM,OAAOC,EAAG,MAAO,GAClC,GAAI,OAAOD,GAAM,SAAU,OAAOA,IAAMC,EACxC,GAAI,MAAM,QAAQD,CAAC,IAAM,MAAM,QAAQC,CAAC,EAAG,MAAO,GAElD,GAAI,MAAM,QAAQD,CAAC,EACjB,OAAOA,EAAE,SAAWC,EAAE,QAAUD,EAAE,MAAM,CAACE,EAAOC,IAAUJ,EAAUG,EAAOD,EAAEE,CAAK,CAAC,CAAC,EAEtF,MAAMC,EAAQ,OAAO,KAAKJ,CAAC,EACrBK,EAAQ,OAAO,KAAKJ,CAAC,EAE3B,GAAIG,EAAM,SAAWC,EAAM,OAAQ,MAAO,GAE1C,UAAWC,KAAOF,EAEhB,GADI,CAACC,EAAM,SAASC,CAAG,GACnB,CAACP,EAAUC,EAAEM,CAAG,EAAGL,EAAEK,CAAG,CAAC,EAAG,MAAO,GAGzC,MAAO,EACT,EAaaC,EAAmB,CAACC,EAAwBC,IAA0B,CACjF,MAAMC,EAAUC,EAAAA,OAAuBF,CAAI,GAEvC,CAACC,EAAQ,SAAW,CAACX,EAAUU,EAAMC,EAAQ,OAAO,KACtDA,EAAQ,QAAUD,GAGpBG,YAAUJ,EAAQE,EAAQ,OAAO,CACnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStorage.cjs","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/* The use storage initial value type */\nexport type UseStorageInitialValue<Value> = (() => Value) | Value;\n\n/* The use storage options type */\nexport interface UseStorageOptions<Value> {\n /* The initial value of the storage */\n initialValue?: UseStorageInitialValue<Value>;\n /* The storage to be used */\n storage?: Storage;\n /* The deserializer function to be invoked */\n deserializer?: (value: string) => Value;\n /* The serializer function to be invoked */\n serializer?: (value: Value) => string;\n}\n\n/* The use storage return type */\nexport interface UseStorageReturn<Value> {\n /* The value of the storage */\n value: Value;\n /* The error state of the storage */\n remove: () => void;\n /* The loading state of the storage */\n set: (value: Value) => void;\n}\n\nexport interface UseStorage {\n <Value>(
|
|
1
|
+
{"version":3,"file":"useStorage.cjs","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/* The use storage initial value type */\nexport type UseStorageInitialValue<Value> = (() => Value) | Value;\n\n/* The use storage options type */\nexport interface UseStorageOptions<Value> {\n /* The initial value of the storage */\n initialValue?: UseStorageInitialValue<Value>;\n /* The storage to be used */\n storage?: Storage;\n /* The deserializer function to be invoked */\n deserializer?: (value: string) => Value;\n /* The serializer function to be invoked */\n serializer?: (value: Value) => string;\n}\n\n/* The use storage return type */\nexport interface UseStorageReturn<Value> {\n /* The value of the storage */\n value: Value;\n /* The error state of the storage */\n remove: () => void;\n /* The loading state of the storage */\n set: (value: Value) => void;\n}\n\nexport interface UseStorage {\n <Value>(key: string, options?: UseStorageOptions<Value>): UseStorageReturn<Value | undefined>;\n\n <Value>(\n key: string,\n initialValue?: UseStorageInitialValue<Value>\n ): UseStorageReturn<Value | undefined>;\n}\n\nexport const STORAGE_EVENT = 'reactuse-storage';\n\nexport const dispatchStorageEvent = (params: Partial<StorageEvent>) =>\n window.dispatchEvent(new StorageEvent(STORAGE_EVENT, params));\n\nconst setStorageItem = (storage: Storage, key: string, value: string) => {\n const oldValue = storage.getItem(key);\n\n storage.setItem(key, value);\n dispatchStorageEvent({\n key,\n oldValue,\n newValue: value,\n storageArea: storage\n });\n};\n\nconst removeStorageItem = (storage: Storage, key: string) => {\n const oldValue = storage.getItem(key);\n\n storage.removeItem(key);\n dispatchStorageEvent({ key, oldValue, newValue: null, storageArea: storage });\n};\n\nconst getStorageItem = (storage: Storage, key: string) => {\n const value = storage.getItem(key);\n if (!value) return undefined;\n return value;\n};\n\n/**\n * @name useStorage\n * @description - Hook that manages storage value\n * @category Browser\n *\n * @overload\n * @param {string} key The key of the storage\n * @param {UseStorageInitialValue<Value>} [initialValue] The initial value of the storage\n * @returns {UseStorageReturn<Value>} The value and the set function\n *\n * @overload\n * @param {string} key The key of the storage\n * @param {(value: Value) => string} [params.serializer] The serializer function\n * @param {(value: string) => Value} [params.deserializer] The deserializer function\n * @param {Storage} [params.storage] The storage\n * @param {UseStorageInitialValue<Value>} [params.initialValue] The initial value of the storage\n * @returns {UseStorageReturn<Value>} The value and the set function\n *\n * @example\n * const { value, set, remove } = useStorage('key', 'value');\n */\nexport const useStorage = (<Value>(key: string, params?: any): UseStorageReturn<Value> => {\n const options = (\n typeof params === 'object' &&\n params &&\n ('serializer' in params ||\n 'deserializer' in params ||\n 'initialValue' in params ||\n 'storage' in params)\n ? params\n : undefined\n ) as UseStorageOptions<Value>;\n\n const initialValue = (options ? options?.initialValue : params) as UseStorageInitialValue<Value>;\n\n if (typeof window === 'undefined') {\n const value = typeof initialValue === 'function' ? (initialValue as () => any)() : initialValue;\n return {\n value,\n set: () => {},\n remove: () => {}\n };\n }\n\n const serializer = (value: Value) => {\n if (options?.serializer) return options.serializer(value);\n if (typeof value === 'string') return value;\n return JSON.stringify(value);\n };\n\n const storage = options?.storage ?? window?.localStorage;\n\n const set = (value: Value) => setStorageItem(storage, key, serializer(value));\n const remove = () => removeStorageItem(storage, key);\n\n const deserializer = (value: string) => {\n if (options?.deserializer) return options.deserializer(value);\n if (value === 'undefined') return undefined as unknown as Value;\n\n try {\n return JSON.parse(value) as Value;\n } catch {\n return value as Value;\n }\n };\n\n const [value, setValue] = useState<Value | undefined>(() => {\n const storageValue = getStorageItem(storage, key);\n if (storageValue === undefined && initialValue !== undefined) {\n const value =\n typeof initialValue === 'function' ? (initialValue as () => Value)() : initialValue;\n setStorageItem(storage, key, serializer(value));\n return value;\n }\n return storageValue ? deserializer(storageValue) : undefined;\n });\n\n useEffect(() => {\n const onChange = () => {\n const storageValue = getStorageItem(storage, key);\n setValue(storageValue ? deserializer(storageValue) : undefined);\n };\n window.addEventListener(STORAGE_EVENT, onChange);\n return () => window.removeEventListener(STORAGE_EVENT, onChange);\n }, [key]);\n\n return {\n value: value as Value,\n set,\n remove\n };\n}) as UseStorage;\n"],"names":["STORAGE_EVENT","dispatchStorageEvent","params","setStorageItem","storage","key","value","oldValue","removeStorageItem","getStorageItem","useStorage","options","initialValue","serializer","set","remove","deserializer","setValue","useState","storageValue","useEffect","onChange"],"mappings":"yGAoCaA,EAAgB,mBAEhBC,EAAwBC,GACnC,OAAO,cAAc,IAAI,aAAaF,EAAeE,CAAM,CAAC,EAExDC,EAAiB,CAACC,EAAkBC,EAAaC,IAAkB,CACvE,MAAMC,EAAWH,EAAQ,QAAQC,CAAG,EAEpCD,EAAQ,QAAQC,EAAKC,CAAK,EAC1BL,EAAqB,CACnB,IAAAI,EACA,SAAAE,EACA,SAAUD,EACV,YAAaF,CAAA,CACd,CACH,EAEMI,EAAoB,CAACJ,EAAkBC,IAAgB,CAC3D,MAAME,EAAWH,EAAQ,QAAQC,CAAG,EAEpCD,EAAQ,WAAWC,CAAG,EACtBJ,EAAqB,CAAE,IAAAI,EAAK,SAAAE,EAAU,SAAU,KAAM,YAAaH,EAAS,CAC9E,EAEMK,EAAiB,CAACL,EAAkBC,IAAgB,CACxD,MAAMC,EAAQF,EAAQ,QAAQC,CAAG,EACjC,GAAKC,EACL,OAAOA,CACT,EAuBaI,EAAc,CAAQL,EAAaH,IAA0C,CACxF,MAAMS,EACJ,OAAOT,GAAW,UAClBA,IACC,eAAgBA,GACf,iBAAkBA,GAClB,iBAAkBA,GAClB,YAAaA,GACXA,EACA,OAGAU,EAAgBD,EAAUA,GAAS,aAAeT,EAExD,GAAI,OAAO,OAAW,IAEpB,MAAO,CACL,MAFY,OAAOU,GAAiB,WAAcA,IAA+BA,EAGjF,IAAK,IAAM,CAAA,EACX,OAAQ,IAAM,CAAA,CAAC,EAInB,MAAMC,EAAcP,GACdK,GAAS,WAAmBA,EAAQ,WAAWL,CAAK,EACpD,OAAOA,GAAU,SAAiBA,EAC/B,KAAK,UAAUA,CAAK,EAGvBF,EAAUO,GAAS,SAAW,QAAQ,aAEtCG,EAAOR,GAAiBH,EAAeC,EAASC,EAAKQ,EAAWP,CAAK,CAAC,EACtES,EAAS,IAAMP,EAAkBJ,EAASC,CAAG,EAE7CW,EAAgBV,GAAkB,CACtC,GAAIK,GAAS,aAAc,OAAOA,EAAQ,aAAaL,CAAK,EAC5D,GAAIA,IAAU,YAEd,GAAI,CACF,OAAO,KAAK,MAAMA,CAAK,CAAA,MACjB,CACN,OAAOA,CAAA,CACT,EAGI,CAACA,EAAOW,CAAQ,EAAIC,EAAAA,SAA4B,IAAM,CAC1D,MAAMC,EAAeV,EAAeL,EAASC,CAAG,EAChD,GAAIc,IAAiB,QAAaP,IAAiB,OAAW,CAC5D,MAAMN,EACJ,OAAOM,GAAiB,WAAcA,IAAiCA,EACzE,OAAAT,EAAeC,EAASC,EAAKQ,EAAWP,CAAK,CAAC,EACvCA,CAAA,CAET,OAAOa,EAAeH,EAAaG,CAAY,EAAI,MAAA,CACpD,EAEDC,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAW,IAAM,CACrB,MAAMF,EAAeV,EAAeL,EAASC,CAAG,EAChDY,EAASE,EAAeH,EAAaG,CAAY,EAAI,MAAS,CAAA,EAEhE,cAAO,iBAAiBnB,EAAeqB,CAAQ,EACxC,IAAM,OAAO,oBAAoBrB,EAAeqB,CAAQ,CAAA,EAC9D,CAAChB,CAAG,CAAC,EAED,CACL,MAAAC,EACA,IAAAQ,EACA,OAAAC,CAAA,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),R=(o,u)=>{const c=e.useRef(o),t=e.useRef(null),r=e.useRef(!1),l=e.useRef(u),n=e.useRef(null);return c.current=o,l.current=u,e.useMemo(()=>{const s=()=>{r.current=!1,n.current&&(c.current.apply(void 0,n.current),n.current=null,setTimeout(s,l.current))},a=()=>{t.current&&(clearTimeout(t.current),t.current=null,r.current=!1)},f=function(...i){n.current=i,!r.current&&(c.current.apply(this,i),r.current=!0,t.current=setTimeout(s,l.current))};return f.cancel=a,console.log("cancel",t.current),a(),f},[u])};exports.useThrottleCallback=R;
|
|
2
2
|
//# sourceMappingURL=useThrottleCallback.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThrottleCallback.cjs","sources":["../../../../src/hooks/useThrottleCallback/useThrottleCallback.ts"],"sourcesContent":["import { useMemo } from 'react';\n\
|
|
1
|
+
{"version":3,"file":"useThrottleCallback.cjs","sources":["../../../../src/hooks/useThrottleCallback/useThrottleCallback.ts"],"sourcesContent":["import { useMemo, useRef } from 'react';\n\nexport type ThrottledCallback<Params extends unknown[]> = ((...args: Params) => void) & {\n cancel: () => void;\n};\n\n/**\n * @name useThrottleCallback\n * @description - Hook that creates a throttled callback\n * @category Utilities\n *\n * @template Params The type of the params\n * @template Return The type of the return\n * @param {(...args: Params) => Return} callback The callback function\n * @param {number} delay The delay in milliseconds\n * @returns {(...args: Params) => Return} The callback with throttle\n *\n * @example\n * const throttled = useThrottleCallback(() => console.log('callback'), 500);\n */\nexport const useThrottleCallback = <Params extends unknown[], Return>(\n callback: (...args: Params) => Return,\n delay: number\n): ThrottledCallback<Params> => {\n const internalCallbackRef = useRef(callback);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isCalledRef = useRef(false);\n const delayRef = useRef(delay);\n const lastArgsRef = useRef<Params | null>(null);\n\n internalCallbackRef.current = callback;\n delayRef.current = delay;\n\n const throttled = useMemo(() => {\n const timer = () => {\n isCalledRef.current = false;\n\n if (!lastArgsRef.current) return;\n internalCallbackRef.current.apply(this, lastArgsRef.current);\n lastArgsRef.current = null;\n setTimeout(timer, delayRef.current);\n };\n\n const cancel = () => {\n if (!timeoutRef.current) return;\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n isCalledRef.current = false;\n };\n\n const throttledCallback = function (this: any, ...args: Params) {\n lastArgsRef.current = args;\n if (isCalledRef.current) return;\n\n internalCallbackRef.current.apply(this, args);\n isCalledRef.current = true;\n timeoutRef.current = setTimeout(timer, delayRef.current);\n };\n\n throttledCallback.cancel = cancel;\n\n console.log('cancel', timeoutRef.current);\n cancel();\n return throttledCallback;\n }, [delay]);\n\n return throttled;\n};\n"],"names":["useThrottleCallback","callback","delay","internalCallbackRef","useRef","timeoutRef","isCalledRef","delayRef","lastArgsRef","useMemo","timer","cancel","throttledCallback","args"],"mappings":"yGAoBaA,EAAsB,CACjCC,EACAC,IAC8B,CAC9B,MAAMC,EAAsBC,EAAAA,OAAOH,CAAQ,EACrCI,EAAaD,EAAAA,OAA6C,IAAI,EAC9DE,EAAcF,EAAAA,OAAO,EAAK,EAC1BG,EAAWH,EAAAA,OAAOF,CAAK,EACvBM,EAAcJ,EAAAA,OAAsB,IAAI,EAE9C,OAAAD,EAAoB,QAAUF,EAC9BM,EAAS,QAAUL,EAEDO,EAAAA,QAAQ,IAAM,CAC9B,MAAMC,EAAQ,IAAM,CAClBJ,EAAY,QAAU,GAEjBE,EAAY,UACjBL,EAAoB,QAAQ,MAAM,OAAMK,EAAY,OAAO,EAC3DA,EAAY,QAAU,KACtB,WAAWE,EAAOH,EAAS,OAAO,EAAA,EAG9BI,EAAS,IAAM,CACdN,EAAW,UAChB,aAAaA,EAAW,OAAO,EAC/BA,EAAW,QAAU,KACrBC,EAAY,QAAU,GAAA,EAGlBM,EAAoB,YAAwBC,EAAc,CAC9DL,EAAY,QAAUK,EAClB,CAAAP,EAAY,UAEhBH,EAAoB,QAAQ,MAAM,KAAMU,CAAI,EAC5CP,EAAY,QAAU,GACtBD,EAAW,QAAU,WAAWK,EAAOH,EAAS,OAAO,EAAA,EAGzD,OAAAK,EAAkB,OAASD,EAE3B,QAAQ,IAAI,SAAUN,EAAW,OAAO,EACxCM,EAAA,EACOC,CAAA,EACN,CAACV,CAAK,CAAC,CAGZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWizard.cjs","sources":["../../../../src/hooks/useWizard/useWizard.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport interface WizardItem<WizardStepId> {\n id: WizardStepId;\n nodes?: WizardStepId[];\n}\n\n/**\n * @name useWizard\n * @description - Hook that manages a wizard\n * @category Utilities\n *\n * @param {WizardItem<WizardStepId>[]} map The map of the wizard\n * @param {WizardStepId} [initialStepId] The initial step id\n * @returns {UseWizardReturn<WizardStepId>} An object containing the current step id and functions to interact with the wizard\n *\n * @example\n * const { currentStepId, set, reset, back, history } = useWizard([\n * { id: 'step1', nodes: ['step2', 'step3'] },\n * { id: 'step2', nodes: ['step3'] },\n * { id: 'step3', nodes: [] },\n * ])\n */\nexport const useWizard = <WizardStepId extends string>(\n map: WizardItem<WizardStepId>[],\n initialStepId?: WizardStepId\n) => {\n const initialId = initialStepId ?? map[0].id;\n const wizardMap = new Map(map.map((wizardItem) => [wizardItem.id, wizardItem]));\n const [currentStepId, setCurrentStepId] = useState(initialId);\n const [history, setHistory] = useState<WizardStepId[]>([initialId]);\n\n const set = (id: WizardStepId) => {\n if (!wizardMap.get(currentStepId)?.nodes?.includes(id))\n throw new Error(`Can't go to ${id} from ${currentStepId}`);\n\n setHistory([...history, id]);\n setCurrentStepId(id);\n };\n\n const back = () => {\n if (history.length === 1) return;\n\n const previousStepId = history[history.length - 2];\n if (!wizardMap.get(currentStepId)?.nodes?.includes(previousStepId))\n throw new Error(`Can't go to ${previousStepId} from ${currentStepId}`);\n\n setHistory(history.slice(0, -1));\n setCurrentStepId(history[history.length - 2]);\n };\n\n const reset = () => {\n setCurrentStepId(initialId);\n setHistory([initialId]);\n };\n\n return { currentStepId, set, reset, back, history };\n};\n"],"names":["useWizard","map","initialStepId","initialId","wizardMap","wizardItem","currentStepId","setCurrentStepId","useState","history","setHistory","id","previousStepId"],"mappings":"yGAuBaA,EAAY,CACvBC,EACAC,IACG,CACH,MAAMC,EAAYD,GAAiBD,EAAI,CAAC,EAAE,GACpCG,EAAY,IAAI,IAAIH,EAAI,IAAKI,GAAe,CAACA,EAAW,GAAIA,CAAU,CAAC,CAAC,EACxE,CAACC,EAAeC,CAAgB,EAAIC,EAAAA,SAASL,CAAS,EACtD,CAACM,EAASC,CAAU,EAAIF,EAAAA,SAAyB,CAACL,CAAS,CAAC,EA0BlE,MAAO,CAAE,cAAAG,EAAe,IAxBXK,GAAqB,CAChC,GAAI,CAACP,EAAU,IAAIE,CAAa,GAAG,OAAO,SAASK,CAAE,EACnD,MAAM,IAAI,MAAM,eAAeA,CAAE,SAASL,CAAa,EAAE,EAE3DI,EAAW,CAAC,GAAGD,EAASE,CAAE,CAAC,EAC3BJ,EAAiBI,CAAE,CAAA,EAmBQ,MALf,IAAM,CAClBJ,EAAiBJ,CAAS,EAC1BO,EAAW,CAACP,CAAS,CAAC,CAAA,EAGY,KAhBvB,IAAM,CACjB,GAAIM,EAAQ,SAAW,EAAG,OAE1B,MAAMG,EAAiBH,EAAQA,EAAQ,OAAS,CAAC,EACjD,GAAI,CAACL,EAAU,IAAIE,CAAa,GAAG,OAAO,SAASM,CAAc,EAC/D,MAAM,IAAI,MAAM,eAAeA,CAAc,SAASN,CAAa,EAAE,EAEvEI,EAAWD,EAAQ,MAAM,EAAG,EAAE,CAAC,EAC/BF,EAAiBE,EAAQA,EAAQ,OAAS,CAAC,CAAC,CAAA,EAQJ,QAAAA,CAAA,CAC5C"}
|
|
1
|
+
{"version":3,"file":"useWizard.cjs","sources":["../../../../src/hooks/useWizard/useWizard.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport interface WizardItem<WizardStepId> {\n id: WizardStepId;\n nodes?: WizardStepId[];\n}\n\n/**\n * @name useWizard\n * @description - Hook that manages a wizard\n * @category Utilities\n *\n * @param {WizardItem<WizardStepId>[]} map The map of the wizard\n * @param {WizardStepId} [initialStepId] The initial step id\n * @returns {UseWizardReturn<WizardStepId>} An object containing the current step id and functions to interact with the wizard\n *\n * @example\n * const { currentStepId, set, reset, back, next, history } = useWizard([\n * { id: 'step1', nodes: ['step2', 'step3'] },\n * { id: 'step2', nodes: ['step3'] },\n * { id: 'step3', nodes: [] },\n * ])\n */\nexport const useWizard = <WizardStepId extends string>(\n map: WizardItem<WizardStepId>[],\n initialStepId?: WizardStepId\n) => {\n const initialId = initialStepId ?? map[0].id;\n const wizardMap = new Map(map.map((wizardItem) => [wizardItem.id, wizardItem]));\n const [currentStepId, setCurrentStepId] = useState(initialId);\n const [history, setHistory] = useState<WizardStepId[]>([initialId]);\n\n const set = (id: WizardStepId) => {\n if (!wizardMap.get(currentStepId)?.nodes?.includes(id))\n throw new Error(`Can't go to ${id} from ${currentStepId}`);\n\n setHistory([...history, id]);\n setCurrentStepId(id);\n };\n\n const back = () => {\n if (history.length === 1) return;\n\n const previousStepId = history[history.length - 2];\n if (!wizardMap.get(currentStepId)?.nodes?.includes(previousStepId))\n throw new Error(`Can't go to ${previousStepId} from ${currentStepId}`);\n\n setHistory(history.slice(0, -1));\n setCurrentStepId(history[history.length - 2]);\n };\n\n const reset = () => {\n setCurrentStepId(initialId);\n setHistory([initialId]);\n };\n\n return { currentStepId, set, reset, back, history };\n};\n"],"names":["useWizard","map","initialStepId","initialId","wizardMap","wizardItem","currentStepId","setCurrentStepId","useState","history","setHistory","id","previousStepId"],"mappings":"yGAuBaA,EAAY,CACvBC,EACAC,IACG,CACH,MAAMC,EAAYD,GAAiBD,EAAI,CAAC,EAAE,GACpCG,EAAY,IAAI,IAAIH,EAAI,IAAKI,GAAe,CAACA,EAAW,GAAIA,CAAU,CAAC,CAAC,EACxE,CAACC,EAAeC,CAAgB,EAAIC,EAAAA,SAASL,CAAS,EACtD,CAACM,EAASC,CAAU,EAAIF,EAAAA,SAAyB,CAACL,CAAS,CAAC,EA0BlE,MAAO,CAAE,cAAAG,EAAe,IAxBXK,GAAqB,CAChC,GAAI,CAACP,EAAU,IAAIE,CAAa,GAAG,OAAO,SAASK,CAAE,EACnD,MAAM,IAAI,MAAM,eAAeA,CAAE,SAASL,CAAa,EAAE,EAE3DI,EAAW,CAAC,GAAGD,EAASE,CAAE,CAAC,EAC3BJ,EAAiBI,CAAE,CAAA,EAmBQ,MALf,IAAM,CAClBJ,EAAiBJ,CAAS,EAC1BO,EAAW,CAACP,CAAS,CAAC,CAAA,EAGY,KAhBvB,IAAM,CACjB,GAAIM,EAAQ,SAAW,EAAG,OAE1B,MAAMG,EAAiBH,EAAQA,EAAQ,OAAS,CAAC,EACjD,GAAI,CAACL,EAAU,IAAIE,CAAa,GAAG,OAAO,SAASM,CAAc,EAC/D,MAAM,IAAI,MAAM,eAAeA,CAAc,SAASN,CAAa,EAAE,EAEvEI,EAAWD,EAAQ,MAAM,EAAG,EAAE,CAAC,EAC/BF,EAAiBE,EAAQA,EAAQ,OAAS,CAAC,CAAC,CAAA,EAQJ,QAAAA,CAAA,CAC5C"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./helpers/createContext/createContext.cjs"),C=require("./helpers/createEventEmitter/createEventEmitter.cjs"),R=require("./helpers/createReactiveContext/createReactiveContext.cjs"),p=require("./helpers/createStore/createStore.cjs"),y=require("./hooks/useActiveElement/useActiveElement.cjs"),v=require("./hooks/useAsync/useAsync.cjs"),O=require("./hooks/useBattery/useBattery.cjs"),I=require("./hooks/useBluetooth/useBluetooth.cjs"),k=require("./hooks/useBoolean/useBoolean.cjs"),e=require("./hooks/useBreakpoints/useBreakpoints.cjs"),D=require("./hooks/useBrowserLanguage/useBrowserLanguage.cjs"),h=require("./hooks/useClickOutside/useClickOutside.cjs"),A=require("./hooks/useClipboard/useClipboard.cjs"),b=require("./hooks/useConst/useConst.cjs"),s=require("./hooks/useCookie/useCookie.cjs"),i=require("./hooks/useCookies/useCookies.cjs"),L=require("./hooks/useCopy/useCopy.cjs"),M=require("./hooks/useCounter/useCounter.cjs"),f=require("./hooks/useCssVar/useCssVar.cjs"),_=require("./hooks/useDebounceCallback/useDebounceCallback.cjs"),N=require("./hooks/useDebounceValue/useDebounceValue.cjs"),B=require("./hooks/useDefault/useDefault.cjs"),K=require("./hooks/useDeviceMotion/useDeviceMotion.cjs"),F=require("./hooks/useDeviceOrientation/useDeviceOrientation.cjs"),V=require("./hooks/useDevicePixelRatio/useDevicePixelRatio.cjs"),U=require("./hooks/useDidUpdate/useDidUpdate.cjs"),w=require("./hooks/useDisclosure/useDisclosure.cjs"),W=require("./hooks/useDisplayMedia/useDisplayMedia.cjs"),x=require("./hooks/useDocumentEvent/useDocumentEvent.cjs"),H=require("./hooks/useDocumentTitle/useDocumentTitle.cjs"),Q=require("./hooks/useDocumentVisibility/useDocumentVisibility.cjs"),z=require("./hooks/useDoubleClick/useDoubleClick.cjs"),G=require("./hooks/useDropZone/useDropZone.cjs"),X=require("./hooks/useElementSize/useElementSize.cjs"),Z=require("./hooks/useEvent/useEvent.cjs"),j=require("./hooks/useEventListener/useEventListener.cjs"),J=require("./hooks/useEventSource/useEventSource.cjs"),Y=require("./hooks/useEyeDropper/useEyeDropper.cjs"),$=require("./hooks/useFavicon/useFavicon.cjs"),ee=require("./hooks/useField/useField.cjs"),se=require("./hooks/useFileDialog/useFileDialog.cjs"),ue=require("./hooks/useFocus/useFocus.cjs"),re=require("./hooks/useFps/useFps.cjs"),te=require("./hooks/useFul/useFul.cjs"),oe=require("./hooks/useFullscreen/useFullscreen.cjs"),n=require("./hooks/useGamepad/useGamepad.cjs"),ie=require("./hooks/useGeolocation/useGeolocation.cjs"),ne=require("./hooks/useHash/useHash.cjs"),c=require("./hooks/useHotkeys/useHotkeys.cjs"),ce=require("./hooks/useHover/useHover.cjs"),ae=require("./hooks/useIdle/useIdle.cjs"),le=require("./hooks/useImage/useImage.cjs"),Se=require("./hooks/useInfiniteScroll/useInfiniteScroll.cjs"),qe=require("./hooks/useIntersectionObserver/useIntersectionObserver.cjs"),de=require("./hooks/useInterval/useInterval.cjs"),ge=require("./hooks/useIsFirstRender/useIsFirstRender.cjs"),Ee=require("./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs"),Pe=require("./hooks/useKeyboard/useKeyboard.cjs"),Te=require("./hooks/useKeyPress/useKeyPress.cjs"),me=require("./hooks/useKeyPressEvent/useKeyPressEvent.cjs"),Ce=require("./hooks/useKeysPressed/useKeysPressed.cjs"),Re=require("./hooks/useLastChanged/useLastChanged.cjs"),pe=require("./hooks/useLatest/useLatest.cjs"),ye=require("./hooks/useLess/useLess.cjs"),ve=require("./hooks/useList/useList.cjs"),Oe=require("./hooks/useLocalStorage/useLocalStorage.cjs"),Ie=require("./hooks/useLockCallback/useLockCallback.cjs"),ke=require("./hooks/useLogger/useLogger.cjs"),De=require("./hooks/useLongPress/useLongPress.cjs"),he=require("./hooks/useMap/useMap.cjs"),Ae=require("./hooks/useMeasure/useMeasure.cjs"),be=require("./hooks/useMediaQuery/useMediaQuery.cjs"),Le=require("./hooks/useMemory/useMemory.cjs"),Me=require("./hooks/useMount/useMount.cjs"),fe=require("./hooks/useMouse/useMouse.cjs"),_e=require("./hooks/useMutation/useMutation.cjs"),Ne=require("./hooks/useMutationObserver/useMutationObserver.cjs"),a=require("./hooks/useNetwork/useNetwork.cjs"),Be=require("./hooks/useOffsetPagination/useOffsetPagination.cjs"),Ke=require("./hooks/useOnce/useOnce.cjs"),Fe=require("./hooks/useOnline/useOnline.cjs"),l=require("./hooks/useOperatingSystem/useOperatingSystem.cjs"),Ve=require("./hooks/useOptimistic/useOptimistic.cjs"),Ue=require("./hooks/useOrientation/useOrientation.cjs"),we=require("./hooks/useOtpCredential/useOtpCredential.cjs"),We=require("./hooks/usePageLeave/usePageLeave.cjs"),r=require("./hooks/usePaint/usePaint.cjs"),xe=require("./hooks/useParallax/useParallax.cjs"),He=require("./hooks/usePerformanceObserver/usePerformanceObserver.cjs"),Qe=require("./hooks/usePermission/usePermission.cjs"),ze=require("./hooks/usePointerLock/usePointerLock.cjs"),Ge=require("./hooks/usePostMessage/usePostMessage.cjs"),Xe=require("./hooks/usePreferredColorScheme/usePreferredColorScheme.cjs"),Ze=require("./hooks/usePreferredContrast/usePreferredContrast.cjs"),je=require("./hooks/usePreferredDark/usePreferredDark.cjs"),Je=require("./hooks/usePreferredLanguages/usePreferredLanguages.cjs"),Ye=require("./hooks/usePreferredReducedMotion/usePreferredReducedMotion.cjs"),$e=require("./hooks/usePrevious/usePrevious.cjs"),es=require("./hooks/useQuery/useQuery.cjs"),ss=require("./hooks/useQueue/useQueue.cjs"),us=require("./hooks/useRaf/useRaf.cjs"),rs=require("./hooks/useRafValue/useRafValue.cjs"),ts=require("./hooks/useRefState/useRefState.cjs"),os=require("./hooks/useRenderCount/useRenderCount.cjs"),is=require("./hooks/useRenderInfo/useRenderInfo.cjs"),ns=require("./hooks/useRerender/useRerender.cjs"),cs=require("./hooks/useResizeObserver/useResizeObserver.cjs"),as=require("./hooks/useScreenOrientation/useScreenOrientation.cjs"),S=require("./hooks/useScript/useScript.cjs"),ls=require("./hooks/useScroll/useScroll.cjs"),Ss=require("./hooks/useScrollIntoView/useScrollIntoView.cjs"),qs=require("./hooks/useScrollTo/useScrollTo.cjs"),ds=require("./hooks/useSessionStorage/useSessionStorage.cjs"),gs=require("./hooks/useSet/useSet.cjs"),Es=require("./hooks/useShare/useShare.cjs"),q=require("./hooks/useSpeechRecognition/useSpeechRecognition.cjs"),Ps=require("./hooks/useSpeechSynthesis/useSpeechSynthesis.cjs"),d=require("./hooks/useStateHistory/useStateHistory.cjs"),Ts=require("./hooks/useStep/useStep.cjs"),ms=require("./hooks/useSticky/useSticky.cjs"),Cs=require("./hooks/useStopwatch/useStopwatch.cjs"),t=require("./hooks/useStorage/useStorage.cjs"),Rs=require("./hooks/useTextDirection/useTextDirection.cjs"),g=require("./hooks/useTextSelection/useTextSelection.cjs"),ps=require("./hooks/useThrottleCallback/useThrottleCallback.cjs"),ys=require("./hooks/useThrottleValue/useThrottleValue.cjs"),vs=require("./hooks/useTime/useTime.cjs"),Os=require("./hooks/useTimeout/useTimeout.cjs"),E=require("./hooks/useTimer/useTimer.cjs"),Is=require("./hooks/useToggle/useToggle.cjs"),ks=require("./hooks/useUnmount/useUnmount.cjs"),u=require("./hooks/useUrlSearchParam/useUrlSearchParam.cjs"),Ds=require("./hooks/useUrlSearchParams/useUrlSearchParams.cjs"),hs=require("./hooks/useVibrate/useVibrate.cjs"),As=require("./hooks/useWakeLock/useWakeLock.cjs"),bs=require("./hooks/useWebSocket/useWebSocket.cjs"),Ls=require("./hooks/useWindowEvent/useWindowEvent.cjs"),Ms=require("./hooks/useWindowFocus/useWindowFocus.cjs"),P=require("./hooks/useWindowScroll/useWindowScroll.cjs"),fs=require("./hooks/useWindowSize/useWindowSize.cjs"),_s=require("./hooks/useWizard/useWizard.cjs"),T=require("./utils/helpers/copy.cjs"),Ns=require("./utils/helpers/debounce.cjs"),Bs=require("./utils/helpers/getDate.cjs"),o=require("./utils/helpers/getElement.cjs"),Ks=require("./utils/helpers/getRetry.cjs"),Fs=require("./utils/helpers/isTarget.cjs"),Vs=require("./utils/helpers/throttle.cjs");exports.createContext=m.createContext;exports.createEventEmitter=C.createEventEmitter;exports.createReactiveContext=R.createReactiveContext;exports.createStore=p.createStore;exports.useActiveElement=y.useActiveElement;exports.useAsync=v.useAsync;exports.useBattery=O.useBattery;exports.useBluetooth=I.useBluetooth;exports.useBoolean=k.useBoolean;exports.BREAKPOINTS_ANT_DESIGN=e.BREAKPOINTS_ANT_DESIGN;exports.BREAKPOINTS_BOOTSTRAP_V5=e.BREAKPOINTS_BOOTSTRAP_V5;exports.BREAKPOINTS_MANTINE=e.BREAKPOINTS_MANTINE;exports.BREAKPOINTS_MASTER_CSS=e.BREAKPOINTS_MASTER_CSS;exports.BREAKPOINTS_MATERIAL_UI=e.BREAKPOINTS_MATERIAL_UI;exports.BREAKPOINTS_PRIME_FLEX=e.BREAKPOINTS_PRIME_FLEX;exports.BREAKPOINTS_QUASAR_V2=e.BREAKPOINTS_QUASAR_V2;exports.BREAKPOINTS_SEMANTIC=e.BREAKPOINTS_SEMANTIC;exports.BREAKPOINTS_TAILWIND=e.BREAKPOINTS_TAILWIND;exports.useBreakpoints=e.useBreakpoints;exports.useBrowserLanguage=D.useBrowserLanguage;exports.useClickOutside=h.useClickOutside;exports.useClipboard=A.useClipboard;exports.useConst=b.useConst;exports.COOKIE_EVENT=s.COOKIE_EVENT;exports.dispatchCookieEvent=s.dispatchCookieEvent;exports.getCookie=s.getCookie;exports.getCookies=s.getCookies;exports.removeCookie=s.removeCookie;exports.removeCookieItem=s.removeCookieItem;exports.setCookie=s.setCookie;exports.setCookieItem=s.setCookieItem;exports.useCookie=s.useCookie;exports.clearCookies=i.clearCookies;exports.useCookies=i.useCookies;exports.useCopy=L.useCopy;exports.useCounter=M.useCounter;exports.useCssVar=f.useCssVar;exports.useDebounceCallback=_.useDebounceCallback;exports.useDebounceValue=N.useDebounceValue;exports.useDefault=B.useDefault;exports.useDeviceMotion=K.useDeviceMotion;exports.useDeviceOrientation=F.useDeviceOrientation;exports.useDevicePixelRatio=V.useDevicePixelRatio;exports.useDidUpdate=U.useDidUpdate;exports.useDisclosure=w.useDisclosure;exports.useDisplayMedia=W.useDisplayMedia;exports.useDocumentEvent=x.useDocumentEvent;exports.useDocumentTitle=H.useDocumentTitle;exports.useDocumentVisibility=Q.useDocumentVisibility;exports.useDoubleClick=z.useDoubleClick;exports.useDropZone=G.useDropZone;exports.useElementSize=X.useElementSize;exports.useEvent=Z.useEvent;exports.useEventListener=j.useEventListener;exports.useEventSource=J.useEventSource;exports.useEyeDropper=Y.useEyeDropper;exports.useFavicon=$.useFavicon;exports.useField=ee.useField;exports.useFileDialog=se.useFileDialog;exports.useFocus=ue.useFocus;exports.useFps=re.useFps;exports.useFul=te.useFul;exports.useFullscreen=oe.useFullscreen;exports.mapGamepadToXbox360Controller=n.mapGamepadToXbox360Controller;exports.useGamepad=n.useGamepad;exports.useGeolocation=ie.useGeolocation;exports.useHash=ne.useHash;exports.isHotkeyMatch=c.isHotkeyMatch;exports.useHotkeys=c.useHotkeys;exports.useHover=ce.useHover;exports.useIdle=ae.useIdle;exports.useImage=le.useImage;exports.useInfiniteScroll=Se.useInfiniteScroll;exports.useIntersectionObserver=qe.useIntersectionObserver;exports.useInterval=de.useInterval;exports.useIsFirstRender=ge.useIsFirstRender;exports.useIsomorphicLayoutEffect=Ee.useIsomorphicLayoutEffect;exports.useKeyboard=Pe.useKeyboard;exports.useKeyPress=Te.useKeyPress;exports.useKeyPressEvent=me.useKeyPressEvent;exports.useKeysPressed=Ce.useKeysPressed;exports.useLastChanged=Re.useLastChanged;exports.useLatest=pe.useLatest;exports.useLess=ye.useLess;exports.useList=ve.useList;exports.useLocalStorage=Oe.useLocalStorage;exports.useLockCallback=Ie.useLockCallback;exports.useLogger=ke.useLogger;exports.useLongPress=De.useLongPress;exports.useMap=he.useMap;exports.useMeasure=Ae.useMeasure;exports.useMediaQuery=be.useMediaQuery;exports.useMemory=Le.useMemory;exports.useMount=Me.useMount;exports.useMouse=fe.useMouse;exports.useMutation=_e.useMutation;exports.useMutationObserver=Ne.useMutationObserver;exports.getConnection=a.getConnection;exports.useNetwork=a.useNetwork;exports.useOffsetPagination=Be.useOffsetPagination;exports.useOnce=Ke.useOnce;exports.useOnline=Fe.useOnline;exports.getOperatingSystem=l.getOperatingSystem;exports.useOperatingSystem=l.useOperatingSystem;exports.useOptimistic=Ve.useOptimistic;exports.useOrientation=Ue.useOrientation;exports.useOtpCredential=we.useOtpCredential;exports.usePageLeave=We.usePageLeave;exports.Paint=r.Paint;exports.Pointer=r.Pointer;exports.usePaint=r.usePaint;exports.useParallax=xe.useParallax;exports.usePerformanceObserver=He.usePerformanceObserver;exports.usePermission=Qe.usePermission;exports.usePointerLock=ze.usePointerLock;exports.usePostMessage=Ge.usePostMessage;exports.usePreferredColorScheme=Xe.usePreferredColorScheme;exports.usePreferredContrast=Ze.usePreferredContrast;exports.usePreferredDark=je.usePreferredDark;exports.usePreferredLanguages=Je.usePreferredLanguages;exports.usePreferredReducedMotion=Ye.usePreferredReducedMotion;exports.usePrevious=$e.usePrevious;exports.useQuery=es.useQuery;exports.useQueue=ss.useQueue;exports.useRaf=us.useRaf;exports.useRafValue=rs.useRafValue;exports.useRefState=ts.useRefState;exports.useRenderCount=os.useRenderCount;exports.useRenderInfo=is.useRenderInfo;exports.useRerender=ns.useRerender;exports.useResizeObserver=cs.useResizeObserver;exports.useScreenOrientation=as.useScreenOrientation;exports.SCRIPT_STATUS_ATTRIBUTE_NAME=S.SCRIPT_STATUS_ATTRIBUTE_NAME;exports.useScript=S.useScript;exports.useScroll=ls.useScroll;exports.useScrollIntoView=Ss.useScrollIntoView;exports.useScrollTo=qs.useScrollTo;exports.useSessionStorage=ds.useSessionStorage;exports.useSet=gs.useSet;exports.useShare=Es.useShare;exports.getSpeechRecognition=q.getSpeechRecognition;exports.useSpeechRecognition=q.useSpeechRecognition;exports.useSpeechSynthesis=Ps.useSpeechSynthesis;exports.stateHistoryReducer=d.stateHistoryReducer;exports.useStateHistory=d.useStateHistory;exports.useStep=Ts.useStep;exports.useSticky=ms.useSticky;exports.useStopwatch=Cs.useStopwatch;exports.STORAGE_EVENT=t.STORAGE_EVENT;exports.dispatchStorageEvent=t.dispatchStorageEvent;exports.useStorage=t.useStorage;exports.useTextDirection=Rs.useTextDirection;exports.getRangesSelection=g.getRangesSelection;exports.useTextSelection=g.useTextSelection;exports.useThrottleCallback=ps.useThrottleCallback;exports.useThrottleValue=ys.useThrottleValue;exports.useTime=vs.useTime;exports.useTimeout=Os.useTimeout;exports.getTimeFromSeconds=E.getTimeFromSeconds;exports.useTimer=E.useTimer;exports.useToggle=Is.useToggle;exports.useUnmount=ks.useUnmount;exports.URL_SEARCH_PARAMS_EVENT=u.URL_SEARCH_PARAMS_EVENT;exports.createQueryString=u.createQueryString;exports.dispatchUrlSearchParamsEvent=u.dispatchUrlSearchParamsEvent;exports.getUrlSearchParams=u.getUrlSearchParams;exports.useUrlSearchParam=u.useUrlSearchParam;exports.useUrlSearchParams=Ds.useUrlSearchParams;exports.useVibrate=hs.useVibrate;exports.useWakeLock=As.useWakeLock;exports.useWebSocket=bs.useWebSocket;exports.useWindowEvent=Ls.useWindowEvent;exports.useWindowFocus=Ms.useWindowFocus;exports.scrollTo=P.scrollTo;exports.useWindowScroll=P.useWindowScroll;exports.useWindowSize=fs.useWindowSize;exports.useWizard=_s.useWizard;exports.copy=T.copy;exports.legacyCopyToClipboard=T.legacyCopyToClipboard;exports.debounce=Ns.debounce;exports.getDate=Bs.getDate;exports.getElement=o.getElement;exports.target=o.target;exports.targetSymbol=o.targetSymbol;exports.getRetry=Ks.getRetry;exports.isTarget=Fs.isTarget;exports.throttle=Vs.throttle;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("./helpers/createContext/createContext.cjs"),p=require("./helpers/createEventEmitter/createEventEmitter.cjs"),y=require("./helpers/createReactiveContext/createReactiveContext.cjs"),O=require("./helpers/createStore/createStore.cjs"),v=require("./hooks/useActiveElement/useActiveElement.cjs"),I=require("./hooks/useAsync/useAsync.cjs"),k=require("./hooks/useBattery/useBattery.cjs"),D=require("./hooks/useBluetooth/useBluetooth.cjs"),h=require("./hooks/useBoolean/useBoolean.cjs"),e=require("./hooks/useBreakpoints/useBreakpoints.cjs"),A=require("./hooks/useBrowserLanguage/useBrowserLanguage.cjs"),L=require("./hooks/useClickOutside/useClickOutside.cjs"),b=require("./hooks/useClipboard/useClipboard.cjs"),f=require("./hooks/useConst/useConst.cjs"),s=require("./hooks/useCookie/useCookie.cjs"),i=require("./hooks/useCookies/useCookies.cjs"),M=require("./hooks/useCopy/useCopy.cjs"),_=require("./hooks/useCounter/useCounter.cjs"),N=require("./hooks/useCssVar/useCssVar.cjs"),B=require("./hooks/useDebounceCallback/useDebounceCallback.cjs"),F=require("./hooks/useDebounceValue/useDebounceValue.cjs"),K=require("./hooks/useDefault/useDefault.cjs"),V=require("./hooks/useDeviceMotion/useDeviceMotion.cjs"),U=require("./hooks/useDeviceOrientation/useDeviceOrientation.cjs"),w=require("./hooks/useDevicePixelRatio/useDevicePixelRatio.cjs"),W=require("./hooks/useDidUpdate/useDidUpdate.cjs"),H=require("./hooks/useDisclosure/useDisclosure.cjs"),x=require("./hooks/useDisplayMedia/useDisplayMedia.cjs"),Q=require("./hooks/useDocumentEvent/useDocumentEvent.cjs"),z=require("./hooks/useDocumentTitle/useDocumentTitle.cjs"),G=require("./hooks/useDocumentVisibility/useDocumentVisibility.cjs"),n=require("./hooks/useDoubleClick/useDoubleClick.cjs"),X=require("./hooks/useDropZone/useDropZone.cjs"),Z=require("./hooks/useElementSize/useElementSize.cjs"),j=require("./hooks/useEvent/useEvent.cjs"),J=require("./hooks/useEventListener/useEventListener.cjs"),Y=require("./hooks/useEventSource/useEventSource.cjs"),$=require("./hooks/useEyeDropper/useEyeDropper.cjs"),ee=require("./hooks/useFavicon/useFavicon.cjs"),se=require("./hooks/useField/useField.cjs"),ue=require("./hooks/useFileDialog/useFileDialog.cjs"),re=require("./hooks/useFocus/useFocus.cjs"),te=require("./hooks/useFps/useFps.cjs"),oe=require("./hooks/useFul/useFul.cjs"),ie=require("./hooks/useFullscreen/useFullscreen.cjs"),c=require("./hooks/useGamepad/useGamepad.cjs"),ne=require("./hooks/useGeolocation/useGeolocation.cjs"),ce=require("./hooks/useHash/useHash.cjs"),a=require("./hooks/useHotkeys/useHotkeys.cjs"),ae=require("./hooks/useHover/useHover.cjs"),le=require("./hooks/useIdle/useIdle.cjs"),Se=require("./hooks/useImage/useImage.cjs"),qe=require("./hooks/useInfiniteScroll/useInfiniteScroll.cjs"),Ee=require("./hooks/useIntersectionObserver/useIntersectionObserver.cjs"),de=require("./hooks/useInterval/useInterval.cjs"),ge=require("./hooks/useIsFirstRender/useIsFirstRender.cjs"),Te=require("./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs"),Pe=require("./hooks/useKeyboard/useKeyboard.cjs"),me=require("./hooks/useKeyPress/useKeyPress.cjs"),Ce=require("./hooks/useKeyPressEvent/useKeyPressEvent.cjs"),Re=require("./hooks/useKeysPressed/useKeysPressed.cjs"),pe=require("./hooks/useLastChanged/useLastChanged.cjs"),ye=require("./hooks/useLatest/useLatest.cjs"),Oe=require("./hooks/useLess/useLess.cjs"),ve=require("./hooks/useList/useList.cjs"),Ie=require("./hooks/useLocalStorage/useLocalStorage.cjs"),ke=require("./hooks/useLockCallback/useLockCallback.cjs"),De=require("./hooks/useLogger/useLogger.cjs"),he=require("./hooks/useLongPress/useLongPress.cjs"),Ae=require("./hooks/useMap/useMap.cjs"),Le=require("./hooks/useMeasure/useMeasure.cjs"),be=require("./hooks/useMediaQuery/useMediaQuery.cjs"),fe=require("./hooks/useMemory/useMemory.cjs"),Me=require("./hooks/useMount/useMount.cjs"),_e=require("./hooks/useMouse/useMouse.cjs"),Ne=require("./hooks/useMutation/useMutation.cjs"),Be=require("./hooks/useMutationObserver/useMutationObserver.cjs"),l=require("./hooks/useNetwork/useNetwork.cjs"),Fe=require("./hooks/useOffsetPagination/useOffsetPagination.cjs"),Ke=require("./hooks/useOnce/useOnce.cjs"),Ve=require("./hooks/useOnline/useOnline.cjs"),S=require("./hooks/useOperatingSystem/useOperatingSystem.cjs"),Ue=require("./hooks/useOptimistic/useOptimistic.cjs"),we=require("./hooks/useOrientation/useOrientation.cjs"),We=require("./hooks/useOtpCredential/useOtpCredential.cjs"),He=require("./hooks/usePageLeave/usePageLeave.cjs"),r=require("./hooks/usePaint/usePaint.cjs"),xe=require("./hooks/useParallax/useParallax.cjs"),Qe=require("./hooks/usePerformanceObserver/usePerformanceObserver.cjs"),ze=require("./hooks/usePermission/usePermission.cjs"),Ge=require("./hooks/usePointerLock/usePointerLock.cjs"),Xe=require("./hooks/usePostMessage/usePostMessage.cjs"),Ze=require("./hooks/usePreferredColorScheme/usePreferredColorScheme.cjs"),je=require("./hooks/usePreferredContrast/usePreferredContrast.cjs"),Je=require("./hooks/usePreferredDark/usePreferredDark.cjs"),Ye=require("./hooks/usePreferredLanguages/usePreferredLanguages.cjs"),$e=require("./hooks/usePreferredReducedMotion/usePreferredReducedMotion.cjs"),es=require("./hooks/usePrevious/usePrevious.cjs"),ss=require("./hooks/useQuery/useQuery.cjs"),us=require("./hooks/useQueue/useQueue.cjs"),rs=require("./hooks/useRaf/useRaf.cjs"),ts=require("./hooks/useRafValue/useRafValue.cjs"),os=require("./hooks/useRefState/useRefState.cjs"),is=require("./hooks/useRenderCount/useRenderCount.cjs"),ns=require("./hooks/useRenderInfo/useRenderInfo.cjs"),cs=require("./hooks/useRerender/useRerender.cjs"),as=require("./hooks/useResizeObserver/useResizeObserver.cjs"),ls=require("./hooks/useScreenOrientation/useScreenOrientation.cjs"),q=require("./hooks/useScript/useScript.cjs"),Ss=require("./hooks/useScroll/useScroll.cjs"),qs=require("./hooks/useScrollIntoView/useScrollIntoView.cjs"),Es=require("./hooks/useScrollTo/useScrollTo.cjs"),ds=require("./hooks/useSessionStorage/useSessionStorage.cjs"),gs=require("./hooks/useSet/useSet.cjs"),E=require("./hooks/useShallowEffect/useShallowEffect.cjs"),Ts=require("./hooks/useShare/useShare.cjs"),d=require("./hooks/useSpeechRecognition/useSpeechRecognition.cjs"),Ps=require("./hooks/useSpeechSynthesis/useSpeechSynthesis.cjs"),g=require("./hooks/useStateHistory/useStateHistory.cjs"),ms=require("./hooks/useStep/useStep.cjs"),Cs=require("./hooks/useSticky/useSticky.cjs"),Rs=require("./hooks/useStopwatch/useStopwatch.cjs"),t=require("./hooks/useStorage/useStorage.cjs"),ps=require("./hooks/useTextDirection/useTextDirection.cjs"),T=require("./hooks/useTextSelection/useTextSelection.cjs"),ys=require("./hooks/useThrottleCallback/useThrottleCallback.cjs"),Os=require("./hooks/useThrottleValue/useThrottleValue.cjs"),vs=require("./hooks/useTime/useTime.cjs"),Is=require("./hooks/useTimeout/useTimeout.cjs"),P=require("./hooks/useTimer/useTimer.cjs"),ks=require("./hooks/useToggle/useToggle.cjs"),Ds=require("./hooks/useUnmount/useUnmount.cjs"),u=require("./hooks/useUrlSearchParam/useUrlSearchParam.cjs"),hs=require("./hooks/useUrlSearchParams/useUrlSearchParams.cjs"),As=require("./hooks/useVibrate/useVibrate.cjs"),Ls=require("./hooks/useWakeLock/useWakeLock.cjs"),bs=require("./hooks/useWebSocket/useWebSocket.cjs"),fs=require("./hooks/useWindowEvent/useWindowEvent.cjs"),Ms=require("./hooks/useWindowFocus/useWindowFocus.cjs"),m=require("./hooks/useWindowScroll/useWindowScroll.cjs"),_s=require("./hooks/useWindowSize/useWindowSize.cjs"),Ns=require("./hooks/useWizard/useWizard.cjs"),C=require("./utils/helpers/copy.cjs"),Bs=require("./utils/helpers/debounce.cjs"),Fs=require("./utils/helpers/getDate.cjs"),o=require("./utils/helpers/getElement.cjs"),Ks=require("./utils/helpers/getRetry.cjs"),Vs=require("./utils/helpers/isTarget.cjs"),Us=require("./utils/helpers/throttle.cjs");exports.createContext=R.createContext;exports.createEventEmitter=p.createEventEmitter;exports.createReactiveContext=y.createReactiveContext;exports.createStore=O.createStore;exports.useActiveElement=v.useActiveElement;exports.useAsync=I.useAsync;exports.useBattery=k.useBattery;exports.useBluetooth=D.useBluetooth;exports.useBoolean=h.useBoolean;exports.BREAKPOINTS_ANT_DESIGN=e.BREAKPOINTS_ANT_DESIGN;exports.BREAKPOINTS_BOOTSTRAP_V5=e.BREAKPOINTS_BOOTSTRAP_V5;exports.BREAKPOINTS_MANTINE=e.BREAKPOINTS_MANTINE;exports.BREAKPOINTS_MASTER_CSS=e.BREAKPOINTS_MASTER_CSS;exports.BREAKPOINTS_MATERIAL_UI=e.BREAKPOINTS_MATERIAL_UI;exports.BREAKPOINTS_PRIME_FLEX=e.BREAKPOINTS_PRIME_FLEX;exports.BREAKPOINTS_QUASAR_V2=e.BREAKPOINTS_QUASAR_V2;exports.BREAKPOINTS_SEMANTIC=e.BREAKPOINTS_SEMANTIC;exports.BREAKPOINTS_TAILWIND=e.BREAKPOINTS_TAILWIND;exports.useBreakpoints=e.useBreakpoints;exports.useBrowserLanguage=A.useBrowserLanguage;exports.useClickOutside=L.useClickOutside;exports.useClipboard=b.useClipboard;exports.useConst=f.useConst;exports.COOKIE_EVENT=s.COOKIE_EVENT;exports.dispatchCookieEvent=s.dispatchCookieEvent;exports.getCookie=s.getCookie;exports.getCookies=s.getCookies;exports.removeCookie=s.removeCookie;exports.removeCookieItem=s.removeCookieItem;exports.setCookie=s.setCookie;exports.setCookieItem=s.setCookieItem;exports.useCookie=s.useCookie;exports.clearCookies=i.clearCookies;exports.useCookies=i.useCookies;exports.useCopy=M.useCopy;exports.useCounter=_.useCounter;exports.useCssVar=N.useCssVar;exports.useDebounceCallback=B.useDebounceCallback;exports.useDebounceValue=F.useDebounceValue;exports.useDefault=K.useDefault;exports.useDeviceMotion=V.useDeviceMotion;exports.useDeviceOrientation=U.useDeviceOrientation;exports.useDevicePixelRatio=w.useDevicePixelRatio;exports.useDidUpdate=W.useDidUpdate;exports.useDisclosure=H.useDisclosure;exports.useDisplayMedia=x.useDisplayMedia;exports.useDocumentEvent=Q.useDocumentEvent;exports.useDocumentTitle=z.useDocumentTitle;exports.useDocumentVisibility=G.useDocumentVisibility;exports.DEFAULT_THRESHOLD_TIME=n.DEFAULT_THRESHOLD_TIME;exports.useDoubleClick=n.useDoubleClick;exports.useDropZone=X.useDropZone;exports.useElementSize=Z.useElementSize;exports.useEvent=j.useEvent;exports.useEventListener=J.useEventListener;exports.useEventSource=Y.useEventSource;exports.useEyeDropper=$.useEyeDropper;exports.useFavicon=ee.useFavicon;exports.useField=se.useField;exports.useFileDialog=ue.useFileDialog;exports.useFocus=re.useFocus;exports.useFps=te.useFps;exports.useFul=oe.useFul;exports.useFullscreen=ie.useFullscreen;exports.mapGamepadToXbox360Controller=c.mapGamepadToXbox360Controller;exports.useGamepad=c.useGamepad;exports.useGeolocation=ne.useGeolocation;exports.useHash=ce.useHash;exports.isHotkeyMatch=a.isHotkeyMatch;exports.useHotkeys=a.useHotkeys;exports.useHover=ae.useHover;exports.useIdle=le.useIdle;exports.useImage=Se.useImage;exports.useInfiniteScroll=qe.useInfiniteScroll;exports.useIntersectionObserver=Ee.useIntersectionObserver;exports.useInterval=de.useInterval;exports.useIsFirstRender=ge.useIsFirstRender;exports.useIsomorphicLayoutEffect=Te.useIsomorphicLayoutEffect;exports.useKeyboard=Pe.useKeyboard;exports.useKeyPress=me.useKeyPress;exports.useKeyPressEvent=Ce.useKeyPressEvent;exports.useKeysPressed=Re.useKeysPressed;exports.useLastChanged=pe.useLastChanged;exports.useLatest=ye.useLatest;exports.useLess=Oe.useLess;exports.useList=ve.useList;exports.useLocalStorage=Ie.useLocalStorage;exports.useLockCallback=ke.useLockCallback;exports.useLogger=De.useLogger;exports.useLongPress=he.useLongPress;exports.useMap=Ae.useMap;exports.useMeasure=Le.useMeasure;exports.useMediaQuery=be.useMediaQuery;exports.useMemory=fe.useMemory;exports.useMount=Me.useMount;exports.useMouse=_e.useMouse;exports.useMutation=Ne.useMutation;exports.useMutationObserver=Be.useMutationObserver;exports.getConnection=l.getConnection;exports.useNetwork=l.useNetwork;exports.useOffsetPagination=Fe.useOffsetPagination;exports.useOnce=Ke.useOnce;exports.useOnline=Ve.useOnline;exports.getOperatingSystem=S.getOperatingSystem;exports.useOperatingSystem=S.useOperatingSystem;exports.useOptimistic=Ue.useOptimistic;exports.useOrientation=we.useOrientation;exports.useOtpCredential=We.useOtpCredential;exports.usePageLeave=He.usePageLeave;exports.Paint=r.Paint;exports.Pointer=r.Pointer;exports.usePaint=r.usePaint;exports.useParallax=xe.useParallax;exports.usePerformanceObserver=Qe.usePerformanceObserver;exports.usePermission=ze.usePermission;exports.usePointerLock=Ge.usePointerLock;exports.usePostMessage=Xe.usePostMessage;exports.usePreferredColorScheme=Ze.usePreferredColorScheme;exports.usePreferredContrast=je.usePreferredContrast;exports.usePreferredDark=Je.usePreferredDark;exports.usePreferredLanguages=Ye.usePreferredLanguages;exports.usePreferredReducedMotion=$e.usePreferredReducedMotion;exports.usePrevious=es.usePrevious;exports.useQuery=ss.useQuery;exports.useQueue=us.useQueue;exports.useRaf=rs.useRaf;exports.useRafValue=ts.useRafValue;exports.useRefState=os.useRefState;exports.useRenderCount=is.useRenderCount;exports.useRenderInfo=ns.useRenderInfo;exports.useRerender=cs.useRerender;exports.useResizeObserver=as.useResizeObserver;exports.useScreenOrientation=ls.useScreenOrientation;exports.SCRIPT_STATUS_ATTRIBUTE_NAME=q.SCRIPT_STATUS_ATTRIBUTE_NAME;exports.useScript=q.useScript;exports.useScroll=Ss.useScroll;exports.useScrollIntoView=qs.useScrollIntoView;exports.useScrollTo=Es.useScrollTo;exports.useSessionStorage=ds.useSessionStorage;exports.useSet=gs.useSet;exports.deepEqual=E.deepEqual;exports.useShallowEffect=E.useShallowEffect;exports.useShare=Ts.useShare;exports.getSpeechRecognition=d.getSpeechRecognition;exports.useSpeechRecognition=d.useSpeechRecognition;exports.useSpeechSynthesis=Ps.useSpeechSynthesis;exports.stateHistoryReducer=g.stateHistoryReducer;exports.useStateHistory=g.useStateHistory;exports.useStep=ms.useStep;exports.useSticky=Cs.useSticky;exports.useStopwatch=Rs.useStopwatch;exports.STORAGE_EVENT=t.STORAGE_EVENT;exports.dispatchStorageEvent=t.dispatchStorageEvent;exports.useStorage=t.useStorage;exports.useTextDirection=ps.useTextDirection;exports.getRangesSelection=T.getRangesSelection;exports.useTextSelection=T.useTextSelection;exports.useThrottleCallback=ys.useThrottleCallback;exports.useThrottleValue=Os.useThrottleValue;exports.useTime=vs.useTime;exports.useTimeout=Is.useTimeout;exports.getTimeFromSeconds=P.getTimeFromSeconds;exports.useTimer=P.useTimer;exports.useToggle=ks.useToggle;exports.useUnmount=Ds.useUnmount;exports.URL_SEARCH_PARAMS_EVENT=u.URL_SEARCH_PARAMS_EVENT;exports.createQueryString=u.createQueryString;exports.dispatchUrlSearchParamsEvent=u.dispatchUrlSearchParamsEvent;exports.getUrlSearchParams=u.getUrlSearchParams;exports.useUrlSearchParam=u.useUrlSearchParam;exports.useUrlSearchParams=hs.useUrlSearchParams;exports.useVibrate=As.useVibrate;exports.useWakeLock=Ls.useWakeLock;exports.useWebSocket=bs.useWebSocket;exports.useWindowEvent=fs.useWindowEvent;exports.useWindowFocus=Ms.useWindowFocus;exports.scrollTo=m.scrollTo;exports.useWindowScroll=m.useWindowScroll;exports.useWindowSize=_s.useWindowSize;exports.useWizard=Ns.useWizard;exports.copy=C.copy;exports.legacyCopyToClipboard=C.legacyCopyToClipboard;exports.debounce=Bs.debounce;exports.getDate=Fs.getDate;exports.getElement=o.getElement;exports.target=o.target;exports.targetSymbol=o.targetSymbol;exports.getRetry=Ks.getRetry;exports.isTarget=Vs.isTarget;exports.throttle=Us.throttle;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState as t } from "react";
|
|
2
2
|
import { copy as r } from "../../utils/helpers/copy.mjs";
|
|
3
3
|
const n = (p = 1e3) => {
|
|
4
|
-
const [s, a] = t(
|
|
4
|
+
const [s, a] = t(), [c, o] = t(!1);
|
|
5
5
|
return { value: s, copied: c, copy: async (e) => {
|
|
6
6
|
await r(e), a(e), o(!0), setTimeout(() => o(!1), p);
|
|
7
7
|
} };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCopy.mjs","sources":["../../../../src/hooks/useCopy/useCopy.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { copy } from '@/utils/helpers';\n\n/** The use copy return type */\nexport interface UseCopyReturn {\n /** Whether copy is in progress */\n copied: boolean;\n /** The copied value */\n value
|
|
1
|
+
{"version":3,"file":"useCopy.mjs","sources":["../../../../src/hooks/useCopy/useCopy.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { copy } from '@/utils/helpers';\n\n/** The use copy return type */\nexport interface UseCopyReturn {\n /** Whether copy is in progress */\n copied: boolean;\n /** The copied value */\n value?: string;\n /** Function to copy text */\n copy: (value: string) => Promise<void>;\n}\n\n/** The use copy params type */\nexport interface UseCopyParams {\n /** Reset delay in milliseconds */\n resetDelay?: number;\n}\n\n/**\n * @name useCopy\n * @description - Hook that manages copying text with status reset\n * @category Browser\n *\n * @browserapi navigator.clipboard https://developer.mozilla.org/en-US/docs/Web/API/Navigator/clipboard\n *\n * @param {number} [delay=1000] Delay in ms before resetting copied status\n * @returns {UseCopyReturn} An object containing the copied value, status and copy function\n *\n * @example\n * const { copied, value, copy } = useCopy();\n */\nexport const useCopy = (delay: number = 1000): UseCopyReturn => {\n const [value, setValue] = useState<string | undefined>();\n const [copied, setCopied] = useState(false);\n\n const copyToClipboard = async (text: string) => {\n await copy(text);\n setValue(text);\n setCopied(true);\n setTimeout(() => setCopied(false), delay);\n };\n\n return { value, copied, copy: copyToClipboard };\n};\n"],"names":["useCopy","delay","value","setValue","useState","copied","setCopied","text","copy"],"mappings":";;AAiCO,MAAMA,IAAU,CAACC,IAAgB,QAAwB;AAC9D,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAAA,GACpB,CAACC,GAAQC,CAAS,IAAIF,EAAS,EAAK;AAS1C,SAAO,EAAE,OAAAF,GAAO,QAAAG,GAAQ,MAPA,OAAOE,MAAiB;AAC9C,UAAMC,EAAKD,CAAI,GACfJ,EAASI,CAAI,GACbD,EAAU,EAAI,GACd,WAAW,MAAMA,EAAU,EAAK,GAAGL,CAAK;AAAA,EAAA,EAGZ;AAChC;"}
|