🐛 fix(parameterComponent): handleOnNewValue now accepts Object[] as a valid parameter type to support dict and NestedDict types
🐛 fix(parameterComponent): remove unused state variables obj and dictArr ✨ feat(parameterComponent): add support for dict and NestedDict types in ParameterComponent 🐛 fix(dictComponent): call onChange when value prop changes to ensure proper synchronization 🐛 fix(keypairListComponent): call onChange when value prop changes to ensure proper synchronization 🐛 fix(dialog.tsx): add missing classes to prevent panning, dragging, undoing, and copying in DialogPortal and DialogOverlay components
This commit is contained in:
parent
3ae51da36e
commit
71dd9821ea
4 changed files with 32 additions and 23 deletions
|
|
@ -80,7 +80,9 @@ export default function ParameterComponent({
|
||||||
|
|
||||||
const { data: myData } = useContext(typesContext);
|
const { data: myData } = useContext(typesContext);
|
||||||
|
|
||||||
const handleOnNewValue = (newValue: string | string[] | boolean): void => {
|
const handleOnNewValue = (
|
||||||
|
newValue: string | string[] | boolean | Object[]
|
||||||
|
): void => {
|
||||||
let newData = cloneDeep(data);
|
let newData = cloneDeep(data);
|
||||||
newData.node!.template[name].value = newValue;
|
newData.node!.template[name].value = newValue;
|
||||||
setData(newData);
|
setData(newData);
|
||||||
|
|
@ -99,22 +101,7 @@ export default function ParameterComponent({
|
||||||
renderTooltips();
|
renderTooltips();
|
||||||
};
|
};
|
||||||
|
|
||||||
const [obj, setObj] = useState({
|
|
||||||
arr: ["test", 123456, false, null],
|
|
||||||
boolean: false,
|
|
||||||
number: 123456,
|
|
||||||
try: {
|
|
||||||
k1: 123,
|
|
||||||
k2: "123",
|
|
||||||
k3: false,
|
|
||||||
},
|
|
||||||
string: "string",
|
|
||||||
});
|
|
||||||
|
|
||||||
const [errorDuplicateKey, setErrorDuplicateKey] = useState(false);
|
const [errorDuplicateKey, setErrorDuplicateKey] = useState(false);
|
||||||
const [dictArr, setDictArr] = useState([
|
|
||||||
{ yourKey: "yourValue" },
|
|
||||||
] as Object[]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (name === "openai_api_base") console.log(info);
|
if (name === "openai_api_base") console.log(info);
|
||||||
|
|
@ -237,6 +224,8 @@ export default function ParameterComponent({
|
||||||
type === "code" ||
|
type === "code" ||
|
||||||
type === "prompt" ||
|
type === "prompt" ||
|
||||||
type === "file" ||
|
type === "file" ||
|
||||||
|
type === "dict" ||
|
||||||
|
type === "NestedDict" ||
|
||||||
type === "int") &&
|
type === "int") &&
|
||||||
!optionalHandle ? (
|
!optionalHandle ? (
|
||||||
<></>
|
<></>
|
||||||
|
|
@ -378,10 +367,22 @@ export default function ParameterComponent({
|
||||||
<DictComponent
|
<DictComponent
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
editNode={false}
|
editNode={false}
|
||||||
value={data.node!.template[name].value ?? obj}
|
value={
|
||||||
|
data.node!.template[name].value ?? {
|
||||||
|
arr: ["test", 123456, false, null],
|
||||||
|
boolean: false,
|
||||||
|
number: 123456,
|
||||||
|
try: {
|
||||||
|
k1: 123,
|
||||||
|
k2: "123",
|
||||||
|
k3: false,
|
||||||
|
},
|
||||||
|
string: "string",
|
||||||
|
}
|
||||||
|
}
|
||||||
onChange={(newValue) => {
|
onChange={(newValue) => {
|
||||||
setObj(newValue);
|
|
||||||
data.node!.template[name].value = newValue;
|
data.node!.template[name].value = newValue;
|
||||||
|
handleOnNewValue(newValue);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -393,14 +394,14 @@ export default function ParameterComponent({
|
||||||
value={
|
value={
|
||||||
data.node!.template[name].value?.length === 0 ||
|
data.node!.template[name].value?.length === 0 ||
|
||||||
!data.node!.template[name].value
|
!data.node!.template[name].value
|
||||||
? dictArr
|
? [{ yourKey: "yourValue" }]
|
||||||
: convertObjToArray(data.node!.template[name].value)
|
: convertObjToArray(data.node!.template[name].value)
|
||||||
}
|
}
|
||||||
duplicateKey={errorDuplicateKey}
|
duplicateKey={errorDuplicateKey}
|
||||||
onChange={(newValue) => {
|
onChange={(newValue) => {
|
||||||
setErrorDuplicateKey(hasDuplicateKeys(newValue));
|
|
||||||
setDictArr(newValue);
|
|
||||||
data.node!.template[name].value = newValue;
|
data.node!.template[name].value = newValue;
|
||||||
|
setErrorDuplicateKey(hasDuplicateKeys(newValue));
|
||||||
|
handleOnNewValue(newValue);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@ export default function DictComponent({
|
||||||
}
|
}
|
||||||
}, [disabled]);
|
}, [disabled]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (value) onChange(value);
|
||||||
|
}, [value]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,10 @@ export default function KeypairListComponent({
|
||||||
onChange(newInputList);
|
onChange(newInputList);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (value) onChange(value);
|
||||||
|
}, [value]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ const DialogPortal = ({
|
||||||
...props
|
...props
|
||||||
}: DialogPrimitive.DialogPortalProps) => (
|
}: DialogPrimitive.DialogPortalProps) => (
|
||||||
<DialogPrimitive.Portal className={cn(className)} {...props}>
|
<DialogPrimitive.Portal className={cn(className)} {...props}>
|
||||||
<div className="fixed inset-0 z-50 flex items-start justify-center sm:items-center">
|
<div className="nopan nodrag noundo nocopy fixed inset-0 z-50 flex items-start justify-center sm:items-center">
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</DialogPrimitive.Portal>
|
</DialogPrimitive.Portal>
|
||||||
|
|
@ -27,7 +27,7 @@ const DialogOverlay = React.forwardRef<
|
||||||
<DialogPrimitive.Overlay
|
<DialogPrimitive.Overlay
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
"noundo nocopy fixed inset-0 bottom-0 left-0 right-0 top-0 z-50 overflow-auto bg-blur-shared backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
"nopan nodrag noundo nocopy fixed inset-0 bottom-0 left-0 right-0 top-0 z-50 overflow-auto bg-blur-shared backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue