using Connected.Models;
using Connected.Utilities;
using Microsoft.AspNetCore.Components;

namespace Connected.Components;
public partial class Radio : InputBase
{
	#region Parameters
	[CascadingParameter]
	public RadioGroup? ParentRadioGroup { get; set; }

	[Parameter]
	public bool Checked { get; set; } = false;

	[Parameter, EditorRequired]
	public string? Id { get; set; }

	#endregion

	#region Events

	[Parameter]
	public EventCallback<bool> CheckedChanged { get; set; }

	public async Task OnChange()
	{
		Checked = !Checked;
		await CheckedChanged.InvokeAsync(Checked);
	}

	#endregion

	#region Style

	[Parameter]
	public string ClassName { get; set; } = string.Empty;

	private string ClassNameList
	{
		get
		{
			return new CssBuilder("radio-input")
				.AddClass(ClassName)
				.Build();
		}
	}

	[Parameter]
	public string LabelClassName { get; set; } = string.Empty;

	private string LabelClassNameList
	{
		get
		{
			return new CssBuilder("radio-label")
				.AddClass(LabelClassName)
				.Build();
		}
	}

	#endregion

}
