diff --git a/src/Connected.Components.Showcase.Runner/Pages/Index.razor b/src/Connected.Components.Showcase.Runner/Pages/Index.razor
index b6cc731..a24aa01 100644
--- a/src/Connected.Components.Showcase.Runner/Pages/Index.razor
+++ b/src/Connected.Components.Showcase.Runner/Pages/Index.razor
@@ -7,32 +7,47 @@
ValueText: @inputValueText
-
+
+ Label="String"
+ Required="true"
+ ErrorText="@errorText"
+ @bind-Value="@inputValueText">
-
-
+
+
@code {
diff --git a/src/Connected.Components/Components/InputNumber.razor b/src/Connected.Components/Components/InputNumber.razor
index ef5be8a..fa0a2b9 100644
--- a/src/Connected.Components/Components/InputNumber.razor
+++ b/src/Connected.Components/Components/InputNumber.razor
@@ -11,6 +11,7 @@
step="@_step"
disabled="@Disabled"
readonly="@Readonly"
+ @onmousewheel="@OnMouseWheel"
@oninput=@ChangeValueAsync
@attributes="@InputAttributes">
@@ -33,7 +34,8 @@
@if (Clearable && Value.ToString().Length > 0)
{
-
+
+
}
@if (IsError)
diff --git a/src/Connected.Components/Components/InputNumber.razor.cs b/src/Connected.Components/Components/InputNumber.razor.cs
index b1802f6..7ec19f2 100644
--- a/src/Connected.Components/Components/InputNumber.razor.cs
+++ b/src/Connected.Components/Components/InputNumber.razor.cs
@@ -1,13 +1,15 @@
using Connected.Models;
using Connected.Utilities;
using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Web;
using System.Numerics;
+using System.Runtime.CompilerServices;
using static Connected.Colors;
namespace Connected.Components;
public partial class InputNumber:InputBase where NumberType : INumber
{
- private double _step;
+ private double _step =1;
[Parameter]
public double Step {
get
@@ -16,8 +18,42 @@ public partial class InputNumber:InputBase where NumberType : INumbe
}
set
{
- _step = value;
- AdjustStep();
+ _step = CalculateStep(value);
+ }
+ }
+
+ [Parameter]
+ public bool DisableMouseWheel { get; set; } = false;
+
+ private async Task StepUp()
+ {
+ double num = (double)Convert.ChangeType(Value, typeof(double));
+ num += _step;
+ Value = (NumberType)Convert.ChangeType(num, typeof(NumberType));
+ await ValueChanged.InvokeAsync(Value);
+ }
+
+ private async Task StepDown()
+ {
+ double num = (double)Convert.ChangeType(Value, typeof(double));
+ num -= _step;
+ Value = (NumberType)Convert.ChangeType(num, typeof(NumberType));
+ await ValueChanged.InvokeAsync(Value);
+ }
+ protected async Task OnMouseWheel(WheelEventArgs obj)
+ {
+ if (DisableMouseWheel==false)
+ {
+ if (!obj.ShiftKey || Disabled || Readonly)
+ return;
+ if (obj.DeltaY < 0)
+ {
+ StepDown();
+ }
+ else
+ {
+ StepUp();
+ }
}
}
@@ -35,8 +71,7 @@ public partial class InputNumber:InputBase where NumberType : INumbe
{
if (args.Value is not null)
{
- NumberType originalValue = (NumberType)Convert.ChangeType(args.Value, typeof(NumberType));
- NumberType value = originalValue;
+ NumberType value = (NumberType)Convert.ChangeType(args.Value, typeof(NumberType));
if (value.ToString().Length > 0)
{
@@ -53,21 +88,22 @@ public partial class InputNumber:InputBase where NumberType : INumbe
}
}
- private void AdjustStep()
+ private double CalculateStep(double step)
{
+ double CalculatedStep = 1;
if (DecimalPlaces > 0)
{
- var StepDecmalPlaces = Helper.GetDecimalPlaces(_step);
- if (StepDecmalPlaces > DecimalPlaces)
+ var CurrentStepDecmalPlaces = Helper.GetDecimalPlaces(step);
+
+ if (CurrentStepDecmalPlaces > DecimalPlaces)
{
- double MinStep = 1;
for (int i = 0; i < DecimalPlaces; i++)
{
- MinStep = MinStep / 10;
+ CalculatedStep = CalculatedStep / 10;
}
- _step = MinStep;
}
}
+ return CalculatedStep;
}
private NumberType AdjustDecimalPlaces(NumberType value)
@@ -99,7 +135,6 @@ public partial class InputNumber:InputBase where NumberType : INumbe
Value = AdjustDecimalPlaces(Value);
await ValueChanged.InvokeAsync(Value);
}
- AdjustStep();
}
protected override async Task OnParametersSetAsync()
diff --git a/src/Connected.Components/Components/InputPassword.razor b/src/Connected.Components/Components/InputPassword.razor
deleted file mode 100644
index ff0c0de..0000000
--- a/src/Connected.Components/Components/InputPassword.razor
+++ /dev/null
@@ -1,44 +0,0 @@
-@using Connected.Models;
-
-@inherits InputBase;
-
-
\ No newline at end of file
diff --git a/src/Connected.Components/Components/InputPassword.razor.cs b/src/Connected.Components/Components/InputPassword.razor.cs
deleted file mode 100644
index ddb325f..0000000
--- a/src/Connected.Components/Components/InputPassword.razor.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using Connected.Models;
-using Microsoft.AspNetCore.Components;
-
-namespace Connected.Components;
-public partial class InputPassword: InputBase
-{
-
- [Parameter]
- public string Value { get; set; }
-
-
- [Parameter]
- public EventCallback ValueChanged { get; set; }
-
- private async Task ChangeValueAsync(ChangeEventArgs args)
- {
- await ValueChanged.InvokeAsync(args.Value.ToString());
- StateHasChanged();
- }
-
- private async Task Clear()
- {
- await ValueChanged.InvokeAsync(string.Empty);
- }
-
- protected override async Task OnInitializedAsync()
- {
- if (base.InputAttributes is null) base.InputAttributes = new();
- if (base.Required)
- {
- if (base.InputAttributes.ContainsKey("required")) base.InputAttributes.Add("required", true);
- }
- await base.OnInitializedAsync();
- }
-
-}
\ No newline at end of file
diff --git a/src/Connected.Components/Components/InputText.razor b/src/Connected.Components/Components/InputText.razor
index 9cbc275..360bfe5 100644
--- a/src/Connected.Components/Components/InputText.razor
+++ b/src/Connected.Components/Components/InputText.razor
@@ -5,13 +5,25 @@
@if (NumOfRows==1)
{
-
+ } else
+ {
+
+ }
} else
{