@ninebone/table 0.0.209 → 0.0.210

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(m,y){typeof exports=="object"&&typeof module<"u"?y(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],y):(m=typeof globalThis<"u"?globalThis:m||self,y(m.NineboneUtil))})(this,function(m){"use strict";var $e=Object.defineProperty;var We=m=>{throw TypeError(m)};var De=(m,y,S)=>y in m?$e(m,y,{enumerable:!0,configurable:!0,writable:!0,value:S}):m[y]=S;var a=(m,y)=>$e(m,"name",{value:y,configurable:!0});var x=(m,y,S)=>De(m,typeof y!="symbol"?y+"":y,S),ze=(m,y,S)=>y.has(m)||We("Cannot "+S);var e=(m,y,S)=>(ze(m,y,"read from private field"),S?S.call(m):y.get(m)),f=(m,y,S)=>y.has(m)?We("Cannot add the same private member more than once"):y instanceof WeakSet?y.add(m):y.set(m,S),p=(m,y,S,O)=>(ze(m,y,"write to private field"),O?O.call(m,S):y.set(m,S),S);var Oe=(m,y,S,O)=>({set _(ee){p(m,y,ee,S)},get _(){return e(m,y,O)}});var H,P,w,V,X,F,oe,Y,le,U,I,A,B,$,W,ae,ce,z,K,he,de,fe,ie,T,ue,se,ge,D,Z,q,v,k,G,be,N,pe,ne,ye,me,J,j,we;const qe=class qe extends m.trace.constructor{constructor(){super(),this.init("nine-table","green")}};a(qe,"Trace");let y=qe;const S=new y,ke=class ke extends HTMLElement{constructor(){super();f(this,H);f(this,P,!1);f(this,w);f(this,V);f(this,X);f(this,F);f(this,oe,a(()=>{if(!e(this,H))return;const t=e(this,H).querySelector(".ng-container-body");t&&(p(this,F,new ResizeObserver(()=>{this.refresh()})),e(this,F).observe(t))},"#observeResize"));x(this,"refresh",a(()=>{if(!e(this,H)||!e(this,w)||e(this,P))return;const t=e(this,w).container,s=t.querySelector("table");if(!s)return;const n=e(this,w).track,r=e(this,w).thumb,o=e(this,H).querySelector(".ng-container-bottom"),c=t.clientWidth,b=s.scrollWidth;if(c!==0&&b>c)o&&(o.style.display="flex");else{o&&(o.style.display="none");return}const l=n.clientWidth;if(l<=0)return;const h=Math.max(Math.min(l*(c/b),l),20);r.style.width=`${h}px`;let d=0;const u=s.style.transform;if(u&&u.includes("translateX")){const E=u.match(/translateX\(([-\d.]+)px\)/);E&&E[1]&&(d=parseFloat(E[1]))}else d=parseInt(s.style.left||0,10);let g=parseInt(Math.abs(d)*l/b,10);g<0&&(g=0);const R=l-h;g>R&&(g=R),r.style.left=`${g}px`,e(this,w).left.disabled=g===0,e(this,w).right.disabled=g>=R-1},"refresh"));f(this,Y,a(t=>{if(!e(this,w))return!1;const s=e(this,w).container,n=s.querySelector("table");if(!n)return!1;const r=e(this,w).track.getBoundingClientRect(),o=e(this,w).thumb.clientWidth;let c=t;c<0&&(c=0);const b=r.width-o;c>b&&(c=b),c=parseInt(c,10),e(this,w).thumb.style.left=`${c}px`,e(this,w).left.disabled=c===0,e(this,w).right.disabled=c>=b-1;const l=s.clientWidth,h=n.scrollWidth;let d=b>0?-c*(h-l)/b:0;return-d>h-l&&(d=-(h-l)),-d+5>h-l&&(d=-(h-l)),l>=h&&(d=0),n.style.transform=`translateX(${d}px)`,c>0&&c<b-1},"#thumbMoveTo"));f(this,le,a(()=>{const t=a(n=>{clearInterval(e(this,V)),clearInterval(e(this,X));const r=parseInt(e(this,w).thumb.style.left||0,10);e(this,Y).call(this,r+n),p(this,V,setInterval(()=>{clearInterval(e(this,V)),p(this,X,setInterval(()=>{const o=parseInt(e(this,w).thumb.style.left||0,10);e(this,Y).call(this,o+n)||clearInterval(e(this,X))},50))},500))},"delayScroll"),s=a(()=>{clearInterval(e(this,V)),clearInterval(e(this,X))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(n=>{e(this,w).left.addEventListener(n,s),e(this,w).right.addEventListener(n,s),e(this,w).track.addEventListener(n,s)}),e(this,w).left.addEventListener("mousedown",n=>{n.button===0&&t(-20)}),e(this,w).right.addEventListener("mousedown",n=>{n.button===0&&t(20)}),e(this,w).left.addEventListener("touchstart",()=>t(-20)),e(this,w).right.addEventListener("touchstart",()=>t(20)),e(this,w).track.addEventListener("mousedown",n=>{if(n.button!==0)return;n.preventDefault();const r=e(this,w).track.getBoundingClientRect(),o=e(this,w).thumb.clientWidth;e(this,Y).call(this,n.clientX-r.left-o/2)}),e(this,w).thumb.addEventListener("mousedown",n=>{if(n.button!==0)return;n.stopPropagation(),n.preventDefault(),p(this,P,!0),this.shiftX=n.clientX-e(this,w).thumb.getBoundingClientRect().left;const r=a(c=>{if(!e(this,P))return;const b=e(this,w).track.getBoundingClientRect();e(this,Y).call(this,c.clientX-b.left-this.shiftX)},"onMouseMove"),o=a(()=>{p(this,P,!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,H,this.closest("nine-table-sheet")||this.getRootNode().host),!e(this,H))return;this.innerHTML=`
1
+ (function(m,y){typeof exports=="object"&&typeof module<"u"?y(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],y):(m=typeof globalThis<"u"?globalThis:m||self,y(m.NineboneUtil))})(this,function(m){"use strict";var He=Object.defineProperty;var Ie=m=>{throw TypeError(m)};var Oe=(m,y,S)=>y in m?He(m,y,{enumerable:!0,configurable:!0,writable:!0,value:S}):m[y]=S;var a=(m,y)=>He(m,"name",{value:y,configurable:!0});var x=(m,y,S)=>Oe(m,typeof y!="symbol"?y+"":y,S),$e=(m,y,S)=>y.has(m)||Ie("Cannot "+S);var e=(m,y,S)=>($e(m,y,"read from private field"),S?S.call(m):y.get(m)),g=(m,y,S)=>y.has(m)?Ie("Cannot add the same private member more than once"):y instanceof WeakSet?y.add(m):y.set(m,S),p=(m,y,S,W)=>($e(m,y,"write to private field"),W?W.call(m,S):y.set(m,S),S);var We=(m,y,S,W)=>({set _(J){p(m,y,J,S)},get _(){return e(m,y,W)}});var C,N,w,P,V,X,ne,F,re,Y,_,A,O,M,H,oe,le,I,U,ae,ce,he,ee,T,de,te,fe,z,K,q,v,k,j,ue,B,ge,ie,be,pe,G,Z,ye;const Ee=class Ee extends m.trace.constructor{constructor(){super(),this.init("nine-table","green")}};a(Ee,"Trace");let y=Ee;const S=new y,Te=class Te extends HTMLElement{constructor(){super();g(this,C);g(this,N,!1);g(this,w);g(this,P);g(this,V);g(this,X);g(this,ne,a(()=>{if(!e(this,C))return;const t=e(this,C).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,C)||!e(this,w)||e(this,N))return;const t=e(this,w).container,s=t.querySelector("table");if(!s)return;const n=e(this,w).track,r=e(this,w).thumb,o=e(this,C).querySelector(".ng-container-bottom"),c=t.clientWidth,f=s.scrollWidth;if(c!==0&&f>c)o&&(o.style.display="flex");else{o&&(o.style.display="none");return}const l=n.clientWidth;if(l<=0)return;const d=Math.max(Math.min(l*(c/f),l),20);r.style.width=`${d}px`;let u=0;const b=s.style.transform;if(b&&b.includes("translateX")){const R=b.match(/translateX\(([-\d.]+)px\)/);R&&R[1]&&(u=parseFloat(R[1]))}else u=parseInt(s.style.left||0,10);let h=parseInt(Math.abs(u)*l/f,10);h<0&&(h=0);const E=l-d;h>E&&(h=E),r.style.left=`${h}px`,e(this,w).left.disabled=h===0,e(this,w).right.disabled=h>=E-1},"refresh"));g(this,F,a(t=>{if(!e(this,w))return!1;const s=e(this,w).container,n=s.querySelector("table");if(!n)return!1;const r=e(this,w).track.getBoundingClientRect(),o=e(this,w).thumb.clientWidth;let c=t;c<0&&(c=0);const f=r.width-o;c>f&&(c=f),c=parseInt(c,10),e(this,w).thumb.style.left=`${c}px`,e(this,w).left.disabled=c===0,e(this,w).right.disabled=c>=f-1;const l=s.clientWidth,d=n.scrollWidth;let u=f>0?-c*(d-l)/f:0;return-u>d-l&&(u=-(d-l)),-u+5>d-l&&(u=-(d-l)),l>=d&&(u=0),n.style.transform=`translateX(${u}px)`,c>0&&c<f-1},"#thumbMoveTo"));g(this,re,a(()=>{const t=a(n=>{clearInterval(e(this,P)),clearInterval(e(this,V));const r=parseInt(e(this,w).thumb.style.left||0,10);e(this,F).call(this,r+n),p(this,P,setInterval(()=>{clearInterval(e(this,P)),p(this,V,setInterval(()=>{const o=parseInt(e(this,w).thumb.style.left||0,10);e(this,F).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,w).left.addEventListener(n,s),e(this,w).right.addEventListener(n,s),e(this,w).track.addEventListener(n,s)}),e(this,w).left.addEventListener("mousedown",n=>{n.button===0&&t(-20)}),e(this,w).right.addEventListener("mousedown",n=>{n.button===0&&t(20)}),e(this,w).left.addEventListener("touchstart",()=>t(-20)),e(this,w).right.addEventListener("touchstart",()=>t(20)),e(this,w).track.addEventListener("mousedown",n=>{if(n.button!==0)return;n.preventDefault();const r=e(this,w).track.getBoundingClientRect(),o=e(this,w).thumb.clientWidth;e(this,F).call(this,n.clientX-r.left-o/2)}),e(this,w).thumb.addEventListener("mousedown",n=>{if(n.button!==0)return;n.stopPropagation(),n.preventDefault(),p(this,N,!0),this.shiftX=n.clientX-e(this,w).thumb.getBoundingClientRect().left;const r=a(c=>{if(!e(this,N))return;const f=e(this,w).track.getBoundingClientRect();e(this,F).call(this,c.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,C,this.closest("nine-table-sheet")||this.getRootNode().host),!e(this,C))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=a(()=>{const s=e(this,H).querySelector(".ng-container-body");if(!s){setTimeout(t,10);return}p(this,w,{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,le).call(this),e(this,oe).call(this),this.refresh()},"initWhenReady");t()}disconnectedCallback(){e(this,F)&&e(this,F).disconnect()}};H=new WeakMap,P=new WeakMap,w=new WeakMap,V=new WeakMap,X=new WeakMap,F=new WeakMap,oe=new WeakMap,Y=new WeakMap,le=new WeakMap,a(ke,"NineTableHScrollBar");let O=ke;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",O);const Le=class Le{constructor(i){f(this,U);f(this,I,[]);f(this,A,null);f(this,B,null);f(this,$,0);f(this,W,0);x(this,"getRowHeight",a(()=>e(this,A),"getRowHeight"));f(this,ae,a(()=>{e(this,ce).call(this)},"#init"));f(this,ce,a(()=>{!e(this,U)||!(e(this,U)instanceof HTMLElement)||(p(this,B,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 c=s.querySelector(".ng-container-body")||s,b=c.querySelector("thead"),l=c.querySelector("tfoot");b&&(o+=b.offsetHeight||b.getBoundingClientRect().height),l&&(o+=l.offsetHeight||l.getBoundingClientRect().height);const h=Math.max(r-o,100);if(e(this,$)!==h&&(p(this,$,h),e(this,A)!==null)){const d=Math.ceil(e(this,$)/e(this,A));p(this,W,d+20),S.log(`[RowManager] Resized. Height: ${e(this,$)}px | Target Rows: ${e(this,W)}`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(u=>{const g=s.querySelector(u);g&&g.querySelector("tbody")&&this.renderRows(g)})}}}})),e(this,B).observe(e(this,U)))},"#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,I,s.map(n=>n.cloneNode(!0))),p(this,A,null),console.log(`[RowManager] Template initialized with ${e(this,I).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,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(d=>d.remove());const s=t.querySelector("tr.nodata"),n=document.createDocumentFragment();e(this,I).forEach(d=>{n.appendChild(d.cloneNode(!0))}),s?s.before(n):t.appendChild(n);const r=i.closest("nine-table-sheet"),o=r?r.style.display:"",c=r?r.style.visibility:"",b=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((d,u)=>{const g=d.offsetHeight||d.getBoundingClientRect().height;g===0?l+=40:l+=g}),r&&(r.style.display=o,r.style.visibility=c,r.style.position=b),p(this,A,l),e(this,$)>0){const d=Math.ceil(e(this,$)/e(this,A));p(this,W,d+20)}else p(this,W,40);return console.log(`[RowManager] Template Height Cached: ${e(this,A)}px | RowCount: ${e(this,W)}`),e(this,A)},"measureAndCacheHeight"));x(this,"renderRows",a(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(o=>o.remove());const s=t.querySelector("tr.nodata"),n=document.createDocumentFragment(),r=e(this,W);for(let o=0;o<r;o++)e(this,I).forEach(c=>{n.appendChild(c.cloneNode(!0))});s?s.before(n):t.appendChild(n),console.log(`[RowManager] Rendered ${r} sets into DOM.`)},"renderRows"));x(this,"destroy",a(()=>{e(this,B)&&(e(this,B).disconnect(),p(this,B,null))},"destroy"));p(this,U,i),e(this,ae).call(this)}get templateLength(){return e(this,I).length||1}};U=new WeakMap,I=new WeakMap,A=new WeakMap,B=new WeakMap,$=new WeakMap,W=new WeakMap,ae=new WeakMap,ce=new WeakMap,a(Le,"RowManager");let ee=Le;const te=class te extends HTMLElement{constructor(){super();f(this,z,null);f(this,K);x(this,"generate",a(t=>{if(!t)return;const s=a(l=>{const h=a(u=>{if(u.querySelector("colgroup"))return;const g=u.querySelector("tbody tr")||u.querySelector("tr"),R=g?g.querySelectorAll("th, td").length:1,E=document.createElement("colgroup"),C=Math.max(Math.floor((u.clientWidth||600)/R),100);for(let _=0;_<R;_++){const Q=document.createElement("col");Q.setAttribute("width",C),E.appendChild(Q)}u.prepend(E)},"ensureColgroup"),d=a(u=>{if(u.querySelector("thead"))return;const g=document.createElement("thead"),R=u.querySelector("colgroup");R?R.after(g):u.prepend(g)},"ensureThead");return h(l),d(l),l.classList.add("nine-table-element"),l},"initializeTable"),n=t.cloneNode(!0);p(this,z,s(n)),e(this,z).style.display="table",e(this,K).initTemplate(e(this,z));const r=this.querySelector(".ng-container-left"),o=this.querySelector(".ng-container-body"),c=this.querySelector(".ng-container-right"),b=a((l,h,d=!1)=>{const u=l.cloneNode(!0),g=Array.from(u.querySelectorAll("colgroup col")),R=[];return g.forEach((E,C)=>{const _=E.getAttribute("fixed");(d?_!=="left"&&_!=="right":_===h)||R.push(C)}),R.reverse().forEach(E=>{g[E]&&g[E].remove(),u.querySelectorAll("tr").forEach(C=>{const _=C.querySelectorAll("th, td");_[E]&&_[E].remove()})}),u},"filterTableByFixed");if(o){const l=b(e(this,z),null,!0);o.innerHTML="",o.appendChild(l),e(this,K).measureAndCacheHeight(o)}if(r){const l=b(e(this,z),"left",!1);let h=0;l.querySelectorAll("col").forEach(u=>{const g=parseInt(u.getAttribute("width"),10);isNaN(g)||(h+=g)}),r.innerHTML="",r.appendChild(l);const d=h>0?h:0;r.style.flex=`0 0 ${d}px`,r.style.width=`${d}px`}if(c){const l=b(e(this,z),"right",!1);let h=0;l.querySelectorAll("col").forEach(u=>{const g=parseInt(u.getAttribute("width"),10);isNaN(g)||(h+=g)}),c.innerHTML="",c.appendChild(l);const d=h>0?h:0;c.style.flex=`0 0 ${d}px`,c.style.width=`${d}px`}o&&o.addEventListener("scroll",()=>{var l;this.querySelector("nine-table-hscrollbar"),(l=this.querySelector("nine-table-hscrollbar"))==null||l.refresh()}),requestAnimationFrame(()=>{var C,_,Q;const l=r==null?void 0:r.querySelector("table"),h=o==null?void 0:o.querySelector("table"),d=c==null?void 0:c.querySelector("table");if(!h)return;const u=l?Array.from(l.querySelectorAll("tr")):[],g=Array.from(h.querySelectorAll("tr")),R=d?Array.from(d.querySelectorAll("tr")):[],E=Math.max(u.length,g.length,R.length);for(let M=0;M<E;M++){const Be=[((C=u[M])==null?void 0:C.getBoundingClientRect().height)||0,((_=g[M])==null?void 0:_.getBoundingClientRect().height)||0,((Q=R[M])==null?void 0:Q.getBoundingClientRect().height)||0],ve=Math.max(...Be);ve>0&&(u[M]&&(u[M].style.height=`${ve}px`),g[M]&&(g[M].style.height=`${ve}px`),R[M]&&(R[M].style.height=`${ve}px`))}}),setTimeout(()=>{const l=this.querySelector("nine-table-hscrollbar");l&&typeof l.refresh=="function"&&l.refresh()},0)},"generate"));x(this,"getRowHeight",a(()=>e(this,K).getRowHeight(),"getRowHeight"));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"));f(this,he,a(()=>{e(this,de).call(this)},"#init"));f(this,de,a(()=>{const t=te.SCROLLBAR_SIZE;this.innerHTML=`
63
+ `;const t=a(()=>{const s=e(this,C).querySelector(".ng-container-body");if(!s){setTimeout(t,10);return}p(this,w,{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()}};C=new WeakMap,N=new WeakMap,w=new WeakMap,P=new WeakMap,V=new WeakMap,X=new WeakMap,ne=new WeakMap,F=new WeakMap,re=new WeakMap,a(Te,"NineTableHScrollBar");let W=Te;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",W);const Ae=class Ae{constructor(i){g(this,Y);g(this,_,[]);g(this,A,null);g(this,O,null);g(this,M,0);g(this,H,0);x(this,"getRowHeight",a(()=>e(this,A),"getRowHeight"));g(this,oe,a(()=>{e(this,le).call(this)},"#init"));g(this,le,a(()=>{!e(this,Y)||!(e(this,Y)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 c=s.querySelector(".ng-container-body")||s,f=c.querySelector("thead"),l=c.querySelector("tfoot");f&&(o+=f.offsetHeight||f.getBoundingClientRect().height),l&&(o+=l.offsetHeight||l.getBoundingClientRect().height);const d=Math.max(r-o,100);if(e(this,M)!==d&&(p(this,M,d),e(this,A)!==null)){const u=Math.ceil(e(this,M)/e(this,A));p(this,H,u+20),S.log(`[RowManager] Resized. Height: ${e(this,M)}px | Target Rows: ${e(this,H)}`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(b=>{const h=s.querySelector(b);h&&h.querySelector("tbody")&&this.renderRows(h)})}}}})),e(this,O).observe(e(this,Y)))},"#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,_,s.map(n=>n.cloneNode(!0))),p(this,A,null),console.log(`[RowManager] Template initialized with ${e(this,_).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,_).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(u=>u.remove());const s=t.querySelector("tr.nodata"),n=document.createDocumentFragment();e(this,_).forEach(u=>{n.appendChild(u.cloneNode(!0))}),s?s.before(n):t.appendChild(n);const r=i.closest("nine-table-sheet"),o=r?r.style.display:"",c=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((u,b)=>{const h=u.offsetHeight||u.getBoundingClientRect().height;h===0?l+=40:l+=h}),r&&(r.style.display=o,r.style.visibility=c,r.style.position=f),p(this,A,l),e(this,M)>0){const u=Math.ceil(e(this,M)/e(this,A));p(this,H,u+20)}else p(this,H,40);return console.log(`[RowManager] Template Height Cached: ${e(this,A)}px | RowCount: ${e(this,H)}`),e(this,A)},"measureAndCacheHeight"));x(this,"renderRows",a(i=>{if(e(this,_).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,H);for(let o=0;o<r;o++)e(this,_).forEach(c=>{n.appendChild(c.cloneNode(!0))});s?s.before(n):t.appendChild(n),console.log(`[RowManager] Rendered ${r} sets into DOM.`)},"renderRows"));x(this,"destroy",a(()=>{e(this,O)&&(e(this,O).disconnect(),p(this,O,null))},"destroy"));p(this,Y,i),e(this,oe).call(this)}get templateLength(){return e(this,_).length||1}};Y=new WeakMap,_=new WeakMap,A=new WeakMap,O=new WeakMap,M=new WeakMap,H=new WeakMap,oe=new WeakMap,le=new WeakMap,a(Ae,"RowManager");let J=Ae;const Q=class Q extends HTMLElement{constructor(){super();g(this,I,null);g(this,U);x(this,"generate",a(t=>{if(!t)return;const s=a(l=>{const d=a(b=>{if(b.querySelector("colgroup"))return;const h=b.querySelector("tbody tr")||b.querySelector("tr"),E=h?h.querySelectorAll("th, td").length:1,R=document.createElement("colgroup"),D=Math.max(Math.floor((b.clientWidth||600)/E),100);for(let $=0;$<E;$++){const Me=document.createElement("col");Me.setAttribute("width",D),R.appendChild(Me)}b.prepend(R)},"ensureColgroup"),u=a(b=>{if(b.querySelector("thead"))return;const h=document.createElement("thead"),E=b.querySelector("colgroup");E?E.after(h):b.prepend(h)},"ensureThead");return d(l),u(l),l.classList.add("nine-table-element"),l},"initializeTable"),n=t.cloneNode(!0);p(this,I,s(n)),e(this,I).style.display="table",e(this,U).initTemplate(e(this,I));const r=this.querySelector(".ng-container-left"),o=this.querySelector(".ng-container-body"),c=this.querySelector(".ng-container-right"),f=a((l,d,u=!1)=>{const b=l.cloneNode(!0),h=Array.from(b.querySelectorAll("colgroup col")),E=[];return h.forEach((R,D)=>{const $=R.getAttribute("fixed");(u?$!=="left"&&$!=="right":$===d)||E.push(D)}),E.reverse().forEach(R=>{h[R]&&h[R].remove(),b.querySelectorAll("tr").forEach(D=>{const $=D.querySelectorAll("th, td");$[R]&&$[R].remove()})}),b},"filterTableByFixed");if(o){const l=f(e(this,I),null,!0);o.innerHTML="",o.appendChild(l),e(this,U).measureAndCacheHeight(o)}if(r){const l=f(e(this,I),"left",!1);let d=0;l.querySelectorAll("col").forEach(b=>{const h=parseInt(b.getAttribute("width"),10);isNaN(h)||(d+=h)}),r.innerHTML="",r.appendChild(l);const u=d>0?d:0;r.style.flex=`0 0 ${u}px`,r.style.width=`${u}px`}if(c){const l=f(e(this,I),"right",!1);let d=0;l.querySelectorAll("col").forEach(b=>{const h=parseInt(b.getAttribute("width"),10);isNaN(h)||(d+=h)}),c.innerHTML="",c.appendChild(l);const u=d>0?d:0;c.style.flex=`0 0 ${u}px`,c.style.width=`${u}px`}o&&o.addEventListener("scroll",()=>{var l;this.querySelector("nine-table-hscrollbar"),(l=this.querySelector("nine-table-hscrollbar"))==null||l.refresh()}),setTimeout(()=>{const l=this.querySelector("nine-table-hscrollbar");l&&typeof l.refresh=="function"&&l.refresh()},0)},"generate"));x(this,"getRowHeight",a(()=>e(this,U).getRowHeight(),"getRowHeight"));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"));g(this,ae,a(()=>{e(this,ce).call(this);const t=a(()=>{requestAnimationFrame(()=>{var d,u,b;const s=this.querySelector(".ng-container-left table"),n=this.querySelector(".ng-container-body table"),r=this.querySelector(".ng-container-right table");if(!n)return;const o=s?Array.from(s.querySelectorAll("tr")):[],c=Array.from(n.querySelectorAll("tr")),f=r?Array.from(r.querySelectorAll("tr")):[],l=Math.max(o.length,c.length,f.length);for(let h=0;h<l;h++){const E=[((d=o[h])==null?void 0:d.getBoundingClientRect().height)||0,((u=c[h])==null?void 0:u.getBoundingClientRect().height)||0,((b=f[h])==null?void 0:b.getBoundingClientRect().height)||0],R=Math.max(...E);R>0&&(o[h]&&(o[h].style.height=`${R}px`),c[h]&&(c[h].style.height=`${R}px`),f[h]&&(f[h].style.height=`${R}px`))}})},"syncRowHeights");new MutationObserver(s=>{for(const n of s)n.attributeName==="class"&&this.classList.contains("active")&&t()}).observe(this,{attributes:!0})},"#init"));g(this,ce,a(()=>{const t=Q.SCROLLBAR_SIZE;this.innerHTML=`
64
64
  <style>
65
65
  nine-table-sheet {
66
66
  display: none;
@@ -172,7 +172,7 @@
172
172
  <nine-table-hscrollbar></nine-table-hscrollbar>
173
173
  <div class='ng-scroll-edge'></div>
174
174
  </div>
175
- `},"#render"));p(this,K,new ee(this))}connectedCallback(){e(this,he).call(this)}disconnectedCallback(){this.innerHTML="",S.log("NineTableSheet destroyed.")}};z=new WeakMap,K=new WeakMap,he=new WeakMap,de=new WeakMap,a(te,"NineTableSheet"),x(te,"SCROLLBAR_SIZE",16);let re=te;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",re);const _e=class _e extends HTMLElement{constructor(){super();f(this,fe,a(()=>{var t;(t=this.querySelector(".nine-tab-bar"))==null||t.addEventListener("click",s=>{var o;const n=s.ctrlKey||s.metaKey||s.shiftKey,r=parseInt((o=s.target.closest(".nine-tab-item"))==null?void 0:o.dataset.index,10);e(this,ie).call(this,r,n)}),e(this,ie).call(this,0,!1)},"#init"));f(this,ie,a((t,s=!1)=>{const n=a(()=>{const h=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(g=>g.style.setProperty("display","none"));const u=h.filter(g=>g.classList.contains("active"));u.length<2||u.forEach(g=>{const R=parseInt(g.getAttribute("data-index"),10),E=this.querySelector(`nine-splitter[data-split-index="${R}"]`),C=h[R+1];E&&C&&C.classList.contains("active")&&E.style.setProperty("display","flex")})},"updateSplitters"),r=this.querySelector(".nine-tab-bar"),o=this.querySelector("nine-table-sheets-body"),c=r.querySelectorAll(".nine-tab-item"),b=o.querySelectorAll("nine-table-sheet");if(!c[t])return;if(!s)c.forEach((h,d)=>{h.classList.toggle("active",d===t)}),b.forEach((h,d)=>{const u=d===t;h.classList.toggle("active",u),h.style.flex=u?"1 1 100%":""});else{const h=c[t],d=r.querySelectorAll(".nine-tab-item.active");if(h.classList.contains("active")&&d.length<=1)return;h.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=o.querySelectorAll("nine-table-sheet.active");l==null||l.forEach(h=>{h.style.flex=l.length>1?"1 1 0%":"1 1 100%"}),n()},"#switchSheet"))}connectedCallback(){e(this,fe).call(this)}};fe=new WeakMap,ie=new WeakMap,a(_e,"NineTableSheets");let xe=_e;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",xe);const Ce=class Ce{constructor(i){f(this,T);f(this,ue,a(()=>{e(this,ge).call(this),new ResizeObserver(i=>{for(let t of i)e(this,T).getAttribute("auto-height")==="true"&&e(this,se).call(this)}).observe(e(this,T))},"#init"));f(this,se,a(()=>{var b,l;const i=Array.from(e(this,T).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(i.length===0)return;const t=parseInt(e(this,T).getAttribute("max-display-row"),10)||10,s=Math.max(...i.map(h=>h.getRowHeight())),n=(b=e(this,T).shadowRoot.querySelector("nine-table-header"))==null?void 0:b.getBoundingClientRect().height,r=(l=e(this,T).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:l.getBoundingClientRect().height,o=re.SCROLLBAR_SIZE,c=t*s+n+r+o;e(this,T).style.height=`${c}px`},"#applyAutoHeight"));f(this,ge,a(()=>{const t=Array.from(e(this,T).children).filter(b=>b.tagName==="TABLE"),s=e(this,T).getAttribute("auto-height")==="true",n=t.length,r=t.map((b,l)=>{const d=`<nine-table-sheet class="${l===0?"active":""}" data-index="${l}"></nine-table-sheet>`,u=l<n-1?`<nine-splitter class="h" data-split-index="${l}"></nine-splitter>`:"";return d+u}).join(""),o=t.map((b,l)=>`<div class="nine-tab-item ${l===0?"active":""}" data-index="${l}">Sheet ${l+1}</div>`).join("");e(this,T).shadowRoot.innerHTML=`
175
+ `},"#render"));p(this,U,new J(this))}connectedCallback(){e(this,ae).call(this)}disconnectedCallback(){this.innerHTML="",S.log("NineTableSheet destroyed.")}};I=new WeakMap,U=new WeakMap,ae=new WeakMap,ce=new WeakMap,a(Q,"NineTableSheet"),x(Q,"SCROLLBAR_SIZE",16);let se=Q;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",se);const qe=class qe extends HTMLElement{constructor(){super();g(this,he,a(()=>{var t;(t=this.querySelector(".nine-tab-bar"))==null||t.addEventListener("click",s=>{var o;const n=s.ctrlKey||s.metaKey||s.shiftKey,r=parseInt((o=s.target.closest(".nine-tab-item"))==null?void 0:o.dataset.index,10);e(this,ee).call(this,r,n)}),e(this,ee).call(this,0,!1)},"#init"));g(this,ee,a((t,s=!1)=>{const n=a(()=>{const d=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(h=>h.style.setProperty("display","none"));const b=d.filter(h=>h.classList.contains("active"));b.length<2||b.forEach(h=>{const E=parseInt(h.getAttribute("data-index"),10),R=this.querySelector(`nine-splitter[data-split-index="${E}"]`),D=d[E+1];R&&D&&D.classList.contains("active")&&R.style.setProperty("display","flex")})},"updateSplitters"),r=this.querySelector(".nine-tab-bar"),o=this.querySelector("nine-table-sheets-body"),c=r.querySelectorAll(".nine-tab-item"),f=o.querySelectorAll("nine-table-sheet");if(!c[t])return;if(!s)c.forEach((d,u)=>{d.classList.toggle("active",u===t)}),f.forEach((d,u)=>{const b=u===t;d.classList.toggle("active",b),d.style.flex=b?"1 1 100%":""});else{const d=c[t],u=r.querySelectorAll(".nine-tab-item.active");if(d.classList.contains("active")&&u.length<=1)return;d.classList.toggle("active");const b=o.querySelector(`nine-table-sheet[data-index="${t}"]`);b&&(b.classList.toggle("active"),b.classList.contains("active")||(b.style.flex=""))}const l=o.querySelectorAll("nine-table-sheet.active");l==null||l.forEach(d=>{d.style.flex=l.length>1?"1 1 0%":"1 1 100%"}),n()},"#switchSheet"))}connectedCallback(){e(this,he).call(this)}};he=new WeakMap,ee=new WeakMap,a(qe,"NineTableSheets");let me=qe;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",me);const ke=class ke{constructor(i){g(this,T);g(this,de,a(()=>{e(this,fe).call(this),new ResizeObserver(i=>{for(let t of i)e(this,T).getAttribute("auto-height")==="true"&&e(this,te).call(this)}).observe(e(this,T))},"#init"));g(this,te,a(()=>{var f,l;const i=Array.from(e(this,T).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(i.length===0)return;const t=parseInt(e(this,T).getAttribute("max-display-row"),10)||10,s=Math.max(...i.map(d=>d.getRowHeight())),n=(f=e(this,T).shadowRoot.querySelector("nine-table-header"))==null?void 0:f.getBoundingClientRect().height,r=(l=e(this,T).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:l.getBoundingClientRect().height,o=se.SCROLLBAR_SIZE,c=t*s+n+r+o;e(this,T).style.height=`${c}px`},"#applyAutoHeight"));g(this,fe,a(()=>{const t=Array.from(e(this,T).children).filter(f=>f.tagName==="TABLE"),s=e(this,T).getAttribute("auto-height")==="true",n=t.length,r=t.map((f,l)=>{const u=`<nine-table-sheet class="${l===0?"active":""}" data-index="${l}"></nine-table-sheet>`,b=l<n-1?`<nine-splitter class="h" data-split-index="${l}"></nine-splitter>`:"";return u+b}).join(""),o=t.map((f,l)=>`<div class="nine-tab-item ${l===0?"active":""}" data-index="${l}">Sheet ${l+1}</div>`).join("");e(this,T).shadowRoot.innerHTML=`
176
176
  <style>
177
177
  :host {
178
178
  display: flex;
@@ -270,5 +270,5 @@
270
270
  <nine-table-analysis></nine-table-analysis>
271
271
  </nine-table-body>
272
272
  <nine-table-footer></nine-table-footer>
273
- `;const c=e(this,T).shadowRoot.querySelectorAll("nine-table-sheet");c==null||c.forEach((b,l)=>{t[l]&&setTimeout(()=>{b.generate(t[l]),s&&e(this,se).call(this)})})},"#render"));p(this,T,i),e(this,ue).call(this)}};T=new WeakMap,ue=new WeakMap,se=new WeakMap,ge=new WeakMap,a(Ce,"LayoutManager");let Se=Ce;const Me=class Me{constructor(i){f(this,D);f(this,Z,-1);x(this,"count",a(()=>e(this,D).rawRecords.length,"count"));p(this,D,i)}get at(){return e(this,Z)}set at(i){var s,n;p(this,Z,parseInt(i,10));const t=((n=(s=e(this,D).owner).querySelector)==null?void 0:n.call(s,".ng-container-body"))||e(this,D).owner.body;t&&!t.querySelector(`tbody.bindable tr[data-row="${e(this,Z)}"]`)&&setTimeout(()=>{var r,o;(o=(r=e(this,D).owner).scrollTo_V1)==null||o.call(r,e(this,Z))})}};D=new WeakMap,Z=new WeakMap,a(Me,"ngRow");let Re=Me;const L=class L{constructor(i,t){f(this,q);f(this,v);f(this,k,[]);f(this,G,[]);f(this,be,0);f(this,N,[]);f(this,pe,a(()=>{p(this,N,[]);const i=e(this,q).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,v).rawRecords||[]).forEach(t=>{t.__ng||(t.__ng=e(this,ne).call(this)),t.__ng.height=e(this,N).slice()})},"#initialize"));x(this,"set",a(i=>{this.clear(),this.add(i,!1)},"set"));f(this,ne,a(()=>({rowState:L.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:e(this,N).slice(),o:{},c:{},_:[0,0,0,0,L.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,e(this,N).slice(),-1,{},{}]}),"#getDefaultMeta"));x(this,"reset",a(()=>{p(this,k,[]),p(this,G,[])},"reset"));x(this,"clear",a(()=>{var i;e(this,v).rawRecords=[],p(this,k,[]),p(this,G,[]),(i=e(this,v).viewRecords)!=null&&i.reset&&e(this,v).viewRecords.reset()},"clear"));f(this,ye,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(c=>{o.v.push(r[c]!==void 0&&r[c]!==null?r[c]:"")}),s.push(o)}),s},"#json2Array"));f(this,me,a(i=>(Array.isArray(i)||(i=[i]),i.forEach(t=>{t.__ng=e(this,ne).call(this),t.__ng.rowid=this.nextId,t.__ng.rowState=L.ROW_STATE.INSERT,t.__ng._[0]=t.__ng.rowid}),i),"#defaultInsert"));x(this,"add",a((i,t=!0)=>{var r;i===void 0&&(i={});const s=e(this,ye).call(this,i);e(this,v).rawRecords=e(this,v).rawRecords.concat(e(this,me).call(this,s)),this.resetRecords();const n=this.count()-1;return t||s.forEach((o,c)=>{const b=e(this,v).rawRecords[n-c];b&&(b.__ng.rowState=L.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===L.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=L.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 b;i=parseInt(i,10);const r=(typeof((b=e(this,q).fields)==null?void 0:b.get)=="function"?e(this,q).fields.get():[]).indexOf(t);if(r<0)return;const o=this.getValidData()[i];if(!o)return;const c=o.v[r];c!==s&&o.__ng.rowState!==L.ROW_STATE.INSERT&&(o.__ng.o.hasOwnProperty(t)||(o.__ng.o[t]=c),o.__ng.rowState=L.ROW_STATE.UPDATE),o.v[r]=s,e(this,v).owner.refreshData&&e(this,v).owner.refreshData(i)},"setValue"));x(this,"resetRecords",a(()=>{p(this,G,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"));f(this,J,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,c)=>{r[o]=n.v?n.v[c]: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,J).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,J).call(this,s[i])},"get"));p(this,q,i),p(this,v,t),e(this,pe).call(this)}get source(){return e(this,J).call(this,e(this,v).rawRecords)}set source(i){this.clear(),this.add(i,!1)}get nextId(){return++Oe(this,be)._}get length(){return e(this,k).length}getRowCount(){return this.length}};q=new WeakMap,v=new WeakMap,k=new WeakMap,G=new WeakMap,be=new WeakMap,N=new WeakMap,pe=new WeakMap,ne=new WeakMap,ye=new WeakMap,me=new WeakMap,J=new WeakMap,a(L,"ngData"),x(L,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Ee=L;const He=class He{constructor(i){this.owner=i,this.row=new Re(this),this.data=new Ee(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(He,"ngDataManager");let Te=He;const Ie=class Ie extends HTMLElement{constructor(){super();f(this,j);f(this,we);this.attachShadow({mode:"open"}),p(this,j,new Te(this))}connectedCallback(){p(this,we,new Se(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,j).data}get row(){return e(this,j).row}get dataManager(){return e(this,j)}};j=new WeakMap,we=new WeakMap,a(Ie,"NineTable");let Ae=Ie;customElements.get("nine-table")||customElements.define("nine-table",Ae)});
273
+ `;const c=e(this,T).shadowRoot.querySelectorAll("nine-table-sheet");c==null||c.forEach((f,l)=>{t[l]&&setTimeout(()=>{f.generate(t[l]),s&&e(this,te).call(this)})})},"#render"));p(this,T,i),e(this,de).call(this)}};T=new WeakMap,de=new WeakMap,te=new WeakMap,fe=new WeakMap,a(ke,"LayoutManager");let we=ke;const Le=class Le{constructor(i){g(this,z);g(this,K,-1);x(this,"count",a(()=>e(this,z).rawRecords.length,"count"));p(this,z,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,z).owner).querySelector)==null?void 0:n.call(s,".ng-container-body"))||e(this,z).owner.body;t&&!t.querySelector(`tbody.bindable tr[data-row="${e(this,K)}"]`)&&setTimeout(()=>{var r,o;(o=(r=e(this,z).owner).scrollTo_V1)==null||o.call(r,e(this,K))})}};z=new WeakMap,K=new WeakMap,a(Le,"ngRow");let ve=Le;const L=class L{constructor(i,t){g(this,q);g(this,v);g(this,k,[]);g(this,j,[]);g(this,ue,0);g(this,B,[]);g(this,ge,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"));g(this,ie,a(()=>({rowState:L.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:e(this,B).slice(),o:{},c:{},_:[0,0,0,0,L.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,e(this,B).slice(),-1,{},{}]}),"#getDefaultMeta"));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"));g(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(c=>{o.v.push(r[c]!==void 0&&r[c]!==null?r[c]:"")}),s.push(o)}),s},"#json2Array"));g(this,pe,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=L.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,pe).call(this,s)),this.resetRecords();const n=this.count()-1;return t||s.forEach((o,c)=>{const f=e(this,v).rawRecords[n-c];f&&(f.__ng.rowState=L.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===L.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=L.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 c=o.v[r];c!==s&&o.__ng.rowState!==L.ROW_STATE.INSERT&&(o.__ng.o.hasOwnProperty(t)||(o.__ng.o[t]=c),o.__ng.rowState=L.ROW_STATE.UPDATE),o.v[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"));g(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,c)=>{r[o]=n.v?n.v[c]: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,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++We(this,ue)._}get length(){return e(this,k).length}getRowCount(){return this.length}};q=new WeakMap,v=new WeakMap,k=new WeakMap,j=new WeakMap,ue=new WeakMap,B=new WeakMap,ge=new WeakMap,ie=new WeakMap,be=new WeakMap,pe=new WeakMap,G=new WeakMap,a(L,"ngData"),x(L,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let xe=L;const Ce=class Ce{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([])}};a(Ce,"ngDataManager");let Se=Ce;const _e=class _e extends HTMLElement{constructor(){super();g(this,Z);g(this,ye);this.attachShadow({mode:"open"}),p(this,Z,new Se(this))}connectedCallback(){p(this,ye,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,ye=new WeakMap,a(_e,"NineTable");let Re=_e;customElements.get("nine-table")||customElements.define("nine-table",Re)});
274
274
  //# sourceMappingURL=nine-table.umd.js.map