@wavy/react-pdf 0.0.8 → 0.0.10

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
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
 
@@ -160,4 +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
- 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 h=(n=>(n.paper="#ffffff",n.onPaper="#28282B",n))(h||{}),w=e=>`${e*16}px`,G=e=>/^#([A-Fa-f0-9]{3,4}){1,2}$/.test(e),L=e=>parseInt(e.repeat(2/e.length),16),S=(e,t=1)=>{let n=(m,f)=>m.match(new RegExp(`.{${f}}`,"g")),r=m=>typeof m<"u"?m/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,y]=o.map(L);return `rgba(${s}, ${c}, ${u}, ${r(y)})`};var B=createContext(null);function W(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:e.contentPadding||w(.25)},children:jsx(View,{style:{width:e.width||"100%",padding:e.padding},children:e.children})})}function j(e){let t=useContext(B);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(n=>jsx(Text,{style:{width:n.width,textAlign:n.textAlign,overflow:"hidden"},children:e.formatColName?.(n.name)||camelCaseToLetter(n.name)},n.name))})}function _(e){let t=useContext(B);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((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:W,Header:j,Body:_};var g=e=>{let{fullWidth:t,fullHeight:n,height:r,width:i,backgroundColor:o,color:s,fontWeight:c,fontSize:u,gap:y,halfFade:m,quarterFade:f,opacity:I,flex:z,corners:R,padding:A}=e,x="auto";return {width:t?"100%":i||x,height:n?"100%":r||x,backgroundColor:o,color:s,fontWeight:c,fontSize:u,gap:y,flex:z,padding:A,borderRadius:R,opacity:m?.5:f?.25:I}};var H=e=>{let{underline:t,lineThrough:n,upperFirst:r,uppercase:i,lowercase:o,caps:s,bold:c}=e;return {...g(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"}},D=H;var q=D;function P(e){let t=()=>e.text||e.children;return jsx(Text,{style:[q({...e}),e.style],children:jsx(t,{})})}var Y=e=>{let{row:t,stretch:n,alignCenter:r,alignEnd:i,justifyCenter:o,justifySpaceBetween:s,justifySpaceEvenly:c,justifyEnd:u}=e;return {...g(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"}},O=Y;var J=O;function C(e){let t=Array.isArray(e.style)?e.style:[e.style];return jsx(View,{style:[J({...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 K=V;function je(e){return jsx(Image,{src:{uri:e.src,method:"GET",headers:{"Cache-Control":"no-cache"}},style:[K(e),e.style]})}function Xe(e){return jsxs(C,{...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,C as BasicView,h as ColorResources,se as TableView,S as hexToRgba,w 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]})}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.8",
3
+ "version": "0.0.10",
4
4
  "description": "",
5
5
  "main": "dist/main.js",
6
6
  "scripts": {