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