Compare commits

..

No commits in common. "42d67dee07585c9e7c21f48bd41b8ff964467e3b" and "cac80598f0c734731375d2c69b129fb61107a451" have entirely different histories.

14 changed files with 43 additions and 168 deletions

View File

@ -6,21 +6,13 @@
<p>SelectedValue: @SelectedValue.ToString()</p> <p>SelectedValue: @SelectedValue.ToString()</p>
<RadioGroup Name="Group1"> <SimpleSelect
<Radio Id="radio1" Label="Group 1, Radio 1"></Radio> Items="@items"
<Radio Id="radio2" Label="Group 1, Radio 2"></Radio> Label="Simple select"
<Radio Id="radio3" Label="Group 1, Radio 3"></Radio> @bind-Value=@SelectedValue
<Radio Id="radio4" Label="Group 1, Radio 4"></Radio> />
<Radio Id="radio5" Label="Group 1, Radio 5" Disabled=true></Radio>
</RadioGroup>
<RadioGroup Name="Group2" Disabled=true>
<Radio Id="radio21" Label="Group 2, Radio 1"></Radio>
<Radio Id="radio22" Label="Group 2, Radio 2"></Radio>
<Radio Id="radio23" Label="Group 2, Radio 3"></Radio>
<Radio Id="radio24" Label="Group 2, Radio 4"></Radio>
<Radio Id="radio25" Label="Group 2, Radio 5"></Radio>
</RadioGroup>
@code { @code {
int SelectedValue; int SelectedValue;

View File

@ -1,13 +0,0 @@
@using Connected.Models;
@inherits InputBase;
<div class="checkbox-group">
@if (Checked)
{
<input id="@Id" name="checkbox" type="checkbox" @onchange="OnChange" @attributes=@InputAttributes checked>
} else {
<input id="@Id" name="checkbox" type="checkbox" @onchange="OnChange" @attributes=@InputAttributes>
}
<label for="@Id" class="checkbox-label">@Label</label>
</div>

View File

@ -1,21 +0,0 @@
using Connected.Models;
using Microsoft.AspNetCore.Components;
namespace Connected.Components;
public partial class CheckBox: InputBase
{
[Parameter]
public bool Checked { get; set; } = false;
[Parameter, EditorRequired]
public string Id { get; set; }
[Parameter]
public EventCallback<bool> CheckedChange { get; set; }
public async Task OnChange(ChangeEventArgs args)
{
Checked = (bool)args.Value;
CheckedChange.InvokeAsync(Checked);
}
}

View File

@ -1,9 +0,0 @@
@using Connected.Models;
@inherits InputBase;
<div>
<div class="container">
@ChildContent
</div>
</div>

View File

@ -1,11 +0,0 @@
using Microsoft.AspNetCore.Components;
namespace Connected.Components;
public partial class CheckBoxGroup
{
[Parameter, EditorRequired]
public string Id { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
}

View File

@ -228,14 +228,5 @@ public partial class NumberInput<NumberType>:InputBase where NumberType : INumbe
await base.OnParametersSetAsync(); await base.OnParametersSetAsync();
} }
protected override async Task OnInitializedAsync() #endregion
{
await base.OnInitializedAsync();
if (Required)
{
if (!InputAttributes.ContainsKey("required")) InputAttributes.Add("required", true);
}
}
#endregion
} }

View File

@ -1,8 +0,0 @@
@using Connected.Models;
@inherits InputBase;
<div class="radio-group">
<input id="@Id" name="@ParentRadioGroup.Name" type="radio" @onchange="OnChange" @attributes=@InputAttributes>
<label for="@Id" class="radio-label">@Label</label>
</div>

View File

@ -1,31 +0,0 @@
using Connected.Models;
using Microsoft.AspNetCore.Components;
namespace Connected.Components;
public partial class Radio: InputBase
{
[CascadingParameter]
public RadioGroup? ParentRadioGroup { get; set; }
[Parameter]
public bool Checked { get; set; } = false;
[Parameter, EditorRequired]
public string Id { get; set; }
[Parameter]
public EventCallback<bool> CheckedChange { get; set; }
public async Task OnChange(ChangeEventArgs args)
{
Checked = (bool)args.Value;
CheckedChange.InvokeAsync(Checked);
}
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if (ParentRadioGroup.Disabled) Disabled = true;
if (!InputAttributes.ContainsKey("disabled"))
InputAttributes.Add("disabled", Disabled);
}
}

View File

@ -1,15 +0,0 @@
@using Connected.Models;
@inherits InputBase;
<CascadingValue Value="this">
<div>
@if (!string.IsNullOrEmpty(Name))
{
<h5>@Name</h5>
}
<div class="container">
@ChildContent
</div>
</div>
</CascadingValue>

View File

@ -1,12 +0,0 @@
using Microsoft.AspNetCore.Components;
namespace Connected.Components;
public partial class RadioGroup
{
[Parameter, EditorRequired]
public string Name { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
}

View File

@ -7,6 +7,7 @@
@if (Items is not null) @if (Items is not null)
{ {
<div class="@InputFieldClassList"> <div class="@InputFieldClassList">
<select type="textarea" style="height:0px;" @attributes=@InputAttributes> <select type="textarea" style="height:0px;" @attributes=@InputAttributes>
</select> </select>
@if (IsLabel) @if (IsLabel)
@ -41,7 +42,8 @@
<input type="text" <input type="text"
placeholder="Enter search string..." placeholder="Enter search string..."
class="dropdown-item" class="dropdown-item"
@bind-value="@SearchText" /> @bind-value="@SearchText"
/>
} }
@foreach (ValueType item in Items) @foreach (ValueType item in Items)
{ {

View File

@ -29,13 +29,30 @@ public partial class SimpleSelect<ValueType> : InputBase
} }
} }
private string DropDownClass { get; set; } = "drop-down";
bool DropDownClicked = false;
public void DropDownClassToggle()
{
DropDownClicked = !DropDownClicked;
if (DropDownClicked)
{
DropDownClass = "";
} else
{
DropDownClass = "drop-down";
}
StateHasChanged();
}
private async Task SetSelectedItem(ValueType item) private async Task SetSelectedItem(ValueType item)
{ {
//DropDownClassToggle(); //DropDownClassToggle();
await ValueChanged.InvokeAsync(item); await ValueChanged.InvokeAsync(item);
} }
private void FilterItems() private async Task FilterItems()
{ {
if (string.IsNullOrEmpty(_searchText)) if (string.IsNullOrEmpty(_searchText))
{ {
@ -59,18 +76,13 @@ public partial class SimpleSelect<ValueType> : InputBase
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
if (base.InputAttributes is null) base.InputAttributes = new();
OriginalItems = Items; if (base.Required)
if (_searchText.Length>0) FilterItems();
await base.OnParametersSetAsync();
}
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if (Required)
{ {
if (InputAttributes.ContainsKey("required")) InputAttributes.Add("required", true); if (base.InputAttributes.ContainsKey("required")) base.InputAttributes.Add("required", true);
} }
OriginalItems = Items;
if (_searchText.Length>0) await FilterItems();
await base.OnInitializedAsync();
} }
} }

View File

@ -56,13 +56,14 @@ public partial class TextInput: InputBase
} }
protected override async Task OnInitializedAsync() protected override async Task OnParametersSetAsync()
{ {
await base.OnInitializedAsync(); if (base.InputAttributes is null) base.InputAttributes = new();
if (Required) if (base.Required)
{ {
if (!InputAttributes.ContainsKey("required")) InputAttributes.Add("required", true); if (base.InputAttributes.ContainsKey("required")) base.InputAttributes.Add("required", true);
} }
} await base.OnInitializedAsync();
}
} }

View File

@ -1,5 +1,7 @@
using Connected.Utilities; using Connected.Utilities;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using static Connected.Colors;
using static System.Net.Mime.MediaTypeNames;
namespace Connected.Models; namespace Connected.Models;
public class InputBase : ComponentBase public class InputBase : ComponentBase
@ -122,9 +124,4 @@ public class InputBase : ComponentBase
[Parameter] [Parameter]
public string Placeholder { get; set; } = string.Empty; public string Placeholder { get; set; } = string.Empty;
protected override async Task OnInitializedAsync()
{
if (InputAttributes is null) InputAttributes = new();
}
} }