aptechka 0.4.18 → 0.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var tt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n);var K=(n,t,e)=>{if(!t.has(n))throw TypeError("Cannot "+e)};var i=(n,t,e)=>(K(n,t,"read from private field"),e?e.call(n):t.get(n)),o=(n,t,e)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,e)},
|
|
1
|
+
"use strict";var tt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n);var K=(n,t,e)=>{if(!t.has(n))throw TypeError("Cannot "+e)};var i=(n,t,e)=>(K(n,t,"read from private field"),e?e.call(n):t.get(n)),o=(n,t,e)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,e)},a=(n,t,e,r)=>(K(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e);var m=(n,t,e)=>(K(n,t,"access private method"),e);var T=(n,t,e)=>new Promise((r,s)=>{var c=u=>{try{d(e.next(u))}catch(f){s(f)}},L=u=>{try{d(e.throw(u))}catch(f){s(f)}},d=u=>u.done?r(u.value):Promise.resolve(u.value).then(c,L);d((e=e.apply(n,t)).next())});var et=(n,t,e)=>(t=n[tt("asyncIterator")])?t.call(n):(n=n[tt("iterator")](),t={},e=(r,s)=>(s=n[r])&&(t[r]=c=>new Promise((L,d,u)=>(c=s.call(n,c),u=c.done,Promise.resolve(c.value).then(f=>L({value:f,done:u}),d)))),e("next"),e("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const it=require("../notifier/index.cjs"),ct=require("../browser-CpzFX2xg.cjs");require("../path-data-polyfill-CXsOR7Oc.cjs");var y,l,w,H,S,P;class lt{constructor(t,e){o(this,y,void 0);o(this,l,void 0);o(this,w,void 0);o(this,H,void 0);o(this,S,t=>{t.preventDefault(),i(this,y).navigate(i(this,w),i(this,H))});o(this,P,()=>{i(this,y).prefetch(i(this,w)),i(this,l).removeEventListener("pointerenter",i(this,P))});a(this,y,e),a(this,l,t),a(this,w,i(this,l).getAttribute("href")||"/"),a(this,H,i(this,l).getAttribute("data-history-action")||"push"),i(this,l).addEventListener("click",i(this,S));const r=e.normalizePath(i(this,w)),s=e.normalizePath(location.pathname);i(this,l).hasAttribute("data-include")?s.pathname.includes(r.pathname)&&i(this,l).classList.add("current"):r.pathname===s.pathname&&i(this,l).classList.add("current"),i(this,l).hasAttribute("data-prefetch")&&i(this,l).addEventListener("pointerenter",i(this,P))}destroy(){i(this,l).removeEventListener("click",i(this,S)),i(this,l).removeEventListener("pointerenter",i(this,P)),i(this,l).classList.remove("current")}}y=new WeakMap,l=new WeakMap,w=new WeakMap,H=new WeakMap,S=new WeakMap,P=new WeakMap;var g,N,A,C,k,O,b,E,M,W,x,q,Y,z,_,D,G,$,st,R,J,j;class ut{constructor(t){o(this,q);o(this,z);o(this,D);o(this,$);o(this,R);o(this,g,null);o(this,N,null);o(this,A,null);o(this,C,null);o(this,k,[]);o(this,O,new DOMParser);o(this,b,new Map);o(this,E,void 0);o(this,M,null);o(this,W,new it.Notifier);o(this,x,new it.Notifier);o(this,j,t=>{t.state&&this.navigate(t.state,"none")});ct.isBrowser&&(a(this,g,(t==null?void 0:t.base)||"/"),t!=null&&t.base?(a(this,g,t.base),t.base.endsWith("/")||a(this,g,i(this,g)+"/")):a(this,g,"/"),a(this,N,(t==null?void 0:t.waitForHeadToLoad)!==!1),a(this,A,(t==null?void 0:t.cachePages)!==!1),a(this,C,m(this,D,G).call(this,document)),a(this,M,location.pathname),m(this,z,_).call(this),addEventListener("popstate",i(this,j)))}normalizePath(t){t=t.replace(i(this,g),""),t.startsWith("/")&&(t=t.slice(1));const e=t.split("#"),r=e[0].split("?"),s=r[0].endsWith("/")?r[0].slice(0,-1):r[0],c=i(this,g)+s,L=r==null?void 0:r[1],d=e==null?void 0:e[1];return{leaf:s,pathname:c,parameters:L,hash:d}}beforeNavigationEvent(t){return i(this,W).subscribe(t)}afterNavigationEvent(t){return i(this,x).subscribe(t)}prefetch(t){return T(this,null,function*(){const e=this.normalizePath(t);return m(this,q,Y).call(this,e.pathname)})}navigate(t,e="push"){return T(this,null,function*(){var u;const r=this.normalizePath(t);let{pathname:s,hash:c,parameters:L}=r;if(i(this,E)===s||i(this,M)===s)return;a(this,E,s);const d=i(this,b).has(s);try{let f=!0;if(i(this,W).notify({pathname:s,isCached:d}),this.preprocessor)try{yield new Promise((h,p)=>{var v;(v=this.preprocessor)==null||v.call(this,{pathname:s,resolve:h,reject:p,isCached:d})})}catch(h){h?console.error(h):console.log("Route change canceled"),f=!1}if(!f||i(this,E)!==s)return;const Q=i(this,b).get(s)||(yield m(this,q,Y).call(this,s));if(i(this,E)!==s)return;const U=Array.from(document.head.children),V=Array.from(Q.head.cloneNode(!0).children),X=m(this,$,st).call(this,U,V),nt=m(this,R,J).call(this,U,X),F=m(this,R,J).call(this,V,X);nt.forEach(h=>{h.remove()}),F.forEach((h,p)=>{if(h.tagName==="SCRIPT"&&h.getAttribute("src")){const v=document.createElement("script");v.type="module",v.src=h.getAttribute("src"),F[p]=v}}),F.forEach((h,p)=>{document.head.appendChild(h)});const B=F.filter(h=>h.tagName==="STYLE"||h.tagName==="SCRIPT"||h.tagName==="LINK");i(this,N)&&B.length&&(yield new Promise(h=>T(this,null,function*(){let p=0;try{for(var v=et(B),mt,pt,gt;mt=!(pt=yield v.next()).done;mt=!1){const at=pt.value;at.onload=()=>{p++,p===B.length&&h()}}}catch(pt){gt=[pt]}finally{try{mt&&(pt=v.return)&&(yield pt.call(v))}finally{if(gt)throw gt[0]}}}))),a(this,M,s);const I=L||location.search,rt=c?c.startsWith("#")?c:"#"+c:"",ot=I?I.startsWith("?")?I:"?"+I:"",Z=`${s}${rt}${ot}`;e==="push"?history.pushState(s,"",Z):e==="replace"&&history.replaceState(s,"",Z);const ht=m(this,D,G).call(this,Q);i(this,C).forEach((h,p)=>{const v=ht[p];h.innerHTML=v.innerHTML}),m(this,z,_).call(this),(u=this.postprocessor)==null||u.call(this,{pathname:s,isCached:d}),i(this,x).notify({pathname:s,isCached:d})}catch(f){console.error(f)}a(this,E,void 0)})}}g=new WeakMap,N=new WeakMap,A=new WeakMap,C=new WeakMap,k=new WeakMap,O=new WeakMap,b=new WeakMap,E=new WeakMap,M=new WeakMap,W=new WeakMap,x=new WeakMap,q=new WeakSet,Y=function(t){return T(this,null,function*(){const e=i(this,b).get(t);if(e)return e;const s=yield(yield fetch(t)).text(),c=i(this,O).parseFromString(s,"text/html");return i(this,A)&&i(this,b).set(t,c),c})},z=new WeakSet,_=function(){const t=[...document.documentElement.querySelectorAll("a")].filter(e=>{var r;return(r=e.getAttribute("href"))==null?void 0:r.startsWith("/")});i(this,k).forEach(e=>e.destroy()),a(this,k,t.map(e=>new lt(e,this)))},D=new WeakSet,G=function(t){const e=t.querySelectorAll("[data-morph]");return e.length?[...e]:[t.body]},$=new WeakSet,st=function(t,e){return t.filter(r=>e.find(s=>s.outerHTML===r.outerHTML))},R=new WeakSet,J=function(t,e){return t.filter(r=>!e.find(s=>s.outerHTML===r.outerHTML))},j=new WeakMap;exports.Morph=ut;
|
package/lib/morph/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var Y = (n, t, e) => {
|
|
|
3
3
|
if (!t.has(n))
|
|
4
4
|
throw TypeError("Cannot " + e);
|
|
5
5
|
};
|
|
6
|
-
var s = (n, t, e) => (Y(n, t, "read from private field"), e ? e.call(n) : t.get(n)),
|
|
6
|
+
var s = (n, t, e) => (Y(n, t, "read from private field"), e ? e.call(n) : t.get(n)), h = (n, t, e) => {
|
|
7
7
|
if (t.has(n))
|
|
8
8
|
throw TypeError("Cannot add the same private member more than once");
|
|
9
9
|
t instanceof WeakSet ? t.add(n) : t.set(n, e);
|
|
@@ -12,79 +12,79 @@ var m = (n, t, e) => (Y(n, t, "access private method"), e);
|
|
|
12
12
|
var T = (n, t, e) => new Promise((o, i) => {
|
|
13
13
|
var c = (u) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
i(
|
|
15
|
+
d(e.next(u));
|
|
16
|
+
} catch (f) {
|
|
17
|
+
i(f);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
19
|
+
}, v = (u) => {
|
|
20
20
|
try {
|
|
21
|
-
|
|
22
|
-
} catch (
|
|
23
|
-
i(
|
|
21
|
+
d(e.throw(u));
|
|
22
|
+
} catch (f) {
|
|
23
|
+
i(f);
|
|
24
24
|
}
|
|
25
|
-
},
|
|
26
|
-
|
|
25
|
+
}, d = (u) => u.done ? o(u.value) : Promise.resolve(u.value).then(c, v);
|
|
26
|
+
d((e = e.apply(n, t)).next());
|
|
27
27
|
});
|
|
28
|
-
var et = (n, t, e) => (t = n[tt("asyncIterator")]) ? t.call(n) : (n = n[tt("iterator")](), t = {}, e = (o, i) => (i = n[o]) && (t[o] = (c) => new Promise((
|
|
28
|
+
var et = (n, t, e) => (t = n[tt("asyncIterator")]) ? t.call(n) : (n = n[tt("iterator")](), t = {}, e = (o, i) => (i = n[o]) && (t[o] = (c) => new Promise((v, d, u) => (c = i.call(n, c), u = c.done, Promise.resolve(c.value).then((f) => v({ value: f, done: u }), d)))), e("next"), e("return"), t);
|
|
29
29
|
import { Notifier as st } from "../notifier/index.js";
|
|
30
30
|
import { i as ct } from "../browser-0zX67oeU.js";
|
|
31
31
|
import "../path-data-polyfill-DgeDWYeI.js";
|
|
32
|
-
var
|
|
32
|
+
var y, l, w, M, A, P;
|
|
33
33
|
class lt {
|
|
34
34
|
constructor(t, e) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
t.preventDefault(), s(this,
|
|
35
|
+
h(this, y, void 0);
|
|
36
|
+
h(this, l, void 0);
|
|
37
|
+
h(this, w, void 0);
|
|
38
|
+
h(this, M, void 0);
|
|
39
|
+
h(this, A, (t) => {
|
|
40
|
+
t.preventDefault(), s(this, y).navigate(s(this, w), s(this, M));
|
|
41
41
|
});
|
|
42
|
-
|
|
43
|
-
s(this,
|
|
42
|
+
h(this, P, () => {
|
|
43
|
+
s(this, y).prefetch(s(this, w)), s(this, l).removeEventListener("pointerenter", s(this, P));
|
|
44
44
|
});
|
|
45
|
-
a(this,
|
|
45
|
+
a(this, y, e), a(this, l, t), a(this, w, s(this, l).getAttribute("href") || "/"), a(this, M, s(this, l).getAttribute(
|
|
46
46
|
"data-history-action"
|
|
47
|
-
) || "push"), s(this, l).addEventListener("click", s(this,
|
|
47
|
+
) || "push"), s(this, l).addEventListener("click", s(this, A));
|
|
48
48
|
const o = e.normalizePath(s(this, w)), i = e.normalizePath(location.pathname);
|
|
49
|
-
o.pathname === i.pathname && s(this, l).classList.add("current"), s(this, l).hasAttribute("data-prefetch") && s(this, l).addEventListener("pointerenter", s(this, P));
|
|
49
|
+
s(this, l).hasAttribute("data-include") ? i.pathname.includes(o.pathname) && s(this, l).classList.add("current") : o.pathname === i.pathname && s(this, l).classList.add("current"), s(this, l).hasAttribute("data-prefetch") && s(this, l).addEventListener("pointerenter", s(this, P));
|
|
50
50
|
}
|
|
51
51
|
destroy() {
|
|
52
|
-
s(this, l).removeEventListener("click", s(this,
|
|
52
|
+
s(this, l).removeEventListener("click", s(this, A)), s(this, l).removeEventListener("pointerenter", s(this, P)), s(this, l).classList.remove("current");
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
var g,
|
|
55
|
+
y = new WeakMap(), l = new WeakMap(), w = new WeakMap(), M = new WeakMap(), A = new WeakMap(), P = new WeakMap();
|
|
56
|
+
var g, N, S, C, k, q, b, L, H, W, x, z, j, D, G, R, J, O, it, F, Q, B;
|
|
57
57
|
class pt {
|
|
58
58
|
constructor(t) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
h(this, z);
|
|
60
|
+
h(this, D);
|
|
61
|
+
h(this, R);
|
|
62
|
+
h(this, O);
|
|
63
|
+
h(this, F);
|
|
64
|
+
h(this, g, null);
|
|
65
|
+
h(this, N, null);
|
|
66
|
+
h(this, S, null);
|
|
67
|
+
h(this, C, null);
|
|
68
|
+
h(this, k, []);
|
|
69
|
+
h(this, q, new DOMParser());
|
|
70
|
+
h(this, b, /* @__PURE__ */ new Map());
|
|
71
|
+
h(this, L, void 0);
|
|
72
|
+
h(this, H, null);
|
|
73
|
+
h(this, W, new st());
|
|
74
|
+
h(this, x, new st());
|
|
75
|
+
h(this, B, (t) => {
|
|
76
76
|
t.state && this.navigate(t.state, "none");
|
|
77
77
|
});
|
|
78
|
-
ct && (a(this, g, (t == null ? void 0 : t.base) || "/"), t != null && t.base ? (a(this, g, t.base), t.base.endsWith("/") || a(this, g, s(this, g) + "/")) : a(this, g, "/"), a(this,
|
|
78
|
+
ct && (a(this, g, (t == null ? void 0 : t.base) || "/"), t != null && t.base ? (a(this, g, t.base), t.base.endsWith("/") || a(this, g, s(this, g) + "/")) : a(this, g, "/"), a(this, N, (t == null ? void 0 : t.waitForHeadToLoad) !== !1), a(this, S, (t == null ? void 0 : t.cachePages) !== !1), a(this, C, m(this, R, J).call(this, document)), a(this, H, location.pathname), m(this, D, G).call(this), addEventListener("popstate", s(this, B)));
|
|
79
79
|
}
|
|
80
80
|
normalizePath(t) {
|
|
81
81
|
t = t.replace(s(this, g), ""), t.startsWith("/") && (t = t.slice(1));
|
|
82
|
-
const e = t.split("#"), o = e[0].split("?"), i = o[0].endsWith("/") ? o[0].slice(0, -1) : o[0], c = s(this, g) + i,
|
|
82
|
+
const e = t.split("#"), o = e[0].split("?"), i = o[0].endsWith("/") ? o[0].slice(0, -1) : o[0], c = s(this, g) + i, v = o == null ? void 0 : o[1], d = e == null ? void 0 : e[1];
|
|
83
83
|
return {
|
|
84
84
|
leaf: i,
|
|
85
85
|
pathname: c,
|
|
86
|
-
parameters:
|
|
87
|
-
hash:
|
|
86
|
+
parameters: v,
|
|
87
|
+
hash: d
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
beforeNavigationEvent(t) {
|
|
@@ -103,87 +103,87 @@ class pt {
|
|
|
103
103
|
return T(this, null, function* () {
|
|
104
104
|
var u;
|
|
105
105
|
const o = this.normalizePath(t);
|
|
106
|
-
let { pathname: i, hash: c, parameters:
|
|
107
|
-
if (s(this,
|
|
106
|
+
let { pathname: i, hash: c, parameters: v } = o;
|
|
107
|
+
if (s(this, L) === i || s(this, H) === i)
|
|
108
108
|
return;
|
|
109
|
-
a(this,
|
|
110
|
-
const
|
|
109
|
+
a(this, L, i);
|
|
110
|
+
const d = s(this, b).has(i);
|
|
111
111
|
try {
|
|
112
|
-
let
|
|
112
|
+
let f = !0;
|
|
113
113
|
if (s(this, W).notify({
|
|
114
114
|
pathname: i,
|
|
115
|
-
isCached:
|
|
115
|
+
isCached: d
|
|
116
116
|
}), this.preprocessor)
|
|
117
117
|
try {
|
|
118
|
-
yield new Promise((
|
|
118
|
+
yield new Promise((r, p) => {
|
|
119
119
|
var E;
|
|
120
|
-
(E = this.preprocessor) == null || E.call(this, { pathname: i, resolve:
|
|
120
|
+
(E = this.preprocessor) == null || E.call(this, { pathname: i, resolve: r, reject: p, isCached: d });
|
|
121
121
|
});
|
|
122
|
-
} catch (
|
|
123
|
-
|
|
122
|
+
} catch (r) {
|
|
123
|
+
r ? console.error(r) : console.log("Route change canceled"), f = !1;
|
|
124
124
|
}
|
|
125
|
-
if (!
|
|
125
|
+
if (!f || s(this, L) !== i)
|
|
126
126
|
return;
|
|
127
|
-
const U = s(this,
|
|
128
|
-
if (s(this,
|
|
127
|
+
const U = s(this, b).get(i) || (yield m(this, z, j).call(this, i));
|
|
128
|
+
if (s(this, L) !== i)
|
|
129
129
|
return;
|
|
130
130
|
const V = Array.from(document.head.children), X = Array.from(
|
|
131
131
|
U.head.cloneNode(!0).children
|
|
132
132
|
), Z = m(this, O, it).call(this, V, X), nt = m(this, F, Q).call(this, V, Z), I = m(this, F, Q).call(this, X, Z);
|
|
133
|
-
nt.forEach((
|
|
134
|
-
|
|
135
|
-
}), I.forEach((
|
|
136
|
-
if (
|
|
133
|
+
nt.forEach((r) => {
|
|
134
|
+
r.remove();
|
|
135
|
+
}), I.forEach((r, p) => {
|
|
136
|
+
if (r.tagName === "SCRIPT" && r.getAttribute("src")) {
|
|
137
137
|
const E = document.createElement("script");
|
|
138
|
-
E.type = "module", E.src =
|
|
138
|
+
E.type = "module", E.src = r.getAttribute("src"), I[p] = E;
|
|
139
139
|
}
|
|
140
|
-
}), I.forEach((
|
|
141
|
-
document.head.appendChild(
|
|
140
|
+
}), I.forEach((r, p) => {
|
|
141
|
+
document.head.appendChild(r);
|
|
142
142
|
});
|
|
143
143
|
const K = I.filter(
|
|
144
|
-
(
|
|
144
|
+
(r) => r.tagName === "STYLE" || r.tagName === "SCRIPT" || r.tagName === "LINK"
|
|
145
145
|
);
|
|
146
|
-
s(this,
|
|
146
|
+
s(this, N) && K.length && (yield new Promise((r) => T(this, null, function* () {
|
|
147
147
|
let p = 0;
|
|
148
148
|
try {
|
|
149
|
-
for (var E = et(K),
|
|
150
|
-
const at =
|
|
149
|
+
for (var E = et(K), Lt, vt, wt; Lt = !(vt = yield E.next()).done; Lt = !1) {
|
|
150
|
+
const at = vt.value;
|
|
151
151
|
at.onload = () => {
|
|
152
|
-
p++, p === K.length &&
|
|
152
|
+
p++, p === K.length && r();
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
} catch (
|
|
156
|
-
wt = [
|
|
155
|
+
} catch (vt) {
|
|
156
|
+
wt = [vt];
|
|
157
157
|
} finally {
|
|
158
158
|
try {
|
|
159
|
-
|
|
159
|
+
Lt && (vt = E.return) && (yield vt.call(E));
|
|
160
160
|
} finally {
|
|
161
161
|
if (wt)
|
|
162
162
|
throw wt[0];
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
}))), a(this, H, i);
|
|
166
|
-
const $ =
|
|
166
|
+
const $ = v || location.search, ot = c ? c.startsWith("#") ? c : "#" + c : "", ht = $ ? $.startsWith("?") ? $ : "?" + $ : "", _ = `${i}${ot}${ht}`;
|
|
167
167
|
e === "push" ? history.pushState(i, "", _) : e === "replace" && history.replaceState(i, "", _);
|
|
168
|
-
const
|
|
169
|
-
s(this, C).forEach((
|
|
170
|
-
const E =
|
|
171
|
-
|
|
172
|
-
}), m(this, D, G).call(this), (u = this.postprocessor) == null || u.call(this, { pathname: i, isCached:
|
|
173
|
-
} catch (
|
|
174
|
-
console.error(
|
|
168
|
+
const rt = m(this, R, J).call(this, U);
|
|
169
|
+
s(this, C).forEach((r, p) => {
|
|
170
|
+
const E = rt[p];
|
|
171
|
+
r.innerHTML = E.innerHTML;
|
|
172
|
+
}), m(this, D, G).call(this), (u = this.postprocessor) == null || u.call(this, { pathname: i, isCached: d }), s(this, x).notify({ pathname: i, isCached: d });
|
|
173
|
+
} catch (f) {
|
|
174
|
+
console.error(f);
|
|
175
175
|
}
|
|
176
|
-
a(this,
|
|
176
|
+
a(this, L, void 0);
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
g = new WeakMap(),
|
|
180
|
+
g = new WeakMap(), N = new WeakMap(), S = new WeakMap(), C = new WeakMap(), k = new WeakMap(), q = new WeakMap(), b = new WeakMap(), L = new WeakMap(), H = new WeakMap(), W = new WeakMap(), x = new WeakMap(), z = new WeakSet(), j = function(t) {
|
|
181
181
|
return T(this, null, function* () {
|
|
182
|
-
const e = s(this,
|
|
182
|
+
const e = s(this, b).get(t);
|
|
183
183
|
if (e)
|
|
184
184
|
return e;
|
|
185
185
|
const i = yield (yield fetch(t)).text(), c = s(this, q).parseFromString(i, "text/html");
|
|
186
|
-
return s(this,
|
|
186
|
+
return s(this, S) && s(this, b).set(t, c), c;
|
|
187
187
|
});
|
|
188
188
|
}, D = new WeakSet(), G = function() {
|
|
189
189
|
const t = [
|
|
@@ -7,6 +7,7 @@ export declare class PopoverButtonElement extends CustomElement {
|
|
|
7
7
|
constructor();
|
|
8
8
|
get popoverElement(): PopoverElement | undefined;
|
|
9
9
|
protected connectedCallback(): void;
|
|
10
|
+
protected disconnectedCallback(): void;
|
|
10
11
|
}
|
|
11
12
|
declare global {
|
|
12
13
|
interface HTMLElementTagNameMap {
|
|
@@ -17,4 +17,10 @@ declare global {
|
|
|
17
17
|
interface HTMLElementTagNameMap {
|
|
18
18
|
'e-popover': PopoverElement;
|
|
19
19
|
}
|
|
20
|
+
interface HTMLElementEventMap {
|
|
21
|
+
popoverTriggered: CustomEvent;
|
|
22
|
+
popoverOpened: CustomEvent;
|
|
23
|
+
popoverClosing: CustomEvent;
|
|
24
|
+
popoverClosed: CustomEvent;
|
|
25
|
+
}
|
|
20
26
|
}
|
package/lib/popover/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../attribute/index.cjs"),W=require("../custom-element/index.cjs"),I=require("../Store-BQGNOHlY.cjs"),N=require("../style-At6aDoqG.cjs");require("../path-data-polyfill-CXsOR7Oc.cjs");const G=require("../browser-CpzFX2xg.cjs"),T=require("../tags-CueX-JLX.cjs"),H=require("../createStylesheet-C8aQQ4hd.cjs");var R=Object.defineProperty,U=Object.getOwnPropertyDescriptor,z=(t,e,s,n)=>{for(var a=n>1?void 0:n?U(e,s):e,c=t.length-1,d;c>=0;c--)(d=t[c])&&(a=(n?d(e,s,a):d(a))||a);return n&&a&&R(e,s,a),a},A=(t,e,s)=>{if(!e.has(t))throw TypeError("Cannot "+s)},i=(t,e,s)=>(A(t,e,"read from private field"),s?s.call(t):e.get(t)),h=(t,e,s)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,s)},O=(t,e,s,n)=>(A(t,e,"write to private field"),n?n.call(t,s):e.set(t,s),s),x=(t,e,s)=>(A(t,e,"access private method"),s),M,p,g,l,v,f,$,B,u,m,w,y,L,q,E;exports.PopoverElement=class extends W.CustomElement{constructor(){super(...arguments),h(this,$),h(this,u),h(this,L),h(this,M,-1),h(this,p,new I.Store(!1)),h(this,g,void 0),h(this,l,new b.Attribute(this,"history",!1)),h(this,v,new b.Attribute(this,"single",!1)),h(this,f,!1),this.open=()=>{i(this,p).current||(i(this,p).current=!0,i(this,v).current&&(exports.PopoverElement.__opened.forEach(e=>e.close()),exports.PopoverElement.__opened=[]),exports.PopoverElement.__opened.push(this),O(this,M,exports.PopoverElement.__opened.length-1),i(this,l).current&&i(this,f)&&history.pushState("","",i(this,$,B)),clearTimeout(i(this,g)),this.classList.add("triggered"),this.style.display="block",this.dispatchEvent(new CustomEvent("popoverTriggered")),setTimeout(()=>{addEventListener("click",i(this,w)),addEventListener("keydown",i(this,y)),this.style.opacity="1",this.classList.add("opened"),this.dispatchEvent(new CustomEvent("popoverOpened"))}))},this.close=()=>{if(i(this,p).current){if(i(this,p).current=!1,exports.PopoverElement.__opened=exports.PopoverElement.__opened.filter(e=>e!==this),i(this,l).current){const e=new URL(location.href);e.searchParams.delete(i(this,u,m)),history.replaceState(null,"",e.href)}this.classList.remove("opened"),this.style.opacity="0",this.dispatchEvent(new CustomEvent("popoverClosing")),removeEventListener("click",i(this,w)),removeEventListener("keydown",i(this,y)),setTimeout(()=>{this.classList.remove("triggered"),this.style.display="none",this.dispatchEvent(new CustomEvent("popoverClosed"))},N.getElementTransitionDurationMS(this))}},h(this,w,e=>{x(this,L,q).call(this,()=>{const s=e.composedPath();(!s.find(n=>n===this)&&!s.find(n=>n instanceof HTMLElement&&n.closest("e-popover-button"))||s[0]instanceof HTMLElement&&s[0].hasAttribute("outside"))&&this.close()})}),h(this,y,e=>{x(this,L,q).call(this,()=>{e.code==="Escape"&&this.close()})}),h(this,E,()=>{O(this,f,!1),i(this,p).current&&i(this,l).current&&!location.search.includes(i(this,u,m))?this.close():!i(this,p).current&&i(this,l).current&&location.search.includes(i(this,u,m))&&this.open(),O(this,f,!0)})}get history(){return i(this,l)}get single(){return i(this,v)}get opened(){return i(this,p)}connectedCallback(){i(this,l).observe(),i(this,v).observe(),this.style.opacity="0",this.style.display="none",addEventListener("popstate",i(this,E)),setTimeout(()=>{i(this,E).call(this)},0)}disconnectedCallback(){i(this,l).unobserve(),i(this,v).unobserve(),clearTimeout(i(this,g)),removeEventListener("popstate",i(this,E))}};M=new WeakMap;p=new WeakMap;g=new WeakMap;l=new WeakMap;v=new WeakMap;f=new WeakMap;$=new WeakSet;B=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${i(this,u,m)}`};u=new WeakSet;m=function(){return`modal-${this.id}`};w=new WeakMap;y=new WeakMap;L=new WeakSet;q=function(t){(exports.PopoverElement.__opened[i(this,M)-1]||exports.PopoverElement.__opened.length===1)&&t()};E=new WeakMap;exports.PopoverElement.__opened=[];exports.PopoverElement=z([W.define("e-popover")],exports.PopoverElement);var F=Object.defineProperty,J=Object.getOwnPropertyDescriptor,K=(t,e,s,n)=>{for(var a=n>1?void 0:n?J(e,s):e,c=t.length-1,d;c>=0;c--)(d=t[c])&&(a=(n?d(e,s,a):d(a))||a);return n&&a&&F(e,s,a),a},D=(t,e,s)=>{if(!e.has(t))throw TypeError("Cannot "+s)},r=(t,e,s)=>(D(t,e,"read from private field"),s?s.call(t):e.get(t)),_=(t,e,s)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,s)},Q=(t,e,s,n)=>(D(t,e,"write to private field"),n?n.call(t,s):e.set(t,s),s),o,P,C,k,S;const V=H.createStylesheet({button:{all:"inherit"}});exports.PopoverButtonElement=class extends W.CustomElement{constructor(){super(),_(this,o,void 0),_(this,P,()=>{this.classList.add("triggered")}),_(this,C,()=>{this.classList.add("opened")}),_(this,k,()=>{this.classList.remove("opened")}),_(this,S,()=>{this.classList.remove("triggered")}),this.openShadow(V),G.isBrowser&&T.element(this,{children:[T.button({onClick:()=>{if(r(this,o)){const e=this.getAttribute("type")||"open";e==="open"||e==="toggle"&&!r(this,o).opened.current?r(this,o).open():(e==="close"||e==="toggle"&&r(this,o).opened.current)&&r(this,o).close()}},children:[T.slot()]})]})}get popoverElement(){return r(this,o)}connectedCallback(){const e=this.getAttribute("target");if(e){const s=document.querySelector(`#${e}`)||this.getRootNode().querySelector(`#${e}`);s?(Q(this,o,s),r(this,o).addEventListener("popoverTriggered",r(this,P)),r(this,o).addEventListener("popoverOpened",r(this,C)),r(this,o).addEventListener("popoverClosing",r(this,k)),r(this,o).addEventListener("popoverClosed",r(this,S))):console.warn(this,`target ${e} not found`)}}disconnectedCallback(){r(this,o)&&(r(this,o).removeEventListener("popoverTriggered",r(this,P)),r(this,o).removeEventListener("popoverOpened",r(this,C)),r(this,o).removeEventListener("popoverClosing",r(this,k)),r(this,o).removeEventListener("popoverClosed",r(this,S)))}};o=new WeakMap;P=new WeakMap;C=new WeakMap;k=new WeakMap;S=new WeakMap;exports.PopoverButtonElement=K([W.define("e-popover-button")],exports.PopoverButtonElement);
|
package/lib/popover/index.js
CHANGED
|
@@ -1,146 +1,185 @@
|
|
|
1
|
-
import { Attribute as
|
|
2
|
-
import { CustomElement as
|
|
3
|
-
import { S as
|
|
4
|
-
import { g as
|
|
1
|
+
import { Attribute as D } from "../attribute/index.js";
|
|
2
|
+
import { CustomElement as N, define as q } from "../custom-element/index.js";
|
|
3
|
+
import { S as H } from "../Store-Cd-E5W1z.js";
|
|
4
|
+
import { g as R } from "../style-j2TwriJ_.js";
|
|
5
5
|
import "../path-data-polyfill-DgeDWYeI.js";
|
|
6
|
-
import { i as
|
|
7
|
-
import { e as
|
|
8
|
-
import { c as
|
|
9
|
-
var
|
|
10
|
-
for (var
|
|
11
|
-
(
|
|
12
|
-
return
|
|
13
|
-
},
|
|
6
|
+
import { i as b } from "../browser-0zX67oeU.js";
|
|
7
|
+
import { e as U, p as z, ay as F } from "../tags-BoPv9fDr.js";
|
|
8
|
+
import { c as J } from "../createStylesheet-KMRQhSa-.js";
|
|
9
|
+
var K = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, V = (e, t, s, o) => {
|
|
10
|
+
for (var a = o > 1 ? void 0 : o ? Q(t, s) : t, d = e.length - 1, v; d >= 0; d--)
|
|
11
|
+
(v = e[d]) && (a = (o ? v(t, s, a) : v(a)) || a);
|
|
12
|
+
return o && a && K(t, s, a), a;
|
|
13
|
+
}, A = (e, t, s) => {
|
|
14
14
|
if (!t.has(e))
|
|
15
15
|
throw TypeError("Cannot " + s);
|
|
16
|
-
}, i = (e, t, s) => (
|
|
16
|
+
}, i = (e, t, s) => (A(e, t, "read from private field"), s ? s.call(e) : t.get(e)), h = (e, t, s) => {
|
|
17
17
|
if (t.has(e))
|
|
18
18
|
throw TypeError("Cannot add the same private member more than once");
|
|
19
19
|
t instanceof WeakSet ? t.add(e) : t.set(e, s);
|
|
20
|
-
},
|
|
21
|
-
let
|
|
20
|
+
}, O = (e, t, s, o) => (A(e, t, "write to private field"), o ? o.call(e, s) : t.set(e, s), s), x = (e, t, s) => (A(e, t, "access private method"), s), T, c, E, l, u, m, $, B, _, w, y, L, C, P, g;
|
|
21
|
+
let p = class extends N {
|
|
22
22
|
constructor() {
|
|
23
|
-
super(...arguments),
|
|
24
|
-
i(this,
|
|
25
|
-
addEventListener("click", i(this,
|
|
23
|
+
super(...arguments), h(this, $), h(this, _), h(this, C), h(this, T, -1), h(this, c, new H(!1)), h(this, E, void 0), h(this, l, new D(this, "history", !1)), h(this, u, new D(this, "single", !1)), h(this, m, !1), this.open = () => {
|
|
24
|
+
i(this, c).current || (i(this, c).current = !0, i(this, u).current && (p.__opened.forEach((e) => e.close()), p.__opened = []), p.__opened.push(this), O(this, T, p.__opened.length - 1), i(this, l).current && i(this, m) && history.pushState("", "", i(this, $, B)), clearTimeout(i(this, E)), this.classList.add("triggered"), this.style.display = "block", this.dispatchEvent(new CustomEvent("popoverTriggered")), setTimeout(() => {
|
|
25
|
+
addEventListener("click", i(this, y)), addEventListener("keydown", i(this, L)), this.style.opacity = "1", this.classList.add("opened"), this.dispatchEvent(new CustomEvent("popoverOpened"));
|
|
26
26
|
}));
|
|
27
27
|
}, this.close = () => {
|
|
28
|
-
if (i(this,
|
|
29
|
-
if (i(this,
|
|
28
|
+
if (i(this, c).current) {
|
|
29
|
+
if (i(this, c).current = !1, p.__opened = p.__opened.filter((e) => e !== this), i(this, l).current) {
|
|
30
30
|
const e = new URL(location.href);
|
|
31
31
|
e.searchParams.delete(i(this, _, w)), history.replaceState(null, "", e.href);
|
|
32
32
|
}
|
|
33
|
-
this.classList.remove("opened"), this.style.opacity = "0", removeEventListener("click", i(this,
|
|
34
|
-
this.classList.remove("triggered"), this.style.display = "none";
|
|
35
|
-
},
|
|
33
|
+
this.classList.remove("opened"), this.style.opacity = "0", this.dispatchEvent(new CustomEvent("popoverClosing")), removeEventListener("click", i(this, y)), removeEventListener("keydown", i(this, L)), setTimeout(() => {
|
|
34
|
+
this.classList.remove("triggered"), this.style.display = "none", this.dispatchEvent(new CustomEvent("popoverClosed"));
|
|
35
|
+
}, R(this));
|
|
36
36
|
}
|
|
37
|
-
},
|
|
38
|
-
|
|
37
|
+
}, h(this, y, (e) => {
|
|
38
|
+
x(this, C, P).call(this, () => {
|
|
39
39
|
const t = e.composedPath();
|
|
40
40
|
(!t.find((s) => s === this) && !t.find(
|
|
41
41
|
(s) => s instanceof HTMLElement && s.closest("e-popover-button")
|
|
42
42
|
) || t[0] instanceof HTMLElement && t[0].hasAttribute("outside")) && this.close();
|
|
43
43
|
});
|
|
44
|
-
}),
|
|
45
|
-
|
|
44
|
+
}), h(this, L, (e) => {
|
|
45
|
+
x(this, C, P).call(this, () => {
|
|
46
46
|
e.code === "Escape" && this.close();
|
|
47
47
|
});
|
|
48
|
-
}),
|
|
49
|
-
|
|
48
|
+
}), h(this, g, () => {
|
|
49
|
+
O(this, m, !1), i(this, c).current && i(this, l).current && !location.search.includes(i(this, _, w)) ? this.close() : !i(this, c).current && i(this, l).current && location.search.includes(i(this, _, w)) && this.open(), O(this, m, !0);
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
get history() {
|
|
53
|
-
return i(this,
|
|
53
|
+
return i(this, l);
|
|
54
54
|
}
|
|
55
55
|
get single() {
|
|
56
|
-
return i(this,
|
|
56
|
+
return i(this, u);
|
|
57
57
|
}
|
|
58
58
|
get opened() {
|
|
59
|
-
return i(this,
|
|
59
|
+
return i(this, c);
|
|
60
60
|
}
|
|
61
61
|
connectedCallback() {
|
|
62
|
-
i(this,
|
|
63
|
-
i(this,
|
|
62
|
+
i(this, l).observe(), i(this, u).observe(), this.style.opacity = "0", this.style.display = "none", addEventListener("popstate", i(this, g)), setTimeout(() => {
|
|
63
|
+
i(this, g).call(this);
|
|
64
64
|
}, 0);
|
|
65
65
|
}
|
|
66
66
|
disconnectedCallback() {
|
|
67
|
-
i(this,
|
|
67
|
+
i(this, l).unobserve(), i(this, u).unobserve(), clearTimeout(i(this, E)), removeEventListener("popstate", i(this, g));
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
-
|
|
71
|
-
h = /* @__PURE__ */ new WeakMap();
|
|
72
|
-
y = /* @__PURE__ */ new WeakMap();
|
|
70
|
+
T = /* @__PURE__ */ new WeakMap();
|
|
73
71
|
c = /* @__PURE__ */ new WeakMap();
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
E = /* @__PURE__ */ new WeakMap();
|
|
73
|
+
l = /* @__PURE__ */ new WeakMap();
|
|
74
|
+
u = /* @__PURE__ */ new WeakMap();
|
|
75
|
+
m = /* @__PURE__ */ new WeakMap();
|
|
76
|
+
$ = /* @__PURE__ */ new WeakSet();
|
|
77
|
+
B = function() {
|
|
78
78
|
return `${location.pathname}${location.search ? location.search + "&" : "?"}${i(this, _, w)}`;
|
|
79
79
|
};
|
|
80
80
|
_ = /* @__PURE__ */ new WeakSet();
|
|
81
81
|
w = function() {
|
|
82
82
|
return `modal-${this.id}`;
|
|
83
83
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
(
|
|
84
|
+
y = /* @__PURE__ */ new WeakMap();
|
|
85
|
+
L = /* @__PURE__ */ new WeakMap();
|
|
86
|
+
C = /* @__PURE__ */ new WeakSet();
|
|
87
|
+
P = function(e) {
|
|
88
|
+
(p.__opened[i(this, T) - 1] || p.__opened.length === 1) && e();
|
|
89
89
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
],
|
|
95
|
-
var
|
|
96
|
-
for (var
|
|
97
|
-
(
|
|
98
|
-
return
|
|
99
|
-
},
|
|
90
|
+
g = /* @__PURE__ */ new WeakMap();
|
|
91
|
+
p.__opened = [];
|
|
92
|
+
p = V([
|
|
93
|
+
q("e-popover")
|
|
94
|
+
], p);
|
|
95
|
+
var X = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, Z = (e, t, s, o) => {
|
|
96
|
+
for (var a = o > 1 ? void 0 : o ? Y(t, s) : t, d = e.length - 1, v; d >= 0; d--)
|
|
97
|
+
(v = e[d]) && (a = (o ? v(t, s, a) : v(a)) || a);
|
|
98
|
+
return o && a && X(t, s, a), a;
|
|
99
|
+
}, G = (e, t, s) => {
|
|
100
100
|
if (!t.has(e))
|
|
101
101
|
throw TypeError("Cannot " + s);
|
|
102
|
-
},
|
|
102
|
+
}, r = (e, t, s) => (G(e, t, "read from private field"), s ? s.call(e) : t.get(e)), f = (e, t, s) => {
|
|
103
103
|
if (t.has(e))
|
|
104
104
|
throw TypeError("Cannot add the same private member more than once");
|
|
105
105
|
t instanceof WeakSet ? t.add(e) : t.set(e, s);
|
|
106
|
-
},
|
|
107
|
-
const
|
|
106
|
+
}, j = (e, t, s, o) => (G(e, t, "write to private field"), o ? o.call(e, s) : t.set(e, s), s), n, k, W, M, S;
|
|
107
|
+
const ee = J({
|
|
108
108
|
button: {
|
|
109
109
|
all: "inherit"
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
|
-
let
|
|
112
|
+
let I = class extends N {
|
|
113
113
|
constructor() {
|
|
114
|
-
super(),
|
|
114
|
+
super(), f(this, n, void 0), f(this, k, () => {
|
|
115
|
+
this.classList.add("triggered");
|
|
116
|
+
}), f(this, W, () => {
|
|
117
|
+
this.classList.add("opened");
|
|
118
|
+
}), f(this, M, () => {
|
|
119
|
+
this.classList.remove("opened");
|
|
120
|
+
}), f(this, S, () => {
|
|
121
|
+
this.classList.remove("triggered");
|
|
122
|
+
}), this.openShadow(ee), b && U(this, {
|
|
115
123
|
children: [
|
|
116
|
-
|
|
124
|
+
z({
|
|
117
125
|
onClick: () => {
|
|
118
|
-
if (
|
|
126
|
+
if (r(this, n)) {
|
|
119
127
|
const e = this.getAttribute("type") || "open";
|
|
120
|
-
e === "open" || e === "toggle" && !
|
|
128
|
+
e === "open" || e === "toggle" && !r(this, n).opened.current ? r(this, n).open() : (e === "close" || e === "toggle" && r(this, n).opened.current) && r(this, n).close();
|
|
121
129
|
}
|
|
122
130
|
},
|
|
123
|
-
children: [
|
|
131
|
+
children: [F()]
|
|
124
132
|
})
|
|
125
133
|
]
|
|
126
134
|
});
|
|
127
135
|
}
|
|
128
136
|
get popoverElement() {
|
|
129
|
-
return
|
|
137
|
+
return r(this, n);
|
|
130
138
|
}
|
|
131
139
|
connectedCallback() {
|
|
132
140
|
const e = this.getAttribute("target");
|
|
133
141
|
if (e) {
|
|
134
142
|
const t = document.querySelector(`#${e}`) || this.getRootNode().querySelector(`#${e}`);
|
|
135
|
-
t ?
|
|
143
|
+
t ? (j(this, n, t), r(this, n).addEventListener(
|
|
144
|
+
"popoverTriggered",
|
|
145
|
+
r(this, k)
|
|
146
|
+
), r(this, n).addEventListener(
|
|
147
|
+
"popoverOpened",
|
|
148
|
+
r(this, W)
|
|
149
|
+
), r(this, n).addEventListener(
|
|
150
|
+
"popoverClosing",
|
|
151
|
+
r(this, M)
|
|
152
|
+
), r(this, n).addEventListener(
|
|
153
|
+
"popoverClosed",
|
|
154
|
+
r(this, S)
|
|
155
|
+
)) : console.warn(this, `target ${e} not found`);
|
|
136
156
|
}
|
|
137
157
|
}
|
|
158
|
+
disconnectedCallback() {
|
|
159
|
+
r(this, n) && (r(this, n).removeEventListener(
|
|
160
|
+
"popoverTriggered",
|
|
161
|
+
r(this, k)
|
|
162
|
+
), r(this, n).removeEventListener(
|
|
163
|
+
"popoverOpened",
|
|
164
|
+
r(this, W)
|
|
165
|
+
), r(this, n).removeEventListener(
|
|
166
|
+
"popoverClosing",
|
|
167
|
+
r(this, M)
|
|
168
|
+
), r(this, n).removeEventListener(
|
|
169
|
+
"popoverClosed",
|
|
170
|
+
r(this, S)
|
|
171
|
+
));
|
|
172
|
+
}
|
|
138
173
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
174
|
+
n = /* @__PURE__ */ new WeakMap();
|
|
175
|
+
k = /* @__PURE__ */ new WeakMap();
|
|
176
|
+
W = /* @__PURE__ */ new WeakMap();
|
|
177
|
+
M = /* @__PURE__ */ new WeakMap();
|
|
178
|
+
S = /* @__PURE__ */ new WeakMap();
|
|
179
|
+
I = Z([
|
|
180
|
+
q("e-popover-button")
|
|
181
|
+
], I);
|
|
143
182
|
export {
|
|
144
|
-
|
|
145
|
-
|
|
183
|
+
I as PopoverButtonElement,
|
|
184
|
+
p as PopoverElement
|
|
146
185
|
};
|