UNPKG

@progress/kendo-vue-grid

Version:
9 lines (8 loc) 3.44 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2026 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function B(d,n,e){let a=0,u=!1;if(e>0&&n)for(let t=0;t<e;t++){const c=n[t]||[];for(let p=0;p<c.length;p++){const h=c[p],S=d[h];(S.rowSpan||1)>e-t&&(a+=S.headerColSpan||1,p===0&&(u=!0))}}return{emptyColSpan:a,skipOffset:u}}function E(d,n){const e=d[n];return!e||e.parentIndex<0?[]:[e.parentIndex,...E(d,e.parentIndex)]}function L(d,n,e){n.forEach(a=>{E(d,a).forEach(t=>e.add(t))})}function w(d,n,e){var u;const a=d[n];((u=a==null?void 0:a.children)==null?void 0:u.length)>0&&a.children.forEach(t=>{let c=typeof t=="number"?t:d.indexOf(t);c>=0&&!e.has(c)&&(e.add(c),w(d,c,e))})}function j(d){const{cellsToRender:n,columns:e,rowIndex:a,enableVirtualization:u,columnsMap:t}=d;if(!u||!n||n.length===0)return{columnsToRender:[],colSpans:[]};const c=[],p=[];let h=-1,S=-1;function m(o,r){let s=-1,i=-1;for(let f=0;f<r.length;f++)o[r[f]].locked||(s===-1&&(s=f),i=f);return{first:s,last:i}}const O=n.reduce((o,r)=>o+r.colSpan,0);let R=0;for(const o of n){const r=e[o.columnIndex];if(r!=null&&r.locked)R+=o.colSpan;else break}const l=O-R;let V=[],x=[];const P=e.filter(o=>o.children.length===0),A=new Map;e.forEach((o,r)=>{if(o.children.length===0){const s=P.findIndex(i=>i===o);s>=0&&A.set(s,r)}});const C=new Set;if(n.forEach(o=>{const r=A.get(o.columnIndex);if(r!==void 0){C.add(r);const s=E(e,r);s.forEach(i=>C.add(i)),L(e,s,C),w(e,r,C),s.forEach(i=>{w(e,i,C)})}}),t&&Array.isArray(t)){for(let o=0;o<t.length;o++)V[o]=t[o].filter(r=>C.has(r));x=V[a]||[]}const M=m(e,x);h=M.first,S=M.last;let U=0;for(let o=0;o<h;o++){const r=e[x[o]];r!=null&&r.locked&&(U+=r.headerColSpan||1)}let v=0,y=0,F=!1;return x.forEach((o,r)=>{c.push(o);const s=e[o],i=(s==null?void 0:s.headerColSpan)||1;let f;if(h===S)f=l;else if(r===h){const T=(s==null?void 0:s.virtualColumnOffset)||0,{emptyColSpan:k,skipOffset:g}=B(e,V,a);y+=k;const I=Math.max(0,T-U);g&&(y+=I,F=!0),I>0&&!g?f=i+I:f=i}else if(r===S){let T=r===x.length-1;if(t!=null&&t[a]){const k=t[a],g=o;let I=-1;for(let b=k.length-1;b>=0;b--)if(!e[k[b]].locked){I=k[b];break}T=g===I}if(T)f=i;else{const k=l-v-y;if(f=Math.max(k,i),i>k&&p.length>0){const g=i-k;p[0]-=g}}}else f=i;p.push(f),v+=f}),{columnsToRender:c,colSpans:p,skipOffset:F}}function D(d){const{cellModels:n,columns:e=[],tableViewPortWidth:a,scrollLeft:u}=d;let t=0,c=n.length-1,p=0,h=0;for(let l=0;l<n.length;l++)if(!e[n[l].columnIndex].locked&&(p=h,h+=n[l].width||10,h>=u)){t=l;break}for(let l=t;l<n.length;l++)if(!e[n[l].columnIndex].locked)if(p<a+u)p+=n[l].width||10,c=l;else break;t>0&&t--,c<n.length-1&&c++;let S=0,m=0;for(let l=0;l<t;l++)e[n[l].columnIndex].locked||(S+=n[l].colSpan);for(let l=c+1;l<n.length;l++)e[n[l].columnIndex].locked||(m+=n[l].colSpan);n[t].colSpan+=S,n[c].colSpan+=m;const O=n.slice(0,t).filter(l=>e[l.columnIndex].locked),R=n.slice(c+1).filter(l=>e[l.columnIndex].locked);return[...O,...n.slice(t,c+1),...R]}exports.addAllAncestors=L;exports.addDescendants=w;exports.getParentIndices=E;exports.getVirtualCellsToRender=D;exports.getVirtualHeaderCellsToRender=j;