vxe-table 4.1.0 → 4.1.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.
Files changed (72) hide show
  1. package/README.md +1 -0
  2. package/README.zh-TW.md +1 -0
  3. package/es/edit/src/hook.js +2 -2
  4. package/es/export/src/hook.js +24 -0
  5. package/es/export/src/util.js +20 -8
  6. package/es/footer/src/footer.js +4 -4
  7. package/es/form/src/form.js +13 -6
  8. package/es/form/src/render.js +4 -4
  9. package/es/grid/src/grid.js +48 -1
  10. package/es/header/src/header.js +7 -5
  11. package/es/select/src/select.js +5 -5
  12. package/es/table/src/body.js +18 -14
  13. package/es/table/src/cell.js +70 -54
  14. package/es/table/src/props.js +4 -1
  15. package/es/table/src/table.js +208 -97
  16. package/es/v-x-e-table/src/conf.js +2 -3
  17. package/es/validator/src/hook.js +12 -5
  18. package/helper/vetur/attributes.json +16 -8
  19. package/helper/vetur/tags.json +2 -0
  20. package/lib/edit/src/hook.js +2 -2
  21. package/lib/edit/src/hook.min.js +1 -1
  22. package/lib/export/src/hook.js +28 -0
  23. package/lib/export/src/hook.min.js +1 -1
  24. package/lib/export/src/util.js +21 -7
  25. package/lib/export/src/util.min.js +1 -1
  26. package/lib/footer/src/footer.js +4 -4
  27. package/lib/footer/src/footer.min.js +1 -1
  28. package/lib/form/src/form.js +23 -6
  29. package/lib/form/src/form.min.js +1 -1
  30. package/lib/form/src/render.js +4 -4
  31. package/lib/form/src/render.min.js +1 -1
  32. package/lib/grid/src/grid.js +56 -1
  33. package/lib/grid/src/grid.min.js +1 -1
  34. package/lib/header/src/header.js +7 -5
  35. package/lib/header/src/header.min.js +1 -1
  36. package/lib/index.umd.js +536 -220
  37. package/lib/index.umd.min.js +1 -1
  38. package/lib/select/src/select.js +5 -5
  39. package/lib/table/src/body.js +18 -14
  40. package/lib/table/src/body.min.js +1 -1
  41. package/lib/table/src/cell.js +92 -35
  42. package/lib/table/src/cell.min.js +1 -1
  43. package/lib/table/src/props.js +4 -1
  44. package/lib/table/src/props.min.js +1 -1
  45. package/lib/table/src/table.js +265 -133
  46. package/lib/table/src/table.min.js +1 -1
  47. package/lib/v-x-e-table/src/conf.js +2 -3
  48. package/lib/v-x-e-table/src/conf.min.js +1 -1
  49. package/lib/validator/src/hook.js +12 -5
  50. package/lib/validator/src/hook.min.js +1 -1
  51. package/package.json +2 -2
  52. package/packages/edit/src/hook.ts +2 -2
  53. package/packages/export/src/hook.ts +24 -0
  54. package/packages/export/src/util.ts +17 -5
  55. package/packages/footer/src/footer.ts +4 -4
  56. package/packages/form/src/form.ts +10 -6
  57. package/packages/form/src/render.ts +4 -4
  58. package/packages/grid/src/grid.ts +48 -1
  59. package/packages/header/src/header.ts +7 -5
  60. package/packages/select/src/select.ts +5 -5
  61. package/packages/table/src/body.ts +18 -14
  62. package/packages/table/src/cell.ts +77 -44
  63. package/packages/table/src/props.ts +4 -1
  64. package/packages/table/src/table.ts +211 -96
  65. package/packages/v-x-e-table/src/conf.ts +2 -3
  66. package/packages/validator/src/hook.ts +9 -5
  67. package/types/column.d.ts +5 -1
  68. package/types/form-item.d.ts +5 -1
  69. package/types/form.d.ts +5 -1
  70. package/types/modal.d.ts +4 -5
  71. package/types/table.d.ts +49 -14
  72. package/types/validator.d.ts +5 -1
@@ -312,17 +312,18 @@ export const Cell = {
312
312
  const { selectRow } = reactData
313
313
  const radioOpts = computeRadioOpts.value
314
314
  const { slots } = column
315
- const { labelField, checkMethod } = radioOpts
315
+ const { labelField, checkMethod, visibleMethod } = radioOpts
316
316
  const { row } = params
317
317
  const defaultSlot = slots ? slots.default : null
318
318
  const radioSlot = slots ? slots.radio : null
319
319
  const isChecked = row === selectRow
320
+ const isVisible = !visibleMethod || visibleMethod({ row })
320
321
  let isDisabled = !!checkMethod
321
322
  let ons
322
323
  if (!isHidden) {
323
324
  ons = {
324
325
  onClick (evnt: Event) {
325
- if (!isDisabled) {
326
+ if (!isDisabled && isVisible) {
326
327
  $table.triggerRadioRowEvent(evnt, params)
327
328
  }
328
329
  }
@@ -331,26 +332,36 @@ export const Cell = {
331
332
  isDisabled = !checkMethod({ row })
332
333
  }
333
334
  }
334
- const radioParams = { ...params, checked: isChecked, disabled: isDisabled }
335
- return radioSlot ? $table.callSlot(radioSlot, radioParams) : [
336
- h('span', {
337
- class: ['vxe-cell--radio', {
338
- 'is--checked': isChecked,
339
- 'is--disabled': isDisabled
340
- }],
341
- ...ons
342
- }, [
335
+ const radioParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible }
336
+ if (radioSlot) {
337
+ return $table.callSlot(radioSlot, radioParams)
338
+ }
339
+ const radioVNs = []
340
+ if (isVisible) {
341
+ radioVNs.push(
343
342
  h('span', {
344
343
  class: 'vxe-radio--icon vxe-radio--checked-icon'
345
344
  }),
346
345
  h('span', {
347
346
  class: 'vxe-radio--icon vxe-radio--unchecked-icon'
348
347
  })
349
- ].concat(defaultSlot || labelField ? [
348
+ )
349
+ }
350
+ if (defaultSlot || labelField) {
351
+ radioVNs.push(
350
352
  h('span', {
351
353
  class: 'vxe-radio--label'
352
354
  }, defaultSlot ? $table.callSlot(defaultSlot, radioParams) : XEUtils.get(row, labelField as string))
353
- ] : []))
355
+ )
356
+ }
357
+ return [
358
+ h('span', {
359
+ class: ['vxe-cell--radio', {
360
+ 'is--checked': isChecked,
361
+ 'is--disabled': isDisabled
362
+ }],
363
+ ...ons
364
+ }, radioVNs)
354
365
  ]
355
366
  },
356
367
  renderTreeRadioCell (params: VxeTableDefines.CellRenderBodyParams) {
@@ -427,19 +438,20 @@ export const Cell = {
427
438
  const { selection, treeIndeterminates } = reactData
428
439
  const { computeCheckboxOpts } = $table.getComputeMaps()
429
440
  const checkboxOpts = computeCheckboxOpts.value
430
- const { labelField, checkMethod } = checkboxOpts
441
+ const { labelField, checkMethod, visibleMethod } = checkboxOpts
431
442
  const { slots } = column
432
443
  const defaultSlot = slots ? slots.default : null
433
444
  const checkboxSlot = slots ? slots.checkbox : null
434
445
  let indeterminate = false
435
446
  let isChecked = false
447
+ const isVisible = !visibleMethod || visibleMethod({ row })
436
448
  let isDisabled = !!checkMethod
437
449
  let ons
438
450
  if (!isHidden) {
439
451
  isChecked = $table.findRowIndexOf(selection, row) > -1
440
452
  ons = {
441
453
  onClick (evnt: MouseEvent) {
442
- if (!isDisabled) {
454
+ if (!isDisabled && isVisible) {
443
455
  $table.triggerCheckRowEvent(evnt, params, !isChecked)
444
456
  }
445
457
  }
@@ -451,16 +463,13 @@ export const Cell = {
451
463
  indeterminate = $table.findRowIndexOf(treeIndeterminates, row) > -1
452
464
  }
453
465
  }
454
- const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, indeterminate }
455
- return checkboxSlot ? $table.callSlot(checkboxSlot, checkboxParams) : [
456
- h('span', {
457
- class: ['vxe-cell--checkbox', {
458
- 'is--checked': isChecked,
459
- 'is--disabled': isDisabled,
460
- 'is--indeterminate': indeterminate
461
- }],
462
- ...ons
463
- }, [
466
+ const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
467
+ if (checkboxSlot) {
468
+ return $table.callSlot(checkboxSlot, checkboxParams)
469
+ }
470
+ const checkVNs = []
471
+ if (isVisible) {
472
+ checkVNs.push(
464
473
  h('span', {
465
474
  class: 'vxe-checkbox--icon vxe-checkbox--checked-icon'
466
475
  }),
@@ -470,11 +479,24 @@ export const Cell = {
470
479
  h('span', {
471
480
  class: 'vxe-checkbox--icon vxe-checkbox--indeterminate-icon'
472
481
  })
473
- ].concat(defaultSlot || labelField ? [
482
+ )
483
+ }
484
+ if (defaultSlot || labelField) {
485
+ checkVNs.push(
474
486
  h('span', {
475
487
  class: 'vxe-checkbox--label'
476
488
  }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams) : XEUtils.get(row, labelField as string))
477
- ] : []))
489
+ )
490
+ }
491
+ return [
492
+ h('span', {
493
+ class: ['vxe-cell--checkbox', {
494
+ 'is--checked': isChecked,
495
+ 'is--disabled': isDisabled,
496
+ 'is--indeterminate': indeterminate
497
+ }],
498
+ ...ons
499
+ }, checkVNs)
478
500
  ]
479
501
  },
480
502
  renderTreeSelectionCell (params: VxeTableDefines.CellRenderBodyParams) {
@@ -487,19 +509,20 @@ export const Cell = {
487
509
  const { treeIndeterminates } = reactData
488
510
  const { computeCheckboxOpts } = $table.getComputeMaps()
489
511
  const checkboxOpts = computeCheckboxOpts.value
490
- const { labelField, checkField: property, halfField, checkMethod } = checkboxOpts
512
+ const { labelField, checkField: property, halfField, checkMethod, visibleMethod } = checkboxOpts
491
513
  const { slots } = column
492
514
  const defaultSlot = slots ? slots.default : null
493
515
  const checkboxSlot = slots ? slots.checkbox : null
494
516
  let indeterminate = false
495
517
  let isChecked = false
518
+ const isVisible = !visibleMethod || visibleMethod({ row })
496
519
  let isDisabled = !!checkMethod
497
520
  let ons
498
521
  if (!isHidden) {
499
522
  isChecked = XEUtils.get(row, property as string)
500
523
  ons = {
501
524
  onClick (evnt: MouseEvent) {
502
- if (!isDisabled) {
525
+ if (!isDisabled && isVisible) {
503
526
  $table.triggerCheckRowEvent(evnt, params, !isChecked)
504
527
  }
505
528
  }
@@ -511,16 +534,13 @@ export const Cell = {
511
534
  indeterminate = $table.findRowIndexOf(treeIndeterminates, row) > -1
512
535
  }
513
536
  }
514
- const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, indeterminate }
515
- return checkboxSlot ? $table.callSlot(checkboxSlot, checkboxParams) : [
516
- h('span', {
517
- class: ['vxe-cell--checkbox', {
518
- 'is--checked': isChecked,
519
- 'is--disabled': isDisabled,
520
- 'is--indeterminate': halfField && !isChecked ? row[halfField] : indeterminate
521
- }],
522
- ...ons
523
- }, [
537
+ const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
538
+ if (checkboxSlot) {
539
+ return $table.callSlot(checkboxSlot, checkboxParams)
540
+ }
541
+ const checkVNs = []
542
+ if (isVisible) {
543
+ checkVNs.push(
524
544
  h('span', {
525
545
  class: 'vxe-checkbox--icon vxe-checkbox--checked-icon'
526
546
  }),
@@ -530,11 +550,24 @@ export const Cell = {
530
550
  h('span', {
531
551
  class: 'vxe-checkbox--icon vxe-checkbox--indeterminate-icon'
532
552
  })
533
- ].concat(defaultSlot || labelField ? [
534
- h('span', {
535
- class: 'vxe-checkbox--label'
536
- }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams) : XEUtils.get(row, labelField as string))
537
- ] : []))
553
+ )
554
+ if (defaultSlot || labelField) {
555
+ checkVNs.push(
556
+ h('span', {
557
+ class: 'vxe-checkbox--label'
558
+ }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams) : XEUtils.get(row, labelField as string))
559
+ )
560
+ }
561
+ }
562
+ return [
563
+ h('span', {
564
+ class: ['vxe-cell--checkbox', {
565
+ 'is--checked': isChecked,
566
+ 'is--disabled': isDisabled,
567
+ 'is--indeterminate': halfField && !isChecked ? row[halfField] : indeterminate
568
+ }],
569
+ ...ons
570
+ }, checkVNs)
538
571
  ]
539
572
  },
540
573
  renderTreeSelectionCellByProp (params: VxeTableDefines.CellRenderBodyParams) {
@@ -99,8 +99,11 @@ export default {
99
99
  autoResize: { type: Boolean as PropType<VxeTablePropTypes.AutoResize>, default: () => GlobalConfig.table.autoResize },
100
100
  // 是否自动根据状态属性去更新响应式表格宽高
101
101
  syncResize: [Boolean, String, Number],
102
- // 设置列的默认参数,仅对部分支持的属性有效
102
+ // 列配置信息
103
103
  columnConfig: Object as PropType<VxeTablePropTypes.ColumnConfig>,
104
+ // 行配置信息
105
+ rowConfig: Object as PropType<VxeTablePropTypes.RowConfig>,
106
+ // 列调整配置项
104
107
  resizableConfig: Object as PropType<VxeTablePropTypes.ResizableConfig>,
105
108
  // 序号配置项
106
109
  seqConfig: Object as PropType<VxeTablePropTypes.SeqConfig>,