@ninebone/table 0.0.265 → 0.0.267

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(m,p){typeof exports=="object"&&typeof module<"u"?p(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],p):(m=typeof globalThis<"u"?globalThis:m||self,p(m.NineboneUtil))})(this,function(m){"use strict";var Oe=Object.defineProperty;var Be=m=>{throw TypeError(m)};var Pe=(m,p,x)=>p in m?Oe(m,p,{enumerable:!0,configurable:!0,writable:!0,value:x}):m[p]=x;var c=(m,p)=>Oe(m,"name",{value:p,configurable:!0});var S=(m,p,x)=>Pe(m,typeof p!="symbol"?p+"":p,x),De=(m,p,x)=>p.has(m)||Be("Cannot "+x);var e=(m,p,x)=>(De(m,p,"read from private field"),x?x.call(m):p.get(m)),g=(m,p,x)=>p.has(m)?Be("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(m):p.set(m,x),y=(m,p,x,W)=>(De(m,p,"write to private field"),W?W.call(m,x):p.set(m,x),x);var Ne=(m,p,x,W)=>({set _(J){y(m,p,J,x)},get _(){return e(m,p,W)}});var _,N,w,P,V,X,oe,Y,le,z,I,q,O,M,$,ae,ce,he,de,A,K,Q,Z,ee,fe,ue,ge,ie,T,be,se,ye,B,U,k,v,L,j,pe,D,me,ne,we,xe,G,F,ve;const ke=class ke extends m.trace.constructor{constructor(){super(),this.init("nine-table","green")}};c(ke,"Trace");let p=ke;const x=new p,Le=class Le extends HTMLElement{constructor(){super();g(this,_);g(this,N,!1);g(this,w);g(this,P);g(this,V);g(this,X);g(this,oe,c(()=>{if(!e(this,_))return;const t=e(this,_).querySelector(".ng-container-body");t&&(y(this,X,new ResizeObserver(()=>{this.refresh()})),e(this,X).observe(t))},"#observeResize"));S(this,"refresh",c(()=>{if(!e(this,_)||!e(this,w)||e(this,N))return;const t=e(this,w).container,i=t.querySelector("table");if(!i)return;const n=e(this,w).track,r=e(this,w).thumb,o=e(this,_).querySelector(".ng-container-bottom"),a=t.clientWidth,f=i.scrollWidth;if(a!==0&&f>a)o&&(o.style.display="flex");else{o&&(o.style.display="none");return}const l=n.clientWidth;if(l<=0)return;const h=Math.max(Math.min(l*(a/f),l),20);r.style.width=`${h}px`;const u=t.scrollLeft,d=f-a;let b=0;d>0&&(b=parseInt(u/d*(l-h),10)),b<0&&(b=0);const E=l-h;b>E&&(b=E),r.style.left=`${b}px`,x.log(b),e(this,w).left.disabled=b===0,e(this,w).right.disabled=b>=E-1},"refresh"));g(this,Y,c(t=>{if(!e(this,w))return!1;const i=e(this,w).container,n=i.querySelector("table");if(!n)return!1;const r=e(this,w).track.getBoundingClientRect(),o=e(this,w).thumb.clientWidth;let a=t;a<0&&(a=0);const f=r.width-o;a>f&&(a=f),a=parseInt(a,10),e(this,w).thumb.style.left=`${a}px`,e(this,w).left.disabled=a===0,e(this,w).right.disabled=a>=f-1;const l=i.clientWidth,h=n.scrollWidth;let u=f>0?-a*(h-l)/f:0;return-u>h-l&&(u=-(h-l)),-u+5>h-l&&(u=-(h-l)),l>=h&&(u=0),n.style.transform=`translateX(${u}px)`,a>0&&a<f-1},"#thumbMoveTo"));g(this,le,c(()=>{const t=c(n=>{clearInterval(e(this,P)),clearInterval(e(this,V));const r=parseInt(e(this,w).thumb.style.left||0,10);e(this,Y).call(this,r+n),y(this,P,setInterval(()=>{clearInterval(e(this,P)),y(this,V,setInterval(()=>{const o=parseInt(e(this,w).thumb.style.left||0,10);e(this,Y).call(this,o+n)||clearInterval(e(this,V))},50))},500))},"delayScroll"),i=c(()=>{clearInterval(e(this,P)),clearInterval(e(this,V))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(n=>{e(this,w).left.addEventListener(n,i),e(this,w).right.addEventListener(n,i),e(this,w).track.addEventListener(n,i)}),e(this,w).left.addEventListener("mousedown",n=>{n.button===0&&t(-20)}),e(this,w).right.addEventListener("mousedown",n=>{n.button===0&&t(20)}),e(this,w).left.addEventListener("touchstart",()=>t(-20)),e(this,w).right.addEventListener("touchstart",()=>t(20)),e(this,w).track.addEventListener("mousedown",n=>{if(n.button!==0)return;n.preventDefault();const r=e(this,w).track.getBoundingClientRect(),o=e(this,w).thumb.clientWidth;e(this,Y).call(this,n.clientX-r.left-o/2)}),e(this,w).thumb.addEventListener("mousedown",n=>{if(n.button!==0)return;n.stopPropagation(),n.preventDefault(),y(this,N,!0),this.shiftX=n.clientX-e(this,w).thumb.getBoundingClientRect().left;const r=c(a=>{if(!e(this,N))return;const f=e(this,w).track.getBoundingClientRect();e(this,Y).call(this,a.clientX-f.left-this.shiftX)},"onMouseMove"),o=c(()=>{y(this,N,!1),i(),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",o),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",o)})},"#init"))}connectedCallback(){if(y(this,_,this.closest("nine-table-sheet")||this.getRootNode().host),!e(this,_))return;this.innerHTML=`
1
+ (function(w,p){typeof exports=="object"&&typeof module<"u"?p(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],p):(w=typeof globalThis<"u"?globalThis:w||self,p(w.NineboneUtil))})(this,function(w){"use strict";var Xe=Object.defineProperty;var Ye=w=>{throw TypeError(w)};var Ze=(w,p,v)=>p in w?Xe(w,p,{enumerable:!0,configurable:!0,writable:!0,value:v}):w[p]=v;var h=(w,p)=>Xe(w,"name",{value:p,configurable:!0});var A=(w,p,v)=>Ze(w,typeof p!="symbol"?p+"":p,v),Ue=(w,p,v)=>p.has(w)||Ye("Cannot "+v);var e=(w,p,v)=>(Ue(w,p,"read from private field"),v?v.call(w):p.get(w)),g=(w,p,v)=>p.has(w)?Ye("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(w):p.set(w,v),y=(w,p,v,N)=>(Ue(w,p,"write to private field"),N?N.call(w,v):p.set(w,v),v);var je=(w,p,v,N)=>({set _(te){y(w,p,te,v)},get _(){return e(w,p,N)}});var I,D,x,P,V,X,de,Y,fe,W,M,T,z,H,$,ue,ge,be,ye,R,Z,ie,F,se,pe,me,we,ne,xe,oe,G,J,q,ve,le,Se,O,j,C,S,k,Q,Ee,B,Ae,ae,Re,qe,ee,K,Te;const Ne=class Ne extends w.trace.constructor{constructor(){super(),this.init("nine-table","green")}};h(Ne,"Trace");let p=Ne;const v=new p,We=class We extends HTMLElement{constructor(){super();g(this,I);g(this,D,!1);g(this,x);g(this,P);g(this,V);g(this,X);g(this,de,h(()=>{if(!e(this,I))return;const t=e(this,I).querySelector(".ng-container-body");t&&(y(this,X,new ResizeObserver(()=>{this.refresh()})),e(this,X).observe(t))},"#observeResize"));A(this,"refresh",h(()=>{if(!e(this,I)||!e(this,x)||e(this,D))return;const t=e(this,x).container,s=t.querySelector("table");if(!s)return;const r=e(this,x).track,n=e(this,x).thumb,o=e(this,I).querySelector(".ng-container-bottom"),c=t.clientWidth,u=s.scrollWidth;if(c!==0&&u>c)o&&(o.style.display="flex");else{o&&(o.style.display="none");return}const l=r.clientWidth;if(l<=0)return;const a=Math.max(Math.min(l*(c/u),l),20);n.style.width=`${a}px`;const d=t.scrollLeft,f=u-c;let b=0;f>0&&(b=parseInt(d/f*(l-a),10)),b<0&&(b=0);const m=l-a;b>m&&(b=m),n.style.left=`${b}px`,v.log(b),e(this,x).left.disabled=b===0,e(this,x).right.disabled=b>=m-1},"refresh"));g(this,Y,h(t=>{if(!e(this,x))return!1;const s=e(this,x).container,r=s.querySelector("table");if(!r)return!1;const n=e(this,x).track.getBoundingClientRect(),o=e(this,x).thumb.clientWidth;let c=t;c<0&&(c=0);const u=n.width-o;c>u&&(c=u),c=parseInt(c,10),e(this,x).thumb.style.left=`${c}px`,e(this,x).left.disabled=c===0,e(this,x).right.disabled=c>=u-1;const l=s.clientWidth,a=r.scrollWidth;let d=u>0?-c*(a-l)/u:0;return-d>a-l&&(d=-(a-l)),-d+5>a-l&&(d=-(a-l)),l>=a&&(d=0),r.style.transform=`translateX(${d}px)`,c>0&&c<u-1},"#thumbMoveTo"));g(this,fe,h(()=>{const t=h(r=>{clearInterval(e(this,P)),clearInterval(e(this,V));const n=parseInt(e(this,x).thumb.style.left||0,10);e(this,Y).call(this,n+r),y(this,P,setInterval(()=>{clearInterval(e(this,P)),y(this,V,setInterval(()=>{const o=parseInt(e(this,x).thumb.style.left||0,10);e(this,Y).call(this,o+r)||clearInterval(e(this,V))},50))},500))},"delayScroll"),s=h(()=>{clearInterval(e(this,P)),clearInterval(e(this,V))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(r=>{e(this,x).left.addEventListener(r,s),e(this,x).right.addEventListener(r,s),e(this,x).track.addEventListener(r,s)}),e(this,x).left.addEventListener("mousedown",r=>{r.button===0&&t(-20)}),e(this,x).right.addEventListener("mousedown",r=>{r.button===0&&t(20)}),e(this,x).left.addEventListener("touchstart",()=>t(-20)),e(this,x).right.addEventListener("touchstart",()=>t(20)),e(this,x).track.addEventListener("mousedown",r=>{if(r.button!==0)return;r.preventDefault();const n=e(this,x).track.getBoundingClientRect(),o=e(this,x).thumb.clientWidth;e(this,Y).call(this,r.clientX-n.left-o/2)}),e(this,x).thumb.addEventListener("mousedown",r=>{if(r.button!==0)return;r.stopPropagation(),r.preventDefault(),y(this,D,!0),this.shiftX=r.clientX-e(this,x).thumb.getBoundingClientRect().left;const n=h(c=>{if(!e(this,D))return;const u=e(this,x).track.getBoundingClientRect();e(this,Y).call(this,c.clientX-u.left-this.shiftX)},"onMouseMove"),o=h(()=>{y(this,D,!1),s(),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",o),this.refresh()},"onMouseUp");document.addEventListener("mousemove",n),document.addEventListener("mouseup",o)})},"#init"))}connectedCallback(){if(y(this,I,this.closest("nine-table-sheet")||this.getRootNode().host),!e(this,I))return;this.innerHTML=`
2
2
  <style>
3
3
  nine-table-hscrollbar {
4
4
  display: flex;
@@ -60,7 +60,7 @@
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=c(()=>{const i=e(this,_).querySelector(".ng-container-body");if(!i){setTimeout(t,10);return}y(this,w,{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")}),e(this,le).call(this),e(this,oe).call(this),this.refresh()},"initWhenReady");t()}disconnectedCallback(){e(this,X)&&e(this,X).disconnect()}};_=new WeakMap,N=new WeakMap,w=new WeakMap,P=new WeakMap,V=new WeakMap,X=new WeakMap,oe=new WeakMap,Y=new WeakMap,le=new WeakMap,c(Le,"NineTableHScrollBar");let W=Le;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",W);const Ce=class Ce{constructor(s){g(this,z);g(this,I,[]);g(this,q,null);g(this,O,null);g(this,M,0);g(this,$,0);S(this,"getRowHeight",c(()=>e(this,q),"getRowHeight"));g(this,ae,c(()=>{e(this,ce).call(this)},"#init"));g(this,ce,c(()=>{!e(this,z)||!(e(this,z)instanceof HTMLElement)||(y(this,O,new ResizeObserver(s=>{for(const t of s){const i=t.target;if(!i.classList.contains("active"))continue;const n=t.contentRect.height||(t.borderBoxSize&&t.borderBoxSize[0]?t.borderBoxSize[0].blockSize:0);if(n>0){const r=i.clientHeight||i.getBoundingClientRect().height||n;let o=0;const a=i.querySelector(".ng-container-body")||i,f=a.querySelector("thead"),l=a.querySelector("tfoot");f&&(o+=f.offsetHeight||f.getBoundingClientRect().height),l&&(o+=l.offsetHeight||l.getBoundingClientRect().height);const h=Math.max(r-o,100);if(e(this,M)!==h&&(y(this,M,h),e(this,q)!==null)){const u=Math.ceil(e(this,M)/e(this,q));y(this,$,u+20),x.log(`[RowManager] Resized. Height: ${e(this,M)}px | Target Rows: ${e(this,$)}`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(d=>{const b=i.querySelector(d);b&&b.querySelector("tbody")&&e(this,de).call(this,b)})}}}})),e(this,O).observe(e(this,z)))},"#initResizeObserver"));S(this,"initialize",c(s=>{x.log(s);const t=e(this,z).querySelector(".ng-container-body"),i=s.querySelector("tbody"),n=Array.from(i.querySelectorAll("tr"));y(this,I,n.map(r=>r.cloneNode(!0))),y(this,q,null),e(this,he).call(this,t)},"initialize"));g(this,he,c(s=>{if(e(this,q)!==null&&e(this,q)>0)return e(this,q);if(e(this,I).length===0)throw new Error("[RowManager] Template TRs are empty.");const t=s.querySelector("tbody.bindable")||s.querySelector("tbody");if(!t)return 24;t.querySelectorAll("tr:not(.nodata)").forEach(u=>u.remove());const i=t.querySelector("tr.nodata"),n=document.createDocumentFragment();e(this,I).forEach(u=>{n.appendChild(u.cloneNode(!0))}),i?i.before(n):t.appendChild(n);const r=s.closest("nine-table-sheet"),o=r?r.style.display:"",a=r?r.style.visibility:"",f=r?r.style.position:"";r&&(r.style.display==="none"||window.getComputedStyle(r).display==="none")&&(r.style.display="block",r.style.visibility="hidden",r.style.position="absolute");let l=0;const h=t.querySelectorAll("tr:not(.nodata)");if(h.forEach((u,d)=>{l+=u.offsetHeight||u.getBoundingClientRect().height}),h.forEach(u=>u.remove()),r&&(r.style.display=o,r.style.visibility=a,r.style.position=f),y(this,q,l),e(this,M)>0){const u=Math.ceil(e(this,M)/e(this,q));y(this,$,u+20)}else y(this,$,40);return console.log(`[RowManager] Template Height Cached: ${e(this,q)}px | RowCount: ${e(this,$)}`),e(this,q)},"#measureAndCacheHeight"));g(this,de,c(s=>{if(e(this,I).length===0)return;const t=s.querySelector("tbody.bindable")||s.querySelector("tbody");if(!t)return;t.querySelectorAll("tr:not(.nodata)").forEach(o=>o.remove());const i=t.querySelector("tr.nodata"),n=document.createDocumentFragment(),r=e(this,$);for(let o=0;o<r;o++)e(this,I).forEach(a=>{n.appendChild(a.cloneNode(!0))});i?i.before(n):t.appendChild(n),console.log(`[RowManager] Rendered ${r} sets into DOM.`)},"#renderRows"));S(this,"destroy",c(()=>{e(this,O)&&(e(this,O).disconnect(),y(this,O,null))},"destroy"));y(this,z,s),e(this,ae).call(this)}get templateLength(){return e(this,I).length||1}};z=new WeakMap,I=new WeakMap,q=new WeakMap,O=new WeakMap,M=new WeakMap,$=new WeakMap,ae=new WeakMap,ce=new WeakMap,he=new WeakMap,de=new WeakMap,c(Ce,"RowManager");let J=Ce;const te=class te extends HTMLElement{constructor(){super();g(this,A,null);g(this,K);g(this,Q,c((t,i)=>{const n=Array.from(t.querySelectorAll(i+" tr")),r=Array.from(t.querySelectorAll(i+" th,"+i+" td")),o=n.length;if(o===0||r.length===0)return;let a=0;r.forEach(l=>{a+=l.colSpan||1});const f=Array.from(Array(o),()=>Array(a).fill(null));n.forEach(l=>{const h=l.sectionRowIndex;let u=0;Array.from(l.querySelectorAll("th,td")).forEach(d=>{for(let R=0;R<f[h].length;R++)if(f[h][R]===null){u=R;break}const b=d.rowSpan||1,E=d.colSpan||1;for(let R=0;R<b;R++)for(let H=0;H<E;H++)h+R<o&&u+H<a&&(f[h+R][u+H]=R===0&&H===0?"1":"0")})}),n.forEach(l=>{const h=l.sectionRowIndex;Array.from(l.querySelectorAll("th,td")).forEach(u=>{for(let d=0;d<f[h].length;d++)if(f[h][d]==="1"){u.dataset.col=d,f[h][d]="0";break}})})},"#resetColIndex"));g(this,Z,c((t,i)=>{const n=t.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"));S(this,"generate",c(t=>{if(!t)return;const i=c(l=>{const h=c(d=>{if(d.querySelector("colgroup"))return;const b=d.querySelector("tbody tr")||d.querySelector("tr"),E=b?b.querySelectorAll("th, td").length:1,R=document.createElement("colgroup"),H=Math.max(Math.floor(d.clientWidth/E),100);for(let We=0;We<E;We++){const ze=document.createElement("col");ze.setAttribute("width",H),R.appendChild(ze)}d.prepend(R)},"ensureColgroup"),u=c(d=>{if(d.querySelector("thead"))return;const b=document.createElement("thead"),E=d.querySelector("colgroup");E?E.after(b):d.prepend(b)},"ensureThead");return h(l),u(l),l.classList.add("nine-table-element"),l},"initializeTable"),n=t.cloneNode(!0);y(this,A,i(n)),e(this,A).style.display="table",e(this,Q).call(this,e(this,A),"thead"),e(this,Q).call(this,e(this,A),"tbody"),Array.from(e(this,A).querySelectorAll("colgroup col")).forEach((l,h)=>{const u=l.getAttribute("fixed");u&&e(this,A).querySelectorAll(`[data-col="${h}"]`).forEach(d=>{d.setAttribute("fixed",u)})}),x.log(e(this,A));const o=this.querySelector(".ng-container-left"),a=this.querySelector(".ng-container-body"),f=this.querySelector(".ng-container-right");if(a){const l=e(this,Z).call(this,e(this,A),null);a.innerHTML="",a.appendChild(l),x.log(e(this,A)),x.log(l),e(this,K).initialize(e(this,A))}if(o){const l=e(this,Z).call(this,e(this,A),"left");let h=0;l.querySelectorAll("col").forEach(d=>{const b=parseInt(d.getAttribute("width"),10);isNaN(b)||(h+=b)}),o.innerHTML="",o.appendChild(l);const u=h>0?h:0;o.style.flex=`0 0 ${u}px`,o.style.width=`${u}px`}if(f){const l=e(this,Z).call(this,e(this,A),"right");let h=0;l.querySelectorAll("col").forEach(d=>{const b=parseInt(d.getAttribute("width"),10);isNaN(b)||(h+=b)}),f.innerHTML="",f.appendChild(l);const u=h>0?h:0;f.style.flex=`0 0 ${u}px`,f.style.width=`${u}px`}a&&a.addEventListener("scroll",()=>{var l;(l=this.querySelector("nine-table-hscrollbar"))==null||l.refresh()}),setTimeout(()=>{var l;e(this,ee).call(this),(l=this.querySelector("nine-table-hscrollbar"))==null||l.refresh()},0)},"generate"));S(this,"getRowHeight",c(()=>e(this,K).getRowHeight(),"getRowHeight"));S(this,"scrollToX",c(t=>{const i=this.querySelector(".ng-container-body");i&&(i.scrollLeft=t)},"scrollToX"));S(this,"scrollToY",c(t=>{const i=this.querySelector(".ng-container-body");i&&(i.scrollTop=t)},"scrollToY"));g(this,ee,c(()=>{var l,h,u;const t=this.querySelector(".ng-container-left table"),i=this.querySelector(".ng-container-body table"),n=this.querySelector(".ng-container-right table");if(!i)return;const r=t?Array.from(t.querySelectorAll("tr")):[],o=Array.from(i.querySelectorAll("tr")),a=n?Array.from(n.querySelectorAll("tr")):[],f=Math.max(r.length,o.length,a.length);for(let d=0;d<f;d++){const b=[((l=r[d])==null?void 0:l.getBoundingClientRect().height)||0,((h=o[d])==null?void 0:h.getBoundingClientRect().height)||0,((u=a[d])==null?void 0:u.getBoundingClientRect().height)||0],E=Math.max(...b);E>0&&(r[d]&&(r[d].style.height=`${E}px`),o[d]&&(o[d].style.height=`${E}px`),a[d]&&(a[d].style.height=`${E}px`))}},"#syncRowHeights"));g(this,fe,c(()=>{e(this,ue).call(this),new MutationObserver(t=>{for(const i of t)i.attributeName==="class"&&this.classList.contains("active")&&e(this,ee).call(this)}).observe(this,{attributes:!0})},"#init"));g(this,ue,c(()=>{const t=te.SCROLLBAR_SIZE;this.innerHTML=`
63
+ `;const t=h(()=>{const s=e(this,I).querySelector(".ng-container-body");if(!s){setTimeout(t,10);return}y(this,x,{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")}),e(this,fe).call(this),e(this,de).call(this),this.refresh()},"initWhenReady");t()}disconnectedCallback(){e(this,X)&&e(this,X).disconnect()}};I=new WeakMap,D=new WeakMap,x=new WeakMap,P=new WeakMap,V=new WeakMap,X=new WeakMap,de=new WeakMap,Y=new WeakMap,fe=new WeakMap,h(We,"NineTableHScrollBar");let N=We;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",N);const ze=class ze{constructor(i){g(this,W);g(this,M,[]);g(this,T,null);g(this,z,null);g(this,H,0);g(this,$,0);A(this,"getRowHeight",h(()=>e(this,T),"getRowHeight"));g(this,ue,h(()=>{e(this,ge).call(this)},"#init"));g(this,ge,h(()=>{!e(this,W)||!(e(this,W)instanceof HTMLElement)||(y(this,z,new ResizeObserver(i=>{for(const t of i){const s=t.target;if(!s.classList.contains("active"))continue;const r=t.contentRect.height||(t.borderBoxSize&&t.borderBoxSize[0]?t.borderBoxSize[0].blockSize:0);if(r>0){const n=s.clientHeight||s.getBoundingClientRect().height||r;let o=0;const c=s.querySelector(".ng-container-body")||s,u=c.querySelector("thead"),l=c.querySelector("tfoot");u&&(o+=u.offsetHeight||u.getBoundingClientRect().height),l&&(o+=l.offsetHeight||l.getBoundingClientRect().height);const a=Math.max(n-o,100);if(e(this,H)!==a&&(y(this,H,a),e(this,T)!==null)){const d=Math.ceil(e(this,H)/e(this,T));y(this,$,d+20),v.log(`[RowManager] Resized. Height: ${e(this,H)}px | Target Rows: ${e(this,$)}`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(f=>{const b=s.querySelector(f);b&&b.querySelector("tbody")&&e(this,ye).call(this,b)})}}}})),e(this,z).observe(e(this,W)))},"#initResizeObserver"));A(this,"initialize",h(i=>{v.log(i);const t=e(this,W).querySelector(".ng-container-body"),s=i.querySelector("tbody"),r=Array.from(s.querySelectorAll("tr"));y(this,M,r.map(n=>n.cloneNode(!0))),y(this,T,null),e(this,be).call(this,t)},"initialize"));g(this,be,h(i=>{if(e(this,T)!==null&&e(this,T)>0)return e(this,T);if(e(this,M).length===0)throw new Error("[RowManager] Template TRs are empty.");const t=i.querySelector("tbody.bindable")||i.querySelector("tbody");if(!t)return 24;t.querySelectorAll("tr:not(.nodata)").forEach(d=>d.remove());const s=t.querySelector("tr.nodata"),r=document.createDocumentFragment();e(this,M).forEach(d=>{r.appendChild(d.cloneNode(!0))}),s?s.before(r):t.appendChild(r);const n=i.closest("nine-table-sheet"),o=n?n.style.display:"",c=n?n.style.visibility:"",u=n?n.style.position:"";n&&(n.style.display==="none"||window.getComputedStyle(n).display==="none")&&(n.style.display="block",n.style.visibility="hidden",n.style.position="absolute");let l=0;const a=t.querySelectorAll("tr:not(.nodata)");if(a.forEach((d,f)=>{l+=d.offsetHeight||d.getBoundingClientRect().height}),a.forEach(d=>d.remove()),n&&(n.style.display=o,n.style.visibility=c,n.style.position=u),y(this,T,l),e(this,H)>0){const d=Math.ceil(e(this,H)/e(this,T));y(this,$,d+20)}else y(this,$,40);return console.log(`[RowManager] Template Height Cached: ${e(this,T)}px | RowCount: ${e(this,$)}`),e(this,T)},"#measureAndCacheHeight"));g(this,ye,h(i=>{if(e(this,M).length===0)return;const t=i.querySelector("tbody.bindable")||i.querySelector("tbody");if(!t)return;t.querySelectorAll("tr:not(.nodata)").forEach(o=>o.remove());const s=t.querySelector("tr.nodata"),r=document.createDocumentFragment(),n=e(this,$);for(let o=0;o<n;o++)e(this,M).forEach(c=>{r.appendChild(c.cloneNode(!0))});s?s.before(r):t.appendChild(r),console.log(`[RowManager] Rendered ${n} sets into DOM.`)},"#renderRows"));A(this,"destroy",h(()=>{e(this,z)&&(e(this,z).disconnect(),y(this,z,null))},"destroy"));y(this,W,i),e(this,ue).call(this)}get templateLength(){return e(this,M).length||1}};W=new WeakMap,M=new WeakMap,T=new WeakMap,z=new WeakMap,H=new WeakMap,$=new WeakMap,ue=new WeakMap,ge=new WeakMap,be=new WeakMap,ye=new WeakMap,h(ze,"RowManager");let te=ze;const re=class re extends HTMLElement{constructor(){super();g(this,R,null);g(this,Z);g(this,ie,h((t,s)=>{const r=Array.from(t.querySelectorAll(s+" tr")),n=Array.from(t.querySelectorAll(s+" th,"+s+" td")),o=r.length;if(o===0||n.length===0)return;let c=0;n.forEach(l=>{c+=l.colSpan||1});const u=Array.from(Array(o),()=>Array(c).fill(null));r.forEach(l=>{const a=l.sectionRowIndex;let d=0;Array.from(l.querySelectorAll("th,td")).forEach(f=>{for(let E=0;E<u[a].length;E++)if(u[a][E]===null){d=E;break}const b=f.rowSpan||1,m=f.colSpan||1;for(let E=0;E<b;E++)for(let _=0;_<m;_++)a+E<o&&d+_<c&&(u[a+E][d+_]=E===0&&_===0?"1":"0")})}),r.forEach(l=>{const a=l.sectionRowIndex;Array.from(l.querySelectorAll("th,td")).forEach(d=>{for(let f=0;f<u[a].length;f++)if(u[a][f]==="1"){d.dataset.col=f,u[a][f]="0";break}})})},"#resetColIndex"));g(this,F,h((t,s)=>{const r=t.cloneNode(!0);return s==="left"?r.querySelectorAll("col, th, td").forEach(n=>{n.getAttribute("fixed")!=="left"&&n.remove()}):s==="right"?r.querySelectorAll("col, th, td").forEach(n=>{n.getAttribute("fixed")!=="right"&&n.remove()}):r.querySelectorAll("[fixed=left], [fixed=right]").forEach(n=>{n.remove()}),r},"#createSplitTable"));A(this,"generate",h(t=>{if(!t)return;const s=h(l=>{const a=h(f=>{if(f.querySelector("colgroup"))return;const b=f.querySelector("tbody tr")||f.querySelector("tr"),m=b?b.querySelectorAll("th, td").length:1,E=document.createElement("colgroup"),_=Math.max(Math.floor(f.clientWidth/m),100);for(let Ce=0;Ce<m;Ce++){const ce=document.createElement("col");ce.setAttribute("width",_),E.appendChild(ce)}f.prepend(E)},"ensureColgroup"),d=h(f=>{if(f.querySelector("thead"))return;const b=document.createElement("thead"),m=f.querySelector("colgroup");m?m.after(b):f.prepend(b)},"ensureThead");return a(l),d(l),l.classList.add("nine-table-element"),l},"initializeTable"),r=t.cloneNode(!0);y(this,R,s(r)),e(this,R).style.display="table",e(this,ie).call(this,e(this,R),"thead"),e(this,ie).call(this,e(this,R),"tbody"),Array.from(e(this,R).querySelectorAll("colgroup col")).forEach((l,a)=>{const d=l.getAttribute("fixed");d&&e(this,R).querySelectorAll(`[data-col="${a}"]`).forEach(f=>{f.setAttribute("fixed",d)})}),v.log(e(this,R));const o=this.querySelector(".ng-container-left"),c=this.querySelector(".ng-container-body"),u=this.querySelector(".ng-container-right");if(c){const l=e(this,F).call(this,e(this,R),null);c.innerHTML="",c.appendChild(l),v.log(e(this,R)),v.log(l),e(this,Z).initialize(e(this,R))}if(o){const l=e(this,F).call(this,e(this,R),"left");let a=0;l.querySelectorAll("col").forEach(f=>{const b=parseInt(f.getAttribute("width"),10);isNaN(b)||(a+=b)}),o.innerHTML="",o.appendChild(l);const d=a>0?a:0;o.style.flex=`0 0 ${d}px`,o.style.width=`${d}px`}if(u){const l=e(this,F).call(this,e(this,R),"right");let a=0;l.querySelectorAll("col").forEach(f=>{const b=parseInt(f.getAttribute("width"),10);isNaN(b)||(a+=b)}),u.innerHTML="",u.appendChild(l);const d=a>0?a:0;u.style.flex=`0 0 ${d}px`,u.style.width=`${d}px`}c&&c.addEventListener("scroll",()=>{var l;(l=this.querySelector("nine-table-hscrollbar"))==null||l.refresh()}),setTimeout(()=>{var l;e(this,se).call(this),(l=this.querySelector("nine-table-hscrollbar"))==null||l.refresh()},0)},"generate"));A(this,"getRowHeight",h(()=>e(this,Z).getRowHeight(),"getRowHeight"));A(this,"scrollToX",h(t=>{const s=this.querySelector(".ng-container-body");s&&(s.scrollLeft=t)},"scrollToX"));A(this,"scrollToY",h(t=>{const s=this.querySelector(".ng-container-body");s&&(s.scrollTop=t)},"scrollToY"));g(this,se,h(()=>{var l,a,d;const t=this.querySelector(".ng-container-left table"),s=this.querySelector(".ng-container-body table"),r=this.querySelector(".ng-container-right table");if(!s)return;const n=t?Array.from(t.querySelectorAll("tr")):[],o=Array.from(s.querySelectorAll("tr")),c=r?Array.from(r.querySelectorAll("tr")):[],u=Math.max(n.length,o.length,c.length);for(let f=0;f<u;f++){const b=[((l=n[f])==null?void 0:l.getBoundingClientRect().height)||0,((a=o[f])==null?void 0:a.getBoundingClientRect().height)||0,((d=c[f])==null?void 0:d.getBoundingClientRect().height)||0],m=Math.max(...b);m>0&&(n[f]&&(n[f].style.height=`${m}px`),o[f]&&(o[f].style.height=`${m}px`),c[f]&&(c[f].style.height=`${m}px`))}},"#syncRowHeights"));g(this,pe,h(()=>{e(this,me).call(this),new MutationObserver(t=>{for(const s of t)s.attributeName==="class"&&this.classList.contains("active")&&e(this,se).call(this)}).observe(this,{attributes:!0})},"#init"));g(this,me,h(()=>{const t=re.SCROLLBAR_SIZE;this.innerHTML=`
64
64
  <style>
65
65
  nine-table-sheet {
66
66
  display: none;
@@ -180,14 +180,14 @@
180
180
  <nine-table-hscrollbar></nine-table-hscrollbar>
181
181
  <div class='ng-scroll-edge'></div>
182
182
  </div>
183
- `},"#render"));y(this,K,new J(this))}connectedCallback(){e(this,fe).call(this)}disconnectedCallback(){this.innerHTML="",x.log("NineTableSheet destroyed.")}};A=new WeakMap,K=new WeakMap,Q=new WeakMap,Z=new WeakMap,ee=new WeakMap,fe=new WeakMap,ue=new WeakMap,c(te,"NineTableSheet"),S(te,"SCROLLBAR_SIZE",16);let re=te;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",re);const _e=class _e extends HTMLElement{constructor(){super();g(this,ge,c(()=>{var t;(t=this.querySelector(".nine-tab-bar"))==null||t.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);e(this,ie).call(this,r,n)}),e(this,ie).call(this,0,!1)},"#init"));g(this,ie,c((t,i=!1)=>{const n=c(()=>{const h=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(b=>b.style.setProperty("display","none"));const d=h.filter(b=>b.classList.contains("active"));d.length<2||d.forEach(b=>{const E=parseInt(b.getAttribute("data-index"),10),R=this.querySelector(`nine-splitter[data-split-index="${E}"]`),H=h[E+1];R&&H&&H.classList.contains("active")&&R.style.setProperty("display","flex")})},"updateSplitters"),r=this.querySelector(".nine-tab-bar"),o=this.querySelector("nine-table-sheets-body"),a=r.querySelectorAll(".nine-tab-item"),f=o.querySelectorAll("nine-table-sheet");if(!a[t])return;if(!i)a.forEach((h,u)=>{h.classList.toggle("active",u===t)}),f.forEach((h,u)=>{const d=u===t;h.classList.toggle("active",d),h.style.flex=d?"1 1 100%":""});else{const h=a[t],u=r.querySelectorAll(".nine-tab-item.active");if(h.classList.contains("active")&&u.length<=1)return;h.classList.toggle("active");const d=o.querySelector(`nine-table-sheet[data-index="${t}"]`);d&&(d.classList.toggle("active"),d.classList.contains("active")||(d.style.flex=""))}const l=o.querySelectorAll("nine-table-sheet.active");l==null||l.forEach(h=>{h.style.flex=l.length>1?"1 1 0%":"1 1 100%"}),n()},"#switchSheet"))}connectedCallback(){e(this,ge).call(this)}};ge=new WeakMap,ie=new WeakMap,c(_e,"NineTableSheets");let Se=_e;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",Se);const He=class He{constructor(s){g(this,T);g(this,be,c(()=>{e(this,ye).call(this),new ResizeObserver(s=>{for(let t of s)e(this,T).getAttribute("auto-height")==="true"&&e(this,se).call(this)}).observe(e(this,T))},"#init"));g(this,se,c(()=>{var f,l;const s=Array.from(e(this,T).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(s.length===0)return;const t=parseInt(e(this,T).getAttribute("max-display-row"),10)||10,i=Math.max(...s.map(h=>h.getRowHeight())),n=(f=e(this,T).shadowRoot.querySelector("nine-table-header"))==null?void 0:f.getBoundingClientRect().height,r=(l=e(this,T).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:l.getBoundingClientRect().height,o=re.SCROLLBAR_SIZE,a=t*i+n+r+o;e(this,T).style.height=`${a}px`},"#applyAutoHeight"));g(this,ye,c(()=>{const t=Array.from(e(this,T).children).filter(f=>f.tagName==="TABLE"),i=e(this,T).getAttribute("auto-height")==="true",n=t.length,r=t.map((f,l)=>{const u=`<nine-table-sheet class="${l===0?"active":""}" data-index="${l}"></nine-table-sheet>`,d=l<n-1?`<nine-splitter class="h" data-split-index="${l}"></nine-splitter>`:"";return u+d}).join(""),o=t.map((f,l)=>`<div class="nine-tab-item ${l===0?"active":""}" data-index="${l}">Sheet ${l+1}</div>`).join("");e(this,T).shadowRoot.innerHTML=`
183
+ `},"#render"));y(this,Z,new te(this))}connectedCallback(){e(this,pe).call(this)}disconnectedCallback(){this.innerHTML="",v.log("NineTableSheet destroyed.")}};R=new WeakMap,Z=new WeakMap,ie=new WeakMap,F=new WeakMap,se=new WeakMap,pe=new WeakMap,me=new WeakMap,h(re,"NineTableSheet"),A(re,"SCROLLBAR_SIZE",16);let he=re;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",he);const Oe=class Oe extends HTMLElement{constructor(){super();g(this,we,h(()=>{var t;(t=this.querySelector(".nine-tab-bar"))==null||t.addEventListener("click",s=>{var o;const r=s.ctrlKey||s.metaKey||s.shiftKey,n=parseInt((o=s.target.closest(".nine-tab-item"))==null?void 0:o.dataset.index,10);e(this,ne).call(this,n,r)}),e(this,ne).call(this,0,!1)},"#init"));g(this,ne,h((t,s=!1)=>{const r=h(()=>{const a=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(b=>b.style.setProperty("display","none"));const f=a.filter(b=>b.classList.contains("active"));f.length<2||f.forEach(b=>{const m=parseInt(b.getAttribute("data-index"),10),E=this.querySelector(`nine-splitter[data-split-index="${m}"]`),_=a[m+1];E&&_&&_.classList.contains("active")&&E.style.setProperty("display","flex")})},"updateSplitters"),n=this.querySelector(".nine-tab-bar"),o=this.querySelector("nine-table-sheets-body"),c=n.querySelectorAll(".nine-tab-item"),u=o.querySelectorAll("nine-table-sheet");if(!c[t])return;if(!s)c.forEach((a,d)=>{a.classList.toggle("active",d===t)}),u.forEach((a,d)=>{const f=d===t;a.classList.toggle("active",f),a.style.flex=f?"1 1 100%":""});else{const a=c[t],d=n.querySelectorAll(".nine-tab-item.active");if(a.classList.contains("active")&&d.length<=1)return;a.classList.toggle("active");const f=o.querySelector(`nine-table-sheet[data-index="${t}"]`);f&&(f.classList.toggle("active"),f.classList.contains("active")||(f.style.flex=""))}const l=o.querySelectorAll("nine-table-sheet.active");l==null||l.forEach(a=>{a.style.flex=l.length>1?"1 1 0%":"1 1 100%"}),r()},"#switchSheet"))}connectedCallback(){e(this,we).call(this)}};we=new WeakMap,ne=new WeakMap,h(Oe,"NineTableSheets");let ke=Oe;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",ke);const U=class U{static compileAll(i){return Array.isArray(i)?i.map(t=>NineTableCompiler.compile(t)):[]}static compile(i){var c,u,l,a,d,f,b,m,E;if(!i)return null;const t=i.cloneNode(!0);e(c=NineTableCompiler,xe).call(c,t),e(u=NineTableCompiler,oe).call(u,t,"thead"),e(l=NineTableCompiler,oe).call(l,t,"tbody"),Array.from(t.querySelectorAll("colgroup col")).forEach((_,Ce)=>{const ce=_.getAttribute("fixed");ce&&t.querySelectorAll(`[data-col="${Ce}"]`).forEach(Ke=>{Ke.setAttribute("fixed",ce)})});const r=e(a=NineTableCompiler,G).call(a,t,"left"),n=e(d=NineTableCompiler,G).call(d,t,null),o=e(f=NineTableCompiler,G).call(f,t,"right");return{masterTable:t,left:{table:r,width:e(b=NineTableCompiler,J).call(b,r)},body:{table:n,width:e(m=NineTableCompiler,J).call(m,n)},right:{table:o,width:e(E=NineTableCompiler,J).call(E,o)}}}};xe=new WeakMap,oe=new WeakMap,G=new WeakMap,J=new WeakMap,h(U,"TableCompiler"),g(U,xe,h(i=>{if(!i.querySelector("colgroup")){const t=i.querySelector("tbody tr")||i.querySelector("tr"),s=t?t.querySelectorAll("th, td").length:1,r=document.createElement("colgroup"),n=Math.max(Math.floor(i.clientWidth/s),100);for(let o=0;o<s;o++){const c=document.createElement("col");c.setAttribute("width",n),r.appendChild(c)}i.prepend(r)}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")),g(U,oe,h((i,t)=>{const s=Array.from(i.querySelectorAll(t+" tr")),r=Array.from(i.querySelectorAll(t+" th,"+t+" td")),n=s.length;if(n===0||r.length===0)return;let o=0;r.forEach(u=>{o+=u.colSpan||1});const c=Array.from(Array(n),()=>Array(o).fill(null));s.forEach(u=>{const l=u.sectionRowIndex;let a=0;Array.from(u.querySelectorAll("th,td")).forEach(d=>{for(let m=0;m<c[l].length;m++)if(c[l][m]===null){a=m;break}const f=d.rowSpan||1,b=d.colSpan||1;for(let m=0;m<f;m++)for(let E=0;E<b;E++)l+m<n&&a+E<o&&(c[l+m][a+E]=m===0&&E===0?"1":"0")})}),s.forEach(u=>{const l=u.sectionRowIndex;Array.from(u.querySelectorAll("th,td")).forEach(a=>{for(let d=0;d<c[l].length;d++)if(c[l][d]==="1"){a.dataset.col=d,c[l][d]="0";break}})})},"#resetColIndex")),g(U,G,h((i,t)=>{const s=i.cloneNode(!0);return t==="left"?s.querySelectorAll("col, th, td").forEach(r=>{r.getAttribute("fixed")!=="left"&&r.remove()}):t==="right"?s.querySelectorAll("col, th, td").forEach(r=>{r.getAttribute("fixed")!=="right"&&r.remove()}):s.querySelectorAll("[fixed=left], [fixed=right]").forEach(r=>{r.remove()}),s},"#createSplitTable")),g(U,J,h(i=>{let t=0;return i.querySelectorAll("col").forEach(s=>{const r=parseInt(s.getAttribute("width"),10);isNaN(r)||(t+=r)}),t},"#calculateTableWidth"));let Le=U;const Be=class Be{constructor(i){g(this,q);g(this,ve,h(()=>{e(this,Se).call(this),new ResizeObserver(i=>{for(let t of i)e(this,q).getAttribute("auto-height")==="true"&&e(this,le).call(this)}).observe(e(this,q))},"#init"));g(this,le,h(()=>{var u,l;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(a=>a.getRowHeight())),r=(u=e(this,q).shadowRoot.querySelector("nine-table-header"))==null?void 0:u.getBoundingClientRect().height,n=(l=e(this,q).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:l.getBoundingClientRect().height,o=he.SCROLLBAR_SIZE,c=t*s+r+n+o;e(this,q).style.height=`${c}px`},"#applyAutoHeight"));g(this,Se,h(()=>{const t=Array.from(e(this,q).children).filter(l=>l.tagName==="TABLE"),s=e(this,q).getAttribute("auto-height")==="true",r=t.length,n=t.map((l,a)=>{const f=`<nine-table-sheet class="${a===0?"active":""}" data-index="${a}"></nine-table-sheet>`,b=a<r-1?`<nine-splitter class="h" data-split-index="${a}"></nine-splitter>`:"";return f+b}).join(""),o=t.map((l,a)=>`<div class="nine-tab-item ${a===0?"active":""}" data-index="${a}">Sheet ${a+1}</div>`).join("");e(this,q).shadowRoot.innerHTML=`
184
184
  <style>
185
185
  :host {
186
186
  display: flex;
187
187
  flex-direction: column;
188
188
  position: relative;
189
189
  overflow: hidden;
190
- height: ${i?"auto":"100%"};
190
+ height: ${s?"auto":"100%"};
191
191
  background: #fff;
192
192
  }
193
193
 
@@ -269,7 +269,7 @@
269
269
  <nine-table-body>
270
270
  <nine-table-summary></nine-table-summary>
271
271
  <nine-table-sheets>
272
- <nine-table-sheets-body>${r}</nine-table-sheets-body>
272
+ <nine-table-sheets-body>${n}</nine-table-sheets-body>
273
273
  <nine-table-sheets-footer>
274
274
  <div class="nine-tab-bar">${o}</div>
275
275
  <div class="sheets-counter">Total : <span id="row-count">0</span></div>
@@ -278,5 +278,5 @@
278
278
  <nine-table-analysis></nine-table-analysis>
279
279
  </nine-table-body>
280
280
  <nine-table-footer></nine-table-footer>
281
- `;const a=e(this,T).shadowRoot.querySelectorAll("nine-table-sheet");a==null||a.forEach((f,l)=>{t[l]&&setTimeout(()=>{f.generate(t[l]),i&&e(this,se).call(this)})})},"#render"));y(this,T,s),e(this,be).call(this)}};T=new WeakMap,be=new WeakMap,se=new WeakMap,ye=new WeakMap,c(He,"LayoutManager");let Ee=He;const Ie=class Ie{constructor(s){g(this,B);g(this,U,-1);S(this,"count",c(()=>e(this,B).rawRecords.length,"count"));y(this,B,s)}get at(){return e(this,U)}set at(s){var i,n;y(this,U,parseInt(s,10));const t=((n=(i=e(this,B).owner).querySelector)==null?void 0:n.call(i,".ng-container-body"))||e(this,B).owner.body;t&&!t.querySelector(`tbody.bindable tr[data-row="${e(this,U)}"]`)&&setTimeout(()=>{var r,o;(o=(r=e(this,B).owner).scrollTo_V1)==null||o.call(r,e(this,U))})}};B=new WeakMap,U=new WeakMap,c(Ie,"ngRow");let Re=Ie;const C=class C{constructor(s,t){g(this,k);g(this,v);g(this,L,[]);g(this,j,[]);g(this,pe,0);g(this,D,[]);g(this,me,c(()=>{y(this,D,[]);const s=e(this,k).template||[];Array.from(s).forEach(t=>{var i;e(this,D).push(((i=t.getBoundingClientRect)==null?void 0:i.call(t).height)||24)}),(e(this,v).rawRecords||[]).forEach(t=>{t.__ng||(t.__ng=e(this,ne).call(this)),t.__ng.height=e(this,D).slice()})},"#initialize"));S(this,"set",c(s=>{this.clear(),this.add(s,!1)},"set"));g(this,ne,c(()=>({rowState:C.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:e(this,D).slice(),o:{},c:{},_:[0,0,0,0,C.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,e(this,D).slice(),-1,{},{}]}),"#getDefaultMeta"));S(this,"reset",c(()=>{y(this,L,[]),y(this,j,[])},"reset"));S(this,"clear",c(()=>{var s;e(this,v).rawRecords=[],y(this,L,[]),y(this,j,[]),(s=e(this,v).viewRecords)!=null&&s.reset&&e(this,v).viewRecords.reset()},"clear"));g(this,we,c(s=>{var n;Array.isArray(s)||(s=[s]);const t=typeof((n=e(this,k).fields)==null?void 0:n.get)=="function"?e(this,k).fields.get():Object.keys(s[0]||{}),i=[];return s.forEach(r=>{const o={v:[]};t.forEach(a=>{o.v.push(r[a]!==void 0&&r[a]!==null?r[a]:"")}),i.push(o)}),i},"#json2Array"));g(this,xe,c(s=>(Array.isArray(s)||(s=[s]),s.forEach(t=>{t.__ng=e(this,ne).call(this),t.__ng.rowid=this.nextId,t.__ng.rowState=C.ROW_STATE.INSERT,t.__ng._[0]=t.__ng.rowid}),s),"#defaultInsert"));S(this,"add",c((s,t=!0)=>{var r;s===void 0&&(s={});const i=e(this,we).call(this,s);e(this,v).rawRecords=e(this,v).rawRecords.concat(e(this,xe).call(this,i)),this.resetRecords();const n=this.count()-1;return t||i.forEach((o,a)=>{const f=e(this,v).rawRecords[n-a];f&&(f.__ng.rowState=C.ROW_STATE.EMPTY)}),(r=e(this,v).viewRecords)!=null&&r.reset&&e(this,v).viewRecords.reset(),n},"add"));S(this,"delete",c(s=>{var i;let t=[];Array.isArray(s)?t=s:typeof s>"u"?t=[e(this,v).owner.row.at]:t=[parseInt(s,10)],t.sort((n,r)=>r-n).forEach(n=>{if(e(this,L)[n]){const r=e(this,L)[n].__ng.rowid;e(this,L)[n].__ng.rowState===C.ROW_STATE.INSERT?e(this,v).rawRecords=e(this,v).rawRecords.filter(o=>o.__ng.rowid!==r):e(this,v).rawRecords.forEach(o=>{o.__ng.rowid===r&&(o.__ng.deleted=!0,o.__ng.rowState=C.ROW_STATE.DELETE)})}}),this.resetRecords(),(i=e(this,v).viewRecords)!=null&&i.reset&&e(this,v).viewRecords.reset()},"delete"));S(this,"setValue",c((s,t,i)=>{var f;s=parseInt(s,10);const r=(typeof((f=e(this,k).fields)==null?void 0:f.get)=="function"?e(this,k).fields.get():[]).indexOf(t);if(r<0)return;const o=this.getValidData()[s];if(!o)return;const a=o.v[r];a!==i&&o.__ng.rowState!==C.ROW_STATE.INSERT&&(o.__ng.o.hasOwnProperty(t)||(o.__ng.o[t]=a),o.__ng.rowState=C.ROW_STATE.UPDATE),o.v[r]=i,e(this,v).owner.refreshData&&e(this,v).owner.refreshData(s)},"setValue"));S(this,"resetRecords",c(()=>{y(this,j,e(this,v).rawRecords.filter(s=>!s.__ng.deleted)),y(this,L,e(this,v).rawRecords.filter(s=>!s.__ng.deleted&&!s.__ng.filtered)),e(this,v).rawRecords.forEach((s,t)=>{s.__ng.rowidx=t}),e(this,L).forEach((s,t)=>{s.__ng.i=t})},"resetRecords"));S(this,"getValidData",c(()=>(e(this,L).length===0&&e(this,v).rawRecords.length>0&&this.resetRecords(),e(this,L)),"getValidData"));g(this,G,c(s=>{var i;if(!s)return s;const t=typeof((i=e(this,k).fields)==null?void 0:i.get)=="function"?e(this,k).fields.get():[];return Array.isArray(s)?s.filter(n=>!n.__ng.deleted).map(n=>{const r={};return t.forEach((o,a)=>{r[o]=n.v?n.v[a]:n[o]}),r.__ng=n.__ng,r}):s},"#conv2"));S(this,"count",c(()=>this.getValidData().length,"count"));S(this,"get",c((s,t)=>{var r;const i=this.getValidData();if(!i||i.length<=0)return;if(s==null)return e(this,G).call(this,i);if(s<0||s>=i.length)return null;const n=typeof((r=e(this,k).fields)==null?void 0:r.get)=="function"?e(this,k).fields.get():[];if(t!=null){const o=n.indexOf(t);return o>=0?i[s].v[o]:null}return e(this,G).call(this,i[s])},"get"));y(this,k,s),y(this,v,t),e(this,me).call(this)}get source(){return e(this,G).call(this,e(this,v).rawRecords)}set source(s){this.clear(),this.add(s,!1)}get nextId(){return++Ne(this,pe)._}get length(){return e(this,L).length}getRowCount(){return this.length}};k=new WeakMap,v=new WeakMap,L=new WeakMap,j=new WeakMap,pe=new WeakMap,D=new WeakMap,me=new WeakMap,ne=new WeakMap,we=new WeakMap,xe=new WeakMap,G=new WeakMap,c(C,"ngData"),S(C,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Ae=C;const Me=class Me{constructor(s){this.owner=s,this.row=new Re(this),this.data=new Ae(s,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 i=parseInt(t,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=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,i)=>this.data.get(t,i),this.setColumn=(t,i,n)=>{t=parseInt(t,10),this.data.setValue(t,i,n)},this.setDataSource([])}};c(Me,"ngDataManager");let Te=Me;const $e=class $e extends HTMLElement{constructor(){super();g(this,F);g(this,ve);this.attachShadow({mode:"open"}),y(this,F,new Te(this))}connectedCallback(){y(this,ve,new Ee(this)),x.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))}disconnectedCallback(){x.log("NineTable disconnected.")}get data(){return e(this,F).data}get row(){return e(this,F).row}get dataManager(){return e(this,F)}};F=new WeakMap,ve=new WeakMap,c($e,"NineTable");let qe=$e;customElements.get("nine-table")||customElements.define("nine-table",qe)});
281
+ `;const c=e(this,q).shadowRoot.querySelectorAll("nine-table-sheet"),u=Le.compileAll(t);v.log(u),c==null||c.forEach((l,a)=>{t[a]&&setTimeout(()=>{l.generate(t[a]),s&&e(this,le).call(this)})})},"#render"));y(this,q,i),e(this,ve).call(this)}};q=new WeakMap,ve=new WeakMap,le=new WeakMap,Se=new WeakMap,h(Be,"LayoutManager");let _e=Be;const De=class De{constructor(i){g(this,O);g(this,j,-1);A(this,"count",h(()=>e(this,O).rawRecords.length,"count"));y(this,O,i)}get at(){return e(this,j)}set at(i){var s,r;y(this,j,parseInt(i,10));const t=((r=(s=e(this,O).owner).querySelector)==null?void 0:r.call(s,".ng-container-body"))||e(this,O).owner.body;t&&!t.querySelector(`tbody.bindable tr[data-row="${e(this,j)}"]`)&&setTimeout(()=>{var n,o;(o=(n=e(this,O).owner).scrollTo_V1)==null||o.call(n,e(this,j))})}};O=new WeakMap,j=new WeakMap,h(De,"ngRow");let Ie=De;const L=class L{constructor(i,t){g(this,C);g(this,S);g(this,k,[]);g(this,Q,[]);g(this,Ee,0);g(this,B,[]);g(this,Ae,h(()=>{y(this,B,[]);const i=e(this,C).template||[];Array.from(i).forEach(t=>{var s;e(this,B).push(((s=t.getBoundingClientRect)==null?void 0:s.call(t).height)||24)}),(e(this,S).rawRecords||[]).forEach(t=>{t.__ng||(t.__ng=e(this,ae).call(this)),t.__ng.height=e(this,B).slice()})},"#initialize"));A(this,"set",h(i=>{this.clear(),this.add(i,!1)},"set"));g(this,ae,h(()=>({rowState:L.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:e(this,B).slice(),o:{},c:{},_:[0,0,0,0,L.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,e(this,B).slice(),-1,{},{}]}),"#getDefaultMeta"));A(this,"reset",h(()=>{y(this,k,[]),y(this,Q,[])},"reset"));A(this,"clear",h(()=>{var i;e(this,S).rawRecords=[],y(this,k,[]),y(this,Q,[]),(i=e(this,S).viewRecords)!=null&&i.reset&&e(this,S).viewRecords.reset()},"clear"));g(this,Re,h(i=>{var r;Array.isArray(i)||(i=[i]);const t=typeof((r=e(this,C).fields)==null?void 0:r.get)=="function"?e(this,C).fields.get():Object.keys(i[0]||{}),s=[];return i.forEach(n=>{const o={v:[]};t.forEach(c=>{o.v.push(n[c]!==void 0&&n[c]!==null?n[c]:"")}),s.push(o)}),s},"#json2Array"));g(this,qe,h(i=>(Array.isArray(i)||(i=[i]),i.forEach(t=>{t.__ng=e(this,ae).call(this),t.__ng.rowid=this.nextId,t.__ng.rowState=L.ROW_STATE.INSERT,t.__ng._[0]=t.__ng.rowid}),i),"#defaultInsert"));A(this,"add",h((i,t=!0)=>{var n;i===void 0&&(i={});const s=e(this,Re).call(this,i);e(this,S).rawRecords=e(this,S).rawRecords.concat(e(this,qe).call(this,s)),this.resetRecords();const r=this.count()-1;return t||s.forEach((o,c)=>{const u=e(this,S).rawRecords[r-c];u&&(u.__ng.rowState=L.ROW_STATE.EMPTY)}),(n=e(this,S).viewRecords)!=null&&n.reset&&e(this,S).viewRecords.reset(),r},"add"));A(this,"delete",h(i=>{var s;let t=[];Array.isArray(i)?t=i:typeof i>"u"?t=[e(this,S).owner.row.at]:t=[parseInt(i,10)],t.sort((r,n)=>n-r).forEach(r=>{if(e(this,k)[r]){const n=e(this,k)[r].__ng.rowid;e(this,k)[r].__ng.rowState===L.ROW_STATE.INSERT?e(this,S).rawRecords=e(this,S).rawRecords.filter(o=>o.__ng.rowid!==n):e(this,S).rawRecords.forEach(o=>{o.__ng.rowid===n&&(o.__ng.deleted=!0,o.__ng.rowState=L.ROW_STATE.DELETE)})}}),this.resetRecords(),(s=e(this,S).viewRecords)!=null&&s.reset&&e(this,S).viewRecords.reset()},"delete"));A(this,"setValue",h((i,t,s)=>{var u;i=parseInt(i,10);const n=(typeof((u=e(this,C).fields)==null?void 0:u.get)=="function"?e(this,C).fields.get():[]).indexOf(t);if(n<0)return;const o=this.getValidData()[i];if(!o)return;const c=o.v[n];c!==s&&o.__ng.rowState!==L.ROW_STATE.INSERT&&(o.__ng.o.hasOwnProperty(t)||(o.__ng.o[t]=c),o.__ng.rowState=L.ROW_STATE.UPDATE),o.v[n]=s,e(this,S).owner.refreshData&&e(this,S).owner.refreshData(i)},"setValue"));A(this,"resetRecords",h(()=>{y(this,Q,e(this,S).rawRecords.filter(i=>!i.__ng.deleted)),y(this,k,e(this,S).rawRecords.filter(i=>!i.__ng.deleted&&!i.__ng.filtered)),e(this,S).rawRecords.forEach((i,t)=>{i.__ng.rowidx=t}),e(this,k).forEach((i,t)=>{i.__ng.i=t})},"resetRecords"));A(this,"getValidData",h(()=>(e(this,k).length===0&&e(this,S).rawRecords.length>0&&this.resetRecords(),e(this,k)),"getValidData"));g(this,ee,h(i=>{var s;if(!i)return i;const t=typeof((s=e(this,C).fields)==null?void 0:s.get)=="function"?e(this,C).fields.get():[];return Array.isArray(i)?i.filter(r=>!r.__ng.deleted).map(r=>{const n={};return t.forEach((o,c)=>{n[o]=r.v?r.v[c]:r[o]}),n.__ng=r.__ng,n}):i},"#conv2"));A(this,"count",h(()=>this.getValidData().length,"count"));A(this,"get",h((i,t)=>{var n;const s=this.getValidData();if(!s||s.length<=0)return;if(i==null)return e(this,ee).call(this,s);if(i<0||i>=s.length)return null;const r=typeof((n=e(this,C).fields)==null?void 0:n.get)=="function"?e(this,C).fields.get():[];if(t!=null){const o=r.indexOf(t);return o>=0?s[i].v[o]:null}return e(this,ee).call(this,s[i])},"get"));y(this,C,i),y(this,S,t),e(this,Ae).call(this)}get source(){return e(this,ee).call(this,e(this,S).rawRecords)}set source(i){this.clear(),this.add(i,!1)}get nextId(){return++je(this,Ee)._}get length(){return e(this,k).length}getRowCount(){return this.length}};C=new WeakMap,S=new WeakMap,k=new WeakMap,Q=new WeakMap,Ee=new WeakMap,B=new WeakMap,Ae=new WeakMap,ae=new WeakMap,Re=new WeakMap,qe=new WeakMap,ee=new WeakMap,h(L,"ngData"),A(L,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Me=L;const Pe=class Pe{constructor(i){this.owner=i,this.row=new Ie(this),this.data=new Me(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 r,n;const s=parseInt(t,10);if(!(s>=this.data.count()))return(n=(r=this.data.getValidData()[s])==null?void 0:r.__ng)==null?void 0:n.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,r)=>{t=parseInt(t,10),this.data.setValue(t,s,r)},this.setDataSource([])}};h(Pe,"ngDataManager");let He=Pe;const Ve=class Ve extends HTMLElement{constructor(){super();g(this,K);g(this,Te);this.attachShadow({mode:"open"}),y(this,K,new He(this))}connectedCallback(){y(this,Te,new _e(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,K).data}get row(){return e(this,K).row}get dataManager(){return e(this,K)}};K=new WeakMap,Te=new WeakMap,h(Ve,"NineTable");let $e=Ve;customElements.get("nine-table")||customElements.define("nine-table",$e)});
282
282
  //# sourceMappingURL=nine-table.umd.js.map