@progress/kendo-angular-barcodes
Version:
Kendo UI Angular Barcodes
179 lines (178 loc) • 6.62 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { ChangeDetectionStrategy, Component, ElementRef, Input, NgZone, Renderer2 } from '@angular/core';
import { QRCode } from '@progress/kendo-charts';
import { BaseComponent } from './base.component';
import { packageMetadata } from './package-metadata';
import { ResizeSensorComponent } from '@progress/kendo-angular-common';
import * as i0 from "@angular/core";
const DEFAULT_COLOR = '#000';
const DEFAULT_BACKGROUND = '#fff';
const DEFAULT_ERROR_CORRECTION = 'L';
/**
* Represents the [Kendo UI QR Code component for Angular](slug:overview_qrcode_barcodes).
*
* Shows a QR Code for the provided value.
*
* @example
* ```ts
* import { Component } from '@angular/core';
*
* @Component({
* selector: 'my-app',
* template: `
* <kendo-qrcode value="https://www.telerik.com/kendo-angular-ui">
* </kendo-qrcode>
* `
* })
* export class AppComponent {
* }
* ```
*/
export class QRCodeComponent extends BaseComponent {
element;
renderer;
ngZone;
/**
* Sets the background color of the QR Code. Accepts any valid CSS color string, such as hex or rgb.
*
* @default "white"
*/
background;
/**
* Sets the border of the QR Code.
*/
border;
/**
* Sets the color of the QR Code. Accepts any valid CSS color string, such as hex or rgb.
*
* @default "black"
*/
color;
/**
* Sets the encoding mode for the value.
*
* > **Important** The UTF-8 encoding is not part of the specifications and some readers may not support it.
*
* @default "ISO_8859_1"
*/
encoding;
/**
* Sets the error correction level.
*
* @default "L"
*/
errorCorrection;
/**
* Sets an optional image overlay to display over the QR Code.
*
* > **Note** Always test if the code scans correctly with the overlay. If needed, increase the `errorCorrection` level to `"M"` or `"H"`.
*/
overlay;
/**
* Sets the padding for the QR Code in pixels.
*
* @default 0
*/
padding;
/**
* Sets the rendering mode for the QR Code.
*
* @default "svg"
* ```
*/
renderAs;
/**
* Sets the size of the QR Code. Numeric values are in pixels.
*
* If no size is specified, the size will be determined from the element width and height.
* If the element has width or height of zero, a default value of 200 pixels will be used.
*
* @default "200px"
*/
size;
/**
* Sets the value to encode in the QR Code.
*/
value;
/**
* Limits how often the QR Code resizes automatically. Sets the maximum redraws per second when the container size changes.
* Set to `0` to disable automatic resizing.
*
* @default 10
*/
resizeRateLimit = 10;
get options() {
return {
background: this.background || DEFAULT_BACKGROUND,
border: this.border,
color: this.color || DEFAULT_COLOR,
encoding: this.encoding,
errorCorrection: this.errorCorrection || DEFAULT_ERROR_CORRECTION,
overlay: this.overlay || {},
padding: this.padding,
renderAs: this.renderAs,
size: this.size,
value: this.value
};
}
constructor(element, renderer, ngZone) {
super(element, renderer, ngZone);
this.element = element;
this.renderer = renderer;
this.ngZone = ngZone;
}
createInstance(element, options) {
return new QRCode(element, options, this.onError.bind(this));
}
onError(error) {
error.name = packageMetadata.productName + ' QRCode';
if (this.isDevMode()) {
throw error;
}
else {
console.warn(error);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: QRCodeComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: QRCodeComponent, isStandalone: true, selector: "kendo-qrcode", inputs: { background: "background", border: "border", color: "color", encoding: "encoding", errorCorrection: "errorCorrection", overlay: "overlay", padding: "padding", renderAs: "renderAs", size: "size", value: "value", resizeRateLimit: "resizeRateLimit" }, exportAs: ["kendoQRCode"], usesInheritance: true, ngImport: i0, template: `
<kendo-resize-sensor (resize)="onResize()" [rateLimit]="resizeRateLimit"></kendo-resize-sensor>
`, isInline: true, dependencies: [{ kind: "component", type: ResizeSensorComponent, selector: "kendo-resize-sensor", inputs: ["rateLimit"], outputs: ["resize"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: QRCodeComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'kendo-qrcode',
exportAs: 'kendoQRCode',
template: `
<kendo-resize-sensor (resize)="onResize()" [rateLimit]="resizeRateLimit"></kendo-resize-sensor>
`,
standalone: true,
imports: [ResizeSensorComponent]
}]
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }]; }, propDecorators: { background: [{
type: Input
}], border: [{
type: Input
}], color: [{
type: Input
}], encoding: [{
type: Input
}], errorCorrection: [{
type: Input
}], overlay: [{
type: Input
}], padding: [{
type: Input
}], renderAs: [{
type: Input
}], size: [{
type: Input
}], value: [{
type: Input
}], resizeRateLimit: [{
type: Input
}] } });