@ninebone/table 0.0.808 → 0.0.810
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.umd.js
CHANGED
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
<button class='ng-scroll-top' disabled><div class='ng-scroll-icon'></div></button>
|
|
124
124
|
<div class='ng-scroll-track'><div class='ng-scroll-thumb'></div></div>
|
|
125
125
|
<button class='ng-scroll-bottom' disabled><div class='ng-scroll-icon'></div></button>
|
|
126
|
-
`;const e=h(()=>{const s=t(this,at).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}p(this,L,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),top:this.querySelector(".ng-scroll-top"),bottom:this.querySelector(".ng-scroll-bottom")}),t(this,se).call(this),this.refresh()},"initWhenReady");e()}};it=new WeakMap,at=new WeakMap,wt=new WeakMap,L=new WeakMap,Lt=new WeakMap,It=new WeakMap,se=new WeakMap,h(Ye,"NineTableVScrollBar");let kt=Ye;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",kt);const Ge=class Ge{constructor(n){d(this,lt);d(this,q);d(this,ct);d(this,V,new Map);d(this,D,null);d(this,Q,null);d(this,ht,0);d(this,Mt,40);d(this,Xe,!1);d(this,Ke,!1);d(this,ne,3);d(this,re,3);d(this,Y,0);C(this,"refresh",h(()=>{var e;S.log("rowManager.refresh");const n=t(this,q).querySelector(".ng-container-body .ng-part-body");n&&(t(this,Ht).call(this),t(this,$t).call(this),t(this,vt).call(this,n.scrollTop),(e=t(this,q).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));C(this,"initialize",h(()=>{S.log("rowManager.initialize"),p(this,ct,{scrollTables:t(this,q).querySelectorAll(".ng-part-body table"),firstTr:t(this,q).querySelector(".ng-container-body .ng-part-body tbody.bindable-tbody tr:not(.nodata)")}),p(this,D,null),t(this,V).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const a=t(this,q).querySelector(o);if(!a)return;const c=a.querySelector(".ng-part-body table");if(!c)return;const l=c.querySelector("tbody.bindable-tbody");if(!l)return;const f=Array.from(l.querySelectorAll("tr")).map(b=>b.cloneNode(!0));t(this,V).set(o,f)});const n=t(this,q).querySelector(".ng-container-body .ng-part-body"),e=t(this,q).querySelector(".ng-container-left .ng-part-body"),s=t(this,q).querySelector(".ng-container-right .ng-part-body"),r=t(this,q).querySelector(".ng-container-body .ng-part-header"),i=t(this,q).querySelector(".ng-container-body .ng-part-footer");if(n){t(this,Ht).call(this),t(this,_t).call(this),t(this,$t).call(this),t(this,vt).call(this,n.scrollTop);let o=!1;p(this,Y,n.scrollLeft);const a=h(c=>{var b;if(o)return;o=!0;const l=c.scrollTop,u=c.scrollLeft;n&&n.scrollTop!==l&&(n.scrollTop=l),e&&e.scrollTop!==l&&(e.scrollTop=l),s&&s.scrollTop!==l&&(s.scrollTop=l),Math.abs(u-t(this,Y))>=t(this,re)?(r&&r.scrollLeft!==u&&(r.scrollLeft=u),i&&i.scrollLeft!==u&&(i.scrollLeft=u),p(this,Y,u)):r&&r.scrollLeft!==t(this,Y)&&(r.scrollLeft=t(this,Y),i&&(i.scrollLeft=t(this,Y))),t(this,vt).call(this,l),(b=t(this,q).querySelector("nine-table-vscrollbar"))==null||b.refresh(),o=!1},"handleContainerScroll");n==null||n.addEventListener("scroll",c=>{a(n)}),[e,s].forEach(c=>{c==null||c.addEventListener("scroll",l=>{if(o)return;o=!0;const u=c.scrollTop;n&&n.scrollTop!==u&&(n.scrollTop=u),o=!1})})}},"initialize"));d(this,oe,h((n,e)=>{S.log("rowManager.#renderRows");const s=t(this,V).get(e);if(!s||s.length===0)return;const r=n.querySelector(".ng-part-body tbody.bindable-tbody");if(!r)return;r.querySelectorAll("tr:not(.nodata)").forEach(a=>a.remove());const i=r.querySelector("tr.nodata"),o=document.createDocumentFragment();for(let a=0;a<t(this,Mt);a++)s.forEach(c=>{o.appendChild(c.cloneNode(!0))});i?i.before(o):r.appendChild(o),e===".ng-container-body"&&(t(this,ct).firstTr=r.querySelector("tr:not(.nodata)"))},"#renderRows"));d(this,Ht,h(()=>{if(t(this,D)!==null&&t(this,D)>0)return t(this,D);const n=t(this,q).querySelector(".ng-container-body .ng-part-body");S.log("rowManager.#measureAndCacheHeight");const e=t(this,V).get(".ng-container-body");if(!e||e.length===0)throw new Error("invalid dom");const s=n.querySelector("tbody.bindable-tbody");if(!s)throw new Error("invalid dom");s.querySelectorAll("tr:not(.nodata)").forEach(b=>b.remove());const r=s.querySelector("tr.nodata"),i=document.createDocumentFragment();e.forEach(b=>{i.appendChild(b.cloneNode(!0))}),r?r.before(i):s.appendChild(i);const o=t(this,q),a=o.style.display,c=o.style.visibility,l=o.style.position;(a==="none"||window.getComputedStyle(o).display==="none")&&(o.style.display="block",o.style.visibility="hidden",o.style.position="absolute");let u=0;const f=s.querySelectorAll("tr");return f.forEach(b=>{let g=b.offsetHeight||b.getBoundingClientRect().height;if(g===0){const y=window.getComputedStyle(b);g=parseFloat(y.height)||parseFloat(y.minHeight)||0}u+=g}),f.forEach(b=>b.remove()),o.style.display=a,o.style.visibility=c,o.style.position=l,u<=0?-1:(p(this,D,u),t(this,Nt).call(this),t(this,D))},"#measureAndCacheHeight"));d(this,$t,h(()=>{S.log("rowManager.#updateVirtualScrollHeight");const e=(t(this,lt).data.get()||[]).length,s=t(this,D),r=e*s;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(i=>{const o=t(this,q).querySelector(i);if(!o)return;const a=o.querySelector(".ng-part-body .ng-virtual-spacer");a&&(a.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));d(this,Nt,h(()=>{if(t(this,ht)>0&&t(this,D)>0){const n=Math.ceil(t(this,ht)/t(this,D));p(this,Mt,n+t(this,ne))}},"#updateRowCount"));d(this,ie,h(()=>{var a,c,l,u,f,b;const n=t(this,q).querySelector(".ng-container-left .ng-part-body table"),e=t(this,q).querySelector(".ng-container-body .ng-part-body table"),s=t(this,q).querySelector(".ng-container-right .ng-part-body table");if(e){const g=n?Array.from(n.querySelectorAll("tbody tr")):[],y=Array.from(e.querySelectorAll("tbody tr")),x=s?Array.from(s.querySelectorAll("tbody tr")):[],w=Math.max(g.length,y.length,x.length);for(let m=0;m<w;m++){const k=[((a=g[m])==null?void 0:a.getBoundingClientRect().height)||0,((c=y[m])==null?void 0:c.getBoundingClientRect().height)||0,((l=x[m])==null?void 0:l.getBoundingClientRect().height)||0],A=Math.max(...k);A>0&&(g[m]&&(g[m].style.height=`${A}px`),y[m]&&(y[m].style.height=`${A}px`),x[m]&&(x[m].style.height=`${A}px`))}}const r=t(this,q).querySelector(".ng-container-left .ng-part-footer table"),i=t(this,q).querySelector(".ng-container-body .ng-part-footer table"),o=t(this,q).querySelector(".ng-container-right .ng-part-footer table");if(i){const g=r?Array.from(r.querySelectorAll("tfoot tr")):[],y=Array.from(i.querySelectorAll("tfoot tr")),x=o?Array.from(o.querySelectorAll("tfoot tr")):[],w=Math.max(g.length,y.length,x.length);for(let m=0;m<w;m++){const k=[((u=g[m])==null?void 0:u.getBoundingClientRect().height)||0,((f=y[m])==null?void 0:f.getBoundingClientRect().height)||0,((b=x[m])==null?void 0:b.getBoundingClientRect().height)||0],A=Math.max(...k);A>0&&(g[m]&&(g[m].style.height=`${A}px`),y[m]&&(y[m].style.height=`${A}px`),x[m]&&(x[m].style.height=`${A}px`))}}},"#syncRowHeights"));d(this,ae,h(()=>{!t(this,q)||!(t(this,q)instanceof HTMLElement)||(p(this,Q,new ResizeObserver(n=>{for(const e of n){const s=e.target;if(!s.classList.contains("active"))continue;const r=e.contentRect.height;if(r>0){let i=0;const o=s.querySelector(".ng-part-header"),a=s.querySelector(".ng-part-footer");o&&(i+=o.offsetHeight),a&&(i+=a.offsetHeight);const c=Math.max(r-i,100);t(this,ht)!==c&&(p(this,ht,c),t(this,Nt).call(this),t(this,D)!==null&&(t(this,_t).call(this),this.refresh()))}}})),t(this,Q).observe(t(this,q)))},"#initResizeObserver"));d(this,_t,h(()=>{S.log("rowManager.#renderAllContainers"),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,q).querySelector(n);e&&e.querySelector(".ng-part-body tbody.bindable-tbody")&&t(this,oe).call(this,e,n)}),t(this,ce).call(this),t(this,ie).call(this)},"#renderAllContainers"));d(this,vt,h(n=>{var f,b;const e=t(this,D);if(!e||e<=0)return;const s=t(this,lt).data.length;if(s===0)return;const r=((f=t(this,V).get(".ng-container-body"))==null?void 0:f.length)||1,i=t(this,q).querySelector(".ng-container-body .ng-part-body"),o=Math.max(0,s-Math.floor(i.clientHeight/e)),a=Math.min(o,Math.max(0,Math.floor(n/e)));let c=Math.floor(a*e);const l=t(this,ct).firstTr,u=l&&l.dataset.row!==void 0?parseInt(l.dataset.row,10):-1;(b=t(this,ct))==null||b.scrollTables.forEach(g=>{g.style.transform=`translate3d(0, ${c}px, 0)`}),u!==a&&[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(g=>{const y=t(this,q).querySelector(g);if(!y)return;const x=y.querySelector(".ng-part-body tbody.bindable-tbody");if(!x)return;Array.from(x.querySelectorAll("tr:not(.nodata)")).forEach((m,k)=>{const A=a+Math.floor(k/r);if(A>=s){m.style.display="none";return}const N=t(this,lt).data.get(A);m.style.display="",t(this,le).call(this,m,N,A)})})},"#handleScroll"));d(this,le,h((n,e,s)=>{n.dataset.row=s,n.data=e,Array.from(n.cells).forEach((r,i)=>{r.dataset.row=s;const o=Array.from(r.children).find(a=>a.tagName.toLowerCase().startsWith("cell-")||typeof a.refresh=="function");o&&typeof o.refresh=="function"&&o.refresh()})},"#bindRowData"));d(this,ce,h(()=>{var c,l,u;S.log("rowManager.#syncHeaderHeights");const n=t(this,q).querySelector(".ng-container-left .ng-part-header table"),e=t(this,q).querySelector(".ng-container-body .ng-part-header table"),s=t(this,q).querySelector(".ng-container-right .ng-part-header table");if(!e)return;const r=n?Array.from(n.querySelectorAll("tr")):[],i=Array.from(e.querySelectorAll("tr")),o=s?Array.from(s.querySelectorAll("tr")):[],a=Math.max(r.length,i.length,o.length);for(let f=0;f<a;f++){const b=[((c=r[f])==null?void 0:c.getBoundingClientRect().height)||0,((l=i[f])==null?void 0:l.getBoundingClientRect().height)||0,((u=o[f])==null?void 0:u.getBoundingClientRect().height)||0],g=Math.max(...b);g>0&&(r[f]&&(r[f].style.height=`${g}px`),i[f]&&(i[f].style.height=`${g}px`),o[f]&&(o[f].style.height=`${g}px`))}},"#syncHeaderHeights"));C(this,"destroy",h(()=>{t(this,Q)&&(t(this,Q).disconnect(),p(this,Q,null))},"destroy"));p(this,lt,n.getRootNode().host),p(this,q,n),t(this,ae).call(this)}getRowHeight(){return t(this,D)}templateLength(n=".ng-container-body"){var e;return((e=t(this,V).get(n))==null?void 0:e.length)||1}};lt=new WeakMap,q=new WeakMap,ct=new WeakMap,V=new WeakMap,D=new WeakMap,Q=new WeakMap,ht=new WeakMap,Mt=new WeakMap,Xe=new WeakMap,Ke=new WeakMap,ne=new WeakMap,re=new WeakMap,Y=new WeakMap,oe=new WeakMap,Ht=new WeakMap,$t=new WeakMap,Nt=new WeakMap,ie=new WeakMap,ae=new WeakMap,_t=new WeakMap,vt=new WeakMap,le=new WeakMap,ce=new WeakMap,h(Ge,"RowManager");let Le=Ge;const he=class he{static compileAll(n){return Array.isArray(n)?n.map(e=>he.compile(e)):[]}static compile(n){if(!n)return null;const e=h(a=>{a.querySelectorAll("tbody td, tbody th, tfoot td, tfoot th").forEach(l=>{const u=l.getAttribute("cell-type")||"renderer";if(l.children.length>0&&l.firstElementChild.tagName.includes("-"))return;let f=`cell-${u}`;const b=l.getAttribute("data-bind"),g=l.getAttribute("data-expr"),y=l.getAttribute("maxbyte"),x=l.getAttribute("type");let w=[];b&&w.push(`data-bind="${b}"`),g&&w.push(`data-expr="${g}"`),y&&w.push(`maxbyte="${y}"`),x&&w.push(`type="${x}"`),l.innerHTML=`<${f} ${w.join(" ")}></${f}>`}),a.querySelectorAll("tbody td, tfoot td").forEach(l=>{l.setAttribute("tabindex","0")})},"processCellTypes"),s=h(a=>{if(!a.querySelector("colgroup")){const c=a.querySelector("tbody tr")||a.querySelector("tr"),l=c?c.querySelectorAll("th, td").length:1,u=document.createElement("colgroup"),f=Math.max(Math.floor(a.clientWidth/l),100);for(let b=0;b<l;b++){const g=document.createElement("col");g.setAttribute("width",f),u.appendChild(g)}a.prepend(u)}if(!a.querySelector("thead")){const c=document.createElement("thead"),l=a.querySelector("colgroup");l?l.after(c):a.prepend(c)}a.classList.add("nine-table-element")},"ensureTableStructure"),r=h((a,c)=>{const l=Array.from(a.querySelectorAll(c+" tr")),u=Array.from(a.querySelectorAll(c+" th,"+c+" td")),f=l.length;if(f===0||u.length===0)return;let b=0;u.forEach(y=>{b+=y.colSpan||1});const g=Array.from(Array(f),()=>Array(b).fill(null));l.forEach(y=>{const x=y.sectionRowIndex;let w=0;Array.from(y.querySelectorAll("th,td")).forEach(m=>{for(let N=0;N<g[x].length;N++)if(g[x][N]===null){w=N;break}const k=m.rowSpan||1,A=m.colSpan||1;for(let N=0;N<k;N++)for(let B=0;B<A;B++)x+N<f&&w+B<b&&(g[x+N][w+B]=N===0&&B===0?"1":"0")})}),l.forEach(y=>{const x=y.sectionRowIndex;Array.from(y.querySelectorAll("th,td")).forEach(w=>{for(let m=0;m<g[x].length;m++)if(g[x][m]==="1"){w.dataset.col=m,g[x][m]="0";break}})})},"resetColIndex"),i=n.cloneNode(!0);return s(i),e(i),r(i,"thead"),r(i,"tbody"),r(i,"tfoot"),Array.from(i.querySelectorAll("colgroup col")).forEach((a,c)=>{const l=a.getAttribute("fixed");l&&i.querySelectorAll(`thead [data-col="${c}"], tbody [data-col="${c}"], tfoot [data-col="${c}"]`).forEach(u=>{u.setAttribute("fixed",l)})}),i}};h(he,"TableCompiler");let Ie=he;const Ze=class Ze{constructor(n){d(this,K);d(this,_);d(this,X,{startRow:-1,startCol:-1,endRow:-1,endCol:-1});C(this,"render",h(()=>{const{startRow:n,startCol:e,endRow:s,endCol:r}=t(this,X);S.log("🎨 [CellSelection.render] Rendering range ->",t(this,X));const i=t(this,_).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");if(i.forEach(a=>{a.querySelectorAll(".selected, .selected-top, .selected-bottom, .selected-left, .selected-right").forEach(c=>{c.classList.remove("selected","selected-top","selected-bottom","selected-left","selected-right")})}),n<0||e<0){S.log("⚠️ [CellSelection.render] Range is invalid (< 0), skipping render.");return}let o=0;i.forEach(a=>{a.querySelectorAll("tbody tr").forEach(c=>{const{matrixRow:l}=G(this,K,Jt).call(this,c);l<0||c.querySelectorAll("td, th").forEach(u=>{const f=parseInt(u.dataset.col,10);if(isNaN(f))return;const b=parseInt(u.rowSpan||1,10),g=parseInt(u.colSpan||1,10),y=l+b-1,x=f+g-1;y>=n&&l<=s&&x>=e&&f<=r&&(o++,u.classList.add("selected"),S.log(u,n,e,s,r),l<=n&&u.classList.add("selected-top"),y>=s&&u.classList.add("selected-bottom"),f<=e&&u.classList.add("selected-left"),x>=r&&u.classList.add("selected-right"))})})}),S.log(`✨ [CellSelection.render] Total rendered cells marked: ${o}`)},"render"));p(this,_,n),G(this,K,vs).call(this),t(this,_).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body").forEach(s=>{s.addEventListener("scroll",()=>{t(this,X).startRow>=0&&t(this,X).startCol>=0&&this.render()})}),S.log("🎯 [CellSelection] Initialized")}setRange(n,e,s,r){S.log(`🔍 [CellSelection.setRange] Input -> startRow: ${n}, startCol: ${e}, endRow: ${s}, endCol: ${r}`);let i=Math.min(n,s),o=Math.max(n,s),a=Math.min(e,r),c=Math.max(e,r);const l=t(this,_).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");let u=!0,f=0;for(;u&&f<5;)u=!1,f++,l.forEach(b=>{b.querySelectorAll("tbody tr").forEach(g=>{if(g.classList.contains("nodata"))return;const{matrixRow:y}=G(this,K,Jt).call(this,g);y<0||g.querySelectorAll("td, th").forEach(x=>{const w=parseInt(x.dataset.col,10);if(isNaN(w))return;const m=parseInt(x.rowSpan||1,10),k=parseInt(x.colSpan||1,10),A=y+m-1,N=w+k-1;if(A>=i&&y<=o&&N>=a&&w<=c){const P=Math.min(i,y),ke=Math.max(o,A),ps=Math.min(a,w),ys=Math.max(c,N);(P!==i||ke!==o||ps!==a||ys!==c)&&(i=P,o=ke,a=ps,c=ys,u=!0)}})})});p(this,X,{startRow:i,startCol:a,endRow:o,endCol:c}),S.log("📦 [CellSelection.setRange] Final Range ->",t(this,X)),this.render()}};_=new WeakMap,X=new WeakMap,K=new WeakSet,Jt=h(function(n){if(!n||n.classList.contains("nodata"))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};const e=parseInt(n.dataset.row,10);if(isNaN(e))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};const s=n.closest("tbody"),i=Array.from(s.querySelectorAll("tr:not(.nodata)")).filter(l=>parseInt(l.dataset.row,10)===e),o=i.indexOf(n),a=i.length>0?i.length:1,c=e*a+(o>=0?o:n.sectionRowIndex%a);return{dataRow:e,subRowIndex:o,matrixRow:c}},"#getMatrixRow"),vs=h(function(){const n=t(this,_).querySelector(".ng-container-top");if(!n){S.log("❌ [CellSelection] .ng-container-top not found!");return}n.addEventListener("mousedown",e=>{if(e.button!==0)return;const s=e.target.closest("td, th");if(!s||s.dataset.row===void 0||s.dataset.col===void 0||s.closest("tr").classList.contains("nodata"))return;t(this,_).style.userSelect="none",t(this,_).style.webkitUserSelect="none";const r=s.closest("tr"),{matrixRow:i}=G(this,K,Jt).call(this,r),o=parseInt(s.dataset.col,10);if(i<0){t(this,_).style.userSelect="",t(this,_).style.webkitUserSelect="";return}S.log(`🖱️ [MouseDown Success] startRow: ${i}, startCol: ${o}`),t(this,_).navigation.currentCell=s;let a=i,c=o;const l=h(f=>{const b=document.elementFromPoint(f.clientX,f.clientY);let g=b==null?void 0:b.closest("td, th");if(!g||!t(this,_).contains(g)){const m=t(this,_).querySelectorAll(".ng-part-body tbody tr:not(.nodata) td, .ng-part-body tbody tr:not(.nodata) th");for(const k of m){const A=k.getBoundingClientRect();if(f.clientX>=A.left&&f.clientX<=A.right&&f.clientY>=A.top&&f.clientY<=A.bottom){g=k;break}}}if(!g||g.dataset.row===void 0||g.dataset.col===void 0||g.closest("tr").classList.contains("nodata"))return;const y=g.closest("tr"),{matrixRow:x}=G(this,K,Jt).call(this,y),w=parseInt(g.dataset.col,10);x<0||a===x&&c===w||(a=x,c=w,this.setRange(i,o,x,w))},"onMouseMove"),u=h(()=>{S.log("🖱️ [MouseUp] Drag ended."),t(this,_).style.userSelect="",t(this,_).style.webkitUserSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",u)},"onMouseUp");document.addEventListener("mousemove",l),document.addEventListener("mouseup",u)})},"#initEvents"),h(Ze,"CellSelection");let Me=Ze;const Je=class Je{constructor(n){d(this,ft);d(this,j);d(this,dt,null);d(this,de,-1);d(this,fe,-1);d(this,Ot,h(n=>{const e=[];return n.forEach(s=>e.push(...Array.from(s.querySelectorAll("td")))),e.length===0?null:(e.sort((s,r)=>parseInt(s.dataset.col,10)-parseInt(r.dataset.col,10)),e[e.length-1])},"#getMaxColCell"));d(this,Dt,h((n,e)=>{const s=t(this,ut).call(this,n);if(s.length===0)return e+1;let r=e+1;const i=[];s.forEach(o=>i.push(...Array.from(o.querySelectorAll("td")))),i.sort((o,a)=>parseInt(o.dataset.col,10)-parseInt(a.dataset.col,10));for(const o of i){const a=parseInt(o.dataset.col,10),c=parseInt(o.colSpan||1,10);if(e>=a&&e<a+c){r=a+c;break}}return r},"#getNextCol"));d(this,Wt,h((n,e)=>{const s=t(this,ut).call(this,n);if(s.length===0)return Math.max(0,e-1);let r=-1;const i=[];s.forEach(o=>i.push(...Array.from(o.querySelectorAll("td")))),i.sort((o,a)=>parseInt(o.dataset.col,10)-parseInt(a.dataset.col,10));for(const o of i){const a=parseInt(o.dataset.col,10);if(a<e)r=a;else break}return r},"#getPreviousCol"));d(this,ut,h(n=>{const e=t(this,j).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body"),s=[];return e.forEach(r=>{const i=Array.from(r.querySelectorAll("tbody tr:not(.nodata)"));for(const o of i){const a=parseInt(o.dataset.row,10),c=i.filter(y=>parseInt(y.dataset.row,10)===a),l=c.length>0?c.length:1,u=c.indexOf(o),f=a*l+(u>=0?u:0);if(f===n){s.push(o);break}const b=Array.from(o.querySelectorAll("td"));let g=!1;for(const y of b){const x=parseInt(y.rowSpan||1,10);if(x>1&&n>=f&&n<f+x){s.push(o),g=!0;break}}if(g)break}}),s},"#findTargetTrsByMatrix"));d(this,zt,h((n,e,s,r)=>{const i=t(this,j).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body"),o=r!==void 0?r:n*1+e;for(const a of i){const c=Array.from(a.querySelectorAll("tbody tr:not(.nodata)"));for(const l of c){const u=parseInt(l.dataset.row,10),f=c.filter(w=>parseInt(w.dataset.row,10)===u),b=f.length>0?f.length:1,g=f.indexOf(l),y=u*b+(g>=0?g:0),x=Array.from(l.querySelectorAll("td"));for(const w of x){const m=parseInt(w.dataset.col,10),k=parseInt(w.colSpan||1,10),A=parseInt(w.rowSpan||1,10);if(!isNaN(m)&&s>=m&&s<m+k&&o>=y&&o<y+A&&window.getComputedStyle(w).display!=="none")return w}}}return null},"#getNearElement"));p(this,j,n),G(this,ft,Ss).call(this),S.log("🎯 [CellNavigation] Initialized")}get currentCell(){return t(this,dt)}set currentCell(n){if(!n)return;p(this,dt,n),n.focus({preventScroll:!0});const e=parseInt(n.dataset.row,10),s=parseInt(n.dataset.col,10);if(!isNaN(e)&&!isNaN(s)){p(this,de,e),p(this,fe,s);const r=n.closest("tr"),i=r==null?void 0:r.closest("tbody");if(i){const a=Array.from(i.querySelectorAll("tr:not(.nodata)")).filter(f=>parseInt(f.dataset.row,10)===e),c=a.length>0?a.length:1,l=a.indexOf(r),u=e*c+(l>=0?l:0);t(this,j).selection.setRange(u,s,u,s)}}}moveCell(n){var m,k,A,N;if(!t(this,dt))return;const e=t(this,dt),s=e.closest("tr"),r=parseInt(e.dataset.row,10),i=parseInt(e.dataset.col,10),o=s==null?void 0:s.closest("tbody");if(!o)return;const c=Array.from(o.querySelectorAll("tr:not(.nodata)")).filter(B=>parseInt(B.dataset.row,10)===r),l=c.length>0?c.length:1,u=c.indexOf(s),f=r*l+(u>=0?u:0);let b=f,g=i;switch(n.code){case"Tab":if(n.preventDefault(),n.shiftKey){if(g=t(this,Wt).call(this,f,i),g<0&&f>0){b=f-1;const B=t(this,ut).call(this,b),P=t(this,Ot).call(this,B);g=P?parseInt(P.dataset.col,10):0}}else{g=t(this,Dt).call(this,f,i);const B=t(this,ut).call(this,f),P=t(this,Ot).call(this,B),ke=P?parseInt(P.dataset.col,10)+parseInt(P.colSpan||1,10):0;g>=ke&&(b=f+1,g=0)}break;case"ArrowRight":g=t(this,Dt).call(this,f,i);break;case"ArrowLeft":g=t(this,Wt).call(this,f,i);break;case"ArrowDown":n.preventDefault(),b=f+(e.rowSpan||1);break;case"ArrowUp":n.preventDefault(),b=Math.max(0,f-(e.rowSpan||1));break}const y=Math.floor(b/l),x=b%l;let w=t(this,zt).call(this,y,x,g,b);if(w)this.currentCell=w,G(this,ft,bs).call(this,w);else if(y!==r&&y>=0){const B=((k=(m=t(this,j)).getRowHeight)==null?void 0:k.call(m))||40;(N=(A=t(this,j)).scrollToY)==null||N.call(A,y*B),setTimeout(()=>{const P=t(this,zt).call(this,y,x,g,b);P&&(this.currentCell=P,G(this,ft,bs).call(this,P))},0)}}};j=new WeakMap,dt=new WeakMap,de=new WeakMap,fe=new WeakMap,ft=new WeakSet,bs=h(function(n){const e=t(this,j).querySelector(".ng-container-body .ng-part-body");if(!e)return;const s=n.getBoundingClientRect(),r=e.getBoundingClientRect();s.top<r.top?e.scrollTop-=r.top-s.top:s.bottom>r.bottom&&(e.scrollTop+=s.bottom-r.bottom),s.left<r.left?e.scrollLeft-=r.left-s.left:s.right>r.right&&(e.scrollLeft+=s.right-r.right)},"#ensureCellVisible"),Ot=new WeakMap,Dt=new WeakMap,Wt=new WeakMap,ut=new WeakMap,zt=new WeakMap,Ss=h(function(){t(this,j).addEventListener("keydown",n=>{["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n.code)&&this.moveCell(n)})},"#initEvents"),h(Je,"CellNavigation");let He=Je;const Ft=class Ft extends HTMLElement{constructor(){super();d(this,ue);d(this,gt,null);d(this,bt);d(this,Bt);d(this,Pt);C(this,"invalidate",h(()=>{S.log("sheet.invalidate()"),t(this,bt).refresh()},"invalidate"));C(this,"generate",h(e=>{if(S.log("sheet.generate()"),!e)return;p(this,gt,Ie.compile(e)),t(this,ge).call(this),t(this,be).call(this);const s=this.querySelector(".ng-container-body .ng-part-header"),r=this.querySelector(".ng-container-body .ng-part-footer"),i=this.querySelector(".ng-nodata-overlay");s&&i&&(i.style.top=`${s.offsetHeight}px`),r&&i&&(i.style.bottom=`${r.offsetHeight}px`),t(this,bt).initialize(),setTimeout(()=>{var o;(o=this.querySelector("nine-table-hscrollbar"))==null||o.refresh()},0)},"generate"));d(this,ge,h(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:s,type:r})=>{var i,o,a;(i=this.querySelector(`${s} .ng-part-header`))==null||i.appendChild(t(this,St).call(this,t(this,gt),r,"header")),(o=this.querySelector(`${s} .ng-virtual-spacer`))==null||o.before(t(this,St).call(this,t(this,gt),r,"body")),(a=this.querySelector(`${s} .ng-part-footer`))==null||a.appendChild(t(this,St).call(this,t(this,gt),r,"footer"))})},"#renderSplitContainers"));d(this,be,h(()=>{["left","right","body"].forEach(e=>{const s=this.querySelector(`.ng-container-${e}`),r=s==null?void 0:s.querySelectorAll("table");if(!s||!r||r.length===0)return;let i=0;r[0].querySelectorAll("col").forEach(o=>{const a=parseInt(o.getAttribute("width"),10);isNaN(a)||(i+=a)}),e==="body"?(s.style.flex="1",r.forEach(o=>{o.style.width=`${i}px`,o.style.minWidth=`${i}px`})):(s.style.flex=`0 0 ${i}px`,s.style.width=`${i}px`,r.forEach(o=>{o.style.width=`${i}px`,o.style.minWidth=`${i}px`}))})},"#updateContainerWidths"));d(this,St,h((e,s,r)=>{const i=e.cloneNode(!0),o=i.querySelector("thead"),a=i.querySelector("tbody"),c=i.querySelector("tfoot");if(r==="header"){if(a&&a.remove(),c&&c.remove(),e.querySelector("tbody")){const u=document.createElement("tbody");u.className="fixed-tbody",i.appendChild(u)}}else r==="body"?(o&&o.remove(),c&&c.remove(),a&&(a.className="bindable-tbody")):r==="footer"&&(o&&o.remove(),a&&a.remove());return s==="left"?i.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="left"&&l.remove()}):s==="right"?i.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="right"&&l.remove()}):i.querySelectorAll("[fixed=left], [fixed=right]").forEach(l=>{l.remove()}),i},"#createSplitTable"));C(this,"getRowHeight",h(()=>t(this,bt).getRowHeight(),"getRowHeight"));C(this,"scrollToX",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollLeft=e)},"scrollToX"));C(this,"scrollToY",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollTop=e)},"scrollToY"));d(this,pe,h(()=>{t(this,ye).call(this),p(this,Bt,new Me(this)),p(this,Pt,new He(this))},"#init"));d(this,ye,h(()=>{const e=Ft.SCROLLBAR_SIZE;this.innerHTML=`
|
|
126
|
+
`;const e=h(()=>{const s=t(this,at).querySelector(".ng-container-body .ng-part-body");if(!s){setTimeout(e,10);return}p(this,L,{container:s,track:this.querySelector(".ng-scroll-track"),thumb:this.querySelector(".ng-scroll-thumb"),top:this.querySelector(".ng-scroll-top"),bottom:this.querySelector(".ng-scroll-bottom")}),t(this,se).call(this),this.refresh()},"initWhenReady");e()}};it=new WeakMap,at=new WeakMap,wt=new WeakMap,L=new WeakMap,Lt=new WeakMap,It=new WeakMap,se=new WeakMap,h(Ye,"NineTableVScrollBar");let kt=Ye;customElements.get("nine-table-vscrollbar")||customElements.define("nine-table-vscrollbar",kt);const Ge=class Ge{constructor(n){d(this,lt);d(this,q);d(this,ct);d(this,V,new Map);d(this,D,null);d(this,Q,null);d(this,ht,0);d(this,Mt,40);d(this,Xe,!1);d(this,Ke,!1);d(this,ne,3);d(this,re,10);d(this,Y,0);C(this,"refresh",h(()=>{var e;S.log("rowManager.refresh");const n=t(this,q).querySelector(".ng-container-body .ng-part-body");n&&(t(this,Ht).call(this),t(this,$t).call(this),t(this,vt).call(this,n.scrollTop),(e=t(this,q).querySelector("nine-table-vscrollbar"))==null||e.refresh())},"refresh"));C(this,"initialize",h(()=>{S.log("rowManager.initialize"),p(this,ct,{scrollTables:t(this,q).querySelectorAll(".ng-part-body table"),firstTr:t(this,q).querySelector(".ng-container-body .ng-part-body tbody.bindable-tbody tr:not(.nodata)")}),p(this,D,null),t(this,V).clear(),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(o=>{const a=t(this,q).querySelector(o);if(!a)return;const c=a.querySelector(".ng-part-body table");if(!c)return;const l=c.querySelector("tbody.bindable-tbody");if(!l)return;const f=Array.from(l.querySelectorAll("tr")).map(b=>b.cloneNode(!0));t(this,V).set(o,f)});const n=t(this,q).querySelector(".ng-container-body .ng-part-body"),e=t(this,q).querySelector(".ng-container-left .ng-part-body"),s=t(this,q).querySelector(".ng-container-right .ng-part-body"),r=t(this,q).querySelector(".ng-container-body .ng-part-header"),i=t(this,q).querySelector(".ng-container-body .ng-part-footer");if(n){t(this,Ht).call(this),t(this,_t).call(this),t(this,$t).call(this),t(this,vt).call(this,n.scrollTop);let o=!1;p(this,Y,n.scrollLeft);const a=h(c=>{var b;if(o)return;o=!0;const l=c.scrollTop,u=c.scrollLeft;n&&n.scrollTop!==l&&(n.scrollTop=l),e&&e.scrollTop!==l&&(e.scrollTop=l),s&&s.scrollTop!==l&&(s.scrollTop=l),Math.abs(u-t(this,Y))>=t(this,re)?(r&&r.scrollLeft!==u&&(r.scrollLeft=u),i&&i.scrollLeft!==u&&(i.scrollLeft=u),p(this,Y,u)):r&&r.scrollLeft!==t(this,Y)&&(r.scrollLeft=t(this,Y),i&&(i.scrollLeft=t(this,Y))),t(this,vt).call(this,l),(b=t(this,q).querySelector("nine-table-vscrollbar"))==null||b.refresh(),o=!1},"handleContainerScroll");n==null||n.addEventListener("scroll",c=>{a(n)}),[e,s].forEach(c=>{c==null||c.addEventListener("scroll",l=>{if(o)return;o=!0;const u=c.scrollTop;n&&n.scrollTop!==u&&(n.scrollTop=u),o=!1})})}},"initialize"));d(this,oe,h((n,e)=>{S.log("rowManager.#renderRows");const s=t(this,V).get(e);if(!s||s.length===0)return;const r=n.querySelector(".ng-part-body tbody.bindable-tbody");if(!r)return;r.querySelectorAll("tr:not(.nodata)").forEach(a=>a.remove());const i=r.querySelector("tr.nodata"),o=document.createDocumentFragment();for(let a=0;a<t(this,Mt);a++)s.forEach(c=>{o.appendChild(c.cloneNode(!0))});i?i.before(o):r.appendChild(o),e===".ng-container-body"&&(t(this,ct).firstTr=r.querySelector("tr:not(.nodata)"))},"#renderRows"));d(this,Ht,h(()=>{if(t(this,D)!==null&&t(this,D)>0)return t(this,D);const n=t(this,q).querySelector(".ng-container-body .ng-part-body");S.log("rowManager.#measureAndCacheHeight");const e=t(this,V).get(".ng-container-body");if(!e||e.length===0)throw new Error("invalid dom");const s=n.querySelector("tbody.bindable-tbody");if(!s)throw new Error("invalid dom");s.querySelectorAll("tr:not(.nodata)").forEach(b=>b.remove());const r=s.querySelector("tr.nodata"),i=document.createDocumentFragment();e.forEach(b=>{i.appendChild(b.cloneNode(!0))}),r?r.before(i):s.appendChild(i);const o=t(this,q),a=o.style.display,c=o.style.visibility,l=o.style.position;(a==="none"||window.getComputedStyle(o).display==="none")&&(o.style.display="block",o.style.visibility="hidden",o.style.position="absolute");let u=0;const f=s.querySelectorAll("tr");return f.forEach(b=>{let g=b.offsetHeight||b.getBoundingClientRect().height;if(g===0){const y=window.getComputedStyle(b);g=parseFloat(y.height)||parseFloat(y.minHeight)||0}u+=g}),f.forEach(b=>b.remove()),o.style.display=a,o.style.visibility=c,o.style.position=l,u<=0?-1:(p(this,D,u),t(this,Nt).call(this),t(this,D))},"#measureAndCacheHeight"));d(this,$t,h(()=>{S.log("rowManager.#updateVirtualScrollHeight");const e=(t(this,lt).data.get()||[]).length,s=t(this,D),r=e*s;[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(i=>{const o=t(this,q).querySelector(i);if(!o)return;const a=o.querySelector(".ng-part-body .ng-virtual-spacer");a&&(a.style.height=`${r}px`)})},"#updateVirtualScrollHeight"));d(this,Nt,h(()=>{if(t(this,ht)>0&&t(this,D)>0){const n=Math.ceil(t(this,ht)/t(this,D));p(this,Mt,n+t(this,ne))}},"#updateRowCount"));d(this,ie,h(()=>{var a,c,l,u,f,b;const n=t(this,q).querySelector(".ng-container-left .ng-part-body table"),e=t(this,q).querySelector(".ng-container-body .ng-part-body table"),s=t(this,q).querySelector(".ng-container-right .ng-part-body table");if(e){const g=n?Array.from(n.querySelectorAll("tbody tr")):[],y=Array.from(e.querySelectorAll("tbody tr")),x=s?Array.from(s.querySelectorAll("tbody tr")):[],w=Math.max(g.length,y.length,x.length);for(let m=0;m<w;m++){const k=[((a=g[m])==null?void 0:a.getBoundingClientRect().height)||0,((c=y[m])==null?void 0:c.getBoundingClientRect().height)||0,((l=x[m])==null?void 0:l.getBoundingClientRect().height)||0],A=Math.max(...k);A>0&&(g[m]&&(g[m].style.height=`${A}px`),y[m]&&(y[m].style.height=`${A}px`),x[m]&&(x[m].style.height=`${A}px`))}}const r=t(this,q).querySelector(".ng-container-left .ng-part-footer table"),i=t(this,q).querySelector(".ng-container-body .ng-part-footer table"),o=t(this,q).querySelector(".ng-container-right .ng-part-footer table");if(i){const g=r?Array.from(r.querySelectorAll("tfoot tr")):[],y=Array.from(i.querySelectorAll("tfoot tr")),x=o?Array.from(o.querySelectorAll("tfoot tr")):[],w=Math.max(g.length,y.length,x.length);for(let m=0;m<w;m++){const k=[((u=g[m])==null?void 0:u.getBoundingClientRect().height)||0,((f=y[m])==null?void 0:f.getBoundingClientRect().height)||0,((b=x[m])==null?void 0:b.getBoundingClientRect().height)||0],A=Math.max(...k);A>0&&(g[m]&&(g[m].style.height=`${A}px`),y[m]&&(y[m].style.height=`${A}px`),x[m]&&(x[m].style.height=`${A}px`))}}},"#syncRowHeights"));d(this,ae,h(()=>{!t(this,q)||!(t(this,q)instanceof HTMLElement)||(p(this,Q,new ResizeObserver(n=>{for(const e of n){const s=e.target;if(!s.classList.contains("active"))continue;const r=e.contentRect.height;if(r>0){let i=0;const o=s.querySelector(".ng-part-header"),a=s.querySelector(".ng-part-footer");o&&(i+=o.offsetHeight),a&&(i+=a.offsetHeight);const c=Math.max(r-i,100);t(this,ht)!==c&&(p(this,ht,c),t(this,Nt).call(this),t(this,D)!==null&&(t(this,_t).call(this),this.refresh()))}}})),t(this,Q).observe(t(this,q)))},"#initResizeObserver"));d(this,_t,h(()=>{S.log("rowManager.#renderAllContainers"),[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(n=>{const e=t(this,q).querySelector(n);e&&e.querySelector(".ng-part-body tbody.bindable-tbody")&&t(this,oe).call(this,e,n)}),t(this,ce).call(this),t(this,ie).call(this)},"#renderAllContainers"));d(this,vt,h(n=>{var f,b;const e=t(this,D);if(!e||e<=0)return;const s=t(this,lt).data.length;if(s===0)return;const r=((f=t(this,V).get(".ng-container-body"))==null?void 0:f.length)||1,i=t(this,q).querySelector(".ng-container-body .ng-part-body"),o=Math.max(0,s-Math.floor(i.clientHeight/e)),a=Math.min(o,Math.max(0,Math.floor(n/e)));let c=Math.floor(a*e);const l=t(this,ct).firstTr,u=l&&l.dataset.row!==void 0?parseInt(l.dataset.row,10):-1;(b=t(this,ct))==null||b.scrollTables.forEach(g=>{g.style.transform=`translate3d(0, ${c}px, 0)`}),u!==a&&[".ng-container-body",".ng-container-left",".ng-container-right"].forEach(g=>{const y=t(this,q).querySelector(g);if(!y)return;const x=y.querySelector(".ng-part-body tbody.bindable-tbody");if(!x)return;Array.from(x.querySelectorAll("tr:not(.nodata)")).forEach((m,k)=>{const A=a+Math.floor(k/r);if(A>=s){m.style.display="none";return}const N=t(this,lt).data.get(A);m.style.display="",t(this,le).call(this,m,N,A)})})},"#handleScroll"));d(this,le,h((n,e,s)=>{n.dataset.row=s,n.data=e,Array.from(n.cells).forEach((r,i)=>{r.dataset.row=s;const o=Array.from(r.children).find(a=>a.tagName.toLowerCase().startsWith("cell-")||typeof a.refresh=="function");o&&typeof o.refresh=="function"&&o.refresh()})},"#bindRowData"));d(this,ce,h(()=>{var c,l,u;S.log("rowManager.#syncHeaderHeights");const n=t(this,q).querySelector(".ng-container-left .ng-part-header table"),e=t(this,q).querySelector(".ng-container-body .ng-part-header table"),s=t(this,q).querySelector(".ng-container-right .ng-part-header table");if(!e)return;const r=n?Array.from(n.querySelectorAll("tr")):[],i=Array.from(e.querySelectorAll("tr")),o=s?Array.from(s.querySelectorAll("tr")):[],a=Math.max(r.length,i.length,o.length);for(let f=0;f<a;f++){const b=[((c=r[f])==null?void 0:c.getBoundingClientRect().height)||0,((l=i[f])==null?void 0:l.getBoundingClientRect().height)||0,((u=o[f])==null?void 0:u.getBoundingClientRect().height)||0],g=Math.max(...b);g>0&&(r[f]&&(r[f].style.height=`${g}px`),i[f]&&(i[f].style.height=`${g}px`),o[f]&&(o[f].style.height=`${g}px`))}},"#syncHeaderHeights"));C(this,"destroy",h(()=>{t(this,Q)&&(t(this,Q).disconnect(),p(this,Q,null))},"destroy"));p(this,lt,n.getRootNode().host),p(this,q,n),t(this,ae).call(this)}getRowHeight(){return t(this,D)}templateLength(n=".ng-container-body"){var e;return((e=t(this,V).get(n))==null?void 0:e.length)||1}};lt=new WeakMap,q=new WeakMap,ct=new WeakMap,V=new WeakMap,D=new WeakMap,Q=new WeakMap,ht=new WeakMap,Mt=new WeakMap,Xe=new WeakMap,Ke=new WeakMap,ne=new WeakMap,re=new WeakMap,Y=new WeakMap,oe=new WeakMap,Ht=new WeakMap,$t=new WeakMap,Nt=new WeakMap,ie=new WeakMap,ae=new WeakMap,_t=new WeakMap,vt=new WeakMap,le=new WeakMap,ce=new WeakMap,h(Ge,"RowManager");let Le=Ge;const he=class he{static compileAll(n){return Array.isArray(n)?n.map(e=>he.compile(e)):[]}static compile(n){if(!n)return null;const e=h(a=>{a.querySelectorAll("tbody td, tbody th, tfoot td, tfoot th").forEach(l=>{const u=l.getAttribute("cell-type")||"renderer";if(l.children.length>0&&l.firstElementChild.tagName.includes("-"))return;let f=`cell-${u}`;const b=l.getAttribute("data-bind"),g=l.getAttribute("data-expr"),y=l.getAttribute("maxbyte"),x=l.getAttribute("type");let w=[];b&&w.push(`data-bind="${b}"`),g&&w.push(`data-expr="${g}"`),y&&w.push(`maxbyte="${y}"`),x&&w.push(`type="${x}"`),l.innerHTML=`<${f} ${w.join(" ")}></${f}>`}),a.querySelectorAll("tbody td, tfoot td").forEach(l=>{l.setAttribute("tabindex","0")})},"processCellTypes"),s=h(a=>{if(!a.querySelector("colgroup")){const c=a.querySelector("tbody tr")||a.querySelector("tr"),l=c?c.querySelectorAll("th, td").length:1,u=document.createElement("colgroup"),f=Math.max(Math.floor(a.clientWidth/l),100);for(let b=0;b<l;b++){const g=document.createElement("col");g.setAttribute("width",f),u.appendChild(g)}a.prepend(u)}if(!a.querySelector("thead")){const c=document.createElement("thead"),l=a.querySelector("colgroup");l?l.after(c):a.prepend(c)}a.classList.add("nine-table-element")},"ensureTableStructure"),r=h((a,c)=>{const l=Array.from(a.querySelectorAll(c+" tr")),u=Array.from(a.querySelectorAll(c+" th,"+c+" td")),f=l.length;if(f===0||u.length===0)return;let b=0;u.forEach(y=>{b+=y.colSpan||1});const g=Array.from(Array(f),()=>Array(b).fill(null));l.forEach(y=>{const x=y.sectionRowIndex;let w=0;Array.from(y.querySelectorAll("th,td")).forEach(m=>{for(let N=0;N<g[x].length;N++)if(g[x][N]===null){w=N;break}const k=m.rowSpan||1,A=m.colSpan||1;for(let N=0;N<k;N++)for(let B=0;B<A;B++)x+N<f&&w+B<b&&(g[x+N][w+B]=N===0&&B===0?"1":"0")})}),l.forEach(y=>{const x=y.sectionRowIndex;Array.from(y.querySelectorAll("th,td")).forEach(w=>{for(let m=0;m<g[x].length;m++)if(g[x][m]==="1"){w.dataset.col=m,g[x][m]="0";break}})})},"resetColIndex"),i=n.cloneNode(!0);return s(i),e(i),r(i,"thead"),r(i,"tbody"),r(i,"tfoot"),Array.from(i.querySelectorAll("colgroup col")).forEach((a,c)=>{const l=a.getAttribute("fixed");l&&i.querySelectorAll(`thead [data-col="${c}"], tbody [data-col="${c}"], tfoot [data-col="${c}"]`).forEach(u=>{u.setAttribute("fixed",l)})}),i}};h(he,"TableCompiler");let Ie=he;const Ze=class Ze{constructor(n){d(this,K);d(this,_);d(this,X,{startRow:-1,startCol:-1,endRow:-1,endCol:-1});C(this,"render",h(()=>{const{startRow:n,startCol:e,endRow:s,endCol:r}=t(this,X);S.log("🎨 [CellSelection.render] Rendering range ->",t(this,X));const i=t(this,_).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");if(i.forEach(a=>{a.querySelectorAll(".selected, .selected-top, .selected-bottom, .selected-left, .selected-right").forEach(c=>{c.classList.remove("selected","selected-top","selected-bottom","selected-left","selected-right")})}),n<0||e<0){S.log("⚠️ [CellSelection.render] Range is invalid (< 0), skipping render.");return}let o=0;i.forEach(a=>{a.querySelectorAll("tbody tr").forEach(c=>{const{matrixRow:l}=G(this,K,Jt).call(this,c);l<0||c.querySelectorAll("td, th").forEach(u=>{const f=parseInt(u.dataset.col,10);if(isNaN(f))return;const b=parseInt(u.rowSpan||1,10),g=parseInt(u.colSpan||1,10),y=l+b-1,x=f+g-1;y>=n&&l<=s&&x>=e&&f<=r&&(o++,u.classList.add("selected"),S.log(u,n,e,s,r),l<=n&&u.classList.add("selected-top"),y>=s&&u.classList.add("selected-bottom"),f<=e&&u.classList.add("selected-left"),x>=r&&u.classList.add("selected-right"))})})}),S.log(`✨ [CellSelection.render] Total rendered cells marked: ${o}`)},"render"));p(this,_,n),G(this,K,vs).call(this),t(this,_).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body").forEach(s=>{s.addEventListener("scroll",()=>{t(this,X).startRow>=0&&t(this,X).startCol>=0&&this.render()})}),S.log("🎯 [CellSelection] Initialized")}setRange(n,e,s,r){S.log(`🔍 [CellSelection.setRange] Input -> startRow: ${n}, startCol: ${e}, endRow: ${s}, endCol: ${r}`);let i=Math.min(n,s),o=Math.max(n,s),a=Math.min(e,r),c=Math.max(e,r);const l=t(this,_).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body");let u=!0,f=0;for(;u&&f<5;)u=!1,f++,l.forEach(b=>{b.querySelectorAll("tbody tr").forEach(g=>{if(g.classList.contains("nodata"))return;const{matrixRow:y}=G(this,K,Jt).call(this,g);y<0||g.querySelectorAll("td, th").forEach(x=>{const w=parseInt(x.dataset.col,10);if(isNaN(w))return;const m=parseInt(x.rowSpan||1,10),k=parseInt(x.colSpan||1,10),A=y+m-1,N=w+k-1;if(A>=i&&y<=o&&N>=a&&w<=c){const P=Math.min(i,y),ke=Math.max(o,A),ps=Math.min(a,w),ys=Math.max(c,N);(P!==i||ke!==o||ps!==a||ys!==c)&&(i=P,o=ke,a=ps,c=ys,u=!0)}})})});p(this,X,{startRow:i,startCol:a,endRow:o,endCol:c}),S.log("📦 [CellSelection.setRange] Final Range ->",t(this,X)),this.render()}};_=new WeakMap,X=new WeakMap,K=new WeakSet,Jt=h(function(n){if(!n||n.classList.contains("nodata"))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};const e=parseInt(n.dataset.row,10);if(isNaN(e))return{dataRow:-1,subRowIndex:-1,matrixRow:-1};const s=n.closest("tbody"),i=Array.from(s.querySelectorAll("tr:not(.nodata)")).filter(l=>parseInt(l.dataset.row,10)===e),o=i.indexOf(n),a=i.length>0?i.length:1,c=e*a+(o>=0?o:n.sectionRowIndex%a);return{dataRow:e,subRowIndex:o,matrixRow:c}},"#getMatrixRow"),vs=h(function(){const n=t(this,_).querySelector(".ng-container-top");if(!n){S.log("❌ [CellSelection] .ng-container-top not found!");return}n.addEventListener("mousedown",e=>{if(e.button!==0)return;const s=e.target.closest("td, th");if(!s||s.dataset.row===void 0||s.dataset.col===void 0||s.closest("tr").classList.contains("nodata"))return;t(this,_).style.userSelect="none",t(this,_).style.webkitUserSelect="none";const r=s.closest("tr"),{matrixRow:i}=G(this,K,Jt).call(this,r),o=parseInt(s.dataset.col,10);if(i<0){t(this,_).style.userSelect="",t(this,_).style.webkitUserSelect="";return}S.log(`🖱️ [MouseDown Success] startRow: ${i}, startCol: ${o}`),t(this,_).navigation.currentCell=s;let a=i,c=o;const l=h(f=>{const b=document.elementFromPoint(f.clientX,f.clientY);let g=b==null?void 0:b.closest("td, th");if(!g||!t(this,_).contains(g)){const m=t(this,_).querySelectorAll(".ng-part-body tbody tr:not(.nodata) td, .ng-part-body tbody tr:not(.nodata) th");for(const k of m){const A=k.getBoundingClientRect();if(f.clientX>=A.left&&f.clientX<=A.right&&f.clientY>=A.top&&f.clientY<=A.bottom){g=k;break}}}if(!g||g.dataset.row===void 0||g.dataset.col===void 0||g.closest("tr").classList.contains("nodata"))return;const y=g.closest("tr"),{matrixRow:x}=G(this,K,Jt).call(this,y),w=parseInt(g.dataset.col,10);x<0||a===x&&c===w||(a=x,c=w,this.setRange(i,o,x,w))},"onMouseMove"),u=h(()=>{S.log("🖱️ [MouseUp] Drag ended."),t(this,_).style.userSelect="",t(this,_).style.webkitUserSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",u)},"onMouseUp");document.addEventListener("mousemove",l),document.addEventListener("mouseup",u)})},"#initEvents"),h(Ze,"CellSelection");let Me=Ze;const Je=class Je{constructor(n){d(this,ft);d(this,j);d(this,dt,null);d(this,de,-1);d(this,fe,-1);d(this,Ot,h(n=>{const e=[];return n.forEach(s=>e.push(...Array.from(s.querySelectorAll("td")))),e.length===0?null:(e.sort((s,r)=>parseInt(s.dataset.col,10)-parseInt(r.dataset.col,10)),e[e.length-1])},"#getMaxColCell"));d(this,Dt,h((n,e)=>{const s=t(this,ut).call(this,n);if(s.length===0)return e+1;let r=e+1;const i=[];s.forEach(o=>i.push(...Array.from(o.querySelectorAll("td")))),i.sort((o,a)=>parseInt(o.dataset.col,10)-parseInt(a.dataset.col,10));for(const o of i){const a=parseInt(o.dataset.col,10),c=parseInt(o.colSpan||1,10);if(e>=a&&e<a+c){r=a+c;break}}return r},"#getNextCol"));d(this,Wt,h((n,e)=>{const s=t(this,ut).call(this,n);if(s.length===0)return Math.max(0,e-1);let r=-1;const i=[];s.forEach(o=>i.push(...Array.from(o.querySelectorAll("td")))),i.sort((o,a)=>parseInt(o.dataset.col,10)-parseInt(a.dataset.col,10));for(const o of i){const a=parseInt(o.dataset.col,10);if(a<e)r=a;else break}return r},"#getPreviousCol"));d(this,ut,h(n=>{const e=t(this,j).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body"),s=[];return e.forEach(r=>{const i=Array.from(r.querySelectorAll("tbody tr:not(.nodata)"));for(const o of i){const a=parseInt(o.dataset.row,10),c=i.filter(y=>parseInt(y.dataset.row,10)===a),l=c.length>0?c.length:1,u=c.indexOf(o),f=a*l+(u>=0?u:0);if(f===n){s.push(o);break}const b=Array.from(o.querySelectorAll("td"));let g=!1;for(const y of b){const x=parseInt(y.rowSpan||1,10);if(x>1&&n>=f&&n<f+x){s.push(o),g=!0;break}}if(g)break}}),s},"#findTargetTrsByMatrix"));d(this,zt,h((n,e,s,r)=>{const i=t(this,j).querySelectorAll(".ng-container-left .ng-part-body, .ng-container-body .ng-part-body, .ng-container-right .ng-part-body"),o=r!==void 0?r:n*1+e;for(const a of i){const c=Array.from(a.querySelectorAll("tbody tr:not(.nodata)"));for(const l of c){const u=parseInt(l.dataset.row,10),f=c.filter(w=>parseInt(w.dataset.row,10)===u),b=f.length>0?f.length:1,g=f.indexOf(l),y=u*b+(g>=0?g:0),x=Array.from(l.querySelectorAll("td"));for(const w of x){const m=parseInt(w.dataset.col,10),k=parseInt(w.colSpan||1,10),A=parseInt(w.rowSpan||1,10);if(!isNaN(m)&&s>=m&&s<m+k&&o>=y&&o<y+A&&window.getComputedStyle(w).display!=="none")return w}}}return null},"#getNearElement"));p(this,j,n),G(this,ft,Ss).call(this),S.log("🎯 [CellNavigation] Initialized")}get currentCell(){return t(this,dt)}set currentCell(n){if(!n)return;p(this,dt,n),n.focus({preventScroll:!0});const e=parseInt(n.dataset.row,10),s=parseInt(n.dataset.col,10);if(!isNaN(e)&&!isNaN(s)){p(this,de,e),p(this,fe,s);const r=n.closest("tr"),i=r==null?void 0:r.closest("tbody");if(i){const a=Array.from(i.querySelectorAll("tr:not(.nodata)")).filter(f=>parseInt(f.dataset.row,10)===e),c=a.length>0?a.length:1,l=a.indexOf(r),u=e*c+(l>=0?l:0);t(this,j).selection.setRange(u,s,u,s)}}}moveCell(n){var m,k,A,N;if(!t(this,dt))return;const e=t(this,dt),s=e.closest("tr"),r=parseInt(e.dataset.row,10),i=parseInt(e.dataset.col,10),o=s==null?void 0:s.closest("tbody");if(!o)return;const c=Array.from(o.querySelectorAll("tr:not(.nodata)")).filter(B=>parseInt(B.dataset.row,10)===r),l=c.length>0?c.length:1,u=c.indexOf(s),f=r*l+(u>=0?u:0);let b=f,g=i;switch(n.code){case"Tab":if(n.preventDefault(),n.shiftKey){if(g=t(this,Wt).call(this,f,i),g<0&&f>0){b=f-1;const B=t(this,ut).call(this,b),P=t(this,Ot).call(this,B);g=P?parseInt(P.dataset.col,10):0}}else{g=t(this,Dt).call(this,f,i);const B=t(this,ut).call(this,f),P=t(this,Ot).call(this,B),ke=P?parseInt(P.dataset.col,10)+parseInt(P.colSpan||1,10):0;g>=ke&&(b=f+1,g=0)}break;case"ArrowRight":g=t(this,Dt).call(this,f,i);break;case"ArrowLeft":g=t(this,Wt).call(this,f,i);break;case"ArrowDown":n.preventDefault(),b=f+(e.rowSpan||1);break;case"ArrowUp":n.preventDefault(),b=Math.max(0,f-(e.rowSpan||1));break}const y=Math.floor(b/l),x=b%l;let w=t(this,zt).call(this,y,x,g,b);if(w)this.currentCell=w,G(this,ft,bs).call(this,w);else if(y!==r&&y>=0){const B=((k=(m=t(this,j)).getRowHeight)==null?void 0:k.call(m))||40;(N=(A=t(this,j)).scrollToY)==null||N.call(A,y*B),setTimeout(()=>{const P=t(this,zt).call(this,y,x,g,b);P&&(this.currentCell=P,G(this,ft,bs).call(this,P))},0)}}};j=new WeakMap,dt=new WeakMap,de=new WeakMap,fe=new WeakMap,ft=new WeakSet,bs=h(function(n){const e=t(this,j).querySelector(".ng-container-body .ng-part-body");if(!e)return;const s=n.getBoundingClientRect(),r=e.getBoundingClientRect();s.top<r.top?e.scrollTop-=r.top-s.top:s.bottom>r.bottom&&(e.scrollTop+=s.bottom-r.bottom),s.left<r.left?e.scrollLeft-=r.left-s.left:s.right>r.right&&(e.scrollLeft+=s.right-r.right)},"#ensureCellVisible"),Ot=new WeakMap,Dt=new WeakMap,Wt=new WeakMap,ut=new WeakMap,zt=new WeakMap,Ss=h(function(){t(this,j).addEventListener("keydown",n=>{["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n.code)&&this.moveCell(n)})},"#initEvents"),h(Je,"CellNavigation");let He=Je;const Ft=class Ft extends HTMLElement{constructor(){super();d(this,ue);d(this,gt,null);d(this,bt);d(this,Bt);d(this,Pt);C(this,"invalidate",h(()=>{S.log("sheet.invalidate()"),t(this,bt).refresh()},"invalidate"));C(this,"generate",h(e=>{if(S.log("sheet.generate()"),!e)return;p(this,gt,Ie.compile(e)),t(this,ge).call(this),t(this,be).call(this);const s=this.querySelector(".ng-container-body .ng-part-header"),r=this.querySelector(".ng-container-body .ng-part-footer"),i=this.querySelector(".ng-nodata-overlay");s&&i&&(i.style.top=`${s.offsetHeight}px`),r&&i&&(i.style.bottom=`${r.offsetHeight}px`),t(this,bt).initialize(),setTimeout(()=>{var o;(o=this.querySelector("nine-table-hscrollbar"))==null||o.refresh()},0)},"generate"));d(this,ge,h(()=>{[{selector:".ng-container-body",type:null},{selector:".ng-container-left",type:"left"},{selector:".ng-container-right",type:"right"}].forEach(({selector:s,type:r})=>{var i,o,a;(i=this.querySelector(`${s} .ng-part-header`))==null||i.appendChild(t(this,St).call(this,t(this,gt),r,"header")),(o=this.querySelector(`${s} .ng-virtual-spacer`))==null||o.before(t(this,St).call(this,t(this,gt),r,"body")),(a=this.querySelector(`${s} .ng-part-footer`))==null||a.appendChild(t(this,St).call(this,t(this,gt),r,"footer"))})},"#renderSplitContainers"));d(this,be,h(()=>{["left","right","body"].forEach(e=>{const s=this.querySelector(`.ng-container-${e}`),r=s==null?void 0:s.querySelectorAll("table");if(!s||!r||r.length===0)return;let i=0;r[0].querySelectorAll("col").forEach(o=>{const a=parseInt(o.getAttribute("width"),10);isNaN(a)||(i+=a)}),e==="body"?(s.style.flex="1",r.forEach(o=>{o.style.width=`${i}px`,o.style.minWidth=`${i}px`})):(s.style.flex=`0 0 ${i}px`,s.style.width=`${i}px`,r.forEach(o=>{o.style.width=`${i}px`,o.style.minWidth=`${i}px`}))})},"#updateContainerWidths"));d(this,St,h((e,s,r)=>{const i=e.cloneNode(!0),o=i.querySelector("thead"),a=i.querySelector("tbody"),c=i.querySelector("tfoot");if(r==="header"){if(a&&a.remove(),c&&c.remove(),e.querySelector("tbody")){const u=document.createElement("tbody");u.className="fixed-tbody",i.appendChild(u)}}else r==="body"?(o&&o.remove(),c&&c.remove(),a&&(a.className="bindable-tbody")):r==="footer"&&(o&&o.remove(),a&&a.remove());return s==="left"?i.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="left"&&l.remove()}):s==="right"?i.querySelectorAll("col, th, td, tfoot td, tfoot th").forEach(l=>{l.getAttribute("fixed")!=="right"&&l.remove()}):i.querySelectorAll("[fixed=left], [fixed=right]").forEach(l=>{l.remove()}),i},"#createSplitTable"));C(this,"getRowHeight",h(()=>t(this,bt).getRowHeight(),"getRowHeight"));C(this,"scrollToX",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollLeft=e)},"scrollToX"));C(this,"scrollToY",h(e=>{const s=this.querySelector(".ng-container-body .ng-part-body");s&&(s.scrollTop=e)},"scrollToY"));d(this,pe,h(()=>{t(this,ye).call(this),p(this,Bt,new Me(this)),p(this,Pt,new He(this))},"#init"));d(this,ye,h(()=>{const e=Ft.SCROLLBAR_SIZE;this.innerHTML=`
|
|
127
127
|
<style>
|
|
128
128
|
nine-table-sheet {
|
|
129
129
|
display: none;
|