|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the Apache 2.0 License |
| 3 | +// See the LICENSE file in the project root for more information. |
| 4 | +// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone |
| 5 | + |
| 6 | +namespace BootstrapBlazor.Components; |
| 7 | + |
| 8 | +/// <summary> |
| 9 | +/// 单选框组合组件 |
| 10 | +/// </summary> |
| 11 | +[ExcludeFromCodeCoverage] |
| 12 | +public partial class RadioListGeneric<TValue> |
| 13 | +{ |
| 14 | + /// <summary> |
| 15 | + /// 获得/设置 值为可为空枚举类型时是否自动添加空值 默认 false 自定义空值显示文本请参考 <see cref="NullItemText"/> |
| 16 | + /// </summary> |
| 17 | + [Parameter] |
| 18 | + public bool IsAutoAddNullItem { get; set; } |
| 19 | + |
| 20 | + /// <summary> |
| 21 | + /// 获得/设置 空值项显示文字 默认为 "" 是否自动添加空值请参考 <see cref="IsAutoAddNullItem"/> |
| 22 | + /// </summary> |
| 23 | + [Parameter] |
| 24 | + [NotNull] |
| 25 | + public string? NullItemText { get; set; } |
| 26 | + |
| 27 | + /// <summary> |
| 28 | + /// 获得/设置 项模板 |
| 29 | + /// </summary> |
| 30 | + [Parameter] |
| 31 | + public RenderFragment<SelectedItem<TValue>>? ItemTemplate { get; set; } |
| 32 | + |
| 33 | + //private string? GroupName => Id; |
| 34 | + |
| 35 | + //private string? ClassString => CssBuilder.Default("radio-list form-control") |
| 36 | + // .AddClass("no-border", !ShowBorder && ValidCss != "is-invalid") |
| 37 | + // .AddClass("is-vertical", IsVertical) |
| 38 | + // .AddClass(CssClass).AddClass(ValidCss) |
| 39 | + // .Build(); |
| 40 | + |
| 41 | + //private string? ButtonClassString => CssBuilder.Default("radio-list btn-group") |
| 42 | + // .AddClass("disabled", IsDisabled) |
| 43 | + // .AddClass("btn-group-vertical", IsVertical) |
| 44 | + // .AddClassFromAttributes(AdditionalAttributes) |
| 45 | + // .Build(); |
| 46 | + |
| 47 | + //private string? GetButtonItemClassString(SelectedItem item) => CssBuilder.Default("btn") |
| 48 | + // .AddClass($"active bg-{Color.ToDescriptionString()}", CurrentValueAsString == item.Value) |
| 49 | + // .Build(); |
| 50 | + |
| 51 | + ///// <summary> |
| 52 | + ///// <inheritdoc/> |
| 53 | + ///// </summary> |
| 54 | + //protected override void OnParametersSet() |
| 55 | + //{ |
| 56 | + // var t = NullableUnderlyingType ?? typeof(TValue); |
| 57 | + // if (t.IsEnum && Items == null) |
| 58 | + // { |
| 59 | + // Items = t.ToSelectList<TValue>((NullableUnderlyingType != null && IsAutoAddNullItem) ? new SelectedItem<TValue>(default, NullItemText) : null); |
| 60 | + // } |
| 61 | + |
| 62 | + // base.OnParametersSet(); |
| 63 | + //} |
| 64 | + |
| 65 | + ///// <summary> |
| 66 | + ///// 点击选择框方法 |
| 67 | + ///// </summary> |
| 68 | + //private async Task OnClick(SelectedItem<TValue> item) |
| 69 | + //{ |
| 70 | + // if (!IsDisabled) |
| 71 | + // { |
| 72 | + // if (OnSelectedChanged != null) |
| 73 | + // { |
| 74 | + // await OnSelectedChanged(Items, Value); |
| 75 | + // } |
| 76 | + // StateHasChanged(); |
| 77 | + // } |
| 78 | + //} |
| 79 | + |
| 80 | + //private CheckboxState CheckState(SelectedItem<TValue> item) => this.Equals<TValue>(Value, item.Value) ? CheckboxState.Checked : CheckboxState.UnChecked; |
| 81 | + |
| 82 | + //private RenderFragment? GetChildContent(SelectedItem<TValue> item) => ItemTemplate == null |
| 83 | + // ? null |
| 84 | + // : ItemTemplate(item); |
| 85 | +} |
0 commit comments