@jobber/hooks 2.9.2 → 2.9.3
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.
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
export declare function useMediaQuery(query: MediaQuery): boolean;
|
|
7
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* Sets the JS media query listener. Internal use only.
|
|
3
|
+
*/
|
|
4
|
+
export declare function useMediaQuery(CSSMediaQuery: string): boolean;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useMediaQuery =
|
|
3
|
+
exports.useMediaQuery = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const matches = (0, react_1.useSyncExternalStore)(subscribeMediaQuery, exports.mediaQueryStore.getSnapshot(query), () => true);
|
|
5
|
+
/**
|
|
6
|
+
* Sets the JS media query listener. Internal use only.
|
|
7
|
+
*/
|
|
8
|
+
function useMediaQuery(CSSMediaQuery) {
|
|
9
|
+
const [matches, setMatches] = (0, react_1.useState)(window.matchMedia(CSSMediaQuery).matches);
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
const media = window.matchMedia(CSSMediaQuery);
|
|
12
|
+
if (media.matches !== matches) {
|
|
13
|
+
setMatches(media.matches);
|
|
14
|
+
}
|
|
15
|
+
const listener = () => setMatches(media.matches);
|
|
16
|
+
media.addEventListener("change", listener);
|
|
17
|
+
return () => media.removeEventListener("change", listener);
|
|
18
|
+
}, [CSSMediaQuery]);
|
|
20
19
|
return matches;
|
|
21
20
|
}
|
|
22
21
|
exports.useMediaQuery = useMediaQuery;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const useSafeLayoutEffect: typeof
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
export declare const useSafeLayoutEffect: typeof useEffect;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/hooks",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.js",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@apollo/client": "^3.0.0",
|
|
45
45
|
"react": "^18"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "e3f8dba243561bc1da65067d3e97414f28f40c5a"
|
|
48
48
|
}
|