From fcfba4322ad0e27d7912fe5fcda6f4f362442e03 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 11 May 2023 15:49:28 -0300 Subject: fix some ui in arrays and created input file --- .../exchange-backoffice-ui/src/forms/InputFile.tsx | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 packages/exchange-backoffice-ui/src/forms/InputFile.tsx (limited to 'packages/exchange-backoffice-ui/src/forms/InputFile.tsx') diff --git a/packages/exchange-backoffice-ui/src/forms/InputFile.tsx b/packages/exchange-backoffice-ui/src/forms/InputFile.tsx new file mode 100644 index 000000000..749c8b264 --- /dev/null +++ b/packages/exchange-backoffice-ui/src/forms/InputFile.tsx @@ -0,0 +1,99 @@ +import { VNode, h } from "preact"; +import { + InputLine, + LabelWithTooltipMaybeRequired, + UIFormProps, +} from "./InputLine.js"; +import { useField } from "./useField.js"; + +export function InputFile( + props: { maxBites: number; accept?: string } & UIFormProps, +): VNode { + const { + name, + label, + placeholder, + tooltip, + required, + help, + maxBites, + accept, + } = props; + const { value, onChange } = useField<{ [s: string]: string }>(name); + + return ( +
+ + {!value || !value.startsWith("data:image/") ? ( +
+
+ +
+ + {/*

or drag and drop

*/} +
+
+
+ ) : ( +
+ + +
{ + onChange(undefined!); + }} + > + Clear +
+
+ )} + {help &&

{help}

} +
+ ); +} -- cgit v1.2.3