<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 Icons buttons are simple, icon-only buttons that can be used for actions and in toolbars.
 * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-icon-button--docs
 * @status stable
 * @since 1.1.0
 *
 * @dependency syn-icon
 *
 * @event syn-blur - Emitted when the icon button loses focus.
 * @event syn-focus - Emitted when the icon button gains focus.
 *
 * @csspart base - The component's base wrapper.
 */
import { computed, ref } from 'vue';
import '@synergy-design-system/components/components/icon-button/icon-button.js';

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

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

defineExpose({
  nativeElement,
});

// Map attributes
const props = defineProps<{
  /**
   * The name of the icon to draw.
   * Available names depend on the icon library being used.
   */
  name?: SynIconButton['name'];

  /**
   * The name of a registered custom icon library.
   */
  library?: SynIconButton['library'];

  /**
* An external URL of an SVG file.
* Be sure you trust the content you are including, as it will be executed as code and
can result in XSS attacks.
 */
  src?: SynIconButton['src'];

  /**
   * When set, the underlying button will be rendered as an `<a>` with this `href` instead of a `<button>`.
   */
  href?: SynIconButton['href'];

  /**
   * Tells the browser where to open the link.
   * Only used when `href` is set.
   */
  target?: SynIconButton['target'];

  /**
   * Tells the browser to download the linked file as this filename.
   * Only used when `href` is set.
   */
  download?: SynIconButton['download'];

  /**
* A description that gets read by assistive devices.
* For optimal accessibility, you should always include a label
that describes what the icon button does.
 */
  label?: SynIconButton['label'];

  /**
   * The icon button's size.
   */
  size?: SynIconButton['size'];

  /**
* The color of the icon button.
The default "currentColor" makes it possible to easily style the icon button from outside without any CSS variables.
 */
  color?: SynIconButton['color'];

  /**
   * Disables the button.
   */
  disabled?: SynIconButton['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'),
  ),
);

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

  /**
   * Emitted when the icon 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-icon-button
    @syn-blur="$emit('syn-blur', $event)"
    @syn-focus="$emit('syn-focus', $event)"
    v-bind="visibleProps"
    ref="nativeElement">
  </syn-icon-button>
</template>
