TabBar.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _extends2 = require('babel-runtime/helpers/extends');
  6. var _extends3 = _interopRequireDefault(_extends2);
  7. var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
  8. var _defineProperty3 = _interopRequireDefault(_defineProperty2);
  9. var _typeof2 = require('babel-runtime/helpers/typeof');
  10. var _typeof3 = _interopRequireDefault(_typeof2);
  11. var _icon = require('../icon');
  12. var _icon2 = _interopRequireDefault(_icon);
  13. var _ScrollableInkTabBar = require('../vc-tabs/src/ScrollableInkTabBar');
  14. var _ScrollableInkTabBar2 = _interopRequireDefault(_ScrollableInkTabBar);
  15. var _vnode = require('../_util/vnode');
  16. var _vueTypes = require('../_util/vue-types');
  17. var _vueTypes2 = _interopRequireDefault(_vueTypes);
  18. var _propsUtil = require('../_util/props-util');
  19. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  20. var TabBar = {
  21. name: 'TabBar',
  22. inheritAttrs: false,
  23. props: {
  24. prefixCls: _vueTypes2['default'].string,
  25. tabBarStyle: _vueTypes2['default'].object,
  26. tabBarExtraContent: _vueTypes2['default'].any,
  27. type: _vueTypes2['default'].oneOf(['line', 'card', 'editable-card']),
  28. tabPosition: _vueTypes2['default'].oneOf(['top', 'right', 'bottom', 'left']).def('top'),
  29. tabBarPosition: _vueTypes2['default'].oneOf(['top', 'right', 'bottom', 'left']),
  30. size: _vueTypes2['default'].oneOf(['default', 'small', 'large']),
  31. animated: _vueTypes2['default'].oneOfType([_vueTypes2['default'].bool, _vueTypes2['default'].object]),
  32. renderTabBar: _vueTypes2['default'].func,
  33. panels: _vueTypes2['default'].array.def([]),
  34. activeKey: _vueTypes2['default'].oneOfType([_vueTypes2['default'].string, _vueTypes2['default'].number]),
  35. tabBarGutter: _vueTypes2['default'].number
  36. },
  37. render: function render() {
  38. var _cls;
  39. var h = arguments[0];
  40. var _$props = this.$props,
  41. tabBarStyle = _$props.tabBarStyle,
  42. _$props$animated = _$props.animated,
  43. animated = _$props$animated === undefined ? true : _$props$animated,
  44. renderTabBar = _$props.renderTabBar,
  45. tabBarExtraContent = _$props.tabBarExtraContent,
  46. tabPosition = _$props.tabPosition,
  47. prefixCls = _$props.prefixCls,
  48. _$props$type = _$props.type,
  49. type = _$props$type === undefined ? 'line' : _$props$type,
  50. size = _$props.size;
  51. var inkBarAnimated = (typeof animated === 'undefined' ? 'undefined' : (0, _typeof3['default'])(animated)) === 'object' ? animated.inkBar : animated;
  52. var isVertical = tabPosition === 'left' || tabPosition === 'right';
  53. var prevIconType = isVertical ? 'up' : 'left';
  54. var nextIconType = isVertical ? 'down' : 'right';
  55. var prevIcon = h(
  56. 'span',
  57. { 'class': prefixCls + '-tab-prev-icon' },
  58. [h(_icon2['default'], {
  59. attrs: { type: prevIconType },
  60. 'class': prefixCls + '-tab-prev-icon-target' })]
  61. );
  62. var nextIcon = h(
  63. 'span',
  64. { 'class': prefixCls + '-tab-next-icon' },
  65. [h(_icon2['default'], {
  66. attrs: { type: nextIconType },
  67. 'class': prefixCls + '-tab-next-icon-target' })]
  68. );
  69. // Additional className for style usage
  70. var cls = (_cls = {}, (0, _defineProperty3['default'])(_cls, prefixCls + '-' + tabPosition + '-bar', true), (0, _defineProperty3['default'])(_cls, prefixCls + '-' + size + '-bar', !!size), (0, _defineProperty3['default'])(_cls, prefixCls + '-card-bar', type && type.indexOf('card') >= 0), _cls);
  71. var renderProps = {
  72. props: (0, _extends3['default'])({}, this.$props, this.$attrs, {
  73. inkBarAnimated: inkBarAnimated,
  74. extraContent: tabBarExtraContent,
  75. prevIcon: prevIcon,
  76. nextIcon: nextIcon
  77. }),
  78. style: tabBarStyle,
  79. on: (0, _propsUtil.getListeners)(this),
  80. 'class': cls
  81. };
  82. var RenderTabBar = void 0;
  83. if (renderTabBar) {
  84. RenderTabBar = renderTabBar(renderProps, _ScrollableInkTabBar2['default']);
  85. // https://github.com/vueComponent/ant-design-vue/issues/2157
  86. return (0, _vnode.cloneElement)(RenderTabBar, renderProps);
  87. } else {
  88. return h(_ScrollableInkTabBar2['default'], renderProps);
  89. }
  90. }
  91. };
  92. exports['default'] = TabBar;