1 | import classNames from 'classnames';
|
2 | import * as React from 'react';
|
3 | import Anchor from '@restart/ui/Anchor';
|
4 | import { useNavItem } from '@restart/ui/NavItem';
|
5 | import { makeEventKey } from '@restart/ui/SelectableContext';
|
6 | import { useBootstrapPrefix } from './ThemeProvider';
|
7 | import { jsx as _jsx } from "react/jsx-runtime";
|
8 | const defaultProps = {
|
9 | disabled: false
|
10 | };
|
11 | const NavLink = 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 _jsx(Component, { ...props,
|
26 | ...navItemProps,
|
27 | ref: ref,
|
28 | className: classNames(className, bsPrefix, props.disabled && 'disabled', meta.isActive && 'active')
|
29 | });
|
30 | });
|
31 | NavLink.displayName = 'NavLink';
|
32 | NavLink.defaultProps = defaultProps;
|
33 | export default NavLink; |
\ | No newline at end of file |