"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _comp = require("../../ui/src/comp");
var _ui = require("../../ui");
var _util = require("./util");
var _xeUtils = _interopRequireDefault(require("xe-utils"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
var _default2 = exports.default = /* define-vxe-component start */(0, _comp.defineVxeComponent)({
  name: 'VxeSplitterPanel',
  mixins: [_ui.globalMixins.sizeMixin],
  props: {
    name: [Number, String],
    width: [Number, String],
    height: [Number, String],
    minWidth: {
      type: [Number, String],
      default: function _default() {
        return null;
      }
    },
    minHeight: {
      type: [Number, String],
      default: function _default() {
        return null;
      }
    },
    // 已废弃
    showAction: Boolean
  },
  inject: {
    $xeSplitter: {
      default: null
    }
  },
  provide: function provide() {
    var $xeSplitterItem = this;
    return {
      $xeSplitterItem: $xeSplitterItem
    };
  },
  data: function data() {
    var xID = _xeUtils.default.uniqueId();
    var reactData = {};
    var paneConfig = {
      id: xID,
      name: '',
      width: 0,
      height: 0,
      minWidth: 0,
      minHeight: 0,
      showAction: false,
      isExpand: true,
      renderWidth: 0,
      resizeWidth: 0,
      foldWidth: 0,
      renderHeight: 0,
      resizeHeight: 0,
      foldHeight: 0,
      slots: {}
    };
    return {
      xID: xID,
      reactData: reactData,
      paneConfig: paneConfig
    };
  },
  computed: Object.assign({}, {}),
  watch: {
    name: function name(val) {
      var $xeSplitterItem = this;
      var paneConfig = $xeSplitterItem.paneConfig;
      paneConfig.name = val;
    },
    width: function width(val) {
      var $xeSplitterItem = this;
      var paneConfig = $xeSplitterItem.paneConfig;
      paneConfig.width = val;
    },
    height: function height(val) {
      var $xeSplitterItem = this;
      var paneConfig = $xeSplitterItem.paneConfig;
      paneConfig.height = val;
    },
    minWidth: function minWidth(val) {
      var $xeSplitterItem = this;
      var paneConfig = $xeSplitterItem.paneConfig;
      paneConfig.minWidth = val;
    },
    minHeight: function minHeight(val) {
      var $xeSplitterItem = this;
      var paneConfig = $xeSplitterItem.paneConfig;
      paneConfig.minHeight = val;
    },
    showAction: function showAction(val) {
      var $xeSplitterItem = this;
      var paneConfig = $xeSplitterItem.paneConfig;
      paneConfig.showAction = val;
    }
  },
  methods: {
    //
    // Method
    //
    dispatchEvent: function dispatchEvent(type, params, evnt) {
      var $xeSplitterItem = this;
      $xeSplitterItem.$emit(type, (0, _ui.createEvent)(evnt, {
        $splitterPanel: $xeSplitterItem
      }, params));
    },
    //
    // Render
    //
    renderVN: function renderVN(h) {
      return h('div', {
        ref: 'refElem'
      });
    }
  },
  created: function created() {
    var $xeSplitterItem = this;
    var props = $xeSplitterItem;
    var slots = $xeSplitterItem.$scopedSlots;
    var paneConfig = $xeSplitterItem.paneConfig;
    Object.assign(paneConfig, {
      name: props.name,
      width: props.width,
      height: props.height,
      minWidth: props.minWidth,
      minHeight: props.minHeight,
      showAction: props.showAction,
      slots: slots
    });
  },
  mounted: function mounted() {
    var $xeSplitterItem = this;
    var slots = $xeSplitterItem.$scopedSlots;
    var paneConfig = $xeSplitterItem.paneConfig;
    var $xeSplitter = $xeSplitterItem.$xeSplitter;
    paneConfig.slots = slots;
    var elem = $xeSplitterItem.$refs.refElem;
    if ($xeSplitter && elem) {
      (0, _util.assembleSplitterItem)($xeSplitter, elem, paneConfig);
    }
  },
  beforeDestroy: function beforeDestroy() {
    var $xeSplitterItem = this;
    var paneConfig = $xeSplitterItem.paneConfig;
    var $xeSplitter = $xeSplitterItem.$xeSplitter;
    if ($xeSplitter) {
      (0, _util.destroySplitterItem)($xeSplitter, paneConfig);
    }
  },
  render: function render(h) {
    return this.renderVN(h);
  }
});
/* define-vxe-component end */