mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-07-28 17:42:57 +00:00
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using AIStudio.Settings;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AIStudio.Components;
|
|
|
|
/// <summary>
|
|
/// Configuration component for selecting a value from a list.
|
|
/// </summary>
|
|
/// <typeparam name="TConfig">The type of the value to select.</typeparam>
|
|
public partial class ConfigurationSelect<TConfig> : ConfigurationBaseCore
|
|
{
|
|
/// <summary>
|
|
/// The data to select from.
|
|
/// </summary>
|
|
[Parameter]
|
|
public IEnumerable<ConfigurationSelectData<TConfig>> Data { get; set; } = [];
|
|
|
|
/// <summary>
|
|
/// The selected value.
|
|
/// </summary>
|
|
[Parameter]
|
|
public Func<TConfig> SelectedValue { get; set; } = () => default!;
|
|
|
|
/// <summary>
|
|
/// An action that is called when the selection changes.
|
|
/// </summary>
|
|
[Parameter]
|
|
public Action<TConfig> SelectionUpdate { get; set; } = _ => { };
|
|
|
|
private async Task OptionChanged(TConfig updatedValue)
|
|
{
|
|
this.SelectionUpdate(updatedValue);
|
|
await this.SettingsManager.StoreSettings();
|
|
await this.InformAboutChange();
|
|
}
|
|
|
|
private static string GetClass => $"{MARGIN_CLASS} rounded-lg";
|
|
} |