Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-barcode

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-barcode - npm Package Compare versions

Comparing version 1.3.4 to 1.4.0

204

lib/react-barcode.js

@@ -1,13 +0,35 @@

'use strict';
"use strict";
var React = require('react');
var JsBarcode = require('jsbarcode');
var createClass = require('create-react-class');
var PropTypes = require('prop-types');
var _react = _interopRequireDefault(require("react"));
var getDOMNode;
// Super naive semver detection but it's good enough. We support 0.12, 0.13
var _jsbarcode = _interopRequireDefault(require("jsbarcode"));
var _propTypes = _interopRequireDefault(require("prop-types"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var getDOMNode; // Super naive semver detection but it's good enough. We support 0.12, 0.13
// which both have getDOMNode on the ref. 0.14 and 15 make the DOM node the ref.
var version = React.version.split(/[.-]/);
if (version[0] === '0' && version[1] === '13' || version[1] === '12') {
var version = _react["default"].version.split(/[.-]/);
if (version[0] === '0' && (version[1] === '13' || version[1] === '12')) {
getDOMNode = function getDOMNode(ref) {

@@ -22,79 +44,107 @@ return ref.getDOMNode();

var Barcode = createClass({
propTypes: {
value: PropTypes.string.isRequired,
renderer: PropTypes.string,
format: PropTypes.string,
width: PropTypes.number,
height: PropTypes.number,
displayValue: PropTypes.bool,
fontOptions: PropTypes.string,
font: PropTypes.string,
textAlign: PropTypes.string,
textPosition: PropTypes.string,
textMargin: PropTypes.number,
fontSize: PropTypes.number,
background: PropTypes.string,
lineColor: PropTypes.string,
margin: PropTypes.number,
marginTop: PropTypes.number,
marginBottom: PropTypes.number,
marginLeft: PropTypes.number,
marginRight: PropTypes.number
},
var Barcode =
/*#__PURE__*/
function (_React$Component) {
_inherits(Barcode, _React$Component);
getDefaultProps: function getDefaultProps() {
return {
format: 'CODE128',
renderer: 'svg',
width: 2,
height: 100,
displayValue: true,
fontOptions: '',
font: 'monospace',
textAlign: 'center',
textPosition: 'bottom',
textMargin: 2,
fontSize: 20,
background: '#ffffff',
lineColor: '#000000',
margin: 10
};
},
function Barcode(props) {
var _this;
shouldComponentUpdate: function shouldComponentUpdate(nextProps) {
var _this = this;
_classCallCheck(this, Barcode);
return Object.keys(Barcode.propTypes).some(function (k) {
return _this.props[k] !== nextProps[k];
});
},
_this = _possibleConstructorReturn(this, _getPrototypeOf(Barcode).call(this, props));
_this.update = _this.update.bind(_assertThisInitialized(_this));
return _this;
}
componentDidMount: function componentDidMount() {
this.update();
},
_createClass(Barcode, [{
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps) {
var _this2 = this;
componentDidUpdate: function componentDidUpdate() {
this.update();
},
update: function update() {
var renderElement = getDOMNode(this.refs.renderElement);
try {
new JsBarcode(renderElement, this.props.value, Object.assign({}, this.props));
} catch (e) {
// prevent stop the parent process
window.console.error(e);
return Object.keys(Barcode.propTypes).some(function (k) {
return _this2.props[k] !== nextProps[k];
});
}
},
}, {
key: "componentDidMount",
value: function componentDidMount() {
this.update();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
this.update();
}
}, {
key: "update",
value: function update() {
var renderElement = getDOMNode(this.refs.renderElement);
render: function render() {
if (this.props.renderer === 'svg') {
return React.createElement('svg', { ref: 'renderElement' });
} else if (this.props.renderer === 'canvas') {
return React.createElement('canvas', { ref: 'renderElement' });
try {
new _jsbarcode["default"](renderElement, this.props.value, Object.assign({}, this.props));
} catch (e) {
// prevent stop the parent process
window.console.error(e);
}
}
}
});
}, {
key: "render",
value: function render() {
if (this.props.renderer === 'svg') {
return _react["default"].createElement("svg", {
ref: "renderElement"
});
} else if (this.props.renderer === 'canvas') {
return _react["default"].createElement("canvas", {
ref: "renderElement"
});
} else if (this.props.renderer === 'img') {
return _react["default"].createElement("img", {
ref: "renderElement"
});
}
}
}]);
return Barcode;
}(_react["default"].Component);
Barcode.propTypes = {
value: _propTypes["default"].string.isRequired,
renderer: _propTypes["default"].string,
format: _propTypes["default"].string,
width: _propTypes["default"].number,
height: _propTypes["default"].number,
displayValue: _propTypes["default"].bool,
fontOptions: _propTypes["default"].string,
font: _propTypes["default"].string,
textAlign: _propTypes["default"].string,
textPosition: _propTypes["default"].string,
textMargin: _propTypes["default"].number,
fontSize: _propTypes["default"].number,
background: _propTypes["default"].string,
lineColor: _propTypes["default"].string,
margin: _propTypes["default"].number,
marginTop: _propTypes["default"].number,
marginBottom: _propTypes["default"].number,
marginLeft: _propTypes["default"].number,
marginRight: _propTypes["default"].number
};
Barcode.defaultProps = {
format: 'CODE128',
renderer: 'svg',
width: 2,
height: 100,
displayValue: true,
fontOptions: '',
font: 'monospace',
textAlign: 'center',
textPosition: 'bottom',
textMargin: 2,
fontSize: 20,
background: '#ffffff',
lineColor: '#000000',
margin: 10
};
module.exports = Barcode;
{
"name": "react-barcode",
"version": "1.3.4",
"version": "1.4.0",
"description": "React component to generate barcodes",

@@ -31,17 +31,17 @@ "keywords": [

"jsbarcode": "^3.8.0",
"create-react-class": "^15.5.3",
"prop-types": "^15.5.10"
"prop-types": "^15.6.2"
},
"devDependencies": {
"babel-cli": "^6.4.0",
"babel-eslint": "^4.1.3",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babelify": "^7.2.0",
"browserify": "^13.0.0",
"eslint": "^1.6.0",
"@babel/cli": "7.7.0",
"@babel/core": "7.7.2",
"@babel/preset-env": "7.7.1",
"@babel/preset-react": "7.7.0",
"babel-eslint": "^10.0.3",
"babelify": "^10.0.0",
"browserify": "^16.5.0",
"eslint": "^4.18.2",
"eslint-plugin-react": "^3.5.1",
"react": "^15.0.0",
"react-dom": "^15.0.0"
"react": "^16.4.1",
"react-dom": "^16.4.1"
}
}

@@ -8,7 +8,2 @@ # react-barcode

## Donate
If you like this open source, you can sponsor it. :smile:
[Paypal me](https://www.paypal.me/kciter)
## Installation

@@ -60,2 +55,7 @@ ```

## Donate
If you like this open source, you can sponsor it. :smile:
[Paypal me](https://www.paypal.me/kciter)
## Licence

@@ -62,0 +62,0 @@ Copyright (c) 2016, Lee Sun-Hyoup

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc