@opentiny/vue-renderless
Version:
An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.
28 lines (27 loc) • 967 B
JavaScript
import "../chunk-G2ADBYYC.js";
import { useRelation as createUseRelation } from "@opentiny/vue-hooks";
const renderless = (props, hooks, { slots, vm }) => {
const { inject, onBeforeUnmount, reactive, toRef, markRaw } = hooks;
const tabs = inject("tabs", null);
const tabsId = inject("tabsId", null);
const useRelation = createUseRelation(hooks);
const { lazy } = props;
const item = reactive({
title: toRef(props, "title"),
name: toRef(props, "name"),
slotDefault: slots.default,
slotTitle: props.renderTitle ? toRef(props, "renderTitle") : slots.title,
slotSetting: props.renderSetting ? toRef(props, "renderSetting") : slots.setting,
lazy,
selected: false,
vm: markRaw(vm)
});
item.selected = (tabs.activeName || tabs.modelValue) === item.name;
tabs.addItem(item);
onBeforeUnmount(() => tabs.removeItem(item.name, true));
useRelation({ relationKey: `tabs-${tabsId}` });
return {};
};
export {
renderless
};