vxe-table 3.9.0 → 3.9.2

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 (88) hide show
  1. package/README.md +80 -9
  2. package/es/grid/src/grid.js +4 -4
  3. package/es/locale/lang/en-US.js +4 -1
  4. package/es/locale/lang/es-ES.js +3 -0
  5. package/es/locale/lang/hu-HU.js +3 -0
  6. package/es/locale/lang/ja-JP.js +3 -0
  7. package/es/locale/lang/ko-KR.js +3 -0
  8. package/es/locale/lang/pt-BR.js +3 -0
  9. package/es/locale/lang/ru-RU.js +3 -0
  10. package/es/locale/lang/uk-UA.js +3 -0
  11. package/es/locale/lang/vi-VN.js +3 -0
  12. package/es/locale/lang/zh-CHT.js +3 -0
  13. package/es/locale/lang/zh-CN.js +3 -0
  14. package/es/style.css +1 -1
  15. package/es/table/module/edit/mixin.js +2 -16
  16. package/es/table/src/methods.js +71 -22
  17. package/es/table/src/table.js +28 -28
  18. package/es/ui/index.js +2 -2
  19. package/es/ui/src/log.js +1 -1
  20. package/lib/grid/src/grid.js +4 -4
  21. package/lib/grid/src/grid.min.js +1 -1
  22. package/lib/index.umd.js +133 -86
  23. package/lib/index.umd.min.js +1 -1
  24. package/lib/locale/lang/en-US.js +4 -1
  25. package/lib/locale/lang/en-US.min.js +1 -1
  26. package/lib/locale/lang/en-US.umd.js +4 -1
  27. package/lib/locale/lang/es-ES.js +3 -0
  28. package/lib/locale/lang/es-ES.min.js +1 -1
  29. package/lib/locale/lang/es-ES.umd.js +3 -0
  30. package/lib/locale/lang/hu-HU.js +3 -0
  31. package/lib/locale/lang/hu-HU.min.js +1 -1
  32. package/lib/locale/lang/hu-HU.umd.js +3 -0
  33. package/lib/locale/lang/ja-JP.js +3 -0
  34. package/lib/locale/lang/ja-JP.min.js +1 -1
  35. package/lib/locale/lang/ja-JP.umd.js +3 -0
  36. package/lib/locale/lang/ko-KR.js +3 -0
  37. package/lib/locale/lang/ko-KR.min.js +1 -1
  38. package/lib/locale/lang/ko-KR.umd.js +3 -0
  39. package/lib/locale/lang/pt-BR.js +3 -0
  40. package/lib/locale/lang/pt-BR.min.js +1 -1
  41. package/lib/locale/lang/pt-BR.umd.js +3 -0
  42. package/lib/locale/lang/ru-RU.js +3 -0
  43. package/lib/locale/lang/ru-RU.min.js +1 -1
  44. package/lib/locale/lang/ru-RU.umd.js +3 -0
  45. package/lib/locale/lang/uk-UA.js +3 -0
  46. package/lib/locale/lang/uk-UA.min.js +1 -1
  47. package/lib/locale/lang/uk-UA.umd.js +3 -0
  48. package/lib/locale/lang/vi-VN.js +3 -0
  49. package/lib/locale/lang/vi-VN.min.js +1 -1
  50. package/lib/locale/lang/zh-CHT.js +3 -0
  51. package/lib/locale/lang/zh-CHT.min.js +1 -1
  52. package/lib/locale/lang/zh-CHT.umd.js +3 -0
  53. package/lib/locale/lang/zh-CN.js +3 -0
  54. package/lib/locale/lang/zh-CN.min.js +1 -1
  55. package/lib/locale/lang/zh-CN.umd.js +3 -0
  56. package/lib/style.css +1 -1
  57. package/lib/table/module/edit/mixin.js +2 -16
  58. package/lib/table/module/edit/mixin.min.js +1 -1
  59. package/lib/table/src/methods.js +93 -35
  60. package/lib/table/src/methods.min.js +1 -1
  61. package/lib/table/src/table.js +28 -28
  62. package/lib/table/src/table.min.js +1 -1
  63. package/lib/ui/index.js +2 -2
  64. package/lib/ui/index.min.js +1 -1
  65. package/lib/ui/src/log.js +1 -1
  66. package/lib/ui/src/log.min.js +1 -1
  67. package/package.json +2 -2
  68. package/packages/grid/src/grid.ts +4 -4
  69. package/packages/locale/lang/en-US.ts +4 -1
  70. package/packages/locale/lang/es-ES.ts +3 -0
  71. package/packages/locale/lang/hu-HU.ts +3 -0
  72. package/packages/locale/lang/ja-JP.ts +3 -0
  73. package/packages/locale/lang/ko-KR.ts +3 -0
  74. package/packages/locale/lang/pt-BR.ts +3 -0
  75. package/packages/locale/lang/ru-RU.ts +3 -0
  76. package/packages/locale/lang/uk-UA.ts +3 -0
  77. package/packages/locale/lang/vi-VN.ts +3 -0
  78. package/packages/locale/lang/zh-CHT.ts +3 -0
  79. package/packages/locale/lang/zh-CN.ts +3 -0
  80. package/packages/table/module/edit/mixin.ts +2 -16
  81. package/packages/table/src/methods.ts +73 -22
  82. package/packages/table/src/table.ts +28 -28
  83. /package/es/{iconfont.1728348263835.ttf → iconfont.1728637870047.ttf} +0 -0
  84. /package/es/{iconfont.1728348263835.woff → iconfont.1728637870047.woff} +0 -0
  85. /package/es/{iconfont.1728348263835.woff2 → iconfont.1728637870047.woff2} +0 -0
  86. /package/lib/{iconfont.1728348263835.ttf → iconfont.1728637870047.ttf} +0 -0
  87. /package/lib/{iconfont.1728348263835.woff → iconfont.1728637870047.woff} +0 -0
  88. /package/lib/{iconfont.1728348263835.woff2 → iconfont.1728637870047.woff2} +0 -0
@@ -7,6 +7,8 @@ import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible,
7
7
  import { getSlotVNs } from '../../ui/src/vn'
8
8
  import { warnLog, errLog } from '../../ui/src/log'
9
9
 
10
+ import type { VxeTableDefines } from '../../../types'
11
+
10
12
  const { getConfig, getI18n, renderer, formats, interceptor } = VxeUI
11
13
 
12
14
  const isWebkit = browse['-webkit'] && !browse.edge
@@ -650,13 +652,14 @@ const Methods = {
650
652
  * 更新数据行的 Map
651
653
  * 牺牲数据组装的耗时,用来换取使用过程中的流畅
652
654
  */
653
- cacheRowMap (source: any) {
654
- const { treeConfig, treeOpts, tableFullData, fullDataRowMap, fullAllDataRowMap, tableFullTreeData } = this
655
- let { fullDataRowIdData, fullAllDataRowIdData } = this
655
+ cacheRowMap (isSource?: boolean) {
656
+ const { treeConfig, treeOpts, tableFullData, fullAllDataRowIdData, fullAllDataRowMap, tableFullTreeData } = this
656
657
  const childrenField = treeOpts.children || treeOpts.childrenField
657
658
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
658
659
  const rowkey = getRowkey(this)
659
660
  const isLazy = treeConfig && treeOpts.lazy
661
+ const fullAllDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = {}
662
+ const fullDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = {}
660
663
  const handleCache = (row: any, index: any, items: any, path: any, parent: any, nodes: any) => {
661
664
  let rowid = getRowid(this, row)
662
665
  const seq = treeConfig && path ? toTreePathSeq(path) : index + 1
@@ -668,19 +671,20 @@ const Methods = {
668
671
  if (isLazy && row[hasChildField] && XEUtils.isUndefined(row[childrenField])) {
669
672
  row[childrenField] = null
670
673
  }
671
- const rest = { row, rowid, seq, index: treeConfig && parent ? -1 : index, _index: -1, $index: -1, items, parent, level }
672
- if (source) {
673
- fullDataRowIdData[rowid] = rest
674
- fullDataRowMap.set(row, rest)
674
+ let cacheItem = fullAllDataRowIdData[rowid]
675
+ if (!cacheItem) {
676
+ cacheItem = { row, rowid, seq, index: -1, _index: -1, $index: -1, items, parent, level }
677
+ }
678
+ if (isSource) {
679
+ cacheItem.index = treeConfig && parent ? -1 : index
680
+ fullDataRowIdMaps[rowid] = cacheItem
675
681
  }
676
- fullAllDataRowIdData[rowid] = rest
677
- fullAllDataRowMap.set(row, rest)
682
+ fullAllDataRowIdMaps[rowid] = cacheItem
678
683
  }
679
- if (source) {
680
- fullDataRowIdData = this.fullDataRowIdData = {}
681
- fullDataRowMap.clear()
684
+ if (isSource) {
685
+ this.fullDataRowIdData = fullDataRowIdMaps
682
686
  }
683
- fullAllDataRowIdData = this.fullAllDataRowIdData = {}
687
+ this.fullAllDataRowIdData = fullAllDataRowIdMaps
684
688
  fullAllDataRowMap.clear()
685
689
  if (treeConfig) {
686
690
  XEUtils.eachTree(tableFullTreeData, handleCache, { children: childrenField })
@@ -910,10 +914,10 @@ const Methods = {
910
914
  * @param {Row} row 行对象
911
915
  */
912
916
  getRowSeq (row: any) {
913
- const { fullDataRowIdData } = this
917
+ const { fullAllDataRowIdData } = this
914
918
  if (row) {
915
919
  const rowid = getRowid(this, row)
916
- const rest = fullDataRowIdData[rowid]
920
+ const rest = fullAllDataRowIdData[rowid]
917
921
  if (rest) {
918
922
  return rest.seq
919
923
  }
@@ -925,14 +929,30 @@ const Methods = {
925
929
  * @param {Row} row 行对象
926
930
  */
927
931
  getRowIndex (row: any) {
928
- return this.fullDataRowMap.has(row) ? this.fullDataRowMap.get(row).index : -1
932
+ const { fullAllDataRowIdData } = this
933
+ if (row) {
934
+ const rowid = getRowid(this, row)
935
+ const rest = fullAllDataRowIdData[rowid]
936
+ if (rest) {
937
+ return rest.index
938
+ }
939
+ }
940
+ return -1
929
941
  },
930
942
  /**
931
943
  * 根据 row 获取相对于当前数据中的索引
932
944
  * @param {Row} row 行对象
933
945
  */
934
946
  getVTRowIndex (row: any) {
935
- return this.afterFullData.indexOf(row)
947
+ const { fullAllDataRowIdData } = this
948
+ if (row) {
949
+ const rowid = getRowid(this, row)
950
+ const rest = fullAllDataRowIdData[rowid]
951
+ if (rest) {
952
+ return rest._index
953
+ }
954
+ }
955
+ return -1
936
956
  },
937
957
  // 在 v3 中废弃
938
958
  _getRowIndex (row: any) {
@@ -946,7 +966,15 @@ const Methods = {
946
966
  * @param {Row} row 行对象
947
967
  */
948
968
  getVMRowIndex (row: any) {
949
- return this.tableData.indexOf(row)
969
+ const { fullAllDataRowIdData } = this
970
+ if (row) {
971
+ const rowid = getRowid(this, row)
972
+ const rest = fullAllDataRowIdData[rowid]
973
+ if (rest) {
974
+ return rest.$index
975
+ }
976
+ }
977
+ return -1
950
978
  },
951
979
  // 在 v3 中废弃
952
980
  $getRowIndex (row: any) {
@@ -960,14 +988,28 @@ const Methods = {
960
988
  * @param {ColumnInfo} column 列配置
961
989
  */
962
990
  getColumnIndex (column: any) {
963
- return this.fullColumnMap.has(column) ? this.fullColumnMap.get(column).index : -1
991
+ const { fullColumnIdData } = this
992
+ if (column) {
993
+ const rest = fullColumnIdData[column.id]
994
+ if (rest) {
995
+ return rest.index
996
+ }
997
+ }
998
+ return -1
964
999
  },
965
1000
  /**
966
1001
  * 根据 column 获取相对于当前表格列中的索引
967
1002
  * @param {ColumnInfo} column 列配置
968
1003
  */
969
1004
  getVTColumnIndex (column: any) {
970
- return this.visibleColumn.indexOf(column)
1005
+ const { fullColumnIdData } = this
1006
+ if (column) {
1007
+ const rest = fullColumnIdData[column.id]
1008
+ if (rest) {
1009
+ return rest._index
1010
+ }
1011
+ }
1012
+ return -1
971
1013
  },
972
1014
  // 在 v3 中废弃
973
1015
  _getColumnIndex (column: any) {
@@ -981,7 +1023,14 @@ const Methods = {
981
1023
  * @param {ColumnInfo} column 列配置
982
1024
  */
983
1025
  getVMColumnIndex (column: any) {
984
- return this.tableColumn.indexOf(column)
1026
+ const { fullColumnIdData } = this
1027
+ if (column) {
1028
+ const rest = fullColumnIdData[column.id]
1029
+ if (rest) {
1030
+ return rest.$index
1031
+ }
1032
+ }
1033
+ return -1
985
1034
  },
986
1035
  // 在 v3 中废弃
987
1036
  $getColumnIndex (column: any) {
@@ -2147,7 +2196,9 @@ const Methods = {
2147
2196
  })
2148
2197
  } else {
2149
2198
  const labelEl = cellEl.firstChild as HTMLElement
2150
- titleWidth = labelEl.offsetWidth
2199
+ if (labelEl) {
2200
+ titleWidth = labelEl.offsetWidth
2201
+ }
2151
2202
  }
2152
2203
  if (titleWidth) {
2153
2204
  colWidth = Math.max(colWidth, Math.ceil(titleWidth) + 4)
@@ -373,19 +373,19 @@ export default {
373
373
  return this.computeValidOpts
374
374
  },
375
375
  computeValidOpts () {
376
- return Object.assign({ message: 'default' }, XEUtils.clone(getConfig().table.validConfig, true), this.validConfig)
376
+ return Object.assign({ message: 'default' }, getConfig().table.validConfig, this.validConfig)
377
377
  },
378
378
  sXOpts () {
379
379
  return this.computeSXOpts
380
380
  },
381
381
  computeSXOpts () {
382
- return Object.assign({}, XEUtils.clone(getConfig().table.scrollX, true), this.scrollX)
382
+ return Object.assign({}, getConfig().table.scrollX, this.scrollX)
383
383
  },
384
384
  sYOpts () {
385
385
  return this.computeSYOpts
386
386
  },
387
387
  computeSYOpts () {
388
- return Object.assign({}, XEUtils.clone(getConfig().table.scrollY, true), this.scrollY)
388
+ return Object.assign({}, getConfig().table.scrollY, this.scrollY)
389
389
  },
390
390
  rowHeightMaps () {
391
391
  return {
@@ -399,49 +399,49 @@ export default {
399
399
  return this.computeColumnOpts
400
400
  },
401
401
  computeColumnOpts () {
402
- return Object.assign({}, XEUtils.clone(getConfig().table.columnConfig, true), this.columnConfig)
402
+ return Object.assign({}, getConfig().table.columnConfig, this.columnConfig)
403
403
  },
404
404
  rowOpts () {
405
405
  return this.computeRowOpts
406
406
  },
407
407
  computeRowOpts () {
408
- return Object.assign({}, XEUtils.clone(getConfig().table.rowConfig, true), this.rowConfig)
408
+ return Object.assign({}, getConfig().table.rowConfig, this.rowConfig)
409
409
  },
410
410
  resizeOpts () {
411
411
  return this.computeResizeOpts
412
412
  },
413
413
  computeResizeOpts () {
414
- return Object.assign({}, XEUtils.clone(getConfig().table.resizeConfig, true), this.resizeConfig)
414
+ return Object.assign({}, getConfig().table.resizeConfig, this.resizeConfig)
415
415
  },
416
416
  resizableOpts () {
417
417
  return this.computeResizableOpts
418
418
  },
419
419
  computeResizableOpts () {
420
- return Object.assign({}, XEUtils.clone(getConfig().table.resizableConfig, true), this.resizableConfig)
420
+ return Object.assign({}, getConfig().table.resizableConfig, this.resizableConfig)
421
421
  },
422
422
  seqOpts () {
423
423
  return this.computeSeqOpts
424
424
  },
425
425
  computeSeqOpts () {
426
- return Object.assign({ startIndex: 0 }, XEUtils.clone(getConfig().table.seqConfig, true), this.seqConfig)
426
+ return Object.assign({ startIndex: 0 }, getConfig().table.seqConfig, this.seqConfig)
427
427
  },
428
428
  radioOpts () {
429
429
  return this.computeRadioOpts
430
430
  },
431
431
  computeRadioOpts () {
432
- return Object.assign({}, XEUtils.clone(getConfig().table.radioConfig, true), this.radioConfig)
432
+ return Object.assign({}, getConfig().table.radioConfig, this.radioConfig)
433
433
  },
434
434
  checkboxOpts () {
435
435
  return this.computeCheckboxOpts
436
436
  },
437
437
  computeCheckboxOpts () {
438
- return Object.assign({}, XEUtils.clone(getConfig().table.checkboxConfig, true), this.checkboxConfig)
438
+ return Object.assign({}, getConfig().table.checkboxConfig, this.checkboxConfig)
439
439
  },
440
440
  tooltipOpts () {
441
441
  return this.computeTooltipOpts
442
442
  },
443
443
  computeTooltipOpts () {
444
- return Object.assign({}, XEUtils.clone(getConfig().tooltip, true), XEUtils.clone(getConfig().table.tooltipConfig, true), this.tooltipConfig)
444
+ return Object.assign({}, getConfig().tooltip, getConfig().table.tooltipConfig, this.tooltipConfig)
445
445
  },
446
446
  tipConfig () {
447
447
  return { ...this.tooltipOpts }
@@ -453,49 +453,49 @@ export default {
453
453
  return this.computeEditOpts
454
454
  },
455
455
  computeEditOpts () {
456
- return Object.assign({}, XEUtils.clone(getConfig().table.editConfig, true), this.editConfig)
456
+ return Object.assign({}, getConfig().table.editConfig, this.editConfig)
457
457
  },
458
458
  sortOpts () {
459
459
  return this.computeSortOpts
460
460
  },
461
461
  computeSortOpts () {
462
- return Object.assign({ orders: ['asc', 'desc', null] }, XEUtils.clone(getConfig().table.sortConfig, true), this.sortConfig)
462
+ return Object.assign({ orders: ['asc', 'desc', null] }, getConfig().table.sortConfig, this.sortConfig)
463
463
  },
464
464
  filterOpts () {
465
465
  return this.computeFilterOpts
466
466
  },
467
467
  computeFilterOpts () {
468
- return Object.assign({}, XEUtils.clone(getConfig().table.filterConfig, true), this.filterConfig)
468
+ return Object.assign({}, getConfig().table.filterConfig, this.filterConfig)
469
469
  },
470
470
  mouseOpts () {
471
471
  return this.computeMouseOpts
472
472
  },
473
473
  computeMouseOpts () {
474
- return Object.assign({}, XEUtils.clone(getConfig().table.mouseConfig, true), this.mouseConfig)
474
+ return Object.assign({}, getConfig().table.mouseConfig, this.mouseConfig)
475
475
  },
476
476
  areaOpts () {
477
477
  return this.computeAreaOpts
478
478
  },
479
479
  computeAreaOpts () {
480
- return Object.assign({}, XEUtils.clone(getConfig().table.areaConfig, true), this.areaConfig)
480
+ return Object.assign({}, getConfig().table.areaConfig, this.areaConfig)
481
481
  },
482
482
  keyboardOpts () {
483
483
  return this.computeKeyboardOpts
484
484
  },
485
485
  computeKeyboardOpts () {
486
- return Object.assign({}, XEUtils.clone(getConfig().table.keyboardConfig, true), this.keyboardConfig)
486
+ return Object.assign({}, getConfig().table.keyboardConfig, this.keyboardConfig)
487
487
  },
488
488
  clipOpts () {
489
489
  return this.computeClipOpts
490
490
  },
491
491
  computeClipOpts () {
492
- return Object.assign({}, XEUtils.clone(getConfig().table.clipConfig, true), this.clipConfig)
492
+ return Object.assign({}, getConfig().table.clipConfig, this.clipConfig)
493
493
  },
494
494
  fnrOpts () {
495
495
  return this.computeFNROpts
496
496
  },
497
497
  computeFNROpts () {
498
- return Object.assign({}, XEUtils.clone(getConfig().table.fnrConfig, true), this.fnrConfig)
498
+ return Object.assign({}, getConfig().table.fnrConfig, this.fnrConfig)
499
499
  },
500
500
  headerCtxMenu () {
501
501
  const headerOpts = this.ctxMenuOpts.header
@@ -525,49 +525,49 @@ export default {
525
525
  return this.computeMenuOpts
526
526
  },
527
527
  computeMenuOpts () {
528
- return Object.assign({}, XEUtils.clone(getConfig().table.menuConfig, true), this.contextMenu, this.menuConfig)
528
+ return Object.assign({}, getConfig().table.menuConfig, this.contextMenu, this.menuConfig)
529
529
  },
530
530
  exportOpts () {
531
531
  return this.computeExportOpts
532
532
  },
533
533
  computeExportOpts () {
534
- return Object.assign({}, XEUtils.clone(getConfig().table.exportConfig, true), this.exportConfig)
534
+ return Object.assign({}, getConfig().table.exportConfig, this.exportConfig)
535
535
  },
536
536
  importOpts () {
537
537
  return this.computeImportOpts
538
538
  },
539
539
  computeImportOpts () {
540
- return Object.assign({}, XEUtils.clone(getConfig().table.importConfig, true), this.importConfig)
540
+ return Object.assign({}, getConfig().table.importConfig, this.importConfig)
541
541
  },
542
542
  printOpts () {
543
543
  return this.computePrintOpts
544
544
  },
545
545
  computePrintOpts () {
546
- return Object.assign({}, XEUtils.clone(getConfig().table.printConfig, true), this.printConfig)
546
+ return Object.assign({}, getConfig().table.printConfig, this.printConfig)
547
547
  },
548
548
  expandOpts () {
549
549
  return this.computeExpandOpts
550
550
  },
551
551
  computeExpandOpts () {
552
- return Object.assign({}, XEUtils.clone(getConfig().table.expandConfig, true), this.expandConfig)
552
+ return Object.assign({}, getConfig().table.expandConfig, this.expandConfig)
553
553
  },
554
554
  treeOpts () {
555
555
  return this.computeTreeOpts
556
556
  },
557
557
  computeTreeOpts () {
558
- return Object.assign({}, XEUtils.clone(getConfig().table.treeConfig, true), this.treeConfig)
558
+ return Object.assign({}, getConfig().table.treeConfig, this.treeConfig)
559
559
  },
560
560
  emptyOpts () {
561
561
  return this.computeEmptyOpts
562
562
  },
563
563
  computeEmptyOpts () {
564
- return Object.assign({}, XEUtils.clone(getConfig().table.emptyRender, true), this.emptyRender)
564
+ return Object.assign({}, getConfig().table.emptyRender, this.emptyRender)
565
565
  },
566
566
  loadingOpts () {
567
567
  return this.computeLoadingOpts
568
568
  },
569
569
  computeLoadingOpts () {
570
- return Object.assign({}, XEUtils.clone(getConfig().table.loadingConfig, true), this.loadingConfig)
570
+ return Object.assign({}, getConfig().table.loadingConfig, this.loadingConfig)
571
571
  },
572
572
  cellOffsetWidth () {
573
573
  return this.border ? Math.max(2, Math.ceil(this.scrollbarWidth / this.tableColumn.length)) : 1
@@ -576,7 +576,7 @@ export default {
576
576
  return this.computeCustomOpts
577
577
  },
578
578
  computeCustomOpts () {
579
- return Object.assign({}, XEUtils.clone(getConfig().table.customConfig, true), this.customConfig)
579
+ return Object.assign({}, getConfig().table.customConfig, this.customConfig)
580
580
  },
581
581
  autoWidthColumnList () {
582
582
  const { tableColumn, visibleColumn } = this