@ninebone/table 0.0.193 → 0.0.195
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 +150 -161
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +6 -23
- 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(w,y){typeof exports=="object"&&typeof module<"u"?y(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],y):(w=typeof globalThis<"u"?globalThis:w||self,y(w.NineboneUtil))})(this,function(w){"use strict";var Ie=Object.defineProperty;var He=w=>{throw TypeError(w)};var We=(w,y,S)=>y in w?Ie(w,y,{enumerable:!0,configurable:!0,writable:!0,value:S}):w[y]=S;var l=(w,y)=>Ie(w,"name",{value:y,configurable:!0});var x=(w,y,S)=>We(w,typeof y!="symbol"?y+"":y,S),$e=(w,y,S)=>y.has(w)||He("Cannot "+S);var e=(w,y,S)=>($e(w,y,"read from private field"),S?S.call(w):y.get(w)),u=(w,y,S)=>y.has(w)?He("Cannot add the same private member more than once"):y instanceof WeakSet?y.add(w):y.set(w,S),
|
|
1
|
+
(function(w,y){typeof exports=="object"&&typeof module<"u"?y(require("@ninebone/util")):typeof define=="function"&&define.amd?define(["@ninebone/util"],y):(w=typeof globalThis<"u"?globalThis:w||self,y(w.NineboneUtil))})(this,function(w){"use strict";var Ie=Object.defineProperty;var He=w=>{throw TypeError(w)};var We=(w,y,S)=>y in w?Ie(w,y,{enumerable:!0,configurable:!0,writable:!0,value:S}):w[y]=S;var l=(w,y)=>Ie(w,"name",{value:y,configurable:!0});var x=(w,y,S)=>We(w,typeof y!="symbol"?y+"":y,S),$e=(w,y,S)=>y.has(w)||He("Cannot "+S);var e=(w,y,S)=>($e(w,y,"read from private field"),S?S.call(w):y.get(w)),u=(w,y,S)=>y.has(w)?He("Cannot add the same private member more than once"):y instanceof WeakSet?y.add(w):y.set(w,S),b=(w,y,S,z)=>($e(w,y,"write to private field"),z?z.call(w,S):y.set(w,S),S);var ze=(w,y,S,z)=>({set _(Q){b(w,y,Q,S)},get _(){return e(w,y,z)}});var M,N,m,P,V,X,oe,Y,re,F,I,q,W,H,$,le,ae,_,U,ce,he,E,de,te,fe,ie,ue,O,K,A,v,C,j,ge,B,be,se,pe,ye,G,Z,we;const Te=class Te extends w.trace.constructor{constructor(){super(),this.init("nine-table","green")}};l(Te,"Trace");let y=Te;const S=new y,qe=class qe extends HTMLElement{constructor(){super();u(this,M);u(this,N,!1);u(this,m);u(this,P);u(this,V);u(this,X);u(this,oe,l(()=>{if(!e(this,M))return;const t=e(this,M).querySelector(".ng-container-body");t&&(b(this,X,new ResizeObserver(()=>{this.refresh()})),e(this,X).observe(t))},"#observeResize"));x(this,"refresh",l(()=>{if(!e(this,M)||!e(this,m)||e(this,N))return;const t=e(this,m).container,s=t.querySelector("table");if(!s)return;const n=e(this,m).track,o=e(this,m).thumb,r=e(this,M).querySelector(".ng-container-bottom"),h=t.clientWidth,p=s.scrollWidth;if(h!==0&&p>h)r&&(r.style.display="flex");else{r&&(r.style.display="none");return}const c=n.clientWidth;if(c<=0)return;const d=Math.max(Math.min(c*(h/p),c),20);o.style.width=`${d}px`;let a=0;const g=s.style.transform;if(g&&g.includes("translateX")){const R=g.match(/translateX\(([-\d.]+)px\)/);R&&R[1]&&(a=parseFloat(R[1]))}else a=parseInt(s.style.left||0,10);let f=parseInt(Math.abs(a)*c/p,10);f<0&&(f=0);const T=c-d;f>T&&(f=T),o.style.left=`${f}px`,e(this,m).left.disabled=f===0,e(this,m).right.disabled=f>=T-1},"refresh"));u(this,Y,l(t=>{if(!e(this,m))return!1;const s=e(this,m).container,n=s.querySelector("table");if(!n)return!1;const o=e(this,m).track.getBoundingClientRect(),r=e(this,m).thumb.clientWidth;let h=t;h<0&&(h=0);const p=o.width-r;h>p&&(h=p),h=parseInt(h,10),e(this,m).thumb.style.left=`${h}px`,e(this,m).left.disabled=h===0,e(this,m).right.disabled=h>=p-1;const c=s.clientWidth,d=n.scrollWidth;let a=p>0?-h*(d-c)/p:0;return-a>d-c&&(a=-(d-c)),-a+5>d-c&&(a=-(d-c)),c>=d&&(a=0),n.style.transform=`translateX(${a}px)`,h>0&&h<p-1},"#thumbMoveTo"));u(this,re,l(()=>{const t=l(n=>{clearInterval(e(this,P)),clearInterval(e(this,V));const o=parseInt(e(this,m).thumb.style.left||0,10);e(this,Y).call(this,o+n),b(this,P,setInterval(()=>{clearInterval(e(this,P)),b(this,V,setInterval(()=>{const r=parseInt(e(this,m).thumb.style.left||0,10);e(this,Y).call(this,r+n)||clearInterval(e(this,V))},50))},500))},"delayScroll"),s=l(()=>{clearInterval(e(this,P)),clearInterval(e(this,V))},"clearTimer");["mouseup","mouseleave","touchend"].forEach(n=>{e(this,m).left.addEventListener(n,s),e(this,m).right.addEventListener(n,s),e(this,m).track.addEventListener(n,s)}),e(this,m).left.addEventListener("mousedown",n=>{n.button===0&&t(-20)}),e(this,m).right.addEventListener("mousedown",n=>{n.button===0&&t(20)}),e(this,m).left.addEventListener("touchstart",()=>t(-20)),e(this,m).right.addEventListener("touchstart",()=>t(20)),e(this,m).track.addEventListener("mousedown",n=>{if(n.button!==0)return;n.preventDefault();const o=e(this,m).track.getBoundingClientRect(),r=e(this,m).thumb.clientWidth;e(this,Y).call(this,n.clientX-o.left-r/2)}),e(this,m).thumb.addEventListener("mousedown",n=>{if(n.button!==0)return;n.stopPropagation(),n.preventDefault(),b(this,N,!0),this.shiftX=n.clientX-e(this,m).thumb.getBoundingClientRect().left;const o=l(h=>{if(!e(this,N))return;const p=e(this,m).track.getBoundingClientRect();e(this,Y).call(this,h.clientX-p.left-this.shiftX)},"onMouseMove"),r=l(()=>{b(this,N,!1),s(),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r),this.refresh()},"onMouseUp");document.addEventListener("mousemove",o),document.addEventListener("mouseup",r)})},"#init"))}connectedCallback(){if(b(this,M,this.closest("nine-table-sheet")||this.getRootNode().host),!e(this,M))return;this.innerHTML=`
|
|
2
2
|
<style>
|
|
3
3
|
nine-table-hscrollbar {
|
|
4
4
|
display: flex;
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
<button class='ng-scroll-left' disabled><div class='ng-scroll-icon'></div></button>
|
|
61
61
|
<div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
|
|
62
62
|
<button class='ng-scroll-right' disabled><div class='ng-scroll-icon'></div></button>
|
|
63
|
-
`;const t=l(()=>{const s=e(this,M).querySelector(".ng-container-body");if(!s){setTimeout(t,10);return}
|
|
63
|
+
`;const t=l(()=>{const s=e(this,M).querySelector(".ng-container-body");if(!s){setTimeout(t,10);return}b(this,m,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),left:this.querySelector(".ng-scroll-left"),right:this.querySelector(".ng-scroll-right")}),e(this,re).call(this),e(this,oe).call(this),this.refresh()},"initWhenReady");t()}disconnectedCallback(){e(this,X)&&e(this,X).disconnect()}};M=new WeakMap,N=new WeakMap,m=new WeakMap,P=new WeakMap,V=new WeakMap,X=new WeakMap,oe=new WeakMap,Y=new WeakMap,re=new WeakMap,l(qe,"NineTableHScrollBar");let z=qe;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",z);const Ae=class Ae{constructor(i){u(this,F);u(this,I,[]);u(this,q,null);u(this,W,null);u(this,H,0);u(this,$,0);x(this,"getRowHeight",l(()=>e(this,q),"getRowHeight"));u(this,le,l(()=>{e(this,ae).call(this)},"#init"));u(this,ae,l(()=>{!e(this,F)||!(e(this,F)instanceof HTMLElement)||(b(this,W,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 o=s.clientHeight||s.getBoundingClientRect().height||n;let r=0;const h=s.querySelector(".ng-container-body")||s,p=h.querySelector("thead"),c=h.querySelector("tfoot");p&&(r+=p.offsetHeight||p.getBoundingClientRect().height),c&&(r+=c.offsetHeight||c.getBoundingClientRect().height);const d=Math.max(o-r,100);if(e(this,H)!==d&&(b(this,H,d),e(this,q)!==null)){const a=Math.ceil(e(this,H)/e(this,q));b(this,$,a+20),S.log(`[RowManager] Resized. Height: ${e(this,H)}px | Target Rows: ${e(this,$)}`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(g=>{const f=s.querySelector(g);f&&f.querySelector("tbody")&&this.renderRows(f)})}}}})),e(this,W).observe(e(this,F)))},"#initResizeObserver"));x(this,"initTemplate",l(i=>{const t=i.querySelector("tbody.bindable")||i.querySelector("tbody");if(!t)return;const s=Array.from(t.querySelectorAll("tr")).filter(n=>!n.classList.contains("nodata"));b(this,I,s.map(n=>n.cloneNode(!0))),b(this,q,null),console.log(`[RowManager] Template initialized with ${e(this,I).length} row(s).`)},"initTemplate"));x(this,"measureAndCacheHeight",l(i=>{if(e(this,q)!==null&&e(this,q)>0)return e(this,q);if(e(this,I).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(a=>a.remove());const s=t.querySelector("tr.nodata"),n=document.createDocumentFragment();e(this,I).forEach(a=>{n.appendChild(a.cloneNode(!0))}),s?s.before(n):t.appendChild(n);const o=i.closest("nine-table-sheet"),r=o?o.style.display:"",h=o?o.style.visibility:"",p=o?o.style.position:"";o&&(o.style.display==="none"||window.getComputedStyle(o).display==="none")&&(o.style.display="block",o.style.visibility="hidden",o.style.position="absolute");let c=0;if(t.querySelectorAll("tr:not(.nodata)").forEach((a,g)=>{const f=a.offsetHeight||a.getBoundingClientRect().height;f===0?c+=40:c+=f}),o&&(o.style.display=r,o.style.visibility=h,o.style.position=p),b(this,q,c),e(this,H)>0){const a=Math.ceil(e(this,H)/e(this,q));b(this,$,a+20)}else b(this,$,40);return console.log(`[RowManager] Template Height Cached: ${e(this,q)}px | RowCount: ${e(this,$)}`),e(this,q)},"measureAndCacheHeight"));x(this,"renderRows",l(i=>{if(e(this,I).length===0)return;const t=i.querySelector("tbody.bindable")||i.querySelector("tbody");if(!t)return;t.querySelectorAll("tr:not(.nodata)").forEach(r=>r.remove());const s=t.querySelector("tr.nodata"),n=document.createDocumentFragment(),o=e(this,$);for(let r=0;r<o;r++)e(this,I).forEach(h=>{n.appendChild(h.cloneNode(!0))});s?s.before(n):t.appendChild(n),console.log(`[RowManager] Rendered ${o} sets into DOM.`)},"renderRows"));x(this,"destroy",l(()=>{e(this,W)&&(e(this,W).disconnect(),b(this,W,null))},"destroy"));b(this,F,i),e(this,le).call(this)}get templateLength(){return e(this,I).length||1}};F=new WeakMap,I=new WeakMap,q=new WeakMap,W=new WeakMap,H=new WeakMap,$=new WeakMap,le=new WeakMap,ae=new WeakMap,l(Ae,"RowManager");let Q=Ae;const ee=class ee extends HTMLElement{constructor(){super();u(this,_,null);u(this,U);x(this,"init",l(t=>{if(!t)return;const s=l(c=>{const d=l(g=>{if(g.querySelector("colgroup"))return;const f=g.querySelector("tbody tr")||g.querySelector("tr"),T=f?f.querySelectorAll("th, td").length:1,R=document.createElement("colgroup"),D=Math.max(Math.floor((g.clientWidth||600)/T),100);for(let L=0;L<T;L++){const J=document.createElement("col");J.setAttribute("width",D),R.appendChild(J)}g.prepend(R)},"ensureColgroup"),a=l(g=>{if(g.querySelector("thead"))return;const f=document.createElement("thead"),T=g.querySelector("colgroup");T?T.after(f):g.prepend(f)},"ensureThead");return d(c),a(c),c.classList.add("nine-table-element"),c},"initializeTable"),n=t.cloneNode(!0);b(this,_,s(n)),e(this,_).style.display="table",e(this,U).initTemplate(e(this,_));const o=this.querySelector(".ng-container-left"),r=this.querySelector(".ng-container-body"),h=this.querySelector(".ng-container-right"),p=l((c,d,a=!1)=>{const g=c.cloneNode(!0),f=Array.from(g.querySelectorAll("colgroup col")),T=[];return f.forEach((R,D)=>{const L=R.getAttribute("fixed");(a?L!=="left"&&L!=="right":L===d)||T.push(D)}),T.reverse().forEach(R=>{f[R]&&f[R].remove(),g.querySelectorAll("tr").forEach(D=>{const L=D.querySelectorAll("th, td");L[R]&&L[R].remove()})}),g},"filterTableByFixed");if(r){const c=p(e(this,_),null,!0);r.innerHTML="",r.appendChild(c),e(this,U).measureAndCacheHeight(r)}if(o){const c=p(e(this,_),"left",!1);let d=0;c.querySelectorAll("col").forEach(g=>{const f=parseInt(g.getAttribute("width"),10);isNaN(f)||(d+=f)}),o.innerHTML="",o.appendChild(c);const a=d>0?d:0;o.style.flex=`0 0 ${a}px`,o.style.width=`${a}px`}if(h){const c=p(e(this,_),"right",!1);let d=0;c.querySelectorAll("col").forEach(g=>{const f=parseInt(g.getAttribute("width"),10);isNaN(f)||(d+=f)}),h.innerHTML="",h.appendChild(c);const a=d>0?d:0;h.style.flex=`0 0 ${a}px`,h.style.width=`${a}px`}if(r){const c=this.getRowCount();r.style.overflowY=c>10?"auto":"hidden",r.addEventListener("scroll",()=>{const d=this.querySelector("nine-table-hscrollbar");d&&typeof d.refresh=="function"&&d.refresh()})}setTimeout(()=>{const c=this.querySelector("nine-table-hscrollbar");c&&typeof c.refresh=="function"&&c.refresh()},0),S.log(`NineTableSheet 3-split initialized with rows: ${this.getRowCount()}`)},"init"));x(this,"getRowHeight",l(()=>e(this,U).getRowHeight(),"getRowHeight"));x(this,"getRowCount",l(()=>e(this,_)?e(this,_).querySelectorAll("tbody tr").length:0,"getRowCount"));x(this,"scrollToX",l(t=>{const s=this.querySelector(".ng-container-body");s&&(s.scrollLeft=t)},"scrollToX"));x(this,"scrollToY",l(t=>{const s=this.querySelector(".ng-container-body");s&&(s.scrollTop=t)},"scrollToY"));u(this,ce,l(()=>{const t=ee.SCROLLBAR_SIZE;this.innerHTML=`
|
|
64
64
|
<style>
|
|
65
65
|
nine-table-sheet {
|
|
66
66
|
flex-direction: column;
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
overflow: hidden;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
nine-table-sheet
|
|
75
|
+
nine-table-sheet {
|
|
76
76
|
display: none;
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -129,14 +129,6 @@
|
|
|
129
129
|
border-top: 1px solid #e5e7eb;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
/**
|
|
133
|
-
nine-table-sheet nine-table-hscrollbar {
|
|
134
|
-
flex: 1;
|
|
135
|
-
height: 100%;
|
|
136
|
-
overflow: hidden;
|
|
137
|
-
--display: block;
|
|
138
|
-
} */
|
|
139
|
-
|
|
140
132
|
nine-table-sheet .ng-scroll-edge {
|
|
141
133
|
width: ${t}px;
|
|
142
134
|
min-width: ${t}px;
|
|
@@ -180,7 +172,7 @@
|
|
|
180
172
|
<nine-table-hscrollbar></nine-table-hscrollbar>
|
|
181
173
|
<div class='ng-scroll-edge'></div>
|
|
182
174
|
</div>
|
|
183
|
-
`},"#render"));
|
|
175
|
+
`},"#render"));b(this,U,new Q(this))}connectedCallback(){e(this,ce).call(this)}disconnectedCallback(){this.innerHTML="",S.log("NineTableSheet destroyed.")}};_=new WeakMap,U=new WeakMap,ce=new WeakMap,l(ee,"NineTableSheet"),x(ee,"SCROLLBAR_SIZE",16);let ne=ee;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",ne);const Ce=class Ce extends HTMLElement{constructor(){super();u(this,he,l(()=>{const t=this.querySelector(".nine-tab-bar");t&&(t.addEventListener("click",s=>{const n=s.target.closest(".nine-tab-item");if(!n)return;const o=s.ctrlKey||s.metaKey||s.shiftKey,r=parseInt(n.dataset.index,10);this.switchSheet(r,o)}),this.switchSheet(0,!1))},"#init"));x(this,"switchSheet",l((t,s=!1)=>{const n=l(a=>{const g=Array.from(a.querySelectorAll("nine-table-sheet"));Array.from(a.querySelectorAll("nine-splitter")).forEach(R=>R.style.setProperty("display","none"));const T=g.filter(R=>R.classList.contains("active"));T.length<2||T.forEach(R=>{const D=parseInt(R.getAttribute("data-index"),10),L=a.querySelector(`nine-splitter[data-split-index="${D}"]`),J=g[D+1];L&&J&&J.classList.contains("active")&&L.style.setProperty("display","block")})},"updateSplitters"),o=this.querySelector(".nine-tab-bar"),r=this.querySelector("nine-table-sheets-body"),h=o.querySelectorAll(".nine-tab-item"),p=r.querySelectorAll("nine-table-sheet");if(!h[t])return;if(!s)trace.log("================================= 1"),h.forEach((a,g)=>{a.classList.toggle("active",g===t)}),p.forEach((a,g)=>{const f=g===t;a.classList.toggle("active",f),f?a.style.flex="1 1 100%":a.style.flex=""});else{trace.log("================================= 2");const a=h[t],g=o.querySelectorAll(".nine-tab-item.active");if(trace.log(a,g.length),a.classList.contains("active")&&g.length<=1)return;a.classList.toggle("active");const f=r.querySelector(`nine-table-sheet[data-index="${t}"]`);f&&(f.classList.toggle("active"),f.classList.contains("active")||(f.style.flex=""))}const c=Array.from(r.querySelectorAll("nine-table-sheet.active"));c.length>1?c.forEach(a=>{a.style.flex="1 1 0%"}):c.forEach(a=>{a.style.flex="1 1 100%"}),n(r);const d=r.querySelector("nine-table-sheet.active");if(d&&typeof d.getRowCount=="function"){const a=this.querySelector("#row-count");a&&(a.textContent=d.getRowCount().toLocaleString())}},"switchSheet"))}connectedCallback(){e(this,he).call(this)}};he=new WeakMap,l(Ce,"NineTableSheets");let me=Ce;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",me);const ke=class ke{constructor(i){u(this,E);u(this,de);u(this,te,null);u(this,fe,l(()=>{const i=e(this,E).shadowRoot.host;i&&(b(this,te,new ResizeObserver(t=>{for(let s of t)i.getAttribute("auto-height")==="true"&&e(this,ie).call(this,i)})),e(this,te).observe(i))},"#observeResize"));u(this,ie,l(i=>{var a,g;const t=Array.from(e(this,E).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(t.length===0)return;const s=parseInt(i.getAttribute("max-display-row"),10)||10,n=Math.max(...t.map(f=>f.getRowHeight())),o=(a=e(this,E).shadowRoot.querySelector("nine-table-header"))==null?void 0:a.getBoundingClientRect().height,r=(g=e(this,E).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:g.getBoundingClientRect().height,h=ne.SCROLLBAR_SIZE,p=s*n+o+r+h;i.style.height=`${p}px`;const c=Math.max(...t.map(f=>f.getRowCount())),d=e(this,E).shadowRoot.querySelector("nine-table-sheets-body");if(!d)throw new Error("[LayoutManager] sheetsBody element is missing from the DOM.");S.log(e(this,E).data.getRowCount()),S.log(e(this,E).data.length),d.style.overflowY=c>s?"auto":"hidden"},"#applyAutoHeight"));u(this,ue,l(()=>{const i=e(this,E).shadowRoot.host;console.log(i,e(this,E));const s=Array.from(i.children).filter(c=>c.tagName==="TABLE"),n=i.getAttribute("auto-height")==="true",o=s.length,r=s.map((c,d)=>{const g=`<nine-table-sheet class="${d===0?"active":""}" data-index="${d}"></nine-table-sheet>`,f=d<o-1?`<nine-splitter class="h" data-split-index="${d}"></nine-splitter>`:"";return g+f}).join(""),h=s.map((c,d)=>`<div class="nine-tab-item ${d===0?"active":""}" data-index="${d}">Sheet ${d+1}</div>`).join("");e(this,E).shadowRoot.innerHTML=`
|
|
184
176
|
<style>
|
|
185
177
|
:host {
|
|
186
178
|
display: flex;
|
|
@@ -190,6 +182,7 @@
|
|
|
190
182
|
height: ${n?"auto":"100%"};
|
|
191
183
|
background: #fff;
|
|
192
184
|
}
|
|
185
|
+
|
|
193
186
|
nine-table-header { height: 40px; display: block; flex-shrink: 0; border-bottom: 1px solid #e5e7eb; background: #fff; }
|
|
194
187
|
nine-table-body { display: flex; flex-direction: row; flex: 1; overflow: hidden; position: relative; }
|
|
195
188
|
nine-table-summary { display: none; width: 250px; flex-shrink: 0; border-right: 1px solid #e5e7eb; }
|
|
@@ -213,16 +206,6 @@
|
|
|
213
206
|
flex-direction: row;
|
|
214
207
|
}
|
|
215
208
|
|
|
216
|
-
bbbb-nine-table-sheet {
|
|
217
|
-
display: none;
|
|
218
|
-
height: 100%;
|
|
219
|
-
overflow: auto;
|
|
220
|
-
flex: 1 1 ${o>1?`${100/o}%`:"100%"};
|
|
221
|
-
}
|
|
222
|
-
bbb-nine-table-sheet.active {
|
|
223
|
-
display: block;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
209
|
nine-table-sheets-body nine-splitter.h {
|
|
227
210
|
width: 4px;
|
|
228
211
|
background: #e5e7eb;
|
|
@@ -287,5 +270,5 @@
|
|
|
287
270
|
<nine-table-analysis></nine-table-analysis>
|
|
288
271
|
</nine-table-body>
|
|
289
272
|
<nine-table-footer></nine-table-footer>
|
|
290
|
-
`;const p=e(this,
|
|
273
|
+
`;const p=e(this,E).shadowRoot.querySelectorAll("nine-table-sheet");p==null||p.forEach((c,d)=>{s[d]&&setTimeout(()=>{c.init(s[d]),n&&e(this,ie).call(this,i)})})},"#render"));b(this,E,i),b(this,de,e(this,E).shadowRoot),e(this,ue).call(this),e(this,fe).call(this)}};E=new WeakMap,de=new WeakMap,te=new WeakMap,fe=new WeakMap,ie=new WeakMap,ue=new WeakMap,l(ke,"LayoutManager");let ve=ke;const Le=class Le{constructor(i){u(this,O);u(this,K,-1);x(this,"count",l(()=>e(this,O).rawRecords.length,"count"));b(this,O,i)}get at(){return e(this,K)}set at(i){var s,n;b(this,K,parseInt(i,10));const t=((n=(s=e(this,O).owner).querySelector)==null?void 0:n.call(s,".ng-container-body"))||e(this,O).owner.body;t&&!t.querySelector(`tbody.bindable tr[data-row="${e(this,K)}"]`)&&setTimeout(()=>{var o,r;(r=(o=e(this,O).owner).scrollTo_V1)==null||r.call(o,e(this,K))})}};O=new WeakMap,K=new WeakMap,l(Le,"ngRow");let xe=Le;const k=class k{constructor(i,t){u(this,A);u(this,v);u(this,C,[]);u(this,j,[]);u(this,ge,0);u(this,B,[]);u(this,be,l(()=>{b(this,B,[]);const i=e(this,A).template||[];Array.from(i).forEach(t=>{var s;e(this,B).push(((s=t.getBoundingClientRect)==null?void 0:s.call(t).height)||24)}),(e(this,v).rawRecords||[]).forEach(t=>{t.__ng||(t.__ng=e(this,se).call(this)),t.__ng.height=e(this,B).slice()})},"#initialize"));x(this,"set",l(i=>{this.clear(),this.add(i,!1)},"set"));u(this,se,l(()=>({rowState:k.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:e(this,B).slice(),o:{},c:{},_:[0,0,0,0,k.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,e(this,B).slice(),-1,{},{}]}),"#getDefaultMeta"));x(this,"reset",l(()=>{b(this,C,[]),b(this,j,[])},"reset"));x(this,"clear",l(()=>{var i;e(this,v).rawRecords=[],b(this,C,[]),b(this,j,[]),(i=e(this,v).viewRecords)!=null&&i.reset&&e(this,v).viewRecords.reset()},"clear"));u(this,pe,l(i=>{var n;Array.isArray(i)||(i=[i]);const t=typeof((n=e(this,A).fields)==null?void 0:n.get)=="function"?e(this,A).fields.get():Object.keys(i[0]||{}),s=[];return i.forEach(o=>{const r={v:[]};t.forEach(h=>{r.v.push(o[h]!==void 0&&o[h]!==null?o[h]:"")}),s.push(r)}),s},"#json2Array"));u(this,ye,l(i=>(Array.isArray(i)||(i=[i]),i.forEach(t=>{t.__ng=e(this,se).call(this),t.__ng.rowid=this.nextId,t.__ng.rowState=k.ROW_STATE.INSERT,t.__ng._[0]=t.__ng.rowid}),i),"#defaultInsert"));x(this,"add",l((i,t=!0)=>{var o;i===void 0&&(i={});const s=e(this,pe).call(this,i);e(this,v).rawRecords=e(this,v).rawRecords.concat(e(this,ye).call(this,s)),this.resetRecords();const n=this.count()-1;return t||s.forEach((r,h)=>{const p=e(this,v).rawRecords[n-h];p&&(p.__ng.rowState=k.ROW_STATE.EMPTY)}),(o=e(this,v).viewRecords)!=null&&o.reset&&e(this,v).viewRecords.reset(),n},"add"));x(this,"delete",l(i=>{var s;let t=[];Array.isArray(i)?t=i:typeof i>"u"?t=[e(this,v).owner.row.at]:t=[parseInt(i,10)],t.sort((n,o)=>o-n).forEach(n=>{if(e(this,C)[n]){const o=e(this,C)[n].__ng.rowid;e(this,C)[n].__ng.rowState===k.ROW_STATE.INSERT?e(this,v).rawRecords=e(this,v).rawRecords.filter(r=>r.__ng.rowid!==o):e(this,v).rawRecords.forEach(r=>{r.__ng.rowid===o&&(r.__ng.deleted=!0,r.__ng.rowState=k.ROW_STATE.DELETE)})}}),this.resetRecords(),(s=e(this,v).viewRecords)!=null&&s.reset&&e(this,v).viewRecords.reset()},"delete"));x(this,"setValue",l((i,t,s)=>{var p;i=parseInt(i,10);const o=(typeof((p=e(this,A).fields)==null?void 0:p.get)=="function"?e(this,A).fields.get():[]).indexOf(t);if(o<0)return;const r=this.getValidData()[i];if(!r)return;const h=r.v[o];h!==s&&r.__ng.rowState!==k.ROW_STATE.INSERT&&(r.__ng.o.hasOwnProperty(t)||(r.__ng.o[t]=h),r.__ng.rowState=k.ROW_STATE.UPDATE),r.v[o]=s,e(this,v).owner.refreshData&&e(this,v).owner.refreshData(i)},"setValue"));x(this,"resetRecords",l(()=>{b(this,j,e(this,v).rawRecords.filter(i=>!i.__ng.deleted)),b(this,C,e(this,v).rawRecords.filter(i=>!i.__ng.deleted&&!i.__ng.filtered)),e(this,v).rawRecords.forEach((i,t)=>{i.__ng.rowidx=t}),e(this,C).forEach((i,t)=>{i.__ng.i=t})},"resetRecords"));x(this,"getValidData",l(()=>(e(this,C).length===0&&e(this,v).rawRecords.length>0&&this.resetRecords(),e(this,C)),"getValidData"));u(this,G,l(i=>{var s;if(!i)return i;const t=typeof((s=e(this,A).fields)==null?void 0:s.get)=="function"?e(this,A).fields.get():[];return Array.isArray(i)?i.filter(n=>!n.__ng.deleted).map(n=>{const o={};return t.forEach((r,h)=>{o[r]=n.v?n.v[h]:n[r]}),o.__ng=n.__ng,o}):i},"#conv2"));x(this,"count",l(()=>this.getValidData().length,"count"));x(this,"get",l((i,t)=>{var o;const s=this.getValidData();if(!s||s.length<=0)return;if(i==null)return e(this,G).call(this,s);if(i<0||i>=s.length)return null;const n=typeof((o=e(this,A).fields)==null?void 0:o.get)=="function"?e(this,A).fields.get():[];if(t!=null){const r=n.indexOf(t);return r>=0?s[i].v[r]:null}return e(this,G).call(this,s[i])},"get"));b(this,A,i),b(this,v,t),e(this,be).call(this)}get source(){return e(this,G).call(this,e(this,v).rawRecords)}set source(i){this.clear(),this.add(i,!1)}get nextId(){return++ze(this,ge)._}get length(){return e(this,C).length}getRowCount(){return this.length}};A=new WeakMap,v=new WeakMap,C=new WeakMap,j=new WeakMap,ge=new WeakMap,B=new WeakMap,be=new WeakMap,se=new WeakMap,pe=new WeakMap,ye=new WeakMap,G=new WeakMap,l(k,"ngData"),x(k,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Se=k;const _e=class _e{constructor(i){this.owner=i,this.row=new xe(this),this.data=new Se(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,o;const s=parseInt(t,10);if(!(s>=this.data.count()))return(o=(n=this.data.getValidData()[s])==null?void 0:n.__ng)==null?void 0:o.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([])}};l(_e,"ngDataManager");let Re=_e;const Me=class Me extends HTMLElement{constructor(){super();u(this,Z);u(this,we);this.attachShadow({mode:"open"}),b(this,Z,new Re(this))}connectedCallback(){b(this,we,new ve(this)),S.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))}disconnectedCallback(){S.log("NineTable disconnected.")}get data(){return e(this,Z).data}get row(){return e(this,Z).row}get dataManager(){return e(this,Z)}};Z=new WeakMap,we=new WeakMap,l(Me,"NineTable");let Ee=Me;customElements.get("nine-table")||customElements.define("nine-table",Ee)});
|
|
291
274
|
//# sourceMappingURL=nine-table.umd.js.map
|