tomtaw-vxe-table 3.25.2 → 3.25.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/style.css +1 -1
- package/es/table/src/body.js +5 -7
- package/es/table/src/expand-height.js +108 -0
- package/es/table/src/methods.js +65 -18
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/index.umd.js +336 -21
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/src/body.js +3 -7
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/expand-height.js +118 -0
- package/lib/table/src/expand-height.min.js +1 -0
- package/lib/table/src/methods.js +13 -10
- package/lib/table/src/methods.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +2 -2
- package/packages/table/src/body.ts +5 -7
- package/packages/table/src/expand-height.ts +108 -0
- package/packages/table/src/methods.ts +66 -18
- package/types/all.d.ts +13 -0
- /package/es/{iconfont.1791960929606.ttf → iconfont.1792027709716.ttf} +0 -0
- /package/es/{iconfont.1791960929606.woff → iconfont.1792027709716.woff} +0 -0
- /package/es/{iconfont.1791960929606.woff2 → iconfont.1792027709716.woff2} +0 -0
- /package/lib/{iconfont.1791960929606.ttf → iconfont.1792027709716.ttf} +0 -0
- /package/lib/{iconfont.1791960929606.woff → iconfont.1792027709716.woff} +0 -0
- /package/lib/{iconfont.1791960929606.woff2 → iconfont.1792027709716.woff2} +0 -0
package/lib/ui/index.js
CHANGED
|
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "VxeUI", {
|
|
|
13
13
|
exports.version = exports.validators = exports.use = exports.t = exports.setup = exports.setTheme = exports.setLanguage = exports.setIcon = exports.setI18n = exports.setConfig = exports.saveFile = exports.renderer = exports.readFile = exports.print = exports.modal = exports.menus = exports.log = exports.interceptor = exports.globalResize = exports.globalEvents = exports.getTheme = exports.getIcon = exports.getI18n = exports.getConfig = exports.formats = exports.default = exports.config = exports.commands = exports.clipboard = exports._t = void 0;
|
|
14
14
|
var _core = require("@vxe-ui/core");
|
|
15
15
|
var _utils = require("./src/utils");
|
|
16
|
-
const version = exports.version = "3.25.
|
|
16
|
+
const version = exports.version = "3.25.4";
|
|
17
17
|
_core.VxeUI.version = version;
|
|
18
18
|
_core.VxeUI.tableVersion = version;
|
|
19
19
|
_core.VxeUI.setConfig({
|
package/lib/ui/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.VXETable=void 0,Object.defineProperty(exports,"VxeUI",{enumerable:!0,get:function(){return _core.VxeUI}}),exports.version=exports.validators=exports.use=exports.t=exports.setup=exports.setTheme=exports.setLanguage=exports.setIcon=exports.setI18n=exports.setConfig=exports.saveFile=exports.renderer=exports.readFile=exports.print=exports.modal=exports.menus=exports.log=exports.interceptor=exports.globalResize=exports.globalEvents=exports.getTheme=exports.getIcon=exports.getI18n=exports.getConfig=exports.formats=exports.default=exports.config=exports.commands=exports.clipboard=exports._t=void 0;var _core=require("@vxe-ui/core"),_utils=require("./src/utils");let version=exports.version="3.25.
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.VXETable=void 0,Object.defineProperty(exports,"VxeUI",{enumerable:!0,get:function(){return _core.VxeUI}}),exports.version=exports.validators=exports.use=exports.t=exports.setup=exports.setTheme=exports.setLanguage=exports.setIcon=exports.setI18n=exports.setConfig=exports.saveFile=exports.renderer=exports.readFile=exports.print=exports.modal=exports.menus=exports.log=exports.interceptor=exports.globalResize=exports.globalEvents=exports.getTheme=exports.getIcon=exports.getI18n=exports.getConfig=exports.formats=exports.default=exports.config=exports.commands=exports.clipboard=exports._t=void 0;var _core=require("@vxe-ui/core"),_utils=require("./src/utils");let version=exports.version="3.25.4",iconPrefix=(_core.VxeUI.version=version,_core.VxeUI.tableVersion=version,_core.VxeUI.setConfig({emptyCell:" ",table:{fit:!0,showHeader:!0,animat:!0,delayHover:250,autoResize:!0,padding:!0,resizeConfig:{},resizableConfig:{dragMode:"auto",showDragTip:!0,isSyncAutoHeight:!0,isSyncAutoWidth:!0,minHeight:18},currentRowConfig:{strict:!0},currentColumnConfig:{strict:!0},radioConfig:{strict:!0},rowDragConfig:{showIcon:!0,animation:!0,showGuidesStatus:!0,showDragTip:!0},columnDragConfig:{showIcon:!0,animation:!0,showGuidesStatus:!0,showDragTip:!0},checkboxConfig:{strict:!0},tooltipConfig:{mode:"tooltip",enterable:!0,defaultPlacement:"top"},headerTooltipConfig:{mode:"tooltip",enterable:!0},footerTooltipConfig:{mode:"tooltip",enterable:!0},validConfig:{showErrorMessage:!0,autoClear:!0,autoPos:!0,message:"inline",msgMode:"single",theme:"beautify"},columnConfig:{autoOptions:{isCalcHeader:!0,isCalcBody:!0,isCalcFooter:!0},maxFixedSize:4},cellConfig:{padding:!0},headerCellConfig:{height:"unset"},footerCellConfig:{height:"unset"},menuConfig:{destroyOnClose:!0},customConfig:{allowVisible:!0,allowResizable:!0,allowFixed:!0,allowSort:!0,allowAlign:!0,showSortDragButton:!0,showFooter:!0,placement:"top-right",storeOptions:{visible:!0,resizable:!0,sort:!0,fixed:!0,align:!0,headerAlign:!0,footerAlign:!0,aggFunc:!0},modalOptions:{showMaximize:!0,mask:!0,lockView:!0,resize:!0,escClosable:!0},drawerOptions:{mask:!0,lockView:!0,escClosable:!0,resize:!0}},sortConfig:{showIcon:!0,allowClear:!0,allowBtn:!0,iconLayout:"vertical"},filterConfig:{destroyOnClose:!0,multiple:!0,showIcon:!0,maxHeight:280},floatingFilterConfig:{},aggregateConfig:{padding:!0,placement:"left",rowField:"id",parentField:"_X_ROW_PARENT_KEY",childrenField:"_X_ROW_CHILDREN",mapChildrenField:"_X_ROW_CHILD_LIST",indent:20,showIcon:!0,maxGroupSize:4,showAggFuncTitle:!0},treeConfig:{padding:!0,rowField:"id",parentField:"parentId",childrenField:"children",hasChildField:"hasChild",mapChildrenField:"_X_ROW_CHILD",indent:20,showIcon:!0,showRootLine:!0},expandConfig:{showIcon:!0,mode:"fixed"},editConfig:{showIcon:!0,showAsterisk:!0,autoFocus:!0,isReuseKeep:!0},importConfig:{_typeMaps:{csv:1,html:1,xml:1,txt:1}},exportConfig:{_typeMaps:{csv:1,html:1,xml:1,txt:1}},printConfig:{},mouseConfig:{extension:!0},keyboardConfig:{isAll:!0,isEsc:!0},areaConfig:{autoClear:!0,selectCellByHeader:!0,selectCellByBody:!0,extendDirection:{top:!0,left:!0,bottom:!0,right:!0}},clipConfig:{isCopy:!0,isCut:!0,isPaste:!0},fnrConfig:{isFind:!0,isReplace:!0},virtualXConfig:{gt:24,preSize:0,oSize:0},virtualYConfig:{gt:100,preSize:1,oSize:0},scrollbarConfig:{},undoRedoHistoryConfig:{stackSize:50}},grid:{formConfig:{enabled:!0},pagerConfig:{enabled:!0},toolbarConfig:{enabled:!0},proxyConfig:{enabled:!0,autoLoad:!0,showLoading:!0,showResponseMsg:!0,showActionMsg:!0,response:{list:"list",result:"result",total:"page.total",footerData:"footerData",message:"message"}}},toolbar:{},gantt:{}}),"vxe-table-icon-"),setTheme=(_core.VxeUI.setIcon({TABLE_SORT_ASC:iconPrefix+"caret-up",TABLE_SORT_DESC:iconPrefix+"caret-down",TABLE_FILTER_NONE:iconPrefix+"funnel",TABLE_FILTER_MATCH:iconPrefix+"funnel",TABLE_EDIT:iconPrefix+"edit",TABLE_TITLE_PREFIX:iconPrefix+"question-circle-fill",TABLE_TITLE_SUFFIX:iconPrefix+"question-circle-fill",TABLE_TREE_LOADED:iconPrefix+"spinner roll",TABLE_TREE_OPEN:iconPrefix+"caret-right rotate90",TABLE_TREE_CLOSE:iconPrefix+"caret-right",TABLE_EXPAND_LOADED:iconPrefix+"spinner roll",TABLE_EXPAND_OPEN:iconPrefix+"arrow-right rotate90",TABLE_EXPAND_CLOSE:iconPrefix+"arrow-right",TABLE_CHECKBOX_CHECKED:iconPrefix+"checkbox-checked-fill",TABLE_CHECKBOX_UNCHECKED:iconPrefix+"checkbox-unchecked",TABLE_CHECKBOX_INDETERMINATE:iconPrefix+"checkbox-indeterminate-fill",TABLE_CHECKBOX_DISABLED_UNCHECKED:iconPrefix+"checkbox-unchecked-fill",TABLE_RADIO_CHECKED:iconPrefix+"radio-checked-fill",TABLE_RADIO_UNCHECKED:iconPrefix+"radio-unchecked",TABLE_RADIO_DISABLED_UNCHECKED:iconPrefix+"radio-unchecked-fill",TABLE_CUSTOM_SORT:iconPrefix+"drag-handle",TABLE_CUSTOM_FIXED_LEFT:iconPrefix+"fixed-left",TABLE_CUSTOM_FIXED_RIGHT:iconPrefix+"fixed-right",TABLE_CUSTOM_ALIGN_LEFT:iconPrefix+"align-left",TABLE_CUSTOM_ALIGN_CENTER:iconPrefix+"align-center",TABLE_CUSTOM_ALIGN_RIGHT:iconPrefix+"align-right",TABLE_CUSTOM_MOVE_UP:iconPrefix+"arrows-up",TABLE_CUSTOM_MOVE_DN:iconPrefix+"arrows-down",TABLE_CUSTOM_PUT_TOP:iconPrefix+"top",TABLE_CUSTOM_PUT_BOTTOM:iconPrefix+"bottom",TABLE_MENU_OPTIONS:iconPrefix+"arrow-right",TABLE_MENU_OPTION_LOADING:iconPrefix+"repeat roll",TABLE_DRAG_ROW:iconPrefix+"drag-handle",TABLE_DRAG_COLUMN:iconPrefix+"drag-handle",TABLE_DRAG_STATUS_ROW:iconPrefix+"sort",TABLE_DRAG_STATUS_SUB_ROW:iconPrefix+"add-sub",TABLE_DRAG_STATUS_AGG_GROUP:iconPrefix+"grouping",TABLE_DRAG_STATUS_AGG_VALUES:iconPrefix+"values",TABLE_DRAG_STATUS_COLUMN:iconPrefix+"swap",TABLE_DRAG_DISABLED:iconPrefix+"no-drop",TABLE_ROW_GROUP_OPEN:iconPrefix+"arrow-right rotate90",TABLE_ROW_GROUP_CLOSE:iconPrefix+"arrow-right",TABLE_AGGREGATE_GROUPING:iconPrefix+"grouping",TABLE_AGGREGATE_VALUES:iconPrefix+"values",TABLE_AGGREGATE_SORT:iconPrefix+"drag-handle",TABLE_AGGREGATE_DELETE:iconPrefix+"close",TOOLBAR_TOOLS_REFRESH:iconPrefix+"repeat",TOOLBAR_TOOLS_REFRESH_LOADING:iconPrefix+"repeat roll",TOOLBAR_TOOLS_IMPORT:iconPrefix+"upload",TOOLBAR_TOOLS_EXPORT:iconPrefix+"download",TOOLBAR_TOOLS_PRINT:iconPrefix+"print",TOOLBAR_TOOLS_FULLSCREEN:iconPrefix+"fullscreen",TOOLBAR_TOOLS_MINIMIZE:iconPrefix+"minimize",TOOLBAR_TOOLS_CUSTOM:iconPrefix+"setting",TOOLBAR_TOOLS_FIXED_LEFT:iconPrefix+"fixed-left",TOOLBAR_TOOLS_FIXED_LEFT_ACTIVE:iconPrefix+"fixed-left-fill",TOOLBAR_TOOLS_FIXED_RIGHT:iconPrefix+"fixed-right",TOOLBAR_TOOLS_FIXED_RIGHT_ACTIVE:iconPrefix+"fixed-right-fill"}),exports.setTheme=_core.VxeUI.setTheme),getTheme=exports.getTheme=_core.VxeUI.getTheme,setConfig=exports.setConfig=_core.VxeUI.setConfig,getConfig=exports.getConfig=_core.VxeUI.getConfig,setIcon=exports.setIcon=_core.VxeUI.setIcon,getIcon=exports.getIcon=_core.VxeUI.getIcon,setLanguage=exports.setLanguage=_core.VxeUI.setLanguage,setI18n=exports.setI18n=_core.VxeUI.setI18n,getI18n=exports.getI18n=_core.VxeUI.getI18n,globalEvents=exports.globalEvents=_core.VxeUI.globalEvents,globalResize=exports.globalResize=_core.VxeUI.globalResize,renderer=exports.renderer=_core.VxeUI.renderer,validators=exports.validators=_core.VxeUI.validators,menus=exports.menus=_core.VxeUI.menus,formats=exports.formats=_core.VxeUI.formats,commands=exports.commands=_core.VxeUI.commands,interceptor=exports.interceptor=_core.VxeUI.interceptor,clipboard=exports.clipboard=_core.VxeUI.clipboard,log=exports.log=_core.VxeUI.log,use=exports.use=_core.VxeUI.use,setup=e=>_core.VxeUI.setConfig(e),config=(exports.setup=setup,_core.VxeUI.setup=setup,e=>_core.VxeUI.setConfig(e)),t=(exports.config=config,_core.VxeUI.config=config,(e,o)=>_core.VxeUI.getI18n(e,o)),_t=(exports.t=t,_core.VxeUI.t=t,(e,o)=>(0,_utils.getFuncText)(e,o)),VXETable=(exports._t=_t,_core.VxeUI._t=_t,exports.VXETable=_core.VxeUI),saveFile=e=>_core.VxeUI.saveFile(e),readFile=(exports.saveFile=saveFile,e=>_core.VxeUI.readFile(e)),print=(exports.readFile=readFile,e=>_core.VxeUI.print(e)),modal=(exports.print=print,exports.modal={get(e){return _core.VxeUI.modal.get(e)},close(e){return _core.VxeUI.modal.close(e)},open(e){return _core.VxeUI.modal.open(e)},alert(e,o,i){return _core.VxeUI.modal.alert(e,o,i)},confirm(e,o,i){return _core.VxeUI.modal.confirm(e,o,i)},message(e,o){return _core.VxeUI.modal.message(e,o)},notification(e,o,i){return _core.VxeUI.modal.notification(e,o,i)}});var _default=exports.default=_core.VxeUI;
|
package/lib/ui/src/log.js
CHANGED
|
@@ -9,7 +9,7 @@ var _core = require("@vxe-ui/core");
|
|
|
9
9
|
const {
|
|
10
10
|
log
|
|
11
11
|
} = _core.VxeUI;
|
|
12
|
-
const tableVersion = `table v${"3.25.
|
|
12
|
+
const tableVersion = `table v${"3.25.4"}`;
|
|
13
13
|
function createComponentLog(name) {
|
|
14
14
|
const uiVersion = _core.VxeUI.uiVersion ? `ui v${_core.VxeUI.uiVersion}` : '';
|
|
15
15
|
const ganttVersion = _core.VxeUI.ganttVersion ? `gantt v${_core.VxeUI.ganttVersion}` : '';
|
package/lib/ui/src/log.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.createComponentLog=createComponentLog,exports.warnLog=exports.errLog=void 0;var _core=require("@vxe-ui/core");let log=_core.VxeUI.log,tableVersion="table v3.25.
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.createComponentLog=createComponentLog,exports.warnLog=exports.errLog=void 0;var _core=require("@vxe-ui/core");let log=_core.VxeUI.log,tableVersion="table v3.25.4";function createComponentLog(e){var r=_core.VxeUI.uiVersion?"ui v"+_core.VxeUI.uiVersion:"",o=_core.VxeUI.ganttVersion?"gantt v"+_core.VxeUI.ganttVersion:"",t=_core.VxeUI.designVersion?"design v"+_core.VxeUI.designVersion:"",r=[r,tableVersion,o,t].filter(e=>e).join(" ");return{warnLog:log.create("warn",r+"] ["+e),errLog:log.create("error",r+"] ["+e)}}let warnLog=exports.warnLog=log.create("warn",tableVersion),errLog=exports.errLog=log.create("error",tableVersion);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tomtaw-vxe-table",
|
|
3
|
-
"version": "3.25.
|
|
3
|
+
"version": "3.25.4",
|
|
4
4
|
"description": "A PC-end table component based on Vxe UI, supporting copy-paste, data pivot table, and high-performance virtual list table solution.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"update": "npm install --legacy-peer-deps",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"gulp-uglify": "^3.0.2",
|
|
61
61
|
"sass": "~1.101.7",
|
|
62
62
|
"sass-loader": "^14.2.1",
|
|
63
|
-
"typescript": "5.9.3",
|
|
63
|
+
"typescript": "~5.9.3",
|
|
64
64
|
"vue": "~2.6.14",
|
|
65
65
|
"vue-i18n": "^8.15.1",
|
|
66
66
|
"vue-router": "^3.5.1",
|
|
@@ -4,6 +4,7 @@ import { VxeUI } from '../../ui'
|
|
|
4
4
|
import { defineVxeComponent } from '../../ui/src/comp'
|
|
5
5
|
import { isEnableConf, getClass, getDefaultConfig, hasEnableConf } from '../../ui/src/utils'
|
|
6
6
|
import { getRowid, createHandleGetRowId, getCellRestHeight } from './util'
|
|
7
|
+
import { getRowExpandHeight } from './expand-height'
|
|
7
8
|
import { updateCellTitle } from '../../ui/src/dom'
|
|
8
9
|
import { getSlotVNs } from '../../ui/src/vn'
|
|
9
10
|
|
|
@@ -622,13 +623,10 @@ function renderRows (h: CreateElement, _vm: any, fixedType: 'left' | 'right' | '
|
|
|
622
623
|
const expandOpts = $xeTable.computeExpandOpts
|
|
623
624
|
const { height: expandHeight, padding, mode: expandMode } = expandOpts
|
|
624
625
|
if (expandMode === 'fixed') {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
expHeight = (currExpHeight || expandHeight || 0) + 1
|
|
630
|
-
}
|
|
631
|
-
}
|
|
626
|
+
// 与位置及总高度计算共用同一规则;估算不改变展开内容的自然高度。
|
|
627
|
+
const expHeight = rowExpandHeightFlag || expandOpts.estimateHeight
|
|
628
|
+
? getRowExpandHeight($xeTable, row, rowRest)
|
|
629
|
+
: 0
|
|
632
630
|
rows.push(
|
|
633
631
|
h('tr', {
|
|
634
632
|
class: 'vxe-body--row-expanded-place',
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { VxeTableConstructor, VxeTablePrivateMethods } from '../../../types'
|
|
2
|
+
|
|
3
|
+
type Table = VxeTableConstructor & VxeTablePrivateMethods
|
|
4
|
+
type HeightRecord = { expandHeight?: number }
|
|
5
|
+
type Measurement = { binding: HeightRecord; height: number; dirty: boolean }
|
|
6
|
+
const estimateValues = new WeakMap<HeightRecord, number>()
|
|
7
|
+
|
|
8
|
+
/** 仅缓存当前挂载的展开区。没有完整观察能力时保留同步测量路径。 */
|
|
9
|
+
export function createExpandHeightCache ($table: Table, onResize: () => void) {
|
|
10
|
+
const entries = new Map<HTMLElement, Measurement>()
|
|
11
|
+
let disposed = false
|
|
12
|
+
let queued = false
|
|
13
|
+
const supported = typeof ResizeObserver !== 'undefined' && typeof MutationObserver !== 'undefined'
|
|
14
|
+
const observer = supported
|
|
15
|
+
? new ResizeObserver(records => {
|
|
16
|
+
let changed = false
|
|
17
|
+
records.forEach(record => {
|
|
18
|
+
const entry = entries.get(record.target as HTMLElement)
|
|
19
|
+
if (entry) {
|
|
20
|
+
entry.dirty = true
|
|
21
|
+
changed = true
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
if (changed && !queued && !disposed) {
|
|
25
|
+
queued = true
|
|
26
|
+
$table.$nextTick(() => {
|
|
27
|
+
queued = false
|
|
28
|
+
if (!disposed) onResize()
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
: null
|
|
33
|
+
// 内容/样式变化先失效,避免下一次滚动发生在 ResizeObserver 通知之前。
|
|
34
|
+
const mutations = supported
|
|
35
|
+
? new MutationObserver(records => {
|
|
36
|
+
entries.forEach((entry, element) => {
|
|
37
|
+
if (records.some(record => element === record.target || element.contains(record.target))) {
|
|
38
|
+
entry.dirty = true
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
: null
|
|
43
|
+
let container: HTMLElement | null = null
|
|
44
|
+
let width = -1
|
|
45
|
+
$table.$once('hook:beforeDestroy', () => {
|
|
46
|
+
disposed = true
|
|
47
|
+
if (observer) observer.disconnect()
|
|
48
|
+
if (mutations) mutations.disconnect()
|
|
49
|
+
entries.clear()
|
|
50
|
+
container = null
|
|
51
|
+
})
|
|
52
|
+
return {
|
|
53
|
+
sync (element: HTMLElement) {
|
|
54
|
+
const nextWidth = element.clientWidth
|
|
55
|
+
if (container !== element) {
|
|
56
|
+
if (mutations) {
|
|
57
|
+
mutations.disconnect()
|
|
58
|
+
mutations.observe(element, { subtree: true, childList: true, attributes: true, characterData: true })
|
|
59
|
+
}
|
|
60
|
+
container = element
|
|
61
|
+
width = -1
|
|
62
|
+
}
|
|
63
|
+
entries.forEach((entry, child) => {
|
|
64
|
+
if (child.parentElement !== element) {
|
|
65
|
+
if (observer) observer.unobserve(child)
|
|
66
|
+
entries.delete(child)
|
|
67
|
+
} else if (nextWidth !== width) {
|
|
68
|
+
entry.dirty = true
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
width = nextWidth
|
|
72
|
+
},
|
|
73
|
+
measure (element: HTMLElement, binding: HeightRecord, scrolling: boolean) {
|
|
74
|
+
const previous = entries.get(element)
|
|
75
|
+
if (observer && scrolling && previous && previous.binding === binding && previous.height === binding.expandHeight && !previous.dirty) {
|
|
76
|
+
return previous.height
|
|
77
|
+
}
|
|
78
|
+
const height = element.offsetHeight
|
|
79
|
+
entries.set(element, { binding, height, dirty: false })
|
|
80
|
+
if (observer && !previous) {
|
|
81
|
+
// 旧实现不支持 box 选项时继续使用原有同步读取,不缓存滚动测量。
|
|
82
|
+
try {
|
|
83
|
+
observer.observe(element, { box: 'border-box' })
|
|
84
|
+
} catch (e) {
|
|
85
|
+
entries.delete(element)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return height
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** 估算只用于未测量的占位及滚动几何,不约束展开内容的实际 CSS 高度。 */
|
|
94
|
+
export function getRowExpandHeight ($table: Table, row: any, record: HeightRecord) {
|
|
95
|
+
const options = $table.computeExpandOpts
|
|
96
|
+
let estimatedHeight = 0
|
|
97
|
+
if (!options.height && options.mode === 'fixed' && options.estimateHeight) {
|
|
98
|
+
const estimate = options.estimateHeight({ row, $table })
|
|
99
|
+
if (typeof estimate === 'number' && Number.isFinite(estimate) && estimate >= 0) {
|
|
100
|
+
// 例如未挂载子表的条数变化:不能继续使用旧条数的实测高度。
|
|
101
|
+
const previous = estimateValues.get(record)
|
|
102
|
+
if (previous !== undefined && previous !== estimate) record.expandHeight = 0
|
|
103
|
+
estimateValues.set(record, estimate)
|
|
104
|
+
estimatedHeight = estimate
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return record.expandHeight || options.height || estimatedHeight
|
|
108
|
+
}
|
|
@@ -8,6 +8,7 @@ import { getSlotVNs } from '../../ui/src/vn'
|
|
|
8
8
|
import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from '../../ui/src/anime'
|
|
9
9
|
import { createComponentLog } from '../../ui/src/log'
|
|
10
10
|
import { getCrossTableDragRowInfo } from './store'
|
|
11
|
+
import { createExpandHeightCache, getRowExpandHeight } from './expand-height'
|
|
11
12
|
|
|
12
13
|
import type { VxeTooltipInstance, ValueOf } from 'vxe-pc-ui'
|
|
13
14
|
import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, TableReactData, VxeTableConstructor, VxeToolbarConstructor, VxeToolbarInstance, TableInternalData, VxeGridConstructor, VxeTablePrivateMethods, VxeTablePropTypes, VxeGridPrivateMethods } from '../../../types'
|
|
@@ -24,7 +25,14 @@ const maxXWidth = 5e6
|
|
|
24
25
|
const sourceType = 'table'
|
|
25
26
|
|
|
26
27
|
// 仅合并等待同一轮 DOM 更新的展开行位置重算,不保留表格实例。
|
|
27
|
-
const pendingExpandOffsetUpdates = new
|
|
28
|
+
const pendingExpandOffsetUpdates = new WeakMap<VxeTableConstructor, number>()
|
|
29
|
+
const expandHeightCaches = new WeakMap<VxeTableConstructor, ReturnType<typeof createExpandHeightCache>>()
|
|
30
|
+
// 仅高度变化可复用前缀;排序、筛选等原有调用仍完整重建索引。
|
|
31
|
+
const rowOffsetIndexes = new WeakMap<VxeTableConstructor, {
|
|
32
|
+
rows: any[]
|
|
33
|
+
cache: TableInternalData['fullAllDataRowIdData']
|
|
34
|
+
indexes: Map<string, number>
|
|
35
|
+
}>()
|
|
28
36
|
|
|
29
37
|
let crossTableDragRowObj: {
|
|
30
38
|
$oldTable: VxeTableConstructor & VxeTablePrivateMethods
|
|
@@ -4468,7 +4476,7 @@ function updateColumnOffsetLeft ($xeTable: VxeTableConstructor & VxeTablePrivate
|
|
|
4468
4476
|
}
|
|
4469
4477
|
}
|
|
4470
4478
|
|
|
4471
|
-
function updateRowOffsetTop ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
4479
|
+
function updateRowOffsetTop ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, dirtyIndex = 0) {
|
|
4472
4480
|
const reactData = $xeTable as unknown as TableReactData
|
|
4473
4481
|
const internalData = $xeTable as unknown as TableInternalData
|
|
4474
4482
|
|
|
@@ -4478,29 +4486,40 @@ function updateRowOffsetTop ($xeTable: VxeTableConstructor & VxeTablePrivateMeth
|
|
|
4478
4486
|
if (!el || !el.clientWidth) {
|
|
4479
4487
|
return
|
|
4480
4488
|
}
|
|
4481
|
-
const expandOpts = $xeTable.computeExpandOpts
|
|
4482
4489
|
const rowOpts = $xeTable.computeRowOpts
|
|
4483
4490
|
const cellOpts = $xeTable.computeCellOpts
|
|
4484
4491
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
4485
4492
|
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
4486
|
-
|
|
4487
|
-
|
|
4493
|
+
const previous = rowOffsetIndexes.get($xeTable)
|
|
4494
|
+
let startIndex = previous && previous.rows === afterFullData && previous.cache === fullAllDataRowIdData
|
|
4495
|
+
? Math.max(0, Math.min(dirtyIndex, afterFullData.length))
|
|
4496
|
+
: 0
|
|
4497
|
+
const firstRow = afterFullData[startIndex]
|
|
4498
|
+
const firstRest = firstRow ? fullAllDataRowIdData[handleGetRowId(firstRow)] : null
|
|
4499
|
+
if (startIndex && (!firstRest || !Number.isFinite(firstRest.oTop))) startIndex = 0
|
|
4500
|
+
const indexes = startIndex && previous ? previous.indexes : new Map<string, number>()
|
|
4501
|
+
let offsetTop = startIndex && firstRest ? firstRest.oTop : 0
|
|
4502
|
+
for (let rIndex = startIndex, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
4488
4503
|
const row = afterFullData[rIndex]
|
|
4489
4504
|
const rowid = handleGetRowId(row)
|
|
4490
4505
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
4506
|
+
if (expandColumn) indexes.set(rowid, rIndex)
|
|
4491
4507
|
rowRest.oTop = offsetTop
|
|
4492
4508
|
offsetTop += getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
|
|
4493
4509
|
// 是否展开行
|
|
4494
4510
|
if (expandColumn && rowExpandedMaps[rowid]) {
|
|
4495
|
-
offsetTop +=
|
|
4511
|
+
offsetTop += getRowExpandHeight($xeTable, row, rowRest)
|
|
4496
4512
|
}
|
|
4497
4513
|
}
|
|
4514
|
+
rowOffsetIndexes.set($xeTable, { rows: afterFullData, cache: fullAllDataRowIdData, indexes })
|
|
4515
|
+
// 完整重算也覆盖了此前排队的高度变化,避免下一轮重复计算。
|
|
4516
|
+
pendingExpandOffsetUpdates.delete($xeTable)
|
|
4498
4517
|
}
|
|
4499
4518
|
|
|
4500
4519
|
/**
|
|
4501
4520
|
* 更新展开行样式
|
|
4502
4521
|
*/
|
|
4503
|
-
function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
4522
|
+
function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, forceMeasure = false) {
|
|
4504
4523
|
const reactData = $xeTable as unknown as TableReactData
|
|
4505
4524
|
const internalData = $xeTable as unknown as TableInternalData
|
|
4506
4525
|
|
|
@@ -4519,7 +4538,20 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
4519
4538
|
const rowExpandEl = $xeTable.$refs.refRowExpandElem as HTMLDivElement
|
|
4520
4539
|
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
4521
4540
|
if (rowExpandEl && bodyScrollElem) {
|
|
4541
|
+
const previousHeightCache = expandHeightCaches.get($xeTable)
|
|
4542
|
+
const heightCache = previousHeightCache || createExpandHeightCache($xeTable, () => updateRowExpandStyle($xeTable, true))
|
|
4543
|
+
if (!previousHeightCache) {
|
|
4544
|
+
$xeTable.$once('hook:beforeDestroy', () => {
|
|
4545
|
+
pendingExpandOffsetUpdates.delete($xeTable)
|
|
4546
|
+
rowOffsetIndexes.delete($xeTable)
|
|
4547
|
+
expandHeightCaches.delete($xeTable)
|
|
4548
|
+
})
|
|
4549
|
+
}
|
|
4550
|
+
expandHeightCaches.set($xeTable, heightCache)
|
|
4551
|
+
heightCache.sync(rowExpandEl)
|
|
4522
4552
|
let isUpdateHeight = false
|
|
4553
|
+
let dirtyIndex = Infinity
|
|
4554
|
+
const offsetIndex = rowOffsetIndexes.get($xeTable)
|
|
4523
4555
|
const expandStyles: { el: HTMLDivElement; top: string }[] = []
|
|
4524
4556
|
// 先集中读取尺寸,避免每个展开区写 top 后又读取下一个展开区的布局。
|
|
4525
4557
|
XEUtils.arrayEach(rowExpandEl.children, reEl => {
|
|
@@ -4527,7 +4559,7 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
4527
4559
|
const rowid = expandEl.getAttribute('rowid') || ''
|
|
4528
4560
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
4529
4561
|
if (rowRest) {
|
|
4530
|
-
const expandHeight = expandEl.
|
|
4562
|
+
const expandHeight = heightCache.measure(expandEl, rowRest, !!internalData.inVirtualScroll && !forceMeasure)
|
|
4531
4563
|
// 普通虚拟滚动使用缓存位置,无需为每个展开区查询主表行 DOM。
|
|
4532
4564
|
const trEl = !scrollYLoad || isScrollYBig
|
|
4533
4565
|
? bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement | null
|
|
@@ -4549,10 +4581,12 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
4549
4581
|
}
|
|
4550
4582
|
expandStyles.push({ el: expandEl, top: toCssUnit(offsetTop) })
|
|
4551
4583
|
|
|
4552
|
-
if (
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4584
|
+
if (rowRest.expandHeight !== expandHeight) {
|
|
4585
|
+
isUpdateHeight = true
|
|
4586
|
+
const index = offsetIndex && offsetIndex.rows === internalData.afterFullData && offsetIndex.cache === fullAllDataRowIdData
|
|
4587
|
+
? offsetIndex.indexes.get(rowid)
|
|
4588
|
+
: undefined
|
|
4589
|
+
dirtyIndex = Math.min(dirtyIndex, index === undefined ? 0 : index)
|
|
4556
4590
|
}
|
|
4557
4591
|
rowRest.expandHeight = expandHeight
|
|
4558
4592
|
}
|
|
@@ -4564,11 +4598,18 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
4564
4598
|
})
|
|
4565
4599
|
if (isUpdateHeight) {
|
|
4566
4600
|
reactData.rowExpandHeightFlag++
|
|
4567
|
-
|
|
4568
|
-
|
|
4601
|
+
const pendingIndex = pendingExpandOffsetUpdates.get($xeTable)
|
|
4602
|
+
pendingExpandOffsetUpdates.set($xeTable, Math.min(pendingIndex === undefined ? Infinity : pendingIndex, dirtyIndex))
|
|
4603
|
+
if (pendingIndex === undefined) {
|
|
4569
4604
|
$xeTable.$nextTick(() => {
|
|
4570
|
-
pendingExpandOffsetUpdates.
|
|
4571
|
-
|
|
4605
|
+
const index = pendingExpandOffsetUpdates.get($xeTable)
|
|
4606
|
+
if (index !== undefined) {
|
|
4607
|
+
pendingExpandOffsetUpdates.delete($xeTable)
|
|
4608
|
+
updateRowOffsetTop($xeTable, index)
|
|
4609
|
+
updateRowExpandStyle($xeTable)
|
|
4610
|
+
$xeTable.updateScrollYSpace()
|
|
4611
|
+
if (reactData.scrollYLoad) loadScrollYData($xeTable)
|
|
4612
|
+
}
|
|
4572
4613
|
})
|
|
4573
4614
|
}
|
|
4574
4615
|
}
|
|
@@ -7787,6 +7828,14 @@ const tableMethods: any = {
|
|
|
7787
7828
|
const isForce = !!reFull
|
|
7788
7829
|
return handleLazyRecalculate($xeTable, isForce, isForce, isForce)
|
|
7789
7830
|
},
|
|
7831
|
+
refreshRowExpandHeight () {
|
|
7832
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7833
|
+
return $xeTable.$nextTick().then(() => {
|
|
7834
|
+
updateRowExpandStyle($xeTable, true)
|
|
7835
|
+
// 等待同一轮高度变化的位置重算及其 DOM 更新。
|
|
7836
|
+
return $xeTable.$nextTick().then(() => $xeTable.$nextTick())
|
|
7837
|
+
})
|
|
7838
|
+
},
|
|
7790
7839
|
updateStyle () {
|
|
7791
7840
|
const $xeTable = this
|
|
7792
7841
|
|
|
@@ -13364,7 +13413,6 @@ const tableMethods: any = {
|
|
|
13364
13413
|
const $xeGanttView = internalData.xeGanttView
|
|
13365
13414
|
const { startIndex } = scrollYStore
|
|
13366
13415
|
const mouseOpts = $xeTable.computeMouseOpts
|
|
13367
|
-
const expandOpts = $xeTable.computeExpandOpts
|
|
13368
13416
|
const rowOpts = $xeTable.computeRowOpts
|
|
13369
13417
|
const cellOpts = $xeTable.computeCellOpts
|
|
13370
13418
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
@@ -13401,7 +13449,7 @@ const tableMethods: any = {
|
|
|
13401
13449
|
sYHeight = (rowRest.oTop || 0) + rHeight
|
|
13402
13450
|
// 是否展开行
|
|
13403
13451
|
if (expandColumn && rowExpandedMaps[rowid]) {
|
|
13404
|
-
sYHeight +=
|
|
13452
|
+
sYHeight += getRowExpandHeight($xeTable, lastRow, rowRest)
|
|
13405
13453
|
}
|
|
13406
13454
|
}
|
|
13407
13455
|
}
|
package/types/all.d.ts
CHANGED
|
@@ -8,6 +8,19 @@ import VxeTable from 'vxe-pc-ui/types/components/table'
|
|
|
8
8
|
import VxeGrid from 'vxe-pc-ui/types/components/grid'
|
|
9
9
|
import VxeToolbar from 'vxe-pc-ui/types/components/toolbar'
|
|
10
10
|
|
|
11
|
+
declare module 'vxe-pc-ui/types/components/table' {
|
|
12
|
+
interface TableMethods<DT = any> {
|
|
13
|
+
/** 重新测量挂载的 fixed 展开区,不重算整表列宽。 */
|
|
14
|
+
refreshRowExpandHeight(): Promise<void>
|
|
15
|
+
}
|
|
16
|
+
namespace VxeTablePropTypes {
|
|
17
|
+
interface ExpandConfig<D = any> {
|
|
18
|
+
/** fixed 模式下未测量展开区的高度估算,不设置内容的固定高度。 */
|
|
19
|
+
estimateHeight?: (params: { row: D; $table: VxeTableConstructor<D> }) => number
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
11
24
|
declare global {
|
|
12
25
|
interface Window {
|
|
13
26
|
VxeUITable: VxeUIExport
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|