@kdcloudjs/table 1.1.2 → 1.1.3-canary.3

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.
@@ -658,7 +658,12 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
658
658
  offsetY: offsetY
659
659
  };
660
660
  }), op.distinctUntilChanged(function (x, y) {
661
- // 因为 overscan 的存在,滚动较小的距离时不需要触发组件重渲染
661
+ // 如果表格区域被隐藏, 不需要触发组件重渲染
662
+ if (y.maxRenderHeight === 0 && y.maxRenderWidth === 0) {
663
+ return true;
664
+ } // 因为 overscan 的存在,滚动较小的距离时不需要触发组件重渲染
665
+
666
+
662
667
  return Math.abs(x.maxRenderWidth - y.maxRenderWidth) < OVERSCAN_SIZE / 2 && Math.abs(x.maxRenderHeight - y.maxRenderHeight) < OVERSCAN_SIZE / 2 && Math.abs(x.offsetY - y.offsetY) < OVERSCAN_SIZE / 2;
663
668
  })).subscribe(function (sizeAndOffset) {
664
669
  _this2.setState(sizeAndOffset);
@@ -750,10 +755,12 @@ export var BaseTable = /*#__PURE__*/function (_React$Component) {
750
755
 
751
756
  if (size === 0) {
752
757
  zeroHeightRowCount += 1;
758
+ } else {
759
+ // 渲染出来的行高度为0,说明是display=none情况,行高不存在该种异常情况,不保存当前的高度
760
+ this.rowHeightManager.updateRow(rowIndex, offset, size);
753
761
  }
754
762
 
755
763
  maxTrBottom = Math.max(maxTrBottom, offset + size);
756
- this.rowHeightManager.updateRow(rowIndex, offset, size);
757
764
  } // 当 estimatedRowHeight 过大时,可能出现「渲染行数过少,无法覆盖可视范围」的情况
758
765
  // 出现这种情况时,我们判断「下一次渲染能够渲染更多行」是否满足,满足的话就直接调用 forceUpdate
759
766
  // zeroHeightRowCount === 0 用于确保当前没有 display=none 的情况
@@ -7,6 +7,10 @@ import { FILL_COLUMN_CODE } from './autoFill';
7
7
  var stateKey = 'columnDrag';
8
8
  var SCROLL_SIZE = 30;
9
9
 
10
+ function disableSelect(event) {
11
+ event.preventDefault();
12
+ }
13
+
10
14
  function sortColumns(columns, sort) {
11
15
  var res = new Array(columns.length);
12
16
 
@@ -63,7 +67,9 @@ export function columnDrag() {
63
67
  onMouseDown: !isLeaf || path.length > 1 ? undefined : function (e) {
64
68
  if (e.button !== 0) {
65
69
  return;
66
- } // const cx = e.clientX
70
+ }
71
+
72
+ window.addEventListener('selectstart', disableSelect); // const cx = e.clientX
67
73
  // const width = col.width
68
74
  // const a = startIndex
69
75
  // const b = endIndex
@@ -72,7 +78,6 @@ export function columnDrag() {
72
78
  // let newStartIndex = startIndex
73
79
  // let endIdx = endIndex
74
80
 
75
-
76
81
  var columnMoved = false;
77
82
  var columns = pipeline.getColumns();
78
83
 
@@ -245,6 +250,7 @@ export function columnDrag() {
245
250
  e.stopPropagation();
246
251
  document.body.removeEventListener('mousemove', handleMouseMove);
247
252
  document.body.removeEventListener('mouseup', handleMouseUp);
253
+ window.removeEventListener('selectstart', disableSelect);
248
254
  window.requestAnimationFrame(function () {
249
255
  // 取消阻止列头点击事件
250
256
  currentTarget.removeEventListener('click', stopClickPropagation);
@@ -330,10 +336,6 @@ export function columnDrag() {
330
336
 
331
337
  document.body.addEventListener('mousemove', handleMouseMove);
332
338
  document.body.addEventListener('mouseup', handleMouseUp);
333
-
334
- document.body.onselectstart = function () {
335
- return false;
336
- };
337
339
  },
338
340
  style: style
339
341
  })
@@ -53,6 +53,7 @@ export function contextMenu() {
53
53
  }
54
54
 
55
55
  e.preventDefault();
56
+ e.stopPropagation();
56
57
  showContextMenu(e);
57
58
  };
58
59
 
@@ -705,7 +705,12 @@ var BaseTable = /*#__PURE__*/function (_React$Component) {
705
705
  offsetY: offsetY
706
706
  };
707
707
  }), op.distinctUntilChanged(function (x, y) {
708
- // 因为 overscan 的存在,滚动较小的距离时不需要触发组件重渲染
708
+ // 如果表格区域被隐藏, 不需要触发组件重渲染
709
+ if (y.maxRenderHeight === 0 && y.maxRenderWidth === 0) {
710
+ return true;
711
+ } // 因为 overscan 的存在,滚动较小的距离时不需要触发组件重渲染
712
+
713
+
709
714
  return Math.abs(x.maxRenderWidth - y.maxRenderWidth) < _utils.OVERSCAN_SIZE / 2 && Math.abs(x.maxRenderHeight - y.maxRenderHeight) < _utils.OVERSCAN_SIZE / 2 && Math.abs(x.offsetY - y.offsetY) < _utils.OVERSCAN_SIZE / 2;
710
715
  })).subscribe(function (sizeAndOffset) {
711
716
  _this2.setState(sizeAndOffset);
@@ -797,10 +802,12 @@ var BaseTable = /*#__PURE__*/function (_React$Component) {
797
802
 
798
803
  if (size === 0) {
799
804
  zeroHeightRowCount += 1;
805
+ } else {
806
+ // 渲染出来的行高度为0,说明是display=none情况,行高不存在该种异常情况,不保存当前的高度
807
+ this.rowHeightManager.updateRow(rowIndex, offset, size);
800
808
  }
801
809
 
802
810
  maxTrBottom = Math.max(maxTrBottom, offset + size);
803
- this.rowHeightManager.updateRow(rowIndex, offset, size);
804
811
  } // 当 estimatedRowHeight 过大时,可能出现「渲染行数过少,无法覆盖可视范围」的情况
805
812
  // 出现这种情况时,我们判断「下一次渲染能够渲染更多行」是否满足,满足的话就直接调用 forceUpdate
806
813
  // zeroHeightRowCount === 0 用于确保当前没有 display=none 的情况
@@ -22,6 +22,10 @@ var _autoFill = require("./autoFill");
22
22
  var stateKey = 'columnDrag';
23
23
  var SCROLL_SIZE = 30;
24
24
 
25
+ function disableSelect(event) {
26
+ event.preventDefault();
27
+ }
28
+
25
29
  function sortColumns(columns, sort) {
26
30
  var res = new Array(columns.length);
27
31
  var lastColumns = (0, _toConsumableArray2.default)(columns);
@@ -77,7 +81,9 @@ function columnDrag() {
77
81
  onMouseDown: !isLeaf || path.length > 1 ? undefined : function (e) {
78
82
  if (e.button !== 0) {
79
83
  return;
80
- } // const cx = e.clientX
84
+ }
85
+
86
+ window.addEventListener('selectstart', disableSelect); // const cx = e.clientX
81
87
  // const width = col.width
82
88
  // const a = startIndex
83
89
  // const b = endIndex
@@ -86,7 +92,6 @@ function columnDrag() {
86
92
  // let newStartIndex = startIndex
87
93
  // let endIdx = endIndex
88
94
 
89
-
90
95
  var columnMoved = false;
91
96
  var columns = pipeline.getColumns();
92
97
 
@@ -259,6 +264,7 @@ function columnDrag() {
259
264
  e.stopPropagation();
260
265
  document.body.removeEventListener('mousemove', handleMouseMove);
261
266
  document.body.removeEventListener('mouseup', handleMouseUp);
267
+ window.removeEventListener('selectstart', disableSelect);
262
268
  window.requestAnimationFrame(function () {
263
269
  // 取消阻止列头点击事件
264
270
  currentTarget.removeEventListener('click', stopClickPropagation);
@@ -343,10 +349,6 @@ function columnDrag() {
343
349
 
344
350
  document.body.addEventListener('mousemove', handleMouseMove);
345
351
  document.body.addEventListener('mouseup', handleMouseUp);
346
-
347
- document.body.onselectstart = function () {
348
- return false;
349
- };
350
352
  },
351
353
  style: style
352
354
  })
@@ -87,6 +87,7 @@ function contextMenu() {
87
87
  }
88
88
 
89
89
  e.preventDefault();
90
+ e.stopPropagation();
90
91
  showContextMenu(e);
91
92
  };
92
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/table",
3
- "version": "1.1.2",
3
+ "version": "1.1.3-canary.3",
4
4
  "description": "金蝶 react table 组件",
5
5
  "title": "table",
6
6
  "keywords": [
@@ -55,7 +55,7 @@
55
55
  "test:ci": "jest --config .jest.js --coverage --ci --update-snapshot",
56
56
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --skip-unstable",
57
57
  "pub": "npm run test:all && npm run build && cross-env PUB_ENV=pub np --no-cleanup --no-tests",
58
- "pub:beta": "npm run test:all && npm run build && cross-env PUB_ENV=pub np --no-cleanup --anyBranch --no-tests --tag=beta",
58
+ "pub:canary": "npm run build && cross-env PUB_ENV=pub np --no-cleanup --anyBranch --no-tests --tag=canary",
59
59
  "new": "node scripts/create-component.js",
60
60
  "kd-ui": "npm install @kingdee-ui/kui --registry http://npm.kingdee.com/"
61
61
  },