synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
115 lines (114 loc) • 2.78 kB
JavaScript
import { jsx as a } from "react/jsx-runtime";
import { ComplexMenu as A } from "../../../menu/ComplexMenu.js";
import f from "../../../IconSvg/IconSvg.js";
function p(i, o) {
return Object.fromEntries(
Object.entries(i).filter(([e, n]) => !n || !n.visible ? !1 : ![
...o.buttonActions,
...o.primaryMenuActions.flat(),
...o.downloadMenuActions.flat()
].some(
(u) => u.action === e
))
);
}
function m(i, o) {
return i.reduce(
(e, n) => {
const t = o[n.action];
return t && t.visible && e.push({
text: t.text ?? n.action,
onClick: t.onClick,
href: t.href,
tooltipText: t.tooltipText,
disabled: t.disabled,
icon: n.icon,
textSx: n.textSx,
iconSx: n.iconSx
}), e;
},
[]
);
}
function d(i, o) {
return i.reduce(
(e, n) => {
const t = m(n, o);
return t.length > 0 && e.push(t), e;
},
[]
);
}
function I(i) {
const { actionConfiguration: o, menuConfiguration: e, layout: n } = i, t = p(o, n);
Object.entries(t).length > 0 && (console.warn(
"Actions are visible but have not been configured in the layout:",
Object.entries(t).map((c) => c[0])
), n.primaryMenuActions.unshift(
Object.entries(t).map(
(c) => ({
action: c[0]
})
)
));
const u = n.buttonActions.reduce(
(c, s) => {
const r = o[s.action];
if (r && r.visible) {
let l = r.onClick;
l == null && !r.href && (console.warn(`No handler registered for ${s.action}`), l = () => {
console.warn(`No handler registered for ${s.action}`);
}), c.push({
icon: s.icon,
onClick: l,
tooltipText: r.text,
disabled: r.disabled,
href: r.href
});
}
return c;
},
[]
), b = {
dropdownButtonText: "Download Options",
convertSingleItemToButton: !0,
renderMenuIfNoItems: !1,
buttonTooltip: e.DOWNLOAD.tooltipText,
buttonProps: {
disabled: e.DOWNLOAD.disabled,
endIcon: /* @__PURE__ */ a(f, { icon: "download", wrap: !1 })
},
items: d(
n.downloadMenuActions,
o
)
}, x = {
dropdownButtonText: n.primaryMenuText,
convertSingleItemToButton: !0,
renderMenuIfNoItems: !1,
buttonProps: {
endIcon: /* @__PURE__ */ a(f, { icon: n.primaryMenuEndIcon, wrap: !1 })
},
items: d(
n.primaryMenuActions,
o
)
};
return /* @__PURE__ */ a(
A,
{
iconButtons: u,
dropdownMenus: [b, x]
}
);
}
const T = {
getUnmappedActions: p,
mapAndFilterItemsInMenuGroup: m,
mapAndFilterMenuGroups: d
};
export {
T as EXPORTED_FOR_UNIT_TESTING,
I as default
};
//# sourceMappingURL=EntityActionMenu.js.map