@xanui/core 1.1.14 → 1.1.15
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/breakpoint/BreakpointProvider.js +26 -34
- package/breakpoint/BreakpointProvider.js.map +1 -1
- package/breakpoint/BreakpointProvider.mjs +26 -34
- package/breakpoint/BreakpointProvider.mjs.map +1 -1
- package/breakpoint/useBreakpoint.d.ts +2 -2
- package/breakpoint/useBreakpoint.js +12 -10
- package/breakpoint/useBreakpoint.js.map +1 -1
- package/breakpoint/useBreakpoint.mjs +12 -10
- package/breakpoint/useBreakpoint.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1,43 +1,35 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var jsxRuntime=require('react/jsx-runtime'),React=require('react'),isWindow=require('../isWindow.js'),index=require('../css/index.js');const BreakpointCtx = React.createContext("
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var jsxRuntime=require('react/jsx-runtime'),React=require('react'),isWindow=require('../isWindow.js'),index=require('../css/index.js');const BreakpointCtx = React.createContext("xs");
|
|
2
|
+
/**
|
|
3
|
+
* SSR-safe breakpoint detection
|
|
4
|
+
*/
|
|
2
5
|
const getKey = () => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (width < index.breakpoints.sm) {
|
|
7
|
-
return 'xs';
|
|
8
|
-
}
|
|
9
|
-
else if (width > index.breakpoints.xs && width < index.breakpoints.md) {
|
|
10
|
-
return 'sm';
|
|
11
|
-
}
|
|
12
|
-
else if (width > index.breakpoints.sm && width < index.breakpoints.lg) {
|
|
13
|
-
return 'md';
|
|
14
|
-
}
|
|
15
|
-
else if (width > index.breakpoints.md && width < index.breakpoints.xl) {
|
|
16
|
-
return 'lg';
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return 'xl';
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
return 'xl';
|
|
6
|
+
if (!isWindow.default()) {
|
|
7
|
+
// Server fallback (mobile-first)
|
|
8
|
+
return "xs";
|
|
24
9
|
}
|
|
10
|
+
const width = window.innerWidth;
|
|
11
|
+
if (width < index.breakpoints.sm)
|
|
12
|
+
return "xs";
|
|
13
|
+
if (width < index.breakpoints.md)
|
|
14
|
+
return "sm";
|
|
15
|
+
if (width < index.breakpoints.lg)
|
|
16
|
+
return "md";
|
|
17
|
+
if (width < index.breakpoints.xl)
|
|
18
|
+
return "lg";
|
|
19
|
+
return "xl";
|
|
25
20
|
};
|
|
26
21
|
const BreakpointProvider = ({ children }) => {
|
|
27
22
|
const [current, setCurrent] = React.useState(getKey);
|
|
28
|
-
const handler = () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
};
|
|
23
|
+
const handler = React.useCallback(() => {
|
|
24
|
+
const newKey = getKey();
|
|
25
|
+
setCurrent(prev => (prev === newKey ? prev : newKey));
|
|
26
|
+
}, []);
|
|
34
27
|
React.useEffect(() => {
|
|
35
|
-
|
|
28
|
+
if (!isWindow.default())
|
|
29
|
+
return;
|
|
36
30
|
window.addEventListener("resize", handler);
|
|
37
|
-
handler();
|
|
38
|
-
return () =>
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
}, [current]);
|
|
31
|
+
handler(); // detect on mount
|
|
32
|
+
return () => window.removeEventListener("resize", handler);
|
|
33
|
+
}, [handler]);
|
|
42
34
|
return (jsxRuntime.jsx(BreakpointCtx.Provider, { value: current, children: children }));
|
|
43
35
|
};exports.BreakpointCtx=BreakpointCtx;exports.BreakpointProvider=BreakpointProvider;//# sourceMappingURL=BreakpointProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BreakpointProvider.js","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["import React, { ReactNode, useState } from \"react\";\nimport isWindow from \"../isWindow\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\n\nexport const BreakpointCtx = React.createContext<BreakpointKeys>(\"
|
|
1
|
+
{"version":3,"file":"BreakpointProvider.js","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["import React, { ReactNode, useState, useCallback } from \"react\";\nimport isWindow from \"../isWindow\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\n\nexport const BreakpointCtx = React.createContext<BreakpointKeys>(\"xs\");\n\n/**\n * SSR-safe breakpoint detection\n */\nconst getKey = (): BreakpointKeys => {\n if (!isWindow()) {\n // Server fallback (mobile-first)\n return \"xs\";\n }\n\n const width = window.innerWidth;\n\n if (width < breakpoints.sm) return \"xs\";\n if (width < breakpoints.md) return \"sm\";\n if (width < breakpoints.lg) return \"md\";\n if (width < breakpoints.xl) return \"lg\";\n return \"xl\";\n};\n\nexport const BreakpointProvider = ({ children }: { children?: ReactNode }) => {\n const [current, setCurrent] = useState<BreakpointKeys>(getKey);\n\n const handler = useCallback(() => {\n const newKey = getKey();\n setCurrent(prev => (prev === newKey ? prev : newKey));\n }, []);\n\n React.useEffect(() => {\n if (!isWindow()) return;\n\n window.addEventListener(\"resize\", handler);\n handler(); // detect on mount\n\n return () => window.removeEventListener(\"resize\", handler);\n }, [handler]);\n\n return (\n <BreakpointCtx.Provider value={current}>\n {children}\n </BreakpointCtx.Provider>\n );\n};\n"],"names":["isWindow","breakpoints","useState","useCallback","_jsx"],"mappings":"6MAKO,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAiB,IAAI;AAErE;;AAEG;AACH,MAAM,MAAM,GAAG,MAAqB;AAChC,IAAA,IAAI,CAACA,gBAAQ,EAAE,EAAE;;AAEb,QAAA,OAAO,IAAI;IACf;AAEA,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU;AAE/B,IAAA,IAAI,KAAK,GAAGC,iBAAW,CAAC,EAAE;AAAE,QAAA,OAAO,IAAI;AACvC,IAAA,IAAI,KAAK,GAAGA,iBAAW,CAAC,EAAE;AAAE,QAAA,OAAO,IAAI;AACvC,IAAA,IAAI,KAAK,GAAGA,iBAAW,CAAC,EAAE;AAAE,QAAA,OAAO,IAAI;AACvC,IAAA,IAAI,KAAK,GAAGA,iBAAW,CAAC,EAAE;AAAE,QAAA,OAAO,IAAI;AACvC,IAAA,OAAO,IAAI;AACf,CAAC;MAEY,kBAAkB,GAAG,CAAC,EAAE,QAAQ,EAA4B,KAAI;IACzE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAGC,cAAQ,CAAiB,MAAM,CAAC;AAE9D,IAAA,MAAM,OAAO,GAAGC,iBAAW,CAAC,MAAK;AAC7B,QAAA,MAAM,MAAM,GAAG,MAAM,EAAE;AACvB,QAAA,UAAU,CAAC,IAAI,KAAK,IAAI,KAAK,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC;IACzD,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,KAAK,CAAC,SAAS,CAAC,MAAK;QACjB,IAAI,CAACH,gBAAQ,EAAE;YAAE;AAEjB,QAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC1C,OAAO,EAAE,CAAC;QAEV,OAAO,MAAM,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC;AAC9D,IAAA,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AAEb,IAAA,QACII,cAAA,CAAC,aAAa,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,OAAO,EAAA,QAAA,EACjC,QAAQ,EAAA,CACY;AAEjC"}
|
|
@@ -1,43 +1,35 @@
|
|
|
1
|
-
import {jsx}from'react/jsx-runtime';import React__default,{useState}from'react';import isWindow from'../isWindow.mjs';import {breakpoints}from'../css/index.mjs';const BreakpointCtx = React__default.createContext("
|
|
1
|
+
import {jsx}from'react/jsx-runtime';import React__default,{useState,useCallback}from'react';import isWindow from'../isWindow.mjs';import {breakpoints}from'../css/index.mjs';const BreakpointCtx = React__default.createContext("xs");
|
|
2
|
+
/**
|
|
3
|
+
* SSR-safe breakpoint detection
|
|
4
|
+
*/
|
|
2
5
|
const getKey = () => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (width < breakpoints.sm) {
|
|
7
|
-
return 'xs';
|
|
8
|
-
}
|
|
9
|
-
else if (width > breakpoints.xs && width < breakpoints.md) {
|
|
10
|
-
return 'sm';
|
|
11
|
-
}
|
|
12
|
-
else if (width > breakpoints.sm && width < breakpoints.lg) {
|
|
13
|
-
return 'md';
|
|
14
|
-
}
|
|
15
|
-
else if (width > breakpoints.md && width < breakpoints.xl) {
|
|
16
|
-
return 'lg';
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return 'xl';
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
return 'xl';
|
|
6
|
+
if (!isWindow()) {
|
|
7
|
+
// Server fallback (mobile-first)
|
|
8
|
+
return "xs";
|
|
24
9
|
}
|
|
10
|
+
const width = window.innerWidth;
|
|
11
|
+
if (width < breakpoints.sm)
|
|
12
|
+
return "xs";
|
|
13
|
+
if (width < breakpoints.md)
|
|
14
|
+
return "sm";
|
|
15
|
+
if (width < breakpoints.lg)
|
|
16
|
+
return "md";
|
|
17
|
+
if (width < breakpoints.xl)
|
|
18
|
+
return "lg";
|
|
19
|
+
return "xl";
|
|
25
20
|
};
|
|
26
21
|
const BreakpointProvider = ({ children }) => {
|
|
27
22
|
const [current, setCurrent] = useState(getKey);
|
|
28
|
-
const handler = () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
};
|
|
23
|
+
const handler = useCallback(() => {
|
|
24
|
+
const newKey = getKey();
|
|
25
|
+
setCurrent(prev => (prev === newKey ? prev : newKey));
|
|
26
|
+
}, []);
|
|
34
27
|
React__default.useEffect(() => {
|
|
35
|
-
|
|
28
|
+
if (!isWindow())
|
|
29
|
+
return;
|
|
36
30
|
window.addEventListener("resize", handler);
|
|
37
|
-
handler();
|
|
38
|
-
return () =>
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
}, [current]);
|
|
31
|
+
handler(); // detect on mount
|
|
32
|
+
return () => window.removeEventListener("resize", handler);
|
|
33
|
+
}, [handler]);
|
|
42
34
|
return (jsx(BreakpointCtx.Provider, { value: current, children: children }));
|
|
43
35
|
};export{BreakpointCtx,BreakpointProvider};//# sourceMappingURL=BreakpointProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BreakpointProvider.mjs","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["import React, { ReactNode, useState } from \"react\";\nimport isWindow from \"../isWindow\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\n\nexport const BreakpointCtx = React.createContext<BreakpointKeys>(\"
|
|
1
|
+
{"version":3,"file":"BreakpointProvider.mjs","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["import React, { ReactNode, useState, useCallback } from \"react\";\nimport isWindow from \"../isWindow\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\n\nexport const BreakpointCtx = React.createContext<BreakpointKeys>(\"xs\");\n\n/**\n * SSR-safe breakpoint detection\n */\nconst getKey = (): BreakpointKeys => {\n if (!isWindow()) {\n // Server fallback (mobile-first)\n return \"xs\";\n }\n\n const width = window.innerWidth;\n\n if (width < breakpoints.sm) return \"xs\";\n if (width < breakpoints.md) return \"sm\";\n if (width < breakpoints.lg) return \"md\";\n if (width < breakpoints.xl) return \"lg\";\n return \"xl\";\n};\n\nexport const BreakpointProvider = ({ children }: { children?: ReactNode }) => {\n const [current, setCurrent] = useState<BreakpointKeys>(getKey);\n\n const handler = useCallback(() => {\n const newKey = getKey();\n setCurrent(prev => (prev === newKey ? prev : newKey));\n }, []);\n\n React.useEffect(() => {\n if (!isWindow()) return;\n\n window.addEventListener(\"resize\", handler);\n handler(); // detect on mount\n\n return () => window.removeEventListener(\"resize\", handler);\n }, [handler]);\n\n return (\n <BreakpointCtx.Provider value={current}>\n {children}\n </BreakpointCtx.Provider>\n );\n};\n"],"names":["React","_jsx"],"mappings":"6KAKO,MAAM,aAAa,GAAGA,cAAK,CAAC,aAAa,CAAiB,IAAI;AAErE;;AAEG;AACH,MAAM,MAAM,GAAG,MAAqB;AAChC,IAAA,IAAI,CAAC,QAAQ,EAAE,EAAE;;AAEb,QAAA,OAAO,IAAI;IACf;AAEA,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU;AAE/B,IAAA,IAAI,KAAK,GAAG,WAAW,CAAC,EAAE;AAAE,QAAA,OAAO,IAAI;AACvC,IAAA,IAAI,KAAK,GAAG,WAAW,CAAC,EAAE;AAAE,QAAA,OAAO,IAAI;AACvC,IAAA,IAAI,KAAK,GAAG,WAAW,CAAC,EAAE;AAAE,QAAA,OAAO,IAAI;AACvC,IAAA,IAAI,KAAK,GAAG,WAAW,CAAC,EAAE;AAAE,QAAA,OAAO,IAAI;AACvC,IAAA,OAAO,IAAI;AACf,CAAC;MAEY,kBAAkB,GAAG,CAAC,EAAE,QAAQ,EAA4B,KAAI;IACzE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAiB,MAAM,CAAC;AAE9D,IAAA,MAAM,OAAO,GAAG,WAAW,CAAC,MAAK;AAC7B,QAAA,MAAM,MAAM,GAAG,MAAM,EAAE;AACvB,QAAA,UAAU,CAAC,IAAI,KAAK,IAAI,KAAK,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC;IACzD,CAAC,EAAE,EAAE,CAAC;AAEN,IAAAA,cAAK,CAAC,SAAS,CAAC,MAAK;QACjB,IAAI,CAAC,QAAQ,EAAE;YAAE;AAEjB,QAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC1C,OAAO,EAAE,CAAC;QAEV,OAAO,MAAM,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC;AAC9D,IAAA,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AAEb,IAAA,QACIC,GAAA,CAAC,aAAa,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,OAAO,EAAA,QAAA,EACjC,QAAQ,EAAA,CACY;AAEjC"}
|
|
@@ -3,10 +3,10 @@ import { BreakpointKeys } from '../css/types.js';
|
|
|
3
3
|
declare const useBreakpoint: () => {
|
|
4
4
|
value: BreakpointKeys;
|
|
5
5
|
is: (key: BreakpointKeys) => boolean;
|
|
6
|
-
isDown: (key: BreakpointKeys) => boolean;
|
|
7
6
|
isUp: (key: BreakpointKeys) => boolean;
|
|
8
|
-
|
|
7
|
+
isDown: (key: BreakpointKeys) => boolean;
|
|
9
8
|
isOrUp: (key: BreakpointKeys) => boolean;
|
|
9
|
+
isOrDown: (key: BreakpointKeys) => boolean;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export { useBreakpoint as default };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var React=require('react'),BreakpointProvider=require('./BreakpointProvider.js'),isWindow=require('../isWindow.js'),index=require('../css/index.js');const useBreakpoint = () => {
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
const value = React.useContext(BreakpointProvider.BreakpointCtx);
|
|
3
|
+
const getWidth = () => isWindow.default() ? window.innerWidth : 99999;
|
|
4
|
+
const is = (key) => value === key;
|
|
5
|
+
const isUp = (key) => getWidth() >= index.breakpoints[key];
|
|
6
|
+
const isDown = (key) => getWidth() < index.breakpoints[key];
|
|
7
|
+
return {
|
|
8
|
+
value,
|
|
9
|
+
is,
|
|
10
|
+
isUp,
|
|
11
|
+
isDown,
|
|
12
|
+
isOrUp: (key) => is(key) || isUp(key),
|
|
13
|
+
isOrDown: (key) => is(key) || isDown(key)
|
|
11
14
|
};
|
|
12
|
-
return bp;
|
|
13
15
|
};exports.default=useBreakpoint;//# sourceMappingURL=useBreakpoint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBreakpoint.js","sources":["../../src/breakpoint/useBreakpoint.ts"],"sourcesContent":["import { useContext } from \"react\"\nimport { BreakpointCtx } from \"./BreakpointProvider\"\nimport isWindow from \"../isWindow\"\nimport { breakpoints } from \"../css\"\nimport { BreakpointKeys } from \"../css/types\"\n\nconst useBreakpoint = () => {\n const
|
|
1
|
+
{"version":3,"file":"useBreakpoint.js","sources":["../../src/breakpoint/useBreakpoint.ts"],"sourcesContent":["import { useContext } from \"react\"\nimport { BreakpointCtx } from \"./BreakpointProvider\"\nimport isWindow from \"../isWindow\"\nimport { breakpoints } from \"../css\"\nimport { BreakpointKeys } from \"../css/types\"\n\nconst useBreakpoint = () => {\n const value = useContext(BreakpointCtx)\n const getWidth = () => isWindow() ? window.innerWidth : 99999\n const is = (key: BreakpointKeys) => value === key\n const isUp = (key: BreakpointKeys) => getWidth() >= breakpoints[key]\n const isDown = (key: BreakpointKeys) => getWidth() < breakpoints[key]\n\n return {\n value,\n is,\n isUp,\n isDown,\n isOrUp: (key: BreakpointKeys) => is(key) || isUp(key),\n isOrDown: (key: BreakpointKeys) => is(key) || isDown(key)\n }\n}\n\nexport default useBreakpoint\n"],"names":["useContext","BreakpointCtx","isWindow","breakpoints"],"mappings":"2NAMA,MAAM,aAAa,GAAG,MAAK;AACxB,IAAA,MAAM,KAAK,GAAGA,gBAAU,CAACC,gCAAa,CAAC;AACvC,IAAA,MAAM,QAAQ,GAAG,MAAMC,gBAAQ,EAAE,GAAG,MAAM,CAAC,UAAU,GAAG,KAAK;IAC7D,MAAM,EAAE,GAAG,CAAC,GAAmB,KAAK,KAAK,KAAK,GAAG;AACjD,IAAA,MAAM,IAAI,GAAG,CAAC,GAAmB,KAAK,QAAQ,EAAE,IAAIC,iBAAW,CAAC,GAAG,CAAC;AACpE,IAAA,MAAM,MAAM,GAAG,CAAC,GAAmB,KAAK,QAAQ,EAAE,GAAGA,iBAAW,CAAC,GAAG,CAAC;IAErE,OAAO;QACJ,KAAK;QACL,EAAE;QACF,IAAI;QACJ,MAAM;AACN,QAAA,MAAM,EAAE,CAAC,GAAmB,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC;AACrD,QAAA,QAAQ,EAAE,CAAC,GAAmB,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG;KAC1D;AACJ"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {useContext}from'react';import {BreakpointCtx}from'./BreakpointProvider.mjs';import isWindow from'../isWindow.mjs';import {breakpoints}from'../css/index.mjs';const useBreakpoint = () => {
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
const value = useContext(BreakpointCtx);
|
|
3
|
+
const getWidth = () => isWindow() ? window.innerWidth : 99999;
|
|
4
|
+
const is = (key) => value === key;
|
|
5
|
+
const isUp = (key) => getWidth() >= breakpoints[key];
|
|
6
|
+
const isDown = (key) => getWidth() < breakpoints[key];
|
|
7
|
+
return {
|
|
8
|
+
value,
|
|
9
|
+
is,
|
|
10
|
+
isUp,
|
|
11
|
+
isDown,
|
|
12
|
+
isOrUp: (key) => is(key) || isUp(key),
|
|
13
|
+
isOrDown: (key) => is(key) || isDown(key)
|
|
11
14
|
};
|
|
12
|
-
return bp;
|
|
13
15
|
};export{useBreakpoint as default};//# sourceMappingURL=useBreakpoint.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBreakpoint.mjs","sources":["../../src/breakpoint/useBreakpoint.ts"],"sourcesContent":["import { useContext } from \"react\"\nimport { BreakpointCtx } from \"./BreakpointProvider\"\nimport isWindow from \"../isWindow\"\nimport { breakpoints } from \"../css\"\nimport { BreakpointKeys } from \"../css/types\"\n\nconst useBreakpoint = () => {\n const
|
|
1
|
+
{"version":3,"file":"useBreakpoint.mjs","sources":["../../src/breakpoint/useBreakpoint.ts"],"sourcesContent":["import { useContext } from \"react\"\nimport { BreakpointCtx } from \"./BreakpointProvider\"\nimport isWindow from \"../isWindow\"\nimport { breakpoints } from \"../css\"\nimport { BreakpointKeys } from \"../css/types\"\n\nconst useBreakpoint = () => {\n const value = useContext(BreakpointCtx)\n const getWidth = () => isWindow() ? window.innerWidth : 99999\n const is = (key: BreakpointKeys) => value === key\n const isUp = (key: BreakpointKeys) => getWidth() >= breakpoints[key]\n const isDown = (key: BreakpointKeys) => getWidth() < breakpoints[key]\n\n return {\n value,\n is,\n isUp,\n isDown,\n isOrUp: (key: BreakpointKeys) => is(key) || isUp(key),\n isOrDown: (key: BreakpointKeys) => is(key) || isDown(key)\n }\n}\n\nexport default useBreakpoint\n"],"names":[],"mappings":"qKAMA,MAAM,aAAa,GAAG,MAAK;AACxB,IAAA,MAAM,KAAK,GAAG,UAAU,CAAC,aAAa,CAAC;AACvC,IAAA,MAAM,QAAQ,GAAG,MAAM,QAAQ,EAAE,GAAG,MAAM,CAAC,UAAU,GAAG,KAAK;IAC7D,MAAM,EAAE,GAAG,CAAC,GAAmB,KAAK,KAAK,KAAK,GAAG;AACjD,IAAA,MAAM,IAAI,GAAG,CAAC,GAAmB,KAAK,QAAQ,EAAE,IAAI,WAAW,CAAC,GAAG,CAAC;AACpE,IAAA,MAAM,MAAM,GAAG,CAAC,GAAmB,KAAK,QAAQ,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC;IAErE,OAAO;QACJ,KAAK;QACL,EAAE;QACF,IAAI;QACJ,MAAM;AACN,QAAA,MAAM,EAAE,CAAC,GAAmB,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC;AACrD,QAAA,QAAQ,EAAE,CAAC,GAAmB,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG;KAC1D;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xanui/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"oncss": "^1.2.2",
|
|
12
12
|
"pretty-class": "^1.0.8",
|
|
13
|
-
"react-state-bucket": "^1.2.
|
|
13
|
+
"react-state-bucket": "^1.2.4"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/react": "^19.2.7",
|