<template>
    <div class="ui-gate-content" :class="{ active }" v-if="brotherInstances">
        <slot :active="active"></slot>
    </div>
</template>

<script setup>
// getCurrentInstance
import { onBeforeMount, ref, inject, onUnmounted } from 'vue'
import { Relation } from './constant'

const active = ref(false)
const brotherInstances = inject(Relation).value

if (brotherInstances) {
    onBeforeMount(() => brotherInstances.push(active))
    onUnmounted(() => {
        const index = brotherInstances.indexOf(active)
        if (~index) {
            brotherInstances.splice(index, 1)
        }
    })
}
</script>

<script>
export default { name: 'UiGateContent' }
</script>
