aptechka 0.74.1 → 0.74.2
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 +41 -43
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ae=Object.defineProperty,ne=Object.defineProperties;var re=Object.getOwnPropertyDescriptors;var Xt=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var Yt=(o,e)=>(e=Symbol[o])?e:Symbol.for("Symbol."+o),Kt=o=>{throw TypeError(o)};var jt=(o,e,i)=>e in o?ae(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,St=(o,e)=>{for(var i in e||(e={}))oe.call(e,i)&&jt(o,i,e[i]);if(Xt)for(var i of Xt(e))le.call(e,i)&&jt(o,i,e[i]);return o},Pt=(o,e)=>ne(o,re(e));var Ct=(o,e,i)=>e.has(o)||Kt("Cannot "+i);var t=(o,e,i)=>(Ct(o,e,"read from private field"),i?i.call(o):e.get(o)),l=(o,e,i)=>e.has(o)?Kt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(o):e.set(o,i),r=(o,e,i,s)=>(Ct(o,e,"write to private field"),s?s.call(o,i):e.set(o,i),i),p=(o,e,i)=>(Ct(o,e,"access private method"),i);var W=(o,e,i)=>new Promise((s,h)=>{var v=d=>{try{L(i.next(d))}catch(E){h(E)}},g=d=>{try{L(i.throw(d))}catch(E){h(E)}},L=d=>d.done?s(d.value):Promise.resolve(d.value).then(v,g);L((i=i.apply(o,e)).next())});var $t=(o,e,i)=>(e=o[Yt("asyncIterator")])?e.call(o):(o=o[Yt("iterator")](),e={},i=(s,h)=>(h=o[s])&&(e[s]=v=>new Promise((g,L,d)=>(v=h.call(o,v),d=v.done,Promise.resolve(v.value).then(E=>g({value:E,done:d}),L)))),i("next"),i("return"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Qt=require("../index-DekP7OZe.cjs"),M=require("../events-KVanG9sR.cjs"),Gt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const nt=require("../url-DGcX4fGV.cjs"),he=require("../css-value-parser/index.cjs");class Zt extends HTMLElement{connectedCallback(){const e={"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[i,s]of Object.entries(e))this.setAttribute(i,s)}}Qt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Zt);var P,a,I,J,bt,ot,Q;class Ht{constructor(e,i){l(this,J);l(this,P);l(this,a);l(this,I);l(this,ot,e=>{var s;if(e.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(t(this,a).hasAttribute("data-back")&&t(this,P).previousURL)history.back();else{r(this,I,t(this,a).getAttribute("href")||"/");const h=t(this,a).getAttribute("data-history-action")||"push",v=t(this,a).hasAttribute("data-center-scroll"),g=getComputedStyle(t(this,a)).getPropertyValue("--offset-scroll").trim(),L=g?he.cssValueParser.parse(g):void 0,d=t(this,a).hasAttribute("data-revalidate")||t(this,a).hasAttribute("data-pagination-more-link")||t(this,a).hasAttribute("data-pagination-set-link"),E=t(this,a).hasAttribute("data-keep-search-parameters"),mt=t(this,a).hasAttribute("data-keep-scroll-position")||t(this,a).hasAttribute("data-pagination-more-link");console.log(mt);const at=t(this,a).getAttribute("data-scroll-behaviour"),ft=p(this,J,bt).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));ft&&(t(this,a).hasAttribute("data-pagination-set-link")?t(this,P).links.forEach(U=>{U.updatePagination(parseInt(t(this,a).getAttribute("data-value")||"1"),ft.selector)}):t(this,a).hasAttribute("data-pagination-more-link")&&t(this,P).links.forEach(U=>{U.updatePagination(ft.currentPage+1,ft.selector)}));const pt=((s=t(this,a).getAttribute("data-submorph"))==null?void 0:s.split(",").map(U=>U.trim()))||t(this,a).hasAttribute("data-pagination-more-link")&&[t(this,a).getAttribute("data-pagination-more-link")]||t(this,a).hasAttribute("data-pagination-set-link")&&[t(this,a).getAttribute("data-pagination-set-link")]||void 0,c=t(this,a).hasAttribute("data-clear-state");t(this,P).navigate(t(this,I),{historyAction:h,centerScroll:v,offsetScroll:L,revalidate:d,keepSearchParameters:E,submorph:pt,clearState:c,keepScrollPosition:mt,scrollBehaviour:at,submorphAppend:t(this,a).hasAttribute("data-pagination-more-link")})}});l(this,Q,()=>{const e=t(this,a).hasAttribute("data-revalidate");t(this,P).prefetch(t(this,I),e),t(this,a).removeEventListener("pointerenter",t(this,Q))});r(this,P,i),r(this,a,e),t(this,a).addEventListener("click",t(this,ot)),r(this,I,t(this,a).getAttribute("href")||"/"),this.checkCurrent(location.href.replace(location.origin,""));const s=p(this,J,bt).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));s&&this.updatePagination(s.currentPage,s.selector),t(this,a).hasAttribute("data-prefetch")&&t(this,a).addEventListener("pointerenter",t(this,Q))}get element(){return t(this,a)}checkCurrent(e){var h;const i=t(this,P).normalizePath(e),s=t(this,P).normalizePath(t(this,I));t(this,a).hasAttribute("data-include")&&i.pathname.includes(s.pathname)?t(this,a).classList.add("current"):s.pathname===i.pathname?t(this,a).classList.add("current"):(h=t(this,a).getAttribute("data-associated-paths"))!=null&&h.split(",").find(v=>i.pathname.includes(v))?t(this,a).classList.add("current"):t(this,a).classList.remove("current"),i.path===s.path?t(this,a).classList.add("exact"):t(this,a).classList.remove("exact")}updatePagination(e,i){const s=p(this,J,bt).call(this,i);if(s)if(s.element.setAttribute("data-current-page",e.toString()),t(this,a).hasAttribute("data-pagination-more-link"))if(e<s.totalPages){t(this,a).style.display="";const h=t(this,a).querySelector("[data-pagination-more-link-counter]");h&&(h.textContent=(s.totalPages-e).toString());const v=t(this,a).getAttribute("href"),g=new URL(v,window.location.origin);g.searchParams.set("page",(e+1).toString());const L=g.href.replace(g.origin,"").toString();t(this,a).setAttribute("href",L),this.checkCurrent(L)}else t(this,a).style.display="none";else t(this,a).hasAttribute("data-pagination-set-link")&&(t(this,a).getAttribute("data-value")===e.toString()?t(this,a).classList.add("pagination-current"):t(this,a).classList.remove("pagination-current"))}destroy(){t(this,a).removeEventListener("click",t(this,ot)),t(this,a).removeEventListener("pointerenter",t(this,Q)),t(this,a).classList.remove("current","exact","pagination-current")}}P=new WeakMap,a=new WeakMap,I=new WeakMap,J=new WeakSet,bt=function(e){if(!e)return;const i=document.querySelector(e);if(i){const s=parseInt(i.getAttribute("data-current-page")||"1"),h=parseInt(i.getAttribute("data-total-pages")||"1");return{element:i,currentPage:s,totalPages:h,selector:e}}},ot=new WeakMap,Q=new WeakMap;const ce=new DOMParser;var T,X,A,x,Y,z,Z,j,V,lt;class Jt{constructor(e,i){l(this,T);l(this,X);l(this,A,{x:0,y:0});l(this,x,null);l(this,Y,null);l(this,z,null);l(this,Z,null);l(this,j,null);l(this,V,null);l(this,lt);r(this,T,e),r(this,X,i)}get pathname(){return t(this,X)}get scrollState(){return t(this,A)}get document(){return t(this,z)}setHeaders(e){r(this,lt,e)}setInitialDocument(e){r(this,x,e.cloneNode(!0))}abort(){var e;return(e=t(this,j))==null?void 0:e.abort(`[${t(this,X)}] page loading cancelled`)}fetch(e,i,s){return W(this,null,function*(){var h;if(!s){const L=((h=t(this,x))==null?void 0:h.documentElement.getAttribute("data-cache"))&&i!==e,d=t(this,x)&&t(this,T).isPopstateNavigation;if(t(this,V)||L||d)return t(this,V)}return r(this,V,new Promise(v=>W(this,null,function*(){try{r(this,j,new AbortController);const L=yield(yield fetch(e,{signal:t(this,j).signal,headers:St({"X-MORPH":"true","X-MORPH-CURRENT-PATH":encodeURIComponent(i),"X-MORPH-NEW-PATH":encodeURIComponent(e)},t(this,lt))})).text(),d=ce.parseFromString(L,"text/html");this.setInitialDocument(d)}catch(g){console.warn(g)}finally{r(this,j,null),r(this,V,null),v()}}))),t(this,V)})}cloneDocument(){r(this,z,(t(this,Y)||t(this,x)).cloneNode(!0))}get title(){let e="";if(t(this,z).title)e=t(this,z).title;else{const i=t(this,z).querySelector("h1");e=(i==null?void 0:i.innerText)||(i==null?void 0:i.textContent)||t(this,X)}return e}clearScrollState(){t(this,A).x=0,t(this,A).y=0}clearDocumentState(){r(this,Y,null)}saveScrollState(){t(this,x).documentElement.hasAttribute("data-no-scroll-restoration")?(t(this,A).x=0,t(this,A).y=0):(t(this,A).x=t(this,T).scrollValue.left,t(this,A).y=t(this,T).scrollValue.top)}restoreScrollPosition(){t(this,T).scrollElement.scroll({top:t(this,A).y,left:t(this,A).x,behavior:"instant"})}saveDocumentState(){t(this,x).documentElement.hasAttribute("data-no-page-restoration")?r(this,Y,null):r(this,Y,document.cloneNode(!0))}renewScrollPosition(){t(this,T).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(e){r(this,Z,e)}clearState(){const e=t(this,Z);return r(this,Z,null),e}}T=new WeakMap,X=new WeakMap,A=new WeakMap,x=new WeakMap,Y=new WeakMap,z=new WeakMap,Z=new WeakMap,j=new WeakMap,V=new WeakMap,lt=new WeakMap;var R,_,y,O,f,K,F,B,C,ht,N,$,tt,et,ct,it,ut,m,Mt,dt,Lt,Tt,_t,xt,Nt,Ut,qt,yt,st;const rt=class rt{constructor(e){l(this,m);l(this,R,null);l(this,_,null);l(this,y,[]);l(this,O);l(this,f,null);l(this,K);l(this,F,[]);l(this,B,!1);l(this,C,null);l(this,ht,!1);l(this,N,new Map);l(this,$,null);l(this,tt,0);l(this,et,0);l(this,ct);l(this,it);l(this,ut);l(this,dt,e=>{var i;return((i=e.getAttribute("href"))==null?void 0:i.startsWith("/"))&&!e.hasAttribute("download")&&!e.hasAttribute("data-morph-skip")&&!e.closest("[data-morph-skip]")&&e.getAttribute("target")!=="_blank"});l(this,yt,e=>W(this,null,function*(){e.preventDefault(),r(this,B,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:t(this,it)?void 0:t(this,ct),revalidate:t(this,it),keepScrollPosition:t(this,ut)}),r(this,B,!1)}));l(this,st,()=>{const{left:e,top:i}=this.scrollValue,s=i-t(this,et),h=e-t(this,tt);r(this,et,i),r(this,tt,e),document.documentElement.classList.toggle("scroll-y",i>0),document.documentElement.classList.toggle("scroll-x",e>0),document.documentElement.classList.toggle("scroll-y-forward",s>0),document.documentElement.classList.toggle("scroll-y-backward",s<0),document.documentElement.classList.toggle("scroll-x-forward",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),M.dispatchEvent(document,"morphScroll",{detail:{left:e,top:i}})});if(Qt.isBrowser&&!rt.instance){rt.instance=this,r(this,R,{base:nt.normalizeBase(e==null?void 0:e.base),waitForHeadToLoad:(e==null?void 0:e.waitForHeadToLoad)!==!1,trailingSlash:(e==null?void 0:e.trailingSlash)||!1,scrollSelector:e==null?void 0:e.scrollSelector,morphInsideScrollContainer:(e==null?void 0:e.morphInsideScrollContainer)||!1}),r(this,_,p(this,m,Tt).call(this,document.body));const i=this.normalizePath(location.pathname+location.search+location.hash);r(this,f,i);const s=new Jt(this,t(this,f).pathname);s.setInitialDocument(document),t(this,N).set(t(this,f).pathname,s),document.documentElement.setAttribute("data-current-pathname",t(this,f).pathname),document.documentElement.setAttribute("data-current-leaf",i.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",t(this,yt)),nt.changeHistory({action:"replace",pathname:i.pathname,searchParameters:i.parameters,hash:i.hash}),r(this,$,new Zt),p(this,m,Ut).call(this,document)}}get currentURL(){return t(this,f)}get previousURL(){return t(this,K)}get links(){return t(this,y)}get scrollElement(){return t(this,C)}get isPopstateNavigation(){return t(this,B)}get scrollValue(){let e=0,i=0;return t(this,ht)?(e=window.scrollY,i=window.scrollX):(e=t(this,C).scrollTop,i=t(this,C).scrollLeft),{top:e,left:i}}saveState(e){const i=t(this,N).get(t(this,f).path);i&&i.saveState(e)}getState(){const e=t(this,N).get(t(this,f).path);return e==null?void 0:e.clearState()}normalizePath(e){return nt.splitPath(e,{base:t(this,R).base,trailingSlash:t(this,R).trailingSlash})}prefetch(e,i){return W(this,null,function*(){var h;if(t(this,F).length)return;e=((h=this.pathnameModifier)==null?void 0:h.call(this,e))||e;const s=p(this,m,Lt).call(this,e);s==null||s.fetch(e,t(this,f).path,i)})}excludeHeadChild(e){return!1}setHeaders(e){}navigate(ft){return W(this,arguments,function*(e,{historyAction:i="push",centerScroll:s,offsetScroll:h,scrollBehaviour:v,revalidate:g,keepSearchParameters:L,submorph:d,submorphAppend:E,clearState:mt,keepScrollPosition:at}={}){var U,Dt,It,zt;if(t(this,F).length)return;r(this,ct,d),r(this,it,g),r(this,ut,at);const pt=((U=this.pathnameModifier)==null?void 0:U.call(this,e))||e,c=this.normalizePath(pt);if(t(this,y).forEach(G=>{G.checkCurrent(c.path)}),!g&&(((Dt=t(this,O))==null?void 0:Dt.pathname)===c.pathname||t(this,f).pathname===c.pathname)){at||p(this,m,qt).call(this,c.hash||0,{centerScroll:s,offsetScroll:h,behavior:"smooth"}),M.dispatchEvent(document,"morphSamePath",{custom:!0}),((It=t(this,f))==null?void 0:It.parameters)!==c.parameters&&(r(this,K,t(this,f)),r(this,f,c),nt.changeHistory({action:((zt=t(this,f))==null?void 0:zt.hash)!==c.hash?"replace":i,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),M.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:t(this,f),previousURL:t(this,K)}}));return}r(this,O,c);try{let G=!0;if(this.preprocessor)try{yield new Promise((n,w)=>{var k;(k=this.preprocessor)==null||k.call(this,{url:c,resolve:n,reject:w,submorph:d})})}catch(n){n?console.error(n):console.log("Route change canceled"),G=!1}if(!G||t(this,O).pathname!==c.pathname){t(this,y).forEach(n=>{n.checkCurrent(t(this,f).path)});return}const Vt={url:c,submorph:d};d?E||d.forEach(n=>{document.querySelectorAll(n).forEach(w=>{w.classList.add("out"),w.setAttribute("data-morph-out","")})}):t(this,_).forEach(n=>{var w,k;(w=n.firstElementChild)==null||w.classList.add("out"),(k=n.firstElementChild)==null||k.setAttribute("data-morph-out","")}),M.dispatchEvent(document,"morphNavigation",{detail:Vt});const wt=p(this,m,Lt).call(this,t(this,f).pathname),S=p(this,m,Lt).call(this,c.pathname);if(t(this,N).forEach(n=>{n.pathname!==c.pathname&&n.abort()}),yield S==null?void 0:S.fetch(pt,t(this,f).path,g),t(this,O).pathname!==c.pathname){t(this,y).forEach(n=>{n.checkCurrent(t(this,f).path)});return}wt.clearState(),wt.saveScrollState(),wt.saveDocumentState(),(!t(this,B)||g)&&(S.clearScrollState(),S.clearDocumentState()),mt&&S.clearState(),S.cloneDocument(),t(this,$).textContent=S.title,document.body.appendChild(t(this,$));const gt=Pt(St({},Vt),{document:S.document});E||gt.document.querySelectorAll("[data-morph-out]").forEach(n=>{n.classList.remove("out")}),M.dispatchEvent(document,"morphStart",{detail:gt});const Ot=Array.from(document.head.children),Ft=Array.from(S.document.head.children),Bt=p(this,m,_t).call(this,Ot,Ft),te=p(this,m,xt).call(this,Ot,Bt),Et=p(this,m,xt).call(this,Ft,Bt).filter(n=>!this.excludeHeadChild(n));Et.forEach((n,w)=>{n.tagName==="SCRIPT"&&(Et[w]=p(this,m,Mt).call(this,n))}),Et.forEach(n=>{document.head.appendChild(n)});const At=Et.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(p(this,m,Nt).call(this,n))return!0});t(this,R).waitForHeadToLoad&&At.length&&(yield new Promise(n=>W(this,null,function*(){let w=0;try{for(var k=$t(At),ie,q,H;ie=!(q=yield k.next()).done;ie=!1){const vt=q.value;vt.onload=()=>{w++,w===At.length&&n()}}}catch(q){H=[q]}finally{try{ie&&(q=k.return)&&(yield q.call(k))}finally{if(H)throw H[0]}}}))),yield Gt.wait(10);const Wt=[];E||te.forEach(n=>{n.hasAttribute("data-permanent")||(p(this,m,Nt).call(this,n)?Wt.push(n):n.remove())});const ee=p(this,m,Tt).call(this,S.document.body);!t(this,R).morphInsideScrollContainer&&!d&&p(this,m,Ut).call(this,S.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),nt.changeHistory({action:i,pathname:c.pathname,searchParameters:c.parameters||(L?location.search:""),hash:c.hash}),t(this,$).remove(),r(this,K,t(this,f)),r(this,f,c);const kt=[];t(this,_).forEach((n,w)=>{const k=ee[w],ie=getComputedStyle(n).getPropertyValue("--morph-duration");let q=[],H=[];d?(d.forEach(u=>{const b=n.querySelector(u),D=k.querySelector(u);b&&D&&(H.push(b),q.push(D))}),H.forEach(u=>{u.parentElement&&kt.push(u.parentElement)})):(q.push(...k.childNodes),H.push(...n.childNodes),kt.push(n)),E||H.forEach(u=>{u instanceof HTMLElement&&(this.destroyOldLinks(u),u.classList.add("old"))}),q.forEach(u=>{u instanceof HTMLElement&&(this.findNewLinks(u),u.classList.add("new"))}),d?E?q.forEach((u,b)=>{H[b]instanceof HTMLElement&&H[b].append(...u.childNodes)}):q.forEach((u,b)=>{var D;(D=H[b].parentElement)==null||D.insertBefore(u,H[b])}):n.prepend(...q),setTimeout(()=>{E||H.forEach(u=>{u instanceof HTMLElement&&u.classList.add("old-idle")}),q.forEach(u=>{var b;u instanceof HTMLElement&&((b=u.parentElement)==null||b.style.setProperty("--new-content-height",u.offsetHeight+"px"),u.classList.add("new-idle"))})},0);const vt=Pt(St({},gt),{morphElement:n});M.dispatchEvent(document,"morphNewChildrenAdded",{detail:vt});const se=new Promise(u=>{setTimeout(()=>{E||H.forEach(b=>b.remove()),q.forEach(b=>{var D;b instanceof HTMLElement&&((D=b.parentElement)==null||D.style.removeProperty("--new-content-height"),b.classList.remove("new-idle","new"))}),E||M.dispatchEvent(document,"morphOldChildrenRemoved",{detail:vt}),u()},(parseFloat(ie)||0)*1e3+10)});t(this,F).push(se)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-S.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),M.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:S.scrollState}),c.hash?(S.clearScrollState(),p(this,m,qt).call(this,c.hash,{centerScroll:s,offsetScroll:h,behavior:v})):t(this,B)?S.restoreScrollPosition():at||S.renewScrollPosition(),yield Promise.all(t(this,F)),E||Wt.forEach(n=>n.remove()),r(this,F,[]),kt.forEach(n=>{n.querySelectorAll("script").forEach(k=>{k.replaceWith(p(this,m,Mt).call(this,k))})}),t(this,y).forEach(n=>{n.checkCurrent(t(this,f).path)}),M.dispatchEvent(document,"morphComplete",{detail:gt}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(G){console.error(G)}r(this,O,void 0)})}addLink(e){t(this,y).push(new Ht(e,this))}addLinks(e){e.forEach(i=>{this.addLink(i)})}removeLink(e){r(this,y,t(this,y).filter(i=>i.element===e?(i.destroy(),!1):!0))}destroyOldLinks(e){r(this,y,t(this,y).filter(i=>e.contains(i.element)?(i.destroy(),!1):!0))}findNewLinks(e){const i=[...e.querySelectorAll("a")].filter(t(this,dt));t(this,y).push(...i.map(s=>new Ht(s,this)))}findLinks(){const e=[...document.documentElement.querySelectorAll("a")].filter(t(this,dt));t(this,y).forEach(i=>i.destroy()),r(this,y,e.map(i=>new Ht(i,this)))}};R=new WeakMap,_=new WeakMap,y=new WeakMap,O=new WeakMap,f=new WeakMap,K=new WeakMap,F=new WeakMap,B=new WeakMap,C=new WeakMap,ht=new WeakMap,N=new WeakMap,$=new WeakMap,tt=new WeakMap,et=new WeakMap,ct=new WeakMap,it=new WeakMap,ut=new WeakMap,m=new WeakSet,Mt=function(e){const i=document.createElement("script");for(let s=0;s<e.attributes.length;s++){const h=e.attributes[s];i.setAttribute(h.name,h.value)}return e.hasAttribute("src")||(i.innerHTML=e.innerHTML),i},dt=new WeakMap,Lt=function(e){const i=this.normalizePath(e);let s=t(this,N).get(i.pathname);return s||(s=new Jt(this,i.pathname),t(this,N).set(i.pathname,s)),s},Tt=function(e){const i=[...e.querySelectorAll("[data-morph]")];return i.length?i:[e]},_t=function(e,i){return e.filter(s=>i.find(h=>h.outerHTML===s.outerHTML))},xt=function(e,i){return e.filter(s=>!i.find(h=>h.outerHTML===s.outerHTML))},Nt=function(e){return e.tagName==="SCRIPT"||e.tagName==="STYLE"||e.tagName==="LINK"&&e.getAttribute("rel")==="stylesheet"},Ut=function(e){var i,s;(i=t(this,C))==null||i.removeEventListener("scroll",t(this,st)),r(this,et,0),r(this,tt,0),r(this,C,t(this,R).scrollSelector&&e.querySelector(t(this,R).scrollSelector)||window),r(this,ht,t(this,C)===window),(s=t(this,C))==null||s.addEventListener("scroll",t(this,st)),t(this,st).call(this)},qt=function(e,i){const s=typeof e=="string"?document.getElementById(e):e;(typeof s=="number"||s)&&Gt.scrollToElement(s,{scrollElement:t(this,C),behavior:(i==null?void 0:i.behavior)||"instant",center:i==null?void 0:i.centerScroll,offset:i==null?void 0:i.offsetScroll})},yt=new WeakMap,st=new WeakMap,rt.instance=null;let Rt=rt;exports.Morph=Rt;
|
|
1
|
+
"use strict";var ae=Object.defineProperty,ne=Object.defineProperties;var re=Object.getOwnPropertyDescriptors;var Xt=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var Yt=(o,e)=>(e=Symbol[o])?e:Symbol.for("Symbol."+o),Kt=o=>{throw TypeError(o)};var jt=(o,e,i)=>e in o?ae(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,vt=(o,e)=>{for(var i in e||(e={}))oe.call(e,i)&&jt(o,i,e[i]);if(Xt)for(var i of Xt(e))le.call(e,i)&&jt(o,i,e[i]);return o},Pt=(o,e)=>ne(o,re(e));var Ct=(o,e,i)=>e.has(o)||Kt("Cannot "+i);var t=(o,e,i)=>(Ct(o,e,"read from private field"),i?i.call(o):e.get(o)),l=(o,e,i)=>e.has(o)?Kt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(o):e.set(o,i),r=(o,e,i,s)=>(Ct(o,e,"write to private field"),s?s.call(o,i):e.set(o,i),i),p=(o,e,i)=>(Ct(o,e,"access private method"),i);var W=(o,e,i)=>new Promise((s,h)=>{var v=d=>{try{L(i.next(d))}catch(E){h(E)}},g=d=>{try{L(i.throw(d))}catch(E){h(E)}},L=d=>d.done?s(d.value):Promise.resolve(d.value).then(v,g);L((i=i.apply(o,e)).next())});var $t=(o,e,i)=>(e=o[Yt("asyncIterator")])?e.call(o):(o=o[Yt("iterator")](),e={},i=(s,h)=>(h=o[s])&&(e[s]=v=>new Promise((g,L,d)=>(v=h.call(o,v),d=v.done,Promise.resolve(v.value).then(E=>g({value:E,done:d}),L)))),i("next"),i("return"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Qt=require("../index-DekP7OZe.cjs"),M=require("../events-KVanG9sR.cjs"),Gt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const nt=require("../url-DGcX4fGV.cjs"),he=require("../css-value-parser/index.cjs");class Zt extends HTMLElement{connectedCallback(){const e={"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[i,s]of Object.entries(e))this.setAttribute(i,s)}}Qt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Zt);var P,a,I,J,St,ot,Q;class Ht{constructor(e,i){l(this,J);l(this,P);l(this,a);l(this,I);l(this,ot,e=>{var s;if(e.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(t(this,a).hasAttribute("data-back")&&t(this,P).previousURL)history.back();else{r(this,I,t(this,a).getAttribute("href")||"/");const h=t(this,a).getAttribute("data-history-action")||"push",v=t(this,a).hasAttribute("data-center-scroll"),g=getComputedStyle(t(this,a)).getPropertyValue("--offset-scroll").trim(),L=g?he.cssValueParser.parse(g):void 0,d=t(this,a).hasAttribute("data-revalidate")||t(this,a).hasAttribute("data-pagination-more-link")||t(this,a).hasAttribute("data-pagination-set-link"),E=t(this,a).hasAttribute("data-keep-search-parameters"),yt=t(this,a).hasAttribute("data-keep-scroll-position")||t(this,a).hasAttribute("data-pagination-more-link"),at=t(this,a).getAttribute("data-scroll-behaviour"),mt=p(this,J,St).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));mt&&(t(this,a).hasAttribute("data-pagination-set-link")?t(this,P).links.forEach(U=>{U.updatePagination(parseInt(t(this,a).getAttribute("data-value")||"1"),mt.selector)}):t(this,a).hasAttribute("data-pagination-more-link")&&t(this,P).links.forEach(U=>{U.updatePagination(mt.currentPage+1,mt.selector)}));const ft=((s=t(this,a).getAttribute("data-submorph"))==null?void 0:s.split(",").map(U=>U.trim()))||t(this,a).hasAttribute("data-pagination-more-link")&&[t(this,a).getAttribute("data-pagination-more-link")]||t(this,a).hasAttribute("data-pagination-set-link")&&[t(this,a).getAttribute("data-pagination-set-link")]||void 0,c=t(this,a).hasAttribute("data-clear-state");t(this,P).navigate(t(this,I),{historyAction:h,centerScroll:v,offsetScroll:L,revalidate:d,keepSearchParameters:E,submorph:ft,clearState:c,keepScrollPosition:yt,scrollBehaviour:at,submorphAppend:t(this,a).hasAttribute("data-pagination-more-link")})}});l(this,Q,()=>{const e=t(this,a).hasAttribute("data-revalidate");t(this,P).prefetch(t(this,I),e),t(this,a).removeEventListener("pointerenter",t(this,Q))});r(this,P,i),r(this,a,e),t(this,a).addEventListener("click",t(this,ot)),r(this,I,t(this,a).getAttribute("href")||"/"),this.checkCurrent(location.href.replace(location.origin,""));const s=p(this,J,St).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));s&&this.updatePagination(s.currentPage,s.selector),t(this,a).hasAttribute("data-prefetch")&&t(this,a).addEventListener("pointerenter",t(this,Q))}get element(){return t(this,a)}checkCurrent(e){var h;const i=t(this,P).normalizePath(e),s=t(this,P).normalizePath(t(this,I));t(this,a).hasAttribute("data-include")&&i.pathname.includes(s.pathname)?t(this,a).classList.add("current"):s.pathname===i.pathname?t(this,a).classList.add("current"):(h=t(this,a).getAttribute("data-associated-paths"))!=null&&h.split(",").find(v=>i.pathname.includes(v))?t(this,a).classList.add("current"):t(this,a).classList.remove("current"),i.path===s.path?t(this,a).classList.add("exact"):t(this,a).classList.remove("exact")}updatePagination(e,i){const s=p(this,J,St).call(this,i);if(s)if(s.element.setAttribute("data-current-page",e.toString()),t(this,a).hasAttribute("data-pagination-more-link"))if(e<s.totalPages){t(this,a).style.display="";const h=t(this,a).querySelector("[data-pagination-more-link-counter]");h&&(h.textContent=(s.totalPages-e).toString());const v=t(this,a).getAttribute("href"),g=new URL(v,window.location.origin);g.searchParams.set("page",(e+1).toString());const L=g.href.replace(g.origin,"").toString();t(this,a).setAttribute("href",L),this.checkCurrent(L)}else t(this,a).style.display="none";else t(this,a).hasAttribute("data-pagination-set-link")&&(t(this,a).getAttribute("data-value")===e.toString()?t(this,a).classList.add("pagination-current"):t(this,a).classList.remove("pagination-current"))}destroy(){t(this,a).removeEventListener("click",t(this,ot)),t(this,a).removeEventListener("pointerenter",t(this,Q)),t(this,a).classList.remove("current","exact","pagination-current")}}P=new WeakMap,a=new WeakMap,I=new WeakMap,J=new WeakSet,St=function(e){if(!e)return;const i=document.querySelector(e);if(i){const s=parseInt(i.getAttribute("data-current-page")||"1"),h=parseInt(i.getAttribute("data-total-pages")||"1");return{element:i,currentPage:s,totalPages:h,selector:e}}},ot=new WeakMap,Q=new WeakMap;const ce=new DOMParser;var T,X,A,x,Y,z,Z,j,V,lt;class Jt{constructor(e,i){l(this,T);l(this,X);l(this,A,{x:0,y:0});l(this,x,null);l(this,Y,null);l(this,z,null);l(this,Z,null);l(this,j,null);l(this,V,null);l(this,lt);r(this,T,e),r(this,X,i)}get pathname(){return t(this,X)}get scrollState(){return t(this,A)}get document(){return t(this,z)}setHeaders(e){r(this,lt,e)}setInitialDocument(e){r(this,x,e.cloneNode(!0))}abort(){var e;return(e=t(this,j))==null?void 0:e.abort(`[${t(this,X)}] page loading cancelled`)}fetch(e,i,s){return W(this,null,function*(){var h;if(!s){const L=((h=t(this,x))==null?void 0:h.documentElement.getAttribute("data-cache"))&&i!==e,d=t(this,x)&&t(this,T).isPopstateNavigation;if(t(this,V)||L||d)return t(this,V)}return r(this,V,new Promise(v=>W(this,null,function*(){try{r(this,j,new AbortController);const L=yield(yield fetch(e,{signal:t(this,j).signal,headers:vt({"X-MORPH":"true","X-MORPH-CURRENT-PATH":encodeURIComponent(i),"X-MORPH-NEW-PATH":encodeURIComponent(e)},t(this,lt))})).text(),d=ce.parseFromString(L,"text/html");this.setInitialDocument(d)}catch(g){console.warn(g)}finally{r(this,j,null),r(this,V,null),v()}}))),t(this,V)})}cloneDocument(){r(this,z,(t(this,Y)||t(this,x)).cloneNode(!0))}get title(){let e="";if(t(this,z).title)e=t(this,z).title;else{const i=t(this,z).querySelector("h1");e=(i==null?void 0:i.innerText)||(i==null?void 0:i.textContent)||t(this,X)}return e}clearScrollState(){t(this,A).x=0,t(this,A).y=0}clearDocumentState(){r(this,Y,null)}saveScrollState(){t(this,x).documentElement.hasAttribute("data-no-scroll-restoration")?(t(this,A).x=0,t(this,A).y=0):(t(this,A).x=t(this,T).scrollValue.left,t(this,A).y=t(this,T).scrollValue.top)}restoreScrollPosition(){t(this,T).scrollElement.scroll({top:t(this,A).y,left:t(this,A).x,behavior:"instant"})}saveDocumentState(){t(this,x).documentElement.hasAttribute("data-no-page-restoration")?r(this,Y,null):r(this,Y,document.cloneNode(!0))}renewScrollPosition(){t(this,T).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(e){r(this,Z,e)}clearState(){const e=t(this,Z);return r(this,Z,null),e}}T=new WeakMap,X=new WeakMap,A=new WeakMap,x=new WeakMap,Y=new WeakMap,z=new WeakMap,Z=new WeakMap,j=new WeakMap,V=new WeakMap,lt=new WeakMap;var R,_,y,O,f,K,F,B,C,ht,N,$,tt,et,ct,it,ut,m,Mt,dt,bt,Tt,_t,xt,Nt,Ut,qt,Lt,st;const rt=class rt{constructor(e){l(this,m);l(this,R,null);l(this,_,null);l(this,y,[]);l(this,O);l(this,f,null);l(this,K);l(this,F,[]);l(this,B,!1);l(this,C,null);l(this,ht,!1);l(this,N,new Map);l(this,$,null);l(this,tt,0);l(this,et,0);l(this,ct);l(this,it);l(this,ut);l(this,dt,e=>{var i;return((i=e.getAttribute("href"))==null?void 0:i.startsWith("/"))&&!e.hasAttribute("download")&&!e.hasAttribute("data-morph-skip")&&!e.closest("[data-morph-skip]")&&e.getAttribute("target")!=="_blank"});l(this,Lt,e=>W(this,null,function*(){e.preventDefault(),r(this,B,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:t(this,it)?void 0:t(this,ct),revalidate:t(this,it),keepScrollPosition:t(this,ut)}),r(this,B,!1)}));l(this,st,()=>{const{left:e,top:i}=this.scrollValue,s=i-t(this,et),h=e-t(this,tt);r(this,et,i),r(this,tt,e),document.documentElement.classList.toggle("scroll-y",i>0),document.documentElement.classList.toggle("scroll-x",e>0),document.documentElement.classList.toggle("scroll-y-forward",s>0),document.documentElement.classList.toggle("scroll-y-backward",s<0),document.documentElement.classList.toggle("scroll-x-forward",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),M.dispatchEvent(document,"morphScroll",{detail:{left:e,top:i}})});if(Qt.isBrowser&&!rt.instance){rt.instance=this,r(this,R,{base:nt.normalizeBase(e==null?void 0:e.base),waitForHeadToLoad:(e==null?void 0:e.waitForHeadToLoad)!==!1,trailingSlash:(e==null?void 0:e.trailingSlash)||!1,scrollSelector:e==null?void 0:e.scrollSelector,morphInsideScrollContainer:(e==null?void 0:e.morphInsideScrollContainer)||!1}),r(this,_,p(this,m,Tt).call(this,document.body));const i=this.normalizePath(location.pathname+location.search+location.hash);r(this,f,i);const s=new Jt(this,t(this,f).pathname);s.setInitialDocument(document),t(this,N).set(t(this,f).pathname,s),document.documentElement.setAttribute("data-current-pathname",t(this,f).pathname),document.documentElement.setAttribute("data-current-leaf",i.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",t(this,Lt)),nt.changeHistory({action:"replace",pathname:i.pathname,searchParameters:i.parameters,hash:i.hash}),r(this,$,new Zt),p(this,m,Ut).call(this,document)}}get currentURL(){return t(this,f)}get previousURL(){return t(this,K)}get links(){return t(this,y)}get scrollElement(){return t(this,C)}get isPopstateNavigation(){return t(this,B)}get scrollValue(){let e=0,i=0;return t(this,ht)?(e=window.scrollY,i=window.scrollX):(e=t(this,C).scrollTop,i=t(this,C).scrollLeft),{top:e,left:i}}saveState(e){const i=t(this,N).get(t(this,f).path);i&&i.saveState(e)}getState(){const e=t(this,N).get(t(this,f).path);return e==null?void 0:e.clearState()}normalizePath(e){return nt.splitPath(e,{base:t(this,R).base,trailingSlash:t(this,R).trailingSlash})}prefetch(e,i){return W(this,null,function*(){var h;if(t(this,F).length)return;e=((h=this.pathnameModifier)==null?void 0:h.call(this,e))||e;const s=p(this,m,bt).call(this,e);s==null||s.fetch(e,t(this,f).path,i)})}excludeHeadChild(e){return!1}setHeaders(e){}navigate(mt){return W(this,arguments,function*(e,{historyAction:i="push",centerScroll:s,offsetScroll:h,scrollBehaviour:v,revalidate:g,keepSearchParameters:L,submorph:d,submorphAppend:E,clearState:yt,keepScrollPosition:at}={}){var U,Dt,It,zt;if(t(this,F).length)return;r(this,ct,d),r(this,it,g),r(this,ut,at);const ft=((U=this.pathnameModifier)==null?void 0:U.call(this,e))||e,c=this.normalizePath(ft);if(t(this,y).forEach(G=>{G.checkCurrent(c.path)}),!g&&(((Dt=t(this,O))==null?void 0:Dt.pathname)===c.pathname||t(this,f).pathname===c.pathname)){at||p(this,m,qt).call(this,c.hash||0,{centerScroll:s,offsetScroll:h,behavior:"smooth"}),M.dispatchEvent(document,"morphSamePath",{custom:!0}),((It=t(this,f))==null?void 0:It.parameters)!==c.parameters&&(r(this,K,t(this,f)),r(this,f,c),nt.changeHistory({action:((zt=t(this,f))==null?void 0:zt.hash)!==c.hash?"replace":i,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),M.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:t(this,f),previousURL:t(this,K)}}));return}r(this,O,c);try{let G=!0;if(this.preprocessor)try{yield new Promise((n,w)=>{var k;(k=this.preprocessor)==null||k.call(this,{url:c,resolve:n,reject:w,submorph:d})})}catch(n){n?console.error(n):console.log("Route change canceled"),G=!1}if(!G||t(this,O).pathname!==c.pathname){t(this,y).forEach(n=>{n.checkCurrent(t(this,f).path)});return}const Vt={url:c,submorph:d};d?E||d.forEach(n=>{document.querySelectorAll(n).forEach(w=>{w.classList.add("out"),w.setAttribute("data-morph-out","")})}):t(this,_).forEach(n=>{var w,k;(w=n.firstElementChild)==null||w.classList.add("out"),(k=n.firstElementChild)==null||k.setAttribute("data-morph-out","")}),M.dispatchEvent(document,"morphNavigation",{detail:Vt});const wt=p(this,m,bt).call(this,t(this,f).pathname),S=p(this,m,bt).call(this,c.pathname);if(t(this,N).forEach(n=>{n.pathname!==c.pathname&&n.abort()}),yield S==null?void 0:S.fetch(ft,t(this,f).path,g),t(this,O).pathname!==c.pathname){t(this,y).forEach(n=>{n.checkCurrent(t(this,f).path)});return}wt.clearState(),wt.saveScrollState(),wt.saveDocumentState(),(!t(this,B)||g)&&(S.clearScrollState(),S.clearDocumentState()),yt&&S.clearState(),S.cloneDocument(),t(this,$).textContent=S.title,document.body.appendChild(t(this,$));const pt=Pt(vt({},Vt),{document:S.document});E||pt.document.querySelectorAll("[data-morph-out]").forEach(n=>{n.classList.remove("out")}),M.dispatchEvent(document,"morphStart",{detail:pt});const Ot=Array.from(document.head.children),Ft=Array.from(S.document.head.children),Bt=p(this,m,_t).call(this,Ot,Ft),te=p(this,m,xt).call(this,Ot,Bt),gt=p(this,m,xt).call(this,Ft,Bt).filter(n=>!this.excludeHeadChild(n));gt.forEach((n,w)=>{n.tagName==="SCRIPT"&&(gt[w]=p(this,m,Mt).call(this,n))}),gt.forEach(n=>{document.head.appendChild(n)});const At=gt.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(p(this,m,Nt).call(this,n))return!0});t(this,R).waitForHeadToLoad&&At.length&&(yield new Promise(n=>W(this,null,function*(){let w=0;try{for(var k=$t(At),ie,q,H;ie=!(q=yield k.next()).done;ie=!1){const Et=q.value;Et.onload=()=>{w++,w===At.length&&n()}}}catch(q){H=[q]}finally{try{ie&&(q=k.return)&&(yield q.call(k))}finally{if(H)throw H[0]}}}))),yield Gt.wait(10);const Wt=[];E||te.forEach(n=>{n.hasAttribute("data-permanent")||(p(this,m,Nt).call(this,n)?Wt.push(n):n.remove())});const ee=p(this,m,Tt).call(this,S.document.body);!t(this,R).morphInsideScrollContainer&&!d&&p(this,m,Ut).call(this,S.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),nt.changeHistory({action:i,pathname:c.pathname,searchParameters:c.parameters||(L?location.search:""),hash:c.hash}),t(this,$).remove(),r(this,K,t(this,f)),r(this,f,c);const kt=[];t(this,_).forEach((n,w)=>{const k=ee[w],ie=getComputedStyle(n).getPropertyValue("--morph-duration");let q=[],H=[];d?(d.forEach(u=>{const b=n.querySelector(u),D=k.querySelector(u);b&&D&&(H.push(b),q.push(D))}),H.forEach(u=>{u.parentElement&&kt.push(u.parentElement)})):(q.push(...k.childNodes),H.push(...n.childNodes),kt.push(n)),E||H.forEach(u=>{u instanceof HTMLElement&&(this.destroyOldLinks(u),u.classList.add("old"))}),q.forEach(u=>{u instanceof HTMLElement&&(this.findNewLinks(u),u.classList.add("new"))}),d?E?q.forEach((u,b)=>{H[b]instanceof HTMLElement&&H[b].append(...u.childNodes)}):q.forEach((u,b)=>{var D;(D=H[b].parentElement)==null||D.insertBefore(u,H[b])}):n.prepend(...q),setTimeout(()=>{E||H.forEach(u=>{u instanceof HTMLElement&&u.classList.add("old-idle")}),q.forEach(u=>{var b;u instanceof HTMLElement&&((b=u.parentElement)==null||b.style.setProperty("--new-content-height",u.offsetHeight+"px"),u.classList.add("new-idle"))})},0);const Et=Pt(vt({},pt),{morphElement:n});M.dispatchEvent(document,"morphNewChildrenAdded",{detail:Et});const se=new Promise(u=>{setTimeout(()=>{E||H.forEach(b=>b.remove()),q.forEach(b=>{var D;b instanceof HTMLElement&&((D=b.parentElement)==null||D.style.removeProperty("--new-content-height"),b.classList.remove("new-idle","new"))}),E||M.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Et}),u()},(parseFloat(ie)||0)*1e3+10)});t(this,F).push(se)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-S.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),M.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:S.scrollState}),c.hash?(S.clearScrollState(),p(this,m,qt).call(this,c.hash,{centerScroll:s,offsetScroll:h,behavior:v})):t(this,B)?S.restoreScrollPosition():at||S.renewScrollPosition(),yield Promise.all(t(this,F)),E||Wt.forEach(n=>n.remove()),r(this,F,[]),kt.forEach(n=>{n.querySelectorAll("script").forEach(k=>{k.replaceWith(p(this,m,Mt).call(this,k))})}),t(this,y).forEach(n=>{n.checkCurrent(t(this,f).path)}),M.dispatchEvent(document,"morphComplete",{detail:pt}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(G){console.error(G)}r(this,O,void 0)})}addLink(e){t(this,y).push(new Ht(e,this))}addLinks(e){e.forEach(i=>{this.addLink(i)})}removeLink(e){r(this,y,t(this,y).filter(i=>i.element===e?(i.destroy(),!1):!0))}destroyOldLinks(e){r(this,y,t(this,y).filter(i=>e.contains(i.element)?(i.destroy(),!1):!0))}findNewLinks(e){const i=[...e.querySelectorAll("a")].filter(t(this,dt));t(this,y).push(...i.map(s=>new Ht(s,this)))}findLinks(){const e=[...document.documentElement.querySelectorAll("a")].filter(t(this,dt));t(this,y).forEach(i=>i.destroy()),r(this,y,e.map(i=>new Ht(i,this)))}};R=new WeakMap,_=new WeakMap,y=new WeakMap,O=new WeakMap,f=new WeakMap,K=new WeakMap,F=new WeakMap,B=new WeakMap,C=new WeakMap,ht=new WeakMap,N=new WeakMap,$=new WeakMap,tt=new WeakMap,et=new WeakMap,ct=new WeakMap,it=new WeakMap,ut=new WeakMap,m=new WeakSet,Mt=function(e){const i=document.createElement("script");for(let s=0;s<e.attributes.length;s++){const h=e.attributes[s];i.setAttribute(h.name,h.value)}return e.hasAttribute("src")||(i.innerHTML=e.innerHTML),i},dt=new WeakMap,bt=function(e){const i=this.normalizePath(e);let s=t(this,N).get(i.pathname);return s||(s=new Jt(this,i.pathname),t(this,N).set(i.pathname,s)),s},Tt=function(e){const i=[...e.querySelectorAll("[data-morph]")];return i.length?i:[e]},_t=function(e,i){return e.filter(s=>i.find(h=>h.outerHTML===s.outerHTML))},xt=function(e,i){return e.filter(s=>!i.find(h=>h.outerHTML===s.outerHTML))},Nt=function(e){return e.tagName==="SCRIPT"||e.tagName==="STYLE"||e.tagName==="LINK"&&e.getAttribute("rel")==="stylesheet"},Ut=function(e){var i,s;(i=t(this,C))==null||i.removeEventListener("scroll",t(this,st)),r(this,et,0),r(this,tt,0),r(this,C,t(this,R).scrollSelector&&e.querySelector(t(this,R).scrollSelector)||window),r(this,ht,t(this,C)===window),(s=t(this,C))==null||s.addEventListener("scroll",t(this,st)),t(this,st).call(this)},qt=function(e,i){const s=typeof e=="string"?document.getElementById(e):e;(typeof s=="number"||s)&&Gt.scrollToElement(s,{scrollElement:t(this,C),behavior:(i==null?void 0:i.behavior)||"instant",center:i==null?void 0:i.centerScroll,offset:i==null?void 0:i.offsetScroll})},Lt=new WeakMap,st=new WeakMap,rt.instance=null;let Rt=rt;exports.Morph=Rt;
|
package/lib/morph/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var re = Object.prototype.hasOwnProperty, oe = Object.prototype.propertyIsEnumer
|
|
|
5
5
|
var Xt = (o, e) => (e = Symbol[o]) ? e : Symbol.for("Symbol." + o), Kt = (o) => {
|
|
6
6
|
throw TypeError(o);
|
|
7
7
|
};
|
|
8
|
-
var Yt = (o, e, i) => e in o ? se(o, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : o[e] = i,
|
|
8
|
+
var Yt = (o, e, i) => e in o ? se(o, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : o[e] = i, Et = (o, e) => {
|
|
9
9
|
for (var i in e || (e = {}))
|
|
10
10
|
re.call(e, i) && Yt(o, i, e[i]);
|
|
11
11
|
if (Wt)
|
|
@@ -50,7 +50,7 @@ class Qt extends HTMLElement {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
Jt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Qt);
|
|
53
|
-
var P, a, q, J,
|
|
53
|
+
var P, a, q, J, St, rt, Q;
|
|
54
54
|
class Ht {
|
|
55
55
|
constructor(e, i) {
|
|
56
56
|
l(this, J);
|
|
@@ -69,23 +69,21 @@ class Ht {
|
|
|
69
69
|
"data-history-action"
|
|
70
70
|
) || "push", S = t(this, a).hasAttribute("data-center-scroll"), g = getComputedStyle(t(this, a)).getPropertyValue("--offset-scroll").trim(), b = g ? de.parse(g) : void 0, d = t(this, a).hasAttribute("data-revalidate") || t(this, a).hasAttribute("data-pagination-more-link") || t(this, a).hasAttribute("data-pagination-set-link"), E = t(this, a).hasAttribute(
|
|
71
71
|
"data-keep-search-parameters"
|
|
72
|
-
),
|
|
73
|
-
console.log(dt);
|
|
74
|
-
const at = t(this, a).getAttribute(
|
|
72
|
+
), bt = t(this, a).hasAttribute("data-keep-scroll-position") || t(this, a).hasAttribute("data-pagination-more-link"), at = t(this, a).getAttribute(
|
|
75
73
|
"data-scroll-behaviour"
|
|
76
|
-
),
|
|
77
|
-
|
|
74
|
+
), dt = p(this, J, St).call(this, t(this, a).getAttribute("data-pagination-set-link") || t(this, a).getAttribute("data-pagination-more-link"));
|
|
75
|
+
dt && (t(this, a).hasAttribute("data-pagination-set-link") ? t(this, P).links.forEach((U) => {
|
|
78
76
|
U.updatePagination(
|
|
79
77
|
parseInt(t(this, a).getAttribute("data-value") || "1"),
|
|
80
|
-
|
|
78
|
+
dt.selector
|
|
81
79
|
);
|
|
82
80
|
}) : t(this, a).hasAttribute("data-pagination-more-link") && t(this, P).links.forEach((U) => {
|
|
83
81
|
U.updatePagination(
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
dt.currentPage + 1,
|
|
83
|
+
dt.selector
|
|
86
84
|
);
|
|
87
85
|
}));
|
|
88
|
-
const
|
|
86
|
+
const mt = ((s = t(this, a).getAttribute("data-submorph")) == null ? void 0 : s.split(",").map((U) => U.trim())) || t(this, a).hasAttribute("data-pagination-more-link") && [
|
|
89
87
|
t(this, a).getAttribute("data-pagination-more-link")
|
|
90
88
|
] || t(this, a).hasAttribute("data-pagination-set-link") && [
|
|
91
89
|
t(this, a).getAttribute("data-pagination-set-link")
|
|
@@ -96,9 +94,9 @@ class Ht {
|
|
|
96
94
|
offsetScroll: b,
|
|
97
95
|
revalidate: d,
|
|
98
96
|
keepSearchParameters: E,
|
|
99
|
-
submorph:
|
|
97
|
+
submorph: mt,
|
|
100
98
|
clearState: c,
|
|
101
|
-
keepScrollPosition:
|
|
99
|
+
keepScrollPosition: bt,
|
|
102
100
|
scrollBehaviour: at,
|
|
103
101
|
submorphAppend: t(this, a).hasAttribute("data-pagination-more-link")
|
|
104
102
|
});
|
|
@@ -109,7 +107,7 @@ class Ht {
|
|
|
109
107
|
t(this, P).prefetch(t(this, q), e), t(this, a).removeEventListener("pointerenter", t(this, Q));
|
|
110
108
|
});
|
|
111
109
|
r(this, P, i), r(this, a, e), t(this, a).addEventListener("click", t(this, rt)), r(this, q, t(this, a).getAttribute("href") || "/"), this.checkCurrent(location.href.replace(location.origin, ""));
|
|
112
|
-
const s = p(this, J,
|
|
110
|
+
const s = p(this, J, St).call(this, t(this, a).getAttribute("data-pagination-set-link") || t(this, a).getAttribute("data-pagination-more-link"));
|
|
113
111
|
s && this.updatePagination(
|
|
114
112
|
s.currentPage,
|
|
115
113
|
s.selector
|
|
@@ -124,7 +122,7 @@ class Ht {
|
|
|
124
122
|
t(this, a).hasAttribute("data-include") && i.pathname.includes(s.pathname) ? t(this, a).classList.add("current") : s.pathname === i.pathname ? t(this, a).classList.add("current") : (h = t(this, a).getAttribute("data-associated-paths")) != null && h.split(",").find((S) => i.pathname.includes(S)) ? t(this, a).classList.add("current") : t(this, a).classList.remove("current"), i.path === s.path ? t(this, a).classList.add("exact") : t(this, a).classList.remove("exact");
|
|
125
123
|
}
|
|
126
124
|
updatePagination(e, i) {
|
|
127
|
-
const s = p(this, J,
|
|
125
|
+
const s = p(this, J, St).call(this, i);
|
|
128
126
|
if (s)
|
|
129
127
|
if (s.element.setAttribute(
|
|
130
128
|
"data-current-page",
|
|
@@ -148,7 +146,7 @@ class Ht {
|
|
|
148
146
|
t(this, a).removeEventListener("click", t(this, rt)), t(this, a).removeEventListener("pointerenter", t(this, Q)), t(this, a).classList.remove("current", "exact", "pagination-current");
|
|
149
147
|
}
|
|
150
148
|
}
|
|
151
|
-
P = new WeakMap(), a = new WeakMap(), q = new WeakMap(), J = new WeakSet(),
|
|
149
|
+
P = new WeakMap(), a = new WeakMap(), q = new WeakMap(), J = new WeakSet(), St = function(e) {
|
|
152
150
|
if (!e)
|
|
153
151
|
return;
|
|
154
152
|
const i = document.querySelector(e);
|
|
@@ -216,7 +214,7 @@ class $t {
|
|
|
216
214
|
r(this, K, new AbortController());
|
|
217
215
|
const b = yield (yield fetch(e, {
|
|
218
216
|
signal: t(this, K).signal,
|
|
219
|
-
headers:
|
|
217
|
+
headers: Et({
|
|
220
218
|
"X-MORPH": "true",
|
|
221
219
|
"X-MORPH-CURRENT-PATH": encodeURIComponent(i),
|
|
222
220
|
"X-MORPH-NEW-PATH": encodeURIComponent(e)
|
|
@@ -283,7 +281,7 @@ class $t {
|
|
|
283
281
|
}
|
|
284
282
|
}
|
|
285
283
|
M = new WeakMap(), X = new WeakMap(), A = new WeakMap(), x = new WeakMap(), Y = new WeakMap(), z = new WeakMap(), Z = new WeakMap(), K = new WeakMap(), V = new WeakMap(), ot = new WeakMap();
|
|
286
|
-
var R, _, y, F, f, j, O, B, C, lt, N, $, tt, et, ht, it, ct, m, Rt, ut,
|
|
284
|
+
var R, _, y, F, f, j, O, B, C, lt, N, $, tt, et, ht, it, ct, m, Rt, ut, vt, Tt, Zt, Mt, xt, Nt, Ut, Lt, st;
|
|
287
285
|
const nt = class nt {
|
|
288
286
|
constructor(e) {
|
|
289
287
|
l(this, m);
|
|
@@ -308,7 +306,7 @@ const nt = class nt {
|
|
|
308
306
|
var i;
|
|
309
307
|
return ((i = e.getAttribute("href")) == null ? void 0 : i.startsWith("/")) && !e.hasAttribute("download") && !e.hasAttribute("data-morph-skip") && !e.closest("[data-morph-skip]") && e.getAttribute("target") !== "_blank";
|
|
310
308
|
});
|
|
311
|
-
l(this,
|
|
309
|
+
l(this, Lt, (e) => W(this, null, function* () {
|
|
312
310
|
e.preventDefault(), r(this, B, !0), yield this.navigate(location.href.replace(location.origin, ""), {
|
|
313
311
|
historyAction: "none",
|
|
314
312
|
submorph: t(this, it) ? void 0 : t(this, ht),
|
|
@@ -356,7 +354,7 @@ const nt = class nt {
|
|
|
356
354
|
), document.documentElement.setAttribute(
|
|
357
355
|
"data-current-leaf",
|
|
358
356
|
i.leaf
|
|
359
|
-
), this.findLinks(), history.scrollRestoration = "manual", addEventListener("popstate", t(this,
|
|
357
|
+
), this.findLinks(), history.scrollRestoration = "manual", addEventListener("popstate", t(this, Lt)), Ct({
|
|
360
358
|
action: "replace",
|
|
361
359
|
pathname: i.pathname,
|
|
362
360
|
searchParameters: i.parameters,
|
|
@@ -403,7 +401,7 @@ const nt = class nt {
|
|
|
403
401
|
if (t(this, O).length)
|
|
404
402
|
return;
|
|
405
403
|
e = ((h = this.pathnameModifier) == null ? void 0 : h.call(this, e)) || e;
|
|
406
|
-
const s = p(this, m,
|
|
404
|
+
const s = p(this, m, vt).call(this, e);
|
|
407
405
|
s == null || s.fetch(e, t(this, f).path, i);
|
|
408
406
|
});
|
|
409
407
|
}
|
|
@@ -412,7 +410,7 @@ const nt = class nt {
|
|
|
412
410
|
}
|
|
413
411
|
setHeaders(e) {
|
|
414
412
|
}
|
|
415
|
-
navigate(
|
|
413
|
+
navigate(dt) {
|
|
416
414
|
return W(this, arguments, function* (e, {
|
|
417
415
|
historyAction: i = "push",
|
|
418
416
|
centerScroll: s,
|
|
@@ -422,14 +420,14 @@ const nt = class nt {
|
|
|
422
420
|
keepSearchParameters: b,
|
|
423
421
|
submorph: d,
|
|
424
422
|
submorphAppend: E,
|
|
425
|
-
clearState:
|
|
423
|
+
clearState: bt,
|
|
426
424
|
keepScrollPosition: at
|
|
427
425
|
} = {}) {
|
|
428
426
|
var U, Dt, It, qt;
|
|
429
427
|
if (t(this, O).length)
|
|
430
428
|
return;
|
|
431
429
|
r(this, ht, d), r(this, it, g), r(this, ct, at);
|
|
432
|
-
const
|
|
430
|
+
const mt = ((U = this.pathnameModifier) == null ? void 0 : U.call(this, e)) || e, c = this.normalizePath(mt);
|
|
433
431
|
if (t(this, y).forEach((G) => {
|
|
434
432
|
G.checkCurrent(c.path);
|
|
435
433
|
}), !g && (((Dt = t(this, F)) == null ? void 0 : Dt.pathname) === c.pathname || t(this, f).pathname === c.pathname)) {
|
|
@@ -489,31 +487,31 @@ const nt = class nt {
|
|
|
489
487
|
}), T(document, "morphNavigation", {
|
|
490
488
|
detail: zt
|
|
491
489
|
});
|
|
492
|
-
const yt = p(this, m,
|
|
490
|
+
const yt = p(this, m, vt).call(this, t(this, f).pathname), v = p(this, m, vt).call(this, c.pathname);
|
|
493
491
|
if (t(this, N).forEach((n) => {
|
|
494
492
|
n.pathname !== c.pathname && n.abort();
|
|
495
|
-
}), yield v == null ? void 0 : v.fetch(
|
|
493
|
+
}), yield v == null ? void 0 : v.fetch(mt, t(this, f).path, g), t(this, F).pathname !== c.pathname) {
|
|
496
494
|
t(this, y).forEach((n) => {
|
|
497
495
|
n.checkCurrent(t(this, f).path);
|
|
498
496
|
});
|
|
499
497
|
return;
|
|
500
498
|
}
|
|
501
|
-
yt.clearState(), yt.saveScrollState(), yt.saveDocumentState(), (!t(this, B) || g) && (v.clearScrollState(), v.clearDocumentState()),
|
|
502
|
-
const
|
|
499
|
+
yt.clearState(), yt.saveScrollState(), yt.saveDocumentState(), (!t(this, B) || g) && (v.clearScrollState(), v.clearDocumentState()), bt && v.clearState(), v.cloneDocument(), t(this, $).textContent = v.title, document.body.appendChild(t(this, $));
|
|
500
|
+
const ft = kt(Et({}, zt), {
|
|
503
501
|
document: v.document
|
|
504
502
|
});
|
|
505
|
-
E ||
|
|
503
|
+
E || ft.document.querySelectorAll("[data-morph-out]").forEach((n) => {
|
|
506
504
|
n.classList.remove("out");
|
|
507
505
|
}), T(document, "morphStart", {
|
|
508
|
-
detail:
|
|
506
|
+
detail: ft
|
|
509
507
|
});
|
|
510
|
-
const Vt = Array.from(document.head.children), Ft = Array.from(v.document.head.children), Ot = p(this, m, Zt).call(this, Vt, Ft), _t = p(this, m, Mt).call(this, Vt, Ot),
|
|
511
|
-
|
|
512
|
-
n.tagName === "SCRIPT" && (
|
|
513
|
-
}),
|
|
508
|
+
const Vt = Array.from(document.head.children), Ft = Array.from(v.document.head.children), Ot = p(this, m, Zt).call(this, Vt, Ft), _t = p(this, m, Mt).call(this, Vt, Ot), pt = p(this, m, Mt).call(this, Ft, Ot).filter((n) => !this.excludeHeadChild(n));
|
|
509
|
+
pt.forEach((n, w) => {
|
|
510
|
+
n.tagName === "SCRIPT" && (pt[w] = p(this, m, Rt).call(this, n));
|
|
511
|
+
}), pt.forEach((n) => {
|
|
514
512
|
document.head.appendChild(n);
|
|
515
513
|
});
|
|
516
|
-
const wt =
|
|
514
|
+
const wt = pt.filter((n) => {
|
|
517
515
|
if (n.hasAttribute("data-no-waiting"))
|
|
518
516
|
return !1;
|
|
519
517
|
if (p(this, m, xt).call(this, n))
|
|
@@ -523,8 +521,8 @@ const nt = class nt {
|
|
|
523
521
|
let w = 0;
|
|
524
522
|
try {
|
|
525
523
|
for (var k = jt(wt), ee, D, H; ee = !(D = yield k.next()).done; ee = !1) {
|
|
526
|
-
const
|
|
527
|
-
|
|
524
|
+
const gt = D.value;
|
|
525
|
+
gt.onload = () => {
|
|
528
526
|
w++, w === wt.length && n();
|
|
529
527
|
};
|
|
530
528
|
}
|
|
@@ -588,11 +586,11 @@ const nt = class nt {
|
|
|
588
586
|
), u.classList.add("new-idle"));
|
|
589
587
|
});
|
|
590
588
|
}, 0);
|
|
591
|
-
const
|
|
589
|
+
const gt = kt(Et({}, ft), {
|
|
592
590
|
morphElement: n
|
|
593
591
|
});
|
|
594
592
|
T(document, "morphNewChildrenAdded", {
|
|
595
|
-
detail:
|
|
593
|
+
detail: gt
|
|
596
594
|
});
|
|
597
595
|
const ie = new Promise((u) => {
|
|
598
596
|
setTimeout(() => {
|
|
@@ -602,7 +600,7 @@ const nt = class nt {
|
|
|
602
600
|
"--new-content-height"
|
|
603
601
|
), L.classList.remove("new-idle", "new"));
|
|
604
602
|
}), E || T(document, "morphOldChildrenRemoved", {
|
|
605
|
-
detail:
|
|
603
|
+
detail: gt
|
|
606
604
|
}), u();
|
|
607
605
|
}, (parseFloat(ee) || 0) * 1e3 + 10);
|
|
608
606
|
});
|
|
@@ -626,7 +624,7 @@ const nt = class nt {
|
|
|
626
624
|
}), t(this, y).forEach((n) => {
|
|
627
625
|
n.checkCurrent(t(this, f).path);
|
|
628
626
|
}), T(document, "morphComplete", {
|
|
629
|
-
detail:
|
|
627
|
+
detail: ft
|
|
630
628
|
}), document.documentElement.style.removeProperty(
|
|
631
629
|
"--new-document-scroll-position"
|
|
632
630
|
), window.dispatchEvent(new Event("resize"));
|
|
@@ -672,7 +670,7 @@ R = new WeakMap(), _ = new WeakMap(), y = new WeakMap(), F = new WeakMap(), f =
|
|
|
672
670
|
i.setAttribute(h.name, h.value);
|
|
673
671
|
}
|
|
674
672
|
return e.hasAttribute("src") || (i.innerHTML = e.innerHTML), i;
|
|
675
|
-
}, ut = new WeakMap(),
|
|
673
|
+
}, ut = new WeakMap(), vt = function(e) {
|
|
676
674
|
const i = this.normalizePath(e);
|
|
677
675
|
let s = t(this, N).get(i.pathname);
|
|
678
676
|
return s || (s = new $t(this, i.pathname), t(this, N).set(i.pathname, s)), s;
|
|
@@ -707,7 +705,7 @@ R = new WeakMap(), _ = new WeakMap(), y = new WeakMap(), F = new WeakMap(), f =
|
|
|
707
705
|
center: i == null ? void 0 : i.centerScroll,
|
|
708
706
|
offset: i == null ? void 0 : i.offsetScroll
|
|
709
707
|
});
|
|
710
|
-
},
|
|
708
|
+
}, Lt = new WeakMap(), st = new WeakMap(), nt.instance = null;
|
|
711
709
|
let Gt = nt;
|
|
712
710
|
export {
|
|
713
711
|
Gt as Morph
|