Class BOBAutoComplete<TItem>
- Namespace
- BlazOrbit.Components.Forms
- Assembly
- BlazOrbit.dll
[GenerateComponentInfo]
public class BOBAutoComplete<TItem> : BOBInputComponentBase<TItem, BOBAutoComplete<TItem>, BOBInputVariant>, IHasReadOnly, IHasDisabled, IHasRequired, IHasError, IVariantComponent<BOBInputVariant>, IVariantComponent, IBuiltComponent, IHasSize, IHasLoading, IHasDensity, IHasShadow, IHasColor, IHasBackgroundColor, IHasPrefix, IHasSuffix, IInputFamilyComponent
Type Parameters
TItem
- Inheritance
-
objectComponentBaseInputBase<TItem>BOBInputComponentBase<TItem>BOBAutoComplete<TItem>
- Implements
- Inherited Members
Constructors
BOBAutoComplete()
public BOBAutoComplete()
Properties
BackgroundColor
Background color of the input.
[Parameter]
public string? BackgroundColor { get; set; }
Property Value
- string
BuiltInTemplates
Compile-time map of variants to their built-in render templates.
protected override IReadOnlyDictionary<BOBInputVariant, Func<BOBAutoComplete<TItem>, RenderFragment>> BuiltInTemplates { get; }
Property Value
- IReadOnlyDictionary<BOBInputVariant, Func<BOBAutoComplete<TItem>, RenderFragment>>
Color
Text color of the input.
[Parameter]
public string? Color { get; set; }
Property Value
- string
DebounceMs
Trailing-edge debounce delay for keystroke-driven searches. 0 disables debouncing.
[Parameter]
public int DebounceMs { get; set; }
Property Value
- int
DefaultVariant
Variant used when no Variant is supplied.
public override BOBInputVariant DefaultVariant { get; }
Property Value
Density
Vertical density of the input.
[Parameter]
public BOBDensity Density { get; set; }
Property Value
HelperText
Helper text displayed below the input.
[Parameter]
public string? HelperText { get; set; }
Property Value
- string
ItemTemplate
Optional template for rendering each suggestion. Falls back to ItemText.
[Parameter]
public RenderFragment<TItem>? ItemTemplate { get; set; }
Property Value
- RenderFragment<TItem>
ItemText
Projects an item to its display string. Required.
[Parameter]
[EditorRequired]
public Func<TItem, string>? ItemText { get; set; }
Property Value
- Func<TItem, string>
Label
Floating label displayed above the input.
[Parameter]
public string? Label { get; set; }
Property Value
- string
Loading
When true, force the loading indicator. Async searches drive this automatically too.
[Parameter]
public bool Loading { get; set; }
Property Value
- bool
LoadingIndicatorVariant
Variant of the loading indicator shown while a search is in flight.
[Parameter]
public BOBProgressIconVariant LoadingIndicatorVariant { get; set; }
Property Value
MinSearchLength
Minimum length before a search fires. Defaults to 1.
[Parameter]
public int MinSearchLength { get; set; }
Property Value
- int
NoResultsTemplate
Optional template rendered when the search returns zero results.
[Parameter]
public RenderFragment<string>? NoResultsTemplate { get; set; }
Property Value
- RenderFragment<string>
OnSelected
Raised when the user picks a suggestion.
[Parameter]
public EventCallback<TItem> OnSelected { get; set; }
Property Value
- EventCallback<TItem>
Placeholder
Placeholder text shown when the input is empty.
[Parameter]
public string? Placeholder { get; set; }
Property Value
- string
PrefixBackgroundColor
Background color of the prefix.
[Parameter]
public string? PrefixBackgroundColor { get; set; }
Property Value
- string
PrefixColor
Color of the prefix.
[Parameter]
public string? PrefixColor { get; set; }
Property Value
- string
PrefixIcon
Material icon name displayed before the input value.
[Parameter]
public IconKey? PrefixIcon { get; set; }
Property Value
PrefixText
Text displayed before the input value.
[Parameter]
public string? PrefixText { get; set; }
Property Value
- string
SearchAsync
Async source for completion suggestions. Receives the current search text and a cancellation token that fires when a newer keystroke arrives or the component disposes. Required.
[Parameter]
[EditorRequired]
public Func<string, CancellationToken, Task<IEnumerable<TItem>>>? SearchAsync { get; set; }
Property Value
- Func<string, CancellationToken, Task<IEnumerable<TItem>>>
Shadow
Shadow style applied to the input container.
[Parameter]
public ShadowStyle? Shadow { get; set; }
Property Value
Size
Visual size of the input.
[Parameter]
public BOBSize Size { get; set; }
Property Value
StringToItem
Optional resolver lifting a raw search string back to a TItem.
Wires the EditContext path so the bound model can round-trip values that the user
committed via Enter / blur without picking a suggestion (e.g. free-text addresses
where the autocomplete suggests known matches but the field still accepts novel
entries). Return null to reject the string with a validation error.
When null the component keeps its historical SelectAsync-only contract.
[Parameter]
public Func<string, TItem?>? StringToItem { get; set; }
Property Value
- Func<string, TItem>
SuffixBackgroundColor
Background color of the suffix.
[Parameter]
public string? SuffixBackgroundColor { get; set; }
Property Value
- string
SuffixColor
Color of the suffix.
[Parameter]
public string? SuffixColor { get; set; }
Property Value
- string
SuffixIcon
Material icon name displayed after the input value.
[Parameter]
public IconKey? SuffixIcon { get; set; }
Property Value
SuffixText
Text displayed after the input value.
[Parameter]
public string? SuffixText { get; set; }
Property Value
- string
UnresolvedStringError
Validation message surfaced when StringToItem returns null for a non-empty input. Defaults to a generic "value not recognised" string.
[Parameter]
public string? UnresolvedStringError { get; set; }
Property Value
- string
Methods
BuildComponentCssVariables(Dictionary<string, string>)
Contributes additional CSS custom properties to the inline style attribute. Keys
that collide with framework-owned --bob-inline-* variables will be overwritten.
public void BuildComponentCssVariables(Dictionary<string, string> cssVariables)
Parameters
cssVariablesDictionary<string, string>
BuildComponentDataAttributes(Dictionary<string, object>)
Contributes additional data- attributes to the root element. Keys that collide
with framework-owned data-bob- attributes will be overwritten.
public void BuildComponentDataAttributes(Dictionary<string, object> dataAttributes)
Parameters
dataAttributesDictionary<string, object>
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builderRenderTreeBuilder
DisposeAsync()
Async disposal path. Blazor invokes this first when the component is unmounted because the type implements System.IAsyncDisposable; it tears down the JS-side behavior instance via BlazOrbit.Abstractions.BOBComponentPipeline.DisposeBehaviorAsync().
public override ValueTask DisposeAsync()
Returns
- ValueTask
Remarks
Both this method and Dispose(bool) run on disposal - Blazor calls
DisposeAsync for the async work and the framework's System.IDisposable
contract still invokes Dispose(true) afterward. The split is intentional:
async work (JS interop teardown) lives here, sync work (event unsubscribe) lives in
Dispose(true). Both set IsDisposed so derived components can
guard post-await continuations regardless of which path runs first.
OnParametersSet()
Method invoked when the component has received parameters from its parent in the render tree, and the incoming values have been assigned to properties.
protected override void OnParametersSet()
TryParseValueFromString(string?, out TItem, out string?)
Parses a string to create an instance of TValue. Derived classes can override this to change how
Microsoft.AspNetCore.Components.Forms.InputBase<TValue>.CurrentValueAsString interprets incoming values.
protected override bool TryParseValueFromString(string? value, out TItem result, out string? validationErrorMessage)
Parameters
valuestringThe string value to be parsed.
resultTItemAn instance of
TValue.validationErrorMessagestringIf the value could not be parsed, provides a validation error message.
Returns
- bool
True if the value could be parsed; otherwise false.