@progress/kendo-react-data-tools
Version:
Includes React Pager & React Filter component, an intuitive interface to create complex filter descriptions. KendoReact Data Tools package
48 lines (47 loc) • 1.71 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
*-------------------------------------------------------------------------------------------
*/
function I(b) {
const { enabled: w, columns: l = [], tableViewPortWidth: x, scrollLeft: g, getColSpan: p, dataItem: C } = b, r = l.map(() => 1), i = l.map(() => !1);
if (!w)
return { colSpans: r, hiddenColumns: i };
const n = l.map((e) => parseFloat((e.width || "").toString()) || 10);
let o = 0;
for (let e = 0; e < l.length; e++) {
if (l[e].locked)
continue;
let f = 1;
if (p !== void 0) {
let c = p(l[e], C);
c > 2 ? f = c - 1 : c === 2 && (f = c);
}
const k = e < n.length - 1 ? n[e + 1] * f : 0;
if (o + n[e] + k < g)
i[e] = !0, o += n[e];
else
break;
}
const S = n.reduce((e, f) => e + f, 0);
o = 0;
for (let e = l.length - 1; e >= 0; e--)
if (!l[e].locked)
if (o + 2 * n[e] < S - x - g)
i[e] = !0, o += n[e];
else
break;
const t = [...i], h = (e) => e;
let s = t.lastIndexOf(!1), m = t.some(h), u = t.every(h), d, a;
for (; m && t.length && (s !== -1 || u); ) {
for (s < t.length - 1 && (d = u ? t.length : t.length - s - 1, a = t.length - d, a === 0 && (a = d - 1), i[a] = !1, r[a] = d, t.splice(s + 1, d)); t.length && !t[t.length - 1]; )
t.pop();
s = t.lastIndexOf(!1), m = t.some(h), u = t.every(h);
}
return { colSpans: r, hiddenColumns: i };
}
export {
I as tableColumnsVirtualization
};