<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 Radios buttons allow the user to select a single option from a group using a button-like control.
 * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-radio-button--docs
 * @status stable
 * @since 1.0.0
 *
 * @slot - The radio button's label.
 * @slot prefix - A presentational prefix icon or similar element.
 * @slot suffix - A presentational suffix icon or similar element.
 *
 * @event syn-blur - Emitted when the button loses focus.
 * @event syn-focus - Emitted when the button gains focus.
 *
 * @csspart base - The component's base wrapper.
 * @csspart button - The internal `<button>` element.
 * @csspart button--checked - The internal button element when the radio button is checked.
 * @csspart prefix - The container that wraps the prefix.
 * @csspart label - The container that wraps the radio button's label.
 * @csspart suffix - The container that wraps the suffix.
 */
import { computed, ref } from 'vue';
import '@synergy-design-system/components/components/radio-button/radio-button.js';

import type { SynBlurEvent } from '@synergy-design-system/components';
import type { SynFocusEvent } from '@synergy-design-system/components';
import type SynRadioButton from '@synergy-design-system/components/components/radio-button/radio-button.component.js';

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

defineExpose({
  nativeElement,
});

// Map attributes
const props = defineProps<{
  /**
   * The radio's value.
   * When selected, the radio group will receive this value.
   */
  value?: SynRadioButton['value'];

  /**
   * Disables the radio button.
   */
  disabled?: SynRadioButton['disabled'];

  /**
* The radio button's size.
* When used inside a radio group, the size will be determined by the radio group's size so
this attribute can typically be omitted.
 */
  size?: SynRadioButton['size'];

  /**
   * Draws a pill-style radio button with rounded edges.
   */
  pill?: SynRadioButton['pill'];
}>();

// 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'),
  ),
);

// Map events
defineEmits<{
  /**
   * Emitted when the button loses focus.
   */
  'syn-blur': [e: SynBlurEvent];

  /**
   * Emitted when the button gains focus.
   */
  'syn-focus': [e: SynFocusEvent];
}>();
</script>

<script lang="ts">
export type { SynBlurEvent } from '@synergy-design-system/components';
export type { SynFocusEvent } from '@synergy-design-system/components';
</script>

<template>
  <syn-radio-button
    @syn-blur="$emit('syn-blur', $event)"
    @syn-focus="$emit('syn-focus', $event)"
    v-bind="visibleProps"
    ref="nativeElement">
    <slot></slot>
  </syn-radio-button>
</template>
