Skip to content

A Swiss Army knife for developers.

[Dev 2.0] Added DropDownList, ComboBox and improved ScrollViewer (#856)

Etienne BAUDOUXa4551eb79dbc
diff --git a/src/app/dev/DevToys.Blazor/Assets/javascript/popover.js b/src/app/dev/DevToys.Blazor/Assets/javascript/popover.js
index 390427aa3..5dbbfb68e 100644
--- a/src/app/dev/DevToys.Blazor/Assets/javascript/popover.js
+++ b/src/app/dev/DevToys.Blazor/Assets/javascript/popover.js
@@ -382,6 +382,44 @@ class Popover {
Popover.placePopover(popoverNode);
}
}
+Popover.flipClassReplacements = {
+ "top": {
+ "popover-top-left": "popover-bottom-left",
+ "popover-top-center": "popover-bottom-center",
+ "popover-anchor-bottom-center": "popover-anchor-top-center",
+ "popover-top-right": "popover-bottom-right",
+ },
+ "left": {
+ "popover-top-left": "popover-top-right",
+ "popover-center-left": "popover-center-right",
+ "popover-anchor-center-right": "popover-anchor-center-left",
+ "popover-bottom-left": "popover-bottom-right",
+ },
+ "right": {
+ "popover-top-right": "popover-top-left",
+ "popover-center-right": "popover-center-left",
+ "popover-anchor-center-left": "popover-anchor-center-right",
+ "popover-bottom-right": "popover-bottom-left",
+ },
+ "bottom": {
+ "popover-bottom-left": "popover-top-left",
+ "popover-bottom-center": "popover-top-center",
+ "popover-anchor-top-center": "popover-anchor-bottom-center",
+ "popover-bottom-right": "popover-top-right",
+ },
+ "top-and-left": {
+ "popover-top-left": "popover-bottom-right",
+ },
+ "top-and-right": {
+ "popover-top-right": "popover-bottom-left",
+ },
+ "bottom-and-left": {
+ "popover-bottom-left": "popover-top-right",
+ },
+ "bottom-and-right": {
+ "popover-bottom-right": "popover-top-left",
+ },
+};
Popover.flipMargin = 0;
Popover.map = {};
Popover.contentObserver = null;
diff --git a/src/app/dev/DevToys.Blazor/Assets/javascript/popover.ts b/src/app/dev/DevToys.Blazor/Assets/javascript/popover.ts
index 7c9d40504..534ff2fd7 100644
--- a/src/app/dev/DevToys.Blazor/Assets/javascript/popover.ts
+++ b/src/app/dev/DevToys.Blazor/Assets/javascript/popover.ts
@@ -12,7 +12,7 @@ class PopoverPosition {
}
class Popover {
- private static flipClassReplacements: {
+ private static flipClassReplacements = {
"top": {
"popover-top-left": "popover-bottom-left",
"popover-top-center": "popover-bottom-center",
diff --git a/src/app/dev/DevToys.Blazor/Assets/sass/theme/windows/dark.scss b/src/app/dev/DevToys.Blazor/Assets/sass/theme/windows/dark.scss
index 032aefaf2..9044c2adb 100644
--- a/src/app/dev/DevToys.Blazor/Assets/sass/theme/windows/dark.scss
+++ b/src/app/dev/DevToys.Blazor/Assets/sass/theme/windows/dark.scss
@@ -130,17 +130,14 @@
--check-box-check-background-stroke-unchecked-pointer-over: var(--control-strong-stroke-default);
--check-box-check-background-stroke-unchecked-pressed: var(--control-strong-stroke-disabled);
--check-box-check-background-stroke-unchecked-disabled: var(--control-strong-stroke-disabled);
-
--check-box-check-background-stroke-checked: var(--accent-default);
--check-box-check-background-stroke-checked-pointer-over: var(--accent-secondary);
--check-box-check-background-stroke-checked-pressed: var(--accent-tertiary);
--check-box-check-background-stroke-checked-disabled: var(--control-strong-stroke-disabled);
-
--check-box-check-background-fill-unchecked: var(--control-alt-fill-color-secondary);
--check-box-check-background-fill-unchecked-pointer-over: var(--control-alt-fill-color-tertiary);
--check-box-check-background-fill-unchecked-pressed: var(--control-alt-fill-color-quarternary);
--check-box-check-background-fill-unchecked-disabled: var(--control-alt-fill-color-disabled);
-
--check-box-check-background-fill-checked: var(--accent-default);
--check-box-check-background-fill-checked-pointer-over: var(--accent-secondary);
--check-box-check-background-fill-checked-pressed: var(--accent-tertiary);
@@ -150,7 +147,6 @@
--check-box-check-glyph-foreground-unchecked-pointer-over: var(--text-on-accent-primary);
--check-box-check-glyph-foreground-unchecked-pressed: var(--text-on-accent-primary);
--check-box-check-glyph-foreground-unchecked-disabled: var(--text-on-accent-disabled);
-
--check-box-check-glyph-foreground-checked: var(--text-on-accent-primary);
--check-box-check-glyph-foreground-checked-pointer-over: var(--text-on-accent-primary);
--check-box-check-glyph-foreground-checked-pressed: var(--text-on-accent-secondary);
@@ -161,22 +157,18 @@
--toggle-switch-foreground-disabled: var(--text-fill-color-disabled);
--toggle-switch-on-stroke-thickness: 0px;
--toggle-switch-outer-border-stroke-thickness: 1px;
-
--toggle-switch-fill-off: var(--control-alt-fill-color-secondary);
--toggle-switch-fill-off-pointer-over: var(--control-alt-fill-color-tertiary);
--toggle-switch-fill-off-pressed: var(--control-alt-fill-color-quarternary);
--toggle-switch-fill-off-disabled: var(--control-alt-fill-color-disabled);
-
--toggle-switch-stroke-off: var(--control-strong-stroke-default);
--toggle-switch-stroke-off-pointer-over: var(--control-strong-stroke-default);
--toggle-switch-stroke-off-pressed: var(--control-strong-stroke-default);
--toggle-switch-stroke-off-disabled: var(--control-strong-stroke-disabled);
-
--toggle-switch-fill-on: var(--accent-default);
--toggle-switch-fill-on-pointer-over: var(--accent-secondary);
--toggle-switch-fill-on-pressed: var(--accent-tertiary);
--toggle-switch-fill-on-disabled: var(--accent-disabled);
-
--toggle-switch-stroke-on: var(--accent-default);
--toggle-switch-stroke-on-pointer-over: var(--accent-secondary);
--toggle-switch-stroke-on-pressed: var(--accent-tertiary);
@@ -186,7 +178,6 @@
--toggle-switch-knob-fill-off-pointer-over: var(--text-fill-color-secondary);
--toggle-switch-knob-fill-off-pressed: var(--text-fill-color-secondary);
--toggle-switch-knob-fill-off-disabled: var(--text-fill-color-disabled);
-
--toggle-switch-knob-fill-on: var(--text-on-accent-primary);
--toggle-switch-knob-fill-on-pointer-over: var(--text-on-accent-primary);
--toggle-switch-knob-fill-on-pressed: var(--text-on-accent-primary);
@@ -257,9 +248,9 @@
/* Scrollbars */
--scrollbar-track-background-color: transparent;
- --scrollbar-track-background-color-hover: rgba(44, 44, 44, 0.96);
- --scrollbar-thumb-border-color: transparent;
- --scrollbar-thumb-border-color-hover: rgba(44, 44, 44, 0.96);
- --scrollbar-thumb-background-color: rgba(255, 255, 255, 0.5442);
- --scrollbar-thumb-background-color-hover: rgba(255, 255, 255, 0.5442);
+ --scrollbar-track-background-color-hover: rgba(31, 31, 31, 0.9);
+ --scrollbar-thumb-border-color: rgba(85, 85, 85, 0.231);
+ --scrollbar-thumb-border-color-hover: rgba(183, 183, 183, 0.42);
+ --scrollbar-thumb-background-color: rgb(205, 205, 205);
+ --scrollbar-thumb-background-color-hover: rgb(218, 218, 218);
}
diff --git a/src/app/dev/DevToys.Blazor/Components/AutoSuggestBox/AutoSuggestBox.razor b/src/app/dev/DevToys.Blazor/Components/AutoSuggestBox/AutoSuggestBox.razor
index 2f872efe2..188f3b941 100644
--- a/src/app/dev/DevToys.Blazor/Components/AutoSuggestBox/AutoSuggestBox.razor
+++ b/src/app/dev/DevToys.Blazor/Components/AutoSuggestBox/AutoSuggestBox.razor
@@ -31,7 +31,8 @@
Items="@Items"
Context="item"
RaiseSelectionEventOnKeyboardNavigation="false"
- OnSelectedIndexChanged="OnSelectedIndexChanged">
+ UseNativeScrollBar="true"
+ SelectedIndexChanged="OnSelectedIndexChanged">
<ItemTemplate>
@ItemTemplate(item)
</ItemTemplate>
diff --git a/src/app/dev/DevToys.Blazor/Components/AutoSuggestBox/AutoSuggestBox.razor.cs b/src/app/dev/DevToys.Blazor/Components/AutoSuggestBox/AutoSuggestBox.razor.cs
index ee84a4633..090884d7b 100644
--- a/src/app/dev/DevToys.Blazor/Components/AutoSuggestBox/AutoSuggestBox.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/AutoSuggestBox/AutoSuggestBox.razor.cs
@@ -69,17 +69,17 @@ public partial class AutoSuggestBox<TElement> : StyledComponentBase, IDisposable
private void OnTextBoxKeyPress(KeyboardEventArgs ev)
{
- if (string.Equals(ev.Key, "Enter", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(ev.Code, "Enter", StringComparison.OrdinalIgnoreCase))
{
SubmitQuery();
}
else if (_showDropDown && _resultListBox is not null && Items is not null)
{
- if (string.Equals(ev.Key, "ArrowDown", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(ev.Code, "ArrowDown", StringComparison.OrdinalIgnoreCase))
{
_resultListBox.SelectNextItem();
}
- else if (string.Equals(ev.Key, "ArrowUp", StringComparison.OrdinalIgnoreCase))
+ else if (string.Equals(ev.Code, "ArrowUp", StringComparison.OrdinalIgnoreCase))
{
_resultListBox.SelectPreviousItem();
}
diff --git a/src/app/dev/DevToys.Blazor/Components/Button/Button.razor.scss b/src/app/dev/DevToys.Blazor/Components/Button/Button.razor.scss
index ba24cbe71..d1d6481a7 100644
--- a/src/app/dev/DevToys.Blazor/Components/Button/Button.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/Button/Button.razor.scss
@@ -15,6 +15,7 @@ button {
cursor: default;
border-radius: var(--control-corner-radius);
transition: 83ms ease background;
+ width: fit-content;
&:focus-visible {
box-shadow: var(--focus-stroke);
diff --git a/src/app/dev/DevToys.Blazor/Components/CheckBox/CheckBox.razor.cs b/src/app/dev/DevToys.Blazor/Components/CheckBox/CheckBox.razor.cs
index 7256bb901..1fd4904c4 100644
--- a/src/app/dev/DevToys.Blazor/Components/CheckBox/CheckBox.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/CheckBox/CheckBox.razor.cs
@@ -18,7 +18,7 @@ public partial class CheckBox : JSStyledComponentBase
/// Raised when the check box is toggled.
/// </summary>
[Parameter]
- public EventCallback<bool> OnCheckedChanged { get; set; }
+ public EventCallback<bool> IsCheckedChanged { get; set; }
internal ValueTask<bool> FocusAsync()
{
@@ -31,7 +31,7 @@ public partial class CheckBox : JSStyledComponentBase
if (value != IsChecked)
{
IsChecked = value;
- OnCheckedChanged.InvokeAsync(value);
+ IsCheckedChanged.InvokeAsync(value);
}
}
}
diff --git a/src/app/dev/DevToys.Blazor/Components/ComboBox/ComboBox.razor b/src/app/dev/DevToys.Blazor/Components/ComboBox/ComboBox.razor
new file mode 100644
index 000000000..91e03a192
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/ComboBox/ComboBox.razor
@@ -0,0 +1,99 @@
+@namespace DevToys.Blazor.Components
+@typeparam TElement
+@inherits SelectBase<TElement>
+
+<CascadingValue Value="this" IsFixed="false">
+ <div id=@Id
+ class="combo-box-with-header @(FinalCssClasses)"
+ style="@(Style)"
+ @attributes="AdditionalAttributes">
+
+ @if (!string.IsNullOrWhiteSpace(Header))
+ {
+ <TextBlock Appearance="TextBlockAppearance.Body" Class="combo-box-header" Text="@Header" />
+ }
+
+ <Button @ref="_button"
+ Class="@($"combo-box-button {FinalCssClasses}")"
+ Appearance="ButtonAppearance.Neutral"
+ IsEnabled="@IsEnabled"
+ @onclick="@ToggleDropDown">
+ @if (SelectedItem is not null)
+ {
+ @ItemTemplate(SelectedItem)
+ }
+ <div class="arrow-down-icon">
+ <FontIcon Glyph="@('\uf2a6')" />
+ </div>
+
+ <Popover Open="_isOpen"
+ AnchorOrigin="Origin.CenterCenter"
+ TransformOrigin="Origin.CenterCenter"
+ RelativeWidth="false"
+ @ontouchend:stopPropagation>
+ <CascadingValue Value="@this" IsFixed="true">
+ <FocusTrapper Style="display: contents;"
+ OnEscapeKeyPressed="OnEscapeKeyPressed"
+ @onfocusout="OnEscapeKeyPressed">
+ <ScrollViewer Orientation="Orientation.Vertical"
+ IsEnabled="@IsEnabled"
+ Class="@FinalCssClasses"
+ Style="@Style"
+ UseNativeScrollBar="true"
+ AdditionalAttributes="@AdditionalAttributes">
+ <ul @ref="_listBox"
+ role="menu"
+ class="combo-box-list-box"
+ tabindex="0"
+ @onkeydown="OnKeyDown">
+
+ @if (Virtualize)
+ {
+ <Virtualize Items="@Items" Context="item">
+ @RenderItem(item)
+ </Virtualize>
+ }
+ else if (Items is not null)
+ {
+ foreach (var item in Items)
+ {
+ @RenderItem(item)
+ }
+ }
+
+ </ul>
+ </ScrollViewer>
+ </FocusTrapper>
+ </CascadingValue>
+ </Popover>
+ </Button>
+ </div>
+</CascadingValue>
+
+@code {
+ private RenderFragment<TElement> RenderItem { get; set; } = default!;
+
+ protected override Task OnInitializedAsync()
+ {
+ RenderItem = (item) => __builder =>
+ {
+ @if (!OverrideDefaultItemTemplate)
+ {
+ <ListBoxItem OnSelected="OnItemClick"
+ IsSelected="object.ReferenceEquals(item, SelectedItem)"
+ Item="item">
+ @ItemTemplate(item)
+ </ListBoxItem>
+ }
+ else
+ {
+ <div class="@((object.ReferenceEquals(item, SelectedItem) ? "selected" : string.Empty))"
+ @onclick="@(() => OnItemClick(item))">
+ @ItemTemplate(item)
+ </div>
+ }
+ };
+
+ return base.OnInitializedAsync();
+ }
+}
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/ComboBox/ComboBox.razor.cs b/src/app/dev/DevToys.Blazor/Components/ComboBox/ComboBox.razor.cs
new file mode 100644
index 000000000..b580f235b
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/ComboBox/ComboBox.razor.cs
@@ -0,0 +1,83 @@
+using DevToys.Blazor.Core.Services;
+using Microsoft.AspNetCore.Components.Web;
+
+namespace DevToys.Blazor.Components;
+
+public partial class ComboBox<TElement> : SelectBase<TElement> where TElement : class
+{
+ private bool _isOpen;
+ private ElementReference? _listBox;
+ private Button? _button;
+
+ public ComboBox()
+ {
+ RaiseSelectionEventOnKeyboardNavigation = false;
+ }
+
+ [Inject]
+ internal ContextMenuService ContextMenuService { get; set; } = default!;
+
+ [Parameter]
+ public string? Header { get; set; }
+
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ await base.OnAfterRenderAsync(firstRender);
+
+ if (_isOpen && _listBox is not null)
+ {
+ await JSRuntime.InvokeVoidWithErrorHandlingAsync("devtoys.DOM.setFocus", _listBox);
+ }
+ }
+
+ private void ContextMenuService_CloseContextMenuRequested(object? sender, EventArgs e)
+ {
+ CloseDropDown(null);
+ }
+
+ private void ToggleDropDown(MouseEventArgs ev)
+ {
+ if (_isOpen)
+ {
+ CloseDropDown(ev);
+ }
+ else
+ {
+ OpenDropDown(ev);
+ }
+ }
+
+ private void OpenDropDown(MouseEventArgs ev)
+ {
+ if (IsEnabled && ContextMenuService.TryOpenContextMenu())
+ {
+ ContextMenuService.CloseContextMenuRequested += ContextMenuService_CloseContextMenuRequested;
+ _isOpen = true;
+ StateHasChanged();
+ }
+ }
+
+ private void CloseDropDown(MouseEventArgs? ev)
+ {
+ ContextMenuService.CloseContextMenuRequested -= ContextMenuService_CloseContextMenuRequested;
+ ContextMenuService.CloseContextMenu();
+ _isOpen = false;
+ StateHasChanged();
+
+ _ = JSRuntime.InvokeVoidWithErrorHandlingAsync("devtoys.DOM.setFocus", _button);
+ }
+
+ private void OnEscapeKeyPressed()
+ {
+ if (_isOpen)
+ {
+ CloseDropDown(null);
+ }
+ }
+
+ protected override void OnItemSelected()
+ {
+ base.OnItemSelected();
+ CloseDropDown(null);
+ }
+}
diff --git a/src/app/dev/DevToys.Blazor/Components/ComboBox/ComboBox.razor.scss b/src/app/dev/DevToys.Blazor/Components/ComboBox/ComboBox.razor.scss
new file mode 100644
index 000000000..e5c1823d2
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/ComboBox/ComboBox.razor.scss
@@ -0,0 +1,40 @@
+@use "../../Assets/sass/devtoys" as *;
+
+.combo-box {
+ @include typography-body;
+
+ &-with-header {
+ display: inline-flex;
+ flex-direction: column;
+ position: relative;
+
+ .combo-box-header {
+ margin-bottom: 4px;
+ }
+ }
+
+ &-button {
+ .arrow-down-icon {
+ height: 16px;
+ width: 16px;
+ padding-top: 4px;
+ margin-left: 4px;
+ transition-duration: 0.2s;
+ transition-property: transform;
+ color: currentColor !important;
+ }
+
+ &:active {
+ .arrow-down-icon {
+ transform: translateY(2px);
+ color: currentColor !important;
+ }
+ }
+ }
+
+ &-list-box {
+ margin: 0px;
+ padding: 0px;
+ max-height: 400px;
+ }
+}
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenu.razor b/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenu.razor
index 082fab1c6..e9b58aeba 100644
--- a/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenu.razor
+++ b/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenu.razor
@@ -5,8 +5,8 @@
<div id="@Id"
Class="context-menu @(FinalCssClasses)"
Style="@Style"
- @attributes="AdditionalAttributes"
- @oncontextmenu:preventDefault="true">
+@attributes="AdditionalAttributes"
+@oncontextmenu:preventDefault="true">
<CascadingValue Value="this" IsFixed="true">
<div @oncontextmenu="@ToggleMenuAsync"
disabled="@(!IsEnabled)"
@@ -32,7 +32,8 @@
OverrideDefaultItemTemplate="true"
Virtualize="false"
RaiseSelectionEventOnKeyboardNavigation="false"
- OnSelectedIndexChanged="OnContextMenuItemSelected"
+ SelectedIndexChanged="OnContextMenuItemSelected"
+ UseNativeScrollBar="true"
Class="context-menu-list-box"
@onkeydown="OnListBoxKeyDown">
<ItemTemplate>
diff --git a/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenu.razor.cs b/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenu.razor.cs
index 1cb2c4c3e..1af5c535c 100644
--- a/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenu.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenu.razor.cs
@@ -109,7 +109,7 @@ public partial class ContextMenu : StyledComponentBase
private void OnListBoxKeyDown(KeyboardEventArgs ev)
{
- if (_listBox is not null && string.Equals(ev.Key, "Tab", StringComparison.OrdinalIgnoreCase))
+ if (_listBox is not null && string.Equals(ev.Code, "Tab", StringComparison.OrdinalIgnoreCase))
{
_listBox.SelectNextItem();
}
diff --git a/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenu.razor.scss b/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenu.razor.scss
index a441cb3ba..ef602aebc 100644
--- a/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenu.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenu.razor.scss
@@ -8,8 +8,14 @@
}
.context-menu-list-box {
- .list-box:focus, .list-box:focus-visible, .list-box:focus-within {
- outline: none;
+ .list-box {
+ display: inline-block;
+
+ &:focus,
+ &:focus-visible,
+ &:focus-within {
+ outline: none;
+ }
}
.context-menu-item {
@@ -18,11 +24,18 @@
border-radius: var(--control-corner-radius);
background-color: var(--context-menu-item-background);
color: var(--context-menu-item-foreground);
- display: flex;
- gap: 8px;
margin: 3px;
+ display: grid;
+ grid-template-columns: 16px 1fr auto;
+ grid-template-rows: 1fr;
+ gap: 0px 12px;
+ grid-template-areas:
+ "icon title keyboard-shortcut";
- &:hover, &:focus, &:focus-visible, &.selected {
+ &:hover,
+ &:focus,
+ &:focus-visible,
+ &.selected {
outline: none;
background-color: var(--context-menu-item-background-pointer-over);
}
@@ -46,6 +59,7 @@
}
.icon-container {
+ grid-area: icon;
height: 20px;
width: 20px;
display: block;
@@ -58,14 +72,15 @@
}
.text {
- flex-grow: 1;
+ grid-area: title;
align-self: center;
- margin-right: 32px;
}
.keyboard-accelerator {
+ grid-area: keyboard-shortcut;
color: var(--context-menu-item-key-accelerator-foreground);
align-self: center;
+ margin-left: 32px;
}
}
}
diff --git a/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenuItem.cs b/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenuItem.cs
index f77b974fd..3299503bb 100644
--- a/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenuItem.cs
+++ b/src/app/dev/DevToys.Blazor/Components/ContextMenu/ContextMenuItem.cs
@@ -1,16 +1,6 @@
namespace DevToys.Blazor.Components;
-public sealed class ContextMenuItem
+public sealed class ContextMenuItem : DropDownListItem
{
- internal string? Text { get; set; }
-
- internal char IconGlyph { get; set; }
-
- internal string IconFontFamily { get; set; } = "FluentSystemIcons";
-
internal string? KeyboardShortcut { get; set; } // TODO: Actually handle keyboard shortcuts?
-
- internal bool IsEnabled { get; set; } = true;
-
- internal EventCallback OnClick { get; set; }
}
diff --git a/src/app/dev/DevToys.Blazor/Components/DropDownList/DropDownList.razor b/src/app/dev/DevToys.Blazor/Components/DropDownList/DropDownList.razor
new file mode 100644
index 000000000..37eafffaf
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/DropDownList/DropDownList.razor
@@ -0,0 +1,64 @@
+@namespace DevToys.Blazor.Components
+@inherits StyledComponentBase
+
+<CascadingValue Value="this" IsFixed="true">
+ <div id=@Id
+ class="drop-down-list-with-header @(FinalCssClasses)"
+ style="@(Style)"
+ @attributes="AdditionalAttributes">
+
+ @if (!string.IsNullOrWhiteSpace(Header))
+ {
+ <TextBlock Appearance="TextBlockAppearance.Body" Class="drop-down-list-header" Text="@Header" />
+ }
+
+ <Button Class="@($"drop-down-list-button {FinalCssClasses}")"
+ Appearance="ButtonAppearance.Neutral"
+ IsEnabled="@IsEnabled"
+ @onclick="@ToggleDropDown">
+ @ChildContent
+ <div class="arrow-down-icon">
+ <FontIcon Glyph="@('\uf2a6')"/>
+ </div>
+
+ <Popover Open="_isOpen"
+ AnchorOrigin="Origin.BottomCenter"
+ TransformOrigin="Origin.TopCenter"
+ RelativeWidth="false"
+ Class="drop-down-list-drop-down"
+ @ontouchend:stopPropagation>
+ <CascadingValue Value="@this" IsFixed="true">
+ <FocusTrapper Style="display: contents;"
+ OnEscapeKeyPressed="OnEscapeKeyPressed"
+ @onfocusout="OnEscapeKeyPressed">
+ <ListBox @ref="_listBox"
+ Items="Items"
+ Context="item"
+ Role="menu"
+ OverrideDefaultItemTemplate="true"
+ Virtualize="true"
+ RaiseSelectionEventOnKeyboardNavigation="false"
+ SelectedIndexChanged="OnDropDowlListItemSelected"
+ UseNativeScrollBar="true"
+ Class="context-menu-list-box"
+ Style="max-height: 400px">
+ <ItemTemplate>
+ <li role="menuitem"
+ class="@($"context-menu-item {(_listBox!.SelectedItem == item ? "selected" : string.Empty)} {(item.IsEnabled ? string.Empty : "disabled")}")"
+ aria-disabled="@(item.IsEnabled ? string.Empty : "true")">
+ <div class="icon-container">
+ <FontIcon Glyph="@item.IconGlyph" FontFamily="@item.IconFontFamily" />
+ </div>
+ <TextBlock Class="text"
+ NoWrap="true"
+ Text="@item.Text" />
+ </li>
+ </ItemTemplate>
+ </ListBox>
+ </FocusTrapper>
+ </CascadingValue>
+ </Popover>
+ </Button>
+
+ </div>
+</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/DropDownList/DropDownList.razor.cs b/src/app/dev/DevToys.Blazor/Components/DropDownList/DropDownList.razor.cs
new file mode 100644
index 000000000..dc6398358
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/DropDownList/DropDownList.razor.cs
@@ -0,0 +1,91 @@
+using DevToys.Api;
+using DevToys.Blazor.Core.Services;
+using Microsoft.AspNetCore.Components.Web;
+
+namespace DevToys.Blazor.Components;
+
+public partial class DropDownList : StyledComponentBase
+{
+ private bool _isOpen;
+ private ListBox<DropDownListItem>? _listBox;
+
+ [Inject]
+ internal ContextMenuService ContextMenuService { get; set; } = default!;
+
+ /// <summary>
+ /// Gets or sets the content to render in the button.
+ /// </summary>
+ [Parameter]
+ public RenderFragment? ChildContent { get; set; }
+
+ [Parameter]
+ public string? Header { get; set; }
+
+ /// <summary>
+ /// Gets or sets the menu items to display in the drop down list.
+ /// </summary>
+ [Parameter]
+ public ICollection<DropDownListItem>? Items { get; set; }
+
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ await base.OnAfterRenderAsync(firstRender);
+
+ if (_isOpen && _listBox is not null)
+ {
+ await _listBox.FocusAsync();
+ }
+ }
+
+ private void ContextMenuService_CloseContextMenuRequested(object? sender, EventArgs e)
+ {
+ CloseDropDown(null);
+ }
+
+ private void ToggleDropDown(MouseEventArgs ev)
+ {
+ if (_isOpen)
+ {
+ CloseDropDown(ev);
+ }
+ else
+ {
+ OpenDropDown(ev);
+ }
+ }
+
+ private void OpenDropDown(MouseEventArgs ev)
+ {
+ if (IsEnabled && ContextMenuService.TryOpenContextMenu())
+ {
+ ContextMenuService.CloseContextMenuRequested += ContextMenuService_CloseContextMenuRequested;
+ _isOpen = true;
+ StateHasChanged();
+ }
+ }
+
+ private void CloseDropDown(MouseEventArgs? ev)
+ {
+ ContextMenuService.CloseContextMenuRequested -= ContextMenuService_CloseContextMenuRequested;
+ ContextMenuService.CloseContextMenu();
+ _isOpen = false;
+ StateHasChanged();
+ }
+
+ private void OnEscapeKeyPressed()
+ {
+ if (_isOpen)
+ {
+ CloseDropDown(null);
+ }
+ }
+
+ private void OnDropDowlListItemSelected(int itemIndex)
+ {
+ if (_listBox is not null && _listBox.SelectedItem is not null && _listBox.SelectedItem.IsEnabled)
+ {
+ CloseDropDown(null);
+ _listBox.SelectedItem.OnClick.InvokeAsync().Forget();
+ }
+ }
+}
diff --git a/src/app/dev/DevToys.Blazor/Components/DropDownList/DropDownList.razor.scss b/src/app/dev/DevToys.Blazor/Components/DropDownList/DropDownList.razor.scss
new file mode 100644
index 000000000..78e1ba7c9
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/DropDownList/DropDownList.razor.scss
@@ -0,0 +1,42 @@
+@use "../../Assets/sass/devtoys" as *;
+
+.drop-down-list {
+ @include typography-body;
+
+ &-with-header {
+ display: inline-flex;
+ flex-direction: column;
+ position: relative;
+
+ .drop-down-list-header {
+ margin-bottom: 4px;
+ }
+ }
+
+ &-button {
+ .arrow-down-icon {
+ height: 16px;
+ width: 16px;
+ padding-top: 4px;
+ margin-left: 4px;
+ transition-duration: 0.2s;
+ transition-property: transform;
+ color: currentColor !important;
+ }
+
+ &:active {
+ .arrow-down-icon {
+ transform: translateY(2px);
+ color: currentColor !important;
+ }
+ }
+ }
+}
+
+.drop-down-list-drop-down {
+ margin-top: 4px !important;
+
+ &[data-popover-flip="flipped"] {
+ margin-top: -4px !important;
+ }
+}
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/DropDownList/DropDownListItem.cs b/src/app/dev/DevToys.Blazor/Components/DropDownList/DropDownListItem.cs
new file mode 100644
index 000000000..1c1ba8006
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/DropDownList/DropDownListItem.cs
@@ -0,0 +1,14 @@
+namespace DevToys.Blazor.Components;
+
+public class DropDownListItem
+{
+ internal string? Text { get; set; }
+
+ internal char IconGlyph { get; set; }
+
+ internal string IconFontFamily { get; set; } = "FluentSystemIcons";
+
+ internal bool IsEnabled { get; set; } = true;
+
+ internal EventCallback OnClick { get; set; }
+}
diff --git a/src/app/dev/DevToys.Blazor/Components/FocusTrapper/FocusTrapper.razor.cs b/src/app/dev/DevToys.Blazor/Components/FocusTrapper/FocusTrapper.razor.cs
index 5ca29fbc2..44611975e 100644
--- a/src/app/dev/DevToys.Blazor/Components/FocusTrapper/FocusTrapper.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/FocusTrapper/FocusTrapper.razor.cs
@@ -38,7 +38,7 @@ public partial class FocusTrapper : JSStyledComponentBase
private void OnKeyDown(KeyboardEventArgs ev)
{
- if (OnEscapeKeyPressed.HasDelegate && string.Equals(ev.Key, "Escape", StringComparison.OrdinalIgnoreCase))
+ if (OnEscapeKeyPressed.HasDelegate && string.Equals(ev.Code, "Escape", StringComparison.OrdinalIgnoreCase))
{
OnEscapeKeyPressed.InvokeAsync();
}
diff --git a/src/app/dev/DevToys.Blazor/Components/FontIcon/FontIcon.razor.scss b/src/app/dev/DevToys.Blazor/Components/FontIcon/FontIcon.razor.scss
index 21b5d6498..15c5ec36c 100644
--- a/src/app/dev/DevToys.Blazor/Components/FontIcon/FontIcon.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/FontIcon/FontIcon.razor.scss
@@ -1,6 +1,6 @@
.font-icon {
display: block;
- color: currentColor;
+ color: inherit;
user-select: none;
-webkit-user-select: none;
diff --git a/src/app/dev/DevToys.Blazor/Components/GridView/GridView.razor.js b/src/app/dev/DevToys.Blazor/Components/GridView/GridView.razor.js
index 0ab4f0d15..281c318e7 100644
--- a/src/app/dev/DevToys.Blazor/Components/GridView/GridView.razor.js
+++ b/src/app/dev/DevToys.Blazor/Components/GridView/GridView.razor.js
@@ -1,11 +1,18 @@
export function initializeStickyHeaders(id) {
const gridView = document.getElementById(id);
- gridView.addEventListener("scroll", onGridViewScroll);
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore
+ const simpleBar = SimpleBar.instances.get(gridView);
+ simpleBar.getScrollElement().addEventListener("scroll", onGridViewScroll);
}
export function initializeDynamicItemSize(id, itemMinWidth) {
- const gridView = document.getElementById(id);
+ let gridView = document.getElementById(id);
const gridViewBounds = gridView.getBoundingClientRect();
fitGridViewItemsToContainer(gridView, gridViewBounds, itemMinWidth);
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore
+ const simpleBar = SimpleBar.instances.get(gridView);
+ gridView = simpleBar.getScrollElement();
// On grid view resize
const resizeObserver = new ResizeObserver((gridViews) => {
fitGridViewItemsToContainer(gridViews[0].target, gridViews[0].contentRect, itemMinWidth);
@@ -40,8 +47,11 @@ function onGridViewScroll(ev) {
// Calculate the best size items in the grid view should take in order to fill
// as much space possible while having as many columns at possible.
function fitGridViewItemsToContainer(gridView, gridViewBounds, itemMinWidth) {
+ const gridViewContentContainerStyle = getComputedStyle(gridView.getElementsByClassName("simplebar-content")[0]);
const newGridViewContentSize = gridViewBounds;
- const gridViewWidth = newGridViewContentSize.width;
+ const gridViewWidth = newGridViewContentSize.width
+ - parseInt(gridViewContentContainerStyle.paddingLeft)
+ - parseInt(gridViewContentContainerStyle.paddingRight);
const groups = gridView.querySelectorAll(".grid-view-group");
if (groups.length > 0) {
// Calculating the number of columns based on the width of the page
diff --git a/src/app/dev/DevToys.Blazor/Components/GridView/GridView.razor.ts b/src/app/dev/DevToys.Blazor/Components/GridView/GridView.razor.ts
index e8c943cf8..cdb1dc21f 100644
--- a/src/app/dev/DevToys.Blazor/Components/GridView/GridView.razor.ts
+++ b/src/app/dev/DevToys.Blazor/Components/GridView/GridView.razor.ts
@@ -1,14 +1,21 @@
export function initializeStickyHeaders(id: string): void {
const gridView = document.getElementById(id);
-
- gridView.addEventListener("scroll", onGridViewScroll);
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore
+ const simpleBar = SimpleBar.instances.get(gridView);
+ simpleBar.getScrollElement().addEventListener("scroll", onGridViewScroll);
}
export function initializeDynamicItemSize(id: string, itemMinWidth: number): void {
- const gridView = document.getElementById(id);
+ let gridView = document.getElementById(id);
const gridViewBounds = gridView.getBoundingClientRect();
fitGridViewItemsToContainer(gridView, gridViewBounds, itemMinWidth);
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore
+ const simpleBar = SimpleBar.instances.get(gridView);
+ gridView = simpleBar.getScrollElement();
+
// On grid view resize
const resizeObserver = new ResizeObserver((gridViews) => {
fitGridViewItemsToContainer(gridViews[0].target as HTMLElement, gridViews[0].contentRect, itemMinWidth);
@@ -50,8 +57,12 @@ function onGridViewScroll(ev: Event): void {
// Calculate the best size items in the grid view should take in order to fill
// as much space possible while having as many columns at possible.
function fitGridViewItemsToContainer(gridView: HTMLElement, gridViewBounds: DOMRectReadOnly, itemMinWidth: number): void {
+ const gridViewContentContainerStyle = getComputedStyle(gridView.getElementsByClassName("simplebar-content")[0]);
const newGridViewContentSize = gridViewBounds;
- const gridViewWidth = newGridViewContentSize.width;
+ const gridViewWidth
+ = newGridViewContentSize.width
+ - parseInt(gridViewContentContainerStyle.paddingLeft)
+ - parseInt(gridViewContentContainerStyle.paddingRight);
const groups = gridView.querySelectorAll(".grid-view-group");
diff --git a/src/app/dev/DevToys.Blazor/Components/ListBox/ListBox.razor b/src/app/dev/DevToys.Blazor/Components/ListBox/ListBox.razor
index fead02f44..1ff703b19 100644
--- a/src/app/dev/DevToys.Blazor/Components/ListBox/ListBox.razor
+++ b/src/app/dev/DevToys.Blazor/Components/ListBox/ListBox.razor
@@ -1,11 +1,12 @@
@namespace DevToys.Blazor.Components
-@inherits JSStyledComponentBase
@typeparam TElement
+@inherits SelectBase<TElement>
<ScrollViewer Orientation="Orientation.Vertical"
IsEnabled="@IsEnabled"
Class="@FinalCssClasses"
Style="@Style"
+ UseNativeScrollBar="@UseNativeScrollBar"
AdditionalAttributes="@AdditionalAttributes">
<ul @ref="Element"
role="@Role"
@@ -48,7 +49,7 @@
else
{
<div class="@((object.ReferenceEquals(item, SelectedItem) ? "selected" : string.Empty))"
- @onclick="@(() => OnItemClick(item))">
+ @onclick="@(() => OnItemClick(item))">
@ItemTemplate(item)
</div>
}
diff --git a/src/app/dev/DevToys.Blazor/Components/ListBox/ListBox.razor.cs b/src/app/dev/DevToys.Blazor/Components/ListBox/ListBox.razor.cs
index c19211959..426077215 100644
--- a/src/app/dev/DevToys.Blazor/Components/ListBox/ListBox.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/ListBox/ListBox.razor.cs
@@ -1,216 +1,15 @@
-using System.Collections.Specialized;
-using Microsoft.AspNetCore.Components.Web;
+namespace DevToys.Blazor.Components;
-namespace DevToys.Blazor.Components;
-
-public partial class ListBox<TElement> : JSStyledComponentBase where TElement : class
+public partial class ListBox<TElement> : SelectBase<TElement> where TElement : class
{
- private int _oldSelectedIndex;
-
- [Parameter]
- public ICollection<TElement>? Items { get; set; }
-
- [Parameter]
- public RenderFragment<TElement> ItemTemplate { get; set; } = default!;
-
- [Parameter]
- public int SelectedIndex { get; set; } = -1;
-
- [Parameter]
- public EventCallback<int> OnSelectedIndexChanged { get; set; }
-
[Parameter]
public string Role { get; set; } = "listbox";
[Parameter]
- public bool OverrideDefaultItemTemplate { get; set; }
-
- [Parameter]
- public bool Virtualize { get; set; } = true;
-
- [Parameter]
- public bool RaiseSelectionEventOnKeyboardNavigation { get; set; } = true;
-
- internal TElement? SelectedItem { get; private set; }
+ public bool UseNativeScrollBar { get; set; }
internal ValueTask<bool> FocusAsync()
{
return JSRuntime.InvokeVoidWithErrorHandlingAsync("devtoys.DOM.setFocus", Element);
}
- internal void SelectNextItem()
- {
- if (Items is not null)
- {
- if (SelectedIndex == -1 || SelectedIndex == Items.Count - 1)
- {
- SetSelectedIndex(0, raiseEvent: RaiseSelectionEventOnKeyboardNavigation);
- }
- else
- {
- SetSelectedIndex(SelectedIndex + 1, raiseEvent: RaiseSelectionEventOnKeyboardNavigation);
- }
- }
- }
-
- internal void SelectPreviousItem()
- {
- if (Items is not null)
- {
- if (SelectedIndex == -1 || SelectedIndex == 0)
- {
- SetSelectedIndex(Items.Count - 1, raiseEvent: RaiseSelectionEventOnKeyboardNavigation);
- }
- else
- {
- SetSelectedIndex(SelectedIndex - 1, raiseEvent: RaiseSelectionEventOnKeyboardNavigation);
- }
- }
- }
-
- internal void SetSelectedIndex(int index)
- {
- SetSelectedIndex(index, raiseEvent: false);
- }
-
- internal void SetSelectedItem(TElement? item)
- {
- SetSelectedItem(item, raiseEvent: false);
- }
-
- public override ValueTask DisposeAsync()
- {
- if (Items is INotifyCollectionChanged notifyCollection)
- {
- notifyCollection.CollectionChanged -= OnItemsChanged;
- }
- return base.DisposeAsync();
- }
-
- protected override void OnParametersSet()
- {
- base.OnParametersSet();
-
- if (_oldSelectedIndex != SelectedIndex)
- {
- SetSelectedIndex(SelectedIndex, raiseEvent: false);
- }
- }
-
- protected override void OnAfterRender(bool firstRender)
- {
- base.OnAfterRender(firstRender);
-
- if (firstRender)
- {
- if (Items is INotifyCollectionChanged notifyCollection)
- {
- notifyCollection.CollectionChanged += OnItemsChanged;
- }
- }
- }
-
- private void SetSelectedIndex(int index, bool raiseEvent)
- {
- if (index >= Items?.Count)
- {
- ThrowHelper.ThrowArgumentOutOfRangeException(nameof(index));
- }
-
- SelectedIndex = index;
- _oldSelectedIndex = index;
- if (index > -1)
- {
- Guard.IsNotNull(Items);
- SelectedItem = Items.ElementAt(index);
- }
- else
- {
- SelectedItem = default;
- }
-
- if (raiseEvent)
- {
- RaiseOnSelectedIndexChanged();
- }
-
- StateHasChanged();
- }
-
- private void SetSelectedItem(TElement? item, bool raiseEvent)
- {
- Guard.IsNotNull(Items);
- if (item == SelectedItem)
- {
- return;
- }
- else if (item is null)
- {
- SetSelectedIndex(-1, raiseEvent);
- }
- else if (Items is IList<TElement> itemsList)
- {
- int itemIndex = itemsList.IndexOf(item);
- SetSelectedIndex(itemIndex, raiseEvent);
- }
- else
- {
- int i = 0;
- foreach (TElement childItem in Items)
- {
- if (object.ReferenceEquals(childItem, item))
- {
- SetSelectedIndex(i, raiseEvent);
- return;
- }
- i++;
- }
-
- SetSelectedIndex(-1, raiseEvent);
- }
- }
-
- private void RaiseOnSelectedIndexChanged()
- {
- if (OnSelectedIndexChanged.HasDelegate)
- {
- OnSelectedIndexChanged.InvokeAsync(SelectedIndex);
- }
- }
-
- private void OnItemsChanged(object? sender, NotifyCollectionChangedEventArgs e)
- {
- SetSelectedItem(SelectedItem, raiseEvent: false);
- }
-
- private void OnItemClick(object? selectedItem)
- {
- SetSelectedItem(selectedItem as TElement, raiseEvent: true);
- }
-
- private void OnKeyDown(KeyboardEventArgs ev)
- {
- if (Items is not null && Items.Count > 0)
- {
- if (string.Equals(ev.Key, "Enter", StringComparison.OrdinalIgnoreCase))
- {
- RaiseOnSelectedIndexChanged();
- }
- else if (string.Equals(ev.Key, "ArrowDown", StringComparison.OrdinalIgnoreCase))
- {
- SelectNextItem();
- }
- else if (string.Equals(ev.Key, "ArrowUp", StringComparison.OrdinalIgnoreCase))
- {
- SelectPreviousItem();
- }
- else if (string.Equals(ev.Key, "Home", StringComparison.OrdinalIgnoreCase))
- {
- SetSelectedIndex(Math.Min(0, Items.Count - 1));
- }
- else if (string.Equals(ev.Key, "End", StringComparison.OrdinalIgnoreCase))
- {
- SetSelectedIndex(Items.Count - 1);
- }
- }
- }
}
diff --git a/src/app/dev/DevToys.Blazor/Components/ListBox/ListBoxItem.razor.scss b/src/app/dev/DevToys.Blazor/Components/ListBox/ListBoxItem.razor.scss
index b82d6f773..919c831b0 100644
--- a/src/app/dev/DevToys.Blazor/Components/ListBox/ListBoxItem.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/ListBox/ListBoxItem.razor.scss
@@ -1,7 +1,7 @@
@use "../../Assets/sass/devtoys" as *;
.list-box-item {
- @include flex( $align: center, $inline: true );
+ @include flex( $align: center );
position: relative;
box-sizing: border-box;
flex: 0 0 auto;
diff --git a/src/app/dev/DevToys.Blazor/Components/ListBox/SelectBase.cs b/src/app/dev/DevToys.Blazor/Components/ListBox/SelectBase.cs
new file mode 100644
index 000000000..3ede3c50f
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/ListBox/SelectBase.cs
@@ -0,0 +1,231 @@
+using Microsoft.AspNetCore.Components.Web;
+using System.Collections.Specialized;
+
+namespace DevToys.Blazor.Components;
+
+public abstract class SelectBase<TElement> : JSStyledComponentBase where TElement : class
+{
+ private int _oldSelectedIndex = int.MinValue;
+ private TElement? _oldSelectedItem = null;
+
+ [Parameter]
+ public ICollection<TElement>? Items { get; set; }
+
+ [Parameter]
+ public RenderFragment<TElement> ItemTemplate { get; set; } = default!;
+
+ [Parameter]
+ public TElement? SelectedItem { get; set; }
+
+ [Parameter]
+ public int SelectedIndex { get; set; } = -1;
+
+ [Parameter]
+ public EventCallback<int> SelectedIndexChanged { get; set; }
+
+ [Parameter]
+ public EventCallback<TElement> SelectedItemChanged { get; set; }
+
+ [Parameter]
+ public bool OverrideDefaultItemTemplate { get; set; }
+
+ [Parameter]
+ public bool Virtualize { get; set; } = true;
+
+ [Parameter]
+ public virtual bool RaiseSelectionEventOnKeyboardNavigation { get; set; } = true;
+
+ internal void SelectNextItem()
+ {
+ if (Items is not null)
+ {
+ if (SelectedIndex == -1 || SelectedIndex == Items.Count - 1)
+ {
+ SetSelectedIndex(0, raiseEvent: RaiseSelectionEventOnKeyboardNavigation);
+ }
+ else
+ {
+ SetSelectedIndex(SelectedIndex + 1, raiseEvent: RaiseSelectionEventOnKeyboardNavigation);
+ }
+ }
+ }
+
+ internal void SelectPreviousItem()
+ {
+ if (Items is not null)
+ {
+ if (SelectedIndex == -1 || SelectedIndex == 0)
+ {
+ SetSelectedIndex(Items.Count - 1, raiseEvent: RaiseSelectionEventOnKeyboardNavigation);
+ }
+ else
+ {
+ SetSelectedIndex(SelectedIndex - 1, raiseEvent: RaiseSelectionEventOnKeyboardNavigation);
+ }
+ }
+ }
+
+ internal void SetSelectedIndex(int index)
+ {
+ SetSelectedIndex(index, raiseEvent: false);
+ }
+
+ internal void SetSelectedItem(TElement? item)
+ {
+ SetSelectedItem(item, raiseEvent: false);
+ }
+
+ public override ValueTask DisposeAsync()
+ {
+ if (Items is INotifyCollectionChanged notifyCollection)
+ {
+ notifyCollection.CollectionChanged -= OnItemsChanged;
+ }
+ return base.DisposeAsync();
+ }
+
+ protected override void OnParametersSet()
+ {
+ base.OnParametersSet();
+
+ if (_oldSelectedIndex != SelectedIndex)
+ {
+ SetSelectedIndex(SelectedIndex, raiseEvent: false);
+ }
+ else if (_oldSelectedItem != SelectedItem)
+ {
+ SetSelectedItem(SelectedItem, raiseEvent: false);
+ }
+ }
+
+ protected override void OnAfterRender(bool firstRender)
+ {
+ base.OnAfterRender(firstRender);
+
+ if (firstRender)
+ {
+ if (Items is INotifyCollectionChanged notifyCollection)
+ {
+ notifyCollection.CollectionChanged += OnItemsChanged;
+ }
+ }
+ }
+
+ private void SetSelectedIndex(int index, bool raiseEvent)
+ {
+ if (index >= Items?.Count)
+ {
+ ThrowHelper.ThrowArgumentOutOfRangeException(nameof(index));
+ }
+
+ SelectedIndex = index;
+ _oldSelectedIndex = index;
+ if (index > -1)
+ {
+ Guard.IsNotNull(Items);
+ SelectedItem = Items.ElementAt(index);
+ }
+ else
+ {
+ SelectedItem = default;
+ }
+ _oldSelectedItem = SelectedItem;
+
+ if (raiseEvent)
+ {
+ RaiseOnSelectionChanged();
+ }
+
+ StateHasChanged();
+ }
+
+ private void SetSelectedItem(TElement? item, bool raiseEvent)
+ {
+ Guard.IsNotNull(Items);
+ if (item == SelectedItem && !raiseEvent)
+ {
+ return;
+ }
+ else if (item is null)
+ {
+ SetSelectedIndex(-1, raiseEvent);
+ }
+ else if (Items is IList<TElement> itemsList)
+ {
+ int itemIndex = itemsList.IndexOf(item);
+ SetSelectedIndex(itemIndex, raiseEvent);
+ }
+ else
+ {
+ int i = 0;
+ foreach (TElement childItem in Items)
+ {
+ if (object.ReferenceEquals(childItem, item))
+ {
+ SetSelectedIndex(i, raiseEvent);
+ return;
+ }
+ i++;
+ }
+
+ SetSelectedIndex(-1, raiseEvent);
+ }
+ }
+
+ private void RaiseOnSelectionChanged()
+ {
+ OnItemSelected();
+
+ if (SelectedIndexChanged.HasDelegate)
+ {
+ SelectedIndexChanged.InvokeAsync(SelectedIndex);
+ }
+
+ if (SelectedItemChanged.HasDelegate)
+ {
+ SelectedItemChanged.InvokeAsync(SelectedItem);
+ }
+ }
+
+ private void OnItemsChanged(object? sender, NotifyCollectionChangedEventArgs e)
+ {
+ SetSelectedItem(SelectedItem, raiseEvent: false);
+ }
+
+ protected void OnItemClick(object? selectedItem)
+ {
+ SetSelectedItem(selectedItem as TElement, raiseEvent: true);
+ }
+
+ protected void OnKeyDown(KeyboardEventArgs ev)
+ {
+ if (Items is not null && Items.Count > 0)
+ {
+ if (string.Equals(ev.Code, "Enter", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(ev.Code, "Space", StringComparison.OrdinalIgnoreCase))
+ {
+ RaiseOnSelectionChanged();
+ }
+ else if (string.Equals(ev.Code, "ArrowDown", StringComparison.OrdinalIgnoreCase))
+ {
+ SelectNextItem();
+ }
+ else if (string.Equals(ev.Code, "ArrowUp", StringComparison.OrdinalIgnoreCase))
+ {
+ SelectPreviousItem();
+ }
+ else if (string.Equals(ev.Code, "Home", StringComparison.OrdinalIgnoreCase))
+ {
+ SetSelectedIndex(Math.Min(0, Items.Count - 1));
+ }
+ else if (string.Equals(ev.Code, "End", StringComparison.OrdinalIgnoreCase))
+ {
+ SetSelectedIndex(Items.Count - 1);
+ }
+ }
+ }
+
+ protected virtual void OnItemSelected()
+ {
+ }
+}
diff --git a/src/app/dev/DevToys.Blazor/Components/NavBar/NavBarItem.razor.scss b/src/app/dev/DevToys.Blazor/Components/NavBar/NavBarItem.razor.scss
index e1bc7bf25..c3a69c956 100644
--- a/src/app/dev/DevToys.Blazor/Components/NavBar/NavBarItem.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/NavBar/NavBarItem.razor.scss
@@ -1,64 +1,66 @@
-.sidebar-item-separator {
- margin: 4px 0px;
- padding: 0;
- height: 1px;
- border-color: transparent;
- background-color: var(--navigation-view-separator-color);
-}
-
-.list-box-item {
- display: grid;
- grid-template-columns: auto 1fr auto;
- grid-template-rows: 1fr;
- gap: 0px 0px;
- grid-template-areas: ". . .";
- padding-right: 0px;
-
- .sidebar-item-icon {
- height: 16px;
- width: 16px;
- padding-top: 4px;
- margin-right: 16px;
+nav {
+ .sidebar-item-separator {
+ margin: 4px 0px;
+ padding: 0;
+ height: 1px;
+ border-color: transparent;
+ background-color: var(--navigation-view-separator-color);
}
- .sidebar-expand-group-button {
- height: 34px;
- transition-duration: 0.2s;
- transition-property: transform;
+ .list-box-item {
+ display: grid;
+ grid-template-columns: auto 1fr auto;
+ grid-template-rows: 1fr;
+ gap: 0px 0px;
+ grid-template-areas: ". . .";
+ padding-right: 0px;
- &:hover {
- border-color: transparent;
- background-color: transparent;
+ .sidebar-item-icon {
+ height: 16px;
+ width: 16px;
+ padding-top: 4px;
+ margin-right: 16px;
}
- &:active {
- border-color: transparent;
- background-color: transparent;
- }
+ .sidebar-expand-group-button {
+ height: 34px;
+ transition-duration: 0.2s;
+ transition-property: transform;
+
+ &:hover {
+ border-color: transparent;
+ background-color: transparent;
+ }
+
+ &:active {
+ border-color: transparent;
+ background-color: transparent;
+ }
- &[data-expanded="true"] {
- transform: rotate(180deg);
+ &[data-expanded="true"] {
+ transform: rotate(180deg);
+ }
}
}
-}
-.sidebar-child-item {
- padding-left: 42px;
-}
+ .sidebar-child-item {
+ padding-left: 42px;
+ }
-.collapsed:not(.expanded-overlay) {
- .list-box-item {
- max-width: 40px;
- overflow: hidden;
+ &.collapsed:not(.expanded-overlay) {
+ .list-box-item {
+ max-width: 40px;
+ overflow: hidden;
- .sidebar-item-text, .sidebar-expand-group-button {
- display: none;
+ .sidebar-item-text, .sidebar-expand-group-button {
+ display: none;
+ }
}
- }
- .sidebar-items {
- &.children {
- display: none;
+ .sidebar-items {
+ &.children {
+ display: none;
+ }
}
}
-}
\ No newline at end of file
+}
diff --git a/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor b/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor
index 8a9b226d8..7600d0f11 100644
--- a/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor
+++ b/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor
@@ -1,5 +1,5 @@
@namespace DevToys.Blazor.Components
-@inherits JSStyledComponentBase
+@inherits StyledComponentBase
<CascadingValue Value="this" IsFixed="true">
<div id=@Id
diff --git a/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.cs b/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.cs
index 31f97514e..1ae6c3361 100644
--- a/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.cs
@@ -1,9 +1,7 @@
namespace DevToys.Blazor.Components;
-public partial class ScrollViewer : JSStyledComponentBase
+public partial class ScrollViewer : StyledComponentBase
{
- protected override string JavaScriptFile => "./_content/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.js";
-
/// <summary>
/// Gets or set the orientation in which the content can be scrolled.
/// </summary>
@@ -16,18 +14,36 @@ public partial class ScrollViewer : JSStyledComponentBase
[Parameter]
public RenderFragment? ChildContent { get; set; }
+ /// <summary>
+ /// Gets or sets a value indicating whether the native scroll bars of the web browser should be used instead of the scroll bars
+ /// provided by SimpleBar library.
+ /// </summary>
+ /// <remarks>
+ /// This is often useful when the scroll viewer is expect to get the width (or height) or its content instead of fitting within its parent.
+ /// This is commonly happening in context menu / drop down menu list scenarios, where the width of the list of item displayed in the menu
+ /// is dynamic and the parent of the scroll view has no width.
+ /// </remarks>
+ [Parameter]
+ public bool UseNativeScrollBar { get; set; }
+
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
-
- if (firstRender)
- {
- await (await JSModule).InvokeVoidAsync("initializeScrollViewer", Id);
- }
}
protected override void OnParametersSet()
{
+ AdditionalAttributes ??= new Dictionary<string, object>();
+ if (IsEnabled && !UseNativeScrollBar)
+ {
+ // This will trigger simplebar to start.
+ AdditionalAttributes.TryAdd("data-simplebar", true);
+ }
+ else
+ {
+ AdditionalAttributes.Remove("data-simplebar");
+ }
+
if ((Orientation & Orientation.Vertical) != 0
&& (Orientation & Orientation.Horizontal) != 0)
{
@@ -54,6 +70,15 @@ public partial class ScrollViewer : JSStyledComponentBase
}
}
+ if (UseNativeScrollBar)
+ {
+ CSS.Add("use-native-scroll");
+ }
+ else
+ {
+ CSS.Remove("use-native-scroll");
+ }
+
base.OnParametersSet();
}
}
diff --git a/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.js b/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.js
deleted file mode 100644
index 13c5566dd..000000000
--- a/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.js
+++ /dev/null
@@ -1,16 +0,0 @@
-export function initializeScrollViewer(id) {
- const scrollViewer = document.getElementById(id);
- scrollViewer.addEventListener("mousemove", onScrollViewerMouseMove);
-}
-// TODO: Handle horizontal scrollbar
-function onScrollViewerMouseMove(ev) {
- const scrollViewer = ev.target;
- const distance = scrollViewer.offsetLeft + scrollViewer.offsetWidth - ev.pageX;
- if (distance < 12 && distance > -12) {
- scrollViewer.classList.add("on-hover");
- }
- else {
- scrollViewer.classList.remove("on-hover");
- }
-}
-//# sourceMappingURL=ScrollViewer.razor.js.map
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.scss b/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.scss
index 41d893534..0727d70f3 100644
--- a/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.scss
@@ -1,55 +1,326 @@
.scroll-viewer {
overflow-y: overlay;
overflow-x: overlay;
+ height: 100%;
+ width: 100%;
&.vertical {
overflow-y: overlay;
overflow-x: hidden;
- height: 100%;
}
&.horizontal {
overflow-y: hidden;
overflow-x: overlay;
- width: 100%;
}
- &::-webkit-scrollbar-track {
- border-radius: 999px;
- background: var(--scrollbar-track-background-color);
+ &.use-native-scroll {
+ &::-webkit-scrollbar-track {
+ border-radius: 999px;
+ background: var(--scrollbar-track-background-color);
+ }
+
+ &::-webkit-scrollbar-thumb {
+ border-radius: 999px;
+ border-width: 3px;
+ border-style: solid;
+ border-color: var(--scrollbar-thumb-border-color);
+ background-color: var(--scrollbar-thumb-background-color);
+ }
+ // By default, scrollbar is invisible.
+ &::-webkit-scrollbar {
+ width: 0px;
+ transition: all 0.2s ease-in-out;
+ }
+ // When mouse is over the control, shows the scrollbar in small.
+ &:hover {
+ &::-webkit-scrollbar {
+ width: 3px;
+ }
+ }
+ // When the mouse cursor is close from the scrollbar, enlarge it.
+ &.on-hover {
+ &::-webkit-scrollbar {
+ width: 12px;
+ }
+
+ &::-webkit-scrollbar-track {
+ background: var(--scrollbar-track-background-color-hover);
+ }
+
+ &::-webkit-scrollbar-thumb {
+ border-color: var(--scrollbar-thumb-border-color-hover);
+ background-color: var(--scrollbar-thumb-background-color-hover);
+ }
+ }
+ }
+}
+
+[data-simplebar] {
+ position: relative;
+ flex-direction: column;
+ flex-wrap: wrap;
+ justify-content: flex-start;
+ align-content: flex-start;
+ align-items: flex-start;
+}
+
+.simplebar-wrapper {
+ overflow: hidden;
+ width: inherit;
+ height: inherit;
+ max-width: inherit;
+ max-height: inherit;
+}
+
+.simplebar-mask {
+ direction: inherit;
+ position: absolute;
+ overflow: hidden;
+ padding: 0;
+ margin: 0;
+ left: 0;
+ top: 0;
+ bottom: 0;
+ right: 0;
+ width: auto !important;
+ height: auto !important;
+ z-index: 0;
+}
+
+.simplebar-offset {
+ direction: inherit !important;
+ box-sizing: inherit !important;
+ resize: none !important;
+ position: absolute;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ right: 0;
+ padding: 0;
+ margin: 0;
+ -webkit-overflow-scrolling: touch;
+}
+
+.simplebar-content-wrapper {
+ direction: inherit;
+ box-sizing: border-box !important;
+ position: relative;
+ display: block;
+ height: 100%; /* Required for horizontal native scrollbar to not appear if parent is taller than natural height */
+ width: auto;
+ max-width: 100%; /* Not required for horizontal scroll to trigger */
+ max-height: 100%; /* Needed for vertical scroll to trigger */
+ overflow: auto;
+ scrollbar-width: none;
+ -ms-overflow-style: none;
+
+ &:focus-visible {
+ box-shadow: var(--focus-stroke);
}
+}
+
+.simplebar-content-wrapper::-webkit-scrollbar,
+.simplebar-hide-scrollbar::-webkit-scrollbar {
+ display: none;
+ width: 0;
+ height: 0;
+}
+
+.simplebar-content:before,
+.simplebar-content:after {
+ content: ' ';
+ display: table;
+}
+
+.simplebar-placeholder {
+ max-height: 100%;
+ max-width: 100%;
+ width: 100%;
+ pointer-events: none;
+ /*display: contents;*/
+}
+
+.simplebar-height-auto-observer-wrapper {
+ box-sizing: inherit !important;
+ height: 100%;
+ width: 100%;
+ max-width: 1px;
+ position: relative;
+ float: left;
+ max-height: 1px;
+ overflow: hidden;
+ z-index: -1;
+ padding: 0;
+ margin: 0;
+ pointer-events: none;
+ flex-grow: inherit;
+ flex-shrink: 0;
+ flex-basis: 0;
+}
+
+.simplebar-height-auto-observer {
+ box-sizing: inherit;
+ display: block;
+ opacity: 0;
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: 1000%;
+ width: 1000%;
+ min-height: 1px;
+ min-width: 1px;
+ overflow: hidden;
+ pointer-events: none;
+ z-index: -1;
+}
- &::-webkit-scrollbar-thumb {
- border-radius: 999px;
- border-width: 3px;
+.simplebar-scrollbar {
+ position: absolute;
+ left: 0;
+ right: 0;
+ min-height: 10px;
+
+ &:before {
+ position: absolute;
+ content: '';
+ background: var(--scrollbar-thumb-background-color);
+ border-radius: 7px;
+ border-width: 1px;
border-style: solid;
border-color: var(--scrollbar-thumb-border-color);
- background-color: var(--scrollbar-thumb-background-color);
- }
- // By default, scrollbar is invisible.
- &::-webkit-scrollbar {
- width: 0px;
+ left: 2px;
+ right: 2px;
+ opacity: 0;
transition: all 0.2s ease-in-out;
+ transition-delay: 2s;
}
- // When mouse is over the control, shows the scrollbar in small.
- &:hover {
- &::-webkit-scrollbar {
- width: 3px;
+}
+
+.simplebar-track {
+ z-index: 1;
+ position: absolute;
+ right: 0;
+ bottom: 0;
+ pointer-events: none;
+ overflow: hidden;
+ background: var(--scrollbar-track-background-color);
+ border-radius: 7px;
+
+ &.simplebar-hover {
+ background: var(--scrollbar-track-background-color-hover);
+
+ .simplebar-scrollbar {
+ &:before {
+ border-color: var(--scrollbar-thumb-border-color-hover);
+ background-color: var(--scrollbar-thumb-background-color-hover);
+ }
}
}
- // When the mouse cursor is close from the scrollbar, enlarge it.
- &.on-hover {
- &::-webkit-scrollbar {
+
+ &.simplebar-vertical {
+ top: 0;
+ width: 5px;
+ transition: width 0.2s ease-in-out;
+
+ &.simplebar-hover {
width: 12px;
+
+ .simplebar-scrollbar {
+ width: 12px;
+ }
}
+ }
- &::-webkit-scrollbar-track {
- background: var(--scrollbar-track-background-color-hover);
+ &.simplebar-horizontal {
+ left: 0;
+ height: 5px;
+ transition: height 0.2s ease-in-out;
+
+ &.simplebar-hover {
+ height: 12px;
+
+ .simplebar-scrollbar {
+ height: 12px;
+ }
}
- &::-webkit-scrollbar-thumb {
- border-color: var(--scrollbar-thumb-border-color-hover);
- background-color: var(--scrollbar-thumb-background-color-hover);
+ .simplebar-scrollbar {
+ right: auto;
+ left: 0;
+ top: 0;
+ bottom: 0;
+ min-height: 0;
+ min-width: 10px;
+ width: auto;
}
}
}
+
+[data-simplebar].simplebar-dragging {
+ pointer-events: none;
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+
+[data-simplebar].simplebar-dragging .simplebar-content {
+ pointer-events: none;
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+
+[data-simplebar].simplebar-dragging .simplebar-track {
+ pointer-events: all;
+}
+
+.simplebar-scrollbar.simplebar-visible:before {
+ opacity: 1;
+ transition-delay: 0s;
+ transition-duration: 0.2s;
+}
+
+.simplebar-scrollbar:before {
+ top: 2px;
+ bottom: 2px;
+ left: 2px;
+ right: 2px;
+}
+
+/* Rtl support */
+[data-simplebar-direction='rtl'] .simplebar-track.simplebar-vertical {
+ right: auto;
+ left: 0;
+}
+
+.simplebar-dummy-scrollbar-size {
+ direction: rtl;
+ position: fixed;
+ opacity: 0;
+ visibility: hidden;
+ height: 500px;
+ width: 500px;
+ overflow-y: hidden;
+ overflow-x: scroll;
+ -ms-overflow-style: scrollbar !important;
+}
+
+.simplebar-dummy-scrollbar-size > div {
+ width: 200%;
+ height: 200%;
+ margin: 10px 0;
+}
+
+.simplebar-hide-scrollbar {
+ position: fixed;
+ left: 0;
+ visibility: hidden;
+ overflow-y: scroll;
+ scrollbar-width: none;
+ -ms-overflow-style: none;
+}
diff --git a/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.ts b/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.ts
deleted file mode 100644
index b6bed5c62..000000000
--- a/src/app/dev/DevToys.Blazor/Components/ScrollViewer/ScrollViewer.razor.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-export function initializeScrollViewer(id: string): void {
- const scrollViewer = document.getElementById(id);
-
- scrollViewer.addEventListener("mousemove", onScrollViewerMouseMove);
-}
-
-// TODO: Handle horizontal scrollbar
-function onScrollViewerMouseMove(ev: MouseEvent): void {
- const scrollViewer = ev.target as HTMLElement;
- const distance = scrollViewer.offsetLeft + scrollViewer.offsetWidth - ev.pageX;
-
- if (distance < 12 && distance > -12) {
- scrollViewer.classList.add("on-hover");
- }
- else {
- scrollViewer.classList.remove("on-hover");
- }
-}
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/TextBox/TextBox.razor.cs b/src/app/dev/DevToys.Blazor/Components/TextBox/TextBox.razor.cs
index be0a4330e..7cc8e97fd 100644
--- a/src/app/dev/DevToys.Blazor/Components/TextBox/TextBox.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/TextBox/TextBox.razor.cs
@@ -75,8 +75,17 @@ public partial class TextBox : MefComponentBase
public override async ValueTask DisposeAsync()
{
- await (await JSModule).InvokeVoidAsync("dispose", Element);
- await base.DisposeAsync();
+ try
+ {
+ await (await JSModule).InvokeVoidAsync("dispose", Element);
+ }
+ catch
+ {
+ }
+ finally
+ {
+ await base.DisposeAsync();
+ }
}
protected override async Task OnAfterRenderAsync(bool firstRender)
diff --git a/src/app/dev/DevToys.Blazor/Core/Services/ContextMenuService.cs b/src/app/dev/DevToys.Blazor/Core/Services/ContextMenuService.cs
index c37539289..fa65ba6bc 100644
--- a/src/app/dev/DevToys.Blazor/Core/Services/ContextMenuService.cs
+++ b/src/app/dev/DevToys.Blazor/Core/Services/ContextMenuService.cs
@@ -54,6 +54,9 @@ public sealed class ContextMenuService
private void WindowService_MajorWindowChange(object? sender, EventArgs e)
{
- OnCloseContextMenuRequested();
+ if (!Debugger.IsAttached)
+ {
+ OnCloseContextMenuRequested();
+ }
}
}
diff --git a/src/app/dev/DevToys.Blazor/Pages/Index.razor b/src/app/dev/DevToys.Blazor/Pages/Index.razor
index 24c7584e6..57ede1bdd 100644
--- a/src/app/dev/DevToys.Blazor/Pages/Index.razor
+++ b/src/app/dev/DevToys.Blazor/Pages/Index.razor
@@ -7,7 +7,7 @@
@inherits MefComponentBase
<!-- Provider for popover -->
-<PopoverProvider/>
+<PopoverProvider />
<!-- Overlay that covers the whole window for context menus -->
<Overlay ZIndex="80000"
@@ -35,11 +35,13 @@
<!-- Search box's result item design -->
<SearchResultItemTemplate Context="item">
- <div class="sidebar-item-icon">
- <FontIcon FontFamily="@item.ToolInstance.IconFontName" Glyph="@item.ToolInstance.IconGlyph" />
- </div>
- <div class="sidebar-item-text">
- <TextBlock NoWrap="true" Text="@item.ToolInstance.LongDisplayTitle" HighlightedSpans="@item.MatchedSpans" />
+ <div class="sidebar-searchbar-result-item">
+ <div class="sidebar-searchbar-result-item-icon">
+ <FontIcon FontFamily="@item.ToolInstance.IconFontName" Glyph="@item.ToolInstance.IconGlyph" />
+ </div>
+ <div class="sidebar-searchbar-result-item-text">
+ <TextBlock NoWrap="true" Text="@item.ToolInstance.LongDisplayTitle" HighlightedSpans="@item.MatchedSpans" />
+ </div>
</div>
</SearchResultItemTemplate>
@@ -85,25 +87,71 @@
{
if (ViewModel.SelectedMenuItem is GuiToolViewItem guiToolViewItem)
{
- <div class="entranceThemeTransition">
- <TextBlock Appearance="TextBlockAppearance.TitleLarge" Text="@guiToolViewItem.ToolInstance.LongOrShortDisplayTitle" />
- <!-- TODO: Place here a component that takes in argument the guiToolViewItem -->
+ <div class="entranceThemeTransition" style="display: contents">
+ <ScrollViewer>
+ <TextBlock Appearance="TextBlockAppearance.TitleLarge" Text="@guiToolViewItem.ToolInstance.LongOrShortDisplayTitle" />
+ <!-- TODO: Place here a component that takes in argument the guiToolViewItem -->
- <Button IsEnabled="true" @onclick="OnSetFavorite">Set favorite</Button>
- <Button IsEnabled="false">Set favorite</Button>
- <Button IsEnabled="true" Appearance="ButtonAppearance.Accent">Set favorite</Button>
- <Button IsEnabled="false" Appearance="ButtonAppearance.Accent">Set favorite</Button>
- <Button IsEnabled="true" Appearance="ButtonAppearance.Stealth">Set favorite</Button>
- <Button IsEnabled="false" Appearance="ButtonAppearance.Stealth">Set favorite</Button>
- <TextBox Header="First name" Placeholder="Normal" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
- <TextBox Header="Middle name" Placeholder="Read only" IsReadOnly="true" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
- <TextBox Header="Last name" Placeholder="Disabled" IsEnabled="false" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
- <CheckBox IsChecked="true" Text="An option" />
- <CheckBox IsChecked="true" IsEnabled="false" Text="An option" />
- <CheckBox IsChecked="false" IsEnabled="false" Text="An option" />
- <ToggleSwitch IsOn="true" Text="An option" />
- <ToggleSwitch IsOn="true" IsEnabled="false" Text="An option" />
- <ToggleSwitch IsOn="false" IsEnabled="false" Text="An option" />
+ <Button IsEnabled="true" @onclick="OnSetFavorite">Set favorite</Button>
+ <Button IsEnabled="false">Set favorite</Button>
+ <Button IsEnabled="true" Appearance="ButtonAppearance.Accent">Set favorite</Button>
+ <Button IsEnabled="false" Appearance="ButtonAppearance.Accent">Set favorite</Button>
+ <Button IsEnabled="true" Appearance="ButtonAppearance.Stealth">Set favorite</Button>
+ <Button IsEnabled="false" Appearance="ButtonAppearance.Stealth">Set favorite</Button>
+ <TextBox Header="First name" Placeholder="Normal" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
+ <TextBox Header="Middle name" Placeholder="Read only" IsReadOnly="true" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
+ <TextBox Header="Last name" Placeholder="Disabled" IsEnabled="false" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
+ <CheckBox IsChecked="true" Text="An option" />
+ <CheckBox IsChecked="true" IsEnabled="false" Text="An option" />
+ <CheckBox IsChecked="false" IsEnabled="false" Text="An option" />
+ <DropDownList Header="Drop down list header"
+ Items="@(new List<DropDownListItem>
+ {
+ new DropDownListItem { Text = "Item 1", IconGlyph = '\uE670' },
+ new DropDownListItem { Text = "Item 2" },
+ new DropDownListItem { Text = "Item 3" },
+ new DropDownListItem { Text = "Item 4" },
+ new DropDownListItem { Text = "Item 5" },
+ new DropDownListItem { Text = "Item 6" },
+ new DropDownListItem { Text = "Item 7" },
+ new DropDownListItem { Text = "Item 8" },
+ new DropDownListItem { Text = "Item 9" },
+ new DropDownListItem { Text = "Item 10" },
+ new DropDownListItem { Text = "Item 11" },
+ new DropDownListItem { Text = "Item 12" },
+ new DropDownListItem { Text = "Item 13" },
+ new DropDownListItem { Text = "Item 14" },
+ new DropDownListItem { Text = "Item 15 - longer text" }
+ })">
+ <TextBlock Appearance="TextBlockAppearance.Body" Text="Click me!" />
+ </DropDownList>
+ <ToggleSwitch IsOn="true" Text="An option" />
+ <ToggleSwitch IsOn="true" IsEnabled="false" Text="An option" />
+ <ToggleSwitch IsOn="false" IsEnabled="false" Text="An option" />
+ <ComboBox Items="@(new List<string>
+ {
+ "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10",
+ "Item 11", "Item 12", "Item 13", "Item 14", "Item 15", "Item 16 - longer text"
+ })"
+ Context="item"
+ @bind-SelectedIndex="@ComboBoxSelectedItem"
+ Header="ComboBox header">
+ <ItemTemplate>
+ @item
+ </ItemTemplate>
+ </ComboBox>
+ <ListBox Items="@(new List<string>
+ {
+ "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10",
+ "Item 11", "Item 12", "Item 13", "Item 14", "Item 15", "Item 16 - longer text"
+ })"
+ Context="item"
+ SelectedIndex="1">
+ <ItemTemplate>
+ @item
+ </ItemTemplate>
+ </ListBox>
+ </ScrollViewer>
</div>
}
else if (ViewModel.SelectedMenuItem is GroupViewItem groupToolViewItem)
diff --git a/src/app/dev/DevToys.Blazor/Pages/Index.razor.cs b/src/app/dev/DevToys.Blazor/Pages/Index.razor.cs
index c551e70e0..9f0199f09 100644
--- a/src/app/dev/DevToys.Blazor/Pages/Index.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Pages/Index.razor.cs
@@ -24,6 +24,10 @@ public partial class Index : MefComponentBase
[Inject]
internal ContextMenuService ContextMenuService { get; set; } = default!;
+ // TODO: Temp.
+ [Parameter]
+ public int ComboBoxSelectedItem { get; set; } = 1;
+
/// <summary>
/// Indicates whether we're transitioning to another selected menu item.
/// </summary>
diff --git a/src/app/dev/DevToys.Blazor/Pages/Index.razor.scss b/src/app/dev/DevToys.Blazor/Pages/Index.razor.scss
new file mode 100644
index 000000000..d645c44de
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Pages/Index.razor.scss
@@ -0,0 +1,16 @@
+.sidebar-searchbar-result-item {
+ display: grid;
+ grid-template-columns: 16px 1fr;
+ grid-template-rows: 1fr;
+ gap: 0px 12px;
+ grid-template-areas:
+ "icon title";
+
+ .sidebar-searchbar-result-item-icon {
+ grid-area: icon;
+ }
+
+ .sidebar-searchbar-result-item-title {
+ grid-area: title;
+ }
+}
diff --git a/src/app/dev/DevToys.Blazor/wwwroot/js/simplebar-modified.js b/src/app/dev/DevToys.Blazor/wwwroot/js/simplebar-modified.js
new file mode 100644
index 000000000..95c8e5300
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/wwwroot/js/simplebar-modified.js
@@ -0,0 +1,1684 @@
+// NOTE:
+// This is a fork of simplebar - v6.2.5. Some custom changes have been made. Be careful if you decide to update this library.
+
+// TODO: Add license to third party notices
+
+/**
+ * simplebar - v6.2.5
+ * Scrollbars, simpler.
+ * https://grsmto.github.io/simplebar/
+ *
+ * Made by Adrien Denat from a fork by Jonathan Nicol
+ * Under MIT License
+ */
+
+var SimpleBar = (function () {
+ "use strict";
+
+ /******************************************************************************
+ Copyright (c) Microsoft Corporation.
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ PERFORMANCE OF THIS SOFTWARE.
+ ***************************************************************************** */
+ /* global Reflect, Promise */
+
+ var extendStatics = function(d, b) {
+ extendStatics = Object.setPrototypeOf ||
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
+ return extendStatics(d, b);
+ };
+
+ function __extends(d, b) {
+ if (typeof b !== "function" && b !== null)
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
+ extendStatics(d, b);
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+ }
+
+ var canUseDOM = !!(
+ typeof window !== "undefined" &&
+ window.document &&
+ window.document.createElement
+ );
+
+ var canUseDom = canUseDOM;
+
+ /** Detect free variable `global` from Node.js. */
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
+
+ var freeGlobal$1 = freeGlobal;
+
+ /** Detect free variable `self`. */
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
+
+ /** Used as a reference to the global object. */
+ var root = freeGlobal$1 || freeSelf || Function("return this")();
+
+ var root$1 = root;
+
+ /** Built-in value references. */
+ var Symbol = root$1.Symbol;
+
+ var Symbol$1 = Symbol;
+
+ /** Used for built-in method references. */
+ var objectProto$1 = Object.prototype;
+
+ /** Used to check objects for own properties. */
+ var hasOwnProperty = objectProto$1.hasOwnProperty;
+
+ /**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+ var nativeObjectToString$1 = objectProto$1.toString;
+
+ /** Built-in value references. */
+ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
+
+ /**
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the raw `toStringTag`.
+ */
+ function getRawTag(value) {
+ var isOwn = hasOwnProperty.call(value, symToStringTag$1),
+ tag = value[symToStringTag$1];
+
+ try {
+ value[symToStringTag$1] = undefined;
+ var unmasked = true;
+ } catch (e) {}
+
+ var result = nativeObjectToString$1.call(value);
+ if (unmasked) {
+ if (isOwn) {
+ value[symToStringTag$1] = tag;
+ } else {
+ delete value[symToStringTag$1];
+ }
+ }
+ return result;
+ }
+
+ /** Used for built-in method references. */
+ var objectProto = Object.prototype;
+
+ /**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+ var nativeObjectToString = objectProto.toString;
+
+ /**
+ * Converts `value` to a string using `Object.prototype.toString`.
+ *
+ * @private
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ */
+ function objectToString(value) {
+ return nativeObjectToString.call(value);
+ }
+
+ /** `Object#toString` result references. */
+ var nullTag = "[object Null]",
+ undefinedTag = "[object Undefined]";
+
+ /** Built-in value references. */
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
+
+ /**
+ * The base implementation of `getTag` without fallbacks for buggy environments.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the `toStringTag`.
+ */
+ function baseGetTag(value) {
+ if (value == null) {
+ return value === undefined ? undefinedTag : nullTag;
+ }
+ return (symToStringTag && symToStringTag in Object(value))
+ ? getRawTag(value)
+ : objectToString(value);
+ }
+
+ /**
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
+ * and has a `typeof` result of "object".
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
+ * @example
+ *
+ * _.isObjectLike({});
+ * // => true
+ *
+ * _.isObjectLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isObjectLike(_.noop);
+ * // => false
+ *
+ * _.isObjectLike(null);
+ * // => false
+ */
+ function isObjectLike(value) {
+ return value != null && typeof value == "object";
+ }
+
+ /** `Object#toString` result references. */
+ var symbolTag = "[object Symbol]";
+
+ /**
+ * Checks if `value` is classified as a `Symbol` primitive or object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
+ * @example
+ *
+ * _.isSymbol(Symbol.iterator);
+ * // => true
+ *
+ * _.isSymbol('abc');
+ * // => false
+ */
+ function isSymbol(value) {
+ return typeof value == "symbol" ||
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
+ }
+
+ /** Used to match a single whitespace character. */
+ var reWhitespace = /\s/;
+
+ /**
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
+ * character of `string`.
+ *
+ * @private
+ * @param {string} string The string to inspect.
+ * @returns {number} Returns the index of the last non-whitespace character.
+ */
+ function trimmedEndIndex(string) {
+ var index = string.length;
+
+ while (index-- && reWhitespace.test(string.charAt(index))) {}
+ return index;
+ }
+
+ /** Used to match leading whitespace. */
+ var reTrimStart = /^\s+/;
+
+ /**
+ * The base implementation of `_.trim`.
+ *
+ * @private
+ * @param {string} string The string to trim.
+ * @returns {string} Returns the trimmed string.
+ */
+ function baseTrim(string) {
+ return string
+ ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "")
+ : string;
+ }
+
+ /**
+ * Checks if `value` is the
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
+ * @example
+ *
+ * _.isObject({});
+ * // => true
+ *
+ * _.isObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isObject(_.noop);
+ * // => true
+ *
+ * _.isObject(null);
+ * // => false
+ */
+ function isObject(value) {
+ var type = typeof value;
+ return value != null && (type == "object" || type == "function");
+ }
+
+ /** Used as references for various `Number` constants. */
+ var NAN = 0 / 0;
+
+ /** Used to detect bad signed hexadecimal string values. */
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
+
+ /** Used to detect binary string values. */
+ var reIsBinary = /^0b[01]+$/i;
+
+ /** Used to detect octal string values. */
+ var reIsOctal = /^0o[0-7]+$/i;
+
+ /** Built-in method references without a dependency on `root`. */
+ var freeParseInt = parseInt;
+
+ /**
+ * Converts `value` to a number.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to process.
+ * @returns {number} Returns the number.
+ * @example
+ *
+ * _.toNumber(3.2);
+ * // => 3.2
+ *
+ * _.toNumber(Number.MIN_VALUE);
+ * // => 5e-324
+ *
+ * _.toNumber(Infinity);
+ * // => Infinity
+ *
+ * _.toNumber('3.2');
+ * // => 3.2
+ */
+ function toNumber(value) {
+ if (typeof value == "number") {
+ return value;
+ }
+ if (isSymbol(value)) {
+ return NAN;
+ }
+ if (isObject(value)) {
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
+ value = isObject(other) ? (other + "") : other;
+ }
+ if (typeof value != "string") {
+ return value === 0 ? value : +value;
+ }
+ value = baseTrim(value);
+ var isBinary = reIsBinary.test(value);
+ return (isBinary || reIsOctal.test(value))
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
+ : (reIsBadHex.test(value) ? NAN : +value);
+ }
+
+ /**
+ * Gets the timestamp of the number of milliseconds that have elapsed since
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Date
+ * @returns {number} Returns the timestamp.
+ * @example
+ *
+ * _.defer(function(stamp) {
+ * console.log(_.now() - stamp);
+ * }, _.now());
+ * // => Logs the number of milliseconds it took for the deferred invocation.
+ */
+ var now = function() {
+ return root$1.Date.now();
+ };
+
+ var now$1 = now;
+
+ /** Error message constants. */
+ var FUNC_ERROR_TEXT$1 = "Expected a function";
+
+ /* Built-in method references for those with the same name as other `lodash` methods. */
+ var nativeMax = Math.max,
+ nativeMin = Math.min;
+
+ /**
+ * Creates a debounced function that delays invoking `func` until after `wait`
+ * milliseconds have elapsed since the last time the debounced function was
+ * invoked. The debounced function comes with a `cancel` method to cancel
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
+ * Provide `options` to indicate whether `func` should be invoked on the
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
+ * with the last arguments provided to the debounced function. Subsequent
+ * calls to the debounced function return the result of the last `func`
+ * invocation.
+ *
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
+ * invoked on the trailing edge of the timeout only if the debounced function
+ * is invoked more than once during the `wait` timeout.
+ *
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
+ *
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
+ * for details over the differences between `_.debounce` and `_.throttle`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to debounce.
+ * @param {number} [wait=0] The number of milliseconds to delay.
+ * @param {Object} [options={}] The options object.
+ * @param {boolean} [options.leading=false]
+ * Specify invoking on the leading edge of the timeout.
+ * @param {number} [options.maxWait]
+ * The maximum time `func` is allowed to be delayed before it's invoked.
+ * @param {boolean} [options.trailing=true]
+ * Specify invoking on the trailing edge of the timeout.
+ * @returns {Function} Returns the new debounced function.
+ * @example
+ *
+ * // Avoid costly calculations while the window size is in flux.
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
+ *
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
+ * 'leading': true,
+ * 'trailing': false
+ * }));
+ *
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
+ * var source = new EventSource('/stream');
+ * jQuery(source).on('message', debounced);
+ *
+ * // Cancel the trailing debounced invocation.
+ * jQuery(window).on('popstate', debounced.cancel);
+ */
+ function debounce(func, wait, options) {
+ var lastArgs,
+ lastThis,
+ maxWait,
+ result,
+ timerId,
+ lastCallTime,
+ lastInvokeTime = 0,
+ leading = false,
+ maxing = false,
+ trailing = true;
+
+ if (typeof func != "function") {
+ throw new TypeError(FUNC_ERROR_TEXT$1);
+ }
+ wait = toNumber(wait) || 0;
+ if (isObject(options)) {
+ leading = !!options.leading;
+ maxing = "maxWait" in options;
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
+ trailing = "trailing" in options ? !!options.trailing : trailing;
+ }
+
+ function invokeFunc(time) {
+ var args = lastArgs,
+ thisArg = lastThis;
+
+ lastArgs = lastThis = undefined;
+ lastInvokeTime = time;
+ result = func.apply(thisArg, args);
+ return result;
+ }
+
+ function leadingEdge(time) {
+ // Reset any `maxWait` timer.
+ lastInvokeTime = time;
+ // Start the timer for the trailing edge.
+ timerId = setTimeout(timerExpired, wait);
+ // Invoke the leading edge.
+ return leading ? invokeFunc(time) : result;
+ }
+
+ function remainingWait(time) {
+ var timeSinceLastCall = time - lastCallTime,
+ timeSinceLastInvoke = time - lastInvokeTime,
+ timeWaiting = wait - timeSinceLastCall;
+
+ return maxing
+ ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
+ : timeWaiting;
+ }
+
+ function shouldInvoke(time) {
+ var timeSinceLastCall = time - lastCallTime,
+ timeSinceLastInvoke = time - lastInvokeTime;
+
+ // Either this is the first call, activity has stopped and we're at the
+ // trailing edge, the system time has gone backwards and we're treating
+ // it as the trailing edge, or we've hit the `maxWait` limit.
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
+ }
+
+ function timerExpired() {
+ var time = now$1();
+ if (shouldInvoke(time)) {
+ return trailingEdge(time);
+ }
+ // Restart the timer.
+ timerId = setTimeout(timerExpired, remainingWait(time));
+ }
+
+ function trailingEdge(time) {
+ timerId = undefined;
+
+ // Only invoke if we have `lastArgs` which means `func` has been
+ // debounced at least once.
+ if (trailing && lastArgs) {
+ return invokeFunc(time);
+ }
+ lastArgs = lastThis = undefined;
+ return result;
+ }
+
+ function cancel() {
+ if (timerId !== undefined) {
+ clearTimeout(timerId);
+ }
+ lastInvokeTime = 0;
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
+ }
+
+ function flush() {
+ return timerId === undefined ? result : trailingEdge(now$1());
+ }
+
+ function debounced() {
+ var time = now$1(),
+ isInvoking = shouldInvoke(time);
+
+ lastArgs = arguments;
+ lastThis = this;
+ lastCallTime = time;
+
+ if (isInvoking) {
+ if (timerId === undefined) {
+ return leadingEdge(lastCallTime);
+ }
+ if (maxing) {
+ // Handle invocations in a tight loop.
+ clearTimeout(timerId);
+ timerId = setTimeout(timerExpired, wait);
+ return invokeFunc(lastCallTime);
+ }
+ }
+ if (timerId === undefined) {
+ timerId = setTimeout(timerExpired, wait);
+ }
+ return result;
+ }
+ debounced.cancel = cancel;
+ debounced.flush = flush;
+ return debounced;
+ }
+
+ /** Error message constants. */
+ var FUNC_ERROR_TEXT = "Expected a function";
+
+ /**
+ * Creates a throttled function that only invokes `func` at most once per
+ * every `wait` milliseconds. The throttled function comes with a `cancel`
+ * method to cancel delayed `func` invocations and a `flush` method to
+ * immediately invoke them. Provide `options` to indicate whether `func`
+ * should be invoked on the leading and/or trailing edge of the `wait`
+ * timeout. The `func` is invoked with the last arguments provided to the
+ * throttled function. Subsequent calls to the throttled function return the
+ * result of the last `func` invocation.
+ *
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
+ * invoked on the trailing edge of the timeout only if the throttled function
+ * is invoked more than once during the `wait` timeout.
+ *
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
+ *
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
+ * for details over the differences between `_.throttle` and `_.debounce`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to throttle.
+ * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
+ * @param {Object} [options={}] The options object.
+ * @param {boolean} [options.leading=true]
+ * Specify invoking on the leading edge of the timeout.
+ * @param {boolean} [options.trailing=true]
+ * Specify invoking on the trailing edge of the timeout.
+ * @returns {Function} Returns the new throttled function.
+ * @example
+ *
+ * // Avoid excessively updating the position while scrolling.
+ * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
+ *
+ * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
+ * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
+ * jQuery(element).on('click', throttled);
+ *
+ * // Cancel the trailing throttled invocation.
+ * jQuery(window).on('popstate', throttled.cancel);
+ */
+ function throttle(func, wait, options) {
+ var leading = true,
+ trailing = true;
+
+ if (typeof func != "function") {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ if (isObject(options)) {
+ leading = "leading" in options ? !!options.leading : leading;
+ trailing = "trailing" in options ? !!options.trailing : trailing;
+ }
+ return debounce(func, wait, {
+ "leading": leading,
+ "maxWait": wait,
+ "trailing": trailing
+ });
+ }
+
+ /**
+ * simplebar-core - v1.2.4
+ * Scrollbars, simpler.
+ * https://grsmto.github.io/simplebar/
+ *
+ * Made by Adrien Denat from a fork by Jonathan Nicol
+ * Under MIT License
+ */
+
+ /******************************************************************************
+ Copyright (c) Microsoft Corporation.
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ PERFORMANCE OF THIS SOFTWARE.
+ ***************************************************************************** */
+
+ var __assign = function() {
+ __assign = Object.assign || function __assign(t) {
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
+ s = arguments[i];
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
+ }
+ return t;
+ };
+ return __assign.apply(this, arguments);
+ };
+
+ var cachedScrollbarWidth = null;
+ var cachedDevicePixelRatio = null;
+ if (canUseDom) {
+ window.addEventListener("resize", function () {
+ if (cachedDevicePixelRatio !== window.devicePixelRatio) {
+ cachedDevicePixelRatio = window.devicePixelRatio;
+ cachedScrollbarWidth = null;
+ }
+ });
+ }
+ function scrollbarWidth() {
+ if (cachedScrollbarWidth === null) {
+ if (typeof document === "undefined") {
+ cachedScrollbarWidth = 0;
+ return cachedScrollbarWidth;
+ }
+ var body = document.body;
+ var box = document.createElement("div");
+ box.classList.add("simplebar-hide-scrollbar");
+ body.appendChild(box);
+ var width = box.getBoundingClientRect().right;
+ body.removeChild(box);
+ cachedScrollbarWidth = width;
+ }
+ return cachedScrollbarWidth;
+ }
+
+ function getElementWindow$1(element) {
+ if (!element ||
+ !element.ownerDocument ||
+ !element.ownerDocument.defaultView) {
+ return window;
+ }
+ return element.ownerDocument.defaultView;
+ }
+ function getElementDocument$1(element) {
+ if (!element || !element.ownerDocument) {
+ return document;
+ }
+ return element.ownerDocument;
+ }
+ // Helper function to retrieve options from element attributes
+ var getOptions$1 = function (obj) {
+ var initialObj = {};
+ var options = Array.prototype.reduce.call(obj, function (acc, attribute) {
+ var option = attribute.name.match(/data-simplebar-(.+)/);
+ if (option) {
+ var key = option[1].replace(/\W+(.)/g, function (_, chr) { return chr.toUpperCase(); });
+ switch (attribute.value) {
+ case "true":
+ acc[key] = true;
+ break;
+ case "false":
+ acc[key] = false;
+ break;
+ case undefined:
+ acc[key] = true;
+ break;
+ default:
+ acc[key] = attribute.value;
+ }
+ }
+ return acc;
+ }, initialObj);
+ return options;
+ };
+ function addClasses$1(el, classes) {
+ var _a;
+ if (!el)
+ return;
+ (_a = el.classList).add.apply(_a, classes.split(" "));
+ }
+ function removeClasses$1(el, classes) {
+ if (!el)
+ return;
+ classes.split(" ").forEach(function (className) {
+ el.classList.remove(className);
+ });
+ }
+ function classNamesToQuery$1(classNames) {
+ return ".".concat(classNames.split(" ").join("."));
+ }
+
+ var helpers = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ getElementWindow: getElementWindow$1,
+ getElementDocument: getElementDocument$1,
+ getOptions: getOptions$1,
+ addClasses: addClasses$1,
+ removeClasses: removeClasses$1,
+ classNamesToQuery: classNamesToQuery$1
+ });
+
+ var getElementWindow = getElementWindow$1, getElementDocument = getElementDocument$1, getOptions$2 = getOptions$1, addClasses$2 = addClasses$1, removeClasses = removeClasses$1, classNamesToQuery = classNamesToQuery$1;
+ var SimpleBarCore = /** @class */ (function () {
+ function SimpleBarCore(element, options) {
+ if (options === void 0) { options = {}; }
+ var _this = this;
+ this.removePreventClickId = null;
+ this.minScrollbarWidth = 20;
+ this.stopScrollDelay = 175;
+ this.isScrolling = false;
+ this.isMouseEntering = false;
+ this.scrollXTicking = false;
+ this.scrollYTicking = false;
+ this.wrapperEl = null;
+ this.contentWrapperEl = null;
+ this.contentEl = null;
+ this.offsetEl = null;
+ this.maskEl = null;
+ this.placeholderEl = null;
+ this.heightAutoObserverWrapperEl = null;
+ this.heightAutoObserverEl = null;
+ this.rtlHelpers = null;
+ this.scrollbarWidth = 0;
+ this.resizeObserver = null;
+ this.mutationObserver = null;
+ this.elStyles = null;
+ this.isRtl = null;
+ this.mouseX = 0;
+ this.mouseY = 0;
+ this.onMouseMove = function () { };
+ this.onWindowResize = function () { };
+ this.onStopScrolling = function () { };
+ this.onMouseEntered = function () { };
+ /**
+ * On scroll event handling
+ */
+ this.onScroll = function () {
+ var elWindow = getElementWindow(_this.el);
+ if (!_this.scrollXTicking) {
+ elWindow.requestAnimationFrame(_this.scrollX);
+ _this.scrollXTicking = true;
+ }
+ if (!_this.scrollYTicking) {
+ elWindow.requestAnimationFrame(_this.scrollY);
+ _this.scrollYTicking = true;
+ }
+ if (!_this.isScrolling) {
+ _this.isScrolling = true;
+ addClasses$2(_this.el, _this.classNames.scrolling);
+ }
+ _this.showScrollbar("x");
+ _this.showScrollbar("y");
+ _this.onStopScrolling();
+ };
+ this.scrollX = function () {
+ if (_this.axis.x.isOverflowing) {
+ _this.positionScrollbar("x");
+ }
+ _this.scrollXTicking = false;
+ };
+ this.scrollY = function () {
+ if (_this.axis.y.isOverflowing) {
+ _this.positionScrollbar("y");
+ }
+ _this.scrollYTicking = false;
+ };
+ this._onStopScrolling = function () {
+ removeClasses(_this.el, _this.classNames.scrolling);
+ if (_this.options.autoHide) {
+ _this.hideScrollbar("x");
+ _this.hideScrollbar("y");
+ }
+ _this.isScrolling = false;
+ };
+ this.onMouseEnter = function () {
+ if (!_this.isMouseEntering) {
+ addClasses$2(_this.el, _this.classNames.mouseEntered);
+ _this.showScrollbar("x");
+ _this.showScrollbar("y");
+ _this.isMouseEntering = true;
+ }
+ _this.onMouseEntered();
+ };
+ this._onMouseEntered = function () {
+ removeClasses(_this.el, _this.classNames.mouseEntered);
+ if (_this.options.autoHide) {
+ _this.hideScrollbar("x");
+ _this.hideScrollbar("y");
+ }
+ _this.isMouseEntering = false;
+ };
+ this._onMouseMove = function (e) {
+ _this.mouseX = e.clientX;
+ _this.mouseY = e.clientY;
+ if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
+ _this.onMouseMoveForAxis("x");
+ }
+ if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
+ _this.onMouseMoveForAxis("y");
+ }
+ };
+ this.onMouseLeave = function () {
+ _this.onMouseMove.cancel();
+ if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
+ _this.onMouseLeaveForAxis("x");
+ }
+ if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
+ _this.onMouseLeaveForAxis("y");
+ }
+ _this.mouseX = -1;
+ _this.mouseY = -1;
+ };
+ this._onWindowResize = function () {
+ // Recalculate scrollbarWidth in case it's a zoom
+ _this.scrollbarWidth = _this.getScrollbarWidth();
+ _this.hideNativeScrollbar();
+ };
+ this.onPointerEvent = function (e) {
+ if (!_this.axis.x.track.el ||
+ !_this.axis.y.track.el ||
+ !_this.axis.x.scrollbar.el ||
+ !_this.axis.y.scrollbar.el)
+ return;
+ var isWithinTrackXBounds, isWithinTrackYBounds;
+ _this.axis.x.track.rect = _this.axis.x.track.el.getBoundingClientRect();
+ _this.axis.y.track.rect = _this.axis.y.track.el.getBoundingClientRect();
+ if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
+ isWithinTrackXBounds = _this.isWithinBounds(_this.axis.x.track.rect);
+ }
+ if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
+ isWithinTrackYBounds = _this.isWithinBounds(_this.axis.y.track.rect);
+ }
+ // If any pointer event is called on the scrollbar
+ if (isWithinTrackXBounds || isWithinTrackYBounds) {
+ // Prevent event leaking
+ e.stopPropagation();
+ if (e.type === "pointerdown" && e.pointerType !== "touch") {
+ if (isWithinTrackXBounds) {
+ _this.axis.x.scrollbar.rect =
+ _this.axis.x.scrollbar.el.getBoundingClientRect();
+ if (_this.isWithinBounds(_this.axis.x.scrollbar.rect)) {
+ _this.onDragStart(e, "x");
+ }
+ else {
+ _this.onTrackClick(e, "x");
+ }
+ }
+ if (isWithinTrackYBounds) {
+ _this.axis.y.scrollbar.rect =
+ _this.axis.y.scrollbar.el.getBoundingClientRect();
+ if (_this.isWithinBounds(_this.axis.y.scrollbar.rect)) {
+ _this.onDragStart(e, "y");
+ }
+ else {
+ _this.onTrackClick(e, "y");
+ }
+ }
+ }
+ }
+ };
+ /**
+ * Drag scrollbar handle
+ */
+ this.drag = function (e) {
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
+ if (!_this.draggedAxis || !_this.contentWrapperEl)
+ return;
+ var eventOffset;
+ var track = _this.axis[_this.draggedAxis].track;
+ var trackSize = (_b = (_a = track.rect) === null || _a === void 0 ? void 0 : _a[_this.axis[_this.draggedAxis].sizeAttr]) !== null && _b !== void 0 ? _b : 0;
+ var scrollbar = _this.axis[_this.draggedAxis].scrollbar;
+ var contentSize = (_d = (_c = _this.contentWrapperEl) === null || _c === void 0 ? void 0 : _c[_this.axis[_this.draggedAxis].scrollSizeAttr]) !== null && _d !== void 0 ? _d : 0;
+ var hostSize = parseInt((_f = (_e = _this.elStyles) === null || _e === void 0 ? void 0 : _e[_this.axis[_this.draggedAxis].sizeAttr]) !== null && _f !== void 0 ? _f : "0px", 10);
+ e.preventDefault();
+ e.stopPropagation();
+ if (_this.draggedAxis === "y") {
+ eventOffset = e.pageY;
+ }
+ else {
+ eventOffset = e.pageX;
+ }
+ // Calculate how far the user's mouse is from the top/left of the scrollbar (minus the dragOffset).
+ var dragPos = eventOffset -
+ ((_h = (_g = track.rect) === null || _g === void 0 ? void 0 : _g[_this.axis[_this.draggedAxis].offsetAttr]) !== null && _h !== void 0 ? _h : 0) -
+ _this.axis[_this.draggedAxis].dragOffset;
+ dragPos = _this.draggedAxis === "x" && _this.isRtl
+ ? ((_k = (_j = track.rect) === null || _j === void 0 ? void 0 : _j[_this.axis[_this.draggedAxis].sizeAttr]) !== null && _k !== void 0 ? _k : 0) -
+ scrollbar.size -
+ dragPos
+ : dragPos;
+ // Convert the mouse position into a percentage of the scrollbar height/width.
+ var dragPerc = dragPos / (trackSize - scrollbar.size);
+ // Scroll the content by the same percentage.
+ var scrollPos = dragPerc * (contentSize - hostSize);
+ // Fix browsers inconsistency on RTL
+ if (_this.draggedAxis === "x" && _this.isRtl) {
+ scrollPos = ((_l = SimpleBarCore.getRtlHelpers()) === null || _l === void 0 ? void 0 : _l.isScrollingToNegative)
+ ? -scrollPos
+ : scrollPos;
+ }
+ _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollOffsetAttr] =
+ scrollPos;
+ };
+ /**
+ * End scroll handle drag
+ */
+ this.onEndDrag = function (e) {
+ var elDocument = getElementDocument(_this.el);
+ var elWindow = getElementWindow(_this.el);
+ e.preventDefault();
+ e.stopPropagation();
+ removeClasses(_this.el, _this.classNames.dragging);
+ elDocument.removeEventListener("mousemove", _this.drag, true);
+ elDocument.removeEventListener("mouseup", _this.onEndDrag, true);
+ _this.removePreventClickId = elWindow.setTimeout(function () {
+ // Remove these asynchronously so we still suppress click events
+ // generated simultaneously with mouseup.
+ elDocument.removeEventListener("click", _this.preventClick, true);
+ elDocument.removeEventListener("dblclick", _this.preventClick, true);
+ _this.removePreventClickId = null;
+ });
+ };
+ /**
+ * Handler to ignore click events during drag
+ */
+ this.preventClick = function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+ };
+ this.el = element;
+ this.options = __assign(__assign({}, SimpleBarCore.defaultOptions), options);
+ this.classNames = __assign(__assign({}, SimpleBarCore.defaultOptions.classNames), options.classNames);
+ this.axis = {
+ x: {
+ scrollOffsetAttr: "scrollLeft",
+ sizeAttr: "width",
+ scrollSizeAttr: "scrollWidth",
+ offsetSizeAttr: "offsetWidth",
+ offsetAttr: "left",
+ overflowAttr: "overflowX",
+ dragOffset: 0,
+ isOverflowing: true,
+ forceVisible: false,
+ track: { size: null, el: null, rect: null, isVisible: false },
+ scrollbar: { size: null, el: null, rect: null, isVisible: false }
+ },
+ y: {
+ scrollOffsetAttr: "scrollTop",
+ sizeAttr: "height",
+ scrollSizeAttr: "scrollHeight",
+ offsetSizeAttr: "offsetHeight",
+ offsetAttr: "top",
+ overflowAttr: "overflowY",
+ dragOffset: 0,
+ isOverflowing: true,
+ forceVisible: false,
+ track: { size: null, el: null, rect: null, isVisible: false },
+ scrollbar: { size: null, el: null, rect: null, isVisible: false }
+ }
+ };
+ if (typeof this.el !== "object" || !this.el.nodeName) {
+ throw new Error("Argument passed to SimpleBar must be an HTML element instead of ".concat(this.el));
+ }
+ this.onMouseMove = throttle(this._onMouseMove, 64);
+ this.onWindowResize = debounce(this._onWindowResize, 64, { leading: true });
+ this.onStopScrolling = debounce(this._onStopScrolling, this.stopScrollDelay);
+ this.onMouseEntered = debounce(this._onMouseEntered, this.stopScrollDelay);
+ this.init();
+ }
+ /**
+ * Helper to fix browsers inconsistency on RTL:
+ * - Firefox inverts the scrollbar initial position
+ * - IE11 inverts both scrollbar position and scrolling offset
+ * Directly inspired by @KingSora's OverlayScrollbars https://github.com/KingSora/OverlayScrollbars/blob/master/js/OverlayScrollbars.js#L1634
+ */
+ SimpleBarCore.getRtlHelpers = function () {
+ if (SimpleBarCore.rtlHelpers) {
+ return SimpleBarCore.rtlHelpers;
+ }
+ var dummyDiv = document.createElement("div");
+ dummyDiv.innerHTML =
+ "<div class=\"simplebar-dummy-scrollbar-size\"><div></div></div>";
+ var scrollbarDummyEl = dummyDiv.firstElementChild;
+ var dummyChild = scrollbarDummyEl === null || scrollbarDummyEl === void 0 ? void 0 : scrollbarDummyEl.firstElementChild;
+ if (!dummyChild)
+ return null;
+ document.body.appendChild(scrollbarDummyEl);
+ scrollbarDummyEl.scrollLeft = 0;
+ var dummyContainerOffset = SimpleBarCore.getOffset(scrollbarDummyEl);
+ var dummyChildOffset = SimpleBarCore.getOffset(dummyChild);
+ scrollbarDummyEl.scrollLeft = -999;
+ var dummyChildOffsetAfterScroll = SimpleBarCore.getOffset(dummyChild);
+ document.body.removeChild(scrollbarDummyEl);
+ SimpleBarCore.rtlHelpers = {
+ // determines if the scrolling is responding with negative values
+ isScrollOriginAtZero: dummyContainerOffset.left !== dummyChildOffset.left,
+ // determines if the origin scrollbar position is inverted or not (positioned on left or right)
+ isScrollingToNegative: dummyChildOffset.left !== dummyChildOffsetAfterScroll.left
+ };
+ return SimpleBarCore.rtlHelpers;
+ };
+ SimpleBarCore.prototype.getScrollbarWidth = function () {
+ // Try/catch for FF 56 throwing on undefined computedStyles
+ try {
+ // Detect browsers supporting CSS scrollbar styling and do not calculate
+ if ((this.contentWrapperEl &&
+ getComputedStyle(this.contentWrapperEl, "::-webkit-scrollbar")
+ .display === "none") ||
+ "scrollbarWidth" in document.documentElement.style ||
+ "-ms-overflow-style" in document.documentElement.style) {
+ return 0;
+ }
+ else {
+ return scrollbarWidth();
+ }
+ }
+ catch (e) {
+ return scrollbarWidth();
+ }
+ };
+ SimpleBarCore.getOffset = function (el) {
+ var rect = el.getBoundingClientRect();
+ var elDocument = getElementDocument(el);
+ var elWindow = getElementWindow(el);
+ return {
+ top: rect.top +
+ (elWindow.pageYOffset || elDocument.documentElement.scrollTop),
+ left: rect.left +
+ (elWindow.pageXOffset || elDocument.documentElement.scrollLeft)
+ };
+ };
+ SimpleBarCore.prototype.init = function () {
+ // We stop here on server-side
+ if (canUseDom) {
+ this.initDOM();
+ this.rtlHelpers = SimpleBarCore.getRtlHelpers();
+ this.scrollbarWidth = this.getScrollbarWidth();
+ this.recalculate();
+ this.initListeners();
+ }
+ };
+ SimpleBarCore.prototype.initDOM = function () {
+ var _a, _b;
+ // assume that element has his DOM already initiated
+ this.wrapperEl = this.el.querySelector(classNamesToQuery(this.classNames.wrapper));
+ this.contentWrapperEl =
+ this.options.scrollableNode ||
+ this.el.querySelector(classNamesToQuery(this.classNames.contentWrapper));
+ this.contentEl =
+ this.options.contentNode ||
+ this.el.querySelector(classNamesToQuery(this.classNames.contentEl));
+ this.offsetEl = this.el.querySelector(classNamesToQuery(this.classNames.offset));
+ this.maskEl = this.el.querySelector(classNamesToQuery(this.classNames.mask));
+ this.placeholderEl = this.findChild(this.wrapperEl, classNamesToQuery(this.classNames.placeholder));
+ this.heightAutoObserverWrapperEl = this.el.querySelector(classNamesToQuery(this.classNames.heightAutoObserverWrapperEl));
+ this.heightAutoObserverEl = this.el.querySelector(classNamesToQuery(this.classNames.heightAutoObserverEl));
+ this.axis.x.track.el = this.findChild(this.el, "".concat(classNamesToQuery(this.classNames.track)).concat(classNamesToQuery(this.classNames.horizontal)));
+ this.axis.y.track.el = this.findChild(this.el, "".concat(classNamesToQuery(this.classNames.track)).concat(classNamesToQuery(this.classNames.vertical)));
+ this.axis.x.scrollbar.el =
+ ((_a = this.axis.x.track.el) === null || _a === void 0 ? void 0 : _a.querySelector(classNamesToQuery(this.classNames.scrollbar))) || null;
+ this.axis.y.scrollbar.el =
+ ((_b = this.axis.y.track.el) === null || _b === void 0 ? void 0 : _b.querySelector(classNamesToQuery(this.classNames.scrollbar))) || null;
+ if (!this.options.autoHide) {
+ addClasses$2(this.axis.x.scrollbar.el, this.classNames.visible);
+ addClasses$2(this.axis.y.scrollbar.el, this.classNames.visible);
+ }
+ };
+ SimpleBarCore.prototype.initListeners = function () {
+ var _this = this;
+ var _a;
+ var elWindow = getElementWindow(this.el);
+ // Event listeners
+ this.el.addEventListener("mouseenter", this.onMouseEnter);
+ this.el.addEventListener("pointerdown", this.onPointerEvent, true);
+ this.el.addEventListener("mousemove", this.onMouseMove);
+ this.el.addEventListener("mouseleave", this.onMouseLeave);
+ (_a = this.contentWrapperEl) === null || _a === void 0 ? void 0 : _a.addEventListener("scroll", this.onScroll);
+ // Browser zoom triggers a window resize
+ elWindow.addEventListener("resize", this.onWindowResize);
+ if (!this.contentEl)
+ return;
+ if (window.ResizeObserver) {
+ // Hack for https://github.com/WICG/ResizeObserver/issues/38
+ var resizeObserverStarted_1 = false;
+ var resizeObserver = elWindow.ResizeObserver || ResizeObserver;
+ this.resizeObserver = new resizeObserver(function () {
+ if (!resizeObserverStarted_1)
+ return;
+ elWindow.requestAnimationFrame(function () {
+ _this.recalculate();
+ });
+ });
+ this.resizeObserver.observe(this.el);
+ this.resizeObserver.observe(this.contentEl);
+ elWindow.requestAnimationFrame(function () {
+ resizeObserverStarted_1 = true;
+ });
+ }
+ // This is required to detect horizontal scroll. Vertical scroll only needs the resizeObserver.
+ this.mutationObserver = new elWindow.MutationObserver(function () {
+ elWindow.requestAnimationFrame(function () {
+ _this.recalculate();
+ });
+ });
+ this.mutationObserver.observe(this.contentEl, {
+ childList: true,
+ subtree: true,
+ characterData: true
+ });
+ };
+ SimpleBarCore.prototype.recalculate = function () {
+ if (!this.heightAutoObserverEl ||
+ !this.contentEl ||
+ !this.contentWrapperEl ||
+ !this.wrapperEl ||
+ !this.placeholderEl)
+ return;
+ var elWindow = getElementWindow(this.el);
+ this.elStyles = elWindow.getComputedStyle(this.el);
+ this.isRtl = this.elStyles.direction === "rtl";
+ var contentElOffsetWidth = this.contentEl.offsetWidth;
+ var isHeightAuto = this.heightAutoObserverEl.offsetHeight <= 1;
+ var isWidthAuto = this.heightAutoObserverEl.offsetWidth <= 1 || contentElOffsetWidth > 0;
+ var contentWrapperElOffsetWidth = this.contentWrapperEl.offsetWidth;
+ var elOverflowX = this.elStyles.overflowX;
+ var elOverflowY = this.elStyles.overflowY;
+ this.contentEl.style.padding = "".concat(this.elStyles.paddingTop, " ").concat(this.elStyles.paddingRight, " ").concat(this.elStyles.paddingBottom, " ").concat(this.elStyles.paddingLeft);
+ this.wrapperEl.style.margin = "-".concat(this.elStyles.paddingTop, " -").concat(this.elStyles.paddingRight, " -").concat(this.elStyles.paddingBottom, " -").concat(this.elStyles.paddingLeft);
+ var contentElScrollHeight = this.contentEl.scrollHeight;
+ var contentElScrollWidth = this.contentEl.scrollWidth;
+ this.contentWrapperEl.style.height = isHeightAuto ? "auto" : "100%";
+ // Determine placeholder size
+ this.placeholderEl.style.width = isWidthAuto
+ ? "100%"//"".concat(contentElOffsetWidth || contentElScrollWidth, "px")
+ : "auto";
+ this.placeholderEl.style.height = "".concat(contentElScrollHeight, "px");
+ var contentWrapperElOffsetHeight = this.contentWrapperEl.offsetHeight;
+ this.axis.x.isOverflowing =
+ contentElOffsetWidth !== 0 && contentElScrollWidth > contentElOffsetWidth;
+ this.axis.y.isOverflowing =
+ contentElScrollHeight > contentWrapperElOffsetHeight;
+ // Set isOverflowing to false if user explicitely set hidden overflow
+ this.axis.x.isOverflowing =
+ elOverflowX === "hidden" ? false : this.axis.x.isOverflowing;
+ this.axis.y.isOverflowing =
+ elOverflowY === "hidden" ? false : this.axis.y.isOverflowing;
+ this.axis.x.forceVisible =
+ this.options.forceVisible === "x" || this.options.forceVisible === true;
+ this.axis.y.forceVisible =
+ this.options.forceVisible === "y" || this.options.forceVisible === true;
+ this.hideNativeScrollbar();
+ // Set isOverflowing to false if scrollbar is not necessary (content is shorter than offset)
+ var offsetForXScrollbar = this.axis.x.isOverflowing
+ ? this.scrollbarWidth
+ : 0;
+ var offsetForYScrollbar = this.axis.y.isOverflowing
+ ? this.scrollbarWidth
+ : 0;
+ this.axis.x.isOverflowing =
+ this.axis.x.isOverflowing &&
+ contentElScrollWidth > contentWrapperElOffsetWidth - offsetForYScrollbar;
+ this.axis.y.isOverflowing =
+ this.axis.y.isOverflowing &&
+ contentElScrollHeight >
+ contentWrapperElOffsetHeight - offsetForXScrollbar;
+ this.axis.x.scrollbar.size = this.getScrollbarSize("x");
+ this.axis.y.scrollbar.size = this.getScrollbarSize("y");
+ if (this.axis.x.scrollbar.el)
+ this.axis.x.scrollbar.el.style.width = "".concat(this.axis.x.scrollbar.size, "px");
+ if (this.axis.y.scrollbar.el)
+ this.axis.y.scrollbar.el.style.height = "".concat(this.axis.y.scrollbar.size, "px");
+ this.positionScrollbar("x");
+ this.positionScrollbar("y");
+ this.toggleTrackVisibility("x");
+ this.toggleTrackVisibility("y");
+ };
+ /**
+ * Calculate scrollbar size
+ */
+ SimpleBarCore.prototype.getScrollbarSize = function (axis) {
+ var _a, _b;
+ if (axis === void 0) { axis = "y"; }
+ if (!this.axis[axis].isOverflowing || !this.contentEl) {
+ return 0;
+ }
+ var contentSize = this.contentEl[this.axis[axis].scrollSizeAttr];
+ var trackSize = (_b = (_a = this.axis[axis].track.el) === null || _a === void 0 ? void 0 : _a[this.axis[axis].offsetSizeAttr]) !== null && _b !== void 0 ? _b : 0;
+ var scrollbarRatio = trackSize / contentSize;
+ var scrollbarSize;
+ // Calculate new height/position of drag handle.
+ scrollbarSize = Math.max(~~(scrollbarRatio * trackSize), this.options.scrollbarMinSize);
+ if (this.options.scrollbarMaxSize) {
+ scrollbarSize = Math.min(scrollbarSize, this.options.scrollbarMaxSize);
+ }
+ return scrollbarSize;
+ };
+ SimpleBarCore.prototype.positionScrollbar = function (axis) {
+ var _a, _b, _c;
+ if (axis === void 0) { axis = "y"; }
+ var scrollbar = this.axis[axis].scrollbar;
+ if (!this.axis[axis].isOverflowing ||
+ !this.contentWrapperEl ||
+ !scrollbar.el ||
+ !this.elStyles) {
+ return;
+ }
+ var contentSize = this.contentWrapperEl[this.axis[axis].scrollSizeAttr];
+ var trackSize = ((_a = this.axis[axis].track.el) === null || _a === void 0 ? void 0 : _a[this.axis[axis].offsetSizeAttr]) || 0;
+ var hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
+ var scrollOffset = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
+ scrollOffset =
+ axis === "x" &&
+ this.isRtl &&
+ ((_b = SimpleBarCore.getRtlHelpers()) === null || _b === void 0 ? void 0 : _b.isScrollOriginAtZero)
+ ? -scrollOffset
+ : scrollOffset;
+ if (axis === "x" && this.isRtl) {
+ scrollOffset = ((_c = SimpleBarCore.getRtlHelpers()) === null || _c === void 0 ? void 0 : _c.isScrollingToNegative)
+ ? scrollOffset
+ : -scrollOffset;
+ }
+ var scrollPourcent = scrollOffset / (contentSize - hostSize);
+ var handleOffset = ~~((trackSize - scrollbar.size) * scrollPourcent);
+ handleOffset =
+ axis === "x" && this.isRtl
+ ? -handleOffset + (trackSize - scrollbar.size)
+ : handleOffset;
+ scrollbar.el.style.transform =
+ axis === "x"
+ ? "translate3d(".concat(handleOffset, "px, 0, 0)")
+ : "translate3d(0, ".concat(handleOffset, "px, 0)");
+ };
+ SimpleBarCore.prototype.toggleTrackVisibility = function (axis) {
+ if (axis === void 0) { axis = "y"; }
+ var track = this.axis[axis].track.el;
+ var scrollbar = this.axis[axis].scrollbar.el;
+ if (!track || !scrollbar || !this.contentWrapperEl)
+ return;
+ if (this.axis[axis].isOverflowing || this.axis[axis].forceVisible) {
+ track.style.visibility = "visible";
+ this.contentWrapperEl.style[this.axis[axis].overflowAttr] = "scroll";
+ this.el.classList.add("".concat(this.classNames.scrollable, "-").concat(axis));
+ }
+ else {
+ track.style.visibility = "hidden";
+ this.contentWrapperEl.style[this.axis[axis].overflowAttr] = "hidden";
+ this.el.classList.remove("".concat(this.classNames.scrollable, "-").concat(axis));
+ }
+ // Even if forceVisible is enabled, scrollbar itself should be hidden
+ if (this.axis[axis].isOverflowing) {
+ scrollbar.style.display = "block";
+ }
+ else {
+ scrollbar.style.display = "none";
+ }
+ };
+ SimpleBarCore.prototype.showScrollbar = function (axis) {
+ if (axis === void 0) { axis = "y"; }
+ if (this.axis[axis].isOverflowing && !this.axis[axis].scrollbar.isVisible) {
+ addClasses$2(this.axis[axis].scrollbar.el, this.classNames.visible);
+ this.axis[axis].scrollbar.isVisible = true;
+ }
+ };
+ SimpleBarCore.prototype.hideScrollbar = function (axis) {
+ if (axis === void 0) { axis = "y"; }
+ if (this.axis[axis].isOverflowing && this.axis[axis].scrollbar.isVisible) {
+ removeClasses(this.axis[axis].scrollbar.el, this.classNames.visible);
+ this.axis[axis].scrollbar.isVisible = false;
+ }
+ };
+ SimpleBarCore.prototype.hideNativeScrollbar = function () {
+ if (!this.offsetEl)
+ return;
+ this.offsetEl.style[this.isRtl ? "left" : "right"] =
+ this.axis.y.isOverflowing || this.axis.y.forceVisible
+ ? "-".concat(this.scrollbarWidth, "px")
+ : "0px";
+ this.offsetEl.style.bottom =
+ this.axis.x.isOverflowing || this.axis.x.forceVisible
+ ? "-".concat(this.scrollbarWidth, "px")
+ : "0px";
+ };
+ SimpleBarCore.prototype.onMouseMoveForAxis = function (axis) {
+ if (axis === void 0) { axis = "y"; }
+ var currentAxis = this.axis[axis];
+ if (!currentAxis.track.el || !currentAxis.scrollbar.el)
+ return;
+ currentAxis.track.rect = currentAxis.track.el.getBoundingClientRect();
+ currentAxis.scrollbar.rect =
+ currentAxis.scrollbar.el.getBoundingClientRect();
+
+ this.showScrollbar(axis);
+
+ if (this.isWithinBounds(currentAxis.track.rect)) {
+ this.showScrollbar(axis);
+ addClasses$2(currentAxis.track.el, this.classNames.hover);
+ if (this.isWithinBounds(currentAxis.scrollbar.rect)) {
+ addClasses$2(currentAxis.scrollbar.el, this.classNames.hover);
+ }
+ else {
+ removeClasses(currentAxis.scrollbar.el, this.classNames.hover);
+ }
+ }
+ else {
+ removeClasses(currentAxis.track.el, this.classNames.hover);
+ if (this.options.autoHide) {
+ //this.hideScrollbar(axis);
+ }
+ }
+ };
+ SimpleBarCore.prototype.onMouseLeaveForAxis = function (axis) {
+ if (axis === void 0) { axis = "y"; }
+ removeClasses(this.axis[axis].track.el, this.classNames.hover);
+ removeClasses(this.axis[axis].scrollbar.el, this.classNames.hover);
+ if (this.options.autoHide) {
+ this.hideScrollbar(axis);
+ }
+ };
+ /**
+ * on scrollbar handle drag movement starts
+ */
+ SimpleBarCore.prototype.onDragStart = function (e, axis) {
+ var _a;
+ if (axis === void 0) { axis = "y"; }
+ var elDocument = getElementDocument(this.el);
+ var elWindow = getElementWindow(this.el);
+ var scrollbar = this.axis[axis].scrollbar;
+ // Measure how far the user's mouse is from the top of the scrollbar drag handle.
+ var eventOffset = axis === "y" ? e.pageY : e.pageX;
+ this.axis[axis].dragOffset =
+ eventOffset - (((_a = scrollbar.rect) === null || _a === void 0 ? void 0 : _a[this.axis[axis].offsetAttr]) || 0);
+ this.draggedAxis = axis;
+ addClasses$2(this.el, this.classNames.dragging);
+ elDocument.addEventListener("mousemove", this.drag, true);
+ elDocument.addEventListener("mouseup", this.onEndDrag, true);
+ if (this.removePreventClickId === null) {
+ elDocument.addEventListener("click", this.preventClick, true);
+ elDocument.addEventListener("dblclick", this.preventClick, true);
+ }
+ else {
+ elWindow.clearTimeout(this.removePreventClickId);
+ this.removePreventClickId = null;
+ }
+ };
+ SimpleBarCore.prototype.onTrackClick = function (e, axis) {
+ var _this = this;
+ var _a, _b, _c, _d;
+ if (axis === void 0) { axis = "y"; }
+ var currentAxis = this.axis[axis];
+ if (!this.options.clickOnTrack ||
+ !currentAxis.scrollbar.el ||
+ !this.contentWrapperEl)
+ return;
+ // Preventing the event's default to trigger click underneath
+ e.preventDefault();
+ var elWindow = getElementWindow(this.el);
+ this.axis[axis].scrollbar.rect =
+ currentAxis.scrollbar.el.getBoundingClientRect();
+ var scrollbar = this.axis[axis].scrollbar;
+ var scrollbarOffset = (_b = (_a = scrollbar.rect) === null || _a === void 0 ? void 0 : _a[this.axis[axis].offsetAttr]) !== null && _b !== void 0 ? _b : 0;
+ var hostSize = parseInt((_d = (_c = this.elStyles) === null || _c === void 0 ? void 0 : _c[this.axis[axis].sizeAttr]) !== null && _d !== void 0 ? _d : "0px", 10);
+ var scrolled = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
+ var t = axis === "y"
+ ? this.mouseY - scrollbarOffset
+ : this.mouseX - scrollbarOffset;
+ var dir = t < 0 ? -1 : 1;
+ var scrollSize = dir === -1 ? scrolled - hostSize : scrolled + hostSize;
+ var speed = 40;
+ var scrollTo = function () {
+ if (!_this.contentWrapperEl)
+ return;
+ if (dir === -1) {
+ if (scrolled > scrollSize) {
+ scrolled -= speed;
+ _this.contentWrapperEl[_this.axis[axis].scrollOffsetAttr] = scrolled;
+ elWindow.requestAnimationFrame(scrollTo);
+ }
+ }
+ else {
+ if (scrolled < scrollSize) {
+ scrolled += speed;
+ _this.contentWrapperEl[_this.axis[axis].scrollOffsetAttr] = scrolled;
+ elWindow.requestAnimationFrame(scrollTo);
+ }
+ }
+ };
+ scrollTo();
+ };
+ /**
+ * Getter for content element
+ */
+ SimpleBarCore.prototype.getContentElement = function () {
+ return this.contentEl;
+ };
+ /**
+ * Getter for original scrolling element
+ */
+ SimpleBarCore.prototype.getScrollElement = function () {
+ return this.contentWrapperEl;
+ };
+ SimpleBarCore.prototype.removeListeners = function () {
+ var elWindow = getElementWindow(this.el);
+ // Event listeners
+ this.el.removeEventListener("mouseenter", this.onMouseEnter);
+ this.el.removeEventListener("pointerdown", this.onPointerEvent, true);
+ this.el.removeEventListener("mousemove", this.onMouseMove);
+ this.el.removeEventListener("mouseleave", this.onMouseLeave);
+ if (this.contentWrapperEl) {
+ this.contentWrapperEl.removeEventListener("scroll", this.onScroll);
+ }
+ elWindow.removeEventListener("resize", this.onWindowResize);
+ if (this.mutationObserver) {
+ this.mutationObserver.disconnect();
+ }
+ if (this.resizeObserver) {
+ this.resizeObserver.disconnect();
+ }
+ // Cancel all debounced functions
+ this.onMouseMove.cancel();
+ this.onWindowResize.cancel();
+ this.onStopScrolling.cancel();
+ this.onMouseEntered.cancel();
+ };
+ /**
+ * Remove all listeners from DOM nodes
+ */
+ SimpleBarCore.prototype.unMount = function () {
+ this.removeListeners();
+ };
+ /**
+ * Check if mouse is within bounds
+ */
+ SimpleBarCore.prototype.isWithinBounds = function (bbox) {
+ return (this.mouseX >= bbox.left &&
+ this.mouseX <= bbox.left + bbox.width &&
+ this.mouseY >= bbox.top &&
+ this.mouseY <= bbox.top + bbox.height);
+ };
+ /**
+ * Find element children matches query
+ */
+ SimpleBarCore.prototype.findChild = function (el, query) {
+ var matches = el.matches ||
+ el.webkitMatchesSelector ||
+ el.mozMatchesSelector ||
+ el.msMatchesSelector;
+ return Array.prototype.filter.call(el.children, function (child) {
+ return matches.call(child, query);
+ })[0];
+ };
+ SimpleBarCore.rtlHelpers = null;
+ SimpleBarCore.defaultOptions = {
+ forceVisible: false,
+ clickOnTrack: true,
+ scrollbarMinSize: 25,
+ scrollbarMaxSize: 0,
+ ariaLabel: "scrollable content",
+ classNames: {
+ contentEl: "simplebar-content",
+ contentWrapper: "simplebar-content-wrapper",
+ offset: "simplebar-offset",
+ mask: "simplebar-mask",
+ wrapper: "simplebar-wrapper",
+ placeholder: "simplebar-placeholder",
+ scrollbar: "simplebar-scrollbar",
+ track: "simplebar-track",
+ heightAutoObserverWrapperEl: "simplebar-height-auto-observer-wrapper",
+ heightAutoObserverEl: "simplebar-height-auto-observer",
+ visible: "simplebar-visible",
+ horizontal: "simplebar-horizontal",
+ vertical: "simplebar-vertical",
+ hover: "simplebar-hover",
+ dragging: "simplebar-dragging",
+ scrolling: "simplebar-scrolling",
+ scrollable: "simplebar-scrollable",
+ mouseEntered: "simplebar-mouse-entered"
+ },
+ scrollableNode: null,
+ contentNode: null,
+ autoHide: true
+ };
+ /**
+ * Static functions
+ */
+ SimpleBarCore.getOptions = getOptions$2;
+ SimpleBarCore.helpers = helpers;
+ return SimpleBarCore;
+ }());
+
+ var _a = SimpleBarCore.helpers, getOptions = _a.getOptions, addClasses = _a.addClasses;
+ var SimpleBar = /** @class */ (function (_super) {
+ __extends(SimpleBar, _super);
+ function SimpleBar() {
+ var args = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ args[_i] = arguments[_i];
+ }
+ var _this = _super.apply(this, args) || this;
+ // // Save a reference to the instance, so we know this DOM node has already been instancied
+ SimpleBar.instances.set(args[0], _this);
+ return _this;
+ }
+ SimpleBar.initDOMLoadedElements = function () {
+ document.removeEventListener("DOMContentLoaded", this.initDOMLoadedElements);
+ window.removeEventListener("load", this.initDOMLoadedElements);
+ Array.prototype.forEach.call(document.querySelectorAll("[data-simplebar]"), function (el) {
+ if (el.getAttribute("data-simplebar") !== "init" &&
+ !SimpleBar.instances.has(el))
+ new SimpleBar(el, getOptions(el.attributes));
+ });
+ };
+ SimpleBar.removeObserver = function () {
+ var _a;
+ (_a = SimpleBar.globalObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
+ };
+ SimpleBar.prototype.initDOM = function () {
+ var _this = this;
+ var _a, _b, _c;
+ // make sure this element doesn't have the elements yet
+ if (!Array.prototype.filter.call(this.el.children, function (child) {
+ return child.classList.contains(_this.classNames.wrapper);
+ }).length) {
+ // Prepare DOM
+ this.wrapperEl = document.createElement("div");
+ this.contentWrapperEl = document.createElement("div");
+ this.offsetEl = document.createElement("div");
+ this.maskEl = document.createElement("div");
+ this.contentEl = document.createElement("div");
+ this.placeholderEl = document.createElement("div");
+ this.heightAutoObserverWrapperEl = document.createElement("div");
+ this.heightAutoObserverEl = document.createElement("div");
+ addClasses(this.wrapperEl, this.classNames.wrapper);
+ addClasses(this.contentWrapperEl, this.classNames.contentWrapper);
+ addClasses(this.offsetEl, this.classNames.offset);
+ addClasses(this.maskEl, this.classNames.mask);
+ addClasses(this.contentEl, this.classNames.contentEl);
+ addClasses(this.placeholderEl, this.classNames.placeholder);
+ addClasses(this.heightAutoObserverWrapperEl, this.classNames.heightAutoObserverWrapperEl);
+ addClasses(this.heightAutoObserverEl, this.classNames.heightAutoObserverEl);
+ while (this.el.firstChild) {
+ this.contentEl.appendChild(this.el.firstChild);
+ }
+ this.contentWrapperEl.appendChild(this.contentEl);
+ this.offsetEl.appendChild(this.contentWrapperEl);
+ this.maskEl.appendChild(this.offsetEl);
+ this.heightAutoObserverWrapperEl.appendChild(this.heightAutoObserverEl);
+ this.wrapperEl.appendChild(this.heightAutoObserverWrapperEl);
+ this.wrapperEl.appendChild(this.maskEl);
+ this.wrapperEl.appendChild(this.placeholderEl);
+ this.el.appendChild(this.wrapperEl);
+ (_a = this.contentWrapperEl) === null || _a === void 0 ? void 0 : _a.setAttribute("tabindex", "0");
+ (_b = this.contentWrapperEl) === null || _b === void 0 ? void 0 : _b.setAttribute("role", "region");
+ (_c = this.contentWrapperEl) === null || _c === void 0 ? void 0 : _c.setAttribute("aria-label", this.options.ariaLabel);
+ }
+ if (!this.axis.x.track.el || !this.axis.y.track.el) {
+ var track = document.createElement("div");
+ var scrollbar = document.createElement("div");
+ addClasses(track, this.classNames.track);
+ addClasses(scrollbar, this.classNames.scrollbar);
+ track.appendChild(scrollbar);
+ this.axis.x.track.el = track.cloneNode(true);
+ addClasses(this.axis.x.track.el, this.classNames.horizontal);
+ this.axis.y.track.el = track.cloneNode(true);
+ addClasses(this.axis.y.track.el, this.classNames.vertical);
+ this.el.appendChild(this.axis.x.track.el);
+ this.el.appendChild(this.axis.y.track.el);
+ }
+ SimpleBarCore.prototype.initDOM.call(this);
+ this.el.setAttribute("data-simplebar", "init");
+ };
+ SimpleBar.prototype.unMount = function () {
+ SimpleBarCore.prototype.unMount.call(this);
+ SimpleBar.instances["delete"](this.el);
+ };
+ SimpleBar.initHtmlApi = function () {
+ this.initDOMLoadedElements = this.initDOMLoadedElements.bind(this);
+ // MutationObserver is IE11+
+ if (typeof MutationObserver !== "undefined") {
+ // Mutation observer to observe dynamically added elements
+ this.globalObserver = new MutationObserver(SimpleBar.handleMutations);
+ this.globalObserver.observe(document, { childList: true, subtree: true });
+ }
+ // Taken from jQuery `ready` function
+ // Instantiate elements already present on the page
+ if (document.readyState === "complete" || // @ts-ignore: IE specific
+ (document.readyState !== "loading" && !document.documentElement.doScroll)) {
+ // Handle it asynchronously to allow scripts the opportunity to delay init
+ window.setTimeout(this.initDOMLoadedElements);
+ }
+ else {
+ document.addEventListener("DOMContentLoaded", this.initDOMLoadedElements);
+ window.addEventListener("load", this.initDOMLoadedElements);
+ }
+ };
+ SimpleBar.handleMutations = function (mutations) {
+ mutations.forEach(function (mutation) {
+ mutation.addedNodes.forEach(function (addedNode) {
+ if (addedNode.nodeType === 1) {
+ if (addedNode.hasAttribute("data-simplebar")) {
+ !SimpleBar.instances.has(addedNode) &&
+ document.documentElement.contains(addedNode) &&
+ new SimpleBar(addedNode, getOptions(addedNode.attributes));
+ }
+ else {
+ addedNode
+ .querySelectorAll("[data-simplebar]")
+ .forEach(function (el) {
+ if (el.getAttribute("data-simplebar") !== "init" &&
+ !SimpleBar.instances.has(el) &&
+ document.documentElement.contains(el))
+ new SimpleBar(el, getOptions(el.attributes));
+ });
+ }
+ }
+ });
+ mutation.removedNodes.forEach(function (removedNode) {
+ if (removedNode.nodeType === 1) {
+ if (removedNode.getAttribute("data-simplebar") === "init") {
+ SimpleBar.instances.has(removedNode) &&
+ !document.documentElement.contains(removedNode) &&
+ SimpleBar.instances.get(removedNode).unMount();
+ }
+ else {
+ Array.prototype.forEach.call(removedNode.querySelectorAll("[data-simplebar=\"init\"]"), function (el) {
+ SimpleBar.instances.has(el) &&
+ !document.documentElement.contains(el) &&
+ SimpleBar.instances.get(el).unMount();
+ });
+ }
+ }
+ });
+ });
+ };
+ SimpleBar.instances = new WeakMap();
+ return SimpleBar;
+ }(SimpleBarCore));
+ /**
+ * HTML API
+ * Called only in a browser env.
+ */
+ if (canUseDom) {
+ SimpleBar.initHtmlApi();
+ }
+
+ return SimpleBar;
+
+})();
\ No newline at end of file
diff --git a/src/app/dev/platforms/desktop/DevToys.MacOS/wwwroot/index.html b/src/app/dev/platforms/desktop/DevToys.MacOS/wwwroot/index.html
index 5f8821da5..5d37d4c99 100644
--- a/src/app/dev/platforms/desktop/DevToys.MacOS/wwwroot/index.html
+++ b/src/app/dev/platforms/desktop/DevToys.MacOS/wwwroot/index.html
@@ -9,6 +9,7 @@
<script src="_content/DevToys.Blazor/js/require.js"></script>
<script src="_content/DevToys.Blazor/js/devtoys.js" type="text/javascript"></script>
<script src="_content/DevToys.Blazor/js/devtoys.g.js" type="text/javascript"></script>
+ <script src="_content/DevToys.Blazor/js/simplebar-modified.js" type="text/javascript"></script>
<link href="_content/DevToys.Blazor/css/app.css" rel="stylesheet" />
<link href="_content/DevToys.Blazor/css/devtoys.g.css" rel="stylesheet" />
diff --git a/src/app/dev/platforms/desktop/DevToys.Windows/wwwroot/index.html b/src/app/dev/platforms/desktop/DevToys.Windows/wwwroot/index.html
index 369eda76a..b566bff3b 100644
--- a/src/app/dev/platforms/desktop/DevToys.Windows/wwwroot/index.html
+++ b/src/app/dev/platforms/desktop/DevToys.Windows/wwwroot/index.html
@@ -9,6 +9,7 @@
<script src="_content/DevToys.Blazor/js/require.js"></script>
<script src="_content/DevToys.Blazor/js/devtoys.js" type="text/javascript"></script>
<script src="_content/DevToys.Blazor/js/devtoys.g.js" type="text/javascript"></script>
+ <script src="_content/DevToys.Blazor/js/simplebar-modified.js" type="text/javascript"></script>
<link href="_content/DevToys.Blazor/css/app.css" rel="stylesheet" />
<link href="_content/DevToys.Blazor/css/devtoys.g.css" rel="stylesheet" />