feat(BootstrapInputGroupLabel): add IToolbarComponent cascading value (#7259)

* feat(BootstrapInputGroupLabel): add IToolbarComponent cascading value

* test: 增加单元测试

* chore: bump version 10.1.2-beta01
This commit is contained in:
Argo Zhang
2025-12-05 14:49:19 +08:00
committed by GitHub
parent fd396e36ea
commit ba29cfa71c
4 changed files with 31 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<Version>10.1.1</Version>
<Version>10.1.2-beta01</Version>
</PropertyGroup>
<ItemGroup>

View File

@@ -57,9 +57,12 @@ public sealed class BootstrapInputGroupLabel : DisplayBase<string>
[Parameter]
public bool? IsGroupLabel { get; set; }
[CascadingParameter]
private IToolbarComponent? ToolbarComponent { get; set; }
private string? Required => ShowRequiredMark ? "true" : null;
private bool IsInputGroupLabel => IsGroupLabel ?? InputGroup != null;
private bool IsInputGroupLabel => IsGroupLabel ?? InputGroup != null || ToolbarComponent != null;
/// <summary>
/// <inheritdoc/>

View File

@@ -1,4 +1,4 @@
@namespace BootstrapBlazor.Components
@namespace BootstrapBlazor.Components
@typeparam TItem
<div class="float-start table-toolbar-button">
@@ -34,9 +34,11 @@
}
else if (button is TableToolbarComponent<TItem> { IsShow: true } cb)
{
<CascadingValue Value="button" IsFixed="true">
<CascadingValue Value="OnGetSelectedRows" IsFixed="true">
@cb.ChildContent
</CascadingValue>
</CascadingValue>
}
}
</div>

View File

@@ -295,6 +295,27 @@ public class InputTest : BootstrapBlazorTestBase
cut.Contains("input-group-text");
}
[Fact]
public void ToolbarComponent_Ok()
{
var cut = Context.Render<CascadingValue<IToolbarComponent>>(pb =>
{
pb.Add(a => a.Value, new MockToolbarComponent());
pb.Add(a => a.IsFixed, true);
pb.Add(a => a.ChildContent, builder =>
{
builder.OpenComponent<BootstrapInputGroupLabel>(0);
builder.CloseComponent();
});
});
cut.Contains("input-group-text");
}
class MockToolbarComponent : ComponentBase, IToolbarComponent
{
public bool IsShow { get; set; }
}
[Fact]
public void ShowRequiredMark_Ok()
{