@@ -12,6 +12,7 @@ namespace BootstrapBlazor.Components;
1212/// <para lang="zh">An input component for editing numeric values. Supported numeric 类型s are <see cref="int"/>, <see cref="long"/>, <see cref="short"/>, <see cref="float"/>, <see cref="double"/>, <see cref="decimal"/></para>
1313/// <para lang="en">An input component for editing numeric values. Supported numeric types are <see cref="int"/>, <see cref="long"/>, <see cref="short"/>, <see cref="float"/>, <see cref="double"/>, <see cref="decimal"/></para>
1414/// </summary>
15+ [ BootstrapModuleAutoLoader ( "Input/BootstrapInput.razor.js" , JSObjectReference = true ) ]
1516public partial class BootstrapInputNumber < TValue >
1617{
1718 /// <summary>
@@ -29,6 +30,7 @@ public partial class BootstrapInputNumber<TValue>
2930 /// </summary>
3031 protected string ? InputClassString => CssBuilder . Default ( "form-control" )
3132 . AddClass ( CssClass ) . AddClass ( ValidCss )
33+ . AddClass ( "input-number" )
3234 . AddClass ( "input-number-fix" , ShowButton )
3335 . AddClass ( $ "border-{ Color . ToDescriptionString ( ) } ", Color != Color . None )
3436 . AddClassFromAttributes ( AdditionalAttributes )
@@ -120,6 +122,34 @@ protected override void OnInitialized()
120122 {
121123 _lastInputValueString ??= Value ? . ToString ( ) ;
122124 }
125+
126+
127+ }
128+
129+ /// <summary>
130+ ///
131+ /// <inheritdoc/>
132+ /// </summary>
133+ protected override Task InvokeInitAsync ( ) => InvokeVoidAsync ( "init" , Id , Interop , nameof ( TriggerFormatValue ) ) ;
134+
135+ /// <summary>
136+ /// <para lang="zh">Trigger value changed event 回调. Trigger by JavaScript</para>
137+ /// <para lang="en">Trigger value changed event callback. Trigger by JavaScript</para>
138+ /// </summary>
139+ /// <param name="focus"></param>
140+ [ JSInvokable ]
141+ public Task TriggerFormatValue ( bool focus )
142+ {
143+ if ( focus )
144+ {
145+ CurrentValueAsString = InternalFormat ( Value ) ?? "" ;
146+ }
147+ else
148+ {
149+ CurrentValueAsString = GetFormatString ( Value ) ?? "" ;
150+ }
151+ StateHasChanged ( ) ;
152+ return Task . CompletedTask ;
123153 }
124154
125155 /// <summary>
0 commit comments