@consta/uikit 4.4.0 → 4.4.1
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/__internal__/src/hooks/useBreakpoints/mapping.d.ts +1 -1
- package/__internal__/src/hooks/useBreakpoints/mapping.js.map +1 -1
- package/__internal__/src/hooks/useBreakpoints/types.d.ts +2 -2
- package/__internal__/src/hooks/useBreakpoints/types.js.map +1 -1
- package/__internal__/src/hooks/useBreakpoints/useBreakpoints.d.ts +1 -1
- package/__internal__/src/hooks/useBreakpoints/useBreakpoints.js.map +1 -1
- package/__internal__/src/hooks/useComponentBreakpoints/useComponentBreakpoints.d.ts +2 -4
- package/__internal__/src/hooks/useComponentBreakpoints/useComponentBreakpoints.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Map, Returned } from './types';
|
|
2
|
-
export declare const mapping: <POINTS extends string
|
|
2
|
+
export declare const mapping: <POINTS extends string>(width: number, map: Map<POINTS>) => Returned<POINTS>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.js","names":["mapping","width","map","points","key","Object","prototype","hasOwnProperty","call"],"sources":["../../../../../src/hooks/useBreakpoints/mapping.ts"],"sourcesContent":["import { Map, Returned } from './types';\n\nexport const mapping = <POINTS extends string
|
|
1
|
+
{"version":3,"file":"mapping.js","names":["mapping","width","map","points","key","Object","prototype","hasOwnProperty","call"],"sources":["../../../../../src/hooks/useBreakpoints/mapping.ts"],"sourcesContent":["import { Map, Returned } from './types';\n\nexport const mapping = <POINTS extends string>(\n width: number,\n map: Map<POINTS>,\n): Returned<POINTS> => {\n const points = {} as Returned<POINTS>;\n\n for (const key in map) {\n if (Object.prototype.hasOwnProperty.call(map, key)) {\n points[key] = width >= map[key];\n }\n }\n\n return points;\n};\n"],"mappings":"AAEA,MAAO,IAAMA,QAAO,CAAG,SACrBC,CADqB,CAErBC,CAFqB,CAGA,CACrB,GAAMC,EAAM,CAAG,EAAf,CAEA,IAAK,GAAMC,EAAX,GAAkBF,EAAlB,CACMG,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCN,CAArC,CAA0CE,CAA1C,CADN,GAEID,CAAM,CAACC,CAAD,CAAN,CAAcH,CAAK,EAAIC,CAAG,CAACE,CAAD,CAF9B,EAMA,MAAOD,EACR,CAbM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare type Map<POINTS extends string
|
|
2
|
-
export declare type Returned<POINTS extends string
|
|
1
|
+
export declare type Map<POINTS extends string> = Record<POINTS, number>;
|
|
2
|
+
export declare type Returned<POINTS extends string> = Record<POINTS, boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/hooks/useBreakpoints/types.ts"],"sourcesContent":["export type Map<POINTS extends string
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/hooks/useBreakpoints/types.ts"],"sourcesContent":["export type Map<POINTS extends string> = Record<POINTS, number>;\nexport type Returned<POINTS extends string> = Record<POINTS, boolean>;\n"],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Map, Returned } from './types';
|
|
2
|
-
export declare const useBreakpoints: <POINTS extends string
|
|
2
|
+
export declare const useBreakpoints: <POINTS extends string = "m" | "s" | "xs" | "l" | "2xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "3xs" | "5xs" | "4xs">(map?: Map<POINTS> | undefined) => Returned<POINTS>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBreakpoints.js","names":["useLayoutEffect","useState","isEq","mapping","defaultPoints","defaultMap","useBreakpoints","map","pointsMap","window","innerWidth","points","setSetPoints","subscribe","newPoints","state","addEventListener","removeEventListener"],"sources":["../../../../../src/hooks/useBreakpoints/useBreakpoints.ts"],"sourcesContent":["import { useLayoutEffect, useState } from 'react';\n\nimport { isEq } from './isEq';\nimport { mapping } from './mapping';\nimport { Map, Returned } from './types';\n\nconst defaultPoints = [\n '5xs',\n '4xs',\n '3xs',\n '2xs',\n 'xs',\n 's',\n 'm',\n 'l',\n 'xl',\n '2xl',\n '3xl',\n '4xl',\n '5xl',\n] as const;\n\ntype DefaultPoints = typeof defaultPoints[number];\n\nconst defaultMap: Map<DefaultPoints> = {\n '5xs': 320,\n '4xs': 360,\n '3xs': 480,\n '2xs': 720,\n 'xs': 960,\n 's': 1020,\n 'm': 1200,\n 'l': 1400,\n 'xl': 1600,\n '2xl': 1800,\n '3xl': 2000,\n '4xl': 2200,\n '5xl': 2400,\n};\n\nexport const useBreakpoints = <POINTS extends string
|
|
1
|
+
{"version":3,"file":"useBreakpoints.js","names":["useLayoutEffect","useState","isEq","mapping","defaultPoints","defaultMap","useBreakpoints","map","pointsMap","window","innerWidth","points","setSetPoints","subscribe","newPoints","state","addEventListener","removeEventListener"],"sources":["../../../../../src/hooks/useBreakpoints/useBreakpoints.ts"],"sourcesContent":["import { useLayoutEffect, useState } from 'react';\n\nimport { isEq } from './isEq';\nimport { mapping } from './mapping';\nimport { Map, Returned } from './types';\n\nconst defaultPoints = [\n '5xs',\n '4xs',\n '3xs',\n '2xs',\n 'xs',\n 's',\n 'm',\n 'l',\n 'xl',\n '2xl',\n '3xl',\n '4xl',\n '5xl',\n] as const;\n\ntype DefaultPoints = typeof defaultPoints[number];\n\nconst defaultMap: Map<DefaultPoints> = {\n '5xs': 320,\n '4xs': 360,\n '3xs': 480,\n '2xs': 720,\n 'xs': 960,\n 's': 1020,\n 'm': 1200,\n 'l': 1400,\n 'xl': 1600,\n '2xl': 1800,\n '3xl': 2000,\n '4xl': 2200,\n '5xl': 2400,\n};\n\nexport const useBreakpoints = <POINTS extends string = DefaultPoints>(\n map?: Map<POINTS>,\n) => {\n const pointsMap = map || (defaultMap as Map<POINTS>);\n\n const [points, setSetPoints] = useState<Returned<POINTS>>(() =>\n mapping(window.innerWidth, pointsMap),\n );\n\n useLayoutEffect(() => {\n const subscribe = () => {\n const newPoints = mapping(window.innerWidth, pointsMap);\n\n setSetPoints((state) => (isEq(state, newPoints) ? state : newPoints));\n };\n\n window.addEventListener('resize', subscribe);\n\n return () => window.removeEventListener('resize', subscribe);\n }, []);\n\n return points;\n};\n"],"mappings":"iEAAA,OAASA,eAAT,CAA0BC,QAA1B,KAA0C,OAA1C,CAEA,OAASC,IAAT,cACA,OAASC,OAAT,iB,GAGMC,cAAa,CAAG,CACpB,KADoB,CAEpB,KAFoB,CAGpB,KAHoB,CAIpB,KAJoB,CAKpB,IALoB,CAMpB,GANoB,CAOpB,GAPoB,CAQpB,GARoB,CASpB,IAToB,CAUpB,KAVoB,CAWpB,KAXoB,CAYpB,KAZoB,CAapB,KAboB,C,CAkBhBC,UAA8B,CAAG,CACrC,MAAO,GAD8B,CAErC,MAAO,GAF8B,CAGrC,MAAO,GAH8B,CAIrC,MAAO,GAJ8B,CAKrC,GAAM,GAL+B,CAMrC,EAAK,IANgC,CAOrC,EAAK,IAPgC,CAQrC,EAAK,IARgC,CASrC,GAAM,IAT+B,CAUrC,MAAO,IAV8B,CAWrC,MAAO,GAX8B,CAYrC,MAAO,IAZ8B,CAarC,MAAO,IAb8B,C,CAgBvC,MAAO,IAAMC,eAAc,CAAG,SAC5BC,CAD4B,CAEzB,IACGC,EAAS,CAAGD,CAAG,EAAKF,UADvB,GAG4BJ,QAAQ,CAAmB,iBACxDE,QAAO,CAACM,MAAM,CAACC,UAAR,CAAoBF,CAApB,CADiD,CAAnB,CAHpC,uBAGIG,CAHJ,MAGYC,CAHZ,MAmBH,MAZAZ,gBAAe,CAAC,UAAM,CACpB,GAAMa,EAAS,CAAG,UAAM,CACtB,GAAMC,EAAS,CAAGX,OAAO,CAACM,MAAM,CAACC,UAAR,CAAoBF,CAApB,CAAzB,CAEAI,CAAY,CAAC,SAACG,CAAD,QAAYb,KAAI,CAACa,CAAD,CAAQD,CAAR,CAAJ,CAAyBC,CAAzB,CAAiCD,CAA7C,CAAD,CACb,CAJD,CAQA,MAFAL,OAAM,CAACO,gBAAP,CAAwB,QAAxB,CAAkCH,CAAlC,CAEA,CAAO,iBAAMJ,OAAM,CAACQ,mBAAP,CAA2B,QAA3B,CAAqCJ,CAArC,CAAN,CACR,CAVc,CAUZ,EAVY,CAYf,CAAOF,CACR,CAtBM"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare
|
|
3
|
-
export declare const useComponentBreakpoints: <POINTS extends string | number>(ref: React.RefObject<HTMLElement | SVGGraphicsElement>, map: Map<POINTS>) => Returned<POINTS>;
|
|
4
|
-
export {};
|
|
1
|
+
import { Map, Returned } from "../useBreakpoints/types";
|
|
2
|
+
export declare const useComponentBreakpoints: <POINTS extends string>(ref: React.RefObject<HTMLElement | SVGGraphicsElement>, map: Map<POINTS>) => Returned<POINTS>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComponentBreakpoints.js","names":["useLayoutEffect","useState","isEq","mapping","useMutableRef","getWidth","ref","current","getBoundingClientRect","width","useComponentBreakpoints","map","points","setSetPoints","mapRef","resizeObserver","ResizeObserver","newPoints","state","observe","disconnect"],"sources":["../../../../../src/hooks/useComponentBreakpoints/useComponentBreakpoints.ts"],"sourcesContent":["import { useLayoutEffect, useState } from 'react';\n\nimport { isEq } from '##/hooks/useBreakpoints/isEq';\nimport { mapping } from '##/hooks/useBreakpoints/mapping';\nimport {
|
|
1
|
+
{"version":3,"file":"useComponentBreakpoints.js","names":["useLayoutEffect","useState","isEq","mapping","useMutableRef","getWidth","ref","current","getBoundingClientRect","width","useComponentBreakpoints","map","points","setSetPoints","mapRef","resizeObserver","ResizeObserver","newPoints","state","observe","disconnect"],"sources":["../../../../../src/hooks/useComponentBreakpoints/useComponentBreakpoints.ts"],"sourcesContent":["import { useLayoutEffect, useState } from 'react';\n\nimport { isEq } from '##/hooks/useBreakpoints/isEq';\nimport { mapping } from '##/hooks/useBreakpoints/mapping';\nimport { Map, Returned } from '##/hooks/useBreakpoints/types';\nimport { useMutableRef } from '##/hooks/useMutableRef';\n\nconst getWidth = (ref: React.RefObject<HTMLElement | SVGGraphicsElement>) =>\n ref.current?.getBoundingClientRect().width || 0;\n\nexport const useComponentBreakpoints = <POINTS extends string>(\n ref: React.RefObject<HTMLElement | SVGGraphicsElement>,\n map: Map<POINTS>,\n) => {\n const [points, setSetPoints] = useState<Returned<POINTS>>(() =>\n mapping(getWidth(ref), map),\n );\n\n const mapRef = useMutableRef(map);\n\n useLayoutEffect(() => {\n const resizeObserver = new ResizeObserver(() => {\n const newPoints = mapping(getWidth(ref), mapRef.current);\n setSetPoints((state) => (isEq(state, newPoints) ? state : newPoints));\n });\n\n ref.current && resizeObserver.observe(ref.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [ref.current]);\n\n return points;\n};\n"],"mappings":"iEAAA,OAASA,eAAT,CAA0BC,QAA1B,KAA0C,OAA1C,CAEA,OAASC,IAAT,8BACA,OAASC,OAAT,iCAEA,OAASC,aAAT,wBAEA,GAAMC,SAAQ,CAAG,SAACC,CAAD,cACf,WAAAA,CAAG,CAACC,OAAJ,uBAAaC,qBAAb,GAAqCC,KAArC,GAA8C,CAD/B,CAAjB,CAGA,MAAO,IAAMC,wBAAuB,CAAG,SACrCJ,CADqC,CAErCK,CAFqC,CAGlC,OAC4BV,QAAQ,CAAmB,iBACxDE,QAAO,CAACE,QAAQ,CAACC,CAAD,CAAT,CAAgBK,CAAhB,CADiD,CAAnB,CADpC,uBACIC,CADJ,MACYC,CADZ,MAKGC,CAAM,CAAGV,aAAa,CAACO,CAAD,CALzB,CAoBH,MAbAX,gBAAe,CAAC,UAAM,CACpB,GAAMe,EAAc,CAAG,GAAIC,eAAJ,CAAmB,UAAM,CAC9C,GAAMC,EAAS,CAAGd,OAAO,CAACE,QAAQ,CAACC,CAAD,CAAT,CAAgBQ,CAAM,CAACP,OAAvB,CAAzB,CACAM,CAAY,CAAC,SAACK,CAAD,QAAYhB,KAAI,CAACgB,CAAD,CAAQD,CAAR,CAAJ,CAAyBC,CAAzB,CAAiCD,CAA7C,CAAD,CACb,CAHsB,CAAvB,CAOA,MAFAX,EAAG,CAACC,OAAJ,EAAeQ,CAAc,CAACI,OAAf,CAAuBb,CAAG,CAACC,OAA3B,CAEf,CAAO,UAAM,CACXQ,CAAc,CAACK,UAAf,EACD,CACF,CAXc,CAWZ,CAACd,CAAG,CAACC,OAAL,CAXY,CAaf,CAAOK,CACR,CAxBM"}
|