diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 0b000d5cc42..a8ebde4532f 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@  - 9.4.9-beta05 + 9.4.9-beta06 diff --git a/src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs b/src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs index 434b85e1942..aa19153d6ce 100644 --- a/src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs +++ b/src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs @@ -27,7 +27,7 @@ public partial class Dialog : IDisposable private Dictionary? _currentParameter; private bool _isKeyboard = false; private bool _isBackdrop = false; - private bool _isFade = true; + private bool? _isFade = null; /// /// diff --git a/src/BootstrapBlazor/Components/Dialog/DialogOption.cs b/src/BootstrapBlazor/Components/Dialog/DialogOption.cs index 3ebbc45547d..ac271149044 100644 --- a/src/BootstrapBlazor/Components/Dialog/DialogOption.cs +++ b/src/BootstrapBlazor/Components/Dialog/DialogOption.cs @@ -68,9 +68,9 @@ public class DialogOption public bool ShowHeaderCloseButton { get; set; } = true; /// - /// Gets or sets whether to enable fade animation, default is true + /// Gets or sets whether to enable fade animation, default is null /// - public bool IsFade { get; set; } = true; + public bool? IsFade { get; set; } /// /// Gets or sets whether to support closing the dialog with the ESC key, default is true diff --git a/src/BootstrapBlazor/Components/Modal/Modal.razor.cs b/src/BootstrapBlazor/Components/Modal/Modal.razor.cs index c19ecb9adf1..ddd35097035 100644 --- a/src/BootstrapBlazor/Components/Modal/Modal.razor.cs +++ b/src/BootstrapBlazor/Components/Modal/Modal.razor.cs @@ -12,11 +12,15 @@ namespace BootstrapBlazor.Components; /// public partial class Modal { + [Inject] + [NotNull] + private IOptionsMonitor? Options { get; set; } + /// /// Gets the style string /// private string? ClassString => CssBuilder.Default("modal") - .AddClass("fade", IsFade) + .AddClass("fade", Options.CurrentValue.GetIsFadeValue(IsFade)) .AddClassFromAttributes(AdditionalAttributes) .Build(); @@ -40,10 +44,10 @@ public partial class Modal public bool IsKeyboard { get; set; } = true; /// - /// Gets or sets whether to enable fade in and out animation, default is true to enable animation + /// Gets or sets whether to enable fade in and out animation, default is null /// [Parameter] - public bool IsFade { get; set; } = true; + public bool? IsFade { get; set; } /// /// Gets or sets the child component diff --git a/src/BootstrapBlazor/Components/SweetAlert/SweetAlert.razor b/src/BootstrapBlazor/Components/SweetAlert/SweetAlert.razor index 38432bdfc31..0951f3b3167 100644 --- a/src/BootstrapBlazor/Components/SweetAlert/SweetAlert.razor +++ b/src/BootstrapBlazor/Components/SweetAlert/SweetAlert.razor @@ -2,6 +2,6 @@ @inherits BootstrapComponentBase @inject SwalService Swal - + @RenderDialog() diff --git a/src/BootstrapBlazor/Extensions/BootstrapBlazorOptionsExtensions.cs b/src/BootstrapBlazor/Extensions/BootstrapBlazorOptionsExtensions.cs index b6548811774..802e9606ba9 100644 --- a/src/BootstrapBlazor/Extensions/BootstrapBlazorOptionsExtensions.cs +++ b/src/BootstrapBlazor/Extensions/BootstrapBlazorOptionsExtensions.cs @@ -6,27 +6,35 @@ namespace BootstrapBlazor.Components; /// -/// BootstrapBlazorOptions 配置类扩展方法 +/// BootstrapBlazorOptions configuration class extension methods /// public static class BootstrapBlazorOptionsExtensions { /// - /// 获取步长泛型方法 + /// Get step size generic method /// - /// - /// - /// + /// The type parameter + /// The BootstrapBlazorOptions instance + /// The step size as a string public static string? GetStep(this BootstrapBlazorOptions options) => options.GetStep(typeof(TType)); /// - /// 获取步长方法 + /// Get step size method /// - /// 配置实体类实例 - /// 数据类型 - /// + /// The BootstrapBlazorOptions instance + /// The data type + /// The step size as a string public static string? GetStep(this BootstrapBlazorOptions options, Type type) { var t = Nullable.GetUnderlyingType(type) ?? type; return options.StepSettings.GetStep(t); } + + /// + /// Get Modal IsFade value + /// + /// The BootstrapBlazorOptions instance + /// The default value + /// The IsFade value as a boolean + public static bool GetIsFadeValue(this BootstrapBlazorOptions options, bool? value) => value ?? options.ModalSettings.IsFade ?? true; } diff --git a/src/BootstrapBlazor/Options/BootstrapBlazorOptions.cs b/src/BootstrapBlazor/Options/BootstrapBlazorOptions.cs index 5e736586aa4..9983d3491f2 100644 --- a/src/BootstrapBlazor/Options/BootstrapBlazorOptions.cs +++ b/src/BootstrapBlazor/Options/BootstrapBlazorOptions.cs @@ -86,42 +86,47 @@ public class BootstrapBlazorOptions : IOptions public string? JSModuleVersion { get; set; } /// - /// Gets or sets the table settings instance + /// Gets or sets the configuration instance /// public TableSettings TableSettings { get; set; } = new(); + /// + /// Gets or sets the configuration instance + /// + public ModalSettings ModalSettings { get; set; } = new(); + /// /// Gets or sets the configuration instance /// public StepSettings StepSettings { get; set; } = new(); /// - /// Gets or sets the configuration, default is not null + /// Gets or sets the configuration /// public ConnectionHubOptions ConnectionHubOptions { get; set; } = new(); /// - /// Gets or sets the configuration, default is not null + /// Gets or sets the configuration /// public WebClientOptions WebClientOptions { get; set; } = new(); /// - /// Gets or sets the configuration, default is not null + /// Gets or sets the configuration /// public IpLocatorOptions IpLocatorOptions { get; set; } = new(); /// - /// Gets or sets the configuration, default is not null + /// Gets or sets the configuration /// public ScrollOptions ScrollOptions { get; set; } = new(); /// - /// Gets or sets the configuration, default is not null + /// Gets or sets the configuration /// public ContextMenuOptions ContextMenuOptions { get; set; } = new(); /// - /// Gets or sets the CacheManagerOptions configuration, default is not null + /// Gets or sets the CacheManagerOptions configuration /// public CacheManagerOptions CacheManagerOptions { get; set; } = new(); diff --git a/src/BootstrapBlazor/Options/ModalSettings.cs b/src/BootstrapBlazor/Options/ModalSettings.cs new file mode 100644 index 00000000000..7666b45f79a --- /dev/null +++ b/src/BootstrapBlazor/Options/ModalSettings.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License +// See the LICENSE file in the project root for more information. +// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone + +namespace BootstrapBlazor.Components; + +/// +/// Modal component settings +/// +public class ModalSettings +{ + /// + /// Gets or sets whether to enable fade animation, default is null + /// + public bool? IsFade { get; set; } +}