ant-design-blazor/components/calendar/internal/CalendarPanelChooser.razor

65 lines
2.5 KiB
C#

@namespace AntDesign.Internal
@inherits AntDomComponentBase
@{
Action ClosePanel = () => { };
Action<DateTime, int?> ChangePickerValue = async (date, index) => { await Calendar.ChangeValue(date); };
Action<DateTime, int> ChangeValue = async (date, index) => { await Calendar.ChangeValue(date); };
Action<string, int> ChangePickerType = (type, index) => { Calendar.ChangePickerType(type, index); };
Func<int, DateTime> GetIndexPickerValue = (index) => Calendar.Value;
Func<int, DateTime?> GetIndexValue = (index) => Calendar.Value;
Dictionary<string, object> attributes =
new Dictionary<string, object>()
{
{ "PrefixCls", "ant-picker" },
{ "Picker", Calendar.Picker },
{ "Locale", Calendar.Locale },
{ "CultureInfo", Calendar.CultureInfo },
{ "ClosePanel", ClosePanel },
{ "ChangePickerValue", ChangePickerValue },
{ "ChangeValue", ChangeValue },
{ "ChangePickerType", ChangePickerType },
{ "GetIndexPickerValue", GetIndexPickerValue },
{ "GetIndexValue", GetIndexValue },
{ "DisabledDate", Calendar.DisabledDate },
{ "DateRender", Calendar.DateFullCellRender },
{ "MonthCellRender", Calendar.MonthFullCellRender },
{ "CalendarDateRender", Calendar.DateCellRender },
{ "CalendarMonthCellRender", Calendar.MonthCellRender },
{ "OnSelect", OnSelect },
{ "PickerIndex", 0 },
{ "IsCalendar", true },
{ "IsShowHeader", false },
};
Dictionary<string, object> dateAttributes = new Dictionary<string, object>(attributes);
dateAttributes.Add("ShowToday", false);
}
<CascadingValue Value=@Calendar>
@if (IsShowDatePanel())
{
<DatePickerDatePanel TValue="DateTime" @attributes="dateAttributes" />
}
else if (IsShowQuarterPanel())
{
<DatePickerQuarterPanel TValue="DateTime" @attributes="attributes" />
}
else if (IsShowWeekPanel())
{
<DatePickerDatePanel TValue="DateTime" @attributes="dateAttributes" IsWeek="@true" />
}
else if (IsShowMonthPanel())
{
<DatePickerMonthPanel TValue="DateTime" @attributes="attributes" />
}
else if (IsShowYearPanel())
{
<DatePickerYearPanel TValue="DateTime" @attributes="attributes" />
}
else if (IsShowDecadePanel())
{
<DatePickerDecadePanel TValue="DateTime" @attributes="attributes" />
}
</CascadingValue>