/* * Copyright (c) 2020 - present Cloudogu GmbH * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ import React, { ChangeEvent, FocusEvent, useState } from "react"; import { useTranslation } from "react-i18next"; import classNames from "classnames"; import { createAttributesForTesting } from "../devBuild"; import LabelWithHelpIcon from "./LabelWithHelpIcon"; import { createA11yId } from "../createA11yId"; type Props = { name?: string; filenamePlaceholder?: string; className?: string; label?: string; placeholder?: string; helpText?: string; disabled?: boolean; testId?: string; onChange?: (event: ChangeEvent) => void; onBlur?: (event: FocusEvent) => void; }; /** * @deprecated */ const FileInput = React.forwardRef( ({ name, filenamePlaceholder, testId, helpText, placeholder, disabled, label, className, onBlur, onChange }, ref) => { const [t] = useTranslation("commons"); const [file, setFile] = useState(null); const handleChange = (event: ChangeEvent) => { const uploadedFile = event?.target?.files![0]; // @ts-ignore the uploaded file doesn't match our types setFile(uploadedFile); if (onChange && event.target.files) { onChange(event); } }; const handleBlur = (event: FocusEvent) => { if (onBlur && event.target.files) { onBlur(event); } }; const id = createA11yId("file-input"); return (
); } ); export default FileInput;