UNPKG

@scandit/web-datacapture-barcode

Version:

Scandit Data Capture SDK for the Web

1 lines 3.16 kB
import {a}from'./chunk-CYVVGAZ4.js';import {Brush,Color}from'@scandit/web-datacapture-core';import {ScanditHTMLElement}from'@scandit/web-datacapture-core/build/js/private/utils/ScanditHTMLElement.js';import {defineCustomElements}from'@scandit/web-datacapture-core/build/js/private/utils/defineCustomElements.js';import {html,css}from'@scandit/web-datacapture-core/build/js/private/utils/index.js';var e=class e extends ScanditHTMLElement{constructor(){super();this._brush=new Brush(Color.fromHex("#00FFFF").withAlpha(.45),Color.fromHex("#00FFFF"),2);this._icon=null;let t=this.attachShadow({mode:"open"});t.innerHTML=html`<div class="container"><slot></slot></div>`,t.append(e.createStyleElement().cloneNode(true));}connectedCallback(){this.setStylePropertyValue(e.widthCssVariable,"32px"),this.setStylePropertyValue(e.heightCssVariable,"32px"),this.setStylePropertyValue(e.backgroundColorCssVariable,`#${this._brush.fillColor.toJSON()}`),this.setStylePropertyValue(e.strokeColorCssVariable,`#${this._brush.strokeColor.toJSON()}`),this.setStylePropertyValue(e.strokeWidthCssVariable,`${this._brush.strokeWidth}px`);}set barcode(t){this._barcode=t;}get barcode(){return this._barcode}set brush(t){this._brush=t,this.updateBrushColor();}get brush(){return this._brush}set icon(t){var r;(r=this._icon)==null||r.remove(),this._icon=null,t!=null&&(this._icon=t,this.append(this._icon));}get icon(){return this._icon}set width(t){this.setStylePropertyValue(e.widthCssVariable,`${t}px`);}set height(t){this.setStylePropertyValue(e.heightCssVariable,`${t}px`);}get height(){let t=this.getStylePropertyValue(e.heightCssVariable).replace("px","");return Number.parseInt(t,10)}get width(){let t=this.getStylePropertyValue(e.widthCssVariable).replace("px","");return Number.parseInt(t,10)}static create(t){e.register();let r=document.createElement(e.tag);return r.barcode=t,r}static register(){defineCustomElements({[e.tag]:e});}updateBrushColor(){this.setStylePropertyValue(e.backgroundColorCssVariable,`#${this._brush.fillColor.toJSON()}`),this.setStylePropertyValue(e.strokeColorCssVariable,`#${this._brush.strokeColor.toJSON()}`),this.setStylePropertyValue(e.strokeWidthCssVariable,`${this._brush.strokeWidth}px`);}setStylePropertyValue(t,r){this.style.setProperty(t,r);}getStylePropertyValue(t){return this.style.getPropertyValue(t)}static createStyleElement(){return css`:host{--width:32px;--height:32px;--background-color:#00ffff73;--stroke-color:#0ff;--stroke-width:2px}:host([hidden]){display:none}.container{align-items:center;background-color:var(--background-color);border:var(--stroke-width) solid var(--stroke-color);display:flex;height:calc(var(--height) - var(--stroke-width));justify-content:center;position:relative;width:calc(var(--width) - var(--stroke-width))}::slotted(*){left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}`}updatePosition(t,r,a$1){a(this,t,r,a$1);}};e.tag="scandit-barcode-ar-rectangle-highlight",e.widthCssVariable="--width",e.heightCssVariable="--height",e.backgroundColorCssVariable="--background-color",e.strokeColorCssVariable="--stroke-color",e.strokeWidthCssVariable="--stroke-width";var s=e;export{s as a};