react-vector-pdf 0.3.3 → 0.3.5

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.
@@ -1,6 +1,6 @@
1
- (function(H,C){typeof exports=="object"&&typeof module<"u"?C(exports,require("react"),require("jspdf")):typeof define=="function"&&define.amd?define(["exports","react","jspdf"],C):(H=typeof globalThis<"u"?globalThis:H||self,C(H.ReactVectorPdf={},H.React,H.jsPDF))})(this,(function(H,C,at){"use strict";var J={exports:{}},V={};var et;function ft(){if(et)return V;et=1;var i=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,o,s){var f=null;if(s!==void 0&&(f=""+s),o.key!==void 0&&(f=""+o.key),"key"in o){s={};for(var l in o)l!=="key"&&(s[l]=o[l])}else s=o;return o=s.ref,{$$typeof:i,type:n,key:f,ref:o!==void 0?o:null,props:s}}return V.Fragment=t,V.jsx=r,V.jsxs=r,V}var G={};var rt;function ct(){return rt||(rt=1,process.env.NODE_ENV!=="production"&&(function(){function i(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===R?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case u:return"Fragment";case X:return"Profiler";case A:return"StrictMode";case K:return"Suspense";case m:return"SuspenseList";case W:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case S:return"Portal";case U:return e.displayName||"Context";case q:return(e._context.displayName||"Context")+".Consumer";case N:var c=e.render;return e=e.displayName,e||(e=c.displayName||c.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case v:return c=e.displayName||null,c!==null?c:i(e.type)||"Memo";case _:c=e._payload,e=e._init;try{return i(e(c))}catch{}}return null}function t(e){return""+e}function r(e){try{t(e);var c=!1}catch{c=!0}if(c){c=console;var d=c.error,P=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return d.call(c,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",P),t(e)}}function n(e){if(e===u)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===_)return"<...>";try{var c=i(e);return c?"<"+c+">":"<...>"}catch{return"<...>"}}function o(){var e=p.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function f(e){if(z.call(e,"key")){var c=Object.getOwnPropertyDescriptor(e,"key").get;if(c&&c.isReactWarning)return!1}return e.key!==void 0}function l(e,c){function d(){E||(E=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",c))}d.isReactWarning=!0,Object.defineProperty(e,"key",{get:d,configurable:!0})}function g(){var e=i(this.type);return b[e]||(b[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function T(e,c,d,P,I,y){var k=d.ref;return e={$$typeof:j,type:e,key:c,props:d,_owner:P},(k!==void 0?k:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:g}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:I}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:y}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function a(e,c,d,P,I,y){var k=c.children;if(k!==void 0)if(P)if(Y(k)){for(P=0;P<k.length;P++)x(k[P]);Object.freeze&&Object.freeze(k)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else x(k);if(z.call(c,"key")){k=i(e);var M=Object.keys(c).filter(function(xt){return xt!=="key"});P=0<M.length?"{key: someKey, "+M.join(": ..., ")+": ...}":"{key: someKey}",O[k+P]||(M=0<M.length?"{"+M.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(A,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("react"),require("jspdf")):typeof define=="function"&&define.amd?define(["exports","react","jspdf"],T):(A=typeof globalThis<"u"?globalThis:A||self,T(A.ReactVectorPdf={},A.React,A.jsPDF))})(this,(function(A,T,et){"use strict";var Q={exports:{}},V={};var rt;function ct(){if(rt)return V;rt=1;var i=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,o,s){var a=null;if(s!==void 0&&(a=""+s),o.key!==void 0&&(a=""+o.key),"key"in o){s={};for(var c in o)c!=="key"&&(s[c]=o[c])}else s=o;return o=s.ref,{$$typeof:i,type:n,key:a,ref:o!==void 0?o:null,props:s}}return V.Fragment=t,V.jsx=r,V.jsxs=r,V}var G={};var ot;function lt(){return ot||(ot=1,process.env.NODE_ENV!=="production"&&(function(){function i(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===R?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case h:return"Fragment";case B:return"Profiler";case O:return"StrictMode";case K:return"Suspense";case b:return"SuspenseList";case W:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case S:return"Portal";case $:return e.displayName||"Context";case q:return(e._context.displayName||"Context")+".Consumer";case N:var l=e.render;return e=e.displayName,e||(e=l.displayName||l.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case P:return l=e.displayName||null,l!==null?l:i(e.type)||"Memo";case y:l=e._payload,e=e._init;try{return i(e(l))}catch{}}return null}function t(e){return""+e}function r(e){try{t(e);var l=!1}catch{l=!0}if(l){l=console;var g=l.error,E=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return g.call(l,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",E),t(e)}}function n(e){if(e===h)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===y)return"<...>";try{var l=i(e);return l?"<"+l+">":"<...>"}catch{return"<...>"}}function o(){var e=p.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function a(e){if(z.call(e,"key")){var l=Object.getOwnPropertyDescriptor(e,"key").get;if(l&&l.isReactWarning)return!1}return e.key!==void 0}function c(e,l){function g(){C||(C=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",l))}g.isReactWarning=!0,Object.defineProperty(e,"key",{get:g,configurable:!0})}function u(){var e=i(this.type);return w[e]||(w[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function m(e,l,g,E,M,_){var k=g.ref;return e={$$typeof:Y,type:e,key:l,props:g,_owner:E},(k!==void 0?k:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:u}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:_}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function f(e,l,g,E,M,_){var k=l.children;if(k!==void 0)if(E)if(D(k)){for(E=0;E<k.length;E++)x(k[E]);Object.freeze&&Object.freeze(k)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else x(k);if(z.call(l,"key")){k=i(e);var X=Object.keys(l).filter(function(Tt){return Tt!=="key"});E=0<X.length?"{key: someKey, "+X.join(": ..., ")+": ...}":"{key: someKey}",j[k+E]||(X=0<X.length?"{"+X.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,P,k,M,k),O[k+P]=!0)}if(k=null,d!==void 0&&(r(d),k=""+d),f(c)&&(r(c.key),k=""+c.key),"key"in c){d={};for(var tt in c)tt!=="key"&&(d[tt]=c[tt])}else d=c;return k&&l(d,typeof e=="function"?e.displayName||e.name||"Unknown":e),T(e,k,d,o(),I,y)}function x(e){h(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===_&&(e._payload.status==="fulfilled"?h(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function h(e){return typeof e=="object"&&e!==null&&e.$$typeof===j}var D=C,j=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),X=Symbol.for("react.profiler"),q=Symbol.for("react.consumer"),U=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),R=Symbol.for("react.client.reference"),p=D.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,Y=Array.isArray,L=console.createTask?console.createTask:function(){return null};D={react_stack_bottom_frame:function(e){return e()}};var E,b={},F=D.react_stack_bottom_frame.bind(D,s)(),w=L(n(s)),O={};G.Fragment=u,G.jsx=function(e,c,d){var P=1e4>p.recentlyCreatedOwnerStacks++;return a(e,c,d,!1,P?Error("react-stack-top-frame"):F,P?L(n(e)):w)},G.jsxs=function(e,c,d){var P=1e4>p.recentlyCreatedOwnerStacks++;return a(e,c,d,!0,P?Error("react-stack-top-frame"):F,P?L(n(e)):w)}})()),G}var ot;function lt(){return ot||(ot=1,process.env.NODE_ENV==="production"?J.exports=ft():J.exports=ct()),J.exports}var $=lt();function Q(i){return!i&&i!==0?{top:0,right:0,bottom:0,left:0}:typeof i=="number"?{top:i,right:i,bottom:i,left:i}:{top:i.top??0,right:i.right??0,bottom:i.bottom??0,left:i.left??0}}function Z(i){const t=i.replace("#","");if(t.length===3){const r=parseInt(t[0]+t[0],16),n=parseInt(t[1]+t[1],16),o=parseInt(t[2]+t[2],16);return[r,n,o]}if(t.length===6){const r=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),o=parseInt(t.slice(4,6),16);return[r,n,o]}return null}function nt(i,t=!0){if(i<=0)return String(i);const r=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let n=i,o="";for(const[s,f]of r)for(;n>=s;)o+=f,n-=s;return t?o:o.toLowerCase()}class it{constructor(t={}){this.cursorX=0,this.cursorY=0,this.contentWidth=0,this.margin={top:15,right:15,bottom:15,left:15},this.defaultFont={name:void 0,style:"normal",size:12},this.defaultColor="#111827",this.defaultLineHeight=1.25,this.pendingTasks=new Set,this.opQueue=Promise.resolve(),this.margin=t.margin??this.margin,this.defaultFont={name:t.font?.name,style:t.font?.style??"normal",size:t.font?.size??12},this.defaultColor=t.color??this.defaultColor,this.defaultLineHeight=t.lineHeight??this.defaultLineHeight,this.pdf=new at.jsPDF({unit:t.unit??"mm",format:t.format??"a4",orientation:t.orientation??"p"}),this.pageWidth=this.pdf.internal.pageSize.getWidth(),this.pageHeight=this.pdf.internal.pageSize.getHeight(),this.resetFlowCursor(),this.applyBaseFont()}get instance(){return this.pdf}get width(){return this.pageWidth}get height(){return this.pageHeight}get contentLeft(){return this.margin.left}get contentRight(){return this.pageWidth-this.margin.right}get contentTop(){return this.margin.top}get contentBottom(){return this.pageHeight-this.margin.bottom}get contentHeight(){return this.contentBottom-this.contentTop}get contentAreaWidth(){return this.contentWidth}get baseFont(){return this.defaultFont}get baseLineHeight(){return this.defaultLineHeight}resetFlowCursor(){this.cursorX=this.margin.left,this.cursorY=this.margin.top,this.contentWidth=this.pageWidth-this.margin.left-this.margin.right}setHeaderFooter(t,r){this.headerDrawer=t,this.footerDrawer=r}applyBaseFont(){const t=this.defaultFont.name??this.pdf.getFont().fontName;this.pdf.setFont(t,this.defaultFont.style),this.pdf.setFontSize(this.defaultFont.size);const r=Z(this.defaultColor);r&&this.pdf.setTextColor(...r)}addPage(){this.pdf.addPage(),this.resetFlowCursor()}ensureSpace(t){this.cursorY+t>this.contentBottom&&this.addPage()}setTextStyle(t){if(t){if(t.fontSize&&this.pdf.setFontSize(t.fontSize),t.fontStyle){const r=this.pdf.getFont().fontName;this.pdf.setFont(r,t.fontStyle)}if(t.color){const r=Z(t.color);r&&this.pdf.setTextColor(...r)}}}textRaw(t,r,n,o,s,f="left"){this.setTextStyle(o);const l={align:f};typeof s=="number"&&(l.maxWidth=s),this.pdf.text(t,r,n,l),this.applyBaseFont()}box(t,r,n,o,s){const f=s??{};if(f.fillColor){const l=Z(f.fillColor);l&&this.pdf.setFillColor(...l),this.pdf.rect(t,r,n,o,"F")}if(f.borderWidth||f.borderColor){if(f.borderWidth&&this.pdf.setLineWidth(f.borderWidth),f.borderColor){const l=Z(f.borderColor);l&&this.pdf.setDrawColor(...l)}this.pdf.rect(t,r,n,o),this.pdf.setLineWidth(.2),this.pdf.setDrawColor(0,0,0)}}line(t,r,n,o){this.pdf.line(t,r,n,o)}async imageFromUrl(t,r={}){const n=(async()=>{try{const{dataUrl:o,width:s,height:f}=await this.loadImageAsDataURL(t),l=.264583,g=s*l,T=f*l;let a=r.w,x=r.h;a===void 0&&x===void 0?(a=g,x=T):a===void 0&&x!==void 0?a=x*(g/T):x===void 0&&a!==void 0&&(x=a*(T/g));const h=a??g,D=x??T;let j=r.x,S=r.y??this.cursorY;if(r.y===void 0&&S+D>this.contentBottom&&(this.addPage(),S=this.cursorY),j===void 0){const u=r.align??"left";u==="left"?j=this.contentLeft:u==="center"?j=(this.contentLeft+this.contentRight)/2-h/2:u==="right"&&(j=this.contentRight-h)}return this.pdf.addImage(o,r.mime??"PNG",j,S,h,D),{width:h,height:D,x:j,y:S}}catch(o){return console.error("Failed to load image",t,o),{width:0,height:0,x:0,y:0}}})();return this.registerTask(n),n}queueOperation(t){const r=this.opQueue.then(async()=>{try{await t()}catch(n){console.error("Operation failed",n)}});this.opQueue=r,this.registerTask(r)}registerTask(t){this.pendingTasks.add(t),t.finally(()=>{this.pendingTasks.delete(t)})}async waitForTasks(){await Promise.all(this.pendingTasks),await this.opQueue}loadImageAsDataURL(t){return new Promise((r,n)=>{const o=new Image;o.crossOrigin="anonymous",o.onload=()=>{const s=document.createElement("canvas");s.width=o.width,s.height=o.height;const f=s.getContext("2d");if(!f)return n(new Error("Canvas 2D context not available"));f.drawImage(o,0,0),r({dataUrl:s.toDataURL("image/png"),width:o.width,height:o.height})},o.onerror=s=>n(s),o.src=t})}paragraph(t,r,n){const o=n??this.contentWidth;this.setTextStyle(r);const s=r?.lineHeight??this.defaultLineHeight,f=r?.fontSize??this.defaultFont.size,l=f*s*.3528,g=this.pdf.splitTextToSize(t,o),T=r?.align??"left";let a=0;return g.forEach(x=>{this.cursorY+l>this.contentBottom&&this.addPage();const h=this.cursorY+f*.3528;this.pdf.text(x,this.cursorX,h,{align:T,maxWidth:o}),this.cursorY+=l,a+=l}),this.cursorY+=1,this.applyBaseFont(),a}moveCursor(t,r){this.cursorX+=t,this.cursorY+=r}setCursor(t,r){this.cursorX=t,this.cursorY=r}getCursor(){return{x:this.cursorX,y:this.cursorY}}getPageCount(){return this.pdf.getNumberOfPages()}applyHeaderFooter(){const t=this.getPageCount();if(!(!this.headerDrawer&&!this.footerDrawer)){for(let r=1;r<=t;r++)this.pdf.setPage(r),this.headerDrawer&&this.headerDrawer(this.pdf,r,t,this),this.footerDrawer&&this.footerDrawer(this.pdf,r,t,this);this.pdf.setPage(t)}}measureText(t,r,n){this.setTextStyle(r);const o=r?.fontSize??this.defaultFont.size,s=r?.lineHeight??this.defaultLineHeight,f=o*s*.3528;if(n){const l=this.pdf.splitTextToSize(t,n);return{width:n,height:l.length*f}}else{const l=this.pdf.getTextDimensions(t);return{width:l.w,height:l.h}}}setMetadata(t){t.title&&this.pdf.setDocumentProperties({title:t.title}),t.author&&this.pdf.setDocumentProperties({author:t.author}),t.subject&&this.pdf.setDocumentProperties({subject:t.subject}),t.keywords&&this.pdf.setDocumentProperties({keywords:t.keywords.join(", ")})}save(t){this.applyHeaderFooter(),this.pdf.save(t)}}const st=C.createContext(null),B=()=>{const i=C.useContext(st);if(!i)throw new Error("usePdf must be used within <PdfDocument>");return i},ut=({options:i,header:t,footer:r,pageNumbers:n,centerLabel:o,metadata:s,children:f,onReady:l,filename:g,autoSave:T=!1})=>{const[a]=C.useState(()=>new it(i));return C.useEffect(()=>{s&&a.setMetadata(s)},[a,s]),C.useEffect(()=>{const x=(S,u)=>!u||u==="all"?!0:u==="first-only"?S===1:u==="except-first"?S>1:Array.isArray(u)?u.includes(S):!0,h=(S,u)=>u==="roman-upper"?nt(S,!0):u==="roman-lower"?nt(S,!1):String(S),D=(S,u,A)=>{if(!n?.enabled||!x(u,n.scope))return;const X=n.preset??"page-slash-total",U=(n.template??(X==="page-slash-total"?"Page {page}/{total}":X==="page-of-total"?"Page {page} of {total}":"{page}/{total}")).replace("{page}",h(u,n.format)).replace("{total}",h(A,n.format)),N=n.align??"right",K=N==="left"?a.contentLeft+(n.offsetX??0):N==="right"?a.contentRight-(n.offsetX??0):(a.contentLeft+a.contentRight)/2+(n.offsetX??0),m=S==="header"?10:a.height-7,v=typeof n.y=="number"?n.y:m;a.textRaw(U,K,v,n.style,void 0,N)},j=(S,u,A)=>{if(!o?.enabled||!x(u,o.scope))return;const X="center",q=(a.contentLeft+a.contentRight)/2+(o.offsetX??0),U=S==="header"?10:a.height-7,N=typeof o.y=="number"?o.y:U;a.textRaw(o.text,q,N,o.style,void 0,X)};a.setHeaderFooter((S,u,A)=>{t&&t(a,u,A),n?.position==="header"&&D("header",u,A),o?.position==="header"&&j("header",u)},(S,u,A)=>{n?.position==="footer"&&D("footer",u,A),r&&r(a,u,A),o?.position==="footer"&&j("footer",u)}),a.waitForTasks().then(()=>{l?.(a)})},[]),C.useEffect(()=>{T&&g&&a.save(g)},[T,g]),$.jsx(st.Provider,{value:a,children:f})},ht=({x:i,y:t,w:r,h:n,children:o,...s})=>{const f=B(),l=Q(s.padding),g={top:s.paddingTop??l.top,right:s.paddingRight??l.right,bottom:s.paddingBottom??l.bottom,left:s.paddingLeft??l.left},T=C.useRef({}).current;return typeof i=="number"&&typeof t=="number"&&typeof r=="number"&&typeof n=="number"?(C.useEffect(()=>{f.queueOperation(()=>{f.box(i,t,r,n,s)})},[i,t,r,n]),$.jsx(C.Fragment,{children:o})):(C.useEffect(()=>{f.queueOperation(()=>{const a=f.getCursor();T.start={...a};const x=a.x+g.left,h=a.y+g.top;f.setCursor(x,h)})},[]),$.jsxs(C.Fragment,{children:[o,$.jsx(dt,{boxState:T,pad:g,style:s})]}))},dt=({boxState:i,style:t,pad:r})=>{const n=B();return C.useEffect(()=>{n.queueOperation(()=>{const o=i.start;if(!o)return;const s=n.getCursor(),l=Math.max(s.y-o.y-r.top,0)+r.top+r.bottom;n.box(o.x,o.y,n.contentAreaWidth,l,t),n.setCursor(o.x,o.y+l)})},[]),null},gt=({src:i,x:t,y:r,w:n,h:o,mime:s="PNG",flow:f,align:l="left"})=>{const g=B();return C.useEffect(()=>{const T=f===!0||t===void 0&&r===void 0,a=t,x=r;g.queueOperation(async()=>{const h=await g.imageFromUrl(i,{x:a,y:x,w:n,h:o,mime:s,align:l});T&&h&&g.moveCursor(0,h.height+2)})},[i,t,r,n,o,s,f,l]),null},pt=({items:i,ordered:t=!1,style:r,indent:n=5,markerWidth:o=5,spacing:s=2})=>{const f=B();return C.useEffect(()=>{f.queueOperation(()=>{i.forEach((l,g)=>{const T=t?`${g+1}.`:"•",a=f.getCursor().y,x=f.getCursor().x,h=x+n+o,D=r?.fontSize??f.baseFont.size,j=a+D*.3528;f.textRaw(T,x+n,j,r,o,"right"),f.setCursor(h,a);const S=f.contentRight-h;f.paragraph(l,r,S);const u=f.getCursor().y;f.setCursor(x,u+s)})})},[i,t,r,n,o,s]),null},mt=({data:i,columns:t,width:r="100%",borderWidth:n=.1,borderColor:o="#000000",cellPadding:s=2,headerStyle:f,rowStyle:l,alternateRowStyle:g,headerHeight:T})=>{const a=B();return C.useEffect(()=>{a.queueOperation(()=>{const x=typeof r=="number"?r:parseFloat(r)/100*a.contentAreaWidth,h=t.map(m=>typeof m.width=="number"?m.width:typeof m.width=="string"&&m.width.endsWith("%")?parseFloat(m.width)/100*x:0),D=h.reduce((m,v)=>m+v,0),j=Math.max(0,x-D),S=h.filter(m=>m===0).length;if(S>0){const m=j/S;for(let v=0;v<h.length;v++)h[v]===0&&(h[v]=m)}const u=(m,v,_,W,R,p,z="left",Y=!0)=>{Y&&a.box(v,_,W,R,{borderColor:p.borderColor??o,borderWidth:p.borderWidth??n,fillColor:p.fillColor});const L=Q(p.padding??s),E={top:p.paddingTop??L.top,right:p.paddingRight??L.right,bottom:p.paddingBottom??L.bottom,left:p.paddingLeft??L.left},b=W-E.left-E.right,F=a.instance.splitTextToSize(m,b,p),w=(p.fontSize??a.baseFont.size)*(p.lineHeight??a.baseLineHeight)*.3528,O=(p.fontSize??a.baseFont.size)*.3528,e=F.length*w,c=R-E.top-E.bottom;let d=0;p.verticalAlign==="middle"?d=Math.max(0,(c-e)/2):p.verticalAlign==="bottom"&&(d=Math.max(0,c-e));let P=_+E.top+d+O;const I=p.align??z,y=a.getCursor();F.forEach(k=>{let M=v+E.left;I==="center"?M=v+W/2:I==="right"&&(M=v+W-E.right),a.textRaw(k,M,P,p,void 0,I),P+=w}),a.setCursor(y.x,y.y)};let A=a.getCursor().y;const X=a.getCursor().x,q=T??10;A+q>a.contentBottom&&(a.addPage(),A=a.getCursor().y);let U=X;t.forEach((m,v)=>{const _=h[v];u(m.header??"",U,A,_,q,f??{fontStyle:"bold"},m.align??"left"),U+=_}),A+=q,a.setCursor(X,A);const N=(m,v,_)=>{const W=Q(s),R={top:_.paddingTop??W.top,right:_.paddingRight??W.right,bottom:_.paddingBottom??W.bottom,left:_.paddingLeft??W.left},p=v-R.left-R.right;return a.measureText(m,_,p).height+R.top+R.bottom};new Array(t.length).fill(0),(()=>{const m=new Array(i.length).fill(0);for(let R=0;R<i.length;R++){const p=i[R];let z=0;for(let Y=0;Y<t.length;Y++){const L=t[Y],E=typeof L.accessor=="function"?L.accessor(p):p[L.accessor];let b="",F=l,w=1,O=1;if(E&&typeof E=="object"&&E.content!==void 0?(b=String(E.content),E.style&&(F=E.style),E.colSpan&&(w=E.colSpan),E.rowSpan&&(O=E.rowSpan)):b=String(E??""),O>1){Y+=w-1;continue}let e=h[Y];for(let d=1;d<w;d++)Y+d<h.length&&(e+=h[Y+d]);const c=N(b,e,F??{});c>z&&(z=c),Y+=w-1}z<8&&(z=8),m[R]=z}let v=A;const _=new Array(t.length).fill(0),W=a.getCursor().x;for(let R=0;R<i.length;R++){const p=i[R],z=m[R];let Y=z;for(let b=0;b<t.length;b++){const F=t[b],w=typeof F.accessor=="function"?F.accessor(p):p[F.accessor];let O=1;if(w&&typeof w=="object"&&w.rowSpan&&(O=w.rowSpan),O>1){let e=0;for(let c=0;c<O;c++)R+c<m.length&&(e+=m[R+c]);e>Y&&(Y=e)}}const L=Math.abs(v-(a.contentTop+(T??10)))<1;if(v+Y>a.contentBottom&&!L&&(a.addPage(),v=a.getCursor().y,T!==0)){let b=W;t.forEach((F,w)=>{const O=h[w];u(F.header??"",b,v,O,T??10,f??{fontStyle:"bold"},F.align??"left"),b+=O}),v+=T??10}let E=W;for(let b=0;b<t.length;b++){if(_[b]>0){_[b]--,E+=h[b];continue}const F=t[b],w=typeof F.accessor=="function"?F.accessor(p):p[F.accessor];let O=1,e=1,c=R%2===1&&g?g:l,d="";w&&typeof w=="object"&&w.content!==void 0?(d=String(w.content),w.colSpan&&(O=w.colSpan),w.rowSpan&&(e=w.rowSpan),w.style&&(c={...c,...w.style})):d=String(w??"");let P=h[b];for(let y=1;y<O;y++)b+y<h.length&&(P+=h[b+y]);let I=z;if(e>1)for(let y=1;y<e;y++)R+y<m.length&&(I+=m[R+y]);if(u(d,E,v,P,I,c??{},F.align??"left",!0),e>1){_[b]=e-1;for(let y=1;y<O;y++)b+y<_.length&&(_[b+y]=e-1)}E+=P,b+=O-1}v+=z}a.setCursor(W,v)})()})},[i,t,r]),null},bt=({children:i,x:t,y:r,maxWidth:n,spacingBelow:o=2,...s})=>{const f=B();return C.useEffect(()=>{f.queueOperation(()=>{if(typeof t=="number"&&typeof r=="number")f.textRaw(i,t,r,s,n,s.align);else{f.paragraph(i,s,n);const l=f.getCursor();f.setCursor(l.x,l.y+o)}})},[i,t,r,n,o,s.fontSize,s.align]),null};function wt(i){return typeof i=="number"?{top:i,right:i,bottom:i,left:i}:{top:i?.top??0,right:i?.right??0,bottom:i?.bottom??0,left:i?.left??0}}const vt=({style:i={},children:t})=>{const r=B(),n=Q(i.padding),o={top:i.paddingTop??n.top,right:i.paddingRight??n.right,bottom:i.paddingBottom??n.bottom,left:i.paddingLeft??n.left},s=wt(i.margin),f={top:i.marginTop??s.top,right:i.marginRight??s.right,bottom:i.marginBottom??s.bottom,left:i.marginLeft??s.left},l=C.useRef({}).current;return C.useEffect(()=>{r.queueOperation(()=>{f.top>0&&r.moveCursor(0,f.top);const g=r.getCursor();l.start={...g},r.setCursor(g.x+o.left,g.y+o.top)})},[]),$.jsxs(C.Fragment,{children:[t,$.jsx(Tt,{viewState:l,style:i,pad:o,margin:f})]})},Tt=({viewState:i,style:t,pad:r,margin:n})=>{const o=B();return C.useEffect(()=>{o.queueOperation(()=>{const s=i.start;if(!s)return;const f=o.getCursor();let g=Math.max(f.y-s.y-r.top,0)+r.top+r.bottom;t.height&&(g=t.height);let T=o.contentAreaWidth;typeof t.width=="number"&&(T=t.width),(t.borderColor||t.fillColor||t.borderWidth)&&o.box(s.x,s.y,T,g,t);const a=s.y+g+n.bottom;o.setCursor(s.x,a)})},[]),null};H.PdfBox=ht,H.PdfDocument=ut,H.PdfImage=gt,H.PdfList=pt,H.PdfRenderer=it,H.PdfTable=mt,H.PdfText=bt,H.PdfView=vt,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})}));
6
+ <%s key={someKey} {...props} />`,E,k,X,k),j[k+E]=!0)}if(k=null,g!==void 0&&(r(g),k=""+g),a(l)&&(r(l.key),k=""+l.key),"key"in l){g={};for(var tt in l)tt!=="key"&&(g[tt]=l[tt])}else g=l;return k&&c(g,typeof e=="function"?e.displayName||e.name||"Unknown":e),m(e,k,g,o(),M,_)}function x(e){d(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===y&&(e._payload.status==="fulfilled"?d(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function d(e){return typeof e=="object"&&e!==null&&e.$$typeof===Y}var H=T,Y=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),q=Symbol.for("react.consumer"),$=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),R=Symbol.for("react.client.reference"),p=H.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,D=Array.isArray,L=console.createTask?console.createTask:function(){return null};H={react_stack_bottom_frame:function(e){return e()}};var C,w={},F=H.react_stack_bottom_frame.bind(H,s)(),v=L(n(s)),j={};G.Fragment=h,G.jsx=function(e,l,g){var E=1e4>p.recentlyCreatedOwnerStacks++;return f(e,l,g,!1,E?Error("react-stack-top-frame"):F,E?L(n(e)):v)},G.jsxs=function(e,l,g){var E=1e4>p.recentlyCreatedOwnerStacks++;return f(e,l,g,!0,E?Error("react-stack-top-frame"):F,E?L(n(e)):v)}})()),G}var nt;function ut(){return nt||(nt=1,process.env.NODE_ENV==="production"?Q.exports=ct():Q.exports=lt()),Q.exports}var I=ut();function Z(i){return!i&&i!==0?{top:0,right:0,bottom:0,left:0}:typeof i=="number"?{top:i,right:i,bottom:i,left:i}:{top:i.top??0,right:i.right??0,bottom:i.bottom??0,left:i.left??0}}function J(i){const t=i.replace("#","");if(t.length===3){const r=parseInt(t[0]+t[0],16),n=parseInt(t[1]+t[1],16),o=parseInt(t[2]+t[2],16);return[r,n,o]}if(t.length===6){const r=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),o=parseInt(t.slice(4,6),16);return[r,n,o]}return null}function it(i,t=!0){if(i<=0)return String(i);const r=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let n=i,o="";for(const[s,a]of r)for(;n>=s;)o+=a,n-=s;return t?o:o.toLowerCase()}class st{constructor(t={}){this.cursorX=0,this.cursorY=0,this.contentWidth=0,this.margin={top:15,right:15,bottom:15,left:15},this.defaultFont={name:void 0,style:"normal",size:12},this.defaultColor="#111827",this.defaultLineHeight=1.25,this.pendingTasks=new Set,this.opQueue=Promise.resolve(),this.generation=0,this.options=t,this.margin=t.margin??this.margin,this.defaultFont={name:t.font?.name,style:t.font?.style??"normal",size:t.font?.size??12},this.defaultColor=t.color??this.defaultColor,this.defaultLineHeight=t.lineHeight??this.defaultLineHeight,this.pdf=new et.jsPDF({unit:t.unit??"mm",format:t.format??"a4",orientation:t.orientation??"p"}),this.pageWidth=this.pdf.internal.pageSize.getWidth(),this.pageHeight=this.pdf.internal.pageSize.getHeight(),this.resetFlowCursor(),this.applyBaseFont()}get instance(){return this.pdf}get width(){return this.pageWidth}get height(){return this.pageHeight}get contentLeft(){return this.margin.left}get contentRight(){return this.pageWidth-this.margin.right}get contentTop(){return this.margin.top}get contentBottom(){return this.pageHeight-this.margin.bottom}get contentHeight(){return this.contentBottom-this.contentTop}get contentAreaWidth(){return this.contentWidth}get baseFont(){return this.defaultFont}get baseLineHeight(){return this.defaultLineHeight}resetFlowCursor(){this.cursorX=this.margin.left,this.cursorY=this.margin.top,this.contentWidth=this.pageWidth-this.margin.left-this.margin.right}reset(){if(this.pdf=new et.jsPDF({unit:this.options.unit??"mm",format:this.options.format??"a4",orientation:this.options.orientation??"p"}),this.generation++,this.cursorX=0,this.cursorY=0,this.pendingTasks=new Set,this.opQueue=Promise.resolve(),this.resetFlowCursor(),this.applyBaseFont(),this.options.color){const t=J(this.options.color);t&&this.pdf.setTextColor(...t)}}setHeaderFooter(t,r){this.headerDrawer=t,this.footerDrawer=r}applyBaseFont(){const t=this.defaultFont.name??this.pdf.getFont().fontName;this.pdf.setFont(t,this.defaultFont.style),this.pdf.setFontSize(this.defaultFont.size);const r=J(this.defaultColor);r&&this.pdf.setTextColor(...r)}addPage(){this.pdf.addPage(),this.resetFlowCursor()}ensureSpace(t){this.cursorY+t>this.contentBottom&&this.addPage()}setTextStyle(t){if(t){if(t.fontSize&&this.pdf.setFontSize(t.fontSize),t.fontStyle){const r=this.pdf.getFont().fontName;this.pdf.setFont(r,t.fontStyle)}if(t.color){const r=J(t.color);r&&this.pdf.setTextColor(...r)}}}textRaw(t,r,n,o,s,a="left"){this.setTextStyle(o);const c={align:a};typeof s=="number"&&(c.maxWidth=s),this.pdf.text(t,r,n,c),this.applyBaseFont()}box(t,r,n,o,s){const a=s??{};if(a.fillColor){const c=J(a.fillColor);c&&this.pdf.setFillColor(...c),this.pdf.rect(t,r,n,o,"F")}if(a.borderWidth||a.borderColor){if(a.borderWidth&&this.pdf.setLineWidth(a.borderWidth),a.borderColor){const c=J(a.borderColor);c&&this.pdf.setDrawColor(...c)}this.pdf.rect(t,r,n,o),this.pdf.setLineWidth(.2),this.pdf.setDrawColor(0,0,0)}}line(t,r,n,o){this.pdf.line(t,r,n,o)}async imageFromUrl(t,r={}){const n=(async()=>{try{const{dataUrl:o,width:s,height:a}=await this.loadImageAsDataURL(t),c=.264583,u=s*c,m=a*c;let f=r.w,x=r.h;f===void 0&&x===void 0?(f=u,x=m):f===void 0&&x!==void 0?f=x*(u/m):x===void 0&&f!==void 0&&(x=f*(m/u));const d=f??u,H=x??m;let Y=r.x,S=r.y??this.cursorY;if(r.y===void 0&&S+H>this.contentBottom&&(this.addPage(),S=this.cursorY),Y===void 0){const h=r.align??"left";h==="left"?Y=this.contentLeft:h==="center"?Y=(this.contentLeft+this.contentRight)/2-d/2:h==="right"&&(Y=this.contentRight-d)}return this.pdf.addImage(o,r.mime??"PNG",Y,S,d,H),{width:d,height:H,x:Y,y:S}}catch(o){return console.error("Failed to load image",t,o),{width:0,height:0,x:0,y:0}}})();return this.registerTask(n),n}queueOperation(t){const r=this.generation,n=this.opQueue.then(async()=>{if(this.generation===r)try{await t()}catch(o){console.error("Operation failed",o)}});this.opQueue=n,this.registerTask(n)}registerTask(t){this.pendingTasks.add(t),t.finally(()=>{this.pendingTasks.delete(t)})}async waitForTasks(){await Promise.all(this.pendingTasks),await this.opQueue}loadImageAsDataURL(t){return new Promise((r,n)=>{const o=new Image;o.crossOrigin="anonymous",o.onload=()=>{const s=document.createElement("canvas");s.width=o.width,s.height=o.height;const a=s.getContext("2d");if(!a)return n(new Error("Canvas 2D context not available"));a.drawImage(o,0,0),r({dataUrl:s.toDataURL("image/png"),width:o.width,height:o.height})},o.onerror=s=>n(s),o.src=t})}paragraph(t,r,n){const o=n??this.contentWidth;this.setTextStyle(r);const s=r?.lineHeight??this.defaultLineHeight,a=r?.fontSize??this.defaultFont.size,c=a*s*.3528,u=this.pdf.splitTextToSize(t,o),m=r?.align??"left";let f=0;return u.forEach(x=>{this.cursorY+c>this.contentBottom&&this.addPage();const d=this.cursorY+a*.3528;this.pdf.text(x,this.cursorX,d,{align:m,maxWidth:o}),this.cursorY+=c,f+=c}),this.cursorY+=1,this.applyBaseFont(),f}moveCursor(t,r){this.cursorX+=t,this.cursorY+=r}setCursor(t,r){this.cursorX=t,this.cursorY=r}getCursor(){return{x:this.cursorX,y:this.cursorY}}getPageCount(){return this.pdf.getNumberOfPages()}applyHeaderFooter(){const t=this.getPageCount();if(!(!this.headerDrawer&&!this.footerDrawer)){for(let r=1;r<=t;r++)this.pdf.setPage(r),this.headerDrawer&&this.headerDrawer(this.pdf,r,t,this),this.footerDrawer&&this.footerDrawer(this.pdf,r,t,this);this.pdf.setPage(t)}}measureText(t,r,n){this.setTextStyle(r);const o=r?.fontSize??this.defaultFont.size,s=r?.lineHeight??this.defaultLineHeight,a=o*s*.3528;if(n){const c=this.pdf.splitTextToSize(t,n);return{width:n,height:c.length*a}}else{const c=this.pdf.getTextDimensions(t);return{width:c.w,height:c.h}}}setMetadata(t){t.title&&this.pdf.setDocumentProperties({title:t.title}),t.author&&this.pdf.setDocumentProperties({author:t.author}),t.subject&&this.pdf.setDocumentProperties({subject:t.subject}),t.keywords&&this.pdf.setDocumentProperties({keywords:t.keywords.join(", ")})}save(t){this.applyHeaderFooter(),this.pdf.save(t)}getBlobUrl(){return this.applyHeaderFooter(),this.pdf.output("bloburl")}}const at=T.createContext(null),U=()=>{const i=T.useContext(at);if(!i)throw new Error("usePdf must be used within <PdfDocument>");return i},ft=({options:i,header:t,footer:r,pageNumbers:n,centerLabel:o,metadata:s,children:a,onReady:c,filename:u,autoSave:m=!1})=>{const f=T.useMemo(()=>new st(i),[i]);return T.useEffect(()=>{s&&f.setMetadata(s)},[f,s]),T.useEffect(()=>{const x=(S,h)=>!h||h==="all"?!0:h==="first-only"?S===1:h==="except-first"?S>1:Array.isArray(h)?h.includes(S):!0,d=(S,h)=>h==="roman-upper"?it(S,!0):h==="roman-lower"?it(S,!1):String(S),H=(S,h,O)=>{if(!n?.enabled||!x(h,n.scope))return;const B=n.preset??"page-slash-total",$=(n.template??(B==="page-slash-total"?"Page {page}/{total}":B==="page-of-total"?"Page {page} of {total}":"{page}/{total}")).replace("{page}",d(h,n.format)).replace("{total}",d(O,n.format)),N=n.align??"right",K=N==="left"?f.contentLeft+(n.offsetX??0):N==="right"?f.contentRight-(n.offsetX??0):(f.contentLeft+f.contentRight)/2+(n.offsetX??0),b=S==="header"?10:f.height-7,P=typeof n.y=="number"?n.y:b;f.textRaw($,K,P,n.style,void 0,N)},Y=(S,h,O)=>{if(!o?.enabled||!x(h,o.scope))return;const B="center",q=(f.contentLeft+f.contentRight)/2+(o.offsetX??0),$=S==="header"?10:f.height-7,N=typeof o.y=="number"?o.y:$;f.textRaw(o.text,q,N,o.style,void 0,B)};return f.setHeaderFooter((S,h,O)=>{t&&t(f,h,O),n?.position==="header"&&H("header",h,O),o?.position==="header"&&Y("header",h)},(S,h,O)=>{n?.position==="footer"&&H("footer",h,O),r&&r(f,h,O),o?.position==="footer"&&Y("footer",h)}),f.waitForTasks().then(()=>{c?.(f)}),()=>{f.reset()}},[f]),T.useEffect(()=>{m&&u&&f.save(u)},[m,u]),I.jsx(at.Provider,{value:f,children:a})},ht=({x:i,y:t,w:r,h:n,children:o,...s})=>{const a=U(),c=Z(s.padding),u={top:s.paddingTop??c.top,right:s.paddingRight??c.right,bottom:s.paddingBottom??c.bottom,left:s.paddingLeft??c.left},m=T.useRef({}).current;return typeof i=="number"&&typeof t=="number"&&typeof r=="number"&&typeof n=="number"?(T.useEffect(()=>{a.queueOperation(()=>{a.box(i,t,r,n,s)})},[a,i,t,r,n]),I.jsx(T.Fragment,{children:o})):(T.useEffect(()=>{a.queueOperation(()=>{const f=a.getCursor();m.start={...f};const x=f.x+u.left,d=f.y+u.top;a.setCursor(x,d)})},[a]),I.jsxs(T.Fragment,{children:[o,I.jsx(dt,{boxState:m,pad:u,style:s})]}))},dt=({boxState:i,style:t,pad:r})=>{const n=U();return T.useEffect(()=>{n.queueOperation(()=>{const o=i.start;if(!o)return;const s=n.getCursor(),c=Math.max(s.y-o.y-r.top,0)+r.top+r.bottom;n.box(o.x,o.y,n.contentAreaWidth,c,t),n.setCursor(o.x,o.y+c)})},[n]),null},gt=({src:i,x:t,y:r,w:n,h:o,mime:s="PNG",flow:a,align:c="left"})=>{const u=U();return T.useEffect(()=>{const m=a===!0||t===void 0&&r===void 0,f=t,x=r;u.queueOperation(async()=>{const d=await u.imageFromUrl(i,{x:f,y:x,w:n,h:o,mime:s,align:c});m&&d&&u.moveCursor(0,d.height+2)})},[u,i,t,r,n,o,s,a,c]),null},pt=({items:i,ordered:t=!1,style:r,indent:n=5,markerWidth:o=5,spacing:s=2})=>{const a=U();return T.useEffect(()=>{a.queueOperation(()=>{i.forEach((c,u)=>{const m=t?`${u+1}.`:"•",f=a.getCursor().y,x=a.getCursor().x,d=x+n+o,H=r?.fontSize??a.baseFont.size,Y=f+H*.3528;a.textRaw(m,x+n,Y,r,o,"right"),a.setCursor(d,f);const S=a.contentRight-d;a.paragraph(c,r,S);const h=a.getCursor().y;a.setCursor(x,h+s)})})},[a,i,t,r,n,o,s]),null},mt=({width:i="100%",height:t="500px",className:r,style:n,iframeClassName:o,iframeStyle:s,...a})=>{const[c,u]=T.useState(null),m=f=>{const x=f.getBlobUrl();u(x.toString())};return I.jsxs("div",{className:r,style:{width:i,height:t,...n},children:[I.jsx("div",{style:{display:"none"},children:I.jsx(ft,{...a,onReady:m,autoSave:!1,children:a.children})}),c?I.jsx("iframe",{src:c,width:"100%",height:"100%",className:o,style:{border:"none",...s},title:"PDF Preview"}):I.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f3f4f6",color:"#6b7280"},children:"Generating Preview..."})]})},bt=({data:i,columns:t,width:r="100%",borderWidth:n=.1,borderColor:o="#000000",cellPadding:s=2,headerStyle:a,rowStyle:c,alternateRowStyle:u,headerHeight:m})=>{const f=U();return T.useEffect(()=>{f.queueOperation(()=>{const x=typeof r=="number"?r:parseFloat(r)/100*f.contentAreaWidth,d=t.map(b=>typeof b.width=="number"?b.width:typeof b.width=="string"&&b.width.endsWith("%")?parseFloat(b.width)/100*x:0),H=d.reduce((b,P)=>b+P,0),Y=Math.max(0,x-H),S=d.filter(b=>b===0).length;if(S>0){const b=Y/S;for(let P=0;P<d.length;P++)d[P]===0&&(d[P]=b)}const h=(b,P,y,W,R,p,z="left",D=!0)=>{D&&f.box(P,y,W,R,{borderColor:p.borderColor??o,borderWidth:p.borderWidth??n,fillColor:p.fillColor});const L=Z(p.padding??s),C={top:p.paddingTop??L.top,right:p.paddingRight??L.right,bottom:p.paddingBottom??L.bottom,left:p.paddingLeft??L.left},w=W-C.left-C.right,F=f.instance.splitTextToSize(b,w,p),v=(p.fontSize??f.baseFont.size)*(p.lineHeight??f.baseLineHeight)*.3528,j=(p.fontSize??f.baseFont.size)*.3528,e=F.length*v,l=R-C.top-C.bottom;let g=0;p.verticalAlign==="middle"?g=Math.max(0,(l-e)/2):p.verticalAlign==="bottom"&&(g=Math.max(0,l-e));let E=y+C.top+g+j;const M=p.align??z,_=f.getCursor();F.forEach(k=>{let X=P+C.left;M==="center"?X=P+W/2:M==="right"&&(X=P+W-C.right),f.textRaw(k,X,E,p,void 0,M),E+=v}),f.setCursor(_.x,_.y)};let O=f.getCursor().y;const B=f.getCursor().x,q=m??10;O+q>f.contentBottom&&(f.addPage(),O=f.getCursor().y);let $=B;t.forEach((b,P)=>{const y=d[P];h(b.header??"",$,O,y,q,a??{fontStyle:"bold"},b.align??"left"),$+=y}),O+=q,f.setCursor(B,O);const N=(b,P,y)=>{const W=Z(s),R={top:y.paddingTop??W.top,right:y.paddingRight??W.right,bottom:y.paddingBottom??W.bottom,left:y.paddingLeft??W.left},p=P-R.left-R.right;return f.measureText(b,y,p).height+R.top+R.bottom};new Array(t.length).fill(0),(()=>{const b=new Array(i.length).fill(0);for(let R=0;R<i.length;R++){const p=i[R];let z=0;for(let D=0;D<t.length;D++){const L=t[D],C=typeof L.accessor=="function"?L.accessor(p):p[L.accessor];let w="",F=c,v=1,j=1;if(C&&typeof C=="object"&&C.content!==void 0?(w=String(C.content),C.style&&(F=C.style),C.colSpan&&(v=C.colSpan),C.rowSpan&&(j=C.rowSpan)):w=String(C??""),j>1){D+=v-1;continue}let e=d[D];for(let g=1;g<v;g++)D+g<d.length&&(e+=d[D+g]);const l=N(w,e,F??{});l>z&&(z=l),D+=v-1}z<8&&(z=8),b[R]=z}let P=O;const y=new Array(t.length).fill(0),W=f.getCursor().x;for(let R=0;R<i.length;R++){const p=i[R],z=b[R];let D=z;for(let w=0;w<t.length;w++){const F=t[w],v=typeof F.accessor=="function"?F.accessor(p):p[F.accessor];let j=1;if(v&&typeof v=="object"&&v.rowSpan&&(j=v.rowSpan),j>1){let e=0;for(let l=0;l<j;l++)R+l<b.length&&(e+=b[R+l]);e>D&&(D=e)}}const L=Math.abs(P-(f.contentTop+(m??10)))<1;if(P+D>f.contentBottom&&!L&&(f.addPage(),P=f.getCursor().y,m!==0)){let w=W;t.forEach((F,v)=>{const j=d[v];h(F.header??"",w,P,j,m??10,a??{fontStyle:"bold"},F.align??"left"),w+=j}),P+=m??10}let C=W;for(let w=0;w<t.length;w++){if(y[w]>0){y[w]--,C+=d[w];continue}const F=t[w],v=typeof F.accessor=="function"?F.accessor(p):p[F.accessor];let j=1,e=1,l=R%2===1&&u?u:c,g="";v&&typeof v=="object"&&v.content!==void 0?(g=String(v.content),v.colSpan&&(j=v.colSpan),v.rowSpan&&(e=v.rowSpan),v.style&&(l={...l,...v.style})):g=String(v??"");let E=d[w];for(let _=1;_<j;_++)w+_<d.length&&(E+=d[w+_]);let M=z;if(e>1)for(let _=1;_<e;_++)R+_<b.length&&(M+=b[R+_]);if(h(g,C,P,E,M,l??{},F.align??"left",!0),e>1){y[w]=e-1;for(let _=1;_<j;_++)w+_<y.length&&(y[w+_]=e-1)}C+=E,w+=j-1}P+=z}f.setCursor(W,P)})()})},[f,i,t,r]),null},wt=({children:i,x:t,y:r,maxWidth:n,spacingBelow:o=2,...s})=>{const a=U();return T.useEffect(()=>{a.queueOperation(()=>{if(typeof t=="number"&&typeof r=="number")a.textRaw(i,t,r,s,n,s.align);else{a.paragraph(i,s,n);const c=a.getCursor();a.setCursor(c.x,c.y+o)}})},[a,i,t,r,n,o,s.fontSize,s.align]),null};function vt(i){return typeof i=="number"?{top:i,right:i,bottom:i,left:i}:{top:i?.top??0,right:i?.right??0,bottom:i?.bottom??0,left:i?.left??0}}const xt=({style:i={},children:t})=>{const r=U(),n=Z(i.padding),o={top:i.paddingTop??n.top,right:i.paddingRight??n.right,bottom:i.paddingBottom??n.bottom,left:i.paddingLeft??n.left},s=vt(i.margin),a={top:i.marginTop??s.top,right:i.marginRight??s.right,bottom:i.marginBottom??s.bottom,left:i.marginLeft??s.left},c=T.useRef({}).current;return T.useEffect(()=>{r.queueOperation(()=>{a.top>0&&r.moveCursor(0,a.top);const u=r.getCursor();c.start={...u},r.setCursor(u.x+o.left,u.y+o.top)})},[r]),I.jsxs(T.Fragment,{children:[t,I.jsx(Pt,{viewState:c,style:i,pad:o,margin:a})]})},Pt=({viewState:i,style:t,pad:r,margin:n})=>{const o=U();return T.useEffect(()=>{o.queueOperation(()=>{const s=i.start;if(!s)return;const a=o.getCursor();let u=Math.max(a.y-s.y-r.top,0)+r.top+r.bottom;t.height&&(u=t.height);let m=o.contentAreaWidth;typeof t.width=="number"&&(m=t.width),(t.borderColor||t.fillColor||t.borderWidth)&&o.box(s.x,s.y,m,u,t);const f=s.y+u+n.bottom;o.setCursor(s.x,f)})},[o]),null};A.PdfBox=ht,A.PdfDocument=ft,A.PdfImage=gt,A.PdfList=pt,A.PdfPreview=mt,A.PdfRenderer=st,A.PdfTable=bt,A.PdfText=wt,A.PdfView=xt,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-vector-pdf",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "private": false,
5
5
  "description": "Vector (text-selectable) PDF engine with React UI to configure page numbers, formats, scopes, and center labels. Powered by jsPDF.",
6
6
  "repository": {
@@ -28,7 +28,8 @@
28
28
  "scripts": {
29
29
  "dev": "vite",
30
30
  "build": "vite build",
31
- "preview": "vite preview"
31
+ "preview": "vite preview",
32
+ "prepublishOnly": "npm run build"
32
33
  },
33
34
  "keywords": [
34
35
  "pdf",