@payfit/unity-components
Version:
54 lines (53 loc) • 1.94 kB
TypeScript
import { VariantProps } from '@payfit/unity-themes';
import { ComponentPropsWithoutRef, ReactElement, ReactNode, Ref } from 'react';
import { BreadcrumbsProps as AriaBreadcrumbsProps } from 'react-aria-components/Breadcrumbs';
import { AriaBreadcrumbsProps as AriaAriaBreadcrumbsProps } from 'react-aria/useBreadcrumbs';
import { Breadcrumb } from './parts/Breadcrumb.js';
import { breadcrumbsVariant } from './Breadcrumbs.variant.js';
type BreadcrumbWrap = VariantProps<typeof breadcrumbsVariant>['wrap'];
export type BreadcrumbType = 'collapsed' | 'non-collapsed';
export interface BreadcrumbsProps extends AriaAriaBreadcrumbsProps, Pick<AriaBreadcrumbsProps<never>, 'onAction'> {
items?: never;
/**
* The breadcrumb list to render (static API)
*/
children: ReactNode;
/**
* Controls breadcrumbs layout: wrap or nowrap
*/
wrap: BreadcrumbWrap;
/**
* Defines breadcrumb rendering strategy.
* @default 'non-collapsed'
*/
type?: BreadcrumbType;
}
export interface BreadcrumbsWithItemProps<TItem extends {
label: string;
}> extends AriaAriaBreadcrumbsProps, VariantProps<typeof breadcrumbsVariant>, Pick<AriaBreadcrumbsProps<TItem>, 'onAction'> {
/**
* The list of items to render, when using the dynamic API.
*/
items: TItem[];
/**
* The render function for each breadcrumb item (dynamic API)
*/
children: (item: TItem) => ReactElement<ComponentPropsWithoutRef<typeof Breadcrumb>>;
/**
* Controls breadcrumbs layout: wrap or nowrap
*/
wrap: BreadcrumbWrap;
/**
* Defines breadcrumb rendering strategy.
* @default 'non-collapsed'
*/
type?: BreadcrumbType;
}
declare const Breadcrumbs: (<TItem extends {
label: string;
}>(props: (BreadcrumbsProps | BreadcrumbsWithItemProps<TItem>) & {
ref?: Ref<HTMLOListElement>;
}) => ReactNode) & {
displayName: string;
};
export { Breadcrumbs };