@{
#nullable disable
}
@inherits MudBaseInput<T>
@typeparam T
<CascadingValue Name="SubscribeToParentForm" Value="false" IsFixed="true">
<div class="@AutocompleteClassname">
<MudInputControl Label="@Label" Variant="@Variant" HelperText="@HelperText" HelperTextOnFocus="@HelperTextOnFocus" FullWidth="@FullWidth" Margin="@Margin" Class="@Classname" Style="@Style"
Error="@Error" ErrorText="@ErrorText" Disabled="@GetDisabledState()" @onclick="@ToggleMenu" Required="@Required" ForId="@FieldId">
<InputContent>
<MudInput @ref="_elementReference" @key="_elementKey" InputType="InputType.Text"
Class="mud-select-input" Margin="@Margin"
Variant="@Variant"
TextUpdateSuppression="@TextUpdateSuppression"
Value="@Text" DisableUnderLine="@DisableUnderLine"
Disabled="@GetDisabledState()" ReadOnly="@GetReadOnlyState()" Error="@Error"
OnAdornmentClick="@OnAdornmentClick" AdornmentIcon="@CurrentIcon" Adornment="@Adornment" AdornmentColor="@AdornmentColor" IconSize="@IconSize" AdornmentText="@AdornmentText"
Clearable="@(!GetReadOnlyState() && Clearable)" OnClearButtonClick="@OnClearButtonClick"
@attributes="UserAttributes"
TextChanged="OnTextChanged" OnBlur="OnInputBlurred"
OnKeyDown="@this.OnInputKeyDown"
OnKeyUp="@this.OnInputKeyUp" autocomplete=@("mud-disabled-"+Guid.NewGuid()) KeyUpPreventDefault="KeyUpPreventDefault"
Placeholder="@Placeholder" Immediate="true"
InputMode="@InputMode" Pattern="@Pattern"
ShrinkLabel="@ShrinkLabel"
T="string" />
@if (ShowProgressIndicator && IsLoading)
{
@if (ProgressIndicatorTemplate != null)
{
@ProgressIndicatorTemplate
}
else
{
<div class="@CircularProgressClassname">
<MudProgressCircular Color="ProgressIndicatorColor" Indeterminate="true" Size="Size.Small"/>
</div>
}
}
<MudPopover Open="@IsOpen" MaxHeight="@MaxHeight" AnchorOrigin="@AnchorOrigin" TransformOrigin="@TransformOrigin" Class="@PopoverClass" RelativeWidth="true">
@if (ProgressIndicatorInPopoverTemplate != null && IsLoading)
{
@ProgressIndicatorInPopoverTemplate
}
else if (_items != null && _items.Length != 0)
{
<MudList Class="@ListClass" Clickable="true" Dense="@Dense">
@if (BeforeItemsTemplate != null)
{
<div class="mud-autocomplete-before-items pa-1">
@BeforeItemsTemplate
</div>
}
@for (var index = 0; index < _items.Length; index++)
{
var item = _items[index];
bool isSelected = index == _selectedListItemIndex;
bool isDisabled = !_enabledItemIndices.Contains(index);
var captureIndex = index;
<MudListItem @key="@item" id="@GetListItemId(captureIndex)" Disabled="@(isDisabled)" OnClick="@(async () => await ListItemOnClick(item))" OnClickHandlerPreventDefault="true" Class="@GetListItemClassname(isSelected)">
@if (ItemTemplate == null)
{
@GetItemString(item)
}
else if (isDisabled && ItemDisabledTemplate != null)
{
@ItemDisabledTemplate(item)
}
else if (isSelected)
{
@if (ItemSelectedTemplate == null)
@ItemTemplate(item)
else
@ItemSelectedTemplate(item)
}
else
{
@ItemTemplate(item)
}
</MudListItem>
}
@if (MoreItemsTemplate != null && _returnedItemsCount > MaxItems)
{
<div class="mud-autocomplete-more-items pa-1">
@MoreItemsTemplate
</div>
}
@if (AfterItemsTemplate != null)
{
<div class="mud-autocomplete-after-items pa-1">
@AfterItemsTemplate
</div>
}
</MudList>
}
else if (NoItemsTemplate != null)
{
<div class="mud-autocomplete-no-items pa-1">
@NoItemsTemplate
</div>
}
</MudPopover>
</InputContent>
</MudInputControl>
</div>
</CascadingValue>
<MudOverlay Visible="IsOpen" OnClick="@ToggleMenu" @ontouchstart="@ToggleMenu" LockScroll="false" />