UNPKG

@progress/kendo-angular-barcodes

Version:
179 lines (178 loc) 6.38 kB
/**----------------------------------------------------------------------------------------- * 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 { Barcode } 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"; /** * Represents the [Kendo UI Barcode component for Angular](slug:overview_barcode_barcodes). * * Use this component to display a barcode in your Angular application. * * @example * ```typescript * import { Component } from '@angular/core'; * * @Component({ * selector: 'my-app', * template: ` * <kendo-barcode type="EAN8" value="1234567"> * </kendo-barcode> * ` * }) * export class AppComponent { * } * ``` */ export class BarcodeComponent extends BaseComponent { element; renderer; ngZone; /** * Sets the background color of the Barcode. Accepts any valid CSS color string, such as hex or rgb. * * @default "white" */ background; /** * Configures the border of the Barcode. */ border; /** * Shows the checksum digit next to the value in the text area when set to `true`. * * @default false */ checksum; /** * Sets the color of the Barcode. Accepts any valid CSS color string, such as hex or rgb. * * @default "black" */ color; /** * Sets the height of the Barcode in pixels. * * You can also set the Barcode dimensions using CSS. */ height; /** * Sets the padding of the Barcode. Use a number to set all paddings, or a `Padding` object for the individual sides. * * @default 0 */ padding; /** * Sets the rendering mode of the Barcode. * * Use `"canvas"` to render as a Canvas element or `"svg"` to render as an inline SVG. * * @default "svg" */ renderAs; /** * Configures the Barcode text label. */ text; /** * Sets the symbology (encoding) for the Barcode. * * @default "Code39" */ type; /** * Sets the value of the Barcode. */ value; /** * Sets the width of the Barcode in pixels. * * You can also set the Barcode dimensions using CSS. */ width; /** * Limits how often the Barcode resizes automatically. Sets the maximum number of redraws per second when the container size changes. * Set to `0` to disable automatic resizing. * * @default 10 */ 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 }] } });