<template>
  <transition-group :name="dynamicTransitionName">
    <slot />
  </transition-group>
</template>

<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'

interface Props {
  disableOnLoad?: boolean
}

const props = withDefaults(defineProps<Props>(), { disableOnLoad: false })

const isDisabled = ref<boolean>(props.disableOnLoad)

const dynamicTransitionName = computed<string>(() => (isDisabled.value ? '' : 'list-items'))

onMounted(() => (isDisabled.value = false))
</script>

<style lang="scss">
.list-items-move,
.list-items-enter-active,
.list-items-leave-active {
  transition:
    transform 400ms ease,
    opacity 200ms ease;
}

.list-items-enter-from,
.list-items-leave-to {
  opacity: 0;
  transform: translate3d(fn.px-to-rem(30), 0, 0);
}

.list-items-leave-active {
  position: absolute;
}
</style>
