UNPKG

@payfit/unity-components

Version:

74 lines (73 loc) 4.19 kB
import { RegisteredRouter, ValidateLinkOptions } from '@tanstack/react-router'; import { NavigationCardProps as RawNavigationCardProps } from '../../../../components/navigation-card/NavigationCard.js'; type NavigationCardRouterProps<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown> = Omit<RawNavigationCardProps, 'asElement' | 'prefix' | 'suffix'> & ValidateLinkOptions<TRouter, TOptions> & { prefixElement?: RawNavigationCardProps['prefix']; suffixElement?: RawNavigationCardProps['suffix']; }; type NavigationCardButtonProps = Omit<RawNavigationCardProps, 'asElement' | 'prefix' | 'suffix' | 'href'> & { prefixElement?: RawNavigationCardProps['prefix']; suffixElement?: RawNavigationCardProps['suffix']; onPress: NonNullable<RawNavigationCardProps['onPress']>; }; export type NavigationCardProps<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown> = NavigationCardRouterProps<TRouter, TOptions> | NavigationCardButtonProps; /** * Unity's NavigationCard that integrates with Tanstack Router for seamless client-side navigation. * Enables declarative routing with type-safe route parameters, search params, and automatic preloading capabilities. * @param {NavigationCardProps} props - Either router-based props (with 'to') or button-based props (with 'onPress') * @example * ```tsx * import { NavigationCard } from '@payfit/unity-components/integrations/tanstack-router' * import { Icon } from '@payfit/unity-components' * import { NavigationCardLabel } from '@payfit/unity-components' * import { NavigationCardDescription } from '@payfit/unity-components' * * // Router mode - navigation card as a link * function NavigationWithLink() { * return ( * <NavigationCard * to="/dashboard" * prefixElement={<Icon src="LayoutDashboardOutlined" size={24} />} * > * <div> * <NavigationCardLabel>Dashboard</NavigationCardLabel> * <NavigationCardDescription> * View your analytics * </NavigationCardDescription> * </div> * </NavigationCard> * ) * } * * // Button mode - navigation card as a button * function NavigationWithButton() { * return ( * <NavigationCard * onPress={() => console.log('Clicked')} * prefixElement={<Icon src="PlusOutlined" size={24} />} * > * <Text variant="h4">Add New</Text> * </NavigationCard> * ) * } * ``` * @remarks * - Automatically renders as a link when 'to' prop is provided, or as a button when 'onPress' is provided * - Supports type-safe navigation with route parameters and search params via `params` and `search` props * - Provides automatic route preloading on hover or mount via the `preload` prop * - Handles relative and absolute paths with `from` and `to` props for flexible routing * - Integrates seamlessly with Tanstack Router's navigation system and loader functions * - Maintains all accessibility features and styling options from the underlying RawNavigationCard component * - Automatically detects external URLs and applies appropriate security attributes (target="_blank", rel="noopener noreferrer") * - Supports both `compact` and `comfortable` variants for different layout needs * - Use `prefixElement` and `suffixElement` props to add icons or other elements to the card * @see {@link NavigationCardProps} 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/navigation-card 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 NavigationCard<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown>({ prefixElement, suffixElement, ...rest }: NavigationCardProps<TRouter, TOptions>): import("react/jsx-runtime").JSX.Element; declare namespace NavigationCard { var displayName: string; } export { NavigationCard };