UNPKG

@scandit/web-datacapture-barcode

Version:

Scandit Data Capture SDK for the Web

1 lines 2.94 kB
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 p extends l{constructor(){super(),this.annotationTrigger=`highlightTapAndBarcodeScan`,this.anchor=f.Bottom,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 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.hasAttribute(`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){p.register();let t=document.createElement(p.tag);return t.barcode=e,t}static register(){u({[t.tag]:t,[p.tag]:p})}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`${p.tag}{align-items:center;display:flex;justify-content:center;min-height:48px;min-width:48px}`;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,r)}};p.tag=`scandit-barcode-ar-status-icon-annotation`;export{p as BarcodeArStatusIconAnnotation,f as BarcodeArStatusIconAnnotationAnchor};