@hitachivantara/uikit-react-core
Version:
UI Kit Core React components.
36 lines (35 loc) • 1.35 kB
JavaScript
import { SelectionContext } from "./utils/SelectionContext.js";
import { FocusProvider } from "./utils/FocusContext.js";
import { HvHeaderMenuBar } from "./MenuBar/MenuBar.js";
import { useClasses } from "./Navigation.styles.js";
import { useSelectionPath } from "./useSelectionPath.js";
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
import { forwardRef } from "react";
import { jsx } from "react/jsx-runtime";
//#region src/Header/Navigation/Navigation.tsx
var HvHeaderNavigation = forwardRef(function HvHeaderNavigation(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
})
}) })
});
});
//#endregion
export { HvHeaderNavigation };