Skip to content

Commit d34bbd1

Browse files
committed
Merge branch 'main' into doc-authenticator
# Conflicts: # exclusion.dic # src/BootstrapBlazor.Server/Locales/en-US.json # src/BootstrapBlazor.Server/Locales/zh-CN.json # src/BootstrapBlazor.Server/docs.json # src/BootstrapBlazor/Components/Input/OtpInput.razor # src/BootstrapBlazor/Components/Input/OtpInput.razor.cs # src/BootstrapBlazor/Components/Input/OtpInput.razor.js # src/BootstrapBlazor/Components/Input/OtpInput.razor.scss
2 parents ab8c23b + 27474e0 commit d34bbd1

File tree

19 files changed

+437
-54
lines changed

19 files changed

+437
-54
lines changed

exclusion.dic

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,6 @@ Pharmacode
109109
bluetooth
110110
iframe
111111
Sqlite
112+
maxlength
113+
inputmode
112114
Totp
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
@page "/otp-input"
2+
@inject IStringLocalizer<OtpInputs> Localizer
3+
4+
<HeadContent>
5+
<style>
6+
.input-group-text {
7+
--bb-input-group-label-width: 100px;
8+
}
9+
10+
.otp-input-demo {
11+
text-align: center;
12+
}
13+
</style>
14+
</HeadContent>
15+
16+
<h3>@Localizer["OtpInputsTitle"]</h3>
17+
18+
<h4>@Localizer["OtpInputsDescription"]</h4>
19+
20+
<Tips class="mt-3">
21+
<p>@((MarkupString)Localizer["OtpInputsTips"].Value)</p>
22+
</Tips>
23+
24+
<DemoBlock Title="@Localizer["OtpInputsNormalTitle"]"
25+
Introduction="@Localizer["OtpInputsNormalIntro"]"
26+
Name="Normal">
27+
<div class="row g-3 mb-3">
28+
<div class="col-12 col-sm-6">
29+
<BootstrapInputGroup>
30+
<BootstrapInputGroupLabel DisplayText="Type"></BootstrapInputGroupLabel>
31+
<Select @bind-Value="_otpInputType"></Select>
32+
</BootstrapInputGroup>
33+
</div>
34+
<div class="col-12 col-sm-6">
35+
<BootstrapInputGroup>
36+
<BootstrapInputGroupLabel DisplayText="PlaceHolder"></BootstrapInputGroupLabel>
37+
<BootstrapInput @bind-Value="@_placeHolder"></BootstrapInput>
38+
</BootstrapInputGroup>
39+
</div>
40+
<div class="col-12 col-sm-6">
41+
<BootstrapInputGroup>
42+
<BootstrapInputGroupLabel DisplayText="Readonly"></BootstrapInputGroupLabel>
43+
<Switch @bind-Value="@_readonly"></Switch>
44+
</BootstrapInputGroup>
45+
</div>
46+
<div class="col-12 col-sm-6">
47+
<BootstrapInputGroup>
48+
<BootstrapInputGroupLabel DisplayText="Disable"></BootstrapInputGroupLabel>
49+
<Switch @bind-Value="@_disabled"></Switch>
50+
</BootstrapInputGroup>
51+
</div>
52+
</div>
53+
<OtpInput Value="@_value" Type="_otpInputType" PlaceHolder="@_placeHolder" IsReadonly="_readonly" IsDisabled="_disabled"></OtpInput>
54+
</DemoBlock>
55+
56+
<DemoBlock Title="@Localizer["OtpInputsValidateFormTitle"]"
57+
Introduction="@Localizer["OtpInputsValidateFormIntro"]"
58+
Name="ValidateForm">
59+
<ValidateForm Model="@_model">
60+
<div class="row g-3">
61+
<div class="col-12">
62+
<BootstrapInput @bind-Value="@_model.UserName" />
63+
</div>
64+
<div class="col-12">
65+
<GroupBox Title="2FA" class="otp-input-demo">
66+
<OtpInput @bind-Value="@_model.Password"></OtpInput>
67+
</GroupBox>
68+
</div>
69+
<div class="col-12">
70+
<Button ButtonType="ButtonType.Submit" Icon="fa-fw fa-solid fa-save" Text="Submit"></Button>
71+
</div>
72+
</div>
73+
</ValidateForm>
74+
</DemoBlock>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
namespace BootstrapBlazor.Server.Components.Samples;
7+
8+
/// <summary>
9+
/// OtpInputs samples
10+
/// </summary>
11+
public partial class OtpInputs
12+
{
13+
private string _value = "818924";
14+
15+
private OtpInputType _otpInputType;
16+
17+
private string _placeHolder = "X";
18+
19+
private bool _readonly = false;
20+
21+
private bool _disabled = false;
22+
23+
private LoginModel _model = new() { UserName = "Admin", Password = "" };
24+
}

src/BootstrapBlazor.Server/Components/Samples/ValidateForms.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
<div class="col-12 col-sm-6">
6969
<BootstrapInputGroupLabel @bind-Value="@Model2.Name" />
7070
<BootstrapInputGroup>
71-
<Display @bind-Value="@Model2.Name"></Display>
7271
<BootstrapInputGroupLabel DisplayText="Test" />
72+
<Display @bind-Value="@Model2.Name"></Display>
7373
</BootstrapInputGroup>
7474
</div>
7575
<div class="col-12 col-sm-6">

src/BootstrapBlazor.Server/Extensions/MenusLocalizerExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,12 @@ void AddForm(DemoMenuItem item)
409409
Url = "multi-select"
410410
},
411411
new()
412+
{
413+
IsNew = true,
414+
Text = Localizer["OtpInput"],
415+
Url = "otp-input"
416+
},
417+
new()
412418
{
413419
Text = Localizer["OnScreenKeyboard"],
414420
Url = "onscreen-keyboard"

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4919,6 +4919,7 @@
49194919
"Typed": "Typed",
49204920
"UniverSheet": "UniverSheet",
49214921
"ShieldBadge": "ShieldBadge",
4922+
"OtpInput": "OtpInput",
49224923
"Authenticator": "Authenticator"
49234924
},
49244925
"BootstrapBlazor.Server.Components.Samples.Table.TablesHeader": {
@@ -7093,6 +7094,15 @@
70937094
"ToastOnReadyTitle": "Collaboration Notification",
70947095
"ToastOnReadyContent": "After 4 seconds the table is updated by other writers to change the content"
70957096
},
7097+
"BootstrapBlazor.Server.Components.Samples.OtpInputs": {
7098+
"OtpInputsTitle": "OtpInput",
7099+
"OtpInputsDescription": "A secure verification password box based on OTP (One-Time Password) that is limited to one-time use and has a time limit",
7100+
"OtpInputsTips": "OTP (One Time Password, abbreviated as OTP): This is a security measure used to generate a unique password for each login or transaction. This component is used in conjunction with <code>ITotpService</code> <code>IHotpService</code> to greatly improve security.",
7101+
"OtpInputsNormalTitle": "Basic usage",
7102+
"OtpInputsNormalIntro": "Control the password type or length by setting parameters such as <code>Type</code>",
7103+
"OtpInputsValidateFormTitle": "ValidateForm",
7104+
"OtpInputsValidateFormIntro": "When the password is not provided, click the Submit button, the password box will be displayed in red and it will be prompted that it cannot be empty."
7105+
},
70967106
"BootstrapBlazor.Server.Components.Samples.Authenticators": {
70977107
"Title": "Authenticator",
70987108
"SubTitle": "An implementation TOTP RFC 6238 and HOTP RFC 4226 Authenticator service."

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4919,6 +4919,7 @@
49194919
"Typed": "打字机效果 Typed",
49204920
"UniverSheet": "表格组件 UniverSheet",
49214921
"ShieldBadge": "徽章组件 ShieldBadge",
4922+
"OtpInput": "验证码输入框 OtpInput",
49224923
"Authenticator": "密码验证服务 Authenticator"
49234924
},
49244925
"BootstrapBlazor.Server.Components.Samples.Table.TablesHeader": {
@@ -7093,6 +7094,15 @@
70937094
"ToastOnReadyTitle": "在线表格协作通知",
70947095
"ToastOnReadyContent": "4 秒后表格更新其他写作人员更改内容"
70957096
},
7097+
"BootstrapBlazor.Server.Components.Samples.OtpInputs": {
7098+
"OtpInputsTitle": "OtpInput 密码框",
7099+
"OtpInputsDescription": "基于 OTP(One-Time Password‌) 仅限单次使用且具备时效性的安全验证密码框",
7100+
"OtpInputsTips": "OTP(One Time Password,简称OTP):这是一种安全措施,用于在每次登录或交易时生成一个唯一的密码,本组件配合 <code>ITotpService</code> <code>IHotpService</code> 使用大大提高安全性",
7101+
"OtpInputsNormalTitle": "基础用法",
7102+
"OtpInputsNormalIntro": "通过设置 <code>Type</code> 等参数控制密码类型或者长度",
7103+
"OtpInputsValidateFormTitle": "表单内使用",
7104+
"OtpInputsValidateFormIntro": "密码未提供值时,点击提交按钮,密码框显示为红色,并且提示不可为空"
7105+
},
70967106
"BootstrapBlazor.Server.Components.Samples.Authenticators": {
70977107
"Title": "Authenticator 密码验证服务",
70987108
"SubTitle": "实现 TOTP RFC 6238 和 HOTP RFC 4226 认证器服务"

src/BootstrapBlazor.Server/docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
"typed": "Typeds",
230230
"univer-sheet": "UniverSheets",
231231
"shield-badge": "ShieldBadges",
232+
"opt-input": "OtpInputs",
232233
"authenticator": "Authenticators"
233234
},
234235
"video": {

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.5.11-beta07</Version>
4+
<Version>9.5.11-beta06</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,26 @@
44
@if (IsInputGroupLabel)
55
{
66
<div @attributes="@AdditionalAttributes" class="@ClassString" style="@StyleString" required="@Required">
7-
<span>@DisplayText</span>
7+
@if (ChildContent != null)
8+
{
9+
@ChildContent
10+
}
11+
else
12+
{
13+
<span>@DisplayText</span>
14+
}
815
</div>
916
}
1017
else
1118
{
12-
<label @attributes="@AdditionalAttributes" class="@ClassString" style="@StyleString" required="@Required">@DisplayText</label>
19+
<label @attributes="@AdditionalAttributes" class="@ClassString" style="@StyleString" required="@Required">
20+
@if (ChildContent != null)
21+
{
22+
@ChildContent
23+
}
24+
else
25+
{
26+
@DisplayText
27+
}
28+
</label>
1329
}

0 commit comments

Comments
 (0)