@payfit/unity-components
Version:
53 lines (52 loc) • 3.05 kB
TypeScript
import { RegisteredRouter, ValidateLinkOptions } from '@tanstack/react-router';
import { NavItemProps as RawNavItemProps } from '../../../../components/nav/parts/RawNavItem.js';
type NavItemRouterProps<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown> = Omit<RawNavItemProps, 'prefix' | 'suffix' | 'href' | 'onPress'> & ValidateLinkOptions<TRouter, TOptions> & {
prefixElement?: RawNavItemProps['prefix'];
suffixElement?: RawNavItemProps['suffix'];
};
type NavItemButtonProps = Omit<RawNavItemProps, 'prefix' | 'suffix' | 'href'> & {
prefixElement?: RawNavItemProps['prefix'];
suffixElement?: RawNavItemProps['suffix'];
onPress: NonNullable<RawNavItemProps['onPress']>;
};
export type NavItemProps<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown> = NavItemRouterProps<TRouter, TOptions> | NavItemButtonProps;
/**
* A navigation item component that integrates with Tanstack Router for seamless navigation.
* Provides both link-based routing and button-based actions within navigation menus, automatically adapting based on the props provided.
* @param {NavItemProps} props - Either router-based props (with 'to') or button-based props (with 'onPress')
* @example
* ```tsx
* import { NavItem } from '@payfit/unity-components/integrations/tanstack-router'
* import { Nav } from '@payfit/unity-components'
*
* function Navigation() {
* return (
* <Nav title="Main navigation">
* <NavItem to="/dashboard" prefixElement={<Icon src="DashboardOutlined" />}>
* Dashboard
* </NavItem>
* <NavItem onPress={() => console.log('Action')}>
* Action
* </NavItem>
* </Nav>
* )
* }
* ```
* @remarks
* - Automatically renders as a link when 'to' prop is provided, or as a button when 'onPress' is provided
* - Supports type-safe route parameters, search params, and relative navigation with Tanstack Router
* - Integrates with Nav component for consistent navigation UI patterns
* - Provides automatic active state styling based on current route
* - Supports icon prefixes and suffixes via prefixElement and suffixElement props
* - Maintains all accessibility features from the underlying RawNavItem component
* @see {@link NavItemProps} for all available props
* @see Source code in {@link https://github.com/PayFit/hr-apps/tree/master/libs/shared/unity/components/src/integrations/tanstack-router/components/nav-item GitHub}
* @see Design specs {@link https://www.figma.com/design/poaMyU7abAgL9VRhx4ygyy/Unity-DS-%3E-Components-Library Figma}
* @see Design docs in {@link https://www.payfit.design/ Payfit.design}
* @see Developer docs in {@link https://unity-components.payfit.io/?path=/ unity-components.payfit.io}
*/
declare function NavItem<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown>({ prefixElement, suffixElement, ...rest }: NavItemProps<TRouter, TOptions>): import("react/jsx-runtime").JSX.Element;
declare namespace NavItem {
var displayName: string;
}
export { NavItem };