UNPKG

flowbite-react

Version:

Official React components built for Flowbite and Tailwind CSS

1 lines 3.17 kB
{"version":3,"file":"FileInput.mjs","sources":["../../../../src/components/FileInput/FileInput.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from \"react\";\nimport { forwardRef } from \"react\";\nimport { twMerge } from \"tailwind-merge\";\nimport { mergeDeep } from \"../../helpers/merge-deep\";\nimport { getTheme } from \"../../theme-store\";\nimport type { DeepPartial } from \"../../types\";\nimport { HelperText } from \"../HelperText\";\nimport type { FlowbiteTextInputColors, FlowbiteTextInputSizes } from \"../TextInput\";\n\nexport interface FlowbiteFileInputTheme {\n root: FlowbiteFileInputRootTheme;\n field: FlowbiteFileInputFieldTheme;\n}\n\nexport interface FlowbiteFileInputRootTheme {\n base: string;\n}\n\nexport interface FlowbiteFileInputFieldTheme {\n base: string;\n input: FlowbiteFileInputFieldInputTheme;\n}\n\nexport interface FlowbiteFileInputFieldInputTheme {\n base: string;\n colors: FlowbiteTextInputColors;\n sizes: FlowbiteTextInputSizes;\n}\n\nexport interface FileInputProps extends Omit<ComponentProps<\"input\">, \"type\" | \"ref\" | \"color\"> {\n color?: keyof FlowbiteTextInputColors;\n helperText?: ReactNode;\n sizing?: keyof FlowbiteTextInputSizes;\n theme?: DeepPartial<FlowbiteFileInputTheme>;\n}\n\nexport const FileInput = forwardRef<HTMLInputElement, FileInputProps>(\n ({ className, color = \"gray\", helperText, sizing = \"md\", theme: customTheme = {}, ...props }, ref) => {\n const theme = mergeDeep(getTheme().fileInput, customTheme);\n\n return (\n <>\n <div className={twMerge(theme.root.base, className)}>\n <div className={theme.field.base}>\n <input\n className={twMerge(\n theme.field.input.base,\n theme.field.input.colors[color],\n theme.field.input.sizes[sizing],\n )}\n {...props}\n type=\"file\"\n ref={ref}\n />\n </div>\n </div>\n {helperText && <HelperText color={color}>{helperText}</HelperText>}\n </>\n );\n },\n);\n\nFileInput.displayName = \"FileInput\";\n"],"names":[],"mappings":";;;;;;;AAOY,MAAC,SAAS,G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