From 0132e5e4bc0a319295289913ce28e7d93c651d29 Mon Sep 17 00:00:00 2001 From: Michal Klobukowski Date: Thu, 27 Dec 2018 15:55:51 +0100 Subject: [PATCH] Create FormField component Feature #13708 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- src/components/form-field/form-field.tsx | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/components/form-field/form-field.tsx diff --git a/src/components/form-field/form-field.tsx b/src/components/form-field/form-field.tsx new file mode 100644 index 00000000..32362ac4 --- /dev/null +++ b/src/components/form-field/form-field.tsx @@ -0,0 +1,41 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import * as React from 'react'; +import { WrappedFieldProps, WrappedFieldInputProps } from 'redux-form'; +import { FormGroup, FormLabel, FormHelperText } from '@material-ui/core'; + +interface FormFieldCustomProps { + children:

(props: WrappedFieldInputProps) => React.ReactElement

; + label?: string; + helperText?: string; + required?: boolean; +} + +export type FormFieldProps = FormFieldCustomProps & WrappedFieldProps; + +export const FormField = ({ children, ...props }: FormFieldProps & WrappedFieldProps) => { + return ( + + + + {props.label} + + + { children(props.input) } + + + { + props.meta.touched && props.meta.error + ? props.meta.error + : props.helperText + } + + + + ); +}; -- 2.39.5