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
|
|
|
|
|
|
{
|
2026-02-24 16:21:50 +00:00
|
|
|
|
[Parameter] public List<AssistantDropdownItem> Items { get; set; } = new();
|
2025-11-10 16:01:49 +00:00
|
|
|
|
|
2026-02-24 16:21:50 +00:00
|
|
|
|
[Parameter] public AssistantDropdownItem Default { get; set; } = new();
|
2025-11-10 16:01:49 +00:00
|
|
|
|
|
2026-02-24 16:21:50 +00:00
|
|
|
|
[Parameter] public string Value { get; set; } = string.Empty;
|
2025-11-10 16:01:49 +00:00
|
|
|
|
|
2026-02-24 16:21:50 +00:00
|
|
|
|
[Parameter] public EventCallback<string> ValueChanged { get; set; }
|
2025-11-10 16:01:49 +00:00
|
|
|
|
|
2026-02-24 16:21:50 +00:00
|
|
|
|
[Parameter] public string Label { get; set; } = string.Empty;
|
2026-03-13 00:14:03 +00:00
|
|
|
|
|
|
|
|
|
|
[Parameter] public string HelperText { get; set; } = string.Empty;
|
2026-02-24 16:21:50 +00:00
|
|
|
|
|
|
|
|
|
|
[Parameter] public Func<string, string?> ValidateSelection { get; set; } = _ => null;
|
|
|
|
|
|
|
2026-03-13 00:14:03 +00:00
|
|
|
|
[Parameter] public string OpenIcon { get; set; } = Icons.Material.Filled.ArrowDropDown;
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter] public string CloseIcon { get; set; } = Icons.Material.Filled.ArrowDropUp;
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter] public Color IconColor { get; set; } = Color.Default;
|
2026-02-24 16:21:50 +00:00
|
|
|
|
|
2026-03-13 00:14:03 +00:00
|
|
|
|
[Parameter] public Adornment IconPosition { get; set; } = Adornment.End;
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter] public Variant Variant { get; set; } = Variant.Outlined;
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter] public bool IsMultiselect { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter] public bool HasSelectAll { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter] public string SelectAllText { get; set; } = string.Empty;
|
2026-02-24 16:21:50 +00:00
|
|
|
|
|
2026-03-13 00:14:03 +00:00
|
|
|
|
[Parameter] public string Class { get; set; } = string.Empty;
|
|
|
|
|
|
|
2026-02-24 16:21:50 +00:00
|
|
|
|
[Parameter] public string Style { get; set; } = string.Empty;
|
2025-11-10 16:01:49 +00:00
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-02-24 16:21:50 +00:00
|
|
|
|
|
2026-03-13 00:14:03 +00:00
|
|
|
|
private string MergeClasses(string custom, string fallback)
|
2026-02-24 16:21:50 +00:00
|
|
|
|
{
|
|
|
|
|
|
var trimmedCustom = custom?.Trim() ?? string.Empty;
|
|
|
|
|
|
var trimmedFallback = fallback?.Trim() ?? string.Empty;
|
|
|
|
|
|
if (string.IsNullOrEmpty(trimmedCustom))
|
|
|
|
|
|
return trimmedFallback;
|
|
|
|
|
|
|
2026-03-13 00:14:03 +00:00
|
|
|
|
return string.IsNullOrEmpty(trimmedFallback) ? trimmedCustom : $"{trimmedCustom} {trimmedFallback}";
|
2026-02-24 16:21:50 +00:00
|
|
|
|
}
|
2025-11-10 16:01:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|