react-pdf-levelup 3.1.63 → 3.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +340 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {StyleSheet,renderToStream,Document,Page,View,Text,Image,Link}from'@react-pdf/renderer';export{Font,StyleSheet,Text,View,renderToStream}from'@react-pdf/renderer';import O,{createContext,createElement,useContext,useState,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import
|
|
2
|
-
`}),Se=({style:e})=>jsx(View,{style:[f.hr,e]}),Ae=({children:e,style:t})=>jsx(Text,{style:[t],children:e}),Ve=({children:e,style:t,fixed:o=false})=>jsx(View,{style:[f.header,t],fixed:o,children:typeof e=="string"?jsx(Text,{children:e}):e}),Oe=({children:e,style:t})=>jsx(View,{style:t,children:e});var E=createContext({cellHeight:22,textAlign:"left"}),V=StyleSheet.create({table:{width:"100%",borderWidth:1,borderColor:"#000",marginBottom:20},thead:{backgroundColor:"#ccc"},tr:{flexDirection:"row"},textBold:{fontSize:10,fontFamily:"Helvetica",fontWeight:"bold",paddingLeft:8,paddingRight:8,justifyContent:"center"},text:{fontSize:10,fontFamily:"Helvetica",paddingLeft:8,paddingRight:8,justifyContent:"center"},zebraOdd:{backgroundColor:"#eeeeee"}}),Be=({children:e,style:t,cellHeight:o=22})=>jsx(E.Provider,{value:{cellHeight:o,textAlign:"left"},children:jsx(View,{style:[V.table,t],children:e})}),ve=({children:e,style:t,textAlign:o="left"})=>{let{cellHeight:r}=useContext(E);return jsx(E.Provider,{value:{cellHeight:r,textAlign:o},children:jsx(View,{style:[V.thead,t],children:e})})},ke=({children:e,style:t})=>{let o=O.Children.toArray(e),r=o.length;return jsx(Fragment,{children:o.map((a,i)=>O.cloneElement(a,{isLastRow:i===r-1,isOdd:i%2===1}))})},De=({children:e,style:t,isLastRow:o=false,isOdd:r=false})=>{let a=O.Children.toArray(e),i=a.length;return jsx(View,{style:[V.tr,t],children:a.map((n,s)=>{let d=s===i-1,l=`${(100/i).toFixed(2)}%`;return O.cloneElement(n,{width:l,isLast:d,isLastRow:o,isOdd:r})})})},Ee=({children:e,style:t,width:o,height:r,colSpan:a,isLast:i=false,isLastRow:n=false,textAlign:s})=>{let{cellHeight:d,textAlign:l}=useContext(E),c=s||l||"left",g=typeof o=="string"&&a?`${(parseFloat(o)*a).toFixed(2)}%`:o,u={borderRightWidth:i?0:1,borderBottomWidth:n?0:1,borderColor:"#000",minHeight:r!==void 0?r:d};return jsx(View,{style:[V.textBold,{width:g},u,t],children:jsx(Text,{style:{textAlign:c},children:e})})},He=({children:e,style:t,width:o,height:r,colSpan:a,isLast:i=false,isLastRow:n=false,isOdd:s=false,textAlign:d})=>{let{cellHeight:l,textAlign:c}=useContext(E),g=d||c||"left",p=typeof o=="string"&&a?`${(parseFloat(o)*a).toFixed(2)}%`:o,P={borderRightWidth:i?0:1,borderBottomWidth:n?0:1,borderColor:"#000",minHeight:r!==void 0?r:l};return jsx(View,{style:[V.text,s&&V.zebraOdd,{width:p},P,t],children:jsx(Text,{style:{textAlign:g},children:e})})};var m=StyleSheet.create({container:{width:"100%",paddingHorizontal:20},row:{flexDirection:"row",flexWrap:"wrap",marginHorizontal:-5},col:{paddingHorizontal:5},col1:{width:"8.33%"},col2:{width:"16.66%"},col3:{width:"25%"},col4:{width:"33.33%"},col5:{width:"41.66%"},col6:{width:"50%"},col7:{width:"58.33%"},col8:{width:"66.66%"},col9:{width:"75%"},col10:{width:"83.33%"},col11:{width:"91.66%"},col12:{width:"100%"}}),Qe=({children:e,style:t})=>jsx(View,{style:[m.container,t],children:e}),Me=({children:e,style:t})=>jsx(View,{style:[m.row,t],children:e}),Ue=({children:e,style:t})=>jsx(View,{style:[m.col,m.col1,t],children:e}),Ne=({children:e,style:t})=>jsx(View,{style:[m.col,m.col2,t],children:e}),qe=({children:e,style:t})=>jsx(View,{style:[m.col,m.col3,t],children:e}),ze=({children:e,style:t})=>jsx(View,{style:[m.col,m.col4,t],children:e}),$e=({children:e,style:t})=>jsx(View,{style:[m.col,m.col5,t],children:e}),We=({children:e,style:t})=>jsx(View,{style:[m.col,m.col6,t],children:e}),Xe=({children:e,style:t})=>jsx(View,{style:[m.col,m.col7,t],children:e}),Ge=({children:e,style:t})=>jsx(View,{style:[m.col,m.col8,t],children:e}),Je=({children:e,style:t})=>jsx(View,{style:[m.col,m.col9,t],children:e}),_e=({children:e,style:t})=>jsx(View,{style:[m.col,m.col10,t],children:e}),je=({children:e,style:t})=>jsx(View,{style:[m.col,m.col11,t],children:e}),Ke=({children:e,style:t})=>jsx(View,{style:[m.col,m.col12,t],children:e});var W=async({value:e,size:t=150,colorDark:o="#000000",colorLight:r="#ffffff",margin:a=0,errorCorrectionLevel:i="M"})=>{try{let n={errorCorrectionLevel:i,type:"image/png",quality:.92,margin:a,color:{dark:o,light:r},width:t};return Et.toDataURL(e,n)}catch(n){return console.error("Error generando QR:",n),""}},Ye=async(e,t,o,r)=>new Promise(async a=>{if(!e||!t){a(e);return}try{let i=typeof window<"u"&&typeof window.document<"u",n,s,d;if(i)n=document.createElement("canvas"),s=n.getContext("2d"),d=window.Image;else try{let{createCanvas:c,Image:g}=await import('canvas');n=c(100,100),s=n.getContext("2d"),d=g;}catch(c){console.error("Canvas not available in Node environment for addLogoToQR",c),a(e);return}if(!s){a(e);return}let l=new d;i&&(l.crossOrigin="anonymous"),l.onload=()=>{n.width=l.width,n.height=l.height,s.drawImage(l,0,0,n.width,n.height);let c=new d;i&&(c.crossOrigin="anonymous"),c.onload=()=>{let g=(n.width-o)/2,p=(n.height-r)/2;s.fillStyle="#FFFFFF",s.fillRect(g-5,p-5,o+10,r+10),s.drawImage(c,g,p,o,r);let u=n.toDataURL("image/png");a(u);},c.onerror=g=>{console.error("Error cargando el logo:",g),a(e);},c.src=t;},l.onerror=c=>{console.error("Error cargando el QR:",c),a("");},l.src=e;}catch(i){console.error("Error procesando el QR con logo:",i),a(e);}});var qt=StyleSheet.create({qrContainer:{display:"flex",alignItems:"center",justifyContent:"center",margin:10}}),zt={0:"L",1:"M",2:"Q",3:"H"},$t=({value:e,size:t=150,style:o,colorDark:r="#000000",colorLight:a="#ffffff",margin:i=0,logo:n="",logoWidth:s=30,logoHeight:d=30,errorCorrectionLevel:l=n?"H":"M"})=>{let[c,g]=useState("");useEffect(()=>{(async()=>{try{let P=await W({value:e,size:t,colorDark:r,colorLight:a,margin:i,errorCorrectionLevel:typeof l=="number"?zt[l]||"M":l});if(n&&s&&d){let R=await Ye(P,n,s,d);g(R);}else g(P);}catch(P){console.error("Error generando QR:",P);let R=`https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(e)}&size=${t}x${t}&color=${encodeURIComponent(r.replace("#",""))}&bgcolor=${encodeURIComponent(a.replace("#",""))}`;g(R);}})();},[e,t,r,a,i,n,s,d,l]);let p=`https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(e)}&size=${t}x${t}`;return jsx(View,{style:[qt.qrContainer,o],children:jsx(Image,{src:c||p,style:{width:t,height:t}})})},et=$t;var oe=async e=>{try{let t=typeof window<"u"&&typeof window.document<"u",o,r={};if(t)try{let c=await import('qr-code-styling');o=c.default||c;}catch(c){throw console.error("Failed to load qr-code-styling in browser",c),c}else {let c="jsdom",g="canvas",p="qr-code-styling/lib/qr-code-styling.common.js";try{let[u,P,R]=await Promise.all([import(c),import(g),import(p)]),{JSDOM:I}=u,S=P.default||P,{QRCodeStyling:B}=R;o=B,r={jsdom:I,nodeCanvas:S};}catch(u){throw console.error("Failed to load Node dependencies for QR generation",u),u}}let a=typeof e.width=="number"&&isFinite(e.width)?Math.round(e.width):300,i=typeof e.height=="number"&&isFinite(e.height)?Math.round(e.height):300,n=!!e.image,s={width:a,height:i,data:e.value,image:e.image,dotsOptions:e.dotsOptions,backgroundOptions:{color:e.backgroundOptions?.color||"#ffffff",...e.backgroundOptions},imageOptions:{crossOrigin:"anonymous",margin:typeof e.imageOptions?.margin=="number"&&isFinite(e.imageOptions.margin)?e.imageOptions.margin:0,saveAsBlob:!0,imageSize:typeof e.imageOptions?.imageSize=="number"&&isFinite(e.imageOptions.imageSize)?Math.max(0,Math.min(1,e.imageOptions.imageSize)):.4},cornersSquareOptions:e.cornersSquareOptions,cornersDotOptions:e.cornersDotOptions},l=await new o({type:"png",...r,...s}).getRawData("png");if(!l)throw new Error("Failed to generate raw data from qr-code-styling");if(t){if(l instanceof Blob)return new Promise((c,g)=>{let p=new FileReader;p.onloadend=()=>{typeof p.result=="string"?c(p.result):g(new Error("Failed to convert blob to base64"));},p.onerror=g,p.readAsDataURL(l);});console.warn("Unexpected rawData type in browser:",l);}if(typeof Buffer<"u"&&Buffer.isBuffer(l))return `data:image/png;base64,${l.toString("base64")}`;throw new Error(`Unexpected raw data type: ${typeof l}`)}catch(t){return console.error("Error generating QR V2, falling back to V1:",t),W({value:e.value,size:e.width,colorDark:e.fallbackColorDark||e.dotsOptions?.color,colorLight:e.fallbackColorLight||e.backgroundOptions?.color,margin:e.fallbackMargin||0,errorCorrectionLevel:e.fallbackErrorCorrectionLevel||"M"})}};var jt=StyleSheet.create({qrContainer:{display:"flex",alignItems:"center",justifyContent:"center"}}),Kt=({value:e,size:t=300,style:o,image:r,dotsOptions:a,backgroundOptions:i,imageOptions:n,cornersSquareOptions:s,cornersDotOptions:d,colorDark:l,colorLight:c,margin:g,errorCorrectionLevel:p})=>{let[u,P]=useState("");return useEffect(()=>{let R=true;return (async()=>{let S=a||(l?{color:l}:void 0),B=i||(c?{color:c}:void 0),U={...n,margin:n?.margin!==void 0?n.margin:g};try{let v=await oe({value:e,width:t,height:t,image:r,dotsOptions:S,backgroundOptions:B,imageOptions:U,cornersSquareOptions:s,cornersDotOptions:d,fallbackColorDark:l,fallbackColorLight:c,fallbackMargin:g,fallbackErrorCorrectionLevel:p});R&&P(v);}catch(v){console.error("QRV2 Generation Error:",v);}})(),()=>{R=false;}},[e,t,r,JSON.stringify(a),JSON.stringify(i),JSON.stringify(n),JSON.stringify(s),JSON.stringify(d),l,c,g,p]),jsx(View,{style:[jt.qrContainer,o],children:jsx(Image,{style:{width:t,height:t},src:oe({value:e,width:t,height:t,image:r,dotsOptions:a||(l?{color:l}:void 0),backgroundOptions:i||(c?{color:c}:void 0),imageOptions:{...n,margin:n?.margin!==void 0?n.margin:g},cornersSquareOptions:s,cornersDotOptions:d,fallbackColorDark:l,fallbackColorLight:c,fallbackMargin:g,fallbackErrorCorrectionLevel:p})})})},ot=Kt;var Q=StyleSheet.create({ul:{marginBottom:10,paddingLeft:15},ol:{marginBottom:10,paddingLeft:15},li:{marginBottom:5,flexDirection:"row"},bulletPoint:{width:15,marginRight:5,fontSize:12},itemContent:{flex:1}}),Zt=(e="disc")=>{switch(e){case "circle":return "\u25CB";case "square":return "\u25A0";default:return "\u2022"}},eo=(e,t="decimal",o=1)=>{let r=o+e-1;switch(t){case "lower-alpha":return String.fromCharCode(97+r%26)+".";case "upper-alpha":return String.fromCharCode(65+r%26)+".";case "lower-roman":return nt(r).toLowerCase()+".";case "upper-roman":return nt(r)+".";default:return r+"."}},nt=e=>{if(e<=0||e>3999)return String(e);let t=[["","I","II","III","IV","V","VI","VII","VIII","IX"],["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["","M","MM","MMM"]];return t[3][Math.floor(e/1e3)]+t[2][Math.floor(e%1e3/100)]+t[1][Math.floor(e%100/10)]+t[0][e%10]},at=({children:e,style:t,type:o="disc"})=>{let r=O.Children.map(e,(a,i)=>O.isValidElement(a)?O.cloneElement(a,{bulletType:o,isOrdered:false,index:i+1}):a);return jsx(View,{style:[Q.ul,t],children:r})},it=({children:e,style:t,type:o="decimal",start:r=1})=>{let a=O.Children.map(e,(i,n)=>O.isValidElement(i)?O.cloneElement(i,{bulletType:o,isOrdered:true,index:n+1,start:r}):i);return jsx(View,{style:[Q.ol,t],children:a})},st=({children:e,style:t,bulletType:o="disc",isOrdered:r=false,index:a=1,start:i=1,value:n})=>{let s;if(r){let d=n!==void 0?Number(n):a;s=eo(d,o,i);}else s=Zt(o);return jsxs(View,{style:[Q.li,t],children:[jsx(Text,{style:Q.bulletPoint,children:s}),jsx(View,{style:Q.itemContent,children:typeof e=="string"?jsx(Text,{children:e}):e})]})};var re=StyleSheet.create({container:{position:"relative",width:"100%",height:"100%"},background:{position:"absolute",top:0,left:0,right:0,bottom:0},content:{position:"relative"}}),no=({src:e,width:t="100%",height:o="100%",opacity:r=.2,children:a,style:i,fixed:n=false,objectFit:s="cover",objectPosition:d="center"})=>jsxs(View,{style:[re.container,i],children:[jsx(Image,{src:e,style:[re.background,{width:t,height:o,opacity:r,objectFit:s,objectPosition:d}],fixed:n}),jsx(View,{style:re.content,children:a})]}),dt=no;
|
|
3
|
-
export{
|
|
1
|
+
import {StyleSheet,renderToStream,Document,Page,View,Text,Image,Link}from'@react-pdf/renderer';export{Font,StyleSheet,Text,View,renderToStream}from'@react-pdf/renderer';import O,{createContext,createElement,useContext,useState,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Dt from'qrcode';var ht=(e,t)=>{let o=atob(e),n=new Array(o.length);for(let a=0;a<o.length;a++)n[a]=o.charCodeAt(a);let i=new Uint8Array(n),s=new Blob([i],{type:"application/pdf"}),r=URL.createObjectURL(s);if(document===void 0){console.error("document is undefined, only works in browser context");return}let l=document.createElement("a");l.href=r,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),window.open(r,"_blank"),setTimeout(()=>{URL.revokeObjectURL(r);},100);},X=ht;var yt=async({template:e,data:t})=>{try{if(!e)throw new Error("Template not provided");let o=createElement(e,{data:t}),n=await renderToStream(o);return await new Promise((s,r)=>{let l=[];n.on("data",a=>l.push(a)),n.on("end",()=>s(Buffer.concat(l).toString("base64"))),n.on("error",a=>r(a));})}catch(o){throw new Error("Error generating PDF: "+(o instanceof Error?o.message:"Unknown error"))}},G=yt;var re=StyleSheet.create({page:{backgroundColor:"white",padding:30,fontFamily:"Helvetica",fontSize:14},footer:{position:"absolute",left:0,right:0,textAlign:"center"}}),xt=({children:e,size:t="A4",orientation:o="vertical",backgroundColor:n="white",padding:i=30,margen:s="normal",style:r={},pagination:l=true,footer:a,lines:c=a?2:1,rule:d=false})=>{let x=c*20+10,L=(h,P)=>{let w=P.toUpperCase();switch(h){case "apa":return w==="LETTER"||w==="LEGAL"?{paddingTop:72,paddingRight:72,paddingBottom:72,paddingLeft:72}:{paddingTop:72,paddingRight:72,paddingBottom:72,paddingLeft:72};case "estrecho":return {paddingTop:36,paddingRight:36,paddingBottom:36,paddingLeft:36};case "ancho":return {paddingTop:108,paddingRight:108,paddingBottom:108,paddingLeft:108};default:return {paddingTop:i,paddingRight:i,paddingBottom:i,paddingLeft:i}}},T=t,V=o,M=n,te=s;try{typeof t=="string"&&!["A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","LETTER","LEGAL","TABLOID"].includes(t.toUpperCase())&&(console.warn(`Invalid page size: ${t}. Using A4 as default.`),T="A4");let P=["vertical","horizontal","portrait","landscape","h","v"],w=typeof o=="string"?o.toLowerCase():"vertical";P.includes(w)?V=o:(console.warn(`Invalid orientation: ${o}. Using vertical as default.`),V="vertical"),typeof n!="string"&&(console.warn(`Invalid background color: ${n}. Using white as default.`),M="white"),["apa","normal","estrecho","ancho"].includes(s)||(console.warn(`Invalid margin type: ${s}. Using normal as default.`),te="normal"),(typeof c!="number"||c<1)&&console.warn(`Invalid lines value: ${c}. Using 1 as default.`);}catch(h){console.warn("Error processing props in LayoutPDF:",h);}let ct=h=>{switch(h){case "vertical":case "portrait":case "v":return "portrait";case "horizontal":case "landscape":case "h":return "landscape";default:return console.warn(`Unrecognized orientation: ${h}. Using portrait as default.`),"portrait"}},dt=(h,P,w)=>{let v={A0:{width:841,height:1189},A1:{width:594,height:841},A2:{width:420,height:594},A3:{width:297,height:420},A4:{width:210,height:297},A5:{width:148,height:210},A6:{width:105,height:148},A7:{width:74,height:105},A8:{width:52,height:74},A9:{width:37,height:52},LETTER:{width:216,height:279},LEGAL:{width:216,height:356},TABLOID:{width:279,height:432}},I=2.834645669,A=v[h.toUpperCase()];if(!A)return P==="landscape"?595-w-10:842-w-10;let q=A.height*I,C=A.width*I;return P==="landscape"?C-w-10:q-w-10},z=ct(V),U=L(te,T),gt=dt(T,z,x),pt=()=>{if(!d)return null;let h=28.3465,P={A0:{width:841*2.834645669,height:1189*2.834645669},A1:{width:594*2.834645669,height:841*2.834645669},A2:{width:420*2.834645669,height:594*2.834645669},A3:{width:297*2.834645669,height:420*2.834645669},A4:{width:210*2.834645669,height:297*2.834645669},A5:{width:148*2.834645669,height:210*2.834645669},A6:{width:105*2.834645669,height:148*2.834645669},A7:{width:74*2.834645669,height:105*2.834645669},A8:{width:52*2.834645669,height:74*2.834645669},A9:{width:37*2.834645669,height:52*2.834645669},LETTER:{width:216*2.834645669,height:279*2.834645669},LEGAL:{width:216*2.834645669,height:356*2.834645669},TABLOID:{width:279*2.834645669,height:432*2.834645669}},w=P[T.toUpperCase()]||P.A4,v=z==="landscape"?w.height:w.width,I=z==="landscape"?w.width:w.height,A=[],q=[];for(let C=0;C<=Math.ceil(I/h);C++)A.push(jsx(View,{style:{position:"absolute",top:C*h,left:0,right:0,height:C%5===0?1:.5,backgroundColor:C%5===0?"rgba(255, 0, 0, 0.8)":"rgba(100, 100, 100, 0.5)"}},`h-${C}`));for(let C=0;C<=Math.ceil(v/h);C++)q.push(jsx(View,{style:{position:"absolute",left:C*h,top:0,bottom:0,width:C%5===0?1:.5,backgroundColor:C%5===0?"rgba(255, 0, 0, 0.8)":"rgba(100, 100, 100, 0.5)"}},`v-${C}`));return jsxs(View,{style:{position:"absolute",top:0,left:0,right:0,bottom:0},fixed:true,children:[A,q]})},mt={...re.page,backgroundColor:M,paddingTop:r?.paddingTop??r?.padding??U.paddingTop,paddingRight:r?.paddingRight??r?.padding??U.paddingRight,paddingLeft:r?.paddingLeft??r?.padding??U.paddingLeft,paddingBottom:(r?.paddingBottom??r?.padding??U.paddingBottom)+x,...(()=>{let{padding:h,paddingTop:P,paddingRight:w,paddingBottom:v,paddingLeft:I,...A}=r||{};return A})()},oe={...re.footer,top:gt,height:x,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",fontSize:10,color:"grey"};return jsx(Document,{children:jsxs(Page,{size:T,orientation:z,style:mt,wrap:true,children:[pt(),jsx(View,{style:{paddingBottom:x},children:e}),jsxs(View,{style:oe,fixed:true,children:[a&&a,l&&jsx(Text,{style:{fontSize:oe.fontSize},render:({pageNumber:h,totalPages:P})=>`${h} / ${P}`})]})]})})},ne=xt;var Lt=StyleSheet.create({image:{width:"100%",height:"auto",marginBottom:14}}),Ft=({src:e,style:t})=>jsx(Image,{src:e,style:[Lt.image,t]}),ie=Ft;var J=StyleSheet.create({left:{textAlign:"left"},right:{textAlign:"right"},center:{textAlign:"center"}}),ae=({children:e,style:t})=>jsx(View,{style:[J.left,t],children:e}),se=({children:e,style:t})=>jsx(View,{style:[J.right,t],children:e}),le=({children:e,style:t})=>jsx(View,{style:[J.center,t],children:e});var f=StyleSheet.create({p:{fontSize:12,marginBottom:5,lineHeight:1.2},h1:{fontSize:24,fontWeight:"bold",marginBottom:12},h2:{fontSize:20,fontWeight:"bold",marginBottom:10},h3:{fontSize:18,fontWeight:"bold",marginBottom:8},h4:{fontSize:16,fontWeight:"bold",marginBottom:6},h5:{fontSize:14,fontWeight:"bold",marginBottom:4},h6:{fontSize:12,fontWeight:"bold",marginBottom:0},strong:{fontWeight:"bold"},em:{fontStyle:"italic"},u:{textDecoration:"underline"},small:{fontSize:10},blockquote:{marginLeft:20,marginRight:20,fontStyle:"italic",borderLeft:"4px solid #ccc",paddingLeft:10},mark:{backgroundColor:"yellow"},A:{color:"#3d65fd",textDecoration:"none"},br:{width:"100%",height:1,marginTop:7,marginBottom:7},header:{position:"absolute",top:20,left:0,right:0,textAlign:"center",fontSize:10,color:"#666",paddingHorizontal:40},hr:{width:"100%",borderTop:"1px solid #000",marginTop:8,marginBottom:8}}),ce=({children:e,style:t})=>jsx(Text,{style:[f.p,t],children:e}),de=({children:e,style:t})=>jsx(Text,{style:[f.h1,t],children:e}),ge=({children:e,style:t})=>jsx(Text,{style:[f.h2,t],children:e}),pe=({children:e,style:t})=>jsx(Text,{style:[f.h3,t],children:e}),me=({children:e,style:t})=>jsx(Text,{style:[f.h4,t],children:e}),he=({children:e,style:t})=>jsx(Text,{style:[f.h5,t],children:e}),fe=({children:e,style:t})=>jsx(Text,{style:[f.h6,t],children:e}),ue=({children:e,style:t})=>jsx(Text,{style:[f.strong,t],children:e}),ye=({children:e,style:t})=>jsx(Text,{style:[f.em,t],children:e}),we=({children:e,style:t})=>jsx(Text,{style:[f.u,t],children:e}),Ce=({children:e,style:t})=>jsx(Text,{style:[f.small,t],children:e}),Re=({children:e,style:t})=>jsx(Text,{style:[f.blockquote,t],children:e}),be=({children:e,style:t})=>jsx(Text,{style:[f.mark,t],children:e}),xe=({children:e,style:t,href:o})=>jsx(Link,{src:o,style:[f.A,t],children:e}),Pe=({style:e})=>jsx(Text,{style:[f.br,e],children:`
|
|
2
|
+
`}),Te=({style:e})=>jsx(View,{style:[f.hr,e]}),Le=({children:e,style:t})=>jsx(Text,{style:[t],children:e}),Fe=({children:e,style:t,fixed:o=false})=>jsx(View,{style:[f.header,t],fixed:o,children:typeof e=="string"?jsx(Text,{children:e}):e}),Ae=({children:e,style:t})=>jsx(View,{style:t,children:e});var D=createContext({cellHeight:22,textAlign:"left"}),S=StyleSheet.create({table:{width:"100%",borderWidth:1,borderColor:"#000",marginBottom:20},thead:{backgroundColor:"#ccc"},tr:{flexDirection:"row"},textBold:{fontSize:10,fontFamily:"Helvetica",fontWeight:"bold",paddingLeft:8,paddingRight:8,justifyContent:"center"},text:{fontSize:10,fontFamily:"Helvetica",paddingLeft:8,paddingRight:8,justifyContent:"center"},zebraOdd:{backgroundColor:"#eeeeee"}}),Oe=({children:e,style:t,cellHeight:o=22})=>jsx(D.Provider,{value:{cellHeight:o,textAlign:"left"},children:jsx(View,{style:[S.table,t],children:e})}),Ve=({children:e,style:t,textAlign:o="left"})=>{let{cellHeight:n}=useContext(D);return jsx(D.Provider,{value:{cellHeight:n,textAlign:o},children:jsx(View,{style:[S.thead,t],children:e})})},ve=({children:e})=>{let t=O.Children.toArray(e),o=t.length;return jsx(Fragment,{children:t.map((n,i)=>O.cloneElement(n,{isLastRow:i===o-1,isOdd:i%2===1}))})},Ie=({children:e,style:t,isLastRow:o=false,isOdd:n=false})=>{let i=O.Children.toArray(e),s=i.length;return jsx(View,{style:[S.tr,t],children:i.map((r,l)=>{let a=l===s-1,c=`${(100/s).toFixed(2)}%`;return O.cloneElement(r,{width:c,isLast:a,isLastRow:o,isOdd:n})})})},Be=({children:e,style:t,width:o,height:n,colSpan:i,isLast:s=false,isLastRow:r=false,textAlign:l})=>{let{cellHeight:a,textAlign:c}=useContext(D),d=l||c||"left",g=typeof o=="string"&&i?`${(parseFloat(o)*i).toFixed(2)}%`:o,x={borderRightWidth:s?0:1,borderBottomWidth:r?0:1,borderColor:"#000",minHeight:n!==void 0?n:a};return jsx(View,{style:[S.textBold,{width:g},x,t],children:jsx(Text,{style:{textAlign:d},children:e})})},ke=({children:e,style:t,width:o,height:n,colSpan:i,isLast:s=false,isLastRow:r=false,isOdd:l=false,textAlign:a})=>{let{cellHeight:c,textAlign:d}=useContext(D),g=a||d||"left",y=typeof o=="string"&&i?`${(parseFloat(o)*i).toFixed(2)}%`:o,L={borderRightWidth:s?0:1,borderBottomWidth:r?0:1,borderColor:"#000",minHeight:n!==void 0?n:c};return jsx(View,{style:[S.text,l&&S.zebraOdd,{width:y},L,t],children:jsx(Text,{style:{textAlign:g},children:e})})};var p=StyleSheet.create({container:{width:"100%",paddingHorizontal:20},row:{flexDirection:"row",flexWrap:"wrap",marginHorizontal:-5},col:{paddingHorizontal:5},col1:{width:"8.33%"},col2:{width:"16.66%"},col3:{width:"25%"},col4:{width:"33.33%"},col5:{width:"41.66%"},col6:{width:"50%"},col7:{width:"58.33%"},col8:{width:"66.66%"},col9:{width:"75%"},col10:{width:"83.33%"},col11:{width:"91.66%"},col12:{width:"100%"}}),De=({children:e,style:t})=>jsx(View,{style:[p.container,t],children:e}),He=({children:e,style:t})=>jsx(View,{style:[p.row,t],children:e}),Ee=({children:e,style:t})=>jsx(View,{style:[p.col,p.col1,t],children:e}),Qe=({children:e,style:t})=>jsx(View,{style:[p.col,p.col2,t],children:e}),Me=({children:e,style:t})=>jsx(View,{style:[p.col,p.col3,t],children:e}),ze=({children:e,style:t})=>jsx(View,{style:[p.col,p.col4,t],children:e}),Ue=({children:e,style:t})=>jsx(View,{style:[p.col,p.col5,t],children:e}),qe=({children:e,style:t})=>jsx(View,{style:[p.col,p.col6,t],children:e}),Ne=({children:e,style:t})=>jsx(View,{style:[p.col,p.col7,t],children:e}),$e=({children:e,style:t})=>jsx(View,{style:[p.col,p.col8,t],children:e}),We=({children:e,style:t})=>jsx(View,{style:[p.col,p.col9,t],children:e}),Xe=({children:e,style:t})=>jsx(View,{style:[p.col,p.col10,t],children:e}),Ge=({children:e,style:t})=>jsx(View,{style:[p.col,p.col11,t],children:e}),_e=({children:e,style:t})=>jsx(View,{style:[p.col,p.col12,t],children:e});var $=async({value:e,size:t=150,colorDark:o="#000000",colorLight:n="#ffffff",margin:i=0,errorCorrectionLevel:s="M"})=>{try{let r={errorCorrectionLevel:s,type:"image/png",quality:.92,margin:i,color:{dark:o,light:n},width:t};return Dt.toDataURL(e,r)}catch(r){return console.error("Error generando QR:",r),""}},je=async(e,t,o,n)=>new Promise(async i=>{if(!e||!t){i(e);return}try{let s=typeof window<"u"&&typeof window.document<"u",r,l,a;if(s)r=document.createElement("canvas"),l=r.getContext("2d"),a=window.Image;else try{let{createCanvas:d,Image:g}=await import('canvas');r=d(100,100),l=r.getContext("2d"),a=g;}catch(d){console.error("Canvas not available in Node environment for addLogoToQR",d),i(e);return}if(!l){i(e);return}let c=new a;s&&(c.crossOrigin="anonymous"),c.onload=()=>{r.width=c.width,r.height=c.height,l.drawImage(c,0,0,r.width,r.height);let d=new a;s&&(d.crossOrigin="anonymous"),d.onload=()=>{let g=(r.width-o)/2,y=(r.height-n)/2;l.fillStyle="#FFFFFF",l.fillRect(g-5,y-5,o+10,n+10),l.drawImage(d,g,y,o,n);let x=r.toDataURL("image/png");i(x);},d.onerror=g=>{console.error("Error cargando el logo:",g),i(e);},d.src=t;},c.onerror=d=>{console.error("Error cargando el QR:",d),i("");},c.src=e;}catch(s){console.error("Error procesando el QR con logo:",s),i(e);}});var Ut=StyleSheet.create({qrContainer:{display:"flex",alignItems:"center",justifyContent:"center",margin:10}}),qt={0:"L",1:"M",2:"Q",3:"H"},Nt=({value:e,size:t=150,style:o,colorDark:n="#000000",colorLight:i="#ffffff",margin:s=0,logo:r="",logoWidth:l=30,logoHeight:a=30,errorCorrectionLevel:c=r?"H":"M"})=>{let[d,g]=useState("");useEffect(()=>{(async()=>{try{let L=await $({value:e,size:t,colorDark:n,colorLight:i,margin:s,errorCorrectionLevel:typeof c=="number"?qt[c]||"M":c});if(r&&l&&a){let T=await je(L,r,l,a);g(T);}else g(L);}catch(L){console.error("Error generando QR:",L);let T=`https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(e)}&size=${t}x${t}&color=${encodeURIComponent(n.replace("#",""))}&bgcolor=${encodeURIComponent(i.replace("#",""))}`;g(T);}})();},[e,t,n,i,s,r,l,a,c]);let y=`https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(e)}&size=${t}x${t}`;return jsx(View,{style:[Ut.qrContainer,o],children:jsx(Image,{src:d||y,style:{width:t,height:t}})})},Ke=Nt;var Ye=async e=>{try{let t=typeof window<"u"&&typeof window.document<"u",o,n={};if(t)try{let c=await import('qr-code-styling');o=c.default||c;}catch(c){throw console.error("Failed to load qr-code-styling in browser",c),c}else {let c="jsdom",d="canvas",g="qr-code-styling/lib/qr-code-styling.common.js";try{let[y,x,L]=await Promise.all([import(c),import(d),import(g)]),{JSDOM:T}=y,V=x.default||x,{QRCodeStyling:M}=L;o=M,n={jsdom:T,nodeCanvas:V};}catch(y){throw console.error("Failed to load Node dependencies for QR generation",y),y}}let i=typeof e.width=="number"&&isFinite(e.width)?Math.round(e.width):300,s=typeof e.height=="number"&&isFinite(e.height)?Math.round(e.height):300,r={width:i,height:s,data:e.value,image:e.image,dotsOptions:e.dotsOptions,backgroundOptions:{color:e.backgroundOptions?.color||"#ffffff",...e.backgroundOptions},imageOptions:{crossOrigin:"anonymous",margin:typeof e.imageOptions?.margin=="number"&&isFinite(e.imageOptions.margin)?e.imageOptions.margin:0,saveAsBlob:!0,imageSize:typeof e.imageOptions?.imageSize=="number"&&isFinite(e.imageOptions.imageSize)?Math.max(0,Math.min(1,e.imageOptions.imageSize)):.4},cornersSquareOptions:e.cornersSquareOptions,cornersDotOptions:e.cornersDotOptions},a=await new o({type:"png",...n,...r}).getRawData("png");if(!a)throw new Error("Failed to generate raw data from qr-code-styling");if(t){if(a instanceof Blob)return new Promise((c,d)=>{let g=new FileReader;g.onloadend=()=>{typeof g.result=="string"?c(g.result):d(new Error("Failed to convert blob to base64"));},g.onerror=d,g.readAsDataURL(a);});console.warn("Unexpected rawData type in browser:",a);}if(typeof Buffer<"u"&&Buffer.isBuffer(a))return `data:image/png;base64,${a.toString("base64")}`;throw new Error(`Unexpected raw data type: ${typeof a}`)}catch(t){return console.error("Error generating QR V2, falling back to V1:",t),$({value:e.value,size:e.width,colorDark:e.fallbackColorDark||e.dotsOptions?.color,colorLight:e.fallbackColorLight||e.backgroundOptions?.color,margin:e.fallbackMargin||0,errorCorrectionLevel:e.fallbackErrorCorrectionLevel||"M"})}};var Gt=StyleSheet.create({qrContainer:{display:"flex",alignItems:"center",justifyContent:"center"}}),_t=({value:e,size:t=300,style:o,image:n,dotsOptions:i,backgroundOptions:s,imageOptions:r,cornersSquareOptions:l,cornersDotOptions:a,colorDark:c,colorLight:d,margin:g,errorCorrectionLevel:y})=>jsx(View,{style:[Gt.qrContainer,o],children:jsx(Image,{style:{width:t,height:t},src:Ye({value:e,width:t,height:t,image:n,dotsOptions:i||(c?{color:c}:void 0),backgroundOptions:s||(d?{color:d}:void 0),imageOptions:{...r,margin:r?.margin!==void 0?r.margin:g},cornersSquareOptions:l,cornersDotOptions:a,fallbackColorDark:c,fallbackColorLight:d,fallbackMargin:g,fallbackErrorCorrectionLevel:y})})}),et=_t;var E=StyleSheet.create({ul:{marginBottom:10,paddingLeft:15},ol:{marginBottom:10,paddingLeft:15},li:{marginBottom:5,flexDirection:"row"},bulletPoint:{width:15,marginRight:5,fontSize:12},itemContent:{flex:1}}),Jt=(e="disc")=>{switch(e){case "circle":return "\u25CB";case "square":return "\u25A0";default:return "\u2022"}},Kt=(e,t="decimal",o=1)=>{let n=o+e-1;switch(t){case "lower-alpha":return String.fromCharCode(97+n%26)+".";case "upper-alpha":return String.fromCharCode(65+n%26)+".";case "lower-roman":return ot(n).toLowerCase()+".";case "upper-roman":return ot(n)+".";default:return n+"."}},ot=e=>{if(e<=0||e>3999)return String(e);let t=[["","I","II","III","IV","V","VI","VII","VIII","IX"],["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["","M","MM","MMM"]];return t[3][Math.floor(e/1e3)]+t[2][Math.floor(e%1e3/100)]+t[1][Math.floor(e%100/10)]+t[0][e%10]},rt=({children:e,style:t,type:o="disc"})=>{let n=O.Children.map(e,(i,s)=>O.isValidElement(i)?O.cloneElement(i,{bulletType:o,isOrdered:false,index:s+1}):i);return jsx(View,{style:[E.ul,t],children:n})},nt=({children:e,style:t,type:o="decimal",start:n=1})=>{let i=O.Children.map(e,(s,r)=>O.isValidElement(s)?O.cloneElement(s,{bulletType:o,isOrdered:true,index:r+1,start:n}):s);return jsx(View,{style:[E.ol,t],children:i})},it=({children:e,style:t,bulletType:o="disc",isOrdered:n=false,index:i=1,start:s=1,value:r})=>{let l;if(n){let a=r!==void 0?Number(r):i;l=Kt(a,o,s);}else l=Jt(o);return jsxs(View,{style:[E.li,t],children:[jsx(Text,{style:E.bulletPoint,children:l}),jsx(View,{style:E.itemContent,children:typeof e=="string"?jsx(Text,{children:e}):e})]})};var ee=StyleSheet.create({container:{position:"relative",width:"100%",height:"100%"},background:{position:"absolute",top:0,left:0,right:0,bottom:0},content:{position:"relative"}}),to=({src:e,width:t="100%",height:o="100%",opacity:n=.2,children:i,style:s,fixed:r=false,objectFit:l="cover",objectPosition:a="center"})=>jsxs(View,{style:[ee.container,s],children:[jsx(Image,{src:e,style:[ee.background,{width:t,height:o,opacity:n,objectFit:l,objectPosition:a}],fixed:r}),jsx(View,{style:ee.content,children:i})]}),lt=to;
|
|
3
|
+
export{xe as A,Pe as BR,Re as Blockquote,le as Center,Ee as Col1,Xe as Col10,Ge as Col11,_e as Col12,Qe as Col2,Me as Col3,ze as Col4,Ue as Col5,qe as Col6,Ne as Col7,$e as Col8,We as Col9,De as Container,Ae as Div,ye as Em,de as H1,ge as H2,pe as H3,me as H4,he as H5,fe as H6,Te as HR,Fe as Header,ie as Img,lt as ImgBg,it as LI,ne as LayoutPDF,ae as Left,be as Mark,nt as OL,ce as P,Ke as QR,et as QRV2,se as Right,He as Row,Ce as Small,Le as Span,ue as Strong,Oe as Table,ve as Tbody,ke as Td,Be as Th,Ve as Thead,Ie as Tr,we as U,rt as UL,X as decodeBase64Pdf,G as generatePDF};//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|