ant-design-x-vue
Version:
Craft AI-driven interfaces effortlessly
94 lines (93 loc) • 2.7 kB
JavaScript
import { defineComponent as p, toRef as y, computed as i, createVNode as t, mergeProps as h } from "vue";
import { a as $, c as O } from "../attachments/Attachments2.mjs";
import T from "../_util/pick-attrs.mjs";
import { Tooltip as E, Typography as M, Dropdown as w, Menu as I } from "ant-design-vue";
import s from "../_util/hooks/use-state.mjs";
import { E as N } from "../attachments/FileList/FileList2.mjs";
const S = /* @__PURE__ */ p({
name: "AXConversationsItem",
__name: "ConversationsItem",
props: {
info: null,
prefixCls: null,
direction: null,
menu: null,
active: {
type: Boolean
},
onClick: {
type: Function
}
},
setup(e) {
const u = $(e, ["prefixCls", "info", "class", "direction", "onClick", "active", "menu"]);
y(e, "class");
const f = i(() => T(u, {
aria: !0,
data: !0,
attr: !0
})), m = (n) => {
n.stopPropagation();
}, l = i(() => e.info.disabled), [d, g] = s(!1), [C, r] = s(!1), v = i(() => O(e.class, `${e.prefixCls}-item`, {
[`${e.prefixCls}-item-active`]: e.active && !l.value
}, {
[`${e.prefixCls}-item-disabled`]: l.value
})), x = () => {
!l.value && e.onClick && e.onClick(e.info);
}, P = (n) => {
n && r(!n);
}, o = i(() => {
var n;
return (n = e.menu) == null ? void 0 : n.trigger;
}), c = i(() => {
const {
trigger: n,
...a
} = e.menu || {};
return a;
}), b = i(() => {
var n;
return (n = c.value) == null ? void 0 : n.getPopupContainer;
}), k = (n) => {
const a = t(N, {
onClick: m,
class: `${e.prefixCls}-menu-icon`
}, null);
return o.value ? typeof o.value == "function" ? o.value(n, {
originNode: a
}) : o.value : a;
};
return () => t(E, {
title: e.info.label,
open: d.value && C.value,
onOpenChange: r,
placement: e.direction === "rtl" ? "left" : "right"
}, {
default: () => [t("li", h(f.value, {
class: v.value,
onClick: x
}), [e.info.icon && t("div", {
class: `${e.prefixCls}-icon`
}, [e.info.icon]), t(M.Text, {
class: `${e.prefixCls}-label`,
ellipsis: {
onEllipsis: g
}
}, {
default: () => [e.info.label]
}), !l.value && e.menu && t(w, {
placement: e.direction === "rtl" ? "bottomLeft" : "bottomRight",
trigger: ["click"],
disabled: l.value,
onOpenChange: P,
getPopupContainer: b.value
}, {
default: () => k(e.info),
overlay: () => t(I, c.value, null)
})])]
});
}
});
export {
S as default
};