aptechka 0.65.0 → 0.65.1
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 +41 -47
- package/package.json +6 -6
package/lib/popover/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var te=c=>{throw TypeError(c)};var K=(c,o,t)=>o.has(c)||te("Cannot "+t);var e=(c,o,t)=>(K(c,o,"read from private field"),t?t.call(c):o.get(c)),r=(c,o,t)=>o.has(c)?te("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(c):o.set(c,t),n=(c,o,t,s)=>(K(c,o,"write to private field"),s?s.call(c,t):o.set(c,t),t),y=(c,o,t)=>(K(c,o,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const he=require("../element-linked-store/index.cjs"),g=require("../css-property/index.cjs"),_=require("../index-DekP7OZe.cjs"),X=require("../events-KVanG9sR.cjs"),ce=require("../function-MthRj-GJ.cjs"),se=require("../style-At6aDoqG.cjs");require("construct-style-sheets-polyfill");const ie=require("../url-lnBE_6yf.cjs"),re=require("../window-resizer/index.cjs"),Y=require("../Viewport-DB0qAZPJ.cjs");var u,b,I,J;class le{constructor(){r(this,u,new Map);r(this,b,[]);r(this,I,o=>{var s;const t=[...e(this,b)].reverse().find(i=>i.clickOutside.current);if(t){const i=o.composedPath();if(i.find(ee=>ee instanceof HTMLElement&&ee.hasAttribute("data-popover-content")))return;const l=i[0],p=l instanceof Node&&(t.contains(l)||((s=t.shadowRoot)==null?void 0:s.contains(l))),H=l instanceof HTMLElement&&l.hasAttribute("data-outside");(!p||H)&&t.close()}});r(this,J,o=>{if(o.code==="Escape"){const t=[...e(this,b)].reverse().find(s=>s.escape.current);t&&t.close()}});document.documentElement.addEventListener("click",e(this,I)),addEventListener("keydown",e(this,J))}get groups(){return e(this,u)}get stack(){return e(this,b)}add(o,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(o);i==null||i.forEach(l=>{l.close()})}let s=e(this,u).get(o);s!=null&&s.length||(s=[],e(this,u).set(o,s)),e(this,b).push(t),s.push(t)}remove(o,t){if(n(this,b,e(this,b).filter(s=>s!==t)),t.closeRest.current){let s=[];e(this,u).forEach(i=>{i.forEach(l=>s.push(l))}),e(this,u).clear(),s.forEach(i=>i.close())}else if(t.closeRestInGroup.current){const s=e(this,u).get(o);e(this,u).delete(o),s==null||s.forEach(i=>{i.close()})}else{let s=e(this,u).get(o);s&&(s=s.filter(i=>i!==t),e(this,u).set(o,s))}}}u=new WeakMap,b=new WeakMap,I=new WeakMap,J=new WeakMap;var f,$,M,A,B,v,w,C,x,m,R,q,L,T,O,a,P,oe,F,V,S,W,G;const E=class E extends HTMLElement{constructor(){super();r(this,P);r(this,f);r(this,$);r(this,M);r(this,A);r(this,B);r(this,v);r(this,w);r(this,C);r(this,x);r(this,m);r(this,R);r(this,q);r(this,L);r(this,T);r(this,O);r(this,a);r(this,V);r(this,S);r(this,W);r(this,G);this.urlValue="",n(this,f,!1),n(this,v,new g.CSSProperty(this,"--history",!1)),n(this,w,new g.CSSProperty(this,"--restore",!1)),n(this,C,new g.CSSProperty(this,"--close-rest",!1)),n(this,x,new g.CSSProperty(this,"--close-rest-in-group",!1)),n(this,m,new g.CSSProperty(this,"--group","")),n(this,R,new g.CSSProperty(this,"--click-outside",!1)),n(this,q,new g.CSSProperty(this,"--escape",!1)),n(this,L,new g.CSSProperty(this,"--check-viewport-bounds",!1)),n(this,T,!1),n(this,a,new he.ElementLinkedStore(this,{opened:!1,closing:!1,triggered:!1,transitionend:!1})),n(this,V,()=>{n(this,T,!1),e(this,f)&&e(this,v).current&&!location.search.includes(this.id)?this.close():!e(this,f)&&e(this,v).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),n(this,T,!0)}),n(this,S,()=>{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,W).call(this)}),n(this,W,ce.debounce(()=>{e(this,G).call(this)},10)),n(this,G,()=>{if(this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px"),e(this,L).current){const t=this.getBoundingClientRect();let s=0,i=0;t.right>Y.viewport.width?s=Y.viewport.width-t.right:t.left<0&&(s=t.left*-1),t.bottom>Y.viewport.height?i=Y.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")}}),e(this,m).subscribe(t=>{t.previous&&(E.stack.remove(t.previous,this),t.current||(document.documentElement.classList.remove(`${this.group.previous}-closing`),document.documentElement.classList.remove(`${this.group.previous}-opened`)))}),e(this,a).subscribe(t=>{if(this.group.current){document.documentElement.classList.toggle(`${this.group.current}-closing`,t.current.closing);const s=E.stack.groups.get(this.group.current),i=s==null?void 0:s.find(l=>l.opened);document.documentElement.classList.toggle(`${this.group.current}-opened`,!!i)}})}get history(){return e(this,v)}get restore(){return e(this,w)}get closeRest(){return e(this,C)}get closeRestInGroup(){return e(this,x)}get group(){return e(this,m)}get clickOutside(){return e(this,R)}get escape(){return e(this,q)}get opened(){return e(this,f)}get lastTrigger(){return e(this,O)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(t){this.urlValue=(t==null?void 0:t.toString())||"",e(this,f)&&ie.updateSearchParameter(this.id,t)}open(t){if(e(this,f))return;if(n(this,O,t==null?void 0:t.trigger),clearTimeout(e(this,$)),clearTimeout(e(this,M)),this.hasAttribute("data-document-class")){const i=this.getAttribute("data-document-class");document.documentElement.classList.add(i)}e(this,a).set("closing",!1),e(this,a).set("triggered",!0),X.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,O)}}),e(this,v).current&&e(this,T)&&history.pushState(history.state,"",e(this,P,oe)),n(this,f,!0);const s=()=>{E.stack.add(e(this,m).current,this),e(this,S).call(this),e(this,a).set("opened",!0),X.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,O)}}),n(this,A,void 0),n(this,B,setTimeout(()=>{e(this,a).set("transitionend",!0)},se.getElementTransitionDurationMS(this)+10))};t!=null&&t.skipTransition?s():n(this,A,setTimeout(s,10))}close(){if(e(this,f)){if(clearTimeout(e(this,A)),clearTimeout(e(this,B)),E.stack.remove(e(this,m).current,this),n(this,f,!1),y(this,P,F).call(this),this.hasAttribute("data-document-class")){const t=this.getAttribute("data-document-class");document.documentElement.classList.remove(t)}e(this,a).set("transitionend",!1),n(this,$,setTimeout(()=>{e(this,a).set("opened",!1),e(this,a).set("closing",!0),X.dispatchEvent(this,"popoverClosing",{custom:!0}),n(this,M,setTimeout(()=>{e(this,a).set("triggered",!1),e(this,a).set("closing",!1),X.dispatchEvent(this,"popoverClosed",{custom:!0})},se.getElementTransitionDurationMS(this)+10))},10))}}connectedCallback(){e(this,v).observe(),e(this,w).observe(),e(this,C).observe(),e(this,x).observe(),e(this,m).observe(),e(this,R).observe(),e(this,q).observe(),e(this,L).observe(),this.setAttribute("role","dialog"),addEventListener("popstate",e(this,V)),setTimeout(()=>{e(this,w).current?(this.urlValue=ie.parseSearchParameters(location.search)[this.id],e(this,V).call(this)):(y(this,P,F).call(this),n(this,T,!0))},0),e(this,L).subscribe(()=>{e(this,S).call(this)}),re.windowResizer.subscribe(e(this,S))}disconnectedCallback(){E.stack.remove(e(this,m).current,this),re.windowResizer.unsubscribe(e(this,S)),e(this,a).close(),e(this,v).close(),e(this,w).close(),e(this,C).close(),e(this,x).close(),e(this,m).close(),e(this,R).close(),e(this,q).close(),e(this,L).close(),this.removeAttribute("role"),clearTimeout(e(this,$)),clearTimeout(e(this,M)),clearTimeout(e(this,A)),clearTimeout(e(this,B)),removeEventListener("popstate",e(this,V)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),y(this,P,F).call(this)}};f=new WeakMap,$=new WeakMap,M=new WeakMap,A=new WeakMap,B=new WeakMap,v=new WeakMap,w=new WeakMap,C=new WeakMap,x=new WeakMap,m=new WeakMap,R=new WeakMap,q=new WeakMap,L=new WeakMap,T=new WeakMap,O=new WeakMap,a=new WeakMap,P=new WeakSet,oe=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},F=function(){if(e(this,v).current){const t=new URL(location.href);t.searchParams.delete(this.id),history.replaceState(history.state,"",t.href)}},V=new WeakMap,S=new WeakMap,W=new WeakMap,G=new WeakMap,E.stack=new le;let z=E;_.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",z);var h,d,k,Q,D,U,j,N,Z;class ne extends HTMLElement{constructor(){super();r(this,k);r(this,h);r(this,d,new g.CSSProperty(this,"--type","open"));r(this,D,()=>{e(this,d).current!=="close"&&this.classList.add("triggered")});r(this,U,()=>{e(this,d).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))});r(this,j,()=>{e(this,d).current!=="close"&&this.classList.remove("opened")});r(this,N,()=>{e(this,d).current!=="close"&&(this.classList.remove("triggered"),this.setAttribute("aria-expanded","false"))});_.isBrowser&&(this.addEventListener("click",()=>{if(e(this,h)){const t=e(this,d).current;t==="open"||t==="toggle"&&!e(this,h).opened?e(this,h).open({trigger:this}):(t==="close"||t==="toggle"&&e(this,h).opened)&&e(this,h).close()}}),this.addEventListener("keydown",t=>{t.code==="Space"&&!this.hasAttribute("keydown-disabled")&&(t.preventDefault(),this.click())}))}get type(){return e(this,d)}get popoverElement(){return e(this,h)}changePopover(t){var s;if(y(this,k,Q).call(this),t){let i=null;if(t==="parent"){const l=this.closest("[data-popover]");if(l)i=l;else{const p=this.getRootNode();p instanceof ShadowRoot?i=p.host.closest("[data-popover]"):p instanceof HTMLElement&&(i=p.closest("[data-popover]"))}}else if(t==="sibling")i=(s=this.parentElement)==null?void 0:s.querySelector("[data-popover]");else if(t==="ancestor-child"){const l=p=>{if(!p)return null;let H=p.querySelector("[data-popover]");return!H&&(p!=null&&p.parentElement)&&(H=l(p.parentElement)),H};i=l(this.parentElement)||null}else!t.startsWith(".")&&!t.startsWith("[")&&(t=`#${t}`),i=document.querySelector(t)||this.getRootNode().querySelector(t);i instanceof HTMLElement?(n(this,h,i),e(this,h).addEventListener("popoverTriggered",e(this,D)),e(this,h).addEventListener("popoverOpened",e(this,U)),e(this,h).addEventListener("popoverClosing",e(this,j)),e(this,h).addEventListener("popoverClosed",e(this,N))):console.warn(this,`target ${t} not found`)}y(this,k,Z).call(this,e(this,d).current)}connectedCallback(){e(this,d).subscribe(s=>{y(this,k,Z).call(this,s.current)}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("role")||this.setAttribute("role","button");const t=this.getAttribute("target");t&&this.changePopover(t),this.isConnected&&e(this,d).observe()}disconnectedCallback(){e(this,d).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),this.removeAttribute("role"),this.removeAttribute("tabindex"),y(this,k,Q).call(this)}}h=new WeakMap,d=new WeakMap,k=new WeakSet,Q=function(){e(this,h)&&(e(this,h).removeEventListener("popoverTriggered",e(this,D)),e(this,h).removeEventListener("popoverOpened",e(this,U)),e(this,h).removeEventListener("popoverClosing",e(this,j)),e(this,h).removeEventListener("popoverClosed",e(this,N)))},D=new WeakMap,U=new WeakMap,j=new WeakMap,N=new WeakMap,Z=function(t){e(this,h)instanceof z&&(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")))};_.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",ne);exports.PopoverButtonElement=ne;exports.PopoverElement=z;
|
|
1
|
+
"use strict";var te=l=>{throw TypeError(l)};var K=(l,o,t)=>o.has(l)||te("Cannot "+t);var e=(l,o,t)=>(K(l,o,"read from private field"),t?t.call(l):o.get(l)),r=(l,o,t)=>o.has(l)?te("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(l):o.set(l,t),n=(l,o,t,s)=>(K(l,o,"write to private field"),s?s.call(l,t):o.set(l,t),t),y=(l,o,t)=>(K(l,o,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const he=require("../element-linked-store/index.cjs"),g=require("../css-property/index.cjs"),_=require("../index-DekP7OZe.cjs"),X=require("../events-KVanG9sR.cjs"),ce=require("../function-MthRj-GJ.cjs"),se=require("../style-At6aDoqG.cjs");require("construct-style-sheets-polyfill");const ie=require("../url-lnBE_6yf.cjs"),re=require("../window-resizer/index.cjs"),Y=require("../Viewport-DB0qAZPJ.cjs");var u,b,I,J;class le{constructor(){r(this,u,new Map);r(this,b,[]);r(this,I,o=>{var s;const t=[...e(this,b)].reverse().find(i=>i.clickOutside.current);if(t){const i=o.composedPath();if(i.find(ee=>ee instanceof HTMLElement&&ee.hasAttribute("data-popover-content")))return;const c=i[0],p=c instanceof Node&&(t.contains(c)||((s=t.shadowRoot)==null?void 0:s.contains(c))),H=c instanceof HTMLElement&&c.hasAttribute("data-outside");(!p||H)&&t.close()}});r(this,J,o=>{if(o.code==="Escape"){const t=[...e(this,b)].reverse().find(s=>s.escape.current);t&&t.close()}});document.documentElement.addEventListener("click",e(this,I)),addEventListener("keydown",e(this,J))}get groups(){return e(this,u)}get stack(){return e(this,b)}add(o,t){if(t.closeRest.current)e(this,u).forEach(i=>{i.forEach(c=>{c.close()})});else if(t.closeRestInGroup.current){let i=e(this,u).get(o);i==null||i.forEach(c=>{c.close()})}let s=e(this,u).get(o);s!=null&&s.length||(s=[],e(this,u).set(o,s)),e(this,b).push(t),s.push(t)}remove(o,t){if(n(this,b,e(this,b).filter(s=>s!==t)),t.closeRest.current){let s=[];e(this,u).forEach(i=>{i.forEach(c=>s.push(c))}),e(this,u).clear(),s.forEach(i=>i.close())}else if(t.closeRestInGroup.current){const s=e(this,u).get(o);e(this,u).delete(o),s==null||s.forEach(i=>{i.close()})}else{let s=e(this,u).get(o);s&&(s=s.filter(i=>i!==t),e(this,u).set(o,s))}}}u=new WeakMap,b=new WeakMap,I=new WeakMap,J=new WeakMap;var f,$,M,A,B,v,w,C,x,m,R,q,L,T,O,a,P,oe,F,V,S,W,G;const E=class E extends HTMLElement{constructor(){super();r(this,P);r(this,f);r(this,$);r(this,M);r(this,A);r(this,B);r(this,v);r(this,w);r(this,C);r(this,x);r(this,m);r(this,R);r(this,q);r(this,L);r(this,T);r(this,O);r(this,a);r(this,V);r(this,S);r(this,W);r(this,G);this.urlValue="",n(this,f,!1),n(this,v,new g.CSSProperty(this,"--history",!1)),n(this,w,new g.CSSProperty(this,"--restore",!1)),n(this,C,new g.CSSProperty(this,"--close-rest",!1)),n(this,x,new g.CSSProperty(this,"--close-rest-in-group",!1)),n(this,m,new g.CSSProperty(this,"--group","")),n(this,R,new g.CSSProperty(this,"--click-outside",!1)),n(this,q,new g.CSSProperty(this,"--escape",!1)),n(this,L,new g.CSSProperty(this,"--check-viewport-bounds",!1)),n(this,T,!1),n(this,a,new he.ElementLinkedStore(this,{opened:!1,closing:!1,triggered:!1,transitionend:!1})),n(this,V,()=>{n(this,T,!1),e(this,f)&&e(this,v).current&&!location.search.includes(this.id)?this.close():!e(this,f)&&e(this,v).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),n(this,T,!0)}),n(this,S,()=>{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,W).call(this)}),n(this,W,ce.debounce(()=>{e(this,G).call(this)},10)),n(this,G,()=>{if(this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px"),e(this,L).current){const t=this.getBoundingClientRect();let s=0,i=0;t.right>Y.viewport.width?s=Y.viewport.width-t.right:t.left<0&&(s=t.left*-1),t.bottom>Y.viewport.height?i=Y.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")}}),e(this,m).subscribe(t=>{t.previous&&(E.stack.remove(t.previous,this),t.current||(document.documentElement.classList.remove(`${this.group.previous}-closing`),document.documentElement.classList.remove(`${this.group.previous}-opened`)))}),e(this,a).subscribe(t=>{if(this.group.current){document.documentElement.classList.toggle(`${this.group.current}-closing`,t.current.closing);const s=E.stack.groups.get(this.group.current),i=s==null?void 0:s.find(c=>c.opened);document.documentElement.classList.toggle(`${this.group.current}-opened`,!!i)}})}get history(){return e(this,v)}get restore(){return e(this,w)}get closeRest(){return e(this,C)}get closeRestInGroup(){return e(this,x)}get group(){return e(this,m)}get clickOutside(){return e(this,R)}get escape(){return e(this,q)}get opened(){return e(this,f)}get lastTrigger(){return e(this,O)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(t){this.urlValue=(t==null?void 0:t.toString())||"",e(this,f)&&ie.updateSearchParameter(this.id,t)}open(t){if(e(this,f))return;n(this,O,t==null?void 0:t.trigger),clearTimeout(e(this,$)),clearTimeout(e(this,M)),this.hasAttribute("data-document-class")&&this.getAttribute("data-document-class").split(" ").map(c=>{document.documentElement.classList.add(c.trim())}),e(this,a).set("closing",!1),e(this,a).set("triggered",!0),X.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:e(this,O)}}),e(this,v).current&&e(this,T)&&history.pushState(history.state,"",e(this,P,oe)),n(this,f,!0);const s=()=>{E.stack.add(e(this,m).current,this),e(this,S).call(this),e(this,a).set("opened",!0),X.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:e(this,O)}}),n(this,A,void 0),n(this,B,setTimeout(()=>{e(this,a).set("transitionend",!0)},se.getElementTransitionDurationMS(this)+10))};t!=null&&t.skipTransition?s():n(this,A,setTimeout(s,10))}close(){e(this,f)&&(clearTimeout(e(this,A)),clearTimeout(e(this,B)),E.stack.remove(e(this,m).current,this),n(this,f,!1),y(this,P,F).call(this),this.hasAttribute("data-document-class")&&this.getAttribute("data-document-class").split(" ").map(s=>{document.documentElement.classList.remove(s.trim())}),e(this,a).set("transitionend",!1),n(this,$,setTimeout(()=>{e(this,a).set("opened",!1),e(this,a).set("closing",!0),X.dispatchEvent(this,"popoverClosing",{custom:!0}),n(this,M,setTimeout(()=>{e(this,a).set("triggered",!1),e(this,a).set("closing",!1),X.dispatchEvent(this,"popoverClosed",{custom:!0})},se.getElementTransitionDurationMS(this)+10))},10)))}connectedCallback(){e(this,v).observe(),e(this,w).observe(),e(this,C).observe(),e(this,x).observe(),e(this,m).observe(),e(this,R).observe(),e(this,q).observe(),e(this,L).observe(),this.setAttribute("role","dialog"),addEventListener("popstate",e(this,V)),setTimeout(()=>{e(this,w).current?(this.urlValue=ie.parseSearchParameters(location.search)[this.id],e(this,V).call(this)):(y(this,P,F).call(this),n(this,T,!0))},0),e(this,L).subscribe(()=>{e(this,S).call(this)}),re.windowResizer.subscribe(e(this,S))}disconnectedCallback(){E.stack.remove(e(this,m).current,this),re.windowResizer.unsubscribe(e(this,S)),e(this,a).close(),e(this,v).close(),e(this,w).close(),e(this,C).close(),e(this,x).close(),e(this,m).close(),e(this,R).close(),e(this,q).close(),e(this,L).close(),this.removeAttribute("role"),clearTimeout(e(this,$)),clearTimeout(e(this,M)),clearTimeout(e(this,A)),clearTimeout(e(this,B)),removeEventListener("popstate",e(this,V)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),y(this,P,F).call(this)}};f=new WeakMap,$=new WeakMap,M=new WeakMap,A=new WeakMap,B=new WeakMap,v=new WeakMap,w=new WeakMap,C=new WeakMap,x=new WeakMap,m=new WeakMap,R=new WeakMap,q=new WeakMap,L=new WeakMap,T=new WeakMap,O=new WeakMap,a=new WeakMap,P=new WeakSet,oe=function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},F=function(){if(e(this,v).current){const t=new URL(location.href);t.searchParams.delete(this.id),history.replaceState(history.state,"",t.href)}},V=new WeakMap,S=new WeakMap,W=new WeakMap,G=new WeakMap,E.stack=new le;let z=E;_.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",z);var h,d,k,Q,D,N,U,j,Z;class ne extends HTMLElement{constructor(){super();r(this,k);r(this,h);r(this,d,new g.CSSProperty(this,"--type","open"));r(this,D,()=>{e(this,d).current!=="close"&&this.classList.add("triggered")});r(this,N,()=>{e(this,d).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))});r(this,U,()=>{e(this,d).current!=="close"&&this.classList.remove("opened")});r(this,j,()=>{e(this,d).current!=="close"&&(this.classList.remove("triggered"),this.setAttribute("aria-expanded","false"))});_.isBrowser&&(this.addEventListener("click",()=>{if(e(this,h)){const t=e(this,d).current;t==="open"||t==="toggle"&&!e(this,h).opened?e(this,h).open({trigger:this}):(t==="close"||t==="toggle"&&e(this,h).opened)&&e(this,h).close()}}),this.addEventListener("keydown",t=>{t.code==="Space"&&!this.hasAttribute("keydown-disabled")&&(t.preventDefault(),this.click())}))}get type(){return e(this,d)}get popoverElement(){return e(this,h)}changePopover(t){var s;if(y(this,k,Q).call(this),t){let i=null;if(t==="parent"){const c=this.closest("[data-popover]");if(c)i=c;else{const p=this.getRootNode();p instanceof ShadowRoot?i=p.host.closest("[data-popover]"):p instanceof HTMLElement&&(i=p.closest("[data-popover]"))}}else if(t==="sibling")i=(s=this.parentElement)==null?void 0:s.querySelector("[data-popover]");else if(t==="ancestor-child"){const c=p=>{if(!p)return null;let H=p.querySelector("[data-popover]");return!H&&(p!=null&&p.parentElement)&&(H=c(p.parentElement)),H};i=c(this.parentElement)||null}else!t.startsWith(".")&&!t.startsWith("[")&&(t=`#${t}`),i=document.querySelector(t)||this.getRootNode().querySelector(t);i instanceof HTMLElement?(n(this,h,i),e(this,h).addEventListener("popoverTriggered",e(this,D)),e(this,h).addEventListener("popoverOpened",e(this,N)),e(this,h).addEventListener("popoverClosing",e(this,U)),e(this,h).addEventListener("popoverClosed",e(this,j))):console.warn(this,`target ${t} not found`)}y(this,k,Z).call(this,e(this,d).current)}connectedCallback(){e(this,d).subscribe(s=>{y(this,k,Z).call(this,s.current)}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("role")||this.setAttribute("role","button");const t=this.getAttribute("target");t&&this.changePopover(t),this.isConnected&&e(this,d).observe()}disconnectedCallback(){e(this,d).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),this.removeAttribute("role"),this.removeAttribute("tabindex"),y(this,k,Q).call(this)}}h=new WeakMap,d=new WeakMap,k=new WeakSet,Q=function(){e(this,h)&&(e(this,h).removeEventListener("popoverTriggered",e(this,D)),e(this,h).removeEventListener("popoverOpened",e(this,N)),e(this,h).removeEventListener("popoverClosing",e(this,U)),e(this,h).removeEventListener("popoverClosed",e(this,j)))},D=new WeakMap,N=new WeakMap,U=new WeakMap,j=new WeakMap,Z=function(t){e(this,h)instanceof z&&(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")))};_.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",ne);exports.PopoverButtonElement=ne;exports.PopoverElement=z;
|
package/lib/popover/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var et = (
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var et = (a) => {
|
|
2
|
+
throw TypeError(a);
|
|
3
3
|
};
|
|
4
|
-
var K = (
|
|
5
|
-
var t = (
|
|
4
|
+
var K = (a, o, e) => o.has(a) || et("Cannot " + e);
|
|
5
|
+
var t = (a, o, e) => (K(a, o, "read from private field"), e ? e.call(a) : o.get(a)), r = (a, o, e) => o.has(a) ? et("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(a) : o.set(a, e), h = (a, o, e, s) => (K(a, o, "write to private field"), s ? s.call(a, e) : o.set(a, e), e), y = (a, o, e) => (K(a, o, "access private method"), e);
|
|
6
6
|
import { ElementLinkedStore as ot } from "../element-linked-store/index.js";
|
|
7
7
|
import { CSSProperty as g } from "../css-property/index.js";
|
|
8
8
|
import { i as _ } from "../index-Bv9zgfdb.js";
|
|
@@ -27,7 +27,7 @@ class at {
|
|
|
27
27
|
(tt) => tt instanceof HTMLElement && tt.hasAttribute("data-popover-content")
|
|
28
28
|
))
|
|
29
29
|
return;
|
|
30
|
-
const
|
|
30
|
+
const c = i[0], p = c instanceof Node && (e.contains(c) || ((s = e.shadowRoot) == null ? void 0 : s.contains(c))), G = c instanceof HTMLElement && c.hasAttribute("data-outside");
|
|
31
31
|
(!p || G) && e.close();
|
|
32
32
|
}
|
|
33
33
|
});
|
|
@@ -51,14 +51,14 @@ class at {
|
|
|
51
51
|
add(o, e) {
|
|
52
52
|
if (e.closeRest.current)
|
|
53
53
|
t(this, u).forEach((i) => {
|
|
54
|
-
i.forEach((
|
|
55
|
-
|
|
54
|
+
i.forEach((c) => {
|
|
55
|
+
c.close();
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
else if (e.closeRestInGroup.current) {
|
|
59
59
|
let i = t(this, u).get(o);
|
|
60
|
-
i == null || i.forEach((
|
|
61
|
-
|
|
60
|
+
i == null || i.forEach((c) => {
|
|
61
|
+
c.close();
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
let s = t(this, u).get(o);
|
|
@@ -68,7 +68,7 @@ class at {
|
|
|
68
68
|
if (h(this, b, t(this, b).filter((s) => s !== e)), e.closeRest.current) {
|
|
69
69
|
let s = [];
|
|
70
70
|
t(this, u).forEach((i) => {
|
|
71
|
-
i.forEach((
|
|
71
|
+
i.forEach((c) => s.push(c));
|
|
72
72
|
}), t(this, u).clear(), s.forEach((i) => i.close());
|
|
73
73
|
} else if (e.closeRestInGroup.current) {
|
|
74
74
|
const s = t(this, u).get(o);
|
|
@@ -140,7 +140,7 @@ const E = class E extends HTMLElement {
|
|
|
140
140
|
`${this.group.current}-closing`,
|
|
141
141
|
e.current.closing
|
|
142
142
|
);
|
|
143
|
-
const s = E.stack.groups.get(this.group.current), i = s == null ? void 0 : s.find((
|
|
143
|
+
const s = E.stack.groups.get(this.group.current), i = s == null ? void 0 : s.find((c) => c.opened);
|
|
144
144
|
document.documentElement.classList.toggle(
|
|
145
145
|
`${this.group.current}-opened`,
|
|
146
146
|
!!i
|
|
@@ -184,11 +184,9 @@ const E = class E extends HTMLElement {
|
|
|
184
184
|
open(e) {
|
|
185
185
|
if (t(this, f))
|
|
186
186
|
return;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
t(this, l).set("closing", !1), t(this, l).set("triggered", !0), X(this, "popoverTriggered", {
|
|
187
|
+
h(this, O, e == null ? void 0 : e.trigger), clearTimeout(t(this, M)), clearTimeout(t(this, H)), this.hasAttribute("data-document-class") && this.getAttribute("data-document-class").split(" ").map((c) => {
|
|
188
|
+
document.documentElement.classList.add(c.trim());
|
|
189
|
+
}), t(this, l).set("closing", !1), t(this, l).set("triggered", !0), X(this, "popoverTriggered", {
|
|
192
190
|
custom: !0,
|
|
193
191
|
detail: {
|
|
194
192
|
trigger: t(this, O)
|
|
@@ -207,21 +205,17 @@ const E = class E extends HTMLElement {
|
|
|
207
205
|
e != null && e.skipTransition ? s() : h(this, x, setTimeout(s, 10));
|
|
208
206
|
}
|
|
209
207
|
close() {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
t(this, l).set("
|
|
208
|
+
t(this, f) && (clearTimeout(t(this, x)), clearTimeout(t(this, W)), E.stack.remove(t(this, v).current, this), h(this, f, !1), y(this, A, j).call(this), this.hasAttribute("data-document-class") && this.getAttribute("data-document-class").split(" ").map((s) => {
|
|
209
|
+
document.documentElement.classList.remove(s.trim());
|
|
210
|
+
}), t(this, l).set("transitionend", !1), h(this, M, setTimeout(() => {
|
|
211
|
+
t(this, l).set("opened", !1), t(this, l).set("closing", !0), X(this, "popoverClosing", {
|
|
212
|
+
custom: !0
|
|
213
|
+
}), h(this, H, setTimeout(() => {
|
|
214
|
+
t(this, l).set("triggered", !1), t(this, l).set("closing", !1), X(this, "popoverClosed", {
|
|
217
215
|
custom: !0
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
});
|
|
222
|
-
}, st(this) + 10));
|
|
223
|
-
}, 10));
|
|
224
|
-
}
|
|
216
|
+
});
|
|
217
|
+
}, st(this) + 10));
|
|
218
|
+
}, 10)));
|
|
225
219
|
}
|
|
226
220
|
connectedCallback() {
|
|
227
221
|
t(this, m).observe(), t(this, w).observe(), t(this, S).observe(), t(this, C).observe(), t(this, v).observe(), t(this, R).observe(), t(this, $).observe(), t(this, L).observe(), this.setAttribute("role", "dialog"), addEventListener("popstate", t(this, V)), setTimeout(() => {
|
|
@@ -244,7 +238,7 @@ f = new WeakMap(), M = new WeakMap(), H = new WeakMap(), x = new WeakMap(), W =
|
|
|
244
238
|
}, V = new WeakMap(), k = new WeakMap(), q = new WeakMap(), z = new WeakMap(), E.stack = new at();
|
|
245
239
|
let F = E;
|
|
246
240
|
_ && !customElements.get("e-popover") && customElements.define("e-popover", F);
|
|
247
|
-
var n, d, P, Q, B, D, U,
|
|
241
|
+
var n, d, P, Q, B, N, D, U, Z;
|
|
248
242
|
class lt extends HTMLElement {
|
|
249
243
|
constructor() {
|
|
250
244
|
super();
|
|
@@ -254,13 +248,13 @@ class lt extends HTMLElement {
|
|
|
254
248
|
r(this, B, () => {
|
|
255
249
|
t(this, d).current !== "close" && this.classList.add("triggered");
|
|
256
250
|
});
|
|
257
|
-
r(this,
|
|
251
|
+
r(this, N, () => {
|
|
258
252
|
t(this, d).current !== "close" && (this.classList.add("opened"), this.setAttribute("aria-expanded", "true"));
|
|
259
253
|
});
|
|
260
|
-
r(this,
|
|
254
|
+
r(this, D, () => {
|
|
261
255
|
t(this, d).current !== "close" && this.classList.remove("opened");
|
|
262
256
|
});
|
|
263
|
-
r(this,
|
|
257
|
+
r(this, U, () => {
|
|
264
258
|
t(this, d).current !== "close" && (this.classList.remove("triggered"), this.setAttribute("aria-expanded", "false"));
|
|
265
259
|
});
|
|
266
260
|
_ && (this.addEventListener("click", () => {
|
|
@@ -283,9 +277,9 @@ class lt extends HTMLElement {
|
|
|
283
277
|
if (y(this, P, Q).call(this), e) {
|
|
284
278
|
let i = null;
|
|
285
279
|
if (e === "parent") {
|
|
286
|
-
const
|
|
287
|
-
if (
|
|
288
|
-
i =
|
|
280
|
+
const c = this.closest("[data-popover]");
|
|
281
|
+
if (c)
|
|
282
|
+
i = c;
|
|
289
283
|
else {
|
|
290
284
|
const p = this.getRootNode();
|
|
291
285
|
p instanceof ShadowRoot ? i = p.host.closest("[data-popover]") : p instanceof HTMLElement && (i = p.closest("[data-popover]"));
|
|
@@ -293,13 +287,13 @@ class lt extends HTMLElement {
|
|
|
293
287
|
} else if (e === "sibling")
|
|
294
288
|
i = (s = this.parentElement) == null ? void 0 : s.querySelector("[data-popover]");
|
|
295
289
|
else if (e === "ancestor-child") {
|
|
296
|
-
const
|
|
290
|
+
const c = (p) => {
|
|
297
291
|
if (!p)
|
|
298
292
|
return null;
|
|
299
293
|
let G = p.querySelector("[data-popover]");
|
|
300
|
-
return !G && (p != null && p.parentElement) && (G =
|
|
294
|
+
return !G && (p != null && p.parentElement) && (G = c(p.parentElement)), G;
|
|
301
295
|
};
|
|
302
|
-
i =
|
|
296
|
+
i = c(this.parentElement) || null;
|
|
303
297
|
} else
|
|
304
298
|
!e.startsWith(".") && !e.startsWith("[") && (e = `#${e}`), i = document.querySelector(e) || this.getRootNode().querySelector(e);
|
|
305
299
|
i instanceof HTMLElement ? (h(this, n, i), t(this, n).addEventListener(
|
|
@@ -307,13 +301,13 @@ class lt extends HTMLElement {
|
|
|
307
301
|
t(this, B)
|
|
308
302
|
), t(this, n).addEventListener(
|
|
309
303
|
"popoverOpened",
|
|
310
|
-
t(this,
|
|
304
|
+
t(this, N)
|
|
311
305
|
), t(this, n).addEventListener(
|
|
312
306
|
"popoverClosing",
|
|
313
|
-
t(this,
|
|
307
|
+
t(this, D)
|
|
314
308
|
), t(this, n).addEventListener(
|
|
315
309
|
"popoverClosed",
|
|
316
|
-
t(this,
|
|
310
|
+
t(this, U)
|
|
317
311
|
)) : console.warn(this, `target ${e} not found`);
|
|
318
312
|
}
|
|
319
313
|
y(this, P, Z).call(this, t(this, d).current);
|
|
@@ -335,15 +329,15 @@ n = new WeakMap(), d = new WeakMap(), P = new WeakSet(), Q = function() {
|
|
|
335
329
|
t(this, B)
|
|
336
330
|
), t(this, n).removeEventListener(
|
|
337
331
|
"popoverOpened",
|
|
338
|
-
t(this,
|
|
332
|
+
t(this, N)
|
|
339
333
|
), t(this, n).removeEventListener(
|
|
340
334
|
"popoverClosing",
|
|
341
|
-
t(this,
|
|
335
|
+
t(this, D)
|
|
342
336
|
), t(this, n).removeEventListener(
|
|
343
337
|
"popoverClosed",
|
|
344
|
-
t(this,
|
|
338
|
+
t(this, U)
|
|
345
339
|
));
|
|
346
|
-
}, B = new WeakMap(),
|
|
340
|
+
}, B = new WeakMap(), N = new WeakMap(), D = new WeakMap(), U = new WeakMap(), Z = function(e) {
|
|
347
341
|
t(this, n) instanceof F && (e !== "close" ? (this.setAttribute("aria-haspopup", "true"), this.setAttribute(
|
|
348
342
|
"aria-expanded",
|
|
349
343
|
t(this, n).opened ? "true" : "false"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aptechka",
|
|
3
|
-
"version": "0.65.
|
|
3
|
+
"version": "0.65.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/denisavitski/aptechka.git"
|
|
@@ -401,12 +401,12 @@
|
|
|
401
401
|
"dev": "vite --host --mode site"
|
|
402
402
|
},
|
|
403
403
|
"devDependencies": {
|
|
404
|
-
"@types/node": "^22.
|
|
404
|
+
"@types/node": "^22.13.17",
|
|
405
405
|
"@types/three": "^0.175.0",
|
|
406
|
-
"tsx": "^4.19.
|
|
407
|
-
"vite": "^6.
|
|
408
|
-
"vite-plugin-dts": "^4.3
|
|
409
|
-
"vite-plugin-htmc": "0.1.
|
|
406
|
+
"tsx": "^4.19.3",
|
|
407
|
+
"vite": "^6.2.4",
|
|
408
|
+
"vite-plugin-dts": "^4.5.3",
|
|
409
|
+
"vite-plugin-htmc": "0.1.16"
|
|
410
410
|
},
|
|
411
411
|
"dependencies": {
|
|
412
412
|
"construct-style-sheets-polyfill": "^3.1.0",
|