@scandit/web-datacapture-barcode
Version:
Scandit Data Capture SDK for the Web
1 lines • 2.26 kB
JavaScript
import {Color,ScanditIconBuilder,ScanditIconShape,ScanditIconType}from'@scandit/web-datacapture-core';import {gray900}from'@scandit/web-datacapture-core/build/js/private/ui/colors.js';import {ScanditHTMLElement,html,defineCustomElements,css}from'@scandit/web-datacapture-core/build/js/private/utils/index.js';var i=Color.fromRGBA(255,255,255,1),o=class o extends ScanditHTMLElement{constructor(){super();this.onPressedHandler=this.onPressed.bind(this);this.onReleasedHandler=this.onReleased.bind(this);let t=this.attachShadow({mode:"open"});t.innerHTML=html`<button type="button"><slot name="1x"></slot><slot name="2x"></slot></button>`,t.append(o.createStyleElement().cloneNode(true));}set zoom(t){this.setAttribute("zoom",t);}get zoom(){var t;return (t=this.getAttribute("zoom"))!=null?t:"1x"}static create(){return document.createElement(o.tag)}static register(){defineCustomElements({[o.tag]:o});}static createStyleElement(){return css`:host[hidden]{display:none}:host button{background:none;border:none;display:flex;margin:0;outline:none;padding:0;-webkit-tap-highlight-color:transparent}::slotted(*){display:none}:host([zoom="1x"]) ::slotted([slot="1x"]),:host([zoom="2x"]) ::slotted([slot="2x"]){display:block}`}async connectedCallback(){var n,s;let t=new ScanditIconBuilder().withBackgroundShape(ScanditIconShape.Circle).withBackgroundColor(gray900.withAlpha(.3)).withBackgroundStrokeColor(gray900).withWidth(36).withHeight(36).withIconSize(32),[e,d]=await Promise.all([t.withIcon(ScanditIconType.OneX).build(),t.withIcon(ScanditIconType.TwoX).build()]);this.icon1x=e,this.icon2x=d,this.icon1x.slot="1x",this.icon2x.slot="2x",this.append(this.icon1x,this.icon2x),(n=this.shadowRoot)==null||n.addEventListener("pointerdown",this.onPressedHandler),(s=this.shadowRoot)==null||s.addEventListener("pointerup",this.onReleasedHandler);}disconnectedCallback(){var t,e;(t=this.shadowRoot)==null||t.removeEventListener("pointerdown",this.onPressedHandler),(e=this.shadowRoot)==null||e.removeEventListener("pointerup",this.onReleasedHandler);}onPressed(){this.icon2x.iconColor=i.withAlpha(.3),this.icon1x.iconColor=i.withAlpha(.3);}onReleased(){this.icon1x.iconColor=i,this.icon2x.iconColor=i;}};o.tag="scandit-check-switch-zoom-button";var r=o;export{r as a};