@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.
@@ -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("xl");
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
- const isWin = isWindow.default();
4
- if (isWin) {
5
- const width = window.innerWidth;
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
- let c = getKey();
30
- if (current !== c) {
31
- setCurrent(c);
32
- }
33
- };
23
+ const handler = React.useCallback(() => {
24
+ const newKey = getKey();
25
+ setCurrent(prev => (prev === newKey ? prev : newKey));
26
+ }, []);
34
27
  React.useEffect(() => {
35
- window.removeEventListener("resize", handler);
28
+ if (!isWindow.default())
29
+ return;
36
30
  window.addEventListener("resize", handler);
37
- handler();
38
- return () => {
39
- window.removeEventListener("resize", handler);
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>(\"xl\")\n\nconst getKey = (): BreakpointKeys => {\n const isWin = isWindow()\n if (isWin) {\n const width = window.innerWidth\n if (width < breakpoints.sm) {\n return 'xs'\n } else if (width > breakpoints.xs && width < breakpoints.md) {\n return 'sm'\n } else if (width > breakpoints.sm && width < breakpoints.lg) {\n return 'md'\n } else if (width > breakpoints.md && width < breakpoints.xl) {\n return 'lg'\n } else {\n return 'xl'\n }\n } else {\n return 'xl'\n }\n}\n\nexport const BreakpointProvider = ({ children }: { children?: ReactNode }) => {\n const [current, setCurrent] = useState<BreakpointKeys>(getKey)\n\n const handler = () => {\n let c = getKey()\n if (current !== c) {\n setCurrent(c)\n }\n }\n\n React.useEffect(() => {\n window.removeEventListener(\"resize\", handler)\n window.addEventListener(\"resize\", handler)\n handler()\n return () => {\n window.removeEventListener(\"resize\", handler)\n }\n }, [current])\n\n return (\n <BreakpointCtx.Provider value={current}>\n {children}\n </BreakpointCtx.Provider>\n )\n}\n"],"names":["isWindow","breakpoints","useState","_jsx"],"mappings":"6MAKO,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAiB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AAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC;AACjD,QAAA,CAAC;AACL,IAAA,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AAEb,IAAA,QACIC,cAAA,CAAC,aAAa,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,OAAO,EAAA,QAAA,EACjC,QAAQ,EAAA,CACY;AAEjC"}
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,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import {breakpoints}from'../css/index.mjs';const BreakpointCtx = React__default.createContext("xl");
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
- const isWin = isWindow();
4
- if (isWin) {
5
- const width = window.innerWidth;
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
- let c = getKey();
30
- if (current !== c) {
31
- setCurrent(c);
32
- }
33
- };
23
+ const handler = useCallback(() => {
24
+ const newKey = getKey();
25
+ setCurrent(prev => (prev === newKey ? prev : newKey));
26
+ }, []);
34
27
  React__default.useEffect(() => {
35
- window.removeEventListener("resize", handler);
28
+ if (!isWindow())
29
+ return;
36
30
  window.addEventListener("resize", handler);
37
- handler();
38
- return () => {
39
- window.removeEventListener("resize", handler);
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>(\"xl\")\n\nconst getKey = (): BreakpointKeys => {\n const isWin = isWindow()\n if (isWin) {\n const width = window.innerWidth\n if (width < breakpoints.sm) {\n return 'xs'\n } else if (width > breakpoints.xs && width < breakpoints.md) {\n return 'sm'\n } else if (width > breakpoints.sm && width < breakpoints.lg) {\n return 'md'\n } else if (width > breakpoints.md && width < breakpoints.xl) {\n return 'lg'\n } else {\n return 'xl'\n }\n } else {\n return 'xl'\n }\n}\n\nexport const BreakpointProvider = ({ children }: { children?: ReactNode }) => {\n const [current, setCurrent] = useState<BreakpointKeys>(getKey)\n\n const handler = () => {\n let c = getKey()\n if (current !== c) {\n setCurrent(c)\n }\n }\n\n React.useEffect(() => {\n window.removeEventListener(\"resize\", handler)\n window.addEventListener(\"resize\", handler)\n handler()\n return () => {\n window.removeEventListener(\"resize\", handler)\n }\n }, [current])\n\n return (\n <BreakpointCtx.Provider value={current}>\n {children}\n </BreakpointCtx.Provider>\n )\n}\n"],"names":["React","_jsx"],"mappings":"iKAKO,MAAM,aAAa,GAAGA,cAAK,CAAC,aAAa,CAAiB,IAAI;AAErE,MAAM,MAAM,GAAG,MAAqB;AAChC,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;IACxB,IAAI,KAAK,EAAE;AACP,QAAA,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU;AAC/B,QAAA,IAAI,KAAK,GAAG,WAAW,CAAC,EAAE,EAAE;AACxB,YAAA,OAAO,IAAI;QACf;AAAO,aAAA,IAAI,KAAK,GAAG,WAAW,CAAC,EAAE,IAAI,KAAK,GAAG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ode, 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
- isOrDown: (key: BreakpointKeys) => boolean;
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 val = React.useContext(BreakpointProvider.BreakpointCtx);
3
- const isWin = isWindow.default();
4
- const bp = {
5
- value: val,
6
- is: (key) => val === key,
7
- isDown: (key) => isWin ? window.innerWidth < index.breakpoints[key] : false,
8
- isUp: (key) => isWin ? window.innerWidth > index.breakpoints[key] : false,
9
- isOrDown: (key) => bp.is(key) || bp.isDown(key),
10
- isOrUp: (key) => bp.is(key) || bp.isUp(key)
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 val = useContext(BreakpointCtx)\n const isWin = isWindow()\n const bp = {\n value: val,\n is: (key: BreakpointKeys) => val === key,\n isDown: (key: BreakpointKeys) => isWin ? window.innerWidth < breakpoints[key] : false,\n isUp: (key: BreakpointKeys) => isWin ? window.innerWidth > breakpoints[key] : false,\n isOrDown: (key: BreakpointKeys) => bp.is(key) || bp.isDown(key),\n isOrUp: (key: BreakpointKeys) => bp.is(key) || bp.isUp(key)\n }\n return bp\n}\n\nexport default useBreakpoint\n"],"names":["useContext","BreakpointCtx","isWindow","breakpoints"],"mappings":"2NAMA,MAAM,aAAa,GAAG,MAAK;AACxB,IAAA,MAAM,GAAG,GAAGA,gBAAU,CAACC,gCAAa,CAAC;AACrC,IAAA,MAAM,KAAK,GAAGC,gBAAQ,EAAE;AACxB,IAAA,MAAM,EAAE,GAAG;AACR,QAAA,KAAK,EAAE,GAAG;QACV,EAAE,EAAE,CAAC,GAAmB,KAAK,GAAG,KAAK,GAAG;QACxC,MAAM,EAAE,CAAC,GAAmB,KAAK,KAAK,GAAG,MAAM,CAAC,UAAU,GAAGC,iBAAW,CAAC,GAAG,CAAC,GAAG,KAAK;QACrF,IAAI,EAAE,CAAC,GAAmB,KAAK,KAAK,GAAG,MAAM,CAAC,UAAU,GAAGA,iBAAW,CAAC,GAAG,CAAC,GAAG,KAAK;AACnF,QAAA,QAAQ,EAAE,CAAC,GAAmB,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC;AAC/D,QAAA,MAAM,EAAE,CAAC,GAAmB,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG;KAC5D;AACD,IAAA,OAAO,EAAE;AACZ"}
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 val = useContext(BreakpointCtx);
3
- const isWin = isWindow();
4
- const bp = {
5
- value: val,
6
- is: (key) => val === key,
7
- isDown: (key) => isWin ? window.innerWidth < breakpoints[key] : false,
8
- isUp: (key) => isWin ? window.innerWidth > breakpoints[key] : false,
9
- isOrDown: (key) => bp.is(key) || bp.isDown(key),
10
- isOrUp: (key) => bp.is(key) || bp.isUp(key)
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 val = useContext(BreakpointCtx)\n const isWin = isWindow()\n const bp = {\n value: val,\n is: (key: BreakpointKeys) => val === key,\n isDown: (key: BreakpointKeys) => isWin ? window.innerWidth < breakpoints[key] : false,\n isUp: (key: BreakpointKeys) => isWin ? window.innerWidth > breakpoints[key] : false,\n isOrDown: (key: BreakpointKeys) => bp.is(key) || bp.isDown(key),\n isOrUp: (key: BreakpointKeys) => bp.is(key) || bp.isUp(key)\n }\n return bp\n}\n\nexport default useBreakpoint\n"],"names":[],"mappings":"qKAMA,MAAM,aAAa,GAAG,MAAK;AACxB,IAAA,MAAM,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC;AACrC,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;AACxB,IAAA,MAAM,EAAE,GAAG;AACR,QAAA,KAAK,EAAE,GAAG;QACV,EAAE,EAAE,CAAC,GAAmB,KAAK,GAAG,KAAK,GAAG;QACxC,MAAM,EAAE,CAAC,GAAmB,KAAK,KAAK,GAAG,MAAM,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK;QACrF,IAAI,EAAE,CAAC,GAAmB,KAAK,KAAK,GAAG,MAAM,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK;AACnF,QAAA,QAAQ,EAAE,CAAC,GAAmB,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC;AAC/D,QAAA,MAAM,EAAE,CAAC,GAAmB,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG;KAC5D;AACD,IAAA,OAAO,EAAE;AACZ"}
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.14",
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.3"
13
+ "react-state-bucket": "^1.2.4"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/react": "^19.2.7",