2026-10-03 12:01:42 +02:00
|
|
|
@inherits DComponentBase
|
|
|
|
|
|
|
|
|
|
@* daisyUI Table: https://daisyui.com/components/table/ . ChildContent is the <thead>/<tbody>/<tfoot> markup. Class and
|
|
|
|
|
the other attributes go on the <table>; with Scroll (the default) it sits in an overflow-x-auto div, whose classes
|
2026-10-07 00:20:56 +02:00
|
|
|
are WrapperClass (pinned rows need it to have a height, e.g. h-96); it is marked as a strip that scrolls sideways on
|
|
|
|
|
purpose (data-scroll-x), which the phone tests allow. *@
|
2026-10-03 12:01:42 +02:00
|
|
|
@if (Scroll)
|
|
|
|
|
{
|
2026-10-07 00:20:56 +02:00
|
|
|
<div class="@Cx("overflow-x-auto", WrapperClass)" data-scroll-x>
|
2026-10-03 12:01:42 +02:00
|
|
|
<table @attributes="AdditionalAttributes" class="@CssClass">@ChildContent</table>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
<table @attributes="AdditionalAttributes" class="@CssClass">@ChildContent</table>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
[Parameter] public RenderFragment ChildContent { get; set; }
|
|
|
|
|
[Parameter] public DSize Size { get; set; }
|
|
|
|
|
[Parameter] public bool Zebra { get; set; }
|
|
|
|
|
/// <summary>Sticky thead/tfoot rows while the wrapper scrolls vertically.</summary>
|
|
|
|
|
[Parameter] public bool PinRows { get; set; }
|
|
|
|
|
/// <summary>Sticky <th> columns while the wrapper scrolls horizontally.</summary>
|
|
|
|
|
[Parameter] public bool PinCols { get; set; }
|
|
|
|
|
/// <summary>Wrap the table in an overflow-x-auto div so it scrolls on narrow screens.</summary>
|
|
|
|
|
[Parameter] public bool Scroll { get; set; } = true;
|
|
|
|
|
[Parameter] public string WrapperClass { get; set; }
|
|
|
|
|
|
|
|
|
|
string CssClass => Cx("table", Zebra ? "table-zebra" : null, PinRows ? "table-pin-rows" : null,
|
|
|
|
|
PinCols ? "table-pin-cols" : null, SizeClass, Class);
|
|
|
|
|
|
|
|
|
|
string SizeClass => Size switch
|
|
|
|
|
{
|
|
|
|
|
DSize.Xs => "table-xs",
|
|
|
|
|
DSize.Sm => "table-sm",
|
|
|
|
|
DSize.Lg => "table-lg",
|
|
|
|
|
DSize.Xl => "table-xl",
|
|
|
|
|
_ => null
|
|
|
|
|
};
|
|
|
|
|
}
|