@wavy/react-pdf 0.0.7 → 0.0.8
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 +6 -0
- package/dist/main.js +1 -1
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -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;
|
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
|
|
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};
|