diff --git a/src/components/inspector.tsx b/src/components/inspector.tsx index 05d2a4f..3152aab 100644 --- a/src/components/inspector.tsx +++ b/src/components/inspector.tsx @@ -10,6 +10,8 @@ import Markdown from "react-markdown"; interface OptionType extends DefaultOptionType {} +type ArgType = "string" | "int" | "float" | "boolean" | "enum" | "code"; + export const Inspector: FC = () => { const workspace = { editing: useWorkspace((state) => state.editing), @@ -287,31 +289,26 @@ export const Inspector: FC = () => { {def.args.map((v) => { const required = v.type.indexOf("?") == -1; + const type = v.type.replace("?", "") as ArgType; return ( = 0 ? "checked" : undefined} + initialValue={type === "boolean" ? v.default ?? false : v.default} + valuePropName={type === "boolean" ? "checked" : undefined} rules={[{ required, message: t("node.fileRequired", { field: v.desc }) }]} > - {v.type.indexOf("string") >= 0 && ( - - )} - {v.type.indexOf("int") >= 0 && ( + {type === "string" && } + {type === "int" && ( )} - {v.type.indexOf("float") >= 0 && ( - - )} - {v.type.indexOf("boolean") >= 0 && ( - - )} - {v.type.indexOf("code") >= 0 && ( + {type === "float" && } + {type === "boolean" && } + {type === "code" && ( )} - {v.type.indexOf("enum") >= 0 && ( + {type === "enum" && (