aptechka 0.62.3 → 0.63.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/lib/billboard/index.cjs +1 -1
- package/lib/billboard/index.js +25 -25
- package/lib/custom-scrollbar/index.cjs +1 -1
- package/lib/custom-scrollbar/index.js +20 -20
- package/lib/morph/Morph.d.ts +2 -0
- package/lib/morph/MorphRoute.d.ts +4 -1
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +217 -201
- package/lib/popover/index.cjs +1 -1
- package/lib/popover/index.js +15 -15
- package/lib/scroll/index.cjs +1 -1
- package/lib/scroll/index.js +165 -165
- package/package.json +1 -1
package/lib/billboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Q=i=>{throw TypeError(i)};var
|
|
1
|
+
"use strict";var Q=i=>{throw TypeError(i)};var O=(i,r,e)=>r.has(i)||Q("Cannot "+e);var t=(i,r,e)=>(O(i,r,"read from private field"),e?e.call(i):r.get(i)),s=(i,r,e)=>r.has(i)?Q("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(i):r.set(i,e),d=(i,r,e,n)=>(O(i,r,"write to private field"),n?n.call(i,e):r.set(i,e),e),m=(i,r,e)=>(O(i,r,"access private method"),e);var J=(i,r,e)=>new Promise((n,h)=>{var a=y=>{try{G(e.next(y))}catch(N){h(N)}},k=y=>{try{G(e.throw(y))}catch(N){h(N)}},G=y=>y.done?n(y.value):Promise.resolve(y.value).then(a,k);G((e=e.apply(i,r)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("../index-Cqw2NKev.cjs"),K=require("../dom-JBOkFLTh.cjs"),M=require("../css-property/index.cjs"),W=require("../events-KVanG9sR.cjs"),X=require("../gestures-C7gbKx11.cjs"),Y=require("../math-GDWEqu7y.cjs"),Z=require("../number-DyefJ5a1.cjs");var P,S,f,E,L,x,o,l,u,$,T,_,B,j,F;class z extends HTMLElement{constructor(){super(...arguments);s(this,u);s(this,P,new M.CSSProperty(this,"--resize",!0));s(this,S,new M.CSSProperty(this,"--loop",!0));s(this,f,new M.CSSProperty(this,"--autoplay",!1));s(this,E,new M.CSSProperty(this,"--swipe","x"));s(this,L);s(this,x,!1);s(this,o,[]);s(this,l,0);s(this,T,e=>{d(this,x,e.isIntersecting),t(this,x)?m(this,u,$).call(this):clearInterval(t(this,L))});s(this,_,()=>{clearInterval(t(this,L)),t(this,x)&&d(this,L,setInterval(t(this,j),parseFloat(t(this,f).current||"0")*1e3))});s(this,j,()=>{m(this,u,B).call(this,t(this,l)+1)});s(this,F,e=>{if(!t(this,E).current)return;let n=0;X.setupDrag(h=>{const a=e.x-h.x,k=e.y-h.y;t(this,E).current==="x"?Math.abs(a)>Math.abs(k)&&Math.abs(a)>10&&(n=Math.sign(a)):t(this,E).current==="y"&&Math.abs(k)>Math.abs(a)&&Math.abs(k)>10&&(n=Math.sign(k))},()=>{n&&this.shift(n)})})}get counter(){return t(this,l)}get loop(){return t(this,S)}get autoplay(){return t(this,f)}get swipe(){return t(this,E)}get itemElements(){return t(this,o)}addItem(e){t(this,o).push(e),m(this,u,B).call(this)}set(e){(!this.handleSet||this.handleSet(e))&&(m(this,u,B).call(this,e),m(this,u,$).call(this))}shift(e){this.set(t(this,l)+e)}connectedCallback(){var e;d(this,o,[...this.querySelectorAll(`[data-billboard-item${this.id?`="${this.id}"`:""}]`)]),(e=t(this,o)[0])==null||e.classList.add("current"),t(this,f).subscribe(n=>{n.current?(I.intersector.subscribe(this,t(this,T)),m(this,u,$).call(this)):(d(this,x,!0),I.intersector.unsubscribe(t(this,T)),clearInterval(t(this,L)),m(this,u,B).call(this,0))}),t(this,f).observe(),t(this,E).observe(),t(this,S).observe(),t(this,P).observe(),m(this,u,B).call(this,0),this.addEventListener("pointerdown",t(this,F))}disconnectedCallback(){t(this,f).unobserve(),t(this,E).unobserve(),t(this,S).unobserve(),t(this,P).unobserve(),I.intersector.unsubscribe(t(this,T)),clearInterval(t(this,L))}}P=new WeakMap,S=new WeakMap,f=new WeakMap,E=new WeakMap,L=new WeakMap,x=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakSet,$=function(){t(this,f).current!==!1&&t(this,_).call(this)},T=new WeakMap,_=new WeakMap,B=function(e=t(this,l)){const n=t(this,l);t(this,S).current?d(this,l,Z.loopNumber(e,t(this,o).length)):d(this,l,Y.clamp(e,0,t(this,o).length-1)),this.classList.remove("forward","backward"),t(this,l)-n>=0?this.classList.add("forward"):t(this,l)-n<0&&this.classList.add("backward"),t(this,o).forEach((h,a)=>{h.classList.remove("current","previous","next"),a===t(this,l)?h.classList.add("current"):a<t(this,l)?h.classList.add("previous"):a>t(this,l)&&h.classList.add("next")}),this.classList.toggle("has-length",t(this,o).length>1),this.classList.toggle("start",t(this,l)===0),this.classList.toggle("end",t(this,l)===t(this,o).length-1),this.style.setProperty("--counter",t(this,l).toString()),this.style.setProperty("--sections",t(this,o).length.toString()),t(this,l)!==n&&(W.dispatchEvent(this,"billboardChange",{detail:{counter:t(this,l)}}),t(this,P).current&&setTimeout(()=>{window.dispatchEvent(new Event("resize"))},0))},j=new WeakMap,F=new WeakMap;customElements.get("e-billboard")||customElements.define("e-billboard",z);var b,q,p,D,A;class R extends HTMLElement{constructor(){super(...arguments);s(this,b,null);s(this,q,null);s(this,p,[]);s(this,D,e=>{const n=e.currentTarget,h=t(this,p).findIndex(a=>a===n);h>=0&&t(this,b).set(h)});s(this,A,()=>{t(this,p).forEach((e,n)=>{n===t(this,b).counter?e.classList.add("current"):e.classList.remove("current")})})}connectedCallback(){return J(this,null,function*(){var e;if(d(this,b,K.findParentElement(this,z)),t(this,b)&&(yield customElements.whenDefined("e-billboard"),this.isConnected)){this.innerHTML="";const n=t(this,b).itemElements.length;d(this,q,document.createElement("div"));for(let h=0;h<n;h++){const a=document.createElement("button");a.setAttribute("aria-label",`Go to item ${h+1}`),t(this,p).push(a),t(this,q).appendChild(a)}this.appendChild(t(this,q)),t(this,p).forEach(h=>{h.addEventListener("click",t(this,D))}),(e=t(this,b))==null||e.addEventListener("billboardChange",t(this,A)),t(this,A).call(this)}})}disconnectedCallback(){var e;t(this,p).forEach(n=>{n.removeEventListener("click",t(this,D))}),(e=t(this,b))==null||e.removeEventListener("billboardChange",t(this,A)),this.innerHTML="",d(this,p,[])}}b=new WeakMap,q=new WeakMap,p=new WeakMap,D=new WeakMap,A=new WeakMap;I.isBrowser&&!customElements.get("e-billboard-bullets")&&customElements.define("e-billboard-bullets",R);var v,g,C;class U extends HTMLElement{constructor(){super();s(this,v,new M.CSSProperty(this,"--index",0));s(this,g,null);s(this,C,()=>{var e;t(this,v).current===((e=t(this,g))==null?void 0:e.counter)?this.classList.add("current"):this.classList.remove("current")});this.addEventListener("click",e=>{t(this,g)&&(!this.handleClick||this.handleClick(e))&&t(this,g).set(t(this,v).current)})}connectedCallback(){var e;this.tabIndex=0,d(this,g,K.findParentElement(this,z)),(e=t(this,g))==null||e.addEventListener("billboardChange",t(this,C)),customElements.whenDefined("e-billboard").then(()=>{this.isConnected&&t(this,C).call(this)}),t(this,v).subscribe(t(this,C)),t(this,v).observe()}disconnectedCallback(){var e;this.removeAttribute("tabindex"),t(this,v).unsubscribe(t(this,C)),t(this,v).unobserve(),(e=t(this,g))==null||e.removeEventListener("billboardChange",t(this,C))}}v=new WeakMap,g=new WeakMap,C=new WeakMap;I.isBrowser&&!customElements.get("e-billboard-set-button")&&customElements.define("e-billboard-set-button",U);var w,c,H;class V extends HTMLElement{constructor(){super();s(this,w,new M.CSSProperty(this,"--step",1));s(this,c,null);s(this,H,()=>{t(this,c)&&(!t(this,c).loop.current&&(t(this,c).counter===0&&t(this,w).current<=0||t(this,c).counter===t(this,c).itemElements.length-1&&t(this,w).current>=0)?this.setAttribute("disabled",""):this.removeAttribute("disabled"))});this.addEventListener("click",e=>{t(this,c)&&(!this.handleClick||this.handleClick(e))&&t(this,c).shift(t(this,w).current)})}connectedCallback(){return J(this,null,function*(){var e;yield customElements.whenDefined("e-billboard"),t(this,w).observe(),this.tabIndex=0,d(this,c,K.findParentElement(this,z)),(e=t(this,c))==null||e.addEventListener("billboardChange",t(this,H)),setTimeout(()=>{t(this,H).call(this)},0)})}disconnectedCallback(){var e;this.removeAttribute("tabindex"),t(this,w).unobserve(),(e=t(this,c))==null||e.removeEventListener("billboardChange",t(this,H))}}w=new WeakMap,c=new WeakMap,H=new WeakMap;I.isBrowser&&!customElements.get("e-billboard-step-button")&&customElements.define("e-billboard-step-button",V);exports.BillboardBulletsElement=R;exports.BillboardElement=z;exports.BillboardSetButtonElement=U;exports.BillboardStepButtonElement=V;
|
package/lib/billboard/index.js
CHANGED
|
@@ -6,18 +6,18 @@ var t = (i, r, e) => (J(i, r, "read from private field"), e ? e.call(i) : r.get(
|
|
|
6
6
|
var K = (i, r, e) => new Promise((n, l) => {
|
|
7
7
|
var a = (x) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
} catch (
|
|
11
|
-
l(
|
|
9
|
+
N(e.next(x));
|
|
10
|
+
} catch (j) {
|
|
11
|
+
l(j);
|
|
12
12
|
}
|
|
13
13
|
}, M = (x) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
l(
|
|
15
|
+
N(e.throw(x));
|
|
16
|
+
} catch (j) {
|
|
17
|
+
l(j);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, N = (x) => x.done ? n(x.value) : Promise.resolve(x.value).then(a, M);
|
|
20
|
+
N((e = e.apply(i, r)).next());
|
|
21
21
|
});
|
|
22
22
|
import { a as O, i as Q } from "../index-euf5anj6.js";
|
|
23
23
|
import { b as R } from "../dom-CVWzyXPH.js";
|
|
@@ -26,8 +26,8 @@ import { d as V } from "../events-CsVF98U6.js";
|
|
|
26
26
|
import { s as W } from "../gestures-CcXV6fCp.js";
|
|
27
27
|
import { c as X } from "../math-BOBiC4TN.js";
|
|
28
28
|
import { l as Y } from "../number-CbdpfO3u.js";
|
|
29
|
-
var T, k, f, p, L, y, o, h, b, z,
|
|
30
|
-
class
|
|
29
|
+
var T, k, f, p, L, y, o, h, b, z, A, $, I, q, F;
|
|
30
|
+
class G extends HTMLElement {
|
|
31
31
|
constructor() {
|
|
32
32
|
super(...arguments);
|
|
33
33
|
s(this, b);
|
|
@@ -39,7 +39,7 @@ class N extends HTMLElement {
|
|
|
39
39
|
s(this, y, !1);
|
|
40
40
|
s(this, o, []);
|
|
41
41
|
s(this, h, 0);
|
|
42
|
-
s(this,
|
|
42
|
+
s(this, A, (e) => {
|
|
43
43
|
d(this, y, e.isIntersecting), t(this, y) ? m(this, b, z).call(this) : clearInterval(t(this, L));
|
|
44
44
|
});
|
|
45
45
|
s(this, $, () => {
|
|
@@ -97,16 +97,16 @@ class N extends HTMLElement {
|
|
|
97
97
|
`[data-billboard-item${this.id ? `="${this.id}"` : ""}]`
|
|
98
98
|
)
|
|
99
99
|
]), (e = t(this, o)[0]) == null || e.classList.add("current"), t(this, f).subscribe((n) => {
|
|
100
|
-
n.current ? (O.subscribe(this, t(this,
|
|
100
|
+
n.current ? (O.subscribe(this, t(this, A)), m(this, b, z).call(this)) : (d(this, y, !0), O.unsubscribe(t(this, A)), clearInterval(t(this, L)), m(this, b, I).call(this, 0));
|
|
101
101
|
}), t(this, f).observe(), t(this, p).observe(), t(this, k).observe(), t(this, T).observe(), m(this, b, I).call(this, 0), this.addEventListener("pointerdown", t(this, F));
|
|
102
102
|
}
|
|
103
103
|
disconnectedCallback() {
|
|
104
|
-
t(this, f).unobserve(), t(this, p).unobserve(), t(this, k).unobserve(), t(this, T).unobserve(), O.unsubscribe(t(this,
|
|
104
|
+
t(this, f).unobserve(), t(this, p).unobserve(), t(this, k).unobserve(), t(this, T).unobserve(), O.unsubscribe(t(this, A)), clearInterval(t(this, L));
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
T = new WeakMap(), k = new WeakMap(), f = new WeakMap(), p = new WeakMap(), L = new WeakMap(), y = new WeakMap(), o = new WeakMap(), h = new WeakMap(), b = new WeakSet(), z = function() {
|
|
108
108
|
t(this, f).current !== !1 && t(this, $).call(this);
|
|
109
|
-
},
|
|
109
|
+
}, A = new WeakMap(), $ = new WeakMap(), I = function(e = t(this, h)) {
|
|
110
110
|
const n = t(this, h);
|
|
111
111
|
t(this, k).current ? d(this, h, Y(e, t(this, o).length)) : d(this, h, X(e, 0, t(this, o).length - 1)), this.classList.remove("forward", "backward"), t(this, h) - n >= 0 ? this.classList.add("forward") : t(this, h) - n < 0 && this.classList.add("backward"), t(this, o).forEach((l, a) => {
|
|
112
112
|
l.classList.remove("current", "previous", "next"), a === t(this, h) ? l.classList.add("current") : a < t(this, h) ? l.classList.add("previous") : a > t(this, h) && l.classList.add("next");
|
|
@@ -121,13 +121,13 @@ T = new WeakMap(), k = new WeakMap(), f = new WeakMap(), p = new WeakMap(), L =
|
|
|
121
121
|
window.dispatchEvent(new Event("resize"));
|
|
122
122
|
}, 0));
|
|
123
123
|
}, q = new WeakMap(), F = new WeakMap();
|
|
124
|
-
customElements.get("e-billboard") || customElements.define("e-billboard",
|
|
125
|
-
var u,
|
|
124
|
+
customElements.get("e-billboard") || customElements.define("e-billboard", G);
|
|
125
|
+
var u, B, E, P, H;
|
|
126
126
|
class Z extends HTMLElement {
|
|
127
127
|
constructor() {
|
|
128
128
|
super(...arguments);
|
|
129
129
|
s(this, u, null);
|
|
130
|
-
s(this,
|
|
130
|
+
s(this, B, null);
|
|
131
131
|
s(this, E, []);
|
|
132
132
|
s(this, P, (e) => {
|
|
133
133
|
const n = e.currentTarget, l = t(this, E).findIndex((a) => a === n);
|
|
@@ -142,15 +142,15 @@ class Z extends HTMLElement {
|
|
|
142
142
|
connectedCallback() {
|
|
143
143
|
return K(this, null, function* () {
|
|
144
144
|
var e;
|
|
145
|
-
if (d(this, u, R(this,
|
|
145
|
+
if (d(this, u, R(this, G)), t(this, u) && (yield customElements.whenDefined("e-billboard"), this.isConnected)) {
|
|
146
146
|
this.innerHTML = "";
|
|
147
147
|
const n = t(this, u).itemElements.length;
|
|
148
|
-
d(this,
|
|
148
|
+
d(this, B, document.createElement("div"));
|
|
149
149
|
for (let l = 0; l < n; l++) {
|
|
150
150
|
const a = document.createElement("button");
|
|
151
|
-
t(this, E).push(a), t(this,
|
|
151
|
+
a.setAttribute("aria-label", `Go to item ${l + 1}`), t(this, E).push(a), t(this, B).appendChild(a);
|
|
152
152
|
}
|
|
153
|
-
this.appendChild(t(this,
|
|
153
|
+
this.appendChild(t(this, B)), t(this, E).forEach((l) => {
|
|
154
154
|
l.addEventListener("click", t(this, P));
|
|
155
155
|
}), (e = t(this, u)) == null || e.addEventListener(
|
|
156
156
|
"billboardChange",
|
|
@@ -169,7 +169,7 @@ class Z extends HTMLElement {
|
|
|
169
169
|
), this.innerHTML = "", d(this, E, []);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
u = new WeakMap(),
|
|
172
|
+
u = new WeakMap(), B = new WeakMap(), E = new WeakMap(), P = new WeakMap(), H = new WeakMap();
|
|
173
173
|
Q && !customElements.get("e-billboard-bullets") && customElements.define("e-billboard-bullets", Z);
|
|
174
174
|
var v, g, C;
|
|
175
175
|
class _ extends HTMLElement {
|
|
@@ -187,7 +187,7 @@ class _ extends HTMLElement {
|
|
|
187
187
|
}
|
|
188
188
|
connectedCallback() {
|
|
189
189
|
var e;
|
|
190
|
-
this.tabIndex = 0, d(this, g, R(this,
|
|
190
|
+
this.tabIndex = 0, d(this, g, R(this, G)), (e = t(this, g)) == null || e.addEventListener(
|
|
191
191
|
"billboardChange",
|
|
192
192
|
t(this, C)
|
|
193
193
|
), customElements.whenDefined("e-billboard").then(() => {
|
|
@@ -220,7 +220,7 @@ class tt extends HTMLElement {
|
|
|
220
220
|
connectedCallback() {
|
|
221
221
|
return K(this, null, function* () {
|
|
222
222
|
var e;
|
|
223
|
-
yield customElements.whenDefined("e-billboard"), t(this, w).observe(), this.tabIndex = 0, d(this, c, R(this,
|
|
223
|
+
yield customElements.whenDefined("e-billboard"), t(this, w).observe(), this.tabIndex = 0, d(this, c, R(this, G)), (e = t(this, c)) == null || e.addEventListener(
|
|
224
224
|
"billboardChange",
|
|
225
225
|
t(this, D)
|
|
226
226
|
), setTimeout(() => {
|
|
@@ -240,7 +240,7 @@ w = new WeakMap(), c = new WeakMap(), D = new WeakMap();
|
|
|
240
240
|
Q && !customElements.get("e-billboard-step-button") && customElements.define("e-billboard-step-button", tt);
|
|
241
241
|
export {
|
|
242
242
|
Z as BillboardBulletsElement,
|
|
243
|
-
|
|
243
|
+
G as BillboardElement,
|
|
244
244
|
_ as BillboardSetButtonElement,
|
|
245
245
|
tt as BillboardStepButtonElement
|
|
246
246
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var v=l=>{throw TypeError(l)};var k=(l,o,s)=>o.has(l)||v("Cannot "+s);var t=(l,o,s)=>(k(l,o,"read from private field"),s?s.call(l):o.get(l)),h=(l,o,s)=>o.has(l)?v("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(l):o.set(l,s),c=(l,o,s,e)=>(k(l,o,"write to private field"),e?e.call(l,s):o.set(l,s),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("../index-Cqw2NKev.cjs"),q=require("../dom-JBOkFLTh.cjs"),w=require("../gestures-C7gbKx11.cjs"),E=require("../ticker/index.cjs");var i,n,
|
|
1
|
+
"use strict";var v=l=>{throw TypeError(l)};var k=(l,o,s)=>o.has(l)||v("Cannot "+s);var t=(l,o,s)=>(k(l,o,"read from private field"),s?s.call(l):o.get(l)),h=(l,o,s)=>o.has(l)?v("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(l):o.set(l,s),c=(l,o,s,e)=>(k(l,o,"write to private field"),e?e.call(l,s):o.set(l,s),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("../index-Cqw2NKev.cjs"),q=require("../dom-JBOkFLTh.cjs"),w=require("../gestures-C7gbKx11.cjs"),E=require("../ticker/index.cjs");var i,n,m,a,r,d,f,y,p,u,g;class T extends HTMLElement{constructor(){super(...arguments);h(this,i,null);h(this,n,null);h(this,m,0);h(this,a,0);h(this,r,!1);h(this,d);h(this,f,()=>{this.classList.add("active"),clearTimeout(t(this,d));const e=(t(this,r)?t(this,i).scrollLeft:t(this,i).scrollTop)/t(this,a)*t(this,m);t(this,r)?t(this,n).style.transform=`translate3d(${e}px, 0px, 0px)`:t(this,n).style.transform=`translate3d(0px, ${e}px, 0px)`,c(this,d,setTimeout(()=>{this.classList.remove("active")},1e3))});h(this,y,()=>{const s=t(this,r)?this.offsetWidth:this.offsetHeight;c(this,a,t(this,r)?t(this,i).scrollWidth-t(this,i).offsetWidth:t(this,i).scrollHeight-t(this,i).offsetHeight);let e=s*s/(t(this,a)+s);e=Math.max(e,30),t(this,r)?(t(this,n).style.width=e+"px",t(this,n).style.height="100%"):(t(this,n).style.width="100%",t(this,n).style.height=e+"px"),c(this,m,s-e),t(this,r)&&!(t(this,i).scrollWidth>t(this,i).offsetWidth)||!t(this,r)&&!(t(this,i).scrollHeight>t(this,i).offsetHeight)?this.style.display="none":this.style.display="block"});h(this,p,s=>{document.documentElement.classList.add("grabbing");const e=t(this,r)?t(this,i).scrollLeft:t(this,i).scrollTop,b=t(this,r)?s.x:s.y;w.setupDrag(x=>{const H=t(this,a)/t(this,m),S=(t(this,r)?x.x-b:x.y-b)*H;t(this,r)?t(this,i).scroll({left:e+S,behavior:"instant"}):t(this,i).scroll({top:e+S,behavior:"instant"})},()=>{document.documentElement.classList.remove("grabbing")})});h(this,u,()=>{t(this,y).call(this)});h(this,g,s=>{s.isIntersecting?(E.ticker.subscribe(t(this,u),{maxFPS:5}),t(this,u).call(this)):E.ticker.unsubscribe(t(this,u))})}connectedCallback(){const s=this.getAttribute("data-scroll");c(this,r,this.hasAttribute("horisontal"));let e=null;s&&(s==="parent"?e=this.parentElement:e=document.querySelector(s)),e||(e=q.findScrollParentElement(this));const b=this.querySelector("[data-thumb]");e&&b&&(c(this,i,e),c(this,n,b),t(this,i).addEventListener("scroll",t(this,f)),t(this,n).addEventListener("pointerdown",t(this,p)),L.intersector.subscribe(this.parentElement,t(this,g)))}disconnectedCallback(){t(this,i).removeEventListener("scroll",t(this,f)),t(this,n).removeEventListener("pointerdown",t(this,p)),clearTimeout(t(this,d)),L.intersector.unsubscribe(t(this,g)),E.ticker.unsubscribe(t(this,u))}}i=new WeakMap,n=new WeakMap,m=new WeakMap,a=new WeakMap,r=new WeakMap,d=new WeakMap,f=new WeakMap,y=new WeakMap,p=new WeakMap,u=new WeakMap,g=new WeakMap;L.isBrowser&&!customElements.get("e-custom-scrollbar")&&customElements.define("e-custom-scrollbar",T);exports.CustomScrollbarElement=T;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
var v = (l) => {
|
|
2
2
|
throw TypeError(l);
|
|
3
3
|
};
|
|
4
|
-
var S = (l,
|
|
5
|
-
var t = (l,
|
|
4
|
+
var S = (l, o, s) => o.has(l) || v("Cannot " + s);
|
|
5
|
+
var t = (l, o, s) => (S(l, o, "read from private field"), s ? s.call(l) : o.get(l)), r = (l, o, s) => o.has(l) ? v("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(l) : o.set(l, s), c = (l, o, s, e) => (S(l, o, "write to private field"), e ? e.call(l, s) : o.set(l, s), s);
|
|
6
6
|
import { i as k, a as H } from "../index-euf5anj6.js";
|
|
7
7
|
import { f as w } from "../dom-CVWzyXPH.js";
|
|
8
8
|
import { s as z } from "../gestures-CcXV6fCp.js";
|
|
9
9
|
import { ticker as E } from "../ticker/index.js";
|
|
10
|
-
var i, n,
|
|
10
|
+
var i, n, u, a, h, d, b, L, p, m, g;
|
|
11
11
|
class W extends HTMLElement {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments);
|
|
14
14
|
r(this, i, null);
|
|
15
15
|
r(this, n, null);
|
|
16
|
-
r(this,
|
|
16
|
+
r(this, u, 0);
|
|
17
17
|
r(this, a, 0);
|
|
18
|
-
r(this,
|
|
19
|
-
r(this,
|
|
18
|
+
r(this, h, !1);
|
|
19
|
+
r(this, d);
|
|
20
20
|
r(this, b, () => {
|
|
21
|
-
this.classList.add("active"), clearTimeout(t(this,
|
|
22
|
-
const e = (t(this,
|
|
23
|
-
t(this,
|
|
21
|
+
this.classList.add("active"), clearTimeout(t(this, d));
|
|
22
|
+
const e = (t(this, h) ? t(this, i).scrollLeft : t(this, i).scrollTop) / t(this, a) * t(this, u);
|
|
23
|
+
t(this, h) ? t(this, n).style.transform = `translate3d(${e}px, 0px, 0px)` : t(this, n).style.transform = `translate3d(0px, ${e}px, 0px)`, c(this, d, setTimeout(() => {
|
|
24
24
|
this.classList.remove("active");
|
|
25
25
|
}, 1e3));
|
|
26
26
|
});
|
|
27
27
|
r(this, L, () => {
|
|
28
|
-
const s = t(this,
|
|
29
|
-
c(this, a, t(this,
|
|
28
|
+
const s = t(this, h) ? this.offsetWidth : this.offsetHeight;
|
|
29
|
+
c(this, a, t(this, h) ? t(this, i).scrollWidth - t(this, i).offsetWidth : t(this, i).scrollHeight - t(this, i).offsetHeight);
|
|
30
30
|
let e = s * s / (t(this, a) + s);
|
|
31
|
-
e = Math.max(e, 30), t(this,
|
|
31
|
+
e = Math.max(e, 30), t(this, h) ? (t(this, n).style.width = e + "px", t(this, n).style.height = "100%") : (t(this, n).style.width = "100%", t(this, n).style.height = e + "px"), c(this, u, s - e), t(this, h) && !(t(this, i).scrollWidth > t(this, i).offsetWidth) || !t(this, h) && !(t(this, i).scrollHeight > t(this, i).offsetHeight) ? this.style.display = "none" : this.style.display = "block";
|
|
32
32
|
});
|
|
33
33
|
r(this, p, (s) => {
|
|
34
34
|
document.documentElement.classList.add("grabbing");
|
|
35
|
-
const e = t(this,
|
|
35
|
+
const e = t(this, h) ? t(this, i).scrollLeft : t(this, i).scrollTop, f = t(this, h) ? s.x : s.y;
|
|
36
36
|
z(
|
|
37
37
|
(x) => {
|
|
38
|
-
const T = t(this, a) / t(this,
|
|
39
|
-
t(this,
|
|
38
|
+
const T = t(this, a) / t(this, u), y = (t(this, h) ? x.x - f : x.y - f) * T;
|
|
39
|
+
t(this, h) ? t(this, i).scroll({
|
|
40
40
|
left: e + y,
|
|
41
41
|
behavior: "instant"
|
|
42
42
|
}) : t(this, i).scroll({
|
|
@@ -49,26 +49,26 @@ class W extends HTMLElement {
|
|
|
49
49
|
}
|
|
50
50
|
);
|
|
51
51
|
});
|
|
52
|
-
r(this,
|
|
52
|
+
r(this, m, () => {
|
|
53
53
|
t(this, L).call(this);
|
|
54
54
|
});
|
|
55
55
|
r(this, g, (s) => {
|
|
56
|
-
s.isIntersecting ? E.subscribe(t(this,
|
|
56
|
+
s.isIntersecting ? (E.subscribe(t(this, m), { maxFPS: 5 }), t(this, m).call(this)) : E.unsubscribe(t(this, m));
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
connectedCallback() {
|
|
60
60
|
const s = this.getAttribute("data-scroll");
|
|
61
|
-
c(this,
|
|
61
|
+
c(this, h, this.hasAttribute("horisontal"));
|
|
62
62
|
let e = null;
|
|
63
63
|
s && (s === "parent" ? e = this.parentElement : e = document.querySelector(s)), e || (e = w(this));
|
|
64
64
|
const f = this.querySelector("[data-thumb]");
|
|
65
65
|
e && f && (c(this, i, e), c(this, n, f), t(this, i).addEventListener("scroll", t(this, b)), t(this, n).addEventListener("pointerdown", t(this, p)), H.subscribe(this.parentElement, t(this, g)));
|
|
66
66
|
}
|
|
67
67
|
disconnectedCallback() {
|
|
68
|
-
t(this, i).removeEventListener("scroll", t(this, b)), t(this, n).removeEventListener("pointerdown", t(this, p)), clearTimeout(t(this,
|
|
68
|
+
t(this, i).removeEventListener("scroll", t(this, b)), t(this, n).removeEventListener("pointerdown", t(this, p)), clearTimeout(t(this, d)), H.unsubscribe(t(this, g)), E.unsubscribe(t(this, m));
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
i = new WeakMap(), n = new WeakMap(),
|
|
71
|
+
i = new WeakMap(), n = new WeakMap(), u = new WeakMap(), a = new WeakMap(), h = new WeakMap(), d = new WeakMap(), b = new WeakMap(), L = new WeakMap(), p = new WeakMap(), m = new WeakMap(), g = new WeakMap();
|
|
72
72
|
k && !customElements.get("e-custom-scrollbar") && customElements.define("e-custom-scrollbar", W);
|
|
73
73
|
export {
|
|
74
74
|
W as CustomScrollbarElement
|
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface MorphRouteSaveState {
|
|
|
7
7
|
scroll?: MorphRouteScrollState | undefined;
|
|
8
8
|
document?: Document | undefined;
|
|
9
9
|
}
|
|
10
|
+
export type MorpRouteSaveParametersArg = string | object | URLSearchParams;
|
|
10
11
|
export declare class MorphRoute {
|
|
11
12
|
#private;
|
|
12
13
|
constructor(morph: Morph, pathname: string, initialDocument: Document);
|
|
@@ -18,7 +19,9 @@ export declare class MorphRoute {
|
|
|
18
19
|
clearScrollState(): void;
|
|
19
20
|
clearDocumentState(): void;
|
|
20
21
|
saveScrollState(): void;
|
|
21
|
-
saveDocumentState(): void;
|
|
22
22
|
restoreScrollPosition(): void;
|
|
23
|
+
saveDocumentState(): void;
|
|
23
24
|
renewScrollPosition(): void;
|
|
25
|
+
saveState(state: any): void;
|
|
26
|
+
clearState(): any;
|
|
24
27
|
}
|
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,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;
|
|
1
|
+
"use strict";var At=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),kt=n=>{throw TypeError(n)};var ut=(n,t,s)=>t.has(n)||kt("Cannot "+s);var e=(n,t,s)=>(ut(n,t,"read from private field"),s?s.call(n):t.get(n)),a=(n,t,s)=>t.has(n)?kt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),o=(n,t,s,i)=>(ut(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),m=(n,t,s)=>(ut(n,t,"access private method"),s);var z=(n,t,s)=>new Promise((i,d)=>{var v=S=>{try{g(s.next(S))}catch(A){d(A)}},L=S=>{try{g(s.throw(S))}catch(A){d(A)}},g=S=>S.done?i(S.value):Promise.resolve(S.value).then(v,L);g((s=s.apply(n,t)).next())});var Ct=(n,t,s)=>(t=n[At("asyncIterator")])?t.call(n):(n=n[At("iterator")](),t={},s=(i,d)=>(d=n[i])&&(t[i]=v=>new Promise((L,g,S)=>(v=d.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 Ht=require("../index-Cqw2NKev.cjs"),$=require("../events-KVanG9sR.cjs"),Ot=require("../polyfills-Df4r-ETT.cjs"),Tt=require("../scroll-DAhSpkhR.cjs"),rt=require("../url-D1CgmwZ_.cjs"),Bt=require("../css-value-parser/index.cjs");class xt 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)}}Ht.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",xt);var C,l,I,_,K;class dt{constructor(t,s){a(this,C);a(this,l);a(this,I);a(this,_,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,C).previousPathname)history.back();else{const d=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?Bt.cssValueParser.parse(L):void 0,S=e(this,l).hasAttribute("data-revalidate"),A=e(this,l).hasAttribute("data-keep-search-parameters"),f=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(W=>W.trim());e(this,C).navigate(e(this,I),{historyAction:d,centerScroll:v,offsetScroll:g,revalidate:S,keepSearchParameters:A,submorph:f})}});a(this,K,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,I),t),e(this,l).removeEventListener("pointerenter",e(this,K))});o(this,C,s),o(this,l,t),o(this,I,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,_)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,K))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).normalizePath(e(this,I));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,_)),e(this,l).removeEventListener("pointerenter",e(this,K)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,I=new WeakMap,_=new WeakMap,K=new WeakMap;var x,Y,w,O,B,N,G;class Mt{constructor(t,s,i){a(this,x);a(this,Y);a(this,w,{x:0,y:0});a(this,O);a(this,B,null);a(this,N,null);a(this,G,null);o(this,x,t),o(this,Y,s),o(this,O,i.cloneNode(!0))}get pathname(){return e(this,Y)}get scrollState(){return e(this,w)}get document(){return e(this,N)}cloneDocument(){o(this,N,(e(this,B)||e(this,O)).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,Y)}return t}clearScrollState(){e(this,w).x=0,e(this,w).y=0}clearDocumentState(){o(this,B,null)}saveScrollState(){e(this,O).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)}restoreScrollPosition(){e(this,x).scrollElement.scroll({top:e(this,w).y,left:e(this,w).x,behavior:"instant"})}saveDocumentState(){e(this,O).documentElement.hasAttribute("data-no-page-restoration")?o(this,B,null):o(this,B,document.cloneNode(!0))}renewScrollPosition(){e(this,x).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){o(this,G,t)}clearState(){const t=e(this,G);return o(this,G,null),t}}x=new WeakMap,Y=new WeakMap,w=new WeakMap,O=new WeakMap,B=new WeakMap,N=new WeakMap,G=new WeakMap;var T,J,p,at,q,u,tt,F,M,P,D,V,et,c,nt,Nt,ft,qt,pt,Et,gt,vt,ot,Q;const Z=class Z{constructor(t){a(this,c);a(this,T,null);a(this,J,null);a(this,p,[]);a(this,at,new DOMParser);a(this,q);a(this,u,null);a(this,tt);a(this,F,[]);a(this,M,!1);a(this,P,null);a(this,D,new Map);a(this,V,null);a(this,et,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});a(this,ot,t=>z(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),o(this,M,!0),yield this.navigate(t.state.path,{historyAction:"none"}),o(this,M,!1))}));a(this,Q,()=>{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),$.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Ht.isBrowser&&!Z.instance){Z.instance=this,o(this,T,{base:rt.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}),o(this,J,m(this,c,ft).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);o(this,u,s.pathname),e(this,D).set(e(this,u),new Mt(this,e(this,u),document)),document.documentElement.setAttribute("data-current-pathname",e(this,u)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,ot)),rt.changeHistory({action:"replace",pathname:e(this,u),searchParameters:s.parameters||location.search,hash:s.hash}),o(this,V,new xt),m(this,c,gt).call(this,document)}}get currentPathname(){return e(this,u)}get previousPathname(){return e(this,tt)}get links(){return e(this,p)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,M)}saveState(t){const s=e(this,D).get(e(this,u));s&&s.saveState(t)}getState(){const t=e(this,D).get(e(this,u));return t==null?void 0:t.clearState()}normalizePath(t){return rt.splitPath(t,{base:e(this,T).base,trailingSlash:e(this,T).trailingSlash})}prefetch(t,s){return z(this,null,function*(){const i=this.normalizePath(t);m(this,c,nt).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(S){return z(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:d,revalidate:v,keepSearchParameters:L,submorph:g}={}){var yt;if(e(this,F).length)return;const A=this.normalizePath(((yt=this.pathnameModifier)==null?void 0:yt.call(this,t))||t);let{pathname:f,hash:W,parameters:St,leaf:Dt}=A;if(e(this,q)===f||e(this,u)===f){e(this,M)||m(this,c,vt).call(this,W||0,{centerScroll:i,offsetScroll:d,behavior:"smooth"});return}o(this,q,f),e(this,p).forEach(j=>{j.checkCurrent(f)});try{let j=!0;if(this.preprocessor)try{yield new Promise((r,k)=>{var y;(y=this.preprocessor)==null||y.call(this,{pathname:f,resolve:r,reject:k,submorph:g})})}catch(r){r?console.error(r):console.log("Route change canceled"),j=!1}if(!j||e(this,q)!==f){e(this,p).forEach(r=>{r.checkCurrent(e(this,u))});return}const lt={pathname:f,submorph:g};$.dispatchEvent(document,"morphNavigation",{detail:lt});const ct=yield m(this,c,nt).call(this,e(this,u)),b=yield m(this,c,nt).call(this,f,{searchParameters:St,revalidate:v});if(e(this,q)!==f){e(this,p).forEach(r=>{r.checkCurrent(e(this,u))});return}ct.clearState(),ct.saveScrollState(),ct.saveDocumentState(),e(this,M)||(b.clearScrollState(),b.clearDocumentState()),b.cloneDocument(),e(this,V).textContent=b.title,document.body.appendChild(e(this,V)),$.dispatchEvent(document,"morphStart",{detail:lt});const wt=Array.from(document.head.children),Lt=Array.from(b.document.head.children),bt=m(this,c,qt).call(this,wt,Lt),Rt=m(this,c,pt).call(this,wt,bt),st=m(this,c,pt).call(this,Lt,bt);st.forEach((r,k)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=r.getAttribute("src"),st[k]=y}}),st.forEach(r=>{document.head.appendChild(r)});const ht=st.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(m(this,c,Et).call(this,r))return!0});e(this,T).waitForHeadToLoad&&ht.length&&(yield new Promise(r=>z(this,null,function*(){let k=0;try{for(var y=Ct(ht),X,R,U;X=!(R=yield y.next()).done;X=!1){const it=R.value;it.onload=()=>{k++,k===ht.length&&r()}}}catch(R){U=[R]}finally{try{X&&(R=y.return)&&(yield R.call(y))}finally{if(U)throw U[0]}}}))),yield Tt.wait(10);const Pt=[];Rt.forEach(r=>{r.hasAttribute("data-permanent")||(m(this,c,Et).call(this,r)?Pt.push(r):r.remove())});const zt=m(this,c,ft).call(this,b.document.body);e(this,T).morphInsideScrollContainer||m(this,c,gt).call(this,b.document),document.documentElement.setAttribute("data-current-pathname",f),document.documentElement.setAttribute("data-current-leaf",Dt),rt.changeHistory({action:s,pathname:f,searchParameters:St||(L?location.search:""),hash:W}),e(this,V).remove(),o(this,tt,e(this,u)),o(this,u,f),e(this,J).forEach((r,k)=>{const y=zt[k],X=getComputedStyle(r).getPropertyValue("--morph-duration");let R=[],U=[];g?g.forEach(h=>{const E=r.querySelector(h),H=y.querySelector(h);E&&H&&(U.push(E),R.push(H))}):(R.push(...y.childNodes),U.push(...r.childNodes)),U.forEach(h=>{h instanceof HTMLElement&&(this.destroyOldLinks(h),h.classList.add("old"))}),R.forEach(h=>{h instanceof HTMLElement&&(this.findNewLinks(h),h.classList.add("new"))}),g?R.forEach((h,E)=>{var H;(H=U[E].parentElement)==null||H.insertBefore(h,U[E])}):r.prepend(...R),Ot.requestIdleCallback(()=>{R.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 it={morphElement:r,pathname:f};$.dispatchEvent(document,"morphNewChildrenAdded",{detail:it});const It=new Promise(h=>{setTimeout(()=>{U.forEach(E=>E.remove()),R.forEach(E=>{var H;E instanceof HTMLElement&&((H=E.parentElement)==null||H.style.removeProperty("--new-content-height"),E.classList.remove("in","new"))}),$.dispatchEvent(document,"morphOldChildrenRemoved",{detail:it}),h()},(parseFloat(X)||0)*1e3+10)});e(this,F).push(It)}),W?(b.clearScrollState(),m(this,c,vt).call(this,W,{centerScroll:i,offsetScroll:d})):e(this,M)?b.restoreScrollPosition():b.renewScrollPosition(),yield Promise.all(e(this,F)),Pt.forEach(r=>r.remove()),o(this,F,[]),e(this,J).forEach(r=>{r.querySelectorAll("script").forEach(y=>{const X=document.createElement("script");X.type="module",X.src=y.getAttribute("src"),y.replaceWith(X)})}),$.dispatchEvent(document,"morphComplete",{detail:lt}),window.dispatchEvent(new Event("resize"))}catch(j){console.error(j)}o(this,q,void 0)})}addLink(t){e(this,p).push(new dt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){o(this,p,e(this,p).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){o(this,p,e(this,p).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,et));e(this,p).push(...s.map(i=>new dt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,et));e(this,p).forEach(s=>s.destroy()),o(this,p,t.map(s=>new dt(s,this)))}};T=new WeakMap,J=new WeakMap,p=new WeakMap,at=new WeakMap,q=new WeakMap,u=new WeakMap,tt=new WeakMap,F=new WeakMap,M=new WeakMap,P=new WeakMap,D=new WeakMap,V=new WeakMap,et=new WeakMap,c=new WeakSet,nt=function(t,s){return z(this,null,function*(){let i=e(this,D).get(t);return(!i||s!=null&&s.revalidate)&&(i=yield m(this,c,Nt).call(this,t,s==null?void 0:s.searchParameters)),i})},Nt=function(t,s){return z(this,null,function*(){const d=yield(yield fetch(`${t}${s?"?"+s:""}`)).text(),v=e(this,at).parseFromString(d,"text/html"),L=new Mt(this,t,v);return e(this,D).set(t,L),L})},ft=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},qt=function(t,s){return t.filter(i=>s.find(d=>d.outerHTML===i.outerHTML))},pt=function(t,s){return t.filter(i=>!s.find(d=>d.outerHTML===i.outerHTML))},Et=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},gt=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,Q)),o(this,P,t.querySelector(e(this,T).scrollSelector)||t.documentElement),(i=e(this,P))==null||i.addEventListener("scroll",e(this,Q)),e(this,Q).call(this)},vt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Tt.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,Q=new WeakMap,Z.instance=null;let mt=Z;exports.Morph=mt;
|