"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.Cell = void 0;
var _xeUtils = _interopRequireDefault(require("xe-utils"));
var _ui = require("../../ui");
var _utils = require("../../ui/src/utils");
var _dom = require("../../ui/src/dom");
var _util = require("./util");
var _vn = require("../../ui/src/vn");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const {
  getI18n,
  getIcon,
  renderer,
  formats,
  renderEmptyElement
} = _ui.VxeUI;
function renderTitlePrefixIcon(h, params) {
  const {
    $table,
    column
  } = params;
  const titlePrefix = column.titlePrefix || column.titleHelp;
  if (titlePrefix) {
    return h('i', {
      class: ['vxe-cell-title-prefix-icon', titlePrefix.iconStatus ? `theme--${titlePrefix.iconStatus}` : ''],
      on: {
        mouseenter(evnt) {
          $table.triggerHeaderTitleEvent(evnt, titlePrefix, params);
        },
        mouseleave(evnt) {
          $table.handleTargetLeaveEvent(evnt);
        }
      }
    }, [h('i', {
      class: titlePrefix.icon || getIcon().TABLE_TITLE_PREFIX
    })]);
  }
  return renderEmptyElement($table);
}
function renderTitleSuffixIcon(h, params) {
  const {
    $table,
    column
  } = params;
  const titleSuffix = column.titleSuffix;
  if (titleSuffix) {
    return h('i', {
      class: ['vxe-cell-title-suffix-icon', titleSuffix.iconStatus ? `theme--${titleSuffix.iconStatus}` : ''],
      on: {
        mouseenter(evnt) {
          $table.triggerHeaderTitleEvent(evnt, titleSuffix, params);
        },
        mouseleave(evnt) {
          $table.handleTargetLeaveEvent(evnt);
        }
      }
    }, [h('i', {
      class: titleSuffix.icon || getIcon().TABLE_TITLE_SUFFIX
    })]);
  }
  return renderEmptyElement($table);
}
function renderCellDragIcon(h, params) {
  const {
    $table
  } = params;
  const tableSlots = $table.$scopedSlots;
  const tableProps = $table;
  const {
    dragConfig
  } = tableProps;
  const rowDragOpts = $table.computeRowDragOpts;
  const {
    icon,
    trigger,
    disabledMethod
  } = rowDragOpts;
  const rDisabledMethod = disabledMethod || (dragConfig ? dragConfig.rowDisabledMethod : null);
  const isDisabled = rDisabledMethod && rDisabledMethod(params);
  const rowDragIconSlot = tableSlots.rowDragIcon || tableSlots['row-drag-icon'];
  const ons = {};
  if (trigger !== 'cell') {
    ons.mousedown = evnt => {
      if (!isDisabled) {
        $table.handleCellDragMousedownEvent(evnt, params);
      }
    };
    ons.mouseup = $table.handleCellDragMouseupEvent;
  }
  return h('span', {
    key: 'dg',
    class: ['vxe-cell--drag-handle', {
      'is--disabled': isDisabled
    }],
    on: ons
  }, rowDragIconSlot ? $table.callSlot(rowDragIconSlot, params, h) : [h('i', {
    class: icon || (dragConfig ? dragConfig.rowIcon : '') || getIcon().TABLE_DRAG_ROW
  })]);
}
function renderCellBaseVNs(h, params, content) {
  const {
    $table,
    column,
    level
  } = params;
  const {
    dragSort
  } = column;
  const tableProps = $table;
  const {
    treeConfig,
    dragConfig
  } = tableProps;
  const rowOpts = $table.computeRowOpts;
  const rowDragOpts = $table.computeRowDragOpts;
  const treeOpts = $table.computeTreeOpts;
  const {
    showIcon,
    isPeerDrag,
    isCrossDrag,
    visibleMethod
  } = rowDragOpts;
  const rVisibleMethod = visibleMethod || (dragConfig ? dragConfig.rowVisibleMethod : null);
  const vns = [];
  if (dragSort && rowOpts.drag && (showIcon || (dragConfig ? dragConfig.showRowIcon : false)) && (!rVisibleMethod || rVisibleMethod(params))) {
    if (treeConfig) {
      if (treeOpts.transform && (isPeerDrag || isCrossDrag || !level)) {
        vns.unshift(renderCellDragIcon(h, params));
      }
    } else {
      vns.unshift(renderCellDragIcon(h, params));
    }
  }
  return vns.concat(_xeUtils.default.isArray(content) ? content : [content]);
}
function renderHeaderCellDragIcon(h, params) {
  const {
    $table,
    column
  } = params;
  const tableSlots = $table.$scopedSlots;
  const {
    slots
  } = column;
  const columnOpts = $table.computeColumnOpts;
  const columnDragOpts = $table.computeColumnDragOpts;
  const {
    showIcon,
    icon,
    trigger,
    isPeerDrag,
    isCrossDrag,
    visibleMethod,
    disabledMethod
  } = columnDragOpts;
  if (columnOpts.drag && showIcon && (!visibleMethod || visibleMethod(params))) {
    if (!column.fixed && (isPeerDrag || isCrossDrag || !column.parentId)) {
      const isDisabled = disabledMethod && disabledMethod(params);
      const columnDragIconSlot = (slots ? slots.columnDragIcon || slots['column-drag-icon'] : null) || tableSlots.columnDragIcon || tableSlots['column-drag-icon'];
      const ons = {};
      if (trigger !== 'cell') {
        ons.mousedown = evnt => {
          if (!isDisabled) {
            $table.handleHeaderCellDragMousedownEvent(evnt, params);
          }
        };
        ons.mouseup = $table.handleHeaderCellDragMouseupEvent;
      }
      return h('span', {
        key: 'dg',
        class: ['vxe-cell--drag-handle', {
          'is--disabled': isDisabled
        }],
        on: ons
      }, columnDragIconSlot ? $table.callSlot(columnDragIconSlot, params, h) : [h('i', {
        class: icon || getIcon().TABLE_DRAG_COLUMN
      })]);
    }
  }
  return renderEmptyElement($table);
}
function renderHeaderCellBaseVNs(h, params, content) {
  const vns = [renderTitlePrefixIcon(h, params), renderHeaderCellDragIcon(h, params), ...(_xeUtils.default.isArray(content) ? content : [content]), renderTitleSuffixIcon(h, params)];
  return vns;
}
function getRenderDefaultColumnTitle(h, column, content) {
  if (column.type === 'html' && _xeUtils.default.isString(content)) {
    return h('span', {
      key: 'ch',
      domProps: {
        innerHTML: content
      }
    });
  }
  return h('span', {
    key: 'ct'
  }, (0, _vn.getSlotVNs)(content));
}
function renderTitleContent(h, params, content) {
  const {
    $table,
    column
  } = params;
  const tableProps = $table;
  const tableReactData = $table;
  const {
    showHeaderOverflow: allColumnHeaderOverflow
  } = tableProps;
  const {
    isRowGroupStatus
  } = tableReactData;
  const {
    showHeaderOverflow,
    slots
  } = column;
  const titleSlot = slots ? slots.title : null;
  const headerTooltipOpts = $table.computeHeaderTooltipOpts;
  const showAllTip = headerTooltipOpts.showAll;
  const headOverflow = _xeUtils.default.eqNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
  const showTitle = headOverflow === 'title';
  const showTooltip = headOverflow === true || headOverflow === 'tooltip';
  const ons = {};
  if (showTitle || showTooltip || showAllTip) {
    ons.mouseenter = evnt => {
      if (tableReactData.isDragResize) {
        return;
      }
      if (showTitle) {
        (0, _dom.updateCellTitle)(evnt.currentTarget, column);
      } else if (showTooltip || showAllTip) {
        $table.triggerHeaderTooltipEvent(evnt, params);
      }
    };
  }
  if (showTooltip || showAllTip) {
    ons.mouseleave = evnt => {
      if (tableReactData.isDragResize) {
        return;
      }
      if (showTooltip || showAllTip) {
        $table.handleTargetLeaveEvent(evnt);
      }
    };
  }
  const titleVN = getRenderDefaultColumnTitle(h, column, content);
  return [h('span', {
    class: 'vxe-cell--title',
    on: ons
  }, isRowGroupStatus && column.aggFunc && $table.getPivotTableAggregateRenderColTitles ? $table.getPivotTableAggregateRenderColTitles(h, column, titleVN) : titleSlot ? $table.callSlot(titleSlot, params, h) : [titleVN])];
}
function getFooterContent(h, params) {
  const {
    $table,
    column,
    _columnIndex,
    row,
    items
  } = params;
  const {
    slots,
    editRender,
    cellRender,
    footerFormatter
  } = column;
  const renderOpts = editRender || cellRender;
  if (slots && slots.footer) {
    return $table.callSlot(slots.footer, params, h);
  }
  let itemValue = '';
  // 兼容老模式
  if (_xeUtils.default.isArray(items)) {
    itemValue = items[_columnIndex];
  } else {
    itemValue = _xeUtils.default.get(row, column.field);
  }
  const footParams = Object.assign(params, {
    itemValue
  });
  if (footerFormatter) {
    if (_xeUtils.default.isFunction(footerFormatter)) {
      return `${footerFormatter(footParams)}`;
    }
    const isArr = _xeUtils.default.isArray(footerFormatter);
    const gFormatOpts = isArr ? formats.get(footerFormatter[0]) : formats.get(footerFormatter);
    const footerFormatMethod = gFormatOpts ? gFormatOpts.tableFooterCellFormatMethod : null;
    if (footerFormatMethod) {
      return `${isArr ? footerFormatMethod(footParams, ...footerFormatter.slice(1)) : footerFormatMethod(footParams)}`;
    }
    return '';
  }
  if (renderOpts) {
    const compConf = renderer.get(renderOpts.name);
    const rtFooter = compConf ? compConf.renderTableFooter || compConf.renderFooter : null;
    if (rtFooter) {
      return (0, _vn.getSlotVNs)(rtFooter.call($table, h, renderOpts, footParams));
    }
  }
  return [(0, _utils.formatText)(itemValue, 1)];
}
function getDefaultCellLabel(params) {
  const {
    $table,
    row,
    column
  } = params;
  return (0, _utils.formatText)($table.getCellLabel(row, column), 1);
}
function renderCellHandle(h, params) {
  const {
    column,
    row,
    $table
  } = params;
  const tableProps = $table;
  const tableReactData = $table;
  const {
    editConfig
  } = tableProps;
  const {
    isRowGroupStatus
  } = tableReactData;
  const {
    type,
    treeNode,
    rowGroupNode,
    editRender
  } = column;
  const aggregateOpts = $table.computeAggregateOpts;
  const {
    mode
  } = aggregateOpts;
  const checkboxOpts = $table.computeCheckboxOpts;
  const editOpts = $table.computeEditOpts;
  const isDeepCell = treeNode || isRowGroupStatus && (mode === 'column' ? column.field === row.groupField : rowGroupNode);
  switch (type) {
    case 'seq':
      return isDeepCell ? Cell.renderDeepIndexCell(h, params) : Cell.renderSeqCell(h, params);
    case 'radio':
      return isDeepCell ? Cell.renderDeepRadioCell(h, params) : Cell.renderRadioCell(h, params);
    case 'checkbox':
      return checkboxOpts.checkField ? isDeepCell ? Cell.renderDeepSelectionCellByProp(h, params) : Cell.renderCheckboxCellByProp(h, params) : isDeepCell ? Cell.renderDeepSelectionCell(h, params) : Cell.renderCheckboxCell(h, params);
    case 'expand':
      return Cell.renderExpandCell(h, params);
    case 'html':
      return isDeepCell ? Cell.renderDeepHTMLCell(h, params) : Cell.renderHTMLCell(h, params);
  }
  if (editConfig && (0, _utils.isEnableConf)(editOpts) && editRender) {
    return editOpts.mode === 'cell' ? isDeepCell ? Cell.renderDeepCellEdit(h, params) : Cell.renderCellEdit(h, params) : isDeepCell ? Cell.renderDeepRowEdit(h, params) : Cell.renderRowEdit(h, params);
  }
  return isDeepCell ? Cell.renderDeepCell(h, params) : Cell.renderDefaultCell(h, params);
}
function renderHeaderHandle(h, params) {
  const {
    column,
    $table
  } = params;
  const tableProps = $table;
  const {
    editConfig
  } = tableProps;
  const editOpts = $table.computeEditOpts;
  const {
    type,
    filters,
    sortable,
    editRender
  } = column;
  switch (type) {
    case 'seq':
      return Cell.renderSeqHeader(h, params);
    case 'radio':
      return Cell.renderRadioHeader(h, params);
    case 'checkbox':
      return Cell.renderCheckboxHeader(h, params);
    case 'html':
      if (filters && sortable) {
        return Cell.renderSortAndFilterHeader(h, params);
      } else if (sortable) {
        return Cell.renderSortHeader(h, params);
      } else if (filters) {
        return Cell.renderFilterHeader(h, params);
      }
      break;
  }
  if (editConfig && (0, _utils.isEnableConf)(editOpts) && editRender) {
    return Cell.renderEditHeader(h, params);
  } else if (filters && sortable) {
    return Cell.renderSortAndFilterHeader(h, params);
  } else if (sortable) {
    return Cell.renderSortHeader(h, params);
  } else if (filters) {
    return Cell.renderFilterHeader(h, params);
  }
  return Cell.renderDefaultHeader(h, params);
}
function renderFooterHandle(h, params) {
  return Cell.renderDefaultFooter(h, params);
}
const Cell = exports.Cell = {
  createColumn($xeTable, _vm) {
    const {
      type
    } = _vm;
    const renConfs = {
      renderHeader: renderHeaderHandle,
      renderCell: renderCellHandle,
      renderFooter: renderFooterHandle
    };
    if (type === 'expand') {
      renConfs.renderData = Cell.renderExpandData;
    }
    return (0, _util.createColumn)($xeTable, _vm, renConfs);
  },
  /**
   * 列头标题
   */
  renderHeaderTitle(h, params) {
    const {
      $table,
      column
    } = params;
    const {
      slots,
      editRender,
      cellRender
    } = column;
    const renderOpts = editRender || cellRender;
    if (slots && slots.header) {
      return renderTitleContent(h, params, $table.callSlot(slots.header, params, h));
    }
    if (renderOpts) {
      const compConf = renderer.get(renderOpts.name);
      const rtHeader = compConf ? compConf.renderTableHeader || compConf.renderHeader : null;
      if (rtHeader) {
        return (0, _vn.getSlotVNs)(renderTitleContent(h, params, rtHeader.call($table, h, renderOpts, params)));
      }
    }
    return renderTitleContent(h, params, (0, _utils.formatText)(column.getTitle(), 1));
  },
  renderDefaultHeader(h, params) {
    return renderHeaderCellBaseVNs(h, params, Cell.renderHeaderTitle(h, params));
  },
  renderDefaultCell(h, params) {
    const {
      $table,
      row,
      column
    } = params;
    const tableProps = $table;
    const tableReactData = $table;
    const tableInternalData = $table;
    const {
      isRowGroupStatus
    } = tableReactData;
    const {
      editConfig
    } = tableProps;
    const {
      field,
      slots,
      editRender,
      cellRender,
      rowGroupNode,
      aggFunc,
      formatter
    } = column;
    const renderOpts = editConfig && (0, _utils.isEnableConf)(editRender) ? editRender : (0, _utils.isEnableConf)(cellRender) ? cellRender : null;
    const defaultSlot = slots ? slots.default : null;
    const gcSlot = slots ? slots.groupContent || slots['group-content'] : null;
    let cellValue = '';
    if (isRowGroupStatus && field && row.isAggregate) {
      const aggRow = row;
      const {
        fullColumnFieldData
      } = tableInternalData;
      const aggregateOpts = $table.computeAggregateOpts;
      const {
        mode,
        showTotal,
        totalMethod,
        countFields,
        contentMethod,
        mapChildrenField
      } = aggregateOpts;
      const aggCalcMethod = aggregateOpts.calcValuesMethod || aggregateOpts.countMethod || aggregateOpts.aggregateMethod;
      const groupField = aggRow.groupField;
      const groupContent = aggRow.groupContent;
      const childList = mapChildrenField ? aggRow[mapChildrenField] || [] : [];
      const childCount = aggRow.childCount;
      const colRest = fullColumnFieldData[groupField] || {};
      const ctParams = {
        $table,
        groupField,
        groupColumn: colRest ? colRest.column : null,
        column,
        groupValue: groupContent,
        childList,
        childCount,
        aggValue: null,
        /**
         * 已废弃
         * @deprecated
         */
        children: childList,
        /**
         * 已废弃
         * @deprecated
         */
        totalValue: childCount
      };
      if (gcSlot) {
        return renderCellBaseVNs(h, params, $table.callSlot(gcSlot, Object.assign({
          groupField,
          groupContent,
          childList,
          childCount
        }, params), h));
      }
      if (mode === 'column' ? field === aggRow.groupField : rowGroupNode) {
        cellValue = groupContent;
        if (contentMethod) {
          cellValue = `${contentMethod(ctParams)}`;
        }
        if (showTotal) {
          cellValue = getI18n('vxe.table.rowGroupContentTotal', [cellValue, totalMethod ? totalMethod(ctParams) : childCount, childCount]);
        }
      } else if ($table.getPivotTableAggregateCellAggValue) {
        cellValue = $table.getPivotTableAggregateCellAggValue(params);
      } else if (aggFunc === true || countFields && countFields.includes(field)) {
        if (aggCalcMethod) {
          ctParams.aggValue = childCount;
          cellValue = `${aggCalcMethod(ctParams)}`;
        }
      }
    } else {
      if (defaultSlot) {
        return renderCellBaseVNs(h, params, $table.callSlot(defaultSlot, params, h));
      }
      // formatter > (renderTableCell | renderTableDefault)
      if (renderOpts && !formatter) {
        const compConf = renderer.get(renderOpts.name);
        const rtDefault = compConf ? compConf.renderTableDefault || compConf.renderDefault : null;
        const rtCell = compConf ? compConf.renderTableCell || compConf.renderCell : null;
        const renderFn = editRender ? rtCell : rtDefault;
        if (renderFn) {
          return renderCellBaseVNs(h, params, (0, _vn.getSlotVNs)(renderFn.call($table, h, renderOpts, Object.assign({
            $type: editRender ? 'edit' : 'cell'
          }, params))));
        }
      }
      cellValue = $table.getCellLabel(row, column);
    }
    const cellPlaceholder = editRender ? editRender.placeholder : '';
    return renderCellBaseVNs(h, params, [h('span', {
      class: 'vxe-cell--label'
    }, [
    // 如果设置占位符
    editRender && (0, _utils.eqEmptyValue)(cellValue) ? h('span', {
      class: 'vxe-cell--placeholder'
    }, (0, _utils.formatText)((0, _utils.getFuncText)(cellPlaceholder), 1)) : h('span', (0, _utils.formatText)(cellValue, 1))])]);
  },
  renderDeepCell(h, params) {
    return Cell.renderDeepNodeBtn(h, params, Cell.renderDefaultCell.call(this, h, params));
  },
  renderDefaultFooter(h, params) {
    return getFooterContent(h, params);
  },
  /**
   * 行分组
   */
  renderRowGroupBtn(h, params, cellVNodes) {
    const {
      $table
    } = params;
    const tableReactData = $table;
    const tableInternalData = $table;
    const {
      row,
      level
    } = params;
    const {
      rowGroupExpandedFlag
    } = tableReactData;
    const {
      rowGroupExpandedMaps
    } = tableInternalData;
    const aggregateOpts = $table.computeAggregateOpts;
    const {
      mode,
      padding,
      indent
    } = aggregateOpts;
    const rowid = (0, _util.getRowid)($table, row);
    const isExpand = !!rowGroupExpandedFlag && !!rowGroupExpandedMaps[rowid];
    return h('div', {
      class: ['vxe-row-group--tree-node', {
        'is--expanded': isExpand
      }],
      style: mode !== 'column' && padding && indent ? {
        paddingLeft: `${level * indent}px`
      } : undefined
    }, [row.isAggregate ? h('span', {
      class: 'vxe-row-group--node-btn',
      on: {
        click(evnt) {
          $table.triggerRowGroupExpandEvent(evnt, params);
        }
      }
    }, [h('i', {
      class: isExpand ? getIcon().TABLE_ROW_GROUP_OPEN : getIcon().TABLE_ROW_GROUP_CLOSE
    })]) : renderEmptyElement($table), h('div', {
      class: 'vxe-row-group-cell'
    }, cellVNodes)]);
  },
  /**
   * 树
   */
  renderTreeNodeBtn(h, params, cellVNodes) {
    const {
      $table,
      isHidden
    } = params;
    const tableReactData = $table;
    const tableInternalData = $table;
    const {
      treeExpandedFlag
    } = tableReactData;
    const {
      fullAllDataRowIdData,
      treeExpandedMaps,
      treeExpandLazyLoadedMaps
    } = tableInternalData;
    const treeOpts = $table.computeTreeOpts;
    const {
      row,
      column,
      level
    } = params;
    const {
      slots
    } = column;
    const {
      padding,
      indent,
      lazy,
      trigger,
      iconLoaded,
      showIcon,
      iconOpen,
      iconClose
    } = treeOpts;
    const childrenField = treeOpts.children || treeOpts.childrenField;
    const hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
    const rowChilds = row[childrenField];
    const hasChild = rowChilds && rowChilds.length;
    const iconSlot = slots ? slots.icon : null;
    let hasLazyChilds = false;
    let isActive = false;
    let isLazyLoading = false;
    let isLazyLoaded = false;
    const ons = {};
    if (iconSlot) {
      return $table.callSlot(iconSlot, params, h);
    }
    if (!isHidden) {
      const rowid = (0, _util.getRowid)($table, row);
      isActive = !!treeExpandedFlag && !!treeExpandedMaps[rowid];
      if (lazy) {
        const rest = fullAllDataRowIdData[rowid];
        isLazyLoading = !!treeExpandLazyLoadedMaps[rowid];
        hasLazyChilds = row[hasChildField];
        isLazyLoaded = !!rest.treeLoaded;
      }
    }
    if (!trigger || trigger === 'default') {
      ons.click = evnt => {
        $table.triggerTreeExpandEvent(evnt, params);
      };
    }
    return [h('div', {
      class: ['vxe-cell--tree-node', {
        'is--active': isActive
      }],
      style: padding && indent ? {
        paddingLeft: `${level * indent}px`
      } : undefined
    }, [showIcon && (lazy ? isLazyLoaded ? hasChild : hasChild || hasLazyChilds : hasChild) ? [h('div', {
      class: 'vxe-cell--tree-btn',
      on: ons
    }, [h('i', {
      class: isLazyLoading ? iconLoaded || getIcon().TABLE_TREE_LOADED : isActive ? iconOpen || getIcon().TABLE_TREE_OPEN : iconClose || getIcon().TABLE_TREE_CLOSE
    })])] : null, h('div', {
      class: 'vxe-tree-cell'
    }, cellVNodes)])];
  },
  /**
   * 层级节点。
   * 行分组、树结构
   */
  renderDeepNodeBtn(h, params, cellVNodes) {
    const {
      $table,
      row,
      column
    } = params;
    const {
      rowGroupNode
    } = column;
    const tableReactData = $table;
    const {
      rowGroupList
    } = tableReactData;
    if (rowGroupList.length) {
      const aggregateOpts = $table.computeAggregateOpts;
      const {
        mode
      } = aggregateOpts;
      if (mode === 'column' ? column.field === row.groupField : rowGroupNode) {
        return [Cell.renderRowGroupBtn(h, params, cellVNodes)];
      }
    }
    return [Cell.renderTreeNodeBtn(h, params, cellVNodes)];
  },
  /**
   * 序号
   */
  renderSeqHeader(h, params) {
    const {
      $table,
      column
    } = params;
    const {
      slots
    } = column;
    return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, params, slots && slots.header ? $table.callSlot(slots.header, params, h) : (0, _utils.formatText)(column.getTitle(), 1)));
  },
  renderSeqCell(h, params) {
    const {
      $table,
      column
    } = params;
    const tableProps = $table;
    const {
      treeConfig
    } = tableProps;
    const seqOpts = $table.computeSeqOpts;
    const {
      slots
    } = column;
    if (slots && slots.default) {
      return renderCellBaseVNs(h, params, $table.callSlot(slots.default, params, h));
    }
    const {
      seq
    } = params;
    const seqMd = seqOpts.seqMethod;
    return renderCellBaseVNs(h, params, [h('span', `${(0, _utils.formatText)(seqMd ? seqMd(params) : treeConfig ? seq : (seqOpts.startIndex || 0) + seq, 1)}`)]);
  },
  renderDeepIndexCell(h, params) {
    return Cell.renderDeepNodeBtn(h, params, Cell.renderSeqCell(h, params));
  },
  /**
   * 单选
   */
  renderRadioHeader(h, params) {
    const {
      $table,
      column
    } = params;
    const {
      slots
    } = column;
    const headerSlot = slots ? slots.header : null;
    const titleSlot = slots ? slots.title : null;
    return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, params, headerSlot ? $table.callSlot(headerSlot, params, h) : [h('span', {
      class: 'vxe-radio--label'
    }, titleSlot ? $table.callSlot(titleSlot, params, h) : (0, _utils.formatText)(column.getTitle(), 1))]));
  },
  renderRadioCell(h, params) {
    const {
      $table,
      column,
      isHidden
    } = params;
    const tableReactData = $table;
    const {
      selectRadioRow
    } = tableReactData;
    const radioOpts = $table.computeRadioOpts;
    const {
      slots
    } = column;
    const {
      labelField,
      checkMethod,
      visibleMethod
    } = radioOpts;
    const {
      row
    } = params;
    const defaultSlot = slots ? slots.default : null;
    const radioSlot = slots ? slots.radio : null;
    const isChecked = row === selectRadioRow;
    const isVisible = !visibleMethod || visibleMethod({
      $table,
      row
    });
    let isDisabled = !!checkMethod;
    let on;
    if (!isHidden) {
      on = {
        click(evnt) {
          if (!isDisabled && isVisible) {
            $table.triggerRadioRowEvent(evnt, params);
          }
        }
      };
      if (checkMethod) {
        isDisabled = !checkMethod({
          $table,
          row
        });
      }
    }
    const radioParams = Object.assign(Object.assign({}, params), {
      checked: isChecked,
      disabled: isDisabled,
      visible: isVisible
    });
    if (radioSlot) {
      return renderCellBaseVNs(h, params, $table.callSlot(radioSlot, radioParams, h));
    }
    const radioVNs = [];
    if (isVisible) {
      radioVNs.push(h('span', {
        class: ['vxe-radio--icon', isChecked ? getIcon().TABLE_RADIO_CHECKED : isDisabled ? getIcon().TABLE_RADIO_DISABLED_UNCHECKED : getIcon().TABLE_RADIO_UNCHECKED]
      }));
    }
    if (defaultSlot || labelField) {
      radioVNs.push(h('span', {
        class: 'vxe-radio--label'
      }, defaultSlot ? $table.callSlot(defaultSlot, radioParams, h) : _xeUtils.default.get(row, labelField)));
    }
    return renderCellBaseVNs(h, params, [h('span', {
      class: ['vxe-cell--radio', {
        'is--checked': isChecked,
        'is--disabled': isDisabled
      }],
      on
    }, radioVNs)]);
  },
  renderDeepRadioCell(h, params) {
    return Cell.renderDeepNodeBtn(h, params, Cell.renderRadioCell(h, params));
  },
  /**
   * 多选
   */
  renderCheckboxHeader(h, params) {
    const {
      $table,
      column,
      isHidden
    } = params;
    const tableReactData = $table;
    const {
      isAllSelected: isAllCheckboxSelected,
      isIndeterminate: isAllCheckboxIndeterminate
    } = tableReactData;
    const isAllCheckboxDisabled = $table.computeIsAllCheckboxDisabled;
    const {
      slots
    } = column;
    const headerSlot = slots ? slots.header : null;
    const titleSlot = slots ? slots.title : null;
    const checkboxOpts = $table.computeCheckboxOpts;
    const {
      checkStrictly,
      showHeader,
      headerTitle
    } = checkboxOpts;
    const colTitle = column.getTitle();
    const ons = {};
    if (!isHidden) {
      ons.click = evnt => {
        if (!isAllCheckboxDisabled) {
          $table.triggerCheckAllEvent(evnt, !isAllCheckboxSelected);
        }
      };
    }
    const checkboxParams = Object.assign(Object.assign({}, params), {
      checked: isAllCheckboxSelected,
      disabled: isAllCheckboxDisabled,
      indeterminate: isAllCheckboxIndeterminate
    });
    if (headerSlot) {
      return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, checkboxParams, $table.callSlot(headerSlot, checkboxParams, h)));
    }
    if (checkStrictly ? !showHeader : showHeader === false) {
      return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, checkboxParams, [h('span', {
        class: 'vxe-checkbox--label'
      }, titleSlot ? $table.callSlot(titleSlot, checkboxParams, h) : colTitle)]));
    }
    return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, checkboxParams, [h('span', {
      class: ['vxe-cell--checkbox', {
        'is--checked': isAllCheckboxSelected,
        'is--disabled': isAllCheckboxDisabled,
        'is--indeterminate': isAllCheckboxIndeterminate
      }],
      attrs: {
        title: _xeUtils.default.eqNull(headerTitle) ? getI18n('vxe.table.allTitle') : `${headerTitle || ''}`
      },
      on: ons
    }, [h('span', {
      class: ['vxe-checkbox--icon', isAllCheckboxIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : isAllCheckboxSelected ? getIcon().TABLE_CHECKBOX_CHECKED : isAllCheckboxDisabled ? getIcon().TABLE_CHECKBOX_DISABLED_UNCHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED]
    })].concat(titleSlot || colTitle ? [h('span', {
      class: 'vxe-checkbox--label'
    }, titleSlot ? $table.callSlot(titleSlot, checkboxParams, h) : colTitle)] : []))]));
  },
  renderCheckboxCell(h, params) {
    const {
      $table,
      row,
      column,
      isHidden
    } = params;
    const tableProps = $table;
    const tableReactData = $table;
    const tableInternalData = $table;
    const {
      treeConfig
    } = tableProps;
    const {
      updateCheckboxFlag,
      isRowGroupStatus
    } = tableReactData;
    const {
      selectCheckboxMaps,
      treeIndeterminateRowMaps
    } = tableInternalData;
    const aggregateOpts = $table.computeAggregateOpts;
    const {
      mapChildrenField
    } = aggregateOpts;
    const checkboxOpts = $table.computeCheckboxOpts;
    const {
      labelField,
      checkMethod,
      visibleMethod
    } = checkboxOpts;
    const {
      slots
    } = column;
    const defaultSlot = slots ? slots.default : null;
    const checkboxSlot = slots ? slots.checkbox : null;
    let indeterminate = false;
    let isChecked = false;
    let isVisible = true;
    let isDisabled = false;
    const ons = {};
    if (!isHidden) {
      const rowid = (0, _util.getRowid)($table, row);
      isChecked = !!updateCheckboxFlag && !!selectCheckboxMaps[rowid];
      if (checkMethod && isRowGroupStatus && $table.isAggregateRecord(row)) {
        const childList = row[mapChildrenField || ''];
        if (!childList || !childList.length || childList.every(item => !checkMethod({
          $table,
          row: item
        }))) {
          isDisabled = true;
        }
      } else {
        isVisible = !visibleMethod || visibleMethod({
          $table,
          row
        });
        isDisabled = checkMethod ? !checkMethod({
          $table,
          row
        }) : !!checkMethod;
      }
      if (treeConfig || isRowGroupStatus) {
        indeterminate = !!treeIndeterminateRowMaps[rowid];
      }
      ons.click = evnt => {
        if (!isDisabled && isVisible) {
          $table.triggerCheckRowEvent(evnt, params, !isChecked);
        }
      };
    }
    const checkboxParams = Object.assign(Object.assign({}, params), {
      checked: isChecked,
      disabled: isDisabled,
      visible: isVisible,
      indeterminate
    });
    if (checkboxSlot) {
      return renderCellBaseVNs(h, params, $table.callSlot(checkboxSlot, checkboxParams, h));
    }
    const checkVNs = [];
    if (isVisible) {
      checkVNs.push(h('span', {
        class: ['vxe-checkbox--icon', indeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : isDisabled ? getIcon().TABLE_CHECKBOX_DISABLED_UNCHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED]
      }));
    }
    if (defaultSlot || labelField) {
      checkVNs.push(h('span', {
        class: 'vxe-checkbox--label'
      }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams, h) : _xeUtils.default.get(row, labelField)));
    }
    return renderCellBaseVNs(h, params, [h('span', {
      class: ['vxe-cell--checkbox', {
        'is--checked': isChecked,
        'is--disabled': isDisabled,
        'is--indeterminate': indeterminate,
        'is--hidden': !isVisible
      }],
      on: ons
    }, checkVNs)]);
  },
  renderDeepSelectionCell(h, params) {
    return Cell.renderDeepNodeBtn(h, params, Cell.renderCheckboxCell(h, params));
  },
  renderCheckboxCellByProp(h, params) {
    const {
      $table,
      row,
      column,
      isHidden
    } = params;
    const tableProps = $table;
    const tableReactData = $table;
    const tableInternalData = $table;
    const {
      treeConfig
    } = tableProps;
    const {
      updateCheckboxFlag,
      isRowGroupStatus
    } = tableReactData;
    const {
      treeIndeterminateRowMaps
    } = tableInternalData;
    const aggregateOpts = $table.computeAggregateOpts;
    const {
      mapChildrenField
    } = aggregateOpts;
    const checkboxOpts = $table.computeCheckboxOpts;
    const {
      labelField,
      checkField,
      checkMethod,
      visibleMethod
    } = checkboxOpts;
    const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
    const {
      slots
    } = column;
    const defaultSlot = slots ? slots.default : null;
    const checkboxSlot = slots ? slots.checkbox : null;
    let indeterminate = false;
    let isChecked = false;
    let isVisible = true;
    let isDisabled = false;
    const ons = {};
    if (!isHidden) {
      const rowid = (0, _util.getRowid)($table, row);
      isChecked = !!updateCheckboxFlag && _xeUtils.default.get(row, checkField);
      if (checkMethod && isRowGroupStatus && $table.isAggregateRecord(row)) {
        const childList = row[mapChildrenField || ''];
        if (!childList || !childList.length || childList.every(item => !checkMethod({
          $table,
          row: item
        }))) {
          isDisabled = true;
        }
      } else {
        isVisible = !visibleMethod || visibleMethod({
          $table,
          row
        });
        isDisabled = checkMethod ? !checkMethod({
          $table,
          row
        }) : !!checkMethod;
      }
      if (treeConfig || isRowGroupStatus) {
        indeterminate = !!treeIndeterminateRowMaps[rowid];
      }
      ons.click = evnt => {
        if (!isDisabled && isVisible) {
          $table.triggerCheckRowEvent(evnt, params, !isChecked);
        }
      };
    }
    const checkboxParams = Object.assign(Object.assign({}, params), {
      checked: isChecked,
      disabled: isDisabled,
      visible: isVisible,
      indeterminate
    });
    if (checkboxSlot) {
      return renderCellBaseVNs(h, params, $table.callSlot(checkboxSlot, checkboxParams, h));
    }
    const checkVNs = [];
    if (isVisible) {
      checkVNs.push(h('span', {
        class: ['vxe-checkbox--icon', indeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : isDisabled ? getIcon().TABLE_CHECKBOX_DISABLED_UNCHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED]
      }));
    }
    if (defaultSlot || labelField) {
      checkVNs.push(h('span', {
        class: 'vxe-checkbox--label'
      }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams, h) : _xeUtils.default.get(row, labelField)));
    }
    return renderCellBaseVNs(h, params, [h('span', {
      class: ['vxe-cell--checkbox', {
        'is--checked': isChecked,
        'is--disabled': isDisabled,
        'is--indeterminate': indeterminateField && !isChecked ? row[indeterminateField] : indeterminate,
        'is--hidden': !isVisible
      }],
      on: ons
    }, checkVNs)]);
  },
  renderDeepSelectionCellByProp(h, params) {
    return Cell.renderDeepNodeBtn(h, params, Cell.renderCheckboxCellByProp(h, params));
  },
  /**
   * 展开行
   */
  renderExpandCell(h, params) {
    const {
      $table,
      isHidden,
      row,
      column
    } = params;
    const tableReactData = $table;
    const tableInternalData = $table;
    const {
      isRowGroupStatus
    } = tableReactData;
    const {
      rowExpandedMaps,
      rowExpandLazyLoadedMaps
    } = tableInternalData;
    const expandOpts = $table.computeExpandOpts;
    const {
      lazy,
      labelField,
      iconLoaded,
      showIcon,
      iconOpen,
      iconClose,
      visibleMethod
    } = expandOpts;
    const {
      slots
    } = column;
    const defaultSlot = slots ? slots.default : null;
    const iconSlot = slots ? slots.icon : null;
    let isActive = false;
    let isLazyLoading = false;
    if (isRowGroupStatus && row.isAggregate) {
      return renderCellBaseVNs(h, params, []);
    }
    if (iconSlot) {
      return renderCellBaseVNs(h, params, $table.callSlot(iconSlot, params, h));
    }
    if (!isHidden) {
      const rowid = (0, _util.getRowid)($table, row);
      isActive = !!rowExpandedMaps[rowid];
      if (lazy) {
        isLazyLoading = !!rowExpandLazyLoadedMaps[rowid];
      }
    }
    return renderCellBaseVNs(h, params, [showIcon && (!visibleMethod || visibleMethod(params)) ? h('span', {
      class: ['vxe-table--expanded', {
        'is--active': isActive
      }],
      on: {
        mousedown(evnt) {
          evnt.stopPropagation();
        },
        click(evnt) {
          $table.triggerRowExpandEvent(evnt, params);
        }
      }
    }, [h('i', {
      class: ['vxe-table--expand-btn', isLazyLoading ? iconLoaded || getIcon().TABLE_EXPAND_LOADED : isActive ? iconOpen || getIcon().TABLE_EXPAND_OPEN : iconClose || getIcon().TABLE_EXPAND_CLOSE]
    })]) : renderEmptyElement($table), defaultSlot || labelField ? h('span', {
      class: 'vxe-table--expand-label'
    }, defaultSlot ? $table.callSlot(defaultSlot, params, h) : _xeUtils.default.get(row, labelField)) : renderEmptyElement($table)]);
  },
  renderExpandData(h, params) {
    const {
      $table,
      column
    } = params;
    const {
      slots,
      contentRender
    } = column;
    if (slots && slots.content) {
      return $table.callSlot(slots.content, params, h);
    }
    if (contentRender) {
      const compConf = renderer.get(contentRender.name);
      const rtExpand = compConf ? compConf.renderTableExpand || compConf.renderExpand : null;
      if (rtExpand) {
        return (0, _vn.getSlotVNs)(rtExpand.call($table, h, contentRender, params));
      }
    }
    return [];
  },
  /**
   * HTML 标签
   */
  renderHTMLCell(h, params) {
    const {
      $table,
      column
    } = params;
    const {
      slots
    } = column;
    if (slots && slots.default) {
      return renderCellBaseVNs(h, params, $table.callSlot(slots.default, params, h));
    }
    return renderCellBaseVNs(h, params, [h('span', {
      class: 'vxe-cell--html',
      domProps: {
        innerHTML: getDefaultCellLabel(params)
      }
    })]);
  },
  renderDeepHTMLCell(h, params) {
    return Cell.renderDeepNodeBtn(h, params, Cell.renderHTMLCell(h, params));
  },
  /**
   * 排序和筛选
   */
  renderSortAndFilterHeader(h, params) {
    return renderHeaderCellBaseVNs(h, params, Cell.renderHeaderTitle(h, params).concat(Cell.renderSortIcon(h, params).concat(Cell.renderFilterIcon(h, params))));
  },
  /**
   * 排序
   */
  renderSortHeader(h, params) {
    return renderHeaderCellBaseVNs(h, params, Cell.renderHeaderTitle(h, params).concat(Cell.renderSortIcon(h, params)));
  },
  renderSortIcon(h, params) {
    const {
      $table,
      column
    } = params;
    const sortOpts = $table.computeSortOpts;
    const {
      showIcon,
      allowBtn,
      ascTitle,
      descTitle,
      iconLayout,
      iconAsc,
      iconDesc,
      iconVisibleMethod
    } = sortOpts;
    const {
      order,
      slots
    } = column;
    if (showIcon && (!iconVisibleMethod || iconVisibleMethod(params))) {
      const sortSlot = slots ? slots.sort : null;
      return sortSlot ? (0, _vn.getSlotVNs)($table.callSlot(sortSlot, params, h)) : [h('span', {
        class: ['vxe-cell--sort', `vxe-cell--sort-${iconLayout}-layout`]
      }, [h('i', {
        class: ['vxe-sort--asc-btn', iconAsc || getIcon().TABLE_SORT_ASC, {
          'sort--active': order === 'asc'
        }],
        attrs: {
          title: _xeUtils.default.eqNull(ascTitle) ? getI18n('vxe.table.sortAsc') : `${ascTitle || ''}`
        },
        on: allowBtn ? {
          click(evnt) {
            evnt.stopPropagation();
            $table.triggerSortEvent(evnt, column, 'asc');
          }
        } : undefined
      }), h('i', {
        class: ['vxe-sort--desc-btn', iconDesc || getIcon().TABLE_SORT_DESC, {
          'sort--active': order === 'desc'
        }],
        attrs: {
          title: _xeUtils.default.eqNull(descTitle) ? getI18n('vxe.table.sortDesc') : `${descTitle || ''}`
        },
        on: allowBtn ? {
          click(evnt) {
            evnt.stopPropagation();
            $table.triggerSortEvent(evnt, column, 'desc');
          }
        } : undefined
      })])];
    }
    return [];
  },
  /**
   * 筛选
   */
  renderFilterHeader(h, params) {
    return renderHeaderCellBaseVNs(h, params, Cell.renderHeaderTitle(h, params).concat(Cell.renderFilterIcon(h, params)));
  },
  renderFilterIcon(h, params) {
    const {
      $table,
      column,
      hasFilter
    } = params;
    const tableReactData = $table;
    const {
      filterStore
    } = tableReactData;
    const filterOpts = $table.computeFilterOpts;
    const {
      showIcon,
      iconNone,
      iconMatch,
      iconVisibleMethod
    } = filterOpts;
    if (showIcon && (!iconVisibleMethod || iconVisibleMethod(params))) {
      return [h('span', {
        class: ['vxe-cell--filter', {
          'is--active': filterStore.visible && filterStore.column === column
        }],
        on: {
          click(evnt) {
            if ($table.triggerFilterEvent) {
              $table.triggerFilterEvent(evnt, params.column, params);
            }
          }
        }
      }, [h('i', {
        class: ['vxe-filter--btn', hasFilter ? iconMatch || getIcon().TABLE_FILTER_MATCH : iconNone || getIcon().TABLE_FILTER_NONE],
        attrs: {
          title: getI18n('vxe.table.filter')
        }
      })])];
    }
    return [];
  },
  /**
   * 可编辑
   */
  renderEditHeader(h, params) {
    const {
      $table,
      column
    } = params;
    const tableProps = $table;
    const {
      editConfig,
      editRules
    } = tableProps;
    const editOpts = $table.computeEditOpts;
    const {
      sortable,
      filters,
      editRender
    } = column;
    let isRequired = false;
    if (editRules) {
      const columnRules = _xeUtils.default.get(editRules, column.field);
      if (columnRules) {
        isRequired = columnRules.some(rule => rule.required);
      }
    }
    let editIconVNs = [];
    if ((0, _utils.isEnableConf)(editConfig)) {
      const {
        showAsterisk,
        showIcon,
        icon
      } = editOpts;
      editIconVNs = [isRequired && showAsterisk ? h('i', {
        class: 'vxe-cell--required-icon'
      }, [h('i', {
        class: 'vxe-cell--required-icon'
      })]) : renderEmptyElement($table), (0, _utils.isEnableConf)(editRender) && showIcon ? h('i', {
        class: 'vxe-cell--edit-icon'
      }, _xeUtils.default.isFunction(icon) ? (0, _vn.getSlotVNs)(icon({})) : [h('i', {
        class: icon || getIcon().TABLE_EDIT
      })]) : renderEmptyElement($table)];
    }
    return renderHeaderCellBaseVNs(h, params, editIconVNs.concat(Cell.renderHeaderTitle(h, params)).concat(sortable ? Cell.renderSortIcon(h, params) : []).concat(filters ? Cell.renderFilterIcon(h, params) : []));
  },
  // 行格编辑模式
  renderRowEdit(h, params) {
    const {
      $table,
      column
    } = params;
    const tableReactData = $table;
    const {
      editStore
    } = tableReactData;
    const {
      actived
    } = editStore;
    const {
      editRender
    } = column;
    return Cell.runRenderer(h, params, this, (0, _utils.isEnableConf)(editRender) && actived && actived.row === params.row);
  },
  renderDeepRowEdit(h, params) {
    return Cell.renderDeepNodeBtn(h, params, Cell.renderRowEdit(h, params));
  },
  // 单元格编辑模式
  renderCellEdit(h, params) {
    const {
      $table,
      column
    } = params;
    const tableReactData = $table;
    const {
      editStore
    } = tableReactData;
    const {
      actived
    } = editStore;
    const {
      editRender
    } = column;
    return Cell.runRenderer(h, params, this, (0, _utils.isEnableConf)(editRender) && actived && actived.row === params.row && actived.column === params.column);
  },
  renderDeepCellEdit(h, params) {
    return Cell.renderDeepNodeBtn(h, params, Cell.renderCellEdit(h, params));
  },
  runRenderer(h, params, _vm, isEdit) {
    const {
      $table,
      row,
      column
    } = params;
    const tableReactData = $table;
    const {
      isRowGroupStatus
    } = tableReactData;
    const {
      slots,
      field,
      editRender,
      formatter
    } = column;
    const compConf = renderer.get(editRender.name);
    const rtEdit = compConf ? compConf.renderTableEdit || compConf.renderEdit : null;
    const defaultSlot = slots ? slots.default : null;
    const gcSlot = slots ? slots.groupContent || slots['group-content'] : null;
    const cellParams = Object.assign({
      $type: '',
      isEdit
    }, params);
    if (isEdit) {
      if (slots && slots.edit) {
        return $table.callSlot(slots.edit, cellParams, h);
      }
      if (rtEdit) {
        return (0, _vn.getSlotVNs)(rtEdit.call($table, h, editRender, cellParams));
      }
      return [];
    }
    if (isRowGroupStatus && field && row.isAggregate) {
      const aggRow = row;
      const aggregateOpts = $table.computeAggregateOpts;
      const {
        mapChildrenField
      } = aggregateOpts;
      const groupField = aggRow.groupField;
      const groupContent = aggRow.groupContent;
      const childList = mapChildrenField ? aggRow[mapChildrenField] || [] : [];
      const childCount = aggRow.childCount;
      if (gcSlot) {
        return renderCellBaseVNs(h, params, $table.callSlot(gcSlot, Object.assign({
          groupField,
          groupContent,
          childList,
          childCount
        }, params), h));
      }
    } else {
      if (defaultSlot) {
        return renderCellBaseVNs(h, params, $table.callSlot(defaultSlot, cellParams, h));
      }
    }
    if (formatter) {
      return renderCellBaseVNs(h, params, [h('span', {
        class: 'vxe-cell--label'
      }, [getDefaultCellLabel(cellParams)])]);
    }
    return Cell.renderDefaultCell.call(_vm, h, cellParams);
  }
};
var _default = exports.default = Cell;