@progress/kendo-vue-grid
Version:
357 lines (356 loc) • 11.2 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2026 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import { findGroupExpand as H, updateLeft as T, updateRight as O, tableKeyboardNavigationTools as R } from "@progress/kendo-vue-data-tools";
import { getter as E, canUseDOM as F } from "@progress/kendo-vue-common";
import { gridDefaultProps as b } from "../GridColumn.mjs";
const S = "string";
function v(e, t) {
const r = e.split(".");
let n = t;
return r.forEach((a) => {
n = n ? n[a] : void 0;
}), n;
}
function k(e, t, r, n, a, d, i, o, h, f, g = 0, l) {
let c = g;
for (let p = 0; p < t.length; p++) {
let s;
if (!a || t[p].value === void 0 || t[p].items === void 0) {
const w = h ? !!(d != null && d[E(h)(t[p])]) : !1;
e[e.length] = {
dataIndex: n.index,
dataItem: t[p],
rowType: "data",
level: g,
group: l,
// This is related to detail-row expansion
expanded: f !== void 0 ? v(f, t[p]) : w != null ? w : !1
}, n.index++;
continue;
} else {
let w;
l != null && l.parents ? w = [{ field: l.field, value: l.value }, ...l.parents] : l ? w = [l] : w = [], s = {
field: t[p].field,
value: t[p].value,
parents: w
};
}
c = Math.max(c, g + 1);
let x = !1;
const u = H(i || [], s);
f ? x = f === void 0 || v(f, t[p]) === void 0 || v(f, t[p]) : x = u ? u.expanded !== !1 : o !== !1, e[e.length] = {
dataIndex: -1,
dataItem: t[p],
level: g,
group: s,
rowType: "groupHeader",
expanded: x
}, x && (s.expanded = x, c = Math.max(
k(
e,
t[p].items,
r,
n,
a,
d,
i,
o,
h,
f,
g + 1,
s
),
c
)), (r === "always" || x && r === "visible") && (e[e.length] = {
dataIndex: -1,
dataItem: t[p],
rowType: "groupFooter",
level: g,
expanded: x
});
}
return c;
}
function W(e) {
return e && getComputedStyle(e).direction === "rtl" || !1;
}
function X(e, t) {
if (!t || !e || !e.originalEvent || !F)
return -1;
let r = document.elementFromPoint(e.clientX, e.originalEvent.clientY);
for (; r && r.parentElement !== t; )
r = r.parentElement;
const n = t.children;
for (let a = 0; a < n.length; a++)
if (n[a] === r)
return a;
return -1;
}
const A = [
"sortChange",
"filterChange",
"groupChange",
"pageChange",
"expandChange",
"selectionChange",
"headerSelectionChange",
"rowClick",
"itemChange",
"dataStateChange",
"columnResize",
"columnReorder"
], L = (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 Y(e) {
for (let t = 0; t < A.length; t++) {
const r = A[t];
if (e[r] !== void 0) {
const n = "on" + r.charAt(0).toUpperCase() + r.slice(1);
console.warn(L(r, n));
}
}
}
function J(e, t) {
const r = [[]];
let n = 0;
for (let i = e.length - 1; i >= 0; i--)
n = Math.max(n, e[i].depth), e[i].headerColSpan = e[i].headerColSpan || 1, e[i].children.length > 0 && (e[i].headerColSpan = e[i].children.reduce(
(o, h) => h.hidden ? o : o + h.headerColSpan,
0
));
const a = [];
let d = 1;
return e.forEach((i, o) => {
r[i.depth] = r[i.depth] || [];
let h = !1;
r[i.depth].length === 0 && (d <= 1 ? d = 1 + (i.children.length > 0 ? 0 : n - i.depth) : (d--, h = !0)), i.rowSpan = 1 + (i.children.length > 0 ? 0 : n - i.depth), i.kFirst = h, i.index = r[i.depth].length, i.ariaColumnIndex = a[i.depth] ? a[i.depth] + 1 : 1;
let f = 0;
const g = [], l = /* @__PURE__ */ new Set();
let c = i.parentIndex;
for (; c >= 0 && !l.has(c); )
l.add(c), g.unshift(c), c = e[c].parentIndex;
for (let s = 0; s < g.length; s++) {
const x = g[s], u = e[x], w = r[u.depth], y = w.indexOf(x);
for (let I = 0; I < y; I++) {
const C = w[I];
f += e[C].headerColSpan;
}
}
for (let s = 0; s < i.depth; s++) {
const x = r[s] || [], w = (r[i.depth] || []).indexOf(o);
let y = 0;
for (const I of x) {
const C = e[I];
y < w && C.depth + C.rowSpan - 1 >= i.depth && (g.includes(I) || (f += C.headerColSpan)), y += C.headerColSpan;
}
}
const p = r[i.depth];
for (const s of p) {
const x = e[s];
x.parentIndex === i.parentIndex && (f += x.headerColSpan);
}
i.virtualColumnOffset = f, r[i.depth].push(o);
for (let s = i.depth; s < i.depth + i.rowSpan; s++)
a[s] = (a[s] || 0) + i.headerColSpan;
}), T(r, e, t), O(r, e, t), r;
}
function N(e, t, r, n = 0, a = !1) {
const d = [];
if (!e)
return [];
e && e.length === void 0 && (e = [e]), e.forEach((o, h) => {
o = o;
const f = o.id ? o.id : R.generateNavigatableId(`${r.prevId++}`, r.idPrefix, "column"), g = F && o.media && window.matchMedia ? !window.matchMedia(o.media).matches : !1, l = a || g || o.hidden, c = t == null ? void 0 : t.find((s) => s.id === f), p = N(o.children, (c == null ? void 0 : c.children) || [], r, n + 1, l);
d.push(
{
depth: n,
...b,
...p.length ? { cell: () => null, filterCell: () => null } : {},
...o,
id: f,
declarationIndex: d.length,
children: p,
headerColSpan: 0,
rowSpan: 0,
columnType: o.columnType || "data",
colSpan: o.colSpan || 1,
isAccessible: !0,
hidden: l,
left: null,
right: null,
rowSpannable: o.rowSpannable,
...c ? { width: c.width, orderIndex: c.orderIndex } : {}
}
);
});
const i = (o, h) => o.orderIndex === h.orderIndex ? o.declarationIndex - h.declarationIndex : (o.orderIndex || 0) - (h.orderIndex || 0);
if (d.sort(i), n === 0) {
const o = [], h = (f, g) => f.forEach((l) => {
l.parentIndex = g, h(l.children, o.push(l) - 1);
});
return h(d, -1), o;
}
return d;
}
const j = (e) => Array.isArray(e) ? e : e ? e.data : [];
function Q(e, t, r, n) {
const a = j(e), d = [];
if (a.length > 0) {
let i = a[0];
if (t)
for (let h = 0; h < t.length; h++)
i = i.items && i.items[0];
Object.getOwnPropertyNames(i).forEach((h) => {
h !== r.column && d.push(
{
id: R.generateNavigatableId(`${n.prevId++}`, n.idPrefix, "column"),
declarationIndex: -1,
parentIndex: -1,
depth: 0,
colSpan: 0,
headerColSpan: 0,
rowSpan: 0,
index: 0,
columnType: "data",
left: 0,
right: 0,
rightBorder: !1,
children: [],
ariaColumnIndex: 0,
isAccessible: !0,
...b,
field: h
}
);
});
}
return d;
}
const $ = (e, t) => {
var n;
let r = e[t.parentIndex];
for (; r; ) {
if (r.footerCell || (n = r.cells) != null && n.footerCell)
return !0;
r = e[r.parentIndex];
}
return !1;
}, Z = (e) => e.filter((t) => {
var r;
return $(e, t) ? !1 : !!(t.footerCell || (r = t.cells) != null && r.footerCell) || !(t.children && t.children.length > 0);
}), _ = {
number: function(e, t, r) {
return typeof e === S && e.toLowerCase() === "null" ? null : t.parseNumber(e, r);
},
date: function(e, t, r) {
return typeof e === S && e.toLowerCase() === "null" ? null : t.parseDate(e, r);
},
boolean: function(e) {
return typeof e === S ? e.toLowerCase() === "null" ? null : e.toLowerCase() === "true" : e != null ? !!e : e;
},
string: function(e) {
return typeof e === S && e.toLowerCase() === "null" ? null : e != null ? e + "" : e;
},
default: function(e) {
return e;
}
};
function M(e, t, r, n) {
return e.forEach((a) => {
a.expanded = t[n] && !t[n].includes(D(a, r)), a.items && a.items.length && (a.items = M(a.items, t, r, n + 1));
}), e;
}
function q(e, t, r) {
return t && t.length && e.data.forEach((n) => {
n.expanded = n.expanded !== void 0 ? n.expanded : t[0] && !t[0].includes(D(n, r)), n.items && n.items.length && (n.items = M(n.items, t, r, 1));
}), e;
}
function D(e, t) {
let r = e;
for (; r.items && r.items.length; )
r = r.items[0];
return t ? r[t] : e.value;
}
const G = (e) => {
const t = [], r = (n) => n == null ? void 0 : n.forEach((a) => {
t.push(a), r(a.children);
});
return r(e), t;
}, m = typeof window != "undefined" && /Firefox/.test(window.navigator.userAgent), ee = 17895697, te = (e) => e.width !== void 0 ? Math.floor(parseFloat(e.width.toString())) + "px" : void 0, re = (e, t) => t && t.filter((r) => r.field === e).length > 0, B = (e) => (e.sort((t, r) => t.declarationIndex - r.declarationIndex), e.map((t) => {
const { declarationIndex: r, parentIndex: n, depth: a, headerColSpan: d, rowSpan: i, index: o, kFirst: h, children: f, ...g } = t;
return f.length ? {
children: B(f),
...g
} : g;
})), ne = (e, t) => typeof e.colSpan == "function" ? e.colSpan({ dataItem: t, column: e }) : e.colSpan || 1, ie = (e) => {
var n, a;
const t = typeof e == "object" ? (n = e.enabled) != null ? n : !0 : e != null ? e : !1, r = typeof e == "object" ? (a = e.valueGetter) != null ? a : ((d, i) => E(i)(d)) : (d, i) => E(i)(d);
return { enabled: t, valueGetter: r };
}, ae = (e) => {
let t = 0;
if (e) {
const r = e.insertRow(0), n = r.insertCell(0);
n.textContent = " ", t = r.getBoundingClientRect().height, e.deleteRow(0);
}
return t;
}, oe = (e, t) => {
var r, n, a, d, i, o;
if (!(!e && !t))
return t ? e ? {
headerCell: (r = t.headerCell) != null ? r : e.headerCell,
filterCell: (n = t.filterCell) != null ? n : e.filterCell,
footerCell: (a = t.footerCell) != null ? a : e.footerCell,
groupHeader: (d = t.groupHeader) != null ? d : e.groupHeader,
data: (i = t.data) != null ? i : e.data,
groupFooter: (o = t.groupFooter) != null ? o : e.groupFooter,
select: {
...e.select || {},
...t.select || {}
},
hierarchy: {
...e.hierarchy || {},
...t.hierarchy || {}
},
group: {
...e.group || {},
...t.group || {}
},
edit: {
...e.edit || {},
...t.edit || {}
},
pin: {
...e.pin || {},
...t.pin || {}
}
} : t : e;
};
export {
q as applyExpandedState,
Q as autoGenerateColumns,
ae as calcRowHeight,
Y as checkPropCompatibility,
m as firefox,
ee as firefoxMaxHeight,
k as flatData,
Z as footerColumns,
ne as getColSpan,
te as getColumnWidth,
j as getDataAsArray,
G as getFlatColumnsState,
X as getIndex,
v as getNestedValue,
ie as getRowSpanOptions,
D as groupedFirstItemValue,
W as isRtl,
re as isSorted,
J as mapColumns,
_ as parsers,
N as readColumns,
oe as resolveCells,
B as sanitizeColumns
};