winbox-ui-next
Version:
We Design Vue 2.0: A Vue.js 3 UI Library
61 lines (60 loc) • 1.78 kB
JavaScript
;
var vue = require("vue");
var globalConfig = require("../_utils/global-config.js");
var index = require("../icon/icon-more/index.js");
var index$1 = require("../icon/icon-oblique-line/index.js");
var BreadcrumbItem = vue.defineComponent({
name: "BreadcrumbItem",
inheritAttrs: false,
props: {
total: {
type: Number,
default: 0
},
maxCount: {
type: Number,
default: 0
},
separator: {
type: Function
},
index: {
type: Number,
default: 0
}
},
setup(props, {
slots,
attrs
}) {
const prefixCls = globalConfig.getPrefixCls("breadcrumb-item");
const show = vue.computed(() => {
if (props.maxCount > 0 && props.total > props.maxCount + 1) {
if (props.index > 1 && props.index <= props.total - props.maxCount) {
return false;
}
}
return true;
});
const displayMore = vue.computed(() => {
if (props.maxCount > 0 && props.total > props.maxCount + 1) {
if (props.index === 1) {
return true;
}
}
return false;
});
return () => {
var _a, _b, _c, _d;
if (show.value) {
return vue.createVNode(vue.Fragment, null, [vue.createVNode("div", vue.mergeProps({
"class": prefixCls
}, attrs), [displayMore.value ? vue.createVNode(index, null, null) : (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) != null ? _b : ""]), props.index !== props.total - 1 && vue.createVNode("div", {
"class": `${prefixCls}-separator`
}, [(_d = (_c = props.separator) == null ? void 0 : _c.call(props)) != null ? _d : vue.createVNode(index$1, null, null)])]);
}
return null;
};
}
});
module.exports = BreadcrumbItem;