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) 2.05 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"});class a{constructor(e){this.columns=[],this.resizable=!1,this.isRtl=!1,this.setIsRtl=h=>{this.isRtl=h},this.onResize=e,this.dragHandler=this.dragHandler.bind(this)}dragHandler(e,h,l,s){const n=e.originalEvent;s||(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation());const t=l.parentElement;if(!t||!t.parentElement)return;const i=t.clientWidth;let o;if(this.isRtl?(o=l.getBoundingClientRect().right-l.offsetWidth/2-e.clientX,o+=i):o=i+e.clientX-l.getBoundingClientRect().left-l.offsetWidth/2,!s&&Math.abs(o-i)<1)return;this.setWidths(h,Math.floor(o)/i);const r=this.columns.filter(d=>!d.children.length).indexOf(h);this.onResize(r,i,o,n,s)}setWidths(e,h){const l=this.columns.indexOf(e),s=[];let n=e.children.length;for(let t=l+1;t<this.columns.length&&!(n<=0);t++){const i=this.columns[t];i.children.length?n+=i.children.length:s.push(i),n--}s.length===0&&s.push(e),s.forEach(t=>{let i=t.width?parseFloat(t.width.toString())*h:0;const o=t.minResizableWidth===void 0?10:t.minResizableWidth;i<o&&(i=o),t.width=Math.floor(i)}),this.updateColElements(s)}updateColElements(e){const h=this.columns.filter(s=>!s.children.length);let l=1e-10;for(let s=0;s<e.length;s++){const n=h.indexOf(e[s]),t=parseFloat((e[s].width||0).toString());l+=t-Math.floor(t);const i=Math.floor(t)+Math.floor(l);l-=Math.floor(l),this.setColWidth(this.colGroupMain&&this.colGroupMain.children[n],i),this.setColWidth(this.colGroupHeader&&this.colGroupHeader.children[n],i),this.setColWidth(this.colGroupFooter&&this.colGroupFooter.children[n],i)}}setColWidth(e,h){e&&(e.style.width=h+"px")}}exports.ColumnResize=a;