@progress/kendo-react-pdf 8.1.0-develop.8 → 8.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/common/table-query.mjs +1 -1
- package/dist/cdn/js/kendo-react-pdf.js +1 -1
- package/grid/GridPDFExport.js +1 -1
- package/grid/GridPDFExport.mjs +55 -22
- package/grid/grid-query.mjs +1 -1
- package/grid/provideSaveGridPDF.js +1 -1
- package/grid/provideSaveGridPDF.mjs +18 -39
- package/index.d.mts +81 -4
- package/index.d.ts +81 -4
- package/package-metadata.mjs +1 -1
- package/package.json +2 -2
- package/treelist/TreeListPDFExport.js +1 -1
- package/treelist/TreeListPDFExport.mjs +45 -19
- package/treelist/provideSaveTreeListPDF.js +1 -1
- package/treelist/provideSaveTreeListPDF.mjs +14 -28
package/common/table-query.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import {
|
|
9
|
+
import { findElement as e, matchesClasses as t, matchesNodeName as o } from "./dom-queries.mjs";
|
|
10
10
|
const s = "k-grid-header", i = "k-grid-footer", h = "TABLE", a = o(h);
|
|
11
11
|
class d {
|
|
12
12
|
constructor(r) {
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("@progress/kendo-drawing"),require("@progress/kendo-file-saver"),require("react-dom/server"),require("@progress/kendo-react-common"),require("react-dom"),require("react-dom/client")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","@progress/kendo-drawing","@progress/kendo-file-saver","react-dom/server","@progress/kendo-react-common","react-dom","react-dom/client"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactPdf={},e.React,e.PropTypes,e.KendoDrawing,e.KendoFileSaver,e.ReactDOMServer,e.KendoReactCommon,e.ReactDOM,e.ReactDOMClient)}(this,(function(e,t,r,o,n,s,i,a,p){"use strict";function l(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var c=l(t),d=l(s),u=l(a),g=l(p);const h=class extends c.Component{render(){return null}};h.propTypes={left:r.oneOfType([r.number,r.string]),top:r.oneOfType([r.number,r.string]),right:r.oneOfType([r.number,r.string]),bottom:r.oneOfType([r.number,r.string])};let m=h;const f=["bottom","left","right","top"];function y(e){const t=c.Children.toArray(e.children).find((e=>e&&e.type===m));return t?function(e){const t={};for(let r=0;r<f.length;r++){const o=f[r],n=e.props[o];void 0!==n&&(t[o]=n)}return t}(t):e.margin}let b=class{constructor(e,t,r,o,n={}){this.drawDOM=e,this.exportPDF=t,this.saveAs=r,this.domElement=o,this.options=n,this.convertPageTemplateToHtml=e=>`<span>${d.renderToStaticMarkup(c.createElement(this.options.pageTemplate,{pageNum:e.pageNum,totalPages:e.totalPages}))}</span>`}savePDF(e){const t=this.drawDOM(this.domElement,this.getDrawOptions()).then((e=>this.exportPDF(e,this.getPDFOptions()))).then((e=>this.saveAs(e,this.options.fileName||"export.pdf",this.getSaveOptions())));e&&t.then(e,e)}getDrawOptions(){return{avoidLinks:this.options.avoidLinks,forcePageBreak:this.options.forcePageBreak,keepTogether:this.options.keepTogether,margin:this.options.margin,paperSize:this.options.paperSize,landscape:this.options.landscape,repeatHeaders:this.options.repeatHeaders,scale:this.options.scale,template:this.options.pageTemplate&&this.convertPageTemplateToHtml}}getPDFOptions(){return{author:this.options.author,creator:this.options.creator||"KendoReact PDF Generator",date:this.options.date,imgDPI:this.options.imageResolution,keywords:this.options.keywords,landscape:this.options.landscape,margin:this.options.margin,multiPage:!0,paperSize:this.options.paperSize,producer:this.options.producer,subject:this.options.subject,title:this.options.title}}getSaveOptions(){return{forceProxy:this.options.forceProxy,proxyData:this.options.proxyData,proxyTarget:this.options.proxyTarget,proxyURL:this.options.proxyURL}}};const T={name:"@progress/kendo-react-pdf",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},O=class extends c.Component{constructor(e){super(e),this.rootElForPDF=null,i.validatePackage(T)}render(){return c.createElement("div",{ref:e=>{this.rootElForPDF=e}},this.props.children)}save(e){new b(o.drawDOM,o.exportPDF,n.saveAs,this.rootElForPDF,this.getOptions()).savePDF(e)}getOptions(){return Object.assign({},this.props,{margin:y(this.props)})}};O.propTypes={author:r.string,avoidLinks:r.oneOfType([r.bool,r.string]),forcePageBreak:r.string,keepTogether:r.string,creator:r.string,date:r.instanceOf(Date),imageResolution:r.number,fileName:r.string,forceProxy:r.bool,keywords:r.string,landscape:r.bool,margin:r.oneOfType([r.string,r.number,r.shape({left:r.oneOfType([r.number,r.string]),top:r.oneOfType([r.number,r.string]),right:r.oneOfType([r.number,r.string]),bottom:r.oneOfType([r.number,r.string])})]),pageTemplate:r.any,paperSize:r.any,repeatHeaders:r.bool,scale:r.number,proxyData:r.any,proxyURL:r.string,proxyTarget:r.string,producer:r.string,subject:r.string,title:r.string};let v=O;function k(e,t={},r){new b(o.drawDOM,o.exportPDF,n.saveAs,e,t).savePDF(r)}const D={},P=e=>String(e).trim().split(" "),x=e=>t=>((e,t)=>{const r=P(t);return!!P(e.className).find((e=>r.indexOf(e)>=0))})(t,e),C=e=>(D[e]||(D[e]=t=>String(t.nodeName).toLowerCase()===e.toLowerCase()),D[e]),w=(e,t,r=!0)=>{if(e){if(r&&t(e))return e;for(e=e.firstChild;e;){if(1===e.nodeType){const r=w(e,t);if(r)return r}e=e.nextSibling}}},N="k-grid-header",E="k-grid-footer",F=C("TABLE"),S=e=>e?"locked":"wrap";class R{constructor(e){this.element=e,this.list=w(e,x("k-grid-container"))}content(e){return w(this.list,x("k-grid-content"+(e?"-locked":"")))}header(e){return this.headerWrap=this.headerWrap||w(this.element,x(N)),w(this.headerWrap,x(`${N}-${S(e)}`))}footer(e){return this.footerWrap=this.footerWrap||w(this.element,x(E)),w(this.footerWrap,x(`${E}-${S(e)}`))}table(){return w(this.element,F)}}const L="k-first",j=(e,t)=>{const r=t.length;for(let o=0;o<r;o++)e.appendChild(t[o].cloneNode(!0))},A=e=>{const t=document.createElement("div");return t.className="k-grid k-grid-md",t.appendChild(e),t},q=e=>{const t=e.length,r=e[0].cloneNode(!0),o=r.rows.length;if(t>1)for(let n=0;n<o;n++)for(let o=1;o<t;o++)j(r.rows[n],e[o].rows[n].cells);return r},K=(e,t,r,o)=>{const n=document.createElement("table"),s=e[0].cloneNode(!0);for(let t=1;t<e.length;t++)j(s,e[t].querySelectorAll("col"));const i=q(t),a=q(r);if(i.className="k-grid-header",((e,t)=>{if(t.length>1&&e.rows.length>1)for(let r=1;r<e.rows.length;r++){const o=t[0].rows[r].cells.length,n=e.rows[r].cells[o];-1===String(n.className).indexOf(L)&&(n.className+=` ${L}`)}})(i,t),n.appendChild(s),n.appendChild(i),n.appendChild(a),o.length){const e=q(o);e.className="k-grid-footer",n.appendChild(e)}return A(n)},M=e=>{const t=new R(e),r=t.content();let o;if(r){const e=[r.querySelector("colgroup")],n=[t.header().querySelector("thead")],s=[r.querySelector("tbody")],i=t.footer(),a=i?[i.querySelector("tfoot")]:[];o=K(e,n,s,a)}else o=A(t.table().cloneNode(!0));return o};function W(e){return(t,r={},o,n,s)=>function(e,t,r={},o,n,s){let i,a,p;function l(){i=document.createElement("div"),i.setAttribute("style","position:absolute; left: -5000px; top: 0px;"),a=document.createElement("div"),i.appendChild(a),document.body.appendChild(i),Number(c.version.slice(0,2))>=18?(g.createRoot(a).render(f()),setTimeout((()=>{d()}),0)):u.render(f(),a,d)}function d(){e(m(),r,h)}function h(){document.body.removeChild(i),document.body.removeChild(p),i=p=void 0,o&&o()}function m(){p=document.createElement("div"),p.className="k-grid-pdf-export-element";const e=M(a);return p.appendChild(e),document.body.appendChild(p),e}function f(){const e=n&&{data:n,total:n.length,pageSize:n.length,skip:0},r={style:Object.assign({},t.props.style,{width:"1000px"})},o=Object.assign({},e,r);if(s&&s.length>0){const e=function(e){return c.Children.toArray(e.props.children).filter((e=>e&&e.type&&"KendoReactGridColumn"!==e.type.displayName))}(t);return c.cloneElement(t,o,s.concat(e))}return c.cloneElement(t,o)}l()}(e,t,r,o,n,s)}const z=class extends c.Component{constructor(e){super(e),this.saveGridPDF=W(this.getSavePDF())}render(){return null}save(e,t){this.saveGridPDF(this.getGrid(),Object.assign({},this.props,{margin:y(this.props)}),t,e,this.getCustomColumns())}getSavePDF(){return k}getGrid(){return c.Children.toArray(this.props.children).find((e=>e&&"KendoReactGrid"===e.type.displayName))}getCustomColumns(){return c.Children.toArray(this.props.children).filter((e=>e&&"KendoReactGridColumn"===e.type.displayName))}};z.propTypes={author:r.string,avoidLinks:r.oneOfType([r.bool,r.string]),forcePageBreak:r.string,keepTogether:r.string,creator:r.string,date:r.instanceOf(Date),imageResolution:r.number,fileName:r.string,forceProxy:r.bool,keywords:r.string,landscape:r.bool,margin:r.oneOfType([r.string,r.number,r.shape({left:r.oneOfType([r.number,r.string]),top:r.oneOfType([r.number,r.string]),right:r.oneOfType([r.number,r.string]),bottom:r.oneOfType([r.number,r.string])})]),pageTemplate:r.any,paperSize:r.any,repeatHeaders:r.bool,scale:r.number,proxyData:r.any,proxyURL:r.string,proxyTarget:r.string,producer:r.string,subject:r.string,title:r.string};let G=z;const U="k-grid-header",$="k-grid-footer",B=C("TABLE");class H{constructor(e){this.element=e,this.list=w(e,x("k-grid"))}content(){return w(this.list,x("k-grid"))}header(){return this.headerWrap=this.headerWrap||w(this.element,x(U)),w(this.headerWrap,x(`${U}`))}footer(){return this.footerWrap=this.footerWrap||w(this.element,x($)),w(this.footerWrap,x(`${$}`))}table(){return w(this.element,B)}}const I=e=>{const t=new H(e),r=t.content();let o,n=t.header();if(n.childNodes.length>1&&n.removeChild(n.childNodes[1]),n.childNodes[0].childNodes.forEach((e=>e.style.top=0)),r){const e=[r.querySelector("colgroup")],s=[n],i=[r.querySelector("tbody")],a=t.footer(),p=a?[a.querySelector("tfoot")]:[];o=K(e,s,i,p)}else o=A(t.table().cloneNode(!0));return o};function V(e){return(t,r={},o,n,s)=>function(e,t,r={},o,n,s){let i,a,p;function l(){i=document.createElement("div"),i.setAttribute("style","position:absolute; left: -5000px; top: 0px;"),a=document.createElement("div"),i.appendChild(a),document.body.appendChild(i),Number(c.version.slice(0,2))>=18?(g.createRoot(a).render(f()),setTimeout((()=>{d()}),0)):u.render(f(),a,d)}function d(){e(m(),r,h)}function h(){document.body.removeChild(i),document.body.removeChild(p),i=p=void 0,o&&o()}function m(){p=document.createElement("div"),p.className="k-treelist-pdf-export-element";const e=I(a);return p.appendChild(e),document.body.appendChild(p),p}function f(){const e=r.allPages&&n?{data:n,take:Number.MAX_VALUE,skip:0}:{},o={style:Object.assign({},t.props.style,{width:"1000px"})},i=Object.assign({},e,o);return s&&s.length>0?c.cloneElement(t,Object.assign({},i,{columns:s})):c.cloneElement(t,i)}l()}(e,t,r,o,n,s)}const X=class extends c.Component{constructor(e){super(e),this.saveTreeListPDF=V(this.getSavePDF())}render(){return null}save(e,t,r){this.saveTreeListPDF(this.getTreeList(),Object.assign({},this.props,{margin:y(this.props)}),r,e,t||[])}getSavePDF(){return k}getTreeList(){const e=this.props.children;if(e&&e.props.data&&e.props.columns)return this.props.children}};X.propTypes={author:r.string,avoidLinks:r.oneOfType([r.bool,r.string]),forcePageBreak:r.string,keepTogether:r.string,creator:r.string,date:r.instanceOf(Date),imageResolution:r.number,fileName:r.string,forceProxy:r.bool,keywords:r.string,landscape:r.bool,margin:r.oneOfType([r.string,r.number,r.shape({left:r.oneOfType([r.number,r.string]),top:r.oneOfType([r.number,r.string]),right:r.oneOfType([r.number,r.string]),bottom:r.oneOfType([r.number,r.string])})]),pageTemplate:r.any,paperSize:r.any,repeatHeaders:r.bool,scale:r.number,proxyData:r.any,proxyURL:r.string,proxyTarget:r.string,producer:r.string,subject:r.string,title:r.string,allPages:r.bool};let _=X;e.GridPDFExport=G,e.KendoDrawingAdapter=b,e.PDFExport=v,e.PDFMargin=m,e.TreeListPDFExport=_,e.getPageMargin=y,e.savePDF=k}));
|
|
8
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("@progress/kendo-drawing"),require("@progress/kendo-file-saver"),require("react-dom/server"),require("@progress/kendo-react-common"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","@progress/kendo-drawing","@progress/kendo-file-saver","react-dom/server","@progress/kendo-react-common","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactPdf={},e.React,e.PropTypes,e.KendoDrawing,e.KendoFileSaver,e.ReactDOMServer,e.KendoReactCommon,e.ReactDOM)}(this,(function(e,t,r,o,s,n,i,a){"use strict";function p(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var l=p(t),c=p(n);const d=class extends l.Component{render(){return null}};d.propTypes={left:r.oneOfType([r.number,r.string]),top:r.oneOfType([r.number,r.string]),right:r.oneOfType([r.number,r.string]),bottom:r.oneOfType([r.number,r.string])};let h=d;const g=["bottom","left","right","top"];function u(e){const t=l.Children.toArray(e.children).find((e=>e&&e.type===h));return t?function(e){const t={};for(let r=0;r<g.length;r++){const o=g[r],s=e.props[o];void 0!==s&&(t[o]=s)}return t}(t):e.margin}let m=class{constructor(e,t,r,o,s={}){this.drawDOM=e,this.exportPDF=t,this.saveAs=r,this.domElement=o,this.options=s,this.convertPageTemplateToHtml=e=>`<span>${c.renderToStaticMarkup(l.createElement(this.options.pageTemplate,{pageNum:e.pageNum,totalPages:e.totalPages}))}</span>`}savePDF(e){const t=this.drawDOM(this.domElement,this.getDrawOptions()).then((e=>this.exportPDF(e,this.getPDFOptions()))).then((e=>this.saveAs(e,this.options.fileName||"export.pdf",this.getSaveOptions())));e&&t.then(e,e)}getDrawOptions(){return{avoidLinks:this.options.avoidLinks,forcePageBreak:this.options.forcePageBreak,keepTogether:this.options.keepTogether,margin:this.options.margin,paperSize:this.options.paperSize,landscape:this.options.landscape,repeatHeaders:this.options.repeatHeaders,scale:this.options.scale,template:this.options.pageTemplate&&this.convertPageTemplateToHtml}}getPDFOptions(){return{author:this.options.author,creator:this.options.creator||"KendoReact PDF Generator",date:this.options.date,imgDPI:this.options.imageResolution,keywords:this.options.keywords,landscape:this.options.landscape,margin:this.options.margin,multiPage:!0,paperSize:this.options.paperSize,producer:this.options.producer,subject:this.options.subject,title:this.options.title}}getSaveOptions(){return{forceProxy:this.options.forceProxy,proxyData:this.options.proxyData,proxyTarget:this.options.proxyTarget,proxyURL:this.options.proxyURL}}};const f={name:"@progress/kendo-react-pdf",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},y=class extends l.Component{constructor(e){super(e),this.rootElForPDF=null,i.validatePackage(f)}render(){return l.createElement("div",{ref:e=>{this.rootElForPDF=e}},this.props.children)}save(e){new m(o.drawDOM,o.exportPDF,s.saveAs,this.rootElForPDF,this.getOptions()).savePDF(e)}getOptions(){return Object.assign({},this.props,{margin:u(this.props)})}};y.propTypes={author:r.string,avoidLinks:r.oneOfType([r.bool,r.string]),forcePageBreak:r.string,keepTogether:r.string,creator:r.string,date:r.instanceOf(Date),imageResolution:r.number,fileName:r.string,forceProxy:r.bool,keywords:r.string,landscape:r.bool,margin:r.oneOfType([r.string,r.number,r.shape({left:r.oneOfType([r.number,r.string]),top:r.oneOfType([r.number,r.string]),right:r.oneOfType([r.number,r.string]),bottom:r.oneOfType([r.number,r.string])})]),pageTemplate:r.any,paperSize:r.any,repeatHeaders:r.bool,scale:r.number,proxyData:r.any,proxyURL:r.string,proxyTarget:r.string,producer:r.string,subject:r.string,title:r.string};let b=y;function T(e,t={},r){new m(o.drawDOM,o.exportPDF,s.saveAs,e,t).savePDF(r)}const O={},k=e=>String(e).trim().split(" "),v=e=>t=>((e,t)=>{const r=k(t);return!!k(e.className).find((e=>r.indexOf(e)>=0))})(t,e),w=e=>(O[e]||(O[e]=t=>String(t.nodeName).toLowerCase()===e.toLowerCase()),O[e]),P=(e,t,r=!0)=>{if(e){if(r&&t(e))return e;for(e=e.firstChild;e;){if(1===e.nodeType){const r=P(e,t);if(r)return r}e=e.nextSibling}}},D="k-grid-header",x="k-grid-footer",C=w("TABLE"),E=e=>e?"locked":"wrap";class F{constructor(e){this.element=e,this.list=P(e,v("k-grid-container"))}content(e){return P(this.list,v("k-grid-content"+(e?"-locked":"")))}header(e){return this.headerWrap=this.headerWrap||P(this.element,v(D)),P(this.headerWrap,v(`${D}-${E(e)}`))}footer(e){return this.footerWrap=this.footerWrap||P(this.element,v(x)),P(this.footerWrap,v(`${x}-${E(e)}`))}table(){return P(this.element,C)}}const N="k-first",S=(e,t)=>{const r=t.length;for(let o=0;o<r;o++)e.appendChild(t[o].cloneNode(!0))},R=e=>{const t=document.createElement("div");return t.className="k-grid k-grid-md",t.appendChild(e),t},L=e=>{const t=e.length,r=e[0].cloneNode(!0),o=r.rows.length;if(t>1)for(let s=0;s<o;s++)for(let o=1;o<t;o++)S(r.rows[s],e[o].rows[s].cells);return r},j=(e,t,r,o)=>{const s=document.createElement("table"),n=e[0].cloneNode(!0);for(let t=1;t<e.length;t++)S(n,e[t].querySelectorAll("col"));const i=L(t),a=L(r);if(i.className="k-grid-header",((e,t)=>{if(t.length>1&&e.rows.length>1)for(let r=1;r<e.rows.length;r++){const o=t[0].rows[r].cells.length,s=e.rows[r].cells[o];-1===String(s.className).indexOf(N)&&(s.className+=` ${N}`)}})(i,t),s.appendChild(n),s.appendChild(i),s.appendChild(a),o.length){const e=L(o);e.className="k-grid-footer",s.appendChild(e)}return R(s)},W=e=>{const t=new F(e),r=t.content();let o;if(r){const e=[r.querySelector("colgroup")],s=[t.header().querySelector("thead")],n=[r.querySelector("tbody")],i=t.footer(),a=i?[i.querySelector("tfoot")]:[];o=j(e,s,n,a)}else o=R(t.table().cloneNode(!0));return o};function q(e){return(t,r={},o)=>function(e,t,r={},o){let s;function n(){e(a(),r,i)}function i(){document.body.removeChild(s),s=void 0,o&&o()}function a(){s=document.createElement("div"),s.className="k-grid-pdf-export-element";const e=W(t);return s.appendChild(e),document.body.appendChild(s),e}n()}(e,t,r,o)}const A=class extends l.Component{constructor(e){super(e),this.state={show:!1},this.saveGridPDF=q(this.getSavePDF()),this.gridInnerWrapperRef=l.createRef()}componentDidUpdate(e,t){this.state.show&&this.state.show!==t.show&&this.saveGridPDF(this.gridInnerWrapperRef.current,Object.assign({},this.props,{margin:u(this.props)}),this.callback)}render(){return this.state.show&&a.createPortal(l.createElement("div",{style:{position:"absolute",left:"-5000px",top:"0px"}},l.createElement("div",{ref:this.gridInnerWrapperRef},this.prepareRawGridForExport(this.data))),document.body)}save(e,t){this.grid=this.getGrid(),this.columns=this.getCustomColumns(),this.data=e,this.callback=()=>{this.setState({show:!1}),t&&t()},this.setState({show:!0})}getSavePDF(){return T}getGrid(){return l.Children.toArray(this.props.children).find((e=>e&&"KendoReactGrid"===e.type.displayName))}getCustomColumns(){return l.Children.toArray(this.props.children).filter((e=>e&&"KendoReactGridColumn"===e.type.displayName))}prepareRawGridForExport(e){const t=e&&{data:e,total:e.length,pageSize:e.length,skip:0},r={style:Object.assign({},this.grid.props.style,{width:"1000px"})},o=Object.assign({},t,r);if(this.columns&&this.columns.length>0){const e=this.getGridNotColumnChildren(this.grid);return l.cloneElement(this.grid,o,this.columns.concat(e))}return l.cloneElement(this.grid,o)}getGridNotColumnChildren(e){return l.Children.toArray(e.props.children).filter((e=>e&&e.type&&"KendoReactGridColumn"!==e.type.displayName))}};A.propTypes={author:r.string,avoidLinks:r.oneOfType([r.bool,r.string]),forcePageBreak:r.string,keepTogether:r.string,creator:r.string,date:r.instanceOf(Date),imageResolution:r.number,fileName:r.string,forceProxy:r.bool,keywords:r.string,landscape:r.bool,margin:r.oneOfType([r.string,r.number,r.shape({left:r.oneOfType([r.number,r.string]),top:r.oneOfType([r.number,r.string]),right:r.oneOfType([r.number,r.string]),bottom:r.oneOfType([r.number,r.string])})]),pageTemplate:r.any,paperSize:r.any,repeatHeaders:r.bool,scale:r.number,proxyData:r.any,proxyURL:r.string,proxyTarget:r.string,producer:r.string,subject:r.string,title:r.string};let G=A;const K="k-grid-header",M="k-grid-footer",U=w("TABLE");class z{constructor(e){this.element=e,this.list=P(e,v("k-grid"))}content(){return P(this.list,v("k-grid"))}header(){return this.headerWrap=this.headerWrap||P(this.element,v(K)),P(this.headerWrap,v(`${K}`))}footer(){return this.footerWrap=this.footerWrap||P(this.element,v(M)),P(this.footerWrap,v(`${M}`))}table(){return P(this.element,U)}}const I=e=>{const t=new z(e),r=t.content();let o,s=t.header();if(s.childNodes.length>1&&s.removeChild(s.childNodes[1]),s.childNodes[0].childNodes.forEach((e=>e.style.top=0)),r){const e=[r.querySelector("colgroup")],n=[s],i=[r.querySelector("tbody")],a=t.footer(),p=a?[a.querySelector("tfoot")]:[];o=j(e,n,i,p)}else o=R(t.table().cloneNode(!0));return o};function $(e){return(t,r={},o)=>function(e,t,r={},o){let s;function n(){e(a(),r,i)}function i(){document.body.removeChild(s),s=void 0,o&&o()}function a(){s=document.createElement("div"),s.className="k-treelist-pdf-export-element";const e=I(t);return s.appendChild(e),document.body.appendChild(s),s}n()}(e,t,r,o)}const B=class extends l.Component{constructor(e){super(e),this.state={show:!1},this.saveTreeListPDF=$(this.getSavePDF()),this.treeListInnerWrapperRef=l.createRef()}componentDidUpdate(e,t){this.state.show&&this.state.show!==t.show&&this.saveTreeListPDF(this.treeListInnerWrapperRef.current,Object.assign({},this.props,{margin:u(this.props)}),this.callback)}render(){return this.state.show&&a.createPortal(l.createElement("div",{style:{position:"absolute",left:"-5000px",top:"0px"}},l.createElement("div",{ref:this.treeListInnerWrapperRef},this.prepareRawTreeListForExport())),document.body)}save(e,t,r){this.treeList=this.getTreeList(),this.columns=t||[],this.data=e,this.callback=()=>{this.setState({show:!1}),r&&r()},this.setState({show:!0})}getSavePDF(){return T}getTreeList(){const e=this.props.children;if(e&&e.props.data&&e.props.columns)return this.props.children}prepareRawTreeListForExport(){const e=this.props.allPages&&this.data?{data:this.data,take:Number.MAX_VALUE,skip:0}:{},t={style:Object.assign({},this.treeList.props.style,{width:"1000px"})},r=Object.assign({},e,t);return this.columns&&this.columns.length>0?l.cloneElement(this.treeList,Object.assign({},r,{columns:this.columns})):l.cloneElement(this.treeList,r)}};B.propTypes={author:r.string,avoidLinks:r.oneOfType([r.bool,r.string]),forcePageBreak:r.string,keepTogether:r.string,creator:r.string,date:r.instanceOf(Date),imageResolution:r.number,fileName:r.string,forceProxy:r.bool,keywords:r.string,landscape:r.bool,margin:r.oneOfType([r.string,r.number,r.shape({left:r.oneOfType([r.number,r.string]),top:r.oneOfType([r.number,r.string]),right:r.oneOfType([r.number,r.string]),bottom:r.oneOfType([r.number,r.string])})]),pageTemplate:r.any,paperSize:r.any,repeatHeaders:r.bool,scale:r.number,proxyData:r.any,proxyURL:r.string,proxyTarget:r.string,producer:r.string,subject:r.string,title:r.string,allPages:r.bool};let H=B;e.GridPDFExport=G,e.KendoDrawingAdapter=m,e.PDFExport=b,e.PDFMargin=h,e.TreeListPDFExport=H,e.getPageMargin=u,e.savePDF=T}));
|
package/grid/GridPDFExport.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),e=require("prop-types"),g=require("../getPageMargin.js"),u=require("../savePDF.js"),d=require("./provideSaveGridPDF.js"),h=require("react-dom");function m(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const r in n)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>n[r]})}}return t.default=n,Object.freeze(t)}const s=m(c),a=class a extends s.Component{constructor(t){super(t),this.state={show:!1},this.saveGridPDF=d.provideSaveGridPDF(this.getSavePDF()),this.gridInnerWrapperRef=s.createRef()}componentDidUpdate(t,r){this.state.show&&this.state.show!==r.show&&this.saveGridPDF(this.gridInnerWrapperRef.current,Object.assign({},this.props,{margin:g.getPageMargin(this.props)}),this.callback)}render(){return this.state.show&&h.createPortal(s.createElement("div",{style:{position:"absolute",left:"-5000px",top:"0px"}},s.createElement("div",{ref:this.gridInnerWrapperRef},this.prepareRawGridForExport(this.data))),document.body)}save(t,r){this.grid=this.getGrid(),this.columns=this.getCustomColumns(),this.data=t,this.callback=()=>{this.setState({show:!1}),r&&r()},this.setState({show:!0})}getSavePDF(){return u.savePDF}getGrid(){return s.Children.toArray(this.props.children).find(t=>t&&t.type.displayName==="KendoReactGrid")}getCustomColumns(){return s.Children.toArray(this.props.children).filter(t=>t&&t.type.displayName==="KendoReactGridColumn")}prepareRawGridForExport(t){const r=t&&{data:t,total:t.length,pageSize:t.length,skip:0},i={style:Object.assign({},this.grid.props.style,{width:"1000px"})},p=Object.assign({},r,i);if(this.columns&&this.columns.length>0){const l=this.getGridNotColumnChildren(this.grid);return s.cloneElement(this.grid,p,this.columns.concat(l))}else return s.cloneElement(this.grid,p)}getGridNotColumnChildren(t){return s.Children.toArray(t.props.children).filter(r=>r&&r.type&&r.type.displayName!=="KendoReactGridColumn")}};a.propTypes={author:e.string,avoidLinks:e.oneOfType([e.bool,e.string]),forcePageBreak:e.string,keepTogether:e.string,creator:e.string,date:e.instanceOf(Date),imageResolution:e.number,fileName:e.string,forceProxy:e.bool,keywords:e.string,landscape:e.bool,margin:e.oneOfType([e.string,e.number,e.shape({left:e.oneOfType([e.number,e.string]),top:e.oneOfType([e.number,e.string]),right:e.oneOfType([e.number,e.string]),bottom:e.oneOfType([e.number,e.string])})]),pageTemplate:e.any,paperSize:e.any,repeatHeaders:e.bool,scale:e.number,proxyData:e.any,proxyURL:e.string,proxyTarget:e.string,producer:e.string,subject:e.string,title:e.string};let o=a;exports.GridPDFExport=o;
|
package/grid/GridPDFExport.mjs
CHANGED
|
@@ -6,20 +6,46 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import * as
|
|
9
|
+
import * as s from "react";
|
|
10
10
|
import e from "prop-types";
|
|
11
|
-
import { getPageMargin as
|
|
12
|
-
import { savePDF as
|
|
13
|
-
import { provideSaveGridPDF as
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
import { getPageMargin as l } from "../getPageMargin.mjs";
|
|
12
|
+
import { savePDF as h } from "../savePDF.mjs";
|
|
13
|
+
import { provideSaveGridPDF as g } from "./provideSaveGridPDF.mjs";
|
|
14
|
+
import { createPortal as m } from "react-dom";
|
|
15
|
+
const i = class i extends s.Component {
|
|
16
|
+
constructor(t) {
|
|
17
|
+
super(t), this.state = {
|
|
18
|
+
show: !1
|
|
19
|
+
}, this.saveGridPDF = g(this.getSavePDF()), this.gridInnerWrapperRef = s.createRef();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
24
|
+
componentDidUpdate(t, r) {
|
|
25
|
+
this.state.show && this.state.show !== r.show && this.saveGridPDF(
|
|
26
|
+
this.gridInnerWrapperRef.current,
|
|
27
|
+
Object.assign({}, this.props, { margin: l(this.props) }),
|
|
28
|
+
this.callback
|
|
29
|
+
);
|
|
17
30
|
}
|
|
18
31
|
/**
|
|
19
32
|
* @hidden
|
|
20
33
|
*/
|
|
21
34
|
render() {
|
|
22
|
-
return
|
|
35
|
+
return this.state.show && m(
|
|
36
|
+
/* @__PURE__ */ s.createElement(
|
|
37
|
+
"div",
|
|
38
|
+
{
|
|
39
|
+
style: {
|
|
40
|
+
position: "absolute",
|
|
41
|
+
left: "-5000px",
|
|
42
|
+
top: "0px"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
/* @__PURE__ */ s.createElement("div", { ref: this.gridInnerWrapperRef }, this.prepareRawGridForExport(this.data))
|
|
46
|
+
),
|
|
47
|
+
document.body
|
|
48
|
+
);
|
|
23
49
|
}
|
|
24
50
|
/* eslint-disable max-len */
|
|
25
51
|
/**
|
|
@@ -29,26 +55,33 @@ const n = class n extends t.Component {
|
|
|
29
55
|
* @param callback - The callback that will be executed after the PDF is saved.
|
|
30
56
|
*/
|
|
31
57
|
// tslint:enable:max-line-length
|
|
32
|
-
save(
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
o,
|
|
37
|
-
r,
|
|
38
|
-
this.getCustomColumns()
|
|
39
|
-
);
|
|
58
|
+
save(t, r) {
|
|
59
|
+
this.grid = this.getGrid(), this.columns = this.getCustomColumns(), this.data = t, this.callback = () => {
|
|
60
|
+
this.setState({ show: !1 }), r && r();
|
|
61
|
+
}, this.setState({ show: !0 });
|
|
40
62
|
}
|
|
41
63
|
getSavePDF() {
|
|
42
|
-
return
|
|
64
|
+
return h;
|
|
43
65
|
}
|
|
44
66
|
getGrid() {
|
|
45
|
-
return
|
|
67
|
+
return s.Children.toArray(this.props.children).find((t) => t && t.type.displayName === "KendoReactGrid");
|
|
46
68
|
}
|
|
47
69
|
getCustomColumns() {
|
|
48
|
-
return
|
|
70
|
+
return s.Children.toArray(this.props.children).filter((t) => t && t.type.displayName === "KendoReactGridColumn");
|
|
71
|
+
}
|
|
72
|
+
prepareRawGridForExport(t) {
|
|
73
|
+
const r = t && { data: t, total: t.length, pageSize: t.length, skip: 0 }, a = { style: Object.assign({}, this.grid.props.style, { width: "1000px" }) }, o = Object.assign({}, r, a);
|
|
74
|
+
if (this.columns && this.columns.length > 0) {
|
|
75
|
+
const p = this.getGridNotColumnChildren(this.grid);
|
|
76
|
+
return s.cloneElement(this.grid, o, this.columns.concat(p));
|
|
77
|
+
} else
|
|
78
|
+
return s.cloneElement(this.grid, o);
|
|
79
|
+
}
|
|
80
|
+
getGridNotColumnChildren(t) {
|
|
81
|
+
return s.Children.toArray(t.props.children).filter((r) => r && r.type && r.type.displayName !== "KendoReactGridColumn");
|
|
49
82
|
}
|
|
50
83
|
};
|
|
51
|
-
|
|
84
|
+
i.propTypes = {
|
|
52
85
|
author: e.string,
|
|
53
86
|
avoidLinks: e.oneOfType([e.bool, e.string]),
|
|
54
87
|
forcePageBreak: e.string,
|
|
@@ -77,7 +110,7 @@ n.propTypes = {
|
|
|
77
110
|
subject: e.string,
|
|
78
111
|
title: e.string
|
|
79
112
|
};
|
|
80
|
-
let
|
|
113
|
+
let n = i;
|
|
81
114
|
export {
|
|
82
|
-
|
|
115
|
+
n as GridPDFExport
|
|
83
116
|
};
|
package/grid/grid-query.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import {
|
|
9
|
+
import { findElement as t, matchesClasses as r, matchesNodeName as a } from "../common/dom-queries.mjs";
|
|
10
10
|
const o = "k-grid-header", i = "k-grid-footer", h = "TABLE", c = a(h), n = (s) => s ? "locked" : "wrap";
|
|
11
11
|
class l {
|
|
12
12
|
constructor(e) {
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./export-element.js");function c(t){return(r,o={},n)=>p(t,r,o,n)}function p(t,r,o={},n){let e;d();function d(){t(u(),o,l)}function l(){document.body.removeChild(e),e=void 0,n&&n()}function u(){e=document.createElement("div"),e.className="k-grid-pdf-export-element";const i=a.exportElement(r);return e.appendChild(i),document.body.appendChild(e),i}}exports.provideSaveGridPDF=c;
|
|
@@ -6,51 +6,30 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import { exportElement as x } from "./export-element.mjs";
|
|
13
|
-
function D(o) {
|
|
14
|
-
return (e, s = {}, d, t, i) => g(
|
|
15
|
-
o,
|
|
16
|
-
e,
|
|
17
|
-
s,
|
|
18
|
-
d,
|
|
9
|
+
import { exportElement as u } from "./export-element.mjs";
|
|
10
|
+
function m(t) {
|
|
11
|
+
return (r, o = {}, n) => a(
|
|
19
12
|
t,
|
|
20
|
-
|
|
13
|
+
r,
|
|
14
|
+
o,
|
|
15
|
+
n
|
|
21
16
|
);
|
|
22
17
|
}
|
|
23
|
-
function
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
a();
|
|
29
|
-
}, 0)) : b.render(m(), p, a);
|
|
30
|
-
}
|
|
31
|
-
function a() {
|
|
32
|
-
o(h(), s, C);
|
|
18
|
+
function a(t, r, o = {}, n) {
|
|
19
|
+
let e;
|
|
20
|
+
i();
|
|
21
|
+
function i() {
|
|
22
|
+
t(p(), o, l);
|
|
33
23
|
}
|
|
34
|
-
function
|
|
35
|
-
document.body.removeChild(
|
|
24
|
+
function l() {
|
|
25
|
+
document.body.removeChild(e), e = void 0, n && n();
|
|
36
26
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
return
|
|
27
|
+
function p() {
|
|
28
|
+
e = document.createElement("div"), e.className = "k-grid-pdf-export-element";
|
|
29
|
+
const d = u(r);
|
|
30
|
+
return e.appendChild(d), document.body.appendChild(e), d;
|
|
41
31
|
}
|
|
42
|
-
function m() {
|
|
43
|
-
const l = t && { data: t, total: t.length, pageSize: t.length, skip: 0 }, y = { style: Object.assign({}, e.props.style, { width: "1000px" }) }, u = Object.assign({}, l, y);
|
|
44
|
-
if (i && i.length > 0) {
|
|
45
|
-
const v = G(e);
|
|
46
|
-
return c.cloneElement(e, u, i.concat(v));
|
|
47
|
-
} else
|
|
48
|
-
return c.cloneElement(e, u);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function G(o) {
|
|
52
|
-
return c.Children.toArray(o.props.children).filter((e) => e && e.type && e.type.displayName !== "KendoReactGridColumn");
|
|
53
32
|
}
|
|
54
33
|
export {
|
|
55
|
-
|
|
34
|
+
m as provideSaveGridPDF
|
|
56
35
|
};
|
package/index.d.mts
CHANGED
|
@@ -25,7 +25,7 @@ export declare function getPageMargin(props: any): any;
|
|
|
25
25
|
/**
|
|
26
26
|
* A React component which facilitates the PDF export of the Grid.
|
|
27
27
|
*/
|
|
28
|
-
export declare class GridPDFExport extends React_2.Component<GridPDFExportProps,
|
|
28
|
+
export declare class GridPDFExport extends React_2.Component<GridPDFExportProps, GridPDFExportState> {
|
|
29
29
|
/**
|
|
30
30
|
* @hidden
|
|
31
31
|
*/
|
|
@@ -62,11 +62,41 @@ export declare class GridPDFExport extends React_2.Component<GridPDFExportProps,
|
|
|
62
62
|
* @hidden
|
|
63
63
|
*/
|
|
64
64
|
saveGridPDF: any;
|
|
65
|
+
/**
|
|
66
|
+
* @hidden
|
|
67
|
+
*/
|
|
68
|
+
grid: any;
|
|
69
|
+
/**
|
|
70
|
+
* @hidden
|
|
71
|
+
*/
|
|
72
|
+
columns: any;
|
|
73
|
+
/**
|
|
74
|
+
* @hidden
|
|
75
|
+
*/
|
|
76
|
+
data?: any[];
|
|
77
|
+
/**
|
|
78
|
+
* @hidden
|
|
79
|
+
*/
|
|
80
|
+
callback?: any;
|
|
81
|
+
/**
|
|
82
|
+
* @hidden
|
|
83
|
+
*/
|
|
84
|
+
gridInnerWrapperRef: React_2.RefObject<HTMLDivElement>;
|
|
85
|
+
/**
|
|
86
|
+
* @hidden
|
|
87
|
+
*/
|
|
88
|
+
readonly state: {
|
|
89
|
+
show: boolean;
|
|
90
|
+
};
|
|
65
91
|
constructor(props: any);
|
|
66
92
|
/**
|
|
67
93
|
* @hidden
|
|
68
94
|
*/
|
|
69
|
-
|
|
95
|
+
componentDidUpdate(_prevProps: any, prevState: any): void;
|
|
96
|
+
/**
|
|
97
|
+
* @hidden
|
|
98
|
+
*/
|
|
99
|
+
render(): false | React_2.ReactPortal;
|
|
70
100
|
/**
|
|
71
101
|
* Saves the content of the Grid as a PDF file.
|
|
72
102
|
*
|
|
@@ -77,6 +107,8 @@ export declare class GridPDFExport extends React_2.Component<GridPDFExportProps,
|
|
|
77
107
|
protected getSavePDF(): typeof savePDF;
|
|
78
108
|
private getGrid;
|
|
79
109
|
private getCustomColumns;
|
|
110
|
+
private prepareRawGridForExport;
|
|
111
|
+
private getGridNotColumnChildren;
|
|
80
112
|
}
|
|
81
113
|
|
|
82
114
|
/**
|
|
@@ -86,6 +118,13 @@ export declare class GridPDFExport extends React_2.Component<GridPDFExportProps,
|
|
|
86
118
|
export declare interface GridPDFExportProps extends PDFExportProps {
|
|
87
119
|
}
|
|
88
120
|
|
|
121
|
+
/**
|
|
122
|
+
* @hidden
|
|
123
|
+
*/
|
|
124
|
+
declare interface GridPDFExportState {
|
|
125
|
+
show: boolean;
|
|
126
|
+
}
|
|
127
|
+
|
|
89
128
|
/**
|
|
90
129
|
* @hidden
|
|
91
130
|
*/
|
|
@@ -370,7 +409,7 @@ export declare function savePDF(domElement: HTMLElement, options?: PDFExportProp
|
|
|
370
409
|
/**
|
|
371
410
|
* A React component which facilitates the PDF export of the TreeList.
|
|
372
411
|
*/
|
|
373
|
-
export declare class TreeListPDFExport extends React_2.Component<TreeListPDFExportProps,
|
|
412
|
+
export declare class TreeListPDFExport extends React_2.Component<TreeListPDFExportProps, TreeListPDFExportState> {
|
|
374
413
|
/**
|
|
375
414
|
* @hidden
|
|
376
415
|
*/
|
|
@@ -408,11 +447,41 @@ export declare class TreeListPDFExport extends React_2.Component<TreeListPDFExpo
|
|
|
408
447
|
* @hidden
|
|
409
448
|
*/
|
|
410
449
|
saveTreeListPDF: any;
|
|
450
|
+
/**
|
|
451
|
+
* @hidden
|
|
452
|
+
*/
|
|
453
|
+
treeList: any;
|
|
454
|
+
/**
|
|
455
|
+
* @hidden
|
|
456
|
+
*/
|
|
457
|
+
columns: any;
|
|
458
|
+
/**
|
|
459
|
+
* @hidden
|
|
460
|
+
*/
|
|
461
|
+
data?: any[];
|
|
462
|
+
/**
|
|
463
|
+
* @hidden
|
|
464
|
+
*/
|
|
465
|
+
callback?: any;
|
|
466
|
+
/**
|
|
467
|
+
* @hidden
|
|
468
|
+
*/
|
|
469
|
+
treeListInnerWrapperRef: React_2.RefObject<HTMLDivElement>;
|
|
470
|
+
/**
|
|
471
|
+
* @hidden
|
|
472
|
+
*/
|
|
473
|
+
readonly state: {
|
|
474
|
+
show: boolean;
|
|
475
|
+
};
|
|
411
476
|
constructor(props: any);
|
|
412
477
|
/**
|
|
413
478
|
* @hidden
|
|
414
479
|
*/
|
|
415
|
-
|
|
480
|
+
componentDidUpdate(_prevProps: any, prevState: any): void;
|
|
481
|
+
/**
|
|
482
|
+
* @hidden
|
|
483
|
+
*/
|
|
484
|
+
render(): false | React_2.ReactPortal;
|
|
416
485
|
/**
|
|
417
486
|
* Saves the content of the TreeList as a PDF file.
|
|
418
487
|
*
|
|
@@ -423,6 +492,7 @@ export declare class TreeListPDFExport extends React_2.Component<TreeListPDFExpo
|
|
|
423
492
|
save(data?: any[], columns?: any[], callback?: () => void): void;
|
|
424
493
|
protected getSavePDF(): typeof savePDF;
|
|
425
494
|
private getTreeList;
|
|
495
|
+
private prepareRawTreeListForExport;
|
|
426
496
|
}
|
|
427
497
|
|
|
428
498
|
/**
|
|
@@ -436,4 +506,11 @@ export declare interface TreeListPDFExportProps extends PDFExportProps {
|
|
|
436
506
|
allPages?: boolean;
|
|
437
507
|
}
|
|
438
508
|
|
|
509
|
+
/**
|
|
510
|
+
* @hidden
|
|
511
|
+
*/
|
|
512
|
+
declare interface TreeListPDFExportState {
|
|
513
|
+
show: boolean;
|
|
514
|
+
}
|
|
515
|
+
|
|
439
516
|
export { }
|
package/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare function getPageMargin(props: any): any;
|
|
|
25
25
|
/**
|
|
26
26
|
* A React component which facilitates the PDF export of the Grid.
|
|
27
27
|
*/
|
|
28
|
-
export declare class GridPDFExport extends React_2.Component<GridPDFExportProps,
|
|
28
|
+
export declare class GridPDFExport extends React_2.Component<GridPDFExportProps, GridPDFExportState> {
|
|
29
29
|
/**
|
|
30
30
|
* @hidden
|
|
31
31
|
*/
|
|
@@ -62,11 +62,41 @@ export declare class GridPDFExport extends React_2.Component<GridPDFExportProps,
|
|
|
62
62
|
* @hidden
|
|
63
63
|
*/
|
|
64
64
|
saveGridPDF: any;
|
|
65
|
+
/**
|
|
66
|
+
* @hidden
|
|
67
|
+
*/
|
|
68
|
+
grid: any;
|
|
69
|
+
/**
|
|
70
|
+
* @hidden
|
|
71
|
+
*/
|
|
72
|
+
columns: any;
|
|
73
|
+
/**
|
|
74
|
+
* @hidden
|
|
75
|
+
*/
|
|
76
|
+
data?: any[];
|
|
77
|
+
/**
|
|
78
|
+
* @hidden
|
|
79
|
+
*/
|
|
80
|
+
callback?: any;
|
|
81
|
+
/**
|
|
82
|
+
* @hidden
|
|
83
|
+
*/
|
|
84
|
+
gridInnerWrapperRef: React_2.RefObject<HTMLDivElement>;
|
|
85
|
+
/**
|
|
86
|
+
* @hidden
|
|
87
|
+
*/
|
|
88
|
+
readonly state: {
|
|
89
|
+
show: boolean;
|
|
90
|
+
};
|
|
65
91
|
constructor(props: any);
|
|
66
92
|
/**
|
|
67
93
|
* @hidden
|
|
68
94
|
*/
|
|
69
|
-
|
|
95
|
+
componentDidUpdate(_prevProps: any, prevState: any): void;
|
|
96
|
+
/**
|
|
97
|
+
* @hidden
|
|
98
|
+
*/
|
|
99
|
+
render(): false | React_2.ReactPortal;
|
|
70
100
|
/**
|
|
71
101
|
* Saves the content of the Grid as a PDF file.
|
|
72
102
|
*
|
|
@@ -77,6 +107,8 @@ export declare class GridPDFExport extends React_2.Component<GridPDFExportProps,
|
|
|
77
107
|
protected getSavePDF(): typeof savePDF;
|
|
78
108
|
private getGrid;
|
|
79
109
|
private getCustomColumns;
|
|
110
|
+
private prepareRawGridForExport;
|
|
111
|
+
private getGridNotColumnChildren;
|
|
80
112
|
}
|
|
81
113
|
|
|
82
114
|
/**
|
|
@@ -86,6 +118,13 @@ export declare class GridPDFExport extends React_2.Component<GridPDFExportProps,
|
|
|
86
118
|
export declare interface GridPDFExportProps extends PDFExportProps {
|
|
87
119
|
}
|
|
88
120
|
|
|
121
|
+
/**
|
|
122
|
+
* @hidden
|
|
123
|
+
*/
|
|
124
|
+
declare interface GridPDFExportState {
|
|
125
|
+
show: boolean;
|
|
126
|
+
}
|
|
127
|
+
|
|
89
128
|
/**
|
|
90
129
|
* @hidden
|
|
91
130
|
*/
|
|
@@ -370,7 +409,7 @@ export declare function savePDF(domElement: HTMLElement, options?: PDFExportProp
|
|
|
370
409
|
/**
|
|
371
410
|
* A React component which facilitates the PDF export of the TreeList.
|
|
372
411
|
*/
|
|
373
|
-
export declare class TreeListPDFExport extends React_2.Component<TreeListPDFExportProps,
|
|
412
|
+
export declare class TreeListPDFExport extends React_2.Component<TreeListPDFExportProps, TreeListPDFExportState> {
|
|
374
413
|
/**
|
|
375
414
|
* @hidden
|
|
376
415
|
*/
|
|
@@ -408,11 +447,41 @@ export declare class TreeListPDFExport extends React_2.Component<TreeListPDFExpo
|
|
|
408
447
|
* @hidden
|
|
409
448
|
*/
|
|
410
449
|
saveTreeListPDF: any;
|
|
450
|
+
/**
|
|
451
|
+
* @hidden
|
|
452
|
+
*/
|
|
453
|
+
treeList: any;
|
|
454
|
+
/**
|
|
455
|
+
* @hidden
|
|
456
|
+
*/
|
|
457
|
+
columns: any;
|
|
458
|
+
/**
|
|
459
|
+
* @hidden
|
|
460
|
+
*/
|
|
461
|
+
data?: any[];
|
|
462
|
+
/**
|
|
463
|
+
* @hidden
|
|
464
|
+
*/
|
|
465
|
+
callback?: any;
|
|
466
|
+
/**
|
|
467
|
+
* @hidden
|
|
468
|
+
*/
|
|
469
|
+
treeListInnerWrapperRef: React_2.RefObject<HTMLDivElement>;
|
|
470
|
+
/**
|
|
471
|
+
* @hidden
|
|
472
|
+
*/
|
|
473
|
+
readonly state: {
|
|
474
|
+
show: boolean;
|
|
475
|
+
};
|
|
411
476
|
constructor(props: any);
|
|
412
477
|
/**
|
|
413
478
|
* @hidden
|
|
414
479
|
*/
|
|
415
|
-
|
|
480
|
+
componentDidUpdate(_prevProps: any, prevState: any): void;
|
|
481
|
+
/**
|
|
482
|
+
* @hidden
|
|
483
|
+
*/
|
|
484
|
+
render(): false | React_2.ReactPortal;
|
|
416
485
|
/**
|
|
417
486
|
* Saves the content of the TreeList as a PDF file.
|
|
418
487
|
*
|
|
@@ -423,6 +492,7 @@ export declare class TreeListPDFExport extends React_2.Component<TreeListPDFExpo
|
|
|
423
492
|
save(data?: any[], columns?: any[], callback?: () => void): void;
|
|
424
493
|
protected getSavePDF(): typeof savePDF;
|
|
425
494
|
private getTreeList;
|
|
495
|
+
private prepareRawTreeListForExport;
|
|
426
496
|
}
|
|
427
497
|
|
|
428
498
|
/**
|
|
@@ -436,4 +506,11 @@ export declare interface TreeListPDFExportProps extends PDFExportProps {
|
|
|
436
506
|
allPages?: boolean;
|
|
437
507
|
}
|
|
438
508
|
|
|
509
|
+
/**
|
|
510
|
+
* @hidden
|
|
511
|
+
*/
|
|
512
|
+
declare interface TreeListPDFExportState {
|
|
513
|
+
show: boolean;
|
|
514
|
+
}
|
|
515
|
+
|
|
439
516
|
export { }
|
package/package-metadata.mjs
CHANGED
|
@@ -10,7 +10,7 @@ const e = {
|
|
|
10
10
|
name: "@progress/kendo-react-pdf",
|
|
11
11
|
productName: "KendoReact",
|
|
12
12
|
productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
|
|
13
|
-
publishDate:
|
|
13
|
+
publishDate: 1719467553,
|
|
14
14
|
version: "",
|
|
15
15
|
licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
|
|
16
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-pdf",
|
|
3
|
-
"version": "8.1.0
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "React PDF Processing enables you to export single- and multi-page content in PDF. KendoReact PDF Processing package",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@progress/kendo-drawing": "^1.20.1",
|
|
26
26
|
"@progress/kendo-file-saver": "^1.0.1",
|
|
27
27
|
"@progress/kendo-licensing": "^1.3.4",
|
|
28
|
-
"@progress/kendo-react-common": "8.1.0
|
|
28
|
+
"@progress/kendo-react-common": "8.1.0",
|
|
29
29
|
"react": "^16.8.2 || ^17.0.0 || ^18.0.0",
|
|
30
30
|
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
|
|
31
31
|
},
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react"),e=require("prop-types"),c=require("../getPageMargin.js"),l=require("../savePDF.js"),u=require("./provideSaveTreeListPDF.js"),g=require("react-dom");function h(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const s in n)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>n[s]})}}return t.default=n,Object.freeze(t)}const i=h(p),a=class a extends i.Component{constructor(t){super(t),this.state={show:!1},this.saveTreeListPDF=u.provideSaveTreeListPDF(this.getSavePDF()),this.treeListInnerWrapperRef=i.createRef()}componentDidUpdate(t,s){this.state.show&&this.state.show!==s.show&&this.saveTreeListPDF(this.treeListInnerWrapperRef.current,Object.assign({},this.props,{margin:c.getPageMargin(this.props)}),this.callback)}render(){return this.state.show&&g.createPortal(i.createElement("div",{style:{position:"absolute",left:"-5000px",top:"0px"}},i.createElement("div",{ref:this.treeListInnerWrapperRef},this.prepareRawTreeListForExport())),document.body)}save(t,s,r){this.treeList=this.getTreeList(),this.columns=s||[],this.data=t,this.callback=()=>{this.setState({show:!1}),r&&r()},this.setState({show:!0})}getSavePDF(){return l.savePDF}getTreeList(){const t=this.props.children;if(t&&t.props.data&&t.props.columns)return this.props.children}prepareRawTreeListForExport(){const t=this.props.allPages&&this.data?{data:this.data,take:Number.MAX_VALUE,skip:0}:{},s={style:Object.assign({},this.treeList.props.style,{width:"1000px"})},r=Object.assign({},t,s);return this.columns&&this.columns.length>0?i.cloneElement(this.treeList,Object.assign({},r,{columns:this.columns})):i.cloneElement(this.treeList,r)}};a.propTypes={author:e.string,avoidLinks:e.oneOfType([e.bool,e.string]),forcePageBreak:e.string,keepTogether:e.string,creator:e.string,date:e.instanceOf(Date),imageResolution:e.number,fileName:e.string,forceProxy:e.bool,keywords:e.string,landscape:e.bool,margin:e.oneOfType([e.string,e.number,e.shape({left:e.oneOfType([e.number,e.string]),top:e.oneOfType([e.number,e.string]),right:e.oneOfType([e.number,e.string]),bottom:e.oneOfType([e.number,e.string])})]),pageTemplate:e.any,paperSize:e.any,repeatHeaders:e.bool,scale:e.number,proxyData:e.any,proxyURL:e.string,proxyTarget:e.string,producer:e.string,subject:e.string,title:e.string,allPages:e.bool};let o=a;exports.TreeListPDFExport=o;
|
|
@@ -6,20 +6,46 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import * as
|
|
9
|
+
import * as s from "react";
|
|
10
10
|
import e from "prop-types";
|
|
11
11
|
import { getPageMargin as a } from "../getPageMargin.mjs";
|
|
12
12
|
import { savePDF as p } from "../savePDF.mjs";
|
|
13
|
-
import { provideSaveTreeListPDF as
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
import { provideSaveTreeListPDF as h } from "./provideSaveTreeListPDF.mjs";
|
|
14
|
+
import { createPortal as l } from "react-dom";
|
|
15
|
+
const o = class o extends s.Component {
|
|
16
|
+
constructor(t) {
|
|
17
|
+
super(t), this.state = {
|
|
18
|
+
show: !1
|
|
19
|
+
}, this.saveTreeListPDF = h(this.getSavePDF()), this.treeListInnerWrapperRef = s.createRef();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
24
|
+
componentDidUpdate(t, r) {
|
|
25
|
+
this.state.show && this.state.show !== r.show && this.saveTreeListPDF(
|
|
26
|
+
this.treeListInnerWrapperRef.current,
|
|
27
|
+
Object.assign({}, this.props, { margin: a(this.props) }),
|
|
28
|
+
this.callback
|
|
29
|
+
);
|
|
17
30
|
}
|
|
18
31
|
/**
|
|
19
32
|
* @hidden
|
|
20
33
|
*/
|
|
21
34
|
render() {
|
|
22
|
-
return
|
|
35
|
+
return this.state.show && l(
|
|
36
|
+
/* @__PURE__ */ s.createElement(
|
|
37
|
+
"div",
|
|
38
|
+
{
|
|
39
|
+
style: {
|
|
40
|
+
position: "absolute",
|
|
41
|
+
left: "-5000px",
|
|
42
|
+
top: "0px"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
/* @__PURE__ */ s.createElement("div", { ref: this.treeListInnerWrapperRef }, this.prepareRawTreeListForExport())
|
|
46
|
+
),
|
|
47
|
+
document.body
|
|
48
|
+
);
|
|
23
49
|
}
|
|
24
50
|
/* eslint-disable max-len */
|
|
25
51
|
/**
|
|
@@ -30,25 +56,25 @@ const t = class t extends i.Component {
|
|
|
30
56
|
* @param callback - The callback that will be executed after the PDF is saved.
|
|
31
57
|
*/
|
|
32
58
|
// tslint:enable:max-line-length
|
|
33
|
-
save(
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
o,
|
|
38
|
-
r,
|
|
39
|
-
n || []
|
|
40
|
-
);
|
|
59
|
+
save(t, r, i) {
|
|
60
|
+
this.treeList = this.getTreeList(), this.columns = r || [], this.data = t, this.callback = () => {
|
|
61
|
+
this.setState({ show: !1 }), i && i();
|
|
62
|
+
}, this.setState({ show: !0 });
|
|
41
63
|
}
|
|
42
64
|
getSavePDF() {
|
|
43
65
|
return p;
|
|
44
66
|
}
|
|
45
67
|
getTreeList() {
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
68
|
+
const t = this.props.children;
|
|
69
|
+
if (t && t.props.data && t.props.columns)
|
|
48
70
|
return this.props.children;
|
|
49
71
|
}
|
|
72
|
+
prepareRawTreeListForExport() {
|
|
73
|
+
const t = this.props.allPages && this.data ? { data: this.data, take: Number.MAX_VALUE, skip: 0 } : {}, r = { style: Object.assign({}, this.treeList.props.style, { width: "1000px" }) }, i = Object.assign({}, t, r);
|
|
74
|
+
return this.columns && this.columns.length > 0 ? s.cloneElement(this.treeList, Object.assign({}, i, { columns: this.columns })) : s.cloneElement(this.treeList, i);
|
|
75
|
+
}
|
|
50
76
|
};
|
|
51
|
-
|
|
77
|
+
o.propTypes = {
|
|
52
78
|
author: e.string,
|
|
53
79
|
avoidLinks: e.oneOfType([e.bool, e.string]),
|
|
54
80
|
forcePageBreak: e.string,
|
|
@@ -78,7 +104,7 @@ t.propTypes = {
|
|
|
78
104
|
title: e.string,
|
|
79
105
|
allPages: e.bool
|
|
80
106
|
};
|
|
81
|
-
let
|
|
107
|
+
let n = o;
|
|
82
108
|
export {
|
|
83
|
-
|
|
109
|
+
n as TreeListPDFExport
|
|
84
110
|
};
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./export-element.js");function c(n){return(r,o={},t)=>p(n,r,o,t)}function p(n,r,o={},t){let e;i();function i(){n(l(),o,d)}function d(){document.body.removeChild(e),e=void 0,t&&t()}function l(){e=document.createElement("div"),e.className="k-treelist-pdf-export-element";const u=a.exportElement(r);return e.appendChild(u),document.body.appendChild(e),e}}exports.provideSaveTreeListPDF=c;
|
|
@@ -6,44 +6,30 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function P(c) {
|
|
14
|
-
return (r, i = {}, s, l, n) => x(
|
|
15
|
-
c,
|
|
9
|
+
import { exportElement as u } from "./export-element.mjs";
|
|
10
|
+
function m(t) {
|
|
11
|
+
return (r, o = {}, n) => a(
|
|
12
|
+
t,
|
|
16
13
|
r,
|
|
17
|
-
|
|
18
|
-
s,
|
|
19
|
-
l,
|
|
14
|
+
o,
|
|
20
15
|
n
|
|
21
16
|
);
|
|
22
17
|
}
|
|
23
|
-
function
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
t
|
|
28
|
-
d();
|
|
29
|
-
}, 0)) : E.render(m(), o, d);
|
|
18
|
+
function a(t, r, o = {}, n) {
|
|
19
|
+
let e;
|
|
20
|
+
i();
|
|
21
|
+
function i() {
|
|
22
|
+
t(l(), o, d);
|
|
30
23
|
}
|
|
31
24
|
function d() {
|
|
32
|
-
|
|
25
|
+
document.body.removeChild(e), e = void 0, n && n();
|
|
33
26
|
}
|
|
34
|
-
function
|
|
35
|
-
document.body.removeChild(t), document.body.removeChild(e), t = e = void 0, s && s();
|
|
36
|
-
}
|
|
37
|
-
function v() {
|
|
27
|
+
function l() {
|
|
38
28
|
e = document.createElement("div"), e.className = "k-treelist-pdf-export-element";
|
|
39
|
-
const p =
|
|
29
|
+
const p = u(r);
|
|
40
30
|
return e.appendChild(p), document.body.appendChild(e), e;
|
|
41
31
|
}
|
|
42
|
-
function m() {
|
|
43
|
-
const p = i.allPages && l ? { data: l, take: Number.MAX_VALUE, skip: 0 } : {}, C = { style: Object.assign({}, r.props.style, { width: "1000px" }) }, u = Object.assign({}, p, C);
|
|
44
|
-
return n && n.length > 0 ? a.cloneElement(r, Object.assign({}, u, { columns: n })) : a.cloneElement(r, u);
|
|
45
|
-
}
|
|
46
32
|
}
|
|
47
33
|
export {
|
|
48
|
-
|
|
34
|
+
m as provideSaveTreeListPDF
|
|
49
35
|
};
|