using Microsoft.AspNetCore.Components; using Radzen.Blazor.Rendering; using System; using System.Collections.Generic; namespace Radzen.Blazor { /// /// RadzenRadioButtonListItem component. /// /// The type of the value. public class RadzenRadioButtonListItem : RadzenComponent { /// /// Specifies additional custom attributes that will be rendered by the input. /// /// The attributes. [Parameter] public IReadOnlyDictionary? InputAttributes { get; set; } private string? text; /// /// Gets or sets the text. /// /// The text. [Parameter] public string? Text { get { return text; } set { if (value != text) { text = value; if (List != null) List.Refresh(); } } } /// /// Gets or sets the template. /// /// The template. [Parameter] public RenderFragment>? Template { get; set; } /// /// Gets or sets the value. /// /// The value. [Parameter] public TValue? Value { get; set; } /// /// Gets or sets a value indicating whether this is disabled. /// /// true if disabled; otherwise, false. [Parameter] public virtual bool Disabled { get; set; } private RadzenRadioButtonList? list; /// /// Gets or sets the list. /// /// The list. [CascadingParameter] public RadzenRadioButtonList? List { get { return list; } set { if (list != value) { list = value; list?.AddItem(this); } } } /// /// Disposes this instance. /// public override void Dispose() { base.Dispose(); List?.RemoveItem(this); GC.SuppressFinalize(this); } internal void SetText(string value) { Text = value; } internal void SetValue(TValue value) { Value = value; } internal void SetDisabled(bool value) { Disabled = value; } internal void SetVisible(bool value) { Visible = value; } internal string? GetItemId() { return GetId(); } internal string GetItemCssClass() { return ClassList.Create(GetCssClass()) .AddDisabled(Disabled) .ToString(); } /// protected override string GetComponentCssClass() { return "rz-radio-btn"; } } }