design-react-kit 5.4.0 → 5.5.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.
Files changed (105) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/Autocomplete/Autocomplete.cjs +2 -0
  3. package/dist/Autocomplete/Autocomplete.cjs.map +1 -0
  4. package/dist/Autocomplete/Autocomplete.js +21 -0
  5. package/dist/Autocomplete/Autocomplete.js.map +1 -0
  6. package/dist/BackToTop/BackToTop.cjs +1 -1
  7. package/dist/BackToTop/BackToTop.cjs.map +1 -1
  8. package/dist/BackToTop/BackToTop.js +3 -4
  9. package/dist/BackToTop/BackToTop.js.map +1 -1
  10. package/dist/Collapse/Collapse.cjs +1 -1
  11. package/dist/Collapse/Collapse.cjs.map +1 -1
  12. package/dist/Collapse/Collapse.js +14 -9
  13. package/dist/Collapse/Collapse.js.map +1 -1
  14. package/dist/Dropdown/Dropdown.cjs +1 -1
  15. package/dist/Dropdown/Dropdown.cjs.map +1 -1
  16. package/dist/Dropdown/Dropdown.js +3 -3
  17. package/dist/Dropdown/Dropdown.js.map +1 -1
  18. package/dist/Dropdown/DropdownMenu.cjs +1 -1
  19. package/dist/Dropdown/DropdownMenu.cjs.map +1 -1
  20. package/dist/Dropdown/DropdownMenu.js +3 -6
  21. package/dist/Dropdown/DropdownMenu.js.map +1 -1
  22. package/dist/Dropdown/DropdownToggle.cjs +1 -1
  23. package/dist/Dropdown/DropdownToggle.cjs.map +1 -1
  24. package/dist/Dropdown/DropdownToggle.js +1 -2
  25. package/dist/Dropdown/DropdownToggle.js.map +1 -1
  26. package/dist/Header/HeaderContent.cjs +1 -1
  27. package/dist/Header/HeaderContent.cjs.map +1 -1
  28. package/dist/Header/HeaderContent.js +1 -1
  29. package/dist/Header/HeaderContent.js.map +1 -1
  30. package/dist/Header/HeaderToggler.cjs +1 -1
  31. package/dist/Header/HeaderToggler.cjs.map +1 -1
  32. package/dist/Header/HeaderToggler.js +3 -2
  33. package/dist/Header/HeaderToggler.js.map +1 -1
  34. package/dist/Input/Input.cjs +1 -1
  35. package/dist/Input/Input.cjs.map +1 -1
  36. package/dist/Input/TextArea.cjs +1 -1
  37. package/dist/Input/TextArea.cjs.map +1 -1
  38. package/dist/Input/TextArea.js +4 -1
  39. package/dist/Input/TextArea.js.map +1 -1
  40. package/dist/Input/utils.cjs +1 -1
  41. package/dist/Input/utils.cjs.map +1 -1
  42. package/dist/Input/utils.js +2 -2
  43. package/dist/Input/utils.js.map +1 -1
  44. package/dist/Megamenu/MegamenuItem.cjs +1 -1
  45. package/dist/Megamenu/MegamenuItem.cjs.map +1 -1
  46. package/dist/Megamenu/MegamenuItem.js +4 -2
  47. package/dist/Megamenu/MegamenuItem.js.map +1 -1
  48. package/dist/NavScroll/index.cjs +1 -1
  49. package/dist/NavScroll/index.cjs.map +1 -1
  50. package/dist/NavScroll/types.cjs +1 -1
  51. package/dist/NavScroll/types.cjs.map +1 -1
  52. package/dist/NavScroll/useNavScroll.cjs +1 -1
  53. package/dist/NavScroll/useNavScroll.cjs.map +1 -1
  54. package/dist/NavScroll/useNavScroll.js +84 -28
  55. package/dist/NavScroll/useNavScroll.js.map +1 -1
  56. package/dist/Rating/Rating.cjs +1 -1
  57. package/dist/Rating/Rating.cjs.map +1 -1
  58. package/dist/Rating/Rating.js +1 -1
  59. package/dist/Rating/Rating.js.map +1 -1
  60. package/dist/Skiplink/Skiplink.cjs +1 -1
  61. package/dist/Skiplink/Skiplink.cjs.map +1 -1
  62. package/dist/Skiplink/Skiplink.js +9 -3
  63. package/dist/Skiplink/Skiplink.js.map +1 -1
  64. package/dist/Skiplink/SkiplinkItem.cjs +1 -1
  65. package/dist/Skiplink/SkiplinkItem.cjs.map +1 -1
  66. package/dist/Skiplink/SkiplinkItem.js +8 -2
  67. package/dist/Skiplink/SkiplinkItem.js.map +1 -1
  68. package/dist/index.cjs +1 -1
  69. package/dist/index.cjs.map +1 -1
  70. package/dist/index.js +2 -0
  71. package/dist/index.js.map +1 -1
  72. package/dist/track-focus.cjs +2 -0
  73. package/dist/track-focus.cjs.map +1 -0
  74. package/dist/track-focus.js +2 -0
  75. package/dist/track-focus.js.map +1 -0
  76. package/dist/types/Autocomplete/Autocomplete.d.ts +32 -0
  77. package/dist/types/BackToTop/BackToTop.d.ts +10 -6
  78. package/dist/types/Collapse/Collapse.d.ts +2 -0
  79. package/dist/types/Dropdown/Dropdown.d.ts +3 -2
  80. package/dist/types/Dropdown/DropdownMenu.d.ts +1 -0
  81. package/dist/types/Header/HeaderToggler.d.ts +2 -1
  82. package/dist/types/Input/TextArea.d.ts +1 -1
  83. package/dist/types/NavScroll/types.d.ts +4 -0
  84. package/dist/types/Skiplink/Skiplink.d.ts +3 -0
  85. package/dist/types/Skiplink/SkiplinkItem.d.ts +2 -0
  86. package/dist/types/index.d.ts +2 -0
  87. package/package.json +25 -16
  88. package/src/Autocomplete/Autocomplete.tsx +80 -0
  89. package/src/BackToTop/BackToTop.tsx +14 -11
  90. package/src/Collapse/Collapse.tsx +20 -7
  91. package/src/Dropdown/Dropdown.tsx +9 -6
  92. package/src/Dropdown/DropdownMenu.tsx +10 -6
  93. package/src/Dropdown/DropdownToggle.tsx +1 -2
  94. package/src/Header/HeaderContent.tsx +1 -1
  95. package/src/Header/HeaderToggler.tsx +4 -2
  96. package/src/Input/TextArea.tsx +9 -3
  97. package/src/Input/utils.tsx +2 -2
  98. package/src/Megamenu/MegamenuItem.tsx +4 -2
  99. package/src/NavScroll/types.ts +4 -0
  100. package/src/NavScroll/useNavScroll.ts +102 -34
  101. package/src/Rating/Rating.tsx +1 -1
  102. package/src/Skiplink/Skiplink.tsx +16 -3
  103. package/src/Skiplink/SkiplinkItem.tsx +12 -1
  104. package/src/index.ts +3 -0
  105. package/src/track-focus.js +49 -0
@@ -5,8 +5,10 @@ import { DropdownToggle } from '../Dropdown/DropdownToggle';
5
5
  import classNames from 'classnames';
6
6
  export const MegamenuItem = ({ itemName, className, children, ...attributes }) => {
7
7
  const classes = classNames(className, 'megamenu');
8
- const toggleClasses = classNames('px-lg-2', 'px-xl-3');
9
- return (React.createElement(Dropdown, { className: classes, inNavbar: true, ...attributes },
8
+ const [dropdownOpen, setDropdownOpen] = React.useState(false);
9
+ const toggle = () => setDropdownOpen((prevState) => !prevState);
10
+ const toggleClasses = classNames('px-lg-2', 'px-xl-3', dropdownOpen ? 'show' : '');
11
+ return (React.createElement(Dropdown, { className: classes, inNavbar: true, ...attributes, isOpen: dropdownOpen, toggle: toggle },
10
12
  React.createElement(DropdownToggle, { inNavbar: true, caret: true, className: toggleClasses },
11
13
  React.createElement("span", null, itemName)),
12
14
  React.createElement(DropdownMenu, null,
@@ -1 +1 @@
1
- {"version":3,"file":"MegamenuItem.js","sourceRoot":"","sources":["../../src/Megamenu/MegamenuItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,UAAU,MAAM,YAAY,CAAC;AASpC,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,EAAE,EAAE;IACtG,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAEvD,OAAO,CACL,oBAAC,QAAQ,IAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,WAAK,UAAU;QACnD,oBAAC,cAAc,IAAC,QAAQ,QAAC,KAAK,QAAC,SAAS,EAAE,aAAa;YACrD,kCAAO,QAAQ,CAAQ,CACR;QACjB,oBAAC,YAAY;YACX,6BAAK,SAAS,EAAC,4BAA4B,IA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@@ -1,2 +1,2 @@
1
- "use strict";var C=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var Y=(r,e)=>{for(var s in e)C(r,s,{get:e[s],enumerable:!0})},_=(r,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of F(e))!V.call(r,c)&&c!==s&&C(r,c,{get:()=>e[c],enumerable:!(o=$(e,c))||o.enumerable});return r};var G=r=>_(C({},"__esModule",{value:!0}),r);var j={};Y(j,{useNavScroll:()=>O});module.exports=G(j);var n=require("react");var A=(r,e)=>{let s;return(...o)=>{clearTimeout(s),s=setTimeout(()=>{r(...o)},e)}};var h=require("react");var L=150,z=({root:r,isHorizontal:e,activeId:s,onChange:o,setForceRecompute:c,updateActiveId:l,hasWindow:m})=>{let[y,b]=(0,h.useState)(1),a=r==null||m&&(e?window.innerWidth<r.clientWidth:window.innerHeight<r.clientHeight),u=(0,h.useCallback)(A(()=>{c(!0)},L),[c]);return(0,h.useEffect)(()=>{if(!m)return;let f=null,w=()=>{setTimeout(()=>{b(e?window.innerWidth:window.innerHeight)},L)},E=g=>{let[S]=g;a||b(e?S.boundingClientRect.width:S.boundingClientRect.height),S.intersectionRatio===0&&s!=null&&(l(null),o&&o({added:null,removed:s}))};return addEventListener("scroll",u),a&&(b(e?window.innerWidth:window.innerHeight),addEventListener("resize",w)),r&&(f=new IntersectionObserver(E),f.observe(r)),()=>{f&&f.disconnect(),removeEventListener("resize",w),removeEventListener("scroll",u)}},[r,e,s,o,a,u,m,l]),{targetSize:y,useViewport:a}};var T=typeof window<"u",J=50;function U(r,e){let s=[r],o=s[0];for(;o!=null&&e[o]!=null;)s.push(e[o]),o=e[o];return s.reverse()}function O(r={}){let{onChange:e,root:s,offset:o=50,isHorizontal:c=!1}=r,l=(0,n.useRef)([]),[m,y]=(0,n.useState)(0),[b,a]=(0,n.useState)(!1),[u,f]=(0,n.useState)(null),{targetSize:w,useViewport:E}=z({root:s,isHorizontal:c,onChange:e,activeId:u,setForceRecompute:a,updateActiveId:f,hasWindow:T}),g=Math.floor(w*o/100)||1,S=(0,n.useMemo)(()=>{let t=g%2===1?g-1:g,i=w-g;return{root:E?null:s,rootMargin:c?`0px ${-t}px 0px ${-i}px`:`${-t}px 0px ${-i}px 0px`}},[s,w,g,c,E]),R=(0,n.useMemo)(()=>{let t={};for(let{id:i,parent:d}of l.current)t[i]=d;return t},[]),x=(0,n.useMemo)(()=>u?U(u,R):[],[u,R]),N=(0,n.useMemo)(()=>new Set(x),[x]);(0,n.useEffect)(()=>{if(!T)return;let t=d=>{let p=null,I=1/0;d.forEach(v=>{v.isIntersecting&&I>v.boundingClientRect.top&&(I=v.boundingClientRect.top,p=v.target.id)}),p!=null&&(f(p),e&&e({added:p,removed:u}))},i=new IntersectionObserver(t,S);return l.current.forEach(({ref:d})=>{d&&d.current&&i.observe(d.current)}),b&&(t(i.takeRecords(),i),a(!1)),()=>{i.disconnect()}},[x,f,l,R,e,N,u,S,c,s,b]);let k=(0,n.useCallback)(A(()=>{y(m+1)},J),[m]),D=(0,n.useCallback)((t,i={})=>{if(!T)return{id:t,ref:null};let d=t in R,p=d?l.current.find(({id:v})=>v===t):i,I=p&&p.ref||(0,n.createRef)();return d||(l.current=[...l.current,{id:t,ref:I,parent:i.parent}],k()),{id:t,ref:I}},[R,k]),M=(0,n.useCallback)(t=>{l.current=l.current.filter(({id:i})=>i!==t)},[]),W=(0,n.useCallback)(t=>N.has(t),[N]),H=(0,n.useCallback)(()=>{let t=l.current.find(({id:i})=>i===u);return t?t.ref:null},[u]);return{register:D,unregister:M,activeIds:x,isActive:W,getActiveRef:H}}0&&(module.exports={useNavScroll});
1
+ "use strict";var ee=Object.create;var k=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var ie=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},W=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ne(t))!oe.call(e,s)&&s!==n&&k(e,s,{get:()=>t[s],enumerable:!(r=te(t,s))||r.enumerable});return e};var se=(e,t,n)=>(n=e!=null?ee(re(e)):{},W(t||!e||!e.__esModule?k(n,"default",{value:e,enumerable:!0}):n,e)),le=e=>W(k({},"__esModule",{value:!0}),e);var ge={};ie(ge,{useNavScroll:()=>G});module.exports=le(ge);var o=require("react");var I=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}};var v=require("react");var $=150,U=({root:e,isHorizontal:t,activeId:n,onChange:r,setForceRecompute:s,updateActiveId:u,hasWindow:f})=>{let[C,x]=(0,v.useState)(1),m=e==null||f&&(t?window.innerWidth<e.clientWidth:window.innerHeight<e.clientHeight),d=(0,v.useCallback)(I(()=>{s(!0)},$),[s]);return(0,v.useEffect)(()=>{if(!f)return;let p=null,y=()=>{setTimeout(()=>{x(t?window.innerWidth:window.innerHeight)},$)},L=h=>{let[g]=h;m||x(t?g.boundingClientRect.width:g.boundingClientRect.height),g.intersectionRatio===0&&n!=null&&(u(null),r&&r({added:null,removed:n}))};return addEventListener("scroll",d),m&&(x(t?window.innerWidth:window.innerHeight),addEventListener("resize",y)),e&&(p=new IntersectionObserver(L),p.observe(e)),()=>{p&&p.disconnect(),removeEventListener("resize",y),removeEventListener("scroll",d)}},[e,t,n,r,m,d,f,u]),{targetSize:C,useViewport:m}};var V=se(require("crypto")),T=new Uint8Array(256),N=T.length;function _(){return N>T.length-16&&(V.default.randomFillSync(T),N=0),T.slice(N,N+=16)}var B=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function ce(e){return typeof e=="string"&&B.test(e)}var P=ce;var l=[];for(let e=0;e<256;++e)l.push((e+256).toString(16).substr(1));function ue(e,t=0){let n=(l[e[t+0]]+l[e[t+1]]+l[e[t+2]]+l[e[t+3]]+"-"+l[e[t+4]]+l[e[t+5]]+"-"+l[e[t+6]]+l[e[t+7]]+"-"+l[e[t+8]]+l[e[t+9]]+"-"+l[e[t+10]]+l[e[t+11]]+l[e[t+12]]+l[e[t+13]]+l[e[t+14]]+l[e[t+15]]).toLowerCase();if(!P(n))throw TypeError("Stringified UUID is invalid");return n}var q=ue;function de(e,t,n){e=e||{};let r=e.random||(e.rng||_)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n=n||0;for(let s=0;s<16;++s)t[n+s]=r[s];return t}return q(r)}var M=de;var O=!1,E=[],H=class{_callback;id;constructor(t,n){this.id=t,this._callback=n}dispose(){ae(this.id)}_execute(t){this._callback(t)}},ae=e=>{E=E.filter(t=>t.id!==e)},fe=e=>{if(!(typeof document>"u")){if(E.length||typeof window<"u"&&typeof document<"u"&&document.addEventListener("scroll",t=>{O||(window.requestAnimationFrame(()=>{E.forEach(n=>n.cb._execute(t)),O=!1}),O=!0)}),typeof e=="function"){let t=new H(M(),e);return E.push({id:t.id,cb:t}),t}return console.error("[onDocumentScroll] the provided data has to be of type function"),null}},F=typeof window<"u",pe=50;function me(e,t){let n=[e],r=n[0];for(;r!=null&&t[r]!=null;)n.push(t[r]),r=t[r];return n.reverse()}function G(e={}){let{onChange:t,root:n,offset:r=50,isHorizontal:s=!1}=e,u=(0,o.useRef)([]),[f,C]=(0,o.useState)(0),[x,m]=(0,o.useState)(!1),[d,p]=(0,o.useState)(null),[y,L]=(0,o.useState)(0),{targetSize:h,useViewport:g}=U({root:n,isHorizontal:s,onChange:t,activeId:d,setForceRecompute:m,updateActiveId:p,hasWindow:F}),w=Math.floor(h*r/100)||1,Y=(0,o.useMemo)(()=>{let i=w%2===1?w-1:w,c=h-w;return{root:g?null:n,rootMargin:s?`0px ${-i}px 0px ${-c}px`:`${-i}px 0px ${-c}px 0px`}},[n,h,w,s,g]),R=(0,o.useMemo)(()=>{let i={};for(let{id:c,parent:a}of u.current)i[c]=a;return i},[f]),A=(0,o.useMemo)(()=>d?me(d,R):[],[d,R]),D=(0,o.useMemo)(()=>new Set(A),[A]);(0,o.useEffect)(()=>{if(!F)return;let i=()=>{let c=null;for(let a=0;a<u.current.length;a++){let b=u.current[a].ref.current,S=b?.getBoundingClientRect().top?b?.getBoundingClientRect().top:0;if(!S)break;if(S>0&&a>0){let z=n?.previousSibling?.firstChild?.parentNode?.querySelectorAll(".it-navscroll-wrapper .nav-link").length||1;L(a/(z/2)*100),c=u.current[a-1].ref.current?.id;break}}c!=null&&(p(c),t&&t({added:c,removed:d}))};fe(i),setTimeout(()=>{i()},300)},[A,p,u,R,t,D,d,Y,s,n,x]);let J=(0,o.useCallback)(I(()=>{C(f+1)},pe),[f]),X=(0,o.useCallback)((i,c={})=>{if(!F)return{id:i,ref:null};let a=i in R,b=a?u.current.find(({id:z})=>z===i):c,S=b&&b.ref||(0,o.createRef)();return a||(u.current=[...u.current,{id:i,ref:S,parent:c.parent}],J()),{id:i,ref:S}},[f]),j=(0,o.useCallback)(i=>{u.current=u.current.filter(({id:c})=>c!==i)},[f]),K=(0,o.useCallback)(i=>D.has(i),[D]),Q=(0,o.useMemo)(()=>y,[y]),Z=(0,o.useCallback)(()=>{let i=u.current.find(({id:c})=>c===d);return i?i.ref:null},[d]);return{percentage:Q,register:X,unregister:j,activeIds:A,isActive:K,getActiveRef:Z}}0&&(module.exports={useNavScroll});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/NavScroll/index.ts","../../src/NavScroll/useNavScroll.ts","../../src/NavScroll/debounce.ts","../../src/NavScroll/useSizeDetector.ts"],"sourcesContent":["/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n/* @internal */\nexport type { ChangesType, RegisterOptions, useNavScrollArgs, useNavScrollResult } from './types';\n\nexport { useNavScroll } from './useNavScroll';\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nimport { createRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { debounce } from './debounce';\nimport type { TrackedElement, useNavScrollArgs, useNavScrollResult } from './types';\nimport { useSizeDetector } from './useSizeDetector';\n\nconst hasWindow = typeof window !== 'undefined';\nconst REGISTER_DELAY = 50;\n\nfunction resolveHierarchyIds(id: string, lookup: Record<string, string | undefined>) {\n const newActiveIds = [id];\n let lastId: string | undefined = newActiveIds[0];\n while (lastId != null && lookup[lastId] != null) {\n newActiveIds.push(lookup[lastId] as string);\n lastId = lookup[lastId];\n }\n // return a list from parent to current child\n return newActiveIds.reverse();\n}\n/**\n * This is the main hook: use it in a react function component to track\n * the state of the passed ids. The function accepts an initial configuration\n * of type `useNavScrollArgs` to customize the behaviour.\n */\nexport function useNavScroll(args: useNavScrollArgs = {}): useNavScrollResult {\n const { onChange, root, offset = 50, isHorizontal = false } = args;\n const els = useRef<TrackedElement[]>([]);\n const [counter, setCounter] = useState(0);\n const [forceRecompute, setForceRecompute] = useState(false);\n const [activeId, updateActiveId] = useState<string | null>(null);\n\n const { targetSize, useViewport } = useSizeDetector({\n root,\n isHorizontal,\n onChange,\n activeId,\n setForceRecompute,\n updateActiveId,\n hasWindow\n });\n\n const observerMargin = Math.floor((targetSize * offset) / 100) || 1;\n const observerOptions = useMemo(() => {\n const topMargin = observerMargin % 2 === 1 ? observerMargin - 1 : observerMargin;\n const bottomMargin = targetSize - observerMargin;\n return {\n root: useViewport ? null : root,\n rootMargin: isHorizontal\n ? `0px ${-topMargin}px 0px ${-bottomMargin}px`\n : `${-topMargin}px 0px ${-bottomMargin}px 0px`\n };\n }, [root, targetSize, observerMargin, isHorizontal, useViewport]);\n\n const elsLookup = useMemo(() => {\n const lookup: Record<string, string | undefined> = {};\n for (const { id, parent } of els.current) {\n lookup[id] = parent;\n }\n return lookup;\n }, []);\n const activeIds = useMemo(() => (activeId ? resolveHierarchyIds(activeId, elsLookup) : []), [activeId, elsLookup]);\n\n const activeLookups = useMemo(() => new Set(activeIds), [activeIds]);\n useEffect(() => {\n if (!hasWindow) {\n return;\n }\n const handleIntersection: IntersectionObserverCallback = (entries) => {\n let intersectionId = null;\n let topMin = Infinity;\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n if (topMin > entry.boundingClientRect.top) {\n topMin = entry.boundingClientRect.top;\n intersectionId = entry.target.id;\n }\n }\n });\n if (intersectionId != null) {\n updateActiveId(intersectionId);\n if (onChange) {\n const diffIds = {\n added: intersectionId,\n removed: activeId\n };\n onChange(diffIds);\n }\n }\n };\n\n const observer = new IntersectionObserver(handleIntersection, observerOptions);\n\n els.current.forEach(({ ref }) => {\n if (ref && ref.current) {\n observer.observe(ref.current);\n }\n });\n\n if (forceRecompute) {\n handleIntersection(observer.takeRecords(), observer);\n setForceRecompute(false);\n }\n return () => {\n observer.disconnect();\n };\n }, [\n activeIds,\n updateActiveId,\n els,\n elsLookup,\n onChange,\n activeLookups,\n activeId,\n observerOptions,\n isHorizontal,\n root,\n forceRecompute\n ]);\n\n const refresh = useCallback(\n debounce(() => {\n setCounter(counter + 1);\n }, REGISTER_DELAY),\n [counter]\n );\n\n const register = useCallback(\n (id: string, options = {}) => {\n if (!hasWindow) {\n return { id, ref: null };\n }\n const alreadyRegistered = id in elsLookup;\n const entry = (alreadyRegistered ? els.current.find(({ id: existingId }) => existingId === id) : options) as any;\n const ref = (entry && entry.ref) || createRef();\n\n if (!alreadyRegistered) {\n els.current = [...els.current, { id, ref, parent: (options as any).parent }];\n refresh();\n }\n return { id, ref };\n },\n [elsLookup, refresh]\n );\n\n const unregister = useCallback((idToUnregister: string) => {\n els.current = els.current.filter(({ id }) => id !== idToUnregister);\n }, []);\n\n const isActive = useCallback((id: string) => activeLookups.has(id), [activeLookups]);\n\n const getActiveRef = useCallback(() => {\n const entry = els.current.find(({ id }) => id === activeId);\n return entry ? entry.ref : null;\n }, [activeId]);\n\n return {\n register,\n unregister,\n activeIds,\n isActive,\n getActiveRef\n };\n}\n","/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nexport const debounce = (callback: CallableFunction, wait: number) => {\n let timeoutId: NodeJS.Timeout;\n return (...args: unknown[]) => {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => {\n callback(...args);\n }, wait);\n };\n};\n","/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { debounce } from './debounce';\nimport { useNavScrollArgs } from './types';\n\nconst DEFAULT_DELAY = 150;\n\nexport type useSizeDetectorArgs = Omit<useNavScrollArgs, 'offset'> & {\n activeId: string | null;\n hasWindow: boolean;\n setForceRecompute: (force: boolean) => void;\n updateActiveId: (id: string | null) => void;\n};\n\nexport const useSizeDetector = ({\n root,\n isHorizontal,\n activeId,\n onChange,\n setForceRecompute,\n updateActiveId,\n hasWindow\n}: useSizeDetectorArgs) => {\n const [targetSize, setTargetSize] = useState<number>(1);\n\n const useViewport =\n root == null ||\n (hasWindow && (isHorizontal ? window.innerWidth < root.clientWidth : window.innerHeight < root.clientHeight));\n\n const scrollEnd = useCallback(\n debounce(() => {\n setForceRecompute(true);\n }, DEFAULT_DELAY),\n [setForceRecompute]\n );\n\n useEffect(() => {\n if (!hasWindow) {\n return;\n }\n let observer: IntersectionObserver | null = null;\n\n const resizeWindowHandler = () => {\n setTimeout(() => {\n setTargetSize(isHorizontal ? window.innerWidth : window.innerHeight);\n }, DEFAULT_DELAY);\n };\n\n const resizeElementHandler: IntersectionObserverCallback = (entries) => {\n const [entry] = entries;\n if (!useViewport) {\n setTargetSize(isHorizontal ? entry.boundingClientRect.width : entry.boundingClientRect.height);\n }\n\n if (entry.intersectionRatio === 0) {\n if (activeId != null) {\n updateActiveId(null);\n if (onChange) {\n onChange({\n added: null,\n removed: activeId\n });\n }\n }\n }\n };\n\n addEventListener('scroll', scrollEnd);\n if (useViewport) {\n setTargetSize(isHorizontal ? window.innerWidth : window.innerHeight);\n addEventListener('resize', resizeWindowHandler);\n }\n if (root) {\n observer = new IntersectionObserver(resizeElementHandler);\n observer.observe(root);\n }\n return () => {\n if (observer) {\n observer.disconnect();\n }\n removeEventListener('resize', resizeWindowHandler);\n removeEventListener('scroll', scrollEnd);\n };\n }, [root, isHorizontal, activeId, onChange, useViewport, scrollEnd, hasWindow, updateActiveId]);\n return { targetSize, useViewport };\n};\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GCOA,IAAAI,EAA6E,iBCDtE,IAAMC,EAAW,CAACC,EAA4BC,IAAiB,CACpE,IAAIC,EACJ,MAAO,IAAIC,IAAoB,CAC7B,aAAaD,CAAS,EACtBA,EAAY,WAAW,IAAM,CAC3BF,EAAS,GAAGG,CAAI,CAClB,EAAGF,CAAI,CACT,CACF,ECRA,IAAAG,EAAiD,iBAIjD,IAAMC,EAAgB,IASTC,EAAkB,CAAC,CAC9B,KAAAC,EACA,aAAAC,EACA,SAAAC,EACA,SAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,UAAAC,CACF,IAA2B,CACzB,GAAM,CAACC,EAAYC,CAAa,KAAI,YAAiB,CAAC,EAEhDC,EACJT,GAAQ,MACPM,IAAcL,EAAe,OAAO,WAAaD,EAAK,YAAc,OAAO,YAAcA,EAAK,cAE3FU,KAAY,eAChBC,EAAS,IAAM,CACbP,EAAkB,EAAI,CACxB,EAAGN,CAAa,EAChB,CAACM,CAAiB,CACpB,EAEA,sBAAU,IAAM,CACd,GAAI,CAACE,EACH,OAEF,IAAIM,EAAwC,KAEtCC,EAAsB,IAAM,CAChC,WAAW,IAAM,CACfL,EAAcP,EAAe,OAAO,WAAa,OAAO,WAAW,CACrE,EAAGH,CAAa,CAClB,EAEMgB,EAAsDC,G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AAC,CAAE,GAAAV,CAAG,IAAMA,IAAOe,CAAQ,EAC1D,OAAOiB,EAAQA,EAAM,IAAM,IAC7B,EAAG,CAACjB,CAAQ,CAAC,EAEb,MAAO,CACL,SAAAsB,EACA,WAAAI,EACA,UAAAf,EACA,SAAAiB,EACA,aAAAC,CACF,CACF","names":["NavScroll_exports","__export","useNavScroll","__toCommonJS","import_react","debounce","callback","wait","timeoutId","args","import_react","DEFAULT_DELAY","useSizeDetector","root","isHorizontal","activeId","onChange","setForceRecompute","updateActiveId","hasWindow","targetSize","setTargetSize","useViewport","scrollEnd","debounce","observer","resizeWindowHandler","resizeElementHandler","entries","entry","hasWindow","REGISTER_DELAY","resolveHierarchyIds","id","lookup","newActiveIds","lastId","useNavScroll","args","onChange","root","offset","isHorizontal","els","counter","setCounter","forceRecompute","setForceRecompute","activeId","updateActiveId","targetSize","useViewport","useSizeDetector","observerMargin","observerOptions","topMargin","bottomMargin","elsLookup","parent","activeIds","activeLookups","handleIntersection","entries","intersectionId","topMin","entry","observer","ref","refresh","debounce","register","options","alreadyRegistered","existingId","unregister","idToUnregister","isActive","getActiveRef"]}
1
+ {"version":3,"sources":["../../src/NavScroll/index.ts","../../src/NavScroll/useNavScroll.ts","../../src/NavScroll/debounce.ts","../../src/NavScroll/useSizeDetector.ts","../../node_modules/uuid/dist/esm-node/rng.js","../../node_modules/uuid/dist/esm-node/regex.js","../../node_modules/uuid/dist/esm-node/validate.js","../../node_modules/uuid/dist/esm-node/stringify.js","../../node_modules/uuid/dist/esm-node/v4.js"],"sourcesContent":["/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n/* @internal */\nexport type { ChangesType, RegisterOptions, useNavScrollArgs, useNavScrollResult } from './types';\n\nexport { useNavScroll } from './useNavScroll';\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n/*--------------------------------------------------------------------------\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati (@dej611)\n * Code: https://github.com/dej611/react-use-navscroll\n * --------------------------------------------------------------------------\n * Parts of this code has been modified using Bootstrap Italia source code\n * --------------------------------------------------------------------------\n * Bootstrap Italia (https://italia.github.io/bootstrap-italia/)\n * Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS\n * License: BSD-3-Clause (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport { createRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { debounce } from './debounce';\nimport type { useNavScrollArgs, useNavScrollResult, TrackedElement } from './types';\nimport { useSizeDetector } from './useSizeDetector';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nlet ticking: boolean = false;\nlet callbacks: any[] = [];\n\nclass ScrollCallback {\n private _callback: any;\n id: string;\n constructor(id: string, callback: any) {\n this.id = id;\n this._callback = callback;\n }\n\n //Public\n dispose() {\n removeCallBack(this.id);\n }\n\n //Private\n _execute(data: any) {\n this._callback(data);\n }\n}\n\nconst removeCallBack = (id: string) => {\n callbacks = callbacks.filter((cb) => cb.id !== id);\n};\n\nconst onDocumentScroll = (callback: any) => {\n if (typeof document === 'undefined') {\n return;\n }\n if (!callbacks.length) {\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n document.addEventListener('scroll', (evt) => {\n if (!ticking) {\n window.requestAnimationFrame(() => {\n callbacks.forEach((cbObj) => cbObj.cb._execute(evt));\n ticking = false;\n });\n ticking = true;\n }\n });\n }\n }\n\n if (typeof callback === 'function') {\n const newCb = new ScrollCallback(uuidv4(), callback);\n callbacks.push({\n id: newCb.id,\n cb: newCb\n });\n return newCb;\n }\n\n console.error('[onDocumentScroll] the provided data has to be of type function');\n return null;\n};\n\nconst hasWindow = typeof window !== 'undefined';\nconst REGISTER_DELAY = 50;\n\nfunction resolveHierarchyIds(id: string, lookup: Record<string, string | undefined>) {\n const newActiveIds = [id];\n let lastId: string | undefined = newActiveIds[0];\n while (lastId != null && lookup[lastId] != null) {\n newActiveIds.push(lookup[lastId] as string);\n lastId = lookup[lastId];\n }\n // return a list from parent to current child\n return newActiveIds.reverse();\n}\n/**\n * This is the main hook: use it in a react function component to track\n * the state of the passed ids. The function accepts an initial configuration\n * of type `useNavScrollArgs` to customize the behaviour.\n */\nexport function useNavScroll(args: useNavScrollArgs = {}): useNavScrollResult {\n const { onChange, root, offset = 50, isHorizontal = false } = args;\n const els = useRef<TrackedElement[]>([]);\n const [counter, setCounter] = useState(0);\n const [forceRecompute, setForceRecompute] = useState(false);\n const [activeId, updateActiveId] = useState<string | null>(null);\n const [percentageValue, setPercentageValue] = useState(0);\n\n const { targetSize, useViewport } = useSizeDetector({\n root,\n isHorizontal,\n onChange,\n activeId,\n setForceRecompute,\n updateActiveId,\n hasWindow\n });\n\n const observerMargin = Math.floor((targetSize * offset) / 100) || 1;\n const observerOptions = useMemo(() => {\n const topMargin = observerMargin % 2 === 1 ? observerMargin - 1 : observerMargin;\n const bottomMargin = targetSize - observerMargin;\n return {\n root: useViewport ? null : root,\n rootMargin: isHorizontal\n ? `0px ${-topMargin}px 0px ${-bottomMargin}px`\n : `${-topMargin}px 0px ${-bottomMargin}px 0px`\n };\n }, [root, targetSize, observerMargin, isHorizontal, useViewport]);\n\n const elsLookup = useMemo(() => {\n const lookup: Record<string, string | undefined> = {};\n for (const { id, parent } of els.current) {\n lookup[id] = parent;\n }\n return lookup;\n }, [counter]);\n const activeIds = useMemo(() => (activeId ? resolveHierarchyIds(activeId, elsLookup) : []), [activeId, elsLookup]);\n\n const activeLookups = useMemo(() => new Set(activeIds), [activeIds]);\n useEffect(() => {\n if (!hasWindow) {\n return;\n }\n const _onScroll = () => {\n let intersectionId = null;\n for (let k = 0; k < els.current.length; k++) {\n const entry = els.current[k].ref.current;\n const min = entry?.getBoundingClientRect().top ? entry?.getBoundingClientRect().top : 0;\n if (!min) {\n break;\n }\n if (min > 0 && k > 0) {\n const totEls =\n root?.previousSibling?.firstChild?.parentNode?.querySelectorAll('.it-navscroll-wrapper .nav-link').length ||\n 1;\n setPercentageValue((k / (totEls / 2)) * 100);\n intersectionId = els.current[k - 1].ref.current?.id;\n break;\n }\n }\n if (intersectionId != null) {\n updateActiveId(intersectionId);\n if (onChange) {\n const diffIds = {\n added: intersectionId,\n removed: activeId\n };\n onChange(diffIds);\n }\n }\n };\n\n onDocumentScroll(_onScroll);\n\n setTimeout(() => {\n _onScroll();\n }, 300);\n }, [\n activeIds,\n updateActiveId,\n els,\n elsLookup,\n onChange,\n activeLookups,\n activeId,\n observerOptions,\n isHorizontal,\n root,\n forceRecompute\n ]);\n\n const refresh = useCallback(\n debounce(() => {\n setCounter(counter + 1);\n }, REGISTER_DELAY),\n [counter]\n );\n\n const register = useCallback(\n (id: string, options: any = {}) => {\n if (!hasWindow) {\n return { id, ref: null };\n }\n const alreadyRegistered = id in elsLookup;\n const entry = alreadyRegistered ? els.current.find(({ id: existingId }) => existingId === id) : options;\n const ref = (entry && entry.ref) || createRef();\n\n if (!alreadyRegistered) {\n els.current = [...els.current, { id, ref, parent: options.parent }];\n refresh();\n }\n return { id, ref };\n },\n [counter]\n );\n\n const unregister = useCallback(\n (idToUnregister: string) => {\n els.current = els.current.filter(({ id }) => id !== idToUnregister);\n },\n [counter]\n );\n\n const isActive = useCallback((id: string) => activeLookups.has(id), [activeLookups]);\n const percentage = useMemo(() => percentageValue, [percentageValue]);\n\n const getActiveRef = useCallback(() => {\n const entry = els.current.find(({ id }) => id === activeId);\n return entry ? entry.ref : null;\n }, [activeId]);\n\n return {\n percentage,\n register,\n unregister,\n activeIds,\n isActive,\n getActiveRef\n };\n}\n","/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nexport const debounce = (callback: CallableFunction, wait: number) => {\n let timeoutId: NodeJS.Timeout;\n return (...args: unknown[]) => {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => {\n callback(...args);\n }, wait);\n };\n};\n","/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { debounce } from './debounce';\nimport { useNavScrollArgs } from './types';\n\nconst DEFAULT_DELAY = 150;\n\nexport type useSizeDetectorArgs = Omit<useNavScrollArgs, 'offset'> & {\n activeId: string | null;\n hasWindow: boolean;\n setForceRecompute: (force: boolean) => void;\n updateActiveId: (id: string | null) => void;\n};\n\nexport const useSizeDetector = ({\n root,\n isHorizontal,\n activeId,\n onChange,\n setForceRecompute,\n updateActiveId,\n hasWindow\n}: useSizeDetectorArgs) => {\n const [targetSize, setTargetSize] = useState<number>(1);\n\n const useViewport =\n root == null ||\n (hasWindow && (isHorizontal ? window.innerWidth < root.clientWidth : window.innerHeight < root.clientHeight));\n\n const scrollEnd = useCallback(\n debounce(() => {\n setForceRecompute(true);\n }, DEFAULT_DELAY),\n [setForceRecompute]\n );\n\n useEffect(() => {\n if (!hasWindow) {\n return;\n }\n let observer: IntersectionObserver | null = null;\n\n const resizeWindowHandler = () => {\n setTimeout(() => {\n setTargetSize(isHorizontal ? window.innerWidth : window.innerHeight);\n }, DEFAULT_DELAY);\n };\n\n const resizeElementHandler: IntersectionObserverCallback = (entries) => {\n const [entry] = entries;\n if (!useViewport) {\n setTargetSize(isHorizontal ? entry.boundingClientRect.width : entry.boundingClientRect.height);\n }\n\n if (entry.intersectionRatio === 0) {\n if (activeId != null) {\n updateActiveId(null);\n if (onChange) {\n onChange({\n added: null,\n removed: activeId\n });\n }\n }\n }\n };\n\n addEventListener('scroll', scrollEnd);\n if (useViewport) {\n setTargetSize(isHorizontal ? window.innerWidth : window.innerHeight);\n addEventListener('resize', resizeWindowHandler);\n }\n if (root) {\n observer = new IntersectionObserver(resizeElementHandler);\n observer.observe(root);\n }\n return () => {\n if (observer) {\n observer.disconnect();\n }\n removeEventListener('resize', resizeWindowHandler);\n removeEventListener('scroll', scrollEnd);\n };\n }, [root, isHorizontal, activeId, onChange, useViewport, scrollEnd, hasWindow, updateActiveId]);\n return { targetSize, useViewport };\n};\n","import crypto from 'crypto';\nconst rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate\n\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n crypto.randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n\n return rnds8Pool.slice(poolPtr, poolPtr += 16);\n}","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).substr(1));\n}\n\nfunction stringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import rng from './rng.js';\nimport stringify from './stringify.js';\n\nfunction v4(options, buf, offset) {\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return stringify(rnds);\n}\n\nexport default v4;"],"mappings":"ukBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,kBAAAE,IAAA,eAAAC,GAAAH,ICcA,IAAAI,EAA6E,iBCRtE,IAAMC,EAAW,CAACC,EAA4BC,IAAiB,CACpE,IAAIC,EACJ,MAAO,IAAIC,IAAoB,CAC7B,aAAaD,CAAS,EACtBA,EAAY,WAAW,IAAM,CAC3BF,EAAS,GAAGG,CAAI,CAClB,EAAGF,CAAI,CACT,CACF,ECRA,IAAAG,EAAiD,iBAIjD,IAAMC,EAAgB,IASTC,EAAkB,CAAC,CAC9B,KAAAC,EACA,aAAAC,EACA,SAAAC,EACA,SAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,UAAAC,CACF,IAA2B,CACzB,GAAM,CAACC,EAAYC,CAAa,KAAI,YAAiB,CAAC,EAEhDC,EACJT,GAAQ,MACPM,IAAcL,EAAe,OAAO,WAAaD,EAAK,YAAc,OAAO,YAAcA,EAAK,cAE3FU,KAAY,eAChBC,EAAS,IAAM,CACbP,EAAkB,EAAI,CACxB,EAAGN,CAAa,EAChB,CAACM,CAAiB,CACpB,EAEA,sBAAU,IAAM,CACd,GAAI,CAACE,EACH,OAEF,IAAIM,EAAwC,KAEtCC,EAAsB,IAAM,CAChC,WAAW,IAAM,CACfL,EAAcP,EAAe,OAAO,WAAa,OAAO,WAAW,CACrE,EAAGH,CA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AQ,OAAO,CAAC,CAAE,GAAAtB,CAAG,IAAMA,IAAOwD,CAAc,CACpE,EACA,CAACjC,CAAO,CACV,EAEMkC,KAAW,eAAazD,GAAeyC,EAAc,IAAIzC,CAAE,EAAG,CAACyC,CAAa,CAAC,EAC7EiB,KAAa,WAAQ,IAAM7B,EAAiB,CAACA,CAAe,CAAC,EAE7D8B,KAAe,eAAY,IAAM,CACrC,IAAMd,EAAQvB,EAAI,QAAQ,KAAK,CAAC,CAAE,GAAAtB,CAAG,IAAMA,IAAO2B,CAAQ,EAC1D,OAAOkB,EAAQA,EAAM,IAAM,IAC7B,EAAG,CAAClB,CAAQ,CAAC,EAEb,MAAO,CACL,WAAA+B,EACA,SAAAR,EACA,WAAAK,EACA,UAAAf,EACA,SAAAiB,EACA,aAAAE,CACF,CACF","names":["NavScroll_exports","__export","useNavScroll","__toCommonJS","import_react","debounce","callback","wait","timeoutId","args","import_react","DEFAULT_DELAY","useSizeDetector","root","isHorizontal","activeId","onChange","setForceRecompute","updateActiveId","hasWindow","targetSize","setTargetSize","useViewport","scrollEnd","debounce","observer","resizeWindowHandler","resizeElementHandler","entries","entry","import_crypto","rnds8Pool","poolPtr","rng","crypto","regex_default","validate","uuid","regex_default","validate_default","byteToHex","i","stringify","arr","offset","uuid","validate_default","stringify_default","v4","options","buf","offset","rnds","rng","i","stringify_default","v4_default","ticking","callbacks","ScrollCallback","id","callback","removeCallBack","data","cb","onDocumentScroll","evt","cbObj","newCb","v4_default","hasWindow","REGISTER_DELAY","resolveHierarchyIds","lookup","newActiveIds","lastId","useNavScroll","args","onChange","root","offset","isHorizontal","els","counter","setCounter","forceRecompute","setForceRecompute","activeId","updateActiveId","percentageValue","setPercentageValue","targetSize","useViewport","useSizeDetector","observerMargin","observerOptions","topMargin","bottomMargin","elsLookup","parent","activeIds","activeLookups","_onScroll","intersectionId","k","entry","min","totEls","refresh","debounce","register","options","alreadyRegistered","existingId","ref","unregister","idToUnregister","isActive","percentage","getActiveRef"]}
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var p=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of g(e))!l.call(t,r)&&r!==n&&s(t,r,{get:()=>e[r],enumerable:!(i=o(e,r))||i.enumerable});return t};var d=t=>p(s({},"__esModule",{value:!0}),t);var a={};module.exports=d(a);
1
+ "use strict";var n=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var l=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of g(e))!p.call(t,r)&&r!==s&&n(t,r,{get:()=>e[r],enumerable:!(i=o(e,r))||i.enumerable});return t};var d=t=>l(n({},"__esModule",{value:!0}),t);var a={};module.exports=d(a);
2
2
  //# sourceMappingURL=types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/NavScroll/types.ts"],"sourcesContent":["/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nimport { HTMLAttributes, RefObject } from 'react';\n\n/**\n * The returned object from the `onChange` passed function, with the current state of\n * `added` and `removed` element ids.\n */\nexport type ChangesType = {\n added: string | null;\n removed: string | null;\n};\n\n/**\n * The react-use-navscroll configuration object\n */\nexport type useNavScrollArgs = {\n /**\n * Function called every time an element becomes active.\n * The changes object returned contains the \"added\" and \"removed\" id.\n * */\n onChange?: (changes: ChangesType) => void;\n /**\n * Pass an element as root to track a specific container, smaller than a viewport. Default is window (the whole viewport).\n * */\n root?: Element;\n /**\n * Moves the detection line by the amount of this offset, expressed in percentage. By default the value is 50 (center).\n * */\n offset?: number;\n /**\n * Declare if the detection should work vertically or horizontally. By default false (vertical)\n */\n isHorizontal?: boolean;\n};\n\n/**\n * The options object passed to the `register` function.\n */\nexport type RegisterOptions = {\n /**\n * Pass the string id of the parent element\n */\n parent?: string;\n /**\n * If the tracked element has already a reference, you can pass it and will be reused\n */\n ref?: RefObject<Element>;\n};\n\n/**\n * The attributes object to assign to the element to assign\n */\nexport type RegisteredAttributes<T extends Element> = {\n id: HTMLAttributes<T>['id'];\n ref: RefObject<T> | null;\n};\n\n/**\n * The object returned by the hook.\n */\nexport type useNavScrollResult = {\n /**\n * The function used to register the component into the tracking system.\n * It returns the id already passed and the reference object.\n * Note that only the reference value will be `null` in a SSR context.\n */\n register: <T extends Element>(id: string, options?: RegisterOptions) => RegisteredAttributes<T>;\n /**\n * Removes the given id from the tracking system.\n */\n unregister: (idToUnregister: string) => void;\n /**\n * A list of active ids (the full hierarchy).\n */\n activeIds: string[];\n /**\n * A convenience function to quickly check the active state for the given id\n */\n isActive: (id: string) => boolean;\n /**\n * A function to retrieve the reference of the current active element (only the last element, not the elements hierarchy).\n */\n getActiveRef: () => RefObject<Element> | null;\n};\n\n// @private\nexport type TrackedElement = {\n id: string;\n} & Required<Pick<RegisterOptions, 'ref'>> &\n Pick<RegisterOptions, 'parent'>;\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["types_exports","__toCommonJS"]}
1
+ {"version":3,"sources":["../../src/NavScroll/types.ts"],"sourcesContent":["/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nimport { HTMLAttributes, RefObject } from 'react';\n\n/**\n * The returned object from the `onChange` passed function, with the current state of\n * `added` and `removed` element ids.\n */\nexport type ChangesType = {\n added: string | null;\n removed: string | null;\n};\n\n/**\n * The react-use-navscroll configuration object\n */\nexport type useNavScrollArgs = {\n /**\n * Function called every time an element becomes active.\n * The changes object returned contains the \"added\" and \"removed\" id.\n * */\n onChange?: (changes: ChangesType) => void;\n /**\n * Pass an element as root to track a specific container, smaller than a viewport. Default is window (the whole viewport).\n * */\n root?: Element;\n /**\n * Moves the detection line by the amount of this offset, expressed in percentage. By default the value is 50 (center).\n * */\n offset?: number;\n /**\n * Declare if the detection should work vertically or horizontally. By default false (vertical)\n */\n isHorizontal?: boolean;\n};\n\n/**\n * The options object passed to the `register` function.\n */\nexport type RegisterOptions = {\n /**\n * Pass the string id of the parent element\n */\n parent?: string;\n /**\n * If the tracked element has already a reference, you can pass it and will be reused\n */\n ref?: RefObject<Element>;\n};\n\n/**\n * The attributes object to assign to the element to assign\n */\nexport type RegisteredAttributes<T extends Element> = {\n id: HTMLAttributes<T>['id'];\n ref: RefObject<T> | null;\n};\n\n/**\n * The object returned by the hook.\n */\nexport type useNavScrollResult = {\n /**\n * The function used to register the component into the tracking system.\n * It returns the id already passed and the reference object.\n * Note that only the reference value will be `null` in a SSR context.\n */\n register: <T extends Element>(id: string, options?: RegisterOptions) => RegisteredAttributes<T>;\n /**\n * Removes the given id from the tracking system.\n */\n unregister: (idToUnregister: string) => void;\n /**\n * A list of active ids (the full hierarchy).\n */\n activeIds: string[];\n /**\n * A convenience function to quickly check the active state for the given id\n */\n isActive: (id: string) => boolean;\n /**\n * A function to retrieve the reference of the current active element (only the last element, not the elements hierarchy).\n */\n getActiveRef: () => RefObject<Element> | null;\n /**\n * A list of active ids (the full hierarchy).\n */\n percentage: number;\n};\n\n// @private\nexport type TrackedElement = {\n id: string;\n} & Required<Pick<RegisterOptions, 'ref'>> &\n Pick<RegisterOptions, 'parent'>;\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["types_exports","__toCommonJS"]}
@@ -1,2 +1,2 @@
1
- "use strict";var C=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var V=(r,e)=>{for(var s in e)C(r,s,{get:e[s],enumerable:!0})},Y=(r,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of $(e))!F.call(r,c)&&c!==s&&C(r,c,{get:()=>e[c],enumerable:!(o=H(e,c))||o.enumerable});return r};var _=r=>Y(C({},"__esModule",{value:!0}),r);var j={};V(j,{useNavScroll:()=>U});module.exports=_(j);var n=require("react");var x=(r,e)=>{let s;return(...o)=>{clearTimeout(s),s=setTimeout(()=>{r(...o)},e)}};var S=require("react");var z=150,N=({root:r,isHorizontal:e,activeId:s,onChange:o,setForceRecompute:c,updateActiveId:l,hasWindow:m})=>{let[k,b]=(0,S.useState)(1),a=r==null||m&&(e?window.innerWidth<r.clientWidth:window.innerHeight<r.clientHeight),u=(0,S.useCallback)(x(()=>{c(!0)},z),[c]);return(0,S.useEffect)(()=>{if(!m)return;let f=null,w=()=>{setTimeout(()=>{b(e?window.innerWidth:window.innerHeight)},z)},E=g=>{let[h]=g;a||b(e?h.boundingClientRect.width:h.boundingClientRect.height),h.intersectionRatio===0&&s!=null&&(l(null),o&&o({added:null,removed:s}))};return addEventListener("scroll",u),a&&(b(e?window.innerWidth:window.innerHeight),addEventListener("resize",w)),r&&(f=new IntersectionObserver(E),f.observe(r)),()=>{f&&f.disconnect(),removeEventListener("resize",w),removeEventListener("scroll",u)}},[r,e,s,o,a,u,m,l]),{targetSize:k,useViewport:a}};var L=typeof window<"u",G=50;function J(r,e){let s=[r],o=s[0];for(;o!=null&&e[o]!=null;)s.push(e[o]),o=e[o];return s.reverse()}function U(r={}){let{onChange:e,root:s,offset:o=50,isHorizontal:c=!1}=r,l=(0,n.useRef)([]),[m,k]=(0,n.useState)(0),[b,a]=(0,n.useState)(!1),[u,f]=(0,n.useState)(null),{targetSize:w,useViewport:E}=N({root:s,isHorizontal:c,onChange:e,activeId:u,setForceRecompute:a,updateActiveId:f,hasWindow:L}),g=Math.floor(w*o/100)||1,h=(0,n.useMemo)(()=>{let t=g%2===1?g-1:g,i=w-g;return{root:E?null:s,rootMargin:c?`0px ${-t}px 0px ${-i}px`:`${-t}px 0px ${-i}px 0px`}},[s,w,g,c,E]),I=(0,n.useMemo)(()=>{let t={};for(let{id:i,parent:d}of l.current)t[i]=d;return t},[]),A=(0,n.useMemo)(()=>u?J(u,I):[],[u,I]),y=(0,n.useMemo)(()=>new Set(A),[A]);(0,n.useEffect)(()=>{if(!L)return;let t=d=>{let p=null,R=1/0;d.forEach(v=>{v.isIntersecting&&R>v.boundingClientRect.top&&(R=v.boundingClientRect.top,p=v.target.id)}),p!=null&&(f(p),e&&e({added:p,removed:u}))},i=new IntersectionObserver(t,h);return l.current.forEach(({ref:d})=>{d&&d.current&&i.observe(d.current)}),b&&(t(i.takeRecords(),i),a(!1)),()=>{i.disconnect()}},[A,f,l,I,e,y,u,h,c,s,b]);let T=(0,n.useCallback)(x(()=>{k(m+1)},G),[m]),D=(0,n.useCallback)((t,i={})=>{if(!L)return{id:t,ref:null};let d=t in I,p=d?l.current.find(({id:v})=>v===t):i,R=p&&p.ref||(0,n.createRef)();return d||(l.current=[...l.current,{id:t,ref:R,parent:i.parent}],T()),{id:t,ref:R}},[I,T]),M=(0,n.useCallback)(t=>{l.current=l.current.filter(({id:i})=>i!==t)},[]),O=(0,n.useCallback)(t=>y.has(t),[y]),W=(0,n.useCallback)(()=>{let t=l.current.find(({id:i})=>i===u);return t?t.ref:null},[u]);return{register:D,unregister:M,activeIds:A,isActive:O,getActiveRef:W}}0&&(module.exports={useNavScroll});
1
+ "use strict";var Z=Object.create;var k=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var oe=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},W=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of te(t))!re.call(e,s)&&s!==n&&k(e,s,{get:()=>t[s],enumerable:!(r=ee(t,s))||r.enumerable});return e};var ie=(e,t,n)=>(n=e!=null?Z(ne(e)):{},W(t||!e||!e.__esModule?k(n,"default",{value:e,enumerable:!0}):n,e)),se=e=>W(k({},"__esModule",{value:!0}),e);var ge={};oe(ge,{useNavScroll:()=>me});module.exports=se(ge);var o=require("react");var I=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}};var v=require("react");var $=150,U=({root:e,isHorizontal:t,activeId:n,onChange:r,setForceRecompute:s,updateActiveId:u,hasWindow:f})=>{let[C,x]=(0,v.useState)(1),m=e==null||f&&(t?window.innerWidth<e.clientWidth:window.innerHeight<e.clientHeight),d=(0,v.useCallback)(I(()=>{s(!0)},$),[s]);return(0,v.useEffect)(()=>{if(!f)return;let p=null,w=()=>{setTimeout(()=>{x(t?window.innerWidth:window.innerHeight)},$)},D=b=>{let[g]=b;m||x(t?g.boundingClientRect.width:g.boundingClientRect.height),g.intersectionRatio===0&&n!=null&&(u(null),r&&r({added:null,removed:n}))};return addEventListener("scroll",d),m&&(x(t?window.innerWidth:window.innerHeight),addEventListener("resize",w)),e&&(p=new IntersectionObserver(D),p.observe(e)),()=>{p&&p.disconnect(),removeEventListener("resize",w),removeEventListener("scroll",d)}},[e,t,n,r,m,d,f,u]),{targetSize:C,useViewport:m}};var V=ie(require("crypto")),T=new Uint8Array(256),L=T.length;function _(){return L>T.length-16&&(V.default.randomFillSync(T),L=0),T.slice(L,L+=16)}var B=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function ce(e){return typeof e=="string"&&B.test(e)}var P=ce;var c=[];for(let e=0;e<256;++e)c.push((e+256).toString(16).substr(1));function le(e,t=0){let n=(c[e[t+0]]+c[e[t+1]]+c[e[t+2]]+c[e[t+3]]+"-"+c[e[t+4]]+c[e[t+5]]+"-"+c[e[t+6]]+c[e[t+7]]+"-"+c[e[t+8]]+c[e[t+9]]+"-"+c[e[t+10]]+c[e[t+11]]+c[e[t+12]]+c[e[t+13]]+c[e[t+14]]+c[e[t+15]]).toLowerCase();if(!P(n))throw TypeError("Stringified UUID is invalid");return n}var q=le;function ue(e,t,n){e=e||{};let r=e.random||(e.rng||_)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n=n||0;for(let s=0;s<16;++s)t[n+s]=r[s];return t}return q(r)}var M=ue;var F=!1,E=[],O=class{_callback;id;constructor(t,n){this.id=t,this._callback=n}dispose(){de(this.id)}_execute(t){this._callback(t)}},de=e=>{E=E.filter(t=>t.id!==e)},ae=e=>{if(!(typeof document>"u")){if(E.length||typeof window<"u"&&typeof document<"u"&&document.addEventListener("scroll",t=>{F||(window.requestAnimationFrame(()=>{E.forEach(n=>n.cb._execute(t)),F=!1}),F=!0)}),typeof e=="function"){let t=new O(M(),e);return E.push({id:t.id,cb:t}),t}return console.error("[onDocumentScroll] the provided data has to be of type function"),null}},H=typeof window<"u",fe=50;function pe(e,t){let n=[e],r=n[0];for(;r!=null&&t[r]!=null;)n.push(t[r]),r=t[r];return n.reverse()}function me(e={}){let{onChange:t,root:n,offset:r=50,isHorizontal:s=!1}=e,u=(0,o.useRef)([]),[f,C]=(0,o.useState)(0),[x,m]=(0,o.useState)(!1),[d,p]=(0,o.useState)(null),[w,D]=(0,o.useState)(0),{targetSize:b,useViewport:g}=U({root:n,isHorizontal:s,onChange:t,activeId:d,setForceRecompute:m,updateActiveId:p,hasWindow:H}),h=Math.floor(b*r/100)||1,G=(0,o.useMemo)(()=>{let i=h%2===1?h-1:h,l=b-h;return{root:g?null:n,rootMargin:s?`0px ${-i}px 0px ${-l}px`:`${-i}px 0px ${-l}px 0px`}},[n,b,h,s,g]),R=(0,o.useMemo)(()=>{let i={};for(let{id:l,parent:a}of u.current)i[l]=a;return i},[f]),A=(0,o.useMemo)(()=>d?pe(d,R):[],[d,R]),N=(0,o.useMemo)(()=>new Set(A),[A]);(0,o.useEffect)(()=>{if(!H)return;let i=()=>{let l=null;for(let a=0;a<u.current.length;a++){let y=u.current[a].ref.current,S=y?.getBoundingClientRect().top?y?.getBoundingClientRect().top:0;if(!S)break;if(S>0&&a>0){let z=n?.previousSibling?.firstChild?.parentNode?.querySelectorAll(".it-navscroll-wrapper .nav-link").length||1;D(a/(z/2)*100),l=u.current[a-1].ref.current?.id;break}}l!=null&&(p(l),t&&t({added:l,removed:d}))};ae(i),setTimeout(()=>{i()},300)},[A,p,u,R,t,N,d,G,s,n,x]);let Y=(0,o.useCallback)(I(()=>{C(f+1)},fe),[f]),J=(0,o.useCallback)((i,l={})=>{if(!H)return{id:i,ref:null};let a=i in R,y=a?u.current.find(({id:z})=>z===i):l,S=y&&y.ref||(0,o.createRef)();return a||(u.current=[...u.current,{id:i,ref:S,parent:l.parent}],Y()),{id:i,ref:S}},[f]),X=(0,o.useCallback)(i=>{u.current=u.current.filter(({id:l})=>l!==i)},[f]),j=(0,o.useCallback)(i=>N.has(i),[N]),K=(0,o.useMemo)(()=>w,[w]),Q=(0,o.useCallback)(()=>{let i=u.current.find(({id:l})=>l===d);return i?i.ref:null},[d]);return{percentage:K,register:J,unregister:X,activeIds:A,isActive:j,getActiveRef:Q}}0&&(module.exports={useNavScroll});
2
2
  //# sourceMappingURL=useNavScroll.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/NavScroll/useNavScroll.ts","../../src/NavScroll/debounce.ts","../../src/NavScroll/useSizeDetector.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nimport { createRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { debounce } from './debounce';\nimport type { TrackedElement, useNavScrollArgs, useNavScrollResult } from './types';\nimport { useSizeDetector } from './useSizeDetector';\n\nconst hasWindow = typeof window !== 'undefined';\nconst REGISTER_DELAY = 50;\n\nfunction resolveHierarchyIds(id: string, lookup: Record<string, string | undefined>) {\n const newActiveIds = [id];\n let lastId: string | undefined = newActiveIds[0];\n while (lastId != null && lookup[lastId] != null) {\n newActiveIds.push(lookup[lastId] as string);\n lastId = lookup[lastId];\n }\n // return a list from parent to current child\n return newActiveIds.reverse();\n}\n/**\n * This is the main hook: use it in a react function component to track\n * the state of the passed ids. The function accepts an initial configuration\n * of type `useNavScrollArgs` to customize the behaviour.\n */\nexport function useNavScroll(args: useNavScrollArgs = {}): useNavScrollResult {\n const { onChange, root, offset = 50, isHorizontal = false } = args;\n const els = useRef<TrackedElement[]>([]);\n const [counter, setCounter] = useState(0);\n const [forceRecompute, setForceRecompute] = useState(false);\n const [activeId, updateActiveId] = useState<string | null>(null);\n\n const { targetSize, useViewport } = useSizeDetector({\n root,\n isHorizontal,\n onChange,\n activeId,\n setForceRecompute,\n updateActiveId,\n hasWindow\n });\n\n const observerMargin = Math.floor((targetSize * offset) / 100) || 1;\n const observerOptions = useMemo(() => {\n const topMargin = observerMargin % 2 === 1 ? observerMargin - 1 : observerMargin;\n const bottomMargin = targetSize - observerMargin;\n return {\n root: useViewport ? null : root,\n rootMargin: isHorizontal\n ? `0px ${-topMargin}px 0px ${-bottomMargin}px`\n : `${-topMargin}px 0px ${-bottomMargin}px 0px`\n };\n }, [root, targetSize, observerMargin, isHorizontal, useViewport]);\n\n const elsLookup = useMemo(() => {\n const lookup: Record<string, string | undefined> = {};\n for (const { id, parent } of els.current) {\n lookup[id] = parent;\n }\n return lookup;\n }, []);\n const activeIds = useMemo(() => (activeId ? resolveHierarchyIds(activeId, elsLookup) : []), [activeId, elsLookup]);\n\n const activeLookups = useMemo(() => new Set(activeIds), [activeIds]);\n useEffect(() => {\n if (!hasWindow) {\n return;\n }\n const handleIntersection: IntersectionObserverCallback = (entries) => {\n let intersectionId = null;\n let topMin = Infinity;\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n if (topMin > entry.boundingClientRect.top) {\n topMin = entry.boundingClientRect.top;\n intersectionId = entry.target.id;\n }\n }\n });\n if (intersectionId != null) {\n updateActiveId(intersectionId);\n if (onChange) {\n const diffIds = {\n added: intersectionId,\n removed: activeId\n };\n onChange(diffIds);\n }\n }\n };\n\n const observer = new IntersectionObserver(handleIntersection, observerOptions);\n\n els.current.forEach(({ ref }) => {\n if (ref && ref.current) {\n observer.observe(ref.current);\n }\n });\n\n if (forceRecompute) {\n handleIntersection(observer.takeRecords(), observer);\n setForceRecompute(false);\n }\n return () => {\n observer.disconnect();\n };\n }, [\n activeIds,\n updateActiveId,\n els,\n elsLookup,\n onChange,\n activeLookups,\n activeId,\n observerOptions,\n isHorizontal,\n root,\n forceRecompute\n ]);\n\n const refresh = useCallback(\n debounce(() => {\n setCounter(counter + 1);\n }, REGISTER_DELAY),\n [counter]\n );\n\n const register = useCallback(\n (id: string, options = {}) => {\n if (!hasWindow) {\n return { id, ref: null };\n }\n const alreadyRegistered = id in elsLookup;\n const entry = (alreadyRegistered ? els.current.find(({ id: existingId }) => existingId === id) : options) as any;\n const ref = (entry && entry.ref) || createRef();\n\n if (!alreadyRegistered) {\n els.current = [...els.current, { id, ref, parent: (options as any).parent }];\n refresh();\n }\n return { id, ref };\n },\n [elsLookup, refresh]\n );\n\n const unregister = useCallback((idToUnregister: string) => {\n els.current = els.current.filter(({ id }) => id !== idToUnregister);\n }, []);\n\n const isActive = useCallback((id: string) => activeLookups.has(id), [activeLookups]);\n\n const getActiveRef = useCallback(() => {\n const entry = els.current.find(({ id }) => id === activeId);\n return entry ? entry.ref : null;\n }, [activeId]);\n\n return {\n register,\n unregister,\n activeIds,\n isActive,\n getActiveRef\n };\n}\n","/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nexport const debounce = (callback: CallableFunction, wait: number) => {\n let timeoutId: NodeJS.Timeout;\n return (...args: unknown[]) => {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => {\n callback(...args);\n }, wait);\n };\n};\n","/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { debounce } from './debounce';\nimport { useNavScrollArgs } from './types';\n\nconst DEFAULT_DELAY = 150;\n\nexport type useSizeDetectorArgs = Omit<useNavScrollArgs, 'offset'> & {\n activeId: string | null;\n hasWindow: boolean;\n setForceRecompute: (force: boolean) => void;\n updateActiveId: (id: string | null) => void;\n};\n\nexport const useSizeDetector = ({\n root,\n isHorizontal,\n activeId,\n onChange,\n setForceRecompute,\n updateActiveId,\n hasWindow\n}: useSizeDetectorArgs) => {\n const [targetSize, setTargetSize] = useState<number>(1);\n\n const useViewport =\n root == null ||\n (hasWindow && (isHorizontal ? window.innerWidth < root.clientWidth : window.innerHeight < root.clientHeight));\n\n const scrollEnd = useCallback(\n debounce(() => {\n setForceRecompute(true);\n }, DEFAULT_DELAY),\n [setForceRecompute]\n );\n\n useEffect(() => {\n if (!hasWindow) {\n return;\n }\n let observer: IntersectionObserver | null = null;\n\n const resizeWindowHandler = () => {\n setTimeout(() => {\n setTargetSize(isHorizontal ? window.innerWidth : window.innerHeight);\n }, DEFAULT_DELAY);\n };\n\n const resizeElementHandler: IntersectionObserverCallback = (entries) => {\n const [entry] = entries;\n if (!useViewport) {\n setTargetSize(isHorizontal ? entry.boundingClientRect.width : entry.boundingClientRect.height);\n }\n\n if (entry.intersectionRatio === 0) {\n if (activeId != null) {\n updateActiveId(null);\n if (onChange) {\n onChange({\n added: null,\n removed: activeId\n });\n }\n }\n }\n };\n\n addEventListener('scroll', scrollEnd);\n if (useViewport) {\n setTargetSize(isHorizontal ? window.innerWidth : window.innerHeight);\n addEventListener('resize', resizeWindowHandler);\n }\n if (root) {\n observer = new IntersectionObserver(resizeElementHandler);\n observer.observe(root);\n }\n return () => {\n if (observer) {\n observer.disconnect();\n }\n removeEventListener('resize', resizeWindowHandler);\n removeEventListener('scroll', scrollEnd);\n };\n }, [root, isHorizontal, activeId, onChange, useViewport, scrollEnd, hasWindow, updateActiveId]);\n return { targetSize, useViewport };\n};\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAOA,IAAAI,EAA6E,iBCDtE,IAAMC,EAAW,CAACC,EAA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M,CAC5B,GAAI,CAACzC,EACH,MAAO,CAAE,GAAAG,EAAI,IAAK,IAAK,EAEzB,IAAMuC,EAAoBvC,KAAMwB,EAC1BQ,EAASO,EAAoB7B,EAAI,QAAQ,KAAK,CAAC,CAAE,GAAI8B,CAAW,IAAMA,IAAexC,CAAE,EAAIsC,EAC3FJ,EAAOF,GAASA,EAAM,QAAQ,aAAU,EAE9C,OAAKO,IACH7B,EAAI,QAAU,CAAC,GAAGA,EAAI,QAAS,CAAE,GAAAV,EAAI,IAAAkC,EAAK,OAASI,EAAgB,MAAO,CAAC,EAC3EH,EAAQ,GAEH,CAAE,GAAAnC,EAAI,IAAAkC,CAAI,CACnB,EACA,CAACV,EAAWW,CAAO,CACrB,EAEMM,KAAa,eAAaC,GAA2B,CACzDhC,EAAI,QAAUA,EAAI,QAAQ,OAAO,CAAC,CAAE,GAAAV,CAAG,IAAMA,IAAO0C,CAAc,CACpE,EAAG,CAAC,CAAC,EAECC,KAAW,eAAa3C,GAAe2B,EAAc,IAAI3B,CAAE,EAAG,CAAC2B,CAAa,CAAC,EAE7EiB,KAAe,eAAY,IAAM,CACrC,IAAMZ,EAAQtB,EAAI,QAAQ,KAAK,CAAC,CAAE,GAAAV,CAAG,IAAMA,IAAOe,CAAQ,EAC1D,OAAOiB,EAAQA,EAAM,IAAM,IAC7B,EAAG,CAACjB,CAAQ,CAAC,EAEb,MAAO,CACL,SAAAsB,EACA,WAAAI,EACA,UAAAf,EACA,SAAAiB,EACA,aAAAC,CACF,CACF","names":["useNavScroll_exports","__export","useNavScroll","__toCommonJS","import_react","debounce","callback","wait","timeoutId","args","import_react","DEFAULT_DELAY","useSizeDetector","root","isHorizontal","activeId","onChange","setForceRecompute","updateActiveId","hasWindow","targetSize","setTargetSize","useViewport","scrollEnd","debounce","observer","resizeWindowHandler","resizeElementHandler","entries","entry","hasWindow","REGISTER_DELAY","resolveHierarchyIds","id","lookup","newActiveIds","lastId","useNavScroll","args","onChange","root","offset","isHorizontal","els","counter","setCounter","forceRecompute","setForceRecompute","activeId","updateActiveId","targetSize","useViewport","useSizeDetector","observerMargin","observerOptions","topMargin","bottomMargin","elsLookup","parent","activeIds","activeLookups","handleIntersection","entries","intersectionId","topMin","entry","observer","ref","refresh","debounce","register","options","alreadyRegistered","existingId","unregister","idToUnregister","isActive","getActiveRef"]}
1
+ {"version":3,"sources":["../../src/NavScroll/useNavScroll.ts","../../src/NavScroll/debounce.ts","../../src/NavScroll/useSizeDetector.ts","../../node_modules/uuid/dist/esm-node/rng.js","../../node_modules/uuid/dist/esm-node/regex.js","../../node_modules/uuid/dist/esm-node/validate.js","../../node_modules/uuid/dist/esm-node/stringify.js","../../node_modules/uuid/dist/esm-node/v4.js"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/*--------------------------------------------------------------------------\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati (@dej611)\n * Code: https://github.com/dej611/react-use-navscroll\n * --------------------------------------------------------------------------\n * Parts of this code has been modified using Bootstrap Italia source code\n * --------------------------------------------------------------------------\n * Bootstrap Italia (https://italia.github.io/bootstrap-italia/)\n * Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS\n * License: BSD-3-Clause (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport { createRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { debounce } from './debounce';\nimport type { useNavScrollArgs, useNavScrollResult, TrackedElement } from './types';\nimport { useSizeDetector } from './useSizeDetector';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nlet ticking: boolean = false;\nlet callbacks: any[] = [];\n\nclass ScrollCallback {\n private _callback: any;\n id: string;\n constructor(id: string, callback: any) {\n this.id = id;\n this._callback = callback;\n }\n\n //Public\n dispose() {\n removeCallBack(this.id);\n }\n\n //Private\n _execute(data: any) {\n this._callback(data);\n }\n}\n\nconst removeCallBack = (id: string) => {\n callbacks = callbacks.filter((cb) => cb.id !== id);\n};\n\nconst onDocumentScroll = (callback: any) => {\n if (typeof document === 'undefined') {\n return;\n }\n if (!callbacks.length) {\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n document.addEventListener('scroll', (evt) => {\n if (!ticking) {\n window.requestAnimationFrame(() => {\n callbacks.forEach((cbObj) => cbObj.cb._execute(evt));\n ticking = false;\n });\n ticking = true;\n }\n });\n }\n }\n\n if (typeof callback === 'function') {\n const newCb = new ScrollCallback(uuidv4(), callback);\n callbacks.push({\n id: newCb.id,\n cb: newCb\n });\n return newCb;\n }\n\n console.error('[onDocumentScroll] the provided data has to be of type function');\n return null;\n};\n\nconst hasWindow = typeof window !== 'undefined';\nconst REGISTER_DELAY = 50;\n\nfunction resolveHierarchyIds(id: string, lookup: Record<string, string | undefined>) {\n const newActiveIds = [id];\n let lastId: string | undefined = newActiveIds[0];\n while (lastId != null && lookup[lastId] != null) {\n newActiveIds.push(lookup[lastId] as string);\n lastId = lookup[lastId];\n }\n // return a list from parent to current child\n return newActiveIds.reverse();\n}\n/**\n * This is the main hook: use it in a react function component to track\n * the state of the passed ids. The function accepts an initial configuration\n * of type `useNavScrollArgs` to customize the behaviour.\n */\nexport function useNavScroll(args: useNavScrollArgs = {}): useNavScrollResult {\n const { onChange, root, offset = 50, isHorizontal = false } = args;\n const els = useRef<TrackedElement[]>([]);\n const [counter, setCounter] = useState(0);\n const [forceRecompute, setForceRecompute] = useState(false);\n const [activeId, updateActiveId] = useState<string | null>(null);\n const [percentageValue, setPercentageValue] = useState(0);\n\n const { targetSize, useViewport } = useSizeDetector({\n root,\n isHorizontal,\n onChange,\n activeId,\n setForceRecompute,\n updateActiveId,\n hasWindow\n });\n\n const observerMargin = Math.floor((targetSize * offset) / 100) || 1;\n const observerOptions = useMemo(() => {\n const topMargin = observerMargin % 2 === 1 ? observerMargin - 1 : observerMargin;\n const bottomMargin = targetSize - observerMargin;\n return {\n root: useViewport ? null : root,\n rootMargin: isHorizontal\n ? `0px ${-topMargin}px 0px ${-bottomMargin}px`\n : `${-topMargin}px 0px ${-bottomMargin}px 0px`\n };\n }, [root, targetSize, observerMargin, isHorizontal, useViewport]);\n\n const elsLookup = useMemo(() => {\n const lookup: Record<string, string | undefined> = {};\n for (const { id, parent } of els.current) {\n lookup[id] = parent;\n }\n return lookup;\n }, [counter]);\n const activeIds = useMemo(() => (activeId ? resolveHierarchyIds(activeId, elsLookup) : []), [activeId, elsLookup]);\n\n const activeLookups = useMemo(() => new Set(activeIds), [activeIds]);\n useEffect(() => {\n if (!hasWindow) {\n return;\n }\n const _onScroll = () => {\n let intersectionId = null;\n for (let k = 0; k < els.current.length; k++) {\n const entry = els.current[k].ref.current;\n const min = entry?.getBoundingClientRect().top ? entry?.getBoundingClientRect().top : 0;\n if (!min) {\n break;\n }\n if (min > 0 && k > 0) {\n const totEls =\n root?.previousSibling?.firstChild?.parentNode?.querySelectorAll('.it-navscroll-wrapper .nav-link').length ||\n 1;\n setPercentageValue((k / (totEls / 2)) * 100);\n intersectionId = els.current[k - 1].ref.current?.id;\n break;\n }\n }\n if (intersectionId != null) {\n updateActiveId(intersectionId);\n if (onChange) {\n const diffIds = {\n added: intersectionId,\n removed: activeId\n };\n onChange(diffIds);\n }\n }\n };\n\n onDocumentScroll(_onScroll);\n\n setTimeout(() => {\n _onScroll();\n }, 300);\n }, [\n activeIds,\n updateActiveId,\n els,\n elsLookup,\n onChange,\n activeLookups,\n activeId,\n observerOptions,\n isHorizontal,\n root,\n forceRecompute\n ]);\n\n const refresh = useCallback(\n debounce(() => {\n setCounter(counter + 1);\n }, REGISTER_DELAY),\n [counter]\n );\n\n const register = useCallback(\n (id: string, options: any = {}) => {\n if (!hasWindow) {\n return { id, ref: null };\n }\n const alreadyRegistered = id in elsLookup;\n const entry = alreadyRegistered ? els.current.find(({ id: existingId }) => existingId === id) : options;\n const ref = (entry && entry.ref) || createRef();\n\n if (!alreadyRegistered) {\n els.current = [...els.current, { id, ref, parent: options.parent }];\n refresh();\n }\n return { id, ref };\n },\n [counter]\n );\n\n const unregister = useCallback(\n (idToUnregister: string) => {\n els.current = els.current.filter(({ id }) => id !== idToUnregister);\n },\n [counter]\n );\n\n const isActive = useCallback((id: string) => activeLookups.has(id), [activeLookups]);\n const percentage = useMemo(() => percentageValue, [percentageValue]);\n\n const getActiveRef = useCallback(() => {\n const entry = els.current.find(({ id }) => id === activeId);\n return entry ? entry.ref : null;\n }, [activeId]);\n\n return {\n percentage,\n register,\n unregister,\n activeIds,\n isActive,\n getActiveRef\n };\n}\n","/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nexport const debounce = (callback: CallableFunction, wait: number) => {\n let timeoutId: NodeJS.Timeout;\n return (...args: unknown[]) => {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => {\n callback(...args);\n }, wait);\n };\n};\n","/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { debounce } from './debounce';\nimport { useNavScrollArgs } from './types';\n\nconst DEFAULT_DELAY = 150;\n\nexport type useSizeDetectorArgs = Omit<useNavScrollArgs, 'offset'> & {\n activeId: string | null;\n hasWindow: boolean;\n setForceRecompute: (force: boolean) => void;\n updateActiveId: (id: string | null) => void;\n};\n\nexport const useSizeDetector = ({\n root,\n isHorizontal,\n activeId,\n onChange,\n setForceRecompute,\n updateActiveId,\n hasWindow\n}: useSizeDetectorArgs) => {\n const [targetSize, setTargetSize] = useState<number>(1);\n\n const useViewport =\n root == null ||\n (hasWindow && (isHorizontal ? window.innerWidth < root.clientWidth : window.innerHeight < root.clientHeight));\n\n const scrollEnd = useCallback(\n debounce(() => {\n setForceRecompute(true);\n }, DEFAULT_DELAY),\n [setForceRecompute]\n );\n\n useEffect(() => {\n if (!hasWindow) {\n return;\n }\n let observer: IntersectionObserver | null = null;\n\n const resizeWindowHandler = () => {\n setTimeout(() => {\n setTargetSize(isHorizontal ? window.innerWidth : window.innerHeight);\n }, DEFAULT_DELAY);\n };\n\n const resizeElementHandler: IntersectionObserverCallback = (entries) => {\n const [entry] = entries;\n if (!useViewport) {\n setTargetSize(isHorizontal ? entry.boundingClientRect.width : entry.boundingClientRect.height);\n }\n\n if (entry.intersectionRatio === 0) {\n if (activeId != null) {\n updateActiveId(null);\n if (onChange) {\n onChange({\n added: null,\n removed: activeId\n });\n }\n }\n }\n };\n\n addEventListener('scroll', scrollEnd);\n if (useViewport) {\n setTargetSize(isHorizontal ? window.innerWidth : window.innerHeight);\n addEventListener('resize', resizeWindowHandler);\n }\n if (root) {\n observer = new IntersectionObserver(resizeElementHandler);\n observer.observe(root);\n }\n return () => {\n if (observer) {\n observer.disconnect();\n }\n removeEventListener('resize', resizeWindowHandler);\n removeEventListener('scroll', scrollEnd);\n };\n }, [root, isHorizontal, activeId, onChange, useViewport, scrollEnd, hasWindow, updateActiveId]);\n return { targetSize, useViewport };\n};\n","import crypto from 'crypto';\nconst rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate\n\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n crypto.randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n\n return rnds8Pool.slice(poolPtr, poolPtr += 16);\n}","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).substr(1));\n}\n\nfunction stringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import rng from './rng.js';\nimport stringify from './stringify.js';\n\nfunction v4(options, buf, offset) {\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return stringify(rnds);\n}\n\nexport default v4;"],"mappings":"qkBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,kBAAAE,KAAA,eAAAC,GAAAH,IAcA,IAAAI,EAA6E,iBCRtE,IAAMC,EAAW,CAACC,EAA4BC,IAAiB,CACpE,IAAIC,EACJ,MAAO,IAAIC,IAAoB,CAC7B,aAAaD,CAAS,EACtBA,EAAY,WAAW,IAAM,CAC3BF,EAAS,GAAGG,CAAI,CAClB,EAAGF,CAAI,CACT,CACF,ECRA,I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2B,KAAW,eACf,CAAClD,EAAYmD,EAAe,CAAC,IAAM,CACjC,GAAI,CAACzC,EACH,MAAO,CAAE,GAAAV,EAAI,IAAK,IAAK,EAEzB,IAAMoD,EAAoBpD,KAAMsC,EAC1BO,EAAQO,EAAoB9B,EAAI,QAAQ,KAAK,CAAC,CAAE,GAAI+B,CAAW,IAAMA,IAAerD,CAAE,EAAImD,EAC1FG,EAAOT,GAASA,EAAM,QAAQ,aAAU,EAE9C,OAAKO,IACH9B,EAAI,QAAU,CAAC,GAAGA,EAAI,QAAS,CAAE,GAAAtB,EAAI,IAAAsD,EAAK,OAAQH,EAAQ,MAAO,CAAC,EAClEH,EAAQ,GAEH,CAAE,GAAAhD,EAAI,IAAAsD,CAAI,CACnB,EACA,CAAC/B,CAAO,CACV,EAEMgC,KAAa,eAChBC,GAA2B,CAC1BlC,EAAI,QAAUA,EAAI,QAAQ,OAAO,CAAC,CAAE,GAAAtB,CAAG,IAAMA,IAAOwD,CAAc,CACpE,EACA,CAACjC,CAAO,CACV,EAEMkC,KAAW,eAAazD,GAAeyC,EAAc,IAAIzC,CAAE,EAAG,CAACyC,CAAa,CAAC,EAC7EiB,KAAa,WAAQ,IAAM7B,EAAiB,CAACA,CAAe,CAAC,EAE7D8B,KAAe,eAAY,IAAM,CACrC,IAAMd,EAAQvB,EAAI,QAAQ,KAAK,CAAC,CAAE,GAAAtB,CAAG,IAAMA,IAAO2B,CAAQ,EAC1D,OAAOkB,EAAQA,EAAM,IAAM,IAC7B,EAAG,CAAClB,CAAQ,CAAC,EAEb,MAAO,CACL,WAAA+B,EACA,SAAAR,EACA,WAAAK,EACA,UAAAf,EACA,SAAAiB,EACA,aAAAE,CACF,CACF","names":["useNavScroll_exports","__export","useNavScroll","__toCommonJS","import_react","debounce","callback","wait","timeoutId","args","import_react","DEFAULT_DELAY","useSizeDetector","root","isHorizontal","activeId","onChange","setForceRecompute","updateActiveId","hasWindow","targetSize","setTargetSize","useViewport","scrollEnd","debounce","observer","resizeWindowHandler","resizeElementHandler","entries","entry","import_crypto","rnds8Pool","poolPtr","rng","crypto","regex_default","validate","uuid","regex_default","validate_default","byteToHex","i","stringify","arr","offset","uuid","validate_default","stringify_default","v4","options","buf","offset","rnds","rng","i","stringify_default","v4_default","ticking","callbacks","ScrollCallback","id","callback","removeCallBack","data","cb","onDocumentScroll","evt","cbObj","newCb","v4_default","hasWindow","REGISTER_DELAY","resolveHierarchyIds","lookup","newActiveIds","lastId","useNavScroll","args","onChange","root","offset","isHorizontal","els","counter","setCounter","forceRecompute","setForceRecompute","activeId","updateActiveId","percentageValue","setPercentageValue","targetSize","useViewport","useSizeDetector","observerMargin","observerOptions","topMargin","bottomMargin","elsLookup","parent","activeIds","activeLookups","_onScroll","intersectionId","k","entry","min","totEls","refresh","debounce","register","options","alreadyRegistered","existingId","ref","unregister","idToUnregister","isActive","percentage","getActiveRef"]}
@@ -1,12 +1,69 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /*
2
+ /*--------------------------------------------------------------------------
3
3
  * This work derives from the React Use Navscroll library
4
- * Released under the MIT license by Marco Liberati
4
+ * Released under the MIT license by Marco Liberati (@dej611)
5
5
  * Code: https://github.com/dej611/react-use-navscroll
6
+ * --------------------------------------------------------------------------
7
+ * Parts of this code has been modified using Bootstrap Italia source code
8
+ * --------------------------------------------------------------------------
9
+ * Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
10
+ * Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
11
+ * License: BSD-3-Clause (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
12
+ * --------------------------------------------------------------------------
6
13
  */
7
14
  import { createRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
8
15
  import { debounce } from './debounce';
9
16
  import { useSizeDetector } from './useSizeDetector';
17
+ import { v4 as uuidv4 } from 'uuid';
18
+ let ticking = false;
19
+ let callbacks = [];
20
+ class ScrollCallback {
21
+ _callback;
22
+ id;
23
+ constructor(id, callback) {
24
+ this.id = id;
25
+ this._callback = callback;
26
+ }
27
+ //Public
28
+ dispose() {
29
+ removeCallBack(this.id);
30
+ }
31
+ //Private
32
+ _execute(data) {
33
+ this._callback(data);
34
+ }
35
+ }
36
+ const removeCallBack = (id) => {
37
+ callbacks = callbacks.filter((cb) => cb.id !== id);
38
+ };
39
+ const onDocumentScroll = (callback) => {
40
+ if (typeof document === 'undefined') {
41
+ return;
42
+ }
43
+ if (!callbacks.length) {
44
+ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
45
+ document.addEventListener('scroll', (evt) => {
46
+ if (!ticking) {
47
+ window.requestAnimationFrame(() => {
48
+ callbacks.forEach((cbObj) => cbObj.cb._execute(evt));
49
+ ticking = false;
50
+ });
51
+ ticking = true;
52
+ }
53
+ });
54
+ }
55
+ }
56
+ if (typeof callback === 'function') {
57
+ const newCb = new ScrollCallback(uuidv4(), callback);
58
+ callbacks.push({
59
+ id: newCb.id,
60
+ cb: newCb
61
+ });
62
+ return newCb;
63
+ }
64
+ console.error('[onDocumentScroll] the provided data has to be of type function');
65
+ return null;
66
+ };
10
67
  const hasWindow = typeof window !== 'undefined';
11
68
  const REGISTER_DELAY = 50;
12
69
  function resolveHierarchyIds(id, lookup) {
@@ -30,6 +87,7 @@ export function useNavScroll(args = {}) {
30
87
  const [counter, setCounter] = useState(0);
31
88
  const [forceRecompute, setForceRecompute] = useState(false);
32
89
  const [activeId, updateActiveId] = useState(null);
90
+ const [percentageValue, setPercentageValue] = useState(0);
33
91
  const { targetSize, useViewport } = useSizeDetector({
34
92
  root,
35
93
  isHorizontal,
@@ -56,24 +114,29 @@ export function useNavScroll(args = {}) {
56
114
  lookup[id] = parent;
57
115
  }
58
116
  return lookup;
59
- }, []);
117
+ }, [counter]);
60
118
  const activeIds = useMemo(() => (activeId ? resolveHierarchyIds(activeId, elsLookup) : []), [activeId, elsLookup]);
61
119
  const activeLookups = useMemo(() => new Set(activeIds), [activeIds]);
62
120
  useEffect(() => {
63
121
  if (!hasWindow) {
64
122
  return;
65
123
  }
66
- const handleIntersection = (entries) => {
124
+ const _onScroll = () => {
67
125
  let intersectionId = null;
68
- let topMin = Infinity;
69
- entries.forEach((entry) => {
70
- if (entry.isIntersecting) {
71
- if (topMin > entry.boundingClientRect.top) {
72
- topMin = entry.boundingClientRect.top;
73
- intersectionId = entry.target.id;
74
- }
126
+ for (let k = 0; k < els.current.length; k++) {
127
+ const entry = els.current[k].ref.current;
128
+ const min = entry?.getBoundingClientRect().top ? entry?.getBoundingClientRect().top : 0;
129
+ if (!min) {
130
+ break;
75
131
  }
76
- });
132
+ if (min > 0 && k > 0) {
133
+ const totEls = root?.previousSibling?.firstChild?.parentNode?.querySelectorAll('.it-navscroll-wrapper .nav-link').length ||
134
+ 1;
135
+ setPercentageValue((k / (totEls / 2)) * 100);
136
+ intersectionId = els.current[k - 1].ref.current?.id;
137
+ break;
138
+ }
139
+ }
77
140
  if (intersectionId != null) {
78
141
  updateActiveId(intersectionId);
79
142
  if (onChange) {
@@ -85,19 +148,10 @@ export function useNavScroll(args = {}) {
85
148
  }
86
149
  }
87
150
  };
88
- const observer = new IntersectionObserver(handleIntersection, observerOptions);
89
- els.current.forEach(({ ref }) => {
90
- if (ref && ref.current) {
91
- observer.observe(ref.current);
92
- }
93
- });
94
- if (forceRecompute) {
95
- handleIntersection(observer.takeRecords(), observer);
96
- setForceRecompute(false);
97
- }
98
- return () => {
99
- observer.disconnect();
100
- };
151
+ onDocumentScroll(_onScroll);
152
+ setTimeout(() => {
153
+ _onScroll();
154
+ }, 300);
101
155
  }, [
102
156
  activeIds,
103
157
  updateActiveId,
@@ -119,23 +173,25 @@ export function useNavScroll(args = {}) {
119
173
  return { id, ref: null };
120
174
  }
121
175
  const alreadyRegistered = id in elsLookup;
122
- const entry = (alreadyRegistered ? els.current.find(({ id: existingId }) => existingId === id) : options);
176
+ const entry = alreadyRegistered ? els.current.find(({ id: existingId }) => existingId === id) : options;
123
177
  const ref = (entry && entry.ref) || createRef();
124
178
  if (!alreadyRegistered) {
125
179
  els.current = [...els.current, { id, ref, parent: options.parent }];
126
180
  refresh();
127
181
  }
128
182
  return { id, ref };
129
- }, [elsLookup, refresh]);
183
+ }, [counter]);
130
184
  const unregister = useCallback((idToUnregister) => {
131
185
  els.current = els.current.filter(({ id }) => id !== idToUnregister);
132
- }, []);
186
+ }, [counter]);
133
187
  const isActive = useCallback((id) => activeLookups.has(id), [activeLookups]);
188
+ const percentage = useMemo(() => percentageValue, [percentageValue]);
134
189
  const getActiveRef = useCallback(() => {
135
190
  const entry = els.current.find(({ id }) => id === activeId);
136
191
  return entry ? entry.ref : null;
137
192
  }, [activeId]);
138
193
  return {
194
+ percentage,
139
195
  register,
140
196
  unregister,
141
197
  activeIds,
@@ -1 +1 @@
1
- {"version":3,"file":"useNavScroll.js","sourceRoot":"","sources":["../../src/NavScroll/useNavScroll.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAChD,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,SAAS,mBAAmB,CAAC,EAAU,EAAE,MAA0C;IACjF,MAAM,YAAY,GAAG,CAAC,EAAE,CAAC,CAAC;IAC1B,IAAI,MAAM,GAAuB,YAAY,CAAC,CAAC,CAAC,CAAC;IACjD,OAAO,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QAChD,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAW,CAAC,CAAC;QAC5C,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1B,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