mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-19 14:09:31 +02:00
feat: arithmetic sequence
This commit is contained in:
@@ -10,7 +10,7 @@ import ToolExamples, {
|
||||
} from '@components/examples/ToolExamples';
|
||||
import { ToolComponentProps } from '@tools/defineTool';
|
||||
|
||||
interface ToolContentPropsBase<T, I> extends ToolComponentProps {
|
||||
interface ToolContentProps<T, I> extends ToolComponentProps {
|
||||
// Input/Output components
|
||||
inputComponent: ReactNode;
|
||||
resultComponent: ReactNode;
|
||||
@@ -29,28 +29,15 @@ interface ToolContentPropsBase<T, I> extends ToolComponentProps {
|
||||
};
|
||||
|
||||
// Input value to pass to the compute function
|
||||
input: I;
|
||||
input?: I;
|
||||
|
||||
exampleCards?: CardExampleType<T>[];
|
||||
setInput?: React.Dispatch<React.SetStateAction<I>>;
|
||||
|
||||
// Validation schema (optional)
|
||||
validationSchema?: any;
|
||||
}
|
||||
|
||||
interface ToolContentPropsWithExamples<T, I>
|
||||
extends ToolContentPropsBase<T, I> {
|
||||
exampleCards: CardExampleType<T>[];
|
||||
setInput: React.Dispatch<React.SetStateAction<I>>;
|
||||
}
|
||||
|
||||
interface ToolContentPropsWithoutExamples<T, I>
|
||||
extends ToolContentPropsBase<T, I> {
|
||||
exampleCards?: never;
|
||||
setInput?: never;
|
||||
}
|
||||
|
||||
type ToolContentProps<T, I> =
|
||||
| ToolContentPropsWithExamples<T, I>
|
||||
| ToolContentPropsWithoutExamples<T, I>;
|
||||
|
||||
export default function ToolContent<T extends FormikValues, I>({
|
||||
title,
|
||||
inputComponent,
|
||||
|
@@ -14,10 +14,10 @@ import { GetGroupsType } from '@components/options/ToolOptions';
|
||||
export interface ExampleCardProps<T> {
|
||||
title: string;
|
||||
description: string;
|
||||
sampleText: string;
|
||||
sampleText?: string;
|
||||
sampleResult: string;
|
||||
sampleOptions: T;
|
||||
changeInputResult: (newInput: string, newOptions: T) => void;
|
||||
changeInputResult: (newInput: string | undefined, newOptions: T) => void;
|
||||
getGroups: GetGroupsType<T> | null;
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@ export interface ExampleProps<T> {
|
||||
exampleCards: CardExampleType<T>[];
|
||||
getGroups: GetGroupsType<T> | null;
|
||||
formRef: React.RefObject<FormikProps<T>>;
|
||||
setInput: React.Dispatch<React.SetStateAction<any>>;
|
||||
setInput?: React.Dispatch<React.SetStateAction<any>>;
|
||||
}
|
||||
|
||||
export default function ToolExamples<T>({
|
||||
@@ -26,8 +26,8 @@ export default function ToolExamples<T>({
|
||||
formRef,
|
||||
setInput
|
||||
}: ExampleProps<T>) {
|
||||
function changeInputResult(newInput: string, newOptions: T) {
|
||||
setInput(newInput);
|
||||
function changeInputResult(newInput: string | undefined, newOptions: T) {
|
||||
setInput?.(newInput);
|
||||
formRef.current?.setValues(newOptions);
|
||||
const toolsElement = document.getElementById('tool');
|
||||
if (toolsElement) {
|
||||
|
Reference in New Issue
Block a user