"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 _ui = require("../../ui");
var _utils = require("../../ui/src/utils");
var _render = require("./render");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
var _default = exports.default = /* define-vxe-component start */(0, _comp.defineVxeComponent)({
  name: 'VxeFormConfigItem',
  mixins: [_ui.globalMixins.sizeMixin],
  props: {
    itemConfig: Object
  },
  inject: {
    $xeForm: {
      default: null
    }
  },
  provide: function provide() {
    var xeFormItemInfo = this;
    return {
      xeFormItemInfo: xeFormItemInfo,
      $xeFormGroup: null
    };
  },
  computed: Object.assign({}, {}),
  methods: {
    renderItem: function renderItem(h, $xeForm, item) {
      var $xeFormConfigItem = this;
      var formProps = $xeForm;
      var data = formProps.data,
        readonly = formProps.readonly,
        disabled = formProps.disabled;
      var visible = item.visible,
        field = item.field,
        itemRender = item.itemRender,
        contentStyle = item.contentStyle,
        children = item.children,
        showContent = item.showContent;
      var compConf = (0, _utils.isEnableConf)(itemRender) ? _ui.renderer.get(itemRender.name) : null;
      var itemStyle = compConf ? compConf.formItemStyle || compConf.itemStyle : null;
      var itemContentStyle = compConf ? compConf.formItemContentStyle || compConf.itemContentStyle : null;
      var params = {
        data: data,
        disabled: disabled,
        readonly: readonly,
        field: field,
        property: field,
        item: item,
        $form: $xeForm,
        $grid: $xeForm.$xeGrid
      };
      var hasGroup = children && children.length > 0;
      if (visible === false) {
        return (0, _ui.renderEmptyElement)($xeFormConfigItem);
      }
      return h('div', {
        key: item.id,
        class: (0, _render.getItemClass)($xeForm, item),
        style: _xeUtils.default.isFunction(itemStyle) ? itemStyle(params) : itemStyle || {},
        attrs: {
          itemid: item.id
        }
      }, [(0, _render.renderTitle)(h, $xeForm, item), showContent === false ? (0, _ui.renderEmptyElement)($xeFormConfigItem) : h('div', {
        class: (0, _render.getItemContentClass)($xeForm, item),
        style: Object.assign({}, _xeUtils.default.isFunction(itemContentStyle) ? itemContentStyle(params) : itemContentStyle, _xeUtils.default.isFunction(contentStyle) ? contentStyle(params) : contentStyle)
      }, hasGroup ? children.map(function (childItem) {
        return $xeFormConfigItem.renderItem(h, $xeForm, childItem);
      }) : [(0, _render.renderItemContent)(h, $xeForm, item), (0, _render.renderItemErrorIcon)(h, $xeForm, item)])]);
    },
    renderVN: function renderVN(h) {
      var $xeFormConfigItem = this;
      var props = $xeFormConfigItem;
      var $xeForm = $xeFormConfigItem.$xeForm;
      return $xeFormConfigItem.renderItem(h, $xeForm, props.itemConfig);
    }
  },
  render: function render(h) {
    return this.renderVN(h);
  }
});
/* define-vxe-component end */