added class and style properties to every component

This commit is contained in:
krut_ni 2026-02-24 17:21:50 +01:00
parent 024fb5821c
commit 6ad7aba58e
No known key found for this signature in database
GPG Key ID: A5C0151B4DDB172C
18 changed files with 371 additions and 206 deletions

View File

@ -12,7 +12,7 @@
if (component is AssistantTextArea textArea) if (component is AssistantTextArea textArea)
{ {
var lines = textArea.IsSingleLine ? 1 : 6; var lines = textArea.IsSingleLine ? 1 : 6;
<MudTextField T="string" @bind-Text="@this.inputFields[textArea.Name]" Label="@textArea.Label" ReadOnly="@textArea.ReadOnly" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Variant="Variant.Outlined" Lines="@lines" AutoGrow="@true" MaxLines="12" Class="mb-3"/> <MudTextField T="string" @bind-Text="@this.inputFields[textArea.Name]" Label="@textArea.Label" ReadOnly="@textArea.ReadOnly" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Variant="Variant.Outlined" Lines="@lines" AutoGrow="@true" MaxLines="12" Class='@MergeClass(textArea.Class, "mb-3")' Style="@this.GetOptionalStyle(textArea.Style)"/>
} }
break; break;
case AssistantComponentType.IMAGE: case AssistantComponentType.IMAGE:
@ -23,7 +23,7 @@
{ {
var image = assistantImage; var image = assistantImage;
<div Class="mb-4"> <div Class="mb-4">
<MudImage Fluid="true" Src="@resolvedSource" Alt="@image.Alt" Class="rounded-lg mb-2" Elevation="20"/> <MudImage Fluid="true" Src="@resolvedSource" Alt="@image.Alt" Class='@MergeClass(image.Class, "rounded-lg mb-2")' Style="@this.GetOptionalStyle(image.Style)" Elevation="20"/>
@if (!string.IsNullOrWhiteSpace(image.Caption)) @if (!string.IsNullOrWhiteSpace(image.Caption))
{ {
<MudText Typo="Typo.caption" Align="Align.Center">@image.Caption</MudText> <MudText Typo="Typo.caption" Align="Align.Center">@image.Caption</MudText>
@ -39,13 +39,17 @@
ProviderSettings="@this.providerSettings" ProviderSettings="@this.providerSettings"
@bind-AgentIsRunning="@webState.AgentIsRunning" @bind-AgentIsRunning="@webState.AgentIsRunning"
@bind-Preselect="@webState.Preselect" @bind-Preselect="@webState.Preselect"
@bind-PreselectContentCleanerAgent="@webState.PreselectContentCleanerAgent" /> @bind-PreselectContentCleanerAgent="@webState.PreselectContentCleanerAgent"
Class="@webContent.Class"
Style="@webContent.Style" />
} }
break; break;
case AssistantComponentType.FILE_CONTENT_READER: case AssistantComponentType.FILE_CONTENT_READER:
if (component is AssistantFileContentReader fileContent && this.fileContentFields.TryGetValue(fileContent.Name, out var fileState)) if (component is AssistantFileContentReader fileContent && this.fileContentFields.TryGetValue(fileContent.Name, out var fileState))
{ {
<ReadFileContent @bind-FileContent="@fileState.Content" /> <ReadFileContent @bind-FileContent="@fileState.Content"
Class="@fileContent.Class"
Style="@fileContent.Style" />
} }
break; break;
@ -56,26 +60,34 @@
@bind-Value="@this.dropdownFields[assistantDropdown.Name]" @bind-Value="@this.dropdownFields[assistantDropdown.Name]"
Default="@assistantDropdown.Default" Default="@assistantDropdown.Default"
Label="@assistantDropdown.Label" Label="@assistantDropdown.Label"
Icon="@Icons.Material.Filled.Translate"/> Icon="@Icons.Material.Filled.Translate"
Class="@assistantDropdown.Class"
Style="@assistantDropdown.Style"/>
} }
break; break;
case AssistantComponentType.PROVIDER_SELECTION: case AssistantComponentType.PROVIDER_SELECTION:
if (component is AssistantProviderSelection providerSelection) if (component is AssistantProviderSelection providerSelection)
{ {
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/> <ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"
Class="@providerSelection.Class"
Style="@providerSelection.Style"/>
} }
break; break;
case AssistantComponentType.PROFILE_SELECTION: case AssistantComponentType.PROFILE_SELECTION:
if (component is AssistantProfileSelection profileSelection) if (component is AssistantProfileSelection profileSelection)
{ {
var selection = profileSelection; var selection = profileSelection;
<ProfileFormSelection Validation="@((Profile profile) => this.ValidateProfileSelection(selection, profile))" @bind-Profile="@this.currentProfile"/> <ProfileFormSelection Validation="@((Profile profile) => this.ValidateProfileSelection(selection, profile))" @bind-Profile="@this.currentProfile"
Class="@selection.Class"
Style="@selection.Style"/>
} }
break; break;
case AssistantComponentType.SWITCH: case AssistantComponentType.SWITCH:
if (component is AssistantSwitch assistantSwitch) if (component is AssistantSwitch assistantSwitch)
{ {
<MudTextSwitch Label="@assistantSwitch.Label" @bind-Value="@this.switchFields[assistantSwitch.Name]" LabelOn="@assistantSwitch.LabelOn" LabelOff="@assistantSwitch.LabelOff" /> <MudTextSwitch Label="@assistantSwitch.Label" @bind-Value="@this.switchFields[assistantSwitch.Name]" LabelOn="@assistantSwitch.LabelOn" LabelOff="@assistantSwitch.LabelOff"
Class="@assistantSwitch.Class"
Style="@this.GetOptionalStyle(assistantSwitch.Style)" />
} }
break; break;
case AssistantComponentType.HEADING: case AssistantComponentType.HEADING:
@ -85,16 +97,16 @@
@switch (assistantHeading.Level) @switch (assistantHeading.Level)
{ {
case 1: case 1:
<MudText Typo="Typo.h4">@heading.Text</MudText> <MudText Typo="Typo.h4" Class="@heading.Class" Style="@this.GetOptionalStyle(heading.Style)">@heading.Text</MudText>
break; break;
case 2: case 2:
<MudText Typo="Typo.h5">@heading.Text</MudText> <MudText Typo="Typo.h5" Class="@heading.Class" Style="@this.GetOptionalStyle(heading.Style)">@heading.Text</MudText>
break; break;
case 3: case 3:
<MudText Typo="Typo.h6">@heading.Text</MudText> <MudText Typo="Typo.h6" Class="@heading.Class" Style="@this.GetOptionalStyle(heading.Style)">@heading.Text</MudText>
break; break;
default: default:
<MudText Typo="Typo.h4">@heading.Text</MudText> <MudText Typo="Typo.h4" Class="@heading.Class" Style="@this.GetOptionalStyle(heading.Style)">@heading.Text</MudText>
break; break;
} }
} }
@ -103,14 +115,14 @@
if (component is AssistantText assistantText) if (component is AssistantText assistantText)
{ {
var text = assistantText; var text = assistantText;
<MudText Typo="Typo.body1" Class="mb-3">@text.Content</MudText> <MudText Typo="Typo.body1" Class='@MergeClass(text.Class, "mb-3")' Style="@this.GetOptionalStyle(text.Style)">@text.Content</MudText>
} }
break; break;
case AssistantComponentType.LIST: case AssistantComponentType.LIST:
if (component is AssistantList assistantList) if (component is AssistantList assistantList)
{ {
var list = assistantList; var list = assistantList;
<MudList T="string" Class="mb-6"> <MudList T="string" Class='@MergeClass(list.Class, "mb-6")' Style="@this.GetOptionalStyle(list.Style)">
@foreach (var item in list.Items) @foreach (var item in list.Items)
{ {
@if (item.Type == "LINK") @if (item.Type == "LINK")

View File

@ -307,6 +307,21 @@ public partial class AssistantDynamic : AssistantBaseCore<SettingsDialogDynamic>
return prompt; return prompt;
} }
private static string MergeClass(string customClass, string fallback)
{
var trimmedCustom = customClass?.Trim() ?? string.Empty;
var trimmedFallback = fallback?.Trim() ?? string.Empty;
if (string.IsNullOrEmpty(trimmedCustom))
return trimmedFallback;
if (string.IsNullOrEmpty(trimmedFallback))
return trimmedCustom;
return $"{trimmedCustom} {trimmedFallback}";
}
private string? GetOptionalStyle(string? style) => string.IsNullOrWhiteSpace(style) ? null : style;
private string? ValidateProfileSelection(AssistantProfileSelection profileSelection, Profile profile) private string? ValidateProfileSelection(AssistantProfileSelection profileSelection, Profile profile)
{ {

View File

@ -1,4 +1,4 @@
<MudStack Row="true" Class="mb-3"> <MudStack Row="true" Class='@this.MergeClasses(this.Class, "mb-3")' Style="@this.Style">
<MudSelect <MudSelect
T="string" T="string"
Value="@this.Value" Value="@this.Value"
@ -18,4 +18,4 @@
</MudSelectItem> </MudSelectItem>
} }
</MudSelect> </MudSelect>
</MudStack> </MudStack>

View File

@ -9,27 +9,24 @@ namespace AIStudio.Components
{ {
public partial class DynamicAssistantDropdown : ComponentBase public partial class DynamicAssistantDropdown : ComponentBase
{ {
[Parameter] [Parameter] public List<AssistantDropdownItem> Items { get; set; } = new();
public List<AssistantDropdownItem> Items { get; set; } = new();
[Parameter]
public AssistantDropdownItem Default { get; set; } = new();
[Parameter] [Parameter] public AssistantDropdownItem Default { get; set; } = new();
public string Value { get; set; } = string.Empty;
[Parameter] [Parameter] public string Value { get; set; } = string.Empty;
public EventCallback<string> ValueChanged { get; set; }
[Parameter] [Parameter] public EventCallback<string> ValueChanged { get; set; }
public string Label { get; set; } = string.Empty;
[Parameter] [Parameter] public string Label { get; set; } = string.Empty;
public Func<string, string?> ValidateSelection { get; set; } = _ => null;
[Parameter] public Func<string, string?> ValidateSelection { get; set; } = _ => null;
[Parameter] public string Icon { get; set; } = Icons.Material.Filled.ArrowDropDown;
[Parameter] public string Class { get; set; } = string.Empty;
[Parameter] public string Style { get; set; } = string.Empty;
[Parameter]
public string Icon { get; set; } = Icons.Material.Filled.ArrowDropDown;
private async Task OnValueChanged(string newValue) private async Task OnValueChanged(string newValue)
{ {
if (this.Value != newValue) if (this.Value != newValue)
@ -38,5 +35,18 @@ namespace AIStudio.Components
await this.ValueChanged.InvokeAsync(newValue); await this.ValueChanged.InvokeAsync(newValue);
} }
} }
internal string MergeClasses(string custom, string fallback)
{
var trimmedCustom = custom?.Trim() ?? string.Empty;
var trimmedFallback = fallback?.Trim() ?? string.Empty;
if (string.IsNullOrEmpty(trimmedCustom))
return trimmedFallback;
if (string.IsNullOrEmpty(trimmedFallback))
return trimmedCustom;
return $"{trimmedCustom} {trimmedFallback}";
}
} }
} }

View File

@ -1,6 +1,6 @@
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel; namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
public class AssistantButton : AssistantComponentBase internal sealed class AssistantButton : AssistantComponentBase
{ {
public override AssistantComponentType Type => AssistantComponentType.BUTTON; public override AssistantComponentType Type => AssistantComponentType.BUTTON;
public Dictionary<string, object> Props { get; set; } = new(); public Dictionary<string, object> Props { get; set; } = new();
@ -8,23 +8,30 @@ public class AssistantButton : AssistantComponentBase
public string Name public string Name
{ {
get => this.Props.TryGetValue(nameof(this.Name), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
: string.Empty;
set => this.Props[nameof(this.Name)] = value;
} }
public string Text public string Text
{ {
get => this.Props.TryGetValue(nameof(this.Text), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Text));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Text), value);
: string.Empty;
set => this.Props[nameof(this.Text)] = value;
} }
public string Action public string Action
{ {
get => this.Props.TryGetValue(nameof(this.Action), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Action));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Action), value);
: string.Empty;
set => this.Props[nameof(this.Action)] = value;
} }
}
public string Class
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
}
public string Style
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
}
}

View File

@ -0,0 +1,21 @@
using System.Collections.Generic;
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
internal static class AssistantComponentPropHelper
{
public static string ReadString(Dictionary<string, object> props, string key)
{
if (props.TryGetValue(key, out var value))
{
return value?.ToString() ?? string.Empty;
}
return string.Empty;
}
public static void WriteString(Dictionary<string, object> props, string key, string value)
{
props[key] = value ?? string.Empty;
}
}

View File

@ -1,34 +1,31 @@
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel; using System.Collections.Generic;
public class AssistantDropdown : AssistantComponentBase namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
internal sealed class AssistantDropdown : AssistantComponentBase
{ {
public override AssistantComponentType Type => AssistantComponentType.DROPDOWN; public override AssistantComponentType Type => AssistantComponentType.DROPDOWN;
public Dictionary<string, object> Props { get; set; } = new(); public Dictionary<string, object> Props { get; set; } = new();
public List<IAssistantComponent> Children { get; set; } = new(); public List<IAssistantComponent> Children { get; set; } = new();
public string Name public string Name
{ {
get => this.Props.TryGetValue(nameof(this.Name), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
: string.Empty;
set => this.Props[nameof(this.Name)] = value;
} }
public string Label public string Label
{ {
get => this.Props.TryGetValue(nameof(this.Label), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Label));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Label), value);
: string.Empty;
set => this.Props[nameof(this.Label)] = value;
} }
public string UserPrompt public string UserPrompt
{ {
get => this.Props.TryGetValue(nameof(this.UserPrompt), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.UserPrompt));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.UserPrompt), value);
: string.Empty;
set => this.Props[nameof(this.UserPrompt)] = value;
} }
public AssistantDropdownItem Default public AssistantDropdownItem Default
{ {
get get
@ -40,15 +37,15 @@ public class AssistantDropdown : AssistantComponentBase
} }
set => this.Props[nameof(this.Default)] = value; set => this.Props[nameof(this.Default)] = value;
} }
public List<AssistantDropdownItem> Items public List<AssistantDropdownItem> Items
{ {
get => this.Props.TryGetValue(nameof(this.Items), out var v) && v is List<AssistantDropdownItem> list get => this.Props.TryGetValue(nameof(this.Items), out var v) && v is List<AssistantDropdownItem> list
? list ? list
: []; : [];
set => this.Props[nameof(this.Items)] = value; set => this.Props[nameof(this.Items)] = value;
} }
public string ValueType public string ValueType
{ {
get => this.Props.TryGetValue(nameof(this.ValueType), out var v) get => this.Props.TryGetValue(nameof(this.ValueType), out var v)
@ -56,7 +53,7 @@ public class AssistantDropdown : AssistantComponentBase
: "string"; : "string";
set => this.Props[nameof(this.ValueType)] = value; set => this.Props[nameof(this.ValueType)] = value;
} }
public IEnumerable<object> GetParsedDropdownValues() public IEnumerable<object> GetParsedDropdownValues()
{ {
foreach (var item in this.Items) foreach (var item in this.Items)
@ -78,4 +75,16 @@ public class AssistantDropdown : AssistantComponentBase
} }
} }
} }
}
public string Class
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
}
public string Style
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
}
}

View File

@ -1,6 +1,6 @@
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel; namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
public class AssistantFileContentReader : AssistantComponentBase internal sealed class AssistantFileContentReader : AssistantComponentBase
{ {
public override AssistantComponentType Type => AssistantComponentType.FILE_CONTENT_READER; public override AssistantComponentType Type => AssistantComponentType.FILE_CONTENT_READER;
public Dictionary<string, object> Props { get; set; } = new(); public Dictionary<string, object> Props { get; set; } = new();
@ -8,17 +8,25 @@ public class AssistantFileContentReader : AssistantComponentBase
public string Name public string Name
{ {
get => this.Props.TryGetValue(nameof(this.Name), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
: string.Empty;
set => this.Props[nameof(this.Name)] = value;
} }
public string UserPrompt public string UserPrompt
{ {
get => this.Props.TryGetValue(nameof(this.UserPrompt), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.UserPrompt));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.UserPrompt), value);
: string.Empty; }
set => this.Props[nameof(this.UserPrompt)] = value;
public string Class
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
}
public string Style
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
} }
} }

View File

@ -1,19 +1,17 @@
using System.Collections.Generic;
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel; namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
public class AssistantHeading : AssistantComponentBase internal sealed class AssistantHeading : AssistantComponentBase
{ {
public override AssistantComponentType Type => AssistantComponentType.HEADING; public override AssistantComponentType Type => AssistantComponentType.HEADING;
public Dictionary<string, object> Props { get; set; } = new(); public Dictionary<string, object> Props { get; set; } = new();
public List<IAssistantComponent> Children { get; set; } = new(); public List<IAssistantComponent> Children { get; set; } = new();
public string Text public string Text
{ {
get => this.Props.TryGetValue(nameof(this.Text), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Text));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Text), value);
: string.Empty;
set => this.Props[nameof(this.Text)] = value;
} }
public int Level public int Level
@ -21,7 +19,19 @@ public class AssistantHeading : AssistantComponentBase
get => this.Props.TryGetValue(nameof(this.Level), out var v) get => this.Props.TryGetValue(nameof(this.Level), out var v)
&& int.TryParse(v.ToString(), out var i) && int.TryParse(v.ToString(), out var i)
? i ? i
: 2; : 2;
set => this.Props[nameof(this.Level)] = value; set => this.Props[nameof(this.Level)] = value;
} }
}
public string Class
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
}
public string Style
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
}
}

View File

@ -1,6 +1,8 @@
using System.Collections.Generic;
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel; namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
public class AssistantImage : AssistantComponentBase internal sealed class AssistantImage : AssistantComponentBase
{ {
public override AssistantComponentType Type => AssistantComponentType.IMAGE; public override AssistantComponentType Type => AssistantComponentType.IMAGE;
public Dictionary<string, object> Props { get; set; } = new(); public Dictionary<string, object> Props { get; set; } = new();
@ -8,25 +10,31 @@ public class AssistantImage : AssistantComponentBase
public string Src public string Src
{ {
get => this.Props.TryGetValue(nameof(this.Src), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Src));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Src), value);
: string.Empty;
set => this.Props[nameof(this.Src)] = value;
} }
public string Alt public string Alt
{ {
get => this.Props.TryGetValue(nameof(this.Alt), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Alt));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Alt), value);
: string.Empty;
set => this.Props[nameof(this.Alt)] = value;
} }
public string Caption public string Caption
{ {
get => this.Props.TryGetValue(nameof(this.Caption), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Caption));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Caption), value);
: string.Empty; }
set => this.Props[nameof(this.Caption)] = value;
public string Class
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
}
public string Style
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
} }
} }

View File

@ -1,18 +1,30 @@
using System.Collections.Generic;
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel; namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
public class AssistantList : AssistantComponentBase internal sealed class AssistantList : AssistantComponentBase
{ {
public override AssistantComponentType Type => AssistantComponentType.LIST; public override AssistantComponentType Type => AssistantComponentType.LIST;
public Dictionary<string, object> Props { get; set; } = new(); public Dictionary<string, object> Props { get; set; } = new();
public List<IAssistantComponent> Children { get; set; } = new(); public List<IAssistantComponent> Children { get; set; } = new();
public List<AssistantListItem> Items public List<AssistantListItem> Items
{ {
get => this.Props.TryGetValue(nameof(this.Items), out var v) && v is List<AssistantListItem> list get => this.Props.TryGetValue(nameof(this.Items), out var v) && v is List<AssistantListItem> list
? list ? list
: []; : [];
set => this.Props[nameof(this.Items)] = value; set => this.Props[nameof(this.Items)] = value;
} }
}
public string Class
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
}
public string Style
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
}
}

View File

@ -1,8 +1,8 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel; namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
public class AssistantProfileSelection : AssistantComponentBase internal sealed class AssistantProfileSelection : AssistantComponentBase
{ {
public override AssistantComponentType Type => AssistantComponentType.PROFILE_SELECTION; public override AssistantComponentType Type => AssistantComponentType.PROFILE_SELECTION;
public Dictionary<string, object> Props { get; set; } = new(); public Dictionary<string, object> Props { get; set; } = new();
@ -10,9 +10,19 @@ public class AssistantProfileSelection : AssistantComponentBase
public string ValidationMessage public string ValidationMessage
{ {
get => this.Props.TryGetValue(nameof(this.ValidationMessage), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.ValidationMessage));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.ValidationMessage), value);
: string.Empty; }
set => this.Props[nameof(this.ValidationMessage)] = value;
public string Class
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
}
public string Style
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
} }
} }

View File

@ -1,6 +1,8 @@
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel; using System.Collections.Generic;
public class AssistantProviderSelection : AssistantComponentBase namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
internal sealed class AssistantProviderSelection : AssistantComponentBase
{ {
public override AssistantComponentType Type => AssistantComponentType.PROVIDER_SELECTION; public override AssistantComponentType Type => AssistantComponentType.PROVIDER_SELECTION;
public Dictionary<string, object> Props { get; set; } = new(); public Dictionary<string, object> Props { get; set; } = new();
@ -8,16 +10,25 @@ public class AssistantProviderSelection : AssistantComponentBase
public string Name public string Name
{ {
get => this.Props.TryGetValue(nameof(this.Name), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
: string.Empty;
set => this.Props[nameof(this.Name)] = value;
} }
public string Label public string Label
{ {
get => this.Props.TryGetValue(nameof(this.Label), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Label));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Label), value);
: string.Empty;
set => this.Props[nameof(this.Label)] = value;
} }
}
public string Class
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
}
public string Style
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
}
}

View File

@ -1,6 +1,8 @@
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel; using System.Collections.Generic;
public class AssistantSwitch : AssistantComponentBase namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
internal sealed class AssistantSwitch : AssistantComponentBase
{ {
public override AssistantComponentType Type => AssistantComponentType.SWITCH; public override AssistantComponentType Type => AssistantComponentType.SWITCH;
public Dictionary<string, object> Props { get; set; } = new(); public Dictionary<string, object> Props { get; set; } = new();
@ -8,47 +10,49 @@ public class AssistantSwitch : AssistantComponentBase
public string Name public string Name
{ {
get => this.Props.TryGetValue(nameof(this.Name), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
: string.Empty;
set => this.Props[nameof(this.Name)] = value;
} }
public string Label public string Label
{ {
get => this.Props.TryGetValue(nameof(this.Label), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Label));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Label), value);
: string.Empty;
set => this.Props[nameof(this.Label)] = value;
} }
public bool Value public bool Value
{ {
get => this.Props.TryGetValue(nameof(this.Value), out var val) && val is true; get => this.Props.TryGetValue(nameof(this.Value), out var val) && val is true;
set => this.Props[nameof(this.Value)] = value; set => this.Props[nameof(this.Value)] = value;
} }
public string UserPrompt public string UserPrompt
{ {
get => this.Props.TryGetValue(nameof(this.UserPrompt), out var val) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.UserPrompt));
? val.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.UserPrompt), value);
: string.Empty;
set => this.Props[nameof(this.UserPrompt)] = value;
} }
public string LabelOn public string LabelOn
{ {
get => this.Props.TryGetValue(nameof(this.LabelOn), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.LabelOn));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.LabelOn), value);
: string.Empty;
set => this.Props[nameof(this.LabelOn)] = value;
} }
public string LabelOff public string LabelOff
{ {
get => this.Props.TryGetValue(nameof(this.LabelOff), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.LabelOff));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.LabelOff), value);
: string.Empty;
set => this.Props[nameof(this.LabelOff)] = value;
} }
}
public string Class
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
}
public string Style
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
}
}

View File

@ -1,6 +1,8 @@
using System.Collections.Generic;
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel; namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
public class AssistantText : AssistantComponentBase internal sealed class AssistantText : AssistantComponentBase
{ {
public override AssistantComponentType Type => AssistantComponentType.TEXT; public override AssistantComponentType Type => AssistantComponentType.TEXT;
@ -10,9 +12,19 @@ public class AssistantText : AssistantComponentBase
public string Content public string Content
{ {
get => this.Props.TryGetValue(nameof(this.Content), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Content));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Content), value);
: string.Empty;
set => this.Props[nameof(this.Content)] = value;
} }
}
public string Class
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
}
public string Style
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
}
}

View File

@ -1,52 +1,58 @@
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel; using System.Collections.Generic;
public class AssistantTextArea : AssistantComponentBase namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
internal sealed class AssistantTextArea : AssistantComponentBase
{ {
public override AssistantComponentType Type => AssistantComponentType.TEXT_AREA; public override AssistantComponentType Type => AssistantComponentType.TEXT_AREA;
public Dictionary<string, object> Props { get; set; } = new(); public Dictionary<string, object> Props { get; set; } = new();
public List<IAssistantComponent> Children { get; set; } = new(); public List<IAssistantComponent> Children { get; set; } = new();
public string Name public string Name
{ {
get => this.Props.TryGetValue(nameof(this.Name), out var val) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
? val.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
: string.Empty;
set => this.Props[nameof(this.Name)] = value;
} }
public string Label public string Label
{ {
get => this.Props.TryGetValue(nameof(this.Label), out var val) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Label));
? val.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Label), value);
: string.Empty;
set => this.Props[nameof(this.Label)] = value;
} }
public string UserPrompt public string UserPrompt
{ {
get => this.Props.TryGetValue(nameof(this.UserPrompt), out var val) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.UserPrompt));
? val.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.UserPrompt), value);
: string.Empty;
set => this.Props[nameof(this.UserPrompt)] = value;
} }
public string PrefillText public string PrefillText
{ {
get => this.Props.TryGetValue(nameof(this.PrefillText), out var val) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.PrefillText));
? val.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.PrefillText), value);
: string.Empty;
set => this.Props[nameof(this.PrefillText)] = value;
} }
public bool IsSingleLine public bool IsSingleLine
{ {
get => this.Props.TryGetValue(nameof(this.IsSingleLine), out var val) && val is true; get => this.Props.TryGetValue(nameof(this.IsSingleLine), out var val) && val is true;
set => this.Props[nameof(this.IsSingleLine)] = value; set => this.Props[nameof(this.IsSingleLine)] = value;
} }
public bool ReadOnly public bool ReadOnly
{ {
get => this.Props.TryGetValue(nameof(this.ReadOnly), out var val) && val is true; get => this.Props.TryGetValue(nameof(this.ReadOnly), out var val) && val is true;
set => this.Props[nameof(this.ReadOnly)] = value; set => this.Props[nameof(this.ReadOnly)] = value;
} }
}
public string Class
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
}
public string Style
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
}
}

View File

@ -1,6 +1,8 @@
using System.Collections.Generic;
namespace AIStudio.Tools.PluginSystem.Assistants.DataModel; namespace AIStudio.Tools.PluginSystem.Assistants.DataModel;
public class AssistantWebContentReader : AssistantComponentBase internal sealed class AssistantWebContentReader : AssistantComponentBase
{ {
public override AssistantComponentType Type => AssistantComponentType.WEB_CONTENT_READER; public override AssistantComponentType Type => AssistantComponentType.WEB_CONTENT_READER;
public Dictionary<string, object> Props { get; set; } = new(); public Dictionary<string, object> Props { get; set; } = new();
@ -8,18 +10,14 @@ public class AssistantWebContentReader : AssistantComponentBase
public string Name public string Name
{ {
get => this.Props.TryGetValue(nameof(this.Name), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Name));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Name), value);
: string.Empty;
set => this.Props[nameof(this.Name)] = value;
} }
public string UserPrompt public string UserPrompt
{ {
get => this.Props.TryGetValue(nameof(this.UserPrompt), out var v) get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.UserPrompt));
? v.ToString() ?? string.Empty set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.UserPrompt), value);
: string.Empty;
set => this.Props[nameof(this.UserPrompt)] = value;
} }
public bool Preselect public bool Preselect
@ -33,4 +31,16 @@ public class AssistantWebContentReader : AssistantComponentBase
get => this.Props.TryGetValue(nameof(this.PreselectContentCleanerAgent), out var v) && v is true; get => this.Props.TryGetValue(nameof(this.PreselectContentCleanerAgent), out var v) && v is true;
set => this.Props[nameof(this.PreselectContentCleanerAgent)] = value; set => this.Props[nameof(this.PreselectContentCleanerAgent)] = value;
} }
public string Class
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Class));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Class), value);
}
public string Style
{
get => AssistantComponentPropHelper.ReadString(this.Props, nameof(this.Style));
set => AssistantComponentPropHelper.WriteString(this.Props, nameof(this.Style), value);
}
} }

View File

@ -7,55 +7,55 @@ public static class ComponentPropSpecs
{ {
[AssistantComponentType.FORM] = new( [AssistantComponentType.FORM] = new(
required: ["Children"], required: ["Children"],
optional: [] optional: ["Class", "Style"]
), ),
[AssistantComponentType.TEXT_AREA] = new( [AssistantComponentType.TEXT_AREA] = new(
required: ["Name", "Label"], required: ["Name", "Label"],
optional: ["UserPrompt", "PrefillText", "ReadOnly", "IsSingleLine"] optional: ["UserPrompt", "PrefillText", "ReadOnly", "IsSingleLine", "Class", "Style"]
), ),
[AssistantComponentType.BUTTON] = new( [AssistantComponentType.BUTTON] = new(
required: ["Name", "Text", "Action"], required: ["Name", "Text", "Action"],
optional: [] optional: ["Class", "Style"]
), ),
[AssistantComponentType.DROPDOWN] = new( [AssistantComponentType.DROPDOWN] = new(
required: ["Name", "Label", "Default", "Items"], required: ["Name", "Label", "Default", "Items"],
optional: ["UserPrompt"] optional: ["UserPrompt", "Class", "Style"]
), ),
[AssistantComponentType.PROVIDER_SELECTION] = new( [AssistantComponentType.PROVIDER_SELECTION] = new(
required: ["Name", "Label"], required: ["Name", "Label"],
optional: [] optional: ["Class", "Style"]
), ),
[AssistantComponentType.PROFILE_SELECTION] = new( [AssistantComponentType.PROFILE_SELECTION] = new(
required: [], required: [],
optional: ["ValidationMessage"] optional: ["ValidationMessage", "Class", "Style"]
), ),
[AssistantComponentType.SWITCH] = new( [AssistantComponentType.SWITCH] = new(
required: ["Name", "Label", "LabelOn", "LabelOff", "Value"], required: ["Name", "Label", "LabelOn", "LabelOff", "Value"],
optional: ["UserPrompt"] optional: ["UserPrompt", "Class", "Style"]
), ),
[AssistantComponentType.HEADING] = new( [AssistantComponentType.HEADING] = new(
required: ["Text", "Level"], required: ["Text", "Level"],
optional: [] optional: ["Class", "Style"]
), ),
[AssistantComponentType.TEXT] = new( [AssistantComponentType.TEXT] = new(
required: ["Content"], required: ["Content"],
optional: [] optional: ["Class", "Style"]
), ),
[AssistantComponentType.LIST] = new( [AssistantComponentType.LIST] = new(
required: ["Items"], required: ["Items"],
optional: [] optional: ["Class", "Style"]
), ),
[AssistantComponentType.WEB_CONTENT_READER] = new( [AssistantComponentType.WEB_CONTENT_READER] = new(
required: ["Name"], required: ["Name"],
optional: ["UserPrompt", "Preselect", "PreselectContentCleanerAgent"] optional: ["UserPrompt", "Preselect", "PreselectContentCleanerAgent", "Class", "Style"]
), ),
[AssistantComponentType.FILE_CONTENT_READER] = new( [AssistantComponentType.FILE_CONTENT_READER] = new(
required: ["Name"], required: ["Name"],
optional: ["UserPrompt"] optional: ["UserPrompt", "Class", "Style"]
), ),
[AssistantComponentType.IMAGE] = new( [AssistantComponentType.IMAGE] = new(
required: ["Src"], required: ["Src"],
optional: ["Alt", "Caption"] optional: ["Alt", "Caption", "Class", "Style"]
), ),
}; };
} }