<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 Progress bars are used to show the status of an ongoing operation.
 * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-progress-bar--docs
 * @status stable
 * @since 1.19.0
 *
 * @slot - A label to show inside the progress indicator.
 *
 * @csspart base - The component's base wrapper.
 * @csspart indicator - The progress bar's indicator.
 * @csspart label - The progress bar's label.
 *
 * @cssproperty --height - The progress bar's height.
 * @cssproperty --track-color - The color of the track.
 * @cssproperty --indicator-color - The color of the indicator.
 * @cssproperty --label-color - The color of the label.
 * @cssproperty --speed - The speed of the progress bar when in indeterminate state.
 */
import { computed, ref } from 'vue';
import '@synergy-design-system/components/components/progress-bar/progress-bar.js';

import type SynProgressBar from '@synergy-design-system/components/components/progress-bar/progress-bar.component.js';

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

defineExpose({
  nativeElement,
});

// Map attributes
const props = defineProps<{
  /**
   * The current progress as a percentage, 0 to 100.
   */
  value?: SynProgressBar['value'];

  /**
   * When true, percentage is ignored, the label is hidden, and the progress bar is drawn in an indeterminate state.
   */
  indeterminate?: SynProgressBar['indeterminate'];

  /**
   * A custom label for assistive devices.
   */
  label?: SynProgressBar['label'];
}>();

// 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-progress-bar v-bind="visibleProps" ref="nativeElement">
    <slot></slot>
  </syn-progress-bar>
</template>
