aptechka 0.7.8 → 0.7.10
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/popover/index.cjs +1 -1
- package/lib/popover/index.js +48 -49
- package/package.json +1 -1
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 A=require("../attribute/index.cjs"),S=require("../custom-element/index.cjs"),D=require("../Store-6s0YXK4o.cjs"),H=require("../style-At6aDoqG.cjs"),I=require("../browser-CpzFX2xg.cjs"),N=require("../tags-ld5jemJw.cjs");var R=Object.defineProperty,G=Object.getOwnPropertyDescriptor,K=(t,e,s,r)=>{for(var a=r>1?void 0:r?G(e,s):e,l=t.length-1,p;l>=0;l--)(p=t[l])&&(a=(r?p(e,s,a):p(a))||a);return r&&a&&R(e,s,a),a},b=(t,e,s)=>{if(!e.has(t))throw TypeError("Cannot "+s)},i=(t,e,s)=>(b(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)},W=(t,e,s,r)=>(b(t,e,"write to private field"),e.set(t,s),s),q=(t,e,s)=>(b(t,e,"access private method"),s),M,c,m,d,v,f,O,x,u,g,w,y,L,$,E;exports.PopoverElement=class extends S.CustomElement{constructor(){super(),h(this,O),h(this,u),h(this,L),h(this,M,-1),h(this,c,new D.Store(!1)),h(this,m,void 0),h(this,d,new A.Attribute(this,"history",!1)),h(this,v,new A.Attribute(this,"single",!1)),h(this,f,!1),this.open=(e=!0)=>{if(i(this,c).current)return;i(this,c).current=!0,i(this,v).current&&(exports.PopoverElement.__opened.forEach(r=>r.close()),exports.PopoverElement.__opened=[]),exports.PopoverElement.__opened.push(this),W(this,M,exports.PopoverElement.__opened.length-1),i(this,d).current&&i(this,f)&&history.pushState("","",i(this,O,x)),clearTimeout(i(this,m)),this.classList.add("triggered"),this.style.display="block",this.dispatchEvent(new CustomEvent("popoverTriggered"));const s=()=>{addEventListener("click",i(this,w)),addEventListener("keydown",i(this,y)),this.style.opacity="1",this.classList.add("opened"),this.dispatchEvent(new CustomEvent("popoverOpened"))};e?setTimeout(s):s()},this.close=()=>{if(i(this,c).current){if(i(this,c).current=!1,exports.PopoverElement.__opened=exports.PopoverElement.__opened.filter(e=>e!==this),i(this,d).current){const e=new URL(location.href);e.searchParams.delete(i(this,u,g)),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"))},H.getElementTransitionDurationMS(this)+10)}},h(this,w,e=>{q(this,L,$).call(this,()=>{var p;const r=e.composedPath()[0],a=r instanceof HTMLElement&&(this.contains(r)||((p=this.shadowRoot)==null?void 0:p.contains(r))),l=r instanceof HTMLElement&&r.hasAttribute("outside");(!a||l)&&this.close()})}),h(this,y,e=>{q(this,L,$).call(this,()=>{e.code==="Escape"&&this.close()})}),h(this,E,()=>{W(this,f,!1),i(this,c).current&&i(this,d).current&&!location.search.includes(i(this,u,g))?this.close():!i(this,c).current&&i(this,d).current&&location.search.includes(i(this,u,g))&&this.open(),W(this,f,!0)}),this.setAttribute("popover-target","")}get history(){return i(this,d)}get single(){return i(this,v)}get opened(){return i(this,c)}connectedCallback(){i(this,d).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,d).unobserve(),i(this,v).unobserve(),exports.PopoverElement.__opened=exports.PopoverElement.__opened.filter(e=>e!==this),clearTimeout(i(this,m)),removeEventListener("popstate",i(this,E))}};M=new WeakMap;c=new WeakMap;m=new WeakMap;d=new WeakMap;v=new WeakMap;f=new WeakMap;O=new WeakSet;x=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${i(this,u,g)}`};u=new WeakSet;g=function(){return`modal-${this.id}`};w=new WeakMap;y=new WeakMap;L=new WeakSet;$=function(t){(exports.PopoverElement.__opened[i(this,M)-1]||exports.PopoverElement.__opened.length===1)&&t()};E=new WeakMap;exports.PopoverElement.__opened=[];exports.PopoverElement=K([S.define("e-popover")],exports.PopoverElement);var U=Object.defineProperty,z=Object.getOwnPropertyDescriptor,F=(t,e,s,r)=>{for(var a=r>1?void 0:r?z(e,s):e,l=t.length-1,p;l>=0;l--)(p=t[l])&&(a=(r?p(e,s,a):p(a))||a);return r&&a&&U(e,s,a),a},B=(t,e,s)=>{if(!e.has(t))throw TypeError("Cannot "+s)},o=(t,e,s)=>(B(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)},J=(t,e,s,r)=>(B(t,e,"write to private field"),e.set(t,s),s),n,P,C,k,T;exports.PopoverButtonElement=class extends S.CustomElement{constructor(){super(),_(this,n,void 0),_(this,P,()=>{this.classList.add("triggered")}),_(this,C,()=>{this.classList.add("opened")}),_(this,k,()=>{this.classList.remove("opened")}),_(this,T,()=>{this.classList.remove("triggered")}),I.isBrowser&&N.element(this,{tabindex:this.getAttribute("tabindex")||"0",onClick:()=>{if(o(this,n)){const e=this.getAttribute("type")||"open";e==="open"||e==="toggle"&&!o(this,n).opened.current?o(this,n).open():(e==="close"||e==="toggle"&&o(this,n).opened.current)&&o(this,n).close()}},onKeydown:e=>{e.code==="Space"&&e.currentTarget.click()}})}get popoverElement(){return o(this,n)}connectedCallback(){var s;const e=this.getAttribute("target");if(e){let r=null;e==="parent"?r=this.closest("[popover-target]"):e==="sibling"?r=(s=this.parentElement)==null?void 0:s.querySelector("[popover-target]"):r=document.querySelector(`#${e}`)||this.getRootNode().querySelector(`#${e}`),r instanceof HTMLElement?(J(this,n,r),o(this,n).addEventListener("popoverTriggered",o(this,P)),o(this,n).addEventListener("popoverOpened",o(this,C)),o(this,n).addEventListener("popoverClosing",o(this,k)),o(this,n).addEventListener("popoverClosed",o(this,T))):console.warn(this,`target ${e} not found`)}}disconnectedCallback(){o(this,n)&&(o(this,n).removeEventListener("popoverTriggered",o(this,P)),o(this,n).removeEventListener("popoverOpened",o(this,C)),o(this,n).removeEventListener("popoverClosing",o(this,k)),o(this,n).removeEventListener("popoverClosed",o(this,T)))}};n=new WeakMap;P=new WeakMap;C=new WeakMap;k=new WeakMap;T=new WeakMap;exports.PopoverButtonElement=F([S.define("e-popover-button")],exports.PopoverButtonElement);
|
package/lib/popover/index.js
CHANGED
|
@@ -1,58 +1,57 @@
|
|
|
1
1
|
import { Attribute as x } from "../attribute/index.js";
|
|
2
2
|
import { CustomElement as q, define as H } from "../custom-element/index.js";
|
|
3
|
-
import { S as
|
|
4
|
-
import { a as
|
|
5
|
-
import { i as
|
|
3
|
+
import { S as R } from "../Store-BI2xxXOA.js";
|
|
4
|
+
import { a as B } from "../style-CklEF62D.js";
|
|
5
|
+
import { i as G } from "../browser-0zX67oeU.js";
|
|
6
6
|
import { e as K } from "../tags-BqJKcIve.js";
|
|
7
|
-
var U = Object.defineProperty, z = Object.getOwnPropertyDescriptor, F = (e, t, s,
|
|
8
|
-
for (var o =
|
|
9
|
-
(v = e[
|
|
10
|
-
return
|
|
7
|
+
var U = Object.defineProperty, z = Object.getOwnPropertyDescriptor, F = (e, t, s, a) => {
|
|
8
|
+
for (var o = a > 1 ? void 0 : a ? z(t, s) : t, c = e.length - 1, v; c >= 0; c--)
|
|
9
|
+
(v = e[c]) && (o = (a ? v(t, s, o) : v(o)) || o);
|
|
10
|
+
return a && o && U(t, s, o), o;
|
|
11
11
|
}, A = (e, t, s) => {
|
|
12
12
|
if (!t.has(e))
|
|
13
13
|
throw TypeError("Cannot " + s);
|
|
14
|
-
}, i = (e, t, s) => (A(e, t, "read from private field"), s ? s.call(e) : t.get(e)),
|
|
14
|
+
}, i = (e, t, s) => (A(e, t, "read from private field"), s ? s.call(e) : t.get(e)), p = (e, t, s) => {
|
|
15
15
|
if (t.has(e))
|
|
16
16
|
throw TypeError("Cannot add the same private member more than once");
|
|
17
17
|
t instanceof WeakSet ? t.add(e) : t.set(e, s);
|
|
18
|
-
}, O = (e, t, s,
|
|
19
|
-
let
|
|
18
|
+
}, O = (e, t, s, a) => (A(e, t, "write to private field"), t.set(e, s), s), b = (e, t, s) => (A(e, t, "access private method"), s), S, l, E, d, u, g, $, I, _, m, L, y, C, P, w;
|
|
19
|
+
let h = class extends q {
|
|
20
20
|
constructor() {
|
|
21
|
-
super(),
|
|
21
|
+
super(), p(this, $), p(this, _), p(this, C), p(this, S, -1), p(this, l, new R(!1)), p(this, E, void 0), p(this, d, new x(this, "history", !1)), p(this, u, new x(this, "single", !1)), p(this, g, !1), this.open = (e = !0) => {
|
|
22
22
|
if (i(this, l).current)
|
|
23
23
|
return;
|
|
24
|
-
i(this, l).current = !0, i(this, u).current && (
|
|
24
|
+
i(this, l).current = !0, i(this, u).current && (h.__opened.forEach((s) => s.close()), h.__opened = []), h.__opened.push(this), O(this, S, h.__opened.length - 1), i(this, d).current && i(this, g) && history.pushState("", "", i(this, $, I)), clearTimeout(i(this, E)), this.classList.add("triggered"), this.style.display = "block", this.dispatchEvent(new CustomEvent("popoverTriggered"));
|
|
25
25
|
const t = () => {
|
|
26
26
|
addEventListener("click", i(this, L)), addEventListener("keydown", i(this, y)), this.style.opacity = "1", this.classList.add("opened"), this.dispatchEvent(new CustomEvent("popoverOpened"));
|
|
27
27
|
};
|
|
28
28
|
e ? setTimeout(t) : t();
|
|
29
29
|
}, this.close = () => {
|
|
30
30
|
if (i(this, l).current) {
|
|
31
|
-
if (i(this, l).current = !1,
|
|
31
|
+
if (i(this, l).current = !1, h.__opened = h.__opened.filter((e) => e !== this), i(this, d).current) {
|
|
32
32
|
const e = new URL(location.href);
|
|
33
|
-
e.searchParams.delete(i(this, _,
|
|
33
|
+
e.searchParams.delete(i(this, _, m)), history.replaceState(null, "", e.href);
|
|
34
34
|
}
|
|
35
35
|
this.classList.remove("opened"), this.style.opacity = "0", this.dispatchEvent(new CustomEvent("popoverClosing")), removeEventListener("click", i(this, L)), removeEventListener("keydown", i(this, y)), setTimeout(() => {
|
|
36
36
|
this.classList.remove("triggered"), this.style.display = "none", this.dispatchEvent(new CustomEvent("popoverClosed"));
|
|
37
|
-
},
|
|
37
|
+
}, B(this) + 10);
|
|
38
38
|
}
|
|
39
|
-
},
|
|
39
|
+
}, p(this, L, (e) => {
|
|
40
40
|
b(this, C, P).call(this, () => {
|
|
41
|
-
|
|
42
|
-
(
|
|
43
|
-
|
|
44
|
-
) || t[0] instanceof HTMLElement && t[0].closest("[outside]")) && this.close();
|
|
41
|
+
var c;
|
|
42
|
+
const s = e.composedPath()[0], a = s instanceof HTMLElement && (this.contains(s) || ((c = this.shadowRoot) == null ? void 0 : c.contains(s))), o = s instanceof HTMLElement && s.hasAttribute("outside");
|
|
43
|
+
(!a || o) && this.close();
|
|
45
44
|
});
|
|
46
|
-
}),
|
|
45
|
+
}), p(this, y, (e) => {
|
|
47
46
|
b(this, C, P).call(this, () => {
|
|
48
47
|
e.code === "Escape" && this.close();
|
|
49
48
|
});
|
|
50
|
-
}),
|
|
51
|
-
O(this, g, !1), i(this, l).current && i(this,
|
|
49
|
+
}), p(this, w, () => {
|
|
50
|
+
O(this, g, !1), i(this, l).current && i(this, d).current && !location.search.includes(i(this, _, m)) ? this.close() : !i(this, l).current && i(this, d).current && location.search.includes(i(this, _, m)) && this.open(), O(this, g, !0);
|
|
52
51
|
}), this.setAttribute("popover-target", "");
|
|
53
52
|
}
|
|
54
53
|
get history() {
|
|
55
|
-
return i(this,
|
|
54
|
+
return i(this, d);
|
|
56
55
|
}
|
|
57
56
|
get single() {
|
|
58
57
|
return i(this, u);
|
|
@@ -61,43 +60,43 @@ let a = class extends q {
|
|
|
61
60
|
return i(this, l);
|
|
62
61
|
}
|
|
63
62
|
connectedCallback() {
|
|
64
|
-
i(this,
|
|
65
|
-
i(this,
|
|
63
|
+
i(this, d).observe(), i(this, u).observe(), this.style.opacity = "0", this.style.display = "none", addEventListener("popstate", i(this, w)), setTimeout(() => {
|
|
64
|
+
i(this, w).call(this);
|
|
66
65
|
}, 0);
|
|
67
66
|
}
|
|
68
67
|
disconnectedCallback() {
|
|
69
|
-
i(this,
|
|
68
|
+
i(this, d).unobserve(), i(this, u).unobserve(), h.__opened = h.__opened.filter((e) => e !== this), clearTimeout(i(this, E)), removeEventListener("popstate", i(this, w));
|
|
70
69
|
}
|
|
71
70
|
};
|
|
72
71
|
S = /* @__PURE__ */ new WeakMap();
|
|
73
72
|
l = /* @__PURE__ */ new WeakMap();
|
|
74
73
|
E = /* @__PURE__ */ new WeakMap();
|
|
75
|
-
|
|
74
|
+
d = /* @__PURE__ */ new WeakMap();
|
|
76
75
|
u = /* @__PURE__ */ new WeakMap();
|
|
77
76
|
g = /* @__PURE__ */ new WeakMap();
|
|
78
77
|
$ = /* @__PURE__ */ new WeakSet();
|
|
79
78
|
I = function() {
|
|
80
|
-
return `${location.pathname}${location.search ? location.search + "&" : "?"}${i(this, _,
|
|
79
|
+
return `${location.pathname}${location.search ? location.search + "&" : "?"}${i(this, _, m)}`;
|
|
81
80
|
};
|
|
82
81
|
_ = /* @__PURE__ */ new WeakSet();
|
|
83
|
-
|
|
82
|
+
m = function() {
|
|
84
83
|
return `modal-${this.id}`;
|
|
85
84
|
};
|
|
86
85
|
L = /* @__PURE__ */ new WeakMap();
|
|
87
86
|
y = /* @__PURE__ */ new WeakMap();
|
|
88
87
|
C = /* @__PURE__ */ new WeakSet();
|
|
89
88
|
P = function(e) {
|
|
90
|
-
(
|
|
89
|
+
(h.__opened[i(this, S) - 1] || h.__opened.length === 1) && e();
|
|
91
90
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
w = /* @__PURE__ */ new WeakMap();
|
|
92
|
+
h.__opened = [];
|
|
93
|
+
h = F([
|
|
95
94
|
H("e-popover")
|
|
96
|
-
],
|
|
97
|
-
var J = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, V = (e, t, s,
|
|
98
|
-
for (var o =
|
|
99
|
-
(v = e[
|
|
100
|
-
return
|
|
95
|
+
], h);
|
|
96
|
+
var J = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, V = (e, t, s, a) => {
|
|
97
|
+
for (var o = a > 1 ? void 0 : a ? Q(t, s) : t, c = e.length - 1, v; c >= 0; c--)
|
|
98
|
+
(v = e[c]) && (o = (a ? v(t, s, o) : v(o)) || o);
|
|
99
|
+
return a && o && J(t, s, o), o;
|
|
101
100
|
}, N = (e, t, s) => {
|
|
102
101
|
if (!t.has(e))
|
|
103
102
|
throw TypeError("Cannot " + s);
|
|
@@ -105,18 +104,18 @@ var J = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, V = (e, t, s
|
|
|
105
104
|
if (t.has(e))
|
|
106
105
|
throw TypeError("Cannot add the same private member more than once");
|
|
107
106
|
t instanceof WeakSet ? t.add(e) : t.set(e, s);
|
|
108
|
-
}, X = (e, t, s,
|
|
107
|
+
}, X = (e, t, s, a) => (N(e, t, "write to private field"), t.set(e, s), s), n, k, T, M, W;
|
|
109
108
|
let D = class extends q {
|
|
110
109
|
constructor() {
|
|
111
110
|
super(), f(this, n, void 0), f(this, k, () => {
|
|
112
111
|
this.classList.add("triggered");
|
|
113
|
-
}), f(this, M, () => {
|
|
114
|
-
this.classList.add("opened");
|
|
115
112
|
}), f(this, T, () => {
|
|
113
|
+
this.classList.add("opened");
|
|
114
|
+
}), f(this, M, () => {
|
|
116
115
|
this.classList.remove("opened");
|
|
117
116
|
}), f(this, W, () => {
|
|
118
117
|
this.classList.remove("triggered");
|
|
119
|
-
}),
|
|
118
|
+
}), G && K(this, {
|
|
120
119
|
tabindex: this.getAttribute("tabindex") || "0",
|
|
121
120
|
onClick: () => {
|
|
122
121
|
if (r(this, n)) {
|
|
@@ -142,10 +141,10 @@ let D = class extends q {
|
|
|
142
141
|
r(this, k)
|
|
143
142
|
), r(this, n).addEventListener(
|
|
144
143
|
"popoverOpened",
|
|
145
|
-
r(this,
|
|
144
|
+
r(this, T)
|
|
146
145
|
), r(this, n).addEventListener(
|
|
147
146
|
"popoverClosing",
|
|
148
|
-
r(this,
|
|
147
|
+
r(this, M)
|
|
149
148
|
), r(this, n).addEventListener(
|
|
150
149
|
"popoverClosed",
|
|
151
150
|
r(this, W)
|
|
@@ -158,10 +157,10 @@ let D = class extends q {
|
|
|
158
157
|
r(this, k)
|
|
159
158
|
), r(this, n).removeEventListener(
|
|
160
159
|
"popoverOpened",
|
|
161
|
-
r(this,
|
|
160
|
+
r(this, T)
|
|
162
161
|
), r(this, n).removeEventListener(
|
|
163
162
|
"popoverClosing",
|
|
164
|
-
r(this,
|
|
163
|
+
r(this, M)
|
|
165
164
|
), r(this, n).removeEventListener(
|
|
166
165
|
"popoverClosed",
|
|
167
166
|
r(this, W)
|
|
@@ -170,13 +169,13 @@ let D = class extends q {
|
|
|
170
169
|
};
|
|
171
170
|
n = /* @__PURE__ */ new WeakMap();
|
|
172
171
|
k = /* @__PURE__ */ new WeakMap();
|
|
173
|
-
M = /* @__PURE__ */ new WeakMap();
|
|
174
172
|
T = /* @__PURE__ */ new WeakMap();
|
|
173
|
+
M = /* @__PURE__ */ new WeakMap();
|
|
175
174
|
W = /* @__PURE__ */ new WeakMap();
|
|
176
175
|
D = V([
|
|
177
176
|
H("e-popover-button")
|
|
178
177
|
], D);
|
|
179
178
|
export {
|
|
180
179
|
D as PopoverButtonElement,
|
|
181
|
-
|
|
180
|
+
h as PopoverElement
|
|
182
181
|
};
|