@progress/kendo-react-pivotgrid
Version:
React PivotGrid (also called Pivot Table) can be data-bound to an OLAP service and customized extensively. KendoReact PivotGrid package
42 lines (41 loc) • 1.43 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 p from "react";
var u = /* @__PURE__ */ ((r) => (r.toggle = "EXPAND_TOGGLE", r.expand = "EXPAND_EXPAND", r.collapse = "EXPAND_COLLAPSE", r))(u || {});
const E = (r, d, e) => {
switch (d.type) {
case "EXPAND_TOGGLE":
return Array.isArray(r) ? r.find((l) => e(l, d.payload)) ? [...r.filter((l) => !e(l, d.payload))] : [...r, d.payload] : e(r, d.payload) ? null : d.payload;
case "EXPAND_EXPAND":
if (Array.isArray(r)) {
if (!r.find((l) => e(l, d.payload)))
return [...r, d.payload];
} else if (!e(r, d.payload))
return d.payload;
break;
case "EXPAND_COLLAPSE":
if (Array.isArray(r)) {
if (r.find((l) => e(l, d.payload)))
return [...r.filter((l) => !e(l, d.payload))];
} else
e(r, d.payload);
break;
default:
return r;
}
}, s = (r = [], d, e, l = (n, a) => n === a) => {
const [n, a] = p.useState(r);
return [n, (y, i) => {
const f = E(n, y, l);
a(f);
}];
};
export {
u as EXPANSION_ACTION,
s as useExpansion
};