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