UNPKG

angular-qrious

Version:
114 lines (108 loc) 2.92 kB
import { __decorate } from 'tslib'; import { Input, ViewChild, Component, NgModule } from '@angular/core'; import QRious from 'qrious'; let QrCodeComponent = class QrCodeComponent { constructor() { this.background = 'white'; this.backgroundAlpha = 1.0; this.foreground = 'black'; this.foregroundAlpha = 1.0; this.level = 'L'; this.mime = 'image/png'; this.padding = null; this.size = 100; this.value = ''; } ngOnChanges(changes) { const inputs = [ 'background', 'backgroundAlpha', 'foreground', 'foregroundAlpha', 'level', 'mime', 'padding', 'size', 'value', ]; if (inputs.some(key => key in changes)) { this.update(); } } ngOnDestroy() { delete this.qrious; } update() { try { const config = { 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, element: this.element.nativeElement, }; this.qrious = new QRious(config); } catch (e) { alert(e.message); console.error(`update error: ${e.message}`); } } }; __decorate([ Input() ], QrCodeComponent.prototype, "background", void 0); __decorate([ Input() ], QrCodeComponent.prototype, "backgroundAlpha", void 0); __decorate([ Input() ], QrCodeComponent.prototype, "foreground", void 0); __decorate([ Input() ], QrCodeComponent.prototype, "foregroundAlpha", void 0); __decorate([ Input() ], QrCodeComponent.prototype, "level", void 0); __decorate([ Input() ], QrCodeComponent.prototype, "mime", void 0); __decorate([ Input() ], QrCodeComponent.prototype, "padding", void 0); __decorate([ Input() ], QrCodeComponent.prototype, "size", void 0); __decorate([ Input() ], QrCodeComponent.prototype, "value", void 0); __decorate([ ViewChild('qrcode', { static: true }) ], QrCodeComponent.prototype, "element", void 0); QrCodeComponent = __decorate([ Component({ selector: 'qr-code', template: '<canvas #qrcode></canvas>' }) ], QrCodeComponent); let QriousModule = class QriousModule { }; QriousModule = __decorate([ NgModule({ declarations: [QrCodeComponent], exports: [QrCodeComponent], }) ], QriousModule); /* * Public API Surface of angular-qrious-lib */ /** * Generated bundle index. Do not edit. */ export { QrCodeComponent, QriousModule }; //# sourceMappingURL=angular-qrious.js.map