UNPKG

e-virt-table

Version:

A powerful data table based on canvas. You can use it as data grid、Microsoft Excel or Google sheets. It supports virtual scroll、cell edit etc.

4 lines 253 kB
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(":root{--evt-header-font: 12px normal Arial;--evt-body-font: 12px normal Arial;--evt-color-white: #fff;--evt-color-black: #000000;--evt-color-primary: rgb(82, 146, 247);--evt-text-color-primary: #333;--evt-text-color-regular: #666;--evt-text-color-secondary: #999;--evt-box-shadow: 0 2px 12px 0 #0000001a;--evt-editor-bg-color: #fff;--evt-editor-text-color: #333;--evt-border-color: #e1e6eb;--evt-fixed-column-shadow-color: rgba(0, 0, 0, .1);--evt-fixed-column-shadow-fade-color: rgba(0, 0, 0, 0);--evt-body-bg-color: #fff;--evt-stripe-color: #fafafa;--evt-placeholder-color: #cdd0dc;--evt-header-bg-color: #f8faff;--evt-header-text-color: #1d2129;--evt-body-text-color: #4e5969;--evt-footer-text-color: #4e5969;--evt-loading-icon-color: #4e5969;--evt-expand-icon-color: #4e5969;--evt-shrink-icon-color: #4e5969;--evt-error-tip-icon-color: red;--evt-required-color: #f56c6c;--evt-cell-hover-icon-bg-color: #fff;--evt-cell-hover-icon-border-color: #dde0ea;--evt-scroller-color: #dee0e3;--evt-scroller-track-color: #fff;--evt-scroller-focus-color: #bbbec4;--evt-select-border-color: var(--evt-color-primary);--evt-select-area-color: rgba(82, 146, 247, .1);--evt-select-row-col-bg-color: rgba(82, 146, 247, .1);--evt-autofill-point-border-color: #fff;--evt-edit-bg-color: #fcf6ed;--evt-checkbox-color: var(--evt-color-primary);--evt-checkbox-uncheck-color: #dde0ea;--evt-checkbox-disabled-color: #f1f2f4;--evt-checkbox-check-disabled-color: #dde0ea;--evt-icon-edit-color: #4e5969;--evt-icon-select-color: #4e5969;--evt-readonly-color: #fff;--evt-readonly-text-color: var(--evt-body-text-color);--evt-error-tip-color: #ed3f14;--evt-footer-bg-color: #fafafa;--evt-highlight-hover-row-color: rgba(186, 203, 231, .1);--evt-highlight-selected-row-color: rgba(82, 146, 247, .1);--evt-tooltip-bg-color: #303133;--evt-tooltip-text-color: #fff;--evt-resize-row-line-color: #e1e6eb;--evt-resize-column-text-color: #fff;--evt-resize-column-text-bg-color: var(--evt-color-primary);--evt-resize-column-line-color: #e1e6eb;--evt-tree-line-color: #e1e6eb;--evt-sort-icon-color: var(--evt-color-primary);--evt-drag-tip-bg-color: rgba(82, 146, 247, .1);--evt-drag-tip-line-color: var(--evt-color-primary);--evt-context-menu-min-width: 150px;--evt-context-menu-max-width: 220px;--evt-context-menu-item-padding: 8px 12px;--evt-context-menu-bg-color: #fff;--evt-context-menu-text-color: #333;--evt-context-menu-item-hover-text-color: var(--evt-color-primary);--evt-context-menu-item-hover-bg-color: #f5f5f5;--evt-context-menu-text-size: 13px}.dark{--evt-border-color: #363637;--evt-header-bg-color: #141414;--evt-body-bg-color: #141414;--evt-header-text-color: #a3a6ad;--evt-body-text-color: #cfd3dc;--evt-readonly-text-color: #cfd3dc;--evt-footer-text-color: #cfd3dc;--evt-scroller-color: #414243;--evt-scroller-track-color: #141414;--evt-scroller-focus-color: #a3a6ad;--evt-edit-bg-color: #141414;--evt-footer-bg-color: #262727;--evt-autofill-point-border-color: #fff;--evt-editor-bg-color: #434343;--evt-editor-text-color: #cfd3dc;--evt-context-menu-bg-color: #141414;--evt-context-menu-text-color: #cfd3dc;--evt-context-menu-item-hover-text-color: var(--evt-color-primary);--evt-context-menu-item-hover-bg-color: #414243}.e-virt-table-container{position:relative;outline:none}.e-virt-table-stage{position:relative;overflow:hidden;outline:none;box-sizing:border-box;z-index:10;border-radius:8px;border:1px solid var(--evt-border-color)}.e-virt-table-canvas{position:absolute;left:0;top:0;box-sizing:border-box;background-color:var(--evt-body-bg-color);border:none;outline:none;z-index:10}.e-virt-table-editor{position:absolute;top:-10000px;left:-10000px;text-align:left;height:auto;line-height:0;z-index:100;overflow:hidden;background-color:var(--evt-editor-bg-color);border:2px solid var(--evt-color-primary);box-sizing:border-box;box-shadow:var(--evt-box-shadow);display:flex;align-items:center}.e-virt-table-overlayer{position:absolute;left:0;top:0;overflow:hidden;z-index:100;pointer-events:none}.e-virt-table-editor-textarea{width:100%;box-sizing:border-box;outline:none;font-weight:400;padding:8px;font-size:12px;color:inherit;white-space:pre-wrap;word-wrap:break-word;word-break:break-all;line-height:1.5;margin:0;border:none;vertical-align:middle;background:var(--evt-editor-bg-color);color:var(--evt-editor-text-color);overflow-y:auto;resize:none}.e-virt-table-context-menu{position:absolute;font-size:14px;color:var(--evt-text-color-regular);background-color:var(--evt-color-white);border-radius:4px;border:1px solid #e4e7ed;box-shadow:var(--evt-box-shadow);width:fit-content;padding:6px 0;z-index:9999;left:-99999px;top:-99999px}.e-virt-table-context-menu-item{cursor:pointer;padding:6px 24px;color:var(--evt-text-color-regular)}.e-virt-table-context-menu-item:hover{color:var(--evt-color-primary);background-color:#f5f7fa}.e-virt-table-loading{display:none;position:absolute;left:0;top:0;right:0;bottom:0;width:100%;height:100%;z-index:2000;background-color:#fff6;display:flex;align-items:center;justify-content:center}.e-virt-table-loading-spinner{opacity:1;display:flex;flex-direction:column;align-items:center;justify-content:center}.e-virt-table-loading-spinner svg{color:var(--evt-text-color-regular);animation:rotate 1s linear infinite}@keyframes rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.e-virt-table-loading-text{margin:0;font-size:12px;color:var(--evt-text-color-regular)}.e-virt-table-main-menu,.e-virt-table-submenu{position:absolute;background:var(--evt-context-menu-bg-color);border-radius:4px;box-shadow:0 2px 8px #0000001a;min-width:var(--evt-context-menu-min-width);max-width:var(--evt-context-menu-max-width);color:var(--evt-text-color-primary)}.e-virt-table-main-menu{border:1px solid var(--evt-border-color);z-index:3000;left:-99999px;top:-99999px;display:none;position:fixed;background-color:var(--evt-body-bg-color)}.e-virt-table-submenu{border:1px solid var(--evt-border-color);z-index:1000;max-height:350px;overflow-y:auto;opacity:0;visibility:hidden;transform:translate(-10px);transition:opacity .2s,visibility .2s,transform .2s;-ms-overflow-style:none;scrollbar-width:none}.e-virt-table-submenu::-webkit-scrollbar{display:none}.e-virt-table-submenu.show{opacity:1;visibility:visible;transform:translate(0)}.e-virt-table-submenu:not(.show){transition:none}.e-virt-table-menu-item,.e-virt-table-submenu-item{position:relative;-webkit-user-select:none;user-select:none;padding:var(--evt-context-menu-item-padding);cursor:pointer;display:flex;justify-content:space-between;align-items:center;transition:background .2s,color .2s;color:var(--evt-context-menu-text-color);font-size:var(--evt-context-menu-text-size)}.e-virt-table-menu-item:last-child,.e-virt-table-submenu-item:last-child{border-bottom:none}.e-virt-table-menu-item:has(.e-virt-table-menu-item-icon){padding-left:8px}.e-virt-table-menu-item-content{display:flex;align-items:center;flex:1;min-width:0}.e-virt-table-menu-item-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;margin-right:8px;flex-shrink:0}.e-virt-table-menu-item-icon svg{width:100%;height:100%;fill:currentColor}.e-virt-table-menu-item-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.e-virt-table-menu-arrow{display:inline-flex;align-items:center;justify-content:center;color:var(--evt-text-color-regular);transition:color .2s}.e-virt-table-menu-arrow svg{width:20px;height:20px;fill:currentColor}.e-virt-table-submenu-item:hover,.e-virt-table-menu-item:hover,.e-virt-table-menu-item.active{background:var(--evt-context-menu-item-hover-bg-color);color:var(--evt-context-menu-item-hover-text-color)}.e-virt-table-menu-item.disabled,.e-virt-table-submenu-item.disabled{cursor:not-allowed}.e-virt-table-finder-bar{position:absolute;top:8px;right:16px;display:none;z-index:10000;background:#fff;border:1px solid #dadce0;border-radius:12px;box-shadow:0 2px 6px #0003;padding:0 8px;height:48px;min-width:250px;align-items:center;font-size:12px}.e-virt-table-finder-bar.show{display:flex}.e-virt-table-finder-bar-input-wrapper{display:flex;align-items:center;flex:1;padding:0 8px;position:relative}.e-virt-table-finder-bar-input{border:none;outline:none;flex:1;font-size:12px;background:transparent;color:#333;min-width:150px;padding-left:0;position:relative}.e-virt-table-finder-bar-nav{display:flex;flex-direction:row;gap:8px;margin:0 8px;align-items:center}.e-virt-table-finder-bar-nav-btn{border:none;background:transparent;cursor:pointer;padding:0;color:#666;border-radius:50%;display:flex;align-items:center;justify-content:center}.e-virt-table-finder-bar-nav-btn svg{width:24px;height:24px}.e-virt-table-finder-bar-nav-btn.prev-btn{transform:rotate(-90deg)}.e-virt-table-finder-bar-nav-btn.next-btn{transform:rotate(90deg)}.e-virt-table-finder-bar-nav-btn.close-btn{font-size:24px;color:#666;line-height:1;width:24px;height:24px}.e-virt-table-finder-bar-nav-btn:hover{color:#666;background-color:#f0f0f0}.e-virt-table-finder-bar-count{color:#666;font-size:12px;margin:0 8px;white-space:nowrap;flex-shrink:0}.e-virt-table-finder-bar-count.no-results{color:#999}.e-virt-table-finder-bar-loading{display:none;position:absolute;left:8px;top:0;width:16px;height:16px;flex-shrink:0;pointer-events:none;z-index:0}.e-virt-table-finder-bar-loading.show{display:block}.e-virt-table-finder-bar-loading svg{width:100%;height:100%;color:#666;animation:rotate 1s linear infinite}.e-virt-table-empty{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);font-size:14px;color:#666;z-index:15}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})(); (function(Y,B){typeof exports=="object"&&typeof module<"u"?module.exports=B():typeof define=="function"&&define.amd?define(B):(Y=typeof globalThis<"u"?globalThis:Y||self,Y.EVirtTable=B())})(this,(function(){"use strict";var as=Object.defineProperty;var ls=(Y,B,G)=>B in Y?as(Y,B,{enumerable:!0,configurable:!0,writable:!0,value:G}):Y[B]=G;var n=(Y,B,G)=>ls(Y,typeof B!="symbol"?B+"":B,G);class Y{constructor(t){n(this,"rules");this.rules=t}validate(t){const e=[],{column:i,row:s,key:o,rowKey:r,colIndex:a,rowIndex:l,value:c,field:f,fieldValue:d}=t;Array.isArray(this.rules)||(this.rules=[this.rules]);for(const u of this.rules){if(u.validator){const x={field:f,fieldValue:d,value:c,column:i,colIndex:a,rowIndex:l,row:s,key:o,rowKey:r,...u};u.validator(x,c,g=>{g&&e.push({...x,message:g})})}if(!u.required&&(c==null||c===""))return e;u.pattern&&!u.pattern.test(c)&&e.push({value:c,column:i,row:s,key:o,rowKey:r,colIndex:a,rowIndex:l,field:f,fieldValue:d,message:u.message||`${o} is pattern validation error`}),u.required&&(c==null||c==="")&&e.push({value:c,column:i,row:s,key:o,rowKey:r,colIndex:a,rowIndex:l,field:f,fieldValue:d,message:u.message||`${o} is required`})}return e}}function B(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(h){const t=Math.random()*16|0;return(h==="x"?t:t&3|8).toString(16)})}function G(h,t){let e=0,i;return function(...s){const o=new Date().getTime(),r=o-e,a=typeof t=="function"?t():t;!e||r>=a?(h.apply(this,s),e=o):i||(i=setTimeout(()=>{h.apply(this,s),e=new Date().getTime(),i=void 0},a-r))}}function ft(h=[]){return h.length?h.map(t=>ft(t.children)+1).sort((t,e)=>e-t)[0]:0}function Se(h=[]){let t=[],e=[],i=[];return h.forEach(s=>{s.fixed==="left"?t.push(s):s.fixed==="right"?i.push(s):e.push(s)}),[...t.sort((s,o)=>(s.sort??0)-(o.sort??0)),...e.sort((s,o)=>(s.sort??0)-(o.sort??0)),...i.sort((s,o)=>(s.sort??0)-(o.sort??0))]}function ut(h=[],t=1,e=0,i=""){return h.sort((s,o)=>(s.sort??0)-(o.sort??0)).map(s=>{if(s.children){let o=0,r=s.fixed;s.children.forEach(l=>{l.fixed=r});const a=ut(s.children,t-1,e+1,s.key);return a&&a.forEach(l=>{o+=l.colspan??0}),{...s,width:s.width,level:e,rowspan:1,colspan:o,parentKey:i,children:a.sort((l,c)=>(l.sort??0)-(c.sort??0))}}return{...s,level:e,rowspan:t,colspan:1,parentKey:i}})}function rt(h=[]){let t=[];return h.forEach(e=>{e.children?t=t.concat(rt(e.children)):t.push(e)}),t}function $t(h){return h.filter(t=>!t.hide).map(t=>Array.isArray(t.children)&&t.children.length>0?{...t,children:$t(t.children)}:{...t})}const Gt=/^(\r\n|\n\r|\r|\n)/,Oe=/^[^\t\r\n]+/,Ut=/^\t/;function Le(h){let t=[[""]];if(h.length===0)return t;let e=0,i=0,s;for(;h.length>0&&s!==h.length;)if(s=h.length,h.match(Ut))h=h.replace(Ut,""),e+=1,t[i][e]="";else if(h.match(Gt))h=h.replace(Gt,""),e=0,i+=1,t[i]=[""];else{let o="";if(h.startsWith('"')){let r=0,a=!0;for(;a;){const l=h.slice(0,1);l==='"'&&(r+=1),o+=l,h=h.slice(1),(h.length===0||h.match(/^[\t\r\n]/)&&r%2===0)&&(a=!1)}o=o.replace(/^"/,"").replace(/"$/,"").replace(/["]*/g,l=>new Array(Math.floor(l.length/2)).fill('"').join(""))}else{const r=h.match(Oe);o=r?r[0]:"",h=h.slice(o.length)}t[i][e]=o}return Array.isArray(t)&&t.length>1&&t[t.length-1].length===1&&t[t.length-1][0]===""&&(t=t.slice(0,t.length-1)),t}function Me(h){let t,e,i,s,o="",r;for(t=0,e=h.length;t<e;t+=1){for(s=h[t].length,i=0;i<s;i+=1)i>0&&(o+=" "),r=h[t][i],typeof r=="string"?r.indexOf(` `)>-1?o+=`"${r.replace(/"/g,'""')}"`:o+=r:r==null?o+="":o+=r;t!==e-1&&(o+=` `)}return o}function jt(h,t,e=[]){let i=0;const s=[];return h.forEach((o,r)=>{if(r===0)s.push(1);else{const a=e.reduce((c,f)=>`${c}${o[f]??""}`,"")||o[t],l=e.reduce((c,f)=>`${c}${h[r-1][f]??""}`,"")||h[r-1][t];a===l?(s[i]+=1,s.push(0)):(s.push(1),i=r)}}),s}function qt(h,t){let e="",i="";const s={};return t.forEach((o,r)=>{r===0?(e=o.key,i=o.key,s[o.key]=1):h[o.key]===h[e]?(s[o.key]=0,s[i]+=1):(s[o.key]=1,e=o.key,i=o.key)}),s}function Ae(h,t,e=[]){const{visibleRows:i,rowIndex:s,headIndex:o}=h,r=jt(i,t,e);return r[s-o]===0?{rowspan:0,colspan:0,relationRowKeys:e,mergeRow:!0}:{rowspan:r[s-o],colspan:1,relationRowKeys:e,mergeRow:!0}}function De(h,t=[]){const{column:e,row:i,visibleLeafColumns:s}=h,o=s.filter(r=>t.includes(r.key));if(t.includes(e.key)){const r=qt(i,o);return r[e.key]===0?{rowspan:0,colspan:0,relationColKeys:t,mergeCol:!0}:{rowspan:1,colspan:r[e.key],relationColKeys:t,mergeCol:!0}}}function He(h,t=document.documentElement){const e=h.startsWith("--")?h:`--${h}`;return getComputedStyle(t).getPropertyValue(e).trim()}function Zt(h){if(!h)return new Date(0);if(typeof h=="number")return new Date(h);const t=String(h).trim(),e=new Date(t);if(!isNaN(e.getTime()))return e;const i=[/^(\d{4})-(\d{1,2})-(\d{1,2})$/,/^(\d{4})\/(\d{1,2})\/(\d{1,2})$/,/^(\d{4})\.(\d{1,2})\.(\d{1,2})$/,/^(\d{1,2})-(\d{1,2})-(\d{4})$/,/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,/^(\d{1,2})-(\d{1,2})-(\d{4})$/,/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,/^(\d{4})(\d{2})(\d{2})$/,/^(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/,/^(\d{4})\/(\d{1,2})\/(\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/];for(const s of i){const o=t.match(s);if(o){const r=o.slice(1).map(Number);if(s.source.includes("YYYY-MM-DD")||s.source.includes("YYYY/MM/DD")||s.source.includes("YYYY.MM.DD")){const[a,l,c,f=0,d=0,u=0]=r;return new Date(a,l-1,c,f,d,u)}else if(s.source.includes("DD-MM-YYYY")||s.source.includes("DD/MM/YYYY")||s.source.includes("DD.MM.YYYY")){const[a,l,c,f=0,d=0,u=0]=r;return new Date(c,l-1,a,f,d,u)}else if(s.source.includes("MM-DD-YYYY")||s.source.includes("MM/DD/YYYY")||s.source.includes("MM.DD.YYYY")){const[a,l,c,f=0,d=0,u=0]=r;return new Date(c,a-1,l,f,d,u)}else if(s.source.includes("YYYYMMDD")){const[a,l,c]=r;return new Date(a,l-1,c)}}}return new Date(NaN)}function Ne(h,t){const e=Zt(h),i=Zt(t);return isNaN(e.getTime())&&isNaN(i.getTime())?0:isNaN(e.getTime())?-1:isNaN(i.getTime())?1:e.getTime()-i.getTime()}function ke(h){const t=String(h).match(/\.(\d+)/);return(t==null?void 0:t[1].length)??0}function Be(h){return(h.scrollbarMode??h.SCROLLBAR_MODE)==="inner"?"inner":"outer"}function P(h){return Be(h)==="inner"}function X(h){return P(h)?0:h.SCROLLER_TRACK_SIZE||0}function Jt(h){return h.SCROLLER_TRACK_SIZE||0}function Qt(h,t){return!P(h)||!t?0:Jt(h)}function Xe(h){return P(h)?1:0}function Fe(h){return!P(h)}function Ye(h){return!P(h)}function Ke(h,t){return P(h)&&t}function We(h,t){return P(h)?t.innerVisible||t.isFocus||t.isDragging:!0}class te{constructor(t,e,i,s,o,r,a){n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"visibleWidth",0);n(this,"visibleHeight",0);n(this,"fixed");n(this,"cellType");n(this,"drawX",0);n(this,"drawY",0);n(this,"cellImages",new Map);this.ctx=t,this.x=e,this.y=i,this.width=s,this.height=o,this.fixed=a,this.cellType=r}isHorizontalVisible(){if(this.fixed)return!0;const{stageWidth:t,fixedLeftWidth:e,scrollX:i,fixedRightWidth:s}=this.ctx,o=t;return!(this.x+this.width-e-i<=0||this.x-i>=o-s)}isVerticalVisible(){const{stageHeight:t,scrollY:e}=this.ctx,i=t;return!(this.y+this.height-e<=0||this.y-e>=i)}getDrawX(){if(this.fixed==="left")return this.x;if(this.fixed==="right"){const{stageWidth:t}=this.ctx;return t-(this.ctx.header.width-this.x)-X(this.ctx.config)}return this.x-this.ctx.scrollX}getDrawY(){return this.cellType==="header"?this.y:this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED?this.y:this.y-this.ctx.scrollY}getLeftFixedX(){return this.x-this.ctx.scrollX}isInside(t,e){return t>=this.drawX&&t<=this.drawX+this.width&&e>=this.drawY&&e<=this.drawY+this.height}isInsideVisible(t,e){return t>=this.drawX&&t<=this.drawX+this.visibleWidth&&e>=this.drawY&&e<=this.drawY+this.visibleHeight&&this.isInside(t,e)}setImage(t,e){this.cellImages.set(t,e)}getImages(){return this.cellImages}getImage(t){return this.cellImages.get(t)}isImageInside(t,e){const{offsetX:i,offsetY:s}=this.ctx.getOffset(e),o=this.getImage(t);return o?o.isInside(i,s):!1}getImageClickDirection(t,e){const{offsetX:i,offsetY:s}=this.ctx.getOffset(e),o=this.getImage(t);if(!o)return null;const r=i-o.x,a=s-o.y,l=o.width/2,c=o.height/2;return a<c?r<l?"up-left":"up-right":r<l?"down-left":"down-right"}}class tt{constructor(t,e,i,s,o,r){n(this,"source");n(this,"name");n(this,"x");n(this,"y");n(this,"width");n(this,"height");n(this,"visible",!0);this.source=r,this.name=t,this.x=e,this.y=i,this.width=s,this.height=o}drawWrapper(t,e){t.paint.drawRect(this.x-2,this.y-2,this.width+4,this.height+4,{radius:4,borderWidth:1,...e})}setVisible(t){this.visible=t}isInside(t,e){return this.visible?!!(this.source&&t>this.x&&t<this.x+this.width&&e>this.y&&e<this.y+this.height):!1}}function Ve(h){return h.ENABLE_RESIZE_COLUMN?h.RESIZE_COLUMN_DIVIDER_COLOR:void 0}function nt(h){return h===!0?"default":h===!1?"inner":h}function xt(h){return nt(h)==="default"}function Ot(h){const t=nt(h);return t==="default"||t==="inner"}function ze(h,t,e,i,s={}){const{fixedLeftEnd:o=i,fixedRightStart:r=0}=s;return h==="right"?t>r+.01?"left":null:h==="left"?t+e<o-.01?"right":null:t+e<i-.01?"right":null}function Pe(h){const t=nt(h);return t==="default"||t==="outer"}function Lt(h){return nt(h)==="default"}function $e(h,t){return Lt(h)||t}class ee extends te{constructor(e,i,s,o,r,a,l,c,f,d="body",u=!0){super(e,o,r,a,l,d,c.fixed);n(this,"parentRowKey","");n(this,"parentRowKeys",[]);n(this,"formatter");n(this,"formatterFinderValue");n(this,"formatterFinderFooterValue");n(this,"formatterFooter");n(this,"hoverIconName","");n(this,"operation",!1);n(this,"align");n(this,"verticalAlign");n(this,"fixed");n(this,"type");n(this,"editorType");n(this,"editorProps");n(this,"cellType");n(this,"level");n(this,"colspan",1);n(this,"rowspan",1);n(this,"mergeRow",!1);n(this,"mergeCol",!1);n(this,"relationRowKeys",[]);n(this,"relationColKeys",[]);n(this,"key");n(this,"column");n(this,"rowIndex");n(this,"colIndex");n(this,"rowKey");n(this,"row");n(this,"value");n(this,"render");n(this,"renderFooter");n(this,"style",{});n(this,"domDataset",{});n(this,"rules",[]);n(this,"message","");n(this,"text","");n(this,"displayText","");n(this,"visibleWidth",0);n(this,"visibleHeight",0);n(this,"isHasChanged",!1);n(this,"drawX",0);n(this,"drawY",0);n(this,"drawCellBgColor","");n(this,"drawCellSkyBgColor","");n(this,"drawTextColor","");n(this,"drawTextFont","");n(this,"drawTextX",0);n(this,"drawTextY",0);n(this,"drawTextWidth",0);n(this,"drawTextHeight",0);n(this,"autoRowHeight",!1);n(this,"calculatedHeight",0);n(this,"ellipsis",!1);n(this,"rowExpand",!1);n(this,"rowHasChildren",!1);n(this,"overflowTooltipShow",!0);n(this,"selectorCellValueType","value");n(this,"overflowTooltipMaxWidth",500);n(this,"overflowTooltipPlacement","top");n(this,"maxLineClamp","auto");n(this,"precision");n(this,"min");n(this,"max");n(this,"maxlength");n(this,"mixedRender",!1);n(this,"renderType","default");n(this,"renderFooterType","default");this.visibleWidth=this.width,this.visibleHeight=this.height,this.colIndex=s,this.rowIndex=i,this.key=c.key,this.type=c.type||"",this.editorType=c.editorType||"text",this.selectorCellValueType=c.selectorCellValueType||this.ctx.config.SELECTOR_CELL_VALUE_TYPE||"value",this.editorProps=c.editorProps||{},this.cellType=d,this.align=c.align||this.ctx.config.COLUMNS_ALIGN,this.verticalAlign=c.verticalAlign||this.ctx.config.COLUMNS_VERTICAL_ALIGN,this.fixed=c.fixed||"",this.level=c.level||0,this.operation=c.operation||!1,this.column=c,this.rules=c.rules||[],this.row=f,this.rowKey=this.cellType==="body"?this.ctx.database.getRowKeyForRowIndex(i):`${this.cellType}_${this.rowIndex}`,this.value=this.getValue(),this.render=c.render,this.overflowTooltipShow=c.overflowTooltipShow!==!1,this.autoRowHeight=c.autoRowHeight!==void 0?c.autoRowHeight:this.ctx.config.AUTO_ROW_HEIGHT,this.overflowTooltipMaxWidth=c.overflowTooltipMaxWidth||500,this.overflowTooltipPlacement=c.overflowTooltipPlacement||"top",this.renderFooter=c.renderFooter,this.hoverIconName=c.hoverIconName,this.formatter=c.formatter,this.formatterFinderValue=c.formatterFinderValue,this.formatterFinderFooterValue=c.formatterFinderFooterValue,this.formatterFooter=c.formatterFooter,this.maxLineClamp=c.maxLineClamp||"auto",this.precision=c.precision,this.min=c.min,this.max=c.max,this.maxlength=c.maxlength,this.mixedRender=c.mixedRender||!1,this.renderType=c.renderType||"default",this.renderFooterType=c.renderFooterType||"default";const x=this.ctx.database.getRowForRowKey(this.rowKey);this.cellType==="body"&&x&&(this.parentRowKey=x.parentRowKey,this.parentRowKeys=x.parentRowKeys),u&&this.update()}setWidthHeight(e,i){this.width=e,this.height=i}getValidationMessage(){const e=this.ctx.database.getValidationError(this.rowKey,this.key);if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message||""}return this.message}update(){this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.updateSpan(),this.updateDragImage();const e=this.getImage("drag"),i=e?e.width:0;this.drawTextX=this.drawX+i,this.drawTextY=this.drawY,this.isHasChanged=this.ctx.database.isHasChangedData(this.rowKey,this.key),this.drawTextWidth=this.visibleWidth-i,this.drawTextHeight=this.visibleHeight,this.updateStyle(),this.updateType(),this.updateHoverIcon(),this.updateSelection(),this.updateTree(),this.updateEditor(),this.updateRender(),this.getValidationMessage(),this.updateContainer(),this.text=this.getText(),this.displayText=this.getDisplayText()}updateSpan(){if(this.cellType==="footer")return;const{SPAN_METHOD:e}=this.ctx.config;if(typeof e=="function"){const i=e,{colspan:s=1,rowspan:o=1,relationRowKeys:r,relationColKeys:a,mergeRow:l=!1,mergeCol:c=!1}=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue(),headIndex:this.ctx.body.headIndex,headPosition:this.ctx.database.getPositionForRowIndex(this.ctx.body.headIndex),visibleRows:this.ctx.body.visibleRows,visibleLeafColumns:this.ctx.header.visibleLeafColumns,rows:this.ctx.body.data})||{};Array.isArray(r)&&r.length>0?this.relationRowKeys=r:this.relationRowKeys=[this.key],Array.isArray(a)&&a.length>0?this.relationColKeys=a:this.relationColKeys=[this.key],this.mergeCol=c,this.mergeRow=l,this.colspan=s,this.rowspan=o,this.visibleWidth=this.getWidthByColIndexColSpan(this.colIndex,this.colspan),this.visibleHeight=this.ctx.database.getHeightByRowIndexRowSpan(this.rowIndex,this.rowspan)}}updateSpanInfo(){if(this.mergeRow||this.mergeCol){const e=this.getSpanInfo();this.height=e.height,this.width=e.width,this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawY-=e.offsetTop,this.drawX-=e.offsetLeft}}updateType(){const{BODY_CELL_TYPE_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.type=s)}}updateEditor(){const{BODY_CELL_EDITOR_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});if(s!==void 0){const{type:o,props:r={}}=s;this.editorType=o,this.editorProps=r}}}updateRender(){const{BODY_CELL_RENDER_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.render=s)}}validate(){this.ctx.database.getValidator(this.rowKey,this.key).then(e=>{if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message}else this.message=""}).finally(()=>{this.ctx.emit("draw")})}updateStyle(){this.autoRowHeight&&(this.domDataset={"data-auto-height":!0,"data-row-index":this.rowIndex,"data-col-index":this.colIndex}),this.style=this.getOverlayerViewsStyle()}isInsideVisible(e,i){return e>=this.drawX&&e<=this.drawX+this.visibleWidth&&i>=this.drawY&&i<=this.drawY+this.visibleHeight}updateTree(){const{CELL_PADDING:e=0}=this.ctx.config,{rowKey:i,cellType:s}=this;let o,r=0,a="";if(!(["tree","selection-tree","tree-selection"].includes(this.type)&&s==="body"))return;const l=this.ctx.database.getRowForRowKey(i),{expand:c=!1,hasChildren:f=!1,expandLoading:d=!1,level:u=0}=l||{};this.rowExpand=c,this.rowHasChildren=f;const{TREE_INDENT:x=16,CHECKBOX_SIZE:g,TREE_ICON_SIZE:m}=this.ctx.config;if(r=u*x,d){const v=this.ctx.icons.get("loading");a="loading",o=v}else if(f){const v=this.ctx.icons.get("expand"),R=this.ctx.icons.get("shrink");o=c?R:v,a=c?"shrink":"expand"}let w=m,p=m,y=this.drawX;(this.align==="center"||this.align==="right")&&(y=this.drawX+(this.visibleWidth-w-2*e)/2,this.align="left");let C=y+r+e,b=this.drawY+(this.visibleHeight-p)/2,E=r+this.drawX+w-.5;const I=this.getImage("selection"),_=this.getImage("drag"),T=_?_.width:0;if(this.type==="selection-tree"&&I){const v=I.x,R=I.width;C=r+v+R,E=C+w-e/2}else this.type==="tree-selection"?(C+=T,E=C+g+w-e/2):(C+=T,E=C+w-e/2);this.drawTextX=E,this.drawTextWidth=this.drawX+this.visibleWidth-E,!(C+w+e>this.drawX+this.visibleWidth)&&(b+p+e>this.drawY+this.visibleHeight||this.setImage("tree",new tt(a,C,b,w,p,o)))}updateDragImage(){if(this.cellType==="body"&&this.column.dragRow){const{DRAG_ROW_ICON_SIZE:e,CELL_PADDING:i}=this.ctx.config,s=this.drawX+i/2,o=this.drawY+(this.visibleHeight-e)/2,r=new tt("drag",s,o,e,e,this.ctx.icons.get("drag"));this.rowspan===0&&r.setVisible(!1),this.setImage("drag",r)}}drawTreeLine(){const{TREE_LINE:e,TREE_INDENT:i=16,TREE_ICON_SIZE:s=16,TREE_LINE_COLOR:o="#e1e6eb"}=this.ctx.config;if(!e||this.cellType!=="body"||!["tree","selection-tree","tree-selection"].includes(this.type)||this.rowspan===0||this.colspan===0)return;const r=this.ctx.database.getRowForRowKey(this.rowKey)||{},a=r.level??0,l=this.getImage("tree");if(!l)return;const c=l.x,f=l.y,d=l.width,u=l.height,x=c+d/2,g=f+u/2;let m=c-a*i;const w=Array.isArray(r.parentRowKeys)?r.parentRowKeys:[];if(a>0){for(let E=0;E<a-1;E+=1){const I=w[E+1];if(!!(I?this.ctx.database.getRowForRowKey(I)||{}:{}).isLastChild)continue;const v=Math.round(c-(a-E)*i+s/2);this.ctx.paint.drawLine([v,this.drawY,v,this.drawY+this.visibleHeight],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}const p=Math.round(c-i+s/2),C=!!r.isLastChild?g:this.drawY+this.visibleHeight;this.ctx.paint.drawLine([p,this.drawY,p,C],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0});const b=Math.round(m+(a-1)*i+s/2);this.ctx.paint.drawLine([b,g,x,g],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}if(r.hasChildren&&r.expand){const p=f+u,y=this.drawY+this.visibleHeight;this.ctx.paint.drawLine([x,p,x,y],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}}updateContainer(){const{BODY_BG_COLOR:e,EDIT_BG_COLOR:i,BODY_CELL_STYLE_METHOD:s,FOOTER_CELL_STYLE_METHOD:o,READONLY_TEXT_COLOR:r,BODY_TEXT_COLOR:a,FOOTER_TEXT_COLOR:l,FOOTER_BG_COLOR:c,HIGHLIGHT_SELECTED_ROW:f,HIGHLIGHT_SELECTED_ROW_COLOR:d,HIGHLIGHT_HOVER_ROW:u,HIGHLIGHT_HOVER_ROW_COLOR:x,STRIPE:g,STRIPE_COLOR:m,FINDER_CELL_BG_COLOR:w}=this.ctx.config;if(this.cellType==="footer"){let S=c,O=l;if(typeof o=="function"){const N=o,{backgroundColor:A,color:k,font:H}=N({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};A&&(S=A),k&&(O=k),H&&(this.drawTextFont=H)}const{rowIndex:M,colIndex:L,type:D}=this.ctx.finderBar;M===this.rowIndex&&L===this.colIndex&&D==="footer"&&(S=w),this.drawCellSkyBgColor="transparent",this.drawCellBgColor=S,this.drawTextColor=O;return}let p="transparent";const y=this.ctx.hoverCell,C=this.ctx.currentCell;let b=this.rowIndex,E=this.rowIndex;if(this.rowspan!==1&&(u||f)){const S=this.getSpanInfo(),{yArr:O}=S;b=O[0],E=O[1]}u&&y&&!this.ctx.dragRowIng&&(y.rowKey===this.rowKey&&(p=x),y.rowIndex>=b&&y.rowIndex<=E&&(p=x)),f&&C&&!this.ctx.dragRowIng&&(C.rowKey===this.rowKey&&(p=d),C.rowIndex>=b&&C.rowIndex<=E&&(p=d)),this.drawCellSkyBgColor=p;let I=e,_=a;if(!this.ctx.database.getReadonly(this.rowKey,this.key)&&!["index","index-selection"].includes(this.type)&&(I=i,_=r),g&&(this.rowIndex%2?I=m:I=e),typeof s=="function"){const S=s,{backgroundColor:O,color:M,font:L}=S({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,isHasChanged:this.isHasChanged,value:this.getValue()})||{};O&&(I=O),M&&(_=M),L&&(this.drawTextFont=L)}const{rowIndex:T,colIndex:v,type:R}=this.ctx.finderBar;T===this.rowIndex&&v===this.colIndex&&R==="body"&&(I=w),this.drawCellBgColor=I,this.drawTextColor=_}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:o,cellType:r,type:a,rowIndex:l,rowKey:c}=this;if(s===0||o===0||r==="footer"||!["index-selection","selection","selection-tree","tree-selection"].includes(a))return;const f=this.ctx.database.getRowSelectable(c),{CHECKBOX_SIZE:d=0,CELL_PADDING:u}=this.ctx.config;let x=this.drawX+u;(this.align==="center"||this.align==="right")&&(x=this.drawX+(e-d)/2);let g=x,m=this.drawY+(i-d)/2;if(a!=="selection-tree"){if(a==="tree-selection"){const{TREE_INDENT:E=16,TREE_ICON_SIZE:I}=this.ctx.config,_=this.ctx.database.getRowForRowKey(c),{level:T=0}=_||{},v=T*E;g=x+I+v}}let w=this.ctx.icons.get("checkbox-uncheck"),p="checkbox-uncheck";if(a==="selection-tree"||a==="tree-selection"){const E=this.ctx.database.getTreeSelectionState(c);E.indeterminate&&f?(w=this.ctx.icons.get("checkbox-indeterminate"),p="checkbox-indeterminate"):E.checked&&f?(w=this.ctx.icons.get("checkbox-check"),p="checkbox-check"):!E.checked&&f?(w=this.ctx.icons.get("checkbox-uncheck"),p="checkbox-uncheck"):(w=this.ctx.icons.get("checkbox-disabled"),p="checkbox-disabled")}else{const E=this.ctx.database.getRowSelection(c);E&&f?(w=this.ctx.icons.get("checkbox-check"),p="checkbox-check"):E&&!f?(w=this.ctx.icons.get("checkbox-check-disabled"),p="checkbox-check-disabled"):!E&&f?(w=this.ctx.icons.get("checkbox-uncheck"),p="checkbox-uncheck"):(w=this.ctx.icons.get("checkbox-disabled"),p="checkbox-disabled")}const y=this.getImage("drag"),C=y?y.width:0;if(g+=C,g+d+u>this.drawX+this.visibleWidth||m+d+u>this.drawY+this.visibleHeight)return;const b=new tt(p,g,m,d,d,w);if(a==="index-selection"){b.setVisible(!1),(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===l||["checkbox-disabled","checkbox-check"].includes(p))&&b.setVisible(!0);let E=this.rowIndex,I=this.rowIndex;const _=this.ctx.hoverCell,T=this.getSpanInfo(),{yArr:v}=T;E=v[0],I=v[1],_&&_.rowIndex>=E&&_.rowIndex<=I&&b.setVisible(!0)}this.setImage("selection",b)}updateHoverIcon(){if(this.ctx.database.getReadonly(this.rowKey,this.key))return;const{BODY_CELL_HOVER_ICON_METHOD:i,CELL_HOVER_ICON_SIZE:s,CELL_PADDING:o,ENABLE_MERGE_CELL_LINK:r}=this.ctx.config;if(typeof i=="function"){const c=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});c!==void 0&&(this.hoverIconName=c)}const{hoverCell:a}=this.ctx;if(this.hoverIconName&&!this.ctx.editing&&!this.ctx.dragRowIng&&a){let l=0,c=0;if(a.rowKey===this.rowKey&&(l=this.drawX+this.width-s-o,c=this.drawY+(this.height-s)/2),this.rowspan!==1&&r){const u=this.getSpanInfo(),{yArr:x}=u,g=x[0],m=x[1];if(a.rowIndex>=g&&a.rowIndex<=m){const{width:w,height:p,offsetTop:y,offsetLeft:C}=u;l=this.drawX-C+w-s-o,c=this.drawY-y+(p-s)/2}}const f=this.ctx.icons.get(this.hoverIconName),d=new tt(this.hoverIconName,l,c,s,s,f);(this.rowspan===0||this.colspan===0)&&d.setVisible(!1),this.setImage("hover",d)}}getAutoHeight(){if(this.cellType!=="body"||!this.autoRowHeight||this.rowspan===0)return 0;if(this.render){const a=this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex);return this.rowspan>1?a<this.visibleHeight?0:Math.round(a-(this.visibleHeight-this.height)):Math.round(a)}if(!(this.displayText&&typeof this.displayText=="string"))return 0;const{BODY_FONT:e,CELL_PADDING:i,CELL_LINE_HEIGHT:s}=this.ctx.config,o=`${this.displayText}_${this.drawTextWidth}_${this.drawTextFont}`,r=this.ctx.paint.calculateTextHeight(this.displayText,this.drawTextWidth,{font:this.drawTextFont||e,padding:i,align:this.align,verticalAlign:this.verticalAlign,color:this.drawTextColor,autoRowHeight:this.autoRowHeight,lineHeight:s,maxLineClamp:this.maxLineClamp,cacheTextKey:o});return this.rowspan>1?r<this.visibleHeight?0:Math.round(r-(this.visibleHeight-this.height)):Math.round(r)}getSpanInfo(){return this.ctx.database.getSpanInfo(this)}getDisplayText(e=this.text){if(this.cellType==="footer")return this.renderFooter&&this.renderFooterType==="default"||e==null?"":`${e}`;{if(this.rowspan===0||this.colspan===0||this.render&&this.renderType==="default"&&!this.mixedRender)return"";const i=this.getImage("selection");return this.type==="index-selection"&&i&&i.visible||e==null?"":`${e}`}}getText(){if(this.cellType==="footer")return typeof this.formatterFooter=="function"?this.formatterFooter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.row[this.key]}):this.row[this.key];if(typeof this.formatter=="function")return this.formatter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});const{BODY_CELL_FORMATTER_METHOD:e}=this.ctx.config;return typeof e=="function"?e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()}):["index-selection","index"].includes(this.type)?`${this.rowIndex+1}`:(this.value=this.ctx.database.getItemValue(this.rowKey,this.key),this.value)}getFinderText(){const e=this.getDisplayText(this.getText()),i=this.cellType==="footer"?this.formatterFinderFooterValue:this.formatterFinderValue;if(typeof i!="function")return e;const s=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.cellType==="footer"?this.row[this.key]:this.getValue(),displayText:e});return s==null?e:`${s}`}getValue(){return this.ctx.database.getItemValue(this.rowKey,this.key)}setValue(e){this.ctx.setItemValueByEditor(this.rowKey,this.key,e)}getOverlayerViewsStyle(){let e=this.drawX-this.ctx.fixedLeftWidth,i=this.drawY-this.ctx.body.y;if(this.fixed==="left"?e=this.drawX:this.fixed==="right"&&(e=this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)),this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED&&(i=this.drawY-this.ctx.footer.y),this.autoRowHeight&&this.render&&this.verticalAlign==="middle"){const o=this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex);if(o<this.visibleHeight&&o>0){const r=(this.visibleHeight-o)/2;i=i+r}}this.autoRowHeight&&this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex)===0&&(e=-99999,i=-99999);let s={};return this.rowspan===0&&(s={display:"none"}),{position:"absolute",overflow:"hidden",left:`${Math.round(e-1)}px`,top:`${Math.round(i-1)}px`,width:`${this.visibleWidth}px`,height:this.autoRowHeight&&this.renderType==="default"?"auto":`${this.visibleHeight}px`,pointerEvents:"initial",userSelect:"none",...s}}drawContainer(){const{paint:e,config:i}=this.ctx,{BORDER:s}=i,{drawX:o,drawY:r}=this,l=xt(s)?i.BORDER_COLOR:void 0;e.drawRect(o,r,this.visibleWidth,this.visibleHeight,{borderColor:l,fillColor:this.drawCellBgColor}),e.drawRect(o,r,this.width,this.height,{fillColor:this.drawCellSkyBgColor})}drawHorizontalBorder(){const{config:e}=this.ctx,{BORDER:i}=e;if(!Ot(i)||this.cellType!=="footer"&&xt(i))return;const{drawX:s,drawY:o}=this,r=e.BORDER_COLOR;this.ctx.paint.drawLine([s,o+this.visibleHeight,s+this.visibleWidth,o+this.visibleHeight],{borderColor:r,fillColor:r,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawAutofillPiont(){if(this.cellType==="footer")return;const{SELECT_BORDER_COLOR:e,ENABLE_AUTOFILL:i,ENABLE_SELECTOR:s,AUTOFILL_POINT_BORDER_COLOR:o}=this.ctx.config;if(!s||!i||this.ctx.editing)return;const{xArr:r,yArr:a}=this.ctx.selector,l=r[1],c=a[1],{colIndex:f,rowIndex:d,drawX:u,drawY:x}=this;if(f===l&&d===c){const m=f===this.ctx.maxColIndex||d===this.ctx.maxRowIndex||f===this.ctx.lastCenterColIndex?6:4;this.ctx.paint.drawRect(u+this.width-m,x+this.height-m,6,6,{borderColor:o,fillColor:e})}}draw(){this.drawTreeLine(),this.drawText(),this.drawImage(),this.drawSelector(),this.drawAutofillPiont(),this.drawErrorTip()}getWidthByColIndexColSpan(e,i){if(i===0)return 0;let s=0;for(let o=e;o<e+i;o++){const r=this.ctx.header.leafCellHeaders[o];s+=r.width}return s}drawText(){const{CELL_PADDING:e,BODY_FONT:i,PLACEHOLDER_COLOR:s,CELL_LINE_HEIGHT:o}=this.ctx.config,{placeholder:r}=this.column;let a=this.displayText,l=this.drawTextColor;if(!this.ctx.database.getReadonly(this.rowKey,this.key)&&r&&["",null,void 0].includes(this.text)&&this.cellType==="body"&&!(this.rowspan===0||this.colspan===0)&&(a=r,l=s),["",null,void 0].includes(a))return!1;typeof a!="string"&&(a=`${a}`);const f=`${a}_${this.drawTextWidth}_${this.drawTextFont}`;return this.ellipsis=this.ctx.paint.drawText(a,this.drawTextX,this.drawTextY,this.drawTextWidth,this.drawTextHeight,{font:this.drawTextFont||i,padding:e,align:this.align,verticalAlign:this.verticalAlign,color:l,autoRowHeight:this.autoRowHeight,lineHeight:o,maxLineClamp:this.maxLineClamp,cacheTextKey:f,layoutCallback:d=>{this.ctx.emit("registerTextLayout",`${this.cellType}-${this.rowIndex}-${this.colIndex}`,d)}}),this.ellipsis}drawImage(){this.getImages().forEach((e,i)=>{if(e.visible&&e.source){if(i==="hover"){const{CELL_HOVER_ICON_BG_COLOR:s,CELL_HOVER_ICON_BORDER_COLOR:o}=this.ctx.config;e.drawWrapper(this.ctx,{borderColor:o,fillColor:s})}this.ctx.paint.drawImage(e.source,e.x,e.y,e.width,e.height)}})}drawSelector(){if(this.cellType==="footer")return;const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i,yArr:s,xArrCopy:o,yArrCopy:r}=this.ctx.selector;this.drawBorder({xArr:o,yArr:r,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:this.ctx.autofill.xArr,yArr:this.ctx.autofill.yArr,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:i,yArr:s,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1});const[a,l]=i,[c,f]=s;!(a===l&&c===f)&&this.colIndex>=a&&this.colIndex<=l&&this.rowIndex>=c&&this.rowIndex<=f&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_AREA_COLOR||"rgba(82,146,247,0.1)"}),this.operation&&this.rowIndex>=c&&this.rowIndex<=f&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.visibleWidth,this.visibleHeight,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||"transparent"})}drawErrorTip(){if(this.cellType==="footer"||!this.message||this.rowspan===0||this.colspan===0)return;const{ERROR_TIP_ICON_SIZE:e,ERROR_TIP_COLOR:i}=this.ctx.config,{width:s}=this,o=this.drawX,r=this.drawY,a=[o+s-e-.5,r,o+s-.5,r,o+s-.5,r+e];this.ctx.paint.drawLine(a,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,rowIndex:o,colIndex:r,height:a,width:l}=this;let c=i,f=s;const{xArr:d,yArr:u,lineDash:x=[],borderWidth:g=1,borderColor:m,fillColor:w}=e,p=d[0],y=d[1],C=u[0],b=u[1];if(r>=p&&r<=y&&o===C){const E=r===y?1:0,I=r===p?1:0;this.ctx.paint.drawLine([c+I,f+1,c+l-E,f+1],{borderColor:m,fillColor:w,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:x})}if(r===y&&o>=C&&o<=b){const E=o===C?1:0,I=o===b?1:0;this.ctx.paint.drawLine([c+l-1,f+E,c+l-1,f+a-I],{borderColor:m,fillColor:w,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:x})}if(r>=p&&r<=y&&o===b){const E=r===y?1:0,I=r===p?1:0;this.ctx.paint.drawLine([c+I,f+a-1,c+l-E,f+a-1],{borderColor:m,fillColor:w,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:x})}if(r===p&&o>=C&&o<=b){const E=o===b?1:0,I=o===C?1:0;this.ctx.paint.drawLine([c+1,f+I,c+1,f+a-E],{borderColor:m,fillColor:w,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:x})}}}class Ge{constructor(t,e){n(this,"ctx");n(this,"data");n(this,"columns");n(this,"footerData",[]);n(this,"rowKeyMap",new Map);n(this,"colIndexKeyMap",new Map);n(this,"headerMap",new Map);n(this,"rowIndexRowKeyMap",new Map);n(this,"rowKeyRowIndexMap",new Map);n(this,"checkboxKeyMap",new Map);n(this,"selectionMap",new Map);n(this,"expandMap",new Map);n(this,"originalDataMap",new Map);n(this,"changedDataMap",new Map);n(this,"validationErrorMap",new Map);n(this,"itemRowKeyMap",new WeakMap);n(this,"bufferData",[]);n(this,"customHeader",{fixedData:{},sortData:{},hideData:{},resizableData:{}});n(this,"overlayerAutoHeightMap",new Map);n(this,"maxRowHeightCellMap",new Map);n(this,"bufferCheckState",{buffer:!1,check:!1,indeterminate:!1,selectable:!0});n(this,"sumHeight",0);n(this,"filterMethod");n(this,"positions",[]);n(this,"sortState",new Map);this.ctx=t;const{data:i=[],columns:s=[],footerData:o=[]}=e;this.data=i,this.footerData=o,this.columns=s,this.init()}init(t=!0){this.ctx.paint.clearTextCache(),this.clearBufferData(),this.rowKeyMap.clear(),this.checkboxKeyMap.clear(),this.colIndexKeyMap.clear(),this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear(),this.maxRowHeightCellMap.clear();const e=this.getColumns(),i=rt(e);if(this.ctx.hasSelection=i.some(s=>s.type==="selection"),this.ctx.hasTree=i.some(s=>{var o;return(o=s.type)==null?void 0:o.includes("tree")}),t){this.originalDataMap.clear(),this.changedDataMap.clear(),this.validationErrorMap.clear();const{ROW_KEY:s}=this.ctx.config;s?(this.ctx.hasSelection||this.selectionMap.clear(),this.ctx.hasTree||this.expandMap.clear()):(this.selectionMap.clear(),this.expandMap.clear())}this.itemRowKeyMap=new WeakMap,this.initData(this.data),this.getData(),this.bufferCheckState.buffer=!1}clearBufferData(){this.bufferData=[]}resolveRowKey(t,e=""){let i;return typeof e=="function"?i=e(t):e&&(i=t[e]),i!=null?String(i):B()}initData(t,e=0,i=[]){const s=t.length,{ROW_KEY:o="",DEFAULT_EXPAND_ALL:r,CELL_HEIGHT:a,SELECTABLE_METHOD:l,CHECKBOX_KEY:c,TREE_CHILDREN_KEY:f}=this.ctx.config;t.forEach((d,u)=>{var y;f!=="children"&&(d.children=d[f]);const x=this.resolveRowKey(d,o);this.itemRowKeyMap.set(d,x);const g=d._height||a,m=d._readonly;let w=!0;if(typeof l=="function"&&(w=l),c){const C=d[c];if(this.checkboxKeyMap.has(C)){const b=this.checkboxKeyMap.get(C)||[];b.push(x),this.checkboxKeyMap.set(C,b)}else this.checkboxKeyMap.set(C,[x])}this.selectionMap.set(x,{key:c?d[c]:x,row:d,check:((y=this.selectionMap.get(x))==null?void 0:y.check)||!1});const p=r||this.expandMap.get(x)||d._expand||!1;this.expandMap.set(x,p),this.rowKeyMap.set(x,{readonly:m,index:u,rowIndex:u,level:e,height:g,calculatedHeight:-1,check:!1,selectable:w,expand:p,expandLazy:!1,hasChildren:d._hasChildren||(Array.isArray(d.children)?d.children.length>0:!1),expandLoading:!1,item:d,parentRowKeys:i,parentRowKey:i[i.length-1]||"",isLastChild:u===s-1}),Array.isArray(d.children)&&d.children.length&&this.initData(d.children,e+1,[...i,x])})}setRowHeight(t,e){const i=this.rowIndexRowKeyMap.get(t);if(i===void 0)return;const s=this.rowKeyMap.get(i);s.height=e,s.item._height=e,this.clearBufferData()}setBatchRowHeight(t){t.forEach(({rowIndex:e,height:i})=>{const s=this.rowIndexRowKeyMap.get(e);if(s){const o=this.rowKeyMap.get(s);o.height=i,o.item._height=i}}),this.clearBufferData()}setBatchCalculatedRowHeight(t){return t.every(({height:i,rowIndex:s})=>this.getPositionForRowIndex(s).calculatedHeight===i)?!1:(t.forEach(({rowIndex:i,height:s})=>{const o=this.rowIndexRowKeyMap.get(i);if(o){const r=this.rowKeyMap.get(o),{height:a=-1}=this.getMaxRowHeightItem(o)||{};r.calculatedHeight=Math.max(s,a)}}),this.clearBufferData(),this.getData(),!0)}getAllRowsData(){let t=[];const e=i=>{i.forEach(s=>{t.push(s),Array.isArray(s.children)&&e(s.children)})};return e(this.data),t}generateColumns(t){const e=i=>i.map(s=>{var c,f,d,u,x,g,m,w;const o=s.children&&Array.isArray(s.children)?e(s.children):void 0,r={hide:(f=(c=this.customHeader)==null?void 0:c.hideData)==null?void 0:f[s.key],fixed:(u=(d=this.customHeader)==null?void 0:d.fixedData)==null?void 0:u[s.key],sort:(g=(x=this.customHeader)==null?void 0:x.sortData)==null?void 0:g[s.key],width:(w=(m=this.customHeader)==null?void 0:m.resizableData)==null?void 0:w[s.key]},a={};for(const[p,y]of Object.entries(r))y!==void 0&&(a[p]=y);const l=o&&o.every(p=>p.hide);return{...s,children:o,hide:l||(typeof s.hide=="function"?s.hide(s):s.hide),...a}});return e(t)}getColumns(){return this.generateColumns(this.columns)}setColumns(t){this.columns=t,this.clearBufferData()}setData(t){this.data=t,this.init()}getOriginalData(){return this.data}getData(){if(this.bufferData.length>0)return{data:this.bufferData,sumHeight:this.sumHeight,positions:this.positions};let t=[],e=0;this.sumHeight=0,this.positions=[];const i=o=>{o==null||o.forEach(r=>{t.push(r);const a=this.itemRowKeyMap.get(r),{expand:l,hasChildren:c,height:f,calculatedHeight:d}=this.rowKeyMap.get(a),u=this.sumHeight,x=Math.max(d,f);this.sumHeight+=x,this.rowIndexRowKeyMap.set(e,a),this.rowKeyRowIndexMap.set(a,e),this.positions.push({top:u,height:x,bottom:this.sumHeight,calculatedHeight:d}),e+=1,l&&c&&i(r.children)})};this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();let s=this.data;if(typeof this.filterMethod=="function"&&(s=this.filterMethod(s)),this.sortState.size){const o=Array.from(this.sortState.entries()).sort((r,a)=>r[1].timestamp-a[1].timestamp);s=this.sortDataRecursive(s,o)}return i(s),this.bufferData=t,{data:t,sumHeight:this.sumHeight,positions:this.positions}}setFooterData(t){this.footerData=t}getFooterData(){return this.footerData}setFilterMethod(t){this.filterMethod=t}clearFilterMethod(){this.filterMethod=void 0}getSortState(t){return this.sortState.get(t)||{direction:"none",timestamp:0}}setSortState(t,e){const i=Date.now();this.ctx.config.SORT_STRICTLY&&this.sortState.clear(),e==="none"?this.sortState.delete(t):this.sortState.set(t,{direction:e,timestamp:i}),this.ctx.emit("sortChange",this.sortState),this.clearBufferData(),this.ctx.emit("draw")}clearSort(){this.sortState.clear(),this.ctx.emit("sortChange",this.sortState),this.clearBufferData(),this.ctx.emit("draw")}sortDataRecursive(t,e){let i=[...t];for(const[s,{direction:o}]of e){if(o==="none")continue;const r=this.getColumnByKey(s);!r||!r.column.sortBy||(i=this.applySingleColumnSort(i,s,o,r.column.sortBy))}return i.map(s=>(s.children&&Array.isArray(s.children)&&(s.children=this.sortDataRecursive(s.children,e)),s))}applySingleColumnSort(t,e,i,s){return t.sort((o,r)=>{const a=o[e],l=r[e];let c=0;if(typeof s=="function")c=s(o,r);else if(s==="number"){const f=Number(a)||0,d=Number(l)||0;c=f-d}else if(s==="string"){const f=String(a||""),d=String(l||"");c=f.localeCompare(d)}else s==="date"&&(c=Ne(a,l));return i==="asc"?c:-c})}expandItem(t,e=!1){const i=this.rowKeyMap.get(t);i.expand=e,this.expandMap.set(t,e),this.clearBufferData(),this.ctx.emit("draw")}setExpandRowKeys(t,e=!0){this.expandMap.clear(),t.forEach(i=>{const s=this.rowKeyMap.get(i);this.expandMap.set(i,e),s.expand=e}),this.clearBufferData(),this.ctx.emit("draw")}getExpandRowKeys(){let t=[];return this.rowKeyMap.forEach((e,i)=>{e.expand&&t.push(i)}),t}expandAll(t){this.expandMap.clear(),this.rowKeyMap.forEach((e,i)=>{e.expand=t,this.expandMap.set(i,t)}),this.clearBufferData(),this.ctx.emit("draw")}expandLoading(t,e=!1){const i=this.rowKeyMap.get(t);i.expandLoading=e,this.clearBufferData(),this.ctx.emit("draw")}setExpandChildren(t,e){const i=this.rowKeyMap.get(t);i.expand=!0,this.expandMap.set(t,!0),i.expandLazy=!0,i.item.children=e,this.initData(i.item.children,i.level+1),this.clearBufferData()}getIsExpandLoading(t){return this.rowKeyMap.get(t).expandLoading}getIsExpandLazy(t){return this.rowKeyMap.get(t).expandLazy}getIsExpand(t){return this.rowKeyMap.get(t).expand}getRowForRowKey(t){return this.rowKeyMap.get(t)}getRowForRowIndex(t){const e=this.getRowKeyForRowIndex(t);return this.rowKeyMap.get(e)}getRowKeyForRowIndex(t){return this.rowIndexRowKeyMap.get(t)||""}getRowKeyByItem(t){return this.itemRowKeyMap.get(t)}getRowIndexForRowKey(t){return this.rowKeyRowIndexMap.get(t)}getItemValueForRowIndexAndColIndex(t,e){if(!(this.rowIndexRowKeyMap.has(t)&&this.colIndexKeyMap.get(e)))return null;const s=this.rowIndexRowKeyMap.get(t),o=this.colIndexKeyMap.get(e);return s===void 0||o===void 0?null:{rowKey:s,key:o,value:this.getItemValue(s,o)}}getItemValue(t,e){const i=this.rowKeyMap.get(t);return i&&i.item?i.item[e]===void 0?null:i.item[e]:null}async batchSetItemValue(t,e=!1,i=!0,s="none"){var g;let o=[],r=i;const a=new Map,l=[];let c=[