Skip to content

Commit f52ed89

Browse files
authored
Add versioning and docs attributes to Tabs and Tab components (#1229)
- Added [AddedVersion], [DefaultValue], and [Description] attributes to all public parameters, properties, and events in Tab and Tabs components for improved API documentation and version tracking. - Updated Tab parameters (Content, Name, Title, TitleTemplate) to be nullable and removed default values; Content is no longer [EditorRequired]. - Enhanced Tabs methods and event callbacks with documentation attributes. - Updated documentation to include "TabsEventArgs Properties" and "TabEventArgs Properties" sections. - Added documentation attributes to TabEventArgs and TabsEventArgs properties. - Adjusted EnumExtensions default cases to return null! and updated comments for consistency.
1 parent 0fd9c01 commit f52ed89

File tree

6 files changed

+112
-36
lines changed

6 files changed

+112
-36
lines changed

BlazorBootstrap.Demo.RCL/Components/Pages/Docs/Tabs/Tabs_Doc_01_Documentation.razor

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
<DocxTable TItem="Tabs" DocType="DocType.Events" />
2727
</Section>
2828

29+
<Section Class="p-0" Size="HeadingSize.H3" Name="TabsEventArgs Properties" PageUrl="@pageUrl" Link="tabs-event-args-properties">
30+
<DocxTable TItem="TabsEventArgs" DocType="DocType.Properties" />
31+
</Section>
32+
2933
<Section Class="p-0" Size="HeadingSize.H3" Name="Tab Parameters" PageUrl="@pageUrl" Link="tab-parameters">
3034
<DocxTable TItem="Tab" DocType="DocType.Parameters" />
3135
</Section>
@@ -34,6 +38,10 @@
3438
<DocxTable TItem="Tab" DocType="DocType.Events" />
3539
</Section>
3640

41+
<Section Class="p-0" Size="HeadingSize.H3" Name="TabEventArgs Properties" PageUrl="@pageUrl" Link="tab-event-args-properties">
42+
<DocxTable TItem="TabEventArgs" DocType="DocType.Properties" />
43+
</Section>
44+
3745
@code {
3846
private const string componentName = nameof(Tabs);
3947
private const string pageUrl = DemoRouteConstants.Docs_URL_Tabs;

blazorbootstrap/Components/Tabs/Tab.razor.cs

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,44 +35,58 @@ protected override void OnInitialized()
3535

3636
/// <summary>
3737
/// Gets or sets the active state.
38+
/// <para>
39+
/// Default value is <see langword="false"/>.
40+
/// </para>
3841
/// </summary>
39-
/// <remarks>
40-
/// Default value is false.
41-
/// </remarks>
42+
[AddedVersion("1.0.0")]
43+
[DefaultValue(false)]
44+
[Description("Gets or sets the active state.")]
4245
[Parameter]
4346
public bool Active { get; set; }
4447

4548
/// <summary>
4649
/// Gets or sets the content to be rendered within the component.
50+
/// <para>
51+
/// Default value is <see langword="null"/>.
52+
/// </para>
4753
/// </summary>
48-
/// <remarks>
49-
/// Default value is null.
50-
/// </remarks>
51-
[Parameter]
54+
[AddedVersion("1.0.0")]
55+
[DefaultValue(null)]
56+
[Description("Gets or sets the content to be rendered within the component.")]
5257
[EditorRequired]
53-
public RenderFragment Content { get; set; } = default!;
58+
[Parameter]
59+
public RenderFragment? Content { get; set; }
5460

5561
/// <summary>
5662
/// Gets or sets the disabled state.
63+
/// <para>
64+
/// Default value is <see langword="false"/>.
65+
/// </para>
5766
/// </summary>
58-
/// <remarks>
59-
/// Default value is false.
60-
/// </remarks>
67+
[AddedVersion("1.0.0")]
68+
[DefaultValue(false)]
69+
[Description("Gets or sets the disabled state.")]
6170
[Parameter]
6271
public bool Disabled { get; set; }
6372

6473
/// <summary>
6574
/// Gets or sets the tab name.
75+
/// <para>
76+
/// Default value is <see langword="null"/>.
77+
/// </para>
6678
/// </summary>
67-
/// <remarks>
68-
/// Default value is null.
69-
/// </remarks>
79+
[AddedVersion("1.0.0")]
80+
[DefaultValue(null)]
81+
[Description("Gets or sets the tab name.")]
7082
[Parameter]
71-
public string Name { get; set; } = default!;
83+
public string? Name { get; set; }
7284

7385
/// <summary>
7486
/// This event fires when the user clicks the corresponding tab button and the tab is displayed.
7587
/// </summary>
88+
[AddedVersion("1.11.0")]
89+
[Description("This event fires when the user clicks the corresponding tab button and the tab is displayed.")]
7690
[Parameter]
7791
public EventCallback<TabEventArgs> OnClick { get; set; }
7892

@@ -84,21 +98,27 @@ protected override void OnInitialized()
8498

8599
/// <summary>
86100
/// Gets or sets the tab title.
101+
/// <para>
102+
/// Default value is <see langword="null"/>.
103+
/// </para>
87104
/// </summary>
88-
/// <remarks>
89-
/// Default value is null.
90-
/// </remarks>
105+
[AddedVersion("1.0.0")]
106+
[DefaultValue(null)]
107+
[Description("Gets or sets the tab title.")]
91108
[Parameter]
92-
public string Title { get; set; } = default!;
109+
public string? Title { get; set; }
93110

94111
/// <summary>
95112
/// Gets or sets the tab title template.
113+
/// <para>
114+
/// Default value is <see langword="null"/>.
115+
/// </para>
96116
/// </summary>
97-
/// <remarks>
98-
/// Default value is null.
99-
/// </remarks>
117+
[AddedVersion("1.0.0")]
118+
[DefaultValue(null)]
119+
[Description("Gets or sets the tab title template.")]
100120
[Parameter]
101-
public RenderFragment TitleTemplate { get; set; } = default!;
121+
public RenderFragment? TitleTemplate { get; set; }
102122

103123
#endregion
104124
}

blazorbootstrap/Components/Tabs/Tabs.razor.cs

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,16 @@ public async Task bsShowTab(string activeTabId, string previousActiveTabId)
111111
/// Gets the active tab.
112112
/// </summary>
113113
/// <returns>Returns the cuurent active <see cref="Tab"/>.</returns>
114+
[AddedVersion("3.0.0")]
115+
[Description("Gets the active tab.")]
114116
public Tab GetActiveTab() => activeTab;
115117

116118
/// <summary>
117119
/// Removes the tab by index.
118120
/// </summary>
119121
/// <param name="tabIndex"></param>
122+
[AddedVersion("2.2.0")]
123+
[Description("Removes the tab by index.")]
120124
public void RemoveTabByIndex(int tabIndex)
121125
{
122126
var tab = tabs.ElementAtOrDefault(tabIndex);
@@ -136,6 +140,8 @@ public void RemoveTabByIndex(int tabIndex)
136140
/// Removes the tab by name.
137141
/// </summary>
138142
/// <param name="tabName"></param>
143+
[AddedVersion("2.2.0")]
144+
[Description("Removes the tab by name.")]
139145
public void RemoveTabByName(string tabName)
140146
{
141147
var tabIndex = tabs.FindIndex(x => x.Name == tabName);
@@ -155,6 +161,8 @@ public void RemoveTabByName(string tabName)
155161
/// <summary>
156162
/// Selects the first tab and show its associated pane.
157163
/// </summary>
164+
[AddedVersion("1.0.0")]
165+
[Description("Selects the first tab and show its associated pane.")]
158166
public async Task ShowFirstTabAsync()
159167
{
160168
var tab = tabs.FirstOrDefault(x => !x.Disabled);
@@ -168,6 +176,8 @@ public async Task ShowFirstTabAsync()
168176
/// <summary>
169177
/// Selects the last tab and show its associated pane.
170178
/// </summary>
179+
[AddedVersion("1.0.0")]
180+
[Description("Selects the last tab and show its associated pane.")]
171181
public async Task ShowLastTabAsync()
172182
{
173183
if (tabs.Count == 0) return;
@@ -181,12 +191,16 @@ public async Task ShowLastTabAsync()
181191
/// <summary>
182192
/// Shows the recently added tab.
183193
/// </summary>
194+
[AddedVersion("2.2.0")]
195+
[Description("Shows the recently added tab.")]
184196
public void ShowRecentTab() => showLastTab = true;
185197

186198
/// <summary>
187199
/// Selects the tab by index and show its associated pane.
188200
/// </summary>
189201
/// <param name="tabIndex">The zero-based index of the element to get or set.</param>
202+
[AddedVersion("1.0.0")]
203+
[Description("Selects the tab by index and show its associated pane.")]
190204
public async Task ShowTabByIndexAsync(int tabIndex)
191205
{
192206
if (tabs.Count == 0) return;
@@ -203,6 +217,8 @@ public async Task ShowTabByIndexAsync(int tabIndex)
203217
/// Selects the tab by name and show its associated pane.
204218
/// </summary>
205219
/// <param name="tabName">The name of the tab to select.</param>
220+
[AddedVersion("1.0.0")]
221+
[Description("Selects the tab by name and show its associated pane.")]
206222
public async Task ShowTabByNameAsync(string tabName)
207223
{
208224
if (tabs.Count == 0) return;
@@ -270,7 +286,7 @@ private async Task ShowTabAsync(Tab tab)
270286
queuedTasks.Enqueue(async () => await JSRuntime.InvokeVoidAsync("window.blazorBootstrap.tabs.show", tab.Id));
271287

272288
if (tab?.OnClick.HasDelegate ?? false)
273-
await tab.OnClick.InvokeAsync(new TabEventArgs(tab!.Name, tab.Title));
289+
await tab.OnClick.InvokeAsync(new TabEventArgs(tab.Name!, tab.Title!));
274290

275291
activeTab = tab!;
276292
}
@@ -289,19 +305,26 @@ private async Task ShowTabAsync(Tab tab)
289305

290306
/// <summary>
291307
/// Gets or sets the content to be rendered within the component.
308+
/// <para>
309+
/// Default value is <see langword="null"/>.
310+
/// </para>
292311
/// </summary>
293-
/// <remarks>
294-
/// Default value is null.
295-
/// </remarks>
312+
[AddedVersion("1.0.0")]
313+
[DefaultValue(null)]
314+
[Description("Gets or sets the content to be rendered within the component.")]
315+
[EditorRequired]
296316
[Parameter]
297-
public RenderFragment ChildContent { get; set; } = default!;
317+
public RenderFragment? ChildContent { get; set; }
298318

299319
/// <summary>
300320
/// Gets or sets the tabs fade effect.
321+
/// <para>
322+
/// Default value is <see langword="false"/>.
323+
/// </para>
301324
/// </summary>
302-
/// <remarks>
303-
/// Default value is false.
304-
/// </remarks>
325+
[AddedVersion("1.0.0")]
326+
[DefaultValue(false)]
327+
[Description("Gets or sets the tabs fade effect.")]
305328
[Parameter]
306329
public bool EnableFadeEffect { get; set; }
307330

@@ -314,34 +337,45 @@ private async Task ShowTabAsync(Tab tab)
314337

315338
/// <summary>
316339
/// Get or sets the nav style.
317-
/// </summary>
318-
/// <remarks>
340+
/// <para>
319341
/// Default value is <see cref="NavStyle.Tabs" />.
320-
/// </remarks>
342+
/// </para>
343+
/// </summary>
344+
[AddedVersion("1.0.0")]
345+
[DefaultValue(NavStyle.Tabs)]
346+
[Description("Get or sets the nav style.")]
321347
[Parameter]
322348
public NavStyle NavStyle { get; set; } = NavStyle.Tabs;
323349

324350
/// <summary>
325351
/// This event fires after a new tab is shown (and thus the previous active tab is hidden).
326352
/// </summary>
353+
[AddedVersion("1.0.0")]
354+
[Description("This event fires after a new tab is shown (and thus the previous active tab is hidden).")]
327355
[Parameter]
328356
public EventCallback<TabsEventArgs> OnHidden { get; set; }
329357

330358
/// <summary>
331359
/// This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden).
332360
/// </summary>
361+
[AddedVersion("1.0.0")]
362+
[Description("This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden).")]
333363
[Parameter]
334364
public EventCallback<TabsEventArgs> OnHiding { get; set; }
335365

336366
/// <summary>
337367
/// This event fires on tab show, but before the new tab has been shown.
338368
/// </summary>
369+
[AddedVersion("1.0.0")]
370+
[Description("This event fires on tab show, but before the new tab has been shown.")]
339371
[Parameter]
340372
public EventCallback<TabsEventArgs> OnShowing { get; set; }
341373

342374
/// <summary>
343375
/// This event fires on tab show after a tab has been shown.
344376
/// </summary>
377+
[AddedVersion("1.0.0")]
378+
[Description("This event fires on tab show after a tab has been shown.")]
345379
[Parameter]
346380
public EventCallback<TabsEventArgs> OnShown { get; set; }
347381

blazorbootstrap/EventArguments/Tabs/TabEventArgs.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ public TabEventArgs(string name, string title)
1717
/// <summary>
1818
/// Gets the <see cref="Tab" /> name.
1919
/// </summary>
20+
[AddedVersion("1.0.0")]
21+
[Description("Gets the <b>Tab</b> name.")]
2022
public string Name { get; }
2123

2224
/// <summary>
2325
/// Gets the <see cref="Tab" /> title.
2426
/// </summary>
27+
[AddedVersion("1.0.0")]
28+
[Description("Gets the <b>Tab</b> title.")]
2529
public string Title { get; }
2630

2731
#endregion

blazorbootstrap/EventArguments/Tabs/TabsEventArgs.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,29 @@ public TabsEventArgs(string activeTabName, string activeTabTitle, string previou
1919
/// <summary>
2020
/// Gets the active <see cref="Tab" /> name.
2121
/// </summary>
22+
[AddedVersion("1.0.0")]
23+
[Description("Gets the active <b>Tab</b> name.")]
2224
public string ActiveTabName { get; }
2325

2426
/// <summary>
2527
/// Gets the active <see cref="Tab" /> title.
2628
/// </summary>
29+
[AddedVersion("1.0.0")]
30+
[Description("Gets the active <b>Tab</b> title.")]
2731
public string ActiveTabTitle { get; }
2832

2933
/// <summary>
3034
/// Gets the previous active <see cref="Tab" /> name.
3135
/// </summary>
36+
[AddedVersion("1.0.0")]
37+
[Description("Gets the previous active <b>Tab</b> name.")]
3238
public string PreviousActiveTabName { get; }
3339

3440
/// <summary>
3541
/// Gets the previous active <see cref="Tab" /> title.
3642
/// </summary>
43+
[AddedVersion("1.0.0")]
44+
[Description("Gets the previous active <b>Tab</b> title.")]
3745
public string PreviousActiveTabTitle { get; }
3846

3947
#endregion

blazorbootstrap/Extensions/EnumExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,17 @@ public static object ToSortableListPullMode(this SortableListPullMode sortableLi
458458
SortableListPullMode.True => true,
459459
SortableListPullMode.False => false,
460460
SortableListPullMode.Clone => "clone",
461-
//SortableListPullMode.Array => "array"
461+
//SortableListPullMode.Array => "array",
462+
_ => null!
462463
};
463464

464465
public static object ToSortableListPutMode(this SortableListPutMode sortableListPutMode) =>
465466
sortableListPutMode switch
466467
{
467468
SortableListPutMode.True => true,
468469
SortableListPutMode.False => false,
469-
//SortableListPullMode.Array => "array"
470+
//SortableListPullMode.Array => "array",
471+
_ => null!
470472
};
471473

472474
public static string ToSpinnerColorClass(this SpinnerColor spinnerColor) =>

0 commit comments

Comments
 (0)