@scandit/web-datacapture-barcode
Version:
Scandit Data Capture SDK for the Web
9 lines (6 loc) • 1.66 kB
JavaScript
import { a } from './chunk-WBSINSMA.js';
import { a as a$1 } from './chunk-ADMKAYF6.js';
import { Color } from '@scandit/web-datacapture-core';
import { ScanditHTMLElement, html, defineCustomElements, css } from '@scandit/web-datacapture-core/build/js/private/utils/index.js';
var o=class o extends ScanditHTMLElement{constructor(){super();this.onIcon=void 0;this.offIcon=void 0;let t=this.attachShadow({mode:"open"});t.innerHTML=html`<button><slot></slot></button>`,t.append(o.createStyleElement().cloneNode(!0));}get state(){var t;return (t=this.getAttribute("state"))!=null?t:"off"}set state(t){this.setAttribute("state",t);}static create(){return document.createElement(o.tag)}static register(){defineCustomElements({[o.tag]:o});}static createStyleElement(){return css`:host button{background:none;border:none;display:flex;margin:0;outline:none;padding:0}`}connectedCallback(){let t=Color.fromHex("#FFFFFF");this.onIcon=a.create(),this.offIcon=a$1.create(),this.onIcon.setAttribute("shadow",""),this.offIcon.setAttribute("shadow",""),this.onIcon.size=36,this.offIcon.size=36,this.offIcon.fill=`#${t.withAlpha(.5).toJSON()}`,this.onIcon.fill=`#${t.toJSON()}`;let e="off";(this.getAttribute("state")==="on"||this.getAttribute("state")==="off")&&(e=this.getAttribute("state")),this.state=e;}attributeChangedCallback(t,e,a){t==="state"&&this.render(a);}render(t){t==="on"?(this.offIcon!=null&&this.offIcon.remove(),this.onIcon!=null&&this.append(this.onIcon)):(this.onIcon!=null&&this.onIcon.remove(),this.offIcon!=null&&this.append(this.offIcon));}};o.tag="scandit-find-torch-button",o.observedAttributes=["state"];var n=o;n.register();
export { n as a };