index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. exports.__esModule = true;
  4. exports.default = void 0;
  5. var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  6. var _utils = require("../utils");
  7. var _relation = require("../mixins/relation");
  8. var _router = require("../utils/router");
  9. var _info = _interopRequireDefault(require("../info"));
  10. var _createNamespace = (0, _utils.createNamespace)('sidebar-item'),
  11. createComponent = _createNamespace[0],
  12. bem = _createNamespace[1];
  13. var _default = createComponent({
  14. mixins: [(0, _relation.ChildrenMixin)('vanSidebar')],
  15. props: (0, _extends2.default)({}, _router.routeProps, {
  16. dot: Boolean,
  17. // @deprecated
  18. info: [Number, String],
  19. badge: [Number, String],
  20. title: String,
  21. disabled: Boolean
  22. }),
  23. computed: {
  24. select: function select() {
  25. return this.index === +this.parent.activeKey;
  26. }
  27. },
  28. methods: {
  29. onClick: function onClick() {
  30. if (this.disabled) {
  31. return;
  32. }
  33. this.$emit('click', this.index);
  34. this.parent.$emit('input', this.index);
  35. this.parent.setIndex(this.index);
  36. (0, _router.route)(this.$router, this);
  37. }
  38. },
  39. render: function render() {
  40. var _this$slots, _this$badge;
  41. var h = arguments[0];
  42. if (process.env.NODE_ENV === 'development' && this.info) {
  43. console.warn('[Vant] SidebarItem: "info" prop is deprecated, use "badge" prop instead.');
  44. }
  45. return h("a", {
  46. "class": bem({
  47. select: this.select,
  48. disabled: this.disabled
  49. }),
  50. "on": {
  51. "click": this.onClick
  52. }
  53. }, [h("div", {
  54. "class": bem('text')
  55. }, [(_this$slots = this.slots('title')) != null ? _this$slots : this.title, h(_info.default, {
  56. "attrs": {
  57. "dot": this.dot,
  58. "info": (_this$badge = this.badge) != null ? _this$badge : this.info
  59. },
  60. "class": bem('info')
  61. })])]);
  62. }
  63. });
  64. exports.default = _default;