From 3d0da891a9e26aaaca44bdec15f922de75c82114 Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Wed, 10 Jul 2019 22:00:32 -0400 Subject: [PATCH] introduce formik select component --- src/components/formik-forms/formik-select.jsx | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/components/formik-forms/formik-select.jsx diff --git a/src/components/formik-forms/formik-select.jsx b/src/components/formik-forms/formik-select.jsx new file mode 100644 index 000000000..392b5ad7a --- /dev/null +++ b/src/components/formik-forms/formik-select.jsx @@ -0,0 +1,62 @@ +const classNames = require('classnames'); +const PropTypes = require('prop-types'); +const React = require('react'); +import {Field} from 'formik'; + +const ValidationMessage = require('../forms/validation-message.jsx'); + +require('../forms/input.scss'); +require('../forms/row.scss'); + +const FormikSelect = ({ + className, + error, + options, + validationClassName, + ...props +}) => { + const optionsList = options.map((item, index) => ( + + )); + return ( +
+ + {optionsList} + + {error && ( + + )} +
+ ); +}; + + +FormikSelect.propTypes = { + className: PropTypes.string, + error: PropTypes.string, + // expect structure like: [ + // {value: 'US', label: 'United States'} + // {value: 'AG', label: 'Angola'} + // ... + // ] + options: PropTypes.arrayOf(PropTypes.any), + validationClassName: PropTypes.string, + value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]) +}; + +module.exports = FormikSelect;