@progress/kendo-react-pdf 6.1.1 → 7.0.0-develop.2

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.
Files changed (92) hide show
  1. package/{dist/npm/KendoDrawingAdapter.d.ts → KendoDrawingAdapter.d.ts} +4 -0
  2. package/LICENSE.md +1 -1
  3. package/{dist/npm/PDFExport.d.ts → PDFExport.d.ts} +5 -1
  4. package/{dist/es/PDFExportProps.d.ts → PDFExportProps.d.ts} +4 -1
  5. package/{dist/npm/PDFMargin.d.ts → PDFMargin.d.ts} +4 -0
  6. package/PageTemplateProps.d.ts +17 -0
  7. package/{dist/npm/common → common}/dom-queries.d.ts +4 -0
  8. package/{dist/npm/common → common}/table-query.d.ts +4 -0
  9. package/{dist/es/common → common}/utils.d.ts +4 -0
  10. package/dist/cdn/js/kendo-react-pdf.js +8 -1
  11. package/getPageMargin.d.ts +10 -0
  12. package/{dist/npm/grid → grid}/GridPDFExport.d.ts +4 -0
  13. package/grid/export-element.d.ts +8 -0
  14. package/{dist/es/grid → grid}/grid-query.d.ts +4 -0
  15. package/grid/provideSaveGridPDF.d.ts +9 -0
  16. package/index.d.ts +14 -0
  17. package/index.js +8 -0
  18. package/index.mjs +486 -0
  19. package/package-metadata.d.ts +9 -0
  20. package/package.json +28 -35
  21. package/{dist/npm/savePDF.d.ts → savePDF.d.ts} +4 -0
  22. package/{dist/es/treelist → treelist}/TreeListPDFExport.d.ts +4 -0
  23. package/treelist/export-element.d.ts +8 -0
  24. package/treelist/provideSaveTreeListPDF.d.ts +9 -0
  25. package/about.md +0 -3
  26. package/dist/es/KendoDrawingAdapter.d.ts +0 -20
  27. package/dist/es/KendoDrawingAdapter.js +0 -72
  28. package/dist/es/PDFExport.d.ts +0 -53
  29. package/dist/es/PDFExport.js +0 -95
  30. package/dist/es/PDFExportProps.js +0 -2
  31. package/dist/es/PDFMargin.d.ts +0 -67
  32. package/dist/es/PDFMargin.js +0 -37
  33. package/dist/es/PageTemplateProps.d.ts +0 -13
  34. package/dist/es/PageTemplateProps.js +0 -1
  35. package/dist/es/common/dom-queries.d.ts +0 -44
  36. package/dist/es/common/dom-queries.js +0 -123
  37. package/dist/es/common/table-query.d.ts +0 -22
  38. package/dist/es/common/table-query.js +0 -36
  39. package/dist/es/common/utils.js +0 -74
  40. package/dist/es/getPageMargin.d.ts +0 -6
  41. package/dist/es/getPageMargin.js +0 -25
  42. package/dist/es/grid/GridPDFExport.d.ts +0 -66
  43. package/dist/es/grid/GridPDFExport.js +0 -97
  44. package/dist/es/grid/export-element.d.ts +0 -4
  45. package/dist/es/grid/export-element.js +0 -22
  46. package/dist/es/grid/grid-query.js +0 -37
  47. package/dist/es/grid/provideSaveGridPDF.d.ts +0 -5
  48. package/dist/es/grid/provideSaveGridPDF.js +0 -69
  49. package/dist/es/main.d.ts +0 -10
  50. package/dist/es/main.js +0 -8
  51. package/dist/es/package-metadata.d.ts +0 -5
  52. package/dist/es/package-metadata.js +0 -11
  53. package/dist/es/savePDF.d.ts +0 -9
  54. package/dist/es/savePDF.js +0 -14
  55. package/dist/es/treelist/TreeListPDFExport.js +0 -93
  56. package/dist/es/treelist/export-element.d.ts +0 -4
  57. package/dist/es/treelist/export-element.js +0 -27
  58. package/dist/es/treelist/provideSaveTreeListPDF.d.ts +0 -5
  59. package/dist/es/treelist/provideSaveTreeListPDF.js +0 -62
  60. package/dist/npm/KendoDrawingAdapter.js +0 -74
  61. package/dist/npm/PDFExport.js +0 -98
  62. package/dist/npm/PDFExportProps.d.ts +0 -124
  63. package/dist/npm/PDFExportProps.js +0 -3
  64. package/dist/npm/PDFMargin.js +0 -40
  65. package/dist/npm/PageTemplateProps.d.ts +0 -13
  66. package/dist/npm/PageTemplateProps.js +0 -2
  67. package/dist/npm/common/dom-queries.js +0 -137
  68. package/dist/npm/common/table-query.js +0 -39
  69. package/dist/npm/common/utils.d.ts +0 -20
  70. package/dist/npm/common/utils.js +0 -82
  71. package/dist/npm/getPageMargin.d.ts +0 -6
  72. package/dist/npm/getPageMargin.js +0 -29
  73. package/dist/npm/grid/GridPDFExport.js +0 -100
  74. package/dist/npm/grid/export-element.d.ts +0 -4
  75. package/dist/npm/grid/export-element.js +0 -26
  76. package/dist/npm/grid/grid-query.d.ts +0 -22
  77. package/dist/npm/grid/grid-query.js +0 -40
  78. package/dist/npm/grid/provideSaveGridPDF.d.ts +0 -5
  79. package/dist/npm/grid/provideSaveGridPDF.js +0 -73
  80. package/dist/npm/main.d.ts +0 -10
  81. package/dist/npm/main.js +0 -17
  82. package/dist/npm/package-metadata.d.ts +0 -5
  83. package/dist/npm/package-metadata.js +0 -14
  84. package/dist/npm/savePDF.js +0 -18
  85. package/dist/npm/treelist/TreeListPDFExport.d.ts +0 -71
  86. package/dist/npm/treelist/TreeListPDFExport.js +0 -96
  87. package/dist/npm/treelist/export-element.d.ts +0 -4
  88. package/dist/npm/treelist/export-element.js +0 -31
  89. package/dist/npm/treelist/provideSaveTreeListPDF.d.ts +0 -5
  90. package/dist/npm/treelist/provideSaveTreeListPDF.js +0 -66
  91. package/dist/systemjs/kendo-react-pdf.js +0 -1
  92. package/e2e-next/basic.tests.ts +0 -23
@@ -1,66 +0,0 @@
1
- import * as React from 'react';
2
- import * as PropTypes from 'prop-types';
3
- import { savePDF } from '../savePDF';
4
- import { PDFExportProps } from '../PDFExportProps';
5
- /**
6
- * The props of the GridPDFExport component
7
- * ([more information and examples in the documentation on PDF export]({% slug overview_pdfexport_grid %})).
8
- */
9
- export interface GridPDFExportProps extends PDFExportProps {
10
- }
11
- /**
12
- * A React component which facilitates the PDF export of the Grid.
13
- */
14
- export declare class GridPDFExport extends React.Component<GridPDFExportProps, {}> {
15
- /**
16
- * @hidden
17
- */
18
- static propTypes: {
19
- author: PropTypes.Requireable<string>;
20
- avoidLinks: PropTypes.Requireable<NonNullable<string | boolean | null | undefined>>;
21
- forcePageBreak: PropTypes.Requireable<string>;
22
- keepTogether: PropTypes.Requireable<string>;
23
- creator: PropTypes.Requireable<string>;
24
- date: PropTypes.Requireable<Date>;
25
- imageResolution: PropTypes.Requireable<number>;
26
- fileName: PropTypes.Requireable<string>;
27
- forceProxy: PropTypes.Requireable<boolean>;
28
- keywords: PropTypes.Requireable<string>;
29
- landscape: PropTypes.Requireable<boolean>;
30
- margin: PropTypes.Requireable<NonNullable<string | number | PropTypes.InferProps<{
31
- left: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
32
- top: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
33
- right: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
34
- bottom: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
35
- }> | null | undefined>>;
36
- pageTemplate: PropTypes.Requireable<any>;
37
- paperSize: PropTypes.Requireable<any>;
38
- repeatHeaders: PropTypes.Requireable<boolean>;
39
- scale: PropTypes.Requireable<number>;
40
- proxyData: PropTypes.Requireable<any>;
41
- proxyURL: PropTypes.Requireable<string>;
42
- proxyTarget: PropTypes.Requireable<string>;
43
- producer: PropTypes.Requireable<string>;
44
- subject: PropTypes.Requireable<string>;
45
- title: PropTypes.Requireable<string>;
46
- };
47
- /**
48
- * @hidden
49
- */
50
- saveGridPDF: any;
51
- constructor(props: any);
52
- /**
53
- * @hidden
54
- */
55
- render(): null;
56
- /**
57
- * Saves the content of the Grid as a PDF file.
58
- *
59
- * @param data - The data can be different from the currently displayed data in the Grid. Can be used to export all Grid pages.
60
- * @param callback - The callback that will be executed after the PDF is saved.
61
- */
62
- save(data?: any[], callback?: () => void): void;
63
- protected getSavePDF(): typeof savePDF;
64
- private getGrid;
65
- private getCustomColumns;
66
- }
@@ -1,97 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- import * as React from 'react';
17
- import * as PropTypes from 'prop-types';
18
- import { getPageMargin } from '../getPageMargin';
19
- import { savePDF } from '../savePDF';
20
- import { provideSaveGridPDF } from './provideSaveGridPDF';
21
- /**
22
- * A React component which facilitates the PDF export of the Grid.
23
- */
24
- var GridPDFExport = /** @class */ (function (_super) {
25
- __extends(GridPDFExport, _super);
26
- function GridPDFExport(props) {
27
- var _this = _super.call(this, props) || this;
28
- _this.saveGridPDF = provideSaveGridPDF(_this.getSavePDF());
29
- return _this;
30
- }
31
- /**
32
- * @hidden
33
- */
34
- GridPDFExport.prototype.render = function () {
35
- return null;
36
- };
37
- /* eslint-disable max-len */
38
- /**
39
- * Saves the content of the Grid as a PDF file.
40
- *
41
- * @param data - The data can be different from the currently displayed data in the Grid. Can be used to export all Grid pages.
42
- * @param callback - The callback that will be executed after the PDF is saved.
43
- */
44
- // tslint:enable:max-line-length
45
- GridPDFExport.prototype.save = function (data, callback) {
46
- this.saveGridPDF(this.getGrid(), Object.assign({}, this.props, { margin: getPageMargin(this.props) }), callback, data, this.getCustomColumns());
47
- };
48
- GridPDFExport.prototype.getSavePDF = function () {
49
- return savePDF;
50
- };
51
- GridPDFExport.prototype.getGrid = function () {
52
- return React.Children
53
- .toArray(this.props.children)
54
- .find(function (child) { return child &&
55
- child.type.displayName === 'KendoReactGrid'; });
56
- };
57
- GridPDFExport.prototype.getCustomColumns = function () {
58
- return React.Children
59
- .toArray(this.props.children)
60
- .filter(function (child) { return child &&
61
- child.type.displayName === 'KendoReactGridColumn'; });
62
- };
63
- /**
64
- * @hidden
65
- */
66
- GridPDFExport.propTypes = {
67
- author: PropTypes.string,
68
- avoidLinks: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
69
- forcePageBreak: PropTypes.string,
70
- keepTogether: PropTypes.string,
71
- creator: PropTypes.string,
72
- date: PropTypes.instanceOf(Date),
73
- imageResolution: PropTypes.number,
74
- fileName: PropTypes.string,
75
- forceProxy: PropTypes.bool,
76
- keywords: PropTypes.string,
77
- landscape: PropTypes.bool,
78
- margin: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.shape({
79
- left: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
80
- top: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
81
- right: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
82
- bottom: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
83
- })]),
84
- pageTemplate: PropTypes.any,
85
- paperSize: PropTypes.any,
86
- repeatHeaders: PropTypes.bool,
87
- scale: PropTypes.number,
88
- proxyData: PropTypes.any,
89
- proxyURL: PropTypes.string,
90
- proxyTarget: PropTypes.string,
91
- producer: PropTypes.string,
92
- subject: PropTypes.string,
93
- title: PropTypes.string
94
- };
95
- return GridPDFExport;
96
- }(React.Component));
97
- export { GridPDFExport };
@@ -1,4 +0,0 @@
1
- /**
2
- * @hidden
3
- */
4
- export declare const exportElement: (wrapper: HTMLElement) => HTMLElement;
@@ -1,22 +0,0 @@
1
- import { GridQuery } from './grid-query';
2
- import { wrapTable, createTable } from '../common/utils';
3
- /**
4
- * @hidden
5
- */
6
- export var exportElement = function (wrapper) {
7
- var query = new GridQuery(wrapper);
8
- var content = query.content();
9
- var result;
10
- if (content) {
11
- var colGroups = [content.querySelector('colgroup')];
12
- var headers = [query.header().querySelector('thead')];
13
- var bodies = [content.querySelector('tbody')];
14
- var footer = query.footer();
15
- var footers = footer ? [footer.querySelector('tfoot')] : [];
16
- result = createTable(colGroups, headers, bodies, footers);
17
- }
18
- else {
19
- result = wrapTable(query.table().cloneNode(true));
20
- }
21
- return result;
22
- };
@@ -1,37 +0,0 @@
1
- import { matchesClasses, matchesNodeName, findElement } from '../common/dom-queries';
2
- /**
3
- * @hidden
4
- */
5
- export var HEADER_CLASS = 'k-grid-header';
6
- /**
7
- * @hidden
8
- */
9
- export var FOOTER_CLASS = 'k-grid-footer';
10
- var TABLE = 'TABLE';
11
- var matchesTable = matchesNodeName(TABLE);
12
- var suffix = function (locked) { return locked ? 'locked' : 'wrap'; };
13
- /**
14
- * @hidden
15
- */
16
- var GridQuery = /** @class */ (function () {
17
- function GridQuery(element) {
18
- this.element = element;
19
- this.list = findElement(element, matchesClasses('k-grid-container'));
20
- }
21
- GridQuery.prototype.content = function (locked) {
22
- return findElement(this.list, matchesClasses("k-grid-content".concat(locked ? '-locked' : '')));
23
- };
24
- GridQuery.prototype.header = function (locked) {
25
- this.headerWrap = this.headerWrap || findElement(this.element, matchesClasses(HEADER_CLASS));
26
- return findElement(this.headerWrap, matchesClasses("".concat(HEADER_CLASS, "-").concat(suffix(locked))));
27
- };
28
- GridQuery.prototype.footer = function (locked) {
29
- this.footerWrap = this.footerWrap || findElement(this.element, matchesClasses(FOOTER_CLASS));
30
- return findElement(this.footerWrap, matchesClasses("".concat(FOOTER_CLASS, "-").concat(suffix(locked))));
31
- };
32
- GridQuery.prototype.table = function () {
33
- return findElement(this.element, matchesTable);
34
- };
35
- return GridQuery;
36
- }());
37
- export { GridQuery };
@@ -1,5 +0,0 @@
1
- import { PDFExportProps } from '../PDFExportProps';
2
- /**
3
- * @hidden
4
- */
5
- export declare function provideSaveGridPDF(savePDF: (domElement: HTMLElement, options?: PDFExportProps, callback?: () => void) => void): (grid: any, pdfExportOptions?: PDFExportProps, callback?: () => void, data?: any, columns?: any) => void;
@@ -1,69 +0,0 @@
1
- import * as ReactDOM from 'react-dom';
2
- import * as React from 'react';
3
- import { exportElement } from './export-element';
4
- /**
5
- * @hidden
6
- */
7
- export function provideSaveGridPDF(savePDF) {
8
- return function (grid, pdfExportOptions, callback, data, columns) {
9
- if (pdfExportOptions === void 0) { pdfExportOptions = {}; }
10
- return saveGridPDF(savePDF, grid, pdfExportOptions, callback, data, columns);
11
- };
12
- }
13
- function saveGridPDF(savePDF, grid, pdfExportOptions, callback, data, columns) {
14
- if (pdfExportOptions === void 0) { pdfExportOptions = {}; }
15
- renderGrid();
16
- var gridOuterWrapper;
17
- var gridInnerWrapper;
18
- var finalContainer;
19
- function renderGrid() {
20
- gridOuterWrapper = document.createElement('div');
21
- gridOuterWrapper.setAttribute('style', 'position:absolute; left: -5000px; top: 0px;');
22
- gridInnerWrapper = document.createElement('div');
23
- gridOuterWrapper.appendChild(gridInnerWrapper);
24
- document.body.appendChild(gridOuterWrapper);
25
- ReactDOM.render(prepareRawGridForExport(), gridInnerWrapper, onGridRendered);
26
- }
27
- function onGridRendered() {
28
- savePDF(prepareFinalElementForExport(), pdfExportOptions, cleanUpAndInvokeCallback);
29
- }
30
- function cleanUpAndInvokeCallback() {
31
- document.body.removeChild(gridOuterWrapper);
32
- document.body.removeChild(finalContainer);
33
- gridOuterWrapper = finalContainer = undefined;
34
- if (callback) {
35
- callback();
36
- }
37
- }
38
- function prepareFinalElementForExport() {
39
- /* Ultimatelly, there is no need for double DOM-copying of the grid.
40
- The one in this method is a copied Angular implementation
41
- that has been plugged almost seemlessly. */
42
- finalContainer = document.createElement('div');
43
- finalContainer.className = 'k-grid-pdf-export-element';
44
- var result = exportElement(gridInnerWrapper);
45
- finalContainer.appendChild(result);
46
- document.body.appendChild(finalContainer);
47
- return result;
48
- }
49
- function prepareRawGridForExport() {
50
- var customDataProps = data && { data: data, total: data.length, pageSize: data.length, skip: 0 };
51
- // A custom width is needed because otherwise when all pages are exported,
52
- // the "hidden" PDF grid will be visible.
53
- var customStyleProp = { style: Object.assign({}, grid.props.style, { width: '1000px' }) };
54
- var customProps = Object.assign({}, customDataProps, customStyleProp);
55
- if (columns && columns.length > 0) {
56
- var notColumnChildren = getGridNotColumnChildren(grid);
57
- return React.cloneElement(grid, customProps, columns.concat(notColumnChildren));
58
- }
59
- else {
60
- return React.cloneElement(grid, customProps);
61
- }
62
- }
63
- }
64
- function getGridNotColumnChildren(grid) {
65
- return React.Children
66
- .toArray(grid.props.children)
67
- .filter(function (child) { return child && child.type &&
68
- child.type.displayName !== 'KendoReactGridColumn'; });
69
- }
package/dist/es/main.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { PDFExport } from './PDFExport';
2
- import { PDFExportProps } from './PDFExportProps';
3
- import { PageTemplateProps } from './PageTemplateProps';
4
- import { PDFMargin, PDFMarginProps } from './PDFMargin';
5
- import { savePDF } from './savePDF';
6
- import { getPageMargin } from './getPageMargin';
7
- import { GridPDFExport, GridPDFExportProps } from './grid/GridPDFExport';
8
- import { TreeListPDFExport, TreeListPDFExportProps } from './treelist/TreeListPDFExport';
9
- import KendoDrawingAdapter from './KendoDrawingAdapter';
10
- export { PDFExport, PDFExportProps, PageTemplateProps, PDFMargin, PDFMarginProps, savePDF, getPageMargin, GridPDFExport, GridPDFExportProps, TreeListPDFExport, TreeListPDFExportProps, KendoDrawingAdapter };
package/dist/es/main.js DELETED
@@ -1,8 +0,0 @@
1
- import { PDFExport } from './PDFExport';
2
- import { PDFMargin } from './PDFMargin';
3
- import { savePDF } from './savePDF';
4
- import { getPageMargin } from './getPageMargin';
5
- import { GridPDFExport } from './grid/GridPDFExport';
6
- import { TreeListPDFExport } from './treelist/TreeListPDFExport';
7
- import KendoDrawingAdapter from './KendoDrawingAdapter';
8
- export { PDFExport, PDFMargin, savePDF, getPageMargin, GridPDFExport, TreeListPDFExport, KendoDrawingAdapter };
@@ -1,5 +0,0 @@
1
- import { PackageMetadata } from '@progress/kendo-licensing';
2
- /**
3
- * @hidden
4
- */
5
- export declare const packageMetadata: PackageMetadata;
@@ -1,11 +0,0 @@
1
- /**
2
- * @hidden
3
- */
4
- export var packageMetadata = {
5
- name: '@progress/kendo-react-pdf',
6
- productName: 'KendoReact',
7
- productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
8
- publishDate: 1700064286,
9
- version: '',
10
- licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
11
- };
@@ -1,9 +0,0 @@
1
- import { PDFExportProps } from './PDFExportProps';
2
- /**
3
- * Saves the content of a DOM element to a PDF file.
4
- *
5
- * @param domElement - The root DOM element to save to a PDF file.
6
- * @param options - The export options.
7
- * @param callback - The callback to be executed after the PDF is saved.
8
- */
9
- export declare function savePDF(domElement: HTMLElement, options?: PDFExportProps, callback?: () => void): void;
@@ -1,14 +0,0 @@
1
- import { drawDOM, exportPDF } from '@progress/kendo-drawing';
2
- import { saveAs } from '@progress/kendo-file-saver';
3
- import KendoDrawingAdapter from './KendoDrawingAdapter';
4
- /**
5
- * Saves the content of a DOM element to a PDF file.
6
- *
7
- * @param domElement - The root DOM element to save to a PDF file.
8
- * @param options - The export options.
9
- * @param callback - The callback to be executed after the PDF is saved.
10
- */
11
- export function savePDF(domElement, options, callback) {
12
- if (options === void 0) { options = {}; }
13
- new KendoDrawingAdapter(drawDOM, exportPDF, saveAs, domElement, options).savePDF(callback);
14
- }
@@ -1,93 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- import * as React from 'react';
17
- import * as PropTypes from 'prop-types';
18
- import { getPageMargin } from '../getPageMargin';
19
- import { savePDF } from '../savePDF';
20
- import { provideSaveTreeListPDF } from './provideSaveTreeListPDF';
21
- /**
22
- * A React component which facilitates the PDF export of the TreeList.
23
- */
24
- var TreeListPDFExport = /** @class */ (function (_super) {
25
- __extends(TreeListPDFExport, _super);
26
- function TreeListPDFExport(props) {
27
- var _this = _super.call(this, props) || this;
28
- _this.saveTreeListPDF = provideSaveTreeListPDF(_this.getSavePDF());
29
- return _this;
30
- }
31
- /**
32
- * @hidden
33
- */
34
- TreeListPDFExport.prototype.render = function () {
35
- return null;
36
- };
37
- /* eslint-disable max-len */
38
- /**
39
- * Saves the content of the TreeList as a PDF file.
40
- *
41
- * @param data - The data that will be exported to the PDF. The data can be different from the currently displayed data in the TreeList.
42
- * @param columns - The columns that will be exported to the PDF. The columns collection can be different from the currently displayed in the TreeList.
43
- * @param callback - The callback that will be executed after the PDF is saved.
44
- */
45
- // tslint:enable:max-line-length
46
- TreeListPDFExport.prototype.save = function (data, columns, callback) {
47
- this.saveTreeListPDF(this.getTreeList(), Object.assign({}, this.props, { margin: getPageMargin(this.props) }), callback, data, columns || []);
48
- };
49
- TreeListPDFExport.prototype.getSavePDF = function () {
50
- return savePDF;
51
- };
52
- TreeListPDFExport.prototype.getTreeList = function () {
53
- var children = this.props.children;
54
- if (children && children.props.data && children.props.columns) {
55
- return this.props.children;
56
- }
57
- };
58
- /**
59
- * @hidden
60
- */
61
- TreeListPDFExport.propTypes = {
62
- author: PropTypes.string,
63
- avoidLinks: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
64
- forcePageBreak: PropTypes.string,
65
- keepTogether: PropTypes.string,
66
- creator: PropTypes.string,
67
- date: PropTypes.instanceOf(Date),
68
- imageResolution: PropTypes.number,
69
- fileName: PropTypes.string,
70
- forceProxy: PropTypes.bool,
71
- keywords: PropTypes.string,
72
- landscape: PropTypes.bool,
73
- margin: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.shape({
74
- left: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
75
- top: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
76
- right: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
77
- bottom: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
78
- })]),
79
- pageTemplate: PropTypes.any,
80
- paperSize: PropTypes.any,
81
- repeatHeaders: PropTypes.bool,
82
- scale: PropTypes.number,
83
- proxyData: PropTypes.any,
84
- proxyURL: PropTypes.string,
85
- proxyTarget: PropTypes.string,
86
- producer: PropTypes.string,
87
- subject: PropTypes.string,
88
- title: PropTypes.string,
89
- allPages: PropTypes.bool
90
- };
91
- return TreeListPDFExport;
92
- }(React.Component));
93
- export { TreeListPDFExport };
@@ -1,4 +0,0 @@
1
- /**
2
- * @hidden
3
- */
4
- export declare const exportElement: (wrapper: HTMLElement) => HTMLElement;
@@ -1,27 +0,0 @@
1
- import { GridQuery } from '../common/table-query';
2
- import { wrapTable, createTable } from '../common/utils';
3
- /**
4
- * @hidden
5
- */
6
- export var exportElement = function (wrapper) {
7
- var query = new GridQuery(wrapper);
8
- var content = query.content();
9
- var result;
10
- var headerWithoutFilter = query.header();
11
- if (headerWithoutFilter.childNodes.length > 1) {
12
- headerWithoutFilter.removeChild(headerWithoutFilter.childNodes[1]);
13
- }
14
- headerWithoutFilter.childNodes[0].childNodes.forEach(function (headerCell) { return headerCell.style.top = 0; });
15
- if (content) {
16
- var colGroups = [content.querySelector('colgroup')];
17
- var headers = [headerWithoutFilter];
18
- var bodies = [content.querySelector('tbody')];
19
- var footer = query.footer();
20
- var footers = footer ? [footer.querySelector('tfoot')] : [];
21
- result = createTable(colGroups, headers, bodies, footers);
22
- }
23
- else {
24
- result = wrapTable(query.table().cloneNode(true));
25
- }
26
- return result;
27
- };
@@ -1,5 +0,0 @@
1
- import { TreeListPDFExportProps } from './TreeListPDFExport';
2
- /**
3
- * @hidden
4
- */
5
- export declare function provideSaveTreeListPDF(savePDF: (domElement: HTMLElement, options?: TreeListPDFExportProps, callback?: () => void) => void): (treeList: any, pdfExportOptions?: TreeListPDFExportProps, callback?: () => void, data?: any, columns?: any) => void;
@@ -1,62 +0,0 @@
1
- import * as ReactDOM from 'react-dom';
2
- import * as React from 'react';
3
- import { exportElement } from './export-element';
4
- /**
5
- * @hidden
6
- */
7
- export function provideSaveTreeListPDF(savePDF) {
8
- return function (treeList, pdfExportOptions, callback, data, columns) {
9
- if (pdfExportOptions === void 0) { pdfExportOptions = {}; }
10
- return saveTreeListPDF(savePDF, treeList, pdfExportOptions, callback, data, columns);
11
- };
12
- }
13
- function saveTreeListPDF(savePDF, treeList, pdfExportOptions, callback, data, columns) {
14
- if (pdfExportOptions === void 0) { pdfExportOptions = {}; }
15
- rendertreeList();
16
- var treeListOuterWrapper;
17
- var treeListInnerWrapper;
18
- var finalContainer;
19
- function rendertreeList() {
20
- treeListOuterWrapper = document.createElement('div');
21
- treeListOuterWrapper.setAttribute('style', 'position:absolute; left: -5000px; top: 0px;');
22
- treeListInnerWrapper = document.createElement('div');
23
- treeListOuterWrapper.appendChild(treeListInnerWrapper);
24
- document.body.appendChild(treeListOuterWrapper);
25
- ReactDOM.render(prepareRawTreeListForExport(), treeListInnerWrapper, ontreeListRendered);
26
- }
27
- function ontreeListRendered() {
28
- savePDF(prepareFinalElementForExport(), pdfExportOptions, cleanUpAndInvokeCallback);
29
- }
30
- function cleanUpAndInvokeCallback() {
31
- document.body.removeChild(treeListOuterWrapper);
32
- document.body.removeChild(finalContainer);
33
- treeListOuterWrapper = finalContainer = undefined;
34
- if (callback) {
35
- callback();
36
- }
37
- }
38
- function prepareFinalElementForExport() {
39
- /* Ultimatelly, there is no need for double DOM-copying of the treeList.
40
- The one in this method is a copied Angular implementation
41
- that has been plugged almost seemlessly. */
42
- finalContainer = document.createElement('div');
43
- finalContainer.className = 'k-treelist-pdf-export-element';
44
- var result = exportElement(treeListInnerWrapper);
45
- finalContainer.appendChild(result);
46
- document.body.appendChild(finalContainer);
47
- return finalContainer;
48
- }
49
- function prepareRawTreeListForExport() {
50
- var customDataProps = pdfExportOptions.allPages && data ? { data: data, take: Number.MAX_VALUE, skip: 0 } : {};
51
- // A custom width is needed because otherwise when all pages are exported,
52
- // the "hidden" PDF treeList will be visible.
53
- var customStyleProp = { style: Object.assign({}, treeList.props.style, { width: '1000px' }) };
54
- var customProps = Object.assign({}, customDataProps, customStyleProp);
55
- if (columns && columns.length > 0) {
56
- return React.cloneElement(treeList, Object.assign({}, customProps, { columns: columns }));
57
- }
58
- else {
59
- return React.cloneElement(treeList, customProps);
60
- }
61
- }
62
- }
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var React = require("react");
4
- var ReactDOMServer = require("react-dom/server");
5
- var defaultFileName = 'export.pdf';
6
- var defaultCreator = 'KendoReact PDF Generator';
7
- /**
8
- * @hidden
9
- */
10
- var KendoDrawingAdapter = /** @class */ (function () {
11
- function KendoDrawingAdapter(drawDOM, exportPDF, saveAs, domElement, options) {
12
- if (options === void 0) { options = {}; }
13
- var _this = this;
14
- this.drawDOM = drawDOM;
15
- this.exportPDF = exportPDF;
16
- this.saveAs = saveAs;
17
- this.domElement = domElement;
18
- this.options = options;
19
- this.convertPageTemplateToHtml = function (pageContext) {
20
- var pageTemplateContent = ReactDOMServer.renderToStaticMarkup(React.createElement(_this.options.pageTemplate, {
21
- pageNum: pageContext.pageNum, totalPages: pageContext.totalPages
22
- }));
23
- return "<span>".concat(pageTemplateContent, "</span>");
24
- };
25
- }
26
- KendoDrawingAdapter.prototype.savePDF = function (callback) {
27
- var _this = this;
28
- var savePromise = this.drawDOM(this.domElement, this.getDrawOptions())
29
- .then(function (group) { return _this.exportPDF(group, _this.getPDFOptions()); })
30
- .then(function (dataUri) { return _this.saveAs(dataUri, _this.options.fileName || defaultFileName, _this.getSaveOptions()); });
31
- if (callback) {
32
- savePromise.then(callback, callback);
33
- }
34
- };
35
- KendoDrawingAdapter.prototype.getDrawOptions = function () {
36
- return {
37
- avoidLinks: this.options.avoidLinks,
38
- forcePageBreak: this.options.forcePageBreak,
39
- keepTogether: this.options.keepTogether,
40
- margin: this.options.margin,
41
- paperSize: this.options.paperSize,
42
- landscape: this.options.landscape,
43
- repeatHeaders: this.options.repeatHeaders,
44
- scale: this.options.scale,
45
- template: this.options.pageTemplate && this.convertPageTemplateToHtml
46
- };
47
- };
48
- KendoDrawingAdapter.prototype.getPDFOptions = function () {
49
- return {
50
- author: this.options.author,
51
- creator: this.options.creator || defaultCreator,
52
- date: this.options.date,
53
- imgDPI: this.options.imageResolution,
54
- keywords: this.options.keywords,
55
- landscape: this.options.landscape,
56
- margin: this.options.margin,
57
- multiPage: true,
58
- paperSize: this.options.paperSize,
59
- producer: this.options.producer,
60
- subject: this.options.subject,
61
- title: this.options.title
62
- };
63
- };
64
- KendoDrawingAdapter.prototype.getSaveOptions = function () {
65
- return {
66
- forceProxy: this.options.forceProxy,
67
- proxyData: this.options.proxyData,
68
- proxyTarget: this.options.proxyTarget,
69
- proxyURL: this.options.proxyURL
70
- };
71
- };
72
- return KendoDrawingAdapter;
73
- }());
74
- exports.default = KendoDrawingAdapter;