features/new
stm 2 years ago
parent 943579faec
commit 457df20346

@ -23,6 +23,7 @@
<InputText <InputText
Label="String" Label="String"
Required="true" Required="true"
ErrorText="@errorText"
@bind-Value="@inputValueText"> @bind-Value="@inputValueText">
</InputText> </InputText>
@ -48,4 +49,14 @@
counter++; counter++;
StateHasChanged(); StateHasChanged();
} }
string errorText
{
get
{
if (string.IsNullOrEmpty(inputValueText)) return string.Empty;
return "Error!!";
}
}
} }

@ -1,4 +1,6 @@
@inherits InputBase @using Connected.Models;
@inherits InputBase
@typeparam NumberType @typeparam NumberType
@ -28,7 +30,7 @@
} }
<span class="input-glyph-wraper"> <span class="input-glyph-wraper">
<span class="input-glyph"> <span class="input-glyph">
@if (Clearable) @if (Clearable && Value.ToString().Length > 0)
{ {
<span class="input-glyph button" @onclick="Clear"> <span class="input-glyph button" @onclick="Clear">
<i class='bx bx-x-circle'></i> <i class='bx bx-x-circle'></i>
@ -37,7 +39,8 @@
@if (IsError) @if (IsError)
{ {
<span class="input-glyph error"> <span class="input-glyph error">
<i class='bx bx-error-circle'></i> <Glyph SVG="@Icons.Material.Outlined.Error" Color="#D10000" />
<!--<i class='bx bx-error-circle'></i>-->
</span> </span>
} }
</span> </span>

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Components; using Connected.Models;
using Microsoft.AspNetCore.Components;
using System.Numerics; using System.Numerics;
namespace Connected.Components; namespace Connected.Components;
@ -22,6 +23,7 @@ public partial class InputNumber<NumberType>:InputBase where NumberType : INumbe
{ {
if (args.Value is not null) if (args.Value is not null)
{ {
if (args.Value.ToString().Length > 0) if (args.Value.ToString().Length > 0)
{ {
await ValueChanged.InvokeAsync((NumberType)Convert.ChangeType(args.Value, typeof(NumberType))); await ValueChanged.InvokeAsync((NumberType)Convert.ChangeType(args.Value, typeof(NumberType)));

@ -1,4 +1,6 @@
@inherits InputBase; @using Connected.Models;
@inherits InputBase;
<div class="@InputFieldClassList"> <div class="@InputFieldClassList">
<input type="password" <input type="password"
@ -25,7 +27,7 @@
} }
<span class="input-glyph-wraper"> <span class="input-glyph-wraper">
<span class="input-glyph"> <span class="input-glyph">
@if (Clearable) @if (Clearable && Value.ToString().Length > 0)
{ {
<span class="input-glyph button" @onclick="Clear"> <span class="input-glyph button" @onclick="Clear">
<i class='bx bx-x-circle'></i> <i class='bx bx-x-circle'></i>

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Components; using Connected.Models;
using Microsoft.AspNetCore.Components;
namespace Connected.Components; namespace Connected.Components;
public partial class InputPassword: InputBase public partial class InputPassword: InputBase

@ -1,4 +1,6 @@
@inherits InputBase; @using Connected.Models;
@inherits InputBase;
<div class="@InputFieldClassList"> <div class="@InputFieldClassList">
@if (NumOfRows==1) @if (NumOfRows==1)
@ -38,16 +40,18 @@
} }
<span class="input-glyph-wraper"> <span class="input-glyph-wraper">
<span class="input-glyph"> <span class="input-glyph">
@if (Clearable) @if (Clearable && Value.ToString().Length>0)
{ {
<span class="input-glyph button" @onclick="Clear"> <span class="input-glyph button" @onclick="Clear">
<i class='bx bx-x-circle'></i> <Glyph SVG="@Icons.Material.Rounded.Dangerous" />
<!--<i class='bx bx-x-circle'></i>-->
</span> </span>
} }
@if (IsError) @if (IsError)
{ {
<span class="input-glyph error"> <span class="input-glyph error">
<i class='bx bx-error-circle'></i> <Glyph SVG="@Icons.Material.Outlined.Error" Color="#D10000" />
<!--<i class='bx bx-error-circle'></i>-->
</span> </span>
} }
</span> </span>

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Components; using Connected.Models;
using Microsoft.AspNetCore.Components;
namespace Connected.Components; namespace Connected.Components;
public partial class InputText: InputBase public partial class InputText: InputBase
@ -34,16 +35,20 @@ public partial class InputText: InputBase
private async Task ChangeValueAsync(ChangeEventArgs args) private async Task ChangeValueAsync(ChangeEventArgs args)
{ {
if (string.IsNullOrEmpty(args.Value.ToString())) ErrorText = string.Empty;
await ValueChanged.InvokeAsync(args.Value.ToString()); await ValueChanged.InvokeAsync(args.Value.ToString());
StateHasChanged(); StateHasChanged();
} }
private async Task Clear() 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.InputAttributes is null) base.InputAttributes = new();
if (base.Required) if (base.Required)

@ -28,6 +28,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Interfaces\" />
<Folder Include="Services\" />
<Folder Include="wwwroot\" /> <Folder Include="wwwroot\" />
</ItemGroup> </ItemGroup>
<!--<Target Name="CompileStaticAssets" AfterTargets="AfterBuild"> <!--<Target Name="CompileStaticAssets" AfterTargets="AfterBuild">

@ -1,7 +1,7 @@
using Connected.Utilities; using Connected.Utilities;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace Connected.Components; namespace Connected.Models;
public class InputBase : ComponentBase public class InputBase : ComponentBase
{ {
[Parameter] [Parameter]
Loading…
Cancel
Save