Skip to content

Commit 9ee878e

Browse files
committed
refactor: 移动到 Auto 组件中
1 parent 911c5da commit 9ee878e

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ public partial class AutoComplete
6868
[Parameter]
6969
public bool ShowNoDataTip { get; set; } = true;
7070

71+
/// <summary>
72+
/// Gets or sets whether the select component is clearable. Default is false.
73+
/// </summary>
74+
[Parameter]
75+
public bool IsClearable { get; set; }
76+
77+
/// <summary>
78+
/// Gets or sets the right-side clear icon. Default is fa-solid fa-angle-up.
79+
/// </summary>
80+
[Parameter]
81+
[NotNull]
82+
public string? ClearIcon { get; set; }
83+
7184
/// <summary>
7285
/// IStringLocalizer service instance
7386
/// </summary>
@@ -89,6 +102,15 @@ public partial class AutoComplete
89102
.AddClass("is-clearable", IsClearable)
90103
.Build();
91104

105+
/// <summary>
106+
/// Gets the clear icon class string.
107+
/// </summary>
108+
protected string? ClearClassString => CssBuilder.Default("clear-icon")
109+
.AddClass($"text-{Color.ToDescriptionString()}", Color != Color.None)
110+
.AddClass($"text-success", IsValid.HasValue && IsValid.Value)
111+
.AddClass($"text-danger", IsValid.HasValue && !IsValid.Value)
112+
.Build();
113+
92114
/// <summary>
93115
/// <inheritdoc/>
94116
/// </summary>
@@ -130,6 +152,12 @@ protected override void OnParametersSet()
130152
/// <returns></returns>
131153
protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, Value);
132154

155+
/// <summary>
156+
/// Gets whether show the clear button.
157+
/// </summary>
158+
/// <returns></returns>
159+
private bool GetClearable() => IsClearable && !IsDisabled;
160+
133161
/// <summary>
134162
/// Callback method when a candidate item is clicked
135163
/// </summary>

src/BootstrapBlazor/Components/AutoComplete/PopoverCompleteBase.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,6 @@ public abstract class PopoverCompleteBase<TValue> : BootstrapInputBase<TValue>,
4949
[Parameter]
5050
public bool IsPopover { get; set; }
5151

52-
/// <summary>
53-
/// Gets or sets whether the select component is clearable. Default is false.
54-
/// </summary>
55-
[Parameter]
56-
public bool IsClearable { get; set; }
57-
58-
/// <summary>
59-
/// Gets or sets the right-side clear icon. Default is fa-solid fa-angle-up.
60-
/// </summary>
61-
[Parameter]
62-
[NotNull]
63-
public string? ClearIcon { get; set; }
64-
6552
/// <summary>
6653
/// <inheritdoc/>
6754
/// </summary>
@@ -161,21 +148,6 @@ public abstract class PopoverCompleteBase<TValue> : BootstrapInputBase<TValue>,
161148
.AddClass("shadow", ShowShadow)
162149
.Build();
163150

164-
/// <summary>
165-
/// Gets whether show the clear button.
166-
/// </summary>
167-
/// <returns></returns>
168-
protected bool GetClearable() => IsClearable && !IsDisabled;
169-
170-
/// <summary>
171-
/// Gets the clear icon class string.
172-
/// </summary>
173-
protected string? ClearClassString => CssBuilder.Default("clear-icon")
174-
.AddClass($"text-{Color.ToDescriptionString()}", Color != Color.None)
175-
.AddClass($"text-success", IsValid.HasValue && IsValid.Value)
176-
.AddClass($"text-danger", IsValid.HasValue && !IsValid.Value)
177-
.Build();
178-
179151
/// <summary>
180152
/// <inheritdoc/>
181153
/// </summary>

0 commit comments

Comments
 (0)