@consta/uikit 5.29.2 → 5.30.0

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.
@@ -0,0 +1 @@
1
+ export * from './useBodyScrollFreeze';
@@ -0,0 +1,2 @@
1
+ export*from"./useBodyScrollFreeze";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/hooks/useBodyScrollFreeze/index.ts"],"sourcesContent":["export * from './useBodyScrollFreeze';\n"],"mappings":"AAAA"}
@@ -0,0 +1 @@
1
+ .BodyScrollFreeze{margin-right:var(--body-scroll-freeze-scrollbar-width)!important;overflow:hidden!important}
@@ -0,0 +1,6 @@
1
+ export declare const cnBodyScrollFreeze: import("@bem-react/classname").ClassNameFormatter;
2
+ export declare const SCROLLBAR_WIDTH_VAR = "--body-scroll-freeze-scrollbar-width";
3
+ export type UseBodyScrollFreezeProps = {
4
+ isActive?: boolean;
5
+ };
6
+ export declare const useBodyScrollFreeze: ({ isActive, }: UseBodyScrollFreezeProps) => void;
@@ -0,0 +1,2 @@
1
+ import{useEffect}from"react";import{cn}from"../../utils/bem";export var cnBodyScrollFreeze=cn("BodyScrollFreeze");export var SCROLLBAR_WIDTH_VAR="--body-scroll-freeze-scrollbar-width";var isClassName=function(a,b){return a.classList.contains(b)},addClassName=function(a,b){isClassName(a,b)||a.classList.add(b)},removeClassName=function(a,b){isClassName(a,b)&&a.classList.remove(b)},addCssVariable=function(a,b){document.documentElement.style.setProperty(a,b)},removeCssVariable=function(a){document.documentElement.style.removeProperty(a)},getScrollBarWidth=function(){return"undefined"==typeof window?0:window.innerWidth-document.documentElement.clientWidth},bodyAddStyles=function(){var a=getScrollBarWidth();addCssVariable(SCROLLBAR_WIDTH_VAR,"".concat(a,"px")),addClassName(document.documentElement,cnBodyScrollFreeze())},bodyRemoveStyles=function(){removeClassName(document.documentElement,cnBodyScrollFreeze()),removeCssVariable(SCROLLBAR_WIDTH_VAR)};export var useBodyScrollFreeze=function(a){var b=a.isActive;useEffect(function(){if(b)return"undefined"==typeof window?void 0:(bodyAddStyles(),bodyRemoveStyles)},[b])};
2
+ //# sourceMappingURL=useBodyScrollFreeze.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBodyScrollFreeze.js","names":["useEffect","cn","cnBodyScrollFreeze","SCROLLBAR_WIDTH_VAR","isClassName","element","className","classList","contains","addClassName","add","removeClassName","remove","addCssVariable","variableName","value","document","documentElement","style","setProperty","removeCssVariable","removeProperty","getScrollBarWidth","window","innerWidth","clientWidth","bodyAddStyles","scrollBarWidth","bodyRemoveStyles","useBodyScrollFreeze","isActive"],"sources":["../../../../../src/hooks/useBodyScrollFreeze/useBodyScrollFreeze.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { cn } from '##/utils/bem';\n\nexport const cnBodyScrollFreeze = cn('BodyScrollFreeze');\nexport const SCROLLBAR_WIDTH_VAR = '--body-scroll-freeze-scrollbar-width';\n\nconst isClassName = (element: HTMLElement, className: string) => {\n return element.classList.contains(className);\n};\n\nconst addClassName = (element: HTMLElement, className: string) => {\n if (!isClassName(element, className)) {\n element.classList.add(className);\n }\n};\n\nconst removeClassName = (element: HTMLElement, className: string) => {\n if (isClassName(element, className)) {\n element.classList.remove(className);\n }\n};\n\nconst addCssVariable = (variableName: string, value: string) => {\n document.documentElement.style.setProperty(variableName, value);\n};\n\nconst removeCssVariable = (variableName: string) => {\n document.documentElement.style.removeProperty(variableName);\n};\n\nconst getScrollBarWidth = () =>\n typeof window !== 'undefined'\n ? window.innerWidth - document.documentElement.clientWidth\n : 0;\n\nconst bodyAddStyles = () => {\n const scrollBarWidth = getScrollBarWidth();\n\n addCssVariable(SCROLLBAR_WIDTH_VAR, `${scrollBarWidth}px`);\n\n addClassName(document.documentElement, cnBodyScrollFreeze());\n};\n\nconst bodyRemoveStyles = () => {\n removeClassName(document.documentElement, cnBodyScrollFreeze());\n\n removeCssVariable(SCROLLBAR_WIDTH_VAR);\n};\n\nexport type UseBodyScrollFreezeProps = {\n isActive?: boolean;\n};\n\nexport const useBodyScrollFreeze = ({\n isActive,\n}: UseBodyScrollFreezeProps): void => {\n useEffect(() => {\n if (!isActive) return;\n if (typeof window === 'undefined') return;\n\n bodyAddStyles();\n\n return bodyRemoveStyles;\n }, [isActive]);\n};\n"],"mappings":"AAAA,OAASA,SAAT,KAA0B,OAA1B,CAEA,OAASC,EAAT,uBAEA,MAAO,IAAMC,mBAAkB,CAAGD,EAAE,CAAC,kBAAD,CAA7B,CACP,MAAO,IAAME,oBAAmB,CAAG,sCAA5B,C,GAEDC,YAAW,CAAG,SAACC,CAAD,CAAuBC,CAAvB,CAA6C,CAC/D,MAAOD,EAAO,CAACE,SAAR,CAAkBC,QAAlB,CAA2BF,CAA3B,CACR,C,CAEKG,YAAY,CAAG,SAACJ,CAAD,CAAuBC,CAAvB,CAA6C,CAC3DF,WAAW,CAACC,CAAD,CAAUC,CAAV,CADgD,EAE9DD,CAAO,CAACE,SAAR,CAAkBG,GAAlB,CAAsBJ,CAAtB,CAEH,C,CAEKK,eAAe,CAAG,SAACN,CAAD,CAAuBC,CAAvB,CAA6C,CAC/DF,WAAW,CAACC,CAAD,CAAUC,CAAV,CADoD,EAEjED,CAAO,CAACE,SAAR,CAAkBK,MAAlB,CAAyBN,CAAzB,CAEH,C,CAEKO,cAAc,CAAG,SAACC,CAAD,CAAuBC,CAAvB,CAAyC,CAC9DC,QAAQ,CAACC,eAAT,CAAyBC,KAAzB,CAA+BC,WAA/B,CAA2CL,CAA3C,CAAyDC,CAAzD,CACD,C,CAEKK,iBAAiB,CAAG,SAACN,CAAD,CAA0B,CAClDE,QAAQ,CAACC,eAAT,CAAyBC,KAAzB,CAA+BG,cAA/B,CAA8CP,CAA9C,CACD,C,CAEKQ,iBAAiB,CAAG,iBACN,WAAlB,QAAOC,OAAP,CAEI,CAFJ,CACIA,MAAM,CAACC,UAAP,CAAoBR,QAAQ,CAACC,eAAT,CAAyBQ,WAFzB,C,CAKpBC,aAAa,CAAG,UAAM,CAC1B,GAAMC,EAAc,CAAGL,iBAAiB,EAAxC,CAEAT,cAAc,CAACV,mBAAD,WAAyBwB,CAAzB,OAHY,CAK1BlB,YAAY,CAACO,QAAQ,CAACC,eAAV,CAA2Bf,kBAAkB,EAA7C,CACb,C,CAEK0B,gBAAgB,CAAG,UAAM,CAC7BjB,eAAe,CAACK,QAAQ,CAACC,eAAV,CAA2Bf,kBAAkB,EAA7C,CADc,CAG7BkB,iBAAiB,CAACjB,mBAAD,CAClB,C,CAMD,MAAO,IAAM0B,oBAAmB,CAAG,WAEG,IADpCC,EACoC,GADpCA,QACoC,CACpC9B,SAAS,CAAC,UAAM,CACd,GAAK8B,CAAL,OACsB,WAAlB,QAAOP,OADX,SAGAG,aAAa,EAHb,CAKOE,gBALP,CAMD,CAPQ,CAON,CAACE,CAAD,CAPM,CAQV,CAXM"}
@@ -0,0 +1 @@
1
+ export * from './useHover';
@@ -0,0 +1,2 @@
1
+ export*from"./useHover";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/hooks/useHover/index.ts"],"sourcesContent":["export * from './useHover';\n"],"mappings":"AAAA"}
@@ -0,0 +1,9 @@
1
+ export type UseHoverProps = {
2
+ isActive?: boolean | (() => boolean | undefined);
3
+ refs: React.RefObject<HTMLElement>[];
4
+ onHover?: (event: MouseEvent) => void;
5
+ onBlur?: (event: MouseEvent) => void;
6
+ blurDelay?: number;
7
+ hoverDelay?: number;
8
+ };
9
+ export declare const useHover: ({ refs, onHover, onBlur, blurDelay, hoverDelay, isActive, }: UseHoverProps) => void;
@@ -0,0 +1,2 @@
1
+ function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c["return"]||c["return"]()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}import{useEffect,useRef}from"react";import{useMutableRef}from"../useMutableRef";export var useHover=function(a){var b=a.refs,c=a.onHover,d=a.onBlur,e=a.blurDelay,f=void 0===e?200:e,g=a.hoverDelay,h=void 0===g?0:g,i=a.isActive,j=useRef(null),k=useRef(null),l=useRef(!1),m=useMutableRef([c,d,i,f,h]),n=function(){return"function"==typeof m.current[2]?m.current[2]():m.current[2]},o=function(){k.current&&(clearTimeout(k.current),k.current=null),j.current&&(clearTimeout(j.current),j.current=null)};useEffect(function(){var a,c=function(a){n()&&(o(),k.current=setTimeout(function(){if(!l.current){var b,c;l.current=!0,null===(b=(c=m.current)[0])||void 0===b?void 0:b.call(c,a)}},m.current[4]))},d=function(a){n()&&(o(),j.current=setTimeout(function(){if(l.current){var b,c;l.current=!1,null===(b=(c=m.current)[1])||void 0===b?void 0:b.call(c,a)}},m.current[3]))},e=_createForOfIteratorHelper(b);try{for(e.s();!(a=e.n()).done;){var f,g,h=a.value;null===(f=h.current)||void 0===f?void 0:f.addEventListener("mouseenter",c),null===(g=h.current)||void 0===g?void 0:g.addEventListener("mouseleave",d)}}catch(a){e.e(a)}finally{e.f()}return function(){var a,e=_createForOfIteratorHelper(b);try{for(e.s();!(a=e.n()).done;){var f,g,h=a.value;null===(f=h.current)||void 0===f?void 0:f.removeEventListener("mouseenter",c),null===(g=h.current)||void 0===g?void 0:g.removeEventListener("mouseleave",d)}}catch(a){e.e(a)}finally{e.f()}o()}},[b])};
2
+ //# sourceMappingURL=useHover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHover.js","names":["useEffect","useRef","useMutableRef","useHover","refs","onHover","onBlur","blurDelay","hoverDelay","isActive","blurTimeoutId","hoverTimeoutId","isHovered","mutableRef","getActive","current","clearTimeouts","clearTimeout","handleMouseEnter","event","setTimeout","handleMouseLeave","element","addEventListener","removeEventListener"],"sources":["../../../../../src/hooks/useHover/useHover.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nimport { useMutableRef } from '##/hooks/useMutableRef';\n\nexport type UseHoverProps = {\n isActive?: boolean | (() => boolean | undefined);\n refs: React.RefObject<HTMLElement>[];\n onHover?: (event: MouseEvent) => void;\n onBlur?: (event: MouseEvent) => void;\n blurDelay?: number;\n hoverDelay?: number;\n};\n\nexport const useHover = ({\n refs,\n onHover,\n onBlur,\n blurDelay = 200,\n hoverDelay = 0,\n isActive,\n}: UseHoverProps): void => {\n const blurTimeoutId = useRef<NodeJS.Timeout | null>(null);\n const hoverTimeoutId = useRef<NodeJS.Timeout | null>(null);\n const isHovered = useRef(false);\n const mutableRef = useMutableRef([\n onHover,\n onBlur,\n isActive,\n blurDelay,\n hoverDelay,\n ] as const);\n\n const getActive = () =>\n typeof mutableRef.current[2] === 'function'\n ? mutableRef.current[2]()\n : mutableRef.current[2];\n\n const clearTimeouts = () => {\n if (hoverTimeoutId.current) {\n clearTimeout(hoverTimeoutId.current);\n hoverTimeoutId.current = null;\n }\n if (blurTimeoutId.current) {\n clearTimeout(blurTimeoutId.current);\n blurTimeoutId.current = null;\n }\n };\n\n useEffect(() => {\n const handleMouseEnter = (event: MouseEvent) => {\n if (!getActive()) {\n return;\n }\n\n clearTimeouts();\n\n hoverTimeoutId.current = setTimeout(() => {\n if (!isHovered.current) {\n isHovered.current = true;\n mutableRef.current[0]?.(event);\n }\n }, mutableRef.current[4]);\n };\n\n const handleMouseLeave = (event: MouseEvent) => {\n if (!getActive()) {\n return;\n }\n\n clearTimeouts();\n\n blurTimeoutId.current = setTimeout(() => {\n if (isHovered.current) {\n isHovered.current = false;\n mutableRef.current[1]?.(event);\n }\n }, mutableRef.current[3]);\n };\n\n for (const element of refs) {\n element.current?.addEventListener('mouseenter', handleMouseEnter);\n element.current?.addEventListener('mouseleave', handleMouseLeave);\n }\n\n return () => {\n for (const element of refs) {\n element.current?.removeEventListener('mouseenter', handleMouseEnter);\n element.current?.removeEventListener('mouseleave', handleMouseLeave);\n }\n clearTimeouts();\n };\n }, [refs]);\n};\n"],"mappings":"qpCAAA,OAASA,SAAT,CAAoBC,MAApB,KAAkC,OAAlC,CAEA,OAASC,aAAT,wBAWA,MAAO,IAAMC,SAAQ,CAAG,WAOG,IANzBC,EAMyB,GANzBA,IAMyB,CALzBC,CAKyB,GALzBA,OAKyB,CAJzBC,CAIyB,GAJzBA,MAIyB,KAHzBC,SAGyB,CAHzBA,CAGyB,YAHb,GAGa,OAFzBC,UAEyB,CAFzBA,CAEyB,YAFZ,CAEY,GADzBC,CACyB,GADzBA,QACyB,CACnBC,CAAa,CAAGT,MAAM,CAAwB,IAAxB,CADH,CAEnBU,CAAc,CAAGV,MAAM,CAAwB,IAAxB,CAFJ,CAGnBW,CAAS,CAAGX,MAAM,IAHC,CAInBY,CAAU,CAAGX,aAAa,CAAC,CAC/BG,CAD+B,CAE/BC,CAF+B,CAG/BG,CAH+B,CAI/BF,CAJ+B,CAK/BC,CAL+B,CAAD,CAJP,CAYnBM,CAAS,CAAG,iBACiB,UAAjC,QAAOD,EAAU,CAACE,OAAX,CAAmB,CAAnB,CAAP,CACIF,CAAU,CAACE,O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CAD0B,WAE1BI,CAAO,CAACP,OAFkB,qBAE1B,EAAiBQ,gBAAjB,CAAkC,YAAlC,CAAgDF,CAAhD,CACD,CAlCa,+BAoCd,MAAO,WAAM,oCACWjB,CADX,MACX,2BAA4B,SAAjBkB,CAAiB,mBAC1BA,CAAO,CAACP,OADkB,qBAC1B,EAAiBS,mBAAjB,CAAqC,YAArC,CAAmDN,CAAnD,CAD0B,WAE1BI,CAAO,CAACP,OAFkB,qBAE1B,EAAiBS,mBAAjB,CAAqC,YAArC,CAAmDH,CAAnD,CACD,CAJU,+BAKXL,CAAa,EACd,CACF,CA3CQ,CA2CN,CAACZ,CAAD,CA3CM,CA4CV,CA/EM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@consta/uikit",
3
- "version": "5.29.2",
3
+ "version": "5.30.0",
4
4
  "keywords": [
5
5
  "ui-kit",
6
6
  "design-system",
@@ -0,0 +1 @@
1
+ export * from "../__internal__/src/hooks/useBodyScrollFreeze";
@@ -0,0 +1 @@
1
+ export * from "../__internal__/src/hooks/useBodyScrollFreeze";
@@ -0,0 +1 @@
1
+ export * from "../__internal__/src/hooks/useHover";
@@ -0,0 +1 @@
1
+ export * from "../__internal__/src/hooks/useHover";