UNPKG

982 BJavaScriptView Raw
1import classNames from 'classnames';
2import * as React from 'react';
3import Anchor from '@restart/ui/Anchor';
4import { useNavItem } from '@restart/ui/NavItem';
5import { makeEventKey } from '@restart/ui/SelectableContext';
6import { useBootstrapPrefix } from './ThemeProvider';
7import { jsx as _jsx } from "react/jsx-runtime";
8const defaultProps = {
9 disabled: false
10};
11const NavLink = /*#__PURE__*/React.forwardRef(({
12 bsPrefix,
13 className,
14 as: Component = Anchor,
15 active,
16 eventKey,
17 ...props
18}, ref) => {
19 bsPrefix = useBootstrapPrefix(bsPrefix, 'nav-link');
20 const [navItemProps, meta] = useNavItem({
21 key: makeEventKey(eventKey, props.href),
22 active,
23 ...props
24 });
25 return /*#__PURE__*/_jsx(Component, { ...props,
26 ...navItemProps,
27 ref: ref,
28 className: classNames(className, bsPrefix, props.disabled && 'disabled', meta.isActive && 'active')
29 });
30});
31NavLink.displayName = 'NavLink';
32NavLink.defaultProps = defaultProps;
33export default NavLink;
\No newline at end of file