@ninebone/table 0.0.280 → 0.0.282
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 +69 -66
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +4 -4
- 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,g){typeof exports=="object"&&typeof module<"u"?g(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],g):(y=typeof globalThis<"u"?globalThis:y||self,g(y.NineboneUtil))})(this,function(y){"use strict";var Ve=Object.defineProperty;var Xe=y=>{throw TypeError(y)};var Ke=(y,g,x)=>g in y?Ve(y,g,{enumerable:!0,configurable:!0,writable:!0,value:x}):y[g]=x;var a=(y,g)=>Ve(y,"name",{value:g,configurable:!0});var S=(y,g,x)=>Ke(y,typeof g!="symbol"?g+"":g,x),Ye=(y,g,x)=>g.has(y)||Xe("Cannot "+x);var e=(y,g,x)=>(Ye(y,g,"read from private field"),x?x.call(y):g.get(y)),c=(y,g,x)=>g.has(y)?Xe("Cannot add the same private member more than once"):g instanceof WeakSet?g.add(y):g.set(y,x),b=(y,g,x,I)=>(Ye(y,g,"write to private field"),I?I.call(y,x):g.set(y,x),x);var Ue=(y,g,x,I)=>({set _(
|
|
1
|
+
(function(y,g){typeof exports=="object"&&typeof module<"u"?g(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],g):(y=typeof globalThis<"u"?globalThis:y||self,g(y.NineboneUtil))})(this,function(y){"use strict";var Ve=Object.defineProperty;var Xe=y=>{throw TypeError(y)};var Ke=(y,g,x)=>g in y?Ve(y,g,{enumerable:!0,configurable:!0,writable:!0,value:x}):y[g]=x;var a=(y,g)=>Ve(y,"name",{value:g,configurable:!0});var S=(y,g,x)=>Ke(y,typeof g!="symbol"?g+"":g,x),Ye=(y,g,x)=>g.has(y)||Xe("Cannot "+x);var e=(y,g,x)=>(Ye(y,g,"read from private field"),x?x.call(y):g.get(y)),c=(y,g,x)=>g.has(y)?Xe("Cannot add the same private member more than once"):g instanceof WeakSet?g.add(y):g.set(y,x),b=(y,g,x,I)=>(Ye(y,g,"write to private field"),I?I.call(y,x):g.set(y,x),x);var Ue=(y,g,x,I)=>({set _(J){b(y,g,J,x)},get _(){return e(y,g,I)}});var C,z,p,D,N,B,le,P,ae,ce,Q,q,H,A,M,V,X,he,$e,de,ee,fe,te,K,Z,ue,ge,be,j,ye,pe,me,se,R,we,ne,xe,$,Y,T,w,k,F,ve,O,Se,re,Ee,Re,G,U,Ae;const He=class He extends y.trace.constructor{constructor(){super(),this.init("nine-table","green")}};a(He,"Trace");let g=He;const x=new g,Me=class Me extends HTMLElement{constructor(){super();c(this,C);c(this,z,!1);c(this,p);c(this,D);c(this,N);c(this,B);c(this,le,a(()=>{if(!e(this,C))return;const t=e(this,C).querySelector(".ng-container-body");t&&(b(this,B,new ResizeObserver(()=>{this.refresh()})),e(this,B).observe(t))},"#observeResize"));S(this,"refresh",a(()=>{if(!e(this,C)||!e(this,p)||e(this,z))return;const t=e(this,p).container,i=t.querySelector("table");if(!i)return;const n=e(this,p).track,r=e(this,p).thumb,o=e(this,C).querySelector(".ng-container-bottom"),l=t.clientWidth,d=i.scrollWidth;if(l!==0&&d>l)o&&(o.style.display="flex");else{o&&(o.style.display="none");return}const h=n.clientWidth;if(h<=0)return;const f=Math.max(Math.min(h*(l/d),h),20);r.style.width=`${f}px`;const m=t.scrollLeft,u=d-l;let E=0;u>0&&(E=parseInt(m/u*(h-f),10)),E<0&&(E=0);const v=h-f;E>v&&(E=v),r.style.left=`${E}px`,x.log(E),e(this,p).left.disabled=E===0,e(this,p).right.disabled=E>=v-1},"refresh"));c(this,P,a(t=>{if(!e(this,p))return!1;const i=e(this,p).container,n=i.querySelector("table");if(!n)return!1;const r=e(this,p).track.getBoundingClientRect(),o=e(this,p).thumb.clientWidth;let l=t;l<0&&(l=0);const d=r.width-o;l>d&&(l=d),l=parseInt(l,10),e(this,p).thumb.style.left=`${l}px`,e(this,p).left.disabled=l===0,e(this,p).right.disabled=l>=d-1;const h=i.clientWidth,f=n.scrollWidth;let m=d>0?-l*(f-h)/d:0;return-m>f-h&&(m=-(f-h)),-m+5>f-h&&(m=-(f-h)),h>=f&&(m=0),n.style.transform=`translateX(${m}px)`,l>0&&l<d-1},"#thumbMoveTo"));c(this,ae,a(()=>{const t=a(n=>{clearInterval(e(this,D)),clearInterval(e(this,N));const r=parseInt(e(this,p).thumb.style.left||0,10);e(this,P).call(this,r+n),b(this,D,setInterval(()=>{clearInterval(e(this,D)),b(this,N,setInterval(()=>{const o=parseInt(e(this,p).thumb.style.left||0,10);e(this,P).call(this,o+n)||clearInterval(e(this,N))},50))},500))},"delayScroll"),i=a(()=>{clearInterval(e(this,D)),clearInterval(e(this,N))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(n=>{e(this,p).left.addEventListener(n,i),e(this,p).right.addEventListener(n,i),e(this,p).track.addEventListener(n,i)}),e(this,p).left.addEventListener("mousedown",n=>{n.button===0&&t(-20)}),e(this,p).right.addEventListener("mousedown",n=>{n.button===0&&t(20)}),e(this,p).left.addEventListener("touchstart",()=>t(-20)),e(this,p).right.addEventListener("touchstart",()=>t(20)),e(this,p).track.addEventListener("mousedown",n=>{if(n.button!==0)return;n.preventDefault();const r=e(this,p).track.getBoundingClientRect(),o=e(this,p).thumb.clientWidth;e(this,P).call(this,n.clientX-r.left-o/2)}),e(this,p).thumb.addEventListener("mousedown",n=>{if(n.button!==0)return;n.stopPropagation(),n.preventDefault(),b(this,z,!0),this.shiftX=n.clientX-e(this,p).thumb.getBoundingClientRect().left;const r=a(l=>{if(!e(this,z))return;const d=e(this,p).track.getBoundingClientRect();e(this,P).call(this,l.clientX-d.left-this.shiftX)},"onMouseMove"),o=a(()=>{b(this,z,!1),i(),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",o),this.refresh()},"onMouseUp");document.addEventListener("mousemove",r),document.addEventListener("mouseup",o)})},"#init"))}connectedCallback(){if(b(this,C,this.closest("nine-table-sheet")||this.getRootNode().host),!e(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 t=a(()=>{const i=e(this,C).querySelector(".ng-container-body");if(!i){setTimeout(t,10);return}b(this,p,{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")}),e(this,ae).call(this),e(this,le).call(this),this.refresh()},"initWhenReady");t()}disconnectedCallback(){e(this,B)&&e(this,B).disconnect()}};C=new WeakMap,z=new WeakMap,p=new WeakMap,D=new WeakMap,N=new WeakMap,B=new WeakMap,le=new WeakMap,P=new WeakMap,ae=new WeakMap,a(Me,"NineTableHScrollBar");let I=Me;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",I);const _=class _{static compileAll(s){return Array.isArray(s)?s.map(t=>_.compile(t)):[]}static compile(s){var n,r,o;if(!s)return null;const t=s.cloneNode(!0);return e(n=_,ce).call(n,t),e(r=_,
|
|
63
|
+
`;const t=a(()=>{const i=e(this,C).querySelector(".ng-container-body");if(!i){setTimeout(t,10);return}b(this,p,{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")}),e(this,ae).call(this),e(this,le).call(this),this.refresh()},"initWhenReady");t()}disconnectedCallback(){e(this,B)&&e(this,B).disconnect()}};C=new WeakMap,z=new WeakMap,p=new WeakMap,D=new WeakMap,N=new WeakMap,B=new WeakMap,le=new WeakMap,P=new WeakMap,ae=new WeakMap,a(Me,"NineTableHScrollBar");let I=Me;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",I);const _=class _{static compileAll(s){return Array.isArray(s)?s.map(t=>_.compile(t)):[]}static compile(s){var n,r,o;if(!s)return null;const t=s.cloneNode(!0);return e(n=_,ce).call(n,t),e(r=_,Q).call(r,t,"thead"),e(o=_,Q).call(o,t,"tbody"),Array.from(t.querySelectorAll("colgroup col")).forEach((l,d)=>{const h=l.getAttribute("fixed");h&&t.querySelectorAll(`[data-col="${d}"]`).forEach(f=>{f.setAttribute("fixed",h)})}),t}};ce=new WeakMap,Q=new WeakMap,a(_,"TableCompiler"),c(_,ce,a(s=>{if(!s.querySelector("colgroup")){const t=s.querySelector("tbody tr")||s.querySelector("tr"),i=t?t.querySelectorAll("th, td").length:1,n=document.createElement("colgroup"),r=Math.max(Math.floor(s.clientWidth/i),100);for(let o=0;o<i;o++){const l=document.createElement("col");l.setAttribute("width",r),n.appendChild(l)}s.prepend(n)}if(!s.querySelector("thead")){const t=document.createElement("thead"),i=s.querySelector("colgroup");i?i.after(t):s.prepend(t)}s.classList.add("nine-table-element"),s.style.display="table"},"#ensureTableStructure")),c(_,Q,a((s,t)=>{const i=Array.from(s.querySelectorAll(t+" tr")),n=Array.from(s.querySelectorAll(t+" th,"+t+" td")),r=i.length;if(r===0||n.length===0)return;let o=0;n.forEach(d=>{o+=d.colSpan||1});const l=Array.from(Array(r),()=>Array(o).fill(null));i.forEach(d=>{const h=d.sectionRowIndex;let f=0;Array.from(d.querySelectorAll("th,td")).forEach(m=>{for(let v=0;v<l[h].length;v++)if(l[h][v]===null){f=v;break}const u=m.rowSpan||1,E=m.colSpan||1;for(let v=0;v<u;v++)for(let W=0;W<E;W++)h+v<r&&f+W<o&&(l[h+v][f+W]=v===0&&W===0?"1":"0")})}),i.forEach(d=>{const h=d.sectionRowIndex;Array.from(d.querySelectorAll("th,td")).forEach(f=>{for(let m=0;m<l[h].length;m++)if(l[h][m]==="1"){f.dataset.col=m,l[h][m]="0";break}})})},"#resetColIndex"));let J=_;const Oe=class Oe{constructor(s){c(this,q);c(this,H,new Map);c(this,A,null);c(this,M,null);c(this,V,0);c(this,X,40);S(this,"initialize",a(()=>{b(this,A,null),e(this,H).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(t=>{const i=e(this,q).querySelector(t);if(!i)return;const n=i.querySelector("table");if(!n)return;const r=n.querySelector("tbody");if(!r)return;const l=Array.from(r.querySelectorAll("tr")).map(d=>d.cloneNode(!0));e(this,H).set(t,l)});const s=e(this,q).querySelector(".ng-container-body");s&&(e(this,de).call(this,s),e(this,te).call(this))},"initialize"));c(this,he,a((s,t)=>{const i=e(this,H).get(t);if(!i||i.length===0)return;const n=s.querySelector("tbody");if(!n)return;n.querySelectorAll("tr:not(.nodata)").forEach(l=>l.remove());const r=n.querySelector("tr.nodata"),o=document.createDocumentFragment();for(let l=0;l<e(this,X);l++)i.forEach(d=>{o.appendChild(d.cloneNode(!0))});r?r.before(o):n.appendChild(o)},"#renderRows"));c(this,$e,a((s,t)=>{const i=s.cloneNode(!0);return t==="left"?i.querySelectorAll("col, th, td").forEach(n=>{n.getAttribute("fixed")!=="left"&&n.remove()}):t==="right"?i.querySelectorAll("col, th, td").forEach(n=>{n.getAttribute("fixed")!=="right"&&n.remove()}):i.querySelectorAll("[fixed='left'], [fixed='right']").forEach(n=>n.remove()),i},"#createSplitTable"));c(this,de,a(s=>{if(e(this,A)!==null&&e(this,A)>0)return e(this,A);const t=e(this,H).get(".ng-container-body");if(!t||t.length===0)return 24;const i=s.querySelector("tbody");if(!i)return 24;i.querySelectorAll("tr:not(.nodata)").forEach(u=>u.remove());const n=i.querySelector("tr.nodata"),r=document.createDocumentFragment();t.forEach(u=>{r.appendChild(u.cloneNode(!0))}),n?n.before(r):i.appendChild(r);const o=e(this,q),l=o.style.display,d=o.style.visibility,h=o.style.position;(l==="none"||window.getComputedStyle(o).display==="none")&&(o.style.display="block",o.style.visibility="hidden",o.style.position="absolute");let f=0;const m=i.querySelectorAll("tr:not(.nodata)");return m.forEach(u=>{f+=u.offsetHeight||u.getBoundingClientRect().height}),m.forEach(u=>u.remove()),o.style.display=l,o.style.visibility=d,o.style.position=h,b(this,A,f>0?f:24),e(this,ee).call(this),x.log(`[RowManager] Height Cached: ${e(this,A)}px | RowCount: ${e(this,X)}`),e(this,A)},"#measureAndCacheHeight"));c(this,ee,a(()=>{if(e(this,V)>0&&e(this,A)>0){const s=Math.ceil(e(this,V)/e(this,A));b(this,X,s+20)}else b(this,X,40)},"#updateRowCount"));c(this,fe,a(()=>{!e(this,q)||!(e(this,q)instanceof HTMLElement)||(b(this,M,new ResizeObserver(s=>{for(const t of s){const i=t.target;if(!i.classList.contains("active"))continue;const n=t.contentRect.height;if(n>0){let r=0;const o=i.querySelector("thead");o&&(r+=o.offsetHeight||o.getBoundingClientRect().height);const l=Math.max(n-r,100);e(this,V)!==l&&(b(this,V,l),e(this,ee).call(this),e(this,A)!==null&&e(this,te).call(this))}}})),e(this,M).observe(e(this,q)))},"#initResizeObserver"));c(this,te,a(()=>{[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(s=>{const t=e(this,q).querySelector(s);t&&t.querySelector("tbody")&&e(this,he).call(this,t,s)}),typeof e(this,q).syncRowHeights=="function"&&e(this,q).syncRowHeights()},"#renderAllContainers"));S(this,"destroy",a(()=>{e(this,M)&&(e(this,M).disconnect(),b(this,M,null))},"destroy"));b(this,q,s),e(this,fe).call(this)}getRowHeight(){return e(this,A)}templateLength(s=".ng-container-body"){var t;return((t=e(this,H).get(s))==null?void 0:t.length)||1}};q=new WeakMap,H=new WeakMap,A=new WeakMap,M=new WeakMap,V=new WeakMap,X=new WeakMap,he=new WeakMap,$e=new WeakMap,de=new WeakMap,ee=new WeakMap,fe=new WeakMap,te=new WeakMap,a(Oe,"RowManager");let qe=Oe;const ie=class ie extends HTMLElement{constructor(){super();c(this,K,null);c(this,Z);c(this,ue,a(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:i,type:n})=>{const r=this.querySelector(i);if(!r)return;const o=e(this,be).call(this,e(this,K),n);r.innerHTML="",r.appendChild(o)})},"#renderSplitContainers"));c(this,ge,a(()=>{["left","right"].forEach(t=>{const i=this.querySelector(`.ng-container-${t}`),n=i==null?void 0:i.querySelector("table");if(!i||!n)return;let r=0;n.querySelectorAll("col").forEach(o=>{const l=parseInt(o.getAttribute("width"),10);isNaN(r)||(r+=l)}),i.style.flex=`0 0 ${r}px`,i.style.width=`${r}px`})},"#updateContainerWidths"));S(this,"generate",a(t=>{if(!t)return;b(this,K,J.compile(t)),e(this,K).style.display="table",e(this,ue).call(this),e(this,Z).initialize(),e(this,ge).call(this);const i=this.querySelector(".ng-container-body");i&&i.addEventListener("scroll",()=>{var n;(n=this.querySelector("nine-table-hscrollbar"))==null||n.refresh()}),setTimeout(()=>{var n;e(this,j).call(this),(n=this.querySelector("nine-table-hscrollbar"))==null||n.refresh()},0)},"generate"));c(this,be,a((t,i)=>{const n=t.cloneNode(!0);return i==="left"?n.querySelectorAll("col, th, td").forEach(r=>{r.getAttribute("fixed")!=="left"&&r.remove()}):i==="right"?n.querySelectorAll("col, th, td").forEach(r=>{r.getAttribute("fixed")!=="right"&&r.remove()}):n.querySelectorAll("[fixed=left], [fixed=right]").forEach(r=>{r.remove()}),n},"#createSplitTable"));S(this,"getRowHeight",a(()=>e(this,Z).getRowHeight(),"getRowHeight"));S(this,"scrollToX",a(t=>{const i=this.querySelector(".ng-container-body");i&&(i.scrollLeft=t)},"scrollToX"));S(this,"scrollToY",a(t=>{const i=this.querySelector(".ng-container-body");i&&(i.scrollTop=t)},"scrollToY"));S(this,"syncRowHeights",a(()=>{e(this,j).call(this)},"syncRowHeights"));c(this,j,a(()=>{var h,f,m;const t=this.querySelector(".ng-container-left table"),i=this.querySelector(".ng-container-body table"),n=this.querySelector(".ng-container-right table");if(!i)return;const r=t?Array.from(t.querySelectorAll("tr")):[],o=Array.from(i.querySelectorAll("tr")),l=n?Array.from(n.querySelectorAll("tr")):[],d=Math.max(r.length,o.length,l.length);for(let u=0;u<d;u++){const E=[((h=r[u])==null?void 0:h.getBoundingClientRect().height)||0,((f=o[u])==null?void 0:f.getBoundingClientRect().height)||0,((m=l[u])==null?void 0:m.getBoundingClientRect().height)||0],v=Math.max(...E);v>0&&(r[u]&&(r[u].style.height=`${v}px`),o[u]&&(o[u].style.height=`${v}px`),l[u]&&(l[u].style.height=`${v}px`))}},"#syncRowHeights"));c(this,ye,a(()=>{e(this,pe).call(this),new MutationObserver(t=>{for(const i of t)i.attributeName==="class"&&this.classList.contains("active")&&e(this,j).call(this)}).observe(this,{attributes:!0})},"#init"));c(this,pe,a(()=>{const t=ie.SCROLLBAR_SIZE;this.innerHTML=`
|
|
64
64
|
<style>
|
|
65
65
|
nine-table-sheet {
|
|
66
66
|
display: none;
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
<nine-table-hscrollbar></nine-table-hscrollbar>
|
|
181
181
|
<div class='ng-scroll-edge'></div>
|
|
182
182
|
</div>
|
|
183
|
-
`},"#render"));b(this,Z,new qe(this))}connectedCallback(){e(this,ye).call(this)}disconnectedCallback(){this.innerHTML="",x.log("NineTableSheet destroyed.")}};K=new WeakMap,Z=new WeakMap,ue=new WeakMap,ge=new WeakMap,be=new WeakMap,
|
|
183
|
+
`},"#render"));b(this,Z,new qe(this))}connectedCallback(){e(this,ye).call(this)}disconnectedCallback(){this.innerHTML="",x.log("NineTableSheet destroyed.")}};K=new WeakMap,Z=new WeakMap,ue=new WeakMap,ge=new WeakMap,be=new WeakMap,j=new WeakMap,ye=new WeakMap,pe=new WeakMap,a(ie,"NineTableSheet"),S(ie,"SCROLLBAR_SIZE",16);let oe=ie;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",oe);const We=class We extends HTMLElement{constructor(){super();c(this,me,a(()=>{var t;(t=this.querySelector(".nine-tab-bar"))==null||t.addEventListener("click",i=>{var o;const n=i.ctrlKey||i.metaKey||i.shiftKey,r=parseInt((o=i.target.closest(".nine-tab-item"))==null?void 0:o.dataset.index,10);e(this,se).call(this,r,n)}),e(this,se).call(this,0,!1)},"#init"));c(this,se,a((t,i=!1)=>{const n=a(()=>{const f=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(E=>E.style.setProperty("display","none"));const u=f.filter(E=>E.classList.contains("active"));u.length<2||u.forEach(E=>{const v=parseInt(E.getAttribute("data-index"),10),W=this.querySelector(`nine-splitter[data-split-index="${v}"]`),Pe=f[v+1];W&&Pe&&Pe.classList.contains("active")&&W.style.setProperty("display","flex")})},"updateSplitters"),r=this.querySelector(".nine-tab-bar"),o=this.querySelector("nine-table-sheets-body"),l=r.querySelectorAll(".nine-tab-item"),d=o.querySelectorAll("nine-table-sheet");if(!l[t])return;if(!i)l.forEach((f,m)=>{f.classList.toggle("active",m===t)}),d.forEach((f,m)=>{const u=m===t;f.classList.toggle("active",u),f.style.flex=u?"1 1 100%":""});else{const f=l[t],m=r.querySelectorAll(".nine-tab-item.active");if(f.classList.contains("active")&&m.length<=1)return;f.classList.toggle("active");const u=o.querySelector(`nine-table-sheet[data-index="${t}"]`);u&&(u.classList.toggle("active"),u.classList.contains("active")||(u.style.flex=""))}const h=o.querySelectorAll("nine-table-sheet.active");h==null||h.forEach(f=>{f.style.flex=h.length>1?"1 1 0%":"1 1 100%"}),n()},"#switchSheet"))}connectedCallback(){e(this,me).call(this)}};me=new WeakMap,se=new WeakMap,a(We,"NineTableSheets");let Te=We;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",Te);const ze=class ze{constructor(s){c(this,R);c(this,we,a(()=>{e(this,xe).call(this),new ResizeObserver(s=>{for(let t of s)e(this,R).getAttribute("auto-height")==="true"&&e(this,ne).call(this)}).observe(e(this,R))},"#init"));c(this,ne,a(()=>{var d,h;const s=Array.from(e(this,R).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(s.length===0)return;const t=parseInt(e(this,R).getAttribute("max-display-row"),10)||10,i=Math.max(...s.map(f=>f.getRowHeight())),n=(d=e(this,R).shadowRoot.querySelector("nine-table-header"))==null?void 0:d.getBoundingClientRect().height,r=(h=e(this,R).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:h.getBoundingClientRect().height,o=oe.SCROLLBAR_SIZE,l=t*i+n+r+o;e(this,R).style.height=`${l}px`},"#applyAutoHeight"));c(this,xe,a(()=>{const t=Array.from(e(this,R).children).filter(d=>d.tagName==="TABLE"),i=e(this,R).getAttribute("auto-height")==="true",n=t.length,r=t.map((d,h)=>{const m=`<nine-table-sheet class="${h===0?"active":""}" data-index="${h}"></nine-table-sheet>`,u=h<n-1?`<nine-splitter class="h" data-split-index="${h}"></nine-splitter>`:"";return m+u}).join(""),o=t.map((d,h)=>`<div class="nine-tab-item ${h===0?"active":""}" data-index="${h}">Sheet ${h+1}</div>`).join("");e(this,R).shadowRoot.innerHTML=`
|
|
184
184
|
<style>
|
|
185
185
|
:host {
|
|
186
186
|
display: flex;
|
|
@@ -278,5 +278,5 @@
|
|
|
278
278
|
<nine-table-analysis></nine-table-analysis>
|
|
279
279
|
</nine-table-body>
|
|
280
280
|
<nine-table-footer></nine-table-footer>
|
|
281
|
-
`;const l=e(this,R).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((d,h)=>{t[h]&&setTimeout(()=>{d.generate(t[h]),i&&e(this,ne).call(this)})})},"#render"));b(this,R,s),e(this,we).call(this)}};R=new WeakMap,we=new WeakMap,ne=new WeakMap,xe=new WeakMap,a(ze,"LayoutManager");let ke=ze;const De=class De{constructor(s){c(this,$);c(this,Y,-1);S(this,"count",a(()=>e(this,$).rawRecords.length,"count"));b(this,$,s)}get at(){return e(this,Y)}set at(s){var i,n;b(this,Y,parseInt(s,10));const t=((n=(i=e(this,$).owner).querySelector)==null?void 0:n.call(i,".ng-container-body"))||e(this,$).owner.body;t&&!t.querySelector(`tbody.bindable tr[data-row="${e(this,Y)}"]`)&&setTimeout(()=>{var r,o;(o=(r=e(this,$).owner).scrollTo_V1)==null||o.call(r,e(this,Y))})}};$=new WeakMap,Y=new WeakMap,a(De,"ngRow");let Le=De;const
|
|
281
|
+
`;const l=e(this,R).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((d,h)=>{t[h]&&setTimeout(()=>{d.generate(t[h]),i&&e(this,ne).call(this)})})},"#render"));b(this,R,s),e(this,we).call(this)}};R=new WeakMap,we=new WeakMap,ne=new WeakMap,xe=new WeakMap,a(ze,"LayoutManager");let ke=ze;const De=class De{constructor(s){c(this,$);c(this,Y,-1);S(this,"count",a(()=>e(this,$).rawRecords.length,"count"));b(this,$,s)}get at(){return e(this,Y)}set at(s){var i,n;b(this,Y,parseInt(s,10));const t=((n=(i=e(this,$).owner).querySelector)==null?void 0:n.call(i,".ng-container-body"))||e(this,$).owner.body;t&&!t.querySelector(`tbody.bindable tr[data-row="${e(this,Y)}"]`)&&setTimeout(()=>{var r,o;(o=(r=e(this,$).owner).scrollTo_V1)==null||o.call(r,e(this,Y))})}};$=new WeakMap,Y=new WeakMap,a(De,"ngRow");let Le=De;const L=class L{constructor(s,t){c(this,T);c(this,w);c(this,k,[]);c(this,F,[]);c(this,ve,0);c(this,O,[]);c(this,Se,a(()=>{b(this,O,[]);const s=e(this,T).template||[];Array.from(s).forEach(t=>{var i;e(this,O).push(((i=t.getBoundingClientRect)==null?void 0:i.call(t).height)||24)}),(e(this,w).rawRecords||[]).forEach(t=>{t.__ng||(t.__ng=e(this,re).call(this)),t.__ng.height=e(this,O).slice()})},"#initialize"));S(this,"set",a(s=>{this.clear(),this.add(s,!1)},"set"));c(this,re,a(()=>({rowState:L.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:e(this,O).slice(),o:{},c:{},_:[0,0,0,0,L.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,e(this,O).slice(),-1,{},{}]}),"#getDefaultMeta"));S(this,"reset",a(()=>{b(this,k,[]),b(this,F,[])},"reset"));S(this,"clear",a(()=>{var s;e(this,w).rawRecords=[],b(this,k,[]),b(this,F,[]),(s=e(this,w).viewRecords)!=null&&s.reset&&e(this,w).viewRecords.reset()},"clear"));c(this,Ee,a(s=>{var n;Array.isArray(s)||(s=[s]);const t=typeof((n=e(this,T).fields)==null?void 0:n.get)=="function"?e(this,T).fields.get():Object.keys(s[0]||{}),i=[];return s.forEach(r=>{const o={v:[]};t.forEach(l=>{o.v.push(r[l]!==void 0&&r[l]!==null?r[l]:"")}),i.push(o)}),i},"#json2Array"));c(this,Re,a(s=>(Array.isArray(s)||(s=[s]),s.forEach(t=>{t.__ng=e(this,re).call(this),t.__ng.rowid=this.nextId,t.__ng.rowState=L.ROW_STATE.INSERT,t.__ng._[0]=t.__ng.rowid}),s),"#defaultInsert"));S(this,"add",a((s,t=!0)=>{var r;s===void 0&&(s={});const i=e(this,Ee).call(this,s);e(this,w).rawRecords=e(this,w).rawRecords.concat(e(this,Re).call(this,i)),this.resetRecords();const n=this.count()-1;return t||i.forEach((o,l)=>{const d=e(this,w).rawRecords[n-l];d&&(d.__ng.rowState=L.ROW_STATE.EMPTY)}),(r=e(this,w).viewRecords)!=null&&r.reset&&e(this,w).viewRecords.reset(),n},"add"));S(this,"delete",a(s=>{var i;let t=[];Array.isArray(s)?t=s:typeof s>"u"?t=[e(this,w).owner.row.at]:t=[parseInt(s,10)],t.sort((n,r)=>r-n).forEach(n=>{if(e(this,k)[n]){const r=e(this,k)[n].__ng.rowid;e(this,k)[n].__ng.rowState===L.ROW_STATE.INSERT?e(this,w).rawRecords=e(this,w).rawRecords.filter(o=>o.__ng.rowid!==r):e(this,w).rawRecords.forEach(o=>{o.__ng.rowid===r&&(o.__ng.deleted=!0,o.__ng.rowState=L.ROW_STATE.DELETE)})}}),this.resetRecords(),(i=e(this,w).viewRecords)!=null&&i.reset&&e(this,w).viewRecords.reset()},"delete"));S(this,"setValue",a((s,t,i)=>{var d;s=parseInt(s,10);const r=(typeof((d=e(this,T).fields)==null?void 0:d.get)=="function"?e(this,T).fields.get():[]).indexOf(t);if(r<0)return;const o=this.getValidData()[s];if(!o)return;const l=o.v[r];l!==i&&o.__ng.rowState!==L.ROW_STATE.INSERT&&(o.__ng.o.hasOwnProperty(t)||(o.__ng.o[t]=l),o.__ng.rowState=L.ROW_STATE.UPDATE),o.v[r]=i,e(this,w).owner.refreshData&&e(this,w).owner.refreshData(s)},"setValue"));S(this,"resetRecords",a(()=>{b(this,F,e(this,w).rawRecords.filter(s=>!s.__ng.deleted)),b(this,k,e(this,w).rawRecords.filter(s=>!s.__ng.deleted&&!s.__ng.filtered)),e(this,w).rawRecords.forEach((s,t)=>{s.__ng.rowidx=t}),e(this,k).forEach((s,t)=>{s.__ng.i=t})},"resetRecords"));S(this,"getValidData",a(()=>(e(this,k).length===0&&e(this,w).rawRecords.length>0&&this.resetRecords(),e(this,k)),"getValidData"));c(this,G,a(s=>{var i;if(!s)return s;const t=typeof((i=e(this,T).fields)==null?void 0:i.get)=="function"?e(this,T).fields.get():[];return Array.isArray(s)?s.filter(n=>!n.__ng.deleted).map(n=>{const r={};return t.forEach((o,l)=>{r[o]=n.v?n.v[l]:n[o]}),r.__ng=n.__ng,r}):s},"#conv2"));S(this,"count",a(()=>this.getValidData().length,"count"));S(this,"get",a((s,t)=>{var r;const i=this.getValidData();if(!i||i.length<=0)return;if(s==null)return e(this,G).call(this,i);if(s<0||s>=i.length)return null;const n=typeof((r=e(this,T).fields)==null?void 0:r.get)=="function"?e(this,T).fields.get():[];if(t!=null){const o=n.indexOf(t);return o>=0?i[s].v[o]:null}return e(this,G).call(this,i[s])},"get"));b(this,T,s),b(this,w,t),e(this,Se).call(this)}get source(){return e(this,G).call(this,e(this,w).rawRecords)}set source(s){this.clear(),this.add(s,!1)}get nextId(){return++Ue(this,ve)._}get length(){return e(this,k).length}getRowCount(){return this.length}};T=new WeakMap,w=new WeakMap,k=new WeakMap,F=new WeakMap,ve=new WeakMap,O=new WeakMap,Se=new WeakMap,re=new WeakMap,Ee=new WeakMap,Re=new WeakMap,G=new WeakMap,a(L,"ngData"),S(L,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Ce=L;const Ne=class Ne{constructor(s){this.owner=s,this.row=new Le(this),this.data=new Ce(s,this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var t;(t=this.owner.view)!=null&&t.redraw&&this.owner.view.redraw()},this.setDataSource=t=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(t||[])},this.getRowState=t=>{var n,r;const i=parseInt(t,10);if(!(i>=this.data.count()))return(r=(n=this.data.getValidData()[i])==null?void 0:n.__ng)==null?void 0:r.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=t=>{this.row.at=t},this.scrollTo_V1=t=>(t<0&&(t=0),t>=this.rawRecords.length&&(t=this.rawRecords.length-1),this.viewRecords.rawIndex=t,this.viewRecords.reset&&this.viewRecords.reset(),!(t<=0||t>=this.rawRecords.length-1)),this.getColumn=(t,i)=>this.data.get(t,i),this.setColumn=(t,i,n)=>{t=parseInt(t,10),this.data.setValue(t,i,n)},this.setDataSource([])}};a(Ne,"ngDataManager");let _e=Ne;const Be=class Be extends HTMLElement{constructor(){super();c(this,U);c(this,Ae);this.attachShadow({mode:"open"}),b(this,U,new _e(this))}connectedCallback(){b(this,Ae,new ke(this)),x.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))}disconnectedCallback(){x.log("NineTable disconnected.")}get data(){return e(this,U).data}get row(){return e(this,U).row}get dataManager(){return e(this,U)}};U=new WeakMap,Ae=new WeakMap,a(Be,"NineTable");let Ie=Be;customElements.get("nine-table")||customElements.define("nine-table",Ie)});
|
|
282
282
|
//# sourceMappingURL=nine-table.umd.js.map
|