@ninebone/table 0.0.201 → 0.0.202
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 +284 -276
- 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,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 Me=Object.defineProperty;var He=m=>{throw TypeError(m)};var We=(m,y,S)=>y in m?Me(m,y,{enumerable:!0,configurable:!0,writable:!0,value:S}):m[y]=S;var a=(m,y)=>Me(m,"name",{value:y,configurable:!0});var x=(m,y,S)=>We(m,typeof y!="symbol"?y+"":y,S),Ie=(m,y,S)=>y.has(m)||He("Cannot "+S);var e=(m,y,S)=>(Ie(m,y,"read from private field"),S?S.call(m):y.get(m)),d=(m,y,S)=>y.has(m)?He("Cannot add the same private member more than once"):y instanceof WeakSet?y.add(m):y.set(m,S),p=(m,y,S,W)=>(Ie(m,y,"write to private field"),W?W.call(m,S):y.set(m,S),S);var $e=(m,y,S,W)=>({set _(J){p(m,y,J,S)},get _(){return e(m,y,W)}});var _,B,w,P,V,X,ne,Y,re,F,M,A,z,H,I,oe,le,L,U,ae,ce,ee,E,he,te,de,O,K,q,v,k,j,fe,D,ue,ie,be,ge,G,Z,pe;const Re=class Re extends m.trace.constructor{constructor(){super(),this.init("nine-table","green")}};a(Re,"Trace");let y=Re;const S=new y,Ee=class Ee extends HTMLElement{constructor(){super();d(this,_);d(this,B,!1);d(this,w);d(this,P);d(this,V);d(this,X);d(this,ne,a(()=>{if(!e(this,_))return;const t=e(this,_).querySelector(".ng-container-body");t&&(p(this,X,new ResizeObserver(()=>{this.refresh()})),e(this,X).observe(t))},"#observeResize"));x(this,"refresh",a(()=>{if(!e(this,_)||!e(this,w)||e(this,B))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 h=Math.max(Math.min(l*(c/u),l),20);r.style.width=`${h}px`;let f=0;const b=s.style.transform;if(b&&b.includes("translateX")){const R=b.match(/translateX\(([-\d.]+)px\)/);R&&R[1]&&(f=parseFloat(R[1]))}else f=parseInt(s.style.left||0,10);let g=parseInt(Math.abs(f)*l/u,10);g<0&&(g=0);const T=l-h;g>T&&(g=T),r.style.left=`${g}px`,e(this,w).left.disabled=g===0,e(this,w).right.disabled=g>=T-1},"refresh"));d(this,Y,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 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,h=n.scrollWidth;let f=u>0?-c*(h-l)/u:0;return-f>h-l&&(f=-(h-l)),-f+5>h-l&&(f=-(h-l)),l>=h&&(f=0),n.style.transform=`translateX(${f}px)`,c>0&&c<u-1},"#thumbMoveTo"));d(this,re,a(()=>{const t=a(n=>{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+n),p(this,P,setInterval(()=>{clearInterval(e(this,P)),p(this,V,setInterval(()=>{const o=parseInt(e(this,w).thumb.style.left||0,10);e(this,Y).call(this,o+n)||clearInterval(e(this,V))},50))},500))},"delayScroll"),s=a(()=>{clearInterval(e(this,P)),clearInterval(e(this,V))},"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,Y).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,B,!0),this.shiftX=n.clientX-e(this,w).thumb.getBoundingClientRect().left;const r=a(c=>{if(!e(this,B))return;const u=e(this,w).track.getBoundingClientRect();e(this,Y).call(this,c.clientX-u.left-this.shiftX)},"onMouseMove"),o=a(()=>{p(this,B,!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 s=e(this,_).querySelector(".ng-container-body");if(!s){setTimeout(t,10);return}
|
|
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,re).call(this),e(this,ne).call(this),this.refresh()},"initWhenReady");t()}disconnectedCallback(){e(this,X)&&e(this,X).disconnect()}};_=new WeakMap,B=new WeakMap,w=new WeakMap,P=new WeakMap,V=new WeakMap,X=new WeakMap,ne=new WeakMap,Y=new WeakMap,re=new WeakMap,a(Ee,"NineTableHScrollBar");let W=Ee;customElements.get("nine-table-hscrollbar")||customElements.define("nine-table-hscrollbar",W);const Te=class Te{constructor(i){d(this,F);d(this,M,[]);d(this,A,null);d(this,z,null);d(this,H,0);d(this,I,0);x(this,"getRowHeight",a(()=>e(this,A),"getRowHeight"));d(this,oe,a(()=>{e(this,le).call(this)},"#init"));d(this,le,a(()=>{!e(this,F)||!(e(this,F)instanceof HTMLElement)||(p(this,z,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 h=Math.max(r-o,100);if(e(this,H)!==h&&(p(this,H,h),e(this,A)!==null)){const f=Math.ceil(e(this,H)/e(this,A));p(this,I,f+20),S.log(`[RowManager] Resized. Height: ${e(this,H)}px | Target Rows: ${e(this,I)}`),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(b=>{const g=s.querySelector(b);g&&g.querySelector("tbody")&&this.renderRows(g)})}}}})),e(this,z).observe(e(this,F)))},"#initResizeObserver"));x(this,"initTemplate",a(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"));p(this,M,s.map(n=>n.cloneNode(!0))),p(this,A,null),console.log(`[RowManager] Template initialized with ${e(this,M).length} row(s).`)},"initTemplate"));x(this,"measureAndCacheHeight",a(i=>{if(e(this,A)!==null&&e(this,A)>0)return e(this,A);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(f=>f.remove());const s=t.querySelector("tr.nodata"),n=document.createDocumentFragment();e(this,M).forEach(f=>{n.appendChild(f.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;if(t.querySelectorAll("tr:not(.nodata)").forEach((f,b)=>{const g=f.offsetHeight||f.getBoundingClientRect().height;g===0?l+=40:l+=g}),r&&(r.style.display=o,r.style.visibility=c,r.style.position=u),p(this,A,l),e(this,H)>0){const f=Math.ceil(e(this,H)/e(this,A));p(this,I,f+20)}else p(this,I,40);return console.log(`[RowManager] Template Height Cached: ${e(this,A)}px | RowCount: ${e(this,I)}`),e(this,A)},"measureAndCacheHeight"));x(this,"renderRows",a(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,I);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"));x(this,"destroy",a(()=>{e(this,z)&&(e(this,z).disconnect(),p(this,z,null))},"destroy"));p(this,F,i),e(this,oe).call(this)}get templateLength(){return e(this,M).length||1}};F=new WeakMap,M=new WeakMap,A=new WeakMap,z=new WeakMap,H=new WeakMap,I=new WeakMap,oe=new WeakMap,le=new WeakMap,a(Te,"RowManager");let J=Te;const Q=class Q extends HTMLElement{constructor(){super();d(this,L,null);d(this,U);x(this,"init",a(t=>{if(!t)return;const s=a(l=>{const h=a(b=>{if(b.querySelector("colgroup"))return;const g=b.querySelector("tbody tr")||b.querySelector("tr"),T=g?g.querySelectorAll("th, td").length:1,R=document.createElement("colgroup"),N=Math.max(Math.floor((b.clientWidth||600)/T),100);for(let $=0;$<T;$++){const _e=document.createElement("col");_e.setAttribute("width",N),R.appendChild(_e)}b.prepend(R)},"ensureColgroup"),f=a(b=>{if(b.querySelector("thead"))return;const g=document.createElement("thead"),T=b.querySelector("colgroup");T?T.after(g):b.prepend(g)},"ensureThead");return h(l),f(l),l.classList.add("nine-table-element"),l},"initializeTable"),n=t.cloneNode(!0);p(this,L,s(n)),e(this,L).style.display="table",e(this,U).initTemplate(e(this,L));const r=this.querySelector(".ng-container-left"),o=this.querySelector(".ng-container-body"),c=this.querySelector(".ng-container-right"),u=a((l,h,f=!1)=>{const b=l.cloneNode(!0),g=Array.from(b.querySelectorAll("colgroup col")),T=[];return g.forEach((R,N)=>{const $=R.getAttribute("fixed");(f?$!=="left"&&$!=="right":$===h)||T.push(N)}),T.reverse().forEach(R=>{g[R]&&g[R].remove(),b.querySelectorAll("tr").forEach(N=>{const $=N.querySelectorAll("th, td");$[R]&&$[R].remove()})}),b},"filterTableByFixed");if(o){const l=u(e(this,L),null,!0);o.innerHTML="",o.appendChild(l),e(this,U).measureAndCacheHeight(o)}if(r){const l=u(e(this,L),"left",!1);let h=0;l.querySelectorAll("col").forEach(b=>{const g=parseInt(b.getAttribute("width"),10);isNaN(g)||(h+=g)}),r.innerHTML="",r.appendChild(l);const f=h>0?h:0;r.style.flex=`0 0 ${f}px`,r.style.width=`${f}px`}if(c){const l=u(e(this,L),"right",!1);let h=0;l.querySelectorAll("col").forEach(b=>{const g=parseInt(b.getAttribute("width"),10);isNaN(g)||(h+=g)}),c.innerHTML="",c.appendChild(l);const f=h>0?h:0;c.style.flex=`0 0 ${f}px`,c.style.width=`${f}px`}if(o){const l=this.getRowCount();o.style.overflowY=l>10?"auto":"hidden",o.addEventListener("scroll",()=>{const h=this.querySelector("nine-table-hscrollbar");h&&typeof h.refresh=="function"&&h.refresh()})}setTimeout(()=>{const l=this.querySelector("nine-table-hscrollbar");l&&typeof l.refresh=="function"&&l.refresh()},0),S.log(`NineTableSheet 3-split initialized with rows: ${this.getRowCount()}`)},"init"));x(this,"getRowHeight",a(()=>e(this,U).getRowHeight(),"getRowHeight"));x(this,"getRowCount",a(()=>e(this,L)?e(this,L).querySelectorAll("tbody tr").length:0,"getRowCount"));x(this,"scrollToX",a(t=>{const s=this.querySelector(".ng-container-body");s&&(s.scrollLeft=t)},"scrollToX"));x(this,"scrollToY",a(t=>{const s=this.querySelector(".ng-container-body");s&&(s.scrollTop=t)},"scrollToY"));d(this,ae,a(()=>{const t=Q.SCROLLBAR_SIZE;this.innerHTML=`
|
|
64
64
|
<style>
|
|
65
65
|
nine-table-sheet {
|
|
66
66
|
flex-direction: column;
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
그 스플리터 바로 앞에 있는 시트(.active)도 켜져 있을 때만 display: block
|
|
172
172
|
*/
|
|
173
173
|
nine-table-sheet.active + nine-splitter + nine-table-sheet.active {
|
|
174
|
-
display: flex;
|
|
174
|
+
--display: flex;
|
|
175
175
|
}
|
|
176
176
|
</style>
|
|
177
177
|
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
<nine-table-hscrollbar></nine-table-hscrollbar>
|
|
186
186
|
<div class='ng-scroll-edge'></div>
|
|
187
187
|
</div>
|
|
188
|
-
`},"#render"));
|
|
188
|
+
`},"#render"));p(this,U,new J(this))}connectedCallback(){e(this,ae).call(this)}disconnectedCallback(){this.innerHTML="",S.log("NineTableSheet destroyed.")}};L=new WeakMap,U=new WeakMap,ae=new WeakMap,a(Q,"NineTableSheet"),x(Q,"SCROLLBAR_SIZE",16);let se=Q;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",se);const Ae=class Ae extends HTMLElement{constructor(){super();d(this,ce,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,ee).call(this,r,n)}),e(this,ee).call(this,0,!1)},"#init"));d(this,ee,a((t,s=!1)=>{var l;const n=a(()=>{const h=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(g=>g.style.setProperty("display","none"));const b=h.filter(g=>g.classList.contains("active"));b.length<2||b.forEach(g=>{const T=parseInt(g.getAttribute("data-index"),10),R=this.querySelector(`nine-splitter[data-split-index="${T}"]`),N=h[T+1];R&&N&&N.classList.contains("active")&&R.style.setProperty("display","block")})},"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]){if(!s)c.forEach((h,f)=>{h.classList.toggle("active",f===t)}),u.forEach((h,f)=>{const b=f===t;h.classList.toggle("active",b),h.style.flex=b?"1 1 100%":""});else{const h=c[t],f=r.querySelectorAll(".nine-tab-item.active");if(h.classList.contains("active")&&f.length<=1)return;h.classList.toggle("active");const b=o.querySelector(`nine-table-sheet[data-index="${t}"]`);b&&(b.classList.toggle("active"),b.classList.contains("active")||(b.style.flex=""))}(l=o.querySelectorAll("nine-table-sheet.active"))==null||l.forEach(h=>{h.style.flex=activeSheets.length>1?"1 1 0%":"1 1 100%"}),n()}},"#switchSheet"))}connectedCallback(){e(this,ce).call(this)}};ce=new WeakMap,ee=new WeakMap,a(Ae,"NineTableSheets");let ye=Ae;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",ye);const qe=class qe{constructor(i){d(this,E);d(this,he,a(()=>{e(this,de).call(this),new ResizeObserver(i=>{for(let t of i)e(this,E).getAttribute("auto-height")==="true"&&e(this,te).call(this)}).observe(e(this,E))},"#init"));d(this,te,a(()=>{var u,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=(u=e(this,E).shadowRoot.querySelector("nine-table-header"))==null?void 0:u.getBoundingClientRect().height,r=(l=e(this,E).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:l.getBoundingClientRect().height,o=se.SCROLLBAR_SIZE,c=t*s+n+r+o;e(this,E).style.height=`${c}px`},"#applyAutoHeight"));d(this,de,a(()=>{const t=Array.from(e(this,E).children).filter(u=>u.tagName==="TABLE"),s=e(this,E).getAttribute("auto-height")==="true",n=t.length,r=t.map((u,l)=>{const f=`<nine-table-sheet class="${l===0?"active":""}" data-index="${l}"></nine-table-sheet>`,b=l<n-1?`<nine-splitter class="h" data-split-index="${l}"></nine-splitter>`:"";return f+b}).join(""),o=t.map((u,l)=>`<div class="nine-tab-item ${l===0?"active":""}" data-index="${l}">Sheet ${l+1}</div>`).join("");e(this,E).shadowRoot.innerHTML=`
|
|
189
189
|
<style>
|
|
190
190
|
:host {
|
|
191
191
|
display: flex;
|
|
@@ -283,5 +283,5 @@
|
|
|
283
283
|
<nine-table-analysis></nine-table-analysis>
|
|
284
284
|
</nine-table-body>
|
|
285
285
|
<nine-table-footer></nine-table-footer>
|
|
286
|
-
`;const
|
|
286
|
+
`;const c=e(this,E).shadowRoot.querySelectorAll("nine-table-sheet");c==null||c.forEach((u,l)=>{t[l]&&setTimeout(()=>{u.init(t[l]),s&&e(this,te).call(this)})})},"#render"));p(this,E,i),e(this,he).call(this)}};E=new WeakMap,he=new WeakMap,te=new WeakMap,de=new WeakMap,a(qe,"LayoutManager");let me=qe;const ke=class ke{constructor(i){d(this,O);d(this,K,-1);x(this,"count",a(()=>e(this,O).rawRecords.length,"count"));p(this,O,i)}get at(){return e(this,K)}set at(i){var s,n;p(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 r,o;(o=(r=e(this,O).owner).scrollTo_V1)==null||o.call(r,e(this,K))})}};O=new WeakMap,K=new WeakMap,a(ke,"ngRow");let we=ke;const C=class C{constructor(i,t){d(this,q);d(this,v);d(this,k,[]);d(this,j,[]);d(this,fe,0);d(this,D,[]);d(this,ue,a(()=>{p(this,D,[]);const i=e(this,q).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,v).rawRecords||[]).forEach(t=>{t.__ng||(t.__ng=e(this,ie).call(this)),t.__ng.height=e(this,D).slice()})},"#initialize"));x(this,"set",a(i=>{this.clear(),this.add(i,!1)},"set"));d(this,ie,a(()=>({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"));x(this,"reset",a(()=>{p(this,k,[]),p(this,j,[])},"reset"));x(this,"clear",a(()=>{var i;e(this,v).rawRecords=[],p(this,k,[]),p(this,j,[]),(i=e(this,v).viewRecords)!=null&&i.reset&&e(this,v).viewRecords.reset()},"clear"));d(this,be,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,ge,a(i=>(Array.isArray(i)||(i=[i]),i.forEach(t=>{t.__ng=e(this,ie).call(this),t.__ng.rowid=this.nextId,t.__ng.rowState=C.ROW_STATE.INSERT,t.__ng._[0]=t.__ng.rowid}),i),"#defaultInsert"));x(this,"add",a((i,t=!0)=>{var r;i===void 0&&(i={});const s=e(this,be).call(this,i);e(this,v).rawRecords=e(this,v).rawRecords.concat(e(this,ge).call(this,s)),this.resetRecords();const n=this.count()-1;return t||s.forEach((o,c)=>{const u=e(this,v).rawRecords[n-c];u&&(u.__ng.rowState=C.ROW_STATE.EMPTY)}),(r=e(this,v).viewRecords)!=null&&r.reset&&e(this,v).viewRecords.reset(),n},"add"));x(this,"delete",a(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,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,v).rawRecords=e(this,v).rawRecords.filter(o=>o.__ng.rowid!==r):e(this,v).rawRecords.forEach(o=>{o.__ng.rowid===r&&(o.__ng.deleted=!0,o.__ng.rowState=C.ROW_STATE.DELETE)})}}),this.resetRecords(),(s=e(this,v).viewRecords)!=null&&s.reset&&e(this,v).viewRecords.reset()},"delete"));x(this,"setValue",a((i,t,s)=>{var u;i=parseInt(i,10);const r=(typeof((u=e(this,q).fields)==null?void 0:u.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,v).owner.refreshData&&e(this,v).owner.refreshData(i)},"setValue"));x(this,"resetRecords",a(()=>{p(this,j,e(this,v).rawRecords.filter(i=>!i.__ng.deleted)),p(this,k,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,k).forEach((i,t)=>{i.__ng.i=t})},"resetRecords"));x(this,"getValidData",a(()=>(e(this,k).length===0&&e(this,v).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"));x(this,"count",a(()=>this.getValidData().length,"count"));x(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,v,t),e(this,ue).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++$e(this,fe)._}get length(){return e(this,k).length}getRowCount(){return this.length}};q=new WeakMap,v=new WeakMap,k=new WeakMap,j=new WeakMap,fe=new WeakMap,D=new WeakMap,ue=new WeakMap,ie=new WeakMap,be=new WeakMap,ge=new WeakMap,G=new WeakMap,a(C,"ngData"),x(C,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let ve=C;const Ce=class Ce{constructor(i){this.owner=i,this.row=new we(this),this.data=new ve(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(Ce,"ngDataManager");let xe=Ce;const Le=class Le extends HTMLElement{constructor(){super();d(this,Z);d(this,pe);this.attachShadow({mode:"open"}),p(this,Z,new xe(this))}connectedCallback(){p(this,pe,new me(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,pe=new WeakMap,a(Le,"NineTable");let Se=Le;customElements.get("nine-table")||customElements.define("nine-table",Se)});
|
|
287
287
|
//# sourceMappingURL=nine-table.umd.js.map
|