@usefy/usefy 0.0.18 → 0.0.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 +32 -0
- 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 +14 -13
package/README.md
CHANGED
|
@@ -114,6 +114,7 @@ All packages require React 18 or 19:
|
|
|
114
114
|
| [@usefy/use-copy-to-clipboard](https://www.npmjs.com/package/@usefy/use-copy-to-clipboard) | Clipboard copy with fallback support | [](https://www.npmjs.com/package/@usefy/use-copy-to-clipboard) |  |
|
|
115
115
|
| [@usefy/use-event-listener](https://www.npmjs.com/package/@usefy/use-event-listener) | DOM event listener with auto cleanup | [](https://www.npmjs.com/package/@usefy/use-event-listener) |  |
|
|
116
116
|
| [@usefy/use-on-click-outside](https://www.npmjs.com/package/@usefy/use-on-click-outside) | Outside click detection for modals/dropdowns | [](https://www.npmjs.com/package/@usefy/use-on-click-outside) |  |
|
|
117
|
+
| [@usefy/use-timer](https://www.npmjs.com/package/@usefy/use-timer) | Countdown timer with drift compensation and formats | [](https://www.npmjs.com/package/@usefy/use-timer) |  |
|
|
117
118
|
|
|
118
119
|
---
|
|
119
120
|
|
|
@@ -297,6 +298,36 @@ const throttledFn = useThrottleCallback(callback, 100);
|
|
|
297
298
|
|
|
298
299
|
</details>
|
|
299
300
|
|
|
301
|
+
<details>
|
|
302
|
+
<summary><strong>useTimer</strong> — Countdown timer with accurate timing</summary>
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
import { useTimer, ms } from "@usefy/use-timer";
|
|
306
|
+
|
|
307
|
+
const timer = useTimer(ms.minutes(5), {
|
|
308
|
+
format: "MM:SS",
|
|
309
|
+
autoStart: false,
|
|
310
|
+
loop: false,
|
|
311
|
+
onComplete: () => console.log("Time's up!"),
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// Controls
|
|
315
|
+
timer.start();
|
|
316
|
+
timer.pause();
|
|
317
|
+
timer.reset();
|
|
318
|
+
timer.addTime(ms.seconds(10));
|
|
319
|
+
timer.subtractTime(ms.seconds(5));
|
|
320
|
+
|
|
321
|
+
// State
|
|
322
|
+
timer.formattedTime; // "05:00"
|
|
323
|
+
timer.progress; // 0-100
|
|
324
|
+
timer.isRunning; // boolean
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Perfect for countdown timers, Pomodoro apps, kitchen timers, and time-based UIs with smart render optimization.
|
|
328
|
+
|
|
329
|
+
</details>
|
|
330
|
+
|
|
300
331
|
### 💾 Storage
|
|
301
332
|
|
|
302
333
|
<details>
|
|
@@ -442,6 +473,7 @@ All packages are comprehensively tested using Vitest to ensure reliability and s
|
|
|
442
473
|
| use-copy-to-clipboard | 88% | 79% | 86% | 88% |
|
|
443
474
|
| use-event-listener | 96% | 91% | 100% | 96% |
|
|
444
475
|
| use-on-click-outside | 97% | 93% | 100% | 97% |
|
|
476
|
+
| use-timer | 84% | 73% | 94% | 84% |
|
|
445
477
|
|
|
446
478
|
---
|
|
447
479
|
|
package/dist/index.d.mts
CHANGED
|
@@ -10,3 +10,4 @@ export { InitialValue, UseLocalStorageOptions, UseLocalStorageReturn, useLocalSt
|
|
|
10
10
|
export { InitialValue as SessionStorageInitialValue, UseSessionStorageOptions, UseSessionStorageReturn, useSessionStorage } from '@usefy/use-session-storage';
|
|
11
11
|
export { ClickOutsideEvent, MouseEventType, OnClickOutsideHandler, RefTarget, TouchEventType, UseOnClickOutsideOptions, useOnClickOutside } from '@usefy/use-on-click-outside';
|
|
12
12
|
export { EventTargetType, UseEventListenerOptions, useEventListener } from '@usefy/use-event-listener';
|
|
13
|
+
export { TimeFormat, TimeUnit, UseTimerOptions, UseTimerReturn, useTimer } from '@usefy/use-timer';
|
package/dist/index.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export { InitialValue, UseLocalStorageOptions, UseLocalStorageReturn, useLocalSt
|
|
|
10
10
|
export { InitialValue as SessionStorageInitialValue, UseSessionStorageOptions, UseSessionStorageReturn, useSessionStorage } from '@usefy/use-session-storage';
|
|
11
11
|
export { ClickOutsideEvent, MouseEventType, OnClickOutsideHandler, RefTarget, TouchEventType, UseOnClickOutsideOptions, useOnClickOutside } from '@usefy/use-on-click-outside';
|
|
12
12
|
export { EventTargetType, UseEventListenerOptions, useEventListener } from '@usefy/use-event-listener';
|
|
13
|
+
export { TimeFormat, TimeUnit, UseTimerOptions, UseTimerReturn, useTimer } from '@usefy/use-timer';
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __export(index_exports, {
|
|
|
31
31
|
useSessionStorage: () => import_use_session_storage.useSessionStorage,
|
|
32
32
|
useThrottle: () => import_use_throttle.useThrottle,
|
|
33
33
|
useThrottleCallback: () => import_use_throttle_callback.useThrottleCallback,
|
|
34
|
+
useTimer: () => import_use_timer.useTimer,
|
|
34
35
|
useToggle: () => import_use_toggle.useToggle
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -46,6 +47,7 @@ var import_use_local_storage = require("@usefy/use-local-storage");
|
|
|
46
47
|
var import_use_session_storage = require("@usefy/use-session-storage");
|
|
47
48
|
var import_use_on_click_outside = require("@usefy/use-on-click-outside");
|
|
48
49
|
var import_use_event_listener = require("@usefy/use-event-listener");
|
|
50
|
+
var import_use_timer = require("@usefy/use-timer");
|
|
49
51
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
52
|
0 && (module.exports = {
|
|
51
53
|
useClickAnyWhere,
|
|
@@ -59,6 +61,7 @@ var import_use_event_listener = require("@usefy/use-event-listener");
|
|
|
59
61
|
useSessionStorage,
|
|
60
62
|
useThrottle,
|
|
61
63
|
useThrottleCallback,
|
|
64
|
+
useTimer,
|
|
62
65
|
useToggle
|
|
63
66
|
});
|
|
64
67
|
//# sourceMappingURL=index.js.map
|
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\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\n// useEventListener\nexport {\n useEventListener,\n type UseEventListenerOptions,\n type EventTargetType,\n} from \"@usefy/use-event-listener\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;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;AAGP,gCAIO;","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\n// useEventListener\nexport {\n useEventListener,\n type UseEventListenerOptions,\n type EventTargetType,\n} from \"@usefy/use-event-listener\";\n\n// useTimer\nexport {\n useTimer,\n type TimeUnit,\n type TimeFormat,\n type UseTimerOptions,\n type UseTimerReturn,\n} from \"@usefy/use-timer\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;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;AAGP,gCAIO;AAGP,uBAMO;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -27,6 +27,9 @@ import {
|
|
|
27
27
|
import {
|
|
28
28
|
useEventListener
|
|
29
29
|
} from "@usefy/use-event-listener";
|
|
30
|
+
import {
|
|
31
|
+
useTimer
|
|
32
|
+
} from "@usefy/use-timer";
|
|
30
33
|
export {
|
|
31
34
|
useClickAnyWhere,
|
|
32
35
|
useCopyToClipboard,
|
|
@@ -39,6 +42,7 @@ export {
|
|
|
39
42
|
useSessionStorage,
|
|
40
43
|
useThrottle,
|
|
41
44
|
useThrottleCallback,
|
|
45
|
+
useTimer,
|
|
42
46
|
useToggle
|
|
43
47
|
};
|
|
44
48
|
//# sourceMappingURL=index.mjs.map
|
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\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\n// useEventListener\nexport {\n useEventListener,\n type UseEventListenerOptions,\n type EventTargetType,\n} from \"@usefy/use-event-listener\";\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;AAGP;AAAA,EACE;AAAA,OAGK;","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\n// useEventListener\nexport {\n useEventListener,\n type UseEventListenerOptions,\n type EventTargetType,\n} from \"@usefy/use-event-listener\";\n\n// useTimer\nexport {\n useTimer,\n type TimeUnit,\n type TimeFormat,\n type UseTimerOptions,\n type UseTimerReturn,\n} from \"@usefy/use-timer\";\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;AAGP;AAAA,EACE;AAAA,OAGK;AAGP;AAAA,EACE;AAAA,OAKK;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usefy/usefy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "A collection of useful React hooks",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -17,18 +17,19 @@
|
|
|
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-debounce": "0.0.
|
|
25
|
-
"@usefy/use-debounce-callback": "0.0.
|
|
26
|
-
"@usefy/use-throttle": "0.0.
|
|
27
|
-
"@usefy/use-throttle-callback": "0.0.
|
|
28
|
-
"@usefy/use-local-storage": "0.0.
|
|
29
|
-
"@usefy/use-session-storage": "0.0.
|
|
30
|
-
"@usefy/use-on-click-outside": "0.0.
|
|
31
|
-
"@usefy/use-event-listener": "0.0.
|
|
20
|
+
"@usefy/use-click-any-where": "0.0.19",
|
|
21
|
+
"@usefy/use-copy-to-clipboard": "0.0.19",
|
|
22
|
+
"@usefy/use-counter": "0.0.19",
|
|
23
|
+
"@usefy/use-toggle": "0.0.19",
|
|
24
|
+
"@usefy/use-debounce": "0.0.19",
|
|
25
|
+
"@usefy/use-debounce-callback": "0.0.19",
|
|
26
|
+
"@usefy/use-throttle": "0.0.19",
|
|
27
|
+
"@usefy/use-throttle-callback": "0.0.19",
|
|
28
|
+
"@usefy/use-local-storage": "0.0.19",
|
|
29
|
+
"@usefy/use-session-storage": "0.0.19",
|
|
30
|
+
"@usefy/use-on-click-outside": "0.0.19",
|
|
31
|
+
"@usefy/use-event-listener": "0.0.19",
|
|
32
|
+
"@usefy/use-timer": "0.0.19"
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
34
35
|
"react": "^18.0.0 || ^19.0.0"
|