@vchasno/ui-kit 0.4.64 → 0.4.65
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/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.4.65] - 2025-11-24
|
|
11
|
+
|
|
12
|
+
## Fixed
|
|
13
|
+
|
|
14
|
+
- fix ScrollableBox size change detection with MutationObserver subtree and attributes checks
|
|
15
|
+
|
|
10
16
|
## [0.4.64] - 2025-11-21
|
|
11
17
|
|
|
12
18
|
## Fixed
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as r,useEffect as t}from"react";function n(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=Array(t);n<t;n++)e[n]=r[n];return e}var e=function(e,o){var i,u=function(r){if(Array.isArray(r))return r}(i=r(!1))||function(r,t){var n,e,o=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=o){var i=[],u=!0,
|
|
1
|
+
import{useState as r,useEffect as t}from"react";function n(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=Array(t);n<t;n++)e[n]=r[n];return e}var e=function(e,o){var i,u=function(r){if(Array.isArray(r))return r}(i=r(!1))||function(r,t){var n,e,o=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=o){var i=[],u=!0,a=!1;try{for(o=o.call(r);!(u=(n=o.next()).done)&&(i.push(n.value),2!==i.length);u=!0);}catch(r){a=!0,e=r}finally{try{u||null==o.return||o.return()}finally{if(a)throw e}}return i}}(i,2)||function(r,t){if(r){if("string"==typeof r)return n(r,2);var e=Object.prototype.toString.call(r).slice(8,-1);if("Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return n(r,2)}}(i,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),a=u[0],l=u[1];return t(function(){var r=e.current;if(!r)return function(){return null};var t=function(){l("horizontal"===o?r.scrollWidth>r.clientWidth:r.scrollHeight>r.clientHeight)};t();var n=[];if(window.ResizeObserver){var i=new ResizeObserver(t);i.observe(r),n.push(function(){i.disconnect()})}if(window.MutationObserver){var u=new MutationObserver(t);u.observe(r,{childList:!0,subtree:!0,attributes:!0}),n.push(function(){u.disconnect()})}return function(){n.forEach(function(r){return r()})}},[o,e]),a};export{e as useElementScrollable};
|
|
2
2
|
//# sourceMappingURL=useElementScrollable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useElementScrollable.js","sources":["../../../src/components/ScrollableBox/useElementScrollable.ts"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nconst detectScrollable = (element: HTMLElement, direction: 'horizontal' | 'vertical') => {\n if (direction === 'horizontal') {\n return element.scrollWidth > element.clientWidth;\n }\n return element.scrollHeight > element.clientHeight;\n};\n\nexport const useElementScrollable = (\n ref: React.RefObject<HTMLElement>,\n direction: 'horizontal' | 'vertical',\n) => {\n const [isScrollable, setIsScrollable] = useState(false);\n\n useEffect(() => {\n const root = ref.current;\n\n if (!root) {\n return () => null;\n }\n\n const mutationHandler = () => {\n setIsScrollable(detectScrollable(root, direction));\n };\n\n mutationHandler();\n\n const unmountCBList: VoidFunction[] = [];\n\n if (window.ResizeObserver) {\n const resizeObserver = new ResizeObserver(mutationHandler);\n resizeObserver.observe(root);\n\n unmountCBList.push(() => {\n resizeObserver.disconnect();\n });\n }\n\n if (window.MutationObserver) {\n const mutationObserver = new MutationObserver(mutationHandler);\n mutationObserver.observe(root, {\n childList: true,\n });\n\n unmountCBList.push(() => {\n mutationObserver.disconnect();\n });\n }\n\n return () => {\n unmountCBList.forEach((unmount) => unmount());\n };\n }, [direction, ref]);\n\n return isScrollable;\n};\n"],"names":["useElementScrollable","ref","direction","useState","isScrollable","setIsScrollable","useEffect","root","current","mutationHandler","element","scrollWidth","clientWidth","scrollHeight","clientHeight","unmountCBList","window","ResizeObserver","resizeObserver","observe","push","disconnect","MutationObserver","mutationObserver","childList","forEach","unmount"],"mappings":"sJASO,IAAMA,EAAuB,SAChCC,CACAC,CAAAA,CAAAA,EAEA,MAAwCC,8CAAAA,EAAS,CAAA,sMAA1CC,oHAAAA,yDAAAA,0OAAAA,OAAAA,gLAAAA,EAAiCD,KAAnBE,EAAmBF,CAAAA,CAAAA,EAAAA,
|
|
1
|
+
{"version":3,"file":"useElementScrollable.js","sources":["../../../src/components/ScrollableBox/useElementScrollable.ts"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nconst detectScrollable = (element: HTMLElement, direction: 'horizontal' | 'vertical') => {\n if (direction === 'horizontal') {\n return element.scrollWidth > element.clientWidth;\n }\n return element.scrollHeight > element.clientHeight;\n};\n\nexport const useElementScrollable = (\n ref: React.RefObject<HTMLElement>,\n direction: 'horizontal' | 'vertical',\n) => {\n const [isScrollable, setIsScrollable] = useState(false);\n\n useEffect(() => {\n const root = ref.current;\n\n if (!root) {\n return () => null;\n }\n\n const mutationHandler = () => {\n setIsScrollable(detectScrollable(root, direction));\n };\n\n mutationHandler();\n\n const unmountCBList: VoidFunction[] = [];\n\n if (window.ResizeObserver) {\n const resizeObserver = new ResizeObserver(mutationHandler);\n resizeObserver.observe(root);\n\n unmountCBList.push(() => {\n resizeObserver.disconnect();\n });\n }\n\n if (window.MutationObserver) {\n const mutationObserver = new MutationObserver(mutationHandler);\n mutationObserver.observe(root, {\n childList: true,\n subtree: true,\n attributes: true,\n });\n\n unmountCBList.push(() => {\n mutationObserver.disconnect();\n });\n }\n\n return () => {\n unmountCBList.forEach((unmount) => unmount());\n };\n }, [direction, ref]);\n\n return isScrollable;\n};\n"],"names":["useElementScrollable","ref","direction","useState","isScrollable","setIsScrollable","useEffect","root","current","mutationHandler","element","scrollWidth","clientWidth","scrollHeight","clientHeight","unmountCBList","window","ResizeObserver","resizeObserver","observe","push","disconnect","MutationObserver","mutationObserver","childList","subtree","attributes","forEach","unmount"],"mappings":"sJASO,IAAMA,EAAuB,SAChCC,CACAC,CAAAA,CAAAA,EAEA,MAAwCC,8CAAAA,EAAS,CAAA,sMAA1CC,oHAAAA,yDAAAA,0OAAAA,OAAAA,gLAAAA,EAAiCD,KAAnBE,EAAmBF,CAAAA,CAAAA,EAAAA,CA4CxC,OA1CAG,EAAU,WACN,IAAMC,EAAON,EAAIO,OAAO,CAExB,GAAI,CAACD,EACD,OAAO,WAAM,OAAA,MAGjB,IAAME,EAAkB,WACpBJ,EApBJH,AAAc,eAoB6BA,EAnBpCQ,AAmB8BH,EAnBtBI,WAAW,CAAGD,AAmBQH,EAnBAK,WAAW,CAE7CF,AAiBkCH,EAjB1BM,YAAY,CAAGH,AAiBWH,EAjBHO,YAAY,CAkB9C,EAEAL,IAEA,IAAMM,EAAgC,EAAE,CAExC,GAAIC,OAAOC,cAAc,CAAE,CACvB,IAAMC,EAAiB,IAAID,eAAeR,GAC1CS,EAAeC,OAAO,CAACZ,GAEvBQ,EAAcK,IAAI,CAAC,WACfF,EAAeG,UAAU,EAC7B,EACJ,CAEA,GAAIL,OAAOM,gBAAgB,CAAE,CACzB,IAAMC,EAAmB,IAAID,iBAAiBb,GAC9Cc,EAAiBJ,OAAO,CAACZ,EAAM,CAC3BiB,UAAW,CAAA,EACXC,QAAS,CAAA,EACTC,WAAY,CAAA,CAChB,GAEAX,EAAcK,IAAI,CAAC,WACfG,EAAiBF,UAAU,EAC/B,EACJ,CAEA,OAAO,WACHN,EAAcY,OAAO,CAAC,SAACC,CAAAA,EAAYA,OAAAA,KACvC,GACD,CAAC1B,EAAWD,EAAI,EAEZG,CACX"}
|