@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
74 lines (73 loc) • 2.39 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 { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
import { cx } from "antd-style";
//#region src/base-ui/List/ListRow.tsx
const ListRow = memo(({ active, classNames, item, onSelect, styles: customStyles }) => {
const { actions, avatar, danger, description, disabled, extra, href, icon, label, showAction } = item;
const handleClick = (event) => {
if (disabled) {
event.preventDefault();
return;
}
onSelect(item, event);
};
const rowClassName = cx(styles.row, active && styles.active, danger && styles.danger, disabled && styles.disabled, classNames?.item, item.className);
const rowStyle = {
...customStyles?.item,
...item.style
};
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
avatar ?? (icon ? /* @__PURE__ */ jsx(Icon, {
icon,
size: 16
}) : null),
/* @__PURE__ */ jsxs("span", {
className: styles.body,
children: [/* @__PURE__ */ jsx("span", {
className: cx(styles.label, classNames?.label),
style: customStyles?.label,
children: label
}), description != null && /* @__PURE__ */ jsx("span", {
className: cx(styles.description, classNames?.description),
style: customStyles?.description,
children: description
})]
}),
extra != null && /* @__PURE__ */ jsx("span", {
className: cx(styles.extra, classNames?.extra),
style: customStyles?.extra,
children: extra
})
] });
return /* @__PURE__ */ jsxs("li", {
className: cx(styles.item, showAction && styles.showAction),
children: [href && !disabled ? /* @__PURE__ */ jsx(A, {
"aria-current": active ? "page" : void 0,
className: rowClassName,
href,
style: rowStyle,
onClick: handleClick,
children: content
}) : /* @__PURE__ */ jsx("button", {
"aria-current": active ? "true" : void 0,
"aria-disabled": disabled || void 0,
className: rowClassName,
style: rowStyle,
type: "button",
onClick: handleClick,
children: content
}), actions != null && /* @__PURE__ */ jsx("span", {
className: cx(styles.actions, classNames?.actions),
style: customStyles?.actions,
children: actions
})]
});
});
ListRow.displayName = "ListRow";
//#endregion
export { ListRow as default };
//# sourceMappingURL=ListRow.mjs.map