@ninebone/table 0.0.322 → 0.0.323

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