@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,
106 lines (105 loc) • 3.72 kB
JavaScript
import { defineComponent, ref, computed, watch, createElementBlock, createCommentVNode, openBlock, normalizeClass, createElementVNode, normalizeStyle, renderSlot, toDisplayString, createVNode, unref } from "vue";
import { IconClose } from "@tencentcloud/uikit-base-component-vue3";
import { addSuffix } from "../../../utils/utils.mjs";
const _hoisted_1 = { class: "drawer-header" };
const _hoisted_2 = { class: "drawer-header-title" };
const _hoisted_3 = { class: "drawer-content" };
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "Drawer",
props: {
title: { default: "" },
modelValue: { type: Boolean, default: false },
modal: { type: Boolean, default: false },
size: { default: "400" },
beforeClose: { type: Function, default: void 0 },
appendToBody: { type: Boolean, default: false },
appendToRoomContainer: { type: Boolean, default: false },
closeOnClickModal: { type: Boolean, default: true }
},
emits: ["update:modelValue"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const drawerRef = ref();
const visible = ref(false);
const drawerContainerStyle = computed(() => `width: ${addSuffix(props.size)}`);
watch(
() => props.modelValue,
(val) => {
visible.value = val;
}
);
watch(visible, (val) => {
var _a;
if (val) {
if (props.appendToBody) {
document.body.appendChild(drawerRef.value);
} else if (props.appendToRoomContainer) {
(_a = document.getElementById("roomContainer")) == null ? void 0 : _a.appendChild(drawerRef.value);
}
}
});
function doClose() {
visible.value = false;
emit("update:modelValue", false);
}
function handleClose() {
if (props.beforeClose) {
props.beforeClose(doClose);
} else {
doClose();
}
}
let mouseDownInCurrentTarget = false;
let mouseUpInCurrentTarget = false;
function handleOverlayMouseUp(event) {
mouseUpInCurrentTarget = event.target === event.currentTarget;
}
function handleOverlayMouseDown(event) {
mouseDownInCurrentTarget = event.target === event.currentTarget;
}
function handleOverlayClick() {
if (!props.closeOnClickModal) {
return;
}
if (mouseDownInCurrentTarget && mouseUpInCurrentTarget) {
handleClose();
mouseDownInCurrentTarget = false;
mouseUpInCurrentTarget = false;
}
}
return (_ctx, _cache) => {
return visible.value ? (openBlock(), createElementBlock("div", {
key: 0,
ref_key: "drawerRef",
ref: drawerRef,
class: normalizeClass(["overlay-container", [_ctx.modal && "overlay"]]),
onMouseup: handleOverlayMouseUp,
onMousedown: handleOverlayMouseDown,
onClick: handleOverlayClick
}, [
createElementVNode("div", {
class: "drawer-container",
style: normalizeStyle(drawerContainerStyle.value)
}, [
createElementVNode("div", _hoisted_1, [
createElementVNode("div", _hoisted_2, toDisplayString(_ctx.title), 1),
_ctx.$slots.title ? renderSlot(_ctx.$slots, "title", { key: 0 }, void 0, true) : createCommentVNode("", true),
createElementVNode("div", {
class: "close",
onClick: handleClose
}, [
createVNode(unref(IconClose))
])
]),
createElementVNode("div", _hoisted_3, [
renderSlot(_ctx.$slots, "default", {}, void 0, true)
])
], 4)
], 34)) : createCommentVNode("", true);
};
}
});
export {
_sfc_main as default
};