// Copyright (c) MudBlazor 2021
// MudBlazor licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Connected.Utilities;
using Microsoft.AspNetCore.Components;

namespace Connected.Components;

public partial class FooterCell<T> : UIComponent
{
   [CascadingParameter] public DataGrid<T> DataGrid { get; set; }

   [Parameter] public Column<T> Column { get; set; }
   [Parameter] public RenderFragment ChildContent { get; set; }
   [Parameter] public IEnumerable<T> CurrentItems { get; set; }

   private string _classname =>
       new CssBuilder("footer-cell")
           .AddClass(Column?.FooterClass)
           .AddClass(Column?.footerClassname)
           .AddClass(AdditionalClassList)
       .Build();
   private string _style =>
       new StyleBuilder()
           .AddStyle(Column?.FooterStyle)
           .AddStyle("font-weight", "600")
       .Build();

   internal IEnumerable<T> items
   {
      get
      {
         return CurrentItems ?? DataGrid?.CurrentPageItems;
      }
   }
}
