chore: formik updateField

This commit is contained in:
Ibrahima G. Coulibaly
2024-06-27 21:25:11 +01:00
parent a6eb5d59e9
commit da93452bd3
12 changed files with 66 additions and 49 deletions

View File

@@ -134,7 +134,7 @@ export default function ChangeColorsInPng() {
/>
<TextFieldWithDesc
value={values.similarity}
onChange={(val) => setFieldValue('similarity', val)}
onOwnChange={(val) => setFieldValue('similarity', val)}
description={
'Match this % of similar colors of the from color. For example, 10% white will match white and a little bit of gray.'
}

View File

@@ -122,7 +122,7 @@ export default function ChangeColorsInPng() {
/>
<TextFieldWithDesc
value={values.similarity}
onChange={(val) => setFieldValue('similarity', val)}
onOwnChange={(val) => setFieldValue('similarity', val)}
description={
'Match this % of similar colors of the from color. For example, 10% white will match white and a little bit of gray.'
}

View File

@@ -7,6 +7,7 @@ import ToolOptions from '../../../components/options/ToolOptions';
import { Sort, SortingMethod, SplitOperatorType } from './service';
import ToolInputAndResult from '../../../components/ToolInputAndResult';
import SimpleRadio from '../../../components/options/SimpleRadio';
import TextFieldWithDesc from '../../../components/options/TextFieldWithDesc';
const initialValues = {
splitSeparatorType: 'symbol' as SplitOperatorType,
@@ -80,18 +81,27 @@ export default function SplitText() {
/>
<ToolOptions
compute={computeExternal}
getGroups={({ values, setFieldValue, handleChange }) => [
getGroups={({ values, updateField }) => [
{
title: 'Input item separator',
component: splitOperators.map(({ title, description, type }) => (
<SimpleRadio
key={type}
onClick={() => setFieldValue('splitSeparatorType', type)}
title={title}
description={description}
checked={values.splitSeparatorType === type}
/>
))
component: (
<Box>
{splitOperators.map(({ title, description, type }) => (
<SimpleRadio
key={type}
onClick={() => updateField('splitSeparatorType', type)}
title={title}
description={description}
checked={values.splitSeparatorType === type}
/>
))}
<TextFieldWithDesc
description={'Set a delimiting symbol or regular expression.'}
value={values.splitSeparator}
onOwnChange={(val) => updateField('splitSeparator', val)}
/>
</Box>
)
},
{
title: 'Sort method',

View File

@@ -34,19 +34,19 @@ export default function SplitText() {
<TextFieldWithDesc
description={'Start sequence from this number.'}
value={values.firstValue}
onChange={(val) => setFieldValue('firstValue', val)}
onOwnChange={(val) => setFieldValue('firstValue', val)}
type={'number'}
/>
<TextFieldWithDesc
description={'Increase each element by this amount'}
value={values.step}
onChange={(val) => setFieldValue('step', val)}
onOwnChange={(val) => setFieldValue('step', val)}
type={'number'}
/>
<TextFieldWithDesc
description={'Number of elements in sequence.'}
value={values.numberOfNumbers}
onChange={(val) => setFieldValue('numberOfNumbers', val)}
onOwnChange={(val) => setFieldValue('numberOfNumbers', val)}
type={'number'}
/>
</Box>
@@ -60,7 +60,7 @@ export default function SplitText() {
'Separate elements in the arithmetic sequence by this character.'
}
value={values.separator}
onChange={(val) => setFieldValue('separator', val)}
onOwnChange={(val) => setFieldValue('separator', val)}
/>
)
}

View File

@@ -149,7 +149,7 @@ export default function JoinText() {
<TextFieldWithDesc
placeholder={mergeOptions.placeholder}
value={values['joinCharacter']}
onChange={(value) =>
onOwnChange={(value) =>
setFieldValue(mergeOptions.accessor, value)
}
description={mergeOptions.description}

View File

@@ -138,7 +138,7 @@ export default function SplitText() {
<TextFieldWithDesc
key={option.accessor}
value={values[option.accessor]}
onChange={(value) => setFieldValue(option.accessor, value)}
onOwnChange={(value) => setFieldValue(option.accessor, value)}
description={option.description}
/>
))

View File

@@ -42,7 +42,7 @@ export default function ToMorse() {
'Symbol that will correspond to the dot in Morse code.'
}
value={values.dotSymbol}
onChange={(val) => setFieldValue('dotSymbol', val)}
onOwnChange={(val) => setFieldValue('dotSymbol', val)}
/>
)
},
@@ -54,7 +54,7 @@ export default function ToMorse() {
'Symbol that will correspond to the dash in Morse code.'
}
value={values.dashSymbol}
onChange={(val) => setFieldValue('dashSymbol', val)}
onOwnChange={(val) => setFieldValue('dashSymbol', val)}
/>
)
}

View File

@@ -130,7 +130,7 @@ export default function ChangeSpeed() {
<Box>
<TextFieldWithDesc
value={values.newSpeed}
onChange={(val) => setFieldValue('newSpeed', val)}
onOwnChange={(val) => setFieldValue('newSpeed', val)}
description={'Default new GIF speed.'}
InputProps={{ endAdornment: <Typography>ms</Typography> }}
type={'number'}