2025-08-22 20:17:00 +03:00
|
|
|
import { Ref } from "preact";
|
|
|
|
|
|
2025-08-05 23:03:38 +03:00
|
|
|
interface FormFileUploadProps {
|
2025-08-22 20:17:00 +03:00
|
|
|
name?: string;
|
2025-08-05 23:03:38 +03:00
|
|
|
onChange: (files: FileList | null) => void;
|
|
|
|
|
multiple?: boolean;
|
2025-08-22 20:17:00 +03:00
|
|
|
hidden?: boolean;
|
|
|
|
|
inputRef?: Ref<HTMLInputElement>;
|
2025-08-05 23:03:38 +03:00
|
|
|
}
|
|
|
|
|
|
2025-08-22 20:17:00 +03:00
|
|
|
export default function FormFileUpload({ inputRef, name, onChange, multiple, hidden }: FormFileUploadProps) {
|
2025-08-05 23:03:38 +03:00
|
|
|
return (
|
2025-08-22 20:17:00 +03:00
|
|
|
<label class="tn-file-input tn-input-field" style={hidden ? { display: "none" } : undefined}>
|
|
|
|
|
<input
|
|
|
|
|
ref={inputRef}
|
|
|
|
|
name={name}
|
|
|
|
|
type="file"
|
|
|
|
|
class="form-control-file"
|
|
|
|
|
multiple={multiple}
|
2025-08-05 23:03:38 +03:00
|
|
|
onChange={e => onChange((e.target as HTMLInputElement).files)} />
|
|
|
|
|
</label>
|
|
|
|
|
)
|
|
|
|
|
}
|