UNPKG

@layui/layui-vue

Version:

a component library for Vue 3 base on layui-vue

17 lines (16 loc) 1.12 kB
import { defineComponent as m, getCurrentInstance as u, useSlots as b, inject as l, reactive as n, watch as f, onBeforeUnmount as p, openBlock as I, createElementBlock as v, normalizeClass as B, unref as C, renderSlot as S } from "vue"; import { TabInjectKey as g } from "../tab/interface.js"; const w = m({ name: "LayTabItem", __name: "index", props: { id: {}, title: {}, icon: {}, closable: { type: [Boolean, String], default: !0 } }, setup(d) { var i; const e = d, s = u(), o = b(), c = l("active"), t = l(g, {}), r = n({ id: e.id, title: e.title, icon: e.icon, closable: e.closable, slots: o }); return s != null && s.uid && ((i = t.addItem) == null || i.call(t, e.id, r)), f(() => e, () => { var a; (a = t.addItem) == null || a.call(t, e.id, n({ id: e.id, title: e.title, icon: e.icon, closable: e.closable, slots: o })); }, { deep: !0 }), p(() => { var a; s != null && s.uid && ((a = t.removeItem) == null || a.call(t, e.id)); }), (a, h) => (I(), v("div", { class: B(["layui-tab-item", [C(c) === a.id ? "layui-show" : ""]]) }, [S(a.$slots, "default")], 2)); } }); export { w as default };