@ninebone/table 0.0.208 → 0.0.209

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