@payfit/unity-components
Version:
52 lines (51 loc) • 3.36 kB
TypeScript
import { RegisteredRouter, ValidateLinkOptions } from '@tanstack/react-router';
import { RawListViewItemProps } from '../../../../../components/list-view/parts/RawListViewItem.js';
type ListViewItemRouterProps<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown> = Omit<RawListViewItemProps<object>, 'prefix' | 'suffix' | 'href'> & ValidateLinkOptions<TRouter, TOptions> & {
prefixElement?: RawListViewItemProps<object>['prefix'];
suffixElement?: RawListViewItemProps<object>['suffix'];
};
type ListViewItemHrefProps = Omit<RawListViewItemProps<object>, 'prefix' | 'suffix'> & {
prefixElement?: RawListViewItemProps<object>['prefix'];
suffixElement?: RawListViewItemProps<object>['suffix'];
href: string;
};
export type ListViewItemProps<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown> = ListViewItemRouterProps<TRouter, TOptions> | ListViewItemHrefProps;
/**
* Unity's ListViewItem 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 {ListViewItemProps} props - Either router-based props (with 'to') or direct link props (with 'href')
* @example
* ```tsx
* import { ListView } from '@payfit/unity-components'
* import { ListViewItem } from '@payfit/unity-components/integrations/tanstack-router'
* import { ListViewItemLabel } from '@payfit/unity-components'
*
* function DocumentsList() {
* return (
* <ListView aria-label="Documents">
* <ListViewItem to="/documents/$id" params={{ id: '123' }}>
* <ListViewItemLabel>Document 123</ListViewItemLabel>
* </ListViewItem>
* </ListView>
* )
* }
* ```
* @remarks
* - Automatically renders as a router link when 'to' prop is provided, or as a standard link when 'href' is provided
* - Supports type-safe route parameters, search params, and relative navigation with Tanstack Router
* - Provides automatic route preloading on hover or mount via the `preload` prop
* - Integrates seamlessly with ListView component for list-based navigation UI patterns
* - Supports icon prefixes and suffixes via prefixElement and suffixElement props
* - Maintains all accessibility features and styling options from the underlying RawListViewItem component
* - Use `hideDisclosureIndicator` to hide the default disclosure arrow for non-navigational items
* @see {@link ListViewItemProps} 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/list-view-item GitHub}
* @see Design specs {@link https://www.figma.com/design/poaMyU7abAgL9VRhx4ygyy/Unity-DS-%3E-Components-Library?node-id=15306-115&m=dev Figma}
* @see Design docs in {@link https://www.payfit.design/ Payfit.design}
* @see Developer docs in {@link https://unity-components.payfit.io/?path=/docs/component-reference-listview--docs unity-components.payfit.io}
*/
declare function ListViewItem<TRouter extends RegisteredRouter = RegisteredRouter, TOptions = unknown>({ prefixElement, suffixElement, ...rest }: ListViewItemProps<TRouter, TOptions>): import("react/jsx-runtime").JSX.Element;
declare namespace ListViewItem {
var displayName: string;
}
export { ListViewItem };