Skip to content

Commit 7997535

Browse files
committed
refactor: 移动参数方法到基类中
1 parent 8fe9940 commit 7997535

File tree

2 files changed

+83
-83
lines changed

2 files changed

+83
-83
lines changed

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

Lines changed: 1 addition & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -26,61 +26,12 @@ public partial class AutoComplete
2626
[NotNull]
2727
public IEnumerable<string>? Items { get; set; }
2828

29-
/// <summary>
30-
/// 获得/设置 匹配数据时显示的数量
31-
/// </summary>
32-
[Parameter]
33-
[NotNull]
34-
public int? DisplayCount { get; set; }
35-
36-
/// <summary>
37-
/// 获得/设置 是否开启模糊查询,默认为 false
38-
/// </summary>
39-
[Parameter]
40-
public bool IsLikeMatch { get; set; }
41-
42-
/// <summary>
43-
/// 获得/设置 匹配时是否忽略大小写,默认为 true
44-
/// </summary>
45-
[Parameter]
46-
public bool IgnoreCase { get; set; } = true;
47-
4829
/// <summary>
4930
/// 获得/设置 自定义集合过滤规则 默认 null
5031
/// </summary>
5132
[Parameter]
5233
public Func<string, Task<IEnumerable<string>>>? OnCustomFilter { get; set; }
5334

54-
/// <summary>
55-
/// 获得/设置 下拉菜单选择回调方法 默认 null
56-
/// </summary>
57-
[Parameter]
58-
public Func<string, Task>? OnSelectedItemChanged { get; set; }
59-
60-
/// <summary>
61-
/// 获得/设置 是否跳过 Enter 按键处理 默认 false
62-
/// </summary>
63-
[Parameter]
64-
public bool SkipEnter { get; set; }
65-
66-
/// <summary>
67-
/// 获得/设置 是否跳过 Esc 按键处理 默认 false
68-
/// </summary>
69-
[Parameter]
70-
public bool SkipEsc { get; set; }
71-
72-
/// <summary>
73-
/// 获得/设置 滚动行为 默认 <see cref="ScrollIntoViewBehavior.Smooth"/>
74-
/// </summary>
75-
[Parameter]
76-
public ScrollIntoViewBehavior ScrollIntoViewBehavior { get; set; } = ScrollIntoViewBehavior.Smooth;
77-
78-
/// <summary>
79-
/// 获得/设置 候选项模板 默认 null
80-
/// </summary>
81-
[Parameter]
82-
public RenderFragment<string>? ItemTemplate { get; set; }
83-
8435
/// <summary>
8536
/// 获得/设置 图标
8637
/// </summary>
@@ -100,27 +51,6 @@ public partial class AutoComplete
10051
[NotNull]
10152
private IStringLocalizer<AutoComplete>? Localizer { get; set; }
10253

103-
/// <summary>
104-
/// 获得/设置 UI 呈现数据集合
105-
/// </summary>
106-
[NotNull]
107-
protected List<string>? FilterItems { get; set; }
108-
109-
/// <summary>
110-
/// 获得 是否跳过 ESC 按键字符串
111-
/// </summary>
112-
protected string? SkipEscString => SkipEsc ? "true" : null;
113-
114-
/// <summary>
115-
/// 获得 是否跳过 Enter 按键字符串
116-
/// </summary>
117-
protected string? SkipEnterString => SkipEnter ? "true" : null;
118-
119-
/// <summary>
120-
/// 获得 滚动行为字符串
121-
/// </summary>
122-
protected string? ScrollIntoViewBehaviorString => ScrollIntoViewBehavior == ScrollIntoViewBehavior.Smooth ? null : ScrollIntoViewBehavior.ToDescriptionString();
123-
12454
/// <summary>
12555
/// <inheritdoc/>
12656
/// </summary>
@@ -138,26 +68,14 @@ protected override void OnParametersSet()
13868
{
13969
base.OnParametersSet();
14070

71+
LoadingIcon ??= IconTheme.GetIconByKey(ComponentIcons.LoadingIcon);
14172
NoDataTip ??= Localizer[nameof(NoDataTip)];
14273
PlaceHolder ??= Localizer[nameof(PlaceHolder)];
14374
Icon ??= IconTheme.GetIconByKey(ComponentIcons.AutoCompleteIcon);
144-
LoadingIcon ??= IconTheme.GetIconByKey(ComponentIcons.LoadingIcon);
14575

14676
FilterItems = Items?.ToList() ?? [];
14777
}
14878

149-
/// <summary>
150-
/// 鼠标点击候选项时回调此方法
151-
/// </summary>
152-
protected async Task OnClickItem(string val)
153-
{
154-
CurrentValue = val;
155-
if (OnSelectedItemChanged != null)
156-
{
157-
await OnSelectedItemChanged(val);
158-
}
159-
}
160-
16179
/// <summary>
16280
/// TriggerOnChange 方法
16381
/// </summary>

src/BootstrapBlazor/Components/AutoComplete/PopoverCompleteBase.cs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,76 @@ public abstract class PopoverCompleteBase<TValue> : BootstrapInputBase<TValue>,
7474
[Parameter]
7575
public int Debounce { get; set; }
7676

77+
/// <summary>
78+
/// 获得/设置 匹配数据时显示的数量
79+
/// </summary>
80+
[Parameter]
81+
[NotNull]
82+
public int? DisplayCount { get; set; }
83+
84+
/// <summary>
85+
/// 获得/设置 是否开启模糊查询,默认为 false
86+
/// </summary>
87+
[Parameter]
88+
public bool IsLikeMatch { get; set; }
89+
90+
/// <summary>
91+
/// 获得/设置 匹配时是否忽略大小写,默认为 true
92+
/// </summary>
93+
[Parameter]
94+
public bool IgnoreCase { get; set; } = true;
95+
96+
/// <summary>
97+
/// 获得/设置 下拉菜单选择回调方法 默认 null
98+
/// </summary>
99+
[Parameter]
100+
public Func<TValue, Task>? OnSelectedItemChanged { get; set; }
101+
102+
/// <summary>
103+
/// 获得/设置 是否跳过 Enter 按键处理 默认 false
104+
/// </summary>
105+
[Parameter]
106+
public bool SkipEnter { get; set; }
107+
108+
/// <summary>
109+
/// 获得/设置 是否跳过 Esc 按键处理 默认 false
110+
/// </summary>
111+
[Parameter]
112+
public bool SkipEsc { get; set; }
113+
114+
/// <summary>
115+
/// 获得/设置 滚动行为 默认 <see cref="ScrollIntoViewBehavior.Smooth"/>
116+
/// </summary>
117+
[Parameter]
118+
public ScrollIntoViewBehavior ScrollIntoViewBehavior { get; set; } = ScrollIntoViewBehavior.Smooth;
119+
120+
/// <summary>
121+
/// 获得/设置 候选项模板 默认 null
122+
/// </summary>
123+
[Parameter]
124+
public RenderFragment<string>? ItemTemplate { get; set; }
125+
126+
/// <summary>
127+
/// 获得/设置 UI 呈现数据集合
128+
/// </summary>
129+
[NotNull]
130+
protected List<string>? FilterItems { get; set; }
131+
132+
/// <summary>
133+
/// 获得 是否跳过 ESC 按键字符串
134+
/// </summary>
135+
protected string? SkipEscString => SkipEsc ? "true" : null;
136+
137+
/// <summary>
138+
/// 获得 是否跳过 Enter 按键字符串
139+
/// </summary>
140+
protected string? SkipEnterString => SkipEnter ? "true" : null;
141+
142+
/// <summary>
143+
/// 获得 滚动行为字符串
144+
/// </summary>
145+
protected string? ScrollIntoViewBehaviorString => ScrollIntoViewBehavior == ScrollIntoViewBehavior.Smooth ? null : ScrollIntoViewBehavior.ToDescriptionString();
146+
77147
/// <summary>
78148
/// 防抖时长字符串
79149
/// </summary>
@@ -141,6 +211,18 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
141211
}
142212
}
143213

214+
/// <summary>
215+
/// 鼠标点击候选项时回调此方法
216+
/// </summary>
217+
protected async Task OnClickItem(TValue val)
218+
{
219+
CurrentValue = val;
220+
if (OnSelectedItemChanged != null)
221+
{
222+
await OnSelectedItemChanged(val);
223+
}
224+
}
225+
144226
/// <summary>
145227
/// <inheritdoc/>
146228
/// </summary>

0 commit comments

Comments
 (0)