UNPKG

@scandit/web-datacapture-barcode

Version:

Scandit Data Capture SDK for the Web

1 lines 2.27 kB
import"./BarcodeArAnnotation.js";import{updatePosition as e}from"./private/updatePosition.js";import{BarcodeArPopoverAnnotationButton as t}from"./BarcodeArPopoverAnnotationButton.js";import{ScanditHTMLElement as n,css as r,defineCustomElements as i,html as a}from"@scandit/web-datacapture-core/build/js/private/utils/index.js";let o=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 s=class s extends n{constructor(){super(),this.isEntirePopoverTappable=!1,this.annotationTrigger=`highlightTap`,this.onPointerUpListener=this.onPointerUp.bind(this),this.anchor=o.Bottom;let e=this.attachShadow({mode:`open`});e.innerHTML=a`<div class="container" role="group"><slot></slot></div>`,e.append(s.createStyleElement().cloneNode(!0))}updatePosition(t,n,r){e(this,t,n,0)}get barcode(){return this._barcode}set barcode(e){this._barcode=e}set direction(e){this.setAttribute(`direction`,e)}get direction(){return this.getAttribute(`direction`)??`horizontal`}static register(){i({[s.tag]:s})}static create(e){s.register();let t=document.createElement(s.tag);return t.barcode=e,t}static createStyleElement(){return r`:host{background-color:unset;border:none;border-radius:14px;margin:0;overflow:hidden;padding:0}:host([direction=horizontal]) .container{flex-direction:row}:host([direction=vertical]) .container{flex-direction:column}.container{backdrop-filter:blur(16px);background:#ffffffb3;box-shadow:0 6px 10px 4px #12161926;display:flex;gap:14px}`}connectedCallback(){let e=Array.from(this.querySelectorAll(t.tag));for(let[t,n]of Object.entries(e))n.setAttribute(`data-position`,t);this.addEventListener(`pointerup`,this.onPointerUpListener)}disconnectedCallback(){this.removeEventListener(`pointerup`,this.onPointerUpListener)}onPointerUp(e){var n,r,i;if(this.isEntirePopoverTappable){var a,o;(a=this.listener)==null||(o=a.onPopoverTapped)==null||o.call(a,this);return}let s=(n=e.target)==null?void 0:n.closest(t.tag);s&&((r=this.listener)==null||(i=r.onPopoverButtonTapped)==null||i.call(r,this,s,Number(s.getAttribute(`data-position`))))}};s.tag=`scandit-barcode-ar-popover-annotation`;export{s as BarcodeArPopoverAnnotation,o as BarcodeArPopoverAnnotationAnchor};