mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-16 01:41:14 +08:00
2a05064c25
* fix(module:DatePicker): input OnClick has new event handler * fix(module:DateTime): remove misleading reliance on picker index * fix(module: DatePicker & RangePicker): DefaultValue type change DefaultValue type change to align with Value type * fix(module:rangepicker): add default values helper with tests * fix(module:datepicker): ChangePickerValue action declaration fix Picker value is served based on input index (start/end) * fix(module:DatePicker): optimization ViewStartDate, MaxRow & MaxCol do not cause refresh if not changed * fix(module:DatePicker): min date fix ArgumentOutOfRangeException fix for dates before DateTime.MinValue * fix(module:RangePicker): sorted values Values get ordered on set * fix(module:DatePicker): OneOf switch to TValue * fix(module:DatePicker): code optimization and PickerValue fix PickerValue fix gets first panel value and evaluates second panel value * fix(module:DatePicker): default values evaluation * fix(module:RangePicker): default picker value fix * docs(module:DatePicker): switch to TValue for DefaultValue * fix(module:RangePicker): other value picker fix * fix(module:RangePicker): on value init include DefaultValue Co-authored-by: James Yeung <shunjiey@hotmail.com>
57 lines
2.2 KiB
C#
57 lines
2.2 KiB
C#
@namespace AntDesign.Internal
|
|
@typeparam TValue
|
|
@inherits DatePickerPanelBase<TValue>
|
|
@using System.Globalization;
|
|
|
|
@{
|
|
var calendar = CultureInfo.InvariantCulture.Calendar;
|
|
|
|
int startYear = PickerValue.Year / 10 * 10 - 1;
|
|
DateTime startDate;
|
|
if (startYear > 0)
|
|
startDate = new DateTime(startYear, 1, 1);
|
|
else
|
|
startDate = DateTime.MinValue;
|
|
|
|
int yearIndex = 0;
|
|
}
|
|
<div class='@($"{PrefixCls}-panel")'>
|
|
<DatePickerTemplate @attributes="GetAttritubes()"
|
|
TValue="TValue"
|
|
MaxRow="MAX_ROW"
|
|
MaxCol="MAX_COL"
|
|
ViewStartDate="startDate"
|
|
IsInView="date => IsInView(date, startDate)"
|
|
IsToday="date => DateHelper.IsSameYear(date, DatePicker.CurrentDate)"
|
|
IsSelected="date => DateHelper.IsSameYear(date, Value)"
|
|
GetColTitle='date => date.ToString(Locale.Lang.YearFormat, CultureInfo)'
|
|
OnValueSelect="date => OnSelectYear(date)"
|
|
GetNextColValue="date => date.AddYears(1)">
|
|
<RenderPickerHeader>
|
|
<DatePickerHeader @attributes="GetAttritubes()"
|
|
TValue="TValue"
|
|
SuperChangeDateInterval="10"
|
|
ShowPreChange="@false"
|
|
ShowNextChange="@false"
|
|
ShowSuperPreChange="@(!(IsRange && PickerIndex == 1))"
|
|
ShowSuperNextChange="@(!(IsRange && PickerIndex == 0))" />
|
|
</RenderPickerHeader>
|
|
<RenderColValue Context="currentColDate">
|
|
@{yearIndex++;}
|
|
@currentColDate.Year
|
|
</RenderColValue>
|
|
</DatePickerTemplate>
|
|
</div>
|
|
|
|
@code {
|
|
private const int MAX_ROW = 4;
|
|
private const int MAX_COL = 3;
|
|
private const int FIRST_YEAR_INDEX = 0;
|
|
private const int LAST_YEAR_INDEX = MAX_ROW * MAX_COL - 1;
|
|
|
|
private bool IsInView(DateTime date, DateTime startDate)
|
|
{
|
|
return date.Year != startDate.AddYears(FIRST_YEAR_INDEX).Year
|
|
&& date.Year != startDate.AddYears(LAST_YEAR_INDEX).Year;
|
|
}
|
|
} |