@wavy/react-pdf 0.0.7 → 0.0.9

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/main.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ViewProps, Styles } from '@react-pdf/renderer';
2
- export { BlobProvider, BlobProviderProps, Document, DocumentProps, Image, ImageProps, PDFViewer, PDFViewerProps, Page, PageProps, Text, TextProps, View, ViewProps, pdf, usePDF } from '@react-pdf/renderer';
1
+ import { ViewProps, Styles, DocumentProps } from '@react-pdf/renderer';
2
+ export { BlobProvider, BlobProviderProps, DocumentProps, Font, Image, ImageProps, PDFViewer, PDFViewerProps, Page, PageProps, Text, TextProps, View, ViewProps, pdf, usePDF } from '@react-pdf/renderer';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { JSX, PropsWithChildren } from 'react';
5
5
 
@@ -34,6 +34,7 @@ declare namespace TableViewProps {
34
34
  width?: string;
35
35
  columnGap?: string;
36
36
  padding?: string;
37
+ contentPadding?: string;
37
38
  entries: Record<T, string>[];
38
39
  children: JSX.Element | [JSX.Element, JSX.Element];
39
40
  }
@@ -43,12 +44,17 @@ declare namespace TableViewProps {
43
44
  padding?: string;
44
45
  /**@default ".25rem" */
45
46
  borderRadius?: string;
47
+ color?: string;
48
+ fontWeight?: string;
49
+ formatColName?: (column: string) => string;
46
50
  }
47
51
  interface BodyProps {
48
52
  /**@default ".5rem" */
49
53
  fontSize?: string;
50
54
  padding?: string;
51
55
  rowGap?: string;
56
+ marginTop?: string;
57
+ marginBottom?: string;
52
58
  styleRow?: (rowIndex: number, entries: Record<string, string>[]) => null | undefined | PDFStyle;
53
59
  styleCell?: (cell: {
54
60
  cellIndex: number;
@@ -154,4 +160,6 @@ declare enum ColorResources {
154
160
  declare const remAsPx: (value: number) => string;
155
161
  declare const hexToRgba: (hex: string, alpha?: number) => string;
156
162
 
157
- export { BasicImage, type BasicImageProps, BasicPDFListItem, type BasicPDFListItemProps, BasicText, type BasicTextProps, BasicView, type BasicViewProps, ColorResources, type PDFStyle, TableView, TableViewProps, hexToRgba, remAsPx };
163
+ declare function Document(props: DocumentProps): react_jsx_runtime.JSX.Element;
164
+
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 {View,Text,Image}from'@react-pdf/renderer';export{BlobProvider,Document,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 w=(n=>(n.paper="#ffffff",n.onPaper="#28282B",n))(w||{}),Z=e=>`${e*16}px`,G=e=>/^#([A-Fa-f0-9]{3,4}){1,2}$/.test(e),A=e=>parseInt(e.repeat(2/e.length),16),S=(e,t=1)=>{let n=(p,f)=>p.match(new RegExp(`.{${f}}`,"g")),r=p=>typeof p<"u"?p/255:typeof t!="number"||t<0||t>1?1:t;if(!G(e))throw new Error(`Invalid HEX: ${e}`);let i=Math.floor((e.length-1)/3),o=n(e.slice(1),i),[s,c,u,g]=o.map(A);return `rgba(${s}, ${c}, ${u}, ${r(g)})`};var B=createContext(null);function v(e){let t=()=>e.columns.map(r=>{let i=typeof r=="object"?r:{},o={textAlign:"left",width:"100%"};return typeof r=="string"?i={name:r,...o}:["textAlign","width"].forEach(s=>{s in i&&i[s]||(i[s]=o[s]);}),i}),n=e.gap??".25rem";return jsx(B.Provider,{value:{entries:e.entries,columns:t(),rowGap:e.rowGap??n,columnGap:e.columnGap??n,padding:`${.25*16}px`},children:jsx(View,{style:{width:e.width||"100%",padding:e.padding},children:e.children})})}function W(e){let t=useContext(B);return jsx(View,{style:{width:"100%",flexDirection:"row",color:S("#28282B",.5),backgroundColor:S("#28282B",.1),fontSize:e.fontSize||".55rem",borderRadius:e.borderRadius??".25rem",padding:t.padding??e.padding,columnGap:t.columnGap},children:t.columns.map(n=>jsx(Text,{style:{width:n.width,textAlign:n.textAlign,overflow:"hidden"},children:camelCaseToLetter(n.name)},n.name))})}function j(e){let t=useContext(B);return jsx(View,{style:{width:"100%",padding:e.padding||t.padding,rowGap:e.rowGap??t.rowGap},children:t.entries.map((n,r)=>jsx(View,{style:{flexDirection:"row",fontSize:e.fontSize||".5rem",...e.styleRow?.(r,t.entries)||{},alignItems:"center",width:"100%",overflow:"hidden",columnGap:t.columnGap},children:t.columns.map((i,o)=>jsx(Text,{style:{textAlign:i.textAlign,opacity:i.opacity??1,...e.styleCell?.({cellIndex:t.columns.length*r+o,rowIndex:r,columnName:i.name,siblingData:{previous:n?.[t.columns[o-1]?.name||""]||null,next:n?.[t.columns[o+1]?.name||""]||null},data:n?.[i.name]})||{},width:i.width},children:n?.[i.name]||i.placeholder||"-"},i.name+o))}))})}var se={Root:v,Header:W,Body:j};var y=e=>{let{fullWidth:t,fullHeight:n,height:r,width:i,backgroundColor:o,color:s,fontWeight:c,fontSize:u,gap:g,halfFade:p,quarterFade:f,opacity:E,flex:I,corners:z,padding:R}=e,x="auto";return {width:t?"100%":i||x,height:n?"100%":r||x,backgroundColor:o,color:s,fontWeight:c,fontSize:u,gap:g,flex:I,padding:R,borderRadius:z,opacity:p?.5:f?.25:E}};var _=e=>{let{underline:t,lineThrough:n,upperFirst:r,uppercase:i,lowercase:o,caps:s,bold:c}=e;return {...y(e),fontWeight:c&&"bold",textDecoration:t&&n?"underline line-through":t?"underline":n?"line-through":"none",textTransform:r?"upperfirst":i?"uppercase":o?"lowercase":s?"capitalize":"none"}},F=_;var H=F;function P(e){let t=()=>e.text||e.children;return jsx(Text,{style:[H({...e}),e.style],children:jsx(t,{})})}var q=e=>{let{row:t,stretch:n,alignCenter:r,alignEnd:i,justifyCenter:o,justifySpaceBetween:s,justifySpaceEvenly:c,justifyEnd:u}=e;return {...y(e),flexDirection:t?"row":"column",alignItems:n?"stretch":r?"center":i?"flex-end":"flex-start",justifyContent:o?"center":u?"flex-end":s?"space-between":c?"space-evenly":"flex-start"}},T=q;var X=T;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:n,backgroundColor:r,objectFit:i,circle:o,corners:s}=e;return {height:t,width:t,borderRadius:o?t:s,padding:n||(o?1:0),backgroundColor:r,objectFit:i}},V=U;var M=V;function je(e){return jsx(Image,{src:{uri:e.src,method:"GET",headers:{"Cache-Control":"no-cache"}},style:[M(e),e.style]})}function Xe(e){return jsxs(O,{...e,children:[jsx(P,{...e.slotProps?.primary?.quickStyle,fontSize:e.primaryFontSize,text:e.primary,style:e.slotProps?.primary?.style}),e.secondary&&jsx(P,{...e.slotProps?.secondary?.quickStyle,halfFade:true,fontSize:e.secondaryFontSize||12,text:e.secondary,style:e.slotProps?.secondary?.style})]})}export{je as BasicImage,Xe as BasicPDFListItem,P as BasicText,O as BasicView,w as ColorResources,se as TableView,S as hexToRgba,Z as remAsPx};
1
+ 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 p=(u=>(u.paper="#ffffff",u.onPaper="#28282B",u))(p||{}),$=i=>`${i*16}px`,i6=i=>/^#([A-Fa-f0-9]{3,4}){1,2}$/.test(i),n6=i=>parseInt(i.repeat(2/i.length),16),D=(i,n=1)=>{let u=(F,P)=>F.match(new RegExp(`.{${P}}`,"g")),E=F=>typeof F<"u"?F/255:typeof n!="number"||n<0||n>1?1:n;if(!i6(i))throw new Error(`Invalid HEX: ${i}`);let s=Math.floor((i.length-1)/3),e=u(i.slice(1),s),[r,A,c,b]=e.map(n6);return `rgba(${r}, ${A}, ${c}, ${E(b)})`};var y=createContext(null);function E6(i){let n=()=>i.columns.map(E=>{let s=typeof E=="object"?E:{},e={textAlign:"left",width:"100%"};return typeof E=="string"?s={name:E,...e}:["textAlign","width"].forEach(r=>{r in s&&s[r]||(s[r]=e[r]);}),s}),u=i.gap??".25rem";return jsx(y.Provider,{value:{entries:i.entries,columns:n(),rowGap:i.rowGap??u,columnGap:i.columnGap??u,padding:i.contentPadding||$(.25)},children:jsx(View,{style:{width:i.width||"100%",padding:i.padding},children:i.children})})}function e6(i){let n=useContext(y);return jsx(View,{style:{width:"100%",flexDirection:"row",fontWeight:i.fontWeight,color:i.color||D("#28282B",.5),backgroundColor:D("#28282B",.1),fontSize:i.fontSize||".55rem",borderRadius:i.borderRadius??".25rem",padding:i.padding??n.padding,columnGap:n.columnGap},children:n.columns.map(u=>jsx(Text,{style:{width:u.width,textAlign:u.textAlign,overflow:"hidden"},children:i.formatColName?.(u.name)||camelCaseToLetter(u.name)},u.name))})}function r6(i){let n=useContext(y);return jsx(View,{style:{width:"100%",padding:i.padding||n.padding,rowGap:i.rowGap??n.rowGap,marginTop:i.marginTop,marginBottom:i.marginBottom},children:n.entries.map((u,E)=>jsx(View,{style:{flexDirection:"row",fontSize:i.fontSize||".5rem",...i.styleRow?.(E,n.entries)||{},alignItems:"center",width:"100%",overflow:"hidden",columnGap:n.columnGap},children:n.columns.map((s,e)=>jsx(Text,{style:{textAlign:s.textAlign,opacity:s.opacity??1,...i.styleCell?.({cellIndex:n.columns.length*E+e,rowIndex:E,columnName:s.name,siblingData:{previous:u?.[n.columns[e-1]?.name||""]||null,next:u?.[n.columns[e+1]?.name||""]||null},data:u?.[s.name]})||{},width:s.width},children:u?.[s.name]||s.placeholder||"-"},s.name+e))}))})}var K6={Root:E6,Header:e6,Body:r6};var Q=i=>{let{fullWidth:n,fullHeight:u,height:E,width:s,backgroundColor:e,color:r,fontWeight:A,fontSize:c,gap:b,halfFade:F,quarterFade:P,opacity:N,flex:M,corners:O,padding:U}=i,h="auto";return {width:n?"100%":s||h,height:u?"100%":E||h,backgroundColor:e,color:r,fontWeight:A,fontSize:c,gap:b,flex:M,padding:U,borderRadius:O,opacity:F?.5:P?.25:N}};var t6=i=>{let{underline:n,lineThrough:u,upperFirst:E,uppercase:s,lowercase:e,caps:r,bold:A}=i;return {...Q(i),fontWeight:A&&"bold",textDecoration:n&&u?"underline line-through":n?"underline":u?"line-through":"none",textTransform:E?"upperfirst":s?"uppercase":e?"lowercase":r?"capitalize":"none"}},z=t6;var A6=z;function d(i){let n=()=>i.text||i.children;return jsx(Text,{style:[A6({...i}),i.style],children:jsx(n,{})})}var o6=i=>{let{row:n,stretch:u,alignCenter:E,alignEnd:s,justifyCenter:e,justifySpaceBetween:r,justifySpaceEvenly:A,justifyEnd:c}=i;return {...Q(i),flexDirection:n?"row":"column",alignItems:u?"stretch":E?"center":s?"flex-end":"flex-start",justifyContent:e?"center":c?"flex-end":r?"space-between":A?"space-evenly":"flex-start"}},C=o6;var c6=C;function f(i){let n=Array.isArray(i.style)?i.style:[i.style];return jsx(View,{style:[c6({...i}),...n],children:i.children})}var Q6=i=>{let{size:n,padding:u,backgroundColor:E,objectFit:s,circle:e,corners:r}=i;return {height:n,width:n,borderRadius:e?n:r,padding:u||(e?1:0),backgroundColor:E,objectFit:s}},x=Q6;var P6=x;function gi(i){return jsx(Image,{src:{uri:i.src,method:"GET",headers:{"Cache-Control":"no-cache"}},style:[P6(i),i.style]})}function Li(i){return jsxs(f,{...i,children:[jsx(d,{...i.slotProps?.primary?.quickStyle,fontSize:i.primaryFontSize,text:i.primary,style:i.slotProps?.primary?.style}),i.secondary&&jsx(d,{...i.slotProps?.secondary?.quickStyle,halfFade:true,fontSize:i.secondaryFontSize||12,text:i.secondary,style:i.slotProps?.secondary?.style})]})}var S="./inter_black-OGQ2PUQD.ttf";var L="./inter_bold-K2QR2KD5.ttf";var v="./inter_extraBold-BNP5WZ26.ttf";var H="./inter_extraLight-47YA7K4G.ttf";var X="./inter_light-DLROSCK5.ttf";var R="./inter_medium-VXC6SNUD.ttf";var T="./inter_normal-UHNXEOLW.ttf";var J="./inter_semiBold-GVMOABA4.ttf";var G="./inter_thin-WZZMREQH.ttf";var Z="./inter_black-LJR676MV.ttf";var j="./inter_bold-P52POTAJ.ttf";var V="./inter_extraBold-FNRNNRUB.ttf";var I="./inter_extraLight-HRHM3B6L.ttf";var W="./inter_light-Q3WLF3TH.ttf";var _="./inter_medium-N3BJDZQ5.ttf";var K="./inter_normal-NW62PDBA.ttf";var q="./inter_semiBold-RWEOEKYJ.ttf";var Y="./inter_thin-DLSLX7ZK.ttf";Font.register({family:"Inter",fonts:[{src:T},{src:G,fontWeight:"thin"},{src:X,fontWeight:"light"},{src:H,fontWeight:"ultralight"},{src:R,fontWeight:"medium"},{src:J,fontWeight:"semibold"},{src:L,fontWeight:"bold"},{src:v,fontWeight:"ultrabold"},{src:S,fontWeight:"heavy"},{src:K,fontStyle:"italic"},{src:Y,fontStyle:"italic",fontWeight:"thin"},{src:W,fontStyle:"italic",fontWeight:"light"},{src:I,fontStyle:"italic",fontWeight:"ultralight"},{src:_,fontStyle:"italic",fontWeight:"medium"},{src:q,fontStyle:"italic",fontWeight:"semibold"},{src:j,fontStyle:"italic",fontWeight:"bold"},{src:V,fontStyle:"italic",fontWeight:"ultrabold"},{src:Z,fontStyle:"italic",fontWeight:"heavy"}]});function J6(i){let n=Array.isArray(i.style)?i.style:i.style?[i.style]:[];return jsx(Document,{...i,style:[{fontFamily:"Inter"},...n]})}export{gi as BasicImage,Li as BasicPDFListItem,d as BasicText,f as BasicView,p as ColorResources,J6 as Document,K6 as TableView,D as hexToRgba,$ as remAsPx};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavy/react-pdf",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "main": "dist/main.js",
6
6
  "scripts": {