@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,
58 lines (57 loc) • 2.07 kB
JavaScript
import { defineComponent, ref, inject, computed, onMounted, onBeforeUnmount, watch, createElementBlock, openBlock, normalizeClass, renderSlot, normalizeStyle, toDisplayString } from "vue";
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "OptionPC",
props: {
label: {},
value: { type: [String, Number, Boolean, Object] },
customOptionContentStyle: { type: [Boolean, null, String, Object, Array] }
},
setup(__props) {
const optionRef = ref(null);
const props = __props;
const select = inject("select");
const isSelected = computed(
() => select && select.selectedValue === props.value
);
const optionData = computed(() => ({
label: props.label,
value: props.value,
ref: optionRef
}));
onMounted(() => {
select == null ? void 0 : select.onOptionCreated(optionData.value);
});
onBeforeUnmount(() => {
select == null ? void 0 : select.onOptionDestroyed(props.value);
});
watch(
() => [props.value, props.label],
(val, oldVal) => {
if (JSON.stringify(val) !== JSON.stringify(oldVal)) {
select == null ? void 0 : select.onOptionDestroyed(oldVal);
select == null ? void 0 : select.onOptionCreated(optionData.value);
}
}
);
function handleChooseOption() {
select == null ? void 0 : select.onOptionSelected(optionData.value);
}
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
ref_key: "optionRef",
ref: optionRef,
class: normalizeClass(["option-container", { active: isSelected.value }]),
onClick: handleChooseOption
}, [
_ctx.$slots.customOptionContent ? renderSlot(_ctx.$slots, "customOptionContent", { key: 0 }, void 0, true) : (openBlock(), createElementBlock("span", {
key: 1,
style: normalizeStyle(props.customOptionContentStyle),
class: "option-content"
}, toDisplayString(_ctx.label || _ctx.value), 5))
], 2);
};
}
});
export {
_sfc_main as default
};