diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d24e445..c748470 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -6,9 +6,8 @@
-
-
-
+
+
@@ -25,7 +24,7 @@
@@ -100,6 +99,7 @@
}
+
@@ -107,54 +107,54 @@
- {
+ "keyToString": {
+ "ASKED_ADD_EXTERNAL_FILES": "true",
+ "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "Docker.Dockerfile build.executor": "Run",
+ "Docker.Dockerfile.executor": "Run",
+ "Playwright.Create transparent PNG.should make png color transparent.executor": "Run",
+ "Playwright.JoinText Component.executor": "Run",
+ "Playwright.JoinText Component.should merge text pieces with specified join character.executor": "Run",
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "Vitest.compute function (1).executor": "Run",
+ "Vitest.compute function.executor": "Run",
+ "Vitest.mergeText.executor": "Run",
+ "Vitest.mergeText.should merge lines and preserve blank lines when deleteBlankLines is false.executor": "Run",
+ "Vitest.mergeText.should merge lines, preserve blank lines and trailing spaces when both deleteBlankLines and deleteTrailingSpaces are false.executor": "Run",
+ "Vitest.removeDuplicateLines function.executor": "Run",
+ "Vitest.removeDuplicateLines function.newlines option.executor": "Run",
+ "Vitest.removeDuplicateLines function.newlines option.should filter newlines when newlines is set to filter.executor": "Run",
+ "Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp.executor": "Run",
+ "Vitest.replaceText function.executor": "Run",
+ "git-widget-placeholder": "main",
+ "ignore.virus.scanning.warn.message": "true",
+ "kotlin-language-version-configured": "true",
+ "last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/src/pages/tools/list/duplicate/index.tsx",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "npm.build.executor": "Run",
+ "npm.dev.executor": "Run",
+ "npm.lint.executor": "Run",
+ "npm.prebuild.executor": "Run",
+ "npm.script:create:tool.executor": "Run",
+ "npm.test.executor": "Run",
+ "npm.test:e2e.executor": "Run",
+ "npm.test:e2e:run.executor": "Run",
+ "prettierjs.PrettierConfiguration.Package": "C:\\Users\\Ibrahima\\IdeaProjects\\omni-tools\\node_modules\\prettier",
+ "project.structure.last.edited": "Problems",
+ "project.structure.proportion": "0.0",
+ "project.structure.side.proportion": "0.2",
+ "settings.editor.selected.configurable": "refactai_advanced_settings",
+ "ts.external.directory.path": "C:\\Users\\Ibrahima\\IdeaProjects\\omni-tools\\node_modules\\typescript\\lib",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
-
+
@@ -253,10 +253,10 @@
-
-
+
+
@@ -340,6 +340,7 @@
+
diff --git a/src/components/ToolContent.tsx b/src/components/ToolContent.tsx
index 1eb802f..a1aa62c 100644
--- a/src/components/ToolContent.tsx
+++ b/src/components/ToolContent.tsx
@@ -1,6 +1,6 @@
-import React, { useRef, ReactNode, useState } from 'react';
+import React, { ReactNode, useContext } from 'react';
import { Box } from '@mui/material';
-import { Formik, FormikProps, FormikValues } from 'formik';
+import { Formik, FormikValues, useFormikContext } from 'formik';
import ToolOptions, { GetGroupsType } from '@components/options/ToolOptions';
import ToolInputAndResult from '@components/ToolInputAndResult';
import ToolInfo from '@components/ToolInfo';
@@ -9,6 +9,29 @@ import ToolExamples, {
CardExampleType
} from '@components/examples/ToolExamples';
import { ToolComponentProps } from '@tools/defineTool';
+import { CustomSnackBarContext } from '../contexts/CustomSnackBarContext';
+
+const FormikListenerComponent = ({
+ input,
+ compute
+}: {
+ input: any;
+ compute: (optionsValues: T, input: any) => void;
+}) => {
+ const { values } = useFormikContext();
+ const { showSnackBar } = useContext(CustomSnackBarContext);
+
+ React.useEffect(() => {
+ try {
+ compute(values, input);
+ } catch (exception: unknown) {
+ if (exception instanceof Error) showSnackBar(exception.message, 'error');
+ else console.error(exception);
+ }
+ }, [values, input, showSnackBar]);
+
+ return null; // This component doesn't render anything
+};
interface ToolContentProps extends ToolComponentProps {
// Input/Output components
@@ -75,12 +98,8 @@ export default function ToolContent({
}
result={resultComponent}
/>
-
-
+ compute={compute} input={input} />
+
{toolInfo && toolInfo.title && toolInfo.description && (
= (field: Y, value: T[Y]) => void;
-const FormikListenerComponent = ({
- input,
- compute
-}: {
- input: any;
- compute: (optionsValues: T, input: any) => void;
-}) => {
- const { values } = useFormikContext();
- const { showSnackBar } = useContext(CustomSnackBarContext);
-
- React.useEffect(() => {
- try {
- compute(values, input);
- } catch (exception: unknown) {
- if (exception instanceof Error) showSnackBar(exception.message, 'error');
- else console.error(exception);
- }
- }, [values, input, showSnackBar]);
-
- return null; // This component doesn't render anything
-};
-
export type GetGroupsType = (
formikProps: FormikProps & { updateField: UpdateField }
) => ToolOptionGroup[];
export default function ToolOptions({
children,
- compute,
- input,
getGroups
}: {
children?: ReactNode;
- compute: (optionsValues: T, input: any) => void;
- input?: any;
getGroups: GetGroupsType | null;
}) {
const theme = useTheme();
@@ -74,7 +47,6 @@ export default function ToolOptions({
- compute={compute} input={input} />