react-code39-barcode
Advanced tools
Comparing version
@@ -1,1 +0,1 @@ | ||
const e={0:"101001101101",1:"110100101011",2:"101100101011",3:"110110010101",4:"101001101011",5:"110100110101",6:"101100110101",7:"101001011011",8:"110100101101",9:"101100101101",A:"110101001011",B:"101101001011",C:"110110100101",D:"101011001011",E:"110101100101",F:"101101100101",G:"101010011011",H:"110101001101",I:"101101001101",J:"101011001101",K:"110101010011",L:"101101010011",M:"110110101001",N:"101011010011",O:"110101101001",P:"101101101001",Q:"101010110011",R:"110101011001",S:"101101011001",T:"101011011001",U:"110010101011",V:"100110101011",W:"110011010101",X:"100101101011",Y:"110010110101",Z:"100110110101","-":"100101011011",".":"110010101101"," ":"100110101101",$:"100100100101","/":"100100101001","+":"100101001001","%":"101001001001","*":"100101101101"};function t(t,o,r,i,n,l,a,s,c,h){const d="*"+t.toUpperCase()+"*";let g="";for(let t of d){if(!e[t])throw new Error(`Invalid character for Code39 barcode: ${t}`);g+=e[t]+"0"}const f=[];let $=0;for(let e of g)"1"===e?$+=1:(f.push($),$=0);let p=0,w="";for(let e of f){const t=2===e?2*r:0;0!==e&&(w+=`<rect x="${p}" y="0" width="${r+t}" height="${o}" />`,p+=r+t),p+=r}s||(s="black"),c||(c=s);return`<svg xmlns="http://www.w3.org/2000/svg" width="${p}" version="1.1" height="${o}"><g style="fill:${s};">${w}</g></svg>${i?`<div style="font: ${n}px ${l}; text-align:center; width: ${p}px; color: ${c}; line-height: ${h}px; font-weight: ${a}" >${t.toUpperCase()}</div>`:""}`}function o({value:e="",height:o=60,width:r=1,showValue:i=!0,fontSize:n=16,fontFamily:l="monospace",fontWeight:a="500",padding:s=10,color:c="black",textColor:h="",lineSpacing:d=10,className:g="",id:f=""}){if(!e)throw new Error("Barcode39Svg: value prop is required");return React.createElement("div",{id:f,className:g,style:{padding:s},dangerouslySetInnerHTML:{__html:t(e,o,r,i,n,l,a,c,h,d)}})}export{o as Barcode39Svg}; | ||
import t from"react";function r(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,o=Array(r);n<r;n++)o[n]=t[n];return o}function n(t,n){var o="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!o){if(Array.isArray(t)||(o=function(t,n){if(t){if("string"==typeof t)return r(t,n);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(t,n):void 0}}(t))||n){o&&(t=o);var e=0,a=function(){};return{s:a,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,l=!1;return{s:function(){o=o.call(t)},n:function(){var t=o.next();return c=t.done,t},e:function(t){l=!0,i=t},f:function(){try{c||null==o.return||o.return()}finally{if(l)throw i}}}}var o={0:"101001101101",1:"110100101011",2:"101100101011",3:"110110010101",4:"101001101011",5:"110100110101",6:"101100110101",7:"101001011011",8:"110100101101",9:"101100101101",A:"110101001011",B:"101101001011",C:"110110100101",D:"101011001011",E:"110101100101",F:"101101100101",G:"101010011011",H:"110101001101",I:"101101001101",J:"101011001101",K:"110101010011",L:"101101010011",M:"110110101001",N:"101011010011",O:"110101101001",P:"101101101001",Q:"101010110011",R:"110101011001",S:"101101011001",T:"101011011001",U:"110010101011",V:"100110101011",W:"110011010101",X:"100101101011",Y:"110010110101",Z:"100110110101","-":"100101011011",".":"110010101101"," ":"100110101101",$:"100100100101","/":"100100101001","+":"100101001001","%":"101001001001","*":"100101101101"};function e(t,r,e,a,i,c,l,d,v,f){var u,s="",h=n("*"+t.toUpperCase()+"*");try{for(h.s();!(u=h.n()).done;){var g=u.value;if(!o[g])throw new Error("Invalid character for Code39 barcode: ".concat(g));s+=o[g]+"0"}}catch(t){h.e(t)}finally{h.f()}var y,p=[],m=0,w=n(s);try{for(w.s();!(y=w.n()).done;){"1"===y.value?m+=1:(p.push(m),m=0)}}catch(t){w.e(t)}finally{w.f()}for(var b=0,S="",x=0,A=p;x<A.length;x++){var C=A[x],I=2===C?2*e:0;0!==C&&(S+='<rect x="'.concat(b,'" y="0" width="').concat(e+I,'" height="').concat(r,'" />'),b+=e+I),b+=e}d||(d="black"),v||(v=d);var E=a?'<div style="font: '.concat(i,"px ").concat(c,"; text-align:center; width: ").concat(b,"px; color: ").concat(v,"; line-height: ").concat(f,"px; font-weight: ").concat(l,'" >').concat(t.toUpperCase(),"</div>"):"";return'<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(b,'" version="1.1" height="').concat(r,'"><g style="fill:').concat(d,';">').concat(S,"</g></svg>").concat(E)}function a(r){var n=r.value,o=void 0===n?"":n,a=r.height,i=void 0===a?60:a,c=r.width,l=void 0===c?1:c,d=r.showValue,v=void 0===d||d,f=r.fontSize,u=void 0===f?16:f,s=r.fontFamily,h=void 0===s?"monospace":s,g=r.fontWeight,y=void 0===g?"500":g,p=r.padding,m=void 0===p?10:p,w=r.color,b=void 0===w?"black":w,S=r.textColor,x=void 0===S?"":S,A=r.lineSpacing,C=void 0===A?10:A,I=r.className,E=void 0===I?"":I,U=r.id,M=void 0===U?"":U;if(!o)throw new Error("Barcode39Svg: value prop is required");return t.createElement("div",{id:M,className:E,style:{padding:m},dangerouslySetInnerHTML:{__html:e(o,i,l,v,u,h,y,b,x,C)}})}export{a as Barcode39Svg}; |
{ | ||
"name": "react-code39-barcode", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "", | ||
@@ -30,3 +30,2 @@ "main": "dist/index.es.js", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@rollup/plugin-commonjs": "^26.0.1", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
@@ -33,0 +32,0 @@ "@rollup/plugin-terser": "^0.4.4", |
@@ -5,2 +5,6 @@ # React Code39 Barcode | ||
## Supported Code | ||
- CODE39 | ||
## Installation | ||
@@ -7,0 +11,0 @@ |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
7881
23.35%9
-10%13
62.5%71
5.97%0
-100%2
100%