import React from 'react';
import { clsx } from 'clsx';

import { forwardRef } from '../utils/react';
import { Box } from '../box';
import * as css from './field.css';

export interface FieldProps extends css.FieldVariants {}

export const Field = forwardRef<'div', FieldProps>(function Field(
  { className, invalid, width, children, ...rest },
  ref,
) {
  const cn = clsx(className, css.field({ invalid, width }));

  return (
    <Box ref={ref} className={cn} {...rest}>
      {children}
    </Box>
  );
});
