From b160a7ad468e2740a517fb1f22cc8d00f3d551fb Mon Sep 17 00:00:00 2001 From: Manuel Monteagudo Date: Sat, 5 Oct 2024 00:30:05 -0400 Subject: [PATCH 1/7] Adds Floating label type to MultiSelect --- .../Forms/HxMultiSelect.cs | 7 ++++++- .../Forms/MultiSelectSettings.cs | 5 +++++ .../XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxMultiSelect.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxMultiSelect.cs index 1271cf2f..80c08ab7 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxMultiSelect.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxMultiSelect.cs @@ -8,7 +8,7 @@ namespace Havit.Blazor.Components.Web.Bootstrap; /// /// Type of values. /// Type of items. -public class HxMultiSelect : HxInputBase>, IInputWithSize +public class HxMultiSelect : HxInputBase>, IInputWithSize, IInputWithLabelType { /// /// Return defaults. @@ -161,6 +161,11 @@ public class HxMultiSelect : HxInputBase>, IInputWit [Parameter] public IconBase FilterClearIcon { get; set; } protected IconBase FilterClearIconEffective => FilterClearIcon ?? GetSettings()?.FilterClearIcon ?? GetDefaults().FilterClearIcon; + /// + [Parameter] public LabelType? LabelType { get; set; } + protected LabelType LabelTypeEffective => LabelType ?? GetSettings()?.LabelType ?? GetDefaults()?.LabelType ?? HxSetup.Defaults.LabelType; + LabelType IInputWithLabelType.LabelTypeEffective => LabelTypeEffective; + private List _itemsToRender; private HxMultiSelectInternal _hxMultiSelectInternalComponent; diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/MultiSelectSettings.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/MultiSelectSettings.cs index 27a62131..4bdca09f 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/MultiSelectSettings.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/MultiSelectSettings.cs @@ -12,6 +12,11 @@ public record MultiSelectSettings : InputSettings /// public InputSize? InputSize { get; set; } + /// + /// The label type. + /// + public LabelType? LabelType { get; set; } + /// /// Enables filtering capabilities. /// diff --git a/Havit.Blazor.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml b/Havit.Blazor.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml index 644d8078..ac38f5b0 100644 --- a/Havit.Blazor.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml +++ b/Havit.Blazor.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml @@ -4681,6 +4681,9 @@ Icon displayed in filter input for clearing the filter. + + + @@ -5395,6 +5398,11 @@ Input size. + + + The label type. + + Enables filtering capabilities. From 2468d138eb0a03fbea420909e8fffd9ba416cc86 Mon Sep 17 00:00:00 2001 From: Manuel Monteagudo Date: Sat, 5 Oct 2024 02:20:25 -0400 Subject: [PATCH 2/7] Adds floating label type to MultiSelect --- .../Forms/HxInputBase.cs | 25 ++++++++++++++++--- .../Forms/HxMultiSelect.cs | 2 ++ .../Internal/HxMultiSelectInternal.razor | 10 +++++--- .../Internal/HxMultiSelectInternal.razor.cs | 4 +++ .../HxMultiSelect_Demo_BasicUsage.razor | 1 + 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs index 267a0e01..0080c88a 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs @@ -145,10 +145,27 @@ public abstract class HxInputBase : InputBase, ICascadeEnabledCo /// /// Elements rendering order. /// - protected virtual LabelValueRenderOrder RenderOrder => - ((this is IInputWithLabelType inputWithLabelType) && (inputWithLabelType.LabelTypeEffective == LabelType.Floating)) - ? LabelValueRenderOrder.ValueLabel - : LabelValueRenderOrder.LabelValue; + protected virtual LabelValueRenderOrder RenderOrder + { + get + { + if ((this is IInputWithLabelType inputWithLabelType) && (inputWithLabelType.LabelTypeEffective == LabelType.Floating)) + { + if (this.GetType().IsGenericType && this.GetType().GetGenericTypeDefinition() == typeof(HxMultiSelect<,>)) + { + return LabelValueRenderOrder.ValueOnly; + } + else + { + return LabelValueRenderOrder.ValueLabel; + } + } + else + { + return LabelValueRenderOrder.LabelValue; + } + } + } /// /// Gets or sets the current value of the input. diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxMultiSelect.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxMultiSelect.cs index 80c08ab7..4045bdd3 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxMultiSelect.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxMultiSelect.cs @@ -217,6 +217,8 @@ protected override void BuildRenderInput(RenderTreeBuilder builder) builder.AddAttribute(102, nameof(HxMultiSelectInternal.InputCssClass), GetInputCssClassToRender()); builder.AddAttribute(103, nameof(HxMultiSelectInternal.InputText), GetInputText()); builder.AddAttribute(104, nameof(HxMultiSelectInternal.EnabledEffective), EnabledEffective); + builder.AddAttribute(125, nameof(HxMultiSelectInternal.LabelTypeEffective), LabelTypeEffective); + builder.AddAttribute(126, nameof(HxMultiSelectInternal.LabelText), Label); builder.AddAttribute(105, nameof(HxMultiSelectInternal.ItemsToRender), _itemsToRender); builder.AddAttribute(106, nameof(HxMultiSelectInternal.TextSelector), TextSelector); builder.AddAttribute(107, nameof(HxMultiSelectInternal.ValueSelector), ValueSelector); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxMultiSelectInternal.razor b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxMultiSelectInternal.razor index c41401a1..50f3c15e 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxMultiSelectInternal.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxMultiSelectInternal.razor @@ -5,8 +5,7 @@ @{ bool enabled = EnabledEffective && (ItemsToRender != null); } -
@@ -16,7 +15,7 @@ } @InputGroupStartTemplate -