winbox-ui-next
Version:
We Design Vue 2.0: A Vue.js 3 UI Library
60 lines (59 loc) • 1.79 kB
JavaScript
import { defineComponent, computed, createVNode, Fragment, mergeProps } from "vue";
import { getPrefixCls } from "../_utils/global-config.js";
import IconMore from "../icon/icon-more/index.js";
import IconObliqueLine from "../icon/icon-oblique-line/index.js";
var BreadcrumbItem = 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 = getPrefixCls("breadcrumb-item");
const show = 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 = 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 createVNode(Fragment, null, [createVNode("div", mergeProps({
"class": prefixCls
}, attrs), [displayMore.value ? createVNode(IconMore, null, null) : (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) != null ? _b : ""]), props.index !== props.total - 1 && createVNode("div", {
"class": `${prefixCls}-separator`
}, [(_d = (_c = props.separator) == null ? void 0 : _c.call(props)) != null ? _d : createVNode(IconObliqueLine, null, null)])]);
}
return null;
};
}
});
export { BreadcrumbItem as default };