vxe-table 4.10.10 → 4.10.12

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 (52) 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/validator/hook.js +11 -0
  7. package/es/table/render/index.js +104 -43
  8. package/es/table/src/header.js +4 -2
  9. package/es/table/src/table.js +28 -26
  10. package/es/table/style.css +10 -2
  11. package/es/table/style.min.css +1 -1
  12. package/es/ui/index.js +1 -1
  13. package/es/ui/src/log.js +1 -1
  14. package/es/vxe-table/style.css +10 -2
  15. package/es/vxe-table/style.min.css +1 -1
  16. package/lib/index.css +1 -1
  17. package/lib/index.min.css +1 -1
  18. package/lib/index.umd.js +176 -89
  19. package/lib/index.umd.min.js +1 -1
  20. package/lib/style.css +1 -1
  21. package/lib/style.min.css +1 -1
  22. package/lib/table/module/edit/hook.js +7 -8
  23. package/lib/table/module/edit/hook.min.js +1 -1
  24. package/lib/table/module/validator/hook.js +16 -0
  25. package/lib/table/module/validator/hook.min.js +1 -1
  26. package/lib/table/render/index.js +109 -41
  27. package/lib/table/render/index.min.js +1 -1
  28. package/lib/table/src/header.js +4 -2
  29. package/lib/table/src/header.min.js +1 -1
  30. package/lib/table/src/table.js +38 -36
  31. package/lib/table/src/table.min.js +1 -1
  32. package/lib/table/style/style.css +10 -2
  33. package/lib/table/style/style.min.css +1 -1
  34. package/lib/ui/index.js +1 -1
  35. package/lib/ui/index.min.js +1 -1
  36. package/lib/ui/src/log.js +1 -1
  37. package/lib/ui/src/log.min.js +1 -1
  38. package/lib/vxe-table/style/style.css +10 -2
  39. package/lib/vxe-table/style/style.min.css +1 -1
  40. package/package.json +2 -2
  41. package/packages/table/module/edit/hook.ts +7 -8
  42. package/packages/table/module/validator/hook.ts +11 -0
  43. package/packages/table/render/index.ts +120 -51
  44. package/packages/table/src/header.ts +4 -2
  45. package/packages/table/src/table.ts +28 -26
  46. package/styles/components/table.scss +10 -2
  47. /package/es/{iconfont.1739161310227.ttf → iconfont.1739237387649.ttf} +0 -0
  48. /package/es/{iconfont.1739161310227.woff → iconfont.1739237387649.woff} +0 -0
  49. /package/es/{iconfont.1739161310227.woff2 → iconfont.1739237387649.woff2} +0 -0
  50. /package/lib/{iconfont.1739161310227.ttf → iconfont.1739237387649.ttf} +0 -0
  51. /package/lib/{iconfont.1739161310227.woff → iconfont.1739237387649.woff} +0 -0
  52. /package/lib/{iconfont.1739161310227.woff2 → iconfont.1739237387649.woff2} +0 -0
@@ -7,7 +7,7 @@ import { getOnName, getModelEvent, getChangeEvent } from '../../ui/src/vn'
7
7
  import { errLog } from '../../ui/src/log'
8
8
 
9
9
  import type { VxeButtonComponent } from 'vxe-pc-ui'
10
- import type { VxeGlobalRendererHandles, VxeColumnPropTypes } from '../../../types'
10
+ import type { VxeGlobalRendererHandles, VxeColumnPropTypes, VxeTableConstructor, VxeTablePrivateMethods } from '../../../types'
11
11
 
12
12
  const { getConfig, renderer, getI18n } = VxeUI
13
13
 
@@ -114,10 +114,15 @@ function getCellLabelVNs (renderOpts: any, params: any, cellLabel: any) {
114
114
  * @param modelFunc
115
115
  * @param changeFunc
116
116
  */
117
- function getNativeElementOns (renderOpts: any, params: any, modelFunc?: any, changeFunc?: any) {
117
+ function getNativeElementOns (renderOpts: any, params: any, eFns?: {
118
+ model: (evnt: Event) => void
119
+ change?: (evnt: Event) => void
120
+ blur?: (evnt: Event) => void
121
+ }) {
118
122
  const { events } = renderOpts
119
123
  const modelEvent = getModelEvent(renderOpts)
120
124
  const changeEvent = getChangeEvent(renderOpts)
125
+ const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {}
121
126
  const isSameEvent = changeEvent === modelEvent
122
127
  const ons: any = {}
123
128
  if (events) {
@@ -139,16 +144,26 @@ function getNativeElementOns (renderOpts: any, params: any, modelFunc?: any, cha
139
144
  }
140
145
  }
141
146
  if (!isSameEvent && changeFunc) {
142
- ons[getOnName(changeEvent)] = function (...args: any[]) {
143
- changeFunc(...args)
147
+ ons[getOnName(changeEvent)] = function (evnt: Event) {
148
+ changeFunc(evnt)
144
149
  if (events && events[changeEvent]) {
145
- events[changeEvent](params, ...args)
150
+ events[changeEvent](params, evnt)
151
+ }
152
+ }
153
+ }
154
+ if (blurFunc) {
155
+ ons[getOnName(blurEvent)] = function (evnt: Event) {
156
+ blurFunc(evnt)
157
+ if (events && events[blurEvent]) {
158
+ events[blurEvent](params, evnt)
146
159
  }
147
160
  }
148
161
  }
149
162
  return ons
150
163
  }
151
164
 
165
+ const blurEvent = 'blur'
166
+
152
167
  /**
153
168
  * 组件事件处理
154
169
  * @param renderOpts
@@ -156,10 +171,15 @@ function getNativeElementOns (renderOpts: any, params: any, modelFunc?: any, cha
156
171
  * @param modelFunc
157
172
  * @param changeFunc
158
173
  */
159
- function getComponentOns (renderOpts: any, params: any, modelFunc?: any, changeFunc?: any) {
174
+ function getComponentOns (renderOpts: any, params: any, eFns?: {
175
+ model: (cellValue: any) => void
176
+ change?: (...args: any[]) => void
177
+ blur?: (...args: any[]) => void
178
+ }) {
160
179
  const { events } = renderOpts
161
180
  const modelEvent = getModelEvent(renderOpts)
162
181
  const changeEvent = getChangeEvent(renderOpts)
182
+ const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {}
163
183
  const ons: any = {}
164
184
  XEUtils.objectEach(events, (func, key: any) => {
165
185
  ons[getOnName(key)] = function (...args: any[]) {
@@ -187,68 +207,117 @@ function getComponentOns (renderOpts: any, params: any, modelFunc?: any, changeF
187
207
  }
188
208
  }
189
209
  }
210
+ if (blurFunc) {
211
+ ons[getOnName(blurEvent)] = function (...args: any[]) {
212
+ blurFunc(...args)
213
+ if (events && events[blurEvent]) {
214
+ events[blurEvent](params, ...args)
215
+ }
216
+ }
217
+ }
190
218
  return ons
191
219
  }
192
220
 
193
- function getEditOns (renderOpts: any, params: any) {
221
+ function getEditOns (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
194
222
  const { $table, row, column } = params
195
223
  const { name } = renderOpts
196
224
  const { model } = column
197
225
  const isImmediate = isImmediateCell(renderOpts, params)
198
- return getComponentOns(renderOpts, params, (cellValue: any) => {
199
- // 处理 model 值双向绑定
200
- model.update = true
201
- model.value = cellValue
202
- if (isImmediate) {
203
- setCellValue(row, column, cellValue)
204
- }
205
- }, (eventParams: any) => {
206
- // 处理 change 事件相关逻辑
207
- if (!isImmediate && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
208
- const cellValue = eventParams.value
226
+ return getComponentOns(renderOpts, params, {
227
+ model (cellValue) {
228
+ // 处理 model 值双向绑定
209
229
  model.update = true
210
230
  model.value = cellValue
211
- $table.updateStatus(params, cellValue)
212
- } else {
213
- $table.updateStatus(params)
231
+ if (isImmediate) {
232
+ setCellValue(row, column, cellValue)
233
+ }
234
+ },
235
+ change (eventParams) {
236
+ // 处理 change 事件相关逻辑
237
+ if (!isImmediate && name && (['VxeInput', 'VxeNumberInput', 'VxeTextarea', '$input', '$textarea'].includes(name))) {
238
+ const cellValue = eventParams.value
239
+ model.update = true
240
+ model.value = cellValue
241
+ $table.updateStatus(params, cellValue)
242
+ } else {
243
+ $table.updateStatus(params)
244
+ }
245
+ },
246
+ blur () {
247
+ if (isImmediate) {
248
+ $table.handleCellRuleUpdateStatus('blur', params)
249
+ } else {
250
+ $table.handleCellRuleUpdateStatus('blur', params, model.value)
251
+ }
214
252
  }
215
253
  })
216
254
  }
217
255
 
218
256
  function getFilterOns (renderOpts: any, params: any, option: any) {
219
- return getComponentOns(renderOpts, params, (value: any) => {
220
- // 处理 model 值双向绑定
221
- option.data = value
222
- }, () => {
223
- handleConfirmFilter(params, !XEUtils.eqNull(option.data), option)
257
+ return getComponentOns(renderOpts, params, {
258
+ model (value: any) {
259
+ // 处理 model 值双向绑定
260
+ option.data = value
261
+ },
262
+ change () {
263
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option)
264
+ },
265
+ blur () {
266
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option)
267
+ }
224
268
  })
225
269
  }
226
270
 
227
271
  function getNativeEditOns (renderOpts: any, params: any) {
228
272
  const { $table, row, column } = params
229
273
  const { model } = column
230
- return getNativeElementOns(renderOpts, params, (evnt: any) => {
231
- // 处理 model 值双向绑定
232
- const cellValue = evnt.target.value
233
- if (isImmediateCell(renderOpts, params)) {
234
- setCellValue(row, column, cellValue)
235
- } else {
236
- model.update = true
237
- model.value = cellValue
274
+ return getNativeElementOns(renderOpts, params, {
275
+ model (evnt) {
276
+ // 处理 model 值双向绑定
277
+ const targetEl = evnt.target as HTMLInputElement
278
+ if (targetEl) {
279
+ const cellValue = targetEl.value
280
+ if (isImmediateCell(renderOpts, params)) {
281
+ setCellValue(row, column, cellValue)
282
+ } else {
283
+ model.update = true
284
+ model.value = cellValue
285
+ }
286
+ }
287
+ },
288
+ change (evnt) {
289
+ // 处理 change 事件相关逻辑
290
+ const targetEl = evnt.target as HTMLInputElement
291
+ if (targetEl) {
292
+ const cellValue = targetEl.value
293
+ $table.updateStatus(params, cellValue)
294
+ }
295
+ },
296
+ blur (evnt) {
297
+ const targetEl = evnt.target as HTMLInputElement
298
+ if (targetEl) {
299
+ const cellValue = targetEl.value
300
+ $table.updateStatus(params, cellValue)
301
+ }
238
302
  }
239
- }, (evnt: any) => {
240
- // 处理 change 事件相关逻辑
241
- const cellValue = evnt.target.value
242
- $table.updateStatus(params, cellValue)
243
303
  })
244
304
  }
245
305
 
246
306
  function getNativeFilterOns (renderOpts: any, params: any, option: any) {
247
- return getNativeElementOns(renderOpts, params, (evnt: any) => {
248
- // 处理 model 值双向绑定
249
- option.data = evnt.target.value
250
- }, () => {
251
- handleConfirmFilter(params, !XEUtils.eqNull(option.data), option)
307
+ return getNativeElementOns(renderOpts, params, {
308
+ model (evnt) {
309
+ // 处理 model 值双向绑定
310
+ const targetEl = evnt.target as HTMLInputElement
311
+ if (targetEl) {
312
+ option.data = targetEl.value
313
+ }
314
+ },
315
+ change () {
316
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option)
317
+ },
318
+ blur () {
319
+ handleConfirmFilter(params, !XEUtils.eqNull(option.data), option)
320
+ }
252
321
  })
253
322
  }
254
323
 
@@ -279,7 +348,7 @@ function buttonCellRender (renderOpts: any, params: any) {
279
348
  ]
280
349
  }
281
350
 
282
- function defaultEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams) {
351
+ function defaultEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
283
352
  const { row, column } = params
284
353
  const cellValue = getCellValue(row, column)
285
354
  return [
@@ -290,7 +359,7 @@ function defaultEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEdit
290
359
  ]
291
360
  }
292
361
 
293
- function radioAndCheckboxEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams) {
362
+ function radioAndCheckboxEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
294
363
  const { options } = renderOpts
295
364
  const { row, column } = params
296
365
  const cellValue = getCellValue(row, column)
@@ -307,7 +376,7 @@ function radioAndCheckboxEditRender (renderOpts: VxeGlobalRendererHandles.Render
307
376
  * 已废弃
308
377
  * @deprecated
309
378
  */
310
- function oldEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams) {
379
+ function oldEditRender (renderOpts: VxeGlobalRendererHandles.RenderTableEditOptions, params: VxeGlobalRendererHandles.RenderEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
311
380
  const { row, column } = params
312
381
  const cellValue = getCellValue(row, column)
313
382
  return [
@@ -768,7 +837,7 @@ renderer.mixin({
768
837
  },
769
838
  VxeColorPicker: {
770
839
  tableAutoFocus: 'input',
771
- renderTableEdit (renderOpts: any, params: any) {
840
+ renderTableEdit (renderOpts, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
772
841
  const { row, column } = params
773
842
  const { options } = renderOpts
774
843
  const cellValue = getCellValue(row, column)
@@ -796,7 +865,7 @@ renderer.mixin({
796
865
  },
797
866
  VxeIconPicker: {
798
867
  tableAutoFocus: 'input',
799
- renderTableEdit (renderOpts: any, params: any) {
868
+ renderTableEdit (renderOpts, params: VxeGlobalRendererHandles.RenderTableEditParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
800
869
  const { row, column } = params
801
870
  const { options } = renderOpts
802
871
  const cellValue = getCellValue(row, column)
@@ -832,7 +901,7 @@ renderer.mixin({
832
901
  renderTableDefault: defaultEditRender
833
902
  },
834
903
  VxeImage: {
835
- renderTableDefault (renderOpts, params) {
904
+ renderTableDefault (renderOpts, params: VxeGlobalRendererHandles.RenderTableDefaultParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
836
905
  const { row, column } = params
837
906
  const { props } = renderOpts
838
907
  const cellValue = getCellValue(row, column)
@@ -846,7 +915,7 @@ renderer.mixin({
846
915
  }
847
916
  },
848
917
  VxeImageGroup: {
849
- renderTableDefault (renderOpts, params) {
918
+ renderTableDefault (renderOpts, params: VxeGlobalRendererHandles.RenderTableDefaultParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
850
919
  const { row, column } = params
851
920
  const { props } = renderOpts
852
921
  const cellValue = getCellValue(row, column)
@@ -860,7 +929,7 @@ renderer.mixin({
860
929
  }
861
930
  },
862
931
  VxeTextEllipsis: {
863
- renderTableDefault (renderOpts, params) {
932
+ renderTableDefault (renderOpts, params: VxeGlobalRendererHandles.RenderTableDefaultParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
864
933
  const { row, column } = params
865
934
  const { props } = renderOpts
866
935
  const cellValue = getCellValue(row, column)
@@ -115,8 +115,10 @@ export default defineComponent({
115
115
  const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
116
116
 
117
117
  let isVNPreEmptyStatus = false
118
- if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
119
- isVNPreEmptyStatus = true
118
+ if (!isGroup) {
119
+ if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
120
+ isVNPreEmptyStatus = true
121
+ }
120
122
  }
121
123
 
122
124
  const tcStyle: Record<string, string> = {}
@@ -5504,34 +5504,10 @@ export default defineComponent({
5504
5504
  * 如果单元格配置了校验规则,则会进行校验
5505
5505
  */
5506
5506
  updateStatus (slotParams, cellValue) {
5507
- const customVal = !XEUtils.isUndefined(cellValue)
5508
5507
  return nextTick().then(() => {
5509
5508
  const { editRules } = props
5510
- const { validStore } = reactData
5511
- const tableBody = refTableBody.value
5512
- if (slotParams && tableBody && editRules) {
5513
- const { row, column } = slotParams
5514
- const type = 'change'
5515
- if ($xeTable.hasCellRules) {
5516
- if ($xeTable.hasCellRules(type, row, column)) {
5517
- const cell = tableMethods.getCellElement(row, column)
5518
- if (cell) {
5519
- return $xeTable.validCellRules(type, row, column, cellValue)
5520
- .then(() => {
5521
- if (customVal && validStore.visible) {
5522
- setCellValue(row, column, cellValue)
5523
- }
5524
- $xeTable.clearValidate(row, column)
5525
- })
5526
- .catch(({ rule }) => {
5527
- if (customVal) {
5528
- setCellValue(row, column, cellValue)
5529
- }
5530
- $xeTable.showValidTooltip({ rule, row, column, cell })
5531
- })
5532
- }
5533
- }
5534
- }
5509
+ if (slotParams && editRules) {
5510
+ return $xeTable.handleCellRuleUpdateStatus('change', slotParams, cellValue)
5535
5511
  }
5536
5512
  })
5537
5513
  },
@@ -7832,6 +7808,32 @@ export default defineComponent({
7832
7808
  $xeTable.handleColumnSortEvent(evnt, column)
7833
7809
  }
7834
7810
  },
7811
+ handleCellRuleUpdateStatus (type, cellParams, cellValue) {
7812
+ const { validStore } = reactData
7813
+ const { row, column } = cellParams
7814
+ if ($xeTable.hasCellRules) {
7815
+ if ($xeTable.hasCellRules(type, row, column)) {
7816
+ const cell = $xeTable.getCellElement(row, column)
7817
+ if (cell) {
7818
+ const customVal = !XEUtils.isUndefined(cellValue)
7819
+ return $xeTable.validCellRules(type, row, column, cellValue)
7820
+ .then(() => {
7821
+ if (customVal && validStore.visible) {
7822
+ setCellValue(row, column, cellValue)
7823
+ }
7824
+ $xeTable.clearValidate(row, column)
7825
+ })
7826
+ .catch(({ rule }: any) => {
7827
+ if (customVal) {
7828
+ setCellValue(row, column, cellValue)
7829
+ }
7830
+ $xeTable.showValidTooltip({ rule, row, column, cell })
7831
+ })
7832
+ }
7833
+ }
7834
+ }
7835
+ return nextTick()
7836
+ },
7835
7837
  /**
7836
7838
  * 表头单元格按下事件
7837
7839
  */
@@ -1255,6 +1255,9 @@
1255
1255
  }
1256
1256
  }
1257
1257
  }
1258
+ .vxe-cell--valid-error-tip {
1259
+ padding: 0 var(--vxe-ui-table-cell-padding-medium);
1260
+ }
1258
1261
  }
1259
1262
  &.size--small {
1260
1263
  font-size: var(--vxe-ui-font-size-small);
@@ -1286,6 +1289,9 @@
1286
1289
  }
1287
1290
  }
1288
1291
  }
1292
+ .vxe-cell--valid-error-tip {
1293
+ padding: 0 var(--vxe-ui-table-cell-padding-small);
1294
+ }
1289
1295
  }
1290
1296
  &.size--mini {
1291
1297
  font-size: var(--vxe-ui-font-size-mini);
@@ -1317,6 +1323,9 @@
1317
1323
  }
1318
1324
  }
1319
1325
  }
1326
+ .vxe-cell--valid-error-tip {
1327
+ padding: 0 var(--vxe-ui-table-cell-padding-mini);
1328
+ }
1320
1329
  }
1321
1330
 
1322
1331
  .vxe-header--column,
@@ -1915,8 +1924,7 @@
1915
1924
  transform: translateX(-50%);
1916
1925
  text-align: left;
1917
1926
  z-index: 4;
1918
- padding-left: var(--vxe-ui-table-cell-padding-left);
1919
- padding-right: var(--vxe-ui-table-cell-padding-right);
1927
+ padding: 0 var(--vxe-ui-table-cell-padding-default);
1920
1928
  }
1921
1929
  .vxe-cell--valid-error-wrapper {
1922
1930
  display: inline-block;