@jobber/components 4.87.2 → 4.87.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 @@
|
|
|
1
|
-
|
|
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 {};
|
|
1
|
+
export declare function useMediaQuery(CSSMediaQuery: string): boolean;
|
package/dist/DataList/index.js
CHANGED
|
@@ -101,19 +101,7 @@ function useDataListContext() {
|
|
|
101
101
|
return React.useContext(DataListContext);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
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) {
|
|
104
|
+
function useMediaQuery(CSSMediaQuery) {
|
|
117
105
|
/**
|
|
118
106
|
* matchMedia have had full support for browsers since 2012 but jest, being a
|
|
119
107
|
* lite version of a DOM, doesn't support it.
|
|
@@ -125,12 +113,18 @@ function useMediaQuery(query) {
|
|
|
125
113
|
* screen sizes, they can use the `mockViewportWidth` function from
|
|
126
114
|
* `@jobber/components/useBreakpoints`.
|
|
127
115
|
*/
|
|
128
|
-
if (
|
|
129
|
-
typeof window.matchMedia === "undefined") {
|
|
116
|
+
if (window.matchMedia === undefined)
|
|
130
117
|
return true;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
118
|
+
const [matches, setMatches] = React.useState(window.matchMedia(CSSMediaQuery).matches);
|
|
119
|
+
React.useEffect(() => {
|
|
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]);
|
|
134
128
|
return matches;
|
|
135
129
|
}
|
|
136
130
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.87.
|
|
3
|
+
"version": "4.87.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@jobber/design": "^0.56.0",
|
|
23
23
|
"@jobber/formatters": "*",
|
|
24
|
-
"@jobber/hooks": "^2.9.
|
|
24
|
+
"@jobber/hooks": "^2.9.3",
|
|
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": "e3f8dba243561bc1da65067d3e97414f28f40c5a"
|
|
84
84
|
}
|