import { useContext } from "react"; import type { FC, MouseEvent, ReactElement } from "react"; import type { IComponentBaseProps } from "../../../types/components"; import { Icon } from "../../icon"; import type { INavigationItem } from "../config/types"; import { NavigationContext } from "../context"; /** * Компонент элемента навигации. * @returns {ReactElement} Элемент навигации. */ export const NavigationItem: FC = (props = {}): ReactElement => { const { getCN, handleClick } = useContext(NavigationContext); const { children, name, onClick = handleClick, href = "", extraClasses = {}, extraAttrs = {}, title, icon = "icon-next", iconSize = "medium", isPrev, isNext, isDisabled = false, } = props; const classes = { isDisabled, isPrev, isNext, ...extraClasses, }; const onLinkClick = isDisabled ? undefined : (event: MouseEvent) => onClick({ event, data: props }); let content = children; if (!content) { if (isDisabled) { content =
; } else if (name) { content = ( ); } else { content = ( ); } } return (
  • {content}
  • ); };