Files
probo/packages/ui/src/Molecules/FileButton/FileButton.tsx
Émile Ré e143477d66 Remove extensions from import paths
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-01-23 12:42:34 +04:00

41 lines
855 B
TypeScript

import type {
ChangeEventHandler,
ComponentProps,
PropsWithChildren,
RefObject,
} from "react";
import { button, Button } from "../../Atoms/Button/Button";
type Props = PropsWithChildren<{
onChange: ChangeEventHandler<HTMLInputElement>;
accept?: string;
disabled?: boolean;
className?: string;
ref?: RefObject<HTMLInputElement | null>;
}>
& Pick<ComponentProps<typeof Button>, "disabled" | "variant" | "icon">;
export function FileButton({
onChange,
children,
icon: IconComponent,
ref,
accept,
...props
}: Props) {
return (
<label className={button({ ...props })}>
{IconComponent && <IconComponent size={16} className="flex-none" />}
{children}
<input
type="file"
onChange={onChange}
hidden
ref={ref}
{...(accept && { accept })}
/>
</label>
);
}