@progress/kendo-angular-barcodes
Version:
Kendo UI Angular Barcodes
385 lines (384 loc) • 11.8 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 { 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.
*
* @example
* ```ts
* 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;
/**
* 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"`—Renders the component as a Canvas element.
* * `"svg"`—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
}] } });