macro checkbox args + search & replace imporved

This commit is contained in:
Jan Prochazka
2020-11-01 10:22:14 +01:00
parent 20180fe4c4
commit 4efa87c3c8
5 changed files with 45 additions and 2 deletions

View File

@@ -2,7 +2,7 @@ import React from 'react';
import styled from 'styled-components';
import Select from 'react-select';
import Creatable from 'react-select/creatable';
import { TextField, SelectField } from './inputs';
import { TextField, SelectField, CheckboxField } from './inputs';
import { Field, useFormikContext } from 'formik';
import FormStyledButton from '../widgets/FormStyledButton';
import {
@@ -49,6 +49,26 @@ export function FormTextField({ label, ...other }) {
);
}
export function FormCheckboxFieldRaw({ name = undefined, ...other }) {
const { values, setFieldValue } = useFormikContext();
const handleChange = (event) => {
setFieldValue(name, event.target.checked);
};
return <CheckboxField name={name} checked={!!values[name]} onChange={handleChange} {...other} />;
// return <Field {...other} as={CheckboxField} />;
}
export function FormCheckboxField({ label, ...other }) {
return (
<FormRow>
<FormLabel>{label}</FormLabel>
<FormValue>
<FormCheckboxFieldRaw {...other} />
</FormValue>
</FormRow>
);
}
export function FormSelectFieldRaw({ children, ...other }) {
return (
<Field {...other} as={SelectField}>