UNPKG

@scandit/web-datacapture-barcode

Version:

Scandit Data Capture SDK for the Web

1 lines 2.93 kB
import {Color}from'@scandit/web-datacapture-core';import {gray900}from'@scandit/web-datacapture-core/build/js/private/ui/colors.js';import {ScanditHTMLElement,html,defineCustomElements,css}from'@scandit/web-datacapture-core/build/js/private/utils/index.js';var o=class o extends ScanditHTMLElement{constructor(){super();this.isLeftIconTappable=true;this.isRightIconTappable=true;let t=this.attachShadow({mode:"open"});t.innerHTML=html`<div class="container"><slot name="left-barcode-icon"></slot><div class="text"></div><slot name="right-barcode-icon"></slot></div>`,t.append(o.createStyleElement().cloneNode(true)),this.textElement=t.querySelector(".text"),this.containerElement=t.querySelector(".container");}set rightIcon(t){var n;let e=(n=this.shadowRoot)==null?void 0:n.querySelector("[slot='right-barcode-icon']");(e==null?void 0:e.assignedSlot)!==t&&(e&&t==null&&e.remove(),t&&(t.slot="right-barcode-icon",this.append(t)));}get rightIcon(){var t,e,n;return ((n=(e=(t=this.shadowRoot)==null?void 0:t.querySelector("slot[name='right-barcode-icon']"))==null?void 0:e.assignedElements())!=null?n:[])[0]}set leftIcon(t){var n;let e=(n=this.shadowRoot)==null?void 0:n.querySelector("[slot='left-barcode-icon']");(e==null?void 0:e.assignedSlot)!==t&&(e&&t==null&&e.remove(),t&&(t.slot="left-barcode-icon",this.append(t)));}get leftIcon(){var t,e,n;return ((n=(e=(t=this.shadowRoot)==null?void 0:t.querySelector("slot[name='left-barcode-icon']"))==null?void 0:e.assignedElements())!=null?n:[])[0]}get text(){var t;return (t=this.textElement.textContent)!=null?t:""}set text(t){this.textElement.textContent=t;}get textSize(){return Number.parseInt(this.style.getPropertyValue("--text-size"),10)}set textSize(t){this.style.setProperty("--text-size",`${t}px`);}get textAlignment(){var t;return (t=this.containerElement.getAttribute("text-alignment"))!=null?t:"center"}set textAlignment(t){this.containerElement.setAttribute("text-alignment",t);}get textColor(){let t=this.style.getPropertyValue("--text-color");return t===""?Color.fromRGBA(0,0,0,1):Color.fromHex(t)}set textColor(t){this.style.setProperty("--text-color",`#${t.toJSON()}`);}static create(){return o.register(),document.createElement(o.tag)}static register(){defineCustomElements({[o.tag]:o});}static createStyleElement(){return css`:host{--text-color:#${gray900.toJSON()};--text-size:14px}.container{align-items:center;display:flex;font-size:var(--text-size);gap:.75rem;justify-content:center;padding:1rem 1rem 0}.container .text{color:var(--text-color)}.container[text-alignment=start]{justify-content:flex-start}.container[text-alignment=center]{justify-content:center}.container[text-alignment=end]{justify-content:flex-end}.container[text-alignment=start] .text{text-align:start}.container[text-alignment=center] .text{text-align:center}.container[text-alignment=end] .text{text-align:end}`}};o.tag="scandit-barcode-ar-info-annotation-body";var r=o;export{r as a};