@ninebone/table 0.0.178 → 0.0.180

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