UNPKG

@payfit/unity-components

Version:

53 lines (52 loc) 2.49 kB
import { RegisteredRouter, ValidateLinkOptions } from '@tanstack/react-router'; import { ReactNode } from 'react'; import { TabProps as RawTabProps } from '../../../../../components/tabs/parts/RawTab.js'; type TabProps<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown> = Omit<RawTabProps, 'onPress' | 'children' | 'suffix' | 'id'> & ValidateLinkOptions<TRouter, TOptions> & { children?: ReactNode; suffixElement?: RawTabProps['suffix']; id?: RawTabProps['id']; }; /** * A tab component that integrates with Tanstack Router for navigation. * Provides seamless routing capabilities for tab-based navigation interfaces. * @param props - Either router-based props (with 'to') or button-based props (with 'onPress') * @example * ```tsx * import { Tab } from '@payfit/unity-components/integrations/tanstack-router' * * function NavigationTabs() { * return ( * <Tabs> * <TabList aria-label="Main navigation"> * <Tab to="/dashboard" id="dashboard"> * Dashboard * </Tab> * <Tab to="/employees" id="employees"> * Employees * </Tab> * <Tab onPress={() => alert('Action triggered')} id="action"> * Perform Action * </Tab> * </TabList> * </Tabs> * ) * } * ``` * @remarks * - When 'to' prop is provided, the component renders as a router link * - When 'onPress' prop is provided (without 'to'), it renders as a button * - Supports all Tanstack Router link features like preloading, search params, and route params * - Maintains accessibility features from the underlying RawTab component * - Must be used within a TabsProvider context for proper styling and behavior * @see {@link TabProps} 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/tabs 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 Tab<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown>(props: TabProps<TRouter, TOptions>): import("react/jsx-runtime").JSX.Element; declare namespace Tab { var displayName: string; } export { Tab }; export type { TabProps };