@progress/kendo-vue-data-tools
Version:
9 lines (8 loc) • 2.79 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../navigation/utils.js"),c=require("../../interfaces/ColumnProps.js");function I(t,r){const i=t[r].depth;let n=null;for(let l=r+1;l<t.length;l++)if(t[l].depth===i){n=t[l];break}return n}const g=t=>{let r=t.width?parseFloat(t.width.toString()):0;return!r&&t.children&&t.children.length&&(r=t.children.reduce((i,n)=>g(n)+i,0)),r};function S(t){const r=[[]];let i=0;for(let e=t.length-1;e>=0;e--)i=Math.max(i,t[e].depth),t[e].colSpan=t[e].colSpan||1,t[e].parentIndex!==-1&&(t[t[e].parentIndex].colSpan=(t[t[e].parentIndex].colSpan||0)+t[e].colSpan);const n=[];let l=1;t.forEach((e,d)=>{r[e.depth]=r[e.depth]||[];let o=!1;r[e.depth].length===0&&(l<=1?l=1+(e.children.length>0?0:i-e.depth):(l--,o=!0)),e.rowSpan=1+(e.children.length>0?0:i-e.depth),e.kFirst=o,e.index=r[e.depth].length,r[e.depth].push(d),e.ariaColumnIndex=n[e.depth]?n[e.depth]+1:1;for(let p=e.depth;p<e.depth+e.rowSpan;p++)n[p]=(n[p]||0)+e.colSpan});let h=new Array(r.length).fill(0),a=0;t.forEach(e=>{if(e.locked)if(e.left=h[e.depth],a=g(e),e.children.length===0)for(let d=e.depth;d<h.length;d++)h[d]+=a;else h[e.depth]+=a});let f=new Array(r.length).fill(0);for(let e=t.length-1;e>=0;e--){const d=t[e];if(d.locked){if(d.right=f[d.depth],a=g(d),d.children.length===0)for(let p=d.depth;p<f.length;p++)f[p]+=a;else f[d.depth]+=a;const o=I(t,e);d.rightBorder=!(o&&o.locked)}}return r}function x(t,r,i=0){let n=[];if(!t||!t.length)return[];t.forEach(h=>{const a=x(h.children||[],r,i+1);n.push(Object.assign({},{depth:i},c.ColumnDefaultProps,h,{id:h.id?h.id:s.generateNavigatableId(`${r.prevId++}`,r.idPrefix,"column"),declarationIndex:n.length,children:a,rowSpan:0,colSpan:0,isAccessible:!0}))});const l=(h,a)=>h.orderIndex===a.orderIndex?h.declarationIndex-a.declarationIndex:(h.orderIndex||0)-(a.orderIndex||0);if(n.sort(l),i===0){let h=[];const a=(f,e)=>f.forEach(d=>{d.parentIndex=e,a(d.children,h.push(d)-1)});return a(n,-1),h}return n}function w(t){return!!(t&&getComputedStyle(t).direction==="rtl")}function C(t,r){if(!r||!t||!t.originalEvent)return-1;let i=r.ownerDocument?r.ownerDocument.elementFromPoint(t.clientX,t.originalEvent.clientY):null;for(;i&&i.parentElement!==r;)i=i.parentElement;const n=r.children;for(let l=0;l<n.length;l++)if(n[l]===i)return l;return-1}exports.getIndex=C;exports.isRtl=w;exports.mapColumns=S;exports.readColumns=x;