vxe-pc-ui 4.9.0 → 4.9.2

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 (59) hide show
  1. package/es/icon/style.css +1 -1
  2. package/es/modal/src/modal.js +5 -2
  3. package/es/split/src/split-pane.js +3 -3
  4. package/es/split/src/split.js +244 -141
  5. package/es/split/style.css +82 -45
  6. package/es/split/style.min.css +1 -1
  7. package/es/style.css +1 -1
  8. package/es/style.min.css +1 -1
  9. package/es/tabs/src/tabs.js +6 -3
  10. package/es/ui/index.js +1 -1
  11. package/es/ui/src/log.js +1 -1
  12. package/es/upload/src/upload.js +7 -2
  13. package/es/vxe-split/style.css +82 -45
  14. package/es/vxe-split/style.min.css +1 -1
  15. package/lib/icon/style/style.css +1 -1
  16. package/lib/icon/style/style.min.css +1 -1
  17. package/lib/index.umd.js +270 -166
  18. package/lib/index.umd.min.js +1 -1
  19. package/lib/modal/src/modal.js +5 -2
  20. package/lib/modal/src/modal.min.js +1 -1
  21. package/lib/split/src/split-pane.js +3 -3
  22. package/lib/split/src/split-pane.min.js +1 -1
  23. package/lib/split/src/split.js +247 -154
  24. package/lib/split/src/split.min.js +1 -1
  25. package/lib/split/style/style.css +82 -45
  26. package/lib/split/style/style.min.css +1 -1
  27. package/lib/style.css +1 -1
  28. package/lib/style.min.css +1 -1
  29. package/lib/tabs/src/tabs.js +6 -3
  30. package/lib/tabs/src/tabs.min.js +1 -1
  31. package/lib/ui/index.js +1 -1
  32. package/lib/ui/index.min.js +1 -1
  33. package/lib/ui/src/log.js +1 -1
  34. package/lib/ui/src/log.min.js +1 -1
  35. package/lib/upload/src/upload.js +7 -2
  36. package/lib/upload/src/upload.min.js +1 -1
  37. package/lib/vxe-split/style/style.css +82 -45
  38. package/lib/vxe-split/style/style.min.css +1 -1
  39. package/package.json +1 -1
  40. package/packages/modal/src/modal.ts +6 -2
  41. package/packages/split/src/split-pane.ts +4 -3
  42. package/packages/split/src/split.ts +243 -142
  43. package/packages/tabs/src/tabs.ts +7 -3
  44. package/packages/upload/src/upload.ts +8 -2
  45. package/styles/components/split.scss +109 -88
  46. package/types/components/split-pane.d.ts +11 -2
  47. package/types/components/split.d.ts +26 -22
  48. /package/es/icon/{iconfont.1756083805751.ttf → iconfont.1756133787659.ttf} +0 -0
  49. /package/es/icon/{iconfont.1756083805751.woff → iconfont.1756133787659.woff} +0 -0
  50. /package/es/icon/{iconfont.1756083805751.woff2 → iconfont.1756133787659.woff2} +0 -0
  51. /package/es/{iconfont.1756083805751.ttf → iconfont.1756133787659.ttf} +0 -0
  52. /package/es/{iconfont.1756083805751.woff → iconfont.1756133787659.woff} +0 -0
  53. /package/es/{iconfont.1756083805751.woff2 → iconfont.1756133787659.woff2} +0 -0
  54. /package/lib/icon/style/{iconfont.1756083805751.ttf → iconfont.1756133787659.ttf} +0 -0
  55. /package/lib/icon/style/{iconfont.1756083805751.woff → iconfont.1756133787659.woff} +0 -0
  56. /package/lib/icon/style/{iconfont.1756083805751.woff2 → iconfont.1756133787659.woff2} +0 -0
  57. /package/lib/{iconfont.1756083805751.ttf → iconfont.1756133787659.ttf} +0 -0
  58. /package/lib/{iconfont.1756083805751.woff → iconfont.1756133787659.woff} +0 -0
  59. /package/lib/{iconfont.1756083805751.woff2 → iconfont.1756133787659.woff2} +0 -0
@@ -4,7 +4,7 @@ import { getConfig, getIcon, createEvent, globalEvents, globalResize, renderEmpt
4
4
  import { getSlotVNs } from '../../ui/src/vn'
5
5
  import { toCssUnit, isScale, addClass, removeClass } from '../../ui/src/dom'
6
6
  import { getGlobalDefaultConfig } from '../../ui/src/utils'
7
- import { errLog } from '../../ui/src/log'
7
+ import { warnLog, errLog } from '../../ui/src/log'
8
8
  import XEUtils from 'xe-utils'
9
9
 
10
10
  import type { SplitReactData, SplitPrivateRef, VxeSplitPropTypes, SplitInternalData, SplitMethods, VxeSplitDefines, VxeSplitPaneProps, VxeSplitPrivateComputed, SplitPrivateMethods, VxeSplitEmits, VxeSplitConstructor, ValueOf, VxeSplitPrivateMethods } from '../../../types'
@@ -50,11 +50,14 @@ export default defineVxeComponent({
50
50
  const xID = XEUtils.uniqueId()
51
51
 
52
52
  const refElem = ref<HTMLDivElement>()
53
+ const refBarInfoElem = ref<HTMLDivElement>()
53
54
  const refResizableSplitTip = ref<HTMLDivElement>()
54
55
 
55
56
  const reactData = reactive<SplitReactData>({
56
57
  staticItems: [],
57
- itemList: []
58
+ itemList: [],
59
+ barWidth: 0,
60
+ barHeight: 0
58
61
  })
59
62
 
60
63
  const internalData: SplitInternalData = {
@@ -78,13 +81,8 @@ export default defineVxeComponent({
78
81
  return Object.assign({}, getConfig().split.actionConfig, props.actionConfig)
79
82
  })
80
83
 
81
- const computeIsFoldNext = computed(() => {
82
- const actionOpts = computeActionOpts.value
83
- return actionOpts.direction === 'next'
84
- })
85
-
86
84
  const computeVisibleItems = computed(() => {
87
- return reactData.itemList.filter(item => item.isVisible)
85
+ return reactData.itemList.filter(item => item.isExpand)
88
86
  })
89
87
 
90
88
  const computeAutoItems = computed(() => {
@@ -94,16 +92,16 @@ export default defineVxeComponent({
94
92
  let widthCount = 0
95
93
  reactData.itemList.forEach(vertical
96
94
  ? item => {
97
- const { renderHeight, resizeHeight, foldHeight, isVisible, height } = item
98
- const itemHeight = isVisible ? (foldHeight || resizeHeight || renderHeight) : 0
95
+ const { renderHeight, resizeHeight, foldHeight, isExpand, height } = item
96
+ const itemHeight = isExpand ? (foldHeight || resizeHeight || renderHeight) : 0
99
97
  if (!height) {
100
98
  autoItems.push(item)
101
99
  }
102
100
  heightCount += itemHeight
103
101
  }
104
102
  : item => {
105
- const { renderWidth, resizeWidth, foldWidth, isVisible, width } = item
106
- const itemWidth = isVisible ? (foldWidth || resizeWidth || renderWidth) : 0
103
+ const { renderWidth, resizeWidth, foldWidth, isExpand, width } = item
104
+ const itemWidth = isExpand ? (foldWidth || resizeWidth || renderWidth) : 0
107
105
  if (!width) {
108
106
  autoItems.push(item)
109
107
  }
@@ -134,8 +132,7 @@ export default defineVxeComponent({
134
132
  const computeMaps: VxeSplitPrivateComputed = {
135
133
  computeItemOpts,
136
134
  computeBarOpts,
137
- computeActionOpts,
138
- computeIsFoldNext
135
+ computeActionOpts
139
136
  }
140
137
 
141
138
  const refMaps: SplitPrivateRef = {
@@ -169,33 +166,29 @@ export default defineVxeComponent({
169
166
  return []
170
167
  }
171
168
 
172
- const getDefaultActionIcon = (item: VxeSplitDefines.PaneConfig) => {
169
+ const getActionIcon = (prevItem: VxeSplitDefines.PaneConfig, nextItem: VxeSplitDefines.PaneConfig, isNext: boolean) => {
173
170
  const { vertical } = props
174
- const { showAction, isExpand } = item
175
- const isFoldNext = computeIsFoldNext.value
176
171
  const topIcon = 'SPLIT_TOP_ACTION'
177
172
  const bottomIcon = 'SPLIT_BOTTOM_ACTION'
178
173
  const leftIcon = 'SPLIT_LEFT_ACTION'
179
174
  const rightIcon = 'SPLIT_RIGHT_ACTION'
180
- if (showAction) {
181
- let iconName: 'SPLIT_TOP_ACTION' | 'SPLIT_BOTTOM_ACTION' | 'SPLIT_LEFT_ACTION' | 'SPLIT_RIGHT_ACTION' | '' = ''
182
- if (isFoldNext) {
183
- if (vertical) {
184
- iconName = isExpand ? bottomIcon : topIcon
185
- } else {
186
- iconName = isExpand ? rightIcon : leftIcon
187
- }
175
+ let iconName: 'SPLIT_TOP_ACTION' | 'SPLIT_BOTTOM_ACTION' | 'SPLIT_LEFT_ACTION' | 'SPLIT_RIGHT_ACTION' | '' = ''
176
+ if (vertical) {
177
+ if (isNext) {
178
+ iconName = nextItem.isExpand ? bottomIcon : topIcon
188
179
  } else {
189
- if (vertical) {
190
- iconName = isExpand ? topIcon : bottomIcon
191
- } else {
192
- iconName = isExpand ? leftIcon : rightIcon
193
- }
180
+ iconName = prevItem.isExpand ? topIcon : bottomIcon
194
181
  }
195
- if (iconName) {
196
- return getIcon()[iconName]
182
+ } else {
183
+ if (isNext) {
184
+ iconName = nextItem.isExpand ? rightIcon : leftIcon
185
+ } else {
186
+ iconName = prevItem.isExpand ? leftIcon : rightIcon
197
187
  }
198
188
  }
189
+ if (iconName) {
190
+ return getIcon()[iconName]
191
+ }
199
192
  return ''
200
193
  }
201
194
 
@@ -203,7 +196,6 @@ export default defineVxeComponent({
203
196
  const { itemList } = reactData
204
197
  itemList.forEach(item => {
205
198
  item.isExpand = true
206
- item.isVisible = true
207
199
  item.foldHeight = 0
208
200
  item.foldWidth = 0
209
201
  item.resizeHeight = 0
@@ -214,8 +206,9 @@ export default defineVxeComponent({
214
206
 
215
207
  const handleLoadItem = (list: VxeSplitPaneProps[], isReset: boolean) => {
216
208
  const { staticItems } = reactData
209
+ const actionOpts = computeActionOpts.value
210
+ const { showPrevButton, showNextButton } = actionOpts
217
211
  const itemDef = {
218
- isVisible: true,
219
212
  isExpand: true,
220
213
  renderWidth: 0,
221
214
  resizeWidth: 0,
@@ -225,6 +218,9 @@ export default defineVxeComponent({
225
218
  foldHeight: 0
226
219
  }
227
220
  reactData.itemList = list.map(item => {
221
+ if (item.showAction) {
222
+ warnLog('vxe.error.removeProp', ['showAction'])
223
+ }
228
224
  if (item.slots) {
229
225
  XEUtils.each(item.slots, (func) => {
230
226
  if (!XEUtils.isFunction(func)) {
@@ -241,6 +237,9 @@ export default defineVxeComponent({
241
237
  if (staticItems.length) {
242
238
  errLog('vxe.error.errConflicts', ['<vxe-split-pane ...>', 'items'])
243
239
  }
240
+ if ((showPrevButton || showNextButton) && reactData.itemList.length > 2) {
241
+ errLog('vxe.error.errConflicts', ['action-config.showPrevButton | action-config.showNextButton', 'Only supports 2 item'])
242
+ }
244
243
  return recalculate()
245
244
  }
246
245
 
@@ -257,6 +256,7 @@ export default defineVxeComponent({
257
256
  const { vertical } = props
258
257
  const { itemList } = reactData
259
258
  const el = refElem.value
259
+ const barInfoElem = refBarInfoElem.value
260
260
  if (!el) {
261
261
  return
262
262
  }
@@ -265,6 +265,12 @@ export default defineVxeComponent({
265
265
  if (!wWidth || !wHeight) {
266
266
  return
267
267
  }
268
+ if (barInfoElem) {
269
+ reactData.barWidth = barInfoElem.offsetWidth
270
+ reactData.barHeight = barInfoElem.offsetHeight
271
+ }
272
+ const contentWidth = wWidth - (vertical ? 0 : reactData.barWidth * (itemList.length - 1))
273
+ const contentHeight = wHeight - (vertical ? reactData.barHeight * (itemList.length - 1) : 0)
268
274
  const itemOpts = computeItemOpts.value
269
275
  const allMinWidth = XEUtils.toNumber(itemOpts.minWidth)
270
276
  const allMinHeight = XEUtils.toNumber(itemOpts.minHeight)
@@ -276,7 +282,7 @@ export default defineVxeComponent({
276
282
  let itemHeight = 0
277
283
  if (height) {
278
284
  if (isScale(height)) {
279
- itemHeight = wHeight * XEUtils.toNumber(height) / 100
285
+ itemHeight = contentHeight * XEUtils.toNumber(height) / 100
280
286
  } else {
281
287
  itemHeight = XEUtils.toNumber(height)
282
288
  }
@@ -287,7 +293,7 @@ export default defineVxeComponent({
287
293
  countHeight += itemHeight
288
294
  })
289
295
  if (residueItems.length) {
290
- const reMeanHeight = (wHeight - countHeight) / residueItems.length
296
+ const reMeanHeight = (contentHeight - countHeight) / residueItems.length
291
297
  residueItems.forEach(item => {
292
298
  item.renderHeight = Math.max(XEUtils.toNumber(getGlobalDefaultConfig(item.minHeight, allMinHeight)), reMeanHeight)
293
299
  })
@@ -299,7 +305,7 @@ export default defineVxeComponent({
299
305
  let itemWidth = 0
300
306
  if (width) {
301
307
  if (isScale(width)) {
302
- itemWidth = wWidth * XEUtils.toNumber(width) / 100
308
+ itemWidth = contentWidth * XEUtils.toNumber(width) / 100
303
309
  } else {
304
310
  itemWidth = XEUtils.toNumber(width)
305
311
  }
@@ -310,14 +316,14 @@ export default defineVxeComponent({
310
316
  countWidth += itemWidth
311
317
  })
312
318
  if (residueItems.length) {
313
- const reMeanWidth = (wWidth - countWidth) / residueItems.length
319
+ const reMeanWidth = (contentWidth - countWidth) / residueItems.length
314
320
  residueItems.forEach(item => {
315
321
  item.renderWidth = Math.max(XEUtils.toNumber(getGlobalDefaultConfig(item.minWidth, allMinWidth)), reMeanWidth)
316
322
  })
317
323
  }
318
324
  }
319
- internalData.wrapperWidth = wWidth
320
- internalData.wrapperHeight = wHeight
325
+ internalData.wrapperWidth = contentWidth
326
+ internalData.wrapperHeight = contentHeight
321
327
  })
322
328
  }
323
329
 
@@ -334,36 +340,28 @@ export default defineVxeComponent({
334
340
  if (!el) {
335
341
  return
336
342
  }
337
- const itemId = handleEl.getAttribute('itemid')
338
- const itemIndex = XEUtils.findIndexOf(itemList, item => item.id === itemId)
339
- const item = itemList[itemIndex]
340
- if (!item) {
343
+ const prevEl = handleEl.previousElementSibling as HTMLDivElement
344
+ const nextEl = handleEl.nextElementSibling as HTMLDivElement
345
+ if (!prevEl || !nextEl) {
341
346
  return
342
347
  }
343
- if (!item.isExpand) {
348
+ const prevId = prevEl.getAttribute('itemid')
349
+ const nextId = nextEl.getAttribute('itemid')
350
+ const prevItem = itemList.find(item => item.id === prevId)
351
+ const nextItem = itemList.find(item => item.id === nextId)
352
+ if (!prevItem || !nextItem) {
344
353
  return
345
354
  }
346
355
  const containerRect = el.getBoundingClientRect()
347
356
  const barRect = barEl.getBoundingClientRect()
348
357
  const rsSplitLineEl = refResizableSplitTip.value
349
358
  const rsSplitTipEl = rsSplitLineEl ? rsSplitLineEl.children[0] as HTMLDivElement : null
350
- const isFoldNext = computeIsFoldNext.value
351
359
  const itemOpts = computeItemOpts.value
352
360
  const resizeOpts = computeResizeOpts.value
353
361
  const { immediate } = resizeOpts
354
362
  const allMinWidth = XEUtils.toNumber(itemOpts.minWidth)
355
363
  const allMinHeight = XEUtils.toNumber(itemOpts.minHeight)
356
364
 
357
- const targetItem = itemList[itemIndex + (isFoldNext ? 1 : -1)]
358
-
359
- const prevItem = itemList[itemIndex + (isFoldNext ? 0 : -1)]
360
- const nextItem = itemList[itemIndex + (isFoldNext ? 1 : 0)]
361
- const prevEl = targetItem ? el.querySelector<HTMLDivElement>(`.vxe-split-pane[itemid="${prevItem.id}"]`) : null
362
- const nextEl = item ? el.querySelector<HTMLDivElement>(`.vxe-split-pane[itemid="${nextItem.id}"]`) : null
363
- if (!prevEl || !nextEl) {
364
- return
365
- }
366
-
367
365
  const barOffsetX = Math.ceil(barRect.width - (evnt.clientX - barRect.left))
368
366
  const barOffsetY = Math.ceil(evnt.clientY - barRect.top)
369
367
 
@@ -504,7 +502,7 @@ export default defineVxeComponent({
504
502
  if (rsSplitLineEl) {
505
503
  handleReStyle(evnt)
506
504
  }
507
- dispatchEvent('resize-drag', { item, name: item.name, prevItem, nextItem, offsetHeight: targetOffsetHeight, offsetWidth: targetOffsetWidth }, evnt)
505
+ dispatchEvent('resize-drag', { prevItem, nextItem, offsetHeight: targetOffsetHeight, offsetWidth: targetOffsetWidth }, evnt)
508
506
  }
509
507
 
510
508
  document.onmousemove = (evnt) => {
@@ -519,7 +517,7 @@ export default defineVxeComponent({
519
517
  }
520
518
  handleUpdate()
521
519
  removeClass(el, 'is--drag')
522
- dispatchEvent('resize-end', { item, name: item.name, prevItem, nextItem, offsetHeight: targetOffsetHeight, offsetWidth: targetOffsetWidth }, evnt)
520
+ dispatchEvent('resize-end', { prevItem, nextItem, offsetHeight: targetOffsetHeight, offsetWidth: targetOffsetWidth }, evnt)
523
521
  recalculate()
524
522
  }
525
523
 
@@ -529,77 +527,130 @@ export default defineVxeComponent({
529
527
  }
530
528
  handleDrag(evnt)
531
529
  addClass(el, 'is--drag')
532
- dispatchEvent('resize-start', { item, name: item.name, prevItem, nextItem }, evnt)
530
+ dispatchEvent('resize-start', { prevItem, nextItem }, evnt)
533
531
  }
534
532
 
535
- const handleItemActionEvent = (evnt: MouseEvent) => {
536
- const el = refElem.value
537
- if (!el) {
538
- return
539
- }
533
+ const handleItemActionEvent = (evnt: MouseEvent, prevItem: VxeSplitDefines.PaneConfig, nextItem: VxeSplitDefines.PaneConfig, isNext: boolean) => {
540
534
  const { vertical } = props
535
+ let expanded = false
536
+ let item = prevItem
537
+ if (isNext) {
538
+ item = nextItem
539
+ expanded = !nextItem.isExpand
540
+ nextItem.isExpand = expanded
541
+ } else {
542
+ expanded = !prevItem.isExpand
543
+ prevItem.isExpand = expanded
544
+ }
545
+ if (vertical) {
546
+ if (prevItem.isExpand && nextItem.isExpand) {
547
+ prevItem.foldHeight = 0
548
+ nextItem.foldHeight = 0
549
+ } else if (prevItem.isExpand) {
550
+ nextItem.foldHeight = 0
551
+ prevItem.foldHeight = (prevItem.resizeHeight || prevItem.renderHeight) + (nextItem.resizeHeight || nextItem.renderHeight)
552
+ } else {
553
+ prevItem.foldHeight = 0
554
+ nextItem.foldHeight = (prevItem.resizeHeight || prevItem.renderHeight) + (nextItem.resizeHeight || nextItem.renderHeight)
555
+ }
556
+ } else {
557
+ if (prevItem.isExpand && nextItem.isExpand) {
558
+ prevItem.foldWidth = 0
559
+ nextItem.foldWidth = 0
560
+ } else if (prevItem.isExpand) {
561
+ nextItem.foldWidth = 0
562
+ prevItem.foldWidth = (prevItem.resizeWidth || prevItem.renderWidth) + (nextItem.resizeWidth || nextItem.renderWidth)
563
+ } else {
564
+ prevItem.foldWidth = 0
565
+ nextItem.foldWidth = (prevItem.resizeWidth || prevItem.renderWidth) + (nextItem.resizeWidth || nextItem.renderWidth)
566
+ }
567
+ }
568
+ dispatchEvent('toggle-expand', { prevItem, nextItem, expanded, item }, evnt)
569
+ recalculate()
570
+ }
571
+
572
+ const handlePrevActionDblclickEvent = (evnt: MouseEvent) => {
541
573
  const { itemList } = reactData
542
- const isFoldNext = computeIsFoldNext.value
574
+ const actionOpts = computeActionOpts.value
543
575
  const btnEl = evnt.currentTarget as HTMLDivElement
544
- const handleEl = btnEl.parentElement as HTMLDivElement
545
- const itemId = handleEl.getAttribute('itemid')
546
- const itemIndex = XEUtils.findIndexOf(itemList, item => item.id === itemId)
547
- const item = itemList[itemIndex]
548
- const targetItem = itemList[itemIndex + (isFoldNext ? 1 : -1)]
549
- if (item) {
550
- const { showAction, isExpand } = item
551
- if (showAction) {
552
- if (vertical) {
553
- if (targetItem) {
554
- targetItem.isVisible = !isExpand
555
- targetItem.foldHeight = 0
556
- item.isExpand = !isExpand
557
- item.isVisible = true
558
- item.foldHeight = isExpand ? (targetItem.resizeHeight || targetItem.renderHeight) + (item.resizeHeight || item.renderHeight) : 0
559
- }
560
- } else {
561
- if (targetItem) {
562
- targetItem.isVisible = !isExpand
563
- targetItem.foldWidth = 0
564
- item.isExpand = !isExpand
565
- item.isVisible = true
566
- item.foldWidth = isExpand ? (targetItem.resizeWidth || targetItem.renderWidth) + (item.resizeWidth || item.renderWidth) : 0
567
- }
568
- }
569
- dispatchEvent('toggle-expand', { item, name: item.name, targetItem, targetName: targetItem ? targetItem.name : '', expanded: item.isExpand }, evnt)
570
- recalculate()
576
+ const btnWrapperEl = btnEl.parentElement as HTMLDivElement
577
+ const handleEl = btnWrapperEl.parentElement as HTMLDivElement
578
+ const prevEl = handleEl.previousElementSibling as HTMLDivElement
579
+ const prevId = prevEl.getAttribute('itemid')
580
+ const prevItem = itemList.find(item => item.id === prevId)
581
+ const nextEl = handleEl.nextElementSibling as HTMLDivElement
582
+ const nextId = nextEl.getAttribute('itemid')
583
+ const nextItem = itemList.find(item => item.id === nextId)
584
+
585
+ if (actionOpts.trigger === 'dblclick') {
586
+ if (prevItem && nextItem && nextItem.isExpand) {
587
+ handleItemActionEvent(evnt, prevItem, nextItem, false)
588
+ }
589
+ }
590
+ dispatchEvent('action-dblclick', { prevItem, nextItem }, evnt)
591
+ }
592
+
593
+ const handlePrevActionClickEvent = (evnt: MouseEvent) => {
594
+ const { itemList } = reactData
595
+ const actionOpts = computeActionOpts.value
596
+ const btnEl = evnt.currentTarget as HTMLDivElement
597
+ const btnWrapperEl = btnEl.parentElement as HTMLDivElement
598
+ const handleEl = btnWrapperEl.parentElement as HTMLDivElement
599
+ const prevEl = handleEl.previousElementSibling as HTMLDivElement
600
+ const prevId = prevEl.getAttribute('itemid')
601
+ const prevItem = itemList.find(item => item.id === prevId)
602
+ const nextEl = handleEl.nextElementSibling as HTMLDivElement
603
+ const nextId = nextEl.getAttribute('itemid')
604
+ const nextItem = itemList.find(item => item.id === nextId)
605
+
606
+ if (actionOpts.trigger !== 'dblclick') {
607
+ if (prevItem && nextItem && nextItem.isExpand) {
608
+ handleItemActionEvent(evnt, prevItem, nextItem, false)
571
609
  }
572
610
  }
611
+ dispatchEvent('action-click', { prevItem, nextItem }, evnt)
573
612
  }
574
613
 
575
- const handleActionDblclickEvent = (evnt: MouseEvent) => {
614
+ const handleNextActionDblclickEvent = (evnt: MouseEvent) => {
576
615
  const { itemList } = reactData
577
616
  const actionOpts = computeActionOpts.value
578
617
  const btnEl = evnt.currentTarget as HTMLDivElement
579
- const handleEl = btnEl.parentElement as HTMLDivElement
580
- const itemId = handleEl.getAttribute('itemid')
581
- const itemIndex = XEUtils.findIndexOf(itemList, item => item.id === itemId)
582
- const item = itemList[itemIndex]
618
+ const btnWrapperEl = btnEl.parentElement as HTMLDivElement
619
+ const handleEl = btnWrapperEl.parentElement as HTMLDivElement
620
+ const prevEl = handleEl.previousElementSibling as HTMLDivElement
621
+ const prevId = prevEl.getAttribute('itemid')
622
+ const prevItem = itemList.find(item => item.id === prevId)
623
+ const nextEl = handleEl.nextElementSibling as HTMLDivElement
624
+ const nextId = nextEl.getAttribute('itemid')
625
+ const nextItem = itemList.find(item => item.id === nextId)
583
626
 
584
627
  if (actionOpts.trigger === 'dblclick') {
585
- handleItemActionEvent(evnt)
628
+ if (prevItem && nextItem && prevItem.isExpand) {
629
+ handleItemActionEvent(evnt, prevItem, nextItem, true)
630
+ }
586
631
  }
587
- dispatchEvent('action-dblclick', { item, name: item ? item.name : '' }, evnt)
632
+ dispatchEvent('action-dblclick', { prevItem, nextItem }, evnt)
588
633
  }
589
634
 
590
- const handleActionClickEvent = (evnt: MouseEvent) => {
635
+ const handleNextActionClickEvent = (evnt: MouseEvent) => {
591
636
  const { itemList } = reactData
592
637
  const actionOpts = computeActionOpts.value
593
638
  const btnEl = evnt.currentTarget as HTMLDivElement
594
- const handleEl = btnEl.parentElement as HTMLDivElement
595
- const itemId = handleEl.getAttribute('itemid')
596
- const itemIndex = XEUtils.findIndexOf(itemList, item => item.id === itemId)
597
- const item = itemList[itemIndex]
639
+ const btnWrapperEl = btnEl.parentElement as HTMLDivElement
640
+ const handleEl = btnWrapperEl.parentElement as HTMLDivElement
641
+ const prevEl = handleEl.previousElementSibling as HTMLDivElement
642
+ const prevId = prevEl.getAttribute('itemid')
643
+ const prevItem = itemList.find(item => item.id === prevId)
644
+ const nextEl = handleEl.nextElementSibling as HTMLDivElement
645
+ const nextId = nextEl.getAttribute('itemid')
646
+ const nextItem = itemList.find(item => item.id === nextId)
598
647
 
599
648
  if (actionOpts.trigger !== 'dblclick') {
600
- handleItemActionEvent(evnt)
649
+ if (prevItem && nextItem && prevItem.isExpand) {
650
+ handleItemActionEvent(evnt, prevItem, nextItem, true)
651
+ }
601
652
  }
602
- dispatchEvent('action-click', { item, name: item ? item.name : '' }, evnt)
653
+ dispatchEvent('action-click', { prevItem, nextItem }, evnt)
603
654
  }
604
655
 
605
656
  const handleGlobalResizeEvent = () => {
@@ -619,30 +670,53 @@ export default defineVxeComponent({
619
670
 
620
671
  Object.assign($xeSplit, splitMethods, splitPrivateMethods)
621
672
 
622
- const renderHandleBar = (item: VxeSplitDefines.PaneConfig) => {
673
+ const renderHandleBar = (prevItem: VxeSplitDefines.PaneConfig, nextItem: VxeSplitDefines.PaneConfig) => {
674
+ const { border, resize, vertical } = props
675
+ const { itemList } = reactData
623
676
  const barStyle = computeBarStyle.value
624
677
  const actionOpts = computeActionOpts.value
625
- const isFoldNext = computeIsFoldNext.value
626
- const { id, isExpand, showAction } = item
627
-
678
+ const { direction } = actionOpts
679
+ const showPrevButton = XEUtils.isBoolean(actionOpts.showPrevButton) ? actionOpts.showPrevButton : (itemList.some(item => item.showAction))
680
+ const showNextButton = XEUtils.isBoolean(actionOpts.showNextButton) ? actionOpts.showNextButton : (direction === 'next' && itemList.some(item => item.showAction))
681
+ const resizeOpts = computeResizeOpts.value
682
+ const { immediate } = resizeOpts
628
683
  return h('div', {
629
- itemid: id,
630
- class: ['vxe-split-pane-handle', isFoldNext ? 'to--next' : 'to--prev']
684
+ class: ['vxe-split-pane-handle', vertical ? 'is--vertical' : 'is--horizontal', immediate ? 'is-resize--immediate' : 'is-resize--lazy', {
685
+ 'is--resize': resize,
686
+ 'is--border': border
687
+ }]
631
688
  }, [
632
689
  h('div', {
633
690
  class: 'vxe-split-pane-handle-bar',
634
691
  style: barStyle,
635
692
  onMousedown: dragEvent
636
693
  }),
637
- showAction
638
- ? h('span', {
639
- class: 'vxe-split-pane-action-btn',
640
- onDblclick: handleActionDblclickEvent,
641
- onClick: handleActionClickEvent
694
+ itemList.length === 2
695
+ ? h('div', {
696
+ class: 'vxe-split-pane-action-btn-wrapper'
642
697
  }, [
643
- h('i', {
644
- class: (isExpand ? actionOpts.openIcon : actionOpts.closeIcon) || getDefaultActionIcon(item)
645
- })
698
+ showPrevButton && nextItem.isExpand
699
+ ? h('div', {
700
+ class: 'vxe-split-pane-action-btn',
701
+ onDblclick: handlePrevActionDblclickEvent,
702
+ onClick: handlePrevActionClickEvent
703
+ }, [
704
+ h('i', {
705
+ class: getActionIcon(prevItem, nextItem, false)
706
+ })
707
+ ])
708
+ : renderEmptyElement($xeSplit),
709
+ showNextButton && prevItem.isExpand
710
+ ? h('div', {
711
+ class: 'vxe-split-pane-action-btn',
712
+ onDblclick: handleNextActionDblclickEvent,
713
+ onClick: handleNextActionClickEvent
714
+ }, [
715
+ h('i', {
716
+ class: getActionIcon(prevItem, nextItem, true)
717
+ })
718
+ ])
719
+ : renderEmptyElement($xeSplit)
646
720
  ])
647
721
  : renderEmptyElement($xeSplit)
648
722
  ])
@@ -655,34 +729,36 @@ export default defineVxeComponent({
655
729
  const { immediate } = resizeOpts
656
730
  const visibleItems = computeVisibleItems.value
657
731
  const { autoItems } = computeAutoItems.value
658
- const isFoldNext = computeIsFoldNext.value
659
732
  const itemVNs: VNode[] = []
660
- itemList.forEach((item, index) => {
661
- const { id, name, slots, renderHeight, resizeHeight, foldHeight, renderWidth, resizeWidth, foldWidth, isVisible, isExpand } = item
733
+ itemList.forEach((prevItem, index) => {
734
+ const { id, name, slots, renderHeight, resizeHeight, foldHeight, renderWidth, resizeWidth, foldWidth, isExpand } = prevItem
735
+ const nextItem = itemList[index + 1]
662
736
  const defaultSlot = slots ? slots.default : null
663
737
  const stys: Record<string, string | number> = {}
664
- let itemWidth = isVisible ? (foldWidth || resizeWidth || renderWidth) : 0
665
- let itemHeight = isVisible ? (foldHeight || resizeHeight || renderHeight) : 0
738
+ let itemWidth = isExpand ? (foldWidth || resizeWidth || renderWidth) : 0
739
+ let itemHeight = isExpand ? (foldHeight || resizeHeight || renderHeight) : 0
666
740
  // 至少存在一个自适应
667
741
  if (autoItems.length === 1) {
668
742
  if (vertical) {
669
- if (!item.height) {
743
+ if (!prevItem.height) {
670
744
  itemHeight = 0
671
745
  }
672
746
  } else {
673
- if (!item.width) {
747
+ if (!prevItem.width) {
674
748
  itemWidth = 0
675
749
  }
676
750
  }
677
751
  }
678
- // 当只剩下一个可视区自动占用 100%
752
+ let isFill = true
679
753
  if (vertical) {
680
- if (itemHeight) {
681
- stys.height = visibleItems.length === 1 ? '100%' : toCssUnit(itemHeight)
754
+ if (itemHeight && visibleItems.length > 1) {
755
+ isFill = false
756
+ stys.height = toCssUnit(itemHeight)
682
757
  }
683
758
  } else {
684
- if (itemWidth) {
685
- stys.width = visibleItems.length === 1 ? '100%' : toCssUnit(itemWidth)
759
+ if (itemWidth && visibleItems.length > 1) {
760
+ isFill = false
761
+ stys.width = toCssUnit(itemWidth)
686
762
  }
687
763
  }
688
764
 
@@ -695,25 +771,26 @@ export default defineVxeComponent({
695
771
  'is--border': border,
696
772
  'is--height': itemHeight,
697
773
  'is--width': itemWidth,
698
- 'is--fill': isVisible && !itemHeight && !itemWidth,
699
- 'is--handle': index > 0,
700
- 'is--expand': isExpand,
701
- 'is--hidden': !isVisible
774
+ 'is--visible': isExpand,
775
+ 'is--hidden': !isExpand,
776
+ 'is--fill': isExpand && isFill
702
777
  }],
703
778
  style: stys
704
779
  }, [
705
- index && !isFoldNext ? renderHandleBar(item) : renderEmptyElement($xeSplit),
706
780
  h('div', {
707
781
  itemid: id,
708
782
  class: 'vxe-split-pane--wrapper'
709
783
  }, [
710
784
  h('div', {
711
785
  class: 'vxe-split-pane--inner'
712
- }, defaultSlot ? callSlot(defaultSlot, { name, isVisible, isExpand }) : [])
713
- ]),
714
- isFoldNext && index < itemList.length - 1 ? renderHandleBar(item) : renderEmptyElement($xeSplit)
786
+ }, defaultSlot ? callSlot(defaultSlot, { name, isExpand }) : [])
787
+ ])
715
788
  ])
716
789
  )
790
+
791
+ if (nextItem) {
792
+ itemVNs.push(renderHandleBar(prevItem, nextItem))
793
+ }
717
794
  })
718
795
  return h('div', {
719
796
  class: 'vxe-split-wrapper'
@@ -757,7 +834,15 @@ export default defineVxeComponent({
757
834
  })
758
835
  ])
759
836
  ]
760
- : [])
837
+ : []),
838
+ h('div', {
839
+ class: 'vxe-split--render-vars'
840
+ }, [
841
+ h('div', {
842
+ ref: refBarInfoElem,
843
+ class: 'vxe-split--handle-bar-info'
844
+ })
845
+ ])
761
846
  ])
762
847
  }
763
848
 
@@ -773,10 +858,21 @@ export default defineVxeComponent({
773
858
  })
774
859
 
775
860
  watch(() => reactData.staticItems, (val) => {
861
+ const actionOpts = computeActionOpts.value
862
+ const { showPrevButton, showNextButton } = actionOpts
776
863
  if (props.items && props.items.length) {
777
864
  errLog('vxe.error.errConflicts', ['<vxe-split-pane ...>', 'items'])
778
865
  }
779
- reactData.itemList = val
866
+ reactData.itemList = val || []
867
+
868
+ if ((showPrevButton || showNextButton) && reactData.itemList.length > 2) {
869
+ errLog('vxe.error.modelConflicts', ['action-config.showPrevButton | action-config.showNextButton', '<vxe-split-pane ...> Only supports 2 panel'])
870
+ }
871
+ reactData.itemList.forEach(item => {
872
+ if (item.showAction) {
873
+ warnLog('vxe.error.removeProp', ['showAction'])
874
+ }
875
+ })
780
876
  recalculate()
781
877
  })
782
878
 
@@ -795,6 +891,11 @@ export default defineVxeComponent({
795
891
  resizeObserver.observe(el)
796
892
  }
797
893
 
894
+ const actionOpts = computeActionOpts.value
895
+ if (actionOpts.direction) {
896
+ errLog('vxe.error.delProp', ['action-config.direction', 'action-config.showPrevButton | action-config.showNextButton'])
897
+ }
898
+
798
899
  globalEvents.on($xeSplit, 'resize', handleGlobalResizeEvent)
799
900
  })
800
901