<template>
    <div class="scroll-component" :id="id">
        <div class="inner-scroll-component">
            <slot></slot>
        </div>
    </div>
</template>

<script setup lang="ts">
const id = crypto.randomUUID();

function scrollToBottom()
{
    nextTick(() => {
        const element = document.getElementById(id);
        if(element)
        {
            console.log("Scroll to bottom");
            element.scrollTo({top: element.scrollHeight, behavior: 'instant'});
        }
    })
}

defineExpose({
    scrollToBottom
})
</script>

<style scoped>
.scroll-component {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: scroll;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.inner-scroll-component {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    min-height: 100%;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    width: 100%;
}
</style>