aptechka 0.47.8 → 0.47.9
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/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +225 -221
- package/lib/scroll-H9zqFeML.cjs +1 -0
- package/lib/scroll-myLAt-Tq.js +28 -0
- package/lib/utils/index.cjs +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/scroll.d.ts +2 -2
- package/package.json +1 -1
- package/lib/scroll-DNUlcfbO.js +0 -22
- package/lib/scroll-DPDSZypW.cjs +0 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ft=(i,t)=>(t=Symbol[i])?t:Symbol.for("Symbol."+i),pt=i=>{throw TypeError(i)};var $=(i,t,s)=>t.has(i)||pt("Cannot "+s);var e=(i,t,s)=>($(i,t,"read from private field"),s?s.call(i):t.get(i)),o=(i,t,s)=>t.has(i)?pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),a=(i,t,s,r)=>($(i,t,"write to private field"),r?r.call(i,s):t.set(i,s),s),d=(i,t,s)=>($(i,t,"access private method"),s);var M=(i,t,s)=>new Promise((r,u)=>{var m=l=>{try{A(s.next(l))}catch(g){u(g)}},V=l=>{try{A(s.throw(l))}catch(g){u(g)}},A=l=>l.done?r(l.value):Promise.resolve(l.value).then(m,V);A((s=s.apply(i,t)).next())});var Et=(i,t,s)=>(t=i[ft("asyncIterator")])?t.call(i):(i=i[ft("iterator")](),t={},s=(r,u)=>(u=i[r])&&(t[r]=m=>new Promise((V,A,l)=>(m=u.call(i,m),l=m.done,Promise.resolve(m.value).then(g=>V({value:g,done:l}),A)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=require("../index-Cqw2NKev.cjs"),J=require("../events-KVanG9sR.cjs"),Tt=require("../polyfills-Df4r-ETT.cjs"),Ct=require("../scroll-DPDSZypW.cjs"),Q=require("../url-CLvdjbII.cjs"),Ht=require("../css-value-parser/index.cjs");class yt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,r]of Object.entries(t))this.setAttribute(s,r)}}St.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",yt);var R,h,T,O,q;class gt{constructor(t,s){o(this,R);o(this,h);o(this,T);o(this,O,t=>{t.preventDefault();const s=e(this,h).getAttribute("data-history-action")||"push",r=e(this,h).hasAttribute("data-center-scroll"),u=getComputedStyle(e(this,h)).getPropertyValue("--offset-scroll").trim(),m=u?Ht.cssValueParser.parse(u):void 0,V=e(this,h).hasAttribute("data-revalidate");e(this,R).navigate(e(this,T),{historyAction:s,centerScroll:r,offsetScroll:m,revalidate:V})});o(this,q,()=>{e(this,R).prefetch(e(this,T)),e(this,h).removeEventListener("pointerenter",e(this,q))});a(this,R,s),a(this,h,t),a(this,T,e(this,h).getAttribute("href")||"/"),e(this,h).addEventListener("click",e(this,O));const r=s.normalizePath(e(this,T)),u=s.normalizePath(location.pathname);e(this,h).hasAttribute("data-include")&&u.pathname.includes(r.pathname)?e(this,h).classList.add("current"):r.pathname===u.pathname&&e(this,h).classList.add("current"),e(this,h).hasAttribute("data-prefetch")&&e(this,h).addEventListener("pointerenter",e(this,q))}get element(){return e(this,h)}destroy(){e(this,h).removeEventListener("click",e(this,O)),e(this,h).removeEventListener("pointerenter",e(this,q)),e(this,h).classList.remove("current")}}R=new WeakMap,h=new WeakMap,T=new WeakMap,O=new WeakMap,q=new WeakMap;var C,z,p,H,k,w;class vt{constructor(t,s,r){o(this,C);o(this,z);o(this,p,{x:0,y:0});o(this,H);o(this,k,null);o(this,w,null);a(this,C,t),a(this,z,s),a(this,H,r.cloneNode(!0))}get pathname(){return e(this,z)}get scrollState(){return e(this,p)}get document(){return e(this,w)}cloneDocument(){a(this,w,(e(this,k)||e(this,H)).cloneNode(!0))}get title(){let t="";if(e(this,w).title)t=e(this,w).title;else{const s=e(this,w).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,z)}return t}clearScrollState(){e(this,p).x=0,e(this,p).y=0}clearDocumentState(){a(this,k,null)}saveScrollState(){e(this,H).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,p).x=0,e(this,p).y=0):(e(this,p).x=e(this,C).scrollElement.scrollLeft,e(this,p).y=e(this,C).scrollElement.scrollTop)}saveDocumentState(){e(this,H).documentElement.hasAttribute("data-no-page-restoration")?a(this,k,null):a(this,k,document.cloneNode(!0))}restoreScrollPosition(){e(this,C).scrollElement.scroll({top:e(this,p).y,left:e(this,p).x})}}C=new WeakMap,z=new WeakMap,p=new WeakMap,H=new WeakMap,k=new WeakMap,w=new WeakMap;var b,W,S,U,P,f,j,x,N,F,I,D,c,tt,et,st,Lt,it,nt,rt,X;class kt{constructor(t){o(this,c);o(this,b,null);o(this,W,null);o(this,S,[]);o(this,U,new DOMParser);o(this,P);o(this,f,null);o(this,j);o(this,x,[]);o(this,N,!1);o(this,F,null);o(this,I,new Map);o(this,D,null);o(this,X,t=>M(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(a(this,N,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,N,!1))}));if(St.isBrowser){a(this,b,{base:Q.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body"}),a(this,W,d(this,c,st).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,f,s.pathname),e(this,I).set(e(this,f),new vt(this,e(this,f),document)),document.documentElement.setAttribute("data-current-pathname",e(this,f)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,X)),Q.changeHistory({action:"replace",pathname:e(this,f),searchParameters:s.parameters,hash:s.hash}),a(this,D,new yt),d(this,c,rt).call(this,document)}}get currentPathname(){return e(this,f)}get previousPathname(){return e(this,j)}get links(){return e(this,S)}get scrollElement(){return e(this,F)}normalizePath(t){return Q.splitPath(t,{base:e(this,b).base,trailingSlash:e(this,b).trailingSlash})}prefetch(t){return M(this,null,function*(){const s=this.normalizePath(t);d(this,c,et).call(this,s.pathname)})}navigate(V){return M(this,arguments,function*(t,{historyAction:s="push",centerScroll:r,offsetScroll:u,revalidate:m}={}){if(e(this,x).length)return;const A=this.normalizePath(t);let{pathname:l,hash:g,parameters:wt,leaf:bt}=A;if(!(e(this,P)===l||e(this,f)===l)){a(this,P,l);try{let _=!0;if(this.preprocessor)try{yield new Promise((n,y)=>{var L;(L=this.preprocessor)==null||L.call(this,{pathname:l,resolve:n,reject:y})})}catch(n){n?console.error(n):console.log("Route change canceled"),_=!1}if(!_||e(this,P)!==l)return;const ot=yield d(this,c,tt).call(this,e(this,f)),v=yield d(this,c,tt).call(this,l,m);if(e(this,P)!==l)return;ot.saveScrollState(),ot.saveDocumentState(),e(this,N)||(v.clearScrollState(),v.clearDocumentState()),v.cloneDocument(),e(this,D).textContent=v.title,document.body.appendChild(e(this,D));const at={pathname:l};J.dispatchEvent(document,"morphStart",{detail:at});const lt=Array.from(document.head.children),ct=Array.from(v.document.head.children),ht=d(this,c,Lt).call(this,lt,ct),Pt=d(this,c,it).call(this,lt,ht),K=d(this,c,it).call(this,ct,ht);K.forEach((n,y)=>{if(n.tagName==="SCRIPT"&&n.getAttribute("src")){const L=document.createElement("script");L.type="module",L.src=n.getAttribute("src"),K[y]=L}}),K.forEach(n=>{document.head.appendChild(n)});const Z=K.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(d(this,c,nt).call(this,n))return!0});e(this,b).waitForHeadToLoad&&Z.length&&(yield new Promise(n=>M(this,null,function*(){let y=0;try{for(var L=Et(Z),dt,B,mt;dt=!(B=yield L.next()).done;dt=!1){const Y=B.value;Y.onload=()=>{y++,y===Z.length&&n()}}}catch(B){mt=[B]}finally{try{dt&&(B=L.return)&&(yield B.call(L))}finally{if(mt)throw mt[0]}}})));const ut=[];Pt.forEach(n=>{n.hasAttribute("data-permanent")||(d(this,c,nt).call(this,n)?ut.push(n):n.remove())});const At=d(this,c,st).call(this,v.document.body);if(d(this,c,rt).call(this,v.document),document.documentElement.setAttribute("data-current-pathname",l),document.documentElement.setAttribute("data-current-leaf",bt),Q.changeHistory({action:s,pathname:l,searchParameters:wt,hash:g}),e(this,D).remove(),a(this,j,e(this,f)),a(this,f,l),e(this,W).forEach((n,y)=>{const L=At[y],dt=getComputedStyle(n).getPropertyValue("--morph-duration"),B=[...L.childNodes];if(dt){const mt=[...n.childNodes];mt.forEach(E=>{E instanceof HTMLElement&&E.classList.add("old")}),B.forEach(E=>{E instanceof HTMLElement&&E.classList.add("new")}),n.prepend(...B),Tt.requestIdleCallback(()=>{B.forEach(E=>{E instanceof HTMLElement&&E.classList.add("in")})});const Y={morphElement:n,pathname:l};J.dispatchEvent(document,"morphNewChildrenAdded",{detail:Y});const Mt=new Promise(E=>{setTimeout(()=>{mt.forEach(G=>G.remove()),B.forEach(G=>{G instanceof HTMLElement&&G.classList.remove("in","new")}),J.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Y}),E()},(parseFloat(dt)||0)*1e3+10)});e(this,x).push(Mt)}else n.innerHTML="",n.append(...B)}),g){v.clearScrollState();const n=document.getElementById(g);n instanceof HTMLElement&&Ct.scrollToElement(n,{scrollElement:e(this,F),behaviour:"instant",center:r,offset:u})}else e(this,N)&&v.restoreScrollPosition();yield Promise.all(e(this,x)),ut.forEach(n=>n.remove()),a(this,x,[]),this.findLinks(),J.dispatchEvent(document,"morphComplete",{detail:at}),window.dispatchEvent(new Event("resize"))}catch(_){console.error(_)}a(this,P,void 0)}})}addLink(t){e(this,S).push(new gt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,S,e(this,S).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var r;return((r=s.getAttribute("href"))==null?void 0:r.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});e(this,S).forEach(s=>s.destroy()),a(this,S,t.map(s=>new gt(s,this)))}}b=new WeakMap,W=new WeakMap,S=new WeakMap,U=new WeakMap,P=new WeakMap,f=new WeakMap,j=new WeakMap,x=new WeakMap,N=new WeakMap,F=new WeakMap,I=new WeakMap,D=new WeakMap,c=new WeakSet,tt=function(t,s=!1){return M(this,null,function*(){let r=e(this,I).get(t);return(!r||s)&&(r=yield d(this,c,et).call(this,t)),r})},et=function(t){return M(this,null,function*(){const r=yield(yield fetch(t)).text(),u=e(this,U).parseFromString(r,"text/html"),m=new vt(this,t,u);return e(this,I).set(t,m),m})},st=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Lt=function(t,s){return t.filter(r=>s.find(u=>u.outerHTML===r.outerHTML))},it=function(t,s){return t.filter(r=>!s.find(u=>u.outerHTML===r.outerHTML))},nt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},rt=function(t){a(this,F,t.querySelector(e(this,b).scrollSelector)||t.documentElement)},X=new WeakMap;exports.Morph=kt;
|
|
1
|
+
"use strict";var pt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),Et=n=>{throw TypeError(n)};var $=(n,t,s)=>t.has(n)||Et("Cannot "+s);var e=(n,t,s)=>($(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?Et("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>($(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>($(n,t,"access private method"),s);var M=(n,t,s)=>new Promise((i,c)=>{var m=h=>{try{A(s.next(h))}catch(E){c(E)}},V=h=>{try{A(s.throw(h))}catch(E){c(E)}},A=h=>h.done?i(h.value):Promise.resolve(h.value).then(m,V);A((s=s.apply(n,t)).next())});var gt=(n,t,s)=>(t=n[pt("asyncIterator")])?t.call(n):(n=n[pt("iterator")](),t={},s=(i,c)=>(c=n[i])&&(t[i]=m=>new Promise((V,A,h)=>(m=c.call(n,m),h=m.done,Promise.resolve(m.value).then(E=>V({value:E,done:h}),A)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=require("../index-Cqw2NKev.cjs"),J=require("../events-KVanG9sR.cjs"),Ct=require("../polyfills-Df4r-ETT.cjs"),Ht=require("../scroll-H9zqFeML.cjs"),Q=require("../url-CLvdjbII.cjs"),kt=require("../css-value-parser/index.cjs");class wt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(t))this.setAttribute(s,i)}}St.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",wt);var R,u,T,O,q;class vt{constructor(t,s){o(this,R);o(this,u);o(this,T);o(this,O,t=>{t.preventDefault();const s=e(this,u).getAttribute("data-history-action")||"push",i=e(this,u).hasAttribute("data-center-scroll"),c=getComputedStyle(e(this,u)).getPropertyValue("--offset-scroll").trim(),m=c?kt.cssValueParser.parse(c):void 0,V=e(this,u).hasAttribute("data-revalidate");e(this,R).navigate(e(this,T),{historyAction:s,centerScroll:i,offsetScroll:m,revalidate:V})});o(this,q,()=>{e(this,R).prefetch(e(this,T)),e(this,u).removeEventListener("pointerenter",e(this,q))});a(this,R,s),a(this,u,t),a(this,T,e(this,u).getAttribute("href")||"/"),e(this,u).addEventListener("click",e(this,O));const i=s.normalizePath(e(this,T)),c=s.normalizePath(location.pathname);e(this,u).hasAttribute("data-include")&&c.pathname.includes(i.pathname)?e(this,u).classList.add("current"):i.pathname===c.pathname&&e(this,u).classList.add("current"),e(this,u).hasAttribute("data-prefetch")&&e(this,u).addEventListener("pointerenter",e(this,q))}get element(){return e(this,u)}destroy(){e(this,u).removeEventListener("click",e(this,O)),e(this,u).removeEventListener("pointerenter",e(this,q)),e(this,u).classList.remove("current")}}R=new WeakMap,u=new WeakMap,T=new WeakMap,O=new WeakMap,q=new WeakMap;var C,z,p,H,k,L;class yt{constructor(t,s,i){o(this,C);o(this,z);o(this,p,{x:0,y:0});o(this,H);o(this,k,null);o(this,L,null);a(this,C,t),a(this,z,s),a(this,H,i.cloneNode(!0))}get pathname(){return e(this,z)}get scrollState(){return e(this,p)}get document(){return e(this,L)}cloneDocument(){a(this,L,(e(this,k)||e(this,H)).cloneNode(!0))}get title(){let t="";if(e(this,L).title)t=e(this,L).title;else{const s=e(this,L).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,z)}return t}clearScrollState(){e(this,p).x=0,e(this,p).y=0}clearDocumentState(){a(this,k,null)}saveScrollState(){e(this,H).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,p).x=0,e(this,p).y=0):(e(this,p).x=e(this,C).scrollElement.scrollLeft,e(this,p).y=e(this,C).scrollElement.scrollTop)}saveDocumentState(){e(this,H).documentElement.hasAttribute("data-no-page-restoration")?a(this,k,null):a(this,k,document.cloneNode(!0))}restoreScrollPosition(){e(this,C).scrollElement.scroll({top:e(this,p).y,left:e(this,p).x})}}C=new WeakMap,z=new WeakMap,p=new WeakMap,H=new WeakMap,k=new WeakMap,L=new WeakMap;var b,W,y,U,P,f,j,x,N,F,I,D,l,tt,et,st,Lt,it,nt,rt,ot,X;class xt{constructor(t){o(this,l);o(this,b,null);o(this,W,null);o(this,y,[]);o(this,U,new DOMParser);o(this,P);o(this,f,null);o(this,j);o(this,x,[]);o(this,N,!1);o(this,F,null);o(this,I,new Map);o(this,D,null);o(this,X,t=>M(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(a(this,N,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,N,!1))}));if(St.isBrowser){a(this,b,{base:Q.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body"}),a(this,W,d(this,l,st).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,f,s.pathname),e(this,I).set(e(this,f),new yt(this,e(this,f),document)),document.documentElement.setAttribute("data-current-pathname",e(this,f)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,X)),Q.changeHistory({action:"replace",pathname:e(this,f),searchParameters:s.parameters,hash:s.hash}),a(this,D,new wt),d(this,l,rt).call(this,document)}}get currentPathname(){return e(this,f)}get previousPathname(){return e(this,j)}get links(){return e(this,y)}get scrollElement(){return e(this,F)}normalizePath(t){return Q.splitPath(t,{base:e(this,b).base,trailingSlash:e(this,b).trailingSlash})}prefetch(t){return M(this,null,function*(){const s=this.normalizePath(t);d(this,l,et).call(this,s.pathname)})}navigate(V){return M(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:c,revalidate:m}={}){if(e(this,x).length)return;const A=this.normalizePath(t);let{pathname:h,hash:E,parameters:bt,leaf:Pt}=A;if(e(this,P)===h||e(this,f)===h){d(this,l,ot).call(this,E||0,{centerScroll:i,offsetScroll:c,behavior:"smooth"});return}a(this,P,h);try{let _=!0;if(this.preprocessor)try{yield new Promise((r,S)=>{var w;(w=this.preprocessor)==null||w.call(this,{pathname:h,resolve:r,reject:S})})}catch(r){r?console.error(r):console.log("Route change canceled"),_=!1}if(!_||e(this,P)!==h)return;const at=yield d(this,l,tt).call(this,e(this,f)),v=yield d(this,l,tt).call(this,h,m);if(e(this,P)!==h)return;at.saveScrollState(),at.saveDocumentState(),e(this,N)||(v.clearScrollState(),v.clearDocumentState()),v.cloneDocument(),e(this,D).textContent=v.title,document.body.appendChild(e(this,D));const lt={pathname:h};J.dispatchEvent(document,"morphStart",{detail:lt});const ht=Array.from(document.head.children),ct=Array.from(v.document.head.children),ut=d(this,l,Lt).call(this,ht,ct),At=d(this,l,it).call(this,ht,ut),K=d(this,l,it).call(this,ct,ut);K.forEach((r,S)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const w=document.createElement("script");w.type="module",w.src=r.getAttribute("src"),K[S]=w}}),K.forEach(r=>{document.head.appendChild(r)});const Z=K.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,l,nt).call(this,r))return!0});e(this,b).waitForHeadToLoad&&Z.length&&(yield new Promise(r=>M(this,null,function*(){let S=0;try{for(var w=gt(Z),mt,B,ft;mt=!(B=yield w.next()).done;mt=!1){const Y=B.value;Y.onload=()=>{S++,S===Z.length&&r()}}}catch(B){ft=[B]}finally{try{mt&&(B=w.return)&&(yield B.call(w))}finally{if(ft)throw ft[0]}}})));const dt=[];At.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,l,nt).call(this,r)?dt.push(r):r.remove())});const Mt=d(this,l,st).call(this,v.document.body);d(this,l,rt).call(this,v.document),document.documentElement.setAttribute("data-current-pathname",h),document.documentElement.setAttribute("data-current-leaf",Pt),Q.changeHistory({action:s,pathname:h,searchParameters:bt,hash:E}),e(this,D).remove(),a(this,j,e(this,f)),a(this,f,h),e(this,W).forEach((r,S)=>{const w=Mt[S],mt=getComputedStyle(r).getPropertyValue("--morph-duration"),B=[...w.childNodes];if(mt){const ft=[...r.childNodes];ft.forEach(g=>{g instanceof HTMLElement&&g.classList.add("old")}),B.forEach(g=>{g instanceof HTMLElement&&g.classList.add("new")}),r.prepend(...B),Ct.requestIdleCallback(()=>{B.forEach(g=>{g instanceof HTMLElement&&g.classList.add("in")})});const Y={morphElement:r,pathname:h};J.dispatchEvent(document,"morphNewChildrenAdded",{detail:Y});const Tt=new Promise(g=>{setTimeout(()=>{ft.forEach(G=>G.remove()),B.forEach(G=>{G instanceof HTMLElement&&G.classList.remove("in","new")}),J.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Y}),g()},(parseFloat(mt)||0)*1e3+10)});e(this,x).push(Tt)}else r.innerHTML="",r.append(...B)}),E?(v.clearScrollState(),d(this,l,ot).call(this,E,{centerScroll:i,offsetScroll:c})):e(this,N)&&v.restoreScrollPosition(),yield Promise.all(e(this,x)),dt.forEach(r=>r.remove()),a(this,x,[]),this.findLinks(),J.dispatchEvent(document,"morphComplete",{detail:lt}),window.dispatchEvent(new Event("resize"))}catch(_){console.error(_)}a(this,P,void 0)})}addLink(t){e(this,y).push(new vt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,y,e(this,y).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var i;return((i=s.getAttribute("href"))==null?void 0:i.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});e(this,y).forEach(s=>s.destroy()),a(this,y,t.map(s=>new vt(s,this)))}}b=new WeakMap,W=new WeakMap,y=new WeakMap,U=new WeakMap,P=new WeakMap,f=new WeakMap,j=new WeakMap,x=new WeakMap,N=new WeakMap,F=new WeakMap,I=new WeakMap,D=new WeakMap,l=new WeakSet,tt=function(t,s=!1){return M(this,null,function*(){let i=e(this,I).get(t);return(!i||s)&&(i=yield d(this,l,et).call(this,t)),i})},et=function(t){return M(this,null,function*(){const i=yield(yield fetch(t)).text(),c=e(this,U).parseFromString(i,"text/html"),m=new yt(this,t,c);return e(this,I).set(t,m),m})},st=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Lt=function(t,s){return t.filter(i=>s.find(c=>c.outerHTML===i.outerHTML))},it=function(t,s){return t.filter(i=>!s.find(c=>c.outerHTML===i.outerHTML))},nt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},rt=function(t){a(this,F,t.querySelector(e(this,b).scrollSelector)||t.documentElement)},ot=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ht.scrollToElement(i,{scrollElement:e(this,F),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},X=new WeakMap;exports.Morph=xt;
|
package/lib/morph/index.js
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var ft = (n, t) => (t = Symbol[n]) ? t : Symbol.for("Symbol." + n), pt = (n) => {
|
|
2
|
+
throw TypeError(n);
|
|
3
3
|
};
|
|
4
|
-
var _ = (
|
|
5
|
-
var e = (
|
|
6
|
-
var
|
|
7
|
-
var m = (
|
|
4
|
+
var _ = (n, t, s) => t.has(n) || pt("Cannot " + s);
|
|
5
|
+
var e = (n, t, s) => (_(n, t, "read from private field"), s ? s.call(n) : t.get(n)), o = (n, t, s) => t.has(n) ? pt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s), a = (n, t, s, i) => (_(n, t, "write to private field"), i ? i.call(n, s) : t.set(n, s), s), d = (n, t, s) => (_(n, t, "access private method"), s);
|
|
6
|
+
var T = (n, t, s) => new Promise((i, c) => {
|
|
7
|
+
var m = (h) => {
|
|
8
8
|
try {
|
|
9
|
-
A(s.next(
|
|
10
|
-
} catch (
|
|
11
|
-
|
|
9
|
+
A(s.next(h));
|
|
10
|
+
} catch (E) {
|
|
11
|
+
c(E);
|
|
12
12
|
}
|
|
13
|
-
}, V = (
|
|
13
|
+
}, V = (h) => {
|
|
14
14
|
try {
|
|
15
|
-
A(s.throw(
|
|
16
|
-
} catch (
|
|
17
|
-
|
|
15
|
+
A(s.throw(h));
|
|
16
|
+
} catch (E) {
|
|
17
|
+
c(E);
|
|
18
18
|
}
|
|
19
|
-
}, A = (
|
|
20
|
-
A((s = s.apply(
|
|
19
|
+
}, A = (h) => h.done ? i(h.value) : Promise.resolve(h.value).then(m, V);
|
|
20
|
+
A((s = s.apply(n, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var
|
|
23
|
-
import { i as
|
|
22
|
+
var Et = (n, t, s) => (t = n[ft("asyncIterator")]) ? t.call(n) : (n = n[ft("iterator")](), t = {}, s = (i, c) => (c = n[i]) && (t[i] = (m) => new Promise((V, A, h) => (m = c.call(n, m), h = m.done, Promise.resolve(m.value).then((E) => V({ value: E, done: h }), A)))), s("next"), s("return"), t);
|
|
23
|
+
import { i as yt } from "../index-euf5anj6.js";
|
|
24
24
|
import { d as Q } from "../events-CsVF98U6.js";
|
|
25
|
-
import { r as
|
|
26
|
-
import { s as
|
|
27
|
-
import { n as
|
|
28
|
-
import { cssValueParser as
|
|
29
|
-
class
|
|
25
|
+
import { r as Mt } from "../polyfills-DJrTJQky.js";
|
|
26
|
+
import { s as Ht } from "../scroll-myLAt-Tq.js";
|
|
27
|
+
import { n as kt, c as gt, s as xt } from "../url-CfcHdBT6.js";
|
|
28
|
+
import { cssValueParser as Nt } from "../css-value-parser/index.js";
|
|
29
|
+
class Lt extends HTMLElement {
|
|
30
30
|
connectedCallback() {
|
|
31
31
|
const t = {
|
|
32
32
|
"aria-live": "assertive",
|
|
33
33
|
"aria-atomic": "true",
|
|
34
34
|
style: "position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"
|
|
35
35
|
};
|
|
36
|
-
for (const [s,
|
|
37
|
-
this.setAttribute(s,
|
|
36
|
+
for (const [s, i] of Object.entries(t))
|
|
37
|
+
this.setAttribute(s, i);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
var R,
|
|
42
|
-
class
|
|
40
|
+
yt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Lt);
|
|
41
|
+
var R, u, C, O, z;
|
|
42
|
+
class vt {
|
|
43
43
|
constructor(t, s) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
o(this, R);
|
|
45
|
+
o(this, u);
|
|
46
|
+
o(this, C);
|
|
47
|
+
o(this, O, (t) => {
|
|
48
48
|
t.preventDefault();
|
|
49
|
-
const s = e(this,
|
|
49
|
+
const s = e(this, u).getAttribute(
|
|
50
50
|
"data-history-action"
|
|
51
|
-
) || "push",
|
|
52
|
-
e(this, R).navigate(e(this,
|
|
51
|
+
) || "push", i = e(this, u).hasAttribute("data-center-scroll"), c = getComputedStyle(e(this, u)).getPropertyValue("--offset-scroll").trim(), m = c ? Nt.parse(c) : void 0, V = e(this, u).hasAttribute("data-revalidate");
|
|
52
|
+
e(this, R).navigate(e(this, C), {
|
|
53
53
|
historyAction: s,
|
|
54
|
-
centerScroll:
|
|
54
|
+
centerScroll: i,
|
|
55
55
|
offsetScroll: m,
|
|
56
56
|
revalidate: V
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
|
-
|
|
60
|
-
e(this, R).prefetch(e(this,
|
|
59
|
+
o(this, z, () => {
|
|
60
|
+
e(this, R).prefetch(e(this, C)), e(this, u).removeEventListener("pointerenter", e(this, z));
|
|
61
61
|
});
|
|
62
|
-
a(this, R, s), a(this,
|
|
63
|
-
const
|
|
64
|
-
e(this,
|
|
62
|
+
a(this, R, s), a(this, u, t), a(this, C, e(this, u).getAttribute("href") || "/"), e(this, u).addEventListener("click", e(this, O));
|
|
63
|
+
const i = s.normalizePath(e(this, C)), c = s.normalizePath(location.pathname);
|
|
64
|
+
e(this, u).hasAttribute("data-include") && c.pathname.includes(i.pathname) ? e(this, u).classList.add("current") : i.pathname === c.pathname && e(this, u).classList.add("current"), e(this, u).hasAttribute("data-prefetch") && e(this, u).addEventListener("pointerenter", e(this, z));
|
|
65
65
|
}
|
|
66
66
|
get element() {
|
|
67
|
-
return e(this,
|
|
67
|
+
return e(this, u);
|
|
68
68
|
}
|
|
69
69
|
destroy() {
|
|
70
|
-
e(this,
|
|
70
|
+
e(this, u).removeEventListener("click", e(this, O)), e(this, u).removeEventListener("pointerenter", e(this, z)), e(this, u).classList.remove("current");
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
R = new WeakMap(),
|
|
74
|
-
var
|
|
75
|
-
class
|
|
76
|
-
constructor(t, s,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
a(this,
|
|
73
|
+
R = new WeakMap(), u = new WeakMap(), C = new WeakMap(), O = new WeakMap(), z = new WeakMap();
|
|
74
|
+
var M, q, p, H, k, w;
|
|
75
|
+
class St {
|
|
76
|
+
constructor(t, s, i) {
|
|
77
|
+
o(this, M);
|
|
78
|
+
o(this, q);
|
|
79
|
+
o(this, p, { x: 0, y: 0 });
|
|
80
|
+
o(this, H);
|
|
81
|
+
o(this, k, null);
|
|
82
|
+
o(this, w, null);
|
|
83
|
+
a(this, M, t), a(this, q, s), a(this, H, i.cloneNode(!0));
|
|
84
84
|
}
|
|
85
85
|
get pathname() {
|
|
86
86
|
return e(this, q);
|
|
@@ -89,17 +89,17 @@ class Lt {
|
|
|
89
89
|
return e(this, p);
|
|
90
90
|
}
|
|
91
91
|
get document() {
|
|
92
|
-
return e(this,
|
|
92
|
+
return e(this, w);
|
|
93
93
|
}
|
|
94
94
|
cloneDocument() {
|
|
95
|
-
a(this,
|
|
95
|
+
a(this, w, (e(this, k) || e(this, H)).cloneNode(!0));
|
|
96
96
|
}
|
|
97
97
|
get title() {
|
|
98
98
|
let t = "";
|
|
99
|
-
if (e(this,
|
|
100
|
-
t = e(this,
|
|
99
|
+
if (e(this, w).title)
|
|
100
|
+
t = e(this, w).title;
|
|
101
101
|
else {
|
|
102
|
-
const s = e(this,
|
|
102
|
+
const s = e(this, w).querySelector("h1");
|
|
103
103
|
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, q);
|
|
104
104
|
}
|
|
105
105
|
return t;
|
|
@@ -113,7 +113,7 @@ class Lt {
|
|
|
113
113
|
saveScrollState() {
|
|
114
114
|
e(this, H).documentElement.hasAttribute(
|
|
115
115
|
"data-no-scroll-restoration"
|
|
116
|
-
) ? (e(this, p).x = 0, e(this, p).y = 0) : (e(this, p).x = e(this,
|
|
116
|
+
) ? (e(this, p).x = 0, e(this, p).y = 0) : (e(this, p).x = e(this, M).scrollElement.scrollLeft, e(this, p).y = e(this, M).scrollElement.scrollTop);
|
|
117
117
|
}
|
|
118
118
|
saveDocumentState() {
|
|
119
119
|
e(this, H).documentElement.hasAttribute(
|
|
@@ -121,59 +121,59 @@ class Lt {
|
|
|
121
121
|
) ? a(this, k, null) : a(this, k, document.cloneNode(!0));
|
|
122
122
|
}
|
|
123
123
|
restoreScrollPosition() {
|
|
124
|
-
e(this,
|
|
124
|
+
e(this, M).scrollElement.scroll({
|
|
125
125
|
top: e(this, p).y,
|
|
126
126
|
left: e(this, p).x
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
var b, W, S, U, P, f, j, x, N, F, I, D,
|
|
132
|
-
class
|
|
130
|
+
M = new WeakMap(), q = new WeakMap(), p = new WeakMap(), H = new WeakMap(), k = new WeakMap(), w = new WeakMap();
|
|
131
|
+
var b, W, S, U, P, f, j, x, N, F, I, D, l, $, tt, et, wt, st, it, nt, rt, X;
|
|
132
|
+
class Bt {
|
|
133
133
|
constructor(t) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
134
|
+
o(this, l);
|
|
135
|
+
o(this, b, null);
|
|
136
|
+
o(this, W, null);
|
|
137
|
+
o(this, S, []);
|
|
138
|
+
o(this, U, new DOMParser());
|
|
139
|
+
o(this, P);
|
|
140
|
+
o(this, f, null);
|
|
141
|
+
o(this, j);
|
|
142
|
+
o(this, x, []);
|
|
143
|
+
o(this, N, !1);
|
|
144
|
+
o(this, F, null);
|
|
145
|
+
o(this, I, /* @__PURE__ */ new Map());
|
|
146
|
+
o(this, D, null);
|
|
147
|
+
o(this, X, (t) => T(this, null, function* () {
|
|
148
148
|
var s;
|
|
149
149
|
(s = t.state) != null && s.path && (a(this, N, !0), yield this.navigate(t.state.path, { historyAction: "none" }), a(this, N, !1));
|
|
150
150
|
}));
|
|
151
|
-
if (
|
|
151
|
+
if (yt) {
|
|
152
152
|
a(this, b, {
|
|
153
|
-
base:
|
|
153
|
+
base: kt(t == null ? void 0 : t.base),
|
|
154
154
|
waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
|
|
155
155
|
cachePages: (t == null ? void 0 : t.cachePages) !== !1,
|
|
156
156
|
trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
|
|
157
157
|
scrollSelector: (t == null ? void 0 : t.scrollSelector) || "body"
|
|
158
|
-
}), a(this, W, d(this,
|
|
158
|
+
}), a(this, W, d(this, l, et).call(this, document.body));
|
|
159
159
|
const s = this.normalizePath(
|
|
160
160
|
location.pathname + location.hash
|
|
161
161
|
);
|
|
162
162
|
a(this, f, s.pathname), e(this, I).set(
|
|
163
163
|
e(this, f),
|
|
164
|
-
new
|
|
164
|
+
new St(this, e(this, f), document)
|
|
165
165
|
), document.documentElement.setAttribute(
|
|
166
166
|
"data-current-pathname",
|
|
167
167
|
e(this, f)
|
|
168
168
|
), document.documentElement.setAttribute(
|
|
169
169
|
"data-current-leaf",
|
|
170
170
|
s.leaf
|
|
171
|
-
), this.findLinks(), addEventListener("popstate", e(this, X)),
|
|
171
|
+
), this.findLinks(), addEventListener("popstate", e(this, X)), gt({
|
|
172
172
|
action: "replace",
|
|
173
173
|
pathname: e(this, f),
|
|
174
174
|
searchParameters: s.parameters,
|
|
175
175
|
hash: s.hash
|
|
176
|
-
}), a(this, D, new
|
|
176
|
+
}), a(this, D, new Lt()), d(this, l, nt).call(this, document);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
get currentPathname() {
|
|
@@ -189,156 +189,152 @@ class Vt {
|
|
|
189
189
|
return e(this, F);
|
|
190
190
|
}
|
|
191
191
|
normalizePath(t) {
|
|
192
|
-
return
|
|
192
|
+
return xt(t, {
|
|
193
193
|
base: e(this, b).base,
|
|
194
194
|
trailingSlash: e(this, b).trailingSlash
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
prefetch(t) {
|
|
198
|
-
return
|
|
198
|
+
return T(this, null, function* () {
|
|
199
199
|
const s = this.normalizePath(t);
|
|
200
|
-
d(this,
|
|
200
|
+
d(this, l, tt).call(this, s.pathname);
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
navigate(V) {
|
|
204
|
-
return
|
|
204
|
+
return T(this, arguments, function* (t, {
|
|
205
205
|
historyAction: s = "push",
|
|
206
|
-
centerScroll:
|
|
207
|
-
offsetScroll:
|
|
206
|
+
centerScroll: i,
|
|
207
|
+
offsetScroll: c,
|
|
208
208
|
revalidate: m
|
|
209
209
|
} = {}) {
|
|
210
210
|
if (e(this, x).length)
|
|
211
211
|
return;
|
|
212
212
|
const A = this.normalizePath(t);
|
|
213
|
-
let { pathname:
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
213
|
+
let { pathname: h, hash: E, parameters: bt, leaf: Pt } = A;
|
|
214
|
+
if (e(this, P) === h || e(this, f) === h) {
|
|
215
|
+
d(this, l, rt).call(this, E || 0, {
|
|
216
|
+
centerScroll: i,
|
|
217
|
+
offsetScroll: c,
|
|
218
|
+
behavior: "smooth"
|
|
219
|
+
});
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
a(this, P, h);
|
|
223
|
+
try {
|
|
224
|
+
let K = !0;
|
|
225
|
+
if (this.preprocessor)
|
|
226
|
+
try {
|
|
227
|
+
yield new Promise((r, y) => {
|
|
228
|
+
var L;
|
|
229
|
+
(L = this.preprocessor) == null || L.call(this, {
|
|
230
|
+
pathname: h,
|
|
231
|
+
resolve: r,
|
|
232
|
+
reject: y
|
|
227
233
|
});
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
234
|
+
});
|
|
235
|
+
} catch (r) {
|
|
236
|
+
r ? console.error(r) : console.log("Route change canceled"), K = !1;
|
|
237
|
+
}
|
|
238
|
+
if (!K || e(this, P) !== h)
|
|
239
|
+
return;
|
|
240
|
+
const ot = yield d(this, l, $).call(this, e(this, f)), v = yield d(this, l, $).call(this, h, m);
|
|
241
|
+
if (e(this, P) !== h)
|
|
242
|
+
return;
|
|
243
|
+
ot.saveScrollState(), ot.saveDocumentState(), e(this, N) || (v.clearScrollState(), v.clearDocumentState()), v.cloneDocument(), e(this, D).textContent = v.title, document.body.appendChild(e(this, D));
|
|
244
|
+
const at = {
|
|
245
|
+
pathname: h
|
|
246
|
+
};
|
|
247
|
+
Q(document, "morphStart", {
|
|
248
|
+
detail: at
|
|
249
|
+
});
|
|
250
|
+
const lt = Array.from(document.head.children), ht = Array.from(v.document.head.children), ct = d(this, l, wt).call(this, lt, ht), At = d(this, l, st).call(this, lt, ct), Y = d(this, l, st).call(this, ht, ct);
|
|
251
|
+
Y.forEach((r, y) => {
|
|
252
|
+
if (r.tagName === "SCRIPT" && r.getAttribute("src")) {
|
|
253
|
+
const L = document.createElement("script");
|
|
254
|
+
L.type = "module", L.src = r.getAttribute("src"), Y[y] = L;
|
|
255
|
+
}
|
|
256
|
+
}), Y.forEach((r) => {
|
|
257
|
+
document.head.appendChild(r);
|
|
258
|
+
});
|
|
259
|
+
const Z = Y.filter((r) => {
|
|
260
|
+
if (r.hasAttribute("data-no-waiting"))
|
|
261
|
+
return !1;
|
|
262
|
+
if (d(this, l, it).call(this, r))
|
|
263
|
+
return !0;
|
|
264
|
+
});
|
|
265
|
+
e(this, b).waitForHeadToLoad && Z.length && (yield new Promise((r) => T(this, null, function* () {
|
|
266
|
+
let y = 0;
|
|
267
|
+
try {
|
|
268
|
+
for (var L = Et(Z), dt, B, mt; dt = !(B = yield L.next()).done; dt = !1) {
|
|
269
|
+
const G = B.value;
|
|
270
|
+
G.onload = () => {
|
|
271
|
+
y++, y === Z.length && r();
|
|
272
|
+
};
|
|
248
273
|
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
const Z = Y.filter((n) => {
|
|
253
|
-
if (n.hasAttribute("data-no-waiting"))
|
|
254
|
-
return !1;
|
|
255
|
-
if (d(this, h, it).call(this, n))
|
|
256
|
-
return !0;
|
|
257
|
-
});
|
|
258
|
-
e(this, b).waitForHeadToLoad && Z.length && (yield new Promise((n) => M(this, null, function* () {
|
|
259
|
-
let v = 0;
|
|
274
|
+
} catch (B) {
|
|
275
|
+
mt = [B];
|
|
276
|
+
} finally {
|
|
260
277
|
try {
|
|
261
|
-
|
|
262
|
-
const G = B.value;
|
|
263
|
-
G.onload = () => {
|
|
264
|
-
v++, v === Z.length && n();
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
} catch (B) {
|
|
268
|
-
dt = [B];
|
|
278
|
+
dt && (B = L.return) && (yield B.call(L));
|
|
269
279
|
} finally {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
} finally {
|
|
273
|
-
if (dt)
|
|
274
|
-
throw dt[0];
|
|
275
|
-
}
|
|
280
|
+
if (mt)
|
|
281
|
+
throw mt[0];
|
|
276
282
|
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
283
|
+
}
|
|
284
|
+
})));
|
|
285
|
+
const ut = [];
|
|
286
|
+
At.forEach((r) => {
|
|
287
|
+
r.hasAttribute("data-permanent") || (d(this, l, it).call(this, r) ? ut.push(r) : r.remove());
|
|
288
|
+
});
|
|
289
|
+
const Tt = d(this, l, et).call(this, v.document.body);
|
|
290
|
+
d(this, l, nt).call(this, v.document), document.documentElement.setAttribute("data-current-pathname", h), document.documentElement.setAttribute("data-current-leaf", Pt), gt({
|
|
291
|
+
action: s,
|
|
292
|
+
pathname: h,
|
|
293
|
+
searchParameters: bt,
|
|
294
|
+
hash: E
|
|
295
|
+
}), e(this, D).remove(), a(this, j, e(this, f)), a(this, f, h), e(this, W).forEach((r, y) => {
|
|
296
|
+
const L = Tt[y], dt = getComputedStyle(r).getPropertyValue("--morph-duration"), B = [...L.childNodes];
|
|
297
|
+
if (dt) {
|
|
298
|
+
const mt = [...r.childNodes];
|
|
299
|
+
mt.forEach((g) => {
|
|
300
|
+
g instanceof HTMLElement && g.classList.add("old");
|
|
301
|
+
}), B.forEach((g) => {
|
|
302
|
+
g instanceof HTMLElement && g.classList.add("new");
|
|
303
|
+
}), r.prepend(...B), Mt(() => {
|
|
304
|
+
B.forEach((g) => {
|
|
305
|
+
g instanceof HTMLElement && g.classList.add("in");
|
|
300
306
|
});
|
|
301
|
-
const G = {
|
|
302
|
-
morphElement: n,
|
|
303
|
-
pathname: l
|
|
304
|
-
};
|
|
305
|
-
Q(document, "morphNewChildrenAdded", {
|
|
306
|
-
detail: G
|
|
307
|
-
});
|
|
308
|
-
const Mt = new Promise((E) => {
|
|
309
|
-
setTimeout(() => {
|
|
310
|
-
dt.forEach((J) => J.remove()), B.forEach((J) => {
|
|
311
|
-
J instanceof HTMLElement && J.classList.remove("in", "new");
|
|
312
|
-
}), Q(document, "morphOldChildrenRemoved", {
|
|
313
|
-
detail: G
|
|
314
|
-
}), E();
|
|
315
|
-
}, (parseFloat(ut) || 0) * 1e3 + 10);
|
|
316
|
-
});
|
|
317
|
-
e(this, x).push(Mt);
|
|
318
|
-
} else
|
|
319
|
-
n.innerHTML = "", n.append(...B);
|
|
320
|
-
}), g) {
|
|
321
|
-
L.clearScrollState();
|
|
322
|
-
const n = document.getElementById(g);
|
|
323
|
-
n instanceof HTMLElement && Ct(n, {
|
|
324
|
-
scrollElement: e(this, F),
|
|
325
|
-
behaviour: "instant",
|
|
326
|
-
center: o,
|
|
327
|
-
offset: u
|
|
328
307
|
});
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
308
|
+
const G = {
|
|
309
|
+
morphElement: r,
|
|
310
|
+
pathname: h
|
|
311
|
+
};
|
|
312
|
+
Q(document, "morphNewChildrenAdded", {
|
|
313
|
+
detail: G
|
|
314
|
+
});
|
|
315
|
+
const Ct = new Promise((g) => {
|
|
316
|
+
setTimeout(() => {
|
|
317
|
+
mt.forEach((J) => J.remove()), B.forEach((J) => {
|
|
318
|
+
J instanceof HTMLElement && J.classList.remove("in", "new");
|
|
319
|
+
}), Q(document, "morphOldChildrenRemoved", {
|
|
320
|
+
detail: G
|
|
321
|
+
}), g();
|
|
322
|
+
}, (parseFloat(dt) || 0) * 1e3 + 10);
|
|
323
|
+
});
|
|
324
|
+
e(this, x).push(Ct);
|
|
325
|
+
} else
|
|
326
|
+
r.innerHTML = "", r.append(...B);
|
|
327
|
+
}), E ? (v.clearScrollState(), d(this, l, rt).call(this, E, { centerScroll: i, offsetScroll: c })) : e(this, N) && v.restoreScrollPosition(), yield Promise.all(e(this, x)), ut.forEach((r) => r.remove()), a(this, x, []), this.findLinks(), Q(document, "morphComplete", {
|
|
328
|
+
detail: at
|
|
329
|
+
}), window.dispatchEvent(new Event("resize"));
|
|
330
|
+
} catch (K) {
|
|
331
|
+
console.error(K);
|
|
337
332
|
}
|
|
333
|
+
a(this, P, void 0);
|
|
338
334
|
});
|
|
339
335
|
}
|
|
340
336
|
addLink(t) {
|
|
341
|
-
e(this, S).push(new
|
|
337
|
+
e(this, S).push(new vt(t, this));
|
|
342
338
|
}
|
|
343
339
|
addLinks(t) {
|
|
344
340
|
t.forEach((s) => {
|
|
@@ -353,21 +349,21 @@ class Vt {
|
|
|
353
349
|
...document.documentElement.querySelectorAll("a")
|
|
354
350
|
].filter(
|
|
355
351
|
(s) => {
|
|
356
|
-
var
|
|
357
|
-
return ((
|
|
352
|
+
var i;
|
|
353
|
+
return ((i = s.getAttribute("href")) == null ? void 0 : i.startsWith("/")) && !s.hasAttribute("download") && !s.hasAttribute("data-morph-skip") && !s.closest("[data-morph-skip]");
|
|
358
354
|
}
|
|
359
355
|
);
|
|
360
|
-
e(this, S).forEach((s) => s.destroy()), a(this, S, t.map((s) => new
|
|
356
|
+
e(this, S).forEach((s) => s.destroy()), a(this, S, t.map((s) => new vt(s, this)));
|
|
361
357
|
}
|
|
362
358
|
}
|
|
363
|
-
b = new WeakMap(), W = new WeakMap(), S = new WeakMap(), U = new WeakMap(), P = new WeakMap(), f = new WeakMap(), j = new WeakMap(), x = new WeakMap(), N = new WeakMap(), F = new WeakMap(), I = new WeakMap(), D = new WeakMap(),
|
|
364
|
-
return
|
|
365
|
-
let
|
|
366
|
-
return (!
|
|
359
|
+
b = new WeakMap(), W = new WeakMap(), S = new WeakMap(), U = new WeakMap(), P = new WeakMap(), f = new WeakMap(), j = new WeakMap(), x = new WeakMap(), N = new WeakMap(), F = new WeakMap(), I = new WeakMap(), D = new WeakMap(), l = new WeakSet(), $ = function(t, s = !1) {
|
|
360
|
+
return T(this, null, function* () {
|
|
361
|
+
let i = e(this, I).get(t);
|
|
362
|
+
return (!i || s) && (i = yield d(this, l, tt).call(this, t)), i;
|
|
367
363
|
});
|
|
368
364
|
}, tt = function(t) {
|
|
369
|
-
return
|
|
370
|
-
const
|
|
365
|
+
return T(this, null, function* () {
|
|
366
|
+
const i = yield (yield fetch(t)).text(), c = e(this, U).parseFromString(i, "text/html"), m = new St(this, t, c);
|
|
371
367
|
return e(this, I).set(t, m), m;
|
|
372
368
|
});
|
|
373
369
|
}, et = function(t) {
|
|
@@ -375,21 +371,29 @@ b = new WeakMap(), W = new WeakMap(), S = new WeakMap(), U = new WeakMap(), P =
|
|
|
375
371
|
return s.length ? s : [t];
|
|
376
372
|
}, wt = function(t, s) {
|
|
377
373
|
return t.filter(
|
|
378
|
-
(
|
|
379
|
-
(
|
|
374
|
+
(i) => s.find(
|
|
375
|
+
(c) => c.outerHTML === i.outerHTML
|
|
380
376
|
)
|
|
381
377
|
);
|
|
382
378
|
}, st = function(t, s) {
|
|
383
379
|
return t.filter(
|
|
384
|
-
(
|
|
385
|
-
(
|
|
380
|
+
(i) => !s.find(
|
|
381
|
+
(c) => c.outerHTML === i.outerHTML
|
|
386
382
|
)
|
|
387
383
|
);
|
|
388
384
|
}, it = function(t) {
|
|
389
385
|
return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
|
|
390
386
|
}, nt = function(t) {
|
|
391
387
|
a(this, F, t.querySelector(e(this, b).scrollSelector) || t.documentElement);
|
|
388
|
+
}, rt = function(t, s) {
|
|
389
|
+
const i = typeof t == "string" ? document.getElementById(t) : t;
|
|
390
|
+
(typeof i == "number" || i) && Ht(i, {
|
|
391
|
+
scrollElement: e(this, F),
|
|
392
|
+
behavior: (s == null ? void 0 : s.behavior) || "instant",
|
|
393
|
+
center: s == null ? void 0 : s.centerScroll,
|
|
394
|
+
offset: s == null ? void 0 : s.offsetScroll
|
|
395
|
+
});
|
|
392
396
|
}, X = new WeakMap();
|
|
393
397
|
export {
|
|
394
|
-
|
|
398
|
+
Bt as Morph
|
|
395
399
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const f=require("./dom-JBOkFLTh.cjs"),m=require("./layout-Ctc2p3uz.cjs");require("./index-Cqw2NKev.cjs");function g(n,{behavior:u="instant",offset:o=0,center:c=!1,scrollElement:l}={}){var r;let t,i=l,s=l;if(typeof n=="number")t=n;else{const e=f.getElement(n);e&&(i=e,s=l||f.findScrollParentElement(e),t=m.getCumulativeOffsetTop(e))}if(i&&s&&typeof t=="number"){const e=(typeof o=="number"?o:((r=f.getElement(o))==null?void 0:r.offsetHeight)||0)*-1,a=c?innerHeight/2*-1+i.offsetHeight/2:0;s.scroll({top:t+e+a,behavior:u})}}exports.scrollToElement=g;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { g as l, f as c } from "./dom-CVWzyXPH.js";
|
|
2
|
+
import { a as g } from "./layout-DpZo-I0y.js";
|
|
3
|
+
import "./index-euf5anj6.js";
|
|
4
|
+
function E(n, {
|
|
5
|
+
behavior: m = "instant",
|
|
6
|
+
offset: o = 0,
|
|
7
|
+
center: p = !1,
|
|
8
|
+
scrollElement: f
|
|
9
|
+
} = {}) {
|
|
10
|
+
var a;
|
|
11
|
+
let e, i = f, s = f;
|
|
12
|
+
if (typeof n == "number")
|
|
13
|
+
e = n;
|
|
14
|
+
else {
|
|
15
|
+
const t = l(n);
|
|
16
|
+
t && (i = t, s = f || c(t), e = g(t));
|
|
17
|
+
}
|
|
18
|
+
if (i && s && typeof e == "number") {
|
|
19
|
+
const t = (typeof o == "number" ? o : ((a = l(o)) == null ? void 0 : a.offsetHeight) || 0) * -1, r = p ? innerHeight / 2 * -1 + i.offsetHeight / 2 : 0;
|
|
20
|
+
s.scroll({
|
|
21
|
+
top: e + t + r,
|
|
22
|
+
behavior: m
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
E as s
|
|
28
|
+
};
|
package/lib/utils/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../attributes-Bf2svn4j.cjs"),y=require("../index-Cqw2NKev.cjs"),d=require("../canvas-CU5Xjahf.cjs"),g=require("../coordinates-D8Np3cPD.cjs"),p=require("../dom-JBOkFLTh.cjs"),r=require("../easings-GegIwET5.cjs"),q=require("../events-KVanG9sR.cjs"),C=require("../file-DSpfWdd9.cjs"),I=require("../function-MthRj-GJ.cjs"),w=require("../gestures-DHLrn6Q8.cjs"),O=require("../jss-B_mh4mIw.cjs"),m=require("../layout-Ctc2p3uz.cjs"),i=require("../math-GDWEqu7y.cjs"),f=require("../number-0243DApo.cjs"),c=require("../object-CCiXnER2.cjs"),T=require("../polyfills-Df4r-ETT.cjs"),Q=require("../scroll-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../attributes-Bf2svn4j.cjs"),y=require("../index-Cqw2NKev.cjs"),d=require("../canvas-CU5Xjahf.cjs"),g=require("../coordinates-D8Np3cPD.cjs"),p=require("../dom-JBOkFLTh.cjs"),r=require("../easings-GegIwET5.cjs"),q=require("../events-KVanG9sR.cjs"),C=require("../file-DSpfWdd9.cjs"),I=require("../function-MthRj-GJ.cjs"),w=require("../gestures-DHLrn6Q8.cjs"),O=require("../jss-B_mh4mIw.cjs"),m=require("../layout-Ctc2p3uz.cjs"),i=require("../math-GDWEqu7y.cjs"),f=require("../number-0243DApo.cjs"),c=require("../object-CCiXnER2.cjs"),T=require("../polyfills-Df4r-ETT.cjs"),Q=require("../scroll-H9zqFeML.cjs"),l=require("../string-DhgS_iFl.cjs"),S=require("../style-At6aDoqG.cjs"),u=require("../url-CLvdjbII.cjs");function B(t,e,...n){return[...t.slice(0,e),...n,...t.slice(e)]}function D(t,e){const n=t.length;e=e%n;const o=new Array(n);for(let s=0;s<n;s++){const a=(s+e)%n;o[a]=t[s]}return o}function A(t,e=2){if(!+t)return"0 Bytes";const n=1024,o=e<0?0:e,s=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],a=Math.floor(Math.log(t)/Math.log(n));return`${parseFloat((t/Math.pow(n,a)).toFixed(o))} ${s[a]}`}function R(t){if(navigator.clipboard)navigator.clipboard.writeText(t).then(()=>{console.log("Text copied to clipboard successfully!")}).catch(e=>{console.error("Failed to copy text to clipboard:",e)});else{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.top="0",e.style.left="0",document.body.appendChild(e),e.select();try{document.execCommand("copy")?console.log("Text copied to clipboard successfully!"):console.error("Failed to copy text to clipboard.")}catch(n){console.error("Failed to copy text to clipboard:",n)}document.body.removeChild(e)}}function N(t,e){return t.x<e.x+e.width&&t.x>e.x&&t.y<e.y+e.height&&t.y>e.y}function z(t,e){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)<e.radius}function x(t,e){const n=t.style.getPropertyValue(e);if(n){const o=n.toString();return o.startsWith("var")?x(t,o.slice(4,-1)):o}}function M(...t){const e={};return Array.from(document.styleSheets).forEach(n=>{Array.from(n.cssRules).forEach(o=>{o instanceof CSSStyleRule&&o.selectorText===":root"&&t.forEach(s=>{const a=x(o,s);a&&(e[s]=a)})})}),t.forEach(n=>{e[n]||console.warn(`variable named ${n} not found`)}),e}function j(t){const e=window.atob(t);return decodeURIComponent(window.escape(e))}function k(t){const e=window.unescape(encodeURIComponent(t));return window.btoa(e)}function V(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}function U(t,e){if(t){const o=t.content.cloneNode(!0).firstElementChild;return o&&(e==null||e(o)),o}return null}function F(t,e,n,o){let s,a=!1,b=0;const v=()=>{clearInterval(s),o!=null&&o.restartCounter&&(b=0),a&&(s=setInterval(()=>{n(b++)},e))},E=y.intersector.subscribe(t,P=>{a=P.isIntersecting,v()});return()=>{E(),clearInterval(s)}}exports.parseAttribute=h.parseAttribute;exports.parseAttributeValue=h.parseAttributeValue;exports.isBrowser=y.isBrowser;exports.contain=d.contain;exports.cover=d.cover;exports.fixPosition=d.fixPosition;exports.measureText=d.measureText;exports.getPointerPosition=g.getPointerPosition;exports.normalize=g.normalize;exports.screenToCartesian=g.screenToCartesian;exports.findParentElement=p.findParentElement;exports.findScrollParentElement=p.findScrollParentElement;exports.getAllParentElements=p.getAllParentElements;exports.getElement=p.getElement;exports.easeInCubic=r.easeInCubic;exports.easeInExpo=r.easeInExpo;exports.easeInOutCubic=r.easeInOutCubic;exports.easeInOutExpo=r.easeInOutExpo;exports.easeInOutQuad=r.easeInOutQuad;exports.easeInOutQuart=r.easeInOutQuart;exports.easeInOutQuint=r.easeInOutQuint;exports.easeInQuad=r.easeInQuad;exports.easeInQuart=r.easeInQuart;exports.easeInQuint=r.easeInQuint;exports.easeOutCubic=r.easeOutCubic;exports.easeOutExpo=r.easeOutExpo;exports.easeOutQuad=r.easeOutQuad;exports.easeOutQuart=r.easeOutQuart;exports.easeOutQuint=r.easeOutQuint;exports.linear=r.linear;exports.dispatchEvent=q.dispatchEvent;exports.createJSONAndSave=C.createJSONAndSave;exports.downloadURI=C.downloadURI;exports.debounce=I.debounce;exports.throttle=I.throttle;exports.setupDrag=w.setupDrag;exports.createStylesheet=O.createStylesheet;exports.styleToString=O.styleToString;exports.getCumulativeOffsetLeft=m.getCumulativeOffsetLeft;exports.getCumulativeOffsetTop=m.getCumulativeOffsetTop;exports.getCumulativePosition=m.getCumulativePosition;exports.getStickyOffset=m.getStickyOffset;exports.calculateDistance=i.calculateDistance;exports.calculateDistanceWithRadius=i.calculateDistanceWithRadius;exports.clamp=i.clamp;exports.damp=i.damp;exports.lerp=i.lerp;exports.mapRange=i.mapRange;exports.round=i.round;exports.smootherstep=i.smootherstep;exports.smoothstep=i.smoothstep;exports.step=i.step;exports.loopNumber=f.loopNumber;exports.preciseNumber=f.preciseNumber;exports.roundNumberTo=f.roundNumberTo;exports.toStep=f.toStep;exports.cloneDeep=c.cloneDeep;exports.compareObjects=c.compareObjects;exports.isESClass=c.isESClass;exports.isNullish=c.isNullish;exports.isObject=c.isObject;exports.mergeDeep=c.mergeDeep;exports.mixin=c.mixin;exports.omit=c.omit;exports.pick=c.pick;exports.nullishCoalescing=T.nullishCoalescing;exports.requestIdleCallback=T.requestIdleCallback;exports.scrollToElement=Q.scrollToElement;exports.camelToKebab=l.camelToKebab;exports.capitalize=l.capitalize;exports.generateId=l.generateId;exports.isUppercase=l.isUppercase;exports.kebabToCamel=l.kebabToCamel;exports.snakeToDotted=l.snakeToDotted;exports.toPascalCase=l.toPascalCase;exports.uncapitalize=l.uncapitalize;exports.getElementTransitionDurationMS=S.getElementTransitionDurationMS;exports.getElementTransitionDurationS=S.getElementTransitionDurationS;exports.changeHistory=u.changeHistory;exports.normalizeBase=u.normalizeBase;exports.parseSearchParameters=u.parseSearchParameters;exports.splitPath=u.splitPath;exports.updateSearchParameter=u.updateSearchParameter;exports.cloneTemplateContent=U;exports.copyTextToClipboard=R;exports.decode=k;exports.dotCircleCollision=z;exports.dotRectCollision=N;exports.encode=j;exports.formatBytes=A;exports.getRootVariables=M;exports.insert=B;exports.setIntervalOnIntersection=F;exports.shiftArray=D;exports.wait=V;
|
package/lib/utils/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { e as Oe, f as Pe, c as Be, d as Ae, l as Qe, m as Re, r as De, b as Me,
|
|
|
15
15
|
import { l as Ve, p as je, r as ke, t as Ue } from "../number-DwCxt_Ck.js";
|
|
16
16
|
import { c as $e, d as Ke, i as We, b as Ge, a as He, m as Je, e as Le, o as Ye, p as Ze } from "../object-D6MVWB4l.js";
|
|
17
17
|
import { n as _e, r as et } from "../polyfills-DJrTJQky.js";
|
|
18
|
-
import { s as at } from "../scroll-
|
|
18
|
+
import { s as at } from "../scroll-myLAt-Tq.js";
|
|
19
19
|
import { c as ot, a as rt, g as nt, i as it, k as ct, s as lt, t as ut, u as ft } from "../string-f0Dnk0L1.js";
|
|
20
20
|
import { g as dt, a as mt } from "../style-j2TwriJ_.js";
|
|
21
21
|
import { c as gt, n as bt, p as ht, s as yt, u as Ct } from "../url-CfcHdBT6.js";
|
package/lib/utils/scroll.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ElementOrSelector } from '.';
|
|
2
|
-
export declare function scrollToElement(
|
|
3
|
-
|
|
2
|
+
export declare function scrollToElement(elementOrSelectorOrNumber: ElementOrSelector<HTMLElement> | number, { behavior, offset, center, scrollElement, }?: {
|
|
3
|
+
behavior?: ScrollBehavior;
|
|
4
4
|
offset?: number | ElementOrSelector<HTMLElement>;
|
|
5
5
|
center?: boolean;
|
|
6
6
|
scrollElement?: HTMLElement;
|
package/package.json
CHANGED
package/lib/scroll-DNUlcfbO.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { g as s, f as p } from "./dom-CVWzyXPH.js";
|
|
2
|
-
import { a as g } from "./layout-DpZo-I0y.js";
|
|
3
|
-
import "./index-euf5anj6.js";
|
|
4
|
-
function H(l, {
|
|
5
|
-
behaviour: i = "instant",
|
|
6
|
-
offset: e = 0,
|
|
7
|
-
center: r = !1,
|
|
8
|
-
scrollElement: f
|
|
9
|
-
} = {}) {
|
|
10
|
-
var n;
|
|
11
|
-
const t = s(l);
|
|
12
|
-
if (t) {
|
|
13
|
-
const o = f || p(t), a = g(t), m = (typeof e == "number" ? e : ((n = s(e)) == null ? void 0 : n.offsetHeight) || 0) * -1, c = r ? innerHeight / 2 * -1 + t.offsetHeight / 2 : 0;
|
|
14
|
-
o == null || o.scroll({
|
|
15
|
-
top: a + m + c,
|
|
16
|
-
behavior: i
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
H as s
|
|
22
|
-
};
|
package/lib/scroll-DPDSZypW.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const o=require("./dom-JBOkFLTh.cjs"),a=require("./layout-Ctc2p3uz.cjs");require("./index-Cqw2NKev.cjs");function g(s,{behaviour:r="instant",offset:t=0,center:c=!1,scrollElement:i}={}){var l;const e=o.getElement(s);if(e){const n=i||o.findScrollParentElement(e),u=a.getCumulativeOffsetTop(e),f=(typeof t=="number"?t:((l=o.getElement(t))==null?void 0:l.offsetHeight)||0)*-1,m=c?innerHeight/2*-1+e.offsetHeight/2:0;n==null||n.scroll({top:u+f+m,behavior:r})}}exports.scrollToElement=g;
|