@ninebone/table 0.0.243 → 0.0.245

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