aptechka 0.36.0 → 0.36.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 -1
- package/lib/popover/index.cjs +1 -1
- package/lib/popover/index.js +16 -16
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ export declare class PopoverElement extends HTMLElement {
|
|
|
16
16
|
private static __opened;
|
|
17
17
|
get history(): CSSProperty<false>;
|
|
18
18
|
get restore(): CSSProperty<false>;
|
|
19
|
-
get dominance(): CSSProperty<
|
|
19
|
+
get dominance(): CSSProperty<number>;
|
|
20
20
|
get clickOutside(): CSSProperty<false>;
|
|
21
21
|
get escape(): CSSProperty<false>;
|
|
22
22
|
get opened(): Store<boolean>;
|
package/lib/popover/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var W=n=>{throw TypeError(n)};var B=(n,h,t)=>h.has(n)||W("Cannot "+t);var e=(n,h,t)=>(B(n,h,"read from private field"),t?t.call(n):h.get(n)),s=(n,h,t)=>h.has(n)?W("Cannot add the same private member more than once"):h instanceof WeakSet?h.add(n):h.set(n,t),i=(n,h,t,c)=>(B(n,h,"write to private field"),c?c.call(n,t):h.set(n,t),t),_=(n,h,t)=>(B(n,h,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../css-property/index.cjs"),K=require("../Store-CDb6RMce.cjs"),$=require("../events-KVanG9sR.cjs"),Q=require("../function-MthRj-GJ.cjs"),V=require("../style-At6aDoqG.cjs"),F=require("../window-resizer/vanilla/index.cjs"),X=require("../browser-CpzFX2xg.cjs");var A,l,x,b,d,v,p,g,m,f,L,u,G,E,N,w,j,T,C,q,P;const a=class a extends HTMLElement{constructor(){super(...arguments);s(this,u);s(this,A);s(this,l);s(this,x);s(this,b);s(this,d);s(this,v);s(this,p);s(this,g);s(this,m);s(this,f);s(this,L);s(this,E);s(this,w);s(this,T);s(this,C);s(this,q);s(this,P);i(this,A,-1),i(this,l,new K.Store(!1)),i(this,d,new k.CSSProperty(this,"--history",!1)),i(this,v,new k.CSSProperty(this,"--restore",!1)),i(this,p,new k.CSSProperty(this,"--dominance"
|
|
1
|
+
"use strict";var W=n=>{throw TypeError(n)};var B=(n,h,t)=>h.has(n)||W("Cannot "+t);var e=(n,h,t)=>(B(n,h,"read from private field"),t?t.call(n):h.get(n)),s=(n,h,t)=>h.has(n)?W("Cannot add the same private member more than once"):h instanceof WeakSet?h.add(n):h.set(n,t),i=(n,h,t,c)=>(B(n,h,"write to private field"),c?c.call(n,t):h.set(n,t),t),_=(n,h,t)=>(B(n,h,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../css-property/index.cjs"),K=require("../Store-CDb6RMce.cjs"),$=require("../events-KVanG9sR.cjs"),Q=require("../function-MthRj-GJ.cjs"),V=require("../style-At6aDoqG.cjs"),F=require("../window-resizer/vanilla/index.cjs"),X=require("../browser-CpzFX2xg.cjs");var A,l,x,b,d,v,p,g,m,f,L,u,G,E,N,w,j,T,C,q,P;const a=class a extends HTMLElement{constructor(){super(...arguments);s(this,u);s(this,A);s(this,l);s(this,x);s(this,b);s(this,d);s(this,v);s(this,p);s(this,g);s(this,m);s(this,f);s(this,L);s(this,E);s(this,w);s(this,T);s(this,C);s(this,q);s(this,P);i(this,A,-1),i(this,l,new K.Store(!1)),i(this,d,new k.CSSProperty(this,"--history",!1)),i(this,v,new k.CSSProperty(this,"--restore",!1)),i(this,p,new k.CSSProperty(this,"--dominance",-1)),i(this,g,new k.CSSProperty(this,"--click-outside",!1)),i(this,m,new k.CSSProperty(this,"--escape",!1)),i(this,f,!1),this.open=t=>{if(e(this,l).current)return;i(this,L,t==null?void 0:t.trigger),e(this,l).current=!0,e(this,p).current&&(a.__opened=a.__opened.filter(o=>o!==this&&o.dominance.current!==0&&this.dominance.current>=o.dominance.current?(o.close(),!1):!0)),a.__opened.push(this),i(this,A,a.__opened.length-1),e(this,d).current&&e(this,f)&&history.pushState("","",e(this,u,G)),clearTimeout(e(this,x)),this.classList.remove("closing"),this.classList.add("triggered"),this.style.display="block",$.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,L)}});const c=()=>{addEventListener("click",e(this,E)),addEventListener("keydown",e(this,w)),e(this,P).call(this),this.style.opacity="1",this.classList.add("opened"),$.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,L)}}),i(this,b,void 0)};t!=null&&t.skipTransition?c():i(this,b,setTimeout(c,10))},this.close=()=>{e(this,l).current&&(removeEventListener("click",e(this,E)),removeEventListener("keydown",e(this,w)),e(this,l).current=!1,a.__opened=a.__opened.filter(t=>t===this?!1:e(t,p).current!==0&&e(t,p).current<this.dominance.current&&!e(t,b)?(t.close(),!1):!0),_(this,u,N).call(this),this.classList.remove("opened"),this.classList.add("closing"),this.style.opacity="0",$.dispatchEvent(this,"popoverClosing",{custom:!0}),setTimeout(()=>{this.classList.remove("triggered"),this.classList.remove("closing"),this.style.display="none",$.dispatchEvent(this,"popoverClosed",{custom:!0})},V.getElementTransitionDurationMS(this)+10))},i(this,E,t=>{e(this,g).current&&_(this,u,j).call(this,()=>{var D;const c=t.composedPath();if(c.find(U=>U instanceof HTMLElement&&U.hasAttribute("data-popover-content")))return;const o=c[0],z=o instanceof HTMLElement&&(this.contains(o)||((D=this.shadowRoot)==null?void 0:D.contains(o))),S=o instanceof HTMLElement&&o.hasAttribute("data-outside");(!z||S)&&this.close()})}),i(this,w,t=>{e(this,m).current&&_(this,u,j).call(this,()=>{t.code==="Escape"&&this.close()})}),i(this,T,()=>{i(this,f,!1),e(this,l).current&&e(this,d).current&&!location.search.includes(this.id)?this.close():!e(this,l).current&&e(this,d).current&&location.search.includes(this.id)&&this.open(),i(this,f,!0)}),i(this,C,()=>{this.style.setProperty("--content-width","initial"),this.style.setProperty("--content-height","initial"),e(this,q).call(this)}),i(this,q,Q.debounce(()=>{e(this,P).call(this)},10)),i(this,P,()=>{this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px")})}get history(){return e(this,d)}get restore(){return e(this,v)}get dominance(){return e(this,p)}get clickOutside(){return e(this,g)}get escape(){return e(this,m)}get opened(){return e(this,l)}get lastTrigger(){return e(this,L)}connectedCallback(){e(this,d).observe(),e(this,v).observe(),e(this,p).observe(),e(this,g).observe(),e(this,m).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,T)),setTimeout(()=>{e(this,v).current?e(this,T).call(this):(_(this,u,N).call(this),i(this,f,!0))},0),F.windowResizer.subscribe(e(this,C))}disconnectedCallback(){F.windowResizer.unsubscribe(e(this,C)),e(this,d).unobserve(),e(this,v).unobserve(),e(this,p).unobserve(),e(this,g).unobserve(),e(this,m).unobserve(),this.style.opacity="",this.style.display="",this.removeAttribute("popover-target"),a.__opened=a.__opened.filter(t=>t!==this),clearTimeout(e(this,x)),clearTimeout(e(this,b)),removeEventListener("popstate",e(this,T)),removeEventListener("click",e(this,E)),removeEventListener("keydown",e(this,w)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height")}};A=new WeakMap,l=new WeakMap,x=new WeakMap,b=new WeakMap,d=new WeakMap,v=new WeakMap,p=new WeakMap,g=new WeakMap,m=new WeakMap,f=new WeakMap,L=new WeakMap,u=new WeakSet,G=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.id}`},E=new WeakMap,N=function(){if(e(this,d).current){const t=new URL(location.href);t.searchParams.delete(this.id),history.replaceState(null,"",t.href)}},w=new WeakMap,j=function(t){(a.__opened[e(this,A)-1]||a.__opened.length===1||a.__opened.filter(c=>c!==this).every(c=>e(this,p).current>c.dominance.current))&&t()},T=new WeakMap,C=new WeakMap,q=new WeakMap,P=new WeakMap,a.__opened=[];let I=a;customElements.get("e-popover")||customElements.define("e-popover",I);var r,y,M,O,R,H;class J extends HTMLElement{constructor(){super();s(this,r);s(this,y,new k.CSSProperty(this,"--type","open"));s(this,M,()=>{this.classList.add("triggered")});s(this,O,()=>{this.classList.add("opened"),this.setAttribute("aria-expanded","true")});s(this,R,()=>{this.classList.remove("opened")});s(this,H,()=>{this.classList.remove("triggered"),this.setAttribute("aria-expanded","false")});X.isBrowser&&(this.addEventListener("click",()=>{if(e(this,r)){const t=e(this,y).current;t==="open"||t==="toggle"&&!e(this,r).opened.current?e(this,r).open({trigger:this}):(t==="close"||t==="toggle"&&e(this,r).opened.current)&&e(this,r).close()}}),this.addEventListener("keydown",t=>{t.code==="Space"&&t.currentTarget.click()}))}get type(){return e(this,y)}get popoverElement(){return e(this,r)}connectedCallback(){var c;e(this,y).subscribe(o=>{e(this,r)&&(o.current!=="close"?(this.setAttribute("aria-has-popup","true"),this.setAttribute("aria-expanded",e(this,r).opened.current?"true":"false"),this.setAttribute("aria-controls",e(this,r).id||"")):(this.removeAttribute("aria-has-popup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls")))}),this.hasAttribute("tabindex")||(this.tabIndex=0);const t=this.getAttribute("target");if(t){let o=null;if(t==="parent"){const z=this.closest("[popover-target]");if(z)o=z;else{const S=this.getRootNode();S instanceof ShadowRoot?o=S.host.closest("[popover-target]"):S instanceof HTMLElement&&(o=S.closest("[popover-target]"))}}else t==="sibling"?o=(c=this.parentElement)==null?void 0:c.querySelector("[popover-target]"):o=document.querySelector(`#${t}`)||this.getRootNode().querySelector(`#${t}`);o instanceof HTMLElement?(i(this,r,o),e(this,r).addEventListener("popoverTriggered",e(this,M)),e(this,r).addEventListener("popoverOpened",e(this,O)),e(this,r).addEventListener("popoverClosing",e(this,R)),e(this,r).addEventListener("popoverClosed",e(this,H))):console.warn(this,`target ${t} not found`)}e(this,y).observe()}disconnectedCallback(){e(this,y).unobserve(),this.removeAttribute("aria-has-popup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),e(this,r)&&(e(this,r).removeEventListener("popoverTriggered",e(this,M)),e(this,r).removeEventListener("popoverOpened",e(this,O)),e(this,r).removeEventListener("popoverClosing",e(this,R)),e(this,r).removeEventListener("popoverClosed",e(this,H)))}}r=new WeakMap,y=new WeakMap,M=new WeakMap,O=new WeakMap,R=new WeakMap,H=new WeakMap;customElements.get("e-popover-button")||customElements.define("e-popover-button",J);exports.PopoverButtonElement=J;exports.PopoverElement=I;
|
package/lib/popover/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var j = (n) => {
|
|
|
2
2
|
throw TypeError(n);
|
|
3
3
|
};
|
|
4
4
|
var q = (n, h, t) => h.has(n) || j("Cannot " + t);
|
|
5
|
-
var e = (n, h, t) => (q(n, h, "read from private field"), t ? t.call(n) : h.get(n)), s = (n, h, t) => h.has(n) ? j("Cannot add the same private member more than once") : h instanceof WeakSet ? h.add(n) : h.set(n, t), i = (n, h, t,
|
|
5
|
+
var e = (n, h, t) => (q(n, h, "read from private field"), t ? t.call(n) : h.get(n)), s = (n, h, t) => h.has(n) ? j("Cannot add the same private member more than once") : h instanceof WeakSet ? h.add(n) : h.set(n, t), i = (n, h, t, c) => (q(n, h, "write to private field"), c ? c.call(n, t) : h.set(n, t), t), _ = (n, h, t) => (q(n, h, "access private method"), t);
|
|
6
6
|
import { CSSProperty as A } from "../css-property/index.js";
|
|
7
7
|
import { S as J } from "../Store-OTdcl6SX.js";
|
|
8
8
|
import { d as z } from "../events-CsVF98U6.js";
|
|
@@ -11,7 +11,7 @@ import { g as Q } from "../style-j2TwriJ_.js";
|
|
|
11
11
|
import { windowResizer as F } from "../window-resizer/vanilla/index.js";
|
|
12
12
|
import { i as V } from "../browser-0zX67oeU.js";
|
|
13
13
|
var S, l, P, y, d, v, p, m, g, f, b, u, G, E, B, T, D, w, x, H, C;
|
|
14
|
-
const
|
|
14
|
+
const a = class a extends HTMLElement {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
17
17
|
s(this, u);
|
|
@@ -32,16 +32,16 @@ const c = class c extends HTMLElement {
|
|
|
32
32
|
s(this, x);
|
|
33
33
|
s(this, H);
|
|
34
34
|
s(this, C);
|
|
35
|
-
i(this, S, -1), i(this, l, new J(!1)), i(this, d, new A(this, "--history", !1)), i(this, v, new A(this, "--restore", !1)), i(this, p, new A(this, "--dominance",
|
|
35
|
+
i(this, S, -1), i(this, l, new J(!1)), i(this, d, new A(this, "--history", !1)), i(this, v, new A(this, "--restore", !1)), i(this, p, new A(this, "--dominance", -1)), i(this, m, new A(this, "--click-outside", !1)), i(this, g, new A(this, "--escape", !1)), i(this, f, !1), this.open = (t) => {
|
|
36
36
|
if (e(this, l).current)
|
|
37
37
|
return;
|
|
38
|
-
i(this, b, t == null ? void 0 : t.trigger), e(this, l).current = !0, e(this, p).current && (
|
|
38
|
+
i(this, b, t == null ? void 0 : t.trigger), e(this, l).current = !0, e(this, p).current && (a.__opened = a.__opened.filter((o) => o !== this && o.dominance.current !== 0 && this.dominance.current >= o.dominance.current ? (o.close(), !1) : !0)), a.__opened.push(this), i(this, S, a.__opened.length - 1), e(this, d).current && e(this, f) && history.pushState("", "", e(this, u, G)), clearTimeout(e(this, P)), this.classList.remove("closing"), this.classList.add("triggered"), this.style.display = "block", z(this, "popoverTriggered", {
|
|
39
39
|
custom: !0,
|
|
40
40
|
detail: {
|
|
41
41
|
trigger: e(this, b)
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
|
-
const
|
|
44
|
+
const c = () => {
|
|
45
45
|
addEventListener("click", e(this, E)), addEventListener("keydown", e(this, T)), e(this, C).call(this), this.style.opacity = "1", this.classList.add("opened"), z(this, "popoverOpened", {
|
|
46
46
|
custom: !0,
|
|
47
47
|
detail: {
|
|
@@ -49,9 +49,9 @@ const c = class c extends HTMLElement {
|
|
|
49
49
|
}
|
|
50
50
|
}), i(this, y, void 0);
|
|
51
51
|
};
|
|
52
|
-
t != null && t.skipTransition ?
|
|
52
|
+
t != null && t.skipTransition ? c() : i(this, y, setTimeout(c, 10));
|
|
53
53
|
}, this.close = () => {
|
|
54
|
-
e(this, l).current && (removeEventListener("click", e(this, E)), removeEventListener("keydown", e(this, T)), e(this, l).current = !1,
|
|
54
|
+
e(this, l).current && (removeEventListener("click", e(this, E)), removeEventListener("keydown", e(this, T)), e(this, l).current = !1, a.__opened = a.__opened.filter((t) => t === this ? !1 : e(t, p).current !== 0 && e(t, p).current < this.dominance.current && !e(t, y) ? (t.close(), !1) : !0), _(this, u, B).call(this), this.classList.remove("opened"), this.classList.add("closing"), this.style.opacity = "0", z(this, "popoverClosing", {
|
|
55
55
|
custom: !0
|
|
56
56
|
}), setTimeout(() => {
|
|
57
57
|
this.classList.remove("triggered"), this.classList.remove("closing"), this.style.display = "none", z(this, "popoverClosed", {
|
|
@@ -61,12 +61,12 @@ const c = class c extends HTMLElement {
|
|
|
61
61
|
}, i(this, E, (t) => {
|
|
62
62
|
e(this, m).current && _(this, u, D).call(this, () => {
|
|
63
63
|
var U;
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
64
|
+
const c = t.composedPath();
|
|
65
|
+
if (c.find(
|
|
66
66
|
(W) => W instanceof HTMLElement && W.hasAttribute("data-popover-content")
|
|
67
67
|
))
|
|
68
68
|
return;
|
|
69
|
-
const o =
|
|
69
|
+
const o = c[0], I = o instanceof HTMLElement && (this.contains(o) || ((U = this.shadowRoot) == null ? void 0 : U.contains(o))), k = o instanceof HTMLElement && o.hasAttribute("data-outside");
|
|
70
70
|
(!I || k) && this.close();
|
|
71
71
|
});
|
|
72
72
|
}), i(this, T, (t) => {
|
|
@@ -110,7 +110,7 @@ const c = class c extends HTMLElement {
|
|
|
110
110
|
}, 0), F.subscribe(e(this, x));
|
|
111
111
|
}
|
|
112
112
|
disconnectedCallback() {
|
|
113
|
-
F.unsubscribe(e(this, x)), e(this, d).unobserve(), e(this, v).unobserve(), e(this, p).unobserve(), e(this, m).unobserve(), e(this, g).unobserve(), this.style.opacity = "", this.style.display = "", this.removeAttribute("popover-target"),
|
|
113
|
+
F.unsubscribe(e(this, x)), e(this, d).unobserve(), e(this, v).unobserve(), e(this, p).unobserve(), e(this, m).unobserve(), e(this, g).unobserve(), this.style.opacity = "", this.style.display = "", this.removeAttribute("popover-target"), a.__opened = a.__opened.filter((t) => t !== this), clearTimeout(e(this, P)), clearTimeout(e(this, y)), removeEventListener("popstate", e(this, w)), removeEventListener("click", e(this, E)), removeEventListener("keydown", e(this, T)), this.style.removeProperty("--content-width"), this.style.removeProperty("--content-height");
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
S = new WeakMap(), l = new WeakMap(), P = new WeakMap(), y = new WeakMap(), d = new WeakMap(), v = new WeakMap(), p = new WeakMap(), m = new WeakMap(), g = new WeakMap(), f = new WeakMap(), b = new WeakMap(), u = new WeakSet(), G = function() {
|
|
@@ -121,9 +121,9 @@ S = new WeakMap(), l = new WeakMap(), P = new WeakMap(), y = new WeakMap(), d =
|
|
|
121
121
|
t.searchParams.delete(this.id), history.replaceState(null, "", t.href);
|
|
122
122
|
}
|
|
123
123
|
}, T = new WeakMap(), D = function(t) {
|
|
124
|
-
(
|
|
125
|
-
}, w = new WeakMap(), x = new WeakMap(), H = new WeakMap(), C = new WeakMap(),
|
|
126
|
-
let N =
|
|
124
|
+
(a.__opened[e(this, S) - 1] || a.__opened.length === 1 || a.__opened.filter((c) => c !== this).every((c) => e(this, p).current > c.dominance.current)) && t();
|
|
125
|
+
}, w = new WeakMap(), x = new WeakMap(), H = new WeakMap(), C = new WeakMap(), a.__opened = [];
|
|
126
|
+
let N = a;
|
|
127
127
|
customElements.get("e-popover") || customElements.define("e-popover", N);
|
|
128
128
|
var r, L, M, O, R, $;
|
|
129
129
|
class X extends HTMLElement {
|
|
@@ -159,7 +159,7 @@ class X extends HTMLElement {
|
|
|
159
159
|
return e(this, r);
|
|
160
160
|
}
|
|
161
161
|
connectedCallback() {
|
|
162
|
-
var
|
|
162
|
+
var c;
|
|
163
163
|
e(this, L).subscribe((o) => {
|
|
164
164
|
e(this, r) && (o.current !== "close" ? (this.setAttribute("aria-has-popup", "true"), this.setAttribute(
|
|
165
165
|
"aria-expanded",
|
|
@@ -177,7 +177,7 @@ class X extends HTMLElement {
|
|
|
177
177
|
const k = this.getRootNode();
|
|
178
178
|
k instanceof ShadowRoot ? o = k.host.closest("[popover-target]") : k instanceof HTMLElement && (o = k.closest("[popover-target]"));
|
|
179
179
|
}
|
|
180
|
-
} else t === "sibling" ? o = (
|
|
180
|
+
} else t === "sibling" ? o = (c = this.parentElement) == null ? void 0 : c.querySelector("[popover-target]") : o = document.querySelector(`#${t}`) || this.getRootNode().querySelector(`#${t}`);
|
|
181
181
|
o instanceof HTMLElement ? (i(this, r, o), e(this, r).addEventListener(
|
|
182
182
|
"popoverTriggered",
|
|
183
183
|
e(this, M)
|