@progress/kendo-react-dropdowns
Version:
React DropDowns offer an interface for users to select different items from a list and more. KendoReact Dropdowns package
67 lines (66 loc) • 1.97 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 { getter as V } from "@progress/kendo-react-common";
const a = (l, f) => {
const i = {};
return l && l.length && l.forEach((g) => {
i[f(g)] = !0;
}), i;
}, E = (l, f) => {
const { items: i, dataItemKey: g, value: u, subItemsField: x = "items", operation: w } = f, t = V(g), I = a(u, t);
if (w === "clear")
return [];
if (w === "delete") {
const n = a(i, t);
return u.filter((e) => !n[t(e)]);
}
const G = i[0], C = t(G), d = V(x), h = [...l], c = [];
let b = [], m;
for (; h.length; ) {
const n = h.pop();
if (C === t(n)) {
b = c.map((e) => e.item), m = n;
break;
} else {
c && c.length && c[c.length - 1].parentPosition === h.length && c.pop();
const e = d(n);
e && e.length && (c.push({ item: n, parentPosition: h.length }), h.push(...e));
}
}
const k = [...d(m) || []], M = [];
for (; k.length; ) {
const n = k.pop();
M.push(n);
const e = d(n);
e && e.length && k.push(...e);
}
const L = !I[C], o = [];
if (L) {
o.push(...u), o.push(m), o.push(...M.filter((s) => !I[t(s)]));
const n = b.filter((s) => !I[t(s)]), e = a(o, t);
for (let s = n.length - 1; s > -1; s--) {
const p = n[s], r = d(p);
if (r.filter((P) => e[t(P)]).length < r.length)
break;
o.push(p), e[t(p)] = !0;
}
} else {
const n = t(m), e = a(M, t), s = a(b, t);
o.push(
...u.filter((p) => {
const r = t(p);
return !e[r] && n !== r && !s[r];
})
);
}
return o;
};
export {
E as getMultiSelectTreeValue,
a as getValueMap
};