vxe-table 3.19.2 → 3.19.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.
Files changed (34) hide show
  1. package/es/style.css +1 -1
  2. package/es/table/src/body.js +30 -14
  3. package/es/table/src/methods.js +118 -8
  4. package/es/table/src/table.js +4 -4
  5. package/es/table/src/util.js +0 -61
  6. package/es/ui/index.js +3 -2
  7. package/es/ui/src/log.js +1 -1
  8. package/lib/index.umd.js +171 -109
  9. package/lib/index.umd.min.js +1 -1
  10. package/lib/style.css +1 -1
  11. package/lib/table/src/body.js +28 -15
  12. package/lib/table/src/body.min.js +1 -1
  13. package/lib/table/src/methods.js +136 -8
  14. package/lib/table/src/methods.min.js +1 -1
  15. package/lib/table/src/table.js +3 -4
  16. package/lib/table/src/table.min.js +1 -1
  17. package/lib/table/src/util.js +0 -81
  18. package/lib/table/src/util.min.js +1 -1
  19. package/lib/ui/index.js +3 -2
  20. package/lib/ui/index.min.js +1 -1
  21. package/lib/ui/src/log.js +1 -1
  22. package/lib/ui/src/log.min.js +1 -1
  23. package/package.json +2 -2
  24. package/packages/table/src/body.ts +29 -14
  25. package/packages/table/src/methods.ts +122 -8
  26. package/packages/table/src/table.ts +4 -4
  27. package/packages/table/src/util.ts +0 -66
  28. package/packages/ui/index.ts +2 -1
  29. /package/es/{iconfont.1761269884508.ttf → iconfont.1761699967297.ttf} +0 -0
  30. /package/es/{iconfont.1761269884508.woff → iconfont.1761699967297.woff} +0 -0
  31. /package/es/{iconfont.1761269884508.woff2 → iconfont.1761699967297.woff2} +0 -0
  32. /package/lib/{iconfont.1761269884508.ttf → iconfont.1761699967297.ttf} +0 -0
  33. /package/lib/{iconfont.1761269884508.woff → iconfont.1761699967297.woff} +0 -0
  34. /package/lib/{iconfont.1761269884508.woff2 → iconfont.1761699967297.woff2} +0 -0
@@ -147,7 +147,7 @@ function handleCustomRestore ($xeTable: VxeTableConstructor & VxeTablePrivateMet
147
147
  const customOpts = $xeTable.computeCustomOpts
148
148
  const { storage, storeOptions } = customOpts
149
149
  const isAllCustom = storage === true
150
- const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions)
150
+ const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = Object.assign({}, isAllCustom ? {} : storage || {}, storeOptions)
151
151
  const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom)
152
152
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
153
153
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
@@ -246,7 +246,7 @@ function restoreCustomStorage ($xeTable: VxeTableConstructor & VxeTablePrivateMe
246
246
  const customOpts = $xeTable.computeCustomOpts
247
247
  const { storage, restoreStore, storeOptions } = customOpts
248
248
  const isAllCustom = storage === true
249
- const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions)
249
+ const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = Object.assign({}, isAllCustom ? {} : storage || {}, storeOptions)
250
250
  const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom)
251
251
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
252
252
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
@@ -509,6 +509,7 @@ function handleBaseTreeExpand ($xeTable: VxeTableConstructor & VxeTablePrivateMe
509
509
  }
510
510
  reactData.treeExpandedFlag++
511
511
  return Promise.all(result).then(() => {
512
+ updateTreeLineStyle($xeTable)
512
513
  return $xeTable.recalculate()
513
514
  })
514
515
  }
@@ -2509,6 +2510,9 @@ function autoCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
2509
2510
  updateHeight($xeTable)
2510
2511
  }
2511
2512
 
2513
+ /**
2514
+ * 计算自适应行高
2515
+ */
2512
2516
  const calcCellAutoHeight = (rowRest: VxeTableDefines.RowCacheItem, wrapperEl: HTMLDivElement) => {
2513
2517
  const cellElemList = wrapperEl.querySelectorAll(`.vxe-cell--wrapper[rowid="${rowRest.rowid}"]`)
2514
2518
  let colHeight = rowRest.height
@@ -2527,15 +2531,21 @@ const calcCellAutoHeight = (rowRest: VxeTableDefines.RowCacheItem, wrapperEl: HT
2527
2531
  return colHeight
2528
2532
  }
2529
2533
 
2534
+ /**
2535
+ * 自适应行高
2536
+ */
2530
2537
  const calcCellHeight = ($xeTable: VxeTableConstructor) => {
2538
+ const props = $xeTable
2531
2539
  const reactData = $xeTable as unknown as TableReactData
2532
2540
  const internalData = $xeTable as unknown as TableInternalData
2533
2541
 
2542
+ const { treeConfig } = props
2534
2543
  const { tableData, isAllOverflow, scrollYLoad, scrollXLoad } = reactData
2535
2544
  const { fullAllDataRowIdData } = internalData
2545
+ const treeOpts = $xeTable.computeTreeOpts
2536
2546
  const defaultRowHeight = $xeTable.computeDefaultRowHeight
2537
2547
  const el = $xeTable.$refs.refElem as HTMLDivElement
2538
- if (!isAllOverflow && (scrollYLoad || scrollXLoad) && el) {
2548
+ if (!isAllOverflow && (scrollYLoad || scrollXLoad || (treeConfig && treeOpts.showLine)) && el) {
2539
2549
  const { handleGetRowId } = createHandleGetRowId($xeTable)
2540
2550
  tableData.forEach(row => {
2541
2551
  const rowid = handleGetRowId(row)
@@ -3029,6 +3039,9 @@ function handleRecalculateStyle ($xeTable: VxeTableConstructor & VxeTablePrivate
3029
3039
  calcScrollbar($xeTable)
3030
3040
  updateStyle($xeTable)
3031
3041
  updateRowExpandStyle($xeTable)
3042
+ if (reFull) {
3043
+ updateTreeLineStyle($xeTable)
3044
+ }
3032
3045
  return computeScrollLoad($xeTable).then(() => {
3033
3046
  // 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
3034
3047
  if (reWidth) {
@@ -3046,6 +3059,9 @@ function handleRecalculateStyle ($xeTable: VxeTableConstructor & VxeTablePrivate
3046
3059
  updateRowOffsetTop($xeTable)
3047
3060
  }
3048
3061
  updateRowExpandStyle($xeTable)
3062
+ if (reFull) {
3063
+ updateTreeLineStyle($xeTable)
3064
+ }
3049
3065
  if (reFull) {
3050
3066
  return computeScrollLoad($xeTable)
3051
3067
  }
@@ -3411,6 +3427,7 @@ function loadTableData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
3411
3427
  }
3412
3428
  reactData.isRowLoading = false
3413
3429
  handleRecalculateStyle($xeTable, false, false, false)
3430
+ updateTreeLineStyle($xeTable)
3414
3431
  // 如果是自动行高,特殊情况需调用 recalculate 手动刷新
3415
3432
  if (!props.showOverflow) {
3416
3433
  setTimeout(() => {
@@ -3424,6 +3441,7 @@ function loadTableData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
3424
3441
  .then(() => {
3425
3442
  handleRecalculateStyle($xeTable, false, true, true)
3426
3443
  updateRowOffsetTop($xeTable)
3444
+ updateTreeLineStyle($xeTable)
3427
3445
  resolve()
3428
3446
  })
3429
3447
  } else {
@@ -3432,6 +3450,7 @@ function loadTableData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
3432
3450
  .then(() => {
3433
3451
  handleRecalculateStyle($xeTable, false, true, true)
3434
3452
  updateRowOffsetTop($xeTable)
3453
+ updateTreeLineStyle($xeTable)
3435
3454
  resolve()
3436
3455
  })
3437
3456
  })
@@ -3939,6 +3958,9 @@ function updateHeight ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
3939
3958
  }
3940
3959
  }
3941
3960
 
3961
+ /**
3962
+ * 计算自适应列宽
3963
+ */
3942
3964
  function calcColumnAutoWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, column: VxeTableDefines.ColumnInfo, wrapperEl: HTMLDivElement) {
3943
3965
  const columnOpts = $xeTable.computeColumnOpts
3944
3966
  const { autoOptions } = columnOpts
@@ -3968,6 +3990,9 @@ function calcColumnAutoWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMet
3968
3990
  return colWidth + leftRightPadding
3969
3991
  }
3970
3992
 
3993
+ /**
3994
+ * 自适应列宽
3995
+ */
3971
3996
  function calcCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
3972
3997
  const internalData = $xeTable as unknown as TableInternalData
3973
3998
 
@@ -4118,9 +4143,97 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
4118
4143
  /**
4119
4144
  * 更新树连接线样式
4120
4145
  */
4121
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
4122
4146
  function updateTreeLineStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
4123
- // 待优化
4147
+ const props = $xeTable
4148
+ const reactData = $xeTable as unknown as TableReactData
4149
+ const internalData = $xeTable as unknown as TableInternalData
4150
+
4151
+ const { treeConfig } = props
4152
+ if (!treeConfig) {
4153
+ return
4154
+ }
4155
+ const { tableData } = reactData
4156
+ const { fullAllDataRowIdData, treeExpandedMaps } = internalData
4157
+ const cellOpts = $xeTable.computeCellOpts
4158
+ const rowOpts = $xeTable.computeRowOpts
4159
+ const defaultRowHeight = $xeTable.computeDefaultRowHeight
4160
+ const treeOpts = $xeTable.computeTreeOpts
4161
+ const { transform, mapChildrenField } = treeOpts
4162
+ const childrenField = treeOpts.children || treeOpts.childrenField
4163
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
4164
+ const expParentList: {
4165
+ row: any
4166
+ prevRow: any
4167
+ nextRow: any
4168
+ }[] = []
4169
+
4170
+ const handleNodeRow = (row: any, rIndex: number, rows: any[]) => {
4171
+ const rowid = handleGetRowId(row)
4172
+ const rowRest = fullAllDataRowIdData[rowid] || {}
4173
+ const childList: any[] = row[transform ? mapChildrenField : childrenField]
4174
+ const prevRow = rows[rIndex - 1] || null
4175
+ const nextRow = rows[rIndex + 1] || null
4176
+ if (childList && childList.length && treeExpandedMaps[rowid]) {
4177
+ expParentList.push({ row, prevRow, nextRow })
4178
+ childList.forEach((childRow, crIndex) => {
4179
+ const childRowid = handleGetRowId(childRow)
4180
+ if (treeExpandedMaps[childRowid]) {
4181
+ handleNodeRow(childRow, crIndex, childList)
4182
+ }
4183
+ })
4184
+ } else {
4185
+ if (nextRow) {
4186
+ const nextRowid = handleGetRowId(nextRow)
4187
+ const nextRowRest = fullAllDataRowIdData[nextRowid] || {}
4188
+ const currCellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
4189
+ const nextCellHeight = getCellRestHeight(nextRowRest, cellOpts, rowOpts, defaultRowHeight)
4190
+ rowRest.oHeight = currCellHeight
4191
+ rowRest.lineHeight = Math.floor(currCellHeight / 2 + nextCellHeight / 2)
4192
+ } else {
4193
+ rowRest.oHeight = 0
4194
+ rowRest.lineHeight = 0
4195
+ }
4196
+ }
4197
+ }
4198
+ tableData.forEach((row, rIndex) => {
4199
+ handleNodeRow(row, rIndex, tableData)
4200
+ })
4201
+
4202
+ XEUtils.lastArrayEach(expParentList, ({ row, nextRow }) => {
4203
+ const rowid = handleGetRowId(row)
4204
+ const childList: any[] = row[transform ? mapChildrenField : childrenField]
4205
+ const rowRest = fullAllDataRowIdData[rowid]
4206
+ if (rowRest) {
4207
+ const currCellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
4208
+ let countOffsetHeight = currCellHeight
4209
+ let countLineHeight = 0
4210
+ childList.forEach((childRow) => {
4211
+ const childRowid = handleGetRowId(childRow)
4212
+ const childRowRest = fullAllDataRowIdData[childRowid] || {}
4213
+ const childList: any[] = childRow[transform ? mapChildrenField : childrenField]
4214
+ if (treeExpandedMaps[childRowid] && childList && childList.length) {
4215
+ countOffsetHeight += (childRowRest.oHeight || 0)
4216
+ countLineHeight += (childRowRest.oHeight || 0)
4217
+ } else {
4218
+ const cellHeight = getCellRestHeight(childRowRest, cellOpts, rowOpts, defaultRowHeight)
4219
+ childRowRest.oHeight = cellHeight
4220
+ childRowRest.lineHeight = cellHeight
4221
+ countOffsetHeight += cellHeight
4222
+ countLineHeight += cellHeight
4223
+ }
4224
+ })
4225
+ if (nextRow) {
4226
+ const nextRowid = handleGetRowId(nextRow)
4227
+ const nextRowRest = fullAllDataRowIdData[nextRowid] || {}
4228
+ const currCellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
4229
+ const nextCellHeight = getCellRestHeight(nextRowRest, cellOpts, rowOpts, defaultRowHeight)
4230
+ countOffsetHeight += currCellHeight
4231
+ countLineHeight += Math.floor(currCellHeight / 2 + nextCellHeight / 2)
4232
+ }
4233
+ rowRest.lineHeight = countLineHeight
4234
+ rowRest.oHeight = countOffsetHeight
4235
+ }
4236
+ })
4124
4237
  }
4125
4238
 
4126
4239
  function handleRowExpandScroll ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
@@ -5631,7 +5744,7 @@ const Methods = {
5631
5744
  const customOpts = $xeTable.computeCustomOpts
5632
5745
  const { storage, restoreStore, storeOptions } = customOpts
5633
5746
  const isAllCustom = storage === true
5634
- const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions)
5747
+ const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = Object.assign({}, isAllCustom ? {} : storage || {}, storeOptions)
5635
5748
  const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom)
5636
5749
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
5637
5750
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
@@ -5669,7 +5782,7 @@ const Methods = {
5669
5782
  const { fullColumnFieldData, collectColumn } = internalData
5670
5783
  const { storage, checkMethod, storeOptions } = customOpts
5671
5784
  const isAllCustom = storage === true
5672
- const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions)
5785
+ const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = Object.assign({}, isAllCustom ? {} : storage || {}, storeOptions)
5673
5786
  const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom)
5674
5787
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
5675
5788
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
@@ -5789,7 +5902,7 @@ const Methods = {
5789
5902
  const customOpts = $xeTable.computeCustomOpts
5790
5903
  const { updateStore, storage, storeOptions } = customOpts
5791
5904
  const isAllCustom = storage === true
5792
- const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions)
5905
+ const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = Object.assign({}, isAllCustom ? {} : storage || {}, storeOptions)
5793
5906
  const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom)
5794
5907
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
5795
5908
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
@@ -10819,6 +10932,7 @@ const Methods = {
10819
10932
  }
10820
10933
  reactData.treeExpandedFlag++
10821
10934
  }).then(() => {
10935
+ updateTreeLineStyle($xeTable)
10822
10936
  if (expList.length) {
10823
10937
  $xeTable.recalculate()
10824
10938
  }
@@ -1640,7 +1640,7 @@ export default {
1640
1640
 
1641
1641
  handleKeyField($xeTable)
1642
1642
 
1643
- const { data, exportConfig, importConfig, treeConfig, showOverflow, highlightCurrentRow, highlightCurrentColumn } = props
1643
+ const { data, exportConfig, importConfig, treeConfig, highlightCurrentRow, highlightCurrentColumn } = props
1644
1644
  const { scrollXStore, scrollYStore } = internalData
1645
1645
  const columnOpts = $xeTable.computeColumnOpts
1646
1646
  const editOpts = $xeTable.computeEditOpts
@@ -1675,9 +1675,9 @@ export default {
1675
1675
  if (props.editConfig && editOpts.showStatus && !props.keepSource) {
1676
1676
  warnLog('vxe.error.reqProp', ['keep-source'])
1677
1677
  }
1678
- if (treeConfig && (treeOpts.showLine || treeOpts.line) && !showOverflow) {
1679
- warnLog('vxe.error.reqProp', ['show-overflow'])
1680
- }
1678
+ // if (treeConfig && (treeOpts.showLine || treeOpts.line) && !showOverflow) {
1679
+ // warnLog('vxe.error.reqProp', ['show-overflow'])
1680
+ // }
1681
1681
  if (treeConfig && !treeOpts.transform && props.stripe) {
1682
1682
  warnLog('vxe.error.noTree', ['stripe'])
1683
1683
  }
@@ -549,72 +549,6 @@ export function getLastChildColumn (column: VxeTableDefines.ColumnInfo): VxeTabl
549
549
  return column
550
550
  }
551
551
 
552
- const lineOffsetSizes: Record<string, any> = {
553
- mini: 3,
554
- small: 2,
555
- medium: 1,
556
- large: 0
557
- }
558
-
559
- function countTreeExpandSize (prevRow: any, params: VxeTableDefines.CellRenderBodyParams) {
560
- let count = 1
561
- if (!prevRow) {
562
- return count
563
- }
564
- const { $table } = params
565
- const reactData = $table as unknown as TableReactData
566
- const { treeExpandedFlag } = reactData
567
- const internalData = $table as unknown as TableInternalData
568
- const { treeExpandedMaps } = internalData
569
- const treeOpts = $table.computeTreeOpts
570
- const { transform, mapChildrenField } = treeOpts
571
- const childrenField = treeOpts.children || treeOpts.childrenField
572
- const rowChildren = prevRow[transform ? mapChildrenField : childrenField]
573
- if (rowChildren && treeExpandedFlag && treeExpandedMaps[getRowid($table, prevRow)]) {
574
- for (let index = 0; index < rowChildren.length; index++) {
575
- count += countTreeExpandSize(rowChildren[index], params)
576
- }
577
- }
578
- return count
579
- }
580
-
581
- export function getOffsetSize ($xeTable: VxeTableConstructor) {
582
- const vSize = $xeTable.computeSize
583
- if (vSize) {
584
- return lineOffsetSizes[vSize] || 0
585
- }
586
- return 0
587
- }
588
-
589
- export function calcTreeLine (params: VxeTableDefines.CellRenderBodyParams, prevRow: any) {
590
- const { $table, row } = params
591
- const tableProps = $table
592
- const tableReactData = $table as unknown as TableReactData
593
- const tableInternalData = $table as unknown as TableInternalData
594
-
595
- const { showOverflow } = tableProps
596
- const { scrollYLoad } = tableReactData
597
- const { fullAllDataRowIdData } = tableInternalData
598
- const rowOpts = $table.computeRowOpts
599
- const cellOpts = $table.computeCellOpts
600
- const defaultRowHeight = $table.computeDefaultRowHeight
601
- const rowid = getRowid($table, row)
602
- const rowRest = fullAllDataRowIdData[rowid]
603
- const currCellHeight = rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
604
- let expandSize = 1
605
- if (prevRow) {
606
- expandSize = countTreeExpandSize(prevRow, params)
607
- }
608
- let cellHeight = currCellHeight
609
- const vnHeight = rowRest.height
610
- if (scrollYLoad) {
611
- if (!showOverflow) {
612
- cellHeight = vnHeight || currCellHeight
613
- }
614
- }
615
- return cellHeight * expandSize - (prevRow ? 1 : (12 - getOffsetSize($table)))
616
- }
617
-
618
552
  export function getCellValue (row: any, column: any) {
619
553
  return XEUtils.get(row, column.field)
620
554
  }
@@ -179,7 +179,8 @@ VxeUI.setConfig({
179
179
  hasChildField: 'hasChild',
180
180
  mapChildrenField: '_X_ROW_CHILD',
181
181
  indent: 20,
182
- showIcon: true
182
+ showIcon: true,
183
+ showRootLine: true
183
184
  },
184
185
  expandConfig: {
185
186
  // trigger: 'default',