ant-design-blazor/components/checkbox/CheckboxGroup.razor
James Yeung 698ae84ab1
feat(module: checkbox): support generic value (#3715)
* feat(module: checkbox): support generic value

* fix tests

* fix test

* fix name

* fix tests

* fix tests
2024-04-02 22:15:48 +08:00

47 lines
1.7 KiB
C#

@namespace AntDesign
@typeparam TValue
@inherits AntInputComponentBase<TValue[]>
@using AntDesign.Internal;
<CascadingValue Value="null" Name="FormItem" TValue="IFormItem" IsFixed="@true">
<CascadingValue Value="this" IsFixed="@true">
<div class="@ClassMapper.Class" style="@Style" id="@Id" @ref="Ref">
@if (MixedMode == CheckboxGroupMixedMode.ChildContentFirst)
@ChildContent
@if (Options.Value != null)
{
if (Options.IsT0)
{
@foreach (var option in Options.AsT0)
{
<CascadingValue Value="option.Value" Name="ItemValue">
<Checkbox Disabled="option.Disabled || Disabled"
Checked="@option.Checked"
Label="@option.Label">
@option.Label
</Checkbox>
</CascadingValue>
}
}
else
{
@foreach (var option in Options.AsT1)
{
<CascadingValue Value="option" Name="ItemValue">
<Checkbox Disabled="Disabled"
Checked="@option.IsIn(_selectedValues)"
Label="@option.ToString()">
@option
</Checkbox>
</CascadingValue>
}
}
}
@if (MixedMode == CheckboxGroupMixedMode.OptionsFirst)
@ChildContent
</div>
</CascadingValue>
</CascadingValue>