@code {
    [Parameter, Required] public IGrouping<FeDisc, FeTrack> DataSource { get; set; }
    [Parameter, Required] public string SearchName { get; set; }
    [Parameter, Required] public string SearchArtist { get; set; }

    private DiscDialog dlgDisc;
}

<DiscDialog @ref="dlgDisc" Disc="CurrentDisc"></DiscDialog>

<div class="table-responsive">
    <table class="table w-100">
        <tbody>
            <tr class="table-primary">
                <td><img src="@DataSource.Key.CoverPath" style="height:50px" /></td>
                <td colspan="2" class="w-100">
                    <div class="text-nowrap">@DataSource.Key.Name</div>
                    <div class="text-nowrap text-muted">@DataSource.Key.Lib.Name</div>
                </td>
                <td colspan="2" class="text-end">
                    <button class="btn btn-primary" @onclick="()=>dlgDisc.Show(DataSource.Key)">
                        <i class="bi bi-window-stack"></i>
                    </button>
                </td>
            </tr>

            @foreach (var tr in DataSource.OrderBy(p => p.Name))
            {
                <tr class="mouse-hilight">
                    <td class="align-middle"><FileIcon Track="@tr" ShowParam="true"></FileIcon></td>
                    <td class="w-100 text-nowrap">
                        <div>
                            <a @onclick="() => App.Instance.PlayTrack(tr)" @onclick:preventDefault href="@tr.Path" target="@FnzConst.PlayPageTarget">
                                <HighLightKeyword Text="@tr.GetTitleOrFilename()" Keywords="@(new []{ SearchName})"></HighLightKeyword>
                            </a>
                        </div>
                        <div class="text-nowrap text-muted">
                            <HighLightKeyword Text="@tr.Tag?.Artist" Keywords="@(new []{ SearchArtist})" MatchedClass="text-warning"></HighLightKeyword>
                        </div>
                    </td>
                    <td>
                        <div class="text-nowrap">@tr.Tag.Duration.SecondToDur()</div>
                        <div class="text-nowrap text-muted">@tr.Tag.Length.BytesToFileSize()</div>
                    </td>
                    <td class="text-center align-middle">
                        <button type="button" class="btn btn-link" style="padding:0.1rem" @onclick="() => App.Instance.ShowAddTrackToPlaylistDialog(tr)">
                            <i class="bi bi-folder-plus"></i>
                        </button>
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>
