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