react-code39-barcode
Advanced tools
Comparing version
@@ -1,1 +0,1 @@ | ||
import e from"react";const t={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 o(e,o,r,n,i,l,a,c,h,s){const d="*"+e.toUpperCase()+"*";let f="";if(d.length>43)throw new Error("Data too long for Code39 barcode");for(let e of d){if(!t[e])throw new Error(`Invalid character for Code39 barcode: ${e}`);f+=t[e]+"0"}const g=[];let p=0;for(let e of f)"1"===e?p+=1:(g.push(p),p=0);let $=0,w="";for(let e of g){const t=2===e?2*r:0;0!==e&&(w+=`<rect x="${$}" y="0" width="${r+t}" height="${o}" />`,$+=r+t),$+=r}c||(c="black"),h||(h=c);return`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" version="1.1" height="${o}"><g style="fill:${c};">${w}</g></svg>${n?`<div style="font: ${i}px ${l}; text-align:center; width: ${$}px; color: ${h}; ${s?"line-height:"+s+"px":""}; font-weight: ${a}" >${e.toUpperCase()}</div>`:""}`}function r({value:t="",height:r=60,width:n=1,showValue:i=!0,fontSize:l=16,fontFamily:a="monospace",fontWeight:c="500",padding:h=10,color:s="black",textColor:d="",lineSpacing:f,className:g="",id:p=""}){if(!t)throw new Error("Barcode39Svg: value prop is required");return e.createElement("div",{id:p,className:g,style:{padding:h},dangerouslySetInnerHTML:{__html:o(t,r,n,i,l,a,c,s,d,f)}})}export{r as Barcode39Svg}; | ||
import e from"react";const t={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 o(e,o,r,n,i,l,a,s,c,h){const d="*"+e.toUpperCase()+"*";let f="";if(d.length>43)throw new Error("Data too long for Code39 barcode");for(let e of d){if(!t[e])throw new Error(`Invalid character for Code39 barcode: ${e}`);f+=t[e]+"0"}const g=[];let p=0;for(let e of f)"1"===e?p+=1:(g.push(p),p=0);let $=0,w="";for(let e of g){const t=2===e?2*r:0;0!==e&&(w+=`<rect x="${$}" y="0" width="${r+t}" height="${o}" />`,$+=r+t),$+=r}s||(s="black"),c||(c=s);return`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" version="1.1" height="${o}"><g style="fill:${s};">${w}</g></svg>${n?`<div style="font: ${i}px ${l}; text-align:center; width: ${$}px; color: ${c}; ${h?"line-height:"+h+"px":""}; font-weight: ${a}" >${e.toUpperCase()}</div>`:""}`}function r({value:t="",height:r=60,width:n=1,showValue:i=!0,fontSize:l=16,fontFamily:a="monospace",fontWeight:s="500",padding:c=10,color:h="black",textColor:d="",lineSpacing:f,className:g="",id:p="",style:$={}}){if(!t)throw new Error("Barcode39Svg: value prop is required");return e.createElement("div",{id:p,className:g,style:{...$,padding:c},dangerouslySetInnerHTML:{__html:o(t,r,n,i,l,a,s,h,d,f)}})}export{r as Barcode39Svg}; |
{ | ||
"name": "react-code39-barcode", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.es.js", |
@@ -34,16 +34,17 @@ # React Code39 Barcode | ||
| Prop | Type | Default | Description | | ||
| ----------- | ------- | ----------- | ----------------------------------------------------------------------------- | | ||
| value | string | - | The value to be encoded as a Code39 barcode. | | ||
| width | number | 1 | The width of each bar in pixels. | | ||
| height | number | 60 | The height of the barcode in pixels. | | ||
| fontSize | number | 16 | The font size of the text displayed below the barcode. | | ||
| fontFamily | string | 'monospace' | The CSS font family of the text displayed below the barcode. | | ||
| fontWeight | string | '500' | The CSS font weight of the text displayed below the barcode. | | ||
| color | string | "black" | The color of the barcode. | | ||
| textColor | string | "black" | The color of the text displayed below the barcode if different from the color | | ||
| showText | boolean | true | Whether to display the text below the barcode. | | ||
| lineSpacing | number | - | The spacing between the display text and the barcode. | | ||
| className | string | - | Any valid css class that will be applied to the barcode container | | ||
| id | string | - | HTML id for the barcode container | | ||
| Prop | Type | Default | Description | | ||
| ----------- | -------------------- | ----------- | ----------------------------------------------------------------------------- | | ||
| value | string | - | The value to be encoded as a Code39 barcode. | | ||
| width | number | 1 | The width of each bar in pixels. | | ||
| height | number | 60 | The height of the barcode in pixels. | | ||
| fontSize | number | 16 | The font size of the text displayed below the barcode. | | ||
| fontFamily | string | 'monospace' | The CSS font family of the text displayed below the barcode. | | ||
| fontWeight | string | '500' | The CSS font weight of the text displayed below the barcode. | | ||
| color | string | "black" | The color of the barcode. | | ||
| textColor | string | "black" | The color of the text displayed below the barcode if different from the color | | ||
| showText | boolean | true | Whether to display the text below the barcode. | | ||
| lineSpacing | number | - | The spacing between the display text and the barcode. | | ||
| className | string | - | Any valid css class that will be applied to the barcode container | | ||
| id | string | - | HTML id for the barcode container | | ||
| style | React.CSSProperties; | {} | React CSS properties that will apply to the barcode container | | ||
@@ -50,0 +51,0 @@ ## License |
@@ -15,4 +15,5 @@ declare function Barcode39Svg(props: { | ||
id?: string; | ||
style?: React.CSSProperties; | ||
}): JSX.Element; | ||
export { Barcode39Svg }; |
6164
6.28%25
4.17%53
1.92%