@ninebone/table 0.0.128 → 0.0.130

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