+
@if (MultiSelection && SelectAll && SelectAllPosition == SelectAllPosition.BeforeSearchBox && ParentList == null)
{
@@ -31,7 +31,7 @@
{
SelectAllItems(_allSelected)" Dense="true" />
}
-
diff --git a/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs
index f00541d7..bde0fb18 100644
--- a/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs
+++ b/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs
@@ -744,7 +744,6 @@ protected override void OnParametersSet()
ParametersChanged?.Invoke();
}
- private IKeyInterceptor? _keyInterceptor;
private bool _firstRendered = false;
///
///
@@ -758,24 +757,29 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
{
_firstRendered = false;
- await KeyInterceptorService.SubscribeAsync(_elementId, new KeyInterceptorOptions
- {
- //EnableLogging = true,
- TargetClass = "mud-list-item-extended",
- Keys = {
- //new KeyOptions { Key=" ", PreventDown = "key+none" }, //prevent scrolling page, toggle open/close
- new KeyOptions { Key="ArrowUp", PreventDown = "key+none" }, // prevent scrolling page, instead hilight previous item
- new KeyOptions { Key="ArrowDown", PreventDown = "key+none" }, // prevent scrolling page, instead hilight next item
- new KeyOptions { Key="Home", PreventDown = "key+none" },
- new KeyOptions { Key="End", PreventDown = "key+none" },
- new KeyOptions { Key="Escape" },
- new KeyOptions { Key="Enter", PreventDown = "key+none" },
- new KeyOptions { Key="NumpadEnter", PreventDown = "key+none" },
- new KeyOptions { Key="a", PreventDown = "key+ctrl" }, // select all items instead of all page text
- new KeyOptions { Key="A", PreventDown = "key+ctrl" }, // select all items instead of all page text
- new KeyOptions { Key="/./", SubscribeDown = true, SubscribeUp = true }, // for our users
- },
- }, KeyObserver.KeyDownIgnore(), KeyObserver.KeyUpIgnore());
+ var options = new KeyInterceptorOptions(
+ "mud-list-item-extended",
+ [
+ // prevent scrolling page, toggle open/close
+ new(" ", preventDown: "key+none"),
+ // prevent scrolling page, instead highlight previous item
+ new("ArrowUp", preventDown: "key+none"),
+ // prevent scrolling page, instead highlight next item
+ new("ArrowDown", preventDown: "key+none"),
+ new("Home", preventDown: "key+none"),
+ new("End", preventDown: "key+none"),
+ new("Escape"),
+ new("Enter", preventDown: "key+none"),
+ new("NumpadEnter", preventDown: "key+none"),
+ // select all items instead of all page text
+ new("a", preventDown: "key+ctrl"),
+ // select all items instead of all page text
+ new("A", preventDown: "key+ctrl"),
+ // for our users
+ new("/./", subscribeDown: true, subscribeUp: true)
+ ]);
+
+ await KeyInterceptorService.SubscribeAsync(_elementId, options, keyDown: HandleKeyDownAsync);
if (MudSelectExtended == null && MudAutocomplete == null)
{
@@ -901,7 +905,7 @@ protected internal void Unregister(MudListExtended child)
///
///
///
- protected internal async Task SearchBoxHandleKeyDown(KeyboardEventArgs obj)
+ protected internal async Task SearchBoxHandleKeyDownAsync(KeyboardEventArgs obj)
{
if (Disabled || (!Clickable && !MultiSelection))
return;
@@ -924,11 +928,11 @@ protected internal async Task SearchBoxHandleKeyDown(KeyboardEventArgs obj)
break;
case "ArrowUp":
case "ArrowDown":
- await HandleKeyDown(obj);
+ await HandleKeyDownAsync(obj);
break;
case "Enter":
case "NumpadEnter":
- await HandleKeyDown(obj);
+ await HandleKeyDownAsync(obj);
if (MudSelectExtended != null && MultiSelection == false)
{
await MudSelectExtended.CloseMenu();
@@ -956,7 +960,7 @@ protected internal async Task SearchBoxHandleKeyDown(KeyboardEventArgs obj)
///
///
///
- protected internal async Task HandleKeyDown(KeyboardEventArgs obj)
+ protected internal async Task HandleKeyDownAsync(KeyboardEventArgs obj)
{
if (Disabled || (!Clickable && !MultiSelection))
return;
diff --git a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor
index dd807da2..cb3d77d6 100644
--- a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor
+++ b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor
@@ -110,7 +110,7 @@
x.Value != null && Value != null && x.Value.Equals(Value))?.ListItem;
@@ -813,18 +819,14 @@ public void ForceUpdateItems()
///
///
///
- ///
- protected override void Dispose(bool disposing)
+ ///
+ protected override async ValueTask DisposeAsyncCore()
{
- base.Dispose(disposing);
+ await base.DisposeAsyncCore();
- if (disposing)
+ if (IsJSRuntimeAvailable)
{
- if (IsJSRuntimeAvailable)
- {
- //TODO: Use IAsyncDisposable instead.
- KeyInterceptorService.UnsubscribeAsync(_elementId).CatchAndLog();
- }
+ await KeyInterceptorService.UnsubscribeAsync(_elementId);
}
}
@@ -837,14 +839,14 @@ protected override void Dispose(bool disposing)
/// Keydown event.
///
///
- protected internal async Task HandleKeyDown(KeyboardEventArgs obj)
+ protected internal async Task HandleKeyDownAsync(KeyboardEventArgs obj)
{
if (Disabled || ReadOnly)
return;
if (_list != null && _isOpen)
{
- await _list.HandleKeyDown(obj);
+ await _list.HandleKeyDownAsync(obj);
}
switch (obj.Key)
@@ -914,7 +916,7 @@ protected internal async Task HandleKeyDown(KeyboardEventArgs obj)
/// Keyup event.
///
///
- protected internal async Task HandleKeyUp(KeyboardEventArgs obj)
+ protected internal async Task HandleKeyUpAsync(KeyboardEventArgs obj)
{
await OnKeyUp.InvokeAsync(obj);
}
diff --git a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemExtended.razor b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemExtended.razor
index e6ced25b..31b1ee79 100644
--- a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemExtended.razor
+++ b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemExtended.razor
@@ -1,10 +1,10 @@
@namespace MudExtensions
@typeparam T
-@inherits MudBaseSelectItem
+@inherits MudComponentBase
@if (HideContent == false)
{
-
+
@if (ChildContent != null && MudSelectExtended?.ItemCollection == null)
{
@ChildContent
diff --git a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemExtended.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemExtended.razor.cs
index 1a05307b..18626005 100644
--- a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemExtended.razor.cs
+++ b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemExtended.razor.cs
@@ -8,7 +8,7 @@ namespace MudExtensions
///
/// Represents an option of a select or multi-select. To be used inside MudSelect.
///
- public partial class MudSelectItemExtended : MudBaseSelectItem, IDisposable
+ public partial class MudSelectItemExtended : MudComponentBase, IDisposable
{
private String GetCssClasses() => new CssBuilder()
.AddClass(Class)
@@ -100,6 +100,20 @@ private void OnUpdateSelectionStateFromOutside(IEnumerable? selection)
[Category(CategoryTypes.FormComponent.Behavior)]
public T? Value { get; set; }
+ ///
+ /// The URL to navigate to when this item is clicked.
+ ///
+ [Parameter]
+ [Category(CategoryTypes.General.ClickAction)]
+ public string? Href { get; set; }
+
+ ///
+ /// The content within this item.
+ ///
+ [Parameter]
+ [Category(CategoryTypes.General.Behavior)]
+ public RenderFragment? ChildContent { get; set; }
+
///
/// Mirrors the MultiSelection status of the parent select
///
@@ -113,6 +127,21 @@ protected bool MultiSelection
}
}
+ ///
+ /// OnClick event.
+ ///
+ [Parameter]
+ [Category(CategoryTypes.FormComponent.Behavior)]
+ public EventCallback OnClick { get; set; }
+
+ ///
+ /// Prevents the user from interacting with this item.
+ ///
+ [Parameter]
+ [Category(CategoryTypes.General.Behavior)]
+ public bool Disabled { get; set; }
+
+
private bool _isSelected;
internal bool IsSelected
{
@@ -142,20 +171,20 @@ protected string? DisplayString
///
///
///
- protected void HandleOnClick()
+ protected async Task HandleOnClickAsync()
{
// Selection works on list. We arrange only popover state and some minor arrangements on click.
- MudSelectExtended?.SelectOption(Value).CatchAndLog();
- InvokeAsync(StateHasChanged);
+ await MudSelectExtended?.SelectOption(Value);
+ await InvokeAsync(StateHasChanged);
if (!MultiSelection)
{
- MudSelectExtended?.CloseMenu().CatchAndLog();
+ await MudSelectExtended?.CloseMenu();
}
else
{
- MudSelectExtended?.FocusAsync().CatchAndLog();
+ MudSelectExtended?.FocusAsync();
}
- OnClick.InvokeAsync().CatchAndLog();
+ await OnClick.InvokeAsync();
}
///
diff --git a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemGroupExtended.razor b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemGroupExtended.razor
index 8895b9ba..ee13f74c 100644
--- a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemGroupExtended.razor
+++ b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemGroupExtended.razor
@@ -1,6 +1,6 @@
@namespace MudExtensions
@typeparam T
-@inherits MudBaseSelectItem
+@inherits MudComponentBase
@if (HideContent == false)
{
diff --git a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemGroupExtended.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemGroupExtended.razor.cs
index 9cab2d62..c3d974f4 100644
--- a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemGroupExtended.razor.cs
+++ b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectItemGroupExtended.razor.cs
@@ -6,7 +6,7 @@ namespace MudExtensions
///
/// Represents an option of a select or multi-select. To be used inside MudSelect.
///
- public partial class MudSelectItemGroupExtended : MudBaseSelectItem
+ public partial class MudSelectItemGroupExtended : MudComponentBase
{
//private IMudSelect _parent;
@@ -26,6 +26,13 @@ public partial class MudSelectItemGroupExtended : MudBaseSelectItem
[Category(CategoryTypes.FormComponent.Behavior)]
public string? Text { get; set; }
+ ///
+ /// The content within this item.
+ ///
+ [Parameter]
+ [Category(CategoryTypes.General.Behavior)]
+ public RenderFragment? ChildContent { get; set; }
+
///
/// A user-defined option that can be selected
///
diff --git a/CodeBeam.MudBlazor.Extensions/Components/SwitchM3/MudSwitchM3.razor b/CodeBeam.MudBlazor.Extensions/Components/SwitchM3/MudSwitchM3.razor
index 3a801726..b4f6f9ca 100644
--- a/CodeBeam.MudBlazor.Extensions/Components/SwitchM3/MudSwitchM3.razor
+++ b/CodeBeam.MudBlazor.Extensions/Components/SwitchM3/MudSwitchM3.razor
@@ -2,7 +2,7 @@
@inherits MudBooleanInput
@typeparam T
-
protected string? SwitchClassname =>
new CssBuilder("mud-button-root mud-icon-button mud-switch-base-m3")
- .AddClass($"mud-ripple mud-ripple-switch", Ripple && !ReadOnly && !Disabled)
+ .AddClass($"mud-ripple mud-ripple-switch", Ripple && !GetReadOnlyState() && !GetDisabledState())
.AddClass($"mud-{Color.ToDescriptionString()}-text hover:mud-{Color.ToDescriptionString()}-hover", BoolValue == true)
//.AddClass($"mud-{UnCheckedColor.ToDescriptionString()}-text hover:mud-{UnCheckedColor.ToDescriptionString()}-hover", BoolValue == false)
- .AddClass($"mud-switch-disabled", Disabled)
- .AddClass($"mud-readonly", ReadOnly)
+ .AddClass($"mud-switch-disabled", GetDisabledState())
+ .AddClass($"mud-readonly", GetReadOnlyState())
.AddClass($"mud-checked", BoolValue)
.AddClass("mud-switch-base-dense-m3", !string.IsNullOrEmpty(ThumbOffIcon))
.Build();
@@ -66,27 +67,6 @@ public partial class MudSwitchM3 : MudBooleanInput
[Inject] private IKeyInterceptorService KeyInterceptorService { get; set; } = null!;
- ///
- /// The color of the component. It supports the theme colors.
- ///
- [Parameter]
- [Category(CategoryTypes.FormComponent.Appearance)]
- public Color Color { get; set; } = Color.Default;
-
- ///
- /// The text/label will be displayed next to the switch if set.
- ///
- [Parameter]
- [Category(CategoryTypes.FormComponent.Behavior)]
- public string? Label { get; set; }
-
- ///
- /// The position of the text/label.
- ///
- [Parameter]
- [Category(CategoryTypes.FormComponent.Behavior)]
- public LabelPosition LabelPosition { get; set; } = LabelPosition.End;
-
///
/// Shows an icon on Switch's thumb.
///
@@ -101,18 +81,11 @@ public partial class MudSwitchM3 : MudBooleanInput
[Category(CategoryTypes.FormComponent.Appearance)]
public string? ThumbOffIcon { get; set; }
- ///
- /// If true, disables ripple effect.
- ///
- [Parameter]
- [Category(CategoryTypes.FormComponent.Appearance)]
- public bool Ripple { get; set; } = true;
-
///
/// Keydown event.
///
///
- protected internal async Task HandleKeyDown(KeyboardEventArgs obj)
+ protected internal async Task HandleKeyDownAsync(KeyboardEventArgs obj)
{
if (Disabled || ReadOnly)
return;
@@ -162,17 +135,17 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
- // TODO: Make HandleKeyDown async Task
- await KeyInterceptorService.SubscribeAsync(_elementId, new KeyInterceptorOptions()
- {
- //EnableLogging = true,
- TargetClass = "mud-switch-base-m3",
- Keys = {
- new KeyOptions { Key="ArrowUp", PreventDown = "key+none" }, // prevent scrolling page, instead increment
- new KeyOptions { Key="ArrowDown", PreventDown = "key+none" }, // prevent scrolling page, instead decrement
- new KeyOptions { Key=" ", PreventDown = "key+none", PreventUp = "key+none" },
- },
- }, keyDown: HandleKeyDown);
+ var options = new KeyInterceptorOptions(
+ "mud-switch-base",
+ [
+ // prevent scrolling page, instead increment
+ new("ArrowUp", preventDown: "key+none"),
+ // prevent scrolling page, instead decrement
+ new("ArrowDown", preventDown: "key+none"),
+ new(" ", preventDown: "key+none", preventUp: "key+none")
+ ]);
+
+ await KeyInterceptorService.SubscribeAsync(_elementId, options, keyDown: HandleKeyDownAsync);
}
await base.OnAfterRenderAsync(firstRender);
}
@@ -180,19 +153,16 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
///
///
///
- ///
- protected override void Dispose(bool disposing)
+ ///
+ protected override async ValueTask DisposeAsyncCore()
{
- base.Dispose(disposing);
+ await base.DisposeAsyncCore();
- if (disposing)
+ if (IsJSRuntimeAvailable)
{
- if (IsJSRuntimeAvailable)
- {
- //TODO: Use IAsyncDisposable
- KeyInterceptorService.UnsubscribeAsync(_elementId).CatchAndLog();
- }
+ await KeyInterceptorService.UnsubscribeAsync(_elementId);
}
}
+
}
}
diff --git a/CodeBeam.MudBlazor.Extensions/Components/TextFieldExtended/MudTextFieldExtended.razor b/CodeBeam.MudBlazor.Extensions/Components/TextFieldExtended/MudTextFieldExtended.razor
index 12e74795..2e22af0d 100644
--- a/CodeBeam.MudBlazor.Extensions/Components/TextFieldExtended/MudTextFieldExtended.razor
+++ b/CodeBeam.MudBlazor.Extensions/Components/TextFieldExtended/MudTextFieldExtended.razor
@@ -45,7 +45,7 @@
OnInput="@OnInput"
OnBlur="@OnBlurredAsync"
OnKeyDown="@InvokeKeyDownAsync"
- OnInternalInputChanged="OnChange"
+ OnInternalInputChanged="OnChanged"
OnKeyUp="@InvokeKeyUpAsync"
KeyDownPreventDefault="KeyDownPreventDefault"
KeyUpPreventDefault="KeyUpPreventDefault"
diff --git a/CodeBeam.MudBlazor.Extensions/Components/Wheel/MudWheel.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/Wheel/MudWheel.razor.cs
index 732b6f1a..fd90cdb9 100644
--- a/CodeBeam.MudBlazor.Extensions/Components/Wheel/MudWheel.razor.cs
+++ b/CodeBeam.MudBlazor.Extensions/Components/Wheel/MudWheel.razor.cs
@@ -219,7 +219,7 @@ protected async Task HandleOnSwipe(SwipeEventArgs args)
_animateValue = - GetAnimateValue();
}
- int changedCount = (Math.Abs((int)args.SwipeDelta) / (Sensitivity == 0 ? 1 : Sensitivity));
+ int changedCount = (Math.Abs((int)(args.SwipeDelta ?? 0)) / (Sensitivity == 0 ? 1 : Sensitivity));
for (int i = 0; i < changedCount; i++)
{
await _animate.Refresh();