angular-qrious
Version:
118 lines (112 loc) • 3.34 kB
JavaScript
import { __decorate } from 'tslib';
import { Input, ViewChild, Component, NgModule } from '@angular/core';
import QRious from 'qrious';
var QrCodeComponent = /** @class */ (function () {
function QrCodeComponent() {
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 = '';
}
QrCodeComponent.prototype.ngOnChanges = function (changes) {
var inputs = [
'background',
'backgroundAlpha',
'foreground',
'foregroundAlpha',
'level',
'mime',
'padding',
'size',
'value',
];
if (inputs.some(function (key) { return key in changes; })) {
this.update();
}
};
QrCodeComponent.prototype.ngOnDestroy = function () {
delete this.qrious;
};
QrCodeComponent.prototype.update = function () {
try {
var 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);
return QrCodeComponent;
}());
var QriousModule = /** @class */ (function () {
function QriousModule() {
}
QriousModule = __decorate([
NgModule({
declarations: [QrCodeComponent],
exports: [QrCodeComponent],
})
], QriousModule);
return QriousModule;
}());
/*
* Public API Surface of angular-qrious-lib
*/
/**
* Generated bundle index. Do not edit.
*/
export { QrCodeComponent, QriousModule };
//# sourceMappingURL=angular-qrious.js.map