From 24b5a31942eaff813c4c037203caed4fae68033d Mon Sep 17 00:00:00 2001 From: Argo-AscioTech Date: Mon, 8 Jan 2024 16:10:03 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20InputNumber=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20oninput=20=E4=BA=8B=E4=BB=B6?= 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 | 8 ------- .../Input/BootstrapInputEventBase.cs | 22 +++++++++++++++++++ .../InputNumber/BootstrapInputNumber.razor | 4 ++-- .../InputNumber/BootstrapInputNumberBase.cs | 2 +- .../Components/Slider/Slider.razor | 2 +- .../Components/Slider/Slider.razor.cs | 8 ------- 7 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 src/BootstrapBlazor/Components/Input/BootstrapInputEventBase.cs diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInput.razor b/src/BootstrapBlazor/Components/Input/BootstrapInput.razor index 8fd048f2946..7b9c38f900a 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInput.razor +++ b/src/BootstrapBlazor/Components/Input/BootstrapInput.razor @@ -1,6 +1,6 @@ @namespace BootstrapBlazor.Components @typeparam TValue -@inherits BootstrapInputBase +@inherits BootstrapInputEventBase @if (IsShowLabel) { diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs b/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs index 7c5ce7eed5d..4f2e66b5f83 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs +++ b/src/BootstrapBlazor/Components/Input/BootstrapInput.razor.cs @@ -16,12 +16,4 @@ public partial class BootstrapInput public bool Readonly { get; set; } private string? ReadonlyString => Readonly ? "true" : null; - - /// - /// 获得/设置 是否在文本框输入值时触发 bind-value:event="oninput" 默认 false - /// - [Parameter] - public bool UseInputEvent { get; set; } = false; - - private string EventString => UseInputEvent ? "oninput" : "onchange"; } diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputEventBase.cs b/src/BootstrapBlazor/Components/Input/BootstrapInputEventBase.cs new file mode 100644 index 00000000000..d8451717c6d --- /dev/null +++ b/src/BootstrapBlazor/Components/Input/BootstrapInputEventBase.cs @@ -0,0 +1,22 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Website: https://www.blazor.zone or https://argozhang.github.io/ + +namespace BootstrapBlazor.Components; + +/// +/// 输入框基类 +/// +public abstract class BootstrapInputEventBase : BootstrapInputBase +{ + /// + /// 获得/设置 是否在文本框输入值时触发 bind-value:event="oninput" 默认 false + /// + [Parameter] + public bool UseInputEvent { get; set; } + + /// + /// event 字符串 + /// + protected string EventString => UseInputEvent ? "oninput" : "onchange"; +} diff --git a/src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumber.razor b/src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumber.razor index f6ffd80e85b..21c8ab4c573 100644 --- a/src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumber.razor +++ b/src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumber.razor @@ -12,7 +12,7 @@ - + @@ -20,5 +20,5 @@ } else { - + } diff --git a/src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumberBase.cs b/src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumberBase.cs index 1b7e5b5a23a..c63fe7cc1b9 100644 --- a/src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumberBase.cs +++ b/src/BootstrapBlazor/Components/InputNumber/BootstrapInputNumberBase.cs @@ -7,7 +7,7 @@ namespace BootstrapBlazor.Components; /// /// BootstrapInputNumber 基类 /// -public class BootstrapInputNumberBase : BootstrapInputBase +public class BootstrapInputNumberBase : BootstrapInputEventBase { /// /// SetParametersAsync 方法 diff --git a/src/BootstrapBlazor/Components/Slider/Slider.razor b/src/BootstrapBlazor/Components/Slider/Slider.razor index c30dd6ea4bf..4f1a5bc2ec2 100644 --- a/src/BootstrapBlazor/Components/Slider/Slider.razor +++ b/src/BootstrapBlazor/Components/Slider/Slider.razor @@ -20,5 +20,5 @@ else @code { RenderFragment RenderRange => - @; + @; } diff --git a/src/BootstrapBlazor/Components/Slider/Slider.razor.cs b/src/BootstrapBlazor/Components/Slider/Slider.razor.cs index 5c6a9f20774..4f0c6f65634 100644 --- a/src/BootstrapBlazor/Components/Slider/Slider.razor.cs +++ b/src/BootstrapBlazor/Components/Slider/Slider.razor.cs @@ -16,12 +16,6 @@ public partial class Slider .AddClassFromAttributes(AdditionalAttributes) .Build(); - /// - /// 获得/设置 是否使用 input 事件 默认为 false - /// - [Parameter] - public bool UseInputEvent { get; set; } - /// /// 获得/设置 最小值 默认为 null 未设置 /// @@ -43,8 +37,6 @@ public partial class Slider [NotNull] public TValue? Step { get; set; } - private string eventName => UseInputEvent ? "oninput" : "onchange"; - private string? MinString => Min.ToString() == "0" ? GetRangeMinString : Min.ToString(); private string? GetRangeMinString => _range?.Minimum.ToString(); From 712d902f4c3100669e0292e0bc4cabc82fbc226a Mon Sep 17 00:00:00 2001 From: Argo-AscioTech Date: Mon, 8 Jan 2024 16:11:38 +0800 Subject: [PATCH 2/2] chore: bump version 8.1.6-beta01 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index d91e5121f4d..b937e44ea4b 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 8.1.5 + 8.1.6-beta01