@tencentcloud/roomkit-electron-vue3
Version:
<h1 align="center"> TUIRoomKit</h1> Conference (TUIRoomKit) is a product suitable for multi-person audio and video conversation scenarios such as business meetings, webinars, and online education. By integrating this product, you can add room management,
195 lines (194 loc) • 7.6 kB
JavaScript
import { defineComponent, computed, ref, watch, createElementBlock, openBlock, createBlock, createCommentVNode, createElementVNode, createVNode, withCtx, createTextVNode, toDisplayString, withDirectives, unref, normalizeClass, Fragment, renderList, vShow, isRef, nextTick } from "vue";
import { useI18n } from "../../../locales/index.mjs";
import TuiButton from "../../common/base/Button.vue.mjs";
import Dialog from "../../common/base/Dialog/index.vue.mjs";
import TuiInput from "../../common/base/Input/index.vue.mjs";
import SvgIcon from "../../common/base/SvgIcon.vue.mjs";
import ArrowUpIcon from "../../common/icons/ArrowUpIcon.vue.mjs";
import useMemberControl from "./useMemberControlHooks.mjs";
import useMemberItem from "../MemberItem/useMemberItemHooks.mjs";
const _hoisted_1 = { class: "member-control-container" };
const _hoisted_2 = ["onClick"];
const _hoisted_3 = { class: "operate-text" };
const _hoisted_4 = { class: "dialog-content" };
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "index",
props: {
userInfo: {},
showMemberControl: { type: Boolean }
},
setup(__props) {
const props = __props;
const { t } = useI18n();
const {
controlList,
handleCancelDialog,
handleAction,
isDialogVisible,
dialogData,
tempUserName
} = useMemberControl(props);
const { isCanOperateMySelf } = useMemberItem(props.userInfo);
const singleControl = computed(() => {
return isCanOperateMySelf.value ? null : controlList.value[0];
});
const moreControlList = computed(() => {
return isCanOperateMySelf.value ? controlList.value : controlList.value.slice(1);
});
const dropdownClass = ref("down");
const moreBtnRef = ref();
const operateListRef = ref();
const showMoreControl = ref(false);
watch(
() => props.showMemberControl,
(val) => {
if (!val) {
showMoreControl.value = false;
}
}
);
async function toggleClickMoreBtn() {
if (showMoreControl.value) {
showMoreControl.value = false;
} else {
await handleDropDownPosition();
showMoreControl.value = true;
}
}
async function handleDropDownPosition() {
var _a, _b, _c;
const { top, bottom } = (_a = moreBtnRef.value) == null ? void 0 : _a.getBoundingClientRect();
const { top: containerTop, bottom: containerBottom } = (_b = document.getElementById("memberListContainer")) == null ? void 0 : _b.getBoundingClientRect();
if (!containerBottom || !containerTop) {
return;
}
const bottomSize = containerBottom - bottom;
const topSize = top - containerTop;
let dropDownContainerHeight = 0;
if (!showMoreControl.value) {
operateListRef.value.style = "display:block;position:absolute;z-index:-1000";
await nextTick();
dropDownContainerHeight = operateListRef.value.offsetHeight;
operateListRef.value.style = "";
} else {
dropDownContainerHeight = (_c = operateListRef.value) == null ? void 0 : _c.offsetHeight;
}
if (topSize < dropDownContainerHeight) {
return;
}
if (bottomSize < dropDownContainerHeight) {
dropdownClass.value = "up";
}
}
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", _hoisted_1, [
singleControl.value ? (openBlock(), createBlock(TuiButton, {
key: 0,
class: "button",
size: "default",
onClick: _cache[0] || (_cache[0] = ($event) => singleControl.value.func(props.userInfo))
}, {
default: withCtx(() => {
var _a;
return [
createTextVNode(toDisplayString((_a = singleControl.value) == null ? void 0 : _a.title), 1)
];
}),
_: 1
})) : createCommentVNode("", true),
createElementVNode("div", {
ref_key: "moreBtnRef",
ref: moreBtnRef,
class: "more-container"
}, [
createVNode(TuiButton, {
class: "button",
type: "primary",
onClick: toggleClickMoreBtn
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(unref(t)("More")) + " ", 1),
createVNode(SvgIcon, {
size: "12",
class: normalizeClass(["more-arrow", showMoreControl.value ? "up" : "down"]),
icon: ArrowUpIcon
}, null, 8, ["class"])
]),
_: 1
}),
withDirectives(createElementVNode("div", {
id: "operate-list",
ref_key: "operateListRef",
ref: operateListRef,
class: normalizeClass(["user-operate-list", dropdownClass.value])
}, [
(openBlock(true), createElementBlock(Fragment, null, renderList(moreControlList.value, (item) => {
return openBlock(), createElementBlock("div", {
key: item.key,
class: "user-operate-item",
onClick: ($event) => item.func(props.userInfo)
}, [
createVNode(SvgIcon, {
icon: item.icon
}, null, 8, ["icon"]),
createElementVNode("span", _hoisted_3, toDisplayString(item.title), 1)
], 8, _hoisted_2);
}), 128))
], 2), [
[vShow, showMoreControl.value]
])
], 512),
createVNode(Dialog, {
modelValue: unref(isDialogVisible),
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => isRef(isDialogVisible) ? isDialogVisible.value = $event : null),
title: unref(dialogData).title,
modal: true,
width: "480px",
"before-close": unref(handleCancelDialog),
"close-on-click-modal": true,
"append-to-room-container": true
}, {
footer: withCtx(() => [
createVNode(TuiButton, {
size: "default",
onClick: _cache[2] || (_cache[2] = ($event) => unref(handleAction)(props.userInfo)),
disabled: unref(dialogData).isConfirmButtonDisable
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(unref(dialogData).confirmText), 1)
]),
_: 1
}, 8, ["disabled"]),
createVNode(TuiButton, {
class: "cancel",
size: "default",
type: "primary",
onClick: unref(handleCancelDialog)
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(unref(t)("Cancel")), 1)
]),
_: 1
}, 8, ["onClick"])
]),
default: withCtx(() => [
createElementVNode("div", _hoisted_4, [
createElementVNode("span", null, toDisplayString(unref(dialogData).content), 1),
unref(dialogData).showInput ? (openBlock(), createBlock(TuiInput, {
key: 0,
"model-value": unref(tempUserName),
onInput: _cache[1] || (_cache[1] = ($event) => tempUserName.value = $event),
class: "dialog-input",
placeholder: unref(t)("Please input user name")
}, null, 8, ["model-value", "placeholder"])) : createCommentVNode("", true)
])
]),
_: 1
}, 8, ["modelValue", "title", "before-close"])
]);
};
}
});
export {
_sfc_main as default
};