UNPKG

lean-qr

Version:
2 lines (1 loc) 1.07 kB
"use strict";const e=e=>{const t=new Error(`lean-qr error ${e}`);throw t.code=e,t},t=["minCorrectionLevel","maxCorrectionLevel","minVersion","maxVersion","mask","trailer","modes"],r=["on","off","pad","padX","padY","width","height","scale"],s=e=>{try{return e()}catch(e){console.warn(e.message)}},n=(e,t)=>Object.fromEntries(t.map(t=>[t,e[t]]).filter(([e,t])=>void 0!==t)),i="image-rendering:pixelated",o={props:["content",...t,...r],expose:[]};exports.makeVueCanvasComponent=({h}=e(6),a=e(7),d={})=>({name:"LeanQRCanvas",...o,computed:{qr(){return s(()=>a(this.content,{...d,...n(this,t)}))},d(){return[this.qr,{...d,...n(this,r)}]}},mounted(){this.$watch("d",([e,t])=>{this.$refs.o.hidden=!e,e?.toCanvas(this.$refs.o,t)},{immediate:!0,flush:"post"})},render:()=>h("canvas",{ref:"o",style:i})}),exports.makeVueSvgComponent=({h}=e(6),a=e(7),d=e(8),c={})=>({name:"LeanQRSvg",...o,computed:{qr(){return s(()=>a(this.content,{...c,...n(this,t)}))},u(){return this.qr&&s(()=>d(this.qr,{...c,...n(this,r)}))}},render(){return this.u?h("img",{src:this.u,style:i}):null}});