2025-11-10 16:01:49 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using AIStudio.Tools.PluginSystem.Assistants.DataModel;
|
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
using MudBlazor;
|
|
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Components
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class DynamicAssistantDropdown : ComponentBase
|
|
|
|
|
|
{
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
public List<AssistantDropdownItem> Items { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
public AssistantDropdownItem Default { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
public string Value { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
public EventCallback<string> ValueChanged { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
public string Label { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
public Func<string, string?> ValidateSelection { get; set; } = _ => null;
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
public string Icon { get; set; } = Icons.Material.Filled.ArrowDropDown;
|
2025-11-11 14:57:15 +00:00
|
|
|
|
|
|
|
|
|
|
private async Task OnValueChanged(string newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.Value != newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Value = newValue;
|
|
|
|
|
|
await this.ValueChanged.InvokeAsync(newValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-10 16:01:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|