@ninebone/table 0.0.291 → 0.0.292

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.
@@ -1,4 +1,4 @@
1
- (function(y,g){typeof exports=="object"&&typeof module<"u"?g(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],g):(y=typeof globalThis<"u"?globalThis:y||self,g(y.NineboneUtil))})(this,function(y){"use strict";var Xe=Object.defineProperty;var Ye=y=>{throw TypeError(y)};var Fe=(y,g,v)=>g in y?Xe(y,g,{enumerable:!0,configurable:!0,writable:!0,value:v}):y[g]=v;var a=(y,g)=>Xe(y,"name",{value:g,configurable:!0});var S=(y,g,v)=>Fe(y,typeof g!="symbol"?g+"":g,v),Ue=(y,g,v)=>g.has(y)||Ye("Cannot "+v);var e=(y,g,v)=>(Ue(y,g,"read from private field"),v?v.call(y):g.get(y)),c=(y,g,v)=>g.has(y)?Ye("Cannot add the same private member more than once"):g instanceof WeakSet?g.add(y):g.set(y,v),b=(y,g,v,H)=>(Ue(y,g,"write to private field"),H?H.call(y,v):g.set(y,v),v);var Ke=(y,g,v,H)=>({set _(G){b(y,g,G,v)},get _(){return e(y,g,H)}});var C,M,p,z,N,B,oe,P,le,ae,J,R,I,A,W,V,X,ce,he,Q,de,fe,ee,ue,ge,K,F,be,ye,pe,me,we,xe,ie,q,ve,se,Se,$,Y,T,w,k,Z,Ee,O,Re,ne,Ae,qe,j,U,Te;const We=class We extends y.trace.constructor{constructor(){super(),this.init("nine-table","green")}};a(We,"Trace");let g=We;const v=new g,$e=class $e extends HTMLElement{constructor(){super();c(this,C);c(this,M,!1);c(this,p);c(this,z);c(this,N);c(this,B);c(this,oe,a(()=>{if(!e(this,C))return;const t=e(this,C).querySelector(".ng-container-body");t&&(b(this,B,new ResizeObserver(()=>{this.refresh()})),e(this,B).observe(t))},"#observeResize"));S(this,"refresh",a(()=>{if(!e(this,C)||!e(this,p)||e(this,M))return;const t=e(this,p).container,s=t.querySelector("table");if(!s)return;const n=e(this,p).track,r=e(this,p).thumb,o=e(this,C).querySelector(".ng-container-bottom"),l=t.clientWidth,h=s.scrollWidth;if(l!==0&&h>l)o&&(o.style.display="flex");else{o&&(o.style.display="none");return}const d=n.clientWidth;if(d<=0)return;const u=Math.max(Math.min(d*(l/h),d),20);r.style.width=`${u}px`;const f=t.scrollLeft,m=h-l;let x=0;m>0&&(x=parseInt(f/m*(d-u),10)),x<0&&(x=0);const E=d-u;x>E&&(x=E),r.style.left=`${x}px`,v.log(x),e(this,p).left.disabled=x===0,e(this,p).right.disabled=x>=E-1},"refresh"));c(this,P,a(t=>{if(!e(this,p))return!1;const s=e(this,p).container,n=s.querySelector("table");if(!n)return!1;const r=e(this,p).track.getBoundingClientRect(),o=e(this,p).thumb.clientWidth;let l=t;l<0&&(l=0);const h=r.width-o;l>h&&(l=h),l=parseInt(l,10),e(this,p).thumb.style.left=`${l}px`,e(this,p).left.disabled=l===0,e(this,p).right.disabled=l>=h-1;const d=s.clientWidth,f=n.scrollWidth-d;return h>0&&f>0&&(s.scrollLeft=l/h*f),l>0&&l<h-1},"#thumbMoveTo"));c(this,le,a(()=>{const t=a(n=>{clearInterval(e(this,z)),clearInterval(e(this,N));const r=parseInt(e(this,p).thumb.style.left||0,10);e(this,P).call(this,r+n),b(this,z,setInterval(()=>{clearInterval(e(this,z)),b(this,N,setInterval(()=>{const o=parseInt(e(this,p).thumb.style.left||0,10);e(this,P).call(this,o+n)||clearInterval(e(this,N))},50))},500))},"delayScroll"),s=a(()=>{clearInterval(e(this,z)),clearInterval(e(this,N))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(n=>{e(this,p).left.addEventListener(n,s),e(this,p).right.addEventListener(n,s),e(this,p).track.addEventListener(n,s)}),e(this,p).left.addEventListener("mousedown",n=>{n.button===0&&t(-20)}),e(this,p).right.addEventListener("mousedown",n=>{n.button===0&&t(20)}),e(this,p).left.addEventListener("touchstart",()=>t(-20)),e(this,p).right.addEventListener("touchstart",()=>t(20)),e(this,p).track.addEventListener("mousedown",n=>{if(n.button!==0)return;n.preventDefault();const r=e(this,p).track.getBoundingClientRect(),o=e(this,p).thumb.clientWidth;e(this,P).call(this,n.clientX-r.left-o/2)}),e(this,p).thumb.addEventListener("mousedown",n=>{if(n.button!==0)return;n.stopPropagation(),n.preventDefault(),b(this,M,!0),this.shiftX=n.clientX-e(this,p).thumb.getBoundingClientRect().left;const r=a(l=>{if(!e(this,M))return;const h=e(this,p).track.getBoundingClientRect();e(this,P).call(this,l.clientX-h.left-this.shiftX)},"onMouseMove"),o=a(()=>{b(this,M,!1),s(),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",o),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",o)})},"#init"))}connectedCallback(){if(b(this,C,this.closest("nine-table-sheet")||this.getRootNode().host),!e(this,C))return;this.innerHTML=`
1
+ (function(y,p){typeof exports=="object"&&typeof module<"u"?p(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],p):(y=typeof globalThis<"u"?globalThis:y||self,p(y.NineboneUtil))})(this,function(y){"use strict";var Jt=Object.defineProperty;var Qt=y=>{throw TypeError(y)};var ie=(y,p,w)=>p in y?Jt(y,p,{enumerable:!0,configurable:!0,writable:!0,value:w}):y[p]=w;var c=(y,p)=>Jt(y,"name",{value:p,configurable:!0});var R=(y,p,w)=>ie(y,typeof p!="symbol"?p+"":p,w),te=(y,p,w)=>p.has(y)||Qt("Cannot "+w);var t=(y,p,w)=>(te(y,p,"read from private field"),w?w.call(y):p.get(y)),h=(y,p,w)=>p.has(y)?Qt("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(y):p.set(y,w),g=(y,p,w,$)=>(te(y,p,"write to private field"),$?$.call(y,w):p.set(y,w),w);var ee=(y,p,w,$)=>({set _(tt){g(y,p,tt,w)},get _(){return t(y,p,$)}});var C,W,m,B,N,Y,dt,V,ft,X,O,E,et,it,ut,bt,st,T,I,A,z,U,K,gt,pt,nt,yt,mt,rt,xt,vt,Z,G,wt,St,Et,Rt,Tt,At,lt,k,kt,ct,qt,D,j,q,v,L,J,Lt,P,Ht,at,Ct,_t,Q,F,Mt;const Nt=class Nt extends y.trace.constructor{constructor(){super(),this.init("nine-table","green")}};c(Nt,"Trace");let p=Nt;const w=new p,Yt=class Yt extends HTMLElement{constructor(){super();h(this,C);h(this,W,!1);h(this,m);h(this,B);h(this,N);h(this,Y);h(this,dt,c(()=>{if(!t(this,C))return;const e=t(this,C).querySelector(".ng-container-body");e&&(g(this,Y,new ResizeObserver(()=>{this.refresh()})),t(this,Y).observe(e))},"#observeResize"));R(this,"refresh",c(()=>{if(!t(this,C)||!t(this,m)||t(this,W))return;const e=t(this,m).container,i=e.querySelector("table");if(!i)return;const n=t(this,m).track,r=t(this,m).thumb,o=t(this,C).querySelector(".ng-container-bottom"),l=e.clientWidth,a=i.scrollWidth;if(l!==0&&a>l)o&&(o.style.display="flex");else{o&&(o.style.display="none");return}const d=n.clientWidth;if(d<=0)return;const u=Math.max(Math.min(d*(l/a),d),20);r.style.width=`${u}px`;const f=e.scrollLeft,b=a-l;let x=0;b>0&&(x=parseInt(f/b*(d-u),10)),x<0&&(x=0);const S=d-u;x>S&&(x=S),r.style.left=`${x}px`,w.log(x),t(this,m).left.disabled=x===0,t(this,m).right.disabled=x>=S-1},"refresh"));h(this,V,c(e=>{if(!t(this,m))return!1;const i=t(this,m).container,n=i.querySelector("table");if(!n)return!1;const r=t(this,m).track.getBoundingClientRect(),o=t(this,m).thumb.clientWidth;let l=e;l<0&&(l=0);const a=r.width-o;l>a&&(l=a),l=parseInt(l,10),t(this,m).thumb.style.left=`${l}px`,t(this,m).left.disabled=l===0,t(this,m).right.disabled=l>=a-1;const d=i.clientWidth,f=n.scrollWidth-d;return a>0&&f>0&&(i.scrollLeft=l/a*f),l>0&&l<a-1},"#thumbMoveTo"));h(this,ft,c(()=>{const e=c(n=>{clearInterval(t(this,B)),clearInterval(t(this,N));const r=parseInt(t(this,m).thumb.style.left||0,10);t(this,V).call(this,r+n),g(this,B,setInterval(()=>{clearInterval(t(this,B)),g(this,N,setInterval(()=>{const o=parseInt(t(this,m).thumb.style.left||0,10);t(this,V).call(this,o+n)||clearInterval(t(this,N))},50))},500))},"delayScroll"),i=c(()=>{clearInterval(t(this,B)),clearInterval(t(this,N))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(n=>{t(this,m).left.addEventListener(n,i),t(this,m).right.addEventListener(n,i),t(this,m).track.addEventListener(n,i)}),t(this,m).left.addEventListener("mousedown",n=>{n.button===0&&e(-20)}),t(this,m).right.addEventListener("mousedown",n=>{n.button===0&&e(20)}),t(this,m).left.addEventListener("touchstart",()=>e(-20)),t(this,m).right.addEventListener("touchstart",()=>e(20)),t(this,m).track.addEventListener("mousedown",n=>{if(n.button!==0)return;n.preventDefault();const r=t(this,m).track.getBoundingClientRect(),o=t(this,m).thumb.clientWidth;t(this,V).call(this,n.clientX-r.left-o/2)}),t(this,m).thumb.addEventListener("mousedown",n=>{if(n.button!==0)return;n.stopPropagation(),n.preventDefault(),g(this,W,!0),this.shiftX=n.clientX-t(this,m).thumb.getBoundingClientRect().left;const r=c(l=>{if(!t(this,W))return;const a=t(this,m).track.getBoundingClientRect();t(this,V).call(this,l.clientX-a.left-this.shiftX)},"onMouseMove"),o=c(()=>{g(this,W,!1),i(),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",o),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",o)})},"#init"))}connectedCallback(){if(g(this,C,this.closest("nine-table-sheet")||this.getRootNode().host),!t(this,C))return;this.innerHTML=`
2
2
  <style>
3
3
  nine-table-hscrollbar {
4
4
  display: flex;
@@ -60,7 +60,69 @@
60
60
  <button class='ng-scroll-left' disabled><div class='ng-scroll-icon'></div></button>
61
61
  <div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
62
62
  <button class='ng-scroll-right' disabled><div class='ng-scroll-icon'></div></button>
63
- `;const t=a(()=>{const s=e(this,C).querySelector(".ng-container-body");if(!s){setTimeout(t,10);return}b(this,p,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),s.addEventListener("scroll",()=>{e(this,M)||this.refresh()}),e(this,le).call(this),e(this,oe).call(this),this.refresh()},"initWhenReady");t()}disconnectedCallback(){e(this,B)&&e(this,B).disconnect()}};C=new WeakMap,M=new WeakMap,p=new WeakMap,z=new WeakMap,N=new WeakMap,B=new WeakMap,oe=new WeakMap,P=new WeakMap,le=new WeakMap,a($e,"NineTableHScrollBar");let H=$e;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",H);const _=class _{static compileAll(i){return Array.isArray(i)?i.map(t=>_.compile(t)):[]}static compile(i){var n,r,o;if(!i)return null;const t=i.cloneNode(!0);return e(n=_,ae).call(n,t),e(r=_,J).call(r,t,"thead"),e(o=_,J).call(o,t,"tbody"),Array.from(t.querySelectorAll("colgroup col")).forEach((l,h)=>{const d=l.getAttribute("fixed");d&&t.querySelectorAll(`[data-col="${h}"]`).forEach(u=>{u.setAttribute("fixed",d)})}),t}};ae=new WeakMap,J=new WeakMap,a(_,"TableCompiler"),c(_,ae,a(i=>{if(!i.querySelector("colgroup")){const t=i.querySelector("tbody tr")||i.querySelector("tr"),s=t?t.querySelectorAll("th, td").length:1,n=document.createElement("colgroup"),r=Math.max(Math.floor(i.clientWidth/s),100);for(let o=0;o<s;o++){const l=document.createElement("col");l.setAttribute("width",r),n.appendChild(l)}i.prepend(n)}if(!i.querySelector("thead")){const t=document.createElement("thead"),s=i.querySelector("colgroup");s?s.after(t):i.prepend(t)}i.classList.add("nine-table-element"),i.style.display="table"},"#ensureTableStructure")),c(_,J,a((i,t)=>{const s=Array.from(i.querySelectorAll(t+" tr")),n=Array.from(i.querySelectorAll(t+" th,"+t+" td")),r=s.length;if(r===0||n.length===0)return;let o=0;n.forEach(h=>{o+=h.colSpan||1});const l=Array.from(Array(r),()=>Array(o).fill(null));s.forEach(h=>{const d=h.sectionRowIndex;let u=0;Array.from(h.querySelectorAll("th,td")).forEach(f=>{for(let E=0;E<l[d].length;E++)if(l[d][E]===null){u=E;break}const m=f.rowSpan||1,x=f.colSpan||1;for(let E=0;E<m;E++)for(let D=0;D<x;D++)d+E<r&&u+D<o&&(l[d+E][u+D]=E===0&&D===0?"1":"0")})}),s.forEach(h=>{const d=h.sectionRowIndex;Array.from(h.querySelectorAll("th,td")).forEach(u=>{for(let f=0;f<l[d].length;f++)if(l[d][f]==="1"){u.dataset.col=f,l[d][f]="0";break}})})},"#resetColIndex"));let G=_;const Oe=class Oe{constructor(i){c(this,R);c(this,I,new Map);c(this,A,null);c(this,W,null);c(this,V,0);c(this,X,40);S(this,"initialize",a(()=>{b(this,A,null),e(this,I).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(t=>{const s=e(this,R).querySelector(t);if(!s)return;const n=s.querySelector("table");if(!n)return;const r=n.querySelector("tbody");if(!r)return;const l=Array.from(r.querySelectorAll("tr")).map(h=>h.cloneNode(!0));e(this,I).set(t,l)});const i=e(this,R).querySelector(".ng-container-body");if(i){e(this,he).call(this,i),e(this,ee).call(this);let t=i.scrollTop;i.addEventListener("scroll",()=>{var n;const s=i.scrollTop;v.log(t,s),t!==s&&(t=s,e(this,ue).call(this,s)),(n=e(this,R).querySelector("nine-table-vscrollbar"))==null||n.refresh()})}},"initialize"));c(this,ce,a((i,t)=>{const s=e(this,I).get(t);if(!s||s.length===0)return;const n=i.querySelector("tbody");if(!n)return;n.querySelectorAll("tr:not(.nodata)").forEach(l=>l.remove());const r=n.querySelector("tr.nodata"),o=document.createDocumentFragment();for(let l=0;l<e(this,X);l++)s.forEach(h=>{o.appendChild(h.cloneNode(!0))});r?r.before(o):n.appendChild(o)},"#renderRows"));c(this,he,a(i=>{if(e(this,A)!==null&&e(this,A)>0)return e(this,A);const t=e(this,I).get(".ng-container-body");if(!t||t.length===0)return 24;const s=i.querySelector("tbody");if(!s)return 24;s.querySelectorAll("tr:not(.nodata)").forEach(m=>m.remove());const n=s.querySelector("tr.nodata"),r=document.createDocumentFragment();t.forEach(m=>{r.appendChild(m.cloneNode(!0))}),n?n.before(r):s.appendChild(r);const o=e(this,R),l=o.style.display,h=o.style.visibility,d=o.style.position;(l==="none"||window.getComputedStyle(o).display==="none")&&(o.style.display="block",o.style.visibility="hidden",o.style.position="absolute");let u=0;const f=s.querySelectorAll("tr:not(.nodata)");return f.forEach(m=>{u+=m.offsetHeight||m.getBoundingClientRect().height}),f.forEach(m=>m.remove()),o.style.display=l,o.style.visibility=h,o.style.position=d,b(this,A,u>0?u:24),e(this,Q).call(this),v.log(`[RowManager] Height Cached: ${e(this,A)}px | RowCount: ${e(this,X)}`),e(this,A)},"#measureAndCacheHeight"));c(this,Q,a(()=>{if(e(this,V)>0&&e(this,A)>0){const i=Math.ceil(e(this,V)/e(this,A));b(this,X,i+20)}else b(this,X,40)},"#updateRowCount"));c(this,de,a(()=>{var h,d,u;const i=e(this,R).querySelector(".ng-container-left table"),t=e(this,R).querySelector(".ng-container-body table"),s=e(this,R).querySelector(".ng-container-right table");if(!t)return;const n=i?Array.from(i.querySelectorAll("tr")):[],r=Array.from(t.querySelectorAll("tr")),o=s?Array.from(s.querySelectorAll("tr")):[],l=Math.max(n.length,r.length,o.length);for(let f=0;f<l;f++){const m=[((h=n[f])==null?void 0:h.getBoundingClientRect().height)||0,((d=r[f])==null?void 0:d.getBoundingClientRect().height)||0,((u=o[f])==null?void 0:u.getBoundingClientRect().height)||0],x=Math.max(...m);x>0&&(n[f]&&(n[f].style.height=`${x}px`),r[f]&&(r[f].style.height=`${x}px`),o[f]&&(o[f].style.height=`${x}px`))}},"#syncRowHeights"));c(this,fe,a(()=>{!e(this,R)||!(e(this,R)instanceof HTMLElement)||(b(this,W,new ResizeObserver(i=>{for(const t of i){const s=t.target;if(!s.classList.contains("active"))continue;const n=t.contentRect.height;if(n>0){let r=0;const o=s.querySelector("thead");o&&(r+=o.offsetHeight||o.getBoundingClientRect().height);const l=Math.max(n-r,100);e(this,V)!==l&&(b(this,V,l),e(this,Q).call(this),e(this,A)!==null&&e(this,ee).call(this))}}})),e(this,W).observe(e(this,R)))},"#initResizeObserver"));c(this,ee,a(()=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(i=>{const t=e(this,R).querySelector(i);t&&t.querySelector("tbody")&&e(this,ce).call(this,t,i)}),e(this,de).call(this)},"#renderAllContainers"));c(this,ue,a(i=>{var o;const t=e(this,A);if(!t||t<=0)return;const s=((o=e(this,I).get(".ng-container-body"))==null?void 0:o.length)||1,n=Math.floor(i/t),r=Math.max(0,n);[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(l=>{const h=e(this,R).querySelector(l);if(!h)return;const d=h.querySelector("tbody");if(!d)return;Array.from(d.querySelectorAll("tr:not(.nodata)")).forEach((f,m)=>{const x=r+Math.floor(m/s),E=e(this,R).getData?e(this,R).getData(x):null;E?(f.style.display="",e(this,ge).call(this,f,E,x)):f.style.display="none"})})},"#handleScroll"));c(this,ge,a((i,t,s)=>{i.dataset.row=s,Array.from(i.cells).forEach(n=>{const r=n.dataset.bind;r&&t[r]!==void 0&&(n.textContent=t[r]),n.dataset.row=s})},"#bindRowData"));S(this,"destroy",a(()=>{e(this,W)&&(e(this,W).disconnect(),b(this,W,null))},"destroy"));b(this,R,i),e(this,fe).call(this)}getRowHeight(){return e(this,A)}templateLength(i=".ng-container-body"){var t;return((t=e(this,I).get(i))==null?void 0:t.length)||1}};R=new WeakMap,I=new WeakMap,A=new WeakMap,W=new WeakMap,V=new WeakMap,X=new WeakMap,ce=new WeakMap,he=new WeakMap,Q=new WeakMap,de=new WeakMap,fe=new WeakMap,ee=new WeakMap,ue=new WeakMap,ge=new WeakMap,a(Oe,"RowManager");let ke=Oe;const te=class te extends HTMLElement{constructor(){super();c(this,K,null);c(this,F);c(this,be,a(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:s,type:n})=>{const r=this.querySelector(s);if(!r)return;const o=e(this,pe).call(this,e(this,K),n);r.innerHTML="",r.appendChild(o)})},"#renderSplitContainers"));c(this,ye,a(()=>{["left","right"].forEach(t=>{const s=this.querySelector(`.ng-container-${t}`),n=s==null?void 0:s.querySelector("table");if(!s||!n)return;let r=0;n.querySelectorAll("col").forEach(o=>{const l=parseInt(o.getAttribute("width"),10);isNaN(r)||(r+=l)}),s.style.flex=`0 0 ${r}px`,s.style.width=`${r}px`})},"#updateContainerWidths"));S(this,"generate",a(t=>{t&&(b(this,K,G.compile(t)),e(this,K).style.display="table",e(this,be).call(this),e(this,F).initialize(),e(this,ye).call(this),setTimeout(()=>{var s;(s=this.querySelector("nine-table-hscrollbar"))==null||s.refresh()},0))},"generate"));c(this,pe,a((t,s)=>{const n=t.cloneNode(!0);return s==="left"?n.querySelectorAll("col, th, td").forEach(r=>{r.getAttribute("fixed")!=="left"&&r.remove()}):s==="right"?n.querySelectorAll("col, th, td").forEach(r=>{r.getAttribute("fixed")!=="right"&&r.remove()}):n.querySelectorAll("[fixed=left], [fixed=right]").forEach(r=>{r.remove()}),n},"#createSplitTable"));S(this,"getRowHeight",a(()=>e(this,F).getRowHeight(),"getRowHeight"));S(this,"scrollToX",a(t=>{const s=this.querySelector(".ng-container-body");s&&(s.scrollLeft=t)},"scrollToX"));S(this,"scrollToY",a(t=>{const s=this.querySelector(".ng-container-body");s&&(s.scrollTop=t)},"scrollToY"));c(this,me,a(()=>{e(this,we).call(this)},"#init"));c(this,we,a(()=>{const t=te.SCROLLBAR_SIZE;this.innerHTML=`
63
+ `;const e=c(()=>{const i=t(this,C).querySelector(".ng-container-body");if(!i){setTimeout(e,10);return}g(this,m,{container:i,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),i.addEventListener("scroll",()=>{t(this,W)||this.refresh()}),t(this,ft).call(this),t(this,dt).call(this),this.refresh()},"initWhenReady");e()}disconnectedCallback(){t(this,Y)&&t(this,Y).disconnect()}};C=new WeakMap,W=new WeakMap,m=new WeakMap,B=new WeakMap,N=new WeakMap,Y=new WeakMap,dt=new WeakMap,V=new WeakMap,ft=new WeakMap,c(Yt,"NineTableHScrollBar");let $=Yt;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",$);const Vt=class Vt extends HTMLElement{constructor(){super();h(this,X);h(this,O,!1);h(this,E);h(this,et,0);h(this,it,0);R(this,"refresh",c(()=>{if(!t(this,X)||!t(this,E)||t(this,O))return;const e=t(this,E).container,i=e.querySelector("table");if(!i)return;const n=t(this,E).track,r=t(this,E).thumb,o=e.clientHeight,l=i.scrollHeight;if(l<=o){r.style.display="none",t(this,E).top.disabled=!0,t(this,E).bottom.disabled=!0;return}else r.style.display="block";const a=n.clientHeight;if(a<=0)return;const d=Math.max(Math.min(a*(o/l),a),20);r.style.height=`${d}px`;const u=e.scrollTop,f=l-o;let b=0;f>0&&(b=u/f*(a-d));const x=a-d;b<0&&(b=0),b>x&&(b=x),r.style.top=`${b}px`,t(this,E).top.disabled=u<=0,t(this,E).bottom.disabled=u>=f-1},"refresh"));h(this,ut,c(()=>{const e=t(this,E).container;e.addEventListener("scroll",()=>{t(this,O)||this.refresh()}),t(this,E).thumb.addEventListener("mousedown",i=>{if(i.button!==0)return;i.stopPropagation(),i.preventDefault(),g(this,O,!0),g(this,et,i.clientY),g(this,it,e.scrollTop);const n=c(o=>{if(!t(this,O))return;const l=t(this,E).track.getBoundingClientRect(),a=t(this,E).thumb.clientHeight,u=l.height-a,f=o.clientY-t(this,et),b=e.clientHeight,S=table.scrollHeight-b;if(u>0&&S>0){const _=f/u*S;e.scrollTop=t(this,it)+_}this.refresh()},"onMouseMove"),r=c(()=>{g(this,O,!1),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",r),this.refresh()},"onMouseUp");document.addEventListener("mousemove",n),document.addEventListener("mouseup",r)}),t(this,E).track.addEventListener("mousedown",i=>{if(i.button!==0||i.target===t(this,E).thumb)return;const n=t(this,E).track.getBoundingClientRect(),r=t(this,E).thumb.clientHeight,o=i.clientY-n.top-r/2,a=n.height-r,d=e.clientHeight,f=e.querySelector("table").scrollHeight-d;if(a>0&&f>0){const b=Math.max(0,Math.min(1,o/a));e.scrollTop=b*f}this.refresh()}),t(this,E).top.addEventListener("click",()=>{e.scrollTop-=40}),t(this,E).bottom.addEventListener("click",()=>{e.scrollTop+=40})},"#init"))}connectedCallback(){if(g(this,X,this.closest("nine-table-sheet")||this.getRootNode().host),!t(this,X))return;this.innerHTML=`
64
+ <style>
65
+ nine-table-vscrollbar {
66
+ display: flex;
67
+ flex-direction: column;
68
+ width: 16px;
69
+ height: 100%;
70
+ background: #f9fafb;
71
+ box-sizing: border-box;
72
+ user-select: none;
73
+ position: relative;
74
+ }
75
+ nine-table-vscrollbar button {
76
+ height: 16px;
77
+ width: 100%;
78
+ background: #f3f4f6;
79
+ border: none;
80
+ cursor: pointer;
81
+ display: flex;
82
+ align-items: center;
83
+ justify-content: center;
84
+ padding: 0;
85
+ flex-shrink: 0;
86
+ z-index: 2;
87
+ }
88
+ nine-table-vscrollbar button:disabled {
89
+ opacity: 0.4;
90
+ cursor: default;
91
+ }
92
+ nine-table-vscrollbar .ng-scroll-icon {
93
+ width: 6px;
94
+ height: 6px;
95
+ border-top: 2px solid #6b7280;
96
+ border-right: 2px solid #6b7280;
97
+ }
98
+ nine-table-vscrollbar .ng-scroll-top .ng-scroll-icon { transform: rotate(-45deg); margin-top: 2px; }
99
+ nine-table-vscrollbar .ng-scroll-bottom .ng-scroll-icon { transform: rotate(135deg); margin-bottom: 2px; }
100
+ nine-table-vscrollbar .ng-scroll-track {
101
+ flex: 1;
102
+ width: 100%;
103
+ position: relative;
104
+ background: #f3f4f6;
105
+ overflow: hidden;
106
+ }
107
+ nine-table-vscrollbar .ng-scroll-thumb {
108
+ position: absolute;
109
+ left: 2px;
110
+ right: 2px;
111
+ top: 0px;
112
+ height: 30px;
113
+ background: #9ca3af;
114
+ border-radius: 4px;
115
+ cursor: pointer;
116
+ z-index: 1;
117
+ }
118
+ nine-table-vscrollbar .ng-scroll-thumb:hover {
119
+ background: #6b7280;
120
+ }
121
+ </style>
122
+ <button class='ng-scroll-top' disabled><div class='ng-scroll-icon'></div></button>
123
+ <div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
124
+ <button class='ng-scroll-bottom' disabled><div class='ng-scroll-icon'></div></button>
125
+ `;const e=c(()=>{const i=t(this,X).querySelector(".ng-container-body");if(!i){setTimeout(e,10);return}g(this,E,{container:i,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),top:this.querySelector(".ng-scroll-top"),bottom:this.querySelector(".ng-scroll-bottom")}),t(this,ut).call(this),this.refresh()},"initWhenReady");e()}};X=new WeakMap,O=new WeakMap,E=new WeakMap,et=new WeakMap,it=new WeakMap,ut=new WeakMap,c(Vt,"NineTableVScrollBar");let tt=Vt;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",tt);const M=class M{static compileAll(s){return Array.isArray(s)?s.map(e=>M.compile(e)):[]}static compile(s){var n,r,o;if(!s)return null;const e=s.cloneNode(!0);return t(n=M,bt).call(n,e),t(r=M,st).call(r,e,"thead"),t(o=M,st).call(o,e,"tbody"),Array.from(e.querySelectorAll("colgroup col")).forEach((l,a)=>{const d=l.getAttribute("fixed");d&&e.querySelectorAll(`[data-col="${a}"]`).forEach(u=>{u.setAttribute("fixed",d)})}),e}};bt=new WeakMap,st=new WeakMap,c(M,"TableCompiler"),h(M,bt,c(s=>{if(!s.querySelector("colgroup")){const e=s.querySelector("tbody tr")||s.querySelector("tr"),i=e?e.querySelectorAll("th, td").length:1,n=document.createElement("colgroup"),r=Math.max(Math.floor(s.clientWidth/i),100);for(let o=0;o<i;o++){const l=document.createElement("col");l.setAttribute("width",r),n.appendChild(l)}s.prepend(n)}if(!s.querySelector("thead")){const e=document.createElement("thead"),i=s.querySelector("colgroup");i?i.after(e):s.prepend(e)}s.classList.add("nine-table-element"),s.style.display="table"},"#ensureTableStructure")),h(M,st,c((s,e)=>{const i=Array.from(s.querySelectorAll(e+" tr")),n=Array.from(s.querySelectorAll(e+" th,"+e+" td")),r=i.length;if(r===0||n.length===0)return;let o=0;n.forEach(a=>{o+=a.colSpan||1});const l=Array.from(Array(r),()=>Array(o).fill(null));i.forEach(a=>{const d=a.sectionRowIndex;let u=0;Array.from(a.querySelectorAll("th,td")).forEach(f=>{for(let S=0;S<l[d].length;S++)if(l[d][S]===null){u=S;break}const b=f.rowSpan||1,x=f.colSpan||1;for(let S=0;S<b;S++)for(let _=0;_<x;_++)d+S<r&&u+_<o&&(l[d+S][u+_]=S===0&&_===0?"1":"0")})}),i.forEach(a=>{const d=a.sectionRowIndex;Array.from(a.querySelectorAll("th,td")).forEach(u=>{for(let f=0;f<l[d].length;f++)if(l[d][f]==="1"){u.dataset.col=f,l[d][f]="0";break}})})},"#resetColIndex"));let It=M;const Xt=class Xt{constructor(s){h(this,T);h(this,I,new Map);h(this,A,null);h(this,z,null);h(this,U,0);h(this,K,40);R(this,"initialize",c(()=>{g(this,A,null),t(this,I).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(e=>{const i=t(this,T).querySelector(e);if(!i)return;const n=i.querySelector("table");if(!n)return;const r=n.querySelector("tbody");if(!r)return;const l=Array.from(r.querySelectorAll("tr")).map(a=>a.cloneNode(!0));t(this,I).set(e,l)});const s=t(this,T).querySelector(".ng-container-body");if(s){t(this,pt).call(this,s),t(this,rt).call(this);let e=s.scrollTop;s.addEventListener("scroll",()=>{var n;const i=s.scrollTop;w.log(e,i),e!==i&&(e=i,t(this,xt).call(this,i)),(n=t(this,T).querySelector("nine-table-vscrollbar"))==null||n.refresh()})}},"initialize"));h(this,gt,c((s,e)=>{const i=t(this,I).get(e);if(!i||i.length===0)return;const n=s.querySelector("tbody");if(!n)return;n.querySelectorAll("tr:not(.nodata)").forEach(l=>l.remove());const r=n.querySelector("tr.nodata"),o=document.createDocumentFragment();for(let l=0;l<t(this,K);l++)i.forEach(a=>{o.appendChild(a.cloneNode(!0))});r?r.before(o):n.appendChild(o)},"#renderRows"));h(this,pt,c(s=>{if(t(this,A)!==null&&t(this,A)>0)return t(this,A);const e=t(this,I).get(".ng-container-body");if(!e||e.length===0)return 24;const i=s.querySelector("tbody");if(!i)return 24;i.querySelectorAll("tr:not(.nodata)").forEach(b=>b.remove());const n=i.querySelector("tr.nodata"),r=document.createDocumentFragment();e.forEach(b=>{r.appendChild(b.cloneNode(!0))}),n?n.before(r):i.appendChild(r);const o=t(this,T),l=o.style.display,a=o.style.visibility,d=o.style.position;(l==="none"||window.getComputedStyle(o).display==="none")&&(o.style.display="block",o.style.visibility="hidden",o.style.position="absolute");let u=0;const f=i.querySelectorAll("tr:not(.nodata)");return f.forEach(b=>{u+=b.offsetHeight||b.getBoundingClientRect().height}),f.forEach(b=>b.remove()),o.style.display=l,o.style.visibility=a,o.style.position=d,g(this,A,u>0?u:24),t(this,nt).call(this),w.log(`[RowManager] Height Cached: ${t(this,A)}px | RowCount: ${t(this,K)}`),t(this,A)},"#measureAndCacheHeight"));h(this,nt,c(()=>{if(t(this,U)>0&&t(this,A)>0){const s=Math.ceil(t(this,U)/t(this,A));g(this,K,s+20)}else g(this,K,40)},"#updateRowCount"));h(this,yt,c(()=>{var a,d,u;const s=t(this,T).querySelector(".ng-container-left table"),e=t(this,T).querySelector(".ng-container-body table"),i=t(this,T).querySelector(".ng-container-right table");if(!e)return;const n=s?Array.from(s.querySelectorAll("tr")):[],r=Array.from(e.querySelectorAll("tr")),o=i?Array.from(i.querySelectorAll("tr")):[],l=Math.max(n.length,r.length,o.length);for(let f=0;f<l;f++){const b=[((a=n[f])==null?void 0:a.getBoundingClientRect().height)||0,((d=r[f])==null?void 0:d.getBoundingClientRect().height)||0,((u=o[f])==null?void 0:u.getBoundingClientRect().height)||0],x=Math.max(...b);x>0&&(n[f]&&(n[f].style.height=`${x}px`),r[f]&&(r[f].style.height=`${x}px`),o[f]&&(o[f].style.height=`${x}px`))}},"#syncRowHeights"));h(this,mt,c(()=>{!t(this,T)||!(t(this,T)instanceof HTMLElement)||(g(this,z,new ResizeObserver(s=>{for(const e of s){const i=e.target;if(!i.classList.contains("active"))continue;const n=e.contentRect.height;if(n>0){let r=0;const o=i.querySelector("thead");o&&(r+=o.offsetHeight||o.getBoundingClientRect().height);const l=Math.max(n-r,100);t(this,U)!==l&&(g(this,U,l),t(this,nt).call(this),t(this,A)!==null&&t(this,rt).call(this))}}})),t(this,z).observe(t(this,T)))},"#initResizeObserver"));h(this,rt,c(()=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(s=>{const e=t(this,T).querySelector(s);e&&e.querySelector("tbody")&&t(this,gt).call(this,e,s)}),t(this,yt).call(this)},"#renderAllContainers"));h(this,xt,c(s=>{var o;const e=t(this,A);if(!e||e<=0)return;const i=((o=t(this,I).get(".ng-container-body"))==null?void 0:o.length)||1,n=Math.floor(s/e),r=Math.max(0,n);[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(l=>{const a=t(this,T).querySelector(l);if(!a)return;const d=a.querySelector("tbody");if(!d)return;Array.from(d.querySelectorAll("tr:not(.nodata)")).forEach((f,b)=>{const x=r+Math.floor(b/i),S=t(this,T).getData?t(this,T).getData(x):null;S?(f.style.display="",t(this,vt).call(this,f,S,x)):f.style.display="none"})})},"#handleScroll"));h(this,vt,c((s,e,i)=>{s.dataset.row=i,Array.from(s.cells).forEach(n=>{const r=n.dataset.bind;r&&e[r]!==void 0&&(n.textContent=e[r]),n.dataset.row=i})},"#bindRowData"));R(this,"destroy",c(()=>{t(this,z)&&(t(this,z).disconnect(),g(this,z,null))},"destroy"));g(this,T,s),t(this,mt).call(this)}getRowHeight(){return t(this,A)}templateLength(s=".ng-container-body"){var e;return((e=t(this,I).get(s))==null?void 0:e.length)||1}};T=new WeakMap,I=new WeakMap,A=new WeakMap,z=new WeakMap,U=new WeakMap,K=new WeakMap,gt=new WeakMap,pt=new WeakMap,nt=new WeakMap,yt=new WeakMap,mt=new WeakMap,rt=new WeakMap,xt=new WeakMap,vt=new WeakMap,c(Xt,"RowManager");let $t=Xt;const ot=class ot extends HTMLElement{constructor(){super();h(this,Z,null);h(this,G);h(this,wt,c(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:i,type:n})=>{const r=this.querySelector(i);if(!r)return;const o=t(this,Et).call(this,t(this,Z),n);r.innerHTML="",r.appendChild(o)})},"#renderSplitContainers"));h(this,St,c(()=>{["left","right"].forEach(e=>{const i=this.querySelector(`.ng-container-${e}`),n=i==null?void 0:i.querySelector("table");if(!i||!n)return;let r=0;n.querySelectorAll("col").forEach(o=>{const l=parseInt(o.getAttribute("width"),10);isNaN(r)||(r+=l)}),i.style.flex=`0 0 ${r}px`,i.style.width=`${r}px`})},"#updateContainerWidths"));R(this,"generate",c(e=>{e&&(g(this,Z,It.compile(e)),t(this,Z).style.display="table",t(this,wt).call(this),t(this,G).initialize(),t(this,St).call(this),setTimeout(()=>{var i;(i=this.querySelector("nine-table-hscrollbar"))==null||i.refresh()},0))},"generate"));h(this,Et,c((e,i)=>{const n=e.cloneNode(!0);return i==="left"?n.querySelectorAll("col, th, td").forEach(r=>{r.getAttribute("fixed")!=="left"&&r.remove()}):i==="right"?n.querySelectorAll("col, th, td").forEach(r=>{r.getAttribute("fixed")!=="right"&&r.remove()}):n.querySelectorAll("[fixed=left], [fixed=right]").forEach(r=>{r.remove()}),n},"#createSplitTable"));R(this,"getRowHeight",c(()=>t(this,G).getRowHeight(),"getRowHeight"));R(this,"scrollToX",c(e=>{const i=this.querySelector(".ng-container-body");i&&(i.scrollLeft=e)},"scrollToX"));R(this,"scrollToY",c(e=>{const i=this.querySelector(".ng-container-body");i&&(i.scrollTop=e)},"scrollToY"));h(this,Rt,c(()=>{t(this,Tt).call(this)},"#init"));h(this,Tt,c(()=>{const e=ot.SCROLLBAR_SIZE;this.innerHTML=`
64
126
  <style>
65
127
  nine-table-sheet {
66
128
  display: none;
@@ -82,7 +144,7 @@
82
144
  flex-direction: row;
83
145
  flex: 1 1 auto;
84
146
  width: 100%;
85
- height: calc(100% - ${t}px);
147
+ height: calc(100% - ${e}px);
86
148
  overflow: hidden;
87
149
  position: relative;
88
150
  }
@@ -126,16 +188,16 @@
126
188
  nine-table-sheet .ng-container-bottom {
127
189
  display: flex;
128
190
  flex-direction: row;
129
- height: ${t}px;
130
- min-height: ${t}px;
191
+ height: ${e}px;
192
+ min-height: ${e}px;
131
193
  flex-shrink: 0;
132
194
  background: #f9fafb;
133
195
  border-top: 1px solid #e5e7eb;
134
196
  }
135
197
 
136
198
  nine-table-sheet .ng-scroll-edge {
137
- width: ${t}px;
138
- min-width: ${t}px;
199
+ width: ${e}px;
200
+ min-width: ${e}px;
139
201
  height: 100%;
140
202
  flex-shrink: 0;
141
203
  background: #f3f4f6;
@@ -180,14 +242,14 @@
180
242
  <nine-table-hscrollbar></nine-table-hscrollbar>
181
243
  <div class='ng-scroll-edge'></div>
182
244
  </div>
183
- `},"#render"));b(this,F,new ke(this))}connectedCallback(){e(this,me).call(this)}disconnectedCallback(){this.innerHTML="",v.log("NineTableSheet destroyed.")}};K=new WeakMap,F=new WeakMap,be=new WeakMap,ye=new WeakMap,pe=new WeakMap,me=new WeakMap,we=new WeakMap,a(te,"NineTableSheet"),S(te,"SCROLLBAR_SIZE",16);let re=te;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",re);const De=class De extends HTMLElement{constructor(){super();c(this,xe,a(()=>{var t;(t=this.querySelector(".nine-tab-bar"))==null||t.addEventListener("click",s=>{var o;const n=s.ctrlKey||s.metaKey||s.shiftKey,r=parseInt((o=s.target.closest(".nine-tab-item"))==null?void 0:o.dataset.index,10);e(this,ie).call(this,r,n)}),e(this,ie).call(this,0,!1)},"#init"));c(this,ie,a((t,s=!1)=>{const n=a(()=>{const u=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(x=>x.style.setProperty("display","none"));const m=u.filter(x=>x.classList.contains("active"));m.length<2||m.forEach(x=>{const E=parseInt(x.getAttribute("data-index"),10),D=this.querySelector(`nine-splitter[data-split-index="${E}"]`),Ve=u[E+1];D&&Ve&&Ve.classList.contains("active")&&D.style.setProperty("display","flex")})},"updateSplitters"),r=this.querySelector(".nine-tab-bar"),o=this.querySelector("nine-table-sheets-body"),l=r.querySelectorAll(".nine-tab-item"),h=o.querySelectorAll("nine-table-sheet");if(!l[t])return;if(!s)l.forEach((u,f)=>{u.classList.toggle("active",f===t)}),h.forEach((u,f)=>{const m=f===t;u.classList.toggle("active",m),u.style.flex=m?"1 1 100%":""});else{const u=l[t],f=r.querySelectorAll(".nine-tab-item.active");if(u.classList.contains("active")&&f.length<=1)return;u.classList.toggle("active");const m=o.querySelector(`nine-table-sheet[data-index="${t}"]`);m&&(m.classList.toggle("active"),m.classList.contains("active")||(m.style.flex=""))}const d=o.querySelectorAll("nine-table-sheet.active");d==null||d.forEach(u=>{u.style.flex=d.length>1?"1 1 0%":"1 1 100%"}),n()},"#switchSheet"))}connectedCallback(){e(this,xe).call(this)}};xe=new WeakMap,ie=new WeakMap,a(De,"NineTableSheets");let Le=De;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",Le);const ze=class ze{constructor(i){c(this,q);c(this,ve,a(()=>{e(this,Se).call(this),new ResizeObserver(i=>{for(let t of i)e(this,q).getAttribute("auto-height")==="true"&&e(this,se).call(this)}).observe(e(this,q))},"#init"));c(this,se,a(()=>{var h,d;const i=Array.from(e(this,q).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(i.length===0)return;const t=parseInt(e(this,q).getAttribute("max-display-row"),10)||10,s=Math.max(...i.map(u=>u.getRowHeight())),n=(h=e(this,q).shadowRoot.querySelector("nine-table-header"))==null?void 0:h.getBoundingClientRect().height,r=(d=e(this,q).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:d.getBoundingClientRect().height,o=re.SCROLLBAR_SIZE,l=t*s+n+r+o;e(this,q).style.height=`${l}px`},"#applyAutoHeight"));c(this,Se,a(()=>{const t=Array.from(e(this,q).children).filter(h=>h.tagName==="TABLE"),s=e(this,q).getAttribute("auto-height")==="true",n=t.length,r=t.map((h,d)=>{const f=`<nine-table-sheet class="${d===0?"active":""}" data-index="${d}"></nine-table-sheet>`,m=d<n-1?`<nine-splitter class="h" data-split-index="${d}"></nine-splitter>`:"";return f+m}).join(""),o=t.map((h,d)=>`<div class="nine-tab-item ${d===0?"active":""}" data-index="${d}">Sheet ${d+1}</div>`).join("");e(this,q).shadowRoot.innerHTML=`
245
+ `},"#render"));g(this,G,new $t(this))}connectedCallback(){t(this,Rt).call(this)}disconnectedCallback(){this.innerHTML="",w.log("NineTableSheet destroyed.")}};Z=new WeakMap,G=new WeakMap,wt=new WeakMap,St=new WeakMap,Et=new WeakMap,Rt=new WeakMap,Tt=new WeakMap,c(ot,"NineTableSheet"),R(ot,"SCROLLBAR_SIZE",16);let ht=ot;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",ht);const Ut=class Ut extends HTMLElement{constructor(){super();h(this,At,c(()=>{var e;(e=this.querySelector(".nine-tab-bar"))==null||e.addEventListener("click",i=>{var o;const n=i.ctrlKey||i.metaKey||i.shiftKey,r=parseInt((o=i.target.closest(".nine-tab-item"))==null?void 0:o.dataset.index,10);t(this,lt).call(this,r,n)}),t(this,lt).call(this,0,!1)},"#init"));h(this,lt,c((e,i=!1)=>{const n=c(()=>{const u=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(x=>x.style.setProperty("display","none"));const b=u.filter(x=>x.classList.contains("active"));b.length<2||b.forEach(x=>{const S=parseInt(x.getAttribute("data-index"),10),_=this.querySelector(`nine-splitter[data-split-index="${S}"]`),Gt=u[S+1];_&&Gt&&Gt.classList.contains("active")&&_.style.setProperty("display","flex")})},"updateSplitters"),r=this.querySelector(".nine-tab-bar"),o=this.querySelector("nine-table-sheets-body"),l=r.querySelectorAll(".nine-tab-item"),a=o.querySelectorAll("nine-table-sheet");if(!l[e])return;if(!i)l.forEach((u,f)=>{u.classList.toggle("active",f===e)}),a.forEach((u,f)=>{const b=f===e;u.classList.toggle("active",b),u.style.flex=b?"1 1 100%":""});else{const u=l[e],f=r.querySelectorAll(".nine-tab-item.active");if(u.classList.contains("active")&&f.length<=1)return;u.classList.toggle("active");const b=o.querySelector(`nine-table-sheet[data-index="${e}"]`);b&&(b.classList.toggle("active"),b.classList.contains("active")||(b.style.flex=""))}const d=o.querySelectorAll("nine-table-sheet.active");d==null||d.forEach(u=>{u.style.flex=d.length>1?"1 1 0%":"1 1 100%"}),n()},"#switchSheet"))}connectedCallback(){t(this,At).call(this)}};At=new WeakMap,lt=new WeakMap,c(Ut,"NineTableSheets");let Wt=Ut;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",Wt);const Kt=class Kt{constructor(s){h(this,k);h(this,kt,c(()=>{t(this,qt).call(this),new ResizeObserver(s=>{for(let e of s)t(this,k).getAttribute("auto-height")==="true"&&t(this,ct).call(this)}).observe(t(this,k))},"#init"));h(this,ct,c(()=>{var a,d;const s=Array.from(t(this,k).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(s.length===0)return;const e=parseInt(t(this,k).getAttribute("max-display-row"),10)||10,i=Math.max(...s.map(u=>u.getRowHeight())),n=(a=t(this,k).shadowRoot.querySelector("nine-table-header"))==null?void 0:a.getBoundingClientRect().height,r=(d=t(this,k).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:d.getBoundingClientRect().height,o=ht.SCROLLBAR_SIZE,l=e*i+n+r+o;t(this,k).style.height=`${l}px`},"#applyAutoHeight"));h(this,qt,c(()=>{const e=Array.from(t(this,k).children).filter(a=>a.tagName==="TABLE"),i=t(this,k).getAttribute("auto-height")==="true",n=e.length,r=e.map((a,d)=>{const f=`<nine-table-sheet class="${d===0?"active":""}" data-index="${d}"></nine-table-sheet>`,b=d<n-1?`<nine-splitter class="h" data-split-index="${d}"></nine-splitter>`:"";return f+b}).join(""),o=e.map((a,d)=>`<div class="nine-tab-item ${d===0?"active":""}" data-index="${d}">Sheet ${d+1}</div>`).join("");t(this,k).shadowRoot.innerHTML=`
184
246
  <style>
185
247
  :host {
186
248
  display: flex;
187
249
  flex-direction: column;
188
250
  position: relative;
189
251
  overflow: hidden;
190
- height: ${s?"auto":"100%"};
252
+ height: ${i?"auto":"100%"};
191
253
  background: #fff;
192
254
  }
193
255
 
@@ -278,5 +340,5 @@
278
340
  <nine-table-analysis></nine-table-analysis>
279
341
  </nine-table-body>
280
342
  <nine-table-footer></nine-table-footer>
281
- `;const l=e(this,q).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((h,d)=>{t[d]&&setTimeout(()=>{h.generate(t[d]),s&&e(this,se).call(this)})})},"#render"));b(this,q,i),e(this,ve).call(this)}};q=new WeakMap,ve=new WeakMap,se=new WeakMap,Se=new WeakMap,a(ze,"LayoutManager");let Ce=ze;const Ne=class Ne{constructor(i){c(this,$);c(this,Y,-1);S(this,"count",a(()=>e(this,$).rawRecords.length,"count"));b(this,$,i)}get at(){return e(this,Y)}set at(i){var s,n;b(this,Y,parseInt(i,10));const t=((n=(s=e(this,$).owner).querySelector)==null?void 0:n.call(s,".ng-container-body"))||e(this,$).owner.body;t&&!t.querySelector(`tbody.bindable tr[data-row="${e(this,Y)}"]`)&&setTimeout(()=>{var r,o;(o=(r=e(this,$).owner).scrollTo_V1)==null||o.call(r,e(this,Y))})}};$=new WeakMap,Y=new WeakMap,a(Ne,"ngRow");let _e=Ne;const L=class L{constructor(i,t){c(this,T);c(this,w);c(this,k,[]);c(this,Z,[]);c(this,Ee,0);c(this,O,[]);c(this,Re,a(()=>{b(this,O,[]);const i=e(this,T).template||[];Array.from(i).forEach(t=>{var s;e(this,O).push(((s=t.getBoundingClientRect)==null?void 0:s.call(t).height)||24)}),(e(this,w).rawRecords||[]).forEach(t=>{t.__ng||(t.__ng=e(this,ne).call(this)),t.__ng.height=e(this,O).slice()})},"#initialize"));S(this,"set",a(i=>{this.clear(),this.add(i,!1)},"set"));c(this,ne,a(()=>({rowState:L.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:e(this,O).slice(),o:{},c:{},_:[0,0,0,0,L.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,e(this,O).slice(),-1,{},{}]}),"#getDefaultMeta"));S(this,"reset",a(()=>{b(this,k,[]),b(this,Z,[])},"reset"));S(this,"clear",a(()=>{var i;e(this,w).rawRecords=[],b(this,k,[]),b(this,Z,[]),(i=e(this,w).viewRecords)!=null&&i.reset&&e(this,w).viewRecords.reset()},"clear"));c(this,Ae,a(i=>{var n;Array.isArray(i)||(i=[i]);const t=typeof((n=e(this,T).fields)==null?void 0:n.get)=="function"?e(this,T).fields.get():Object.keys(i[0]||{}),s=[];return i.forEach(r=>{const o={v:[]};t.forEach(l=>{o.v.push(r[l]!==void 0&&r[l]!==null?r[l]:"")}),s.push(o)}),s},"#json2Array"));c(this,qe,a(i=>(Array.isArray(i)||(i=[i]),i.forEach(t=>{t.__ng=e(this,ne).call(this),t.__ng.rowid=this.nextId,t.__ng.rowState=L.ROW_STATE.INSERT,t.__ng._[0]=t.__ng.rowid}),i),"#defaultInsert"));S(this,"add",a((i,t=!0)=>{var r;i===void 0&&(i={});const s=e(this,Ae).call(this,i);e(this,w).rawRecords=e(this,w).rawRecords.concat(e(this,qe).call(this,s)),this.resetRecords();const n=this.count()-1;return t||s.forEach((o,l)=>{const h=e(this,w).rawRecords[n-l];h&&(h.__ng.rowState=L.ROW_STATE.EMPTY)}),(r=e(this,w).viewRecords)!=null&&r.reset&&e(this,w).viewRecords.reset(),n},"add"));S(this,"delete",a(i=>{var s;let t=[];Array.isArray(i)?t=i:typeof i>"u"?t=[e(this,w).owner.row.at]:t=[parseInt(i,10)],t.sort((n,r)=>r-n).forEach(n=>{if(e(this,k)[n]){const r=e(this,k)[n].__ng.rowid;e(this,k)[n].__ng.rowState===L.ROW_STATE.INSERT?e(this,w).rawRecords=e(this,w).rawRecords.filter(o=>o.__ng.rowid!==r):e(this,w).rawRecords.forEach(o=>{o.__ng.rowid===r&&(o.__ng.deleted=!0,o.__ng.rowState=L.ROW_STATE.DELETE)})}}),this.resetRecords(),(s=e(this,w).viewRecords)!=null&&s.reset&&e(this,w).viewRecords.reset()},"delete"));S(this,"setValue",a((i,t,s)=>{var h;i=parseInt(i,10);const r=(typeof((h=e(this,T).fields)==null?void 0:h.get)=="function"?e(this,T).fields.get():[]).indexOf(t);if(r<0)return;const o=this.getValidData()[i];if(!o)return;const l=o.v[r];l!==s&&o.__ng.rowState!==L.ROW_STATE.INSERT&&(o.__ng.o.hasOwnProperty(t)||(o.__ng.o[t]=l),o.__ng.rowState=L.ROW_STATE.UPDATE),o.v[r]=s,e(this,w).owner.refreshData&&e(this,w).owner.refreshData(i)},"setValue"));S(this,"resetRecords",a(()=>{b(this,Z,e(this,w).rawRecords.filter(i=>!i.__ng.deleted)),b(this,k,e(this,w).rawRecords.filter(i=>!i.__ng.deleted&&!i.__ng.filtered)),e(this,w).rawRecords.forEach((i,t)=>{i.__ng.rowidx=t}),e(this,k).forEach((i,t)=>{i.__ng.i=t})},"resetRecords"));S(this,"getValidData",a(()=>(e(this,k).length===0&&e(this,w).rawRecords.length>0&&this.resetRecords(),e(this,k)),"getValidData"));c(this,j,a(i=>{var s;if(!i)return i;const t=typeof((s=e(this,T).fields)==null?void 0:s.get)=="function"?e(this,T).fields.get():[];return Array.isArray(i)?i.filter(n=>!n.__ng.deleted).map(n=>{const r={};return t.forEach((o,l)=>{r[o]=n.v?n.v[l]:n[o]}),r.__ng=n.__ng,r}):i},"#conv2"));S(this,"count",a(()=>this.getValidData().length,"count"));S(this,"get",a((i,t)=>{var r;const s=this.getValidData();if(!s||s.length<=0)return;if(i==null)return e(this,j).call(this,s);if(i<0||i>=s.length)return null;const n=typeof((r=e(this,T).fields)==null?void 0:r.get)=="function"?e(this,T).fields.get():[];if(t!=null){const o=n.indexOf(t);return o>=0?s[i].v[o]:null}return e(this,j).call(this,s[i])},"get"));b(this,T,i),b(this,w,t),e(this,Re).call(this)}get source(){return e(this,j).call(this,e(this,w).rawRecords)}set source(i){this.clear(),this.add(i,!1)}get nextId(){return++Ke(this,Ee)._}get length(){return e(this,k).length}getRowCount(){return this.length}};T=new WeakMap,w=new WeakMap,k=new WeakMap,Z=new WeakMap,Ee=new WeakMap,O=new WeakMap,Re=new WeakMap,ne=new WeakMap,Ae=new WeakMap,qe=new WeakMap,j=new WeakMap,a(L,"ngData"),S(L,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Ie=L;const Be=class Be{constructor(i){this.owner=i,this.row=new _e(this),this.data=new Ie(i,this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var t;(t=this.owner.view)!=null&&t.redraw&&this.owner.view.redraw()},this.setDataSource=t=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(t||[])},this.getRowState=t=>{var n,r;const s=parseInt(t,10);if(!(s>=this.data.count()))return(r=(n=this.data.getValidData()[s])==null?void 0:n.__ng)==null?void 0:r.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=t=>{this.row.at=t},this.scrollTo_V1=t=>(t<0&&(t=0),t>=this.rawRecords.length&&(t=this.rawRecords.length-1),this.viewRecords.rawIndex=t,this.viewRecords.reset&&this.viewRecords.reset(),!(t<=0||t>=this.rawRecords.length-1)),this.getColumn=(t,s)=>this.data.get(t,s),this.setColumn=(t,s,n)=>{t=parseInt(t,10),this.data.setValue(t,s,n)},this.setDataSource([])}};a(Be,"ngDataManager");let He=Be;const Pe=class Pe extends HTMLElement{constructor(){super();c(this,U);c(this,Te);this.attachShadow({mode:"open"}),b(this,U,new He(this))}connectedCallback(){b(this,Te,new Ce(this)),v.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))}disconnectedCallback(){v.log("NineTable disconnected.")}get data(){return e(this,U).data}get row(){return e(this,U).row}get dataManager(){return e(this,U)}};U=new WeakMap,Te=new WeakMap,a(Pe,"NineTable");let Me=Pe;customElements.get("nine-table")||customElements.define("nine-table",Me)});
343
+ `;const l=t(this,k).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((a,d)=>{e[d]&&setTimeout(()=>{a.generate(e[d]),i&&t(this,ct).call(this)})})},"#render"));g(this,k,s),t(this,kt).call(this)}};k=new WeakMap,kt=new WeakMap,ct=new WeakMap,qt=new WeakMap,c(Kt,"LayoutManager");let Ot=Kt;const jt=class jt{constructor(s){h(this,D);h(this,j,-1);R(this,"count",c(()=>t(this,D).rawRecords.length,"count"));g(this,D,s)}get at(){return t(this,j)}set at(s){var i,n;g(this,j,parseInt(s,10));const e=((n=(i=t(this,D).owner).querySelector)==null?void 0:n.call(i,".ng-container-body"))||t(this,D).owner.body;e&&!e.querySelector(`tbody.bindable tr[data-row="${t(this,j)}"]`)&&setTimeout(()=>{var r,o;(o=(r=t(this,D).owner).scrollTo_V1)==null||o.call(r,t(this,j))})}};D=new WeakMap,j=new WeakMap,c(jt,"ngRow");let zt=jt;const H=class H{constructor(s,e){h(this,q);h(this,v);h(this,L,[]);h(this,J,[]);h(this,Lt,0);h(this,P,[]);h(this,Ht,c(()=>{g(this,P,[]);const s=t(this,q).template||[];Array.from(s).forEach(e=>{var i;t(this,P).push(((i=e.getBoundingClientRect)==null?void 0:i.call(e).height)||24)}),(t(this,v).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,at).call(this)),e.__ng.height=t(this,P).slice()})},"#initialize"));R(this,"set",c(s=>{this.clear(),this.add(s,!1)},"set"));h(this,at,c(()=>({rowState:H.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,P).slice(),o:{},c:{},_:[0,0,0,0,H.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,P).slice(),-1,{},{}]}),"#getDefaultMeta"));R(this,"reset",c(()=>{g(this,L,[]),g(this,J,[])},"reset"));R(this,"clear",c(()=>{var s;t(this,v).rawRecords=[],g(this,L,[]),g(this,J,[]),(s=t(this,v).viewRecords)!=null&&s.reset&&t(this,v).viewRecords.reset()},"clear"));h(this,Ct,c(s=>{var n;Array.isArray(s)||(s=[s]);const e=typeof((n=t(this,q).fields)==null?void 0:n.get)=="function"?t(this,q).fields.get():Object.keys(s[0]||{}),i=[];return s.forEach(r=>{const o={v:[]};e.forEach(l=>{o.v.push(r[l]!==void 0&&r[l]!==null?r[l]:"")}),i.push(o)}),i},"#json2Array"));h(this,_t,c(s=>(Array.isArray(s)||(s=[s]),s.forEach(e=>{e.__ng=t(this,at).call(this),e.__ng.rowid=this.nextId,e.__ng.rowState=H.ROW_STATE.INSERT,e.__ng._[0]=e.__ng.rowid}),s),"#defaultInsert"));R(this,"add",c((s,e=!0)=>{var r;s===void 0&&(s={});const i=t(this,Ct).call(this,s);t(this,v).rawRecords=t(this,v).rawRecords.concat(t(this,_t).call(this,i)),this.resetRecords();const n=this.count()-1;return e||i.forEach((o,l)=>{const a=t(this,v).rawRecords[n-l];a&&(a.__ng.rowState=H.ROW_STATE.EMPTY)}),(r=t(this,v).viewRecords)!=null&&r.reset&&t(this,v).viewRecords.reset(),n},"add"));R(this,"delete",c(s=>{var i;let e=[];Array.isArray(s)?e=s:typeof s>"u"?e=[t(this,v).owner.row.at]:e=[parseInt(s,10)],e.sort((n,r)=>r-n).forEach(n=>{if(t(this,L)[n]){const r=t(this,L)[n].__ng.rowid;t(this,L)[n].__ng.rowState===H.ROW_STATE.INSERT?t(this,v).rawRecords=t(this,v).rawRecords.filter(o=>o.__ng.rowid!==r):t(this,v).rawRecords.forEach(o=>{o.__ng.rowid===r&&(o.__ng.deleted=!0,o.__ng.rowState=H.ROW_STATE.DELETE)})}}),this.resetRecords(),(i=t(this,v).viewRecords)!=null&&i.reset&&t(this,v).viewRecords.reset()},"delete"));R(this,"setValue",c((s,e,i)=>{var a;s=parseInt(s,10);const r=(typeof((a=t(this,q).fields)==null?void 0:a.get)=="function"?t(this,q).fields.get():[]).indexOf(e);if(r<0)return;const o=this.getValidData()[s];if(!o)return;const l=o.v[r];l!==i&&o.__ng.rowState!==H.ROW_STATE.INSERT&&(o.__ng.o.hasOwnProperty(e)||(o.__ng.o[e]=l),o.__ng.rowState=H.ROW_STATE.UPDATE),o.v[r]=i,t(this,v).owner.refreshData&&t(this,v).owner.refreshData(s)},"setValue"));R(this,"resetRecords",c(()=>{g(this,J,t(this,v).rawRecords.filter(s=>!s.__ng.deleted)),g(this,L,t(this,v).rawRecords.filter(s=>!s.__ng.deleted&&!s.__ng.filtered)),t(this,v).rawRecords.forEach((s,e)=>{s.__ng.rowidx=e}),t(this,L).forEach((s,e)=>{s.__ng.i=e})},"resetRecords"));R(this,"getValidData",c(()=>(t(this,L).length===0&&t(this,v).rawRecords.length>0&&this.resetRecords(),t(this,L)),"getValidData"));h(this,Q,c(s=>{var i;if(!s)return s;const e=typeof((i=t(this,q).fields)==null?void 0:i.get)=="function"?t(this,q).fields.get():[];return Array.isArray(s)?s.filter(n=>!n.__ng.deleted).map(n=>{const r={};return e.forEach((o,l)=>{r[o]=n.v?n.v[l]:n[o]}),r.__ng=n.__ng,r}):s},"#conv2"));R(this,"count",c(()=>this.getValidData().length,"count"));R(this,"get",c((s,e)=>{var r;const i=this.getValidData();if(!i||i.length<=0)return;if(s==null)return t(this,Q).call(this,i);if(s<0||s>=i.length)return null;const n=typeof((r=t(this,q).fields)==null?void 0:r.get)=="function"?t(this,q).fields.get():[];if(e!=null){const o=n.indexOf(e);return o>=0?i[s].v[o]:null}return t(this,Q).call(this,i[s])},"get"));g(this,q,s),g(this,v,e),t(this,Ht).call(this)}get source(){return t(this,Q).call(this,t(this,v).rawRecords)}set source(s){this.clear(),this.add(s,!1)}get nextId(){return++ee(this,Lt)._}get length(){return t(this,L).length}getRowCount(){return this.length}};q=new WeakMap,v=new WeakMap,L=new WeakMap,J=new WeakMap,Lt=new WeakMap,P=new WeakMap,Ht=new WeakMap,at=new WeakMap,Ct=new WeakMap,_t=new WeakMap,Q=new WeakMap,c(H,"ngData"),R(H,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Dt=H;const Ft=class Ft{constructor(s){this.owner=s,this.row=new zt(this),this.data=new Dt(s,this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var e;(e=this.owner.view)!=null&&e.redraw&&this.owner.view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{var n,r;const i=parseInt(e,10);if(!(i>=this.data.count()))return(r=(n=this.data.getValidData()[i])==null?void 0:n.__ng)==null?void 0:r.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,i)=>this.data.get(e,i),this.setColumn=(e,i,n)=>{e=parseInt(e,10),this.data.setValue(e,i,n)},this.setDataSource([])}};c(Ft,"ngDataManager");let Pt=Ft;const Zt=class Zt extends HTMLElement{constructor(){super();h(this,F);h(this,Mt);this.attachShadow({mode:"open"}),g(this,F,new Pt(this))}connectedCallback(){g(this,Mt,new Ot(this)),w.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))}disconnectedCallback(){w.log("NineTable disconnected.")}get data(){return t(this,F).data}get row(){return t(this,F).row}get dataManager(){return t(this,F)}};F=new WeakMap,Mt=new WeakMap,c(Zt,"NineTable");let Bt=Zt;customElements.get("nine-table")||customElements.define("nine-table",Bt)});
282
344
  //# sourceMappingURL=nine-table.umd.js.map