<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 Tags are used as labels to organize things or to indicate a selection.
 * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-tag--docs
 * @status stable
 * @since 1.2.0
 *
 * @dependency syn-icon-button
 *
 * @slot - The tag's content.
 *
 * @event syn-remove - Emitted when the remove button is activated.
 *
 * @csspart base - The component's base wrapper.
 * @csspart content - The tag's content.
 * @csspart remove-button - The tag's remove button, an `<syn-icon-button>`.
 * @csspart remove-button__base - The remove button's exported `base` part.
 */
import { computed, ref } from 'vue';
import '@synergy-design-system/components/components/tag/tag.js';

import type { SynRemoveEvent } from '@synergy-design-system/components';
import type SynTag from '@synergy-design-system/components/components/tag/tag.component.js';

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

defineExpose({
  nativeElement,
});

// Map attributes
const props = defineProps<{
  /**
   * The tag's size.
   */
  size?: SynTag['size'];

  /**
   * Makes the tag removable and shows a remove button.
   */
  removable?: SynTag['removable'];
}>();

// 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 remove button is activated.
   */
  'syn-remove': [e: SynRemoveEvent];
}>();
</script>

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

<template>
  <syn-tag
    @syn-remove="$emit('syn-remove', $event)"
    v-bind="visibleProps"
    ref="nativeElement">
    <slot></slot>
  </syn-tag>
</template>
