<script setup lang="ts">
import { Accordion as ShadcnAccordion } from '@/components/core/accordion';
import type { UiAccordionProps, UiAccordionEmits } from './types';

defineOptions({
  name: 'UiAccordion',
});

const props = defineProps<UiAccordionProps>();

const emit = defineEmits<UiAccordionEmits>();

function handleUpdateModelValue(value: string | string[] | undefined) {
  emit('update:modelValue', value);
}
</script>

<template>
  <ShadcnAccordion
    :type="props.type"
    :model-value="props.modelValue"
    :default-value="props.defaultValue"
    :collapsible="props.type === 'single' ? props.collapsible : undefined"
    :disabled="props.disabled"
    :dir="props.dir"
    :orientation="props.orientation"
    @update:model-value="handleUpdateModelValue"
  >
    <slot />
  </ShadcnAccordion>
</template>
