mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 09:21:24 +08:00
e8965eb369
* feat(module: table): add a method to get query model (#1202) * feat(module: table): add OnExpand event (#1208) * feat(module: table): add summary (#1218) * feat(module: table): add summary row * feat: add fixed summary cell * feat(module: InputNumber): Add long-click and keyboard operation (#1235) * feat(module: InputNumber): Add long click and keyboard event 1. When hold mouse down button will always trigger the increase or decrease 2. Add event listener to "ArrowUp" and "ArrowDown" key * feat(module: InputNumber): Add long click and keyboard event 1. When hold mouse down button will always trigger the increase or decrease 2. Add event listener to "ArrowUp" and "ArrowDown" key * fix null reference exception Co-authored-by: ElderJames <shunjiey@hotmail.com> * refactor(module: pagination): cover the apis of react (#1220) * feat(module: config-provider): support RTL (#1238) * feat(module: config-provider): support RTL * add rtl for each component * fix rtl for pagination * add rtl for overlay * chore: sync ant-design v4.14.0 (#1249) * feat(module: tag): add closing event (#1268) * tag add onclosing event * clean code * translate the comment * translation Co-authored-by: James Yeung <shunjiey@hotmail.com> * chore: sync ant-design v4.15.0 (#1281) * feat: add built-in themes (#1286) * feat: add themes * add docs theming styles * fix the RTL for FixedWidgets * fix aliyun theme * fix docs style * feat(module: form): Form lable supports left alignment (#1292) * feat: Form lable supports left alignment * Update and rename components/grid/Col.razor.cs to 组件/格网/Col.razor.cs * Delete Col.razor.cs * no message * PR:1292 * typo LabelAlign * add the property in Col instead FormItem * clean code Co-authored-by: James Yeung <shunjiey@hotmail.com> * feat(module: upload): missing and new event (#1302) * feat(module:upload): missing and new event * docs(module:upload): new events (missing Chinese) Co-authored-by: James Yeung <shunjiey@hotmail.com> * refactor: unified use of FeedbackComponent for modal comfirm and drawer (#1263) * refactor: support to use the same template for confirm and modal * refactor: support to use the same template for drawer * refactor: separate interface IOkCancelRef * chore: modify EventUtil class summary Co-authored-by: James Yeung <shunjiey@hotmail.com> * feat(module: alert): add message template and loop banner demo (#1250) * feat(Alert): added alert loop component * fix: move cmp into main * feat: add parameters for looping text * feat: add new messages loop * fix: create new internal looptext cmp * doc: add demo * doc: add demo markdown * doc: update alert api * doc: update cn docs * fix: add missing dependency * fix: update param name * impleement loop text with css * fix the document Co-authored-by: James Yeung <shunjiey@hotmail.com> * feat(module: table): add support for Display attribute (#1310) feat(module:table): add support for Display attribute Display attribute is widely used to specify display text for entity properties. Table component should get column names from Display attribute instances. Closes #1278 * test: add TestKit for public tests (#1248) * test: change folder structure and add new TestKit csproj for public testing of AntDesign-based applications * docs: added CN and EN docs about TestKit * fix doc translate * change the directory structure Co-authored-by: Patryk Grzelak <pgrzelak@mutate.app> Co-authored-by: James Yeung <shunjiey@hotmail.com> * feat(module: space): add wrap, split and size array (#1314) * fix(module: datepicker): incorrect in RTL mode (#1300) * fix(module: dropdown): default PlacementType is incorrect in RTL mode * fix(module: datepicker): not correct in RTL mode * fix(module: datepicker): styles is incorrect when switch to LTR from RTL Co-authored-by: James Yeung <shunjiey@hotmail.com> * docs: fix default css link (#1318) * fix(module: table): bring PR1208 to PR1303 merge master into feature (#1326) * feat(module: pagination): add TotalBoundaryShowSizeChanger parameter (#1325) * feat(module: pagination): add TotalBoundaryShowSizeChanger * docs(module: pagination): update API Co-authored-by: James Yeung <shunjiey@hotmail.com> * docs: dynamic primary color changing (#1332) * feat(docs): change color dynamically * docs: dynamic primary color changing * fix file path * delete the script * feat(module: table): add build-in filters (#1267) * tablefilter-moreoptions * tablefilter-moreoptions * tablefilter-moreoptions * tablefilter-moreoptions * tablefilter-moreoptions * fix demo and docs Co-authored-by: James Yeung <shunjiey@hotmail.com> * fix(module: tooltip): wrong popup direction (#1348) * fix merge conflicts Co-authored-by: Andrzej Bakun <andrzej@neelyc.com.cy> Co-authored-by: LingDev <lingjing0921@live.com> Co-authored-by: Zonciu Liang <zonciu@zonciu.com> Co-authored-by: TimChen <TimChen44@users.noreply.github.com> Co-authored-by: unsung189 <52531536+unsung189@users.noreply.github.com> Co-authored-by: zxyao <zxyao145@gmail.com> Co-authored-by: Patrick <42546986+MutatePat@users.noreply.github.com> Co-authored-by: anranruye <54608128+anranruye@users.noreply.github.com> Co-authored-by: Patryk Grzelak <pgrzelak@mutate.app> Co-authored-by: 笨木头 <musicvs@163.com> Co-authored-by: Magehernan <magehernan@gmail.com> Co-authored-by: ldsenow <ldsenow@gmail.com> Co-authored-by: Leishi <lluo@octet.com> Co-authored-by: YMohd <31305504+YMohd@users.noreply.github.com>
151 lines
4.5 KiB
C#
151 lines
4.5 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public partial class Radio<TValue> : AntDomComponentBase
|
|
{
|
|
[Parameter]
|
|
public RenderFragment ChildContent { get; set; }
|
|
|
|
[Parameter]
|
|
public TValue Value { get; set; }
|
|
|
|
[Parameter]
|
|
public bool AutoFocus { get; set; } = false;
|
|
|
|
[Parameter]
|
|
public bool RadioButton { get; set; }
|
|
|
|
[Parameter]
|
|
public bool Checked { get => _checked ?? false; set { _checked = value; } }
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> CheckedChanged { get; set; }
|
|
|
|
[Parameter]
|
|
public bool Disabled { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> CheckedChange { get; set; }
|
|
|
|
[CascadingParameter] public RadioGroup<TValue> RadioGroup { get; set; }
|
|
|
|
protected ClassMapper RadioClassMapper { get; set; } = new ClassMapper();
|
|
|
|
protected ClassMapper InputClassMapper { get; set; } = new ClassMapper();
|
|
|
|
protected ClassMapper InnerClassMapper { get; set; } = new ClassMapper();
|
|
|
|
protected ElementReference InputRef { get; set; }
|
|
|
|
protected bool IsChecked => _checked ?? this.Checked;
|
|
|
|
private bool? _checked;
|
|
|
|
internal string _name;
|
|
|
|
protected void SetClass()
|
|
{
|
|
string prefixCls = "ant-radio";
|
|
ClassMapper.Clear()
|
|
.If($"{prefixCls}-wrapper", () => !RadioButton)
|
|
.If($"{prefixCls}-button-wrapper", () => RadioButton)
|
|
.If($"{prefixCls}-wrapper-checked", () => IsChecked && !RadioButton)
|
|
.If($"{prefixCls}-button-wrapper-checked", () => IsChecked && RadioButton)
|
|
.If($"{prefixCls}-wrapper-disabled", () => Disabled && !RadioButton)
|
|
.If($"{prefixCls}-button-wrapper-disabled", () => Disabled && RadioButton)
|
|
.If($"{prefixCls}-button-wrapper-rtl", () => RTL);
|
|
|
|
RadioClassMapper.Clear()
|
|
.If(prefixCls, () => !RadioButton)
|
|
.If($"{prefixCls}-checked", () => IsChecked && !RadioButton)
|
|
.If($"{prefixCls}-disabled", () => Disabled && !RadioButton)
|
|
.If($"{prefixCls}-button", () => RadioButton)
|
|
.If($"{prefixCls}-button-checked", () => IsChecked && RadioButton)
|
|
.If($"{prefixCls}-button-disabled", () => Disabled && RadioButton)
|
|
.If($"{prefixCls}-rtl", () => RTL);
|
|
|
|
InputClassMapper.Clear()
|
|
.If($"{prefixCls}-input", () => !RadioButton)
|
|
.If($"{prefixCls}-button-input", () => RadioButton);
|
|
|
|
InnerClassMapper.Clear()
|
|
.If($"{prefixCls}-inner", () => !RadioButton)
|
|
.If($"{prefixCls}-button-inner", () => RadioButton);
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
SetClass();
|
|
RadioGroup?.AddRadio(this);
|
|
|
|
if (RadioGroup != null && RadioGroup.Disabled)
|
|
{
|
|
Disabled = true;
|
|
}
|
|
|
|
base.OnInitialized();
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
RadioGroup?.RadioItems?.Remove(this);
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
protected override async Task OnFirstAfterRenderAsync()
|
|
{
|
|
if (this.AutoFocus)
|
|
{
|
|
await FocusAsync(this.InputRef);
|
|
}
|
|
|
|
await base.OnFirstAfterRenderAsync();
|
|
}
|
|
|
|
internal async Task Select()
|
|
{
|
|
if (!Disabled && !IsChecked)
|
|
{
|
|
this._checked = true;
|
|
await CheckedChange.InvokeAsync(true);
|
|
await CheckedChanged.InvokeAsync(true);
|
|
}
|
|
}
|
|
|
|
internal async Task UnSelect()
|
|
{
|
|
if (!Disabled && this.IsChecked)
|
|
{
|
|
this._checked = false;
|
|
await CheckedChange.InvokeAsync(false);
|
|
await CheckedChanged.InvokeAsync(false);
|
|
}
|
|
}
|
|
|
|
public async Task OnClick()
|
|
{
|
|
if (Disabled)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (RadioGroup != null)
|
|
{
|
|
await RadioGroup.OnRadioChange(this.Value);
|
|
}
|
|
else
|
|
{
|
|
await Select();
|
|
}
|
|
}
|
|
|
|
protected async Task Blur()
|
|
{
|
|
await JsInvokeAsync(JSInteropConstants.Blur, this.InputRef);
|
|
}
|
|
}
|
|
}
|