aptechka 0.73.0 → 0.73.2
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/morph/index.cjs +1 -1
- package/lib/morph/index.js +272 -267
- package/lib/popover/PopoverElement.d.ts +1 -0
- package/lib/popover/index.cjs +1 -1
- package/lib/popover/index.js +111 -107
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ export declare class PopoverElement extends HTMLElement {
|
|
|
19
19
|
get closingClass(): string | null;
|
|
20
20
|
get history(): CSSProperty<false>;
|
|
21
21
|
get restore(): CSSProperty<false>;
|
|
22
|
+
get dispatchResize(): CSSProperty<false>;
|
|
22
23
|
get closeRest(): CSSProperty<boolean>;
|
|
23
24
|
get closeRestInGroup(): CSSProperty<boolean>;
|
|
24
25
|
get group(): CSSProperty<"">;
|
package/lib/popover/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var oe=l=>{throw TypeError(l)};var ee=(l,n,t)=>n.has(l)||oe("Cannot "+t);var e=(l,n,t)=>(ee(l,n,"read from private field"),t?t.call(l):n.get(l)),r=(l,n,t)=>n.has(l)?oe("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(l):n.set(l,t),o=(l,n,t,s)=>(ee(l,n,"write to private field"),s?s.call(l,t):n.set(l,t),t),p=(l,n,t)=>(ee(l,n,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ue=require("../element-linked-store/index.cjs"),E=require("../css-property/index.cjs"),ie=require("../index-DekP7OZe.cjs"),M=require("../events-KVanG9sR.cjs"),pe=require("../function-MthRj-GJ.cjs"),ne=require("../style-At6aDoqG.cjs");require("construct-style-sheets-polyfill");const he=require("../url-DGcX4fGV.cjs"),le=require("../window-resizer/index.cjs"),Q=require("../Viewport-DB0qAZPJ.cjs");var d,w,_,N;class de{constructor(){r(this,d,new Map);r(this,w,[]);r(this,_,n=>{var s;const t=[...e(this,w)].reverse().find(i=>i.clickOutside.current);if(t){const i=n.composedPath();if(i.find(re=>re instanceof HTMLElement&&re.hasAttribute("data-popover-content")))return;const c=i[0],f=c instanceof Node&&(t.contains(c)||((s=t.shadowRoot)==null?void 0:s.contains(c))),F=c instanceof HTMLElement&&c.hasAttribute("data-outside");(!f||F)&&t.close()}});r(this,N,n=>{if(n.code==="Escape"){const t=[...e(this,w)].reverse().find(s=>s.escape.current);t&&t.close()}});document.documentElement.addEventListener("click",e(this,_)),addEventListener("keydown",e(this,N))}get groups(){return e(this,d)}get stack(){return e(this,w)}add(n,t){if(t.closeRest.current)e(this,d).forEach(i=>{i.forEach(c=>{c.close()})});else if(t.closeRestInGroup.current){let i=e(this,d).get(n);i==null||i.forEach(c=>{c.close()})}let s=e(this,d).get(n);s!=null&&s.length||(s=[],e(this,d).set(n,s)),e(this,w).push(t),s.push(t)}remove(n,t){if(setTimeout(()=>{o(this,w,e(this,w).filter(s=>s!==t))}),t.closeRest.current){let s=[];e(this,d).forEach(i=>{i.forEach(c=>s.push(c))}),e(this,d).clear(),s.forEach(i=>i.close())}else if(t.closeRestInGroup.current){const s=e(this,d).get(n);e(this,d).delete(n),s==null||s.forEach(i=>{i.close()})}else{let s=e(this,d).get(n);s&&(s=s.filter(i=>i!==t),e(this,d).set(n,s))}}}d=new WeakMap,w=new WeakMap,_=new WeakMap,N=new WeakMap;var v,z,B,k,H,m,T,A,x,b,R,q,C,y,$,a,V,W,u,ce,L,Z,G,O,j,X,D;const S=class S extends HTMLElement{constructor(){super();r(this,u);r(this,v);r(this,z);r(this,B);r(this,k);r(this,H);r(this,m);r(this,T);r(this,A);r(this,x);r(this,b);r(this,R);r(this,q);r(this,C);r(this,y);r(this,$);r(this,a);r(this,V);r(this,W);r(this,G);r(this,O);r(this,j);r(this,X);r(this,D);this.urlValue="",o(this,v,!1),o(this,m,new E.CSSProperty(this,"--history",!1)),o(this,T,new E.CSSProperty(this,"--restore",!1)),o(this,A,new E.CSSProperty(this,"--close-rest",!1)),o(this,x,new E.CSSProperty(this,"--close-rest-in-group",!1)),o(this,b,new E.CSSProperty(this,"--group","")),o(this,R,new E.CSSProperty(this,"--click-outside",!1)),o(this,q,new E.CSSProperty(this,"--escape",!1)),o(this,C,new E.CSSProperty(this,"--check-viewport-bounds",!1)),o(this,y,!0),o(this,a,new ue.ElementLinkedStore(this,{triggered:!1,beforeopen:!1,opened:!1,closing:!1,transitionend:!1})),o(this,V,[]),o(this,W,[]),o(this,G,()=>{o(this,y,!1),e(this,v)&&e(this,m).current&&!location.search.includes(this.id)?this.close():!e(this,v)&&e(this,m).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),o(this,y,!0)}),o(this,O,()=>{this.style.setProperty("--content-width","initial"),this.style.setProperty("--content-height","initial"),this.style.setProperty("--viewport-offset-x","0px"),this.style.setProperty("--viewport-offset-y","0px"),e(this,j).call(this)}),o(this,j,pe.debounce(()=>{e(this,X).call(this)},10)),o(this,X,()=>{if(this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px"),e(this,C).current){const t=this.getBoundingClientRect();let s=0,i=0;t.right>Q.viewport.width?s=Q.viewport.width-t.right:t.left<0&&(s=t.left*-1),t.bottom>Q.viewport.height?i=Q.viewport.height-t.bottom:t.top<0&&(i=t.top*-1),this.style.setProperty("--viewport-offset-x",s+"px"),this.style.setProperty("--viewport-offset-y",i+"px")}}),o(this,D,()=>{this.close()}),e(this,b).subscribe(t=>{t.previous&&(S.stack.remove(t.previous,this),t.current||(document.documentElement.classList.remove(`${this.group.previous}-closing`),document.documentElement.classList.remove(`${this.group.previous}-opened`)))}),e(this,a).subscribe(t=>{if(this.group.current){document.documentElement.classList.toggle(`${this.group.current}-closing`,t.current.closing);const s=S.stack.groups.get(this.group.current),i=s==null?void 0:s.find(c=>c.opened);document.documentElement.classList.toggle(`${this.group.current}-opened`,!!i)}})}get openClass(){return this.getAttribute("data-open-global-class")}get closingClass(){return this.getAttribute("data-closing-global-class")}get history(){return e(this,m)}get restore(){return e(this,T)}get closeRest(){return e(this,A)}get closeRestInGroup(){return e(this,x)}get group(){return e(this,b)}get clickOutside(){return e(this,R)}get escape(){return e(this,q)}get opened(){return e(this,v)}get lastTrigger(){return e(this,$)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(t){this.urlValue=(t==null?void 0:t.toString())||"",e(this,v)&&he.updateSearchParameter(this.id,t)}open(t){if(e(this,v))return;o(this,$,t==null?void 0:t.trigger),clearTimeout(e(this,z)),clearTimeout(e(this,B)),p(this,u,L).call(this,!1,this.closingClass),e(this,a).set("closing",!1),e(this,a).set("triggered",!0),M.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,$)}}),e(this,m).current&&e(this,y)&&history.pushState(history.state,"",e(this,u,ce)),e(this,a).set("beforeopen",!0),o(this,v,!0);const s=()=>{S.stack.add(e(this,b).current,this),e(this,W).forEach(i=>{i.scroll({top:0,left:0,behavior:"instant"})}),p(this,u,L).call(this,!0,this.openClass),e(this,a).set("opened",!0),M.dispatchEvent(window,"resize"),M.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,$)},bubbles:!0}),o(this,k,void 0),o(this,H,setTimeout(()=>{e(this,a).set("transitionend",!0),M.dispatchEvent(this,"popoverTransitionend")},ne.getElementTransitionDurationMS(this)+10))};t!=null&&t.skipTransition?s():o(this,k,requestAnimationFrame(s))}close(){e(this,v)&&(o(this,v,!1),cancelAnimationFrame(e(this,k)),clearTimeout(e(this,H)),S.stack.remove(e(this,b).current,this),p(this,u,Z).call(this),o(this,z,setTimeout(()=>{e(this,a).set("transitionend",!1),e(this,a).set("opened",!1),e(this,a).set("closing",!0),p(this,u,L).call(this,!1,this.openClass),p(this,u,L).call(this,!0,this.closingClass),M.dispatchEvent(this,"popoverClosing",{custom:!0,bubbles:!0}),o(this,B,setTimeout(()=>{e(this,a).set("triggered",!1),e(this,a).set("beforeopen",!1),e(this,a).set("closing",!1),p(this,u,L).call(this,!1,this.closingClass),M.dispatchEvent(this,"popoverClosed",{custom:!0,bubbles:!0})},ne.getElementTransitionDurationMS(this)+10))},10)))}connectedCallback(){o(this,V,[...this.querySelectorAll(`[data-popover-close${this.id?`="${this.id}"`:""}]`)]),e(this,V).forEach(t=>{t.addEventListener("click",e(this,D))}),o(this,W,[...this.querySelectorAll(`[data-popover-reset-scroll${this.id?`="${this.id}"`:""}]`)]),e(this,m).observe(),e(this,T).observe(),e(this,A).observe(),e(this,x).observe(),e(this,b).observe(),e(this,R).observe(),e(this,q).observe(),e(this,C).observe(),this.setAttribute("role","dialog"),addEventListener("popstate",e(this,G)),setTimeout(()=>{e(this,T).current?(o(this,y,!1),this.urlValue=he.parseSearchParameters(location.search)[this.id],location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),o(this,y,!0)):(p(this,u,Z).call(this),o(this,y,!0))},0),e(this,C).subscribe(()=>{e(this,O).call(this)}),le.windowResizer.subscribe(e(this,O))}disconnectedCallback(){e(this,V).forEach(t=>{t.removeEventListener("click",e(this,D))}),S.stack.remove(e(this,b).current,this),le.windowResizer.unsubscribe(e(this,O)),e(this,m).close(),e(this,T).close(),e(this,A).close(),e(this,x).close(),e(this,b).close(),e(this,R).close(),e(this,q).close(),e(this,C).close(),this.removeAttribute("role"),p(this,u,L).call(this,!1,this.openClass),p(this,u,L).call(this,!1,this.closingClass),clearTimeout(e(this,z)),clearTimeout(e(this,B)),clearTimeout(e(this,k)),clearTimeout(e(this,H)),removeEventListener("popstate",e(this,G)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),p(this,u,Z).call(this)}};v=new WeakMap,z=new WeakMap,B=new WeakMap,k=new WeakMap,H=new WeakMap,m=new WeakMap,T=new WeakMap,A=new WeakMap,x=new WeakMap,b=new WeakMap,R=new WeakMap,q=new WeakMap,C=new WeakMap,y=new WeakMap,$=new WeakMap,a=new WeakMap,V=new WeakMap,W=new WeakMap,u=new WeakSet,ce=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},L=function(t,s){s&&s.split(" ").map(i=>{document.documentElement.classList.toggle(i.trim(),t)})},Z=function(){if(e(this,m).current){const t=new URL(location.href);t.searchParams.delete(this.id),history.replaceState(history.state,"",t.href)}},G=new WeakMap,O=new WeakMap,j=new WeakMap,X=new WeakMap,D=new WeakMap,S.stack=new de;let U=S;ie.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",U);var h,g,P,te,Y,I,J,K,se;class ae extends HTMLElement{constructor(){super();r(this,P);r(this,h);r(this,g,new E.CSSProperty(this,"--type","open"));r(this,Y,t=>{t.target===e(this,h)&&e(this,g).current!=="close"&&this.classList.add("triggered")});r(this,I,t=>{t.target===e(this,h)&&e(this,g).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))});r(this,J,t=>{t.target===e(this,h)&&e(this,g).current!=="close"&&this.classList.remove("opened")});r(this,K,t=>{t.target===e(this,h)&&e(this,g).current!=="close"&&(this.classList.remove("triggered"),this.setAttribute("aria-expanded","false"))});ie.isBrowser&&(this.addEventListener("click",()=>{if(e(this,h)){const t=e(this,g).current;t==="open"||t==="toggle"&&!e(this,h).opened?e(this,h).open({trigger:this}):(t==="close"||t==="toggle"&&e(this,h).opened)&&e(this,h).close()}}),this.addEventListener("keydown",t=>{t.code==="Space"&&!this.hasAttribute("keydown-disabled")&&(t.preventDefault(),this.click())}))}get type(){return e(this,g)}get popoverElement(){return e(this,h)}changePopover(t){var s;if(p(this,P,te).call(this),t){let i=null;if(t==="parent"){const c=this.closest("[data-popover]");if(c)i=c;else{const f=this.getRootNode();f instanceof ShadowRoot?i=f.host.closest("[data-popover]"):f instanceof HTMLElement&&(i=f.closest("[data-popover]"))}}else if(t==="sibling")i=(s=this.parentElement)==null?void 0:s.querySelector("[data-popover]");else if(t==="ancestor-child"){const c=f=>{if(!f)return null;let F=f.querySelector("[data-popover]");return!F&&(f!=null&&f.parentElement)&&(F=c(f.parentElement)),F};i=c(this.parentElement)||null}else!t.startsWith(".")&&!t.startsWith("[")&&(t=`#${t}`),i=document.querySelector(t)||this.getRootNode().querySelector(t);i instanceof HTMLElement?(o(this,h,i),e(this,h).addEventListener("popoverTriggered",e(this,Y)),e(this,h).addEventListener("popoverOpened",e(this,I)),e(this,h).addEventListener("popoverClosing",e(this,J)),e(this,h).addEventListener("popoverClosed",e(this,K))):console.warn(this,`target ${t} not found`)}p(this,P,se).call(this,e(this,g).current)}connectedCallback(){e(this,g).subscribe(s=>{p(this,P,se).call(this,s.current)}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("role")||this.setAttribute("role","button");const t=this.getAttribute("target");t&&this.changePopover(t),this.isConnected&&e(this,g).observe()}disconnectedCallback(){e(this,g).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),this.removeAttribute("role"),this.removeAttribute("tabindex"),p(this,P,te).call(this)}}h=new WeakMap,g=new WeakMap,P=new WeakSet,te=function(){e(this,h)&&(e(this,h).removeEventListener("popoverTriggered",e(this,Y)),e(this,h).removeEventListener("popoverOpened",e(this,I)),e(this,h).removeEventListener("popoverClosing",e(this,J)),e(this,h).removeEventListener("popoverClosed",e(this,K)))},Y=new WeakMap,I=new WeakMap,J=new WeakMap,K=new WeakMap,se=function(t){e(this,h)instanceof U&&(t!=="close"?(this.setAttribute("aria-haspopup","true"),this.setAttribute("aria-expanded",e(this,h).opened?"true":"false"),this.setAttribute("aria-controls",e(this,h).id||"")):(this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls")))};ie.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",ae);exports.PopoverButtonElement=ae;exports.PopoverElement=U;
|
|
1
|
+
"use strict";var ne=c=>{throw TypeError(c)};var te=(c,n,t)=>n.has(c)||ne("Cannot "+t);var e=(c,n,t)=>(te(c,n,"read from private field"),t?t.call(c):n.get(c)),r=(c,n,t)=>n.has(c)?ne("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(c):n.set(c,t),o=(c,n,t,s)=>(te(c,n,"write to private field"),s?s.call(c,t):n.set(c,t),t),p=(c,n,t)=>(te(c,n,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const pe=require("../element-linked-store/index.cjs"),y=require("../css-property/index.cjs"),re=require("../index-DekP7OZe.cjs"),M=require("../events-KVanG9sR.cjs"),de=require("../function-MthRj-GJ.cjs"),he=require("../style-At6aDoqG.cjs");require("construct-style-sheets-polyfill");const ce=require("../url-DGcX4fGV.cjs"),le=require("../window-resizer/index.cjs"),Z=require("../Viewport-DB0qAZPJ.cjs");var d,w,N,ee;class fe{constructor(){r(this,d,new Map);r(this,w,[]);r(this,N,n=>{var s;const t=[...e(this,w)].reverse().find(i=>i.clickOutside.current);if(t){const i=n.composedPath();if(i.find(oe=>oe instanceof HTMLElement&&oe.hasAttribute("data-popover-content")))return;const l=i[0],f=l instanceof Node&&(t.contains(l)||((s=t.shadowRoot)==null?void 0:s.contains(l))),U=l instanceof HTMLElement&&l.hasAttribute("data-outside");(!f||U)&&t.close()}});r(this,ee,n=>{if(n.code==="Escape"){const t=[...e(this,w)].reverse().find(s=>s.escape.current);t&&t.close()}});document.documentElement.addEventListener("click",e(this,N)),addEventListener("keydown",e(this,ee))}get groups(){return e(this,d)}get stack(){return e(this,w)}add(n,t){if(t.closeRest.current)e(this,d).forEach(i=>{i.forEach(l=>{l.close()})});else if(t.closeRestInGroup.current){let i=e(this,d).get(n);i==null||i.forEach(l=>{l.close()})}let s=e(this,d).get(n);s!=null&&s.length||(s=[],e(this,d).set(n,s)),e(this,w).push(t),s.push(t)}remove(n,t){if(setTimeout(()=>{o(this,w,e(this,w).filter(s=>s!==t))}),t.closeRest.current){let s=[];e(this,d).forEach(i=>{i.forEach(l=>s.push(l))}),e(this,d).clear(),s.forEach(i=>i.close())}else if(t.closeRestInGroup.current){const s=e(this,d).get(n);e(this,d).delete(n),s==null||s.forEach(i=>{i.close()})}else{let s=e(this,d).get(n);s&&(s=s.filter(i=>i!==t),e(this,d).set(n,s))}}}d=new WeakMap,w=new WeakMap,N=new WeakMap,ee=new WeakMap;var v,B,H,x,W,m,C,T,R,q,b,$,V,P,E,O,a,z,G,u,ae,L,_,D,k,X,Y,F;const S=class S extends HTMLElement{constructor(){super();r(this,u);r(this,v);r(this,B);r(this,H);r(this,x);r(this,W);r(this,m);r(this,C);r(this,T);r(this,R);r(this,q);r(this,b);r(this,$);r(this,V);r(this,P);r(this,E);r(this,O);r(this,a);r(this,z);r(this,G);r(this,D);r(this,k);r(this,X);r(this,Y);r(this,F);this.urlValue="",o(this,v,!1),o(this,m,new y.CSSProperty(this,"--history",!1)),o(this,C,new y.CSSProperty(this,"--restore",!1)),o(this,T,new y.CSSProperty(this,"--dispatch-resize",!1)),o(this,R,new y.CSSProperty(this,"--close-rest",!1)),o(this,q,new y.CSSProperty(this,"--close-rest-in-group",!1)),o(this,b,new y.CSSProperty(this,"--group","")),o(this,$,new y.CSSProperty(this,"--click-outside",!1)),o(this,V,new y.CSSProperty(this,"--escape",!1)),o(this,P,new y.CSSProperty(this,"--check-viewport-bounds",!1)),o(this,E,!0),o(this,a,new pe.ElementLinkedStore(this,{triggered:!1,beforeopen:!1,opened:!1,closing:!1,transitionend:!1})),o(this,z,[]),o(this,G,[]),o(this,D,()=>{o(this,E,!1),e(this,v)&&e(this,m).current&&!location.search.includes(this.id)?this.close():!e(this,v)&&e(this,m).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),o(this,E,!0)}),o(this,k,()=>{this.style.setProperty("--content-width","initial"),this.style.setProperty("--content-height","initial"),this.style.setProperty("--viewport-offset-x","0px"),this.style.setProperty("--viewport-offset-y","0px"),e(this,X).call(this)}),o(this,X,de.debounce(()=>{e(this,Y).call(this)},10)),o(this,Y,()=>{if(this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px"),e(this,P).current){const t=this.getBoundingClientRect();let s=0,i=0;t.right>Z.viewport.width?s=Z.viewport.width-t.right:t.left<0&&(s=t.left*-1),t.bottom>Z.viewport.height?i=Z.viewport.height-t.bottom:t.top<0&&(i=t.top*-1),this.style.setProperty("--viewport-offset-x",s+"px"),this.style.setProperty("--viewport-offset-y",i+"px")}}),o(this,F,()=>{this.close()}),e(this,b).subscribe(t=>{t.previous&&(S.stack.remove(t.previous,this),t.current||(document.documentElement.classList.remove(`${this.group.previous}-closing`),document.documentElement.classList.remove(`${this.group.previous}-opened`)))}),e(this,a).subscribe(t=>{if(this.group.current){document.documentElement.classList.toggle(`${this.group.current}-closing`,t.current.closing);const s=S.stack.groups.get(this.group.current),i=s==null?void 0:s.find(l=>l.opened);document.documentElement.classList.toggle(`${this.group.current}-opened`,!!i)}})}get openClass(){return this.getAttribute("data-open-global-class")}get closingClass(){return this.getAttribute("data-closing-global-class")}get history(){return e(this,m)}get restore(){return e(this,C)}get dispatchResize(){return e(this,T)}get closeRest(){return e(this,R)}get closeRestInGroup(){return e(this,q)}get group(){return e(this,b)}get clickOutside(){return e(this,$)}get escape(){return e(this,V)}get opened(){return e(this,v)}get lastTrigger(){return e(this,O)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(t){this.urlValue=(t==null?void 0:t.toString())||"",e(this,v)&&ce.updateSearchParameter(this.id,t)}open(t){if(e(this,v))return;o(this,O,t==null?void 0:t.trigger),clearTimeout(e(this,B)),clearTimeout(e(this,H)),p(this,u,L).call(this,!1,this.closingClass),e(this,a).set("closing",!1),e(this,a).set("triggered",!0),M.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,O)}}),e(this,m).current&&e(this,E)&&history.pushState(history.state,"",e(this,u,ae)),e(this,a).set("beforeopen",!0),o(this,v,!0);const s=()=>{S.stack.add(e(this,b).current,this),e(this,G).forEach(i=>{i.scroll({top:0,left:0,behavior:"instant"})}),p(this,u,L).call(this,!0,this.openClass),e(this,a).set("opened",!0),e(this,T).current?M.dispatchEvent(window,"resize",{custom:!0}):e(this,k).call(this),M.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,O)},bubbles:!0}),o(this,x,void 0),o(this,W,setTimeout(()=>{e(this,a).set("transitionend",!0),M.dispatchEvent(this,"popoverTransitionend")},he.getElementTransitionDurationMS(this)+10))};t!=null&&t.skipTransition?s():o(this,x,requestAnimationFrame(s))}close(){e(this,v)&&(o(this,v,!1),cancelAnimationFrame(e(this,x)),clearTimeout(e(this,W)),S.stack.remove(e(this,b).current,this),p(this,u,_).call(this),o(this,B,setTimeout(()=>{e(this,a).set("transitionend",!1),e(this,a).set("opened",!1),e(this,a).set("closing",!0),p(this,u,L).call(this,!1,this.openClass),p(this,u,L).call(this,!0,this.closingClass),M.dispatchEvent(this,"popoverClosing",{custom:!0,bubbles:!0}),o(this,H,setTimeout(()=>{e(this,a).set("triggered",!1),e(this,a).set("beforeopen",!1),e(this,a).set("closing",!1),p(this,u,L).call(this,!1,this.closingClass),M.dispatchEvent(this,"popoverClosed",{custom:!0,bubbles:!0})},he.getElementTransitionDurationMS(this)+10))},10)))}connectedCallback(){o(this,z,[...this.querySelectorAll(`[data-popover-close${this.id?`="${this.id}"`:""}]`)]),e(this,z).forEach(t=>{t.addEventListener("click",e(this,F))}),o(this,G,[...this.querySelectorAll(`[data-popover-reset-scroll${this.id?`="${this.id}"`:""}]`)]),e(this,m).observe(),e(this,C).observe(),e(this,T).observe(),e(this,R).observe(),e(this,q).observe(),e(this,b).observe(),e(this,$).observe(),e(this,V).observe(),e(this,P).observe(),this.setAttribute("role","dialog"),addEventListener("popstate",e(this,D)),setTimeout(()=>{e(this,C).current?(o(this,E,!1),this.urlValue=ce.parseSearchParameters(location.search)[this.id],location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),o(this,E,!0)):(p(this,u,_).call(this),o(this,E,!0))},0),e(this,P).subscribe(()=>{e(this,k).call(this)}),le.windowResizer.subscribe(e(this,k))}disconnectedCallback(){e(this,z).forEach(t=>{t.removeEventListener("click",e(this,F))}),S.stack.remove(e(this,b).current,this),le.windowResizer.unsubscribe(e(this,k)),e(this,m).close(),e(this,C).close(),e(this,T).close(),e(this,R).close(),e(this,q).close(),e(this,b).close(),e(this,$).close(),e(this,V).close(),e(this,P).close(),this.removeAttribute("role"),p(this,u,L).call(this,!1,this.openClass),p(this,u,L).call(this,!1,this.closingClass),clearTimeout(e(this,B)),clearTimeout(e(this,H)),clearTimeout(e(this,x)),clearTimeout(e(this,W)),removeEventListener("popstate",e(this,D)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),p(this,u,_).call(this)}};v=new WeakMap,B=new WeakMap,H=new WeakMap,x=new WeakMap,W=new WeakMap,m=new WeakMap,C=new WeakMap,T=new WeakMap,R=new WeakMap,q=new WeakMap,b=new WeakMap,$=new WeakMap,V=new WeakMap,P=new WeakMap,E=new WeakMap,O=new WeakMap,a=new WeakMap,z=new WeakMap,G=new WeakMap,u=new WeakSet,ae=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},L=function(t,s){s&&s.split(" ").map(i=>{document.documentElement.classList.toggle(i.trim(),t)})},_=function(){if(e(this,m).current){const t=new URL(location.href);t.searchParams.delete(this.id),history.replaceState(history.state,"",t.href)}},D=new WeakMap,k=new WeakMap,X=new WeakMap,Y=new WeakMap,F=new WeakMap,S.stack=new fe;let j=S;re.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",j);var h,g,A,se,I,J,K,Q,ie;class ue extends HTMLElement{constructor(){super();r(this,A);r(this,h);r(this,g,new y.CSSProperty(this,"--type","open"));r(this,I,t=>{t.target===e(this,h)&&e(this,g).current!=="close"&&this.classList.add("triggered")});r(this,J,t=>{t.target===e(this,h)&&e(this,g).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))});r(this,K,t=>{t.target===e(this,h)&&e(this,g).current!=="close"&&this.classList.remove("opened")});r(this,Q,t=>{t.target===e(this,h)&&e(this,g).current!=="close"&&(this.classList.remove("triggered"),this.setAttribute("aria-expanded","false"))});re.isBrowser&&(this.addEventListener("click",()=>{if(e(this,h)){const t=e(this,g).current;t==="open"||t==="toggle"&&!e(this,h).opened?e(this,h).open({trigger:this}):(t==="close"||t==="toggle"&&e(this,h).opened)&&e(this,h).close()}}),this.addEventListener("keydown",t=>{t.code==="Space"&&!this.hasAttribute("keydown-disabled")&&(t.preventDefault(),this.click())}))}get type(){return e(this,g)}get popoverElement(){return e(this,h)}changePopover(t){var s;if(p(this,A,se).call(this),t){let i=null;if(t==="parent"){const l=this.closest("[data-popover]");if(l)i=l;else{const f=this.getRootNode();f instanceof ShadowRoot?i=f.host.closest("[data-popover]"):f instanceof HTMLElement&&(i=f.closest("[data-popover]"))}}else if(t==="sibling")i=(s=this.parentElement)==null?void 0:s.querySelector("[data-popover]");else if(t==="ancestor-child"){const l=f=>{if(!f)return null;let U=f.querySelector("[data-popover]");return!U&&(f!=null&&f.parentElement)&&(U=l(f.parentElement)),U};i=l(this.parentElement)||null}else!t.startsWith(".")&&!t.startsWith("[")&&(t=`#${t}`),i=document.querySelector(t)||this.getRootNode().querySelector(t);i instanceof HTMLElement?(o(this,h,i),e(this,h).addEventListener("popoverTriggered",e(this,I)),e(this,h).addEventListener("popoverOpened",e(this,J)),e(this,h).addEventListener("popoverClosing",e(this,K)),e(this,h).addEventListener("popoverClosed",e(this,Q))):console.warn(this,`target ${t} not found`)}p(this,A,ie).call(this,e(this,g).current)}connectedCallback(){e(this,g).subscribe(s=>{p(this,A,ie).call(this,s.current)}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("role")||this.setAttribute("role","button");const t=this.getAttribute("target");t&&this.changePopover(t),this.isConnected&&e(this,g).observe()}disconnectedCallback(){e(this,g).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),this.removeAttribute("role"),this.removeAttribute("tabindex"),p(this,A,se).call(this)}}h=new WeakMap,g=new WeakMap,A=new WeakSet,se=function(){e(this,h)&&(e(this,h).removeEventListener("popoverTriggered",e(this,I)),e(this,h).removeEventListener("popoverOpened",e(this,J)),e(this,h).removeEventListener("popoverClosing",e(this,K)),e(this,h).removeEventListener("popoverClosed",e(this,Q)))},I=new WeakMap,J=new WeakMap,K=new WeakMap,Q=new WeakMap,ie=function(t){e(this,h)instanceof j&&(t!=="close"?(this.setAttribute("aria-haspopup","true"),this.setAttribute("aria-expanded",e(this,h).opened?"true":"false"),this.setAttribute("aria-controls",e(this,h).id||"")):(this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls")))};re.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",ue);exports.PopoverButtonElement=ue;exports.PopoverElement=j;
|
package/lib/popover/index.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ht = (l) => {
|
|
2
2
|
throw TypeError(l);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var t = (l, h, e) => (
|
|
6
|
-
import { ElementLinkedStore as
|
|
7
|
-
import { CSSProperty as
|
|
8
|
-
import { i as
|
|
4
|
+
var et = (l, h, e) => h.has(l) || ht("Cannot " + e);
|
|
5
|
+
var t = (l, h, e) => (et(l, h, "read from private field"), e ? e.call(l) : h.get(l)), r = (l, h, e) => h.has(l) ? ht("Cannot add the same private member more than once") : h instanceof WeakSet ? h.add(l) : h.set(l, e), o = (l, h, e, s) => (et(l, h, "write to private field"), s ? s.call(l, e) : h.set(l, e), e), p = (l, h, e) => (et(l, h, "access private method"), e);
|
|
6
|
+
import { ElementLinkedStore as at } from "../element-linked-store/index.js";
|
|
7
|
+
import { CSSProperty as E } from "../css-property/index.js";
|
|
8
|
+
import { i as rt } from "../index-Bv9zgfdb.js";
|
|
9
9
|
import { d as q } from "../events-CsVF98U6.js";
|
|
10
|
-
import { d as
|
|
11
|
-
import { g as
|
|
10
|
+
import { d as ut } from "../function-C10DGppn.js";
|
|
11
|
+
import { g as nt } from "../style-j2TwriJ_.js";
|
|
12
12
|
import "construct-style-sheets-polyfill";
|
|
13
|
-
import { u as
|
|
14
|
-
import { windowResizer as
|
|
15
|
-
import { v as
|
|
16
|
-
var d, w,
|
|
17
|
-
class
|
|
13
|
+
import { u as pt, p as dt } from "../url-CFnGU6md.js";
|
|
14
|
+
import { windowResizer as lt } from "../window-resizer/index.js";
|
|
15
|
+
import { v as Q } from "../Viewport-DA10iWAO.js";
|
|
16
|
+
var d, w, _, tt;
|
|
17
|
+
class ft {
|
|
18
18
|
constructor() {
|
|
19
19
|
r(this, d, /* @__PURE__ */ new Map());
|
|
20
20
|
r(this, w, []);
|
|
21
|
-
r(this,
|
|
21
|
+
r(this, _, (h) => {
|
|
22
22
|
var s;
|
|
23
23
|
const e = [...t(this, w)].reverse().find((i) => i.clickOutside.current);
|
|
24
24
|
if (e) {
|
|
25
25
|
const i = h.composedPath();
|
|
26
26
|
if (i.find(
|
|
27
|
-
(
|
|
27
|
+
(ot) => ot instanceof HTMLElement && ot.hasAttribute("data-popover-content")
|
|
28
28
|
))
|
|
29
29
|
return;
|
|
30
|
-
const c = i[0], f = c instanceof Node && (e.contains(c) || ((s = e.shadowRoot) == null ? void 0 : s.contains(c))),
|
|
31
|
-
(!f ||
|
|
30
|
+
const c = i[0], f = c instanceof Node && (e.contains(c) || ((s = e.shadowRoot) == null ? void 0 : s.contains(c))), U = c instanceof HTMLElement && c.hasAttribute("data-outside");
|
|
31
|
+
(!f || U) && e.close();
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
r(this,
|
|
34
|
+
r(this, tt, (h) => {
|
|
35
35
|
if (h.code === "Escape") {
|
|
36
36
|
const e = [...t(this, w)].reverse().find((s) => s.escape.current);
|
|
37
37
|
e && e.close();
|
|
@@ -39,8 +39,8 @@ class dt {
|
|
|
39
39
|
});
|
|
40
40
|
document.documentElement.addEventListener(
|
|
41
41
|
"click",
|
|
42
|
-
t(this,
|
|
43
|
-
), addEventListener("keydown", t(this,
|
|
42
|
+
t(this, _)
|
|
43
|
+
), addEventListener("keydown", t(this, tt));
|
|
44
44
|
}
|
|
45
45
|
get groups() {
|
|
46
46
|
return t(this, d);
|
|
@@ -83,8 +83,8 @@ class dt {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
d = new WeakMap(), w = new WeakMap(),
|
|
87
|
-
var m, H, W,
|
|
86
|
+
d = new WeakMap(), w = new WeakMap(), _ = new WeakMap(), tt = new WeakMap();
|
|
87
|
+
var m, H, W, S, G, v, k, A, R, $, b, V, O, C, y, z, a, M, B, u, ct, L, Z, F, P, X, Y, D;
|
|
88
88
|
const T = class T extends HTMLElement {
|
|
89
89
|
constructor() {
|
|
90
90
|
super();
|
|
@@ -92,49 +92,50 @@ const T = class T extends HTMLElement {
|
|
|
92
92
|
r(this, m);
|
|
93
93
|
r(this, H);
|
|
94
94
|
r(this, W);
|
|
95
|
-
r(this,
|
|
95
|
+
r(this, S);
|
|
96
96
|
r(this, G);
|
|
97
97
|
r(this, v);
|
|
98
98
|
r(this, k);
|
|
99
|
-
r(this,
|
|
100
|
-
r(this, S);
|
|
101
|
-
r(this, b);
|
|
99
|
+
r(this, A);
|
|
102
100
|
r(this, R);
|
|
103
101
|
r(this, $);
|
|
104
|
-
r(this,
|
|
105
|
-
r(this, E);
|
|
102
|
+
r(this, b);
|
|
106
103
|
r(this, V);
|
|
107
|
-
r(this, a);
|
|
108
104
|
r(this, O);
|
|
105
|
+
r(this, C);
|
|
106
|
+
r(this, y);
|
|
109
107
|
r(this, z);
|
|
110
|
-
r(this,
|
|
108
|
+
r(this, a);
|
|
111
109
|
r(this, M);
|
|
112
|
-
r(this,
|
|
113
|
-
r(this, X);
|
|
110
|
+
r(this, B);
|
|
114
111
|
r(this, F);
|
|
115
|
-
|
|
112
|
+
r(this, P);
|
|
113
|
+
r(this, X);
|
|
114
|
+
r(this, Y);
|
|
115
|
+
r(this, D);
|
|
116
|
+
this.urlValue = "", o(this, m, !1), o(this, v, new E(this, "--history", !1)), o(this, k, new E(this, "--restore", !1)), o(this, A, new E(this, "--dispatch-resize", !1)), o(this, R, new E(this, "--close-rest", !1)), o(this, $, new E(
|
|
116
117
|
this,
|
|
117
118
|
"--close-rest-in-group",
|
|
118
119
|
!1
|
|
119
|
-
)), o(this, b, new
|
|
120
|
+
)), o(this, b, new E(this, "--group", "")), o(this, V, new E(this, "--click-outside", !1)), o(this, O, new E(this, "--escape", !1)), o(this, C, new E(this, "--check-viewport-bounds", !1)), o(this, y, !0), o(this, a, new at(this, {
|
|
120
121
|
triggered: !1,
|
|
121
122
|
beforeopen: !1,
|
|
122
123
|
opened: !1,
|
|
123
124
|
closing: !1,
|
|
124
125
|
transitionend: !1
|
|
125
|
-
})), o(this,
|
|
126
|
-
o(this,
|
|
127
|
-
}), o(this,
|
|
128
|
-
this.style.setProperty("--content-width", "initial"), this.style.setProperty("--content-height", "initial"), this.style.setProperty("--viewport-offset-x", "0px"), this.style.setProperty("--viewport-offset-y", "0px"), t(this,
|
|
129
|
-
}), o(this,
|
|
130
|
-
t(this,
|
|
131
|
-
}, 10)), o(this,
|
|
132
|
-
if (this.style.setProperty("--content-width", this.scrollWidth + "px"), this.style.setProperty("--content-height", this.scrollHeight + "px"), t(this,
|
|
126
|
+
})), o(this, M, []), o(this, B, []), o(this, F, () => {
|
|
127
|
+
o(this, y, !1), t(this, m) && t(this, v).current && !location.search.includes(this.id) ? this.close() : !t(this, m) && t(this, v).current && location.search.includes(this.id) && this.open({ trigger: this.idWithValue }), o(this, y, !0);
|
|
128
|
+
}), o(this, P, () => {
|
|
129
|
+
this.style.setProperty("--content-width", "initial"), this.style.setProperty("--content-height", "initial"), this.style.setProperty("--viewport-offset-x", "0px"), this.style.setProperty("--viewport-offset-y", "0px"), t(this, X).call(this);
|
|
130
|
+
}), o(this, X, ut(() => {
|
|
131
|
+
t(this, Y).call(this);
|
|
132
|
+
}, 10)), o(this, Y, () => {
|
|
133
|
+
if (this.style.setProperty("--content-width", this.scrollWidth + "px"), this.style.setProperty("--content-height", this.scrollHeight + "px"), t(this, C).current) {
|
|
133
134
|
const e = this.getBoundingClientRect();
|
|
134
135
|
let s = 0, i = 0;
|
|
135
|
-
e.right >
|
|
136
|
+
e.right > Q.width ? s = Q.width - e.right : e.left < 0 && (s = e.left * -1), e.bottom > Q.height ? i = Q.height - e.bottom : e.top < 0 && (i = e.top * -1), this.style.setProperty("--viewport-offset-x", s + "px"), this.style.setProperty("--viewport-offset-y", i + "px");
|
|
136
137
|
}
|
|
137
|
-
}), o(this,
|
|
138
|
+
}), o(this, D, () => {
|
|
138
139
|
this.close();
|
|
139
140
|
}), t(this, b).subscribe((e) => {
|
|
140
141
|
e.previous && (T.stack.remove(e.previous, this), e.current || (document.documentElement.classList.remove(
|
|
@@ -168,63 +169,66 @@ const T = class T extends HTMLElement {
|
|
|
168
169
|
get restore() {
|
|
169
170
|
return t(this, k);
|
|
170
171
|
}
|
|
172
|
+
get dispatchResize() {
|
|
173
|
+
return t(this, A);
|
|
174
|
+
}
|
|
171
175
|
get closeRest() {
|
|
172
|
-
return t(this,
|
|
176
|
+
return t(this, R);
|
|
173
177
|
}
|
|
174
178
|
get closeRestInGroup() {
|
|
175
|
-
return t(this,
|
|
179
|
+
return t(this, $);
|
|
176
180
|
}
|
|
177
181
|
get group() {
|
|
178
182
|
return t(this, b);
|
|
179
183
|
}
|
|
180
184
|
get clickOutside() {
|
|
181
|
-
return t(this,
|
|
185
|
+
return t(this, V);
|
|
182
186
|
}
|
|
183
187
|
get escape() {
|
|
184
|
-
return t(this,
|
|
188
|
+
return t(this, O);
|
|
185
189
|
}
|
|
186
190
|
get opened() {
|
|
187
191
|
return t(this, m);
|
|
188
192
|
}
|
|
189
193
|
get lastTrigger() {
|
|
190
|
-
return t(this,
|
|
194
|
+
return t(this, z);
|
|
191
195
|
}
|
|
192
196
|
get idWithValue() {
|
|
193
197
|
return `${this.id}${this.urlValue ? "=" + this.urlValue : ""}`;
|
|
194
198
|
}
|
|
195
199
|
updateUrlValue(e) {
|
|
196
|
-
this.urlValue = (e == null ? void 0 : e.toString()) || "", t(this, m) &&
|
|
200
|
+
this.urlValue = (e == null ? void 0 : e.toString()) || "", t(this, m) && pt(this.id, e);
|
|
197
201
|
}
|
|
198
202
|
open(e) {
|
|
199
203
|
if (t(this, m))
|
|
200
204
|
return;
|
|
201
|
-
o(this,
|
|
205
|
+
o(this, z, e == null ? void 0 : e.trigger), clearTimeout(t(this, H)), clearTimeout(t(this, W)), p(this, u, L).call(this, !1, this.closingClass), t(this, a).set("closing", !1), t(this, a).set("triggered", !0), q(this, "popoverTriggered", {
|
|
202
206
|
custom: !0,
|
|
203
207
|
detail: {
|
|
204
|
-
trigger: t(this,
|
|
208
|
+
trigger: t(this, z)
|
|
205
209
|
}
|
|
206
|
-
}), t(this, v).current && t(this,
|
|
210
|
+
}), t(this, v).current && t(this, y) && history.pushState(history.state, "", t(this, u, ct)), t(this, a).set("beforeopen", !0), o(this, m, !0);
|
|
207
211
|
const s = () => {
|
|
208
|
-
T.stack.add(t(this, b).current, this), t(this,
|
|
212
|
+
T.stack.add(t(this, b).current, this), t(this, B).forEach((i) => {
|
|
209
213
|
i.scroll({
|
|
210
214
|
top: 0,
|
|
211
215
|
left: 0,
|
|
212
216
|
behavior: "instant"
|
|
213
217
|
});
|
|
214
|
-
}), p(this, u, L).call(this, !0, this.openClass), t(this, a).set("opened", !0), q(window, "resize"), q(this, "popoverOpened", {
|
|
218
|
+
}), p(this, u, L).call(this, !0, this.openClass), t(this, a).set("opened", !0), t(this, A).current ? q(window, "resize", { custom: !0 }) : t(this, P).call(this), q(this, "popoverOpened", {
|
|
215
219
|
custom: !0,
|
|
216
220
|
detail: {
|
|
217
|
-
trigger: t(this,
|
|
221
|
+
trigger: t(this, z)
|
|
218
222
|
},
|
|
219
223
|
bubbles: !0
|
|
220
|
-
}), o(this,
|
|
224
|
+
}), o(this, S, void 0), o(this, G, setTimeout(() => {
|
|
221
225
|
t(this, a).set("transitionend", !0), q(this, "popoverTransitionend");
|
|
222
|
-
},
|
|
226
|
+
}, nt(this) + 10));
|
|
223
227
|
};
|
|
224
|
-
e != null && e.skipTransition ? s() : o(this,
|
|
228
|
+
e != null && e.skipTransition ? s() : o(this, S, requestAnimationFrame(s));
|
|
225
229
|
}
|
|
226
230
|
close() {
|
|
227
|
-
t(this, m) && (o(this, m, !1), cancelAnimationFrame(t(this,
|
|
231
|
+
t(this, m) && (o(this, m, !1), cancelAnimationFrame(t(this, S)), clearTimeout(t(this, G)), T.stack.remove(t(this, b).current, this), p(this, u, Z).call(this), o(this, H, setTimeout(() => {
|
|
228
232
|
t(this, a).set("transitionend", !1), t(this, a).set("opened", !1), t(this, a).set("closing", !0), p(this, u, L).call(this, !1, this.openClass), p(this, u, L).call(this, !0, this.closingClass), q(this, "popoverClosing", {
|
|
229
233
|
custom: !0,
|
|
230
234
|
bubbles: !0
|
|
@@ -233,66 +237,66 @@ const T = class T extends HTMLElement {
|
|
|
233
237
|
custom: !0,
|
|
234
238
|
bubbles: !0
|
|
235
239
|
});
|
|
236
|
-
},
|
|
240
|
+
}, nt(this) + 10));
|
|
237
241
|
}, 10)));
|
|
238
242
|
}
|
|
239
243
|
connectedCallback() {
|
|
240
|
-
o(this,
|
|
244
|
+
o(this, M, [
|
|
241
245
|
...this.querySelectorAll(
|
|
242
246
|
`[data-popover-close${this.id ? `="${this.id}"` : ""}]`
|
|
243
247
|
)
|
|
244
|
-
]), t(this,
|
|
245
|
-
e.addEventListener("click", t(this,
|
|
246
|
-
}), o(this,
|
|
248
|
+
]), t(this, M).forEach((e) => {
|
|
249
|
+
e.addEventListener("click", t(this, D));
|
|
250
|
+
}), o(this, B, [
|
|
247
251
|
...this.querySelectorAll(
|
|
248
252
|
`[data-popover-reset-scroll${this.id ? `="${this.id}"` : ""}]`
|
|
249
253
|
)
|
|
250
|
-
]), t(this, v).observe(), t(this, k).observe(), t(this,
|
|
251
|
-
t(this, k).current ? (o(this,
|
|
252
|
-
}, 0), t(this,
|
|
253
|
-
t(this,
|
|
254
|
-
}),
|
|
254
|
+
]), t(this, v).observe(), t(this, k).observe(), t(this, A).observe(), t(this, R).observe(), t(this, $).observe(), t(this, b).observe(), t(this, V).observe(), t(this, O).observe(), t(this, C).observe(), this.setAttribute("role", "dialog"), addEventListener("popstate", t(this, F)), setTimeout(() => {
|
|
255
|
+
t(this, k).current ? (o(this, y, !1), this.urlValue = dt(location.search)[this.id], location.search.includes(this.id) && this.open({ trigger: this.idWithValue }), o(this, y, !0)) : (p(this, u, Z).call(this), o(this, y, !0));
|
|
256
|
+
}, 0), t(this, C).subscribe(() => {
|
|
257
|
+
t(this, P).call(this);
|
|
258
|
+
}), lt.subscribe(t(this, P));
|
|
255
259
|
}
|
|
256
260
|
disconnectedCallback() {
|
|
257
|
-
t(this,
|
|
258
|
-
e.removeEventListener("click", t(this,
|
|
259
|
-
}), T.stack.remove(t(this, b).current, this),
|
|
261
|
+
t(this, M).forEach((e) => {
|
|
262
|
+
e.removeEventListener("click", t(this, D));
|
|
263
|
+
}), T.stack.remove(t(this, b).current, this), lt.unsubscribe(t(this, P)), t(this, v).close(), t(this, k).close(), t(this, A).close(), t(this, R).close(), t(this, $).close(), t(this, b).close(), t(this, V).close(), t(this, O).close(), t(this, C).close(), this.removeAttribute("role"), p(this, u, L).call(this, !1, this.openClass), p(this, u, L).call(this, !1, this.closingClass), clearTimeout(t(this, H)), clearTimeout(t(this, W)), clearTimeout(t(this, S)), clearTimeout(t(this, G)), removeEventListener("popstate", t(this, F)), this.style.removeProperty("--content-width"), this.style.removeProperty("--content-height"), this.style.removeProperty("--viewport-offset-x"), this.style.removeProperty("--viewport-offset-y"), p(this, u, Z).call(this);
|
|
260
264
|
}
|
|
261
265
|
};
|
|
262
|
-
m = new WeakMap(), H = new WeakMap(), W = new WeakMap(),
|
|
266
|
+
m = new WeakMap(), H = new WeakMap(), W = new WeakMap(), S = new WeakMap(), G = new WeakMap(), v = new WeakMap(), k = new WeakMap(), A = new WeakMap(), R = new WeakMap(), $ = new WeakMap(), b = new WeakMap(), V = new WeakMap(), O = new WeakMap(), C = new WeakMap(), y = new WeakMap(), z = new WeakMap(), a = new WeakMap(), M = new WeakMap(), B = new WeakMap(), u = new WeakSet(), ct = function() {
|
|
263
267
|
return `${location.pathname}${location.search ? location.search + "&" : "?"}${this.idWithValue}`;
|
|
264
268
|
}, L = function(e, s) {
|
|
265
269
|
s && s.split(" ").map((i) => {
|
|
266
270
|
document.documentElement.classList.toggle(i.trim(), e);
|
|
267
271
|
});
|
|
268
|
-
},
|
|
272
|
+
}, Z = function() {
|
|
269
273
|
if (t(this, v).current) {
|
|
270
274
|
const e = new URL(location.href);
|
|
271
275
|
e.searchParams.delete(this.id), history.replaceState(history.state, "", e.href);
|
|
272
276
|
}
|
|
273
|
-
},
|
|
274
|
-
let
|
|
275
|
-
|
|
276
|
-
var n, g,
|
|
277
|
-
class
|
|
277
|
+
}, F = new WeakMap(), P = new WeakMap(), X = new WeakMap(), Y = new WeakMap(), D = new WeakMap(), T.stack = new ft();
|
|
278
|
+
let N = T;
|
|
279
|
+
rt && !customElements.get("e-popover") && customElements.define("e-popover", N);
|
|
280
|
+
var n, g, x, st, j, I, J, K, it;
|
|
281
|
+
class gt extends HTMLElement {
|
|
278
282
|
constructor() {
|
|
279
283
|
super();
|
|
280
|
-
r(this,
|
|
284
|
+
r(this, x);
|
|
281
285
|
r(this, n);
|
|
282
|
-
r(this, g, new
|
|
283
|
-
r(this,
|
|
286
|
+
r(this, g, new E(this, "--type", "open"));
|
|
287
|
+
r(this, j, (e) => {
|
|
284
288
|
e.target === t(this, n) && t(this, g).current !== "close" && this.classList.add("triggered");
|
|
285
289
|
});
|
|
286
|
-
r(this,
|
|
290
|
+
r(this, I, (e) => {
|
|
287
291
|
e.target === t(this, n) && t(this, g).current !== "close" && (this.classList.add("opened"), this.setAttribute("aria-expanded", "true"));
|
|
288
292
|
});
|
|
289
|
-
r(this,
|
|
293
|
+
r(this, J, (e) => {
|
|
290
294
|
e.target === t(this, n) && t(this, g).current !== "close" && this.classList.remove("opened");
|
|
291
295
|
});
|
|
292
|
-
r(this,
|
|
296
|
+
r(this, K, (e) => {
|
|
293
297
|
e.target === t(this, n) && t(this, g).current !== "close" && (this.classList.remove("triggered"), this.setAttribute("aria-expanded", "false"));
|
|
294
298
|
});
|
|
295
|
-
|
|
299
|
+
rt && (this.addEventListener("click", () => {
|
|
296
300
|
if (t(this, n)) {
|
|
297
301
|
const e = t(this, g).current;
|
|
298
302
|
e === "open" || e === "toggle" && !t(this, n).opened ? t(this, n).open({ trigger: this }) : (e === "close" || e === "toggle" && t(this, n).opened) && t(this, n).close();
|
|
@@ -309,7 +313,7 @@ class ft extends HTMLElement {
|
|
|
309
313
|
}
|
|
310
314
|
changePopover(e) {
|
|
311
315
|
var s;
|
|
312
|
-
if (p(this,
|
|
316
|
+
if (p(this, x, st).call(this), e) {
|
|
313
317
|
let i = null;
|
|
314
318
|
if (e === "parent") {
|
|
315
319
|
const c = this.closest("[data-popover]");
|
|
@@ -325,61 +329,61 @@ class ft extends HTMLElement {
|
|
|
325
329
|
const c = (f) => {
|
|
326
330
|
if (!f)
|
|
327
331
|
return null;
|
|
328
|
-
let
|
|
329
|
-
return !
|
|
332
|
+
let U = f.querySelector("[data-popover]");
|
|
333
|
+
return !U && (f != null && f.parentElement) && (U = c(f.parentElement)), U;
|
|
330
334
|
};
|
|
331
335
|
i = c(this.parentElement) || null;
|
|
332
336
|
} else
|
|
333
337
|
!e.startsWith(".") && !e.startsWith("[") && (e = `#${e}`), i = document.querySelector(e) || this.getRootNode().querySelector(e);
|
|
334
338
|
i instanceof HTMLElement ? (o(this, n, i), t(this, n).addEventListener(
|
|
335
339
|
"popoverTriggered",
|
|
336
|
-
t(this,
|
|
340
|
+
t(this, j)
|
|
337
341
|
), t(this, n).addEventListener(
|
|
338
342
|
"popoverOpened",
|
|
339
|
-
t(this,
|
|
343
|
+
t(this, I)
|
|
340
344
|
), t(this, n).addEventListener(
|
|
341
345
|
"popoverClosing",
|
|
342
|
-
t(this,
|
|
346
|
+
t(this, J)
|
|
343
347
|
), t(this, n).addEventListener(
|
|
344
348
|
"popoverClosed",
|
|
345
|
-
t(this,
|
|
349
|
+
t(this, K)
|
|
346
350
|
)) : console.warn(this, `target ${e} not found`);
|
|
347
351
|
}
|
|
348
|
-
p(this,
|
|
352
|
+
p(this, x, it).call(this, t(this, g).current);
|
|
349
353
|
}
|
|
350
354
|
connectedCallback() {
|
|
351
355
|
t(this, g).subscribe((s) => {
|
|
352
|
-
p(this,
|
|
356
|
+
p(this, x, it).call(this, s.current);
|
|
353
357
|
}), this.hasAttribute("tabindex") || (this.tabIndex = 0), this.hasAttribute("role") || this.setAttribute("role", "button");
|
|
354
358
|
const e = this.getAttribute("target");
|
|
355
359
|
e && this.changePopover(e), this.isConnected && t(this, g).observe();
|
|
356
360
|
}
|
|
357
361
|
disconnectedCallback() {
|
|
358
|
-
t(this, g).unobserve(), this.removeAttribute("aria-haspopup"), this.removeAttribute("aria-expanded"), this.removeAttribute("aria-controls"), this.removeAttribute("role"), this.removeAttribute("tabindex"), p(this,
|
|
362
|
+
t(this, g).unobserve(), this.removeAttribute("aria-haspopup"), this.removeAttribute("aria-expanded"), this.removeAttribute("aria-controls"), this.removeAttribute("role"), this.removeAttribute("tabindex"), p(this, x, st).call(this);
|
|
359
363
|
}
|
|
360
364
|
}
|
|
361
|
-
n = new WeakMap(), g = new WeakMap(),
|
|
365
|
+
n = new WeakMap(), g = new WeakMap(), x = new WeakSet(), st = function() {
|
|
362
366
|
t(this, n) && (t(this, n).removeEventListener(
|
|
363
367
|
"popoverTriggered",
|
|
364
|
-
t(this,
|
|
368
|
+
t(this, j)
|
|
365
369
|
), t(this, n).removeEventListener(
|
|
366
370
|
"popoverOpened",
|
|
367
|
-
t(this,
|
|
371
|
+
t(this, I)
|
|
368
372
|
), t(this, n).removeEventListener(
|
|
369
373
|
"popoverClosing",
|
|
370
|
-
t(this,
|
|
374
|
+
t(this, J)
|
|
371
375
|
), t(this, n).removeEventListener(
|
|
372
376
|
"popoverClosed",
|
|
373
|
-
t(this,
|
|
377
|
+
t(this, K)
|
|
374
378
|
));
|
|
375
|
-
},
|
|
376
|
-
t(this, n) instanceof
|
|
379
|
+
}, j = new WeakMap(), I = new WeakMap(), J = new WeakMap(), K = new WeakMap(), it = function(e) {
|
|
380
|
+
t(this, n) instanceof N && (e !== "close" ? (this.setAttribute("aria-haspopup", "true"), this.setAttribute(
|
|
377
381
|
"aria-expanded",
|
|
378
382
|
t(this, n).opened ? "true" : "false"
|
|
379
383
|
), this.setAttribute("aria-controls", t(this, n).id || "")) : (this.removeAttribute("aria-haspopup"), this.removeAttribute("aria-expanded"), this.removeAttribute("aria-controls")));
|
|
380
384
|
};
|
|
381
|
-
|
|
385
|
+
rt && !customElements.get("e-popover-button") && customElements.define("e-popover-button", gt);
|
|
382
386
|
export {
|
|
383
|
-
|
|
384
|
-
|
|
387
|
+
gt as PopoverButtonElement,
|
|
388
|
+
N as PopoverElement
|
|
385
389
|
};
|