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