@@ -213,6 +241,7 @@
@inject IScrollHandler _scrollHandler
@inject IFocusHandler _focusHandler
+@inject IResizeHandler _resizeHandler
@inject IClickBoundariesHandler _clichHandler;
@inject IClipboardHandler _clipboardHandler;
@inject IGlobalMouseEventHandler _globalMouseEventHandler;
@@ -224,6 +253,7 @@
await ScrollEventHandler();
await ClickEventHandler();
await GlobalClickEventHandler();
+ await ResizeEventHandler();
}
//Click examples
@@ -248,7 +278,7 @@
}
private async Task PageClick(MouseEventArgs args, string message)
{
- _logMessage += $"Page clicked {message} X pos: {args.ClientX}, Y pos: {args.ClientY}{Environment.NewLine}";
+ _logMessage += $"{DateTime.Now.TimeOfDay}: Page clicked {message} X pos: {args.ClientX}, Y pos: {args.ClientY}{Environment.NewLine}";
StateHasChanged();
await _log.ScrollToEndAsync();
@@ -269,16 +299,16 @@
}
else
{
- _mouseDown = await _globalMouseEventHandler.RegisterPageMouseDownAsync(async (args) => await PageMouseEvents(args, "Document Mouse DOWN"));
- _mouseUp = await _globalMouseEventHandler.RegisterPageMouseUpAsync(async (args) => await PageMouseEvents(args, "Document Mouse UP"));
- _mouseMove = await _globalMouseEventHandler.RegisterPageMouseMoveAsync(async (args) => await PageMouseEvents(args, "Document Mouse MOVE"));
+ _mouseDown = await _globalMouseEventHandler.RegisterPageMouseDownAsync(async (args) => await PageMouseEvents(args, "Mouse DOWN"));
+ _mouseUp = await _globalMouseEventHandler.RegisterPageMouseUpAsync(async (args) => await PageMouseEvents(args, "Mouse UP"));
+ _mouseMove = await _globalMouseEventHandler.RegisterPageMouseMoveAsync(async (args) => await PageMouseEvents(args, "Mouse MOVE"));
}
_clickSubscribed2 = !_clickSubscribed2;
}
private async Task PageMouseEvents(MouseEventArgs args, string message)
{
- _logMessage3 += $"Page clicked {message} X pos: {args.ClientX}, Y pos: {args.ClientY}, Buttons: {args.Buttons}{Environment.NewLine}";
+ _logMessage3 += $"{DateTime.Now.TimeOfDay}: Global Mouse event: {message} X pos: {args.ClientX}, Y pos: {args.ClientY}, Buttons: {args.Buttons}{Environment.NewLine}";
StateHasChanged();
await _log3.ScrollToEndAsync();
@@ -290,7 +320,7 @@
{
await _focusHandler.StoreFocusedElementAsync();
_focusMsg = "Focused element stored, click somewhere else and do not hover on RED area.";
- }
+ }
private async Task RestoreFocus()
{
await _focusHandler.RestoreStoredElementFocusAsync();
@@ -335,7 +365,7 @@
private string _logMessage2;
private async Task PageScrolled(ScrollEventArgs args)
{
- _logMessage2 += $"Page scrolled: X pos: {args.X}, Y pos: {args.Y}{Environment.NewLine}";
+ _logMessage2 += $"{DateTime.Now.TimeOfDay}: Page scrolled: X pos: {args.X}, Y pos: {args.Y}{Environment.NewLine}";
StateHasChanged();
await _log2.ScrollToEndAsync();
@@ -356,6 +386,35 @@
_scrollSubscribed = !_scrollSubscribed;
}
+ //Resize JS
+ private bool _resizeSubscribed;
+ private async Task ResizeEventHandler()
+ {
+ if (_resizeSubscribed)
+ {
+ await _resizeHandler.RemovePageResizeAsync(_scrollEventId);
+ await _resizeHandler.RemoveResizeAsync(_resizeElement);
+ }
+ else
+ {
+ _scrollEventId = await _resizeHandler.RegisterPageResizeAsync(arg => Resized(arg, "Window resized"));
+ await _resizeHandler.RegisterResizeAsync(_resizeElement, arg => Resized(arg, "Textarea resized"));
+ }
+
+ _resizeSubscribed = !_resizeSubscribed;
+ }
+
+ private ElementReference _resizeElement;
+ private ElementReference _log4;
+ private string _logMessage4;
+ private async Task Resized(ResizeEventArgs args, string message)
+ {
+ _logMessage4 += $"{DateTime.Now.TimeOfDay}: {message} - Width: {args.Width}, Height: {args.Height}{Environment.NewLine}";
+ StateHasChanged();
+
+ await _log4.ScrollToEndAsync();
+ }
+
//Clipboard JS
private ElementReference _copyInput;
private string _codedString = "Copy string value form C# code...";
@@ -391,5 +450,10 @@
{
await _clipboardHandler.DisposeAsync();
}
+
+ if (_resizeHandler is not null)
+ {
+ await _resizeHandler.DisposeAsync();
+ }
}
}
\ No newline at end of file
diff --git a/demo/Blazor.Components.DemoApp/Components/Tabs.razor b/demo/Blazor.Components.DemoApp/Components/Tabs.razor
new file mode 100644
index 00000000..f5e2d2fa
--- /dev/null
+++ b/demo/Blazor.Components.DemoApp/Components/Tabs.razor
@@ -0,0 +1,167 @@
+
Tabs Components
+
+ Blazor component that renders customizable Tabs element panel with many tabs and custom content. For usege see soruce code and docs on
+ Github .
+ Majorsoft.Blazor.Components.Tabs package is available on Nuget
+
+
+
+
TabsPanel with TabItems
+
Renders TabsPanel
container for TabItem
components with custumizable header and content.
+
+
+
+ Active tab color (Name, RGB, Hex, HSL):
+
+
+
+
+ Inactive tabs color (Name, RGB, Hex, HSL):
+
+
+
+
+ Tabs Hover color (Name, RGB, Hex, HSL):
+
+
+
+
+ Tab items Width (0 is auto): @(_width)px
+ _width = int.Parse(e.Value?.ToString()))" />
+
+
+
+
+ Tab items Height (0 is auto): @(_height)px
+ _height = int.Parse(e.Value?.ToString()))" />
+
+
+
+
+
+
+
+ Tabs horizontal positon:
+ @foreach (var item in Enum.GetValues(typeof(TabPositons)))
+ {
+ @item
+ }
+
+
+
+
+
+
+
+
+
+
+
+ The first tab
+
+
+
+
+
+ The second tab
+
+
+
+
+
+ This tab can be disabled
+ And also any TabItem
can be disabled by using Disabled
property.
+
+
+
+
+
+ Tab with icon in header
+
+
+
+
+
+
+
+
+
+ Tabs Event log :
+
+
+
+
+
+
+@using System.Linq;
+
+@code {
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ if (firstRender)
+ {
+ await _tabs.InnerElementReference.FocusAsync();
+
+ //Group
+ _activeTab = _tab2;
+ _tabsCount = _tabs.TabCount;
+ StateHasChanged();
+ }
+ }
+
+ private string _activeColor = "DodgerBlue";
+ private string _inactiveColor = "White";
+ private string _hoverColor = "WhiteSmoke";
+ private int _width = 135;
+ private int _height = 40;
+ private TabPositons _tabPositon = TabPositons.Left;
+ private bool _isAnimated = true;
+ private bool _allTabsDisabled = false;
+ private bool _isTabDisabled = false;
+
+ private int _tabsCount;
+
+ private TabsPanel _tabs;
+ private TabItem _activeTab;
+ private TabItem _tab1;
+ private TabItem _tab2;
+ private TabItem _tab3;
+ private TabItem _tab4;
+
+ private ElementReference _log;
+ private string _tabsLog;
+
+ private async Task OnTabChanged(TabItem tab)
+ {
+ _activeTab = tab;
+ var index = _tabs.Tabs.ToList().IndexOf(tab);
+ _tabsLog = await WriteLog(_tabsLog, $"Tab item activated event Active tab index: {index}");
+ }
+
+ private async Task
WriteLog(string log, string message)
+ {
+ log += $"{DateTime.Now.TimeOfDay}: {message}. \r\n";
+ await _log.ScrollToEndAsync();
+
+ return log;
+ }
+}
\ No newline at end of file
diff --git a/demo/Blazor.Components.DemoApp/Components/Toggle.razor b/demo/Blazor.Components.DemoApp/Components/Toggle.razor
new file mode 100644
index 00000000..fd20e641
--- /dev/null
+++ b/demo/Blazor.Components.DemoApp/Components/Toggle.razor
@@ -0,0 +1,292 @@
+Toggler Components
+
+ Blazor component that renders customizable Toggle Switch and Toggle Button components. For usege see soruce code and docs on
+ Github .
+ Majorsoft.Blazor.Components.Toggle package is available on Nuget
+
+
+
+
+ Toggle switch
+
+
Renders HTML input styled as Toggle switch with customizable size and color, etc.
+
+
+
+ Toggle switch On color (Name, RGB, Hex, HSL):
+
+
+
+
+ Toggle switch Off color (Name, RGB, Hex, HSL):
+
+
+
+
+ Toggle switch Width: @(_width)px
+ _width = int.Parse(e.Value?.ToString()))" />
+
+
+
+
+ Toggle switch Height: @(_height)px
+ _height = int.Parse(e.Value?.ToString()))" />
+
+
+
+
+
+
+
+ Toggle switch Style:
+ @foreach (var item in Enum.GetValues(typeof(ToggleSwitchStyle)))
+ {
+ @item
+ }
+
+
+
+
+
+
+
+
+ Toggle switch Event log :
+
+
+
+
+
+
+
+ Toggle button
+
+
Renders HTML button styled as Toggle button with custom content and customizable size, color, etc.
+
+
+
+ Toggle button On color (Name, RGB, Hex, HSL):
+
+
+
+
+ Toggle button Off color (Name, RGB, Hex, HSL):
+
+
+
+
+ Toggle button Hover color (Name, RGB, Hex, HSL):
+
+
+
+
+ Toggle button Width: @(_buttonWidth)px
+ _buttonWidth = int.Parse(e.Value?.ToString()))" />
+
+
+
+
+ Toggle button Height: @(_buttonHeight)px
+ _buttonHeight = int.Parse(e.Value?.ToString()))" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Toggle button Event log :
+
+
+
+
+
+
+ Other Toggle button examples:
+
+ B
+
+
+ I
+
+
+ U
+
+
+
+
+
+
+
+
+ Toggle button group
+
+
Renders a container for HTML button styled as Toggle button with custom content and customizable size, color, etc. Also allows only one toggle button to be Checked.
+
+
+
+
+
+ @*ToggleButtons can be configured as regular ToggleButton*@
+
+
+
+ 1
+
+
+ 2
+
+
+ 3
+
+
+
+
+
+
+
+
+ Toggle Button group Event log :
+
+
+
+
+
+
+@using System.Linq;
+
+@code {
+ //Switch
+ private ToggleSwitch _toggleSwitch;
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ if (firstRender)
+ {
+ await _toggleSwitch.InnerElementReference.FocusAsync();
+
+ //Group
+ _activeButton = _btn1;
+ _btnCount = _btnGroup.ButtonCount;
+ StateHasChanged();
+ }
+ }
+
+ private string _onColor = "DodgerBlue";
+ private string _offColor = "DarkGray";
+ private int _width = 50;
+ private int _height = 22;
+ private bool _isChecked = true;
+ private bool _disabled = false;
+ private ToggleSwitchStyle _styleType = ToggleSwitchStyle.Circle;
+
+ private ElementReference _log1;
+ private string _swithch1Log;
+
+ private async Task OnToggleSwitched(bool val)
+ {
+ _isChecked = val;
+ _swithch1Log = await WriteLog(_swithch1Log, $"Toggle Switched event currently Checked: {val}");
+ }
+
+ //Button
+ private ToggleButton _toggleButton;
+
+ private string _buttonOnColor = "#5ec2f7";
+ private string _buttonOffColor = "white";
+ private string _buttonHoverColor = "WhiteSmoke";
+ private int _buttonWidth = 30;
+ private int _buttonHeight = 30;
+ private bool _isButtonChecked = true;
+ private bool _buttonDisabled = false;
+
+ private ElementReference _log2;
+ private string _button1Log;
+
+ private async Task OnToggleClicked(bool val)
+ {
+ _isButtonChecked = val;
+ _button1Log = await WriteLog(_button1Log, $"Toggle Button event currently Checked: {val}");
+ }
+
+ //Button group
+ private ToggleButtonGroup _btnGroup;
+ private ToggleButton _activeButton;
+ private ToggleButton _btn1;
+ private ToggleButton _btn2;
+ private ToggleButton _btn3;
+ private bool _buttonGroupDisabled = false;
+ private bool _mustToggled = false;
+ private int _btnCount = 0;
+ private string _btnGroupOnColor = "#a4edd5";
+
+ private ElementReference _log3;
+ private string _buttonGroupLog;
+
+ private async Task OnToggleGroupClicked(ToggleButton active)
+ {
+ _activeButton = active;
+ var index = _btnGroup.Buttons.ToList().IndexOf(active);
+ _buttonGroupLog = await WriteLog(_buttonGroupLog, $"Toggle Button group event Active button index: {index}");
+ }
+
+
+ private async Task WriteLog(string log, string message)
+ {
+ log += $"{DateTime.Now.TimeOfDay}: {message}. \r\n";
+ await _log1.ScrollToEndAsync();
+ await _log2.ScrollToEndAsync();
+ await _log3.ScrollToEndAsync();
+
+ return log;
+ }
+}
\ No newline at end of file
diff --git a/demo/Blazor.Components.DemoApp/Components/Typeahead.razor b/demo/Blazor.Components.DemoApp/Components/Typeahead.razor
index 4fc2c237..b17480d4 100644
--- a/demo/Blazor.Components.DemoApp/Components/Typeahead.razor
+++ b/demo/Blazor.Components.DemoApp/Components/Typeahead.razor
@@ -63,7 +63,7 @@ textarea {