oqtane.framework/Oqtane.Client/Modules/Controls/InputList.razor
Leigh Pointer 09f1d3ca15 Add InputList control to select values from a dictionary of string
The control accepts a dictionary of string that can be searched using an input control.
Pages Add and Edit have implemented the control to render the list of Icons found in the Oqtane Shared namespace.
2023-08-22 09:50:59 +02:00

31 lines
898 B
Plaintext

@namespace Oqtane.Modules.Controls
@using System.Linq.Expressions;
@inherits ModuleControlBase
<input type="text" value="@Value" list="Dictionarylist" class="form-select" @onchange="(e => OnChange(e))" />
<datalist id="Dictionarylist" value="@Value">
@foreach(var iv in InputValues)
{
<option value="@iv.Value">@iv.Key</option>
}
</datalist>
@code {
[Parameter]
public string Value { get; set; }
[EditorRequired]
[Parameter]
public Dictionary<string, string> InputValues { get; set; }
[EditorRequired]
[Parameter]
public EventCallback<string> ValueChanged { get; set; }
protected void OnChange(ChangeEventArgs e)
{
if (string.IsNullOrWhiteSpace(e.Value.ToString())) { return; }
Value = e.Value.ToString();
if (ValueChanged.HasDelegate)
{
ValueChanged.InvokeAsync(Value);
}
}
}