@scandit/web-datacapture-barcode
Version:
Scandit Data Capture SDK for the Web
1 lines • 3.1 kB
JavaScript
import"./BarcodeArAnnotation.js";import{updatePosition as e}from"./private/updatePosition.js";import{BarcodeStatusIconContainer as t}from"../atoms/private/BarcodeStatusIconContainer.js";import{Color as n,ScanditIcon as r,ScanditIconBuilder as i,ScanditIconShape as a,ScanditIconType as o}from"@scandit/web-datacapture-core";import{SecondaryOrange100 as s,gray900 as c}from"@scandit/web-datacapture-core/build/js/private/ui/colors.js";import{ScanditHTMLElement as l}from"@scandit/web-datacapture-core/build/js/private/utils/ScanditHTMLElement.js";import{defineCustomElements as u}from"@scandit/web-datacapture-core/build/js/private/utils/defineCustomElements.js";import{css as d}from"@scandit/web-datacapture-core/build/js/private/utils/css.js";let f=function(e){return e[e.Top=`top-center`]=`Top`,e[e.Bottom=`bottom-center`]=`Bottom`,e[e.Left=`left-center`]=`Left`,e[e.Right=`right-center`]=`Right`,e}({});var p=class f extends l{constructor(){super(),this.annotationTrigger=`highlightTapAndBarcodeScan`,this.onToggleListener=this.onToggle.bind(this),this._backgroundColor=n.fromHex(`#fff`),this._icon=null,this.statusIconContainer=t.create()}get barcode(){return this._barcode}set barcode(e){this._barcode=e}set anchor(e){this.statusIconContainer.anchor=e}get anchor(){return this.statusIconContainer.anchor}set text(e){this.statusIconContainer.text=e}get text(){return this.statusIconContainer.text}set hasTip(e){this.statusIconContainer.toggleAttribute(`tip`,e)}get hasTip(){return this.statusIconContainer.tip}set icon(e){var t;(t=this.icon)==null||t.remove(),this._icon=e,e&&(e.slot=`barcode-icon`,e.width=24,e.height=24,e.setIconSize(16),this.statusIconContainer.append(e))}get icon(){return this.statusIconContainer.querySelector(r.tag)??this._icon}set backgroundColor(e){this._backgroundColor=e,this.statusIconContainer.backgroundColor=e}get backgroundColor(){return this.statusIconContainer.backgroundColor}set textColor(e){this.statusIconContainer.textColor=e}get textColor(){return this.statusIconContainer.textColor}static create(e){f.register();let t=document.createElement(f.tag);return t.barcode=e,t}static register(){u({[t.tag]:t,[f.tag]:f})}async connectedCallback(){if(!this._icon){let e=new i().withIcon(o.ExclamationMark).withBackgroundShape(a.Circle).withBackgroundColor(s).withIconColor(c).withWidth(24).withHeight(24).withIconSize(16);this._icon=await e.build()}this.icon=this._icon;let e=d`${f.tag}{align-items:center;display:flex;height:32px;justify-content:flex-start;overflow:visible;width:32px}${f.tag}[hidden]{display:none}${f.tag}:before{content:"";inset:-8px;position:absolute}`;this.append(e),this.append(this.statusIconContainer),this.statusIconContainer.append(this.icon),this.addEventListener(`pointerup`,this.onToggleListener)}disconnectedCallback(){this.removeEventListener(`pointerup`,this.onToggleListener)}onToggle(){this.statusIconContainer.expanded=!this.statusIconContainer.expanded}updatePosition(t,n,r){e(this,t,n,0)}};p.tag=`scandit-barcode-ar-status-icon-annotation`;export{p as BarcodeArStatusIconAnnotation,f as BarcodeArStatusIconAnnotationAnchor};