From ca9eeed3347faab8ba268cb52a4c992e396f816f Mon Sep 17 00:00:00 2001 From: Saleh Yusefnejad Date: Fri, 19 Dec 2025 11:29:28 +0330 Subject: [PATCH 1/5] add Params infrastructure to BitStack #11884 --- .../Layouts/Stack/BitStackParams.cs | 248 ++++++++++++++++++ 1 file changed, 248 insertions(+) create mode 100644 src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs b/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs new file mode 100644 index 0000000000..99075d9a73 --- /dev/null +++ b/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs @@ -0,0 +1,248 @@ +namespace Bit.BlazorUI; + +/// +/// The parameters for component. +/// +public class BitStackParams : BitComponentBaseParams, IBitComponentParams +{ + /// + /// Represents the parameter name used to identify the cascading parameters within . + /// + /// + /// This constant is typically used when referencing or accessing the BitStack value in + /// parameterized APIs or configuration settings. Using this constant helps ensure consistency and reduces the risk + /// of typographical errors. + /// + public const string ParamName = $"{nameof(BitParams)}.{nameof(BitStack)}"; + + + + public string Name => ParamName; + + + + /// + /// Defines whether to render Stack children both horizontally and vertically. + /// + public BitAlignment? Alignment { get; set; } + + /// + /// Make the height of the stack auto. + /// + public bool? AutoHeight { get; set; } + + /// + /// Make the width and height of the stack auto. + /// + public bool? AutoSize { get; set; } + + /// + /// Make the width of the stack auto. + /// + public bool? AutoWidth { get; set; } + + /// + /// The custom html element used for the root node. The default is "div". + /// + public string? Element { get; set; } + + /// + /// Expand the direct children to occupy all of the root element's width and height. + /// + public bool? FillContent { get; set; } + + /// + /// Sets the height of the stack to fit its content. + /// + public bool? FitHeight { get; set; } + + /// + /// Sets the width and height of the stack to fit its content. + /// + public bool? FitSize { get; set; } + + /// + /// Sets the width of the stack to fit its content. + /// + public bool? FitWidth { get; set; } + + /// + /// Defines the spacing between Stack children. + /// + public string? Gap { get; set; } + + /// + /// Defines how much to grow the Stack in proportion to its siblings. + /// + public string? Grow { get; set; } + + /// + /// Defines how much to grow the Stack in proportion to its siblings. + /// + public bool? Grows { get; set; } + + /// + /// Defines whether to render Stack children horizontally. + /// + public bool? Horizontal { get; set; } + + /// + /// Defines whether to render Stack children horizontally. + /// + public BitAlignment? HorizontalAlign { get; set; } + + /// + /// Defines whether to render Stack children in the opposite direction (bottom-to-top if it's a vertical Stack and right-to-left if it's a horizontal Stack). + /// + public bool? Reversed { get; set; } + + /// + /// Defines whether to render Stack children vertically. + /// + public BitAlignment? VerticalAlign { get; set; } + + /// + /// Defines whether Stack children should wrap onto multiple rows or columns when they are about to overflow the size of the Stack. + /// + public bool? Wrap { get; set; } + + + + /// + /// Updates the properties of the specified instance with any values that have been set on + /// this object, if those properties have not already been set on the . + /// + /// + /// Only properties that have a value set and have not already been set on the will be updated. + /// This method does not overwrite existing values on . + /// + /// + /// The instance whose properties will be updated. Cannot be null. + /// + public void UpdateParameters(BitStack bitStack) + { + if (bitStack is null) return; + + UpdateBaseParameters(bitStack); + + if (Alignment.HasValue && bitStack.HasNotBeenSet(nameof(Alignment))) + { + bitStack.Alignment = Alignment.Value; + + bitStack.StyleBuilder.Reset(); + } + + if (AutoHeight.HasValue && bitStack.HasNotBeenSet(nameof(AutoHeight))) + { + bitStack.AutoHeight = AutoHeight.Value; + + bitStack.StyleBuilder.Reset(); + } + + if (AutoSize.HasValue && bitStack.HasNotBeenSet(nameof(AutoSize))) + { + bitStack.AutoSize = AutoSize.Value; + + bitStack.StyleBuilder.Reset(); + } + + if (AutoWidth.HasValue && bitStack.HasNotBeenSet(nameof(AutoWidth))) + { + bitStack.AutoWidth = AutoWidth.Value; + + bitStack.StyleBuilder.Reset(); + } + + if (Element.HasValue() && bitStack.HasNotBeenSet(nameof(Element))) + { + bitStack.Element = Element; + } + + if (FillContent.HasValue && bitStack.HasNotBeenSet(nameof(FillContent))) + { + bitStack.FillContent = FillContent.Value; + + bitStack.ClassBuilder.Reset(); + } + + if (FitHeight.HasValue && bitStack.HasNotBeenSet(nameof(FitHeight))) + { + bitStack.FitHeight = FitHeight.Value; + + bitStack.StyleBuilder.Reset(); + } + + if (FitSize.HasValue && bitStack.HasNotBeenSet(nameof(FitSize))) + { + bitStack.FitSize = FitSize.Value; + + bitStack.StyleBuilder.Reset(); + } + + if (FitWidth.HasValue && bitStack.HasNotBeenSet(nameof(FitWidth))) + { + bitStack.FitWidth = FitWidth.Value; + + bitStack.StyleBuilder.Reset(); + } + + if (Gap.HasValue() && bitStack.HasNotBeenSet(nameof(Gap))) + { + bitStack.Gap = Gap; + + bitStack.StyleBuilder.Reset(); + } + + if (Grow.HasValue() && bitStack.HasNotBeenSet(nameof(Grow))) + { + bitStack.Grow = Grow; + + bitStack.StyleBuilder.Reset(); + } + + if (Grows.HasValue && bitStack.HasNotBeenSet(nameof(Grows))) + { + bitStack.Grows = Grows.Value; + + bitStack.StyleBuilder.Reset(); + } + + if (Horizontal.HasValue && bitStack.HasNotBeenSet(nameof(Horizontal))) + { + bitStack.Horizontal = Horizontal.Value; + + bitStack.ClassBuilder.Reset(); + bitStack.StyleBuilder.Reset(); + } + + if (HorizontalAlign.HasValue && bitStack.HasNotBeenSet(nameof(HorizontalAlign))) + { + bitStack.HorizontalAlign = HorizontalAlign.Value; + + bitStack.StyleBuilder.Reset(); + } + + if (Reversed.HasValue && bitStack.HasNotBeenSet(nameof(Reversed))) + { + bitStack.Reversed = Reversed.Value; + + bitStack.StyleBuilder.Reset(); + } + + if (VerticalAlign.HasValue && bitStack.HasNotBeenSet(nameof(VerticalAlign))) + { + bitStack.VerticalAlign = VerticalAlign.Value; + + bitStack.StyleBuilder.Reset(); + } + + if (Wrap.HasValue && bitStack.HasNotBeenSet(nameof(Wrap))) + { + bitStack.Wrap = Wrap.Value; + + bitStack.StyleBuilder.Reset(); + } + } +} + + From 70649b21388ea04f6dd3965b1dc7de8bff04c811 Mon Sep 17 00:00:00 2001 From: Saleh Yusefnejad Date: Fri, 19 Dec 2025 11:32:49 +0330 Subject: [PATCH 2/5] add missing parts --- .../Components/Layouts/Stack/BitStack.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStack.cs b/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStack.cs index 54b7e6340b..163ddfedb1 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStack.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStack.cs @@ -7,6 +7,19 @@ namespace Bit.BlazorUI; /// public partial class BitStack : BitComponentBase { + /// + /// Gets or sets the cascading parameters for the stack component. + /// + /// + /// This property receives its value from an ancestor component via Blazor's cascading parameter mechanism. + ///
+ /// The intended use is to allow shared configuration or settings to be applied to multiple stack components through the component. + ///
+ [CascadingParameter(Name = BitStackParams.ParamName)] + public BitStackParams? CascadingParameters { get; set; } + + + /// /// Defines whether to render Stack children both horizontally and vertically. /// @@ -161,6 +174,16 @@ protected override void RegisterCssStyles() StyleBuilder.Register(() => (FitSize || FitHeight) ? "height:fit-content" : string.Empty); } + [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(BitStackParams))] + protected override void OnParametersSet() + { + CascadingParameters?.UpdateParameters(this); + + base.OnParametersSet(); + } + + + protected override void BuildRenderTree(RenderTreeBuilder builder) { builder.OpenElement(0, Element ?? "div"); From 25c54a9478a15ea6464f489b8b3a042c159819a3 Mon Sep 17 00:00:00 2001 From: Saleh Yusefnejad Date: Fri, 19 Dec 2025 21:26:03 +0330 Subject: [PATCH 3/5] add missing using statement --- .../Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs b/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs index 99075d9a73..fc67a05457 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs @@ -1,3 +1,5 @@ +using System.Diagnostics.CodeAnalysis; + namespace Bit.BlazorUI; /// From ba3b98a1ee854f476730f378e13d5ea1b5bff922 Mon Sep 17 00:00:00 2001 From: Saleh Yusefnejad Date: Fri, 19 Dec 2025 21:26:23 +0330 Subject: [PATCH 4/5] fix bom --- .../Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs b/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs index fc67a05457..bdc60400a5 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; namespace Bit.BlazorUI; From 097ead35db3bf276ed7a48a89140aba69930f1d1 Mon Sep 17 00:00:00 2001 From: Saleh Yusefnejad Date: Fri, 19 Dec 2025 21:30:40 +0330 Subject: [PATCH 5/5] fix usings --- .../Bit.BlazorUI/Components/Layouts/Stack/BitStack.cs | 3 ++- .../Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStack.cs b/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStack.cs index 163ddfedb1..676ea7a8a7 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStack.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStack.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Components.CompilerServices; +using System.Diagnostics.CodeAnalysis; +using Microsoft.AspNetCore.Components.CompilerServices; namespace Bit.BlazorUI; diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs b/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs index bdc60400a5..de3d5c88fc 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Layouts/Stack/BitStackParams.cs @@ -1,6 +1,4 @@ -using System.Diagnostics.CodeAnalysis; - -namespace Bit.BlazorUI; +namespace Bit.BlazorUI; /// /// The parameters for component.