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