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.

Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
@namespace MudExtensions.Docs.Examples

<div class="d-flex gap-8">
<MudSelectExtended T="string" Label="RenderFragment Based">
<MudSelectItemExtended Value="@("Foo")" Text="Foo" />
<MudSelectItemExtended Value="@("Bar")" Text="Bar" />
<MudSelectItemExtended Value="@("Fizz")" Text="Fizz" />
<MudSelectItemExtended Value="@("Buzz")" Text="Buzz" />
</MudSelectExtended>
<MudGrid>
<MudItem xs="12" sm="8">
<MudStack>
<MudSelectExtended T="string" Label="RenderFragment Based" Disabled="_disabled">
<MudSelectItemExtended Value="@("Foo")" Text="Foo" />
<MudSelectItemExtended Value="@("Bar")" Text="Bar" />
<MudSelectItemExtended Value="@("Fizz")" Text="Fizz" />
<MudSelectItemExtended Value="@("Buzz")" Text="Buzz" />
</MudSelectExtended>
<MudSelectExtended T="string" Label="Data Based" ItemCollection="_collection" Disabled="_disabled" />
<MudSelectExtended T="string" Label="Data Based" ItemCollection="_collection" Disabled="_disabled" AddNullItem="true" AddedNullItemText="@_nullItemText" />
</MudStack>
</MudItem>

<MudSelectExtended T="string" Label="Data Based" ItemCollection="_collection" />
</div>
<MudItem xs="12" sm="4">
<MudStack>
<MudSwitchM3 @bind-Value="_disabled" Color="Color.Secondary" Label="Disabled" />
<MudTextField @bind-Value="_nullItemText" Label="Null Item Text" Variant="Variant.Outlined" />
</MudStack>
</MudItem>
</MudGrid>

@code {
string[] _collection = new string[] { "Foo", "Bar", "Fizz", "Buzz" };
private bool _disabled = false;
private string[] _collection = new string[] { "Foo", "Bar", "Fizz", "Buzz" };
private string? _nullItemText = "None";
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@
<MudDivider />
}
}
@if (AddNullItem)
{
@if (MudSelectExtended != null)
{
<MudSelectItemExtended Value="default(T)" Text="@AddedNullItemText" />
}
else
{
<MudListItemExtended Value="default(T)" Text="@AddedNullItemText" />
}
}
<MudVirtualize Enabled="@Virtualize" Items="GetSearchedItems()" Context="item" OverscanCount="@OverscanCount">
@if (MudSelectExtended != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,19 @@ public bool MultiSelection
/// </summary>
[Parameter] public EventCallback<ListItemClickEventArgs<T?>> OnDoubleClick { get; set; }

/// <summary>
/// If true, a null item will be added to the list (Only for ItemCollection).
/// </summary>
[Parameter]
public bool AddNullItem { get; set; }

/// <summary>
/// Gets or sets the text displayed for a null item that has been added.
/// </summary>
[Parameter]
public string? AddedNullItemText { get; set; } = "None";


#endregion


Expand Down Expand Up @@ -740,6 +753,19 @@ protected override void OnInitialized()
/// </summary>
protected override void OnParametersSet()
{
//if (ItemCollection != null)
//{
// var list = ItemCollection.ToList();

// if (PopulateOptions == ItemPopulateOptions.AddNullItem)
// {
// if (!list.Contains(default(T)))
// list.Insert(0, default(T)); // null item
// }

// ItemCollection = list;
//}

base.OnParametersSet();
ParametersChanged?.Invoke();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<CascadingValue Name="Standalone" Value="false" IsFixed="true">
<CascadingValue Value="@this" IsFixed="true">
<div class="mud-select-extended" id="@_elementId">
<div class="mud-select-extended" style="@(Disabled ? "pointer-events: none" : null)" id="@_elementId">
<MudInputControl Label="@Label" Variant="@Variant" HelperText="@HelperText" HelperTextOnFocus="@HelperTextOnFocus" FullWidth="@FullWidth" Margin="@Margin" Class="@Classname" Style="@Style"
Error="@Error" ErrorText="@ErrorText" ErrorId="@ErrorId" Disabled="@Disabled" @onclick="@ToggleMenu" Required="@Required" ForId="@FieldId">
<InputContent>
Expand Down Expand Up @@ -126,7 +126,7 @@
<MudListExtended @ref="@_list" T="T" @bind-SelectedValue="@Value" Style="@($"overflow-y:auto; max-height: {MaxHeight}px")" @bind-SelectedValues="@SelectedValues" @bind-SelectedItem="@SelectedListItem" @bind-SelectedItems="@SelectedListItems"
Clickable="true" Color="@Color" Dense="@Dense" ItemCollection="@ItemCollection" Virtualize="@Virtualize" Padding="@EnablePopoverPadding" EnableSelectedItemStyle="@EnableSelectedItemStyle"
MultiSelection="@MultiSelection" MultiSelectionComponent="@MultiSelectionComponent" MultiSelectionAlign="@MultiSelectionAlign" SelectAll="@SelectAll" SelectAllPosition="@SelectAllPosition" SelectAllText="@SelectAllText"
CheckedIcon="@CheckedIcon" UncheckedIcon="@UncheckedIcon" IndeterminateIcon="@IndeterminateIcon" SelectValueOnTab="@SelectValueOnTab" Comparer="@Comparer"
CheckedIcon="@CheckedIcon" UncheckedIcon="@UncheckedIcon" IndeterminateIcon="@IndeterminateIcon" SelectValueOnTab="@SelectValueOnTab" Comparer="@Comparer" AddNullItem="@AddNullItem" AddedNullItemText="@AddedNullItemText"
ItemTemplate="@ItemTemplate" ItemSelectedTemplate="@ItemSelectedTemplate" ItemDisabledTemplate="@ItemDisabledTemplate" SearchBox="@SearchBox" SearchBoxAutoFocus="@SearchBoxAutoFocus" SearchFunc="@SearchFunc" SearchBoxPlaceholder="@SearchBoxPlaceholder"
SearchBoxClearable="@SearchBoxClearable" SearchBoxVariant="@SearchBoxVariant" SearchBoxAdornment="SearchBoxAdornment" ToStringFunc="@ToStringFunc" OnSearchStringChange="@OnSearchStringChange">
@ChildContent
Expand All @@ -151,7 +151,7 @@
<MudListExtended T="T" @bind-SelectedValue="@Value" @bind-SelectedValues="@SelectedValues" @bind-SelectedItem="@SelectedListItem" @bind-SelectedItems="@SelectedListItems"
Clickable="true" Color="@Color" Dense="@Dense" ItemCollection="@ItemCollection" Virtualize="@Virtualize" Padding="@EnablePopoverPadding" EnableSelectedItemStyle="@EnableSelectedItemStyle"
MultiSelection="@MultiSelection" MultiSelectionComponent="@MultiSelectionComponent" MultiSelectionAlign="@MultiSelectionAlign" SelectAll="@SelectAll" SelectAllPosition="@SelectAllPosition" SelectAllText="@SelectAllText"
CheckedIcon="@CheckedIcon" UncheckedIcon="@UncheckedIcon" IndeterminateIcon="@IndeterminateIcon" SelectValueOnTab="@SelectValueOnTab" Comparer="@Comparer"
CheckedIcon="@CheckedIcon" UncheckedIcon="@UncheckedIcon" IndeterminateIcon="@IndeterminateIcon" SelectValueOnTab="@SelectValueOnTab" Comparer="@Comparer" AddNullItem="@AddNullItem" AddedNullItemText="@AddedNullItemText"
ItemTemplate="@ItemTemplate" ItemSelectedTemplate="@ItemSelectedTemplate" ItemDisabledTemplate="@ItemDisabledTemplate" SearchBox="@SearchBox" SearchBoxAutoFocus="@SearchBoxAutoFocus" SearchFunc="@SearchFunc" SearchBoxPlaceholder="@SearchBoxPlaceholder"
SearchBoxClearable="@SearchBoxClearable" SearchBoxVariant="@SearchBoxVariant" SearchBoxAdornment="SearchBoxAdornment" ToStringFunc="@ToStringFunc" OnSearchStringChange="@OnSearchStringChange">
@ChildContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
/// <summary>
///
/// </summary>
protected Dictionary<T, MudSelectItemExtended<T?>> _valueLookup = new();

Check warning on line 45 in CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor.cs

View workflow job for this annotation

GitHub Actions / build

The type 'T' cannot be used as type parameter 'TKey' in the generic type or method 'Dictionary<TKey, TValue>'. Nullability of type argument 'T' doesn't match 'notnull' constraint.
/// <summary>
///
/// </summary>
protected Dictionary<T, MudSelectItemExtended<T?>> _shadowLookup = new();

Check warning on line 49 in CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor.cs

View workflow job for this annotation

GitHub Actions / build

The type 'T' cannot be used as type parameter 'TKey' in the generic type or method 'Dictionary<TKey, TValue>'. Nullability of type argument 'T' doesn't match 'notnull' constraint.
private MudInputExtended<string> _elementReference = new();
internal bool _isOpen;
/// <summary>
Expand Down Expand Up @@ -522,6 +522,18 @@
}
}

/// <summary>
/// If true, a null item will be added to the list (Only for ItemCollection).
/// </summary>
[Parameter]
public bool AddNullItem { get; set; }

/// <summary>
/// Gets or sets the text displayed for a null item that has been added.
/// </summary>
[Parameter]
public string? AddedNullItemText { get; set; } = "None";

#endregion


Expand Down
Loading