@design.estate/dees-document 1.0.103 → 1.1.0
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_bundle/bundle.js +174 -163
- package/dist_bundle/bundle.js.map +4 -4
- package/dist_ts/00_commitinfo_data.js +3 -3
- package/dist_ts/classes.pdfservice.d.ts +5 -1
- package/dist_ts/classes.pdfservice.js +4 -3
- package/dist_ts/interfaces/document.d.ts +5 -0
- package/dist_ts/interfaces/document.js +2 -0
- package/dist_ts/interfaces/index.d.ts +2 -0
- package/dist_ts/interfaces/index.js +3 -0
- package/dist_ts/interfaces/translation.d.ts +4 -0
- package/dist_ts/interfaces/translation.js +2 -0
- package/dist_watch/bundle.js +100 -37
- package/dist_watch/bundle.js.map +4 -4
- package/npmextra.json +11 -10
- package/package.json +13 -12
- package/readme.md +128 -87
- package/ts/00_commitinfo_data.ts +2 -2
- package/ts/classes.pdfservice.ts +6 -2
- package/ts/interfaces/document.ts +5 -0
- package/ts/interfaces/index.ts +2 -0
- package/ts/interfaces/translation.ts +4 -0
- package/ts_web/00_commitinfo_data.ts +2 -2
- package/ts_web/elements/contentinvoice.ts +4 -5
- package/ts_web/elements/document.ts +17 -7
- package/ts_web/elements/page.ts +45 -20
- package/ts_web/elements/pageheader.ts +9 -3
- package/ts_web/elements/shared/index.ts +3 -0
- package/ts_web/elements/shared/translation.ts +31 -0
package/npmextra.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"githost": "code.foss.global",
|
|
6
6
|
"gitscope": "designestate/private",
|
|
7
7
|
"gitrepo": "dedocument-catalog",
|
|
8
|
-
"description": "A
|
|
8
|
+
"description": "A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.",
|
|
9
9
|
"npmPackagename": "@designestate_private/dedocument-catalog",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"projectDomain": "design.estate",
|
|
@@ -14,19 +14,20 @@
|
|
|
14
14
|
"document generation",
|
|
15
15
|
"invoices",
|
|
16
16
|
"PDF creation",
|
|
17
|
-
"
|
|
17
|
+
"TypeScript",
|
|
18
18
|
"web components",
|
|
19
|
-
"custom elements",
|
|
20
|
-
"QR code",
|
|
21
|
-
"smart contracts",
|
|
22
19
|
"templating",
|
|
23
20
|
"dynamic rendering",
|
|
24
21
|
"responsive design",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
22
|
+
"business documentation",
|
|
23
|
+
"automated workflows",
|
|
24
|
+
"modular architecture",
|
|
25
|
+
"smart contracts",
|
|
26
|
+
"javascript",
|
|
27
|
+
"QR code",
|
|
28
|
+
"custom elements",
|
|
29
|
+
"nodejs",
|
|
30
|
+
"data-driven"
|
|
30
31
|
]
|
|
31
32
|
}
|
|
32
33
|
},
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@design.estate/dees-document",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "A
|
|
5
|
+
"description": "A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.",
|
|
6
6
|
"main": "dist_ts_web/index.js",
|
|
7
7
|
"typings": "dist_ts_web/index.d.ts",
|
|
8
8
|
"exports": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@push.rocks/smartfile": "^11.0.21",
|
|
20
20
|
"@push.rocks/smartjson": "^5.0.20",
|
|
21
21
|
"@push.rocks/smartpath": "^5.0.18",
|
|
22
|
-
"@push.rocks/smartpdf": "^3.1.
|
|
22
|
+
"@push.rocks/smartpdf": "^3.1.8",
|
|
23
23
|
"@push.rocks/smarttime": "^4.0.8",
|
|
24
24
|
"@tsclass/tsclass": "^4.1.2",
|
|
25
25
|
"@types/qrcode": "^1.5.5",
|
|
@@ -61,19 +61,20 @@
|
|
|
61
61
|
"document generation",
|
|
62
62
|
"invoices",
|
|
63
63
|
"PDF creation",
|
|
64
|
-
"
|
|
64
|
+
"TypeScript",
|
|
65
65
|
"web components",
|
|
66
|
-
"custom elements",
|
|
67
|
-
"QR code",
|
|
68
|
-
"smart contracts",
|
|
69
66
|
"templating",
|
|
70
67
|
"dynamic rendering",
|
|
71
68
|
"responsive design",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
69
|
+
"business documentation",
|
|
70
|
+
"automated workflows",
|
|
71
|
+
"modular architecture",
|
|
72
|
+
"smart contracts",
|
|
73
|
+
"javascript",
|
|
74
|
+
"QR code",
|
|
75
|
+
"custom elements",
|
|
76
|
+
"nodejs",
|
|
77
|
+
"data-driven"
|
|
77
78
|
],
|
|
78
79
|
"scripts": {
|
|
79
80
|
"test": "npm run build && tstest test/",
|
package/readme.md
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
# @design.estate/dees-document
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.
|
|
3
4
|
|
|
4
5
|
## Install
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
To add `@design.estate/dees-document` to your project, run the following command in your terminal:
|
|
8
|
+
|
|
6
9
|
```shell
|
|
7
10
|
npm install @design.estate/dees-document --save
|
|
8
11
|
```
|
|
9
12
|
|
|
10
|
-
This will add
|
|
13
|
+
This will install the package and add it to your project's dependencies, ensuring all required modules are available in your `node_modules` directory.
|
|
11
14
|
|
|
12
15
|
## Usage
|
|
13
|
-
The `@design.estate/dees-document` package is a comprehensive toolkit for creating various types of documents, such as invoices, with ease. It leverages modern ECMAScript (ES) modules and TypeScript for a type-safe, developer-friendly experience. Below, you'll find detailed examples covering how to utilize the package to its full potential.
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
The `@design.estate/dees-document` package provides a robust framework for creating documents including invoices, contracts, and various other business-related documents. It is built on modern web technologies including TypeScript and ES modules to ensure a type-safe and easy-to-integrate experience. Below, we will guide you through the comprehensive usage of this package, from setting up your environment to generating PDF documents.
|
|
18
|
+
|
|
19
|
+
### Getting Started
|
|
20
|
+
|
|
21
|
+
Before creating documents, initialize the document service which is central to this package. This is typically done at the beginning of your application.
|
|
17
22
|
|
|
18
23
|
```typescript
|
|
19
24
|
import { PdfService, IPdfServiceConstructorOptions } from '@design.estate/dees-document';
|
|
20
25
|
|
|
21
26
|
async function setupPdfService() {
|
|
22
27
|
const options: IPdfServiceConstructorOptions = {
|
|
23
|
-
//
|
|
28
|
+
// Add necessary configuration here
|
|
24
29
|
};
|
|
25
30
|
|
|
26
31
|
const pdfService = await PdfService.createAndStart(options);
|
|
@@ -29,100 +34,136 @@ async function setupPdfService() {
|
|
|
29
34
|
}
|
|
30
35
|
```
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
This script initializes `PdfService`. Modify the options to tailor the service to your needs.
|
|
38
|
+
|
|
39
|
+
### Creating Documents
|
|
40
|
+
|
|
41
|
+
With the PDF service ready, you can proceed to generate documents. The following section provides a detailed example of creating an invoice. This example is applicable to various document types with necessary adjustments.
|
|
42
|
+
|
|
43
|
+
#### Step-by-Step: Create an Invoice
|
|
44
|
+
|
|
45
|
+
1. **Define the Data Structure**: Describe the invoice details. This includes sender and recipient information, the items being invoiced, and more.
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { ILetter } from '@design.estate/dees-document';
|
|
49
|
+
|
|
50
|
+
const invoiceData: ILetter = {
|
|
51
|
+
from: {
|
|
52
|
+
name: "Your Company Name",
|
|
53
|
+
address: {
|
|
54
|
+
streetName: "Your Street",
|
|
55
|
+
houseNumber: "123",
|
|
56
|
+
city: "Your City",
|
|
57
|
+
country: "Your Country",
|
|
58
|
+
postalCode: "12345",
|
|
59
|
+
},
|
|
60
|
+
email: "your-email@example.com",
|
|
61
|
+
phone: "123-456-7890",
|
|
62
|
+
},
|
|
63
|
+
to: {
|
|
64
|
+
name: "Recipient Company Name",
|
|
65
|
+
address: {
|
|
66
|
+
streetName: "Recipient Street",
|
|
67
|
+
houseNumber: "456",
|
|
68
|
+
city: "Recipient City",
|
|
69
|
+
country: "Recipient Country",
|
|
70
|
+
postalCode: "67890",
|
|
71
|
+
},
|
|
72
|
+
email: "recipient-email@example.com",
|
|
73
|
+
phone: "098-765-4321",
|
|
74
|
+
},
|
|
75
|
+
content: {
|
|
76
|
+
invoiceData: {
|
|
77
|
+
items: [
|
|
78
|
+
{
|
|
79
|
+
name: "Service or Product Name",
|
|
80
|
+
unitQuantity: 2,
|
|
81
|
+
unitNetPrice: 100.00,
|
|
82
|
+
unitType: 'service',
|
|
83
|
+
vatPercentage: 19,
|
|
84
|
+
currency: 'EUR',
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
subject: "Invoice for Services Rendered",
|
|
90
|
+
date: new Date().getTime(),
|
|
91
|
+
versionInfo: {
|
|
92
|
+
type: "final",
|
|
93
|
+
version: "1.0.0"
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
```
|
|
33
97
|
|
|
34
|
-
|
|
35
|
-
After setting up the document service, you can proceed to create documents such as invoices. Here, we'll demonstrate how to create a basic invoice.
|
|
98
|
+
Here, `ILetter` interface details all components of an invoice including sender (`from`) and recipient (`to`) information, as well as the invoiced items.
|
|
36
99
|
|
|
37
|
-
|
|
38
|
-
First, define the basic structure of your invoice. This involves specifying details like the sender, recipient, items, and more.
|
|
100
|
+
2. **Generate the PDF**: Transform the invoice details into a PDF.
|
|
39
101
|
|
|
40
|
-
```typescript
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
from: {
|
|
45
|
-
name: "Your Company Name",
|
|
46
|
-
address: {
|
|
47
|
-
streetName: "Your Street",
|
|
48
|
-
houseNumber: "123",
|
|
49
|
-
city: "Your City",
|
|
50
|
-
country: "Your Country",
|
|
51
|
-
postalCode: "12345",
|
|
52
|
-
},
|
|
53
|
-
email: "your-email@example.com",
|
|
54
|
-
phone: "123-456-7890",
|
|
55
|
-
},
|
|
56
|
-
to: {
|
|
57
|
-
name: "Recipient Company Name",
|
|
58
|
-
address: {
|
|
59
|
-
streetName: "Recipient Street",
|
|
60
|
-
houseNumber: "456",
|
|
61
|
-
city: "Recipient City",
|
|
62
|
-
country: "Recipient Country",
|
|
63
|
-
postalCode: "67890",
|
|
64
|
-
},
|
|
65
|
-
email: "recipient-email@example.com",
|
|
66
|
-
phone: "098-765-4321",
|
|
67
|
-
},
|
|
68
|
-
content: {
|
|
69
|
-
invoiceData: {
|
|
70
|
-
items: [
|
|
71
|
-
{
|
|
72
|
-
name: "Service or Product Name",
|
|
73
|
-
unitQuantity: 2,
|
|
74
|
-
unitNetPrice: 100.00,
|
|
75
|
-
unitType: 'service',
|
|
76
|
-
vatPercentage: 19,
|
|
77
|
-
currency: 'EUR',
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
subject: "Invoice for Services Rendered",
|
|
83
|
-
date: new Date().getTime(),
|
|
84
|
-
versionInfo: {
|
|
85
|
-
type: "final",
|
|
86
|
-
version: "1.0.0"
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
```
|
|
102
|
+
```typescript
|
|
103
|
+
async function generateInvoice(pdfService: PdfService, invoiceData: ILetter) {
|
|
104
|
+
const pdfBuffer = await pdfService.createPdfFromLetterObject(invoiceData);
|
|
105
|
+
console.log('Invoice PDF generated successfully.');
|
|
90
106
|
|
|
91
|
-
|
|
107
|
+
// Save the PDF, send it via email, etc.
|
|
108
|
+
}
|
|
109
|
+
```
|
|
92
110
|
|
|
93
|
-
|
|
94
|
-
With the invoice data ready, you can now generate the PDF using the `PdfService` instance.
|
|
111
|
+
The function `createPdfFromLetterObject` returns a `Buffer` containing the generated PDF. From here, you can save this PDF to a file, send it to clients, or archive it.
|
|
95
112
|
|
|
96
|
-
|
|
97
|
-
async function generateInvoice(pdfService: PdfService, invoiceData: ILetter) {
|
|
98
|
-
const pdfBuffer = await pdfService.createPdfFromLetterObject(invoiceData);
|
|
99
|
-
console.log('Invoice PDF generated successfully.');
|
|
113
|
+
3. **Integrate It All**: Here's how everything ties together into a complete script for generating an invoice:
|
|
100
114
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
115
|
+
```typescript
|
|
116
|
+
async function main() {
|
|
117
|
+
const pdfService = await setupPdfService();
|
|
118
|
+
await generateInvoice(pdfService, invoiceData);
|
|
119
|
+
}
|
|
104
120
|
|
|
105
|
-
|
|
121
|
+
main().then(() => console.log('Invoice generation process completed.'));
|
|
122
|
+
```
|
|
106
123
|
|
|
107
|
-
|
|
108
|
-
Combining everything, your complete script to set up the service, define invoice data, and generate a PDF invoice might look something like this:
|
|
124
|
+
This script initiates the PDF service and generates the invoice PDF with the provided information.
|
|
109
125
|
|
|
110
|
-
|
|
111
|
-
async function main() {
|
|
112
|
-
const pdfService = await setupPdfService();
|
|
113
|
-
await generateInvoice(pdfService, invoiceData);
|
|
114
|
-
}
|
|
126
|
+
### Advanced Document Features
|
|
115
127
|
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
The package is designed to create not only invoices but a wide range of document types. Leverage its modular architecture to build and customize documents to fit specific needs.
|
|
129
|
+
|
|
130
|
+
#### Advanced Scenarios
|
|
131
|
+
|
|
132
|
+
1. **Custom Styling**: Customize the appearance of elements within your documents, such as headers, footers, and more.
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { DeDocumentViewer } from '@design.estate/dees-element';
|
|
118
136
|
|
|
119
|
-
|
|
120
|
-
|
|
137
|
+
const customStyledViewer = new DeDocumentViewer();
|
|
138
|
+
customStyledViewer.style.setProperty('--main-bg-color', 'lightblue');
|
|
139
|
+
document.body.appendChild(customStyledViewer);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Customize via CSS or dynamically through TypeScript where necessary.
|
|
143
|
+
|
|
144
|
+
2. **Interactive Document Elements**: Incorporate UI components like buttons, input fields, or visualizations tailored for your document needs.
|
|
145
|
+
|
|
146
|
+
3. **Multi-page Document Generation**: Handle overflow of content and automatic page generation while maintaining headers and footers.
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
pdfService.adjustDePageScaling();
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Toggle between print and digital formats and handle scaling.
|
|
153
|
+
|
|
154
|
+
4. **Embedding Images and Logos**: Add company logos, graphics, or auxiliary content to enhance document presentation.
|
|
155
|
+
|
|
156
|
+
### Additional Capabilities
|
|
157
|
+
|
|
158
|
+
Beyond these examples, delve deeper into advanced functionalities such as:
|
|
159
|
+
|
|
160
|
+
- **Document Management**: Manage multiple document templates, manage versions, and add annotations or notes.
|
|
161
|
+
- **Dynamic Rendering**: Use templating for dynamic content rendering based on variable inputs.
|
|
162
|
+
- **Responsive Design for Digital Documents**: Ensure documents are displayed correctly across devices.
|
|
121
163
|
|
|
122
|
-
|
|
164
|
+
### Concluding Remarks
|
|
123
165
|
|
|
124
|
-
|
|
125
|
-
For more advanced scenarios, such as custom styling, embedding images, and handling more complex document structures, refer to the package's documentation. It provides comprehensive details and examples to help you fully leverage the capabilities of `@design.estate/dees-document`.
|
|
166
|
+
The `@design.estate/dees-document` package is an essential tool in the modern document generation ecosystem. Its expansive capabilities, from basic invoices to complex document templates, make it a versatile solution for businesses of all scales. Implementing this service broadly simplifies document management workflows and enhances document presentation precision and quality. For further depth, consult the package's documentation or explore the examples included in the module.
|
|
126
167
|
|
|
127
168
|
## License and Legal Information
|
|
128
169
|
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@design.estate/dees-document',
|
|
6
|
-
version: '1.0
|
|
7
|
-
description: 'A
|
|
6
|
+
version: '1.1.0',
|
|
7
|
+
description: 'A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.'
|
|
8
8
|
}
|
package/ts/classes.pdfservice.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
2
|
import * as paths from './paths.js';
|
|
3
3
|
import * as helpers from './helpers.js';
|
|
4
|
+
import * as interfaces from '../ts/interfaces/index.js';
|
|
4
5
|
|
|
5
6
|
export interface IPdfServiceConstructorOptions {
|
|
6
7
|
|
|
@@ -44,12 +45,15 @@ export class PdfService {
|
|
|
44
45
|
/**
|
|
45
46
|
* creates an letter
|
|
46
47
|
*/
|
|
47
|
-
public async createPdfFromLetterObject(
|
|
48
|
+
public async createPdfFromLetterObject(optionsArg: {
|
|
49
|
+
letterData: plugins.tsclass.business.ILetter,
|
|
50
|
+
documentSettings: interfaces.IDocumentSettings
|
|
51
|
+
}) {
|
|
48
52
|
const html = `
|
|
49
53
|
<script type="module">
|
|
50
54
|
${await helpers.getBundleAsString()}
|
|
51
55
|
</script>
|
|
52
|
-
<dedocument-dedocument printMode letterData="${plugins.smartjson.stringifyBase64(
|
|
56
|
+
<dedocument-dedocument printMode documentSettings="${plugins.smartjson.stringifyBase64(optionsArg.documentSettings)}" letterData="${plugins.smartjson.stringifyBase64(optionsArg.letterData)}"></dedocument-dedocument>
|
|
53
57
|
`;
|
|
54
58
|
// console.log(html);
|
|
55
59
|
const pdfResult = await this.smartpdfInstance.getA4PdfResultForHtmlString(html);
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@design.estate/dees-document',
|
|
6
|
-
version: '1.0
|
|
7
|
-
description: 'A
|
|
6
|
+
version: '1.1.0',
|
|
7
|
+
description: 'A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.'
|
|
8
8
|
}
|
|
@@ -12,14 +12,13 @@ import {
|
|
|
12
12
|
cssManager,
|
|
13
13
|
unsafeCSS,
|
|
14
14
|
render,
|
|
15
|
+
domtools,
|
|
15
16
|
} from '@design.estate/dees-element';
|
|
16
|
-
import * as domtools from '@design.estate/dees-domtools';
|
|
17
|
-
|
|
18
17
|
import * as plugins from '../plugins.js';
|
|
19
|
-
|
|
20
18
|
import * as shared from './shared/index.js';
|
|
21
19
|
|
|
22
20
|
|
|
21
|
+
|
|
23
22
|
declare global {
|
|
24
23
|
interface HTMLElementTagNameMap {
|
|
25
24
|
'dedocument-contentinvoice': DeContentInvoice;
|
|
@@ -277,8 +276,8 @@ export class DeContentInvoice extends DeesElement {
|
|
|
277
276
|
<div>We hereby invoice products and services provided to you by Lossless GmbH:</div>
|
|
278
277
|
<div class="grid topLine dataHeader">
|
|
279
278
|
<div class="lineItem">Item Pos.</div>
|
|
280
|
-
<div class="lineItem"
|
|
281
|
-
<div class="lineItem"
|
|
279
|
+
<div class="lineItem">${shared.translation.translate('DE', 'description', 'Description')}</div>
|
|
280
|
+
<div class="lineItem">${shared.translation.translate('DE', 'quantity', 'Quantity')}</div>
|
|
282
281
|
<div class="lineItem">Unit Type</div>
|
|
283
282
|
<div class="lineItem">Unit Net Price</div>
|
|
284
283
|
<div class="lineItem">Total Net Price</div>
|
|
@@ -11,8 +11,15 @@ import {
|
|
|
11
11
|
domtools,
|
|
12
12
|
} from '@design.estate/dees-element';
|
|
13
13
|
|
|
14
|
+
import * as interfaces from '../../ts/interfaces/index.js';
|
|
14
15
|
import * as plugins from '../plugins.js';
|
|
15
16
|
|
|
17
|
+
export const defaultDocumentSettings: interfaces.IDocumentSettings = {
|
|
18
|
+
enableTopDraftText: true,
|
|
19
|
+
enableDefaultHeader: true,
|
|
20
|
+
enableDefaultFooter: true,
|
|
21
|
+
};
|
|
22
|
+
|
|
16
23
|
|
|
17
24
|
import { DePage } from './page.js';
|
|
18
25
|
import { DeContentInvoice } from './contentinvoice.js';
|
|
@@ -68,9 +75,17 @@ export class DeDocument extends DeesElement {
|
|
|
68
75
|
public letterData: plugins.tsclass.business.ILetter;
|
|
69
76
|
|
|
70
77
|
@property({
|
|
71
|
-
type:
|
|
78
|
+
type: Object,
|
|
79
|
+
reflect: true,
|
|
80
|
+
converter: (valueArg) => {
|
|
81
|
+
if (typeof valueArg === 'string') {
|
|
82
|
+
return plugins.smartjson.parseBase64(valueArg)
|
|
83
|
+
} else {
|
|
84
|
+
return valueArg;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
72
87
|
})
|
|
73
|
-
public
|
|
88
|
+
public documentSettings: interfaces.IDocumentSettings = defaultDocumentSettings;
|
|
74
89
|
|
|
75
90
|
constructor() {
|
|
76
91
|
super();
|
|
@@ -112,11 +127,6 @@ export class DeDocument extends DeesElement {
|
|
|
112
127
|
this.registerGarbageFunction(() => {
|
|
113
128
|
resizeObserver.disconnect();
|
|
114
129
|
})
|
|
115
|
-
|
|
116
|
-
if (this.letterDataUrl) {
|
|
117
|
-
const response = await fetch(this.letterDataUrl);
|
|
118
|
-
this.letterData = await response.json();
|
|
119
|
-
}
|
|
120
130
|
}
|
|
121
131
|
|
|
122
132
|
public latestRenderedLetterData: plugins.tsclass.business.ILetter = null;
|
package/ts_web/elements/page.ts
CHANGED
|
@@ -8,8 +8,12 @@ import {
|
|
|
8
8
|
css,
|
|
9
9
|
cssManager,
|
|
10
10
|
unsafeCSS,
|
|
11
|
+
domtools,
|
|
11
12
|
} from '@design.estate/dees-element';
|
|
12
|
-
|
|
13
|
+
|
|
14
|
+
import * as interfaces from '../../ts/interfaces/index.js';
|
|
15
|
+
|
|
16
|
+
import { defaultDocumentSettings } from './document.js';
|
|
13
17
|
|
|
14
18
|
import * as shared from './shared/index.js';
|
|
15
19
|
|
|
@@ -23,10 +27,14 @@ declare global {
|
|
|
23
27
|
export class DePage extends DeesElement {
|
|
24
28
|
public static demo = () => html` <dedocument-page .format="${'a4'}"></dedocument-page> `;
|
|
25
29
|
|
|
26
|
-
@property(
|
|
30
|
+
@property({
|
|
31
|
+
type: Number,
|
|
32
|
+
})
|
|
27
33
|
viewWidth: number = null;
|
|
28
34
|
|
|
29
|
-
@property(
|
|
35
|
+
@property({
|
|
36
|
+
type: Number,
|
|
37
|
+
})
|
|
30
38
|
viewHeight: number = null;
|
|
31
39
|
|
|
32
40
|
@property({
|
|
@@ -55,6 +63,12 @@ export class DePage extends DeesElement {
|
|
|
55
63
|
})
|
|
56
64
|
printMode = false;
|
|
57
65
|
|
|
66
|
+
@property({
|
|
67
|
+
type: Object,
|
|
68
|
+
reflect: true,
|
|
69
|
+
})
|
|
70
|
+
public documentSettings: interfaces.IDocumentSettings = defaultDocumentSettings;
|
|
71
|
+
|
|
58
72
|
constructor() {
|
|
59
73
|
super();
|
|
60
74
|
domtools.DomTools.setupDomTools();
|
|
@@ -109,11 +123,15 @@ export class DePage extends DeesElement {
|
|
|
109
123
|
<dedocument-pagecontainer .printMode=${this.printMode}>
|
|
110
124
|
${this.letterData
|
|
111
125
|
? html`
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
126
|
+
${this.documentSettings.enableDefaultHeader
|
|
127
|
+
? html`
|
|
128
|
+
<dedocument-pageheader
|
|
129
|
+
.letterData=${this.letterData}
|
|
130
|
+
.pageNumber="${this.pageNumber}"
|
|
131
|
+
.pageTotalNumber="${this.pageTotalNumber}"
|
|
132
|
+
></dedocument-pageheader>
|
|
133
|
+
`
|
|
134
|
+
: ``}
|
|
117
135
|
${this.pageNumber === 1
|
|
118
136
|
? html`
|
|
119
137
|
<dedocument-letterheader
|
|
@@ -129,26 +147,33 @@ export class DePage extends DeesElement {
|
|
|
129
147
|
.letterData=${this.letterData}
|
|
130
148
|
><slot></slot
|
|
131
149
|
></dedocument-pagecontent>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
150
|
+
${this.documentSettings.enableDefaultFooter
|
|
151
|
+
? html`
|
|
152
|
+
<dedocument-pagefooter
|
|
153
|
+
.letterData=${this.letterData}
|
|
154
|
+
.pageNumber="${this.pageNumber}"
|
|
155
|
+
.pageTotalNumber="${this.pageTotalNumber}"
|
|
156
|
+
></dedocument-pagefooter>
|
|
157
|
+
`
|
|
158
|
+
: ``}
|
|
137
159
|
<div class="versionOverlay">
|
|
138
160
|
${this.letterData.versionInfo.type === 'draft'
|
|
139
161
|
? html`
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
162
|
+
${this.documentSettings.enableTopDraftText
|
|
163
|
+
? html`
|
|
164
|
+
<div class="topInfo">
|
|
165
|
+
Please note: THIS IS A DRAFT ONLY. NO RIGHTS CAN BE DERIVED FROM
|
|
166
|
+
THIS.<br />
|
|
167
|
+
-> Revision/Document version: ${this.letterData.versionInfo.version}
|
|
168
|
+
</div>
|
|
169
|
+
`
|
|
170
|
+
: ``}
|
|
144
171
|
<div class="bigDraftText">DRAFT</div>
|
|
145
172
|
`
|
|
146
173
|
: html``}
|
|
147
174
|
</div>
|
|
148
175
|
`
|
|
149
|
-
: html`
|
|
150
|
-
<slot></slot>
|
|
151
|
-
`}
|
|
176
|
+
: html` <slot></slot> `}
|
|
152
177
|
</dedocument-pagecontainer>
|
|
153
178
|
</div>
|
|
154
179
|
`;
|
|
@@ -74,13 +74,17 @@ export class DePageHeader extends DeesElement {
|
|
|
74
74
|
color: #333;
|
|
75
75
|
font-size: 10px;
|
|
76
76
|
}
|
|
77
|
-
.topstripe
|
|
78
|
-
filter: invert(1);
|
|
77
|
+
.topstripe .logo {
|
|
79
78
|
position: absolute;
|
|
80
79
|
bottom: 10px;
|
|
81
80
|
height: 25px;
|
|
82
81
|
left: auto;
|
|
83
82
|
right: ${unsafeCSS(shared.rightMargin + 'px')};
|
|
83
|
+
font-family: 'Courier New', Courier, monospace;
|
|
84
|
+
}
|
|
85
|
+
.topstripe .logo img {
|
|
86
|
+
position: relative;
|
|
87
|
+
height: 25px;
|
|
84
88
|
}
|
|
85
89
|
`,
|
|
86
90
|
];
|
|
@@ -88,7 +92,9 @@ export class DePageHeader extends DeesElement {
|
|
|
88
92
|
public render(): TemplateResult {
|
|
89
93
|
return html`
|
|
90
94
|
<div class="topstripe">
|
|
91
|
-
<
|
|
95
|
+
<div class="logo">
|
|
96
|
+
No logo set!
|
|
97
|
+
</div>
|
|
92
98
|
</div>
|
|
93
99
|
<div class="topstripe2">${this.letterData?.from?.description || '[no letterData.from.description set]'}</div>
|
|
94
100
|
`;
|