|
5 | 5 | PagedNodesResult pagedNodes = GetPagedNodes(); |
6 | 6 | } |
7 | 7 |
|
8 | | -<div class="fancy-table-topbar d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2"> |
9 | | - <div class="d-flex flex-wrap align-items-center gap-2"> |
10 | | - @if (TreeActionsTemplate is not null) |
11 | | - { |
12 | | - @TreeActionsTemplate(TreeContext) |
13 | | - } |
14 | | - |
15 | | - @if (ShouldRenderPageSizeSelector) |
16 | | - { |
17 | | - <div class="fancy-page-size"> |
18 | | - @if (PageSizeTemplate is not null) |
19 | | - { |
20 | | - @PageSizeTemplate(pagedNodes.Context) |
21 | | - } |
22 | | - else |
23 | | - { |
24 | | - <label class="d-inline-flex align-items-center gap-2 small text-muted"> |
25 | | - <span>Rows per page</span> |
26 | | - <select class="form-select form-select-sm w-auto" value="@PaginationPageSize" @onchange="OnPageSizeChanged"> |
27 | | - @foreach (int option in EffectivePageSizeOptions) |
28 | | - { |
29 | | - <option value="@option">@(option == 0 ? "All" : option.ToString())</option> |
30 | | - } |
31 | | - </select> |
32 | | - </label> |
33 | | - } |
34 | | - </div> |
35 | | - } |
36 | | - </div> |
| 8 | +<div class="@GetTopBarClass()"> |
| 9 | + @if (ShouldRenderPageSizeSelector) |
| 10 | + { |
| 11 | + <div class="@GetPageSizeContainerClass()"> |
| 12 | + @if (PageSizeTemplate is not null) |
| 13 | + { |
| 14 | + @PageSizeTemplate(pagedNodes.Context) |
| 15 | + } |
| 16 | + else |
| 17 | + { |
| 18 | + <label class="d-inline-flex align-items-center gap-2 small text-muted"> |
| 19 | + <span>Rows per page</span> |
| 20 | + <select class="form-select form-select-sm w-auto" value="@PaginationPageSize" @onchange="OnPageSizeChanged"> |
| 21 | + @foreach (int option in EffectivePageSizeOptions) |
| 22 | + { |
| 23 | + <option value="@option">@(option == 0 ? "All" : option.ToString())</option> |
| 24 | + } |
| 25 | + </select> |
| 26 | + </label> |
| 27 | + } |
| 28 | + </div> |
| 29 | + } |
37 | 30 |
|
38 | 31 | @if (ToolbarTemplate is not null) |
39 | 32 | { |
40 | | - @ToolbarTemplate |
| 33 | + <div class="@GetToolbarContainerClass()"> |
| 34 | + @ToolbarTemplate |
| 35 | + </div> |
41 | 36 | } |
42 | 37 | else |
43 | 38 | { |
44 | | - <div class="d-flex ms-auto"> |
| 39 | + <div class="@GetToolbarContainerClass()"> |
45 | 40 | <input class="form-control form-control-md" placeholder="@SearchPlaceholder" value="@SearchText" @oninput="OnSearchInput" @onkeyup="HandleSearchKeyPress" /> |
46 | 41 |
|
47 | 42 | @if (string.IsNullOrWhiteSpace(SearchText)) |
|
60 | 55 | } |
61 | 56 | </div> |
62 | 57 |
|
| 58 | +@if (TreeActionsTemplate is not null) |
| 59 | +{ |
| 60 | + <div class="@GetTreeActionsContainerClass()"> |
| 61 | + @TreeActionsTemplate(TreeContext) |
| 62 | + </div> |
| 63 | +} |
| 64 | + |
63 | 65 | <div class="tree-table-container"> |
64 | 66 | <table class="tree-table"> |
65 | 67 | <thead> |
|
126 | 128 |
|
127 | 129 | @if (ShouldRenderPaginationFooter(pagedNodes.Context)) |
128 | 130 | { |
129 | | - <div class="fancy-pagination d-flex flex-wrap align-items-center justify-content-between gap-2 mt-3"> |
| 131 | + <div class="@GetPaginationContainerClass()"> |
130 | 132 | @if (PaginationTemplate is not null) |
131 | 133 | { |
132 | 134 | @PaginationTemplate(pagedNodes.Context) |
133 | 135 | } |
134 | 136 | else |
135 | 137 | { |
136 | | - <div class="fancy-pagination-summary text-muted small"> |
| 138 | + <div class="@GetPaginationSummaryClass()"> |
137 | 139 | @if (PaginationSummaryTemplate is not null) |
138 | 140 | { |
139 | 141 | @PaginationSummaryTemplate(pagedNodes.Context) |
|
254 | 256 | [Parameter] |
255 | 257 | public RenderFragment<FancyTreeTableContext<TItem>>? TreeActionsTemplate { get; set; } |
256 | 258 |
|
| 259 | + [Parameter] |
| 260 | + public string? TopBarClass { get; set; } |
| 261 | + |
| 262 | + [Parameter] |
| 263 | + public string? ToolbarContainerClass { get; set; } |
| 264 | + |
| 265 | + [Parameter] |
| 266 | + public string? PageSizeContainerClass { get; set; } |
| 267 | + |
| 268 | + [Parameter] |
| 269 | + public string? TreeActionsContainerClass { get; set; } |
| 270 | + |
| 271 | + [Parameter] |
| 272 | + public string? PaginationContainerClass { get; set; } |
| 273 | + |
| 274 | + [Parameter] |
| 275 | + public string? PaginationSummaryClass { get; set; } |
| 276 | + |
257 | 277 | private readonly HashSet<string> HiddenColumns = new(StringComparer.Ordinal); |
258 | 278 | private readonly Dictionary<TItem, bool> ExpandedStates = new(); |
259 | 279 | private readonly List<TreeNodeState<TItem>> RootNodes = []; |
|
744 | 764 | return Enumerable.Range(startPage, endPage - startPage + 1).ToList(); |
745 | 765 | } |
746 | 766 |
|
| 767 | + private string GetTopBarClass() => CombineClasses("fancy-table-topbar d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2", TopBarClass); |
| 768 | + |
| 769 | + private string GetToolbarContainerClass() => CombineClasses("d-flex ms-auto", ToolbarContainerClass); |
| 770 | + |
| 771 | + private string GetPageSizeContainerClass() => CombineClasses("fancy-page-size", PageSizeContainerClass); |
| 772 | + |
| 773 | + private string GetTreeActionsContainerClass() => CombineClasses("fancy-tree-actions", TreeActionsContainerClass); |
| 774 | + |
| 775 | + private string GetPaginationContainerClass() => CombineClasses("fancy-pagination d-flex flex-wrap align-items-center justify-content-between gap-2 mt-3", PaginationContainerClass); |
| 776 | + |
| 777 | + private string GetPaginationSummaryClass() => CombineClasses("fancy-pagination-summary text-muted small", PaginationSummaryClass); |
| 778 | + |
| 779 | + private static string CombineClasses(string baseClass, string? additionalClass) => |
| 780 | + string.IsNullOrWhiteSpace(additionalClass) ? baseClass : $"{baseClass} {additionalClass}"; |
| 781 | + |
747 | 782 | private sealed class PagedNodesResult |
748 | 783 | { |
749 | 784 | public required IReadOnlyList<TreeNodeState<TItem>> Items { get; init; } |
|
0 commit comments