import type { FC, LegacyRef, PropsWithoutRef, ReactNode } from 'react' import type { ExtractProps } from '../types' import { ListboxButton } from '@headlessui/react' import { ChevronDownIcon } from '@heroicons/react/20/solid' import classNames from 'classnames' import React, { forwardRef } from 'react' import { DEFAULT_INPUT_CLASSNAME, ERROR_INPUT_CLASSNAME } from '../input' import { Typography } from '../typography' export type SelectButtonProps = PropsWithoutRef> & { open?: boolean children?: ReactNode standalone?: boolean error?: boolean ref?: LegacyRef } const SelectButton: FC = forwardRef( ({ className, children, standalone, error = false, open, ...props }, ref) => { return React.createElement( standalone ? 'div' : ListboxButton, { ...props, ref, className: classNames( open ? 'ring-2 ring-offset-2 ring-blue bg-slate-200 dark:bg-slate-600' : '', 'relative w-full pr-10', DEFAULT_INPUT_CLASSNAME, error ? ERROR_INPUT_CLASSNAME : '', className, ), }, <> {children} , ) }, ) export default SelectButton