<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 <syn-pagination /> provides page navigation, direct page input, and page-size selection for large data sets.
 *
 * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-pagination--docs
 * @status stable
 * @since 3.12.0
 *
 * @event syn-pagination-page-changed - Emitted when the current page changes
 * @event syn-pagination-page-size-changed - Emitted when the page size changes
 *
 * @csspart base - The component's base wrapper.
 * @csspart divider - The divider element displayed at the top of the pagination component.
 * @csspart page-size-select-wrapper - The wrapper element containing the page size select and page item summary.
 * @csspart page-size-select - The page size select element.
 * @csspart page-item-summary - The text element displaying the current page item range and total items.
 * @csspart page-input-section - The section containing the page number input and total pages display.
 * @csspart page-input - The page number input element.
 * @csspart navigation - The pagination navigation element.
 * @csspart navigation-action - The individual navigation action buttons (first, previous, next, last).
 *
 * @accessibility
 * The entire component is wrapped in a semantic `<nav>` landmark with an `aria-label` for screen reader accessibility.
 * Use the `aria-label` attribute to provide a unique, descriptive label when multiple pagination controls exist on the page.
 * Example: `<syn-pagination aria-label="Search results pagination"></syn-pagination>`
 */
import { computed, ref } from 'vue';
import '@synergy-design-system/components/components/pagination/pagination.js';

import type { SynPaginationPageChangedEvent } from '@synergy-design-system/components';
import type { SynPaginationPageSizeChangedEvent } from '@synergy-design-system/components';
import type SynPagination from '@synergy-design-system/components/components/pagination/pagination.component.js';

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

defineExpose({
  nativeElement,
});

// Map attributes
const props = defineProps<{
  /**
   * When true, a divider is displayed at the top of the pagination component.
   */
  divider?: SynPagination['divider'];

  /**
   * When true, the pagination controls are disabled and non-interactive.
   */
  disabled?: SynPagination['disabled'];

  /**
   * The size of the pagination controls.
   */
  size?: SynPagination['size'];

  /**
* The current page number.
* The default value is 1.
The component will emit a `syn-pagination-page-changed` event whenever the page changes, allowing you to respond to page changes in your application.
 */
  currentPage?: SynPagination['currentPage'];

  /**
* The number of items to display per page.
* The default value is 25.
The component will emit a `syn-pagination-page-size-changed` event whenever the page size changes, allowing you to respond to page size changes in your application.
 */
  pageSize?: SynPagination['pageSize'];

  /**
* An array of numbers representing the available options for the number of items to display per page.
* The default value is [10, 25, 50, 100].
The component will use this array to populate the rows-per-page selector, allowing users to choose from the specified options.
 */
  pageSizeOptions?: SynPagination['pageSizeOptions'];

  /**
   * Total amount of items.
   * The component will use this value to calculate the total number of pages based on the selected rows per page.
   */
  totalItems?: SynPagination['totalItems'];

  /**
* The pagination variant to use.
* The "full" variant includes comprehensive controls for navigating between pages and adjusting the number of displayed rows,
while the "compact" variant offers a streamlined interface with essential navigation controls.
The default value is "full".
 */
  variant?: SynPagination['variant'];

  /**
   * An accessible label for the navigation landmark.
   * Customize for multiple paginations on a page.
   */
  ariaLabel?: SynPagination['ariaLabel'];
}>();

// 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 current page changes
   */
  'syn-pagination-page-changed': [e: SynPaginationPageChangedEvent];

  /**
   * Emitted when the page size changes
   */
  'syn-pagination-page-size-changed': [e: SynPaginationPageSizeChangedEvent];
}>();
</script>

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

<template>
  <syn-pagination
    @syn-pagination-page-changed="$emit('syn-pagination-page-changed', $event)"
    @syn-pagination-page-size-changed="
      $emit('syn-pagination-page-size-changed', $event)
    "
    v-bind="visibleProps"
    ref="nativeElement">
  </syn-pagination>
</template>
