"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const comp = require("../../ui/src/comp.js");
const XEUtils = require("xe-utils");
const utils = require("../../ui/src/utils.js");
const dom = require("../../ui/src/dom.js");
require("../../ui/index.js");
const props = require("./props.js");
const emits = require("./emits.js");
const vn = require("../../ui/src/vn.js");
const log = require("../../ui/src/log.js");
const emits$1 = require("../../table/src/emits.js");
const props$1 = require("../../table/src/props.js");
const table = require("../../table/src/table.js");
const toolbar = require("../../toolbar/src/toolbar.js");
const index_esm = require("../../../../@vxe-ui/core/es/index.esm.js");
const { getConfig, getI18n, commands, hooks, useFns, createEvent, globalEvents, GLOBAL_EVENT_KEYS, renderEmptyElement } = index_esm.VxeUI;
const tableComponentPropKeys = Object.keys(props$1.tableProps);
const tableComponentMethodKeys = ["clearAll", "syncData", "updateData", "loadData", "reloadData", "reloadRow", "loadColumn", "reloadColumn", "getRowNode", "getColumnNode", "getRowIndex", "getVTRowIndex", "getVMRowIndex", "getColumnIndex", "getVTColumnIndex", "getVMColumnIndex", "setRow", "createData", "createRow", "revertData", "clearData", "isRemoveByRow", "isInsertByRow", "isUpdateByRow", "getColumns", "getColumnById", "getColumnByField", "getTableColumn", "getFullColumns", "getData", "getCheckboxRecords", "getParentRow", "getTreeRowChildren", "getTreeRowLevel", "getTreeParentRow", "getRowSeq", "getRowById", "getRowid", "getTableData", "getFullData", "setColumnFixed", "clearColumnFixed", "setColumnWidth", "getColumnWidth", "recalcRowHeight", "setRowHeightConf", "getRowHeightConf", "setRowHeight", "getRowHeight", "hideColumn", "showColumn", "resetColumn", "refreshColumn", "refreshScroll", "recalculate", "closeTooltip", "isAllCheckboxChecked", "isAllCheckboxIndeterminate", "getCheckboxIndeterminateRecords", "setCheckboxRow", "setCheckboxRowKey", "isCheckedByCheckboxRow", "isCheckedByCheckboxRowKey", "isIndeterminateByCheckboxRow", "isIndeterminateByCheckboxRowKey", "toggleCheckboxRow", "setAllCheckboxRow", "getRadioReserveRecord", "clearRadioReserve", "getCheckboxReserveRecords", "clearCheckboxReserve", "toggleAllCheckboxRow", "clearCheckboxRow", "setCurrentRow", "isCheckedByRadioRow", "isCheckedByRadioRowKey", "setRadioRow", "setRadioRowKey", "clearCurrentRow", "clearRadioRow", "getCurrentRecord", "getRadioRecord", "getCurrentColumn", "setCurrentColumn", "clearCurrentColumn", "setPendingRow", "togglePendingRow", "hasPendingByRow", "isPendingByRow", "getPendingRecords", "clearPendingRow", "setFilterByEvent", "sort", "setSort", "setSortByEvent", "clearSort", "clearSortByEvent", "isSort", "getSortColumns", "closeFilter", "isFilter", "clearFilterByEvent", "isActiveFilterByColumn", "isRowExpandLoaded", "clearRowExpandLoaded", "reloadRowExpand", "reloadRowExpand", "toggleRowExpand", "setAllRowExpand", "setRowExpand", "isExpandByRow", "isRowExpandByRow", "clearRowExpand", "clearRowExpandReserve", "getRowExpandRecords", "getTreeExpandRecords", "isTreeExpandLoaded", "clearTreeExpandLoaded", "reloadTreeExpand", "reloadTreeChilds", "toggleTreeExpand", "setAllTreeExpand", "setTreeExpand", "isTreeExpandByRow", "clearTreeExpand", "clearTreeExpandReserve", "getScroll", "getScrollData", "scrollTo", "scrollToStartRow", "scrollToEndRow", "scrollToRow", "scrollToStartColumn", "scrollToEndColumn", "scrollToColumn", "clearScroll", "updateFooter", "updateStatus", "setMergeCells", "removeInsertRow", "removeMergeCells", "getMergeCells", "setMergeHeaderCells", "removeMergeHeaderCells", "getMergeHeaderCells", "clearMergeHeaderCells", "clearMergeCells", "setMergeFooterItems", "removeMergeFooterItems", "getMergeFooterItems", "clearMergeFooterItems", "getCustomStoreData", "setRowGroupExpand", "setRowGroupExpandByField", "setAllRowGroupExpand", "clearRowGroupExpand", "isRowGroupExpandByRow", "isRowGroupRecord", "isAggregateRecord", "isAggregateExpandByRow", "getAggregateContentByRow", "getAggregateRowChildren", "setRowGroups", "clearRowGroups", "openTooltip", "moveColumnTo", "moveRowTo", "getCellLabel", "getCellElement", "focus", "blur", "connect", "connectToolbar"];
function createInternalData() {
  return {
    uFoot: false
  };
}
const VxeGridComponent = comp.defineVxeComponent({
  name: "VxeGrid",
  props: props.gridProps,
  emits: emits.gridEmits,
  setup(props2, context) {
    var _a;
    const { slots, emit } = context;
    const xID = XEUtils.uniqueId();
    const VxeUIFormComponent = index_esm.VxeUI.getComponent("VxeForm");
    const VxeUIPagerComponent = index_esm.VxeUI.getComponent("VxePager");
    const defaultLayouts = [["Form"], ["Toolbar", "Top", "Table", "Bottom", "Pager"]];
    const { computeSize } = useFns.useSize(props2);
    const reactData = vue.reactive({
      tableLoading: false,
      proxyInited: false,
      isZMax: false,
      tableData: [],
      filterData: [],
      formData: {},
      sortData: [],
      footerData: [],
      tZindex: 0,
      tablePage: {
        total: 0,
        pageSize: ((_a = getConfig().pager) === null || _a === void 0 ? void 0 : _a.pageSize) || 10,
        currentPage: 1
      }
    });
    const internalData = createInternalData();
    const refElem = vue.ref();
    const refTable = vue.ref();
    const refForm = vue.ref();
    const refToolbar = vue.ref();
    const refPager = vue.ref();
    const refPopupContainerElem = vue.ref();
    const refFormWrapper = vue.ref();
    const refToolbarWrapper = vue.ref();
    const refTopWrapper = vue.ref();
    const refBottomWrapper = vue.ref();
    const refPagerWrapper = vue.ref();
    const extendTableMethods = (methodKeys) => {
      const funcs = {};
      methodKeys.forEach((name) => {
        funcs[name] = (...args) => {
          const $xeTable = refTable.value;
          if ($xeTable && $xeTable[name]) {
            return $xeTable[name](...args);
          }
        };
      });
      return funcs;
    };
    const gridExtendTableMethods = extendTableMethods(tableComponentMethodKeys);
    tableComponentMethodKeys.forEach((name) => {
      gridExtendTableMethods[name] = (...args) => {
        const $xeTable = refTable.value;
        if ($xeTable && $xeTable[name]) {
          return $xeTable && $xeTable[name](...args);
        }
      };
    });
    const computeProxyOpts = vue.computed(() => {
      return XEUtils.merge({}, XEUtils.clone(getConfig().grid.proxyConfig, true), props2.proxyConfig);
    });
    const computeIsRespMsg = vue.computed(() => {
      const proxyOpts = computeProxyOpts.value;
      return !!(XEUtils.isBoolean(proxyOpts.message) ? proxyOpts.message : proxyOpts.showResponseMsg);
    });
    const computeIsActiveMsg = vue.computed(() => {
      const proxyOpts = computeProxyOpts.value;
      return XEUtils.isBoolean(proxyOpts.showActionMsg) ? proxyOpts.showActionMsg : !!proxyOpts.showActiveMsg;
    });
    const computePagerOpts = vue.computed(() => {
      return Object.assign({}, getConfig().grid.pagerConfig, props2.pagerConfig);
    });
    const computeFormOpts = vue.computed(() => {
      return Object.assign({}, getConfig().grid.formConfig, props2.formConfig);
    });
    const computeToolbarOpts = vue.computed(() => {
      return Object.assign({}, getConfig().grid.toolbarConfig, props2.toolbarConfig);
    });
    const computeZoomOpts = vue.computed(() => {
      return Object.assign({}, getConfig().grid.zoomConfig, props2.zoomConfig);
    });
    const computeStyles = vue.computed(() => {
      const { height, maxHeight } = props2;
      const { isZMax, tZindex } = reactData;
      const stys = {};
      if (isZMax) {
        stys.zIndex = tZindex;
      } else {
        if (height) {
          stys.height = height === "auto" || height === "100%" ? "100%" : dom.toCssUnit(height);
        }
        if (maxHeight) {
          stys.maxHeight = maxHeight === "auto" || maxHeight === "100%" ? "100%" : dom.toCssUnit(maxHeight);
        }
      }
      return stys;
    });
    const computeTableExtendProps = vue.computed(() => {
      const rest = {};
      tableComponentPropKeys.forEach((key) => {
        if (props2[key] !== void 0) {
          rest[key] = props2[key];
        }
      });
      return rest;
    });
    const computeTableProps = vue.computed(() => {
      const { showFooter, seqConfig, pagerConfig, editConfig, proxyConfig } = props2;
      const { isZMax, tablePage, footerData } = reactData;
      const tableExtendProps = computeTableExtendProps.value;
      const proxyOpts = computeProxyOpts.value;
      const pagerOpts = computePagerOpts.value;
      const isLoading = computeIsLoading.value;
      const tProps = Object.assign({}, tableExtendProps);
      if (showFooter && !tProps.footerData) {
        tProps.footerData = footerData;
      } else if (proxyOpts.footer && footerData.length) {
        tProps.footerData = footerData;
      }
      if (isZMax) {
        if (tProps.maxHeight) {
          tProps.maxHeight = "100%";
        } else {
          tProps.height = "100%";
        }
      }
      if (proxyConfig && utils.isEnableConf(proxyOpts)) {
        tProps.loading = isLoading;
        if (pagerConfig && proxyOpts.seq && utils.isEnableConf(pagerOpts)) {
          tProps.seqConfig = Object.assign({}, seqConfig, { startIndex: (tablePage.currentPage - 1) * tablePage.pageSize });
        }
      }
      if (editConfig) {
        tProps.editConfig = Object.assign({}, editConfig);
      }
      return tProps;
    });
    const computeCurrLayoutConf = vue.computed(() => {
      const { layouts } = props2;
      let confs = [];
      if (layouts && layouts.length) {
        confs = layouts;
      } else {
        confs = getConfig().grid.layouts || defaultLayouts;
      }
      let headKeys = [];
      let bodyKeys = [];
      let footKeys = [];
      if (confs.length) {
        if (XEUtils.isArray(confs[0])) {
          headKeys = confs[0];
          bodyKeys = confs[1] || [];
          footKeys = confs[2] || [];
        } else {
          bodyKeys = confs;
        }
      }
      return {
        headKeys,
        bodyKeys,
        footKeys
      };
    });
    const computeCustomCurrentPageFlag = vue.computed(() => {
      const pagerOpts = computePagerOpts.value;
      return pagerOpts.currentPage;
    });
    const computeCustomPageSizeFlag = vue.computed(() => {
      const pagerOpts = computePagerOpts.value;
      return pagerOpts.pageSize;
    });
    const computeCustomTotalFlag = vue.computed(() => {
      const pagerOpts = computePagerOpts.value;
      return pagerOpts.total;
    });
    const computePageCount = vue.computed(() => {
      const { tablePage } = reactData;
      return Math.max(Math.ceil(tablePage.total / tablePage.pageSize), 1);
    });
    const computeIsLoading = vue.computed(() => {
      const { loading, proxyConfig } = props2;
      const { tableLoading } = reactData;
      const proxyOpts = computeProxyOpts.value;
      const { showLoading } = proxyOpts;
      return loading || tableLoading && showLoading && proxyConfig && utils.isEnableConf(proxyOpts);
    });
    const refMaps = {
      refElem,
      refTable,
      refForm,
      refToolbar,
      refPager,
      refPopupContainerElem
    };
    const computeMaps = {
      computeProxyOpts,
      computePagerOpts,
      computeFormOpts,
      computeToolbarOpts,
      computeZoomOpts
    };
    const $xeGrid = {
      xID,
      props: props2,
      context,
      reactData,
      internalData,
      getRefMaps: () => refMaps,
      getComputeMaps: () => computeMaps
    };
    const initToolbar = () => {
      const toolbarOpts = computeToolbarOpts.value;
      if (props2.toolbarConfig && utils.isEnableConf(toolbarOpts)) {
        vue.nextTick(() => {
          const $xeTable = refTable.value;
          const $xeToolbar = refToolbar.value;
          if ($xeTable && $xeToolbar) {
            $xeTable.connectToolbar($xeToolbar);
          }
        });
      }
    };
    const getFormData = () => {
      const { proxyConfig } = props2;
      const { formData } = reactData;
      const proxyOpts = computeProxyOpts.value;
      const formOpts = computeFormOpts.value;
      return proxyConfig && utils.isEnableConf(proxyOpts) && proxyOpts.form ? formData : formOpts.data;
    };
    const initPages = (propKey) => {
      const { tablePage } = reactData;
      const { pagerConfig } = props2;
      const pagerOpts = computePagerOpts.value;
      if (pagerConfig && utils.isEnableConf(pagerOpts)) {
        if (propKey) {
          if (pagerOpts[propKey]) {
            tablePage[propKey] = XEUtils.toNumber(pagerOpts[propKey]);
          }
        } else {
          const { currentPage, pageSize, total } = pagerOpts;
          if (currentPage) {
            tablePage.currentPage = currentPage;
          }
          if (pageSize) {
            tablePage.pageSize = pageSize;
          }
          if (total) {
            tablePage.total = total;
          }
        }
      }
    };
    const triggerPendingEvent = (code) => {
      const isActiveMsg = computeIsActiveMsg.value;
      const $xeTable = refTable.value;
      const selectRecords = $xeTable ? $xeTable.getCheckboxRecords() : [];
      if (selectRecords.length) {
        if ($xeTable) {
          $xeTable.togglePendingRow(selectRecords);
        }
        $xeGrid.clearCheckboxRow();
      } else {
        if (isActiveMsg) {
          if (index_esm.VxeUI.modal) {
            index_esm.VxeUI.modal.message({ id: code, content: getI18n("vxe.grid.selectOneRecord"), status: "warning" });
          }
        }
      }
    };
    const getRespMsg = (rest, defaultMsg) => {
      const proxyOpts = computeProxyOpts.value;
      const resConfigs = proxyOpts.response || proxyOpts.props || {};
      const messageProp = resConfigs.message;
      const $xeTable = refTable.value;
      let msg;
      if (rest && messageProp) {
        msg = XEUtils.isFunction(messageProp) ? messageProp({ data: rest, $table: $xeTable, $grid: $xeGrid, $gantt: null }) : XEUtils.get(rest, messageProp);
      }
      return msg || getI18n(defaultMsg);
    };
    const handleDeleteRow = (code, alertKey, callback) => {
      const isActiveMsg = computeIsActiveMsg.value;
      const selectRecords = $xeGrid.getCheckboxRecords();
      if (isActiveMsg) {
        if (selectRecords.length) {
          if (index_esm.VxeUI.modal) {
            return index_esm.VxeUI.modal.confirm({ id: `cfm_${code}`, content: getI18n(alertKey), escClosable: true }).then((type) => {
              if (type === "confirm") {
                return callback();
              }
            });
          }
        } else {
          if (index_esm.VxeUI.modal) {
            index_esm.VxeUI.modal.message({ id: `msg_${code}`, content: getI18n("vxe.grid.selectOneRecord"), status: "warning" });
          }
        }
      } else {
        if (selectRecords.length) {
          callback();
        }
      }
      return Promise.resolve();
    };
    const pageChangeEvent = (params) => {
      const { proxyConfig } = props2;
      const { tablePage } = reactData;
      const { $event, currentPage, pageSize } = params;
      const proxyOpts = computeProxyOpts.value;
      tablePage.currentPage = currentPage;
      tablePage.pageSize = pageSize;
      $xeGrid.dispatchEvent("page-change", params, $event);
      if (proxyConfig && utils.isEnableConf(proxyOpts)) {
        $xeGrid.commitProxy("query").then((rest) => {
          $xeGrid.dispatchEvent("proxy-query", rest, $event);
        });
      }
    };
    const handleSortEvent = (params) => {
      const $xeTable = refTable.value;
      const { proxyConfig } = props2;
      if (!$xeTable) {
        return;
      }
      const { computeSortOpts } = $xeTable.getComputeMaps();
      const proxyOpts = computeProxyOpts.value;
      const sortOpts = computeSortOpts.value;
      if (sortOpts.remote) {
        reactData.sortData = params.sortList;
        if (proxyConfig && utils.isEnableConf(proxyOpts)) {
          reactData.tablePage.currentPage = 1;
          $xeGrid.commitProxy("query").then((rest) => {
            $xeGrid.dispatchEvent("proxy-query", rest, params.$event);
          });
        }
      }
    };
    const sortChangeEvent = (params) => {
      handleSortEvent(params);
      $xeGrid.dispatchEvent("sort-change", params, params.$event);
    };
    const clearAllSortEvent = (params) => {
      handleSortEvent(params);
      $xeGrid.dispatchEvent("clear-all-sort", params, params.$event);
    };
    const handleFilterEvent = (params) => {
      const $xeTable = refTable.value;
      const { proxyConfig } = props2;
      if (!$xeTable) {
        return;
      }
      const { computeFilterOpts } = $xeTable.getComputeMaps();
      const proxyOpts = computeProxyOpts.value;
      const filterOpts = computeFilterOpts.value;
      if (filterOpts.remote) {
        reactData.filterData = params.filterList;
        if (proxyConfig && utils.isEnableConf(proxyOpts)) {
          reactData.tablePage.currentPage = 1;
          internalData.uFoot = true;
          $xeGrid.commitProxy("query").then((rest) => {
            $xeGrid.dispatchEvent("proxy-query", rest, params.$event);
          });
          internalData.uFoot = false;
          updateQueryFooter();
        }
      }
    };
    const filterChangeEvent = (params) => {
      handleFilterEvent(params);
      $xeGrid.dispatchEvent("filter-change", params, params.$event);
    };
    const clearAllFilterEvent = (params) => {
      handleFilterEvent(params);
      $xeGrid.dispatchEvent("clear-all-filter", params, params.$event);
    };
    const submitFormEvent = (params) => {
      const { proxyConfig } = props2;
      const proxyOpts = computeProxyOpts.value;
      if (reactData.tableLoading) {
        return;
      }
      if (proxyConfig && utils.isEnableConf(proxyOpts)) {
        internalData.uFoot = true;
        $xeGrid.commitProxy("reload").then((rest) => {
          $xeGrid.dispatchEvent("proxy-query", Object.assign(Object.assign({}, rest), { isReload: true }), params.$event);
        });
        internalData.uFoot = false;
        updateQueryFooter();
      }
      $xeGrid.dispatchEvent("form-submit", params, params.$event);
    };
    const resetFormEvent = (params) => {
      const $xeTable = refTable.value;
      const { proxyConfig } = props2;
      const { $event } = params;
      const proxyOpts = computeProxyOpts.value;
      if (proxyConfig && utils.isEnableConf(proxyOpts)) {
        if ($xeTable) {
          $xeTable.clearScroll();
        }
        internalData.uFoot = true;
        $xeGrid.commitProxy("reload").then((rest) => {
          $xeGrid.dispatchEvent("proxy-query", Object.assign(Object.assign({}, rest), { isReload: true }), $event);
        });
        internalData.uFoot = false;
        updateQueryFooter();
      }
      $xeGrid.dispatchEvent("form-reset", params, $event);
    };
    const submitInvalidEvent = (params) => {
      $xeGrid.dispatchEvent("form-submit-invalid", params, params.$event);
    };
    const collapseEvent = (params) => {
      const { $event } = params;
      $xeGrid.dispatchEvent("form-toggle-collapse", params, $event);
      $xeGrid.dispatchEvent("form-collapse", params, $event);
    };
    const handleZoom = (isMax) => {
      const { isZMax } = reactData;
      if (isMax ? !isZMax : isZMax) {
        reactData.isZMax = !isZMax;
        if (reactData.tZindex < utils.getLastZIndex()) {
          reactData.tZindex = utils.nextZIndex();
        }
      }
      return vue.nextTick().then(() => $xeGrid.recalculate(true)).then(() => {
        setTimeout(() => $xeGrid.recalculate(true), 15);
        return reactData.isZMax;
      });
    };
    const getFuncSlot = (optSlots, slotKey) => {
      const funcSlot = optSlots[slotKey];
      if (funcSlot) {
        if (XEUtils.isString(funcSlot)) {
          if (slots[funcSlot]) {
            return slots[funcSlot];
          } else {
            log.errLog("vxe.error.notSlot", [`[grid] ${funcSlot}`]);
          }
        } else {
          return funcSlot;
        }
      }
      return null;
    };
    const getConfigSlot = (slotConfigs) => {
      const slotConf = {};
      XEUtils.objectMap(slotConfigs, (slotFunc, slotKey) => {
        if (slotFunc) {
          if (XEUtils.isString(slotFunc)) {
            if (slots[slotFunc]) {
              slotConf[slotKey] = slots[slotFunc];
            } else {
              log.errLog("vxe.error.notSlot", [`[grid] ${slotFunc}`]);
            }
          } else {
            slotConf[slotKey] = slotFunc;
          }
        }
      });
      return slotConf;
    };
    const renderForm = () => {
      const { formConfig, proxyConfig } = props2;
      const { formData } = reactData;
      const proxyOpts = computeProxyOpts.value;
      const formOpts = computeFormOpts.value;
      if (formConfig && utils.isEnableConf(formOpts) || slots.form) {
        let slotVNs = [];
        if (slots.form) {
          slotVNs = slots.form({ $grid: $xeGrid, $gantt: null });
        } else {
          if (formOpts.items) {
            const formSlots = {};
            if (!formOpts.inited) {
              formOpts.inited = true;
              const beforeItem = proxyOpts.beforeItem;
              if (proxyOpts && beforeItem) {
                formOpts.items.forEach((item) => {
                  beforeItem({ $grid: $xeGrid, $gantt: null, item });
                });
              }
            }
            formOpts.items.forEach((item) => {
              XEUtils.each(item.slots, (func) => {
                if (!XEUtils.isFunction(func)) {
                  if (slots[func]) {
                    formSlots[func] = slots[func];
                  }
                }
              });
            });
            if (VxeUIFormComponent) {
              slotVNs.push(vue.h(VxeUIFormComponent, Object.assign(Object.assign({ ref: refForm }, Object.assign({}, formOpts, {
                data: proxyConfig && utils.isEnableConf(proxyOpts) && proxyOpts.form ? formData : formOpts.data
              })), { onSubmit: submitFormEvent, onReset: resetFormEvent, onSubmitInvalid: submitInvalidEvent, onCollapse: collapseEvent }), formSlots));
            }
          }
        }
        return vue.h("div", {
          ref: refFormWrapper,
          key: "form",
          class: "vxe-grid--form-wrapper"
        }, slotVNs);
      }
      return renderEmptyElement($xeGrid);
    };
    const renderToolbar = () => {
      const { toolbarConfig } = props2;
      const toolbarOpts = computeToolbarOpts.value;
      const toolbarSlot = slots.toolbar;
      if (toolbarConfig && utils.isEnableConf(toolbarOpts) || toolbarSlot) {
        let slotVNs = [];
        if (toolbarSlot) {
          slotVNs = toolbarSlot({ $grid: $xeGrid, $gantt: null });
        } else {
          const toolbarOptSlots = toolbarOpts.slots;
          const toolbarSlots = {};
          if (toolbarOptSlots) {
            const buttonsSlot = getFuncSlot(toolbarOptSlots, "buttons");
            const buttonPrefixSlot = getFuncSlot(toolbarOptSlots, "buttonPrefix");
            const buttonSuffixSlot = getFuncSlot(toolbarOptSlots, "buttonSuffix");
            const toolsSlot = getFuncSlot(toolbarOptSlots, "tools");
            const toolPrefixSlot = getFuncSlot(toolbarOptSlots, "toolPrefix");
            const toolSuffixSlot = getFuncSlot(toolbarOptSlots, "toolSuffix");
            if (buttonsSlot) {
              toolbarSlots.buttons = buttonsSlot;
            }
            if (buttonPrefixSlot) {
              toolbarSlots.buttonPrefix = buttonPrefixSlot;
            }
            if (buttonSuffixSlot) {
              toolbarSlots.buttonSuffix = buttonSuffixSlot;
            }
            if (toolsSlot) {
              toolbarSlots.tools = toolsSlot;
            }
            if (toolPrefixSlot) {
              toolbarSlots.toolPrefix = toolPrefixSlot;
            }
            if (toolSuffixSlot) {
              toolbarSlots.toolSuffix = toolSuffixSlot;
            }
          }
          slotVNs.push(vue.h(toolbar.default, Object.assign(Object.assign({ ref: refToolbar }, toolbarOpts), { slots: void 0 }), toolbarSlots));
        }
        return vue.h("div", {
          ref: refToolbarWrapper,
          key: "toolbar",
          class: "vxe-grid--toolbar-wrapper"
        }, slotVNs);
      }
      return renderEmptyElement($xeGrid);
    };
    const renderTop = () => {
      const topSlot = slots.top;
      if (topSlot) {
        return vue.h("div", {
          ref: refTopWrapper,
          key: "top",
          class: "vxe-grid--top-wrapper"
        }, topSlot({ $grid: $xeGrid, $gantt: null }));
      }
      return renderEmptyElement($xeGrid);
    };
    const renderTableLeft = () => {
      const leftSlot = slots.left;
      if (leftSlot) {
        return vue.h("div", {
          class: "vxe-grid--left-wrapper"
        }, leftSlot({ $grid: $xeGrid, $gantt: null }));
      }
      return renderEmptyElement($xeGrid);
    };
    const renderTableRight = () => {
      const rightSlot = slots.right;
      if (rightSlot) {
        return vue.h("div", {
          class: "vxe-grid--right-wrapper"
        }, rightSlot({ $grid: $xeGrid, $gantt: null }));
      }
      return renderEmptyElement($xeGrid);
    };
    const renderTable = () => {
      const { proxyConfig } = props2;
      const tableProps = computeTableProps.value;
      const proxyOpts = computeProxyOpts.value;
      const tableOns = Object.assign({}, tableCompEvents);
      const emptySlot = slots.empty;
      const loadingSlot = slots.loading;
      const rowDragIconSlot = slots.rowDragIcon || slots["row-drag-icon"];
      const columnDragIconSlot = slots.columnDragIcon || slots["column-drag-icon"];
      const headerTooltipSlot = slots.headerTooltip || slots["header-tooltip"];
      const tooltipSlot = slots.tooltip;
      const footerTooltipSlot = slots.footerTooltip || slots["footer-tooltip"];
      if (proxyConfig && utils.isEnableConf(proxyOpts)) {
        if (proxyOpts.sort) {
          tableOns.onSortChange = sortChangeEvent;
          tableOns.onClearAllSort = clearAllSortEvent;
        }
        if (proxyOpts.filter) {
          tableOns.onFilterChange = filterChangeEvent;
          tableOns.onClearAllFilter = clearAllFilterEvent;
        }
      }
      const slotObj = {};
      if (emptySlot) {
        slotObj.empty = emptySlot;
      }
      if (loadingSlot) {
        slotObj.loading = loadingSlot;
      }
      if (rowDragIconSlot) {
        slotObj.rowDragIcon = rowDragIconSlot;
      }
      if (columnDragIconSlot) {
        slotObj.columnDragIcon = columnDragIconSlot;
      }
      if (headerTooltipSlot) {
        slotObj.headerTooltip = headerTooltipSlot;
      }
      if (tooltipSlot) {
        slotObj.tooltip = tooltipSlot;
      }
      if (footerTooltipSlot) {
        slotObj.footerTooltip = footerTooltipSlot;
      }
      return vue.h("div", {
        class: "vxe-grid--table-wrapper"
      }, [
        vue.h(table.default, Object.assign(Object.assign({ ref: refTable }, tableProps), tableOns), slotObj)
      ]);
    };
    const renderBottom = () => {
      if (slots.bottom) {
        return vue.h("div", {
          ref: refBottomWrapper,
          key: "bottom",
          class: "vxe-grid--bottom-wrapper"
        }, slots.bottom({ $grid: $xeGrid, $gantt: null }));
      }
      return renderEmptyElement($xeGrid);
    };
    const renderPager = () => {
      const { proxyConfig, pagerConfig } = props2;
      const proxyOpts = computeProxyOpts.value;
      const pagerOpts = computePagerOpts.value;
      const pagerSlot = slots.pager;
      if (pagerConfig && utils.isEnableConf(pagerOpts) || slots.pager) {
        return vue.h("div", {
          ref: refPagerWrapper,
          key: "pager",
          class: "vxe-grid--pager-wrapper"
        }, pagerSlot ? pagerSlot({ $grid: $xeGrid, $gantt: null }) : [
          VxeUIPagerComponent ? vue.h(VxeUIPagerComponent, Object.assign(Object.assign(Object.assign({ ref: refPager }, pagerOpts), proxyConfig && utils.isEnableConf(proxyOpts) ? reactData.tablePage : {}), { onPageChange: pageChangeEvent }), getConfigSlot(pagerOpts.slots)) : renderEmptyElement($xeGrid)
        ]);
      }
      return renderEmptyElement($xeGrid);
    };
    const renderChildLayout = (layoutKeys) => {
      const childVNs = [];
      layoutKeys.forEach((key) => {
        switch (key) {
          case "Form":
            childVNs.push(renderForm());
            break;
          case "Toolbar":
            childVNs.push(renderToolbar());
            break;
          case "Top":
            childVNs.push(renderTop());
            break;
          case "Table":
            childVNs.push(vue.h("div", {
              key: "table",
              class: "vxe-grid--table-container"
            }, [
              renderTableLeft(),
              renderTable(),
              renderTableRight()
            ]));
            break;
          case "Bottom":
            childVNs.push(renderBottom());
            break;
          case "Pager":
            childVNs.push(renderPager());
            break;
          default:
            log.errLog("vxe.error.notProp", [`[grid] layouts -> ${key}`]);
            break;
        }
      });
      return childVNs;
    };
    const renderLayout = () => {
      const currLayoutConf = computeCurrLayoutConf.value;
      const { headKeys, bodyKeys, footKeys } = currLayoutConf;
      const asideLeftSlot = slots.asideLeft || slots["aside-left"];
      const asideRightSlot = slots.asideRight || slots["aside-right"];
      return [
        vue.h("div", {
          class: "vxe-grid--layout-header-wrapper"
        }, renderChildLayout(headKeys)),
        vue.h("div", {
          class: "vxe-grid--layout-body-wrapper"
        }, [
          asideLeftSlot ? vue.h("div", {
            class: "vxe-grid--layout-aside-left-wrapper"
          }, asideLeftSlot({})) : renderEmptyElement($xeGrid),
          vue.h("div", {
            class: "vxe-grid--layout-body-content-wrapper"
          }, renderChildLayout(bodyKeys)),
          asideRightSlot ? vue.h("div", {
            class: "vxe-grid--layout-aside-right-wrapper"
          }, asideRightSlot({})) : renderEmptyElement($xeGrid)
        ]),
        vue.h("div", {
          class: "vxe-grid--layout-footer-wrapper"
        }, renderChildLayout(footKeys)),
        vue.h("div", {
          ref: refPopupContainerElem
        })
      ];
    };
    const tableCompEvents = {};
    emits$1.tableEmits.forEach((name) => {
      const type = XEUtils.camelCase(`on-${name}`);
      tableCompEvents[type] = (...args) => emit(name, ...args);
    });
    const getDefaultFormData = () => {
      const formOpts = computeFormOpts.value;
      if (formOpts.items) {
        const fData = {};
        formOpts.items.forEach((item) => {
          const { field, itemRender } = item;
          if (field) {
            let itemValue = null;
            if (itemRender) {
              const { startField, endField, defaultValue } = itemRender;
              if (XEUtils.isFunction(defaultValue)) {
                itemValue = defaultValue({ item });
              } else if (!XEUtils.isUndefined(defaultValue)) {
                itemValue = defaultValue;
              }
              if (startField && endField) {
                XEUtils.set(fData, startField, null);
                XEUtils.set(fData, endField, null);
              }
            }
            fData[field] = itemValue;
          }
        });
        return fData;
      }
      return {};
    };
    const initProxy = () => {
      const { proxyConfig, formConfig } = props2;
      const { proxyInited } = reactData;
      const proxyOpts = computeProxyOpts.value;
      const formOpts = computeFormOpts.value;
      if (proxyConfig && utils.isEnableConf(proxyOpts)) {
        if (formConfig && utils.isEnableConf(formOpts) && proxyOpts.form && formOpts.items) {
          reactData.formData = getDefaultFormData();
        }
        if (!proxyInited) {
          reactData.proxyInited = true;
          if (proxyOpts.autoLoad !== false) {
            vue.nextTick().then(() => {
              internalData.uFoot = true;
              const rest = $xeGrid.commitProxy("initial");
              internalData.uFoot = false;
              updateQueryFooter();
              return rest;
            }).then((rest) => {
              dispatchEvent("proxy-query", Object.assign(Object.assign({}, rest), { isInited: true }), new Event("initial"));
            });
          }
        }
      }
    };
    const updateQueryFooter = () => {
      const proxyOpts = computeProxyOpts.value;
      const { ajax } = proxyOpts;
      if (ajax && ajax.queryFooter) {
        return $xeGrid.commitProxy("queryFooter");
      }
    };
    const handleGlobalKeydownEvent = (evnt) => {
      const zoomOpts = computeZoomOpts.value;
      const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE);
      if (isEsc && reactData.isZMax && zoomOpts.escRestore !== false) {
        $xeGrid.triggerZoomEvent(evnt);
      }
    };
    const dispatchEvent = (type, params, evnt) => {
      emit(type, createEvent(evnt, { $grid: $xeGrid, $gantt: null }, params));
    };
    const gridMethods = {
      dispatchEvent,
      getEl() {
        return refElem.value;
      },
      /**
       * 提交指令，支持 code 或 button
       * @param {String/Object} code 字符串或对象
       */
      commitProxy(proxyTarget, ...args) {
        const { showFooter, proxyConfig, toolbarConfig, pagerConfig, editRules, validConfig } = props2;
        const { tablePage } = reactData;
        const isActiveMsg = computeIsActiveMsg.value;
        const isRespMsg = computeIsRespMsg.value;
        const proxyOpts = computeProxyOpts.value;
        const pagerOpts = computePagerOpts.value;
        const toolbarOpts = computeToolbarOpts.value;
        const { beforeQuery, afterQuery, beforeQueryFooter, afterQueryFooter, beforeDelete, afterDelete, beforeSave, afterSave, ajax = {} } = proxyOpts;
        const resConfigs = proxyOpts.response || proxyOpts.props || {};
        const $xeTable = refTable.value;
        if (!$xeTable) {
          return vue.nextTick();
        }
        let formData = getFormData();
        let button = null;
        let code = null;
        if (XEUtils.isString(proxyTarget)) {
          const { buttons } = toolbarOpts;
          const matchObj = toolbarConfig && utils.isEnableConf(toolbarOpts) && buttons ? XEUtils.findTree(buttons, (item) => item.code === proxyTarget, { children: "dropdowns" }) : null;
          button = matchObj ? matchObj.item : null;
          code = proxyTarget;
        } else {
          button = proxyTarget;
          code = button.code;
        }
        const btnParams = button ? button.params : null;
        switch (code) {
          case "insert":
            return $xeTable.insert({});
          case "insert_edit":
            return $xeTable.insert({}).then(({ row }) => $xeTable.setEditRow(row, true));
          // 已废弃
          case "insert_actived":
            return $xeTable.insert({}).then(({ row }) => $xeTable.setEditRow(row, true));
          // 已废弃
          case "mark_cancel":
            triggerPendingEvent(code);
            break;
          case "remove":
            return handleDeleteRow(code, "vxe.grid.removeSelectRecord", () => $xeTable.removeCheckboxRow());
          case "import":
            $xeTable.importData(btnParams);
            break;
          case "open_import":
            $xeTable.openImport(btnParams);
            break;
          case "export":
            $xeTable.exportData(btnParams);
            break;
          case "open_export":
            $xeTable.openExport(btnParams);
            break;
          case "reset_custom":
            return $xeTable.resetCustom(true);
          case "initial":
          case "reload":
          case "query": {
            const qMethods = ajax.query;
            const qsMethods = ajax.querySuccess;
            const qeMethods = ajax.queryError;
            if (qMethods) {
              const isInited = code === "initial";
              const isReload = code === "reload";
              if (!isInited && reactData.tableLoading) {
                return vue.nextTick();
              }
              let operPromise = null;
              let sortList = [];
              let filterList = [];
              let pageParams = {};
              if (pagerConfig) {
                if (isInited || isReload) {
                  tablePage.currentPage = 1;
                }
                if (utils.isEnableConf(pagerOpts)) {
                  pageParams = Object.assign({}, tablePage);
                }
              }
              if (isInited) {
                if (proxyConfig && utils.isEnableConf(proxyOpts) && proxyOpts.form) {
                  formData = getDefaultFormData();
                  reactData.formData = formData;
                }
                if ($xeTable) {
                  const tableInternalData = $xeTable.internalData;
                  const { tableFullColumn, fullColumnFieldData } = tableInternalData;
                  const { computeSortOpts } = $xeTable.getComputeMaps();
                  const sortOpts = computeSortOpts.value;
                  let defaultSort = sortOpts.defaultSort;
                  tableFullColumn.forEach((column) => {
                    column.order = null;
                  });
                  if (defaultSort) {
                    if (!XEUtils.isArray(defaultSort)) {
                      defaultSort = [defaultSort];
                    }
                    sortList = defaultSort.map((item) => {
                      const { field, order } = item;
                      const colRest = fullColumnFieldData[field];
                      if (colRest) {
                        const column = colRest.column;
                        if (column) {
                          column.order = order;
                        }
                      }
                      return {
                        field,
                        property: field,
                        order
                      };
                    });
                  }
                  filterList = $xeTable.getCheckedFilters();
                }
              } else {
                if ($xeTable) {
                  if (isReload) {
                    operPromise = $xeTable.clearAll();
                  } else {
                    sortList = $xeTable.getSortColumns();
                    filterList = $xeTable.getCheckedFilters();
                  }
                }
              }
              const commitParams = {
                $table: $xeTable,
                $grid: $xeGrid,
                $gantt: null,
                code,
                button,
                isInited,
                isReload,
                page: pageParams,
                sort: sortList.length ? sortList[0] : {},
                sorts: sortList,
                filters: filterList,
                form: formData,
                options: qMethods
              };
              reactData.sortData = sortList;
              reactData.filterData = filterList;
              reactData.tableLoading = true;
              return Promise.all([
                Promise.resolve((beforeQuery || qMethods)(commitParams, ...args)),
                operPromise
              ]).then(([rest]) => {
                let tableData = [];
                reactData.tableLoading = false;
                if (rest) {
                  const reParams = { data: rest, $table: $xeTable, $grid: $xeGrid, $gantt: null };
                  if (pagerConfig && utils.isEnableConf(pagerOpts)) {
                    const totalProp = resConfigs.total;
                    const total = (XEUtils.isFunction(totalProp) ? totalProp(reParams) : XEUtils.get(rest, totalProp || "page.total")) || 0;
                    tablePage.total = XEUtils.toNumber(total);
                    const resultProp = resConfigs.result;
                    tableData = (XEUtils.isFunction(resultProp) ? resultProp(reParams) : XEUtils.get(rest, resultProp || "result")) || [];
                    const pageCount = Math.max(Math.ceil(total / tablePage.pageSize), 1);
                    if (tablePage.currentPage > pageCount) {
                      tablePage.currentPage = pageCount;
                    }
                  } else {
                    const listProp = resConfigs.list;
                    if (XEUtils.isArray(rest)) {
                      tableData = rest;
                    } else if (listProp) {
                      tableData = (XEUtils.isFunction(listProp) ? listProp(reParams) : XEUtils.get(rest, listProp)) || [];
                    }
                  }
                  if (showFooter) {
                    const fdProp = resConfigs.footerData;
                    const footerList = fdProp ? XEUtils.isFunction(fdProp) ? fdProp(reParams) : XEUtils.get(rest, fdProp) : [];
                    if (XEUtils.isArray(footerList)) {
                      reactData.footerData = footerList;
                    }
                  }
                }
                if ($xeTable) {
                  $xeTable.loadData(tableData);
                } else {
                  vue.nextTick(() => {
                    const $xeTable2 = refTable.value;
                    if ($xeTable2) {
                      $xeTable2.loadData(tableData);
                    }
                  });
                }
                if (afterQuery) {
                  afterQuery(commitParams, ...args);
                }
                if (qsMethods) {
                  qsMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
                }
                return { status: true };
              }).catch((rest) => {
                reactData.tableLoading = false;
                if (qeMethods) {
                  qeMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
                }
                return { status: false };
              });
            } else {
              log.errLog("vxe.error.notFunc", ["[grid] proxy-config.ajax.query"]);
            }
            break;
          }
          case "queryFooter": {
            const qfMethods = ajax.queryFooter;
            const qfSuccessMethods = ajax.queryFooterSuccess;
            const qfErrorMethods = ajax.queryFooterError;
            if (qfMethods) {
              let filterList = [];
              if ($xeTable) {
                filterList = $xeTable.getCheckedFilters();
              }
              const commitParams = {
                $table: $xeTable,
                $grid: $xeGrid,
                $gantt: null,
                code,
                button,
                filters: filterList,
                form: formData,
                options: qfMethods
              };
              return Promise.resolve((beforeQueryFooter || qfMethods)(commitParams, ...args)).then((rest) => {
                reactData.footerData = XEUtils.isArray(rest) ? rest : [];
                if (afterQueryFooter) {
                  afterQueryFooter(commitParams, ...args);
                }
                if (qfSuccessMethods) {
                  qfSuccessMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
                }
                return { status: true };
              }).catch((rest) => {
                if (qfErrorMethods) {
                  qfErrorMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
                }
                return { status: false };
              });
            } else {
              log.errLog("vxe.error.notFunc", ["[grid] proxy-config.ajax.queryFooter"]);
            }
            break;
          }
          case "delete": {
            const dMethods = ajax.delete;
            const deleteSuccessMethods = ajax.deleteSuccess;
            const deleteErrorMethods = ajax.deleteError;
            if (dMethods) {
              const selectRecords = $xeGrid.getCheckboxRecords();
              const removeRecords = selectRecords.filter((row) => !$xeTable.isInsertByRow(row));
              const body = { removeRecords };
              const commitParams = {
                $table: $xeTable,
                $grid: $xeGrid,
                $gantt: null,
                code,
                button,
                body,
                form: formData,
                options: dMethods
              };
              if (selectRecords.length) {
                return handleDeleteRow(code, "vxe.grid.deleteSelectRecord", () => {
                  if (!removeRecords.length) {
                    return $xeTable.remove(selectRecords);
                  }
                  reactData.tableLoading = true;
                  return Promise.resolve((beforeDelete || dMethods)(commitParams, ...args)).then((rest) => {
                    reactData.tableLoading = false;
                    $xeTable.setPendingRow(removeRecords, false);
                    if (isRespMsg) {
                      if (index_esm.VxeUI.modal) {
                        index_esm.VxeUI.modal.message({ content: getRespMsg(rest, "vxe.grid.delSuccess"), status: "success" });
                      }
                    }
                    if (afterDelete) {
                      afterDelete(commitParams, ...args);
                    } else {
                      internalData.uFoot = true;
                      $xeGrid.commitProxy("query");
                      internalData.uFoot = false;
                      updateQueryFooter();
                    }
                    if (deleteSuccessMethods) {
                      deleteSuccessMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
                    }
                    return { status: true };
                  }).catch((rest) => {
                    reactData.tableLoading = false;
                    if (isRespMsg) {
                      if (index_esm.VxeUI.modal) {
                        index_esm.VxeUI.modal.message({ id: code, content: getRespMsg(rest, "vxe.grid.operError"), status: "error" });
                      }
                    }
                    if (deleteErrorMethods) {
                      deleteErrorMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
                    }
                    return { status: false };
                  });
                });
              } else {
                if (isActiveMsg) {
                  if (index_esm.VxeUI.modal) {
                    index_esm.VxeUI.modal.message({ id: code, content: getI18n("vxe.grid.selectOneRecord"), status: "warning" });
                  }
                }
              }
            } else {
              log.errLog("vxe.error.notFunc", ["[grid] proxy-config.ajax.delete"]);
            }
            break;
          }
          case "save": {
            const ajaxMethods = ajax.save;
            const saveSuccessMethods = ajax.saveSuccess;
            const saveErrorMethods = ajax.saveError;
            if (ajaxMethods) {
              const body = $xeTable.getRecordset();
              const { insertRecords, removeRecords, updateRecords, pendingRecords } = body;
              const commitParams = {
                $table: $xeTable,
                $grid: $xeGrid,
                $gantt: null,
                code,
                button,
                body,
                form: formData,
                options: ajaxMethods
              };
              if (insertRecords.length) {
                body.pendingRecords = pendingRecords.filter((row) => $xeTable.findRowIndexOf(insertRecords, row) === -1);
              }
              if (pendingRecords.length) {
                body.insertRecords = insertRecords.filter((row) => $xeTable.findRowIndexOf(pendingRecords, row) === -1);
              }
              let restPromise = Promise.resolve();
              if (editRules) {
                restPromise = $xeTable[validConfig && validConfig.msgMode === "full" ? "fullValidate" : "validate"](body.insertRecords.concat(updateRecords));
              }
              return restPromise.then((errMap) => {
                if (errMap) {
                  return;
                }
                if (body.insertRecords.length || removeRecords.length || updateRecords.length || body.pendingRecords.length) {
                  reactData.tableLoading = true;
                  return Promise.resolve((beforeSave || ajaxMethods)(commitParams, ...args)).then((rest) => {
                    reactData.tableLoading = false;
                    $xeTable.clearPendingRow();
                    if (isRespMsg) {
                      if (index_esm.VxeUI.modal) {
                        index_esm.VxeUI.modal.message({ content: getRespMsg(rest, "vxe.grid.saveSuccess"), status: "success" });
                      }
                    }
                    if (afterSave) {
                      afterSave(commitParams, ...args);
                    } else {
                      internalData.uFoot = true;
                      $xeGrid.commitProxy("query");
                      internalData.uFoot = false;
                      updateQueryFooter();
                    }
                    if (saveSuccessMethods) {
                      saveSuccessMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
                    }
                    return { status: true };
                  }).catch((rest) => {
                    reactData.tableLoading = false;
                    if (isRespMsg) {
                      if (index_esm.VxeUI.modal) {
                        index_esm.VxeUI.modal.message({ id: code, content: getRespMsg(rest, "vxe.grid.operError"), status: "error" });
                      }
                    }
                    if (saveErrorMethods) {
                      saveErrorMethods(Object.assign(Object.assign({}, commitParams), { response: rest }));
                    }
                    return { status: false };
                  });
                } else {
                  if (isActiveMsg) {
                    if (index_esm.VxeUI.modal) {
                      index_esm.VxeUI.modal.message({ id: code, content: getI18n("vxe.grid.dataUnchanged"), status: "info" });
                    }
                  }
                }
              });
            } else {
              log.errLog("vxe.error.notFunc", ["[grid] proxy-config.ajax.save"]);
            }
            break;
          }
          default: {
            const gCommandOpts = commands.get(code);
            if (gCommandOpts) {
              const tCommandMethod = gCommandOpts.tableCommandMethod || gCommandOpts.commandMethod;
              if (tCommandMethod) {
                tCommandMethod({ code, button, $grid: $xeGrid, $table: $xeTable, $gantt: null }, ...args);
              } else {
                log.errLog("vxe.error.notCommands", [`[grid] ${code}`]);
              }
            }
          }
        }
        return vue.nextTick();
      },
      getParams() {
        return props2.params;
      },
      zoom() {
        if (reactData.isZMax) {
          return $xeGrid.revert();
        }
        return $xeGrid.maximize();
      },
      isMaximized() {
        return reactData.isZMax;
      },
      maximize() {
        return handleZoom(true);
      },
      revert() {
        return handleZoom();
      },
      getFormData,
      getFormItems(itemIndex) {
        const formOpts = computeFormOpts.value;
        const { formConfig } = props2;
        const { items } = formOpts;
        const itemList = [];
        XEUtils.eachTree(formConfig && utils.isEnableConf(formOpts) && items ? items : [], (item) => {
          itemList.push(item);
        }, { children: "children" });
        return XEUtils.isUndefined(itemIndex) ? itemList : itemList[itemIndex];
      },
      resetForm() {
        const $form = refForm.value;
        if ($form) {
          return $form.reset();
        }
        return vue.nextTick();
      },
      validateForm() {
        const $form = refForm.value;
        if ($form) {
          return $form.validate();
        }
        return vue.nextTick();
      },
      validateFormField(field) {
        const $form = refForm.value;
        if ($form) {
          return $form.validateField(field);
        }
        return vue.nextTick();
      },
      clearFormValidate(field) {
        const $form = refForm.value;
        if ($form) {
          return $form.clearValidate(field);
        }
        return vue.nextTick();
      },
      homePage() {
        const { tablePage } = reactData;
        tablePage.currentPage = 1;
        return vue.nextTick();
      },
      homePageByEvent(evnt) {
        const $pager = refPager.value;
        if ($pager) {
          $pager.homePageByEvent(evnt);
        }
      },
      endPage() {
        const { tablePage } = reactData;
        const pageCount = computePageCount.value;
        tablePage.currentPage = pageCount;
        return vue.nextTick();
      },
      endPageByEvent(evnt) {
        const $pager = refPager.value;
        if ($pager) {
          $pager.endPageByEvent(evnt);
        }
      },
      getCurrentPage() {
        const { tablePage } = reactData;
        return tablePage.currentPage;
      },
      setCurrentPage(currentPage) {
        const { tablePage } = reactData;
        const pageCount = computePageCount.value;
        tablePage.currentPage = Math.min(pageCount, Math.max(1, XEUtils.toNumber(currentPage)));
        return vue.nextTick();
      },
      setCurrentPageByEvent(evnt, currentPage) {
        const $pager = refPager.value;
        if ($pager) {
          $pager.setCurrentPageByEvent(evnt, currentPage);
        }
      },
      getPageSize() {
        const { tablePage } = reactData;
        return tablePage.pageSize;
      },
      setPageSize(pageSize) {
        const { tablePage } = reactData;
        tablePage.pageSize = Math.max(1, XEUtils.toNumber(pageSize));
        return vue.nextTick();
      },
      setPageSizeByEvent(evnt, pageSize) {
        const $pager = refPager.value;
        if ($pager) {
          $pager.setPageSizeByEvent(evnt, pageSize);
        }
      },
      getProxyInfo() {
        const $xeTable = refTable.value;
        if (props2.proxyConfig) {
          const { sortData } = reactData;
          return {
            data: $xeTable ? $xeTable.getFullData() : [],
            filter: reactData.filterData,
            form: getFormData(),
            sort: sortData.length ? sortData[0] : {},
            sorts: sortData,
            pager: reactData.tablePage,
            pendingRecords: $xeTable ? $xeTable.getPendingRecords() : []
          };
        }
        return null;
      }
      // setProxyInfo (options) {
      //   if (props.proxyConfig && options) {
      //     const { pager, form } = options
      //     const proxyOpts = computeProxyOpts.value
      //     if (pager) {
      //       if (pager.currentPage) {
      //         reactData.tablePage.currentPage = Number(pager.currentPage)
      //       }
      //       if (pager.pageSize) {
      //         reactData.tablePage.pageSize = Number(pager.pageSize)
      //       }
      //     }
      //     if (proxyOpts.form && form) {
      //       Object.assign(reactData.formData, form)
      //     }
      //   }
      //   return nextTick()
      // }
    };
    const gridPrivateMethods = {
      extendTableMethods,
      callSlot(slotFunc, params) {
        if (slotFunc) {
          if (XEUtils.isString(slotFunc)) {
            slotFunc = slots[slotFunc] || null;
          }
          if (XEUtils.isFunction(slotFunc)) {
            return vn.getSlotVNs(slotFunc(params));
          }
        }
        return [];
      },
      /**
       * 获取需要排除的高度
       */
      getExcludeHeight() {
        const { height } = props2;
        const { isZMax } = reactData;
        const el = refElem.value;
        if (el) {
          const formWrapper = refFormWrapper.value;
          const toolbarWrapper = refToolbarWrapper.value;
          const topWrapper = refTopWrapper.value;
          const bottomWrapper = refBottomWrapper.value;
          const pagerWrapper = refPagerWrapper.value;
          const parentEl = el.parentElement;
          let parentPaddingSize = 0;
          if (parentEl && (height === "100%" || height === "auto")) {
            parentPaddingSize = isZMax ? 0 : dom.getPaddingTopBottomSize(parentEl);
          }
          return parentPaddingSize + dom.getPaddingTopBottomSize(el) + dom.getOffsetHeight(formWrapper) + dom.getOffsetHeight(toolbarWrapper) + dom.getOffsetHeight(topWrapper) + dom.getOffsetHeight(bottomWrapper) + dom.getOffsetHeight(pagerWrapper);
        }
        return 0;
      },
      getParentHeight() {
        const el = refElem.value;
        if (el) {
          const parentEl = el.parentElement;
          return (reactData.isZMax ? dom.getDomNode().visibleHeight : parentEl ? XEUtils.toNumber(getComputedStyle(parentEl).height) : 0) - gridPrivateMethods.getExcludeHeight();
        }
        return 0;
      },
      triggerToolbarCommitEvent(params, evnt) {
        const { code } = params;
        if (code) {
          const isUf = ["reload", "delete", "save"].includes(code);
          if (isUf) {
            internalData.uFoot = true;
          }
          const rest = $xeGrid.commitProxy(params, evnt).then((rest2) => {
            if (rest2 && rest2.status && ["query", "reload", "delete", "save"].includes(code)) {
              $xeGrid.dispatchEvent(code === "delete" || code === "save" ? `proxy-${code}` : "proxy-query", Object.assign(Object.assign({}, rest2), { isReload: code === "reload" }), evnt);
            }
          });
          internalData.uFoot = false;
          if (isUf) {
            updateQueryFooter();
          }
          return rest;
        }
        return vue.nextTick();
      },
      triggerToolbarBtnEvent(button, evnt) {
        $xeGrid.triggerToolbarCommitEvent(button, evnt);
        $xeGrid.dispatchEvent("toolbar-button-click", { code: button.code, button }, evnt);
      },
      triggerToolbarTolEvent(tool, evnt) {
        $xeGrid.triggerToolbarCommitEvent(tool, evnt);
        $xeGrid.dispatchEvent("toolbar-tool-click", { code: tool.code, tool }, evnt);
      },
      triggerZoomEvent(evnt) {
        $xeGrid.zoom();
        $xeGrid.dispatchEvent("zoom", { type: reactData.isZMax ? "max" : "revert" }, evnt);
      }
    };
    Object.assign($xeGrid, gridExtendTableMethods, gridMethods, gridPrivateMethods, {
      // 检查插槽
      loadColumn(columns) {
        const $xeTable = refTable.value;
        XEUtils.eachTree(columns, (column) => {
          if (column.slots) {
            XEUtils.each(column.slots, (func) => {
              if (!XEUtils.isFunction(func)) {
                if (!slots[func]) {
                  log.errLog("vxe.error.notSlot", [`[grid] ${func}`]);
                }
              }
            });
          }
        });
        if ($xeTable) {
          return $xeTable.loadColumn(columns);
        }
        return vue.nextTick();
      },
      reloadColumn(columns) {
        $xeGrid.clearAll();
        return $xeGrid.loadColumn(columns);
      }
    });
    const renderVN = () => {
      const vSize = computeSize.value;
      const styles = computeStyles.value;
      const isLoading = computeIsLoading.value;
      return vue.h("div", {
        ref: refElem,
        class: ["vxe-grid", {
          [`size--${vSize}`]: vSize,
          "is--animat": !!props2.animat,
          "is--round": props2.round,
          "is--maximize": reactData.isZMax,
          "is--loading": isLoading
        }],
        style: styles
      }, renderLayout());
    };
    const columnFlag = vue.ref(0);
    vue.watch(() => props2.columns ? props2.columns.length : -1, () => {
      columnFlag.value++;
    });
    vue.watch(() => props2.columns, () => {
      columnFlag.value++;
    });
    vue.watch(columnFlag, () => {
      vue.nextTick(() => $xeGrid.loadColumn(props2.columns || []));
    });
    vue.watch(() => props2.toolbarConfig, () => {
      initToolbar();
    });
    vue.watch(computeCustomCurrentPageFlag, () => {
      initPages("currentPage");
    });
    vue.watch(computeCustomPageSizeFlag, () => {
      initPages("pageSize");
    });
    vue.watch(computeCustomTotalFlag, () => {
      initPages("total");
    });
    vue.watch(() => props2.proxyConfig, () => {
      initProxy();
    });
    hooks.forEach((options) => {
      const { setupGrid } = options;
      if (setupGrid) {
        const hookRest = setupGrid($xeGrid);
        if (hookRest && XEUtils.isObject(hookRest)) {
          Object.assign($xeGrid, hookRest);
        }
      }
    });
    initPages();
    vue.onMounted(() => {
      vue.nextTick(() => {
        const { columns } = props2;
        const proxyOpts = computeProxyOpts.value;
        if (props2.formConfig) {
          if (!VxeUIFormComponent) {
            log.errLog("vxe.error.reqComp", ["vxe-form"]);
          }
        }
        if (props2.pagerConfig) {
          if (!VxeUIPagerComponent) {
            log.errLog("vxe.error.reqComp", ["vxe-pager"]);
          }
        }
        if (proxyOpts.props) {
          log.warnLog("vxe.error.delProp", ["[grid] proxy-config.props", "proxy-config.response"]);
        }
        if (columns && columns.length) {
          $xeGrid.loadColumn(columns);
        }
        initToolbar();
        initProxy();
      });
      globalEvents.on($xeGrid, "keydown", handleGlobalKeydownEvent);
    });
    vue.onUnmounted(() => {
      globalEvents.off($xeGrid, "keydown");
      XEUtils.assign(internalData, createInternalData());
    });
    $xeGrid.renderVN = renderVN;
    vue.provide("$xeGrid", $xeGrid);
    vue.provide("$xeGantt", null);
    return $xeGrid;
  },
  render() {
    return this.renderVN();
  }
});
exports.default = VxeGridComponent;
