Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -578,20 +578,23 @@ private async Task ToggleCallout()
{
if (IsEnabled is false || IsDisposed) return;

await _js.BitCalloutToggleCallout(_dotnetObj,
_Id,
null,
_calloutId,
null,
IsOpen,
BitResponsiveMode.None,
BitDropDirection.TopAndBottom,
Dir is BitDir.Rtl,
"",
0,
"",
"",
true);
await _js.BitCalloutToggleCallout(
dotnetObj: _dotnetObj,
componentId: _Id,
component: null,
calloutId: _calloutId,
callout: null,
isCalloutOpen: IsOpen,
responsiveMode: BitResponsiveMode.None,
dropDirection: BitDropDirection.TopAndBottom,
isRtl: Dir is BitDir.Rtl,
scrollContainerId: "",
scrollOffset: 0,
headerId: "",
footerId: "",
setCalloutWidth: true,
preserveCalloutWidth: false,
maxWindowWidth: 0);
}

private void OnSetIsOpen()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,20 +536,23 @@ private async Task ToggleCallout()
if (Standalone) return;
if (IsEnabled is false || IsDisposed) return;

await _js.BitCalloutToggleCallout(_dotnetObj,
_circularTimePickerId,
null,
_calloutId,
null,
IsOpen,
Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
BitDropDirection.TopAndBottom,
Dir is BitDir.Rtl,
"",
0,
"",
"",
false);
await _js.BitCalloutToggleCallout(
dotnetObj: _dotnetObj,
componentId: _circularTimePickerId,
component: null,
calloutId: _calloutId,
callout: null,
isCalloutOpen: IsOpen,
responsiveMode: Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
dropDirection: BitDropDirection.TopAndBottom,
isRtl: Dir is BitDir.Rtl,
scrollContainerId: "",
scrollOffset: 0,
headerId: "",
footerId: "",
setCalloutWidth: false,
preserveCalloutWidth: false,
maxWindowWidth: 0);
}

private async Task UpdateTime(MouseEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1401,21 +1401,23 @@ private async Task<bool> ToggleCallout()
if (Standalone) return false;
if (IsEnabled is false || IsDisposed) return false;

return await _js.BitCalloutToggleCallout(_dotnetObj,
_datePickerId,
null,
_calloutId,
null,
IsOpen,
Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
BitDropDirection.TopAndBottom,
Dir is BitDir.Rtl,
"",
0,
"",
"",
false,
MAX_WIDTH);
return await _js.BitCalloutToggleCallout(
dotnetObj: _dotnetObj,
componentId: _datePickerId,
component: null,
calloutId: _calloutId,
callout: null,
isCalloutOpen: IsOpen,
responsiveMode: Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
dropDirection: BitDropDirection.TopAndBottom,
isRtl: Dir is BitDir.Rtl,
scrollContainerId: "",
scrollOffset: 0,
headerId: "",
footerId: "",
setCalloutWidth: false,
preserveCalloutWidth: false,
maxWindowWidth: MAX_WIDTH);
}

private string GetCalloutCssClasses()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1924,21 +1924,23 @@ private async Task<bool> ToggleCallout()
if (Standalone) return false;
if (IsEnabled is false || IsDisposed) return false;

return await _js.BitCalloutToggleCallout(_dotnetObj,
_dateRangePickerId,
null,
_calloutId,
null,
IsOpen,
Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
BitDropDirection.TopAndBottom,
Dir is BitDir.Rtl,
"",
0,
"",
"",
false,
MAX_WIDTH);
return await _js.BitCalloutToggleCallout(
dotnetObj: _dotnetObj,
componentId: _dateRangePickerId,
component: null,
calloutId: _calloutId,
callout: null,
isCalloutOpen: IsOpen,
responsiveMode: Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
dropDirection: BitDropDirection.TopAndBottom,
isRtl: Dir is BitDir.Rtl,
scrollContainerId: "",
scrollOffset: 0,
headerId: "",
footerId: "",
setCalloutWidth: false,
preserveCalloutWidth: false,
maxWindowWidth: MAX_WIDTH);
}

private string GetCalloutCssClasses()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
await base.OnAfterRenderAsync(firstRender);

if (firstRender is false) return;

_dotnetObj = DotNetObjectReference.Create(this);

if (Responsive is false) return;
Expand Down Expand Up @@ -1172,20 +1172,23 @@ private async Task ToggleCallout()
{
if (IsEnabled is false || IsDisposed) return;

_isResponsiveMode = await _js.BitCalloutToggleCallout(_dotnetObj,
_dropdownId,
null,
_calloutId,
null,
IsOpen,
Responsive ? BitResponsiveMode.Panel : BitResponsiveMode.None,
DropDirection,
Dir is BitDir.Rtl,
_scrollContainerId,
ShowSearchBox && Combo is false ? 32 : 0,
CalloutHeaderTemplate is not null ? _headerId : "",
CalloutFooterTemplate is not null ? _footerId : "",
PreserveCalloutWidth is false);
_isResponsiveMode = await _js.BitCalloutToggleCallout(
dotnetObj: _dotnetObj,
componentId: _dropdownId,
component: null,
calloutId: _calloutId,
callout: null,
isCalloutOpen: IsOpen,
responsiveMode: Responsive ? BitResponsiveMode.Panel : BitResponsiveMode.None,
dropDirection: DropDirection,
isRtl: Dir is BitDir.Rtl,
scrollContainerId: _scrollContainerId,
scrollOffset: ShowSearchBox && Combo is false ? 32 : 0,
headerId: CalloutHeaderTemplate is not null ? _headerId : "",
footerId: CalloutFooterTemplate is not null ? _footerId : "",
setCalloutWidth: PreserveCalloutWidth is false,
preserveCalloutWidth: false,
maxWindowWidth: 0);
}

private async ValueTask<ItemsProviderResult<TItem>> InternalItemsProvider(ItemsProviderRequest request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,20 +520,23 @@ private async Task ToggleCallout()
{
if (IsEnabled is false || IsDisposed) return;

await _js.BitCalloutToggleCallout(_dotnetObj,
_Id,
null,
_calloutId,
null,
_isOpen,
BitResponsiveMode.None,
BitDropDirection.TopAndBottom,
Dir is BitDir.Rtl,
_scrollContainerId,
0,
string.Empty,
string.Empty,
true);
await _js.BitCalloutToggleCallout(
dotnetObj: _dotnetObj,
componentId: _Id,
component: null,
calloutId: _calloutId,
callout: null,
isCalloutOpen: _isOpen,
responsiveMode: BitResponsiveMode.None,
dropDirection: BitDropDirection.TopAndBottom,
isRtl: Dir is BitDir.Rtl,
scrollContainerId: _scrollContainerId,
scrollOffset: 0,
headerId: string.Empty,
footerId: string.Empty,
setCalloutWidth: false,
preserveCalloutWidth: false,
maxWindowWidth: 0);
}

private async Task ChangeSelectedItem(bool isArrowUp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
if (firstRender is false) return;

_dotnetObj = DotNetObjectReference.Create(this);

if (Responsive is false) return;

await _js.BitSwipesSetup(_calloutId, 0.25m, BitPanelPosition.Top, Dir is BitDir.Rtl, BitSwipeOrientation.Vertical, _dotnetObj);
Expand Down Expand Up @@ -432,20 +432,23 @@ private async Task ToggleCallout()
if (Standalone) return;
if (IsEnabled is false || IsDisposed) return;

await _js.BitCalloutToggleCallout(_dotnetObj,
_timePickerId,
null,
_calloutId,
null,
IsOpen,
Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
DropDirection,
Dir is BitDir.Rtl,
string.Empty,
0,
string.Empty,
string.Empty,
true);
await _js.BitCalloutToggleCallout(
dotnetObj: _dotnetObj,
componentId: _timePickerId,
component: null,
calloutId: _calloutId,
callout: null,
isCalloutOpen: IsOpen,
responsiveMode: Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
dropDirection: DropDirection,
isRtl: Dir is BitDir.Rtl,
scrollContainerId: string.Empty,
scrollOffset: 0,
headerId: string.Empty,
footerId: string.Empty,
setCalloutWidth: true,
preserveCalloutWidth: false,
maxWindowWidth: 0);
}

private async Task HandleOnChange(ChangeEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,20 +607,23 @@ private async Task ToggleCallout()
{
if (IsEnabled is false || IsDisposed) return;

await _js.BitCalloutToggleCallout(_dotnetObj,
_overflowAnchorId,
null,
_calloutId,
null,
_isCalloutOpen,
BitResponsiveMode.None,
BitDropDirection.TopAndBottom,
Dir is BitDir.Rtl,
_scrollContainerId,
0,
"",
"",
false);
await _js.BitCalloutToggleCallout(
dotnetObj: _dotnetObj,
componentId: _overflowAnchorId,
component: null,
calloutId: _calloutId,
callout: null,
isCalloutOpen: _isCalloutOpen,
responsiveMode: BitResponsiveMode.None,
dropDirection: BitDropDirection.TopAndBottom,
isRtl: Dir is BitDir.Rtl,
scrollContainerId: _scrollContainerId,
scrollOffset: 0,
headerId: "",
footerId: "",
setCalloutWidth: false,
preserveCalloutWidth: false,
maxWindowWidth: 0);
}

private string GetItemKey(TItem item, string defaultKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ await _js.BitCalloutToggleCallout(
headerId: "",
footerId: "",
setCalloutWidth: false,
preserveCalloutWidth: false,
maxWindowWidth: 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ public partial class BitCallout : BitComponentBase
[Parameter] public EventCallback<bool> OnToggle { get; set; }

/// <summary>
/// Force the callout to set its content container width while openning it based on the available space and actual content.
/// Forces the callout to preserve its component's original width.
/// </summary>
[Parameter] public bool PreserveCalloutWidth { get; set; }

/// <summary>
/// Forces the callout to set its content container width while openning based on the available space and actual content.
/// </summary>
[Parameter] public bool SetCalloutWidth { get; set; }

Expand Down Expand Up @@ -200,6 +205,7 @@ await _js.BitCalloutToggleCallout(
headerId: HeaderId ?? "",
footerId: FooterId ?? "",
setCalloutWidth: SetCalloutWidth,
preserveCalloutWidth: PreserveCalloutWidth,
maxWindowWidth: MaxWindowWidth ?? 0);

await OnToggle.InvokeAsync(IsOpen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ internal static class CalloutsJsRuntimeExtensions
string headerId,
string footerId,
bool setCalloutWidth,
int maxWindowWidth = 0) where T : class
bool preserveCalloutWidth,
int maxWindowWidth) where T : class
{
return jsRuntime.Invoke<bool>("BitBlazorUI.Callouts.toggle",
dotnetObj,
Expand All @@ -37,6 +38,7 @@ internal static class CalloutsJsRuntimeExtensions
headerId,
footerId,
setCalloutWidth,
preserveCalloutWidth,
maxWindowWidth);
}

Expand Down
6 changes: 6 additions & 0 deletions src/BlazorUI/Bit.BlazorUI/Scripts/Callouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace BitBlazorUI {
headerId: string,
footerId: string,
setCalloutWidth: boolean,
preserveCalloutWidth: boolean,
maxWindowWidth: number,
) {
component ??= document.getElementById(componentId);
Expand Down Expand Up @@ -94,6 +95,11 @@ namespace BitBlazorUI {
callout.style.width = width + 'px';
calloutWidth = width;
}
if (preserveCalloutWidth) {
let width = Math.min(componentWidth, calloutWidth);
callout.style.width = width + 'px';
calloutWidth = width;
}

if (windowWidth < Utils.MAX_MOBILE_WIDTH && responsiveMode) {
callout.style.opacity = '1';
Expand Down
Loading
Loading