aptechka 0.70.16 → 0.70.18
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 +171 -167
- package/lib/popover/index.cjs +1 -1
- package/lib/popover/index.js +2 -2
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Yt=Object.defineProperty,Xt=Object.defineProperties;var jt=Object.getOwnPropertyDescriptors;var xt=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable;var Ht=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),qt=r=>{throw TypeError(r)};var Nt=(r,t,s)=>t in r?Yt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s,pt=(r,t)=>{for(var s in t||(t={}))Ut.call(t,s)&&Nt(r,s,t[s]);if(xt)for(var s of xt(t))Kt.call(t,s)&&Nt(r,s,t[s]);return r},Et=(r,t)=>Xt(r,jt(t));var gt=(r,t,s)=>t.has(r)||qt("Cannot "+s);var e=(r,t,s)=>(gt(r,t,"read from private field"),s?s.call(r):t.get(r)),a=(r,t,s)=>t.has(r)?qt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,s),n=(r,t,s,i)=>(gt(r,t,"write to private field"),i?i.call(r,s):t.set(r,s),s),p=(r,t,s)=>(gt(r,t,"access private method"),s);var X=(r,t,s)=>new Promise((i,u)=>{var w=g=>{try{v(s.next(g))}catch(O){u(O)}},H=g=>{try{v(s.throw(g))}catch(O){u(O)}},v=g=>g.done?i(g.value):Promise.resolve(g.value).then(w,H);v((s=s.apply(r,t)).next())});var Dt=(r,t,s)=>(t=r[Ht("asyncIterator")])?t.call(r):(r=r[Ht("iterator")](),t={},s=(i,u)=>(u=r[i])&&(t[i]=w=>new Promise((H,v,g)=>(w=u.call(r,w),g=w.done,Promise.resolve(w.value).then(O=>H({value:O,done:g}),v)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vt=require("../index-DekP7OZe.cjs"),j=require("../events-KVanG9sR.cjs"),$t=require("../polyfills-Df4r-ETT.cjs"),It=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const ct=require("../url-BT4fssbO.cjs"),Gt=require("../css-value-parser/index.cjs");class zt 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)}}Vt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",zt);var C,l,I,st,G;class St{constructor(t,s){a(this,C);a(this,l);a(this,I);a(this,st,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,C).previousPathname)history.back();else{n(this,I,e(this,l).getAttribute("href")||"/");const u=e(this,l).getAttribute("data-history-action")||"push",w=e(this,l).hasAttribute("data-center-scroll"),H=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),v=H?Gt.cssValueParser.parse(H):void 0,g=e(this,l).hasAttribute("data-revalidate"),O=e(this,l).hasAttribute("data-keep-search-parameters"),d=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(N=>N.trim()),ot=e(this,l).hasAttribute("data-clear-state");e(this,C).navigate(e(this,I),{historyAction:u,centerScroll:w,offsetScroll:v,revalidate:g,keepSearchParameters:O,submorph:d,clearState:ot})}});a(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,I),t),e(this,l).removeEventListener("pointerenter",e(this,G))});n(this,C,s),n(this,l,t),n(this,I,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,st)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,G))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).normalizePath(e(this,I));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,st)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,I=new WeakMap,st=new WeakMap,G=new WeakMap;const Jt=new DOMParser;var T,R,b,P,U,V,J,K,z;class Rt{constructor(t,s){a(this,T);a(this,R);a(this,b,{x:0,y:0});a(this,P,null);a(this,U,null);a(this,V,null);a(this,J,null);a(this,K,null);a(this,z,null);n(this,T,t),n(this,R,s)}get path(){return e(this,R)}get scrollState(){return e(this,b)}get document(){return e(this,V)}setInitialDocument(t){n(this,P,t.cloneNode(!0))}abort(){var t;return(t=e(this,K))==null?void 0:t.abort(`[${e(this,R)}] page loading cancelled`)}fetch(t){return X(this,null,function*(){return e(this,z)||e(this,P)&&e(this,P).documentElement.hasAttribute("data-cache")&&!t||e(this,P)&&e(this,T).isPopstateNavigation?e(this,z):(n(this,z,new Promise(s=>X(this,null,function*(){try{n(this,K,new AbortController);const u=yield(yield fetch(e(this,R),{signal:e(this,K).signal})).text(),w=Jt.parseFromString(u,"text/html");this.setInitialDocument(w)}catch(i){console.warn(i)}finally{n(this,K,null),n(this,z,null),s()}}))),e(this,z))})}cloneDocument(){n(this,V,(e(this,U)||e(this,P)).cloneNode(!0))}get title(){let t="";if(e(this,V).title)t=e(this,V).title;else{const s=e(this,V).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,R)}return t}clearScrollState(){e(this,b).x=0,e(this,b).y=0}clearDocumentState(){n(this,U,null)}saveScrollState(){e(this,P).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,b).x=0,e(this,b).y=0):(e(this,b).x=e(this,T).scrollValue.left,e(this,b).y=e(this,T).scrollValue.top)}restoreScrollPosition(){e(this,T).scrollElement.scroll({top:e(this,b).y,left:e(this,b).x,behavior:"instant"})}saveDocumentState(){e(this,P).documentElement.hasAttribute("data-no-page-restoration")?n(this,U,null):n(this,U,document.cloneNode(!0))}renewScrollPosition(){e(this,T).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,J,t)}clearState(){const t=e(this,J);return n(this,J,null),t}}T=new WeakMap,R=new WeakMap,b=new WeakMap,P=new WeakMap,U=new WeakMap,V=new WeakMap,J=new WeakMap,K=new WeakMap,z=new WeakMap;var A,Q,E,B,f,it,F,M,L,rt,x,$,Z,_,nt,c,ht,wt,Bt,yt,bt,Lt,Pt,ut,tt;const et=class et{constructor(t){a(this,c);a(this,A,null);a(this,Q,null);a(this,E,[]);a(this,B);a(this,f,null);a(this,it);a(this,F,[]);a(this,M,!1);a(this,L,null);a(this,rt,!1);a(this,x,new Map);a(this,$,null);a(this,Z,0);a(this,_,0);a(this,nt,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});a(this,ut,t=>X(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),n(this,M,!0),yield this.navigate(t.state.path,{historyAction:"none"}),n(this,M,!1))}));a(this,tt,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,_),u=t-e(this,Z);n(this,_,s),n(this,Z,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",u>0),document.documentElement.classList.toggle("scroll-x-backward",u<0),j.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Vt.isBrowser&&!et.instance){et.instance=this,n(this,A,{base:ct.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,Q,p(this,c,wt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,f,s.path);const i=new Rt(this,e(this,f));i.setInitialDocument(document),e(this,x).set(e(this,f),i),document.documentElement.setAttribute("data-current-pathname",e(this,f)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,ut)),ct.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),n(this,$,new zt),p(this,c,Lt).call(this,document)}}get currentPath(){return e(this,f)}get previousPathname(){return e(this,it)}get links(){return e(this,E)}get scrollElement(){return e(this,L)}get isPopstateNavigation(){return e(this,M)}get scrollValue(){let t=0,s=0;return e(this,rt)?(t=window.scrollY,s=window.scrollX):(t=e(this,L).scrollTop,s=e(this,L).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,x).get(e(this,f));s&&s.saveState(t)}getState(){const t=e(this,x).get(e(this,f));return t==null?void 0:t.clearState()}normalizePath(t){return ct.splitPath(t,{base:e(this,A).base,trailingSlash:e(this,A).trailingSlash})}prefetch(t,s){return X(this,null,function*(){if(e(this,F).length)return;const i=p(this,c,ht).call(this,t);i==null||i.fetch(s)})}navigate(O){return X(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:w,keepSearchParameters:H,submorph:v,clearState:g}={}){var ot;if(e(this,F).length)return;const d=this.normalizePath(((ot=this.pathnameModifier)==null?void 0:ot.call(this,t))||t);if(e(this,B)===d.path||e(this,f)===d.path){e(this,M)||p(this,c,Pt).call(this,d.hash||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}n(this,B,d.path),e(this,E).forEach(N=>{N.checkCurrent(d.path)});try{let N=!0;if(this.preprocessor)try{yield new Promise((o,k)=>{var y;(y=this.preprocessor)==null||y.call(this,{path:t,resolve:o,reject:k,submorph:v})})}catch(o){o?console.error(o):console.log("Route change canceled"),N=!1}if(!N||e(this,B)!==d.path){e(this,E).forEach(o=>{o.checkCurrent(e(this,f))});return}const At={path:d.path,submorph:v};j.dispatchEvent(document,"morphNavigation",{detail:At});const dt=p(this,c,ht).call(this,e(this,f)),m=p(this,c,ht).call(this,t);if(e(this,x).forEach(o=>{o.path!==d.path&&o.abort()}),yield m==null?void 0:m.fetch(w),e(this,B)!==d.path){e(this,E).forEach(o=>{o.checkCurrent(e(this,f))});return}dt.clearState(),dt.saveScrollState(),dt.saveDocumentState(),e(this,M)||(m.clearScrollState(),m.clearDocumentState()),g&&m.clearState(),m.cloneDocument(),e(this,$).textContent=m.title,document.body.appendChild(e(this,$));const mt=Et(pt({},At),{document:m.document});j.dispatchEvent(document,"morphStart",{detail:mt});const kt=Array.from(document.head.children),Ct=Array.from(m.document.head.children),Tt=p(this,c,Bt).call(this,kt,Ct),Ft=p(this,c,yt).call(this,kt,Tt),at=p(this,c,yt).call(this,Ct,Tt);at.forEach((o,k)=>{if(o.tagName==="SCRIPT"&&o.getAttribute("src")){const y=document.createElement("script"),q=o.getAttribute("src");q.includes("http")||(y.type="module"),y.src=q,at[k]=y}}),at.forEach(o=>{document.head.appendChild(o)});const ft=at.filter(o=>{if(o.hasAttribute("data-no-waiting"))return!1;if(p(this,c,bt).call(this,o))return!0});e(this,A).waitForHeadToLoad&&ft.length&&(yield new Promise(o=>X(this,null,function*(){let k=0;try{for(var y=Dt(ft),q,W,Y;q=!(W=yield y.next()).done;q=!1){const lt=W.value;lt.onload=()=>{k++,k===ft.length&&o()}}}catch(W){Y=[W]}finally{try{q&&(W=y.return)&&(yield W.call(y))}finally{if(Y)throw Y[0]}}}))),yield It.wait(10);const Mt=[];Ft.forEach(o=>{o.hasAttribute("data-permanent")||(p(this,c,bt).call(this,o)?Mt.push(o):o.remove())});const Ot=p(this,c,wt).call(this,m.document.body);e(this,A).morphInsideScrollContainer||p(this,c,Lt).call(this,m.document),document.documentElement.setAttribute("data-current-pathname",d.pathname),document.documentElement.setAttribute("data-current-leaf",d.leaf),ct.changeHistory({action:s,pathname:d.pathname,searchParameters:d.parameters||(H?location.search:""),hash:d.hash}),e(this,$).remove(),n(this,it,e(this,f)),n(this,f,d.path),e(this,Q).forEach((o,k)=>{const y=Ot[k],q=getComputedStyle(o).getPropertyValue("--morph-duration");let W=[],Y=[];v?v.forEach(h=>{const S=o.querySelector(h),D=y.querySelector(h);S&&D&&(Y.push(S),W.push(D))}):(W.push(...y.childNodes),Y.push(...o.childNodes)),Y.forEach(h=>{h instanceof HTMLElement&&(this.destroyOldLinks(h),h.classList.add("old"))}),W.forEach(h=>{h instanceof HTMLElement&&(this.findNewLinks(h),h.classList.add("new"))}),v?W.forEach((h,S)=>{var D;(D=Y[S].parentElement)==null||D.insertBefore(h,Y[S])}):o.prepend(...W),$t.requestIdleCallback(()=>{Y.forEach(h=>{h instanceof HTMLElement&&h.classList.add("old-idle")}),W.forEach(h=>{var S;h instanceof HTMLElement&&((S=h.parentElement)==null||S.style.setProperty("--new-content-height",h.offsetHeight+"px"),h.classList.add("new-idle"))})});const lt=Et(pt({},mt),{morphElement:o});j.dispatchEvent(document,"morphNewChildrenAdded",{detail:lt});const Wt=new Promise(h=>{setTimeout(()=>{Y.forEach(S=>S.remove()),W.forEach(S=>{var D;S instanceof HTMLElement&&((D=S.parentElement)==null||D.style.removeProperty("--new-content-height"),S.classList.remove("new-idle","new"))}),j.dispatchEvent(document,"morphOldChildrenRemoved",{detail:lt}),h()},(parseFloat(q)||0)*1e3+10)});e(this,F).push(Wt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-m.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),j.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:m.scrollState}),d.hash?(m.clearScrollState(),p(this,c,Pt).call(this,d.hash,{centerScroll:i,offsetScroll:u})):e(this,M)?m.restoreScrollPosition():m.renewScrollPosition(),yield Promise.all(e(this,F)),Mt.forEach(o=>o.remove()),n(this,F,[]),e(this,Q).forEach(o=>{o.querySelectorAll("script").forEach(y=>{const q=document.createElement("script");q.type="module",q.src=y.getAttribute("src"),y.replaceWith(q)})}),j.dispatchEvent(document,"morphComplete",{detail:mt}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(N){console.error(N)}n(this,B,void 0)})}addLink(t){e(this,E).push(new St(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,E,e(this,E).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(this,E,e(this,E).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,nt));e(this,E).push(...s.map(i=>new St(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,nt));e(this,E).forEach(s=>s.destroy()),n(this,E,t.map(s=>new St(s,this)))}};A=new WeakMap,Q=new WeakMap,E=new WeakMap,B=new WeakMap,f=new WeakMap,it=new WeakMap,F=new WeakMap,M=new WeakMap,L=new WeakMap,rt=new WeakMap,x=new WeakMap,$=new WeakMap,Z=new WeakMap,_=new WeakMap,nt=new WeakMap,c=new WeakSet,ht=function(t){let s=t.split("#")[0],i=e(this,x).get(s);return i||(i=new Rt(this,s),e(this,x).set(s,i)),i},wt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Bt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},yt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},bt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Lt=function(t){var s,i;(s=e(this,L))==null||s.removeEventListener("scroll",e(this,tt)),n(this,_,0),n(this,Z,0),n(this,L,e(this,A).scrollSelector&&t.querySelector(e(this,A).scrollSelector)||window),n(this,rt,e(this,L)===window),(i=e(this,L))==null||i.addEventListener("scroll",e(this,tt)),e(this,tt).call(this)},Pt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&It.scrollToElement(i,{scrollElement:e(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ut=new WeakMap,tt=new WeakMap,et.instance=null;let vt=et;exports.Morph=vt;
|
|
1
|
+
"use strict";var Yt=Object.defineProperty,Xt=Object.defineProperties;var jt=Object.getOwnPropertyDescriptors;var Ht=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable;var xt=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),qt=r=>{throw TypeError(r)};var Nt=(r,t,s)=>t in r?Yt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s,pt=(r,t)=>{for(var s in t||(t={}))Ut.call(t,s)&&Nt(r,s,t[s]);if(Ht)for(var s of Ht(t))Kt.call(t,s)&&Nt(r,s,t[s]);return r},Et=(r,t)=>Xt(r,jt(t));var gt=(r,t,s)=>t.has(r)||qt("Cannot "+s);var e=(r,t,s)=>(gt(r,t,"read from private field"),s?s.call(r):t.get(r)),a=(r,t,s)=>t.has(r)?qt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,s),n=(r,t,s,i)=>(gt(r,t,"write to private field"),i?i.call(r,s):t.set(r,s),s),E=(r,t,s)=>(gt(r,t,"access private method"),s);var X=(r,t,s)=>new Promise((i,u)=>{var y=S=>{try{w(s.next(S))}catch(Y){u(Y)}},q=S=>{try{w(s.throw(S))}catch(Y){u(Y)}},w=S=>S.done?i(S.value):Promise.resolve(S.value).then(y,q);w((s=s.apply(r,t)).next())});var Dt=(r,t,s)=>(t=r[xt("asyncIterator")])?t.call(r):(r=r[xt("iterator")](),t={},s=(i,u)=>(u=r[i])&&(t[i]=y=>new Promise((q,w,S)=>(y=u.call(r,y),S=y.done,Promise.resolve(y.value).then(Y=>q({value:Y,done:S}),w)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vt=require("../index-DekP7OZe.cjs"),j=require("../events-KVanG9sR.cjs"),$t=require("../polyfills-Df4r-ETT.cjs"),It=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const ct=require("../url-BT4fssbO.cjs"),Gt=require("../css-value-parser/index.cjs");class zt 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)}}Vt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",zt);var M,l,V,st,G;class St{constructor(t,s){a(this,M);a(this,l);a(this,V);a(this,st,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,M).previousPathname)history.back();else{n(this,V,e(this,l).getAttribute("href")||"/");const u=e(this,l).getAttribute("data-history-action")||"push",y=e(this,l).hasAttribute("data-center-scroll"),q=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),w=q?Gt.cssValueParser.parse(q):void 0,S=e(this,l).hasAttribute("data-revalidate"),Y=e(this,l).hasAttribute("data-keep-search-parameters"),d=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(D=>D.trim()),ot=e(this,l).hasAttribute("data-clear-state");e(this,M).navigate(e(this,V),{historyAction:u,centerScroll:y,offsetScroll:w,revalidate:S,keepSearchParameters:Y,submorph:d,clearState:ot})}});a(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,M).prefetch(e(this,V),t),e(this,l).removeEventListener("pointerenter",e(this,G))});n(this,M,s),n(this,l,t),n(this,V,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,st)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,G))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,M).normalizePath(t),i=e(this,M).normalizePath(e(this,V));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,st)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current")}}M=new WeakMap,l=new WeakMap,V=new WeakMap,st=new WeakMap,G=new WeakMap;const Jt=new DOMParser;var H,z,b,k,U,B,J,K,F;class Rt{constructor(t,s){a(this,H);a(this,z);a(this,b,{x:0,y:0});a(this,k,null);a(this,U,null);a(this,B,null);a(this,J,null);a(this,K,null);a(this,F,null);n(this,H,t),n(this,z,s)}get path(){return e(this,z)}get scrollState(){return e(this,b)}get document(){return e(this,B)}setInitialDocument(t){n(this,k,t.cloneNode(!0))}abort(){var t;return(t=e(this,K))==null?void 0:t.abort(`[${e(this,z)}] page loading cancelled`)}fetch(t){return X(this,null,function*(){return e(this,F)||e(this,k)&&e(this,k).documentElement.hasAttribute("data-cache")&&!t||e(this,k)&&e(this,H).isPopstateNavigation?e(this,F):(n(this,F,new Promise(s=>X(this,null,function*(){try{n(this,K,new AbortController);const u=yield(yield fetch(e(this,z),{signal:e(this,K).signal})).text(),y=Jt.parseFromString(u,"text/html");this.setInitialDocument(y)}catch(i){console.warn(i)}finally{n(this,K,null),n(this,F,null),s()}}))),e(this,F))})}cloneDocument(){n(this,B,(e(this,U)||e(this,k)).cloneNode(!0))}get title(){let t="";if(e(this,B).title)t=e(this,B).title;else{const s=e(this,B).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,z)}return t}clearScrollState(){e(this,b).x=0,e(this,b).y=0}clearDocumentState(){n(this,U,null)}saveScrollState(){e(this,k).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,b).x=0,e(this,b).y=0):(e(this,b).x=e(this,H).scrollValue.left,e(this,b).y=e(this,H).scrollValue.top)}restoreScrollPosition(){e(this,H).scrollElement.scroll({top:e(this,b).y,left:e(this,b).x,behavior:"instant"})}saveDocumentState(){e(this,k).documentElement.hasAttribute("data-no-page-restoration")?n(this,U,null):n(this,U,document.cloneNode(!0))}renewScrollPosition(){e(this,H).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,J,t)}clearState(){const t=e(this,J);return n(this,J,null),t}}H=new WeakMap,z=new WeakMap,b=new WeakMap,k=new WeakMap,U=new WeakMap,B=new WeakMap,J=new WeakMap,K=new WeakMap,F=new WeakMap;var C,Q,g,O,f,it,W,x,P,rt,N,$,Z,_,nt,c,ht,wt,Bt,yt,bt,Lt,Pt,ut,tt;const et=class et{constructor(t){a(this,c);a(this,C,null);a(this,Q,null);a(this,g,[]);a(this,O);a(this,f,null);a(this,it);a(this,W,[]);a(this,x,!1);a(this,P,null);a(this,rt,!1);a(this,N,new Map);a(this,$,null);a(this,Z,0);a(this,_,0);a(this,nt,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});a(this,ut,t=>X(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),n(this,x,!0),yield this.navigate(t.state.path,{historyAction:"none"}),n(this,x,!1))}));a(this,tt,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,_),u=t-e(this,Z);n(this,_,s),n(this,Z,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",u>0),document.documentElement.classList.toggle("scroll-x-backward",u<0),j.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Vt.isBrowser&&!et.instance){et.instance=this,n(this,C,{base:ct.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,Q,E(this,c,wt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,f,s.path);const i=new Rt(this,e(this,f));i.setInitialDocument(document),e(this,N).set(e(this,f),i),document.documentElement.setAttribute("data-current-pathname",e(this,f)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,ut)),ct.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),n(this,$,new zt),E(this,c,Lt).call(this,document)}}get currentPath(){return e(this,f)}get previousPathname(){return e(this,it)}get links(){return e(this,g)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,x)}get scrollValue(){let t=0,s=0;return e(this,rt)?(t=window.scrollY,s=window.scrollX):(t=e(this,P).scrollTop,s=e(this,P).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,N).get(e(this,f));s&&s.saveState(t)}getState(){const t=e(this,N).get(e(this,f));return t==null?void 0:t.clearState()}normalizePath(t){return ct.splitPath(t,{base:e(this,C).base,trailingSlash:e(this,C).trailingSlash})}prefetch(t,s){return X(this,null,function*(){if(e(this,W).length)return;const i=E(this,c,ht).call(this,t);i==null||i.fetch(s)})}navigate(Y){return X(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:y,keepSearchParameters:q,submorph:w,clearState:S}={}){var ot;if(e(this,W).length)return;const d=this.normalizePath(((ot=this.pathnameModifier)==null?void 0:ot.call(this,t))||t);if(e(this,O)===d.path||e(this,f)===d.path){e(this,x)||E(this,c,Pt).call(this,d.hash||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}n(this,O,d.path),e(this,g).forEach(D=>{D.checkCurrent(d.path)});try{let D=!0;if(this.preprocessor)try{yield new Promise((o,T)=>{var p;(p=this.preprocessor)==null||p.call(this,{path:t,resolve:o,reject:T,submorph:w})})}catch(o){o?console.error(o):console.log("Route change canceled"),D=!1}if(!D||e(this,O)!==d.path){e(this,g).forEach(o=>{o.checkCurrent(e(this,f))});return}const At={path:d.path,submorph:w};j.dispatchEvent(document,"morphNavigation",{detail:At});const dt=E(this,c,ht).call(this,e(this,f)),m=E(this,c,ht).call(this,t);if(e(this,N).forEach(o=>{o.path!==d.path&&o.abort()}),yield m==null?void 0:m.fetch(y),e(this,O)!==d.path){e(this,g).forEach(o=>{o.checkCurrent(e(this,f))});return}dt.clearState(),dt.saveScrollState(),dt.saveDocumentState(),e(this,x)||(m.clearScrollState(),m.clearDocumentState()),S&&m.clearState(),m.cloneDocument(),e(this,$).textContent=m.title,document.body.appendChild(e(this,$));const mt=Et(pt({},At),{document:m.document});j.dispatchEvent(document,"morphStart",{detail:mt});const kt=Array.from(document.head.children),Ct=Array.from(m.document.head.children),Tt=E(this,c,Bt).call(this,kt,Ct),Ft=E(this,c,yt).call(this,kt,Tt),at=E(this,c,yt).call(this,Ct,Tt);at.forEach((o,T)=>{if(o.tagName==="SCRIPT"&&o.getAttribute("src")){const p=document.createElement("script"),I=o.getAttribute("src");I.includes("http")||(p.type="module"),p.src=I,at[T]=p}}),at.forEach(o=>{document.head.appendChild(o)});const ft=at.filter(o=>{if(o.hasAttribute("data-no-waiting"))return!1;if(E(this,c,bt).call(this,o))return!0});e(this,C).waitForHeadToLoad&&ft.length&&(yield new Promise(o=>X(this,null,function*(){let T=0;try{for(var p=Dt(ft),I,L,A;I=!(L=yield p.next()).done;I=!1){const lt=L.value;lt.onload=()=>{T++,T===ft.length&&o()}}}catch(L){A=[L]}finally{try{I&&(L=p.return)&&(yield L.call(p))}finally{if(A)throw A[0]}}}))),yield It.wait(10);const Mt=[];Ft.forEach(o=>{o.hasAttribute("data-permanent")||(E(this,c,bt).call(this,o)?Mt.push(o):o.remove())});const Ot=E(this,c,wt).call(this,m.document.body);e(this,C).morphInsideScrollContainer||E(this,c,Lt).call(this,m.document),document.documentElement.setAttribute("data-current-pathname",d.pathname),document.documentElement.setAttribute("data-current-leaf",d.leaf),ct.changeHistory({action:s,pathname:d.pathname,searchParameters:d.parameters||(q?location.search:""),hash:d.hash}),e(this,$).remove(),n(this,it,e(this,f)),n(this,f,d.path),e(this,Q).forEach((o,T)=>{const p=Ot[T],I=getComputedStyle(o).getPropertyValue("--morph-duration");let L=[],A=[];w?w.forEach(h=>{const v=o.querySelector(h),R=p.querySelector(h);v&&R&&(A.push(v),L.push(R))}):(L.push(...p.childNodes),A.push(...o.childNodes)),A.forEach(h=>{h instanceof HTMLElement&&(this.destroyOldLinks(h),h.classList.add("old"))}),L.forEach(h=>{h instanceof HTMLElement&&(this.findNewLinks(h),h.classList.add("new"))}),w?L.forEach((h,v)=>{var R;(R=A[v].parentElement)==null||R.insertBefore(h,A[v])}):o.prepend(...L),$t.requestIdleCallback(()=>{A.forEach(h=>{h instanceof HTMLElement&&h.classList.add("old-idle")}),L.forEach(h=>{var v;h instanceof HTMLElement&&((v=h.parentElement)==null||v.style.setProperty("--new-content-height",h.offsetHeight+"px"),h.classList.add("new-idle"))})});const lt=Et(pt({},mt),{morphElement:o});j.dispatchEvent(document,"morphNewChildrenAdded",{detail:lt});const Wt=new Promise(h=>{setTimeout(()=>{A.forEach(v=>v.remove()),L.forEach(v=>{var R;v instanceof HTMLElement&&((R=v.parentElement)==null||R.style.removeProperty("--new-content-height"),v.classList.remove("new-idle","new"))}),j.dispatchEvent(document,"morphOldChildrenRemoved",{detail:lt}),h()},(parseFloat(I)||0)*1e3+10)});e(this,W).push(Wt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-m.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),j.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:m.scrollState}),d.hash?(m.clearScrollState(),E(this,c,Pt).call(this,d.hash,{centerScroll:i,offsetScroll:u})):e(this,x)?m.restoreScrollPosition():m.renewScrollPosition(),yield Promise.all(e(this,W)),Mt.forEach(o=>o.remove()),n(this,W,[]),e(this,Q).forEach(o=>{o.querySelectorAll("script").forEach(p=>{const I=document.createElement("script");for(let L=0;L<p.attributes.length;L++){const A=p.attributes[L];I.setAttribute(A.name,A.value)}p.hasAttribute("src")||(I.innerHTML=p.innerHTML),p.replaceWith(I)})}),j.dispatchEvent(document,"morphComplete",{detail:mt}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(D){console.error(D)}n(this,O,void 0)})}addLink(t){e(this,g).push(new St(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,g,e(this,g).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(this,g,e(this,g).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,nt));e(this,g).push(...s.map(i=>new St(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,nt));e(this,g).forEach(s=>s.destroy()),n(this,g,t.map(s=>new St(s,this)))}};C=new WeakMap,Q=new WeakMap,g=new WeakMap,O=new WeakMap,f=new WeakMap,it=new WeakMap,W=new WeakMap,x=new WeakMap,P=new WeakMap,rt=new WeakMap,N=new WeakMap,$=new WeakMap,Z=new WeakMap,_=new WeakMap,nt=new WeakMap,c=new WeakSet,ht=function(t){let s=t.split("#")[0],i=e(this,N).get(s);return i||(i=new Rt(this,s),e(this,N).set(s,i)),i},wt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Bt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},yt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},bt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Lt=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,tt)),n(this,_,0),n(this,Z,0),n(this,P,e(this,C).scrollSelector&&t.querySelector(e(this,C).scrollSelector)||window),n(this,rt,e(this,P)===window),(i=e(this,P))==null||i.addEventListener("scroll",e(this,tt)),e(this,tt).call(this)},Pt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&It.scrollToElement(i,{scrollElement:e(this,P),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ut=new WeakMap,tt=new WeakMap,et.instance=null;let vt=et;exports.Morph=vt;
|
package/lib/morph/index.js
CHANGED
|
@@ -2,36 +2,36 @@ var Ot = Object.defineProperty, Yt = Object.defineProperties;
|
|
|
2
2
|
var Xt = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var Tt = Object.getOwnPropertySymbols;
|
|
4
4
|
var Ut = Object.prototype.hasOwnProperty, jt = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var
|
|
5
|
+
var Ht = (r, t) => (t = Symbol[r]) ? t : Symbol.for("Symbol." + r), xt = (r) => {
|
|
6
6
|
throw TypeError(r);
|
|
7
7
|
};
|
|
8
|
-
var
|
|
8
|
+
var Mt = (r, t, s) => t in r ? Ot(r, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[t] = s, ft = (r, t) => {
|
|
9
9
|
for (var s in t || (t = {}))
|
|
10
|
-
Ut.call(t, s) &&
|
|
10
|
+
Ut.call(t, s) && Mt(r, s, t[s]);
|
|
11
11
|
if (Tt)
|
|
12
12
|
for (var s of Tt(t))
|
|
13
|
-
jt.call(t, s) &&
|
|
13
|
+
jt.call(t, s) && Mt(r, s, t[s]);
|
|
14
14
|
return r;
|
|
15
15
|
}, pt = (r, t) => Yt(r, Xt(t));
|
|
16
|
-
var Et = (r, t, s) => t.has(r) ||
|
|
17
|
-
var e = (r, t, s) => (Et(r, t, "read from private field"), s ? s.call(r) : t.get(r)), a = (r, t, s) => t.has(r) ?
|
|
16
|
+
var Et = (r, t, s) => t.has(r) || xt("Cannot " + s);
|
|
17
|
+
var e = (r, t, s) => (Et(r, t, "read from private field"), s ? s.call(r) : t.get(r)), a = (r, t, s) => t.has(r) ? xt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, s), n = (r, t, s, i) => (Et(r, t, "write to private field"), i ? i.call(r, s) : t.set(r, s), s), E = (r, t, s) => (Et(r, t, "access private method"), s);
|
|
18
18
|
var X = (r, t, s) => new Promise((i, u) => {
|
|
19
|
-
var
|
|
19
|
+
var v = (S) => {
|
|
20
20
|
try {
|
|
21
|
-
|
|
22
|
-
} catch (
|
|
23
|
-
u(
|
|
21
|
+
y(s.next(S));
|
|
22
|
+
} catch (Y) {
|
|
23
|
+
u(Y);
|
|
24
24
|
}
|
|
25
|
-
},
|
|
25
|
+
}, D = (S) => {
|
|
26
26
|
try {
|
|
27
|
-
|
|
28
|
-
} catch (
|
|
29
|
-
u(
|
|
27
|
+
y(s.throw(S));
|
|
28
|
+
} catch (Y) {
|
|
29
|
+
u(Y);
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
|
|
31
|
+
}, y = (S) => S.done ? i(S.value) : Promise.resolve(S.value).then(v, D);
|
|
32
|
+
y((s = s.apply(r, t)).next());
|
|
33
33
|
});
|
|
34
|
-
var Nt = (r, t, s) => (t = r[
|
|
34
|
+
var Nt = (r, t, s) => (t = r[Ht("asyncIterator")]) ? t.call(r) : (r = r[Ht("iterator")](), t = {}, s = (i, u) => (u = r[i]) && (t[i] = (v) => new Promise((D, y, S) => (v = u.call(r, v), S = v.done, Promise.resolve(v.value).then((Y) => D({ value: Y, done: S }), y)))), s("next"), s("return"), t);
|
|
35
35
|
import { i as Vt } from "../index-Bv9zgfdb.js";
|
|
36
36
|
import { d as U } from "../events-CsVF98U6.js";
|
|
37
37
|
import { r as Kt } from "../polyfills-DJrTJQky.js";
|
|
@@ -51,29 +51,29 @@ class qt extends HTMLElement {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
Vt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", qt);
|
|
54
|
-
var
|
|
54
|
+
var H, l, q, st, G;
|
|
55
55
|
class gt {
|
|
56
56
|
constructor(t, s) {
|
|
57
|
-
a(this,
|
|
57
|
+
a(this, H);
|
|
58
58
|
a(this, l);
|
|
59
|
-
a(this,
|
|
59
|
+
a(this, q);
|
|
60
60
|
a(this, st, (t) => {
|
|
61
61
|
var i;
|
|
62
|
-
if (t.preventDefault(), e(this, l).hasAttribute("data-back") && e(this,
|
|
62
|
+
if (t.preventDefault(), e(this, l).hasAttribute("data-back") && e(this, H).previousPathname)
|
|
63
63
|
history.back();
|
|
64
64
|
else {
|
|
65
|
-
n(this,
|
|
65
|
+
n(this, q, e(this, l).getAttribute("href") || "/");
|
|
66
66
|
const u = e(this, l).getAttribute(
|
|
67
67
|
"data-history-action"
|
|
68
|
-
) || "push",
|
|
68
|
+
) || "push", v = e(this, l).hasAttribute("data-center-scroll"), D = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), y = D ? Zt.parse(D) : void 0, S = e(this, l).hasAttribute("data-revalidate"), Y = e(this, l).hasAttribute(
|
|
69
69
|
"data-keep-search-parameters"
|
|
70
|
-
), d = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((
|
|
71
|
-
e(this,
|
|
70
|
+
), d = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((I) => I.trim()), ot = e(this, l).hasAttribute("data-clear-state");
|
|
71
|
+
e(this, H).navigate(e(this, q), {
|
|
72
72
|
historyAction: u,
|
|
73
|
-
centerScroll:
|
|
74
|
-
offsetScroll:
|
|
75
|
-
revalidate:
|
|
76
|
-
keepSearchParameters:
|
|
73
|
+
centerScroll: v,
|
|
74
|
+
offsetScroll: y,
|
|
75
|
+
revalidate: S,
|
|
76
|
+
keepSearchParameters: Y,
|
|
77
77
|
submorph: d,
|
|
78
78
|
clearState: ot
|
|
79
79
|
});
|
|
@@ -81,82 +81,82 @@ class gt {
|
|
|
81
81
|
});
|
|
82
82
|
a(this, G, () => {
|
|
83
83
|
const t = e(this, l).hasAttribute("data-revalidate");
|
|
84
|
-
e(this,
|
|
84
|
+
e(this, H).prefetch(e(this, q), t), e(this, l).removeEventListener("pointerenter", e(this, G));
|
|
85
85
|
});
|
|
86
|
-
n(this,
|
|
86
|
+
n(this, H, s), n(this, l, t), n(this, q, e(this, l).getAttribute("href") || "/"), e(this, l).addEventListener("click", e(this, st)), this.checkCurrent(location.pathname), e(this, l).hasAttribute("data-prefetch") && e(this, l).addEventListener("pointerenter", e(this, G));
|
|
87
87
|
}
|
|
88
88
|
get element() {
|
|
89
89
|
return e(this, l);
|
|
90
90
|
}
|
|
91
91
|
checkCurrent(t) {
|
|
92
|
-
const s = e(this,
|
|
92
|
+
const s = e(this, H).normalizePath(t), i = e(this, H).normalizePath(e(this, q));
|
|
93
93
|
e(this, l).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? e(this, l).classList.add("current") : i.pathname === s.pathname ? e(this, l).classList.add("current") : e(this, l).classList.remove("current");
|
|
94
94
|
}
|
|
95
95
|
destroy() {
|
|
96
96
|
e(this, l).removeEventListener("click", e(this, st)), e(this, l).removeEventListener("pointerenter", e(this, G)), e(this, l).classList.remove("current");
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
H = new WeakMap(), l = new WeakMap(), q = new WeakMap(), st = new WeakMap(), G = new WeakMap();
|
|
100
100
|
const _t = new DOMParser();
|
|
101
|
-
var
|
|
101
|
+
var M, z, b, k, j, F, J, K, W;
|
|
102
102
|
class It {
|
|
103
103
|
constructor(t, s) {
|
|
104
|
-
a(this,
|
|
105
|
-
a(this,
|
|
104
|
+
a(this, M);
|
|
105
|
+
a(this, z);
|
|
106
106
|
a(this, b, { x: 0, y: 0 });
|
|
107
|
-
a(this,
|
|
107
|
+
a(this, k, null);
|
|
108
108
|
a(this, j, null);
|
|
109
|
-
a(this,
|
|
109
|
+
a(this, F, null);
|
|
110
110
|
a(this, J, null);
|
|
111
111
|
a(this, K, null);
|
|
112
|
-
a(this,
|
|
113
|
-
n(this,
|
|
112
|
+
a(this, W, null);
|
|
113
|
+
n(this, M, t), n(this, z, s);
|
|
114
114
|
}
|
|
115
115
|
get path() {
|
|
116
|
-
return e(this,
|
|
116
|
+
return e(this, z);
|
|
117
117
|
}
|
|
118
118
|
get scrollState() {
|
|
119
119
|
return e(this, b);
|
|
120
120
|
}
|
|
121
121
|
get document() {
|
|
122
|
-
return e(this,
|
|
122
|
+
return e(this, F);
|
|
123
123
|
}
|
|
124
124
|
setInitialDocument(t) {
|
|
125
|
-
n(this,
|
|
125
|
+
n(this, k, t.cloneNode(!0));
|
|
126
126
|
}
|
|
127
127
|
abort() {
|
|
128
128
|
var t;
|
|
129
129
|
return (t = e(this, K)) == null ? void 0 : t.abort(
|
|
130
|
-
`[${e(this,
|
|
130
|
+
`[${e(this, z)}] page loading cancelled`
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
133
|
fetch(t) {
|
|
134
134
|
return X(this, null, function* () {
|
|
135
|
-
return e(this,
|
|
135
|
+
return e(this, W) || e(this, k) && e(this, k).documentElement.hasAttribute("data-cache") && !t || e(this, k) && e(this, M).isPopstateNavigation ? e(this, W) : (n(this, W, new Promise((s) => X(this, null, function* () {
|
|
136
136
|
try {
|
|
137
137
|
n(this, K, new AbortController());
|
|
138
|
-
const u = yield (yield fetch(e(this,
|
|
138
|
+
const u = yield (yield fetch(e(this, z), {
|
|
139
139
|
signal: e(this, K).signal
|
|
140
|
-
})).text(),
|
|
141
|
-
this.setInitialDocument(
|
|
140
|
+
})).text(), v = _t.parseFromString(u, "text/html");
|
|
141
|
+
this.setInitialDocument(v);
|
|
142
142
|
} catch (i) {
|
|
143
143
|
console.warn(i);
|
|
144
144
|
} finally {
|
|
145
|
-
n(this, K, null), n(this,
|
|
145
|
+
n(this, K, null), n(this, W, null), s();
|
|
146
146
|
}
|
|
147
|
-
}))), e(this,
|
|
147
|
+
}))), e(this, W));
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
cloneDocument() {
|
|
151
|
-
n(this,
|
|
151
|
+
n(this, F, (e(this, j) || e(this, k)).cloneNode(!0));
|
|
152
152
|
}
|
|
153
153
|
get title() {
|
|
154
154
|
let t = "";
|
|
155
|
-
if (e(this,
|
|
156
|
-
t = e(this,
|
|
155
|
+
if (e(this, F).title)
|
|
156
|
+
t = e(this, F).title;
|
|
157
157
|
else {
|
|
158
|
-
const s = e(this,
|
|
159
|
-
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this,
|
|
158
|
+
const s = e(this, F).querySelector("h1");
|
|
159
|
+
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, z);
|
|
160
160
|
}
|
|
161
161
|
return t;
|
|
162
162
|
}
|
|
@@ -167,24 +167,24 @@ class It {
|
|
|
167
167
|
n(this, j, null);
|
|
168
168
|
}
|
|
169
169
|
saveScrollState() {
|
|
170
|
-
e(this,
|
|
170
|
+
e(this, k).documentElement.hasAttribute(
|
|
171
171
|
"data-no-scroll-restoration"
|
|
172
|
-
) ? (e(this, b).x = 0, e(this, b).y = 0) : (e(this, b).x = e(this,
|
|
172
|
+
) ? (e(this, b).x = 0, e(this, b).y = 0) : (e(this, b).x = e(this, M).scrollValue.left, e(this, b).y = e(this, M).scrollValue.top);
|
|
173
173
|
}
|
|
174
174
|
restoreScrollPosition() {
|
|
175
|
-
e(this,
|
|
175
|
+
e(this, M).scrollElement.scroll({
|
|
176
176
|
top: e(this, b).y,
|
|
177
177
|
left: e(this, b).x,
|
|
178
178
|
behavior: "instant"
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
saveDocumentState() {
|
|
182
|
-
e(this,
|
|
182
|
+
e(this, k).documentElement.hasAttribute(
|
|
183
183
|
"data-no-page-restoration"
|
|
184
184
|
) ? n(this, j, null) : n(this, j, document.cloneNode(!0));
|
|
185
185
|
}
|
|
186
186
|
renewScrollPosition() {
|
|
187
|
-
e(this,
|
|
187
|
+
e(this, M).scrollElement.scroll({
|
|
188
188
|
top: 0,
|
|
189
189
|
left: 0,
|
|
190
190
|
behavior: "instant"
|
|
@@ -198,22 +198,22 @@ class It {
|
|
|
198
198
|
return n(this, J, null), t;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
|
|
202
|
-
var
|
|
201
|
+
M = new WeakMap(), z = new WeakMap(), b = new WeakMap(), k = new WeakMap(), j = new WeakMap(), F = new WeakMap(), J = new WeakMap(), K = new WeakMap(), W = new WeakMap();
|
|
202
|
+
var C, Q, g, B, f, it, O, x, A, rt, N, $, Z, _, nt, c, ct, St, zt, wt, yt, vt, bt, ht, tt;
|
|
203
203
|
const et = class et {
|
|
204
204
|
constructor(t) {
|
|
205
205
|
a(this, c);
|
|
206
|
-
a(this,
|
|
206
|
+
a(this, C, null);
|
|
207
207
|
a(this, Q, null);
|
|
208
|
-
a(this,
|
|
209
|
-
a(this,
|
|
208
|
+
a(this, g, []);
|
|
209
|
+
a(this, B);
|
|
210
210
|
a(this, f, null);
|
|
211
211
|
a(this, it);
|
|
212
|
-
a(this,
|
|
212
|
+
a(this, O, []);
|
|
213
213
|
a(this, x, !1);
|
|
214
|
-
a(this,
|
|
214
|
+
a(this, A, null);
|
|
215
215
|
a(this, rt, !1);
|
|
216
|
-
a(this,
|
|
216
|
+
a(this, N, /* @__PURE__ */ new Map());
|
|
217
217
|
a(this, $, null);
|
|
218
218
|
a(this, Z, 0);
|
|
219
219
|
a(this, _, 0);
|
|
@@ -247,19 +247,19 @@ const et = class et {
|
|
|
247
247
|
});
|
|
248
248
|
});
|
|
249
249
|
if (Vt && !et.instance) {
|
|
250
|
-
et.instance = this, n(this,
|
|
250
|
+
et.instance = this, n(this, C, {
|
|
251
251
|
base: Jt(t == null ? void 0 : t.base),
|
|
252
252
|
waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
|
|
253
253
|
trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
|
|
254
254
|
scrollSelector: t == null ? void 0 : t.scrollSelector,
|
|
255
255
|
morphInsideScrollContainer: (t == null ? void 0 : t.morphInsideScrollContainer) || !1
|
|
256
|
-
}), n(this, Q,
|
|
256
|
+
}), n(this, Q, E(this, c, St).call(this, document.body));
|
|
257
257
|
const s = this.normalizePath(
|
|
258
258
|
location.pathname + location.hash + location.search
|
|
259
259
|
);
|
|
260
260
|
n(this, f, s.path);
|
|
261
261
|
const i = new It(this, e(this, f));
|
|
262
|
-
i.setInitialDocument(document), e(this,
|
|
262
|
+
i.setInitialDocument(document), e(this, N).set(e(this, f), i), document.documentElement.setAttribute(
|
|
263
263
|
"data-current-pathname",
|
|
264
264
|
e(this, f)
|
|
265
265
|
), document.documentElement.setAttribute(
|
|
@@ -270,7 +270,7 @@ const et = class et {
|
|
|
270
270
|
pathname: s.pathname,
|
|
271
271
|
searchParameters: s.parameters,
|
|
272
272
|
hash: s.hash
|
|
273
|
-
}), n(this, $, new qt()),
|
|
273
|
+
}), n(this, $, new qt()), E(this, c, vt).call(this, document);
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
get currentPath() {
|
|
@@ -280,117 +280,117 @@ const et = class et {
|
|
|
280
280
|
return e(this, it);
|
|
281
281
|
}
|
|
282
282
|
get links() {
|
|
283
|
-
return e(this,
|
|
283
|
+
return e(this, g);
|
|
284
284
|
}
|
|
285
285
|
get scrollElement() {
|
|
286
|
-
return e(this,
|
|
286
|
+
return e(this, A);
|
|
287
287
|
}
|
|
288
288
|
get isPopstateNavigation() {
|
|
289
289
|
return e(this, x);
|
|
290
290
|
}
|
|
291
291
|
get scrollValue() {
|
|
292
292
|
let t = 0, s = 0;
|
|
293
|
-
return e(this, rt) ? (t = window.scrollY, s = window.scrollX) : (t = e(this,
|
|
293
|
+
return e(this, rt) ? (t = window.scrollY, s = window.scrollX) : (t = e(this, A).scrollTop, s = e(this, A).scrollLeft), { top: t, left: s };
|
|
294
294
|
}
|
|
295
295
|
saveState(t) {
|
|
296
|
-
const s = e(this,
|
|
296
|
+
const s = e(this, N).get(e(this, f));
|
|
297
297
|
s && s.saveState(t);
|
|
298
298
|
}
|
|
299
299
|
getState() {
|
|
300
|
-
const t = e(this,
|
|
300
|
+
const t = e(this, N).get(e(this, f));
|
|
301
301
|
return t == null ? void 0 : t.clearState();
|
|
302
302
|
}
|
|
303
303
|
normalizePath(t) {
|
|
304
304
|
return Qt(t, {
|
|
305
|
-
base: e(this,
|
|
306
|
-
trailingSlash: e(this,
|
|
305
|
+
base: e(this, C).base,
|
|
306
|
+
trailingSlash: e(this, C).trailingSlash
|
|
307
307
|
});
|
|
308
308
|
}
|
|
309
309
|
prefetch(t, s) {
|
|
310
310
|
return X(this, null, function* () {
|
|
311
|
-
if (e(this,
|
|
311
|
+
if (e(this, O).length)
|
|
312
312
|
return;
|
|
313
|
-
const i =
|
|
313
|
+
const i = E(this, c, ct).call(this, t);
|
|
314
314
|
i == null || i.fetch(s);
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
|
-
navigate(
|
|
317
|
+
navigate(Y) {
|
|
318
318
|
return X(this, arguments, function* (t, {
|
|
319
319
|
historyAction: s = "push",
|
|
320
320
|
centerScroll: i,
|
|
321
321
|
offsetScroll: u,
|
|
322
|
-
revalidate:
|
|
323
|
-
keepSearchParameters:
|
|
324
|
-
submorph:
|
|
325
|
-
clearState:
|
|
322
|
+
revalidate: v,
|
|
323
|
+
keepSearchParameters: D,
|
|
324
|
+
submorph: y,
|
|
325
|
+
clearState: S
|
|
326
326
|
} = {}) {
|
|
327
327
|
var ot;
|
|
328
|
-
if (e(this,
|
|
328
|
+
if (e(this, O).length)
|
|
329
329
|
return;
|
|
330
330
|
const d = this.normalizePath(
|
|
331
331
|
((ot = this.pathnameModifier) == null ? void 0 : ot.call(this, t)) || t
|
|
332
332
|
);
|
|
333
|
-
if (e(this,
|
|
334
|
-
e(this, x) ||
|
|
333
|
+
if (e(this, B) === d.path || e(this, f) === d.path) {
|
|
334
|
+
e(this, x) || E(this, c, bt).call(this, d.hash || 0, {
|
|
335
335
|
centerScroll: i,
|
|
336
336
|
offsetScroll: u,
|
|
337
337
|
behavior: "smooth"
|
|
338
338
|
});
|
|
339
339
|
return;
|
|
340
340
|
}
|
|
341
|
-
n(this,
|
|
342
|
-
|
|
341
|
+
n(this, B, d.path), e(this, g).forEach((I) => {
|
|
342
|
+
I.checkCurrent(d.path);
|
|
343
343
|
});
|
|
344
344
|
try {
|
|
345
|
-
let
|
|
345
|
+
let I = !0;
|
|
346
346
|
if (this.preprocessor)
|
|
347
347
|
try {
|
|
348
|
-
yield new Promise((o,
|
|
349
|
-
var
|
|
350
|
-
(
|
|
348
|
+
yield new Promise((o, T) => {
|
|
349
|
+
var p;
|
|
350
|
+
(p = this.preprocessor) == null || p.call(this, {
|
|
351
351
|
path: t,
|
|
352
352
|
resolve: o,
|
|
353
|
-
reject:
|
|
354
|
-
submorph:
|
|
353
|
+
reject: T,
|
|
354
|
+
submorph: y
|
|
355
355
|
});
|
|
356
356
|
});
|
|
357
357
|
} catch (o) {
|
|
358
|
-
o ? console.error(o) : console.log("Route change canceled"),
|
|
358
|
+
o ? console.error(o) : console.log("Route change canceled"), I = !1;
|
|
359
359
|
}
|
|
360
|
-
if (!
|
|
361
|
-
e(this,
|
|
360
|
+
if (!I || e(this, B) !== d.path) {
|
|
361
|
+
e(this, g).forEach((o) => {
|
|
362
362
|
o.checkCurrent(e(this, f));
|
|
363
363
|
});
|
|
364
364
|
return;
|
|
365
365
|
}
|
|
366
366
|
const Lt = {
|
|
367
367
|
path: d.path,
|
|
368
|
-
submorph:
|
|
368
|
+
submorph: y
|
|
369
369
|
};
|
|
370
370
|
U(document, "morphNavigation", {
|
|
371
371
|
detail: Lt
|
|
372
372
|
});
|
|
373
|
-
const ut =
|
|
374
|
-
if (e(this,
|
|
373
|
+
const ut = E(this, c, ct).call(this, e(this, f)), m = E(this, c, ct).call(this, t);
|
|
374
|
+
if (e(this, N).forEach((o) => {
|
|
375
375
|
o.path !== d.path && o.abort();
|
|
376
|
-
}), yield m == null ? void 0 : m.fetch(
|
|
377
|
-
e(this,
|
|
376
|
+
}), yield m == null ? void 0 : m.fetch(v), e(this, B) !== d.path) {
|
|
377
|
+
e(this, g).forEach((o) => {
|
|
378
378
|
o.checkCurrent(e(this, f));
|
|
379
379
|
});
|
|
380
380
|
return;
|
|
381
381
|
}
|
|
382
|
-
ut.clearState(), ut.saveScrollState(), ut.saveDocumentState(), e(this, x) || (m.clearScrollState(), m.clearDocumentState()),
|
|
382
|
+
ut.clearState(), ut.saveScrollState(), ut.saveDocumentState(), e(this, x) || (m.clearScrollState(), m.clearDocumentState()), S && m.clearState(), m.cloneDocument(), e(this, $).textContent = m.title, document.body.appendChild(e(this, $));
|
|
383
383
|
const dt = pt(ft({}, Lt), {
|
|
384
384
|
document: m.document
|
|
385
385
|
});
|
|
386
386
|
U(document, "morphStart", {
|
|
387
387
|
detail: dt
|
|
388
388
|
});
|
|
389
|
-
const
|
|
390
|
-
at.forEach((o,
|
|
389
|
+
const At = Array.from(document.head.children), Pt = Array.from(m.document.head.children), kt = E(this, c, zt).call(this, At, Pt), Ft = E(this, c, wt).call(this, At, kt), at = E(this, c, wt).call(this, Pt, kt);
|
|
390
|
+
at.forEach((o, T) => {
|
|
391
391
|
if (o.tagName === "SCRIPT" && o.getAttribute("src")) {
|
|
392
|
-
const
|
|
393
|
-
|
|
392
|
+
const p = document.createElement("script"), R = o.getAttribute("src");
|
|
393
|
+
R.includes("http") || (p.type = "module"), p.src = R, at[T] = p;
|
|
394
394
|
}
|
|
395
395
|
}), at.forEach((o) => {
|
|
396
396
|
document.head.appendChild(o);
|
|
@@ -398,35 +398,35 @@ const et = class et {
|
|
|
398
398
|
const mt = at.filter((o) => {
|
|
399
399
|
if (o.hasAttribute("data-no-waiting"))
|
|
400
400
|
return !1;
|
|
401
|
-
if (
|
|
401
|
+
if (E(this, c, yt).call(this, o))
|
|
402
402
|
return !0;
|
|
403
403
|
});
|
|
404
|
-
e(this,
|
|
405
|
-
let
|
|
404
|
+
e(this, C).waitForHeadToLoad && mt.length && (yield new Promise((o) => X(this, null, function* () {
|
|
405
|
+
let T = 0;
|
|
406
406
|
try {
|
|
407
|
-
for (var
|
|
408
|
-
const lt =
|
|
407
|
+
for (var p = Nt(mt), R, L, P; R = !(L = yield p.next()).done; R = !1) {
|
|
408
|
+
const lt = L.value;
|
|
409
409
|
lt.onload = () => {
|
|
410
|
-
|
|
410
|
+
T++, T === mt.length && o();
|
|
411
411
|
};
|
|
412
412
|
}
|
|
413
|
-
} catch (
|
|
414
|
-
|
|
413
|
+
} catch (L) {
|
|
414
|
+
P = [L];
|
|
415
415
|
} finally {
|
|
416
416
|
try {
|
|
417
|
-
|
|
417
|
+
R && (L = p.return) && (yield L.call(p));
|
|
418
418
|
} finally {
|
|
419
|
-
if (
|
|
420
|
-
throw
|
|
419
|
+
if (P)
|
|
420
|
+
throw P[0];
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
423
|
}))), yield $t(10);
|
|
424
424
|
const Ct = [];
|
|
425
425
|
Ft.forEach((o) => {
|
|
426
|
-
o.hasAttribute("data-permanent") || (
|
|
426
|
+
o.hasAttribute("data-permanent") || (E(this, c, yt).call(this, o) ? Ct.push(o) : o.remove());
|
|
427
427
|
});
|
|
428
|
-
const Wt =
|
|
429
|
-
e(this,
|
|
428
|
+
const Wt = E(this, c, St).call(this, m.document.body);
|
|
429
|
+
e(this, C).morphInsideScrollContainer || E(this, c, vt).call(this, m.document), document.documentElement.setAttribute(
|
|
430
430
|
"data-current-pathname",
|
|
431
431
|
d.pathname
|
|
432
432
|
), document.documentElement.setAttribute(
|
|
@@ -435,30 +435,30 @@ const et = class et {
|
|
|
435
435
|
), Dt({
|
|
436
436
|
action: s,
|
|
437
437
|
pathname: d.pathname,
|
|
438
|
-
searchParameters: d.parameters || (
|
|
438
|
+
searchParameters: d.parameters || (D ? location.search : ""),
|
|
439
439
|
hash: d.hash
|
|
440
|
-
}), e(this, $).remove(), n(this, it, e(this, f)), n(this, f, d.path), e(this, Q).forEach((o,
|
|
441
|
-
const
|
|
442
|
-
let
|
|
443
|
-
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
}) : (
|
|
440
|
+
}), e(this, $).remove(), n(this, it, e(this, f)), n(this, f, d.path), e(this, Q).forEach((o, T) => {
|
|
441
|
+
const p = Wt[T], R = getComputedStyle(o).getPropertyValue("--morph-duration");
|
|
442
|
+
let L = [], P = [];
|
|
443
|
+
y ? y.forEach((h) => {
|
|
444
|
+
const w = o.querySelector(h), V = p.querySelector(h);
|
|
445
|
+
w && V && (P.push(w), L.push(V));
|
|
446
|
+
}) : (L.push(...p.childNodes), P.push(...o.childNodes)), P.forEach((h) => {
|
|
447
447
|
h instanceof HTMLElement && (this.destroyOldLinks(h), h.classList.add("old"));
|
|
448
|
-
}),
|
|
448
|
+
}), L.forEach((h) => {
|
|
449
449
|
h instanceof HTMLElement && (this.findNewLinks(h), h.classList.add("new"));
|
|
450
|
-
}),
|
|
451
|
-
var
|
|
452
|
-
(
|
|
450
|
+
}), y ? L.forEach((h, w) => {
|
|
451
|
+
var V;
|
|
452
|
+
(V = P[w].parentElement) == null || V.insertBefore(
|
|
453
453
|
h,
|
|
454
|
-
|
|
454
|
+
P[w]
|
|
455
455
|
);
|
|
456
|
-
}) : o.prepend(...
|
|
457
|
-
|
|
456
|
+
}) : o.prepend(...L), Kt(() => {
|
|
457
|
+
P.forEach((h) => {
|
|
458
458
|
h instanceof HTMLElement && h.classList.add("old-idle");
|
|
459
|
-
}),
|
|
460
|
-
var
|
|
461
|
-
h instanceof HTMLElement && ((
|
|
459
|
+
}), L.forEach((h) => {
|
|
460
|
+
var w;
|
|
461
|
+
h instanceof HTMLElement && ((w = h.parentElement) == null || w.style.setProperty(
|
|
462
462
|
"--new-content-height",
|
|
463
463
|
h.offsetHeight + "px"
|
|
464
464
|
), h.classList.add("new-idle"));
|
|
@@ -472,17 +472,17 @@ const et = class et {
|
|
|
472
472
|
});
|
|
473
473
|
const Bt = new Promise((h) => {
|
|
474
474
|
setTimeout(() => {
|
|
475
|
-
|
|
476
|
-
var
|
|
477
|
-
|
|
475
|
+
P.forEach((w) => w.remove()), L.forEach((w) => {
|
|
476
|
+
var V;
|
|
477
|
+
w instanceof HTMLElement && ((V = w.parentElement) == null || V.style.removeProperty(
|
|
478
478
|
"--new-content-height"
|
|
479
|
-
),
|
|
479
|
+
), w.classList.remove("new-idle", "new"));
|
|
480
480
|
}), U(document, "morphOldChildrenRemoved", {
|
|
481
481
|
detail: lt
|
|
482
482
|
}), h();
|
|
483
|
-
}, (parseFloat(
|
|
483
|
+
}, (parseFloat(R) || 0) * 1e3 + 10);
|
|
484
484
|
});
|
|
485
|
-
e(this,
|
|
485
|
+
e(this, O).push(Bt);
|
|
486
486
|
}), this.isPopstateNavigation ? document.documentElement.style.setProperty(
|
|
487
487
|
"--new-document-scroll-position",
|
|
488
488
|
(this.scrollValue.top - m.scrollState.y) * 1 + "px"
|
|
@@ -491,27 +491,31 @@ const et = class et {
|
|
|
491
491
|
this.scrollValue.top + "px"
|
|
492
492
|
), U(document, "morphBeforeNavigationScroll", {
|
|
493
493
|
detail: m.scrollState
|
|
494
|
-
}), d.hash ? (m.clearScrollState(),
|
|
494
|
+
}), d.hash ? (m.clearScrollState(), E(this, c, bt).call(this, d.hash, {
|
|
495
495
|
centerScroll: i,
|
|
496
496
|
offsetScroll: u
|
|
497
|
-
})) : e(this, x) ? m.restoreScrollPosition() : m.renewScrollPosition(), yield Promise.all(e(this,
|
|
498
|
-
o.querySelectorAll("script").forEach((
|
|
499
|
-
const
|
|
500
|
-
|
|
497
|
+
})) : e(this, x) ? m.restoreScrollPosition() : m.renewScrollPosition(), yield Promise.all(e(this, O)), Ct.forEach((o) => o.remove()), n(this, O, []), e(this, Q).forEach((o) => {
|
|
498
|
+
o.querySelectorAll("script").forEach((p) => {
|
|
499
|
+
const R = document.createElement("script");
|
|
500
|
+
for (let L = 0; L < p.attributes.length; L++) {
|
|
501
|
+
const P = p.attributes[L];
|
|
502
|
+
R.setAttribute(P.name, P.value);
|
|
503
|
+
}
|
|
504
|
+
p.hasAttribute("src") || (R.innerHTML = p.innerHTML), p.replaceWith(R);
|
|
501
505
|
});
|
|
502
506
|
}), U(document, "morphComplete", {
|
|
503
507
|
detail: dt
|
|
504
508
|
}), document.documentElement.style.removeProperty(
|
|
505
509
|
"--new-document-scroll-position"
|
|
506
510
|
), window.dispatchEvent(new Event("resize"));
|
|
507
|
-
} catch (
|
|
508
|
-
console.error(
|
|
511
|
+
} catch (I) {
|
|
512
|
+
console.error(I);
|
|
509
513
|
}
|
|
510
|
-
n(this,
|
|
514
|
+
n(this, B, void 0);
|
|
511
515
|
});
|
|
512
516
|
}
|
|
513
517
|
addLink(t) {
|
|
514
|
-
e(this,
|
|
518
|
+
e(this, g).push(new gt(t, this));
|
|
515
519
|
}
|
|
516
520
|
addLinks(t) {
|
|
517
521
|
t.forEach((s) => {
|
|
@@ -519,16 +523,16 @@ const et = class et {
|
|
|
519
523
|
});
|
|
520
524
|
}
|
|
521
525
|
removeLink(t) {
|
|
522
|
-
n(this,
|
|
526
|
+
n(this, g, e(this, g).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
|
|
523
527
|
}
|
|
524
528
|
destroyOldLinks(t) {
|
|
525
|
-
n(this,
|
|
529
|
+
n(this, g, e(this, g).filter((s) => t.contains(s.element) ? (s.destroy(), !1) : !0));
|
|
526
530
|
}
|
|
527
531
|
findNewLinks(t) {
|
|
528
532
|
const s = [...t.querySelectorAll("a")].filter(
|
|
529
533
|
e(this, nt)
|
|
530
534
|
);
|
|
531
|
-
e(this,
|
|
535
|
+
e(this, g).push(
|
|
532
536
|
...s.map((i) => new gt(i, this))
|
|
533
537
|
);
|
|
534
538
|
}
|
|
@@ -536,12 +540,12 @@ const et = class et {
|
|
|
536
540
|
const t = [
|
|
537
541
|
...document.documentElement.querySelectorAll("a")
|
|
538
542
|
].filter(e(this, nt));
|
|
539
|
-
e(this,
|
|
543
|
+
e(this, g).forEach((s) => s.destroy()), n(this, g, t.map((s) => new gt(s, this)));
|
|
540
544
|
}
|
|
541
545
|
};
|
|
542
|
-
|
|
543
|
-
let s = t.split("#")[0], i = e(this,
|
|
544
|
-
return i || (i = new It(this, s), e(this,
|
|
546
|
+
C = new WeakMap(), Q = new WeakMap(), g = new WeakMap(), B = new WeakMap(), f = new WeakMap(), it = new WeakMap(), O = new WeakMap(), x = new WeakMap(), A = new WeakMap(), rt = new WeakMap(), N = new WeakMap(), $ = new WeakMap(), Z = new WeakMap(), _ = new WeakMap(), nt = new WeakMap(), c = new WeakSet(), ct = function(t) {
|
|
547
|
+
let s = t.split("#")[0], i = e(this, N).get(s);
|
|
548
|
+
return i || (i = new It(this, s), e(this, N).set(s, i)), i;
|
|
545
549
|
}, St = function(t) {
|
|
546
550
|
const s = [...t.querySelectorAll("[data-morph]")];
|
|
547
551
|
return s.length ? s : [t];
|
|
@@ -561,14 +565,14 @@ A = new WeakMap(), Q = new WeakMap(), E = new WeakMap(), F = new WeakMap(), f =
|
|
|
561
565
|
return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
|
|
562
566
|
}, vt = function(t) {
|
|
563
567
|
var s, i;
|
|
564
|
-
(s = e(this,
|
|
568
|
+
(s = e(this, A)) == null || s.removeEventListener(
|
|
565
569
|
"scroll",
|
|
566
570
|
e(this, tt)
|
|
567
|
-
), n(this, _, 0), n(this, Z, 0), n(this,
|
|
571
|
+
), n(this, _, 0), n(this, Z, 0), n(this, A, e(this, C).scrollSelector && t.querySelector(e(this, C).scrollSelector) || window), n(this, rt, e(this, A) === window), (i = e(this, A)) == null || i.addEventListener("scroll", e(this, tt)), e(this, tt).call(this);
|
|
568
572
|
}, bt = function(t, s) {
|
|
569
573
|
const i = typeof t == "string" ? document.getElementById(t) : t;
|
|
570
574
|
(typeof i == "number" || i) && Gt(i, {
|
|
571
|
-
scrollElement: e(this,
|
|
575
|
+
scrollElement: e(this, A),
|
|
572
576
|
behavior: (s == null ? void 0 : s.behavior) || "instant",
|
|
573
577
|
center: s == null ? void 0 : s.centerScroll,
|
|
574
578
|
offset: s == null ? void 0 : s.offsetScroll
|
package/lib/popover/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var oe=l=>{throw TypeError(l)};var ee=(l,n,t)=>n.has(l)||oe("Cannot "+t);var e=(l,n,t)=>(ee(l,n,"read from private field"),t?t.call(l):n.get(l)),r=(l,n,t)=>n.has(l)?oe("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(l):n.set(l,t),o=(l,n,t,s)=>(ee(l,n,"write to private field"),s?s.call(l,t):n.set(l,t),t),p=(l,n,t)=>(ee(l,n,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ue=require("../element-linked-store/index.cjs"),E=require("../css-property/index.cjs"),ie=require("../index-DekP7OZe.cjs"),M=require("../events-KVanG9sR.cjs"),pe=require("../function-MthRj-GJ.cjs"),ne=require("../style-At6aDoqG.cjs");require("construct-style-sheets-polyfill");const he=require("../url-BT4fssbO.cjs"),le=require("../window-resizer/index.cjs"),Q=require("../Viewport-DB0qAZPJ.cjs");var d,w,_,N;class de{constructor(){r(this,d,new Map);r(this,w,[]);r(this,_,n=>{var s;const t=[...e(this,w)].reverse().find(i=>i.clickOutside.current);if(t){const i=n.composedPath();if(i.find(re=>re instanceof HTMLElement&&re.hasAttribute("data-popover-content")))return;const c=i[0],f=c instanceof Node&&(t.contains(c)||((s=t.shadowRoot)==null?void 0:s.contains(c))),F=c instanceof HTMLElement&&c.hasAttribute("data-outside");(!f||F)&&t.close()}});r(this,N,n=>{if(n.code==="Escape"){const t=[...e(this,w)].reverse().find(s=>s.escape.current);t&&t.close()}});document.documentElement.addEventListener("click",e(this,_)),addEventListener("keydown",e(this,N))}get groups(){return e(this,d)}get stack(){return e(this,w)}add(n,t){if(t.closeRest.current)e(this,d).forEach(i=>{i.forEach(c=>{c.close()})});else if(t.closeRestInGroup.current){let i=e(this,d).get(n);i==null||i.forEach(c=>{c.close()})}let s=e(this,d).get(n);s!=null&&s.length||(s=[],e(this,d).set(n,s)),e(this,w).push(t),s.push(t)}remove(n,t){if(o(this,w,e(this,w).filter(s=>s!==t)),t.closeRest.current){let s=[];e(this,d).forEach(i=>{i.forEach(c=>s.push(c))}),e(this,d).clear(),s.forEach(i=>i.close())}else if(t.closeRestInGroup.current){const s=e(this,d).get(n);e(this,d).delete(n),s==null||s.forEach(i=>{i.close()})}else{let s=e(this,d).get(n);s&&(s=s.filter(i=>i!==t),e(this,d).set(n,s))}}}d=new WeakMap,w=new WeakMap,_=new WeakMap,N=new WeakMap;var v,z,B,k,H,m,C,A,x,b,R,q,T,y,$,a,V,W,u,ce,L,Z,G,O,j,X,D;const S=class S extends HTMLElement{constructor(){super();r(this,u);r(this,v);r(this,z);r(this,B);r(this,k);r(this,H);r(this,m);r(this,C);r(this,A);r(this,x);r(this,b);r(this,R);r(this,q);r(this,T);r(this,y);r(this,$);r(this,a);r(this,V);r(this,W);r(this,G);r(this,O);r(this,j);r(this,X);r(this,D);this.urlValue="",o(this,v,!1),o(this,m,new E.CSSProperty(this,"--history",!1)),o(this,C,new E.CSSProperty(this,"--restore",!1)),o(this,A,new E.CSSProperty(this,"--close-rest",!1)),o(this,x,new E.CSSProperty(this,"--close-rest-in-group",!1)),o(this,b,new E.CSSProperty(this,"--group","")),o(this,R,new E.CSSProperty(this,"--click-outside",!1)),o(this,q,new E.CSSProperty(this,"--escape",!1)),o(this,T,new E.CSSProperty(this,"--check-viewport-bounds",!1)),o(this,y,!0),o(this,a,new ue.ElementLinkedStore(this,{triggered:!1,beforeopen:!1,opened:!1,closing:!1,transitionend:!1})),o(this,V,[]),o(this,W,[]),o(this,G,()=>{o(this,y,!1),e(this,v)&&e(this,m).current&&!location.search.includes(this.id)?this.close():!e(this,v)&&e(this,m).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),o(this,y,!0)}),o(this,O,()=>{this.style.setProperty("--content-width","initial"),this.style.setProperty("--content-height","initial"),this.style.setProperty("--viewport-offset-x","0px"),this.style.setProperty("--viewport-offset-y","0px"),e(this,j).call(this)}),o(this,j,pe.debounce(()=>{e(this,X).call(this)},10)),o(this,X,()=>{if(this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px"),e(this,T).current){const t=this.getBoundingClientRect();let s=0,i=0;t.right>Q.viewport.width?s=Q.viewport.width-t.right:t.left<0&&(s=t.left*-1),t.bottom>Q.viewport.height?i=Q.viewport.height-t.bottom:t.top<0&&(i=t.top*-1),this.style.setProperty("--viewport-offset-x",s+"px"),this.style.setProperty("--viewport-offset-y",i+"px")}}),o(this,D,()=>{this.close()}),e(this,b).subscribe(t=>{t.previous&&(S.stack.remove(t.previous,this),t.current||(document.documentElement.classList.remove(`${this.group.previous}-closing`),document.documentElement.classList.remove(`${this.group.previous}-opened`)))}),e(this,a).subscribe(t=>{if(this.group.current){document.documentElement.classList.toggle(`${this.group.current}-closing`,t.current.closing);const s=S.stack.groups.get(this.group.current),i=s==null?void 0:s.find(c=>c.opened);document.documentElement.classList.toggle(`${this.group.current}-opened`,!!i)}})}get openClass(){return this.getAttribute("data-open-global-class")}get closingClass(){return this.getAttribute("data-closing-global-class")}get history(){return e(this,m)}get restore(){return e(this,C)}get closeRest(){return e(this,A)}get closeRestInGroup(){return e(this,x)}get group(){return e(this,b)}get clickOutside(){return e(this,R)}get escape(){return e(this,q)}get opened(){return e(this,v)}get lastTrigger(){return e(this,$)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(t){this.urlValue=(t==null?void 0:t.toString())||"",e(this,v)&&he.updateSearchParameter(this.id,t)}open(t){if(e(this,v))return;o(this,$,t==null?void 0:t.trigger),clearTimeout(e(this,z)),clearTimeout(e(this,B)),p(this,u,L).call(this,!1,this.closingClass),e(this,a).set("closing",!1),e(this,a).set("triggered",!0),M.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,$)}}),e(this,m).current&&e(this,y)&&history.pushState(history.state,"",e(this,u,ce)),e(this,a).set("beforeopen",!0),o(this,v,!0);const s=()=>{S.stack.add(e(this,b).current,this),e(this,W).forEach(i=>{i.scroll({top:0,left:0,behavior:"instant"})}),p(this,u,L).call(this,!0,this.openClass),e(this,a).set("opened",!0),M.dispatchEvent(window,"resize"),M.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,$)},bubbles:!0}),o(this,k,void 0),o(this,H,setTimeout(()=>{e(this,a).set("transitionend",!0),M.dispatchEvent(this,"popoverTransitionend")},ne.getElementTransitionDurationMS(this)+10))};t!=null&&t.skipTransition?s():o(this,k,requestAnimationFrame(s))}close(){e(this,v)&&(o(this,v,!1),cancelAnimationFrame(e(this,k)),clearTimeout(e(this,H)),S.stack.remove(e(this,b).current,this),p(this,u,Z).call(this),p(this,u,L).call(this,!1,this.openClass),o(this,z,setTimeout(()=>{e(this,a).set("transitionend",!1),e(this,a).set("opened",!1),e(this,a).set("closing",!0),p(this,u,L).call(this,!0,this.closingClass),M.dispatchEvent(this,"popoverClosing",{custom:!0,bubbles:!0}),o(this,B,setTimeout(()=>{e(this,a).set("triggered",!1),e(this,a).set("beforeopen",!1),e(this,a).set("closing",!1),p(this,u,L).call(this,!1,this.closingClass),M.dispatchEvent(this,"popoverClosed",{custom:!0,bubbles:!0})},ne.getElementTransitionDurationMS(this)+10))},10)))}connectedCallback(){o(this,V,[...this.querySelectorAll(`[data-popover-close${this.id?`="${this.id}"`:""}]`)]),e(this,V).forEach(t=>{t.addEventListener("click",e(this,D))}),o(this,W,[...this.querySelectorAll(`[data-popover-reset-scroll${this.id?`="${this.id}"`:""}]`)]),e(this,m).observe(),e(this,C).observe(),e(this,A).observe(),e(this,x).observe(),e(this,b).observe(),e(this,R).observe(),e(this,q).observe(),e(this,T).observe(),this.setAttribute("role","dialog"),addEventListener("popstate",e(this,G)),setTimeout(()=>{e(this,C).current?(o(this,y,!1),this.urlValue=he.parseSearchParameters(location.search)[this.id],location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),o(this,y,!0)):(p(this,u,Z).call(this),o(this,y,!0))},0),e(this,T).subscribe(()=>{e(this,O).call(this)}),le.windowResizer.subscribe(e(this,O))}disconnectedCallback(){e(this,V).forEach(t=>{t.removeEventListener("click",e(this,D))}),S.stack.remove(e(this,b).current,this),le.windowResizer.unsubscribe(e(this,O)),e(this,m).close(),e(this,C).close(),e(this,A).close(),e(this,x).close(),e(this,b).close(),e(this,R).close(),e(this,q).close(),e(this,T).close(),this.removeAttribute("role"),p(this,u,L).call(this,!1,this.openClass),p(this,u,L).call(this,!1,this.closingClass),clearTimeout(e(this,z)),clearTimeout(e(this,B)),clearTimeout(e(this,k)),clearTimeout(e(this,H)),removeEventListener("popstate",e(this,G)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),p(this,u,Z).call(this)}};v=new WeakMap,z=new WeakMap,B=new WeakMap,k=new WeakMap,H=new WeakMap,m=new WeakMap,C=new WeakMap,A=new WeakMap,x=new WeakMap,b=new WeakMap,R=new WeakMap,q=new WeakMap,T=new WeakMap,y=new WeakMap,$=new WeakMap,a=new WeakMap,V=new WeakMap,W=new WeakMap,u=new WeakSet,ce=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},L=function(t,s){s&&s.split(" ").map(i=>{document.documentElement.classList.toggle(i.trim(),t)})},Z=function(){if(e(this,m).current){const t=new URL(location.href);t.searchParams.delete(this.id),history.replaceState(history.state,"",t.href)}},G=new WeakMap,O=new WeakMap,j=new WeakMap,X=new WeakMap,D=new WeakMap,S.stack=new de;let U=S;ie.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",U);var h,g,P,te,Y,I,J,K,se;class ae extends HTMLElement{constructor(){super();r(this,P);r(this,h);r(this,g,new E.CSSProperty(this,"--type","open"));r(this,Y,()=>{e(this,g).current!=="close"&&this.classList.add("triggered")});r(this,I,()=>{e(this,g).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))});r(this,J,()=>{e(this,g).current!=="close"&&this.classList.remove("opened")});r(this,K,()=>{e(this,g).current!=="close"&&(this.classList.remove("triggered"),this.setAttribute("aria-expanded","false"))});ie.isBrowser&&(this.addEventListener("click",()=>{if(e(this,h)){const t=e(this,g).current;t==="open"||t==="toggle"&&!e(this,h).opened?e(this,h).open({trigger:this}):(t==="close"||t==="toggle"&&e(this,h).opened)&&e(this,h).close()}}),this.addEventListener("keydown",t=>{t.code==="Space"&&!this.hasAttribute("keydown-disabled")&&(t.preventDefault(),this.click())}))}get type(){return e(this,g)}get popoverElement(){return e(this,h)}changePopover(t){var s;if(p(this,P,te).call(this),t){let i=null;if(t==="parent"){const c=this.closest("[data-popover]");if(c)i=c;else{const f=this.getRootNode();f instanceof ShadowRoot?i=f.host.closest("[data-popover]"):f instanceof HTMLElement&&(i=f.closest("[data-popover]"))}}else if(t==="sibling")i=(s=this.parentElement)==null?void 0:s.querySelector("[data-popover]");else if(t==="ancestor-child"){const c=f=>{if(!f)return null;let F=f.querySelector("[data-popover]");return!F&&(f!=null&&f.parentElement)&&(F=c(f.parentElement)),F};i=c(this.parentElement)||null}else!t.startsWith(".")&&!t.startsWith("[")&&(t=`#${t}`),i=document.querySelector(t)||this.getRootNode().querySelector(t);i instanceof HTMLElement?(o(this,h,i),e(this,h).addEventListener("popoverTriggered",e(this,Y)),e(this,h).addEventListener("popoverOpened",e(this,I)),e(this,h).addEventListener("popoverClosing",e(this,J)),e(this,h).addEventListener("popoverClosed",e(this,K))):console.warn(this,`target ${t} not found`)}p(this,P,se).call(this,e(this,g).current)}connectedCallback(){e(this,g).subscribe(s=>{p(this,P,se).call(this,s.current)}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("role")||this.setAttribute("role","button");const t=this.getAttribute("target");t&&this.changePopover(t),this.isConnected&&e(this,g).observe()}disconnectedCallback(){e(this,g).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),this.removeAttribute("role"),this.removeAttribute("tabindex"),p(this,P,te).call(this)}}h=new WeakMap,g=new WeakMap,P=new WeakSet,te=function(){e(this,h)&&(e(this,h).removeEventListener("popoverTriggered",e(this,Y)),e(this,h).removeEventListener("popoverOpened",e(this,I)),e(this,h).removeEventListener("popoverClosing",e(this,J)),e(this,h).removeEventListener("popoverClosed",e(this,K)))},Y=new WeakMap,I=new WeakMap,J=new WeakMap,K=new WeakMap,se=function(t){e(this,h)instanceof U&&(t!=="close"?(this.setAttribute("aria-haspopup","true"),this.setAttribute("aria-expanded",e(this,h).opened?"true":"false"),this.setAttribute("aria-controls",e(this,h).id||"")):(this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls")))};ie.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",ae);exports.PopoverButtonElement=ae;exports.PopoverElement=U;
|
|
1
|
+
"use strict";var oe=l=>{throw TypeError(l)};var ee=(l,n,t)=>n.has(l)||oe("Cannot "+t);var e=(l,n,t)=>(ee(l,n,"read from private field"),t?t.call(l):n.get(l)),r=(l,n,t)=>n.has(l)?oe("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(l):n.set(l,t),o=(l,n,t,s)=>(ee(l,n,"write to private field"),s?s.call(l,t):n.set(l,t),t),p=(l,n,t)=>(ee(l,n,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ue=require("../element-linked-store/index.cjs"),E=require("../css-property/index.cjs"),ie=require("../index-DekP7OZe.cjs"),M=require("../events-KVanG9sR.cjs"),pe=require("../function-MthRj-GJ.cjs"),ne=require("../style-At6aDoqG.cjs");require("construct-style-sheets-polyfill");const he=require("../url-BT4fssbO.cjs"),le=require("../window-resizer/index.cjs"),Q=require("../Viewport-DB0qAZPJ.cjs");var d,w,_,N;class de{constructor(){r(this,d,new Map);r(this,w,[]);r(this,_,n=>{var s;const t=[...e(this,w)].reverse().find(i=>i.clickOutside.current);if(t){const i=n.composedPath();if(i.find(re=>re instanceof HTMLElement&&re.hasAttribute("data-popover-content")))return;const c=i[0],f=c instanceof Node&&(t.contains(c)||((s=t.shadowRoot)==null?void 0:s.contains(c))),F=c instanceof HTMLElement&&c.hasAttribute("data-outside");(!f||F)&&t.close()}});r(this,N,n=>{if(n.code==="Escape"){const t=[...e(this,w)].reverse().find(s=>s.escape.current);t&&t.close()}});document.documentElement.addEventListener("click",e(this,_)),addEventListener("keydown",e(this,N))}get groups(){return e(this,d)}get stack(){return e(this,w)}add(n,t){if(t.closeRest.current)e(this,d).forEach(i=>{i.forEach(c=>{c.close()})});else if(t.closeRestInGroup.current){let i=e(this,d).get(n);i==null||i.forEach(c=>{c.close()})}let s=e(this,d).get(n);s!=null&&s.length||(s=[],e(this,d).set(n,s)),e(this,w).push(t),s.push(t)}remove(n,t){if(o(this,w,e(this,w).filter(s=>s!==t)),t.closeRest.current){let s=[];e(this,d).forEach(i=>{i.forEach(c=>s.push(c))}),e(this,d).clear(),s.forEach(i=>i.close())}else if(t.closeRestInGroup.current){const s=e(this,d).get(n);e(this,d).delete(n),s==null||s.forEach(i=>{i.close()})}else{let s=e(this,d).get(n);s&&(s=s.filter(i=>i!==t),e(this,d).set(n,s))}}}d=new WeakMap,w=new WeakMap,_=new WeakMap,N=new WeakMap;var v,z,B,k,H,m,C,A,x,b,R,q,T,y,$,a,V,W,u,ce,L,Z,G,O,j,X,D;const S=class S extends HTMLElement{constructor(){super();r(this,u);r(this,v);r(this,z);r(this,B);r(this,k);r(this,H);r(this,m);r(this,C);r(this,A);r(this,x);r(this,b);r(this,R);r(this,q);r(this,T);r(this,y);r(this,$);r(this,a);r(this,V);r(this,W);r(this,G);r(this,O);r(this,j);r(this,X);r(this,D);this.urlValue="",o(this,v,!1),o(this,m,new E.CSSProperty(this,"--history",!1)),o(this,C,new E.CSSProperty(this,"--restore",!1)),o(this,A,new E.CSSProperty(this,"--close-rest",!1)),o(this,x,new E.CSSProperty(this,"--close-rest-in-group",!1)),o(this,b,new E.CSSProperty(this,"--group","")),o(this,R,new E.CSSProperty(this,"--click-outside",!1)),o(this,q,new E.CSSProperty(this,"--escape",!1)),o(this,T,new E.CSSProperty(this,"--check-viewport-bounds",!1)),o(this,y,!0),o(this,a,new ue.ElementLinkedStore(this,{triggered:!1,beforeopen:!1,opened:!1,closing:!1,transitionend:!1})),o(this,V,[]),o(this,W,[]),o(this,G,()=>{o(this,y,!1),e(this,v)&&e(this,m).current&&!location.search.includes(this.id)?this.close():!e(this,v)&&e(this,m).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),o(this,y,!0)}),o(this,O,()=>{this.style.setProperty("--content-width","initial"),this.style.setProperty("--content-height","initial"),this.style.setProperty("--viewport-offset-x","0px"),this.style.setProperty("--viewport-offset-y","0px"),e(this,j).call(this)}),o(this,j,pe.debounce(()=>{e(this,X).call(this)},10)),o(this,X,()=>{if(this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px"),e(this,T).current){const t=this.getBoundingClientRect();let s=0,i=0;t.right>Q.viewport.width?s=Q.viewport.width-t.right:t.left<0&&(s=t.left*-1),t.bottom>Q.viewport.height?i=Q.viewport.height-t.bottom:t.top<0&&(i=t.top*-1),this.style.setProperty("--viewport-offset-x",s+"px"),this.style.setProperty("--viewport-offset-y",i+"px")}}),o(this,D,()=>{this.close()}),e(this,b).subscribe(t=>{t.previous&&(S.stack.remove(t.previous,this),t.current||(document.documentElement.classList.remove(`${this.group.previous}-closing`),document.documentElement.classList.remove(`${this.group.previous}-opened`)))}),e(this,a).subscribe(t=>{if(this.group.current){document.documentElement.classList.toggle(`${this.group.current}-closing`,t.current.closing);const s=S.stack.groups.get(this.group.current),i=s==null?void 0:s.find(c=>c.opened);document.documentElement.classList.toggle(`${this.group.current}-opened`,!!i)}})}get openClass(){return this.getAttribute("data-open-global-class")}get closingClass(){return this.getAttribute("data-closing-global-class")}get history(){return e(this,m)}get restore(){return e(this,C)}get closeRest(){return e(this,A)}get closeRestInGroup(){return e(this,x)}get group(){return e(this,b)}get clickOutside(){return e(this,R)}get escape(){return e(this,q)}get opened(){return e(this,v)}get lastTrigger(){return e(this,$)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(t){this.urlValue=(t==null?void 0:t.toString())||"",e(this,v)&&he.updateSearchParameter(this.id,t)}open(t){if(e(this,v))return;o(this,$,t==null?void 0:t.trigger),clearTimeout(e(this,z)),clearTimeout(e(this,B)),p(this,u,L).call(this,!1,this.closingClass),e(this,a).set("closing",!1),e(this,a).set("triggered",!0),M.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,$)}}),e(this,m).current&&e(this,y)&&history.pushState(history.state,"",e(this,u,ce)),e(this,a).set("beforeopen",!0),o(this,v,!0);const s=()=>{S.stack.add(e(this,b).current,this),e(this,W).forEach(i=>{i.scroll({top:0,left:0,behavior:"instant"})}),p(this,u,L).call(this,!0,this.openClass),e(this,a).set("opened",!0),M.dispatchEvent(window,"resize"),M.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,$)},bubbles:!0}),o(this,k,void 0),o(this,H,setTimeout(()=>{e(this,a).set("transitionend",!0),M.dispatchEvent(this,"popoverTransitionend")},ne.getElementTransitionDurationMS(this)+10))};t!=null&&t.skipTransition?s():o(this,k,requestAnimationFrame(s))}close(){e(this,v)&&(o(this,v,!1),cancelAnimationFrame(e(this,k)),clearTimeout(e(this,H)),S.stack.remove(e(this,b).current,this),p(this,u,Z).call(this),o(this,z,setTimeout(()=>{e(this,a).set("transitionend",!1),e(this,a).set("opened",!1),e(this,a).set("closing",!0),p(this,u,L).call(this,!1,this.openClass),p(this,u,L).call(this,!0,this.closingClass),M.dispatchEvent(this,"popoverClosing",{custom:!0,bubbles:!0}),o(this,B,setTimeout(()=>{e(this,a).set("triggered",!1),e(this,a).set("beforeopen",!1),e(this,a).set("closing",!1),p(this,u,L).call(this,!1,this.closingClass),M.dispatchEvent(this,"popoverClosed",{custom:!0,bubbles:!0})},ne.getElementTransitionDurationMS(this)+10))},10)))}connectedCallback(){o(this,V,[...this.querySelectorAll(`[data-popover-close${this.id?`="${this.id}"`:""}]`)]),e(this,V).forEach(t=>{t.addEventListener("click",e(this,D))}),o(this,W,[...this.querySelectorAll(`[data-popover-reset-scroll${this.id?`="${this.id}"`:""}]`)]),e(this,m).observe(),e(this,C).observe(),e(this,A).observe(),e(this,x).observe(),e(this,b).observe(),e(this,R).observe(),e(this,q).observe(),e(this,T).observe(),this.setAttribute("role","dialog"),addEventListener("popstate",e(this,G)),setTimeout(()=>{e(this,C).current?(o(this,y,!1),this.urlValue=he.parseSearchParameters(location.search)[this.id],location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),o(this,y,!0)):(p(this,u,Z).call(this),o(this,y,!0))},0),e(this,T).subscribe(()=>{e(this,O).call(this)}),le.windowResizer.subscribe(e(this,O))}disconnectedCallback(){e(this,V).forEach(t=>{t.removeEventListener("click",e(this,D))}),S.stack.remove(e(this,b).current,this),le.windowResizer.unsubscribe(e(this,O)),e(this,m).close(),e(this,C).close(),e(this,A).close(),e(this,x).close(),e(this,b).close(),e(this,R).close(),e(this,q).close(),e(this,T).close(),this.removeAttribute("role"),p(this,u,L).call(this,!1,this.openClass),p(this,u,L).call(this,!1,this.closingClass),clearTimeout(e(this,z)),clearTimeout(e(this,B)),clearTimeout(e(this,k)),clearTimeout(e(this,H)),removeEventListener("popstate",e(this,G)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),p(this,u,Z).call(this)}};v=new WeakMap,z=new WeakMap,B=new WeakMap,k=new WeakMap,H=new WeakMap,m=new WeakMap,C=new WeakMap,A=new WeakMap,x=new WeakMap,b=new WeakMap,R=new WeakMap,q=new WeakMap,T=new WeakMap,y=new WeakMap,$=new WeakMap,a=new WeakMap,V=new WeakMap,W=new WeakMap,u=new WeakSet,ce=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},L=function(t,s){s&&s.split(" ").map(i=>{document.documentElement.classList.toggle(i.trim(),t)})},Z=function(){if(e(this,m).current){const t=new URL(location.href);t.searchParams.delete(this.id),history.replaceState(history.state,"",t.href)}},G=new WeakMap,O=new WeakMap,j=new WeakMap,X=new WeakMap,D=new WeakMap,S.stack=new de;let U=S;ie.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",U);var h,g,P,te,Y,I,J,K,se;class ae extends HTMLElement{constructor(){super();r(this,P);r(this,h);r(this,g,new E.CSSProperty(this,"--type","open"));r(this,Y,()=>{e(this,g).current!=="close"&&this.classList.add("triggered")});r(this,I,()=>{e(this,g).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))});r(this,J,()=>{e(this,g).current!=="close"&&this.classList.remove("opened")});r(this,K,()=>{e(this,g).current!=="close"&&(this.classList.remove("triggered"),this.setAttribute("aria-expanded","false"))});ie.isBrowser&&(this.addEventListener("click",()=>{if(e(this,h)){const t=e(this,g).current;t==="open"||t==="toggle"&&!e(this,h).opened?e(this,h).open({trigger:this}):(t==="close"||t==="toggle"&&e(this,h).opened)&&e(this,h).close()}}),this.addEventListener("keydown",t=>{t.code==="Space"&&!this.hasAttribute("keydown-disabled")&&(t.preventDefault(),this.click())}))}get type(){return e(this,g)}get popoverElement(){return e(this,h)}changePopover(t){var s;if(p(this,P,te).call(this),t){let i=null;if(t==="parent"){const c=this.closest("[data-popover]");if(c)i=c;else{const f=this.getRootNode();f instanceof ShadowRoot?i=f.host.closest("[data-popover]"):f instanceof HTMLElement&&(i=f.closest("[data-popover]"))}}else if(t==="sibling")i=(s=this.parentElement)==null?void 0:s.querySelector("[data-popover]");else if(t==="ancestor-child"){const c=f=>{if(!f)return null;let F=f.querySelector("[data-popover]");return!F&&(f!=null&&f.parentElement)&&(F=c(f.parentElement)),F};i=c(this.parentElement)||null}else!t.startsWith(".")&&!t.startsWith("[")&&(t=`#${t}`),i=document.querySelector(t)||this.getRootNode().querySelector(t);i instanceof HTMLElement?(o(this,h,i),e(this,h).addEventListener("popoverTriggered",e(this,Y)),e(this,h).addEventListener("popoverOpened",e(this,I)),e(this,h).addEventListener("popoverClosing",e(this,J)),e(this,h).addEventListener("popoverClosed",e(this,K))):console.warn(this,`target ${t} not found`)}p(this,P,se).call(this,e(this,g).current)}connectedCallback(){e(this,g).subscribe(s=>{p(this,P,se).call(this,s.current)}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("role")||this.setAttribute("role","button");const t=this.getAttribute("target");t&&this.changePopover(t),this.isConnected&&e(this,g).observe()}disconnectedCallback(){e(this,g).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),this.removeAttribute("role"),this.removeAttribute("tabindex"),p(this,P,te).call(this)}}h=new WeakMap,g=new WeakMap,P=new WeakSet,te=function(){e(this,h)&&(e(this,h).removeEventListener("popoverTriggered",e(this,Y)),e(this,h).removeEventListener("popoverOpened",e(this,I)),e(this,h).removeEventListener("popoverClosing",e(this,J)),e(this,h).removeEventListener("popoverClosed",e(this,K)))},Y=new WeakMap,I=new WeakMap,J=new WeakMap,K=new WeakMap,se=function(t){e(this,h)instanceof U&&(t!=="close"?(this.setAttribute("aria-haspopup","true"),this.setAttribute("aria-expanded",e(this,h).opened?"true":"false"),this.setAttribute("aria-controls",e(this,h).id||"")):(this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls")))};ie.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",ae);exports.PopoverButtonElement=ae;exports.PopoverElement=U;
|
package/lib/popover/index.js
CHANGED
|
@@ -222,8 +222,8 @@ const T = class T extends HTMLElement {
|
|
|
222
222
|
e != null && e.skipTransition ? s() : o(this, P, requestAnimationFrame(s));
|
|
223
223
|
}
|
|
224
224
|
close() {
|
|
225
|
-
t(this, m) && (o(this, m, !1), cancelAnimationFrame(t(this, P)), clearTimeout(t(this, G)), T.stack.remove(t(this, b).current, this), p(this, u, Q).call(this),
|
|
226
|
-
t(this, a).set("transitionend", !1), t(this, a).set("opened", !1), t(this, a).set("closing", !0), p(this, u, L).call(this, !0, this.closingClass), q(this, "popoverClosing", {
|
|
225
|
+
t(this, m) && (o(this, m, !1), cancelAnimationFrame(t(this, P)), clearTimeout(t(this, G)), T.stack.remove(t(this, b).current, this), p(this, u, Q).call(this), o(this, H, setTimeout(() => {
|
|
226
|
+
t(this, a).set("transitionend", !1), t(this, a).set("opened", !1), t(this, a).set("closing", !0), p(this, u, L).call(this, !1, this.openClass), p(this, u, L).call(this, !0, this.closingClass), q(this, "popoverClosing", {
|
|
227
227
|
custom: !0,
|
|
228
228
|
bubbles: !0
|
|
229
229
|
}), o(this, W, setTimeout(() => {
|