import * as Ariakit from '@ariakit/react';
import { getClassNames } from '@websolutespa/bom-core';
import React, { forwardRef } from 'react';
import { Label } from '../label/label';

type LabelProps = React.ComponentProps<typeof Label>;

export type SelectLabelProps = Omit<Ariakit.SelectLabelProps, 'render'> & Omit<LabelProps, keyof Ariakit.DialogDismissProps>;

export const SelectLabel = forwardRef<HTMLDivElement, SelectLabelProps>(
  function SelectLabel({
    store,
    className,
    ...props
  }: SelectLabelProps, ref) {
    const context = Ariakit.useSelectContext();
    const classNames = getClassNames('select__label', className);
    return (
      <Ariakit.SelectLabel
        ref={ref}
        className={classNames}
        store={store || context}
        {...props}
        render={
          <Label />
        }
      ></Ariakit.SelectLabel>
    );
  });
