UNPKG

@progress/kendo-react-common

Version:

React Common package delivers common utilities that can be used with the KendoReact UI components. KendoReact Common Utilities package

47 lines (46 loc) 1.31 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ function f(t, n, r) { return r ? { ...t, [n]: r.length ? [...r] : void 0 } : t && t[n] ? [...t[n]] : []; } function a(t, n, r) { if (t[n]) { const e = f(t, n).map( (o) => a(o, n, r) ); return r(f(t, n, e)); } return r(t); } const i = (t, n, r) => [...t.map((e) => a(e, n, r))], u = (t, n, r, e) => { let o = t; const h = []; for (let c = 0; c < n.length; c++) o = o[n[c]], o = Array.isArray(o) ? o : o[r], h.push(o); const p = h.length > 1 ? h[h.length - 2] : t, g = n[n.length - 1], s = e(p[g]); p.splice(g, 1, s); }, w = (t, n, r) => Object.assign( {}, t, t[n] ? { [n]: t[n].slice() } : {}, r || {} ), x = (t, n, r) => { const e = [], o = [...n]; if (o.length) { let h = t[o.shift() || 0]; for (e.push(h); o.length && r; ) h = h[r][o.shift() || 0], e.push(h); } return e; }; export { w as extendDataItem, x as getItemPath, i as mapTree, u as mapTreeItem };