@ninebone/table 0.0.262 → 0.0.263

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 ze=Object.defineProperty;var Oe=m=>{throw TypeError(m)};var Ne=(m,p,x)=>p in m?ze(m,p,{enumerable:!0,configurable:!0,writable:!0,value:x}):m[p]=x;var c=(m,p)=>ze(m,"name",{value:p,configurable:!0});var S=(m,p,x)=>Ne(m,typeof p!="symbol"?p+"":p,x),Be=(m,p,x)=>p.has(m)||Oe("Cannot "+x);var e=(m,p,x)=>(Be(m,p,"read from private field"),x?x.call(m):p.get(m)),u=(m,p,x)=>p.has(m)?Oe("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(m):p.set(m,x),y=(m,p,x,W)=>(Be(m,p,"write to private field"),W?W.call(m,x):p.set(m,x),x);var De=(m,p,x,W)=>({set _(J){y(m,p,J,x)},get _(){return e(m,p,W)}});var _,N,w,P,V,X,re,Y,oe,z,I,q,O,M,$,le,ae,ce,he,A,K,Q,Z,de,fe,ue,te,T,ge,ie,be,B,U,k,v,L,j,ye,D,pe,se,me,we,G,F,xe;const qe=class qe extends m.trace.constructor{constructor(){super(),this.init("nine-table","green")}};c(qe,"Trace");let p=qe;const x=new p,ke=class ke extends HTMLElement{constructor(){super();u(this,_);u(this,N,!1);u(this,w);u(this,P);u(this,V);u(this,X);u(this,re,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 s=e(this,w).track,r=e(this,w).thumb,o=e(this,_).querySelector(".ng-container-bottom"),a=t.clientWidth,d=i.scrollWidth;if(a!==0&&d>a)o&&(o.style.display="flex");else{o&&(o.style.display="none");return}const l=s.clientWidth;if(l<=0)return;const h=Math.max(Math.min(l*(a/d),l),20);r.style.width=`${h}px`;const f=t.scrollLeft,g=d-a;let b=0;g>0&&(b=parseInt(f/g*(l-h),10)),b<0&&(b=0);const R=l-h;b>R&&(b=R),r.style.left=`${b}px`,x.log(b),e(this,w).left.disabled=b===0,e(this,w).right.disabled=b>=R-1},"refresh"));u(this,Y,c(t=>{if(!e(this,w))return!1;const i=e(this,w).container,s=i.querySelector("table");if(!s)return!1;const r=e(this,w).track.getBoundingClientRect(),o=e(this,w).thumb.clientWidth;let a=t;a<0&&(a=0);const d=r.width-o;a>d&&(a=d),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>=d-1;const l=i.clientWidth,h=s.scrollWidth;let f=d>0?-a*(h-l)/d:0;return-f>h-l&&(f=-(h-l)),-f+5>h-l&&(f=-(h-l)),l>=h&&(f=0),s.style.transform=`translateX(${f}px)`,a>0&&a<d-1},"#thumbMoveTo"));u(this,oe,c(()=>{const t=c(s=>{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+s),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+s)||clearInterval(e(this,V))},50))},500))},"delayScroll"),i=c(()=>{clearInterval(e(this,P)),clearInterval(e(this,V))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(s=>{e(this,w).left.addEventListener(s,i),e(this,w).right.addEventListener(s,i),e(this,w).track.addEventListener(s,i)}),e(this,w).left.addEventListener("mousedown",s=>{s.button===0&&t(-20)}),e(this,w).right.addEventListener("mousedown",s=>{s.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",s=>{if(s.button!==0)return;s.preventDefault();const r=e(this,w).track.getBoundingClientRect(),o=e(this,w).thumb.clientWidth;e(this,Y).call(this,s.clientX-r.left-o/2)}),e(this,w).thumb.addEventListener("mousedown",s=>{if(s.button!==0)return;s.stopPropagation(),s.preventDefault(),y(this,N,!0),this.shiftX=s.clientX-e(this,w).thumb.getBoundingClientRect().left;const r=c(a=>{if(!e(this,N))return;const d=e(this,w).track.getBoundingClientRect();e(this,Y).call(this,a.clientX-d.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(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=`
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,oe).call(this),e(this,re).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,re=new WeakMap,Y=new WeakMap,oe=new WeakMap,c(ke,"NineTableHScrollBar");let W=ke;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",W);const Le=class Le{constructor(n){u(this,z);u(this,I,[]);u(this,q,null);u(this,O,null);u(this,M,0);u(this,$,0);S(this,"getRowHeight",c(()=>e(this,q),"getRowHeight"));u(this,le,c(()=>{e(this,ae).call(this)},"#init"));u(this,ae,c(()=>{!e(this,z)||!(e(this,z)instanceof HTMLElement)||(y(this,O,new ResizeObserver(n=>{for(const t of n){const i=t.target;if(!i.classList.contains("active"))continue;const s=t.contentRect.height||(t.borderBoxSize&&t.borderBoxSize[0]?t.borderBoxSize[0].blockSize:0);if(s>0){const r=i.clientHeight||i.getBoundingClientRect().height||s;let o=0;const a=i.querySelector(".ng-container-body")||i,d=a.querySelector("thead"),l=a.querySelector("tfoot");d&&(o+=d.offsetHeight||d.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 f=Math.ceil(e(this,M)/e(this,q));y(this,$,f+20),x.log(`[RowManager] Resized. Height: ${e(this,M)}px | Target Rows: ${e(this,$)}`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(g=>{const b=i.querySelector(g);b&&b.querySelector("tbody")&&e(this,he).call(this,b)})}}}})),e(this,O).observe(e(this,z)))},"#initResizeObserver"));S(this,"initialize",c(n=>{x.log(n);const t=e(this,z).querySelector(".ng-container-body"),i=n.querySelector("tbody"),s=Array.from(i.querySelectorAll("tr"));y(this,I,s.map(r=>r.cloneNode(!0))),y(this,q,null),e(this,ce).call(this,t)},"initialize"));u(this,ce,c(n=>{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=n.querySelector("tbody.bindable")||n.querySelector("tbody");if(!t)return 24;t.querySelectorAll("tr:not(.nodata)").forEach(f=>f.remove());const i=t.querySelector("tr.nodata"),s=document.createDocumentFragment();e(this,I).forEach(f=>{s.appendChild(f.cloneNode(!0))}),i?i.before(s):t.appendChild(s);const r=n.closest("nine-table-sheet"),o=r?r.style.display:"",a=r?r.style.visibility:"",d=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((f,g)=>{l+=f.offsetHeight||f.getBoundingClientRect().height}),h.forEach(f=>f.remove()),r&&(r.style.display=o,r.style.visibility=a,r.style.position=d),y(this,q,l),e(this,M)>0){const f=Math.ceil(e(this,M)/e(this,q));y(this,$,f+20)}else y(this,$,40);return console.log(`[RowManager] Template Height Cached: ${e(this,q)}px | RowCount: ${e(this,$)}`),e(this,q)},"#measureAndCacheHeight"));u(this,he,c(n=>{if(e(this,I).length===0)return;const t=n.querySelector("tbody.bindable")||n.querySelector("tbody");if(!t)return;t.querySelectorAll("tr:not(.nodata)").forEach(o=>o.remove());const i=t.querySelector("tr.nodata"),s=document.createDocumentFragment(),r=e(this,$);for(let o=0;o<r;o++)e(this,I).forEach(a=>{s.appendChild(a.cloneNode(!0))});i?i.before(s):t.appendChild(s),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,n),e(this,le).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,le=new WeakMap,ae=new WeakMap,ce=new WeakMap,he=new WeakMap,c(Le,"RowManager");let J=Le;const ee=class ee extends HTMLElement{constructor(){super();u(this,A,null);u(this,K);u(this,Q,c((t,i)=>{const s=Array.from(t.querySelectorAll(i+" tr")),r=Array.from(t.querySelectorAll(i+" th,"+i+" td")),o=s.length;if(o===0||r.length===0)return;let a=0;r.forEach(l=>{a+=l.colSpan||1});const d=Array.from(Array(o),()=>Array(a).fill(null));s.forEach(l=>{const h=l.sectionRowIndex;let f=0;Array.from(l.querySelectorAll("th,td")).forEach(g=>{for(let E=0;E<d[h].length;E++)if(d[h][E]===null){f=E;break}const b=g.rowSpan||1,R=g.colSpan||1;for(let E=0;E<b;E++)for(let H=0;H<R;H++)h+E<o&&f+H<a&&(d[h+E][f+H]=E===0&&H===0?"1":"0")})}),s.forEach(l=>{const h=l.sectionRowIndex;Array.from(l.querySelectorAll("th,td")).forEach(f=>{for(let g=0;g<d[h].length;g++)if(d[h][g]==="1"){f.dataset.col=g,d[h][g]="0";break}})})},"#resetColIndex"));u(this,Z,c((t,i)=>{const s=t.cloneNode(!0);return i==="left"?s.querySelectorAll("col, th, td").forEach(r=>{r.getAttribute("fixed")!=="left"&&r.remove()}):i==="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"));S(this,"generate",c(t=>{if(!t)return;const i=c(l=>{const h=c(g=>{if(g.querySelector("colgroup"))return;const b=g.querySelector("tbody tr")||g.querySelector("tr"),R=b?b.querySelectorAll("th, td").length:1,E=document.createElement("colgroup"),H=Math.max(Math.floor(g.clientWidth/R),100);for(let $e=0;$e<R;$e++){const We=document.createElement("col");We.setAttribute("width",H),E.appendChild(We)}g.prepend(E)},"ensureColgroup"),f=c(g=>{if(g.querySelector("thead"))return;const b=document.createElement("thead"),R=g.querySelector("colgroup");R?R.after(b):g.prepend(b)},"ensureThead");return h(l),f(l),l.classList.add("nine-table-element"),l},"initializeTable"),s=t.cloneNode(!0);y(this,A,i(s)),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 f=l.getAttribute("fixed");f&&e(this,A).querySelectorAll(`[data-col="${h}"]`).forEach(g=>{g.setAttribute("fixed",f)})}),x.log(e(this,A));const o=this.querySelector(".ng-container-left"),a=this.querySelector(".ng-container-body"),d=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(g=>{const b=parseInt(g.getAttribute("width"),10);isNaN(b)||(h+=b)}),o.innerHTML="",o.appendChild(l);const f=h>0?h:0;o.style.flex=`0 0 ${f}px`,o.style.width=`${f}px`}if(d){const l=e(this,Z).call(this,e(this,A),"right");let h=0;l.querySelectorAll("col").forEach(g=>{const b=parseInt(g.getAttribute("width"),10);isNaN(b)||(h+=b)}),d.innerHTML="",d.appendChild(l);const f=h>0?h:0;d.style.flex=`0 0 ${f}px`,d.style.width=`${f}px`}a&&a.addEventListener("scroll",()=>{var l;(l=this.querySelector("nine-table-hscrollbar"))==null||l.refresh()}),setTimeout(()=>{var l;(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"));u(this,de,c(()=>{const t=c(()=>{var h,f,g;const i=this.querySelector(".ng-container-left table"),s=this.querySelector(".ng-container-body table"),r=this.querySelector(".ng-container-right table");if(!s)return;const o=i?Array.from(i.querySelectorAll("tr")):[],a=Array.from(s.querySelectorAll("tr")),d=r?Array.from(r.querySelectorAll("tr")):[],l=Math.max(o.length,a.length,d.length);for(let b=0;b<l;b++){const R=[((h=o[b])==null?void 0:h.getBoundingClientRect().height)||0,((f=a[b])==null?void 0:f.getBoundingClientRect().height)||0,((g=d[b])==null?void 0:g.getBoundingClientRect().height)||0],E=Math.max(...R);E>0&&(o[b]&&(o[b].style.height=`${E}px`),a[b]&&(a[b].style.height=`${E}px`),d[b]&&(d[b].style.height=`${E}px`))}},"syncRowHeights");e(this,fe).call(this),setTimeout(()=>t()),new MutationObserver(i=>{for(const s of i)s.attributeName==="class"&&this.classList.contains("active")&&t()}).observe(this,{attributes:!0})},"#init"));u(this,fe,c(()=>{const t=ee.SCROLLBAR_SIZE;this.innerHTML=`
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()}),e(this,ee).call(this),setTimeout(()=>{var l;(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=`
64
64
  <style>
65
65
  nine-table-sheet {
66
66
  display: none;
@@ -180,7 +180,7 @@
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,de).call(this)}disconnectedCallback(){this.innerHTML="",x.log("NineTableSheet destroyed.")}};A=new WeakMap,K=new WeakMap,Q=new WeakMap,Z=new WeakMap,de=new WeakMap,fe=new WeakMap,c(ee,"NineTableSheet"),S(ee,"SCROLLBAR_SIZE",16);let ne=ee;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",ne);const Ce=class Ce extends HTMLElement{constructor(){super();u(this,ue,c(()=>{var t;(t=this.querySelector(".nine-tab-bar"))==null||t.addEventListener("click",i=>{var o;const s=i.ctrlKey||i.metaKey||i.shiftKey,r=parseInt((o=i.target.closest(".nine-tab-item"))==null?void 0:o.dataset.index,10);e(this,te).call(this,r,s)}),e(this,te).call(this,0,!1)},"#init"));u(this,te,c((t,i=!1)=>{const s=c(()=>{const h=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(b=>b.style.setProperty("display","none"));const g=h.filter(b=>b.classList.contains("active"));g.length<2||g.forEach(b=>{const R=parseInt(b.getAttribute("data-index"),10),E=this.querySelector(`nine-splitter[data-split-index="${R}"]`),H=h[R+1];E&&H&&H.classList.contains("active")&&E.style.setProperty("display","flex")})},"updateSplitters"),r=this.querySelector(".nine-tab-bar"),o=this.querySelector("nine-table-sheets-body"),a=r.querySelectorAll(".nine-tab-item"),d=o.querySelectorAll("nine-table-sheet");if(!a[t])return;if(!i)a.forEach((h,f)=>{h.classList.toggle("active",f===t)}),d.forEach((h,f)=>{const g=f===t;h.classList.toggle("active",g),h.style.flex=g?"1 1 100%":""});else{const h=a[t],f=r.querySelectorAll(".nine-tab-item.active");if(h.classList.contains("active")&&f.length<=1)return;h.classList.toggle("active");const g=o.querySelector(`nine-table-sheet[data-index="${t}"]`);g&&(g.classList.toggle("active"),g.classList.contains("active")||(g.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%"}),s()},"#switchSheet"))}connectedCallback(){e(this,ue).call(this)}};ue=new WeakMap,te=new WeakMap,c(Ce,"NineTableSheets");let ve=Ce;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",ve);const _e=class _e{constructor(n){u(this,T);u(this,ge,c(()=>{e(this,be).call(this),new ResizeObserver(n=>{for(let t of n)e(this,T).getAttribute("auto-height")==="true"&&e(this,ie).call(this)}).observe(e(this,T))},"#init"));u(this,ie,c(()=>{var d,l;const n=Array.from(e(this,T).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(n.length===0)return;const t=parseInt(e(this,T).getAttribute("max-display-row"),10)||10,i=Math.max(...n.map(h=>h.getRowHeight())),s=(d=e(this,T).shadowRoot.querySelector("nine-table-header"))==null?void 0:d.getBoundingClientRect().height,r=(l=e(this,T).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:l.getBoundingClientRect().height,o=ne.SCROLLBAR_SIZE,a=t*i+s+r+o;e(this,T).style.height=`${a}px`},"#applyAutoHeight"));u(this,be,c(()=>{const t=Array.from(e(this,T).children).filter(d=>d.tagName==="TABLE"),i=e(this,T).getAttribute("auto-height")==="true",s=t.length,r=t.map((d,l)=>{const f=`<nine-table-sheet class="${l===0?"active":""}" data-index="${l}"></nine-table-sheet>`,g=l<s-1?`<nine-splitter class="h" data-split-index="${l}"></nine-splitter>`:"";return f+g}).join(""),o=t.map((d,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,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=`
184
184
  <style>
185
185
  :host {
186
186
  display: flex;
@@ -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((d,l)=>{t[l]&&setTimeout(()=>{d.generate(t[l]),i&&e(this,ie).call(this)})})},"#render"));y(this,T,n),e(this,ge).call(this)}};T=new WeakMap,ge=new WeakMap,ie=new WeakMap,be=new WeakMap,c(_e,"LayoutManager");let Se=_e;const He=class He{constructor(n){u(this,B);u(this,U,-1);S(this,"count",c(()=>e(this,B).rawRecords.length,"count"));y(this,B,n)}get at(){return e(this,U)}set at(n){var i,s;y(this,U,parseInt(n,10));const t=((s=(i=e(this,B).owner).querySelector)==null?void 0:s.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(He,"ngRow");let Ee=He;const C=class C{constructor(n,t){u(this,k);u(this,v);u(this,L,[]);u(this,j,[]);u(this,ye,0);u(this,D,[]);u(this,pe,c(()=>{y(this,D,[]);const n=e(this,k).template||[];Array.from(n).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,se).call(this)),t.__ng.height=e(this,D).slice()})},"#initialize"));S(this,"set",c(n=>{this.clear(),this.add(n,!1)},"set"));u(this,se,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 n;e(this,v).rawRecords=[],y(this,L,[]),y(this,j,[]),(n=e(this,v).viewRecords)!=null&&n.reset&&e(this,v).viewRecords.reset()},"clear"));u(this,me,c(n=>{var s;Array.isArray(n)||(n=[n]);const t=typeof((s=e(this,k).fields)==null?void 0:s.get)=="function"?e(this,k).fields.get():Object.keys(n[0]||{}),i=[];return n.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"));u(this,we,c(n=>(Array.isArray(n)||(n=[n]),n.forEach(t=>{t.__ng=e(this,se).call(this),t.__ng.rowid=this.nextId,t.__ng.rowState=C.ROW_STATE.INSERT,t.__ng._[0]=t.__ng.rowid}),n),"#defaultInsert"));S(this,"add",c((n,t=!0)=>{var r;n===void 0&&(n={});const i=e(this,me).call(this,n);e(this,v).rawRecords=e(this,v).rawRecords.concat(e(this,we).call(this,i)),this.resetRecords();const s=this.count()-1;return t||i.forEach((o,a)=>{const d=e(this,v).rawRecords[s-a];d&&(d.__ng.rowState=C.ROW_STATE.EMPTY)}),(r=e(this,v).viewRecords)!=null&&r.reset&&e(this,v).viewRecords.reset(),s},"add"));S(this,"delete",c(n=>{var i;let t=[];Array.isArray(n)?t=n:typeof n>"u"?t=[e(this,v).owner.row.at]:t=[parseInt(n,10)],t.sort((s,r)=>r-s).forEach(s=>{if(e(this,L)[s]){const r=e(this,L)[s].__ng.rowid;e(this,L)[s].__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((n,t,i)=>{var d;n=parseInt(n,10);const r=(typeof((d=e(this,k).fields)==null?void 0:d.get)=="function"?e(this,k).fields.get():[]).indexOf(t);if(r<0)return;const o=this.getValidData()[n];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(n)},"setValue"));S(this,"resetRecords",c(()=>{y(this,j,e(this,v).rawRecords.filter(n=>!n.__ng.deleted)),y(this,L,e(this,v).rawRecords.filter(n=>!n.__ng.deleted&&!n.__ng.filtered)),e(this,v).rawRecords.forEach((n,t)=>{n.__ng.rowidx=t}),e(this,L).forEach((n,t)=>{n.__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"));u(this,G,c(n=>{var i;if(!n)return n;const t=typeof((i=e(this,k).fields)==null?void 0:i.get)=="function"?e(this,k).fields.get():[];return Array.isArray(n)?n.filter(s=>!s.__ng.deleted).map(s=>{const r={};return t.forEach((o,a)=>{r[o]=s.v?s.v[a]:s[o]}),r.__ng=s.__ng,r}):n},"#conv2"));S(this,"count",c(()=>this.getValidData().length,"count"));S(this,"get",c((n,t)=>{var r;const i=this.getValidData();if(!i||i.length<=0)return;if(n==null)return e(this,G).call(this,i);if(n<0||n>=i.length)return null;const s=typeof((r=e(this,k).fields)==null?void 0:r.get)=="function"?e(this,k).fields.get():[];if(t!=null){const o=s.indexOf(t);return o>=0?i[n].v[o]:null}return e(this,G).call(this,i[n])},"get"));y(this,k,n),y(this,v,t),e(this,pe).call(this)}get source(){return e(this,G).call(this,e(this,v).rawRecords)}set source(n){this.clear(),this.add(n,!1)}get nextId(){return++De(this,ye)._}get length(){return e(this,L).length}getRowCount(){return this.length}};k=new WeakMap,v=new WeakMap,L=new WeakMap,j=new WeakMap,ye=new WeakMap,D=new WeakMap,pe=new WeakMap,se=new WeakMap,me=new WeakMap,we=new WeakMap,G=new WeakMap,c(C,"ngData"),S(C,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Re=C;const Ie=class Ie{constructor(n){this.owner=n,this.row=new Ee(this),this.data=new Re(n,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 s,r;const i=parseInt(t,10);if(!(i>=this.data.count()))return(r=(s=this.data.getValidData()[i])==null?void 0:s.__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,s)=>{t=parseInt(t,10),this.data.setValue(t,i,s)},this.setDataSource([])}};c(Ie,"ngDataManager");let Ae=Ie;const Me=class Me extends HTMLElement{constructor(){super();u(this,F);u(this,xe);this.attachShadow({mode:"open"}),y(this,F,new Ae(this))}connectedCallback(){y(this,xe,new Se(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,xe=new WeakMap,c(Me,"NineTable");let Te=Me;customElements.get("nine-table")||customElements.define("nine-table",Te)});
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)});
282
282
  //# sourceMappingURL=nine-table.umd.js.map