<script lang="ts">
import type { PrimitiveProps } from '../../internal/primitive';

/**
 * Groups related items under a shared label (`role="group"`). Wraps a set of
 * `ListboxItem`s and is labelled by its `ListboxGroupLabel` via `aria-labelledby`.
 */
export interface ListboxGroupProps extends PrimitiveProps {}
</script>

<script setup lang="ts">
import { Primitive } from '../../internal/primitive';
import { provideListboxGroupContext } from './context';
import { useForwardExpose } from '@robonen/vue';
import { useId } from '../../utilities/config-provider';

const { as = 'div' } = defineProps<ListboxGroupProps>();

const { forwardRef } = useForwardExpose();
const id = useId(undefined, 'listbox-group').value;

provideListboxGroupContext({ id });
</script>

<template>
  <Primitive
    :ref="forwardRef"
    :as="as"
    role="group"
    :aria-labelledby="id"
  >
    <slot />
  </Primitive>
</template>
