diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index facf6237a..0ae55a4ea 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -9,6 +9,7 @@ import TextAreaComponent from "../../../../components/textAreaComponent"; import { typesContext } from "../../../../contexts/typesContext"; import { ParameterComponentType } from "../../../../types/components"; import FloatComponent from "../../../../components/floatComponent"; +import Dropdown from "../../../../components/dropdownComponent"; export default function ParameterComponent({ left, @@ -38,6 +39,7 @@ export default function ParameterComponent({ const [enabled, setEnabled] = useState( data.node.template[name]?.value ?? false ); + console.log(data.node.template[name]); const { reactFlowInstance } = useContext(typesContext); let disabled = reactFlowInstance?.getEdges().some((e) => e.targetHandle === id) ?? false; @@ -52,30 +54,32 @@ export default function ParameterComponent({ {title} {required ? " *" : ""} - {left && (type === "str" || type === "bool" || type === "float") ? - <> - : - - - isValidConnection(connection, reactFlowInstance) - } - className={classNames( - left ? "-ml-0.5 " : "-mr-0.5 ", - "w-3 h-3 rounded-full border-2 bg-white dark:bg-gray-800" - )} - style={{ - borderColor: color, - top: position, - }} - > - - } - - {left === true && type === "str" ? ( + {left && (type === "str" || type === "bool" || type === "float") ? ( + <> + ) : ( + + + isValidConnection(connection, reactFlowInstance) + } + className={classNames( + left ? "-ml-0.5 " : "-mr-0.5 ", + "w-3 h-3 rounded-full border-2 bg-white dark:bg-gray-800" + )} + style={{ + borderColor: color, + top: position, + }} + > + + )} + + {left === true && + type === "str" && + !data.node.template[name].options ? (
{data.node.template[name].list ? ( + ) : left === true && + type === "str" && + data.node.template[name].options ? ( + data.node.template[name].value=newValue} + value={data.node.template[name].value??"chose an option"} + > ) : ( <> )} diff --git a/src/frontend/src/components/dropdownComponent/index.tsx b/src/frontend/src/components/dropdownComponent/index.tsx index 2eb821909..d1a0f47b8 100644 --- a/src/frontend/src/components/dropdownComponent/index.tsx +++ b/src/frontend/src/components/dropdownComponent/index.tsx @@ -1,21 +1,22 @@ import { Listbox, Transition } from "@headlessui/react"; import { ChevronUpDownIcon, CheckIcon } from "@heroicons/react/24/outline"; -import { Fragment } from "react"; +import { Fragment, useState } from "react"; import { DropDownComponentType } from "../../types/components"; import { classNames } from "../../utils"; -export default function Dropdown({title, value, options, onSelect}:DropDownComponentType) { +export default function Dropdown({value, options, onSelect}:DropDownComponentType) { + let [internalValue,setInternalValue] = useState(value??"choose an option") return ( <> - + { + setInternalValue(value) + onSelect(value) + }}> {({ open }) => ( <> - - {title} -
- {value} + {internalValue} void;