aptechka 0.40.2 → 0.40.4
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.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SourceElement } from '../source';
|
|
2
|
+
|
|
3
|
+
export declare class IFameElement extends SourceElement<HTMLElement> {
|
|
4
|
+
#private;
|
|
5
|
+
protected createConsumer(): HTMLDivElement;
|
|
6
|
+
protected consumeSource(code: string | null): void;
|
|
7
|
+
}
|
|
8
|
+
declare global {
|
|
9
|
+
interface HTMLElementTagNameMap {
|
|
10
|
+
'e-iframe': IFameElement;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var le=a=>{throw TypeError(a)};var ae=(a,n,t)=>n.has(a)||le("Cannot "+t);var e=(a,n,t)=>(ae(a,n,"read from private field"),t?t.call(a):n.get(a)),s=(a,n,t)=>n.has(a)?le("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(a):n.set(a,t),r=(a,n,t,i)=>(ae(a,n,"write to private field"),i?i.call(a,t):n.set(a,t),t),q=(a,n,t)=>(ae(a,n,"access private method"),t);var de=(a,n,t)=>new Promise((i,o)=>{var E=m=>{try{v(t.next(m))}catch(l){o(l)}},A=m=>{try{v(t.throw(m))}catch(l){o(l)}},v=m=>m.done?i(m.value):Promise.resolve(m.value).then(E,A);v((t=t.apply(a,n)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Se=require("../source/index.cjs"),we=require("../class-linked-status/index.cjs"),pe=require("../browser-CpzFX2xg.cjs"),V=require("../events-KVanG9sR.cjs"),Ee=require("../string-DhgS_iFl.cjs"),oe=require("../loading/index.cjs"),Ce=require("../device/index.cjs"),G=require("../css-property/index.cjs"),me=require("../element-resizer/vanilla/index.cjs"),fe=require("../canvas-CU5Xjahf.cjs"),Re=require("../canvas/index.cjs"),he=require("../ticker/vanilla/index.cjs");let Ie=0;var d,h,y,L,f,Y,P,c,U,B,S,M,J,Z,N,ee;class O extends HTMLElement{constructor(){super();s(this,M);s(this,d,null);s(this,h,null);s(this,y,!1);s(this,L,!1);s(this,f,!1);s(this,Y,"");s(this,P,"");s(this,c,new we.ClassLinkedStatus(this,{loading:!1,loaded:!1,error:!1,clear:!1}));s(this,U,null);s(this,B);s(this,S,null);s(this,Z,t=>{const i=t[0];e(this,f)&&(!e(this,L)||this.hasAttribute("reload-source"))&&i.isIntersecting&&this.triggerLazyLoad(),i.isIntersecting?V.dispatchEvent(this,"sourceCapture",{custom:!0}):(this.hasAttribute("reload-source")&&q(this,M,J).call(this,void 0),V.dispatchEvent(this,"sourceRelease",{custom:!0}))});s(this,N,()=>{e(this,c).set("loaded",!0),e(this,c).set("error",!1),e(this,c).set("loading",!1),!e(this,f)&&!e(this,y)&&oe.loading.complete(e(this,P)),V.dispatchEvent(this,"sourceLoaded",{custom:!0});const t=getComputedStyle(this).getPropertyValue("--clear-duration");t?r(this,B,setTimeout(()=>{e(this,c).set("clear",!0)},parseFloat(t)*1e3)):e(this,c).set("clear",!0),r(this,y,!0)});s(this,ee,t=>{e(this,c).set("loaded",!1),e(this,c).set("error",!0),e(this,c).set("loading",!1),!e(this,f)&&!e(this,y)&&oe.loading.error(e(this,P)),V.dispatchEvent(this,"sourceError",{custom:!0}),r(this,y,!0)});pe.isBrowser&&window.IntersectionObserver&&r(this,U,new IntersectionObserver(e(this,Z)))}get consumerElement(){return e(this,h)}get sourceManager(){return e(this,d)}get status(){return e(this,c)}get isLazy(){return e(this,f)}get currentURL(){return e(this,S)}get isFirstLoadHappened(){return e(this,y)}triggerLazyLoad(){!e(this,L)&&e(this,d).current&&e(this,d).current!==e(this,d).previous&&(r(this,L,!0),q(this,M,J).call(this,e(this,d).current))}connectedCallback(){r(this,Y,`source-consumer-${++Ie}`);const t=this.getAttribute("srcset");if(!t)return;const i=this.hasAttribute("notify")?this.closest(this.getAttribute("notify")):null;i&&e(this,c).addElement(i),r(this,h,this.createConsumer()),e(this,h).style.cssText=`
|
|
2
2
|
display: block;
|
|
3
3
|
width: 100%;
|
|
4
4
|
height: 100%;
|
|
5
|
-
`,e(this,h).classList.add("source-consumer"),Array.from(this.attributes).forEach(o=>{if(o.name!=="srcset"){const
|
|
5
|
+
`,e(this,h).classList.add("source-consumer"),Array.from(this.attributes).forEach(o=>{if(o.name!=="srcset"){const E=o.nodeValue||"",A=Ee.kebabToCamel(o.name);A in e(this,h)&&(e(this,h)[A]=E||!0)}}),this.appendChild(e(this,h)),r(this,d,new Se.SourceManager({srcset:t})),r(this,f,this.hasAttribute("lazy")),e(this,d).subscribe(o=>{(!e(this,f)||e(this,f)&&e(this,L))&&q(this,M,J).call(this,o.current)}),e(this,d).connect(),e(this,U).observe(this)}disconnectedCallback(){e(this,U).disconnect(),e(this,d).close(),e(this,h).onloadeddata=null,e(this,h).onload=null,e(this,h).onerror=null,r(this,y,!1),r(this,L,!1),e(this,h).remove(),e(this,c).reset(),clearTimeout(e(this,B))}}d=new WeakMap,h=new WeakMap,y=new WeakMap,L=new WeakMap,f=new WeakMap,Y=new WeakMap,P=new WeakMap,c=new WeakMap,U=new WeakMap,B=new WeakMap,S=new WeakMap,M=new WeakSet,J=function(t){if(clearTimeout(e(this,B)),e(this,h).onloadeddata=null,e(this,h).onload=null,e(this,h).onerror=null,e(this,c).set("loaded",!1),e(this,c).set("error",!1),e(this,c).set("loading",!1),e(this,c).set("clear",!1),t){r(this,P,`${e(this,Y)}-${t.url}`);const i=this.hasAttribute("keep-source-parameters");e(this,c).set("loading",!0),r(this,S,i?t.url:t.name+t.extension),this.consumeSource(e(this,S)),!e(this,f)&&!e(this,y)&&oe.loading.add(e(this,P)),e(this,h).onloadeddata=()=>{e(this,N).call(this)},e(this,h).onload=()=>{e(this,N).call(this)},e(this,h).onerror=()=>{e(this,ee).call(this,e(this,S))}}else r(this,S,null),this.consumeSource(null)},Z=new WeakMap,N=new WeakMap,ee=new WeakMap;var b,te,se;class ye extends O{constructor(){super(...arguments);s(this,b,null);s(this,te,()=>{var t,i;(i=(t=this.consumerElement).onload)==null||i.call(t,new Event("load"))});s(this,se,()=>{var t,i;(i=(t=this.consumerElement).onload)==null||i.call(t,new Event("error"))})}createConsumer(){return document.createElement("div")}consumeSource(t){e(this,b)&&(e(this,b).onload=null,e(this,b).onerror=null),this.consumerElement.innerHTML=(t==null?void 0:t.replace(/\\u003C/g,"<").replace(/\\u003E/g,">").replace(/\\"/g,'"'))||"",r(this,b,this.consumerElement.querySelector("iframe")),e(this,b)&&(e(this,b).onload=e(this,te),e(this,b).onerror=e(this,se))}}b=new WeakMap,te=new WeakMap,se=new WeakMap;customElements.get("e-iframe")||customElements.define("e-iframe",ye);class be extends O{createConsumer(){return document.createElement("img")}consumeSource(n){if(n&&this.hasAttribute("webp")&&Ce.device.isWebp){const t=n.split(".").slice(0,-1).join(".")+".webp";this.consumerElement.src=t}else this.consumerElement.src=n||""}}customElements.get("e-image")||customElements.define("e-image",be);function Ae(a){const n=a.match(/\{([\d-]+)\}/);if(n){const t=n[1].split("-");if(t.length===2){const i=parseInt(t[0],10),o=parseInt(t[1],10);return{start:i,end:o}}}return null}var p,k,F,w,C,x,T,j,g,R;class ge extends O{constructor(t){super();s(this,p,[]);s(this,k,new G.CSSProperty(this,"--fit","contain"));s(this,F,new G.CSSProperty(this,"--autoplay",!1));s(this,w,new G.CSSProperty(this,"--offset-x",.5));s(this,C,new G.CSSProperty(this,"--offset-y",.5));s(this,x,null);s(this,T,0);s(this,j,1);s(this,g,()=>{if(e(this,p).length){const t=e(this,p)[0];e(this,k).current==="cover"?r(this,x,fe.cover(t.naturalWidth,t.naturalHeight,this.consumerElement.width,this.consumerElement.height,e(this,w).current,e(this,C).current)):r(this,x,fe.contain(t.naturalWidth,t.naturalHeight,this.consumerElement.width,this.consumerElement.height,e(this,w).current,e(this,C).current))}});s(this,R,t=>{if(this.status.isFalse("loaded")||!e(this,x))return;t.detail.context.clearRect(0,0,t.detail.width,t.detail.height);const i=e(this,p)[e(this,T)];i&&t.detail.context.drawImage(i,...e(this,x)),e(this,F).current&&r(this,T,(e(this,T)+1)%e(this,p).length)});pe.isBrowser&&(r(this,j,parseInt(((t==null?void 0:t.pad)||this.getAttribute("pad")||"1").toString())),e(this,k).subscribe(e(this,g)),e(this,w).subscribe(e(this,g)),e(this,C).subscribe(e(this,g)),this.addEventListener("sourceCapture",i=>{this.consumerElement.addEventListener("canvasRender",e(this,R))}),this.addEventListener("sourceRelease",i=>{this.consumerElement.removeEventListener("canvasRender",e(this,R))}))}setProgress(t){e(this,p).length&&r(this,T,Math.floor((e(this,p).length-1)*t))}connectedCallback(){super.connectedCallback(),e(this,F).observe(),e(this,k).observe(),e(this,w).observe(),e(this,C).observe(),me.elementResizer.subscribe(this,e(this,g))}disconnectedCallback(){super.disconnectedCallback(),e(this,F).unobserve(),e(this,k).unobserve(),e(this,w).unobserve(),e(this,C).unobserve(),r(this,p,[]),me.elementResizer.unsubscribe(e(this,g)),this.consumerElement.removeEventListener("canvasRender",e(this,R))}createConsumer(){return new Re.CanvasElement}consumeSource(t){return de(this,null,function*(){var i,o,E,A;if(t){this.consumerElement.removeEventListener("canvasRender",e(this,R));const v=[],m=Ae(t);if(m)for(let l=m.start;l<=m.end;l++){const ue=t.replace(/\{([^}]+)\}/,l.toString().padStart(e(this,j),"0")),X=new Image;X.src=ue,v.push(X)}else{const l=new Image;l.src=t,v.push(l)}try{yield Promise.all(v.map((l,ue)=>new Promise((X,Le)=>{l.onload=()=>{X()},l.onerror=Pe=>{Le(`${l.src} Image not found`)}}))),r(this,p,v),e(this,g).call(this),(o=(i=this.consumerElement).onload)==null||o.call(i,new Event("load")),this.isLazy||this.consumerElement.addEventListener("canvasRender",e(this,R))}catch(l){console.error(l),(A=(E=this.consumerElement).onerror)==null||A.call(E,new Event("error"))}}})}}p=new WeakMap,k=new WeakMap,F=new WeakMap,w=new WeakMap,C=new WeakMap,x=new WeakMap,T=new WeakMap,j=new WeakMap,g=new WeakMap,R=new WeakMap;customElements.get("e-sequence")||customElements.define("e-sequence",ge);var _,H;class ve extends O{constructor(){super(...arguments);s(this,_,0);s(this,H,()=>{this.classList.add(`state-${this.consumerElement.readyState}`);const t=this.consumerElement.readyState/4;t>e(this,_)&&r(this,_,t),V.dispatchEvent(this,"videoReadyStateChange",{detail:{readyState:this.consumerElement.readyState,progress:e(this,_)}}),this.consumerElement.readyState===4&&he.ticker.unsubscribe(e(this,H))})}connectedCallback(){super.connectedCallback(),this.addEventListener("sourceCapture",()=>{he.ticker.subscribe(e(this,H)),this.hasAttribute("capture-autoplay")&&this.consumerElement.play()}),this.addEventListener("sourceRelease",()=>{this.hasAttribute("capture-autoplay")&&(this.consumerElement.pause(),this.hasAttribute("replay")&&(this.consumerElement.currentTime=0)),this.hasAttribute("reload-source")&&this.classList.remove("state-0","state-1","state-2","state-3","state-4")})}disconnectedCallback(){super.disconnectedCallback(),he.ticker.unsubscribe(e(this,H)),r(this,_,0)}createConsumer(){return document.createElement("video")}consumeSource(t){this.consumerElement.src=t||"",this.consumerElement.autoplay=!0}}_=new WeakMap,H=new WeakMap;customElements.get("e-video")||customElements.define("e-video",ve);var u,W,I,D,$,ie,re,ne,K,ce;const z=class z extends O{constructor(){super();s(this,K);s(this,u);s(this,W);s(this,I,!1);s(this,D,!1);s(this,$,()=>{r(this,I,e(this,I)||this.hasAttribute("autoplay")&&!this.hasAttribute("capture-autoplay")),r(this,u,new window.YT.Player(e(this,W),{playerVars:{mute:this.hasAttribute("muted")?1:0,controls:this.hasAttribute("controls")?1:0},events:{onReady:e(this,ie),onError:e(this,re),onStateChange:e(this,ne)}}))});s(this,ie,()=>{r(this,D,!0),q(this,K,ce).call(this)});s(this,re,t=>{var i,o;console.error("YouTube: Ошибка при загрузке видео:",this.currentURL,t),(o=(i=this.consumerElement).onerror)==null||o.call(i,new Event("error"))});s(this,ne,()=>{});r(this,W,"yt-"+Ee.generateId(10)),z.__apiReady||(window.onYouTubeIframeAPIReady=()=>{z.__apiReady=!0,V.dispatchEvent(window,"youTubeIframeAPIReady")}),this.addEventListener("sourceCapture",()=>{this.hasAttribute("capture-autoplay")&&(e(this,D)?e(this,u).playVideo():r(this,I,!0))}),this.addEventListener("sourceRelease",()=>{e(this,u)&&this.hasAttribute("capture-autoplay")&&(e(this,u).pauseVideo(),this.hasAttribute("replay")&&e(this,u).seekTo(0))})}static __onYouTubeIframeAPIReady(){this.__apiReady=!0}createConsumer(){const t=document.createElement("div");return t.id=e(this,W),t}consumeSource(t){var i;if(t){if(!document.getElementById("youtube-script")){const o=document.createElement("script");o.id,o.src="https://www.youtube.com/iframe_api";const E=document.getElementsByTagName("script")[0];(i=E.parentNode)==null||i.insertBefore(o,E)}e(this,u)?q(this,K,ce).call(this):z.__apiReady?e(this,$).call(this):addEventListener("youTubeIframeAPIReady",e(this,$))}else e(this,u)&&e(this,u).stopVideo()}disconnectedCallback(){super.disconnectedCallback(),e(this,u)&&e(this,u).destroy(),removeEventListener("youTubeIframeAPIReady",e(this,$))}};u=new WeakMap,W=new WeakMap,I=new WeakMap,D=new WeakMap,$=new WeakMap,ie=new WeakMap,re=new WeakMap,ne=new WeakMap,K=new WeakSet,ce=function(){var t,i;this.currentURL&&(this.currentURL.startsWith("http")?e(this,u).loadVideoByUrl(this.currentURL):e(this,u).loadVideoById(this.currentURL)),e(this,I)?e(this,u).playVideo():e(this,u).stopVideo(),r(this,I,!1),(i=(t=this.consumerElement).onload)==null||i.call(t,new Event("load"))},z.__apiReady=!1;let Q=z;customElements.get("e-youtube")||customElements.define("e-youtube",Q);exports.IFameElement=ye;exports.ImageElement=be;exports.SequenceElement=ge;exports.SourceElement=O;exports.VideoElement=ve;exports.YouTubeElement=Q;
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ue = (a) => {
|
|
2
2
|
throw TypeError(a);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var e = (a, n, t) => (
|
|
6
|
-
var
|
|
4
|
+
var ne = (a, n, t) => n.has(a) || ue("Cannot " + t);
|
|
5
|
+
var e = (a, n, t) => (ne(a, n, "read from private field"), t ? t.call(a) : n.get(a)), s = (a, n, t) => n.has(a) ? ue("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(a) : n.set(a, t), r = (a, n, t, i) => (ne(a, n, "write to private field"), i ? i.call(a, t) : n.set(a, t), t), U = (a, n, t) => (ne(a, n, "access private method"), t);
|
|
6
|
+
var de = (a, n, t) => new Promise((i, o) => {
|
|
7
7
|
var y = (m) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
} catch (
|
|
11
|
-
o(
|
|
9
|
+
v(t.next(m));
|
|
10
|
+
} catch (u) {
|
|
11
|
+
o(u);
|
|
12
12
|
}
|
|
13
|
-
},
|
|
13
|
+
}, A = (m) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
o(
|
|
15
|
+
v(t.throw(m));
|
|
16
|
+
} catch (u) {
|
|
17
|
+
o(u);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, v = (m) => m.done ? i(m.value) : Promise.resolve(m.value).then(y, A);
|
|
20
|
+
v((t = t.apply(a, n)).next());
|
|
21
21
|
});
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import { CSSProperty as
|
|
30
|
-
import { elementResizer as
|
|
31
|
-
import { c as
|
|
32
|
-
import { CanvasElement as
|
|
33
|
-
import { ticker as
|
|
34
|
-
let
|
|
35
|
-
var d, h,
|
|
36
|
-
class
|
|
22
|
+
import { SourceManager as ye } from "../source/index.js";
|
|
23
|
+
import { ClassLinkedStatus as Ee } from "../class-linked-status/index.js";
|
|
24
|
+
import { i as fe } from "../browser-0zX67oeU.js";
|
|
25
|
+
import { d as z } from "../events-CsVF98U6.js";
|
|
26
|
+
import { k as be, g as ge } from "../string-f0Dnk0L1.js";
|
|
27
|
+
import { loading as ae } from "../loading/index.js";
|
|
28
|
+
import { device as ve } from "../device/index.js";
|
|
29
|
+
import { CSSProperty as G } from "../css-property/index.js";
|
|
30
|
+
import { elementResizer as me } from "../element-resizer/vanilla/index.js";
|
|
31
|
+
import { c as Le, a as we } from "../canvas-DeZ0SLUJ.js";
|
|
32
|
+
import { CanvasElement as Ce } from "../canvas/index.js";
|
|
33
|
+
import { ticker as oe } from "../ticker/vanilla/index.js";
|
|
34
|
+
let Se = 0;
|
|
35
|
+
var d, h, E, L, f, N, k, c, B, H, w, M, J, Q, O, Z;
|
|
36
|
+
class K extends HTMLElement {
|
|
37
37
|
constructor() {
|
|
38
38
|
super();
|
|
39
|
-
s(this,
|
|
39
|
+
s(this, M);
|
|
40
40
|
s(this, d, null);
|
|
41
41
|
s(this, h, null);
|
|
42
|
-
s(this,
|
|
43
|
-
s(this,
|
|
42
|
+
s(this, E, !1);
|
|
43
|
+
s(this, L, !1);
|
|
44
44
|
s(this, f, !1);
|
|
45
|
-
s(this,
|
|
46
|
-
s(this,
|
|
47
|
-
s(this, c, new
|
|
45
|
+
s(this, N, "");
|
|
46
|
+
s(this, k, "");
|
|
47
|
+
s(this, c, new Ee(this, {
|
|
48
48
|
loading: !1,
|
|
49
49
|
loaded: !1,
|
|
50
50
|
error: !1,
|
|
51
51
|
clear: !1
|
|
52
52
|
}));
|
|
53
|
-
s(this,
|
|
54
|
-
s(this,
|
|
55
|
-
s(this,
|
|
56
|
-
s(this,
|
|
53
|
+
s(this, B, null);
|
|
54
|
+
s(this, H);
|
|
55
|
+
s(this, w, null);
|
|
56
|
+
s(this, Q, (t) => {
|
|
57
57
|
const i = t[0];
|
|
58
|
-
e(this, f) && (!e(this,
|
|
58
|
+
e(this, f) && (!e(this, L) || this.hasAttribute("reload-source")) && i.isIntersecting && this.triggerLazyLoad(), i.isIntersecting ? z(this, "sourceCapture", { custom: !0 }) : (this.hasAttribute("reload-source") && U(this, M, J).call(this, void 0), z(this, "sourceRelease", { custom: !0 }));
|
|
59
59
|
});
|
|
60
|
-
s(this,
|
|
61
|
-
e(this, c).set("loaded", !0), e(this, c).set("error", !1), e(this, c).set("loading", !1), !e(this, f) && !e(this,
|
|
60
|
+
s(this, O, () => {
|
|
61
|
+
e(this, c).set("loaded", !0), e(this, c).set("error", !1), e(this, c).set("loading", !1), !e(this, f) && !e(this, E) && ae.complete(e(this, k)), z(this, "sourceLoaded", { custom: !0 });
|
|
62
62
|
const t = getComputedStyle(this).getPropertyValue("--clear-duration");
|
|
63
|
-
t ? r(this,
|
|
63
|
+
t ? r(this, H, setTimeout(() => {
|
|
64
64
|
e(this, c).set("clear", !0);
|
|
65
|
-
}, parseFloat(t) * 1e3)) : e(this, c).set("clear", !0), r(this,
|
|
65
|
+
}, parseFloat(t) * 1e3)) : e(this, c).set("clear", !0), r(this, E, !0);
|
|
66
66
|
});
|
|
67
|
-
s(this,
|
|
68
|
-
e(this, c).set("loaded", !1), e(this, c).set("error", !0), e(this, c).set("loading", !1), !e(this, f) && !e(this,
|
|
67
|
+
s(this, Z, (t) => {
|
|
68
|
+
e(this, c).set("loaded", !1), e(this, c).set("error", !0), e(this, c).set("loading", !1), !e(this, f) && !e(this, E) && ae.error(e(this, k)), z(this, "sourceError", { custom: !0 }), r(this, E, !0);
|
|
69
69
|
});
|
|
70
|
-
|
|
71
|
-
e(this,
|
|
70
|
+
fe && window.IntersectionObserver && r(this, B, new IntersectionObserver(
|
|
71
|
+
e(this, Q)
|
|
72
72
|
));
|
|
73
73
|
}
|
|
74
74
|
get consumerElement() {
|
|
@@ -84,16 +84,16 @@ class te extends HTMLElement {
|
|
|
84
84
|
return e(this, f);
|
|
85
85
|
}
|
|
86
86
|
get currentURL() {
|
|
87
|
-
return e(this,
|
|
87
|
+
return e(this, w);
|
|
88
88
|
}
|
|
89
89
|
get isFirstLoadHappened() {
|
|
90
|
-
return e(this,
|
|
90
|
+
return e(this, E);
|
|
91
91
|
}
|
|
92
92
|
triggerLazyLoad() {
|
|
93
|
-
!e(this,
|
|
93
|
+
!e(this, L) && e(this, d).current && e(this, d).current !== e(this, d).previous && (r(this, L, !0), U(this, M, J).call(this, e(this, d).current));
|
|
94
94
|
}
|
|
95
95
|
connectedCallback() {
|
|
96
|
-
r(this,
|
|
96
|
+
r(this, N, `source-consumer-${++Se}`);
|
|
97
97
|
const t = this.getAttribute("srcset");
|
|
98
98
|
if (!t) return;
|
|
99
99
|
const i = this.hasAttribute("notify") ? this.closest(this.getAttribute("notify")) : null;
|
|
@@ -103,47 +103,70 @@ class te extends HTMLElement {
|
|
|
103
103
|
height: 100%;
|
|
104
104
|
`, e(this, h).classList.add("source-consumer"), Array.from(this.attributes).forEach((o) => {
|
|
105
105
|
if (o.name !== "srcset") {
|
|
106
|
-
const y = o.nodeValue || "",
|
|
107
|
-
|
|
106
|
+
const y = o.nodeValue || "", A = be(o.name);
|
|
107
|
+
A in e(this, h) && (e(this, h)[A] = y || !0);
|
|
108
108
|
}
|
|
109
|
-
}), this.appendChild(e(this, h)), r(this, d, new
|
|
109
|
+
}), this.appendChild(e(this, h)), r(this, d, new ye({
|
|
110
110
|
srcset: t
|
|
111
111
|
})), r(this, f, this.hasAttribute("lazy")), e(this, d).subscribe((o) => {
|
|
112
|
-
(!e(this, f) || e(this, f) && e(this,
|
|
113
|
-
}), e(this, d).connect(), e(this,
|
|
112
|
+
(!e(this, f) || e(this, f) && e(this, L)) && U(this, M, J).call(this, o.current);
|
|
113
|
+
}), e(this, d).connect(), e(this, B).observe(this);
|
|
114
114
|
}
|
|
115
115
|
disconnectedCallback() {
|
|
116
|
-
e(this,
|
|
116
|
+
e(this, B).disconnect(), e(this, d).close(), e(this, h).onloadeddata = null, e(this, h).onload = null, e(this, h).onerror = null, r(this, E, !1), r(this, L, !1), e(this, h).remove(), e(this, c).reset(), clearTimeout(e(this, H));
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
d = new WeakMap(), h = new WeakMap(),
|
|
120
|
-
if (clearTimeout(e(this,
|
|
121
|
-
r(this,
|
|
119
|
+
d = new WeakMap(), h = new WeakMap(), E = new WeakMap(), L = new WeakMap(), f = new WeakMap(), N = new WeakMap(), k = new WeakMap(), c = new WeakMap(), B = new WeakMap(), H = new WeakMap(), w = new WeakMap(), M = new WeakSet(), J = function(t) {
|
|
120
|
+
if (clearTimeout(e(this, H)), e(this, h).onloadeddata = null, e(this, h).onload = null, e(this, h).onerror = null, e(this, c).set("loaded", !1), e(this, c).set("error", !1), e(this, c).set("loading", !1), e(this, c).set("clear", !1), t) {
|
|
121
|
+
r(this, k, `${e(this, N)}-${t.url}`);
|
|
122
122
|
const i = this.hasAttribute("keep-source-parameters");
|
|
123
|
-
e(this, c).set("loading", !0), r(this,
|
|
124
|
-
e(this,
|
|
123
|
+
e(this, c).set("loading", !0), r(this, w, i ? t.url : t.name + t.extension), this.consumeSource(e(this, w)), !e(this, f) && !e(this, E) && ae.add(e(this, k)), e(this, h).onloadeddata = () => {
|
|
124
|
+
e(this, O).call(this);
|
|
125
125
|
}, e(this, h).onload = () => {
|
|
126
|
-
e(this,
|
|
126
|
+
e(this, O).call(this);
|
|
127
127
|
}, e(this, h).onerror = () => {
|
|
128
|
-
e(this,
|
|
128
|
+
e(this, Z).call(this, e(this, w));
|
|
129
129
|
};
|
|
130
130
|
} else
|
|
131
|
-
r(this,
|
|
132
|
-
},
|
|
133
|
-
|
|
131
|
+
r(this, w, null), this.consumeSource(null);
|
|
132
|
+
}, Q = new WeakMap(), O = new WeakMap(), Z = new WeakMap();
|
|
133
|
+
var b, ee, te;
|
|
134
|
+
class Re extends K {
|
|
135
|
+
constructor() {
|
|
136
|
+
super(...arguments);
|
|
137
|
+
s(this, b, null);
|
|
138
|
+
s(this, ee, () => {
|
|
139
|
+
var t, i;
|
|
140
|
+
(i = (t = this.consumerElement).onload) == null || i.call(t, new Event("load"));
|
|
141
|
+
});
|
|
142
|
+
s(this, te, () => {
|
|
143
|
+
var t, i;
|
|
144
|
+
(i = (t = this.consumerElement).onload) == null || i.call(t, new Event("error"));
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
createConsumer() {
|
|
148
|
+
return document.createElement("div");
|
|
149
|
+
}
|
|
150
|
+
consumeSource(t) {
|
|
151
|
+
e(this, b) && (e(this, b).onload = null, e(this, b).onerror = null), this.consumerElement.innerHTML = (t == null ? void 0 : t.replace(/\\u003C/g, "<").replace(/\\u003E/g, ">").replace(/\\"/g, '"')) || "", r(this, b, this.consumerElement.querySelector("iframe")), e(this, b) && (e(this, b).onload = e(this, ee), e(this, b).onerror = e(this, te));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
b = new WeakMap(), ee = new WeakMap(), te = new WeakMap();
|
|
155
|
+
customElements.get("e-iframe") || customElements.define("e-iframe", Re);
|
|
156
|
+
class Ie extends K {
|
|
134
157
|
createConsumer() {
|
|
135
158
|
return document.createElement("img");
|
|
136
159
|
}
|
|
137
160
|
consumeSource(n) {
|
|
138
|
-
if (n && this.hasAttribute("webp") &&
|
|
161
|
+
if (n && this.hasAttribute("webp") && ve.isWebp) {
|
|
139
162
|
const t = n.split(".").slice(0, -1).join(".") + ".webp";
|
|
140
163
|
this.consumerElement.src = t;
|
|
141
164
|
} else
|
|
142
165
|
this.consumerElement.src = n || "";
|
|
143
166
|
}
|
|
144
167
|
}
|
|
145
|
-
customElements.get("e-image") || customElements.define("e-image",
|
|
146
|
-
function
|
|
168
|
+
customElements.get("e-image") || customElements.define("e-image", Ie);
|
|
169
|
+
function Ae(a) {
|
|
147
170
|
const n = a.match(/\{([\d-]+)\}/);
|
|
148
171
|
if (n) {
|
|
149
172
|
const t = n[1].split("-");
|
|
@@ -154,140 +177,140 @@ function Ce(a) {
|
|
|
154
177
|
}
|
|
155
178
|
return null;
|
|
156
179
|
}
|
|
157
|
-
var p,
|
|
158
|
-
class
|
|
180
|
+
var p, P, F, C, S, T, x, Y, g, R;
|
|
181
|
+
class ke extends K {
|
|
159
182
|
constructor(t) {
|
|
160
183
|
super();
|
|
161
184
|
s(this, p, []);
|
|
162
|
-
s(this,
|
|
185
|
+
s(this, P, new G(
|
|
163
186
|
this,
|
|
164
187
|
"--fit",
|
|
165
188
|
"contain"
|
|
166
189
|
));
|
|
167
|
-
s(this,
|
|
168
|
-
s(this,
|
|
169
|
-
s(this,
|
|
170
|
-
s(this,
|
|
171
|
-
s(this,
|
|
172
|
-
s(this,
|
|
190
|
+
s(this, F, new G(this, "--autoplay", !1));
|
|
191
|
+
s(this, C, new G(this, "--offset-x", 0.5));
|
|
192
|
+
s(this, S, new G(this, "--offset-y", 0.5));
|
|
193
|
+
s(this, T, null);
|
|
194
|
+
s(this, x, 0);
|
|
195
|
+
s(this, Y, 1);
|
|
173
196
|
s(this, g, () => {
|
|
174
197
|
if (e(this, p).length) {
|
|
175
198
|
const t = e(this, p)[0];
|
|
176
|
-
e(this,
|
|
199
|
+
e(this, P).current === "cover" ? r(this, T, Le(
|
|
177
200
|
t.naturalWidth,
|
|
178
201
|
t.naturalHeight,
|
|
179
202
|
this.consumerElement.width,
|
|
180
203
|
this.consumerElement.height,
|
|
181
|
-
e(this,
|
|
182
|
-
e(this,
|
|
183
|
-
)) : r(this,
|
|
204
|
+
e(this, C).current,
|
|
205
|
+
e(this, S).current
|
|
206
|
+
)) : r(this, T, we(
|
|
184
207
|
t.naturalWidth,
|
|
185
208
|
t.naturalHeight,
|
|
186
209
|
this.consumerElement.width,
|
|
187
210
|
this.consumerElement.height,
|
|
188
|
-
e(this,
|
|
189
|
-
e(this,
|
|
211
|
+
e(this, C).current,
|
|
212
|
+
e(this, S).current
|
|
190
213
|
));
|
|
191
214
|
}
|
|
192
215
|
});
|
|
193
|
-
s(this,
|
|
194
|
-
if (this.status.isFalse("loaded") || !e(this,
|
|
216
|
+
s(this, R, (t) => {
|
|
217
|
+
if (this.status.isFalse("loaded") || !e(this, T))
|
|
195
218
|
return;
|
|
196
219
|
t.detail.context.clearRect(0, 0, t.detail.width, t.detail.height);
|
|
197
|
-
const i = e(this, p)[e(this,
|
|
198
|
-
i && t.detail.context.drawImage(i, ...e(this,
|
|
220
|
+
const i = e(this, p)[e(this, x)];
|
|
221
|
+
i && t.detail.context.drawImage(i, ...e(this, T)), e(this, F).current && r(this, x, (e(this, x) + 1) % e(this, p).length);
|
|
199
222
|
});
|
|
200
|
-
|
|
223
|
+
fe && (r(this, Y, parseInt(
|
|
201
224
|
((t == null ? void 0 : t.pad) || this.getAttribute("pad") || "1").toString()
|
|
202
|
-
)), e(this,
|
|
225
|
+
)), e(this, P).subscribe(e(this, g)), e(this, C).subscribe(e(this, g)), e(this, S).subscribe(e(this, g)), this.addEventListener("sourceCapture", (i) => {
|
|
203
226
|
this.consumerElement.addEventListener(
|
|
204
227
|
"canvasRender",
|
|
205
|
-
e(this,
|
|
228
|
+
e(this, R)
|
|
206
229
|
);
|
|
207
230
|
}), this.addEventListener("sourceRelease", (i) => {
|
|
208
231
|
this.consumerElement.removeEventListener(
|
|
209
232
|
"canvasRender",
|
|
210
|
-
e(this,
|
|
233
|
+
e(this, R)
|
|
211
234
|
);
|
|
212
235
|
}));
|
|
213
236
|
}
|
|
214
237
|
setProgress(t) {
|
|
215
|
-
e(this, p).length && r(this,
|
|
238
|
+
e(this, p).length && r(this, x, Math.floor((e(this, p).length - 1) * t));
|
|
216
239
|
}
|
|
217
240
|
connectedCallback() {
|
|
218
|
-
super.connectedCallback(), e(this,
|
|
241
|
+
super.connectedCallback(), e(this, F).observe(), e(this, P).observe(), e(this, C).observe(), e(this, S).observe(), me.subscribe(this, e(this, g));
|
|
219
242
|
}
|
|
220
243
|
disconnectedCallback() {
|
|
221
|
-
super.disconnectedCallback(), e(this,
|
|
244
|
+
super.disconnectedCallback(), e(this, F).unobserve(), e(this, P).unobserve(), e(this, C).unobserve(), e(this, S).unobserve(), r(this, p, []), me.unsubscribe(e(this, g)), this.consumerElement.removeEventListener(
|
|
222
245
|
"canvasRender",
|
|
223
|
-
e(this,
|
|
246
|
+
e(this, R)
|
|
224
247
|
);
|
|
225
248
|
}
|
|
226
249
|
createConsumer() {
|
|
227
|
-
return new
|
|
250
|
+
return new Ce();
|
|
228
251
|
}
|
|
229
252
|
consumeSource(t) {
|
|
230
|
-
return
|
|
231
|
-
var i, o, y,
|
|
253
|
+
return de(this, null, function* () {
|
|
254
|
+
var i, o, y, A;
|
|
232
255
|
if (t) {
|
|
233
256
|
this.consumerElement.removeEventListener(
|
|
234
257
|
"canvasRender",
|
|
235
|
-
e(this,
|
|
258
|
+
e(this, R)
|
|
236
259
|
);
|
|
237
|
-
const
|
|
260
|
+
const v = [], m = Ae(t);
|
|
238
261
|
if (m)
|
|
239
|
-
for (let
|
|
240
|
-
const
|
|
262
|
+
for (let u = m.start; u <= m.end; u++) {
|
|
263
|
+
const le = t.replace(
|
|
241
264
|
/\{([^}]+)\}/,
|
|
242
|
-
|
|
243
|
-
),
|
|
244
|
-
|
|
265
|
+
u.toString().padStart(e(this, Y), "0")
|
|
266
|
+
), X = new Image();
|
|
267
|
+
X.src = le, v.push(X);
|
|
245
268
|
}
|
|
246
269
|
else {
|
|
247
|
-
const
|
|
248
|
-
|
|
270
|
+
const u = new Image();
|
|
271
|
+
u.src = t, v.push(u);
|
|
249
272
|
}
|
|
250
273
|
try {
|
|
251
274
|
yield Promise.all(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
},
|
|
256
|
-
|
|
275
|
+
v.map((u, le) => new Promise((X, pe) => {
|
|
276
|
+
u.onload = () => {
|
|
277
|
+
X();
|
|
278
|
+
}, u.onerror = (Te) => {
|
|
279
|
+
pe(`${u.src} Image not found`);
|
|
257
280
|
};
|
|
258
281
|
}))
|
|
259
|
-
), r(this, p,
|
|
282
|
+
), r(this, p, v), e(this, g).call(this), (o = (i = this.consumerElement).onload) == null || o.call(i, new Event("load")), this.isLazy || this.consumerElement.addEventListener(
|
|
260
283
|
"canvasRender",
|
|
261
|
-
e(this,
|
|
284
|
+
e(this, R)
|
|
262
285
|
);
|
|
263
|
-
} catch (
|
|
264
|
-
console.error(
|
|
286
|
+
} catch (u) {
|
|
287
|
+
console.error(u), (A = (y = this.consumerElement).onerror) == null || A.call(y, new Event("error"));
|
|
265
288
|
}
|
|
266
289
|
}
|
|
267
290
|
});
|
|
268
291
|
}
|
|
269
292
|
}
|
|
270
|
-
p = new WeakMap(),
|
|
271
|
-
customElements.get("e-sequence") || customElements.define("e-sequence",
|
|
272
|
-
var
|
|
273
|
-
class
|
|
293
|
+
p = new WeakMap(), P = new WeakMap(), F = new WeakMap(), C = new WeakMap(), S = new WeakMap(), T = new WeakMap(), x = new WeakMap(), Y = new WeakMap(), g = new WeakMap(), R = new WeakMap();
|
|
294
|
+
customElements.get("e-sequence") || customElements.define("e-sequence", ke);
|
|
295
|
+
var V, W;
|
|
296
|
+
class Pe extends K {
|
|
274
297
|
constructor() {
|
|
275
298
|
super(...arguments);
|
|
276
|
-
s(this,
|
|
299
|
+
s(this, V, 0);
|
|
277
300
|
s(this, W, () => {
|
|
278
301
|
this.classList.add(`state-${this.consumerElement.readyState}`);
|
|
279
302
|
const t = this.consumerElement.readyState / 4;
|
|
280
|
-
t > e(this,
|
|
303
|
+
t > e(this, V) && r(this, V, t), z(this, "videoReadyStateChange", {
|
|
281
304
|
detail: {
|
|
282
305
|
readyState: this.consumerElement.readyState,
|
|
283
|
-
progress: e(this,
|
|
306
|
+
progress: e(this, V)
|
|
284
307
|
}
|
|
285
|
-
}), this.consumerElement.readyState === 4 &&
|
|
308
|
+
}), this.consumerElement.readyState === 4 && oe.unsubscribe(e(this, W));
|
|
286
309
|
});
|
|
287
310
|
}
|
|
288
311
|
connectedCallback() {
|
|
289
312
|
super.connectedCallback(), this.addEventListener("sourceCapture", () => {
|
|
290
|
-
|
|
313
|
+
oe.subscribe(e(this, W)), this.hasAttribute("capture-autoplay") && this.consumerElement.play();
|
|
291
314
|
}), this.addEventListener("sourceRelease", () => {
|
|
292
315
|
this.hasAttribute("capture-autoplay") && (this.consumerElement.pause(), this.hasAttribute("replay") && (this.consumerElement.currentTime = 0)), this.hasAttribute("reload-source") && this.classList.remove(
|
|
293
316
|
"state-0",
|
|
@@ -299,7 +322,7 @@ class Re extends te {
|
|
|
299
322
|
});
|
|
300
323
|
}
|
|
301
324
|
disconnectedCallback() {
|
|
302
|
-
super.disconnectedCallback(),
|
|
325
|
+
super.disconnectedCallback(), oe.unsubscribe(e(this, W)), r(this, V, 0);
|
|
303
326
|
}
|
|
304
327
|
createConsumer() {
|
|
305
328
|
return document.createElement("video");
|
|
@@ -308,45 +331,45 @@ class Re extends te {
|
|
|
308
331
|
this.consumerElement.src = t || "", this.consumerElement.autoplay = !0;
|
|
309
332
|
}
|
|
310
333
|
}
|
|
311
|
-
|
|
312
|
-
customElements.get("e-video") || customElements.define("e-video",
|
|
313
|
-
var
|
|
314
|
-
const
|
|
334
|
+
V = new WeakMap(), W = new WeakMap();
|
|
335
|
+
customElements.get("e-video") || customElements.define("e-video", Pe);
|
|
336
|
+
var l, $, I, D, q, se, ie, re, j, ce;
|
|
337
|
+
const _ = class _ extends K {
|
|
315
338
|
constructor() {
|
|
316
339
|
super();
|
|
317
|
-
s(this,
|
|
318
|
-
s(this,
|
|
340
|
+
s(this, j);
|
|
341
|
+
s(this, l);
|
|
319
342
|
s(this, $);
|
|
320
|
-
s(this,
|
|
321
|
-
s(this,
|
|
322
|
-
s(this,
|
|
323
|
-
r(this,
|
|
343
|
+
s(this, I, !1);
|
|
344
|
+
s(this, D, !1);
|
|
345
|
+
s(this, q, () => {
|
|
346
|
+
r(this, I, e(this, I) || this.hasAttribute("autoplay") && !this.hasAttribute("capture-autoplay")), r(this, l, new window.YT.Player(e(this, $), {
|
|
324
347
|
playerVars: {
|
|
325
348
|
mute: this.hasAttribute("muted") ? 1 : 0,
|
|
326
349
|
controls: this.hasAttribute("controls") ? 1 : 0
|
|
327
350
|
},
|
|
328
351
|
events: {
|
|
329
|
-
onReady: e(this,
|
|
330
|
-
onError: e(this,
|
|
331
|
-
onStateChange: e(this,
|
|
352
|
+
onReady: e(this, se),
|
|
353
|
+
onError: e(this, ie),
|
|
354
|
+
onStateChange: e(this, re)
|
|
332
355
|
}
|
|
333
356
|
}));
|
|
334
357
|
});
|
|
335
|
-
s(this,
|
|
336
|
-
r(this,
|
|
358
|
+
s(this, se, () => {
|
|
359
|
+
r(this, D, !0), U(this, j, ce).call(this);
|
|
337
360
|
});
|
|
338
|
-
s(this,
|
|
361
|
+
s(this, ie, (t) => {
|
|
339
362
|
var i, o;
|
|
340
363
|
console.error("YouTube: Ошибка при загрузке видео:", this.currentURL, t), (o = (i = this.consumerElement).onerror) == null || o.call(i, new Event("error"));
|
|
341
364
|
});
|
|
342
|
-
s(this,
|
|
365
|
+
s(this, re, () => {
|
|
343
366
|
});
|
|
344
|
-
r(this, $, "yt-" +
|
|
345
|
-
|
|
367
|
+
r(this, $, "yt-" + ge(10)), _.__apiReady || (window.onYouTubeIframeAPIReady = () => {
|
|
368
|
+
_.__apiReady = !0, z(window, "youTubeIframeAPIReady");
|
|
346
369
|
}), this.addEventListener("sourceCapture", () => {
|
|
347
|
-
this.hasAttribute("capture-autoplay") && (e(this,
|
|
370
|
+
this.hasAttribute("capture-autoplay") && (e(this, D) ? e(this, l).playVideo() : r(this, I, !0));
|
|
348
371
|
}), this.addEventListener("sourceRelease", () => {
|
|
349
|
-
e(this,
|
|
372
|
+
e(this, l) && this.hasAttribute("capture-autoplay") && (e(this, l).pauseVideo(), this.hasAttribute("replay") && e(this, l).seekTo(0));
|
|
350
373
|
});
|
|
351
374
|
}
|
|
352
375
|
static __onYouTubeIframeAPIReady() {
|
|
@@ -365,23 +388,24 @@ const z = class z extends te {
|
|
|
365
388
|
const y = document.getElementsByTagName("script")[0];
|
|
366
389
|
(i = y.parentNode) == null || i.insertBefore(o, y);
|
|
367
390
|
}
|
|
368
|
-
e(this,
|
|
369
|
-
} else e(this,
|
|
391
|
+
e(this, l) ? U(this, j, ce).call(this) : _.__apiReady ? e(this, q).call(this) : addEventListener("youTubeIframeAPIReady", e(this, q));
|
|
392
|
+
} else e(this, l) && e(this, l).stopVideo();
|
|
370
393
|
}
|
|
371
394
|
disconnectedCallback() {
|
|
372
|
-
super.disconnectedCallback(), e(this,
|
|
395
|
+
super.disconnectedCallback(), e(this, l) && e(this, l).destroy(), removeEventListener("youTubeIframeAPIReady", e(this, q));
|
|
373
396
|
}
|
|
374
397
|
};
|
|
375
|
-
|
|
398
|
+
l = new WeakMap(), $ = new WeakMap(), I = new WeakMap(), D = new WeakMap(), q = new WeakMap(), se = new WeakMap(), ie = new WeakMap(), re = new WeakMap(), j = new WeakSet(), ce = function() {
|
|
376
399
|
var t, i;
|
|
377
|
-
this.currentURL && (this.currentURL.startsWith("http") ? e(this,
|
|
378
|
-
},
|
|
379
|
-
let
|
|
380
|
-
customElements.get("e-youtube") || customElements.define("e-youtube",
|
|
400
|
+
this.currentURL && (this.currentURL.startsWith("http") ? e(this, l).loadVideoByUrl(this.currentURL) : e(this, l).loadVideoById(this.currentURL)), e(this, I) ? e(this, l).playVideo() : e(this, l).stopVideo(), r(this, I, !1), (i = (t = this.consumerElement).onload) == null || i.call(t, new Event("load"));
|
|
401
|
+
}, _.__apiReady = !1;
|
|
402
|
+
let he = _;
|
|
403
|
+
customElements.get("e-youtube") || customElements.define("e-youtube", he);
|
|
381
404
|
export {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
405
|
+
Re as IFameElement,
|
|
406
|
+
Ie as ImageElement,
|
|
407
|
+
ke as SequenceElement,
|
|
408
|
+
K as SourceElement,
|
|
409
|
+
Pe as VideoElement,
|
|
410
|
+
he as YouTubeElement
|
|
387
411
|
};
|
package/lib/popover/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var F=n=>{throw TypeError(n)};var W=(n,c,t)=>c.has(n)||F("Cannot "+t);var e=(n,c,t)=>(W(n,c,"read from private field"),t?t.call(n):c.get(n)),s=(n,c,t)=>c.has(n)?F("Cannot add the same private member more than once"):c instanceof WeakSet?c.add(n):c.set(n,t),i=(n,c,t,h)=>(W(n,c,"write to private field"),h?h.call(n,t):c.set(n,t),t),v=(n,c,t)=>(W(n,c,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("../css-property/index.cjs"),X=require("../Store-C2J4Q87x.cjs"),I=require("../events-KVanG9sR.cjs"),Y=require("../function-MthRj-GJ.cjs"),Z=require("../style-At6aDoqG.cjs"),G=require("../url-BiHPIsKq.cjs"),J=require("../window-resizer/vanilla/index.cjs"),ee=require("../browser-CpzFX2xg.cjs");var C,d,O,S,u,m,p,g,f,y,b,w,l,K,T,N,A,B,k,_,R,x,D;const a=class a extends HTMLElement{constructor(){super(...arguments);s(this,l);s(this,C);s(this,d);s(this,O);s(this,S);s(this,u);s(this,m);s(this,p);s(this,g);s(this,f);s(this,y);s(this,b);s(this,w);s(this,T);s(this,A);s(this,k);s(this,_);s(this,R);s(this,x);this.urlValue="",i(this,C,-1),i(this,d,new X.Store(!1)),i(this,u,new E.CSSProperty(this,"--history",!1)),i(this,m,new E.CSSProperty(this,"--restore",!1)),i(this,p,new E.CSSProperty(this,"--dominance",0)),i(this,g,new E.CSSProperty(this,"--group","")),i(this,f,new E.CSSProperty(this,"--click-outside",!1)),i(this,y,new E.CSSProperty(this,"--escape",!1)),i(this,b,!1),this.open=t=>{if(e(this,d).current)return;i(this,w,t==null?void 0:t.trigger),e(this,p).current&&(a.__opened=a.__opened.filter(o=>o!==this&&v(this,l,D).call(this,this,o)?(o.close(),!1):!0)),a.__opened.push(this),i(this,C,a.__opened.length-1),clearTimeout(e(this,O)),this.classList.remove("closing"),this.classList.add("triggered"),this.style.display="block",I.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,w)}}),e(this,u).current&&e(this,b)&&history.pushState(history.state,"",e(this,l,K)),e(this,d).current=!0;const h=()=>{addEventListener("click",e(this,T)),addEventListener("keydown",e(this,A)),e(this,x).call(this),this.style.opacity="1",this.classList.add("opened"),I.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,w)}}),i(this,S,void 0),this.setAttribute("aria-hidden","false")};t!=null&&t.skipTransition?h():i(this,S,setTimeout(h,10))},this.close=()=>{e(this,d).current&&(removeEventListener("click",e(this,T)),removeEventListener("keydown",e(this,A)),e(this,d).current=!1,a.__opened=a.__opened.filter(t=>t===this?!1:!e(t,S)&&v(this,l,D).call(this,this,t)?(t.close(),!1):!0),v(this,l,N).call(this),this.classList.remove("opened"),this.classList.add("closing"),this.setAttribute("aria-hidden","true"),this.style.opacity="0",I.dispatchEvent(this,"popoverClosing",{custom:!0}),setTimeout(()=>{this.classList.remove("triggered"),this.classList.remove("closing"),this.style.display="none",I.dispatchEvent(this,"popoverClosed",{custom:!0})},Z.getElementTransitionDurationMS(this)+10))},i(this,T,t=>{e(this,f).current&&v(this,l,B).call(this,()=>{var U;const h=t.composedPath();if(h.find(j=>j instanceof HTMLElement&&j.hasAttribute("data-popover-content")))return;const o=h[0],z=o instanceof Node&&(this.contains(o)||((U=this.shadowRoot)==null?void 0:U.contains(o))),P=o instanceof HTMLElement&&o.hasAttribute("data-outside");(!z||P)&&this.close()})}),i(this,A,t=>{e(this,y).current&&v(this,l,B).call(this,()=>{t.code==="Escape"&&this.close()})}),i(this,k,()=>{i(this,b,!1),e(this,d).current&&e(this,u).current&&!location.search.includes(this.id)?this.close():!e(this,d).current&&e(this,u).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),i(this,b,!0)}),i(this,_,()=>{this.style.setProperty("--content-width","initial"),this.style.setProperty("--content-height","initial"),e(this,R).call(this)}),i(this,R,Y.debounce(()=>{e(this,x).call(this)},10)),i(this,x,()=>{this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px")})}get history(){return e(this,u)}get restore(){return e(this,m)}get dominance(){return e(this,p)}get group(){return e(this,g)}get clickOutside(){return e(this,f)}get escape(){return e(this,y)}get opened(){return e(this,d)}get lastTrigger(){return e(this,w)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(t){this.urlValue=(t==null?void 0:t.toString())||"",e(this,d).current&&G.updateSearchParameter(this.id,t)}connectedCallback(){e(this,u).observe(),e(this,m).observe(),e(this,p).observe(),e(this,g).observe(),e(this,f).observe(),e(this,y).observe(),this.style.opacity="0",this.style.display="none",this.setAttribute("role","dialog"),this.setAttribute("aria-hidden","true"),this.classList.remove("closing"),this.classList.remove("closed"),this.classList.remove("triggered"),this.classList.remove("opened"),addEventListener("popstate",e(this,k)),setTimeout(()=>{e(this,m).current?(this.urlValue=G.parseSearchParameters(location.search)[this.id],e(this,k).call(this)):(v(this,l,N).call(this),i(this,b,!0))},0),J.windowResizer.subscribe(e(this,_))}disconnectedCallback(){J.windowResizer.unsubscribe(e(this,_)),e(this,u).close(),e(this,m).close(),e(this,p).close(),e(this,g).close(),e(this,f).close(),e(this,y).close(),this.style.opacity="",this.style.display="",this.removeAttribute("role"),this.removeAttribute("aria-hidden"),a.__opened=a.__opened.filter(t=>t!==this),clearTimeout(e(this,O)),clearTimeout(e(this,S)),removeEventListener("popstate",e(this,k)),removeEventListener("click",e(this,T)),removeEventListener("keydown",e(this,A)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),v(this,l,N).call(this)}};C=new WeakMap,d=new WeakMap,O=new WeakMap,S=new WeakMap,u=new WeakMap,m=new WeakMap,p=new WeakMap,g=new WeakMap,f=new WeakMap,y=new WeakMap,b=new WeakMap,w=new WeakMap,l=new WeakSet,K=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},T=new WeakMap,N=function(){if(e(this,u).current){const t=new URL(location.href);t.searchParams.delete(this.id),history.replaceState(history.state,"",t.href)}},A=new WeakMap,B=function(t){(a.__opened[e(this,C)-1]||a.__opened.length===1||a.__opened.filter(h=>h!==this).every(h=>e(this,p).current>h.dominance.current))&&t()},k=new WeakMap,_=new WeakMap,R=new WeakMap,x=new WeakMap,D=function(t,h){if(e(t,g).current===e(h,g).current&&t.dominance.current>=h.dominance.current)return!0},a.__opened=[];let q=a;customElements.get("e-popover")||customElements.define("e-popover",q);var r,L,V,M,$,H;class Q extends HTMLElement{constructor(){super();s(this,r);s(this,L,new E.CSSProperty(this,"--type","open"));s(this,V,()=>{this.classList.add("triggered")});s(this,M,()=>{this.classList.add("opened"),this.setAttribute("aria-expanded","true")});s(this,$,()=>{this.classList.remove("opened")});s(this,H,()=>{this.classList.remove("triggered"),this.setAttribute("aria-expanded","false")});ee.isBrowser&&(this.addEventListener("click",()=>{if(e(this,r)){const t=e(this,L).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,L)}get popoverElement(){return e(this,r)}connectedCallback(){var h;e(this,L).subscribe(o=>{e(this,r)instanceof q&&(o.current!=="close"?(this.setAttribute("aria-
|
|
1
|
+
"use strict";var F=n=>{throw TypeError(n)};var W=(n,c,t)=>c.has(n)||F("Cannot "+t);var e=(n,c,t)=>(W(n,c,"read from private field"),t?t.call(n):c.get(n)),s=(n,c,t)=>c.has(n)?F("Cannot add the same private member more than once"):c instanceof WeakSet?c.add(n):c.set(n,t),i=(n,c,t,h)=>(W(n,c,"write to private field"),h?h.call(n,t):c.set(n,t),t),v=(n,c,t)=>(W(n,c,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("../css-property/index.cjs"),X=require("../Store-C2J4Q87x.cjs"),I=require("../events-KVanG9sR.cjs"),Y=require("../function-MthRj-GJ.cjs"),Z=require("../style-At6aDoqG.cjs"),G=require("../url-BiHPIsKq.cjs"),J=require("../window-resizer/vanilla/index.cjs"),ee=require("../browser-CpzFX2xg.cjs");var C,d,O,S,u,m,p,g,f,y,b,w,l,K,T,N,A,B,k,_,R,x,D;const a=class a extends HTMLElement{constructor(){super(...arguments);s(this,l);s(this,C);s(this,d);s(this,O);s(this,S);s(this,u);s(this,m);s(this,p);s(this,g);s(this,f);s(this,y);s(this,b);s(this,w);s(this,T);s(this,A);s(this,k);s(this,_);s(this,R);s(this,x);this.urlValue="",i(this,C,-1),i(this,d,new X.Store(!1)),i(this,u,new E.CSSProperty(this,"--history",!1)),i(this,m,new E.CSSProperty(this,"--restore",!1)),i(this,p,new E.CSSProperty(this,"--dominance",0)),i(this,g,new E.CSSProperty(this,"--group","")),i(this,f,new E.CSSProperty(this,"--click-outside",!1)),i(this,y,new E.CSSProperty(this,"--escape",!1)),i(this,b,!1),this.open=t=>{if(e(this,d).current)return;i(this,w,t==null?void 0:t.trigger),e(this,p).current&&(a.__opened=a.__opened.filter(o=>o!==this&&v(this,l,D).call(this,this,o)?(o.close(),!1):!0)),a.__opened.push(this),i(this,C,a.__opened.length-1),clearTimeout(e(this,O)),this.classList.remove("closing"),this.classList.add("triggered"),this.style.display="block",I.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,w)}}),e(this,u).current&&e(this,b)&&history.pushState(history.state,"",e(this,l,K)),e(this,d).current=!0;const h=()=>{addEventListener("click",e(this,T)),addEventListener("keydown",e(this,A)),e(this,x).call(this),this.style.opacity="1",this.classList.add("opened"),I.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,w)}}),i(this,S,void 0),this.setAttribute("aria-hidden","false")};t!=null&&t.skipTransition?h():i(this,S,setTimeout(h,10))},this.close=()=>{e(this,d).current&&(removeEventListener("click",e(this,T)),removeEventListener("keydown",e(this,A)),e(this,d).current=!1,a.__opened=a.__opened.filter(t=>t===this?!1:!e(t,S)&&v(this,l,D).call(this,this,t)?(t.close(),!1):!0),v(this,l,N).call(this),this.classList.remove("opened"),this.classList.add("closing"),this.setAttribute("aria-hidden","true"),this.style.opacity="0",I.dispatchEvent(this,"popoverClosing",{custom:!0}),setTimeout(()=>{this.classList.remove("triggered"),this.classList.remove("closing"),this.style.display="none",I.dispatchEvent(this,"popoverClosed",{custom:!0})},Z.getElementTransitionDurationMS(this)+10))},i(this,T,t=>{e(this,f).current&&v(this,l,B).call(this,()=>{var U;const h=t.composedPath();if(h.find(j=>j instanceof HTMLElement&&j.hasAttribute("data-popover-content")))return;const o=h[0],z=o instanceof Node&&(this.contains(o)||((U=this.shadowRoot)==null?void 0:U.contains(o))),P=o instanceof HTMLElement&&o.hasAttribute("data-outside");(!z||P)&&this.close()})}),i(this,A,t=>{e(this,y).current&&v(this,l,B).call(this,()=>{t.code==="Escape"&&this.close()})}),i(this,k,()=>{i(this,b,!1),e(this,d).current&&e(this,u).current&&!location.search.includes(this.id)?this.close():!e(this,d).current&&e(this,u).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),i(this,b,!0)}),i(this,_,()=>{this.style.setProperty("--content-width","initial"),this.style.setProperty("--content-height","initial"),e(this,R).call(this)}),i(this,R,Y.debounce(()=>{e(this,x).call(this)},10)),i(this,x,()=>{this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px")})}get history(){return e(this,u)}get restore(){return e(this,m)}get dominance(){return e(this,p)}get group(){return e(this,g)}get clickOutside(){return e(this,f)}get escape(){return e(this,y)}get opened(){return e(this,d)}get lastTrigger(){return e(this,w)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(t){this.urlValue=(t==null?void 0:t.toString())||"",e(this,d).current&&G.updateSearchParameter(this.id,t)}connectedCallback(){e(this,u).observe(),e(this,m).observe(),e(this,p).observe(),e(this,g).observe(),e(this,f).observe(),e(this,y).observe(),this.style.opacity="0",this.style.display="none",this.setAttribute("role","dialog"),this.setAttribute("aria-hidden","true"),this.classList.remove("closing"),this.classList.remove("closed"),this.classList.remove("triggered"),this.classList.remove("opened"),addEventListener("popstate",e(this,k)),setTimeout(()=>{e(this,m).current?(this.urlValue=G.parseSearchParameters(location.search)[this.id],e(this,k).call(this)):(v(this,l,N).call(this),i(this,b,!0))},0),J.windowResizer.subscribe(e(this,_))}disconnectedCallback(){J.windowResizer.unsubscribe(e(this,_)),e(this,u).close(),e(this,m).close(),e(this,p).close(),e(this,g).close(),e(this,f).close(),e(this,y).close(),this.style.opacity="",this.style.display="",this.removeAttribute("role"),this.removeAttribute("aria-hidden"),a.__opened=a.__opened.filter(t=>t!==this),clearTimeout(e(this,O)),clearTimeout(e(this,S)),removeEventListener("popstate",e(this,k)),removeEventListener("click",e(this,T)),removeEventListener("keydown",e(this,A)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),v(this,l,N).call(this)}};C=new WeakMap,d=new WeakMap,O=new WeakMap,S=new WeakMap,u=new WeakMap,m=new WeakMap,p=new WeakMap,g=new WeakMap,f=new WeakMap,y=new WeakMap,b=new WeakMap,w=new WeakMap,l=new WeakSet,K=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},T=new WeakMap,N=function(){if(e(this,u).current){const t=new URL(location.href);t.searchParams.delete(this.id),history.replaceState(history.state,"",t.href)}},A=new WeakMap,B=function(t){(a.__opened[e(this,C)-1]||a.__opened.length===1||a.__opened.filter(h=>h!==this).every(h=>e(this,p).current>h.dominance.current))&&t()},k=new WeakMap,_=new WeakMap,R=new WeakMap,x=new WeakMap,D=function(t,h){if(e(t,g).current===e(h,g).current&&t.dominance.current>=h.dominance.current)return!0},a.__opened=[];let q=a;customElements.get("e-popover")||customElements.define("e-popover",q);var r,L,V,M,$,H;class Q extends HTMLElement{constructor(){super();s(this,r);s(this,L,new E.CSSProperty(this,"--type","open"));s(this,V,()=>{this.classList.add("triggered")});s(this,M,()=>{this.classList.add("opened"),this.setAttribute("aria-expanded","true")});s(this,$,()=>{this.classList.remove("opened")});s(this,H,()=>{this.classList.remove("triggered"),this.setAttribute("aria-expanded","false")});ee.isBrowser&&(this.addEventListener("click",()=>{if(e(this,r)){const t=e(this,L).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,L)}get popoverElement(){return e(this,r)}connectedCallback(){var h;e(this,L).subscribe(o=>{e(this,r)instanceof q&&(o.current!=="close"?(this.setAttribute("aria-haspopup","true"),this.setAttribute("aria-expanded",e(this,r).opened.current?"true":"false"),this.setAttribute("aria-controls",e(this,r).id||"")):(this.removeAttribute("aria-haspopup"),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 P=this.getRootNode();P instanceof ShadowRoot?o=P.host.closest("[popover-target]"):P instanceof HTMLElement&&(o=P.closest("[popover-target]"))}}else t==="sibling"?o=(h=this.parentElement)==null?void 0:h.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,V)),e(this,r).addEventListener("popoverOpened",e(this,M)),e(this,r).addEventListener("popoverClosing",e(this,$)),e(this,r).addEventListener("popoverClosed",e(this,H))):console.warn(this,`target ${t} not found`)}this.isConnected&&e(this,L).observe()}disconnectedCallback(){e(this,L).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),e(this,r)&&(e(this,r).removeEventListener("popoverTriggered",e(this,V)),e(this,r).removeEventListener("popoverOpened",e(this,M)),e(this,r).removeEventListener("popoverClosing",e(this,$)),e(this,r).removeEventListener("popoverClosed",e(this,H)))}}r=new WeakMap,L=new WeakMap,V=new WeakMap,M=new WeakMap,$=new WeakMap,H=new WeakMap;customElements.get("e-popover-button")||customElements.define("e-popover-button",Q);exports.PopoverButtonElement=Q;exports.PopoverElement=q;
|
package/lib/popover/index.js
CHANGED
|
@@ -175,10 +175,10 @@ class te extends HTMLElement {
|
|
|
175
175
|
connectedCallback() {
|
|
176
176
|
var h;
|
|
177
177
|
e(this, b).subscribe((o) => {
|
|
178
|
-
e(this, r) instanceof W && (o.current !== "close" ? (this.setAttribute("aria-
|
|
178
|
+
e(this, r) instanceof W && (o.current !== "close" ? (this.setAttribute("aria-haspopup", "true"), this.setAttribute(
|
|
179
179
|
"aria-expanded",
|
|
180
180
|
e(this, r).opened.current ? "true" : "false"
|
|
181
|
-
), this.setAttribute("aria-controls", e(this, r).id || "")) : (this.removeAttribute("aria-
|
|
181
|
+
), this.setAttribute("aria-controls", e(this, r).id || "")) : (this.removeAttribute("aria-haspopup"), this.removeAttribute("aria-expanded"), this.removeAttribute("aria-controls")));
|
|
182
182
|
}), this.hasAttribute("tabindex") || (this.tabIndex = 0);
|
|
183
183
|
const t = this.getAttribute("target");
|
|
184
184
|
if (t) {
|
|
@@ -209,7 +209,7 @@ class te extends HTMLElement {
|
|
|
209
209
|
this.isConnected && e(this, b).observe();
|
|
210
210
|
}
|
|
211
211
|
disconnectedCallback() {
|
|
212
|
-
e(this, b).unobserve(), this.removeAttribute("aria-
|
|
212
|
+
e(this, b).unobserve(), this.removeAttribute("aria-haspopup"), this.removeAttribute("aria-expanded"), this.removeAttribute("aria-controls"), e(this, r) && (e(this, r).removeEventListener(
|
|
213
213
|
"popoverTriggered",
|
|
214
214
|
e(this, $)
|
|
215
215
|
), e(this, r).removeEventListener(
|