@ninebone/table 0.0.345 → 0.0.347
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 +20 -20
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +2 -2
- package/dist/nine-table.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/nine-table.umd.js
CHANGED
|
@@ -265,7 +265,7 @@
|
|
|
265
265
|
<nine-table-hscrollbar></nine-table-hscrollbar>
|
|
266
266
|
<div class='ng-scroll-edge'></div>
|
|
267
267
|
</div>
|
|
268
|
-
`},"#render"));b(this,K,new Ut(this)),b(this,Lt,this.getRootNode().host)}connectedCallback(){t(this,Mt).call(this)}disconnectedCallback(){this.innerHTML="",v.log("NineTableSheet destroyed.")}};Lt=new WeakMap,it=new WeakMap,K=new WeakMap,Ht=new WeakMap,Ct=new WeakMap,_t=new WeakMap,Mt=new WeakMap,It=new WeakMap,a(ft,"NineTableSheet"),w(ft,"SCROLLBAR_SIZE",16);let xt=ft;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",xt);const ne=class ne extends HTMLElement{constructor(){super();h(this,$t,a(()=>{var e;(e=this.querySelector(".nine-tab-bar"))==null||e.addEventListener("click",s=>{var n;const o=s.ctrlKey||s.metaKey||s.shiftKey,r=parseInt((n=s.target.closest(".nine-tab-item"))==null?void 0:n.dataset.index,10);t(this,ut).call(this,r,o)}),t(this,ut).call(this,0,!1)},"#init"));h(this,ut,a((e,s=!1)=>{const o=a(()=>{const f=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(x=>x.style.setProperty("display","none"));const g=f.filter(x=>x.classList.contains("active"));g.length<2||g.forEach(x=>{const T=parseInt(x.getAttribute("data-index"),10),_=this.querySelector(`nine-splitter[data-split-index="${T}"]`),Vt=f[T+1];_&&Vt&&Vt.classList.contains("active")&&_.style.setProperty("display","flex")})},"updateSplitters"),r=this.querySelector(".nine-tab-bar"),n=this.querySelector("nine-table-sheets-body"),l=r.querySelectorAll(".nine-tab-item"),c=n.querySelectorAll("nine-table-sheet");if(!l[e])return;if(!s)l.forEach((f,u)=>{f.classList.toggle("active",u===e)}),c.forEach((f,u)=>{const g=u===e;f.classList.toggle("active",g),f.style.flex=g?"1 1 100%":""});else{const f=l[e],u=r.querySelectorAll(".nine-tab-item.active");if(f.classList.contains("active")&&u.length<=1)return;f.classList.toggle("active");const g=n.querySelector(`nine-table-sheet[data-index="${e}"]`);g&&(g.classList.toggle("active"),g.classList.contains("active")||(g.style.flex=""))}const d=n.querySelectorAll("nine-table-sheet.active");d==null||d.forEach(f=>{f.style.flex=d.length>1?"1 1 0%":"1 1 100%"}),o()},"#switchSheet"))}connectedCallback(){t(this,$t).call(this)}};$t=new WeakMap,ut=new WeakMap,a(ne,"NineTableSheets");let jt=ne;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",jt);const oe=class oe{constructor(i){h(this,bt);h(this,A,[]);w(this,"add",a((i,e="string")=>{i.forEach(s=>{t(this,A).some(o=>o.name===s)||t(this,A).push({name:s,type:e})}),t(this,gt).call(this)},"add"));h(this,gt,a(()=>{const i=new Map;t(this,A).forEach(e=>{i.set(e.name,e.type)}),b(this,A,Array.from(i,([e,s])=>({name:e,type:s}))),b(this,A,t(this,A).filter(e=>e.name!==""&&e.name!=="__ng")),t(this,A).sort((e,s)=>e.name.length<s.name.length?1:-1)},"#adjust"));h(this,Wt,a(()=>{b(this,A,[]);const i=Array.from(t(this,bt).querySelectorAll("table"));if(!(!i||i.length===0)){for(const e of i)v.log(e),$("[data-bind]",e).each((s,o)=>{const r=o.dataset.bind,n=o.getAttribute("data-type")||"string";r&&t(this,A).push({name:r,type:n})}),["data-expr","background-color","color","tooltip","visible","readonly","enable-button","enable-check","class-expr","icon-color","icon-src"].forEach(s=>{$(`[${s}]`,e).each((o,r)=>{var n=r.getAttribute(s);if(n.indexOf("data.")<0){const l=n.search(/[(]/g);if(l>0)try{n=String(window[n.substring(0,l).trim()])}catch{n=""}}n.split("data.").forEach(l=>{if(l.trim()!=""){const c=l.search(/[^_A-Za-z0-9]/g);let d="";c>=0?d=l.substring(0,c):n.startsWith("data.")&&(d=l.replace("data.","")),d&&t(this,A).push({name:d,type:"string"})}})})});t(this,gt).call(this)}},"#init"));b(this,bt,i),t(this,Wt).call(this)
|
|
268
|
+
`},"#render"));b(this,K,new Ut(this)),b(this,Lt,this.getRootNode().host)}connectedCallback(){t(this,Mt).call(this)}disconnectedCallback(){this.innerHTML="",v.log("NineTableSheet destroyed.")}};Lt=new WeakMap,it=new WeakMap,K=new WeakMap,Ht=new WeakMap,Ct=new WeakMap,_t=new WeakMap,Mt=new WeakMap,It=new WeakMap,a(ft,"NineTableSheet"),w(ft,"SCROLLBAR_SIZE",16);let xt=ft;customElements.get("nine-table-sheet")||customElements.define("nine-table-sheet",xt);const ne=class ne extends HTMLElement{constructor(){super();h(this,$t,a(()=>{var e;(e=this.querySelector(".nine-tab-bar"))==null||e.addEventListener("click",s=>{var n;const o=s.ctrlKey||s.metaKey||s.shiftKey,r=parseInt((n=s.target.closest(".nine-tab-item"))==null?void 0:n.dataset.index,10);t(this,ut).call(this,r,o)}),t(this,ut).call(this,0,!1)},"#init"));h(this,ut,a((e,s=!1)=>{const o=a(()=>{const f=Array.from(this.querySelectorAll("nine-table-sheet"));Array.from(this.querySelectorAll("nine-splitter")).forEach(x=>x.style.setProperty("display","none"));const g=f.filter(x=>x.classList.contains("active"));g.length<2||g.forEach(x=>{const T=parseInt(x.getAttribute("data-index"),10),_=this.querySelector(`nine-splitter[data-split-index="${T}"]`),Vt=f[T+1];_&&Vt&&Vt.classList.contains("active")&&_.style.setProperty("display","flex")})},"updateSplitters"),r=this.querySelector(".nine-tab-bar"),n=this.querySelector("nine-table-sheets-body"),l=r.querySelectorAll(".nine-tab-item"),c=n.querySelectorAll("nine-table-sheet");if(!l[e])return;if(!s)l.forEach((f,u)=>{f.classList.toggle("active",u===e)}),c.forEach((f,u)=>{const g=u===e;f.classList.toggle("active",g),f.style.flex=g?"1 1 100%":""});else{const f=l[e],u=r.querySelectorAll(".nine-tab-item.active");if(f.classList.contains("active")&&u.length<=1)return;f.classList.toggle("active");const g=n.querySelector(`nine-table-sheet[data-index="${e}"]`);g&&(g.classList.toggle("active"),g.classList.contains("active")||(g.style.flex=""))}const d=n.querySelectorAll("nine-table-sheet.active");d==null||d.forEach(f=>{f.style.flex=d.length>1?"1 1 0%":"1 1 100%"}),o()},"#switchSheet"))}connectedCallback(){t(this,$t).call(this)}};$t=new WeakMap,ut=new WeakMap,a(ne,"NineTableSheets");let jt=ne;customElements.get("nine-table-sheets")||customElements.define("nine-table-sheets",jt);const oe=class oe{constructor(i){h(this,bt);h(this,A,[]);w(this,"add",a((i,e="string")=>{i.forEach(s=>{t(this,A).some(o=>o.name===s)||t(this,A).push({name:s,type:e})}),t(this,gt).call(this)},"add"));h(this,gt,a(()=>{const i=new Map;t(this,A).forEach(e=>{i.set(e.name,e.type)}),b(this,A,Array.from(i,([e,s])=>({name:e,type:s}))),b(this,A,t(this,A).filter(e=>e.name!==""&&e.name!=="__ng")),t(this,A).sort((e,s)=>e.name.length<s.name.length?1:-1)},"#adjust"));h(this,Wt,a(()=>{b(this,A,[]);const i=Array.from(t(this,bt).querySelectorAll("table"));if(!(!i||i.length===0)){for(const e of i)v.log(e),$("[data-bind]",e).each((s,o)=>{const r=o.dataset.bind,n=o.getAttribute("data-type")||"string";r&&t(this,A).push({name:r,type:n})}),["data-expr","background-color","color","tooltip","visible","readonly","enable-button","enable-check","class-expr","icon-color","icon-src"].forEach(s=>{$(`[${s}]`,e).each((o,r)=>{var n=r.getAttribute(s);if(n.indexOf("data.")<0){const l=n.search(/[(]/g);if(l>0)try{n=String(window[n.substring(0,l).trim()])}catch{n=""}}n.split("data.").forEach(l=>{if(l.trim()!=""){const c=l.search(/[^_A-Za-z0-9]/g);let d="";c>=0?d=l.substring(0,c):n.startsWith("data.")&&(d=l.replace("data.","")),d&&t(this,A).push({name:d,type:"string"})}})})});t(this,gt).call(this)}},"#init"));b(this,bt,i),t(this,Wt).call(this)}get(){return t(this,A).map(i=>i.name)}getFields(){return t(this,A)}getType(i){const e=t(this,A).find(s=>s.name===i);return e?e.type:"string"}indexOf(i){return t(this,A).findIndex(e=>e.name===i)}includes(i){return t(this,A).some(e=>e.name===i)}};bt=new WeakMap,A=new WeakMap,gt=new WeakMap,Wt=new WeakMap,a(oe,"ngFields");let Ft=oe;const re=class re{constructor(i){h(this,q);h(this,Ot,a(()=>{t(this,zt).call(this),new ResizeObserver(i=>{for(let e of i)t(this,q).getAttribute("auto-height")==="true"&&t(this,yt).call(this)}).observe(t(this,q))},"#init"));h(this,yt,a(()=>{var c,d;const i=Array.from(t(this,q).shadowRoot.querySelectorAll("nine-table-sheet.active"));if(i.length===0)return;const e=parseInt(t(this,q).getAttribute("max-display-row"),10)||10,s=Math.max(...i.map(f=>f.getRowHeight())),o=(c=t(this,q).shadowRoot.querySelector("nine-table-header"))==null?void 0:c.getBoundingClientRect().height,r=(d=t(this,q).shadowRoot.querySelector("nine-table-sheets-footer"))==null?void 0:d.getBoundingClientRect().height,n=xt.SCROLLBAR_SIZE,l=e*s+o+r+n;t(this,q).style.height=`${l}px`},"#applyAutoHeight"));h(this,zt,a(()=>{const e=Array.from(t(this,q).children).filter(c=>c.tagName==="TABLE"),s=t(this,q).getAttribute("auto-height")==="true",o=e.length,r=e.map((c,d)=>{const u=`<nine-table-sheet class="${d===0?"active":""}" data-index="${d}"></nine-table-sheet>`,g=d<o-1?`<nine-splitter class="h" data-split-index="${d}"></nine-splitter>`:"";return u+g}).join(""),n=e.map((c,d)=>`<div class="nine-tab-item ${d===0?"active":""}" data-index="${d}">Sheet ${d+1}</div>`).join("");t(this,q).shadowRoot.innerHTML=`
|
|
269
269
|
<style>
|
|
270
270
|
:host {
|
|
271
271
|
display: flex;
|
|
@@ -363,5 +363,5 @@
|
|
|
363
363
|
<nine-table-analysis></nine-table-analysis>
|
|
364
364
|
</nine-table-body>
|
|
365
365
|
<nine-table-footer></nine-table-footer>
|
|
366
|
-
`;const l=t(this,q).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((c,d)=>{e[d]&&setTimeout(()=>{c.generate(e[d]),s&&t(this,yt).call(this)})})},"#render"));b(this,q,i),t(this,Ot).call(this)}};q=new WeakMap,Ot=new WeakMap,yt=new WeakMap,zt=new WeakMap,a(re,"LayoutManager");let Kt=re;const le=class le{constructor(i){h(this,pt);h(this,st,-1);w(this,"count",a(()=>t(this,pt).rawRecords.length,"count"));b(this,pt,i)}get at(){return t(this,st)}set at(i){b(this,st,parseInt(i,10)),body&&!body.querySelector(`tbody.bindable tr[data-row="${t(this,st)}"]`)&&setTimeout(()=>{})}};pt=new WeakMap,st=new WeakMap,a(le,"ngRow");let Zt=le;const C=class C{constructor(i,e){h(this,L);h(this,R);h(this,H,[]);h(this,nt,[]);h(this,Dt,0);h(this,B,[]);h(this,Nt,a(()=>{b(this,B,[]);const i=t(this,L).template||[];Array.from(i).forEach(e=>{var s;t(this,B).push(((s=e.getBoundingClientRect)==null?void 0:s.call(e).height)||24)}),(t(this,R).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,mt).call(this)),e.__ng.height=t(this,B).slice()})},"#initialize"));h(this,Z,a(()=>{t(this,L).shadowRoot.querySelectorAll("nine-table-sheet").forEach(i=>{i.invalidate()})},"#invalidate"));w(this,"get",a((i,e)=>{var r;const s=this.getValidData();if(!s||s.length<=0)return;if(i==null)return t(this,ot).call(this,s);if(i<0||i>=s.length)return null;const o=typeof((r=t(this,L).fields)==null?void 0:r.get)=="function"?t(this,L).fields.get():[];if(e!=null){const n=o.indexOf(e);return n>=0?s[i].v[n]:null}return t(this,ot).call(this,s[i])},"get"));w(this,"set",a(i=>{this.clear(),this.add(i,!1),t(this,Z).call(this)},"set"));h(this,mt,a(()=>({rowState:C.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,B).slice(),o:{},c:{},_:[0,0,0,0,C.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,B).slice(),-1,{},{}]}),"#getDefaultMeta"));w(this,"reset",a(()=>{b(this,H,[]),b(this,nt,[]),t(this,Z).call(this)},"reset"));w(this,"clear",a(()=>{var i;t(this,R).rawRecords=[],b(this,H,[]),b(this,nt,[]),(i=t(this,R).viewRecords)!=null&&i.reset&&t(this,R).viewRecords.reset()},"clear"));h(this,Bt,a(i=>{var o;Array.isArray(i)||(i=[i]);const e=typeof((o=t(this,L).fields)==null?void 0:o.get)=="function"?t(this,L).fields.get():Object.keys(i[0]||{}),s=[];return i.forEach(r=>{const n={v:[]};e.forEach(l=>{n.v.push(r[l]!==void 0&&r[l]!==null?r[l]:"")}),s.push(n)}),s},"#json2Array"));h(this,Pt,a(i=>(Array.isArray(i)||(i=[i]),i.forEach(e=>{e.__ng=t(this,mt).call(this),e.__ng.rowid=this.nextId,e.__ng.rowState=C.ROW_STATE.INSERT,e.__ng._[0]=e.__ng.rowid}),i),"#defaultInsert"));w(this,"add",a((i,e=!0)=>{i===void 0&&(i={});const s=t(this,Bt).call(this,i);t(this,R).rawRecords=t(this,R).rawRecords.concat(t(this,Pt).call(this,s)),this.resetRecords();const o=this.count()-1;return e||s.forEach((r,n)=>{const l=t(this,R).rawRecords[o-n];l&&(l.__ng.rowState=C.ROW_STATE.EMPTY)}),t(this,Z).call(this),o},"add"));w(this,"delete",a(i=>{let e=[];Array.isArray(i)?e=i:typeof i>"u"?e=[t(this,R).host.row.at]:e=[parseInt(i,10)],e.sort((s,o)=>o-s).forEach(s=>{if(t(this,H)[s]){const o=t(this,H)[s].__ng.rowid;t(this,H)[s].__ng.rowState===C.ROW_STATE.INSERT?t(this,R).rawRecords=t(this,R).rawRecords.filter(r=>r.__ng.rowid!==o):t(this,R).rawRecords.forEach(r=>{r.__ng.rowid===o&&(r.__ng.deleted=!0,r.__ng.rowState=C.ROW_STATE.DELETE)})}}),this.resetRecords(),t(this,Z).call(this)},"delete"));w(this,"setValue",a((i,e,s)=>{var c;i=parseInt(i,10);const r=(typeof((c=t(this,L).fields)==null?void 0:c.get)=="function"?t(this,L).fields.get():[]).indexOf(e);if(r<0)return;const n=this.getValidData()[i];if(!n)return;const l=n.v[r];l!==s&&n.__ng.rowState!==C.ROW_STATE.INSERT&&(n.__ng.o.hasOwnProperty(e)||(n.__ng.o[e]=l),n.__ng.rowState=C.ROW_STATE.UPDATE),n.v[r]=s},"setValue"));w(this,"resetRecords",a(()=>{b(this,nt,t(this,R).rawRecords.filter(i=>!i.__ng.deleted)),b(this,H,t(this,R).rawRecords.filter(i=>!i.__ng.deleted&&!i.__ng.filtered)),t(this,R).rawRecords.forEach((i,e)=>{i.__ng.rowidx=e}),t(this,H).forEach((i,e)=>{i.__ng.i=e})},"resetRecords"));w(this,"getValidData",a(()=>(t(this,H).length===0&&t(this,R).rawRecords.length>0&&this.resetRecords(),t(this,H)),"getValidData"));h(this,ot,a(i=>{var n;if(!i)return i;const e=!Array.isArray(i),s=e?[i]:i,o=typeof((n=t(this,L).fields)==null?void 0:n.get)=="function"?t(this,L).fields.get():[],r=s.filter(l=>!l.__ng.deleted).map(l=>{const c={};return o.forEach((d,f)=>{c[d]=l.v?l.v[f]:l[d]}),c.__ng=l.__ng,c});return e?r[0]:r},"#conv"));w(this,"count",a(()=>this.getValidData().length,"count"));b(this,L,i),b(this,R,e),t(this,Nt).call(this)}get source(){return t(this,ot).call(this,t(this,R).rawRecords)}set source(i){this.clear(),this.add(i,!1)}get nextId(){return++ue(this,Dt)._}get length(){return t(this,H).length}getRowCount(){return this.length}};L=new WeakMap,R=new WeakMap,H=new WeakMap,nt=new WeakMap,Dt=new WeakMap,B=new WeakMap,Nt=new WeakMap,Z=new WeakMap,mt=new WeakMap,Bt=new WeakMap,Pt=new WeakMap,ot=new WeakMap,a(C,"ngData"),w(C,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Gt=C;const ae=class ae{constructor(i){h(this,G);b(this,G,i),this.row=new Zt(this),this.data=new Gt(t(this,G),this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var e;(e=t(this,G).view)!=null&&e.redraw&&t(this,G).view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{var o,r;const s=parseInt(e,10);if(!(s>=this.data.count()))return(r=(o=this.data.getValidData()[s])==null?void 0:o.__ng)==null?void 0:r.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,s)=>this.data.get(e,s),this.setColumn=(e,s,o)=>{e=parseInt(e,10),this.data.setValue(e,s,o)},this.setDataSource([])}};G=new WeakMap,a(ae,"ngDataManager");let Jt=ae;const ce=class ce extends HTMLElement{constructor(){super();h(this,J);h(this,Yt);this.attachShadow({mode:"open"}),b(this,J,new Jt(this))
|
|
366
|
+
`;const l=t(this,q).shadowRoot.querySelectorAll("nine-table-sheet");l==null||l.forEach((c,d)=>{e[d]&&setTimeout(()=>{c.generate(e[d]),s&&t(this,yt).call(this)})})},"#render"));b(this,q,i),t(this,Ot).call(this)}};q=new WeakMap,Ot=new WeakMap,yt=new WeakMap,zt=new WeakMap,a(re,"LayoutManager");let Kt=re;const le=class le{constructor(i){h(this,pt);h(this,st,-1);w(this,"count",a(()=>t(this,pt).rawRecords.length,"count"));b(this,pt,i)}get at(){return t(this,st)}set at(i){b(this,st,parseInt(i,10)),body&&!body.querySelector(`tbody.bindable tr[data-row="${t(this,st)}"]`)&&setTimeout(()=>{})}};pt=new WeakMap,st=new WeakMap,a(le,"ngRow");let Zt=le;const C=class C{constructor(i,e){h(this,L);h(this,R);h(this,H,[]);h(this,nt,[]);h(this,Dt,0);h(this,B,[]);h(this,Nt,a(()=>{b(this,B,[]);const i=t(this,L).template||[];Array.from(i).forEach(e=>{var s;t(this,B).push(((s=e.getBoundingClientRect)==null?void 0:s.call(e).height)||24)}),(t(this,R).rawRecords||[]).forEach(e=>{e.__ng||(e.__ng=t(this,mt).call(this)),e.__ng.height=t(this,B).slice()})},"#initialize"));h(this,Z,a(()=>{t(this,L).shadowRoot.querySelectorAll("nine-table-sheet").forEach(i=>{i.invalidate()})},"#invalidate"));w(this,"get",a((i,e)=>{var r;const s=this.getValidData();if(!s||s.length<=0)return;if(i==null)return t(this,ot).call(this,s);if(i<0||i>=s.length)return null;const o=typeof((r=t(this,L).fields)==null?void 0:r.get)=="function"?t(this,L).fields.get():[];if(e!=null){const n=o.indexOf(e);return n>=0?s[i].v[n]:null}return t(this,ot).call(this,s[i])},"get"));w(this,"set",a(i=>{this.clear(),this.add(i,!1),t(this,Z).call(this)},"set"));h(this,mt,a(()=>({rowState:C.ROW_STATE.EMPTY,deleted:!1,filtered:!1,height:t(this,B).slice(),o:{},c:{},_:[0,0,0,0,C.ROW_STATE.EMPTY,!1,!1,!0,!1,!0,!0,!1,t(this,B).slice(),-1,{},{}]}),"#getDefaultMeta"));w(this,"reset",a(()=>{b(this,H,[]),b(this,nt,[]),t(this,Z).call(this)},"reset"));w(this,"clear",a(()=>{var i;t(this,R).rawRecords=[],b(this,H,[]),b(this,nt,[]),(i=t(this,R).viewRecords)!=null&&i.reset&&t(this,R).viewRecords.reset()},"clear"));h(this,Bt,a(i=>{var o;Array.isArray(i)||(i=[i]);const e=typeof((o=t(this,L).fields)==null?void 0:o.get)=="function"?t(this,L).fields.get():Object.keys(i[0]||{}),s=[];return i.forEach(r=>{const n={v:[]};e.forEach(l=>{n.v.push(r[l]!==void 0&&r[l]!==null?r[l]:"")}),s.push(n)}),s},"#json2Array"));h(this,Pt,a(i=>(Array.isArray(i)||(i=[i]),i.forEach(e=>{e.__ng=t(this,mt).call(this),e.__ng.rowid=this.nextId,e.__ng.rowState=C.ROW_STATE.INSERT,e.__ng._[0]=e.__ng.rowid}),i),"#defaultInsert"));w(this,"add",a((i,e=!0)=>{i===void 0&&(i={});const s=t(this,Bt).call(this,i);t(this,R).rawRecords=t(this,R).rawRecords.concat(t(this,Pt).call(this,s)),this.resetRecords();const o=this.count()-1;return e||s.forEach((r,n)=>{const l=t(this,R).rawRecords[o-n];l&&(l.__ng.rowState=C.ROW_STATE.EMPTY)}),t(this,Z).call(this),o},"add"));w(this,"delete",a(i=>{let e=[];Array.isArray(i)?e=i:typeof i>"u"?e=[t(this,R).host.row.at]:e=[parseInt(i,10)],e.sort((s,o)=>o-s).forEach(s=>{if(t(this,H)[s]){const o=t(this,H)[s].__ng.rowid;t(this,H)[s].__ng.rowState===C.ROW_STATE.INSERT?t(this,R).rawRecords=t(this,R).rawRecords.filter(r=>r.__ng.rowid!==o):t(this,R).rawRecords.forEach(r=>{r.__ng.rowid===o&&(r.__ng.deleted=!0,r.__ng.rowState=C.ROW_STATE.DELETE)})}}),this.resetRecords(),t(this,Z).call(this)},"delete"));w(this,"setValue",a((i,e,s)=>{var c;i=parseInt(i,10);const r=(typeof((c=t(this,L).fields)==null?void 0:c.get)=="function"?t(this,L).fields.get():[]).indexOf(e);if(r<0)return;const n=this.getValidData()[i];if(!n)return;const l=n.v[r];l!==s&&n.__ng.rowState!==C.ROW_STATE.INSERT&&(n.__ng.o.hasOwnProperty(e)||(n.__ng.o[e]=l),n.__ng.rowState=C.ROW_STATE.UPDATE),n.v[r]=s},"setValue"));w(this,"resetRecords",a(()=>{b(this,nt,t(this,R).rawRecords.filter(i=>!i.__ng.deleted)),b(this,H,t(this,R).rawRecords.filter(i=>!i.__ng.deleted&&!i.__ng.filtered)),t(this,R).rawRecords.forEach((i,e)=>{i.__ng.rowidx=e}),t(this,H).forEach((i,e)=>{i.__ng.i=e})},"resetRecords"));w(this,"getValidData",a(()=>(t(this,H).length===0&&t(this,R).rawRecords.length>0&&this.resetRecords(),t(this,H)),"getValidData"));h(this,ot,a(i=>{var n;if(!i)return i;const e=!Array.isArray(i),s=e?[i]:i,o=typeof((n=t(this,L).fields)==null?void 0:n.get)=="function"?t(this,L).fields.get():[],r=s.filter(l=>!l.__ng.deleted).map(l=>{const c={};return o.forEach((d,f)=>{c[d]=l.v?l.v[f]:l[d]}),c.__ng=l.__ng,c});return e?r[0]:r},"#conv"));w(this,"count",a(()=>this.getValidData().length,"count"));b(this,L,i),b(this,R,e),t(this,Nt).call(this)}get source(){return t(this,ot).call(this,t(this,R).rawRecords)}set source(i){this.clear(),this.add(i,!1)}get nextId(){return++ue(this,Dt)._}get length(){return t(this,H).length}getRowCount(){return this.length}};L=new WeakMap,R=new WeakMap,H=new WeakMap,nt=new WeakMap,Dt=new WeakMap,B=new WeakMap,Nt=new WeakMap,Z=new WeakMap,mt=new WeakMap,Bt=new WeakMap,Pt=new WeakMap,ot=new WeakMap,a(C,"ngData"),w(C,"ROW_STATE",{EMPTY:"EMPTY",NORMAL:"NORMAL",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"});let Gt=C;const ae=class ae{constructor(i){h(this,G);b(this,G,i),this.row=new Zt(this),this.data=new Gt(t(this,G),this),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.pageCnt=25,this.viewRecords.reset=()=>{var e;(e=t(this,G).view)!=null&&e.redraw&&t(this,G).view.redraw()},this.setDataSource=e=>{this.data&&this.data.reset(),this.rawRecords=[],this.viewRecords=[],this.delRecords=[],this.data.set(e||[])},this.getRowState=e=>{var o,r;const s=parseInt(e,10);if(!(s>=this.data.count()))return(r=(o=this.data.getValidData()[s])==null?void 0:o.__ng)==null?void 0:r.rowState},this.getRowPosition=()=>this.row.at,this.setRowPosition=e=>{this.row.at=e},this.scrollTo_V1=e=>(e<0&&(e=0),e>=this.rawRecords.length&&(e=this.rawRecords.length-1),this.viewRecords.rawIndex=e,this.viewRecords.reset&&this.viewRecords.reset(),!(e<=0||e>=this.rawRecords.length-1)),this.getColumn=(e,s)=>this.data.get(e,s),this.setColumn=(e,s,o)=>{e=parseInt(e,10),this.data.setValue(e,s,o)},this.setDataSource([])}};G=new WeakMap,a(ae,"ngDataManager");let Jt=ae;const ce=class ce extends HTMLElement{constructor(){super();h(this,J);h(this,Yt);this.fields=new Ft(this),this.attachShadow({mode:"open"}),b(this,J,new Jt(this))}connectedCallback(){b(this,Yt,new Kt(this)),v.log("NineTable connected."),this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{target:this}}))}disconnectedCallback(){v.log("NineTable disconnected.")}get data(){return t(this,J).data}get row(){return t(this,J).row}get dataManager(){return t(this,J)}};J=new WeakMap,Yt=new WeakMap,a(ce,"NineTable");let Qt=ce;customElements.get("nine-table")||customElements.define("nine-table",Qt)});
|
|
367
367
|
//# sourceMappingURL=nine-table.umd.js.map
|