@vertisanpro/flowbite-react
Version:
Non-Official React components built for Flowbite and Tailwind CSS
17 lines (16 loc) • 1.35 kB
JavaScript
import { twMerge } from '@vertisanpro/tailwind-merge';
import React, { forwardRef } from 'react';
import { mergeDeep } from '../../helpers/merge-deep';
import { getTheme } from '../../theme-store';
import { HelperText } from '../HelperText';
export const Select = forwardRef(({ addon, children, className, color = 'gray', helperText, icon: Icon, shadow, sizing = 'md', theme: customTheme = {}, ...props }, ref) => {
const theme = mergeDeep(getTheme().select, customTheme);
return (React.createElement("div", { className: twMerge(theme.base, className) },
addon && React.createElement("span", { className: theme.addon }, addon),
React.createElement("div", { className: theme.field.base },
Icon && (React.createElement("div", { className: theme.field.icon.base },
React.createElement(Icon, { className: theme.field.icon.svg }))),
React.createElement("select", { className: twMerge(theme.field.select.base, theme.field.select.colors[color], theme.field.select.sizes[sizing], theme.field.select.withIcon[Icon ? 'on' : 'off'], theme.field.select.withAddon[addon ? 'on' : 'off'], theme.field.select.withShadow[shadow ? 'on' : 'off']), ...props, ref: ref }, children),
helperText && React.createElement(HelperText, { color: color }, helperText))));
});
Select.displayName = 'Select';