2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
|
|
|
<template v-if="inline">
|
|
|
|
<slot></slot>
|
|
|
|
</template>
|
|
|
|
<template v-else-if="mounted">
|
|
|
|
<Teleport :to="appendTo">
|
|
|
|
<slot></slot>
|
|
|
|
</Teleport>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2024-06-26 07:46:26 +00:00
|
|
|
import { isClient } from '@primeuix/utils/dom';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Portal',
|
|
|
|
props: {
|
|
|
|
appendTo: {
|
2024-01-08 09:33:05 +00:00
|
|
|
type: [String, Object],
|
2022-09-06 12:03:37 +00:00
|
|
|
default: 'body'
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
mounted: false
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
mounted() {
|
2024-06-26 07:46:26 +00:00
|
|
|
this.mounted = isClient();
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
inline() {
|
|
|
|
return this.disabled || this.appendTo === 'self';
|
|
|
|
}
|
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|