UNPKG

@progress/kendo-angular-barcodes

Version:
1,104 lines (1,090 loc) 35.8 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import * as i0 from '@angular/core'; import { isDevMode, Directive, Input, ViewChild, Component, ChangeDetectionStrategy, NgModule } from '@angular/core'; import { Barcode, QRCode, barcodeValidator, qrcodeValidator } from '@progress/kendo-charts'; import { isDocumentAvailable, ResizeSensorComponent, ResizeBatchService } from '@progress/kendo-angular-common'; import { exportImage, exportSVG } from '@progress/kendo-drawing'; import { validatePackage } from '@progress/kendo-licensing'; /** * @hidden */ const packageMetadata = { name: '@progress/kendo-angular-barcodes', productName: 'Kendo UI for Angular', productCode: 'KENDOUIANGULAR', productCodes: ['KENDOUIANGULAR'], publishDate: 1743579875, version: '18.4.0', licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/' }; /** * @hidden */ class BaseComponent { element; renderer; ngZone; resizeRateLimit = 10; surfaceElement; instance; get autoResize() { return this.resizeRateLimit > 0; } get canRender() { return isDocumentAvailable() && Boolean(this.element); } constructor(element, renderer, ngZone) { this.element = element; this.renderer = renderer; this.ngZone = ngZone; validatePackage(packageMetadata); } ngAfterViewInit() { this.refresh(); } ngOnChanges(changes) { // Need to create a new instance if the rendering mode changes. if (changes['renderAs'] && this.instance) { this.instance.destroy(); this.instance = null; } this.refresh(); } /** * Detects the size of the container and redraws the component. * Resizing is automatic unless you set the `resizeRateLimit` option to `0`. */ resize() { if (this.instance) { this.instance.redraw(); } } /** * @hidden */ onResize() { if (this.autoResize) { this.resize(); } } /** * Exports the component as an image. The export operation is asynchronous and returns a promise. * * @param {ImageExportOptions} options - The parameters for the exported image. * @returns {Promise<string>} - A promise that will be resolved with a PNG image encoded as a Data URI. */ exportImage(options = {}) { return exportImage(this.exportVisual(), options); } /** * Exports the component as an SVG document. The export operation is asynchronous and returns a promise. * * @param options - The parameters for the exported file. * @returns - A promise that will be resolved with an SVG document that is encoded as a Data URI. */ exportSVG(options = {}) { return exportSVG(this.exportVisual(), options); } /** * Exports the component as a Drawing Group. * * @returns - The exported Group. */ exportVisual() { return this.instance.exportVisual(); } refresh() { if (!this.canRender) { return; } if (!this.instance) { const element = this.element.nativeElement; this.instance = this.createInstance(element, this.options); } else { this.instance.setOptions(this.options); } } isDevMode() { return isDevMode(); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BaseComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: BaseComponent, inputs: { resizeRateLimit: "resizeRateLimit" }, viewQueries: [{ propertyName: "surfaceElement", first: true, predicate: ["surface"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BaseComponent, decorators: [{ type: Directive }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }]; }, propDecorators: { resizeRateLimit: [{ type: Input }], surfaceElement: [{ type: ViewChild, args: ['surface', { static: true }] }] } }); /** * Represents the Kendo UI Barcode component for Angular. * * @example * ```ts * import { Component } from '@angular/core'; * * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN8" value="1234567"> * </kendo-barcode> * ` * }) * export class AppComponent { * } * ``` */ class BarcodeComponent extends BaseComponent { element; renderer; ngZone; /** * The background color of the Barcode. Accepts a valid CSS color string, including hex and rgb. * * @default "white" * * @example * ```ts-preview * import { Component } from '@angular/core'; * * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN8" value="1234567" * background="#fc0"> * </kendo-barcode> * ` * }) * export class AppComponent { * } * ``` */ background; /** * The border of the Barcode. * * @example * ```ts-preview * import { Component } from '@angular/core'; * import { Border } from '@progress/kendo-angular-barcodes'; * * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN8" value="1234567" * [border]="barcodeBorder" [padding]="5"> * </kendo-barcode> * ` * }) * export class AppComponent { * barcodeBorder: Border = { * color: '#fc0', * width: 2 * }; * } * ``` */ border; /** * If set to `true`, the Barcode will display the checksum digit next to the value in the text area. * * @default false * * @example * ```ts-preview * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN8" value="1234567" * [checksum]="true"> * </kendo-barcode> * ` * }) * export class AppComponent { * } * ``` */ checksum; /** * The color of the Barcode. Accepts a valid CSS color string, including hex and rgb. * * @default "black" * * @example * ```ts-preview * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN8" value="1234567" * color="#fc0"> * </kendo-barcode> * ` * }) * export class AppComponent { * } * ``` */ color; /** * The height of the Barcode in pixels. * * The Barcode dimensions can also be set through regular CSS styling. * * @example * ```ts-preview * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN8" value="1234567" * [width]="200" [height]="100"> * </kendo-barcode> * * <kendo-barcode type="EAN8" value="1234567" * [style.width.px]="200" [style.height.px]="100"> * </kendo-barcode> * ` * }) * export class AppComponent { * } * ``` */ height; /** * The padding of the Barcode. A numeric value sets all paddings. * * @default 0 * * @example * ```ts-preview * import { Component } from '@angular/core'; * import { Padding } from '@progress/kendo-angular-barcodes'; * * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN8" value="1234567" * [padding]="5" background="#fc0"> * </kendo-barcode> * * <kendo-barcode type="EAN8" value="1234567" * [padding]="barcodePadding" background="#cf0"> * </kendo-barcode> * ` * }) * export class AppComponent { * barcodePadding: Padding = { * top: 20, * bottom: 10, * left: 5, * right: 5 * }; * } * ``` */ padding; /** * Sets the preferred rendering mode of the Barcode. * * The supported values are: * * `"canvas"`&mdash;Renders the component as a Canvas element. * * `"svg"`&mdash;Renders the component as an inline SVG document. * * @default "svg" * * @example * ```ts-preview * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN8" value="1234567" * renderAs="canvas"> * </kendo-barcode> * ` * }) * export class AppComponent { * } * ``` */ renderAs; /** * The Barcode text label configuration. * * @example * ```ts-preview * import { Component } from '@angular/core'; * import { BarcodeText } from '@progress/kendo-angular-barcodes'; * * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN8" value="1234567" * [text]="barcodeText"> * </kendo-barcode> * ` * }) * export class AppComponent { * barcodeText: BarcodeText = { * color: '#fc0', * font: '20px monospace' * }; * } * ``` */ text; /** * The symbology (encoding) the Barcode will use. * * @default "Code39" * * @example * ```ts-preview * import { Component } from '@angular/core'; * * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN13" value="123456789987"> * </kendo-barcode> * ` * }) * export class AppComponent { * } * ``` */ type; /** * The value of the Barcode. * * @example * ```ts-preview * import { Component } from '@angular/core'; * * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN13" value="123456789987"> * </kendo-barcode> * ` * }) * export class AppComponent { * } * ``` */ value; /** * The width of the Barcode in pixels. * * The Barcode dimensions can also be set through regular CSS styling. * * @example * ```ts-preview * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN8" value="1234567" * [width]="200" [height]="100"> * </kendo-barcode> * * <kendo-barcode type="EAN8" value="1234567" * [style.width.px]="200" [style.height.px]="100"> * </kendo-barcode> * ` * }) * export class AppComponent { * } * ``` */ width; /** * Limits the automatic resizing of the Barcode. Sets the maximum number of times per second * that the component redraws its content when the size of its container changes. * Defaults to `10`. To disable the automatic resizing, set it to `0`. * * @example * ```ts * _@Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN8" [value]="1234567" * [resizeRateLimit]="2"> * </kendo-barcode> * ` * }) * export class AppComponent { * } * ``` */ resizeRateLimit = 10; get options() { return { renderAs: this.renderAs, background: this.background, border: this.border, checksum: this.checksum, color: this.color, height: this.height, padding: this.padding, text: this.text, type: this.type, value: this.value, width: this.width }; } constructor(element, renderer, ngZone) { super(element, renderer, ngZone); this.element = element; this.renderer = renderer; this.ngZone = ngZone; } createInstance(element, options) { return new Barcode(element, options, this.onError.bind(this)); } onError(error) { error.name = packageMetadata.productName + ' Barcode'; if (this.isDevMode()) { throw error; } else { console.warn(error); } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarcodeComponent, 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: BarcodeComponent, isStandalone: true, selector: "kendo-barcode", inputs: { background: "background", border: "border", checksum: "checksum", color: "color", height: "height", padding: "padding", renderAs: "renderAs", text: "text", type: "type", value: "value", width: "width", resizeRateLimit: "resizeRateLimit" }, exportAs: ["kendoBarcode"], 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: BarcodeComponent, decorators: [{ type: Component, args: [{ changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'kendoBarcode', selector: 'kendo-barcode', 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 }], checksum: [{ type: Input }], color: [{ type: Input }], height: [{ type: Input }], padding: [{ type: Input }], renderAs: [{ type: Input }], text: [{ type: Input }], type: [{ type: Input }], value: [{ type: Input }], width: [{ type: Input }], resizeRateLimit: [{ type: Input }] } }); const DEFAULT_COLOR = '#000'; const DEFAULT_BACKGROUND = '#fff'; const DEFAULT_ERROR_CORRECTION = 'L'; /** * Represents the Kendo UI QR Code component for Angular. * * @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 { * } * ``` */ class QRCodeComponent extends BaseComponent { element; renderer; ngZone; /** * The background color of the QR Code. Accepts a valid CSS color string, including hex and rgb. * * @default "white" * * @example * ```ts-preview * import { Component } from '@angular/core'; * * _@Component({ * selector: 'my-app', * template: ` * <kendo-qrcode value="https://www.telerik.com/kendo-angular-ui" * background="#fc0"> * </kendo-qrcode> * ` * }) * export class AppComponent { * } * ``` */ background; /** * The border of the QR Code. * * @example * ```ts-preview * import { Component } from '@angular/core'; * import { Border } from '@progress/kendo-angular-barcodes'; * * _@Component({ * selector: 'my-app', * template: ` * <kendo-qrcode value="https://www.telerik.com/kendo-angular-ui" * [border]="qrcodeBorder" [padding]="5"> * </kendo-qrcode> * ` * }) * export class AppComponent { * qrcodeBorder: Border = { * color: '#fc0', * width: 2 * }; * } * ``` */ border; /** * The color of the QR Code. Accepts a valid CSS color string, including hex and rgb. * * @default "black" * * @example * ```ts-preview * _@Component({ * selector: 'my-app', * template: ` * <kendo-qrcode value="https://www.telerik.com/kendo-angular-ui" * color="#fc0"> * </kendo-qrcode> * ` * }) * export class AppComponent { * } * ``` */ color; /** * The encoding mode used to encode the value. * * > **Important** The UTF-8 encoding is not included in the specifications and is not supported by all readers. * * The possible values are: * * `"ISO_8859_1"`&mdash;Supports all characters from the [ISO/IEC 8859-1](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) character set. * * `"UTF_8"`&mdash;Supports all [Unicode](https://en.wikipedia.org/wiki/List_of_Unicode_characters) characters. * * @default "ISO_8859_1" * * @example * ```ts-preview * _@Component({ * selector: 'my-app', * template: ` * <kendo-qrcode value="АБВ" encoding="UTF_8"> * </kendo-qrcode> * ` * }) * export class AppComponent { * } * ``` */ encoding; /** * The error correction level to use. * * The possible values are: * * `"L"`&mdash;Approximately 7% of the codewords can be restored. * * `"M"`&mdash;Approximately 15% of the codewords can be restored. * * `"Q"`&mdash;Approximately 25% of the codewords can be restored. * * `"H"`&mdash;Approximately 30% of the codewords can be restored. * * @default "L" * * @example * ```ts-preview * _@Component({ * selector: 'my-app', * template: ` * <kendo-qrcode value="https://www.telerik.com/kendo-angular-ui" * errorCorrection="Q"> * </kendo-qrcode> * ` * }) * export class AppComponent { * } * ``` */ errorCorrection; /** * An optional image overlay that will placed over the QR Code. * * > **Note** Always test if the code reads correctly with the applied overlay. * > Depending on the length of the value and the size of the overlay, you might need to raise the `errorCorrection` level to `"M"` or `"H"`. * * @example * ```ts-preview * import { QRCodeOverlay } from '@progress/kendo-angular-barcodes'; * * _@Component({ * selector: 'my-app', * template: ` * <kendo-qrcode value="https://www.telerik.com/kendo-angular-ui" * [overlay]="qrcodeOverlay"> * </kendo-qrcode> * ` * }) * export class AppComponent { * qrcodeOverlay: QRCodeOverlay = { * type: 'swiss' * }; * } * ``` */ overlay; /** * The padding of the QR Code. The value sets all paddings in pixels. * * @default 0 * * @example * ```ts-preview * import { Component } from '@angular/core'; * * _@Component({ * selector: 'my-app', * template: ` * <kendo-qrcode value="https://www.telerik.com/kendo-angular-ui" * [padding]="10" background="#fc0"> * </kendo-qrcode> * ` * }) * export class AppComponent { * } * ``` */ padding; /** * Sets the preferred rendering mode of the QR Code. * * The supported values are: * * `"canvas"`&mdash;Renders the component as a Canvas element. * * `"svg"`&mdash;Renders the component as an inline SVG document. * * @default "svg" * * @example * ```ts-preview * _@Component({ * selector: 'my-app', * template: ` * <kendo-qrcode value="https://www.telerik.com/kendo-angular-ui" * renderAs="canvas"> * </kendo-qrcode> * ` * }) * export class AppComponent { * } * ``` */ renderAs; /** * Specifies the size of a QR Code. Numeric values are treated as 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" * * @example * ```ts-preview * _@Component({ * selector: 'my-app', * template: ` * <kendo-qrcode value="https://www.telerik.com/kendo-angular-ui" * [size]="200"> * </kendo-qrcode> * * <kendo-qrcode value="https://www.telerik.com/kendo-angular-ui" * [style.width.px]="200" [style.height.px]="200"> * </kendo-qrcode> * ` * }) * export class AppComponent { * } * ``` */ size; /** * The value of the QR Code. * * @example * ```ts-preview * _@Component({ * selector: 'my-app', * template: ` * <kendo-qrcode value="https://www.telerik.com/kendo-angular-ui"> * </kendo-qrcode> * ` * }) * export class AppComponent { * } * ``` */ value; /** * Limits the automatic resizing of the QR Code. Sets the maximum number of times per second * that the component redraws its content when the size of its container changes. * Defaults to `10`. To disable the automatic resizing, set it to `0`. * * @example * ```ts * _@Component({ * selector: 'my-app', * template: ` * <kendo-qrcode value="https://www.telerik.com/kendo-angular-ui" * [resizeRateLimit]="2"> * </kendo-qrcode> * ` * }) * export class AppComponent { * } * ``` */ 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 }] } }); /** * Utility array that contains all `Barcode` related components and directives */ const KENDO_BARCODE = [ BarcodeComponent ]; /** * Utility array that contains all `QRCode` related components and directives */ const KENDO_QRCODE = [ QRCodeComponent ]; /** * Utility array that contains all `@progress/kendo-angular-barcodes` related components and directives */ const KENDO_BARCODES = [ ...KENDO_BARCODE, ...KENDO_QRCODE ]; //IMPORTANT: NgModule export kept for backwards compatibility /** * Represents the [NgModule](link:site.data.urls.angular['ngmoduleapi']) * definition for the Barcode component. * * @example * * ```ts-no-run * // Import the Barcode module * import { BarcodeModule } from '@progress/kendo-angular-barcodes'; * * // The browser platform with a compiler * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; * * import { NgModule } from '@angular/core'; * * // Import the app component * import { AppComponent } from './app.component'; * * // Define the app module * _@NgModule({ * declarations: [AppComponent], // declare app component * imports: [BrowserModule, BarcodeModule], // import Barcode module * bootstrap: [AppComponent] * }) * export class AppModule {} * * // Compile and launch the module * platformBrowserDynamic().bootstrapModule(AppModule); * * ``` */ class BarcodeModule { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarcodeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: BarcodeModule, imports: [BarcodeComponent], exports: [BarcodeComponent] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarcodeModule, providers: [ResizeBatchService], imports: [KENDO_BARCODE] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarcodeModule, decorators: [{ type: NgModule, args: [{ imports: [...KENDO_BARCODE], exports: [...KENDO_BARCODE], providers: [ResizeBatchService] }] }] }); //IMPORTANT: NgModule export kept for backwards compatibility /** * Represents the [NgModule](link:site.data.urls.angular['ngmoduleapi']) * definition for the QR Code component. * * @example * * ```ts-no-run * // Import the QR Code module * import { QRCodeModule } from '@progress/kendo-angular-barcodes'; * * // The browser platform with a compiler * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; * * import { NgModule } from '@angular/core'; * * // Import the app component * import { AppComponent } from './app.component'; * * // Define the app module * _@NgModule({ * declarations: [AppComponent], // declare app component * imports: [BrowserModule, QRCodeModule], // import QRCodeModule module * bootstrap: [AppComponent] * }) * export class AppModule {} * * // Compile and launch the module * platformBrowserDynamic().bootstrapModule(AppModule); * * ``` */ class QRCodeModule { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: QRCodeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: QRCodeModule, imports: [QRCodeComponent], exports: [QRCodeComponent] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: QRCodeModule, providers: [ResizeBatchService], imports: [KENDO_QRCODE] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: QRCodeModule, decorators: [{ type: NgModule, args: [{ imports: [...KENDO_QRCODE], exports: [...KENDO_QRCODE], providers: [ResizeBatchService] }] }] }); //IMPORTANT: NgModule export kept for backwards compatibility /** * Represents the [NgModule](link:site.data.urls.angular['ngmoduleapi']) * definition for the Barcode and QR Code components. * * @example * * ```ts-no-run * // Import the Barcodes module * import { BarcodesModule } from '@progress/kendo-angular-barcodes'; * * // The browser platform with a compiler * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; * * import { NgModule } from '@angular/core'; * * // Import the app component * import { AppComponent } from './app.component'; * * // Define the app module * _@NgModule({ * declarations: [AppComponent], // declare app component * imports: [BrowserModule, BarcodesModule], // import Barcodes module * bootstrap: [AppComponent] * }) * export class AppModule {} * * // Compile and launch the module * platformBrowserDynamic().bootstrapModule(AppModule); * * ``` */ class BarcodesModule { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarcodesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: BarcodesModule, imports: [BarcodeComponent, QRCodeComponent], exports: [BarcodeComponent, QRCodeComponent] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarcodesModule, providers: [ResizeBatchService], imports: [KENDO_BARCODES] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarcodesModule, decorators: [{ type: NgModule, args: [{ imports: [...KENDO_BARCODES], exports: [...KENDO_BARCODES], providers: [ResizeBatchService] }] }] }); /** * @hidden */ const isPresent = (value) => value !== null && value !== undefined; /** * Creates a value validator for a particular Barcode type. * * @param {BarcodeType} type The type of the Barcode. * @param {Size} size The size of the barcode, excluding the text label, padding and border. Optional. * @returns {ValidatorFn} A validator function that returns an error map with the `barcode` property if the validation check fails, otherwise `null`. * * @example * ```ts-no-run * const control = new FormControl('1234', createBarcodeValidator('EAN8')); * console.log(control.errors); * * // { * // barcode: { * // message: 'The value of the "EAN13" encoding should be 12 symbols', * // value: '1234', * // type: 'EAN13' * // } * // } * ``` */ const createBarcodeValidator = (type, size) => { const validator = barcodeValidator(type, size); return (control) => { if (!isPresent(control.value) || control.value === '') { return null; } const result = validator(control.value); if (result.valid === true) { return null; } return { barcode: { message: result.error.message, value: control.value, type: type } }; }; }; /** * Creates a value validator for a particular Barcode type. * * @param {QRCodeEncoding} encoding The QR Code encoding. Defaults to 'ISO_8859_1'. * @returns {ValidatorFn} A validator function that returns an error map with the `qrcode` property if the validation check fails, otherwise `null`. * * @example * ```ts-no-run * const control = new FormControl('Фоо', createQRCodeValidator()); * console.log(control.errors); * * // { * // qrcode: { * // message: 'Unsupported character in QR Code: "Ф".', * // value: '1234', * // type: 'EAN13' * // } * // } * ``` */ const createQRCodeValidator = (encoding = 'ISO_8859_1') => { const validator = qrcodeValidator(encoding); return (control) => { if (!control.value) { return null; } const result = validator(control.value); if (result.valid === true) { return null; } return { qrcode: { message: result.error.message, value: control.value, encoding: encoding } }; }; }; /** * Generated bundle index. Do not edit. */ export { BarcodeComponent, BarcodeModule, BarcodesModule, KENDO_BARCODE, KENDO_BARCODES, KENDO_QRCODE, QRCodeComponent, QRCodeModule, createBarcodeValidator, createQRCodeValidator };