mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 09:21:24 +08:00
555fdb9a43
* fix(module:checkbox): allow binding to Checked parameter * fix(module:switch): allow binding to Checked parameter * fix(modules): checkbox & switch get AntInputBoolComponentBase class * test(module:switch): add tests * test(module:checkbox): add tests * test(module:divider): simplify by using id:ignore * docs(module:checkbox): bind example * docs(module:switch): bind example * fix(module:switch): add Control + docs + tests * feat(module:checkboxgroup): add layout and mixed mode * fix: review comments + tests * fix(module:checkboxgroup): parameter name should be MixedMode added more tests * fix demo * fix(module:checkboxgroup): allow toggling between modes Co-authored-by: James Yeung <shunjiey@hotmail.com>
54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public abstract class AntInputBoolComponentBase : AntInputComponentBase<bool>
|
|
{
|
|
[Parameter] public bool AutoFocus { get; set; }
|
|
|
|
private bool _checked;
|
|
[Parameter]
|
|
public bool Checked
|
|
{
|
|
get { return _checked; }
|
|
set
|
|
{
|
|
_checked = value;
|
|
if (_checked != Value)
|
|
{
|
|
Value = _checked;
|
|
}
|
|
}
|
|
}
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> OnChange { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets a callback that updates the bound checked value.
|
|
/// </summary>
|
|
[Parameter]
|
|
public virtual EventCallback<bool> CheckedChanged { get; set; }
|
|
|
|
[Parameter]
|
|
public bool Disabled { get; set; }
|
|
|
|
internal virtual string PrefixCls { get; }
|
|
|
|
protected override void OnValueChange(bool value)
|
|
{
|
|
base.OnValueChange(value);
|
|
Checked = value;
|
|
CheckedChanged.InvokeAsync(value);
|
|
}
|
|
|
|
protected virtual async Task ChangeValue(bool value)
|
|
{
|
|
CurrentValue = value;
|
|
if (this.OnChange.HasDelegate)
|
|
await this.OnChange.InvokeAsync(value);
|
|
}
|
|
}
|
|
}
|