'use client';
import { ark } from '@ark-ui/react/factory';
import type { ComponentProps, ReactNode } from 'react';
import { createStyleContext } from 'styled-system/jsx';
import { css } from 'styled-system/css';
import { breadcrumb } from 'styled-system/recipes';
const ChevronRightIcon = () => (
);
const { withProvider, withContext } = createStyleContext(breadcrumb);
export type RootProps = ComponentProps;
export const Root = withProvider(ark.nav, 'root', {
defaultProps: { 'aria-label': 'breadcrumb' },
});
export const List = withContext(ark.ol, 'list');
export const Item = withContext(ark.li, 'item');
export interface LinkProps extends ComponentProps {
disabled?: boolean;
}
const LinkBase = withContext(ark.a, 'link');
const LinkDisabled = withContext(ark.span, 'link');
export const Link = ({ disabled, href, ...props }: LinkProps) => {
if (disabled) {
return ;
}
return ;
};
export const Ellipsis = withContext(ark.li, 'ellipsis', {
defaultProps: {
role: 'presentation',
'aria-hidden': true,
children: '...',
},
});
export const Separator = withContext(ark.li, 'separator', {
defaultProps: {
'aria-hidden': true,
children: ,
},
});
/** The current/active page crumb — renders as a span (not a link) with aria-current="page" */
export const CurrentLink = withContext(ark.span, 'link', {
defaultProps: {
'aria-current': 'page',
},
});
// --- Two-row layout support ---
export interface TwoRowRootProps {
children: ReactNode;
/** aria-label for the nav wrapper (default: 'breadcrumb') */
'aria-label'?: string;
className?: string;
}
/** Wrapper nav that stacks the ParentRow above the dynamic breadcrumb */
export const TwoRowRoot = ({
children,
'aria-label': ariaLabel = 'breadcrumb',
className,
}: TwoRowRootProps) => (
);
export interface ParentRowProps {
children: ReactNode;
/**
* Control visibility of the static parent row.
* Defaults to true. Pass false to hide entirely (renders null — no DOM node).
*/
show?: boolean;
}
/** Static parent breadcrumb row rendered above the dynamic row. Hidden when show={false}. */
export const ParentRow = ({ children, show = true }: ParentRowProps) => {
if (!show) return null;
return (
{children}
);
};
/** A single item in the static parent row. Renders as an anchor when href is provided. */
export const ParentItem = ({
children,
href,
}: {
children: ReactNode;
href?: string;
}) => {
const styles = css({
color: 'fg.subtle',
textStyle: 'bodyMedium',
fontWeight: 'light',
textDecoration: 'none',
_hover: href
? { color: 'fg.default', textDecoration: 'underline' }
: undefined,
});
if (href) {
return (
{children}
);
}
return {children};
};
/** Slash separator for the static parent row */
export const ParentSeparator = () => (
/
);