feat: rename var name sync to used jinjia code (#3964)

This commit is contained in:
Joel
2024-04-29 11:34:30 +08:00
committed by GitHub
parent 99292edd46
commit fa509ce64e
3 changed files with 23 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ type Props = {
readonly: boolean
list: Variable[]
onChange: (list: Variable[]) => void
onVarNameChange?: (oldName: string, newName: string) => void
isSupportConstantValue?: boolean
onlyLeafNodeVar?: boolean
filterVar?: (payload: Var, valueSelector: ValueSelector) => boolean
@@ -23,6 +24,7 @@ const VarList: FC<Props> = ({
readonly,
list,
onChange,
onVarNameChange,
isSupportConstantValue,
onlyLeafNodeVar,
filterVar,
@@ -31,12 +33,13 @@ const VarList: FC<Props> = ({
const handleVarNameChange = useCallback((index: number) => {
return (e: React.ChangeEvent<HTMLInputElement>) => {
onVarNameChange?.(list[index].variable, e.target.value)
const newList = produce(list, (draft) => {
draft[index].variable = e.target.value
})
onChange(newList)
}
}, [list, onChange])
}, [list, onVarNameChange, onChange])
const handleVarReferenceChange = useCallback((index: number) => {
return (value: ValueSelector | string, varKindType: VarKindType) => {