formaui-net.Framework.Browser.Interop
1.0.0-preview.27
Prefix Reserved
dotnet add package formaui-net.Framework.Browser.Interop --version 1.0.0-preview.27
NuGet\Install-Package formaui-net.Framework.Browser.Interop -Version 1.0.0-preview.27
<PackageReference Include="formaui-net.Framework.Browser.Interop" Version="1.0.0-preview.27" />
<PackageVersion Include="formaui-net.Framework.Browser.Interop" Version="1.0.0-preview.27" />
<PackageReference Include="formaui-net.Framework.Browser.Interop" />
paket add formaui-net.Framework.Browser.Interop --version 1.0.0-preview.27
#r "nuget: formaui-net.Framework.Browser.Interop, 1.0.0-preview.27"
#:package formaui-net.Framework.Browser.Interop@1.0.0-preview.27
#addin nuget:?package=formaui-net.Framework.Browser.Interop&version=1.0.0-preview.27&prerelease
#tool nuget:?package=formaui-net.Framework.Browser.Interop&version=1.0.0-preview.27&prerelease
Forma.Framework.Browser.Interop
The browser capabilities Forma's components reach through JavaScript. The DOM watcher and engine give
an owner typed objects for what it observes of its elements and what it does to them, with one
lifetime and one notification path for all of them. Beside them, scripts with typed C# wrappers:
behaviors that attach to an element for a lifetime, such as a drop zone or an anchored popover; operations
that make a single call, such as writing to the clipboard; and the browser side of components such as
FormaDialog and FormaWindow.
The package comes with formaui-net.Blazor. It is built on Forma.Framework.JavaScript.Interop and
implements the abstractions of Forma.Framework.Browser, where the observations, the options and
states they take and report, and INativeOperations live. The watcher and engine sit at the root of
the Forma.Framework.Browser.Interop namespace with the registrations they make, and each capability
area has a namespace beneath it, such as Scrolling. The wrappers sit in Behaviors, Operations and
Components. The scripts are served from _content/forma/browser/scripts/.
The DOM watcher and engine
A component reaches its watcher and engine as Context.DomWatcher and Context.DomEngine; its
context makes them on first use and releases everything they hold when the component is disposed, in
one call to the browser. The engine acts through the watcher it borrows, so an element got from the
engine both observes and acts, and one got from the watcher only observes.
An observation hands each state the browser measures to its handler, the first one included, and an interaction keeps running in the browser. Each is created once and brought in step with the component after every render; a request equal to the one the browser holds makes no call, and overlapping calls join one settle. A freeze pane that reports how far its content can move and steps it with its arrows:
using Forma.Framework.Browser;
using Forma.Framework.Browser.Interop;
private IDomObservation<ScrollWatchOptions, ScrollState>? _scrollState;
private DomInteraction<ScrollInteractionOptions>? _scrolling;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
var scroll = Context.DomEngine.GetElement(_viewport).Scroll;
var watching = scroll.WatchAsync(HandleScrollStateAsync, WatchOptions);
var attaching = scroll.AttachAsync(InteractionOptions, WantsInteraction);
_scrollState = await watching;
_scrolling = await attaching;
}
if (_scrollState is { } scrollState && _scrolling is { } scrolling)
{
await Task.WhenAll(
scrollState.SyncAsync(_viewport, WatchOptions),
scrolling.SyncAsync(_viewport, InteractionOptions, WantsInteraction));
}
}
// The state arrives off the renderer, so the render is marshalled back onto it.
private Task HandleScrollStateAsync(ScrollState state)
{
_state = state;
return InvokeAsync(StateHasChanged);
}
A one-off action is a method on the element: Scroll.StepAsync moves it a step and reports whether
it started moving.
| Capability | Watcher | Engine |
|---|---|---|
Focus |
WatchAsync: whether the reader is within the element, and which of its items holds the focus, named by the attribute its items carry |
AttachAsync: where the focus goes inside the element, from Tab wrapping, regions Tab visits first, one roving Tab stop and the element taking the focus when the one holding it goes away, each selectable alone |
Geometry |
WatchSizeAsync: the element's size along its writing mode's inline and block axes, its border box as laid out |
|
Intersection |
WatchAsync: whether the element is in view of its root, or of the viewport, grown by a margin |
|
Scroll |
WatchAsync: whether the content can still move each way, how far its frozen parts reach, and its visible extent where asked for |
AttachAsync: a wheel route moving the content along its inline axis, and buttons stepping it, both run in the browser; StepAsync: one step to the next stop |
Text |
WatchSelectionAsync: the range a text field's selection spans, as the reader moves it; WatchAutofillAsync: whether the browser filled the field without the reader typing |
A text field's edits are a DomTextEdits, made over the component's engine as it initializes, from the
text it first shows: .NET applies the edits the field sends, in revision order, as each is typed or as
the field commits, and writes a text of its own through the field. The field renders GetShownText,
which keeps the text it was last rendered or written with while the text its component shows is the
one .NET holds, so a render never writes back over typing, and syncs the edits with that text after each
render, which attaches them and writes a text of .NET's own into the field:
<input @ref="RootElement" value="@ShownText" />
private DomTextEdits _edits = default!;
private string? ShownText
=> _edits.GetShownText(CurrentValueAsString);
protected override void OnInitialized()
=> _edits = new DomTextEdits(Context.DomEngine, CurrentValueAsString, HandleTextChangedAsync);
protected override Task OnAfterRenderAsync(bool firstRender)
=> _edits.SyncAsync(RootElement, CurrentValueAsString, new TextEditOptions { SendsOnInput = true });
TextEditOptions also names the most the field accepts, and where it shows a running count of its
characters, which the browser keeps as the reader types. An element whose script owns its text, as a rich text
editor's canvas, follows the same edits: the script provides the text they read and write through
TextSources.provide, and commits it at its own pace. A form's submission waits in the browser while an
edit of a field in it is still on its way, and is made again, by the same submitter, once the edit has
reached .NET. The field takes no Blazor event, since Blazor
sends the field's whole text with every event a .NET handler takes on it or on an element the event
reaches, and neither does an element around a text field: a surface follows the focus within it
through Focus.WatchAsync, and a field's selection through Text.WatchSelectionAsync.
A host registers the bridge the watchers and engines of one circuit share their imports through with
AddFormaBrowserServices, which AddFormaUIServices calls. On Interactive Server, AddFormaServerIntegration also
registers Forma.Framework.Browser.Blazor.Server, which refreshes a circuit's observations, and has
each text field whose edits could have been lost send its whole text, once its connection is restored.
A watcher made with no bridge imports through one of its own, and its observations recover through
RefreshAsync.
Using a wrapper
A component builds a wrapper from its Context.JS, attaches a behavior from OnAfterRenderAsync,
and disposes it from DisposeAsyncCore. A file viewer that pans a zoomed image with the pointer:
using Forma.Framework.Browser.Interop.Behaviors;
public sealed partial class FormaFileViewer : FormaElementBase
{
private PanGesture _pan = default!;
private ElementReference _imageFrameElement;
protected override void OnInitialized()
=> _pan = new PanGesture(Context.JS);
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await _pan.AttachAsync(_imageFrameElement, "file-viewer.pan", "zoomed");
}
}
protected override async ValueTask DisposeAsyncCore()
{
await _pan.DisposeAsync();
await base.DisposeAsyncCore();
}
}
An operation is called whenever it is needed:
using Forma.Framework.Browser.Interop.Operations;
await using var clipboard = new Clipboard(Context.JS);
await clipboard.WriteAsync(link);
A wrapper's calls report whether they ran, so a component carries on when its circuit has gone.
Behaviors
| Wrapper | What it does |
|---|---|
AnchoredPopover |
Keeps a popover positioned against its anchor while it is open. |
DropZone |
A drag-and-drop target, telling its owner through HandleDropAsync which of its targets took the drop. |
FileDropZone |
Hands dropped files to the file input inside an element. |
FilePreview |
Renders thumbnails of a file input's selected files into a container's images. |
PanGesture |
Drags a scroll container's contents with the pointer. |
ReorderInteraction |
Moves an item to a new position in its list by dragging or by keyboard, telling its owner through HandleReorderAsync. |
Scroll |
Moves a container to its center. |
Wheel |
Answers a wheel turned over a surface by telling its owner the direction through HandleWheelAsync. |
DragGesture.js, the press, move and release of a drag, is composed by other scripts and has no
wrapper.
Operations
| Wrapper | What it does |
|---|---|
Asset |
Loads a module, stylesheet or SVG sprite once per page. |
CheckBox |
Sets whether a checkbox shows as indeterminate. |
Clipboard |
Places text on the clipboard. |
DocumentOrder |
Reads the order elements stand in within the document. |
Download |
Hands the reader a file to save. |
ElementLabels |
Reads the label each element is read by, its own aria-label or its text. |
Embedding |
Loads a third-party embed script and has it process the markup rendered since. |
Playback |
Mutes a media element, resuming it if it is paused. |
Print |
Prints the page, or a piece of markup dressed in the page's stylesheets. |
Share |
Offers a title and URL to the platform's share surface, and reports whether it has one. |
TextEntry |
Reads or writes a text entry's selected range. |
INativeOperations, in Forma.Framework.Browser, is a host's own way to save a file and share an
address, for a web view that does neither. CanSave and CanShare tell whether the host does each.
Download, Print and Share take it where the host registers one that does, and take the browser's
path where the host hasn't registered one, does neither, or declines.
Pointer.js, a pointer captured to one element for the rest of its gesture, is composed by
DragGesture.js alone, without a wrapper.
Components
| Wrapper | What it does |
|---|---|
Dialog |
Opens and closes a native dialog as a modal. |
Frame |
Moves a frame by its drag region, resizes it at its edges, steps it with the arrow keys and holds it within its bounds. |
Splitter |
Drags a splitter's bar along its axis, telling its owner the travel once a frame and the drag's end. |
Virtualize |
Tells a virtualized list's owner where the list stands in what scrolls it and how much room its drawn items take, and scrolls it to an offset or an item. |
Window |
Shows a window in the top layer, raises it in front of the others, returns focus to where it was inside it, and tells its owner of each press inside it. |
On a statically rendered page
A page rendered statically has no renderer for a component to call into, so the assembly's JavaScript initializer,
which Blazor loads on every page, runs the scripts a component draws for there: ShareMenu.js enables the share
sheet's Copy Link, Print and device share where the browser can run each, and runs the one pressed, and Stepper.js
measures a stepper whose names may not fit. Each finds its components again after every enhanced update. A host
needs nothing to set them up.
A control's tooltip
The same initializer installs Tooltip.js on every page, in a Web App and in a Blazor Hybrid web view alike. It shows
the FormaTooltip a control names in its aria-describedby beside the control:
- after the pointer rests on the control a moment, at once when the keyboard's focus reaches it, and on a tap;
- while the pointer stays on the control or the tooltip, or the control keeps the focus;
- until Escape or a press elsewhere hides it, Escape going to the tooltip ahead of a dialog around it.
A control disabled with the reason its tooltip gives does nothing when pressed, its keys changing nothing, on a page no renderer handles too. A host needs nothing to set it up.
License
Apache License 2.0, under the repository's LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- formaui-net.Framework.Browser (= 1.0.0-preview.27)
- formaui-net.Framework.Input.Interop (= 1.0.0-preview.27)
- formaui-net.Framework.JavaScript.Interop (= 1.0.0-preview.27)
- Microsoft.AspNetCore.Components (>= 11.0.0)
- Microsoft.Extensions.Logging (>= 11.0.0)
- Microsoft.JSInterop (>= 11.0.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on formaui-net.Framework.Browser.Interop:
| Package | Downloads |
|---|---|
|
formaui-net.Blazor
A Blazor component library for .NET 11: form inputs and pickers, dialogs, popovers and toasts, toolbars and menus, tabs and layout, file pickers, uploaders and viewers, icons, emoji and windows. |
|
|
formaui-net.Framework.Browser.Blazor.Server
What the DOM watcher and engine need from an Interactive Server host: when a circuit's connection to the browser is restored, every observation its components hold is measured afresh and delivered again in one call, so a state the browser sent while the connection was down still reaches its component, and every text field whose text the circuit holds at another revision sends its whole text, so an edit lost while the connection was down is replaced. |
|
|
formaui-net.Blazor.Explorer
FormaExplorer, a file manager for the Forma component library over items and folders the host already holds: a folder tree, an address bar with history and breadcrumbs, thumbnail, details and list views, search, sorting and grouping, selection, drag and drop between folders, upload, and a preview of any item. |
|
|
formaui-net.Blazor.DataView
FormaDataView, the collection component of the Forma component library. |
|
|
formaui-net.Blazor.Composer
FormaComposer, a rich text authoring surface for Blazor: an editor with the toolbar, dialogs, views and attachments an article or a page body needs, assembled from plugins the host picks. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.27 | 61 | 12/3/2026 |
| 1.0.0-preview.26 | 69 | 12/3/2026 |
| 1.0.0-preview.25 | 68 | 12/2/2026 |
| 1.0.0-preview.24 | 87 | 12/1/2026 |
| 1.0.0-preview.23 | 126 | 11/30/2026 |
| 1.0.0-preview.22 | 125 | 11/30/2026 |
| 1.0.0-preview.21 | 122 | 11/29/2026 |
| 1.0.0-preview.20 | 128 | 11/26/2026 |
| 1.0.0-preview.19 | 127 | 11/26/2026 |
| 1.0.0-preview.18 | 124 | 11/26/2026 |
| 1.0.0-preview.17 | 113 | 11/26/2026 |
| 1.0.0-preview.16 | 109 | 11/24/2026 |
| 1.0.0-preview.15 | 108 | 11/23/2026 |
| 1.0.0-preview.14 | 110 | 11/23/2026 |
| 1.0.0-preview.13 | 106 | 11/21/2026 |
| 1.0.0-preview.12 | 115 | 11/20/2026 |
| 1.0.0-preview.11 | 113 | 11/18/2026 |
| 1.0.0-preview.10 | 114 | 11/17/2026 |
| 1.0.0-preview.9 | 141 | 11/17/2026 |
| 1.0.0-preview.8 | 118 | 11/17/2026 |
What this release changed is in Forma's changelog: https://github.com/FormaUI/Forma/blob/v1.0.0-preview.27/CHANGELOG.md