aptechka 0.61.1 → 0.61.3
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 +81 -78
- package/lib/morph/Morph.d.ts +3 -6
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.d.ts +1 -1
- package/lib/morph/index.js +18 -17
- package/package.json +1 -1
package/lib/billboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var J=i=>{throw TypeError(i)};var
|
|
1
|
+
"use strict";var J=i=>{throw TypeError(i)};var O=(i,r,e)=>r.has(i)||J("Cannot "+e);var t=(i,r,e)=>(O(i,r,"read from private field"),e?e.call(i):r.get(i)),n=(i,r,e)=>r.has(i)?J("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(i):r.set(i,e),o=(i,r,e,s)=>(O(i,r,"write to private field"),s?s.call(i,e):r.set(i,e),e),b=(i,r,e)=>(O(i,r,"access private method"),e);var K=(i,r,e)=>new Promise((s,l)=>{var d=C=>{try{F(e.next(C))}catch(N){l(N)}},S=C=>{try{F(e.throw(C))}catch(N){l(N)}},F=C=>C.done?s(C.value):Promise.resolve(C.value).then(d,S);F((e=e.apply(i,r)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../index-Cqw2NKev.cjs"),G=require("../dom-JBOkFLTh.cjs"),T=require("../css-property/index.cjs"),V=require("../events-KVanG9sR.cjs"),W=require("../gestures-C7gbKx11.cjs"),X=require("../math-GDWEqu7y.cjs"),Y=require("../number-DyefJ5a1.cjs");var k,p,v,g,x,c,h,a,A,y,$,D,_,j,z;class H extends HTMLElement{constructor(){super(...arguments);n(this,a);n(this,k,new T.CSSProperty(this,"--loop",!0));n(this,p,new T.CSSProperty(this,"--autoplay",!1));n(this,v,new T.CSSProperty(this,"--swipe","x"));n(this,g);n(this,x,!1);n(this,c,[]);n(this,h,0);n(this,y,e=>{o(this,x,e.isIntersecting),t(this,x)?b(this,a,A).call(this):clearInterval(t(this,g))});n(this,$,()=>{clearInterval(t(this,g)),t(this,x)&&o(this,g,setInterval(t(this,j),parseFloat(t(this,p).current||"0")*1e3))});n(this,j,()=>{b(this,a,_).call(this,t(this,h)+1)});n(this,z,e=>{if(!t(this,v).current)return;let s=0;W.setupDrag(l=>{const d=e.x-l.x,S=e.y-l.y;t(this,v).current==="x"?Math.abs(d)>Math.abs(S)&&Math.abs(d)>10&&(s=Math.sign(d)):t(this,v).current==="y"&&Math.abs(S)>Math.abs(d)&&Math.abs(S)>10&&(s=Math.sign(S))},()=>{s&&this.shift(s)})})}get counter(){return t(this,h)}get itemElements(){return t(this,c)}addItem(e){t(this,c).push(e),b(this,a,D).call(this)}set(e){(!this.handleSet||this.handleSet(e))&&(b(this,a,_).call(this,e),b(this,a,A).call(this))}shift(e){this.set(t(this,h)+e)}connectedCallback(){var e;o(this,c,[...this.querySelectorAll(`[data-billboard-item${this.id?`="${this.id}"`:""}]`)]),(e=t(this,c)[0])==null||e.classList.add("current"),b(this,a,D).call(this),t(this,p).subscribe(s=>{s.current?(w.intersector.subscribe(this,t(this,y)),b(this,a,A).call(this)):(o(this,x,!0),w.intersector.unsubscribe(t(this,y)),clearInterval(t(this,g)),b(this,a,_).call(this,0))}),t(this,p).observe(),t(this,v).observe(),t(this,k).observe(),this.addEventListener("pointerdown",t(this,z))}disconnectedCallback(){t(this,p).unobserve(),t(this,v).unobserve(),t(this,k).unobserve(),w.intersector.unsubscribe(t(this,y)),clearInterval(t(this,g))}}k=new WeakMap,p=new WeakMap,v=new WeakMap,g=new WeakMap,x=new WeakMap,c=new WeakMap,h=new WeakMap,a=new WeakSet,A=function(){t(this,p).current!==!1&&t(this,$).call(this)},y=new WeakMap,$=new WeakMap,D=function(){this.classList.toggle("has-length",t(this,c).length>1),this.classList.toggle("start",t(this,h)===0),this.classList.toggle("end",t(this,h)===t(this,c).length-1)},_=function(e){t(this,k).current?o(this,h,Y.loopNumber(e,t(this,c).length)):o(this,h,X.clamp(e,0,t(this,c).length-1)),t(this,c).forEach((s,l)=>{s.classList.remove("current","previous","next"),l===t(this,h)?s.classList.add("current"):l<t(this,h)?s.classList.add("previous"):l>t(this,h)&&s.classList.add("next")}),b(this,a,D).call(this),V.dispatchEvent(this,"billboardChange",{detail:{counter:t(this,h)}}),setTimeout(()=>{window.dispatchEvent(new Event("resize"))},0)},j=new WeakMap,z=new WeakMap;customElements.get("e-billboard")||customElements.define("e-billboard",H);var u,B,m,q,M;class Q extends HTMLElement{constructor(){super(...arguments);n(this,u,null);n(this,B,null);n(this,m,[]);n(this,q,e=>{const s=e.currentTarget,l=t(this,m).findIndex(d=>d===s);l>=0&&t(this,u).set(l)});n(this,M,()=>{t(this,m).forEach((e,s)=>{s===t(this,u).counter?e.classList.add("current"):e.classList.remove("current")})})}connectedCallback(){return K(this,null,function*(){var e;if(o(this,u,G.findParentElement(this,H)),t(this,u)&&(yield customElements.whenDefined("e-billboard"),this.isConnected)){this.innerHTML="";const s=t(this,u).itemElements.length;o(this,B,document.createElement("div"));for(let l=0;l<s;l++){const d=document.createElement("button");t(this,m).push(d),t(this,B).appendChild(d)}this.appendChild(t(this,B)),t(this,m).forEach(l=>{l.addEventListener("click",t(this,q))}),(e=t(this,u))==null||e.addEventListener("billboardChange",t(this,M)),t(this,M).call(this)}})}disconnectedCallback(){var e;t(this,m).forEach(s=>{s.removeEventListener("click",t(this,q))}),(e=t(this,u))==null||e.removeEventListener("billboardChange",t(this,M)),this.innerHTML="",o(this,m,[])}}u=new WeakMap,B=new WeakMap,m=new WeakMap,q=new WeakMap,M=new WeakMap;w.isBrowser&&!customElements.get("e-billboard-bullets")&&customElements.define("e-billboard-bullets",Q);var f,E,L;class R extends HTMLElement{constructor(){super();n(this,f,new T.CSSProperty(this,"--index",0));n(this,E,null);n(this,L,()=>{var e;t(this,f).current===((e=t(this,E))==null?void 0:e.counter)?this.classList.add("current"):this.classList.remove("current")});this.addEventListener("click",e=>{t(this,E)&&(!this.handleClick||this.handleClick(e))&&t(this,E).set(t(this,f).current)})}connectedCallback(){var e;this.tabIndex=0,o(this,E,G.findParentElement(this,H)),(e=t(this,E))==null||e.addEventListener("billboardChange",t(this,L)),customElements.whenDefined("e-billboard").then(()=>{this.isConnected&&t(this,L).call(this)}),t(this,f).subscribe(t(this,L)),t(this,f).observe()}disconnectedCallback(){var e;this.removeAttribute("tabindex"),t(this,f).unsubscribe(t(this,L)),t(this,f).unobserve(),(e=t(this,E))==null||e.removeEventListener("billboardChange",t(this,L))}}f=new WeakMap,E=new WeakMap,L=new WeakMap;w.isBrowser&&!customElements.get("e-billboard-set-button")&&customElements.define("e-billboard-set-button",R);var I,P;class U extends HTMLElement{constructor(){super();n(this,I,new T.CSSProperty(this,"--step",1));n(this,P,null);this.addEventListener("click",e=>{t(this,P)&&(!this.handleClick||this.handleClick(e))&&t(this,P).shift(t(this,I).current)})}connectedCallback(){this.tabIndex=0,o(this,P,G.findParentElement(this,H)),t(this,I).observe()}disconnectedCallback(){this.removeAttribute("tabindex"),t(this,I).unobserve()}}I=new WeakMap,P=new WeakMap;w.isBrowser&&!customElements.get("e-billboard-step-button")&&customElements.define("e-billboard-step-button",U);exports.BillboardBulletsElement=Q;exports.BillboardElement=H;exports.BillboardSetButtonElement=R;exports.BillboardStepButtonElement=U;
|
package/lib/billboard/index.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
var Q = (i) => {
|
|
2
2
|
throw TypeError(i);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var t = (i, h, e) => (
|
|
6
|
-
var R = (i, h, e) => new Promise((s,
|
|
7
|
-
var
|
|
4
|
+
var G = (i, h, e) => h.has(i) || Q("Cannot " + e);
|
|
5
|
+
var t = (i, h, e) => (G(i, h, "read from private field"), e ? e.call(i) : h.get(i)), n = (i, h, e) => h.has(i) ? Q("Cannot add the same private member more than once") : h instanceof WeakSet ? h.add(i) : h.set(i, e), o = (i, h, e, s) => (G(i, h, "write to private field"), s ? s.call(i, e) : h.set(i, e), e), b = (i, h, e) => (G(i, h, "access private method"), e);
|
|
6
|
+
var R = (i, h, e) => new Promise((s, l) => {
|
|
7
|
+
var d = (C) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
} catch (
|
|
11
|
-
|
|
9
|
+
N(e.next(C));
|
|
10
|
+
} catch (j) {
|
|
11
|
+
l(j);
|
|
12
12
|
}
|
|
13
13
|
}, k = (C) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
|
|
15
|
+
N(e.throw(C));
|
|
16
|
+
} catch (j) {
|
|
17
|
+
l(j);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, N = (C) => C.done ? s(C.value) : Promise.resolve(C.value).then(d, k);
|
|
20
|
+
N((e = e.apply(i, h)).next());
|
|
21
21
|
});
|
|
22
|
-
import { a as
|
|
22
|
+
import { a as J, i as K } from "../index-euf5anj6.js";
|
|
23
23
|
import { b as O } from "../dom-CVWzyXPH.js";
|
|
24
24
|
import { CSSProperty as T } from "../css-property/index.js";
|
|
25
25
|
import { d as U } from "../events-CsVF98U6.js";
|
|
26
26
|
import { s as V } from "../gestures-CcXV6fCp.js";
|
|
27
27
|
import { c as W } from "../math-BOBiC4TN.js";
|
|
28
28
|
import { l as X } from "../number-CbdpfO3u.js";
|
|
29
|
-
var w, E, v,
|
|
30
|
-
class
|
|
29
|
+
var w, E, v, g, x, c, r, a, A, M, $, D, P, q, z;
|
|
30
|
+
class F extends HTMLElement {
|
|
31
31
|
constructor() {
|
|
32
32
|
super(...arguments);
|
|
33
|
-
n(this,
|
|
33
|
+
n(this, a);
|
|
34
34
|
n(this, w, new T(this, "--loop", !0));
|
|
35
35
|
n(this, E, new T(this, "--autoplay", !1));
|
|
36
36
|
n(this, v, new T(this, "--swipe", "x"));
|
|
37
|
-
n(this,
|
|
37
|
+
n(this, g);
|
|
38
38
|
n(this, x, !1);
|
|
39
|
-
n(this,
|
|
40
|
-
n(this,
|
|
39
|
+
n(this, c, []);
|
|
40
|
+
n(this, r, 0);
|
|
41
41
|
n(this, M, (e) => {
|
|
42
|
-
|
|
42
|
+
o(this, x, e.isIntersecting), t(this, x) ? b(this, a, A).call(this) : clearInterval(t(this, g));
|
|
43
43
|
});
|
|
44
|
-
n(this,
|
|
45
|
-
clearInterval(t(this,
|
|
46
|
-
t(this,
|
|
44
|
+
n(this, $, () => {
|
|
45
|
+
clearInterval(t(this, g)), t(this, x) && o(this, g, setInterval(
|
|
46
|
+
t(this, q),
|
|
47
47
|
parseFloat(t(this, E).current || "0") * 1e3
|
|
48
48
|
));
|
|
49
49
|
});
|
|
50
|
-
n(this,
|
|
51
|
-
|
|
50
|
+
n(this, q, () => {
|
|
51
|
+
b(this, a, P).call(this, t(this, r) + 1);
|
|
52
52
|
});
|
|
53
|
-
n(this,
|
|
53
|
+
n(this, z, (e) => {
|
|
54
54
|
if (!t(this, v).current)
|
|
55
55
|
return;
|
|
56
56
|
let s = 0;
|
|
57
57
|
V(
|
|
58
|
-
(
|
|
59
|
-
const
|
|
60
|
-
t(this, v).current === "x" ? Math.abs(
|
|
58
|
+
(l) => {
|
|
59
|
+
const d = e.x - l.x, k = e.y - l.y;
|
|
60
|
+
t(this, v).current === "x" ? Math.abs(d) > Math.abs(k) && Math.abs(d) > 10 && (s = Math.sign(d)) : t(this, v).current === "y" && Math.abs(k) > Math.abs(d) && Math.abs(k) > 10 && (s = Math.sign(k));
|
|
61
61
|
},
|
|
62
62
|
() => {
|
|
63
63
|
s && this.shift(s);
|
|
@@ -66,81 +66,84 @@ class z extends HTMLElement {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
get counter() {
|
|
69
|
-
return t(this,
|
|
69
|
+
return t(this, r);
|
|
70
70
|
}
|
|
71
71
|
get itemElements() {
|
|
72
|
-
return t(this,
|
|
72
|
+
return t(this, c);
|
|
73
73
|
}
|
|
74
74
|
addItem(e) {
|
|
75
|
-
t(this,
|
|
75
|
+
t(this, c).push(e), b(this, a, D).call(this);
|
|
76
76
|
}
|
|
77
77
|
set(e) {
|
|
78
|
-
(!this.handleSet || this.handleSet(e)) && (
|
|
78
|
+
(!this.handleSet || this.handleSet(e)) && (b(this, a, P).call(this, e), b(this, a, A).call(this));
|
|
79
79
|
}
|
|
80
80
|
shift(e) {
|
|
81
|
-
this.set(t(this,
|
|
81
|
+
this.set(t(this, r) + e);
|
|
82
82
|
}
|
|
83
83
|
connectedCallback() {
|
|
84
84
|
var e;
|
|
85
|
-
|
|
85
|
+
o(this, c, [
|
|
86
86
|
...this.querySelectorAll(
|
|
87
87
|
`[data-billboard-item${this.id ? `="${this.id}"` : ""}]`
|
|
88
88
|
)
|
|
89
|
-
]), (e = t(this,
|
|
90
|
-
s.current ? (
|
|
91
|
-
}), t(this, E).observe(), t(this, v).observe(), t(this, w).observe(), this.addEventListener("pointerdown", t(this,
|
|
89
|
+
]), (e = t(this, c)[0]) == null || e.classList.add("current"), b(this, a, D).call(this), t(this, E).subscribe((s) => {
|
|
90
|
+
s.current ? (J.subscribe(this, t(this, M)), b(this, a, A).call(this)) : (o(this, x, !0), J.unsubscribe(t(this, M)), clearInterval(t(this, g)), b(this, a, P).call(this, 0));
|
|
91
|
+
}), t(this, E).observe(), t(this, v).observe(), t(this, w).observe(), this.addEventListener("pointerdown", t(this, z));
|
|
92
92
|
}
|
|
93
93
|
disconnectedCallback() {
|
|
94
|
-
t(this, E).unobserve(), t(this, v).unobserve(), t(this, w).unobserve(),
|
|
94
|
+
t(this, E).unobserve(), t(this, v).unobserve(), t(this, w).unobserve(), J.unsubscribe(t(this, M)), clearInterval(t(this, g));
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
w = new WeakMap(), E = new WeakMap(), v = new WeakMap(),
|
|
98
|
-
t(this,
|
|
99
|
-
},
|
|
100
|
-
t(this,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
w = new WeakMap(), E = new WeakMap(), v = new WeakMap(), g = new WeakMap(), x = new WeakMap(), c = new WeakMap(), r = new WeakMap(), a = new WeakSet(), A = function() {
|
|
98
|
+
t(this, E).current !== !1 && t(this, $).call(this);
|
|
99
|
+
}, M = new WeakMap(), $ = new WeakMap(), D = function() {
|
|
100
|
+
this.classList.toggle("has-length", t(this, c).length > 1), this.classList.toggle("start", t(this, r) === 0), this.classList.toggle(
|
|
101
|
+
"end",
|
|
102
|
+
t(this, r) === t(this, c).length - 1
|
|
103
|
+
);
|
|
104
|
+
}, P = function(e) {
|
|
105
|
+
t(this, w).current ? o(this, r, X(e, t(this, c).length)) : o(this, r, W(e, 0, t(this, c).length - 1)), t(this, c).forEach((s, l) => {
|
|
106
|
+
s.classList.remove("current", "previous", "next"), l === t(this, r) ? s.classList.add("current") : l < t(this, r) ? s.classList.add("previous") : l > t(this, r) && s.classList.add("next");
|
|
107
|
+
}), b(this, a, D).call(this), U(this, "billboardChange", {
|
|
105
108
|
detail: {
|
|
106
|
-
counter: t(this,
|
|
109
|
+
counter: t(this, r)
|
|
107
110
|
}
|
|
108
111
|
}), setTimeout(() => {
|
|
109
112
|
window.dispatchEvent(new Event("resize"));
|
|
110
113
|
}, 0);
|
|
111
|
-
},
|
|
112
|
-
customElements.get("e-billboard") || customElements.define("e-billboard",
|
|
113
|
-
var
|
|
114
|
+
}, q = new WeakMap(), z = new WeakMap();
|
|
115
|
+
customElements.get("e-billboard") || customElements.define("e-billboard", F);
|
|
116
|
+
var u, I, m, H, y;
|
|
114
117
|
class Y extends HTMLElement {
|
|
115
118
|
constructor() {
|
|
116
119
|
super(...arguments);
|
|
117
|
-
n(this,
|
|
120
|
+
n(this, u, null);
|
|
118
121
|
n(this, I, null);
|
|
119
122
|
n(this, m, []);
|
|
120
123
|
n(this, H, (e) => {
|
|
121
|
-
const s = e.currentTarget,
|
|
122
|
-
|
|
124
|
+
const s = e.currentTarget, l = t(this, m).findIndex((d) => d === s);
|
|
125
|
+
l >= 0 && t(this, u).set(l);
|
|
123
126
|
});
|
|
124
127
|
n(this, y, () => {
|
|
125
128
|
t(this, m).forEach((e, s) => {
|
|
126
|
-
s === t(this,
|
|
129
|
+
s === t(this, u).counter ? e.classList.add("current") : e.classList.remove("current");
|
|
127
130
|
});
|
|
128
131
|
});
|
|
129
132
|
}
|
|
130
133
|
connectedCallback() {
|
|
131
134
|
return R(this, null, function* () {
|
|
132
135
|
var e;
|
|
133
|
-
if (
|
|
136
|
+
if (o(this, u, O(this, F)), t(this, u) && (yield customElements.whenDefined("e-billboard"), this.isConnected)) {
|
|
134
137
|
this.innerHTML = "";
|
|
135
|
-
const s = t(this,
|
|
136
|
-
|
|
137
|
-
for (let
|
|
138
|
-
const
|
|
139
|
-
t(this, m).push(
|
|
138
|
+
const s = t(this, u).itemElements.length;
|
|
139
|
+
o(this, I, document.createElement("div"));
|
|
140
|
+
for (let l = 0; l < s; l++) {
|
|
141
|
+
const d = document.createElement("button");
|
|
142
|
+
t(this, m).push(d), t(this, I).appendChild(d);
|
|
140
143
|
}
|
|
141
|
-
this.appendChild(t(this, I)), t(this, m).forEach((
|
|
142
|
-
|
|
143
|
-
}), (e = t(this,
|
|
144
|
+
this.appendChild(t(this, I)), t(this, m).forEach((l) => {
|
|
145
|
+
l.addEventListener("click", t(this, H));
|
|
146
|
+
}), (e = t(this, u)) == null || e.addEventListener(
|
|
144
147
|
"billboardChange",
|
|
145
148
|
t(this, y)
|
|
146
149
|
), t(this, y).call(this);
|
|
@@ -151,21 +154,21 @@ class Y extends HTMLElement {
|
|
|
151
154
|
var e;
|
|
152
155
|
t(this, m).forEach((s) => {
|
|
153
156
|
s.removeEventListener("click", t(this, H));
|
|
154
|
-
}), (e = t(this,
|
|
157
|
+
}), (e = t(this, u)) == null || e.removeEventListener(
|
|
155
158
|
"billboardChange",
|
|
156
159
|
t(this, y)
|
|
157
|
-
), this.innerHTML = "",
|
|
160
|
+
), this.innerHTML = "", o(this, m, []);
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
|
-
|
|
163
|
+
u = new WeakMap(), I = new WeakMap(), m = new WeakMap(), H = new WeakMap(), y = new WeakMap();
|
|
161
164
|
K && !customElements.get("e-billboard-bullets") && customElements.define("e-billboard-bullets", Y);
|
|
162
|
-
var f, p,
|
|
165
|
+
var f, p, L;
|
|
163
166
|
class Z extends HTMLElement {
|
|
164
167
|
constructor() {
|
|
165
168
|
super();
|
|
166
169
|
n(this, f, new T(this, "--index", 0));
|
|
167
170
|
n(this, p, null);
|
|
168
|
-
n(this,
|
|
171
|
+
n(this, L, () => {
|
|
169
172
|
var e;
|
|
170
173
|
t(this, f).current === ((e = t(this, p)) == null ? void 0 : e.counter) ? this.classList.add("current") : this.classList.remove("current");
|
|
171
174
|
});
|
|
@@ -175,22 +178,22 @@ class Z extends HTMLElement {
|
|
|
175
178
|
}
|
|
176
179
|
connectedCallback() {
|
|
177
180
|
var e;
|
|
178
|
-
this.tabIndex = 0,
|
|
181
|
+
this.tabIndex = 0, o(this, p, O(this, F)), (e = t(this, p)) == null || e.addEventListener(
|
|
179
182
|
"billboardChange",
|
|
180
|
-
t(this,
|
|
183
|
+
t(this, L)
|
|
181
184
|
), customElements.whenDefined("e-billboard").then(() => {
|
|
182
|
-
this.isConnected && t(this,
|
|
183
|
-
}), t(this, f).subscribe(t(this,
|
|
185
|
+
this.isConnected && t(this, L).call(this);
|
|
186
|
+
}), t(this, f).subscribe(t(this, L)), t(this, f).observe();
|
|
184
187
|
}
|
|
185
188
|
disconnectedCallback() {
|
|
186
189
|
var e;
|
|
187
|
-
this.removeAttribute("tabindex"), t(this, f).unsubscribe(t(this,
|
|
190
|
+
this.removeAttribute("tabindex"), t(this, f).unsubscribe(t(this, L)), t(this, f).unobserve(), (e = t(this, p)) == null || e.removeEventListener(
|
|
188
191
|
"billboardChange",
|
|
189
|
-
t(this,
|
|
192
|
+
t(this, L)
|
|
190
193
|
);
|
|
191
194
|
}
|
|
192
195
|
}
|
|
193
|
-
f = new WeakMap(), p = new WeakMap(),
|
|
196
|
+
f = new WeakMap(), p = new WeakMap(), L = new WeakMap();
|
|
194
197
|
K && !customElements.get("e-billboard-set-button") && customElements.define("e-billboard-set-button", Z);
|
|
195
198
|
var B, S;
|
|
196
199
|
class _ extends HTMLElement {
|
|
@@ -203,7 +206,7 @@ class _ extends HTMLElement {
|
|
|
203
206
|
});
|
|
204
207
|
}
|
|
205
208
|
connectedCallback() {
|
|
206
|
-
this.tabIndex = 0,
|
|
209
|
+
this.tabIndex = 0, o(this, S, O(this, F)), t(this, B).observe();
|
|
207
210
|
}
|
|
208
211
|
disconnectedCallback() {
|
|
209
212
|
this.removeAttribute("tabindex"), t(this, B).unobserve();
|
|
@@ -213,7 +216,7 @@ B = new WeakMap(), S = new WeakMap();
|
|
|
213
216
|
K && !customElements.get("e-billboard-step-button") && customElements.define("e-billboard-step-button", _);
|
|
214
217
|
export {
|
|
215
218
|
Y as BillboardBulletsElement,
|
|
216
|
-
|
|
219
|
+
F as BillboardElement,
|
|
217
220
|
Z as BillboardSetButtonElement,
|
|
218
221
|
_ as BillboardStepButtonElement
|
|
219
222
|
};
|
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -10,8 +10,6 @@ export interface MorphOptions {
|
|
|
10
10
|
}
|
|
11
11
|
export interface MorphNavigationEntry {
|
|
12
12
|
pathname: string;
|
|
13
|
-
}
|
|
14
|
-
export interface MorphTransitionEntry extends MorphNavigationEntry {
|
|
15
13
|
submorph?: Array<string>;
|
|
16
14
|
}
|
|
17
15
|
export interface MorphChildrenActionEntry {
|
|
@@ -23,7 +21,6 @@ export interface MorphPreprocessorEntry extends MorphNavigationEntry {
|
|
|
23
21
|
reject: () => void;
|
|
24
22
|
}
|
|
25
23
|
export type MorphPreprocessor = (entry: MorphPreprocessorEntry) => void;
|
|
26
|
-
export type MorphNavigationCallback = (entry: MorphNavigationEntry) => void;
|
|
27
24
|
export type MorphPathnameModifier = (pathname: string) => string;
|
|
28
25
|
export interface MorphNavigateOptions {
|
|
29
26
|
historyAction?: ChangeHistoryAction;
|
|
@@ -38,9 +35,9 @@ export interface MorphScrollDetail {
|
|
|
38
35
|
top: number;
|
|
39
36
|
}
|
|
40
37
|
export interface MorphEvents {
|
|
41
|
-
morphNavigation: CustomEvent<
|
|
42
|
-
morphStart: CustomEvent<
|
|
43
|
-
morphComplete: CustomEvent<
|
|
38
|
+
morphNavigation: CustomEvent<MorphNavigationEntry>;
|
|
39
|
+
morphStart: CustomEvent<MorphNavigationEntry>;
|
|
40
|
+
morphComplete: CustomEvent<MorphNavigationEntry>;
|
|
44
41
|
morphNewChildrenAdded: CustomEvent<MorphChildrenActionEntry>;
|
|
45
42
|
morphOldChildrenRemoved: CustomEvent<MorphChildrenActionEntry>;
|
|
46
43
|
morphScroll: CustomEvent<MorphScrollDetail>;
|
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 g=S=>{try{v(s.next(S))}catch(A){u(A)}},L=S=>{try{v(s.throw(S))}catch(A){u(A)}},v=S=>S.done?i(S.value):Promise.resolve(S.value).then(g,L);v((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]=g=>new Promise((L,v,S)=>(g=u.call(n,g),S=g.done,Promise.resolve(g.value).then(A=>L({value:A,done:S}),v)))),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",g=e(this,l).hasAttribute("data-center-scroll"),L=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),v=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:g,offsetScroll:v,revalidate:S,keepSearchParameters:A,submorph:m})}});o(this,$,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,z),t),e(this,l).removeEventListener("pointerenter",e(this,$))});a(this,C,s),a(this,l,t),a(this,z,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,Z)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,$))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).normalizePath(e(this,z));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,Z)),e(this,l).removeEventListener("pointerenter",e(this,$)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,z=new WeakMap,Z=new WeakMap,$=new WeakMap;var x,K,w,I,O,N;class Tt{constructor(t,s,i){o(this,x);o(this,K);o(this,w,{x:0,y:0});o(this,I);o(this,O,null);o(this,N,null);a(this,x,t),a(this,K,s),a(this,I,i.cloneNode(!0))}get pathname(){return e(this,K)}get scrollState(){return e(this,w)}get document(){return e(this,N)}cloneDocument(){a(this,N,(e(this,O)||e(this,I)).cloneNode(!0))}get title(){let t="";if(e(this,N).title)t=e(this,N).title;else{const s=e(this,N).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,K)}return t}clearScrollState(){e(this,w).x=0,e(this,w).y=0}clearDocumentState(){a(this,O,null)}saveScrollState(){e(this,I).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,w).x=0,e(this,w).y=0):(e(this,w).x=e(this,x).scrollElement.scrollLeft,e(this,w).y=e(this,x).scrollElement.scrollTop)}saveDocumentState(){e(this,I).documentElement.hasAttribute("data-no-page-restoration")?a(this,O,null):a(this,O,document.cloneNode(!0))}restoreScrollPosition(){e(this,x).scrollElement.scroll({top:e(this,w).y,left:e(this,w).x})}renewScrollPosition(){e(this,x).scrollElement.scroll({top:0,left:0,behavior:"instant"})}}x=new WeakMap,K=new WeakMap,w=new WeakMap,I=new WeakMap,O=new WeakMap,N=new WeakMap;var T,Y,f,nt,q,p,_,B,M,P,G,F,tt,c,rt,xt,dt,Nt,mt,ft,pt,Et,ot,J;const X=class X{constructor(t){o(this,c);o(this,T,null);o(this,Y,null);o(this,f,[]);o(this,nt,new DOMParser);o(this,q);o(this,p,null);o(this,_);o(this,B,[]);o(this,M,!1);o(this,P,null);o(this,G,new Map);o(this,F,null);o(this,tt,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,ot,t=>R(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),a(this,M,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,M,!1))}));o(this,J,()=>{const t=e(this,P).scrollTop,s=e(this,P).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),U.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Mt.isBrowser&&!X.instance){X.instance=this,a(this,T,{base:it.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body",morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),a(this,Y,d(this,c,dt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,p,s.pathname),e(this,G).set(e(this,p),new Tt(this,e(this,p),document)),document.documentElement.setAttribute("data-current-pathname",e(this,p)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,ot)),it.changeHistory({action:"replace",pathname:e(this,p),searchParameters:s.parameters||location.search,hash:s.hash}),a(this,F,new Ht),d(this,c,pt).call(this,document)}}get currentPathname(){return e(this,p)}get previousPathname(){return e(this,_)}get links(){return e(this,f)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,M)}normalizePath(t){return it.splitPath(t,{base:e(this,T).base,trailingSlash:e(this,T).trailingSlash})}prefetch(t,s){return R(this,null,function*(){const i=this.normalizePath(t);d(this,c,rt).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(S){return R(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:g,keepSearchParameters:L,submorph:v}={}){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})})}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:v};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:g});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=[];v?v.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"))}),v?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(),g=e(this,nt).parseFromString(u,"text/html"),L=new Tt(this,t,g);return e(this,G).set(t,L),L})},dt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Nt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},mt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ft=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},pt=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,J)),a(this,P,t.querySelector(e(this,T).scrollSelector)||t.documentElement),(i=e(this,P))==null||i.addEventListener("scroll",e(this,J)),e(this,J).call(this)},Et=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ct.scrollToElement(i,{scrollElement:e(this,P),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ot=new WeakMap,J=new WeakMap,X.instance=null;let ut=X;exports.Morph=ut;
|
|
1
|
+
"use strict";var Pt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),At=n=>{throw TypeError(n)};var ct=(n,t,s)=>t.has(n)||At("Cannot "+s);var e=(n,t,s)=>(ct(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?At("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>(ct(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>(ct(n,t,"access private method"),s);var R=(n,t,s)=>new Promise((i,u)=>{var v=S=>{try{g(s.next(S))}catch(A){u(A)}},L=S=>{try{g(s.throw(S))}catch(A){u(A)}},g=S=>S.done?i(S.value):Promise.resolve(S.value).then(v,L);g((s=s.apply(n,t)).next())});var kt=(n,t,s)=>(t=n[Pt("asyncIterator")])?t.call(n):(n=n[Pt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=v=>new Promise((L,g,S)=>(v=u.call(n,v),S=v.done,Promise.resolve(v.value).then(A=>L({value:A,done:S}),g)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Mt=require("../index-Cqw2NKev.cjs"),U=require("../events-KVanG9sR.cjs"),It=require("../polyfills-Df4r-ETT.cjs"),Ct=require("../scroll-DAhSpkhR.cjs"),it=require("../url-D1CgmwZ_.cjs"),Ot=require("../css-value-parser/index.cjs");class Ht extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(t))this.setAttribute(s,i)}}Mt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Ht);var C,l,z,Z,$;class ht{constructor(t,s){o(this,C);o(this,l);o(this,z);o(this,Z,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,C).previousPathname)history.back();else{const u=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),L=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),g=L?Ot.cssValueParser.parse(L):void 0,S=e(this,l).hasAttribute("data-revalidate"),A=e(this,l).hasAttribute("data-keep-search-parameters"),m=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(V=>V.trim());e(this,C).navigate(e(this,z),{historyAction:u,centerScroll:v,offsetScroll:g,revalidate:S,keepSearchParameters:A,submorph:m})}});o(this,$,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,z),t),e(this,l).removeEventListener("pointerenter",e(this,$))});a(this,C,s),a(this,l,t),a(this,z,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,Z)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,$))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).normalizePath(e(this,z));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,Z)),e(this,l).removeEventListener("pointerenter",e(this,$)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,z=new WeakMap,Z=new WeakMap,$=new WeakMap;var x,K,w,I,O,N;class Tt{constructor(t,s,i){o(this,x);o(this,K);o(this,w,{x:0,y:0});o(this,I);o(this,O,null);o(this,N,null);a(this,x,t),a(this,K,s),a(this,I,i.cloneNode(!0))}get pathname(){return e(this,K)}get scrollState(){return e(this,w)}get document(){return e(this,N)}cloneDocument(){a(this,N,(e(this,O)||e(this,I)).cloneNode(!0))}get title(){let t="";if(e(this,N).title)t=e(this,N).title;else{const s=e(this,N).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,K)}return t}clearScrollState(){e(this,w).x=0,e(this,w).y=0}clearDocumentState(){a(this,O,null)}saveScrollState(){e(this,I).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,w).x=0,e(this,w).y=0):(e(this,w).x=e(this,x).scrollElement.scrollLeft,e(this,w).y=e(this,x).scrollElement.scrollTop)}saveDocumentState(){e(this,I).documentElement.hasAttribute("data-no-page-restoration")?a(this,O,null):a(this,O,document.cloneNode(!0))}restoreScrollPosition(){e(this,x).scrollElement.scroll({top:e(this,w).y,left:e(this,w).x})}renewScrollPosition(){e(this,x).scrollElement.scroll({top:0,left:0,behavior:"instant"})}}x=new WeakMap,K=new WeakMap,w=new WeakMap,I=new WeakMap,O=new WeakMap,N=new WeakMap;var T,Y,f,nt,q,p,_,B,M,P,G,F,tt,c,rt,xt,dt,Nt,mt,ft,pt,Et,ot,J;const X=class X{constructor(t){o(this,c);o(this,T,null);o(this,Y,null);o(this,f,[]);o(this,nt,new DOMParser);o(this,q);o(this,p,null);o(this,_);o(this,B,[]);o(this,M,!1);o(this,P,null);o(this,G,new Map);o(this,F,null);o(this,tt,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,ot,t=>R(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),a(this,M,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,M,!1))}));o(this,J,()=>{const t=e(this,P).scrollTop,s=e(this,P).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),U.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Mt.isBrowser&&!X.instance){X.instance=this,a(this,T,{base:it.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body",morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),a(this,Y,d(this,c,dt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,p,s.pathname),e(this,G).set(e(this,p),new Tt(this,e(this,p),document)),document.documentElement.setAttribute("data-current-pathname",e(this,p)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,ot)),it.changeHistory({action:"replace",pathname:e(this,p),searchParameters:s.parameters||location.search,hash:s.hash}),a(this,F,new Ht),d(this,c,pt).call(this,document)}}get currentPathname(){return e(this,p)}get previousPathname(){return e(this,_)}get links(){return e(this,f)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,M)}normalizePath(t){return it.splitPath(t,{base:e(this,T).base,trailingSlash:e(this,T).trailingSlash})}prefetch(t,s){return R(this,null,function*(){const i=this.normalizePath(t);d(this,c,rt).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(S){return R(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:v,keepSearchParameters:L,submorph:g}={}){var vt;if(e(this,B).length)return;const A=this.normalizePath(((vt=this.pathnameModifier)==null?void 0:vt.call(this,t))||t);let{pathname:m,hash:V,parameters:gt,leaf:qt}=A;if(e(this,q)===m||e(this,p)===m){e(this,M)||d(this,c,Et).call(this,V||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,q,m),e(this,f).forEach(W=>{W.checkCurrent(m)});try{let W=!0;if(this.preprocessor)try{yield new Promise((r,k)=>{var y;(y=this.preprocessor)==null||y.call(this,{pathname:m,resolve:r,reject:k,submorph:g})})}catch(r){r?console.error(r):console.log("Route change canceled"),W=!1}if(!W||e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}const at={pathname:m,submorph:g};U.dispatchEvent(document,"morphNavigation",{detail:at});const St=yield d(this,c,rt).call(this,e(this,p)),b=yield d(this,c,rt).call(this,m,{searchParameters:gt,revalidate:v});if(e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}St.saveScrollState(),St.saveDocumentState(),e(this,M)||(b.clearScrollState(),b.clearDocumentState()),b.cloneDocument(),e(this,F).textContent=b.title,document.body.appendChild(e(this,F)),U.dispatchEvent(document,"morphStart",{detail:at});const yt=Array.from(document.head.children),wt=Array.from(b.document.head.children),Lt=d(this,c,Nt).call(this,yt,wt),Dt=d(this,c,mt).call(this,yt,Lt),et=d(this,c,mt).call(this,wt,Lt);et.forEach((r,k)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=r.getAttribute("src"),et[k]=y}}),et.forEach(r=>{document.head.appendChild(r)});const lt=et.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,c,ft).call(this,r))return!0});e(this,T).waitForHeadToLoad&<.length&&(yield new Promise(r=>R(this,null,function*(){let k=0;try{for(var y=kt(lt),Q,D,j;Q=!(D=yield y.next()).done;Q=!1){const st=D.value;st.onload=()=>{k++,k===lt.length&&r()}}}catch(D){j=[D]}finally{try{Q&&(D=y.return)&&(yield D.call(y))}finally{if(j)throw j[0]}}}))),yield Ct.wait(10);const bt=[];Dt.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,c,ft).call(this,r)?bt.push(r):r.remove())});const Rt=d(this,c,dt).call(this,b.document.body);e(this,T).morphInsideScrollContainer||d(this,c,pt).call(this,b.document),document.documentElement.setAttribute("data-current-pathname",m),document.documentElement.setAttribute("data-current-leaf",qt),it.changeHistory({action:s,pathname:m,searchParameters:gt||(L?location.search:""),hash:V}),e(this,F).remove(),a(this,_,e(this,p)),a(this,p,m),e(this,Y).forEach((r,k)=>{const y=Rt[k],Q=getComputedStyle(r).getPropertyValue("--morph-duration");let D=[],j=[];g?g.forEach(h=>{const E=r.querySelector(h),H=y.querySelector(h);E&&H&&(j.push(E),D.push(H))}):(D.push(...y.childNodes),j.push(...r.childNodes)),j.forEach(h=>{h instanceof HTMLElement&&(this.destroyOldLinks(h),h.classList.add("old"))}),D.forEach(h=>{h instanceof HTMLElement&&(this.findNewLinks(h),h.classList.add("new"))}),g?D.forEach((h,E)=>{var H;(H=j[E].parentElement)==null||H.insertBefore(h,j[E])}):r.prepend(...D),It.requestIdleCallback(()=>{D.forEach(h=>{var E;h instanceof HTMLElement&&((E=h.parentElement)==null||E.style.setProperty("--new-content-height",h.offsetHeight+"px"),h.classList.add("in"))})});const st={morphElement:r,pathname:m};U.dispatchEvent(document,"morphNewChildrenAdded",{detail:st});const zt=new Promise(h=>{setTimeout(()=>{j.forEach(E=>E.remove()),D.forEach(E=>{var H;E instanceof HTMLElement&&((H=E.parentElement)==null||H.style.removeProperty("--new-content-height"),E.classList.remove("in","new"))}),U.dispatchEvent(document,"morphOldChildrenRemoved",{detail:st}),h()},(parseFloat(Q)||0)*1e3+10)});e(this,B).push(zt)}),V?(b.clearScrollState(),d(this,c,Et).call(this,V,{centerScroll:i,offsetScroll:u})):e(this,M)?b.restoreScrollPosition():b.renewScrollPosition(),yield Promise.all(e(this,B)),bt.forEach(r=>r.remove()),a(this,B,[]),e(this,Y).forEach(r=>{r.querySelectorAll("script").forEach(y=>{const Q=document.createElement("script");Q.type="module",Q.src=y.getAttribute("src"),y.replaceWith(Q)})}),U.dispatchEvent(document,"morphComplete",{detail:at}),window.dispatchEvent(new Event("resize"))}catch(W){console.error(W)}a(this,q,void 0)})}addLink(t){e(this,f).push(new ht(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,f,e(this,f).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){a(this,f,e(this,f).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,tt));e(this,f).push(...s.map(i=>new ht(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,tt));e(this,f).forEach(s=>s.destroy()),a(this,f,t.map(s=>new ht(s,this)))}};T=new WeakMap,Y=new WeakMap,f=new WeakMap,nt=new WeakMap,q=new WeakMap,p=new WeakMap,_=new WeakMap,B=new WeakMap,M=new WeakMap,P=new WeakMap,G=new WeakMap,F=new WeakMap,tt=new WeakMap,c=new WeakSet,rt=function(t,s){return R(this,null,function*(){let i=e(this,G).get(t);return(!i||s!=null&&s.revalidate)&&(i=yield d(this,c,xt).call(this,t,s==null?void 0:s.searchParameters)),i})},xt=function(t,s){return R(this,null,function*(){const u=yield(yield fetch(`${t}${s?"?"+s:""}`)).text(),v=e(this,nt).parseFromString(u,"text/html"),L=new Tt(this,t,v);return e(this,G).set(t,L),L})},dt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Nt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},mt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ft=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},pt=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,J)),a(this,P,t.querySelector(e(this,T).scrollSelector)||t.documentElement),(i=e(this,P))==null||i.addEventListener("scroll",e(this,J)),e(this,J).call(this)},Et=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ct.scrollToElement(i,{scrollElement:e(this,P),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ot=new WeakMap,J=new WeakMap,X.instance=null;let ut=X;exports.Morph=ut;
|
package/lib/morph/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Morph, type
|
|
1
|
+
export { Morph, type MorphPreprocessor, type MorphPreprocessorEntry, type MorphNavigationEntry, type MorphOptions, type MorphChildrenActionEntry, type MorphNavigateOptions, type MorphEvents, } from './Morph';
|
package/lib/morph/index.js
CHANGED
|
@@ -4,22 +4,22 @@ var Lt = (n, t) => (t = Symbol[n]) ? t : Symbol.for("Symbol." + n), bt = (n) =>
|
|
|
4
4
|
var lt = (n, t, s) => t.has(n) || bt("Cannot " + s);
|
|
5
5
|
var e = (n, t, s) => (lt(n, t, "read from private field"), s ? s.call(n) : t.get(n)), o = (n, t, s) => t.has(n) ? bt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s), a = (n, t, s, i) => (lt(n, t, "write to private field"), i ? i.call(n, s) : t.set(n, s), s), d = (n, t, s) => (lt(n, t, "access private method"), s);
|
|
6
6
|
var q = (n, t, s) => new Promise((i, u) => {
|
|
7
|
-
var
|
|
7
|
+
var S = (v) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
9
|
+
g(s.next(v));
|
|
10
10
|
} catch (A) {
|
|
11
11
|
u(A);
|
|
12
12
|
}
|
|
13
13
|
}, L = (v) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
g(s.throw(v));
|
|
16
16
|
} catch (A) {
|
|
17
17
|
u(A);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, g = (v) => v.done ? i(v.value) : Promise.resolve(v.value).then(S, L);
|
|
20
|
+
g((s = s.apply(n, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var Pt = (n, t, s) => (t = n[Lt("asyncIterator")]) ? t.call(n) : (n = n[Lt("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (
|
|
22
|
+
var Pt = (n, t, s) => (t = n[Lt("asyncIterator")]) ? t.call(n) : (n = n[Lt("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (S) => new Promise((L, g, v) => (S = u.call(n, S), v = S.done, Promise.resolve(S.value).then((A) => L({ value: A, done: v }), g)))), s("next"), s("return"), t);
|
|
23
23
|
import { i as Tt } from "../index-euf5anj6.js";
|
|
24
24
|
import { d as $ } from "../events-CsVF98U6.js";
|
|
25
25
|
import { r as zt } from "../polyfills-DJrTJQky.js";
|
|
@@ -51,13 +51,13 @@ class ht {
|
|
|
51
51
|
else {
|
|
52
52
|
const u = e(this, l).getAttribute(
|
|
53
53
|
"data-history-action"
|
|
54
|
-
) || "push",
|
|
54
|
+
) || "push", S = e(this, l).hasAttribute("data-center-scroll"), L = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), g = L ? Vt.parse(L) : void 0, v = e(this, l).hasAttribute("data-revalidate"), A = e(this, l).hasAttribute(
|
|
55
55
|
"data-keep-search-parameters"
|
|
56
56
|
), m = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((V) => V.trim());
|
|
57
57
|
e(this, C).navigate(e(this, z), {
|
|
58
58
|
historyAction: u,
|
|
59
|
-
centerScroll:
|
|
60
|
-
offsetScroll:
|
|
59
|
+
centerScroll: S,
|
|
60
|
+
offsetScroll: g,
|
|
61
61
|
revalidate: v,
|
|
62
62
|
keepSearchParameters: A,
|
|
63
63
|
submorph: m
|
|
@@ -243,9 +243,9 @@ const X = class X {
|
|
|
243
243
|
historyAction: s = "push",
|
|
244
244
|
centerScroll: i,
|
|
245
245
|
offsetScroll: u,
|
|
246
|
-
revalidate:
|
|
246
|
+
revalidate: S,
|
|
247
247
|
keepSearchParameters: L,
|
|
248
|
-
submorph:
|
|
248
|
+
submorph: g
|
|
249
249
|
} = {}) {
|
|
250
250
|
var Et;
|
|
251
251
|
if (e(this, O).length)
|
|
@@ -272,7 +272,8 @@ const X = class X {
|
|
|
272
272
|
(y = this.preprocessor) == null || y.call(this, {
|
|
273
273
|
pathname: m,
|
|
274
274
|
resolve: r,
|
|
275
|
-
reject: k
|
|
275
|
+
reject: k,
|
|
276
|
+
submorph: g
|
|
276
277
|
});
|
|
277
278
|
});
|
|
278
279
|
} catch (r) {
|
|
@@ -286,14 +287,14 @@ const X = class X {
|
|
|
286
287
|
}
|
|
287
288
|
const ot = {
|
|
288
289
|
pathname: m,
|
|
289
|
-
submorph:
|
|
290
|
+
submorph: g
|
|
290
291
|
};
|
|
291
292
|
$(document, "morphNavigation", {
|
|
292
293
|
detail: ot
|
|
293
294
|
});
|
|
294
295
|
const gt = yield d(this, h, it).call(this, e(this, p)), b = yield d(this, h, it).call(this, m, {
|
|
295
296
|
searchParameters: pt,
|
|
296
|
-
revalidate:
|
|
297
|
+
revalidate: S
|
|
297
298
|
});
|
|
298
299
|
if (e(this, D) !== m) {
|
|
299
300
|
e(this, f).forEach((r) => {
|
|
@@ -352,14 +353,14 @@ const X = class X {
|
|
|
352
353
|
}), e(this, B).remove(), a(this, _, e(this, p)), a(this, p, m), e(this, Y).forEach((r, k) => {
|
|
353
354
|
const y = Rt[k], Q = getComputedStyle(r).getPropertyValue("--morph-duration");
|
|
354
355
|
let R = [], U = [];
|
|
355
|
-
|
|
356
|
+
g ? g.forEach((c) => {
|
|
356
357
|
const E = r.querySelector(c), H = y.querySelector(c);
|
|
357
358
|
E && H && (U.push(E), R.push(H));
|
|
358
359
|
}) : (R.push(...y.childNodes), U.push(...r.childNodes)), U.forEach((c) => {
|
|
359
360
|
c instanceof HTMLElement && (this.destroyOldLinks(c), c.classList.add("old"));
|
|
360
361
|
}), R.forEach((c) => {
|
|
361
362
|
c instanceof HTMLElement && (this.findNewLinks(c), c.classList.add("new"));
|
|
362
|
-
}),
|
|
363
|
+
}), g ? R.forEach((c, E) => {
|
|
363
364
|
var H;
|
|
364
365
|
(H = U[E].parentElement) == null || H.insertBefore(
|
|
365
366
|
c,
|
|
@@ -446,7 +447,7 @@ T = new WeakMap(), Y = new WeakMap(), f = new WeakMap(), rt = new WeakMap(), D =
|
|
|
446
447
|
return q(this, null, function* () {
|
|
447
448
|
const u = yield (yield fetch(
|
|
448
449
|
`${t}${s ? "?" + s : ""}`
|
|
449
|
-
)).text(),
|
|
450
|
+
)).text(), S = e(this, rt).parseFromString(u, "text/html"), L = new kt(this, t, S);
|
|
450
451
|
return e(this, G).set(t, L), L;
|
|
451
452
|
});
|
|
452
453
|
}, ct = function(t) {
|