@hitachivantara/uikit-react-core
Version:
Core React components for the NEXT Design System.
41 lines (40 loc) • 1.44 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import { forwardRef } from "react";
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
import { useClasses } from "./Navigation.styles.js";
import { staticClasses } from "./Navigation.styles.js";
import { useSelectionPath } from "./useSelectionPath.js";
import { FocusProvider } from "./utils/FocusContext.js";
import { SelectionContext } from "./utils/SelectionContext.js";
import { HvHeaderMenuBar } from "./MenuBar/MenuBar.js";
const HvHeaderNavigation = forwardRef(function HvHeaderNavigation2(props, ref) {
const {
data,
selected,
onClick,
className,
classes: classesProp,
levels = 2,
...others
} = useDefaultProps("HvHeaderNavigation", props);
const { classes, cx } = useClasses(classesProp);
const selectionPath = useSelectionPath(data, selected);
const handleClick = (event, selection) => {
event.preventDefault();
onClick?.(event, selection);
};
return /* @__PURE__ */ jsx(SelectionContext.Provider, { value: selectionPath, children: /* @__PURE__ */ jsx(FocusProvider, { children: /* @__PURE__ */ jsx("nav", { ref, className: cx(classes.root, className), ...others, children: /* @__PURE__ */ jsx(
HvHeaderMenuBar,
{
data,
type: "menubar",
onClick: handleClick,
levels,
currentLevel: 1
}
) }) }) });
});
export {
HvHeaderNavigation,
staticClasses as headerNavigationClasses
};