Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit 875b9cf

Browse files
author
David Kucsai
committed
Github docs does not like linking to sub directories. Moved out the typedoc to utilise markdown
1 parent a0dbc7d commit 875b9cf

File tree

67 files changed

+3243
-11678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3243
-11678
lines changed

.DS_Store

0 Bytes
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ npm install @david.kucsai/react-pdf-table
1414

1515
## Documentation
1616

17-
Refer to [API Documentation](https://dmk99.github.io/react-pdf-table/typedoc/index.html) for the type definitions.
17+
Refer to [API Documentation](https://github.com/dmk99/react-pdf-table/tree/master/docs/typedoc/README.md) for the type definitions.
1818

1919
### Notes
2020

docs/iframe.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@
7171
}</script><style>#root[hidden],
7272
#docs-root[hidden] {
7373
display: none !important;
74-
}</style></head><body><div class="sb-nopreview sb-wrapper"><div class="sb-nopreview_main"><h1 class="sb-nopreview_heading sb-heading">No Preview</h1><p>Sorry, but you either have no stories or none are selected somehow.</p><ul><li>Please check the Storybook config.</li><li>Try reloading the page.</li></ul><p>If the problem persists, check the browser console, or the terminal you've run Storybook from.</p></div></div><div class="sb-errordisplay sb-wrapper"><pre id="error-message" class="sb-heading"></pre><pre class="sb-errordisplay_code"><code id="error-stack"></code></pre></div><div id="root"></div><div id="docs-root"></div><script src="runtime~main.4be8c8d6f6e6eaffbede.bundle.js"></script><script src="vendors~main.4be8c8d6f6e6eaffbede.bundle.js"></script><script src="main.4be8c8d6f6e6eaffbede.bundle.js"></script></body></html>
74+
}</style></head><body><div class="sb-nopreview sb-wrapper"><div class="sb-nopreview_main"><h1 class="sb-nopreview_heading sb-heading">No Preview</h1><p>Sorry, but you either have no stories or none are selected somehow.</p><ul><li>Please check the Storybook config.</li><li>Try reloading the page.</li></ul><p>If the problem persists, check the browser console, or the terminal you've run Storybook from.</p></div></div><div class="sb-errordisplay sb-wrapper"><pre id="error-message" class="sb-heading"></pre><pre class="sb-errordisplay_code"><code id="error-stack"></code></pre></div><div id="root"></div><div id="docs-root"></div><script src="runtime~main.3924e5178b174ca2f3e6.bundle.js"></script><script src="vendors~main.3924e5178b174ca2f3e6.bundle.js"></script><script src="main.3924e5178b174ca2f3e6.bundle.js"></script></body></html>
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/main.3924e5178b174ca2f3e6.bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/main.4be8c8d6f6e6eaffbede.bundle.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/runtime~main.4be8c8d6f6e6eaffbede.bundle.js renamed to docs/runtime~main.3924e5178b174ca2f3e6.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/runtime~main.3924e5178b174ca2f3e6.bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/runtime~main.4be8c8d6f6e6eaffbede.bundle.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/typedoc/README.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
[@david.kucsai/react-pdf-table](README.md)[Globals](globals.md)
2+
3+
# @david.kucsai/react-pdf-table
4+
5+
# @david.kucsai/react-pdf-table
6+
7+
This library is designed to be used with [@react-pdf/renderer](https://www.npmjs.com/package/@react-pdf/renderer).
8+
9+
The goal behind this library is to provide a declarative way of defining tables in a PDF.
10+
11+
[![npm version](http://img.shields.io/npm/v/@david.kucsai/react-pdf-table.svg?style=flat)](https://npmjs.org/package/@david.kucsai/react-pdf-table "View this project on npm")
12+
13+
To get started run:
14+
15+
```
16+
npm install @david.kucsai/react-pdf-table
17+
```
18+
19+
## Documentation
20+
21+
Refer to [API Documentation](https://github.com/dmk99/react-pdf-table/tree/master/docs/typedoc/README.md) for the type definitions.
22+
23+
### Notes
24+
25+
- Layout uses `flex` behind the scenes.
26+
- If `weighting` is not defined for a table cell then it will default to the remaining unassigned weightings.
27+
- `weighting` should be between 0..1. Preferably adding up to `<= 1`.
28+
- If you have lots of rows to display it's recommended to batch up the rows and render them on separate pages to ensure
29+
that values are not cut off.
30+
- Content in `TableCell` and `DataTableCell` must either evaluate to a `string` or a `@react-pdf/renderer` component
31+
e.g. `View`, `Text` etc. If the content is a `string` it will be wrapped with a `Text` element.
32+
- `TableCell`s and `DataTableCell`s can override a lot of the configuration passed to them.
33+
34+
### Examples
35+
36+
#### Simple Example
37+
38+
This example will render a header and one row using the default styling.
39+
40+
```typescript jsx
41+
<PDFViewer>
42+
<Document>
43+
<Page>
44+
<Table
45+
data={[
46+
{firstName: "John", lastName: "Smith", dob: new Date(2000, 1, 1), country: "Australia", phoneNumber: "xxx-0000-0000"}
47+
]}
48+
>
49+
<TableHeader>
50+
<TableCell>
51+
First Name
52+
</TableCell>
53+
<TableCell>
54+
Last Name
55+
</TableCell>
56+
<TableCell>
57+
DOB
58+
</TableCell>
59+
<TableCell>
60+
Country
61+
</TableCell>
62+
<TableCell>
63+
Phone Number
64+
</TableCell>
65+
</TableHeader>
66+
<TableBody>
67+
<DataTableCell getContent={(r) => r.firstName}/>
68+
<DataTableCell getContent={(r) => r.lastName}/>
69+
<DataTableCell getContent={(r) => r.dob.toLocaleString()}/>
70+
<DataTableCell getContent={(r) => r.country}/>
71+
<DataTableCell getContent={(r) => r.phoneNumber}/>
72+
</TableBody>
73+
</Table>
74+
</Page>
75+
</Document>
76+
</PDFViewer>
77+
```
78+
79+
#### Formatting Example - Aligning Text and Weightings for columns
80+
81+
This example will render a header and one row using the default styling.
82+
83+
```typescript jsx
84+
<PDFViewer>
85+
<Document>
86+
<Page>
87+
<Table
88+
data={[
89+
{firstName: "John", lastName: "Smith", dob: new Date(2000, 1, 1), country: "Australia", phoneNumber: "xxx-0000-0000"}
90+
]}
91+
>
92+
<TableHeader textAlign={"center"}>
93+
<TableCell weighting={0.3}>
94+
First Name
95+
</TableCell>
96+
<TableCell weighting={0.3}>
97+
Last Name
98+
</TableCell>
99+
<TableCell>
100+
DOB
101+
</TableCell>
102+
<TableCell>
103+
Country
104+
</TableCell>
105+
<TableCell>
106+
Phone Number
107+
</TableCell>
108+
</TableHeader>
109+
<TableBody>
110+
<DataTableCell weighting={0.3} getContent={(r) => r.firstName}/>
111+
<DataTableCell weighting={0.3} getContent={(r) => r.lastName}/>
112+
<DataTableCell getContent={(r) => r.dob.toLocaleString()}/>
113+
<DataTableCell getContent={(r) => r.country}/>
114+
<DataTableCell getContent={(r) => r.phoneNumber}/>
115+
</TableBody>
116+
</Table>
117+
</Page>
118+
</Document>
119+
</PDFViewer>
120+
```
121+
122+
## Running Locally
123+
124+
To run the storybook:
125+
```
126+
yarn storybook
127+
```
128+
129+
Compile to typescript:
130+
```
131+
yarn recompile
132+
```
133+
134+
Build (Clean & Compile):
135+
```
136+
yarn build
137+
```
138+
139+
Run tests:
140+
```
141+
yarn test
142+
```

0 commit comments

Comments
 (0)