From 91a120efa19c801011ec9962fb47e6ba2b0c65d3 Mon Sep 17 00:00:00 2001 From: Glen Blanchard Date: Sat, 9 Sep 2023 08:11:57 +1000 Subject: [PATCH 01/40] fixes #597 [HxCalendar] + [HxInputDate*] Add TimeProvider --- .../HxCalendarComponents/ZonedTimeProvider.cs | 55 ++++++++++++++++++ .../Pages/HxCalendar_Issue597_Test.razor | 58 +++++++++++++++++++ BlazorAppTest/Startup.cs | 3 + .../HxCalendar_Documentation.razor | 20 +++++++ ...HxCalendar_RegisterServices.CodeSnippet.cs | 39 +++++++++++++ ...xCalendar_ZonedTimeProvider.CodeSnippet.cs | 16 +++++ ...endar_ZonedTimeProvider.CodeSnippet.csproj | 3 + .../HxInputDate_Documentation.razor | 5 ++ .../HxInputDateRange_Documentation.razor | 5 ++ .../Havit.Blazor.Components.Web.Bootstrap.xml | 36 ++++++++++++ .../Calendar/HxCalendar.razor.cs | 28 ++++++++- .../Forms/HxInputDate.cs | 9 +++ .../Forms/HxInputDateRange.cs | 9 +++ .../Forms/Internal/HxInputDateInternal.razor | 2 +- .../Internal/HxInputDateInternal.razor.cs | 8 +++ .../Internal/HxInputDateRangeInternal.razor | 4 +- .../HxInputDateRangeInternal.razor.cs | 2 + ...vit.Blazor.Components.Web.Bootstrap.csproj | 1 + .../Havit.Blazor.Components.Web.csproj | 1 + .../ServiceCollectionExtensions.cs | 2 + 20 files changed, 301 insertions(+), 5 deletions(-) create mode 100644 BlazorAppTest/Pages/HxCalendarComponents/ZonedTimeProvider.cs create mode 100644 BlazorAppTest/Pages/HxCalendar_Issue597_Test.razor create mode 100644 Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_RegisterServices.CodeSnippet.cs create mode 100644 Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.cs create mode 100644 Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.csproj diff --git a/BlazorAppTest/Pages/HxCalendarComponents/ZonedTimeProvider.cs b/BlazorAppTest/Pages/HxCalendarComponents/ZonedTimeProvider.cs new file mode 100644 index 00000000..59363234 --- /dev/null +++ b/BlazorAppTest/Pages/HxCalendarComponents/ZonedTimeProvider.cs @@ -0,0 +1,55 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.WebUtilities; + +namespace BlazorAppTest.Pages.HxCalendarComponents; + +public class ZonedTimeProvider : TimeProvider, IDisposable +{ + private TimeZoneInfo zoneInfo; + private readonly NavigationManager? navigationManager; + + public ZonedTimeProvider(TimeZoneInfo zoneInfo) + { + this.zoneInfo = zoneInfo; + } + + public ZonedTimeProvider(NavigationManager navigationManager) : base() + { + this.navigationManager = navigationManager; + navigationManager.LocationChanged += NavigationManager_LocationChanged; + Update(); + } + + private void NavigationManager_LocationChanged(object sender, Microsoft.AspNetCore.Components.Routing.LocationChangedEventArgs e) + { + Update(); + } + + private void Update() + { + TimeZoneInfo? zoneInfo = null; + try + { + var uri = navigationManager?.ToAbsoluteUri(navigationManager.Uri); + if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("tz", out var vals)) + { + zoneInfo = TimeZoneInfo.FindSystemTimeZoneById(vals.FirstOrDefault() ?? "Not Found"); + } + } + catch (Exception) + { + // Ignore and fallback to local timezone + } + this.zoneInfo = zoneInfo ?? TimeZoneInfo.Local; + } + public override TimeZoneInfo LocalTimeZone { get => zoneInfo; } + public static TimeProvider FromLocalTimeZone(TimeZoneInfo zoneInfo) => new ZonedTimeProvider(zoneInfo); + + public void Dispose() + { + if (navigationManager != null) + { + navigationManager.LocationChanged -= NavigationManager_LocationChanged; + } + } +} \ No newline at end of file diff --git a/BlazorAppTest/Pages/HxCalendar_Issue597_Test.razor b/BlazorAppTest/Pages/HxCalendar_Issue597_Test.razor new file mode 100644 index 00000000..773836ab --- /dev/null +++ b/BlazorAppTest/Pages/HxCalendar_Issue597_Test.razor @@ -0,0 +1,58 @@ +@page "/HxCalendar_Issue597_Test" +@using BlazorAppTest.Pages.HxCalendarComponents; +@implements IDisposable +@inject NavigationManager NavigationManager +@inject IServiceProvider ServiceProvider +

HxCalendar

+
+ +

+ American Samoa | + Samoa | + System +

+
+ +
+
+ + +
+ +
+
+
+ +
+ +
+
+ +@code { + TimeProvider cascadingTimeProvider = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("UTC-11")); + TimeProvider parameterTimeProvider = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("Samoa Standard Time")); + TimeProvider diOrSystemTimeProvider; + + public override Task SetParametersAsync(ParameterView parameters) + { + diOrSystemTimeProvider = ServiceProvider.GetService() ?? TimeProvider.System; + + NavigationManager.LocationChanged += HandleNavigation; + return base.SetParametersAsync(parameters); + } + + protected override void OnInitialized() + { + base.OnInitialized(); + } + + protected void HandleNavigation(object sender, LocationChangedEventArgs ev) + { + StateHasChanged(); + } + + public void Dispose() + { + NavigationManager.LocationChanged -= HandleNavigation; + } +} diff --git a/BlazorAppTest/Startup.cs b/BlazorAppTest/Startup.cs index 0b6e85a3..4dfeed25 100644 --- a/BlazorAppTest/Startup.cs +++ b/BlazorAppTest/Startup.cs @@ -1,5 +1,6 @@ using System.Globalization; using BlazorAppTest.Resources; +using BlazorAppTest.Pages.HxCalendarComponents; using Havit.Blazor.Components.Web; using Havit.Blazor.GoogleTagManager; @@ -26,6 +27,8 @@ public void ConfigureServices(IServiceCollection services) services.AddRazorPages(); services.AddServerSideBlazor(); + services.AddScoped(); + services.AddHxServices(); services.AddHxMessenger(); services.AddHxMessageBoxHost(); services.AddHxGoogleTagManager(options => diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor index 21d60e60..980ec949 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor @@ -20,6 +20,26 @@ HxCalendar is used in implementation of HxInputDate and HxInputDateRange components. See their documentation for more info.

+ + +

+ You can change the timezone used by the calendar by providing a custom TimeZoneProvider. + TimeProvider is resolved in the following order: +

    +
  1. TimeProvider parameter on HxCalendar, HxInputDate and HxInputDateRange.
  2. +
  3. By using a CascadingValue.
  4. +
  5. Adding a TimeProvider service via dependency injection.
  6. +
  7. The default TimeProvider.System time provider.
  8. +
+

+

+ One use for this is for server rendered blazor components where the server local timezone is different to the client timezone. + See the following smaple: +

+ +

Then add the following to your Program.cs. Please expand to provide appropriate error handling, caching, etc. depending on your needs.

+ + diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_RegisterServices.CodeSnippet.cs b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_RegisterServices.CodeSnippet.cs new file mode 100644 index 00000000..c5e24ddc --- /dev/null +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_RegisterServices.CodeSnippet.cs @@ -0,0 +1,39 @@ +using Havit.Blazor.Components.Web; // <------ ADD THIS LINE +using Havit.Blazor.Components.Web.Bootstrap; // <------ ADD THIS LINE +using System; // <------ ADD THIS LINE + +public static async Task Main(string[] args) +{ + var builder = WebAssemblyHostBuilder.CreateDefault(args); + builder.RootComponents.Add("app"); + + // ... shortened for brevity + + // So the provider can access the context + builder.Services.AddHttpContextAccessor(); // <------ ADD THIS LINE + + // Do this before AddHxServices + builder.Services.AddScoped(provider => // <------ ADD THIS BLOCK + { + NavigationManager? navigationManager = provider.GetService(); + TimeZoneInfo ? requestTimeZoneInfo = null; + try + { + var uri = navigationManager?.ToAbsoluteUri(navigationManager.Uri); + if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("tz", out var vals)) + { + requestTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(vals.FirstOrDefault() ?? "Not Found"); + } + } + catch (Exception) + { + // Ignore and fallback to local timezone + } + requestTimeZoneInfo ??= TimeZoneInfo.Local; + return ZonedTimeProvider(requestTimeZoneInfo); + }); + + builder.Services.AddHxServices(); // <------ ADD THIS LINE + + await builder.Build().RunAsync(); +} \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.cs b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.cs new file mode 100644 index 00000000..ada1f641 --- /dev/null +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.cs @@ -0,0 +1,16 @@ +using System; + +public class ZonedTimeProvider +{ + // Create a time provider that work with a time zone different than the local time zone + public class ZonedTimeProvider : TimeProvider + { + private TimeZoneInfo _zoneInfo; + public ZonedTimeProvider(TimeZoneInfo zoneInfo) : base() + { + _zoneInfo = zoneInfo ?? TimeZoneInfo.Local; + } + public override TimeZoneInfo LocalTimeZone { get => _zoneInfo; } + public static TimeProvider FromLocalTimeZone(TimeZoneInfo zoneInfo) => new ZonedTimeProvider(zoneInfo); + } +} diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.csproj b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.csproj new file mode 100644 index 00000000..050f4dc7 --- /dev/null +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.csproj @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateDoc/HxInputDate_Documentation.razor b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateDoc/HxInputDate_Documentation.razor index 864001a9..b23b3249 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateDoc/HxInputDate_Documentation.razor +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateDoc/HxInputDate_Documentation.razor @@ -37,4 +37,9 @@ (Enabled="false") or set specific CSS class (CssClass="...").

+ + +

+ You can customize the dropdown calendar timezone by supplying a custom TimeProvider. See HxCalendar TimeZones for more details. +

\ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateRangeDoc/HxInputDateRange_Documentation.razor b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateRangeDoc/HxInputDateRange_Documentation.razor index 374f7979..3fd476c9 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateRangeDoc/HxInputDateRange_Documentation.razor +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateRangeDoc/HxInputDateRange_Documentation.razor @@ -36,4 +36,9 @@ (Enabled="false") or set specific CSS class (CssClass="...").

+ + +

+ You can customize the dropdown calendar timezone by supplying a custom TimeProvider. See HxCalendar TimeZones for more details. +

\ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml b/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml index 7f0a1ebf..56d1269f 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml @@ -735,6 +735,15 @@ Default is true (tabindex attribute is not rendered). + + + TimeProvider is resolved in the following order: + 1. TimeProvider from this parameter + 2. TimeProvider from a CascadingValue + 3. TimeProvider from DependencyInjection + 4. Default TimeProvider.System + + Refreshes the calendar. @@ -2695,6 +2704,15 @@ Input-group at the end of the input. + + + TimeProvider is resolved in the following order: + 1. TimeProvider from this parameter + 2. TimeProvider from a CascadingValue + 3. TimeProvider from DependencyInjection + 4. Default TimeProvider.System + + @@ -3875,6 +3893,15 @@ Input-group at the end of the input. + + + TimeProvider is resolved in the following order: + 1. TimeProvider from this parameter + 2. TimeProvider from a CascadingValue + 3. TimeProvider from DependencyInjection + 4. Default TimeProvider.System + + @@ -3975,6 +4002,15 @@ Default customization is configurable with . + + + TimeProvider is resolved in the following order: + 1. TimeProvider from this parameter + 2. TimeProvider from a CascadingValue + 3. TimeProvider from DependencyInjection + 4. Default TimeProvider.System + + diff --git a/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs index 5e610f54..0226a9b8 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs @@ -1,4 +1,5 @@ using System.Globalization; +using Microsoft.Extensions.DependencyInjection; namespace Havit.Blazor.Components.Web.Bootstrap; @@ -105,6 +106,22 @@ static HxCalendar() /// [Parameter] public bool KeyboardNavigation { get; set; } = true; + // Set during SetParameterSetAsync to make it optional + protected TimeProvider? TimeProviderFromServices { get; set; } + [CascadingParameter] protected TimeProvider? TimeProviderFromCascade { get; set; } = null; + /// + /// TimeProvider is resolved in the following order: + /// 1. TimeProvider from this parameter + /// 2. TimeProvider from a CascadingValue + /// 3. TimeProvider from DependencyInjection + /// 4. Default TimeProvider.System + /// + [Parameter] public TimeProvider? TimeProvider { get; set; } = null; + + protected TimeProvider TimeProviderEffective => TimeProvider ?? TimeProviderFromCascade ?? TimeProviderFromServices ?? TimeProvider.System; + + [Inject] protected IServiceProvider ServiceProvider { get; set; } + private CultureInfo Culture => CultureInfo.CurrentUICulture; private DayOfWeek FirstDayOfWeek => Culture.DateTimeFormat.FirstDayOfWeek; protected DateTime DisplayMonthFirstDay => new DateTime(DisplayMonth.Year, DisplayMonth.Month, 1); @@ -129,6 +146,13 @@ protected DateTime FirstDayToDisplay private RenderData renderData; private DateTime? lastKnownValue; + public override Task SetParametersAsync(ParameterView parameters) + { + TimeProviderFromServices = ServiceProvider.GetService(); + return base.SetParametersAsync(parameters); + + } + protected override async Task OnParametersSetAsync() { await base.OnParametersSetAsync(); @@ -138,7 +162,7 @@ protected override async Task OnParametersSetAsync() if (DisplayMonth == default) { - await SetDisplayMonthAsync(Value ?? DateTime.Today); + await SetDisplayMonthAsync(Value ?? TimeProviderEffective.GetLocalNow().Date); } else if ((Value != null) && lastKnownValueChanged && ((DisplayMonth.Year != Value.Value.Year) || (DisplayMonth.Month != Value.Value.Month))) { @@ -191,7 +215,7 @@ private void UpdateRenderData() DateTime currentDay = FirstDayToDisplay; DateTime valueDay = Value?.Date ?? default; - DateTime today = DateTime.Today; + DateTime today = TimeProviderEffective.GetLocalNow().Date; for (var week = 0; week < 6; week++) { diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs index bd394c65..eedafe0d 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs @@ -124,6 +124,14 @@ public class HxInputDate : HxInputBase, IInputWithPlaceholder, I /// Input-group at the end of the input. /// [Parameter] public RenderFragment InputGroupEndTemplate { get; set; } + /// + /// TimeProvider is resolved in the following order: + /// 1. TimeProvider from this parameter + /// 2. TimeProvider from a CascadingValue + /// 3. TimeProvider from DependencyInjection + /// 4. Default TimeProvider.System + /// + [Parameter] public TimeProvider? TimeProvider { get; set; } = null; [Inject] private IStringLocalizer StringLocalizer { get; set; } @@ -169,6 +177,7 @@ protected virtual void BuildRenderInputCore(RenderTreeBuilder builder) builder.AddAttribute(211, nameof(HxInputDateInternal.CalendarDateCustomizationProviderEffective), CalendarDateCustomizationProviderEffective); builder.AddAttribute(212, nameof(HxInputDateInternal.LabelTypeEffective), labelTypeEffective); builder.AddAttribute(213, nameof(HxInputDateInternal.FormValueComponent), this); + builder.AddAttribute(214, nameof(HxInputDateInternal.TimeProvider), TimeProvider); builder.AddAttribute(214, nameof(HxInputDateInternal.InputGroupStartText), this.InputGroupStartText); builder.AddAttribute(215, nameof(HxInputDateInternal.InputGroupEndText), this.InputGroupEndText); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs index 0106d5a4..f6da7af1 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs @@ -105,6 +105,14 @@ static HxInputDateRange() /// [Parameter] public CalendarDateCustomizationProviderDelegate CalendarDateCustomizationProvider { get; set; } protected CalendarDateCustomizationProviderDelegate CalendarDateCustomizationProviderEffective => this.CalendarDateCustomizationProvider ?? this.GetSettings()?.CalendarDateCustomizationProvider ?? GetDefaults().CalendarDateCustomizationProvider; + /// + /// TimeProvider is resolved in the following order: + /// 1. TimeProvider from this parameter + /// 2. TimeProvider from a CascadingValue + /// 3. TimeProvider from DependencyInjection + /// 4. Default TimeProvider.System + /// + [Parameter] public TimeProvider? TimeProvider { get; set; } = null; [Inject] private IStringLocalizer StringLocalizer { get; set; } @@ -134,6 +142,7 @@ protected virtual void BuildRenderInputCore(RenderTreeBuilder builder) builder.AddAttribute(211, nameof(HxInputDateRangeInternal.MinDateEffective), MinDateEffective); builder.AddAttribute(212, nameof(HxInputDateRangeInternal.MaxDateEffective), MaxDateEffective); builder.AddAttribute(220, nameof(HxInputDateRangeInternal.CalendarDateCustomizationProviderEffective), CalendarDateCustomizationProviderEffective); + builder.AddAttribute(221, nameof(HxInputDateRangeInternal.TimeProvider), TimeProvider); builder.AddMultipleAttributes(300, this.AdditionalAttributes); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor index f4edee4b..c8d51378 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor @@ -50,7 +50,7 @@ @if (EnabledEffective) {
- +
@if (ShowClearButtonEffective) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs index 1193bbed..8eb06ca3 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs @@ -56,6 +56,14 @@ public partial class HxInputDateInternal : InputBase, IAsyncDisp [Parameter] public RenderFragment InputGroupEndTemplate { get; set; } [Parameter] public IFormValueComponent FormValueComponent { get; set; } + /// + /// TimeProvider is resolved in the following order: + /// 1. TimeProvider from this parameter + /// 2. TimeProvider from a CascadingValue + /// 3. TimeProvider from DependencyInjection + /// 4. Default TimeProvider.System + /// + [Parameter] public TimeProvider? TimeProvider { get; set; } = null; [Inject] protected IStringLocalizerFactory StringLocalizerFactory { get; set; } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor index bafd15b1..5e73349c 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor @@ -28,7 +28,7 @@ @if (EnabledEffective) {
- +
@if (ShowClearButtonEffective) @@ -66,7 +66,7 @@ @if (EnabledEffective) {
- +
@if (ShowClearButtonEffective) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor.cs index 4cacb688..fd081b84 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor.cs @@ -31,6 +31,8 @@ public partial class HxInputDateRangeInternal : InputBase, IAsync [Parameter] public CalendarDateCustomizationProviderDelegate CalendarDateCustomizationProviderEffective { get; set; } + [Parameter] public TimeProvider? TimeProvider { get; set; } = null; + [Inject] protected IStringLocalizerFactory StringLocalizerFactory { get; set; } [Inject] protected IJSRuntime JSRuntime { get; set; } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj b/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj index d7e67ed7..9b1ff4ab 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj +++ b/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj @@ -38,6 +38,7 @@ + diff --git a/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj b/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj index a3d619a5..f36b96c4 100644 --- a/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj +++ b/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj @@ -28,6 +28,7 @@ + diff --git a/Havit.Blazor.Components.Web/ServiceCollectionExtensions.cs b/Havit.Blazor.Components.Web/ServiceCollectionExtensions.cs index fcef3037..cee76562 100644 --- a/Havit.Blazor.Components.Web/ServiceCollectionExtensions.cs +++ b/Havit.Blazor.Components.Web/ServiceCollectionExtensions.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; namespace Havit.Blazor.Components.Web; @@ -10,6 +11,7 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddHxServices(this IServiceCollection services) { services.AddLocalization(); + services.TryAddSingleton(TimeProvider.System); return services; } From e85d06d8c6e0adbba71c3a9a1397e048526cedec Mon Sep 17 00:00:00 2001 From: Glen Blanchard Date: Sun, 10 Sep 2023 07:36:56 +1000 Subject: [PATCH 02/40] Fix name used in documentation --- .../Components/HxCalendarDoc/HxCalendar_Documentation.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor index 980ec949..c37028af 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor @@ -23,7 +23,7 @@

- You can change the timezone used by the calendar by providing a custom TimeZoneProvider. + You can change the timezone used by the calendar by providing a custom TimeProvider. TimeProvider is resolved in the following order:

  1. TimeProvider parameter on HxCalendar, HxInputDate and HxInputDateRange.
  2. From ec5c026dbac257bbd426379cb5c1e73142325890 Mon Sep 17 00:00:00 2001 From: Glen Blanchard Date: Mon, 18 Sep 2023 07:59:11 +1000 Subject: [PATCH 03/40] WIP following the feedback from #597 --- .../Calendar/CalendarSettings.cs | 6 +++++ .../Calendar/HxCalendar.razor.cs | 22 +++++-------------- .../Forms/HxInputDate.cs | 13 ++++------- .../Forms/HxInputDate.nongeneric.cs | 2 +- .../Forms/HxInputDateRange.cs | 13 +++-------- .../Forms/InputDatePredefinedDatesItem.cs | 8 ++++++- .../Forms/InputDateRangeSettings.cs | 5 +++++ .../Forms/InputDateSettings.cs | 5 +++++ .../Forms/Internal/HxInputDateInternal.razor | 4 ++-- .../Internal/HxInputDateInternal.razor.cs | 10 ++------- .../Internal/HxInputDateRangeInternal.razor | 2 +- .../HxInputDateRangeInternal.razor.cs | 2 +- 12 files changed, 43 insertions(+), 49 deletions(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Calendar/CalendarSettings.cs b/Havit.Blazor.Components.Web.Bootstrap/Calendar/CalendarSettings.cs index dd1d3622..6a8c5632 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Calendar/CalendarSettings.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Calendar/CalendarSettings.cs @@ -19,4 +19,10 @@ public record CalendarSettings /// Allows customization of the dates in dropdown calendars. /// public CalendarDateCustomizationProviderDelegate DateCustomizationProvider { get; set; } + + /// + /// TimeProvider to customise the today date + /// + public TimeProvider? TimeProvider { get; set; } + } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs index 0226a9b8..5b648050 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs @@ -29,7 +29,7 @@ static HxCalendar() Defaults = new CalendarSettings() { MinDate = DefaultMinDate, - MaxDate = DefaultMaxDate + MaxDate = DefaultMaxDate, }; } @@ -107,20 +107,17 @@ static HxCalendar() [Parameter] public bool KeyboardNavigation { get; set; } = true; // Set during SetParameterSetAsync to make it optional - protected TimeProvider? TimeProviderFromServices { get; set; } - [CascadingParameter] protected TimeProvider? TimeProviderFromCascade { get; set; } = null; + [Inject] public TimeProvider TimeProviderFromServices { get; set; } /// /// TimeProvider is resolved in the following order: /// 1. TimeProvider from this parameter - /// 2. TimeProvider from a CascadingValue - /// 3. TimeProvider from DependencyInjection - /// 4. Default TimeProvider.System + /// 2. GetSettings TimeProvider + /// 3. DefaultSettings TimeProvider + /// 4. TimeProvider from DependencyInjection /// [Parameter] public TimeProvider? TimeProvider { get; set; } = null; - protected TimeProvider TimeProviderEffective => TimeProvider ?? TimeProviderFromCascade ?? TimeProviderFromServices ?? TimeProvider.System; - - [Inject] protected IServiceProvider ServiceProvider { get; set; } + protected TimeProvider TimeProviderEffective => TimeProvider ?? GetSettings().TimeProvider ?? GetDefaults().TimeProvider ?? TimeProviderFromServices; private CultureInfo Culture => CultureInfo.CurrentUICulture; private DayOfWeek FirstDayOfWeek => Culture.DateTimeFormat.FirstDayOfWeek; @@ -146,13 +143,6 @@ protected DateTime FirstDayToDisplay private RenderData renderData; private DateTime? lastKnownValue; - public override Task SetParametersAsync(ParameterView parameters) - { - TimeProviderFromServices = ServiceProvider.GetService(); - return base.SetParametersAsync(parameters); - - } - protected override async Task OnParametersSetAsync() { await base.OnParametersSetAsync(); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs index eedafe0d..c162d424 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs @@ -124,15 +124,10 @@ public class HxInputDate : HxInputBase, IInputWithPlaceholder, I /// Input-group at the end of the input. /// [Parameter] public RenderFragment InputGroupEndTemplate { get; set; } - /// - /// TimeProvider is resolved in the following order: - /// 1. TimeProvider from this parameter - /// 2. TimeProvider from a CascadingValue - /// 3. TimeProvider from DependencyInjection - /// 4. Default TimeProvider.System - /// - [Parameter] public TimeProvider? TimeProvider { get; set; } = null; + [Inject] public TimeProvider TimeProviderFromServices { get; set; } + + protected TimeProvider TimeProviderEffective => GetSettings().TimeProvider ?? GetDefaults().TimeProvider ?? TimeProviderFromServices; [Inject] private IStringLocalizer StringLocalizer { get; set; } @@ -177,7 +172,7 @@ protected virtual void BuildRenderInputCore(RenderTreeBuilder builder) builder.AddAttribute(211, nameof(HxInputDateInternal.CalendarDateCustomizationProviderEffective), CalendarDateCustomizationProviderEffective); builder.AddAttribute(212, nameof(HxInputDateInternal.LabelTypeEffective), labelTypeEffective); builder.AddAttribute(213, nameof(HxInputDateInternal.FormValueComponent), this); - builder.AddAttribute(214, nameof(HxInputDateInternal.TimeProvider), TimeProvider); + builder.AddAttribute(214, nameof(HxInputDateInternal.TimeProviderEffective), TimeProviderEffective); builder.AddAttribute(214, nameof(HxInputDateInternal.InputGroupStartText), this.InputGroupStartText); builder.AddAttribute(215, nameof(HxInputDateInternal.InputGroupEndText), this.InputGroupEndText); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.nongeneric.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.nongeneric.cs index bde54167..940912c9 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.nongeneric.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.nongeneric.cs @@ -20,7 +20,7 @@ static HxInputDate() MaxDate = HxCalendar.DefaultMaxDate, ShowClearButton = true, ShowPredefinedDates = true, - PredefinedDates = new List() { new InputDatePredefinedDatesItem() { Label = "Today", ResourceType = typeof(HxInputDate), Date = DateTime.Today } } + PredefinedDates = new List() { new InputDatePredefinedDatesItem() { Label = "Today", ResourceType = typeof(HxInputDate), DateSelector = (timeProvider) => timeProvider.GetLocalNow().LocalDateTime } }, }; } } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs index f6da7af1..bdd060fd 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs @@ -24,7 +24,7 @@ static HxInputDateRange() MaxDate = HxCalendar.DefaultMaxDate, ShowClearButton = true, ShowPredefinedDateRanges = true, - PredefinedDateRanges = null + PredefinedDateRanges = null, }; } @@ -105,14 +105,7 @@ static HxInputDateRange() /// [Parameter] public CalendarDateCustomizationProviderDelegate CalendarDateCustomizationProvider { get; set; } protected CalendarDateCustomizationProviderDelegate CalendarDateCustomizationProviderEffective => this.CalendarDateCustomizationProvider ?? this.GetSettings()?.CalendarDateCustomizationProvider ?? GetDefaults().CalendarDateCustomizationProvider; - /// - /// TimeProvider is resolved in the following order: - /// 1. TimeProvider from this parameter - /// 2. TimeProvider from a CascadingValue - /// 3. TimeProvider from DependencyInjection - /// 4. Default TimeProvider.System - /// - [Parameter] public TimeProvider? TimeProvider { get; set; } = null; + protected TimeProvider TimeProviderEffective => GetSettings().TimeProvider ?? GetDefaults().TimeProvider; [Inject] private IStringLocalizer StringLocalizer { get; set; } @@ -142,7 +135,7 @@ protected virtual void BuildRenderInputCore(RenderTreeBuilder builder) builder.AddAttribute(211, nameof(HxInputDateRangeInternal.MinDateEffective), MinDateEffective); builder.AddAttribute(212, nameof(HxInputDateRangeInternal.MaxDateEffective), MaxDateEffective); builder.AddAttribute(220, nameof(HxInputDateRangeInternal.CalendarDateCustomizationProviderEffective), CalendarDateCustomizationProviderEffective); - builder.AddAttribute(221, nameof(HxInputDateRangeInternal.TimeProvider), TimeProvider); + builder.AddAttribute(221, nameof(HxInputDateRangeInternal.TimeProviderEffective), TimeProviderEffective); builder.AddMultipleAttributes(300, this.AdditionalAttributes); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDatePredefinedDatesItem.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDatePredefinedDatesItem.cs index e6b9be76..2df49215 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDatePredefinedDatesItem.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDatePredefinedDatesItem.cs @@ -18,5 +18,11 @@ public class InputDatePredefinedDatesItem /// /// Date. /// - public DateTime Date { get; set; } + public DateTime? Date { get; set; } + + /// + /// Used to supply the date at runtime especially to use + /// a TimeProvider + /// + public Func DateSelector { get; set; } } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateRangeSettings.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateRangeSettings.cs index 337737a9..36bf2dbd 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateRangeSettings.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateRangeSettings.cs @@ -41,4 +41,9 @@ public record InputDateRangeSettings : InputSettings, IInputSettingsWithSize /// Predefined date ranges to be displayed. /// public IEnumerable PredefinedDateRanges { get; set; } + + /// + /// TimeProvider used to get DateTime.Today + /// + public TimeProvider? TimeProvider { get; set; } } \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateSettings.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateSettings.cs index 97a9b552..9cf9175d 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateSettings.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateSettings.cs @@ -46,4 +46,9 @@ public record InputDateSettings : InputSettings, IInputSettingsWithSize /// Predefined dates to be displayed. /// public IEnumerable PredefinedDates { get; set; } + + /// + /// TimeProvider to use, note: override the 'Today' in PredefinedDates + /// + public TimeProvider? TimeProvider { get; set; } } \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor index c8d51378..68f9e3ec 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor @@ -50,7 +50,7 @@ @if (EnabledEffective) {
    - +
    @if (ShowClearButtonEffective) @@ -61,7 +61,7 @@ { foreach (var item in PredefinedDatesEffective) { - + } }
    diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs index 8eb06ca3..7cc88d37 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs @@ -56,14 +56,8 @@ public partial class HxInputDateInternal : InputBase, IAsyncDisp [Parameter] public RenderFragment InputGroupEndTemplate { get; set; } [Parameter] public IFormValueComponent FormValueComponent { get; set; } - /// - /// TimeProvider is resolved in the following order: - /// 1. TimeProvider from this parameter - /// 2. TimeProvider from a CascadingValue - /// 3. TimeProvider from DependencyInjection - /// 4. Default TimeProvider.System - /// - [Parameter] public TimeProvider? TimeProvider { get; set; } = null; + + [Parameter] public TimeProvider TimeProviderEffective { get; set; } [Inject] protected IStringLocalizerFactory StringLocalizerFactory { get; set; } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor index 5e73349c..7d51cc9d 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor @@ -66,7 +66,7 @@ @if (EnabledEffective) {
    - +
    @if (ShowClearButtonEffective) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor.cs index fd081b84..12ed2d2b 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor.cs @@ -31,7 +31,7 @@ public partial class HxInputDateRangeInternal : InputBase, IAsync [Parameter] public CalendarDateCustomizationProviderDelegate CalendarDateCustomizationProviderEffective { get; set; } - [Parameter] public TimeProvider? TimeProvider { get; set; } = null; + [Parameter] public TimeProvider TimeProviderEffective { get; set; } [Inject] protected IStringLocalizerFactory StringLocalizerFactory { get; set; } From 442cfd8f80d4ac1f9ec3aeca55726367383c6980 Mon Sep 17 00:00:00 2001 From: Glen Blanchard Date: Mon, 18 Sep 2023 08:09:09 +1000 Subject: [PATCH 04/40] Update to latest TimeProvider library which fixes min sdk requirements --- .../Forms/Internal/HxInputDateInternal.razor | 2 +- .../Havit.Blazor.Components.Web.Bootstrap.csproj | 2 +- Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor index 68f9e3ec..77b5ef01 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor @@ -61,7 +61,7 @@ { foreach (var item in PredefinedDatesEffective) { - + } }
    diff --git a/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj b/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj index 9b1ff4ab..2734a0cc 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj +++ b/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj @@ -38,7 +38,7 @@ - + diff --git a/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj b/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj index f36b96c4..5e993ed2 100644 --- a/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj +++ b/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj @@ -28,7 +28,7 @@ - + From bb68ebc0bcfbf136487d194e097ffe6cb633a9fb Mon Sep 17 00:00:00 2001 From: Glen Blanchard Date: Mon, 18 Sep 2023 20:36:44 +1000 Subject: [PATCH 05/40] Update the calendar test page --- BlazorAppTest/BlazorAppTest.csproj | 6 +- .../Pages/HxCalendar_Issue597_Test.razor | 61 ++++++++----------- BlazorAppTest/Startup.cs | 1 - .../Havit.Blazor.Components.Web.Bootstrap.xml | 54 ++++++++-------- .../Calendar/HxCalendar.razor.cs | 2 +- .../Forms/HxInputDate.cs | 2 +- .../Forms/HxInputDateRange.cs | 2 +- .../Internal/HxInputDateRangeInternal.razor | 2 +- 8 files changed, 59 insertions(+), 71 deletions(-) diff --git a/BlazorAppTest/BlazorAppTest.csproj b/BlazorAppTest/BlazorAppTest.csproj index 935bc863..d36a0e48 100644 --- a/BlazorAppTest/BlazorAppTest.csproj +++ b/BlazorAppTest/BlazorAppTest.csproj @@ -1,4 +1,4 @@ - + net7.0 @@ -21,4 +21,8 @@ + + + + diff --git a/BlazorAppTest/Pages/HxCalendar_Issue597_Test.razor b/BlazorAppTest/Pages/HxCalendar_Issue597_Test.razor index 773836ab..512d20f8 100644 --- a/BlazorAppTest/Pages/HxCalendar_Issue597_Test.razor +++ b/BlazorAppTest/Pages/HxCalendar_Issue597_Test.razor @@ -1,44 +1,44 @@ @page "/HxCalendar_Issue597_Test" @using BlazorAppTest.Pages.HxCalendarComponents; -@implements IDisposable -@inject NavigationManager NavigationManager -@inject IServiceProvider ServiceProvider +@inject TimeProvider SystemTimeProvider

    HxCalendar

    - -

    - American Samoa | - Samoa | - System -

    +
    - +
    - -
    - -
    -
    -
    +
    + +
    +
    + +
    + +
    +
    - -
    + +
    @code { - TimeProvider cascadingTimeProvider = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("UTC-11")); - TimeProvider parameterTimeProvider = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("Samoa Standard Time")); - TimeProvider diOrSystemTimeProvider; - public override Task SetParametersAsync(ParameterView parameters) + public class AppCalendarSettings { - diOrSystemTimeProvider = ServiceProvider.GetService() ?? TimeProvider.System; - - NavigationManager.LocationChanged += HandleNavigation; - return base.SetParametersAsync(parameters); + public static TimeProvider timeProviderUtc = new ZonedTimeProvider(TimeZoneInfo.Utc); + public static TimeProvider timeProviderUtc11 = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("UTC-11")); + public static TimeProvider timeProviderUtc13 = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("Samoa Standard Time")); + public static CalendarSettings AmericanSamoa => new() + { + TimeProvider = timeProviderUtc11, + }; + public static CalendarSettings Samoa => new() + { + TimeProvider = timeProviderUtc13, + }; } protected override void OnInitialized() @@ -46,13 +46,4 @@ base.OnInitialized(); } - protected void HandleNavigation(object sender, LocationChangedEventArgs ev) - { - StateHasChanged(); - } - - public void Dispose() - { - NavigationManager.LocationChanged -= HandleNavigation; - } } diff --git a/BlazorAppTest/Startup.cs b/BlazorAppTest/Startup.cs index 4dfeed25..10e5ead1 100644 --- a/BlazorAppTest/Startup.cs +++ b/BlazorAppTest/Startup.cs @@ -27,7 +27,6 @@ public void ConfigureServices(IServiceCollection services) services.AddRazorPages(); services.AddServerSideBlazor(); - services.AddScoped(); services.AddHxServices(); services.AddHxMessenger(); services.AddHxMessageBoxHost(); diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml b/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml index 56d1269f..b0a7d857 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml @@ -642,6 +642,11 @@ Allows customization of the dates in dropdown calendars. + + + TimeProvider to customise the today date + + Basic calendar building block. Used for and implementation.
    @@ -739,9 +744,9 @@ TimeProvider is resolved in the following order: 1. TimeProvider from this parameter - 2. TimeProvider from a CascadingValue - 3. TimeProvider from DependencyInjection - 4. Default TimeProvider.System + 2. GetSettings TimeProvider + 3. DefaultSettings TimeProvider + 4. TimeProvider from DependencyInjection @@ -2704,15 +2709,6 @@ Input-group at the end of the input.
    - - - TimeProvider is resolved in the following order: - 1. TimeProvider from this parameter - 2. TimeProvider from a CascadingValue - 3. TimeProvider from DependencyInjection - 4. Default TimeProvider.System - - @@ -3893,15 +3889,6 @@ Input-group at the end of the input. - - - TimeProvider is resolved in the following order: - 1. TimeProvider from this parameter - 2. TimeProvider from a CascadingValue - 3. TimeProvider from DependencyInjection - 4. Default TimeProvider.System - - @@ -4002,15 +3989,6 @@ Default customization is configurable with . - - - TimeProvider is resolved in the following order: - 1. TimeProvider from this parameter - 2. TimeProvider from a CascadingValue - 3. TimeProvider from DependencyInjection - 4. Default TimeProvider.System - - @@ -4862,6 +4840,12 @@ Date. + + + Used to supply the date at runtime especially to use + a TimeProvider + + Item for . @@ -4922,6 +4906,11 @@ Predefined date ranges to be displayed. + + + TimeProvider used to get DateTime.Today + + Settings for . @@ -4967,6 +4956,11 @@ Predefined dates to be displayed. + + + TimeProvider to use, note: override the 'Today' in PredefinedDates + + Settings for the and derived components. diff --git a/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs index 5b648050..1266153f 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs @@ -117,7 +117,7 @@ static HxCalendar() /// [Parameter] public TimeProvider? TimeProvider { get; set; } = null; - protected TimeProvider TimeProviderEffective => TimeProvider ?? GetSettings().TimeProvider ?? GetDefaults().TimeProvider ?? TimeProviderFromServices; + protected TimeProvider TimeProviderEffective => TimeProvider ?? GetSettings()?.TimeProvider ?? GetDefaults()?.TimeProvider ?? TimeProviderFromServices; private CultureInfo Culture => CultureInfo.CurrentUICulture; private DayOfWeek FirstDayOfWeek => Culture.DateTimeFormat.FirstDayOfWeek; diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs index c162d424..899d3fa8 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs @@ -127,7 +127,7 @@ public class HxInputDate : HxInputBase, IInputWithPlaceholder, I [Inject] public TimeProvider TimeProviderFromServices { get; set; } - protected TimeProvider TimeProviderEffective => GetSettings().TimeProvider ?? GetDefaults().TimeProvider ?? TimeProviderFromServices; + protected TimeProvider TimeProviderEffective => GetSettings()?.TimeProvider ?? GetDefaults().TimeProvider ?? TimeProviderFromServices; [Inject] private IStringLocalizer StringLocalizer { get; set; } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs index bdd060fd..4e79ebd8 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs @@ -105,7 +105,7 @@ static HxInputDateRange() /// [Parameter] public CalendarDateCustomizationProviderDelegate CalendarDateCustomizationProvider { get; set; } protected CalendarDateCustomizationProviderDelegate CalendarDateCustomizationProviderEffective => this.CalendarDateCustomizationProvider ?? this.GetSettings()?.CalendarDateCustomizationProvider ?? GetDefaults().CalendarDateCustomizationProvider; - protected TimeProvider TimeProviderEffective => GetSettings().TimeProvider ?? GetDefaults().TimeProvider; + protected TimeProvider TimeProviderEffective => GetSettings()?.TimeProvider ?? GetDefaults().TimeProvider; [Inject] private IStringLocalizer StringLocalizer { get; set; } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor index 7d51cc9d..40f48173 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor @@ -28,7 +28,7 @@ @if (EnabledEffective) {
    - +
    @if (ShowClearButtonEffective) From 92afa051eca98c51655ab0c0a571c79764ec0e24 Mon Sep 17 00:00:00 2001 From: Glen Blanchard Date: Mon, 18 Sep 2023 21:13:01 +1000 Subject: [PATCH 06/40] Fix for documentation --- .../HxCalendarComponents/ZonedTimeProvider.cs | 46 +------------------ .../HxCalendar_Documentation.razor | 7 +-- ...HxCalendar_RegisterServices.CodeSnippet.cs | 39 ---------------- .../HxCalendar_TimeProvider.CodeSnippet.razor | 24 ++++++++++ ...xCalendar_ZonedTimeProvider.CodeSnippet.cs | 1 - .../Havit.Blazor.Components.Web.Bootstrap.xml | 10 ++-- .../Calendar/HxCalendar.razor.cs | 10 ++-- 7 files changed, 40 insertions(+), 97 deletions(-) delete mode 100644 Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_RegisterServices.CodeSnippet.cs create mode 100644 Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_TimeProvider.CodeSnippet.razor diff --git a/BlazorAppTest/Pages/HxCalendarComponents/ZonedTimeProvider.cs b/BlazorAppTest/Pages/HxCalendarComponents/ZonedTimeProvider.cs index 59363234..336b9128 100644 --- a/BlazorAppTest/Pages/HxCalendarComponents/ZonedTimeProvider.cs +++ b/BlazorAppTest/Pages/HxCalendarComponents/ZonedTimeProvider.cs @@ -1,55 +1,13 @@ -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.WebUtilities; +namespace BlazorAppTest.Pages.HxCalendarComponents; -namespace BlazorAppTest.Pages.HxCalendarComponents; - -public class ZonedTimeProvider : TimeProvider, IDisposable +public class ZonedTimeProvider : TimeProvider { private TimeZoneInfo zoneInfo; - private readonly NavigationManager? navigationManager; public ZonedTimeProvider(TimeZoneInfo zoneInfo) { this.zoneInfo = zoneInfo; } - public ZonedTimeProvider(NavigationManager navigationManager) : base() - { - this.navigationManager = navigationManager; - navigationManager.LocationChanged += NavigationManager_LocationChanged; - Update(); - } - - private void NavigationManager_LocationChanged(object sender, Microsoft.AspNetCore.Components.Routing.LocationChangedEventArgs e) - { - Update(); - } - - private void Update() - { - TimeZoneInfo? zoneInfo = null; - try - { - var uri = navigationManager?.ToAbsoluteUri(navigationManager.Uri); - if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("tz", out var vals)) - { - zoneInfo = TimeZoneInfo.FindSystemTimeZoneById(vals.FirstOrDefault() ?? "Not Found"); - } - } - catch (Exception) - { - // Ignore and fallback to local timezone - } - this.zoneInfo = zoneInfo ?? TimeZoneInfo.Local; - } public override TimeZoneInfo LocalTimeZone { get => zoneInfo; } - public static TimeProvider FromLocalTimeZone(TimeZoneInfo zoneInfo) => new ZonedTimeProvider(zoneInfo); - - public void Dispose() - { - if (navigationManager != null) - { - navigationManager.LocationChanged -= NavigationManager_LocationChanged; - } - } } \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor index c37028af..cd86884a 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor @@ -27,18 +27,19 @@ TimeProvider is resolved in the following order:
    1. TimeProvider parameter on HxCalendar, HxInputDate and HxInputDateRange.
    2. -
    3. By using a CascadingValue.
    4. +
    5. Settings
    6. +
    7. Defaults
    8. Adding a TimeProvider service via dependency injection.
    9. The default TimeProvider.System time provider.

    One use for this is for server rendered blazor components where the server local timezone is different to the client timezone. - See the following smaple: + See the following sample:

    Then add the following to your Program.cs. Please expand to provide appropriate error handling, caching, etc. depending on your needs.

    - + diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_RegisterServices.CodeSnippet.cs b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_RegisterServices.CodeSnippet.cs deleted file mode 100644 index c5e24ddc..00000000 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_RegisterServices.CodeSnippet.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Havit.Blazor.Components.Web; // <------ ADD THIS LINE -using Havit.Blazor.Components.Web.Bootstrap; // <------ ADD THIS LINE -using System; // <------ ADD THIS LINE - -public static async Task Main(string[] args) -{ - var builder = WebAssemblyHostBuilder.CreateDefault(args); - builder.RootComponents.Add("app"); - - // ... shortened for brevity - - // So the provider can access the context - builder.Services.AddHttpContextAccessor(); // <------ ADD THIS LINE - - // Do this before AddHxServices - builder.Services.AddScoped(provider => // <------ ADD THIS BLOCK - { - NavigationManager? navigationManager = provider.GetService(); - TimeZoneInfo ? requestTimeZoneInfo = null; - try - { - var uri = navigationManager?.ToAbsoluteUri(navigationManager.Uri); - if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("tz", out var vals)) - { - requestTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(vals.FirstOrDefault() ?? "Not Found"); - } - } - catch (Exception) - { - // Ignore and fallback to local timezone - } - requestTimeZoneInfo ??= TimeZoneInfo.Local; - return ZonedTimeProvider(requestTimeZoneInfo); - }); - - builder.Services.AddHxServices(); // <------ ADD THIS LINE - - await builder.Build().RunAsync(); -} \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_TimeProvider.CodeSnippet.razor b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_TimeProvider.CodeSnippet.razor new file mode 100644 index 00000000..0fcad43e --- /dev/null +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_TimeProvider.CodeSnippet.razor @@ -0,0 +1,24 @@ + + + + + + + + +@code { + + static TimeProvider usersTimeProvider = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("UTC-11")); + + // OR + + public static CalendarSettings UsersCalendarSettings => new() + { + TimeProvider = usersTimeProvider, + }; + + // OR + + HxCalendar.Defaults.TimeProvider = usersTimeProvider + +} \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.cs b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.cs index ada1f641..9fe4401f 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.cs +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.cs @@ -11,6 +11,5 @@ public ZonedTimeProvider(TimeZoneInfo zoneInfo) : base() _zoneInfo = zoneInfo ?? TimeZoneInfo.Local; } public override TimeZoneInfo LocalTimeZone { get => _zoneInfo; } - public static TimeProvider FromLocalTimeZone(TimeZoneInfo zoneInfo) => new ZonedTimeProvider(zoneInfo); } } diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml b/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml index b0a7d857..c82f149c 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml @@ -742,11 +742,11 @@ - TimeProvider is resolved in the following order: - 1. TimeProvider from this parameter - 2. GetSettings TimeProvider - 3. DefaultSettings TimeProvider - 4. TimeProvider from DependencyInjection + TimeProvider is resolved in the following order:
    + 1. TimeProvider from this parameter
    + 2. Settings TimeProvider (configurable from )
    + 3. Defaults TimeProvider (configurable from )
    + 4. TimeProvider from DependencyInjection
    diff --git a/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs index 1266153f..5754d747 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs @@ -109,11 +109,11 @@ static HxCalendar() // Set during SetParameterSetAsync to make it optional [Inject] public TimeProvider TimeProviderFromServices { get; set; } /// - /// TimeProvider is resolved in the following order: - /// 1. TimeProvider from this parameter - /// 2. GetSettings TimeProvider - /// 3. DefaultSettings TimeProvider - /// 4. TimeProvider from DependencyInjection + /// TimeProvider is resolved in the following order:
    + /// 1. TimeProvider from this parameter
    + /// 2. Settings TimeProvider (configurable from )
    + /// 3. Defaults TimeProvider (configurable from )
    + /// 4. TimeProvider from DependencyInjection
    ///
    [Parameter] public TimeProvider? TimeProvider { get; set; } = null; From 9336cb99ec1c96beba2dd2ffcb2a207697744b43 Mon Sep 17 00:00:00 2001 From: Glen Blanchard Date: Thu, 21 Sep 2023 08:08:17 +1000 Subject: [PATCH 07/40] Address code review changes --- BlazorAppTest/BlazorAppTest.csproj | 4 --- .../Pages/HxCalendar_Issue597_Test.razor | 31 ++++++++----------- BlazorAppTest/Startup.cs | 1 - .../HxCalendar_Documentation.razor | 16 +++++----- .../HxCalendar_TimeProvider.CodeSnippet.razor | 15 ++++----- ...endar_ZonedTimeProvider.CodeSnippet.csproj | 3 -- .../HxInputDate_Documentation.razor | 4 +-- .../HxInputDateRange_Documentation.razor | 4 +-- .../Havit.Blazor.Components.Web.Bootstrap.xml | 30 ++++++++++++++++-- .../Calendar/HxCalendar.razor.cs | 3 +- .../Forms/HxInputDate.cs | 13 ++++++-- .../Forms/HxInputDate.nongeneric.cs | 2 +- .../Forms/HxInputDateRange.cs | 13 +++++++- .../Forms/InputDatePredefinedDatesItem.cs | 15 +++++++-- .../Forms/Internal/HxInputDateInternal.razor | 2 +- ...vit.Blazor.Components.Web.Bootstrap.csproj | 1 - 16 files changed, 102 insertions(+), 55 deletions(-) delete mode 100644 Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.csproj diff --git a/BlazorAppTest/BlazorAppTest.csproj b/BlazorAppTest/BlazorAppTest.csproj index d36a0e48..d9f5491d 100644 --- a/BlazorAppTest/BlazorAppTest.csproj +++ b/BlazorAppTest/BlazorAppTest.csproj @@ -21,8 +21,4 @@ - - - - diff --git a/BlazorAppTest/Pages/HxCalendar_Issue597_Test.razor b/BlazorAppTest/Pages/HxCalendar_Issue597_Test.razor index 512d20f8..fa476de1 100644 --- a/BlazorAppTest/Pages/HxCalendar_Issue597_Test.razor +++ b/BlazorAppTest/Pages/HxCalendar_Issue597_Test.razor @@ -20,30 +20,25 @@
    - -
    + +
    @code { + private static TimeProvider timeProviderUtc = new ZonedTimeProvider(TimeZoneInfo.Utc); - public class AppCalendarSettings + private class AppCalendarSettings { - public static TimeProvider timeProviderUtc = new ZonedTimeProvider(TimeZoneInfo.Utc); - public static TimeProvider timeProviderUtc11 = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("UTC-11")); - public static TimeProvider timeProviderUtc13 = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("Samoa Standard Time")); + private static TimeProvider timeProviderUtc11 = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("UTC-11")); + private static TimeProvider timeProviderUtc13 = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("Samoa Standard Time")); public static CalendarSettings AmericanSamoa => new() - { - TimeProvider = timeProviderUtc11, - }; + { + TimeProvider = timeProviderUtc11, + }; public static CalendarSettings Samoa => new() - { - TimeProvider = timeProviderUtc13, - }; + { + TimeProvider = timeProviderUtc13, + }; } - - protected override void OnInitialized() - { - base.OnInitialized(); - } - + } diff --git a/BlazorAppTest/Startup.cs b/BlazorAppTest/Startup.cs index 10e5ead1..4deb3c12 100644 --- a/BlazorAppTest/Startup.cs +++ b/BlazorAppTest/Startup.cs @@ -1,6 +1,5 @@ using System.Globalization; using BlazorAppTest.Resources; -using BlazorAppTest.Pages.HxCalendarComponents; using Havit.Blazor.Components.Web; using Havit.Blazor.GoogleTagManager; diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor index cd86884a..b52cdf8e 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor @@ -21,25 +21,27 @@ and HxInputDateRange components. See their documentation for more info.

    - +

    - You can change the timezone used by the calendar by providing a custom TimeProvider. + You can change the time zone used by the calendar by providing a custom TimeProvider. TimeProvider is resolved in the following order:

      -
    1. TimeProvider parameter on HxCalendar, HxInputDate and HxInputDateRange.
    2. -
    3. Settings
    4. -
    5. Defaults
    6. +
    7. TimeProvider parameter on HxCalendar, HxInputDate and HxInputDateRange.
    8. +
    9. Settings HxCalendar.Settings
    10. +
    11. Defaults HxCalendar.Defaults
    12. Adding a TimeProvider service via dependency injection.
    13. The default TimeProvider.System time provider.

    - One use for this is for server rendered blazor components where the server local timezone is different to the client timezone. + One use for this is for server rendered blazor components where the server local time zone is different to the client time zone. See the following sample:

    -

    Then add the following to your Program.cs. Please expand to provide appropriate error handling, caching, etc. depending on your needs.

    +

    Use the ZonedTimeProvider. Ensure that Defaults are configured in Program.cs or where you maintain your other defaults. + Please expand to provide appropriate error handling, caching, etc. depending on your needs.

    + diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_TimeProvider.CodeSnippet.razor b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_TimeProvider.CodeSnippet.razor index 0fcad43e..b7565113 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_TimeProvider.CodeSnippet.razor +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_TimeProvider.CodeSnippet.razor @@ -1,24 +1,25 @@  - + - + @code { - static TimeProvider usersTimeProvider = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("UTC-11")); + TimeProvider usersTimeProvider = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("UTC-11")); // OR public static CalendarSettings UsersCalendarSettings => new() - { - TimeProvider = usersTimeProvider, - }; + { + TimeProvider = usersTimeProvider, + }; // OR - HxCalendar.Defaults.TimeProvider = usersTimeProvider + // Program.cs or somewhere where you maintain the defaults + HxCalendar.Defaults.TimeProvider = new ZonedTimeProvider(TimeZoneInfo.FindSystemTimeZoneById("E. Australia Standard Time")); } \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.csproj b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.csproj deleted file mode 100644 index 050f4dc7..00000000 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_ZonedTimeProvider.CodeSnippet.csproj +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateDoc/HxInputDate_Documentation.razor b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateDoc/HxInputDate_Documentation.razor index b23b3249..6771e6a2 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateDoc/HxInputDate_Documentation.razor +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateDoc/HxInputDate_Documentation.razor @@ -38,8 +38,8 @@

    - +

    - You can customize the dropdown calendar timezone by supplying a custom TimeProvider. See HxCalendar TimeZones for more details. + You can customize the dropdown calendar time zone by supplying a custom TimeProvider. See HxCalendar time zones for more details.

    \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateRangeDoc/HxInputDateRange_Documentation.razor b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateRangeDoc/HxInputDateRange_Documentation.razor index 3fd476c9..bddb9093 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateRangeDoc/HxInputDateRange_Documentation.razor +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/Pages/Components/HxInputDateRangeDoc/HxInputDateRange_Documentation.razor @@ -37,8 +37,8 @@

    - +

    - You can customize the dropdown calendar timezone by supplying a custom TimeProvider. See HxCalendar TimeZones for more details. + You can customize the dropdown calendar time zone by supplying a custom TimeProvider. See HxCalendar time zones for more details.

    \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml b/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml index c82f149c..a776584f 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml @@ -3889,6 +3889,15 @@ Input-group at the end of the input.
    + + + TimeProvider is resolved in the following order:
    + 1. TimeProvider from this parameter
    + 2. Settings TimeProvider (configurable from )
    + 3. Defaults TimeProvider (configurable from )
    + 4. TimeProvider from DependencyInjection
    +
    +
    @@ -3989,6 +3998,15 @@ Default customization is configurable with . + + + TimeProvider is resolved in the following order:
    + 1. TimeProvider from this parameter
    + 2. Settings TimeProvider (configurable from )
    + 3. Defaults TimeProvider (configurable from )
    + 4. TimeProvider from DependencyInjection
    +
    +
    @@ -4837,15 +4855,23 @@ - Date. + Date. Overrides any Used to supply the date at runtime especially to use - a TimeProvider + a TimeProvider. Not used if is set. + + + Defaults to returning the otherwise calls .
    + Used to resolve the date at runtime, particularly when a TimeProvider is needed. +
    + + +
    Item for . diff --git a/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs index 5754d747..cabe7edc 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs @@ -107,7 +107,8 @@ static HxCalendar() [Parameter] public bool KeyboardNavigation { get; set; } = true; // Set during SetParameterSetAsync to make it optional - [Inject] public TimeProvider TimeProviderFromServices { get; set; } + [Inject] protected TimeProvider TimeProviderFromServices { get; set; } + /// /// TimeProvider is resolved in the following order:
    /// 1. TimeProvider from this parameter
    diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs index 899d3fa8..8b00d364 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs @@ -125,9 +125,18 @@ public class HxInputDate : HxInputBase, IInputWithPlaceholder, I ///
    [Parameter] public RenderFragment InputGroupEndTemplate { get; set; } - [Inject] public TimeProvider TimeProviderFromServices { get; set; } + [Inject] protected TimeProvider TimeProviderFromServices { get; set; } - protected TimeProvider TimeProviderEffective => GetSettings()?.TimeProvider ?? GetDefaults().TimeProvider ?? TimeProviderFromServices; + /// + /// TimeProvider is resolved in the following order:
    + /// 1. TimeProvider from this parameter
    + /// 2. Settings TimeProvider (configurable from )
    + /// 3. Defaults TimeProvider (configurable from )
    + /// 4. TimeProvider from DependencyInjection
    + ///
    + [Parameter] public TimeProvider? TimeProvider { get; set; } = null; + + protected TimeProvider TimeProviderEffective => TimeProvider ?? GetSettings()?.TimeProvider ?? GetDefaults().TimeProvider ?? TimeProviderFromServices; [Inject] private IStringLocalizer StringLocalizer { get; set; } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.nongeneric.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.nongeneric.cs index 940912c9..92ac69c1 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.nongeneric.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.nongeneric.cs @@ -20,7 +20,7 @@ static HxInputDate() MaxDate = HxCalendar.DefaultMaxDate, ShowClearButton = true, ShowPredefinedDates = true, - PredefinedDates = new List() { new InputDatePredefinedDatesItem() { Label = "Today", ResourceType = typeof(HxInputDate), DateSelector = (timeProvider) => timeProvider.GetLocalNow().LocalDateTime } }, + PredefinedDates = new List() { new InputDatePredefinedDatesItem() { Label = "Today", ResourceType = typeof(HxInputDate), DateSelector = (timeProvider) => timeProvider.GetLocalNow().LocalDateTime.Date } }, }; } } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs index 4e79ebd8..9cb588a9 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs @@ -105,7 +105,18 @@ static HxInputDateRange() ///
    [Parameter] public CalendarDateCustomizationProviderDelegate CalendarDateCustomizationProvider { get; set; } protected CalendarDateCustomizationProviderDelegate CalendarDateCustomizationProviderEffective => this.CalendarDateCustomizationProvider ?? this.GetSettings()?.CalendarDateCustomizationProvider ?? GetDefaults().CalendarDateCustomizationProvider; - protected TimeProvider TimeProviderEffective => GetSettings()?.TimeProvider ?? GetDefaults().TimeProvider; + + [Inject] protected TimeProvider TimeProviderFromServices { get; set; } + + /// + /// TimeProvider is resolved in the following order:
    + /// 1. TimeProvider from this parameter
    + /// 2. Settings TimeProvider (configurable from )
    + /// 3. Defaults TimeProvider (configurable from )
    + /// 4. TimeProvider from DependencyInjection
    + ///
    + [Parameter] public TimeProvider? TimeProvider { get; set; } = null; + protected TimeProvider TimeProviderEffective => TimeProvider ?? GetSettings()?.TimeProvider ?? GetDefaults().TimeProvider ?? TimeProviderFromServices; [Inject] private IStringLocalizer StringLocalizer { get; set; } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDatePredefinedDatesItem.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDatePredefinedDatesItem.cs index 2df49215..91be57ab 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDatePredefinedDatesItem.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDatePredefinedDatesItem.cs @@ -16,13 +16,24 @@ public class InputDatePredefinedDatesItem public Type ResourceType { get; set; } /// - /// Date. + /// Date. Overrides any /// public DateTime? Date { get; set; } /// /// Used to supply the date at runtime especially to use - /// a TimeProvider + /// a TimeProvider. Not used if is set. /// public Func DateSelector { get; set; } + + /// + /// Defaults to returning the otherwise calls .
    + /// Used to resolve the date at runtime, particularly when a TimeProvider is needed. + ///
    + /// + /// + public DateTime GetDateEffective(TimeProvider timeProvider) + { + return Date ?? DateSelector(timeProvider); + } } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor index 77b5ef01..90ab6953 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor @@ -61,7 +61,7 @@ { foreach (var item in PredefinedDatesEffective) { - + } }
    diff --git a/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj b/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj index 2734a0cc..d7e67ed7 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj +++ b/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj @@ -38,7 +38,6 @@ - From c285708a1c496d26eb10cce91096b2ecd7a57350 Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Mon, 25 Sep 2023 14:59:16 +0200 Subject: [PATCH 08/40] release 4.2.1-TimeProvider (from branch) --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6f1b04d8..aafd2eb7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,7 @@ latest - 4.2.1 + 4.2.1-TimeProvider 1.4.4 From 968ad209de925420278544ebc94105b0d29dc2e0 Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Mon, 25 Sep 2023 15:54:30 +0200 Subject: [PATCH 09/40] #597 [HxCalendar] Add TimeZone support - code cleanup --- .../XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml | 4 ++-- .../Calendar/CalendarSettings.cs | 4 ++-- .../Calendar/HxCalendar.razor.cs | 2 +- Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs | 5 ++--- .../Forms/HxInputDateRange.cs | 2 +- .../Forms/InputDateRangeSettings.cs | 2 +- .../Forms/InputDateSettings.cs | 2 +- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml b/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml index 865963a2..e96b055d 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml +++ b/Havit.Blazor.Components.Web.Bootstrap.Documentation/XmlDoc/Havit.Blazor.Components.Web.Bootstrap.xml @@ -644,7 +644,7 @@
    - TimeProvider to customise the today date + TimeProvider to customize the today date @@ -3893,7 +3893,7 @@ TimeProvider is resolved in the following order:
    1. TimeProvider from this parameter
    - 2. Settings TimeProvider (configurable from )
    + 2. Settings TimeProvider (configurable from )
    3. Defaults TimeProvider (configurable from )
    4. TimeProvider from DependencyInjection
    diff --git a/Havit.Blazor.Components.Web.Bootstrap/Calendar/CalendarSettings.cs b/Havit.Blazor.Components.Web.Bootstrap/Calendar/CalendarSettings.cs index 6a8c5632..6814ae4a 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Calendar/CalendarSettings.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Calendar/CalendarSettings.cs @@ -21,8 +21,8 @@ public record CalendarSettings public CalendarDateCustomizationProviderDelegate DateCustomizationProvider { get; set; } /// - /// TimeProvider to customise the today date + /// TimeProvider to customize the today date /// - public TimeProvider? TimeProvider { get; set; } + public TimeProvider TimeProvider { get; set; } } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs index cabe7edc..a10d758c 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Calendar/HxCalendar.razor.cs @@ -116,7 +116,7 @@ static HxCalendar() /// 3. Defaults TimeProvider (configurable from )
    /// 4. TimeProvider from DependencyInjection
    /// - [Parameter] public TimeProvider? TimeProvider { get; set; } = null; + [Parameter] public TimeProvider TimeProvider { get; set; } = null; protected TimeProvider TimeProviderEffective => TimeProvider ?? GetSettings()?.TimeProvider ?? GetDefaults()?.TimeProvider ?? TimeProviderFromServices; diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs index 8b00d364..94357d48 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDate.cs @@ -130,12 +130,11 @@ public class HxInputDate : HxInputBase, IInputWithPlaceholder, I /// /// TimeProvider is resolved in the following order:
    /// 1. TimeProvider from this parameter
    - /// 2. Settings TimeProvider (configurable from )
    + /// 2. Settings TimeProvider (configurable from )
    /// 3. Defaults TimeProvider (configurable from )
    /// 4. TimeProvider from DependencyInjection
    ///
    - [Parameter] public TimeProvider? TimeProvider { get; set; } = null; - + [Parameter] public TimeProvider TimeProvider { get; set; } = null; protected TimeProvider TimeProviderEffective => TimeProvider ?? GetSettings()?.TimeProvider ?? GetDefaults().TimeProvider ?? TimeProviderFromServices; [Inject] private IStringLocalizer StringLocalizer { get; set; } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs index 9cb588a9..793c7add 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputDateRange.cs @@ -115,7 +115,7 @@ static HxInputDateRange() /// 3. Defaults TimeProvider (configurable from )
    /// 4. TimeProvider from DependencyInjection
    /// - [Parameter] public TimeProvider? TimeProvider { get; set; } = null; + [Parameter] public TimeProvider TimeProvider { get; set; } = null; protected TimeProvider TimeProviderEffective => TimeProvider ?? GetSettings()?.TimeProvider ?? GetDefaults().TimeProvider ?? TimeProviderFromServices; [Inject] private IStringLocalizer StringLocalizer { get; set; } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateRangeSettings.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateRangeSettings.cs index 36bf2dbd..fbc1b4bc 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateRangeSettings.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateRangeSettings.cs @@ -45,5 +45,5 @@ public record InputDateRangeSettings : InputSettings, IInputSettingsWithSize /// /// TimeProvider used to get DateTime.Today /// - public TimeProvider? TimeProvider { get; set; } + public TimeProvider TimeProvider { get; set; } } \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateSettings.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateSettings.cs index 9cf9175d..5ca41e75 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateSettings.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/InputDateSettings.cs @@ -50,5 +50,5 @@ public record InputDateSettings : InputSettings, IInputSettingsWithSize /// /// TimeProvider to use, note: override the 'Today' in PredefinedDates /// - public TimeProvider? TimeProvider { get; set; } + public TimeProvider TimeProvider { get; set; } } \ No newline at end of file From c3e109e768fa41c82ab7be6680cd80dcae3a38f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikul=C3=A1=C5=A1=20Hobl=C3=ADk?= Date: Wed, 8 Nov 2023 17:38:32 +0100 Subject: [PATCH 10/40] [HxMultiSelect] The italian resource for the component has a wrong name #652 --- .../{HxMultiSelect-it-IT.resx => HxMultiSelect.it-IT.resx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Havit.Blazor.Components.Web.Bootstrap/Resources/{HxMultiSelect-it-IT.resx => HxMultiSelect.it-IT.resx} (100%) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Resources/HxMultiSelect-it-IT.resx b/Havit.Blazor.Components.Web.Bootstrap/Resources/HxMultiSelect.it-IT.resx similarity index 100% rename from Havit.Blazor.Components.Web.Bootstrap/Resources/HxMultiSelect-it-IT.resx rename to Havit.Blazor.Components.Web.Bootstrap/Resources/HxMultiSelect.it-IT.resx From 97147438768f989660880c5bc6944da32e5bd529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clavek=2C=20Ond=C5=99ej?= Date: Thu, 9 Nov 2023 22:12:49 +0100 Subject: [PATCH 11/40] HxSearchBox - fix clear button padding if there is delete icon --- .../Forms/SearchBox/HxSearchBox.razor | 1 + .../Forms/SearchBox/HxSearchBox.razor.cs | 5 +++++ .../Forms/SearchBox/HxSearchBox.razor.css | 8 ++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor b/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor index c3c0a844..f9ef6573 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor @@ -43,6 +43,7 @@ class="@CssClassHelper.Combine( "form-control", (!HasInputGroupEnd && HasInputGroups ? "hx-search-box-input-with-search-icon" : null), + (HasClearButton ? "hx-search-box-input-with-clear-icon" : null), InputCssClassEffective)" /> @if (!string.IsNullOrEmpty(Label) && LabelType == Havit.Blazor.Components.Web.Bootstrap.LabelType.Floating) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.cs index 878ec232..29891ed1 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.cs @@ -218,6 +218,10 @@ public partial class HxSearchBox : IAsyncDisposable protected bool HasInputGroups => HasInputGroupStart || HasInputGroupEnd; private bool HasInputGroupStart => !String.IsNullOrWhiteSpace(InputGroupStartText) || (InputGroupStartTemplate is not null); private bool HasInputGroupEnd => !String.IsNullOrWhiteSpace(InputGroupEndText) || (InputGroupEndTemplate is not null); + private bool HasClearButton => !HasInputGroupEnd + && !dataProviderInProgress + && !string.IsNullOrEmpty(TextQuery) + && (ClearIconEffective is not null); private string dropdownToggleElementId = "hx" + Guid.NewGuid().ToString("N"); private string dropdownId = "hx" + Guid.NewGuid().ToString("N"); @@ -239,6 +243,7 @@ public partial class HxSearchBox : IAsyncDisposable private DotNetObjectReference> dotnetObjectReference; private bool clickIsComing; private bool disposed = false; + public HxSearchBox() { dotnetObjectReference = DotNetObjectReference.Create(this); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.css b/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.css index f99c4def..9012104c 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.css +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.css @@ -18,8 +18,12 @@ } ::deep .hx-search-box-input-with-search-icon { - border-top-right-radius: 0.375rem !important; - border-bottom-right-radius: 0.375rem !important; + border-top-right-radius: 0.375rem !important; + border-bottom-right-radius: 0.375rem !important; +} + +::deep .hx-search-box-input-with-clear-icon { + padding-right: 2rem; } .dropdown-item:not(:active) ::deep .hx-search-box-item-title { From bfa7e68cfbe7f9e1f767d98e8a77acdfab20914f Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Fri, 10 Nov 2023 13:09:17 +0100 Subject: [PATCH 12/40] static dictionarties - typos --- .../Services/DataStores/DictionaryStaticDataStore.cs | 10 +++++----- .../Services/DataStores/IDictionaryStaticDataStore.cs | 4 ++-- .../Services/DataStores/IStaticDataStore.cs | 4 ++-- .../Services/DataStores/StaticDataStore.cs | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Havit.Blazor.Components.Web/Services/DataStores/DictionaryStaticDataStore.cs b/Havit.Blazor.Components.Web/Services/DataStores/DictionaryStaticDataStore.cs index 801a1305..41161b15 100644 --- a/Havit.Blazor.Components.Web/Services/DataStores/DictionaryStaticDataStore.cs +++ b/Havit.Blazor.Components.Web/Services/DataStores/DictionaryStaticDataStore.cs @@ -5,15 +5,15 @@ /// /// /// Uses in-memory Dictionary to store the data. -/// Does not preload data, the data get loaded within first data-retriaval call. -/// Does not implement any memory-release logic, the data get refreshed within data-retrivals where returns true. +/// Does not preload data, the data get loaded within first data-retrieval call. +/// Does not implement any memory-release logic, the data get refreshed within data-retrievals where returns true. /// public abstract class DictionaryStaticDataStore : IDictionaryStaticDataStore { protected Dictionary Data; /// - /// Template method to implement the data retrival logic. + /// Template method to implement the data retrieval logic. /// You should never call this method directly, use to load data. /// This method is sequential (does not allow parallel runs), just take care of the data retrieval. /// Must return non-null value, use Enumerable.Empty if needed. @@ -116,9 +116,9 @@ public void Clear() } /// - /// To be called before any data-retrival to load/refresh the data.
    + /// To be called before any data-retrieval to load/refresh the data.
    /// Is automatically called before all asynchronous data-retrieval calls. - /// You have to call this method on your own (e.g. in OnInitializedAsync) before calling any sychronnous API.
    + /// You have to call this method on your own (e.g. in OnInitializedAsync) before calling any sychronous API.
    /// Uses to check for refreshment request. /// Uses lock to prevent multiple parallel loads. ///
    diff --git a/Havit.Blazor.Components.Web/Services/DataStores/IDictionaryStaticDataStore.cs b/Havit.Blazor.Components.Web/Services/DataStores/IDictionaryStaticDataStore.cs index c8d1e1c0..2d6c929d 100644 --- a/Havit.Blazor.Components.Web/Services/DataStores/IDictionaryStaticDataStore.cs +++ b/Havit.Blazor.Components.Web/Services/DataStores/IDictionaryStaticDataStore.cs @@ -6,9 +6,9 @@ public interface IDictionaryStaticDataStore { /// - /// To be called before any data-retrival to load/refresh the data.
    + /// To be called before any data-retrieval to load/refresh the data.
    /// Is automatically called before all asynchronous data-retrieval calls. - /// You have to call this method on your own (e.g. in OnInitializedAsync) before calling any sychronnous API.
    + /// You have to call this method on your own (e.g. in OnInitializedAsync) before calling any synchronous API.
    ///
    Task EnsureDataAsync(); diff --git a/Havit.Blazor.Components.Web/Services/DataStores/IStaticDataStore.cs b/Havit.Blazor.Components.Web/Services/DataStores/IStaticDataStore.cs index 63391d4c..80ba59ef 100644 --- a/Havit.Blazor.Components.Web/Services/DataStores/IStaticDataStore.cs +++ b/Havit.Blazor.Components.Web/Services/DataStores/IStaticDataStore.cs @@ -4,9 +4,9 @@ public interface IStaticDataStore { /// - /// To be called before any data-retrival to load/refresh the data.
    + /// To be called before any data-retrieval to load/refresh the data.
    /// Is automatically called before all asynchronous data-retrieval calls. - /// You have to call this method on your own (e.g. in OnInitializedAsync) before calling any sychronnous API.
    + /// You have to call this method on your own (e.g. in OnInitializedAsync) before calling any sychronous API.
    ///
    Task EnsureDataAsync(); diff --git a/Havit.Blazor.Components.Web/Services/DataStores/StaticDataStore.cs b/Havit.Blazor.Components.Web/Services/DataStores/StaticDataStore.cs index 8cd4b143..4fcf9466 100644 --- a/Havit.Blazor.Components.Web/Services/DataStores/StaticDataStore.cs +++ b/Havit.Blazor.Components.Web/Services/DataStores/StaticDataStore.cs @@ -5,8 +5,8 @@ ///
    /// /// Uses in-memory static field to store the data. -/// Does not preload data, the data get loaded within first data-retriaval call. -/// Does not implement any memory-release logic, the data get refreshed within data-retrivals where returns true. +/// Does not preload data, the data get loaded within first data-retrieval call. +/// Does not implement any memory-release logic, the data get refreshed within data-retrievals where returns true. /// public abstract class StaticDataStore : IStaticDataStore { @@ -14,7 +14,7 @@ public abstract class StaticDataStore : IStaticDataStore protected TValue Data; /// - /// Template method to implement the data retrival logic. + /// Template method to implement the data retrieval logic. /// You should never call this method directly, use to load data. /// This method is sequential (does not allow parallel runs), just take care of the data retrieval. /// Must return non-default value. @@ -64,9 +64,9 @@ public void Clear() } /// - /// To be called before any data-retrival to load/refresh the data.
    + /// To be called before any data-retrieval to load/refresh the data.
    /// Is automatically called before all asynchronous data-retrieval calls. - /// You have to call this method on your own (e.g. in OnInitializedAsync) before calling any sychronnous API.
    + /// You have to call this method on your own (e.g. in OnInitializedAsync) before calling any synchronous API.
    /// Uses to check for refreshment request. /// Uses lock to prevent multiple parallel loads. ///
    From e9c7082d481167b95a3365dbe0dd4be2dbf3ea73 Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Sat, 11 Nov 2023 01:42:27 +0100 Subject: [PATCH 13/40] fix #659 [HxInputText] Generates chip for String.Empty value --- .../Forms/HxInputBase.cs | 5 ++++ .../XmlDoc/Havit.Blazor.Components.Web.xml | 28 +++++++++---------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs index 5d3896fe..e268a544 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs @@ -352,6 +352,11 @@ protected virtual void RenderChipGenerator(RenderTreeBuilder builder) /// protected virtual bool ShouldRenderChipGenerator() { + if (CurrentValue is string currentValueString) + { + // fixes #659 [HxInputText] Generates chip for String.Empty value + return !String.IsNullOrEmpty(currentValueString); + } return !EqualityComparer.Default.Equals(CurrentValue, default(TValue)); } diff --git a/Havit.Blazor.Documentation/XmlDoc/Havit.Blazor.Components.Web.xml b/Havit.Blazor.Documentation/XmlDoc/Havit.Blazor.Components.Web.xml index bcebf7b8..4da8c7b0 100644 --- a/Havit.Blazor.Documentation/XmlDoc/Havit.Blazor.Components.Web.xml +++ b/Havit.Blazor.Documentation/XmlDoc/Havit.Blazor.Components.Web.xml @@ -871,13 +871,13 @@
    Uses in-memory Dictionary to store the data. - Does not preload data, the data get loaded within first data-retriaval call. - Does not implement any memory-release logic, the data get refreshed within data-retrivals where returns true. + Does not preload data, the data get loaded within first data-retrieval call. + Does not implement any memory-release logic, the data get refreshed within data-retrievals where returns true.
    - Template method to implement the data retrival logic. + Template method to implement the data retrieval logic. You should never call this method directly, use to load data. This method is sequential (does not allow parallel runs), just take care of the data retrieval. Must return non-null value, use Enumerable.Empty if needed. @@ -937,9 +937,9 @@ - To be called before any data-retrival to load/refresh the data.
    + To be called before any data-retrieval to load/refresh the data.
    Is automatically called before all asynchronous data-retrieval calls. - You have to call this method on your own (e.g. in OnInitializedAsync) before calling any sychronnous API.
    + You have to call this method on your own (e.g. in OnInitializedAsync) before calling any sychronous API.
    Uses to check for refreshment request. Uses lock to prevent multiple parallel loads.
    @@ -951,9 +951,9 @@
    - To be called before any data-retrival to load/refresh the data.
    + To be called before any data-retrieval to load/refresh the data.
    Is automatically called before all asynchronous data-retrieval calls. - You have to call this method on your own (e.g. in OnInitializedAsync) before calling any sychronnous API.
    + You have to call this method on your own (e.g. in OnInitializedAsync) before calling any synchronous API.
    @@ -998,9 +998,9 @@ - To be called before any data-retrival to load/refresh the data.
    + To be called before any data-retrieval to load/refresh the data.
    Is automatically called before all asynchronous data-retrieval calls. - You have to call this method on your own (e.g. in OnInitializedAsync) before calling any sychronnous API.
    + You have to call this method on your own (e.g. in OnInitializedAsync) before calling any sychronous API.
    @@ -1029,13 +1029,13 @@
    Uses in-memory static field to store the data. - Does not preload data, the data get loaded within first data-retriaval call. - Does not implement any memory-release logic, the data get refreshed within data-retrivals where returns true. + Does not preload data, the data get loaded within first data-retrieval call. + Does not implement any memory-release logic, the data get refreshed within data-retrievals where returns true.
    - Template method to implement the data retrival logic. + Template method to implement the data retrieval logic. You should never call this method directly, use to load data. This method is sequential (does not allow parallel runs), just take care of the data retrieval. Must return non-default value. @@ -1070,9 +1070,9 @@ - To be called before any data-retrival to load/refresh the data.
    + To be called before any data-retrieval to load/refresh the data.
    Is automatically called before all asynchronous data-retrieval calls. - You have to call this method on your own (e.g. in OnInitializedAsync) before calling any sychronnous API.
    + You have to call this method on your own (e.g. in OnInitializedAsync) before calling any synchronous API.
    Uses to check for refreshment request. Uses lock to prevent multiple parallel loads.
    From 7bb25b315ae020db7f08b6d8d8f4757170a32e6e Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Sat, 11 Nov 2023 01:42:55 +0100 Subject: [PATCH 14/40] release 4.2.7 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 56683500..7454d0ac 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,7 @@ latest - 4.2.6 + 4.2.7 1.4.4 From 3a2ae7c54dc010d82b418e80f3dae58bd70d5b50 Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Tue, 14 Nov 2023 12:39:33 +0100 Subject: [PATCH 15/40] net8.0 targeting --- .github/workflows/dotnet.yml | 4 ++++ BlazorAppTest/BlazorAppTest.csproj | 2 +- BlazorRTLAppTest/BlazorRTLAppTest.csproj | 2 +- .../Havit.Blazor.Components.Web.Bootstrap.Tests.csproj | 2 +- .../Havit.Blazor.Components.Web.Bootstrap.csproj | 2 +- .../Havit.Blazor.Components.Web.Tests.csproj | 2 +- .../Havit.Blazor.Components.Web.csproj | 3 ++- .../Havit.Blazor.Documentation.Server.csproj | 4 ++-- .../Properties/PublishProfiles/TfsPublish.pubxml | 2 +- .../Havit.Blazor.Documentation.Tests.csproj | 2 +- .../Havit.Blazor.Documentation.csproj | 10 +++++----- .../Havit.Blazor.GoogleTagManager.csproj | 3 ++- .../Havit.Blazor.Grpc.Client.Tests.csproj | 2 +- .../Havit.Blazor.Grpc.Client.WebAssembly.csproj | 3 ++- .../Havit.Blazor.Grpc.Client.csproj | 4 ++-- .../Havit.Blazor.Grpc.Core.Tests.csproj | 2 +- Havit.Blazor.Grpc.Core/Havit.Blazor.Grpc.Core.csproj | 2 +- .../Havit.Blazor.Grpc.Server.csproj | 2 +- .../Havit.Blazor.Grpc.TestContracts.csproj | 2 +- 19 files changed, 31 insertions(+), 24 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index c159fb72..ef059b2b 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -13,6 +13,10 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Setup .NET 8 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x - name: Setup .NET 7 uses: actions/setup-dotnet@v3 with: diff --git a/BlazorAppTest/BlazorAppTest.csproj b/BlazorAppTest/BlazorAppTest.csproj index 0d9db993..643433d3 100644 --- a/BlazorAppTest/BlazorAppTest.csproj +++ b/BlazorAppTest/BlazorAppTest.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 enable diff --git a/BlazorRTLAppTest/BlazorRTLAppTest.csproj b/BlazorRTLAppTest/BlazorRTLAppTest.csproj index 0c4b1eae..8078911f 100644 --- a/BlazorRTLAppTest/BlazorRTLAppTest.csproj +++ b/BlazorRTLAppTest/BlazorRTLAppTest.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 enable enable false diff --git a/Havit.Blazor.Components.Web.Bootstrap.Tests/Havit.Blazor.Components.Web.Bootstrap.Tests.csproj b/Havit.Blazor.Components.Web.Bootstrap.Tests/Havit.Blazor.Components.Web.Bootstrap.Tests.csproj index 292eebbc..5f10cd19 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Tests/Havit.Blazor.Components.Web.Bootstrap.Tests.csproj +++ b/Havit.Blazor.Components.Web.Bootstrap.Tests/Havit.Blazor.Components.Web.Bootstrap.Tests.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 false enable diff --git a/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj b/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj index 911f9eaa..243666c4 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj +++ b/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 enable 1591;1701;1702;SA1134;BL0007 true diff --git a/Havit.Blazor.Components.Web.Tests/Havit.Blazor.Components.Web.Tests.csproj b/Havit.Blazor.Components.Web.Tests/Havit.Blazor.Components.Web.Tests.csproj index f9876d46..f6cf0c9c 100644 --- a/Havit.Blazor.Components.Web.Tests/Havit.Blazor.Components.Web.Tests.csproj +++ b/Havit.Blazor.Components.Web.Tests/Havit.Blazor.Components.Web.Tests.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 enable false diff --git a/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj b/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj index b8c56081..caddbb17 100644 --- a/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj +++ b/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 enable 1591;1701;1702;SA1134 true @@ -26,6 +26,7 @@ + diff --git a/Havit.Blazor.Documentation.Server/Havit.Blazor.Documentation.Server.csproj b/Havit.Blazor.Documentation.Server/Havit.Blazor.Documentation.Server.csproj index 9ff7d682..e8533b50 100644 --- a/Havit.Blazor.Documentation.Server/Havit.Blazor.Documentation.Server.csproj +++ b/Havit.Blazor.Documentation.Server/Havit.Blazor.Documentation.Server.csproj @@ -1,12 +1,12 @@  - net7.0 + net8.0 enable - + diff --git a/Havit.Blazor.Documentation.Server/Properties/PublishProfiles/TfsPublish.pubxml b/Havit.Blazor.Documentation.Server/Properties/PublishProfiles/TfsPublish.pubxml index e5869d51..2a8ab281 100644 --- a/Havit.Blazor.Documentation.Server/Properties/PublishProfiles/TfsPublish.pubxml +++ b/Havit.Blazor.Documentation.Server/Properties/PublishProfiles/TfsPublish.pubxml @@ -15,7 +15,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt true havit.blazor.eu false - net7.0 + net8.0 c4cc1c76-bcc9-403a-917d-144868f1215e \ No newline at end of file diff --git a/Havit.Blazor.Documentation.Tests/Havit.Blazor.Documentation.Tests.csproj b/Havit.Blazor.Documentation.Tests/Havit.Blazor.Documentation.Tests.csproj index 56ee793b..1a10c428 100644 --- a/Havit.Blazor.Documentation.Tests/Havit.Blazor.Documentation.Tests.csproj +++ b/Havit.Blazor.Documentation.Tests/Havit.Blazor.Documentation.Tests.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 enable false diff --git a/Havit.Blazor.Documentation/Havit.Blazor.Documentation.csproj b/Havit.Blazor.Documentation/Havit.Blazor.Documentation.csproj index 4826524f..a7cb980c 100644 --- a/Havit.Blazor.Documentation/Havit.Blazor.Documentation.csproj +++ b/Havit.Blazor.Documentation/Havit.Blazor.Documentation.csproj @@ -1,17 +1,17 @@  - net7.0 + net8.0 enable 1701;1702;SA1134 - - - - + + + + diff --git a/Havit.Blazor.GoogleTagManager/Havit.Blazor.GoogleTagManager.csproj b/Havit.Blazor.GoogleTagManager/Havit.Blazor.GoogleTagManager.csproj index 8452074b..cce792ab 100644 --- a/Havit.Blazor.GoogleTagManager/Havit.Blazor.GoogleTagManager.csproj +++ b/Havit.Blazor.GoogleTagManager/Havit.Blazor.GoogleTagManager.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 enable 1591;1701;1702;SA1134 true @@ -22,6 +22,7 @@ + diff --git a/Havit.Blazor.Grpc.Client.Tests/Havit.Blazor.Grpc.Client.Tests.csproj b/Havit.Blazor.Grpc.Client.Tests/Havit.Blazor.Grpc.Client.Tests.csproj index 1e21d958..16c94e81 100644 --- a/Havit.Blazor.Grpc.Client.Tests/Havit.Blazor.Grpc.Client.Tests.csproj +++ b/Havit.Blazor.Grpc.Client.Tests/Havit.Blazor.Grpc.Client.Tests.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 enable false diff --git a/Havit.Blazor.Grpc.Client.WebAssembly/Havit.Blazor.Grpc.Client.WebAssembly.csproj b/Havit.Blazor.Grpc.Client.WebAssembly/Havit.Blazor.Grpc.Client.WebAssembly.csproj index c6aeed77..b2410f7b 100644 --- a/Havit.Blazor.Grpc.Client.WebAssembly/Havit.Blazor.Grpc.Client.WebAssembly.csproj +++ b/Havit.Blazor.Grpc.Client.WebAssembly/Havit.Blazor.Grpc.Client.WebAssembly.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 enable @@ -16,6 +16,7 @@ + diff --git a/Havit.Blazor.Grpc.Client/Havit.Blazor.Grpc.Client.csproj b/Havit.Blazor.Grpc.Client/Havit.Blazor.Grpc.Client.csproj index 7179aab8..bf50d62a 100644 --- a/Havit.Blazor.Grpc.Client/Havit.Blazor.Grpc.Client.csproj +++ b/Havit.Blazor.Grpc.Client/Havit.Blazor.Grpc.Client.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 enable @@ -18,9 +18,9 @@ + - diff --git a/Havit.Blazor.Grpc.Core.Tests/Havit.Blazor.Grpc.Core.Tests.csproj b/Havit.Blazor.Grpc.Core.Tests/Havit.Blazor.Grpc.Core.Tests.csproj index d57246ff..ac7e60cd 100644 --- a/Havit.Blazor.Grpc.Core.Tests/Havit.Blazor.Grpc.Core.Tests.csproj +++ b/Havit.Blazor.Grpc.Core.Tests/Havit.Blazor.Grpc.Core.Tests.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 enable false diff --git a/Havit.Blazor.Grpc.Core/Havit.Blazor.Grpc.Core.csproj b/Havit.Blazor.Grpc.Core/Havit.Blazor.Grpc.Core.csproj index 41ee0183..5155ea75 100644 --- a/Havit.Blazor.Grpc.Core/Havit.Blazor.Grpc.Core.csproj +++ b/Havit.Blazor.Grpc.Core/Havit.Blazor.Grpc.Core.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 enable diff --git a/Havit.Blazor.Grpc.Server/Havit.Blazor.Grpc.Server.csproj b/Havit.Blazor.Grpc.Server/Havit.Blazor.Grpc.Server.csproj index f41ce474..ed5592ca 100644 --- a/Havit.Blazor.Grpc.Server/Havit.Blazor.Grpc.Server.csproj +++ b/Havit.Blazor.Grpc.Server/Havit.Blazor.Grpc.Server.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 enable diff --git a/Havit.Blazor.Grpc.TestContracts/Havit.Blazor.Grpc.TestContracts.csproj b/Havit.Blazor.Grpc.TestContracts/Havit.Blazor.Grpc.TestContracts.csproj index e833ae30..3e94ba54 100644 --- a/Havit.Blazor.Grpc.TestContracts/Havit.Blazor.Grpc.TestContracts.csproj +++ b/Havit.Blazor.Grpc.TestContracts/Havit.Blazor.Grpc.TestContracts.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0 + net8.0;net7.0;net6.0 enable From dcfc3a072ce9e3eace2a1f6d03a187155f60fd02 Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Tue, 14 Nov 2023 13:15:14 +0100 Subject: [PATCH 16/40] add net8.0 to documentation --- Havit.Blazor.Documentation/Pages/Index.razor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Havit.Blazor.Documentation/Pages/Index.razor b/Havit.Blazor.Documentation/Pages/Index.razor index fa171975..42f8411b 100644 --- a/Havit.Blazor.Documentation/Pages/Index.razor +++ b/Havit.Blazor.Documentation/Pages/Index.razor @@ -21,8 +21,8 @@

    Havit.Blazor components have the following requirements:

      -
    • .NET 6.0 or newer (net6.0 and net7.0 multitargeting; net5.0 support dropped in v3.2)
    • -
    • Blazor WebAssembly or Blazor Server hosting model (other options not tested yet)
    • +
    • .NET 6.0 or newer (net8.0, net7.0 and net6.0 multitargeting; net5.0 support dropped in v3.2)
    • +
    • Blazor WebAssembly (preferred) or Blazor Server hosting models (other options at your own risk)
    From 3a35a4fcb7a3f63b89853e193efaff09d3f2eed3 Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Tue, 14 Nov 2023 16:03:33 +0100 Subject: [PATCH 17/40] bump dependencies (net8 final) --- .../Havit.Blazor.Components.Web.Bootstrap.Tests.csproj | 2 +- .../Havit.Blazor.Components.Web.Bootstrap.csproj | 2 +- .../Havit.Blazor.Components.Web.Tests.csproj | 2 +- .../Havit.Blazor.Components.Web.csproj | 8 ++++---- .../Havit.Blazor.Documentation.Server.csproj | 2 +- .../Havit.Blazor.Documentation.Tests.csproj | 2 +- .../Havit.Blazor.Documentation.csproj | 8 ++++---- .../Havit.Blazor.GoogleTagManager.csproj | 6 +++--- .../Havit.Blazor.Grpc.Client.Tests.csproj | 2 +- .../Havit.Blazor.Grpc.Client.WebAssembly.csproj | 6 +++--- .../Havit.Blazor.Grpc.Client.csproj | 10 +++++----- .../Havit.Blazor.Grpc.Core.Tests.csproj | 2 +- .../Havit.Blazor.Grpc.Server.csproj | 4 ++-- .../Havit.Extensions.Localization.csproj | 2 +- 14 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap.Tests/Havit.Blazor.Components.Web.Bootstrap.Tests.csproj b/Havit.Blazor.Components.Web.Bootstrap.Tests/Havit.Blazor.Components.Web.Bootstrap.Tests.csproj index 5f10cd19..3802d7b9 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Tests/Havit.Blazor.Components.Web.Bootstrap.Tests.csproj +++ b/Havit.Blazor.Components.Web.Bootstrap.Tests/Havit.Blazor.Components.Web.Bootstrap.Tests.csproj @@ -8,7 +8,7 @@ - + diff --git a/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj b/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj index 243666c4..473c30c7 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj +++ b/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj @@ -37,7 +37,7 @@ - + diff --git a/Havit.Blazor.Components.Web.Tests/Havit.Blazor.Components.Web.Tests.csproj b/Havit.Blazor.Components.Web.Tests/Havit.Blazor.Components.Web.Tests.csproj index f6cf0c9c..7959d7a8 100644 --- a/Havit.Blazor.Components.Web.Tests/Havit.Blazor.Components.Web.Tests.csproj +++ b/Havit.Blazor.Components.Web.Tests/Havit.Blazor.Components.Web.Tests.csproj @@ -8,7 +8,7 @@ - + diff --git a/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj b/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj index caddbb17..8a453eaa 100644 --- a/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj +++ b/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj @@ -25,10 +25,10 @@ - - - - + + + + diff --git a/Havit.Blazor.Documentation.Server/Havit.Blazor.Documentation.Server.csproj b/Havit.Blazor.Documentation.Server/Havit.Blazor.Documentation.Server.csproj index e8533b50..baa09e02 100644 --- a/Havit.Blazor.Documentation.Server/Havit.Blazor.Documentation.Server.csproj +++ b/Havit.Blazor.Documentation.Server/Havit.Blazor.Documentation.Server.csproj @@ -6,7 +6,7 @@
    - + diff --git a/Havit.Blazor.Documentation.Tests/Havit.Blazor.Documentation.Tests.csproj b/Havit.Blazor.Documentation.Tests/Havit.Blazor.Documentation.Tests.csproj index 1a10c428..5d4e3083 100644 --- a/Havit.Blazor.Documentation.Tests/Havit.Blazor.Documentation.Tests.csproj +++ b/Havit.Blazor.Documentation.Tests/Havit.Blazor.Documentation.Tests.csproj @@ -9,7 +9,7 @@ - + diff --git a/Havit.Blazor.Documentation/Havit.Blazor.Documentation.csproj b/Havit.Blazor.Documentation/Havit.Blazor.Documentation.csproj index a7cb980c..ad21952d 100644 --- a/Havit.Blazor.Documentation/Havit.Blazor.Documentation.csproj +++ b/Havit.Blazor.Documentation/Havit.Blazor.Documentation.csproj @@ -8,10 +8,10 @@ - - - - + + + + diff --git a/Havit.Blazor.GoogleTagManager/Havit.Blazor.GoogleTagManager.csproj b/Havit.Blazor.GoogleTagManager/Havit.Blazor.GoogleTagManager.csproj index cce792ab..e4499ca2 100644 --- a/Havit.Blazor.GoogleTagManager/Havit.Blazor.GoogleTagManager.csproj +++ b/Havit.Blazor.GoogleTagManager/Havit.Blazor.GoogleTagManager.csproj @@ -22,9 +22,9 @@ - - - + + + diff --git a/Havit.Blazor.Grpc.Client.Tests/Havit.Blazor.Grpc.Client.Tests.csproj b/Havit.Blazor.Grpc.Client.Tests/Havit.Blazor.Grpc.Client.Tests.csproj index 16c94e81..f1d92f95 100644 --- a/Havit.Blazor.Grpc.Client.Tests/Havit.Blazor.Grpc.Client.Tests.csproj +++ b/Havit.Blazor.Grpc.Client.Tests/Havit.Blazor.Grpc.Client.Tests.csproj @@ -7,7 +7,7 @@
    - + diff --git a/Havit.Blazor.Grpc.Client.WebAssembly/Havit.Blazor.Grpc.Client.WebAssembly.csproj b/Havit.Blazor.Grpc.Client.WebAssembly/Havit.Blazor.Grpc.Client.WebAssembly.csproj index b2410f7b..f4bfe6ca 100644 --- a/Havit.Blazor.Grpc.Client.WebAssembly/Havit.Blazor.Grpc.Client.WebAssembly.csproj +++ b/Havit.Blazor.Grpc.Client.WebAssembly/Havit.Blazor.Grpc.Client.WebAssembly.csproj @@ -16,9 +16,9 @@
    - - - + + + diff --git a/Havit.Blazor.Grpc.Client/Havit.Blazor.Grpc.Client.csproj b/Havit.Blazor.Grpc.Client/Havit.Blazor.Grpc.Client.csproj index bf50d62a..405d7ee7 100644 --- a/Havit.Blazor.Grpc.Client/Havit.Blazor.Grpc.Client.csproj +++ b/Havit.Blazor.Grpc.Client/Havit.Blazor.Grpc.Client.csproj @@ -15,12 +15,12 @@ https://github.com/havit/Havit.Blazor
    - - + + - - - + + + diff --git a/Havit.Blazor.Grpc.Core.Tests/Havit.Blazor.Grpc.Core.Tests.csproj b/Havit.Blazor.Grpc.Core.Tests/Havit.Blazor.Grpc.Core.Tests.csproj index ac7e60cd..e9faa592 100644 --- a/Havit.Blazor.Grpc.Core.Tests/Havit.Blazor.Grpc.Core.Tests.csproj +++ b/Havit.Blazor.Grpc.Core.Tests/Havit.Blazor.Grpc.Core.Tests.csproj @@ -8,7 +8,7 @@ - + diff --git a/Havit.Blazor.Grpc.Server/Havit.Blazor.Grpc.Server.csproj b/Havit.Blazor.Grpc.Server/Havit.Blazor.Grpc.Server.csproj index ed5592ca..427ef1be 100644 --- a/Havit.Blazor.Grpc.Server/Havit.Blazor.Grpc.Server.csproj +++ b/Havit.Blazor.Grpc.Server/Havit.Blazor.Grpc.Server.csproj @@ -16,13 +16,13 @@ - + - + diff --git a/Havit.Extensions.Localization/Havit.Extensions.Localization.csproj b/Havit.Extensions.Localization/Havit.Extensions.Localization.csproj index 219283f1..dba9a25d 100644 --- a/Havit.Extensions.Localization/Havit.Extensions.Localization.csproj +++ b/Havit.Extensions.Localization/Havit.Extensions.Localization.csproj @@ -6,7 +6,7 @@ - + From 3194500818ff40e8daded2e90bbb196668c7a816 Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Tue, 14 Nov 2023 16:10:04 +0100 Subject: [PATCH 18/40] bump Microsoft.Bcl.TimeProvider + only for net6+7 --- Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj b/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj index b85f8d45..a1755958 100644 --- a/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj +++ b/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj @@ -29,7 +29,7 @@ - + From 4c38623ba0c98c193ca0a59cde37b78e67507afa Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Tue, 14 Nov 2023 17:37:43 +0100 Subject: [PATCH 19/40] release 4.3.0-pre1 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index a68a3be4..d4e399a1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,7 @@ latest - 4.2.7-TimeProvider + 4.3.0-pre1 1.4.4 From ed7e26365f31d666c173fd62f35739ed553bc18e Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Wed, 15 Nov 2023 00:30:19 +0100 Subject: [PATCH 20/40] net8 self-contained publish --- .../Properties/PublishProfiles/TfsPublish.pubxml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Havit.Blazor.Documentation.Server/Properties/PublishProfiles/TfsPublish.pubxml b/Havit.Blazor.Documentation.Server/Properties/PublishProfiles/TfsPublish.pubxml index 2a8ab281..d30b8467 100644 --- a/Havit.Blazor.Documentation.Server/Properties/PublishProfiles/TfsPublish.pubxml +++ b/Havit.Blazor.Documentation.Server/Properties/PublishProfiles/TfsPublish.pubxml @@ -9,13 +9,14 @@ by editing this MSBuild file. In order to learn more about this please visit htt Release Any CPU - True - False + true + false obj\Release\TfsPublish\DocumentationWeb.zip true havit.blazor.eu - false + true net8.0 c4cc1c76-bcc9-403a-917d-144868f1215e + win-x86
    \ No newline at end of file From ea910bb6131daaf6115c3ba427678c3b65995232 Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Wed, 15 Nov 2023 01:21:00 +0100 Subject: [PATCH 21/40] HxAnchorFragmentNavigation no longer needed in net8 --- BlazorAppTest/Pages/HxScrollspyTest.razor | 4 ++++ .../Navigation/HxAnchorFragmentNavigation.cs | 4 ++++ .../HxAnchorFragmentNavigation_Demo.razor | 6 +++++- .../HxAnchorFragmentNavigation_Documentation.razor | 10 ++++++++-- .../HxScrollspy_Demo_CustomNavigationContent.razor | 4 +--- .../HxScrollspy_Demo_DynamicContent.razor | 4 ---- .../HxScrollspyDoc/HxScrollspy_Demo_HxNav.razor | 4 +--- .../HxScrollspy_Demo_ListGroup.razor | 3 +-- .../HxScrollspyDoc/HxScrollspy_Documentation.razor | 2 +- Havit.Blazor.Documentation/Shared/MainLayout.razor | 4 +--- Havit.Blazor.Documentation/Shared/Sidebar.razor | 14 +++++++++++++- 11 files changed, 39 insertions(+), 20 deletions(-) diff --git a/BlazorAppTest/Pages/HxScrollspyTest.razor b/BlazorAppTest/Pages/HxScrollspyTest.razor index bb5cae8c..d027ce20 100644 --- a/BlazorAppTest/Pages/HxScrollspyTest.razor +++ b/BlazorAppTest/Pages/HxScrollspyTest.razor @@ -1,5 +1,8 @@ @page "/HxScrollspyTest" @inject NavigationManager NavigationManager +@{ +#pragma warning disable 0618 // HxAnchorFragmentNavigation +}

    Scrollspy Tests

    @@ -100,4 +103,5 @@ await anchorFragmentNavigationComponent.ScrollToCurrentUriFragmentAsync(); } } +#pragma warning restore 0618 } \ No newline at end of file diff --git a/Havit.Blazor.Components.Web.Bootstrap/Navigation/HxAnchorFragmentNavigation.cs b/Havit.Blazor.Components.Web.Bootstrap/Navigation/HxAnchorFragmentNavigation.cs index 0cd2c93a..b2a67afb 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Navigation/HxAnchorFragmentNavigation.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Navigation/HxAnchorFragmentNavigation.cs @@ -8,6 +8,10 @@ namespace Havit.Blazor.Components.Web.Bootstrap; /// GitHub Issue: Blazor 0.8.0: hash routing to named element #8393.
    /// Full documentation and demos: https://havit.blazor.eu/components/HxAnchorFragmentNavigation ///
    + +#if NET8_0_OR_GREATER +[Obsolete("HxAnchorFragmentNavigation is no longer needed. ASP.NET Core Blazor 8 resolves the issue with anchor fragments.")] +#endif public class HxAnchorFragmentNavigation : ComponentBase, IAsyncDisposable { /// diff --git a/Havit.Blazor.Documentation/Pages/Components/HxAnchorFragmentNavigationDoc/HxAnchorFragmentNavigation_Demo.razor b/Havit.Blazor.Documentation/Pages/Components/HxAnchorFragmentNavigationDoc/HxAnchorFragmentNavigation_Demo.razor index d8198385..07e6f63b 100644 --- a/Havit.Blazor.Documentation/Pages/Components/HxAnchorFragmentNavigationDoc/HxAnchorFragmentNavigation_Demo.razor +++ b/Havit.Blazor.Documentation/Pages/Components/HxAnchorFragmentNavigationDoc/HxAnchorFragmentNavigation_Demo.razor @@ -1,4 +1,8 @@ - @* Usually hosted in MainLayout.razor *@ +@{ +#pragma warning disable 0618 // HxAnchorFragmentNavigation is obsolete in net8.0 +} + + @* Usually hosted in MainLayout.razor *@ Par1 Par2 diff --git a/Havit.Blazor.Documentation/Pages/Components/HxAnchorFragmentNavigationDoc/HxAnchorFragmentNavigation_Documentation.razor b/Havit.Blazor.Documentation/Pages/Components/HxAnchorFragmentNavigationDoc/HxAnchorFragmentNavigation_Documentation.razor index e4432c80..3c88e377 100644 --- a/Havit.Blazor.Documentation/Pages/Components/HxAnchorFragmentNavigationDoc/HxAnchorFragmentNavigation_Documentation.razor +++ b/Havit.Blazor.Documentation/Pages/Components/HxAnchorFragmentNavigationDoc/HxAnchorFragmentNavigation_Documentation.razor @@ -1,8 +1,14 @@ -@attribute [Route("/components/" + nameof(HxAnchorFragmentNavigation))] - +@attribute [Route("/components/HxAnchorFragmentNavigation")] +@{ +#pragma warning disable 0618 // HxAnchorFragmentNavigation +} + Starting with net8.0 this component is no longer needed as Blazor supports anchor-fragment navigation natively. + + + As Blazor uses the <base> element, all the links have to include full page path! diff --git a/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_CustomNavigationContent.razor b/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_CustomNavigationContent.razor index e9c425e4..6a09d51d 100644 --- a/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_CustomNavigationContent.razor +++ b/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_CustomNavigationContent.razor @@ -1,6 +1,4 @@ - @* Usually placed in @page *@ - -
    +
    diff --git a/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_DynamicContent.razor b/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_DynamicContent.razor index 035f3a82..1c53101f 100644 --- a/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_DynamicContent.razor +++ b/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_DynamicContent.razor @@ -60,11 +60,8 @@
    - @* Usually placed in @page *@ - @code { private HxScrollspy scrollspyComponent; - private HxAnchorFragmentNavigation anchorFragmentNavigationComponent; private bool loaded; private bool shouldRefreshScrollspy; @@ -81,7 +78,6 @@ { shouldRefreshScrollspy = false; await scrollspyComponent.RefreshAsync(); - await anchorFragmentNavigationComponent.ScrollToCurrentUriFragmentAsync(); } } } \ No newline at end of file diff --git a/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_HxNav.razor b/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_HxNav.razor index 5ca4a991..dedd0f81 100644 --- a/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_HxNav.razor +++ b/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_HxNav.razor @@ -1,6 +1,4 @@ - @* Usually placed in @page *@ - - + Par 1 Par 2 Par 3 diff --git a/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_ListGroup.razor b/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_ListGroup.razor index 0c5eac11..88c2f66e 100644 --- a/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_ListGroup.razor +++ b/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Demo_ListGroup.razor @@ -1,5 +1,4 @@ - @* Usually placed in @page *@ -
    +
    diff --git a/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Documentation.razor b/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Documentation.razor index 8c273f2a..f3127e44 100644 --- a/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Documentation.razor +++ b/Havit.Blazor.Documentation/Pages/Components/HxScrollspyDoc/HxScrollspy_Documentation.razor @@ -12,7 +12,7 @@

    The scrollspy navigation has to use custom HxScrollspyNavLink to workaround the <base> Blazor requirement and inability of Bootstrap to interpret the page#fragment form of link.

    -

    For anchor-fragment navigation (<a href="#id">) to work the page have to host HxAnchorFragmentNavigation component.

    +

    For anchor-fragment navigation (<a href="#id">) to work in net7.0 and earlier the page has to host HxAnchorFragmentNavigation component.

    Current component design expects the scrollspy to by used in dedicated scrollable container diff --git a/Havit.Blazor.Documentation/Shared/MainLayout.razor b/Havit.Blazor.Documentation/Shared/MainLayout.razor index b49205d9..a8ed68c0 100644 --- a/Havit.Blazor.Documentation/Shared/MainLayout.razor +++ b/Havit.Blazor.Documentation/Shared/MainLayout.razor @@ -15,6 +15,4 @@
    On this page
    -
    - - \ No newline at end of file +
    \ No newline at end of file diff --git a/Havit.Blazor.Documentation/Shared/Sidebar.razor b/Havit.Blazor.Documentation/Shared/Sidebar.razor index 4acf71a9..3a00b106 100644 --- a/Havit.Blazor.Documentation/Shared/Sidebar.razor +++ b/Havit.Blazor.Documentation/Shared/Sidebar.razor @@ -85,8 +85,14 @@ + @{ +#pragma warning disable 0618 // Obsolete + } - + @{ +#pragma warning restore 0618 + } + @@ -113,7 +119,13 @@ + @{ +#pragma warning disable 0618 // Obsolete + } + @{ +#pragma warning restore 0618 + } From 2cbc452e3c7bcb0237111c6707b847626a8ec2dc Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Wed, 15 Nov 2023 01:21:27 +0100 Subject: [PATCH 22/40] release 4.3.0-pre2 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index d4e399a1..50c96a12 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,7 @@ latest - 4.3.0-pre1 + 4.3.0-pre2 1.4.4 From 321c59a4b77ec6045888061f706a142990373009 Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Wed, 15 Nov 2023 01:59:03 +0100 Subject: [PATCH 23/40] gRPC packages release 1.5.0-pre2 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 50c96a12..f505fc7c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,7 @@ 4.3.0-pre2 - 1.4.4 + 1.5.0-pre2 From 35222eccc193db1d5b98c3429dbce0ac3f6d1588 Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Wed, 15 Nov 2023 02:37:11 +0100 Subject: [PATCH 24/40] release 4.3.0 (gRPC 1.5.0) --- Directory.Build.props | 4 ++-- .../Havit.Blazor.GoogleTagManager.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index f505fc7c..f9de40f3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,8 +11,8 @@ latest - 4.3.0-pre2 - 1.5.0-pre2 + 4.3.0 + 1.5.0 diff --git a/Havit.Blazor.GoogleTagManager/Havit.Blazor.GoogleTagManager.csproj b/Havit.Blazor.GoogleTagManager/Havit.Blazor.GoogleTagManager.csproj index e4499ca2..5559f19d 100644 --- a/Havit.Blazor.GoogleTagManager/Havit.Blazor.GoogleTagManager.csproj +++ b/Havit.Blazor.GoogleTagManager/Havit.Blazor.GoogleTagManager.csproj @@ -14,7 +14,7 @@ - 1.1.3 + 1.2.0 HAVIT Blazor Library - Google Tag Manager support (incl. optional automatic page-views tracking) MIT https://github.com/havit/Havit.Blazor From 7a726e721ea8196804304e3566e94e659a6ff439 Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Wed, 15 Nov 2023 11:53:50 +0100 Subject: [PATCH 25/40] bump dependencies --- .../Havit.Blazor.Components.Web.Bootstrap.Tests.csproj | 2 +- .../Havit.Blazor.Components.Web.Bootstrap.csproj | 2 +- .../Havit.Blazor.Components.Web.Tests.csproj | 2 +- .../Havit.Blazor.Components.Web.csproj | 4 ++-- .../Havit.Blazor.Documentation.Tests.csproj | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap.Tests/Havit.Blazor.Components.Web.Bootstrap.Tests.csproj b/Havit.Blazor.Components.Web.Bootstrap.Tests/Havit.Blazor.Components.Web.Bootstrap.Tests.csproj index 3802d7b9..26c8c5cc 100644 --- a/Havit.Blazor.Components.Web.Bootstrap.Tests/Havit.Blazor.Components.Web.Bootstrap.Tests.csproj +++ b/Havit.Blazor.Components.Web.Bootstrap.Tests/Havit.Blazor.Components.Web.Bootstrap.Tests.csproj @@ -7,7 +7,7 @@ - + diff --git a/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj b/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj index 473c30c7..30c8cac9 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj +++ b/Havit.Blazor.Components.Web.Bootstrap/Havit.Blazor.Components.Web.Bootstrap.csproj @@ -37,7 +37,7 @@ - + diff --git a/Havit.Blazor.Components.Web.Tests/Havit.Blazor.Components.Web.Tests.csproj b/Havit.Blazor.Components.Web.Tests/Havit.Blazor.Components.Web.Tests.csproj index 7959d7a8..eb8f259b 100644 --- a/Havit.Blazor.Components.Web.Tests/Havit.Blazor.Components.Web.Tests.csproj +++ b/Havit.Blazor.Components.Web.Tests/Havit.Blazor.Components.Web.Tests.csproj @@ -7,7 +7,7 @@ - + diff --git a/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj b/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj index a1755958..feaa0c21 100644 --- a/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj +++ b/Havit.Blazor.Components.Web/Havit.Blazor.Components.Web.csproj @@ -25,11 +25,11 @@ - + - + diff --git a/Havit.Blazor.Documentation.Tests/Havit.Blazor.Documentation.Tests.csproj b/Havit.Blazor.Documentation.Tests/Havit.Blazor.Documentation.Tests.csproj index 5d4e3083..20332352 100644 --- a/Havit.Blazor.Documentation.Tests/Havit.Blazor.Documentation.Tests.csproj +++ b/Havit.Blazor.Documentation.Tests/Havit.Blazor.Documentation.Tests.csproj @@ -8,7 +8,7 @@ - + From e8018fa53bd1054305bc3fd760a28d57acef547d Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Wed, 15 Nov 2023 11:54:14 +0100 Subject: [PATCH 26/40] release 4.3.1 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index f9de40f3..1853915e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,7 @@ latest - 4.3.0 + 4.3.1 1.5.0 From 0f3c95f2d88f21e6a0cbd2b327b239d1a091daa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikul=C3=A1=C5=A1=20Hobl=C3=ADk?= Date: Wed, 15 Nov 2023 16:37:11 +0100 Subject: [PATCH 27/40] [docs] Link to component property leads to type definition instead of component #657 --- Havit.Blazor.Documentation/Model/MemberModel.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Havit.Blazor.Documentation/Model/MemberModel.cs b/Havit.Blazor.Documentation/Model/MemberModel.cs index ef61222a..9b6d50a2 100644 --- a/Havit.Blazor.Documentation/Model/MemberModel.cs +++ b/Havit.Blazor.Documentation/Model/MemberModel.cs @@ -165,7 +165,8 @@ private string GenerateHavitDocumentationLink(string[] splitLink) } } - isComponent = ApiTypeHelper.GetType(splitLink[^2])?.IsSubclassOf(typeof(ComponentBase)) ?? false; + string className = GetFullGenericTypeName(splitLink[^2]); + isComponent = ApiTypeHelper.GetType(className)?.IsSubclassOf(typeof(ComponentBase)) ?? false; } else { From c9598aac15911e7940d81050fb0a9366e7736e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikul=C3=A1=C5=A1=20Hobl=C3=ADk?= Date: Wed, 15 Nov 2023 16:51:44 +0100 Subject: [PATCH 28/40] [docs] Fix links to defaults --- Havit.Blazor.Documentation/Model/MemberModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Havit.Blazor.Documentation/Model/MemberModel.cs b/Havit.Blazor.Documentation/Model/MemberModel.cs index ef61222a..b96e9917 100644 --- a/Havit.Blazor.Documentation/Model/MemberModel.cs +++ b/Havit.Blazor.Documentation/Model/MemberModel.cs @@ -112,7 +112,7 @@ private string HandleSupportClasses(string[] splitLink, string fullLink) if (splitLink[^1] == "Defaults") { - string internalTypeLink = ApiRenderer.GenerateLinkForInternalType($"{splitLink[^2].Remove(0, 2)}{splitLink[^1]}", false, $"{splitLink[^2]}.{splitLink[^1]}"); // We have to generate a type name suitable for the support type page. + string internalTypeLink = ApiRenderer.GenerateLinkForInternalType($"{splitLink[^2].Remove(0, 2)}Settings", false, $"{splitLink[^2]}.{splitLink[^1]}"); // We have to generate a type name suitable for the support type page. if (internalTypeLink is not null) { return internalTypeLink; From 7bc551e959f0e78c8f20de57b915c55e55da2d0f Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Sat, 18 Nov 2023 23:26:45 +0100 Subject: [PATCH 29/40] HxAlert - invalid error message fix --- Havit.Blazor.Components.Web.Bootstrap/Alerts/HxAlert.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Alerts/HxAlert.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Alerts/HxAlert.razor.cs index 1d880df7..60928e09 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Alerts/HxAlert.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Alerts/HxAlert.razor.cs @@ -27,7 +27,7 @@ protected override void OnParametersSet() { base.OnParametersSet(); - Contract.Requires(Color != ThemeColor.None, $"Parameter {nameof(Color)} of {nameof(HxBadge)} is required."); + Contract.Requires(Color != ThemeColor.None, $"Parameter {nameof(Color)} of {nameof(HxAlert)} is required."); } public string GetColorCss() From 25053bb9e49d1f611dbdcde601bd38bf081da2b0 Mon Sep 17 00:00:00 2001 From: dominikcrha Date: Sun, 19 Nov 2023 23:04:00 +0100 Subject: [PATCH 30/40] HAVIT theme hover-background-color opracity -> 10% --- .../wwwroot/defaults.css | 8 ++++---- .../HxCalendarDoc/HxCalendar_Documentation.razor | 4 ++-- .../HxInputFileDropZone_Documentation.razor | 2 +- .../Components/HxSidebarDoc/HxSidebar_Documentation.razor | 7 ++----- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap/wwwroot/defaults.css b/Havit.Blazor.Components.Web.Bootstrap/wwwroot/defaults.css index 5570a278..9ac38955 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/wwwroot/defaults.css +++ b/Havit.Blazor.Components.Web.Bootstrap/wwwroot/defaults.css @@ -24,11 +24,11 @@ --hx-sidebar-item-margin: 0 0 .25rem 0; --hx-sidebar-item-hover-color: var(--bs-primary); --hx-sidebar-item-hover-background-color: var(--bs-primary-rgb); - --hx-sidebar-item-hover-background-opacity: .05; + --hx-sidebar-item-hover-background-opacity: .1; --hx-sidebar-item-hover-icon-color: var(--bs-primary); --hx-sidebar-item-active-color: var(--bs-primary); --hx-sidebar-item-active-background-color: var(--bs-primary-rgb); - --hx-sidebar-item-active-background-opacity: .05; + --hx-sidebar-item-active-background-opacity: .1; --hx-sidebar-item-active-icon-color: var(--bs-primary); --hx-sidebar-subitem-font-size: .875rem; --hx-sidebar-subitem-padding: .5rem; @@ -92,7 +92,7 @@ --hx-input-file-drop-zone-disabled-color: var(--bs-secondary-color); --hx-input-file-drop-zone-disabled-background-color: var(--bs-secondary-bg); --hx-input-file-drop-zone-background-color: transparent; - --hx-input-file-drop-zone-hover-background-color: rgba(var(--bs-primary-rgb), .05); + --hx-input-file-drop-zone-hover-background-color: rgba(var(--bs-primary-rgb), .1); --hx-input-file-drop-zone-hover-border-color: var(--bs-primary); --hx-input-file-drop-zone-border-radius: var(--bs-border-radius-lg); --hx-input-file-drop-zone-margin: 0; @@ -115,7 +115,7 @@ --hx-calendar-navigation-button-text-color: var(--bs-tertiary-color); --hx-calendar-day-today-border: none; --hx-calendar-day-today-background: var(--bs-primary-rgb); - --hx-calendar-day-today-background-opacity: .05; + --hx-calendar-day-today-background-opacity: .1; --hx-calendar-day-today-color: var(--bs-primary); --hx-calendar-day-border-radius: var(--bs-border-radius-sm); --hx-calendar-day-padding: .375rem .5rem; diff --git a/Havit.Blazor.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor b/Havit.Blazor.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor index b52cdf8e..3b41ea11 100644 --- a/Havit.Blazor.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor +++ b/Havit.Blazor.Documentation/Pages/Components/HxCalendarDoc/HxCalendar_Documentation.razor @@ -41,7 +41,7 @@

    Use the ZonedTimeProvider. Ensure that Defaults are configured in Program.cs or where you maintain your other defaults. Please expand to provide appropriate error handling, caching, etc. depending on your needs.

    - + @@ -96,7 +96,7 @@ Background of today. - + Background opacity of today. diff --git a/Havit.Blazor.Documentation/Pages/Components/HxInputFileDropZoneDoc/HxInputFileDropZone_Documentation.razor b/Havit.Blazor.Documentation/Pages/Components/HxInputFileDropZoneDoc/HxInputFileDropZone_Documentation.razor index a9d3c16b..c8e04494 100644 --- a/Havit.Blazor.Documentation/Pages/Components/HxInputFileDropZoneDoc/HxInputFileDropZone_Documentation.razor +++ b/Havit.Blazor.Documentation/Pages/Components/HxInputFileDropZoneDoc/HxInputFileDropZone_Documentation.razor @@ -29,7 +29,7 @@ Background color. - + Background color on hover. diff --git a/Havit.Blazor.Documentation/Pages/Components/HxSidebarDoc/HxSidebar_Documentation.razor b/Havit.Blazor.Documentation/Pages/Components/HxSidebarDoc/HxSidebar_Documentation.razor index e7288590..a7f3a4c2 100644 --- a/Havit.Blazor.Documentation/Pages/Components/HxSidebarDoc/HxSidebar_Documentation.razor +++ b/Havit.Blazor.Documentation/Pages/Components/HxSidebarDoc/HxSidebar_Documentation.razor @@ -82,7 +82,7 @@ Background color of the items on hover. - + Background opacity of the items on hover. @@ -91,10 +91,7 @@ Color of the active item icon. - - Background opacity of the active item. - - + Background opacity of the active item. From e77d7d0a4a1d5904a7c617aa50abcb60a3bd7bd0 Mon Sep 17 00:00:00 2001 From: dominikcrha Date: Sun, 19 Nov 2023 23:16:39 +0100 Subject: [PATCH 31/40] To align btn size in Sidebar header to Sidebar nav items --- .../Components/DocColorMode/DocColorModeSwitcher.razor.css | 4 ++-- .../Shared/Components/GitHubLink.razor.css | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Havit.Blazor.Documentation/Shared/Components/DocColorMode/DocColorModeSwitcher.razor.css b/Havit.Blazor.Documentation/Shared/Components/DocColorMode/DocColorModeSwitcher.razor.css index 6a97269c..fc2f2877 100644 --- a/Havit.Blazor.Documentation/Shared/Components/DocColorMode/DocColorModeSwitcher.razor.css +++ b/Havit.Blazor.Documentation/Shared/Components/DocColorMode/DocColorModeSwitcher.razor.css @@ -2,6 +2,6 @@ --bs-btn-hover-bg: var(--bs-secondary-bg); --bs-btn-active-bg: var(--bs-secondary-bg); --bs-btn-active-border-color: transparent; - --bs-btn-padding-x: .5rem; - --bs-btn-padding-y: .25rem; + --bs-btn-padding-x: 11px; + --bs-btn-padding-y: 7px; } \ No newline at end of file diff --git a/Havit.Blazor.Documentation/Shared/Components/GitHubLink.razor.css b/Havit.Blazor.Documentation/Shared/Components/GitHubLink.razor.css index 9ed11d39..67ce77b8 100644 --- a/Havit.Blazor.Documentation/Shared/Components/GitHubLink.razor.css +++ b/Havit.Blazor.Documentation/Shared/Components/GitHubLink.razor.css @@ -2,6 +2,6 @@ --bs-btn-hover-bg: var(--bs-secondary-bg); --bs-btn-active-bg: var(--bs-secondary-bg); --bs-btn-active-border-color: transparent; - --bs-btn-padding-x: .5rem; - --bs-btn-padding-y: 0.25rem; + --bs-btn-padding-x: 11px; + --bs-btn-padding-y: 7px; } \ No newline at end of file From 2d5f760dd7981af96c19af8e64b5706ba1fdc375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clavek=2C=20Ond=C5=99ej?= Date: Tue, 21 Nov 2023 20:09:25 +0100 Subject: [PATCH 32/40] HxSearchBox - fix right button padding and test page --- BlazorAppTest/Pages/HxSearchBoxTest.razor | 14 +++++++++++++- .../Forms/SearchBox/HxSearchBox.razor.css | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/BlazorAppTest/Pages/HxSearchBoxTest.razor b/BlazorAppTest/Pages/HxSearchBoxTest.razor index 6faa5a44..f9db4a8d 100644 --- a/BlazorAppTest/Pages/HxSearchBoxTest.razor +++ b/BlazorAppTest/Pages/HxSearchBoxTest.razor @@ -1,6 +1,18 @@ @page "/HxSearchBoxTest" - + + +
    Search for Mouse, Table or Door...
    +
    +
    + + + +
    Search for Mouse, Table or Door...
    +
    +
    + +
    Search for Mouse, Table or Door...
    diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.css b/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.css index 9012104c..9125bc8b 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.css +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.css @@ -23,7 +23,7 @@ } ::deep .hx-search-box-input-with-clear-icon { - padding-right: 2rem; + padding-right: 2.375rem; } .dropdown-item:not(:active) ::deep .hx-search-box-item-title { From cf624e86a7408bd7af1cc33cfac6cf1500070b5f Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Thu, 23 Nov 2023 14:49:58 +0100 Subject: [PATCH 33/40] doc Getting started update (net8) --- ...ingStarted_RegisterServices.CodeSnippet.cs | 14 ----- Havit.Blazor.Documentation/Pages/Index.razor | 52 +++++++++++-------- 2 files changed, 30 insertions(+), 36 deletions(-) delete mode 100644 Havit.Blazor.Documentation/Pages/GettingStarted_RegisterServices.CodeSnippet.cs diff --git a/Havit.Blazor.Documentation/Pages/GettingStarted_RegisterServices.CodeSnippet.cs b/Havit.Blazor.Documentation/Pages/GettingStarted_RegisterServices.CodeSnippet.cs deleted file mode 100644 index d3f6c719..00000000 --- a/Havit.Blazor.Documentation/Pages/GettingStarted_RegisterServices.CodeSnippet.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Havit.Blazor.Components.Web; // <------ ADD THIS LINE -using Havit.Blazor.Components.Web.Bootstrap; // <------ ADD THIS LINE - -public static async Task Main(string[] args) -{ - var builder = WebAssemblyHostBuilder.CreateDefault(args); - builder.RootComponents.Add("app"); - - // ... shortened for brevity - - builder.Services.AddHxServices(); // <------ ADD THIS LINE - - await builder.Build().RunAsync(); -} \ No newline at end of file diff --git a/Havit.Blazor.Documentation/Pages/Index.razor b/Havit.Blazor.Documentation/Pages/Index.razor index 42f8411b..902ed8d1 100644 --- a/Havit.Blazor.Documentation/Pages/Index.razor +++ b/Havit.Blazor.Documentation/Pages/Index.razor @@ -32,54 +32,62 @@ -

    Find the Havit.Blazor.Components.Web.Bootstrap package through NuGet Package Manager or install it with following command:

    +

    To incorporate the Havit.Blazor.Components.Web.Bootstrap package into your project, you can use the NuGet Package Manager or execute the following command:

    dotnet add package Havit.Blazor.Components.Web.Bootstrap +

    This package should be added to the project where the components will be utilized, typically in the user interface layer. For instance, in Visual Studio Blazor templates, this would be YourApp.Client.

    - -

    Add CSS & JavaScript references.

    + +

    To ensure proper styling and functionality, add references to CSS and JavaScript in your project.

    -

    Add the following to your HTML <head> section, it's either index.html or _Host.cshtml/_Layout.cshtml depending on whether you're running WebAssembly or Server:

    +

    Insert the following line into the <head> section of your HTML file. The specific file to modify depends on your project's configuration. This could be App.razor, index.html, or _Host.cshtml/_Layout.cshtml:

    -

    If you want to use our custom Bootstrap theme (used in this documentation and demos), replace the first link with:

    +

    [ALTERNATIVE] If you prefer to utilize our custom Bootstrap theme, which is used in this documentation and our demos, substitute the first link with the following:

    -

    You can reference your own or any other Bootstrap build/theme in a same way.

    +

    Similarly, you can reference your custom Bootstrap build or any other Bootstrap theme in the same manner.

    - If you're using a standard Blazor template make sure to remove unnecessary code from site.css and remove the bootstrap.min.css completely from either index.html or _Host.cshtml/_Layout.cshtml. + If you're utilizing a standard Blazor template, it's important to clean up your CSS files. Specifically, you should remove any unnecessary code from site.css and completely delete the bootstrap.min.css reference from either App.razor, index.html or _Host.cshtml/_Layout.cshtml. -

    At the end of HTML <body> section of either index.html add this (Bootstrap JavaScript Bundle with Popper):

    -<!-- JavaScript Bundle with Popper --> @HxSetup.RenderBootstrapJavaScriptReference() -

    It you are hosting you Blazor app in ASP.NET Core server-generated HTML file (e.g. _Host.cshtml/_Layout.cshtml), you can use our helper-method to emit the <script /> tag and automate versioning:

    +

    In the same HTML file, add the following line at the end of the <body> section. This includes the Bootstrap JavaScript Bundle with Popper:

    + + @HxSetup.RenderBootstrapJavaScriptReference() + + +

    [ALTERNATIVE] If your Blazor app is hosted using an ASP.NET Core Razor Page (for example, using _Host.cshtml/_Layout.cshtml), take advantage of our helper method. This method automatically emits the <script /> tag and handles versioning for you:

    <!-- JavaScript Bundle with Popper --> @@Html.Raw(HxSetup.RenderBootstrapJavaScriptReference()) -

    Add following to your _Imports.razor file:

    +

    Add following code to your _Imports.razor file:

    -

    For Blazor WebAssembly add the following to your Program.Main:

    - +

    Add the following line of code to your services registration, typically found in the Program.cs file of your Blazor client project:

    +builder.Services.AddHxServices();

    - For Blazor Server (or WASM with server pre-rendering) add those registrations to your Startup.cs file, ConfigureServices() method. - (You won't use the builder there, register the services to the services collection.) + For projects that originated from earlier Blazor templates, these service registrations may be found in the Startup.cs file, + specifically within the ConfigureServices() method. Note that in this case, you will not use the builder; + instead, register the services directly to the services collection.

    -

    [OPTIONAL] Some of the components need a specific project setup to work. This usually includes registering a service and adding a host-component to App.razor or layout component.

    -

    For instructions see documentation of those components:

    +

    + [OPTIONAL] Some components require a specific project setup to function correctly. + This typically involves registering a service and adding a host component to App.razor or a MainLayout.razor component. +

    +

    For detailed instructions, please refer to the documentation of the respective components:

    -

    Now you are ready to use all the components in your razor files. They come with Hx prefix. IntelliSense will be your friend...

    +

    You are now all set to utilize the full range of components in your Razor files. These components are prefixed with Hx. Rely on IntelliSense to guide you through their usage.

    - This whole documentation is built using the Havit.Blazor library and is running as Blazor WebAssembly ASP.NET Core Hosted project with server-prerendering. - See documentation source code on GitHub. + This entire documentation is created using the Havit.Blazor library and operates as a Blazor WebAssembly ASP.NET Core Hosted project + with server-side prerendering. You can view the source code of this documentation on GitHub. From 0352dded91438c3fff66f3408f1ea61754c54c09 Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Thu, 23 Nov 2023 18:36:23 +0100 Subject: [PATCH 34/40] #668 [HxInputBase] Not binding to properties in net8's server-side rendering (SSR) --- .../Forms/Autosuggests/HxAutosuggest.cs | 3 + .../Internal/HxAutosuggestInputInternal.razor | 1 + .../HxAutosuggestInputInternal.razor.cs | 2 + .../Internal/HxAutosuggestInternal.razor | 1 + .../Internal/HxAutosuggestInternal.razor.cs | 2 + .../Forms/HxInputBase.cs | 16 ++- .../Forms/HxInputRange.cs | 6 + .../Forms/HxInputTextBase.cs | 14 ++- .../Forms/Internal/HxInputDateInternal.razor | 117 +++++++++--------- .../Internal/HxInputDateInternal.razor.cs | 9 ++ .../TreeViews/HxTreeView.razor | 38 +++--- 11 files changed, 123 insertions(+), 86 deletions(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/HxAutosuggest.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/HxAutosuggest.cs index 90e6577c..d555e488 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/HxAutosuggest.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/HxAutosuggest.cs @@ -172,6 +172,9 @@ protected override void BuildRenderInput(RenderTreeBuilder builder) builder.AddAttribute(1023, nameof(HxAutosuggestInternal.InputGroupStartTemplate), this.InputGroupStartTemplate); builder.AddAttribute(1024, nameof(HxAutosuggestInternal.InputGroupEndText), this.InputGroupEndText); builder.AddAttribute(1025, nameof(HxAutosuggestInternal.InputGroupEndTemplate), this.InputGroupEndTemplate); +#if NET8_0_OR_GREATER + builder.AddAttribute(1026, nameof(HxAutosuggestInternal.NameAttributeValue), NameAttributeValue); +#endif builder.AddMultipleAttributes(2000, this.AdditionalAttributes); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/Internal/HxAutosuggestInputInternal.razor b/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/Internal/HxAutosuggestInputInternal.razor index 7110e47d..245f8e97 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/Internal/HxAutosuggestInputInternal.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/Internal/HxAutosuggestInputInternal.razor @@ -2,6 +2,7 @@ [Parameter] public (int Skidding, int Distance) DropdownOffset { get; set; } + [Parameter] public string NameAttributeValue { get; set; } + /// /// Additional attributes to be splatted onto an underlying HTML element. /// diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/Internal/HxAutosuggestInternal.razor b/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/Internal/HxAutosuggestInternal.razor index 87c3a6a4..25fe8d76 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/Internal/HxAutosuggestInternal.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/Internal/HxAutosuggestInternal.razor @@ -13,6 +13,7 @@
    : IAsyncDisposable ///
    [Parameter] public RenderFragment InputGroupEndTemplate { get; set; } + [Parameter] public string NameAttributeValue { get; set; } + /// /// Additional attributes to be splatted onto an underlying HTML element. /// diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs index e268a544..e3e2e253 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputBase.cs @@ -295,16 +295,22 @@ private protected virtual void BuildRenderInput_AddCommonAttributes(RenderTreeBu { builder.AddMultipleAttributes(1, AdditionalAttributes); builder.AddAttribute(2, "id", InputId); - builder.AddAttribute(3, "type", typeValue); - builder.AddAttribute(4, "class", GetInputCssClassToRender()); - builder.AddAttribute(5, "disabled", !EnabledEffective); +#if NET8_0_OR_GREATER + if (!String.IsNullOrEmpty(this.NameAttributeValue)) + { + builder.AddAttribute(3, "name", NameAttributeValue); + } +#endif + builder.AddAttribute(4, "type", typeValue); + builder.AddAttribute(5, "class", GetInputCssClassToRender()); + builder.AddAttribute(6, "disabled", !EnabledEffective); if ((this is IInputWithLabelType inputWithLabelType) && (inputWithLabelType.LabelTypeEffective == LabelType.Floating)) { - builder.AddAttribute(6, "placeholder", "placeholder"); // there must be a nonempty value (which is not visible) + builder.AddAttribute(7, "placeholder", "placeholder"); // there must be a nonempty value (which is not visible) } else if (this is IInputWithPlaceholder inputWithPlaceholder) { - builder.AddAttribute(7, "placeholder", inputWithPlaceholder.Placeholder); + builder.AddAttribute(8, "placeholder", inputWithPlaceholder.Placeholder); } } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputRange.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputRange.cs index 5c8780cf..70cbfa60 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputRange.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputRange.cs @@ -96,6 +96,12 @@ protected override void BuildRenderInput(RenderTreeBuilder builder) builder.AddAttribute(20, "disabled", !EnabledEffective); builder.AddAttribute(30, "id", InputId); +#if NET8_0_OR_GREATER + if (!String.IsNullOrEmpty(NameAttributeValue)) + { + builder.AddAttribute(31, "name", NameAttributeValue); + } +#endif // Capture ElementReference to the input to make focusing it programmatically possible. builder.AddElementReferenceCapture(40, value => InputElement = value); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputTextBase.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputTextBase.cs index 6401109c..9ff52bdd 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputTextBase.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/HxInputTextBase.cs @@ -77,13 +77,19 @@ protected override void BuildRenderInput(RenderTreeBuilder builder) builder.AddAttribute(1002, "value", FormatValueAsString(Value)); builder.AddAttribute(1003, BindEvent.ToEventName(), EventCallback.Factory.CreateBinder(this, value => CurrentValueAsString = value, CurrentValueAsString)); - if (this.InputModeEffective is not null) +#if NET8_0_OR_GREATER + if (!String.IsNullOrEmpty(this.NameAttributeValue)) { - builder.AddAttribute(1004, "inputmode", this.InputModeEffective.Value.ToString("f").ToLower()); + builder.AddAttribute(1004, "name", NameAttributeValue); } +#endif - builder.AddEventStopPropagationAttribute(1005, "onclick", true); - builder.AddElementReferenceCapture(1006, elementReference => InputElement = elementReference); + if (this.InputModeEffective is not null) + { + builder.AddAttribute(1005, "inputmode", this.InputModeEffective.Value.ToString("f").ToLower()); + } + builder.AddEventStopPropagationAttribute(1006, "onclick", true); + builder.AddElementReferenceCapture(1007, elementReference => InputElement = elementReference); builder.CloseElement(); } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor index fc7264e9..f76a0ce0 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor @@ -4,77 +4,78 @@ @if (FieldIdentifier.Model != null) { -
    - + AutoClose="DropdownAutoClose.Outside"> - @if (InputGroupStartText is not null) - { - @InputGroupStartText - } + @if (InputGroupStartText is not null) + { + @InputGroupStartText + } - @InputGroupStartTemplate + @InputGroupStartTemplate - + - @InputGroupEndTemplate + @InputGroupEndTemplate - @if (InputGroupEndText is not null) - { - @InputGroupEndText - } + @if (InputGroupEndText is not null) + { + @InputGroupEndText + } - @if (LabelTypeEffective == Havit.Blazor.Components.Web.Bootstrap.LabelType.Floating) - { - - } + @if (LabelTypeEffective == Havit.Blazor.Components.Web.Bootstrap.LabelType.Floating) + { + + } - - @if (EnabledEffective) - { -
    - -
    -
    - @if (ShowClearButtonEffective) - { - - } - @if (RenderPredefinedDates) - { - foreach (var item in PredefinedDatesEffective) - { - - } - } -
    - } -
    -
    - @if (RenderIcon) - { -
    - -
    - } -
    + + @if (EnabledEffective) + { +
    + +
    +
    + @if (ShowClearButtonEffective) + { + + } + @if (RenderPredefinedDates) + { + foreach (var item in PredefinedDatesEffective) + { + + } + } +
    + } +
    + + @if (RenderIcon) + { +
    + +
    + } +
} diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs index 65103566..f7cf55ec 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs @@ -185,6 +185,15 @@ private void ClearPreviousParsingMessage() } } + private string GetNameAttributeValue() + { +#if NET8_0_OR_GREATER + return String.IsNullOrEmpty(NameAttributeValue) ? null : NameAttributeValue; +#else + return null; +#endif + } + internal static TValue GetValueFromDateTimeOffset(DateTimeOffset? value) { if (value == null) diff --git a/Havit.Blazor.Components.Web.Bootstrap/TreeViews/HxTreeView.razor b/Havit.Blazor.Components.Web.Bootstrap/TreeViews/HxTreeView.razor index 45db43f5..643e9c7b 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/TreeViews/HxTreeView.razor +++ b/Havit.Blazor.Components.Web.Bootstrap/TreeViews/HxTreeView.razor @@ -3,23 +3,23 @@ @typeparam TItem
- - @foreach (var item in this.Items) - { - - } - + + @foreach (var item in this.Items) + { + + } +
\ No newline at end of file From ebb09dbb79d76e35467942c1825fdf335516482e Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Thu, 23 Nov 2023 18:36:46 +0100 Subject: [PATCH 35/40] release 4.3.2-pre1 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 1853915e..6b501c82 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,7 @@ latest - 4.3.1 + 4.3.2-pre1 1.5.0 From 0a8782ac9bd36430c3d91486fed3ba2299e995dc Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Fri, 24 Nov 2023 02:02:26 +0100 Subject: [PATCH 36/40] release 4.3.2 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6b501c82..0eb7eded 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,7 @@ latest - 4.3.2-pre1 + 4.3.2 1.5.0 From f6d795430f794fc0abe00032bde3fc29c780040b Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Mon, 27 Nov 2023 12:21:30 +0100 Subject: [PATCH 37/40] fixes #674 TaskCanceledException - Error when switching pages with the new .Net8 application template --- .../Carousel/HxCarousel.razor.cs | 4 ++++ .../Collapse/HxCollapse.razor.cs | 4 ++++ .../Dropdowns/HxDropdownToggleButton.cs | 4 ++++ .../Dropdowns/HxDropdownToggleElement.cs | 4 ++++ .../Autosuggests/Internal/HxAutosuggestInternal.razor.cs | 4 ++++ .../Forms/Internal/HxInputDateInternal.razor.cs | 4 ++++ .../Forms/Internal/HxInputDateRangeInternal.razor.cs | 4 ++++ .../Forms/Internal/HxMultiSelectInternal.razor.cs | 4 ++++ .../Forms/SearchBox/HxSearchBox.razor.cs | 4 ++++ .../Modals/HxModal.razor.cs | 8 ++++++++ .../Navigation/HxScrollspy.razor.cs | 4 ++++ .../Offcanvas/HxOffcanvas.razor.cs | 8 ++++++++ .../Tags/Internal/HxInputTagsInternal.razor.cs | 4 ++++ Havit.Blazor.Components.Web.Bootstrap/Toasts/HxToast.cs | 4 ++++ .../Tooltips/Internal/HxTooltipInternalBase.cs | 8 ++++++++ Havit.Blazor.Components.Web/Files/HxInputFileCore.cs | 6 +++++- 16 files changed, 77 insertions(+), 1 deletion(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap/Carousel/HxCarousel.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Carousel/HxCarousel.razor.cs index cab51182..cb65f3d1 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Carousel/HxCarousel.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Carousel/HxCarousel.razor.cs @@ -236,6 +236,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } dotnetObjectReference?.Dispose(); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Collapse/HxCollapse.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Collapse/HxCollapse.razor.cs index d9de69de..1837ff1b 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Collapse/HxCollapse.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Collapse/HxCollapse.razor.cs @@ -256,6 +256,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } dotnetObjectReference?.Dispose(); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Dropdowns/HxDropdownToggleButton.cs b/Havit.Blazor.Components.Web.Bootstrap/Dropdowns/HxDropdownToggleButton.cs index 3c1b763b..a827344f 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Dropdowns/HxDropdownToggleButton.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Dropdowns/HxDropdownToggleButton.cs @@ -217,6 +217,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } dotnetObjectReference.Dispose(); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Dropdowns/HxDropdownToggleElement.cs b/Havit.Blazor.Components.Web.Bootstrap/Dropdowns/HxDropdownToggleElement.cs index b59fbc72..af57e557 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Dropdowns/HxDropdownToggleElement.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Dropdowns/HxDropdownToggleElement.cs @@ -219,6 +219,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } dotnetObjectReference.Dispose(); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/Internal/HxAutosuggestInternal.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/Internal/HxAutosuggestInternal.razor.cs index c10fdca1..e092e765 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/Internal/HxAutosuggestInternal.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Autosuggests/Internal/HxAutosuggestInternal.razor.cs @@ -491,6 +491,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } dotnetObjectReference?.Dispose(); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs index f7cf55ec..289267ea 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateInternal.razor.cs @@ -267,6 +267,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } Dispose(false); } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor.cs index 1f379b40..74063d93 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxInputDateRangeInternal.razor.cs @@ -297,6 +297,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } Dispose(false); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxMultiSelectInternal.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxMultiSelectInternal.razor.cs index 8b0ef51b..cb5f441c 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxMultiSelectInternal.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/Internal/HxMultiSelectInternal.razor.cs @@ -268,6 +268,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } dotnetObjectReference?.Dispose(); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.cs index 878ec232..62c25c25 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Forms/SearchBox/HxSearchBox.razor.cs @@ -646,6 +646,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } dotnetObjectReference?.Dispose(); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Modals/HxModal.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Modals/HxModal.razor.cs index 67de03bf..f1bc9621 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Modals/HxModal.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Modals/HxModal.razor.cs @@ -375,6 +375,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } try @@ -385,6 +389,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } dotnetObjectReference.Dispose(); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Navigation/HxScrollspy.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Navigation/HxScrollspy.razor.cs index 613e1a98..5a48be78 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Navigation/HxScrollspy.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Navigation/HxScrollspy.razor.cs @@ -96,6 +96,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } } } diff --git a/Havit.Blazor.Components.Web.Bootstrap/Offcanvas/HxOffcanvas.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Offcanvas/HxOffcanvas.razor.cs index f8cf1714..243ea4c1 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Offcanvas/HxOffcanvas.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Offcanvas/HxOffcanvas.razor.cs @@ -310,6 +310,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } try @@ -320,6 +324,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } dotnetObjectReference.Dispose(); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Tags/Internal/HxInputTagsInternal.razor.cs b/Havit.Blazor.Components.Web.Bootstrap/Tags/Internal/HxInputTagsInternal.razor.cs index f7aa5b8a..69c85517 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Tags/Internal/HxInputTagsInternal.razor.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Tags/Internal/HxInputTagsInternal.razor.cs @@ -546,6 +546,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } dotnetObjectReference.Dispose(); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Toasts/HxToast.cs b/Havit.Blazor.Components.Web.Bootstrap/Toasts/HxToast.cs index d4a20eca..d60e942a 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Toasts/HxToast.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Toasts/HxToast.cs @@ -254,6 +254,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } dotnetObjectReference.Dispose(); diff --git a/Havit.Blazor.Components.Web.Bootstrap/Tooltips/Internal/HxTooltipInternalBase.cs b/Havit.Blazor.Components.Web.Bootstrap/Tooltips/Internal/HxTooltipInternalBase.cs index 93a005a4..34c2615b 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/Tooltips/Internal/HxTooltipInternalBase.cs +++ b/Havit.Blazor.Components.Web.Bootstrap/Tooltips/Internal/HxTooltipInternalBase.cs @@ -335,6 +335,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } try { @@ -344,6 +348,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } jsModule = null; isInitialized = false; } diff --git a/Havit.Blazor.Components.Web/Files/HxInputFileCore.cs b/Havit.Blazor.Components.Web/Files/HxInputFileCore.cs index d30d0377..00102434 100644 --- a/Havit.Blazor.Components.Web/Files/HxInputFileCore.cs +++ b/Havit.Blazor.Components.Web/Files/HxInputFileCore.cs @@ -266,7 +266,7 @@ protected virtual async ValueTask DisposeAsyncCore() { disposed = true; - // Microsoft violates the pattern - there is no protected virtual voud Dispose(bool) method and the IDisposable implementation is explicit. + // Microsoft violates the pattern - there is no protected virtual void Dispose(bool) method and the IDisposable implementation is explicit. ((IDisposable)this).Dispose(); if (jsModule != null) @@ -280,6 +280,10 @@ protected virtual async ValueTask DisposeAsyncCore() { // NOOP } + catch (TaskCanceledException) + { + // NOOP + } } dotnetObjectReference.Dispose(); From a8df7d1f865fa0872d8fdb75e7d97838d252495f Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Mon, 27 Nov 2023 12:21:51 +0100 Subject: [PATCH 38/40] release 4.3.3 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 0eb7eded..7f228e04 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,7 @@ latest - 4.3.2 + 4.3.3 1.5.0 From db403e2941838f6f8f82ffb37a669375a1a8760c Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Tue, 28 Nov 2023 00:29:18 +0100 Subject: [PATCH 39/40] fixes #675 [HxSearchBox] Cannot read properties of null (reading 'removeEventListener') at Module.dispose --- .../wwwroot/HxSearchBox.js | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Havit.Blazor.Components.Web.Bootstrap/wwwroot/HxSearchBox.js b/Havit.Blazor.Components.Web.Bootstrap/wwwroot/HxSearchBox.js index 52080e59..c7e9db91 100644 --- a/Havit.Blazor.Components.Web.Bootstrap/wwwroot/HxSearchBox.js +++ b/Havit.Blazor.Components.Web.Bootstrap/wwwroot/HxSearchBox.js @@ -4,23 +4,23 @@ return; } - inputElement.hxSearchBoxDotnetObjectReference = hxSearchBoxDotnetObjectReference; + inputElement.hxSearchBoxDotnetObjectReference = hxSearchBoxDotnetObjectReference; inputElement.hxSearchBoxKeysToPreventDefault = keysToPreventDefault; - inputElement.addEventListener('keydown', handleKeyDown); + inputElement.addEventListener('keydown', handleKeyDown); inputElement.addEventListener('mousedown', handleMouseDown); inputElement.addEventListener('mouseup', handleMouseUp); } function handleKeyDown(event) { - let key = event.key; + let key = event.key; - event.target.hxSearchBoxDotnetObjectReference.invokeMethodAsync("HxSearchBox_HandleInputKeyDown", key); + event.target.hxSearchBoxDotnetObjectReference.invokeMethodAsync("HxSearchBox_HandleInputKeyDown", key); if (event.target.hxSearchBoxKeysToPreventDefault.includes(key)) { - event.preventDefault(); - } + event.preventDefault(); + } } function handleMouseDown(event) { @@ -32,7 +32,6 @@ function handleMouseUp(event) { event.target.clickIsComing = false; } - export function scrollToFocusedItem() { const focusedElements = document.getElementsByClassName("hx-dropdown-item-focused"); if (focusedElements && focusedElements[0]) { @@ -41,11 +40,14 @@ export function scrollToFocusedItem() { } export function dispose(inputId) { - let inputElement = document.getElementById(inputId); + let inputElement = document.getElementById(inputId); + if (!inputElement) { + return; + } - inputElement.removeEventListener('keydown', handleKeyDown); + inputElement.removeEventListener('keydown', handleKeyDown); inputElement.removeEventListener('mousedown', handleMouseDown); inputElement.removeEventListener('mouseup', handleMouseUp); - inputElement.hxSearchBoxDotnetObjectReference = null; + inputElement.hxSearchBoxDotnetObjectReference = null; inputElement.hxSearchBoxKeysToPreventDefault = null; } From 6c1e7e0ba10e53ba86898c9af5af206f622b5e8b Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Tue, 28 Nov 2023 00:29:36 +0100 Subject: [PATCH 40/40] release 4.3.4 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 7f228e04..48f8c0ff 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,7 @@ latest - 4.3.3 + 4.3.4 1.5.0