import { EventUtils } from '../../esl-utils/dom/events' ; /**
 * Base class for ESL custom elements.
 * Allows to define custom element with the optional custom tag name.
 */ export abstract class ESLBaseElement extends HTMLElement { /** Custom element tag name */ public static is = '' ; protected _connected : boolean = false ; protected connectedCallback ( ) { this . _connected = true ; this . classList . add ( ( this . constructor as typeof ESLBaseElement ) . is ) ; } protected disconnectedCallback ( ) { this . _connected = false ; } /** Check that the element is connected and `connectedCallback` has been executed */ public get connected ( ) : boolean { return this . _connected ; } param eventName param eventInit - custom event init. See  CustomEventInit public $$fire ( eventName , eventInit ? ) { return EventUtils . dispatch ( this , 'esl:' + eventName , eventInit ) ; } /**
     * Register component in the  customElements registry
     *  param tagName public static register ( this , tagName ? ) { tagName = tagName || this . is ; if ( ! tagName ) throw new Error ( 'Can not define custom element' ) ; const constructor = customElements . get ( tagName ) ; if ( constructor ) { if ( constructor . is !== tagName ) throw new Error ( 'Element declaration tag inconsistency' ) ; return ; } if ( this . is !== tagName ) { this . is = tagName ; } customElements . define ( tagName , this as any as CustomElementConstructor ) ; } public static get registered ( ) : Promise < CustomElementConstructor > { return customElements . whenDefined ( this . is ) ; } }