@ninebone/table 0.0.278 → 0.0.280

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