@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
58 lines (57 loc) • 1.77 kB
JavaScript
"use client";
import A from "../../A/index.mjs";
import Icon from "../../Icon/Icon.mjs";
import { styles } from "./style.mjs";
import { memo } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { cx } from "antd-style";
import { ChevronRight } from "lucide-react";
//#region src/base-ui/Breadcrumb/Breadcrumb.tsx
const renderTitle = (item) => {
if (item.href) return /* @__PURE__ */ jsx(A, {
className: styles.link,
href: item.href,
onClick: item.onClick,
children: item.title
});
if (item.onClick) return /* @__PURE__ */ jsx("button", {
className: styles.button,
type: "button",
onClick: item.onClick,
children: item.title
});
return item.title;
};
const Breadcrumb = memo(({ className, classNames, items, ref, separator, styles: customStyles, ...rest }) => {
const separatorNode = separator ?? /* @__PURE__ */ jsx(Icon, {
icon: ChevronRight,
size: 14
});
return /* @__PURE__ */ jsx("nav", {
"aria-label": "breadcrumb",
className: cx(styles.root, className),
ref,
...rest,
children: /* @__PURE__ */ jsx("ol", {
className: styles.list,
children: items.map((item, index) => {
const isLast = index === items.length - 1;
return /* @__PURE__ */ jsxs("li", {
"aria-current": isLast ? "page" : void 0,
className: cx(styles.item, classNames?.item),
style: customStyles?.item,
children: [renderTitle(item), !isLast && /* @__PURE__ */ jsx("span", {
"aria-hidden": "true",
className: cx(styles.separator, classNames?.separator),
style: customStyles?.separator,
children: separatorNode
})]
}, item.key ?? index);
})
})
});
});
Breadcrumb.displayName = "Breadcrumb";
//#endregion
export { Breadcrumb as default };
//# sourceMappingURL=Breadcrumb.mjs.map