sandai-react
Version:
React components and utilities for the Sandai 3D AI Characters.
52 lines • 1.7 kB
TypeScript
/**
* Represents a parameter schema for the function tester component.
*
* @typedef {Object} SchemaType
* @property {string} id - The unique identifier for the input field.
* @property {string} type - The type of input (e.g., "text", "number").
* @property {string} label - The display label for the input field.
*/
type SchemaType = {
id: string;
type: string;
label: string;
};
/**
* Props for the `FunctionTester` component.
*
* @typedef {Object} FunctionTesterProps
* @property {Function} func - The function to be tested, which receives input values as arguments.
* @property {SchemaType[]} schema - An array of schema objects defining the function parameters.
*/
type FunctionTesterProps = {
func: Function;
schema: SchemaType[];
};
/**
* A reusable form component that dynamically generates input fields
* based on a schema and executes a function when submitted.
*
* The form captures input values, maps them according to the schema,
* and passes them as arguments to the provided function.
*
* ## Example Usage
* ```tsx
* const myFunction = (name: string, age: number) => {
* console.log(`Name: ${name}, Age: ${age}`);
* };
*
* const schema = [
* { id: "name", type: "text", label: "Name" },
* { id: "age", type: "number", label: "Age" }
* ];
*
* <FunctionTester func={myFunction} schema={schema} />
* ```
*
* @component
* @param {FunctionTesterProps} props - The component props.
* @returns {JSX.Element} The dynamically generated form component.
*/
export declare const FunctionTester: ({ func, schema }: FunctionTesterProps) => import("react/jsx-runtime").JSX.Element;
export {};
//# sourceMappingURL=FunctionTester.d.ts.map