aptechka 0.61.8 → 0.61.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +70 -69
- package/lib/popover/index.cjs +1 -1
- package/lib/popover/index.js +13 -13
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Pt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),At=n=>{throw TypeError(n)};var ct=(n,t,s)=>t.has(n)||At("Cannot "+s);var e=(n,t,s)=>(ct(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?At("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>(ct(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>(ct(n,t,"access private method"),s);var R=(n,t,s)=>new Promise((i,u)=>{var v=S=>{try{g(s.next(S))}catch(A){u(A)}},L=S=>{try{g(s.throw(S))}catch(A){u(A)}},g=S=>S.done?i(S.value):Promise.resolve(S.value).then(v,L);g((s=s.apply(n,t)).next())});var kt=(n,t,s)=>(t=n[Pt("asyncIterator")])?t.call(n):(n=n[Pt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=v=>new Promise((L,g,S)=>(v=u.call(n,v),S=v.done,Promise.resolve(v.value).then(A=>L({value:A,done:S}),g)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Mt=require("../index-Cqw2NKev.cjs"),U=require("../events-KVanG9sR.cjs"),It=require("../polyfills-Df4r-ETT.cjs"),Ct=require("../scroll-DAhSpkhR.cjs"),it=require("../url-D1CgmwZ_.cjs"),Ot=require("../css-value-parser/index.cjs");class Ht 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)}}Mt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Ht);var C,l,z,Z,$;class ht{constructor(t,s){o(this,C);o(this,l);o(this,z);o(this,Z,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,C).previousPathname)history.back();else{const u=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),L=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),g=L?Ot.cssValueParser.parse(L):void 0,S=e(this,l).hasAttribute("data-revalidate"),A=e(this,l).hasAttribute("data-keep-search-parameters"),m=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(V=>V.trim());e(this,C).navigate(e(this,z),{historyAction:u,centerScroll:v,offsetScroll:g,revalidate:S,keepSearchParameters:A,submorph:m})}});o(this,$,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,z),t),e(this,l).removeEventListener("pointerenter",e(this,$))});a(this,C,s),a(this,l,t),a(this,z,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,Z)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,$))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).normalizePath(e(this,z));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,Z)),e(this,l).removeEventListener("pointerenter",e(this,$)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,z=new WeakMap,Z=new WeakMap,$=new WeakMap;var x,K,w,I,O,N;class Tt{constructor(t,s,i){o(this,x);o(this,K);o(this,w,{x:0,y:0});o(this,I);o(this,O,null);o(this,N,null);a(this,x,t),a(this,K,s),a(this,I,i.cloneNode(!0))}get pathname(){return e(this,K)}get scrollState(){return e(this,w)}get document(){return e(this,N)}cloneDocument(){a(this,N,(e(this,O)||e(this,I)).cloneNode(!0))}get title(){let t="";if(e(this,N).title)t=e(this,N).title;else{const s=e(this,N).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,K)}return t}clearScrollState(){e(this,w).x=0,e(this,w).y=0}clearDocumentState(){a(this,O,null)}saveScrollState(){e(this,I).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,w).x=0,e(this,w).y=0):(e(this,w).x=e(this,x).scrollElement.scrollLeft,e(this,w).y=e(this,x).scrollElement.scrollTop)}saveDocumentState(){e(this,I).documentElement.hasAttribute("data-no-page-restoration")?a(this,O,null):a(this,O,document.cloneNode(!0))}restoreScrollPosition(){e(this,x).scrollElement.scroll({top:e(this,w).y,left:e(this,w).x})}renewScrollPosition(){e(this,x).scrollElement.scroll({top:0,left:0,behavior:"instant"})}}x=new WeakMap,K=new WeakMap,w=new WeakMap,I=new WeakMap,O=new WeakMap,N=new WeakMap;var T,Y,f,nt,q,p,_,B,M,P,G,F,tt,c,rt,xt,dt,Nt,mt,ft,pt,Et,ot,J;const X=class X{constructor(t){o(this,c);o(this,T,null);o(this,Y,null);o(this,f,[]);o(this,nt,new DOMParser);o(this,q);o(this,p,null);o(this,_);o(this,B,[]);o(this,M,!1);o(this,P,null);o(this,G,new Map);o(this,F,null);o(this,tt,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"});o(this,ot,t=>R(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),a(this,M,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,M,!1))}));o(this,J,()=>{const t=e(this,P).scrollTop,s=e(this,P).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),U.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Mt.isBrowser&&!X.instance){X.instance=this,a(this,T,{base:it.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body",morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),a(this,Y,d(this,c,dt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,p,s.pathname),e(this,G).set(e(this,p),new Tt(this,e(this,p),document)),document.documentElement.setAttribute("data-current-pathname",e(this,p)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,ot)),it.changeHistory({action:"replace",pathname:e(this,p),searchParameters:s.parameters||location.search,hash:s.hash}),a(this,F,new Ht),d(this,c,pt).call(this,document)}}get currentPathname(){return e(this,p)}get previousPathname(){return e(this,_)}get links(){return e(this,f)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,M)}normalizePath(t){return it.splitPath(t,{base:e(this,T).base,trailingSlash:e(this,T).trailingSlash})}prefetch(t,s){return R(this,null,function*(){const i=this.normalizePath(t);d(this,c,rt).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(S){return R(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:v,keepSearchParameters:L,submorph:g}={}){var vt;if(e(this,B).length)return;const A=this.normalizePath(((vt=this.pathnameModifier)==null?void 0:vt.call(this,t))||t);let{pathname:m,hash:V,parameters:gt,leaf:qt}=A;if(e(this,q)===m||e(this,p)===m){e(this,M)||d(this,c,Et).call(this,V||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,q,m),e(this,f).forEach(W=>{W.checkCurrent(m)});try{let W=!0;if(this.preprocessor)try{yield new Promise((r,k)=>{var y;(y=this.preprocessor)==null||y.call(this,{pathname:m,resolve:r,reject:k,submorph:g})})}catch(r){r?console.error(r):console.log("Route change canceled"),W=!1}if(!W||e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}const at={pathname:m,submorph:g};U.dispatchEvent(document,"morphNavigation",{detail:at});const St=yield d(this,c,rt).call(this,e(this,p)),b=yield d(this,c,rt).call(this,m,{searchParameters:gt,revalidate:v});if(e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}St.saveScrollState(),St.saveDocumentState(),e(this,M)||(b.clearScrollState(),b.clearDocumentState()),b.cloneDocument(),e(this,F).textContent=b.title,document.body.appendChild(e(this,F)),U.dispatchEvent(document,"morphStart",{detail:at});const yt=Array.from(document.head.children),wt=Array.from(b.document.head.children),Lt=d(this,c,Nt).call(this,yt,wt),Dt=d(this,c,mt).call(this,yt,Lt),et=d(this,c,mt).call(this,wt,Lt);et.forEach((r,k)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=r.getAttribute("src"),et[k]=y}}),et.forEach(r=>{document.head.appendChild(r)});const lt=et.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,c,ft).call(this,r))return!0});e(this,T).waitForHeadToLoad&<.length&&(yield new Promise(r=>R(this,null,function*(){let k=0;try{for(var y=kt(lt),Q,D,j;Q=!(D=yield y.next()).done;Q=!1){const st=D.value;st.onload=()=>{k++,k===lt.length&&r()}}}catch(D){j=[D]}finally{try{Q&&(D=y.return)&&(yield D.call(y))}finally{if(j)throw j[0]}}}))),yield Ct.wait(10);const bt=[];Dt.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,c,ft).call(this,r)?bt.push(r):r.remove())});const Rt=d(this,c,dt).call(this,b.document.body);e(this,T).morphInsideScrollContainer||d(this,c,pt).call(this,b.document),document.documentElement.setAttribute("data-current-pathname",m),document.documentElement.setAttribute("data-current-leaf",qt),it.changeHistory({action:s,pathname:m,searchParameters:gt||(L?location.search:""),hash:V}),e(this,F).remove(),a(this,_,e(this,p)),a(this,p,m),e(this,Y).forEach((r,k)=>{const y=Rt[k],Q=getComputedStyle(r).getPropertyValue("--morph-duration");let D=[],j=[];g?g.forEach(h=>{const E=r.querySelector(h),H=y.querySelector(h);E&&H&&(j.push(E),D.push(H))}):(D.push(...y.childNodes),j.push(...r.childNodes)),j.forEach(h=>{h instanceof HTMLElement&&(this.destroyOldLinks(h),h.classList.add("old"))}),D.forEach(h=>{h instanceof HTMLElement&&(this.findNewLinks(h),h.classList.add("new"))}),g?D.forEach((h,E)=>{var H;(H=j[E].parentElement)==null||H.insertBefore(h,j[E])}):r.prepend(...D),It.requestIdleCallback(()=>{D.forEach(h=>{var E;h instanceof HTMLElement&&((E=h.parentElement)==null||E.style.setProperty("--new-content-height",h.offsetHeight+"px"),h.classList.add("in"))})});const st={morphElement:r,pathname:m};U.dispatchEvent(document,"morphNewChildrenAdded",{detail:st});const zt=new Promise(h=>{setTimeout(()=>{j.forEach(E=>E.remove()),D.forEach(E=>{var H;E instanceof HTMLElement&&((H=E.parentElement)==null||H.style.removeProperty("--new-content-height"),E.classList.remove("in","new"))}),U.dispatchEvent(document,"morphOldChildrenRemoved",{detail:st}),h()},(parseFloat(Q)||0)*1e3+10)});e(this,B).push(zt)}),V?(b.clearScrollState(),d(this,c,Et).call(this,V,{centerScroll:i,offsetScroll:u})):e(this,M)?b.restoreScrollPosition():b.renewScrollPosition(),yield Promise.all(e(this,B)),bt.forEach(r=>r.remove()),a(this,B,[]),e(this,Y).forEach(r=>{r.querySelectorAll("script").forEach(y=>{const Q=document.createElement("script");Q.type="module",Q.src=y.getAttribute("src"),y.replaceWith(Q)})}),U.dispatchEvent(document,"morphComplete",{detail:at}),window.dispatchEvent(new Event("resize"))}catch(W){console.error(W)}a(this,q,void 0)})}addLink(t){e(this,f).push(new ht(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,f,e(this,f).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){a(this,f,e(this,f).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,tt));e(this,f).push(...s.map(i=>new ht(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,tt));e(this,f).forEach(s=>s.destroy()),a(this,f,t.map(s=>new ht(s,this)))}};T=new WeakMap,Y=new WeakMap,f=new WeakMap,nt=new WeakMap,q=new WeakMap,p=new WeakMap,_=new WeakMap,B=new WeakMap,M=new WeakMap,P=new WeakMap,G=new WeakMap,F=new WeakMap,tt=new WeakMap,c=new WeakSet,rt=function(t,s){return R(this,null,function*(){let i=e(this,G).get(t);return(!i||s!=null&&s.revalidate)&&(i=yield d(this,c,xt).call(this,t,s==null?void 0:s.searchParameters)),i})},xt=function(t,s){return R(this,null,function*(){const u=yield(yield fetch(`${t}${s?"?"+s:""}`)).text(),v=e(this,nt).parseFromString(u,"text/html"),L=new Tt(this,t,v);return e(this,G).set(t,L),L})},dt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Nt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},mt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ft=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},pt=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,J)),a(this,P,t.querySelector(e(this,T).scrollSelector)||t.documentElement),(i=e(this,P))==null||i.addEventListener("scroll",e(this,J)),e(this,J).call(this)},Et=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ct.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})},ot=new WeakMap,J=new WeakMap,X.instance=null;let ut=X;exports.Morph=ut;
|
|
1
|
+
"use strict";var Pt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),At=n=>{throw TypeError(n)};var ct=(n,t,s)=>t.has(n)||At("Cannot "+s);var e=(n,t,s)=>(ct(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?At("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>(ct(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>(ct(n,t,"access private method"),s);var R=(n,t,s)=>new Promise((i,u)=>{var v=S=>{try{g(s.next(S))}catch(A){u(A)}},L=S=>{try{g(s.throw(S))}catch(A){u(A)}},g=S=>S.done?i(S.value):Promise.resolve(S.value).then(v,L);g((s=s.apply(n,t)).next())});var kt=(n,t,s)=>(t=n[Pt("asyncIterator")])?t.call(n):(n=n[Pt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=v=>new Promise((L,g,S)=>(v=u.call(n,v),S=v.done,Promise.resolve(v.value).then(A=>L({value:A,done:S}),g)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Mt=require("../index-Cqw2NKev.cjs"),U=require("../events-KVanG9sR.cjs"),It=require("../polyfills-Df4r-ETT.cjs"),Ct=require("../scroll-DAhSpkhR.cjs"),it=require("../url-D1CgmwZ_.cjs"),Ot=require("../css-value-parser/index.cjs");class Ht 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)}}Mt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Ht);var C,l,z,Z,$;class ht{constructor(t,s){o(this,C);o(this,l);o(this,z);o(this,Z,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,C).previousPathname)history.back();else{const u=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),L=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),g=L?Ot.cssValueParser.parse(L):void 0,S=e(this,l).hasAttribute("data-revalidate"),A=e(this,l).hasAttribute("data-keep-search-parameters"),m=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(V=>V.trim());e(this,C).navigate(e(this,z),{historyAction:u,centerScroll:v,offsetScroll:g,revalidate:S,keepSearchParameters:A,submorph:m})}});o(this,$,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,z),t),e(this,l).removeEventListener("pointerenter",e(this,$))});a(this,C,s),a(this,l,t),a(this,z,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,Z)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,$))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).normalizePath(e(this,z));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,Z)),e(this,l).removeEventListener("pointerenter",e(this,$)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,z=new WeakMap,Z=new WeakMap,$=new WeakMap;var x,K,w,I,O,N;class Tt{constructor(t,s,i){o(this,x);o(this,K);o(this,w,{x:0,y:0});o(this,I);o(this,O,null);o(this,N,null);a(this,x,t),a(this,K,s),a(this,I,i.cloneNode(!0))}get pathname(){return e(this,K)}get scrollState(){return e(this,w)}get document(){return e(this,N)}cloneDocument(){a(this,N,(e(this,O)||e(this,I)).cloneNode(!0))}get title(){let t="";if(e(this,N).title)t=e(this,N).title;else{const s=e(this,N).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,K)}return t}clearScrollState(){e(this,w).x=0,e(this,w).y=0}clearDocumentState(){a(this,O,null)}saveScrollState(){e(this,I).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,w).x=0,e(this,w).y=0):(e(this,w).x=e(this,x).scrollElement.scrollLeft,e(this,w).y=e(this,x).scrollElement.scrollTop)}saveDocumentState(){e(this,I).documentElement.hasAttribute("data-no-page-restoration")?a(this,O,null):a(this,O,document.cloneNode(!0))}restoreScrollPosition(){e(this,x).scrollElement.scroll({top:e(this,w).y,left:e(this,w).x,behavior:"instant"})}renewScrollPosition(){e(this,x).scrollElement.scroll({top:0,left:0,behavior:"instant"})}}x=new WeakMap,K=new WeakMap,w=new WeakMap,I=new WeakMap,O=new WeakMap,N=new WeakMap;var T,Y,f,nt,q,p,_,B,M,P,G,F,tt,c,rt,xt,dt,Nt,mt,ft,pt,Et,ot,J;const X=class X{constructor(t){o(this,c);o(this,T,null);o(this,Y,null);o(this,f,[]);o(this,nt,new DOMParser);o(this,q);o(this,p,null);o(this,_);o(this,B,[]);o(this,M,!1);o(this,P,null);o(this,G,new Map);o(this,F,null);o(this,tt,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"});o(this,ot,t=>R(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),a(this,M,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,M,!1))}));o(this,J,()=>{const t=e(this,P).scrollTop,s=e(this,P).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),U.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Mt.isBrowser&&!X.instance){X.instance=this,a(this,T,{base:it.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body",morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),a(this,Y,d(this,c,dt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,p,s.pathname),e(this,G).set(e(this,p),new Tt(this,e(this,p),document)),document.documentElement.setAttribute("data-current-pathname",e(this,p)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,ot)),it.changeHistory({action:"replace",pathname:e(this,p),searchParameters:s.parameters||location.search,hash:s.hash}),a(this,F,new Ht),d(this,c,pt).call(this,document)}}get currentPathname(){return e(this,p)}get previousPathname(){return e(this,_)}get links(){return e(this,f)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,M)}normalizePath(t){return it.splitPath(t,{base:e(this,T).base,trailingSlash:e(this,T).trailingSlash})}prefetch(t,s){return R(this,null,function*(){const i=this.normalizePath(t);d(this,c,rt).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(S){return R(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:v,keepSearchParameters:L,submorph:g}={}){var vt;if(e(this,B).length)return;const A=this.normalizePath(((vt=this.pathnameModifier)==null?void 0:vt.call(this,t))||t);let{pathname:m,hash:V,parameters:gt,leaf:qt}=A;if(e(this,q)===m||e(this,p)===m){e(this,M)||d(this,c,Et).call(this,V||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,q,m),e(this,f).forEach(W=>{W.checkCurrent(m)});try{let W=!0;if(this.preprocessor)try{yield new Promise((r,k)=>{var y;(y=this.preprocessor)==null||y.call(this,{pathname:m,resolve:r,reject:k,submorph:g})})}catch(r){r?console.error(r):console.log("Route change canceled"),W=!1}if(!W||e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}const at={pathname:m,submorph:g};U.dispatchEvent(document,"morphNavigation",{detail:at});const St=yield d(this,c,rt).call(this,e(this,p)),b=yield d(this,c,rt).call(this,m,{searchParameters:gt,revalidate:v});if(e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}St.saveScrollState(),St.saveDocumentState(),e(this,M)||(b.clearScrollState(),b.clearDocumentState()),b.cloneDocument(),e(this,F).textContent=b.title,document.body.appendChild(e(this,F)),U.dispatchEvent(document,"morphStart",{detail:at});const yt=Array.from(document.head.children),wt=Array.from(b.document.head.children),Lt=d(this,c,Nt).call(this,yt,wt),Dt=d(this,c,mt).call(this,yt,Lt),et=d(this,c,mt).call(this,wt,Lt);et.forEach((r,k)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=r.getAttribute("src"),et[k]=y}}),et.forEach(r=>{document.head.appendChild(r)});const lt=et.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,c,ft).call(this,r))return!0});e(this,T).waitForHeadToLoad&<.length&&(yield new Promise(r=>R(this,null,function*(){let k=0;try{for(var y=kt(lt),Q,D,j;Q=!(D=yield y.next()).done;Q=!1){const st=D.value;st.onload=()=>{k++,k===lt.length&&r()}}}catch(D){j=[D]}finally{try{Q&&(D=y.return)&&(yield D.call(y))}finally{if(j)throw j[0]}}}))),yield Ct.wait(10);const bt=[];Dt.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,c,ft).call(this,r)?bt.push(r):r.remove())});const Rt=d(this,c,dt).call(this,b.document.body);e(this,T).morphInsideScrollContainer||d(this,c,pt).call(this,b.document),document.documentElement.setAttribute("data-current-pathname",m),document.documentElement.setAttribute("data-current-leaf",qt),it.changeHistory({action:s,pathname:m,searchParameters:gt||(L?location.search:""),hash:V}),e(this,F).remove(),a(this,_,e(this,p)),a(this,p,m),e(this,Y).forEach((r,k)=>{const y=Rt[k],Q=getComputedStyle(r).getPropertyValue("--morph-duration");let D=[],j=[];g?g.forEach(h=>{const E=r.querySelector(h),H=y.querySelector(h);E&&H&&(j.push(E),D.push(H))}):(D.push(...y.childNodes),j.push(...r.childNodes)),j.forEach(h=>{h instanceof HTMLElement&&(this.destroyOldLinks(h),h.classList.add("old"))}),D.forEach(h=>{h instanceof HTMLElement&&(this.findNewLinks(h),h.classList.add("new"))}),g?D.forEach((h,E)=>{var H;(H=j[E].parentElement)==null||H.insertBefore(h,j[E])}):r.prepend(...D),It.requestIdleCallback(()=>{D.forEach(h=>{var E;h instanceof HTMLElement&&((E=h.parentElement)==null||E.style.setProperty("--new-content-height",h.offsetHeight+"px"),h.classList.add("in"))})});const st={morphElement:r,pathname:m};U.dispatchEvent(document,"morphNewChildrenAdded",{detail:st});const zt=new Promise(h=>{setTimeout(()=>{j.forEach(E=>E.remove()),D.forEach(E=>{var H;E instanceof HTMLElement&&((H=E.parentElement)==null||H.style.removeProperty("--new-content-height"),E.classList.remove("in","new"))}),U.dispatchEvent(document,"morphOldChildrenRemoved",{detail:st}),h()},(parseFloat(Q)||0)*1e3+10)});e(this,B).push(zt)}),V?(b.clearScrollState(),d(this,c,Et).call(this,V,{centerScroll:i,offsetScroll:u})):e(this,M)?b.restoreScrollPosition():b.renewScrollPosition(),yield Promise.all(e(this,B)),bt.forEach(r=>r.remove()),a(this,B,[]),e(this,Y).forEach(r=>{r.querySelectorAll("script").forEach(y=>{const Q=document.createElement("script");Q.type="module",Q.src=y.getAttribute("src"),y.replaceWith(Q)})}),U.dispatchEvent(document,"morphComplete",{detail:at}),window.dispatchEvent(new Event("resize"))}catch(W){console.error(W)}a(this,q,void 0)})}addLink(t){e(this,f).push(new ht(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,f,e(this,f).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){a(this,f,e(this,f).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,tt));e(this,f).push(...s.map(i=>new ht(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,tt));e(this,f).forEach(s=>s.destroy()),a(this,f,t.map(s=>new ht(s,this)))}};T=new WeakMap,Y=new WeakMap,f=new WeakMap,nt=new WeakMap,q=new WeakMap,p=new WeakMap,_=new WeakMap,B=new WeakMap,M=new WeakMap,P=new WeakMap,G=new WeakMap,F=new WeakMap,tt=new WeakMap,c=new WeakSet,rt=function(t,s){return R(this,null,function*(){let i=e(this,G).get(t);return(!i||s!=null&&s.revalidate)&&(i=yield d(this,c,xt).call(this,t,s==null?void 0:s.searchParameters)),i})},xt=function(t,s){return R(this,null,function*(){const u=yield(yield fetch(`${t}${s?"?"+s:""}`)).text(),v=e(this,nt).parseFromString(u,"text/html"),L=new Tt(this,t,v);return e(this,G).set(t,L),L})},dt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Nt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},mt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ft=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},pt=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,J)),a(this,P,t.querySelector(e(this,T).scrollSelector)||t.documentElement),(i=e(this,P))==null||i.addEventListener("scroll",e(this,J)),e(this,J).call(this)},Et=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ct.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})},ot=new WeakMap,J=new WeakMap,X.instance=null;let ut=X;exports.Morph=ut;
|
package/lib/morph/index.js
CHANGED
|
@@ -2,24 +2,24 @@ var Lt = (n, t) => (t = Symbol[n]) ? t : Symbol.for("Symbol." + n), bt = (n) =>
|
|
|
2
2
|
throw TypeError(n);
|
|
3
3
|
};
|
|
4
4
|
var lt = (n, t, s) => t.has(n) || bt("Cannot " + s);
|
|
5
|
-
var e = (n, t, s) => (lt(n, t, "read from private field"), s ? s.call(n) : t.get(n)),
|
|
5
|
+
var e = (n, t, s) => (lt(n, t, "read from private field"), s ? s.call(n) : t.get(n)), a = (n, t, s) => t.has(n) ? bt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s), o = (n, t, s, i) => (lt(n, t, "write to private field"), i ? i.call(n, s) : t.set(n, s), s), d = (n, t, s) => (lt(n, t, "access private method"), s);
|
|
6
6
|
var q = (n, t, s) => new Promise((i, u) => {
|
|
7
|
-
var
|
|
7
|
+
var v = (S) => {
|
|
8
8
|
try {
|
|
9
|
-
g(s.next(
|
|
9
|
+
g(s.next(S));
|
|
10
10
|
} catch (A) {
|
|
11
11
|
u(A);
|
|
12
12
|
}
|
|
13
|
-
}, L = (
|
|
13
|
+
}, L = (S) => {
|
|
14
14
|
try {
|
|
15
|
-
g(s.throw(
|
|
15
|
+
g(s.throw(S));
|
|
16
16
|
} catch (A) {
|
|
17
17
|
u(A);
|
|
18
18
|
}
|
|
19
|
-
}, g = (
|
|
19
|
+
}, g = (S) => S.done ? i(S.value) : Promise.resolve(S.value).then(v, L);
|
|
20
20
|
g((s = s.apply(n, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var Pt = (n, t, s) => (t = n[Lt("asyncIterator")]) ? t.call(n) : (n = n[Lt("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (
|
|
22
|
+
var Pt = (n, t, s) => (t = n[Lt("asyncIterator")]) ? t.call(n) : (n = n[Lt("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (v) => new Promise((L, g, S) => (v = u.call(n, v), S = v.done, Promise.resolve(v.value).then((A) => L({ value: A, done: S }), g)))), s("next"), s("return"), t);
|
|
23
23
|
import { i as Tt } from "../index-euf5anj6.js";
|
|
24
24
|
import { d as $ } from "../events-CsVF98U6.js";
|
|
25
25
|
import { r as zt } from "../polyfills-DJrTJQky.js";
|
|
@@ -41,34 +41,34 @@ Tt && !customElements.get("morph-announcer") && customElements.define("morph-ann
|
|
|
41
41
|
var C, l, z, Z, j;
|
|
42
42
|
class ht {
|
|
43
43
|
constructor(t, s) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
a(this, C);
|
|
45
|
+
a(this, l);
|
|
46
|
+
a(this, z);
|
|
47
|
+
a(this, Z, (t) => {
|
|
48
48
|
var i;
|
|
49
49
|
if (t.preventDefault(), e(this, l).hasAttribute("data-back") && e(this, C).previousPathname)
|
|
50
50
|
history.back();
|
|
51
51
|
else {
|
|
52
52
|
const u = e(this, l).getAttribute(
|
|
53
53
|
"data-history-action"
|
|
54
|
-
) || "push",
|
|
54
|
+
) || "push", v = e(this, l).hasAttribute("data-center-scroll"), L = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), g = L ? Vt.parse(L) : void 0, S = e(this, l).hasAttribute("data-revalidate"), A = e(this, l).hasAttribute(
|
|
55
55
|
"data-keep-search-parameters"
|
|
56
56
|
), m = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((V) => V.trim());
|
|
57
57
|
e(this, C).navigate(e(this, z), {
|
|
58
58
|
historyAction: u,
|
|
59
|
-
centerScroll:
|
|
59
|
+
centerScroll: v,
|
|
60
60
|
offsetScroll: g,
|
|
61
|
-
revalidate:
|
|
61
|
+
revalidate: S,
|
|
62
62
|
keepSearchParameters: A,
|
|
63
63
|
submorph: m
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
|
-
|
|
67
|
+
a(this, j, () => {
|
|
68
68
|
const t = e(this, l).hasAttribute("data-revalidate");
|
|
69
69
|
e(this, C).prefetch(e(this, z), t), e(this, l).removeEventListener("pointerenter", e(this, j));
|
|
70
70
|
});
|
|
71
|
-
|
|
71
|
+
o(this, C, s), o(this, l, t), o(this, z, e(this, l).getAttribute("href") || "/"), e(this, l).addEventListener("click", e(this, Z)), this.checkCurrent(location.pathname), e(this, l).hasAttribute("data-prefetch") && e(this, l).addEventListener("pointerenter", e(this, j));
|
|
72
72
|
}
|
|
73
73
|
get element() {
|
|
74
74
|
return e(this, l);
|
|
@@ -85,13 +85,13 @@ C = new WeakMap(), l = new WeakMap(), z = new WeakMap(), Z = new WeakMap(), j =
|
|
|
85
85
|
var N, K, w, I, F, x;
|
|
86
86
|
class kt {
|
|
87
87
|
constructor(t, s, i) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
a(this, N);
|
|
89
|
+
a(this, K);
|
|
90
|
+
a(this, w, { x: 0, y: 0 });
|
|
91
|
+
a(this, I);
|
|
92
|
+
a(this, F, null);
|
|
93
|
+
a(this, x, null);
|
|
94
|
+
o(this, N, t), o(this, K, s), o(this, I, i.cloneNode(!0));
|
|
95
95
|
}
|
|
96
96
|
get pathname() {
|
|
97
97
|
return e(this, K);
|
|
@@ -103,7 +103,7 @@ class kt {
|
|
|
103
103
|
return e(this, x);
|
|
104
104
|
}
|
|
105
105
|
cloneDocument() {
|
|
106
|
-
|
|
106
|
+
o(this, x, (e(this, F) || e(this, I)).cloneNode(!0));
|
|
107
107
|
}
|
|
108
108
|
get title() {
|
|
109
109
|
let t = "";
|
|
@@ -119,7 +119,7 @@ class kt {
|
|
|
119
119
|
e(this, w).x = 0, e(this, w).y = 0;
|
|
120
120
|
}
|
|
121
121
|
clearDocumentState() {
|
|
122
|
-
|
|
122
|
+
o(this, F, null);
|
|
123
123
|
}
|
|
124
124
|
saveScrollState() {
|
|
125
125
|
e(this, I).documentElement.hasAttribute(
|
|
@@ -129,12 +129,13 @@ class kt {
|
|
|
129
129
|
saveDocumentState() {
|
|
130
130
|
e(this, I).documentElement.hasAttribute(
|
|
131
131
|
"data-no-page-restoration"
|
|
132
|
-
) ?
|
|
132
|
+
) ? o(this, F, null) : o(this, F, document.cloneNode(!0));
|
|
133
133
|
}
|
|
134
134
|
restoreScrollPosition() {
|
|
135
135
|
e(this, N).scrollElement.scroll({
|
|
136
136
|
top: e(this, w).y,
|
|
137
|
-
left: e(this, w).x
|
|
137
|
+
left: e(this, w).x,
|
|
138
|
+
behavior: "instant"
|
|
138
139
|
});
|
|
139
140
|
}
|
|
140
141
|
renewScrollPosition() {
|
|
@@ -149,28 +150,28 @@ N = new WeakMap(), K = new WeakMap(), w = new WeakMap(), I = new WeakMap(), F =
|
|
|
149
150
|
var T, Y, f, rt, D, p, _, O, M, P, G, B, tt, h, it, Ht, ct, Nt, ut, dt, mt, ft, nt, J;
|
|
150
151
|
const X = class X {
|
|
151
152
|
constructor(t) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
153
|
+
a(this, h);
|
|
154
|
+
a(this, T, null);
|
|
155
|
+
a(this, Y, null);
|
|
156
|
+
a(this, f, []);
|
|
157
|
+
a(this, rt, new DOMParser());
|
|
158
|
+
a(this, D);
|
|
159
|
+
a(this, p, null);
|
|
160
|
+
a(this, _);
|
|
161
|
+
a(this, O, []);
|
|
162
|
+
a(this, M, !1);
|
|
163
|
+
a(this, P, null);
|
|
164
|
+
a(this, G, /* @__PURE__ */ new Map());
|
|
165
|
+
a(this, B, null);
|
|
166
|
+
a(this, tt, (t) => {
|
|
166
167
|
var s;
|
|
167
168
|
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";
|
|
168
169
|
});
|
|
169
|
-
|
|
170
|
+
a(this, nt, (t) => q(this, null, function* () {
|
|
170
171
|
var s;
|
|
171
|
-
(s = t.state) != null && s.path && (t.preventDefault(),
|
|
172
|
+
(s = t.state) != null && s.path && (t.preventDefault(), o(this, M, !0), yield this.navigate(t.state.path, { historyAction: "none" }), o(this, M, !1));
|
|
172
173
|
}));
|
|
173
|
-
|
|
174
|
+
a(this, J, () => {
|
|
174
175
|
const t = e(this, P).scrollTop, s = e(this, P).scrollLeft;
|
|
175
176
|
document.documentElement.classList.toggle("top-scrolled", t > 0), document.documentElement.classList.toggle("left-scrolled", s > 0), $(document, "morphScroll", {
|
|
176
177
|
detail: {
|
|
@@ -180,18 +181,18 @@ const X = class X {
|
|
|
180
181
|
});
|
|
181
182
|
});
|
|
182
183
|
if (Tt && !X.instance) {
|
|
183
|
-
X.instance = this,
|
|
184
|
+
X.instance = this, o(this, T, {
|
|
184
185
|
base: Ot(t == null ? void 0 : t.base),
|
|
185
186
|
waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
|
|
186
187
|
cachePages: (t == null ? void 0 : t.cachePages) !== !1,
|
|
187
188
|
trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
|
|
188
189
|
scrollSelector: (t == null ? void 0 : t.scrollSelector) || "body",
|
|
189
190
|
morphInsideScrollContainer: (t == null ? void 0 : t.morphInsideScrollContainer) || !1
|
|
190
|
-
}),
|
|
191
|
+
}), o(this, Y, d(this, h, ct).call(this, document.body));
|
|
191
192
|
const s = this.normalizePath(
|
|
192
193
|
location.pathname + location.hash
|
|
193
194
|
);
|
|
194
|
-
|
|
195
|
+
o(this, p, s.pathname), e(this, G).set(
|
|
195
196
|
e(this, p),
|
|
196
197
|
new kt(this, e(this, p), document)
|
|
197
198
|
), document.documentElement.setAttribute(
|
|
@@ -205,7 +206,7 @@ const X = class X {
|
|
|
205
206
|
pathname: e(this, p),
|
|
206
207
|
searchParameters: s.parameters || location.search,
|
|
207
208
|
hash: s.hash
|
|
208
|
-
}),
|
|
209
|
+
}), o(this, B, new Mt()), d(this, h, mt).call(this, document);
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
get currentPathname() {
|
|
@@ -238,12 +239,12 @@ const X = class X {
|
|
|
238
239
|
});
|
|
239
240
|
});
|
|
240
241
|
}
|
|
241
|
-
navigate(
|
|
242
|
+
navigate(S) {
|
|
242
243
|
return q(this, arguments, function* (t, {
|
|
243
244
|
historyAction: s = "push",
|
|
244
245
|
centerScroll: i,
|
|
245
246
|
offsetScroll: u,
|
|
246
|
-
revalidate:
|
|
247
|
+
revalidate: v,
|
|
247
248
|
keepSearchParameters: L,
|
|
248
249
|
submorph: g
|
|
249
250
|
} = {}) {
|
|
@@ -260,7 +261,7 @@ const X = class X {
|
|
|
260
261
|
});
|
|
261
262
|
return;
|
|
262
263
|
}
|
|
263
|
-
|
|
264
|
+
o(this, D, m), e(this, f).forEach((W) => {
|
|
264
265
|
W.checkCurrent(m);
|
|
265
266
|
});
|
|
266
267
|
try {
|
|
@@ -285,16 +286,16 @@ const X = class X {
|
|
|
285
286
|
});
|
|
286
287
|
return;
|
|
287
288
|
}
|
|
288
|
-
const
|
|
289
|
+
const at = {
|
|
289
290
|
pathname: m,
|
|
290
291
|
submorph: g
|
|
291
292
|
};
|
|
292
293
|
$(document, "morphNavigation", {
|
|
293
|
-
detail:
|
|
294
|
+
detail: at
|
|
294
295
|
});
|
|
295
296
|
const gt = yield d(this, h, it).call(this, e(this, p)), b = yield d(this, h, it).call(this, m, {
|
|
296
297
|
searchParameters: pt,
|
|
297
|
-
revalidate:
|
|
298
|
+
revalidate: v
|
|
298
299
|
});
|
|
299
300
|
if (e(this, D) !== m) {
|
|
300
301
|
e(this, f).forEach((r) => {
|
|
@@ -303,9 +304,9 @@ const X = class X {
|
|
|
303
304
|
return;
|
|
304
305
|
}
|
|
305
306
|
gt.saveScrollState(), gt.saveDocumentState(), e(this, M) || (b.clearScrollState(), b.clearDocumentState()), b.cloneDocument(), e(this, B).textContent = b.title, document.body.appendChild(e(this, B)), $(document, "morphStart", {
|
|
306
|
-
detail:
|
|
307
|
+
detail: at
|
|
307
308
|
});
|
|
308
|
-
const
|
|
309
|
+
const vt = Array.from(document.head.children), St = Array.from(b.document.head.children), yt = d(this, h, Nt).call(this, vt, St), Dt = d(this, h, ut).call(this, vt, yt), et = d(this, h, ut).call(this, St, yt);
|
|
309
310
|
et.forEach((r, k) => {
|
|
310
311
|
if (r.tagName === "SCRIPT" && r.getAttribute("src")) {
|
|
311
312
|
const y = document.createElement("script");
|
|
@@ -314,19 +315,19 @@ const X = class X {
|
|
|
314
315
|
}), et.forEach((r) => {
|
|
315
316
|
document.head.appendChild(r);
|
|
316
317
|
});
|
|
317
|
-
const
|
|
318
|
+
const ot = et.filter((r) => {
|
|
318
319
|
if (r.hasAttribute("data-no-waiting"))
|
|
319
320
|
return !1;
|
|
320
321
|
if (d(this, h, dt).call(this, r))
|
|
321
322
|
return !0;
|
|
322
323
|
});
|
|
323
|
-
e(this, T).waitForHeadToLoad &&
|
|
324
|
+
e(this, T).waitForHeadToLoad && ot.length && (yield new Promise((r) => q(this, null, function* () {
|
|
324
325
|
let k = 0;
|
|
325
326
|
try {
|
|
326
|
-
for (var y = Pt(
|
|
327
|
+
for (var y = Pt(ot), Q, R, U; Q = !(R = yield y.next()).done; Q = !1) {
|
|
327
328
|
const st = R.value;
|
|
328
329
|
st.onload = () => {
|
|
329
|
-
k++, k ===
|
|
330
|
+
k++, k === ot.length && r();
|
|
330
331
|
};
|
|
331
332
|
}
|
|
332
333
|
} catch (R) {
|
|
@@ -350,7 +351,7 @@ const X = class X {
|
|
|
350
351
|
pathname: m,
|
|
351
352
|
searchParameters: pt || (L ? location.search : ""),
|
|
352
353
|
hash: V
|
|
353
|
-
}), e(this, B).remove(),
|
|
354
|
+
}), e(this, B).remove(), o(this, _, e(this, p)), o(this, p, m), e(this, Y).forEach((r, k) => {
|
|
354
355
|
const y = Rt[k], Q = getComputedStyle(r).getPropertyValue("--morph-duration");
|
|
355
356
|
let R = [], U = [];
|
|
356
357
|
g ? g.forEach((c) => {
|
|
@@ -395,18 +396,18 @@ const X = class X {
|
|
|
395
396
|
}, (parseFloat(Q) || 0) * 1e3 + 10);
|
|
396
397
|
});
|
|
397
398
|
e(this, O).push(qt);
|
|
398
|
-
}), V ? (b.clearScrollState(), d(this, h, ft).call(this, V, { centerScroll: i, offsetScroll: u })) : e(this, M) ? b.restoreScrollPosition() : b.renewScrollPosition(), yield Promise.all(e(this, O)), wt.forEach((r) => r.remove()),
|
|
399
|
+
}), V ? (b.clearScrollState(), d(this, h, ft).call(this, V, { centerScroll: i, offsetScroll: u })) : e(this, M) ? b.restoreScrollPosition() : b.renewScrollPosition(), yield Promise.all(e(this, O)), wt.forEach((r) => r.remove()), o(this, O, []), e(this, Y).forEach((r) => {
|
|
399
400
|
r.querySelectorAll("script").forEach((y) => {
|
|
400
401
|
const Q = document.createElement("script");
|
|
401
402
|
Q.type = "module", Q.src = y.getAttribute("src"), y.replaceWith(Q);
|
|
402
403
|
});
|
|
403
404
|
}), $(document, "morphComplete", {
|
|
404
|
-
detail:
|
|
405
|
+
detail: at
|
|
405
406
|
}), window.dispatchEvent(new Event("resize"));
|
|
406
407
|
} catch (W) {
|
|
407
408
|
console.error(W);
|
|
408
409
|
}
|
|
409
|
-
|
|
410
|
+
o(this, D, void 0);
|
|
410
411
|
});
|
|
411
412
|
}
|
|
412
413
|
addLink(t) {
|
|
@@ -418,10 +419,10 @@ const X = class X {
|
|
|
418
419
|
});
|
|
419
420
|
}
|
|
420
421
|
removeLink(t) {
|
|
421
|
-
|
|
422
|
+
o(this, f, e(this, f).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
|
|
422
423
|
}
|
|
423
424
|
destroyOldLinks(t) {
|
|
424
|
-
|
|
425
|
+
o(this, f, e(this, f).filter((s) => t.contains(s.element) ? (s.destroy(), !1) : !0));
|
|
425
426
|
}
|
|
426
427
|
findNewLinks(t) {
|
|
427
428
|
const s = [...t.querySelectorAll("a")].filter(
|
|
@@ -435,7 +436,7 @@ const X = class X {
|
|
|
435
436
|
const t = [
|
|
436
437
|
...document.documentElement.querySelectorAll("a")
|
|
437
438
|
].filter(e(this, tt));
|
|
438
|
-
e(this, f).forEach((s) => s.destroy()),
|
|
439
|
+
e(this, f).forEach((s) => s.destroy()), o(this, f, t.map((s) => new ht(s, this)));
|
|
439
440
|
}
|
|
440
441
|
};
|
|
441
442
|
T = new WeakMap(), Y = new WeakMap(), f = new WeakMap(), rt = new WeakMap(), D = new WeakMap(), p = new WeakMap(), _ = new WeakMap(), O = new WeakMap(), M = new WeakMap(), P = new WeakMap(), G = new WeakMap(), B = new WeakMap(), tt = new WeakMap(), h = new WeakSet(), it = function(t, s) {
|
|
@@ -447,7 +448,7 @@ T = new WeakMap(), Y = new WeakMap(), f = new WeakMap(), rt = new WeakMap(), D =
|
|
|
447
448
|
return q(this, null, function* () {
|
|
448
449
|
const u = yield (yield fetch(
|
|
449
450
|
`${t}${s ? "?" + s : ""}`
|
|
450
|
-
)).text(),
|
|
451
|
+
)).text(), v = e(this, rt).parseFromString(u, "text/html"), L = new kt(this, t, v);
|
|
451
452
|
return e(this, G).set(t, L), L;
|
|
452
453
|
});
|
|
453
454
|
}, ct = function(t) {
|
|
@@ -472,7 +473,7 @@ T = new WeakMap(), Y = new WeakMap(), f = new WeakMap(), rt = new WeakMap(), D =
|
|
|
472
473
|
(s = e(this, P)) == null || s.removeEventListener(
|
|
473
474
|
"scroll",
|
|
474
475
|
e(this, J)
|
|
475
|
-
),
|
|
476
|
+
), o(this, P, t.querySelector(e(this, T).scrollSelector) || t.documentElement), (i = e(this, P)) == null || i.addEventListener("scroll", e(this, J)), e(this, J).call(this);
|
|
476
477
|
}, ft = function(t, s) {
|
|
477
478
|
const i = typeof t == "string" ? document.getElementById(t) : t;
|
|
478
479
|
(typeof i == "number" || i) && Ft(i, {
|
package/lib/popover/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var te=c=>{throw TypeError(c)};var Q=(c,o,t)=>o.has(c)||te("Cannot "+t);var e=(c,o,t)=>(Q(c,o,"read from private field"),t?t.call(c):o.get(c)),r=(c,o,t)=>o.has(c)?te("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(c):o.set(c,t),n=(c,o,t,s)=>(Q(c,o,"write to private field"),s?s.call(c,t):o.set(c,t),t),b=(c,o,t)=>(Q(c,o,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const he=require("../element-linked-store/index.cjs"),m=require("../css-property/index.cjs"),N=require("../index-Cqw2NKev.cjs"),Y=require("../events-KVanG9sR.cjs"),ce=require("../function-MthRj-GJ.cjs"),se=require("../style-At6aDoqG.cjs"),ie=require("../url-D1CgmwZ_.cjs"),re=require("../window-resizer/index.cjs"),F=require("../device/index.cjs");var u,y,J,K;class le{constructor(){r(this,u,new Map);r(this,y,[]);r(this,J,o=>{var s;const t=[...e(this,y)].reverse().find(i=>i.clickOutside.current);if(t){const i=o.composedPath();if(i.find(ee=>ee instanceof HTMLElement&&ee.hasAttribute("data-popover-content")))return;const l=i[0],p=l instanceof Node&&(t.contains(l)||((s=t.shadowRoot)==null?void 0:s.contains(l))),H=l instanceof HTMLElement&&l.hasAttribute("data-outside");(!p||H)&&t.close()}});r(this,K,o=>{if(o.code==="Escape"){const t=[...e(this,y)].reverse().find(s=>s.escape.current);t&&t.close()}});addEventListener("click",e(this,J)),addEventListener("keydown",e(this,K))}get groups(){return e(this,u)}get stack(){return e(this,y)}add(o,t){if(t.closeRest.current)e(this,u).forEach(i=>{i.forEach(l=>{l.close()})});else if(t.closeRestInGroup.current){let i=e(this,u).get(o);i==null||i.forEach(l=>{l.close()})}let s=e(this,u).get(o);s!=null&&s.length||(s=[],e(this,u).set(o,s)),e(this,y).push(t),s.push(t)}remove(o,t){if(n(this,y,e(this,y).filter(s=>s!==t)),t.closeRest.current){let s=[];e(this,u).forEach(i=>{i.forEach(l=>s.push(l))}),e(this,u).clear(),s.forEach(i=>i.close())}else if(t.closeRestInGroup.current){const s=e(this,u).get(o);e(this,u).delete(o),s==null||s.forEach(i=>{i.close()})}else{let s=e(this,u).get(o);s&&(s=s.filter(i=>i!==t),e(this,u).set(o,s))}}}u=new WeakMap,y=new WeakMap,J=new WeakMap,K=new WeakMap;var f,M,V,C,B,v,w,x,A,g,R,q,L,T,O,a,P,oe,I,$,S,W,G;const E=class E extends HTMLElement{constructor(){super();r(this,P);r(this,f);r(this,M);r(this,V);r(this,C);r(this,B);r(this,v);r(this,w);r(this,x);r(this,A);r(this,g);r(this,R);r(this,q);r(this,L);r(this,T);r(this,O);r(this,a);r(this,$);r(this,S);r(this,W);r(this,G);this.urlValue="",n(this,f,!1),n(this,v,new m.CSSProperty(this,"--history",!1)),n(this,w,new m.CSSProperty(this,"--restore",!1)),n(this,x,new m.CSSProperty(this,"--close-rest",!1)),n(this,A,new m.CSSProperty(this,"--close-rest-in-group",!1)),n(this,g,new m.CSSProperty(this,"--group","")),n(this,R,new m.CSSProperty(this,"--click-outside",!1)),n(this,q,new m.CSSProperty(this,"--escape",!1)),n(this,L,new m.CSSProperty(this,"--check-viewport-bounds",!1)),n(this,T,!1),n(this,a,new he.ElementLinkedStore(this,{opened:!1,closing:!1,triggered:!1,transitionend:!1})),n(this,$,()=>{n(this,T,!1),e(this,f)&&e(this,v).current&&!location.search.includes(this.id)?this.close():!e(this,f)&&e(this,v).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),n(this,T,!0)}),n(this,S,()=>{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,W).call(this)}),n(this,W,ce.debounce(()=>{e(this,G).call(this)},10)),n(this,G,()=>{if(this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px"),e(this,L).current){const t=this.getBoundingClientRect();let s=0,i=0;t.right>F.viewport.width?s=F.viewport.width-t.right:t.left<0&&(s=t.left*-1),t.bottom>F.viewport.height?i=F.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")}}),e(this,g).subscribe(t=>{t.previous&&(E.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=E.stack.groups.get(this.group.current),i=s==null?void 0:s.find(l=>l.opened);document.documentElement.classList.toggle(`${this.group.current}-opened`,!!i)}})}get history(){return e(this,v)}get restore(){return e(this,w)}get closeRest(){return e(this,x)}get closeRestInGroup(){return e(this,A)}get group(){return e(this,g)}get clickOutside(){return e(this,R)}get escape(){return e(this,q)}get opened(){return e(this,f)}get lastTrigger(){return e(this,O)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(t){this.urlValue=(t==null?void 0:t.toString())||"",e(this,f)&&ie.updateSearchParameter(this.id,t)}open(t){if(e(this,f))return;n(this,O,t==null?void 0:t.trigger),clearTimeout(e(this,M)),clearTimeout(e(this,V)),e(this,a).set("closing",!1),e(this,a).set("triggered",!0),Y.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,O)}}),e(this,v).current&&e(this,T)&&history.pushState(history.state,"",e(this,P,oe)),n(this,f,!0);const s=()=>{E.stack.add(e(this,g).current,this),e(this,S).call(this),e(this,a).set("opened",!0),Y.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,O)}}),n(this,C,void 0),n(this,B,setTimeout(()=>{e(this,a).set("transitionend",!0)},se.getElementTransitionDurationMS(this)+10))};t!=null&&t.skipTransition?s():n(this,C,setTimeout(s,10))}close(){e(this,f)&&(clearTimeout(e(this,C)),clearTimeout(e(this,B)),E.stack.remove(e(this,g).current,this),n(this,f,!1),b(this,P,I).call(this),e(this,a).set("transitionend",!1),n(this,M,setTimeout(()=>{e(this,a).set("opened",!1),e(this,a).set("closing",!0),Y.dispatchEvent(this,"popoverClosing",{custom:!0}),n(this,V,setTimeout(()=>{e(this,a).set("triggered",!1),e(this,a).set("closing",!1),Y.dispatchEvent(this,"popoverClosed",{custom:!0})},se.getElementTransitionDurationMS(this)+10))},10)))}connectedCallback(){e(this,v).observe(),e(this,w).observe(),e(this,x).observe(),e(this,A).observe(),e(this,g).observe(),e(this,R).observe(),e(this,q).observe(),e(this,L).observe(),this.setAttribute("role","dialog"),addEventListener("popstate",e(this,$)),setTimeout(()=>{e(this,w).current?(this.urlValue=ie.parseSearchParameters(location.search)[this.id],e(this,$).call(this)):(b(this,P,I).call(this),n(this,T,!0))},0),e(this,L).subscribe(()=>{e(this,S).call(this)}),re.windowResizer.subscribe(e(this,S))}disconnectedCallback(){E.stack.remove(e(this,g).current,this),re.windowResizer.unsubscribe(e(this,S)),e(this,a).close(),e(this,v).close(),e(this,w).close(),e(this,x).close(),e(this,A).close(),e(this,g).close(),e(this,R).close(),e(this,q).close(),e(this,L).close(),this.removeAttribute("role"),clearTimeout(e(this,M)),clearTimeout(e(this,V)),clearTimeout(e(this,C)),clearTimeout(e(this,B)),removeEventListener("popstate",e(this,$)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),b(this,P,I).call(this)}};f=new WeakMap,M=new WeakMap,V=new WeakMap,C=new WeakMap,B=new WeakMap,v=new WeakMap,w=new WeakMap,x=new WeakMap,A=new WeakMap,g=new WeakMap,R=new WeakMap,q=new WeakMap,L=new WeakMap,T=new WeakMap,O=new WeakMap,a=new WeakMap,P=new WeakSet,oe=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},I=function(){if(e(this,v).current){const t=new URL(location.href);t.searchParams.delete(this.id),history.replaceState(history.state,"",t.href)}},$=new WeakMap,S=new WeakMap,W=new WeakMap,G=new WeakMap,E.stack=new le;let z=E;N.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",z);var h,d,k,Z,D,U,j,X,_;class ne extends HTMLElement{constructor(){super();r(this,k);r(this,h);r(this,d,new m.CSSProperty(this,"--type","open"));r(this,D,()=>{e(this,d).current!=="close"&&this.classList.add("triggered")});r(this,U,()=>{e(this,d).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))});r(this,j,()=>{e(this,d).current!=="close"&&this.classList.remove("opened")});r(this,X,()=>{e(this,d).current!=="close"&&(this.classList.remove("triggered"),this.setAttribute("aria-expanded","false"))});N.isBrowser&&(this.addEventListener("click",()=>{if(e(this,h)){const t=e(this,d).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"&&t.currentTarget.click()}))}get type(){return e(this,d)}get popoverElement(){return e(this,h)}changePopover(t){var s;if(b(this,k,Z).call(this),t){let i=null;if(t==="parent"){const l=this.closest("[data-popover]");if(l)i=l;else{const p=this.getRootNode();p instanceof ShadowRoot?i=p.host.closest("[data-popover]"):p instanceof HTMLElement&&(i=p.closest("[data-popover]"))}}else if(t==="sibling")i=(s=this.parentElement)==null?void 0:s.querySelector("[data-popover]");else if(t==="ancestor-child"){const l=p=>{if(!p)return null;let H=p.querySelector("[data-popover]");return!H&&(p!=null&&p.parentElement)&&(H=l(p.parentElement)),H};i=l(this.parentElement)||null}else!t.startsWith(".")&&!t.startsWith("[")&&(t=`#${t}`),i=document.querySelector(t)||this.getRootNode().querySelector(t);i instanceof HTMLElement?(n(this,h,i),e(this,h).addEventListener("popoverTriggered",e(this,D)),e(this,h).addEventListener("popoverOpened",e(this,U)),e(this,h).addEventListener("popoverClosing",e(this,j)),e(this,h).addEventListener("popoverClosed",e(this,X))):console.warn(this,`target ${t} not found`)}b(this,k,_).call(this,e(this,d).current)}connectedCallback(){e(this,d).subscribe(s=>{b(this,k,_).call(this,s.current)}),this.hasAttribute("tabindex")||(this.tabIndex=0);const t=this.getAttribute("target");t&&this.changePopover(t),this.isConnected&&e(this,d).observe()}disconnectedCallback(){e(this,d).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),b(this,k,Z).call(this)}}h=new WeakMap,d=new WeakMap,k=new WeakSet,Z=function(){e(this,h)&&(e(this,h).removeEventListener("popoverTriggered",e(this,D)),e(this,h).removeEventListener("popoverOpened",e(this,U)),e(this,h).removeEventListener("popoverClosing",e(this,j)),e(this,h).removeEventListener("popoverClosed",e(this,X)))},D=new WeakMap,U=new WeakMap,j=new WeakMap,X=new WeakMap,_=function(t){e(this,h)instanceof z&&(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")))};N.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",ne);exports.PopoverButtonElement=ne;exports.PopoverElement=z;
|
|
1
|
+
"use strict";var te=c=>{throw TypeError(c)};var Q=(c,o,t)=>o.has(c)||te("Cannot "+t);var e=(c,o,t)=>(Q(c,o,"read from private field"),t?t.call(c):o.get(c)),r=(c,o,t)=>o.has(c)?te("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(c):o.set(c,t),n=(c,o,t,s)=>(Q(c,o,"write to private field"),s?s.call(c,t):o.set(c,t),t),b=(c,o,t)=>(Q(c,o,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const he=require("../element-linked-store/index.cjs"),y=require("../css-property/index.cjs"),N=require("../index-Cqw2NKev.cjs"),Y=require("../events-KVanG9sR.cjs"),ce=require("../function-MthRj-GJ.cjs"),se=require("../style-At6aDoqG.cjs"),ie=require("../url-D1CgmwZ_.cjs"),re=require("../window-resizer/index.cjs"),F=require("../device/index.cjs");var u,m,J,K;class le{constructor(){r(this,u,new Map);r(this,m,[]);r(this,J,o=>{var s;const t=[...e(this,m)].reverse().find(i=>i.clickOutside.current);if(t){const i=o.composedPath();if(i.find(ee=>ee instanceof HTMLElement&&ee.hasAttribute("data-popover-content")))return;const l=i[0],p=l instanceof Node&&(t.contains(l)||((s=t.shadowRoot)==null?void 0:s.contains(l))),H=l instanceof HTMLElement&&l.hasAttribute("data-outside");(!p||H)&&t.close()}});r(this,K,o=>{if(o.code==="Escape"){const t=[...e(this,m)].reverse().find(s=>s.escape.current);console.log(e(this,m)),t&&t.close()}});addEventListener("click",e(this,J)),addEventListener("keydown",e(this,K))}get groups(){return e(this,u)}get stack(){return e(this,m)}add(o,t){if(t.closeRest.current)e(this,u).forEach(i=>{i.forEach(l=>{l.close()})});else if(t.closeRestInGroup.current){let i=e(this,u).get(o);i==null||i.forEach(l=>{l.close()})}let s=e(this,u).get(o);s!=null&&s.length||(s=[],e(this,u).set(o,s)),e(this,m).push(t),s.push(t)}remove(o,t){if(n(this,m,e(this,m).filter(s=>s!==t)),t.closeRest.current){let s=[];e(this,u).forEach(i=>{i.forEach(l=>s.push(l))}),e(this,u).clear(),s.forEach(i=>i.close())}else if(t.closeRestInGroup.current){const s=e(this,u).get(o);e(this,u).delete(o),s==null||s.forEach(i=>{i.close()})}else{let s=e(this,u).get(o);s&&(s=s.filter(i=>i!==t),e(this,u).set(o,s))}}}u=new WeakMap,m=new WeakMap,J=new WeakMap,K=new WeakMap;var f,M,V,C,B,v,w,x,A,g,R,q,L,T,O,a,P,oe,I,$,S,W,G;const E=class E extends HTMLElement{constructor(){super();r(this,P);r(this,f);r(this,M);r(this,V);r(this,C);r(this,B);r(this,v);r(this,w);r(this,x);r(this,A);r(this,g);r(this,R);r(this,q);r(this,L);r(this,T);r(this,O);r(this,a);r(this,$);r(this,S);r(this,W);r(this,G);this.urlValue="",n(this,f,!1),n(this,v,new y.CSSProperty(this,"--history",!1)),n(this,w,new y.CSSProperty(this,"--restore",!1)),n(this,x,new y.CSSProperty(this,"--close-rest",!1)),n(this,A,new y.CSSProperty(this,"--close-rest-in-group",!1)),n(this,g,new y.CSSProperty(this,"--group","")),n(this,R,new y.CSSProperty(this,"--click-outside",!1)),n(this,q,new y.CSSProperty(this,"--escape",!1)),n(this,L,new y.CSSProperty(this,"--check-viewport-bounds",!1)),n(this,T,!1),n(this,a,new he.ElementLinkedStore(this,{opened:!1,closing:!1,triggered:!1,transitionend:!1})),n(this,$,()=>{n(this,T,!1),e(this,f)&&e(this,v).current&&!location.search.includes(this.id)?this.close():!e(this,f)&&e(this,v).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),n(this,T,!0)}),n(this,S,()=>{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,W).call(this)}),n(this,W,ce.debounce(()=>{e(this,G).call(this)},10)),n(this,G,()=>{if(this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px"),e(this,L).current){const t=this.getBoundingClientRect();let s=0,i=0;t.right>F.viewport.width?s=F.viewport.width-t.right:t.left<0&&(s=t.left*-1),t.bottom>F.viewport.height?i=F.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")}}),e(this,g).subscribe(t=>{t.previous&&(E.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=E.stack.groups.get(this.group.current),i=s==null?void 0:s.find(l=>l.opened);document.documentElement.classList.toggle(`${this.group.current}-opened`,!!i)}})}get history(){return e(this,v)}get restore(){return e(this,w)}get closeRest(){return e(this,x)}get closeRestInGroup(){return e(this,A)}get group(){return e(this,g)}get clickOutside(){return e(this,R)}get escape(){return e(this,q)}get opened(){return e(this,f)}get lastTrigger(){return e(this,O)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(t){this.urlValue=(t==null?void 0:t.toString())||"",e(this,f)&&ie.updateSearchParameter(this.id,t)}open(t){if(e(this,f))return;n(this,O,t==null?void 0:t.trigger),clearTimeout(e(this,M)),clearTimeout(e(this,V)),e(this,a).set("closing",!1),e(this,a).set("triggered",!0),Y.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,O)}}),e(this,v).current&&e(this,T)&&history.pushState(history.state,"",e(this,P,oe)),n(this,f,!0);const s=()=>{E.stack.add(e(this,g).current,this),e(this,S).call(this),e(this,a).set("opened",!0),Y.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,O)}}),n(this,C,void 0),n(this,B,setTimeout(()=>{e(this,a).set("transitionend",!0)},se.getElementTransitionDurationMS(this)+10))};t!=null&&t.skipTransition?s():n(this,C,setTimeout(s,10))}close(){e(this,f)&&(clearTimeout(e(this,C)),clearTimeout(e(this,B)),E.stack.remove(e(this,g).current,this),n(this,f,!1),b(this,P,I).call(this),e(this,a).set("transitionend",!1),n(this,M,setTimeout(()=>{e(this,a).set("opened",!1),e(this,a).set("closing",!0),Y.dispatchEvent(this,"popoverClosing",{custom:!0}),n(this,V,setTimeout(()=>{e(this,a).set("triggered",!1),e(this,a).set("closing",!1),Y.dispatchEvent(this,"popoverClosed",{custom:!0})},se.getElementTransitionDurationMS(this)+10))},10)))}connectedCallback(){e(this,v).observe(),e(this,w).observe(),e(this,x).observe(),e(this,A).observe(),e(this,g).observe(),e(this,R).observe(),e(this,q).observe(),e(this,L).observe(),this.setAttribute("role","dialog"),addEventListener("popstate",e(this,$)),setTimeout(()=>{e(this,w).current?(this.urlValue=ie.parseSearchParameters(location.search)[this.id],e(this,$).call(this)):(b(this,P,I).call(this),n(this,T,!0))},0),e(this,L).subscribe(()=>{e(this,S).call(this)}),re.windowResizer.subscribe(e(this,S))}disconnectedCallback(){E.stack.remove(e(this,g).current,this),re.windowResizer.unsubscribe(e(this,S)),e(this,a).close(),e(this,v).close(),e(this,w).close(),e(this,x).close(),e(this,A).close(),e(this,g).close(),e(this,R).close(),e(this,q).close(),e(this,L).close(),this.removeAttribute("role"),clearTimeout(e(this,M)),clearTimeout(e(this,V)),clearTimeout(e(this,C)),clearTimeout(e(this,B)),removeEventListener("popstate",e(this,$)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),b(this,P,I).call(this)}};f=new WeakMap,M=new WeakMap,V=new WeakMap,C=new WeakMap,B=new WeakMap,v=new WeakMap,w=new WeakMap,x=new WeakMap,A=new WeakMap,g=new WeakMap,R=new WeakMap,q=new WeakMap,L=new WeakMap,T=new WeakMap,O=new WeakMap,a=new WeakMap,P=new WeakSet,oe=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},I=function(){if(e(this,v).current){const t=new URL(location.href);t.searchParams.delete(this.id),history.replaceState(history.state,"",t.href)}},$=new WeakMap,S=new WeakMap,W=new WeakMap,G=new WeakMap,E.stack=new le;let z=E;N.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",z);var h,d,k,Z,D,U,j,X,_;class ne extends HTMLElement{constructor(){super();r(this,k);r(this,h);r(this,d,new y.CSSProperty(this,"--type","open"));r(this,D,()=>{e(this,d).current!=="close"&&this.classList.add("triggered")});r(this,U,()=>{e(this,d).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))});r(this,j,()=>{e(this,d).current!=="close"&&this.classList.remove("opened")});r(this,X,()=>{e(this,d).current!=="close"&&(this.classList.remove("triggered"),this.setAttribute("aria-expanded","false"))});N.isBrowser&&(this.addEventListener("click",()=>{if(e(this,h)){const t=e(this,d).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"&&t.currentTarget.click()}))}get type(){return e(this,d)}get popoverElement(){return e(this,h)}changePopover(t){var s;if(b(this,k,Z).call(this),t){let i=null;if(t==="parent"){const l=this.closest("[data-popover]");if(l)i=l;else{const p=this.getRootNode();p instanceof ShadowRoot?i=p.host.closest("[data-popover]"):p instanceof HTMLElement&&(i=p.closest("[data-popover]"))}}else if(t==="sibling")i=(s=this.parentElement)==null?void 0:s.querySelector("[data-popover]");else if(t==="ancestor-child"){const l=p=>{if(!p)return null;let H=p.querySelector("[data-popover]");return!H&&(p!=null&&p.parentElement)&&(H=l(p.parentElement)),H};i=l(this.parentElement)||null}else!t.startsWith(".")&&!t.startsWith("[")&&(t=`#${t}`),i=document.querySelector(t)||this.getRootNode().querySelector(t);i instanceof HTMLElement?(n(this,h,i),e(this,h).addEventListener("popoverTriggered",e(this,D)),e(this,h).addEventListener("popoverOpened",e(this,U)),e(this,h).addEventListener("popoverClosing",e(this,j)),e(this,h).addEventListener("popoverClosed",e(this,X))):console.warn(this,`target ${t} not found`)}b(this,k,_).call(this,e(this,d).current)}connectedCallback(){e(this,d).subscribe(s=>{b(this,k,_).call(this,s.current)}),this.hasAttribute("tabindex")||(this.tabIndex=0);const t=this.getAttribute("target");t&&this.changePopover(t),this.isConnected&&e(this,d).observe()}disconnectedCallback(){e(this,d).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),b(this,k,Z).call(this)}}h=new WeakMap,d=new WeakMap,k=new WeakSet,Z=function(){e(this,h)&&(e(this,h).removeEventListener("popoverTriggered",e(this,D)),e(this,h).removeEventListener("popoverOpened",e(this,U)),e(this,h).removeEventListener("popoverClosing",e(this,j)),e(this,h).removeEventListener("popoverClosed",e(this,X)))},D=new WeakMap,U=new WeakMap,j=new WeakMap,X=new WeakMap,_=function(t){e(this,h)instanceof z&&(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")))};N.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",ne);exports.PopoverButtonElement=ne;exports.PopoverElement=z;
|
package/lib/popover/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var et = (c) => {
|
|
|
4
4
|
var Q = (c, o, e) => o.has(c) || et("Cannot " + e);
|
|
5
5
|
var t = (c, o, e) => (Q(c, o, "read from private field"), e ? e.call(c) : o.get(c)), r = (c, o, e) => o.has(c) ? et("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(c) : o.set(c, e), h = (c, o, e, s) => (Q(c, o, "write to private field"), s ? s.call(c, e) : o.set(c, e), e), y = (c, o, e) => (Q(c, o, "access private method"), e);
|
|
6
6
|
import { ElementLinkedStore as ot } from "../element-linked-store/index.js";
|
|
7
|
-
import { CSSProperty as
|
|
7
|
+
import { CSSProperty as b } from "../css-property/index.js";
|
|
8
8
|
import { i as _ } from "../index-euf5anj6.js";
|
|
9
9
|
import { d as Y } from "../events-CsVF98U6.js";
|
|
10
10
|
import { d as ht } from "../function-C10DGppn.js";
|
|
@@ -12,14 +12,14 @@ import { g as st } from "../style-j2TwriJ_.js";
|
|
|
12
12
|
import { u as nt, p as ct } from "../url-B6BNcw6_.js";
|
|
13
13
|
import { windowResizer as it } from "../window-resizer/index.js";
|
|
14
14
|
import { viewport as j } from "../device/index.js";
|
|
15
|
-
var u,
|
|
15
|
+
var u, v, J, K;
|
|
16
16
|
class lt {
|
|
17
17
|
constructor() {
|
|
18
18
|
r(this, u, /* @__PURE__ */ new Map());
|
|
19
|
-
r(this,
|
|
19
|
+
r(this, v, []);
|
|
20
20
|
r(this, J, (o) => {
|
|
21
21
|
var s;
|
|
22
|
-
const e = [...t(this,
|
|
22
|
+
const e = [...t(this, v)].reverse().find((i) => i.clickOutside.current);
|
|
23
23
|
if (e) {
|
|
24
24
|
const i = o.composedPath();
|
|
25
25
|
if (i.find(
|
|
@@ -32,8 +32,8 @@ class lt {
|
|
|
32
32
|
});
|
|
33
33
|
r(this, K, (o) => {
|
|
34
34
|
if (o.code === "Escape") {
|
|
35
|
-
const e = [...t(this,
|
|
36
|
-
e && e.close();
|
|
35
|
+
const e = [...t(this, v)].reverse().find((s) => s.escape.current);
|
|
36
|
+
console.log(t(this, v)), e && e.close();
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
addEventListener("click", t(this, J)), addEventListener("keydown", t(this, K));
|
|
@@ -42,7 +42,7 @@ class lt {
|
|
|
42
42
|
return t(this, u);
|
|
43
43
|
}
|
|
44
44
|
get stack() {
|
|
45
|
-
return t(this,
|
|
45
|
+
return t(this, v);
|
|
46
46
|
}
|
|
47
47
|
add(o, e) {
|
|
48
48
|
if (e.closeRest.current)
|
|
@@ -58,10 +58,10 @@ class lt {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
let s = t(this, u).get(o);
|
|
61
|
-
s != null && s.length || (s = [], t(this, u).set(o, s)), t(this,
|
|
61
|
+
s != null && s.length || (s = [], t(this, u).set(o, s)), t(this, v).push(e), s.push(e);
|
|
62
62
|
}
|
|
63
63
|
remove(o, e) {
|
|
64
|
-
if (h(this,
|
|
64
|
+
if (h(this, v, t(this, v).filter((s) => s !== e)), e.closeRest.current) {
|
|
65
65
|
let s = [];
|
|
66
66
|
t(this, u).forEach((i) => {
|
|
67
67
|
i.forEach((l) => s.push(l));
|
|
@@ -77,7 +77,7 @@ class lt {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
u = new WeakMap(),
|
|
80
|
+
u = new WeakMap(), v = new WeakMap(), J = new WeakMap(), K = new WeakMap();
|
|
81
81
|
var f, M, H, A, W, g, w, S, C, m, R, $, L, T, O, a, P, rt, F, V, k, q, z;
|
|
82
82
|
const E = class E extends HTMLElement {
|
|
83
83
|
constructor() {
|
|
@@ -103,11 +103,11 @@ const E = class E extends HTMLElement {
|
|
|
103
103
|
r(this, k);
|
|
104
104
|
r(this, q);
|
|
105
105
|
r(this, z);
|
|
106
|
-
this.urlValue = "", h(this, f, !1), h(this, g, new
|
|
106
|
+
this.urlValue = "", h(this, f, !1), h(this, g, new b(this, "--history", !1)), h(this, w, new b(this, "--restore", !1)), h(this, S, new b(this, "--close-rest", !1)), h(this, C, new b(
|
|
107
107
|
this,
|
|
108
108
|
"--close-rest-in-group",
|
|
109
109
|
!1
|
|
110
|
-
)), h(this, m, new
|
|
110
|
+
)), h(this, m, new b(this, "--group", "")), h(this, R, new b(this, "--click-outside", !1)), h(this, $, new b(this, "--escape", !1)), h(this, L, new b(this, "--check-viewport-bounds", !1)), h(this, T, !1), h(this, a, new ot(this, {
|
|
111
111
|
opened: !1,
|
|
112
112
|
closing: !1,
|
|
113
113
|
triggered: !1,
|
|
@@ -236,7 +236,7 @@ class at extends HTMLElement {
|
|
|
236
236
|
super();
|
|
237
237
|
r(this, x);
|
|
238
238
|
r(this, n);
|
|
239
|
-
r(this, d, new
|
|
239
|
+
r(this, d, new b(this, "--type", "open"));
|
|
240
240
|
r(this, B, () => {
|
|
241
241
|
t(this, d).current !== "close" && this.classList.add("triggered");
|
|
242
242
|
});
|