aptechka 0.70.7 → 0.70.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 +31 -31
- 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"),F=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,z,C,B,m,L,k,A,b,x,R,S,P,q,a,$,H,p,le,O,Z,W,V,j,X,G;const w=class w extends HTMLElement{constructor(){super();r(this,p);r(this,v);r(this,M);r(this,z);r(this,C);r(this,B);r(this,m);r(this,L);r(this,k);r(this,A);r(this,b);r(this,x);r(this,R);r(this,S);r(this,P);r(this,q);r(this,a);r(this,$);r(this,H);r(this,W);r(this,V);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,k,new y.CSSProperty(this,"--close-rest",!1)),o(this,A,new y.CSSProperty(this,"--close-rest-in-group",!1)),o(this,b,new y.CSSProperty(this,"--group","")),o(this,x,new y.CSSProperty(this,"--click-outside",!1)),o(this,R,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,$,[]),o(this,H,[]),o(this,W,()=>{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,V,()=>{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,k)}get closeRestInGroup(){return e(this,A)}get group(){return e(this,b)}get clickOutside(){return e(this,x)}get escape(){return e(this,R)}get opened(){return e(this,v)}get lastTrigger(){return e(this,q)}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,q,t==null?void 0:t.trigger),clearTimeout(e(this,M)),clearTimeout(e(this,z)),f(this,p,O).call(this,!1,this.closingClass),e(this,a).set("closing",!1),e(this,a).set("triggered",!0),F.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,q)}}),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,H).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),F.dispatchEvent(window,"resize"),F.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,q)},bubbles:!0}),o(this,C,void 0),o(this,B,setTimeout(()=>{e(this,a).set("transitionend",!0)},ne.getElementTransitionDurationMS(this)+10))};t!=null&&t.skipTransition?s():o(this,C,requestAnimationFrame(s))}close(){e(this,v)&&(o(this,v,!1),cancelAnimationFrame(e(this,C)),clearTimeout(e(this,B)),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),F.dispatchEvent(this,"popoverClosing",{custom:!0,bubbles:!0}),o(this,z,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),F.dispatchEvent(this,"popoverClosed",{custom:!0,bubbles:!0})},ne.getElementTransitionDurationMS(this)+10))},10)))}connectedCallback(){o(this,$,[...this.querySelectorAll(`[data-popover-close${this.id?`="${this.id}"`:""}]`)]),e(this,$).forEach(t=>{t.addEventListener("click",e(this,G))}),o(this,H,[...this.querySelectorAll(`[data-popover-reset-scroll${this.id?`="${this.id}"`:""}]`)]),e(this,m).observe(),e(this,L).observe(),e(this,k).observe(),e(this,A).observe(),e(this,b).observe(),e(this,x).observe(),e(this,R).observe(),e(this,S).observe(),this.setAttribute("role","dialog"),addEventListener("popstate",e(this,W)),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,V).call(this)}),ce.windowResizer.subscribe(e(this,V))}disconnectedCallback(){e(this,$).forEach(t=>{t.removeEventListener("click",e(this,G))}),w.stack.remove(e(this,b).current,this),ce.windowResizer.unsubscribe(e(this,V)),e(this,a).close(),e(this,m).close(),e(this,L).close(),e(this,k).close(),e(this,A).close(),e(this,b).close(),e(this,x).close(),e(this,R).close(),e(this,S).close(),this.removeAttribute("role"),clearTimeout(e(this,M)),clearTimeout(e(this,z)),clearTimeout(e(this,C)),clearTimeout(e(this,B)),removeEventListener("popstate",e(this,W)),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,z=new WeakMap,C=new WeakMap,B=new WeakMap,m=new WeakMap,L=new WeakMap,k=new WeakMap,A=new WeakMap,b=new WeakMap,x=new WeakMap,R=new WeakMap,S=new WeakMap,P=new WeakMap,q=new WeakMap,a=new WeakMap,$=new WeakMap,H=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)}},W=new WeakMap,V=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,T,te,Y,I,J,K,se;class ae extends HTMLElement{constructor(){super();r(this,T);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,I,()=>{e(this,g).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))});r(this,J,()=>{e(this,g).current!=="close"&&this.classList.remove("opened")});r(this,K,()=>{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,T,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,I)),e(this,h).addEventListener("popoverClosing",e(this,J)),e(this,h).addEventListener("popoverClosed",e(this,K))):console.warn(this,`target ${t} not found`)}f(this,T,se).call(this,e(this,g).current)}connectedCallback(){e(this,g).subscribe(s=>{f(this,T,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,T,te).call(this)}}h=new WeakMap,g=new WeakMap,T=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=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"),E=require("../css-property/index.cjs"),ie=require("../index-DekP7OZe.cjs"),F=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,w,_,N;class de{constructor(){r(this,u,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 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,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,u)}get stack(){return e(this,w)}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,w).push(t),s.push(t)}remove(n,t){if(o(this,w,e(this,w).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,w=new WeakMap,_=new WeakMap,N=new WeakMap;var v,M,z,C,B,m,S,k,A,b,x,R,P,y,q,a,$,H,p,le,O,Z,W,V,j,X,G;const L=class L extends HTMLElement{constructor(){super();r(this,p);r(this,v);r(this,M);r(this,z);r(this,C);r(this,B);r(this,m);r(this,S);r(this,k);r(this,A);r(this,b);r(this,x);r(this,R);r(this,P);r(this,y);r(this,q);r(this,a);r(this,$);r(this,H);r(this,W);r(this,V);r(this,j);r(this,X);r(this,G);this.urlValue="",o(this,v,!1),o(this,m,new E.CSSProperty(this,"--history",!1)),o(this,S,new E.CSSProperty(this,"--restore",!1)),o(this,k,new E.CSSProperty(this,"--close-rest",!1)),o(this,A,new E.CSSProperty(this,"--close-rest-in-group",!1)),o(this,b,new E.CSSProperty(this,"--group","")),o(this,x,new E.CSSProperty(this,"--click-outside",!1)),o(this,R,new E.CSSProperty(this,"--escape",!1)),o(this,P,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,$,[]),o(this,H,[]),o(this,W,()=>{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,V,()=>{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,P).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&&(L.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=L.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,S)}get closeRest(){return e(this,k)}get closeRestInGroup(){return e(this,A)}get group(){return e(this,b)}get clickOutside(){return e(this,x)}get escape(){return e(this,R)}get opened(){return e(this,v)}get lastTrigger(){return e(this,q)}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,q,t==null?void 0:t.trigger),clearTimeout(e(this,M)),clearTimeout(e(this,z)),f(this,p,O).call(this,!1,this.closingClass),e(this,a).set("closing",!1),e(this,a).set("triggered",!0),F.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,q)}}),e(this,m).current&&e(this,y)&&history.pushState(history.state,"",e(this,p,le)),e(this,a).set("beforeopen",!0),o(this,v,!0);const s=()=>{L.stack.add(e(this,b).current,this),e(this,H).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),F.dispatchEvent(window,"resize"),F.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,q)},bubbles:!0}),o(this,C,void 0),o(this,B,setTimeout(()=>{e(this,a).set("transitionend",!0)},ne.getElementTransitionDurationMS(this)+10))};t!=null&&t.skipTransition?s():o(this,C,requestAnimationFrame(s))}close(){e(this,v)&&(o(this,v,!1),cancelAnimationFrame(e(this,C)),clearTimeout(e(this,B)),L.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),F.dispatchEvent(this,"popoverClosing",{custom:!0,bubbles:!0}),o(this,z,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),F.dispatchEvent(this,"popoverClosed",{custom:!0,bubbles:!0})},ne.getElementTransitionDurationMS(this)+10))},10)))}connectedCallback(){o(this,$,[...this.querySelectorAll(`[data-popover-close${this.id?`="${this.id}"`:""}]`)]),e(this,$).forEach(t=>{t.addEventListener("click",e(this,G))}),o(this,H,[...this.querySelectorAll(`[data-popover-reset-scroll${this.id?`="${this.id}"`:""}]`)]),e(this,m).observe(),e(this,S).observe(),e(this,k).observe(),e(this,A).observe(),e(this,b).observe(),e(this,x).observe(),e(this,R).observe(),e(this,P).observe(),this.setAttribute("role","dialog"),addEventListener("popstate",e(this,W)),setTimeout(()=>{e(this,S).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)):(f(this,p,Z).call(this),o(this,y,!0))},0),e(this,P).subscribe(()=>{e(this,V).call(this)}),ce.windowResizer.subscribe(e(this,V))}disconnectedCallback(){e(this,$).forEach(t=>{t.removeEventListener("click",e(this,G))}),L.stack.remove(e(this,b).current,this),ce.windowResizer.unsubscribe(e(this,V)),e(this,a).close(),e(this,m).close(),e(this,S).close(),e(this,k).close(),e(this,A).close(),e(this,b).close(),e(this,x).close(),e(this,R).close(),e(this,P).close(),this.removeAttribute("role"),clearTimeout(e(this,M)),clearTimeout(e(this,z)),clearTimeout(e(this,C)),clearTimeout(e(this,B)),removeEventListener("popstate",e(this,W)),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,z=new WeakMap,C=new WeakMap,B=new WeakMap,m=new WeakMap,S=new WeakMap,k=new WeakMap,A=new WeakMap,b=new WeakMap,x=new WeakMap,R=new WeakMap,P=new WeakMap,y=new WeakMap,q=new WeakMap,a=new WeakMap,$=new WeakMap,H=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)}},W=new WeakMap,V=new WeakMap,j=new WeakMap,X=new WeakMap,G=new WeakMap,L.stack=new de;let U=L;ie.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",U);var h,g,T,te,Y,I,J,K,se;class ae extends HTMLElement{constructor(){super();r(this,T);r(this,h);r(this,g,new E.CSSProperty(this,"--type","open"));r(this,Y,()=>{e(this,g).current!=="close"&&this.classList.add("triggered")});r(this,I,()=>{e(this,g).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))});r(this,J,()=>{e(this,g).current!=="close"&&this.classList.remove("opened")});r(this,K,()=>{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,T,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,I)),e(this,h).addEventListener("popoverClosing",e(this,J)),e(this,h).addEventListener("popoverClosed",e(this,K))):console.warn(this,`target ${t} not found`)}f(this,T,se).call(this,e(this,g).current)}connectedCallback(){e(this,g).subscribe(s=>{f(this,T,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,T,te).call(this)}}h=new WeakMap,g=new WeakMap,T=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
|
@@ -4,7 +4,7 @@ var ot = (l) => {
|
|
|
4
4
|
var tt = (l, h, e) => h.has(l) || ot("Cannot " + e);
|
|
5
5
|
var t = (l, h, e) => (tt(l, h, "read from private field"), e ? e.call(l) : h.get(l)), r = (l, h, e) => h.has(l) ? ot("Cannot add the same private member more than once") : h instanceof WeakSet ? h.add(l) : h.set(l, e), o = (l, h, e, s) => (tt(l, h, "write to private field"), s ? s.call(l, e) : h.set(l, e), e), f = (l, h, e) => (tt(l, h, "access private method"), e);
|
|
6
6
|
import { ElementLinkedStore as ct } from "../element-linked-store/index.js";
|
|
7
|
-
import { CSSProperty as
|
|
7
|
+
import { CSSProperty as y } from "../css-property/index.js";
|
|
8
8
|
import { i as it } from "../index-Bv9zgfdb.js";
|
|
9
9
|
import { d as D } from "../events-CsVF98U6.js";
|
|
10
10
|
import { d as at } from "../function-C10DGppn.js";
|
|
@@ -13,14 +13,14 @@ import "construct-style-sheets-polyfill";
|
|
|
13
13
|
import { u as ut, p as pt } from "../url-Cb0SFRMc.js";
|
|
14
14
|
import { windowResizer as nt } from "../window-resizer/index.js";
|
|
15
15
|
import { v as K } from "../Viewport-DA10iWAO.js";
|
|
16
|
-
var u,
|
|
16
|
+
var u, w, N, _;
|
|
17
17
|
class dt {
|
|
18
18
|
constructor() {
|
|
19
19
|
r(this, u, /* @__PURE__ */ new Map());
|
|
20
|
-
r(this,
|
|
20
|
+
r(this, w, []);
|
|
21
21
|
r(this, N, (h) => {
|
|
22
22
|
var s;
|
|
23
|
-
const e = [...t(this,
|
|
23
|
+
const e = [...t(this, w)].reverse().find((i) => i.clickOutside.current);
|
|
24
24
|
if (e) {
|
|
25
25
|
const i = h.composedPath();
|
|
26
26
|
if (i.find(
|
|
@@ -33,7 +33,7 @@ class dt {
|
|
|
33
33
|
});
|
|
34
34
|
r(this, _, (h) => {
|
|
35
35
|
if (h.code === "Escape") {
|
|
36
|
-
const e = [...t(this,
|
|
36
|
+
const e = [...t(this, w)].reverse().find((s) => s.escape.current);
|
|
37
37
|
e && e.close();
|
|
38
38
|
}
|
|
39
39
|
});
|
|
@@ -46,7 +46,7 @@ class dt {
|
|
|
46
46
|
return t(this, u);
|
|
47
47
|
}
|
|
48
48
|
get stack() {
|
|
49
|
-
return t(this,
|
|
49
|
+
return t(this, w);
|
|
50
50
|
}
|
|
51
51
|
add(h, e) {
|
|
52
52
|
if (e.closeRest.current)
|
|
@@ -62,10 +62,10 @@ class dt {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
let s = t(this, u).get(h);
|
|
65
|
-
s != null && s.length || (s = [], t(this, u).set(h, s)), t(this,
|
|
65
|
+
s != null && s.length || (s = [], t(this, u).set(h, s)), t(this, w).push(e), s.push(e);
|
|
66
66
|
}
|
|
67
67
|
remove(h, e) {
|
|
68
|
-
if (o(this,
|
|
68
|
+
if (o(this, w, t(this, w).filter((s) => s !== e)), e.closeRest.current) {
|
|
69
69
|
let s = [];
|
|
70
70
|
t(this, u).forEach((i) => {
|
|
71
71
|
i.forEach((c) => s.push(c));
|
|
@@ -81,9 +81,9 @@ class dt {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
u = new WeakMap(),
|
|
85
|
-
var m, q, H, C, W, v,
|
|
86
|
-
const
|
|
84
|
+
u = new WeakMap(), w = new WeakMap(), N = new WeakMap(), _ = new WeakMap();
|
|
85
|
+
var m, q, H, C, W, v, T, P, x, b, S, R, k, E, $, a, V, G, p, lt, M, Q, z, O, U, X, B;
|
|
86
|
+
const L = class L extends HTMLElement {
|
|
87
87
|
constructor() {
|
|
88
88
|
super();
|
|
89
89
|
r(this, p);
|
|
@@ -93,14 +93,14 @@ const w = class w extends HTMLElement {
|
|
|
93
93
|
r(this, C);
|
|
94
94
|
r(this, W);
|
|
95
95
|
r(this, v);
|
|
96
|
-
r(this,
|
|
96
|
+
r(this, T);
|
|
97
97
|
r(this, P);
|
|
98
98
|
r(this, x);
|
|
99
99
|
r(this, b);
|
|
100
100
|
r(this, S);
|
|
101
101
|
r(this, R);
|
|
102
|
-
r(this, T);
|
|
103
102
|
r(this, k);
|
|
103
|
+
r(this, E);
|
|
104
104
|
r(this, $);
|
|
105
105
|
r(this, a);
|
|
106
106
|
r(this, V);
|
|
@@ -110,24 +110,24 @@ const w = class w extends HTMLElement {
|
|
|
110
110
|
r(this, U);
|
|
111
111
|
r(this, X);
|
|
112
112
|
r(this, B);
|
|
113
|
-
this.urlValue = "", o(this, m, !1), o(this, v, new
|
|
113
|
+
this.urlValue = "", o(this, m, !1), o(this, v, new y(this, "--history", !1)), o(this, T, new y(this, "--restore", !1)), o(this, P, new y(this, "--close-rest", !1)), o(this, x, new y(
|
|
114
114
|
this,
|
|
115
115
|
"--close-rest-in-group",
|
|
116
116
|
!1
|
|
117
|
-
)), o(this, b, new
|
|
117
|
+
)), o(this, b, new y(this, "--group", "")), o(this, S, new y(this, "--click-outside", !1)), o(this, R, new y(this, "--escape", !1)), o(this, k, new y(this, "--check-viewport-bounds", !1)), o(this, E, !0), o(this, a, new ct(this, {
|
|
118
118
|
triggered: !1,
|
|
119
119
|
beforeopen: !1,
|
|
120
120
|
opened: !1,
|
|
121
121
|
closing: !1,
|
|
122
122
|
transitionend: !1
|
|
123
123
|
})), o(this, V, []), o(this, G, []), o(this, z, () => {
|
|
124
|
-
o(this,
|
|
124
|
+
o(this, E, !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, E, !0);
|
|
125
125
|
}), o(this, O, () => {
|
|
126
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, U).call(this);
|
|
127
127
|
}), o(this, U, at(() => {
|
|
128
128
|
t(this, X).call(this);
|
|
129
129
|
}, 10)), o(this, X, () => {
|
|
130
|
-
if (this.style.setProperty("--content-width", this.scrollWidth + "px"), this.style.setProperty("--content-height", this.scrollHeight + "px"), t(this,
|
|
130
|
+
if (this.style.setProperty("--content-width", this.scrollWidth + "px"), this.style.setProperty("--content-height", this.scrollHeight + "px"), t(this, k).current) {
|
|
131
131
|
const e = this.getBoundingClientRect();
|
|
132
132
|
let s = 0, i = 0;
|
|
133
133
|
e.right > K.width ? s = K.width - e.right : e.left < 0 && (s = e.left * -1), e.bottom > K.height ? i = K.height - e.bottom : e.top < 0 && (i = e.top * -1), this.style.setProperty("--viewport-offset-x", s + "px"), this.style.setProperty("--viewport-offset-y", i + "px");
|
|
@@ -135,7 +135,7 @@ const w = class w extends HTMLElement {
|
|
|
135
135
|
}), o(this, B, () => {
|
|
136
136
|
this.close();
|
|
137
137
|
}), t(this, b).subscribe((e) => {
|
|
138
|
-
e.previous && (
|
|
138
|
+
e.previous && (L.stack.remove(e.previous, this), e.current || (document.documentElement.classList.remove(
|
|
139
139
|
`${this.group.previous}-closing`
|
|
140
140
|
), document.documentElement.classList.remove(
|
|
141
141
|
`${this.group.previous}-opened`
|
|
@@ -146,7 +146,7 @@ const w = class w extends HTMLElement {
|
|
|
146
146
|
`${this.group.current}-closing`,
|
|
147
147
|
e.current.closing
|
|
148
148
|
);
|
|
149
|
-
const s =
|
|
149
|
+
const s = L.stack.groups.get(this.group.current), i = s == null ? void 0 : s.find((c) => c.opened);
|
|
150
150
|
document.documentElement.classList.toggle(
|
|
151
151
|
`${this.group.current}-opened`,
|
|
152
152
|
!!i
|
|
@@ -164,7 +164,7 @@ const w = class w extends HTMLElement {
|
|
|
164
164
|
return t(this, v);
|
|
165
165
|
}
|
|
166
166
|
get restore() {
|
|
167
|
-
return t(this,
|
|
167
|
+
return t(this, T);
|
|
168
168
|
}
|
|
169
169
|
get closeRest() {
|
|
170
170
|
return t(this, P);
|
|
@@ -201,9 +201,9 @@ const w = class w extends HTMLElement {
|
|
|
201
201
|
detail: {
|
|
202
202
|
trigger: t(this, $)
|
|
203
203
|
}
|
|
204
|
-
}), t(this, v).current && t(this,
|
|
204
|
+
}), t(this, v).current && t(this, E) && history.pushState(history.state, "", t(this, p, lt)), t(this, a).set("beforeopen", !0), o(this, m, !0);
|
|
205
205
|
const s = () => {
|
|
206
|
-
|
|
206
|
+
L.stack.add(t(this, b).current, this), t(this, G).forEach((i) => {
|
|
207
207
|
i.scroll({
|
|
208
208
|
top: 0,
|
|
209
209
|
left: 0,
|
|
@@ -222,7 +222,7 @@ const w = class w extends HTMLElement {
|
|
|
222
222
|
e != null && e.skipTransition ? s() : o(this, C, requestAnimationFrame(s));
|
|
223
223
|
}
|
|
224
224
|
close() {
|
|
225
|
-
t(this, m) && (o(this, m, !1), cancelAnimationFrame(t(this, C)), clearTimeout(t(this, W)),
|
|
225
|
+
t(this, m) && (o(this, m, !1), cancelAnimationFrame(t(this, C)), 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(() => {
|
|
226
226
|
t(this, a).set("opened", !1), t(this, a).set("closing", !0), f(this, p, M).call(this, !0, this.closingClass), D(this, "popoverClosing", {
|
|
227
227
|
custom: !0,
|
|
228
228
|
bubbles: !0
|
|
@@ -245,19 +245,19 @@ const w = class w extends HTMLElement {
|
|
|
245
245
|
...this.querySelectorAll(
|
|
246
246
|
`[data-popover-reset-scroll${this.id ? `="${this.id}"` : ""}]`
|
|
247
247
|
)
|
|
248
|
-
]), t(this, v).observe(), t(this,
|
|
249
|
-
t(this,
|
|
250
|
-
}, 0), t(this,
|
|
248
|
+
]), t(this, v).observe(), t(this, T).observe(), t(this, P).observe(), t(this, x).observe(), t(this, b).observe(), t(this, S).observe(), t(this, R).observe(), t(this, k).observe(), this.setAttribute("role", "dialog"), addEventListener("popstate", t(this, z)), setTimeout(() => {
|
|
249
|
+
t(this, T).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)) : (f(this, p, Q).call(this), o(this, E, !0));
|
|
250
|
+
}, 0), t(this, k).subscribe(() => {
|
|
251
251
|
t(this, O).call(this);
|
|
252
252
|
}), nt.subscribe(t(this, O));
|
|
253
253
|
}
|
|
254
254
|
disconnectedCallback() {
|
|
255
255
|
t(this, V).forEach((e) => {
|
|
256
256
|
e.removeEventListener("click", t(this, B));
|
|
257
|
-
}),
|
|
257
|
+
}), L.stack.remove(t(this, b).current, this), nt.unsubscribe(t(this, O)), t(this, a).close(), t(this, v).close(), t(this, T).close(), t(this, P).close(), t(this, x).close(), t(this, b).close(), t(this, S).close(), t(this, R).close(), t(this, k).close(), this.removeAttribute("role"), clearTimeout(t(this, q)), clearTimeout(t(this, H)), clearTimeout(t(this, C)), 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);
|
|
258
258
|
}
|
|
259
259
|
};
|
|
260
|
-
m = new WeakMap(), q = new WeakMap(), H = new WeakMap(), C = new WeakMap(), W = new WeakMap(), v = new WeakMap(),
|
|
260
|
+
m = new WeakMap(), q = new WeakMap(), H = new WeakMap(), C = new WeakMap(), W = new WeakMap(), v = new WeakMap(), T = new WeakMap(), P = new WeakMap(), x = new WeakMap(), b = new WeakMap(), S = new WeakMap(), R = new WeakMap(), k = new WeakMap(), E = new WeakMap(), $ = new WeakMap(), a = new WeakMap(), V = new WeakMap(), G = new WeakMap(), p = new WeakSet(), lt = function() {
|
|
261
261
|
return `${location.pathname}${location.search ? location.search + "&" : "?"}${this.idWithValue}`;
|
|
262
262
|
}, M = function(e, s) {
|
|
263
263
|
s && s.split(" ").map((i) => {
|
|
@@ -268,8 +268,8 @@ m = new WeakMap(), q = new WeakMap(), H = new WeakMap(), C = new WeakMap(), W =
|
|
|
268
268
|
const e = new URL(location.href);
|
|
269
269
|
e.searchParams.delete(this.id), history.replaceState(history.state, "", e.href);
|
|
270
270
|
}
|
|
271
|
-
}, z = new WeakMap(), O = new WeakMap(), U = new WeakMap(), X = new WeakMap(), B = new WeakMap(),
|
|
272
|
-
let Z =
|
|
271
|
+
}, z = new WeakMap(), O = new WeakMap(), U = new WeakMap(), X = new WeakMap(), B = new WeakMap(), L.stack = new dt();
|
|
272
|
+
let Z = L;
|
|
273
273
|
it && !customElements.get("e-popover") && customElements.define("e-popover", Z);
|
|
274
274
|
var n, g, A, et, Y, j, I, J, st;
|
|
275
275
|
class ft extends HTMLElement {
|
|
@@ -277,7 +277,7 @@ class ft extends HTMLElement {
|
|
|
277
277
|
super();
|
|
278
278
|
r(this, A);
|
|
279
279
|
r(this, n);
|
|
280
|
-
r(this, g, new
|
|
280
|
+
r(this, g, new y(this, "--type", "open"));
|
|
281
281
|
r(this, Y, () => {
|
|
282
282
|
t(this, g).current !== "close" && this.classList.add("triggered");
|
|
283
283
|
});
|