aptechka 0.47.11 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +60 -60
- package/lib/radio/index.cjs +1 -0
- package/lib/radio/index.d.ts +19 -0
- package/lib/radio/index.js +67 -0
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Инари
|
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var pt=(i,t)=>(t=Symbol[i])?t:Symbol.for("Symbol."+i),Et=i=>{throw TypeError(i)};var $=(i,t,s)=>t.has(i)||Et("Cannot "+s);var e=(i,t,s)=>($(i,t,"read from private field"),s?s.call(i):t.get(i)),o=(i,t,s)=>t.has(i)?Et("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),a=(i,t,s,r)=>($(i,t,"write to private field"),r?r.call(i,s):t.set(i,s),s),d=(i,t,s)=>($(i,t,"access private method"),s);var M=(i,t,s)=>new Promise((r,u)=>{var f=l=>{try{k(s.next(l))}catch(g){u(g)}},B=l=>{try{k(s.throw(l))}catch(g){u(g)}},k=l=>l.done?r(l.value):Promise.resolve(l.value).then(f,B);k((s=s.apply(i,t)).next())});var gt=(i,t,s)=>(t=i[pt("asyncIterator")])?t.call(i):(i=i[pt("iterator")](),t={},s=(r,u)=>(u=i[r])&&(t[r]=f=>new Promise((B,k,l)=>(f=u.call(i,f),l=f.done,Promise.resolve(f.value).then(g=>B({value:g,done:l}),k)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=require("../index-Cqw2NKev.cjs"),G=require("../events-KVanG9sR.cjs"),Mt=require("../polyfills-Df4r-ETT.cjs"),Tt=require("../scroll-H9zqFeML.cjs"),J=require("../url-CLvdjbII.cjs"),Ht=require("../css-value-parser/index.cjs");class wt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,r]of Object.entries(t))this.setAttribute(s,r)}}St.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",wt);var L,c,T,W,z;class vt{constructor(t,s){o(this,L);o(this,c);o(this,T);o(this,W,t=>{t.preventDefault();const s=e(this,c).getAttribute("data-history-action")||"push",r=e(this,c).hasAttribute("data-center-scroll"),u=getComputedStyle(e(this,c)).getPropertyValue("--offset-scroll").trim(),f=u?Ht.cssValueParser.parse(u):void 0,B=e(this,c).hasAttribute("data-revalidate");e(this,L).navigate(e(this,T),{historyAction:s,centerScroll:r,offsetScroll:f,revalidate:B})});o(this,z,()=>{e(this,L).prefetch(e(this,T)),e(this,c).removeEventListener("pointerenter",e(this,z))});a(this,L,s),a(this,c,t),a(this,T,e(this,c).getAttribute("href")||"/"),e(this,c).addEventListener("click",e(this,W)),this.checkCurrent(e(this,L).normalizePath(e(this,T)).pathname),e(this,c).hasAttribute("data-prefetch")&&e(this,c).addEventListener("pointerenter",e(this,z))}get element(){return e(this,c)}checkCurrent(t){const s=e(this,L).normalizePath(location.pathname);e(this,c).hasAttribute("data-include")&&s.pathname.includes(t)?e(this,c).classList.add("current"):t===s.pathname&&e(this,c).classList.add("current")}destroy(){e(this,c).removeEventListener("click",e(this,W)),e(this,c).removeEventListener("pointerenter",e(this,z)),e(this,c).classList.remove("current")}}L=new WeakMap,c=new WeakMap,T=new WeakMap,W=new WeakMap,z=new WeakMap;var H,F,p,x,N,b;class yt{constructor(t,s,r){o(this,H);o(this,F);o(this,p,{x:0,y:0});o(this,x);o(this,N,null);o(this,b,null);a(this,H,t),a(this,F,s),a(this,x,r.cloneNode(!0))}get pathname(){return e(this,F)}get scrollState(){return e(this,p)}get document(){return e(this,b)}cloneDocument(){a(this,b,(e(this,N)||e(this,x)).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,F)}return t}clearScrollState(){e(this,p).x=0,e(this,p).y=0}clearDocumentState(){a(this,N,null)}saveScrollState(){e(this,x).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,p).x=0,e(this,p).y=0):(e(this,p).x=e(this,H).scrollElement.scrollLeft,e(this,p).y=e(this,H).scrollElement.scrollTop)}saveDocumentState(){e(this,x).documentElement.hasAttribute("data-no-page-restoration")?a(this,N,null):a(this,N,document.cloneNode(!0))}restoreScrollPosition(){e(this,H).scrollElement.scroll({top:e(this,p).y,left:e(this,p).x})}}H=new WeakMap,F=new WeakMap,p=new WeakMap,x=new WeakMap,N=new WeakMap,b=new WeakMap;var P,j,E,Q,A,m,_,D,C,I,V,R,h,tt,et,st,Lt,it,rt,nt,ot,X;class xt{constructor(t){o(this,h);o(this,P,null);o(this,j,null);o(this,E,[]);o(this,Q,new DOMParser);o(this,A);o(this,m,null);o(this,_);o(this,D,[]);o(this,C,!1);o(this,I,null);o(this,V,new Map);o(this,R,null);o(this,X,t=>M(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(a(this,C,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,C,!1))}));if(St.isBrowser){a(this,P,{base:J.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body"}),a(this,j,d(this,h,st).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,m,s.pathname),e(this,V).set(e(this,m),new yt(this,e(this,m),document)),document.documentElement.setAttribute("data-current-pathname",e(this,m)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,X)),J.changeHistory({action:"replace",pathname:e(this,m),searchParameters:s.parameters,hash:s.hash}),a(this,R,new wt),d(this,h,nt).call(this,document)}}get currentPathname(){return e(this,m)}get previousPathname(){return e(this,_)}get links(){return e(this,E)}get scrollElement(){return e(this,I)}normalizePath(t){return J.splitPath(t,{base:e(this,P).base,trailingSlash:e(this,P).trailingSlash})}prefetch(t){return M(this,null,function*(){const s=this.normalizePath(t);d(this,h,et).call(this,s.pathname)})}navigate(B){return M(this,arguments,function*(t,{historyAction:s="push",centerScroll:r,offsetScroll:u,revalidate:f}={}){if(e(this,D).length)return;const k=this.normalizePath(t);let{pathname:l,hash:g,parameters:bt,leaf:Pt}=k;if(e(this,A)===l||e(this,m)===l){e(this,C)||d(this,h,ot).call(this,g||0,{centerScroll:r,offsetScroll:u,behavior:"smooth"});return}e(this,E).forEach(q=>{q.checkCurrent(l)}),a(this,A,l);try{let q=!0;if(this.preprocessor)try{yield new Promise((n,S)=>{var w;(w=this.preprocessor)==null||w.call(this,{pathname:l,resolve:n,reject:S})})}catch(n){n?console.error(n):console.log("Route change canceled"),q=!1}if(!q||e(this,A)!==l){e(this,E).forEach(n=>{n.checkCurrent(e(this,m))});return}const at=yield d(this,h,tt).call(this,e(this,m)),y=yield d(this,h,tt).call(this,l,f);if(e(this,A)!==l){e(this,E).forEach(n=>{n.checkCurrent(e(this,m))});return}at.saveScrollState(),at.saveDocumentState(),e(this,C)||(y.clearScrollState(),y.clearDocumentState()),y.cloneDocument(),e(this,R).textContent=y.title,document.body.appendChild(e(this,R));const ht={pathname:l};G.dispatchEvent(document,"morphStart",{detail:ht});const lt=Array.from(document.head.children),ct=Array.from(y.document.head.children),ut=d(this,h,Lt).call(this,lt,ct),At=d(this,h,it).call(this,lt,ut),K=d(this,h,it).call(this,ct,ut);K.forEach((n,S)=>{if(n.tagName==="SCRIPT"&&n.getAttribute("src")){const w=document.createElement("script");w.type="module",w.src=n.getAttribute("src"),K[S]=w}}),K.forEach(n=>{document.head.appendChild(n)});const Z=K.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(d(this,h,rt).call(this,n))return!0});e(this,P).waitForHeadToLoad&&Z.length&&(yield new Promise(n=>M(this,null,function*(){let S=0;try{for(var w=gt(Z),mt,O,ft;mt=!(O=yield w.next()).done;mt=!1){const U=O.value;U.onload=()=>{S++,S===Z.length&&n()}}}catch(O){ft=[O]}finally{try{mt&&(O=w.return)&&(yield O.call(w))}finally{if(ft)throw ft[0]}}})));const dt=[];At.forEach(n=>{n.hasAttribute("data-permanent")||(d(this,h,rt).call(this,n)?dt.push(n):n.remove())});const Ct=d(this,h,st).call(this,y.document.body);d(this,h,nt).call(this,y.document),document.documentElement.setAttribute("data-current-pathname",l),document.documentElement.setAttribute("data-current-leaf",Pt),J.changeHistory({action:s,pathname:l,searchParameters:bt,hash:g}),e(this,R).remove(),a(this,_,e(this,m)),a(this,m,l),e(this,j).forEach((n,S)=>{const w=Ct[S],mt=getComputedStyle(n).getPropertyValue("--morph-duration"),O=[...w.childNodes];if(mt){const ft=[...n.childNodes];ft.forEach(v=>{v instanceof HTMLElement&&v.classList.add("old")}),O.forEach(v=>{v instanceof HTMLElement&&v.classList.add("new")}),n.prepend(...O),Mt.requestIdleCallback(()=>{O.forEach(v=>{v instanceof HTMLElement&&v.classList.add("in")})});const U={morphElement:n,pathname:l};G.dispatchEvent(document,"morphNewChildrenAdded",{detail:U});const kt=new Promise(v=>{setTimeout(()=>{ft.forEach(Y=>Y.remove()),O.forEach(Y=>{Y instanceof HTMLElement&&Y.classList.remove("in","new")}),G.dispatchEvent(document,"morphOldChildrenRemoved",{detail:U}),v()},(parseFloat(mt)||0)*1e3+10)});e(this,D).push(kt)}else n.innerHTML="",n.append(...O)}),g?(y.clearScrollState(),d(this,h,ot).call(this,g,{centerScroll:r,offsetScroll:u})):e(this,C)&&y.restoreScrollPosition(),yield Promise.all(e(this,D)),dt.forEach(n=>n.remove()),a(this,D,[]),this.findLinks(),G.dispatchEvent(document,"morphComplete",{detail:ht}),window.dispatchEvent(new Event("resize"))}catch(q){console.error(q)}a(this,A,void 0)})}addLink(t){e(this,E).push(new vt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,E,e(this,E).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var r;return((r=s.getAttribute("href"))==null?void 0:r.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});e(this,E).forEach(s=>s.destroy()),a(this,E,t.map(s=>new vt(s,this)))}}P=new WeakMap,j=new WeakMap,E=new WeakMap,Q=new WeakMap,A=new WeakMap,m=new WeakMap,_=new WeakMap,D=new WeakMap,C=new WeakMap,I=new WeakMap,V=new WeakMap,R=new WeakMap,h=new WeakSet,tt=function(t,s=!1){return M(this,null,function*(){let r=e(this,V).get(t);return(!r||s)&&(r=yield d(this,h,et).call(this,t)),r})},et=function(t){return M(this,null,function*(){const r=yield(yield fetch(t)).text(),u=e(this,Q).parseFromString(r,"text/html"),f=new yt(this,t,u);return e(this,V).set(t,f),f})},st=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Lt=function(t,s){return t.filter(r=>s.find(u=>u.outerHTML===r.outerHTML))},it=function(t,s){return t.filter(r=>!s.find(u=>u.outerHTML===r.outerHTML))},rt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},nt=function(t){a(this,I,t.querySelector(e(this,P).scrollSelector)||t.documentElement)},ot=function(t,s){const r=typeof t=="string"?document.getElementById(t):t;(typeof r=="number"||r)&&Tt.scrollToElement(r,{scrollElement:e(this,I),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},X=new WeakMap;exports.Morph=xt;
|
|
1
|
+
"use strict";var pt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),Et=n=>{throw TypeError(n)};var $=(n,t,s)=>t.has(n)||Et("Cannot "+s);var e=(n,t,s)=>($(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?Et("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>($(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>($(n,t,"access private method"),s);var M=(n,t,s)=>new Promise((i,u)=>{var f=l=>{try{k(s.next(l))}catch(g){u(g)}},B=l=>{try{k(s.throw(l))}catch(g){u(g)}},k=l=>l.done?i(l.value):Promise.resolve(l.value).then(f,B);k((s=s.apply(n,t)).next())});var gt=(n,t,s)=>(t=n[pt("asyncIterator")])?t.call(n):(n=n[pt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=f=>new Promise((B,k,l)=>(f=u.call(n,f),l=f.done,Promise.resolve(f.value).then(g=>B({value:g,done:l}),k)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=require("../index-Cqw2NKev.cjs"),G=require("../events-KVanG9sR.cjs"),Mt=require("../polyfills-Df4r-ETT.cjs"),Tt=require("../scroll-H9zqFeML.cjs"),J=require("../url-CLvdjbII.cjs"),Ht=require("../css-value-parser/index.cjs");class Lt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(t))this.setAttribute(s,i)}}St.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Lt);var w,c,T,W,z;class vt{constructor(t,s){o(this,w);o(this,c);o(this,T);o(this,W,t=>{t.preventDefault();const s=e(this,c).getAttribute("data-history-action")||"push",i=e(this,c).hasAttribute("data-center-scroll"),u=getComputedStyle(e(this,c)).getPropertyValue("--offset-scroll").trim(),f=u?Ht.cssValueParser.parse(u):void 0,B=e(this,c).hasAttribute("data-revalidate");e(this,w).navigate(e(this,T),{historyAction:s,centerScroll:i,offsetScroll:f,revalidate:B})});o(this,z,()=>{e(this,w).prefetch(e(this,T)),e(this,c).removeEventListener("pointerenter",e(this,z))});a(this,w,s),a(this,c,t),a(this,T,e(this,c).getAttribute("href")||"/"),e(this,c).addEventListener("click",e(this,W)),this.checkCurrent(location.pathname),e(this,c).hasAttribute("data-prefetch")&&e(this,c).addEventListener("pointerenter",e(this,z))}get element(){return e(this,c)}checkCurrent(t){const s=e(this,w).normalizePath(t),i=e(this,w).normalizePath(e(this,T));e(this,c).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,c).classList.add("current"):i.pathname===s.pathname?e(this,c).classList.add("current"):e(this,c).classList.remove("current")}destroy(){e(this,c).removeEventListener("click",e(this,W)),e(this,c).removeEventListener("pointerenter",e(this,z)),e(this,c).classList.remove("current")}}w=new WeakMap,c=new WeakMap,T=new WeakMap,W=new WeakMap,z=new WeakMap;var H,F,p,x,N,b;class yt{constructor(t,s,i){o(this,H);o(this,F);o(this,p,{x:0,y:0});o(this,x);o(this,N,null);o(this,b,null);a(this,H,t),a(this,F,s),a(this,x,i.cloneNode(!0))}get pathname(){return e(this,F)}get scrollState(){return e(this,p)}get document(){return e(this,b)}cloneDocument(){a(this,b,(e(this,N)||e(this,x)).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,F)}return t}clearScrollState(){e(this,p).x=0,e(this,p).y=0}clearDocumentState(){a(this,N,null)}saveScrollState(){e(this,x).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,p).x=0,e(this,p).y=0):(e(this,p).x=e(this,H).scrollElement.scrollLeft,e(this,p).y=e(this,H).scrollElement.scrollTop)}saveDocumentState(){e(this,x).documentElement.hasAttribute("data-no-page-restoration")?a(this,N,null):a(this,N,document.cloneNode(!0))}restoreScrollPosition(){e(this,H).scrollElement.scroll({top:e(this,p).y,left:e(this,p).x})}}H=new WeakMap,F=new WeakMap,p=new WeakMap,x=new WeakMap,N=new WeakMap,b=new WeakMap;var P,j,E,Q,A,m,U,D,C,I,V,R,h,tt,et,st,wt,it,nt,rt,ot,X;class xt{constructor(t){o(this,h);o(this,P,null);o(this,j,null);o(this,E,[]);o(this,Q,new DOMParser);o(this,A);o(this,m,null);o(this,U);o(this,D,[]);o(this,C,!1);o(this,I,null);o(this,V,new Map);o(this,R,null);o(this,X,t=>M(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(a(this,C,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,C,!1))}));if(St.isBrowser){a(this,P,{base:J.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body"}),a(this,j,d(this,h,st).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,m,s.pathname),e(this,V).set(e(this,m),new yt(this,e(this,m),document)),document.documentElement.setAttribute("data-current-pathname",e(this,m)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,X)),J.changeHistory({action:"replace",pathname:e(this,m),searchParameters:s.parameters,hash:s.hash}),a(this,R,new Lt),d(this,h,rt).call(this,document)}}get currentPathname(){return e(this,m)}get previousPathname(){return e(this,U)}get links(){return e(this,E)}get scrollElement(){return e(this,I)}normalizePath(t){return J.splitPath(t,{base:e(this,P).base,trailingSlash:e(this,P).trailingSlash})}prefetch(t){return M(this,null,function*(){const s=this.normalizePath(t);d(this,h,et).call(this,s.pathname)})}navigate(B){return M(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:f}={}){if(e(this,D).length)return;const k=this.normalizePath(t);let{pathname:l,hash:g,parameters:bt,leaf:Pt}=k;if(e(this,A)===l||e(this,m)===l){e(this,C)||d(this,h,ot).call(this,g||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,A,l),e(this,E).forEach(q=>{q.checkCurrent(l)});try{let q=!0;if(this.preprocessor)try{yield new Promise((r,S)=>{var L;(L=this.preprocessor)==null||L.call(this,{pathname:l,resolve:r,reject:S})})}catch(r){r?console.error(r):console.log("Route change canceled"),q=!1}if(!q||e(this,A)!==l){e(this,E).forEach(r=>{r.checkCurrent(e(this,m))});return}const at=yield d(this,h,tt).call(this,e(this,m)),y=yield d(this,h,tt).call(this,l,f);if(e(this,A)!==l){e(this,E).forEach(r=>{r.checkCurrent(e(this,m))});return}at.saveScrollState(),at.saveDocumentState(),e(this,C)||(y.clearScrollState(),y.clearDocumentState()),y.cloneDocument(),e(this,R).textContent=y.title,document.body.appendChild(e(this,R));const ht={pathname:l};G.dispatchEvent(document,"morphStart",{detail:ht});const lt=Array.from(document.head.children),ct=Array.from(y.document.head.children),ut=d(this,h,wt).call(this,lt,ct),At=d(this,h,it).call(this,lt,ut),_=d(this,h,it).call(this,ct,ut);_.forEach((r,S)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const L=document.createElement("script");L.type="module",L.src=r.getAttribute("src"),_[S]=L}}),_.forEach(r=>{document.head.appendChild(r)});const Z=_.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,h,nt).call(this,r))return!0});e(this,P).waitForHeadToLoad&&Z.length&&(yield new Promise(r=>M(this,null,function*(){let S=0;try{for(var L=gt(Z),mt,O,ft;mt=!(O=yield L.next()).done;mt=!1){const K=O.value;K.onload=()=>{S++,S===Z.length&&r()}}}catch(O){ft=[O]}finally{try{mt&&(O=L.return)&&(yield O.call(L))}finally{if(ft)throw ft[0]}}})));const dt=[];At.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,h,nt).call(this,r)?dt.push(r):r.remove())});const Ct=d(this,h,st).call(this,y.document.body);d(this,h,rt).call(this,y.document),document.documentElement.setAttribute("data-current-pathname",l),document.documentElement.setAttribute("data-current-leaf",Pt),J.changeHistory({action:s,pathname:l,searchParameters:bt,hash:g}),e(this,R).remove(),a(this,U,e(this,m)),a(this,m,l),e(this,j).forEach((r,S)=>{const L=Ct[S],mt=getComputedStyle(r).getPropertyValue("--morph-duration"),O=[...L.childNodes];if(mt){const ft=[...r.childNodes];ft.forEach(v=>{v instanceof HTMLElement&&v.classList.add("old")}),O.forEach(v=>{v instanceof HTMLElement&&v.classList.add("new")}),r.prepend(...O),Mt.requestIdleCallback(()=>{O.forEach(v=>{v instanceof HTMLElement&&v.classList.add("in")})});const K={morphElement:r,pathname:l};G.dispatchEvent(document,"morphNewChildrenAdded",{detail:K});const kt=new Promise(v=>{setTimeout(()=>{ft.forEach(Y=>Y.remove()),O.forEach(Y=>{Y instanceof HTMLElement&&Y.classList.remove("in","new")}),G.dispatchEvent(document,"morphOldChildrenRemoved",{detail:K}),v()},(parseFloat(mt)||0)*1e3+10)});e(this,D).push(kt)}else r.innerHTML="",r.append(...O)}),g?(y.clearScrollState(),d(this,h,ot).call(this,g,{centerScroll:i,offsetScroll:u})):e(this,C)&&y.restoreScrollPosition(),yield Promise.all(e(this,D)),dt.forEach(r=>r.remove()),a(this,D,[]),this.findLinks(),G.dispatchEvent(document,"morphComplete",{detail:ht}),window.dispatchEvent(new Event("resize"))}catch(q){console.error(q)}a(this,A,void 0)})}addLink(t){e(this,E).push(new vt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,E,e(this,E).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var i;return((i=s.getAttribute("href"))==null?void 0:i.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});e(this,E).forEach(s=>s.destroy()),a(this,E,t.map(s=>new vt(s,this)))}}P=new WeakMap,j=new WeakMap,E=new WeakMap,Q=new WeakMap,A=new WeakMap,m=new WeakMap,U=new WeakMap,D=new WeakMap,C=new WeakMap,I=new WeakMap,V=new WeakMap,R=new WeakMap,h=new WeakSet,tt=function(t,s=!1){return M(this,null,function*(){let i=e(this,V).get(t);return(!i||s)&&(i=yield d(this,h,et).call(this,t)),i})},et=function(t){return M(this,null,function*(){const i=yield(yield fetch(t)).text(),u=e(this,Q).parseFromString(i,"text/html"),f=new yt(this,t,u);return e(this,V).set(t,f),f})},st=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},wt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},it=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},nt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},rt=function(t){a(this,I,t.querySelector(e(this,P).scrollSelector)||t.documentElement)},ot=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Tt.scrollToElement(i,{scrollElement:e(this,I),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},X=new WeakMap;exports.Morph=xt;
|
package/lib/morph/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var ft = (
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var ft = (r, t) => (t = Symbol[r]) ? t : Symbol.for("Symbol." + r), pt = (r) => {
|
|
2
|
+
throw TypeError(r);
|
|
3
3
|
};
|
|
4
|
-
var _ = (
|
|
5
|
-
var e = (
|
|
6
|
-
var T = (
|
|
4
|
+
var _ = (r, t, s) => t.has(r) || pt("Cannot " + s);
|
|
5
|
+
var e = (r, t, s) => (_(r, t, "read from private field"), s ? s.call(r) : t.get(r)), o = (r, t, s) => t.has(r) ? pt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, s), a = (r, t, s, i) => (_(r, t, "write to private field"), i ? i.call(r, s) : t.set(r, s), s), d = (r, t, s) => (_(r, t, "access private method"), s);
|
|
6
|
+
var T = (r, t, s) => new Promise((i, u) => {
|
|
7
7
|
var f = (l) => {
|
|
8
8
|
try {
|
|
9
9
|
k(s.next(l));
|
|
@@ -16,28 +16,28 @@ var T = (i, t, s) => new Promise((r, u) => {
|
|
|
16
16
|
} catch (g) {
|
|
17
17
|
u(g);
|
|
18
18
|
}
|
|
19
|
-
}, k = (l) => l.done ?
|
|
20
|
-
k((s = s.apply(
|
|
19
|
+
}, k = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(f, B);
|
|
20
|
+
k((s = s.apply(r, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var Et = (
|
|
23
|
-
import { i as
|
|
22
|
+
var Et = (r, t, s) => (t = r[ft("asyncIterator")]) ? t.call(r) : (r = r[ft("iterator")](), t = {}, s = (i, u) => (u = r[i]) && (t[i] = (f) => new Promise((B, k, l) => (f = u.call(r, f), l = f.done, Promise.resolve(f.value).then((g) => B({ value: g, done: l }), k)))), s("next"), s("return"), t);
|
|
23
|
+
import { i as Lt } from "../index-euf5anj6.js";
|
|
24
24
|
import { d as J } from "../events-CsVF98U6.js";
|
|
25
25
|
import { r as Tt } from "../polyfills-DJrTJQky.js";
|
|
26
26
|
import { s as Mt } from "../scroll-myLAt-Tq.js";
|
|
27
27
|
import { n as Ht, c as gt, s as xt } from "../url-CfcHdBT6.js";
|
|
28
28
|
import { cssValueParser as Nt } from "../css-value-parser/index.js";
|
|
29
|
-
class
|
|
29
|
+
class yt extends HTMLElement {
|
|
30
30
|
connectedCallback() {
|
|
31
31
|
const t = {
|
|
32
32
|
"aria-live": "assertive",
|
|
33
33
|
"aria-atomic": "true",
|
|
34
34
|
style: "position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"
|
|
35
35
|
};
|
|
36
|
-
for (const [s,
|
|
37
|
-
this.setAttribute(s,
|
|
36
|
+
for (const [s, i] of Object.entries(t))
|
|
37
|
+
this.setAttribute(s, i);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
Lt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", yt);
|
|
41
41
|
var w, c, M, W, q;
|
|
42
42
|
class vt {
|
|
43
43
|
constructor(t, s) {
|
|
@@ -48,10 +48,10 @@ class vt {
|
|
|
48
48
|
t.preventDefault();
|
|
49
49
|
const s = e(this, c).getAttribute(
|
|
50
50
|
"data-history-action"
|
|
51
|
-
) || "push",
|
|
51
|
+
) || "push", i = e(this, c).hasAttribute("data-center-scroll"), u = getComputedStyle(e(this, c)).getPropertyValue("--offset-scroll").trim(), f = u ? Nt.parse(u) : void 0, B = e(this, c).hasAttribute("data-revalidate");
|
|
52
52
|
e(this, w).navigate(e(this, M), {
|
|
53
53
|
historyAction: s,
|
|
54
|
-
centerScroll:
|
|
54
|
+
centerScroll: i,
|
|
55
55
|
offsetScroll: f,
|
|
56
56
|
revalidate: B
|
|
57
57
|
});
|
|
@@ -59,14 +59,14 @@ class vt {
|
|
|
59
59
|
o(this, q, () => {
|
|
60
60
|
e(this, w).prefetch(e(this, M)), e(this, c).removeEventListener("pointerenter", e(this, q));
|
|
61
61
|
});
|
|
62
|
-
a(this, w, s), a(this, c, t), a(this, M, e(this, c).getAttribute("href") || "/"), e(this, c).addEventListener("click", e(this, W)), this.checkCurrent(
|
|
62
|
+
a(this, w, s), a(this, c, t), a(this, M, e(this, c).getAttribute("href") || "/"), e(this, c).addEventListener("click", e(this, W)), this.checkCurrent(location.pathname), e(this, c).hasAttribute("data-prefetch") && e(this, c).addEventListener("pointerenter", e(this, q));
|
|
63
63
|
}
|
|
64
64
|
get element() {
|
|
65
65
|
return e(this, c);
|
|
66
66
|
}
|
|
67
67
|
checkCurrent(t) {
|
|
68
|
-
const s = e(this, w).normalizePath(
|
|
69
|
-
e(this, c).hasAttribute("data-include") && s.pathname.includes(
|
|
68
|
+
const s = e(this, w).normalizePath(t), i = e(this, w).normalizePath(e(this, M));
|
|
69
|
+
e(this, c).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? e(this, c).classList.add("current") : i.pathname === s.pathname ? e(this, c).classList.add("current") : e(this, c).classList.remove("current");
|
|
70
70
|
}
|
|
71
71
|
destroy() {
|
|
72
72
|
e(this, c).removeEventListener("click", e(this, W)), e(this, c).removeEventListener("pointerenter", e(this, q)), e(this, c).classList.remove("current");
|
|
@@ -75,14 +75,14 @@ class vt {
|
|
|
75
75
|
w = new WeakMap(), c = new WeakMap(), M = new WeakMap(), W = new WeakMap(), q = new WeakMap();
|
|
76
76
|
var H, F, p, x, N, b;
|
|
77
77
|
class St {
|
|
78
|
-
constructor(t, s,
|
|
78
|
+
constructor(t, s, i) {
|
|
79
79
|
o(this, H);
|
|
80
80
|
o(this, F);
|
|
81
81
|
o(this, p, { x: 0, y: 0 });
|
|
82
82
|
o(this, x);
|
|
83
83
|
o(this, N, null);
|
|
84
84
|
o(this, b, null);
|
|
85
|
-
a(this, H, t), a(this, F, s), a(this, x,
|
|
85
|
+
a(this, H, t), a(this, F, s), a(this, x, i.cloneNode(!0));
|
|
86
86
|
}
|
|
87
87
|
get pathname() {
|
|
88
88
|
return e(this, F);
|
|
@@ -130,17 +130,17 @@ class St {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
H = new WeakMap(), F = new WeakMap(), p = new WeakMap(), x = new WeakMap(), N = new WeakMap(), b = new WeakMap();
|
|
133
|
-
var P,
|
|
133
|
+
var P, U, E, Q, A, m, j, D, C, I, V, R, h, $, tt, et, wt, st, it, rt, nt, X;
|
|
134
134
|
class Bt {
|
|
135
135
|
constructor(t) {
|
|
136
136
|
o(this, h);
|
|
137
137
|
o(this, P, null);
|
|
138
|
-
o(this,
|
|
138
|
+
o(this, U, null);
|
|
139
139
|
o(this, E, []);
|
|
140
140
|
o(this, Q, new DOMParser());
|
|
141
141
|
o(this, A);
|
|
142
142
|
o(this, m, null);
|
|
143
|
-
o(this,
|
|
143
|
+
o(this, j);
|
|
144
144
|
o(this, D, []);
|
|
145
145
|
o(this, C, !1);
|
|
146
146
|
o(this, I, null);
|
|
@@ -150,14 +150,14 @@ class Bt {
|
|
|
150
150
|
var s;
|
|
151
151
|
(s = t.state) != null && s.path && (a(this, C, !0), yield this.navigate(t.state.path, { historyAction: "none" }), a(this, C, !1));
|
|
152
152
|
}));
|
|
153
|
-
if (
|
|
153
|
+
if (Lt) {
|
|
154
154
|
a(this, P, {
|
|
155
155
|
base: Ht(t == null ? void 0 : t.base),
|
|
156
156
|
waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
|
|
157
157
|
cachePages: (t == null ? void 0 : t.cachePages) !== !1,
|
|
158
158
|
trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
|
|
159
159
|
scrollSelector: (t == null ? void 0 : t.scrollSelector) || "body"
|
|
160
|
-
}), a(this,
|
|
160
|
+
}), a(this, U, d(this, h, et).call(this, document.body));
|
|
161
161
|
const s = this.normalizePath(
|
|
162
162
|
location.pathname + location.hash
|
|
163
163
|
);
|
|
@@ -175,14 +175,14 @@ class Bt {
|
|
|
175
175
|
pathname: e(this, m),
|
|
176
176
|
searchParameters: s.parameters,
|
|
177
177
|
hash: s.hash
|
|
178
|
-
}), a(this, R, new
|
|
178
|
+
}), a(this, R, new yt()), d(this, h, rt).call(this, document);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
get currentPathname() {
|
|
182
182
|
return e(this, m);
|
|
183
183
|
}
|
|
184
184
|
get previousPathname() {
|
|
185
|
-
return e(this,
|
|
185
|
+
return e(this, j);
|
|
186
186
|
}
|
|
187
187
|
get links() {
|
|
188
188
|
return e(this, E);
|
|
@@ -205,7 +205,7 @@ class Bt {
|
|
|
205
205
|
navigate(B) {
|
|
206
206
|
return T(this, arguments, function* (t, {
|
|
207
207
|
historyAction: s = "push",
|
|
208
|
-
centerScroll:
|
|
208
|
+
centerScroll: i,
|
|
209
209
|
offsetScroll: u,
|
|
210
210
|
revalidate: f
|
|
211
211
|
} = {}) {
|
|
@@ -215,25 +215,25 @@ class Bt {
|
|
|
215
215
|
let { pathname: l, hash: g, parameters: bt, leaf: Pt } = k;
|
|
216
216
|
if (e(this, A) === l || e(this, m) === l) {
|
|
217
217
|
e(this, C) || d(this, h, nt).call(this, g || 0, {
|
|
218
|
-
centerScroll:
|
|
218
|
+
centerScroll: i,
|
|
219
219
|
offsetScroll: u,
|
|
220
220
|
behavior: "smooth"
|
|
221
221
|
});
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
|
-
e(this, E).forEach((z) => {
|
|
224
|
+
a(this, A, l), e(this, E).forEach((z) => {
|
|
225
225
|
z.checkCurrent(l);
|
|
226
|
-
})
|
|
226
|
+
});
|
|
227
227
|
try {
|
|
228
228
|
let z = !0;
|
|
229
229
|
if (this.preprocessor)
|
|
230
230
|
try {
|
|
231
|
-
yield new Promise((n,
|
|
232
|
-
var
|
|
233
|
-
(
|
|
231
|
+
yield new Promise((n, L) => {
|
|
232
|
+
var y;
|
|
233
|
+
(y = this.preprocessor) == null || y.call(this, {
|
|
234
234
|
pathname: l,
|
|
235
235
|
resolve: n,
|
|
236
|
-
reject:
|
|
236
|
+
reject: L
|
|
237
237
|
});
|
|
238
238
|
});
|
|
239
239
|
} catch (n) {
|
|
@@ -259,35 +259,35 @@ class Bt {
|
|
|
259
259
|
J(document, "morphStart", {
|
|
260
260
|
detail: at
|
|
261
261
|
});
|
|
262
|
-
const ht = Array.from(document.head.children), lt = Array.from(S.document.head.children), ct = d(this, h, wt).call(this, ht, lt), At = d(this, h, st).call(this, ht, ct),
|
|
263
|
-
|
|
262
|
+
const ht = Array.from(document.head.children), lt = Array.from(S.document.head.children), ct = d(this, h, wt).call(this, ht, lt), At = d(this, h, st).call(this, ht, ct), K = d(this, h, st).call(this, lt, ct);
|
|
263
|
+
K.forEach((n, L) => {
|
|
264
264
|
if (n.tagName === "SCRIPT" && n.getAttribute("src")) {
|
|
265
|
-
const
|
|
266
|
-
|
|
265
|
+
const y = document.createElement("script");
|
|
266
|
+
y.type = "module", y.src = n.getAttribute("src"), K[L] = y;
|
|
267
267
|
}
|
|
268
|
-
}),
|
|
268
|
+
}), K.forEach((n) => {
|
|
269
269
|
document.head.appendChild(n);
|
|
270
270
|
});
|
|
271
|
-
const Z =
|
|
271
|
+
const Z = K.filter((n) => {
|
|
272
272
|
if (n.hasAttribute("data-no-waiting"))
|
|
273
273
|
return !1;
|
|
274
274
|
if (d(this, h, it).call(this, n))
|
|
275
275
|
return !0;
|
|
276
276
|
});
|
|
277
277
|
e(this, P).waitForHeadToLoad && Z.length && (yield new Promise((n) => T(this, null, function* () {
|
|
278
|
-
let
|
|
278
|
+
let L = 0;
|
|
279
279
|
try {
|
|
280
|
-
for (var
|
|
280
|
+
for (var y = Et(Z), dt, O, mt; dt = !(O = yield y.next()).done; dt = !1) {
|
|
281
281
|
const Y = O.value;
|
|
282
282
|
Y.onload = () => {
|
|
283
|
-
|
|
283
|
+
L++, L === Z.length && n();
|
|
284
284
|
};
|
|
285
285
|
}
|
|
286
286
|
} catch (O) {
|
|
287
287
|
mt = [O];
|
|
288
288
|
} finally {
|
|
289
289
|
try {
|
|
290
|
-
dt && (O =
|
|
290
|
+
dt && (O = y.return) && (yield O.call(y));
|
|
291
291
|
} finally {
|
|
292
292
|
if (mt)
|
|
293
293
|
throw mt[0];
|
|
@@ -304,8 +304,8 @@ class Bt {
|
|
|
304
304
|
pathname: l,
|
|
305
305
|
searchParameters: bt,
|
|
306
306
|
hash: g
|
|
307
|
-
}), e(this, R).remove(), a(this,
|
|
308
|
-
const
|
|
307
|
+
}), e(this, R).remove(), a(this, j, e(this, m)), a(this, m, l), e(this, U).forEach((n, L) => {
|
|
308
|
+
const y = Ct[L], dt = getComputedStyle(n).getPropertyValue("--morph-duration"), O = [...y.childNodes];
|
|
309
309
|
if (dt) {
|
|
310
310
|
const mt = [...n.childNodes];
|
|
311
311
|
mt.forEach((v) => {
|
|
@@ -336,7 +336,7 @@ class Bt {
|
|
|
336
336
|
e(this, D).push(kt);
|
|
337
337
|
} else
|
|
338
338
|
n.innerHTML = "", n.append(...O);
|
|
339
|
-
}), g ? (S.clearScrollState(), d(this, h, nt).call(this, g, { centerScroll:
|
|
339
|
+
}), g ? (S.clearScrollState(), d(this, h, nt).call(this, g, { centerScroll: i, offsetScroll: u })) : e(this, C) && S.restoreScrollPosition(), yield Promise.all(e(this, D)), ut.forEach((n) => n.remove()), a(this, D, []), this.findLinks(), J(document, "morphComplete", {
|
|
340
340
|
detail: at
|
|
341
341
|
}), window.dispatchEvent(new Event("resize"));
|
|
342
342
|
} catch (z) {
|
|
@@ -361,21 +361,21 @@ class Bt {
|
|
|
361
361
|
...document.documentElement.querySelectorAll("a")
|
|
362
362
|
].filter(
|
|
363
363
|
(s) => {
|
|
364
|
-
var
|
|
365
|
-
return ((
|
|
364
|
+
var i;
|
|
365
|
+
return ((i = s.getAttribute("href")) == null ? void 0 : i.startsWith("/")) && !s.hasAttribute("download") && !s.hasAttribute("data-morph-skip") && !s.closest("[data-morph-skip]");
|
|
366
366
|
}
|
|
367
367
|
);
|
|
368
368
|
e(this, E).forEach((s) => s.destroy()), a(this, E, t.map((s) => new vt(s, this)));
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
|
-
P = new WeakMap(),
|
|
371
|
+
P = new WeakMap(), U = new WeakMap(), E = new WeakMap(), Q = new WeakMap(), A = new WeakMap(), m = new WeakMap(), j = new WeakMap(), D = new WeakMap(), C = new WeakMap(), I = new WeakMap(), V = new WeakMap(), R = new WeakMap(), h = new WeakSet(), $ = function(t, s = !1) {
|
|
372
372
|
return T(this, null, function* () {
|
|
373
|
-
let
|
|
374
|
-
return (!
|
|
373
|
+
let i = e(this, V).get(t);
|
|
374
|
+
return (!i || s) && (i = yield d(this, h, tt).call(this, t)), i;
|
|
375
375
|
});
|
|
376
376
|
}, tt = function(t) {
|
|
377
377
|
return T(this, null, function* () {
|
|
378
|
-
const
|
|
378
|
+
const i = yield (yield fetch(t)).text(), u = e(this, Q).parseFromString(i, "text/html"), f = new St(this, t, u);
|
|
379
379
|
return e(this, V).set(t, f), f;
|
|
380
380
|
});
|
|
381
381
|
}, et = function(t) {
|
|
@@ -383,14 +383,14 @@ P = new WeakMap(), j = new WeakMap(), E = new WeakMap(), Q = new WeakMap(), A =
|
|
|
383
383
|
return s.length ? s : [t];
|
|
384
384
|
}, wt = function(t, s) {
|
|
385
385
|
return t.filter(
|
|
386
|
-
(
|
|
387
|
-
(u) => u.outerHTML ===
|
|
386
|
+
(i) => s.find(
|
|
387
|
+
(u) => u.outerHTML === i.outerHTML
|
|
388
388
|
)
|
|
389
389
|
);
|
|
390
390
|
}, st = function(t, s) {
|
|
391
391
|
return t.filter(
|
|
392
|
-
(
|
|
393
|
-
(u) => u.outerHTML ===
|
|
392
|
+
(i) => !s.find(
|
|
393
|
+
(u) => u.outerHTML === i.outerHTML
|
|
394
394
|
)
|
|
395
395
|
);
|
|
396
396
|
}, it = function(t) {
|
|
@@ -398,8 +398,8 @@ P = new WeakMap(), j = new WeakMap(), E = new WeakMap(), Q = new WeakMap(), A =
|
|
|
398
398
|
}, rt = function(t) {
|
|
399
399
|
a(this, I, t.querySelector(e(this, P).scrollSelector) || t.documentElement);
|
|
400
400
|
}, nt = function(t, s) {
|
|
401
|
-
const
|
|
402
|
-
(typeof
|
|
401
|
+
const i = typeof t == "string" ? document.getElementById(t) : t;
|
|
402
|
+
(typeof i == "number" || i) && Mt(i, {
|
|
403
403
|
scrollElement: e(this, I),
|
|
404
404
|
behavior: (s == null ? void 0 : s.behavior) || "instant",
|
|
405
405
|
center: s == null ? void 0 : s.centerScroll,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var E=e=>{throw TypeError(e)};var b=(e,a,t)=>a.has(e)||E("Cannot "+t);var i=(e,a,t)=>(b(e,a,"read from private field"),t?t.call(e):a.get(e)),r=(e,a,t)=>a.has(e)?E("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(e):a.set(e,t),l=(e,a,t,s)=>(b(e,a,"write to private field"),s?s.call(e,t):a.set(e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../events-KVanG9sR.cjs");require("../index-Cqw2NKev.cjs");var d,n,o,c,u,h;class g extends HTMLElement{constructor(){super(...arguments);r(this,d,[]);r(this,n);r(this,o,null);r(this,c,()=>{this.isConnected&&(document.documentElement.addEventListener("radioChange",i(this,h)),i(this,d).forEach(t=>{t.addEventListener("click",i(this,u)),t.hasAttribute("data-checked")&&this.setValue(t.getAttribute("data-value"))}))});r(this,u,t=>{const m=t.currentTarget.getAttribute("data-value");m&&this.setValue(m)});r(this,h,t=>{const s=t.target;s!==this&&s.name===this.name&&this.setValue(t.detail)})}get value(){return i(this,n)}get name(){return this.getAttribute("name")}get currentButtonElement(){return i(this,o)}setValue(t){t&&t!==i(this,n)&&(l(this,n,t),i(this,d).forEach(s=>{s.getAttribute("data-value")===i(this,n)?(s.setAttribute("data-checked",""),l(this,o,s)):s.removeAttribute("data-checked")}),v.dispatchEvent(this,"radioChange",{detail:i(this,n),bubbles:!0}))}connectedCallback(){l(this,d,[...this.querySelectorAll("[data-radio-button]")]),document.readyState==="complete"?i(this,c).call(this):addEventListener("load",i(this,c))}disconnectedCallback(){i(this,d).forEach(t=>{t.removeEventListener("click",i(this,u))}),removeEventListener("load",i(this,c)),document.documentElement.removeEventListener("radioChange",i(this,h))}}d=new WeakMap,n=new WeakMap,o=new WeakMap,c=new WeakMap,u=new WeakMap,h=new WeakMap;customElements.get("e-radio")||customElements.define("e-radio",g);exports.RadioElement=g;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface RadioEvents {
|
|
2
|
+
radioChange: CustomEvent<string | undefined>;
|
|
3
|
+
}
|
|
4
|
+
export declare class RadioElement<T extends string = string> extends HTMLElement {
|
|
5
|
+
#private;
|
|
6
|
+
get value(): T | undefined;
|
|
7
|
+
get name(): string | null;
|
|
8
|
+
get currentButtonElement(): HTMLElement | null;
|
|
9
|
+
setValue(value: T | undefined): void;
|
|
10
|
+
protected connectedCallback(): void;
|
|
11
|
+
protected disconnectedCallback(): void;
|
|
12
|
+
}
|
|
13
|
+
declare global {
|
|
14
|
+
interface HTMLElementTagNameMap {
|
|
15
|
+
'e-radio': RadioElement;
|
|
16
|
+
}
|
|
17
|
+
interface HTMLElementEventMap extends RadioEvents {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var E = (e) => {
|
|
2
|
+
throw TypeError(e);
|
|
3
|
+
};
|
|
4
|
+
var b = (e, a, t) => a.has(e) || E("Cannot " + t);
|
|
5
|
+
var i = (e, a, t) => (b(e, a, "read from private field"), t ? t.call(e) : a.get(e)), r = (e, a, t) => a.has(e) ? E("Cannot add the same private member more than once") : a instanceof WeakSet ? a.add(e) : a.set(e, t), l = (e, a, t, s) => (b(e, a, "write to private field"), s ? s.call(e, t) : a.set(e, t), t);
|
|
6
|
+
import { d as g } from "../events-CsVF98U6.js";
|
|
7
|
+
import "../index-euf5anj6.js";
|
|
8
|
+
var d, n, c, o, h, u;
|
|
9
|
+
class v extends HTMLElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
r(this, d, []);
|
|
13
|
+
r(this, n);
|
|
14
|
+
r(this, c, null);
|
|
15
|
+
r(this, o, () => {
|
|
16
|
+
this.isConnected && (document.documentElement.addEventListener(
|
|
17
|
+
"radioChange",
|
|
18
|
+
i(this, u)
|
|
19
|
+
), i(this, d).forEach((t) => {
|
|
20
|
+
t.addEventListener("click", i(this, h)), t.hasAttribute("data-checked") && this.setValue(t.getAttribute("data-value"));
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
r(this, h, (t) => {
|
|
24
|
+
const m = t.currentTarget.getAttribute("data-value");
|
|
25
|
+
m && this.setValue(m);
|
|
26
|
+
});
|
|
27
|
+
r(this, u, (t) => {
|
|
28
|
+
const s = t.target;
|
|
29
|
+
s !== this && s.name === this.name && this.setValue(t.detail);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
get value() {
|
|
33
|
+
return i(this, n);
|
|
34
|
+
}
|
|
35
|
+
get name() {
|
|
36
|
+
return this.getAttribute("name");
|
|
37
|
+
}
|
|
38
|
+
get currentButtonElement() {
|
|
39
|
+
return i(this, c);
|
|
40
|
+
}
|
|
41
|
+
setValue(t) {
|
|
42
|
+
t && t !== i(this, n) && (l(this, n, t), i(this, d).forEach((s) => {
|
|
43
|
+
s.getAttribute("data-value") === i(this, n) ? (s.setAttribute("data-checked", ""), l(this, c, s)) : s.removeAttribute("data-checked");
|
|
44
|
+
}), g(this, "radioChange", {
|
|
45
|
+
detail: i(this, n),
|
|
46
|
+
bubbles: !0
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
l(this, d, [
|
|
51
|
+
...this.querySelectorAll("[data-radio-button]")
|
|
52
|
+
]), document.readyState === "complete" ? i(this, o).call(this) : addEventListener("load", i(this, o));
|
|
53
|
+
}
|
|
54
|
+
disconnectedCallback() {
|
|
55
|
+
i(this, d).forEach((t) => {
|
|
56
|
+
t.removeEventListener("click", i(this, h));
|
|
57
|
+
}), removeEventListener("load", i(this, o)), document.documentElement.removeEventListener(
|
|
58
|
+
"radioChange",
|
|
59
|
+
i(this, u)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
d = new WeakMap(), n = new WeakMap(), c = new WeakMap(), o = new WeakMap(), h = new WeakMap(), u = new WeakMap();
|
|
64
|
+
customElements.get("e-radio") || customElements.define("e-radio", v);
|
|
65
|
+
export {
|
|
66
|
+
v as RadioElement
|
|
67
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aptechka",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/denisavitski/aptechka.git"
|
|
@@ -163,6 +163,11 @@
|
|
|
163
163
|
"require": "./lib/popover/index.cjs",
|
|
164
164
|
"default": "./lib/popover/index.js"
|
|
165
165
|
},
|
|
166
|
+
"./radio": {
|
|
167
|
+
"types": "./lib/radio/index.d.ts",
|
|
168
|
+
"require": "./lib/radio/index.cjs",
|
|
169
|
+
"default": "./lib/radio/index.js"
|
|
170
|
+
},
|
|
166
171
|
"./router": {
|
|
167
172
|
"types": "./lib/router/index.d.ts",
|
|
168
173
|
"require": "./lib/router/index.cjs",
|
|
@@ -331,6 +336,9 @@
|
|
|
331
336
|
"popover": [
|
|
332
337
|
"lib/popover/index.d.ts"
|
|
333
338
|
],
|
|
339
|
+
"radio": [
|
|
340
|
+
"lib/radio/index.d.ts"
|
|
341
|
+
],
|
|
334
342
|
"router": [
|
|
335
343
|
"lib/router/index.d.ts"
|
|
336
344
|
],
|