@wocwin/t-ui-plus
Version:
Page level components developed based on Element Plus.
88 lines (85 loc) • 2.92 kB
JavaScript
import { defineComponent, useSlots, ref, resolveComponent, createElementBlock, openBlock, createVNode, mergeProps, createSlots, withCtx, Fragment, renderList, createBlock, renderSlot, unref, normalizeProps, guardReactiveProps } from 'vue';
const _hoisted_1 = { class: "t_tabs" };
var _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: "TTabs"
},
__name: "index",
props: {
tabs: { default: () => [] }
},
emits: ["tabsChange"],
setup(__props, { expose: __expose, emit: __emit }) {
const props = __props;
const slots = useSlots();
const activeName = ref(props.tabs && props.tabs[0].key);
const emit = __emit;
const setSelectedTab = (key) => {
activeName.value = key;
};
__expose({
setSelectedTab
});
return (_ctx, _cache) => {
const _component_el_tab_pane = resolveComponent("el-tab-pane");
const _component_el_tabs = resolveComponent("el-tabs");
return openBlock(), createElementBlock("div", _hoisted_1, [
createVNode(_component_el_tabs, mergeProps({
modelValue: activeName.value,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeName.value = $event)
}, _ctx.$attrs), createSlots({
default: withCtx(() => [
(openBlock(true), createElementBlock(
Fragment,
null,
renderList(_ctx.tabs, (tab) => {
return openBlock(), createBlock(
_component_el_tab_pane,
mergeProps({
key: tab.key
}, {
name: tab.key,
label: tab.title,
...tab.bind
}),
createSlots({
default: withCtx(() => [
renderSlot(_ctx.$slots, tab.key)
]),
_: 2
/* DYNAMIC */
}, [
renderList(unref(slots), (_index, name) => {
return {
name,
fn: withCtx((data) => [
renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(data)))
])
};
})
]),
1040
/* FULL_PROPS, DYNAMIC_SLOTS */
);
}),
128
/* KEYED_FRAGMENT */
))
]),
_: 2
/* DYNAMIC */
}, [
renderList(unref(slots), (_index, name) => {
return {
name,
fn: withCtx((data) => [
renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(data)))
])
};
})
]), 1040, ["modelValue"])
]);
};
}
});
export { _sfc_main as default };