@progress/kendo-react-pdf 6.1.1 → 7.0.0-develop.1
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/npm/KendoDrawingAdapter.d.ts → KendoDrawingAdapter.d.ts} +4 -0
- package/LICENSE.md +1 -1
- package/{dist/npm/PDFExport.d.ts → PDFExport.d.ts} +5 -1
- package/{dist/es/PDFExportProps.d.ts → PDFExportProps.d.ts} +4 -1
- package/{dist/npm/PDFMargin.d.ts → PDFMargin.d.ts} +4 -0
- package/PageTemplateProps.d.ts +17 -0
- package/{dist/npm/common → common}/dom-queries.d.ts +4 -0
- package/{dist/npm/common → common}/table-query.d.ts +4 -0
- package/{dist/es/common → common}/utils.d.ts +4 -0
- package/dist/cdn/js/kendo-react-pdf.js +8 -1
- package/getPageMargin.d.ts +10 -0
- package/{dist/npm/grid → grid}/GridPDFExport.d.ts +4 -0
- package/grid/export-element.d.ts +8 -0
- package/{dist/es/grid → grid}/grid-query.d.ts +4 -0
- package/grid/provideSaveGridPDF.d.ts +9 -0
- package/index.d.ts +14 -0
- package/index.js +8 -0
- package/index.mjs +486 -0
- package/package-metadata.d.ts +9 -0
- package/package.json +28 -35
- package/{dist/npm/savePDF.d.ts → savePDF.d.ts} +4 -0
- package/{dist/es/treelist → treelist}/TreeListPDFExport.d.ts +4 -0
- package/treelist/export-element.d.ts +8 -0
- package/treelist/provideSaveTreeListPDF.d.ts +9 -0
- package/about.md +0 -3
- package/dist/es/KendoDrawingAdapter.d.ts +0 -20
- package/dist/es/KendoDrawingAdapter.js +0 -72
- package/dist/es/PDFExport.d.ts +0 -53
- package/dist/es/PDFExport.js +0 -95
- package/dist/es/PDFExportProps.js +0 -2
- package/dist/es/PDFMargin.d.ts +0 -67
- package/dist/es/PDFMargin.js +0 -37
- package/dist/es/PageTemplateProps.d.ts +0 -13
- package/dist/es/PageTemplateProps.js +0 -1
- package/dist/es/common/dom-queries.d.ts +0 -44
- package/dist/es/common/dom-queries.js +0 -123
- package/dist/es/common/table-query.d.ts +0 -22
- package/dist/es/common/table-query.js +0 -36
- package/dist/es/common/utils.js +0 -74
- package/dist/es/getPageMargin.d.ts +0 -6
- package/dist/es/getPageMargin.js +0 -25
- package/dist/es/grid/GridPDFExport.d.ts +0 -66
- package/dist/es/grid/GridPDFExport.js +0 -97
- package/dist/es/grid/export-element.d.ts +0 -4
- package/dist/es/grid/export-element.js +0 -22
- package/dist/es/grid/grid-query.js +0 -37
- package/dist/es/grid/provideSaveGridPDF.d.ts +0 -5
- package/dist/es/grid/provideSaveGridPDF.js +0 -69
- package/dist/es/main.d.ts +0 -10
- package/dist/es/main.js +0 -8
- package/dist/es/package-metadata.d.ts +0 -5
- package/dist/es/package-metadata.js +0 -11
- package/dist/es/savePDF.d.ts +0 -9
- package/dist/es/savePDF.js +0 -14
- package/dist/es/treelist/TreeListPDFExport.js +0 -93
- package/dist/es/treelist/export-element.d.ts +0 -4
- package/dist/es/treelist/export-element.js +0 -27
- package/dist/es/treelist/provideSaveTreeListPDF.d.ts +0 -5
- package/dist/es/treelist/provideSaveTreeListPDF.js +0 -62
- package/dist/npm/KendoDrawingAdapter.js +0 -74
- package/dist/npm/PDFExport.js +0 -98
- package/dist/npm/PDFExportProps.d.ts +0 -124
- package/dist/npm/PDFExportProps.js +0 -3
- package/dist/npm/PDFMargin.js +0 -40
- package/dist/npm/PageTemplateProps.d.ts +0 -13
- package/dist/npm/PageTemplateProps.js +0 -2
- package/dist/npm/common/dom-queries.js +0 -137
- package/dist/npm/common/table-query.js +0 -39
- package/dist/npm/common/utils.d.ts +0 -20
- package/dist/npm/common/utils.js +0 -82
- package/dist/npm/getPageMargin.d.ts +0 -6
- package/dist/npm/getPageMargin.js +0 -29
- package/dist/npm/grid/GridPDFExport.js +0 -100
- package/dist/npm/grid/export-element.d.ts +0 -4
- package/dist/npm/grid/export-element.js +0 -26
- package/dist/npm/grid/grid-query.d.ts +0 -22
- package/dist/npm/grid/grid-query.js +0 -40
- package/dist/npm/grid/provideSaveGridPDF.d.ts +0 -5
- package/dist/npm/grid/provideSaveGridPDF.js +0 -73
- package/dist/npm/main.d.ts +0 -10
- package/dist/npm/main.js +0 -17
- package/dist/npm/package-metadata.d.ts +0 -5
- package/dist/npm/package-metadata.js +0 -14
- package/dist/npm/savePDF.js +0 -18
- package/dist/npm/treelist/TreeListPDFExport.d.ts +0 -71
- package/dist/npm/treelist/TreeListPDFExport.js +0 -96
- package/dist/npm/treelist/export-element.d.ts +0 -4
- package/dist/npm/treelist/export-element.js +0 -31
- package/dist/npm/treelist/provideSaveTreeListPDF.d.ts +0 -5
- package/dist/npm/treelist/provideSaveTreeListPDF.js +0 -66
- package/dist/systemjs/kendo-react-pdf.js +0 -1
- package/e2e-next/basic.tests.ts +0 -23
package/index.mjs
ADDED
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import * as d from "react";
|
|
6
|
+
import * as e from "prop-types";
|
|
7
|
+
import { drawDOM as G, exportPDF as $ } from "@progress/kendo-drawing";
|
|
8
|
+
import { saveAs as W } from "@progress/kendo-file-saver";
|
|
9
|
+
import * as z from "react-dom/server";
|
|
10
|
+
import * as E from "@progress/kendo-licensing";
|
|
11
|
+
import * as j from "react-dom";
|
|
12
|
+
class M extends d.Component {
|
|
13
|
+
render() {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
M.propTypes = {
|
|
18
|
+
left: e.oneOfType([e.number, e.string]),
|
|
19
|
+
top: e.oneOfType([e.number, e.string]),
|
|
20
|
+
right: e.oneOfType([e.number, e.string]),
|
|
21
|
+
bottom: e.oneOfType([e.number, e.string])
|
|
22
|
+
};
|
|
23
|
+
const S = ["bottom", "left", "right", "top"];
|
|
24
|
+
function v(r) {
|
|
25
|
+
const t = d.Children.toArray(r.children).find((o) => o && o.type === M);
|
|
26
|
+
return t ? K(t) : r.margin;
|
|
27
|
+
}
|
|
28
|
+
function K(r) {
|
|
29
|
+
const t = {};
|
|
30
|
+
for (let o = 0; o < S.length; o++) {
|
|
31
|
+
const n = S[o], s = r.props[n];
|
|
32
|
+
s !== void 0 && (t[n] = s);
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
}
|
|
36
|
+
const Q = "export.pdf", V = "KendoReact PDF Generator";
|
|
37
|
+
class I {
|
|
38
|
+
constructor(t, o, n, s, i = {}) {
|
|
39
|
+
this.drawDOM = t, this.exportPDF = o, this.saveAs = n, this.domElement = s, this.options = i, this.convertPageTemplateToHtml = (p) => `<span>${z.renderToStaticMarkup(
|
|
40
|
+
d.createElement(this.options.pageTemplate, {
|
|
41
|
+
pageNum: p.pageNum,
|
|
42
|
+
totalPages: p.totalPages
|
|
43
|
+
})
|
|
44
|
+
)}</span>`;
|
|
45
|
+
}
|
|
46
|
+
savePDF(t) {
|
|
47
|
+
const o = this.drawDOM(this.domElement, this.getDrawOptions()).then((n) => this.exportPDF(n, this.getPDFOptions())).then((n) => this.saveAs(n, this.options.fileName || Q, this.getSaveOptions()));
|
|
48
|
+
t && o.then(t, t);
|
|
49
|
+
}
|
|
50
|
+
getDrawOptions() {
|
|
51
|
+
return {
|
|
52
|
+
avoidLinks: this.options.avoidLinks,
|
|
53
|
+
forcePageBreak: this.options.forcePageBreak,
|
|
54
|
+
keepTogether: this.options.keepTogether,
|
|
55
|
+
margin: this.options.margin,
|
|
56
|
+
paperSize: this.options.paperSize,
|
|
57
|
+
landscape: this.options.landscape,
|
|
58
|
+
repeatHeaders: this.options.repeatHeaders,
|
|
59
|
+
scale: this.options.scale,
|
|
60
|
+
template: this.options.pageTemplate && this.convertPageTemplateToHtml
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
getPDFOptions() {
|
|
64
|
+
return {
|
|
65
|
+
author: this.options.author,
|
|
66
|
+
creator: this.options.creator || V,
|
|
67
|
+
date: this.options.date,
|
|
68
|
+
imgDPI: this.options.imageResolution,
|
|
69
|
+
keywords: this.options.keywords,
|
|
70
|
+
landscape: this.options.landscape,
|
|
71
|
+
margin: this.options.margin,
|
|
72
|
+
multiPage: !0,
|
|
73
|
+
paperSize: this.options.paperSize,
|
|
74
|
+
producer: this.options.producer,
|
|
75
|
+
subject: this.options.subject,
|
|
76
|
+
title: this.options.title
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
getSaveOptions() {
|
|
80
|
+
return {
|
|
81
|
+
forceProxy: this.options.forceProxy,
|
|
82
|
+
proxyData: this.options.proxyData,
|
|
83
|
+
proxyTarget: this.options.proxyTarget,
|
|
84
|
+
proxyURL: this.options.proxyURL
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const P = {
|
|
89
|
+
name: "@progress/kendo-react-pdf",
|
|
90
|
+
productName: "KendoReact",
|
|
91
|
+
productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
|
|
92
|
+
publishDate: 1700493900,
|
|
93
|
+
version: "",
|
|
94
|
+
licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
|
|
95
|
+
};
|
|
96
|
+
class X extends d.Component {
|
|
97
|
+
constructor(t) {
|
|
98
|
+
if (super(t), this.rootElForPDF = null, typeof E < "u")
|
|
99
|
+
E.validatePackage(P);
|
|
100
|
+
else {
|
|
101
|
+
let o = `License activation failed for ${P.name}
|
|
102
|
+
`;
|
|
103
|
+
o += `The @progress/kendo-licensing script is not loaded.
|
|
104
|
+
`, o += `See ${P.licensingDocsUrl} for more information.
|
|
105
|
+
`, console.warn(o);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @hidden
|
|
110
|
+
*/
|
|
111
|
+
render() {
|
|
112
|
+
return /* @__PURE__ */ d.createElement("div", { ref: (t) => {
|
|
113
|
+
this.rootElForPDF = t;
|
|
114
|
+
} }, this.props.children);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Saves the content as a PDF file.
|
|
118
|
+
*
|
|
119
|
+
* @param callback - The callback to be executed after the PDF is saved.
|
|
120
|
+
*/
|
|
121
|
+
save(t) {
|
|
122
|
+
new I(
|
|
123
|
+
G,
|
|
124
|
+
$,
|
|
125
|
+
W,
|
|
126
|
+
this.rootElForPDF,
|
|
127
|
+
this.getOptions()
|
|
128
|
+
).savePDF(t);
|
|
129
|
+
}
|
|
130
|
+
getOptions() {
|
|
131
|
+
return Object.assign({}, this.props, { margin: v(this.props) });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
X.propTypes = {
|
|
135
|
+
author: e.string,
|
|
136
|
+
avoidLinks: e.oneOfType([e.bool, e.string]),
|
|
137
|
+
forcePageBreak: e.string,
|
|
138
|
+
keepTogether: e.string,
|
|
139
|
+
creator: e.string,
|
|
140
|
+
date: e.instanceOf(Date),
|
|
141
|
+
imageResolution: e.number,
|
|
142
|
+
fileName: e.string,
|
|
143
|
+
forceProxy: e.bool,
|
|
144
|
+
keywords: e.string,
|
|
145
|
+
landscape: e.bool,
|
|
146
|
+
margin: e.oneOfType([e.string, e.number, e.shape({
|
|
147
|
+
left: e.oneOfType([e.number, e.string]),
|
|
148
|
+
top: e.oneOfType([e.number, e.string]),
|
|
149
|
+
right: e.oneOfType([e.number, e.string]),
|
|
150
|
+
bottom: e.oneOfType([e.number, e.string])
|
|
151
|
+
})]),
|
|
152
|
+
pageTemplate: e.any,
|
|
153
|
+
paperSize: e.any,
|
|
154
|
+
repeatHeaders: e.bool,
|
|
155
|
+
scale: e.number,
|
|
156
|
+
proxyData: e.any,
|
|
157
|
+
proxyURL: e.string,
|
|
158
|
+
proxyTarget: e.string,
|
|
159
|
+
producer: e.string,
|
|
160
|
+
subject: e.string,
|
|
161
|
+
title: e.string
|
|
162
|
+
};
|
|
163
|
+
function U(r, t = {}, o) {
|
|
164
|
+
new I(
|
|
165
|
+
G,
|
|
166
|
+
$,
|
|
167
|
+
W,
|
|
168
|
+
r,
|
|
169
|
+
t
|
|
170
|
+
).savePDF(o);
|
|
171
|
+
}
|
|
172
|
+
const O = {}, k = (r) => String(r).trim().split(" "), J = (r, t) => {
|
|
173
|
+
const o = k(t);
|
|
174
|
+
return !!k(r.className).find((n) => o.indexOf(n) >= 0);
|
|
175
|
+
}, u = (r) => (t) => J(t, r), q = (r) => (O[r] || (O[r] = (t) => String(t.nodeName).toLowerCase() === r.toLowerCase()), O[r]), c = (r, t, o = !0) => {
|
|
176
|
+
if (r) {
|
|
177
|
+
if (o && t(r))
|
|
178
|
+
return r;
|
|
179
|
+
for (r = r.firstChild; r; ) {
|
|
180
|
+
if (r.nodeType === 1) {
|
|
181
|
+
const n = c(r, t);
|
|
182
|
+
if (n)
|
|
183
|
+
return n;
|
|
184
|
+
}
|
|
185
|
+
r = r.nextSibling;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}, F = "k-grid-header", w = "k-grid-footer", Y = "TABLE", Z = q(Y), L = (r) => r ? "locked" : "wrap";
|
|
189
|
+
let ee = class {
|
|
190
|
+
constructor(t) {
|
|
191
|
+
this.element = t, this.list = c(t, u("k-grid-container"));
|
|
192
|
+
}
|
|
193
|
+
content(t) {
|
|
194
|
+
return c(this.list, u(`k-grid-content${t ? "-locked" : ""}`));
|
|
195
|
+
}
|
|
196
|
+
header(t) {
|
|
197
|
+
return this.headerWrap = this.headerWrap || c(this.element, u(F)), c(this.headerWrap, u(`${F}-${L(t)}`));
|
|
198
|
+
}
|
|
199
|
+
footer(t) {
|
|
200
|
+
return this.footerWrap = this.footerWrap || c(this.element, u(w)), c(this.footerWrap, u(`${w}-${L(t)}`));
|
|
201
|
+
}
|
|
202
|
+
table() {
|
|
203
|
+
return c(this.element, Z);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
const N = "k-first", te = "k-grid-header", re = "k-grid-footer", B = (r, t) => {
|
|
207
|
+
const o = t.length;
|
|
208
|
+
for (let n = 0; n < o; n++)
|
|
209
|
+
r.appendChild(t[n].cloneNode(!0));
|
|
210
|
+
}, x = (r) => {
|
|
211
|
+
const t = document.createElement("div");
|
|
212
|
+
return t.className = "k-grid k-grid-md", t.appendChild(r), t;
|
|
213
|
+
}, D = (r) => {
|
|
214
|
+
const t = r.length, o = r[0].cloneNode(!0), n = o.rows.length;
|
|
215
|
+
if (t > 1)
|
|
216
|
+
for (let s = 0; s < n; s++)
|
|
217
|
+
for (let i = 1; i < t; i++)
|
|
218
|
+
B(o.rows[s], r[i].rows[s].cells);
|
|
219
|
+
return o;
|
|
220
|
+
}, oe = (r, t) => {
|
|
221
|
+
if (t.length > 1 && r.rows.length > 1)
|
|
222
|
+
for (let o = 1; o < r.rows.length; o++) {
|
|
223
|
+
const n = t[0].rows[o].cells.length, s = r.rows[o].cells[n];
|
|
224
|
+
String(s.className).indexOf(N) === -1 && (s.className += ` ${N}`);
|
|
225
|
+
}
|
|
226
|
+
}, H = (r, t, o, n) => {
|
|
227
|
+
const s = document.createElement("table"), i = r[0].cloneNode(!0);
|
|
228
|
+
for (let a = 1; a < r.length; a++)
|
|
229
|
+
B(i, r[a].querySelectorAll("col"));
|
|
230
|
+
const p = D(t), l = D(o);
|
|
231
|
+
if (p.className = te, oe(p, t), s.appendChild(i), s.appendChild(p), s.appendChild(l), n.length) {
|
|
232
|
+
const a = D(n);
|
|
233
|
+
a.className = re, s.appendChild(a);
|
|
234
|
+
}
|
|
235
|
+
return x(s);
|
|
236
|
+
}, ne = (r) => {
|
|
237
|
+
const t = new ee(r), o = t.content();
|
|
238
|
+
let n;
|
|
239
|
+
if (o) {
|
|
240
|
+
const s = [o.querySelector("colgroup")], i = [t.header().querySelector("thead")], p = [o.querySelector("tbody")], l = t.footer(), a = l ? [l.querySelector("tfoot")] : [];
|
|
241
|
+
n = H(s, i, p, a);
|
|
242
|
+
} else
|
|
243
|
+
n = x(t.table().cloneNode(!0));
|
|
244
|
+
return n;
|
|
245
|
+
};
|
|
246
|
+
function se(r) {
|
|
247
|
+
return (t, o = {}, n, s, i) => ie(
|
|
248
|
+
r,
|
|
249
|
+
t,
|
|
250
|
+
o,
|
|
251
|
+
n,
|
|
252
|
+
s,
|
|
253
|
+
i
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
function ie(r, t, o = {}, n, s, i) {
|
|
257
|
+
let p, l, a;
|
|
258
|
+
g();
|
|
259
|
+
function g() {
|
|
260
|
+
p = document.createElement("div"), p.setAttribute("style", "position:absolute; left: -5000px; top: 0px;"), l = document.createElement("div"), p.appendChild(l), document.body.appendChild(p), j.render(T(), l, f);
|
|
261
|
+
}
|
|
262
|
+
function f() {
|
|
263
|
+
r(b(), o, y);
|
|
264
|
+
}
|
|
265
|
+
function y() {
|
|
266
|
+
document.body.removeChild(p), document.body.removeChild(a), p = a = void 0, n && n();
|
|
267
|
+
}
|
|
268
|
+
function b() {
|
|
269
|
+
a = document.createElement("div"), a.className = "k-grid-pdf-export-element";
|
|
270
|
+
const h = ne(l);
|
|
271
|
+
return a.appendChild(h), document.body.appendChild(a), h;
|
|
272
|
+
}
|
|
273
|
+
function T() {
|
|
274
|
+
const h = s && { data: s, total: s.length, pageSize: s.length, skip: 0 }, C = { style: Object.assign({}, t.props.style, { width: "1000px" }) }, m = Object.assign({}, h, C);
|
|
275
|
+
if (i && i.length > 0) {
|
|
276
|
+
const _ = ae(t);
|
|
277
|
+
return d.cloneElement(t, m, i.concat(_));
|
|
278
|
+
} else
|
|
279
|
+
return d.cloneElement(t, m);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function ae(r) {
|
|
283
|
+
return d.Children.toArray(r.props.children).filter((t) => t && t.type && t.type.displayName !== "KendoReactGridColumn");
|
|
284
|
+
}
|
|
285
|
+
class pe extends d.Component {
|
|
286
|
+
constructor(t) {
|
|
287
|
+
super(t), this.saveGridPDF = se(this.getSavePDF());
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* @hidden
|
|
291
|
+
*/
|
|
292
|
+
render() {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
/* eslint-disable max-len */
|
|
296
|
+
/**
|
|
297
|
+
* Saves the content of the Grid as a PDF file.
|
|
298
|
+
*
|
|
299
|
+
* @param data - The data can be different from the currently displayed data in the Grid. Can be used to export all Grid pages.
|
|
300
|
+
* @param callback - The callback that will be executed after the PDF is saved.
|
|
301
|
+
*/
|
|
302
|
+
// tslint:enable:max-line-length
|
|
303
|
+
save(t, o) {
|
|
304
|
+
this.saveGridPDF(
|
|
305
|
+
this.getGrid(),
|
|
306
|
+
Object.assign({}, this.props, { margin: v(this.props) }),
|
|
307
|
+
o,
|
|
308
|
+
t,
|
|
309
|
+
this.getCustomColumns()
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
getSavePDF() {
|
|
313
|
+
return U;
|
|
314
|
+
}
|
|
315
|
+
getGrid() {
|
|
316
|
+
return d.Children.toArray(this.props.children).find((t) => t && t.type.displayName === "KendoReactGrid");
|
|
317
|
+
}
|
|
318
|
+
getCustomColumns() {
|
|
319
|
+
return d.Children.toArray(this.props.children).filter((t) => t && t.type.displayName === "KendoReactGridColumn");
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
pe.propTypes = {
|
|
323
|
+
author: e.string,
|
|
324
|
+
avoidLinks: e.oneOfType([e.bool, e.string]),
|
|
325
|
+
forcePageBreak: e.string,
|
|
326
|
+
keepTogether: e.string,
|
|
327
|
+
creator: e.string,
|
|
328
|
+
date: e.instanceOf(Date),
|
|
329
|
+
imageResolution: e.number,
|
|
330
|
+
fileName: e.string,
|
|
331
|
+
forceProxy: e.bool,
|
|
332
|
+
keywords: e.string,
|
|
333
|
+
landscape: e.bool,
|
|
334
|
+
margin: e.oneOfType([e.string, e.number, e.shape({
|
|
335
|
+
left: e.oneOfType([e.number, e.string]),
|
|
336
|
+
top: e.oneOfType([e.number, e.string]),
|
|
337
|
+
right: e.oneOfType([e.number, e.string]),
|
|
338
|
+
bottom: e.oneOfType([e.number, e.string])
|
|
339
|
+
})]),
|
|
340
|
+
pageTemplate: e.any,
|
|
341
|
+
paperSize: e.any,
|
|
342
|
+
repeatHeaders: e.bool,
|
|
343
|
+
scale: e.number,
|
|
344
|
+
proxyData: e.any,
|
|
345
|
+
proxyURL: e.string,
|
|
346
|
+
proxyTarget: e.string,
|
|
347
|
+
producer: e.string,
|
|
348
|
+
subject: e.string,
|
|
349
|
+
title: e.string
|
|
350
|
+
};
|
|
351
|
+
const A = "k-grid-header", R = "k-grid-footer", le = "TABLE", ce = q(le);
|
|
352
|
+
class de {
|
|
353
|
+
constructor(t) {
|
|
354
|
+
this.element = t, this.list = c(t, u("k-grid"));
|
|
355
|
+
}
|
|
356
|
+
content() {
|
|
357
|
+
return c(this.list, u("k-grid"));
|
|
358
|
+
}
|
|
359
|
+
header() {
|
|
360
|
+
return this.headerWrap = this.headerWrap || c(this.element, u(A)), c(this.headerWrap, u(`${A}`));
|
|
361
|
+
}
|
|
362
|
+
footer() {
|
|
363
|
+
return this.footerWrap = this.footerWrap || c(this.element, u(R)), c(this.footerWrap, u(`${R}`));
|
|
364
|
+
}
|
|
365
|
+
table() {
|
|
366
|
+
return c(this.element, ce);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
const ue = (r) => {
|
|
370
|
+
const t = new de(r), o = t.content();
|
|
371
|
+
let n, s = t.header();
|
|
372
|
+
if (s.childNodes.length > 1 && s.removeChild(s.childNodes[1]), s.childNodes[0].childNodes.forEach((i) => i.style.top = 0), o) {
|
|
373
|
+
const i = [o.querySelector("colgroup")], p = [s], l = [o.querySelector("tbody")], a = t.footer(), g = a ? [a.querySelector("tfoot")] : [];
|
|
374
|
+
n = H(i, p, l, g);
|
|
375
|
+
} else
|
|
376
|
+
n = x(t.table().cloneNode(!0));
|
|
377
|
+
return n;
|
|
378
|
+
};
|
|
379
|
+
function he(r) {
|
|
380
|
+
return (t, o = {}, n, s, i) => ge(
|
|
381
|
+
r,
|
|
382
|
+
t,
|
|
383
|
+
o,
|
|
384
|
+
n,
|
|
385
|
+
s,
|
|
386
|
+
i
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
function ge(r, t, o = {}, n, s, i) {
|
|
390
|
+
let p, l, a;
|
|
391
|
+
g();
|
|
392
|
+
function g() {
|
|
393
|
+
p = document.createElement("div"), p.setAttribute("style", "position:absolute; left: -5000px; top: 0px;"), l = document.createElement("div"), p.appendChild(l), document.body.appendChild(p), j.render(T(), l, f);
|
|
394
|
+
}
|
|
395
|
+
function f() {
|
|
396
|
+
r(b(), o, y);
|
|
397
|
+
}
|
|
398
|
+
function y() {
|
|
399
|
+
document.body.removeChild(p), document.body.removeChild(a), p = a = void 0, n && n();
|
|
400
|
+
}
|
|
401
|
+
function b() {
|
|
402
|
+
a = document.createElement("div"), a.className = "k-treelist-pdf-export-element";
|
|
403
|
+
const h = ue(l);
|
|
404
|
+
return a.appendChild(h), document.body.appendChild(a), a;
|
|
405
|
+
}
|
|
406
|
+
function T() {
|
|
407
|
+
const h = o.allPages && s ? { data: s, take: Number.MAX_VALUE, skip: 0 } : {}, C = { style: Object.assign({}, t.props.style, { width: "1000px" }) }, m = Object.assign({}, h, C);
|
|
408
|
+
return i && i.length > 0 ? d.cloneElement(t, Object.assign({}, m, { columns: i })) : d.cloneElement(t, m);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
class me extends d.Component {
|
|
412
|
+
constructor(t) {
|
|
413
|
+
super(t), this.saveTreeListPDF = he(this.getSavePDF());
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* @hidden
|
|
417
|
+
*/
|
|
418
|
+
render() {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
/* eslint-disable max-len */
|
|
422
|
+
/**
|
|
423
|
+
* Saves the content of the TreeList as a PDF file.
|
|
424
|
+
*
|
|
425
|
+
* @param data - The data that will be exported to the PDF. The data can be different from the currently displayed data in the TreeList.
|
|
426
|
+
* @param columns - The columns that will be exported to the PDF. The columns collection can be different from the currently displayed in the TreeList.
|
|
427
|
+
* @param callback - The callback that will be executed after the PDF is saved.
|
|
428
|
+
*/
|
|
429
|
+
// tslint:enable:max-line-length
|
|
430
|
+
save(t, o, n) {
|
|
431
|
+
this.saveTreeListPDF(
|
|
432
|
+
this.getTreeList(),
|
|
433
|
+
Object.assign({}, this.props, { margin: v(this.props) }),
|
|
434
|
+
n,
|
|
435
|
+
t,
|
|
436
|
+
o || []
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
getSavePDF() {
|
|
440
|
+
return U;
|
|
441
|
+
}
|
|
442
|
+
getTreeList() {
|
|
443
|
+
const t = this.props.children;
|
|
444
|
+
if (t && t.props.data && t.props.columns)
|
|
445
|
+
return this.props.children;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
me.propTypes = {
|
|
449
|
+
author: e.string,
|
|
450
|
+
avoidLinks: e.oneOfType([e.bool, e.string]),
|
|
451
|
+
forcePageBreak: e.string,
|
|
452
|
+
keepTogether: e.string,
|
|
453
|
+
creator: e.string,
|
|
454
|
+
date: e.instanceOf(Date),
|
|
455
|
+
imageResolution: e.number,
|
|
456
|
+
fileName: e.string,
|
|
457
|
+
forceProxy: e.bool,
|
|
458
|
+
keywords: e.string,
|
|
459
|
+
landscape: e.bool,
|
|
460
|
+
margin: e.oneOfType([e.string, e.number, e.shape({
|
|
461
|
+
left: e.oneOfType([e.number, e.string]),
|
|
462
|
+
top: e.oneOfType([e.number, e.string]),
|
|
463
|
+
right: e.oneOfType([e.number, e.string]),
|
|
464
|
+
bottom: e.oneOfType([e.number, e.string])
|
|
465
|
+
})]),
|
|
466
|
+
pageTemplate: e.any,
|
|
467
|
+
paperSize: e.any,
|
|
468
|
+
repeatHeaders: e.bool,
|
|
469
|
+
scale: e.number,
|
|
470
|
+
proxyData: e.any,
|
|
471
|
+
proxyURL: e.string,
|
|
472
|
+
proxyTarget: e.string,
|
|
473
|
+
producer: e.string,
|
|
474
|
+
subject: e.string,
|
|
475
|
+
title: e.string,
|
|
476
|
+
allPages: e.bool
|
|
477
|
+
};
|
|
478
|
+
export {
|
|
479
|
+
pe as GridPDFExport,
|
|
480
|
+
I as KendoDrawingAdapter,
|
|
481
|
+
X as PDFExport,
|
|
482
|
+
M as PDFMargin,
|
|
483
|
+
me as TreeListPDFExport,
|
|
484
|
+
v as getPageMargin,
|
|
485
|
+
U as savePDF
|
|
486
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { PackageMetadata } from '@progress/kendo-licensing';
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
export declare const packageMetadata: PackageMetadata;
|
package/package.json
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-pdf",
|
|
3
|
+
"version": "7.0.0-develop.1",
|
|
3
4
|
"description": "React PDF Processing enables you to export single- and multi-page content in PDF. KendoReact PDF Processing package",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
"author": "Progress",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
|
+
"homepage": "https://www.telerik.com/kendo-react-ui",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./index.mjs",
|
|
13
|
+
"require": "./index.js"
|
|
14
|
+
}
|
|
8
15
|
},
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"@progress/kendo-drawing": "^1.17.2",
|
|
19
|
+
"@progress/kendo-file-saver": "^1.0.1",
|
|
20
|
+
"@progress/kendo-licensing": "^1.3.0",
|
|
21
|
+
"@progress/kendo-react-common": "7.0.0-develop.1",
|
|
22
|
+
"react": "^16.8.2 || ^17.0.0 || ^18.0.0",
|
|
23
|
+
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"prop-types": "^15.6.0"
|
|
17
27
|
},
|
|
18
|
-
"homepage": "https://www.telerik.com/kendo-react-ui",
|
|
19
28
|
"keywords": [
|
|
20
29
|
"Kendo UI",
|
|
21
30
|
"React",
|
|
@@ -29,31 +38,15 @@
|
|
|
29
38
|
"Telerik",
|
|
30
39
|
"PDF export"
|
|
31
40
|
],
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"@progress/kendo-drawing": "^1.17.2",
|
|
34
|
-
"@progress/kendo-licensing": "^1.3.0",
|
|
35
|
-
"react": "^16.8.2 || ^17.0.0 || ^18.0.0",
|
|
36
|
-
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@progress/kendo-file-saver": "^1.0.1"
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@progress/kendo-date-math": "^1.4.1",
|
|
43
|
-
"@progress/kendo-drawing": "^1.17.2",
|
|
44
|
-
"@progress/kendo-licensing": "^1.3.0",
|
|
45
|
-
"@progress/kendo-react-charts": "6.1.1",
|
|
46
|
-
"@progress/kendo-react-grid": "6.1.1",
|
|
47
|
-
"prop-types": "^15.6.0"
|
|
48
|
-
},
|
|
49
41
|
"@progress": {
|
|
50
42
|
"friendlyName": "PDF",
|
|
51
43
|
"framework": "KendoReact"
|
|
52
44
|
},
|
|
53
|
-
"
|
|
54
|
-
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/telerik/kendo-react.git"
|
|
48
|
+
},
|
|
55
49
|
"publishConfig": {
|
|
56
50
|
"access": "public"
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
1
5
|
import { PDFExportProps } from './PDFExportProps';
|
|
2
6
|
/**
|
|
3
7
|
* Saves the content of a DOM element to a PDF file.
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
1
5
|
import * as React from 'react';
|
|
2
6
|
import * as PropTypes from 'prop-types';
|
|
3
7
|
import { savePDF } from '../savePDF';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
export declare const exportElement: (wrapper: HTMLElement) => HTMLElement;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { TreeListPDFExportProps } from './TreeListPDFExport';
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
export declare function provideSaveTreeListPDF(savePDF: (domElement: HTMLElement, options?: TreeListPDFExportProps, callback?: () => void) => void): (treeList: any, pdfExportOptions?: TreeListPDFExportProps, callback?: () => void, data?: any, columns?: any) => void;
|
package/about.md
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { DrawOptions, Group } from '@progress/kendo-drawing';
|
|
2
|
-
import { PDFOptions } from '@progress/kendo-drawing/pdf';
|
|
3
|
-
import { SaveOptions } from '@progress/kendo-file-saver';
|
|
4
|
-
import { PDFExportProps } from './PDFExportProps';
|
|
5
|
-
/**
|
|
6
|
-
* @hidden
|
|
7
|
-
*/
|
|
8
|
-
export default class KendoDrawingAdapter {
|
|
9
|
-
private drawDOM;
|
|
10
|
-
private exportPDF;
|
|
11
|
-
private saveAs;
|
|
12
|
-
private domElement;
|
|
13
|
-
private options;
|
|
14
|
-
constructor(drawDOM: (element: HTMLElement, options: DrawOptions) => Promise<Group>, exportPDF: (group: Group, options: PDFOptions) => Promise<string>, saveAs: (dataUri: string, fileName: string, options: SaveOptions) => void, domElement: HTMLElement, options?: PDFExportProps);
|
|
15
|
-
savePDF(callback?: () => void): void;
|
|
16
|
-
private getDrawOptions;
|
|
17
|
-
private getPDFOptions;
|
|
18
|
-
private getSaveOptions;
|
|
19
|
-
private convertPageTemplateToHtml;
|
|
20
|
-
}
|