Barcode Generation
This commit is contained in:
225
node_modules/jsbarcode/src/JsBarcode.js
generated
vendored
Normal file
225
node_modules/jsbarcode/src/JsBarcode.js
generated
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
// Import all the barcodes
|
||||
import barcodes from './barcodes/';
|
||||
|
||||
// Help functions
|
||||
import merge from './help/merge.js';
|
||||
import linearizeEncodings from './help/linearizeEncodings.js';
|
||||
import fixOptions from './help/fixOptions.js';
|
||||
import getRenderProperties from './help/getRenderProperties.js';
|
||||
import optionsFromStrings from './help/optionsFromStrings.js';
|
||||
|
||||
// Exceptions
|
||||
import ErrorHandler from './exceptions/ErrorHandler.js';
|
||||
import {InvalidInputException, NoElementException} from './exceptions/exceptions.js';
|
||||
|
||||
// Default values
|
||||
import defaults from './options/defaults.js';
|
||||
|
||||
// The protype of the object returned from the JsBarcode() call
|
||||
let API = function(){};
|
||||
|
||||
// The first call of the library API
|
||||
// Will return an object with all barcodes calls and the data that is used
|
||||
// by the renderers
|
||||
let JsBarcode = function(element, text, options){
|
||||
var api = new API();
|
||||
|
||||
if(typeof element === "undefined"){
|
||||
throw Error("No element to render on was provided.");
|
||||
}
|
||||
|
||||
// Variables that will be pased through the API calls
|
||||
api._renderProperties = getRenderProperties(element);
|
||||
api._encodings = [];
|
||||
api._options = defaults;
|
||||
api._errorHandler = new ErrorHandler(api);
|
||||
|
||||
// If text is set, use the simple syntax (render the barcode directly)
|
||||
if(typeof text !== "undefined"){
|
||||
options = options || {};
|
||||
|
||||
if(!options.format){
|
||||
options.format = autoSelectBarcode();
|
||||
}
|
||||
|
||||
api.options(options)[options.format](text, options).render();
|
||||
}
|
||||
|
||||
return api;
|
||||
};
|
||||
|
||||
// To make tests work TODO: remove
|
||||
JsBarcode.getModule = function(name){
|
||||
return barcodes[name];
|
||||
};
|
||||
|
||||
// Register all barcodes
|
||||
for(var name in barcodes){
|
||||
if(barcodes.hasOwnProperty(name)){ // Security check if the propery is a prototype property
|
||||
registerBarcode(barcodes, name);
|
||||
}
|
||||
}
|
||||
function registerBarcode(barcodes, name){
|
||||
API.prototype[name] =
|
||||
API.prototype[name.toUpperCase()] =
|
||||
API.prototype[name.toLowerCase()] =
|
||||
function(text, options){
|
||||
var api = this;
|
||||
return api._errorHandler.wrapBarcodeCall(function(){
|
||||
// Ensure text is options.text
|
||||
options.text = typeof options.text === 'undefined' ? undefined : '' + options.text;
|
||||
|
||||
var newOptions = merge(api._options, options);
|
||||
newOptions = optionsFromStrings(newOptions);
|
||||
var Encoder = barcodes[name];
|
||||
var encoded = encode(text, Encoder, newOptions);
|
||||
api._encodings.push(encoded);
|
||||
|
||||
return api;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// encode() handles the Encoder call and builds the binary string to be rendered
|
||||
function encode(text, Encoder, options){
|
||||
// Ensure that text is a string
|
||||
text = "" + text;
|
||||
|
||||
var encoder = new Encoder(text, options);
|
||||
|
||||
// If the input is not valid for the encoder, throw error.
|
||||
// If the valid callback option is set, call it instead of throwing error
|
||||
if(!encoder.valid()){
|
||||
throw new InvalidInputException(encoder.constructor.name, text);
|
||||
}
|
||||
|
||||
// Make a request for the binary data (and other infromation) that should be rendered
|
||||
var encoded = encoder.encode();
|
||||
|
||||
// Encodings can be nestled like [[1-1, 1-2], 2, [3-1, 3-2]
|
||||
// Convert to [1-1, 1-2, 2, 3-1, 3-2]
|
||||
encoded = linearizeEncodings(encoded);
|
||||
|
||||
// Merge
|
||||
for(let i = 0; i < encoded.length; i++){
|
||||
encoded[i].options = merge(options, encoded[i].options);
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
function autoSelectBarcode(){
|
||||
// If CODE128 exists. Use it
|
||||
if(barcodes["CODE128"]){
|
||||
return "CODE128";
|
||||
}
|
||||
|
||||
// Else, take the first (probably only) barcode
|
||||
return Object.keys(barcodes)[0];
|
||||
}
|
||||
|
||||
// Sets global encoder options
|
||||
// Added to the api by the JsBarcode function
|
||||
API.prototype.options = function(options){
|
||||
this._options = merge(this._options, options);
|
||||
return this;
|
||||
};
|
||||
|
||||
// Will create a blank space (usually in between barcodes)
|
||||
API.prototype.blank = function(size){
|
||||
const zeroes = new Array(size + 1).join("0");
|
||||
this._encodings.push({data: zeroes});
|
||||
return this;
|
||||
};
|
||||
|
||||
// Initialize JsBarcode on all HTML elements defined.
|
||||
API.prototype.init = function(){
|
||||
// Should do nothing if no elements where found
|
||||
if(!this._renderProperties){
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure renderProperies is an array
|
||||
if(!Array.isArray(this._renderProperties)){
|
||||
this._renderProperties = [this._renderProperties];
|
||||
}
|
||||
|
||||
var renderProperty;
|
||||
for(let i in this._renderProperties){
|
||||
renderProperty = this._renderProperties[i];
|
||||
var options = merge(this._options, renderProperty.options);
|
||||
|
||||
if(options.format == "auto"){
|
||||
options.format = autoSelectBarcode();
|
||||
}
|
||||
|
||||
this._errorHandler.wrapBarcodeCall(function(){
|
||||
var text = options.value;
|
||||
var Encoder = barcodes[options.format.toUpperCase()];
|
||||
var encoded = encode(text, Encoder, options);
|
||||
|
||||
render(renderProperty, encoded, options);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// The render API call. Calls the real render function.
|
||||
API.prototype.render = function(){
|
||||
if(!this._renderProperties){
|
||||
throw new NoElementException();
|
||||
}
|
||||
|
||||
if(Array.isArray(this._renderProperties)){
|
||||
for(var i = 0; i < this._renderProperties.length; i++){
|
||||
render(this._renderProperties[i], this._encodings, this._options);
|
||||
}
|
||||
}
|
||||
else{
|
||||
render(this._renderProperties, this._encodings, this._options);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
API.prototype._defaults = defaults;
|
||||
|
||||
// Prepares the encodings and calls the renderer
|
||||
function render(renderProperties, encodings, options){
|
||||
encodings = linearizeEncodings(encodings);
|
||||
|
||||
for(let i = 0; i < encodings.length; i++){
|
||||
encodings[i].options = merge(options, encodings[i].options);
|
||||
fixOptions(encodings[i].options);
|
||||
}
|
||||
|
||||
fixOptions(options);
|
||||
|
||||
var Renderer = renderProperties.renderer;
|
||||
var renderer = new Renderer(renderProperties.element, encodings, options);
|
||||
renderer.render();
|
||||
|
||||
if(renderProperties.afterRender){
|
||||
renderProperties.afterRender();
|
||||
}
|
||||
}
|
||||
|
||||
// Export to browser
|
||||
if(typeof window !== "undefined"){
|
||||
window.JsBarcode = JsBarcode;
|
||||
}
|
||||
|
||||
// Export to jQuery
|
||||
/*global jQuery */
|
||||
if (typeof jQuery !== 'undefined') {
|
||||
jQuery.fn.JsBarcode = function(content, options){
|
||||
var elementArray = [];
|
||||
jQuery(this).each(function() {
|
||||
elementArray.push(this);
|
||||
});
|
||||
return JsBarcode(elementArray, content, options);
|
||||
};
|
||||
}
|
||||
|
||||
// Export to commonJS
|
||||
module.exports = JsBarcode;
|
||||
9
node_modules/jsbarcode/src/barcodes/Barcode.js
generated
vendored
Normal file
9
node_modules/jsbarcode/src/barcodes/Barcode.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
class Barcode{
|
||||
constructor(data, options){
|
||||
this.data = data;
|
||||
this.text = options.text || data;
|
||||
this.options = options;
|
||||
}
|
||||
}
|
||||
|
||||
export default Barcode;
|
||||
127
node_modules/jsbarcode/src/barcodes/CODE128/CODE128.js
generated
vendored
Normal file
127
node_modules/jsbarcode/src/barcodes/CODE128/CODE128.js
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
import Barcode from "../Barcode.js";
|
||||
import { SHIFT, SET_A, SET_B, MODULO, STOP, FNC1, SET_BY_CODE, SWAP, BARS } from './constants';
|
||||
|
||||
// This is the master class,
|
||||
// it does require the start code to be included in the string
|
||||
class CODE128 extends Barcode {
|
||||
constructor(data, options) {
|
||||
super(data.substring(1), options);
|
||||
|
||||
// Get array of ascii codes from data
|
||||
this.bytes = data.split('')
|
||||
.map(char => char.charCodeAt(0));
|
||||
}
|
||||
|
||||
valid() {
|
||||
// ASCII value ranges 0-127, 200-211
|
||||
return /^[\x00-\x7F\xC8-\xD3]+$/.test(this.data);
|
||||
}
|
||||
|
||||
// The public encoding function
|
||||
encode() {
|
||||
const bytes = this.bytes;
|
||||
// Remove the start code from the bytes and set its index
|
||||
const startIndex = bytes.shift() - 105;
|
||||
// Get start set by index
|
||||
const startSet = SET_BY_CODE[startIndex];
|
||||
|
||||
if (startSet === undefined) {
|
||||
throw new RangeError('The encoding does not start with a start character.');
|
||||
}
|
||||
|
||||
if (this.shouldEncodeAsEan128() === true) {
|
||||
bytes.unshift(FNC1);
|
||||
}
|
||||
|
||||
// Start encode with the right type
|
||||
const encodingResult = CODE128.next(bytes, 1, startSet);
|
||||
|
||||
return {
|
||||
text:
|
||||
this.text === this.data
|
||||
? this.text.replace(/[^\x20-\x7E]/g, '')
|
||||
: this.text,
|
||||
data:
|
||||
// Add the start bits
|
||||
CODE128.getBar(startIndex) +
|
||||
// Add the encoded bits
|
||||
encodingResult.result +
|
||||
// Add the checksum
|
||||
CODE128.getBar((encodingResult.checksum + startIndex) % MODULO) +
|
||||
// Add the end bits
|
||||
CODE128.getBar(STOP)
|
||||
};
|
||||
}
|
||||
|
||||
// GS1-128/EAN-128
|
||||
shouldEncodeAsEan128() {
|
||||
let isEAN128 = this.options.ean128 || false;
|
||||
if (typeof isEAN128 === 'string') {
|
||||
isEAN128 = isEAN128.toLowerCase() === 'true';
|
||||
}
|
||||
return isEAN128;
|
||||
}
|
||||
|
||||
// Get a bar symbol by index
|
||||
static getBar(index) {
|
||||
return BARS[index] ? BARS[index].toString() : '';
|
||||
}
|
||||
|
||||
// Correct an index by a set and shift it from the bytes array
|
||||
static correctIndex(bytes, set) {
|
||||
if (set === SET_A) {
|
||||
const charCode = bytes.shift();
|
||||
return charCode < 32 ? charCode + 64 : charCode - 32;
|
||||
} else if (set === SET_B) {
|
||||
return bytes.shift() - 32;
|
||||
} else {
|
||||
return (bytes.shift() - 48) * 10 + bytes.shift() - 48;
|
||||
}
|
||||
}
|
||||
|
||||
static next(bytes, pos, set) {
|
||||
if (!bytes.length) {
|
||||
return { result: '', checksum: 0 };
|
||||
}
|
||||
|
||||
let nextCode, index;
|
||||
|
||||
// Special characters
|
||||
if (bytes[0] >= 200){
|
||||
index = bytes.shift() - 105;
|
||||
const nextSet = SWAP[index];
|
||||
|
||||
// Swap to other set
|
||||
if (nextSet !== undefined) {
|
||||
nextCode = CODE128.next(bytes, pos + 1, nextSet);
|
||||
}
|
||||
// Continue on current set but encode a special character
|
||||
else {
|
||||
// Shift
|
||||
if ((set === SET_A || set === SET_B) && index === SHIFT) {
|
||||
// Convert the next character so that is encoded correctly
|
||||
bytes[0] = (set === SET_A)
|
||||
? bytes[0] > 95 ? bytes[0] - 96 : bytes[0]
|
||||
: bytes[0] < 32 ? bytes[0] + 96 : bytes[0];
|
||||
}
|
||||
nextCode = CODE128.next(bytes, pos + 1, set);
|
||||
}
|
||||
}
|
||||
// Continue encoding
|
||||
else {
|
||||
index = CODE128.correctIndex(bytes, set);
|
||||
nextCode = CODE128.next(bytes, pos + 1, set);
|
||||
}
|
||||
|
||||
// Get the correct binary encoding and calculate the weight
|
||||
const enc = CODE128.getBar(index);
|
||||
const weight = index * pos;
|
||||
|
||||
return {
|
||||
result: enc + nextCode.result,
|
||||
checksum: weight + nextCode.checksum
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default CODE128;
|
||||
14
node_modules/jsbarcode/src/barcodes/CODE128/CODE128A.js
generated
vendored
Normal file
14
node_modules/jsbarcode/src/barcodes/CODE128/CODE128A.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import CODE128 from './CODE128.js';
|
||||
import { A_START_CHAR, A_CHARS } from './constants';
|
||||
|
||||
class CODE128A extends CODE128 {
|
||||
constructor(string, options) {
|
||||
super(A_START_CHAR + string, options);
|
||||
}
|
||||
|
||||
valid() {
|
||||
return (new RegExp(`^${A_CHARS}+$`)).test(this.data);
|
||||
}
|
||||
}
|
||||
|
||||
export default CODE128A;
|
||||
14
node_modules/jsbarcode/src/barcodes/CODE128/CODE128B.js
generated
vendored
Normal file
14
node_modules/jsbarcode/src/barcodes/CODE128/CODE128B.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import CODE128 from './CODE128.js';
|
||||
import { B_START_CHAR, B_CHARS } from './constants';
|
||||
|
||||
class CODE128B extends CODE128 {
|
||||
constructor(string, options) {
|
||||
super(B_START_CHAR + string, options);
|
||||
}
|
||||
|
||||
valid() {
|
||||
return (new RegExp(`^${B_CHARS}+$`)).test(this.data);
|
||||
}
|
||||
}
|
||||
|
||||
export default CODE128B;
|
||||
14
node_modules/jsbarcode/src/barcodes/CODE128/CODE128C.js
generated
vendored
Normal file
14
node_modules/jsbarcode/src/barcodes/CODE128/CODE128C.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import CODE128 from './CODE128.js';
|
||||
import { C_START_CHAR, C_CHARS } from './constants';
|
||||
|
||||
class CODE128C extends CODE128 {
|
||||
constructor(string, options) {
|
||||
super(C_START_CHAR + string, options);
|
||||
}
|
||||
|
||||
valid() {
|
||||
return (new RegExp(`^${C_CHARS}+$`)).test(this.data);
|
||||
}
|
||||
}
|
||||
|
||||
export default CODE128C;
|
||||
15
node_modules/jsbarcode/src/barcodes/CODE128/CODE128_AUTO.js
generated
vendored
Normal file
15
node_modules/jsbarcode/src/barcodes/CODE128/CODE128_AUTO.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import CODE128 from './CODE128';
|
||||
import autoSelectModes from './auto';
|
||||
|
||||
class CODE128AUTO extends CODE128{
|
||||
constructor(data, options){
|
||||
// ASCII value ranges 0-127, 200-211
|
||||
if (/^[\x00-\x7F\xC8-\xD3]+$/.test(data)) {
|
||||
super(autoSelectModes(data), options);
|
||||
} else{
|
||||
super(data, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default CODE128AUTO;
|
||||
68
node_modules/jsbarcode/src/barcodes/CODE128/auto.js
generated
vendored
Normal file
68
node_modules/jsbarcode/src/barcodes/CODE128/auto.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import { A_START_CHAR, B_START_CHAR, C_START_CHAR, A_CHARS, B_CHARS, C_CHARS } from './constants';
|
||||
|
||||
// Match Set functions
|
||||
const matchSetALength = (string) => string.match(new RegExp(`^${A_CHARS}*`))[0].length;
|
||||
const matchSetBLength = (string) => string.match(new RegExp(`^${B_CHARS}*`))[0].length;
|
||||
const matchSetC = (string) => string.match(new RegExp(`^${C_CHARS}*`))[0];
|
||||
|
||||
// CODE128A or CODE128B
|
||||
function autoSelectFromAB(string, isA){
|
||||
const ranges = isA ? A_CHARS : B_CHARS;
|
||||
const untilC = string.match(new RegExp(`^(${ranges}+?)(([0-9]{2}){2,})([^0-9]|$)`));
|
||||
|
||||
if (untilC) {
|
||||
return (
|
||||
untilC[1] +
|
||||
String.fromCharCode(204) +
|
||||
autoSelectFromC(string.substring(untilC[1].length))
|
||||
);
|
||||
}
|
||||
|
||||
const chars = string.match(new RegExp(`^${ranges}+`))[0];
|
||||
|
||||
if (chars.length === string.length) {
|
||||
return string;
|
||||
}
|
||||
|
||||
return (
|
||||
chars +
|
||||
String.fromCharCode(isA ? 205 : 206) +
|
||||
autoSelectFromAB(string.substring(chars.length), !isA)
|
||||
);
|
||||
}
|
||||
|
||||
// CODE128C
|
||||
function autoSelectFromC(string) {
|
||||
const cMatch = matchSetC(string);
|
||||
const length = cMatch.length;
|
||||
|
||||
if (length === string.length) {
|
||||
return string;
|
||||
}
|
||||
|
||||
string = string.substring(length);
|
||||
|
||||
// Select A/B depending on the longest match
|
||||
const isA = matchSetALength(string) >= matchSetBLength(string);
|
||||
return cMatch + String.fromCharCode(isA ? 206 : 205) + autoSelectFromAB(string, isA);
|
||||
}
|
||||
|
||||
// Detect Code Set (A, B or C) and format the string
|
||||
export default (string) => {
|
||||
let newString;
|
||||
const cLength = matchSetC(string).length;
|
||||
|
||||
// Select 128C if the string start with enough digits
|
||||
if (cLength >= 2) {
|
||||
newString = C_START_CHAR + autoSelectFromC(string);
|
||||
} else {
|
||||
// Select A/B depending on the longest match
|
||||
const isA = matchSetALength(string) > matchSetBLength(string);
|
||||
newString = (isA ? A_START_CHAR : B_START_CHAR) + autoSelectFromAB(string, isA);
|
||||
}
|
||||
|
||||
return newString.replace(
|
||||
/[\xCD\xCE]([^])[\xCD\xCE]/, // Any sequence between 205 and 206 characters
|
||||
(match, char) => String.fromCharCode(203) + char
|
||||
);
|
||||
};
|
||||
71
node_modules/jsbarcode/src/barcodes/CODE128/constants.js
generated
vendored
Normal file
71
node_modules/jsbarcode/src/barcodes/CODE128/constants.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
// constants for internal usage
|
||||
export const SET_A = 0;
|
||||
export const SET_B = 1;
|
||||
export const SET_C = 2;
|
||||
|
||||
// Special characters
|
||||
export const SHIFT = 98;
|
||||
export const START_A = 103;
|
||||
export const START_B = 104;
|
||||
export const START_C = 105;
|
||||
export const MODULO = 103;
|
||||
export const STOP = 106;
|
||||
export const FNC1 = 207;
|
||||
|
||||
// Get set by start code
|
||||
export const SET_BY_CODE = {
|
||||
[START_A]: SET_A,
|
||||
[START_B]: SET_B,
|
||||
[START_C]: SET_C,
|
||||
};
|
||||
|
||||
// Get next set by code
|
||||
export const SWAP = {
|
||||
101: SET_A,
|
||||
100: SET_B,
|
||||
99: SET_C,
|
||||
};
|
||||
|
||||
export const A_START_CHAR = String.fromCharCode(208); // START_A + 105
|
||||
export const B_START_CHAR = String.fromCharCode(209); // START_B + 105
|
||||
export const C_START_CHAR = String.fromCharCode(210); // START_C + 105
|
||||
|
||||
// 128A (Code Set A)
|
||||
// ASCII characters 00 to 95 (0–9, A–Z and control codes), special characters, and FNC 1–4
|
||||
export const A_CHARS = "[\x00-\x5F\xC8-\xCF]";
|
||||
|
||||
// 128B (Code Set B)
|
||||
// ASCII characters 32 to 127 (0–9, A–Z, a–z), special characters, and FNC 1–4
|
||||
export const B_CHARS = "[\x20-\x7F\xC8-\xCF]";
|
||||
|
||||
// 128C (Code Set C)
|
||||
// 00–99 (encodes two digits with a single code point) and FNC1
|
||||
export const C_CHARS = "(\xCF*[0-9]{2}\xCF*)";
|
||||
|
||||
// CODE128 includes 107 symbols:
|
||||
// 103 data symbols, 3 start symbols (A, B and C), and 1 stop symbol (the last one)
|
||||
// Each symbol consist of three black bars (1) and three white spaces (0).
|
||||
export const BARS = [
|
||||
11011001100, 11001101100, 11001100110, 10010011000, 10010001100,
|
||||
10001001100, 10011001000, 10011000100, 10001100100, 11001001000,
|
||||
11001000100, 11000100100, 10110011100, 10011011100, 10011001110,
|
||||
10111001100, 10011101100, 10011100110, 11001110010, 11001011100,
|
||||
11001001110, 11011100100, 11001110100, 11101101110, 11101001100,
|
||||
11100101100, 11100100110, 11101100100, 11100110100, 11100110010,
|
||||
11011011000, 11011000110, 11000110110, 10100011000, 10001011000,
|
||||
10001000110, 10110001000, 10001101000, 10001100010, 11010001000,
|
||||
11000101000, 11000100010, 10110111000, 10110001110, 10001101110,
|
||||
10111011000, 10111000110, 10001110110, 11101110110, 11010001110,
|
||||
11000101110, 11011101000, 11011100010, 11011101110, 11101011000,
|
||||
11101000110, 11100010110, 11101101000, 11101100010, 11100011010,
|
||||
11101111010, 11001000010, 11110001010, 10100110000, 10100001100,
|
||||
10010110000, 10010000110, 10000101100, 10000100110, 10110010000,
|
||||
10110000100, 10011010000, 10011000010, 10000110100, 10000110010,
|
||||
11000010010, 11001010000, 11110111010, 11000010100, 10001111010,
|
||||
10100111100, 10010111100, 10010011110, 10111100100, 10011110100,
|
||||
10011110010, 11110100100, 11110010100, 11110010010, 11011011110,
|
||||
11011110110, 11110110110, 10101111000, 10100011110, 10001011110,
|
||||
10111101000, 10111100010, 11110101000, 11110100010, 10111011110,
|
||||
10111101110, 11101011110, 11110101110, 11010000100, 11010010000,
|
||||
11010011100, 1100011101011
|
||||
];
|
||||
6
node_modules/jsbarcode/src/barcodes/CODE128/index.js
generated
vendored
Normal file
6
node_modules/jsbarcode/src/barcodes/CODE128/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import CODE128 from './CODE128_AUTO.js';
|
||||
import CODE128A from './CODE128A.js';
|
||||
import CODE128B from './CODE128B.js';
|
||||
import CODE128C from './CODE128C.js';
|
||||
|
||||
export {CODE128, CODE128A, CODE128B, CODE128C};
|
||||
105
node_modules/jsbarcode/src/barcodes/CODE39/index.js
generated
vendored
Normal file
105
node_modules/jsbarcode/src/barcodes/CODE39/index.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
// Encoding documentation:
|
||||
// https://en.wikipedia.org/wiki/Code_39#Encoding
|
||||
|
||||
import Barcode from "../Barcode.js";
|
||||
|
||||
class CODE39 extends Barcode {
|
||||
constructor(data, options){
|
||||
data = data.toUpperCase();
|
||||
|
||||
// Calculate mod43 checksum if enabled
|
||||
if(options.mod43){
|
||||
data += getCharacter(mod43checksum(data));
|
||||
}
|
||||
|
||||
super(data, options);
|
||||
}
|
||||
|
||||
encode(){
|
||||
// First character is always a *
|
||||
var result = getEncoding("*");
|
||||
|
||||
// Take every character and add the binary representation to the result
|
||||
for(let i = 0; i < this.data.length; i++){
|
||||
result += getEncoding(this.data[i]) + "0";
|
||||
}
|
||||
|
||||
// Last character is always a *
|
||||
result += getEncoding("*");
|
||||
|
||||
return {
|
||||
data: result,
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
|
||||
valid(){
|
||||
return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/) !== -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// All characters. The position in the array is the (checksum) value
|
||||
var characters = [
|
||||
"0", "1", "2", "3",
|
||||
"4", "5", "6", "7",
|
||||
"8", "9", "A", "B",
|
||||
"C", "D", "E", "F",
|
||||
"G", "H", "I", "J",
|
||||
"K", "L", "M", "N",
|
||||
"O", "P", "Q", "R",
|
||||
"S", "T", "U", "V",
|
||||
"W", "X", "Y", "Z",
|
||||
"-", ".", " ", "$",
|
||||
"/", "+", "%", "*"
|
||||
];
|
||||
|
||||
// The decimal representation of the characters, is converted to the
|
||||
// corresponding binary with the getEncoding function
|
||||
var encodings = [
|
||||
20957, 29783, 23639, 30485,
|
||||
20951, 29813, 23669, 20855,
|
||||
29789, 23645, 29975, 23831,
|
||||
30533, 22295, 30149, 24005,
|
||||
21623, 29981, 23837, 22301,
|
||||
30023, 23879, 30545, 22343,
|
||||
30161, 24017, 21959, 30065,
|
||||
23921, 22385, 29015, 18263,
|
||||
29141, 17879, 29045, 18293,
|
||||
17783, 29021, 18269, 17477,
|
||||
17489, 17681, 20753, 35770
|
||||
];
|
||||
|
||||
// Get the binary representation of a character by converting the encodings
|
||||
// from decimal to binary
|
||||
function getEncoding(character){
|
||||
return getBinary(characterValue(character));
|
||||
}
|
||||
|
||||
function getBinary(characterValue){
|
||||
return encodings[characterValue].toString(2);
|
||||
}
|
||||
|
||||
function getCharacter(characterValue){
|
||||
return characters[characterValue];
|
||||
}
|
||||
|
||||
function characterValue(character){
|
||||
return characters.indexOf(character);
|
||||
}
|
||||
|
||||
function mod43checksum(data){
|
||||
var checksum = 0;
|
||||
for(let i = 0; i < data.length; i++){
|
||||
checksum += characterValue(data[i]);
|
||||
}
|
||||
|
||||
checksum = checksum % 43;
|
||||
return checksum;
|
||||
}
|
||||
|
||||
export {CODE39};
|
||||
72
node_modules/jsbarcode/src/barcodes/EAN_UPC/EAN.js
generated
vendored
Normal file
72
node_modules/jsbarcode/src/barcodes/EAN_UPC/EAN.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
import { SIDE_BIN, MIDDLE_BIN } from './constants';
|
||||
import encode from './encoder';
|
||||
import Barcode from '../Barcode';
|
||||
|
||||
// Base class for EAN8 & EAN13
|
||||
class EAN extends Barcode {
|
||||
|
||||
constructor(data, options) {
|
||||
super(data, options);
|
||||
|
||||
// Make sure the font is not bigger than the space between the guard bars
|
||||
this.fontSize = !options.flat && options.fontSize > options.width * 10
|
||||
? options.width * 10
|
||||
: options.fontSize;
|
||||
|
||||
// Make the guard bars go down half the way of the text
|
||||
this.guardHeight = options.height + this.fontSize / 2 + options.textMargin;
|
||||
}
|
||||
|
||||
encode() {
|
||||
return this.options.flat
|
||||
? this.encodeFlat()
|
||||
: this.encodeGuarded();
|
||||
}
|
||||
|
||||
leftText(from, to) {
|
||||
return this.text.substr(from, to);
|
||||
}
|
||||
|
||||
leftEncode(data, structure) {
|
||||
return encode(data, structure);
|
||||
}
|
||||
|
||||
rightText(from, to) {
|
||||
return this.text.substr(from, to);
|
||||
}
|
||||
|
||||
rightEncode(data, structure) {
|
||||
return encode(data, structure);
|
||||
}
|
||||
|
||||
encodeGuarded() {
|
||||
const textOptions = { fontSize: this.fontSize };
|
||||
const guardOptions = { height: this.guardHeight };
|
||||
|
||||
return [
|
||||
{ data: SIDE_BIN, options: guardOptions },
|
||||
{ data: this.leftEncode(), text: this.leftText(), options: textOptions },
|
||||
{ data: MIDDLE_BIN, options: guardOptions },
|
||||
{ data: this.rightEncode(), text: this.rightText(), options: textOptions },
|
||||
{ data: SIDE_BIN, options: guardOptions },
|
||||
];
|
||||
}
|
||||
|
||||
encodeFlat() {
|
||||
const data = [
|
||||
SIDE_BIN,
|
||||
this.leftEncode(),
|
||||
MIDDLE_BIN,
|
||||
this.rightEncode(),
|
||||
SIDE_BIN
|
||||
];
|
||||
|
||||
return {
|
||||
data: data.join(''),
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default EAN;
|
||||
90
node_modules/jsbarcode/src/barcodes/EAN_UPC/EAN13.js
generated
vendored
Normal file
90
node_modules/jsbarcode/src/barcodes/EAN_UPC/EAN13.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
// Encoding documentation:
|
||||
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Binary_encoding_of_data_digits_into_EAN-13_barcode
|
||||
|
||||
import { EAN13_STRUCTURE } from './constants';
|
||||
import EAN from './EAN';
|
||||
|
||||
// Calculate the checksum digit
|
||||
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
|
||||
const checksum = (number) => {
|
||||
const res = number
|
||||
.substr(0, 12)
|
||||
.split('')
|
||||
.map((n) => +n)
|
||||
.reduce((sum, a, idx) => (
|
||||
idx % 2 ? sum + a * 3 : sum + a
|
||||
), 0);
|
||||
|
||||
return (10 - (res % 10)) % 10;
|
||||
};
|
||||
|
||||
class EAN13 extends EAN {
|
||||
|
||||
constructor(data, options) {
|
||||
// Add checksum if it does not exist
|
||||
if (data.search(/^[0-9]{12}$/) !== -1) {
|
||||
data += checksum(data);
|
||||
}
|
||||
|
||||
super(data, options);
|
||||
|
||||
// Adds a last character to the end of the barcode
|
||||
this.lastChar = options.lastChar;
|
||||
}
|
||||
|
||||
valid() {
|
||||
return (
|
||||
this.data.search(/^[0-9]{13}$/) !== -1 &&
|
||||
+this.data[12] === checksum(this.data)
|
||||
);
|
||||
}
|
||||
|
||||
leftText() {
|
||||
return super.leftText(1, 6);
|
||||
}
|
||||
|
||||
leftEncode() {
|
||||
const data = this.data.substr(1, 6);
|
||||
const structure = EAN13_STRUCTURE[this.data[0]];
|
||||
return super.leftEncode(data, structure);
|
||||
}
|
||||
|
||||
rightText() {
|
||||
return super.rightText(7, 6);
|
||||
}
|
||||
|
||||
rightEncode() {
|
||||
const data = this.data.substr(7, 6);
|
||||
return super.rightEncode(data, 'RRRRRR');
|
||||
}
|
||||
|
||||
// The "standard" way of printing EAN13 barcodes with guard bars
|
||||
encodeGuarded() {
|
||||
const data = super.encodeGuarded();
|
||||
|
||||
// Extend data with left digit & last character
|
||||
if (this.options.displayValue) {
|
||||
data.unshift({
|
||||
data: '000000000000',
|
||||
text: this.text.substr(0, 1),
|
||||
options: { textAlign: 'left', fontSize: this.fontSize }
|
||||
});
|
||||
|
||||
if (this.options.lastChar) {
|
||||
data.push({
|
||||
data: '00'
|
||||
});
|
||||
data.push({
|
||||
data: '00000',
|
||||
text: this.options.lastChar,
|
||||
options: { fontSize: this.fontSize }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default EAN13;
|
||||
30
node_modules/jsbarcode/src/barcodes/EAN_UPC/EAN2.js
generated
vendored
Normal file
30
node_modules/jsbarcode/src/barcodes/EAN_UPC/EAN2.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
// Encoding documentation:
|
||||
// https://en.wikipedia.org/wiki/EAN_2#Encoding
|
||||
|
||||
import { EAN2_STRUCTURE } from './constants';
|
||||
import encode from './encoder';
|
||||
import Barcode from '../Barcode';
|
||||
|
||||
class EAN2 extends Barcode {
|
||||
|
||||
constructor(data, options) {
|
||||
super(data, options);
|
||||
}
|
||||
|
||||
valid() {
|
||||
return this.data.search(/^[0-9]{2}$/) !== -1;
|
||||
}
|
||||
|
||||
encode(){
|
||||
// Choose the structure based on the number mod 4
|
||||
const structure = EAN2_STRUCTURE[parseInt(this.data) % 4];
|
||||
return {
|
||||
// Start bits + Encode the two digits with 01 in between
|
||||
data: '1011' + encode(this.data, structure, '01'),
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default EAN2;
|
||||
40
node_modules/jsbarcode/src/barcodes/EAN_UPC/EAN5.js
generated
vendored
Normal file
40
node_modules/jsbarcode/src/barcodes/EAN_UPC/EAN5.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// Encoding documentation:
|
||||
// https://en.wikipedia.org/wiki/EAN_5#Encoding
|
||||
|
||||
import { EAN5_STRUCTURE } from './constants';
|
||||
import encode from './encoder';
|
||||
import Barcode from '../Barcode';
|
||||
|
||||
const checksum = (data) => {
|
||||
const result = data
|
||||
.split('')
|
||||
.map(n => +n)
|
||||
.reduce((sum, a, idx) => {
|
||||
return idx % 2
|
||||
? sum + a * 9
|
||||
: sum + a * 3;
|
||||
}, 0);
|
||||
return result % 10;
|
||||
};
|
||||
|
||||
class EAN5 extends Barcode {
|
||||
|
||||
constructor(data, options) {
|
||||
super(data, options);
|
||||
}
|
||||
|
||||
valid() {
|
||||
return this.data.search(/^[0-9]{5}$/) !== -1;
|
||||
}
|
||||
|
||||
encode() {
|
||||
const structure = EAN5_STRUCTURE[checksum(this.data)];
|
||||
return {
|
||||
data: '1011' + encode(this.data, structure, '01'),
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default EAN5;
|
||||
57
node_modules/jsbarcode/src/barcodes/EAN_UPC/EAN8.js
generated
vendored
Normal file
57
node_modules/jsbarcode/src/barcodes/EAN_UPC/EAN8.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
// Encoding documentation:
|
||||
// http://www.barcodeisland.com/ean8.phtml
|
||||
|
||||
import EAN from './EAN';
|
||||
|
||||
// Calculate the checksum digit
|
||||
const checksum = (number) => {
|
||||
const res = number
|
||||
.substr(0, 7)
|
||||
.split('')
|
||||
.map((n) => +n)
|
||||
.reduce((sum, a, idx) => (
|
||||
idx % 2 ? sum + a : sum + a * 3
|
||||
), 0);
|
||||
|
||||
return (10 - (res % 10)) % 10;
|
||||
};
|
||||
|
||||
class EAN8 extends EAN {
|
||||
|
||||
constructor(data, options) {
|
||||
// Add checksum if it does not exist
|
||||
if (data.search(/^[0-9]{7}$/) !== -1) {
|
||||
data += checksum(data);
|
||||
}
|
||||
|
||||
super(data, options);
|
||||
}
|
||||
|
||||
valid() {
|
||||
return (
|
||||
this.data.search(/^[0-9]{8}$/) !== -1 &&
|
||||
+this.data[7] === checksum(this.data)
|
||||
);
|
||||
}
|
||||
|
||||
leftText() {
|
||||
return super.leftText(0, 4);
|
||||
}
|
||||
|
||||
leftEncode() {
|
||||
const data = this.data.substr(0, 4);
|
||||
return super.leftEncode(data, 'LLLL');
|
||||
}
|
||||
|
||||
rightText() {
|
||||
return super.rightText(4, 4);
|
||||
}
|
||||
|
||||
rightEncode() {
|
||||
const data = this.data.substr(4, 4);
|
||||
return super.rightEncode(data, 'RRRR');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default EAN8;
|
||||
132
node_modules/jsbarcode/src/barcodes/EAN_UPC/UPC.js
generated
vendored
Normal file
132
node_modules/jsbarcode/src/barcodes/EAN_UPC/UPC.js
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
// Encoding documentation:
|
||||
// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
|
||||
|
||||
import encode from './encoder';
|
||||
import Barcode from "../Barcode.js";
|
||||
|
||||
class UPC extends Barcode{
|
||||
constructor(data, options){
|
||||
// Add checksum if it does not exist
|
||||
if(data.search(/^[0-9]{11}$/) !== -1){
|
||||
data += checksum(data);
|
||||
}
|
||||
|
||||
super(data, options);
|
||||
|
||||
this.displayValue = options.displayValue;
|
||||
|
||||
// Make sure the font is not bigger than the space between the guard bars
|
||||
if(options.fontSize > options.width * 10){
|
||||
this.fontSize = options.width * 10;
|
||||
}
|
||||
else{
|
||||
this.fontSize = options.fontSize;
|
||||
}
|
||||
|
||||
// Make the guard bars go down half the way of the text
|
||||
this.guardHeight = options.height + this.fontSize / 2 + options.textMargin;
|
||||
}
|
||||
|
||||
valid(){
|
||||
return this.data.search(/^[0-9]{12}$/) !== -1 &&
|
||||
this.data[11] == checksum(this.data);
|
||||
}
|
||||
|
||||
encode(){
|
||||
if(this.options.flat){
|
||||
return this.flatEncoding();
|
||||
}
|
||||
else{
|
||||
return this.guardedEncoding();
|
||||
}
|
||||
}
|
||||
|
||||
flatEncoding(){
|
||||
var result = "";
|
||||
|
||||
result += "101";
|
||||
result += encode(this.data.substr(0, 6), "LLLLLL");
|
||||
result += "01010";
|
||||
result += encode(this.data.substr(6, 6), "RRRRRR");
|
||||
result += "101";
|
||||
|
||||
return {
|
||||
data: result,
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
|
||||
guardedEncoding(){
|
||||
var result = [];
|
||||
|
||||
// Add the first digit
|
||||
if(this.displayValue){
|
||||
result.push({
|
||||
data: "00000000",
|
||||
text: this.text.substr(0, 1),
|
||||
options: {textAlign: "left", fontSize: this.fontSize}
|
||||
});
|
||||
}
|
||||
|
||||
// Add the guard bars
|
||||
result.push({
|
||||
data: "101" + encode(this.data[0], "L"),
|
||||
options: {height: this.guardHeight}
|
||||
});
|
||||
|
||||
// Add the left side
|
||||
result.push({
|
||||
data: encode(this.data.substr(1, 5), "LLLLL"),
|
||||
text: this.text.substr(1, 5),
|
||||
options: {fontSize: this.fontSize}
|
||||
});
|
||||
|
||||
// Add the middle bits
|
||||
result.push({
|
||||
data: "01010",
|
||||
options: {height: this.guardHeight}
|
||||
});
|
||||
|
||||
// Add the right side
|
||||
result.push({
|
||||
data: encode(this.data.substr(6, 5), "RRRRR"),
|
||||
text: this.text.substr(6, 5),
|
||||
options: {fontSize: this.fontSize}
|
||||
});
|
||||
|
||||
// Add the end bits
|
||||
result.push({
|
||||
data: encode(this.data[11], "R") + "101",
|
||||
options: {height: this.guardHeight}
|
||||
});
|
||||
|
||||
// Add the last digit
|
||||
if(this.displayValue){
|
||||
result.push({
|
||||
data: "00000000",
|
||||
text: this.text.substr(11, 1),
|
||||
options: {textAlign: "right", fontSize: this.fontSize}
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// Calulate the checksum digit
|
||||
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
|
||||
export function checksum(number){
|
||||
var result = 0;
|
||||
|
||||
var i;
|
||||
for(i = 1; i < 11; i += 2){
|
||||
result += parseInt(number[i]);
|
||||
}
|
||||
for(i = 0; i < 11; i += 2){
|
||||
result += parseInt(number[i]) * 3;
|
||||
}
|
||||
|
||||
return (10 - (result % 10)) % 10;
|
||||
}
|
||||
|
||||
export default UPC;
|
||||
177
node_modules/jsbarcode/src/barcodes/EAN_UPC/UPCE.js
generated
vendored
Normal file
177
node_modules/jsbarcode/src/barcodes/EAN_UPC/UPCE.js
generated
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
// Encoding documentation:
|
||||
// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
|
||||
//
|
||||
// UPC-E documentation:
|
||||
// https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E
|
||||
|
||||
import encode from './encoder';
|
||||
import Barcode from "../Barcode.js";
|
||||
import { checksum } from './UPC.js';
|
||||
|
||||
const EXPANSIONS = [
|
||||
"XX00000XXX",
|
||||
"XX10000XXX",
|
||||
"XX20000XXX",
|
||||
"XXX00000XX",
|
||||
"XXXX00000X",
|
||||
"XXXXX00005",
|
||||
"XXXXX00006",
|
||||
"XXXXX00007",
|
||||
"XXXXX00008",
|
||||
"XXXXX00009"
|
||||
];
|
||||
|
||||
const PARITIES = [
|
||||
["EEEOOO", "OOOEEE"],
|
||||
["EEOEOO", "OOEOEE"],
|
||||
["EEOOEO", "OOEEOE"],
|
||||
["EEOOOE", "OOEEEO"],
|
||||
["EOEEOO", "OEOOEE"],
|
||||
["EOOEEO", "OEEOOE"],
|
||||
["EOOOEE", "OEEEOO"],
|
||||
["EOEOEO", "OEOEOE"],
|
||||
["EOEOOE", "OEOEEO"],
|
||||
["EOOEOE", "OEEOEO"]
|
||||
];
|
||||
|
||||
class UPCE extends Barcode{
|
||||
constructor(data, options){
|
||||
// Code may be 6 or 8 digits;
|
||||
// A 7 digit code is ambiguous as to whether the extra digit
|
||||
// is a UPC-A check or number system digit.
|
||||
super(data, options);
|
||||
this.isValid = false;
|
||||
if(data.search(/^[0-9]{6}$/) !== -1){
|
||||
this.middleDigits = data;
|
||||
this.upcA = expandToUPCA(data, "0");
|
||||
this.text = options.text ||
|
||||
`${this.upcA[0]}${data}${this.upcA[this.upcA.length - 1]}`;
|
||||
this.isValid = true;
|
||||
}
|
||||
else if(data.search(/^[01][0-9]{7}$/) !== -1){
|
||||
this.middleDigits = data.substring(1, data.length - 1);
|
||||
this.upcA = expandToUPCA(this.middleDigits, data[0]);
|
||||
|
||||
if(this.upcA[this.upcA.length - 1] === data[data.length - 1]){
|
||||
this.isValid = true;
|
||||
}
|
||||
else{
|
||||
// checksum mismatch
|
||||
return;
|
||||
}
|
||||
}
|
||||
else{
|
||||
return;
|
||||
}
|
||||
|
||||
this.displayValue = options.displayValue;
|
||||
|
||||
// Make sure the font is not bigger than the space between the guard bars
|
||||
if(options.fontSize > options.width * 10){
|
||||
this.fontSize = options.width * 10;
|
||||
}
|
||||
else{
|
||||
this.fontSize = options.fontSize;
|
||||
}
|
||||
|
||||
// Make the guard bars go down half the way of the text
|
||||
this.guardHeight = options.height + this.fontSize / 2 + options.textMargin;
|
||||
}
|
||||
|
||||
valid(){
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
encode(){
|
||||
if(this.options.flat){
|
||||
return this.flatEncoding();
|
||||
}
|
||||
else{
|
||||
return this.guardedEncoding();
|
||||
}
|
||||
}
|
||||
|
||||
flatEncoding(){
|
||||
var result = "";
|
||||
|
||||
result += "101";
|
||||
result += this.encodeMiddleDigits();
|
||||
result += "010101";
|
||||
|
||||
return {
|
||||
data: result,
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
|
||||
guardedEncoding(){
|
||||
var result = [];
|
||||
|
||||
// Add the UPC-A number system digit beneath the quiet zone
|
||||
if(this.displayValue){
|
||||
result.push({
|
||||
data: "00000000",
|
||||
text: this.text[0],
|
||||
options: {textAlign: "left", fontSize: this.fontSize}
|
||||
});
|
||||
}
|
||||
|
||||
// Add the guard bars
|
||||
result.push({
|
||||
data: "101",
|
||||
options: {height: this.guardHeight}
|
||||
});
|
||||
|
||||
// Add the 6 UPC-E digits
|
||||
result.push({
|
||||
data: this.encodeMiddleDigits(),
|
||||
text: this.text.substring(1, 7),
|
||||
options: {fontSize: this.fontSize}
|
||||
});
|
||||
|
||||
// Add the end bits
|
||||
result.push({
|
||||
data: "010101",
|
||||
options: {height: this.guardHeight}
|
||||
});
|
||||
|
||||
// Add the UPC-A check digit beneath the quiet zone
|
||||
if(this.displayValue){
|
||||
result.push({
|
||||
data: "00000000",
|
||||
text: this.text[7],
|
||||
options: {textAlign: "right", fontSize: this.fontSize}
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
encodeMiddleDigits() {
|
||||
const numberSystem = this.upcA[0];
|
||||
const checkDigit = this.upcA[this.upcA.length - 1];
|
||||
const parity = PARITIES[parseInt(checkDigit)][parseInt(numberSystem)];
|
||||
return encode(this.middleDigits, parity);
|
||||
}
|
||||
}
|
||||
|
||||
function expandToUPCA(middleDigits, numberSystem) {
|
||||
const lastUpcE = parseInt(middleDigits[middleDigits.length - 1]);
|
||||
const expansion = EXPANSIONS[lastUpcE];
|
||||
|
||||
let result = "";
|
||||
let digitIndex = 0;
|
||||
for(let i = 0; i < expansion.length; i++) {
|
||||
let c = expansion[i];
|
||||
if (c === 'X') {
|
||||
result += middleDigits[digitIndex++];
|
||||
} else {
|
||||
result += c;
|
||||
}
|
||||
}
|
||||
|
||||
result = `${numberSystem}${result}`;
|
||||
return `${result}${checksum(result)}`;
|
||||
}
|
||||
|
||||
export default UPCE;
|
||||
41
node_modules/jsbarcode/src/barcodes/EAN_UPC/constants.js
generated
vendored
Normal file
41
node_modules/jsbarcode/src/barcodes/EAN_UPC/constants.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// Standard start end and middle bits
|
||||
export const SIDE_BIN = '101';
|
||||
export const MIDDLE_BIN = '01010';
|
||||
|
||||
export const BINARIES = {
|
||||
'L': [ // The L (left) type of encoding
|
||||
'0001101', '0011001', '0010011', '0111101', '0100011',
|
||||
'0110001', '0101111', '0111011', '0110111', '0001011'
|
||||
],
|
||||
'G': [ // The G type of encoding
|
||||
'0100111', '0110011', '0011011', '0100001', '0011101',
|
||||
'0111001', '0000101', '0010001', '0001001', '0010111'
|
||||
],
|
||||
'R': [ // The R (right) type of encoding
|
||||
'1110010', '1100110', '1101100', '1000010', '1011100',
|
||||
'1001110', '1010000', '1000100', '1001000', '1110100'
|
||||
],
|
||||
'O': [ // The O (odd) encoding for UPC-E
|
||||
'0001101', '0011001', '0010011', '0111101', '0100011',
|
||||
'0110001', '0101111', '0111011', '0110111', '0001011'
|
||||
],
|
||||
'E': [ // The E (even) encoding for UPC-E
|
||||
'0100111', '0110011', '0011011', '0100001', '0011101',
|
||||
'0111001', '0000101', '0010001', '0001001', '0010111'
|
||||
]
|
||||
};
|
||||
|
||||
// Define the EAN-2 structure
|
||||
export const EAN2_STRUCTURE = ['LL', 'LG', 'GL', 'GG'];
|
||||
|
||||
// Define the EAN-5 structure
|
||||
export const EAN5_STRUCTURE = [
|
||||
'GGLLL', 'GLGLL', 'GLLGL', 'GLLLG', 'LGGLL',
|
||||
'LLGGL', 'LLLGG', 'LGLGL', 'LGLLG', 'LLGLG'
|
||||
];
|
||||
|
||||
// Define the EAN-13 structure
|
||||
export const EAN13_STRUCTURE = [
|
||||
'LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG',
|
||||
'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL'
|
||||
];
|
||||
20
node_modules/jsbarcode/src/barcodes/EAN_UPC/encoder.js
generated
vendored
Normal file
20
node_modules/jsbarcode/src/barcodes/EAN_UPC/encoder.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import { BINARIES } from './constants';
|
||||
|
||||
// Encode data string
|
||||
const encode = (data, structure, separator) => {
|
||||
let encoded = data
|
||||
.split('')
|
||||
.map((val, idx) => BINARIES[structure[idx]])
|
||||
.map((val, idx) => val ? val[data[idx]] : '');
|
||||
|
||||
if (separator) {
|
||||
const last = data.length - 1;
|
||||
encoded = encoded.map((val, idx) => (
|
||||
idx < last ? val + separator : val
|
||||
));
|
||||
}
|
||||
|
||||
return encoded.join('');
|
||||
};
|
||||
|
||||
export default encode;
|
||||
8
node_modules/jsbarcode/src/barcodes/EAN_UPC/index.js
generated
vendored
Normal file
8
node_modules/jsbarcode/src/barcodes/EAN_UPC/index.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import EAN13 from './EAN13.js';
|
||||
import EAN8 from './EAN8.js';
|
||||
import EAN5 from './EAN5.js';
|
||||
import EAN2 from './EAN2.js';
|
||||
import UPC from './UPC.js';
|
||||
import UPCE from './UPCE.js';
|
||||
|
||||
export {EAN13, EAN8, EAN5, EAN2, UPC, UPCE};
|
||||
22
node_modules/jsbarcode/src/barcodes/GenericBarcode/index.js
generated
vendored
Normal file
22
node_modules/jsbarcode/src/barcodes/GenericBarcode/index.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import Barcode from "../Barcode.js";
|
||||
|
||||
class GenericBarcode extends Barcode{
|
||||
constructor(data, options){
|
||||
super(data, options); // Sets this.data and this.text
|
||||
}
|
||||
|
||||
// Return the corresponding binary numbers for the data provided
|
||||
encode(){
|
||||
return {
|
||||
data: "10101010101010101010101010101010101010101",
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
|
||||
// Resturn true/false if the string provided is valid for this encoder
|
||||
valid(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export {GenericBarcode};
|
||||
37
node_modules/jsbarcode/src/barcodes/ITF/ITF.js
generated
vendored
Normal file
37
node_modules/jsbarcode/src/barcodes/ITF/ITF.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import { START_BIN, END_BIN, BINARIES } from './constants';
|
||||
import Barcode from '../Barcode';
|
||||
|
||||
class ITF extends Barcode {
|
||||
|
||||
valid() {
|
||||
return this.data.search(/^([0-9]{2})+$/) !== -1;
|
||||
}
|
||||
|
||||
encode() {
|
||||
// Calculate all the digit pairs
|
||||
const encoded = this.data
|
||||
.match(/.{2}/g)
|
||||
.map(pair => this.encodePair(pair))
|
||||
.join('');
|
||||
|
||||
return {
|
||||
data: START_BIN + encoded + END_BIN,
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
|
||||
// Calculate the data of a number pair
|
||||
encodePair(pair) {
|
||||
const second = BINARIES[pair[1]];
|
||||
|
||||
return BINARIES[pair[0]]
|
||||
.split('')
|
||||
.map((first, idx) => (
|
||||
(first === '1' ? '111' : '1') +
|
||||
(second[idx] === '1' ? '000' : '0')
|
||||
))
|
||||
.join('');
|
||||
}
|
||||
}
|
||||
|
||||
export default ITF;
|
||||
33
node_modules/jsbarcode/src/barcodes/ITF/ITF14.js
generated
vendored
Normal file
33
node_modules/jsbarcode/src/barcodes/ITF/ITF14.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import ITF from './ITF';
|
||||
|
||||
// Calculate the checksum digit
|
||||
const checksum = (data) => {
|
||||
const res = data
|
||||
.substr(0, 13)
|
||||
.split('')
|
||||
.map(num => parseInt(num, 10))
|
||||
.reduce((sum, n, idx) => sum + (n * (3 - (idx % 2) * 2)), 0);
|
||||
|
||||
return Math.ceil(res / 10) * 10 - res;
|
||||
};
|
||||
|
||||
class ITF14 extends ITF {
|
||||
|
||||
constructor(data, options) {
|
||||
// Add checksum if it does not exist
|
||||
if (data.search(/^[0-9]{13}$/) !== -1) {
|
||||
data += checksum(data);
|
||||
}
|
||||
super(data, options);
|
||||
}
|
||||
|
||||
valid() {
|
||||
return (
|
||||
this.data.search(/^[0-9]{14}$/) !== -1 &&
|
||||
+this.data[13] === checksum(this.data)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default ITF14;
|
||||
7
node_modules/jsbarcode/src/barcodes/ITF/constants.js
generated
vendored
Normal file
7
node_modules/jsbarcode/src/barcodes/ITF/constants.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export const START_BIN = '1010';
|
||||
export const END_BIN = '11101';
|
||||
|
||||
export const BINARIES = [
|
||||
'00110', '10001', '01001', '11000', '00101',
|
||||
'10100', '01100', '00011', '10010', '01010',
|
||||
];
|
||||
4
node_modules/jsbarcode/src/barcodes/ITF/index.js
generated
vendored
Normal file
4
node_modules/jsbarcode/src/barcodes/ITF/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import ITF from './ITF';
|
||||
import ITF14 from './ITF14';
|
||||
|
||||
export { ITF, ITF14 };
|
||||
48
node_modules/jsbarcode/src/barcodes/MSI/MSI.js
generated
vendored
Normal file
48
node_modules/jsbarcode/src/barcodes/MSI/MSI.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
// Encoding documentation
|
||||
// https://en.wikipedia.org/wiki/MSI_Barcode#Character_set_and_binary_lookup
|
||||
|
||||
import Barcode from "../Barcode.js";
|
||||
|
||||
class MSI extends Barcode{
|
||||
constructor(data, options){
|
||||
super(data, options);
|
||||
}
|
||||
|
||||
encode(){
|
||||
// Start bits
|
||||
var ret = "110";
|
||||
|
||||
for(var i = 0; i < this.data.length; i++){
|
||||
// Convert the character to binary (always 4 binary digits)
|
||||
var digit = parseInt(this.data[i]);
|
||||
var bin = digit.toString(2);
|
||||
bin = addZeroes(bin, 4 - bin.length);
|
||||
|
||||
// Add 100 for every zero and 110 for every 1
|
||||
for(var b = 0; b < bin.length; b++){
|
||||
ret += bin[b] == "0" ? "100" : "110";
|
||||
}
|
||||
}
|
||||
|
||||
// End bits
|
||||
ret += "1001";
|
||||
|
||||
return {
|
||||
data: ret,
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
|
||||
valid(){
|
||||
return this.data.search(/^[0-9]+$/) !== -1;
|
||||
}
|
||||
}
|
||||
|
||||
function addZeroes(number, n){
|
||||
for(var i = 0; i < n; i++){
|
||||
number = "0" + number;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
export default MSI;
|
||||
10
node_modules/jsbarcode/src/barcodes/MSI/MSI10.js
generated
vendored
Normal file
10
node_modules/jsbarcode/src/barcodes/MSI/MSI10.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import MSI from './MSI.js';
|
||||
import {mod10} from './checksums.js';
|
||||
|
||||
class MSI10 extends MSI{
|
||||
constructor(data, options){
|
||||
super(data + mod10(data), options);
|
||||
}
|
||||
}
|
||||
|
||||
export default MSI10;
|
||||
12
node_modules/jsbarcode/src/barcodes/MSI/MSI1010.js
generated
vendored
Normal file
12
node_modules/jsbarcode/src/barcodes/MSI/MSI1010.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import MSI from './MSI.js';
|
||||
import {mod10} from './checksums.js';
|
||||
|
||||
class MSI1010 extends MSI{
|
||||
constructor(data, options){
|
||||
data += mod10(data);
|
||||
data += mod10(data);
|
||||
super(data, options);
|
||||
}
|
||||
}
|
||||
|
||||
export default MSI1010;
|
||||
10
node_modules/jsbarcode/src/barcodes/MSI/MSI11.js
generated
vendored
Normal file
10
node_modules/jsbarcode/src/barcodes/MSI/MSI11.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import MSI from './MSI.js';
|
||||
import {mod11} from './checksums.js';
|
||||
|
||||
class MSI11 extends MSI{
|
||||
constructor(data, options){
|
||||
super(data + mod11(data), options);
|
||||
}
|
||||
}
|
||||
|
||||
export default MSI11;
|
||||
12
node_modules/jsbarcode/src/barcodes/MSI/MSI1110.js
generated
vendored
Normal file
12
node_modules/jsbarcode/src/barcodes/MSI/MSI1110.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import MSI from './MSI.js';
|
||||
import {mod10, mod11} from './checksums.js';
|
||||
|
||||
class MSI1110 extends MSI{
|
||||
constructor(data, options){
|
||||
data += mod11(data);
|
||||
data += mod10(data);
|
||||
super(data, options);
|
||||
}
|
||||
}
|
||||
|
||||
export default MSI1110;
|
||||
23
node_modules/jsbarcode/src/barcodes/MSI/checksums.js
generated
vendored
Normal file
23
node_modules/jsbarcode/src/barcodes/MSI/checksums.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
export function mod10(number){
|
||||
var sum = 0;
|
||||
for(var i = 0; i < number.length; i++){
|
||||
var n = parseInt(number[i]);
|
||||
if((i + number.length) % 2 === 0){
|
||||
sum += n;
|
||||
}
|
||||
else{
|
||||
sum += (n * 2) % 10 + Math.floor((n * 2) / 10);
|
||||
}
|
||||
}
|
||||
return (10 - (sum % 10)) % 10;
|
||||
}
|
||||
|
||||
export function mod11(number){
|
||||
var sum = 0;
|
||||
var weights = [2, 3, 4, 5, 6, 7];
|
||||
for(var i = 0; i < number.length; i++){
|
||||
var n = parseInt(number[number.length - 1 - i]);
|
||||
sum += weights[i % weights.length] * n;
|
||||
}
|
||||
return (11 - (sum % 11)) % 11;
|
||||
}
|
||||
7
node_modules/jsbarcode/src/barcodes/MSI/index.js
generated
vendored
Normal file
7
node_modules/jsbarcode/src/barcodes/MSI/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import MSI from './MSI.js';
|
||||
import MSI10 from './MSI10.js';
|
||||
import MSI11 from './MSI11.js';
|
||||
import MSI1010 from './MSI1010.js';
|
||||
import MSI1110 from './MSI1110.js';
|
||||
|
||||
export {MSI, MSI10, MSI11, MSI1010, MSI1110};
|
||||
63
node_modules/jsbarcode/src/barcodes/codabar/index.js
generated
vendored
Normal file
63
node_modules/jsbarcode/src/barcodes/codabar/index.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// Encoding specification:
|
||||
// http://www.barcodeisland.com/codabar.phtml
|
||||
|
||||
import Barcode from "../Barcode.js";
|
||||
|
||||
class codabar extends Barcode{
|
||||
constructor(data, options){
|
||||
if (data.search(/^[0-9\-\$\:\.\+\/]+$/) === 0) {
|
||||
data = "A" + data + "A";
|
||||
}
|
||||
|
||||
super(data.toUpperCase(), options);
|
||||
|
||||
this.text = this.options.text || this.text.replace(/[A-D]/g, '');
|
||||
}
|
||||
|
||||
valid(){
|
||||
return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/) !== -1;
|
||||
}
|
||||
|
||||
encode(){
|
||||
var result = [];
|
||||
var encodings = this.getEncodings();
|
||||
for(var i = 0; i < this.data.length; i++){
|
||||
result.push(encodings[this.data.charAt(i)]);
|
||||
// for all characters except the last, append a narrow-space ("0")
|
||||
if (i !== this.data.length - 1) {
|
||||
result.push("0");
|
||||
}
|
||||
}
|
||||
return {
|
||||
text: this.text,
|
||||
data: result.join('')
|
||||
};
|
||||
}
|
||||
|
||||
getEncodings(){
|
||||
return {
|
||||
"0": "101010011",
|
||||
"1": "101011001",
|
||||
"2": "101001011",
|
||||
"3": "110010101",
|
||||
"4": "101101001",
|
||||
"5": "110101001",
|
||||
"6": "100101011",
|
||||
"7": "100101101",
|
||||
"8": "100110101",
|
||||
"9": "110100101",
|
||||
"-": "101001101",
|
||||
"$": "101100101",
|
||||
":": "1101011011",
|
||||
"/": "1101101011",
|
||||
".": "1101101101",
|
||||
"+": "1011011011",
|
||||
"A": "1011001001",
|
||||
"B": "1001001011",
|
||||
"C": "1010010011",
|
||||
"D": "1010011001"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export {codabar};
|
||||
20
node_modules/jsbarcode/src/barcodes/index.js
generated
vendored
Normal file
20
node_modules/jsbarcode/src/barcodes/index.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import {CODE39} from './CODE39/';
|
||||
import {CODE128, CODE128A, CODE128B, CODE128C} from './CODE128/';
|
||||
import {EAN13, EAN8, EAN5, EAN2, UPC, UPCE} from './EAN_UPC/';
|
||||
import {ITF, ITF14} from './ITF/';
|
||||
import {MSI, MSI10, MSI11, MSI1010, MSI1110} from './MSI/';
|
||||
import {pharmacode} from './pharmacode/';
|
||||
import {codabar} from './codabar';
|
||||
import {GenericBarcode} from './GenericBarcode/';
|
||||
|
||||
export default {
|
||||
CODE39,
|
||||
CODE128, CODE128A, CODE128B, CODE128C,
|
||||
EAN13, EAN8, EAN5, EAN2, UPC, UPCE,
|
||||
ITF14,
|
||||
ITF,
|
||||
MSI, MSI10, MSI11, MSI1010, MSI1110,
|
||||
pharmacode,
|
||||
codabar,
|
||||
GenericBarcode
|
||||
};
|
||||
43
node_modules/jsbarcode/src/barcodes/pharmacode/index.js
generated
vendored
Normal file
43
node_modules/jsbarcode/src/barcodes/pharmacode/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// Encoding documentation
|
||||
// http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf
|
||||
|
||||
import Barcode from "../Barcode.js";
|
||||
|
||||
class pharmacode extends Barcode{
|
||||
constructor(data, options){
|
||||
super(data, options);
|
||||
this.number = parseInt(data, 10);
|
||||
}
|
||||
|
||||
encode(){
|
||||
var z = this.number;
|
||||
var result = "";
|
||||
|
||||
// http://i.imgur.com/RMm4UDJ.png
|
||||
// (source: http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf, page: 34)
|
||||
while(!isNaN(z) && z != 0){
|
||||
if(z % 2 === 0){ // Even
|
||||
result = "11100" + result;
|
||||
z = (z - 2) / 2;
|
||||
}
|
||||
else{ // Odd
|
||||
result = "100" + result;
|
||||
z = (z - 1) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the two last zeroes
|
||||
result = result.slice(0, -2);
|
||||
|
||||
return {
|
||||
data: result,
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
|
||||
valid(){
|
||||
return this.number >= 3 && this.number <= 131070;
|
||||
}
|
||||
}
|
||||
|
||||
export {pharmacode};
|
||||
39
node_modules/jsbarcode/src/exceptions/ErrorHandler.js
generated
vendored
Normal file
39
node_modules/jsbarcode/src/exceptions/ErrorHandler.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/*eslint no-console: 0 */
|
||||
|
||||
class ErrorHandler{
|
||||
constructor(api){
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
handleCatch(e){
|
||||
// If babel supported extending of Error in a correct way instanceof would be used here
|
||||
if(e.name === "InvalidInputException"){
|
||||
if(this.api._options.valid !== this.api._defaults.valid){
|
||||
this.api._options.valid(false);
|
||||
}
|
||||
else{
|
||||
throw e.message;
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw e;
|
||||
}
|
||||
|
||||
this.api.render = function(){};
|
||||
}
|
||||
|
||||
wrapBarcodeCall(func){
|
||||
try{
|
||||
var result = func(...arguments);
|
||||
this.api._options.valid(true);
|
||||
return result;
|
||||
}
|
||||
catch(e){
|
||||
this.handleCatch(e);
|
||||
|
||||
return this.api;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default ErrorHandler;
|
||||
29
node_modules/jsbarcode/src/exceptions/exceptions.js
generated
vendored
Normal file
29
node_modules/jsbarcode/src/exceptions/exceptions.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
class InvalidInputException extends Error{
|
||||
constructor(symbology, input) {
|
||||
super();
|
||||
this.name = "InvalidInputException";
|
||||
|
||||
this.symbology = symbology;
|
||||
this.input = input;
|
||||
|
||||
this.message = '"' + this.input + '" is not a valid input for ' + this.symbology;
|
||||
}
|
||||
}
|
||||
|
||||
class InvalidElementException extends Error{
|
||||
constructor() {
|
||||
super();
|
||||
this.name = "InvalidElementException";
|
||||
this.message = "Not supported type to render on";
|
||||
}
|
||||
}
|
||||
|
||||
class NoElementException extends Error{
|
||||
constructor() {
|
||||
super();
|
||||
this.name = "NoElementException";
|
||||
this.message = "No element to render on.";
|
||||
}
|
||||
}
|
||||
|
||||
export {InvalidInputException, InvalidElementException, NoElementException};
|
||||
11
node_modules/jsbarcode/src/help/fixOptions.js
generated
vendored
Normal file
11
node_modules/jsbarcode/src/help/fixOptions.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export default fixOptions;
|
||||
|
||||
function fixOptions(options){
|
||||
// Fix the margins
|
||||
options.marginTop = options.marginTop || options.margin;
|
||||
options.marginBottom = options.marginBottom || options.margin;
|
||||
options.marginRight = options.marginRight || options.margin;
|
||||
options.marginLeft = options.marginLeft || options.margin;
|
||||
|
||||
return options;
|
||||
}
|
||||
28
node_modules/jsbarcode/src/help/getOptionsFromElement.js
generated
vendored
Normal file
28
node_modules/jsbarcode/src/help/getOptionsFromElement.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import optionsFromStrings from "./optionsFromStrings.js";
|
||||
import defaults from "../options/defaults.js";
|
||||
|
||||
function getOptionsFromElement(element){
|
||||
var options = {};
|
||||
for(var property in defaults){
|
||||
if(defaults.hasOwnProperty(property)){
|
||||
// jsbarcode-*
|
||||
if(element.hasAttribute("jsbarcode-" + property.toLowerCase())){
|
||||
options[property] = element.getAttribute("jsbarcode-" + property.toLowerCase());
|
||||
}
|
||||
|
||||
// data-*
|
||||
if(element.hasAttribute("data-" + property.toLowerCase())){
|
||||
options[property] = element.getAttribute("data-" + property.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
options["value"] = element.getAttribute("jsbarcode-value") || element.getAttribute("data-value");
|
||||
|
||||
// Since all atributes are string they need to be converted to integers
|
||||
options = optionsFromStrings(options);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
export default getOptionsFromElement;
|
||||
102
node_modules/jsbarcode/src/help/getRenderProperties.js
generated
vendored
Normal file
102
node_modules/jsbarcode/src/help/getRenderProperties.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/* global HTMLImageElement */
|
||||
/* global HTMLCanvasElement */
|
||||
/* global SVGElement */
|
||||
|
||||
import getOptionsFromElement from "./getOptionsFromElement.js";
|
||||
import renderers from "../renderers";
|
||||
|
||||
import {InvalidElementException} from "../exceptions/exceptions.js";
|
||||
|
||||
// Takes an element and returns an object with information about how
|
||||
// it should be rendered
|
||||
// This could also return an array with these objects
|
||||
// {
|
||||
// element: The element that the renderer should draw on
|
||||
// renderer: The name of the renderer
|
||||
// afterRender (optional): If something has to done after the renderer
|
||||
// completed, calls afterRender (function)
|
||||
// options (optional): Options that can be defined in the element
|
||||
// }
|
||||
|
||||
function getRenderProperties(element){
|
||||
// If the element is a string, query select call again
|
||||
if(typeof element === "string"){
|
||||
return querySelectedRenderProperties(element);
|
||||
}
|
||||
// If element is array. Recursivly call with every object in the array
|
||||
else if(Array.isArray(element)){
|
||||
var returnArray = [];
|
||||
for(let i = 0; i < element.length; i++){
|
||||
returnArray.push(getRenderProperties(element[i]));
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
// If element, render on canvas and set the uri as src
|
||||
else if(typeof HTMLCanvasElement !== 'undefined' && element instanceof HTMLImageElement){
|
||||
return newCanvasRenderProperties(element);
|
||||
}
|
||||
// If SVG
|
||||
else if(
|
||||
(element && element.nodeName && element.nodeName.toLowerCase() === 'svg') ||
|
||||
(typeof SVGElement !== 'undefined' && element instanceof SVGElement)
|
||||
){
|
||||
return {
|
||||
element: element,
|
||||
options: getOptionsFromElement(element),
|
||||
renderer: renderers.SVGRenderer
|
||||
};
|
||||
}
|
||||
// If canvas (in browser)
|
||||
else if(typeof HTMLCanvasElement !== 'undefined' && element instanceof HTMLCanvasElement){
|
||||
return {
|
||||
element: element,
|
||||
options: getOptionsFromElement(element),
|
||||
renderer: renderers.CanvasRenderer
|
||||
};
|
||||
}
|
||||
// If canvas (in node)
|
||||
else if(element && element.getContext){
|
||||
return {
|
||||
element: element,
|
||||
renderer: renderers.CanvasRenderer
|
||||
};
|
||||
}
|
||||
else if(element && typeof element === 'object' && !element.nodeName) {
|
||||
return {
|
||||
element: element,
|
||||
renderer: renderers.ObjectRenderer
|
||||
};
|
||||
}
|
||||
else{
|
||||
throw new InvalidElementException();
|
||||
}
|
||||
}
|
||||
|
||||
function querySelectedRenderProperties(string){
|
||||
var selector = document.querySelectorAll(string);
|
||||
if(selector.length === 0){
|
||||
return undefined;
|
||||
}
|
||||
else{
|
||||
let returnArray = [];
|
||||
for(let i = 0; i < selector.length; i++){
|
||||
returnArray.push(getRenderProperties(selector[i]));
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function newCanvasRenderProperties(imgElement){
|
||||
var canvas = document.createElement('canvas');
|
||||
return {
|
||||
element: canvas,
|
||||
options: getOptionsFromElement(imgElement),
|
||||
renderer: renderers.CanvasRenderer,
|
||||
afterRender: function(){
|
||||
imgElement.setAttribute("src", canvas.toDataURL());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default getRenderProperties;
|
||||
22
node_modules/jsbarcode/src/help/linearizeEncodings.js
generated
vendored
Normal file
22
node_modules/jsbarcode/src/help/linearizeEncodings.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
export default linearizeEncodings;
|
||||
|
||||
// Encodings can be nestled like [[1-1, 1-2], 2, [3-1, 3-2]
|
||||
// Convert to [1-1, 1-2, 2, 3-1, 3-2]
|
||||
function linearizeEncodings(encodings){
|
||||
var linearEncodings = [];
|
||||
function nextLevel(encoded){
|
||||
if(Array.isArray(encoded)){
|
||||
for(let i = 0; i < encoded.length; i++){
|
||||
nextLevel(encoded[i]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
encoded.text = encoded.text || "";
|
||||
encoded.data = encoded.data || "";
|
||||
linearEncodings.push(encoded);
|
||||
}
|
||||
}
|
||||
nextLevel(encodings);
|
||||
|
||||
return linearEncodings;
|
||||
}
|
||||
1
node_modules/jsbarcode/src/help/merge.js
generated
vendored
Normal file
1
node_modules/jsbarcode/src/help/merge.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default (old, replaceObj) => ({ ...old, ...replaceObj });
|
||||
31
node_modules/jsbarcode/src/help/optionsFromStrings.js
generated
vendored
Normal file
31
node_modules/jsbarcode/src/help/optionsFromStrings.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
export default optionsFromStrings;
|
||||
|
||||
// Convert string to integers/booleans where it should be
|
||||
function optionsFromStrings(options){
|
||||
var intOptions = [
|
||||
"width",
|
||||
"height",
|
||||
"textMargin",
|
||||
"fontSize",
|
||||
"margin",
|
||||
"marginTop",
|
||||
"marginBottom",
|
||||
"marginLeft",
|
||||
"marginRight"
|
||||
];
|
||||
|
||||
for(var intOption in intOptions){
|
||||
if(intOptions.hasOwnProperty(intOption)){
|
||||
intOption = intOptions[intOption];
|
||||
if(typeof options[intOption] === "string"){
|
||||
options[intOption] = parseInt(options[intOption], 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(typeof options["displayValue"] === "string"){
|
||||
options["displayValue"] = (options["displayValue"] != "false");
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
23
node_modules/jsbarcode/src/options/defaults.js
generated
vendored
Normal file
23
node_modules/jsbarcode/src/options/defaults.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
var defaults = {
|
||||
width: 2,
|
||||
height: 100,
|
||||
format: "auto",
|
||||
displayValue: true,
|
||||
fontOptions: "",
|
||||
font: "monospace",
|
||||
text: undefined,
|
||||
textAlign: "center",
|
||||
textPosition: "bottom",
|
||||
textMargin: 2,
|
||||
fontSize: 20,
|
||||
background: "#ffffff",
|
||||
lineColor: "#000000",
|
||||
margin: 10,
|
||||
marginTop: undefined,
|
||||
marginBottom: undefined,
|
||||
marginLeft: undefined,
|
||||
marginRight: undefined,
|
||||
valid: function(){}
|
||||
};
|
||||
|
||||
export default defaults;
|
||||
137
node_modules/jsbarcode/src/renderers/canvas.js
generated
vendored
Normal file
137
node_modules/jsbarcode/src/renderers/canvas.js
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
import merge from "../help/merge.js";
|
||||
import {calculateEncodingAttributes, getTotalWidthOfEncodings, getMaximumHeightOfEncodings} from "./shared.js";
|
||||
|
||||
class CanvasRenderer{
|
||||
constructor(canvas, encodings, options){
|
||||
this.canvas = canvas;
|
||||
this.encodings = encodings;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
render(){
|
||||
// Abort if the browser does not support HTML5 canvas
|
||||
if (!this.canvas.getContext) {
|
||||
throw new Error('The browser does not support canvas.');
|
||||
}
|
||||
|
||||
this.prepareCanvas();
|
||||
for(let i = 0; i < this.encodings.length; i++){
|
||||
var encodingOptions = merge(this.options, this.encodings[i].options);
|
||||
|
||||
this.drawCanvasBarcode(encodingOptions, this.encodings[i]);
|
||||
this.drawCanvasText(encodingOptions, this.encodings[i]);
|
||||
|
||||
this.moveCanvasDrawing(this.encodings[i]);
|
||||
}
|
||||
|
||||
this.restoreCanvas();
|
||||
}
|
||||
|
||||
prepareCanvas(){
|
||||
// Get the canvas context
|
||||
var ctx = this.canvas.getContext("2d");
|
||||
|
||||
ctx.save();
|
||||
|
||||
calculateEncodingAttributes(this.encodings, this.options, ctx);
|
||||
var totalWidth = getTotalWidthOfEncodings(this.encodings);
|
||||
var maxHeight = getMaximumHeightOfEncodings(this.encodings);
|
||||
|
||||
this.canvas.width = totalWidth + this.options.marginLeft + this.options.marginRight;
|
||||
|
||||
this.canvas.height = maxHeight;
|
||||
|
||||
// Paint the canvas
|
||||
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
if(this.options.background){
|
||||
ctx.fillStyle = this.options.background;
|
||||
ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
}
|
||||
|
||||
ctx.translate(this.options.marginLeft, 0);
|
||||
}
|
||||
|
||||
drawCanvasBarcode(options, encoding){
|
||||
// Get the canvas context
|
||||
var ctx = this.canvas.getContext("2d");
|
||||
|
||||
var binary = encoding.data;
|
||||
|
||||
// Creates the barcode out of the encoded binary
|
||||
var yFrom;
|
||||
if(options.textPosition == "top"){
|
||||
yFrom = options.marginTop + options.fontSize + options.textMargin;
|
||||
}
|
||||
else{
|
||||
yFrom = options.marginTop;
|
||||
}
|
||||
|
||||
ctx.fillStyle = options.lineColor;
|
||||
|
||||
for(var b = 0; b < binary.length; b++){
|
||||
var x = b * options.width + encoding.barcodePadding;
|
||||
|
||||
if(binary[b] === "1"){
|
||||
ctx.fillRect(x, yFrom, options.width, options.height);
|
||||
}
|
||||
else if(binary[b]){
|
||||
ctx.fillRect(x, yFrom, options.width, options.height * binary[b]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drawCanvasText(options, encoding){
|
||||
// Get the canvas context
|
||||
var ctx = this.canvas.getContext("2d");
|
||||
|
||||
var font = options.fontOptions + " " + options.fontSize + "px " + options.font;
|
||||
|
||||
// Draw the text if displayValue is set
|
||||
if(options.displayValue){
|
||||
var x, y;
|
||||
|
||||
if(options.textPosition == "top"){
|
||||
y = options.marginTop + options.fontSize - options.textMargin;
|
||||
}
|
||||
else{
|
||||
y = options.height + options.textMargin + options.marginTop + options.fontSize;
|
||||
}
|
||||
|
||||
ctx.font = font;
|
||||
|
||||
// Draw the text in the correct X depending on the textAlign option
|
||||
if(options.textAlign == "left" || encoding.barcodePadding > 0){
|
||||
x = 0;
|
||||
ctx.textAlign = 'left';
|
||||
}
|
||||
else if(options.textAlign == "right"){
|
||||
x = encoding.width - 1;
|
||||
ctx.textAlign = 'right';
|
||||
}
|
||||
// In all other cases, center the text
|
||||
else{
|
||||
x = encoding.width / 2;
|
||||
ctx.textAlign = 'center';
|
||||
}
|
||||
|
||||
ctx.fillText(encoding.text, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
moveCanvasDrawing(encoding){
|
||||
var ctx = this.canvas.getContext("2d");
|
||||
|
||||
ctx.translate(encoding.width, 0);
|
||||
}
|
||||
|
||||
restoreCanvas(){
|
||||
// Get the canvas context
|
||||
var ctx = this.canvas.getContext("2d");
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
export default CanvasRenderer;
|
||||
5
node_modules/jsbarcode/src/renderers/index.js
generated
vendored
Normal file
5
node_modules/jsbarcode/src/renderers/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import CanvasRenderer from './canvas.js';
|
||||
import SVGRenderer from './svg.js';
|
||||
import ObjectRenderer from './object.js';
|
||||
|
||||
export default {CanvasRenderer, SVGRenderer, ObjectRenderer};
|
||||
14
node_modules/jsbarcode/src/renderers/object.js
generated
vendored
Normal file
14
node_modules/jsbarcode/src/renderers/object.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
class ObjectRenderer {
|
||||
constructor(object, encodings, options) {
|
||||
this.object = object;
|
||||
this.encodings = encodings;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
render() {
|
||||
this.object.encodings = this.encodings;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default ObjectRenderer;
|
||||
94
node_modules/jsbarcode/src/renderers/shared.js
generated
vendored
Normal file
94
node_modules/jsbarcode/src/renderers/shared.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
import merge from "../help/merge.js";
|
||||
|
||||
function getEncodingHeight(encoding, options){
|
||||
return options.height +
|
||||
((options.displayValue && encoding.text.length > 0) ? options.fontSize + options.textMargin : 0) +
|
||||
options.marginTop +
|
||||
options.marginBottom;
|
||||
}
|
||||
|
||||
function getBarcodePadding(textWidth, barcodeWidth, options){
|
||||
if(options.displayValue && barcodeWidth < textWidth){
|
||||
if(options.textAlign == "center"){
|
||||
return Math.floor((textWidth - barcodeWidth) / 2);
|
||||
}
|
||||
else if(options.textAlign == "left"){
|
||||
return 0;
|
||||
}
|
||||
else if(options.textAlign == "right"){
|
||||
return Math.floor(textWidth - barcodeWidth);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function calculateEncodingAttributes(encodings, barcodeOptions, context){
|
||||
for(let i = 0; i < encodings.length; i++){
|
||||
var encoding = encodings[i];
|
||||
var options = merge(barcodeOptions, encoding.options);
|
||||
|
||||
// Calculate the width of the encoding
|
||||
var textWidth;
|
||||
if(options.displayValue){
|
||||
textWidth = messureText(encoding.text, options, context);
|
||||
}
|
||||
else{
|
||||
textWidth = 0;
|
||||
}
|
||||
|
||||
var barcodeWidth = encoding.data.length * options.width;
|
||||
encoding.width = Math.ceil(Math.max(textWidth, barcodeWidth));
|
||||
|
||||
encoding.height = getEncodingHeight(encoding, options);
|
||||
|
||||
encoding.barcodePadding = getBarcodePadding(textWidth, barcodeWidth, options);
|
||||
}
|
||||
}
|
||||
|
||||
function getTotalWidthOfEncodings(encodings){
|
||||
var totalWidth = 0;
|
||||
for(let i = 0; i < encodings.length; i++){
|
||||
totalWidth += encodings[i].width;
|
||||
}
|
||||
return totalWidth;
|
||||
}
|
||||
|
||||
function getMaximumHeightOfEncodings(encodings){
|
||||
var maxHeight = 0;
|
||||
for(let i = 0; i < encodings.length; i++){
|
||||
if(encodings[i].height > maxHeight){
|
||||
maxHeight = encodings[i].height;
|
||||
}
|
||||
}
|
||||
return maxHeight;
|
||||
}
|
||||
|
||||
function messureText(string, options, context){
|
||||
var ctx;
|
||||
|
||||
if(context){
|
||||
ctx = context;
|
||||
}
|
||||
else if(typeof document !== "undefined"){
|
||||
ctx = document.createElement("canvas").getContext("2d");
|
||||
}
|
||||
else{
|
||||
// If the text cannot be messured we will return 0.
|
||||
// This will make some barcode with big text render incorrectly
|
||||
return 0;
|
||||
}
|
||||
ctx.font = options.fontOptions + " " + options.fontSize + "px " + options.font;
|
||||
|
||||
// Calculate the width of the encoding
|
||||
var measureTextResult = ctx.measureText(string);
|
||||
if (!measureTextResult) {
|
||||
// Some implementations don't implement measureText and return undefined.
|
||||
// If the text cannot be measured we will return 0.
|
||||
// This will make some barcode with big text render incorrectly
|
||||
return 0;
|
||||
}
|
||||
var size = measureTextResult.width;
|
||||
return size;
|
||||
}
|
||||
|
||||
export {getMaximumHeightOfEncodings, getEncodingHeight, getBarcodePadding, calculateEncodingAttributes, getTotalWidthOfEncodings};
|
||||
171
node_modules/jsbarcode/src/renderers/svg.js
generated
vendored
Normal file
171
node_modules/jsbarcode/src/renderers/svg.js
generated
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
import merge from "../help/merge.js";
|
||||
import {calculateEncodingAttributes, getTotalWidthOfEncodings, getMaximumHeightOfEncodings} from "./shared.js";
|
||||
|
||||
var svgns = "http://www.w3.org/2000/svg";
|
||||
|
||||
class SVGRenderer{
|
||||
constructor(svg, encodings, options){
|
||||
this.svg = svg;
|
||||
this.encodings = encodings;
|
||||
this.options = options;
|
||||
this.document = options.xmlDocument || document;
|
||||
}
|
||||
|
||||
render(){
|
||||
var currentX = this.options.marginLeft;
|
||||
|
||||
this.prepareSVG();
|
||||
for(let i = 0; i < this.encodings.length; i++){
|
||||
var encoding = this.encodings[i];
|
||||
var encodingOptions = merge(this.options, encoding.options);
|
||||
|
||||
var group = this.createGroup(currentX, encodingOptions.marginTop, this.svg);
|
||||
|
||||
this.setGroupOptions(group, encodingOptions);
|
||||
|
||||
this.drawSvgBarcode(group, encodingOptions, encoding);
|
||||
this.drawSVGText(group, encodingOptions, encoding);
|
||||
|
||||
currentX += encoding.width;
|
||||
}
|
||||
}
|
||||
|
||||
prepareSVG(){
|
||||
// Clear the SVG
|
||||
while (this.svg.firstChild) {
|
||||
this.svg.removeChild(this.svg.firstChild);
|
||||
}
|
||||
|
||||
calculateEncodingAttributes(this.encodings, this.options);
|
||||
var totalWidth = getTotalWidthOfEncodings(this.encodings);
|
||||
var maxHeight = getMaximumHeightOfEncodings(this.encodings);
|
||||
|
||||
var width = totalWidth + this.options.marginLeft + this.options.marginRight;
|
||||
this.setSvgAttributes(width, maxHeight);
|
||||
|
||||
if(this.options.background){
|
||||
this.drawRect(0, 0, width, maxHeight, this.svg).setAttribute(
|
||||
"style", "fill:" + this.options.background + ";"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
drawSvgBarcode(parent, options, encoding){
|
||||
var binary = encoding.data;
|
||||
|
||||
// Creates the barcode out of the encoded binary
|
||||
var yFrom;
|
||||
if(options.textPosition == "top"){
|
||||
yFrom = options.fontSize + options.textMargin;
|
||||
}
|
||||
else{
|
||||
yFrom = 0;
|
||||
}
|
||||
|
||||
var barWidth = 0;
|
||||
var x = 0;
|
||||
for(var b = 0; b < binary.length; b++){
|
||||
x = b * options.width + encoding.barcodePadding;
|
||||
|
||||
if(binary[b] === "1"){
|
||||
barWidth++;
|
||||
}
|
||||
else if(barWidth > 0){
|
||||
this.drawRect(x - options.width * barWidth, yFrom, options.width * barWidth, options.height, parent);
|
||||
barWidth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Last draw is needed since the barcode ends with 1
|
||||
if(barWidth > 0){
|
||||
this.drawRect(x - options.width * (barWidth - 1), yFrom, options.width * barWidth, options.height, parent);
|
||||
}
|
||||
}
|
||||
|
||||
drawSVGText(parent, options, encoding){
|
||||
var textElem = this.document.createElementNS(svgns, 'text');
|
||||
|
||||
// Draw the text if displayValue is set
|
||||
if(options.displayValue){
|
||||
var x, y;
|
||||
|
||||
textElem.setAttribute("style",
|
||||
"font:" + options.fontOptions + " " + options.fontSize + "px " + options.font
|
||||
);
|
||||
|
||||
if(options.textPosition == "top"){
|
||||
y = options.fontSize - options.textMargin;
|
||||
}
|
||||
else{
|
||||
y = options.height + options.textMargin + options.fontSize;
|
||||
}
|
||||
|
||||
// Draw the text in the correct X depending on the textAlign option
|
||||
if(options.textAlign == "left" || encoding.barcodePadding > 0){
|
||||
x = 0;
|
||||
textElem.setAttribute("text-anchor", "start");
|
||||
}
|
||||
else if(options.textAlign == "right"){
|
||||
x = encoding.width - 1;
|
||||
textElem.setAttribute("text-anchor", "end");
|
||||
}
|
||||
// In all other cases, center the text
|
||||
else{
|
||||
x = encoding.width / 2;
|
||||
textElem.setAttribute("text-anchor", "middle");
|
||||
}
|
||||
|
||||
textElem.setAttribute("x", x);
|
||||
textElem.setAttribute("y", y);
|
||||
|
||||
textElem.appendChild(this.document.createTextNode(encoding.text));
|
||||
|
||||
parent.appendChild(textElem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setSvgAttributes(width, height){
|
||||
var svg = this.svg;
|
||||
svg.setAttribute("width", width + "px");
|
||||
svg.setAttribute("height", height + "px");
|
||||
svg.setAttribute("x", "0px");
|
||||
svg.setAttribute("y", "0px");
|
||||
svg.setAttribute("viewBox", "0 0 " + width + " " + height);
|
||||
|
||||
svg.setAttribute("xmlns", svgns);
|
||||
svg.setAttribute("version", "1.1");
|
||||
|
||||
svg.setAttribute("style", "transform: translate(0,0)");
|
||||
}
|
||||
|
||||
createGroup(x, y, parent){
|
||||
var group = this.document.createElementNS(svgns, 'g');
|
||||
group.setAttribute("transform", "translate(" + x + ", " + y + ")");
|
||||
|
||||
parent.appendChild(group);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
setGroupOptions(group, options){
|
||||
group.setAttribute("style",
|
||||
"fill:" + options.lineColor + ";"
|
||||
);
|
||||
}
|
||||
|
||||
drawRect(x, y, width, height, parent){
|
||||
var rect = this.document.createElementNS(svgns, 'rect');
|
||||
|
||||
rect.setAttribute("x", x);
|
||||
rect.setAttribute("y", y);
|
||||
rect.setAttribute("width", width);
|
||||
rect.setAttribute("height", height);
|
||||
|
||||
parent.appendChild(rect);
|
||||
|
||||
return rect;
|
||||
}
|
||||
}
|
||||
|
||||
export default SVGRenderer;
|
||||
Reference in New Issue
Block a user