/**
 * amis-ui v6.12.0-beta.0
 * Copyright 2018-2025 fex
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var tslib = require('tslib');
var React = require('react');
var amisCore = require('amis-core');
var JsBarcode = require('jsbarcode');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
var JsBarcode__default = /*#__PURE__*/_interopDefaultLegacy(JsBarcode);

var __react_jsx__ = require('react');
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
(__react_jsx__["default"] || __react_jsx__).Fragment;
var BarCode = /** @class */ (function (_super) {
    tslib.__extends(BarCode, _super);
    function BarCode(props) {
        var _this = _super.call(this, props) || this;
        _this.dom = React__default["default"].createRef();
        return _this;
    }
    BarCode.prototype.componentDidUpdate = function (prevProps) {
        if (this.props.value !== prevProps.value ||
            JSON.stringify(this.props.options) !== JSON.stringify(prevProps.options)) {
            this.renderBarCode();
        }
    };
    BarCode.prototype.renderBarCode = function () {
        if (this.dom.current) {
            JsBarcode__default["default"](this.dom.current, this.props.value, this.props.options);
        }
    };
    BarCode.prototype.componentDidMount = function () {
        this.renderBarCode();
    };
    BarCode.prototype.render = function () {
        return _J$X_("img", { ref: this.dom });
    };
    return BarCode;
}(React__default["default"].Component));
var BarCode$1 = amisCore.themeable(BarCode);

exports.BarCode = BarCode;
exports["default"] = BarCode$1;
