@progress/kendo-react-grid
Version:
React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package
56 lines (55 loc) • 3.01 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 * as c from "react";
import { validatePackage as k, WatermarkOverlay as v, getter as p } from "@progress/kendo-react-common";
import { packageMetadata as S } from "./package-metadata.mjs";
const x = (o) => {
const { data: a = [] } = o, r = !k(S, { component: "StatusBar" });
return /* @__PURE__ */ c.createElement("div", { className: "k-selection-aggregates k-grid-selection-aggregates" }, a.map((n, i) => /* @__PURE__ */ c.createElement("div", { key: i }, /* @__PURE__ */ c.createElement("span", { className: "k-selection-aggregates-item-text" }, n.type, ": "), /* @__PURE__ */ c.createElement("span", { className: "k-selection-aggregates-item-value" }, n.formattedValue))), r && /* @__PURE__ */ c.createElement(v, null));
};
x.displayName = "KendoReactGridStatusBar";
const D = (o) => {
var r;
const a = o.slice();
for (let n = 0; n < a.length; n++)
for (; a[n] && ((r = a[n].children) != null && r.length); )
a.splice(n, 1, ...a[n].children);
return a;
}, w = (o) => {
const { dataItems: a, target: r } = o, i = D(r.columns).map((e) => e.field).filter((e) => e && typeof e == "string").map(
(e) => p(e)
), b = (e) => o.select[p(o.dataItemKey)(e)], t = { dates: [], numbers: [], booleans: [], others: [] }, y = (e) => {
typeof e == "number" ? t.numbers.push(e) : typeof e == "boolean" ? t.booleans.push(e) : e instanceof Date ? t.dates.push(e) : t.others.push(e);
};
a.forEach((e) => {
const s = b(e);
Array.isArray(s) && s.forEach((l) => {
y(i[l](e));
});
});
const g = t.dates.map((e) => e.getTime()), d = t.booleans.filter((e) => e).length, u = t.booleans.filter((e) => !e).length, m = t.numbers.length ? t.numbers.reduce((e, s) => e + s, 0) : void 0, h = {
sum: m,
average: typeof m == "number" ? m / t.numbers.length : void 0,
min: t.numbers.length ? Math.min(...t.numbers) : void 0,
max: t.numbers.length ? Math.max(...t.numbers) : void 0,
count: t.numbers.length + t.booleans.length + t.dates.length + t.others.length,
isTrue: d > 0 ? d : void 0,
isFalse: u > 0 ? u : void 0,
earliest: t.dates.length ? new Date(Math.min(...g)) : void 0,
latest: t.dates.length ? new Date(Math.max(...g)) : void 0
}, E = (e, s) => (s === "sum" || s === "average") && typeof e == "number" ? e.toFixed(2) : (s === "earliest" || s === "latest") && e instanceof Date ? e.toLocaleDateString() : String(e), f = [];
return Object.keys(h).forEach((e) => {
const s = e, l = h[s];
l !== void 0 && f.push({ type: s, value: l, formattedValue: E(l, s) });
}), f;
};
export {
x as StatusBar,
w as getStatusData,
D as leafColumns
};