"use strict";

var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");

exports.__esModule = true;
exports.default = void 0;

require("./SubMenu.css");

var _component = require("../_utils/component");

var _collapseTransition = _interopRequireDefault(require("../_utils/collapse-transition"));

var _Item = _interopRequireDefault(require("./Item"));

var _Popover = _interopRequireDefault(require("../Popover"));

var _vueNormalizeComponent = _interopRequireDefault(require("../_utils/vue-normalize-component.js"));

/* script */
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
var __vue_script__ = {
  name: (0, _component.createComponentName)('sub-menu'),
  components: {
    Popover: _Popover.default
  },
  mixins: [_component.componentMixin],
  inject: ['menuBus', 'rootMenu'],
  props: {
    title: {
      type: String
    },
    index: {
      type: [String, Number],
      required: true
    },
    route: {
      type: String
    },
    hideMenu: {
      type: Boolean,
      default: false
    },
    offset: {
      type: String,
      default: '0'
    },
    placement: {
      type: String,
      default: 'bottom'
    },
    popoverClass: {
      type: String
    }
  },

  data() {
    return {
      MenuItem: _Item.default
    };
  },

  beforeCreate() {
    this.collapseTransition = (0, _collapseTransition.default)();
  },

  mounted() {
    this.menuBus.on('sub-menu:toggle', this.onToggle);
  },

  destroyed() {
    this.menuBus.removeListener('sub-menu:toggle', this.onToggle);
  },

  methods: {
    onToggle(index, toggle) {
      if (this.index === index && this.$refs.popover) {
        this.$refs.popover.isShowPopper = toggle;
      }
    },

    close() {
      this.$refs.popover.isShowPopper = false;
    }

  }
};
/* template */

var __vue_render__ = function __vue_render__() {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c("Popover", _vm._g(_vm._b({
    ref: "popover",
    attrs: {
      tag: _vm.MenuItem,
      "transition-on": _vm.collapseTransition,
      trigger: _vm.rootMenu.trigger,
      index: _vm.index,
      route: _vm.route,
      lazy: false,
      "popover-class": [_vm.bem("popover"), _vm.popoverClass],
      placement: _vm.placement,
      modifiers: {
        offset: {
          offset: _vm.offset
        }
      }
    }
  }, "Popover", _vm.$attrs, false), _vm.$listeners), [_vm._t("title", [_vm._v(_vm._s(_vm.title))]), _vm._v(" "), !_vm.hideMenu ? _c("ul", {
    class: _vm.bem(),
    attrs: {
      slot: "popup"
    },
    slot: "popup"
  }, [_vm._t("default")], 2) : _vm._e()], 2);
};

var __vue_staticRenderFns__ = [];
__vue_render__._withStripped = true;
/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

var __vue_scope_id__ = undefined;
/* module identifier */

var __vue_module_identifier__ = undefined;
/* functional template */

var __vue_is_functional_template__ = false;
/* component normalizer */

/* style inject */

/* style inject SSR */
var _default = (0, _vueNormalizeComponent.default)({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);

exports.default = _default;