@jobber/components 4.87.3 → 4.87.4-JOB-85849.0
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 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
type MediaQuery = `(${string}:${string})`;
|
|
2
|
+
export declare const mediaQueryStore: {
|
|
3
|
+
subscribe(onChange: () => void, query: MediaQuery): () => void;
|
|
4
|
+
getSnapshot(query: MediaQuery): () => boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function useMediaQuery(query: MediaQuery): boolean;
|
|
7
|
+
export {};
|
package/dist/DataList/index.js
CHANGED
|
@@ -101,7 +101,19 @@ function useDataListContext() {
|
|
|
101
101
|
return React.useContext(DataListContext);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
const mediaQueryStore = {
|
|
105
|
+
subscribe(onChange, query) {
|
|
106
|
+
const matchMedia = window.matchMedia(query);
|
|
107
|
+
matchMedia.addEventListener("change", onChange);
|
|
108
|
+
return () => {
|
|
109
|
+
matchMedia.removeEventListener("change", onChange);
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
getSnapshot(query) {
|
|
113
|
+
return () => window.matchMedia(query).matches;
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
function useMediaQuery(query) {
|
|
105
117
|
/**
|
|
106
118
|
* matchMedia have had full support for browsers since 2012 but jest, being a
|
|
107
119
|
* lite version of a DOM, doesn't support it.
|
|
@@ -115,16 +127,8 @@ function useMediaQuery(CSSMediaQuery) {
|
|
|
115
127
|
*/
|
|
116
128
|
if (window.matchMedia === undefined)
|
|
117
129
|
return true;
|
|
118
|
-
const
|
|
119
|
-
React.
|
|
120
|
-
const media = window.matchMedia(CSSMediaQuery);
|
|
121
|
-
if (media.matches !== matches) {
|
|
122
|
-
setMatches(media.matches);
|
|
123
|
-
}
|
|
124
|
-
const listener = () => setMatches(media.matches);
|
|
125
|
-
media.addEventListener("change", listener);
|
|
126
|
-
return () => media.removeEventListener("change", listener);
|
|
127
|
-
}, [CSSMediaQuery]);
|
|
130
|
+
const subscribeMediaQuery = React.useCallback((onChange) => mediaQueryStore.subscribe(onChange, query), [query]);
|
|
131
|
+
const matches = React.useSyncExternalStore(subscribeMediaQuery, mediaQueryStore.getSnapshot(query), () => true);
|
|
128
132
|
return matches;
|
|
129
133
|
}
|
|
130
134
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.87.
|
|
3
|
+
"version": "4.87.4-JOB-85849.0+e7d68a26",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@jobber/design": "^0.56.0",
|
|
23
|
-
"@jobber/formatters": "
|
|
24
|
-
"@jobber/hooks": "^2.9.
|
|
23
|
+
"@jobber/formatters": "^0.2.2",
|
|
24
|
+
"@jobber/hooks": "^2.9.4-JOB-85849.0+e7d68a26",
|
|
25
25
|
"@popperjs/core": "^2.0.6",
|
|
26
26
|
"@std-proposal/temporal": "0.0.1",
|
|
27
27
|
"@tanstack/react-table": "8.5.13",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"> 1%",
|
|
81
81
|
"IE 10"
|
|
82
82
|
],
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "e7d68a26ce27f2bcf7c9b95fd4b7baafcb3f8779"
|
|
84
84
|
}
|