// // Copyright 2023 DXOS.org // import { Primitive } from '@radix-ui/react-primitive'; import { Slot } from '@radix-ui/react-slot'; import React, { type ComponentPropsWithoutRef, type ComponentPropsWithRef, forwardRef } from 'react'; import { useThemeContext } from '../../hooks'; import { type ThemedClassName } from '../../util'; import { Icon } from '../Icon'; import { Link, type LinkProps } from '../Link'; type BreadcrumbRootProps = ThemedClassName> & { 'aria-label': string; 'asChild'?: boolean; }; const BreadcrumbRoot = forwardRef( ({ asChild, classNames, ...props }, forwardedRef) => { const { tx } = useThemeContext(); const Comp = asChild ? Slot : Primitive.div; return ; }, ); BreadcrumbRoot.displayName = 'Breadcrumb.Root'; type BreadcrumbListProps = ThemedClassName> & { asChild?: boolean }; const BreadcrumbList = forwardRef( ({ asChild, classNames, ...props }, forwardedRef) => { const { tx } = useThemeContext(); const Comp = asChild ? Slot : Primitive.ol; return ; }, ); BreadcrumbList.displayName = 'Breadcrumb.List'; type BreadcrumbListItemProps = ThemedClassName> & { asChild?: boolean }; const BreadcrumbListItem = forwardRef( ({ asChild, classNames, ...props }, forwardedRef) => { const { tx } = useThemeContext(); const Comp = asChild ? Slot : Primitive.li; return ; }, ); BreadcrumbListItem.displayName = 'Breadcrumb.ListItem'; type BreadcrumbLinkProps = LinkProps; const BreadcrumbLink = forwardRef(({ asChild, ...props }, forwardedRef) => { const Comp = asChild ? Slot : Link; return ; }); BreadcrumbLink.displayName = 'Breadcrumb.Link'; type BreadcrumbCurrentProps = ThemedClassName> & { asChild?: boolean }; const BreadcrumbCurrent = forwardRef( ({ asChild, classNames, ...props }, forwardedRef) => { const { tx } = useThemeContext(); const Comp = asChild ? Slot : 'h1'; return ( ); }, ); BreadcrumbCurrent.displayName = 'Breadcrumb.Current'; type BreadcrumbSeparatorProps = ThemedClassName>; function BreadcrumbSeparator({ children, classNames, ...props }: BreadcrumbSeparatorProps) { const { tx } = useThemeContext(); return ( ); } BreadcrumbSeparator.displayName = 'Breadcrumb.Separator'; export const Breadcrumb = { Root: BreadcrumbRoot, List: BreadcrumbList, ListItem: BreadcrumbListItem, Link: BreadcrumbLink, Current: BreadcrumbCurrent, Separator: BreadcrumbSeparator, }; export type { BreadcrumbCurrentProps, BreadcrumbLinkProps, BreadcrumbListItemProps, BreadcrumbListProps, BreadcrumbRootProps, BreadcrumbSeparatorProps, };