@ne1410s/popup
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@ne1410s/cust-elems");class t extends e.CustomElementBase{constructor(){super("data:text/css;base64,LmJhY2sgew0KICBwb3NpdGlvbjogZml4ZWQ7DQogIHRvcDogMDsgcmlnaHQ6IDA7IGJvdHRvbTogMDsgbGVmdDogMDsNCiAgYmFja2dyb3VuZC1jb2xvcjogcmdiYSgwLCAwLCAwLCAuODUpOw0KICBvcGFjaXR5OiAwOw0KICBvdmVyZmxvdzogaGlkZGVuOw0KICB0cmFuc2l0aW9uOiBvcGFjaXR5IC4zczsNCiAgei1pbmRleDogOTk5OTk7DQp9DQouYmFjazpub3QoLm9wZW4pIHsgcG9pbnRlci1ldmVudHM6IG5vbmU7IH0NCi5iYWNrLm9wZW4geyBvcGFjaXR5OiAxOyB9DQouYmFjay5vcGVuIC5mb3JlLnJlYWR5IHsgdHJhbnNpdGlvbjogYm94LXNoYWRvdyAuM3MsIGJhY2tncm91bmQtY29sb3IgLjNzOyB9DQouZm9yZS5vdmVyIHsgY3Vyc29yOiBtb3ZlOyBiYWNrZ3JvdW5kLWNvbG9yOiByZ2JhKDI1MCwgMjUwLCAyNTAsIDEpOyB9DQouZm9yZS5tb3ZpbmcgeyBjdXJzb3I6IGNyb3NzaGFpcjsgYmFja2dyb3VuZC1jb2xvcjogcmdiYSgyMzAsIDIzMCwgMjMwLCAxKTsgdXNlci1zZWxlY3Q6IG5vbmU7IH0NCi5mb3JlLm92ZXIsIC5mb3JlLm1vdmluZyB7IGJveC1zaGFkb3c6IGluc2V0IDAgMCAuNWVtIGJsYWNrIWltcG9ydGFudDsgfQ0KLmZvcmUgew0KICBiYWNrZ3JvdW5kLWNvbG9yOiAjZmZmOw0KICBtaW4td2lkdGg6IDFyZW07IG1heC13aWR0aDogMTAwdnc7DQogIG1pbi1oZWlnaHQ6IDFyZW07IG1heC1oZWlnaHQ6IDEwMHZoOw0KICBwb3NpdGlvbjogYWJzb2x1dGU7IG92ZXJmbG93OiBoaWRkZW47DQogIHRvcDogNTAlOyBsZWZ0OiA1MCU7DQogIHRyYW5zaXRpb246IHRyYW5zZm9ybSAuM3M7DQp9DQouZm9yZSA+IHNwYW4gew0KICBwb3NpdGlvbjogYWJzb2x1dGU7DQogIGZvbnQtc2l6ZTogMS41ZW07DQogIHVzZXItc2VsZWN0OiBub25lOw0KICBjb2xvcjogcmdiYSgwLCAwLCAwLCAuMyk7DQp9DQouZm9yZS5uby1jbG9zZSB7IG1heC13aWR0aDogY2FsYygxMDB2dyAtIDFlbSk7IG1heC1oZWlnaHQ6IGNhbGMoMTAwdmggLSAxZW0pOyB9DQouZm9yZS5uby1jbG9zZSAuY2xvc2UgeyBkaXNwbGF5OiBub25lOyB9DQouZm9yZSAuY2xvc2UgeyBjdXJzb3I6IHBvaW50ZXI7IHRvcDogLTZweDsgcmlnaHQ6IDA7IHBhZGRpbmc6IC4yZW07IH0NCi5mb3JlOm5vdCgucmVzaXplKSAuc2UtcmVzaXplIHsgZGlzcGxheTogbm9uZTsgfQ0KLmZvcmUgLnNlLXJlc2l6ZSB7IGN1cnNvcjogc2UtcmVzaXplOyBib3R0b206IC05cHg7IHJpZ2h0OiAtNHB4OyB9","data:text/html;base64,PGRpdiBjbGFzcz0iYmFjayI+DQogIDxkaXYgY2xhc3M9ImZvcmUiPg0KICAgIDxzbG90Pjwvc2xvdD4NCiAgICA8c3BhbiBjbGFzcz0iY2xvc2UiPiZ0aW1lczs8L3NwYW4+DQogICAgPHNwYW4gY2xhc3M9InNlLXJlc2l6ZSI+JiN4MjVlMjs8L3NwYW4+DQogIDwvZGl2Pg0KPC9kaXY+"),this._styles={};const e=this.root.querySelector(".back"),t=e.querySelector(".fore"),s=t.querySelector(".se-resize"),i=t.querySelector(".close");this.resetOffscreenPosition(t),i.addEventListener("click",()=>this.close()),s.addEventListener("mousedown",()=>{t.classList.toggle("over",this.canResize),t.classList.toggle("resizing",this.canResize)}),e.addEventListener("mousedown",s=>{this._drag=s.target===e?"back":s.target===t?"fore":"fore*",this._coords="fore"!==this._drag?null:{x:s.offsetX,y:s.offsetY},t.classList.toggle("moving",this.canMove&&"fore"===this._drag)}),t.addEventListener("mouseover",e=>t.classList.toggle("over",this.canMove&&e.target===t)),t.addEventListener("mouseout",()=>t.classList.remove("over")),window.addEventListener("mousemove",s=>{const i=t.getBoundingClientRect();if(t.classList.contains("resizing")){const e=5;t.style.width=e+s.pageX-i.x+"px",t.style.height=e+s.pageY-i.y+"px"}else if(this.canMove&&"fore"===this._drag&&this._coords){const i=e.getBoundingClientRect(),o=i.width-window.innerWidth,r=i.height-window.innerHeight,a=100*Math.max(0,s.pageX-this._coords.x)/window.innerWidth,c=100*Math.max(0,s.pageY-this._coords.y)/window.innerHeight,n=`min(${a.toFixed(2)}vw, ${o}px + 100vw - 100%)`,l=`min(${c.toFixed(2)}vh, ${r}px + 100vh - 100%)`;t.style.top=t.style.left="0",t.style.transform=`translate(${n}, ${l})`}}),window.addEventListener("mouseup",()=>{this._drag=null,t.classList.remove("moving","resizing")}),e.addEventListener("mouseup",s=>{"back"===this._drag&&s.target===e&&this.dismiss(),this._drag=null,t.classList.remove("moving","resizing")}),t.addEventListener("transitionend",s=>{"transform"===s.propertyName&&(e.classList.contains("open")?t.classList.add("ready"):this.resetOffscreenPosition(t))})}get canMove(){return this.hasAttribute("move")}get canResize(){return this.hasAttribute("resize")}get canShrink(){return this.canResize&&this.hasAttribute("shrink")}get canClose(){return!this.hasAttribute("no-close")}close(){this.removeAttribute("open")}open(){this.setAttribute("open","")}wrap(e){const t="function"==typeof e.append?e:document.querySelector(e+"");this.appendChild(t)}confirm(){const e=!!this.confirmCallback,t=!e||this.confirmCallback();e&&this.fire(t?"confirmaccept":"confirmreject"),t&&this.close()}dismiss(){const e=!!this.dismissCallback,t=!e||this.dismissCallback();e&&this.fire(t?"dismissaccept":"dismissreject"),t&&this.close()}attributeChangedCallback(e,s,i){switch(e){case"open":const e=this.root.querySelector(".back"),s=e.querySelector(".fore"),o=!!i||"string"==typeof i;if(s.classList.remove("ready","moving"),s.style.transform=o?"translate(-50%, -50%)":s.style.transform+" translateY(-100vh)",s.classList.toggle("resize",this.canResize),s.classList.toggle("no-close",!this.canClose),e.classList.toggle("open",o),o&&this.propagateSupportedStyles(e),!this.canShrink){const e=s.getBoundingClientRect();s.style.minWidth=e.width+"px",s.style.minHeight=e.height+"px"}this.fire(o?"open":"close");break;case"style":i&&(t.STYLE_KEYS.map(e=>({key:e,value:this.style[e]})).filter(e=>e.value).forEach(e=>this._styles[e.key]=e.value),this.removeAttribute("style"))}}connectedCallback(){const e=this.root.querySelector(".back"),t=e.querySelector(".fore");e.classList.contains("open")&&t.classList.add("ready")}disconnectedCallback(){}resetOffscreenPosition(e){e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -100vh)",e.style.minWidth=e.style.width="",e.style.minHeight=e.style.height=""}propagateSupportedStyles(e){["backgroundColor"].forEach(t=>{e.style[t]=this._styles[t]});const t=e.querySelector(".fore");["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","boxShadow"].forEach(e=>{t.style[e]=this._styles[e]})}fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}}t.observedAttributes=["open","style"],t.STYLE_KEYS=["backgroundColor","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","boxShadow"],"customElements"in window&&window.customElements.define("ne14-pop",t),exports.Popup=t; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@ne1410s/cust-elems");class t extends e.CustomElementBase{constructor(){super("data:text/css;base64,LmJhY2sgew0KICBwb3NpdGlvbjogZml4ZWQ7DQogIHRvcDogMDsgcmlnaHQ6IDA7IGJvdHRvbTogMDsgbGVmdDogMDsNCiAgYmFja2dyb3VuZC1jb2xvcjogcmdiYSgwLCAwLCAwLCAuODUpOw0KICBvcGFjaXR5OiAwOw0KICB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13aWR0aDogY2FsYygxMDB2dyAtIDFlbSk7IG1heC1oZWlnaHQ6IGNhbGMoMTAwdmggLSAxZW0pOyB9DQouZm9yZS5uby1jbG9zZSAuY2xvc2UgeyBkaXNwbGF5OiBub25lOyB9DQouZm9yZSAuY2xvc2UgeyBjdXJzb3I6IHBvaW50ZXI7IHRvcDogLTZweDsgcmlnaHQ6IDA7IHBhZGRpbmc6IC4yZW07IH0NCi5mb3JlOm5vdCgucmVzaXplKSAuc2UtcmVzaXplIHsgZGlzcGxheTogbm9uZTsgfQ0KLmZvcmUgLnNlLXJlc2l6ZSB7IGN1cnNvcjogc2UtcmVzaXplOyBib3R0b206IC05cHg7IHJpZ2h0OiAtNHB4OyB9","data:text/html;base64,PGRpdiBjbGFzcz0iYmFjayI+DQogIDxkaXYgY2xhc3M9ImZvcmUiPg0KICAgIDxzbG90Pjwvc2xvdD4NCiAgICA8c3BhbiBjbGFzcz0iY2xvc2UiPiZ0aW1lczs8L3NwYW4+DQogICAgPHNwYW4gY2xhc3M9InNlLXJlc2l6ZSI+JiN4MjVlMjs8L3NwYW4+DQogIDwvZGl2Pg0KPC9kaXY+"),this._styles={};const e=this.root.querySelector(".back"),t=e.querySelector(".fore"),s=t.querySelector(".se-resize"),i=t.querySelector(".close");this.resetOffscreenPosition(t),i.addEventListener("click",()=>this.close()),s.addEventListener("mousedown",()=>{t.classList.toggle("over",this.canResize),t.classList.toggle("resizing",this.canResize)}),e.addEventListener("mousedown",s=>{this._drag=s.target===e?"back":s.target===t?"fore":"fore*",this._coords="fore"!==this._drag?null:{x:s.offsetX,y:s.offsetY},t.classList.toggle("moving",this.canMove&&"fore"===this._drag)}),t.addEventListener("mouseover",e=>t.classList.toggle("over",this.canMove&&e.target===t)),t.addEventListener("mouseout",()=>t.classList.remove("over")),window.addEventListener("mousemove",s=>{const i=t.getBoundingClientRect();if(t.classList.contains("resizing")){const e=5;t.style.width=e+s.pageX-i.x+"px",t.style.height=e+s.pageY-i.y+"px"}else if(this.canMove&&"fore"===this._drag&&this._coords){const i=e.getBoundingClientRect(),o=i.width-window.innerWidth,r=i.height-window.innerHeight,a=100*Math.max(0,s.pageX-this._coords.x)/window.innerWidth,c=100*Math.max(0,s.pageY-this._coords.y)/window.innerHeight,n=`min(${a.toFixed(2)}vw, ${o}px + 100vw - 100%)`,l=`min(${c.toFixed(2)}vh, ${r}px + 100vh - 100%)`;t.style.top=t.style.left="0",t.style.transform=`translate(${n}, ${l})`}}),window.addEventListener("mouseup",()=>{this._drag=null,t.classList.remove("moving","resizing")}),e.addEventListener("mouseup",s=>{"back"===this._drag&&s.target===e&&this.dismiss(),this._drag=null,t.classList.remove("moving","resizing")}),t.addEventListener("transitionend",s=>{"transform"===s.propertyName&&(e.classList.contains("open")?t.classList.add("ready"):this.resetOffscreenPosition(t))})}get canMove(){return this.hasAttribute("move")}get canResize(){return this.hasAttribute("resize")}get canShrink(){return this.canResize&&this.hasAttribute("shrink")}get canClose(){return!this.hasAttribute("no-close")}close(){this.removeAttribute("open")}open(){this.setAttribute("open","")}wrap(e){const t="function"==typeof e.append?e:document.querySelector(e+"");this.appendChild(t)}confirm(){const e=!!this.confirmCallback,t=!e||this.confirmCallback();e&&this.fire(t?"confirmaccept":"confirmreject"),t&&this.close()}dismiss(){const e=!!this.dismissCallback,t=!e||this.dismissCallback();e&&this.fire(t?"dismissaccept":"dismissreject"),t&&this.close()}attributeChangedCallback(e,s,i){switch(e){case"open":const e=this.root.querySelector(".back"),s=e.querySelector(".fore"),o=!!i||"string"==typeof i;s.classList.remove("ready","moving"),s.style.transform=o?"translate(-50%, -50%)":s.style.transform+" translateY(-100vh)",s.classList.toggle("resize",this.canResize),s.classList.toggle("no-close",!this.canClose),e.classList.toggle("open",o),o&&(this.propagateSupportedStyles(e),this.canShrink||this.fixMinSize()),this.fire(o?"open":"close");break;case"style":i&&(t.STYLE_KEYS.map(e=>({key:e,value:this.style[e]})).filter(e=>e.value).forEach(e=>this._styles[e.key]=e.value),this.removeAttribute("style"))}}connectedCallback(){const e=this.root.querySelector(".back"),t=e.querySelector(".fore");e.classList.contains("open")&&t.classList.add("ready")}fixMinSize(){const e=this.root.querySelector(".fore");e.style.minWidth=e.style.width="",e.style.minHeight=e.style.height="";const t=e.getBoundingClientRect();e.style.minWidth=t.width+"px",e.style.minHeight=t.height+"px"}resetOffscreenPosition(e){e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -100vh)"}propagateSupportedStyles(e){["backgroundColor"].forEach(t=>{e.style[t]=this._styles[t]});const t=e.querySelector(".fore");["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","boxShadow"].forEach(e=>{t.style[e]=this._styles[e]})}fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}}t.observedAttributes=["open","style"],t.STYLE_KEYS=["backgroundColor","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","boxShadow"],"customElements"in window&&window.customElements.define("ne14-pop",t),exports.Popup=t; |
@@ -1,1 +0,1 @@ | ||
import{CustomElementBase as e}from"@ne1410s/cust-elems";class t extends e{constructor(){super("data:text/css;base64,LmJhY2sgew0KICBwb3NpdGlvbjogZml4ZWQ7DQogIHRvcDogMDsgcmlnaHQ6IDA7IGJvdHRvbTogMDsgbGVmdDogMDsNCiAgYmFja2dyb3VuZC1jb2xvcjogcmdiYSgwLCAwLCAwLCAuODUpOw0KICBvcGFjaXR5OiAwOw0KICBvdmVyZmxvdzogaGlkZGVuOw0KICB0cmFuc2l0aW9uOiBvcGFjaXR5IC4zczsNCiAgei1pbmRleDogOTk5OTk7DQp9DQouYmFjazpub3QoLm9wZW4pIHsgcG9pbnRlci1ldmVudHM6IG5vbmU7IH0NCi5iYWNrLm9wZW4geyBvcGFjaXR5OiAxOyB9DQouYmFjay5vcGVuIC5mb3JlLnJlYWR5IHsgdHJhbnNpdGlvbjogYm94LXNoYWRvdyAuM3MsIGJhY2tncm91bmQtY29sb3IgLjNzOyB9DQouZm9yZS5vdmV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mZvcmUgLnNlLXJlc2l6ZSB7IGN1cnNvcjogc2UtcmVzaXplOyBib3R0b206IC05cHg7IHJpZ2h0OiAtNHB4OyB9","data:text/html;base64,PGRpdiBjbGFzcz0iYmFjayI+DQogIDxkaXYgY2xhc3M9ImZvcmUiPg0KICAgIDxzbG90Pjwvc2xvdD4NCiAgICA8c3BhbiBjbGFzcz0iY2xvc2UiPiZ0aW1lczs8L3NwYW4+DQogICAgPHNwYW4gY2xhc3M9InNlLXJlc2l6ZSI+JiN4MjVlMjs8L3NwYW4+DQogIDwvZGl2Pg0KPC9kaXY+"),this._styles={};const e=this.root.querySelector(".back"),t=e.querySelector(".fore"),s=t.querySelector(".se-resize"),i=t.querySelector(".close");this.resetOffscreenPosition(t),i.addEventListener("click",()=>this.close()),s.addEventListener("mousedown",()=>{t.classList.toggle("over",this.canResize),t.classList.toggle("resizing",this.canResize)}),e.addEventListener("mousedown",s=>{this._drag=s.target===e?"back":s.target===t?"fore":"fore*",this._coords="fore"!==this._drag?null:{x:s.offsetX,y:s.offsetY},t.classList.toggle("moving",this.canMove&&"fore"===this._drag)}),t.addEventListener("mouseover",e=>t.classList.toggle("over",this.canMove&&e.target===t)),t.addEventListener("mouseout",()=>t.classList.remove("over")),window.addEventListener("mousemove",s=>{const i=t.getBoundingClientRect();if(t.classList.contains("resizing")){const e=5;t.style.width=e+s.pageX-i.x+"px",t.style.height=e+s.pageY-i.y+"px"}else if(this.canMove&&"fore"===this._drag&&this._coords){const i=e.getBoundingClientRect(),o=i.width-window.innerWidth,a=i.height-window.innerHeight,r=100*Math.max(0,s.pageX-this._coords.x)/window.innerWidth,c=100*Math.max(0,s.pageY-this._coords.y)/window.innerHeight,n=`min(${r.toFixed(2)}vw, ${o}px + 100vw - 100%)`,l=`min(${c.toFixed(2)}vh, ${a}px + 100vh - 100%)`;t.style.top=t.style.left="0",t.style.transform=`translate(${n}, ${l})`}}),window.addEventListener("mouseup",()=>{this._drag=null,t.classList.remove("moving","resizing")}),e.addEventListener("mouseup",s=>{"back"===this._drag&&s.target===e&&this.dismiss(),this._drag=null,t.classList.remove("moving","resizing")}),t.addEventListener("transitionend",s=>{"transform"===s.propertyName&&(e.classList.contains("open")?t.classList.add("ready"):this.resetOffscreenPosition(t))})}get canMove(){return this.hasAttribute("move")}get canResize(){return this.hasAttribute("resize")}get canShrink(){return this.canResize&&this.hasAttribute("shrink")}get canClose(){return!this.hasAttribute("no-close")}close(){this.removeAttribute("open")}open(){this.setAttribute("open","")}wrap(e){const t="function"==typeof e.append?e:document.querySelector(e+"");this.appendChild(t)}confirm(){const e=!!this.confirmCallback,t=!e||this.confirmCallback();e&&this.fire(t?"confirmaccept":"confirmreject"),t&&this.close()}dismiss(){const e=!!this.dismissCallback,t=!e||this.dismissCallback();e&&this.fire(t?"dismissaccept":"dismissreject"),t&&this.close()}attributeChangedCallback(e,s,i){switch(e){case"open":const e=this.root.querySelector(".back"),s=e.querySelector(".fore"),o=!!i||"string"==typeof i;if(s.classList.remove("ready","moving"),s.style.transform=o?"translate(-50%, -50%)":s.style.transform+" translateY(-100vh)",s.classList.toggle("resize",this.canResize),s.classList.toggle("no-close",!this.canClose),e.classList.toggle("open",o),o&&this.propagateSupportedStyles(e),!this.canShrink){const e=s.getBoundingClientRect();s.style.minWidth=e.width+"px",s.style.minHeight=e.height+"px"}this.fire(o?"open":"close");break;case"style":i&&(t.STYLE_KEYS.map(e=>({key:e,value:this.style[e]})).filter(e=>e.value).forEach(e=>this._styles[e.key]=e.value),this.removeAttribute("style"))}}connectedCallback(){const e=this.root.querySelector(".back"),t=e.querySelector(".fore");e.classList.contains("open")&&t.classList.add("ready")}disconnectedCallback(){}resetOffscreenPosition(e){e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -100vh)",e.style.minWidth=e.style.width="",e.style.minHeight=e.style.height=""}propagateSupportedStyles(e){["backgroundColor"].forEach(t=>{e.style[t]=this._styles[t]});const t=e.querySelector(".fore");["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","boxShadow"].forEach(e=>{t.style[e]=this._styles[e]})}fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}}t.observedAttributes=["open","style"],t.STYLE_KEYS=["backgroundColor","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","boxShadow"],"customElements"in window&&window.customElements.define("ne14-pop",t);export{t as Popup}; | ||
import{CustomElementBase as e}from"@ne1410s/cust-elems";class t extends e{constructor(){super("data:text/css;base64,LmJhY2sgew0KICBwb3NpdGlvbjogZml4ZWQ7DQogIHRvcDogMDsgcmlnaHQ6IDA7IGJvdHRvbTogMDsgbGVmdDogMDsNCiAgYmFja2dyb3VuZC1jb2xvcjogcmdiYSgwLCAwLCAwLCAuODUpOw0KICBvcGFjaXR5OiAwOw0KICBvdmVyZmxvdzogaGlkZGVuOw0KICB0cmFuc2l0aW9uOiBvcGFjaXR5IC4zczsNCiAgei1pbmRleDogOTk5OTk7DQp9DQouYmFjazpub3QoLm9wZW4pIHsgcG9pbnRlci1ldmVudHM6IG5vbmU7IH0NCi5iYWNrLm9wZW4geyBvcGFjaXR5OiAxOyB9DQouYmFjay5vcGVuIC5mb3JlLnJlYWR5IHsgdHJhbnNpdGlvbjogYm94LXNoYWRvdyAuM3MsIGJhY2tncm91bmQtY29sb3IgLjNzOyB9DQouZm9yZS5vdmVyIHsgY3Vyc29yOiBtb3ZlOyBiYWNrZ3JvdW5kLWNvbG9yOiByZ2JhKDI1MCwgMjUwLCAyNTAsIDEpOyB9DQouZm9yZS5tb3ZpbmcgeyBjdXJzb3I6IGNyb3NzaGFpcjsgYmFja2dyb3VuZC1jb2xvcjogcmdiYSgyMzAsIDIzMCwgMjMwLCAxKTsgdXNlci1zZWxlY3Q6IG5vbmU7IH0NCi5mb3JlLm92ZXIsIC5mb3JlLm1vdmluZyB7IGJveC1zaGFkb3c6IGluc2V0IDAgMCAuNWVtIGJsYWNrIWltcG9ydGFudDsgfQ0KLmZvcmUgew0KICBi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".back"),t=e.querySelector(".fore"),s=t.querySelector(".se-resize"),i=t.querySelector(".close");this.resetOffscreenPosition(t),i.addEventListener("click",()=>this.close()),s.addEventListener("mousedown",()=>{t.classList.toggle("over",this.canResize),t.classList.toggle("resizing",this.canResize)}),e.addEventListener("mousedown",s=>{this._drag=s.target===e?"back":s.target===t?"fore":"fore*",this._coords="fore"!==this._drag?null:{x:s.offsetX,y:s.offsetY},t.classList.toggle("moving",this.canMove&&"fore"===this._drag)}),t.addEventListener("mouseover",e=>t.classList.toggle("over",this.canMove&&e.target===t)),t.addEventListener("mouseout",()=>t.classList.remove("over")),window.addEventListener("mousemove",s=>{const i=t.getBoundingClientRect();if(t.classList.contains("resizing")){const e=5;t.style.width=e+s.pageX-i.x+"px",t.style.height=e+s.pageY-i.y+"px"}else if(this.canMove&&"fore"===this._drag&&this._coords){const i=e.getBoundingClientRect(),o=i.width-window.innerWidth,r=i.height-window.innerHeight,a=100*Math.max(0,s.pageX-this._coords.x)/window.innerWidth,c=100*Math.max(0,s.pageY-this._coords.y)/window.innerHeight,n=`min(${a.toFixed(2)}vw, ${o}px + 100vw - 100%)`,l=`min(${c.toFixed(2)}vh, ${r}px + 100vh - 100%)`;t.style.top=t.style.left="0",t.style.transform=`translate(${n}, ${l})`}}),window.addEventListener("mouseup",()=>{this._drag=null,t.classList.remove("moving","resizing")}),e.addEventListener("mouseup",s=>{"back"===this._drag&&s.target===e&&this.dismiss(),this._drag=null,t.classList.remove("moving","resizing")}),t.addEventListener("transitionend",s=>{"transform"===s.propertyName&&(e.classList.contains("open")?t.classList.add("ready"):this.resetOffscreenPosition(t))})}get canMove(){return this.hasAttribute("move")}get canResize(){return this.hasAttribute("resize")}get canShrink(){return this.canResize&&this.hasAttribute("shrink")}get canClose(){return!this.hasAttribute("no-close")}close(){this.removeAttribute("open")}open(){this.setAttribute("open","")}wrap(e){const t="function"==typeof e.append?e:document.querySelector(e+"");this.appendChild(t)}confirm(){const e=!!this.confirmCallback,t=!e||this.confirmCallback();e&&this.fire(t?"confirmaccept":"confirmreject"),t&&this.close()}dismiss(){const e=!!this.dismissCallback,t=!e||this.dismissCallback();e&&this.fire(t?"dismissaccept":"dismissreject"),t&&this.close()}attributeChangedCallback(e,s,i){switch(e){case"open":const e=this.root.querySelector(".back"),s=e.querySelector(".fore"),o=!!i||"string"==typeof i;s.classList.remove("ready","moving"),s.style.transform=o?"translate(-50%, -50%)":s.style.transform+" translateY(-100vh)",s.classList.toggle("resize",this.canResize),s.classList.toggle("no-close",!this.canClose),e.classList.toggle("open",o),o&&(this.propagateSupportedStyles(e),this.canShrink||this.fixMinSize()),this.fire(o?"open":"close");break;case"style":i&&(t.STYLE_KEYS.map(e=>({key:e,value:this.style[e]})).filter(e=>e.value).forEach(e=>this._styles[e.key]=e.value),this.removeAttribute("style"))}}connectedCallback(){const e=this.root.querySelector(".back"),t=e.querySelector(".fore");e.classList.contains("open")&&t.classList.add("ready")}fixMinSize(){const e=this.root.querySelector(".fore");e.style.minWidth=e.style.width="",e.style.minHeight=e.style.height="";const t=e.getBoundingClientRect();e.style.minWidth=t.width+"px",e.style.minHeight=t.height+"px"}resetOffscreenPosition(e){e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -100vh)"}propagateSupportedStyles(e){["backgroundColor"].forEach(t=>{e.style[t]=this._styles[t]});const t=e.querySelector(".fore");["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","boxShadow"].forEach(e=>{t.style[e]=this._styles[e]})}fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}}t.observedAttributes=["open","style"],t.STYLE_KEYS=["backgroundColor","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","boxShadow"],"customElements"in window&&window.customElements.define("ne14-pop",t);export{t as Popup}; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ne_pop={})}(this,(function(e){"use strict";class t extends HTMLElement{constructor(e,t,s="closed"){super(),this.root=this.attachShadow({mode:s}),this.root.innerHTML=this.decode(t);const o=document.createElement("style");o.textContent=this.decode(e),this.root.appendChild(o)}decode(e){const t=(e+"").indexOf("base64,");return-1===t?e:window.atob(e.substring(t+7))}}class s extends t{constructor(){super("data:text/css;base64,LmJhY2sgew0KICBwb3NpdGlvbjogZml4ZWQ7DQogIHRvcDogMDsgcmlnaHQ6IDA7IGJvdHRvbTogMDsgbGVmdDogMDsNCiAgYmFja2dyb3VuZC1jb2xvcjogcmdiYSgwLCAwLCAwLCAuODUpOw0KICBvcGFjaXR5OiAwOw0KICBvdmVyZmxvdzogaGlkZGVuOw0KICB0cmFuc2l0aW9uOiBvcGFjaXR5IC4zczsNCiAgei1pbmRleDogOTk5OTk7DQp9DQouYmFjazpub3QoLm9wZW4pIHsgcG9pbnRlci1ldmVudHM6IG5vbmU7IH0NCi5iYWNrLm9wZW4geyBvcGFjaXR5OiAxOyB9DQouYmFjay5vcGVuIC5mb3JlLnJlYWR5IHsgdHJhbnNpdGlvbjogYm94LXNoYWRvdyAuM3MsIGJhY2tncm91bmQtY29sb3IgLjNzOyB9DQouZm9yZS5vdmVyIHsgY3Vyc29yOiBtb3ZlOyBiYWNrZ3JvdW5kLWNvbG9yOiByZ2JhKDI1MCwgMjUwLCAyNTAsIDEpOyB9DQouZm9yZS5tb3ZpbmcgeyBjdXJzb3I6IGNyb3NzaGFpcjsgYmFja2dyb3VuZC1jb2xvcjogcmdiYSgyMzAsIDIzMCwgMjMwLCAxKTsgdXNlci1zZWxlY3Q6IG5vbmU7IH0NCi5mb3JlLm92ZXIsIC5mb3JlLm1vdmluZyB7IGJveC1zaGFkb3c6IGluc2V0IDAgMCAuNWVtIGJsYWNrIWltcG9ydGFudDsgfQ0KLmZvcmUgew0KICBiYWNrZ3JvdW5kLWNvbG9yOiAjZmZmOw0KICBtaW4td2lkdGg6IDFyZW07IG1heC13aWR0aDogMTAwdnc7DQogIG1pbi1oZWlnaHQ6IDFyZW07IG1heC1oZWlnaHQ6IDEwMHZoOw0KICBwb3NpdGlvbjogYWJzb2x1dGU7IG92ZXJmbG93OiBoaWRkZW47DQogIHRvcDogNTAlOyBsZWZ0OiA1MCU7DQogIHRyYW5zaXRpb246IHRyYW5zZm9ybSAuM3M7DQp9DQouZm9yZSA+IHNwYW4gew0KICBwb3NpdGlvbjogYWJzb2x1dGU7DQogIGZvbnQtc2l6ZTogMS41ZW07DQogIHVzZXItc2VsZWN0OiBub25lOw0KICBjb2xvcjogcmdiYSgwLCAwLCAwLCAuMyk7DQp9DQouZm9yZS5uby1jbG9zZSB7IG1heC13aWR0aDogY2FsYygxMDB2dyAtIDFlbSk7IG1heC1oZWlnaHQ6IGNhbGMoMTAwdmggLSAxZW0pOyB9DQouZm9yZS5uby1jbG9zZSAuY2xvc2UgeyBkaXNwbGF5OiBub25lOyB9DQouZm9yZSAuY2xvc2UgeyBjdXJzb3I6IHBvaW50ZXI7IHRvcDogLTZweDsgcmlnaHQ6IDA7IHBhZGRpbmc6IC4yZW07IH0NCi5mb3JlOm5vdCgucmVzaXplKSAuc2UtcmVzaXplIHsgZGlzcGxheTogbm9uZTsgfQ0KLmZvcmUgLnNlLXJlc2l6ZSB7IGN1cnNvcjogc2UtcmVzaXplOyBib3R0b206IC05cHg7IHJpZ2h0OiAtNHB4OyB9","data:text/html;base64,PGRpdiBjbGFzcz0iYmFjayI+DQogIDxkaXYgY2xhc3M9ImZvcmUiPg0KICAgIDxzbG90Pjwvc2xvdD4NCiAgICA8c3BhbiBjbGFzcz0iY2xvc2UiPiZ0aW1lczs8L3NwYW4+DQogICAgPHNwYW4gY2xhc3M9InNlLXJlc2l6ZSI+JiN4MjVlMjs8L3NwYW4+DQogIDwvZGl2Pg0KPC9kaXY+"),this._styles={};const e=this.root.querySelector(".back"),t=e.querySelector(".fore"),s=t.querySelector(".se-resize"),o=t.querySelector(".close");this.resetOffscreenPosition(t),o.addEventListener("click",()=>this.close()),s.addEventListener("mousedown",()=>{t.classList.toggle("over",this.canResize),t.classList.toggle("resizing",this.canResize)}),e.addEventListener("mousedown",s=>{this._drag=s.target===e?"back":s.target===t?"fore":"fore*",this._coords="fore"!==this._drag?null:{x:s.offsetX,y:s.offsetY},t.classList.toggle("moving",this.canMove&&"fore"===this._drag)}),t.addEventListener("mouseover",e=>t.classList.toggle("over",this.canMove&&e.target===t)),t.addEventListener("mouseout",()=>t.classList.remove("over")),window.addEventListener("mousemove",s=>{const o=t.getBoundingClientRect();if(t.classList.contains("resizing")){const e=5;t.style.width=e+s.pageX-o.x+"px",t.style.height=e+s.pageY-o.y+"px"}else if(this.canMove&&"fore"===this._drag&&this._coords){const o=e.getBoundingClientRect(),i=o.width-window.innerWidth,n=o.height-window.innerHeight,c=100*Math.max(0,s.pageX-this._coords.x)/window.innerWidth,r=100*Math.max(0,s.pageY-this._coords.y)/window.innerHeight,a=`min(${c.toFixed(2)}vw, ${i}px + 100vw - 100%)`,l=`min(${r.toFixed(2)}vh, ${n}px + 100vh - 100%)`;t.style.top=t.style.left="0",t.style.transform=`translate(${a}, ${l})`}}),window.addEventListener("mouseup",()=>{this._drag=null,t.classList.remove("moving","resizing")}),e.addEventListener("mouseup",s=>{"back"===this._drag&&s.target===e&&this.dismiss(),this._drag=null,t.classList.remove("moving","resizing")}),t.addEventListener("transitionend",s=>{"transform"===s.propertyName&&(e.classList.contains("open")?t.classList.add("ready"):this.resetOffscreenPosition(t))})}get canMove(){return this.hasAttribute("move")}get canResize(){return this.hasAttribute("resize")}get canShrink(){return this.canResize&&this.hasAttribute("shrink")}get canClose(){return!this.hasAttribute("no-close")}close(){this.removeAttribute("open")}open(){this.setAttribute("open","")}wrap(e){const t="function"==typeof e.append?e:document.querySelector(e+"");this.appendChild(t)}confirm(){const e=!!this.confirmCallback,t=!e||this.confirmCallback();e&&this.fire(t?"confirmaccept":"confirmreject"),t&&this.close()}dismiss(){const e=!!this.dismissCallback,t=!e||this.dismissCallback();e&&this.fire(t?"dismissaccept":"dismissreject"),t&&this.close()}attributeChangedCallback(e,t,o){switch(e){case"open":const e=this.root.querySelector(".back"),t=e.querySelector(".fore"),i=!!o||"string"==typeof o;if(t.classList.remove("ready","moving"),t.style.transform=i?"translate(-50%, -50%)":t.style.transform+" translateY(-100vh)",t.classList.toggle("resize",this.canResize),t.classList.toggle("no-close",!this.canClose),e.classList.toggle("open",i),i&&this.propagateSupportedStyles(e),!this.canShrink){const e=t.getBoundingClientRect();t.style.minWidth=e.width+"px",t.style.minHeight=e.height+"px"}this.fire(i?"open":"close");break;case"style":o&&(s.STYLE_KEYS.map(e=>({key:e,value:this.style[e]})).filter(e=>e.value).forEach(e=>this._styles[e.key]=e.value),this.removeAttribute("style"))}}connectedCallback(){const e=this.root.querySelector(".back"),t=e.querySelector(".fore");e.classList.contains("open")&&t.classList.add("ready")}disconnectedCallback(){}resetOffscreenPosition(e){e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -100vh)",e.style.minWidth=e.style.width="",e.style.minHeight=e.style.height=""}propagateSupportedStyles(e){["backgroundColor"].forEach(t=>{e.style[t]=this._styles[t]});const t=e.querySelector(".fore");["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","boxShadow"].forEach(e=>{t.style[e]=this._styles[e]})}fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}}s.observedAttributes=["open","style"],s.STYLE_KEYS=["backgroundColor","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","boxShadow"],"customElements"in window&&window.customElements.define("ne14-pop",s),e.Popup=s,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ne_pop={})}(this,(function(e){"use strict";class t extends HTMLElement{constructor(e,t,s="closed"){super(),this.root=this.attachShadow({mode:s}),this.root.innerHTML=this.decode(t);const o=document.createElement("style");o.textContent=this.decode(e),this.root.appendChild(o)}decode(e){const t=(e+"").indexOf("base64,");return-1===t?e:window.atob(e.substring(t+7))}}class s extends t{constructor(){super("data:text/css;base64,LmJhY2sgew0KICBwb3NpdGlvbjogZml4ZWQ7DQogIHRvcDogMDsgcmlnaHQ6IDA7IGJvdHRvbTogMDsgbGVmdDogMDsNCiAgYmFja2dyb3VuZC1jb2xvcjogcmdiYSgwLCAwLCAwLCAuODUpOw0KICBvcGFjaXR5OiAwOw0KICBvdmVyZmxvdzogaGlkZGVuOw0KICB0cmFuc2l0aW9uOiBvcGFjaXR5IC4zczsNCiAgei1pbmRleDogOTk5OTk7DQp9DQouYmFjazpub3QoLm9wZW4pIHsgcG9pbnRlci1ldmVudHM6IG5vbmU7IH0NCi5iYWNrLm9wZW4geyBvcGFjaXR5OiAxOyB9DQouYmFjay5vcGVuIC5mb3JlLnJlYWR5IHsgdHJhbnNpdGlvbjogYm94LXNoYWRvdyAuM3MsIGJhY2tncm91bmQtY29sb3IgLjNzOyB9DQouZm9yZS5vdmVyIHsgY3Vyc29yOiBtb3ZlOyBiYWNrZ3JvdW5kLWNvbG9yOiByZ2JhKDI1MCwgMjUwLCAyNTAsIDEpOyB9DQouZm9yZS5tb3ZpbmcgeyBjdXJzb3I6IGNyb3NzaGFpcjsgYmFja2dyb3VuZC1jb2xvcjogcmdiYSgyMzAsIDIzMCwgMjMwLCAxKTsgdXNlci1zZWxlY3Q6IG5vbmU7IH0NCi5mb3JlLm92ZXIsIC5mb3JlLm1vdmluZyB7IGJveC1zaGFkb3c6IGluc2V0IDAgMCAuNWVtIGJsYWNrIWltcG9ydGFudDsgfQ0KLmZvcmUgew0KICBiYWNrZ3JvdW5kLWNvbG9yOiAjZmZmOw0KICBtaW4td2lkdGg6IDFyZW07IG1heC13aWR0aDogMTAwdnc7DQogIG1pbi1oZWlnaHQ6IDFyZW07IG1heC1oZWlnaHQ6IDEwMHZoOw0KICBwb3NpdGlvbjogYWJzb2x1dGU7IG92ZXJmbG93OiBoaWRkZW47DQogIHRvcDogNTAlOyBsZWZ0OiA1MCU7DQogIHRyYW5zaXRpb246IHRyYW5zZm9ybSAuM3M7DQp9DQouZm9yZSA+IHNwYW4gew0KICBwb3NpdGlvbjogYWJzb2x1dGU7DQogIGZvbnQtc2l6ZTogMS41ZW07DQogIHVzZXItc2VsZWN0OiBub25lOw0KICBjb2xvcjogcmdiYSgwLCAwLCAwLCAuMyk7DQp9DQouZm9yZS5uby1jbG9zZSB7IG1heC13aWR0aDogY2FsYygxMDB2dyAtIDFlbSk7IG1heC1oZWlnaHQ6IGNhbGMoMTAwdmggLSAxZW0pOyB9DQouZm9yZS5uby1jbG9zZSAuY2xvc2UgeyBkaXNwbGF5OiBub25lOyB9DQouZm9yZSAuY2xvc2UgeyBjdXJzb3I6IHBvaW50ZXI7IHRvcDogLTZweDsgcmlnaHQ6IDA7IHBhZGRpbmc6IC4yZW07IH0NCi5mb3JlOm5vdCgucmVzaXplKSAuc2UtcmVzaXplIHsgZGlzcGxheTogbm9uZTsgfQ0KLmZvcmUgLnNlLXJlc2l6ZSB7IGN1cnNvcjogc2UtcmVzaXplOyBib3R0b206IC05cHg7IHJpZ2h0OiAtNHB4OyB9","data:text/html;base64,PGRpdiBjbGFzcz0iYmFjayI+DQogIDxkaXYgY2xhc3M9ImZvcmUiPg0KICAgIDxzbG90Pjwvc2xvdD4NCiAgICA8c3BhbiBjbGFzcz0iY2xvc2UiPiZ0aW1lczs8L3NwYW4+DQogICAgPHNwYW4gY2xhc3M9InNlLXJlc2l6ZSI+JiN4MjVlMjs8L3NwYW4+DQogIDwvZGl2Pg0KPC9kaXY+"),this._styles={};const e=this.root.querySelector(".back"),t=e.querySelector(".fore"),s=t.querySelector(".se-resize"),o=t.querySelector(".close");this.resetOffscreenPosition(t),o.addEventListener("click",()=>this.close()),s.addEventListener("mousedown",()=>{t.classList.toggle("over",this.canResize),t.classList.toggle("resizing",this.canResize)}),e.addEventListener("mousedown",s=>{this._drag=s.target===e?"back":s.target===t?"fore":"fore*",this._coords="fore"!==this._drag?null:{x:s.offsetX,y:s.offsetY},t.classList.toggle("moving",this.canMove&&"fore"===this._drag)}),t.addEventListener("mouseover",e=>t.classList.toggle("over",this.canMove&&e.target===t)),t.addEventListener("mouseout",()=>t.classList.remove("over")),window.addEventListener("mousemove",s=>{const o=t.getBoundingClientRect();if(t.classList.contains("resizing")){const e=5;t.style.width=e+s.pageX-o.x+"px",t.style.height=e+s.pageY-o.y+"px"}else if(this.canMove&&"fore"===this._drag&&this._coords){const o=e.getBoundingClientRect(),i=o.width-window.innerWidth,n=o.height-window.innerHeight,r=100*Math.max(0,s.pageX-this._coords.x)/window.innerWidth,c=100*Math.max(0,s.pageY-this._coords.y)/window.innerHeight,a=`min(${r.toFixed(2)}vw, ${i}px + 100vw - 100%)`,l=`min(${c.toFixed(2)}vh, ${n}px + 100vh - 100%)`;t.style.top=t.style.left="0",t.style.transform=`translate(${a}, ${l})`}}),window.addEventListener("mouseup",()=>{this._drag=null,t.classList.remove("moving","resizing")}),e.addEventListener("mouseup",s=>{"back"===this._drag&&s.target===e&&this.dismiss(),this._drag=null,t.classList.remove("moving","resizing")}),t.addEventListener("transitionend",s=>{"transform"===s.propertyName&&(e.classList.contains("open")?t.classList.add("ready"):this.resetOffscreenPosition(t))})}get canMove(){return this.hasAttribute("move")}get canResize(){return this.hasAttribute("resize")}get canShrink(){return this.canResize&&this.hasAttribute("shrink")}get canClose(){return!this.hasAttribute("no-close")}close(){this.removeAttribute("open")}open(){this.setAttribute("open","")}wrap(e){const t="function"==typeof e.append?e:document.querySelector(e+"");this.appendChild(t)}confirm(){const e=!!this.confirmCallback,t=!e||this.confirmCallback();e&&this.fire(t?"confirmaccept":"confirmreject"),t&&this.close()}dismiss(){const e=!!this.dismissCallback,t=!e||this.dismissCallback();e&&this.fire(t?"dismissaccept":"dismissreject"),t&&this.close()}attributeChangedCallback(e,t,o){switch(e){case"open":const e=this.root.querySelector(".back"),t=e.querySelector(".fore"),i=!!o||"string"==typeof o;t.classList.remove("ready","moving"),t.style.transform=i?"translate(-50%, -50%)":t.style.transform+" translateY(-100vh)",t.classList.toggle("resize",this.canResize),t.classList.toggle("no-close",!this.canClose),e.classList.toggle("open",i),i&&(this.propagateSupportedStyles(e),this.canShrink||this.fixMinSize()),this.fire(i?"open":"close");break;case"style":o&&(s.STYLE_KEYS.map(e=>({key:e,value:this.style[e]})).filter(e=>e.value).forEach(e=>this._styles[e.key]=e.value),this.removeAttribute("style"))}}connectedCallback(){const e=this.root.querySelector(".back"),t=e.querySelector(".fore");e.classList.contains("open")&&t.classList.add("ready")}fixMinSize(){const e=this.root.querySelector(".fore");e.style.minWidth=e.style.width="",e.style.minHeight=e.style.height="";const t=e.getBoundingClientRect();e.style.minWidth=t.width+"px",e.style.minHeight=t.height+"px"}resetOffscreenPosition(e){e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -100vh)"}propagateSupportedStyles(e){["backgroundColor"].forEach(t=>{e.style[t]=this._styles[t]});const t=e.querySelector(".fore");["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","boxShadow"].forEach(e=>{t.style[e]=this._styles[e]})}fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}}s.observedAttributes=["open","style"],s.STYLE_KEYS=["backgroundColor","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","boxShadow"],"customElements"in window&&window.customElements.define("ne14-pop",s),e.Popup=s,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -5,9 +5,9 @@ import { CustomElementBase } from '@ne1410s/cust-elems'; | ||
private static readonly STYLE_KEYS; | ||
protected get canMove(): boolean; | ||
protected get canResize(): boolean; | ||
protected get canShrink(): boolean; | ||
private get canClose(); | ||
private _styles; | ||
private _coords; | ||
private _drag; | ||
private get canMove(); | ||
private get canResize(); | ||
private get canShrink(); | ||
private get canClose(); | ||
confirmCallback: () => boolean; | ||
@@ -23,3 +23,3 @@ dismissCallback: () => boolean; | ||
connectedCallback(): void; | ||
disconnectedCallback(): void; | ||
protected fixMinSize(): void; | ||
private resetOffscreenPosition; | ||
@@ -26,0 +26,0 @@ /** Some relevant style properties are propagated */ |
{ | ||
"name": "@ne1410s/popup", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "A lightweight configurable popup.", | ||
@@ -5,0 +5,0 @@ "main": "dist/ne14_pop.cjs.min.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24622