From 99db624b0ac7c65fb2fb64c2e0c223e8cecf52a6 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Apr 2025 09:34:55 +0800 Subject: [PATCH 01/11] =?UTF-8?q?refactor:=20=E4=BD=BF=E7=94=A8=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E8=AF=AD=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/DateTimeRange/DateTimeRange.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs b/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs index 0ede2ac4bea..783aed5357b 100644 --- a/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs +++ b/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs @@ -477,7 +477,7 @@ private void UpdateValue(DateTime d) SelectedValue.End = DateTime.MinValue; } - if (ViewMode == DatePickerViewMode.Year || ViewMode == DatePickerViewMode.Month) + if (ViewMode is DatePickerViewMode.Year or DatePickerViewMode.Month) { if (SelectedValue.Start != DateTime.MinValue) { From 92c3ae8fd84bb5086945ae11078cf18c69efef1b Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Apr 2025 09:35:06 +0800 Subject: [PATCH 02/11] =?UTF-8?q?refactor:=20=E7=B2=BE=E7=AE=80=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/DateTimeRange/DateTimeRange.razor.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs b/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs index 783aed5357b..979d2c5fb07 100644 --- a/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs +++ b/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs @@ -344,7 +344,6 @@ private async Task OnClickSidebarItem(DateTimeRangeSidebarItem item) if (AutoCloseClickSideBar) { - await InvokeVoidAsync("hide", Id); await ClickConfirmButton(); } } From a3f8dd1250d92392cdcdee7b0639d0bbfb2e9b54 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Apr 2025 09:36:43 +0800 Subject: [PATCH 03/11] =?UTF-8?q?refactor:=20=E4=BB=A3=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/DateTimeRanges.razor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor b/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor index 14cf2aa879a..7b46abbed70 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor @@ -56,7 +56,7 @@
@((MarkupString)Localizer["SidebarTip"].Value)
- +
@@ -81,7 +81,7 @@
-
From ab77eb64ba313ac6c37c81ea478c3d08fcb4487a Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Apr 2025 11:41:06 +0800 Subject: [PATCH 04/11] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A024=E8=8A=82?= =?UTF-8?q?=E6=B0=94=E5=8F=98=E9=87=8F=E5=BC=80=E5=85=B3=E5=A4=9A=E8=AF=AD?= =?UTF-8?q?=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Server/Locales/en-US.json | 7 ++++++- src/BootstrapBlazor.Server/Locales/zh-CN.json | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor.Server/Locales/en-US.json b/src/BootstrapBlazor.Server/Locales/en-US.json index bc17c834253..654363a9b31 100644 --- a/src/BootstrapBlazor.Server/Locales/en-US.json +++ b/src/BootstrapBlazor.Server/Locales/en-US.json @@ -4007,7 +4007,12 @@ "Submit": "Submit", "Limit": "time limit", "ViewModeTitle": "ViewMode", - "ViewModeIntro": "By setting ViewMode=\"DatePickerViewMode.Year\", the component view is the year view, and by setting ViewMode=\"DatePickerViewMode.Month\", the component view is the year view." + "ViewModeIntro": "By setting ViewMode=\"DatePickerViewMode.Year\", the component view is the year view, and by setting ViewMode=\"DatePickerViewMode.Month\", the component view is the year view.", + "Feature": "Feature", + "FeatureShowLunar": "Lunar", + "FeatureShowSolarTerm": "Solar Term", + "FeatureShowFestivals": "Festivals", + "FeatureShowHolidays": "Holidays" }, "BootstrapBlazor.Server.Components.Samples.Ips": { "IpNormalTitle": "Basic usage", diff --git a/src/BootstrapBlazor.Server/Locales/zh-CN.json b/src/BootstrapBlazor.Server/Locales/zh-CN.json index aa2ff96ebde..5d8b77edbdb 100644 --- a/src/BootstrapBlazor.Server/Locales/zh-CN.json +++ b/src/BootstrapBlazor.Server/Locales/zh-CN.json @@ -4007,7 +4007,12 @@ "Submit": "提交", "Limit": "时间范围", "ViewModeTitle": "显示模式", - "ViewModeIntro": "通过设置 ViewMode=\"DatePickerViewMode.Year\" 使组件视图为年视图,设置 ViewMode=\"DatePickerViewMode.Month\" 使组件视图为年视图" + "ViewModeIntro": "通过设置 ViewMode=\"DatePickerViewMode.Year\" 使组件视图为年视图,设置 ViewMode=\"DatePickerViewMode.Month\" 使组件视图为年视图", + "Feature": "功能体验区", + "FeatureShowLunar": "显示农历", + "FeatureShowSolarTerm": "24 节气", + "FeatureShowFestivals": "节日", + "FeatureShowHolidays": "法定假日" }, "BootstrapBlazor.Server.Components.Samples.Ips": { "IpNormalTitle": "基础用法", From bbcc3d9e6c2fd93b62eb0f7f56d8858c1b00d97d Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Apr 2025 12:03:17 +0800 Subject: [PATCH 05/11] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20OnDateClick?= =?UTF-8?q?=20=E5=9B=9E=E8=B0=83=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DateTimeRange/DateTimeRange.razor.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs b/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs index 979d2c5fb07..a5399465729 100644 --- a/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs +++ b/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.Localization; using System.Globalization; -using System.Reflection; namespace BootstrapBlazor.Components; @@ -252,6 +251,12 @@ public bool AllowNull [Parameter] public bool ShowHolidays { get; set; } + /// + /// Gets or sets the date value changed event callback. + /// + [Parameter] + public Func? OnDateClick { get; set; } + [Inject] [NotNull] private IStringLocalizer? Localizer { get; set; } @@ -449,7 +454,7 @@ private async Task ClickConfirmButton() /// 更新值方法 /// /// - private void UpdateValue(DateTime d) + private async Task UpdateValue(DateTime d) { if (SelectedValue.Start == DateTime.MinValue) { @@ -487,6 +492,11 @@ private void UpdateValue(DateTime d) EndValue = SelectedValue.End; } } + + if (OnDateClick != null) + { + await OnDateClick(d); + } StateHasChanged(); } From 52efa4c9b3d189854fc1c32a13347c2f8ff34c43 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Apr 2025 12:09:09 +0800 Subject: [PATCH 06/11] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A0=E8=8A=82?= =?UTF-8?q?=E6=B0=94=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/DateTimeRanges.razor | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor b/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor index 7b46abbed70..9d02916de99 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor @@ -13,9 +13,33 @@
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
builder.Services.AddBootstrapHolidayService();
+
+
- +
From f71b10afaf5ec093906cdb1e3711a806b230d2a7 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Apr 2025 12:09:27 +0800 Subject: [PATCH 07/11] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A0=20OnDateClick?= =?UTF-8?q?=20=E5=9B=9E=E8=B0=83=E6=96=B9=E6=B3=95=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/DateTimeRanges.razor.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor.cs index 06a5fe1a2d5..2b0a8b5c916 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor.cs @@ -100,6 +100,8 @@ private Task MaxMinOnValueChanged(DateTimeRangeValue val, int index) /// protected override void OnInitialized() { + base.OnInitialized(); + ValidateFormModel = new ValidateFormRangeFoo() { DateTime = DateTime.Now, @@ -148,6 +150,12 @@ private static List GetEvents() => Name = "OnValueChanged", Description="ValueChanged callback delegate", Type ="Func" + }, + new() + { + Name = "OnDateClick", + Description="Date cell click event callback", + Type ="Func" } ]; From 59d79ca1af555d510827f129f88f7d6c56e2f5b0 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Apr 2025 12:11:36 +0800 Subject: [PATCH 08/11] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20ShowSelected?= =?UTF-8?q?Value=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/DateTimeRange/DateTimeRange.razor.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs b/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs index a5399465729..60bc1b681c1 100644 --- a/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs +++ b/src/BootstrapBlazor/Components/DateTimeRange/DateTimeRange.razor.cs @@ -101,6 +101,12 @@ private string? EndValueString [Parameter] public bool AutoCloseClickSideBar { get; set; } + /// + /// Gets or sets whether show the selected value. Default is false. + /// + [Parameter] + public bool ShowSelectedValue { get; set; } + /// /// 获得/设置 清空按钮文字 /// @@ -493,6 +499,12 @@ private async Task UpdateValue(DateTime d) } } + if (ShowSelectedValue) + { + Value.Start = SelectedValue.Start; + Value.End = SelectedValue.End; + } + if (OnDateClick != null) { await OnDateClick(d); From a508a73c21ca6117727c0ceb262aa4621111b481 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Apr 2025 12:11:42 +0800 Subject: [PATCH 09/11] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/DateTimeRanges.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor b/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor index 9d02916de99..874adac8e2f 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor @@ -39,7 +39,7 @@ + ShowSelectedValue="true">
From b066d837e88691adac74ed81b44c2c3e3b1f326b Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Apr 2025 12:13:31 +0800 Subject: [PATCH 10/11] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A0=20ShowSelectedV?= =?UTF-8?q?alue=20=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/DateTimeRanges.razor.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor.cs index 2b0a8b5c916..b70f84da724 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/DateTimeRanges.razor.cs @@ -182,6 +182,14 @@ private static List GetAttributes() => DefaultValue = "false" }, new() + { + Name = nameof(DateTimeRange.ShowSelectedValue), + Description = "Whether to show the selected value", + Type = "bool", + ValueList = "true|false", + DefaultValue = "false" + }, + new() { Name = "ShowToday", Description = "Whether to show today shortcut button", From 56dc2436d5826939e693d1a467240ccb5cc6a3c4 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Apr 2025 12:24:19 +0800 Subject: [PATCH 11/11] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/DateTimeRangeTest.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/UnitTest/Components/DateTimeRangeTest.cs b/test/UnitTest/Components/DateTimeRangeTest.cs index e02bfa8988c..4c25d8250e7 100644 --- a/test/UnitTest/Components/DateTimeRangeTest.cs +++ b/test/UnitTest/Components/DateTimeRangeTest.cs @@ -78,13 +78,27 @@ public void StarEqualEnd_Ok() [Fact] public async Task RangeValue_Ok() { - var cut = Context.RenderComponent(); + var val = DateTime.Today; + var cut = Context.RenderComponent(pb => + { + pb.Add(a => a.ShowSelectedValue, true); + pb.Add(a => a.OnDateClick, d => + { + val = d; + return Task.CompletedTask; + }); + }); var cells = cut.FindAll(".date-table tbody span"); var end = cells.First(i => i.TextContent == "7"); await cut.InvokeAsync(() => { end.Click(); }); + Assert.Equal(7, val.Day); + var inputs = cut.FindAll(".datetime-range-input"); + var input = inputs[0]; + var start = val; + Assert.Equal(start.ToString("yyyy-MM-dd"), input.GetAttribute("value")); cells = cut.FindAll(".date-table tbody span"); var first = cells.First(i => i.TextContent == "1"); @@ -92,6 +106,12 @@ await cut.InvokeAsync(() => { first.Click(); }); + inputs = cut.FindAll(".datetime-range-input"); + input = inputs[0]; + Assert.Equal(val.ToString("yyyy-MM-dd"), input.GetAttribute("value")); + + input = inputs[1]; + Assert.Equal(start.ToString("yyyy-MM-dd"), input.GetAttribute("value")); // confirm var confirm = cut.FindAll(".is-confirm")[cut.FindAll(".is-confirm").Count - 1];