mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2025-12-06 07:28:50 +08:00
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:
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>10.1.1</Version>
|
||||
<Version>10.1.2-beta01</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@namespace BootstrapBlazor.Components
|
||||
@namespace BootstrapBlazor.Components
|
||||
@typeparam TItem
|
||||
|
||||
<div class="float-start table-toolbar-button">
|
||||
@@ -34,8 +34,10 @@
|
||||
}
|
||||
else if (button is TableToolbarComponent<TItem> { IsShow: true } cb)
|
||||
{
|
||||
<CascadingValue Value="OnGetSelectedRows" IsFixed="true">
|
||||
@cb.ChildContent
|
||||
<CascadingValue Value="button" IsFixed="true">
|
||||
<CascadingValue Value="OnGetSelectedRows" IsFixed="true">
|
||||
@cb.ChildContent
|
||||
</CascadingValue>
|
||||
</CascadingValue>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user