import { localePath } from '@ermnvldmr/i18n'; import { cn } from '@ermnvldmr/stl'; import { ChevronRight } from 'lucide-react'; import React, { memo } from 'react'; import { HStack } from '../HStack/HStack'; import { Text } from '../Text/Text'; import type { HStackProps } from '../HStack/HStack'; import type { ClassNameProps, TestIdProps } from '@ermnvldmr/stl'; /** * Props for the Breadcrumbs component. */ export interface BreadcrumbsProps extends HStackProps { /** Breadcrumb items and separators */ children: React.ReactNode; } /** * Root component for hierarchical navigation. */ const BreadcrumbsRoot = memo(function Breadcrumbs({ children, ...props }: BreadcrumbsProps) { return ( ); }); /** * Props for the individual Breadcrumbs item. */ export interface BreadcrumbsItemProps extends TestIdProps { /** Content to be rendered inside the item */ children: React.ReactNode; /** Optional className for the list item */ className?: string; /** Whether this is the current page */ isCurrent?: boolean; /** Optional href for the item (renders as a link) */ href?: string; /** Optional click handler for the item */ onClick?: React.MouseEventHandler; } /** * Individual step in the breadcrumb trail. */ const BreadcrumbsItem = memo(function BreadcrumbsItem({ children, className, isCurrent, href, onClick, 'data-testid': testId, }: BreadcrumbsItemProps) { const resolvedHref = localePath(href); const isClickable = !!(resolvedHref ?? onClick); return (
  • {children}
  • ); }); /** * Visual divider between breadcrumb items. */ export interface BreadcrumbsSeparatorProps extends ClassNameProps, TestIdProps { /** Visual variant of the separator */ variant?: 'slash' | 'bull' | 'arrow'; } const BreadcrumbsSeparator = memo(function BreadcrumbsSeparator({ variant = 'slash', className, 'data-testid': testId, }: BreadcrumbsSeparatorProps) { const content = { slash: '/', bull: '•', arrow: , }; return ( ); }); /** * A hierarchical navigation component. * * Breadcrumbs provides a flexible way to display the current location within * a site's hierarchy. It uses a compound component pattern for maximum flexibility. * * @example * ```tsx * * Home * * Current Page * * ``` */ export const Breadcrumbs = Object.assign(BreadcrumbsRoot, { Item: BreadcrumbsItem, Separator: BreadcrumbsSeparator, });