@progress/kendo-vue-grid
Version:
271 lines (270 loc) • 7.96 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
*-------------------------------------------------------------------------------------------
*/
import { tableKeyboardNavigationTools as x } from "@progress/kendo-vue-data-tools";
import { canUseDOM as C } from "@progress/kendo-vue-common";
const c = "string";
function g(e, t) {
const n = e.split(".");
let a = t;
return n.forEach((o) => {
a = a ? a[o] : void 0;
}), a;
}
function b(e, t, n, a, o, h, l = 0) {
let r = l;
for (let i = 0; i < t.length; i++) {
if (!o || t[i].value === void 0 || t[i].items === void 0) {
e[e.length] = {
dataIndex: ++a.index,
dataItem: t[i],
rowType: "data",
level: l,
expanded: h === void 0 || g(h, t[i])
};
continue;
}
r = Math.max(r, l + 1);
const d = h === void 0 || g(h, t[i]) === void 0 || g(h, t[i]);
e[e.length] = {
dataIndex: -1,
dataItem: t[i],
level: l,
rowType: "groupHeader",
expanded: d
}, d && (r = Math.max(
b(e, t[i].items, n, a, o, h, l + 1),
r
)), (n === "always" || d && n === "visible") && (e[e.length] = {
dataIndex: -1,
dataItem: t[i],
rowType: "groupFooter",
level: l,
expanded: d
});
}
return r;
}
function L(e) {
return e && getComputedStyle(e).direction === "rtl" || !1;
}
function M(e, t) {
if (!t || !e || !e.originalEvent || !C)
return -1;
let n = document.elementFromPoint(e.clientX, e.originalEvent.clientY);
for (; n && n.parentElement !== t; )
n = n.parentElement;
const a = t.children;
for (let o = 0; o < a.length; o++)
if (a[o] === n)
return o;
return -1;
}
const p = [
"sortChange",
"filterChange",
"groupChange",
"pageChange",
"expandChange",
"selectionChange",
"headerSelectionChange",
"rowClick",
"itemChange",
"dataStateChange",
"columnResize",
"columnReorder"
], u = {
filterable: !0,
editable: !0,
sortable: !0,
resizable: !0,
reorderable: !0,
groupable: !0
}, S = (e, t) => `The ${e} event handler property is deprecated, use https://www.telerik.com/kendo-vue-ui/components/grid/api/GridProps/#toc-${t} instead`;
function N(e) {
for (let t = 0; t < p.length; t++) {
const n = p[t];
if (e[n] !== void 0) {
const a = "on" + n.charAt(0).toUpperCase() + n.slice(1);
console.warn(S(n, a));
}
}
}
function E(e, t) {
const n = e[t].depth;
let a = null;
for (let o = t + 1; o < e.length; o++)
if (e[o].depth === n) {
a = e[o];
break;
}
return a;
}
function D(e) {
const t = [[]];
let n = 0;
for (let r = e.length - 1; r >= 0; r--)
n = Math.max(n, e[r].depth), e[r].colSpan = e[r].colSpan || 1, e[r].children.length > 0 && (e[r].colSpan = e[r].children.reduce(
(i, d) => d.hidden ? i : i + d.colSpan,
0
));
let a = 1;
e.forEach((r, i) => {
t[r.depth] = t[r.depth] || [];
let d = !1;
t[r.depth].length === 0 && (a <= 1 ? a = 1 + (r.children.length > 0 ? 0 : n - r.depth) : (a--, d = !0)), r.rowSpan = 1 + (r.children.length > 0 ? 0 : n - r.depth), r.kFirst = d, r.index = t[r.depth].length, t[r.depth].push(i);
});
const o = new Array(t.length).fill(0);
let h = 0;
e.forEach((r) => {
if (r.locked)
if (r.left = o[r.depth], h = r.width ? parseFloat(r.width.toString()) : 0, r.children.length === 0)
for (let i = r.depth; i < o.length; i++)
o[i] += h;
else
o[r.depth] += h;
});
const l = new Array(t.length).fill(0);
for (let r = e.length - 1; r >= 0; r--) {
const i = e[r];
if (i.locked) {
if (i.right = l[i.depth], h = i.width ? parseFloat(i.width.toString()) : 0, i.children.length === 0)
for (let s = i.depth; s < l.length; s++)
l[s] += h;
else
l[i.depth] += h;
const d = E(e, r);
i.rightBorder = !(d && d.locked);
}
}
return t;
}
function m(e, t, n, a = 0) {
const o = [], h = e && e.length ? e.length === t.length : !1;
if (!e)
return [];
e && e.length === void 0 && (e = [e]), e.forEach((r, i) => {
r = r;
const d = h && t[i] || null, s = r.children ? r.children.filter((y) => !y.hidden) : r.children, f = m(s, d && d.children || [], n, a + 1);
o.push(
Object.assign(
{ depth: a },
u,
f.length ? { cell: () => null, filterCell: () => null } : {},
d ? { width: d.width, orderIndex: d.orderIndex } : {},
r,
{
id: x.generateNavigatableId(`${n.prevId++}`, n.idPrefix, "column"),
declarationIndex: o.length,
children: f,
rowSpan: 0,
colSpan: 0,
isAccessible: !0
}
)
);
});
const l = (r, i) => r.orderIndex === i.orderIndex ? r.declarationIndex - i.declarationIndex : (r.orderIndex || 0) - (i.orderIndex || 0);
if (o.sort(l), a === 0) {
const r = [], i = (d, s) => d.forEach((f) => {
f.parentIndex = s, i(f.children, r.push(f) - 1);
});
return i(o, -1), r;
}
return o;
}
function G(e, t, n, a) {
let o = [];
Array.isArray(e) ? o = e : e && (o = e.data), o.length || console.warn("Kendo Grid autogeneration of columns is only possible if some items are defined when the component is created.");
const h = [];
if (o.length > 0) {
let l = o[0];
if (t)
for (let i = 0; i < t.length; i++)
l = l.items && l.items[0];
Object.getOwnPropertyNames(l).forEach((i) => {
i !== n && i !== "__ob__" && h.push(Object.assign(
{
id: x.generateNavigatableId(`${a.prevId++}`, a.idPrefix, "column"),
declarationIndex: -1,
parentIndex: -1,
depth: 0,
colSpan: 0,
rowSpan: 0,
index: 0,
left: 0,
right: 0,
children: [],
rightBorder: !1,
ariaColumnIndex: 1,
isAccessible: !0
},
u,
{ field: i }
));
});
}
return h;
}
const k = (e, t) => {
let n = e[t.parentIndex];
for (; n; ) {
if (n.footerCell)
return !0;
n = e[n.parentIndex];
}
return !1;
}, K = (e) => e.filter((t) => k(e, t) ? !1 : !!t.footerCell || !(t.children && t.children.length > 0)), T = {
number: function(e, t, n) {
return typeof e === c && e.toLowerCase() === "null" ? null : t.parseNumber(e, n);
},
date: function(e, t, n) {
return typeof e === c && e.toLowerCase() === "null" ? null : t.parseDate(e, n);
},
boolean: function(e) {
return typeof e === c ? e.toLowerCase() === "null" ? null : e.toLowerCase() === "true" : e != null ? !!e : e;
},
string: function(e) {
return typeof e === c && e.toLowerCase() === "null" ? null : e != null ? e + "" : e;
},
default: function(e) {
return e;
}
};
function w(e, t, n, a) {
return e.forEach((o) => {
o.expanded = t[a] && !t[a].includes(I(o, n)), o.items && o.items.length && (o.items = w(o.items, t, n, a + 1));
}), e;
}
function O(e, t, n) {
return t && t.length && e.data.forEach((a) => {
a.expanded = a.expanded !== void 0 ? a.expanded : t[0] && !t[0].includes(I(a, n)), a.items && a.items.length && (a.items = w(a.items, t, n, 1));
}), e;
}
function I(e, t) {
let n = e;
for (; n.items && n.items.length; )
n = n.items[0];
return t ? n[t] : e.value;
}
const R = typeof window != "undefined" && /Firefox/.test(window.navigator.userAgent), j = 17895697;
export {
O as applyExpandedState,
G as autoGenerateColumns,
N as checkPropCompatibility,
R as firefox,
j as firefoxMaxHeight,
b as flatData,
K as footerColumns,
M as getIndex,
g as getNestedValue,
I as groupedFirstItemValue,
L as isRtl,
D as mapColumns,
T as parsers,
m as readColumns
};