|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
@page "/forminputcombobox" |
|
|
|
|
|
|
|
|
|
@inject TestDataService dataService; |
|
|
|
|
@inject TestDataService dataService |
|
|
|
|
@inject EmployeeService employeeService |
|
|
|
|
|
|
|
|
|
@rendermode RenderMode.InteractiveServer |
|
|
|
|
|
|
|
|
@ -11,7 +12,7 @@ |
|
|
|
|
</FluentLabel> |
|
|
|
|
|
|
|
|
|
<FluentLabel class="my-3" Typo="Typography.H4">Default Example</FluentLabel> |
|
|
|
|
<FluentCard Class="mt-3" Width="auto" Height="450px" Style="overflow: visible"> |
|
|
|
|
<FluentCard Class="mt-3" Width="auto" Height="auto" AreaRestricted="false"> |
|
|
|
|
<h4>Select the T-shirt of best song from the list</h4> |
|
|
|
|
<FluentCombobox Placeholder="Select song..." Label="Song" Autofocus="true" |
|
|
|
|
Items="@dataService.Songs" @bind-Value="song"/> |
|
|
|
@ -19,18 +20,127 @@ |
|
|
|
|
Items="@dataService.Singers" @bind-Value="singer" /> |
|
|
|
|
<FluentCombobox Placeholder="Select size..." Label="Size" |
|
|
|
|
Items="@dataService.Sizes" @bind-Value="size" /> |
|
|
|
|
<div> |
|
|
|
|
Result: Lable <span>@song?</span>, Image <span>@singer?</span>, Size <span>@size?</span> |
|
|
|
|
<div class="mt-2"> |
|
|
|
|
<strong>Result</strong> |
|
|
|
|
<br /> |
|
|
|
|
Lable: <span>@song?.ToString()</span> | Image: <span>@singer?.ToString()</span> | Size: <span>@size?.ToString()</span> |
|
|
|
|
</div> |
|
|
|
|
</FluentCard> |
|
|
|
|
|
|
|
|
|
<FluentLabel class="my-3" Typo="Typography.H4">From a list of <code>Option<T></code></FluentLabel> |
|
|
|
|
<FluentCard Class="mt-3" Width="auto" Height="auto" AreaRestricted="false"> |
|
|
|
|
<h4 class="mt-2">From <code>Option<string></code> items</h4> |
|
|
|
|
<FluentCombobox Items="@stringOptions" |
|
|
|
|
OptionText="@(i => i.Text)" |
|
|
|
|
OptionValue="@(i => i.Value)" |
|
|
|
|
OptionSelected="@(i => i.Selected)" |
|
|
|
|
@bind-SelectedOption="selectedStringOption" |
|
|
|
|
@bind-Value="stringValue"/> |
|
|
|
|
<p> |
|
|
|
|
Selected Value: @stringValue<br /> |
|
|
|
|
<strong>Selected Item</strong><br /> |
|
|
|
|
Value: @selectedStringOption?.Value (Type: @(selectedStringOption?.GetType())) <br /> |
|
|
|
|
Text: @selectedStringOption?.Text <br /> |
|
|
|
|
</p> |
|
|
|
|
|
|
|
|
|
<h4 class="mt-2">From <code>Option<int></code> items</h4> |
|
|
|
|
<FluentCombobox Items="@intOptions" |
|
|
|
|
OptionText="@(i => i.Text)" |
|
|
|
|
OptionValue="@(i => i.Value.ToString())" |
|
|
|
|
OptionSelected="@(i => i.Selected)" |
|
|
|
|
OptionDisabled="@(i => i.Disabled)" |
|
|
|
|
@bind-SelectedOption="selectedIntOption" |
|
|
|
|
@bind-Value="intValue" /> |
|
|
|
|
<p> |
|
|
|
|
Selected Value: @intValue<br /> |
|
|
|
|
<strong>Selected Item</strong><br /> |
|
|
|
|
Value: @selectedIntOption?.Value (Type: @(selectedIntOption?.GetType())) <br /> |
|
|
|
|
Text: @selectedIntOption?.Text <br /> |
|
|
|
|
</p> |
|
|
|
|
</FluentCard> |
|
|
|
|
|
|
|
|
|
<FluentLabel class="my-3" Typo="Typography.H4">Autocomplete</FluentLabel> |
|
|
|
|
<FluentCard Class="mt-3" Width="auto" Height="auto" AreaRestricted="false"> |
|
|
|
|
<h4>Inline Autocomplte</h4> |
|
|
|
|
<FluentCombobox Items="@names" Autocomplete="ComboboxAutocomplete.Inline" /> |
|
|
|
|
<h4>List Autocomplte</h4> |
|
|
|
|
<FluentCombobox Items="@names" Autocomplete="ComboboxAutocomplete.List" /> |
|
|
|
|
<h4>Both Autocomplte</h4> |
|
|
|
|
<FluentCombobox Items="@names" Autocomplete="ComboboxAutocomplete.Both" /> |
|
|
|
|
</FluentCard> |
|
|
|
|
|
|
|
|
|
<FluentLabel class="my-3" Typo="Typography.H4">Option template</FluentLabel> |
|
|
|
|
<FluentCard Class="mt-3" Width="auto" Height="auto" AreaRestricted="false"> |
|
|
|
|
<FluentCombobox Items="@employeeService.GetFixedEmployeeData()" |
|
|
|
|
OptionValue="@(e => e.ID.ToString())" |
|
|
|
|
@bind-Value="selectedEmployValue" |
|
|
|
|
@bind-SelectedOption="selectedEmployee"> |
|
|
|
|
<OptionTemplate> |
|
|
|
|
<FluentIcon Value="@(new Icons.Regular.Size16.Person())" Slot="end" OnClick="@(() => { message = $"Icon for {context.FirstName} {context.LastName} selected."; })"/> |
|
|
|
|
@context.FirstName (@context.LastName) |
|
|
|
|
</OptionTemplate> |
|
|
|
|
</FluentCombobox> |
|
|
|
|
<p> |
|
|
|
|
<strong>Selected option</strong>: @selectedEmployee?.FirstName @selectedEmployee?.LastName |
|
|
|
|
@if (selectedEmployee != null && selectedEmployee.BirthDate != null) |
|
|
|
|
{ |
|
|
|
|
<span> |
|
|
|
|
(@selectedEmployee.BirthDate.ToString("yyyy-MM-dd")) |
|
|
|
|
</span> |
|
|
|
|
} |
|
|
|
|
<br/> |
|
|
|
|
<strong>Selected value</strong>: @selectedEmployValue <br /> |
|
|
|
|
<strong>Message</strong>: @message; |
|
|
|
|
</p> |
|
|
|
|
</FluentCard> |
|
|
|
|
|
|
|
|
|
@code { |
|
|
|
|
string? song; |
|
|
|
|
string? singer; |
|
|
|
|
string? size; |
|
|
|
|
|
|
|
|
|
Employee selectedEmployee = default!; |
|
|
|
|
string? selectedEmployValue; |
|
|
|
|
string? message; |
|
|
|
|
|
|
|
|
|
protected override void OnInitialized() |
|
|
|
|
{ |
|
|
|
|
singer = dataService.Singers.FirstOrDefault(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Option<string> selectedStringOption = default; |
|
|
|
|
string? stringValue; |
|
|
|
|
Option<int> selectedIntOption = default; |
|
|
|
|
string? intValue; |
|
|
|
|
|
|
|
|
|
List<Option<string>> stringOptions = new() |
|
|
|
|
{ |
|
|
|
|
{ new Option<string> { Value = "1", Text = "One" } }, |
|
|
|
|
{ new Option<string> { Value = "2", Text = "Two", Selected = true } }, |
|
|
|
|
{ new Option<string> { Value = "3", Text = "Three" } }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
List<Option<int>> intOptions = new() |
|
|
|
|
{ |
|
|
|
|
{ new Option<int> { Value = 3, Text = "1", Disabled = true } }, |
|
|
|
|
{ new Option<int> { Value = 2, Text = "2" } }, |
|
|
|
|
{ new Option<int> { Value = 1, Text = "3" } }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
List<string> names = new() |
|
|
|
|
{ |
|
|
|
|
"William Hartnell", |
|
|
|
|
"Patrick Troughton", |
|
|
|
|
"Jon Pertwee", |
|
|
|
|
"Tom Baker", |
|
|
|
|
"Peter Davidson", |
|
|
|
|
"Colin Baker", |
|
|
|
|
"Sylvester McCoy", |
|
|
|
|
"Paul McGann", |
|
|
|
|
"Christopher Eccleston", |
|
|
|
|
"David Tenant", |
|
|
|
|
"Matt Smith", |
|
|
|
|
"Peter Capaldi", |
|
|
|
|
"Jodie Whittaker", |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|