vxe-table 4.10.11 → 4.10.13

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 (56) hide show
  1. package/es/index.css +1 -1
  2. package/es/index.min.css +1 -1
  3. package/es/style.css +1 -1
  4. package/es/style.min.css +1 -1
  5. package/es/table/module/edit/hook.js +7 -8
  6. package/es/table/module/export/hook.js +3 -2
  7. package/es/table/module/validator/hook.js +11 -0
  8. package/es/table/render/index.js +104 -43
  9. package/es/table/src/body.js +1 -0
  10. package/es/table/src/table.js +41 -31
  11. package/es/table/style.css +10 -2
  12. package/es/table/style.min.css +1 -1
  13. package/es/ui/index.js +1 -1
  14. package/es/ui/src/log.js +1 -1
  15. package/es/vxe-table/style.css +10 -2
  16. package/es/vxe-table/style.min.css +1 -1
  17. package/lib/index.css +1 -1
  18. package/lib/index.min.css +1 -1
  19. package/lib/index.umd.js +193 -95
  20. package/lib/index.umd.min.js +1 -1
  21. package/lib/style.css +1 -1
  22. package/lib/style.min.css +1 -1
  23. package/lib/table/module/edit/hook.js +7 -8
  24. package/lib/table/module/edit/hook.min.js +1 -1
  25. package/lib/table/module/export/hook.js +3 -2
  26. package/lib/table/module/export/hook.min.js +1 -1
  27. package/lib/table/module/validator/hook.js +16 -0
  28. package/lib/table/module/validator/hook.min.js +1 -1
  29. package/lib/table/render/index.js +109 -41
  30. package/lib/table/render/index.min.js +1 -1
  31. package/lib/table/src/body.js +1 -0
  32. package/lib/table/src/body.min.js +1 -1
  33. package/lib/table/src/table.js +55 -42
  34. package/lib/table/src/table.min.js +1 -1
  35. package/lib/table/style/style.css +10 -2
  36. package/lib/table/style/style.min.css +1 -1
  37. package/lib/ui/index.js +1 -1
  38. package/lib/ui/index.min.js +1 -1
  39. package/lib/ui/src/log.js +1 -1
  40. package/lib/ui/src/log.min.js +1 -1
  41. package/lib/vxe-table/style/style.css +10 -2
  42. package/lib/vxe-table/style/style.min.css +1 -1
  43. package/package.json +1 -1
  44. package/packages/table/module/edit/hook.ts +7 -8
  45. package/packages/table/module/export/hook.ts +3 -2
  46. package/packages/table/module/validator/hook.ts +11 -0
  47. package/packages/table/render/index.ts +120 -51
  48. package/packages/table/src/body.ts +1 -0
  49. package/packages/table/src/table.ts +44 -31
  50. package/styles/components/table.scss +10 -2
  51. /package/es/{iconfont.1739164577907.ttf → iconfont.1739257038865.ttf} +0 -0
  52. /package/es/{iconfont.1739164577907.woff → iconfont.1739257038865.woff} +0 -0
  53. /package/es/{iconfont.1739164577907.woff2 → iconfont.1739257038865.woff2} +0 -0
  54. /package/lib/{iconfont.1739164577907.ttf → iconfont.1739257038865.ttf} +0 -0
  55. /package/lib/{iconfont.1739164577907.woff → iconfont.1739257038865.woff} +0 -0
  56. /package/lib/{iconfont.1739164577907.woff2 → iconfont.1739257038865.woff2} +0 -0
@@ -85,7 +85,9 @@ hooks.add('tableValidatorModule', {
85
85
  const beginValidate = (rows, cols, cb, isFull) => {
86
86
  const validRest = {};
87
87
  const { editRules, treeConfig } = props;
88
+ const { editStore, pendingRowMaps } = reactData;
88
89
  const { afterFullData } = internalData;
90
+ const { removeMaps } = editStore;
89
91
  const treeOpts = computeTreeOpts.value;
90
92
  const childrenField = treeOpts.children || treeOpts.childrenField;
91
93
  const validOpts = computeValidOpts.value;
@@ -117,6 +119,15 @@ hooks.add('tableValidatorModule', {
117
119
  if (editRules) {
118
120
  const columns = cols && cols.length ? cols : $xeTable.getColumns();
119
121
  const handleVaild = (row) => {
122
+ const rowid = getRowid($xeTable, row);
123
+ // 是否删除
124
+ if (removeMaps[rowid]) {
125
+ return;
126
+ }
127
+ // 是否标记删除
128
+ if (pendingRowMaps[rowid]) {
129
+ return;
130
+ }
120
131
  if (isFull || !validRuleErr) {
121
132
  const colVailds = [];
122
133
  columns.forEach((column) => {
@@ -93,10 +93,11 @@ function getCellLabelVNs(renderOpts, params, cellLabel) {
93
93
  * @param modelFunc
94
94
  * @param changeFunc
95
95
  */
96
- function getNativeElementOns(renderOpts, params, modelFunc, changeFunc) {
96
+ function getNativeElementOns(renderOpts, params, eFns) {
97
97
  const { events } = renderOpts;
98
98
  const modelEvent = getModelEvent(renderOpts);
99
99
  const changeEvent = getChangeEvent(renderOpts);
100
+ const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {};
100
101
  const isSameEvent = changeEvent === modelEvent;
101
102
  const ons = {};
102
103
  if (events) {
@@ -118,15 +119,24 @@ function getNativeElementOns(renderOpts, params, modelFunc, changeFunc) {
118
119
  };
119
120
  }
120
121
  if (!isSameEvent && changeFunc) {
121
- ons[getOnName(changeEvent)] = function (...args) {
122
- changeFunc(...args);
122
+ ons[getOnName(changeEvent)] = function (evnt) {
123
+ changeFunc(evnt);
123
124
  if (events && events[changeEvent]) {
124
- events[changeEvent](params, ...args);
125
+ events[changeEvent](params, evnt);
126
+ }
127
+ };
128
+ }
129
+ if (blurFunc) {
130
+ ons[getOnName(blurEvent)] = function (evnt) {
131
+ blurFunc(evnt);
132
+ if (events && events[blurEvent]) {
133
+ events[blurEvent](params, evnt);
125
134
  }
126
135
  };
127
136
  }
128
137
  return ons;
129
138
  }
139
+ const blurEvent = 'blur';
130
140
  /**
131
141
  * 组件事件处理
132
142
  * @param renderOpts
@@ -134,10 +144,11 @@ function getNativeElementOns(renderOpts, params, modelFunc, changeFunc) {
134
144
  * @param modelFunc
135
145
  * @param changeFunc
136
146
  */
137
- function getComponentOns(renderOpts, params, modelFunc, changeFunc) {
147
+ function getComponentOns(renderOpts, params, eFns) {
138
148
  const { events } = renderOpts;
139
149
  const modelEvent = getModelEvent(renderOpts);
140
150
  const changeEvent = getChangeEvent(renderOpts);
151
+ const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {};
141
152
  const ons = {};
142
153
  XEUtils.objectEach(events, (func, key) => {
143
154
  ons[getOnName(key)] = function (...args) {
@@ -165,6 +176,14 @@ function getComponentOns(renderOpts, params, modelFunc, changeFunc) {
165
176
  }
166
177
  };
167
178
  }
179
+ if (blurFunc) {
180
+ ons[getOnName(blurEvent)] = function (...args) {
181
+ blurFunc(...args);
182
+ if (events && events[blurEvent]) {
183
+ events[blurEvent](params, ...args);
184
+ }
185
+ };
186
+ }
168
187
  return ons;
169
188
  }
170
189
  function getEditOns(renderOpts, params) {
@@ -172,59 +191,101 @@ function getEditOns(renderOpts, params) {
172
191
  const { name } = renderOpts;
173
192
  const { model } = column;
174
193
  const isImmediate = isImmediateCell(renderOpts, params);
175
- return getComponentOns(renderOpts, params, (cellValue) => {
176
- // 处理 model 值双向绑定
177
- model.update = true;
178
- model.value = cellValue;
179
- if (isImmediate) {
180
- setCellValue(row, column, cellValue);
181
- }
182
- }, (eventParams) => {
183
- // 处理 change 事件相关逻辑
184
- if (!isImmediate && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
185
- const cellValue = eventParams.value;
194
+ return getComponentOns(renderOpts, params, {
195
+ model(cellValue) {
196
+ // 处理 model 值双向绑定
186
197
  model.update = true;
187
198
  model.value = cellValue;
188
- $table.updateStatus(params, cellValue);
189
- }
190
- else {
191
- $table.updateStatus(params);
199
+ if (isImmediate) {
200
+ setCellValue(row, column, cellValue);
201
+ }
202
+ },
203
+ change(eventParams) {
204
+ // 处理 change 事件相关逻辑
205
+ if (!isImmediate && name && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
206
+ const cellValue = eventParams.value;
207
+ model.update = true;
208
+ model.value = cellValue;
209
+ $table.updateStatus(params, cellValue);
210
+ }
211
+ else {
212
+ $table.updateStatus(params);
213
+ }
214
+ },
215
+ blur() {
216
+ if (isImmediate) {
217
+ $table.handleCellRuleUpdateStatus('blur', params);
218
+ }
219
+ else {
220
+ $table.handleCellRuleUpdateStatus('blur', params, model.value);
221
+ }
192
222
  }
193
223
  });
194
224
  }
195
225
  function getFilterOns(renderOpts, params, option) {
196
- return getComponentOns(renderOpts, params, (value) => {
197
- // 处理 model 值双向绑定
198
- option.data = value;
199
- }, () => {
200
- handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
226
+ return getComponentOns(renderOpts, params, {
227
+ model(value) {
228
+ // 处理 model 值双向绑定
229
+ option.data = value;
230
+ },
231
+ change() {
232
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
233
+ },
234
+ blur() {
235
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
236
+ }
201
237
  });
202
238
  }
203
239
  function getNativeEditOns(renderOpts, params) {
204
240
  const { $table, row, column } = params;
205
241
  const { model } = column;
206
- return getNativeElementOns(renderOpts, params, (evnt) => {
207
- // 处理 model 值双向绑定
208
- const cellValue = evnt.target.value;
209
- if (isImmediateCell(renderOpts, params)) {
210
- setCellValue(row, column, cellValue);
211
- }
212
- else {
213
- model.update = true;
214
- model.value = cellValue;
242
+ return getNativeElementOns(renderOpts, params, {
243
+ model(evnt) {
244
+ // 处理 model 值双向绑定
245
+ const targetEl = evnt.target;
246
+ if (targetEl) {
247
+ const cellValue = targetEl.value;
248
+ if (isImmediateCell(renderOpts, params)) {
249
+ setCellValue(row, column, cellValue);
250
+ }
251
+ else {
252
+ model.update = true;
253
+ model.value = cellValue;
254
+ }
255
+ }
256
+ },
257
+ change(evnt) {
258
+ // 处理 change 事件相关逻辑
259
+ const targetEl = evnt.target;
260
+ if (targetEl) {
261
+ const cellValue = targetEl.value;
262
+ $table.updateStatus(params, cellValue);
263
+ }
264
+ },
265
+ blur(evnt) {
266
+ const targetEl = evnt.target;
267
+ if (targetEl) {
268
+ const cellValue = targetEl.value;
269
+ $table.updateStatus(params, cellValue);
270
+ }
215
271
  }
216
- }, (evnt) => {
217
- // 处理 change 事件相关逻辑
218
- const cellValue = evnt.target.value;
219
- $table.updateStatus(params, cellValue);
220
272
  });
221
273
  }
222
274
  function getNativeFilterOns(renderOpts, params, option) {
223
- return getNativeElementOns(renderOpts, params, (evnt) => {
224
- // 处理 model 值双向绑定
225
- option.data = evnt.target.value;
226
- }, () => {
227
- handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
275
+ return getNativeElementOns(renderOpts, params, {
276
+ model(evnt) {
277
+ // 处理 model 值双向绑定
278
+ const targetEl = evnt.target;
279
+ if (targetEl) {
280
+ option.data = targetEl.value;
281
+ }
282
+ },
283
+ change() {
284
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
285
+ },
286
+ blur() {
287
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
288
+ }
228
289
  });
229
290
  }
230
291
  /**
@@ -364,6 +364,7 @@ export default defineComponent({
364
364
  'fixed--width': !isAutoCellWidth,
365
365
  'fixed--hidden': fixedHiddenColumn,
366
366
  'is--padding': isCellPadding,
367
+ 'is--progress': (fixedHiddenColumn && isAllOverflow) || isVNPreEmptyStatus,
367
368
  'is--drag-cell': isRowDragCell && (isCrossDrag || isPeerDrag || !rowLevel),
368
369
  'is--drag-disabled': isDisabledDrag,
369
370
  'col--dirty': isDirty,
@@ -1540,12 +1540,12 @@ export default defineComponent({
1540
1540
  const sortOpts = computeSortOpts.value;
1541
1541
  const treeOpts = computeTreeOpts.value;
1542
1542
  const childrenField = treeOpts.children || treeOpts.childrenField;
1543
- const { transform } = treeOpts;
1543
+ const { transform, rowField, parentField, mapChildrenField } = treeOpts;
1544
1544
  const { remote: allRemoteFilter, filterMethod: allFilterMethod } = filterOpts;
1545
1545
  const { remote: allRemoteSort, sortMethod: allSortMethod, multiple: sortMultiple, chronological } = sortOpts;
1546
1546
  let tableData = [];
1547
1547
  let tableTree = [];
1548
- // 处理列
1548
+ // 处理数据
1549
1549
  if (!allRemoteFilter || !allRemoteSort) {
1550
1550
  const filterColumns = [];
1551
1551
  let orderColumns = [];
@@ -1601,7 +1601,7 @@ export default defineComponent({
1601
1601
  tableTree = XEUtils.searchTree(tableFullTreeData, handleFilter, {
1602
1602
  original: true,
1603
1603
  isEvery: true,
1604
- children: treeOpts.mapChildrenField,
1604
+ children: mapChildrenField,
1605
1605
  mapChildren: childrenField
1606
1606
  });
1607
1607
  tableData = tableTree;
@@ -1617,7 +1617,7 @@ export default defineComponent({
1617
1617
  tableTree = XEUtils.searchTree(tableFullTreeData, () => true, {
1618
1618
  original: true,
1619
1619
  isEvery: true,
1620
- children: treeOpts.mapChildrenField,
1620
+ children: mapChildrenField,
1621
1621
  mapChildren: childrenField
1622
1622
  });
1623
1623
  tableData = tableTree;
@@ -1637,7 +1637,15 @@ export default defineComponent({
1637
1637
  tableTree = XEUtils.isArray(sortRests) ? sortRests : tableTree;
1638
1638
  }
1639
1639
  else {
1640
- tableTree = XEUtils.orderBy(tableTree, orderColumns.map(({ column, order }) => [getOrderField(column), order]));
1640
+ const treeList = XEUtils.toTreeArray(tableTree, {
1641
+ children: mapChildrenField
1642
+ });
1643
+ tableTree = XEUtils.toArrayTree(XEUtils.orderBy(treeList, orderColumns.map(({ column, order }) => [getOrderField(column), order])), {
1644
+ key: rowField,
1645
+ parentKey: parentField,
1646
+ children: childrenField,
1647
+ mapChildren: mapChildrenField
1648
+ });
1641
1649
  }
1642
1650
  tableData = tableTree;
1643
1651
  }
@@ -5375,34 +5383,10 @@ export default defineComponent({
5375
5383
  * 如果单元格配置了校验规则,则会进行校验
5376
5384
  */
5377
5385
  updateStatus(slotParams, cellValue) {
5378
- const customVal = !XEUtils.isUndefined(cellValue);
5379
5386
  return nextTick().then(() => {
5380
5387
  const { editRules } = props;
5381
- const { validStore } = reactData;
5382
- const tableBody = refTableBody.value;
5383
- if (slotParams && tableBody && editRules) {
5384
- const { row, column } = slotParams;
5385
- const type = 'change';
5386
- if ($xeTable.hasCellRules) {
5387
- if ($xeTable.hasCellRules(type, row, column)) {
5388
- const cell = tableMethods.getCellElement(row, column);
5389
- if (cell) {
5390
- return $xeTable.validCellRules(type, row, column, cellValue)
5391
- .then(() => {
5392
- if (customVal && validStore.visible) {
5393
- setCellValue(row, column, cellValue);
5394
- }
5395
- $xeTable.clearValidate(row, column);
5396
- })
5397
- .catch(({ rule }) => {
5398
- if (customVal) {
5399
- setCellValue(row, column, cellValue);
5400
- }
5401
- $xeTable.showValidTooltip({ rule, row, column, cell });
5402
- });
5403
- }
5404
- }
5405
- }
5388
+ if (slotParams && editRules) {
5389
+ return $xeTable.handleCellRuleUpdateStatus('change', slotParams, cellValue);
5406
5390
  }
5407
5391
  });
5408
5392
  },
@@ -7741,6 +7725,32 @@ export default defineComponent({
7741
7725
  $xeTable.handleColumnSortEvent(evnt, column);
7742
7726
  }
7743
7727
  },
7728
+ handleCellRuleUpdateStatus(type, cellParams, cellValue) {
7729
+ const { validStore } = reactData;
7730
+ const { row, column } = cellParams;
7731
+ if ($xeTable.hasCellRules) {
7732
+ if ($xeTable.hasCellRules(type, row, column)) {
7733
+ const cell = $xeTable.getCellElement(row, column);
7734
+ if (cell) {
7735
+ const customVal = !XEUtils.isUndefined(cellValue);
7736
+ return $xeTable.validCellRules(type, row, column, cellValue)
7737
+ .then(() => {
7738
+ if (customVal && validStore.visible) {
7739
+ setCellValue(row, column, cellValue);
7740
+ }
7741
+ $xeTable.clearValidate(row, column);
7742
+ })
7743
+ .catch(({ rule }) => {
7744
+ if (customVal) {
7745
+ setCellValue(row, column, cellValue);
7746
+ }
7747
+ $xeTable.showValidTooltip({ rule, row, column, cell });
7748
+ });
7749
+ }
7750
+ }
7751
+ }
7752
+ return nextTick();
7753
+ },
7744
7754
  /**
7745
7755
  * 表头单元格按下事件
7746
7756
  */
@@ -2661,6 +2661,9 @@
2661
2661
  .vxe-table--render-default.size--medium .vxe-cell .vxe-default-input[type=date]::-webkit-inner-spin-button {
2662
2662
  margin-top: 3px;
2663
2663
  }
2664
+ .vxe-table--render-default.size--medium .vxe-cell--valid-error-tip {
2665
+ padding: 0 var(--vxe-ui-table-cell-padding-medium);
2666
+ }
2664
2667
  .vxe-table--render-default.size--small {
2665
2668
  font-size: var(--vxe-ui-font-size-small);
2666
2669
  }
@@ -2686,6 +2689,9 @@
2686
2689
  .vxe-table--render-default.size--small .vxe-cell .vxe-default-input[type=date]::-webkit-inner-spin-button {
2687
2690
  margin-top: 2px;
2688
2691
  }
2692
+ .vxe-table--render-default.size--small .vxe-cell--valid-error-tip {
2693
+ padding: 0 var(--vxe-ui-table-cell-padding-small);
2694
+ }
2689
2695
  .vxe-table--render-default.size--mini {
2690
2696
  font-size: var(--vxe-ui-font-size-mini);
2691
2697
  }
@@ -2711,6 +2717,9 @@
2711
2717
  .vxe-table--render-default.size--mini .vxe-cell .vxe-default-input[type=date]::-webkit-inner-spin-button {
2712
2718
  margin-top: 1px;
2713
2719
  }
2720
+ .vxe-table--render-default.size--mini .vxe-cell--valid-error-tip {
2721
+ padding: 0 var(--vxe-ui-table-cell-padding-mini);
2722
+ }
2714
2723
  .vxe-table--render-default .vxe-header--column.is--padding .vxe-cell,
2715
2724
  .vxe-table--render-default .vxe-body--column.is--padding .vxe-cell,
2716
2725
  .vxe-table--render-default .vxe-footer--column.is--padding .vxe-cell {
@@ -3288,8 +3297,7 @@
3288
3297
  transform: translateX(-50%);
3289
3298
  text-align: left;
3290
3299
  z-index: 4;
3291
- padding-left: var(--vxe-ui-table-cell-padding-left);
3292
- padding-right: var(--vxe-ui-table-cell-padding-right);
3300
+ padding: 0 var(--vxe-ui-table-cell-padding-default);
3293
3301
  }
3294
3302
  .vxe-table--render-default .vxe-body--column .vxe-cell--valid-error-wrapper {
3295
3303
  display: inline-block;