<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 Tooltips display additional information based on a specific action.
 * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-tooltip--docs
 * @status stable
 * @since 1.21.0
 *
 * @dependency syn-popup
 *
 * @slot - The tooltip's target element. Avoid slotting in more than one element, as subsequent ones will be ignored.
 * @slot content - The content to render in the tooltip. Alternatively, you can use the `content` attribute.
 *
 * @event syn-show - Emitted when the tooltip begins to show.
 * @event syn-after-show - Emitted after the tooltip has shown and all animations are complete.
 * @event syn-hide - Emitted when the tooltip begins to hide.
 * @event syn-after-hide - Emitted after the tooltip has hidden and all animations are complete.
 *
 * @csspart base - The component's base wrapper, an `<syn-popup>` element.
 * @csspart base__popup - The popup's exported `popup` part. Use this to target the tooltip's popup container.
 * @csspart base__arrow - The popup's exported `arrow` part. Use this to target the tooltip's arrow.
 * @csspart body - The tooltip's body where its content is rendered.
 *
 * @cssproperty --max-width - The maximum width of the tooltip before its content will wrap.
 * @cssproperty --hide-delay - The amount of time to wait before hiding the tooltip when hovering.
 * @cssproperty --show-delay - The amount of time to wait before showing the tooltip when hovering.
 *
 * @animation tooltip.show - The animation to use when showing the tooltip.
 * @animation tooltip.hide - The animation to use when hiding the tooltip.
 */
import { computed, ref } from 'vue';
import '@synergy-design-system/components/components/tooltip/tooltip.js';

import type { SynShowEvent } from '@synergy-design-system/components';
import type { SynAfterShowEvent } from '@synergy-design-system/components';
import type { SynHideEvent } from '@synergy-design-system/components';
import type { SynAfterHideEvent } from '@synergy-design-system/components';
import type SynTooltip from '@synergy-design-system/components/components/tooltip/tooltip.component.js';

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

defineExpose({
  nativeElement,
});

// Map attributes
const props = defineProps<{
  /**
   * The tooltip's content.
   * If you need to display HTML, use the `content` slot instead.
   */
  content?: SynTooltip['content'];

  /**
* The preferred placement of the tooltip.
* Note that the actual placement may vary as needed to keep the tooltip
inside of the viewport.
 */
  placement?: SynTooltip['placement'];

  /**
   * Disables the tooltip so it won't show when triggered.
   */
  disabled?: SynTooltip['disabled'];

  /**
   * The distance in pixels from which to offset the tooltip away from its target.
   */
  distance?: SynTooltip['distance'];

  /**
   * Indicates whether or not the tooltip is open.
   * You can use this in lieu of the show/hide methods.
   */
  open?: SynTooltip['open'];

  /**
   * The distance in pixels from which to offset the tooltip along its target.
   */
  skidding?: SynTooltip['skidding'];

  /**
* Controls how the tooltip is activated.
* Possible options include `click`, `hover`, `focus`, and `manual`.
* Multiple
options can be passed by separating them with a space.
* When manual is used, the tooltip must be activated
programmatically.
 */
  trigger?: SynTooltip['trigger'];
}>();

// 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 tooltip begins to show.
   */
  'syn-show': [e: SynShowEvent];

  /**
   * Emitted after the tooltip has shown and all animations are complete.
   */
  'syn-after-show': [e: SynAfterShowEvent];

  /**
   * Emitted when the tooltip begins to hide.
   */
  'syn-hide': [e: SynHideEvent];

  /**
   * Emitted after the tooltip has hidden and all animations are complete.
   */
  'syn-after-hide': [e: SynAfterHideEvent];
}>();
</script>

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

<template>
  <syn-tooltip
    @syn-show="$emit('syn-show', $event)"
    @syn-after-show="$emit('syn-after-show', $event)"
    @syn-hide="$emit('syn-hide', $event)"
    @syn-after-hide="$emit('syn-after-hide', $event)"
    v-bind="visibleProps"
    ref="nativeElement">
    <slot></slot>
  </syn-tooltip>
</template>
