@ninebone/table 0.0.195 → 0.0.197

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