@wavy/react-pdf 0.0.10 → 0.0.12

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/dist/main.d.ts CHANGED
@@ -160,6 +160,6 @@ declare enum ColorResources {
160
160
  declare const remAsPx: (value: number) => string;
161
161
  declare const hexToRgba: (hex: string, alpha?: number) => string;
162
162
 
163
- declare function Document(props: DocumentProps): react_jsx_runtime.JSX.Element;
163
+ declare function Document(props: PropsWithChildren<DocumentProps>): react_jsx_runtime.JSX.Element;
164
164
 
165
165
  export { BasicImage, type BasicImageProps, BasicPDFListItem, type BasicPDFListItemProps, BasicText, type BasicTextProps, BasicView, type BasicViewProps, ColorResources, Document, type PDFStyle, TableView, TableViewProps, hexToRgba, remAsPx };
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- import re from'./fonts/normal/inter_black.ttf';import ne from'./fonts/normal/inter_bold.ttf';import oe from'./fonts/normal/inter_extraBold.ttf';import se from'./fonts/normal/inter_extraLight.ttf';import le from'./fonts/normal/inter_light.ttf';import ae from'./fonts/normal/inter_medium.ttf';import ce from'./fonts/normal/inter_normal.ttf';import me from'./fonts/normal/inter_semiBold.ttf';import de from'./fonts/normal/inter_thin.ttf';import fe from'./fonts/italic/inter_black.ttf';import ge from'./fonts/italic/inter_bold.ttf';import ue from'./fonts/italic/inter_extraBold.ttf';import pe from'./fonts/italic/inter_extraLight.ttf';import ye from'./fonts/italic/inter_light.ttf';import Se from'./fonts/italic/inter_medium.ttf';import he from'./fonts/italic/inter_normal.ttf';import Be from'./fonts/italic/inter_semiBold.ttf';import Pe from'./fonts/italic/inter_thin.ttf';import {Font,View,Text,Image,Document}from'@react-pdf/renderer';export{BlobProvider,Font,Image,PDFViewer,Page,Text,View,pdf,usePDF}from'@react-pdf/renderer';import {camelCaseToLetter}from'@wavy/fn';import {createContext,useContext}from'react';import {jsx,jsxs}from'react/jsx-runtime';var x=(i=>(i.paper="#ffffff",i.onPaper="#28282B",i))(x||{}),b=e=>`${e*16}px`,L=e=>/^#([A-Fa-f0-9]{3,4}){1,2}$/.test(e),R=e=>parseInt(e.repeat(2/e.length),16),S=(e,t=1)=>{let i=(d,y)=>d.match(new RegExp(`.{${y}}`,"g")),n=d=>typeof d<"u"?d/255:typeof t!="number"||t<0||t>1?1:t;if(!L(e))throw new Error(`Invalid HEX: ${e}`);let r=Math.floor((e.length-1)/3),o=i(e.slice(1),r),[s,c,f,p]=o.map(R);return `rgba(${s}, ${c}, ${f}, ${n(p)})`};var h=createContext(null);function v(e){let t=()=>e.columns.map(n=>{let r=typeof n=="object"?n:{},o={textAlign:"left",width:"100%"};return typeof n=="string"?r={name:n,...o}:["textAlign","width"].forEach(s=>{s in r&&r[s]||(r[s]=o[s]);}),r}),i=e.gap??".25rem";return jsx(h.Provider,{value:{entries:e.entries,columns:t(),rowGap:e.rowGap??i,columnGap:e.columnGap??i,padding:e.contentPadding||b(.25)},children:jsx(View,{style:{width:e.width||"100%",padding:e.padding},children:e.children})})}function _(e){let t=useContext(h);return jsx(View,{style:{width:"100%",flexDirection:"row",fontWeight:e.fontWeight,color:e.color||S("#28282B",.5),backgroundColor:S("#28282B",.1),fontSize:e.fontSize||".55rem",borderRadius:e.borderRadius??".25rem",padding:e.padding??t.padding,columnGap:t.columnGap},children:t.columns.map(i=>jsx(Text,{style:{width:i.width,textAlign:i.textAlign,overflow:"hidden"},children:e.formatColName?.(i.name)||camelCaseToLetter(i.name)},i.name))})}function j(e){let t=useContext(h);return jsx(View,{style:{width:"100%",padding:e.padding||t.padding,rowGap:e.rowGap??t.rowGap,marginTop:e.marginTop,marginBottom:e.marginBottom},children:t.entries.map((i,n)=>jsx(View,{style:{flexDirection:"row",fontSize:e.fontSize||".5rem",...e.styleRow?.(n,t.entries)||{},alignItems:"center",width:"100%",overflow:"hidden",columnGap:t.columnGap},children:t.columns.map((r,o)=>jsx(Text,{style:{textAlign:r.textAlign,opacity:r.opacity??1,...e.styleCell?.({cellIndex:t.columns.length*n+o,rowIndex:n,columnName:r.name,siblingData:{previous:i?.[t.columns[o-1]?.name||""]||null,next:i?.[t.columns[o+1]?.name||""]||null},data:i?.[r.name]})||{},width:r.width},children:i?.[r.name]||r.placeholder||"-"},r.name+o))}))})}var Oe={Root:v,Header:_,Body:j};var u=e=>{let{fullWidth:t,fullHeight:i,height:n,width:r,backgroundColor:o,color:s,fontWeight:c,fontSize:f,gap:p,halfFade:d,quarterFade:y,opacity:V,flex:W,corners:A,padding:z}=e,P="auto";return {width:t?"100%":r||P,height:i?"100%":n||P,backgroundColor:o,color:s,fontWeight:c,fontSize:f,gap:p,flex:W,padding:z,borderRadius:A,opacity:d?.5:y?.25:V}};var H=e=>{let{underline:t,lineThrough:i,upperFirst:n,uppercase:r,lowercase:o,caps:s,bold:c}=e;return {...u(e),fontWeight:c&&"bold",textDecoration:t&&i?"underline line-through":t?"underline":i?"line-through":"none",textTransform:n?"upperfirst":r?"uppercase":o?"lowercase":s?"capitalize":"none"}},D=H;var q=D;function B(e){let t=()=>e.text||e.children;return jsx(Text,{style:[q({...e}),e.style],children:jsx(t,{})})}var N=e=>{let{row:t,stretch:i,alignCenter:n,alignEnd:r,justifyCenter:o,justifySpaceBetween:s,justifySpaceEvenly:c,justifyEnd:f}=e;return {...u(e),flexDirection:t?"row":"column",alignItems:i?"stretch":n?"center":r?"flex-end":"flex-start",justifyContent:o?"center":f?"flex-end":s?"space-between":c?"space-evenly":"flex-start"}},I=N;var X=I;function O(e){let t=Array.isArray(e.style)?e.style:[e.style];return jsx(View,{style:[X({...e}),...t],children:e.children})}var U=e=>{let{size:t,padding:i,backgroundColor:n,objectFit:r,circle:o,corners:s}=e;return {height:t,width:t,borderRadius:o?t:s,padding:i||(o?1:0),backgroundColor:n,objectFit:r}},C=U;var K=C;function at(e){return jsx(Image,{src:{uri:e.src,method:"GET",headers:{"Cache-Control":"no-cache"}},style:[K(e),e.style]})}function ut(e){return jsxs(O,{...e,children:[jsx(B,{...e.slotProps?.primary?.quickStyle,fontSize:e.primaryFontSize,text:e.primary,style:e.slotProps?.primary?.style}),e.secondary&&jsx(B,{...e.slotProps?.secondary?.quickStyle,halfFade:true,fontSize:e.secondaryFontSize||12,text:e.secondary,style:e.slotProps?.secondary?.style})]})}function te(e){let t=Array.isArray(e.style)?e.style:e.style?[e.style]:[];return jsx(Document,{...e,style:[{fontFamily:"Inter"},...t]})}Font.register({family:"Inter",fonts:[{src:ce},{src:de,fontWeight:"thin"},{src:le,fontWeight:"light"},{src:se,fontWeight:"ultralight"},{src:ae,fontWeight:"medium"},{src:me,fontWeight:"semibold"},{src:ne,fontWeight:"bold"},{src:oe,fontWeight:"ultrabold"},{src:re,fontWeight:"heavy"},{src:he,fontStyle:"italic"},{src:Pe,fontStyle:"italic",fontWeight:"thin"},{src:ye,fontStyle:"italic",fontWeight:"light"},{src:pe,fontStyle:"italic",fontWeight:"ultralight"},{src:Se,fontStyle:"italic",fontWeight:"medium"},{src:Be,fontStyle:"italic",fontWeight:"semibold"},{src:ge,fontStyle:"italic",fontWeight:"bold"},{src:ue,fontStyle:"italic",fontWeight:"ultrabold"},{src:fe,fontStyle:"italic",fontWeight:"heavy"}]});export{at as BasicImage,ut as BasicPDFListItem,B as BasicText,O as BasicView,x as ColorResources,te as Document,Oe as TableView,S as hexToRgba,b as remAsPx};
1
+ import re from'./fonts/normal/inter_black.ttf';import ne from'./fonts/normal/inter_bold.ttf';import oe from'./fonts/normal/inter_extraBold.ttf';import se from'./fonts/normal/inter_extraLight.ttf';import le from'./fonts/normal/inter_light.ttf';import ae from'./fonts/normal/inter_medium.ttf';import ce from'./fonts/normal/inter_normal.ttf';import me from'./fonts/normal/inter_semiBold.ttf';import de from'./fonts/normal/inter_thin.ttf';import fe from'./fonts/italic/inter_black.ttf';import ge from'./fonts/italic/inter_bold.ttf';import ue from'./fonts/italic/inter_extraBold.ttf';import pe from'./fonts/italic/inter_extraLight.ttf';import ye from'./fonts/italic/inter_light.ttf';import Se from'./fonts/italic/inter_medium.ttf';import he from'./fonts/italic/inter_normal.ttf';import Be from'./fonts/italic/inter_semiBold.ttf';import Pe from'./fonts/italic/inter_thin.ttf';import {Font,View,Text,Image,Document}from'@react-pdf/renderer';export{BlobProvider,Font,Image,PDFViewer,Page,Text,View,pdf,usePDF}from'@react-pdf/renderer';import {camelCaseToLetter}from'@wavy/fn';import {createContext,useContext}from'react';import {jsx,jsxs}from'react/jsx-runtime';var x=(i=>(i.paper="#ffffff",i.onPaper="#28282B",i))(x||{}),b=e=>`${e*16}px`,L=e=>/^#([A-Fa-f0-9]{3,4}){1,2}$/.test(e),R=e=>parseInt(e.repeat(2/e.length),16),S=(e,t=1)=>{let i=(d,y)=>d.match(new RegExp(`.{${y}}`,"g")),n=d=>typeof d<"u"?d/255:typeof t!="number"||t<0||t>1?1:t;if(!L(e))throw new Error(`Invalid HEX: ${e}`);let r=Math.floor((e.length-1)/3),o=i(e.slice(1),r),[s,c,f,p]=o.map(R);return `rgba(${s}, ${c}, ${f}, ${n(p)})`};var h=createContext(null);function v(e){let t=()=>e.columns.map(n=>{let r=typeof n=="object"?n:{},o={textAlign:"left",width:"100%"};return typeof n=="string"?r={name:n,...o}:["textAlign","width"].forEach(s=>{s in r&&r[s]||(r[s]=o[s]);}),r}),i=e.gap??".25rem";return jsx(h.Provider,{value:{entries:e.entries,columns:t(),rowGap:e.rowGap??i,columnGap:e.columnGap??i,padding:e.contentPadding||b(.25)},children:jsx(View,{style:{width:e.width||"100%",padding:e.padding},children:e.children})})}function _(e){let t=useContext(h);return jsx(View,{style:{width:"100%",flexDirection:"row",fontWeight:e.fontWeight,color:e.color||S("#28282B",.5),backgroundColor:S("#28282B",.1),fontSize:e.fontSize||".55rem",borderRadius:e.borderRadius??".25rem",padding:e.padding??t.padding,columnGap:t.columnGap},children:t.columns.map(i=>jsx(Text,{style:{width:i.width,textAlign:i.textAlign,overflow:"hidden"},children:e.formatColName?.(i.name)||camelCaseToLetter(i.name)},i.name))})}function j(e){let t=useContext(h);return jsx(View,{style:{width:"100%",padding:e.padding||t.padding,rowGap:e.rowGap??t.rowGap,marginTop:e.marginTop,marginBottom:e.marginBottom},children:t.entries.map((i,n)=>jsx(View,{style:{flexDirection:"row",fontSize:e.fontSize||".5rem",...e.styleRow?.(n,t.entries)||{},alignItems:"center",width:"100%",overflow:"hidden",columnGap:t.columnGap},children:t.columns.map((r,o)=>jsx(Text,{style:{textAlign:r.textAlign,opacity:r.opacity??1,...e.styleCell?.({cellIndex:t.columns.length*n+o,rowIndex:n,columnName:r.name,siblingData:{previous:i?.[t.columns[o-1]?.name||""]||null,next:i?.[t.columns[o+1]?.name||""]||null},data:i?.[r.name]})||{},width:r.width},children:i?.[r.name]||r.placeholder||"-"},r.name+o))}))})}var Oe={Root:v,Header:_,Body:j};var u=e=>{let{fullWidth:t,fullHeight:i,height:n,width:r,backgroundColor:o,color:s,fontWeight:c,fontSize:f,gap:p,halfFade:d,quarterFade:y,opacity:V,flex:W,corners:A,padding:z}=e,P="auto";return {width:t?"100%":r||P,height:i?"100%":n||P,backgroundColor:o,color:s,fontWeight:c,fontSize:f,gap:p,flex:W,padding:z,borderRadius:A,opacity:d?.5:y?.25:V}};var H=e=>{let{underline:t,lineThrough:i,upperFirst:n,uppercase:r,lowercase:o,caps:s,bold:c}=e;return {...u(e),fontWeight:c&&"bold",textDecoration:t&&i?"underline line-through":t?"underline":i?"line-through":"none",textTransform:n?"upperfirst":r?"uppercase":o?"lowercase":s?"capitalize":"none"}},D=H;var q=D;function B(e){let t=()=>e.text||e.children;return jsx(Text,{style:[q({...e}),e.style],children:jsx(t,{})})}var N=e=>{let{row:t,stretch:i,alignCenter:n,alignEnd:r,justifyCenter:o,justifySpaceBetween:s,justifySpaceEvenly:c,justifyEnd:f}=e;return {...u(e),flexDirection:t?"row":"column",alignItems:i?"stretch":n?"center":r?"flex-end":"flex-start",justifyContent:o?"center":f?"flex-end":s?"space-between":c?"space-evenly":"flex-start"}},I=N;var X=I;function O(e){let t=Array.isArray(e.style)?e.style:[e.style];return jsx(View,{style:[X({...e}),...t],children:e.children})}var U=e=>{let{size:t,padding:i,backgroundColor:n,objectFit:r,circle:o,corners:s}=e;return {height:t,width:t,borderRadius:o?t:s,padding:i||(o?1:0),backgroundColor:n,objectFit:r}},C=U;var K=C;function at(e){return jsx(Image,{src:{uri:e.src,method:"GET",headers:{"Cache-Control":"no-cache"}},style:[K(e),e.style]})}function ut(e){return jsxs(O,{...e,children:[jsx(B,{...e.slotProps?.primary?.quickStyle,fontSize:e.primaryFontSize,text:e.primary,style:e.slotProps?.primary?.style}),e.secondary&&jsx(B,{...e.slotProps?.secondary?.quickStyle,halfFade:true,fontSize:e.secondaryFontSize||12,text:e.secondary,style:e.slotProps?.secondary?.style})]})}function te(e){let t=Array.isArray(e.style)?e.style:e.style?[e.style]:[];return jsx(Document,{...e,style:[{fontFamily:"Inter"},...t],children:e.children})}Font.register({family:"Inter",fonts:[{src:ce},{src:de,fontWeight:"thin"},{src:le,fontWeight:"light"},{src:se,fontWeight:"ultralight"},{src:ae,fontWeight:"medium"},{src:me,fontWeight:"semibold"},{src:ne,fontWeight:"bold"},{src:oe,fontWeight:"ultrabold"},{src:re,fontWeight:"heavy"},{src:he,fontStyle:"italic"},{src:Pe,fontStyle:"italic",fontWeight:"thin"},{src:ye,fontStyle:"italic",fontWeight:"light"},{src:pe,fontStyle:"italic",fontWeight:"ultralight"},{src:Se,fontStyle:"italic",fontWeight:"medium"},{src:Be,fontStyle:"italic",fontWeight:"semibold"},{src:ge,fontStyle:"italic",fontWeight:"bold"},{src:ue,fontStyle:"italic",fontWeight:"ultrabold"},{src:fe,fontStyle:"italic",fontWeight:"heavy"}]});export{at as BasicImage,ut as BasicPDFListItem,B as BasicText,O as BasicView,x as ColorResources,te as Document,Oe as TableView,S as hexToRgba,b as remAsPx};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavy/react-pdf",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "",
5
5
  "main": "dist/main.js",
6
6
  "scripts": {