diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index cf6cb57..2a4766a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,15 @@
-
+
+
+
+
+
-
+
+
@@ -80,6 +85,7 @@
+
@@ -129,7 +135,7 @@
-
+
@@ -347,7 +353,15 @@
1719102365836
-
+
+
+ 1719103372481
+
+
+
+ 1719103372481
+
+
@@ -391,7 +405,8 @@
-
+
+
diff --git a/src/components/input/ToolTextInput.tsx b/src/components/input/ToolTextInput.tsx
index bb661e7..b086c3e 100644
--- a/src/components/input/ToolTextInput.tsx
+++ b/src/components/input/ToolTextInput.tsx
@@ -23,7 +23,7 @@ export default function ToolTextInput({
.writeText(value)
.then(() => showSnackBar('Text copied', 'success'))
.catch((err) => {
- showSnackBar('Failed to copy: ', err);
+ showSnackBar('Failed to copy: ' + err, 'error');
});
};
const handleFileChange = (event: React.ChangeEvent) => {
diff --git a/src/components/options/CheckboxWithDesc.tsx b/src/components/options/CheckboxWithDesc.tsx
new file mode 100644
index 0000000..ec49d28
--- /dev/null
+++ b/src/components/options/CheckboxWithDesc.tsx
@@ -0,0 +1,34 @@
+import React from 'react';
+import { Box, Checkbox, FormControlLabel, Typography } from '@mui/material';
+
+const CheckboxWithDesc = ({
+ title,
+ description,
+ checked,
+ onChange
+}: {
+ title: string;
+ description: string;
+ checked: boolean;
+ onChange: (value: boolean) => void;
+}) => {
+ const handleChange = (event: React.ChangeEvent) => {
+ onChange(event.target.checked);
+ };
+
+ return (
+
+
+ }
+ label={title}
+ />
+
+ {description}
+
+
+ );
+};
+
+export default CheckboxWithDesc;
diff --git a/src/components/options/RadioWithTextField.tsx b/src/components/options/RadioWithTextField.tsx
new file mode 100644
index 0000000..d82ca0c
--- /dev/null
+++ b/src/components/options/RadioWithTextField.tsx
@@ -0,0 +1,46 @@
+import { SplitOperatorType } from '../../pages/string/split/service';
+import { Box, Stack } from '@mui/material';
+import { Field } from 'formik';
+import Typography from '@mui/material/Typography';
+import React from 'react';
+import TextFieldWithDesc from './TextFieldWithDesc';
+
+const RadioWithTextField = ({
+ fieldName,
+ type,
+ title,
+ onTypeChange,
+ value,
+ description,
+ onTextChange
+}: {
+ fieldName: string;
+ title: string;
+ type: T;
+ onTypeChange: (val: T) => void;
+ value: string;
+ description: string;
+ onTextChange: (value: string) => void;
+}) => {
+ const onChange = () => onTypeChange(type);
+ return (
+
+
+
+ {title}
+
+
+
+ );
+};
+export default RadioWithTextField;
diff --git a/src/components/options/TextFieldWithDesc.tsx b/src/components/options/TextFieldWithDesc.tsx
new file mode 100644
index 0000000..7d184ea
--- /dev/null
+++ b/src/components/options/TextFieldWithDesc.tsx
@@ -0,0 +1,31 @@
+import { Box, TextField } from '@mui/material';
+import Typography from '@mui/material/Typography';
+import React from 'react';
+
+const TextFieldWithDesc = ({
+ description,
+ value,
+ onChange,
+ placeholder
+}: {
+ description: string;
+ value: string;
+ onChange: (value: string) => void;
+ placeholder?: string;
+}) => {
+ return (
+
+ onChange(event.target.value)}
+ />
+
+ {description}
+
+
+ );
+};
+
+export default TextFieldWithDesc;
diff --git a/src/components/ToolOptions.tsx b/src/components/options/ToolOptions.tsx
similarity index 100%
rename from src/components/ToolOptions.tsx
rename to src/components/options/ToolOptions.tsx
diff --git a/src/pages/string/join/index.tsx b/src/pages/string/join/index.tsx
index ccb143d..2c4cff4 100644
--- a/src/pages/string/join/index.tsx
+++ b/src/pages/string/join/index.tsx
@@ -12,9 +12,11 @@ import { Formik, FormikProps, useFormikContext } from 'formik';
import * as Yup from 'yup';
import ToolTextInput from '../../../components/input/ToolTextInput';
import ToolTextResult from '../../../components/result/ToolTextResult';
-import ToolOptions from '../../../components/ToolOptions';
+import ToolOptions from '../../../components/options/ToolOptions';
import { mergeText } from './service';
import { CustomSnackBarContext } from '../../../contexts/CustomSnackBarContext';
+import TextFieldWithDesc from '../../../components/options/TextFieldWithDesc';
+import CheckboxWithDesc from '../../../components/options/CheckboxWithDesc';
const initialValues = {
joinCharacter: '',
@@ -52,66 +54,8 @@ const blankTrailingOptions: {
}
];
-const InputWithDesc = ({
- placeholder,
- description,
- value,
- onChange
-}: {
- placeholder: string;
- description: string;
- value: string;
- onChange: (value: string) => void;
-}) => {
- return (
-
- onChange(event.target.value)}
- />
-
- {description}
-
-
- );
-};
-
-const CheckboxWithDesc = ({
- title,
- description,
- checked,
- onChange
-}: {
- title: string;
- description: string;
- checked: boolean;
- onChange: (value: boolean) => void;
-}) => {
- const handleChange = (event: React.ChangeEvent) => {
- onChange(event.target.checked);
- };
-
- return (
-
-
- }
- label={title}
- />
-
- {description}
-
-
- );
-};
-
export default function JoinText() {
const [input, setInput] = useState('');
- const formRef = useRef>(null);
const { showSnackBar } = useContext(CustomSnackBarContext);
const [result, setResult] = useState('');
@@ -121,7 +65,6 @@ export default function JoinText() {
useEffect(() => {
try {
- console.log('Form values:', values['joinCharacter']);
setResult(mergeText(input, deleteBlank, deleteTrailing, joinCharacter));
} catch (exception: unknown) {
if (exception instanceof Error)
@@ -129,7 +72,6 @@ export default function JoinText() {
}
}, [values, input]);
- console.log('deleteBlank', deleteBlank);
return null;
};
@@ -151,7 +93,6 @@ export default function JoinText() {
{}}
>
{({ setFieldValue, values }) => (
@@ -159,7 +100,7 @@ export default function JoinText() {
Text Merged Options
-
diff --git a/src/pages/string/split/index.tsx b/src/pages/string/split/index.tsx
index a2c6652..c28e229 100644
--- a/src/pages/string/split/index.tsx
+++ b/src/pages/string/split/index.tsx
@@ -6,9 +6,11 @@ import ToolTextInput from '../../../components/input/ToolTextInput';
import ToolTextResult from '../../../components/result/ToolTextResult';
import { Field, Formik, FormikProps, useFormikContext } from 'formik';
import * as Yup from 'yup';
-import ToolOptions from '../../../components/ToolOptions';
+import ToolOptions from '../../../components/options/ToolOptions';
import { compute, SplitOperatorType } from './service';
import { CustomSnackBarContext } from '../../../contexts/CustomSnackBarContext';
+import RadioWithTextField from '../../../components/options/RadioWithTextField';
+import TextFieldWithDesc from '../../../components/options/TextFieldWithDesc';
const initialValues = {
splitSeparatorType: 'symbol' as SplitOperatorType,
@@ -74,72 +76,11 @@ const outputOptions: {
accessor: 'charAfterChunk'
}
];
-const CustomRadioButton = ({
- fieldName,
- type,
- title,
- onTypeChange,
- value,
- description,
- onTextChange
-}: {
- fieldName: string;
- title: string;
- type: SplitOperatorType;
- onTypeChange: (val: string) => void;
- value: string;
- description: string;
- onTextChange: (value: string) => void;
-}) => {
- const onChange = () => onTypeChange(type);
- return (
-
-
-
- {title}
-
-
-
- );
-};
-
-const InputWithDesc = ({
- description,
- value,
- onChange
-}: {
- description: string;
- value: string;
- onChange: (value: string) => void;
-}) => {
- return (
-
- onChange(event.target.value)}
- />
-
- {description}
-
-
- );
-};
export default function SplitText() {
const [input, setInput] = useState('');
const [result, setResult] = useState('');
- const formRef = useRef>(null);
+ // const formRef = useRef>(null);
const { showSnackBar } = useContext(CustomSnackBarContext);
const FormikListenerComponent = () => {
@@ -197,7 +138,6 @@ export default function SplitText() {
{}}
>
{({ setFieldValue, values }) => (
@@ -206,7 +146,7 @@ export default function SplitText() {
Split separator options
{splitOperators.map(({ title, description, type }) => (
-
Output separator options
{outputOptions.map((option) => (
- setFieldValue(option.accessor, value)}