diff --git a/src/Connected.Components.Showcase.Runner/Pages/Index.razor b/src/Connected.Components.Showcase.Runner/Pages/Index.razor index 9238ca6..18d6d98 100644 --- a/src/Connected.Components.Showcase.Runner/Pages/Index.razor +++ b/src/Connected.Components.Showcase.Runner/Pages/Index.razor @@ -23,6 +23,7 @@ @@ -48,4 +49,14 @@ counter++; StateHasChanged(); } + + string errorText + { + get + { + if (string.IsNullOrEmpty(inputValueText)) return string.Empty; + return "Error!!"; + } + } + } \ No newline at end of file diff --git a/src/Connected.Components/Components/InputNumber.razor b/src/Connected.Components/Components/InputNumber.razor index 92ce583..03a27c4 100644 --- a/src/Connected.Components/Components/InputNumber.razor +++ b/src/Connected.Components/Components/InputNumber.razor @@ -1,4 +1,6 @@ -@inherits InputBase +@using Connected.Models; + +@inherits InputBase @typeparam NumberType @@ -28,7 +30,7 @@ } - @if (Clearable) + @if (Clearable && Value.ToString().Length > 0) { @@ -37,7 +39,8 @@ @if (IsError) { - + + } diff --git a/src/Connected.Components/Components/InputNumber.razor.cs b/src/Connected.Components/Components/InputNumber.razor.cs index bf692c8..f807784 100644 --- a/src/Connected.Components/Components/InputNumber.razor.cs +++ b/src/Connected.Components/Components/InputNumber.razor.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Components; +using Connected.Models; +using Microsoft.AspNetCore.Components; using System.Numerics; namespace Connected.Components; @@ -22,6 +23,7 @@ public partial class InputNumber:InputBase where NumberType : INumbe { if (args.Value is not null) { + if (args.Value.ToString().Length > 0) { await ValueChanged.InvokeAsync((NumberType)Convert.ChangeType(args.Value, typeof(NumberType))); diff --git a/src/Connected.Components/Components/InputPassword.razor b/src/Connected.Components/Components/InputPassword.razor index 7553737..ff0c0de 100644 --- a/src/Connected.Components/Components/InputPassword.razor +++ b/src/Connected.Components/Components/InputPassword.razor @@ -1,4 +1,6 @@ -@inherits InputBase; +@using Connected.Models; + +@inherits InputBase;
- @if (Clearable) + @if (Clearable && Value.ToString().Length > 0) { diff --git a/src/Connected.Components/Components/InputPassword.razor.cs b/src/Connected.Components/Components/InputPassword.razor.cs index 8d0f3c2..ddb325f 100644 --- a/src/Connected.Components/Components/InputPassword.razor.cs +++ b/src/Connected.Components/Components/InputPassword.razor.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Components; +using Connected.Models; +using Microsoft.AspNetCore.Components; namespace Connected.Components; public partial class InputPassword: InputBase diff --git a/src/Connected.Components/Components/InputText.razor b/src/Connected.Components/Components/InputText.razor index efc8fd6..9cbc275 100644 --- a/src/Connected.Components/Components/InputText.razor +++ b/src/Connected.Components/Components/InputText.razor @@ -1,4 +1,6 @@ -@inherits InputBase; +@using Connected.Models; + +@inherits InputBase;
@if (NumOfRows==1) @@ -38,16 +40,18 @@ } - @if (Clearable) + @if (Clearable && Value.ToString().Length>0) { - + + } @if (IsError) { - + + } diff --git a/src/Connected.Components/Components/InputText.razor.cs b/src/Connected.Components/Components/InputText.razor.cs index 76bbc58..08ef495 100644 --- a/src/Connected.Components/Components/InputText.razor.cs +++ b/src/Connected.Components/Components/InputText.razor.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Components; +using Connected.Models; +using Microsoft.AspNetCore.Components; namespace Connected.Components; public partial class InputText: InputBase @@ -6,7 +7,7 @@ public partial class InputText: InputBase [Parameter] public int NumOfRows { - get + get { return _numberOfLines; } @@ -34,16 +35,20 @@ public partial class InputText: InputBase private async Task ChangeValueAsync(ChangeEventArgs args) { + if (string.IsNullOrEmpty(args.Value.ToString())) ErrorText = string.Empty; await ValueChanged.InvokeAsync(args.Value.ToString()); - StateHasChanged(); + StateHasChanged(); } private async Task Clear() { - await ValueChanged.InvokeAsync(string.Empty); + ChangeEventArgs arg = new ChangeEventArgs(); + arg.Value = string.Empty; + await ChangeValueAsync(arg); + } - protected override async Task OnInitializedAsync() + protected override async Task OnParametersSetAsync() { if (base.InputAttributes is null) base.InputAttributes = new(); if (base.Required) diff --git a/src/Connected.Components/Connected.Components.csproj b/src/Connected.Components/Connected.Components.csproj index 91d8e97..901a933 100644 --- a/src/Connected.Components/Connected.Components.csproj +++ b/src/Connected.Components/Connected.Components.csproj @@ -28,6 +28,8 @@ + +