@ninebone/table 0.0.184 → 0.0.186

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