"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.Cell = void 0;
var _vue = require("vue");
var _xeUtils = _interopRequireDefault(require("xe-utils"));
var _conf = _interopRequireDefault(require("../../v-x-e-table/src/conf"));
var _vXETable = require("../../v-x-e-table");
var _utils = require("../../tools/utils");
var _dom = require("../../tools/dom");
var _util = require("./util");
var _vn = require("../../tools/vn");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var __assign = void 0 && (void 0).__assign || function () {
  __assign = Object.assign || function (t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
function renderTitlePrefixIcon(params) {
  var $table = params.$table,
    column = params.column;
  var titlePrefix = column.titlePrefix || column.titleHelp;
  return titlePrefix ? [(0, _vue.h)('i', {
    class: ['vxe-cell-title-prefix-icon', titlePrefix.icon || _conf.default.icon.TABLE_TITLE_PREFIX],
    onMouseenter: function (evnt) {
      $table.triggerHeaderTitleEvent(evnt, titlePrefix, params);
    },
    onMouseleave: function (evnt) {
      $table.handleTargetLeaveEvent(evnt);
    }
  })] : [];
}
function renderTitleSuffixIcon(params) {
  var $table = params.$table,
    column = params.column;
  var titleSuffix = column.titleSuffix;
  return titleSuffix ? [(0, _vue.h)('i', {
    class: ['vxe-cell-title-suffix-icon', titleSuffix.icon || _conf.default.icon.TABLE_TITLE_SUFFIX],
    onMouseenter: function (evnt) {
      $table.triggerHeaderTitleEvent(evnt, titleSuffix, params);
    },
    onMouseleave: function (evnt) {
      $table.handleTargetLeaveEvent(evnt);
    }
  })] : [];
}
function renderTitleContent(params, content) {
  var $table = params.$table,
    column = params.column;
  var props = $table.props,
    reactData = $table.reactData;
  var computeTooltipOpts = $table.getComputeMaps().computeTooltipOpts;
  var allColumnHeaderOverflow = props.showHeaderOverflow;
  var type = column.type,
    showHeaderOverflow = column.showHeaderOverflow;
  var tooltipOpts = computeTooltipOpts.value;
  var showAllTip = tooltipOpts.showAll;
  var headOverflow = _xeUtils.default.isUndefined(showHeaderOverflow) || _xeUtils.default.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
  var showTitle = headOverflow === 'title';
  var showTooltip = headOverflow === true || headOverflow === 'tooltip';
  var ons = {};
  if (showTitle || showTooltip || showAllTip) {
    ons.onMouseenter = function (evnt) {
      if (reactData._isResize) {
        return;
      }
      if (showTitle) {
        (0, _dom.updateCellTitle)(evnt.currentTarget, column);
      } else if (showTooltip || showAllTip) {
        $table.triggerHeaderTooltipEvent(evnt, params);
      }
    };
  }
  if (showTooltip || showAllTip) {
    ons.onMouseleave = function (evnt) {
      if (reactData._isResize) {
        return;
      }
      if (showTooltip || showAllTip) {
        $table.handleTargetLeaveEvent(evnt);
      }
    };
  }
  return [type === 'html' && _xeUtils.default.isString(content) ? (0, _vue.h)('span', __assign({
    class: 'vxe-cell--title',
    innerHTML: content
  }, ons)) : (0, _vue.h)('span', __assign({
    class: 'vxe-cell--title'
  }, ons), (0, _vn.getSlotVNs)(content))];
}
function getFooterContent(params) {
  var $table = params.$table,
    column = params.column,
    _columnIndex = params._columnIndex,
    items = params.items,
    row = params.row;
  var slots = column.slots,
    editRender = column.editRender,
    cellRender = column.cellRender;
  var renderOpts = editRender || cellRender;
  var footerSlot = slots ? slots.footer : null;
  if (footerSlot) {
    return $table.callSlot(footerSlot, params);
  }
  if (renderOpts) {
    var compConf = _vXETable.VXETable.renderer.get(renderOpts.name);
    if (compConf && compConf.renderFooter) {
      return (0, _vn.getSlotVNs)(compConf.renderFooter(renderOpts, params));
    }
  }
  // 兼容老模式
  if (_xeUtils.default.isArray(items)) {
    return [(0, _utils.formatText)(items[_columnIndex], 1)];
  }
  return [(0, _utils.formatText)(_xeUtils.default.get(row, column.field), 1)];
}
function getDefaultCellLabel(params) {
  var $table = params.$table,
    row = params.row,
    column = params.column;
  return (0, _utils.formatText)($table.getCellLabel(row, column), 1);
}
var Cell = {
  createColumn: function ($xetable, columnOpts) {
    var type = columnOpts.type,
      sortable = columnOpts.sortable,
      filters = columnOpts.filters,
      editRender = columnOpts.editRender,
      treeNode = columnOpts.treeNode;
    var props = $xetable.props;
    var editConfig = props.editConfig;
    var _a = $xetable.getComputeMaps(),
      computeEditOpts = _a.computeEditOpts,
      computeCheckboxOpts = _a.computeCheckboxOpts;
    var checkboxOpts = computeCheckboxOpts.value;
    var editOpts = computeEditOpts.value;
    var renConfs = {
      renderHeader: Cell.renderDefaultHeader,
      renderCell: treeNode ? Cell.renderTreeCell : Cell.renderDefaultCell,
      renderFooter: Cell.renderDefaultFooter
    };
    switch (type) {
      case 'seq':
        renConfs.renderHeader = Cell.renderSeqHeader;
        renConfs.renderCell = treeNode ? Cell.renderTreeIndexCell : Cell.renderSeqCell;
        break;
      case 'radio':
        renConfs.renderHeader = Cell.renderRadioHeader;
        renConfs.renderCell = treeNode ? Cell.renderTreeRadioCell : Cell.renderRadioCell;
        break;
      case 'checkbox':
        renConfs.renderHeader = Cell.renderCheckboxHeader;
        renConfs.renderCell = checkboxOpts.checkField ? treeNode ? Cell.renderTreeSelectionCellByProp : Cell.renderCheckboxCellByProp : treeNode ? Cell.renderTreeSelectionCell : Cell.renderCheckboxCell;
        break;
      case 'expand':
        renConfs.renderCell = Cell.renderExpandCell;
        renConfs.renderData = Cell.renderExpandData;
        break;
      case 'html':
        renConfs.renderCell = treeNode ? Cell.renderTreeHTMLCell : Cell.renderHTMLCell;
        if (filters && sortable) {
          renConfs.renderHeader = Cell.renderSortAndFilterHeader;
        } else if (sortable) {
          renConfs.renderHeader = Cell.renderSortHeader;
        } else if (filters) {
          renConfs.renderHeader = Cell.renderFilterHeader;
        }
        break;
      default:
        if (editConfig && editRender) {
          renConfs.renderHeader = Cell.renderEditHeader;
          renConfs.renderCell = editOpts.mode === 'cell' ? treeNode ? Cell.renderTreeCellEdit : Cell.renderCellEdit : treeNode ? Cell.renderTreeRowEdit : Cell.renderRowEdit;
        } else if (filters && sortable) {
          renConfs.renderHeader = Cell.renderSortAndFilterHeader;
        } else if (sortable) {
          renConfs.renderHeader = Cell.renderSortHeader;
        } else if (filters) {
          renConfs.renderHeader = Cell.renderFilterHeader;
        }
    }
    return (0, _util.createColumn)($xetable, columnOpts, renConfs);
  },
  /**
   * 单元格
   */
  renderHeaderTitle: function (params) {
    var $table = params.$table,
      column = params.column;
    var slots = column.slots,
      editRender = column.editRender,
      cellRender = column.cellRender;
    var renderOpts = editRender || cellRender;
    var headerSlot = slots ? slots.header : null;
    if (headerSlot) {
      return renderTitleContent(params, $table.callSlot(headerSlot, params));
    }
    if (renderOpts) {
      var compConf = _vXETable.VXETable.renderer.get(renderOpts.name);
      if (compConf && compConf.renderHeader) {
        return renderTitleContent(params, (0, _vn.getSlotVNs)(compConf.renderHeader(renderOpts, params)));
      }
    }
    return renderTitleContent(params, (0, _utils.formatText)(column.getTitle(), 1));
  },
  renderDefaultHeader: function (params) {
    return renderTitlePrefixIcon(params).concat(Cell.renderHeaderTitle(params)).concat(renderTitleSuffixIcon(params));
  },
  renderDefaultCell: function (params) {
    var $table = params.$table,
      row = params.row,
      column = params.column;
    var slots = column.slots,
      editRender = column.editRender,
      cellRender = column.cellRender;
    var renderOpts = editRender || cellRender;
    var defaultSlot = slots ? slots.default : null;
    if (defaultSlot) {
      return $table.callSlot(defaultSlot, params);
    }
    if (renderOpts) {
      var funName = editRender ? 'renderCell' : 'renderDefault';
      var compConf = _vXETable.VXETable.renderer.get(renderOpts.name);
      var compFn = compConf ? compConf[funName] : null;
      if (compFn) {
        return (0, _vn.getSlotVNs)(compFn(renderOpts, Object.assign({
          $type: editRender ? 'edit' : 'cell'
        }, params)));
      }
    }
    var cellValue = $table.getCellLabel(row, column);
    var cellPlaceholder = editRender ? editRender.placeholder : '';
    return [(0, _vue.h)('span', {
      class: 'vxe-cell--label'
    }, editRender && (0, _utils.eqEmptyValue)(cellValue) ? [
    // 如果设置占位符
    (0, _vue.h)('span', {
      class: 'vxe-cell--placeholder'
    }, (0, _utils.formatText)((0, _utils.getFuncText)(cellPlaceholder), 1))] : (0, _utils.formatText)(cellValue, 1))];
  },
  renderTreeCell: function (params) {
    return Cell.renderTreeIcon(params, Cell.renderDefaultCell(params));
  },
  renderDefaultFooter: function (params) {
    return [(0, _vue.h)('span', {
      class: 'vxe-cell--item'
    }, getFooterContent(params))];
  },
  /**
   * 树节点
   */
  renderTreeIcon: function (params, cellVNodes) {
    var $table = params.$table,
      isHidden = params.isHidden;
    var reactData = $table.reactData;
    var computeTreeOpts = $table.getComputeMaps().computeTreeOpts;
    var treeExpandedMaps = reactData.treeExpandedMaps,
      treeExpandLazyLoadedMaps = reactData.treeExpandLazyLoadedMaps;
    var treeOpts = computeTreeOpts.value;
    var row = params.row,
      column = params.column,
      level = params.level;
    var slots = column.slots;
    var indent = treeOpts.indent,
      lazy = treeOpts.lazy,
      trigger = treeOpts.trigger,
      iconLoaded = treeOpts.iconLoaded,
      showIcon = treeOpts.showIcon,
      iconOpen = treeOpts.iconOpen,
      iconClose = treeOpts.iconClose;
    var childrenField = treeOpts.children || treeOpts.childrenField;
    var hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
    var rowChilds = row[childrenField];
    var iconSlot = slots ? slots.icon : null;
    var hasLazyChilds = false;
    var isAceived = false;
    var isLazyLoaded = false;
    var ons = {};
    if (iconSlot) {
      return $table.callSlot(iconSlot, params);
    }
    if (!isHidden) {
      var rowid = (0, _util.getRowid)($table, row);
      isAceived = !!treeExpandedMaps[rowid];
      if (lazy) {
        isLazyLoaded = !!treeExpandLazyLoadedMaps[rowid];
        hasLazyChilds = row[hasChildField];
      }
    }
    if (!trigger || trigger === 'default') {
      ons.onClick = function (evnt) {
        evnt.stopPropagation();
        $table.triggerTreeExpandEvent(evnt, params);
      };
    }
    return [(0, _vue.h)('div', {
      class: ['vxe-cell--tree-node', {
        'is--active': isAceived
      }],
      style: {
        paddingLeft: "".concat(level * indent, "px")
      }
    }, [showIcon && (rowChilds && rowChilds.length || hasLazyChilds) ? [(0, _vue.h)('div', __assign({
      class: 'vxe-tree--btn-wrapper'
    }, ons), [(0, _vue.h)('i', {
      class: ['vxe-tree--node-btn', isLazyLoaded ? iconLoaded || _conf.default.icon.TABLE_TREE_LOADED : isAceived ? iconOpen || _conf.default.icon.TABLE_TREE_OPEN : iconClose || _conf.default.icon.TABLE_TREE_CLOSE]
    })])] : null, (0, _vue.h)('div', {
      class: 'vxe-tree-cell'
    }, cellVNodes)])];
  },
  /**
   * 索引
   */
  renderSeqHeader: function (params) {
    var $table = params.$table,
      column = params.column;
    var slots = column.slots;
    var headerSlot = slots ? slots.header : null;
    return renderTitleContent(params, headerSlot ? $table.callSlot(headerSlot, params) : (0, _utils.formatText)(column.getTitle(), 1));
  },
  renderSeqCell: function (params) {
    var $table = params.$table,
      column = params.column;
    var props = $table.props;
    var treeConfig = props.treeConfig;
    var computeSeqOpts = $table.getComputeMaps().computeSeqOpts;
    var seqOpts = computeSeqOpts.value;
    var slots = column.slots;
    var defaultSlot = slots ? slots.default : null;
    if (defaultSlot) {
      return $table.callSlot(defaultSlot, params);
    }
    var seq = params.seq;
    var seqMethod = seqOpts.seqMethod;
    return [(0, _utils.formatText)(seqMethod ? seqMethod(params) : treeConfig ? seq : (seqOpts.startIndex || 0) + seq, 1)];
  },
  renderTreeIndexCell: function (params) {
    return Cell.renderTreeIcon(params, Cell.renderSeqCell(params));
  },
  /**
   * 单选
   */
  renderRadioHeader: function (params) {
    var $table = params.$table,
      column = params.column;
    var slots = column.slots;
    var headerSlot = slots ? slots.header : null;
    var titleSlot = slots ? slots.title : null;
    return renderTitleContent(params, headerSlot ? $table.callSlot(headerSlot, params) : [(0, _vue.h)('span', {
      class: 'vxe-radio--label'
    }, titleSlot ? $table.callSlot(titleSlot, params) : (0, _utils.formatText)(column.getTitle(), 1))]);
  },
  renderRadioCell: function (params) {
    var $table = params.$table,
      column = params.column,
      isHidden = params.isHidden;
    var reactData = $table.reactData;
    var computeRadioOpts = $table.getComputeMaps().computeRadioOpts;
    var selectRadioRow = reactData.selectRadioRow;
    var radioOpts = computeRadioOpts.value;
    var slots = column.slots;
    var labelField = radioOpts.labelField,
      checkMethod = radioOpts.checkMethod,
      visibleMethod = radioOpts.visibleMethod;
    var row = params.row;
    var defaultSlot = slots ? slots.default : null;
    var radioSlot = slots ? slots.radio : null;
    var isChecked = $table.eqRow(row, selectRadioRow);
    var isVisible = !visibleMethod || visibleMethod({
      row: row
    });
    var isDisabled = !!checkMethod;
    var ons;
    if (!isHidden) {
      ons = {
        onClick: function (evnt) {
          if (!isDisabled && isVisible) {
            evnt.stopPropagation();
            $table.triggerRadioRowEvent(evnt, params);
          }
        }
      };
      if (checkMethod) {
        isDisabled = !checkMethod({
          row: row
        });
      }
    }
    var radioParams = __assign(__assign({}, params), {
      checked: isChecked,
      disabled: isDisabled,
      visible: isVisible
    });
    if (radioSlot) {
      return $table.callSlot(radioSlot, radioParams);
    }
    var radioVNs = [];
    if (isVisible) {
      radioVNs.push((0, _vue.h)('span', {
        class: ['vxe-radio--icon', isChecked ? _conf.default.icon.TABLE_RADIO_CHECKED : _conf.default.icon.TABLE_RADIO_UNCHECKED]
      }));
    }
    if (defaultSlot || labelField) {
      radioVNs.push((0, _vue.h)('span', {
        class: 'vxe-radio--label'
      }, defaultSlot ? $table.callSlot(defaultSlot, radioParams) : _xeUtils.default.get(row, labelField)));
    }
    return [(0, _vue.h)('span', __assign({
      class: ['vxe-cell--radio', {
        'is--checked': isChecked,
        'is--disabled': isDisabled
      }]
    }, ons), radioVNs)];
  },
  renderTreeRadioCell: function (params) {
    return Cell.renderTreeIcon(params, Cell.renderRadioCell(params));
  },
  /**
   * 多选
   */
  renderCheckboxHeader: function (params) {
    var $table = params.$table,
      column = params.column,
      isHidden = params.isHidden;
    var reactData = $table.reactData;
    var _a = $table.getComputeMaps(),
      computeIsAllCheckboxDisabled = _a.computeIsAllCheckboxDisabled,
      computeCheckboxOpts = _a.computeCheckboxOpts;
    var isAllCheckboxSelected = reactData.isAllSelected,
      isAllCheckboxIndeterminate = reactData.isIndeterminate;
    var isAllCheckboxDisabled = computeIsAllCheckboxDisabled.value;
    var slots = column.slots;
    var headerSlot = slots ? slots.header : null;
    var titleSlot = slots ? slots.title : null;
    var checkboxOpts = computeCheckboxOpts.value;
    var headerTitle = column.getTitle();
    var ons;
    if (!isHidden) {
      ons = {
        onClick: function (evnt) {
          if (!isAllCheckboxDisabled) {
            evnt.stopPropagation();
            $table.triggerCheckAllEvent(evnt, !isAllCheckboxSelected);
          }
        }
      };
    }
    var checkboxParams = __assign(__assign({}, params), {
      checked: isAllCheckboxSelected,
      disabled: isAllCheckboxDisabled,
      indeterminate: isAllCheckboxIndeterminate
    });
    if (headerSlot) {
      return renderTitleContent(checkboxParams, $table.callSlot(headerSlot, checkboxParams));
    }
    if (checkboxOpts.checkStrictly ? !checkboxOpts.showHeader : checkboxOpts.showHeader === false) {
      return renderTitleContent(checkboxParams, [(0, _vue.h)('span', {
        class: 'vxe-checkbox--label'
      }, titleSlot ? $table.callSlot(titleSlot, checkboxParams) : headerTitle)]);
    }
    return renderTitleContent(checkboxParams, [(0, _vue.h)('span', __assign({
      class: ['vxe-cell--checkbox', {
        'is--checked': isAllCheckboxSelected,
        'is--disabled': isAllCheckboxDisabled,
        'is--indeterminate': isAllCheckboxIndeterminate
      }],
      title: _conf.default.i18n('vxe.table.allTitle')
    }, ons), [(0, _vue.h)('span', {
      class: ['vxe-checkbox--icon', isAllCheckboxIndeterminate ? _conf.default.icon.TABLE_CHECKBOX_INDETERMINATE : isAllCheckboxSelected ? _conf.default.icon.TABLE_CHECKBOX_CHECKED : _conf.default.icon.TABLE_CHECKBOX_UNCHECKED]
    })].concat(titleSlot || headerTitle ? [(0, _vue.h)('span', {
      class: 'vxe-checkbox--label'
    }, titleSlot ? $table.callSlot(titleSlot, checkboxParams) : headerTitle)] : []))]);
  },
  renderCheckboxCell: function (params) {
    var $table = params.$table,
      row = params.row,
      column = params.column,
      isHidden = params.isHidden;
    var props = $table.props,
      reactData = $table.reactData;
    var treeConfig = props.treeConfig;
    var selectCheckboxMaps = reactData.selectCheckboxMaps,
      treeIndeterminateMaps = reactData.treeIndeterminateMaps;
    var computeCheckboxOpts = $table.getComputeMaps().computeCheckboxOpts;
    var checkboxOpts = computeCheckboxOpts.value;
    var labelField = checkboxOpts.labelField,
      checkMethod = checkboxOpts.checkMethod,
      visibleMethod = checkboxOpts.visibleMethod;
    var slots = column.slots;
    var defaultSlot = slots ? slots.default : null;
    var checkboxSlot = slots ? slots.checkbox : null;
    var indeterminate = false;
    var isChecked = false;
    var isVisible = !visibleMethod || visibleMethod({
      row: row
    });
    var isDisabled = !!checkMethod;
    var ons;
    if (!isHidden) {
      var rowid = (0, _util.getRowid)($table, row);
      isChecked = !!selectCheckboxMaps[rowid];
      ons = {
        onClick: function (evnt) {
          if (!isDisabled && isVisible) {
            evnt.stopPropagation();
            $table.triggerCheckRowEvent(evnt, params, !isChecked);
          }
        }
      };
      if (checkMethod) {
        isDisabled = !checkMethod({
          row: row
        });
      }
      if (treeConfig) {
        indeterminate = !!treeIndeterminateMaps[rowid];
      }
    }
    var checkboxParams = __assign(__assign({}, params), {
      checked: isChecked,
      disabled: isDisabled,
      visible: isVisible,
      indeterminate: indeterminate
    });
    if (checkboxSlot) {
      return $table.callSlot(checkboxSlot, checkboxParams);
    }
    var checkVNs = [];
    if (isVisible) {
      checkVNs.push((0, _vue.h)('span', {
        class: ['vxe-checkbox--icon', indeterminate ? _conf.default.icon.TABLE_CHECKBOX_INDETERMINATE : isChecked ? _conf.default.icon.TABLE_CHECKBOX_CHECKED : _conf.default.icon.TABLE_CHECKBOX_UNCHECKED]
      }));
    }
    if (defaultSlot || labelField) {
      checkVNs.push((0, _vue.h)('span', {
        class: 'vxe-checkbox--label'
      }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams) : _xeUtils.default.get(row, labelField)));
    }
    return [(0, _vue.h)('span', __assign({
      class: ['vxe-cell--checkbox', {
        'is--checked': isChecked,
        'is--disabled': isDisabled,
        'is--indeterminate': indeterminate
      }]
    }, ons), checkVNs)];
  },
  renderTreeSelectionCell: function (params) {
    return Cell.renderTreeIcon(params, Cell.renderCheckboxCell(params));
  },
  renderCheckboxCellByProp: function (params) {
    var $table = params.$table,
      row = params.row,
      column = params.column,
      isHidden = params.isHidden;
    var props = $table.props,
      reactData = $table.reactData;
    var treeConfig = props.treeConfig;
    var treeIndeterminateMaps = reactData.treeIndeterminateMaps;
    var computeCheckboxOpts = $table.getComputeMaps().computeCheckboxOpts;
    var checkboxOpts = computeCheckboxOpts.value;
    var labelField = checkboxOpts.labelField,
      checkField = checkboxOpts.checkField,
      checkMethod = checkboxOpts.checkMethod,
      visibleMethod = checkboxOpts.visibleMethod;
    var indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
    var slots = column.slots;
    var defaultSlot = slots ? slots.default : null;
    var checkboxSlot = slots ? slots.checkbox : null;
    var isIndeterminate = false;
    var isChecked = false;
    var isVisible = !visibleMethod || visibleMethod({
      row: row
    });
    var isDisabled = !!checkMethod;
    var ons;
    if (!isHidden) {
      var rowid = (0, _util.getRowid)($table, row);
      isChecked = _xeUtils.default.get(row, checkField);
      ons = {
        onClick: function (evnt) {
          if (!isDisabled && isVisible) {
            evnt.stopPropagation();
            $table.triggerCheckRowEvent(evnt, params, !isChecked);
          }
        }
      };
      if (checkMethod) {
        isDisabled = !checkMethod({
          row: row
        });
      }
      if (treeConfig) {
        isIndeterminate = !!treeIndeterminateMaps[rowid];
      }
    }
    var checkboxParams = __assign(__assign({}, params), {
      checked: isChecked,
      disabled: isDisabled,
      visible: isVisible,
      indeterminate: isIndeterminate
    });
    if (checkboxSlot) {
      return $table.callSlot(checkboxSlot, checkboxParams);
    }
    var checkVNs = [];
    if (isVisible) {
      checkVNs.push((0, _vue.h)('span', {
        class: ['vxe-checkbox--icon', isIndeterminate ? _conf.default.icon.TABLE_CHECKBOX_INDETERMINATE : isChecked ? _conf.default.icon.TABLE_CHECKBOX_CHECKED : _conf.default.icon.TABLE_CHECKBOX_UNCHECKED]
      }));
      if (defaultSlot || labelField) {
        checkVNs.push((0, _vue.h)('span', {
          class: 'vxe-checkbox--label'
        }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams) : _xeUtils.default.get(row, labelField)));
      }
    }
    return [(0, _vue.h)('span', __assign({
      class: ['vxe-cell--checkbox', {
        'is--checked': isChecked,
        'is--disabled': isDisabled,
        'is--indeterminate': indeterminateField && !isChecked ? row[indeterminateField] : isIndeterminate
      }]
    }, ons), checkVNs)];
  },
  renderTreeSelectionCellByProp: function (params) {
    return Cell.renderTreeIcon(params, Cell.renderCheckboxCellByProp(params));
  },
  /**
   * 展开行
   */
  renderExpandCell: function (params) {
    var $table = params.$table,
      isHidden = params.isHidden,
      row = params.row,
      column = params.column;
    var reactData = $table.reactData;
    var rowExpandedMaps = reactData.rowExpandedMaps,
      rowExpandLazyLoadedMaps = reactData.rowExpandLazyLoadedMaps;
    var computeExpandOpts = $table.getComputeMaps().computeExpandOpts;
    var expandOpts = computeExpandOpts.value;
    var lazy = expandOpts.lazy,
      labelField = expandOpts.labelField,
      iconLoaded = expandOpts.iconLoaded,
      showIcon = expandOpts.showIcon,
      iconOpen = expandOpts.iconOpen,
      iconClose = expandOpts.iconClose,
      visibleMethod = expandOpts.visibleMethod;
    var slots = column.slots;
    var defaultSlot = slots ? slots.default : null;
    var iconSlot = slots ? slots.icon : null;
    var isAceived = false;
    var isLazyLoaded = false;
    if (iconSlot) {
      return $table.callSlot(iconSlot, params);
    }
    if (!isHidden) {
      var rowid = (0, _util.getRowid)($table, row);
      isAceived = !!rowExpandedMaps[rowid];
      if (lazy) {
        isLazyLoaded = !!rowExpandLazyLoadedMaps[rowid];
      }
    }
    return [showIcon && (!visibleMethod || visibleMethod(params)) ? (0, _vue.h)('span', {
      class: ['vxe-table--expanded', {
        'is--active': isAceived
      }],
      onClick: function (evnt) {
        evnt.stopPropagation();
        $table.triggerRowExpandEvent(evnt, params);
      }
    }, [(0, _vue.h)('i', {
      class: ['vxe-table--expand-btn', isLazyLoaded ? iconLoaded || _conf.default.icon.TABLE_EXPAND_LOADED : isAceived ? iconOpen || _conf.default.icon.TABLE_EXPAND_OPEN : iconClose || _conf.default.icon.TABLE_EXPAND_CLOSE]
    })]) : null, defaultSlot || labelField ? (0, _vue.h)('span', {
      class: 'vxe-table--expand-label'
    }, defaultSlot ? $table.callSlot(defaultSlot, params) : _xeUtils.default.get(row, labelField)) : null];
  },
  renderExpandData: function (params) {
    var $table = params.$table,
      column = params.column;
    var slots = column.slots,
      contentRender = column.contentRender;
    var contentSlot = slots ? slots.content : null;
    if (contentSlot) {
      return $table.callSlot(contentSlot, params);
    }
    if (contentRender) {
      var compConf = _vXETable.VXETable.renderer.get(contentRender.name);
      if (compConf && compConf.renderExpand) {
        return (0, _vn.getSlotVNs)(compConf.renderExpand(contentRender, params));
      }
    }
    return [];
  },
  /**
   * HTML 标签
   */
  renderHTMLCell: function (params) {
    var $table = params.$table,
      column = params.column;
    var slots = column.slots;
    var defaultSlot = slots ? slots.default : null;
    if (defaultSlot) {
      return $table.callSlot(defaultSlot, params);
    }
    return [(0, _vue.h)('span', {
      class: 'vxe-cell--html',
      innerHTML: getDefaultCellLabel(params)
    })];
  },
  renderTreeHTMLCell: function (params) {
    return Cell.renderTreeIcon(params, Cell.renderHTMLCell(params));
  },
  /**
   * 排序和筛选
   */
  renderSortAndFilterHeader: function (params) {
    return Cell.renderDefaultHeader(params).concat(Cell.renderSortIcon(params)).concat(Cell.renderFilterIcon(params));
  },
  /**
   * 排序
   */
  renderSortHeader: function (params) {
    return Cell.renderDefaultHeader(params).concat(Cell.renderSortIcon(params));
  },
  renderSortIcon: function (params) {
    var $table = params.$table,
      column = params.column;
    var computeSortOpts = $table.getComputeMaps().computeSortOpts;
    var sortOpts = computeSortOpts.value;
    var showIcon = sortOpts.showIcon,
      iconLayout = sortOpts.iconLayout,
      iconAsc = sortOpts.iconAsc,
      iconDesc = sortOpts.iconDesc;
    var order = column.order;
    if (showIcon) {
      return [(0, _vue.h)('span', {
        class: ['vxe-cell--sort', "vxe-cell--sort-".concat(iconLayout, "-layout")]
      }, [(0, _vue.h)('i', {
        class: ['vxe-sort--asc-btn', iconAsc || _conf.default.icon.TABLE_SORT_ASC, {
          'sort--active': order === 'asc'
        }],
        title: _conf.default.i18n('vxe.table.sortAsc'),
        onClick: function (evnt) {
          evnt.stopPropagation();
          $table.triggerSortEvent(evnt, column, 'asc');
        }
      }), (0, _vue.h)('i', {
        class: ['vxe-sort--desc-btn', iconDesc || _conf.default.icon.TABLE_SORT_DESC, {
          'sort--active': order === 'desc'
        }],
        title: _conf.default.i18n('vxe.table.sortDesc'),
        onClick: function (evnt) {
          evnt.stopPropagation();
          $table.triggerSortEvent(evnt, column, 'desc');
        }
      })])];
    }
    return [];
  },
  /**
   * 筛选
   */
  renderFilterHeader: function (params) {
    return Cell.renderDefaultHeader(params).concat(Cell.renderFilterIcon(params));
  },
  renderFilterIcon: function (params) {
    var $table = params.$table,
      column = params.column,
      hasFilter = params.hasFilter;
    var reactData = $table.reactData;
    var filterStore = reactData.filterStore;
    var computeFilterOpts = $table.getComputeMaps().computeFilterOpts;
    var filterOpts = computeFilterOpts.value;
    var showIcon = filterOpts.showIcon,
      iconNone = filterOpts.iconNone,
      iconMatch = filterOpts.iconMatch;
    return showIcon ? [(0, _vue.h)('span', {
      class: ['vxe-cell--filter', {
        'is--active': filterStore.visible && filterStore.column === column
      }]
    }, [(0, _vue.h)('i', {
      class: ['vxe-filter--btn', hasFilter ? iconMatch || _conf.default.icon.TABLE_FILTER_MATCH : iconNone || _conf.default.icon.TABLE_FILTER_NONE],
      title: _conf.default.i18n('vxe.table.filter'),
      onClick: function (evnt) {
        if ($table.triggerFilterEvent) {
          $table.triggerFilterEvent(evnt, params.column, params);
        }
      }
    })])] : [];
  },
  /**
   * 可编辑
   */
  renderEditHeader: function (params) {
    var $table = params.$table,
      column = params.column;
    var props = $table.props;
    var computeEditOpts = $table.getComputeMaps().computeEditOpts;
    var editConfig = props.editConfig,
      editRules = props.editRules;
    var editOpts = computeEditOpts.value;
    var sortable = column.sortable,
      filters = column.filters,
      editRender = column.editRender;
    var isRequired = false;
    if (editRules) {
      var columnRules = _xeUtils.default.get(editRules, column.field);
      if (columnRules) {
        isRequired = columnRules.some(function (rule) {
          return rule.required;
        });
      }
    }
    return ((0, _utils.isEnableConf)(editConfig) ? [isRequired && editOpts.showAsterisk ? (0, _vue.h)('i', {
      class: 'vxe-cell--required-icon'
    }) : null, (0, _utils.isEnableConf)(editRender) && editOpts.showIcon ? (0, _vue.h)('i', {
      class: ['vxe-cell--edit-icon', editOpts.icon || _conf.default.icon.TABLE_EDIT]
    }) : null] : []).concat(Cell.renderDefaultHeader(params)).concat(sortable ? Cell.renderSortIcon(params) : []).concat(filters ? Cell.renderFilterIcon(params) : []);
  },
  // 行格编辑模式
  renderRowEdit: function (params) {
    var $table = params.$table,
      column = params.column;
    var reactData = $table.reactData;
    var editStore = reactData.editStore;
    var actived = editStore.actived;
    var editRender = column.editRender;
    return Cell.runRenderer(params, (0, _utils.isEnableConf)(editRender) && actived && actived.row === params.row);
  },
  renderTreeRowEdit: function (params) {
    return Cell.renderTreeIcon(params, Cell.renderRowEdit(params));
  },
  // 单元格编辑模式
  renderCellEdit: function (params) {
    var $table = params.$table,
      column = params.column;
    var reactData = $table.reactData;
    var editStore = reactData.editStore;
    var actived = editStore.actived;
    var editRender = column.editRender;
    return Cell.runRenderer(params, (0, _utils.isEnableConf)(editRender) && actived && actived.row === params.row && actived.column === params.column);
  },
  renderTreeCellEdit: function (params) {
    return Cell.renderTreeIcon(params, Cell.renderCellEdit(params));
  },
  runRenderer: function (params, isEdit) {
    var $table = params.$table,
      column = params.column;
    var slots = column.slots,
      editRender = column.editRender,
      formatter = column.formatter;
    var defaultSlot = slots ? slots.default : null;
    var editSlot = slots ? slots.edit : null;
    var compConf = _vXETable.VXETable.renderer.get(editRender.name);
    if (isEdit) {
      if (editSlot) {
        return $table.callSlot(editSlot, params);
      }
      if (compConf && compConf.renderEdit) {
        return (0, _vn.getSlotVNs)(compConf.renderEdit(editRender, Object.assign({
          $type: 'edit'
        }, params)));
      }
      return [];
    }
    if (defaultSlot) {
      return $table.callSlot(defaultSlot, params);
    }
    if (formatter) {
      return [(0, _vue.h)('span', {
        class: 'vxe-cell--label'
      }, getDefaultCellLabel(params))];
    }
    return Cell.renderDefaultCell(params);
  }
};
exports.Cell = Cell;
var _default = Cell;
exports.default = _default;