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