aptechka 0.30.14 → 0.30.15
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 +43 -38
- package/package.json +1 -1
package/lib/popover/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var R=i=>{throw TypeError(i)};var q=(i,r,t)=>r.has(i)||R("Cannot "+t);var e=(i,r,t)=>(q(i,r,"read from private field"),t?t.call(i):r.get(i)),o=(i,r,t)=>r.has(i)?R("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(i):r.set(i,t),h=(i,r,t,l)=>(q(i,r,"write to private field"),l?l.call(i,t):r.set(i,t),t),b=(i,r,t)=>(q(i,r,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("../attribute/index.cjs"),N=require("../Store-CDb6RMce.cjs"),A=require("../events-KVanG9sR.cjs"),j=require("../style-At6aDoqG.cjs"),D=require("../browser-CpzFX2xg.cjs");var L,a,T,p,u,v,g,d,I,E,O,y,x,m;const c=class c extends HTMLElement{constructor(){super(...arguments);o(this,d);o(this,L);o(this,a);o(this,T);o(this,p);o(this,u);o(this,v);o(this,g);o(this,E);o(this,y);o(this,m);h(this,L,-1),h(this,a,new N.Store(!1)),h(this,p,new H.Attribute(this,"history",!1)),h(this,u,new H.Attribute(this,"restore",!1)),h(this,v,new H.Attribute(this,"single",!1)),h(this,g,!1),this.open=(t=!0)=>{if(e(this,a).current)return;e(this,a).current=!0,e(this,v).current&&(c.__opened.forEach(n=>n.close()),c.__opened=[]),c.__opened.push(this),h(this,L,c.__opened.length-1),e(this,p).current&&e(this,g)&&history.pushState("","",e(this,d,I)),clearTimeout(e(this,T)),this.classList.remove("closing"),this.classList.add("triggered"),this.style.display="block",A.dispatchEvent(this,"popoverTriggered",{custom:!0});const l=()=>{addEventListener("click",e(this,E)),addEventListener("keydown",e(this,y)),this.style.opacity="1",this.classList.add("opened"),A.dispatchEvent(this,"popoverOpened",{custom:!0})};t?setTimeout(l,10):l()},this.close=()=>{e(this,a).current&&(e(this,a).current=!1,c.__opened=c.__opened.filter(t=>t!==this),b(this,d,O).call(this),this.classList.remove("opened"),this.classList.add("closing"),this.style.opacity="0",A.dispatchEvent(this,"popoverClosing",{custom:!0}),removeEventListener("click",e(this,E)),removeEventListener("keydown",e(this,y)),setTimeout(()=>{this.classList.remove("triggered"),this.classList.remove("closing"),this.style.display="none",A.dispatchEvent(this,"popoverClosed",{custom:!0})},j.getElementTransitionDurationMS(this)+10))},h(this,E,t=>{b(this,d,x).call(this,()=>{var $;const l=t.composedPath();if(l.find(P=>P instanceof HTMLElement&&P.hasAttribute("data-popover-content")))return;const n=l[0],_=n instanceof HTMLElement&&(this.contains(n)||(($=this.shadowRoot)==null?void 0:$.contains(n))),f=n instanceof HTMLElement&&n.hasAttribute("data-outside");(!_||f)&&this.close()})}),h(this,y,t=>{b(this,d,x).call(this,()=>{t.code==="Escape"&&this.close()})}),h(this,m,()=>{h(this,g,!1),e(this,a).current&&e(this,p).current&&!location.search.includes(this.id)?this.close():!e(this,a).current&&e(this,p).current&&location.search.includes(this.id)&&this.open(),h(this,g,!0)})}get history(){return e(this,p)}get restore(){return e(this,u)}get single(){return e(this,v)}get opened(){return e(this,a)}connectedCallback(){e(this,p).observe(),e(this,u).observe(),e(this,v).observe(),this.style.opacity="0",this.style.display="none",this.setAttribute("popover-target",""),this.classList.remove("closing"),this.classList.remove("closed"),this.classList.remove("triggered"),this.classList.remove("opened"),addEventListener("popstate",e(this,m)),setTimeout(()=>{e(this,u).current?e(this,m).call(this):(b(this,d,O).call(this),h(this,g,!0))},0)}disconnectedCallback(){e(this,p).unobserve(),e(this,u).unobserve(),e(this,v).unobserve(),this.style.opacity="",this.style.display="",this.removeAttribute("popover-target"),c.__opened=c.__opened.filter(t=>t!==this),clearTimeout(e(this,T)),removeEventListener("popstate",e(this,m))}};L=new WeakMap,a=new WeakMap,T=new WeakMap,p=new WeakMap,u=new WeakMap,v=new WeakMap,g=new WeakMap,d=new WeakSet,I=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.id}`},E=new WeakMap,O=function(){if(e(this,p).current){const t=new URL(location.href);t.searchParams.delete(this.id),history.replaceState(null,"",t.href)}},y=new WeakMap,x=function(t){(c.__opened[e(this,L)-1]||c.__opened.length===1)&&t()},m=new WeakMap,c.__opened=[];let M=c;customElements.get("e-popover")||customElements.define("e-popover",M);var s,w,k,S,C;class B extends HTMLElement{constructor(){super();o(this,s);o(this,w,()=>{this.classList.add("triggered")});o(this,k,()=>{this.classList.add("opened")});o(this,S,()=>{this.classList.remove("opened")});o(this,C,()=>{this.classList.remove("triggered")});D.isBrowser&&(this.addEventListener("click",()=>{if(e(this,s)){const t=this.getAttribute("type")||"open";t==="open"||t==="toggle"&&!e(this,s).opened.current?e(this,s).open():(t==="close"||t==="toggle"&&e(this,s).opened.current)&&e(this,s).close()}}),this.addEventListener("keydown",t=>{t.code==="Space"&&t.currentTarget.click()}))}get popoverElement(){return e(this,s)}connectedCallback(){var l;this.hasAttribute("tabindex")||(this.tabIndex=0);const t=this.getAttribute("target");if(t){let n=null;if(t==="parent"){const _=this.closest("[popover-target]");if(_)n=_;else{const f=this.getRootNode();f instanceof ShadowRoot?n=f.host.closest("[popover-target]"):f instanceof HTMLElement&&(n=f.closest("[popover-target]"))}}else t==="sibling"?n=(l=this.parentElement)==null?void 0:l.querySelector("[popover-target]"):n=document.querySelector(`#${t}`)||this.getRootNode().querySelector(`#${t}`);n instanceof HTMLElement?(h(this,s,n),e(this,s).addEventListener("popoverTriggered",e(this,w)),e(this,s).addEventListener("popoverOpened",e(this,k)),e(this,s).addEventListener("popoverClosing",e(this,S)),e(this,s).addEventListener("popoverClosed",e(this,C))):console.warn(this,`target ${t} not found`)}}disconnectedCallback(){e(this,s)&&(e(this,s).removeEventListener("popoverTriggered",e(this,w)),e(this,s).removeEventListener("popoverOpened",e(this,k)),e(this,s).removeEventListener("popoverClosing",e(this,S)),e(this,s).removeEventListener("popoverClosed",e(this,C)))}}s=new WeakMap,w=new WeakMap,k=new WeakMap,S=new WeakMap,C=new WeakMap;customElements.get("e-popover-button")||customElements.define("e-popover-button",B);exports.PopoverButtonElement=B;exports.PopoverElement=M;
|
package/lib/popover/index.js
CHANGED
|
@@ -1,64 +1,69 @@
|
|
|
1
|
-
var
|
|
1
|
+
var q = (i) => {
|
|
2
2
|
throw TypeError(i);
|
|
3
3
|
};
|
|
4
|
-
var M = (i, r, t) => r.has(i) ||
|
|
5
|
-
var e = (i, r, t) => (M(i, r, "read from private field"), t ? t.call(i) : r.get(i)), o = (i, r, t) => r.has(i) ?
|
|
6
|
-
import { Attribute as
|
|
7
|
-
import { S as
|
|
4
|
+
var M = (i, r, t) => r.has(i) || q("Cannot " + t);
|
|
5
|
+
var e = (i, r, t) => (M(i, r, "read from private field"), t ? t.call(i) : r.get(i)), o = (i, r, t) => r.has(i) ? q("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(i) : r.set(i, t), h = (i, r, t, l) => (M(i, r, "write to private field"), l ? l.call(i, t) : r.set(i, t), t), b = (i, r, t) => (M(i, r, "access private method"), t);
|
|
6
|
+
import { Attribute as H } from "../attribute/index.js";
|
|
7
|
+
import { S as B } from "../Store-OTdcl6SX.js";
|
|
8
8
|
import { d as A } from "../events-CsVF98U6.js";
|
|
9
|
-
import { g as
|
|
10
|
-
import { i as
|
|
11
|
-
var L,
|
|
9
|
+
import { g as P } from "../style-j2TwriJ_.js";
|
|
10
|
+
import { i as D } from "../browser-0zX67oeU.js";
|
|
11
|
+
var L, a, T, p, u, v, g, d, N, E, O, y, $, m;
|
|
12
12
|
const c = class c extends HTMLElement {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
|
-
o(this,
|
|
15
|
+
o(this, d);
|
|
16
16
|
o(this, L);
|
|
17
|
-
o(this, l);
|
|
18
|
-
o(this, T);
|
|
19
17
|
o(this, a);
|
|
18
|
+
o(this, T);
|
|
19
|
+
o(this, p);
|
|
20
20
|
o(this, u);
|
|
21
21
|
o(this, v);
|
|
22
22
|
o(this, g);
|
|
23
23
|
o(this, E);
|
|
24
24
|
o(this, y);
|
|
25
25
|
o(this, m);
|
|
26
|
-
h(this, L, -1), h(this,
|
|
27
|
-
if (e(this,
|
|
26
|
+
h(this, L, -1), h(this, a, new B(!1)), h(this, p, new H(this, "history", !1)), h(this, u, new H(this, "restore", !1)), h(this, v, new H(this, "single", !1)), h(this, g, !1), this.open = (t = !0) => {
|
|
27
|
+
if (e(this, a).current)
|
|
28
28
|
return;
|
|
29
|
-
e(this,
|
|
29
|
+
e(this, a).current = !0, e(this, v).current && (c.__opened.forEach((n) => n.close()), c.__opened = []), c.__opened.push(this), h(this, L, c.__opened.length - 1), e(this, p).current && e(this, g) && history.pushState("", "", e(this, d, N)), clearTimeout(e(this, T)), this.classList.remove("closing"), this.classList.add("triggered"), this.style.display = "block", A(this, "popoverTriggered", {
|
|
30
30
|
custom: !0
|
|
31
31
|
});
|
|
32
|
-
const
|
|
32
|
+
const l = () => {
|
|
33
33
|
addEventListener("click", e(this, E)), addEventListener("keydown", e(this, y)), this.style.opacity = "1", this.classList.add("opened"), A(this, "popoverOpened", {
|
|
34
34
|
custom: !0
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
t ? setTimeout(
|
|
37
|
+
t ? setTimeout(l, 10) : l();
|
|
38
38
|
}, this.close = () => {
|
|
39
|
-
e(this,
|
|
39
|
+
e(this, a).current && (e(this, a).current = !1, c.__opened = c.__opened.filter((t) => t !== this), b(this, d, O).call(this), this.classList.remove("opened"), this.classList.add("closing"), this.style.opacity = "0", A(this, "popoverClosing", {
|
|
40
40
|
custom: !0
|
|
41
41
|
}), removeEventListener("click", e(this, E)), removeEventListener("keydown", e(this, y)), setTimeout(() => {
|
|
42
42
|
this.classList.remove("triggered"), this.classList.remove("closing"), this.style.display = "none", A(this, "popoverClosed", {
|
|
43
43
|
custom: !0
|
|
44
44
|
});
|
|
45
|
-
},
|
|
45
|
+
}, P(this) + 10));
|
|
46
46
|
}, h(this, E, (t) => {
|
|
47
|
-
b(this,
|
|
47
|
+
b(this, d, $).call(this, () => {
|
|
48
48
|
var R;
|
|
49
|
-
const
|
|
49
|
+
const l = t.composedPath();
|
|
50
|
+
if (l.find(
|
|
51
|
+
(I) => I instanceof HTMLElement && I.hasAttribute("data-popover-content")
|
|
52
|
+
))
|
|
53
|
+
return;
|
|
54
|
+
const n = l[0], _ = n instanceof HTMLElement && (this.contains(n) || ((R = this.shadowRoot) == null ? void 0 : R.contains(n))), f = n instanceof HTMLElement && n.hasAttribute("data-outside");
|
|
50
55
|
(!_ || f) && this.close();
|
|
51
56
|
});
|
|
52
57
|
}), h(this, y, (t) => {
|
|
53
|
-
b(this,
|
|
58
|
+
b(this, d, $).call(this, () => {
|
|
54
59
|
t.code === "Escape" && this.close();
|
|
55
60
|
});
|
|
56
61
|
}), h(this, m, () => {
|
|
57
|
-
h(this, g, !1), e(this,
|
|
62
|
+
h(this, g, !1), e(this, a).current && e(this, p).current && !location.search.includes(this.id) ? this.close() : !e(this, a).current && e(this, p).current && location.search.includes(this.id) && this.open(), h(this, g, !0);
|
|
58
63
|
});
|
|
59
64
|
}
|
|
60
65
|
get history() {
|
|
61
|
-
return e(this,
|
|
66
|
+
return e(this, p);
|
|
62
67
|
}
|
|
63
68
|
get restore() {
|
|
64
69
|
return e(this, u);
|
|
@@ -67,31 +72,31 @@ const c = class c extends HTMLElement {
|
|
|
67
72
|
return e(this, v);
|
|
68
73
|
}
|
|
69
74
|
get opened() {
|
|
70
|
-
return e(this,
|
|
75
|
+
return e(this, a);
|
|
71
76
|
}
|
|
72
77
|
connectedCallback() {
|
|
73
|
-
e(this,
|
|
74
|
-
e(this, u).current ? e(this, m).call(this) : (b(this,
|
|
78
|
+
e(this, p).observe(), e(this, u).observe(), e(this, v).observe(), this.style.opacity = "0", this.style.display = "none", this.setAttribute("popover-target", ""), this.classList.remove("closing"), this.classList.remove("closed"), this.classList.remove("triggered"), this.classList.remove("opened"), addEventListener("popstate", e(this, m)), setTimeout(() => {
|
|
79
|
+
e(this, u).current ? e(this, m).call(this) : (b(this, d, O).call(this), h(this, g, !0));
|
|
75
80
|
}, 0);
|
|
76
81
|
}
|
|
77
82
|
disconnectedCallback() {
|
|
78
|
-
e(this,
|
|
83
|
+
e(this, p).unobserve(), e(this, u).unobserve(), e(this, v).unobserve(), this.style.opacity = "", this.style.display = "", this.removeAttribute("popover-target"), c.__opened = c.__opened.filter((t) => t !== this), clearTimeout(e(this, T)), removeEventListener("popstate", e(this, m));
|
|
79
84
|
}
|
|
80
85
|
};
|
|
81
|
-
L = new WeakMap(),
|
|
86
|
+
L = new WeakMap(), a = new WeakMap(), T = new WeakMap(), p = new WeakMap(), u = new WeakMap(), v = new WeakMap(), g = new WeakMap(), d = new WeakSet(), N = function() {
|
|
82
87
|
return `${location.pathname}${location.search ? location.search + "&" : "?"}${this.id}`;
|
|
83
88
|
}, E = new WeakMap(), O = function() {
|
|
84
|
-
if (e(this,
|
|
89
|
+
if (e(this, p).current) {
|
|
85
90
|
const t = new URL(location.href);
|
|
86
91
|
t.searchParams.delete(this.id), history.replaceState(null, "", t.href);
|
|
87
92
|
}
|
|
88
93
|
}, y = new WeakMap(), $ = function(t) {
|
|
89
94
|
(c.__opened[e(this, L) - 1] || c.__opened.length === 1) && t();
|
|
90
95
|
}, m = new WeakMap(), c.__opened = [];
|
|
91
|
-
let
|
|
92
|
-
customElements.get("e-popover") || customElements.define("e-popover",
|
|
96
|
+
let x = c;
|
|
97
|
+
customElements.get("e-popover") || customElements.define("e-popover", x);
|
|
93
98
|
var s, w, k, C, S;
|
|
94
|
-
class
|
|
99
|
+
class U extends HTMLElement {
|
|
95
100
|
constructor() {
|
|
96
101
|
super();
|
|
97
102
|
o(this, s);
|
|
@@ -107,7 +112,7 @@ class D extends HTMLElement {
|
|
|
107
112
|
o(this, S, () => {
|
|
108
113
|
this.classList.remove("triggered");
|
|
109
114
|
});
|
|
110
|
-
|
|
115
|
+
D && (this.addEventListener("click", () => {
|
|
111
116
|
if (e(this, s)) {
|
|
112
117
|
const t = this.getAttribute("type") || "open";
|
|
113
118
|
t === "open" || t === "toggle" && !e(this, s).opened.current ? e(this, s).open() : (t === "close" || t === "toggle" && e(this, s).opened.current) && e(this, s).close();
|
|
@@ -120,7 +125,7 @@ class D extends HTMLElement {
|
|
|
120
125
|
return e(this, s);
|
|
121
126
|
}
|
|
122
127
|
connectedCallback() {
|
|
123
|
-
var
|
|
128
|
+
var l;
|
|
124
129
|
this.hasAttribute("tabindex") || (this.tabIndex = 0);
|
|
125
130
|
const t = this.getAttribute("target");
|
|
126
131
|
if (t) {
|
|
@@ -133,7 +138,7 @@ class D extends HTMLElement {
|
|
|
133
138
|
const f = this.getRootNode();
|
|
134
139
|
f instanceof ShadowRoot ? n = f.host.closest("[popover-target]") : f instanceof HTMLElement && (n = f.closest("[popover-target]"));
|
|
135
140
|
}
|
|
136
|
-
} else t === "sibling" ? n = (
|
|
141
|
+
} else t === "sibling" ? n = (l = this.parentElement) == null ? void 0 : l.querySelector("[popover-target]") : n = document.querySelector(`#${t}`) || this.getRootNode().querySelector(`#${t}`);
|
|
137
142
|
n instanceof HTMLElement ? (h(this, s, n), e(this, s).addEventListener(
|
|
138
143
|
"popoverTriggered",
|
|
139
144
|
e(this, w)
|
|
@@ -166,8 +171,8 @@ class D extends HTMLElement {
|
|
|
166
171
|
}
|
|
167
172
|
}
|
|
168
173
|
s = new WeakMap(), w = new WeakMap(), k = new WeakMap(), C = new WeakMap(), S = new WeakMap();
|
|
169
|
-
customElements.get("e-popover-button") || customElements.define("e-popover-button",
|
|
174
|
+
customElements.get("e-popover-button") || customElements.define("e-popover-button", U);
|
|
170
175
|
export {
|
|
171
|
-
|
|
172
|
-
|
|
176
|
+
U as PopoverButtonElement,
|
|
177
|
+
x as PopoverElement
|
|
173
178
|
};
|