@progress/kendo-vue-charts
Version:
72 lines (71 loc) • 2.17 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
*-------------------------------------------------------------------------------------------
*/
const i = (s, e) => e.chartCollectionIdxKey ? o.collectionConfigurationItem(s, e) : e.chartKey ? o.configurationItem(s, e) : {}, u = (s, e) => {
if (e.type)
switch (e.type) {
case "set":
return o.themeItem(s, e);
case "push":
return Object.assign(s, e.payload);
default:
return s;
}
else
return {};
}, f = (s, e) => {
if (e.type)
switch (e.type) {
case "add":
return [...s, e.payload];
case "remove":
return s.filter((l) => l !== e.payload);
default:
return s;
}
else
return [];
}, o = {
configurationItem(s, e) {
return s[e.chartKey] && Object.keys(s[e.chartKey]).length ? Object.assign(s, {
[e.chartKey]: {
...s[e.chartKey],
...e.payload
}
}) : Object.assign(s, {
[e.chartKey]: e.payload
});
},
collectionConfigurationItem(s, e) {
let l = !1;
const [d, n] = e.chartCollectionIdxKey.split("_"), t = (e.parentKey ? s[e.parentKey] ? s[e.parentKey][d] || [] : [] : s[d] || []).map((r, p) => parseInt(n, 10) === p || e.payload && e.payload.uid === r.uid ? (l = !0, e.payload) : r);
if (l === !1 && !e.uid && t.splice(parseInt(n, 10), 0, e.payload), e.uid) {
const r = t.findIndex((p) => p.uid === e.uid);
r > -1 && t.splice(r, 1);
}
return e.parentKey ? Object.assign(s, {
[e.parentKey]: {
[d]: t
}
}) : Object.assign(s, {
[d]: t
});
},
themeItem(s, e) {
let l = {};
const d = Object.assign(l, s), { field: n, value: y } = e.payload, t = n.split(".");
let r = t.shift();
for (; t.length > 0; )
l = l[r] = l[r] || {}, r = t.shift();
return l[r] = y, d;
}
};
export {
f as observersReducer,
i as optionsReducer,
u as themeReducer
};