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