@tencentcloud/roomkit-web-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,
187 lines (186 loc) • 7.51 kB
JavaScript
import { defineComponent, computed, ref, watch, createElementBlock, openBlock, createBlock, createCommentVNode, createElementVNode, createVNode, unref, withCtx, createTextVNode, toDisplayString, withDirectives, normalizeClass, Fragment, renderList, vShow, isRef, nextTick } from "vue";
import { useI18n } from "../../../locales/index.mjs";
import Dialog from "../../common/base/Dialog/index.mjs";
import Input from "../../common/base/Input/index.mjs";
import { TUIButton, IconArrowUp, TUIIcon } from "@tencentcloud/uikit-base-component-vue3";
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: "MemberControlPC",
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(unref(TUIButton), {
key: 0,
type: "primary",
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(unref(TUIButton), { onClick: toggleClickMoreBtn }, {
default: withCtx(() => [
createTextVNode(toDisplayString(unref(t)("More")) + " ", 1),
createVNode(unref(IconArrowUp), {
size: "12",
class: normalizeClass(["more-arrow", showMoreControl.value ? "up" : "down"])
}, 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)
}, [
item.icon ? (openBlock(), createBlock(unref(TUIIcon), {
key: 0,
icon: item.icon
}, null, 8, ["icon"])) : createCommentVNode("", true),
createElementVNode("span", _hoisted_3, toDisplayString(item.title), 1)
], 8, _hoisted_2);
}), 128))
], 2), [
[vShow, showMoreControl.value]
])
], 512),
createVNode(unref(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(unref(TUIButton), {
onClick: _cache[2] || (_cache[2] = ($event) => unref(handleAction)(props.userInfo)),
disabled: unref(dialogData).isConfirmButtonDisable,
type: "primary",
style: { "min-width": "88px" }
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(unref(dialogData).confirmText), 1)
]),
_: 1
}, 8, ["disabled"]),
createVNode(unref(TUIButton), {
onClick: unref(handleCancelDialog),
style: { "min-width": "88px" }
}, {
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(unref(Input), {
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
};