@scandit/web-datacapture-barcode
Version:
Scandit Data Capture SDK for the Web
1 lines • 1.66 kB
JavaScript
import {e}from'./chunk-YBD5JYCX.js';import {ScanditHTMLElement,css,defineCustomElements,Timeout,html}from'@scandit/web-datacapture-core/build/js/private/utils/index.js';var i=class i extends ScanditHTMLElement{get styleElement(){return (this._styleElement)!=null||(this._styleElement=css`${e}{min-width:calc(100% - 32px);opacity:0;pointer-events:none;transition:.3s ease;user-select:none;width:fit-content}${e}[visible]{opacity:1}.${e}{border-radius:4px;font-family:sans-serif;font-size:14px;font-weight:500;margin:0 auto;padding:8px 12px;width:fit-content}.${e}--${"info"}{background:#fff}.${e}--${"warning"}{background:#fbc02c}.${e}--${"error"}{background:#fa4446;color:#fff}`),this._styleElement}get type(){var e;return (e=this.getAttribute("type"))!=null?e:"info"}set type(e){this.setAttribute("type",e);}get message(){var e;return (e=this.getAttribute("message"))!=null?e:""}set message(e){this.setAttribute("message",e);}get visible(){return this.hasAttribute("visible")}set visible(e){this.toggleAttribute("visible",e);}static create(){return defineCustomElements({[e]:i}),document.createElement(e)}show(e,s,a){this.hide(),this.type=e,this.message=s,this.visible=true,this.timeout=new Timeout(a,this.hide.bind(this)),this.timeout.start();}hide(){var e;(e=this.timeout)==null||e.stop(),this.visible=false;}render(){this.innerHTML=html`<div class="${e} ${e}--${this.type}">${this.message}</div>`;}connectedCallback(){this.render(),this.append(this.styleElement);}disconnectedCallback(){this.hide();}attributeChangedCallback(e,s,a){a!==s&&(this.render(),this.append(this.styleElement));}};i.observedAttributes=["type","message"];var n=i;export{n as a};