import React from 'react'; import { ChevronrightIcon } from '../../components/icons'; import { Breadcrumbs as RACBreadcrumbs, Breadcrumb as RACBreadcrumb, type BreadcrumbProps, type BreadcrumbsProps as RACBreadcrumbsProps, type LinkProps, } from 'react-aria-components'; import { twMerge } from 'tailwind-merge'; import { Link } from '../Link/Link.quanta'; import { composeTailwindRenderProps } from '../utils'; export interface Breadcrumb { '@id': string; title: string; icon?: React.ReactNode; } export function Breadcrumb( props: BreadcrumbProps & Omit & { separator?: React.ReactNode; value?: Breadcrumb; }, ) { return ( svg]:mx-1 [&_a>svg]:inline [&_a>svg]:align-text-top `, )} > {({ isCurrent }) => ( <> {props.value?.icon && props.value?.icon} {!isCurrent && (props.separator ?? ( ))} )} ); } interface BreadcrumbsProps extends RACBreadcrumbsProps { /** * If we should include a root item in the breadcrumbs, we provide a Breadcrumb object. */ root?: Breadcrumb; /** * Icon component to be used for the root item */ homeIcon?: React.ReactNode | boolean | null | undefined; } export function Breadcrumbs(props: BreadcrumbsProps) { // eslint-disable-next-line @typescript-eslint/no-unused-vars const { root, items, homeIcon } = props; let itemsWithRoot: typeof items; // if (root && items) { // const rootItem = { // '@id': root['@id'] || '/', // title: 'Home', // icon: root.icon || , // } as T; // itemsWithRoot = [rootItem, ...items!]; // } if (root && items) { const icon: React.ReactNode = null; // if (homeIcon === true) { // icon = ; // } else if (homeIcon && typeof homeIcon !== 'boolean') { // icon = homeIcon; // JSX node // } const rootItem = { '@id': root['@id'] || '/', title: 'Home', icon: icon, } as T; itemsWithRoot = [rootItem, ...items!]; } return ( ); }