UNPKG

@progress/kendo-react-pdf

Version:

React PDF Processing enables you to export single- and multi-page content in PDF. KendoReact PDF Processing package

9 lines (8 loc) 3.26 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),e=require("prop-types"),g=require("../getPageMargin.js"),h=require("../savePDF.js"),u=require("./provideSaveTreeListPDF.js"),m=require("react-dom"),p=require("../package-metadata.js"),n=require("@progress/kendo-react-common");function d(i){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const s in i)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(t,s,a.get?a:{enumerable:!0,get:()=>i[s]})}}return t.default=i,Object.freeze(t)}const r=d(l),c=class c extends r.Component{constructor(t){super(t),this.state={show:!1},this.showLicenseWatermark=!1,this.showLicenseWatermark=!n.validatePackage(p.packageMetadata,{component:"TreeListPDFExport"}),this.licenseMessage=n.getLicenseMessage(p.packageMetadata),this.saveTreeListPDF=u.provideSaveTreeListPDF(this.getSavePDF()),this.treeListInnerWrapperRef=r.createRef()}componentDidUpdate(t,s){this.state.show&&this.state.show!==s.show&&this.saveTreeListPDF(this.treeListInnerWrapperRef.current,Object.assign({},this.props,{margin:g.getPageMargin(this.props)}),this.callback)}render(){return r.createElement(r.Fragment,null,this.state.show&&m.createPortal(r.createElement("div",{style:{position:"absolute",left:"-5000px",top:"0px"}},r.createElement("div",{ref:this.treeListInnerWrapperRef},this.prepareRawTreeListForExport())),document.body),this.showLicenseWatermark&&r.createElement(n.WatermarkOverlay,{message:this.licenseMessage}))}save(t,s,a){this.treeList=this.getTreeList(),this.columns=s||[],this.data=t,this.callback=()=>{this.setState({show:!1}),a&&a()},this.setState({show:!0})}getSavePDF(){return h.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"})},a=Object.assign({},t,s);return this.columns&&this.columns.length>0?r.cloneElement(this.treeList,Object.assign({},a,{columns:this.columns})):r.cloneElement(this.treeList,a)}};c.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=c;exports.TreeListPDFExport=o;