diff --git a/app/MindWork AI Studio/Components/ConfigurationBase.razor b/app/MindWork AI Studio/Components/ConfigurationBase.razor index e69d8059..875a08c7 100644 --- a/app/MindWork AI Studio/Components/ConfigurationBase.razor +++ b/app/MindWork AI Studio/Components/ConfigurationBase.razor @@ -4,12 +4,20 @@ { @if (!this.Disabled() && this.IsLocked()) { - - @this.Body - + + + @* MudTooltip.RootStyle is set as a workaround for issue -> https://github.com/MudBlazor/MudBlazor/issues/10882 *@ + + + + @this.Body + + } else { - @this.Body + + @this.Body + } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ConfigurationBase.razor.cs b/app/MindWork AI Studio/Components/ConfigurationBase.razor.cs index 1f3bc28c..59ef82b2 100644 --- a/app/MindWork AI Studio/Components/ConfigurationBase.razor.cs +++ b/app/MindWork AI Studio/Components/ConfigurationBase.razor.cs @@ -5,7 +5,7 @@ namespace AIStudio.Components; /// /// A base class for configuration options. /// -public partial class ConfigurationBase : MSGComponentBase +public abstract partial class ConfigurationBase : MSGComponentBase { /// /// The description of the option, i.e., the name. Should be @@ -31,12 +31,37 @@ public partial class ConfigurationBase : MSGComponentBase /// [Parameter] public Func IsLocked { get; set; } = () => false; + + /// + /// Should the option be stretched to fill the available space? + /// + protected abstract bool Stretch { get; } + + /// + /// The CSS class to apply to the component. + /// + protected virtual string GetClassForBase => string.Empty; + + /// + /// The visual variant of the option. + /// + protected virtual Variant Variant => Variant.Text; + + /// + /// The label to display for the option. + /// + protected virtual string Label => string.Empty; + + private StretchItems StretchItems => this.Stretch ? StretchItems.End : StretchItems.None; protected bool IsDisabled => this.Disabled() || this.IsLocked(); - private protected virtual RenderFragment? Body => null; + private string Classes => $"{this.GetClassForBase} {MARGIN_CLASS}"; + + private protected virtual RenderFragment? Body => null; + + private const string MARGIN_CLASS = "mb-6"; - protected const string MARGIN_CLASS = "mb-6"; protected static readonly Dictionary SPELLCHECK_ATTRIBUTES = new(); #region Overrides of ComponentBase diff --git a/app/MindWork AI Studio/Components/ConfigurationMinConfidenceSelection.razor b/app/MindWork AI Studio/Components/ConfigurationMinConfidenceSelection.razor index b3eacda2..93a47e8b 100644 --- a/app/MindWork AI Studio/Components/ConfigurationMinConfidenceSelection.razor +++ b/app/MindWork AI Studio/Components/ConfigurationMinConfidenceSelection.razor @@ -1,3 +1,3 @@ @using AIStudio.Settings -@inherits ConfigurationBaseCore - \ No newline at end of file +@inherits MSGComponentBase + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ConfigurationMinConfidenceSelection.razor.cs b/app/MindWork AI Studio/Components/ConfigurationMinConfidenceSelection.razor.cs index 0cff7228..b5d130c8 100644 --- a/app/MindWork AI Studio/Components/ConfigurationMinConfidenceSelection.razor.cs +++ b/app/MindWork AI Studio/Components/ConfigurationMinConfidenceSelection.razor.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Components; namespace AIStudio.Components; -public partial class ConfigurationMinConfidenceSelection : ConfigurationBaseCore +public partial class ConfigurationMinConfidenceSelection : MSGComponentBase { /// /// The selected value. @@ -23,6 +23,12 @@ public partial class ConfigurationMinConfidenceSelection : ConfigurationBaseCore /// [Parameter] public bool RestrictToGlobalMinimumConfidence { get; set; } + + [Parameter] + public Func Disabled { get; set; } = () => false; + + [Parameter] + public Func IsLocked { get; set; } = () => false; private ConfidenceLevel FilteredSelectedValue() { diff --git a/app/MindWork AI Studio/Components/ConfigurationMultiSelect.razor b/app/MindWork AI Studio/Components/ConfigurationMultiSelect.razor index 1c4c3e0c..6d9d7b89 100644 --- a/app/MindWork AI Studio/Components/ConfigurationMultiSelect.razor +++ b/app/MindWork AI Studio/Components/ConfigurationMultiSelect.razor @@ -9,10 +9,8 @@ Strict="@true" Disabled="@this.IsDisabled" Margin="Margin.Dense" - Label="@this.OptionDescription" - Class="@GetClass" - Variant="Variant.Outlined" - HelperText="@this.OptionHelp" + Class="rounded-lg" + Underline="false" SelectedValuesChanged="@this.OptionChanged"> @foreach (var data in this.Data) { diff --git a/app/MindWork AI Studio/Components/ConfigurationMultiSelect.razor.cs b/app/MindWork AI Studio/Components/ConfigurationMultiSelect.razor.cs index 5c9d31ff..f2e5ed51 100644 --- a/app/MindWork AI Studio/Components/ConfigurationMultiSelect.razor.cs +++ b/app/MindWork AI Studio/Components/ConfigurationMultiSelect.razor.cs @@ -28,6 +28,17 @@ public partial class ConfigurationMultiSelect : ConfigurationBaseCore [Parameter] public Action> SelectionUpdate { get; set; } = _ => { }; + #region Overrides of ConfigurationBase + + /// + protected override bool Stretch => true; + + protected override Variant Variant => Variant.Outlined; + + protected override string Label => this.OptionDescription; + + #endregion + private async Task OptionChanged(IEnumerable? updatedValues) { if(updatedValues is null) @@ -39,8 +50,6 @@ public partial class ConfigurationMultiSelect : ConfigurationBaseCore await this.InformAboutChange(); } - private static string GetClass => $"{MARGIN_CLASS} rounded-lg"; - private string GetMultiSelectionText(List? selectedValues) { if(selectedValues is null || selectedValues.Count == 0) diff --git a/app/MindWork AI Studio/Components/ConfigurationOption.razor b/app/MindWork AI Studio/Components/ConfigurationOption.razor index ea5bfafd..a2ad673e 100644 --- a/app/MindWork AI Studio/Components/ConfigurationOption.razor +++ b/app/MindWork AI Studio/Components/ConfigurationOption.razor @@ -1,7 +1,5 @@ @inherits ConfigurationBaseCore - - - @(this.State() ? this.LabelOn : this.LabelOff) - - \ No newline at end of file + + @(this.State() ? this.LabelOn : this.LabelOff) + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ConfigurationOption.razor.cs b/app/MindWork AI Studio/Components/ConfigurationOption.razor.cs index 081d72db..bbd0da1a 100644 --- a/app/MindWork AI Studio/Components/ConfigurationOption.razor.cs +++ b/app/MindWork AI Studio/Components/ConfigurationOption.razor.cs @@ -31,6 +31,19 @@ public partial class ConfigurationOption : ConfigurationBaseCore [Parameter] public Action StateUpdate { get; set; } = _ => { }; + #region Overrides of ConfigurationBase + + /// + protected override bool Stretch => true; + + /// + protected override Variant Variant => Variant.Outlined; + + /// + protected override string Label => this.OptionDescription; + + #endregion + private async Task OptionChanged(bool updatedState) { this.StateUpdate(updatedState); diff --git a/app/MindWork AI Studio/Components/ConfigurationProviderSelection.razor b/app/MindWork AI Studio/Components/ConfigurationProviderSelection.razor index 6118201f..be6a93cd 100644 --- a/app/MindWork AI Studio/Components/ConfigurationProviderSelection.razor +++ b/app/MindWork AI Studio/Components/ConfigurationProviderSelection.razor @@ -1,2 +1,2 @@ -@inherits ConfigurationBaseCore - \ No newline at end of file +@inherits MSGComponentBase + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ConfigurationProviderSelection.razor.cs b/app/MindWork AI Studio/Components/ConfigurationProviderSelection.razor.cs index 8c392b18..8eced0f2 100644 --- a/app/MindWork AI Studio/Components/ConfigurationProviderSelection.razor.cs +++ b/app/MindWork AI Studio/Components/ConfigurationProviderSelection.razor.cs @@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Components; namespace AIStudio.Components; -public partial class ConfigurationProviderSelection : ConfigurationBaseCore +public partial class ConfigurationProviderSelection : MSGComponentBase { private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(ConfigurationProviderSelection).Namespace, nameof(ConfigurationProviderSelection)); @@ -26,6 +26,12 @@ public partial class ConfigurationProviderSelection : ConfigurationBaseCore [Parameter] public Tools.Components Component { get; set; } = Tools.Components.NONE; + [Parameter] + public Func Disabled { get; set; } = () => false; + + [Parameter] + public Func IsLocked { get; set; } = () => false; + [SuppressMessage("Usage", "MWAIS0001:Direct access to `Providers` is not allowed")] private IEnumerable> FilteredData() { diff --git a/app/MindWork AI Studio/Components/ConfigurationSelect.razor b/app/MindWork AI Studio/Components/ConfigurationSelect.razor index a679752d..c3459101 100644 --- a/app/MindWork AI Studio/Components/ConfigurationSelect.razor +++ b/app/MindWork AI Studio/Components/ConfigurationSelect.razor @@ -1,7 +1,7 @@ @inherits ConfigurationBaseCore @typeparam TConfig - + @foreach (var data in this.Data) { diff --git a/app/MindWork AI Studio/Components/ConfigurationSelect.razor.cs b/app/MindWork AI Studio/Components/ConfigurationSelect.razor.cs index 47ab55bc..14c73eea 100644 --- a/app/MindWork AI Studio/Components/ConfigurationSelect.razor.cs +++ b/app/MindWork AI Studio/Components/ConfigurationSelect.razor.cs @@ -28,12 +28,22 @@ public partial class ConfigurationSelect : ConfigurationBaseCore [Parameter] public Action SelectionUpdate { get; set; } = _ => { }; + #region Overrides of ConfigurationBase + + /// + protected override bool Stretch => true; + + /// + protected override string Label => this.OptionDescription; + + protected override Variant Variant => Variant.Outlined; + + #endregion + private async Task OptionChanged(TConfig updatedValue) { this.SelectionUpdate(updatedValue); await this.SettingsManager.StoreSettings(); await this.InformAboutChange(); } - - private static string GetClass => $"{MARGIN_CLASS} rounded-lg"; } \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ConfigurationSlider.razor b/app/MindWork AI Studio/Components/ConfigurationSlider.razor index eded0922..b04b511d 100644 --- a/app/MindWork AI Studio/Components/ConfigurationSlider.razor +++ b/app/MindWork AI Studio/Components/ConfigurationSlider.razor @@ -1,8 +1,6 @@ @typeparam T @inherits ConfigurationBaseCore - - - @this.Value() @this.Unit - - \ No newline at end of file + + @this.Value() @this.Unit + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ConfigurationSlider.razor.cs b/app/MindWork AI Studio/Components/ConfigurationSlider.razor.cs index 750182fe..429119e1 100644 --- a/app/MindWork AI Studio/Components/ConfigurationSlider.razor.cs +++ b/app/MindWork AI Studio/Components/ConfigurationSlider.razor.cs @@ -42,6 +42,18 @@ public partial class ConfigurationSlider : ConfigurationBaseCore where T : st [Parameter] public Action ValueUpdate { get; set; } = _ => { }; + #region Overrides of ConfigurationBase + + /// + protected override bool Stretch => true; + + /// + protected override Variant Variant => Variant.Outlined; + + protected override string Label => this.OptionDescription; + + #endregion + #region Overrides of ComponentBase protected override async Task OnInitializedAsync() diff --git a/app/MindWork AI Studio/Components/ConfigurationText.razor b/app/MindWork AI Studio/Components/ConfigurationText.razor index b835cd77..80ec63ae 100644 --- a/app/MindWork AI Studio/Components/ConfigurationText.razor +++ b/app/MindWork AI Studio/Components/ConfigurationText.razor @@ -4,9 +4,7 @@ T="string" Text="@this.Text()" TextChanged="@this.InternalUpdate" - Label="@this.OptionDescription" Disabled="@this.IsDisabled" - Class="@MARGIN_CLASS" Adornment="Adornment.Start" AdornmentIcon="@this.Icon" AdornmentColor="@this.IconColor" @@ -15,5 +13,5 @@ AutoGrow="@this.AutoGrow" MaxLines="@this.GetMaxLines" Immediate="@true" - Variant="Variant.Outlined" + Underline="false" /> \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ConfigurationText.razor.cs b/app/MindWork AI Studio/Components/ConfigurationText.razor.cs index 686ea782..7bcce41e 100644 --- a/app/MindWork AI Studio/Components/ConfigurationText.razor.cs +++ b/app/MindWork AI Studio/Components/ConfigurationText.razor.cs @@ -47,6 +47,17 @@ public partial class ConfigurationText : ConfigurationBaseCore { AutoReset = false }; + + #region Overrides of ConfigurationBase + + /// + protected override bool Stretch => true; + + protected override Variant Variant => Variant.Outlined; + + protected override string Label => this.OptionDescription; + + #endregion #region Overrides of ConfigurationBase diff --git a/app/MindWork AI Studio/Components/LockableButton.razor b/app/MindWork AI Studio/Components/LockableButton.razor index 81f964cc..825c5a62 100644 --- a/app/MindWork AI Studio/Components/LockableButton.razor +++ b/app/MindWork AI Studio/Components/LockableButton.razor @@ -1,5 +1,5 @@ @inherits ConfigurationBaseCore - + @this.Text \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/LockableButton.razor.cs b/app/MindWork AI Studio/Components/LockableButton.razor.cs index fe3c0f45..cbfbd910 100644 --- a/app/MindWork AI Studio/Components/LockableButton.razor.cs +++ b/app/MindWork AI Studio/Components/LockableButton.razor.cs @@ -16,6 +16,18 @@ public partial class LockableButton : ConfigurationBaseCore [Parameter] public string Text { get; set; } = string.Empty; + [Parameter] + public string Class { get; set; } = string.Empty; + + #region Overrides of ConfigurationBase + + /// + protected override bool Stretch => false; + + protected override string GetClassForBase => this.Class; + + #endregion + private async Task ClickAsync() { if (this.IsLocked() || this.Disabled()) diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelProviders.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelProviders.razor index 8a8c1de9..616149d0 100644 --- a/app/MindWork AI Studio/Components/Settings/SettingsPanelProviders.razor +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelProviders.razor @@ -75,7 +75,7 @@ } - + @T("LLM Provider Confidence")