1- using System ;
2- using System . Threading . Tasks ;
31using Microsoft . AspNetCore . Components ;
42using Radzen . Blazor . Rendering ;
3+ using System ;
4+ using System . Collections . Generic ;
5+ using System . Collections . ObjectModel ;
6+ using System . Threading . Tasks ;
57namespace Radzen . Blazor ;
68
79#nullable enable
@@ -11,6 +13,15 @@ namespace Radzen.Blazor;
1113/// </summary>
1214public partial class RadzenTocItem : ComponentBase , IAsyncDisposable
1315{
16+ /// <summary>
17+ /// Gets or sets a dictionary of additional HTML attributes that will be applied to the component's root element.
18+ /// Any attributes not explicitly defined as parameters will be captured here and rendered on the element.
19+ /// Use this to add data-* attributes, ARIA attributes, or any custom HTML attributes.
20+ /// </summary>
21+ /// <value>The unmatched attributes dictionary.</value>
22+ [ Parameter ( CaptureUnmatchedValues = true ) ]
23+ public IReadOnlyDictionary < string , object > Attributes { get ; set ; } = new ReadOnlyDictionary < string , object > ( new Dictionary < string , object > ( ) ) ;
24+
1425 /// <summary>
1526 /// Gets or sets the child content.
1627 /// </summary>
@@ -43,10 +54,26 @@ public partial class RadzenTocItem : ComponentBase, IAsyncDisposable
4354
4455 private bool selected ;
4556
46- private string Class => ClassList . Create ( "rz-toc-item" )
57+ /// <summary>
58+ /// Gets the final CSS class rendered by the component. Combines it with a <c>class</c> custom attribute.
59+ /// </summary>
60+ protected string GetCssClass ( )
61+ {
62+ if ( Attributes != null && Attributes . TryGetValue ( "class" , out var @class ) && ! string . IsNullOrEmpty ( Convert . ToString ( @class ) ) )
63+ {
64+ return $ "{ GetComponentCssClass ( ) } { @class } ";
65+ }
66+
67+ return GetComponentCssClass ( ) ;
68+ }
69+
70+ /// <summary>
71+ /// Gets the component CSS class.
72+ /// </summary>
73+ protected string GetComponentCssClass ( ) => ClassList . Create ( "rz-toc-item" )
4774 . Add ( "rz-toc-item-selected" , selected )
4875 . ToString ( ) ;
49-
76+
5077 private string WrapperClass => ClassList . Create ( "rz-toc-item-wrapper" )
5178 . Add ( Level switch
5279 {
@@ -59,7 +86,7 @@ public partial class RadzenTocItem : ComponentBase, IAsyncDisposable
5986
6087 private string LinkClass => ClassList . Create ( "rz-toc-link" )
6188 . ToString ( ) ;
62-
89+
6390 internal void Activate ( )
6491 {
6592 selected = true ;
0 commit comments