vxe-table 3.12.13 → 3.12.14

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/mixin.js +5 -6
  6. package/es/table/module/validator/mixin.js +13 -1
  7. package/es/table/render/index.js +104 -43
  8. package/es/table/src/header.js +4 -2
  9. package/es/table/src/methods.js +35 -28
  10. package/es/table/src/table.js +44 -6
  11. package/es/table/style.css +33 -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 +33 -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 +224 -101
  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/mixin.js +5 -6
  24. package/lib/table/module/edit/mixin.min.js +1 -1
  25. package/lib/table/module/validator/mixin.js +18 -4
  26. package/lib/table/module/validator/mixin.min.js +1 -1
  27. package/lib/table/render/index.js +109 -41
  28. package/lib/table/render/index.min.js +1 -1
  29. package/lib/table/src/header.js +4 -2
  30. package/lib/table/src/header.min.js +1 -1
  31. package/lib/table/src/methods.js +46 -40
  32. package/lib/table/src/methods.min.js +1 -1
  33. package/lib/table/src/table.js +40 -6
  34. package/lib/table/src/table.min.js +1 -1
  35. package/lib/table/style/style.css +33 -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 +33 -2
  42. package/lib/vxe-table/style/style.min.css +1 -1
  43. package/package.json +2 -2
  44. package/packages/table/module/edit/mixin.ts +5 -6
  45. package/packages/table/module/validator/mixin.ts +15 -2
  46. package/packages/table/render/index.ts +120 -51
  47. package/packages/table/src/header.ts +4 -2
  48. package/packages/table/src/methods.ts +42 -30
  49. package/packages/table/src/table.ts +47 -6
  50. package/styles/components/table.scss +31 -2
  51. /package/es/{iconfont.1739152166680.ttf → iconfont.1739181382716.ttf} +0 -0
  52. /package/es/{iconfont.1739152166680.woff → iconfont.1739181382716.woff} +0 -0
  53. /package/es/{iconfont.1739152166680.woff2 → iconfont.1739181382716.woff2} +0 -0
  54. /package/lib/{iconfont.1739152166680.ttf → iconfont.1739181382716.ttf} +0 -0
  55. /package/lib/{iconfont.1739152166680.woff → iconfont.1739181382716.woff} +0 -0
  56. /package/lib/{iconfont.1739152166680.woff2 → iconfont.1739181382716.woff2} +0 -0
@@ -92,10 +92,11 @@ function getCellLabelVNs(h, renderOpts, params, cellLabel) {
92
92
  * @param modelFunc
93
93
  * @param changeFunc
94
94
  */
95
- function getNativeElementOns(renderOpts, params, modelFunc, changeFunc) {
95
+ function getNativeElementOns(renderOpts, params, eFns) {
96
96
  const { events } = renderOpts;
97
97
  const modelEvent = getModelEvent(renderOpts);
98
98
  const changeEvent = getChangeEvent(renderOpts);
99
+ const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {};
99
100
  const isSameEvent = changeEvent === modelEvent;
100
101
  const ons = {};
101
102
  if (events) {
@@ -117,15 +118,24 @@ function getNativeElementOns(renderOpts, params, modelFunc, changeFunc) {
117
118
  };
118
119
  }
119
120
  if (!isSameEvent && changeFunc) {
120
- ons[getOnName(changeEvent)] = function (...args) {
121
- changeFunc(...args);
121
+ ons[getOnName(changeEvent)] = function (evnt) {
122
+ changeFunc(evnt);
122
123
  if (events && events[changeEvent]) {
123
- events[changeEvent](params, ...args);
124
+ events[changeEvent](params, evnt);
125
+ }
126
+ };
127
+ }
128
+ if (blurFunc) {
129
+ ons[getOnName(blurEvent)] = function (evnt) {
130
+ blurFunc(evnt);
131
+ if (events && events[blurEvent]) {
132
+ events[blurEvent](params, evnt);
124
133
  }
125
134
  };
126
135
  }
127
136
  return ons;
128
137
  }
138
+ const blurEvent = 'blur';
129
139
  /**
130
140
  * 组件事件处理
131
141
  * @param renderOpts
@@ -133,10 +143,11 @@ function getNativeElementOns(renderOpts, params, modelFunc, changeFunc) {
133
143
  * @param modelFunc
134
144
  * @param changeFunc
135
145
  */
136
- function getComponentOns(renderOpts, params, modelFunc, changeFunc) {
146
+ function getComponentOns(renderOpts, params, eFns) {
137
147
  const { events } = renderOpts;
138
148
  const modelEvent = getModelEvent(renderOpts);
139
149
  const changeEvent = getChangeEvent(renderOpts);
150
+ const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {};
140
151
  const ons = {};
141
152
  XEUtils.objectEach(events, (func, key) => {
142
153
  ons[getOnName(key)] = function (...args) {
@@ -164,6 +175,14 @@ function getComponentOns(renderOpts, params, modelFunc, changeFunc) {
164
175
  }
165
176
  };
166
177
  }
178
+ if (blurFunc) {
179
+ ons[getOnName(blurEvent)] = function (...args) {
180
+ blurFunc(...args);
181
+ if (events && events[blurEvent]) {
182
+ events[blurEvent](params, ...args);
183
+ }
184
+ };
185
+ }
167
186
  return ons;
168
187
  }
169
188
  function getEditOns(renderOpts, params) {
@@ -171,59 +190,101 @@ function getEditOns(renderOpts, params) {
171
190
  const { name } = renderOpts;
172
191
  const { model } = column;
173
192
  const isImmediate = isImmediateCell(renderOpts, params);
174
- return getComponentOns(renderOpts, params, (cellValue) => {
175
- // 处理 model 值双向绑定
176
- model.update = true;
177
- model.value = cellValue;
178
- if (isImmediate) {
179
- setCellValue(row, column, cellValue);
180
- }
181
- }, (eventParams) => {
182
- // 处理 change 事件相关逻辑
183
- if (!isImmediate && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
184
- const cellValue = eventParams.value;
193
+ return getComponentOns(renderOpts, params, {
194
+ model(cellValue) {
195
+ // 处理 model 值双向绑定
185
196
  model.update = true;
186
197
  model.value = cellValue;
187
- $table.updateStatus(params, cellValue);
188
- }
189
- else {
190
- $table.updateStatus(params);
198
+ if (isImmediate) {
199
+ setCellValue(row, column, cellValue);
200
+ }
201
+ },
202
+ change(eventParams) {
203
+ // 处理 change 事件相关逻辑
204
+ if (!isImmediate && name && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
205
+ const cellValue = eventParams.value;
206
+ model.update = true;
207
+ model.value = cellValue;
208
+ $table.updateStatus(params, cellValue);
209
+ }
210
+ else {
211
+ $table.updateStatus(params);
212
+ }
213
+ },
214
+ blur() {
215
+ if (isImmediate) {
216
+ $table.handleCellRuleUpdateStatus('blur', params);
217
+ }
218
+ else {
219
+ $table.handleCellRuleUpdateStatus('blur', params, model.value);
220
+ }
191
221
  }
192
222
  });
193
223
  }
194
224
  function getFilterOns(renderOpts, params, option) {
195
- return getComponentOns(renderOpts, params, (value) => {
196
- // 处理 model 值双向绑定
197
- option.data = value;
198
- }, () => {
199
- handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
225
+ return getComponentOns(renderOpts, params, {
226
+ model(value) {
227
+ // 处理 model 值双向绑定
228
+ option.data = value;
229
+ },
230
+ change() {
231
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
232
+ },
233
+ blur() {
234
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
235
+ }
200
236
  });
201
237
  }
202
238
  function getNativeEditOns(renderOpts, params) {
203
239
  const { $table, row, column } = params;
204
240
  const { model } = column;
205
- return getNativeElementOns(renderOpts, params, (evnt) => {
206
- // 处理 model 值双向绑定
207
- const cellValue = evnt.target.value;
208
- if (isImmediateCell(renderOpts, params)) {
209
- setCellValue(row, column, cellValue);
210
- }
211
- else {
212
- model.update = true;
213
- model.value = cellValue;
241
+ return getNativeElementOns(renderOpts, params, {
242
+ model(evnt) {
243
+ // 处理 model 值双向绑定
244
+ const targetEl = evnt.target;
245
+ if (targetEl) {
246
+ const cellValue = targetEl.value;
247
+ if (isImmediateCell(renderOpts, params)) {
248
+ setCellValue(row, column, cellValue);
249
+ }
250
+ else {
251
+ model.update = true;
252
+ model.value = cellValue;
253
+ }
254
+ }
255
+ },
256
+ change(evnt) {
257
+ // 处理 change 事件相关逻辑
258
+ const targetEl = evnt.target;
259
+ if (targetEl) {
260
+ const cellValue = targetEl.value;
261
+ $table.updateStatus(params, cellValue);
262
+ }
263
+ },
264
+ blur(evnt) {
265
+ const targetEl = evnt.target;
266
+ if (targetEl) {
267
+ const cellValue = targetEl.value;
268
+ $table.updateStatus(params, cellValue);
269
+ }
214
270
  }
215
- }, (evnt) => {
216
- // 处理 change 事件相关逻辑
217
- const cellValue = evnt.target.value;
218
- $table.updateStatus(params, cellValue);
219
271
  });
220
272
  }
221
273
  function getNativeFilterOns(renderOpts, params, option) {
222
- return getNativeElementOns(renderOpts, params, (evnt) => {
223
- // 处理 model 值双向绑定
224
- option.data = evnt.target.value;
225
- }, () => {
226
- handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
274
+ return getNativeElementOns(renderOpts, params, {
275
+ model(evnt) {
276
+ // 处理 model 值双向绑定
277
+ const targetEl = evnt.target;
278
+ if (targetEl) {
279
+ option.data = targetEl.value;
280
+ }
281
+ },
282
+ change() {
283
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
284
+ },
285
+ blur() {
286
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option);
287
+ }
227
288
  });
228
289
  }
229
290
  /**
@@ -81,8 +81,10 @@ const renderRows = (h, _vm, isGroup, isOptimizeMode, cols, $rowIndex) => {
81
81
  const showResizable = (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable));
82
82
  const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto');
83
83
  let isVNPreEmptyStatus = false;
84
- if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
85
- isVNPreEmptyStatus = true;
84
+ if (!isGroup) {
85
+ if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
86
+ isVNPreEmptyStatus = true;
87
+ }
86
88
  }
87
89
  const tcStyle = {};
88
90
  if (hasEllipsis) {
@@ -6041,8 +6041,8 @@ const Methods = {
6041
6041
  const $xeTable = this;
6042
6042
  const sortOpts = $xeTable.computeSortOpts;
6043
6043
  const { multiple, allowClear } = sortOpts;
6044
- const { field, sortable, remoteSort } = column;
6045
- if (sortable || remoteSort) {
6044
+ const { field, sortable } = column;
6045
+ if (sortable || column.remoteSort) {
6046
6046
  if (!order || column.order === order) {
6047
6047
  if (allowClear) {
6048
6048
  $xeTable.clearSort(multiple ? column : null);
@@ -6054,6 +6054,34 @@ const Methods = {
6054
6054
  $xeTable.handleColumnSortEvent(evnt, column);
6055
6055
  }
6056
6056
  },
6057
+ handleCellRuleUpdateStatus(type, cellParams, cellValue) {
6058
+ const $xeTable = this;
6059
+ const reactData = $xeTable;
6060
+ const { validStore } = reactData;
6061
+ const { row, column } = cellParams;
6062
+ if ($xeTable.hasCellRules) {
6063
+ if ($xeTable.hasCellRules(type, row, column)) {
6064
+ const cell = $xeTable.getCellElement(row, column);
6065
+ if (cell) {
6066
+ const customVal = !XEUtils.isUndefined(cellValue);
6067
+ return $xeTable.validCellRules(type, row, column, cellValue)
6068
+ .then(() => {
6069
+ if (customVal && validStore.visible) {
6070
+ setCellValue(row, column, cellValue);
6071
+ }
6072
+ $xeTable.clearValidate(row, column);
6073
+ })
6074
+ .catch(({ rule }) => {
6075
+ if (customVal) {
6076
+ setCellValue(row, column, cellValue);
6077
+ }
6078
+ $xeTable.showValidTooltip({ rule, row, column, cell });
6079
+ });
6080
+ }
6081
+ }
6082
+ }
6083
+ return $xeTable.$nextTick();
6084
+ },
6057
6085
  /**
6058
6086
  * 表头单元格按下事件
6059
6087
  */
@@ -8341,33 +8369,12 @@ const Methods = {
8341
8369
  * 如果单元格配置了校验规则,则会进行校验
8342
8370
  */
8343
8371
  updateStatus(slotParams, cellValue) {
8344
- const customVal = !XEUtils.isUndefined(cellValue);
8372
+ const $xeTable = this;
8373
+ const props = $xeTable;
8345
8374
  return this.$nextTick().then(() => {
8346
- const { $refs, editRules, validStore } = this;
8347
- const refTableBody = $refs.refTableBody;
8348
- if (slotParams && refTableBody && editRules) {
8349
- const { row, column } = slotParams;
8350
- const type = 'change';
8351
- if (this.hasCellRules) {
8352
- if (this.hasCellRules(type, row, column)) {
8353
- const cell = this.getCellElement(row, column);
8354
- if (cell) {
8355
- return this.validCellRules(type, row, column, cellValue)
8356
- .then(() => {
8357
- if (customVal && validStore.visible) {
8358
- setCellValue(row, column, cellValue);
8359
- }
8360
- this.clearValidate(row, column);
8361
- })
8362
- .catch(({ rule }) => {
8363
- if (customVal) {
8364
- setCellValue(row, column, cellValue);
8365
- }
8366
- this.showValidTooltip({ rule, row, column, cell });
8367
- });
8368
- }
8369
- }
8370
- }
8375
+ const { editRules } = props;
8376
+ if (slotParams && editRules) {
8377
+ return $xeTable.handleCellRuleUpdateStatus('change', slotParams, cellValue);
8371
8378
  }
8372
8379
  });
8373
8380
  },
@@ -554,6 +554,12 @@ export default {
554
554
  isHeader: false,
555
555
  isFooter: false
556
556
  },
557
+ rowHeightStore: {
558
+ default: 48,
559
+ medium: 44,
560
+ small: 40,
561
+ mini: 36
562
+ },
557
563
  scrollVMLoading: false,
558
564
  calcCellHeightFlag: 0,
559
565
  resizeHeightFlag: 0,
@@ -649,12 +655,9 @@ export default {
649
655
  return this.computeRowHeightMaps;
650
656
  },
651
657
  computeRowHeightMaps() {
652
- return {
653
- default: 48,
654
- medium: 44,
655
- small: 40,
656
- mini: 36
657
- };
658
+ const $xeTable = this;
659
+ const reactData = $xeTable;
660
+ return reactData.rowHeightStore;
658
661
  },
659
662
  computeDefaultRowHeight() {
660
663
  const $xeTable = this;
@@ -1365,9 +1368,27 @@ export default {
1365
1368
  mounted() {
1366
1369
  const $xeTable = this;
1367
1370
  const props = $xeTable;
1371
+ const reactData = $xeTable;
1372
+ const { rowHeightStore } = reactData;
1373
+ const varEl = $xeTable.$refs.refVarElem;
1368
1374
  const columnOpts = $xeTable.computeColumnOpts;
1369
1375
  const rowOpts = $xeTable.computeRowOpts;
1370
1376
  const customOpts = $xeTable.computeCustomOpts;
1377
+ if (varEl) {
1378
+ const [defEl, mediumEl, smallEl, miniEl] = varEl.children;
1379
+ if (defEl) {
1380
+ rowHeightStore.default = defEl.clientHeight;
1381
+ }
1382
+ if (mediumEl) {
1383
+ rowHeightStore.medium = mediumEl.clientHeight;
1384
+ }
1385
+ if (smallEl) {
1386
+ rowHeightStore.small = smallEl.clientHeight;
1387
+ }
1388
+ if (miniEl) {
1389
+ rowHeightStore.mini = miniEl.clientHeight;
1390
+ }
1391
+ }
1371
1392
  if (columnOpts.drag || rowOpts.drag || customOpts.allowSort) {
1372
1393
  initTpImg();
1373
1394
  }
@@ -1518,6 +1539,23 @@ export default {
1518
1539
  class: 'vxe-table-slots',
1519
1540
  ref: 'hideColumn'
1520
1541
  }, this.$slots.default),
1542
+ h('div', {
1543
+ ref: 'refVarElem',
1544
+ class: 'vxe-table-vars'
1545
+ }, [
1546
+ h('div', {
1547
+ class: 'vxe-table-var-default'
1548
+ }),
1549
+ h('div', {
1550
+ class: 'vxe-table-var-medium'
1551
+ }),
1552
+ h('div', {
1553
+ class: 'vxe-table-var-small'
1554
+ }),
1555
+ h('div', {
1556
+ class: 'vxe-table-var-mini'
1557
+ })
1558
+ ]),
1521
1559
  h('div', {
1522
1560
  key: 'tw',
1523
1561
  class: 'vxe-table--render-wrapper'
@@ -1682,6 +1682,29 @@
1682
1682
  display: none;
1683
1683
  }
1684
1684
 
1685
+ .vxe-table-vars {
1686
+ height: 0;
1687
+ width: 0;
1688
+ visibility: hidden;
1689
+ overflow: hidden;
1690
+ -webkit-user-select: none;
1691
+ -moz-user-select: none;
1692
+ user-select: none;
1693
+ pointer-events: none;
1694
+ }
1695
+ .vxe-table-vars .vxe-table-var-default {
1696
+ height: var(--vxe-ui-table-row-height-default);
1697
+ }
1698
+ .vxe-table-vars .vxe-table-var-medium {
1699
+ height: var(--vxe-ui-table-row-height-medium);
1700
+ }
1701
+ .vxe-table-vars .vxe-table-var-small {
1702
+ height: var(--vxe-ui-table-row-height-small);
1703
+ }
1704
+ .vxe-table-vars .vxe-table-var-mini {
1705
+ height: var(--vxe-ui-table-row-height-mini);
1706
+ }
1707
+
1685
1708
  .vxe-table--print-frame {
1686
1709
  position: fixed;
1687
1710
  bottom: -100%;
@@ -2638,6 +2661,9 @@
2638
2661
  .vxe-table--render-default.size--medium .vxe-cell .vxe-default-input[type=date]::-webkit-inner-spin-button {
2639
2662
  margin-top: 3px;
2640
2663
  }
2664
+ .vxe-table--render-default.size--medium .vxe-cell--valid-error-tip {
2665
+ padding: 0 var(--vxe-ui-table-cell-padding-medium);
2666
+ }
2641
2667
  .vxe-table--render-default.size--small {
2642
2668
  font-size: var(--vxe-ui-font-size-small);
2643
2669
  }
@@ -2663,6 +2689,9 @@
2663
2689
  .vxe-table--render-default.size--small .vxe-cell .vxe-default-input[type=date]::-webkit-inner-spin-button {
2664
2690
  margin-top: 2px;
2665
2691
  }
2692
+ .vxe-table--render-default.size--small .vxe-cell--valid-error-tip {
2693
+ padding: 0 var(--vxe-ui-table-cell-padding-small);
2694
+ }
2666
2695
  .vxe-table--render-default.size--mini {
2667
2696
  font-size: var(--vxe-ui-font-size-mini);
2668
2697
  }
@@ -2688,6 +2717,9 @@
2688
2717
  .vxe-table--render-default.size--mini .vxe-cell .vxe-default-input[type=date]::-webkit-inner-spin-button {
2689
2718
  margin-top: 1px;
2690
2719
  }
2720
+ .vxe-table--render-default.size--mini .vxe-cell--valid-error-tip {
2721
+ padding: 0 var(--vxe-ui-table-cell-padding-mini);
2722
+ }
2691
2723
  .vxe-table--render-default .vxe-header--column.is--padding .vxe-cell,
2692
2724
  .vxe-table--render-default .vxe-body--column.is--padding .vxe-cell,
2693
2725
  .vxe-table--render-default .vxe-footer--column.is--padding .vxe-cell {
@@ -3265,8 +3297,7 @@
3265
3297
  transform: translateX(-50%);
3266
3298
  text-align: left;
3267
3299
  z-index: 4;
3268
- padding-left: var(--vxe-ui-table-cell-padding-left);
3269
- padding-right: var(--vxe-ui-table-cell-padding-right);
3300
+ padding: 0 var(--vxe-ui-table-cell-padding-default);
3270
3301
  }
3271
3302
  .vxe-table--render-default .vxe-body--column .vxe-cell--valid-error-wrapper {
3272
3303
  display: inline-block;