aptechka 0.70.3 → 0.70.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/popover/index.cjs +1 -1
- package/lib/popover/index.js +36 -35
- package/package.json +1 -1
package/lib/popover/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var oe=c=>{throw TypeError(c)};var ee=(c,n,t)=>n.has(c)||oe("Cannot "+t);var e=(c,n,t)=>(ee(c,n,"read from private field"),t?t.call(c):n.get(c)),r=(c,n,t)=>n.has(c)?oe("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(c):n.set(c,t),o=(c,n,t,s)=>(ee(c,n,"write to private field"),s?s.call(c,t):n.set(c,t),t),f=(c,n,t)=>(ee(c,n,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ue=require("../element-linked-store/index.cjs"),y=require("../css-property/index.cjs"),ie=require("../index-DekP7OZe.cjs"),K=require("../events-KVanG9sR.cjs"),pe=require("../function-MthRj-GJ.cjs"),ne=require("../style-At6aDoqG.cjs");require("construct-style-sheets-polyfill");const he=require("../url-BT4fssbO.cjs"),ce=require("../window-resizer/index.cjs"),Q=require("../Viewport-DB0qAZPJ.cjs");var u,E,_,N;class de{constructor(){r(this,u,new Map);r(this,E,[]);r(this,_,n=>{var s;const t=[...e(this,E)].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 l=i[0],d=l instanceof Node&&(t.contains(l)||((s=t.shadowRoot)==null?void 0:s.contains(l))),D=l instanceof HTMLElement&&l.hasAttribute("data-outside");(!d||D)&&t.close()}});r(this,N,n=>{if(n.code==="Escape"){const t=[...e(this,E)].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,u)}get stack(){return e(this,E)}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,E).push(t),s.push(t)}remove(n,t){if(o(this,E,e(this,E).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,E=new WeakMap,_=new WeakMap,N=new WeakMap;var v,M,B,k,H,m,L,A,x,b,R,q,S,T,$,a,V,W,p,le,O,Z,z,P,j,X,G;const w=class w extends HTMLElement{constructor(){super();r(this,p);r(this,v);r(this,M);r(this,B);r(this,k);r(this,H);r(this,m);r(this,L);r(this,A);r(this,x);r(this,b);r(this,R);r(this,q);r(this,S);r(this,T);r(this,$);r(this,a);r(this,V);r(this,W);r(this,z);r(this,P);r(this,j);r(this,X);r(this,G);this.urlValue="",o(this,v,!1),o(this,m,new y.CSSProperty(this,"--history",!1)),o(this,L,new y.CSSProperty(this,"--restore",!1)),o(this,A,new y.CSSProperty(this,"--close-rest",!1)),o(this,x,new y.CSSProperty(this,"--close-rest-in-group",!1)),o(this,b,new y.CSSProperty(this,"--group","")),o(this,R,new y.CSSProperty(this,"--click-outside",!1)),o(this,q,new y.CSSProperty(this,"--escape",!1)),o(this,S,new y.CSSProperty(this,"--check-viewport-bounds",!1)),o(this,T,!1),o(this,a,new ue.ElementLinkedStore(this,{opened:!1,closing:!1,triggered:!1,transitionend:!1})),o(this,V,[]),o(this,W,[]),o(this,z,()=>{o(this,T,!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,T,!0)}),o(this,P,()=>{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,S).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,G,()=>{this.close()}),e(this,b).subscribe(t=>{t.previous&&(w.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=w.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,L)}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,M)),clearTimeout(e(this,B)),f(this,p,O).call(this,!0,this.openClass),f(this,p,O).call(this,!1,this.closingClass),e(this,a).set("closing",!1),e(this,a).set("triggered",!0),K.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,$)}}),e(this,m).current&&e(this,T)&&history.pushState(history.state,"",e(this,p,le)),o(this,v,!0);const s=()=>{w.stack.add(e(this,b).current,this),e(this,W).forEach(i=>{i.scroll({top:0,left:0,behavior:"instant"})}),e(this,P).call(this),e(this,a).set("opened",!0),K.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)},ne.getElementTransitionDurationMS(this)+10))};t!=null&&t.skipTransition?s():o(this,k,setTimeout(s,10))}close(){e(this,v)&&(o(this,v,!1),clearTimeout(e(this,k)),clearTimeout(e(this,H)),w.stack.remove(e(this,b).current,this),f(this,p,Z).call(this),f(this,p,O).call(this,!1,this.openClass),e(this,a).set("transitionend",!1),o(this,M,setTimeout(()=>{e(this,a).set("opened",!1),e(this,a).set("closing",!0),f(this,p,O).call(this,!0,this.closingClass),K.dispatchEvent(this,"popoverClosing",{custom:!0,bubbles:!0}),o(this,B,setTimeout(()=>{e(this,a).set("triggered",!1),e(this,a).set("closing",!1),f(this,p,O).call(this,!1,this.closingClass),K.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,G))}),o(this,W,[...this.querySelectorAll(`[data-popover-reset-scroll${this.id?`="${this.id}"`:""}]`)]),e(this,m).observe(),e(this,L).observe(),e(this,A).observe(),e(this,x).observe(),e(this,b).observe(),e(this,R).observe(),e(this,q).observe(),e(this,S).observe(),this.setAttribute("role","dialog"),addEventListener("popstate",e(this,z)),setTimeout(()=>{e(this,L).current?(this.urlValue=he.parseSearchParameters(location.search)[this.id],location.search.includes(this.id)&&this.open({trigger:this.idWithValue})):(f(this,p,Z).call(this),o(this,T,!0))},0),e(this,S).subscribe(()=>{e(this,P).call(this)}),ce.windowResizer.subscribe(e(this,P))}disconnectedCallback(){e(this,V).forEach(t=>{t.removeEventListener("click",e(this,G))}),w.stack.remove(e(this,b).current,this),ce.windowResizer.unsubscribe(e(this,P)),e(this,a).close(),e(this,m).close(),e(this,L).close(),e(this,A).close(),e(this,x).close(),e(this,b).close(),e(this,R).close(),e(this,q).close(),e(this,S).close(),this.removeAttribute("role"),clearTimeout(e(this,M)),clearTimeout(e(this,B)),clearTimeout(e(this,k)),clearTimeout(e(this,H)),removeEventListener("popstate",e(this,z)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),f(this,p,Z).call(this)}};v=new WeakMap,M=new WeakMap,B=new WeakMap,k=new WeakMap,H=new WeakMap,m=new WeakMap,L=new WeakMap,A=new WeakMap,x=new WeakMap,b=new WeakMap,R=new WeakMap,q=new WeakMap,S=new WeakMap,T=new WeakMap,$=new WeakMap,a=new WeakMap,V=new WeakMap,W=new WeakMap,p=new WeakSet,le=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},O=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)}},z=new WeakMap,P=new WeakMap,j=new WeakMap,X=new WeakMap,G=new WeakMap,w.stack=new de;let U=w;ie.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",U);var h,g,C,te,Y,F,I,J,se;class ae extends HTMLElement{constructor(){super();r(this,C);r(this,h);r(this,g,new y.CSSProperty(this,"--type","open"));r(this,Y,()=>{e(this,g).current!=="close"&&this.classList.add("triggered")});r(this,F,()=>{e(this,g).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))});r(this,I,()=>{e(this,g).current!=="close"&&this.classList.remove("opened")});r(this,J,()=>{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(f(this,C,te).call(this),t){let i=null;if(t==="parent"){const l=this.closest("[data-popover]");if(l)i=l;else{const d=this.getRootNode();d instanceof ShadowRoot?i=d.host.closest("[data-popover]"):d instanceof HTMLElement&&(i=d.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=d=>{if(!d)return null;let D=d.querySelector("[data-popover]");return!D&&(d!=null&&d.parentElement)&&(D=l(d.parentElement)),D};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,Y)),e(this,h).addEventListener("popoverOpened",e(this,F)),e(this,h).addEventListener("popoverClosing",e(this,I)),e(this,h).addEventListener("popoverClosed",e(this,J))):console.warn(this,`target ${t} not found`)}f(this,C,se).call(this,e(this,g).current)}connectedCallback(){e(this,g).subscribe(s=>{f(this,C,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"),f(this,C,te).call(this)}}h=new WeakMap,g=new WeakMap,C=new WeakSet,te=function(){e(this,h)&&(e(this,h).removeEventListener("popoverTriggered",e(this,Y)),e(this,h).removeEventListener("popoverOpened",e(this,F)),e(this,h).removeEventListener("popoverClosing",e(this,I)),e(this,h).removeEventListener("popoverClosed",e(this,J)))},Y=new WeakMap,F=new WeakMap,I=new WeakMap,J=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 oe=c=>{throw TypeError(c)};var ee=(c,n,t)=>n.has(c)||oe("Cannot "+t);var e=(c,n,t)=>(ee(c,n,"read from private field"),t?t.call(c):n.get(c)),r=(c,n,t)=>n.has(c)?oe("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(c):n.set(c,t),o=(c,n,t,s)=>(ee(c,n,"write to private field"),s?s.call(c,t):n.set(c,t),t),f=(c,n,t)=>(ee(c,n,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ue=require("../element-linked-store/index.cjs"),y=require("../css-property/index.cjs"),ie=require("../index-DekP7OZe.cjs"),K=require("../events-KVanG9sR.cjs"),pe=require("../function-MthRj-GJ.cjs"),ne=require("../style-At6aDoqG.cjs");require("construct-style-sheets-polyfill");const he=require("../url-BT4fssbO.cjs"),ce=require("../window-resizer/index.cjs"),Q=require("../Viewport-DB0qAZPJ.cjs");var u,E,_,N;class de{constructor(){r(this,u,new Map);r(this,E,[]);r(this,_,n=>{var s;const t=[...e(this,E)].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 l=i[0],d=l instanceof Node&&(t.contains(l)||((s=t.shadowRoot)==null?void 0:s.contains(l))),D=l instanceof HTMLElement&&l.hasAttribute("data-outside");(!d||D)&&t.close()}});r(this,N,n=>{if(n.code==="Escape"){const t=[...e(this,E)].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,u)}get stack(){return e(this,E)}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,E).push(t),s.push(t)}remove(n,t){if(o(this,E,e(this,E).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,E=new WeakMap,_=new WeakMap,N=new WeakMap;var v,M,B,k,H,m,L,A,x,b,R,q,S,P,$,a,V,W,p,le,O,Z,z,T,U,j,G;const w=class w extends HTMLElement{constructor(){super();r(this,p);r(this,v);r(this,M);r(this,B);r(this,k);r(this,H);r(this,m);r(this,L);r(this,A);r(this,x);r(this,b);r(this,R);r(this,q);r(this,S);r(this,P);r(this,$);r(this,a);r(this,V);r(this,W);r(this,z);r(this,T);r(this,U);r(this,j);r(this,G);this.urlValue="",o(this,v,!1),o(this,m,new y.CSSProperty(this,"--history",!1)),o(this,L,new y.CSSProperty(this,"--restore",!1)),o(this,A,new y.CSSProperty(this,"--close-rest",!1)),o(this,x,new y.CSSProperty(this,"--close-rest-in-group",!1)),o(this,b,new y.CSSProperty(this,"--group","")),o(this,R,new y.CSSProperty(this,"--click-outside",!1)),o(this,q,new y.CSSProperty(this,"--escape",!1)),o(this,S,new y.CSSProperty(this,"--check-viewport-bounds",!1)),o(this,P,!1),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,z,()=>{o(this,P,!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,P,!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,pe.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,S).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,G,()=>{this.close()}),e(this,b).subscribe(t=>{t.previous&&(w.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=w.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,L)}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,M)),clearTimeout(e(this,B)),f(this,p,O).call(this,!1,this.closingClass),e(this,a).set("closing",!1),e(this,a).set("triggered",!0),K.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,$)}}),e(this,m).current&&e(this,P)&&history.pushState(history.state,"",e(this,p,le)),e(this,a).set("beforeopen",!0),o(this,v,!0);const s=()=>{w.stack.add(e(this,b).current,this),e(this,W).forEach(i=>{i.scroll({top:0,left:0,behavior:"instant"})}),f(this,p,O).call(this,!0,this.openClass),e(this,a).set("opened",!0),e(this,T).call(this),K.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)},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)),w.stack.remove(e(this,b).current,this),f(this,p,Z).call(this),f(this,p,O).call(this,!1,this.openClass),e(this,a).set("transitionend",!1),o(this,M,setTimeout(()=>{e(this,a).set("opened",!1),e(this,a).set("closing",!0),f(this,p,O).call(this,!0,this.closingClass),K.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),f(this,p,O).call(this,!1,this.closingClass),K.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,G))}),o(this,W,[...this.querySelectorAll(`[data-popover-reset-scroll${this.id?`="${this.id}"`:""}]`)]),e(this,m).observe(),e(this,L).observe(),e(this,A).observe(),e(this,x).observe(),e(this,b).observe(),e(this,R).observe(),e(this,q).observe(),e(this,S).observe(),this.setAttribute("role","dialog"),addEventListener("popstate",e(this,z)),setTimeout(()=>{e(this,L).current?(this.urlValue=he.parseSearchParameters(location.search)[this.id],location.search.includes(this.id)&&this.open({trigger:this.idWithValue})):(f(this,p,Z).call(this),o(this,P,!0))},0),e(this,S).subscribe(()=>{e(this,T).call(this)}),ce.windowResizer.subscribe(e(this,T))}disconnectedCallback(){e(this,V).forEach(t=>{t.removeEventListener("click",e(this,G))}),w.stack.remove(e(this,b).current,this),ce.windowResizer.unsubscribe(e(this,T)),e(this,a).close(),e(this,m).close(),e(this,L).close(),e(this,A).close(),e(this,x).close(),e(this,b).close(),e(this,R).close(),e(this,q).close(),e(this,S).close(),this.removeAttribute("role"),clearTimeout(e(this,M)),clearTimeout(e(this,B)),clearTimeout(e(this,k)),clearTimeout(e(this,H)),removeEventListener("popstate",e(this,z)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),f(this,p,Z).call(this)}};v=new WeakMap,M=new WeakMap,B=new WeakMap,k=new WeakMap,H=new WeakMap,m=new WeakMap,L=new WeakMap,A=new WeakMap,x=new WeakMap,b=new WeakMap,R=new WeakMap,q=new WeakMap,S=new WeakMap,P=new WeakMap,$=new WeakMap,a=new WeakMap,V=new WeakMap,W=new WeakMap,p=new WeakSet,le=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},O=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)}},z=new WeakMap,T=new WeakMap,U=new WeakMap,j=new WeakMap,G=new WeakMap,w.stack=new de;let F=w;ie.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",F);var h,g,C,te,X,Y,I,J,se;class ae extends HTMLElement{constructor(){super();r(this,C);r(this,h);r(this,g,new y.CSSProperty(this,"--type","open"));r(this,X,()=>{e(this,g).current!=="close"&&this.classList.add("triggered")});r(this,Y,()=>{e(this,g).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))});r(this,I,()=>{e(this,g).current!=="close"&&this.classList.remove("opened")});r(this,J,()=>{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(f(this,C,te).call(this),t){let i=null;if(t==="parent"){const l=this.closest("[data-popover]");if(l)i=l;else{const d=this.getRootNode();d instanceof ShadowRoot?i=d.host.closest("[data-popover]"):d instanceof HTMLElement&&(i=d.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=d=>{if(!d)return null;let D=d.querySelector("[data-popover]");return!D&&(d!=null&&d.parentElement)&&(D=l(d.parentElement)),D};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,X)),e(this,h).addEventListener("popoverOpened",e(this,Y)),e(this,h).addEventListener("popoverClosing",e(this,I)),e(this,h).addEventListener("popoverClosed",e(this,J))):console.warn(this,`target ${t} not found`)}f(this,C,se).call(this,e(this,g).current)}connectedCallback(){e(this,g).subscribe(s=>{f(this,C,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"),f(this,C,te).call(this)}}h=new WeakMap,g=new WeakMap,C=new WeakSet,te=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,I)),e(this,h).removeEventListener("popoverClosed",e(this,J)))},X=new WeakMap,Y=new WeakMap,I=new WeakMap,J=new WeakMap,se=function(t){e(this,h)instanceof F&&(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=F;
|
package/lib/popover/index.js
CHANGED
|
@@ -27,8 +27,8 @@ class dt {
|
|
|
27
27
|
(rt) => rt instanceof HTMLElement && rt.hasAttribute("data-popover-content")
|
|
28
28
|
))
|
|
29
29
|
return;
|
|
30
|
-
const c = i[0], d = c instanceof Node && (e.contains(c) || ((s = e.shadowRoot) == null ? void 0 : s.contains(c))),
|
|
31
|
-
(!d ||
|
|
30
|
+
const c = i[0], d = c instanceof Node && (e.contains(c) || ((s = e.shadowRoot) == null ? void 0 : s.contains(c))), F = c instanceof HTMLElement && c.hasAttribute("data-outside");
|
|
31
|
+
(!d || F) && e.close();
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
r(this, _, (h) => {
|
|
@@ -82,16 +82,16 @@ class dt {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
u = new WeakMap(), y = new WeakMap(), N = new WeakMap(), _ = new WeakMap();
|
|
85
|
-
var m,
|
|
85
|
+
var m, q, H, P, W, v, w, x, S, b, R, $, T, k, V, a, O, G, p, lt, M, Q, z, A, D, U, B;
|
|
86
86
|
const L = class L extends HTMLElement {
|
|
87
87
|
constructor() {
|
|
88
88
|
super();
|
|
89
89
|
r(this, p);
|
|
90
90
|
r(this, m);
|
|
91
|
+
r(this, q);
|
|
91
92
|
r(this, H);
|
|
92
|
-
r(this, W);
|
|
93
93
|
r(this, P);
|
|
94
|
-
r(this,
|
|
94
|
+
r(this, W);
|
|
95
95
|
r(this, v);
|
|
96
96
|
r(this, w);
|
|
97
97
|
r(this, x);
|
|
@@ -107,25 +107,26 @@ const L = class L extends HTMLElement {
|
|
|
107
107
|
r(this, G);
|
|
108
108
|
r(this, z);
|
|
109
109
|
r(this, A);
|
|
110
|
+
r(this, D);
|
|
110
111
|
r(this, U);
|
|
111
|
-
r(this, X);
|
|
112
112
|
r(this, B);
|
|
113
113
|
this.urlValue = "", o(this, m, !1), o(this, v, new E(this, "--history", !1)), o(this, w, new E(this, "--restore", !1)), o(this, x, new E(this, "--close-rest", !1)), o(this, S, new E(
|
|
114
114
|
this,
|
|
115
115
|
"--close-rest-in-group",
|
|
116
116
|
!1
|
|
117
117
|
)), o(this, b, new E(this, "--group", "")), o(this, R, new E(this, "--click-outside", !1)), o(this, $, new E(this, "--escape", !1)), o(this, T, new E(this, "--check-viewport-bounds", !1)), o(this, k, !1), o(this, a, new ct(this, {
|
|
118
|
+
triggered: !1,
|
|
119
|
+
beforeopen: !1,
|
|
118
120
|
opened: !1,
|
|
119
121
|
closing: !1,
|
|
120
|
-
triggered: !1,
|
|
121
122
|
transitionend: !1
|
|
122
123
|
})), o(this, O, []), o(this, G, []), o(this, z, () => {
|
|
123
124
|
o(this, k, !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, k, !0);
|
|
124
125
|
}), o(this, A, () => {
|
|
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,
|
|
126
|
-
}), o(this,
|
|
127
|
-
t(this,
|
|
128
|
-
}, 10)), o(this,
|
|
126
|
+
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);
|
|
127
|
+
}), o(this, D, at(() => {
|
|
128
|
+
t(this, U).call(this);
|
|
129
|
+
}, 10)), o(this, U, () => {
|
|
129
130
|
if (this.style.setProperty("--content-width", this.scrollWidth + "px"), this.style.setProperty("--content-height", this.scrollHeight + "px"), t(this, T).current) {
|
|
130
131
|
const e = this.getBoundingClientRect();
|
|
131
132
|
let s = 0, i = 0;
|
|
@@ -195,12 +196,12 @@ const L = class L extends HTMLElement {
|
|
|
195
196
|
open(e) {
|
|
196
197
|
if (t(this, m))
|
|
197
198
|
return;
|
|
198
|
-
o(this, V, e == null ? void 0 : e.trigger), clearTimeout(t(this,
|
|
199
|
+
o(this, V, e == null ? void 0 : e.trigger), clearTimeout(t(this, q)), clearTimeout(t(this, H)), f(this, p, M).call(this, !1, this.closingClass), t(this, a).set("closing", !1), t(this, a).set("triggered", !0), J(this, "popoverTriggered", {
|
|
199
200
|
custom: !0,
|
|
200
201
|
detail: {
|
|
201
202
|
trigger: t(this, V)
|
|
202
203
|
}
|
|
203
|
-
}), t(this, v).current && t(this, k) && history.pushState(history.state, "", t(this, p, lt)), o(this, m, !0);
|
|
204
|
+
}), t(this, v).current && t(this, k) && history.pushState(history.state, "", t(this, p, lt)), t(this, a).set("beforeopen", !0), o(this, m, !0);
|
|
204
205
|
const s = () => {
|
|
205
206
|
L.stack.add(t(this, b).current, this), t(this, G).forEach((i) => {
|
|
206
207
|
i.scroll({
|
|
@@ -208,25 +209,25 @@ const L = class L extends HTMLElement {
|
|
|
208
209
|
left: 0,
|
|
209
210
|
behavior: "instant"
|
|
210
211
|
});
|
|
211
|
-
}),
|
|
212
|
+
}), f(this, p, M).call(this, !0, this.openClass), t(this, a).set("opened", !0), t(this, A).call(this), J(this, "popoverOpened", {
|
|
212
213
|
custom: !0,
|
|
213
214
|
detail: {
|
|
214
215
|
trigger: t(this, V)
|
|
215
216
|
},
|
|
216
217
|
bubbles: !0
|
|
217
|
-
}), o(this, P, void 0), o(this,
|
|
218
|
+
}), o(this, P, void 0), o(this, W, setTimeout(() => {
|
|
218
219
|
t(this, a).set("transitionend", !0);
|
|
219
220
|
}, ht(this) + 10));
|
|
220
221
|
};
|
|
221
|
-
e != null && e.skipTransition ? s() : o(this, P,
|
|
222
|
+
e != null && e.skipTransition ? s() : o(this, P, requestAnimationFrame(s));
|
|
222
223
|
}
|
|
223
224
|
close() {
|
|
224
|
-
t(this, m) && (o(this, m, !1),
|
|
225
|
+
t(this, m) && (o(this, m, !1), cancelAnimationFrame(t(this, P)), clearTimeout(t(this, W)), L.stack.remove(t(this, b).current, this), f(this, p, Q).call(this), f(this, p, M).call(this, !1, this.openClass), t(this, a).set("transitionend", !1), o(this, q, setTimeout(() => {
|
|
225
226
|
t(this, a).set("opened", !1), t(this, a).set("closing", !0), f(this, p, M).call(this, !0, this.closingClass), J(this, "popoverClosing", {
|
|
226
227
|
custom: !0,
|
|
227
228
|
bubbles: !0
|
|
228
|
-
}), o(this,
|
|
229
|
-
t(this, a).set("triggered", !1), t(this, a).set("closing", !1), f(this, p, M).call(this, !1, this.closingClass), J(this, "popoverClosed", {
|
|
229
|
+
}), o(this, H, setTimeout(() => {
|
|
230
|
+
t(this, a).set("triggered", !1), t(this, a).set("beforeopen", !1), t(this, a).set("closing", !1), f(this, p, M).call(this, !1, this.closingClass), J(this, "popoverClosed", {
|
|
230
231
|
custom: !0,
|
|
231
232
|
bubbles: !0
|
|
232
233
|
});
|
|
@@ -253,10 +254,10 @@ const L = class L extends HTMLElement {
|
|
|
253
254
|
disconnectedCallback() {
|
|
254
255
|
t(this, O).forEach((e) => {
|
|
255
256
|
e.removeEventListener("click", t(this, B));
|
|
256
|
-
}), L.stack.remove(t(this, b).current, this), nt.unsubscribe(t(this, A)), t(this, a).close(), t(this, v).close(), t(this, w).close(), t(this, x).close(), t(this, S).close(), t(this, b).close(), t(this, R).close(), t(this, $).close(), t(this, T).close(), this.removeAttribute("role"), clearTimeout(t(this,
|
|
257
|
+
}), L.stack.remove(t(this, b).current, this), nt.unsubscribe(t(this, A)), t(this, a).close(), t(this, v).close(), t(this, w).close(), t(this, x).close(), t(this, S).close(), t(this, b).close(), t(this, R).close(), t(this, $).close(), t(this, T).close(), this.removeAttribute("role"), clearTimeout(t(this, q)), clearTimeout(t(this, H)), clearTimeout(t(this, P)), clearTimeout(t(this, W)), removeEventListener("popstate", t(this, z)), this.style.removeProperty("--content-width"), this.style.removeProperty("--content-height"), this.style.removeProperty("--viewport-offset-x"), this.style.removeProperty("--viewport-offset-y"), f(this, p, Q).call(this);
|
|
257
258
|
}
|
|
258
259
|
};
|
|
259
|
-
m = new WeakMap(),
|
|
260
|
+
m = new WeakMap(), q = new WeakMap(), H = new WeakMap(), P = new WeakMap(), W = new WeakMap(), v = new WeakMap(), w = new WeakMap(), x = new WeakMap(), S = new WeakMap(), b = new WeakMap(), R = new WeakMap(), $ = new WeakMap(), T = new WeakMap(), k = new WeakMap(), V = new WeakMap(), a = new WeakMap(), O = new WeakMap(), G = new WeakMap(), p = new WeakSet(), lt = function() {
|
|
260
261
|
return `${location.pathname}${location.search ? location.search + "&" : "?"}${this.idWithValue}`;
|
|
261
262
|
}, M = function(e, s) {
|
|
262
263
|
s && s.split(" ").map((i) => {
|
|
@@ -267,23 +268,23 @@ m = new WeakMap(), H = new WeakMap(), W = new WeakMap(), P = new WeakMap(), q =
|
|
|
267
268
|
const e = new URL(location.href);
|
|
268
269
|
e.searchParams.delete(this.id), history.replaceState(history.state, "", e.href);
|
|
269
270
|
}
|
|
270
|
-
}, z = new WeakMap(), A = new WeakMap(),
|
|
271
|
+
}, z = new WeakMap(), A = new WeakMap(), D = new WeakMap(), U = new WeakMap(), B = new WeakMap(), L.stack = new dt();
|
|
271
272
|
let Z = L;
|
|
272
273
|
it && !customElements.get("e-popover") && customElements.define("e-popover", Z);
|
|
273
|
-
var n, g, C, et, Y, j,
|
|
274
|
+
var n, g, C, et, X, Y, j, I, st;
|
|
274
275
|
class ft extends HTMLElement {
|
|
275
276
|
constructor() {
|
|
276
277
|
super();
|
|
277
278
|
r(this, C);
|
|
278
279
|
r(this, n);
|
|
279
280
|
r(this, g, new E(this, "--type", "open"));
|
|
280
|
-
r(this,
|
|
281
|
+
r(this, X, () => {
|
|
281
282
|
t(this, g).current !== "close" && this.classList.add("triggered");
|
|
282
283
|
});
|
|
283
|
-
r(this,
|
|
284
|
+
r(this, Y, () => {
|
|
284
285
|
t(this, g).current !== "close" && (this.classList.add("opened"), this.setAttribute("aria-expanded", "true"));
|
|
285
286
|
});
|
|
286
|
-
r(this,
|
|
287
|
+
r(this, j, () => {
|
|
287
288
|
t(this, g).current !== "close" && this.classList.remove("opened");
|
|
288
289
|
});
|
|
289
290
|
r(this, I, () => {
|
|
@@ -322,21 +323,21 @@ class ft extends HTMLElement {
|
|
|
322
323
|
const c = (d) => {
|
|
323
324
|
if (!d)
|
|
324
325
|
return null;
|
|
325
|
-
let
|
|
326
|
-
return !
|
|
326
|
+
let F = d.querySelector("[data-popover]");
|
|
327
|
+
return !F && (d != null && d.parentElement) && (F = c(d.parentElement)), F;
|
|
327
328
|
};
|
|
328
329
|
i = c(this.parentElement) || null;
|
|
329
330
|
} else
|
|
330
331
|
!e.startsWith(".") && !e.startsWith("[") && (e = `#${e}`), i = document.querySelector(e) || this.getRootNode().querySelector(e);
|
|
331
332
|
i instanceof HTMLElement ? (o(this, n, i), t(this, n).addEventListener(
|
|
332
333
|
"popoverTriggered",
|
|
333
|
-
t(this,
|
|
334
|
+
t(this, X)
|
|
334
335
|
), t(this, n).addEventListener(
|
|
335
336
|
"popoverOpened",
|
|
336
|
-
t(this,
|
|
337
|
+
t(this, Y)
|
|
337
338
|
), t(this, n).addEventListener(
|
|
338
339
|
"popoverClosing",
|
|
339
|
-
t(this,
|
|
340
|
+
t(this, j)
|
|
340
341
|
), t(this, n).addEventListener(
|
|
341
342
|
"popoverClosed",
|
|
342
343
|
t(this, I)
|
|
@@ -358,18 +359,18 @@ class ft extends HTMLElement {
|
|
|
358
359
|
n = new WeakMap(), g = new WeakMap(), C = new WeakSet(), et = function() {
|
|
359
360
|
t(this, n) && (t(this, n).removeEventListener(
|
|
360
361
|
"popoverTriggered",
|
|
361
|
-
t(this,
|
|
362
|
+
t(this, X)
|
|
362
363
|
), t(this, n).removeEventListener(
|
|
363
364
|
"popoverOpened",
|
|
364
|
-
t(this,
|
|
365
|
+
t(this, Y)
|
|
365
366
|
), t(this, n).removeEventListener(
|
|
366
367
|
"popoverClosing",
|
|
367
|
-
t(this,
|
|
368
|
+
t(this, j)
|
|
368
369
|
), t(this, n).removeEventListener(
|
|
369
370
|
"popoverClosed",
|
|
370
371
|
t(this, I)
|
|
371
372
|
));
|
|
372
|
-
},
|
|
373
|
+
}, X = new WeakMap(), Y = new WeakMap(), j = new WeakMap(), I = new WeakMap(), st = function(e) {
|
|
373
374
|
t(this, n) instanceof Z && (e !== "close" ? (this.setAttribute("aria-haspopup", "true"), this.setAttribute(
|
|
374
375
|
"aria-expanded",
|
|
375
376
|
t(this, n).opened ? "true" : "false"
|