diff --git a/src/Connected.Components.Showcase.Runner/Pages/Index.razor b/src/Connected.Components.Showcase.Runner/Pages/Index.razor index 4f09ccd..748b937 100644 --- a/src/Connected.Components.Showcase.Runner/Pages/Index.razor +++ b/src/Connected.Components.Showcase.Runner/Pages/Index.razor @@ -1,16 +1,12 @@ @page "/" +@using Connected.Models;

Component Sandbox

ValueDouble: @inputValueDouble.ToString()

ValueInt: @inputValueInt.ToString()

ValueText: @inputValueText

- - - Alert!! - +

SimpleSelectValue: @SelectedItemValue

+ + + @code { + List> SelectFieldItems = new(); + string SelectedItemValue = ""; + int counter { get; set; } = 0; private string _inputText = string.Empty; @@ -89,4 +96,19 @@ string errorText = "Error!!"; + protected override async Task OnInitializedAsync() + { + SelectFieldItems.Add(new SelectItem() { DisplayedText = "Item 1", Value = "select item value 1", Enabled = true }); + SelectFieldItems.Add(new SelectItem() { DisplayedText = "Item 2", Value = "select item value 2", Enabled = true }); + SelectFieldItems.Add(new SelectItem() { DisplayedText = "Item 3", Value = "select item value 3", Enabled = true }); + SelectFieldItems.Add(new SelectItem() { DisplayedText = "Item 4", Value = "select item value 4", Enabled = true }); + SelectFieldItems.Add(new SelectItem() { DisplayedText = "Item 5", Value = "select item value 5", Enabled = false }); + SelectFieldItems.Add(new SelectItem() { DisplayedText = "Item 6", Value = "select item value 6", Enabled = true }); + SelectFieldItems.Add(new SelectItem() { DisplayedText = "Item 7", Value = "select item value 7", Enabled = true }); + SelectFieldItems.Add(new SelectItem() { DisplayedText = "Item 8", Value = "select item value 8", Enabled = false }); + SelectFieldItems.Add(new SelectItem() { DisplayedText = "Item 9", Value = "select item value 9", Enabled = true }); + SelectFieldItems.Add(new SelectItem() { DisplayedText = "Item 10", Value = "select item value 10", Enabled = true }); + SelectedItemValue = SelectFieldItems[0].Value; + } + } \ No newline at end of file diff --git a/src/Connected.Components/Components/Button.razor b/src/Connected.Components/Components/Button.razor index 0abbabb..0bbb79b 100644 --- a/src/Connected.Components/Components/Button.razor +++ b/src/Connected.Components/Components/Button.razor @@ -42,87 +42,3 @@ } - - - diff --git a/src/Connected.Components/Components/SimpleSelect.razor b/src/Connected.Components/Components/SimpleSelect.razor new file mode 100644 index 0000000..facc072 --- /dev/null +++ b/src/Connected.Components/Components/SimpleSelect.razor @@ -0,0 +1,18 @@ +@using Connected.Models; + +@typeparam ValueType + +@inherits InputBase; + +
+ +
\ No newline at end of file diff --git a/src/Connected.Components/Components/SimpleSelect.razor.cs b/src/Connected.Components/Components/SimpleSelect.razor.cs new file mode 100644 index 0000000..4bdfdc2 --- /dev/null +++ b/src/Connected.Components/Components/SimpleSelect.razor.cs @@ -0,0 +1,45 @@ +using Connected.Models; +using Microsoft.AspNetCore.Components; +using System; + +namespace Connected.Components; +public partial class SimpleSelect : InputBase +{ + [Parameter] + public ValueType Value { get; set; } + + [Parameter] + public IEnumerable> Items { get; set; } + + public IEnumerable> OriginalItems { get; set; } + + [Parameter] + public bool EnableSearch { get; set; } = true; + public string SearchText { get; set; } + + public void FilterItems() + { + Items= Items.Where(item => item.Value.ToString().ToLower().Contains(SearchText.ToLower()) || item.DisplayedText.ToString().ToLower().Contains(SearchText.ToLower())); + } + + + [Parameter] + public EventCallback ValueChanged { get; set; } + + private async Task ChangeValueAsync(ChangeEventArgs args) + { + await ValueChanged.InvokeAsync((ValueType)Convert.ChangeType(args.Value, typeof(ValueType))); + } + + 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; + await base.OnInitializedAsync(); + } + +} \ No newline at end of file diff --git a/src/Connected.Components/Models/SelectItem.cs b/src/Connected.Components/Models/SelectItem.cs new file mode 100644 index 0000000..bf47c79 --- /dev/null +++ b/src/Connected.Components/Models/SelectItem.cs @@ -0,0 +1,9 @@ +namespace Connected.Models +{ + public class SelectItem + { + public string DisplayedText { get; set; } + public ValueType Value { get; set; } + public bool Enabled { get; set; } + } +} \ No newline at end of file diff --git a/src/Connected.Components/Styles/Connected.Components.scss b/src/Connected.Components/Styles/Connected.Components.scss new file mode 100644 index 0000000..7829ff0 --- /dev/null +++ b/src/Connected.Components/Styles/Connected.Components.scss @@ -0,0 +1,4 @@ +@import 'globals/_index'; +@import 'layout/_index'; +@import 'components/_index'; +@import 'util/_index'; \ No newline at end of file