Skip to content

Commit c09a567

Browse files
committed
feat: 增加 TriggerHideCallback 回调
1 parent dce36f4 commit c09a567

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@namespace BootstrapBlazor.Components
22
@typeparam TValue
33
@inherits PopoverDropdownBase<TValue>
4-
@attribute [BootstrapModuleAutoLoader("DateTimePicker/DateTimePicker.razor.js")]
4+
@attribute [BootstrapModuleAutoLoader("DateTimePicker/DateTimePicker.razor.js", JSObjectReference = true)]
55

66
@if (IsShowLabel)
77
{

src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,15 @@ protected override string FormatValueAsString(TValue? value)
372372
return ret;
373373
}
374374

375+
/// <summary>
376+
/// <inheritdoc/>
377+
/// </summary>
378+
/// <returns></returns>
379+
protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, new
380+
{
381+
TriggerHideCallback = nameof(TriggerHideCallback)
382+
});
383+
375384
private bool MinValueToEmpty(DateTime val) => val == DateTime.MinValue && AllowNull && DisplayMinValueAsEmpty;
376385

377386
private bool MinValueToToday(DateTime val) => val == DateTime.MinValue && !AllowNull && AutoToday;
@@ -454,4 +463,15 @@ protected virtual async Task OnBlur()
454463
await OnBlurAsync(Value);
455464
}
456465
}
466+
467+
/// <summary>
468+
/// 客户端弹窗关闭后由 Javascript 调用此方法
469+
/// </summary>
470+
/// <returns></returns>
471+
[JSInvokable]
472+
public Task TriggerHideCallback()
473+
{
474+
StateHasChanged();
475+
return Task.CompletedTask;
476+
}
457477
}

src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import EventHandler from "../../modules/event-handler.js"
33
import Popover from "../../modules/base-popover.js"
44

5-
export function init(id) {
5+
export function init(id, invoke, options) {
66
const el = document.getElementById(id)
77
if (el == null) {
88
return
@@ -13,6 +13,10 @@ export function init(id) {
1313
dropdownSelector: el.getAttribute('data-bb-dropdown'),
1414
isDisabled: () => {
1515
return el.classList.contains('disabled');
16+
},
17+
hideCallback: () => {
18+
console.log('hideCallback');
19+
invoke.invokeMethodAsync(options.triggerHideCallback);
1620
}
1721
});
1822
const dateTimePicker = {

0 commit comments

Comments
 (0)