@vrx-arco/pro-components
Version:
<p align="center"> <img src="https://vrx-arco.github.io/arco-design-pro/favicon.svg" width="200" height="250"> </p>
38 lines (37 loc) • 1.26 kB
JavaScript
import { style } from "../style/var.js";
import { createVNode, defineComponent, isVNode } from "vue";
import { Avatar, Dropdown } from "@arco-design/web-vue";
import { propsSlot } from "@vrx-arco/use";
function _isSlot(s) {
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
}
const AvatarDropDown = /* @__PURE__ */ defineComponent({
name: "vrx-arco-avatar-drop-down",
props: {
username: String,
dropdown: {
type: Array,
default: () => []
}
},
emits: ["select"],
setup: (props, { slots, emit }) => {
const { bemClass } = style("avatar-dropdown");
const handleSelect = (select) => {
emit("select", select);
};
return () => {
const { dropdown } = props;
const username = propsSlot(slots, props, "username", "default");
return createVNode(Dropdown, { "onSelect": handleSelect }, {
default: () => [createVNode(Avatar, { "class": bemClass() }, _isSlot(username) ? username : { default: () => [username] })],
content: () => slots.content?.() || dropdown.map((item) => createVNode(Dropdown.Option, {
"key": item.value,
"value": item.value,
"disabled": item.disabled
}, { default: () => [item.title] }))
});
};
}
});
export { AvatarDropDown };