refactor(BootstrapInputGroupLabel): use DynamicElement unified tag (#6101)

* refactor: 精简代码

* style: 代码格式化
This commit is contained in:
Argo Zhang
2025-05-27 14:43:05 +08:00
committed by GitHub
parent 2ba3fc8e08
commit 89d90772f2
3 changed files with 13 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
.input-group {
.input-group {
> .datetime-picker,
> .select,
> .switch,

View File

@@ -1,29 +1,13 @@
@namespace BootstrapBlazor.Components
@inherits DisplayBase<string>
@if (IsInputGroupLabel)
{
<div @attributes="@AdditionalAttributes" class="@ClassString" style="@StyleString" required="@Required">
@if (ChildContent != null)
{
@ChildContent
}
else
{
<span>@DisplayText</span>
}
</div>
}
else
{
<label @attributes="@AdditionalAttributes" class="@ClassString" style="@StyleString" required="@Required">
@if (ChildContent != null)
{
@ChildContent
}
else
{
@DisplayText
}
</label>
}
<DynamicElement @attributes="@AdditionalAttributes" TagName="@TagName" class="@ClassString" style="@StyleString" required="@Required">
@if (ChildContent != null)
{
@ChildContent
}
else
{
@DisplayText
}
</DynamicElement>

View File

@@ -23,6 +23,8 @@ public partial class BootstrapInputGroupLabel
.AddClassFromAttributes(AdditionalAttributes)
.Build();
private string TagName => IsInputGroupLabel ? "div" : "label";
/// <summary>
/// 获得/设置 标签宽度 默认 null 未设置自动适应
/// </summary>