<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 Options define the selectable items within various form controls such as [select](/components/select).
 * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-option--docs
 * @status stable
 * @since 1.5.0
 *
 * @dependency syn-icon
 *
 * @slot - The option's label.
 * @slot prefix - Used to prepend an icon or similar element to the menu item.
 * @slot suffix - Used to append an icon or similar element to the menu item.
 *
 * @csspart checked-icon - The checked icon, an `<syn-icon>` element.
 * @csspart base - The component's base wrapper.
 * @csspart label - The option's label.
 * @csspart prefix - The container that wraps the prefix.
 * @csspart suffix - The container that wraps the suffix.
 */
import { computed, ref } from 'vue';
import '@synergy-design-system/components/components/option/option.js';

import type SynOption from '@synergy-design-system/components/components/option/option.component.js';

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

defineExpose({
  nativeElement,
});

// Map attributes
const props = defineProps<{
  /**
* The option's value.
* When selected, the containing form control will receive this value.
* The value must be unique
from other options in the same group.
* Values may not contain spaces, as spaces are used as delimiters when listing
multiple values.
 */
  value?: SynOption['value'];

  /**
   * Draws the option in a disabled state, preventing selection.
   */
  disabled?: SynOption['disabled'];
}>();

// 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-option v-bind="visibleProps" ref="nativeElement">
    <slot></slot>
  </syn-option>
</template>
