vxe-table 4.1.4 → 4.1.7

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 (39) hide show
  1. package/es/edit/src/hook.js +189 -69
  2. package/es/form/src/form.js +2 -2
  3. package/es/input/src/input.js +8 -2
  4. package/es/table/src/body.js +6 -3
  5. package/es/table/src/props.js +6 -6
  6. package/es/table/src/table.js +53 -42
  7. package/es/v-x-e-table/src/conf.js +4 -1
  8. package/es/validator/src/hook.js +3 -3
  9. package/lib/edit/src/hook.js +243 -70
  10. package/lib/edit/src/hook.min.js +1 -1
  11. package/lib/form/src/form.js +2 -2
  12. package/lib/form/src/form.min.js +1 -1
  13. package/lib/index.umd.js +340 -224
  14. package/lib/index.umd.min.js +2 -1
  15. package/lib/input/src/input.js +10 -2
  16. package/lib/input/src/input.min.js +1 -1
  17. package/lib/table/src/body.js +6 -3
  18. package/lib/table/src/body.min.js +1 -1
  19. package/lib/table/src/props.js +6 -6
  20. package/lib/table/src/table.js +57 -45
  21. package/lib/table/src/table.min.js +1 -1
  22. package/lib/v-x-e-table/src/conf.js +4 -1
  23. package/lib/v-x-e-table/src/conf.min.js +1 -1
  24. package/lib/validator/src/hook.js +3 -3
  25. package/lib/validator/src/hook.min.js +1 -1
  26. package/package.json +3 -26
  27. package/packages/edit/src/hook.ts +183 -69
  28. package/packages/form/src/form.ts +2 -2
  29. package/packages/input/src/input.ts +9 -2
  30. package/packages/table/src/body.ts +6 -3
  31. package/packages/table/src/props.ts +6 -6
  32. package/packages/table/src/table.ts +52 -40
  33. package/packages/v-x-e-table/src/conf.ts +4 -1
  34. package/packages/v-x-e-table/src/renderer.ts +1 -1
  35. package/packages/validator/src/hook.ts +3 -3
  36. package/types/edit.d.ts +6 -3
  37. package/types/plugins/pro.d.ts +6 -6
  38. package/types/table.d.ts +9 -0
  39. package/types/v-x-e-table/renderer.d.ts +4 -2
@@ -2866,18 +2866,15 @@ var _default = (0, _vue.defineComponent)({
2866
2866
 
2867
2867
  if (oRow && row) {
2868
2868
  if (field) {
2869
- _xeUtils.default.set(oRow, field, _xeUtils.default.get(record || row, field));
2870
- } else {
2871
- if (record) {
2872
- tableSourceData[rowIndex] = record;
2869
+ var newValue = _xeUtils.default.get(record || row, field);
2873
2870
 
2874
- _xeUtils.default.clear(row, undefined);
2871
+ _xeUtils.default.set(row, field, newValue);
2875
2872
 
2876
- Object.assign(row, tablePrivateMethods.defineField(Object.assign({}, record)));
2877
- tablePrivateMethods.cacheRowMap(true);
2878
- } else {
2879
- _xeUtils.default.destructuring(oRow, _xeUtils.default.clone(row, true));
2880
- }
2873
+ _xeUtils.default.set(oRow, field, newValue);
2874
+ } else {
2875
+ var newRecord = _xeUtils.default.clone(__assign({}, record), true);
2876
+
2877
+ _xeUtils.default.destructuring(oRow, Object.assign(row, newRecord));
2881
2878
  }
2882
2879
  }
2883
2880
 
@@ -2901,8 +2898,8 @@ var _default = (0, _vue.defineComponent)({
2901
2898
  fullAllDataRowIdData = internalData.fullAllDataRowIdData;
2902
2899
  var treeOpts = computeTreeOpts.value;
2903
2900
  var children = treeOpts.children;
2904
- var rest = fullAllDataRowIdData[(0, _util.getRowid)($xetable, row)];
2905
- var parentLevel = rest ? rest.level : 0;
2901
+ var parentRest = fullAllDataRowIdData[(0, _util.getRowid)($xetable, row)];
2902
+ var parentLevel = parentRest ? parentRest.level : 0;
2906
2903
  return tableMethods.createData(childRecords).then(function (rows) {
2907
2904
  if (keepSource) {
2908
2905
  var rowid_1 = (0, _util.getRowid)($xetable, row);
@@ -3881,6 +3878,18 @@ var _default = (0, _vue.defineComponent)({
3881
3878
  var reserveSelection = [];
3882
3879
 
3883
3880
  if (checkboxOpts.reserve) {
3881
+ var afterFullIdMaps_1 = {};
3882
+
3883
+ if (treeConfig) {
3884
+ _xeUtils.default.eachTree(afterFullData, function (row) {
3885
+ afterFullIdMaps_1[(0, _util.getRowid)($xetable, row)] = 1;
3886
+ }, treeOpts);
3887
+ } else {
3888
+ afterFullData.forEach(function (row) {
3889
+ afterFullIdMaps_1[(0, _util.getRowid)($xetable, row)] = 1;
3890
+ });
3891
+ }
3892
+
3884
3893
  _xeUtils.default.each(checkboxReserveRowMap, function (oldRow, oldRowid) {
3885
3894
  if (oldRow) {
3886
3895
  if (isFull) {
@@ -3888,18 +3897,8 @@ var _default = (0, _vue.defineComponent)({
3888
3897
  reserveSelection.push(oldRow);
3889
3898
  }
3890
3899
  } else {
3891
- if (treeConfig) {
3892
- if (!_xeUtils.default.findTree(afterFullData, function (row) {
3893
- return (0, _util.getRowid)($xetable, row) === oldRowid;
3894
- }, treeOpts)) {
3895
- reserveSelection.push(oldRow);
3896
- }
3897
- } else {
3898
- if (!afterFullData.some(function (row) {
3899
- return (0, _util.getRowid)($xetable, row) === oldRowid;
3900
- })) {
3901
- reserveSelection.push(oldRow);
3902
- }
3900
+ if (!afterFullIdMaps_1[oldRowid]) {
3901
+ reserveSelection.push(oldRow);
3903
3902
  }
3904
3903
  }
3905
3904
  }
@@ -3963,12 +3962,13 @@ var _default = (0, _vue.defineComponent)({
3963
3962
  * @param {Row} row 行对象
3964
3963
  */
3965
3964
  setCurrentRow: function setCurrentRow(row) {
3965
+ var rowOpts = computeRowOpts.value;
3966
3966
  var el = refElem.value;
3967
3967
  tableMethods.clearCurrentRow();
3968
3968
  tableMethods.clearCurrentColumn();
3969
3969
  reactData.currentRow = row;
3970
3970
 
3971
- if (props.highlightCurrentRow) {
3971
+ if (rowOpts.isCurrent || props.highlightCurrentRow) {
3972
3972
  if (el) {
3973
3973
  _xeUtils.default.arrayEach(el.querySelectorAll("[rowid=\"" + (0, _util.getRowid)($xetable, row) + "\"]"), function (elem) {
3974
3974
  return (0, _dom.addClass)(elem, 'row--current');
@@ -4029,7 +4029,8 @@ var _default = (0, _vue.defineComponent)({
4029
4029
  * 用于当前行,获取当前行的数据
4030
4030
  */
4031
4031
  getCurrentRecord: function getCurrentRecord() {
4032
- return props.highlightCurrentRow ? reactData.currentRow : null;
4032
+ var rowOpts = computeRowOpts.value;
4033
+ return rowOpts.isCurrent || props.highlightCurrentRow ? reactData.currentRow : null;
4033
4034
  },
4034
4035
 
4035
4036
  /**
@@ -4061,7 +4062,7 @@ var _default = (0, _vue.defineComponent)({
4061
4062
  return selectRow;
4062
4063
  }
4063
4064
  } else {
4064
- if (afterFullData.indexOf(selectRow) > -1) {
4065
+ if ($xetable.findRowIndexOf(afterFullData, selectRow) > -1) {
4065
4066
  return selectRow;
4066
4067
  }
4067
4068
  }
@@ -4071,7 +4072,8 @@ var _default = (0, _vue.defineComponent)({
4071
4072
  return null;
4072
4073
  },
4073
4074
  getCurrentColumn: function getCurrentColumn() {
4074
- return props.highlightCurrentColumn ? reactData.currentColumn : null;
4075
+ var columnOpts = computeColumnOpts.value;
4076
+ return columnOpts.isCurrent || props.highlightCurrentColumn ? reactData.currentColumn : null;
4075
4077
  },
4076
4078
 
4077
4079
  /**
@@ -5027,6 +5029,7 @@ var _default = (0, _vue.defineComponent)({
5027
5029
  ctxMenuStore = reactData.ctxMenuStore,
5028
5030
  editStore = reactData.editStore;
5029
5031
  var mouseOpts = computeMouseOpts.value;
5032
+ var keyboardOpts = computeKeyboardOpts.value;
5030
5033
  var actived = editStore.actived;
5031
5034
  var isEsc = (0, _event.hasEventKey)(evnt, _event.EVENT_KEYS.ESCAPE);
5032
5035
 
@@ -5041,16 +5044,19 @@ var _default = (0, _vue.defineComponent)({
5041
5044
  $xetable.closeMenu();
5042
5045
  }
5043
5046
 
5044
- tableMethods.closeFilter(); // 如果是激活编辑状态,则取消编辑
5047
+ tableMethods.closeFilter();
5045
5048
 
5046
- if (actived.row) {
5047
- var params_1 = actived.args;
5048
- $xetable.clearActived(evnt); // 如果配置了选中功能,则为选中状态
5049
+ if (keyboardConfig && keyboardOpts.isEsc) {
5050
+ // 如果是激活编辑状态,则取消编辑
5051
+ if (actived.row) {
5052
+ var params_1 = actived.args;
5053
+ $xetable.clearActived(evnt); // 如果配置了选中功能,则为选中状态
5049
5054
 
5050
- if (mouseOpts.selected) {
5051
- (0, _vue.nextTick)(function () {
5052
- return $xetable.handleSelected(params_1, evnt);
5053
- });
5055
+ if (mouseOpts.selected) {
5056
+ (0, _vue.nextTick)(function () {
5057
+ return $xetable.handleSelected(params_1, evnt);
5058
+ });
5059
+ }
5054
5060
  }
5055
5061
  }
5056
5062
  }
@@ -5083,6 +5089,7 @@ var _default = (0, _vue.defineComponent)({
5083
5089
  var editOpts = computeEditOpts.value;
5084
5090
  var treeOpts = computeTreeOpts.value;
5085
5091
  var menuList = computeMenuList.value;
5092
+ var rowOpts = computeRowOpts.value;
5086
5093
  var selected = editStore.selected,
5087
5094
  actived = editStore.actived;
5088
5095
  var keyCode = evnt.keyCode;
@@ -5126,7 +5133,7 @@ var _default = (0, _vue.defineComponent)({
5126
5133
 
5127
5134
  tableMethods.closeFilter();
5128
5135
 
5129
- if (actived.row) {
5136
+ if (keyboardConfig && keyboardOpts.isEsc) {
5130
5137
  // 如果是激活编辑状态,则取消编辑
5131
5138
  if (actived.row) {
5132
5139
  var params_2 = actived.args;
@@ -5163,7 +5170,7 @@ var _default = (0, _vue.defineComponent)({
5163
5170
  keyCtxTimeout = setTimeout(function () {
5164
5171
  internalData._keyCtx = false;
5165
5172
  }, 1000);
5166
- } else if (isEnter && !isAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || treeConfig && highlightCurrentRow && currentRow)) {
5173
+ } else if (isEnter && !isAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow)) {
5167
5174
  // 退出选中
5168
5175
  if (hasCtrlKey) {
5169
5176
  // 如果是激活编辑状态,则取消编辑
@@ -5195,7 +5202,7 @@ var _default = (0, _vue.defineComponent)({
5195
5202
  $xetable.moveSelected(targetArgs, isLeftArrow, false, isRightArrow, true, evnt);
5196
5203
  }
5197
5204
  }
5198
- } else if (treeConfig && highlightCurrentRow && currentRow) {
5205
+ } else if (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
5199
5206
  // 如果是树形表格当前行回车移动到子节点
5200
5207
  var childrens = currentRow[treeOpts.children];
5201
5208
 
@@ -5221,7 +5228,7 @@ var _default = (0, _vue.defineComponent)({
5221
5228
  // 如果按下了方向键
5222
5229
  if (selected.row && selected.column) {
5223
5230
  $xetable.moveSelected(selected.args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt);
5224
- } else if ((isUpArrow || isDwArrow) && highlightCurrentRow) {
5231
+ } else if ((isUpArrow || isDwArrow) && (rowOpts.isCurrent || highlightCurrentRow)) {
5225
5232
  // 当前行按键上下移动
5226
5233
  $xetable.moveCurrentRow(isUpArrow, isDwArrow, evnt);
5227
5234
  }
@@ -5233,7 +5240,7 @@ var _default = (0, _vue.defineComponent)({
5233
5240
  } else if (actived.row || actived.column) {
5234
5241
  $xetable.moveTabSelected(actived.args, hasShiftKey, evnt);
5235
5242
  }
5236
- } else if (keyboardConfig && (0, _utils.isEnableConf)(editConfig) && (isDel || (treeConfig && highlightCurrentRow && currentRow ? isBack && keyboardOpts.isArrow : isBack))) {
5243
+ } else if (keyboardConfig && (0, _utils.isEnableConf)(editConfig) && (isDel || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow ? isBack && keyboardOpts.isArrow : isBack))) {
5237
5244
  if (!isEditStatus) {
5238
5245
  var delMethod = keyboardOpts.delMethod,
5239
5246
  backMethod = keyboardOpts.backMethod; // 如果是删除键
@@ -5267,7 +5274,7 @@ var _default = (0, _vue.defineComponent)({
5267
5274
  // 如果按下 del 键,更新表尾数据
5268
5275
  tableMethods.updateFooter();
5269
5276
  }
5270
- } else if (isBack && keyboardOpts.isArrow && treeConfig && highlightCurrentRow && currentRow) {
5277
+ } else if (isBack && keyboardOpts.isArrow && treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
5271
5278
  // 如果树形表格回退键关闭当前行返回父节点
5272
5279
  var parentRow_1 = _xeUtils.default.findTree(internalData.afterFullData, function (item) {
5273
5280
  return item === currentRow;
@@ -6112,6 +6119,7 @@ var _default = (0, _vue.defineComponent)({
6112
6119
  triggerHeaderCellClickEvent: function triggerHeaderCellClickEvent(evnt, params) {
6113
6120
  var _lastResizeTime = internalData._lastResizeTime;
6114
6121
  var sortOpts = computeSortOpts.value;
6122
+ var columnOpts = computeColumnOpts.value;
6115
6123
  var column = params.column;
6116
6124
  var cell = evnt.currentTarget;
6117
6125
 
@@ -6131,7 +6139,7 @@ var _default = (0, _vue.defineComponent)({
6131
6139
  cell: cell
6132
6140
  }, params), evnt);
6133
6141
 
6134
- if (props.highlightCurrentColumn) {
6142
+ if (columnOpts.isCurrent || props.highlightCurrentColumn) {
6135
6143
  tableMethods.setCurrentColumn(column);
6136
6144
  }
6137
6145
  },
@@ -6155,6 +6163,7 @@ var _default = (0, _vue.defineComponent)({
6155
6163
  var treeOpts = computeTreeOpts.value;
6156
6164
  var radioOpts = computeRadioOpts.value;
6157
6165
  var checkboxOpts = computeCheckboxOpts.value;
6166
+ var rowOpts = computeRowOpts.value;
6158
6167
  var actived = editStore.actived;
6159
6168
  var row = params.row,
6160
6169
  column = params.column;
@@ -6192,7 +6201,7 @@ var _default = (0, _vue.defineComponent)({
6192
6201
  if (!triggerTreeNode) {
6193
6202
  if (!triggerExpandNode) {
6194
6203
  // 如果是高亮行
6195
- if (highlightCurrentRow) {
6204
+ if (rowOpts.isCurrent || highlightCurrentRow) {
6196
6205
  if (!triggerCheckbox && !triggerRadio) {
6197
6206
  tablePrivateMethods.triggerCurrentRowEvent(evnt, params);
6198
6207
  }
@@ -6586,6 +6595,7 @@ var _default = (0, _vue.defineComponent)({
6586
6595
  tablePrivateMethods.handleTableData();
6587
6596
  tablePrivateMethods.updateScrollYSpace();
6588
6597
  },
6598
+ updateVirtualTreeData: updateVirtualTreeData,
6589
6599
 
6590
6600
  /**
6591
6601
  * 处理固定列的显示状态
@@ -7236,6 +7246,8 @@ var _default = (0, _vue.defineComponent)({
7236
7246
  rightList = columnStore.rightList;
7237
7247
  var tooltipOpts = computeTooltipOpts.value;
7238
7248
  var treeOpts = computeTreeOpts.value;
7249
+ var rowOpts = computeRowOpts.value;
7250
+ var columnOpts = computeColumnOpts.value;
7239
7251
  var vSize = computeSize.value;
7240
7252
  var tableBorder = computeTableBorder.value;
7241
7253
  var mouseOpts = computeMouseOpts.value;
@@ -7244,7 +7256,7 @@ var _default = (0, _vue.defineComponent)({
7244
7256
  var isMenu = computeIsMenu.value;
7245
7257
  return (0, _vue.h)('div', {
7246
7258
  ref: refElem,
7247
- class: ['vxe-table', 'vxe-table--render-default', "tid_" + xID, "border--" + tableBorder, (_a = {}, _a["size--" + vSize] = vSize, _a['vxe-editable'] = !!editConfig, _a['cell--highlight'] = highlightCell, _a['cell--selected'] = mouseConfig && mouseOpts.selected, _a['cell--area'] = mouseConfig && mouseOpts.area, _a['row--highlight'] = highlightHoverRow, _a['column--highlight'] = highlightHoverColumn, _a['is--header'] = showHeader, _a['is--footer'] = showFooter, _a['is--group'] = isGroup, _a['is--tree-line'] = treeConfig && treeOpts.line, _a['is--fixed-left'] = leftList.length, _a['is--fixed-right'] = rightList.length, _a['is--animat'] = !!props.animat, _a['is--round'] = props.round, _a['is--stripe'] = !treeConfig && stripe, _a['is--loading'] = loading, _a['is--empty'] = !loading && !tableData.length, _a['is--scroll-y'] = overflowY, _a['is--scroll-x'] = overflowX, _a['is--virtual-x'] = scrollXLoad, _a['is--virtual-y'] = scrollYLoad, _a)],
7259
+ class: ['vxe-table', 'vxe-table--render-default', "tid_" + xID, "border--" + tableBorder, (_a = {}, _a["size--" + vSize] = vSize, _a['vxe-editable'] = !!editConfig, _a['cell--highlight'] = highlightCell, _a['cell--selected'] = mouseConfig && mouseOpts.selected, _a['cell--area'] = mouseConfig && mouseOpts.area, _a['row--highlight'] = rowOpts.isHover || highlightHoverRow, _a['column--highlight'] = columnOpts.isHover || highlightHoverColumn, _a['is--header'] = showHeader, _a['is--footer'] = showFooter, _a['is--group'] = isGroup, _a['is--tree-line'] = treeConfig && treeOpts.line, _a['is--fixed-left'] = leftList.length, _a['is--fixed-right'] = rightList.length, _a['is--animat'] = !!props.animat, _a['is--round'] = props.round, _a['is--stripe'] = !treeConfig && stripe, _a['is--loading'] = loading, _a['is--empty'] = !loading && !tableData.length, _a['is--scroll-y'] = overflowY, _a['is--scroll-x'] = overflowX, _a['is--virtual-x'] = scrollXLoad, _a['is--virtual-y'] = scrollYLoad, _a)],
7248
7260
  onKeydown: keydownEvent
7249
7261
  }, [
7250
7262
  /**