import React from 'react' import Button from '../../Button/Button' import Icon from '../../Icons/Icon' import Mdash from '../../Mdash/Mdash' import Popover from '../../Popover/Popover' import { trimText } from '../../../services/HelperServiceTyped' import { BreadcrumbArrow, BreadcrumbPopoverContent, TextUnderline, } from '../Common/BreadcrumbCommonComponents' import { type BreadcrumbsProps } from '../Common/BreadcrumbTypes' import styles from './_mobile-breadcrumb.module.scss' import { breadcrumbBackButtonCallout } from '../Common/BreadcrumbsService' import { c } from '../../../translations/LibraryTranslationService' const MobileBreadcrumbs = ({ breadcrumbs, callout, characterLimit = 11, // Mobile Breadcrumbs have a default character limit of 11. This can be overridden by passing in a `characterLimit` to Breadcrumbs. backButtonProps, textUnderlineCharacterLimit = 30, // Mobile Breadcrumbs have a default character limit of 30. This can be overridden by passing in a `textUnderlineCharacterLimit` to Breadcrumbs. qaTestId = 'mobile-breadcrumbs', }: BreadcrumbsProps): React.JSX.Element => { const isBreadcrumbLengthLessThanThree = breadcrumbs.length < 3 type BreadCrumbWithArrowType = { className: string name: string /** Optionally pass in a character limit */ charLimit?: number } const BreadcrumbWithArrow = ({ className, name, }: BreadCrumbWithArrowType): React.JSX.Element => ( {trimText(name, characterLimit)} ) return (
{breadcrumbs.length > 1 ? ( backButtonProps?.confirmation ? ( ) : ( ) ) : null} {/* Display the breadcrumbs when there are less than 3 breadcrumbs */} {isBreadcrumbLengthLessThanThree ? (
{breadcrumbs.map((b, i) => { if (b.name) { if (breadcrumbs.length - 1 !== i) { const bStyles = breadcrumbs.length === 2 ? styles.twoLevelBreadcrumbPosition : styles.breadcrumbPosition return ( ) } else { return ( ) } } else { return } })}
) : ( // When there are more than 3 breadcrumbs we need a popover to display all of the breadcrumbs. It will appear as +2 More... ( setVisible(false)} callout={callout} /> )} > {({ setVisible }) => (
setVisible(true)}>
{breadcrumbs?.length === 3 ? ( ) : ( )}
)}
)}
) } export default MobileBreadcrumbs