aptechka 0.4.19 → 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.
|
@@ -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
|
};
|