@redseed/redseed-ui-vue3 5.4.0 → 5.4.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.
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref, watch, watchEffect, nextTick } from 'vue'
|
|
2
|
+
import { ref, watch, watchEffect, nextTick, onMounted } from 'vue'
|
|
3
3
|
import { ChevronUpIcon } from '@heroicons/vue/24/outline'
|
|
4
4
|
import { ButtonTertiary } from '../Button'
|
|
5
5
|
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
open: {
|
|
8
8
|
type: Boolean,
|
|
9
|
-
default:
|
|
9
|
+
default: false,
|
|
10
10
|
},
|
|
11
11
|
})
|
|
12
12
|
|
|
13
13
|
const emit = defineEmits(['click'])
|
|
14
14
|
|
|
15
|
-
const triggerId =
|
|
16
|
-
const contentId =
|
|
15
|
+
const triggerId = _.uniqueId('disclosure-trigger-')
|
|
16
|
+
const contentId = _.uniqueId('disclosure-content-')
|
|
17
17
|
|
|
18
18
|
const isOpen = ref(props.open)
|
|
19
19
|
watch(() => props.open, () => isOpen.value = props.open)
|
|
@@ -50,6 +50,24 @@ watchEffect(() => {
|
|
|
50
50
|
|
|
51
51
|
resetContentMaxHeight()
|
|
52
52
|
})
|
|
53
|
+
|
|
54
|
+
const canTeleportTrigger = ref(false)
|
|
55
|
+
const canTeleportContent = ref(false)
|
|
56
|
+
|
|
57
|
+
onMounted(() => {
|
|
58
|
+
const observer = new MutationObserver(() => {
|
|
59
|
+
if (document.getElementById(triggerId)) canTeleportTrigger.value = true
|
|
60
|
+
|
|
61
|
+
if (document.getElementById(contentId)) canTeleportContent.value = true
|
|
62
|
+
|
|
63
|
+
if (canTeleportTrigger.value && canTeleportContent.value) observer.disconnect()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
observer.observe(document.body, {
|
|
67
|
+
childList: true,
|
|
68
|
+
subtree: true,
|
|
69
|
+
})
|
|
70
|
+
})
|
|
53
71
|
</script>
|
|
54
72
|
|
|
55
73
|
<template>
|
|
@@ -62,7 +80,9 @@ watchEffect(() => {
|
|
|
62
80
|
></slot>
|
|
63
81
|
</div>
|
|
64
82
|
|
|
65
|
-
<Teleport
|
|
83
|
+
<Teleport v-if="canTeleportTrigger"
|
|
84
|
+
:to="`#${triggerId}`"
|
|
85
|
+
>
|
|
66
86
|
<slot name="trigger"
|
|
67
87
|
:handleTrigger="handleTrigger"
|
|
68
88
|
>
|
|
@@ -87,7 +107,9 @@ watchEffect(() => {
|
|
|
87
107
|
</slot>
|
|
88
108
|
</Teleport>
|
|
89
109
|
|
|
90
|
-
<Teleport
|
|
110
|
+
<Teleport v-if="canTeleportContent"
|
|
111
|
+
:to="`#${contentId}`"
|
|
112
|
+
>
|
|
91
113
|
<div ref="contentRef"
|
|
92
114
|
:class="[
|
|
93
115
|
'rsui-disclosure__content',
|