From 990fd19dd99267c922d11fe6b2b0aa80a9d88533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=99=93=E6=A0=8B?= <36178221+berkerdong@users.noreply.github.com> Date: Sun, 5 Mar 2023 18:02:48 +0800 Subject: [PATCH 1/9] fix(module: tabs): rewrite the logic of ReuseTabs about tab key (#3153) --- components/tabs/Reuse/ReuseTabs.razor.cs | 23 +++-------------------- components/tabs/Reuse/ReuseTabsService.cs | 9 +++------ 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/components/tabs/Reuse/ReuseTabs.razor.cs b/components/tabs/Reuse/ReuseTabs.razor.cs index 5ded271c3d..4a5cc999b6 100644 --- a/components/tabs/Reuse/ReuseTabs.razor.cs +++ b/components/tabs/Reuse/ReuseTabs.razor.cs @@ -39,8 +39,8 @@ public partial class ReuseTabs : AntDomComponentBase private string CurrentUrl { - get => GetNewKeyByUrl(Navmgr.ToBaseRelativePath(Navmgr.Uri)); - set => Navmgr.NavigateTo(value); + get => Navmgr.ToBaseRelativePath(Navmgr.Uri) == "" ? "/" : Navmgr.ToBaseRelativePath(Navmgr.Uri); + set => Navmgr.NavigateTo(value == "/" ? "" : value); } private ReuseTabsPageItem[] Pages => _pageMap.Values.Where(x => !x.Ignore).OrderBy(x => x.CreatedAt).ToArray(); @@ -52,8 +52,6 @@ public ReuseTabs() protected override void OnInitialized() { - ReuseTabsService.GetNewKeyByUrl += GetNewKeyByUrl; - ReuseTabsService.OnClosePage += RemovePage; ReuseTabsService.OnCloseOther += RemoveOther; ReuseTabsService.OnCloseAll += RemoveAll; @@ -63,8 +61,6 @@ protected override void OnInitialized() protected override void Dispose(bool disposing) { - ReuseTabsService.GetNewKeyByUrl -= GetNewKeyByUrl; - ReuseTabsService.OnClosePage -= RemovePage; ReuseTabsService.OnCloseOther -= RemoveOther; ReuseTabsService.OnCloseAll -= RemoveAll; @@ -184,8 +180,6 @@ private void ScanReuseTabsPageAttribute() public void AddReuseTabsPageItem(string url, Type pageType) { - url = this.GetNewKeyByUrl(url); - if (_pageMap.ContainsKey(url)) return; var reuseTabsPageItem = new ReuseTabsPageItem(); @@ -235,10 +229,7 @@ private void UpdateState() StateHasChanged(); } - private string GetNewKeyByUrl(string url) - { - return GetNewKeyByUrlBase(url); - } + public void RemovePageBase(string key) { @@ -256,13 +247,5 @@ public void RemovePageWithRegex(string pattern) } } - public string GetNewKeyByUrlBase(string url) - { - if (url == "") - { - url = "/"; - } - return url; - } } } diff --git a/components/tabs/Reuse/ReuseTabsService.cs b/components/tabs/Reuse/ReuseTabsService.cs index 9f035c7b7d..34573712cf 100644 --- a/components/tabs/Reuse/ReuseTabsService.cs +++ b/components/tabs/Reuse/ReuseTabsService.cs @@ -3,9 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.AspNetCore.Components; namespace AntDesign { @@ -21,16 +18,16 @@ public partial class ReuseTabsService internal event Action OnUpdate; - internal event Func GetNewKeyByUrl; + public void ClosePage(string key) { - OnClosePage?.Invoke(GetNewKeyByUrl?.Invoke(key)); + OnClosePage?.Invoke(key); } public void CloseOther(string key) { - OnCloseOther?.Invoke(GetNewKeyByUrl.Invoke(key)); + OnCloseOther?.Invoke(key); } public void CloseAll() From c192eece54ecd1fedd7e358a170f0d4b15468097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=99=93=E6=A0=8B?= <36178221+berkerdong@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:00:54 +0800 Subject: [PATCH 2/9] fix(module: checkbox): CheckboxGroup will report an error when the internal Checkbox is null (#3162) --- components/checkbox/CheckboxGroup.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/checkbox/CheckboxGroup.razor.cs b/components/checkbox/CheckboxGroup.razor.cs index 6a6c0b4718..fe42b96e1a 100644 --- a/components/checkbox/CheckboxGroup.razor.cs +++ b/components/checkbox/CheckboxGroup.razor.cs @@ -173,7 +173,7 @@ protected override void OnAfterRender(bool firstRender) { if (firstRender) { - if (ChildContent is not null && _checkboxItems.Count > 0) + if (ChildContent is not null && _checkboxItems?.Count > 0) { _constructedOptions = CreateConstructedOptions(); } From 8db4f8b2a451bc63340ce5434ea3320680d3cbec Mon Sep 17 00:00:00 2001 From: James Yeung Date: Fri, 10 Mar 2023 16:50:15 +0800 Subject: [PATCH 3/9] fix(module: table): the filter of column with the flags enum type place incorrectly (#3168) --- components/table/Column.razor | 3 ++- components/table/Column.razor.cs | 14 +++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/components/table/Column.razor b/components/table/Column.razor index e5b1216251..a30595355b 100644 --- a/components/table/Column.razor +++ b/components/table/Column.razor @@ -338,7 +338,8 @@ else if (IsBody && RowSpan != 0 && ColSpan != 0) } else if (_columnDataType.IsEnum) { - (); - - foreach (var enumValue in Enum.GetValues(_columnDataType)) + _filters = EnumHelper.GetValueLabelList().Select(item => { - var enumName = Enum.GetName(_columnDataType, enumValue); var filterOption = GetNewFilter(); - // use DisplayAttribute only, DisplayNameAttribute is not valid for enum values - filterOption.Text = _columnDataType.GetMember(enumName)[0].GetCustomAttribute()?.Name ?? enumName; - filterOption.Value = enumValue; - ((List)_filters).Add(filterOption); - } + filterOption.Text = item.Label; + filterOption.Value = item.Value; + return filterOption; + }).ToList(); } else { From cc235c8d451c75015259590b47e56d8218ebae5d Mon Sep 17 00:00:00 2001 From: James Yeung Date: Fri, 10 Mar 2023 22:53:48 +0800 Subject: [PATCH 4/9] fix(module: image): preview operations would be covered by the preview image (#3170) --- components/image/ImagePreview.razor | 64 ++++++++++++++++----------- components/modal/core/Dialog.razor | 4 ++ components/modal/core/Dialog.razor.cs | 32 +++++++------- 3 files changed, 58 insertions(+), 42 deletions(-) diff --git a/components/image/ImagePreview.razor b/components/image/ImagePreview.razor index 8d1561163a..eab751abb1 100644 --- a/components/image/ImagePreview.razor +++ b/components/image/ImagePreview.razor @@ -1,33 +1,43 @@ @namespace AntDesign -
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
-
- -
- @if (ImageRef.ImageCount > 1) - { -
- + +
+
-
- + @if (ImageRef.ImageCount > 1) + { +
+ +
+
+ +
+ } + + +
+
    + @if (ImageRef.ImageCount > 1) + { +
  • @(ImageRef.CurrentIndex+1) / @ImageRef.ImageCount
  • + } +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
- } +
\ No newline at end of file diff --git a/components/modal/core/Dialog.razor b/components/modal/core/Dialog.razor index e43baf31fa..40b1547610 100644 --- a/components/modal/core/Dialog.razor +++ b/components/modal/core/Dialog.razor @@ -85,4 +85,8 @@ + @if (AdditionalContent != null) + { + @AdditionalContent + } diff --git a/components/modal/core/Dialog.razor.cs b/components/modal/core/Dialog.razor.cs index cde79bbd07..8d0b5c48b4 100644 --- a/components/modal/core/Dialog.razor.cs +++ b/components/modal/core/Dialog.razor.cs @@ -24,12 +24,15 @@ public partial class Dialog [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] + public RenderFragment AdditionalContent { get; set; } + [Parameter] public bool Visible { get; set; } #pragma warning restore 1591 - #endregion + #endregion Parameters [CascadingParameter(Name = "DialogWrapperId")] public string DialogWrapperId { get; set; } = ""; @@ -45,6 +48,7 @@ public partial class Dialog private bool _doDraggable; #pragma warning disable 649 + /// /// dialog root container /// @@ -58,6 +62,7 @@ public partial class Dialog #region ant-modal style private string _modalStyle = null; + /// /// ant-modal style /// @@ -95,7 +100,6 @@ private string CalcModalStyle() return style + Style + ";"; } - private string GetBodyStyle() { var style = Config.BodyStyle; @@ -120,7 +124,7 @@ internal async Task TryResetModalStyle() } } - #endregion + #endregion ant-modal style /// /// append To body @@ -160,7 +164,7 @@ private async Task OnMaskClick() } } - #endregion + #endregion mask and dialog click event #region keyboard control @@ -168,6 +172,7 @@ private async Task OnMaskClick() /// TAB keyboard control /// private readonly string _sentinelStart = IdPrefix + Guid.NewGuid().ToString(); + private readonly string _sentinelEnd = IdPrefix + Guid.NewGuid().ToString(); /// @@ -207,7 +212,7 @@ private async Task OnKeyDown(KeyboardEventArgs e) } } - #endregion + #endregion keyboard control /// /// closer(X) click event @@ -249,7 +254,6 @@ private Task OnMaxBtnClick() return Task.CompletedTask; } - private void SetModalStatus(ModalStatus modalStatus) { _modalStatus = modalStatus; @@ -257,7 +261,6 @@ private void SetModalStatus(ModalStatus modalStatus) _modalStyle = CalcModalStyle(); } - #region control show and hide class name and style /// @@ -312,7 +315,6 @@ internal async Task CleanShowAnimationAsync() await InvokeStateHasChangedAsync(); } - /// /// Hide Dialog through animation /// @@ -339,7 +341,6 @@ internal async Task Hide() await Config.OnClosed.Invoke(); } } - } /// @@ -351,7 +352,7 @@ public bool IsShow() return _hasShow; } - #endregion + #endregion control show and hide class name and style #region build element's class name @@ -365,18 +366,18 @@ private string GetMaskClsName() private string GetModalClsName() { var clsName = Config.ClassName; - return clsName + _modalAnimationClsName + return clsName + _modalAnimationClsName + (_modalStatus == ModalStatus.Max ? " ant-modal-max" : ""); } - #endregion + #endregion build element's class name #region override private bool _hasRendered = false; /// - /// + /// /// /// protected override async Task OnParametersSetAsync() @@ -407,7 +408,7 @@ protected override async Task OnParametersSetAsync() } /// - /// + /// /// /// /// @@ -456,7 +457,8 @@ protected override async Task OnAfterRenderAsync(bool isFirst) await base.OnAfterRenderAsync(isFirst); } - #endregion + + #endregion override protected override void Dispose(bool disposing) { From e6c21671bcd9457ca276db85c5073ed37c14f49c Mon Sep 17 00:00:00 2001 From: James Yeung Date: Sat, 11 Mar 2023 13:04:56 +0800 Subject: [PATCH 5/9] fix(module: select): empty incorrectly in virtualization mode (#3171) --- components/select/Select.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/select/Select.razor b/components/select/Select.razor index a0b580c5ea..986180522d 100644 --- a/components/select/Select.razor +++ b/components/select/Select.razor @@ -59,7 +59,7 @@ } - else if (SelectOptions == null) + else if (SelectOptions == null && !AllOptionsHidden()) {
From 2fa56e1c13e4c2b83009dcb55b30d928c8ce3dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=99=93=E6=A0=8B?= <36178221+berkerdong@users.noreply.github.com> Date: Wed, 22 Mar 2023 21:54:37 +0800 Subject: [PATCH 6/9] fix(module: input): read spaces or empty strings as null (#3190) --- components/core/Base/AntInputComponentBase.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/components/core/Base/AntInputComponentBase.cs b/components/core/Base/AntInputComponentBase.cs index cba989a285..a9d9a5c5b0 100644 --- a/components/core/Base/AntInputComponentBase.cs +++ b/components/core/Base/AntInputComponentBase.cs @@ -226,13 +226,6 @@ protected virtual string FormatValueAsString(TValue value) /// True if the value could be parsed; otherwise false. protected virtual bool TryParseValueFromString(string value, out TValue result, out string validationErrorMessage) { - if (string.IsNullOrWhiteSpace(value)) - { - result = default; - validationErrorMessage = null; - return true; - } - TValue parsedValue = default; bool success; From f8e51dbccdf687034d8d4f94a9fda5f644a12d9b Mon Sep 17 00:00:00 2001 From: Alex Kryvdyk Date: Wed, 22 Mar 2023 15:58:52 +0200 Subject: [PATCH 7/9] fix:(module: datepicker): un-representable DateTime when day > daysInMonth (#3193) --- components/core/Helpers/DateHelper.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/core/Helpers/DateHelper.cs b/components/core/Helpers/DateHelper.cs index d626f2d879..d5914c5df8 100644 --- a/components/core/Helpers/DateHelper.cs +++ b/components/core/Helpers/DateHelper.cs @@ -158,7 +158,13 @@ public static DateTime GetNextStartDateOfDay(DateTime date) int? minute = null, int? second = null) { - return new DateTime(year ?? date.Year, month ?? date.Month, day ?? date.Day, hour ?? date.Hour, minute ?? date.Minute, second ?? date.Second); + var yearValue = year ?? date.Year; + var monthValue = month ?? date.Month; + var dayValue = day ?? date.Day; + var daysInMonth = DateTime.DaysInMonth(yearValue, monthValue); + dayValue = dayValue > daysInMonth ? daysInMonth : dayValue; + + return new DateTime(yearValue, monthValue, dayValue, hour ?? date.Hour, minute ?? date.Minute, second ?? date.Second); } public static DateTime? FormatDateByPicker(DateTime? dateTime, string picker) From ab3e3c0844d954be848ead45b962df547b743ba7 Mon Sep 17 00:00:00 2001 From: James Yeung Date: Thu, 6 Apr 2023 23:14:27 +0800 Subject: [PATCH 8/9] feat(module: typography): refactor & support editable (#3173) * feat(module: typography): support editable * fix tests --- components/input/TextArea.razor | 55 +++--- components/input/TextArea.razor.cs | 12 +- components/typography/Link.cs | 59 +------ components/typography/Paragraph.cs | 65 +------ components/typography/Text.cs | 58 +------ components/typography/Title.cs | 49 +----- components/typography/TypographyBase.cs | 163 +++++++++++++++++- .../Typography/demo/Interactive.razor | 51 ++++-- tests/AntDesign.Tests/Typography/LinkTests.cs | 21 +-- .../Typography/ParagraphTests.cs | 68 ++++---- tests/AntDesign.Tests/Typography/TextTests.cs | 21 ++- .../AntDesign.Tests/Typography/TitleTests.cs | 24 +-- 12 files changed, 298 insertions(+), 348 deletions(-) diff --git a/components/input/TextArea.razor b/components/input/TextArea.razor index 015bcea8ab..fb0e0a1533 100644 --- a/components/input/TextArea.razor +++ b/components/input/TextArea.razor @@ -39,29 +39,34 @@ } } -
- @if (Suffix != null || AllowClear || FormItem?.FeedbackIcon != null) - { - - +
+
+
  • + Test User +
  • +
    "); + } + + [Fact] + public void StandardRender_ShouldCallJavascriptCallbackToDisplayOverlayWhenTypingAtSymbol() + { + SetupJavascript(); + var systemUnderTest = GetStandardRenderSystemUnderTest(); + + JSInterop.Setup("AntDesign.interop.mentionsHelper.setPopShowFlag", true); + + systemUnderTest.Find("textarea").Input("@"); + + JSInterop.VerifyInvoke("AntDesign.interop.mentionsHelper.setPopShowFlag", 1); + } + + [Fact] + public void TemplatedRender_ShouldCallJavascriptCallbackToDisplayOverlayWhenTypingAtSymbol() + { + SetupJavascript(); + var systemUnderTest = GetStandardRenderSystemUnderTest(); + + JSInterop.Setup("AntDesign.interop.mentionsHelper.setPopShowFlag", true); + + systemUnderTest.Find("textarea").Input("@"); + + JSInterop.VerifyInvoke("AntDesign.interop.mentionsHelper.setPopShowFlag", 1); + } + +#if NET6_0_OR_GREATER + private IRenderedComponent GetTemplatedRenderSystemUnderTest() + { + JSInterop.Setup("AntDesign.interop.inputHelper.getTextAreaInfo", _ => true); + + return Render( + @ + + Test User + + + +
    +
    +
  • + Test User +
  • +
    "); + } +#endif +} \ No newline at end of file