File tree Expand file tree Collapse file tree 4 files changed +51
-8
lines changed Expand file tree Collapse file tree 4 files changed +51
-8
lines changed Original file line number Diff line number Diff line change 66 {
77 if (index < _values .Length )
88 {
9- < span class = " @SpanClassString" > @_values [index ]< / span >
9+ @if (IsReadonly || IsDisabled )
10+ {
11+ < span class = " @ItemClassString" > @_values [index ]< / span >
12+ }
13+ else
14+ {
15+ < span class = " @ItemClassString" >
16+ @{
17+ var charIndex = index ;
18+ }
19+ < input type = " @TypeString" @bind = " @_values[charIndex]" / >
20+ < / span >
21+ }
1022 }
1123 }
1224</div >
Original file line number Diff line number Diff line change @@ -17,7 +17,13 @@ public partial class OtpInput
1717 public int Digits { get ; set ; } = 6 ;
1818
1919 /// <summary>
20- ///
20+ /// Gets or sets whether the OTP input is readonly. Default is false.
21+ /// </summary>
22+ [ Parameter ]
23+ public bool IsReadonly { get ; set ; }
24+
25+ /// <summary>
26+ /// Gets or sets the value type of the OTP input. Default is <see cref="OtpInputType.Number"/>.
2127 /// </summary>
2228 [ Parameter ]
2329 public OtpInputType Type { get ; set ; }
@@ -26,10 +32,18 @@ public partial class OtpInput
2632 . AddClassFromAttributes ( AdditionalAttributes )
2733 . Build ( ) ;
2834
29- private string ? SpanClassString => CssBuilder . Default ( "bb-opt-span" )
35+ private string ? ItemClassString => CssBuilder . Default ( "bb-opt-item" )
36+ . AddClass ( "disabled" , IsDisabled )
3037 . AddClass ( ValidCss )
3138 . Build ( ) ;
3239
40+ private string TypeString => Type switch
41+ {
42+ OtpInputType . Number => "number" ,
43+ OtpInputType . Password => "password" ,
44+ _ => "text"
45+ } ;
46+
3347 private char [ ] _values = [ ] ;
3448
3549 /// <summary>
Original file line number Diff line number Diff line change 1- .bb-opt-span {
1+ .bb-opt-item {
2+ --bb-opt-item-padding : #{$bb-opt-item-padding } ;
3+ --bb-opt-item-margin : #{$bb-opt-item-margin } ;
4+ --bb-opt-font-size : #{$bb-opt-font-size } ;
5+ --bb-opt-border-width : #{$bb-opt-border-width } ;
26 display : inline-block ;
3- border : 1 px solid var (--bs-border-color );
4- font-size : 3 em ;
5- padding : 0 .5 em ;
7+ border : var ( --bb-opt-border-width ) solid var (--bs-border-color );
8+ font-size : var ( --bb-opt-font-size ) ;
9+ padding : var ( --bb-opt-item-padding ) ;
610 border-radius : var (--bs-border-radius );
711
812 & :not (:last-child ) {
9- margin-right : .5rem ;
13+ margin-right : var (--bb-opt-item-margin );
14+ }
15+
16+ & .disabled {
17+ cursor : not-allowed ;
18+ }
19+
20+ > input {
1021 }
1122}
Original file line number Diff line number Diff line change @@ -314,6 +314,12 @@ $bb-viewer-border-radius: 50%;
314314// Ip Address
315315$bb-ip-cell-max-width : 30px ;
316316
317+ // OptInput
318+ $bb-opt-item-padding : 0 .5rem ;
319+ $bb-opt-item-margin : .5rem ;
320+ $bb-opt-font-size : 3em ;
321+ $bb-opt-border-width : 1px ;
322+
317323// Layout
318324$bb-layout-header-height : 50px ;
319325$bb-layout-header-background : #0078d4 ;
You can’t perform that action at this time.
0 commit comments