Skip to content

FieldAdornment ​

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

Describes an adornment to display next to a form field. The adornment's visibility is controlled by an async predicate evaluated against the field value. When the predicate resolves to true, the widget returned by the builder is rendered.

csharp
public sealed record FieldAdornment : IEquatable<FieldAdornment>

Inheritance ​

Object → FieldAdornment

Implements ​

Constructors ​

FieldAdornment(Func<string, CancellationToken, Task<bool>>, Func<Hex1bWidget>) ​

Describes an adornment to display next to a form field. The adornment's visibility is controlled by an async predicate evaluated against the field value. When the predicate resolves to true, the widget returned by the builder is rendered.

Parameters:

  • Predicate (Func<String, CancellationToken, Boolean>>): Async function that receives the current field value and a cancellation token. Returns true if the adornment should be visible.
  • Builder (Func<Hex1bWidget>): Factory function that creates the widget to display when the adornment is visible. Called during reconciliation when the predicate has resolved to true.
csharp
public FieldAdornment(Func<string, CancellationToken, Task<bool>> Predicate, Func<Hex1bWidget> Builder)

Properties ​

Builder ​

Factory function that creates the widget to display when the adornment is visible. Called during reconciliation when the predicate has resolved to true.

Returns: Func<Hex1bWidget>

csharp
public Func<Hex1bWidget> Builder { get; init; }

Predicate ​

Async function that receives the current field value and a cancellation token. Returns true if the adornment should be visible.

Returns: Func<String, CancellationToken, Boolean>>

csharp
public Func<string, CancellationToken, Task<bool>> Predicate { get; init; }

Methods ​

Create(Func<string, Task<bool>>, Func<Hex1bWidget>) ​

Creates an adornment with a predicate that doesn't need cancellation support.

Parameters:

Returns: FieldAdornment

csharp
public static FieldAdornment Create(Func<string, Task<bool>> predicate, Func<Hex1bWidget> builder)

Released under the MIT License.