2020-03-26 15:59:24 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using Microsoft.AspNetCore.Components.Web;
|
2020-07-11 00:23:17 +08:00
|
|
|
|
using OneOf;
|
2020-03-26 15:59:24 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2020-05-29 00:33:49 +08:00
|
|
|
|
namespace AntDesign
|
2020-03-26 15:59:24 +08:00
|
|
|
|
{
|
2020-06-07 19:41:00 +08:00
|
|
|
|
public partial class Step : AntDomComponentBase
|
2020-03-26 15:59:24 +08:00
|
|
|
|
{
|
|
|
|
|
private string _status = "wait";
|
|
|
|
|
private bool _isCustomStatus;
|
|
|
|
|
private int _groupCurrent;
|
|
|
|
|
|
2020-04-24 18:32:50 +08:00
|
|
|
|
private readonly Dictionary<string, object> _containerAttributes = new Dictionary<string, object>();
|
2020-03-26 15:59:24 +08:00
|
|
|
|
|
|
|
|
|
internal bool Clickable { get; set; }
|
|
|
|
|
internal bool Last { get; set; }
|
|
|
|
|
internal bool ShowProcessDot { get; set; }
|
|
|
|
|
internal string GroupStatus { get; set; } = string.Empty;
|
2020-04-24 18:32:50 +08:00
|
|
|
|
|
2020-04-23 17:13:56 +08:00
|
|
|
|
internal int GroupCurrentIndex
|
|
|
|
|
{
|
2020-03-26 15:59:24 +08:00
|
|
|
|
get => _groupCurrent;
|
2020-04-23 17:13:56 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2020-03-26 15:59:24 +08:00
|
|
|
|
_groupCurrent = value;
|
|
|
|
|
if (!_isCustomStatus)
|
|
|
|
|
{
|
|
|
|
|
this._status = value > this.Index ? "finish" : value == this.Index ? GroupStatus ?? string.Empty : "wait";
|
|
|
|
|
}
|
|
|
|
|
SetClassMap();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-24 18:32:50 +08:00
|
|
|
|
|
2020-03-26 15:59:24 +08:00
|
|
|
|
internal int Index { get; set; }
|
2020-08-08 11:44:21 +08:00
|
|
|
|
internal double? Percent { get; set; }
|
|
|
|
|
internal string Size { get; set; } = "default";
|
2020-04-24 18:32:50 +08:00
|
|
|
|
internal RenderFragment ProgressDot { get; set; }
|
2020-03-26 15:59:24 +08:00
|
|
|
|
internal string Direction { get; set; } = "horizontal";
|
|
|
|
|
|
2020-04-23 17:13:56 +08:00
|
|
|
|
[CascadingParameter]
|
2020-06-07 19:41:00 +08:00
|
|
|
|
public Steps Parent { get; set; }
|
2020-04-23 17:13:56 +08:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public string Icon { get; set; }
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public string Status
|
|
|
|
|
{
|
2020-03-26 15:59:24 +08:00
|
|
|
|
get => _status;
|
2020-04-23 17:13:56 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2020-03-26 15:59:24 +08:00
|
|
|
|
_status = value;
|
|
|
|
|
_isCustomStatus = true;
|
|
|
|
|
SetClassMap();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-24 18:32:50 +08:00
|
|
|
|
|
2020-07-11 00:23:17 +08:00
|
|
|
|
[Parameter] public OneOf<string, RenderFragment> Title { get; set; }
|
|
|
|
|
[Parameter] public OneOf<string, RenderFragment> Subtitle { get; set; }
|
|
|
|
|
[Parameter] public OneOf<string, RenderFragment> Description { get; set; }
|
2020-03-26 15:59:24 +08:00
|
|
|
|
[Parameter] public EventCallback<MouseEventArgs> OnClick { get; set; }
|
|
|
|
|
[Parameter] public bool Disabled { get; set; }
|
2020-04-23 17:13:56 +08:00
|
|
|
|
|
2020-03-26 15:59:24 +08:00
|
|
|
|
protected override void OnInitialized()
|
|
|
|
|
{
|
2020-04-23 17:13:56 +08:00
|
|
|
|
Parent._children.Add(this);
|
|
|
|
|
this.Index = Parent._children.Count - 1;
|
2020-03-26 15:59:24 +08:00
|
|
|
|
SetClassMap();
|
|
|
|
|
if (Clickable && !Disabled)
|
|
|
|
|
{
|
2020-04-23 17:13:56 +08:00
|
|
|
|
_containerAttributes["role"] = "button";
|
2020-03-26 15:59:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-24 18:32:50 +08:00
|
|
|
|
protected override void Dispose(bool disposing)
|
2020-03-26 15:59:24 +08:00
|
|
|
|
{
|
2020-04-23 17:13:56 +08:00
|
|
|
|
Parent._children.Remove(this);
|
2020-03-26 15:59:24 +08:00
|
|
|
|
Parent.ResetChildrenSteps();
|
2020-04-24 18:32:50 +08:00
|
|
|
|
base.Dispose(disposing);
|
2020-03-26 15:59:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal int? GetTabIndex()
|
|
|
|
|
{
|
|
|
|
|
if (!Disabled && Clickable) return 0;
|
|
|
|
|
else return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void SetClassMap()
|
|
|
|
|
{
|
|
|
|
|
string prefixName = "ant-steps-item";
|
|
|
|
|
ClassMapper.Clear()
|
|
|
|
|
.Add(prefixName)
|
|
|
|
|
.If($"{prefixName}-{Status}", () => !string.IsNullOrEmpty(Status))
|
2020-04-23 17:13:56 +08:00
|
|
|
|
.If($"{prefixName}-active", () => Parent.Current == Index)
|
2020-03-26 15:59:24 +08:00
|
|
|
|
.If($"{prefixName}-disabled", () => Disabled)
|
|
|
|
|
.If($"{prefixName}-custom", () => !string.IsNullOrEmpty(Icon))
|
2020-04-23 17:13:56 +08:00
|
|
|
|
.If($"ant-steps-next-error", () => GroupStatus == "error" && Parent.Current == Index + 1)
|
2020-03-26 15:59:24 +08:00
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnParametersSet()
|
|
|
|
|
{
|
|
|
|
|
base.OnParametersSet();
|
|
|
|
|
SetClassMap();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-24 18:32:50 +08:00
|
|
|
|
internal static void MarkForCheck()
|
2020-03-26 15:59:24 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|