@creaditor/newsletter-starterkit
Version:
Creaditor Newsletter Editor - Starterkit for creating beautiful email newsletters
17 lines • 3.01 kB
JavaScript
/*! For license information please see 6892.creaditor.bundle.js.LICENSE.txt */
"use strict";(("undefined"!=typeof self?self:this).webpackChunkCreaditor=("undefined"!=typeof self?self:this).webpackChunkCreaditor||[]).push([[6892],{6892:(e,t,s)=>{s.r(t),s.d(t,{EditorBar:()=>l});var i=s(56666),n=s(21293),r=s(58860),o=s(45607),d=(s(3959),s(49120));class l extends n.oi{constructor(){super(),this.opened=!1,this.offsetY=50,this.offsetX=0,this.reRender=this.reRender.bind(this)}reRender(){if(this.opened&&this.componentId){const e=o.Z.getComponent(this.componentId);if(e&&e.element){const t=e.element.getBoundingClientRect();let s=t.top-this.offsetY;-1!==this.direction.indexOf("left")?this.left=t.left+this.offsetX+"px":this.left=t.left+t.width+"px",this.top=s+"px",-1!==this.direction.indexOf("bottom")&&(this.top=t.top-this.offsetY+t.height+20+"px")}}}render(){return this.opened?(this.style.display=null,this.style.left=this.left,this.style.top=this.top,this.style.zIndex=(0,d.Z)(),this.style.transform=`translate(${-1!==this.direction.indexOf("left")?"0":"100%"},${-1!==this.direction.indexOf("bottom")?"100%":"0"})`,n.dy` <slot></slot>`):(this.style.display="none",null)}disconnectedCallback(){super.disconnectedCallback(),r.Z.unSubscribe("onScroll",this.reRender),o.Z.off("update",this.reRender)}connectedCallback(){super.connectedCallback(),r.Z.subscribe("onScroll",this.reRender),o.Z.on("update",this.reRender),setTimeout((()=>{this.reRender()}),0)}}(0,i.Z)(l,"styles",n.iv`
:host {
position: fixed;
border-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
min-height: 40px;
min-width: 40px;
background-color: #fff;
display: flex;
align-items: center;
border-radius: 3px;
transform: translateX(-100%);
transition: top 10ms ease-in-out, left 0.2s ease-in-out;
z-index: 2;
}
`),(0,i.Z)(l,"properties",{componentId:{type:String},opened:{type:Boolean},left:{type:String},top:{type:String},offsetY:{type:Number},offsetX:{type:Number},direction:{type:String}}),customElements.define("cdtr-editor-bar",l)},3959:(e,t,s)=>{s.d(t,{V:()=>d});var i=s(33692),n=s(50875);const r="important",o=" !"+r,d=(0,n.XM)(class extends n.Xe{constructor(e){if(super(e),e.type!==n.pX.ATTRIBUTE||"style"!==e.name||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,s)=>{const i=e[s];return null==i?t:t+`${s=s.includes("-")?s:s.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`}),"")}update(e,[t]){const{style:s}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(t)),this.render(t);for(const e of this.ft)null==t[e]&&(this.ft.delete(e),e.includes("-")?s.removeProperty(e):s[e]=null);for(const e in t){const i=t[e];if(null!=i){this.ft.add(e);const t="string"==typeof i&&i.endsWith(o);e.includes("-")||t?s.setProperty(e,t?i.slice(0,-11):i,t?r:""):s[e]=i}}return i.Jb}})}}]);