@ninebone/table 0.0.409 → 0.0.410
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 +52 -53
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +4 -4
- 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,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 pe=Object.defineProperty;var me=m=>{throw TypeError(m)};var we=(m,p,v)=>p in m?pe(m,p,{enumerable:!0,configurable:!0,writable:!0,value:v}):m[p]=v;var a=(m,p)=>pe(m,"name",{value:p,configurable:!0});var S=(m,p,v)=>we(m,typeof p!="symbol"?p+"":p,v),xe=(m,p,v)=>p.has(m)||me("Cannot "+v);var t=(m,p,v)=>(xe(m,p,"read from private field"),v?v.call(m):p.get(m)),c=(m,p,v)=>p.has(m)?me("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(m):p.set(m,v),g=(m,p,v,
|
|
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 pe=Object.defineProperty;var me=m=>{throw TypeError(m)};var we=(m,p,v)=>p in m?pe(m,p,{enumerable:!0,configurable:!0,writable:!0,value:v}):m[p]=v;var a=(m,p)=>pe(m,"name",{value:p,configurable:!0});var S=(m,p,v)=>we(m,typeof p!="symbol"?p+"":p,v),xe=(m,p,v)=>p.has(m)||me("Cannot "+v);var t=(m,p,v)=>(xe(m,p,"read from private field"),v?v.call(m):p.get(m)),c=(m,p,v)=>p.has(m)?me("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(m):p.set(m,v),g=(m,p,v,z)=>(xe(m,p,"write to private field"),z?z.call(m,v):p.set(m,v),v);var ve=(m,p,v,z)=>({set _(ht){g(m,p,ht,v)},get _(){return t(m,p,z)}});var _,D,x,Y,U,X,At,j,Tt,F,tt,B,R,dt,ft,qt,kt,et,W,E,O,k,N,K,P,it,Lt,Ht,Ct,ut,gt,Mt,_t,bt,$t,st,yt,It,nt,Z,Wt,Ot,zt,Dt,Bt,Nt,mt,L,Pt,xt,Vt,vt,ot,H,A,C,rt,Yt,V,Ut,G,wt,Xt,jt,lt,J,at,T,St,Ft,Q,Kt,Zt;const re=class re extends m.trace.constructor{constructor(){super(),this.init("nine-table","green")}};a(re,"Trace");let p=re;const v=new p,le=class le extends HTMLElement{constructor(){super();c(this,_);c(this,D,!1);c(this,x);c(this,Y);c(this,U);c(this,X);c(this,At,a(()=>{if(!t(this,_))return;const e=t(this,_).querySelector(".ng-container-body");e&&(g(this,X,new ResizeObserver(()=>{this.refresh()})),t(this,X).observe(e))},"#observeResize"));S(this,"refresh",a(()=>{if(!t(this,_)||!t(this,x)||t(this,D))return;const e=t(this,x).container,s=e.querySelector("table");if(!s)return;const o=t(this,x).track,r=t(this,x).thumb,n=t(this,_).querySelector(".ng-container-bottom"),l=e.clientWidth,d=s.scrollWidth;if(l!==0&&d>l)n&&(n.style.display="flex");else{n&&(n.style.display="none");return}const h=o.clientWidth;if(h<=0)return;const f=Math.max(Math.min(h*(l/d),h),20);r.style.width=`${f}px`;const u=e.scrollLeft,b=d-l;let y=0;b>0&&(y=parseInt(u/b*(h-f),10)),y<0&&(y=0);const w=h-f;y>w&&(y=w),r.style.left=`${y}px`,v.log(y),t(this,x).left.disabled=y===0,t(this,x).right.disabled=y>=w-1},"refresh"));c(this,j,a(e=>{if(!t(this,x))return!1;const s=t(this,x).container,o=s.querySelector("table");if(!o)return!1;const r=t(this,x).track.getBoundingClientRect(),n=t(this,x).thumb.clientWidth;let l=e;l<0&&(l=0);const d=r.width-n;l>d&&(l=d),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>=d-1;const h=s.clientWidth,u=o.scrollWidth-h;return d>0&&u>0&&(s.scrollLeft=l/d*u),l>0&&l<d-1},"#thumbMoveTo"));c(this,Tt,a(()=>{const e=a(o=>{clearInterval(t(this,Y)),clearInterval(t(this,U));const r=parseInt(t(this,x).thumb.style.left||0,10);t(this,j).call(this,r+o),g(this,Y,setInterval(()=>{clearInterval(t(this,Y)),g(this,U,setInterval(()=>{const n=parseInt(t(this,x).thumb.style.left||0,10);t(this,j).call(this,n+o)||clearInterval(t(this,U))},50))},500))},"delayScroll"),s=a(()=>{clearInterval(t(this,Y)),clearInterval(t(this,U))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(o=>{t(this,x).left.addEventListener(o,s),t(this,x).right.addEventListener(o,s),t(this,x).track.addEventListener(o,s)}),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(),n=t(this,x).thumb.clientWidth;t(this,j).call(this,o.clientX-r.left-n/2)}),t(this,x).thumb.addEventListener("mousedown",o=>{if(o.button!==0)return;o.stopPropagation(),o.preventDefault(),g(this,D,!0),this.shiftX=o.clientX-t(this,x).thumb.getBoundingClientRect().left;const r=a(l=>{if(!t(this,D))return;const d=t(this,x).track.getBoundingClientRect();t(this,j).call(this,l.clientX-d.left-this.shiftX)},"onMouseMove"),n=a(()=>{g(this,D,!1),s(),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",n),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",n)})},"#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=a(()=>{const s=t(this,_).querySelector(".ng-container-body");if(!s){setTimeout(e,10);return}g(this,x,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),s.addEventListener("scroll",()=>{t(this,
|
|
63
|
+
`;const e=a(()=>{const s=t(this,_).querySelector(".ng-container-body");if(!s){setTimeout(e,10);return}g(this,x,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),s.addEventListener("scroll",()=>{t(this,D)||this.refresh()}),t(this,Tt).call(this),t(this,At).call(this),this.refresh()},"initWhenReady");e()}disconnectedCallback(){t(this,X)&&t(this,X).disconnect()}};_=new WeakMap,D=new WeakMap,x=new WeakMap,Y=new WeakMap,U=new WeakMap,X=new WeakMap,At=new WeakMap,j=new WeakMap,Tt=new WeakMap,a(le,"NineTableHScrollBar");let z=le;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",z);const ae=class ae extends HTMLElement{constructor(){super();c(this,F);c(this,tt);c(this,B,!1);c(this,R);c(this,dt,0);c(this,ft,0);S(this,"refresh",a(()=>{v.log("refresh",t(this,B)),v.log("refresh2");const e=t(this,R).container,s=t(this,R).track,o=t(this,R).thumb,r=e.clientHeight,l=(t(this,F).data.get()||[]).length,d=t(this,tt).getRowHeight(),h=l*d;if(h<=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=s.clientHeight;if(v.log(s,f,this,this.clientHeight),f<=0)return;const u=Math.max(Math.min(f*(r/h),f),20);o.style.height=`${u}px`;const b=e.scrollTop,y=Math.max(h-r,1);let w=0;y>0&&(w=b/y*(f-u));const q=f-u;w<0&&(w=0),w>q&&(w=q),o.style.top=`${w}px`,v.log(w),t(this,R).top.disabled=b<=0,t(this,R).bottom.disabled=b>=y-1},"refresh"));c(this,qt,a(()=>{const e=t(this,R).container,s=a(()=>{const r=(t(this,F).data.get()||[]).length,n=t(this,tt).getRowHeight();return r*n},"getContentHeight");e.addEventListener("scroll",()=>{t(this,B)||this.refresh()}),t(this,R).thumb.addEventListener("mousedown",o=>{if(o.button!==0)return;o.stopPropagation(),o.preventDefault(),g(this,B,!0),g(this,dt,o.clientY),g(this,ft,e.scrollTop);const r=a(l=>{if(!t(this,B))return;const d=t(this,R).track.getBoundingClientRect(),h=t(this,R).thumb.clientHeight,u=d.height-h,b=l.clientY-t(this,dt),y=e.clientHeight,w=s(),q=Math.max(w-y,1);if(u>0&&q>0){const ct=b/u*q;let Et=t(this,ft)+ct;const ye=Math.max(0,w-y);Et<0&&(Et=0),Et>ye&&(Et=ye),e.scrollTop=Et}this.refresh()},"onMouseMove"),n=a(()=>{g(this,B,!1),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",n),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",n)}),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(),n=t(this,R).thumb.clientHeight,l=o.clientY-r.top-n/2,h=r.height-n,f=e.clientHeight,u=s(),b=Math.max(u-f,1);if(h>0&&b>0){const y=Math.max(0,Math.min(1,l/h));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,F,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;
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
<button class='ng-scroll-top' disabled><div class='ng-scroll-icon'></div></button>
|
|
125
125
|
<div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
|
|
126
126
|
<button class='ng-scroll-bottom' disabled><div class='ng-scroll-icon'></div></button>
|
|
127
|
-
`;const e=a(()=>{const s=t(this,N).shadowRoot.querySelector(".ng-container-body");if(!s){setTimeout(e,10);return}g(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,qt).call(this),this.refresh()},"initWhenReady");e()}};N=new WeakMap,tt=new WeakMap,z=new WeakMap,R=new WeakMap,dt=new WeakMap,ft=new WeakMap,qt=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,et).call(r,e,"thead"),t(n=I,et).call(n,e,"tbody"),t(l=I,et).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,et=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,et,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 w=0;w<l[h].length;w++)if(l[h][w]===null){f=w;break}const b=u.rowSpan||1,y=u.colSpan||1;for(let w=0;w<b;w++)for(let q=0;q<y;q++)h+w<r&&f+q<n&&(l[h+w][f+q]=w===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,P,null);c(this,K,0);c(this,V,40);c(this,it,!1);c(this,Lt,3);S(this,"refresh",a(()=>{var e;const i=t(this,E).querySelector(".ng-container-body");i&&(t(this,ut).call(this),t(this,st).call(this,i.scrollTop),(e=t(this,E).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));S(this,"initialize",a(()=>{g(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,Ct).call(this,i),t(this,bt).call(this),t(this,ut).call(this),t(this,st).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,st).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,Ht,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,V);l++)s.forEach(d=>{n.appendChild(d.cloneNode(!0))});r?r.before(n):o.appendChild(n)},"#renderRows"));c(this,Ct,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(b=>b.remove());const o=s.querySelector("tr.nodata"),r=document.createDocumentFragment();e.forEach(b=>{r.appendChild(b.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(b=>{f+=b.offsetHeight||b.getBoundingClientRect().height}),u.forEach(b=>b.remove()),n.style.display=l,n.style.visibility=d,n.style.position=h,g(this,k,f>0?f:24),t(this,gt).call(this),t(this,k)},"#measureAndCacheHeight"));c(this,ut,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;v.log(`[VirtualHeight] totalCount: ${s}, rowHeight: ${o}, totalVirtualHeight: ${r}`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const l=t(this,E).querySelector(n),d=l==null?void 0:l.querySelector("table");d&&(d.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));g(this,V,e+t(this,Lt)),v.log("visibleRows:",e,"cachedRowCount:",t(this,V))}},"#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 b=[((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],y=Math.max(...b);y>0&&(o[u]&&(o[u].style.height=`${y}px`),r[u]&&(r[u].style.height=`${y}px`),n[u]&&(n[u].style.height=`${y}px`))}},"#syncRowHeights"));c(this,_t,a(()=>{!t(this,E)||!(t(this,E)instanceof HTMLElement)||(g(this,P,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&&(g(this,K,l),t(this,gt).call(this),t(this,k)!==null&&t(this,bt).call(this))}}})),t(this,P).observe(t(this,E)))},"#initResizeObserver"));c(this,bt,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,Ht).call(this,e,i)}),t(this,Mt).call(this)},"#renderAllContainers"));c(this,$t,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 b=i+Math.floor(u/n);if(b>=d){f.style.display="none";return}const y=t(this,W).data.get(b);f.style.display="",t(this,yt).call(this,f,y,b)})})},"#adjustBufferRows"));c(this,st,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=((d=t(this,O).get(".ng-container-body"))==null?void 0:d.length)||1,l=r+t(this,V);v.log(`[Scroll] scrollTop: ${i}, startIndex: ${r}, cachedRowCount: ${t(this,V)}, targetDataIndex range: ${r} ~ ${l} (Total: ${o})`),[".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("tbody.bindable-tbody");if(!u)return;Array.from(u.querySelectorAll("tr:not(.nodata)")).forEach((y,w)=>{const q=r+Math.floor(w/n);if(q>=o){y.style.display="none";return}const ct=t(this,W).data.get(q);y.style.display="",t(this,yt).call(this,y,ct,q)})}),t(this,it)||(g(this,it,!0),setTimeout(()=>{t(this,$t).call(this,r),g(this,it,!1)},0))},"#handleScroll"));c(this,yt,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,P)&&(t(this,P).disconnect(),g(this,P,null))},"destroy"));g(this,W,i.getRootNode().host),g(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,P=new WeakMap,K=new WeakMap,V=new WeakMap,it=new WeakMap,Lt=new WeakMap,Ht=new WeakMap,Ct=new WeakMap,ut=new WeakMap,gt=new WeakMap,Mt=new WeakMap,_t=new WeakMap,bt=new WeakMap,$t=new WeakMap,st=new WeakMap,yt=new WeakMap,a(ce,"RowManager");let Jt=ce;const pt=class pt extends HTMLElement{constructor(){super();c(this,It);c(this,nt,null);c(this,Z);S(this,"invalidate",a(()=>{t(this,Z).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,nt),o);r.innerHTML="",r.appendChild(n)})},"#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&&(g(this,nt,Gt.compile(e)),t(this,nt).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,Dt,a(()=>{t(this,Bt).call(this)},"#init"));c(this,Bt,a(()=>{const e=pt.SCROLLBAR_SIZE;this.innerHTML=`
|
|
127
|
+
`;const e=a(()=>{const s=t(this,F).shadowRoot.querySelector(".ng-container-body");if(!s){setTimeout(e,10);return}g(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,qt).call(this),this.refresh()},"initWhenReady");e()}};F=new WeakMap,tt=new WeakMap,B=new WeakMap,R=new WeakMap,dt=new WeakMap,ft=new WeakMap,qt=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,et).call(r,e,"thead"),t(n=I,et).call(n,e,"tbody"),t(l=I,et).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,et=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,et,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 w=0;w<l[h].length;w++)if(l[h][w]===null){f=w;break}const b=u.rowSpan||1,y=u.colSpan||1;for(let w=0;w<b;w++)for(let q=0;q<y;q++)h+w<r&&f+q<n&&(l[h+w][f+q]=w===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,N,null);c(this,K,0);c(this,P,40);c(this,it,!1);c(this,Lt,3);S(this,"refresh",a(()=>{var e;const i=t(this,E).querySelector(".ng-container-body");i&&(t(this,ut).call(this),t(this,st).call(this,i.scrollTop),(e=t(this,E).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));S(this,"initialize",a(()=>{g(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,Ct).call(this,i),t(this,bt).call(this),t(this,ut).call(this),t(this,st).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,st).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,Ht,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,P);l++)s.forEach(d=>{n.appendChild(d.cloneNode(!0))});r?r.before(n):o.appendChild(n)},"#renderRows"));c(this,Ct,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(b=>b.remove());const o=s.querySelector("tr.nodata"),r=document.createDocumentFragment();e.forEach(b=>{r.appendChild(b.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(b=>{f+=b.offsetHeight||b.getBoundingClientRect().height}),u.forEach(b=>b.remove()),n.style.display=l,n.style.visibility=d,n.style.position=h,g(this,k,f>0?f:24),t(this,gt).call(this),t(this,k)},"#measureAndCacheHeight"));c(this,ut,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;v.log(`[VirtualHeight] totalCount: ${s}, rowHeight: ${o}, totalVirtualHeight: ${r}`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const l=t(this,E).querySelector(n),d=l==null?void 0:l.querySelector("table");d&&(d.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));g(this,P,e+t(this,Lt)),v.log("visibleRows:",e,"cachedRowCount:",t(this,P))}},"#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 b=[((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],y=Math.max(...b);y>0&&(o[u]&&(o[u].style.height=`${y}px`),r[u]&&(r[u].style.height=`${y}px`),n[u]&&(n[u].style.height=`${y}px`))}},"#syncRowHeights"));c(this,_t,a(()=>{!t(this,E)||!(t(this,E)instanceof HTMLElement)||(g(this,N,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&&(g(this,K,l),t(this,gt).call(this),t(this,k)!==null&&t(this,bt).call(this))}}})),t(this,N).observe(t(this,E)))},"#initResizeObserver"));c(this,bt,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,Ht).call(this,e,i)}),t(this,Mt).call(this)},"#renderAllContainers"));c(this,$t,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 b=i+Math.floor(u/n);if(b>=d){f.style.display="none";return}const y=t(this,W).data.get(b);f.style.display="",t(this,yt).call(this,f,y,b)})})},"#adjustBufferRows"));c(this,st,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=((d=t(this,O).get(".ng-container-body"))==null?void 0:d.length)||1,l=r+t(this,P);v.log(`[Scroll] scrollTop: ${i}, startIndex: ${r}, cachedRowCount: ${t(this,P)}, targetDataIndex range: ${r} ~ ${l} (Total: ${o})`),[".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("tbody.bindable-tbody");if(!u)return;Array.from(u.querySelectorAll("tr:not(.nodata)")).forEach((y,w)=>{const q=r+Math.floor(w/n);if(q>=o){y.style.display="none";return}const ct=t(this,W).data.get(q);y.style.display="",t(this,yt).call(this,y,ct,q)})}),t(this,it)||(g(this,it,!0),setTimeout(()=>{t(this,$t).call(this,r),g(this,it,!1)},0))},"#handleScroll"));c(this,yt,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,N)&&(t(this,N).disconnect(),g(this,N,null))},"destroy"));g(this,W,i.getRootNode().host),g(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,N=new WeakMap,K=new WeakMap,P=new WeakMap,it=new WeakMap,Lt=new WeakMap,Ht=new WeakMap,Ct=new WeakMap,ut=new WeakMap,gt=new WeakMap,Mt=new WeakMap,_t=new WeakMap,bt=new WeakMap,$t=new WeakMap,st=new WeakMap,yt=new WeakMap,a(ce,"RowManager");let Jt=ce;const pt=class pt extends HTMLElement{constructor(){super();c(this,It);c(this,nt,null);c(this,Z);S(this,"invalidate",a(()=>{t(this,Z).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,nt),o);r.innerHTML="",r.appendChild(n)})},"#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&&(g(this,nt,Gt.compile(e)),t(this,nt).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,Dt,a(()=>{t(this,Bt).call(this)},"#init"));c(this,Bt,a(()=>{const e=pt.SCROLLBAR_SIZE;this.innerHTML=`
|
|
128
128
|
<style>
|
|
129
129
|
nine-table-sheet {
|
|
130
130
|
display: none;
|
|
@@ -357,5 +357,5 @@
|
|
|
357
357
|
<nine-table-analysis></nine-table-analysis>
|
|
358
358
|
</nine-table-body>
|
|
359
359
|
<nine-table-footer></nine-table-footer>
|
|
360
|
-
`;const l=t(this,L).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((d,h)=>{e[h]&&setTimeout(()=>{d.generate(e[h]),s&&t(this,xt).call(this)})})},"#render"));g(this,L,i),t(this,Pt).call(this)}};L=new WeakMap,Pt=new WeakMap,xt=new WeakMap,Vt=new WeakMap,a(de,"LayoutManager");let te=de;const fe=class fe{constructor(i){c(this,vt);c(this,ot,-1);S(this,"count",a(()=>t(this,vt).rawRecords.length,"count"));g(this,vt,i)}get at(){return t(this,ot)}set at(i){g(this,ot,parseInt(i,10)),body&&!body.querySelector(`tbody.bindable tr[data-row="${t(this,ot)}"]`)&&setTimeout(()=>{})}};vt=new WeakMap,ot=new WeakMap,a(fe,"ngRow");let ee=fe;const M=class M{constructor(i,e){c(this,H);c(this,A);c(this,C,[]);c(this,rt,[]);c(this,Yt,0);c(this,
|
|
360
|
+
`;const l=t(this,L).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((d,h)=>{e[h]&&setTimeout(()=>{d.generate(e[h]),s&&t(this,xt).call(this)})})},"#render"));g(this,L,i),t(this,Pt).call(this)}};L=new WeakMap,Pt=new WeakMap,xt=new WeakMap,Vt=new WeakMap,a(de,"LayoutManager");let te=de;const fe=class fe{constructor(i){c(this,vt);c(this,ot,-1);S(this,"count",a(()=>t(this,vt).rawRecords.length,"count"));g(this,vt,i)}get at(){return t(this,ot)}set at(i){g(this,ot,parseInt(i,10)),body&&!body.querySelector(`tbody.bindable tr[data-row="${t(this,ot)}"]`)&&setTimeout(()=>{})}};vt=new WeakMap,ot=new WeakMap,a(fe,"ngRow");let ee=fe;const M=class M{constructor(i,e){c(this,H);c(this,A);c(this,C,[]);c(this,rt,[]);c(this,Yt,0);c(this,V,[]);c(this,Ut,a(()=>{g(this,V,[]);const i=t(this,H).template||[];Array.from(i).forEach(e=>{var s;t(this,V).push(((s=e.getBoundingClientRect)==null?void 0:s.call(e).height)||24)}),(t(this,A).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,wt).call(this)),e.__ng.height=t(this,V).slice()})},"#initialize"));c(this,G,a(()=>{t(this,H).shadowRoot.querySelectorAll("nine-table-sheet").forEach(i=>{i.invalidate()})},"#invalidate"));S(this,"get",a((i,e)=>{var r;const s=this.getValidData();if(!s||s.length<=0)return;if(i==null)return t(this,lt).call(this,s);if(i<0||i>=s.length)return null;const o=typeof((r=t(this,H).fields)==null?void 0:r.get)=="function"?t(this,H).fields.get():[];if(e!=null){const n=o.indexOf(e);return n>=0?s[i].v[n]:null}return t(this,lt).call(this,s[i])},"get"));S(this,"set",a(i=>{this.clear(),this.add(i,!1),t(this,G).call(this)},"set"));c(this,wt,a(()=>({rowState:M.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,V).slice(),o:{},c:{},_:[0,0,0,0,M.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,V).slice(),-1,{},{}]}),"#getDefaultMeta"));S(this,"reset",a(()=>{g(this,C,[]),g(this,rt,[]),t(this,G).call(this)},"reset"));S(this,"clear",a(()=>{var i;t(this,A).rawRecords=[],g(this,C,[]),g(this,rt,[]),(i=t(this,A).viewRecords)!=null&&i.reset&&t(this,A).viewRecords.reset()},"clear"));c(this,Xt,a(i=>{var o;Array.isArray(i)||(i=[i]);const e=typeof((o=t(this,H).fields)==null?void 0:o.get)=="function"?t(this,H).fields.get():Object.keys(i[0]||{}),s=[];return i.forEach(r=>{const n={v:[]};e.forEach(l=>{n.v.push(r[l]!==void 0&&r[l]!==null?r[l]:"")}),s.push(n)}),s},"#json2Array"));c(this,jt,a(i=>(Array.isArray(i)||(i=[i]),i.forEach(e=>{e.__ng=t(this,wt).call(this),e.__ng.rowid=this.nextId,e.__ng.rowState=M.ROW_STATE.INSERT,e.__ng._[0]=e.__ng.rowid}),i),"#defaultInsert"));S(this,"add",a((i,e=!0)=>{i===void 0&&(i={});const s=t(this,Xt).call(this,i);t(this,A).rawRecords=t(this,A).rawRecords.concat(t(this,jt).call(this,s)),this.resetRecords();const o=this.count()-1;return e||s.forEach((r,n)=>{const l=t(this,A).rawRecords[o-n];l&&(l.__ng.rowState=M.ROW_STATE.EMPTY)}),t(this,G).call(this),o},"add"));S(this,"delete",a(i=>{let e=[];Array.isArray(i)?e=i:typeof i>"u"?e=[t(this,A).host.row.at]:e=[parseInt(i,10)],e.sort((s,o)=>o-s).forEach(s=>{if(t(this,C)[s]){const o=t(this,C)[s].__ng.rowid;t(this,C)[s].__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",a((i,e,s)=>{var d;i=parseInt(i,10);const r=(typeof((d=t(this,H).fields)==null?void 0:d.get)=="function"?t(this,H).fields.get():[]).indexOf(e);if(r<0)return;const n=this.getValidData()[i];if(!n)return;const l=n.v[r];l!==s&&n.__ng.rowState!==M.ROW_STATE.INSERT&&(n.__ng.o.hasOwnProperty(e)||(n.__ng.o[e]=l),n.__ng.rowState=M.ROW_STATE.UPDATE),n.v[r]=s},"setValue"));S(this,"resetRecords",a(()=>{g(this,rt,t(this,A).rawRecords.filter(i=>!i.__ng.deleted)),g(this,C,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,C).forEach((i,e)=>{i.__ng.i=e})},"resetRecords"));S(this,"getValidData",a(()=>(t(this,C).length===0&&t(this,A).rawRecords.length>0&&this.resetRecords(),t(this,C)),"getValidData"));c(this,lt,a(i=>{var n;if(!i)return i;const e=!Array.isArray(i),s=e?[i]:i,o=typeof((n=t(this,H).fields)==null?void 0:n.get)=="function"?t(this,H).fields.get():[],r=s.filter(l=>!l.__ng.deleted).map(l=>{const d={};return o.forEach((h,f)=>{d[h]=l.v?l.v[f]:l[h]}),d.__ng=l.__ng,d});return e?r[0]:r},"#conv"));S(this,"count",a(()=>this.getValidData().length,"count"));g(this,H,i),g(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++ve(this,Yt)._}get length(){return t(this,C).length}getRowCount(){return this.length}};H=new WeakMap,A=new WeakMap,C=new WeakMap,rt=new WeakMap,Yt=new WeakMap,V=new WeakMap,Ut=new WeakMap,G=new WeakMap,wt=new WeakMap,Xt=new WeakMap,jt=new WeakMap,lt=new WeakMap,a(M,"ngData"),S(M,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let ie=M;const ue=class ue{constructor(i){c(this,J);g(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 s=parseInt(e,10);if(!(s>=this.data.count()))return(r=(o=this.data.getValidData()[s])==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,s)=>this.data.get(e,s),this.setColumn=(e,s,o)=>{e=parseInt(e,10),this.data.setValue(e,s,o)},this.setDataSource([])}};J=new WeakMap,a(ue,"ngDataManager");let se=ue;const ge=class ge{constructor(i){c(this,at);c(this,T,[]);S(this,"add",a((i,e="string")=>{i.forEach(s=>{t(this,T).some(o=>o.name===s)||t(this,T).push({name:s,type:e})}),t(this,St).call(this)},"add"));c(this,St,a(()=>{const i=new Map;t(this,T).forEach(e=>{i.set(e.name,e.type)}),g(this,T,Array.from(i,([e,s])=>({name:e,type:s}))),g(this,T,t(this,T).filter(e=>e.name!==""&&e.name!=="__ng")),t(this,T).sort((e,s)=>e.name.length<s.name.length?1:-1)},"#adjust"));c(this,Ft,a(()=>{g(this,T,[]),v.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)v.log(e),$("[data-bind]",e).each((s,o)=>{const r=o.dataset.bind,n=o.getAttribute("data-type")||"string";r&&t(this,T).push({name:r,type:n})}),["data-expr","background-color","color","tooltip","visible","readonly","enable-button","enable-check","class-expr","icon-color","icon-src"].forEach(s=>{$(`[${s}]`,e).each((o,r)=>{var n=r.getAttribute(s);if(n.indexOf("data.")<0){const l=n.search(/[(]/g);if(l>0)try{n=String(window[n.substring(0,l).trim()])}catch{n=""}}n.split("data.").forEach(l=>{if(l.trim()!=""){const d=l.search(/[^_A-Za-z0-9]/g);let h="";d>=0?h=l.substring(0,d):n.startsWith("data.")&&(h=l.replace("data.","")),h&&t(this,T).push({name:h,type:"string"})}})})});t(this,St).call(this)}},"#init"));g(this,at,i),t(this,Ft).call(this)}get(){return t(this,T).map(i=>i.name)}getFields(){return t(this,T)}getType(i){const e=t(this,T).find(s=>s.name===i);return e?e.type:"string"}indexOf(i){return t(this,T).findIndex(e=>e.name===i)}includes(i){return t(this,T).some(e=>e.name===i)}};at=new WeakMap,T=new WeakMap,St=new WeakMap,Ft=new WeakMap,a(ge,"ngFields");let ne=ge;const be=class be extends HTMLElement{constructor(){super();c(this,Q);c(this,Kt);c(this,Zt,a(()=>{this.fields=new ne(this),g(this,Kt,new te(this)),v.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,Zt).call(this)}disconnectedCallback(){v.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,a(be,"NineTable");let oe=be;customElements.get("nine-table")||customElements.define("nine-table",oe)});
|
|
361
361
|
//# sourceMappingURL=nine-table.umd.js.map
|