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