Skip to content

Commit 8440361

Browse files
committed
refactor: 支持表单
1 parent 21494c8 commit 8440361

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

src/BootstrapBlazor/Components/Input/OtpInput.razor

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
<div @attributes="AdditionalAttributes" id="@Id" class="@ClassString">
55
@for (var index = 0; index < Digits; index++)
66
{
7-
@if(IsReadonly || IsDisabled)
8-
{
9-
<span class="@ItemClassString">
10-
@GetValueString(index)
11-
</span>
12-
}
13-
else
14-
{
15-
<input type="@TypeString" class="@InputClassString"
16-
maxlength="@MaxLengthString" inputmode="@TypeModeString" placeholder="@PlaceHolder"
17-
value="@GetValueString(index)" />
18-
}
7+
@if(IsReadonly || IsDisabled)
8+
{
9+
<span class="@ItemClassString">
10+
@GetValueString(index)
11+
</span>
12+
}
13+
else
14+
{
15+
<input type="@TypeString" class="@InputClassString"
16+
maxlength="@MaxLengthString" inputmode="@TypeModeString" placeholder="@PlaceHolder"
17+
value="@GetValueString(index)" />
18+
}
1919
}
2020
</div>

src/BootstrapBlazor/Components/Input/OtpInput.razor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public partial class OtpInput
4646

4747
private string? InputClassString => CssBuilder.Default("bb-opt-item")
4848
.AddClass("input-number-fix", Type == OtpInputType.Number)
49+
.AddClass(ValidCss)
4950
.Build();
5051

5152
private string TypeString => Type switch

src/BootstrapBlazor/Components/Input/OtpInput.razor.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
padding: 0;
3131
text-align: center;
3232
}
33+
34+
&.is-valid {
35+
--bs-border-color: var(--bs-success);
36+
}
37+
38+
&.is-invalid {
39+
--bs-border-color: var(--bs-danger);
40+
}
3341
}
3442

3543
span.bb-opt-item {

0 commit comments

Comments
 (0)