yanzhen-design-vue
Version:
118 lines (117 loc) • 3.32 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const vue = require("vue");
const antDesignVue = require("ant-design-vue");
const utils = require("@yanzhen-libs/utils");
const utilsVue = require("@yanzhen-libs/utils-vue");
const lodashEs = require("lodash-es");
const tabs = require("./tabs.cjs");
const { ns } = tabs.tabsOptions;
function useTabs(props, emit) {
const _ref = vue.ref();
const attrs = vue.useAttrs();
const slots = vue.useSlots();
const activeKey = vue.computed({
get() {
return props.value ?? props.activeKey;
},
set(value) {
if (value) {
emit("update:value", value);
emit("update:activeKey", value);
}
}
});
const config = vue.computed(() => lodashEs.pick(props, ...Object.keys(tabs.AntTabs.props)));
const proxyProps = utilsVue.useProxyProps(config, tabs.AntTabs.emits, {
exclude: ["activeKey"],
emit: (event, ...args) => {
switch (event) {
case "update:activeKey":
case "change":
emit("update:value", args[0]);
break;
}
return emit(event, ...args);
},
filter: true
});
function createTabPaneVNode(item, props2 = {}) {
const { minHeight, renderTabPane } = props2;
const _props = lodashEs.omit(item, "name", "tab", "style", "class");
return vue.createVNode(
antDesignVue.Tabs.TabPane,
vue.mergeProps(
{
forceRender: true,
tab: item["name"] ?? item["tab"]
},
_props
),
{
default: vue.withCtx(() => {
const renderVNodeFn = slots[_props.key] ?? renderTabPane;
if (!lodashEs.isFunction(renderVNodeFn)) return;
return vue.createVNode(
"div",
vue.mergeProps(
{
style: [String(minHeight).endsWith("px") ? minHeight : `${minHeight}px`],
tab: item["name"] ?? item["tab"],
class: ns.b("pane-slot-wrap")
},
_props
),
{
default: vue.withCtx(() => {
const vNode = renderVNodeFn(item);
if (!vue.isVNode(vNode)) return;
return vNode;
})
}
);
})
}
);
}
function createTabsDefVNode(props2) {
if (lodashEs.isFunction(slots.default)) return slots.default(props2);
if (utils.isEmptyArray(props2 == null ? void 0 : props2.tabList)) return;
vue.openBlock(true);
return vue.createElementBlock(
vue.Fragment,
{ key: 0 },
vue.renderList(props2 == null ? void 0 : props2.tabList, (item) => {
return createTabPaneVNode(item, props2);
})
);
}
return [
{
_ref,
activeKey,
proxyProps,
TabPane: createTabPaneVNode
},
(props2) => {
const _props = vue.mergeProps(
{
animated: false
},
vue.unref(attrs),
vue.unref(proxyProps),
props2,
{
ref: _ref
}
);
return vue.createVNode(antDesignVue.Tabs, _props, {
...slots,
default: vue.withCtx((props3) => {
return createTabsDefVNode(vue.mergeProps(_props, props3));
})
});
}
];
}
exports.useTabs = useTabs;