aptechka 0.71.24 → 0.71.25
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 +8 -11
- package/package.json +1 -1
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-YEESIcRn.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}"`:""}]`)]),console.log(this.id,`[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 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-YEESIcRn.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;
|
package/lib/popover/index.js
CHANGED
|
@@ -84,7 +84,7 @@ class dt {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
d = new WeakMap(), w = new WeakMap(), N = new WeakMap(), _ = new WeakMap();
|
|
87
|
-
var m, H, W, P, G, v, k, x, S, b,
|
|
87
|
+
var m, H, W, P, G, v, k, x, S, b, R, $, A, E, V, a, O, z, u, lt, L, Q, B, M, U, X, F;
|
|
88
88
|
const T = class T extends HTMLElement {
|
|
89
89
|
constructor() {
|
|
90
90
|
super();
|
|
@@ -99,8 +99,8 @@ const T = class T extends HTMLElement {
|
|
|
99
99
|
r(this, x);
|
|
100
100
|
r(this, S);
|
|
101
101
|
r(this, b);
|
|
102
|
-
r(this, $);
|
|
103
102
|
r(this, R);
|
|
103
|
+
r(this, $);
|
|
104
104
|
r(this, A);
|
|
105
105
|
r(this, E);
|
|
106
106
|
r(this, V);
|
|
@@ -116,7 +116,7 @@ const T = class T extends HTMLElement {
|
|
|
116
116
|
this,
|
|
117
117
|
"--close-rest-in-group",
|
|
118
118
|
!1
|
|
119
|
-
)), o(this, b, new y(this, "--group", "")), o(this,
|
|
119
|
+
)), o(this, b, new y(this, "--group", "")), o(this, R, new y(this, "--click-outside", !1)), o(this, $, new y(this, "--escape", !1)), o(this, A, new y(this, "--check-viewport-bounds", !1)), o(this, E, !0), o(this, a, new ct(this, {
|
|
120
120
|
triggered: !1,
|
|
121
121
|
beforeopen: !1,
|
|
122
122
|
opened: !1,
|
|
@@ -178,10 +178,10 @@ const T = class T extends HTMLElement {
|
|
|
178
178
|
return t(this, b);
|
|
179
179
|
}
|
|
180
180
|
get clickOutside() {
|
|
181
|
-
return t(this,
|
|
181
|
+
return t(this, R);
|
|
182
182
|
}
|
|
183
183
|
get escape() {
|
|
184
|
-
return t(this,
|
|
184
|
+
return t(this, $);
|
|
185
185
|
}
|
|
186
186
|
get opened() {
|
|
187
187
|
return t(this, m);
|
|
@@ -247,10 +247,7 @@ const T = class T extends HTMLElement {
|
|
|
247
247
|
...this.querySelectorAll(
|
|
248
248
|
`[data-popover-reset-scroll${this.id ? `="${this.id}"` : ""}]`
|
|
249
249
|
)
|
|
250
|
-
]),
|
|
251
|
-
this.id,
|
|
252
|
-
`[data-popover-reset-scroll${this.id ? `="${this.id}"` : ""}]`
|
|
253
|
-
), t(this, v).observe(), t(this, k).observe(), t(this, x).observe(), t(this, S).observe(), t(this, b).observe(), t(this, $).observe(), t(this, R).observe(), t(this, A).observe(), this.setAttribute("role", "dialog"), addEventListener("popstate", t(this, B)), setTimeout(() => {
|
|
250
|
+
]), t(this, v).observe(), t(this, k).observe(), t(this, x).observe(), t(this, S).observe(), t(this, b).observe(), t(this, R).observe(), t(this, $).observe(), t(this, A).observe(), this.setAttribute("role", "dialog"), addEventListener("popstate", t(this, B)), setTimeout(() => {
|
|
254
251
|
t(this, k).current ? (o(this, E, !1), this.urlValue = pt(location.search)[this.id], location.search.includes(this.id) && this.open({ trigger: this.idWithValue }), o(this, E, !0)) : (p(this, u, Q).call(this), o(this, E, !0));
|
|
255
252
|
}, 0), t(this, A).subscribe(() => {
|
|
256
253
|
t(this, M).call(this);
|
|
@@ -259,10 +256,10 @@ const T = class T extends HTMLElement {
|
|
|
259
256
|
disconnectedCallback() {
|
|
260
257
|
t(this, O).forEach((e) => {
|
|
261
258
|
e.removeEventListener("click", t(this, F));
|
|
262
|
-
}), T.stack.remove(t(this, b).current, this), nt.unsubscribe(t(this, M)), t(this, v).close(), t(this, k).close(), t(this, x).close(), t(this, S).close(), t(this, b).close(), t(this,
|
|
259
|
+
}), T.stack.remove(t(this, b).current, this), nt.unsubscribe(t(this, M)), t(this, v).close(), t(this, k).close(), t(this, x).close(), t(this, S).close(), t(this, b).close(), t(this, R).close(), t(this, $).close(), t(this, A).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, P)), clearTimeout(t(this, G)), removeEventListener("popstate", t(this, B)), 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, Q).call(this);
|
|
263
260
|
}
|
|
264
261
|
};
|
|
265
|
-
m = new WeakMap(), H = new WeakMap(), W = new WeakMap(), P = new WeakMap(), G = new WeakMap(), v = new WeakMap(), k = new WeakMap(), x = new WeakMap(), S = new WeakMap(), b = new WeakMap(),
|
|
262
|
+
m = new WeakMap(), H = new WeakMap(), W = new WeakMap(), P = new WeakMap(), G = new WeakMap(), v = new WeakMap(), k = new WeakMap(), x = new WeakMap(), S = new WeakMap(), b = new WeakMap(), R = new WeakMap(), $ = new WeakMap(), A = new WeakMap(), E = new WeakMap(), V = new WeakMap(), a = new WeakMap(), O = new WeakMap(), z = new WeakMap(), u = new WeakSet(), lt = function() {
|
|
266
263
|
return `${location.pathname}${location.search ? location.search + "&" : "?"}${this.idWithValue}`;
|
|
267
264
|
}, L = function(e, s) {
|
|
268
265
|
s && s.split(" ").map((i) => {
|