2024-08-21 06:30:01 +00:00
|
|
|
using AIStudio.Layout;
|
2024-06-30 13:26:28 +00:00
|
|
|
|
2024-06-01 18:32:30 +00:00
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
2024-08-21 06:30:01 +00:00
|
|
|
namespace AIStudio.Components;
|
2024-06-01 18:32:30 +00:00
|
|
|
|
2024-06-30 13:26:28 +00:00
|
|
|
public partial class InnerScrolling : MSGComponentBase
|
2024-06-01 18:32:30 +00:00
|
|
|
{
|
2024-11-02 21:53:02 +00:00
|
|
|
[Parameter]
|
|
|
|
public bool FillEntireHorizontalSpace { get; set; }
|
|
|
|
|
2024-06-01 18:32:30 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Set the height of anything above the scrolling content; usually a header.
|
2024-06-30 13:26:28 +00:00
|
|
|
/// What we do is calc(100vh - HeaderHeight). Means, you can use multiple measures like
|
2024-06-01 18:32:30 +00:00
|
|
|
/// 230px - 3em. Default is 3em.
|
|
|
|
/// </summary>
|
|
|
|
[Parameter]
|
|
|
|
public string HeaderHeight { get; set; } = "3em";
|
|
|
|
|
2024-11-02 21:53:02 +00:00
|
|
|
[Parameter]
|
|
|
|
public RenderFragment? HeaderContent { get; set; }
|
|
|
|
|
2024-06-01 18:32:30 +00:00
|
|
|
[Parameter]
|
|
|
|
public RenderFragment? ChildContent { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Optional footer content, shown after the scrolling area.
|
|
|
|
/// </summary>
|
|
|
|
[Parameter]
|
|
|
|
public RenderFragment? FooterContent { get; set; }
|
2024-11-02 21:53:02 +00:00
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
public string Class { get; set; } = string.Empty;
|
2024-06-01 18:32:30 +00:00
|
|
|
|
2025-01-02 12:16:47 +00:00
|
|
|
[Parameter]
|
|
|
|
public string? MinWidth { get; set; }
|
|
|
|
|
2024-06-30 13:26:28 +00:00
|
|
|
[CascadingParameter]
|
|
|
|
private MainLayout MainLayout { get; set; } = null!;
|
2024-08-23 08:32:27 +00:00
|
|
|
|
|
|
|
[Inject]
|
|
|
|
private IJSRuntime JsRuntime { get; init; } = null!;
|
|
|
|
|
|
|
|
private ElementReference AnchorAfterChildContent { get; set; }
|
2024-06-30 13:26:28 +00:00
|
|
|
|
|
|
|
#region Overrides of ComponentBase
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
{
|
|
|
|
this.ApplyFilters([], [ Event.STATE_HAS_CHANGED ]);
|
|
|
|
await base.OnInitializedAsync();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Overrides of MSGComponentBase
|
|
|
|
|
2024-09-15 10:30:07 +00:00
|
|
|
public override Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
|
2024-06-30 13:26:28 +00:00
|
|
|
{
|
|
|
|
switch (triggeredEvent)
|
|
|
|
{
|
|
|
|
case Event.STATE_HAS_CHANGED:
|
|
|
|
this.StateHasChanged();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
}
|
|
|
|
|
2024-07-13 08:37:57 +00:00
|
|
|
public override Task<TResult?> ProcessMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data) where TResult : default where TPayload : default
|
|
|
|
{
|
|
|
|
return Task.FromResult(default(TResult));
|
|
|
|
}
|
|
|
|
|
2024-06-30 13:26:28 +00:00
|
|
|
#endregion
|
|
|
|
|
2025-01-02 12:16:47 +00:00
|
|
|
private string MinWidthStyle => string.IsNullOrWhiteSpace(this.MinWidth) ? string.Empty : $"min-width: {this.MinWidth};";
|
|
|
|
|
|
|
|
private string Styles => this.FillEntireHorizontalSpace ? $"height: calc(100vh - {this.HeaderHeight} - {this.MainLayout.AdditionalHeight}); overflow-x: auto; min-width: 0; {this.MinWidthStyle}" : $"height: calc(100vh - {this.HeaderHeight} - {this.MainLayout.AdditionalHeight}); flex-shrink: 0; {this.MinWidthStyle}";
|
2024-11-02 21:53:02 +00:00
|
|
|
|
|
|
|
private string Classes => this.FillEntireHorizontalSpace ? $"{this.Class} d-flex flex-column flex-grow-1" : $"{this.Class} d-flex flex-column";
|
2024-08-23 08:32:27 +00:00
|
|
|
|
|
|
|
public async Task ScrollToBottom()
|
|
|
|
{
|
|
|
|
await this.AnchorAfterChildContent.ScrollIntoViewAsync(this.JsRuntime);
|
|
|
|
}
|
2024-06-01 18:32:30 +00:00
|
|
|
}
|