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

Commit1798dbd

Browse files
expose selected option with autocomplete comp
1 parent51b9205 commit1798dbd

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

‎client/packages/lowcoder/src/comps/comps/autoCompleteComp/autoCompleteComp.tsx‎

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { default as AutoComplete } from "antd/es/auto-complete";
4343
import{RefControl}from"comps/controls/refControl";
4444
import{
4545
booleanExposingStateControl,
46+
jsonValueExposingStateControl,
4647
}from"comps/controls/codeStateControl";
4748

4849
import{getDayJSLocale}from"i18n/dayjsLocale";
@@ -88,6 +89,7 @@ const childrenMap = {
8889
autocompleteIconColor:dropdownControl(autocompleteIconColor,"blue"),
8990
componentSize:dropdownControl(componentSize,"small"),
9091
valueInItems:booleanExposingStateControl("valueInItems"),
92+
selectedOption:jsonValueExposingStateControl("selectedOption",{}),
9193
style:styleControl(InputFieldStyle,'style'),
9294
labelStyle:styleControl(LabelStyle,'labelStyle'),
9395
inputFieldStyle:styleControl(InputLikeStyle,'inputFieldStyle'),
@@ -247,14 +249,18 @@ let AutoCompleteCompBase = (function () {
247249
setsearchtext(value);
248250
props.value.onChange(value);
249251
props.onEvent("change");
250-
},[props.valueInItems,getTextInputValidate,props.value,props.onEvent]);
252+
if(!Boolean(value)){
253+
props.selectedOption.onChange({});
254+
}
255+
},[props.valueInItems,getTextInputValidate,props.value,props.onEvent,props.selectedOption]);
251256

252257
consthandleSelect=useCallback((data:string,option:any)=>{
253258
setsearchtext(option[valueOrLabel]);
254259
props.valueInItems.onChange(true);
255260
props.value.onChange(option[valueOrLabel]);
261+
props.selectedOption.onChange(option);
256262
props.onEvent("submit");
257-
},[valueOrLabel,props.valueInItems,props.value,props.onEvent]);
263+
},[valueOrLabel,props.valueInItems,props.value,props.onEvent,props.selectedOption]);
258264

259265
consthandleFocus=useCallback(()=>{
260266
setActivationFlag(true);
@@ -313,17 +319,7 @@ let AutoCompleteCompBase = (function () {
313319
.setPropertyViewFn((children)=>{
314320
return(
315321
<>
316-
<Section>
317-
{children.autoCompleteType.getView()==='normal'&&
318-
children.prefixIcon.propertyView({
319-
label:trans('button.prefixIcon'),
320-
})}
321-
{children.autoCompleteType.getView()==='normal'&&
322-
children.suffixIcon.propertyView({
323-
label:trans('button.suffixIcon'),
324-
})}
325-
{allowClearPropertyView(children)}
326-
</Section>
322+
<TextInputBasicSection{...children}/>
327323
<Sectionname={trans('autoComplete.SectionDataName')}>
328324
{children.items.propertyView({
329325
label:trans('autoComplete.value'),
@@ -351,25 +347,35 @@ let AutoCompleteCompBase = (function () {
351347
label:trans('autoComplete.ignoreCase'),
352348
})
353349
)}
354-
{children.filterOptionsByInput.getView()&&(
355-
children.valueOrLabel.propertyView({
356-
label:trans('autoComplete.checkedValueFrom'),
357-
radioButton:true,
358-
})
359-
)}
350+
{children.valueOrLabel.propertyView({
351+
label:trans('autoComplete.checkedValueFrom'),
352+
radioButton:true,
353+
})}
360354
</Section>
361-
<TextInputBasicSection{...children}/>
362355

363356
<FormDataPropertyView{...children}/>
364357
{children.label.getPropertyView()}
365358

366359
<TextInputInteractionSection{...children}/>
367360

368-
{<TextInputValidationSection{...children}/>}
369361

370362
<Sectionname={sectionNames.layout}>
371363
{hiddenPropertyView(children)}
372364
</Section>
365+
366+
<Sectionname={sectionNames.advanced}>
367+
{children.autoCompleteType.getView()==='normal'&&
368+
children.prefixIcon.propertyView({
369+
label:trans('button.prefixIcon'),
370+
})}
371+
{children.autoCompleteType.getView()==='normal'&&
372+
children.suffixIcon.propertyView({
373+
label:trans('button.suffixIcon'),
374+
})}
375+
{allowClearPropertyView(children)}
376+
</Section>
377+
378+
{<TextInputValidationSection{...children}/>}
373379

374380
<Sectionname={sectionNames.style}>
375381
{children.style.getPropertyView()}
@@ -389,9 +395,6 @@ let AutoCompleteCompBase = (function () {
389395
>
390396
{children.animationStyle.getPropertyView()}
391397
</Section>
392-
<Sectionname={sectionNames.advanced}>
393-
{children.tabIndex.propertyView({label:trans("prop.tabIndex")})}
394-
</Section>
395398
</>
396399
);
397400
})
@@ -415,6 +418,7 @@ AutoCompleteCompBase = class extends AutoCompleteCompBase {
415418
exportconstAutoCompleteComp=withExposingConfigs(AutoCompleteCompBase,[
416419
newNameConfig("value",trans("export.inputValueDesc")),
417420
newNameConfig("valueInItems",trans("autoComplete.valueInItems")),
421+
newNameConfig("selectedOption",trans("autoComplete.selectedOption")),
418422
NameConfigPlaceHolder,
419423
NameConfigRequired,
420424
...TextInputConfigs,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp