diff --git a/CodeBeam.MudBlazor.Extensions/Base/MudBaseInputExtended.cs b/CodeBeam.MudBlazor.Extensions/Base/MudBaseInputExtended.cs index 052b4156..857c0881 100644 --- a/CodeBeam.MudBlazor.Extensions/Base/MudBaseInputExtended.cs +++ b/CodeBeam.MudBlazor.Extensions/Base/MudBaseInputExtended.cs @@ -13,7 +13,11 @@ namespace MudExtensions public abstract class MudBaseInputExtended : MudFormComponent { private bool _isDirty; + private bool _validated; + /// + /// + /// protected MudBaseInputExtended() : base(new DefaultConverter()) { } [CascadingParameter(Name = "ParentDisabled")] private bool ParentDisabled { get; set; } @@ -72,7 +76,7 @@ protected MudBaseInputExtended() : base(new DefaultConverter()) { } /// [Parameter] [Category(CategoryTypes.FormComponent.Behavior)] - public string HelperText { get; set; } + public string? HelperText { get; set; } /// /// If true, the helper text will only be visible on focus. @@ -86,14 +90,14 @@ protected MudBaseInputExtended() : base(new DefaultConverter()) { } /// [Parameter] [Category(CategoryTypes.FormComponent.Behavior)] - public string AdornmentIcon { get; set; } + public string? AdornmentIcon { get; set; } /// /// Text that will be used if Adornment is set to Start or End, the Text overrides Icon. /// [Parameter] [Category(CategoryTypes.FormComponent.Behavior)] - public string AdornmentText { get; set; } + public string? AdornmentText { get; set; } /// /// The Adornment if used. By default, it is set to None. @@ -107,14 +111,21 @@ protected MudBaseInputExtended() : base(new DefaultConverter()) { } /// [Parameter] [Category(CategoryTypes.FormComponent.Behavior)] - public RenderFragment AdornmentStart { get; set; } + public RenderFragment? AdornmentStart { get; set; } /// /// The Adornment if used. By default, it is set to None. /// [Parameter] [Category(CategoryTypes.FormComponent.Behavior)] - public RenderFragment AdornmentEnd { get; set; } + public RenderFragment? AdornmentEnd { get; set; } + + /// + /// The aria-label of the adornment. + /// + [Parameter] + [Category(CategoryTypes.FormComponent.Appearance)] + public string? AdornmentAriaLabel { get; set; } = string.Empty; /// /// The validation is only triggered if the user has changed the input value at least once. By default, it is false @@ -128,7 +139,7 @@ protected MudBaseInputExtended() : base(new DefaultConverter()) { } /// [Parameter] [Category(CategoryTypes.FormComponent.Behavior)] - public bool ForceShrink { get; set; } + public bool ShrinkLabel { get; set; } /// /// The color of the adornment if used. It supports the theme colors. @@ -137,13 +148,6 @@ protected MudBaseInputExtended() : base(new DefaultConverter()) { } [Category(CategoryTypes.FormComponent.Appearance)] public Color AdornmentColor { get; set; } = Color.Default; - /// - /// The aria-label of the adornment. - /// - [Parameter] - [Category(CategoryTypes.FormComponent.Appearance)] - public string AdornmentAriaLabel { get; set; } = string.Empty; - /// /// The Icon Size. /// @@ -175,7 +179,7 @@ protected MudBaseInputExtended() : base(new DefaultConverter()) { } /// [Parameter] [Category(CategoryTypes.FormComponent.Behavior)] - public string Placeholder { get; set; } + public string? Placeholder { get; set; } /// /// If set, will display the counter, value 0 will display current count but no stop count. @@ -196,7 +200,7 @@ protected MudBaseInputExtended() : base(new DefaultConverter()) { } /// [Parameter] [Category(CategoryTypes.FormComponent.Behavior)] - public string Label { get; set; } + public string? Label { get; set; } /// /// If true the input will focus automatically. @@ -242,13 +246,13 @@ protected MudBaseInputExtended() : base(new DefaultConverter()) { } /// [Parameter] [Category(CategoryTypes.FormComponent.Validation)] - public virtual string Pattern { get; set; } + public virtual string? Pattern { get; set; } /// /// CSS style of the child content. /// [Parameter] - public string ChildContentStyle { get; set; } + public string? ChildContentStyle { get; set; } /// /// Sync the value, values and text, calls validation manually. Useful to call after user changes value or text programmatically. @@ -264,11 +268,18 @@ public virtual async Task ForceUpdate() /// internal virtual InputType GetInputType() { return InputType.Text; } + /// + /// + /// + /// + /// + /// protected virtual async Task SetTextAsync(string? text, bool updateValue = true) { if (Text != text) { Text = text; + _validated = false; if (!string.IsNullOrWhiteSpace(Text)) Touched = true; if (updateValue) @@ -314,7 +325,7 @@ protected virtual Task UpdateTextPropertyAsync(bool updateValue) /// /// Fired when the text value changes. /// - [Parameter] public EventCallback TextChanged { get; set; } + [Parameter] public EventCallback TextChanged { get; set; } /// /// Fired when the element loses focus. @@ -327,16 +338,32 @@ protected virtual Task UpdateTextPropertyAsync(bool updateValue) [Parameter] public EventCallback OnInternalInputChanged { get; set; } + /// + /// + /// protected bool _isFocused; + /// + /// + /// + /// + /// protected internal virtual async Task OnBlurredAsync(FocusEventArgs obj) { + if (ReadOnly) + { + return; + } + _isFocused = false; if (!OnlyValidateIfDirty || _isDirty) { Touched = true; - await BeginValidationAfterAsync(OnBlur.InvokeAsync(obj)); + if (_validated) + await OnBlur.InvokeAsync(obj); + else + await BeginValidationAfterAsync(OnBlur.InvokeAsync(obj)); } } @@ -345,7 +372,12 @@ protected internal virtual async Task OnBlurredAsync(FocusEventArgs obj) /// [Parameter] public EventCallback OnKeyDown { get; set; } - protected virtual async Task InvokeKeyDown(KeyboardEventArgs obj) + /// + /// + /// + /// + /// + protected virtual async Task InvokeKeyDownAsync(KeyboardEventArgs obj) { _isFocused = true; await OnKeyDown.InvokeAsync(obj); @@ -365,30 +397,17 @@ protected virtual async Task InvokeKeyDown(KeyboardEventArgs obj) [Category(CategoryTypes.FormComponent.Behavior)] public bool DisablePaste { get; set; } - - /// - /// Fired on the KeyPress event. - /// - [Parameter] public EventCallback OnKeyPress { get; set; } - - protected virtual async Task InvokeKeyPress(KeyboardEventArgs obj) - { - await OnKeyPress.InvokeAsync(obj); - } - - /// - /// Prevent the default action for the KeyPress event. - /// - [Parameter] - [Category(CategoryTypes.FormComponent.Behavior)] - public bool KeyPressPreventDefault { get; set; } - /// /// Fired on the KeyUp event. /// [Parameter] public EventCallback OnKeyUp { get; set; } - protected virtual async Task InvokeKeyUp(KeyboardEventArgs obj) + /// + /// + /// + /// + /// + protected virtual async Task InvokeKeyUpAsync(KeyboardEventArgs obj) { _isFocused = true; await OnKeyUp.InvokeAsync(obj); @@ -418,11 +437,19 @@ public T? Value set => _value = value; } + /// + /// + /// + /// + /// + /// + /// protected virtual async Task SetValueAsync(T? value, bool updateText = true, bool force = false) { if (!EqualityComparer.Default.Equals(Value, value) || force == true) { _isDirty = true; + _validated = false; Value = value; await ValueChanged.InvokeAsync(Value); if (updateText) @@ -440,6 +467,11 @@ protected virtual Task UpdateValuePropertyAsync(bool updateText) return SetValueAsync(Converter.Get(Text), updateText); } + /// + /// + /// + /// + /// protected override bool SetConverter(MudBlazor.Converter value) { var changed = base.SetConverter(value); @@ -449,6 +481,11 @@ protected override bool SetConverter(MudBlazor.Converter value) return changed; } + /// + /// + /// + /// + /// protected override bool SetCulture(CultureInfo value) { var changed = base.SetCulture(value); @@ -463,13 +500,18 @@ protected override bool SetCulture(CultureInfo value) /// [Parameter] [Category(CategoryTypes.FormComponent.Behavior)] - public string Format + public string? Format { get => ((Converter)Converter).Format; set => SetFormat(value); } - protected virtual bool SetFormat(string value) + /// + /// + /// + /// + /// + protected virtual bool SetFormat(string? value) { var changed = Format != value; if (changed) @@ -480,12 +522,17 @@ protected virtual bool SetFormat(string value) return changed; } - protected override Task ValidateValue() + /// + /// + /// + /// + protected override async Task ValidateValue() { if (SubscribeToParentFormExtended) - return base.ValidateValue(); - - return Task.CompletedTask; + { + _validated = true; + await base.ValidateValue(); + } } /// @@ -516,9 +563,13 @@ public virtual async Task ForceRender(bool forceTextUpdate) await UpdateTextPropertyAsync(false); StateHasChanged(); } - + /// + /// + /// protected bool _forceTextUpdate; - + /// + /// + /// protected virtual bool SkipUpdateProcessOnSetParameters { get; set; } /// @@ -582,11 +633,16 @@ protected override void OnParametersSet() base.OnParametersSet(); } - protected override void ResetValue() + /// + /// + /// + /// + protected override async Task ResetValueAsync() { - SetTextAsync(null, updateValue: true).AndForget(); + await SetTextAsync(null, updateValue: true); _isDirty = false; - base.ResetValueAsync(); + _validated = false; + await base.ResetValueAsync(); } [CascadingParameter(Name = "SubscribeToParentFormExtended")] diff --git a/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor b/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor index e76f14c5..f45244ad 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor +++ b/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor @@ -7,7 +7,6 @@ Immediate="true" OnKeyDown="HandleKeyDown" OnKeyUp="HandleKeyUp" - OnKeyPress="@(async() => await OnKeyPress.InvokeAsync())" OnBlur="@(async() => await OnBlur.InvokeAsync())" OnClearButtonClick="@(async() => await OnClearButtonClick.InvokeAsync())" OnDebounceIntervalElapsed="@(async() => await OnDebounceIntervalElapsed.InvokeAsync())" diff --git a/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor.cs index f13a7d8b..5e2c40fd 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor.cs +++ b/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor.cs @@ -65,7 +65,7 @@ public partial class MudChipField : MudTextFieldExtended /// CSS styles of the chips. /// [Parameter] - public string StyleChip { get; set; } + public string? StyleChip { get; set; } /// /// Color of the chips. @@ -137,6 +137,10 @@ protected async Task HandleKeyUp(KeyboardEventArgs args) await OnKeyUp.InvokeAsync(args); } + /// + /// + /// + /// protected async Task SetChips() { if (Values == null) diff --git a/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor b/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor index be802eeb..117fb8aa 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor +++ b/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor @@ -19,7 +19,7 @@ DisableUnderLine="@DisableUnderLine" Disabled="@Disabled" ReadOnly="@ReadOnly" Error="@Error" ErrorId="@ErrorId" Clearable="@Clearable" ForceClearable="@(Clearable && HasValue(Value))" OnClearButtonClick="@ClearButtonClickHandlerAsync" - @attributes="UserAttributes" OnBlur="@HandleOnBlur" ForceShrink="@(HasValue(Value) || _isOpen || ForceShrink)"> + @attributes="UserAttributes" OnBlur="@HandleOnBlur" ShrinkLabel="@(HasValue(Value) || _isOpen || ShrinkLabel)"> diff --git a/CodeBeam.MudBlazor.Extensions/Components/InputExtended/MudInputExtended.razor b/CodeBeam.MudBlazor.Extensions/Components/InputExtended/MudInputExtended.razor index 6790b7ee..66716dac 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/InputExtended/MudInputExtended.razor +++ b/CodeBeam.MudBlazor.Extensions/Components/InputExtended/MudInputExtended.razor @@ -26,14 +26,12 @@ @oninput="OnInputHandler" @onchange="OnChangeHandler" @onblur="@OnBlurredAsync" - @onkeydown="@InvokeKeyDown" - @onkeypress="@InvokeKeyPress" - @onkeyup="@InvokeKeyUp" + @onkeydown="@InvokeKeyDownAsync" + @onkeyup="@InvokeKeyUpAsync" @onpaste="@OnPaste" value="@_internalText" maxlength="@MaxLength" @onkeydown:preventDefault="@KeyDownPreventDefault" - @onkeypress:preventDefault="@KeyPressPreventDefault" @onkeyup:preventDefault="@KeyUpPreventDefault" @onmousewheel="@OnMouseWheel" @onwheel="@OnMouseWheel" @@ -71,12 +69,10 @@ @onblur="@OnBlurredAsync" inputmode="@InputMode.ToString()" pattern="@Pattern" - @onkeydown="@InvokeKeyDown" - @onkeypress="@InvokeKeyPress" - @onkeyup="@InvokeKeyUp" + @onkeydown="@InvokeKeyDownAsync" + @onkeyup="@InvokeKeyUpAsync" maxlength="@MaxLength" @onkeydown:preventDefault="KeyDownPreventDefault" - @onkeypress:preventDefault="@KeyPressPreventDefault" @onkeyup:preventDefault="@KeyUpPreventDefault" onpaste="return false" @onmousewheel="@OnMouseWheel" @@ -99,12 +95,10 @@ @onblur="@OnBlurredAsync" inputmode="@InputMode.ToString()" pattern="@Pattern" - @onkeydown="@InvokeKeyDown" - @onkeypress="@InvokeKeyPress" - @onkeyup="@InvokeKeyUp" + @onkeydown="@InvokeKeyDownAsync" + @onkeyup="@InvokeKeyUpAsync" maxlength="@MaxLength" @onkeydown:preventDefault="KeyDownPreventDefault" - @onkeypress:preventDefault="@KeyPressPreventDefault" @onkeyup:preventDefault="@KeyUpPreventDefault" @onmousewheel="@OnMouseWheel" @onwheel="@OnMouseWheel" diff --git a/CodeBeam.MudBlazor.Extensions/Components/InputExtended/MudInputExtended.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/InputExtended/MudInputExtended.razor.cs index 3022901c..a996f245 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/InputExtended/MudInputExtended.razor.cs +++ b/CodeBeam.MudBlazor.Extensions/Components/InputExtended/MudInputExtended.razor.cs @@ -1,6 +1,4 @@ -using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using Microsoft.JSInterop; using MudBlazor; @@ -9,6 +7,10 @@ namespace MudExtensions { + /// + /// The extended input component. + /// + /// public partial class MudInputExtended : MudBaseInputExtended { [Inject] IJSRuntime? JSRuntime { get; set; } @@ -17,7 +19,7 @@ public partial class MudInputExtended : MudBaseInputExtended /// /// protected string? Classname => MudInputCssHelperExtended.GetClassname(this, - () => HasNativeHtmlPlaceholder() || ForceShrink == true || !string.IsNullOrEmpty(Text) || AdornmentStart != null || !string.IsNullOrWhiteSpace(Placeholder) || !string.IsNullOrEmpty(Converter.Set(Value))); + () => HasNativeHtmlPlaceholder() || ShrinkLabel == true || !string.IsNullOrEmpty(Text) || AdornmentStart != null || !string.IsNullOrWhiteSpace(Placeholder) || !string.IsNullOrEmpty(Converter.Set(Value))); /// /// diff --git a/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListItemExtended.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListItemExtended.razor.cs index 9102d4a6..ef1973d2 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListItemExtended.razor.cs +++ b/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListItemExtended.razor.cs @@ -223,20 +223,6 @@ public bool? Dense } } - /// - /// Command parameter. - /// - [Parameter] - [Category(CategoryTypes.List.ClickAction)] - public object CommandParameter { get; set; } - - /// - /// Command executed when the user clicks on an element. - /// - [Parameter] - [Category(CategoryTypes.List.ClickAction)] - public ICommand Command { get; set; } - /// /// Prevent default behavior when click on MudSelectItem. Default behavior is selecting the item and style adjustments. /// diff --git a/CodeBeam.MudBlazor.Extensions/Components/LoadingButton/MudLoadingButton.razor b/CodeBeam.MudBlazor.Extensions/Components/LoadingButton/MudLoadingButton.razor index ef4b7e21..6c117d72 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/LoadingButton/MudLoadingButton.razor +++ b/CodeBeam.MudBlazor.Extensions/Components/LoadingButton/MudLoadingButton.razor @@ -6,7 +6,7 @@ @if (Loading) { @@ -40,7 +40,7 @@ else if (ButtonVariant == ButtonVariant.IconButton) + Icon="@(Loading ? null : Icon)" HtmlTag="@HtmlTag" Title="@Title"> @if (Loading) {
@@ -68,8 +68,8 @@ else if (ButtonVariant == ButtonVariant.Fab) + StartIcon="@StartIcon" EndIcon="@EndIcon" IconColor="@IconColor" IconSize="@IconSize" Label="@Label" + HtmlTag="@HtmlTag" Title="@Title" /> } else { diff --git a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor index 587fca46..226ebd59 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor +++ b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor @@ -15,7 +15,7 @@ Value="@(Strict && !IsValueInList ? null : Text)" DisableUnderLine="@DisableUnderLine" Disabled="@Disabled" ReadOnly="true" Error="@Error" ErrorId="@ErrorId" Clearable="@Clearable" OnClearButtonClick="(async (e) => await SelectClearButtonClickHandlerAsync(e))" - @attributes="UserAttributes" OnBlur="@OnLostFocus" ForceShrink="@ForceShrink" + @attributes="UserAttributes" OnBlur="@OnLostFocus" ShrinkLabel="@ShrinkLabel" ShowVisualiser="true" DataVisualiserStyle="min-height: 1.1876em"> diff --git a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor.cs index c6418498..ab450d69 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor.cs +++ b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor.cs @@ -336,27 +336,6 @@ public bool Dense [Category(CategoryTypes.FormComponent.ListAppearance)] public Origin TransformOrigin { get; set; } = Origin.TopCenter; - /// - /// Sets the direction the Select menu should open. - /// - [ExcludeFromCodeCoverage] - [Obsolete("Use AnchorOrigin or TransformOrigin instead.", true)] - [Parameter] public Direction Direction { get; set; } = Direction.Bottom; - - /// - /// If true, the Select menu will open either before or after the input (left/right). - /// - [ExcludeFromCodeCoverage] - [Obsolete("Use AnchorOrigin or TransformOrigin instead.", true)] - [Parameter] public bool OffsetX { get; set; } - - /// - /// If true, the Select menu will open either before or after the input (top/bottom). - /// - /// [ExcludeFromCodeCoverage] - [Obsolete("Use AnchorOrigin or TransformOrigin instead.", true)] - [Parameter] public bool OffsetY { get; set; } - /// /// If true, the Select's input will not show any values that are not defined in the dropdown. /// This can be useful if Value is bound to a variable which is initialized to a value which is not in the list @@ -1218,14 +1197,6 @@ protected async ValueTask SelectClearButtonClickHandlerAsync(MouseEventArgs e) await OnClearButtonClick.InvokeAsync(e); } - /// - /// - /// - /// - [ExcludeFromCodeCoverage] - [Obsolete("Use Clear instead.", true)] - public Task ClearAsync() => Clear(); - /// /// Clear the selection /// diff --git a/CodeBeam.MudBlazor.Extensions/Components/Splitter/MudSplitter.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/Splitter/MudSplitter.razor.cs index 6a02e8ee..838783b0 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/Splitter/MudSplitter.razor.cs +++ b/CodeBeam.MudBlazor.Extensions/Components/Splitter/MudSplitter.razor.cs @@ -64,13 +64,6 @@ public partial class MudSplitter : MudComponentBase [Parameter] public bool Bordered { get; set; } - /// - /// The two contents' (sections) styles, seperated by space. - /// - [Obsolete("StyleContent is deprecated, please use property ContentStyle, StartContentStyle or EndContentStyle to set the style.")] - [Parameter] - public string? StyleContent { get; set; } - /// /// The style to apply to both content sections, seperated by space. /// @@ -78,24 +71,17 @@ public partial class MudSplitter : MudComponentBase public string? ContentStyle { get; set; } /// - /// The style of the , seperated by space. Overrules + /// The style of the , seperated by space. /// [Parameter] public string? StartContentStyle { get; set; } /// - /// The style of the , seperated by space. Overrules + /// The style of the , seperated by space. /// [Parameter] public string? EndContentStyle { get; set; } - /// - /// The splitter bar's styles, seperated by space. The style string should end with: "!important;" - /// - [Obsolete("StyleBar is deprecated, please use property BarStyle to set the bar's style.")] - [Parameter] - public string? StyleBar { get; set; } = "width:2px !important;"; - /// /// The splitter bar's styles, seperated by space. The style string should end with: "!important;" /// @@ -162,10 +148,10 @@ public partial class MudSplitter : MudComponentBase public EventCallback OnDoubleClicked { get; set; } - string? EffectiveStartStyle { get { return !string.IsNullOrWhiteSpace(StartContentStyle) ? StartContentStyle : !string.IsNullOrWhiteSpace(ContentStyle) ? ContentStyle : StyleContent; } } - string? EffectiveEndStyle { get { return !string.IsNullOrWhiteSpace(EndContentStyle) ? EndContentStyle : !string.IsNullOrWhiteSpace(ContentStyle) ? ContentStyle : StyleContent; } } + string? EffectiveStartStyle { get { return !string.IsNullOrWhiteSpace(StartContentStyle) ? StartContentStyle : ContentStyle; }} + string? EffectiveEndStyle { get { return !string.IsNullOrWhiteSpace(EndContentStyle) ? EndContentStyle : ContentStyle; } } string? EffectiveHeight { get { return !string.IsNullOrWhiteSpace(Height) ? $"height:{Height} !important;" : null; } } - string? EffectiveBarStyle { get { return !string.IsNullOrWhiteSpace(BarStyle) ? BarStyle : StyleBar; } } + string? EffectiveBarStyle { get => BarStyle; } string? EffectiveColor { get { return $"background-color:var(--mud-palette-{(Color == Color.Default ? "action-default" : Color.ToDescriptionString())}) !important;"; } } /// diff --git a/CodeBeam.MudBlazor.Extensions/Components/Stepper/MudStepper.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/Stepper/MudStepper.razor.cs index 9a90c3d9..5c29e9b8 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/Stepper/MudStepper.razor.cs +++ b/CodeBeam.MudBlazor.Extensions/Components/Stepper/MudStepper.razor.cs @@ -6,6 +6,9 @@ namespace MudExtensions { + /// + /// Stepper component with extended features. + /// public partial class MudStepper : MudComponentBase { MudAnimate _animate = new(); @@ -309,10 +312,6 @@ internal int ActiveIndex [Parameter] public EventCallback ActiveStepChanged { get; set; } - [Obsolete("Use PreventStepChangeAsync instead.")] - [Parameter] - public Func PreventStepChange { get; set; } - /// /// Runs a task to prevent step change. Has change direction (backwards or forwards) and target index and returns a bool value. /// @@ -394,11 +393,6 @@ public async Task SetActiveIndex(int count, bool firstCompleted = false, bool sk StepChangeDirection.Backward ); - if (!skipPreventProcess && PreventStepChange != null && PreventStepChange.Invoke(stepChangeDirection)) - { - return; - } - if (skipPreventProcess == false && PreventStepChangeAsync != null) { var result = await PreventStepChangeAsync.Invoke(stepChangeDirection, ActiveIndex + count); @@ -460,11 +454,6 @@ public async Task SetActiveStepByIndex(int index, bool firstCompleted = false, b StepChangeDirection.Backward ); - if (!skipPreventProcess && PreventStepChange != null && PreventStepChange.Invoke(stepChangeDirection)) - { - return; - } - if (skipPreventProcess == false && PreventStepChangeAsync != null) { var result = await PreventStepChangeAsync.Invoke(stepChangeDirection, index); @@ -505,11 +494,6 @@ public async Task CompleteStep(int index, bool moveToNextStep = true) if (isActiveStep) { var stepChangeDirection = (moveToNextStep ? StepChangeDirection.Forward : StepChangeDirection.None); - if (PreventStepChange != null && PreventStepChange.Invoke(stepChangeDirection)) - { - return; - } - if (PreventStepChangeAsync != null) { var result = await PreventStepChangeAsync.Invoke(stepChangeDirection, index + 1); @@ -543,11 +527,6 @@ public async Task SkipStep(int index, bool moveToNextStep = true) if (isActiveStep) { var stepChangeDirection = (moveToNextStep ? StepChangeDirection.Forward : StepChangeDirection.None); - if (PreventStepChange != null && PreventStepChange.Invoke(stepChangeDirection)) - { - return; - } - if (PreventStepChangeAsync != null) { var result = await PreventStepChangeAsync.Invoke(stepChangeDirection, index + 1); diff --git a/CodeBeam.MudBlazor.Extensions/Components/TextFieldExtended/MudTextFieldExtended.razor b/CodeBeam.MudBlazor.Extensions/Components/TextFieldExtended/MudTextFieldExtended.razor index 3f8b0253..dfab450f 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/TextFieldExtended/MudTextFieldExtended.razor +++ b/CodeBeam.MudBlazor.Extensions/Components/TextFieldExtended/MudTextFieldExtended.razor @@ -42,10 +42,9 @@ Immediate="@Immediate" Margin="@Margin" OnBlur="@OnBlurredAsync" - OnKeyDown="@InvokeKeyDown" + OnKeyDown="@InvokeKeyDownAsync" OnInternalInputChanged="OnChange" - OnKeyPress="@InvokeKeyPress" - OnKeyUp="@InvokeKeyUp" + OnKeyUp="@InvokeKeyUpAsync" KeyDownPreventDefault="KeyDownPreventDefault" KeyPressPreventDefault="KeyPressPreventDefault" KeyUpPreventDefault="KeyUpPreventDefault" @@ -53,16 +52,22 @@ Clearable="@Clearable" OnClearButtonClick="@OnClearButtonClick" Pattern="@Pattern" - AdornmentStart="@AdornmentStart" - AdornmentEnd="@AdornmentEnd" AutoSize="AutoSize" - ForceShrink="@ForceShrink" + ShrinkLabel="@ShrinkLabel" ShowVisualiser="@(DataVisualiser != null && ShowVisualiser)" DataVisualiserStyle="@(DataVisualiser != null ? "min-height: 1.1876em" : null)"> @DataVisualiser + + @AdornmentStart + + + + @AdornmentEnd + + } else @@ -89,7 +94,8 @@ Clearable="@Clearable" OnClearButtonClick="@OnClearButtonClick" AdornmentStart="@AdornmentStart" - AdornmentEnd="@AdornmentEnd" /> + AdornmentEnd="@AdornmentEnd"> + } diff --git a/CodeBeam.MudBlazor.Extensions/Services/ScrollManagerExtended.cs b/CodeBeam.MudBlazor.Extensions/Services/ScrollManagerExtended.cs index 97d05e6f..8bc607d0 100644 --- a/CodeBeam.MudBlazor.Extensions/Services/ScrollManagerExtended.cs +++ b/CodeBeam.MudBlazor.Extensions/Services/ScrollManagerExtended.cs @@ -1,4 +1,5 @@ using Microsoft.JSInterop; +using MudBlazor; using MudBlazor.Extensions; namespace MudExtensions.Services @@ -22,13 +23,7 @@ public interface IScrollManagerExtended /// public class ScrollManagerExtended : IScrollManagerExtended { - /// - /// - /// - [Obsolete] - public string? Selector { get; set; } private readonly IJSRuntime _jSRuntime; - /// /// /// @@ -36,52 +31,30 @@ public class ScrollManagerExtended : IScrollManagerExtended public ScrollManagerExtended(IJSRuntime jSRuntime) { _jSRuntime = jSRuntime; - } /// - /// Scroll to an url fragment - /// - /// The id of the selector that is going to be scrolled to - /// smooth or auto - /// - public ValueTask ScrollToFragmentAsync(string id, ScrollBehavior behavior) => - _jSRuntime.InvokeVoidAsync("mudScrollManager.scrollToFragment", id, behavior.ToDescriptionString()); - - /// - /// - /// - /// - /// - /// - [Obsolete] - public async Task ScrollToFragment(string id, ScrollBehavior behavior) => - await ScrollToFragmentAsync(id, behavior); - - /// - /// Scrolls to the coordinates of the element + /// Scrolls to the coordinates of the element. /// /// id of element /// x coordinate /// y coordinate /// smooth or auto /// - public ValueTask ScrollToAsync(string? id, int left, int top, ScrollBehavior behavior) => + public ValueTask ScrollToAsync(string id, int left, int top, ScrollBehavior behavior) => _jSRuntime.InvokeVoidAsync("mudScrollManager.scrollTo", id, left, top, behavior.ToDescriptionString()); /// - /// + /// Scrolls the first instance of the selector into view. /// - /// - /// + /// /// /// - [Obsolete] - public async Task ScrollTo(int left, int top, ScrollBehavior behavior) => - await ScrollToAsync(Selector, left, top, behavior); + public ValueTask ScrollIntoViewAsync(string selector, ScrollBehavior behavior) => + _jSRuntime.InvokeVoidAsync("mudScrollManager.scrollIntoView", selector, behavior.ToDescriptionString()); /// - /// Scrolls to the top of the element + /// Scrolls to the top of the element. /// /// id of element /// smooth or auto @@ -90,16 +63,34 @@ public ValueTask ScrollToTopAsync(string id, ScrollBehavior scrollBehavior = Scr ScrollToAsync(id, 0, 0, scrollBehavior); /// - /// + /// Scroll to the bottom of the element (or if not found to the bottom of the page). /// - /// + /// id of element of null to scroll to page bottom + /// smooth or auto /// - public async Task ScrollToTop(ScrollBehavior scrollBehavior = ScrollBehavior.Auto) - { -#pragma warning disable CS0612 // Type or member is obsolete - await ScrollToAsync(Selector, 0, 0, scrollBehavior); -#pragma warning restore CS0612 // Type or member is obsolete - } + public ValueTask ScrollToBottomAsync(string id, ScrollBehavior behavior) => + _jSRuntime.InvokeVoidAsync("mudScrollManager.scrollToBottom", id, behavior.ToDescriptionString()); + + public ValueTask ScrollToYearAsync(string elementId) => + _jSRuntime.InvokeVoidAsync("mudScrollManager.scrollToYear", elementId); + + public ValueTask ScrollToListItemAsync(string elementId) => + _jSRuntime.InvokeVoidAsync("mudScrollManager.scrollToListItem", elementId); + + public ValueTask LockScrollAsync(string selector = "body", string cssClass = "scroll-locked") => + _jSRuntime.InvokeVoidAsync("mudScrollManager.lockScroll", selector, cssClass); + + public ValueTask UnlockScrollAsync(string selector = "body", string cssClass = "scroll-locked") => + _jSRuntime.InvokeVoidAsyncIgnoreErrors("mudScrollManager.unlockScroll", selector, cssClass); + + /// + /// Scroll to an url fragment + /// + /// The id of the selector that is going to be scrolled to + /// smooth or auto + /// + public ValueTask ScrollToFragmentAsync(string id, ScrollBehavior behavior) => + _jSRuntime.InvokeVoidAsync("mudScrollManager.scrollToFragment", id, behavior.ToDescriptionString()); /// ///