vxe-pc-ui 4.9.1 → 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 (47) hide show
  1. package/es/icon/style.css +1 -1
  2. package/es/split/src/split-pane.js +3 -3
  3. package/es/split/src/split.js +244 -141
  4. package/es/split/style.css +82 -45
  5. package/es/split/style.min.css +1 -1
  6. package/es/style.css +1 -1
  7. package/es/style.min.css +1 -1
  8. package/es/ui/index.js +1 -1
  9. package/es/ui/src/log.js +1 -1
  10. package/es/vxe-split/style.css +82 -45
  11. package/es/vxe-split/style.min.css +1 -1
  12. package/lib/icon/style/style.css +1 -1
  13. package/lib/icon/style/style.min.css +1 -1
  14. package/lib/index.umd.js +252 -159
  15. package/lib/index.umd.min.js +1 -1
  16. package/lib/split/src/split-pane.js +3 -3
  17. package/lib/split/src/split-pane.min.js +1 -1
  18. package/lib/split/src/split.js +247 -154
  19. package/lib/split/src/split.min.js +1 -1
  20. package/lib/split/style/style.css +82 -45
  21. package/lib/split/style/style.min.css +1 -1
  22. package/lib/style.css +1 -1
  23. package/lib/style.min.css +1 -1
  24. package/lib/ui/index.js +1 -1
  25. package/lib/ui/index.min.js +1 -1
  26. package/lib/ui/src/log.js +1 -1
  27. package/lib/ui/src/log.min.js +1 -1
  28. package/lib/vxe-split/style/style.css +82 -45
  29. package/lib/vxe-split/style/style.min.css +1 -1
  30. package/package.json +1 -1
  31. package/packages/split/src/split-pane.ts +4 -3
  32. package/packages/split/src/split.ts +243 -142
  33. package/styles/components/split.scss +109 -88
  34. package/types/components/split-pane.d.ts +11 -2
  35. package/types/components/split.d.ts +26 -22
  36. /package/es/icon/{iconfont.1756086135196.ttf → iconfont.1756133787659.ttf} +0 -0
  37. /package/es/icon/{iconfont.1756086135196.woff → iconfont.1756133787659.woff} +0 -0
  38. /package/es/icon/{iconfont.1756086135196.woff2 → iconfont.1756133787659.woff2} +0 -0
  39. /package/es/{iconfont.1756086135196.ttf → iconfont.1756133787659.ttf} +0 -0
  40. /package/es/{iconfont.1756086135196.woff → iconfont.1756133787659.woff} +0 -0
  41. /package/es/{iconfont.1756086135196.woff2 → iconfont.1756133787659.woff2} +0 -0
  42. /package/lib/icon/style/{iconfont.1756086135196.ttf → iconfont.1756133787659.ttf} +0 -0
  43. /package/lib/icon/style/{iconfont.1756086135196.woff → iconfont.1756133787659.woff} +0 -0
  44. /package/lib/icon/style/{iconfont.1756086135196.woff2 → iconfont.1756133787659.woff2} +0 -0
  45. /package/lib/{iconfont.1756086135196.ttf → iconfont.1756133787659.ttf} +0 -0
  46. /package/lib/{iconfont.1756086135196.woff → iconfont.1756133787659.woff} +0 -0
  47. /package/lib/{iconfont.1756086135196.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
  export default defineVxeComponent({
10
10
  name: 'VxeSplit',
@@ -45,10 +45,13 @@ export default defineVxeComponent({
45
45
  const { emit, slots } = context;
46
46
  const xID = XEUtils.uniqueId();
47
47
  const refElem = ref();
48
+ const refBarInfoElem = ref();
48
49
  const refResizableSplitTip = ref();
49
50
  const reactData = reactive({
50
51
  staticItems: [],
51
- itemList: []
52
+ itemList: [],
53
+ barWidth: 0,
54
+ barHeight: 0
52
55
  });
53
56
  const internalData = {
54
57
  wrapperWidth: 0,
@@ -66,12 +69,8 @@ export default defineVxeComponent({
66
69
  const computeActionOpts = computed(() => {
67
70
  return Object.assign({}, getConfig().split.actionConfig, props.actionConfig);
68
71
  });
69
- const computeIsFoldNext = computed(() => {
70
- const actionOpts = computeActionOpts.value;
71
- return actionOpts.direction === 'next';
72
- });
73
72
  const computeVisibleItems = computed(() => {
74
- return reactData.itemList.filter(item => item.isVisible);
73
+ return reactData.itemList.filter(item => item.isExpand);
75
74
  });
76
75
  const computeAutoItems = computed(() => {
77
76
  const { vertical } = props;
@@ -80,16 +79,16 @@ export default defineVxeComponent({
80
79
  let widthCount = 0;
81
80
  reactData.itemList.forEach(vertical
82
81
  ? item => {
83
- const { renderHeight, resizeHeight, foldHeight, isVisible, height } = item;
84
- const itemHeight = isVisible ? (foldHeight || resizeHeight || renderHeight) : 0;
82
+ const { renderHeight, resizeHeight, foldHeight, isExpand, height } = item;
83
+ const itemHeight = isExpand ? (foldHeight || resizeHeight || renderHeight) : 0;
85
84
  if (!height) {
86
85
  autoItems.push(item);
87
86
  }
88
87
  heightCount += itemHeight;
89
88
  }
90
89
  : item => {
91
- const { renderWidth, resizeWidth, foldWidth, isVisible, width } = item;
92
- const itemWidth = isVisible ? (foldWidth || resizeWidth || renderWidth) : 0;
90
+ const { renderWidth, resizeWidth, foldWidth, isExpand, width } = item;
91
+ const itemWidth = isExpand ? (foldWidth || resizeWidth || renderWidth) : 0;
93
92
  if (!width) {
94
93
  autoItems.push(item);
95
94
  }
@@ -118,8 +117,7 @@ export default defineVxeComponent({
118
117
  const computeMaps = {
119
118
  computeItemOpts,
120
119
  computeBarOpts,
121
- computeActionOpts,
122
- computeIsFoldNext
120
+ computeActionOpts
123
121
  };
124
122
  const refMaps = {
125
123
  refElem
@@ -147,35 +145,31 @@ export default defineVxeComponent({
147
145
  }
148
146
  return [];
149
147
  };
150
- const getDefaultActionIcon = (item) => {
148
+ const getActionIcon = (prevItem, nextItem, isNext) => {
151
149
  const { vertical } = props;
152
- const { showAction, isExpand } = item;
153
- const isFoldNext = computeIsFoldNext.value;
154
150
  const topIcon = 'SPLIT_TOP_ACTION';
155
151
  const bottomIcon = 'SPLIT_BOTTOM_ACTION';
156
152
  const leftIcon = 'SPLIT_LEFT_ACTION';
157
153
  const rightIcon = 'SPLIT_RIGHT_ACTION';
158
- if (showAction) {
159
- let iconName = '';
160
- if (isFoldNext) {
161
- if (vertical) {
162
- iconName = isExpand ? bottomIcon : topIcon;
163
- }
164
- else {
165
- iconName = isExpand ? rightIcon : leftIcon;
166
- }
154
+ let iconName = '';
155
+ if (vertical) {
156
+ if (isNext) {
157
+ iconName = nextItem.isExpand ? bottomIcon : topIcon;
167
158
  }
168
159
  else {
169
- if (vertical) {
170
- iconName = isExpand ? topIcon : bottomIcon;
171
- }
172
- else {
173
- iconName = isExpand ? leftIcon : rightIcon;
174
- }
160
+ iconName = prevItem.isExpand ? topIcon : bottomIcon;
175
161
  }
176
- if (iconName) {
177
- return getIcon()[iconName];
162
+ }
163
+ else {
164
+ if (isNext) {
165
+ iconName = nextItem.isExpand ? rightIcon : leftIcon;
178
166
  }
167
+ else {
168
+ iconName = prevItem.isExpand ? leftIcon : rightIcon;
169
+ }
170
+ }
171
+ if (iconName) {
172
+ return getIcon()[iconName];
179
173
  }
180
174
  return '';
181
175
  };
@@ -183,7 +177,6 @@ export default defineVxeComponent({
183
177
  const { itemList } = reactData;
184
178
  itemList.forEach(item => {
185
179
  item.isExpand = true;
186
- item.isVisible = true;
187
180
  item.foldHeight = 0;
188
181
  item.foldWidth = 0;
189
182
  item.resizeHeight = 0;
@@ -193,8 +186,9 @@ export default defineVxeComponent({
193
186
  };
194
187
  const handleLoadItem = (list, isReset) => {
195
188
  const { staticItems } = reactData;
189
+ const actionOpts = computeActionOpts.value;
190
+ const { showPrevButton, showNextButton } = actionOpts;
196
191
  const itemDef = {
197
- isVisible: true,
198
192
  isExpand: true,
199
193
  renderWidth: 0,
200
194
  resizeWidth: 0,
@@ -204,6 +198,9 @@ export default defineVxeComponent({
204
198
  foldHeight: 0
205
199
  };
206
200
  reactData.itemList = list.map(item => {
201
+ if (item.showAction) {
202
+ warnLog('vxe.error.removeProp', ['showAction']);
203
+ }
207
204
  if (item.slots) {
208
205
  XEUtils.each(item.slots, (func) => {
209
206
  if (!XEUtils.isFunction(func)) {
@@ -220,6 +217,9 @@ export default defineVxeComponent({
220
217
  if (staticItems.length) {
221
218
  errLog('vxe.error.errConflicts', ['<vxe-split-pane ...>', 'items']);
222
219
  }
220
+ if ((showPrevButton || showNextButton) && reactData.itemList.length > 2) {
221
+ errLog('vxe.error.errConflicts', ['action-config.showPrevButton | action-config.showNextButton', 'Only supports 2 item']);
222
+ }
223
223
  return recalculate();
224
224
  };
225
225
  const loadItem = (list) => {
@@ -233,6 +233,7 @@ export default defineVxeComponent({
233
233
  const { vertical } = props;
234
234
  const { itemList } = reactData;
235
235
  const el = refElem.value;
236
+ const barInfoElem = refBarInfoElem.value;
236
237
  if (!el) {
237
238
  return;
238
239
  }
@@ -241,6 +242,12 @@ export default defineVxeComponent({
241
242
  if (!wWidth || !wHeight) {
242
243
  return;
243
244
  }
245
+ if (barInfoElem) {
246
+ reactData.barWidth = barInfoElem.offsetWidth;
247
+ reactData.barHeight = barInfoElem.offsetHeight;
248
+ }
249
+ const contentWidth = wWidth - (vertical ? 0 : reactData.barWidth * (itemList.length - 1));
250
+ const contentHeight = wHeight - (vertical ? reactData.barHeight * (itemList.length - 1) : 0);
244
251
  const itemOpts = computeItemOpts.value;
245
252
  const allMinWidth = XEUtils.toNumber(itemOpts.minWidth);
246
253
  const allMinHeight = XEUtils.toNumber(itemOpts.minHeight);
@@ -252,7 +259,7 @@ export default defineVxeComponent({
252
259
  let itemHeight = 0;
253
260
  if (height) {
254
261
  if (isScale(height)) {
255
- itemHeight = wHeight * XEUtils.toNumber(height) / 100;
262
+ itemHeight = contentHeight * XEUtils.toNumber(height) / 100;
256
263
  }
257
264
  else {
258
265
  itemHeight = XEUtils.toNumber(height);
@@ -265,7 +272,7 @@ export default defineVxeComponent({
265
272
  countHeight += itemHeight;
266
273
  });
267
274
  if (residueItems.length) {
268
- const reMeanHeight = (wHeight - countHeight) / residueItems.length;
275
+ const reMeanHeight = (contentHeight - countHeight) / residueItems.length;
269
276
  residueItems.forEach(item => {
270
277
  item.renderHeight = Math.max(XEUtils.toNumber(getGlobalDefaultConfig(item.minHeight, allMinHeight)), reMeanHeight);
271
278
  });
@@ -278,7 +285,7 @@ export default defineVxeComponent({
278
285
  let itemWidth = 0;
279
286
  if (width) {
280
287
  if (isScale(width)) {
281
- itemWidth = wWidth * XEUtils.toNumber(width) / 100;
288
+ itemWidth = contentWidth * XEUtils.toNumber(width) / 100;
282
289
  }
283
290
  else {
284
291
  itemWidth = XEUtils.toNumber(width);
@@ -291,14 +298,14 @@ export default defineVxeComponent({
291
298
  countWidth += itemWidth;
292
299
  });
293
300
  if (residueItems.length) {
294
- const reMeanWidth = (wWidth - countWidth) / residueItems.length;
301
+ const reMeanWidth = (contentWidth - countWidth) / residueItems.length;
295
302
  residueItems.forEach(item => {
296
303
  item.renderWidth = Math.max(XEUtils.toNumber(getGlobalDefaultConfig(item.minWidth, allMinWidth)), reMeanWidth);
297
304
  });
298
305
  }
299
306
  }
300
- internalData.wrapperWidth = wWidth;
301
- internalData.wrapperHeight = wHeight;
307
+ internalData.wrapperWidth = contentWidth;
308
+ internalData.wrapperHeight = contentHeight;
302
309
  });
303
310
  };
304
311
  const dragEvent = (evnt) => {
@@ -314,33 +321,27 @@ export default defineVxeComponent({
314
321
  if (!el) {
315
322
  return;
316
323
  }
317
- const itemId = handleEl.getAttribute('itemid');
318
- const itemIndex = XEUtils.findIndexOf(itemList, item => item.id === itemId);
319
- const item = itemList[itemIndex];
320
- if (!item) {
324
+ const prevEl = handleEl.previousElementSibling;
325
+ const nextEl = handleEl.nextElementSibling;
326
+ if (!prevEl || !nextEl) {
321
327
  return;
322
328
  }
323
- if (!item.isExpand) {
329
+ const prevId = prevEl.getAttribute('itemid');
330
+ const nextId = nextEl.getAttribute('itemid');
331
+ const prevItem = itemList.find(item => item.id === prevId);
332
+ const nextItem = itemList.find(item => item.id === nextId);
333
+ if (!prevItem || !nextItem) {
324
334
  return;
325
335
  }
326
336
  const containerRect = el.getBoundingClientRect();
327
337
  const barRect = barEl.getBoundingClientRect();
328
338
  const rsSplitLineEl = refResizableSplitTip.value;
329
339
  const rsSplitTipEl = rsSplitLineEl ? rsSplitLineEl.children[0] : null;
330
- const isFoldNext = computeIsFoldNext.value;
331
340
  const itemOpts = computeItemOpts.value;
332
341
  const resizeOpts = computeResizeOpts.value;
333
342
  const { immediate } = resizeOpts;
334
343
  const allMinWidth = XEUtils.toNumber(itemOpts.minWidth);
335
344
  const allMinHeight = XEUtils.toNumber(itemOpts.minHeight);
336
- const targetItem = itemList[itemIndex + (isFoldNext ? 1 : -1)];
337
- const prevItem = itemList[itemIndex + (isFoldNext ? 0 : -1)];
338
- const nextItem = itemList[itemIndex + (isFoldNext ? 1 : 0)];
339
- const prevEl = targetItem ? el.querySelector(`.vxe-split-pane[itemid="${prevItem.id}"]`) : null;
340
- const nextEl = item ? el.querySelector(`.vxe-split-pane[itemid="${nextItem.id}"]`) : null;
341
- if (!prevEl || !nextEl) {
342
- return;
343
- }
344
345
  const barOffsetX = Math.ceil(barRect.width - (evnt.clientX - barRect.left));
345
346
  const barOffsetY = Math.ceil(evnt.clientY - barRect.top);
346
347
  const prevWidth = prevEl.offsetWidth;
@@ -484,7 +485,7 @@ export default defineVxeComponent({
484
485
  if (rsSplitLineEl) {
485
486
  handleReStyle(evnt);
486
487
  }
487
- dispatchEvent('resize-drag', { item, name: item.name, prevItem, nextItem, offsetHeight: targetOffsetHeight, offsetWidth: targetOffsetWidth }, evnt);
488
+ dispatchEvent('resize-drag', { prevItem, nextItem, offsetHeight: targetOffsetHeight, offsetWidth: targetOffsetWidth }, evnt);
488
489
  };
489
490
  document.onmousemove = (evnt) => {
490
491
  evnt.preventDefault();
@@ -498,7 +499,7 @@ export default defineVxeComponent({
498
499
  }
499
500
  handleUpdate();
500
501
  removeClass(el, 'is--drag');
501
- dispatchEvent('resize-end', { item, name: item.name, prevItem, nextItem, offsetHeight: targetOffsetHeight, offsetWidth: targetOffsetWidth }, evnt);
502
+ dispatchEvent('resize-end', { prevItem, nextItem, offsetHeight: targetOffsetHeight, offsetWidth: targetOffsetWidth }, evnt);
502
503
  recalculate();
503
504
  };
504
505
  if (rsSplitLineEl) {
@@ -507,73 +508,127 @@ export default defineVxeComponent({
507
508
  }
508
509
  handleDrag(evnt);
509
510
  addClass(el, 'is--drag');
510
- dispatchEvent('resize-start', { item, name: item.name, prevItem, nextItem }, evnt);
511
+ dispatchEvent('resize-start', { prevItem, nextItem }, evnt);
511
512
  };
512
- const handleItemActionEvent = (evnt) => {
513
- const el = refElem.value;
514
- if (!el) {
515
- return;
516
- }
513
+ const handleItemActionEvent = (evnt, prevItem, nextItem, isNext) => {
517
514
  const { vertical } = props;
515
+ let expanded = false;
516
+ let item = prevItem;
517
+ if (isNext) {
518
+ item = nextItem;
519
+ expanded = !nextItem.isExpand;
520
+ nextItem.isExpand = expanded;
521
+ }
522
+ else {
523
+ expanded = !prevItem.isExpand;
524
+ prevItem.isExpand = expanded;
525
+ }
526
+ if (vertical) {
527
+ if (prevItem.isExpand && nextItem.isExpand) {
528
+ prevItem.foldHeight = 0;
529
+ nextItem.foldHeight = 0;
530
+ }
531
+ else if (prevItem.isExpand) {
532
+ nextItem.foldHeight = 0;
533
+ prevItem.foldHeight = (prevItem.resizeHeight || prevItem.renderHeight) + (nextItem.resizeHeight || nextItem.renderHeight);
534
+ }
535
+ else {
536
+ prevItem.foldHeight = 0;
537
+ nextItem.foldHeight = (prevItem.resizeHeight || prevItem.renderHeight) + (nextItem.resizeHeight || nextItem.renderHeight);
538
+ }
539
+ }
540
+ else {
541
+ if (prevItem.isExpand && nextItem.isExpand) {
542
+ prevItem.foldWidth = 0;
543
+ nextItem.foldWidth = 0;
544
+ }
545
+ else if (prevItem.isExpand) {
546
+ nextItem.foldWidth = 0;
547
+ prevItem.foldWidth = (prevItem.resizeWidth || prevItem.renderWidth) + (nextItem.resizeWidth || nextItem.renderWidth);
548
+ }
549
+ else {
550
+ prevItem.foldWidth = 0;
551
+ nextItem.foldWidth = (prevItem.resizeWidth || prevItem.renderWidth) + (nextItem.resizeWidth || nextItem.renderWidth);
552
+ }
553
+ }
554
+ dispatchEvent('toggle-expand', { prevItem, nextItem, expanded, item }, evnt);
555
+ recalculate();
556
+ };
557
+ const handlePrevActionDblclickEvent = (evnt) => {
518
558
  const { itemList } = reactData;
519
- const isFoldNext = computeIsFoldNext.value;
559
+ const actionOpts = computeActionOpts.value;
520
560
  const btnEl = evnt.currentTarget;
521
- const handleEl = btnEl.parentElement;
522
- const itemId = handleEl.getAttribute('itemid');
523
- const itemIndex = XEUtils.findIndexOf(itemList, item => item.id === itemId);
524
- const item = itemList[itemIndex];
525
- const targetItem = itemList[itemIndex + (isFoldNext ? 1 : -1)];
526
- if (item) {
527
- const { showAction, isExpand } = item;
528
- if (showAction) {
529
- if (vertical) {
530
- if (targetItem) {
531
- targetItem.isVisible = !isExpand;
532
- targetItem.foldHeight = 0;
533
- item.isExpand = !isExpand;
534
- item.isVisible = true;
535
- item.foldHeight = isExpand ? (targetItem.resizeHeight || targetItem.renderHeight) + (item.resizeHeight || item.renderHeight) : 0;
536
- }
537
- }
538
- else {
539
- if (targetItem) {
540
- targetItem.isVisible = !isExpand;
541
- targetItem.foldWidth = 0;
542
- item.isExpand = !isExpand;
543
- item.isVisible = true;
544
- item.foldWidth = isExpand ? (targetItem.resizeWidth || targetItem.renderWidth) + (item.resizeWidth || item.renderWidth) : 0;
545
- }
546
- }
547
- dispatchEvent('toggle-expand', { item, name: item.name, targetItem, targetName: targetItem ? targetItem.name : '', expanded: item.isExpand }, evnt);
548
- recalculate();
561
+ const btnWrapperEl = btnEl.parentElement;
562
+ const handleEl = btnWrapperEl.parentElement;
563
+ const prevEl = handleEl.previousElementSibling;
564
+ const prevId = prevEl.getAttribute('itemid');
565
+ const prevItem = itemList.find(item => item.id === prevId);
566
+ const nextEl = handleEl.nextElementSibling;
567
+ const nextId = nextEl.getAttribute('itemid');
568
+ const nextItem = itemList.find(item => item.id === nextId);
569
+ if (actionOpts.trigger === 'dblclick') {
570
+ if (prevItem && nextItem && nextItem.isExpand) {
571
+ handleItemActionEvent(evnt, prevItem, nextItem, false);
572
+ }
573
+ }
574
+ dispatchEvent('action-dblclick', { prevItem, nextItem }, evnt);
575
+ };
576
+ const handlePrevActionClickEvent = (evnt) => {
577
+ const { itemList } = reactData;
578
+ const actionOpts = computeActionOpts.value;
579
+ const btnEl = evnt.currentTarget;
580
+ const btnWrapperEl = btnEl.parentElement;
581
+ const handleEl = btnWrapperEl.parentElement;
582
+ const prevEl = handleEl.previousElementSibling;
583
+ const prevId = prevEl.getAttribute('itemid');
584
+ const prevItem = itemList.find(item => item.id === prevId);
585
+ const nextEl = handleEl.nextElementSibling;
586
+ const nextId = nextEl.getAttribute('itemid');
587
+ const nextItem = itemList.find(item => item.id === nextId);
588
+ if (actionOpts.trigger !== 'dblclick') {
589
+ if (prevItem && nextItem && nextItem.isExpand) {
590
+ handleItemActionEvent(evnt, prevItem, nextItem, false);
549
591
  }
550
592
  }
593
+ dispatchEvent('action-click', { prevItem, nextItem }, evnt);
551
594
  };
552
- const handleActionDblclickEvent = (evnt) => {
595
+ const handleNextActionDblclickEvent = (evnt) => {
553
596
  const { itemList } = reactData;
554
597
  const actionOpts = computeActionOpts.value;
555
598
  const btnEl = evnt.currentTarget;
556
- const handleEl = btnEl.parentElement;
557
- const itemId = handleEl.getAttribute('itemid');
558
- const itemIndex = XEUtils.findIndexOf(itemList, item => item.id === itemId);
559
- const item = itemList[itemIndex];
599
+ const btnWrapperEl = btnEl.parentElement;
600
+ const handleEl = btnWrapperEl.parentElement;
601
+ const prevEl = handleEl.previousElementSibling;
602
+ const prevId = prevEl.getAttribute('itemid');
603
+ const prevItem = itemList.find(item => item.id === prevId);
604
+ const nextEl = handleEl.nextElementSibling;
605
+ const nextId = nextEl.getAttribute('itemid');
606
+ const nextItem = itemList.find(item => item.id === nextId);
560
607
  if (actionOpts.trigger === 'dblclick') {
561
- handleItemActionEvent(evnt);
608
+ if (prevItem && nextItem && prevItem.isExpand) {
609
+ handleItemActionEvent(evnt, prevItem, nextItem, true);
610
+ }
562
611
  }
563
- dispatchEvent('action-dblclick', { item, name: item ? item.name : '' }, evnt);
612
+ dispatchEvent('action-dblclick', { prevItem, nextItem }, evnt);
564
613
  };
565
- const handleActionClickEvent = (evnt) => {
614
+ const handleNextActionClickEvent = (evnt) => {
566
615
  const { itemList } = reactData;
567
616
  const actionOpts = computeActionOpts.value;
568
617
  const btnEl = evnt.currentTarget;
569
- const handleEl = btnEl.parentElement;
570
- const itemId = handleEl.getAttribute('itemid');
571
- const itemIndex = XEUtils.findIndexOf(itemList, item => item.id === itemId);
572
- const item = itemList[itemIndex];
618
+ const btnWrapperEl = btnEl.parentElement;
619
+ const handleEl = btnWrapperEl.parentElement;
620
+ const prevEl = handleEl.previousElementSibling;
621
+ const prevId = prevEl.getAttribute('itemid');
622
+ const prevItem = itemList.find(item => item.id === prevId);
623
+ const nextEl = handleEl.nextElementSibling;
624
+ const nextId = nextEl.getAttribute('itemid');
625
+ const nextItem = itemList.find(item => item.id === nextId);
573
626
  if (actionOpts.trigger !== 'dblclick') {
574
- handleItemActionEvent(evnt);
627
+ if (prevItem && nextItem && prevItem.isExpand) {
628
+ handleItemActionEvent(evnt, prevItem, nextItem, true);
629
+ }
575
630
  }
576
- dispatchEvent('action-click', { item, name: item ? item.name : '' }, evnt);
631
+ dispatchEvent('action-click', { prevItem, nextItem }, evnt);
577
632
  };
578
633
  const handleGlobalResizeEvent = () => {
579
634
  recalculate();
@@ -587,29 +642,53 @@ export default defineVxeComponent({
587
642
  };
588
643
  const splitPrivateMethods = {};
589
644
  Object.assign($xeSplit, splitMethods, splitPrivateMethods);
590
- const renderHandleBar = (item) => {
645
+ const renderHandleBar = (prevItem, nextItem) => {
646
+ const { border, resize, vertical } = props;
647
+ const { itemList } = reactData;
591
648
  const barStyle = computeBarStyle.value;
592
649
  const actionOpts = computeActionOpts.value;
593
- const isFoldNext = computeIsFoldNext.value;
594
- const { id, isExpand, showAction } = item;
650
+ const { direction } = actionOpts;
651
+ const showPrevButton = XEUtils.isBoolean(actionOpts.showPrevButton) ? actionOpts.showPrevButton : (itemList.some(item => item.showAction));
652
+ const showNextButton = XEUtils.isBoolean(actionOpts.showNextButton) ? actionOpts.showNextButton : (direction === 'next' && itemList.some(item => item.showAction));
653
+ const resizeOpts = computeResizeOpts.value;
654
+ const { immediate } = resizeOpts;
595
655
  return h('div', {
596
- itemid: id,
597
- class: ['vxe-split-pane-handle', isFoldNext ? 'to--next' : 'to--prev']
656
+ class: ['vxe-split-pane-handle', vertical ? 'is--vertical' : 'is--horizontal', immediate ? 'is-resize--immediate' : 'is-resize--lazy', {
657
+ 'is--resize': resize,
658
+ 'is--border': border
659
+ }]
598
660
  }, [
599
661
  h('div', {
600
662
  class: 'vxe-split-pane-handle-bar',
601
663
  style: barStyle,
602
664
  onMousedown: dragEvent
603
665
  }),
604
- showAction
605
- ? h('span', {
606
- class: 'vxe-split-pane-action-btn',
607
- onDblclick: handleActionDblclickEvent,
608
- onClick: handleActionClickEvent
666
+ itemList.length === 2
667
+ ? h('div', {
668
+ class: 'vxe-split-pane-action-btn-wrapper'
609
669
  }, [
610
- h('i', {
611
- class: (isExpand ? actionOpts.openIcon : actionOpts.closeIcon) || getDefaultActionIcon(item)
612
- })
670
+ showPrevButton && nextItem.isExpand
671
+ ? h('div', {
672
+ class: 'vxe-split-pane-action-btn',
673
+ onDblclick: handlePrevActionDblclickEvent,
674
+ onClick: handlePrevActionClickEvent
675
+ }, [
676
+ h('i', {
677
+ class: getActionIcon(prevItem, nextItem, false)
678
+ })
679
+ ])
680
+ : renderEmptyElement($xeSplit),
681
+ showNextButton && prevItem.isExpand
682
+ ? h('div', {
683
+ class: 'vxe-split-pane-action-btn',
684
+ onDblclick: handleNextActionDblclickEvent,
685
+ onClick: handleNextActionClickEvent
686
+ }, [
687
+ h('i', {
688
+ class: getActionIcon(prevItem, nextItem, true)
689
+ })
690
+ ])
691
+ : renderEmptyElement($xeSplit)
613
692
  ])
614
693
  : renderEmptyElement($xeSplit)
615
694
  ]);
@@ -621,36 +700,38 @@ export default defineVxeComponent({
621
700
  const { immediate } = resizeOpts;
622
701
  const visibleItems = computeVisibleItems.value;
623
702
  const { autoItems } = computeAutoItems.value;
624
- const isFoldNext = computeIsFoldNext.value;
625
703
  const itemVNs = [];
626
- itemList.forEach((item, index) => {
627
- const { id, name, slots, renderHeight, resizeHeight, foldHeight, renderWidth, resizeWidth, foldWidth, isVisible, isExpand } = item;
704
+ itemList.forEach((prevItem, index) => {
705
+ const { id, name, slots, renderHeight, resizeHeight, foldHeight, renderWidth, resizeWidth, foldWidth, isExpand } = prevItem;
706
+ const nextItem = itemList[index + 1];
628
707
  const defaultSlot = slots ? slots.default : null;
629
708
  const stys = {};
630
- let itemWidth = isVisible ? (foldWidth || resizeWidth || renderWidth) : 0;
631
- let itemHeight = isVisible ? (foldHeight || resizeHeight || renderHeight) : 0;
709
+ let itemWidth = isExpand ? (foldWidth || resizeWidth || renderWidth) : 0;
710
+ let itemHeight = isExpand ? (foldHeight || resizeHeight || renderHeight) : 0;
632
711
  // 至少存在一个自适应
633
712
  if (autoItems.length === 1) {
634
713
  if (vertical) {
635
- if (!item.height) {
714
+ if (!prevItem.height) {
636
715
  itemHeight = 0;
637
716
  }
638
717
  }
639
718
  else {
640
- if (!item.width) {
719
+ if (!prevItem.width) {
641
720
  itemWidth = 0;
642
721
  }
643
722
  }
644
723
  }
645
- // 当只剩下一个可视区自动占用 100%
724
+ let isFill = true;
646
725
  if (vertical) {
647
- if (itemHeight) {
648
- stys.height = visibleItems.length === 1 ? '100%' : toCssUnit(itemHeight);
726
+ if (itemHeight && visibleItems.length > 1) {
727
+ isFill = false;
728
+ stys.height = toCssUnit(itemHeight);
649
729
  }
650
730
  }
651
731
  else {
652
- if (itemWidth) {
653
- stys.width = visibleItems.length === 1 ? '100%' : toCssUnit(itemWidth);
732
+ if (itemWidth && visibleItems.length > 1) {
733
+ isFill = false;
734
+ stys.width = toCssUnit(itemWidth);
654
735
  }
655
736
  }
656
737
  itemVNs.push(h('div', {
@@ -661,24 +742,24 @@ export default defineVxeComponent({
661
742
  'is--border': border,
662
743
  'is--height': itemHeight,
663
744
  'is--width': itemWidth,
664
- 'is--fill': isVisible && !itemHeight && !itemWidth,
665
- 'is--handle': index > 0,
666
- 'is--expand': isExpand,
667
- 'is--hidden': !isVisible
745
+ 'is--visible': isExpand,
746
+ 'is--hidden': !isExpand,
747
+ 'is--fill': isExpand && isFill
668
748
  }],
669
749
  style: stys
670
750
  }, [
671
- index && !isFoldNext ? renderHandleBar(item) : renderEmptyElement($xeSplit),
672
751
  h('div', {
673
752
  itemid: id,
674
753
  class: 'vxe-split-pane--wrapper'
675
754
  }, [
676
755
  h('div', {
677
756
  class: 'vxe-split-pane--inner'
678
- }, defaultSlot ? callSlot(defaultSlot, { name, isVisible, isExpand }) : [])
679
- ]),
680
- isFoldNext && index < itemList.length - 1 ? renderHandleBar(item) : renderEmptyElement($xeSplit)
757
+ }, defaultSlot ? callSlot(defaultSlot, { name, isExpand }) : [])
758
+ ])
681
759
  ]));
760
+ if (nextItem) {
761
+ itemVNs.push(renderHandleBar(prevItem, nextItem));
762
+ }
682
763
  });
683
764
  return h('div', {
684
765
  class: 'vxe-split-wrapper'
@@ -721,7 +802,15 @@ export default defineVxeComponent({
721
802
  })
722
803
  ])
723
804
  ]
724
- : [])
805
+ : []),
806
+ h('div', {
807
+ class: 'vxe-split--render-vars'
808
+ }, [
809
+ h('div', {
810
+ ref: refBarInfoElem,
811
+ class: 'vxe-split--handle-bar-info'
812
+ })
813
+ ])
725
814
  ]);
726
815
  };
727
816
  const itemFlag = ref(0);
@@ -735,10 +824,20 @@ export default defineVxeComponent({
735
824
  loadItem(props.items || []);
736
825
  });
737
826
  watch(() => reactData.staticItems, (val) => {
827
+ const actionOpts = computeActionOpts.value;
828
+ const { showPrevButton, showNextButton } = actionOpts;
738
829
  if (props.items && props.items.length) {
739
830
  errLog('vxe.error.errConflicts', ['<vxe-split-pane ...>', 'items']);
740
831
  }
741
- reactData.itemList = val;
832
+ reactData.itemList = val || [];
833
+ if ((showPrevButton || showNextButton) && reactData.itemList.length > 2) {
834
+ errLog('vxe.error.modelConflicts', ['action-config.showPrevButton | action-config.showNextButton', '<vxe-split-pane ...> Only supports 2 panel']);
835
+ }
836
+ reactData.itemList.forEach(item => {
837
+ if (item.showAction) {
838
+ warnLog('vxe.error.removeProp', ['showAction']);
839
+ }
840
+ });
742
841
  recalculate();
743
842
  });
744
843
  let resizeObserver;
@@ -753,6 +852,10 @@ export default defineVxeComponent({
753
852
  });
754
853
  resizeObserver.observe(el);
755
854
  }
855
+ const actionOpts = computeActionOpts.value;
856
+ if (actionOpts.direction) {
857
+ errLog('vxe.error.delProp', ['action-config.direction', 'action-config.showPrevButton | action-config.showNextButton']);
858
+ }
756
859
  globalEvents.on($xeSplit, 'resize', handleGlobalResizeEvent);
757
860
  });
758
861
  onUnmounted(() => {