From 018faeb04a4c2c159f5bd65a5a25848ab883f826 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 14 Jan 2025 10:10:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Input/BootstrapInput.razor | 2 +- .../Components/Input/BootstrapInput.razor.cs | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInput.razor b/src/BootstrapBlazor/Components/Input/BootstrapInput.razor index 8b52c29b4fd..c3aae977f1b 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInput.razor +++ b/src/BootstrapBlazor/Components/Input/BootstrapInput.razor @@ -7,7 +7,7 @@ } -@if (Clearable) +@if (IsClearable) {
@RenderInput diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs b/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs index 9fd621de5e8..2efe1fc4fa5 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs +++ b/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs @@ -26,7 +26,14 @@ public partial class BootstrapInput /// 获得/设置 是否显示清空小按钮 默认 false /// [Parameter] - public bool Clearable { get; set; } + [Obsolete("已弃用,请使用 IsClearable 参数;Deprecated use the IsClearable parameter")] + public bool Clearable { get => IsClearable; set => IsClearable = value; } + + /// + /// 获得/设置 是否显示清空小按钮 默认 false + /// + [Parameter] + public bool IsClearable { get; set; } /// /// 获得/设置 清空文本框时回调方法 默认 null @@ -38,7 +45,14 @@ public partial class BootstrapInput /// 获得/设置 清空小按钮图标 默认 null /// [Parameter] - public string? ClearableIcon { get; set; } + [Obsolete("已弃用,请使用 ClearIcon 参数;Deprecated use the ClearIcon parameter")] + public string? ClearableIcon { get => ClearIcon; set => ClearIcon = value; } + + /// + /// 获得/设置 清空小按钮图标 默认 null + /// + [Parameter] + public string? ClearIcon { get; set; } /// /// 图标主题服务 @@ -50,7 +64,7 @@ public partial class BootstrapInput private string? ReadonlyString => Readonly ? "true" : null; private string? ClearableIconString => CssBuilder.Default("form-control-clear-icon") - .AddClass(ClearableIcon) + .AddClass(ClearIcon) .Build(); /// @@ -60,7 +74,7 @@ protected override void OnParametersSet() { base.OnParametersSet(); - ClearableIcon ??= IconTheme.GetIconByKey(ComponentIcons.InputClearIcon); + ClearIcon ??= IconTheme.GetIconByKey(ComponentIcons.InputClearIcon); } /// From 669e1c97fbb8b8966f4cc9132a44d1b6c6d88742 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 14 Jan 2025 10:10:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/Inputs.razor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/BootstrapBlazor.Server/Components/Samples/Inputs.razor b/src/BootstrapBlazor.Server/Components/Samples/Inputs.razor index 499511f1a7d..53d9edee2fb 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Inputs.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/Inputs.razor @@ -227,24 +227,24 @@ Name="OnInput">
- +
- +
- +
- +
From 489722760cc660f7420bacdc67b9ec24e39cda14 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 14 Jan 2025 10:11:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Input/BootstrapInput.razor.cs | 2 ++ test/UnitTest/Components/InputTest.cs | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs b/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs index 2efe1fc4fa5..b9153708ae6 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs +++ b/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs @@ -27,6 +27,7 @@ public partial class BootstrapInput ///
[Parameter] [Obsolete("已弃用,请使用 IsClearable 参数;Deprecated use the IsClearable parameter")] + [ExcludeFromCodeCoverage] public bool Clearable { get => IsClearable; set => IsClearable = value; } /// @@ -46,6 +47,7 @@ public partial class BootstrapInput /// [Parameter] [Obsolete("已弃用,请使用 ClearIcon 参数;Deprecated use the ClearIcon parameter")] + [ExcludeFromCodeCoverage] public string? ClearableIcon { get => ClearIcon; set => ClearIcon = value; } /// diff --git a/test/UnitTest/Components/InputTest.cs b/test/UnitTest/Components/InputTest.cs index 9169033e623..85a6ac5d9b7 100644 --- a/test/UnitTest/Components/InputTest.cs +++ b/test/UnitTest/Components/InputTest.cs @@ -72,10 +72,10 @@ public void Readonly_Ok() [Fact] public void Clearable_Ok() { - var cut = Context.RenderComponent>(builder => builder.Add(a => a.Clearable, false)); + var cut = Context.RenderComponent>(builder => builder.Add(a => a.IsClearable, false)); cut.DoesNotContain("bb-clearable-input"); - cut.SetParametersAndRender(pb => pb.Add(a => a.Clearable, true)); + cut.SetParametersAndRender(pb => pb.Add(a => a.IsClearable, true)); cut.Contains("bb-clearable-input"); cut.Contains("form-control-clear-icon"); @@ -93,7 +93,7 @@ public async Task OnClear_Ok() var clicked = false; var cut = Context.RenderComponent>(builder => { - builder.Add(a => a.Clearable, true); + builder.Add(a => a.IsClearable, true); builder.Add(a => a.OnClear, v => { clicked = true;