UNPKG

@hitachivantara/uikit-react-core

Version:

Core React components for the NEXT Design System.

33 lines (32 loc) 1.02 kB
import { jsx } from "react/jsx-runtime"; import { HvIcon } from "../icons.js"; import { setId } from "../utils/setId.js"; import { HvDropDownMenu } from "../DropDownMenu/DropDownMenu.js"; const removeExtension = (label) => label.includes(".") ? label.substring(0, label.lastIndexOf(".")) : label; const pathWithSubMenu = (id, listRoute, maxVisible, onClick, dropDownMenuProps) => { const nbrElemToSubMenu = listRoute.length - maxVisible; const subMenuList = listRoute.slice(1, nbrElemToSubMenu + 1); const handleClick = (event, data) => { event.preventDefault(); onClick?.(event, data); }; listRoute.splice( 1, nbrElemToSubMenu, /* @__PURE__ */ jsx( HvDropDownMenu, { id: setId(id, "submenu"), icon: /* @__PURE__ */ jsx(HvIcon, { name: "DotsHorizontal" }), dataList: subMenuList, ...dropDownMenuProps, onClick: onClick != null ? handleClick : void 0 } ) ); return listRoute; }; export { pathWithSubMenu, removeExtension };