vxe-table 3.25.0-beta.4 → 3.25.0-beta.6

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.
@@ -14,9 +14,7 @@ import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, TableReactData
14
14
 
15
15
  const { warnLog, errLog } = createComponentLog('table')
16
16
 
17
- const { getConfig, getI18n, renderer, scrollbarUtils, formats, interceptor, createEvent, globalEvents, GLOBAL_EVENT_KEYS } = VxeUI
18
-
19
- const { getThumbOffsetSize, getThumbSize, getScrollFromClick, getScrollFromDrag } = scrollbarUtils || {}
17
+ const { getConfig, getI18n, renderer, formats, interceptor, createEvent, globalEvents, GLOBAL_EVENT_KEYS } = VxeUI
20
18
 
21
19
  const supportMaxRow = 5e6
22
20
  const customStorageKey = 'VXE_CUSTOM_STORE'
@@ -4241,9 +4239,16 @@ function handleSyncScroll ($xeTable: VxeTableConstructor & VxeTablePrivateMethod
4241
4239
  internalData.inHeaderScroll = false
4242
4240
  internalData.inBodyScroll = false
4243
4241
  internalData.inFooterScroll = false
4242
+ internalData.isSyncGanttScrollTop = false
4244
4243
  reactData.lazScrollLoading = false
4245
4244
  internalData.scrollRenderType = ''
4246
4245
 
4246
+ const $xeGanttView = internalData.xeGanttView
4247
+ if ($xeGanttView) {
4248
+ const ganttInternalData = $xeGanttView.internalData
4249
+ ganttInternalData.isSyncTableScrollTop = false
4250
+ }
4251
+
4247
4252
  let xRest = null
4248
4253
  let yRest = null
4249
4254
  if (!isAllOverflow) {
@@ -4322,14 +4327,15 @@ const getWheelSpeed = (lastScrollTime: number) => {
4322
4327
  const syncGanttScrollTop = ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, scrollTop: number) => {
4323
4328
  const internalData = $xeTable as unknown as TableInternalData
4324
4329
 
4330
+ const { isSyncGanttScrollTop } = internalData
4331
+ if (isSyncGanttScrollTop) {
4332
+ return
4333
+ }
4325
4334
  const $xeGanttView = internalData.xeGanttView
4326
4335
  if ($xeGanttView) {
4327
4336
  const ganttInternalData = $xeGanttView.internalData
4328
- const { elemStore: ganttElemStore } = ganttInternalData
4329
- const ganttBodyScrollElem = getRefElem(ganttElemStore['main-body-scroll'])
4330
- if (ganttBodyScrollElem) {
4331
- ganttBodyScrollElem.scrollTop = scrollTop
4332
- }
4337
+ ganttInternalData.isSyncTableScrollTop = true
4338
+ $xeGanttView.handleSyncScrollTop({ scrollTop })
4333
4339
  }
4334
4340
  }
4335
4341
 
@@ -4885,6 +4891,14 @@ const tableMethods: any = {
4885
4891
 
4886
4892
  return $xeTable.$refs.refElem as HTMLDivElement
4887
4893
  },
4894
+ getScrollViewElem () {
4895
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4896
+ const internalData = $xeTable as unknown as TableInternalData
4897
+
4898
+ const { elemStore } = internalData
4899
+ const viewEl = getRefElem(elemStore['main-body-scroll'])
4900
+ return viewEl
4901
+ },
4888
4902
  /**
4889
4903
  * 获取父容器元素
4890
4904
  */
@@ -10275,7 +10289,7 @@ const tableMethods: any = {
10275
10289
  * @private
10276
10290
  */
10277
10291
  updateScrollbar () {
10278
- const $xeTable = this
10292
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
10279
10293
 
10280
10294
  const isVScrollbar = $xeTable.computeIsVScrollbar
10281
10295
  if (isVScrollbar) {
@@ -12780,7 +12794,10 @@ const tableMethods: any = {
12780
12794
  direction,
12781
12795
  ...params
12782
12796
  }
12783
- $xeTable.updateThumbOffset()
12797
+ const isVScrollbar = $xeTable.computeIsVScrollbar
12798
+ if (isVScrollbar) {
12799
+ $xeTable.updateThumbOffset()
12800
+ }
12784
12801
  updateRowExpandStyle($xeTable)
12785
12802
  checkLastSyncScroll($xeTable, isRollX, isRollY)
12786
12803
  if (isRollX) {
@@ -13334,6 +13351,19 @@ const tableMethods: any = {
13334
13351
  $xeTable.updateScrollYSpace()
13335
13352
  })
13336
13353
  },
13354
+ handleSyncScrollTop (params: {
13355
+ scrollTop: number
13356
+ }) {
13357
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
13358
+ const internalData = $xeTable as unknown as TableInternalData
13359
+
13360
+ const { scrollTop } = params
13361
+ const { elemStore } = internalData
13362
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
13363
+ if (bodyScrollElem) {
13364
+ bodyScrollElem.scrollTop = scrollTop
13365
+ }
13366
+ },
13337
13367
  // 更新纵向 Y 可视渲染上下剩余空间大小
13338
13368
  updateScrollYSpace () {
13339
13369
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
@@ -14058,210 +14088,6 @@ const tableMethods: any = {
14058
14088
 
14059
14089
  return $xeTable.handleClearStack()
14060
14090
  },
14061
-
14062
- // 滚动条
14063
- updateThumbSize () {
14064
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
14065
- const reactData = $xeTable as unknown as TableReactData
14066
- const internalData = $xeTable as unknown as TableInternalData
14067
-
14068
- const { elemStore } = internalData
14069
- const viewEl = getRefElem(elemStore['main-body-scroll'])
14070
- if (!viewEl) {
14071
- return
14072
- }
14073
- if (!viewEl.clientHeight || !viewEl.clientHeight) {
14074
- return
14075
- }
14076
- const trackXEl = $xeTable.$refs.refTrackXElem as HTMLDivElement
14077
- const xThumbWidth = trackXEl ? getThumbSize(viewEl.clientWidth, viewEl.scrollWidth, trackXEl.clientWidth) : 0
14078
- const thumbXElem = $xeTable.$refs.refThumbXElem as HTMLDivElement
14079
- if (thumbXElem) {
14080
- thumbXElem.style.width = xThumbWidth + 'px'
14081
- }
14082
- reactData.xThumbWidth = xThumbWidth
14083
-
14084
- const trackYEl = $xeTable.$refs.refTrackYElem as HTMLDivElement
14085
-
14086
- const yThumbHeight = trackYEl ? getThumbSize(viewEl.clientHeight, viewEl.scrollHeight, trackYEl.clientHeight) : 0
14087
- const thumbYElem = $xeTable.$refs.refThumbYElem as HTMLDivElement
14088
- if (thumbYElem) {
14089
- thumbYElem.style.height = yThumbHeight + 'px'
14090
- }
14091
- reactData.yThumbHeight = yThumbHeight
14092
- },
14093
- updateThumbOffset () {
14094
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
14095
- const reactData = $xeTable as unknown as TableReactData
14096
- const internalData = $xeTable as unknown as TableInternalData
14097
-
14098
- const { elemStore } = internalData
14099
- const viewEl = getRefElem(elemStore['main-body-scroll'])
14100
- if (!viewEl) {
14101
- return
14102
- }
14103
- if (!viewEl.clientHeight || !viewEl.clientHeight) {
14104
- return
14105
- }
14106
- const { xThumbWidth, yThumbHeight } = reactData
14107
- const trackXEl = $xeTable.$refs.refTrackXElem as HTMLDivElement
14108
- const thumbXElem = $xeTable.$refs.refThumbXElem as HTMLDivElement
14109
- const xThumbLeft = trackXEl && xThumbWidth ? getThumbOffsetSize(viewEl.scrollLeft, viewEl.clientWidth, viewEl.scrollWidth, trackXEl.clientWidth, xThumbWidth) : 0
14110
- internalData.xThumbLeft = xThumbLeft
14111
- if (thumbXElem && xThumbWidth) {
14112
- thumbXElem.style.width = xThumbWidth + 'px'
14113
- thumbXElem.style.transform = `translateX(${xThumbLeft}px)`
14114
- }
14115
-
14116
- const trackYEl = $xeTable.$refs.refTrackYElem as HTMLDivElement
14117
- const thumbYElem = $xeTable.$refs.refThumbYElem as HTMLDivElement
14118
- const yThumbTop = trackYEl && yThumbHeight ? getThumbOffsetSize(viewEl.scrollTop, viewEl.clientHeight, viewEl.scrollHeight, trackYEl.clientHeight, yThumbHeight) : 0
14119
- internalData.yThumbTop = yThumbTop
14120
- if (thumbYElem && yThumbHeight) {
14121
- thumbYElem.style.height = yThumbHeight + 'px'
14122
- thumbYElem.style.transform = `translateY(${yThumbTop}px)`
14123
- }
14124
- },
14125
- clickTrackXEvent (evnt: MouseEvent) {
14126
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
14127
- const reactData = $xeTable as unknown as TableReactData
14128
- const internalData = $xeTable as unknown as TableInternalData
14129
-
14130
- const { elemStore } = internalData
14131
- const trackEl = evnt.currentTarget as HTMLDivElement
14132
- if (trackEl !== evnt.target) {
14133
- return
14134
- }
14135
- const viewEl = getRefElem(elemStore['main-body-scroll'])
14136
- if (!viewEl) {
14137
- return
14138
- }
14139
- const { xThumbWidth } = reactData
14140
- const trackRect = trackEl.getBoundingClientRect()
14141
- viewEl.scrollTo({
14142
- left: getScrollFromClick(evnt.clientX - trackRect.left, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth),
14143
- behavior: 'auto'
14144
- })
14145
- },
14146
- clickTrackYEvent (evnt: MouseEvent) {
14147
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
14148
- const reactData = $xeTable as unknown as TableReactData
14149
- const internalData = $xeTable as unknown as TableInternalData
14150
-
14151
- const trackEl = evnt.currentTarget as HTMLDivElement
14152
- if (trackEl !== evnt.target) {
14153
- return
14154
- }
14155
- const { elemStore } = internalData
14156
- const viewEl = getRefElem(elemStore['main-body-scroll'])
14157
- if (!viewEl) {
14158
- return
14159
- }
14160
- const { yThumbHeight } = reactData
14161
- const trackRect = trackEl.getBoundingClientRect()
14162
- viewEl.scrollTo({
14163
- top: getScrollFromClick(evnt.clientY - trackRect.top, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight),
14164
- behavior: 'auto'
14165
- })
14166
- },
14167
- pointerdownThumbXEvent (evnt: PointerEvent) {
14168
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
14169
- const reactData = $xeTable as unknown as TableReactData
14170
- const internalData = $xeTable as unknown as TableInternalData
14171
-
14172
- const { elemStore } = internalData
14173
- const thumbEl = evnt.currentTarget as HTMLDivElement
14174
- internalData.isThumbDrag = true
14175
- thumbEl.setPointerCapture(evnt.pointerId)
14176
-
14177
- const viewEl = getRefElem(elemStore['main-body-scroll'])
14178
- if (!viewEl) {
14179
- return
14180
- }
14181
- const { xThumbWidth } = reactData
14182
- const trackEl = thumbEl.parentElement as HTMLDivElement
14183
- const trackRect = trackEl.getBoundingClientRect()
14184
- const pointerPosition = evnt.clientX - trackRect.left
14185
- // 记录 thumb 的偏移
14186
- const thumbOffset = getThumbOffsetSize(viewEl.scrollLeft, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth)
14187
- internalData.thumbDragOffset = pointerPosition - thumbOffset
14188
- },
14189
- pointermoveThumbXEvent (evnt: PointerEvent) {
14190
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
14191
- const reactData = $xeTable as unknown as TableReactData
14192
- const internalData = $xeTable as unknown as TableInternalData
14193
-
14194
- const thumbEl = evnt.currentTarget as HTMLDivElement
14195
- if (!thumbEl.hasPointerCapture(evnt.pointerId)) {
14196
- return
14197
- }
14198
- const { elemStore, isThumbDrag, thumbDragOffset } = internalData
14199
- if (isThumbDrag) {
14200
- const viewEl = getRefElem(elemStore['main-body-scroll'])
14201
- if (!viewEl) {
14202
- return
14203
- }
14204
- const { xThumbWidth } = reactData
14205
- const thumbEl = evnt.currentTarget as HTMLDivElement
14206
- const trackEl = thumbEl.parentElement as HTMLDivElement
14207
- const trackRect = trackEl.getBoundingClientRect()
14208
- // 更新偏移
14209
- viewEl.scrollLeft = getScrollFromDrag(evnt.clientX - trackRect.left, thumbDragOffset, viewEl.clientWidth, viewEl.scrollWidth, trackEl.clientWidth, xThumbWidth)
14210
- }
14211
- },
14212
- cleatPointerThumbEvent (evnt: PointerEvent) {
14213
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
14214
- const internalData = $xeTable as unknown as TableInternalData
14215
-
14216
- const thumbEl = evnt.currentTarget as HTMLDivElement
14217
- thumbEl.releasePointerCapture(evnt.pointerId)
14218
- internalData.isThumbDrag = false
14219
- },
14220
- pointerdownThumbYEvent (evnt: PointerEvent) {
14221
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
14222
- const reactData = $xeTable as unknown as TableReactData
14223
- const internalData = $xeTable as unknown as TableInternalData
14224
-
14225
- const { elemStore } = internalData
14226
- const thumbEl = evnt.currentTarget as HTMLDivElement
14227
- internalData.isThumbDrag = true
14228
- thumbEl.setPointerCapture(evnt.pointerId)
14229
- const viewEl = getRefElem(elemStore['main-body-scroll'])
14230
- if (!viewEl) {
14231
- return
14232
- }
14233
- const { yThumbHeight } = reactData
14234
- const trackEl = thumbEl.parentElement as HTMLDivElement
14235
- const trackRect = trackEl.getBoundingClientRect()
14236
- const pointerPosition = evnt.clientY - trackRect.top
14237
- // 记录 thumb 的偏移
14238
- const thumbOffset = getThumbOffsetSize(viewEl.scrollTop, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight)
14239
- internalData.thumbDragOffset = pointerPosition - thumbOffset
14240
- },
14241
- pointermoveThumbYEvent (evnt: PointerEvent) {
14242
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
14243
- const reactData = $xeTable as unknown as TableReactData
14244
- const internalData = $xeTable as unknown as TableInternalData
14245
-
14246
- const thumbEl = evnt.currentTarget as HTMLDivElement
14247
- if (!thumbEl.hasPointerCapture(evnt.pointerId)) {
14248
- return
14249
- }
14250
- const { elemStore, isThumbDrag, thumbDragOffset } = internalData
14251
- if (isThumbDrag) {
14252
- const viewEl = getRefElem(elemStore['main-body-scroll'])
14253
- if (!viewEl) {
14254
- return
14255
- }
14256
- const { yThumbHeight } = reactData
14257
- const thumbEl = evnt.currentTarget as HTMLDivElement
14258
- const trackEl = thumbEl.parentElement as HTMLDivElement
14259
- const trackRect = trackEl.getBoundingClientRect()
14260
- // 更新偏移
14261
- viewEl.scrollTop = getScrollFromDrag(evnt.clientY - trackRect.top, thumbDragOffset, viewEl.clientHeight, viewEl.scrollHeight, trackEl.clientHeight, yThumbHeight)
14262
- }
14263
- },
14264
- // 滚动条
14265
14091
  dispatchEvent (type: ValueOf<VxeTableEmits>, params: Record<string, any>, evnt: Event | null) {
14266
14092
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
14267
14093
  const $xeGrid = $xeTable.$xeGrid
@@ -14324,6 +14150,16 @@ const tableMethods: any = {
14324
14150
  }
14325
14151
  return $xeTable.$nextTick()
14326
14152
  },
14153
+ getInternalData () {
14154
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
14155
+ const internalData = $xeTable as unknown as TableInternalData
14156
+ return internalData
14157
+ },
14158
+ getReactData () {
14159
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
14160
+ const reactData = $xeTable as unknown as TableReactData
14161
+ return reactData
14162
+ },
14327
14163
 
14328
14164
  /*************************
14329
14165
  * Publish methods
@@ -26,7 +26,7 @@ import keyboardMixin from '../module/keyboard/mixin'
26
26
  import validatorMixin from '../module/validator/mixin'
27
27
  import customMixin from '../module/custom/mixin'
28
28
 
29
- import type { VxeTabsConstructor, VxeTabsPrivateMethods, VxeComponentStyleType, VxeModalConstructor, VxeModalMethods } from 'vxe-pc-ui'
29
+ import type { VxeTabsConstructor, VxeTabsPrivateMethods, VxeComponentStyleType, VxeModalConstructor, VxeModalMethods, VxeUseSizeComputed, VxeUseVScrollbarComputed, VxeUseInitVScrollbarComputed } from 'vxe-pc-ui'
30
30
  import type { VxeTableConstructor, VxeTablePrivateMethods, VxeTablePropTypes, TableInternalData, TableReactData, VxeTableDefines } from '../../../types'
31
31
 
32
32
  const { warnLog, errLog } = createComponentLog('table')
@@ -624,18 +624,18 @@ function renderVirtualBody (h: CreateElement, $xeTable: VxeTableConstructor & Vx
624
624
  ref: 'refTrackXElem',
625
625
  class: 'vxe-scrollbar--track-x',
626
626
  on: {
627
- click: ($xeTable as any).clickTrackXEvent
627
+ click: $xeTable.clickTrackXEvent
628
628
  }
629
629
  }, [
630
630
  h('div', {
631
631
  ref: 'refThumbXElem',
632
632
  class: 'vxe-scrollbar--thumb-x',
633
633
  on: {
634
- pointerdown: ($xeTable as any).pointerdownThumbXEvent,
635
- pointermove: ($xeTable as any).pointermoveThumbXEvent,
636
- pointerup: ($xeTable as any).cleatPointerThumbEvent,
637
- pointercancel: ($xeTable as any).cleatPointerThumbEvent,
638
- lostpointercapture: ($xeTable as any).cleatPointerThumbEvent
634
+ pointerdown: $xeTable.pointerdownThumbXEvent,
635
+ pointermove: $xeTable.pointermoveThumbXEvent,
636
+ pointerup: $xeTable.cleatPointerThumbEvent,
637
+ pointercancel: $xeTable.cleatPointerThumbEvent,
638
+ lostpointercapture: $xeTable.cleatPointerThumbEvent
639
639
  }
640
640
  })
641
641
  ]),
@@ -645,18 +645,18 @@ function renderVirtualBody (h: CreateElement, $xeTable: VxeTableConstructor & Vx
645
645
  ref: 'refTrackYElem',
646
646
  class: 'vxe-scrollbar--track-y',
647
647
  on: {
648
- click: ($xeTable as any).clickTrackYEvent
648
+ click: $xeTable.clickTrackYEvent
649
649
  }
650
650
  }, [
651
651
  h('div', {
652
652
  ref: 'refThumbYElem',
653
653
  class: 'vxe-scrollbar--thumb-y',
654
654
  on: {
655
- pointerdown: ($xeTable as any).pointerdownThumbYEvent,
656
- pointermove: ($xeTable as any).pointermoveThumbYEvent,
657
- pointerup: ($xeTable as any).cleatPointerThumbEvent,
658
- pointercancel: ($xeTable as any).cleatPointerThumbEvent,
659
- lostpointercapture: ($xeTable as any).cleatPointerThumbEvent
655
+ pointerdown: $xeTable.pointerdownThumbYEvent,
656
+ pointermove: $xeTable.pointermoveThumbYEvent,
657
+ pointerup: $xeTable.cleatPointerThumbEvent,
658
+ pointercancel: $xeTable.cleatPointerThumbEvent,
659
+ lostpointercapture: $xeTable.cleatPointerThumbEvent
660
660
  }
661
661
  })
662
662
  ])
@@ -668,6 +668,8 @@ export default {
668
668
  name: 'VxeTable',
669
669
  mixins: [
670
670
  globalMixins.sizeMixin,
671
+ globalMixins.vScrollbarMixin,
672
+ globalMixins.initVScrollbarMixin,
671
673
  filterMixin,
672
674
  menuMixin,
673
675
  editMixin,
@@ -723,7 +725,7 @@ export default {
723
725
  }
724
726
  },
725
727
  computed: {
726
- ...({} as {
728
+ ...({} as VxeUseSizeComputed & VxeUseVScrollbarComputed & VxeUseInitVScrollbarComputed & {
727
729
  $xeModal(): (VxeModalConstructor & VxeModalMethods)| null
728
730
  $xeTabs(): (VxeTabsConstructor & VxeTabsPrivateMethods) | null
729
731
  }),
@@ -2532,7 +2534,7 @@ export default {
2532
2534
  footer: slots.footerTooltip || slots['footer-tooltip']
2533
2535
  }
2534
2536
  const currTooltipSlot = tooltipStore.visible && tooltipStore.type ? tipSlots[tooltipStore.type] : null
2535
- const tableStyle = ($xeTable as any).computeTableStyle as VxeComponentStyleType
2537
+ const tableStyle = $xeTable.computeTableStyle
2536
2538
  const rowDragOpts = $xeTable.computeRowDragOpts
2537
2539
  const tableTipConfig = $xeTable.computeTableTipConfig
2538
2540
  const validTipConfig = $xeTable.computeValidTipConfig
@@ -176,10 +176,44 @@ export function createInternalData (): TableInternalData {
176
176
  initStatus: false,
177
177
  isActivated: false,
178
178
 
179
+ // keyCtxTimeout: undefined,
180
+
181
+ // 刷新布局
179
182
  // rceTimeout: undefined,
180
183
  // rceRunTime: undefined,
181
184
  rceDelay: 0
182
185
 
186
+ // rsePending: false,
187
+
188
+ // 滚动属性
189
+ // intoRunScroll: false,
190
+ // inVirtualScroll: false,
191
+ // inWheelScroll: false,
192
+
193
+ // inHeaderScroll: false,
194
+ // inBodyScroll: false,
195
+ // inFooterScroll: false,
196
+ // scrollRenderType?: '',
197
+
198
+ // isSyncGanttScrollTop: false,
199
+
200
+ // 同步滚动
201
+ // lcsTimeout: undefined,
202
+ // lcsRunTime: undefined,
203
+
204
+ // 横向虚拟
205
+ // lxRunTime: undefined,
206
+ // lxTimeout: undefined,
207
+ // 纵向虚拟
208
+ // lyRunTime: undefined,
209
+ // lyTimeout: undefined,
210
+
211
+ // 动态高度
212
+ // chRunTime: undefined,
213
+ // chTimeout: undefined,
214
+
215
+ // isResizeCellHeight: false,
216
+
183
217
  // _sToTime: null
184
218
  }
185
219
  }