-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bdc9c1
commit ab45aa7
Showing
55 changed files
with
11,229 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 28 additions & 13 deletions
41
docs/HeadlessBlazor.Docs.Client/Examples/Dropdown/SimpleDropdownExample.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,28 @@ | ||
<HBDropdown class="dropdown d-inline-block"> | ||
<HBDropdownTrigger class="btn btn-primary dropdown-toggle">Click Me</HBDropdownTrigger> | ||
<HBDropdownItems class="dropdown-menu show"> | ||
<HBDropdownItem class="dropdown-item">Default</HBDropdownItem> | ||
<HBDropdownItemButton class="dropdown-item">Button</HBDropdownItemButton> | ||
<HBDropdownItemButton class="dropdown-item" disabled="true">Disabled Button</HBDropdownItemButton> | ||
<HBDropdownItemButton class="dropdown-item" @onclick:stopPropagation="true">Button (Stop Propagation)</HBDropdownItemButton> | ||
<HBDropdownItemLink class="dropdown-item">Link</HBDropdownItemLink> | ||
<HBDropdownItemLink class="dropdown-item" href="#" @onclick:preventDefault="true">Link (Prevent Default)</HBDropdownItemLink> | ||
<HBDropdownItemLink class="dropdown-item" href="#" @onclick:stopPropagation="true">Link (Stop Propagation)</HBDropdownItemLink> | ||
<HBDropdownItemLink class="dropdown-item" href="#" OnClickPreventDefault="true" OnClickStopPropagation="true">Link (Prevent Default and Stop Propagation)</HBDropdownItemLink> | ||
</HBDropdownItems> | ||
</HBDropdown> | ||
<div class="d-flex justify-content-between"> | ||
<HBDropdown class="dropdown d-inline-block"> | ||
<HBDropdownTrigger class="btn btn-primary dropdown-toggle">Click Me</HBDropdownTrigger> | ||
<HBDropdownItems class="@(context.IsOpen ? "dropdown-menu show" : "dropdown-menu")"> | ||
<HBDropdownItem class="dropdown-item">Default</HBDropdownItem> | ||
<HBDropdownItemButton class="dropdown-item">Button</HBDropdownItemButton> | ||
<HBDropdownItemButton class="dropdown-item" disabled="true">Disabled Button</HBDropdownItemButton> | ||
<HBDropdownItemButton class="dropdown-item" @onclick:stopPropagation="true">Button (Stop Propagation)</HBDropdownItemButton> | ||
<HBDropdownItemLink class="dropdown-item">Link</HBDropdownItemLink> | ||
<HBDropdownItemLink class="dropdown-item" href="#" @onclick:preventDefault="true">Link (Prevent Default)</HBDropdownItemLink> | ||
<HBDropdownItemLink class="dropdown-item" href="#" @onclick:stopPropagation="true">Link (Stop Propagation)</HBDropdownItemLink> | ||
<HBDropdownItemLink class="dropdown-item" href="#" OnClickPreventDefault="true" OnClickStopPropagation="true">Link (Prevent Default and Stop Propagation)</HBDropdownItemLink> | ||
</HBDropdownItems> | ||
</HBDropdown> | ||
<HBDropdown class="dropdown d-inline-block"> | ||
<HBDropdownTrigger class="btn btn-primary dropdown-toggle">Click Me</HBDropdownTrigger> | ||
<HBDropdownItems class="@(context.IsOpen ? "dropdown-menu show" : "dropdown-menu")"> | ||
<HBDropdownItem class="dropdown-item">Default</HBDropdownItem> | ||
<HBDropdownItemButton class="dropdown-item">Button</HBDropdownItemButton> | ||
<HBDropdownItemButton class="dropdown-item" disabled="true">Disabled Button</HBDropdownItemButton> | ||
<HBDropdownItemButton class="dropdown-item" @onclick:stopPropagation="true">Button (Stop Propagation)</HBDropdownItemButton> | ||
<HBDropdownItemLink class="dropdown-item">Link</HBDropdownItemLink> | ||
<HBDropdownItemLink class="dropdown-item" href="#" @onclick:preventDefault="true">Link (Prevent Default)</HBDropdownItemLink> | ||
<HBDropdownItemLink class="dropdown-item" href="#" @onclick:stopPropagation="true">Link (Stop Propagation)</HBDropdownItemLink> | ||
<HBDropdownItemLink class="dropdown-item" href="#" OnClickPreventDefault="true" OnClickStopPropagation="true">Link (Prevent Default and Stop Propagation)</HBDropdownItemLink> | ||
</HBDropdownItems> | ||
</HBDropdown> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
.page-root > * { | ||
.page-root { | ||
height: 200vh; | ||
} | ||
|
||
.page-root > * { | ||
padding: 0.5rem 1rem; | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "headlessblazor", | ||
"version": "1.0.0", | ||
"description": "<h1>\r <img src=\"HeadlessBlazorLogo.svg\" width=\"24\" hspace=\"4\" /> Headless Blazor\r </h1>", | ||
"main": "index.js", | ||
"directories": { | ||
"doc": "docs" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@floating-ui/dom": "^1.6.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 9 additions & 8 deletions
17
src/HeadlessBlazor.Core/Behaviors/HBOutsideClickBehavior.razor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@implements IAsyncDisposable | ||
@code { | ||
private DotNetObjectReference<HBPopoverBehavior>? dotNetObjRef; | ||
private IJSObjectReference? popover; | ||
|
||
[Inject] | ||
private IJSRuntime JS { get; set; } = default!; | ||
|
||
[Parameter] | ||
public IReferenceable Container { get; set; } = default!; | ||
|
||
public async ValueTask DisposeAsync() | ||
{ | ||
if (popover is not null) | ||
{ | ||
await popover.InvokeVoidAsync("dispose"); | ||
await popover.DisposeAsync(); | ||
popover = null; | ||
} | ||
|
||
dotNetObjRef?.Dispose(); | ||
} | ||
|
||
protected override async Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
if (firstRender) | ||
{ | ||
dotNetObjRef ??= DotNetObjectReference.Create(this); | ||
var moduleName = nameof(HBPopoverBehavior); | ||
var module = await JS.InvokeAsync<IJSObjectReference>("import", $"./_content/HeadlessBlazor.Core/Behaviors/{moduleName}.razor.js"); | ||
popover = await module.InvokeAsync<IJSObjectReference>($"{moduleName}.createInstance", Container.ElementReference, dotNetObjRef); | ||
await module.DisposeAsync(); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/HeadlessBlazor.Core/Behaviors/HBPopoverBehavior.razor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { | ||
autoUpdate, | ||
computePosition, | ||
flip | ||
} from '../@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs'; | ||
|
||
export class HBPopoverBehavior { | ||
|
||
/** | ||
* @static | ||
* @param {Element} container | ||
* @param {any} dotNetRef | ||
* @returns {HBPopoverBehavior} | ||
*/ | ||
static createInstance(container) { | ||
return new HBPopoverBehavior(container); | ||
} | ||
|
||
/** | ||
* Creates a new instance of HBPopoverBehavior. | ||
* @constructor | ||
* @param {Element} container | ||
* @param {any} dotNetRef | ||
*/ | ||
constructor(container) { | ||
const anchor = container.querySelector('[hb-popover-anchor]'); | ||
const floater = container.querySelector('[hb-popover]'); | ||
|
||
this.dispose = autoUpdate(anchor, floater, () => { | ||
computePosition(anchor, floater, { | ||
placement: 'bottom-start', | ||
middleware: [flip()] | ||
}).then(({ x, y }) => { | ||
Object.assign(floater.style, { | ||
display: `block`, | ||
left: `${x}px`, | ||
top: `${y}px`, | ||
}); | ||
}) | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace HeadlessBlazor.Behaviors; | ||
|
||
public interface ICloseable : IReferenceable | ||
public interface ICloseable | ||
{ | ||
Task CloseAsync(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021-present Floating UI contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# @floating-ui/core | ||
|
||
This is the platform-agnostic core of Floating UI, exposing the main | ||
`computePosition` function but no platform interface logic. |
Oops, something went wrong.