@admin-layout/tailwind-ui 12.2.5-alpha.7 → 12.2.5-alpha.9
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/lib/components/ThemeProvider/ThemeProvider.js +1 -1
- package/lib/hooks/__tests__/useMediaQuery.test.d.ts +2 -0
- package/lib/hooks/__tests__/useMediaQuery.test.d.ts.map +1 -0
- package/lib/hooks/useMediaQuery.d.ts +9 -2
- package/lib/hooks/useMediaQuery.d.ts.map +1 -1
- package/lib/hooks/useMediaQuery.js +39 -31
- package/lib/hooks/useMediaQuery.js.map +1 -1
- package/lib/hooks/useWindowSize.d.ts +4 -0
- package/lib/hooks/useWindowSize.d.ts.map +1 -1
- package/lib/hooks/useWindowSize.js +13 -19
- package/lib/hooks/useWindowSize.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {jsx}from'react/jsx-runtime';import {createContext,useState,useEffect,useMemo}from'react';import'../../hooks/
|
|
1
|
+
import {jsx}from'react/jsx-runtime';import {createContext,useState,useEffect,useMemo}from'react';import {useMediaQuery}from'../../hooks/useMediaQuery.js';import'../../hooks/useToast.js';const themes = [{
|
|
2
2
|
value: 'default',
|
|
3
3
|
label: 'Default',
|
|
4
4
|
description: 'Clean and minimal design'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMediaQuery.test.d.ts","sourceRoot":"","sources":["../../../src/hooks/__tests__/useMediaQuery.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface MediaQueryResult {
|
|
1
|
+
export interface MediaQueryResult {
|
|
2
2
|
width: number;
|
|
3
3
|
height: number;
|
|
4
4
|
isMobile: boolean;
|
|
@@ -9,6 +9,13 @@ interface MediaQueryResult {
|
|
|
9
9
|
xl: boolean;
|
|
10
10
|
'2xl': boolean;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Viewport size and Tailwind breakpoint flags.
|
|
14
|
+
*
|
|
15
|
+
* Hydration-safe: while hydrating, React renders the server snapshot (desktop) so the
|
|
16
|
+
* markup matches what the server sent, then re-renders with the real viewport. Reading
|
|
17
|
+
* `window` in the first render instead made every phone-width load throw React #418 and
|
|
18
|
+
* discard the server HTML. Client-only mounts get the real viewport straight away.
|
|
19
|
+
*/
|
|
12
20
|
export declare const useMediaQuery: () => MediaQueryResult;
|
|
13
|
-
export {};
|
|
14
21
|
//# sourceMappingURL=useMediaQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../src/hooks/useMediaQuery.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../src/hooks/useMediaQuery.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;CAClB;AAoDD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,QAAO,gBAAmF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {useSyncExternalStore}from'react';const breakpoints = {
|
|
2
2
|
sm: 640,
|
|
3
3
|
md: 768,
|
|
4
4
|
lg: 1024,
|
|
@@ -13,36 +13,44 @@ const getFlags = width => ({
|
|
|
13
13
|
xl: width >= breakpoints.xl && width < breakpoints['2xl'],
|
|
14
14
|
'2xl': width >= breakpoints['2xl']
|
|
15
15
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
/** The server cannot see the viewport, so it always renders the desktop layout. */
|
|
17
|
+
const SERVER_SNAPSHOT = Object.freeze({
|
|
18
|
+
width: 0,
|
|
19
|
+
height: 0,
|
|
20
|
+
isMobile: false,
|
|
21
|
+
xs: false,
|
|
22
|
+
sm: false,
|
|
23
|
+
md: false,
|
|
24
|
+
lg: false,
|
|
25
|
+
xl: false,
|
|
26
|
+
'2xl': false
|
|
27
|
+
});
|
|
28
|
+
// One cached snapshot per viewport size: useSyncExternalStore needs a stable value between changes.
|
|
29
|
+
let snapshot = null;
|
|
30
|
+
const getSnapshot = () => {
|
|
31
|
+
const width = window.innerWidth;
|
|
32
|
+
const height = window.innerHeight;
|
|
33
|
+
if (!snapshot || snapshot.width !== width || snapshot.height !== height) {
|
|
34
|
+
snapshot = {
|
|
23
35
|
width,
|
|
24
36
|
height,
|
|
25
|
-
isMobile,
|
|
26
|
-
...
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
const [state, setState] = useState(() => typeof window !== 'undefined' ? getDimensions() : {
|
|
30
|
-
width: 0,
|
|
31
|
-
height: 0,
|
|
32
|
-
isMobile: false,
|
|
33
|
-
xs: false,
|
|
34
|
-
sm: false,
|
|
35
|
-
md: false,
|
|
36
|
-
lg: false,
|
|
37
|
-
xl: false,
|
|
38
|
-
'2xl': false
|
|
39
|
-
});
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
const handleResize = () => {
|
|
42
|
-
setState(getDimensions());
|
|
37
|
+
isMobile: width < breakpoints.md,
|
|
38
|
+
...getFlags(width)
|
|
43
39
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
}
|
|
41
|
+
return snapshot;
|
|
42
|
+
};
|
|
43
|
+
const getServerSnapshot = () => SERVER_SNAPSHOT;
|
|
44
|
+
const subscribe = onChange => {
|
|
45
|
+
window.addEventListener('resize', onChange);
|
|
46
|
+
return () => window.removeEventListener('resize', onChange);
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Viewport size and Tailwind breakpoint flags.
|
|
50
|
+
*
|
|
51
|
+
* Hydration-safe: while hydrating, React renders the server snapshot (desktop) so the
|
|
52
|
+
* markup matches what the server sent, then re-renders with the real viewport. Reading
|
|
53
|
+
* `window` in the first render instead made every phone-width load throw React #418 and
|
|
54
|
+
* discard the server HTML. Client-only mounts get the real viewport straight away.
|
|
55
|
+
*/
|
|
56
|
+
const useMediaQuery = () => useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);export{useMediaQuery};//# sourceMappingURL=useMediaQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMediaQuery.js","sources":["../../src/hooks/useMediaQuery.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useMediaQuery.js","sources":["../../src/hooks/useMediaQuery.ts"],"sourcesContent":[null],"names":[],"mappings":"+CAGI,WAAa,GAAC;IAEd,EAAA,GAAA;IACA,EAAE;IACF,EAAE;IACF,EAAE;OACA;;MAEF,gBAAe,KAAA;AAClB,EAAA,EAAA,EAAA,KAAA,GAAA,WAAA,CAAA,EAAA;AAoDD,EAAA,EAAA,EAAA,KAAA,IAAA,WAAA,CAAA,EAAA,IAAA,KAAA,GAAA,WAAA,CAAA,EAAA;;;;;;;AAOG,MAAA,eAAA,GAAA,MAAA,CAAA,MAAA,CAAA;AACH,EAAA,KAAA,EAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWindowSize.d.ts","sourceRoot":"","sources":["../../src/hooks/useWindowSize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useWindowSize.d.ts","sourceRoot":"","sources":["../../src/hooks/useWindowSize.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,aAAa;;;EAG5B"}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// Add event listener for window resize
|
|
15
|
-
window.addEventListener('resize', handleResize);
|
|
16
|
-
// Cleanup the event listener on component unmount
|
|
17
|
-
return () => window.removeEventListener('resize', handleResize);
|
|
18
|
-
}, []);
|
|
19
|
-
return windowSize;
|
|
1
|
+
import {useMemo}from'react';import {useMediaQuery}from'./useMediaQuery.js';/**
|
|
2
|
+
* Viewport width and height - 0 x 0 on the server and while hydrating (see useMediaQuery),
|
|
3
|
+
* the real size after that. The object only changes when the size does.
|
|
4
|
+
*/
|
|
5
|
+
function useWindowSize() {
|
|
6
|
+
const {
|
|
7
|
+
width,
|
|
8
|
+
height
|
|
9
|
+
} = useMediaQuery();
|
|
10
|
+
return useMemo(() => ({
|
|
11
|
+
width,
|
|
12
|
+
height
|
|
13
|
+
}), [width, height]);
|
|
20
14
|
}export{useWindowSize};//# sourceMappingURL=useWindowSize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWindowSize.js","sources":["../../src/hooks/useWindowSize.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useWindowSize.js","sources":["../../src/hooks/useWindowSize.ts"],"sourcesContent":[null],"names":[],"mappings":";AAMG;AACH;;;AAGC,EAAA,MAAA;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@admin-layout/tailwind-ui",
|
|
3
|
-
"version": "12.2.5-alpha.
|
|
3
|
+
"version": "12.2.5-alpha.9",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"typescript": {
|
|
112
112
|
"definition": "lib/index.d.ts"
|
|
113
113
|
},
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "5137d74583f34c57b179f61d76cf1fe5f90efb03"
|
|
115
115
|
}
|