@sohanemon/utils 4.0.19 → 4.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.js +11 -2
- package/package.json +20 -8
package/dist/hooks/index.d.ts
CHANGED
|
@@ -27,4 +27,5 @@ export declare const useAsync: <T extends (...args: any) => any>(fn: T, opts?: U
|
|
|
27
27
|
error: Error;
|
|
28
28
|
};
|
|
29
29
|
export declare const useQuerySelector: <T extends Element>(selector: string) => T | null;
|
|
30
|
-
export
|
|
30
|
+
export declare function useIsClient(): boolean;
|
|
31
|
+
export {};
|
package/dist/hooks/index.js
CHANGED
|
@@ -44,6 +44,7 @@ export function useMediaQuery(tailwindBreakpoint) {
|
|
|
44
44
|
function handleChange() {
|
|
45
45
|
setMatches(getMatches(parsedQuery));
|
|
46
46
|
}
|
|
47
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
47
48
|
useEffect(() => {
|
|
48
49
|
const matchMedia = window.matchMedia(parsedQuery);
|
|
49
50
|
handleChange();
|
|
@@ -59,6 +60,7 @@ export function useEffectOnce(effect) {
|
|
|
59
60
|
}
|
|
60
61
|
export function useUpdateEffect(effect, deps) {
|
|
61
62
|
const isInitialMount = useRef(true);
|
|
63
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
62
64
|
useEffect(() => {
|
|
63
65
|
if (isInitialMount.current) {
|
|
64
66
|
isInitialMount.current = false;
|
|
@@ -66,7 +68,6 @@ export function useUpdateEffect(effect, deps) {
|
|
|
66
68
|
else {
|
|
67
69
|
return effect();
|
|
68
70
|
}
|
|
69
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
71
|
}, deps);
|
|
71
72
|
}
|
|
72
73
|
export function useDebounce(state, delay = 500) {
|
|
@@ -94,6 +95,7 @@ export function useTimeout(callback, delay = 1000) {
|
|
|
94
95
|
}, [delay]);
|
|
95
96
|
}
|
|
96
97
|
export function useWindowEvent(type, listener, options) {
|
|
98
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
97
99
|
useEffect(() => {
|
|
98
100
|
window.addEventListener(type, listener, options);
|
|
99
101
|
return () => window.removeEventListener(type, listener, options);
|
|
@@ -111,6 +113,7 @@ export const useLocalStorage = (key, defaultValue) => {
|
|
|
111
113
|
}, [key]);
|
|
112
114
|
// Function to update the stored value in local storage and state
|
|
113
115
|
const updateStoredValue = (valueOrFn) => {
|
|
116
|
+
// biome-ignore lint/suspicious/noImplicitAnyLet: <explanation>
|
|
114
117
|
let newValue;
|
|
115
118
|
if (typeof valueOrFn === 'function') {
|
|
116
119
|
const updateFunction = valueOrFn;
|
|
@@ -211,4 +214,10 @@ export const useQuerySelector = (selector) => {
|
|
|
211
214
|
}, [selector]);
|
|
212
215
|
return element;
|
|
213
216
|
};
|
|
214
|
-
export
|
|
217
|
+
export function useIsClient() {
|
|
218
|
+
const [isClient, setIsClient] = useState(false);
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
setIsClient(true);
|
|
221
|
+
}, []);
|
|
222
|
+
return isClient;
|
|
223
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sohanemon/utils",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.20",
|
|
4
4
|
"author": "Sohan Emon <sohanemon@outlook.com>",
|
|
5
5
|
"description": "",
|
|
6
6
|
"type": "module",
|
|
@@ -15,26 +15,38 @@
|
|
|
15
15
|
},
|
|
16
16
|
"typesVersions": {
|
|
17
17
|
"*": {
|
|
18
|
-
"core": [
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
"core": [
|
|
19
|
+
"dist/index.d.ts"
|
|
20
|
+
],
|
|
21
|
+
"hooks": [
|
|
22
|
+
"dist/hooks/index.d.ts"
|
|
23
|
+
],
|
|
24
|
+
"components": [
|
|
25
|
+
"dist/components/index.d.ts"
|
|
26
|
+
]
|
|
21
27
|
}
|
|
22
28
|
},
|
|
23
|
-
"files": [
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
24
33
|
"scripts": {
|
|
25
34
|
"build": "tsc",
|
|
26
35
|
"build:watch": "tsc --watch",
|
|
27
36
|
"export": "tsc && npm publish"
|
|
28
37
|
},
|
|
29
|
-
"keywords": [
|
|
38
|
+
"keywords": [
|
|
39
|
+
"utils",
|
|
40
|
+
"cn"
|
|
41
|
+
],
|
|
30
42
|
"license": "ISC",
|
|
31
43
|
"devDependencies": {
|
|
44
|
+
"@types/node": "^22.4.0",
|
|
45
|
+
"@types/react": "^18.3.3",
|
|
32
46
|
"typescript": "^5.5.4"
|
|
33
47
|
},
|
|
34
48
|
"dependencies": {
|
|
35
49
|
"@iconify/react": "^4.1.1",
|
|
36
|
-
"@types/node": "^22.4.0",
|
|
37
|
-
"@types/react": "^18.3.3",
|
|
38
50
|
"clsx": "^2.1.1",
|
|
39
51
|
"react": "^18.3.1",
|
|
40
52
|
"tailwind-merge": "^1.14.0"
|