UNPKG

@progress/kendo-react-barcodes

Version:

React Barcodes provide a set of React components to build beautiful and customizable barcodes. KendoReact Barcodes package

95 lines (94 loc) 3.12 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import * as r from "react"; import { BaseBarcode as a } from "./BaseBarcode.mjs"; import { Barcode as i } from "@progress/kendo-charts"; import { exportImage as n, exportSVG as p, Group as c } from "@progress/kendo-drawing"; import { classNames as u } from "@progress/kendo-react-common"; class g extends r.Component { constructor() { super(...arguments), this._baseBarcode = null, this.getTarget = () => this, this.deriveOptionsFromParent = (e) => Object.assign({}, e, { background: this.props.background, border: this.props.border, checksum: this.props.checksum, color: this.props.color, height: this.props.height, padding: this.props.padding, text: this.props.text, type: this.props.type, value: this.props.value, width: this.props.width }); } /** * @hidden */ get barcodeInstance() { return this._baseBarcode !== null ? this._baseBarcode.barcodeInstance : null; } /** * The Drawing `Surface` of the Barcode. */ get surface() { return this._baseBarcode !== null ? this._baseBarcode.surface : null; } /** * The DOM element of the Barcode. */ get element() { return this._baseBarcode !== null ? this._baseBarcode.element : null; } /** * @hidden */ render() { const { children: e, className: t, ...s } = this.props; return /* @__PURE__ */ r.createElement( a, { ...s, deriveOptionsFromParent: this.deriveOptionsFromParent, ref: (o) => this._baseBarcode = o, barcodeConstructor: i, getTarget: this.getTarget, className: u("k-barcode", t) }, e ); } /** * 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(e = {}) { return n(this.exportVisual(), e); } /** * 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(e = {}) { return p(this.exportVisual(), e); } /** * Exports a Barcode component as a Drawing `Scene`. * * @param {any} options - The parameters for the export operation. * @returns {Group} - A promise that returns the root `Group` of the scene. */ exportVisual(e) { return this.barcodeInstance !== null ? this.barcodeInstance.exportVisual(e) : new c(); } } export { g as Barcode };