Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions src/CodeBeam.MudBlazor.Extensions/Base/MudBaseInputExtended.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ public abstract class MudBaseInputExtended<T> : MudBaseInput<T>
/// </summary>
protected MudBaseInputExtended()
{
Converter = new DefaultConverter<T>
Copy link
Contributor Author

@ScarletKuro ScarletKuro Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need, MudBaseInput already sets a GetDefaultConverter() => DefaultConverter<T>

{
Culture = GetCulture,
Format = GetFormat
};

//using var registerScope = CreateRegisterScope();
//_textState = registerScope.RegisterParameter<string?>(nameof(Text))
// .WithParameter(() => Text)
Expand All @@ -41,8 +35,6 @@ protected MudBaseInputExtended()
// .WithChangeHandler(UpdateInputIdStateAsync);
}



/// <summary>
/// Fires on input.
/// </summary>
Expand Down Expand Up @@ -171,7 +163,5 @@ public async Task<bool> OnBeforeInputFromJs(BeforeInputJsDto dto)
/// <param name="args">An object containing event data for the input operation.</param>
/// <returns>A task that represents the asynchronous operation. The default implementation returns a completed task.</returns>
protected virtual Task OnBeforeInputAsync(BeforeInputEventArgs args) => Task.CompletedTask;


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
OnClearButtonClick="@(async() => await OnClearButtonClick.InvokeAsync())"
OnDebounceIntervalElapsed="@(async() => await OnDebounceIntervalElapsed.InvokeAsync())"
OnInternalInputChanged="@(async() => await OnInternalInputChanged.InvokeAsync())"
ShrinkLabel="@(Values?.Any() ?? false)"
ShrinkLabel="@(_valuesState.Value?.Any() ?? false)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule of parameter state. Always use the backing field, no exceptions

Clearable="@Clearable"
AutoFocus="@AutoFocus"
Class="@Class"
Expand Down Expand Up @@ -43,19 +43,19 @@
Variant="@Variant"
@bind-Value="@_internalValue"
TextChanged="@(async() => await TextChanged.InvokeAsync())"
ShowVisualiser="@(Values?.Any() ?? false)">
ShowVisualiser="@(_valuesState.Value?.Any() ?? false)">

<DataVisualiser>
<MudChipSet T="T" Class="@ChipClassname" Style="@ChipStylename" AllClosable="@Closeable" OnClose="Closed">
@for (int i = 0; i < (MaxChips == 0 ? Values?.Count ?? 0 : (MaxChips < (Values?.Count ?? 0) ? MaxChips : Values?.Count ?? 0)); i++)
@for (int i = 0; i < (MaxChips == 0 ? _valuesState.Value?.Count ?? 0 : (MaxChips < (_valuesState.Value?.Count ?? 0) ? MaxChips : _valuesState.Value?.Count ?? 0)); i++)
{
int a = i;
<MudChip T="T" Class="@ClassChip" Style="@StyleChip" Ripple="false" Text="@(Values != null ? Values[a] : string.Empty)" Color="@ChipColor" Variant="@ChipVariant" Size="@ChipSize" Disabled="@Disabled" />
<MudChip T="T" Class="@ClassChip" Style="@StyleChip" Ripple="false" Text="@(_valuesState.Value != null ? _valuesState.Value[a] : string.Empty)" Color="@ChipColor" Variant="@ChipVariant" Size="@ChipSize" Disabled="@Disabled" />
}
</MudChipSet>
@if (Values != null && MaxChips != 0 && MaxChips < Values.Count)
@if (_valuesState.Value != null && MaxChips != 0 && MaxChips < _valuesState.Value.Count)
{
<MudChip T="T" Ripple="false" Text="@($"+{Values.Count - MaxChips}")" Color="@ChipColor" Variant="@ChipVariant" Size="@ChipSize" Disabled="@Disabled" />
<MudChip T="T" Ripple="false" Text="@($"+{_valuesState.Value.Count - MaxChips}")" Color="@ChipColor" Variant="@ChipVariant" Size="@ChipSize" Disabled="@Disabled" />
}
</DataVisualiser>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
/// <summary>
/// /The list of values.
/// </summary>
[Parameter]
[Parameter, ParameterState]
public List<string>? Values { get; set; }

/// <summary>
Expand Down Expand Up @@ -134,7 +134,7 @@
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
protected internal async Task HandleKeyDown(KeyboardEventArgs args)
protected internal Task HandleKeyDown(KeyboardEventArgs args)
{
//var result = args.Key;
//if (result.Equals(Delimiter, StringComparison.InvariantCultureIgnoreCase) && _internalValue != null)
Expand All @@ -158,17 +158,17 @@
//}
//await Task.Delay(10);
//await SetValueAsync(_internalValue);
await OnKeyDown.InvokeAsync(args);
return OnKeyDown.InvokeAsync(args);
}

/// <summary>
/// Protected keyup event.
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
protected async Task HandleKeyUp(KeyboardEventArgs args)
protected Task HandleKeyUp(KeyboardEventArgs args)
{
await OnKeyUp.InvokeAsync(args);
return OnKeyUp.InvokeAsync(args);
}

/// <summary>
Expand All @@ -186,7 +186,7 @@
if (args.IsInsert && args.Data == Delimiter && _internalValue is not null)
{
args.PreventDefault = true;
var currentText = base.ConvertSet(_internalValue);
var currentText = ConvertSet(_internalValue);

if (!string.IsNullOrEmpty(currentText))
{
Expand All @@ -200,7 +200,7 @@
return;
}

if (args.IsDeleteBackward && string.IsNullOrEmpty(base.ConvertSet(_internalValue)) && _valuesState.Value is { Count: > 0 } && BackspaceChipRemoval)
if (args.IsDeleteBackward && string.IsNullOrEmpty(ConvertSet(_internalValue)) && _valuesState.Value is { Count: > 0 } && BackspaceChipRemoval)
{
args.PreventDefault = true;

Expand All @@ -222,9 +222,9 @@

foreach (var part in parts)
{
if (AllowSameValues || !_valuesState.Value.Contains(part))

Check warning on line 225 in src/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 225 in src/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
{
_valuesState.Value.Add(part);

Check warning on line 227 in src/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 227 in src/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}
}

Expand All @@ -247,7 +247,7 @@
{
await _valuesState.SetValueAsync(new List<string>());
}
_valuesState.Value.Add(base.ConvertSet(_internalValue) ?? "");
_valuesState.Value.Add(ConvertSet(_internalValue) ?? "");

Check warning on line 250 in src/CodeBeam.MudBlazor.Extensions/Components/ChipField/MudChipField.razor.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
await ValuesChanged.InvokeAsync(_valuesState.Value);
if (RuntimeLocation.IsServerSide)
{
Expand Down Expand Up @@ -290,6 +290,5 @@
{
await _textFieldExtendedReference.Clear();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<MudInputControl Class="@Class" Style="@Style" Error="@ErrorState.Value" ErrorText="@GetErrorText()" Required="false">
<InputContent>
<div class="@Classname" style="@InnerStyle">
@for (int i = 0; i < Count; i++)
@for (int i = 0; i < _count.Value; i++)
{
int a = i;
<MudTextFieldExtended @ref="_elementReferences[a]" T="T" Class="@InputClassname" Style="@(Margin == Margin.Dense ? "width: 32px" : "width: 42px")" MaxLength="1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private async Task OnCountChanged()
/// <summary>
/// The value of the input.
/// </summary>
[Parameter]
[Parameter, ParameterState]
[Category(CategoryTypes.FormComponent.Behavior)]
public T? Value { get; set; }

Expand All @@ -114,7 +114,7 @@ private async Task OnCountChanged()
/// <summary>
/// The number of text fields.
/// </summary>
[Parameter]
[Parameter, ParameterState]
[Category(CategoryTypes.FormComponent.Behavior)]
public int Count { get; set; }

Expand Down Expand Up @@ -218,7 +218,7 @@ protected async Task CheckFocus(int count)
_skipRefocus = false;
return;
}
string str = base.ConvertSet(_theValue.Value) ?? string.Empty;
string str = ConvertSet(_theValue.Value) ?? string.Empty;
await _elementReferences[str.Length].FocusAsync();
}

Expand Down Expand Up @@ -298,7 +298,7 @@ public async Task SetValue()
/// <returns></returns>
public async Task SetValueFromOutside(T? value)
{
string? val = base.ConvertSet(value);
string? val = ConvertSet(value);
if (_count.Value < val?.Length)
{
val = val.Substring(0, _count.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{
foreach (var item in CollectionsMarshal.AsSpan(collection))
{
<MudChip Class="@ChipClass" Value="@item.Value" Text="@(ToStringFunc is not null ? ToStringFunc.Invoke(item.Value) : string.IsNullOrWhiteSpace(item.Text) ? base.ConvertSet(item.Value) : item.Text)"
<MudChip Class="@ChipClass" Value="@item.Value" Text="@(ToStringFunc is not null ? ToStringFunc.Invoke(item.Value) : string.IsNullOrWhiteSpace(item.Text) ? ConvertSet(item.Value) : item.Text)"
Color="@Color" Size="@ChipSize" Variant="@ChipVariant" @onmousedown:stopPropagation />
}
}
Expand Down
Loading
Loading