/** * Component container */ export class Component extends HTMLElement { public static get observedAttributes() { return [`message`] } public documentBodyStyle: any public name: string = `bud-overlay` /** * WHM payload */ public payload: any public constructor() { super() this.renderShadow() } public attributeChangedCallback() { if (!this.documentBodyStyle) this.documentBodyStyle = document.body?.style if (this.getAttribute(`message`)) { document.body.style.overflow = `hidden` this.shadowRoot.querySelector(`.overlay`).classList.add(`visible`) this.shadowRoot.querySelector(`.messages`).innerHTML = this.getAttribute(`message`) return } if (this.documentBodyStyle?.overflow && document?.body?.style) { document.body.style.overflow = this.documentBodyStyle.overflow } this.shadowRoot.querySelector(`.overlay`).classList.remove(`visible`) } public connectedCallback() { if (document.body?.style) this.documentBodyStyle = document.body.style } public get message() { return this.getAttribute(`message`) } public renderShadow(): void { const container = document.createElement(`div`) container.classList.add(`overlay`) container.innerHTML = `
` this.attachShadow({mode: `open`}).appendChild(container) } }