@ninebone/grid 0.0.4 → 0.0.5

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.
@@ -717,10 +717,10 @@ Do you want to save it?`,"SAVE",{class:"rgb","true-text":"Yes","false-text":"No"
717
717
  <div></div>
718
718
  <span class="text">${this.displayValue}</span>
719
719
  </div>
720
- `,super.connectedCallback(),tt(this,$a,this.shadowRoot.querySelector("div.ng-pad")),tt(this,La,this.shadowRoot.querySelector("span"))}get prevLevel(){var t=parseInt(this.closest("tr").sectionRowIndex/this.owner.template.length);if(!this.owner.dataManager.viewRecords)return-1;if(t!=0){var l=this.owner.data.getNF(t-1);return l[this.cell.dataset.bind]}else for(var c=parseInt(this.cell.dataset.row)-1;c>=0;c--){var o=this.owner.data.get(c);if(!o.__ng._[H.ROW.EXPAND])return o[this.cell.dataset.bind]}return-1}}$a=new WeakMap,La=new WeakMap,Pa=new WeakMap,yi=new WeakSet,Ol=function(){return this.data.__ng._[H.ROW.EXPAND]},sc=new WeakMap,ic=new WeakMap,nc=new WeakMap,oc=new WeakMap,uu=new WeakMap,Da=new WeakMap,Ba=new WeakMap,ac=new WeakMap,lc=new WeakMap,hc=new WeakMap,customElements.get("ng-tree-item")||customElements.define("ng-tree-item",ef);class rf{constructor(C){Y(this,yt);Y(this,Ge);Y(this,wr);Y(this,vi);Y(this,wi,[]);it(this,"init",()=>{tt(this,wr,{body:$(".ng-container-body",f(this,yt).body).height()||0,thead:$(".ng-container-body thead",f(this,yt).body).height()||0,tfoot:$(".ng-container-body tfoot",f(this,yt).body).height()||0}),!f(this,vi)&&($(".ng-container tbody.bindable tr.nodata",f(this,yt).body).height(f(this,wr).body),tt(this,vi,!0))});it(this,"redraw",()=>{f(this,yt).touchEvent.scrollTop(),this.init(),f(this,yt).dataManager&&(tt(this,Ge,f(this,yt).dataManager.viewRecords.rawIndex||0),f(this,cc).call(this),f(this,kn).call(this),f(this,yt).body.querySelector("ng-vscrollbar").refresh())});it(this,"redrawV2",()=>{f(this,yt).touchEvent.scrollTop(),this.init(),tt(this,Ge,f(this,yt).dataManager.viewRecords.rawIndex||0),f(this,uc).call(this),f(this,kn).call(this),f(this,yt).body.querySelector("ng-vscrollbar").refreshV2()});it(this,"redrawV3",()=>{this.init(),tt(this,Ge,f(this,yt).dataManager.viewRecords.rawIndex||0),f(this,kn).call(this)});Y(this,Fa,()=>{var C=0;return $(".ng-container-body tbody.fixed tr",f(this,yt).body).each((t,l)=>{l.data&&l.data.__ng&&(C+=f(this,yt).matrix.getHeight(l.data.__ng.height[parseInt(t%f(this,yt).template.length)]))}),C});Y(this,qa,()=>{var C=f(this,Fa).call(this);const t=parseInt(f(this,Ge)*f(this,yt).template.length);return $(".ng-container-body tbody.bindable tr:not(.nodata)",f(this,yt).body).each((l,c)=>{C+=f(this,yt).matrix.getHeight(t+l)}),C});Y(this,Ha,()=>{const C=parseInt(f(this,yt).getAttribute("display-row-count"));if(f(this,yt).closest("dialog")&&H.j.querySelectorAll(f(this,yt)).hasClass("simple"))return 1;if([H.PAGINGTYPE.CLIENT,H.PAGINGTYPE.SERVER].includes(f(this,yt).paging.type))return f(this,yt).paging.linesPerPage;if(!isNaN(C))return f(this,Ge)+C>f(this,yt).data.count()&&(tt(this,Ge,C>=f(this,yt).data.count()?0:f(this,yt).data.count()-C),f(this,yt).dataManager.viewRecords.rawIndex=f(this,Ge)),C;const t=f(this,wr).body-f(this,wr).thead-f(this,wr).tfoot-f(this,Fa).call(this);for(var l=0,c=0;c<t;)c+=this.getRowHeight(f(this,Ge)+l++);if(f(this,Ge)+l>f(this,yt).data.count()){l=0,c=0;for(var o=f(this,yt).data.count()-1;o>=0&&c<t;o--)c+=this.getRowHeight(o),l++;c>t&&l--,tt(this,Ge,f(this,yt).data.count()-l),f(this,yt).dataManager.viewRecords.rawIndex=f(this,Ge)}return l});Y(this,za,()=>{var C=f(this,Ha).call(this),t=$(".ng-container-body tbody.bindable tr",f(this,yt).body).not("tr.nodata").length/(f(this,yt).template.length||1);const l=f(this,yt).template.clone(),c=l.clone(),o=l.clone();l.find("th,td").not("[fixed=left]").remove(),c.find("th,td").not("[fixed=right]").remove(),o.find("th[fixed=left],td[fixed=left],th[fixed=right],td[fixed=right]").remove();const r=$("tr.nodata",f(this,yt).body.querySelector(".ng-container-left")),n=$("tr.nodata",f(this,yt).body.querySelector(".ng-container-right")),s=$("tr.nodata",f(this,yt).body.querySelector(".ng-container-body"));for(var e=t;e<C;e++)l.each((u,a)=>{r.before(a.outerHTML)}),c.each((u,a)=>{n.before(a.outerHTML)}),o.each((u,a)=>{s.before(a.outerHTML)});return;var i;if(i.length>0)var t});Y(this,Ua,()=>{var C=Math.min(f(this,Ha).call(this),f(this,yt).data.count());$(".ng-container tbody.bindable tr:not(.nodata)",f(this,yt).body).each((t,l)=>{parseInt(l.sectionRowIndex/f(this,yt).template.length)>=C&&$(l).remove()}),f(this,yt).body.querySelectorAll(".ng-container tbody.bindable tr:not(.nodata)").forEach(t=>{f(this,Ge)+parseInt(t.sectionRowIndex/f(this,yt).template.length)>=f(this,yt).data.count()&&$(t).remove()})});Y(this,cc,()=>{f(this,za).call(this),f(this,Ua).call(this);var C=f(this,wr).body-f(this,wr).thead-f(this,wr).tfoot-f(this,qa).call(this);if(f(this,yt).getAttribute("display-row-count")&&f(this,yt).data.count()>=Number(f(this,yt).getAttribute("display-row-count")||0)&&(C=0),$(".ng-container tbody.bindable tr.nodata",f(this,yt).body).height(C),f(this,yt).closest("dialog")&&H.j.querySelectorAll(f(this,yt)).hasClass("simple")){$("tr.nodata",f(this,yt).body).height(0);var C=47;$(".ng-container-body tbody.bindable tr",f(this,yt).body).not(".nodata").each((l,c)=>{C+=$(c).height()}),$(f(this,yt).closest("dialog")).height(C)}});Y(this,uc,()=>{f(this,za).call(this),f(this,Ua).call(this),f(this,yt).isLastPage});Y(this,dc,()=>{for(const C of f(this,wi))clearTimeout(C);tt(this,wi,[]),f(this,wi).push(setTimeout(()=>{tt(this,vi,!1);var C=$(".ng-container-body tbody.bindable tr",f(this,yt).body).not(".nodata"),t=$(".ng-container-left tbody.bindable tr",f(this,yt).body).not(".nodata"),l=$(".ng-container-right tbody.bindable tr",f(this,yt).body).not(".nodata");if(C.length>0){var c=parseInt(C[0].dataset.row*f(this,yt).template.length);C.each((r,n)=>{var s=f(this,yt).matrix.getHeight(c+r);$("canvas.chart",n).css({height:s-4}),$("canvas.chart",t.eq(r)).css({height:s-4}),$("canvas.chart",l.eq(r)).css({height:s-4}),$(n).css({height:s}).height(s),t.eq(r).css({height:s}).height(s),l.eq(r).css({height:s}).height(s)})}f(this,yt).cell.refresh(),$("ng-row-indicator",f(this,yt).body).each((r,n)=>{n.refresh()});var o=f(this,wr).body-f(this,wr).thead-f(this,wr).tfoot-f(this,qa).call(this);f(this,yt).getAttribute("display-row-count")&&f(this,yt).data.count()>=Number(f(this,yt).getAttribute("display-row-count")||0)&&(o=0),$(".ng-container tbody.bindable tr.nodata",f(this,yt).body).height(o),f(this,yt).refreshBindRows(),f(this,yt).refreshData(),f(this,yt).paging.totalCount=f(this,yt).data.countNF(),f(this,yt).body.querySelector("ng-vscrollbar").refresh(),H.j.querySelectorAll(".ng-table tbody tr",f(this,yt).body).removeClass("hover"),H.j.querySelectorAll(f(this,yt)).removeClass("loading"),H.j.querySelectorAll("ng-filter-panel").removeClass("loading")},300)),f(this,wi).push(setTimeout(()=>{f(this,yt).refreshDataV2()}))});Y(this,kn,()=>{var C=[];f(this,yt).body.querySelectorAll(".ng-container-body tbody.bindable tr:not(.nodata)").forEach(t=>{C.push(f(this,Ge)+parseInt(t.sectionRowIndex/f(this,yt).template.length))}),C=[...new Set(C)],f(this,yt).body.querySelectorAll(".ng-container tbody.bindable tr:not(.nodata)").forEach(t=>{const l=parseInt(t.sectionRowIndex/f(this,yt).template.length);t.dataset.row=C[l],t.dataset.matrixRow=parseInt(C[l]*f(this,yt).template.length)+parseInt(t.sectionRowIndex%f(this,yt).template.length);for(const c of t.cells)c.dataset.row=t.dataset.row,c.dataset.matrixRow=t.dataset.matrixRow}),C.forEach(t=>{const l=f(this,yt).data.get(t);f(this,yt).body.querySelectorAll(`.ng-container tbody.bindable tr[data-row="${t}"]`).forEach(c=>{c.data=l})}),tt(this,Ge,parseInt(f(this,yt).body.querySelector(".ng-container-body tbody.bindable tr:first-of-type").getAttribute("data-row"))),f(this,yt).dataManager.viewRecords.rawIndex=f(this,Ge),f(this,dc).call(this),f(this,yt).isFirstPage=f(this,Ge)==0,f(this,yt).isLastPage=C[C.length-1]==f(this,yt).data.count()-1});it(this,"getVisibleFirstRow",()=>{var C=f(this,yt).body.querySelector(".ng-container-body tbody.bindable tr:first-child");return parseInt(C.dataset.row)});it(this,"getVisibleLastRow",()=>{var C=f(this,yt).body.querySelectorAll(".ng-container-body tbody.bindable tr:not(.nodata)");return C.length>0?parseInt(C[C.length-1].dataset.row):-1});it(this,"getRowHeight",C=>{let t=0;for(var l=0;l<f(this,yt).template.length;l++)t+=f(this,yt).matrix.getHeight(parseInt(C*f(this,yt).template.length+l));return t});it(this,"getTranslateY",()=>{const C=f(this,yt).body.querySelector(".ng-container-body tbody.bindable");return!C||!C.style||!C.style.transform?0:parseFloat(C.style.transform.replace("translateY(","").replace(")",""))});it(this,"getTotalSpace",()=>$(f(this,yt).body.querySelector(".ng-container-body")).height()-($(f(this,yt).body.querySelector(".ng-container-body thead")).height()||0)-($(f(this,yt).body.querySelector(".ng-container-body tfoot")).height()||0)-($(f(this,yt).body.querySelector(".ng-container-body tbody.fixed")).height()||0));it(this,"fitPage",()=>{const C=this.getVisibleLastRow(),t=this.getTotalSpace();if(C==f(this,yt).data.count()-1){for(var l=0,c=C;c>=0;c--)if(l+=this.getRowHeight(c),l>t){f(this,yt).scrollTo(c+1);break}}});it(this,"selectArea",(C,t,l,c)=>{const o=f(this,Us).call(this,C),r=f(this,Us).call(this,l),n=f(this,Vs).call(this,t),s=f(this,Vs).call(this,c),e=parseInt(o*f(this,yt).template.length),i=parseInt(r*f(this,yt).template.length)+f(this,yt).template.length-1;f(this,yt).row.at=o,o>=0&&r>=0?f(this,yt).selection.selectArea(e,n,i,s):this.clearSelection()});it(this,"selectRow",(C,t)=>{const l=f(this,Us).call(this,C),c=H.isNull(t)?l:f(this,Us).call(this,t),o=parseInt(l*f(this,yt).template.length),r=parseInt(c*f(this,yt).template.length)+f(this,yt).template.length-1;f(this,yt).row.at=l,l>=0&&c>=0?f(this,yt).selection.selectArea(o,f(this,yt).firstCol,r,f(this,yt).lastCol):this.clearSelection()});it(this,"selectCol",(C,t)=>{const l=f(this,Vs).call(this,C),c=H.isNull(t)?l:f(this,Vs).call(this,t),o=0,r=parseInt(f(this,yt).data.count()*f(this,yt).template.length-1);l>=0&&c>=0?f(this,yt).selection.selectArea(o,l,r,c):this.clearSelection()});it(this,"selectCell",(C,t,l)=>{const c=f(this,Us).call(this,C),o=f(this,Vs).call(this,t),r=parseInt(c*f(this,yt).template.length)+H.nvl(l,0);f(this,yt).row.at=c,c>=0?f(this,yt).selection.selectArea(r,o,r,o):this.clearSelection()});Y(this,Us,C=>{if(typeof C=="number")return C;if(typeof C=="function")return f(this,yt).data.findIndex(C);throw`invalid ${C}`});Y(this,Vs,C=>{if(typeof C=="number")return C;if(typeof C=="string"&&f(this,yt).fields.includes(C))return parseInt($(`[data-bind="${C}"]`,f(this,yt).template)[0].dataset.col);throw`invalid ${C}`});it(this,"moveTo",C=>{f(this,yt).scrollTo(C)});tt(this,yt,C),tt(this,vi,!1),this.init()}}yt=new WeakMap,Ge=new WeakMap,wr=new WeakMap,vi=new WeakMap,wi=new WeakMap,Fa=new WeakMap,qa=new WeakMap,Ha=new WeakMap,za=new WeakMap,Ua=new WeakMap,cc=new WeakMap,uc=new WeakMap,dc=new WeakMap,kn=new WeakMap,Us=new WeakMap,Vs=new WeakMap;class sf{constructor(C){Y(this,Je);Y(this,Ws);it(this,"initialize",()=>{tt(this,Ws,!1),f(this,Je).data.clearFilter()});it(this,"isFiltering",()=>f(this,Ws));it(this,"on",C=>{tt(this,Ws,!0);const t=f(this,fc).call(this);f(this,Je).body.querySelectorAll(".ng-table thead th, .ng-table thead td").forEach(l=>{var o,r;const c=(o=l.closest("tr"))==null?void 0:o.sectionRowIndex;if(c!==void 0&&c+l.rowSpan-1===t){const n=Array.from(f(this,Je).activeTmpl.querySelectorAll(`[data-col="${l.dataset.col}"]`)).map(s=>s.dataset.bind?{colnm:s.dataset.bind,data:[]}:null).filter(Boolean);if(n.length>0){(r=l.querySelector("ng-filter-button"))==null||r.remove();const s=document.createElement("ng-filter-button");l.appendChild(s),s.filterOptions=n}}})});it(this,"off",()=>{tt(this,Ws,!1),f(this,Je).body.querySelectorAll(".ng-table ng-filter-button").forEach(C=>{C.remove()})});it(this,"set",C=>{this.on();let t=Array.isArray(C)?Object.fromEntries(Object.keys(C[0]).map(l=>[l,[...new Set(C.map(c=>c[l]))]])):C;f(this,Je).data.clearFilter(),Object.entries(t).forEach(([l,c])=>{const o=f(this,Je).fields.indexOf(l);f(this,Je).data.getValidData().some(r=>typeof r.v[o]=="number")&&(c=c.map(Number)),f(this,Je).data.getValidData().filter(r=>c.nineBinarySearch(r.v[o]||"")<0).forEach(r=>{r.__ng.filtered=!0})}),f(this,Je).data.refreshFilter(),f(this,Je).shadowRoot.querySelectorAll("ng-filter-button").forEach(l=>{l.filterOptions.forEach(c=>{c.data=[]})}),Object.entries(t).forEach(([l,c])=>{f(this,Je).shadowRoot.querySelectorAll("ng-filter-button").forEach(o=>{let r=o.filterOptions;r.forEach(n=>{n.colnm===l&&(n.data=c)}),o.filterOptions=r})}),f(this,Je).scrollTo_V1(0),f(this,Je).paging.reset()});Y(this,fc,(C="thead")=>[...f(this,Je).body.querySelectorAll(`.ng-table ${C}`)].reduce((t,l)=>Math.max(l.rows.length-1,t),0));tt(this,Je,C),tt(this,Ws,!1);const t=document.createElement("ng-filter-panel");t.style.display="none",f(this,Je).shadowRoot.appendChild(t)}}Je=new WeakMap,Ws=new WeakMap,fc=new WeakMap;class nf extends HTMLElement{constructor(){super();Y(this,Va);Y(this,Cn);Y(this,Wa,t=>{var o;t.preventDefault(),t.stopPropagation();const l=f(this,Va).shadowRoot.querySelector("ng-filter-panel"),c=(o=this.closest("th,td"))==null?void 0:o.dataset.col;l.col===c?l.close():l.open(this)})}connectedCallback(){tt(this,Va,this.getRootNode().host),this.removeEventListener("click",f(this,Wa)),this.addEventListener("click",f(this,Wa))}get filterOptions(){return f(this,Cn)}set filterOptions(t){tt(this,Cn,t),this.classList.toggle("filtered",f(this,Cn).some(l=>l.data.length>0))}}Va=new WeakMap,Cn=new WeakMap,Wa=new WeakMap;class of extends HTMLElement{constructor(){super();Y(this,Mr);Y(this,Xa);Y(this,Ya);Y(this,pc,t=>{const l=this.shadowRoot.querySelector("nine-grid");this.classList.add("loading"),setTimeout(()=>{const[c,o,r,n]=["LVL","CHK","COLNM","DATA"].map(u=>l.fields.indexOf(u)),s=l.data.getValidDataNF().filter(u=>u.v[c]===2&&u.v[o]==="Y"),e=s.length>0?[...new Set(s.map(u=>u.v[r]))].map(u=>({colnm:u,data:[...new Set(l.data.getValidData().filter(a=>a.v[o]==="Y"&&a.v[r]===u).map(a=>a.v[n]||""))].sort()})):[];f(this,Xa).filterOptions=e;const i=Object.fromEntries([...f(this,Mr).body.querySelectorAll("ng-filter-button")].flatMap(u=>u.filterOptions).filter(u=>u.data.length>0).map(u=>[u.colnm,u.data]));f(this,Mr).filtering.set(i),this.classList.remove("loading"),this.style.display="none"})});Y(this,mc,t=>{this.style.display="none"});Y(this,gc,t=>{const l=this.shadowRoot.querySelector("nine-grid"),c=l.fields.indexOf("CHK"),o=t.target.checked;l.data.getValidData().forEach(r=>{r.v[c]=o?"Y":"N"}),l.refreshData()});Y(this,bc,t=>{const l=this.shadowRoot.querySelector("nine-grid");l.classList.add("loading");const c=l.dataManager.rawRecords;c.forEach(s=>{s.__ng.filtered=!1});const o=t.target.value.toLowerCase(),[r,n]=["LVL","DATA"].map(s=>l.fields.indexOf(s));c.forEach(s=>{s.__ng.filtered=s.v[r]===2&&!String(s.v[n]||"").toLowerCase().includes(o)}),l.data.resetRecords(),clearTimeout(f(this,Ya)),tt(this,Ya,setTimeout(()=>{l.dataManager.viewRecords.reset(),l.dataManager.viewRecords.touch()},200))});it(this,"close",()=>{this.col=null,this.style.display="none"});it(this,"open",t=>{const l=t.closest("th,td"),{left:c}=t.getBoundingClientRect(),{left:o,width:r,top:n}=f(this,Mr).getBoundingClientRect(),{top:s,height:e}=l.getBoundingClientRect(),{width:i}=this.getBoundingClientRect();let u=Math.max(0,c-o);u=Math.min(u,r-i-5);const a=s+e-n;Object.assign(this.style,{left:`${u}px`,top:`${a}px`,display:"flex"}),this.classList.add("loading"),this.shadowRoot.querySelector("input[type=text]").value="",setTimeout(()=>{const h=f(this,Mr).data.getValidDataNF(),p=l.dataset.col;this.col=p,tt(this,Xa,t);const m=t.filterOptions.map((g,S)=>{const E=`<span class="group">${l.textContent}${t.filterOptions.length>1?` #${S+1} (${g.colnm})`:""}</span>`,I=f(this,Mr).activeTmpl.querySelector(`[data-col="${p}"][data-bind="${g.colnm}"]`),D=I==null?void 0:I.getAttribute("data-expr"),z=D?f(this,Mr).exprFunction(D):null,P=h.map(B=>{const F=f(this,Mr).fields.indexOf(g.colnm);return D?{v:B.v[F],v2:z(f(this,Mr).data.conv(B),B.__ng.rowidx,f(this,Mr).data)}:{v:B.v[F],v2:B.v[F]}});return[{LVL:1,CHK:"N",DATA2:E},...[...new Set(P.map(JSON.stringify))].map(JSON.parse).sort((B,F)=>(B.v2||"")>(F.v2||"")?1:(B.v2||"")<(F.v2||"")?-1:0).map(B=>({LVL:2,DATA:B.v,DATA2:B.v2||` <span class="empty">(empty)</span> ${B.v}`,COLNM:g.colnm,CHK:g.data.length===0||g.data.nineBinarySearch(B.v||"")>=0?"Y":"N"}))]}).flat(),d=this.shadowRoot.querySelector("nine-grid");d.fields.add(["DATA","DATA2","COLNM"]),d.data.set(m);const b=this.shadowRoot.querySelector("input[type=checkbox]");b.checked=d.data.getValidData().every(g=>!(g.LVL===2&&g.CHK!=="Y")),this.shadowRoot.querySelector("input").focus(),this.classList.remove("loading")})});this.attachShadow({mode:"open"})}connectedCallback(){tt(this,Mr,this.getRootNode().host);const t=this.getRootNode().host.closest("nine-grid").getAttribute("css-path")||"";this.shadowRoot.innerHTML=`
720
+ `,super.connectedCallback(),tt(this,$a,this.shadowRoot.querySelector("div.ng-pad")),tt(this,La,this.shadowRoot.querySelector("span"))}get prevLevel(){var t=parseInt(this.closest("tr").sectionRowIndex/this.owner.template.length);if(!this.owner.dataManager.viewRecords)return-1;if(t!=0){var l=this.owner.data.getNF(t-1);return l[this.cell.dataset.bind]}else for(var c=parseInt(this.cell.dataset.row)-1;c>=0;c--){var o=this.owner.data.get(c);if(!o.__ng._[H.ROW.EXPAND])return o[this.cell.dataset.bind]}return-1}}$a=new WeakMap,La=new WeakMap,Pa=new WeakMap,yi=new WeakSet,Ol=function(){return this.data.__ng._[H.ROW.EXPAND]},sc=new WeakMap,ic=new WeakMap,nc=new WeakMap,oc=new WeakMap,uu=new WeakMap,Da=new WeakMap,Ba=new WeakMap,ac=new WeakMap,lc=new WeakMap,hc=new WeakMap,customElements.get("ng-tree-item")||customElements.define("ng-tree-item",ef);class rf{constructor(C){Y(this,yt);Y(this,Ge);Y(this,wr);Y(this,vi);Y(this,wi,[]);it(this,"init",()=>{tt(this,wr,{body:$(".ng-container-body",f(this,yt).body).height()||0,thead:$(".ng-container-body thead",f(this,yt).body).height()||0,tfoot:$(".ng-container-body tfoot",f(this,yt).body).height()||0}),!f(this,vi)&&($(".ng-container tbody.bindable tr.nodata",f(this,yt).body).height(f(this,wr).body),tt(this,vi,!0))});it(this,"redraw",()=>{f(this,yt).touchEvent.scrollTop(),this.init(),f(this,yt).dataManager&&(tt(this,Ge,f(this,yt).dataManager.viewRecords.rawIndex||0),f(this,cc).call(this),f(this,kn).call(this),f(this,yt).body.querySelector("ng-vscrollbar").refresh())});it(this,"redrawV2",()=>{f(this,yt).touchEvent.scrollTop(),this.init(),tt(this,Ge,f(this,yt).dataManager.viewRecords.rawIndex||0),f(this,uc).call(this),f(this,kn).call(this),f(this,yt).body.querySelector("ng-vscrollbar").refreshV2()});it(this,"redrawV3",()=>{this.init(),tt(this,Ge,f(this,yt).dataManager.viewRecords.rawIndex||0),f(this,kn).call(this)});Y(this,Fa,()=>{var C=0;return $(".ng-container-body tbody.fixed tr",f(this,yt).body).each((t,l)=>{l.data&&l.data.__ng&&(C+=f(this,yt).matrix.getHeight(l.data.__ng.height[parseInt(t%f(this,yt).template.length)]))}),C});Y(this,qa,()=>{var C=f(this,Fa).call(this);const t=parseInt(f(this,Ge)*f(this,yt).template.length);return $(".ng-container-body tbody.bindable tr:not(.nodata)",f(this,yt).body).each((l,c)=>{C+=f(this,yt).matrix.getHeight(t+l)}),C});Y(this,Ha,()=>{const C=parseInt(f(this,yt).getAttribute("display-row-count"));if(f(this,yt).closest("dialog")&&H.j.querySelectorAll(f(this,yt)).hasClass("simple"))return 1;if([H.PAGINGTYPE.CLIENT,H.PAGINGTYPE.SERVER].includes(f(this,yt).paging.type))return f(this,yt).paging.linesPerPage;if(!isNaN(C))return f(this,Ge)+C>f(this,yt).data.count()&&(tt(this,Ge,C>=f(this,yt).data.count()?0:f(this,yt).data.count()-C),f(this,yt).dataManager.viewRecords.rawIndex=f(this,Ge)),C;const t=f(this,wr).body-f(this,wr).thead-f(this,wr).tfoot-f(this,Fa).call(this);for(var l=0,c=0;c<t;)c+=this.getRowHeight(f(this,Ge)+l++);if(f(this,Ge)+l>f(this,yt).data.count()){l=0,c=0;for(var o=f(this,yt).data.count()-1;o>=0&&c<t;o--)c+=this.getRowHeight(o),l++;c>t&&l--,tt(this,Ge,f(this,yt).data.count()-l),f(this,yt).dataManager.viewRecords.rawIndex=f(this,Ge)}return l});Y(this,za,()=>{var C=f(this,Ha).call(this),t=$(".ng-container-body tbody.bindable tr",f(this,yt).body).not("tr.nodata").length/(f(this,yt).template.length||1);const l=f(this,yt).template.clone(),c=l.clone(),o=l.clone();l.find("th,td").not("[fixed=left]").remove(),c.find("th,td").not("[fixed=right]").remove(),o.find("th[fixed=left],td[fixed=left],th[fixed=right],td[fixed=right]").remove();const r=$("tr.nodata",f(this,yt).body.querySelector(".ng-container-left")),n=$("tr.nodata",f(this,yt).body.querySelector(".ng-container-right")),s=$("tr.nodata",f(this,yt).body.querySelector(".ng-container-body"));for(var e=t;e<C;e++)l.each((u,a)=>{r.before(a.outerHTML)}),c.each((u,a)=>{n.before(a.outerHTML)}),o.each((u,a)=>{s.before(a.outerHTML)});return;var i;if(i.length>0)var t});Y(this,Ua,()=>{var C=Math.min(f(this,Ha).call(this),f(this,yt).data.count());$(".ng-container tbody.bindable tr:not(.nodata)",f(this,yt).body).each((t,l)=>{parseInt(l.sectionRowIndex/f(this,yt).template.length)>=C&&$(l).remove()}),f(this,yt).body.querySelectorAll(".ng-container tbody.bindable tr:not(.nodata)").forEach(t=>{f(this,Ge)+parseInt(t.sectionRowIndex/f(this,yt).template.length)>=f(this,yt).data.count()&&$(t).remove()})});Y(this,cc,()=>{f(this,za).call(this),f(this,Ua).call(this);var C=f(this,wr).body-f(this,wr).thead-f(this,wr).tfoot-f(this,qa).call(this);if(f(this,yt).getAttribute("display-row-count")&&f(this,yt).data.count()>=Number(f(this,yt).getAttribute("display-row-count")||0)&&(C=0),$(".ng-container tbody.bindable tr.nodata",f(this,yt).body).height(C),f(this,yt).closest("dialog")&&H.j.querySelectorAll(f(this,yt)).hasClass("simple")){$("tr.nodata",f(this,yt).body).height(0);var C=47;$(".ng-container-body tbody.bindable tr",f(this,yt).body).not(".nodata").each((l,c)=>{C+=$(c).height()}),$(f(this,yt).closest("dialog")).height(C)}});Y(this,uc,()=>{f(this,za).call(this),f(this,Ua).call(this),f(this,yt).isLastPage});Y(this,dc,()=>{for(const C of f(this,wi))clearTimeout(C);tt(this,wi,[]),f(this,wi).push(setTimeout(()=>{tt(this,vi,!1);var C=$(".ng-container-body tbody.bindable tr",f(this,yt).body).not(".nodata"),t=$(".ng-container-left tbody.bindable tr",f(this,yt).body).not(".nodata"),l=$(".ng-container-right tbody.bindable tr",f(this,yt).body).not(".nodata");if(C.length>0){var c=parseInt(C[0].dataset.row*f(this,yt).template.length);C.each((r,n)=>{var s=f(this,yt).matrix.getHeight(c+r);$("canvas.chart",n).css({height:s-4}),$("canvas.chart",t.eq(r)).css({height:s-4}),$("canvas.chart",l.eq(r)).css({height:s-4}),$(n).css({height:s}).height(s),t.eq(r).css({height:s}).height(s),l.eq(r).css({height:s}).height(s)})}f(this,yt).cell.refresh(),$("ng-row-indicator",f(this,yt).body).each((r,n)=>{n.refresh()});var o=f(this,wr).body-f(this,wr).thead-f(this,wr).tfoot-f(this,qa).call(this);f(this,yt).getAttribute("display-row-count")&&f(this,yt).data.count()>=Number(f(this,yt).getAttribute("display-row-count")||0)&&(o=0),$(".ng-container tbody.bindable tr.nodata",f(this,yt).body).height(o),f(this,yt).refreshBindRows(),f(this,yt).refreshData(),f(this,yt).paging.totalCount=f(this,yt).data.countNF(),f(this,yt).body.querySelector("ng-vscrollbar").refresh(),H.j.querySelectorAll(".ng-table tbody tr",f(this,yt).body).removeClass("hover"),H.j.querySelectorAll(f(this,yt)).removeClass("loading"),H.j.querySelectorAll("ng-filter-panel").removeClass("loading")},300)),f(this,wi).push(setTimeout(()=>{f(this,yt).refreshDataV2()}))});Y(this,kn,()=>{var C=[];f(this,yt).body.querySelectorAll(".ng-container-body tbody.bindable tr:not(.nodata)").forEach(t=>{C.push(f(this,Ge)+parseInt(t.sectionRowIndex/f(this,yt).template.length))}),C=[...new Set(C)],f(this,yt).body.querySelectorAll(".ng-container tbody.bindable tr:not(.nodata)").forEach(t=>{const l=parseInt(t.sectionRowIndex/f(this,yt).template.length);t.dataset.row=C[l],t.dataset.matrixRow=parseInt(C[l]*f(this,yt).template.length)+parseInt(t.sectionRowIndex%f(this,yt).template.length);for(const c of t.cells)c.dataset.row=t.dataset.row,c.dataset.matrixRow=t.dataset.matrixRow}),C.forEach(t=>{const l=f(this,yt).data.get(t);f(this,yt).body.querySelectorAll(`.ng-container tbody.bindable tr[data-row="${t}"]`).forEach(c=>{c.data=l})}),tt(this,Ge,parseInt(f(this,yt).body.querySelector(".ng-container-body tbody.bindable tr:first-of-type").getAttribute("data-row"))),f(this,yt).dataManager.viewRecords.rawIndex=f(this,Ge),f(this,dc).call(this),f(this,yt).isFirstPage=f(this,Ge)==0,f(this,yt).isLastPage=C[C.length-1]==f(this,yt).data.count()-1});it(this,"getVisibleFirstRow",()=>{var C=f(this,yt).body.querySelector(".ng-container-body tbody.bindable tr:first-child");return parseInt(C.dataset.row)});it(this,"getVisibleLastRow",()=>{var C=f(this,yt).body.querySelectorAll(".ng-container-body tbody.bindable tr:not(.nodata)");return C.length>0?parseInt(C[C.length-1].dataset.row):-1});it(this,"getRowHeight",C=>{let t=0;for(var l=0;l<f(this,yt).template.length;l++)t+=f(this,yt).matrix.getHeight(parseInt(C*f(this,yt).template.length+l));return t});it(this,"getTranslateY",()=>{const C=f(this,yt).body.querySelector(".ng-container-body tbody.bindable");return!C||!C.style||!C.style.transform?0:parseFloat(C.style.transform.replace("translateY(","").replace(")",""))});it(this,"getTotalSpace",()=>$(f(this,yt).body.querySelector(".ng-container-body")).height()-($(f(this,yt).body.querySelector(".ng-container-body thead")).height()||0)-($(f(this,yt).body.querySelector(".ng-container-body tfoot")).height()||0)-($(f(this,yt).body.querySelector(".ng-container-body tbody.fixed")).height()||0));it(this,"fitPage",()=>{const C=this.getVisibleLastRow(),t=this.getTotalSpace();if(C==f(this,yt).data.count()-1){for(var l=0,c=C;c>=0;c--)if(l+=this.getRowHeight(c),l>t){f(this,yt).scrollTo(c+1);break}}});it(this,"selectArea",(C,t,l,c)=>{const o=f(this,Us).call(this,C),r=f(this,Us).call(this,l),n=f(this,Vs).call(this,t),s=f(this,Vs).call(this,c),e=parseInt(o*f(this,yt).template.length),i=parseInt(r*f(this,yt).template.length)+f(this,yt).template.length-1;f(this,yt).row.at=o,o>=0&&r>=0?f(this,yt).selection.selectArea(e,n,i,s):this.clearSelection()});it(this,"selectRow",(C,t)=>{const l=f(this,Us).call(this,C),c=H.isNull(t)?l:f(this,Us).call(this,t),o=parseInt(l*f(this,yt).template.length),r=parseInt(c*f(this,yt).template.length)+f(this,yt).template.length-1;f(this,yt).row.at=l,l>=0&&c>=0?f(this,yt).selection.selectArea(o,f(this,yt).firstCol,r,f(this,yt).lastCol):this.clearSelection()});it(this,"selectCol",(C,t)=>{const l=f(this,Vs).call(this,C),c=H.isNull(t)?l:f(this,Vs).call(this,t),o=0,r=parseInt(f(this,yt).data.count()*f(this,yt).template.length-1);l>=0&&c>=0?f(this,yt).selection.selectArea(o,l,r,c):this.clearSelection()});it(this,"selectCell",(C,t,l)=>{const c=f(this,Us).call(this,C),o=f(this,Vs).call(this,t),r=parseInt(c*f(this,yt).template.length)+H.nvl(l,0);f(this,yt).row.at=c,c>=0?f(this,yt).selection.selectArea(r,o,r,o):this.clearSelection()});Y(this,Us,C=>{if(typeof C=="number")return C;if(typeof C=="function")return f(this,yt).data.findIndex(C);throw`invalid ${C}`});Y(this,Vs,C=>{if(typeof C=="number")return C;if(typeof C=="string"&&f(this,yt).fields.includes(C))return parseInt($(`[data-bind="${C}"]`,f(this,yt).template)[0].dataset.col);throw`invalid ${C}`});it(this,"moveTo",C=>{f(this,yt).scrollTo(C)});tt(this,yt,C),tt(this,vi,!1),this.init()}}yt=new WeakMap,Ge=new WeakMap,wr=new WeakMap,vi=new WeakMap,wi=new WeakMap,Fa=new WeakMap,qa=new WeakMap,Ha=new WeakMap,za=new WeakMap,Ua=new WeakMap,cc=new WeakMap,uc=new WeakMap,dc=new WeakMap,kn=new WeakMap,Us=new WeakMap,Vs=new WeakMap;class sf{constructor(C){Y(this,Je);Y(this,Ws);it(this,"initialize",()=>{tt(this,Ws,!1),f(this,Je).data.clearFilter()});it(this,"isFiltering",()=>f(this,Ws));it(this,"on",C=>{tt(this,Ws,!0);const t=f(this,fc).call(this);f(this,Je).body.querySelectorAll(".ng-table thead th, .ng-table thead td").forEach(l=>{var o,r;const c=(o=l.closest("tr"))==null?void 0:o.sectionRowIndex;if(c!==void 0&&c+l.rowSpan-1===t){const n=Array.from(f(this,Je).activeTmpl.querySelectorAll(`[data-col="${l.dataset.col}"]`)).map(s=>s.dataset.bind?{colnm:s.dataset.bind,data:[]}:null).filter(Boolean);if(n.length>0){(r=l.querySelector("ng-filter-button"))==null||r.remove();const s=document.createElement("ng-filter-button");l.appendChild(s),s.filterOptions=n}}})});it(this,"off",()=>{tt(this,Ws,!1),f(this,Je).body.querySelectorAll(".ng-table ng-filter-button").forEach(C=>{C.remove()})});it(this,"set",C=>{this.on();let t=Array.isArray(C)?Object.fromEntries(Object.keys(C[0]).map(l=>[l,[...new Set(C.map(c=>c[l]))]])):C;f(this,Je).data.clearFilter(),Object.entries(t).forEach(([l,c])=>{const o=f(this,Je).fields.indexOf(l);f(this,Je).data.getValidData().some(r=>typeof r.v[o]=="number")&&(c=c.map(Number)),f(this,Je).data.getValidData().filter(r=>c.nineBinarySearch(r.v[o]||"")<0).forEach(r=>{r.__ng.filtered=!0})}),f(this,Je).data.refreshFilter(),f(this,Je).shadowRoot.querySelectorAll("ng-filter-button").forEach(l=>{l.filterOptions.forEach(c=>{c.data=[]})}),Object.entries(t).forEach(([l,c])=>{f(this,Je).shadowRoot.querySelectorAll("ng-filter-button").forEach(o=>{let r=o.filterOptions;r.forEach(n=>{n.colnm===l&&(n.data=c)}),o.filterOptions=r})}),f(this,Je).scrollTo_V1(0),f(this,Je).paging.reset()});Y(this,fc,(C="thead")=>[...f(this,Je).body.querySelectorAll(`.ng-table ${C}`)].reduce((t,l)=>Math.max(l.rows.length-1,t),0));tt(this,Je,C),tt(this,Ws,!1);const t=document.createElement("ng-filter-panel");t.style.display="none",f(this,Je).shadowRoot.appendChild(t)}}Je=new WeakMap,Ws=new WeakMap,fc=new WeakMap;class nf extends HTMLElement{constructor(){super();Y(this,Va);Y(this,Cn);Y(this,Wa,t=>{var o;t.preventDefault(),t.stopPropagation();const l=f(this,Va).shadowRoot.querySelector("ng-filter-panel"),c=(o=this.closest("th,td"))==null?void 0:o.dataset.col;l.col===c?l.close():l.open(this)})}connectedCallback(){tt(this,Va,this.getRootNode().host),this.removeEventListener("click",f(this,Wa)),this.addEventListener("click",f(this,Wa))}get filterOptions(){return f(this,Cn)}set filterOptions(t){tt(this,Cn,t),this.classList.toggle("filtered",f(this,Cn).some(l=>l.data.length>0))}}Va=new WeakMap,Cn=new WeakMap,Wa=new WeakMap;class of extends HTMLElement{constructor(){super();Y(this,Mr);Y(this,Xa);Y(this,Ya);Y(this,pc,t=>{const l=this.shadowRoot.querySelector("nine-grid");this.classList.add("loading"),setTimeout(()=>{const[c,o,r,n]=["LVL","CHK","COLNM","DATA"].map(u=>l.fields.indexOf(u)),s=l.data.getValidDataNF().filter(u=>u.v[c]===2&&u.v[o]==="Y"),e=s.length>0?[...new Set(s.map(u=>u.v[r]))].map(u=>({colnm:u,data:[...new Set(l.data.getValidData().filter(a=>a.v[o]==="Y"&&a.v[r]===u).map(a=>a.v[n]||""))].sort()})):[];f(this,Xa).filterOptions=e;const i=Object.fromEntries([...f(this,Mr).body.querySelectorAll("ng-filter-button")].flatMap(u=>u.filterOptions).filter(u=>u.data.length>0).map(u=>[u.colnm,u.data]));f(this,Mr).filtering.set(i),this.classList.remove("loading"),this.style.display="none"})});Y(this,mc,t=>{this.style.display="none"});Y(this,gc,t=>{const l=this.shadowRoot.querySelector("nine-grid"),c=l.fields.indexOf("CHK"),o=t.target.checked;l.data.getValidData().forEach(r=>{r.v[c]=o?"Y":"N"}),l.refreshData()});Y(this,bc,t=>{const l=this.shadowRoot.querySelector("nine-grid");l.classList.add("loading");const c=l.dataManager.rawRecords;c.forEach(s=>{s.__ng.filtered=!1});const o=t.target.value.toLowerCase(),[r,n]=["LVL","DATA"].map(s=>l.fields.indexOf(s));c.forEach(s=>{s.__ng.filtered=s.v[r]===2&&!String(s.v[n]||"").toLowerCase().includes(o)}),l.data.resetRecords(),clearTimeout(f(this,Ya)),tt(this,Ya,setTimeout(()=>{l.dataManager.viewRecords.reset(),l.dataManager.viewRecords.touch()},200))});it(this,"close",()=>{this.col=null,this.style.display="none"});it(this,"open",t=>{const l=t.closest("th,td"),{left:c}=t.getBoundingClientRect(),{left:o,width:r,top:n}=f(this,Mr).getBoundingClientRect(),{top:s,height:e}=l.getBoundingClientRect(),{width:i}=this.getBoundingClientRect();let u=Math.max(0,c-o);u=Math.min(u,r-i-5);const a=s+e-n;Object.assign(this.style,{left:`${u}px`,top:`${a}px`,display:"flex"}),this.classList.add("loading"),this.shadowRoot.querySelector("input[type=text]").value="",setTimeout(()=>{const h=f(this,Mr).data.getValidDataNF(),p=l.dataset.col;this.col=p,tt(this,Xa,t);const m=t.filterOptions.map((g,S)=>{const E=`<span class="group">${l.textContent}${t.filterOptions.length>1?` #${S+1} (${g.colnm})`:""}</span>`,I=f(this,Mr).activeTmpl.querySelector(`[data-col="${p}"][data-bind="${g.colnm}"]`),D=I==null?void 0:I.getAttribute("data-expr"),z=D?f(this,Mr).exprFunction(D):null,P=h.map(B=>{const F=f(this,Mr).fields.indexOf(g.colnm);return D?{v:B.v[F],v2:z(f(this,Mr).data.conv(B),B.__ng.rowidx,f(this,Mr).data)}:{v:B.v[F],v2:B.v[F]}});return[{LVL:1,CHK:"N",DATA2:E},...[...new Set(P.map(JSON.stringify))].map(JSON.parse).sort((B,F)=>(B.v2||"")>(F.v2||"")?1:(B.v2||"")<(F.v2||"")?-1:0).map(B=>({LVL:2,DATA:B.v,DATA2:B.v2||` <span class="empty">(empty)</span> ${B.v}`,COLNM:g.colnm,CHK:g.data.length===0||g.data.nineBinarySearch(B.v||"")>=0?"Y":"N"}))]}).flat(),d=this.shadowRoot.querySelector("nine-grid");d.fields.add(["DATA","DATA2","COLNM"]),d.data.set(m);const b=this.shadowRoot.querySelector("input[type=checkbox]");b.checked=d.data.getValidData().every(g=>!(g.LVL===2&&g.CHK!=="Y")),this.shadowRoot.querySelector("input").focus(),this.classList.remove("loading")})});this.attachShadow({mode:"open"})}connectedCallback(){tt(this,Mr,this.getRootNode().host);const t=this.getRootNode().host.closest("nine-grid").getAttribute("css-path")||"",l=nine.cssPath?`@import "${nine.cssPath}/ninegrid/ngFilterPanel.css";`:"";console.log("==========="),console.log(nine.cssPath),this.shadowRoot.innerHTML=`
721
721
  <style>
722
722
  @import "https://cdn.jsdelivr.net/npm/ninegrid2@${H.version}/dist/css/ngFilterPanel.css";
723
- ${H.getCustomPath(this,"ngFilterPanel.css")}
723
+ ${l}
724
724
  </style>
725
725
 
726
726
  <div class="head">