UNPKG

@scandit/web-datacapture-barcode

Version:

Scandit Data Capture SDK for the Web

1 lines • 2.61 kB
import"./BarcodeArAnnotation.js";import{isExclusiveWhileVisible as e}from"./private/annotationTriggerBehavior.js";import{updatePosition as t}from"./private/updatePosition.js";import{BarcodeArPopoverAnnotationButton as n}from"./BarcodeArPopoverAnnotationButton.js";import{ScanditHTMLElement as r,css as i,defineCustomElements as a,html as o}from"@scandit/web-datacapture-core/build/js/private/utils/index.js";const s=`exclusive-while-visible`;let c=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 l=class l extends r{get annotationTrigger(){return this._annotationTrigger}set annotationTrigger(t){this._annotationTrigger=t,this.toggleAttribute(s,e(t))}constructor(){super(),this.isEntirePopoverTappable=!1,this._annotationTrigger=`highlightTap`,this.onPointerUpListener=this.onPointerUp.bind(this),this.anchor=c.Bottom;let e=this.attachShadow({mode:`open`});e.innerHTML=o`<div class="container" role="group"><slot></slot></div>`,e.append(l.createStyleElement().cloneNode(!0))}updatePosition(e,n,r){t(this,e,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(){a({[l.tag]:l})}static create(e){l.register();let t=document.createElement(l.tag);return t.barcode=e,t}static createStyleElement(){return i`: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(){this.toggleAttribute(s,e(this._annotationTrigger));let t=Array.from(this.querySelectorAll(n.tag));for(let[e,n]of Object.entries(t))n.setAttribute(`data-position`,e);this.addEventListener(`pointerup`,this.onPointerUpListener)}disconnectedCallback(){this.removeEventListener(`pointerup`,this.onPointerUpListener)}onPointerUp(e){var t,r,i;if(this.isEntirePopoverTappable){var a,o;(a=this.listener)==null||(o=a.onPopoverTapped)==null||o.call(a,this);return}let s=(t=e.target)==null?void 0:t.closest(n.tag);s&&((r=this.listener)==null||(i=r.onPopoverButtonTapped)==null||i.call(r,this,s,Number(s.getAttribute(`data-position`))))}};l.tag=`scandit-barcode-ar-popover-annotation`;export{l as BarcodeArPopoverAnnotation,c as BarcodeArPopoverAnnotationAnchor,s as EXCLUSIVE_WHILE_VISIBLE_ATTRIBUTE};