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