Class Sealed
public sealed class MokaJsonSearchOverlay : ComponentBase

Namespace: Moka.Blazor.Json.Components

Search/find panel with text input, match navigation, and mode toggles.

Inheritance

Inherits from: ComponentBase

Properties

NameDescription
ActiveMatchIndex Zero-based index of the active match.
CaseSensitive Whether case-sensitive search is active.
MatchCount Total number of matches found.
OnCaseSensitiveChanged Callback when case sensitivity is toggled.
OnClose Callback to close the search overlay.
OnNext Callback to navigate to the next match.
OnPrevious Callback to navigate to the previous match.
OnQueryChanged Callback when the query text changes.
OnRegexChanged Callback when regex mode is toggled.
Query The current search query.
UseRegex Whether regex mode is active.

ActiveMatchIndex

int MokaJsonSearchOverlay.ActiveMatchIndex { get; set; }

Zero-based index of the active match.

CaseSensitive

bool MokaJsonSearchOverlay.CaseSensitive { get; set; }

Whether case-sensitive search is active.

MatchCount

int MokaJsonSearchOverlay.MatchCount { get; set; }

Total number of matches found.

OnCaseSensitiveChanged

EventCallback<bool> MokaJsonSearchOverlay.OnCaseSensitiveChanged { get; set; }

Callback when case sensitivity is toggled.

OnClose

EventCallback MokaJsonSearchOverlay.OnClose { get; set; }

Callback to close the search overlay.

OnNext

EventCallback MokaJsonSearchOverlay.OnNext { get; set; }

Callback to navigate to the next match.

OnPrevious

EventCallback MokaJsonSearchOverlay.OnPrevious { get; set; }

Callback to navigate to the previous match.

OnQueryChanged

EventCallback<string> MokaJsonSearchOverlay.OnQueryChanged { get; set; }

Callback when the query text changes.

OnRegexChanged

EventCallback<bool> MokaJsonSearchOverlay.OnRegexChanged { get; set; }

Callback when regex mode is toggled.

Query

string? MokaJsonSearchOverlay.Query { get; set; }

The current search query.

UseRegex

bool MokaJsonSearchOverlay.UseRegex { get; set; }

Whether regex mode is active.

Type Relationships
classDiagram
                    style MokaJsonSearchOverlay fill:#f9f,stroke:#333,stroke-width:2px
                    MokaJsonSearchOverlay --|> ComponentBase : inherits
                
View Source
/// <summary>
///     Search/find panel with text input, match navigation, and mode toggles.
/// </summary>
public sealed partial class MokaJsonSearchOverlay : ComponentBase
{
#region Parameters
    /// <summary>The current search query.</summary>
    [Parameter]
    public string? Query { get; set; }

    /// <summary>Total number of matches found.</summary>
    [Parameter]
    public int MatchCount { get; set; }

    /// <summary>Zero-based index of the active match.</summary>
    [Parameter]
    public int ActiveMatchIndex { get; set; }

    /// <summary>Whether case-sensitive search is active.</summary>
    [Parameter]
    public bool CaseSensitive { get; set; }

    /// <summary>Whether regex mode is active.</summary>
    [Parameter]
    public bool UseRegex { get; set; }

    /// <summary>Callback when the query text changes.</summary>
    [Parameter]
    public EventCallback<string> OnQueryChanged { get; set; }

    /// <summary>Callback to navigate to the next match.</summary>
    [Parameter]
    public EventCallback OnNext { get; set; }

    /// <summary>Callback to navigate to the previous match.</summary>
    [Parameter]
    public EventCallback OnPrevious { get; set; }

    /// <summary>Callback to close the search overlay.</summary>
    [Parameter]
    public EventCallback OnClose { get; set; }

    /// <summary>Callback when case sensitivity is toggled.</summary>
    [Parameter]
    public EventCallback<bool> OnCaseSensitiveChanged { get; set; }

    /// <summary>Callback when regex mode is toggled.</summary>
    [Parameter]
    public EventCallback<bool> OnRegexChanged { get; set; }
    private string InputId { get; } = $"moka-search-{Guid.NewGuid():N}";

#endregion
#region Event Handlers
    private async Task HandleInput(ChangeEventArgs e) => await OnQueryChanged.InvokeAsync(e.Value?.ToString() ?? "");
    private async Task HandleKeyDown(KeyboardEventArgs e)
    {
        switch (e.Key)
        {
            case "Enter" when e.ShiftKey:
            case "F3" when e.ShiftKey:
                await OnPrevious.InvokeAsync();
                break;
            case "Enter":
            case "F3":
                await OnNext.InvokeAsync();
                break;
            case "Escape":
                await OnClose.InvokeAsync();
                break;
        }
    }

    private async Task HandleCaseSensitiveChange(ChangeEventArgs e) => await OnCaseSensitiveChanged.InvokeAsync(bool.TryParse(e.Value?.ToString(), out bool v) && v);
    private async Task HandleRegexChange(ChangeEventArgs e) => await OnRegexChanged.InvokeAsync(bool.TryParse(e.Value?.ToString(), out bool v) && v);
#endregion
}
Was this page helpful?