vxe-table 3.5.9-beta.8 → 3.6.0-beta.0

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 (78) hide show
  1. package/lib/button/src/button.js +5 -1
  2. package/lib/button/src/button.min.js +1 -1
  3. package/lib/edit/src/mixin.js +12 -8
  4. package/lib/edit/src/mixin.min.js +1 -1
  5. package/lib/filter/src/panel.js +2 -1
  6. package/lib/filter/src/panel.min.js +1 -1
  7. package/lib/form/src/form-config-item.js +9 -13
  8. package/lib/form/src/form-config-item.min.js +1 -1
  9. package/lib/form/src/form-gather.js +1 -3
  10. package/lib/form/src/form-gather.min.js +1 -1
  11. package/lib/form/src/form-item.js +12 -13
  12. package/lib/form/src/form-item.min.js +1 -1
  13. package/lib/form/src/form.js +6 -3
  14. package/lib/form/src/form.min.js +1 -1
  15. package/lib/form/src/util.js +41 -0
  16. package/lib/form/src/util.min.js +1 -1
  17. package/lib/grid/src/grid.js +3 -1
  18. package/lib/grid/src/grid.min.js +1 -1
  19. package/lib/grid/style/style.css +1 -1
  20. package/lib/grid/style/style.min.css +1 -1
  21. package/lib/header/src/header.js +9 -2
  22. package/lib/header/src/header.min.js +1 -1
  23. package/lib/header/style/style.css +0 -100
  24. package/lib/header/style/style.min.css +0 -1
  25. package/lib/index.css +1 -1
  26. package/lib/index.umd.js +756 -660
  27. package/lib/index.umd.min.js +1 -1
  28. package/lib/modal/src/modal.js +9 -7
  29. package/lib/modal/src/modal.min.js +1 -1
  30. package/lib/modal/style/style.css +2 -2
  31. package/lib/modal/style/style.min.css +1 -1
  32. package/lib/pager/style/style.css +1 -1
  33. package/lib/pager/style/style.min.css +1 -1
  34. package/lib/select/src/select.js +3 -1
  35. package/lib/select/src/select.min.js +1 -1
  36. package/lib/style.css +1 -1
  37. package/lib/style.min.css +1 -1
  38. package/lib/table/src/cell.js +23 -16
  39. package/lib/table/src/cell.min.js +1 -1
  40. package/lib/table/src/methods.js +300 -269
  41. package/lib/table/src/methods.min.js +1 -1
  42. package/lib/table/style/style.css +101 -0
  43. package/lib/table/style/style.min.css +1 -1
  44. package/lib/toolbar/style/style.css +1 -1
  45. package/lib/toolbar/style/style.min.css +1 -1
  46. package/lib/tools/log.js +1 -1
  47. package/lib/tools/log.min.js +1 -1
  48. package/lib/tools/vn.js +18 -0
  49. package/lib/tools/vn.min.js +1 -0
  50. package/lib/v-x-e-table/index.js +1 -1
  51. package/lib/v-x-e-table/index.min.js +1 -1
  52. package/lib/v-x-e-table/src/store.js +10 -5
  53. package/lib/v-x-e-table/src/store.min.js +1 -1
  54. package/lib/v-x-e-table/style/style.css +1 -1
  55. package/lib/v-x-e-table/style/style.min.css +1 -1
  56. package/package.json +2 -2
  57. package/packages/button/src/button.js +7 -1
  58. package/packages/edit/src/mixin.js +10 -7
  59. package/packages/filter/src/panel.js +1 -1
  60. package/packages/form/src/form-config-item.js +8 -12
  61. package/packages/form/src/form-gather.js +1 -3
  62. package/packages/form/src/form-item.js +12 -14
  63. package/packages/form/src/form.js +6 -4
  64. package/packages/form/src/util.js +23 -0
  65. package/packages/grid/src/grid.js +2 -1
  66. package/packages/header/src/header.js +3 -2
  67. package/packages/modal/src/modal.js +5 -4
  68. package/packages/select/src/select.js +2 -1
  69. package/packages/table/src/cell.js +17 -13
  70. package/packages/table/src/methods.js +67 -46
  71. package/packages/tools/vn.js +8 -0
  72. package/packages/v-x-e-table/src/store.js +8 -4
  73. package/styles/header.scss +0 -134
  74. package/styles/table.scss +134 -0
  75. package/styles/variable.scss +1 -1
  76. package/types/column.d.ts +8 -8
  77. package/types/component.d.ts +3 -1
  78. package/types/v-x-e-table/renderer.d.ts +2 -1
@@ -2,8 +2,9 @@ import XEUtils from 'xe-utils'
2
2
  import GlobalConfig from '../../v-x-e-table/src/conf'
3
3
  import VXETable from '../../v-x-e-table'
4
4
  import { isEnableConf, getFuncText } from '../../tools/utils'
5
- import { createItem, destroyItem, assemItem } from './util'
5
+ import { createItem, destroyItem, assemItem, isActivetem } from './util'
6
6
  import { renderTitle } from './render'
7
+ import { getSlotVNs } from '../../tools/vn'
7
8
 
8
9
  const props = {
9
10
  title: String,
@@ -41,15 +42,14 @@ Object.keys(props).forEach(name => {
41
42
  })
42
43
 
43
44
  const renderItem = (h, _vm, item, slots) => {
44
- const { rules, data, collapseAll, validOpts, titleOverflow: allTitleOverflow } = _vm
45
- const { title, folding, visible, visibleMethod, field, collapseNode, itemRender, showError, errRule, className, titleOverflow } = item
45
+ const { _e, rules, data, collapseAll, validOpts, titleOverflow: allTitleOverflow } = _vm
46
+ const { title, folding, visible, field, collapseNode, itemRender, showError, errRule, className, titleOverflow } = item
46
47
  const compConf = isEnableConf(itemRender) ? VXETable.renderer.get(itemRender.name) : null
47
48
  const itemClassName = compConf ? compConf.itemClassName : ''
48
49
  const span = item.span || _vm.span
49
50
  const align = item.align || _vm.align
50
51
  const titleAlign = item.titleAlign || _vm.titleAlign
51
52
  const titleWidth = item.titleWidth || _vm.titleWidth
52
- let itemVisibleMethod = visibleMethod
53
53
  const itemOverflow = (XEUtils.isUndefined(titleOverflow) || XEUtils.isNull(titleOverflow)) ? allTitleOverflow : titleOverflow
54
54
  const showEllipsis = itemOverflow === 'ellipsis'
55
55
  const showTitle = itemOverflow === 'title'
@@ -57,8 +57,8 @@ const renderItem = (h, _vm, item, slots) => {
57
57
  const hasEllipsis = showTitle || showTooltip || showEllipsis
58
58
  const params = { data, field, property: field, item, $form: _vm }
59
59
  let isRequired
60
- if (!itemVisibleMethod && compConf && compConf.itemVisibleMethod) {
61
- itemVisibleMethod = compConf.itemVisibleMethod
60
+ if (visible === false) {
61
+ return _e()
62
62
  }
63
63
  if (rules) {
64
64
  const itemRules = rules[field]
@@ -70,9 +70,9 @@ const renderItem = (h, _vm, item, slots) => {
70
70
  if (slots && slots.default) {
71
71
  contentVNs = _vm.callSlot(slots.default, params, h)
72
72
  } else if (compConf && compConf.renderItemContent) {
73
- contentVNs = compConf.renderItemContent.call(_vm, h, itemRender, params)
73
+ contentVNs = getSlotVNs(compConf.renderItemContent.call(_vm, h, itemRender, params))
74
74
  } else if (compConf && compConf.renderItem) {
75
- contentVNs = compConf.renderItem.call(_vm, h, itemRender, params)
75
+ contentVNs = getSlotVNs(compConf.renderItem.call(_vm, h, itemRender, params))
76
76
  } else if (field) {
77
77
  contentVNs = [`${XEUtils.get(data, field)}`]
78
78
  }
@@ -88,12 +88,12 @@ const renderItem = (h, _vm, item, slots) => {
88
88
  item.id,
89
89
  span ? `vxe-col--${span} is--span` : '',
90
90
  className ? (XEUtils.isFunction(className) ? className(params) : className) : '',
91
- itemClassName ? (XEUtils.isFunction(itemClassName) ? itemClassName(params) : className) : '',
91
+ itemClassName ? (XEUtils.isFunction(itemClassName) ? itemClassName(params) : itemClassName) : '',
92
92
  {
93
93
  'is--title': title,
94
94
  'is--required': isRequired,
95
- 'is--hidden': visible === false || (folding && collapseAll),
96
- 'is--active': !itemVisibleMethod || itemVisibleMethod(params),
95
+ 'is--hidden': folding && collapseAll,
96
+ 'is--active': isActivetem(_vm, item),
97
97
  'is--error': showError
98
98
  }
99
99
  ]
@@ -156,9 +156,7 @@ export default {
156
156
  provide () {
157
157
  return {
158
158
  $xeformitem: this,
159
- $xeformiteminfo: {
160
- itemConfig: this.itemConfig
161
- }
159
+ $xeformiteminfo: this
162
160
  }
163
161
  },
164
162
  data () {
@@ -4,10 +4,11 @@ import vSize from '../../mixins/size'
4
4
  import VXETable from '../../v-x-e-table'
5
5
  import { isEnableConf, eqEmptyValue, getFuncText } from '../../tools/utils'
6
6
  import DomTools, { browse } from '../../tools/dom'
7
- import { createItem, handleFieldOrItem } from './util'
7
+ import { createItem, handleFieldOrItem, isHiddenItem, isActivetem } from './util'
8
8
  import { errLog } from '../../tools/log'
9
9
  import VxeFormConfigItem from './form-config-item'
10
10
  import VxeLoading from '../../loading/index'
11
+ import { getSlotVNs } from '../../tools/vn'
11
12
 
12
13
  class Rule {
13
14
  constructor (rule) {
@@ -79,6 +80,7 @@ export default {
79
80
  titleAsterisk: { type: Boolean, default: () => GlobalConfig.form.titleAsterisk },
80
81
  titleOverflow: { type: [Boolean, String], default: null },
81
82
  className: [String, Function],
83
+ readonly: Boolean,
82
84
  items: Array,
83
85
  rules: Object,
84
86
  preventSubmit: { type: Boolean, default: () => GlobalConfig.form.preventSubmit },
@@ -193,7 +195,7 @@ export default {
193
195
  slotFunc = $scopedSlots[slotFunc] || null
194
196
  }
195
197
  if (XEUtils.isFunction(slotFunc)) {
196
- return slotFunc.call(this, params, h)
198
+ return getSlotVNs(slotFunc.call(this, params, h))
197
199
  }
198
200
  }
199
201
  return []
@@ -357,7 +359,7 @@ export default {
357
359
  if (data && formRules) {
358
360
  itemList.forEach(item => {
359
361
  const { field } = item
360
- if (field) {
362
+ if (field && !isHiddenItem(this, item) && isActivetem(this, item)) {
361
363
  itemValids.push(
362
364
  this.validItemRules(type || 'all', field).then(() => {
363
365
  item.errRule = null
@@ -506,7 +508,7 @@ export default {
506
508
  },
507
509
  triggerItemEvent (evnt, field, itemValue) {
508
510
  if (field) {
509
- return this.validItemRules(evnt ? evnt.type : 'all', field, itemValue)
511
+ return this.validItemRules(evnt ? (['blur'].includes(evnt.type) ? 'blur' : 'change') : 'all', field, itemValue)
510
512
  .then(() => {
511
513
  this.clearValidate(field)
512
514
  })
@@ -1,6 +1,7 @@
1
1
  import XEUtils from 'xe-utils'
2
2
  import VXETable from '../../v-x-e-table'
3
3
  import { warnLog } from '../../tools/log'
4
+ import { isEnableConf } from '../../tools/utils'
4
5
 
5
6
  class ItemConfig {
6
7
  constructor ($xeform, item) {
@@ -58,6 +59,28 @@ export const handleFieldOrItem = ($xeform, fieldOrItem) => {
58
59
  return null
59
60
  }
60
61
 
62
+ export function isHiddenItem ($xeform, formItem) {
63
+ const { collapseAll } = $xeform
64
+ const { folding, visible } = formItem
65
+ return visible === false || (folding && collapseAll)
66
+ }
67
+
68
+ export function isActivetem ($xeform, formItem) {
69
+ let { visibleMethod, itemRender, visible, field } = formItem
70
+ if (visible === false) {
71
+ return visible
72
+ }
73
+ const compConf = isEnableConf(itemRender) ? VXETable.renderer.get(itemRender.name) : null
74
+ if (!visibleMethod && compConf && compConf.itemVisibleMethod) {
75
+ visibleMethod = compConf.itemVisibleMethod
76
+ }
77
+ if (!visibleMethod) {
78
+ return true
79
+ }
80
+ const { data } = $xeform
81
+ return visibleMethod({ data, field, property: field, item: formItem, $form: $xeform })
82
+ }
83
+
61
84
  export function createItem ($xeform, _vm) {
62
85
  return getItemConfig($xeform, _vm)
63
86
  }
@@ -7,6 +7,7 @@ import UtilTools, { isEnableConf } from '../../tools/utils'
7
7
  import DomTools, { getOffsetHeight, getPaddingTopBottomSize } from '../../tools/dom'
8
8
  import { GlobalEvent } from '../../tools/event'
9
9
  import { warnLog, errLog } from '../../tools/log'
10
+ import { getSlotVNs } from '../../tools/vn'
10
11
 
11
12
  const methods = {}
12
13
  const propKeys = Object.keys(Table.props)
@@ -372,7 +373,7 @@ export default {
372
373
  slotFunc = $scopedSlots[slotFunc] || null
373
374
  }
374
375
  if (XEUtils.isFunction(slotFunc)) {
375
- return slotFunc.call(this, params, h, vNodes)
376
+ return getSlotVNs(slotFunc.call(this, params, h, vNodes))
376
377
  }
377
378
  }
378
379
  return []
@@ -272,7 +272,8 @@ export default {
272
272
  document.onmouseup = function (evnt) {
273
273
  document.onmousemove = domMousemove
274
274
  document.onmouseup = domMouseup
275
- column.resizeWidth = column.renderWidth + (isRightFixed ? dragPosLeft - dragLeft : dragLeft - dragPosLeft)
275
+ const resizeWidth = column.renderWidth + (isRightFixed ? dragPosLeft - dragLeft : dragLeft - dragPosLeft)
276
+ column.resizeWidth = resizeWidth
276
277
  resizeBarElem.style.display = 'none'
277
278
  $xetable._isResize = false
278
279
  $xetable._lastResizeTime = Date.now()
@@ -280,7 +281,7 @@ export default {
280
281
  $xetable.recalculate(true).then(() => {
281
282
  $xetable.saveCustomResizable()
282
283
  $xetable.updateCellAreas()
283
- $xetable.emitEvent('resizable-change', params, evnt)
284
+ $xetable.emitEvent('resizable-change', { ...params, resizeWidth }, evnt)
284
285
  })
285
286
  DomTools.removeClass($xetable.$el, 'drag--resize')
286
287
  }
@@ -5,6 +5,7 @@ import UtilTools, { getFuncText } from '../../tools/utils'
5
5
  import DomTools from '../../tools/dom'
6
6
  import { GlobalEvent } from '../../tools/event'
7
7
  import { errLog } from '../../tools/log'
8
+ import { getSlotVNs } from '../../tools/vn'
8
9
  import VxeLoading from '../../loading/index'
9
10
 
10
11
  export const allActivedModals = []
@@ -168,8 +169,8 @@ export default {
168
169
  'is--ellipsis': !isMsg && showTitleOverflow
169
170
  }],
170
171
  on: headerOns
171
- }, headerSlot ? (!inited || (destroyOnClose && !visible) ? [] : headerSlot.call(this, { $modal: this }, h)) : [
172
- titleSlot ? titleSlot.call(this, { $modal: this }, h) : h('span', {
172
+ }, headerSlot ? (!inited || (destroyOnClose && !visible) ? [] : getSlotVNs(headerSlot.call(this, { $modal: this }, h))) : [
173
+ titleSlot ? getSlotVNs(titleSlot.call(this, { $modal: this }, h)) : h('span', {
173
174
  class: 'vxe-modal--title'
174
175
  }, title ? getFuncText(title) : GlobalConfig.i18n('vxe.alert.title')),
175
176
  showZoom ? h('i', {
@@ -203,7 +204,7 @@ export default {
203
204
  ]) : null,
204
205
  h('div', {
205
206
  class: 'vxe-modal--content'
206
- }, defaultSlot ? (!inited || (destroyOnClose && !visible) ? [] : defaultSlot.call(this, { $modal: this }, h)) : getFuncText(content)),
207
+ }, defaultSlot ? (!inited || (destroyOnClose && !visible) ? [] : getSlotVNs(defaultSlot.call(this, { $modal: this }, h))) : getFuncText(content)),
207
208
  /**
208
209
  * 加载中
209
210
  */
@@ -216,7 +217,7 @@ export default {
216
217
  ]),
217
218
  showFooter ? h('div', {
218
219
  class: 'vxe-modal--footer'
219
- }, footerSlot ? (!inited || (destroyOnClose && !visible) ? [] : footerSlot.call(this, { $modal: this }, h)) : [
220
+ }, footerSlot ? (!inited || (destroyOnClose && !visible) ? [] : getSlotVNs(footerSlot.call(this, { $modal: this }, h))) : [
220
221
  type === 'confirm' ? h('vxe-button', {
221
222
  ref: 'cancelBtn',
222
223
  on: {
@@ -5,6 +5,7 @@ import vSize from '../../mixins/size'
5
5
  import UtilTools, { getFuncText } from '../../tools/utils'
6
6
  import DomTools from '../../tools/dom'
7
7
  import { GlobalEvent, hasEventKey, EVENT_KEYS } from '../../tools/event'
8
+ import { getSlotVNs } from '../../tools/vn'
8
9
 
9
10
  function isOptionVisible (option) {
10
11
  return option.visible !== false
@@ -474,7 +475,7 @@ export default {
474
475
  slotFunc = $scopedSlots[slotFunc] || null
475
476
  }
476
477
  if (XEUtils.isFunction(slotFunc)) {
477
- return slotFunc.call(this, params, h)
478
+ return getSlotVNs(slotFunc.call(this, params, h))
478
479
  }
479
480
  }
480
481
  return []
@@ -4,6 +4,7 @@ import VXETable from '../../v-x-e-table'
4
4
  import DomTools from '../../tools/dom'
5
5
  import UtilTools, { eqEmptyValue, isEnableConf, getFuncText } from '../../tools/utils'
6
6
  import { getColumnConfig } from './util'
7
+ import { getSlotVNs } from '../../tools/vn'
7
8
 
8
9
  function renderHelpIcon (h, params) {
9
10
  const { $table, column } = params
@@ -78,7 +79,7 @@ function getFooterContent (h, params) {
78
79
  if (renderOpts) {
79
80
  const compConf = VXETable.renderer.get(renderOpts.name)
80
81
  if (compConf && compConf.renderFooter) {
81
- return compConf.renderFooter.call($table, h, renderOpts, params)
82
+ return getSlotVNs(compConf.renderFooter.call($table, h, renderOpts, params))
82
83
  }
83
84
  }
84
85
  return [UtilTools.formatText(items[_columnIndex], 1)]
@@ -152,7 +153,7 @@ export const Cell = {
152
153
  if (renderOpts) {
153
154
  const compConf = VXETable.renderer.get(renderOpts.name)
154
155
  if (compConf && compConf.renderHeader) {
155
- return renderTitleContent(h, params, compConf.renderHeader.call($table, h, renderOpts, params))
156
+ return getSlotVNs(renderTitleContent(h, params, compConf.renderHeader.call($table, h, renderOpts, params)))
156
157
  }
157
158
  }
158
159
  return renderTitleContent(h, params, UtilTools.formatText(column.getTitle(), 1))
@@ -171,7 +172,7 @@ export const Cell = {
171
172
  const funName = editRender ? 'renderCell' : 'renderDefault'
172
173
  const compConf = VXETable.renderer.get(renderOpts.name)
173
174
  if (compConf && compConf[funName]) {
174
- return compConf[funName].call($table, h, renderOpts, Object.assign({ $type: editRender ? 'edit' : 'cell' }, params))
175
+ return getSlotVNs(compConf[funName].call($table, h, renderOpts, Object.assign({ $type: editRender ? 'edit' : 'cell' }, params)))
175
176
  }
176
177
  }
177
178
  const cellValue = $table.getCellLabel(row, column)
@@ -216,9 +217,9 @@ export const Cell = {
216
217
  return $table.callSlot(slots.icon, params, h, cellVNodes)
217
218
  }
218
219
  if (!isHidden) {
219
- isAceived = treeExpandeds.indexOf(row) > -1
220
+ isAceived = $table.findRowIndexOf(treeExpandeds, row) > -1
220
221
  if (lazy) {
221
- isLazyLoaded = treeLazyLoadeds.indexOf(row) > -1
222
+ isLazyLoaded = $table.findRowIndexOf(treeLazyLoadeds, row) > -1
222
223
  hasLazyChilds = row[hasChild]
223
224
  }
224
225
  }
@@ -410,7 +411,7 @@ export const Cell = {
410
411
  },
411
412
  renderCheckboxCell (h, params) {
412
413
  const { $table, row, column, isHidden } = params
413
- const { treeConfig, treeIndeterminates } = $table
414
+ const { treeConfig, treeIndeterminates, selection } = $table
414
415
  const { labelField, checkMethod, visibleMethod } = $table.checkboxOpts
415
416
  const { slots } = column
416
417
  const defaultSlot = slots ? slots.default : null
@@ -421,7 +422,7 @@ export const Cell = {
421
422
  let isDisabled = !!checkMethod
422
423
  let on
423
424
  if (!isHidden) {
424
- isChecked = $table.selection.indexOf(row) > -1
425
+ isChecked = $table.findRowIndexOf(selection, row) > -1
425
426
  on = {
426
427
  click (evnt) {
427
428
  if (!isDisabled && isVisible) {
@@ -433,7 +434,7 @@ export const Cell = {
433
434
  isDisabled = !checkMethod({ row })
434
435
  }
435
436
  if (treeConfig) {
436
- indeterminate = treeIndeterminates.indexOf(row) > -1
437
+ indeterminate = $table.findRowIndexOf(treeIndeterminates, row) > -1
437
438
  }
438
439
  }
439
440
  const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
@@ -500,7 +501,7 @@ export const Cell = {
500
501
  isDisabled = !checkMethod({ row })
501
502
  }
502
503
  if (treeConfig) {
503
- indeterminate = treeIndeterminates.indexOf(row) > -1
504
+ indeterminate = $table.findRowIndexOf(treeIndeterminates, row) > -1
504
505
  }
505
506
  }
506
507
  const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
@@ -558,9 +559,9 @@ export const Cell = {
558
559
  return $table.callSlot(slots.icon, params, h)
559
560
  }
560
561
  if (!isHidden) {
561
- isAceived = rowExpandeds.indexOf(params.row) > -1
562
+ isAceived = $table.findRowIndexOf(rowExpandeds, params.row) > -1
562
563
  if (lazy) {
563
- isLazyLoaded = expandLazyLoadeds.indexOf(row) > -1
564
+ isLazyLoaded = $table.findRowIndexOf(expandLazyLoadeds, row) > -1
564
565
  }
565
566
  }
566
567
  return [
@@ -592,7 +593,7 @@ export const Cell = {
592
593
  if (contentRender) {
593
594
  const compConf = VXETable.renderer.get(contentRender.name)
594
595
  if (compConf && compConf.renderExpand) {
595
- return compConf.renderExpand.call($table, h, contentRender, params)
596
+ return getSlotVNs(compConf.renderExpand.call($table, h, contentRender, params))
596
597
  }
597
598
  }
598
599
  return []
@@ -756,7 +757,10 @@ export const Cell = {
756
757
  if (slots && slots.edit) {
757
758
  return $table.callSlot(slots.edit, params, h)
758
759
  }
759
- return compConf && compConf.renderEdit ? compConf.renderEdit.call($table, h, editRender, Object.assign({ $type: 'edit' }, params)) : []
760
+ if (compConf && compConf.renderEdit) {
761
+ return getSlotVNs(compConf.renderEdit.call($table, h, editRender, Object.assign({ $type: 'edit' }, params)))
762
+ }
763
+ return []
760
764
  }
761
765
  if (slots && slots.default) {
762
766
  return $table.callSlot(slots.default, params, h)