@wavy/react-pdf 0.0.6 → 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 +16 -45
- package/dist/main.js +1 -1
- package/package.json +3 -6
package/dist/main.d.ts
CHANGED
|
@@ -1,54 +1,12 @@
|
|
|
1
|
-
import { ViewProps,
|
|
2
|
-
export { BlobProvider, Image, ImageProps, PDFViewer, PDFViewerProps, Page, PageProps, Text, TextProps, View, ViewProps, pdf, usePDF } from '@react-pdf/renderer';
|
|
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';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import { ComputedStyleProps } from '@wavy/react-ui';
|
|
5
|
-
import { SafeOmit } from '@wavy/types';
|
|
6
4
|
import { JSX, PropsWithChildren } from 'react';
|
|
7
5
|
|
|
8
6
|
type PDFStyle = ViewProps["style"] extends object[]
|
|
9
7
|
? never
|
|
10
8
|
: ViewProps["style"];
|
|
11
9
|
|
|
12
|
-
declare function usePDFDocument(): {
|
|
13
|
-
renderedAsPdf: boolean;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
interface DivProps extends ComputedStyleProps {
|
|
17
|
-
/**@default "flex" */
|
|
18
|
-
display?: React.CSSProperties["display"];
|
|
19
|
-
/**Sets the flexDirection to `row`
|
|
20
|
-
* @default false */
|
|
21
|
-
row?: boolean;
|
|
22
|
-
}
|
|
23
|
-
declare function Div(props: DivProps): react_jsx_runtime.JSX.Element;
|
|
24
|
-
|
|
25
|
-
interface SpanProps extends ComputedStyleProps {
|
|
26
|
-
lineLimit?: number;
|
|
27
|
-
italic?: boolean;
|
|
28
|
-
strikeThrough?: boolean;
|
|
29
|
-
underline?: boolean;
|
|
30
|
-
text?: string;
|
|
31
|
-
ellipsis?: boolean | "native";
|
|
32
|
-
}
|
|
33
|
-
declare function Span(props: SpanProps): react_jsx_runtime.JSX.Element;
|
|
34
|
-
|
|
35
|
-
interface ImgProps extends SafeOmit<ComputedStyleProps, "children"> {
|
|
36
|
-
src: string;
|
|
37
|
-
}
|
|
38
|
-
declare function Img(props: ImgProps): react_jsx_runtime.JSX.Element;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* This component represent the PDF document itself. It must be the root of your tree element structure,
|
|
42
|
-
* and under no circumstances should it be used as children of another react-pdf component.
|
|
43
|
-
* In addition, it should only have childs of type .
|
|
44
|
-
*/
|
|
45
|
-
interface PDFDocumentProps extends DocumentProps {
|
|
46
|
-
/**@default false */
|
|
47
|
-
asPdf?: boolean;
|
|
48
|
-
children: JSX.Element | JSX.Element[];
|
|
49
|
-
}
|
|
50
|
-
declare function PDFDocument(props: PDFDocumentProps): react_jsx_runtime.JSX.Element;
|
|
51
|
-
|
|
52
10
|
type Column<T extends string = string> = {
|
|
53
11
|
name: T;
|
|
54
12
|
/**@default 1 */
|
|
@@ -76,6 +34,7 @@ declare namespace TableViewProps {
|
|
|
76
34
|
width?: string;
|
|
77
35
|
columnGap?: string;
|
|
78
36
|
padding?: string;
|
|
37
|
+
contentPadding?: string;
|
|
79
38
|
entries: Record<T, string>[];
|
|
80
39
|
children: JSX.Element | [JSX.Element, JSX.Element];
|
|
81
40
|
}
|
|
@@ -85,12 +44,17 @@ declare namespace TableViewProps {
|
|
|
85
44
|
padding?: string;
|
|
86
45
|
/**@default ".25rem" */
|
|
87
46
|
borderRadius?: string;
|
|
47
|
+
color?: string;
|
|
48
|
+
fontWeight?: string;
|
|
49
|
+
formatColName?: (column: string) => string;
|
|
88
50
|
}
|
|
89
51
|
interface BodyProps {
|
|
90
52
|
/**@default ".5rem" */
|
|
91
53
|
fontSize?: string;
|
|
92
54
|
padding?: string;
|
|
93
55
|
rowGap?: string;
|
|
56
|
+
marginTop?: string;
|
|
57
|
+
marginBottom?: string;
|
|
94
58
|
styleRow?: (rowIndex: number, entries: Record<string, string>[]) => null | undefined | PDFStyle;
|
|
95
59
|
styleCell?: (cell: {
|
|
96
60
|
cellIndex: number;
|
|
@@ -189,4 +153,11 @@ interface BasicPDFListItemProps extends BasicViewStylesOptions {
|
|
|
189
153
|
}
|
|
190
154
|
declare function BasicPDFListItem(props: BasicPDFListItemProps): react_jsx_runtime.JSX.Element;
|
|
191
155
|
|
|
192
|
-
|
|
156
|
+
declare enum ColorResources {
|
|
157
|
+
paper = "#ffffff",
|
|
158
|
+
onPaper = "#28282B"
|
|
159
|
+
}
|
|
160
|
+
declare const remAsPx: (value: number) => string;
|
|
161
|
+
declare const hexToRgba: (hex: string, alpha?: number) => string;
|
|
162
|
+
|
|
163
|
+
export { BasicImage, type BasicImageProps, BasicPDFListItem, type BasicPDFListItemProps, BasicText, type BasicTextProps, BasicView, type BasicViewProps, ColorResources, type PDFStyle, TableView, TableViewProps, hexToRgba, remAsPx };
|
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wavy/react-pdf",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,12 +12,9 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"type": "module",
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@types/react": "^19.2.
|
|
16
|
-
"@types/react-dom": "^19.2.3",
|
|
17
|
-
"@wavy/react-ui": "^0.0.6",
|
|
15
|
+
"@types/react": "^19.2.7",
|
|
18
16
|
"@wavy/types": "^0.0.51",
|
|
19
|
-
"react": "^19.2.
|
|
20
|
-
"react-dom": "^19.2.0",
|
|
17
|
+
"react": "^19.2.1",
|
|
21
18
|
"tsup": "^8.5.1",
|
|
22
19
|
"typescript": "^5.9.3"
|
|
23
20
|
},
|