@usefy/usefy 0.0.13 → 0.0.15
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 +14 -40
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -11
package/README.md
CHANGED
|
@@ -27,13 +27,12 @@
|
|
|
27
27
|
<a href="#installation">Installation</a> •
|
|
28
28
|
<a href="#packages">Packages</a> •
|
|
29
29
|
<a href="#quick-start">Quick Start</a> •
|
|
30
|
-
<a href="#features">Features</a>
|
|
31
|
-
<a href="#contributing">Contributing</a>
|
|
30
|
+
<a href="#features">Features</a>
|
|
32
31
|
</p>
|
|
33
32
|
|
|
34
33
|
---
|
|
35
34
|
|
|
36
|
-
> ⚠️ **Pre-release Notice**: This project is currently in version `0.x.x` (alpha/beta stage). APIs may change between minor versions. While fully functional and tested, please use with caution in production environments.
|
|
35
|
+
> ⚠️ **Pre-release Notice**: This project is currently in version `0.x.x` (alpha/beta stage). APIs may change between minor versions. While fully functional and tested, please use with caution in production environments.
|
|
37
36
|
>
|
|
38
37
|
> 🚧 **Actively Developing**: New hooks are being added regularly. Stay tuned for more utilities!
|
|
39
38
|
|
|
@@ -48,7 +47,7 @@
|
|
|
48
47
|
- **🚀 Zero Dependencies** — Pure React implementation with no external dependencies
|
|
49
48
|
- **📦 Tree Shakeable** — Import only the hooks you need to optimize bundle size
|
|
50
49
|
- **🔷 TypeScript First** — Complete type safety with full autocomplete support
|
|
51
|
-
- **⚡ SSR
|
|
50
|
+
- **⚡ SSR Safe** — Works with Next.js, Remix, and other SSR frameworks without crashing
|
|
52
51
|
- **🧪 Well Tested** — High test coverage ensures reliability and stability
|
|
53
52
|
- **📖 Well Documented** — Detailed documentation with practical examples
|
|
54
53
|
|
|
@@ -393,45 +392,20 @@ All packages are comprehensively tested using Vitest to ensure reliability and s
|
|
|
393
392
|
|
|
394
393
|
---
|
|
395
394
|
|
|
396
|
-
##
|
|
395
|
+
## SSR Compatibility
|
|
397
396
|
|
|
398
|
-
|
|
397
|
+
All hooks are SSR-safe and will not throw errors on the server.
|
|
399
398
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
pnpm test
|
|
399
|
+
| Hook | SSR Behavior |
|
|
400
|
+
| -------------------------------------------- | ------------------------------------------------ |
|
|
401
|
+
| `useToggle`, `useCounter` | ✅ Fully compatible (pure React state) |
|
|
402
|
+
| `useDebounce`, `useThrottle` | ✅ Fully compatible (uses `setTimeout`) |
|
|
403
|
+
| `useDebounceCallback`, `useThrottleCallback` | ✅ Fully compatible |
|
|
404
|
+
| `useLocalStorage`, `useSessionStorage` | ✅ Safe — returns `initialValue` on server |
|
|
405
|
+
| `useClickAnyWhere` | ✅ Safe — event listener only attached on client |
|
|
406
|
+
| `useCopyToClipboard` | ✅ Safe — copy function only works on client |
|
|
409
407
|
|
|
410
|
-
|
|
411
|
-
pnpm build
|
|
412
|
-
|
|
413
|
-
# Run tests with coverage
|
|
414
|
-
pnpm test --coverage
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
### 🗂️ Project Structure
|
|
418
|
-
|
|
419
|
-
```
|
|
420
|
-
usefy/
|
|
421
|
-
├── packages/
|
|
422
|
-
│ ├── usefy/ # All-in-one package
|
|
423
|
-
│ ├── use-toggle/ # Boolean state
|
|
424
|
-
│ ├── use-counter/ # Counter state
|
|
425
|
-
│ ├── use-debounce/ # Value debouncing
|
|
426
|
-
│ ├── use-debounce-callback/ # Callback debouncing
|
|
427
|
-
│ ├── use-throttle/ # Value throttling
|
|
428
|
-
│ ├── use-throttle-callback/ # Callback throttling
|
|
429
|
-
│ ├── use-local-storage/ # localStorage
|
|
430
|
-
│ ├── use-session-storage/ # sessionStorage
|
|
431
|
-
│ ├── use-click-any-where/ # Click detection
|
|
432
|
-
│ └── use-copy-to-clipboard/ # Clipboard
|
|
433
|
-
└── ...
|
|
434
|
-
```
|
|
408
|
+
> **Note**: `useLocalStorage` and `useSessionStorage` include proper `typeof window` checks and will gracefully fall back to `initialValue` during server-side rendering.
|
|
435
409
|
|
|
436
410
|
---
|
|
437
411
|
|
package/dist/index.d.mts
CHANGED
|
@@ -8,3 +8,4 @@ export { UseThrottleOptions, useThrottle } from '@usefy/use-throttle';
|
|
|
8
8
|
export { ThrottledFunction, UseThrottleCallbackOptions, useThrottleCallback } from '@usefy/use-throttle-callback';
|
|
9
9
|
export { InitialValue, UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage } from '@usefy/use-local-storage';
|
|
10
10
|
export { InitialValue as SessionStorageInitialValue, UseSessionStorageOptions, UseSessionStorageReturn, useSessionStorage } from '@usefy/use-session-storage';
|
|
11
|
+
export { ClickOutsideEvent, MouseEventType, OnClickOutsideHandler, RefTarget, TouchEventType, UseOnClickOutsideOptions, useOnClickOutside } from '@usefy/use-on-click-outside';
|
package/dist/index.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export { UseThrottleOptions, useThrottle } from '@usefy/use-throttle';
|
|
|
8
8
|
export { ThrottledFunction, UseThrottleCallbackOptions, useThrottleCallback } from '@usefy/use-throttle-callback';
|
|
9
9
|
export { InitialValue, UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage } from '@usefy/use-local-storage';
|
|
10
10
|
export { InitialValue as SessionStorageInitialValue, UseSessionStorageOptions, UseSessionStorageReturn, useSessionStorage } from '@usefy/use-session-storage';
|
|
11
|
+
export { ClickOutsideEvent, MouseEventType, OnClickOutsideHandler, RefTarget, TouchEventType, UseOnClickOutsideOptions, useOnClickOutside } from '@usefy/use-on-click-outside';
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
useDebounce: () => import_use_debounce.useDebounce,
|
|
27
27
|
useDebounceCallback: () => import_use_debounce_callback.useDebounceCallback,
|
|
28
28
|
useLocalStorage: () => import_use_local_storage.useLocalStorage,
|
|
29
|
+
useOnClickOutside: () => import_use_on_click_outside.useOnClickOutside,
|
|
29
30
|
useSessionStorage: () => import_use_session_storage.useSessionStorage,
|
|
30
31
|
useThrottle: () => import_use_throttle.useThrottle,
|
|
31
32
|
useThrottleCallback: () => import_use_throttle_callback.useThrottleCallback,
|
|
@@ -42,6 +43,7 @@ var import_use_throttle = require("@usefy/use-throttle");
|
|
|
42
43
|
var import_use_throttle_callback = require("@usefy/use-throttle-callback");
|
|
43
44
|
var import_use_local_storage = require("@usefy/use-local-storage");
|
|
44
45
|
var import_use_session_storage = require("@usefy/use-session-storage");
|
|
46
|
+
var import_use_on_click_outside = require("@usefy/use-on-click-outside");
|
|
45
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
48
|
0 && (module.exports = {
|
|
47
49
|
useClickAnyWhere,
|
|
@@ -50,6 +52,7 @@ var import_use_session_storage = require("@usefy/use-session-storage");
|
|
|
50
52
|
useDebounce,
|
|
51
53
|
useDebounceCallback,
|
|
52
54
|
useLocalStorage,
|
|
55
|
+
useOnClickOutside,
|
|
53
56
|
useSessionStorage,
|
|
54
57
|
useThrottle,
|
|
55
58
|
useThrottleCallback,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Re-export all hooks from individual packages\n\n// useClickAnyWhere\nexport {\n useClickAnyWhere,\n type UseClickAnyWhereOptions,\n type ClickAnyWhereHandler,\n} from \"@usefy/use-click-any-where\";\n\n// useCopyToClipboard\nexport {\n useCopyToClipboard,\n type UseCopyToClipboardOptions,\n type UseCopyToClipboardReturn,\n type CopyFn,\n} from \"@usefy/use-copy-to-clipboard\";\n\n// useCounter\nexport { useCounter } from \"@usefy/use-counter\";\n\n// useToggle\nexport { useToggle, type UseToggleReturn } from \"@usefy/use-toggle\";\n\n// useDebounce\nexport { useDebounce, type UseDebounceOptions } from \"@usefy/use-debounce\";\n\n// useDebounceCallback\nexport {\n useDebounceCallback,\n type UseDebounceCallbackOptions,\n type DebouncedFunction,\n} from \"@usefy/use-debounce-callback\";\n\n// useThrottle\nexport { useThrottle, type UseThrottleOptions } from \"@usefy/use-throttle\";\n\n// useThrottleCallback\nexport {\n useThrottleCallback,\n type UseThrottleCallbackOptions,\n type ThrottledFunction,\n} from \"@usefy/use-throttle-callback\";\n\n// useLocalStorage\nexport {\n useLocalStorage,\n type UseLocalStorageOptions,\n type UseLocalStorageReturn,\n type InitialValue,\n} from \"@usefy/use-local-storage\";\n\n// useSessionStorage\nexport {\n useSessionStorage,\n type UseSessionStorageOptions,\n type UseSessionStorageReturn,\n type InitialValue as SessionStorageInitialValue,\n} from \"@usefy/use-session-storage\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iCAIO;AAGP,mCAKO;AAGP,yBAA2B;AAG3B,wBAAgD;AAGhD,0BAAqD;AAGrD,mCAIO;AAGP,0BAAqD;AAGrD,mCAIO;AAGP,+BAKO;AAGP,iCAKO;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Re-export all hooks from individual packages\n\n// useClickAnyWhere\nexport {\n useClickAnyWhere,\n type UseClickAnyWhereOptions,\n type ClickAnyWhereHandler,\n} from \"@usefy/use-click-any-where\";\n\n// useCopyToClipboard\nexport {\n useCopyToClipboard,\n type UseCopyToClipboardOptions,\n type UseCopyToClipboardReturn,\n type CopyFn,\n} from \"@usefy/use-copy-to-clipboard\";\n\n// useCounter\nexport { useCounter } from \"@usefy/use-counter\";\n\n// useToggle\nexport { useToggle, type UseToggleReturn } from \"@usefy/use-toggle\";\n\n// useDebounce\nexport { useDebounce, type UseDebounceOptions } from \"@usefy/use-debounce\";\n\n// useDebounceCallback\nexport {\n useDebounceCallback,\n type UseDebounceCallbackOptions,\n type DebouncedFunction,\n} from \"@usefy/use-debounce-callback\";\n\n// useThrottle\nexport { useThrottle, type UseThrottleOptions } from \"@usefy/use-throttle\";\n\n// useThrottleCallback\nexport {\n useThrottleCallback,\n type UseThrottleCallbackOptions,\n type ThrottledFunction,\n} from \"@usefy/use-throttle-callback\";\n\n// useLocalStorage\nexport {\n useLocalStorage,\n type UseLocalStorageOptions,\n type UseLocalStorageReturn,\n type InitialValue,\n} from \"@usefy/use-local-storage\";\n\n// useSessionStorage\nexport {\n useSessionStorage,\n type UseSessionStorageOptions,\n type UseSessionStorageReturn,\n type InitialValue as SessionStorageInitialValue,\n} from \"@usefy/use-session-storage\";\n\n// useOnClickOutside\nexport {\n useOnClickOutside,\n type UseOnClickOutsideOptions,\n type OnClickOutsideHandler,\n type ClickOutsideEvent,\n type RefTarget,\n type MouseEventType,\n type TouchEventType,\n} from \"@usefy/use-on-click-outside\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iCAIO;AAGP,mCAKO;AAGP,yBAA2B;AAG3B,wBAAgD;AAGhD,0BAAqD;AAGrD,mCAIO;AAGP,0BAAqD;AAGrD,mCAIO;AAGP,+BAKO;AAGP,iCAKO;AAGP,kCAQO;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -21,6 +21,9 @@ import {
|
|
|
21
21
|
import {
|
|
22
22
|
useSessionStorage
|
|
23
23
|
} from "@usefy/use-session-storage";
|
|
24
|
+
import {
|
|
25
|
+
useOnClickOutside
|
|
26
|
+
} from "@usefy/use-on-click-outside";
|
|
24
27
|
export {
|
|
25
28
|
useClickAnyWhere,
|
|
26
29
|
useCopyToClipboard,
|
|
@@ -28,6 +31,7 @@ export {
|
|
|
28
31
|
useDebounce,
|
|
29
32
|
useDebounceCallback,
|
|
30
33
|
useLocalStorage,
|
|
34
|
+
useOnClickOutside,
|
|
31
35
|
useSessionStorage,
|
|
32
36
|
useThrottle,
|
|
33
37
|
useThrottleCallback,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Re-export all hooks from individual packages\n\n// useClickAnyWhere\nexport {\n useClickAnyWhere,\n type UseClickAnyWhereOptions,\n type ClickAnyWhereHandler,\n} from \"@usefy/use-click-any-where\";\n\n// useCopyToClipboard\nexport {\n useCopyToClipboard,\n type UseCopyToClipboardOptions,\n type UseCopyToClipboardReturn,\n type CopyFn,\n} from \"@usefy/use-copy-to-clipboard\";\n\n// useCounter\nexport { useCounter } from \"@usefy/use-counter\";\n\n// useToggle\nexport { useToggle, type UseToggleReturn } from \"@usefy/use-toggle\";\n\n// useDebounce\nexport { useDebounce, type UseDebounceOptions } from \"@usefy/use-debounce\";\n\n// useDebounceCallback\nexport {\n useDebounceCallback,\n type UseDebounceCallbackOptions,\n type DebouncedFunction,\n} from \"@usefy/use-debounce-callback\";\n\n// useThrottle\nexport { useThrottle, type UseThrottleOptions } from \"@usefy/use-throttle\";\n\n// useThrottleCallback\nexport {\n useThrottleCallback,\n type UseThrottleCallbackOptions,\n type ThrottledFunction,\n} from \"@usefy/use-throttle-callback\";\n\n// useLocalStorage\nexport {\n useLocalStorage,\n type UseLocalStorageOptions,\n type UseLocalStorageReturn,\n type InitialValue,\n} from \"@usefy/use-local-storage\";\n\n// useSessionStorage\nexport {\n useSessionStorage,\n type UseSessionStorageOptions,\n type UseSessionStorageReturn,\n type InitialValue as SessionStorageInitialValue,\n} from \"@usefy/use-session-storage\";\n"],"mappings":";AAGA;AAAA,EACE;AAAA,OAGK;AAGP;AAAA,EACE;AAAA,OAIK;AAGP,SAAS,kBAAkB;AAG3B,SAAS,iBAAuC;AAGhD,SAAS,mBAA4C;AAGrD;AAAA,EACE;AAAA,OAGK;AAGP,SAAS,mBAA4C;AAGrD;AAAA,EACE;AAAA,OAGK;AAGP;AAAA,EACE;AAAA,OAIK;AAGP;AAAA,EACE;AAAA,OAIK;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Re-export all hooks from individual packages\n\n// useClickAnyWhere\nexport {\n useClickAnyWhere,\n type UseClickAnyWhereOptions,\n type ClickAnyWhereHandler,\n} from \"@usefy/use-click-any-where\";\n\n// useCopyToClipboard\nexport {\n useCopyToClipboard,\n type UseCopyToClipboardOptions,\n type UseCopyToClipboardReturn,\n type CopyFn,\n} from \"@usefy/use-copy-to-clipboard\";\n\n// useCounter\nexport { useCounter } from \"@usefy/use-counter\";\n\n// useToggle\nexport { useToggle, type UseToggleReturn } from \"@usefy/use-toggle\";\n\n// useDebounce\nexport { useDebounce, type UseDebounceOptions } from \"@usefy/use-debounce\";\n\n// useDebounceCallback\nexport {\n useDebounceCallback,\n type UseDebounceCallbackOptions,\n type DebouncedFunction,\n} from \"@usefy/use-debounce-callback\";\n\n// useThrottle\nexport { useThrottle, type UseThrottleOptions } from \"@usefy/use-throttle\";\n\n// useThrottleCallback\nexport {\n useThrottleCallback,\n type UseThrottleCallbackOptions,\n type ThrottledFunction,\n} from \"@usefy/use-throttle-callback\";\n\n// useLocalStorage\nexport {\n useLocalStorage,\n type UseLocalStorageOptions,\n type UseLocalStorageReturn,\n type InitialValue,\n} from \"@usefy/use-local-storage\";\n\n// useSessionStorage\nexport {\n useSessionStorage,\n type UseSessionStorageOptions,\n type UseSessionStorageReturn,\n type InitialValue as SessionStorageInitialValue,\n} from \"@usefy/use-session-storage\";\n\n// useOnClickOutside\nexport {\n useOnClickOutside,\n type UseOnClickOutsideOptions,\n type OnClickOutsideHandler,\n type ClickOutsideEvent,\n type RefTarget,\n type MouseEventType,\n type TouchEventType,\n} from \"@usefy/use-on-click-outside\";\n"],"mappings":";AAGA;AAAA,EACE;AAAA,OAGK;AAGP;AAAA,EACE;AAAA,OAIK;AAGP,SAAS,kBAAkB;AAG3B,SAAS,iBAAuC;AAGhD,SAAS,mBAA4C;AAGrD;AAAA,EACE;AAAA,OAGK;AAGP,SAAS,mBAA4C;AAGrD;AAAA,EACE;AAAA,OAGK;AAGP;AAAA,EACE;AAAA,OAIK;AAGP;AAAA,EACE;AAAA,OAIK;AAGP;AAAA,EACE;AAAA,OAOK;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usefy/usefy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "A collection of useful React hooks",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -17,16 +17,17 @@
|
|
|
17
17
|
],
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@usefy/use-click-any-where": "0.0.
|
|
21
|
-
"@usefy/use-copy-to-clipboard": "0.0.
|
|
22
|
-
"@usefy/use-counter": "0.0.
|
|
23
|
-
"@usefy/use-toggle": "0.0.
|
|
24
|
-
"@usefy/use-
|
|
25
|
-
"@usefy/use-debounce": "0.0.
|
|
26
|
-
"@usefy/use-
|
|
27
|
-
"@usefy/use-throttle-callback": "0.0.
|
|
28
|
-
"@usefy/use-
|
|
29
|
-
"@usefy/use-
|
|
20
|
+
"@usefy/use-click-any-where": "0.0.15",
|
|
21
|
+
"@usefy/use-copy-to-clipboard": "0.0.15",
|
|
22
|
+
"@usefy/use-counter": "0.0.15",
|
|
23
|
+
"@usefy/use-toggle": "0.0.15",
|
|
24
|
+
"@usefy/use-throttle": "0.0.15",
|
|
25
|
+
"@usefy/use-debounce-callback": "0.0.15",
|
|
26
|
+
"@usefy/use-debounce": "0.0.15",
|
|
27
|
+
"@usefy/use-throttle-callback": "0.0.15",
|
|
28
|
+
"@usefy/use-local-storage": "0.0.15",
|
|
29
|
+
"@usefy/use-session-storage": "0.0.15",
|
|
30
|
+
"@usefy/use-on-click-outside": "0.0.15"
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|
|
32
33
|
"react": "^18.0.0 || ^19.0.0"
|