import { ComponentProps, forwardRef } from 'react';
import * as SelectPrimitives from '@radix-ui/react-select';

export type SelectItemRef = HTMLDivElement;
export type SelectItemProps = ComponentProps<typeof SelectPrimitives.Item>;

export const SelectItem = forwardRef<SelectItemRef, SelectItemProps>((props, ref) => {
  const { children, ...delegated } = props;

  return (
    <SelectPrimitives.Item className="c-select-item" ref={ref} {...delegated}>
      <SelectPrimitives.ItemText>{children}</SelectPrimitives.ItemText>
      <SelectPrimitives.ItemIndicator />
    </SelectPrimitives.Item>
  );
});

SelectItem.displayName = 'SelectItem';
