/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/pandax-report@1.0.0/src/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{h}from"./component/element";import DataProxy from"./core/data_proxy";import Sheet from"./component/sheet";import Bottombar from"./component/bottombar";import{cssPrefix}from"./config";import{locale}from"./locale/locale";import"./index.less";class Xreport{constructor(t,e={}){let s=t;"string"==typeof t&&(s=document.querySelector(t)),this.options={showBottomBar:!1,view:{height:()=>s.clientHeight,width:()=>s.clientWidth},...e},this.sheetIndex=1,this.datas=[],this.bottombar=this.options.showBottomBar?new Bottombar((()=>{if("read"===this.options.mode)return;const t=this.addSheet();this.sheet.resetData(t)}),(t=>{const e=this.datas[t];this.sheet.resetData(e)}),(()=>{this.deleteSheet()}),((t,e)=>{this.datas[t].name=e,this.sheet.trigger("change")})):null,this.data=this.addSheet();const o=h("div",`${cssPrefix}`).on("contextmenu",(t=>t.preventDefault()));s.appendChild(o.el),this.sheet=new Sheet(o,this.data),null!==this.bottombar&&o.child(this.bottombar.el)}addSheet(t,e=!0){const s=t||`sheet${this.sheetIndex}`,o=new DataProxy(s,this.options);return o.change=(...t)=>{this.sheet.trigger("change",...t)},this.datas.push(o),null!==this.bottombar&&this.bottombar.addItem(s,e,this.options),this.sheetIndex+=1,o}deleteSheet(){if(null===this.bottombar)return;const[t,e]=this.bottombar.deleteItem();t>=0&&(this.datas.splice(t,1),e>=0&&this.sheet.resetData(this.datas[e]),this.sheet.trigger("change"))}loadData(t){const e=Array.isArray(t)?t:[t];if(null!==this.bottombar&&this.bottombar.clear(),this.datas=[],e.length>0)for(let t=0;t<e.length;t+=1){const s=e[t],o=this.addSheet(s.name,0===t);o.setData(s),0===t&&this.sheet.resetData(o)}return this}getData(){return this.datas.map((t=>t.getData()))}cellText(t,e,s,o=0){return this.datas[o].setCellText(t,e,s,"finished"),this}cell(t,e,s=0){return this.datas[s].getCell(t,e)}cellStyle(t,e,s=0){return this.datas[s].getCellStyle(t,e)}reRender(){return this.sheet.table.render(),this}on(t,e){return this.sheet.on(t,e),this}validate(){const{validations:t}=this.data;return t.errors.size<=0}change(t){return this.sheet.on("change",t),this}static locale(t,e){locale(t,e)}}const xreport=(t,e={})=>new Xreport(t,e);window&&(window.xreport=xreport);export default xreport;
//# sourceMappingURL=/sm/e6aabdcdb35c89591c8e71626d2bfecaaea22ba66b06c6a4022be70645f2b214.map