Lyo.Formatter.Web.Components
1.0.3
dotnet add package Lyo.Formatter.Web.Components --version 1.0.3
NuGet\Install-Package Lyo.Formatter.Web.Components -Version 1.0.3
<PackageReference Include="Lyo.Formatter.Web.Components" Version="1.0.3" />
<PackageVersion Include="Lyo.Formatter.Web.Components" Version="1.0.3" />
<PackageReference Include="Lyo.Formatter.Web.Components" />
paket add Lyo.Formatter.Web.Components --version 1.0.3
#r "nuget: Lyo.Formatter.Web.Components, 1.0.3"
#:package Lyo.Formatter.Web.Components@1.0.3
#addin nuget:?package=Lyo.Formatter.Web.Components&version=1.0.3
#tool nuget:?package=Lyo.Formatter.Web.Components&version=1.0.3
Lyo.Formatter.Web.Components
WASM-safe Blazor / MudBlazor components for Lyo.Formatter. Two components share a LyoFormatterLiveSession so a host can place the template text box in one region and the live preview in another. Formatting runs in-process via IFormatterService (no HTTP). Compatible with InteractiveWebAssembly and InteractiveServer; this package does not reference Microsoft.AspNetCore.App.
Examples
Split editor and preview
@inject IFormatterService Formatter
<MudGrid>
<MudItem xs="12" md="6">
<LyoFormatterTemplateEditor Session="_session" DebounceInterval="300" />
</MudItem>
<MudItem xs="12" md="6">
<LyoFormatterPreview Session="_session" />
</MudItem>
</MudGrid>
@code {
private LyoFormatterLiveSession _session = default!;
protected override void OnInitialized()
{
_session = new(Formatter) {
Template = "Hello, {Name}! Count: {Count:N0}",
Context = new Dictionary<string, object?> { ["Name"] = "Ada", ["Count"] = 42 }
};
}
}
Components
| Component | Purpose |
|---|---|
LyoFormatterTemplateEditor |
Template textarea with an in-place colored overlay of {placeholders}. Typing { opens a caret-anchored dropdown of session context keys; object/dictionary values also list nested properties (User.Address.City). Typing updates the overlay immediately; preview rebuilds after DebounceInterval (default 300 ms). Chip row under the field is hoverable so keys link to preview values. Session parameter wins over a cascaded session. |
LyoFormatterPreview |
Read-only annotated output. Each replacement is a span with the same per-key color as the editor token. Hover a replacement to emphasize the matching {key} (and vice versa via editor chips). |
Session and highlighting
LyoFormatterLiveSession— parent-ownedINotifyPropertyChangedstate:Template,Context,HoveredPlaceholder,DebounceInterval,TemplateSegments,PreviewSegments. CallRefreshPreview()after setting the initial template/context so the first paint is not empty. Dispose the session with the page.- Stable colors —
LyoFormatterPlaceholderPalettehashes the placeholder key (ordinal ignore-case) to an HSL hue so{Name}and its replacement always match. Fills arecolor-mixed into--mud-palette-surfaceso light and dark themes keep contrast. Not re-randomized per render. - Hover — sets
Session.HoveredPlaceholder; matching spans get a stronger fill and outline. - Unresolved — missing context (
MaintainTokens) uses a muted dashed underline instead of a key color. - Autocomplete —
LyoFormatterContextCatalogwalksSession.Context(dictionary keys or public properties, nested up to 3 levels). Typing{opens a floating list under the caret of keys and nested object properties (User,User.Address.City). Further typing filters the list (prefix match on the path or a dotted segment), including inside an already-closed{key}. Arrow/Enter/Tab/Escape move and insert; the active row scrolls into view. - Optional
CascadingValueof the session so distant editor/preview pairs need not passSessionon every call; an explicitSessionparameter still wins.
Host integration
Call services.AddFormatterService() from Lyo.Formatter. Create one LyoFormatterLiveSession per editor/preview pair (inject IFormatterService). Supply Context as a DTO or IReadOnlyDictionary<string, object?>. There is no context editor in this package.
WASM
No IHttpContextAccessor, no server-only framework reference, no formatting via HTTP. Overlay and textarea share a CSS grid cell so they scroll together. Caret position and the { autocomplete dropdown use a small JS module from this package's wwwroot (imported by the editor; no host <script> tag). Works under InteractiveWebAssembly when the host registers IFormatterService and references this package.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Formatter— (direct, lyo)Lyo.Web.Components— (direct, lyo)MudBlazor9.3— (direct, third-party)Lyo.Api.Client— (transitive, lyo)Lyo.Api.Models— (transitive, lyo)Lyo.Cache— (transitive, lyo)Lyo.Common— (transitive, lyo)Lyo.Compression— (transitive, lyo)Lyo.DataTable.Models— (transitive, lyo)Lyo.DateAndTime— (transitive, lyo)Lyo.Diagnostic— (transitive, lyo)Lyo.Encryption— (transitive, lyo)Lyo.Exceptions— (transitive, lyo)Lyo.Hashing— (transitive, lyo)Lyo.Health— (transitive, lyo)Lyo.IO.Temp— (transitive, lyo)Lyo.KeyStore— (transitive, lyo)Lyo.Metrics— (transitive, lyo)Lyo.PackageMetadata— (transitive, lyo)Lyo.Query— (transitive, lyo)Lyo.Query.Models— (transitive, lyo)Lyo.Result— (transitive, lyo)Lyo.Streams— (transitive, lyo)Lyo.Validation— (transitive, lyo)Blazored.LocalStorage4.5.0— (transitive, third-party)BouncyCastle.Cryptography2.6.2— (transitive, third-party, netstandard2.0)EasyCompressor2.1.0— (transitive, third-party)Konscious.Security.Cryptography.Argon21.3.1— (transitive, third-party)Microsoft.Bcl.AsyncInterfaces10.0.5— (transitive, microsoft, netstandard2.0)Microsoft.Extensions.Caching.Memory10.0.5— (transitive, microsoft)Microsoft.Extensions.Configuration.Binder10.0.5— (transitive, microsoft)Microsoft.Extensions.DependencyInjection10.0.5— (transitive, microsoft)Microsoft.Extensions.DependencyInjection.Abstractions10.0.5— (transitive, microsoft, net10.0, netstandard2.0)Microsoft.Extensions.Hosting.Abstractions10.0.5— (transitive, microsoft)Microsoft.Extensions.Http10.0.5— (transitive, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5— (transitive, microsoft)Microsoft.Extensions.Options.ConfigurationExtensions10.0.5— (transitive, microsoft)SmartFormat.NET3.6.1— (transitive, third-party)System.Buffers4.6.1— (transitive, microsoft, netstandard2.0)System.ComponentModel.Annotations5.0.0— (transitive, microsoft)System.IO.Hashing10.0.5— (transitive, microsoft, net10.0)System.Memory4.6.3— (transitive, microsoft, netstandard2.0)System.Text.Json10.0.5— (transitive, microsoft, netstandard2.0)System.Threading.Tasks.Extensions4.6.3— (transitive, microsoft, netstandard2.0)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Lyo.Formatter (>= 1.0.3)
- Lyo.Web.Components (>= 1.0.3)
- MudBlazor (>= 9.3.0 && < 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.