UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

1 lines • 3.02 kB
{"version":3,"file":"Breadcrumb.mjs","names":[],"sources":["../../../src/base-ui/Breadcrumb/Breadcrumb.tsx"],"sourcesContent":["'use client';\n\nimport { cx } from 'antd-style';\nimport { ChevronRight } from 'lucide-react';\nimport { memo, type ReactNode } from 'react';\n\nimport A from '@/A';\nimport Icon from '@/Icon';\n\nimport { styles } from './style';\nimport type { BreadcrumbItem, BreadcrumbProps } from './type';\n\nconst renderTitle = (item: BreadcrumbItem): ReactNode => {\n if (item.href) {\n return (\n <A className={styles.link} href={item.href} onClick={item.onClick}>\n {item.title}\n </A>\n );\n }\n\n if (item.onClick) {\n return (\n <button className={styles.button} type=\"button\" onClick={item.onClick}>\n {item.title}\n </button>\n );\n }\n\n return item.title;\n};\n\nconst Breadcrumb = memo<BreadcrumbProps>(\n ({ className, classNames, items, ref, separator, styles: customStyles, ...rest }) => {\n const separatorNode = separator ?? <Icon icon={ChevronRight} size={14} />;\n\n return (\n <nav aria-label=\"breadcrumb\" className={cx(styles.root, className)} ref={ref} {...rest}>\n <ol className={styles.list}>\n {items.map((item, index) => {\n const isLast = index === items.length - 1;\n\n return (\n <li\n aria-current={isLast ? 'page' : undefined}\n className={cx(styles.item, classNames?.item)}\n key={item.key ?? index}\n style={customStyles?.item}\n >\n {renderTitle(item)}\n {!isLast && (\n <span\n aria-hidden=\"true\"\n className={cx(styles.separator, classNames?.separator)}\n style={customStyles?.separator}\n >\n {separatorNode}\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n },\n);\n\nBreadcrumb.displayName = 'Breadcrumb';\n\nexport default Breadcrumb;\n"],"mappings":";;;;;;;;;AAYA,MAAM,eAAe,SAAoC;CACvD,IAAI,KAAK,MACP,OACE,oBAAC,GAAD;EAAG,WAAW,OAAO;EAAM,MAAM,KAAK;EAAM,SAAS,KAAK;EACvD,UAAA,KAAK;CACL,CAAA;CAIP,IAAI,KAAK,SACP,OACE,oBAAC,UAAD;EAAQ,WAAW,OAAO;EAAQ,MAAK;EAAS,SAAS,KAAK;EAC3D,UAAA,KAAK;CACA,CAAA;CAIZ,OAAO,KAAK;AACd;AAEA,MAAM,aAAa,MAChB,EAAE,WAAW,YAAY,OAAO,KAAK,WAAW,QAAQ,cAAc,GAAG,WAAW;CACnF,MAAM,gBAAgB,aAAa,oBAAC,MAAD;EAAM,MAAM;EAAc,MAAM;CAAK,CAAA;CAExE,OACE,oBAAC,OAAD;EAAK,cAAW;EAAa,WAAW,GAAG,OAAO,MAAM,SAAS;EAAQ;EAAK,GAAI;EAChF,UAAA,oBAAC,MAAD;GAAI,WAAW,OAAO;GACnB,UAAA,MAAM,KAAK,MAAM,UAAU;IAC1B,MAAM,SAAS,UAAU,MAAM,SAAS;IAExC,OACE,qBAAC,MAAD;KACE,gBAAc,SAAS,SAAS,KAAA;KAChC,WAAW,GAAG,OAAO,MAAM,YAAY,IAAI;KAE3C,OAAO,cAAc;KAJvB,UAAA,CAMG,YAAY,IAAI,GAChB,CAAC,UACA,oBAAC,QAAD;MACE,eAAY;MACZ,WAAW,GAAG,OAAO,WAAW,YAAY,SAAS;MACrD,OAAO,cAAc;MAEpB,UAAA;KACG,CAAA,CAEN;IAbG,GAAA,KAAK,OAAO,KAaf;GAER,CAAC;EACC,CAAA;CACD,CAAA;AAET,CACF;AAEA,WAAW,cAAc"}