@ninebone/table 0.0.437 → 0.0.438
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 +620 -636
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +40 -45
- 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(
|
|
1
|
+
(function(m,y){typeof exports=="object"&&typeof module<"u"?y(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],y):(m=typeof globalThis<"u"?globalThis:m||self,y(m.NineboneUtil))})(this,function(m){"use strict";var ye=Object.defineProperty;var me=m=>{throw TypeError(m)};var we=(m,y,S)=>y in m?ye(m,y,{enumerable:!0,configurable:!0,writable:!0,value:S}):m[y]=S;var c=(m,y)=>ye(m,"name",{value:y,configurable:!0});var w=(m,y,S)=>we(m,typeof y!="symbol"?y+"":y,S),ve=(m,y,S)=>y.has(m)||me("Cannot "+S);var t=(m,y,S)=>(ve(m,y,"read from private field"),S?S.call(m):y.get(m)),d=(m,y,S)=>y.has(m)?me("Cannot add the same private member more than once"):y instanceof WeakSet?y.add(m):y.set(m,S),b=(m,y,S,z)=>(ve(m,y,"write to private field"),z?z.call(m,S):y.set(m,S),S);var xe=(m,y,S,z)=>({set _(ht){b(m,y,ht,S)},get _(){return t(m,y,z)}});var _,N,v,Y,V,U,qt,X,Tt,P,tt,j,E,dt,ft,kt,O,R,I,k,D,F,ut,et,Lt,Ct,Ht,bt,gt,Mt,_t,pt,It,it,yt,$t,nt,Wt,K,Z,Ot,zt,st,Nt,Pt,Dt,vt,L,Bt,xt,Yt,wt,ot,C,A,H,rt,Vt,B,Ut,G,St,Xt,jt,lt,J,at,q,Et,Ft,Q,Kt,Zt;const re=class re extends m.trace.constructor{constructor(){super(),this.init("nine-table","green")}};c(re,"Trace");let y=re;const S=new y,le=class le extends HTMLElement{constructor(){super();d(this,_);d(this,N,!1);d(this,v);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&&(b(this,U,new ResizeObserver(()=>{this.refresh()})),t(this,U).observe(e))},"#observeResize"));w(this,"refresh",c(()=>{if(!t(this,_)||!t(this,v)||t(this,N))return;const e=t(this,v).container,n=e.querySelector("table");if(!n)return;const o=t(this,v).track,r=t(this,v).thumb,s=t(this,_).querySelector(".ng-container-bottom"),l=e.clientWidth,h=n.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,g=h-l;let p=0;g>0&&(p=parseInt(u/g*(a-f),10)),p<0&&(p=0);const x=a-f;p>x&&(p=x),r.style.left=`${p}px`,S.log(p),t(this,v).left.disabled=p===0,t(this,v).right.disabled=p>=x-1},"refresh"));d(this,X,c(e=>{if(!t(this,v))return!1;const n=t(this,v).container,o=n.querySelector("table");if(!o)return!1;const r=t(this,v).track.getBoundingClientRect(),s=t(this,v).thumb.clientWidth;let l=e;l<0&&(l=0);const h=r.width-s;l>h&&(l=h),l=parseInt(l,10),t(this,v).thumb.style.left=`${l}px`,t(this,v).left.disabled=l===0,t(this,v).right.disabled=l>=h-1;const a=n.clientWidth,u=o.scrollWidth-a;return h>0&&u>0&&(n.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,v).thumb.style.left||0,10);t(this,X).call(this,r+o),b(this,Y,setInterval(()=>{clearInterval(t(this,Y)),b(this,V,setInterval(()=>{const s=parseInt(t(this,v).thumb.style.left||0,10);t(this,X).call(this,s+o)||clearInterval(t(this,V))},50))},500))},"delayScroll"),n=c(()=>{clearInterval(t(this,Y)),clearInterval(t(this,V))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(o=>{t(this,v).left.addEventListener(o,n),t(this,v).right.addEventListener(o,n),t(this,v).track.addEventListener(o,n)}),t(this,v).left.addEventListener("mousedown",o=>{o.button===0&&e(-20)}),t(this,v).right.addEventListener("mousedown",o=>{o.button===0&&e(20)}),t(this,v).left.addEventListener("touchstart",()=>e(-20)),t(this,v).right.addEventListener("touchstart",()=>e(20)),t(this,v).track.addEventListener("mousedown",o=>{if(o.button!==0)return;o.preventDefault();const r=t(this,v).track.getBoundingClientRect(),s=t(this,v).thumb.clientWidth;t(this,X).call(this,o.clientX-r.left-s/2)}),t(this,v).thumb.addEventListener("mousedown",o=>{if(o.button!==0)return;o.stopPropagation(),o.preventDefault(),b(this,N,!0),this.shiftX=o.clientX-t(this,v).thumb.getBoundingClientRect().left;const r=c(l=>{if(!t(this,N))return;const h=t(this,v).track.getBoundingClientRect();t(this,X).call(this,l.clientX-h.left-this.shiftX)},"onMouseMove"),s=c(()=>{b(this,N,!1),n(),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",s),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",s)})},"#init"))}connectedCallback(){if(b(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=
|
|
63
|
+
`;const e=c(()=>{const n=t(this,_).querySelector(".ng-container-body");if(!n){setTimeout(e,10);return}b(this,v,{container:n,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),n.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,v=new WeakMap,Y=new WeakMap,V=new WeakMap,U=new WeakMap,qt=new WeakMap,X=new WeakMap,Tt=new WeakMap,c(le,"NineTableHScrollBar");let z=le;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",z);const ae=class ae extends HTMLElement{constructor(){super();d(this,P);d(this,tt);d(this,j,!1);d(this,E);d(this,dt,0);d(this,ft,0);w(this,"refresh",c(()=>{if(!t(this,P)||!t(this,E))return;const e=t(this,E).container,n=t(this,E).track,o=t(this,E).thumb,r=e.clientHeight,l=(t(this,P).data.get()||[]).length,h=t(this,tt).getRowHeight(),a=l*h;if(a<=r){o.style.display="none",t(this,E).top.disabled=!0,t(this,E).bottom.disabled=!0;return}else o.style.display="block";const f=n.clientHeight;if(f<=0)return;const u=Math.max(Math.min(f*(r/a),f),20);o.style.height=`${u}px`;const g=e.scrollTop,p=Math.max(a-r,1);let x=0;p>0&&(x=g/p*(f-u));const T=f-u;x<0&&(x=0),x>T&&(x=T),o.style.top=`${x}px`,t(this,E).top.disabled=g<=0,t(this,E).bottom.disabled=g>=p-1},"refresh"));d(this,kt,c(()=>{const e=t(this,E).container,n=c(()=>{const r=(t(this,P).data.get()||[]).length,s=t(this,tt).getRowHeight();return r*s},"getContentHeight");e.addEventListener("scroll",()=>{t(this,j)||this.refresh()}),t(this,E).thumb.addEventListener("mousedown",o=>{if(o.button!==0)return;o.stopPropagation(),o.preventDefault(),b(this,j,!0),b(this,dt,o.clientY),b(this,ft,e.scrollTop);const r=c(l=>{if(!t(this,j))return;const h=t(this,E).track.getBoundingClientRect(),a=t(this,E).thumb.clientHeight,u=h.height-a,g=l.clientY-t(this,dt),p=e.clientHeight,x=n(),T=Math.max(x-p,1);if(u>0&&T>0){const ct=g/u*T;let Rt=t(this,ft)+ct;const pe=Math.max(0,x-p);Rt<0&&(Rt=0),Rt>pe&&(Rt=pe),e.scrollTop=Rt}this.refresh()},"onMouseMove"),s=c(()=>{b(this,j,!1),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",s),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",s)}),t(this,E).track.addEventListener("mousedown",o=>{if(o.button!==0||o.target===t(this,E).thumb)return;const r=t(this,E).track.getBoundingClientRect(),s=t(this,E).thumb.clientHeight,l=o.clientY-r.top-s/2,a=r.height-s,f=e.clientHeight,u=n(),g=Math.max(u-f,1);if(a>0&&g>0){const p=Math.max(0,Math.min(1,l/a));e.scrollTop=p*g}this.refresh()}),t(this,E).top.addEventListener("click",()=>{e.scrollTop-=40}),t(this,E).bottom.addEventListener("click",()=>{e.scrollTop+=40})},"#init"))}connectedCallback(){b(this,P,this.getRootNode().host),b(this,tt,this.closest("nine-table-sheet")),this.innerHTML=`
|
|
64
64
|
<style>
|
|
65
65
|
nine-table-vscrollbar {
|
|
66
66
|
display: flex;
|
|
@@ -104,7 +104,6 @@
|
|
|
104
104
|
position: relative;
|
|
105
105
|
background: #f3f4f6;
|
|
106
106
|
overflow: hidden;
|
|
107
|
-
border: 2px solid red;
|
|
108
107
|
}
|
|
109
108
|
nine-table-vscrollbar .ng-scroll-thumb {
|
|
110
109
|
position: absolute;
|
|
@@ -124,7 +123,7 @@
|
|
|
124
123
|
<button class='ng-scroll-top' disabled><div class='ng-scroll-icon'></div></button>
|
|
125
124
|
<div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
|
|
126
125
|
<button class='ng-scroll-bottom' disabled><div class='ng-scroll-icon'></div></button>
|
|
127
|
-
`;const e=a(()=>{const s=t(this,F).shadowRoot.querySelector(".ng-container-body");if(!s){setTimeout(e,10);return}b(this,R,{container:s,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,Tt).call(this),this.refresh()},"initWhenReady");e()}};F=new WeakMap,et=new WeakMap,B=new WeakMap,R=new WeakMap,dt=new WeakMap,ft=new WeakMap,Tt=new WeakMap,a(ae,"NineTableVScrollBar");let ht=ae;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",ht);const I=class I{static compileAll(i){return Array.isArray(i)?i.map(e=>I.compile(e)):[]}static compile(i){var o,r,n,l;if(!i)return null;const e=i.cloneNode(!0);return t(o=I,kt).call(o,e),t(r=I,it).call(r,e,"thead"),t(n=I,it).call(n,e,"tbody"),t(l=I,it).call(l,e,"tfoot"),Array.from(e.querySelectorAll("colgroup col")).forEach((d,h)=>{const f=d.getAttribute("fixed");f&&e.querySelectorAll(`thead [data-col="${h}"], tbody [data-col="${h}"], tfoot [data-col="${h}"]`).forEach(u=>{u.setAttribute("fixed",f)})}),e}};kt=new WeakMap,it=new WeakMap,a(I,"TableCompiler"),c(I,kt,a(i=>{if(!i.querySelector("colgroup")){const e=i.querySelector("tbody tr")||i.querySelector("tr"),s=e?e.querySelectorAll("th, td").length:1,o=document.createElement("colgroup"),r=Math.max(Math.floor(i.clientWidth/s),100);for(let n=0;n<s;n++){const l=document.createElement("col");l.setAttribute("width",r),o.appendChild(l)}i.prepend(o)}if(!i.querySelector("thead")){const e=document.createElement("thead"),s=i.querySelector("colgroup");s?s.after(e):i.prepend(e)}i.classList.add("nine-table-element"),i.style.display="table"},"#ensureTableStructure")),c(I,it,a((i,e)=>{const s=Array.from(i.querySelectorAll(e+" tr")),o=Array.from(i.querySelectorAll(e+" th,"+e+" td")),r=s.length;if(r===0||o.length===0)return;let n=0;o.forEach(d=>{n+=d.colSpan||1});const l=Array.from(Array(r),()=>Array(n).fill(null));s.forEach(d=>{const h=d.sectionRowIndex;let f=0;Array.from(d.querySelectorAll("th,td")).forEach(u=>{for(let y=0;y<l[h].length;y++)if(l[h][y]===null){f=y;break}const g=u.rowSpan||1,p=u.colSpan||1;for(let y=0;y<g;y++)for(let q=0;q<p;q++)h+y<r&&f+q<n&&(l[h+y][f+q]=y===0&&q===0?"1":"0")})}),s.forEach(d=>{const h=d.sectionRowIndex;Array.from(d.querySelectorAll("th,td")).forEach(f=>{for(let u=0;u<l[h].length;u++)if(l[h][u]==="1"){f.dataset.col=u,l[h][u]="0";break}})})},"#resetColIndex"));let Gt=I;const ce=class ce{constructor(i){c(this,W);c(this,E);c(this,O,new Map);c(this,k,null);c(this,D,null);c(this,K,0);c(this,ut,40);c(this,st,!1);c(this,Lt,3);S(this,"refresh",a(()=>{var e;const i=t(this,E).querySelector(".ng-container-body");i&&(t(this,bt).call(this),t(this,nt).call(this,i.scrollTop),(e=t(this,E).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));S(this,"initialize",a(()=>{b(this,k,null),t(this,O).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const r=t(this,E).querySelector(o);if(!r)return;const n=r.querySelector("table");if(!n)return;const l=n.querySelector("tbody.bindable-tbody");if(!l)return;const h=Array.from(l.querySelectorAll("tr")).map(f=>f.cloneNode(!0));t(this,O).set(o,h)});const i=t(this,E).querySelector(".ng-container-body"),e=t(this,E).querySelector(".ng-container-left"),s=t(this,E).querySelector(".ng-container-right");if(i){t(this,Ht).call(this,i),t(this,yt).call(this),t(this,bt).call(this),t(this,nt).call(this,i.scrollTop);let o=i.scrollTop;const r=a(n=>{var l;e&&e.scrollTop!==n&&(e.scrollTop=n),s&&s.scrollTop!==n&&(s.scrollTop=n),t(this,nt).call(this,n),(l=t(this,E).querySelector("nine-table-vscrollbar"))==null||l.refresh()},"syncScroll");i.addEventListener("scroll",()=>{const n=i.scrollTop;o!==n&&(o=n,r(n))})}},"initialize"));c(this,Ct,a((i,e)=>{const s=t(this,O).get(e);if(!s||s.length===0)return;const o=i.querySelector("tbody.bindable-tbody");if(!o)return;o.querySelectorAll("tr:not(.nodata)").forEach(l=>l.remove());const r=o.querySelector("tr.nodata"),n=document.createDocumentFragment();for(let l=0;l<t(this,ut);l++)s.forEach(d=>{n.appendChild(d.cloneNode(!0))});r?r.before(n):o.appendChild(n)},"#renderRows"));c(this,Ht,a(i=>{if(t(this,k)!==null&&t(this,k)>0)return t(this,k);const e=t(this,O).get(".ng-container-body");if(!e||e.length===0)return 24;const s=i.querySelector("tbody.bindable-tbody")||i.querySelector("tbody.bindable-tbody:last-of-type");if(!s)return 24;s.querySelectorAll("tr:not(.nodata)").forEach(g=>g.remove());const o=s.querySelector("tr.nodata"),r=document.createDocumentFragment();e.forEach(g=>{r.appendChild(g.cloneNode(!0))}),o?o.before(r):s.appendChild(r);const n=t(this,E),l=n.style.display,d=n.style.visibility,h=n.style.position;(l==="none"||window.getComputedStyle(n).display==="none")&&(n.style.display="block",n.style.visibility="hidden",n.style.position="absolute");let f=0;const u=s.querySelectorAll("tr:not(.nodata)");return u.forEach(g=>{f+=g.offsetHeight||g.getBoundingClientRect().height}),u.forEach(g=>g.remove()),n.style.display=l,n.style.visibility=d,n.style.position=h,b(this,k,f>0?f:24),t(this,gt).call(this),t(this,k)},"#measureAndCacheHeight"));c(this,bt,a(()=>{if(!t(this,E).querySelector(".ng-container-body"))return;const s=(t(this,W).data.get()||[]).length,o=t(this,k)||24,r=s*o;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const l=t(this,E).querySelector(n);if(!l)return;const d=l.querySelector("table");d&&(d.style.height="auto");const h=l.querySelector(".ng-virtual-spacer");h&&(h.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));c(this,gt,a(()=>{if((t(this,W).data.get()||[]).length,t(this,K)>0&&t(this,k)>0){const e=Math.ceil(t(this,K)/t(this,k));b(this,ut,e+t(this,Lt))}},"#updateRowCount"));c(this,Mt,a(()=>{var d,h,f;const i=t(this,E).querySelector(".ng-container-left table"),e=t(this,E).querySelector(".ng-container-body table"),s=t(this,E).querySelector(".ng-container-right table");if(!e)return;const o=i?Array.from(i.querySelectorAll("tr")):[],r=Array.from(e.querySelectorAll("tr")),n=s?Array.from(s.querySelectorAll("tr")):[],l=Math.max(o.length,r.length,n.length);for(let u=0;u<l;u++){const g=[((d=o[u])==null?void 0:d.getBoundingClientRect().height)||0,((h=r[u])==null?void 0:h.getBoundingClientRect().height)||0,((f=n[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`),n[u]&&(n[u].style.height=`${p}px`))}},"#syncRowHeights"));c(this,_t,a(()=>{!t(this,E)||!(t(this,E)instanceof HTMLElement)||(b(this,D,new ResizeObserver(i=>{for(const e of i){const s=e.target;if(!s.classList.contains("active"))continue;const o=e.contentRect.height;if(o>0){let r=0;const n=s.querySelector("thead");n&&(r+=n.offsetHeight||n.getBoundingClientRect().height);const l=Math.max(o-r,100);t(this,K)!==l&&(b(this,K,l),t(this,gt).call(this),t(this,k)!==null&&t(this,yt).call(this))}}})),t(this,D).observe(t(this,E)))},"#initResizeObserver"));c(this,yt,a(()=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(i=>{const e=t(this,E).querySelector(i);e&&e.querySelector("tbody.bindable-tbody")&&t(this,Ct).call(this,e,i)}),t(this,Mt).call(this)},"#renderAllContainers"));c(this,It,a(i=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(e=>{var h;const s=t(this,E).querySelector(e);if(!s)return;const o=s.querySelector("tbody.bindable-tbody");if(!o)return;const r=Array.from(o.querySelectorAll("tr:not(.nodata)")),n=((h=t(this,O).get(e))==null?void 0:h.length)||1,d=(t(this,W).data.get()||[]).length;r.forEach((f,u)=>{const g=i+Math.floor(u/n);if(g>=d){f.style.display="none";return}const p=t(this,W).data.get(g);f.style.display="",t(this,pt).call(this,f,p,g)})})},"#adjustBufferRows"));c(this,nt,a(i=>{var d;const e=t(this,k);if(!e||e<=0)return;const o=(t(this,W).data.get()||[]).length,r=Math.max(0,Math.floor(i/e)),n=r*e,l=((d=t(this,O).get(".ng-container-body"))==null?void 0:d.length)||1;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(h=>{const f=t(this,E).querySelector(h);if(!f)return;const u=f.querySelector("table");if(u){const y=u.querySelector("thead"),q=u.querySelector("tbody.fixed-tbody");y&&(y.style.position="relative",y.style.transform=`translateY(${i}px)`,y.style.zIndex="5"),q&&(q.style.position="relative",q.style.transform=`translateY(${i}px)`,q.style.zIndex="6")}const g=f.querySelector("tbody.bindable-tbody");if(!g)return;g.style.transform=`translateY(${n}px)`,Array.from(g.querySelectorAll("tr:not(.nodata)")).forEach((y,q)=>{const Y=r+Math.floor(q/l);if(Y>=o){y.style.display="none";return}const tt=t(this,W).data.get(Y);y.style.display="",t(this,pt).call(this,y,tt,Y)})}),t(this,st)||(b(this,st,!0),setTimeout(()=>{t(this,It).call(this,r),b(this,st,!1)},0))},"#handleScroll"));c(this,pt,a((i,e,s)=>{i.dataset.row=s,Array.from(i.cells).forEach((o,r)=>{const n=o.dataset.bind;n&&e&&e[n]!==void 0?o.textContent=e[n]:o.textContent=e?e[Object.keys(e)[r]]??`R${s}C${r}`:`행 ${s+1}`,o.dataset.row=s})},"#bindRowData"));S(this,"destroy",a(()=>{t(this,D)&&(t(this,D).disconnect(),b(this,D,null))},"destroy"));b(this,W,i.getRootNode().host),b(this,E,i),t(this,_t).call(this)}getRowHeight(){return t(this,k)}templateLength(i=".ng-container-body"){var e;return((e=t(this,O).get(i))==null?void 0:e.length)||1}};W=new WeakMap,E=new WeakMap,O=new WeakMap,k=new WeakMap,D=new WeakMap,K=new WeakMap,ut=new WeakMap,st=new WeakMap,Lt=new WeakMap,Ct=new WeakMap,Ht=new WeakMap,bt=new WeakMap,gt=new WeakMap,Mt=new WeakMap,_t=new WeakMap,yt=new WeakMap,It=new WeakMap,nt=new WeakMap,pt=new WeakMap,a(ce,"RowManager");let Jt=ce;const mt=class mt extends HTMLElement{constructor(){super();c(this,$t);c(this,ot,null);c(this,Z);S(this,"invalidate",a(()=>{var e,s;t(this,Z).refresh(),(e=this.querySelector("nine-table-hscrollbar"))==null||e.refresh(),(s=this.querySelector("nine-table-vscrollbar"))==null||s.refresh()},"invalidate"));c(this,Wt,a(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:s,type:o})=>{const r=this.querySelector(s);if(!r)return;const n=t(this,zt).call(this,t(this,ot),o);r.innerHTML="";const l=document.createElement("div");l.className="ng-scroll-content",l.style.position="relative",l.style.width="100%",l.appendChild(n);const d=document.createElement("div");d.className="ng-virtual-spacer",d.style.width="100%",d.style.pointerEvents="none",l.appendChild(d),r.appendChild(l)})},"#renderSplitContainers"));c(this,Ot,a(()=>{["left","right"].forEach(e=>{const s=this.querySelector(`.ng-container-${e}`),o=s==null?void 0:s.querySelector("table");if(!s||!o)return;let r=0;o.querySelectorAll("col").forEach(n=>{const l=parseInt(n.getAttribute("width"),10);isNaN(r)||(r+=l)}),s.style.flex=`0 0 ${r}px`,s.style.width=`${r}px`})},"#updateContainerWidths"));S(this,"generate",a(e=>{e&&(b(this,ot,Gt.compile(e)),t(this,ot).style.display="table",t(this,Wt).call(this),t(this,Ot).call(this),requestAnimationFrame(()=>{var o;const s=(o=this.querySelector("thead"))==null?void 0:o.getBoundingClientRect().height;this.querySelectorAll("tbody.fixed-tbody").forEach(r=>{r.style.top=`${s}px`})}),t(this,Z).initialize(),setTimeout(()=>{var s;(s=this.querySelector("nine-table-hscrollbar"))==null||s.refresh()},0))},"generate"));c(this,zt,a((e,s)=>{const o=e.cloneNode(!0),r=o.querySelector("tbody");if(r){const n=document.createElement("tbody");n.className="fixed-tbody",r.className="bindable-tbody",r.before(n)}return s==="left"?o.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(n=>{n.getAttribute("fixed")!=="left"&&n.remove()}):s==="right"?o.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(n=>{n.getAttribute("fixed")!=="right"&&n.remove()}):o.querySelectorAll("[fixed=left], [fixed=right]").forEach(n=>{n.remove()}),o},"#createSplitTable"));S(this,"getRowHeight",a(()=>t(this,Z).getRowHeight(),"getRowHeight"));S(this,"scrollToX",a(e=>{const s=this.querySelector(".ng-container-body");s&&(s.scrollLeft=e)},"scrollToX"));S(this,"scrollToY",a(e=>{const s=this.querySelector(".ng-container-body");s&&(s.scrollTop=e)},"scrollToY"));c(this,Nt,a(()=>{t(this,Bt).call(this)},"#init"));c(this,Bt,a(()=>{const e=mt.SCROLLBAR_SIZE;this.innerHTML=`
|
|
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=`
|
|
128
127
|
<style>
|
|
129
128
|
nine-table-sheet {
|
|
130
129
|
display: none;
|
|
@@ -150,51 +149,56 @@
|
|
|
150
149
|
overflow: hidden;
|
|
151
150
|
position: relative;
|
|
152
151
|
}
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
|
|
153
|
+
/* 9분할 열 컨테이너 공통 스타일 */
|
|
154
|
+
nine-table-sheet .ng-container-left,
|
|
155
|
+
nine-table-sheet .ng-container-body,
|
|
156
|
+
nine-table-sheet .ng-container-right {
|
|
155
157
|
display: flex;
|
|
156
158
|
flex-direction: column;
|
|
157
|
-
|
|
158
|
-
overflow-x: hidden;
|
|
159
|
+
height: 100%;
|
|
159
160
|
background: #ffffff;
|
|
161
|
+
position: relative;
|
|
162
|
+
overflow: hidden;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
nine-table-sheet .ng-container-left {
|
|
160
166
|
border-right: 1px solid #e5e7eb;
|
|
161
167
|
flex-shrink: 0;
|
|
162
|
-
scrollbar-width: none;
|
|
163
|
-
&::-webkit-scrollbar { display: none; }
|
|
164
168
|
}
|
|
165
169
|
|
|
166
|
-
nine-table-sheet
|
|
167
|
-
|
|
168
|
-
top: 0;
|
|
169
|
-
z-index: 3;
|
|
170
|
-
}
|
|
171
|
-
nine-table-sheet tbody.fixed-tbody {
|
|
172
|
-
position: sticky;
|
|
173
|
-
z-index: 4;
|
|
170
|
+
nine-table-sheet .ng-container-body {
|
|
171
|
+
flex: 1;
|
|
174
172
|
}
|
|
175
173
|
|
|
176
|
-
nine-table-sheet .ng-container-
|
|
177
|
-
|
|
178
|
-
flex-
|
|
174
|
+
nine-table-sheet .ng-container-right {
|
|
175
|
+
border-left: 1px solid #e5e7eb;
|
|
176
|
+
flex-shrink: 0;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* 9분할 3단 레이어 (Header / Body / Footer) */
|
|
180
|
+
nine-table-sheet .ng-part-header {
|
|
181
|
+
flex-shrink: 0;
|
|
182
|
+
overflow: hidden;
|
|
183
|
+
background: #f9fafb;
|
|
184
|
+
z-index: 3;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
nine-table-sheet .ng-part-body {
|
|
179
188
|
flex: 1;
|
|
180
189
|
overflow-y: auto;
|
|
181
190
|
overflow-x: auto;
|
|
182
|
-
background: #ffffff;
|
|
183
191
|
position: relative;
|
|
184
192
|
scrollbar-width: none;
|
|
185
193
|
&::-webkit-scrollbar { display: none; height: 0px; }
|
|
186
194
|
}
|
|
187
|
-
|
|
188
|
-
nine-table-sheet .ng-
|
|
189
|
-
display: flex;
|
|
190
|
-
flex-direction: column;
|
|
191
|
-
overflow-y: auto;
|
|
192
|
-
overflow-x: hidden;
|
|
193
|
-
background: #ffffff;
|
|
194
|
-
border-left: 1px solid #e5e7eb;
|
|
195
|
+
|
|
196
|
+
nine-table-sheet .ng-part-footer {
|
|
195
197
|
flex-shrink: 0;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
overflow: hidden;
|
|
199
|
+
background: #f9fafb;
|
|
200
|
+
border-top: 2px solid #d1d5db;
|
|
201
|
+
z-index: 2;
|
|
198
202
|
}
|
|
199
203
|
|
|
200
204
|
nine-table-sheet .ng-container-bottom {
|
|
@@ -238,17 +242,8 @@
|
|
|
238
242
|
text-align: left;
|
|
239
243
|
}
|
|
240
244
|
|
|
241
|
-
nine-table-sheet tfoot {
|
|
242
|
-
display: table-footer-group;
|
|
243
|
-
position: sticky;
|
|
244
|
-
bottom: 0;
|
|
245
|
-
z-index: 2;
|
|
246
|
-
background: #f9fafb;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
245
|
nine-table-sheet tfoot td, nine-table-sheet tfoot th {
|
|
250
246
|
font-weight: 600;
|
|
251
|
-
border-top: 2px solid #d1d5db;
|
|
252
247
|
}
|
|
253
248
|
|
|
254
249
|
nine-splitter {
|
|
@@ -266,14 +261,14 @@
|
|
|
266
261
|
<nine-table-hscrollbar></nine-table-hscrollbar>
|
|
267
262
|
<div class='ng-scroll-edge'></div>
|
|
268
263
|
</div>
|
|
269
|
-
`},"#render"));b(this,Z,new
|
|
264
|
+
`},"#render"));b(this,Z,new Gt(this)),b(this,Wt,this.getRootNode().host)}connectedCallback(){t(this,Nt).call(this)}disconnectedCallback(){this.innerHTML="",S.log("NineTableSheet destroyed.")}};Wt=new WeakMap,K=new WeakMap,Z=new WeakMap,Ot=new WeakMap,zt=new WeakMap,st=new WeakMap,Nt=new WeakMap,Pt=new WeakMap,c(mt,"NineTableSheet"),w(mt,"SCROLLBAR_SIZE",16);let At=mt;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",At);const he=class he extends HTMLElement{constructor(){super();d(this,Dt,c(()=>{var e;(e=this.querySelector(".nine-tab-bar"))==null||e.addEventListener("click",n=>{var s;const o=n.ctrlKey||n.metaKey||n.shiftKey,r=parseInt((s=n.target.closest(".nine-tab-item"))==null?void 0:s.dataset.index,10);t(this,vt).call(this,r,o)}),t(this,vt).call(this,0,!1)},"#init"));d(this,vt,c((e,n=!1)=>{const o=c(()=>{const f=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(p=>p.style.setProperty("display","none"));const g=f.filter(p=>p.classList.contains("active"));g.length<2||g.forEach(p=>{const x=parseInt(p.getAttribute("data-index"),10),T=this.querySelector(`nine-splitter[data-split-index="${x}"]`),ct=f[x+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(!n)l.forEach((f,u)=>{f.classList.toggle("active",u===e)}),h.forEach((f,u)=>{const g=u===e;f.classList.toggle("active",g),f.style.flex=g?"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 g=s.querySelector(`nine-table-sheet[data-index="${e}"]`);g&&(g.classList.toggle("active"),g.classList.contains("active")||(g.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,vt=new WeakMap,c(he,"NineTableSheets");let Qt=he;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",Qt);const de=class de{constructor(i){d(this,L);d(this,Bt,c(()=>{t(this,Yt).call(this),new ResizeObserver(i=>{for(let e of i)t(this,L).getAttribute("auto-height")==="true"&&t(this,xt).call(this)}).observe(t(this,L))},"#init"));d(this,xt,c(()=>{var h,a;const i=Array.from(t(this,L).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(i.length===0)return;const e=parseInt(t(this,L).getAttribute("max-display-row"),10)||10,n=Math.max(...i.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*n+o+r+s;t(this,L).style.height=`${l}px`},"#applyAutoHeight"));d(this,Yt,c(()=>{const e=Array.from(t(this,L).children).filter(h=>h.tagName==="TABLE"),n=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>`,g=a<o-1?`<nine-splitter class="h" data-split-index="${a}"></nine-splitter>`:"";return u+g}).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=`
|
|
270
265
|
<style>
|
|
271
266
|
:host {
|
|
272
267
|
display: flex;
|
|
273
268
|
flex-direction: column;
|
|
274
269
|
position: relative;
|
|
275
270
|
overflow: hidden;
|
|
276
|
-
height: ${
|
|
271
|
+
height: ${n?"auto":"100%"};
|
|
277
272
|
background: #fff;
|
|
278
273
|
}
|
|
279
274
|
|
|
@@ -349,12 +344,12 @@
|
|
|
349
344
|
<nine-table-sheets>
|
|
350
345
|
<nine-table-sheets-body>${r}</nine-table-sheets-body>
|
|
351
346
|
<nine-table-sheets-footer>
|
|
352
|
-
<div class="nine-tab-bar">${
|
|
347
|
+
<div class="nine-tab-bar">${s}</div>
|
|
353
348
|
<div class="sheets-counter">Total : <span id="row-count">0</span></div>
|
|
354
349
|
</nine-table-sheets-footer>
|
|
355
350
|
</nine-table-sheets>
|
|
356
351
|
<nine-table-analysis></nine-table-analysis>
|
|
357
352
|
</nine-table-body>
|
|
358
353
|
<nine-table-footer></nine-table-footer>
|
|
359
|
-
`;const l=t(this,L).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((
|
|
354
|
+
`;const l=t(this,L).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((h,a)=>{e[a]&&setTimeout(()=>{h.generate(e[a]),n&&t(this,xt).call(this)})})},"#render"));b(this,L,i),t(this,Bt).call(this)}};L=new WeakMap,Bt=new WeakMap,xt=new WeakMap,Yt=new WeakMap,c(de,"LayoutManager");let te=de;const fe=class fe{constructor(i){d(this,wt);d(this,ot,-1);w(this,"count",c(()=>t(this,wt).rawRecords.length,"count"));b(this,wt,i)}get at(){return t(this,ot)}set at(i){b(this,ot,parseInt(i,10)),body&&!body.querySelector(`tbody.bindable tr[data-row="${t(this,ot)}"]`)&&setTimeout(()=>{})}};wt=new WeakMap,ot=new WeakMap,c(fe,"ngRow");let ee=fe;const M=class M{constructor(i,e){d(this,C);d(this,A);d(this,H,[]);d(this,rt,[]);d(this,Vt,0);d(this,B,[]);d(this,Ut,c(()=>{b(this,B,[]);const i=t(this,C).template||[];Array.from(i).forEach(e=>{var n;t(this,B).push(((n=e.getBoundingClientRect)==null?void 0:n.call(e).height)||24)}),(t(this,A).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,St).call(this)),e.__ng.height=t(this,B).slice()})},"#initialize"));d(this,G,c(()=>{t(this,C).shadowRoot.querySelectorAll("nine-table-sheet").forEach(i=>{i.invalidate()})},"#invalidate"));w(this,"get",c((i,e)=>{var r;const n=this.getValidData();if(!n||n.length<=0)return;if(i==null)return t(this,lt).call(this,n);if(i<0||i>=n.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?n[i].v[s]:null}return t(this,lt).call(this,n[i])},"get"));w(this,"set",c(i=>{this.clear(),this.add(i,!1),t(this,G).call(this)},"set"));d(this,St,c(()=>({rowState:M.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,B).slice(),o:{},c:{},_:[0,0,0,0,M.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,B).slice(),-1,{},{}]}),"#getDefaultMeta"));w(this,"reset",c(()=>{b(this,H,[]),b(this,rt,[]),t(this,G).call(this)},"reset"));w(this,"clear",c(()=>{var i;t(this,A).rawRecords=[],b(this,H,[]),b(this,rt,[]),(i=t(this,A).viewRecords)!=null&&i.reset&&t(this,A).viewRecords.reset()},"clear"));d(this,Xt,c(i=>{var o;Array.isArray(i)||(i=[i]);const e=typeof((o=t(this,C).fields)==null?void 0:o.get)=="function"?t(this,C).fields.get():Object.keys(i[0]||{}),n=[];return i.forEach(r=>{const s={v:[]};e.forEach(l=>{s.v.push(r[l]!==void 0&&r[l]!==null?r[l]:"")}),n.push(s)}),n},"#json2Array"));d(this,jt,c(i=>(Array.isArray(i)||(i=[i]),i.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}),i),"#defaultInsert"));w(this,"add",c((i,e=!0)=>{i===void 0&&(i={});const n=t(this,Xt).call(this,i);t(this,A).rawRecords=t(this,A).rawRecords.concat(t(this,jt).call(this,n)),this.resetRecords();const o=this.count()-1;return e||n.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"));w(this,"delete",c(i=>{let e=[];Array.isArray(i)?e=i:typeof i>"u"?e=[t(this,A).host.row.at]:e=[parseInt(i,10)],e.sort((n,o)=>o-n).forEach(n=>{if(t(this,H)[n]){const o=t(this,H)[n].__ng.rowid;t(this,H)[n].__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"));w(this,"setValue",c((i,e,n)=>{var h;i=parseInt(i,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()[i];if(!s)return;const l=s.v[r];l!==n&&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]=n},"setValue"));w(this,"resetRecords",c(()=>{b(this,rt,t(this,A).rawRecords.filter(i=>!i.__ng.deleted)),b(this,H,t(this,A).rawRecords.filter(i=>!i.__ng.deleted&&!i.__ng.filtered)),t(this,A).rawRecords.forEach((i,e)=>{i.__ng.rowidx=e}),t(this,H).forEach((i,e)=>{i.__ng.i=e})},"resetRecords"));w(this,"getValidData",c(()=>(t(this,H).length===0&&t(this,A).rawRecords.length>0&&this.resetRecords(),t(this,H)),"getValidData"));d(this,lt,c(i=>{var s;if(!i)return i;const e=!Array.isArray(i),n=e?[i]:i,o=typeof((s=t(this,C).fields)==null?void 0:s.get)=="function"?t(this,C).fields.get():[],r=n.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"));w(this,"count",c(()=>this.getValidData().length,"count"));b(this,C,i),b(this,A,e),t(this,Ut).call(this)}get source(){return t(this,lt).call(this,t(this,A).rawRecords)}set source(i){this.clear(),this.add(i,!1)}get nextId(){return++xe(this,Vt)._}get length(){return t(this,H).length}getRowCount(){return this.length}};C=new WeakMap,A=new WeakMap,H=new WeakMap,rt=new WeakMap,Vt=new WeakMap,B=new WeakMap,Ut=new WeakMap,G=new WeakMap,St=new WeakMap,Xt=new WeakMap,jt=new WeakMap,lt=new WeakMap,c(M,"ngData"),w(M,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let ie=M;const ue=class ue{constructor(i){d(this,J);b(this,J,i),this.row=new ee(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 n=parseInt(e,10);if(!(n>=this.data.count()))return(r=(o=this.data.getValidData()[n])==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,n)=>this.data.get(e,n),this.setColumn=(e,n,o)=>{e=parseInt(e,10),this.data.setValue(e,n,o)},this.setDataSource([])}};J=new WeakMap,c(ue,"ngDataManager");let ne=ue;const be=class be{constructor(i){d(this,at);d(this,q,[]);w(this,"add",c((i,e="string")=>{i.forEach(n=>{t(this,q).some(o=>o.name===n)||t(this,q).push({name:n,type:e})}),t(this,Et).call(this)},"add"));d(this,Et,c(()=>{const i=new Map;t(this,q).forEach(e=>{i.set(e.name,e.type)}),b(this,q,Array.from(i,([e,n])=>({name:e,type:n}))),b(this,q,t(this,q).filter(e=>e.name!==""&&e.name!=="__ng")),t(this,q).sort((e,n)=>e.name.length<n.name.length?1:-1)},"#adjust"));d(this,Ft,c(()=>{b(this,q,[]),S.log(t(this,at).querySelectorAll("table"));const i=Array.from(t(this,at).querySelectorAll("table"));if(!(!i||i.length===0)){for(const e of i)S.log(e),$("[data-bind]",e).each((n,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(n=>{$(`[${n}]`,e).each((o,r)=>{var s=r.getAttribute(n);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"));b(this,at,i),t(this,Ft).call(this)}get(){return t(this,q).map(i=>i.name)}getFields(){return t(this,q)}getType(i){const e=t(this,q).find(n=>n.name===i);return e?e.type:"string"}indexOf(i){return t(this,q).findIndex(e=>e.name===i)}includes(i){return t(this,q).some(e=>e.name===i)}};at=new WeakMap,q=new WeakMap,Et=new WeakMap,Ft=new WeakMap,c(be,"ngFields");let se=be;const ge=class ge extends HTMLElement{constructor(){super();d(this,Q);d(this,Kt);d(this,Zt,c(()=>{this.fields=new se(this),b(this,Kt,new te(this)),S.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))},"#init"));this.attachShadow({mode:"open"}),b(this,Q,new ne(this))}connectedCallback(){t(this,Zt).call(this)}disconnectedCallback(){S.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,Kt=new WeakMap,Zt=new WeakMap,c(ge,"NineTable");let oe=ge;customElements.get("nine-table")||customElements.define("nine-table",oe)});
|
|
360
355
|
//# sourceMappingURL=nine-table.umd.js.map
|