Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitffbe25a

Browse files
committed
apply name checking to control
1 parent8a0884e commitffbe25a

File tree

1 file changed

+66
-4
lines changed

1 file changed

+66
-4
lines changed
Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,56 @@
1-
import{CompAction}from"lowcoder-core";
2-
importSimpleStringControlfrom"../controls/simpleStringControl";
3-
4-
exportclassSimpleVariableHeaderCompextendsSimpleStringControl{
1+
import{CompAction,SimpleComp}from"lowcoder-core";
2+
import{ControlParams,ControlPropertyViewWrapper,EditorContext,EditText,PopupCard}from"@lowcoder-ee/index.sdk";
3+
import{useEffect,useState}from"react";
4+
import{trans}from"@lowcoder-ee/i18n";
5+
import{Input}from"lowcoder-design/src/components/Input";
6+
import{checkName}from"../utils/rename";
7+
constSimpleVariableHeaderPropertyView=({params, comp}:any)=>{
8+
const[error,setError]=useState<string|undefined>("");
9+
const[value,setValue]=useState(comp.value);
10+
useEffect(()=>{
11+
setValue(comp.value);
12+
setError(undefined);
13+
},[comp]);
14+
return(
15+
<ControlPropertyViewWrapper{...params}>
16+
<Input
17+
value={value}
18+
placeholder={params.placeholder}
19+
onChange={(e)=>{
20+
consterror=checkName(e.target.value);
21+
setError(error||undefined);
22+
setValue(e.target.value);
23+
}}
24+
onBlur={(e)=>{
25+
if(!error)comp.dispatchChangeValueAction(value);
26+
else{
27+
setValue(comp.value);
28+
setError(undefined);
29+
}
30+
}}
31+
/>
32+
{/* <EditText
33+
// disabled={readOnly}
34+
text={comp.value}
35+
onFinish={(value) => {
36+
if (editorState.rename(comp.value, value)) {
37+
// editorState.setSelectedBottomRes(value, type);
38+
setError("");
39+
}
40+
}}
41+
onChange={(value) => setError(editorState.checkRename(comp.value, value))}
42+
style={{ maxWidth: '100%', width: '100%' }}
43+
/> */}
44+
<PopupCard
45+
editorFocus={!!error}
46+
title={error ?trans("error") :""}
47+
content={error}
48+
hasError={!!error}
49+
/>
50+
</ControlPropertyViewWrapper>
51+
);
52+
}
53+
exportclassSimpleVariableHeaderCompextendsSimpleComp<string>{
554
overridereduce(action:CompAction): this{
655
// if (isBroadcastAction<RenameAction>(action, CompActionTypes.RENAME)) {
756
// if (this.getView() === action.action.oldName) {
@@ -10,4 +59,17 @@ export class SimpleVariableHeaderComp extends SimpleStringControl {
1059
// }
1160
returnsuper.reduce(action);
1261
}
62+
63+
readonlyIGNORABLE_DEFAULT_VALUE="";
64+
protectedgetDefaultValue():string{
65+
return"";
66+
}
67+
68+
getPropertyView(){
69+
returnthis.propertyView({});
70+
}
71+
72+
propertyView(params:ControlParams){
73+
return<SimpleVariableHeaderPropertyViewparams={params}comp={this}></SimpleVariableHeaderPropertyView>
74+
}
1375
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp