hy-app 0.2.8 → 0.2.9
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.
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
<!-- 使用插槽时无法获取正确宽高 -->
|
|
4
4
|
<view class="hy-popover__pos hy-popover__hidden" id="pos">
|
|
5
5
|
<view class="hy-popover__container">
|
|
6
|
-
<view v-if="mode === 'normal'" class="hy-popover__inner">
|
|
6
|
+
<view v-if="!slots.content && mode === 'normal'" class="hy-popover__inner">
|
|
7
7
|
{{ content }}
|
|
8
8
|
</view>
|
|
9
|
-
<view
|
|
9
|
+
<view
|
|
10
|
+
v-if="!slots.content && mode === 'menu' && typeof content === 'object'"
|
|
11
|
+
class="hy-popover__menu"
|
|
12
|
+
>
|
|
10
13
|
<view
|
|
11
14
|
v-for="(item, index) in content"
|
|
12
15
|
:key="index"
|
|
@@ -17,6 +20,9 @@
|
|
|
17
20
|
<text>{{ item.content }}</text>
|
|
18
21
|
</view>
|
|
19
22
|
</view>
|
|
23
|
+
|
|
24
|
+
<!-- 用户自定义样式 -->
|
|
25
|
+
<slot name="content" v-else />
|
|
20
26
|
</view>
|
|
21
27
|
</view>
|
|
22
28
|
<hy-transition
|
|
@@ -35,13 +41,13 @@
|
|
|
35
41
|
<!-- 三角形 -->
|
|
36
42
|
|
|
37
43
|
<!-- 普通模式 -->
|
|
38
|
-
<view v-if="mode === 'normal'" class="hy-popover__inner">
|
|
44
|
+
<view v-if="!slots.content && mode === 'normal'" class="hy-popover__inner">
|
|
39
45
|
{{ content }}
|
|
40
46
|
</view>
|
|
41
47
|
<!-- 普通模式 -->
|
|
42
48
|
|
|
43
49
|
<!-- 列表模式 -->
|
|
44
|
-
<view v-if="mode === 'menu'" class="hy-popover__menu">
|
|
50
|
+
<view v-if="!slots.content && mode === 'menu'" class="hy-popover__menu">
|
|
45
51
|
<view
|
|
46
52
|
v-for="(item, index) in content"
|
|
47
53
|
:key="index"
|
|
@@ -90,7 +96,17 @@ export default {
|
|
|
90
96
|
</script>
|
|
91
97
|
|
|
92
98
|
<script lang="ts" setup>
|
|
93
|
-
import {
|
|
99
|
+
import {
|
|
100
|
+
getCurrentInstance,
|
|
101
|
+
onMounted,
|
|
102
|
+
onBeforeMount,
|
|
103
|
+
onBeforeUnmount,
|
|
104
|
+
ref,
|
|
105
|
+
toRefs,
|
|
106
|
+
useSlots,
|
|
107
|
+
watch,
|
|
108
|
+
inject,
|
|
109
|
+
} from 'vue'
|
|
94
110
|
import defaultProps from './props'
|
|
95
111
|
import IProps, { type PopoverExpose } from './typing'
|
|
96
112
|
import { isArray } from '../../utils'
|
|
@@ -104,6 +120,7 @@ const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
|
104
120
|
const { modelValue, content, mode, placement } = toRefs(props)
|
|
105
121
|
const emit = defineEmits(['update:modelValue', 'menuClick', 'change', 'open', 'close'])
|
|
106
122
|
|
|
123
|
+
const slots = useSlots()
|
|
107
124
|
const queue = inject<Queue | null>(queueKey, null)
|
|
108
125
|
const selector: string = 'popover'
|
|
109
126
|
const { proxy } = getCurrentInstance() as any
|
|
@@ -140,10 +157,9 @@ watch(
|
|
|
140
157
|
(newValue) => {
|
|
141
158
|
if (newValue) {
|
|
142
159
|
popover.control(placement.value, props.offset)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
queue.closeOther(proxy)
|
|
160
|
+
if (queue && queue.closeOther) {
|
|
161
|
+
queue.closeOther(proxy)
|
|
162
|
+
}
|
|
147
163
|
}
|
|
148
164
|
popover.showStyle.value = newValue ? 'display: inline-block;' : 'display: none;'
|
|
149
165
|
emit('change', { show: newValue })
|
|
@@ -156,12 +172,16 @@ onMounted(() => {
|
|
|
156
172
|
})
|
|
157
173
|
|
|
158
174
|
onBeforeMount(() => {
|
|
159
|
-
queue.pushToQueue
|
|
175
|
+
if (queue && queue.pushToQueue) {
|
|
176
|
+
queue.pushToQueue(proxy)
|
|
177
|
+
}
|
|
160
178
|
popover.showStyle.value = showPopover.value ? 'opacity: 1;' : 'opacity: 0;'
|
|
161
179
|
})
|
|
162
180
|
|
|
163
181
|
onBeforeUnmount(() => {
|
|
164
|
-
queue.removeFromQueue
|
|
182
|
+
if (queue && queue.removeFromQueue) {
|
|
183
|
+
queue.removeFromQueue(proxy)
|
|
184
|
+
}
|
|
165
185
|
})
|
|
166
186
|
|
|
167
187
|
const menuClick = (index: number) => {
|