<script setup lang="ts">
import { TabsRoot, type TabsRootProps } from 'radix-vue'
import { computed, type HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'

const props = defineProps<TabsRootProps & { class?: HTMLAttributes['class'] }>()
const emit = defineEmits(['update:modelValue'])

const delegatedProps = computed(() => {
  const { class: _, ...delegated } = props
  return delegated
})

const handleUpdate = (value: string) => {
  emit('update:modelValue', value)
}
</script>

<template>
  <TabsRoot v-bind="delegatedProps" :class="cn('', props.class)" @update:model-value="handleUpdate">
    <slot />
  </TabsRoot>
</template>
