UNPKG

@progress/kendo-react-data-tools

Version:

Includes React Pager & React Filter component, an intuitive interface to create complex filter descriptions. KendoReact Data Tools package

9 lines (8 loc) 3.13 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 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"});const x=require("../../navigation/utils.js"),w=require("../ColumnProps.js");function p(t,n){const d=t[n].depth;let i=null;for(let h=n+1;h<t.length;h++)if(t[h].depth===d){i=t[h];break}return i}const f=t=>{let n=t.width?parseFloat(t.width.toString()):0;return!n&&t.children&&t.children.length&&(n=t.children.reduce((d,i)=>f(i)+d,0)),n};function S(t,n){const d=[[]];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].children.length>0&&(t[e].colSpan=t[e].children.reduce((l,a)=>a.hidden?l:l+a.colSpan,0));const h=[];let r=1;return t.forEach((e,l)=>{d[e.depth]=d[e.depth]||[];let a=!1;d[e.depth].length===0&&(r<=1?r=1+(e.children.length>0?0:i-e.depth):(r--,a=!0)),e.rowSpan=1+(e.children.length>0?0:i-e.depth),e.kFirst=a,e.index=d[e.depth].length,d[e.depth].push(l),e.ariaColumnIndex=h[e.depth]?h[e.depth]+1:1;for(let o=e.depth;o<e.depth+e.rowSpan;o++)h[o]=(h[o]||0)+e.colSpan}),g(d,t,n),c(d,t,n),d}function g(t,n,d){const i=new Array(t.length).fill(0);let h=0;n.forEach(r=>{if(r.locked&&(!r.left||d))if(r.left=i[r.depth],h=f(r),r.children.length===0)for(let e=r.depth;e<i.length;e++)i[e]+=h;else i[r.depth]+=h})}function c(t,n,d){let i=0;const h=new Array(t.length).fill(0);for(let r=n.length-1;r>=0;r--){const e=n[r];if(e.locked&&(!e.right||d)){if(e.right=h[e.depth],i=f(e),e.children.length===0)for(let a=e.depth;a<h.length;a++)h[a]+=i;else h[e.depth]+=i;const l=p(n,r);e.rightBorder=!(l&&l.locked)}}}function s(t,n,d=0){const i=[];if(!t||!t.length)return[];t.forEach(r=>{const e=s(r.children||[],n,d+1);i.push(Object.assign({},{depth:d},w.ColumnDefaultProps,r,{id:r.id?r.id:x.generateNavigatableId(`${n.prevId++}`,n.idPrefix,"column"),declarationIndex:i.length,children:e,rowSpan:0,colSpan:0,isAccessible:!0}))});const h=(r,e)=>r.orderIndex===e.orderIndex?r.declarationIndex-e.declarationIndex:(r.orderIndex||0)-(e.orderIndex||0);if(i.sort(h),d===0){const r=[],e=(l,a)=>l.forEach(o=>{o.parentIndex=a,e(o.children,r.push(o)-1)});return e(i,-1),r}return i}function y(t){return!!(t&&getComputedStyle(t).direction==="rtl")}function I(t,n){if(!n||!t||!t.originalEvent)return-1;const d={x:t.clientX,y:t.originalEvent.clientY};let i=n.ownerDocument?n.ownerDocument.elementFromPoint(d.x,d.y):null;for(;i&&i.parentElement!==n;)i=i.parentElement;if(!i&&n.matches("tr")){const r=e=>{const l=e.getBoundingClientRect();return d.x>l.left&&d.x<l.left+l.width&&d.y>l.top&&d.y<l.top+l.height};i=Array.from(n.children).find(r)||null}const h=n.children;for(let r=0;r<h.length;r++)if(h[r]===i)return r;return-1}exports.getIndex=I;exports.isRtl=y;exports.mapColumns=S;exports.nextColumn=p;exports.readColumns=s;exports.updateLeft=g;exports.updateRight=c;