@ninebone/table 0.0.273 → 0.0.274

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