@ninebone/table 0.0.438 → 0.0.440
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.
- package/dist/nine-table.js +215 -201
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +6 -6
- package/dist/nine-table.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/nine-table.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(m,
|
|
1
|
+
(function(m,p){typeof exports=="object"&&typeof module<"u"?p(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],p):(m=typeof globalThis<"u"?globalThis:m||self,p(m.NineboneUtil))})(this,function(m){"use strict";var me=Object.defineProperty;var xe=m=>{throw TypeError(m)};var Se=(m,p,E)=>p in m?me(m,p,{enumerable:!0,configurable:!0,writable:!0,value:E}):m[p]=E;var c=(m,p)=>me(m,"name",{value:p,configurable:!0});var S=(m,p,E)=>Se(m,typeof p!="symbol"?p+"":p,E),ve=(m,p,E)=>p.has(m)||xe("Cannot "+E);var t=(m,p,E)=>(ve(m,p,"read from private field"),E?E.call(m):p.get(m)),d=(m,p,E)=>p.has(m)?xe("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(m):p.set(m,E),g=(m,p,E,z)=>(ve(m,p,"write to private field"),z?z.call(m,E):p.set(m,E),E);var we=(m,p,E,z)=>({set _(ht){g(m,p,ht,E)},get _(){return t(m,p,z)}});var _,N,x,Y,V,U,qt,X,Tt,B,tt,j,R,dt,ft,kt,O,w,I,k,P,F,ut,et,Lt,Ct,Ht,gt,bt,Mt,_t,yt,It,nt,pt,$t,Wt,it,Ot,K,Z,zt,Nt,st,Bt,Pt,Dt,xt,L,Yt,vt,Vt,wt,ot,C,A,H,rt,Ut,D,Xt,G,St,jt,Ft,lt,J,at,q,Et,Kt,Q,Zt,Gt;const le=class le extends m.trace.constructor{constructor(){super(),this.init("nine-table","green")}};c(le,"Trace");let p=le;const E=new p,ae=class ae extends HTMLElement{constructor(){super();d(this,_);d(this,N,!1);d(this,x);d(this,Y);d(this,V);d(this,U);d(this,qt,c(()=>{if(!t(this,_))return;const e=t(this,_).querySelector(".ng-container-body");e&&(g(this,U,new ResizeObserver(()=>{this.refresh()})),t(this,U).observe(e))},"#observeResize"));S(this,"refresh",c(()=>{if(!t(this,_)||!t(this,x)||t(this,N))return;const e=t(this,x).container,i=e.querySelector("table");if(!i)return;const o=t(this,x).track,r=t(this,x).thumb,s=t(this,_).querySelector(".ng-container-bottom"),l=e.clientWidth,h=i.scrollWidth;if(l!==0&&h>l)s&&(s.style.display="flex");else{s&&(s.style.display="none");return}const a=o.clientWidth;if(a<=0)return;const f=Math.max(Math.min(a*(l/h),a),20);r.style.width=`${f}px`;const u=e.scrollLeft,b=h-l;let y=0;b>0&&(y=parseInt(u/b*(a-f),10)),y<0&&(y=0);const v=a-f;y>v&&(y=v),r.style.left=`${y}px`,E.log(y),t(this,x).left.disabled=y===0,t(this,x).right.disabled=y>=v-1},"refresh"));d(this,X,c(e=>{if(!t(this,x))return!1;const i=t(this,x).container,o=i.querySelector("table");if(!o)return!1;const r=t(this,x).track.getBoundingClientRect(),s=t(this,x).thumb.clientWidth;let l=e;l<0&&(l=0);const h=r.width-s;l>h&&(l=h),l=parseInt(l,10),t(this,x).thumb.style.left=`${l}px`,t(this,x).left.disabled=l===0,t(this,x).right.disabled=l>=h-1;const a=i.clientWidth,u=o.scrollWidth-a;return h>0&&u>0&&(i.scrollLeft=l/h*u),l>0&&l<h-1},"#thumbMoveTo"));d(this,Tt,c(()=>{const e=c(o=>{clearInterval(t(this,Y)),clearInterval(t(this,V));const r=parseInt(t(this,x).thumb.style.left||0,10);t(this,X).call(this,r+o),g(this,Y,setInterval(()=>{clearInterval(t(this,Y)),g(this,V,setInterval(()=>{const s=parseInt(t(this,x).thumb.style.left||0,10);t(this,X).call(this,s+o)||clearInterval(t(this,V))},50))},500))},"delayScroll"),i=c(()=>{clearInterval(t(this,Y)),clearInterval(t(this,V))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(o=>{t(this,x).left.addEventListener(o,i),t(this,x).right.addEventListener(o,i),t(this,x).track.addEventListener(o,i)}),t(this,x).left.addEventListener("mousedown",o=>{o.button===0&&e(-20)}),t(this,x).right.addEventListener("mousedown",o=>{o.button===0&&e(20)}),t(this,x).left.addEventListener("touchstart",()=>e(-20)),t(this,x).right.addEventListener("touchstart",()=>e(20)),t(this,x).track.addEventListener("mousedown",o=>{if(o.button!==0)return;o.preventDefault();const r=t(this,x).track.getBoundingClientRect(),s=t(this,x).thumb.clientWidth;t(this,X).call(this,o.clientX-r.left-s/2)}),t(this,x).thumb.addEventListener("mousedown",o=>{if(o.button!==0)return;o.stopPropagation(),o.preventDefault(),g(this,N,!0),this.shiftX=o.clientX-t(this,x).thumb.getBoundingClientRect().left;const r=c(l=>{if(!t(this,N))return;const h=t(this,x).track.getBoundingClientRect();t(this,X).call(this,l.clientX-h.left-this.shiftX)},"onMouseMove"),s=c(()=>{g(this,N,!1),i(),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",s),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",s)})},"#init"))}connectedCallback(){if(g(this,_,this.closest("nine-table-sheet")||this.getRootNode().host),!t(this,_))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 e=c(()=>{const
|
|
63
|
+
`;const e=c(()=>{const i=t(this,_).querySelector(".ng-container-body");if(!i){setTimeout(e,10);return}g(this,x,{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")}),i.addEventListener("scroll",()=>{t(this,N)||this.refresh()}),t(this,Tt).call(this),t(this,qt).call(this),this.refresh()},"initWhenReady");e()}disconnectedCallback(){t(this,U)&&t(this,U).disconnect()}};_=new WeakMap,N=new WeakMap,x=new WeakMap,Y=new WeakMap,V=new WeakMap,U=new WeakMap,qt=new WeakMap,X=new WeakMap,Tt=new WeakMap,c(ae,"NineTableHScrollBar");let z=ae;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",z);const ce=class ce extends HTMLElement{constructor(){super();d(this,B);d(this,tt);d(this,j,!1);d(this,R);d(this,dt,0);d(this,ft,0);S(this,"refresh",c(()=>{if(!t(this,B)||!t(this,R))return;const e=t(this,R).container,i=t(this,R).track,o=t(this,R).thumb,r=e.clientHeight,l=(t(this,B).data.get()||[]).length,h=t(this,tt).getRowHeight(),a=l*h;if(a<=r){o.style.display="none",t(this,R).top.disabled=!0,t(this,R).bottom.disabled=!0;return}else o.style.display="block";const f=i.clientHeight;if(f<=0)return;const u=Math.max(Math.min(f*(r/a),f),20);o.style.height=`${u}px`;const b=e.scrollTop,y=Math.max(a-r,1);let v=0;y>0&&(v=b/y*(f-u));const T=f-u;v<0&&(v=0),v>T&&(v=T),o.style.top=`${v}px`,t(this,R).top.disabled=b<=0,t(this,R).bottom.disabled=b>=y-1},"refresh"));d(this,kt,c(()=>{const e=t(this,R).container,i=c(()=>{const r=(t(this,B).data.get()||[]).length,s=t(this,tt).getRowHeight();return r*s},"getContentHeight");e.addEventListener("scroll",()=>{t(this,j)||this.refresh()}),t(this,R).thumb.addEventListener("mousedown",o=>{if(o.button!==0)return;o.stopPropagation(),o.preventDefault(),g(this,j,!0),g(this,dt,o.clientY),g(this,ft,e.scrollTop);const r=c(l=>{if(!t(this,j))return;const h=t(this,R).track.getBoundingClientRect(),a=t(this,R).thumb.clientHeight,u=h.height-a,b=l.clientY-t(this,dt),y=e.clientHeight,v=i(),T=Math.max(v-y,1);if(u>0&&T>0){const ct=b/u*T;let Rt=t(this,ft)+ct;const pe=Math.max(0,v-y);Rt<0&&(Rt=0),Rt>pe&&(Rt=pe),e.scrollTop=Rt}this.refresh()},"onMouseMove"),s=c(()=>{g(this,j,!1),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",s),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",s)}),t(this,R).track.addEventListener("mousedown",o=>{if(o.button!==0||o.target===t(this,R).thumb)return;const r=t(this,R).track.getBoundingClientRect(),s=t(this,R).thumb.clientHeight,l=o.clientY-r.top-s/2,a=r.height-s,f=e.clientHeight,u=i(),b=Math.max(u-f,1);if(a>0&&b>0){const y=Math.max(0,Math.min(1,l/a));e.scrollTop=y*b}this.refresh()}),t(this,R).top.addEventListener("click",()=>{e.scrollTop-=40}),t(this,R).bottom.addEventListener("click",()=>{e.scrollTop+=40})},"#init"))}connectedCallback(){g(this,B,this.getRootNode().host),g(this,tt,this.closest("nine-table-sheet")),this.innerHTML=`
|
|
64
64
|
<style>
|
|
65
65
|
nine-table-vscrollbar {
|
|
66
66
|
display: flex;
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
<button class='ng-scroll-top' disabled><div class='ng-scroll-icon'></div></button>
|
|
124
124
|
<div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
|
|
125
125
|
<button class='ng-scroll-bottom' disabled><div class='ng-scroll-icon'></div></button>
|
|
126
|
-
`;const e=c(()=>{const n=t(this,P).shadowRoot.querySelector(".ng-container-body .ng-part-body");if(!n){setTimeout(e,10);return}b(this,E,{container:n,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),top:this.querySelector(".ng-scroll-top"),bottom:this.querySelector(".ng-scroll-bottom")}),t(this,kt).call(this),this.refresh()},"initWhenReady");e()}};P=new WeakMap,tt=new WeakMap,j=new WeakMap,E=new WeakMap,dt=new WeakMap,ft=new WeakMap,kt=new WeakMap,c(ae,"NineTableVScrollBar");let ht=ae;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",ht);const ce=class ce{constructor(i){d(this,O);d(this,R);d(this,I,new Map);d(this,k,null);d(this,D,null);d(this,F,0);d(this,ut,40);d(this,et,!1);d(this,Lt,3);w(this,"refresh",c(()=>{var e;const i=t(this,R).querySelector(".ng-container-body .ng-part-body");i&&(t(this,bt).call(this),t(this,it).call(this,i.scrollTop),(e=t(this,R).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));w(this,"initialize",c(()=>{b(this,k,null),t(this,I).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const r=t(this,R).querySelector(o);if(!r)return;const s=r.querySelector(".ng-part-body table");if(!s)return;const l=s.querySelector("tbody.bindable-tbody");if(!l)return;const a=Array.from(l.querySelectorAll("tr")).map(f=>f.cloneNode(!0));t(this,I).set(o,a)});const i=t(this,R).querySelector(".ng-container-body .ng-part-body"),e=t(this,R).querySelector(".ng-container-left .ng-part-body"),n=t(this,R).querySelector(".ng-container-right .ng-part-body");if(i){t(this,Ht).call(this,i),t(this,pt).call(this),t(this,bt).call(this),t(this,it).call(this,i.scrollTop);let o=i.scrollTop;const r=c(s=>{var l;e&&e.scrollTop!==s&&(e.scrollTop=s),n&&n.scrollTop!==s&&(n.scrollTop=s),t(this,it).call(this,s),(l=t(this,R).querySelector("nine-table-vscrollbar"))==null||l.refresh()},"syncScroll");i.addEventListener("scroll",()=>{const s=i.scrollTop;o!==s&&(o=s,r(s))})}},"initialize"));d(this,Ct,c((i,e)=>{const n=t(this,I).get(e);if(!n||n.length===0)return;const o=i.querySelector(".ng-part-body tbody.bindable-tbody");if(!o)return;o.querySelectorAll("tr:not(.nodata)").forEach(l=>l.remove());const r=o.querySelector("tr.nodata"),s=document.createDocumentFragment();for(let l=0;l<t(this,ut);l++)n.forEach(h=>{s.appendChild(h.cloneNode(!0))});r?r.before(s):o.appendChild(s)},"#renderRows"));d(this,Ht,c(i=>{if(t(this,k)!==null&&t(this,k)>0)return t(this,k);const e=t(this,I).get(".ng-container-body");if(!e||e.length===0)return 24;const n=i.querySelector("tbody.bindable-tbody");if(!n)return 24;n.querySelectorAll("tr:not(.nodata)").forEach(g=>g.remove());const o=n.querySelector("tr.nodata"),r=document.createDocumentFragment();e.forEach(g=>{r.appendChild(g.cloneNode(!0))}),o?o.before(r):n.appendChild(r);const s=t(this,R),l=s.style.display,h=s.style.visibility,a=s.style.position;(l==="none"||window.getComputedStyle(s).display==="none")&&(s.style.display="block",s.style.visibility="hidden",s.style.position="absolute");let f=0;const u=n.querySelectorAll("tr:not(.nodata)");return u.forEach(g=>{f+=g.offsetHeight||g.getBoundingClientRect().height}),u.forEach(g=>g.remove()),s.style.display=l,s.style.visibility=h,s.style.position=a,b(this,k,f>0?f:24),t(this,gt).call(this),t(this,k)},"#measureAndCacheHeight"));d(this,bt,c(()=>{const e=(t(this,O).data.get()||[]).length,n=t(this,k)||24,o=e*n;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(r=>{const s=t(this,R).querySelector(r);if(!s)return;const l=s.querySelector(".ng-part-body .ng-virtual-spacer");l&&(l.style.height=`${o}px`)})},"#updateVirtualScrollHeight"));d(this,gt,c(()=>{if(t(this,F)>0&&t(this,k)>0){const i=Math.ceil(t(this,F)/t(this,k));b(this,ut,i+t(this,Lt))}},"#updateRowCount"));d(this,Mt,c(()=>{var h,a,f;const i=t(this,R).querySelector(".ng-container-left .ng-part-body table"),e=t(this,R).querySelector(".ng-container-body .ng-part-body table"),n=t(this,R).querySelector(".ng-container-right .ng-part-body table");if(!e)return;const o=i?Array.from(i.querySelectorAll("tr")):[],r=Array.from(e.querySelectorAll("tr")),s=n?Array.from(n.querySelectorAll("tr")):[],l=Math.max(o.length,r.length,s.length);for(let u=0;u<l;u++){const g=[((h=o[u])==null?void 0:h.getBoundingClientRect().height)||0,((a=r[u])==null?void 0:a.getBoundingClientRect().height)||0,((f=s[u])==null?void 0:f.getBoundingClientRect().height)||0],p=Math.max(...g);p>0&&(o[u]&&(o[u].style.height=`${p}px`),r[u]&&(r[u].style.height=`${p}px`),s[u]&&(s[u].style.height=`${p}px`))}},"#syncRowHeights"));d(this,_t,c(()=>{!t(this,R)||!(t(this,R)instanceof HTMLElement)||(b(this,D,new ResizeObserver(i=>{for(const e of i){const n=e.target;if(!n.classList.contains("active"))continue;const o=e.contentRect.height;if(o>0){let r=0;const s=n.querySelector(".ng-part-header"),l=n.querySelector(".ng-part-footer");s&&(r+=s.offsetHeight),l&&(r+=l.offsetHeight);const h=Math.max(o-r,100);t(this,F)!==h&&(b(this,F,h),t(this,gt).call(this),t(this,k)!==null&&t(this,pt).call(this))}}})),t(this,D).observe(t(this,R)))},"#initResizeObserver"));d(this,pt,c(()=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(i=>{const e=t(this,R).querySelector(i);e&&e.querySelector(".ng-part-body tbody.bindable-tbody")&&t(this,Ct).call(this,e,i)}),t(this,Mt).call(this)},"#renderAllContainers"));d(this,It,c(i=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(e=>{var a;const n=t(this,R).querySelector(e);if(!n)return;const o=n.querySelector(".ng-part-body tbody.bindable-tbody");if(!o)return;const r=Array.from(o.querySelectorAll("tr:not(.nodata)")),s=((a=t(this,I).get(e))==null?void 0:a.length)||1,h=(t(this,O).data.get()||[]).length;r.forEach((f,u)=>{const g=i+Math.floor(u/s);if(g>=h){f.style.display="none";return}const p=t(this,O).data.get(g);f.style.display="",t(this,yt).call(this,f,p,g)})})},"#adjustBufferRows"));d(this,it,c(i=>{var h;const e=t(this,k);if(!e||e<=0)return;const o=(t(this,O).data.get()||[]).length,r=Math.max(0,Math.floor(i/e)),s=r*e,l=((h=t(this,I).get(".ng-container-body"))==null?void 0:h.length)||1;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(a=>{const f=t(this,R).querySelector(a);if(!f)return;const u=f.querySelector(".ng-part-body tbody.bindable-tbody");if(!u)return;u.style.transform=`translateY(${s}px)`,Array.from(u.querySelectorAll("tr:not(.nodata)")).forEach((p,x)=>{const T=r+Math.floor(x/l);if(T>=o){p.style.display="none";return}const ct=t(this,O).data.get(T);p.style.display="",t(this,yt).call(this,p,ct,T)})}),t(this,et)||(b(this,et,!0),setTimeout(()=>{t(this,It).call(this,r),b(this,et,!1)},0))},"#handleScroll"));d(this,yt,c((i,e,n)=>{i.dataset.row=n,Array.from(i.cells).forEach((o,r)=>{const s=o.dataset.bind;s&&e&&e[s]!==void 0?o.textContent=e[s]:o.textContent=e?e[Object.keys(e)[r]]??`R${n}C${r}`:`행 ${n+1}`,o.dataset.row=n})},"#bindRowData"));w(this,"destroy",c(()=>{t(this,D)&&(t(this,D).disconnect(),b(this,D,null))},"destroy"));b(this,O,i.getRootNode().host),b(this,R,i),t(this,_t).call(this)}getRowHeight(){return t(this,k)}templateLength(i=".ng-container-body"){var e;return((e=t(this,I).get(i))==null?void 0:e.length)||1}};O=new WeakMap,R=new WeakMap,I=new WeakMap,k=new WeakMap,D=new WeakMap,F=new WeakMap,ut=new WeakMap,et=new WeakMap,Lt=new WeakMap,Ct=new WeakMap,Ht=new WeakMap,bt=new WeakMap,gt=new WeakMap,Mt=new WeakMap,_t=new WeakMap,pt=new WeakMap,It=new WeakMap,it=new WeakMap,yt=new WeakMap,c(ce,"RowManager");let Gt=ce;const W=class W{static compileAll(i){return Array.isArray(i)?i.map(e=>W.compile(e)):[]}static compile(i){var o,r,s,l;if(!i)return null;const e=i.cloneNode(!0);return t(o=W,$t).call(o,e),t(r=W,nt).call(r,e,"thead"),t(s=W,nt).call(s,e,"tbody"),t(l=W,nt).call(l,e,"tfoot"),Array.from(e.querySelectorAll("colgroup col")).forEach((h,a)=>{const f=h.getAttribute("fixed");f&&e.querySelectorAll(`thead [data-col="${a}"], tbody [data-col="${a}"], tfoot [data-col="${a}"]`).forEach(u=>{u.setAttribute("fixed",f)})}),e}};$t=new WeakMap,nt=new WeakMap,c(W,"TableCompiler"),d(W,$t,c(i=>{if(!i.querySelector("colgroup")){const e=i.querySelector("tbody tr")||i.querySelector("tr"),n=e?e.querySelectorAll("th, td").length:1,o=document.createElement("colgroup"),r=Math.max(Math.floor(i.clientWidth/n),100);for(let s=0;s<n;s++){const l=document.createElement("col");l.setAttribute("width",r),o.appendChild(l)}i.prepend(o)}if(!i.querySelector("thead")){const e=document.createElement("thead"),n=i.querySelector("colgroup");n?n.after(e):i.prepend(e)}i.classList.add("nine-table-element"),i.style.display="table"},"#ensureTableStructure")),d(W,nt,c((i,e)=>{const n=Array.from(i.querySelectorAll(e+" tr")),o=Array.from(i.querySelectorAll(e+" th,"+e+" td")),r=n.length;if(r===0||o.length===0)return;let s=0;o.forEach(h=>{s+=h.colSpan||1});const l=Array.from(Array(r),()=>Array(s).fill(null));n.forEach(h=>{const a=h.sectionRowIndex;let f=0;Array.from(h.querySelectorAll("th,td")).forEach(u=>{for(let x=0;x<l[a].length;x++)if(l[a][x]===null){f=x;break}const g=u.rowSpan||1,p=u.colSpan||1;for(let x=0;x<g;x++)for(let T=0;T<p;T++)a+x<r&&f+T<s&&(l[a+x][f+T]=x===0&&T===0?"1":"0")})}),n.forEach(h=>{const a=h.sectionRowIndex;Array.from(h.querySelectorAll("th,td")).forEach(f=>{for(let u=0;u<l[a].length;u++)if(l[a][u]==="1"){f.dataset.col=u,l[a][u]="0";break}})})},"#resetColIndex"));let Jt=W;const mt=class mt extends HTMLElement{constructor(){super();d(this,Wt);d(this,K,null);d(this,Z);w(this,"invalidate",c(()=>{var e,n;t(this,Z).refresh(),(e=this.querySelector("nine-table-hscrollbar"))==null||e.refresh(),(n=this.querySelector("nine-table-vscrollbar"))==null||n.refresh()},"invalidate"));d(this,Ot,c(()=>{[{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=this.querySelector(n);if(!r)return;r.innerHTML="";const s=document.createElement("div");s.className="ng-part-header",s.appendChild(t(this,st).call(this,t(this,K),o,"header"));const l=document.createElement("div");l.className="ng-part-body";const h=document.createElement("div");h.className="ng-scroll-content",h.style.position="relative",h.style.width="100%",h.appendChild(t(this,st).call(this,t(this,K),o,"body"));const a=document.createElement("div");a.className="ng-virtual-spacer",a.style.width="100%",a.style.pointerEvents="none",h.appendChild(a),l.appendChild(h);const f=document.createElement("div");f.className="ng-part-footer",f.appendChild(t(this,st).call(this,t(this,K),o,"footer")),r.appendChild(s),r.appendChild(l),r.appendChild(f)})},"#renderSplitContainers"));d(this,zt,c(()=>{["left","right","body"].forEach(e=>{const n=this.querySelector(`.ng-container-${e}`),o=n==null?void 0:n.querySelectorAll("table");if(!n||!o||o.length===0)return;let r=0;o[0].querySelectorAll("col").forEach(s=>{const l=parseInt(s.getAttribute("width"),10);isNaN(r)||(r+=l)}),e==="body"?n.style.flex="1":(n.style.flex=`0 0 ${r}px`,n.style.width=`${r}px`)})},"#updateContainerWidths"));w(this,"generate",c(e=>{e&&(b(this,K,Jt.compile(e)),t(this,Ot).call(this),t(this,zt).call(this),t(this,Z).initialize(),setTimeout(()=>{var n;(n=this.querySelector("nine-table-hscrollbar"))==null||n.refresh()},0))},"generate"));d(this,st,c((e,n,o)=>{const r=e.cloneNode(!0),s=r.querySelector("thead"),l=r.querySelector("tbody"),h=r.querySelector("tfoot");if(o==="header"){if(l&&l.remove(),h&&h.remove(),e.querySelector("tbody")){const f=document.createElement("tbody");f.className="fixed-tbody",r.appendChild(f)}}else o==="body"?(s&&s.remove(),h&&h.remove(),l&&(l.className="bindable-tbody")):o==="footer"&&(s&&s.remove(),l&&l.remove());return n==="left"?r.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(a=>{a.getAttribute("fixed")!=="left"&&a.remove()}):n==="right"?r.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(a=>{a.getAttribute("fixed")!=="right"&&a.remove()}):r.querySelectorAll("[fixed=left], [fixed=right]").forEach(a=>{a.remove()}),r},"#createSplitTable"));w(this,"getRowHeight",c(()=>t(this,Z).getRowHeight(),"getRowHeight"));w(this,"scrollToX",c(e=>{const n=this.querySelector(".ng-container-body .ng-part-body");n&&(n.scrollLeft=e)},"scrollToX"));w(this,"scrollToY",c(e=>{const n=this.querySelector(".ng-container-body .ng-part-body");n&&(n.scrollTop=e)},"scrollToY"));d(this,Nt,c(()=>{t(this,Pt).call(this)},"#init"));d(this,Pt,c(()=>{const e=mt.SCROLLBAR_SIZE;this.innerHTML=`
|
|
126
|
+
`;const e=c(()=>{const i=t(this,B).shadowRoot.querySelector(".ng-container-body .ng-part-body");if(!i){setTimeout(e,10);return}g(this,R,{container:i,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),top:this.querySelector(".ng-scroll-top"),bottom:this.querySelector(".ng-scroll-bottom")}),t(this,kt).call(this),this.refresh()},"initWhenReady");e()}};B=new WeakMap,tt=new WeakMap,j=new WeakMap,R=new WeakMap,dt=new WeakMap,ft=new WeakMap,kt=new WeakMap,c(ce,"NineTableVScrollBar");let ht=ce;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",ht);const he=class he{constructor(n){d(this,O);d(this,w);d(this,I,new Map);d(this,k,null);d(this,P,null);d(this,F,0);d(this,ut,40);d(this,et,!1);d(this,Lt,3);S(this,"refresh",c(()=>{var e;const n=t(this,w).querySelector(".ng-container-body .ng-part-body");n&&(t(this,gt).call(this),t(this,nt).call(this,n.scrollTop),(e=t(this,w).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));S(this,"initialize",c(()=>{g(this,k,null),t(this,I).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const r=t(this,w).querySelector(o);if(!r)return;const s=r.querySelector(".ng-part-body table");if(!s)return;const l=s.querySelector("tbody.bindable-tbody");if(!l)return;const a=Array.from(l.querySelectorAll("tr")).map(f=>f.cloneNode(!0));t(this,I).set(o,a)});const n=t(this,w).querySelector(".ng-container-body .ng-part-body"),e=t(this,w).querySelector(".ng-container-left .ng-part-body"),i=t(this,w).querySelector(".ng-container-right .ng-part-body");if(n){t(this,Ht).call(this,n),t(this,yt).call(this),t(this,gt).call(this),t(this,nt).call(this,n.scrollTop);let o=n.scrollTop;const r=c(s=>{var l;e&&e.scrollTop!==s&&(e.scrollTop=s),i&&i.scrollTop!==s&&(i.scrollTop=s),t(this,nt).call(this,s),(l=t(this,w).querySelector("nine-table-vscrollbar"))==null||l.refresh()},"syncScroll");n.addEventListener("scroll",()=>{const s=n.scrollTop;o!==s&&(o=s,r(s))})}},"initialize"));d(this,Ct,c((n,e)=>{const i=t(this,I).get(e);if(!i||i.length===0)return;const o=n.querySelector(".ng-part-body tbody.bindable-tbody");if(!o)return;o.querySelectorAll("tr:not(.nodata)").forEach(l=>l.remove());const r=o.querySelector("tr.nodata"),s=document.createDocumentFragment();for(let l=0;l<t(this,ut);l++)i.forEach(h=>{s.appendChild(h.cloneNode(!0))});r?r.before(s):o.appendChild(s)},"#renderRows"));d(this,Ht,c(n=>{if(t(this,k)!==null&&t(this,k)>0)return t(this,k);const e=t(this,I).get(".ng-container-body");if(!e||e.length===0)return 24;const i=n.querySelector("tbody.bindable-tbody");if(!i)return 24;i.querySelectorAll("tr:not(.nodata)").forEach(b=>b.remove());const o=i.querySelector("tr.nodata"),r=document.createDocumentFragment();e.forEach(b=>{r.appendChild(b.cloneNode(!0))}),o?o.before(r):i.appendChild(r);const s=t(this,w),l=s.style.display,h=s.style.visibility,a=s.style.position;(l==="none"||window.getComputedStyle(s).display==="none")&&(s.style.display="block",s.style.visibility="hidden",s.style.position="absolute");let f=0;const u=i.querySelectorAll("tr:not(.nodata)");return u.forEach(b=>{f+=b.offsetHeight||b.getBoundingClientRect().height}),u.forEach(b=>b.remove()),s.style.display=l,s.style.visibility=h,s.style.position=a,g(this,k,f>0?f:24),t(this,bt).call(this),t(this,k)},"#measureAndCacheHeight"));d(this,gt,c(()=>{const e=(t(this,O).data.get()||[]).length,i=t(this,k)||24,o=e*i;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(r=>{const s=t(this,w).querySelector(r);if(!s)return;const l=s.querySelector(".ng-part-body .ng-virtual-spacer");l&&(l.style.height=`${o}px`)})},"#updateVirtualScrollHeight"));d(this,bt,c(()=>{if(t(this,F)>0&&t(this,k)>0){const n=Math.ceil(t(this,F)/t(this,k));g(this,ut,n+t(this,Lt))}},"#updateRowCount"));d(this,Mt,c(()=>{var h,a,f;const n=t(this,w).querySelector(".ng-container-left .ng-part-body table"),e=t(this,w).querySelector(".ng-container-body .ng-part-body table"),i=t(this,w).querySelector(".ng-container-right .ng-part-body table");if(!e)return;const o=n?Array.from(n.querySelectorAll("tr")):[],r=Array.from(e.querySelectorAll("tr")),s=i?Array.from(i.querySelectorAll("tr")):[],l=Math.max(o.length,r.length,s.length);for(let u=0;u<l;u++){const b=[((h=o[u])==null?void 0:h.getBoundingClientRect().height)||0,((a=r[u])==null?void 0:a.getBoundingClientRect().height)||0,((f=s[u])==null?void 0:f.getBoundingClientRect().height)||0],y=Math.max(...b);y>0&&(o[u]&&(o[u].style.height=`${y}px`),r[u]&&(r[u].style.height=`${y}px`),s[u]&&(s[u].style.height=`${y}px`))}},"#syncRowHeights"));d(this,_t,c(()=>{!t(this,w)||!(t(this,w)instanceof HTMLElement)||(g(this,P,new ResizeObserver(n=>{for(const e of n){const i=e.target;if(!i.classList.contains("active"))continue;const o=e.contentRect.height;if(o>0){let r=0;const s=i.querySelector(".ng-part-header"),l=i.querySelector(".ng-part-footer");s&&(r+=s.offsetHeight),l&&(r+=l.offsetHeight);const h=Math.max(o-r,100);t(this,F)!==h&&(g(this,F,h),t(this,bt).call(this),t(this,k)!==null&&t(this,yt).call(this))}}})),t(this,P).observe(t(this,w)))},"#initResizeObserver"));d(this,yt,c(()=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,w).querySelector(n);e&&e.querySelector(".ng-part-body tbody.bindable-tbody")&&t(this,Ct).call(this,e,n)}),t(this,$t).call(this),t(this,Mt).call(this)},"#renderAllContainers"));d(this,It,c(n=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(e=>{var a;const i=t(this,w).querySelector(e);if(!i)return;const o=i.querySelector(".ng-part-body tbody.bindable-tbody");if(!o)return;const r=Array.from(o.querySelectorAll("tr:not(.nodata)")),s=((a=t(this,I).get(e))==null?void 0:a.length)||1,h=(t(this,O).data.get()||[]).length;r.forEach((f,u)=>{const b=n+Math.floor(u/s);if(b>=h){f.style.display="none";return}const y=t(this,O).data.get(b);f.style.display="",t(this,pt).call(this,f,y,b)})})},"#adjustBufferRows"));d(this,nt,c(n=>{var h;const e=t(this,k);if(!e||e<=0)return;const o=(t(this,O).data.get()||[]).length,r=Math.max(0,Math.floor(n/e)),s=r*e,l=((h=t(this,I).get(".ng-container-body"))==null?void 0:h.length)||1;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(a=>{const f=t(this,w).querySelector(a);if(!f)return;const u=f.querySelector(".ng-part-body tbody.bindable-tbody");if(!u)return;u.style.transform=`translateY(${s}px)`,Array.from(u.querySelectorAll("tr:not(.nodata)")).forEach((y,v)=>{const T=r+Math.floor(v/l);if(T>=o){y.style.display="none";return}const ct=t(this,O).data.get(T);y.style.display="",t(this,pt).call(this,y,ct,T)})}),t(this,et)||(g(this,et,!0),setTimeout(()=>{t(this,It).call(this,r),g(this,et,!1)},0))},"#handleScroll"));d(this,pt,c((n,e,i)=>{n.dataset.row=i,Array.from(n.cells).forEach((o,r)=>{const s=o.dataset.bind;s&&e&&e[s]!==void 0?o.textContent=e[s]:o.textContent=e?e[Object.keys(e)[r]]??`R${i}C${r}`:`행 ${i+1}`,o.dataset.row=i})},"#bindRowData"));d(this,$t,c(()=>{var h,a,f;const n=t(this,w).querySelector(".ng-container-left .ng-part-header table"),e=t(this,w).querySelector(".ng-container-body .ng-part-header table"),i=t(this,w).querySelector(".ng-container-right .ng-part-header table");if(!e)return;const o=n?Array.from(n.querySelectorAll("tr")):[],r=Array.from(e.querySelectorAll("tr")),s=i?Array.from(i.querySelectorAll("tr")):[],l=Math.max(o.length,r.length,s.length);for(let u=0;u<l;u++){const b=[((h=o[u])==null?void 0:h.getBoundingClientRect().height)||0,((a=r[u])==null?void 0:a.getBoundingClientRect().height)||0,((f=s[u])==null?void 0:f.getBoundingClientRect().height)||0],y=Math.max(...b);y>0&&(o[u]&&(o[u].style.height=`${y}px`),r[u]&&(r[u].style.height=`${y}px`),s[u]&&(s[u].style.height=`${y}px`))}},"#syncHeaderHeights"));S(this,"destroy",c(()=>{t(this,P)&&(t(this,P).disconnect(),g(this,P,null))},"destroy"));g(this,O,n.getRootNode().host),g(this,w,n),t(this,_t).call(this)}getRowHeight(){return t(this,k)}templateLength(n=".ng-container-body"){var e;return((e=t(this,I).get(n))==null?void 0:e.length)||1}};O=new WeakMap,w=new WeakMap,I=new WeakMap,k=new WeakMap,P=new WeakMap,F=new WeakMap,ut=new WeakMap,et=new WeakMap,Lt=new WeakMap,Ct=new WeakMap,Ht=new WeakMap,gt=new WeakMap,bt=new WeakMap,Mt=new WeakMap,_t=new WeakMap,yt=new WeakMap,It=new WeakMap,nt=new WeakMap,pt=new WeakMap,$t=new WeakMap,c(he,"RowManager");let Jt=he;const W=class W{static compileAll(n){return Array.isArray(n)?n.map(e=>W.compile(e)):[]}static compile(n){var o,r,s,l;if(!n)return null;const e=n.cloneNode(!0);return t(o=W,Wt).call(o,e),t(r=W,it).call(r,e,"thead"),t(s=W,it).call(s,e,"tbody"),t(l=W,it).call(l,e,"tfoot"),Array.from(e.querySelectorAll("colgroup col")).forEach((h,a)=>{const f=h.getAttribute("fixed");f&&e.querySelectorAll(`thead [data-col="${a}"], tbody [data-col="${a}"], tfoot [data-col="${a}"]`).forEach(u=>{u.setAttribute("fixed",f)})}),e}};Wt=new WeakMap,it=new WeakMap,c(W,"TableCompiler"),d(W,Wt,c(n=>{if(!n.querySelector("colgroup")){const e=n.querySelector("tbody tr")||n.querySelector("tr"),i=e?e.querySelectorAll("th, td").length:1,o=document.createElement("colgroup"),r=Math.max(Math.floor(n.clientWidth/i),100);for(let s=0;s<i;s++){const l=document.createElement("col");l.setAttribute("width",r),o.appendChild(l)}n.prepend(o)}if(!n.querySelector("thead")){const e=document.createElement("thead"),i=n.querySelector("colgroup");i?i.after(e):n.prepend(e)}n.classList.add("nine-table-element"),n.style.display="table"},"#ensureTableStructure")),d(W,it,c((n,e)=>{const i=Array.from(n.querySelectorAll(e+" tr")),o=Array.from(n.querySelectorAll(e+" th,"+e+" td")),r=i.length;if(r===0||o.length===0)return;let s=0;o.forEach(h=>{s+=h.colSpan||1});const l=Array.from(Array(r),()=>Array(s).fill(null));i.forEach(h=>{const a=h.sectionRowIndex;let f=0;Array.from(h.querySelectorAll("th,td")).forEach(u=>{for(let v=0;v<l[a].length;v++)if(l[a][v]===null){f=v;break}const b=u.rowSpan||1,y=u.colSpan||1;for(let v=0;v<b;v++)for(let T=0;T<y;T++)a+v<r&&f+T<s&&(l[a+v][f+T]=v===0&&T===0?"1":"0")})}),i.forEach(h=>{const a=h.sectionRowIndex;Array.from(h.querySelectorAll("th,td")).forEach(f=>{for(let u=0;u<l[a].length;u++)if(l[a][u]==="1"){f.dataset.col=u,l[a][u]="0";break}})})},"#resetColIndex"));let Qt=W;const mt=class mt extends HTMLElement{constructor(){super();d(this,Ot);d(this,K,null);d(this,Z);S(this,"invalidate",c(()=>{var e,i;t(this,Z).refresh(),(e=this.querySelector("nine-table-hscrollbar"))==null||e.refresh(),(i=this.querySelector("nine-table-vscrollbar"))==null||i.refresh()},"invalidate"));d(this,zt,c(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:i,type:o})=>{const r=this.querySelector(i);if(!r)return;r.innerHTML="";const s=document.createElement("div");s.className="ng-part-header",s.appendChild(t(this,st).call(this,t(this,K),o,"header"));const l=document.createElement("div");l.className="ng-part-body";const h=document.createElement("div");h.className="ng-scroll-content",h.style.position="relative",h.style.width="100%",h.appendChild(t(this,st).call(this,t(this,K),o,"body"));const a=document.createElement("div");a.className="ng-virtual-spacer",a.style.width="100%",a.style.pointerEvents="none",h.appendChild(a),l.appendChild(h);const f=document.createElement("div");f.className="ng-part-footer",f.appendChild(t(this,st).call(this,t(this,K),o,"footer")),r.appendChild(s),r.appendChild(l),r.appendChild(f)})},"#renderSplitContainers"));d(this,Nt,c(()=>{["left","right","body"].forEach(e=>{const i=this.querySelector(`.ng-container-${e}`),o=i==null?void 0:i.querySelectorAll("table");if(!i||!o||o.length===0)return;let r=0;o[0].querySelectorAll("col").forEach(s=>{const l=parseInt(s.getAttribute("width"),10);isNaN(r)||(r+=l)}),e==="body"?i.style.flex="1":(i.style.flex=`0 0 ${r}px`,i.style.width=`${r}px`)})},"#updateContainerWidths"));S(this,"generate",c(e=>{e&&(g(this,K,Qt.compile(e)),t(this,zt).call(this),t(this,Nt).call(this),t(this,Z).initialize(),setTimeout(()=>{var i;(i=this.querySelector("nine-table-hscrollbar"))==null||i.refresh()},0))},"generate"));d(this,st,c((e,i,o)=>{const r=e.cloneNode(!0),s=r.querySelector("thead"),l=r.querySelector("tbody"),h=r.querySelector("tfoot");if(o==="header"){if(l&&l.remove(),h&&h.remove(),e.querySelector("tbody")){const f=document.createElement("tbody");f.className="fixed-tbody",r.appendChild(f)}}else o==="body"?(s&&s.remove(),h&&h.remove(),l&&(l.className="bindable-tbody")):o==="footer"&&(s&&s.remove(),l&&l.remove());return i==="left"?r.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(a=>{a.getAttribute("fixed")!=="left"&&a.remove()}):i==="right"?r.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(a=>{a.getAttribute("fixed")!=="right"&&a.remove()}):r.querySelectorAll("[fixed=left], [fixed=right]").forEach(a=>{a.remove()}),r},"#createSplitTable"));S(this,"getRowHeight",c(()=>t(this,Z).getRowHeight(),"getRowHeight"));S(this,"scrollToX",c(e=>{const i=this.querySelector(".ng-container-body .ng-part-body");i&&(i.scrollLeft=e)},"scrollToX"));S(this,"scrollToY",c(e=>{const i=this.querySelector(".ng-container-body .ng-part-body");i&&(i.scrollTop=e)},"scrollToY"));d(this,Bt,c(()=>{t(this,Pt).call(this)},"#init"));d(this,Pt,c(()=>{const e=mt.SCROLLBAR_SIZE;this.innerHTML=`
|
|
127
127
|
<style>
|
|
128
128
|
nine-table-sheet {
|
|
129
129
|
display: none;
|
|
@@ -261,14 +261,14 @@
|
|
|
261
261
|
<nine-table-hscrollbar></nine-table-hscrollbar>
|
|
262
262
|
<div class='ng-scroll-edge'></div>
|
|
263
263
|
</div>
|
|
264
|
-
`},"#render"));
|
|
264
|
+
`},"#render"));g(this,Z,new Jt(this)),g(this,Ot,this.getRootNode().host)}connectedCallback(){t(this,Bt).call(this)}disconnectedCallback(){this.innerHTML="",E.log("NineTableSheet destroyed.")}};Ot=new WeakMap,K=new WeakMap,Z=new WeakMap,zt=new WeakMap,Nt=new WeakMap,st=new WeakMap,Bt=new WeakMap,Pt=new WeakMap,c(mt,"NineTableSheet"),S(mt,"SCROLLBAR_SIZE",16);let At=mt;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",At);const de=class de extends HTMLElement{constructor(){super();d(this,Dt,c(()=>{var e;(e=this.querySelector(".nine-tab-bar"))==null||e.addEventListener("click",i=>{var s;const o=i.ctrlKey||i.metaKey||i.shiftKey,r=parseInt((s=i.target.closest(".nine-tab-item"))==null?void 0:s.dataset.index,10);t(this,xt).call(this,r,o)}),t(this,xt).call(this,0,!1)},"#init"));d(this,xt,c((e,i=!1)=>{const o=c(()=>{const f=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(y=>y.style.setProperty("display","none"));const b=f.filter(y=>y.classList.contains("active"));b.length<2||b.forEach(y=>{const v=parseInt(y.getAttribute("data-index"),10),T=this.querySelector(`nine-splitter[data-split-index="${v}"]`),ct=f[v+1];T&&ct&&ct.classList.contains("active")&&T.style.setProperty("display","flex")})},"updateSplitters"),r=this.querySelector(".nine-tab-bar"),s=this.querySelector("nine-table-sheets-body"),l=r.querySelectorAll(".nine-tab-item"),h=s.querySelectorAll("nine-table-sheet");if(!l[e])return;if(!i)l.forEach((f,u)=>{f.classList.toggle("active",u===e)}),h.forEach((f,u)=>{const b=u===e;f.classList.toggle("active",b),f.style.flex=b?"1 1 100%":""});else{const f=l[e],u=r.querySelectorAll(".nine-tab-item.active");if(f.classList.contains("active")&&u.length<=1)return;f.classList.toggle("active");const b=s.querySelector(`nine-table-sheet[data-index="${e}"]`);b&&(b.classList.toggle("active"),b.classList.contains("active")||(b.style.flex=""))}const a=s.querySelectorAll("nine-table-sheet.active");a==null||a.forEach(f=>{f.style.flex=a.length>1?"1 1 0%":"1 1 100%"}),o()},"#switchSheet"))}connectedCallback(){t(this,Dt).call(this)}};Dt=new WeakMap,xt=new WeakMap,c(de,"NineTableSheets");let te=de;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",te);const fe=class fe{constructor(n){d(this,L);d(this,Yt,c(()=>{t(this,Vt).call(this),new ResizeObserver(n=>{for(let e of n)t(this,L).getAttribute("auto-height")==="true"&&t(this,vt).call(this)}).observe(t(this,L))},"#init"));d(this,vt,c(()=>{var h,a;const n=Array.from(t(this,L).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(n.length===0)return;const e=parseInt(t(this,L).getAttribute("max-display-row"),10)||10,i=Math.max(...n.map(f=>f.getRowHeight())),o=(h=t(this,L).shadowRoot.querySelector("nine-table-header"))==null?void 0:h.getBoundingClientRect().height,r=(a=t(this,L).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:a.getBoundingClientRect().height,s=At.SCROLLBAR_SIZE,l=e*i+o+r+s;t(this,L).style.height=`${l}px`},"#applyAutoHeight"));d(this,Vt,c(()=>{const e=Array.from(t(this,L).children).filter(h=>h.tagName==="TABLE"),i=t(this,L).getAttribute("auto-height")==="true",o=e.length,r=e.map((h,a)=>{const u=`<nine-table-sheet class="${a===0?"active":""}" data-index="${a}"></nine-table-sheet>`,b=a<o-1?`<nine-splitter class="h" data-split-index="${a}"></nine-splitter>`:"";return u+b}).join(""),s=e.map((h,a)=>`<div class="nine-tab-item ${a===0?"active":""}" data-index="${a}">Sheet ${a+1}</div>`).join("");t(this,L).shadowRoot.innerHTML=`
|
|
265
265
|
<style>
|
|
266
266
|
:host {
|
|
267
267
|
display: flex;
|
|
268
268
|
flex-direction: column;
|
|
269
269
|
position: relative;
|
|
270
270
|
overflow: hidden;
|
|
271
|
-
height: ${
|
|
271
|
+
height: ${i?"auto":"100%"};
|
|
272
272
|
background: #fff;
|
|
273
273
|
}
|
|
274
274
|
|
|
@@ -351,5 +351,5 @@
|
|
|
351
351
|
<nine-table-analysis></nine-table-analysis>
|
|
352
352
|
</nine-table-body>
|
|
353
353
|
<nine-table-footer></nine-table-footer>
|
|
354
|
-
`;const l=t(this,L).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((h,a)=>{e[a]&&setTimeout(()=>{h.generate(e[a]),
|
|
354
|
+
`;const l=t(this,L).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((h,a)=>{e[a]&&setTimeout(()=>{h.generate(e[a]),i&&t(this,vt).call(this)})})},"#render"));g(this,L,n),t(this,Yt).call(this)}};L=new WeakMap,Yt=new WeakMap,vt=new WeakMap,Vt=new WeakMap,c(fe,"LayoutManager");let ee=fe;const ue=class ue{constructor(n){d(this,wt);d(this,ot,-1);S(this,"count",c(()=>t(this,wt).rawRecords.length,"count"));g(this,wt,n)}get at(){return t(this,ot)}set at(n){g(this,ot,parseInt(n,10)),body&&!body.querySelector(`tbody.bindable tr[data-row="${t(this,ot)}"]`)&&setTimeout(()=>{})}};wt=new WeakMap,ot=new WeakMap,c(ue,"ngRow");let ne=ue;const M=class M{constructor(n,e){d(this,C);d(this,A);d(this,H,[]);d(this,rt,[]);d(this,Ut,0);d(this,D,[]);d(this,Xt,c(()=>{g(this,D,[]);const n=t(this,C).template||[];Array.from(n).forEach(e=>{var i;t(this,D).push(((i=e.getBoundingClientRect)==null?void 0:i.call(e).height)||24)}),(t(this,A).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,St).call(this)),e.__ng.height=t(this,D).slice()})},"#initialize"));d(this,G,c(()=>{t(this,C).shadowRoot.querySelectorAll("nine-table-sheet").forEach(n=>{n.invalidate()})},"#invalidate"));S(this,"get",c((n,e)=>{var r;const i=this.getValidData();if(!i||i.length<=0)return;if(n==null)return t(this,lt).call(this,i);if(n<0||n>=i.length)return null;const o=typeof((r=t(this,C).fields)==null?void 0:r.get)=="function"?t(this,C).fields.get():[];if(e!=null){const s=o.indexOf(e);return s>=0?i[n].v[s]:null}return t(this,lt).call(this,i[n])},"get"));S(this,"set",c(n=>{this.clear(),this.add(n,!1),t(this,G).call(this)},"set"));d(this,St,c(()=>({rowState:M.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,D).slice(),o:{},c:{},_:[0,0,0,0,M.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,D).slice(),-1,{},{}]}),"#getDefaultMeta"));S(this,"reset",c(()=>{g(this,H,[]),g(this,rt,[]),t(this,G).call(this)},"reset"));S(this,"clear",c(()=>{var n;t(this,A).rawRecords=[],g(this,H,[]),g(this,rt,[]),(n=t(this,A).viewRecords)!=null&&n.reset&&t(this,A).viewRecords.reset()},"clear"));d(this,jt,c(n=>{var o;Array.isArray(n)||(n=[n]);const e=typeof((o=t(this,C).fields)==null?void 0:o.get)=="function"?t(this,C).fields.get():Object.keys(n[0]||{}),i=[];return n.forEach(r=>{const s={v:[]};e.forEach(l=>{s.v.push(r[l]!==void 0&&r[l]!==null?r[l]:"")}),i.push(s)}),i},"#json2Array"));d(this,Ft,c(n=>(Array.isArray(n)||(n=[n]),n.forEach(e=>{e.__ng=t(this,St).call(this),e.__ng.rowid=this.nextId,e.__ng.rowState=M.ROW_STATE.INSERT,e.__ng._[0]=e.__ng.rowid}),n),"#defaultInsert"));S(this,"add",c((n,e=!0)=>{n===void 0&&(n={});const i=t(this,jt).call(this,n);t(this,A).rawRecords=t(this,A).rawRecords.concat(t(this,Ft).call(this,i)),this.resetRecords();const o=this.count()-1;return e||i.forEach((r,s)=>{const l=t(this,A).rawRecords[o-s];l&&(l.__ng.rowState=M.ROW_STATE.EMPTY)}),t(this,G).call(this),o},"add"));S(this,"delete",c(n=>{let e=[];Array.isArray(n)?e=n:typeof n>"u"?e=[t(this,A).host.row.at]:e=[parseInt(n,10)],e.sort((i,o)=>o-i).forEach(i=>{if(t(this,H)[i]){const o=t(this,H)[i].__ng.rowid;t(this,H)[i].__ng.rowState===M.ROW_STATE.INSERT?t(this,A).rawRecords=t(this,A).rawRecords.filter(r=>r.__ng.rowid!==o):t(this,A).rawRecords.forEach(r=>{r.__ng.rowid===o&&(r.__ng.deleted=!0,r.__ng.rowState=M.ROW_STATE.DELETE)})}}),this.resetRecords(),t(this,G).call(this)},"delete"));S(this,"setValue",c((n,e,i)=>{var h;n=parseInt(n,10);const r=(typeof((h=t(this,C).fields)==null?void 0:h.get)=="function"?t(this,C).fields.get():[]).indexOf(e);if(r<0)return;const s=this.getValidData()[n];if(!s)return;const l=s.v[r];l!==i&&s.__ng.rowState!==M.ROW_STATE.INSERT&&(s.__ng.o.hasOwnProperty(e)||(s.__ng.o[e]=l),s.__ng.rowState=M.ROW_STATE.UPDATE),s.v[r]=i},"setValue"));S(this,"resetRecords",c(()=>{g(this,rt,t(this,A).rawRecords.filter(n=>!n.__ng.deleted)),g(this,H,t(this,A).rawRecords.filter(n=>!n.__ng.deleted&&!n.__ng.filtered)),t(this,A).rawRecords.forEach((n,e)=>{n.__ng.rowidx=e}),t(this,H).forEach((n,e)=>{n.__ng.i=e})},"resetRecords"));S(this,"getValidData",c(()=>(t(this,H).length===0&&t(this,A).rawRecords.length>0&&this.resetRecords(),t(this,H)),"getValidData"));d(this,lt,c(n=>{var s;if(!n)return n;const e=!Array.isArray(n),i=e?[n]:n,o=typeof((s=t(this,C).fields)==null?void 0:s.get)=="function"?t(this,C).fields.get():[],r=i.filter(l=>!l.__ng.deleted).map(l=>{const h={};return o.forEach((a,f)=>{h[a]=l.v?l.v[f]:l[a]}),h.__ng=l.__ng,h});return e?r[0]:r},"#conv"));S(this,"count",c(()=>this.getValidData().length,"count"));g(this,C,n),g(this,A,e),t(this,Xt).call(this)}get source(){return t(this,lt).call(this,t(this,A).rawRecords)}set source(n){this.clear(),this.add(n,!1)}get nextId(){return++we(this,Ut)._}get length(){return t(this,H).length}getRowCount(){return this.length}};C=new WeakMap,A=new WeakMap,H=new WeakMap,rt=new WeakMap,Ut=new WeakMap,D=new WeakMap,Xt=new WeakMap,G=new WeakMap,St=new WeakMap,jt=new WeakMap,Ft=new WeakMap,lt=new WeakMap,c(M,"ngData"),S(M,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let ie=M;const ge=class ge{constructor(n){d(this,J);g(this,J,n),this.row=new ne(this),this.data=new ie(t(this,J),this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var e;(e=t(this,J).view)!=null&&e.redraw&&t(this,J).view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{var o,r;const i=parseInt(e,10);if(!(i>=this.data.count()))return(r=(o=this.data.getValidData()[i])==null?void 0:o.__ng)==null?void 0:r.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,i)=>this.data.get(e,i),this.setColumn=(e,i,o)=>{e=parseInt(e,10),this.data.setValue(e,i,o)},this.setDataSource([])}};J=new WeakMap,c(ge,"ngDataManager");let se=ge;const be=class be{constructor(n){d(this,at);d(this,q,[]);S(this,"add",c((n,e="string")=>{n.forEach(i=>{t(this,q).some(o=>o.name===i)||t(this,q).push({name:i,type:e})}),t(this,Et).call(this)},"add"));d(this,Et,c(()=>{const n=new Map;t(this,q).forEach(e=>{n.set(e.name,e.type)}),g(this,q,Array.from(n,([e,i])=>({name:e,type:i}))),g(this,q,t(this,q).filter(e=>e.name!==""&&e.name!=="__ng")),t(this,q).sort((e,i)=>e.name.length<i.name.length?1:-1)},"#adjust"));d(this,Kt,c(()=>{g(this,q,[]),E.log(t(this,at).querySelectorAll("table"));const n=Array.from(t(this,at).querySelectorAll("table"));if(!(!n||n.length===0)){for(const e of n)E.log(e),$("[data-bind]",e).each((i,o)=>{const r=o.dataset.bind,s=o.getAttribute("data-type")||"string";r&&t(this,q).push({name:r,type:s})}),["data-expr","background-color","color","tooltip","visible","readonly","enable-button","enable-check","class-expr","icon-color","icon-src"].forEach(i=>{$(`[${i}]`,e).each((o,r)=>{var s=r.getAttribute(i);if(s.indexOf("data.")<0){const l=s.search(/[(]/g);if(l>0)try{s=String(window[s.substring(0,l).trim()])}catch{s=""}}s.split("data.").forEach(l=>{if(l.trim()!=""){const h=l.search(/[^_A-Za-z0-9]/g);let a="";h>=0?a=l.substring(0,h):s.startsWith("data.")&&(a=l.replace("data.","")),a&&t(this,q).push({name:a,type:"string"})}})})});t(this,Et).call(this)}},"#init"));g(this,at,n),t(this,Kt).call(this)}get(){return t(this,q).map(n=>n.name)}getFields(){return t(this,q)}getType(n){const e=t(this,q).find(i=>i.name===n);return e?e.type:"string"}indexOf(n){return t(this,q).findIndex(e=>e.name===n)}includes(n){return t(this,q).some(e=>e.name===n)}};at=new WeakMap,q=new WeakMap,Et=new WeakMap,Kt=new WeakMap,c(be,"ngFields");let oe=be;const ye=class ye extends HTMLElement{constructor(){super();d(this,Q);d(this,Zt);d(this,Gt,c(()=>{this.fields=new oe(this),g(this,Zt,new ee(this)),E.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))},"#init"));this.attachShadow({mode:"open"}),g(this,Q,new se(this))}connectedCallback(){t(this,Gt).call(this)}disconnectedCallback(){E.log("NineTable disconnected.")}get data(){return t(this,Q).data}get row(){return t(this,Q).row}get dataManager(){return t(this,Q)}};Q=new WeakMap,Zt=new WeakMap,Gt=new WeakMap,c(ye,"NineTable");let re=ye;customElements.get("nine-table")||customElements.define("nine-table",re)});
|
|
355
355
|
//# sourceMappingURL=nine-table.umd.js.map
|