UNPKG

@lxlib/seed

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.

16 lines (14 loc) 5.3 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@lxlib/util"),require("@angular/common")):"function"==typeof define&&define.amd?define("@lxlib/seed/qr",["exports","@angular/core","@lxlib/util","@angular/common"],t):t(((e=e||self).lxlib=e.lxlib||{},e.lxlib.seed=e.lxlib.seed||{},e.lxlib.seed.qr={}),e.ng.core,e.lxlib.util,e.ng.common)}(this,(function(e,t,r,n){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */var o=function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function i(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function a(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function s(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(u(arguments[t]));return e}var c=function(){function e(){this.background="white",this.backgroundAlpha=1,this.foreground="black",this.foregroundAlpha=1,this.level="L",this.mime="image/png",this.padding=10,this.size=220}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}();var p=function(){function e(e){this.backgroundAlpha=1,Object.assign(this,e),this.qr=new QRious}return e.prototype.refresh=function(e){var t="object"==typeof e?e:{background:this.background,backgroundAlpha:this.backgroundAlpha,foreground:this.foreground,foregroundAlpha:this.foregroundAlpha,level:this.level,padding:this.padding,size:this.size,value:e||this.value};return t.value=this.toUtf8ByteArray(t.value),this.qr.set(t),this.dataURL},e.prototype.toUtf8ByteArray=function(e){e=encodeURI(e);for(var t=[],r=0;r<e.length;r++)"%"!==e.charAt(r)?t.push(e.charCodeAt(r)):(t.push(parseInt(e.substr(r+1,2),16)),r+=2);return t.map((function(e){return String.fromCharCode(e)})).join("")},Object.defineProperty(e.prototype,"dataURL",{get:function(){return this.qr.toDataURL()},enumerable:!0,configurable:!0}),e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:c}]},e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(c))},token:e,providedIn:"root"}),e}();var l=function(){function e(e,r,n){this.srv=r,this.cdr=n,this.change=new t.EventEmitter,Object.assign(this,o(o({},new c),e))}return e.prototype.ngOnChanges=function(){this.dataURL=this.srv.refresh({background:this.background,backgroundAlpha:this.backgroundAlpha,foreground:this.foreground,foregroundAlpha:this.foregroundAlpha,level:this.level,mime:this.mime,padding:this.padding,size:this.size,value:this.value}),this.cdr.detectChanges(),this.change.emit(this.dataURL)},e.decorators=[{type:t.Component,args:[{selector:"qr",exportAs:"qr",template:' <img class="qr__img" src="{{ dataURL }}" /> ',host:{"[class.qr]":"true","[style.height.px]":"size","[style.width.px]":"size"},preserveWhitespaces:!1,changeDetection:t.ChangeDetectionStrategy.OnPush,encapsulation:t.ViewEncapsulation.None}]}],e.ctorParameters=function(){return[{type:c},{type:p},{type:t.ChangeDetectorRef}]},e.propDecorators={background:[{type:t.Input}],backgroundAlpha:[{type:t.Input}],foreground:[{type:t.Input}],foregroundAlpha:[{type:t.Input}],level:[{type:t.Input}],mime:[{type:t.Input}],padding:[{type:t.Input}],size:[{type:t.Input}],value:[{type:t.Input}],change:[{type:t.Output}]},i([r.InputNumber(),a("design:type",Number)],e.prototype,"padding",void 0),i([r.InputNumber(),a("design:type",Number)],e.prototype,"size",void 0),e}();var d=[l],f=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[n.CommonModule,r.LxlibUtilModule],declarations:s(d),exports:s(d)}]}],e}();e.QRComponent=l,e.QRConfig=c,e.QRModule=f,e.QRService=p,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=qr.umd.min.js.map