|
| 1 | +@* Citation table component — matches Python render_html_table() styling *@ |
| 2 | + |
| 3 | +@if (_sections.Count > 0) |
| 4 | +{ |
| 5 | + <MudDivider Class="my-3" /> |
| 6 | + <MudText Typo="Typo.h6" Class="mb-2">Citations</MudText> |
| 7 | + |
| 8 | + @foreach (var citationGroup in _sections) |
| 9 | + { |
| 10 | + <MudText Typo="Typo.body2" Class="mb-1"> |
| 11 | + <b>@citationGroup.Label (@citationGroup.Items.Count):</b> |
| 12 | + </MudText> |
| 13 | + <div class="citation-table-container mb-3"> |
| 14 | + <table class="citation-table"> |
| 15 | + <thead> |
| 16 | + <tr> |
| 17 | + @foreach (var header in citationGroup.Headers) |
| 18 | + { |
| 19 | + <th>@header</th> |
| 20 | + } |
| 21 | + </tr> |
| 22 | + </thead> |
| 23 | + <tbody> |
| 24 | + @foreach (var row in citationGroup.Items) |
| 25 | + { |
| 26 | + <tr id="@row.AnchorId"> |
| 27 | + @foreach (var cell in row.Cells) |
| 28 | + { |
| 29 | + <td title="@cell">@Truncate(cell, ShortWords)</td> |
| 30 | + } |
| 31 | + </tr> |
| 32 | + } |
| 33 | + </tbody> |
| 34 | + </table> |
| 35 | + </div> |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +@code { |
| 40 | + private const int ShortWords = 12; |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Gets or sets the context data from search results. |
| 44 | + /// </summary> |
| 45 | + [Parameter] |
| 46 | + public object? ContextData { get; set; } |
| 47 | + |
| 48 | + /// <summary> |
| 49 | + /// Gets or sets the search type for context-specific rendering. |
| 50 | + /// </summary> |
| 51 | + [Parameter] |
| 52 | + public SearchType SearchType { get; set; } |
| 53 | + |
| 54 | + private List<CitationSection> _sections = []; |
| 55 | + |
| 56 | + /// <inheritdoc /> |
| 57 | + protected override void OnParametersSet() |
| 58 | + { |
| 59 | + _sections = ParseContextData(); |
| 60 | + } |
| 61 | + |
| 62 | + private List<CitationSection> ParseContextData() |
| 63 | + { |
| 64 | + // Placeholder — in full implementation, parses ContextData dict |
| 65 | + // from search results into structured citation sections |
| 66 | + return []; |
| 67 | + } |
| 68 | + |
| 69 | + private static string Truncate(string text, int maxWords) |
| 70 | + { |
| 71 | + if (string.IsNullOrEmpty(text)) |
| 72 | + { |
| 73 | + return string.Empty; |
| 74 | + } |
| 75 | + |
| 76 | + var words = text.Split(' '); |
| 77 | + if (words.Length <= maxWords) |
| 78 | + { |
| 79 | + return text; |
| 80 | + } |
| 81 | + |
| 82 | + return string.Join(' ', words.Take(maxWords)) + "..."; |
| 83 | + } |
| 84 | + |
| 85 | + private sealed record CitationSection(string Label, string[] Headers, List<CitationRow> Items); |
| 86 | + |
| 87 | + private sealed record CitationRow(string AnchorId, string[] Cells); |
| 88 | +} |
0 commit comments