@@ -7,15 +7,13 @@ import { useOUIAProps, OUIAProps } from '../../helpers';
77import { Popper } from '../../helpers/Popper/Popper' ;
88import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon' ;
99
10- export interface NavItemProps extends Omit < React . HTMLProps < HTMLAnchorElement > , 'onClick' > , OUIAProps {
10+ interface CommonNavItemProps extends Omit < React . HTMLProps < HTMLAnchorElement > , 'onClick' > , OUIAProps {
1111 /** Content rendered inside the nav item. */
1212 children ?: React . ReactNode ;
1313 /** Whether to set className on children when React.isValidElement(children) */
1414 styleChildren ?: boolean ;
1515 /** Additional classes added to the nav item */
1616 className ?: string ;
17- /** Target navigation link */
18- to ?: string ;
1917 /** Flag indicating whether the item is active */
2018 isActive ?: boolean ;
2119 /** Group identifier, will be returned with the onToggle and onSelect callback passed to the Nav component */
@@ -28,8 +26,6 @@ export interface NavItemProps extends Omit<React.HTMLProps<HTMLAnchorElement>, '
2826 onClick ?: NavSelectClickHandler ;
2927 /** Component used to render NavItems if React.isValidElement(children) is false */
3028 component ?: React . ReactNode ;
31- /** Flyout of a nav item. This should be a Menu component. */
32- flyout ?: React . ReactElement ;
3329 /** Callback when flyout is opened or closed */
3430 onShowFlyout ?: ( ) => void ;
3531 /** @beta Opt-in for updated popper that does not use findDOMNode. */
@@ -40,6 +36,22 @@ export interface NavItemProps extends Omit<React.HTMLProps<HTMLAnchorElement>, '
4036 ouiaSafe ?: boolean ;
4137}
4238
39+ type ConditionalNavItemProps =
40+ | {
41+ /** Target navigation link */
42+ to ?: string ;
43+ /** Flyout of a nav item. Disallowed if nav link is defined */
44+ flyout ?: never ;
45+ }
46+ | {
47+ /** Target navigation link. Disallowed if flyout is defined */
48+ to ?: never ;
49+ /** Flyout of a nav item. This should be a Menu component. */
50+ flyout ?: React . ReactNode ;
51+ } ;
52+
53+ export type NavItemProps = CommonNavItemProps & ConditionalNavItemProps ;
54+
4355export const NavItem : React . FunctionComponent < NavItemProps > = ( {
4456 children,
4557 styleChildren = true ,
0 commit comments