Title.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. exports.__esModule = true;
  4. exports.default = void 0;
  5. var _utils = require("../utils");
  6. var _info = _interopRequireDefault(require("../info"));
  7. var _createNamespace = (0, _utils.createNamespace)('tab'),
  8. createComponent = _createNamespace[0],
  9. bem = _createNamespace[1];
  10. var _default = createComponent({
  11. props: {
  12. dot: Boolean,
  13. type: String,
  14. info: [Number, String],
  15. color: String,
  16. title: String,
  17. isActive: Boolean,
  18. disabled: Boolean,
  19. scrollable: Boolean,
  20. activeColor: String,
  21. inactiveColor: String
  22. },
  23. computed: {
  24. style: function style() {
  25. var style = {};
  26. var color = this.color,
  27. isActive = this.isActive;
  28. var isCard = this.type === 'card'; // card theme color
  29. if (color && isCard) {
  30. style.borderColor = color;
  31. if (!this.disabled) {
  32. if (isActive) {
  33. style.backgroundColor = color;
  34. } else {
  35. style.color = color;
  36. }
  37. }
  38. }
  39. var titleColor = isActive ? this.activeColor : this.inactiveColor;
  40. if (titleColor) {
  41. style.color = titleColor;
  42. }
  43. return style;
  44. }
  45. },
  46. methods: {
  47. onClick: function onClick() {
  48. this.$emit('click');
  49. },
  50. genText: function genText() {
  51. var h = this.$createElement;
  52. var Text = h("span", {
  53. "class": bem('text', {
  54. ellipsis: !this.scrollable
  55. })
  56. }, [this.slots() || this.title]);
  57. if (this.dot || (0, _utils.isDef)(this.info) && this.info !== '') {
  58. return h("span", {
  59. "class": bem('text-wrapper')
  60. }, [Text, h(_info.default, {
  61. "attrs": {
  62. "dot": this.dot,
  63. "info": this.info
  64. }
  65. })]);
  66. }
  67. return Text;
  68. }
  69. },
  70. render: function render() {
  71. var h = arguments[0];
  72. return h("div", {
  73. "attrs": {
  74. "role": "tab",
  75. "aria-selected": this.isActive
  76. },
  77. "class": [bem({
  78. active: this.isActive,
  79. disabled: this.disabled
  80. })],
  81. "style": this.style,
  82. "on": {
  83. "click": this.onClick
  84. }
  85. }, [this.genText()]);
  86. }
  87. });
  88. exports.default = _default;