diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 139b0ed..c30d211 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,18 +4,19 @@
-
+
-
-
-
+
+
+
-
-
+
+
-
+
+
@@ -210,14 +211,6 @@
-
-
- 1719096461432
-
-
-
- 1719096461432
-
1719096551866
@@ -602,7 +595,15 @@
1719510922051
-
+
+
+ 1719516424652
+
+
+
+ 1719516424652
+
+
@@ -635,7 +636,6 @@
-
@@ -660,7 +660,8 @@
-
+
+
diff --git a/src/components/options/RadioWithTextField.tsx b/src/components/options/RadioWithTextField.tsx
index 6de5192..75da087 100644
--- a/src/components/options/RadioWithTextField.tsx
+++ b/src/components/options/RadioWithTextField.tsx
@@ -31,10 +31,7 @@ const RadioWithTextField = ({
/>
{
- if (typeof val === 'string') onTextChange(val);
- else onTextChange(val.target.value);
- }}
+ onOwnChange={onTextChange}
description={description}
/>
diff --git a/src/components/options/TextFieldWithDesc.tsx b/src/components/options/TextFieldWithDesc.tsx
index 583781f..c766e38 100644
--- a/src/components/options/TextFieldWithDesc.tsx
+++ b/src/components/options/TextFieldWithDesc.tsx
@@ -5,13 +5,13 @@ import React from 'react';
type OwnProps = {
description?: string;
value: string | number;
- onChange: (value: string) => void;
+ onOwnChange: (value: string) => void;
placeholder?: string;
};
const TextFieldWithDesc = ({
description,
value,
- onChange,
+ onOwnChange,
placeholder,
...props
}: TextFieldProps & OwnProps) => {
@@ -21,7 +21,7 @@ const TextFieldWithDesc = ({
placeholder={placeholder}
sx={{ backgroundColor: 'white' }}
value={value}
- onChange={(event) => onChange(event.target.value)}
+ onChange={(event) => onOwnChange(event.target.value)}
{...props}
/>
{description && (
diff --git a/src/components/options/ToolOptions.tsx b/src/components/options/ToolOptions.tsx
index 89baf83..efe2706 100644
--- a/src/components/options/ToolOptions.tsx
+++ b/src/components/options/ToolOptions.tsx
@@ -6,6 +6,8 @@ import { Formik, FormikProps, FormikValues, useFormikContext } from 'formik';
import ToolOptionGroups, { ToolOptionGroup } from './ToolOptionGroups';
import { CustomSnackBarContext } from '../../contexts/CustomSnackBarContext';
+type UpdateField = (field: Y, value: T[Y]) => void;
+
const FormikListenerComponent = ({
initialValues,
input,
@@ -42,11 +44,16 @@ export default function ToolOptions({
validationSchema: any | (() => any);
compute: (optionsValues: T, input: any) => void;
input?: any;
- getGroups: (formikProps: FormikProps) => ToolOptionGroup[];
+ getGroups: (
+ formikProps: FormikProps & { updateField: UpdateField }
+ ) => ToolOptionGroup[];
formRef?: RefObject>;
}) {
const theme = useTheme();
-
+ const updateField: UpdateField = (field, value) => {
+ // @ts-ignore
+ formRef?.current?.setFieldValue(field, value);
+ };
return (
({
input={input}
initialValues={initialValues}
/>
-
+
{children}
)}
diff --git a/src/pages/image/png/change-colors-in-png/index.tsx b/src/pages/image/png/change-colors-in-png/index.tsx
index 6c83e1d..445d2c6 100644
--- a/src/pages/image/png/change-colors-in-png/index.tsx
+++ b/src/pages/image/png/change-colors-in-png/index.tsx
@@ -134,7 +134,7 @@ export default function ChangeColorsInPng() {
/>
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.'
}
diff --git a/src/pages/image/png/create-transparent/index.tsx b/src/pages/image/png/create-transparent/index.tsx
index 726c728..4df0571 100644
--- a/src/pages/image/png/create-transparent/index.tsx
+++ b/src/pages/image/png/create-transparent/index.tsx
@@ -122,7 +122,7 @@ export default function ChangeColorsInPng() {
/>
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.'
}
diff --git a/src/pages/list/sort/index.tsx b/src/pages/list/sort/index.tsx
index eea2c0b..5223a7e 100644
--- a/src/pages/list/sort/index.tsx
+++ b/src/pages/list/sort/index.tsx
@@ -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() {
/>
[
+ getGroups={({ values, updateField }) => [
{
title: 'Input item separator',
- component: splitOperators.map(({ title, description, type }) => (
- setFieldValue('splitSeparatorType', type)}
- title={title}
- description={description}
- checked={values.splitSeparatorType === type}
- />
- ))
+ component: (
+
+ {splitOperators.map(({ title, description, type }) => (
+ updateField('splitSeparatorType', type)}
+ title={title}
+ description={description}
+ checked={values.splitSeparatorType === type}
+ />
+ ))}
+ updateField('splitSeparator', val)}
+ />
+
+ )
},
{
title: 'Sort method',
diff --git a/src/pages/number/generate/index.tsx b/src/pages/number/generate/index.tsx
index e810407..1002bc4 100644
--- a/src/pages/number/generate/index.tsx
+++ b/src/pages/number/generate/index.tsx
@@ -34,19 +34,19 @@ export default function SplitText() {
setFieldValue('firstValue', val)}
+ onOwnChange={(val) => setFieldValue('firstValue', val)}
type={'number'}
/>
setFieldValue('step', val)}
+ onOwnChange={(val) => setFieldValue('step', val)}
type={'number'}
/>
setFieldValue('numberOfNumbers', val)}
+ onOwnChange={(val) => setFieldValue('numberOfNumbers', val)}
type={'number'}
/>
@@ -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)}
/>
)
}
diff --git a/src/pages/string/join/index.tsx b/src/pages/string/join/index.tsx
index 7369976..ddc2b91 100644
--- a/src/pages/string/join/index.tsx
+++ b/src/pages/string/join/index.tsx
@@ -149,7 +149,7 @@ export default function JoinText() {
+ onOwnChange={(value) =>
setFieldValue(mergeOptions.accessor, value)
}
description={mergeOptions.description}
diff --git a/src/pages/string/split/index.tsx b/src/pages/string/split/index.tsx
index 55269ef..4d3ac88 100644
--- a/src/pages/string/split/index.tsx
+++ b/src/pages/string/split/index.tsx
@@ -138,7 +138,7 @@ export default function SplitText() {
setFieldValue(option.accessor, value)}
+ onOwnChange={(value) => setFieldValue(option.accessor, value)}
description={option.description}
/>
))
diff --git a/src/pages/string/to-morse/index.tsx b/src/pages/string/to-morse/index.tsx
index c06d1aa..f7ce286 100644
--- a/src/pages/string/to-morse/index.tsx
+++ b/src/pages/string/to-morse/index.tsx
@@ -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)}
/>
)
}
diff --git a/src/pages/video/gif/change-speed/index.tsx b/src/pages/video/gif/change-speed/index.tsx
index fbd3601..8277e43 100644
--- a/src/pages/video/gif/change-speed/index.tsx
+++ b/src/pages/video/gif/change-speed/index.tsx
@@ -130,7 +130,7 @@ export default function ChangeSpeed() {
setFieldValue('newSpeed', val)}
+ onOwnChange={(val) => setFieldValue('newSpeed', val)}
description={'Default new GIF speed.'}
InputProps={{ endAdornment: ms }}
type={'number'}