<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 Drawers slide in from a container to expose additional options and information.
 * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-drawer--docs
 * @status stable
 * @since 1.8.0
 *
 * @dependency syn-icon-button
 *
 * @slot - The drawer's main content.
 * @slot label - The drawer's label. Alternatively, you can use the `label` attribute.
 * @slot header-actions - Optional actions to add to the header. Works best with `<syn-icon-button>`.
 * @slot footer - The drawer's footer, usually one or more buttons representing various options.
 *
 * @event syn-show - Emitted when the drawer opens.
 * @event syn-after-show - Emitted after the drawer opens and all animations are complete.
 * @event syn-hide - Emitted when the drawer closes.
 * @event syn-after-hide - Emitted after the drawer closes and all animations are complete.
 * @event syn-initial-focus - Emitted when the drawer opens and is ready to receive focus. Calling
 *   `event.preventDefault()` will prevent focusing and allow you to set it on a different element, such as an input.
 * @event {{ source: 'close-button' | 'keyboard' | 'overlay' }} syn-request-close - Emitted when the user attempts to
 *   close the drawer by clicking the close button, clicking the overlay, or pressing escape. Calling
 *   `event.preventDefault()` will keep the drawer open. Avoid using this unless closing the drawer will result in
 *   destructive behavior such as data loss.
 *
 * @csspart base - The component's base wrapper.
 * @csspart overlay - The overlay that covers the screen behind the drawer.
 * @csspart panel - The drawer's panel (where the drawer and its content are rendered).
 * @csspart header - The drawer's header. This element wraps the title and header actions.
 * @csspart header-actions - Optional actions to add to the header. Works best with `<syn-icon-button>`.
 * @csspart title - The drawer's title.
 * @csspart close-button - The close button, an `<syn-icon-button>`.
 * @csspart close-button__base - The close button's exported `base` part.
 * @csspart body - The drawer's body.
 * @csspart footer - The drawer's footer.
 *
 * @cssproperty --size - The preferred size of the drawer. This will be applied to the drawer's width or height
 *   depending on its `placement`. Note that the drawer will shrink to accommodate smaller screens.
 * @cssproperty --header-spacing - The amount of padding to use for the header.
 * @cssproperty --body-spacing - The amount of padding to use for the body.
 * @cssproperty --footer-spacing - The amount of padding to use for the footer.
 *
 * @animation drawer.showTop - The animation to use when showing a drawer with `top` placement.
 * @animation drawer.showEnd - The animation to use when showing a drawer with `end` placement.
 * @animation drawer.showBottom - The animation to use when showing a drawer with `bottom` placement.
 * @animation drawer.showStart - The animation to use when showing a drawer with `start` placement.
 * @animation drawer.hideTop - The animation to use when hiding a drawer with `top` placement.
 * @animation drawer.hideEnd - The animation to use when hiding a drawer with `end` placement.
 * @animation drawer.hideBottom - The animation to use when hiding a drawer with `bottom` placement.
 * @animation drawer.hideStart - The animation to use when hiding a drawer with `start` placement.
 * @animation drawer.denyClose - The animation to use when a request to close the drawer is denied.
 * @animation drawer.overlay.show - The animation to use when showing the drawer's overlay.
 * @animation drawer.overlay.hide - The animation to use when hiding the drawer's overlay.
 *
 * @property modal - Exposes the internal modal utility that controls focus trapping. To temporarily disable focus
 *   trapping and allow third-party modals spawned from an active Synergy modal, call `modal.activateExternal()` when
 *   the third-party modal opens. Upon closing, call `modal.deactivateExternal()` to restore Synergy's focus trapping.
 */
import { computed, ref } from 'vue';
import '@synergy-design-system/components/components/drawer/drawer.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 { SynInitialFocusEvent } from '@synergy-design-system/components';
import type { SynRequestCloseEvent } from '@synergy-design-system/components';
import type SynDrawer from '@synergy-design-system/components/components/drawer/drawer.component.js';

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

defineExpose({
  nativeElement,
});

// Map attributes
const props = defineProps<{
  /**
* Indicates whether or not the drawer is open.
* You can toggle this attribute to show and hide the drawer, or you can
use the `show()` and `hide()` methods and this attribute will reflect the drawer's open state.
 */
  open?: SynDrawer['open'];

  /**
* The drawer's label as displayed in the header.
* You should always include a relevant label even when using
`no-header`, as it is required for proper accessibility.
* If you need to display HTML, use the `label` slot instead.
 */
  label?: SynDrawer['label'];

  /**
   * The direction from which the drawer will open.
   */
  placement?: SynDrawer['placement'];

  /**
* By default, the drawer slides out of its containing block (usually the viewport).
* To make the drawer slide out of
its parent element, set this attribute and add `position: relative` to the parent.
 */
  contained?: SynDrawer['contained'];

  /**
* Removes the header.
* This will also remove the default close button, so please ensure you provide an easy,
accessible way for users to dismiss the drawer.
 */
  noHeader?: SynDrawer['noHeader'];
}>();

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

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

  /**
   * Emitted when the drawer closes.
   */
  'syn-hide': [e: SynHideEvent];

  /**
   * Emitted after the drawer closes and all animations are complete.
   */
  'syn-after-hide': [e: SynAfterHideEvent];

  /**
   * Emitted when the drawer opens and is ready to receive focus.
   * Calling `event.preventDefault()` will prevent focusing and allow you to set it on a different element, such as an input.
   */
  'syn-initial-focus': [e: SynInitialFocusEvent];

  /**
   * Emitted when the user attempts to close the drawer by clicking the close button, clicking the overlay, or pressing escape.
   * Calling `event.preventDefault()` will keep the drawer open.
   * Avoid using this unless closing the drawer will result in destructive behavior such as data loss.
   */
  'syn-request-close': [e: SynRequestCloseEvent];
}>();
</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';
export type { SynInitialFocusEvent } from '@synergy-design-system/components';
export type { SynRequestCloseEvent } from '@synergy-design-system/components';
</script>

<template>
  <syn-drawer
    @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)"
    @syn-initial-focus="$emit('syn-initial-focus', $event)"
    @syn-request-close="$emit('syn-request-close', $event)"
    v-bind="visibleProps"
    ref="nativeElement">
    <slot></slot>
  </syn-drawer>
</template>
