<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 Menu items provide options for the user to pick from in a menu.
 * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-menu-item--docs
 * @status stable
 * @since 1.12.0
 *
 * @dependency syn-icon
 * @dependency syn-popup
 * @dependency syn-spinner
 *
 * @slot - The menu item'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.
 * @slot submenu - Used to denote a nested menu.
 *
 * @csspart base - The component's base wrapper.
 * @csspart checked-icon - The checked icon, which is only visible when the menu item is checked.
 * @csspart prefix - The prefix container.
 * @csspart label - The menu item label.
 * @csspart suffix - The suffix container.
 * @csspart spinner - The spinner that shows when the menu item is in the loading state.
 * @csspart spinner__base - The spinner's base part.
 * @csspart submenu-icon - The submenu icon, visible only when the menu item has a submenu (not yet implemented).
 *
 * @cssproperty [--submenu-offset=-2px] - The distance submenus shift to overlap the parent menu.
 */
import { computed, ref } from 'vue';
import '@synergy-design-system/components/components/menu-item/menu-item.js';

import type SynMenuItem from '@synergy-design-system/components/components/menu-item/menu-item.component.js';

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

defineExpose({
  nativeElement,
});

// Map attributes
const props = defineProps<{
  /**
   * The type of menu item to render.
   * To use `checked`, this value must be set to `checkbox`.
   */
  type?: SynMenuItem['type'];

  /**
   * Draws the item in a checked state.
   */
  checked?: SynMenuItem['checked'];

  /**
   * A unique value to store in the menu item.
   * This can be used as a way to identify menu items when selected.
   */
  value?: SynMenuItem['value'];

  /**
   * Draws the menu item in a loading state.
   */
  loading?: SynMenuItem['loading'];

  /**
   * Draws the menu item in a disabled state, preventing selection.
   */
  disabled?: SynMenuItem['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-menu-item v-bind="visibleProps" ref="nativeElement">
    <slot></slot>
  </syn-menu-item>
</template>
