umwd-components 0.1.813 → 0.1.814

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.
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("@mui/material/IconButton"),n=require("@mui/material/Dialog"),t=require("@mui/material/DialogContent"),o=require("@mui/material/DialogActions"),l=require("@mui/material/Button"),s=require("@mui/material/CircularProgress"),c=require("@mui/icons-material/PictureAsPdf");const a=()=>{const[e,i]=r.useState(null),[n,t]=r.useState(!0),[o,l]=r.useState(null);return r.useEffect(()=>{let e=!0;return(async()=>{try{const r=await import("@react-pdf/renderer");e&&(i(r),t(!1))}catch(r){console.error("Failed to load PDF renderer:",r),e&&(l("Failed to load PDF components"),t(!1))}})(),()=>{e=!1}},[]),{pdfComponents:e,loading:n,error:o}},d=()=>{const{pdfComponents:r,loading:i,error:n}=a();if(i)return e.jsx(s,{});if(n)return e.jsxs("div",{children:["Error loading PDF components: ",n]});if(!r)return e.jsx("div",{children:"PDF components not available"});const{Document:t,Page:o,View:l,Text:c,StyleSheet:d}=r,u=(e=>e.create({page:{flexDirection:"column",backgroundColor:"#E4E4E4"},header:{padding:10,flexDirection:"row",alignItems:"center"},logo:{width:24,height:24,marginRight:10},section:{margin:10,padding:10,fontSize:12},row:{flexDirection:"row"},rowSection:{flex:1},productRowSection:{flex:1,width:1/6},h1:{fontSize:28},h2:{fontSize:24,fontWeight:"bold"},h3:{fontSize:16,fontWeight:"bold"}}))(d);return e.jsx(t,{children:e.jsxs(o,{size:"A4",style:u.page,children:[e.jsx(l,{style:u.header,children:e.jsx(c,{style:u.h2,children:"Invoice"})}),e.jsx(l,{style:u.section,children:e.jsx(c,{children:"Invoice details go here..."})})]})})};exports.InvoiceDownloadLink=function({invoice:r}){const{pdfComponents:n,loading:t,error:o}=a();if(t||o||!n||!r)return e.jsx(i,{disabled:!0,children:e.jsx(s,{size:20})});const{PDFDownloadLink:l}=n;try{return e.jsx(l,{document:e.jsx(d,{}),fileName:"invoice_",children:e.jsx(i,{children:e.jsx(c,{})})},Date.now())}catch(r){return console.error("Error creating PDF download link:",r),e.jsx(i,{disabled:!0,children:e.jsx(c,{})})}},exports.InvoicePDFViewer=function(){const[u,h]=r.useState(!1),[x,m]=r.useState(null),{pdfComponents:j,loading:f,error:g}=a();if(f||g||!j)return e.jsx(i,{disabled:!0,children:e.jsx(s,{size:20})});const{PDFViewer:p}=j;return e.jsxs(e.Fragment,{children:[e.jsx(i,{onClick:()=>{m(null),h(!0)},children:e.jsx(c,{})}),e.jsxs(n,{open:u,fullWidth:!0,maxWidth:"lg",children:[e.jsx(t,{children:x?e.jsxs("div",{children:["Error rendering PDF: ",x]}):e.jsx(p,{style:{width:"100%",minHeight:"70vh"},children:e.jsx(d,{})},Date.now())}),e.jsx(o,{children:e.jsx(l,{variant:"contained",onClick:()=>h(!1),children:"Close"})})]})]})},exports.default=d;
7
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("@mui/material/IconButton"),n=require("@mui/material/Dialog"),t=require("@mui/material/DialogContent"),o=require("@mui/material/DialogActions"),l=require("@mui/material/Button"),s=require("@mui/material/CircularProgress"),c=require("@mui/icons-material/PictureAsPdf");const a=()=>{const[e,i]=r.useState(null),[n,t]=r.useState(!0),[o,l]=r.useState(null);return r.useEffect(()=>{let e=!0;return(async()=>{try{const r=await import("@react-pdf/renderer");e&&(i(r),t(!1))}catch(r){console.error("Failed to load PDF renderer:",r),e&&(l("Failed to load PDF components"),t(!1))}})(),()=>{e=!1}},[]),{pdfComponents:e,loading:n,error:o}},d=()=>{const{pdfComponents:r,loading:i,error:n}=a();if(i)return e.jsx(s,{});if(n)return e.jsxs("div",{children:["Error loading PDF components: ",n]});if(!r)return e.jsx("div",{children:"PDF components not available"});const{Document:t,Page:o,View:l,Text:c,StyleSheet:d}=r,u=(e=>e.create({page:{flexDirection:"column",backgroundColor:"#E4E4E4"},header:{padding:10,flexDirection:"row",alignItems:"center"},logo:{width:24,height:24,marginRight:10},section:{margin:10,padding:10,fontSize:12},row:{flexDirection:"row"},rowSection:{flex:1},productRowSection:{flex:1,width:1/6},h1:{fontSize:28},h2:{fontSize:24,fontWeight:"bold"},h3:{fontSize:16,fontWeight:"bold"}}))(d);return e.jsx(t,{children:e.jsxs(o,{size:"A4",style:u.page,children:[e.jsx(l,{style:u.header,children:e.jsx(c,{style:u.h2,children:"Invoice"})}),e.jsx(l,{style:u.section,children:e.jsx(c,{children:"Invoice details go here..."})})]})})};exports.InvoiceDownloadLink=function(){const{pdfComponents:r,loading:n,error:t}=a();if(n||t||!r)return e.jsx(i,{disabled:!0,children:e.jsx(s,{size:20})});const{PDFDownloadLink:o}=r;try{return e.jsx(o,{document:e.jsx(d,{}),fileName:"invoice_",children:e.jsx(i,{children:e.jsx(c,{})})},Date.now())}catch(r){return console.error("Error creating PDF download link:",r),e.jsx(i,{disabled:!0,children:e.jsx(c,{})})}},exports.InvoicePDFViewer=function(){const[u,h]=r.useState(!1),[x,m]=r.useState(null),{pdfComponents:j,loading:f,error:g}=a();if(f||g||!j)return e.jsx(i,{disabled:!0,children:e.jsx(s,{size:20})});const{PDFViewer:p}=j;return e.jsxs(e.Fragment,{children:[e.jsx(i,{onClick:()=>{m(null),h(!0)},children:e.jsx(c,{})}),e.jsxs(n,{open:u,fullWidth:!0,maxWidth:"lg",children:[e.jsx(t,{children:x?e.jsxs("div",{children:["Error rendering PDF: ",x]}):e.jsx(p,{style:{width:"100%",minHeight:"70vh"},children:e.jsx(d,{})},Date.now())}),e.jsx(o,{children:e.jsx(l,{variant:"contained",onClick:()=>h(!1),children:"Close"})})]})]})},exports.default=d;