From cf7981aad4b7108d159754830aec7e92ae33daa8 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Wed, 4 Sep 2024 17:55:34 +0300 Subject: [PATCH] Makes Combobox item Value generic --- .../Common/Models/UI/ComboboxItem.cs | 5 +++-- .../Components/EnlightenmentCombobox.razor | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Lumina.Presentation.Web/Common/Models/UI/ComboboxItem.cs b/src/Lumina.Presentation.Web/Common/Models/UI/ComboboxItem.cs index 50364327..7243f4cd 100644 --- a/src/Lumina.Presentation.Web/Common/Models/UI/ComboboxItem.cs +++ b/src/Lumina.Presentation.Web/Common/Models/UI/ComboboxItem.cs @@ -3,7 +3,8 @@ /// /// Represents an item in a combobox. /// -public class ComboboxItem +/// The type used for the property of the item. +public class ComboboxItem { #region ==================================================================== PROPERTIES ================================================================================= /// @@ -14,6 +15,6 @@ public class ComboboxItem /// /// Gets or sets the value of the item, that is used by the application. /// - public string? Value { get; set; } + public TValue? Value { get; set; } #endregion } \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Components/EnlightenmentCombobox.razor b/src/Lumina.Presentation.Web/Components/EnlightenmentCombobox.razor index ffdd7d76..415c3db8 100644 --- a/src/Lumina.Presentation.Web/Components/EnlightenmentCombobox.razor +++ b/src/Lumina.Presentation.Web/Components/EnlightenmentCombobox.razor @@ -1,10 +1,12 @@ @using Lumina.Presentation.Web.Common.Models.UI @using Lumina.Presentation.Web.Core.Services.UI -@inject ComboboxService _comboboxService +@typeparam TValue @implements IDisposable +@inject ComboboxService _comboboxService +
@@ -25,9 +27,9 @@
@code { - [Parameter] public List Items { get; set; } = []; - [Parameter] public ComboboxItem? SelectedItem { get; set; } - [Parameter] public EventCallback SelectedItemChanged { get; set; } + [Parameter] public List> Items { get; set; } = []; + [Parameter] public ComboboxItem? SelectedItem { get; set; } + [Parameter] public EventCallback> SelectedItemChanged { get; set; } [Parameter] public string? CssClass { get; set; } private bool IsOpen { get; set; } @@ -68,7 +70,7 @@ /// Selects the provided . ///
/// The item to select. - private async Task SelectItem(ComboboxItem? item) + private async Task SelectItem(ComboboxItem? item) { SelectedItem = item; IsOpen = false;