<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 The <syn-optgroup> element creates a grouping for <syn-option>s within a <syn-select>.
 * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-optgroup--docs
 * @status stable
 * @since 1.5.0
 *
 * @dependency syn-divider
 *
 * @slot - The given options. Must be `<syn-option>` elements.
 * @slot prefix - A presentational prefix icon or similar element.
 * @slot label - The label for the optgroup
 * @slot suffix - A presentational suffix icon or similar element.
 *
 * @csspart base - The component's base wrapper.
 * @csspart label-container - The container that wraps prefix, label and base
 * @csspart divider - The divider that is displayed above the content
 * @csspart prefix - The container that wraps the prefix.
 * @csspart suffix - The container that wraps the suffix.
 * @csspart options - The container that wraps the <syn-option> elements.
 *
 * @cssproperty --display-divider - Display property of the divider. Defaults to "block"
 */
import { computed, ref } from 'vue';
import '@synergy-design-system/components/components/optgroup/optgroup.js';

import type SynOptgroup from '@synergy-design-system/components/components/optgroup/optgroup.component.js';

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

defineExpose({
  nativeElement,
});

// Map attributes
const props = defineProps<{
  /**
   * Disables all options in the optgroup.
   */
  disabled?: SynOptgroup['disabled'];

  /**
   * The optgroups label.
   * If you need to display HTML, use the `label` slot instead.
   */
  label?: SynOptgroup['label'];
}>();

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