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);
+ }
+}
diff --git a/src/Connected.Components/Components/RadioGroup.razor b/src/Connected.Components/Components/RadioGroup.razor
new file mode 100644
index 0000000..b842c61
--- /dev/null
+++ b/src/Connected.Components/Components/RadioGroup.razor
@@ -0,0 +1,15 @@
+@using Connected.Models;
+
+@inherits InputBase;
+
+
+
+ @if (!string.IsNullOrEmpty(Name))
+ {
+
@Name
+ }
+
+ @ChildContent
+
+
+
\ No newline at end of file
diff --git a/src/Connected.Components/Components/RadioGroup.razor.cs b/src/Connected.Components/Components/RadioGroup.razor.cs
new file mode 100644
index 0000000..7b07360
--- /dev/null
+++ b/src/Connected.Components/Components/RadioGroup.razor.cs
@@ -0,0 +1,12 @@
+using Microsoft.AspNetCore.Components;
+
+namespace Connected.Components;
+public partial class RadioGroup
+{
+ [Parameter, EditorRequired]
+ public string Name { get; set; }
+
+ [Parameter]
+ public RenderFragment ChildContent { get; set; }
+
+}
diff --git a/src/Connected.Components/Components/SimpleSelect.razor b/src/Connected.Components/Components/SimpleSelect.razor
index ec9c163..8fb0f45 100644
--- a/src/Connected.Components/Components/SimpleSelect.razor
+++ b/src/Connected.Components/Components/SimpleSelect.razor
@@ -7,7 +7,6 @@
@if (Items is not null)
{
-
@if (IsLabel)
@@ -42,8 +41,7 @@
+ @bind-value="@SearchText" />
}
@foreach (ValueType item in Items)
{
diff --git a/src/Connected.Components/Components/SimpleSelect.razor.cs b/src/Connected.Components/Components/SimpleSelect.razor.cs
index 2baadb7..456a06b 100644
--- a/src/Connected.Components/Components/SimpleSelect.razor.cs
+++ b/src/Connected.Components/Components/SimpleSelect.razor.cs
@@ -29,30 +29,13 @@ public partial class SimpleSelect : 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)
{
//DropDownClassToggle();
await ValueChanged.InvokeAsync(item);
}
- private async Task FilterItems()
+ private void FilterItems()
{
if (string.IsNullOrEmpty(_searchText))
{
@@ -76,13 +59,18 @@ public partial class SimpleSelect : InputBase
protected override async Task OnParametersSetAsync()
{
- if (base.InputAttributes is null) base.InputAttributes = new();
- if (base.Required)
- {
- if (base.InputAttributes.ContainsKey("required")) base.InputAttributes.Add("required", true);
- }
+
OriginalItems = Items;
- if (_searchText.Length>0) await FilterItems();
+ 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);
+ }
}
}
\ No newline at end of file
diff --git a/src/Connected.Components/Components/TextInput.razor.cs b/src/Connected.Components/Components/TextInput.razor.cs
index e7e5354..b8d4268 100644
--- a/src/Connected.Components/Components/TextInput.razor.cs
+++ b/src/Connected.Components/Components/TextInput.razor.cs
@@ -56,14 +56,13 @@ public partial class TextInput: InputBase
}
- protected override async Task OnParametersSetAsync()
- {
- if (base.InputAttributes is null) base.InputAttributes = new();
- if (base.Required)
+ protected override async Task OnInitializedAsync()
+ {
+ await base.OnInitializedAsync();
+ if (Required)
{
- if (base.InputAttributes.ContainsKey("required")) base.InputAttributes.Add("required", true);
+ if (!InputAttributes.ContainsKey("required")) InputAttributes.Add("required", true);
}
- await base.OnInitializedAsync();
- }
+ }
}
\ No newline at end of file
diff --git a/src/Connected.Components/Models/InputBase.cs b/src/Connected.Components/Models/InputBase.cs
index a95722c..f6bda7a 100644
--- a/src/Connected.Components/Models/InputBase.cs
+++ b/src/Connected.Components/Models/InputBase.cs
@@ -1,7 +1,5 @@
using Connected.Utilities;
using Microsoft.AspNetCore.Components;
-using static Connected.Colors;
-using static System.Net.Mime.MediaTypeNames;
namespace Connected.Models;
public class InputBase : ComponentBase
@@ -124,4 +122,9 @@ public class InputBase : ComponentBase
[Parameter]
public string Placeholder { get; set; } = string.Empty;
+
+ protected override async Task OnInitializedAsync()
+ {
+ if (InputAttributes is null) InputAttributes = new();
+ }
}