@progress/kendo-react-barcodes
Version:
React Barcodes provide a set of React components to build beautiful and customizable barcodes. KendoReact Barcodes package
98 lines (97 loc) • 3.23 kB
JavaScript
/**
* @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 e from "react";
import { BaseBarcode as a } from "./BaseBarcode.mjs";
import { QRCode as n } from "@progress/kendo-charts";
import { exportImage as i, exportSVG as c, Group as p } from "@progress/kendo-drawing";
import { classNames as d } from "@progress/kendo-react-common";
const u = "#000", l = "#fff", h = "L";
class _ extends e.Component {
constructor() {
super(...arguments), this._baseBarcode = null, this.getTarget = () => this, this.deriveOptionsFromParent = (r) => Object.assign({}, r, {
background: this.props.background || l,
border: this.props.border,
color: this.props.color || u,
encoding: this.props.encoding,
errorCorrection: this.props.errorCorrection || h,
overlay: this.props.overlay || {},
padding: this.props.padding,
renderAs: this.props.renderAs,
size: this.props.size,
value: this.props.value
});
}
/**
* @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: r, className: t, ...s } = this.props;
return /* @__PURE__ */ e.createElement(
a,
{
...s,
deriveOptionsFromParent: this.deriveOptionsFromParent,
ref: (o) => {
this._baseBarcode = o;
},
barcodeConstructor: n,
getTarget: this.getTarget,
className: d("k-qrcode", t)
},
r
);
}
/**
* 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(r = {}) {
return i(this.exportVisual(), r);
}
/**
* 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(r = {}) {
return c(this.exportVisual(), r);
}
/**
* 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(r) {
return this.barcodeInstance !== null ? this.barcodeInstance.exportVisual(r) : new p();
}
}
export {
_ as QRCode
};