<script setup lang="ts">
// ---------------------------------------------------------------------
// 🔒 AUTOGENERATED @synergy-design-system/vue wrappers for @synergy-design-system/components
// Please do not edit this file directly!
// It will get recreated when running pnpm build.
// ---------------------------------------------------------------------

/**
 * @summary Accordions provide the ability to group a list of `<syn-details>`.
 *
 * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-accordion--docs
 * @status stable
 * @since 2.3.0
 *
 * @slot - The accordion's main content. Must be `<syn-details />` elements.
 *
 * @csspart base - The component's base wrapper.
 */
import { computed, ref } from 'vue';
import '@synergy-design-system/components/components/accordion/accordion.js';

import type SynAccordion from '@synergy-design-system/components/components/accordion/accordion.component.js';

// DOM Reference to the element
const nativeElement = ref<SynAccordion>();

defineExpose({
  nativeElement,
});

// Map attributes
const props = defineProps<{
  /**
   * Indicates whether or not multiple `<syn-detail>` elements can be open at the same time.
   */
  closeOthers?: SynAccordion['closeOthers'];

  /**
   * Draws the accordion and the slotted `<syn-details>` as contained elements.
   */
  contained?: SynAccordion['contained'];

  /**
   * The size that should be applied to all slotted `<syn-details>` elements
   */
  size?: SynAccordion['size'];
}>();

// Make sure prop binding only forwards the props that are actually there.
// This is needed because :param="param" also adds an empty attribute
// when using web-components, which breaks optional arguments like size in SynInput
// @see https://github.com/vuejs/core/issues/5190#issuecomment-1003112498
const visibleProps = computed(() =>
  Object.fromEntries(
    Object.entries(props).filter(([, value]) => typeof value !== 'undefined'),
  ),
);
</script>

<template>
  <syn-accordion v-bind="visibleProps" ref="nativeElement">
    <slot></slot>
  </syn-accordion>
</template>
