@@ -31,6 +31,10 @@ public partial class DateTimePicker<TValue>
3131 . AddClass ( ValidCss )
3232 . Build ( ) ;
3333
34+ private string ? ButtonClassString => CssBuilder . Default ( "btn dropdown-toggle" )
35+ . AddClass ( $ "btn-{ ButtonColor . ToDescriptionString ( ) } ", ButtonColor != Color . None )
36+ . Build ( ) ;
37+
3438 /// <summary>
3539 /// 获得 组件小图标样式
3640 /// </summary>
@@ -54,6 +58,24 @@ public partial class DateTimePicker<TValue>
5458 /// </summary>
5559 private bool AllowNull { get ; set ; }
5660
61+ /// <summary>
62+ /// 获得/设置 是否显示为按钮样式 默认 false
63+ /// </summary>
64+ [ Parameter ]
65+ public bool IsButton { get ; set ; }
66+
67+ /// <summary>
68+ /// 获得/设置 选择按钮文本 默认 null 读取资源文件
69+ /// </summary>
70+ [ Parameter ]
71+ public string ? PickerButtonText { get ; set ; }
72+
73+ /// <summary>
74+ /// 获得/设置 选择按钮颜色 默认 <see cref="Color.Primary"/>
75+ /// </summary>
76+ [ Parameter ]
77+ public Color ButtonColor { get ; set ; } = Color . Primary ;
78+
5779 /// <summary>
5880 /// 获得/设置 时间格式化字符串 默认值为 null
5981 /// </summary>
@@ -292,6 +314,7 @@ protected override void OnParametersSet()
292314 DateTimeFormat ??= Localizer [ nameof ( DateTimeFormat ) ] ;
293315 DateFormat ??= Localizer [ nameof ( DateFormat ) ] ;
294316 TimeFormat ??= Localizer [ nameof ( TimeFormat ) ] ;
317+ PickerButtonText ??= Localizer [ nameof ( PickerButtonText ) ] ;
295318
296319 Icon ??= IconTheme . GetIconByKey ( ComponentIcons . DateTimePickerIcon ) ;
297320
@@ -371,6 +394,29 @@ protected override async Task OnParametersSetAsync()
371394 /// <returns></returns>
372395 protected override bool ShouldRender ( ) => _render ;
373396
397+ private bool _isButton = false ;
398+ /// <summary>
399+ /// <inheritdoc/>
400+ /// </summary>
401+ /// <param name="firstRender"></param>
402+ /// <returns></returns>
403+ protected override async Task OnAfterRenderAsync ( bool firstRender )
404+ {
405+ await base . OnAfterRenderAsync ( firstRender ) ;
406+
407+ if ( firstRender )
408+ {
409+ // 首次渲染时同步 IsButton 参数值
410+ _isButton = IsButton ;
411+ }
412+
413+ if ( _isButton != IsButton )
414+ {
415+ _isButton = IsButton ;
416+ await InvokeVoidAsync ( "reset" , Id ) ;
417+ }
418+ }
419+
374420 /// <summary>
375421 /// 格式化数值方法
376422 /// </summary>
0 commit comments