1
1
import { ControlParams } from "comps/controls/controlParams" ;
2
+ import { EditorContext } from "comps/editorState" ;
2
3
import { CompAction , SimpleComp } from "lowcoder-core" ;
3
4
import { ControlPropertyViewWrapper , PopupCard , Input } from "lowcoder-design" ;
4
- import { useEffect , useState } from "react" ;
5
+ import { useContext , useEffect , useState } from "react" ;
5
6
import { trans } from "i18n" ;
6
- import { checkName } from "../utils/rename" ;
7
7
const SimpleVariableHeaderPropertyView = ( { params, comp, isCheck} :any ) => {
8
8
const [ error , setError ] = useState < string | undefined > ( ) ;
9
9
const [ value , setValue ] = useState ( comp . value ) ;
10
+ const editorState = useContext ( EditorContext ) ;
10
11
useEffect ( ( ) => {
11
12
setValue ( comp . value ) ;
12
13
isCheck && setError ( undefined ) ;
@@ -17,7 +18,7 @@ const SimpleVariableHeaderPropertyView = ({params, comp, isCheck}: any) => {
17
18
value = { value }
18
19
placeholder = { params . placeholder }
19
20
onChange = { ( e ) => {
20
- const error = isCheck && checkName ( e . target . value ) ;
21
+ const error = isCheck && editorState . checkRename ( value , e . target . value ) ;
21
22
isCheck && setError ( error || undefined ) ;
22
23
setValue ( e . target . value ) ;
23
24
} }