vxe-pc-ui 4.6.4 → 4.6.5

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 (130) hide show
  1. package/es/button/src/button.js +20 -73
  2. package/es/button/style.css +24 -2
  3. package/es/button/style.min.css +1 -1
  4. package/es/color-picker/src/color-picker.js +19 -72
  5. package/es/color-picker/style.css +15 -0
  6. package/es/color-picker/style.min.css +1 -1
  7. package/es/date-picker/src/date-picker.js +19 -74
  8. package/es/date-picker/style.css +3 -2
  9. package/es/date-picker/style.min.css +1 -1
  10. package/es/date-range-picker/src/date-range-picker.js +24 -79
  11. package/es/date-range-picker/style.css +3 -2
  12. package/es/date-range-picker/style.min.css +1 -1
  13. package/es/icon/style.css +1 -1
  14. package/es/pulldown/src/pulldown.js +19 -74
  15. package/es/pulldown/style.css +0 -4
  16. package/es/pulldown/style.min.css +1 -1
  17. package/es/select/src/select.js +19 -72
  18. package/es/style.css +1 -1
  19. package/es/style.min.css +1 -1
  20. package/es/table-select/src/table-select.js +19 -72
  21. package/es/table-select/style.css +0 -1
  22. package/es/table-select/style.min.css +1 -1
  23. package/es/tree-select/src/tree-select.js +19 -72
  24. package/es/tree-select/style.css +0 -1
  25. package/es/tree-select/style.min.css +1 -1
  26. package/es/ui/index.js +1 -1
  27. package/es/ui/src/dom.js +92 -0
  28. package/es/ui/src/log.js +1 -1
  29. package/es/vxe-button/style.css +24 -2
  30. package/es/vxe-button/style.min.css +1 -1
  31. package/es/vxe-color-picker/style.css +15 -0
  32. package/es/vxe-color-picker/style.min.css +1 -1
  33. package/es/vxe-date-picker/style.css +3 -2
  34. package/es/vxe-date-picker/style.min.css +1 -1
  35. package/es/vxe-date-range-picker/style.css +3 -2
  36. package/es/vxe-date-range-picker/style.min.css +1 -1
  37. package/es/vxe-pulldown/style.css +0 -4
  38. package/es/vxe-pulldown/style.min.css +1 -1
  39. package/es/vxe-table-select/style.css +0 -1
  40. package/es/vxe-table-select/style.min.css +1 -1
  41. package/es/vxe-tree-select/style.css +0 -1
  42. package/es/vxe-tree-select/style.min.css +1 -1
  43. package/lib/button/src/button.js +23 -79
  44. package/lib/button/src/button.min.js +1 -1
  45. package/lib/button/style/style.css +24 -2
  46. package/lib/button/style/style.min.css +1 -1
  47. package/lib/color-picker/src/color-picker.js +22 -77
  48. package/lib/color-picker/src/color-picker.min.js +1 -1
  49. package/lib/color-picker/style/style.css +15 -0
  50. package/lib/color-picker/style/style.min.css +1 -1
  51. package/lib/date-picker/src/date-picker.js +22 -79
  52. package/lib/date-picker/src/date-picker.min.js +1 -1
  53. package/lib/date-picker/style/style.css +3 -2
  54. package/lib/date-picker/style/style.min.css +1 -1
  55. package/lib/date-range-picker/src/date-range-picker.js +26 -83
  56. package/lib/date-range-picker/src/date-range-picker.min.js +1 -1
  57. package/lib/date-range-picker/style/style.css +3 -2
  58. package/lib/date-range-picker/style/style.min.css +1 -1
  59. package/lib/icon/style/style.css +1 -1
  60. package/lib/icon/style/style.min.css +1 -1
  61. package/lib/index.umd.js +279 -631
  62. package/lib/index.umd.min.js +1 -1
  63. package/lib/pulldown/src/pulldown.js +22 -80
  64. package/lib/pulldown/src/pulldown.min.js +1 -1
  65. package/lib/pulldown/style/style.css +0 -4
  66. package/lib/pulldown/style/style.min.css +1 -1
  67. package/lib/select/src/select.js +22 -77
  68. package/lib/select/src/select.min.js +1 -1
  69. package/lib/style.css +1 -1
  70. package/lib/style.min.css +1 -1
  71. package/lib/table-select/src/table-select.js +22 -77
  72. package/lib/table-select/src/table-select.min.js +1 -1
  73. package/lib/table-select/style/style.css +0 -1
  74. package/lib/table-select/style/style.min.css +1 -1
  75. package/lib/tree-select/src/tree-select.js +22 -77
  76. package/lib/tree-select/src/tree-select.min.js +1 -1
  77. package/lib/tree-select/style/style.css +0 -1
  78. package/lib/tree-select/style/style.min.css +1 -1
  79. package/lib/ui/index.js +1 -1
  80. package/lib/ui/index.min.js +1 -1
  81. package/lib/ui/src/dom.js +97 -0
  82. package/lib/ui/src/dom.min.js +1 -1
  83. package/lib/ui/src/log.js +1 -1
  84. package/lib/ui/src/log.min.js +1 -1
  85. package/lib/vxe-button/style/style.css +24 -2
  86. package/lib/vxe-button/style/style.min.css +1 -1
  87. package/lib/vxe-color-picker/style/style.css +15 -0
  88. package/lib/vxe-color-picker/style/style.min.css +1 -1
  89. package/lib/vxe-date-picker/style/style.css +3 -2
  90. package/lib/vxe-date-picker/style/style.min.css +1 -1
  91. package/lib/vxe-date-range-picker/style/style.css +3 -2
  92. package/lib/vxe-date-range-picker/style/style.min.css +1 -1
  93. package/lib/vxe-pulldown/style/style.css +0 -4
  94. package/lib/vxe-pulldown/style/style.min.css +1 -1
  95. package/lib/vxe-table-select/style/style.css +0 -1
  96. package/lib/vxe-table-select/style/style.min.css +1 -1
  97. package/lib/vxe-tree-select/style/style.css +0 -1
  98. package/lib/vxe-tree-select/style/style.min.css +1 -1
  99. package/package.json +1 -1
  100. package/packages/button/src/button.ts +20 -70
  101. package/packages/color-picker/src/color-picker.ts +19 -69
  102. package/packages/date-picker/src/date-picker.ts +20 -72
  103. package/packages/date-range-picker/src/date-range-picker.ts +24 -76
  104. package/packages/pulldown/src/pulldown.ts +20 -72
  105. package/packages/select/src/select.ts +19 -69
  106. package/packages/table-select/src/table-select.ts +19 -69
  107. package/packages/tree-select/src/tree-select.ts +19 -69
  108. package/packages/ui/src/dom.ts +95 -0
  109. package/styles/components/button.scss +3 -20
  110. package/styles/components/color-picker.scss +2 -27
  111. package/styles/components/date-picker.scss +2 -34
  112. package/styles/components/date-range-picker.scss +2 -34
  113. package/styles/components/pulldown.scss +2 -41
  114. package/styles/components/select.scss +2 -35
  115. package/styles/components/table-select.scss +2 -36
  116. package/styles/components/tree-select.scss +2 -36
  117. package/styles/helpers/placement.scss +39 -0
  118. package/types/components/table.d.ts +51 -0
  119. /package/es/icon/{iconfont.1747024965925.ttf → iconfont.1747094595378.ttf} +0 -0
  120. /package/es/icon/{iconfont.1747024965925.woff → iconfont.1747094595378.woff} +0 -0
  121. /package/es/icon/{iconfont.1747024965925.woff2 → iconfont.1747094595378.woff2} +0 -0
  122. /package/es/{iconfont.1747024965925.ttf → iconfont.1747094595378.ttf} +0 -0
  123. /package/es/{iconfont.1747024965925.woff → iconfont.1747094595378.woff} +0 -0
  124. /package/es/{iconfont.1747024965925.woff2 → iconfont.1747094595378.woff2} +0 -0
  125. /package/lib/icon/style/{iconfont.1747024965925.ttf → iconfont.1747094595378.ttf} +0 -0
  126. /package/lib/icon/style/{iconfont.1747024965925.woff → iconfont.1747094595378.woff} +0 -0
  127. /package/lib/icon/style/{iconfont.1747024965925.woff2 → iconfont.1747094595378.woff2} +0 -0
  128. /package/lib/{iconfont.1747024965925.ttf → iconfont.1747094595378.ttf} +0 -0
  129. /package/lib/{iconfont.1747024965925.woff → iconfont.1747094595378.woff} +0 -0
  130. /package/lib/{iconfont.1747024965925.woff2 → iconfont.1747094595378.woff2} +0 -0
@@ -2,7 +2,7 @@ import { defineComponent, h, Teleport, ref, Ref, computed, provide, reactive, in
2
2
  import XEUtils from 'xe-utils'
3
3
  import { getConfig, getIcon, getI18n, commands, createEvent, globalEvents, useSize, renderEmptyElement } from '../../ui'
4
4
  import { getFuncText, getLastZIndex, nextZIndex, isEnableConf } from '../../ui/src/utils'
5
- import { getAbsolutePos, getEventTargetNode } from '../../ui/src/dom'
5
+ import { updatePanelPlacement, getEventTargetNode } from '../../ui/src/dom'
6
6
  import { getSlotVNs } from '../../ui/src/vn'
7
7
  import { parseDateObj, getDateByCode } from '../../date-panel/src/util'
8
8
  import { errLog } from '../../ui/src/log'
@@ -10,7 +10,7 @@ import VxeDatePanelComponent from '../../date-panel/src/date-panel'
10
10
  import VxeButtonComponent from '../../button/src/button'
11
11
  import VxeButtonGroupComponent from '../../button/src/button-group'
12
12
 
13
- import type { VxeDatePickerConstructor, VxeDatePickerEmits, DatePickerInternalData, DatePickerReactData, VxeComponentStyleType, DatePickerMethods, VxeDatePickerPropTypes, DatePickerPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines, ValueOf, VxeModalConstructor, VxeDrawerConstructor, VxeModalMethods, VxeDrawerMethods, VxeDatePickerDefines, VxeButtonGroupEvents, VxeDatePanelConstructor } from '../../../types'
13
+ import type { VxeDatePickerConstructor, VxeDatePickerEmits, DatePickerInternalData, DatePickerReactData, DatePickerMethods, VxeDatePickerPropTypes, DatePickerPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines, ValueOf, VxeModalConstructor, VxeDrawerConstructor, VxeModalMethods, VxeDrawerMethods, VxeDatePickerDefines, VxeButtonGroupEvents, VxeDatePanelConstructor } from '../../../types'
14
14
  import type { VxeTableConstructor, VxeTablePrivateMethods } from '../../../types/components/table'
15
15
 
16
16
  export default defineComponent({
@@ -511,76 +511,24 @@ export default defineComponent({
511
511
  }
512
512
 
513
513
  const updatePlacement = () => {
514
- return nextTick().then(() => {
515
- const { placement } = props
516
- const { panelIndex } = reactData
517
- const targetElem = refInputTarget.value
518
- const panelElem = refInputPanel.value
519
- const btnTransfer = computeBtnTransfer.value
520
- if (targetElem && panelElem) {
521
- const targetHeight = targetElem.offsetHeight
522
- const targetWidth = targetElem.offsetWidth
523
- const panelHeight = panelElem.offsetHeight
524
- const panelWidth = panelElem.offsetWidth
525
- const marginSize = 5
526
- const panelStyle: VxeComponentStyleType = {
527
- zIndex: panelIndex
528
- }
529
- const { boundingTop, boundingLeft, visibleHeight, visibleWidth } = getAbsolutePos(targetElem)
530
- let panelPlacement: VxeDatePickerPropTypes.Placement = 'bottom'
531
- if (btnTransfer) {
532
- let left = boundingLeft
533
- let top = boundingTop + targetHeight
534
- if (placement === 'top') {
535
- panelPlacement = 'top'
536
- top = boundingTop - panelHeight
537
- } else if (!placement) {
538
- // 如果下面不够放,则向上
539
- if (top + panelHeight + marginSize > visibleHeight) {
540
- panelPlacement = 'top'
541
- top = boundingTop - panelHeight
542
- }
543
- // 如果上面不够放,则向下(优先)
544
- if (top < marginSize) {
545
- panelPlacement = 'bottom'
546
- top = boundingTop + targetHeight
547
- }
548
- }
549
- // 如果溢出右边
550
- if (left + panelWidth + marginSize > visibleWidth) {
551
- left -= left + panelWidth + marginSize - visibleWidth
552
- }
553
- // 如果溢出左边
554
- if (left < marginSize) {
555
- left = marginSize
556
- }
557
- Object.assign(panelStyle, {
558
- left: `${left}px`,
559
- top: `${top}px`,
560
- minWidth: `${targetWidth}px`
561
- })
562
- } else {
563
- if (placement === 'top') {
564
- panelPlacement = 'top'
565
- panelStyle.bottom = `${targetHeight}px`
566
- } else if (!placement) {
567
- // 如果下面不够放,则向上
568
- panelStyle.top = `${targetHeight}px`
569
- if (boundingTop + targetHeight + panelHeight > visibleHeight) {
570
- // 如果上面不够放,则向下(优先)
571
- if (boundingTop - targetHeight - panelHeight > marginSize) {
572
- panelPlacement = 'top'
573
- panelStyle.top = ''
574
- panelStyle.bottom = `${targetHeight}px`
575
- }
576
- }
577
- }
578
- }
579
- reactData.panelStyle = panelStyle
580
- reactData.panelPlacement = panelPlacement
581
- return nextTick()
582
- }
583
- })
514
+ const { placement } = props
515
+ const { panelIndex } = reactData
516
+ const targetElem = refInputTarget.value
517
+ const panelElem = refInputPanel.value
518
+ const btnTransfer = computeBtnTransfer.value
519
+ const handleStyle = () => {
520
+ const ppObj = updatePanelPlacement(targetElem, panelElem, {
521
+ placement,
522
+ teleportTo: btnTransfer
523
+ })
524
+ const panelStyle: { [key: string]: string | number } = Object.assign(ppObj.style, {
525
+ zIndex: panelIndex
526
+ })
527
+ reactData.panelStyle = panelStyle
528
+ reactData.panelPlacement = ppObj.placement
529
+ }
530
+ handleStyle()
531
+ return nextTick().then(handleStyle)
584
532
  }
585
533
 
586
534
  const showPanel = () => {
@@ -2,7 +2,7 @@ import { defineComponent, h, Teleport, ref, Ref, computed, provide, reactive, in
2
2
  import XEUtils from 'xe-utils'
3
3
  import { getConfig, getIcon, getI18n, commands, globalEvents, createEvent, useSize, renderEmptyElement } from '../../ui'
4
4
  import { getFuncText, getLastZIndex, nextZIndex, isEnableConf } from '../../ui/src/utils'
5
- import { getAbsolutePos, getEventTargetNode } from '../../ui/src/dom'
5
+ import { updatePanelPlacement, getEventTargetNode } from '../../ui/src/dom'
6
6
  import { parseDateString, parseDateObj, getRangeDateByCode } from '../../date-panel/src/util'
7
7
  import { getSlotVNs } from '../../ui/src/vn'
8
8
  import { errLog } from '../../ui/src/log'
@@ -10,7 +10,7 @@ import VxeDatePanelComponent from '../../date-panel/src/date-panel'
10
10
  import VxeButtonComponent from '../../button/src/button'
11
11
  import VxeButtonGroupComponent from '../../button/src/button-group'
12
12
 
13
- import type { VxeDateRangePickerConstructor, VxeDateRangePickerEmits, DateRangePickerInternalData, DateRangePickerReactData, VxeComponentStyleType, DateRangePickerMethods, VxeDateRangePickerPropTypes, DateRangePickerPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines, ValueOf, VxeModalConstructor, VxeDrawerConstructor, VxeModalMethods, VxeDrawerMethods, VxeDateRangePickerDefines, VxeButtonGroupEvents, VxeDatePanelConstructor } from '../../../types'
13
+ import type { VxeDateRangePickerConstructor, VxeDateRangePickerEmits, DateRangePickerInternalData, DateRangePickerReactData, DateRangePickerMethods, VxeDateRangePickerPropTypes, DateRangePickerPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines, ValueOf, VxeModalConstructor, VxeDrawerConstructor, VxeModalMethods, VxeDrawerMethods, VxeDateRangePickerDefines, VxeButtonGroupEvents, VxeDatePanelConstructor } from '../../../types'
14
14
  import type { VxeTableConstructor, VxeTablePrivateMethods } from '../../../types/components/table'
15
15
 
16
16
  export default defineComponent({
@@ -242,7 +242,7 @@ export default defineComponent({
242
242
  if (globalPlaceholder) {
243
243
  return getFuncText(globalPlaceholder)
244
244
  }
245
- return getI18n('vxe.base.pleaseSelect')
245
+ return getI18n('vxe.dateRangePicker.pleaseRange')
246
246
  })
247
247
 
248
248
  const computeInpImmediate = computed(() => {
@@ -541,11 +541,11 @@ export default defineComponent({
541
541
  if ($startDatePanel && $endDatePanel) {
542
542
  const startValue = $startDatePanel.getModelValue()
543
543
  const endValue = $endDatePanel.getModelValue()
544
- if (startValue && endValue) {
544
+ if ((startValue && !endValue) || (!startValue && endValue)) {
545
+ handleChange('', '', evnt)
546
+ } else {
545
547
  $startDatePanel.confirmByEvent(evnt)
546
548
  $endDatePanel.confirmByEvent(evnt)
547
- } else {
548
- handleChange('', '', evnt)
549
549
  }
550
550
  }
551
551
  hidePanel()
@@ -640,76 +640,24 @@ export default defineComponent({
640
640
  }
641
641
 
642
642
  const updatePlacement = () => {
643
- return nextTick().then(() => {
644
- const { placement } = props
645
- const { panelIndex } = reactData
646
- const targetElem = refInputTarget.value
647
- const panelElem = refInputPanel.value
648
- const btnTransfer = computeBtnTransfer.value
649
- if (targetElem && panelElem) {
650
- const targetHeight = targetElem.offsetHeight
651
- const targetWidth = targetElem.offsetWidth
652
- const panelHeight = panelElem.offsetHeight
653
- const panelWidth = panelElem.offsetWidth
654
- const marginSize = 5
655
- const panelStyle: VxeComponentStyleType = {
656
- zIndex: panelIndex
657
- }
658
- const { boundingTop, boundingLeft, visibleHeight, visibleWidth } = getAbsolutePos(targetElem)
659
- let panelPlacement: VxeDateRangePickerPropTypes.Placement = 'bottom'
660
- if (btnTransfer) {
661
- let left = boundingLeft
662
- let top = boundingTop + targetHeight
663
- if (placement === 'top') {
664
- panelPlacement = 'top'
665
- top = boundingTop - panelHeight
666
- } else if (!placement) {
667
- // 如果下面不够放,则向上
668
- if (top + panelHeight + marginSize > visibleHeight) {
669
- panelPlacement = 'top'
670
- top = boundingTop - panelHeight
671
- }
672
- // 如果上面不够放,则向下(优先)
673
- if (top < marginSize) {
674
- panelPlacement = 'bottom'
675
- top = boundingTop + targetHeight
676
- }
677
- }
678
- // 如果溢出右边
679
- if (left + panelWidth + marginSize > visibleWidth) {
680
- left -= left + panelWidth + marginSize - visibleWidth
681
- }
682
- // 如果溢出左边
683
- if (left < marginSize) {
684
- left = marginSize
685
- }
686
- Object.assign(panelStyle, {
687
- left: `${left}px`,
688
- top: `${top}px`,
689
- minWidth: `${targetWidth}px`
690
- })
691
- } else {
692
- if (placement === 'top') {
693
- panelPlacement = 'top'
694
- panelStyle.bottom = `${targetHeight}px`
695
- } else if (!placement) {
696
- // 如果下面不够放,则向上
697
- panelStyle.top = `${targetHeight}px`
698
- if (boundingTop + targetHeight + panelHeight > visibleHeight) {
699
- // 如果上面不够放,则向下(优先)
700
- if (boundingTop - targetHeight - panelHeight > marginSize) {
701
- panelPlacement = 'top'
702
- panelStyle.top = ''
703
- panelStyle.bottom = `${targetHeight}px`
704
- }
705
- }
706
- }
707
- }
708
- reactData.panelStyle = panelStyle
709
- reactData.panelPlacement = panelPlacement
710
- return nextTick()
711
- }
712
- })
643
+ const { placement } = props
644
+ const { panelIndex } = reactData
645
+ const targetElem = refInputTarget.value
646
+ const panelElem = refInputPanel.value
647
+ const btnTransfer = computeBtnTransfer.value
648
+ const handleStyle = () => {
649
+ const ppObj = updatePanelPlacement(targetElem, panelElem, {
650
+ placement,
651
+ teleportTo: btnTransfer
652
+ })
653
+ const panelStyle: { [key: string]: string | number } = Object.assign(ppObj.style, {
654
+ zIndex: panelIndex
655
+ })
656
+ reactData.panelStyle = panelStyle
657
+ reactData.panelPlacement = ppObj.placement
658
+ }
659
+ handleStyle()
660
+ return nextTick().then(handleStyle)
713
661
  }
714
662
 
715
663
  const showPanel = () => {
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, h, Teleport, ref, Ref, onUnmounted, reactive, inject, computed, nextTick, PropType, watch, createCommentVNode } from 'vue'
2
2
  import XEUtils from 'xe-utils'
3
- import { getConfig, globalEvents, createEvent, useSize, VxeComponentStyleType, ValueOf } from '../../ui'
4
- import { getAbsolutePos, getEventTargetNode } from '../../ui/src/dom'
3
+ import { getConfig, globalEvents, createEvent, useSize, ValueOf } from '../../ui'
4
+ import { getEventTargetNode, updatePanelPlacement } from '../../ui/src/dom'
5
5
  import { getLastZIndex, nextZIndex } from '../../ui/src/utils'
6
6
 
7
7
  import type { VxePulldownConstructor, VxePulldownPropTypes, PulldownInternalData, VxePulldownEmits, PulldownReactData, PulldownMethods, PulldownPrivateRef, VxePulldownMethods, VxeDrawerConstructor, VxeDrawerMethods, VxeFormConstructor, VxeFormPrivateMethods, VxeModalConstructor, VxeModalMethods } from '../../../types'
@@ -115,76 +115,24 @@ export default defineComponent({
115
115
  * 手动更新位置
116
116
  */
117
117
  const updatePlacement = () => {
118
- return nextTick().then(() => {
119
- const { placement } = props
120
- const { panelIndex, visiblePanel } = reactData
121
- const btnTransfer = computeBtnTransfer.value
122
- if (visiblePanel) {
123
- const targetElem = refPulldownContent.value
124
- const panelElem = refPulldownPanel.value
125
- if (panelElem && targetElem) {
126
- const targetHeight = targetElem.offsetHeight
127
- const targetWidth = targetElem.offsetWidth
128
- const panelHeight = panelElem.offsetHeight
129
- const panelWidth = panelElem.offsetWidth
130
- const marginSize = 5
131
- const panelStyle: VxeComponentStyleType = {
132
- zIndex: panelIndex
133
- }
134
- const { boundingTop, boundingLeft, visibleHeight, visibleWidth } = getAbsolutePos(targetElem)
135
- let panelPlacement = 'bottom'
136
- if (btnTransfer) {
137
- let left = boundingLeft
138
- let top = boundingTop + targetHeight
139
- if (placement === 'top') {
140
- panelPlacement = 'top'
141
- top = boundingTop - panelHeight
142
- } else if (!placement) {
143
- // 如果下面不够放,则向上
144
- if (top + panelHeight + marginSize > visibleHeight) {
145
- panelPlacement = 'top'
146
- top = boundingTop - panelHeight
147
- }
148
- // 如果上面不够放,则向下(优先)
149
- if (top < marginSize) {
150
- panelPlacement = 'bottom'
151
- top = boundingTop + targetHeight
152
- }
153
- }
154
- // 如果溢出右边
155
- if (left + panelWidth + marginSize > visibleWidth) {
156
- left -= left + panelWidth + marginSize - visibleWidth
157
- }
158
- // 如果溢出左边
159
- if (left < marginSize) {
160
- left = marginSize
161
- }
162
- Object.assign(panelStyle, {
163
- left: `${left}px`,
164
- top: `${top}px`,
165
- minWidth: `${targetWidth}px`
166
- })
167
- } else {
168
- if (placement === 'top') {
169
- panelPlacement = 'top'
170
- panelStyle.bottom = `${targetHeight}px`
171
- } else if (!placement) {
172
- // 如果下面不够放,则向上
173
- if (boundingTop + targetHeight + panelHeight > visibleHeight) {
174
- // 如果上面不够放,则向下(优先)
175
- if (boundingTop - targetHeight - panelHeight > marginSize) {
176
- panelPlacement = 'top'
177
- panelStyle.bottom = `${targetHeight}px`
178
- }
179
- }
180
- }
181
- }
182
- reactData.panelStyle = panelStyle
183
- reactData.panelPlacement = panelPlacement
184
- }
185
- }
186
- return nextTick()
187
- })
118
+ const { placement } = props
119
+ const { panelIndex } = reactData
120
+ const targetElem = refPulldownContent.value
121
+ const panelElem = refPulldownPanel.value
122
+ const btnTransfer = computeBtnTransfer.value
123
+ const handleStyle = () => {
124
+ const ppObj = updatePanelPlacement(targetElem, panelElem, {
125
+ placement,
126
+ teleportTo: btnTransfer
127
+ })
128
+ const panelStyle: { [key: string]: string | number } = Object.assign(ppObj.style, {
129
+ zIndex: panelIndex
130
+ })
131
+ reactData.panelStyle = panelStyle
132
+ reactData.panelPlacement = ppObj.placement
133
+ }
134
+ handleStyle()
135
+ return nextTick().then(handleStyle)
188
136
  }
189
137
 
190
138
  /**
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, h, Teleport, PropType, ref, Ref, inject, computed, provide, onUnmounted, reactive, nextTick, watch, onMounted } from 'vue'
2
2
  import XEUtils from 'xe-utils'
3
3
  import { getConfig, getIcon, getI18n, globalEvents, GLOBAL_EVENT_KEYS, createEvent, useSize, renderEmptyElement } from '../../ui'
4
- import { getEventTargetNode, getAbsolutePos } from '../../ui/src/dom'
4
+ import { getEventTargetNode, updatePanelPlacement } from '../../ui/src/dom'
5
5
  import { getLastZIndex, nextZIndex, getFuncText } from '../../ui/src/utils'
6
6
  import { getSlotVNs } from '../../ui/src/vn'
7
7
  import VxeInputComponent from '../../input/src/input'
@@ -412,74 +412,24 @@ export default defineComponent({
412
412
  }
413
413
 
414
414
  const updatePlacement = () => {
415
- return nextTick().then(() => {
416
- const { placement } = props
417
- const { panelIndex } = reactData
418
- const el = refElem.value
419
- const panelElem = refOptionPanel.value
420
- const btnTransfer = computeBtnTransfer.value
421
- if (panelElem && el) {
422
- const targetHeight = el.offsetHeight
423
- const targetWidth = el.offsetWidth
424
- const panelHeight = panelElem.offsetHeight
425
- const panelWidth = panelElem.offsetWidth
426
- const marginSize = 5
427
- const panelStyle: { [key: string]: any } = {
428
- zIndex: panelIndex
429
- }
430
- const { boundingTop, boundingLeft, visibleHeight, visibleWidth } = getAbsolutePos(el)
431
- let panelPlacement = 'bottom'
432
- if (btnTransfer) {
433
- let left = boundingLeft
434
- let top = boundingTop + targetHeight
435
- if (placement === 'top') {
436
- panelPlacement = 'top'
437
- top = boundingTop - panelHeight
438
- } else if (!placement) {
439
- // 如果下面不够放,则向上
440
- if (top + panelHeight + marginSize > visibleHeight) {
441
- panelPlacement = 'top'
442
- top = boundingTop - panelHeight
443
- }
444
- // 如果上面不够放,则向下(优先)
445
- if (top < marginSize) {
446
- panelPlacement = 'bottom'
447
- top = boundingTop + targetHeight
448
- }
449
- }
450
- // 如果溢出右边
451
- if (left + panelWidth + marginSize > visibleWidth) {
452
- left -= left + panelWidth + marginSize - visibleWidth
453
- }
454
- // 如果溢出左边
455
- if (left < marginSize) {
456
- left = marginSize
457
- }
458
- Object.assign(panelStyle, {
459
- left: `${left}px`,
460
- top: `${top}px`,
461
- minWidth: `${targetWidth}px`
462
- })
463
- } else {
464
- if (placement === 'top') {
465
- panelPlacement = 'top'
466
- panelStyle.bottom = `${targetHeight}px`
467
- } else if (!placement) {
468
- // 如果下面不够放,则向上
469
- if (boundingTop + targetHeight + panelHeight > visibleHeight) {
470
- // 如果上面不够放,则向下(优先)
471
- if (boundingTop - targetHeight - panelHeight > marginSize) {
472
- panelPlacement = 'top'
473
- panelStyle.bottom = `${targetHeight}px`
474
- }
475
- }
476
- }
477
- }
478
- reactData.panelStyle = panelStyle
479
- reactData.panelPlacement = panelPlacement
480
- return nextTick()
481
- }
482
- })
415
+ const { placement } = props
416
+ const { panelIndex } = reactData
417
+ const targetElem = refElem.value
418
+ const panelElem = refOptionPanel.value
419
+ const btnTransfer = computeBtnTransfer.value
420
+ const handleStyle = () => {
421
+ const ppObj = updatePanelPlacement(targetElem, panelElem, {
422
+ placement,
423
+ teleportTo: btnTransfer
424
+ })
425
+ const panelStyle: { [key: string]: string | number } = Object.assign(ppObj.style, {
426
+ zIndex: panelIndex
427
+ })
428
+ reactData.panelStyle = panelStyle
429
+ reactData.panelPlacement = ppObj.placement
430
+ }
431
+ handleStyle()
432
+ return nextTick().then(handleStyle)
483
433
  }
484
434
 
485
435
  const showOptionPanel = () => {
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, ref, h, PropType, computed, inject, watch, provide, nextTick, Teleport, onMounted, onUnmounted, reactive } from 'vue'
2
2
  import XEUtils from 'xe-utils'
3
3
  import { VxeUI, getConfig, getIcon, globalEvents, getI18n, createEvent, useSize, renderEmptyElement } from '../../ui'
4
- import { getEventTargetNode, getAbsolutePos, toCssUnit } from '../../ui/src/dom'
4
+ import { getEventTargetNode, updatePanelPlacement, toCssUnit } from '../../ui/src/dom'
5
5
  import { getOnName } from '../../ui/src/vn'
6
6
  import { getLastZIndex, nextZIndex } from '../../ui/src/utils'
7
7
  import { errLog } from '../../ui/src/log'
@@ -340,74 +340,24 @@ export default defineComponent({
340
340
  }
341
341
 
342
342
  const updatePlacement = () => {
343
- return nextTick().then(() => {
344
- const { placement } = props
345
- const { panelIndex } = reactData
346
- const el = refElem.value
347
- const panelElem = refOptionPanel.value
348
- const btnTransfer = computeBtnTransfer.value
349
- if (panelElem && el) {
350
- const targetHeight = el.offsetHeight
351
- const targetWidth = el.offsetWidth
352
- const panelHeight = panelElem.offsetHeight
353
- const panelWidth = panelElem.offsetWidth
354
- const marginSize = 5
355
- const panelStyle: { [key: string]: any } = {
356
- zIndex: panelIndex
357
- }
358
- const { boundingTop, boundingLeft, visibleHeight, visibleWidth } = getAbsolutePos(el)
359
- let panelPlacement = 'bottom'
360
- if (btnTransfer) {
361
- let left = boundingLeft
362
- let top = boundingTop + targetHeight
363
- if (placement === 'top') {
364
- panelPlacement = 'top'
365
- top = boundingTop - panelHeight
366
- } else if (!placement) {
367
- // 如果下面不够放,则向上
368
- if (top + panelHeight + marginSize > visibleHeight) {
369
- panelPlacement = 'top'
370
- top = boundingTop - panelHeight
371
- }
372
- // 如果上面不够放,则向下(优先)
373
- if (top < marginSize) {
374
- panelPlacement = 'bottom'
375
- top = boundingTop + targetHeight
376
- }
377
- }
378
- // 如果溢出右边
379
- if (left + panelWidth + marginSize > visibleWidth) {
380
- left -= left + panelWidth + marginSize - visibleWidth
381
- }
382
- // 如果溢出左边
383
- if (left < marginSize) {
384
- left = marginSize
385
- }
386
- Object.assign(panelStyle, {
387
- left: `${left}px`,
388
- top: `${top}px`,
389
- minWidth: `${targetWidth}px`
390
- })
391
- } else {
392
- if (placement === 'top') {
393
- panelPlacement = 'top'
394
- panelStyle.bottom = `${targetHeight}px`
395
- } else if (!placement) {
396
- // 如果下面不够放,则向上
397
- if (boundingTop + targetHeight + panelHeight > visibleHeight) {
398
- // 如果上面不够放,则向下(优先)
399
- if (boundingTop - targetHeight - panelHeight > marginSize) {
400
- panelPlacement = 'top'
401
- panelStyle.bottom = `${targetHeight}px`
402
- }
403
- }
404
- }
405
- }
406
- reactData.panelStyle = panelStyle
407
- reactData.panelPlacement = panelPlacement
408
- return nextTick()
409
- }
410
- })
343
+ const { placement } = props
344
+ const { panelIndex } = reactData
345
+ const targetElem = refElem.value
346
+ const panelElem = refOptionPanel.value
347
+ const btnTransfer = computeBtnTransfer.value
348
+ const handleStyle = () => {
349
+ const ppObj = updatePanelPlacement(targetElem, panelElem, {
350
+ placement,
351
+ teleportTo: btnTransfer
352
+ })
353
+ const panelStyle: { [key: string]: string | number } = Object.assign(ppObj.style, {
354
+ zIndex: panelIndex
355
+ })
356
+ reactData.panelStyle = panelStyle
357
+ reactData.panelPlacement = ppObj.placement
358
+ }
359
+ handleStyle()
360
+ return nextTick().then(handleStyle)
411
361
  }
412
362
 
413
363
  const showOptionPanel = () => {