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