You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.9 KiB
91 lines
2.9 KiB
4 years ago
|
import { defineComponent, PropType } from 'vue';
|
||
|
import { tuple } from '../_util/type';
|
||
5 years ago
|
import UpOutlined from '@ant-design/icons-vue/UpOutlined';
|
||
|
import DownOutlined from '@ant-design/icons-vue/DownOutlined';
|
||
|
import LeftOutlined from '@ant-design/icons-vue/LeftOutlined';
|
||
|
import RightOutlined from '@ant-design/icons-vue/RightOutlined';
|
||
6 years ago
|
import ScrollableInkTabBar from '../vc-tabs/src/ScrollableInkTabBar';
|
||
4 years ago
|
import PropTypes from '../_util/vue-types';
|
||
4 years ago
|
|
||
4 years ago
|
const TabBar = defineComponent({
|
||
5 years ago
|
name: 'TabBar',
|
||
|
inheritAttrs: false,
|
||
|
props: {
|
||
|
prefixCls: PropTypes.string,
|
||
4 years ago
|
tabBarStyle: PropTypes.style,
|
||
|
tabBarExtraContent: PropTypes.VNodeChild,
|
||
|
type: PropTypes.oneOf(tuple('line', 'card', 'editable-card')),
|
||
|
tabPosition: PropTypes.oneOf(tuple('top', 'right', 'bottom', 'left')).def('top'),
|
||
|
tabBarPosition: PropTypes.oneOf(tuple('top', 'right', 'bottom', 'left')),
|
||
|
size: PropTypes.oneOf(tuple('default', 'small', 'large')),
|
||
|
animated: {
|
||
|
type: [Boolean, Object] as PropType<boolean | { inkBar: boolean; tabPane: boolean }>,
|
||
|
default: undefined,
|
||
|
},
|
||
5 years ago
|
renderTabBar: PropTypes.func,
|
||
|
panels: PropTypes.array.def([]),
|
||
|
activeKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||
5 years ago
|
tabBarGutter: PropTypes.number,
|
||
5 years ago
|
},
|
||
|
render() {
|
||
6 years ago
|
const {
|
||
|
tabBarStyle,
|
||
|
animated = true,
|
||
|
renderTabBar,
|
||
|
tabBarExtraContent,
|
||
|
tabPosition,
|
||
|
prefixCls,
|
||
6 years ago
|
type = 'line',
|
||
|
size,
|
||
5 years ago
|
} = this.$props;
|
||
6 years ago
|
const inkBarAnimated = typeof animated === 'object' ? animated.inkBar : animated;
|
||
6 years ago
|
|
||
6 years ago
|
const isVertical = tabPosition === 'left' || tabPosition === 'right';
|
||
6 years ago
|
const prevIcon = (
|
||
|
<span class={`${prefixCls}-tab-prev-icon`}>
|
||
5 years ago
|
{isVertical ? (
|
||
|
<UpOutlined class={`${prefixCls}-tab-prev-icon-target`} />
|
||
|
) : (
|
||
5 years ago
|
<LeftOutlined class={`${prefixCls}-tab-prev-icon-target`} />
|
||
5 years ago
|
)}
|
||
6 years ago
|
</span>
|
||
6 years ago
|
);
|
||
6 years ago
|
const nextIcon = (
|
||
|
<span class={`${prefixCls}-tab-next-icon`}>
|
||
5 years ago
|
{isVertical ? (
|
||
|
<DownOutlined class={`${prefixCls}-tab-next-icon-target`} />
|
||
|
) : (
|
||
5 years ago
|
<RightOutlined class={`${prefixCls}-tab-next-icon-target`} />
|
||
5 years ago
|
)}
|
||
6 years ago
|
</span>
|
||
6 years ago
|
);
|
||
6 years ago
|
// Additional className for style usage
|
||
|
const cls = {
|
||
4 years ago
|
[this.$attrs.class as string]: this.$attrs.class,
|
||
6 years ago
|
[`${prefixCls}-${tabPosition}-bar`]: true,
|
||
|
[`${prefixCls}-${size}-bar`]: !!size,
|
||
|
[`${prefixCls}-card-bar`]: type && type.indexOf('card') >= 0,
|
||
6 years ago
|
};
|
||
6 years ago
|
|
||
6 years ago
|
const renderProps = {
|
||
4 years ago
|
...this.$props,
|
||
|
...this.$attrs,
|
||
4 years ago
|
children: null,
|
||
4 years ago
|
inkBarAnimated,
|
||
|
extraContent: tabBarExtraContent,
|
||
|
prevIcon,
|
||
|
nextIcon,
|
||
6 years ago
|
style: tabBarStyle,
|
||
6 years ago
|
class: cls,
|
||
6 years ago
|
};
|
||
6 years ago
|
|
||
|
if (renderTabBar) {
|
||
4 years ago
|
return renderTabBar({ ...renderProps, DefaultTabBar: ScrollableInkTabBar });
|
||
6 years ago
|
} else {
|
||
5 years ago
|
return <ScrollableInkTabBar {...renderProps} />;
|
||
6 years ago
|
}
|
||
|
},
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
6 years ago
|
export default TabBar;
|