UNPKG

vxe-table

Version:

A PC-end table component based on Vxe UI, supporting copy-paste, data pivot table, and high-performance virtual list table solution.

1,143 lines (1,142 loc) • 38.8 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var util_exports = {}; __export(util_exports, { assembleColumn: () => assembleColumn, clearTableAllStatus: () => clearTableAllStatus, clearTableDefaultStatus: () => clearTableDefaultStatus, colToVisible: () => colToVisible, convertHeaderColumnToRows: () => convertHeaderColumnToRows, convertHeaderToGridRows: () => convertHeaderToGridRows, createColumn: () => createColumn, createHandleGetRowId: () => createHandleGetRowId, createHandleUpdateRowId: () => createHandleUpdateRowId, createInternalData: () => createInternalData, createReactData: () => createReactData, createRowId: () => createRowId, destroyColumn: () => destroyColumn, encodeRowid: () => encodeRowid, getCalcHeight: () => getCalcHeight, getCellRestHeight: () => getCellRestHeight, getCellValue: () => getCellValue, getColReMaxWidth: () => getColReMaxWidth, getColReMinWidth: () => getColReMinWidth, getColumnList: () => getColumnList, getFirstChildColumn: () => getFirstChildColumn, getLastChildColumn: () => getLastChildColumn, getRefElem: () => getRefElem, getRootColumn: () => getRootColumn, getRowMaxHeight: () => getRowMaxHeight, getRowUniqueId: () => getRowUniqueId, getRowid: () => getRowid, getRowkey: () => getRowkey, handleCustomStoreConfig: () => handleCustomStoreConfig, handleFieldOrColumn: () => handleFieldOrColumn, handleRowidOrRow: () => handleRowidOrRow, hasDeepKey: () => hasDeepKey, isColumnInfo: () => isColumnInfo, restoreScrollLocation: () => restoreScrollLocation, rowToVisible: () => rowToVisible, setCellValue: () => setCellValue, toFilters: () => toFilters, toTreePathSeq: () => toTreePathSeq, watchColumn: () => watchColumn }); module.exports = __toCommonJS(util_exports); var import_vue = require("vue"); var import_xe_utils = __toESM(require("xe-utils")); var import_columnInfo = require("./columnInfo"); var import_dom = require("../../ui/src/dom"); var import_utils = require("../../ui/src/utils"); function createInternalData() { return { tZindex: 0, currKeyField: "", isCurrDeepKey: false, elemStore: {}, // 存放横向 X 虚拟滚动相关的信息 scrollXStore: { preloadSize: 0, offsetSize: 0, visibleSize: 0, visibleStartIndex: 0, visibleEndIndex: 0, startIndex: 0, endIndex: 0 }, // 存放纵向 Y 虚拟滚动相关信息 scrollYStore: { preloadSize: 0, offsetSize: 0, visibleSize: 0, visibleStartIndex: 0, visibleEndIndex: 0, startIndex: 0, endIndex: 0 }, // 表格宽度 tableWidth: 0, // 表格高度 tableHeight: 0, customHeight: 0, customMinHeight: 0, customMaxHeight: 0, // 当前 hover 行 hoverRow: null, hoverCol: null, // 当前行 currentRow: null, currentCol: null, // resizeObserver: undefined, // 滚动条 // scrollObserver: undefined, // isThumbDrag: false, thumbDragOffset: 0, yThumbTop: 0, xThumbLeft: 0, lastScrollTop: 0, lastScrollLeft: 0, // 单选框属性,已选中保留的行 radioReserveRow: null, // 复选框属性,已选中保留的行集合 checkboxReserveRowMap: {}, // 行数据,已展开保留的行集合 rowExpandedReserveRowMap: {}, // 树结构数据,已展开保留的行集合 treeExpandedReserveRowMap: {}, // 树结构数据,不确定状态的集合 treeIndeterminateRowMaps: {}, // 列表完整数据、条件处理后 tableFullData: [], afterFullData: [], afterTreeFullData: [], afterGroupFullData: [], // 列表条件处理后数据集合 afterFullRowMaps: {}, // 树结构完整数据、条件处理后 tableFullTreeData: [], // 行分组全量数据、条件处理后 tableFullGroupData: [], tableSynchData: [], tableSourceData: [], // 收集的列配置(带分组) collectColumn: [], // 完整所有列(不带分组) tableFullColumn: [], // 渲染所有列 visibleColumn: [], // 全量数据集(包括当前和已删除) fullAllDataRowIdData: {}, // 数据集(仅当前) fullDataRowIdData: {}, // 数据集(仅可视) visibleDataRowIdData: {}, keepUpdateFieldMaps: {}, headerFullDataColData: {}, footerFullDataRowData: {}, // 渲染中缓存数据 sourceDataRowIdData: {}, fullColumnIdData: {}, fullColumnFieldData: {}, fullCellHeightMaps: {}, fullCellStoreMaps: {}, // 合并表头单元格的数据 mergeHeaderList: [], mergeHeaderMaps: {}, // 已合并单元格数据集合 mergeHeaderCellMaps: {}, mergeHeaderRowMaps: {}, mergeHeaderColMaps: {}, // 合并单元格的数据 mergeBodyList: [], mergeBodyMaps: {}, // 已合并单元格数据集合 mergeBodyCellMaps: {}, mergeBodyRowMaps: {}, mergeBodyColMaps: {}, // 合并表尾的数据 mergeFooterList: [], mergeFooterMaps: {}, // 已合并表尾数据集合 mergeFooterCellMaps: {}, mergeFooterRowMaps: {}, mergeFooterColMaps: {}, // 已展开的行集合 rowExpandedMaps: {}, // 懒加载中的展开行的集合 rowExpandLazyLoadedMaps: {}, // 已展开的分组行 rowGroupExpandedMaps: {}, // 已展开树节点集合 treeExpandedMaps: {}, // 懒加载中的树节点的集合 treeExpandLazyLoadedMaps: {}, // 复选框属性,已选中的行集合 selectCheckboxMaps: {}, // 已标记的对象集 pendingRowMaps: {}, // 已新增的临时行 insertRowMaps: {}, // 已删除行 removeRowMaps: {}, cvCacheMaps: {}, // 表头高度 tHeaderHeight: 0, // 表体高度 tBodyHeight: 0, // 表尾高度 tFooterHeight: 0, stackHistoryStore: { undoStacks: [], redoStacks: [] }, teleportToWrapperElem: null, popupToWrapperElem: null, customPopupToElem: null, lastSTime: 0, // isCustomDragStatus: false, inited: false, tooltipTimeout: null, initStatus: false, isActivated: false, // keyCtxTimeout: undefined, // 刷新布局 // rceTimeout: undefined, // rceRunTime: undefined, rceDelay: 0 // rsePending: false, // 滚动属性 // intoRunScroll: false, // inVirtualScroll: false, // inWheelScroll: false, // inHeaderScroll: false, // inBodyScroll: false, // inFooterScroll: false, // scrollRenderType?: '', // isSyncGanttScrollTop: false, // 同步滚动 // lcsTimeout: undefined, // lcsRunTime: undefined, // 横向虚拟 // lxRunTime: undefined, // lxTimeout: undefined, // 纵向虚拟 // lyRunTime: undefined, // lyTimeout: undefined, // 动态高度 // chRunTime: undefined, // chTimeout: undefined, // isResizeCellHeight: false, // _sToTime: null }; } function createReactData() { return { updateColFlag: 0, // 低性能的静态列 staticColumns: [], // 渲染的列分组 tableGroupColumn: [], // 可视区渲染的列 tableColumn: [], // 渲染中的数据 tableData: [], // 是否启用了横向 X 可视渲染方式加载 scrollXLoad: false, // 是否启用了纵向 Y 可视渲染方式加载 scrollYLoad: false, // 是否存在纵向滚动条 overflowY: true, // 是否存在横向滚动条 overflowX: false, // 纵向滚动条的宽度 scrollbarWidth: 0, // 横向滚动条的高度 scrollbarHeight: 0, // 滚动条 yThumbHeight: 0, xThumbWidth: 0, // 行高 rowHeight: 0, // 表格父容器的高度 parentHeight: 0, // 是否使用分组表头 isGroup: false, isAllOverflow: false, // 复选框属性,是否全选 isAllSelected: false, // 复选框属性,有选中且非全选状态 isIndeterminate: false, // 单选框属性,选中行 selectRadioRow: null, // 表尾合计数据 footerTableData: [], // 行分组列信息 rowGroupColumn: null, // 展开列信息 expandColumn: null, checkboxColumn: null, radioColumn: null, // 树节点列信息 treeNodeColumn: null, hasFixedColumn: false, // 刷新列标识,当列筛选被改变时,触发表格刷新数据 upDataFlag: 0, // 刷新列标识,当列的特定属性被改变时,触发表格刷新列 reColumnFlag: 0, // 初始化标识 initStore: { filter: false, import: false, export: false, custom: false }, // 自定义列相关的信息 customStore: { btnEl: null, isAll: false, isIndeterminate: false, activeBtn: false, activeWrapper: false, visible: false, maxHeight: null, defPopupStyle: {}, panePopupStyle: {}, oldSortMaps: {}, oldFixedMaps: {}, oldVisibleMaps: {} }, customColumnList: [], // 当前选中的筛选列 filterStore: { targetEl: null, isAllSelected: false, isIndeterminate: false, style: null, column: null, visible: false }, // 存放列相关的信息 columnStore: { leftList: [], centerList: [], rightList: [], resizeList: [], pxList: [], pxMinList: [], autoMinList: [], scaleList: [], scaleMinList: [], autoList: [], remainList: [] }, // 存放快捷菜单的信息 ctxMenuStore: { selected: null, visible: false, showChild: false, selectChild: null, list: [], style: null }, // 存放可编辑相关信息 editStore: { indexs: { columns: [] }, titles: { columns: [] }, // 选中源 selected: { row: null, column: null }, // 已复制源 copyed: { cut: false, rows: [], columns: [] }, // 激活 actived: { row: null, column: null }, // 当前被强制聚焦单元格,只会在鼠标点击后算聚焦 focused: { row: null, column: null } }, // 存放 tooltip 相关信息 tooltipStore: { row: null, column: null, content: "", visible: false, type: null, currOpts: {} }, // 存放数据校验相关信息 validStore: { visible: false }, validErrorMaps: {}, // 导入相关信息 importStore: { inited: false, file: null, type: "", modeList: [], typeList: [], filename: "", visible: false }, importParams: { mode: "", types: null, message: true }, // 导出相关信息 exportStore: { inited: false, name: "", modeList: [], typeList: [], columns: [], isPrint: false, hasFooter: false, hasMerge: false, hasTree: false, hasRowGroup: false, hasColgroup: false, visible: false }, exportParams: { filename: "", sheetName: "", mode: "", type: "", isColgroup: false, isMerge: false, isTreeAllExpanded: false, isRowGroupAllExpanded: false, useStyle: false, original: false, message: true, isHeader: false, isTitle: false, isFooter: false }, visiblwRowsFlag: 1, isRowGroupStatus: false, rowGroupList: [], aggHandleFields: [], aggHandleAggColumns: [], rowGroupExpandedFlag: 1, rowExpandedFlag: 1, treeExpandedFlag: 1, updateCheckboxFlag: 1, pendingRowFlag: 1, insertRowFlag: 1, removeRowFlag: 1, mergeHeadFlag: 1, mergeBodyFlag: 1, mergeFootFlag: 1, rowHeightStore: { xlarge: 54, large: 52, default: 48, medium: 44, small: 40, mini: 36 }, scrollVMLoading: false, scrollYHeight: 0, scrollYTop: 0, isScrollYBig: false, scrollXLeft: 0, scrollXWidth: 0, isScrollXBig: false, lazScrollLoading: false, rowExpandHeightFlag: 1, calcCellHeightFlag: 1, resizeHeightFlag: 1, resizeWidthFlag: 1, isCustomStatus: false, isCustomDragStatus: true, ctPopupFlag: 1, isCrossDragRow: false, dragRow: null, isCrossDragCol: false, dragCol: null, dragTipText: "", isDragResize: false, isRowLoading: false, isColLoading: false, currColFlag: 1 }; } const maxKey = "__max"; function getRowMaxHeight(chRest, isForce) { if (isForce || !chRest[maxKey]) { let max = 0; for (const key in chRest) { const val = chRest[key]; if (key !== maxKey && import_xe_utils.default.isNumber(val) && val > max) { max = val; } } chRest[maxKey] = max; return max; } return chRest[maxKey]; } const getAllConvertColumns = (columns, parentColumn) => { const result = []; columns.forEach((column) => { column.parentId = parentColumn ? parentColumn.id : null; if (column.visible) { if (column.children && column.children.length && column.children.some((column2) => column2.visible)) { result.push(column); result.push(...getAllConvertColumns(column.children, column)); } else { result.push(column); } } }); return result; }; const convertHeaderColumnToRows = (originColumns) => { let maxLevel = 1; const traverse = (column, parent) => { if (parent) { column.level = parent.level + 1; if (maxLevel < column.level) { maxLevel = column.level; } } if (column.children && column.children.length && column.children.some((column2) => column2.visible)) { let colSpan = 0; column.children.forEach((subColumn) => { if (subColumn.visible) { traverse(subColumn, column); colSpan += subColumn.colSpan; } }); column.colSpan = colSpan; } else { column.colSpan = 1; } }; originColumns.forEach((column) => { column.level = 1; traverse(column); }); const rows = []; for (let i = 0; i < maxLevel; i++) { rows.push([]); } const allColumns = getAllConvertColumns(originColumns); allColumns.forEach((column) => { if (column.children && column.children.length && column.children.some((column2) => column2.visible)) { column.rowSpan = 1; } else { column.rowSpan = maxLevel - column.level + 1; } rows[column.level - 1].push(column); }); return rows; }; function convertHeaderToGridRows(spanColumns) { const rSize = spanColumns.length; const cSize = spanColumns[0].reduce((sum, cell) => sum + cell.colSpan, 0); const occupiedRows = []; const fullRows = []; for (let rIndex = 0; rIndex < rSize; rIndex++) { const oCols = []; const dCols = []; for (let cIndex = 0; cIndex < cSize; cIndex++) { oCols.push(false); dCols.push(""); } occupiedRows.push(oCols); fullRows.push(dCols); } for (let rIndex = 0; rIndex < rSize; rIndex++) { let currColIndex = 0; for (const column of spanColumns[rIndex]) { const { colSpan, rowSpan } = column; let startColIndex = -1; for (let ccIndex = currColIndex; ccIndex <= cSize - colSpan; ccIndex++) { let oFlag = true; for (let csIndex = 0; csIndex < colSpan; csIndex++) { if (occupiedRows[rIndex][ccIndex + csIndex]) { oFlag = false; break; } } if (oFlag) { startColIndex = ccIndex; break; } } if (startColIndex === -1) { for (let j = 0; j <= cSize - colSpan; j++) { let oFlag = true; for (let k = 0; k < colSpan; k++) { if (occupiedRows[rIndex][j + k]) { oFlag = false; break; } } if (oFlag) { startColIndex = j; break; } } if (startColIndex === -1) { break; } } for (let srIndex = rIndex; srIndex < rIndex + rowSpan; srIndex++) { for (let scIndex = startColIndex; scIndex < startColIndex + colSpan; scIndex++) { occupiedRows[srIndex][scIndex] = true; fullRows[srIndex][scIndex] = column; } } currColIndex = startColIndex + colSpan; } } return fullRows; } function restoreScrollLocation($xeTable, scrollLeft, scrollTop) { const internalData = $xeTable.internalData; if (scrollLeft || scrollTop) { internalData.intoRunScroll = false; internalData.inVirtualScroll = false; internalData.inWheelScroll = false; internalData.inHeaderScroll = false; internalData.inBodyScroll = false; internalData.inFooterScroll = false; internalData.scrollRenderType = ""; return $xeTable.scrollTo(scrollLeft, scrollTop); } return $xeTable.clearScroll(); } function getRowUniqueId() { return import_xe_utils.default.uniqueId("row_"); } function createRowId(rowOpts, row, keyField) { const { createKeyMethod } = rowOpts; if (createKeyMethod) { return createKeyMethod({ row, keyField }); } return getRowUniqueId(); } function hasDeepKey(rowKey) { return rowKey.indexOf(".") > -1; } function getRowkey($xeTable) { const { currKeyField } = $xeTable.internalData; return currKeyField; } function getRowid($xeTable, row) { const internalData = $xeTable.internalData; const { isCurrDeepKey, currKeyField } = internalData; return row ? encodeRowid((isCurrDeepKey ? getDeepRowIdByKey : getFastRowIdByKey)(row, currKeyField)) : ""; } function createHandleUpdateRowId($xeTable) { const internalData = $xeTable.internalData; const { isCurrDeepKey, currKeyField } = internalData; const { computeRowOpts } = $xeTable.getComputeMaps(); const rowOpts = computeRowOpts.value; const updateRId = isCurrDeepKey ? updateDeepRowKey : updateFastRowKey; return { rowKey: currKeyField, handleUpdateRowId(row) { return row ? updateRId(rowOpts, row, currKeyField) : ""; } }; } function createHandleGetRowId($xeTable) { const internalData = $xeTable.internalData; const { isCurrDeepKey, currKeyField } = internalData; const getRId = isCurrDeepKey ? getDeepRowIdByKey : getFastRowIdByKey; return { rowKey: currKeyField, handleGetRowId(row) { return row ? encodeRowid(getRId(row, currKeyField)) : ""; } }; } function encodeRowid(rowVal) { return import_xe_utils.default.eqNull(rowVal) ? "" : encodeURIComponent(rowVal); } function getDeepRowIdByKey(row, rowKey) { return import_xe_utils.default.get(row, rowKey); } function updateDeepRowKey(rowOpts, row, rowKey) { let rowid = encodeRowid(getDeepRowIdByKey(row, rowKey)); if ((0, import_utils.eqEmptyValue)(rowid)) { const newRowid = createRowId(rowOpts, row, rowKey); rowid = "" + newRowid; import_xe_utils.default.set(row, rowKey, rowid); } return rowid; } function getFastRowIdByKey(row, rowKey) { return row[rowKey]; } function updateFastRowKey(rowOpts, row, rowKey) { let rowid = encodeRowid(getFastRowIdByKey(row, rowKey)); if ((0, import_utils.eqEmptyValue)(rowid)) { const newRowid = createRowId(rowOpts, row, rowKey); rowid = "" + newRowid; row[rowKey] = newRowid; } return rowid; } function handleFieldOrColumn($xeTable, fieldOrColumn) { if (fieldOrColumn) { return import_xe_utils.default.isString(fieldOrColumn) || import_xe_utils.default.isNumber(fieldOrColumn) ? $xeTable.getColumnByField(`${fieldOrColumn}`) : fieldOrColumn; } return null; } function handleRowidOrRow($xeTable, rowidOrRow) { if (rowidOrRow) { const rowid = import_xe_utils.default.isString(rowidOrRow) || import_xe_utils.default.isNumber(rowidOrRow) ? rowidOrRow : getRowid($xeTable, rowidOrRow); return $xeTable.getRowById(rowid); } return null; } function getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight) { const { height, minHeight, maxHeight } = cellOpts; let cellHeight = rowRest.resizeHeight || height || rowOpts.height || rowRest.height || defaultRowHeight; if (maxHeight && maxHeight <= cellHeight) { cellHeight = maxHeight; } if (minHeight && minHeight >= cellHeight) { cellHeight = minHeight; } return cellHeight; } function getPaddingLeftRightSize(elem) { if (elem) { const computedStyle = getComputedStyle(elem); const paddingLeft = import_xe_utils.default.toNumber(computedStyle.paddingLeft); const paddingRight = import_xe_utils.default.toNumber(computedStyle.paddingRight); return paddingLeft + paddingRight; } return 0; } function getElementMarginAndWidth(elem) { if (elem) { const computedStyle = getComputedStyle(elem); const marginLeft = import_xe_utils.default.toNumber(computedStyle.marginLeft); const marginRight = import_xe_utils.default.toNumber(computedStyle.marginRight); return elem.offsetWidth + marginLeft + marginRight; } return 0; } function toFilters(filters, colid) { if (filters) { if (import_xe_utils.default.isArray(filters)) { return filters.map(({ label, value, data, resetValue, checked }) => { return { label, value, data, resetValue, checked: !!checked, _checked: !!checked, _colId: colid }; }); } return []; } return filters; } function toTreePathSeq(path) { return path.map((num, i) => i % 2 === 0 ? Number(num) + 1 : ".").join(""); } function getCellValue(row, column) { if (column) { return import_xe_utils.default.get(row, column.field); } return null; } function setCellValue(row, column, value) { if (column) { import_xe_utils.default.set(row, column.field, value); } } function getRefElem(refEl) { if (refEl) { const rest = refEl.value; if (rest) { return rest.$el || rest; } } return null; } function getCalcHeight(height) { if (height === "unset") { return 0; } return height || 0; } function getColReMaxWidth(params) { const { $table, column, cell } = params; const internalData = $table.internalData; const { elemStore } = internalData; const { computeColumnOpts, computeResizableOpts } = $table.getComputeMaps(); const resizableOpts = computeResizableOpts.value; const columnOpts = computeColumnOpts.value; const { maxWidth: reMaxWidth } = resizableOpts; const colMaxWidth = column.maxWidth || columnOpts.maxWidth; if (reMaxWidth) { const customMaxWidth = import_xe_utils.default.isFunction(reMaxWidth) ? reMaxWidth(params) : reMaxWidth; if (customMaxWidth !== "auto") { return Math.max(1, import_xe_utils.default.toNumber(customMaxWidth)); } } const minTitleWidth = import_xe_utils.default.floor((import_xe_utils.default.toNumber(getComputedStyle(cell).fontSize) || 14) * 1.8); const paddingLeftRight = getPaddingLeftRightSize(cell) + getPaddingLeftRightSize((0, import_dom.queryElement)(cell, ".vxe-cell")); const mWidth = minTitleWidth + paddingLeftRight; if (colMaxWidth) { const bodyScrollElem = getRefElem(elemStore["main-body-scroll"]); if (bodyScrollElem) { if ((0, import_dom.isScale)(colMaxWidth)) { const bodyWidth = bodyScrollElem.clientWidth - 1; const meanWidth = bodyWidth / 100; return Math.max(mWidth, Math.floor(import_xe_utils.default.toInteger(colMaxWidth) * meanWidth)); } else if ((0, import_dom.isPx)(colMaxWidth)) { return Math.max(mWidth, import_xe_utils.default.toInteger(colMaxWidth)); } } } return -1; } function getColReMinWidth(params) { const { $table, column, cell } = params; const tableProps = $table.props; const internalData = $table.internalData; const { computeColumnOpts, computeResizableOpts } = $table.getComputeMaps(); const resizableOpts = computeResizableOpts.value; const columnOpts = computeColumnOpts.value; const { minWidth: reMinWidth } = resizableOpts; if (reMinWidth) { const customMinWidth = import_xe_utils.default.isFunction(reMinWidth) ? reMinWidth(params) : reMinWidth; if (customMinWidth !== "auto") { return Math.max(1, import_xe_utils.default.toNumber(customMinWidth)); } } const { elemStore } = internalData; const { showHeaderOverflow: allColumnHeaderOverflow } = tableProps; const { showHeaderOverflow } = column; const colMinWidth = column.minWidth || columnOpts.minWidth; const headOverflow = import_xe_utils.default.isUndefined(showHeaderOverflow) || import_xe_utils.default.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow; const showEllipsis = headOverflow === "ellipsis"; const showTitle = headOverflow === "title"; const showTooltip = headOverflow === true || headOverflow === "tooltip"; const hasEllipsis = showTitle || showTooltip || showEllipsis; const minTitleWidth = import_xe_utils.default.floor((import_xe_utils.default.toNumber(getComputedStyle(cell).fontSize) || 14) * 1.8); const paddingLeftRight = getPaddingLeftRightSize(cell) + getPaddingLeftRightSize((0, import_dom.queryElement)(cell, ".vxe-cell")); let mWidth = minTitleWidth + paddingLeftRight; if (hasEllipsis) { const dragIconWidth = getElementMarginAndWidth((0, import_dom.queryElement)(cell, ".vxe-cell--drag-handle")); const checkboxIconWidth = getElementMarginAndWidth((0, import_dom.queryElement)(cell, ".vxe-cell--checkbox")); const requiredIconWidth = getElementMarginAndWidth((0, import_dom.queryElement)(cell, ".vxe-cell--required-icon")); const editIconWidth = getElementMarginAndWidth((0, import_dom.queryElement)(cell, ".vxe-cell--edit-icon")); const prefixIconWidth = getElementMarginAndWidth((0, import_dom.queryElement)(cell, ".vxe-cell-title-prefix-icon")); const suffixIconWidth = getElementMarginAndWidth((0, import_dom.queryElement)(cell, ".vxe-cell-title-suffix-icon")); const sortIconWidth = getElementMarginAndWidth((0, import_dom.queryElement)(cell, ".vxe-cell--sort")); const filterIconWidth = getElementMarginAndWidth((0, import_dom.queryElement)(cell, ".vxe-cell--filter")); mWidth += dragIconWidth + checkboxIconWidth + requiredIconWidth + editIconWidth + prefixIconWidth + suffixIconWidth + filterIconWidth + sortIconWidth; } if (colMinWidth) { const bodyScrollElem = getRefElem(elemStore["main-body-scroll"]); if (bodyScrollElem) { if ((0, import_dom.isScale)(colMinWidth)) { const bodyWidth = bodyScrollElem.clientWidth - 1; const meanWidth = bodyWidth / 100; return Math.max(mWidth, Math.floor(import_xe_utils.default.toInteger(colMinWidth) * meanWidth)); } else if ((0, import_dom.isPx)(colMinWidth)) { return Math.max(mWidth, import_xe_utils.default.toInteger(colMinWidth)); } } } return mWidth; } function isColumnInfo(column) { return column && (column.constructor === import_columnInfo.ColumnInfo || column instanceof import_columnInfo.ColumnInfo); } function getColumnList(columns) { const result = []; columns.forEach((column) => { result.push(...column.children && column.children.length ? getColumnList(column.children) : [column]); }); return result; } function createColumn($xeTable, options, renderOptions) { return isColumnInfo(options) ? options : (0, import_vue.reactive)(new import_columnInfo.ColumnInfo($xeTable, options, renderOptions)); } function watchColumn($xeTable, props, column) { Object.keys(props).forEach((name) => { (0, import_vue.watch)( () => props[name], (value) => { column.update(name, value); if ($xeTable) { if (name === "filters") { $xeTable.setFilter(column, value); $xeTable.handleUpdateDataQueue(); } else if (["visible", "fixed", "width", "minWidth", "maxWidth"].includes(name)) { $xeTable.handleRefreshColumnQueue(); } } } ); }); } function assembleColumn($xeTable, elem, column, colgroup) { const { reactData } = $xeTable; const { staticColumns } = reactData; const parentElem = elem.parentNode; const parentColumn = colgroup ? colgroup.columnConfig : null; const parentCols = parentColumn ? parentColumn.children : staticColumns; if (parentElem && parentCols) { column.defaultParentId = parentColumn ? parentColumn.id : null; parentCols.splice(import_xe_utils.default.arrayIndexOf(parentElem.children, elem), 0, column); reactData.staticColumns = staticColumns.slice(0); } } function destroyColumn($xeTable, column) { const { reactData } = $xeTable; const { staticColumns } = reactData; const matchObj = import_xe_utils.default.findTree(staticColumns, (item) => item.id === column.id, { children: "children" }); if (matchObj) { matchObj.items.splice(matchObj.index, 1); } reactData.staticColumns = staticColumns.slice(0); } function getRootColumn($xeTable, column) { const { internalData } = $xeTable; const { fullColumnIdData } = internalData; if (!column) { return null; } let parentColId = column.parentId; while (fullColumnIdData[parentColId]) { const column2 = fullColumnIdData[parentColId].column; parentColId = column2.parentId; if (!parentColId) { return column2; } } return column; } function getFirstChildColumn(column) { const { children } = column; if (children && children.length) { return getFirstChildColumn(import_xe_utils.default.first(children)); } return column; } function getLastChildColumn(column) { const { children } = column; if (children && children.length) { return getFirstChildColumn(import_xe_utils.default.last(children)); } return column; } function clearTableDefaultStatus($xeTable) { const { props, internalData } = $xeTable; const { keyboardConfig, mouseConfig } = props; const { computeMouseOpts, computeKeyboardOpts } = $xeTable.getComputeMaps(); const mouseOpts = computeMouseOpts.value; const keyboardOpts = computeKeyboardOpts.value; internalData.initStatus = false; const actionList = [ $xeTable.clearSort(), $xeTable.clearCurrentRow(), $xeTable.clearCurrentColumn(), $xeTable.clearRadioRow(), $xeTable.clearRadioReserve(), $xeTable.clearCheckboxRow(), $xeTable.clearCheckboxReserve(), $xeTable.clearRowExpand(), $xeTable.clearTreeExpand(), $xeTable.clearTreeExpandReserve(), $xeTable.clearPendingRow() ]; if ($xeTable.clearFilter) { actionList.push($xeTable.clearFilter()); } if ($xeTable.clearSelected && ((0, import_utils.hasEnableConf)(keyboardConfig, keyboardOpts) || (0, import_utils.hasEnableConf)(mouseConfig, mouseOpts))) { actionList.push($xeTable.clearSelected()); } if ($xeTable.clearCellAreas && (0, import_utils.hasEnableConf)(mouseConfig, mouseOpts)) { actionList.push($xeTable.clearCellAreas(), $xeTable.clearCopyCellArea()); } return Promise.all(actionList).then(() => { return $xeTable.clearScroll(); }); } function clearTableAllStatus($xeTable) { if ($xeTable.clearFilter) { $xeTable.clearFilter(); } return clearTableDefaultStatus($xeTable); } function rowToVisible($xeTable, row) { const reactData = $xeTable.reactData; const internalData = $xeTable.internalData; const { computeLeftFixedWidth, computeRightFixedWidth, computeRowOpts, computeCellOpts, computeDefaultRowHeight } = $xeTable.getComputeMaps(); const { scrollYLoad, scrollYTop, isAllOverflow } = reactData; const { elemStore, afterFullData, fullAllDataRowIdData, isResizeCellHeight } = internalData; const rowOpts = computeRowOpts.value; const cellOpts = computeCellOpts.value; const defaultRowHeight = computeDefaultRowHeight.value; const leftFixedWidth = computeLeftFixedWidth.value; const rightFixedWidth = computeRightFixedWidth.value; const bodyScrollElem = getRefElem(elemStore["main-body-scroll"]); const rowid = getRowid($xeTable, row); if (bodyScrollElem) { const bodyHeight = bodyScrollElem.clientHeight; const bodyScrollTop = bodyScrollElem.scrollTop; const trElem = bodyScrollElem.querySelector(`[rowid="${rowid}"]`); if (trElem) { const trOffsetTop = trElem.offsetTop + (scrollYLoad ? scrollYTop : 0); const trHeight = trElem.clientHeight; if (trOffsetTop < bodyScrollTop || trOffsetTop > bodyScrollTop + bodyHeight) { return $xeTable.scrollTo(null, trOffsetTop); } else if (trOffsetTop + trHeight >= bodyHeight + bodyScrollTop) { return $xeTable.scrollTo(null, bodyScrollTop + trHeight); } } else { if (scrollYLoad) { const isCustomCellHeight = isResizeCellHeight || cellOpts.height || rowOpts.height; if (!isCustomCellHeight && isAllOverflow) { return $xeTable.scrollTo(null, ($xeTable.findRowIndexOf(afterFullData, row) - 1) * defaultRowHeight); } const rowRest = fullAllDataRowIdData[rowid] || {}; const rHeight = rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight; const scrollTop = rowRest.oTop; if (scrollTop < bodyScrollTop) { return $xeTable.scrollTo(null, scrollTop - leftFixedWidth - 1); } return $xeTable.scrollTo(null, scrollTop + rHeight - (bodyHeight - rightFixedWidth - 1)); } } } return Promise.resolve(); } function colToVisible($xeTable, isForce, column, row) { const reactData = $xeTable.reactData; const internalData = $xeTable.internalData; const { computeLeftFixedWidth, computeRightFixedWidth } = $xeTable.getComputeMaps(); const { scrollXLoad, scrollXLeft } = reactData; const { elemStore, visibleColumn } = internalData; const leftFixedWidth = computeLeftFixedWidth.value; const rightFixedWidth = computeRightFixedWidth.value; const bodyScrollElem = getRefElem(elemStore["main-body-scroll"]); if (column.fixed) { return Promise.resolve(); } if (bodyScrollElem) { const bodyWidth = bodyScrollElem.clientWidth; const bodyScrollLeft = bodyScrollElem.scrollLeft; let tdElem = null; if (row) { const rowid = getRowid($xeTable, row); tdElem = bodyScrollElem.querySelector(`[rowid="${rowid}"] .${column.id}`); } if (!tdElem) { tdElem = bodyScrollElem.querySelector(`.${column.id}`); } if (tdElem) { const tdOffsetLeft = tdElem.offsetLeft + (scrollXLoad ? scrollXLeft : 0); const cellWidth = tdElem.clientWidth; if (isForce || !(tdOffsetLeft <= bodyScrollLeft + leftFixedWidth && tdOffsetLeft + cellWidth > bodyScrollLeft + leftFixedWidth) && !(tdOffsetLeft >= bodyScrollLeft + leftFixedWidth && tdOffsetLeft < bodyScrollLeft + bodyWidth - rightFixedWidth)) { if (tdOffsetLeft < bodyScrollLeft + leftFixedWidth) { return $xeTable.scrollTo(tdOffsetLeft - leftFixedWidth - 1); } else if (tdOffsetLeft + cellWidth - bodyScrollLeft > bodyWidth - rightFixedWidth) { return $xeTable.scrollTo(tdOffsetLeft + cellWidth - (bodyWidth - rightFixedWidth - 1)); } } } else { if (scrollXLoad) { let tdOffsetLeft = 0; const cellWidth = column.renderWidth; for (let i = 0; i < visibleColumn.length; i++) { const currCol = visibleColumn[i]; if (currCol === column || currCol.id === column.id) { break; } tdOffsetLeft += currCol.renderWidth; } if (isForce || !(tdOffsetLeft <= bodyScrollLeft + leftFixedWidth && tdOffsetLeft + cellWidth > bodyScrollLeft + leftFixedWidth) && !(tdOffsetLeft >= bodyScrollLeft + leftFixedWidth && tdOffsetLeft < bodyScrollLeft + bodyWidth - rightFixedWidth)) { if (tdOffsetLeft < bodyScrollLeft) { return $xeTable.scrollTo(tdOffsetLeft - leftFixedWidth - 1); } return $xeTable.scrollTo(tdOffsetLeft + cellWidth - (bodyWidth - rightFixedWidth - 1)); } } } } return Promise.resolve(); } function hangleBolleanDefaultValue(currVal, defVal) { return import_xe_utils.default.isBoolean(currVal) ? currVal : defVal; } function handleCustomStoreConfig($xeTable) { const { computeCustomOpts } = $xeTable.getComputeMaps(); const customOpts = computeCustomOpts.value; const { storage, storeOptions } = customOpts; const isAllCustom = storage === true; const storageOpts = Object.assign({}, isAllCustom ? {} : storage || {}, storeOptions); const isCustomAlign = hangleBolleanDefaultValue(storageOpts.align, isAllCustom); const isCustomHeaderAlign = hangleBolleanDefaultValue(storageOpts.headerAlign, isAllCustom); const isCustomFooterAlign = hangleBolleanDefaultValue(storageOpts.footerAlign, isAllCustom); const isCustomResizable = hangleBolleanDefaultValue(storageOpts.resizable, isAllCustom); const isCustomVisible = hangleBolleanDefaultValue(storageOpts.visible, isAllCustom); const isCustomFixed = hangleBolleanDefaultValue(storageOpts.fixed, isAllCustom); const isCustomSort = hangleBolleanDefaultValue(storageOpts.sort, isAllCustom); const isCustomAggGroup = hangleBolleanDefaultValue(storageOpts.aggGroup, isAllCustom); const isCustomAggFunc = hangleBolleanDefaultValue(storageOpts.aggFunc, isAllCustom); const isCustomPager = hangleBolleanDefaultValue(storageOpts.pager, isAllCustom); return { isCustomAlign, isCustomHeaderAlign, isCustomFooterAlign, isCustomResizable, isCustomVisible, isCustomFixed, isCustomSort, isCustomAggGroup, isCustomAggFunc, isCustomPager }; }