Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ internal override IEnumerable<NavItem> GetNavItems()
new (){ Id = "403", Text = "Date Input", Href = DemoRouteConstants.Demos_URL_DateInput, IconName = IconName.CalendarDate, ParentId = "4" },
new (){ Id = "404", Text = "Enum Input", Href = DemoRouteConstants.Demos_URL_EnumInput, IconName = IconName.MenuButtonWideFill, ParentId = "4" },
new (){ Id = "405", Text = "Number Input", Href = DemoRouteConstants.Demos_URL_NumberInput, IconName = IconName.InputCursor, ParentId = "4" },
new (){ Id = "406", Text = "Password Input", Href = DemoRouteConstants.Demos_URL_PasswordInput, IconName = IconName.EyeSlashFill, ParentId = "4" },
new (){ Id = "407", Text = "Radio Input", Href = DemoRouteConstants.Demos_URL_RadioInput, IconName = IconName.RecordCircle, ParentId = "4" },
new (){ Id = "408", Text = "Range Input", Href = DemoRouteConstants.Demos_URL_RangeInput, IconName = IconName.Sliders, ParentId = "4" },
new (){ Id = "406", Text = "OTP Input", Href = DemoRouteConstants.Demos_URL_OTPInput, IconName = IconName.Asterisk, ParentId = "4" },
new (){ Id = "407", Text = "Password Input", Href = DemoRouteConstants.Demos_URL_PasswordInput, IconName = IconName.EyeSlashFill, ParentId = "4" },
new (){ Id = "408", Text = "Radio Input", Href = DemoRouteConstants.Demos_URL_RadioInput, IconName = IconName.RecordCircle, ParentId = "4" },
new (){ Id = "409", Text = "Range Input", Href = DemoRouteConstants.Demos_URL_RangeInput, IconName = IconName.Sliders, ParentId = "4" },
//new (){ Id = "404", Text = "Select Input", Href = DemoRouteConstants.Demos_URL_SelectInput, IconName = IconName.MenuButtonWideFill, ParentId = "4" },
new (){ Id = "409", Text = "Switch", Href = DemoRouteConstants.Demos_URL_Switch, IconName = IconName.ToggleOn, ParentId = "4" },
new (){ Id = "410", Text = "Text Input", Href = DemoRouteConstants.Demos_URL_TextInput, IconName = IconName.InputCursorText, ParentId = "4" },
new (){ Id = "411", Text = "Text Area Input", Href = DemoRouteConstants.Demos_URL_TextAreaInput, IconName = IconName.InputCursorText, ParentId = "4" },
new (){ Id = "412", Text = "Time Input", Href = DemoRouteConstants.Demos_URL_TimeInput, IconName = IconName.ClockFill, ParentId = "4" },
new (){ Id = "410", Text = "Switch", Href = DemoRouteConstants.Demos_URL_Switch, IconName = IconName.ToggleOn, ParentId = "4" },
new (){ Id = "411", Text = "Text Input", Href = DemoRouteConstants.Demos_URL_TextInput, IconName = IconName.InputCursorText, ParentId = "4" },
new (){ Id = "412", Text = "Text Area Input", Href = DemoRouteConstants.Demos_URL_TextAreaInput, IconName = IconName.InputCursorText, ParentId = "4" },
new (){ Id = "413", Text = "Time Input", Href = DemoRouteConstants.Demos_URL_TimeInput, IconName = IconName.ClockFill, ParentId = "4" },

new (){ Id = "5", Text = "Components", IconName = IconName.GearFill, IconColor = IconColor.Danger },
new (){ Id = "500", Text = "Accordion", Href = DemoRouteConstants.Demos_URL_Accordion, IconName = IconName.ChevronBarExpand, ParentId = "5" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ internal override IEnumerable<NavItem> GetNavItems()
new (){ Id = "403", Text = "Date Input", Href = DemoRouteConstants.Docs_URL_DateInput, IconName = IconName.CalendarDate, ParentId = "4" },
new (){ Id = "404", Text = "Enum Input", Href = DemoRouteConstants.Docs_URL_EnumInput, IconName = IconName.MenuButtonWideFill, ParentId = "4" },
new (){ Id = "405", Text = "Number Input", Href = DemoRouteConstants.Docs_URL_NumberInput, IconName = IconName.InputCursor, ParentId = "4" },
new (){ Id = "406", Text = "Password Input", Href = DemoRouteConstants.Docs_URL_PasswordInput, IconName = IconName.EyeSlashFill, ParentId = "4" },
new (){ Id = "407", Text = "Radio Input", Href = DemoRouteConstants.Docs_URL_RadioInput, IconName = IconName.RecordCircle, ParentId = "4" },
new (){ Id = "408", Text = "Range Input", Href = DemoRouteConstants.Docs_URL_RangeInput, IconName = IconName.Sliders, ParentId = "4" },
new (){ Id = "406", Text = "OTP Input", Href = DemoRouteConstants.Docs_URL_OTPInput, IconName = IconName.Asterisk, ParentId = "4" },
new (){ Id = "407", Text = "Password Input", Href = DemoRouteConstants.Docs_URL_PasswordInput, IconName = IconName.EyeSlashFill, ParentId = "4" },
new (){ Id = "408", Text = "Radio Input", Href = DemoRouteConstants.Docs_URL_RadioInput, IconName = IconName.RecordCircle, ParentId = "4" },
new (){ Id = "409", Text = "Range Input", Href = DemoRouteConstants.Docs_URL_RangeInput, IconName = IconName.Sliders, ParentId = "4" },
//new (){ Id = "404", Text = "Select Input", Href = DemoRouteConstants.Docs_URL_SelectInput, IconName = IconName.MenuButtonWideFill, ParentId = "4" },
new (){ Id = "409", Text = "Switch", Href = DemoRouteConstants.Docs_URL_Switch, IconName = IconName.ToggleOn, ParentId = "4" },
new (){ Id = "410", Text = "Text Input", Href = DemoRouteConstants.Docs_URL_TextInput, IconName = IconName.InputCursorText, ParentId = "4" },
new (){ Id = "411", Text = "Text Area Input", Href = DemoRouteConstants.Docs_URL_TextAreaInput, IconName = IconName.InputCursorText, ParentId = "4" },
new (){ Id = "412", Text = "Time Input", Href = DemoRouteConstants.Docs_URL_TimeInput, IconName = IconName.ClockFill, ParentId = "4" },
new (){ Id = "410", Text = "Switch", Href = DemoRouteConstants.Docs_URL_Switch, IconName = IconName.ToggleOn, ParentId = "4" },
new (){ Id = "411", Text = "Text Input", Href = DemoRouteConstants.Docs_URL_TextInput, IconName = IconName.InputCursorText, ParentId = "4" },
new (){ Id = "412", Text = "Text Area Input", Href = DemoRouteConstants.Docs_URL_TextAreaInput, IconName = IconName.InputCursorText, ParentId = "4" },
new (){ Id = "413", Text = "Time Input", Href = DemoRouteConstants.Docs_URL_TimeInput, IconName = IconName.ClockFill, ParentId = "4" },

new (){ Id = "5", Text = "Components", IconName = IconName.GearFill, IconColor = IconColor.Danger },
new (){ Id = "500", Text = "Accordion", Href = DemoRouteConstants.Docs_URL_Accordion, IconName = IconName.ChevronBarExpand, ParentId = "5" },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@page "/otp-input"
@attribute [Route(pageUrl)]
@layout DemosMainLayout

<DemosPageHeadSection PageUrl="@pageUrl"
PageTitle="@pageTitle"
PageDescription="@pageDescription"
MetaTitle="@metaTitle"
MetaDescription="@metaDescription"
ImageUrl="@imageUrl" />

<DocsLink Href="@DemoRouteConstants.Docs_URL_OTPInput" />

<Section Class="p-0" Size="HeadingSize.H3" Name="How it works" PageUrl="@pageUrl" Link="how-it-works">
<div class="mb-3">
The <strong>OTPInput</strong> component provides a user-friendly interface for entering one-time passwords (OTP), commonly used for authentication and verification flows.
<br /><br />
<strong>How to use:</strong>
<div class="content mb-2">
<ol>
<li>Add the <code>OTPInput</code> component to your page.</li>
<li>Handle the <code>OnOTPChanged</code> event to capture the OTP value as the user types.</li>
<li>Handle the <code>OnOTPCompleted</code> event to respond when the user has entered the complete OTP.</li>
<li>Bind the entered OTP to a variable for display or further processing as needed.</li>
</ol>
</div>
This demo illustrates the basic usage of the OTPInput component, including event handling for OTP entry and completion.
</div>
<Demo Type="typeof(OTPInput_Demo_01_How_it_works)" Tabs="true"/>
</Section>

<Section Class="p-0" Size="HeadingSize.H3" Name="Length" PageUrl="@pageUrl" Link="length">
<div class="mb-3">
The <strong>OTPInput</strong> component allows you to specify the required OTP length, adapting the number of input fields accordingly.
<br /><br />
<strong>How to use:</strong>
<div class="content mb-2">
<ol>
<li>Set the <code>Length</code> parameter to define how many digits or characters the OTP should have (e.g., <code>Length="5"</code>).</li>
<li>Handle the <code>OnOTPChanged</code> and <code>OnOTPCompleted</code> events as shown in the demo to process the OTP input.</li>
<li>Display or use the entered OTP value as needed in your application.</li>
</ol>
</div>
This demo demonstrates how to configure the OTPInput component for a custom OTP length and handle user input accordingly.
</div>
<Demo Type="typeof(OTPInput_Demo_02_Length)" Tabs="true" />
</Section>

@code {
private const string componentName = nameof(OTPInput);
private const string pageUrl = DemoRouteConstants.Demos_URL_OTPInput;
private const string pageTitle = componentName;
private const string pageDescription = $"The <code>{componentName}</code> component allows users to enter a one-time password (OTP) in a secure and user-friendly manner. The component is designed to enhance the user experience by providing a visually appealing and functional input field for OTP entry.";
private const string metaTitle = $"Blazor {componentName} Component";
private const string metaDescription = $"The {componentName} component allows users to enter a one-time password (OTP) in a secure and user-friendly manner. The component is designed to enhance the user experience by providing a visually appealing and functional input field for OTP entry.";
private const string imageUrl = DemoScreenshotSrcConstants.Demos_URL_OTPInput;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<OTPInput OnOTPChanged="HandleOtpChanged"
OnOTPCompleted="HandleOtpCompleted" />

<div class="mt-3">Entered OTP: @enteredOTP</div>

@code {
private string? enteredOTP = null;

private void HandleOtpChanged(string otp)
{
enteredOTP = otp;
}

private void HandleOtpCompleted(string otp)
{
Console.WriteLine($"OTP Completed: {otp}");
enteredOTP = otp;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<OTPInput Length="5"
OnOTPChanged="HandleOtpChanged"
OnOTPCompleted="HandleOtpCompleted" />

<div class="mt-3">Entered OTP: @enteredOTP</div>

@code {
private string? enteredOTP = null;

private void HandleOtpChanged(string otp)
{
enteredOTP = otp;
}

private void HandleOtpCompleted(string otp)
{
Console.WriteLine($"OTP Completed: {otp}");
enteredOTP = otp;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@attribute [Route(pageUrl)]
@layout DocsMainLayout

<DocsPageHeadSection PageUrl="@pageUrl"
PageTitle="@pageTitle"
PageDescription="@pageDescription"
MetaTitle="@metaTitle"
MetaDescription="@metaDescription"
ImageUrl="@imageUrl" />

<DemoLink Href="@DemoRouteConstants.Demos_URL_OTPInput" />

<Section Class="p-0" Size="HeadingSize.H3" Name="Screenshot" PageUrl="@pageUrl" Link="screenshot">
<img src="@imageUrl" class="img-fluid" alt="@metaTitle" />
</Section>

<Section Class="p-0" Size="HeadingSize.H3" Name="Parameters" PageUrl="@pageUrl" Link="parameters">
<DocxTable TItem="OTPInput" DocType="DocType.Parameters" />
</Section>

<Section Class="p-0" Size="HeadingSize.H3" Name="Methods" PageUrl="@pageUrl" Link="methods">
<DocxTable TItem="OTPInput" DocType="DocType.Methods" />
</Section>

<Section Class="p-0" Size="HeadingSize.H3" Name="Events" PageUrl="@pageUrl" Link="events">
<DocxTable TItem="OTPInput" DocType="DocType.Events" />
</Section>

@code {
private const string componentName = nameof(OTPInput);
private const string pageUrl = DemoRouteConstants.Docs_URL_OTPInput;
private const string pageTitle = componentName;
private const string pageDescription = $"This documentation provides a comprehensive reference for the <code>{componentName}</code> component, guiding you through its configuration options.";
private const string metaTitle = $"Blazor {componentName} Component";
private const string metaDescription = $"This documentation provides a comprehensive reference for the {componentName} component, guiding you through its configuration options.";
private const string imageUrl = DemoScreenshotSrcConstants.Demos_URL_NumberInput;
}
12 changes: 11 additions & 1 deletion BlazorBootstrap.Demo.RCL/Components/Pages/Home/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@
<h4 class="mb-0 fs-5 fw-semibold"><Icon Name="IconName.InputCursor" class="me-2" /> Number Input</h4>
</a>
</div>
<div class="col-sm-4 mb-2">
<a class="d-block pe-lg-4 text-decoration-none lh-sm" href="@DemoRouteConstants.Demos_URL_OTPInput">
<h4 class="mb-0 fs-5 fw-semibold"><Icon Name="IconName.Asterisk" class="me-2" /> OTP Input <Badge Color="BadgeColor.Danger">New</Badge></h4>
</a>
</div>
<div class="col-sm-4 mb-2">
<a class="d-block pe-lg-4 text-decoration-none lh-sm" href="@DemoRouteConstants.Demos_URL_PasswordInput">
<h4 class="mb-0 fs-5 fw-semibold"><Icon Name="IconName.EyeSlashFill" class="me-2" /> Password Input</h4>
Expand Down Expand Up @@ -314,6 +319,11 @@
<h4 class="mb-0 fs-5 fw-semibold"><Icon Name="IconName.InputCursor" class="me-2" /> Number Input</h4>
</a>
</div>
<div class="col-sm-4 mb-2">
<a class="d-block pe-lg-4 text-decoration-none lh-sm" href="@DemoRouteConstants.Demos_URL_OTPInput">
<h4 class="mb-0 fs-5 fw-semibold"><Icon Name="IconName.Asterisk" class="me-2" /> OTP Input <Badge Color="BadgeColor.Danger">New</Badge></h4>
</a>
</div>
<div class="col-sm-4 mb-2">
<a class="d-block pe-lg-4 text-decoration-none lh-sm" href="@DemoRouteConstants.Demos_URL_PasswordInput">
<h4 class="mb-0 fs-5 fw-semibold"><Icon Name="IconName.EyeSlashFill" class="me-2" /> Password Input</h4>
Expand Down Expand Up @@ -519,7 +529,7 @@

protected override void OnInitialized()
{
version = $"v{Configuration["version"]}"; // example: v0.6.1
version = $"v{Configuration["version"]}"; // example: v4.0.1
releaseShortDescription = Configuration["release:short_description"]!;

base.OnInitialized();
Expand Down
6 changes: 2 additions & 4 deletions BlazorBootstrap.Demo.RCL/Components/Shared/Demo.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class Demo : BlazorBootstrapComponentBase
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
await JS.InvokeVoidAsync("highlightCode");
await SafeInvokeVoidAsync("highlightCode");

await base.OnAfterRenderAsync(firstRender);
}
Expand Down Expand Up @@ -97,16 +97,14 @@ public void ResetCopyStatusJS()
StateHasChanged();
}

private async Task CopyToClipboardAsync() => await JS.InvokeVoidAsync("copyToClipboard", snippet, objRef);
private async Task CopyToClipboardAsync() => await SafeInvokeVoidAsync("copyToClipboard", snippet, objRef);

#endregion

#region Properties, Indexers

protected override string? ClassNames => BuildClassNames(Class, ("bd-example-snippet bd-code-snippet", true));

[Inject] protected IJSRuntime JS { get; set; } = default!;

[Parameter] public LanguageCode LanguageCode { get; set; } = LanguageCode.Razor;

[Parameter] public bool ShowCodeOnly { get; set; }
Expand Down
7 changes: 3 additions & 4 deletions BlazorBootstrap.Demo.RCL/Components/Shared/Snippet.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
namespace BlazorBootstrap.Demo.RCL;

public class Snippet : ComponentBase
public class Snippet : BlazorBootstrapComponentBase
{
#region Members

private string? snippet;
private bool isJsRuntimeAvailable = true;

#endregion

Expand All @@ -31,7 +32,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
await JS.InvokeVoidAsync("highlightCode");
await SafeInvokeVoidAsync("highlightCode");

await base.OnAfterRenderAsync(firstRender);
}
Expand Down Expand Up @@ -69,8 +70,6 @@ protected override async Task OnParametersSetAsync()

#region Properties

[Inject] protected IJSRuntime JS { get; set; } = null!;

[Parameter] public LanguageCode LanguageCode { get; set; } = LanguageCode.Razor;

[Parameter] public string? FilePath { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions BlazorBootstrap.Demo.RCL/Constants/DemoRouteConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static class DemoRouteConstants
public const string Demos_URL_DateInput = Demos_URL_Forms_Prefix + "/date-input";
public const string Demos_URL_EnumInput = Demos_URL_Forms_Prefix + "/enum-input";
public const string Demos_URL_NumberInput = Demos_URL_Forms_Prefix + "/number-input";
public const string Demos_URL_OTPInput = Demos_URL_Forms_Prefix + "/otp-input";
public const string Demos_URL_PasswordInput = Demos_URL_Forms_Prefix + "/password-input";
public const string Demos_URL_RadioInput = Demos_URL_Forms_Prefix + "/radio-input";
public const string Demos_URL_RangeInput = Demos_URL_Forms_Prefix + "/range-input";
Expand Down Expand Up @@ -143,6 +144,7 @@ public static class DemoRouteConstants
public const string Docs_URL_DateInput = Docs_URL_Forms_Prefix + "/date-input";
public const string Docs_URL_EnumInput = Docs_URL_Forms_Prefix + "/enum-input";
public const string Docs_URL_NumberInput = Docs_URL_Forms_Prefix + "/number-input";
public const string Docs_URL_OTPInput = Docs_URL_Forms_Prefix + "/otp-input";
public const string Docs_URL_PasswordInput = Docs_URL_Forms_Prefix + "/password-input";
public const string Docs_URL_RadioInput = Docs_URL_Forms_Prefix + "/radio-input";
public const string Docs_URL_RangeInput = Docs_URL_Forms_Prefix + "/range-input";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class DemoScreenshotSrcConstants
public const string Demos_URL_DateInput = DemoScreenshotSrcPrefix + "date-input.png";
public const string Demos_URL_EnumInput = DemoScreenshotSrcPrefix + "enum-input.png"; // TODO: pending
public const string Demos_URL_NumberInput = DemoScreenshotSrcPrefix + "number-input.png";
public const string Demos_URL_OTPInput = DemoScreenshotSrcPrefix + "otp-input.png";
public const string Demos_URL_PasswordInput = DemoScreenshotSrcPrefix + "password-input.png";
public const string Demos_URL_RadioInput = DemoScreenshotSrcPrefix + "radio-input.png";
public const string Demos_URL_RangeInput = DemoScreenshotSrcPrefix + "range-input.png";
Expand Down
6 changes: 3 additions & 3 deletions blazorbootstrap/Components/Alert/Alert.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected override async ValueTask DisposeAsyncCore(bool disposing)
try
{
if (IsRenderComplete)
await JSRuntime.InvokeVoidAsync("window.blazorBootstrap.alert.dispose", Id);
await SafeInvokeVoidAsync("window.blazorBootstrap.alert.dispose", Id);
}
catch (JSDisconnectedException)
{
Expand All @@ -34,7 +34,7 @@ protected override async ValueTask DisposeAsyncCore(bool disposing)
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
await JSRuntime.InvokeVoidAsync("window.blazorBootstrap.alert.initialize", Id, objRef);
await SafeInvokeVoidAsync("window.blazorBootstrap.alert.initialize", Id, objRef);

await base.OnAfterRenderAsync(firstRender);
}
Expand All @@ -57,7 +57,7 @@ protected override async Task OnInitializedAsync()
/// </summary>
[AddedVersion("1.0.0")]
[Description("Closes an alert by removing it from the DOM.")]
public async Task CloseAsync() => await JSRuntime.InvokeVoidAsync("window.blazorBootstrap.alert.close", Id);
public async Task CloseAsync() => await SafeInvokeVoidAsync("window.blazorBootstrap.alert.close", Id);

#endregion

Expand Down
Loading
Loading