"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _comp = require("../../ui/src/comp");
var _xeUtils = _interopRequireDefault(require("xe-utils"));
var _core = require("@vxe-ui/core");
var _button = _interopRequireDefault(require("./button"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
var _default2 = exports.default = /* define-vxe-component start */(0, _comp.defineVxeComponent)({
  name: 'VxeButtonGroup',
  mixins: [_core.globalMixins.sizeMixin, _core.globalMixins.permissionMixin],
  props: {
    options: Array,
    mode: String,
    status: String,
    round: Boolean,
    vertical: Boolean,
    circle: Boolean,
    align: String,
    className: [String, Function],
    disabled: Boolean,
    permissionCode: [String, Number],
    size: {
      type: String,
      default: function _default() {
        return (0, _core.getConfig)().buttonGroup.size || (0, _core.getConfig)().size;
      }
    }
  },
  provide: function provide() {
    var $xeButtonGroup = this;
    return {
      $xeButtonGroup: $xeButtonGroup
    };
  },
  data: function data() {
    var reactData = {};
    return {
      xID: _xeUtils.default.uniqueId(),
      reactData: reactData
    };
  },
  computed: Object.assign({}, {}),
  methods: {
    // Method
    dispatchEvent: function dispatchEvent(type, params, evnt) {
      var $xeButtonGroup = this;
      $xeButtonGroup.$emit(type, (0, _core.createEvent)(evnt, {
        $buttonGroup: $xeButtonGroup
      }, params));
    },
    //
    // Private
    //
    handleClick: function handleClick(params, evnt) {
      var $xeButtonGroup = this;
      var props = $xeButtonGroup;
      var options = props.options;
      var name = params.name;
      var option = options ? options.find(function (item) {
        return item.name === name;
      }) : null;
      $xeButtonGroup.dispatchEvent('click', Object.assign(Object.assign({}, params), {
        option: option
      }), evnt);
    },
    contextmenuEvent: function contextmenuEvent(evnt) {
      var $xeButtonGroup = this;
      $xeButtonGroup.dispatchEvent('contextmenu', {}, evnt);
    },
    //
    // Render
    //
    renderVN: function renderVN(h) {
      var $xeButtonGroup = this;
      var props = $xeButtonGroup;
      var slots = $xeButtonGroup.$scopedSlots;
      var className = props.className,
        options = props.options,
        vertical = props.vertical;
      var permissionInfo = $xeButtonGroup.computePermissionInfo;
      var defaultSlot = slots.default;
      if (!permissionInfo.visible) {
        return (0, _core.renderEmptyElement)($xeButtonGroup);
      }
      return h('div', {
        class: ['vxe-button-group', className ? _xeUtils.default.isFunction(className) ? className({
          $buttonGroup: $xeButtonGroup
        }) : className : '', {
          'is--vertical': vertical
        }],
        on: {
          contextmenu: $xeButtonGroup.contextmenuEvent
        }
      }, defaultSlot ? defaultSlot({}) : options ? options.map(function (item, index) {
        return h(_button.default, {
          key: index,
          props: item
        });
      }) : []);
    }
  },
  render: function render(h) {
    return this.renderVN(h);
  }
});
/* define-vxe-component end */