@ninebone/table 0.0.369 → 0.0.371
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 +30 -31
- 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,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 be=Object.defineProperty;var ge=m=>{throw TypeError(m)};var me=(m,y,v)=>y in m?be(m,y,{enumerable:!0,configurable:!0,writable:!0,value:v}):m[y]=v;var a=(m,y)=>be(m,"name",{value:y,configurable:!0});var w=(m,y,v)=>me(m,typeof y!="symbol"?y+"":y,v),ye=(m,y,v)=>y.has(m)||ge("Cannot "+v);var t=(m,y,v)=>(ye(m,y,"read from private field"),v?v.call(m):y.get(m)),c=(m,y,v)=>y.has(m)?ge("Cannot add the same private member more than once"):y instanceof WeakSet?y.add(m):y.set(m,v),g=(m,y,v,z)=>(ye(m,y,"write to private field"),z?z.call(m,v):y.set(m,v),v);var pe=(m,y,v,z)=>({set _(at){g(m,y,at,v)},get _(){return t(m,y,z)}});var M,N,x,Y,
|
|
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 be=Object.defineProperty;var ge=m=>{throw TypeError(m)};var me=(m,y,v)=>y in m?be(m,y,{enumerable:!0,configurable:!0,writable:!0,value:v}):m[y]=v;var a=(m,y)=>be(m,"name",{value:y,configurable:!0});var w=(m,y,v)=>me(m,typeof y!="symbol"?y+"":y,v),ye=(m,y,v)=>y.has(m)||ge("Cannot "+v);var t=(m,y,v)=>(ye(m,y,"read from private field"),v?v.call(m):y.get(m)),c=(m,y,v)=>y.has(m)?ge("Cannot add the same private member more than once"):y instanceof WeakSet?y.add(m):y.set(m,v),g=(m,y,v,z)=>(ye(m,y,"write to private field"),z?z.call(m,v):y.set(m,v),v);var pe=(m,y,v,z)=>({set _(at){g(m,y,at,v)},get _(){return t(m,y,z)}});var M,N,x,V,Y,U,St,X,Et,j,B,E,ct,ht,Rt,At,Q,W,S,O,T,D,F,tt,et,qt,Tt,kt,dt,ft,Lt,Ht,ut,Ct,it,bt,_t,st,K,Mt,It,$t,Wt,Ot,zt,yt,k,Nt,pt,Bt,mt,nt,L,A,H,ot,Dt,P,Pt,Z,xt,Vt,Yt,rt,G,lt,q,vt,Ut,J,Xt,jt;const ne=class ne extends m.trace.constructor{constructor(){super(),this.init("nine-table","green")}};a(ne,"Trace");let y=ne;const v=new y,oe=class oe extends HTMLElement{constructor(){super();c(this,M);c(this,N,!1);c(this,x);c(this,V);c(this,Y);c(this,U);c(this,St,a(()=>{if(!t(this,M))return;const e=t(this,M).querySelector(".ng-container-body");e&&(g(this,U,new ResizeObserver(()=>{this.refresh()})),t(this,U).observe(e))},"#observeResize"));w(this,"refresh",a(()=>{if(!t(this,M)||!t(this,x)||t(this,N))return;const e=t(this,x).container,i=e.querySelector("table");if(!i)return;const o=t(this,x).track,r=t(this,x).thumb,n=t(this,M).querySelector(".ng-container-bottom"),l=e.clientWidth,h=i.scrollWidth;if(l!==0&&h>l)n&&(n.style.display="flex");else{n&&(n.style.display="none");return}const d=o.clientWidth;if(d<=0)return;const f=Math.max(Math.min(d*(l/h),d),20);r.style.width=`${f}px`;const u=e.scrollLeft,b=h-l;let p=0;b>0&&(p=parseInt(u/b*(d-f),10)),p<0&&(p=0);const R=d-f;p>R&&(p=R),r.style.left=`${p}px`,v.log(p),t(this,x).left.disabled=p===0,t(this,x).right.disabled=p>=R-1},"refresh"));c(this,X,a(e=>{if(!t(this,x))return!1;const i=t(this,x).container,o=i.querySelector("table");if(!o)return!1;const r=t(this,x).track.getBoundingClientRect(),n=t(this,x).thumb.clientWidth;let l=e;l<0&&(l=0);const h=r.width-n;l>h&&(l=h),l=parseInt(l,10),t(this,x).thumb.style.left=`${l}px`,t(this,x).left.disabled=l===0,t(this,x).right.disabled=l>=h-1;const d=i.clientWidth,u=o.scrollWidth-d;return h>0&&u>0&&(i.scrollLeft=l/h*u),l>0&&l<h-1},"#thumbMoveTo"));c(this,Et,a(()=>{const e=a(o=>{clearInterval(t(this,V)),clearInterval(t(this,Y));const r=parseInt(t(this,x).thumb.style.left||0,10);t(this,X).call(this,r+o),g(this,V,setInterval(()=>{clearInterval(t(this,V)),g(this,Y,setInterval(()=>{const n=parseInt(t(this,x).thumb.style.left||0,10);t(this,X).call(this,n+o)||clearInterval(t(this,Y))},50))},500))},"delayScroll"),i=a(()=>{clearInterval(t(this,V)),clearInterval(t(this,Y))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(o=>{t(this,x).left.addEventListener(o,i),t(this,x).right.addEventListener(o,i),t(this,x).track.addEventListener(o,i)}),t(this,x).left.addEventListener("mousedown",o=>{o.button===0&&e(-20)}),t(this,x).right.addEventListener("mousedown",o=>{o.button===0&&e(20)}),t(this,x).left.addEventListener("touchstart",()=>e(-20)),t(this,x).right.addEventListener("touchstart",()=>e(20)),t(this,x).track.addEventListener("mousedown",o=>{if(o.button!==0)return;o.preventDefault();const r=t(this,x).track.getBoundingClientRect(),n=t(this,x).thumb.clientWidth;t(this,X).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,N,!0),this.shiftX=o.clientX-t(this,x).thumb.getBoundingClientRect().left;const r=a(l=>{if(!t(this,N))return;const h=t(this,x).track.getBoundingClientRect();t(this,X).call(this,l.clientX-h.left-this.shiftX)},"onMouseMove"),n=a(()=>{g(this,N,!1),i(),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",n),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",n)})},"#init"))}connectedCallback(){if(g(this,M,this.closest("nine-table-sheet")||this.getRootNode().host),!t(this,M))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 i=t(this,M).querySelector(".ng-container-body");if(!i){setTimeout(e,10);return}g(this,x,{container:i,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),i.addEventListener("scroll",()=>{t(this,N)||this.refresh()}),t(this,Et).call(this),t(this,St).call(this),this.refresh()},"initWhenReady");e()}disconnectedCallback(){t(this,U)&&t(this,U).disconnect()}};M=new WeakMap,N=new WeakMap,x=new WeakMap,
|
|
63
|
+
`;const e=a(()=>{const i=t(this,M).querySelector(".ng-container-body");if(!i){setTimeout(e,10);return}g(this,x,{container:i,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),i.addEventListener("scroll",()=>{t(this,N)||this.refresh()}),t(this,Et).call(this),t(this,St).call(this),this.refresh()},"initWhenReady");e()}disconnectedCallback(){t(this,U)&&t(this,U).disconnect()}};M=new WeakMap,N=new WeakMap,x=new WeakMap,V=new WeakMap,Y=new WeakMap,U=new WeakMap,St=new WeakMap,X=new WeakMap,Et=new WeakMap,a(oe,"NineTableHScrollBar");let z=oe;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",z);const re=class re extends HTMLElement{constructor(){super();c(this,j);c(this,B,!1);c(this,E);c(this,ct,0);c(this,ht,0);w(this,"refresh",a(()=>{if(!t(this,j)||!t(this,E)||t(this,B))return;const e=t(this,E).container,i=e.querySelector("table");if(!i)return;const o=t(this,E).track,r=t(this,E).thumb,n=e.clientHeight,l=i.scrollHeight;if(l<=n){r.style.display="none",t(this,E).top.disabled=!0,t(this,E).bottom.disabled=!0;return}else r.style.display="block";const h=o.clientHeight;if(h<=0)return;const d=Math.max(Math.min(h*(n/l),h),20);r.style.height=`${d}px`;const f=e.scrollTop,u=l-n;let b=0;u>0&&(b=f/u*(h-d));const p=h-d;b<0&&(b=0),b>p&&(b=p),r.style.top=`${b}px`,t(this,E).top.disabled=f<=0,t(this,E).bottom.disabled=f>=u-1},"refresh"));c(this,Rt,a(()=>{const e=t(this,E).container;e.addEventListener("scroll",()=>{t(this,B)||this.refresh()}),t(this,E).thumb.addEventListener("mousedown",i=>{if(i.button!==0)return;i.stopPropagation(),i.preventDefault(),g(this,B,!0),g(this,ct,i.clientY),g(this,ht,e.scrollTop);const o=a(n=>{if(!t(this,B))return;const l=t(this,E).track.getBoundingClientRect(),h=t(this,E).thumb.clientHeight,f=l.height-h,u=n.clientY-t(this,ct),b=e.clientHeight,p=e.querySelector("table");v.log(p),v.log(p.scrollHeight);const C=p.scrollHeight-b;if(f>0&&C>0){const Ft=u/f*C;e.scrollTop=t(this,ht)+Ft}this.refresh()},"onMouseMove"),r=a(()=>{g(this,B,!1),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r),this.refresh()},"onMouseUp");document.addEventListener("mousemove",o),document.addEventListener("mouseup",r)}),t(this,E).track.addEventListener("mousedown",i=>{if(i.button!==0||i.target===t(this,E).thumb)return;const o=t(this,E).track.getBoundingClientRect(),r=t(this,E).thumb.clientHeight,n=i.clientY-o.top-r/2,h=o.height-r,d=e.clientHeight,u=e.querySelector("table").scrollHeight-d;if(h>0&&u>0){const b=Math.max(0,Math.min(1,n/h));e.scrollTop=b*u}this.refresh()}),t(this,E).top.addEventListener("click",()=>{e.scrollTop-=40}),t(this,E).bottom.addEventListener("click",()=>{e.scrollTop+=40})},"#init"))}connectedCallback(){if(g(this,j,this.closest("nine-table-sheet")||this.getRootNode().host),!t(this,j))return;this.innerHTML=`
|
|
64
64
|
<style>
|
|
65
65
|
nine-table-vscrollbar {
|
|
66
66
|
display: flex;
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
<button class='ng-scroll-top' disabled><div class='ng-scroll-icon'></div></button>
|
|
123
123
|
<div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
|
|
124
124
|
<button class='ng-scroll-bottom' disabled><div class='ng-scroll-icon'></div></button>
|
|
125
|
-
`;const e=a(()=>{const i=t(this,j).querySelector(".ng-container-body");if(!i){setTimeout(e,10);return}g(this,E,{container:i,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),top:this.querySelector(".ng-scroll-top"),bottom:this.querySelector(".ng-scroll-bottom")}),t(this,Rt).call(this),this.refresh()},"initWhenReady");e()}};j=new WeakMap,B=new WeakMap,E=new WeakMap,ct=new WeakMap,ht=new WeakMap,Rt=new WeakMap,a(re,"NineTableVScrollBar");let at=re;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",at);const I=class I{static compileAll(s){return Array.isArray(s)?s.map(e=>I.compile(e)):[]}static compile(s){var o,r,n,l;if(!s)return null;const e=s.cloneNode(!0);return t(o=I,At).call(o,e),t(r=I,Q).call(r,e,"thead"),t(n=I,Q).call(n,e,"tbody"),t(l=I,Q).call(l,e,"tfoot"),Array.from(e.querySelectorAll("colgroup col")).forEach((h,d)=>{const f=h.getAttribute("fixed");f&&e.querySelectorAll(`thead [data-col="${d}"], tbody [data-col="${d}"], tfoot [data-col="${d}"]`).forEach(u=>{u.setAttribute("fixed",f)})}),e}};At=new WeakMap,Q=new WeakMap,a(I,"TableCompiler"),c(I,At,a(s=>{if(!s.querySelector("colgroup")){const e=s.querySelector("tbody tr")||s.querySelector("tr"),i=e?e.querySelectorAll("th, td").length:1,o=document.createElement("colgroup"),r=Math.max(Math.floor(s.clientWidth/i),100);for(let n=0;n<i;n++){const l=document.createElement("col");l.setAttribute("width",r),o.appendChild(l)}s.prepend(o)}if(!s.querySelector("thead")){const e=document.createElement("thead"),i=s.querySelector("colgroup");i?i.after(e):s.prepend(e)}s.classList.add("nine-table-element"),s.style.display="table"},"#ensureTableStructure")),c(I,Q,a((s,e)=>{const i=Array.from(s.querySelectorAll(e+" tr")),o=Array.from(s.querySelectorAll(e+" th,"+e+" td")),r=i.length;if(r===0||o.length===0)return;let n=0;o.forEach(h=>{n+=h.colSpan||1});const l=Array.from(Array(r),()=>Array(n).fill(null));i.forEach(h=>{const d=h.sectionRowIndex;let f=0;Array.from(h.querySelectorAll("th,td")).forEach(u=>{for(let R=0;R<l[d].length;R++)if(l[d][R]===null){f=R;break}const b=u.rowSpan||1,p=u.colSpan||1;for(let R=0;R<b;R++)for(let C=0;C<p;C++)d+R<r&&f+C<n&&(l[d+R][f+C]=R===0&&C===0?"1":"0")})}),i.forEach(h=>{const d=h.sectionRowIndex;Array.from(h.querySelectorAll("th,td")).forEach(f=>{for(let u=0;u<l[d].length;u++)if(l[d][u]==="1"){f.dataset.col=u,l[d][u]="0";break}})})},"#resetColIndex"));let Kt=I;const le=class le{constructor(s){c(this,W);c(this,S);c(this,O,new Map);c(this,T,null);c(this,D,null);c(this,F,0);c(this,tt,40);c(this,et,!1);c(this,qt,3);w(this,"refresh",a(()=>{var e;const s=t(this,S).querySelector(".ng-container-body");s&&(t(this,dt).call(this),t(this,it).call(this,s.scrollTop),(e=t(this,S).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));w(this,"initialize",a(()=>{g(this,T,null),t(this,O).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const r=t(this,S).querySelector(o);if(!r)return;const n=r.querySelector("table");if(!n)return;const l=n.querySelector("tbody.bindable-tbody");if(!l)return;const d=Array.from(l.querySelectorAll("tr")).map(f=>f.cloneNode(!0));t(this,O).set(o,d)});const s=t(this,S).querySelector(".ng-container-body"),e=t(this,S).querySelector(".ng-container-left"),i=t(this,S).querySelector(".ng-container-right");if(s){t(this,kt).call(this,s),t(this,ut).call(this),t(this,dt).call(this),t(this,it).call(this,s.scrollTop);let o=s.scrollTop;const r=a(n=>{var l;e&&e.scrollTop!==n&&(e.scrollTop=n),i&&i.scrollTop!==n&&(i.scrollTop=n),t(this,it).call(this,n),(l=t(this,S).querySelector("nine-table-vscrollbar"))==null||l.refresh()},"syncScroll");s.addEventListener("scroll",()=>{const n=s.scrollTop;o!==n&&(o=n,r(n))})}},"initialize"));c(this,Tt,a((s,e)=>{const i=t(this,O).get(e);if(!i||i.length===0)return;const o=s.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,tt);l++)i.forEach(h=>{n.appendChild(h.cloneNode(!0))});r?r.before(n):o.appendChild(n)},"#renderRows"));c(this,kt,a(s=>{if(t(this,T)!==null&&t(this,T)>0)return t(this,T);const e=t(this,O).get(".ng-container-body");if(!e||e.length===0)return 24;const i=s.querySelector("tbody.bindable-tbody")||s.querySelector("tbody.bindable-tbody:last-of-type");if(!i)return 24;i.querySelectorAll("tr:not(.nodata)").forEach(b=>b.remove());const o=i.querySelector("tr.nodata"),r=document.createDocumentFragment();e.forEach(b=>{r.appendChild(b.cloneNode(!0))}),o?o.before(r):i.appendChild(r);const n=t(this,S),l=n.style.display,h=n.style.visibility,d=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=i.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=h,n.style.position=d,g(this,T,f>0?f:24),t(this,ft).call(this),t(this,T)},"#measureAndCacheHeight"));c(this,dt,a(()=>{if(!t(this,S).querySelector(".ng-container-body"))return;const e=t(this,W).data.get()||[],i=e.length>0?e.length:100,o=t(this,T),r=i*o;v.log(":",i,r),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const l=t(this,S).querySelector(n),h=l==null?void 0:l.querySelector("table");h&&(h.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));c(this,ft,a(()=>{const e=(t(this,W).data.get()||[]).length;if(t(this,F)>0&&t(this,T)>0){const i=Math.ceil(t(this,F)/t(this,T));g(this,tt,Math.min(e,i+t(this,qt))),v.log(i,t(this,tt))}},"#updateRowCount"));c(this,Lt,a(()=>{var h,d,f;const s=t(this,S).querySelector(".ng-container-left table"),e=t(this,S).querySelector(".ng-container-body table"),i=t(this,S).querySelector(".ng-container-right table");if(!e)return;const o=s?Array.from(s.querySelectorAll("tr")):[],r=Array.from(e.querySelectorAll("tr")),n=i?Array.from(i.querySelectorAll("tr")):[],l=Math.max(o.length,r.length,n.length);for(let u=0;u<l;u++){const b=[((h=o[u])==null?void 0:h.getBoundingClientRect().height)||0,((d=r[u])==null?void 0:d.getBoundingClientRect().height)||0,((f=n[u])==null?void 0:f.getBoundingClientRect().height)||0],p=Math.max(...b);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,Ht,a(()=>{!t(this,S)||!(t(this,S)instanceof HTMLElement)||(g(this,D,new ResizeObserver(s=>{for(const e of s){const i=e.target;if(!i.classList.contains("active"))continue;const o=e.contentRect.height;if(o>0){let r=0;const n=i.querySelector("thead");n&&(r+=n.offsetHeight||n.getBoundingClientRect().height);const l=Math.max(o-r,100);t(this,F)!==l&&(g(this,F,l),t(this,ft).call(this),t(this,T)!==null&&t(this,ut).call(this))}}})),t(this,D).observe(t(this,S)))},"#initResizeObserver"));c(this,ut,a(()=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(s=>{const e=t(this,S).querySelector(s);e&&e.querySelector("tbody.bindable-tbody")&&t(this,Tt).call(this,e,s)}),t(this,Lt).call(this)},"#renderAllContainers"));c(this,Ct,a(s=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(e=>{var d;const i=t(this,S).querySelector(e);if(!i)return;const o=i.querySelector("tbody.bindable-tbody");if(!o)return;const r=Array.from(o.querySelectorAll("tr:not(.nodata)")),n=((d=t(this,O).get(e))==null?void 0:d.length)||1,h=(t(this,W).data.get()||[]).length;r.forEach((f,u)=>{const b=s+Math.floor(u/n);if(b>=h){f.style.display="none";return}const p=t(this,W).data.get(b);f.style.display="",t(this,bt).call(this,f,p,b)})})},"#adjustBufferRows"));c(this,it,a(s=>{var l;const e=t(this,T);if(!e||e<=0)return;const i=Math.max(0,Math.floor(s/e)),o=((l=t(this,O).get(".ng-container-body"))==null?void 0:l.length)||1,n=(t(this,W).data.get()||[]).length;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(h=>{const d=t(this,S).querySelector(h);if(!d)return;const f=d.querySelector("tbody.bindable-tbody");if(!f)return;Array.from(f.querySelectorAll("tr:not(.nodata)")).forEach((b,p)=>{const R=i+Math.floor(p/o);if(R>=n){b.style.display="none";return}const C=t(this,W).data.get(R);b.style.display="",t(this,bt).call(this,b,C,R)})}),t(this,et)||(g(this,et,!0),setTimeout(()=>{t(this,Ct).call(this,i),g(this,et,!1)},0))},"#handleScroll"));c(this,bt,a((s,e,i)=>{s.dataset.row=i,Array.from(s.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${i}C${r}`:`행 ${i+1}`,o.dataset.row=i})},"#bindRowData"));w(this,"destroy",a(()=>{t(this,D)&&(t(this,D).disconnect(),g(this,D,null))},"destroy"));g(this,W,s.getRootNode().host),g(this,S,s),t(this,Ht).call(this)}getRowHeight(){return t(this,T)}templateLength(s=".ng-container-body"){var e;return((e=t(this,O).get(s))==null?void 0:e.length)||1}};W=new WeakMap,S=new WeakMap,O=new WeakMap,T=new WeakMap,D=new WeakMap,F=new WeakMap,tt=new WeakMap,et=new WeakMap,qt=new WeakMap,Tt=new WeakMap,kt=new WeakMap,dt=new WeakMap,ft=new WeakMap,Lt=new WeakMap,Ht=new WeakMap,ut=new WeakMap,Ct=new WeakMap,it=new WeakMap,bt=new WeakMap,a(le,"RowManager");let Zt=le;const gt=class gt extends HTMLElement{constructor(){super();c(this,_t);c(this,st,null);c(this,K);w(this,"invalidate",a(()=>{t(this,K).refresh()},"invalidate"));c(this,Mt,a(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:i,type:o})=>{const r=this.querySelector(i);if(!r)return;const n=t(this,$t).call(this,t(this,st),o);r.innerHTML="",r.appendChild(n)})},"#renderSplitContainers"));c(this,It,a(()=>{["left","right"].forEach(e=>{const i=this.querySelector(`.ng-container-${e}`),o=i==null?void 0:i.querySelector("table");if(!i||!o)return;let r=0;o.querySelectorAll("col").forEach(n=>{const l=parseInt(n.getAttribute("width"),10);isNaN(r)||(r+=l)}),i.style.flex=`0 0 ${r}px`,i.style.width=`${r}px`})},"#updateContainerWidths"));w(this,"generate",a(e=>{e&&(g(this,st,Kt.compile(e)),t(this,st).style.display="table",t(this,Mt).call(this),t(this,It).call(this),requestAnimationFrame(()=>{var o;const i=(o=this.querySelector("thead"))==null?void 0:o.getBoundingClientRect().height;this.querySelectorAll("tbody.fixed-tbody").forEach(r=>{r.style.top=`${i}px`})}),t(this,K).initialize(),setTimeout(()=>{var i;(i=this.querySelector("nine-table-hscrollbar"))==null||i.refresh()},0))},"generate"));c(this,$t,a((e,i)=>{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 i==="left"?o.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(n=>{n.getAttribute("fixed")!=="left"&&n.remove()}):i==="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"));w(this,"getRowHeight",a(()=>t(this,K).getRowHeight(),"getRowHeight"));w(this,"scrollToX",a(e=>{const i=this.querySelector(".ng-container-body");i&&(i.scrollLeft=e)},"scrollToX"));w(this,"scrollToY",a(e=>{const i=this.querySelector(".ng-container-body");i&&(i.scrollTop=e)},"scrollToY"));c(this,Wt,a(()=>{t(this,Ot).call(this)},"#init"));c(this,Ot,a(()=>{const e=gt.SCROLLBAR_SIZE;this.innerHTML=`
|
|
125
|
+
`;const e=a(()=>{const i=t(this,j).querySelector(".ng-container-body");if(!i){setTimeout(e,10);return}g(this,E,{container:i,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),top:this.querySelector(".ng-scroll-top"),bottom:this.querySelector(".ng-scroll-bottom")}),t(this,Rt).call(this),this.refresh()},"initWhenReady");e()}};j=new WeakMap,B=new WeakMap,E=new WeakMap,ct=new WeakMap,ht=new WeakMap,Rt=new WeakMap,a(re,"NineTableVScrollBar");let at=re;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",at);const I=class I{static compileAll(s){return Array.isArray(s)?s.map(e=>I.compile(e)):[]}static compile(s){var o,r,n,l;if(!s)return null;const e=s.cloneNode(!0);return t(o=I,At).call(o,e),t(r=I,Q).call(r,e,"thead"),t(n=I,Q).call(n,e,"tbody"),t(l=I,Q).call(l,e,"tfoot"),Array.from(e.querySelectorAll("colgroup col")).forEach((h,d)=>{const f=h.getAttribute("fixed");f&&e.querySelectorAll(`thead [data-col="${d}"], tbody [data-col="${d}"], tfoot [data-col="${d}"]`).forEach(u=>{u.setAttribute("fixed",f)})}),e}};At=new WeakMap,Q=new WeakMap,a(I,"TableCompiler"),c(I,At,a(s=>{if(!s.querySelector("colgroup")){const e=s.querySelector("tbody tr")||s.querySelector("tr"),i=e?e.querySelectorAll("th, td").length:1,o=document.createElement("colgroup"),r=Math.max(Math.floor(s.clientWidth/i),100);for(let n=0;n<i;n++){const l=document.createElement("col");l.setAttribute("width",r),o.appendChild(l)}s.prepend(o)}if(!s.querySelector("thead")){const e=document.createElement("thead"),i=s.querySelector("colgroup");i?i.after(e):s.prepend(e)}s.classList.add("nine-table-element"),s.style.display="table"},"#ensureTableStructure")),c(I,Q,a((s,e)=>{const i=Array.from(s.querySelectorAll(e+" tr")),o=Array.from(s.querySelectorAll(e+" th,"+e+" td")),r=i.length;if(r===0||o.length===0)return;let n=0;o.forEach(h=>{n+=h.colSpan||1});const l=Array.from(Array(r),()=>Array(n).fill(null));i.forEach(h=>{const d=h.sectionRowIndex;let f=0;Array.from(h.querySelectorAll("th,td")).forEach(u=>{for(let R=0;R<l[d].length;R++)if(l[d][R]===null){f=R;break}const b=u.rowSpan||1,p=u.colSpan||1;for(let R=0;R<b;R++)for(let C=0;C<p;C++)d+R<r&&f+C<n&&(l[d+R][f+C]=R===0&&C===0?"1":"0")})}),i.forEach(h=>{const d=h.sectionRowIndex;Array.from(h.querySelectorAll("th,td")).forEach(f=>{for(let u=0;u<l[d].length;u++)if(l[d][u]==="1"){f.dataset.col=u,l[d][u]="0";break}})})},"#resetColIndex"));let Kt=I;const le=class le{constructor(s){c(this,W);c(this,S);c(this,O,new Map);c(this,T,null);c(this,D,null);c(this,F,0);c(this,tt,40);c(this,et,!1);c(this,qt,3);w(this,"refresh",a(()=>{var e;const s=t(this,S).querySelector(".ng-container-body");s&&(t(this,dt).call(this),t(this,it).call(this,s.scrollTop),(e=t(this,S).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));w(this,"initialize",a(()=>{g(this,T,null),t(this,O).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const r=t(this,S).querySelector(o);if(!r)return;const n=r.querySelector("table");if(!n)return;const l=n.querySelector("tbody.bindable-tbody");if(!l)return;const d=Array.from(l.querySelectorAll("tr")).map(f=>f.cloneNode(!0));t(this,O).set(o,d)});const s=t(this,S).querySelector(".ng-container-body"),e=t(this,S).querySelector(".ng-container-left"),i=t(this,S).querySelector(".ng-container-right");if(s){t(this,kt).call(this,s),t(this,ut).call(this),t(this,dt).call(this),t(this,it).call(this,s.scrollTop);let o=s.scrollTop;const r=a(n=>{var l;e&&e.scrollTop!==n&&(e.scrollTop=n),i&&i.scrollTop!==n&&(i.scrollTop=n),t(this,it).call(this,n),(l=t(this,S).querySelector("nine-table-vscrollbar"))==null||l.refresh()},"syncScroll");s.addEventListener("scroll",()=>{const n=s.scrollTop;o!==n&&(o=n,r(n))})}},"initialize"));c(this,Tt,a((s,e)=>{const i=t(this,O).get(e);if(!i||i.length===0)return;const o=s.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,tt);l++)i.forEach(h=>{n.appendChild(h.cloneNode(!0))});r?r.before(n):o.appendChild(n)},"#renderRows"));c(this,kt,a(s=>{if(t(this,T)!==null&&t(this,T)>0)return t(this,T);const e=t(this,O).get(".ng-container-body");if(!e||e.length===0)return 24;const i=s.querySelector("tbody.bindable-tbody")||s.querySelector("tbody.bindable-tbody:last-of-type");if(!i)return 24;i.querySelectorAll("tr:not(.nodata)").forEach(b=>b.remove());const o=i.querySelector("tr.nodata"),r=document.createDocumentFragment();e.forEach(b=>{r.appendChild(b.cloneNode(!0))}),o?o.before(r):i.appendChild(r);const n=t(this,S),l=n.style.display,h=n.style.visibility,d=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=i.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=h,n.style.position=d,g(this,T,f>0?f:24),t(this,ft).call(this),t(this,T)},"#measureAndCacheHeight"));c(this,dt,a(()=>{if(!t(this,S).querySelector(".ng-container-body"))return;const i=(t(this,W).data.get()||[]).length,o=t(this,T)||24,r=i*o;v.log(`[VirtualHeight] totalCount: ${i}, rowHeight: ${o}, totalVirtualHeight: ${r}`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const l=t(this,S).querySelector(n),h=l==null?void 0:l.querySelector("table");h&&(h.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));c(this,ft,a(()=>{if((t(this,W).data.get()||[]).length,t(this,F)>0&&t(this,T)>0){const e=Math.ceil(t(this,F)/t(this,T));g(this,tt,e+t(this,qt)),v.log("visibleRows:",e,"cachedRowCount:",t(this,tt))}},"#updateRowCount"));c(this,Lt,a(()=>{var h,d,f;const s=t(this,S).querySelector(".ng-container-left table"),e=t(this,S).querySelector(".ng-container-body table"),i=t(this,S).querySelector(".ng-container-right table");if(!e)return;const o=s?Array.from(s.querySelectorAll("tr")):[],r=Array.from(e.querySelectorAll("tr")),n=i?Array.from(i.querySelectorAll("tr")):[],l=Math.max(o.length,r.length,n.length);for(let u=0;u<l;u++){const b=[((h=o[u])==null?void 0:h.getBoundingClientRect().height)||0,((d=r[u])==null?void 0:d.getBoundingClientRect().height)||0,((f=n[u])==null?void 0:f.getBoundingClientRect().height)||0],p=Math.max(...b);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,Ht,a(()=>{!t(this,S)||!(t(this,S)instanceof HTMLElement)||(g(this,D,new ResizeObserver(s=>{for(const e of s){const i=e.target;if(!i.classList.contains("active"))continue;const o=e.contentRect.height;if(o>0){let r=0;const n=i.querySelector("thead");n&&(r+=n.offsetHeight||n.getBoundingClientRect().height);const l=Math.max(o-r,100);t(this,F)!==l&&(g(this,F,l),t(this,ft).call(this),t(this,T)!==null&&t(this,ut).call(this))}}})),t(this,D).observe(t(this,S)))},"#initResizeObserver"));c(this,ut,a(()=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(s=>{const e=t(this,S).querySelector(s);e&&e.querySelector("tbody.bindable-tbody")&&t(this,Tt).call(this,e,s)}),t(this,Lt).call(this)},"#renderAllContainers"));c(this,Ct,a(s=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(e=>{var d;const i=t(this,S).querySelector(e);if(!i)return;const o=i.querySelector("tbody.bindable-tbody");if(!o)return;const r=Array.from(o.querySelectorAll("tr:not(.nodata)")),n=((d=t(this,O).get(e))==null?void 0:d.length)||1,h=(t(this,W).data.get()||[]).length;r.forEach((f,u)=>{const b=s+Math.floor(u/n);if(b>=h){f.style.display="none";return}const p=t(this,W).data.get(b);f.style.display="",t(this,bt).call(this,f,p,b)})})},"#adjustBufferRows"));c(this,it,a(s=>{var l;const e=t(this,T);if(!e||e<=0)return;const i=Math.max(0,Math.floor(s/e)),o=((l=t(this,O).get(".ng-container-body"))==null?void 0:l.length)||1,n=(t(this,W).data.get()||[]).length;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(h=>{const d=t(this,S).querySelector(h);if(!d)return;const f=d.querySelector("tbody.bindable-tbody");if(!f)return;Array.from(f.querySelectorAll("tr:not(.nodata)")).forEach((b,p)=>{const R=i+Math.floor(p/o);if(R>=n){b.style.display="none";return}const C=t(this,W).data.get(R);b.style.display="",t(this,bt).call(this,b,C,R)})}),t(this,et)||(g(this,et,!0),setTimeout(()=>{t(this,Ct).call(this,i),g(this,et,!1)},0))},"#handleScroll"));c(this,bt,a((s,e,i)=>{s.dataset.row=i,Array.from(s.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${i}C${r}`:`행 ${i+1}`,o.dataset.row=i})},"#bindRowData"));w(this,"destroy",a(()=>{t(this,D)&&(t(this,D).disconnect(),g(this,D,null))},"destroy"));g(this,W,s.getRootNode().host),g(this,S,s),t(this,Ht).call(this)}getRowHeight(){return t(this,T)}templateLength(s=".ng-container-body"){var e;return((e=t(this,O).get(s))==null?void 0:e.length)||1}};W=new WeakMap,S=new WeakMap,O=new WeakMap,T=new WeakMap,D=new WeakMap,F=new WeakMap,tt=new WeakMap,et=new WeakMap,qt=new WeakMap,Tt=new WeakMap,kt=new WeakMap,dt=new WeakMap,ft=new WeakMap,Lt=new WeakMap,Ht=new WeakMap,ut=new WeakMap,Ct=new WeakMap,it=new WeakMap,bt=new WeakMap,a(le,"RowManager");let Zt=le;const gt=class gt extends HTMLElement{constructor(){super();c(this,_t);c(this,st,null);c(this,K);w(this,"invalidate",a(()=>{t(this,K).refresh()},"invalidate"));c(this,Mt,a(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:i,type:o})=>{const r=this.querySelector(i);if(!r)return;const n=t(this,$t).call(this,t(this,st),o);r.innerHTML="",r.appendChild(n)})},"#renderSplitContainers"));c(this,It,a(()=>{["left","right"].forEach(e=>{const i=this.querySelector(`.ng-container-${e}`),o=i==null?void 0:i.querySelector("table");if(!i||!o)return;let r=0;o.querySelectorAll("col").forEach(n=>{const l=parseInt(n.getAttribute("width"),10);isNaN(r)||(r+=l)}),i.style.flex=`0 0 ${r}px`,i.style.width=`${r}px`})},"#updateContainerWidths"));w(this,"generate",a(e=>{e&&(g(this,st,Kt.compile(e)),t(this,st).style.display="table",t(this,Mt).call(this),t(this,It).call(this),requestAnimationFrame(()=>{var o;const i=(o=this.querySelector("thead"))==null?void 0:o.getBoundingClientRect().height;this.querySelectorAll("tbody.fixed-tbody").forEach(r=>{r.style.top=`${i}px`})}),t(this,K).initialize(),setTimeout(()=>{var i;(i=this.querySelector("nine-table-hscrollbar"))==null||i.refresh()},0))},"generate"));c(this,$t,a((e,i)=>{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 i==="left"?o.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(n=>{n.getAttribute("fixed")!=="left"&&n.remove()}):i==="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"));w(this,"getRowHeight",a(()=>t(this,K).getRowHeight(),"getRowHeight"));w(this,"scrollToX",a(e=>{const i=this.querySelector(".ng-container-body");i&&(i.scrollLeft=e)},"scrollToX"));w(this,"scrollToY",a(e=>{const i=this.querySelector(".ng-container-body");i&&(i.scrollTop=e)},"scrollToY"));c(this,Wt,a(()=>{t(this,Ot).call(this)},"#init"));c(this,Ot,a(()=>{const e=gt.SCROLLBAR_SIZE;this.innerHTML=`
|
|
126
126
|
<style>
|
|
127
127
|
nine-table-sheet {
|
|
128
128
|
display: none;
|
|
@@ -363,5 +363,5 @@
|
|
|
363
363
|
<nine-table-analysis></nine-table-analysis>
|
|
364
364
|
</nine-table-body>
|
|
365
365
|
<nine-table-footer></nine-table-footer>
|
|
366
|
-
`;const l=t(this,k).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((h,d)=>{e[d]&&setTimeout(()=>{h.generate(e[d]),i&&t(this,pt).call(this)})})},"#render"));g(this,k,s),t(this,Nt).call(this)}};k=new WeakMap,Nt=new WeakMap,pt=new WeakMap,Bt=new WeakMap,a(ce,"LayoutManager");let Jt=ce;const he=class he{constructor(s){c(this,mt);c(this,nt,-1);w(this,"count",a(()=>t(this,mt).rawRecords.length,"count"));g(this,mt,s)}get at(){return t(this,nt)}set at(s){g(this,nt,parseInt(s,10)),body&&!body.querySelector(`tbody.bindable tr[data-row="${t(this,nt)}"]`)&&setTimeout(()=>{})}};mt=new WeakMap,nt=new WeakMap,a(he,"ngRow");let Qt=he;const _=class _{constructor(s,e){c(this,L);c(this,A);c(this,H,[]);c(this,ot,[]);c(this,Dt,0);c(this,P,[]);c(this,Pt,a(()=>{g(this,P,[]);const s=t(this,L).template||[];Array.from(s).forEach(e=>{var i;t(this,P).push(((i=e.getBoundingClientRect)==null?void 0:i.call(e).height)||24)}),(t(this,A).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,xt).call(this)),e.__ng.height=t(this,P).slice()})},"#initialize"));c(this,Z,a(()=>{t(this,L).shadowRoot.querySelectorAll("nine-table-sheet").forEach(s=>{s.invalidate()})},"#invalidate"));w(this,"get",a((s,e)=>{var r;const i=this.getValidData();if(!i||i.length<=0)return;if(s==null)return t(this,rt).call(this,i);if(s<0||s>=i.length)return null;const o=typeof((r=t(this,L).fields)==null?void 0:r.get)=="function"?t(this,L).fields.get():[];if(e!=null){const n=o.indexOf(e);return n>=0?i[s].v[n]:null}return t(this,rt).call(this,i[s])},"get"));w(this,"set",a(s=>{this.clear(),this.add(s,!1),t(this,Z).call(this)},"set"));c(this,xt,a(()=>({rowState:_.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,P).slice(),o:{},c:{},_:[0,0,0,0,_.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,P).slice(),-1,{},{}]}),"#getDefaultMeta"));w(this,"reset",a(()=>{g(this,H,[]),g(this,ot,[]),t(this,Z).call(this)},"reset"));w(this,"clear",a(()=>{var s;t(this,A).rawRecords=[],g(this,H,[]),g(this,ot,[]),(s=t(this,A).viewRecords)!=null&&s.reset&&t(this,A).viewRecords.reset()},"clear"));c(this,
|
|
366
|
+
`;const l=t(this,k).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((h,d)=>{e[d]&&setTimeout(()=>{h.generate(e[d]),i&&t(this,pt).call(this)})})},"#render"));g(this,k,s),t(this,Nt).call(this)}};k=new WeakMap,Nt=new WeakMap,pt=new WeakMap,Bt=new WeakMap,a(ce,"LayoutManager");let Jt=ce;const he=class he{constructor(s){c(this,mt);c(this,nt,-1);w(this,"count",a(()=>t(this,mt).rawRecords.length,"count"));g(this,mt,s)}get at(){return t(this,nt)}set at(s){g(this,nt,parseInt(s,10)),body&&!body.querySelector(`tbody.bindable tr[data-row="${t(this,nt)}"]`)&&setTimeout(()=>{})}};mt=new WeakMap,nt=new WeakMap,a(he,"ngRow");let Qt=he;const _=class _{constructor(s,e){c(this,L);c(this,A);c(this,H,[]);c(this,ot,[]);c(this,Dt,0);c(this,P,[]);c(this,Pt,a(()=>{g(this,P,[]);const s=t(this,L).template||[];Array.from(s).forEach(e=>{var i;t(this,P).push(((i=e.getBoundingClientRect)==null?void 0:i.call(e).height)||24)}),(t(this,A).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,xt).call(this)),e.__ng.height=t(this,P).slice()})},"#initialize"));c(this,Z,a(()=>{t(this,L).shadowRoot.querySelectorAll("nine-table-sheet").forEach(s=>{s.invalidate()})},"#invalidate"));w(this,"get",a((s,e)=>{var r;const i=this.getValidData();if(!i||i.length<=0)return;if(s==null)return t(this,rt).call(this,i);if(s<0||s>=i.length)return null;const o=typeof((r=t(this,L).fields)==null?void 0:r.get)=="function"?t(this,L).fields.get():[];if(e!=null){const n=o.indexOf(e);return n>=0?i[s].v[n]:null}return t(this,rt).call(this,i[s])},"get"));w(this,"set",a(s=>{this.clear(),this.add(s,!1),t(this,Z).call(this)},"set"));c(this,xt,a(()=>({rowState:_.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,P).slice(),o:{},c:{},_:[0,0,0,0,_.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,P).slice(),-1,{},{}]}),"#getDefaultMeta"));w(this,"reset",a(()=>{g(this,H,[]),g(this,ot,[]),t(this,Z).call(this)},"reset"));w(this,"clear",a(()=>{var s;t(this,A).rawRecords=[],g(this,H,[]),g(this,ot,[]),(s=t(this,A).viewRecords)!=null&&s.reset&&t(this,A).viewRecords.reset()},"clear"));c(this,Vt,a(s=>{var o;Array.isArray(s)||(s=[s]);const e=typeof((o=t(this,L).fields)==null?void 0:o.get)=="function"?t(this,L).fields.get():Object.keys(s[0]||{}),i=[];return s.forEach(r=>{const n={v:[]};e.forEach(l=>{n.v.push(r[l]!==void 0&&r[l]!==null?r[l]:"")}),i.push(n)}),i},"#json2Array"));c(this,Yt,a(s=>(Array.isArray(s)||(s=[s]),s.forEach(e=>{e.__ng=t(this,xt).call(this),e.__ng.rowid=this.nextId,e.__ng.rowState=_.ROW_STATE.INSERT,e.__ng._[0]=e.__ng.rowid}),s),"#defaultInsert"));w(this,"add",a((s,e=!0)=>{s===void 0&&(s={});const i=t(this,Vt).call(this,s);t(this,A).rawRecords=t(this,A).rawRecords.concat(t(this,Yt).call(this,i)),this.resetRecords();const o=this.count()-1;return e||i.forEach((r,n)=>{const l=t(this,A).rawRecords[o-n];l&&(l.__ng.rowState=_.ROW_STATE.EMPTY)}),t(this,Z).call(this),o},"add"));w(this,"delete",a(s=>{let e=[];Array.isArray(s)?e=s:typeof s>"u"?e=[t(this,A).host.row.at]:e=[parseInt(s,10)],e.sort((i,o)=>o-i).forEach(i=>{if(t(this,H)[i]){const o=t(this,H)[i].__ng.rowid;t(this,H)[i].__ng.rowState===_.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=_.ROW_STATE.DELETE)})}}),this.resetRecords(),t(this,Z).call(this)},"delete"));w(this,"setValue",a((s,e,i)=>{var h;s=parseInt(s,10);const r=(typeof((h=t(this,L).fields)==null?void 0:h.get)=="function"?t(this,L).fields.get():[]).indexOf(e);if(r<0)return;const n=this.getValidData()[s];if(!n)return;const l=n.v[r];l!==i&&n.__ng.rowState!==_.ROW_STATE.INSERT&&(n.__ng.o.hasOwnProperty(e)||(n.__ng.o[e]=l),n.__ng.rowState=_.ROW_STATE.UPDATE),n.v[r]=i},"setValue"));w(this,"resetRecords",a(()=>{g(this,ot,t(this,A).rawRecords.filter(s=>!s.__ng.deleted)),g(this,H,t(this,A).rawRecords.filter(s=>!s.__ng.deleted&&!s.__ng.filtered)),t(this,A).rawRecords.forEach((s,e)=>{s.__ng.rowidx=e}),t(this,H).forEach((s,e)=>{s.__ng.i=e})},"resetRecords"));w(this,"getValidData",a(()=>(t(this,H).length===0&&t(this,A).rawRecords.length>0&&this.resetRecords(),t(this,H)),"getValidData"));c(this,rt,a(s=>{var n;if(!s)return s;const e=!Array.isArray(s),i=e?[s]:s,o=typeof((n=t(this,L).fields)==null?void 0:n.get)=="function"?t(this,L).fields.get():[],r=i.filter(l=>!l.__ng.deleted).map(l=>{const h={};return o.forEach((d,f)=>{h[d]=l.v?l.v[f]:l[d]}),h.__ng=l.__ng,h});return e?r[0]:r},"#conv"));w(this,"count",a(()=>this.getValidData().length,"count"));g(this,L,s),g(this,A,e),t(this,Pt).call(this)}get source(){return t(this,rt).call(this,t(this,A).rawRecords)}set source(s){this.clear(),this.add(s,!1)}get nextId(){return++pe(this,Dt)._}get length(){return t(this,H).length}getRowCount(){return this.length}};L=new WeakMap,A=new WeakMap,H=new WeakMap,ot=new WeakMap,Dt=new WeakMap,P=new WeakMap,Pt=new WeakMap,Z=new WeakMap,xt=new WeakMap,Vt=new WeakMap,Yt=new WeakMap,rt=new WeakMap,a(_,"ngData"),w(_,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let te=_;const de=class de{constructor(s){c(this,G);g(this,G,s),this.row=new Qt(this),this.data=new te(t(this,G),this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var e;(e=t(this,G).view)!=null&&e.redraw&&t(this,G).view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{var o,r;const i=parseInt(e,10);if(!(i>=this.data.count()))return(r=(o=this.data.getValidData()[i])==null?void 0:o.__ng)==null?void 0:r.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,i)=>this.data.get(e,i),this.setColumn=(e,i,o)=>{e=parseInt(e,10),this.data.setValue(e,i,o)},this.setDataSource([])}};G=new WeakMap,a(de,"ngDataManager");let ee=de;const fe=class fe{constructor(s){c(this,lt);c(this,q,[]);w(this,"add",a((s,e="string")=>{s.forEach(i=>{t(this,q).some(o=>o.name===i)||t(this,q).push({name:i,type:e})}),t(this,vt).call(this)},"add"));c(this,vt,a(()=>{const s=new Map;t(this,q).forEach(e=>{s.set(e.name,e.type)}),g(this,q,Array.from(s,([e,i])=>({name:e,type:i}))),g(this,q,t(this,q).filter(e=>e.name!==""&&e.name!=="__ng")),t(this,q).sort((e,i)=>e.name.length<i.name.length?1:-1)},"#adjust"));c(this,Ut,a(()=>{g(this,q,[]),v.log(t(this,lt).querySelectorAll("table"));const s=Array.from(t(this,lt).querySelectorAll("table"));if(!(!s||s.length===0)){for(const e of s)v.log(e),$("[data-bind]",e).each((i,o)=>{const r=o.dataset.bind,n=o.getAttribute("data-type")||"string";r&&t(this,q).push({name:r,type:n})}),["data-expr","background-color","color","tooltip","visible","readonly","enable-button","enable-check","class-expr","icon-color","icon-src"].forEach(i=>{$(`[${i}]`,e).each((o,r)=>{var n=r.getAttribute(i);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 h=l.search(/[^_A-Za-z0-9]/g);let d="";h>=0?d=l.substring(0,h):n.startsWith("data.")&&(d=l.replace("data.","")),d&&t(this,q).push({name:d,type:"string"})}})})});t(this,vt).call(this)}},"#init"));g(this,lt,s),t(this,Ut).call(this)}get(){return t(this,q).map(s=>s.name)}getFields(){return t(this,q)}getType(s){const e=t(this,q).find(i=>i.name===s);return e?e.type:"string"}indexOf(s){return t(this,q).findIndex(e=>e.name===s)}includes(s){return t(this,q).some(e=>e.name===s)}};lt=new WeakMap,q=new WeakMap,vt=new WeakMap,Ut=new WeakMap,a(fe,"ngFields");let ie=fe;const ue=class ue extends HTMLElement{constructor(){super();c(this,J);c(this,Xt);c(this,jt,a(()=>{this.fields=new ie(this),g(this,Xt,new Jt(this)),v.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))},"#init"));this.attachShadow({mode:"open"}),g(this,J,new ee(this))}connectedCallback(){t(this,jt).call(this)}disconnectedCallback(){v.log("NineTable disconnected.")}get data(){return t(this,J).data}get row(){return t(this,J).row}get dataManager(){return t(this,J)}};J=new WeakMap,Xt=new WeakMap,jt=new WeakMap,a(ue,"NineTable");let se=ue;customElements.get("nine-table")||customElements.define("nine-table",se)});
|
|
367
367
|
//# sourceMappingURL=nine-table.umd.js.map
|