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