Class Sealed
public sealed class MokaJsonTreeViewport : ComponentBase

Namespace: Moka.Blazor.Json.Components

Virtualized scrolling container that renders MokaJsonNode rows. Uses Blazor's built-in Virtualize component for performance.

Inheritance

Inherits from: ComponentBase

Properties

NameDescription
EditState Active inline edit state, if any.
Nodes The flattened list of nodes to render.
OnContextMenu Callback when the context menu is requested on a node.
OnDoubleClick Callback when a node is double-clicked.
OnEditCancel Callback when an inline edit is cancelled.
OnEditCommit Callback when an inline edit is committed.
OnSelect Callback when a node is clicked (selected).
OnToggle Callback when a node's expand/collapse toggle is clicked.
ReadOnly Whether the viewer is in read-only mode.
SelectedPath The currently selected node path.
ShowChildCount Whether to show child count on collapsed containers.
ShowLineNumbers Whether to show line numbers in the gutter.
ToggleSize Size of expand/collapse toggle indicators.
ToggleStyle Style of expand/collapse toggle indicators.

EditState

[Parameter]
public InlineEditState? EditState { get; set; }

Active inline edit state, if any.

Nodes

[Parameter]
public List<FlattenedJsonNode>? Nodes { get; set; }

The flattened list of nodes to render.

OnContextMenu

[Parameter]
public EventCallback<(string Path, double ClientX, double ClientY)> OnContextMenu { get; set; }

Callback when the context menu is requested on a node.

OnDoubleClick

[Parameter]
public EventCallback<string> OnDoubleClick { get; set; }

Callback when a node is double-clicked.

OnEditCancel

[Parameter]
public EventCallback OnEditCancel { get; set; }

Callback when an inline edit is cancelled.

OnEditCommit

[Parameter]
public EventCallback<InlineEditResult> OnEditCommit { get; set; }

Callback when an inline edit is committed.

OnSelect

[Parameter]
public EventCallback<string> OnSelect { get; set; }

Callback when a node is clicked (selected).

OnToggle

[Parameter]
public EventCallback<string> OnToggle { get; set; }

Callback when a node's expand/collapse toggle is clicked.

ReadOnly

[Parameter]
public bool ReadOnly { get; set; }

Whether the viewer is in read-only mode.

SelectedPath

[Parameter]
public string? SelectedPath { get; set; }

The currently selected node path.

ShowChildCount

[Parameter]
public bool ShowChildCount { get; set; }

Whether to show child count on collapsed containers.

ShowLineNumbers

[Parameter]
public bool ShowLineNumbers { get; set; }

Whether to show line numbers in the gutter.

ToggleSize

[Parameter]
public MokaJsonToggleSize ToggleSize { get; set; }

Size of expand/collapse toggle indicators.

ToggleStyle

[Parameter]
public MokaJsonToggleStyle ToggleStyle { get; set; }

Style of expand/collapse toggle indicators.

Methods

NameDescription
ScrollToRowAsync(int rowIndex) Scrolls the row at rowIndex of MokaJsonTreeViewport.Nodes into view.
ShouldRender() override

ScrollToRowAsync(int rowIndex)

public ValueTask ScrollToRowAsync(int rowIndex)

Scrolls the row at rowIndex of MokaJsonTreeViewport.Nodes into view.

Type Relationships
classDiagram
    style MokaJsonTreeViewport fill:#f9f,stroke:#333,stroke-width:2px
    MokaJsonTreeViewport --|> ComponentBase : inherits
View Source
/// <summary>
///     Virtualized scrolling container that renders <see cref = "MokaJsonNode"/> rows.
///     Uses Blazor's built-in <c>Virtualize</c> component for performance.
/// </summary>
public sealed partial class MokaJsonTreeViewport : ComponentBase
{
    /// <summary>
    ///     The flattened list of nodes to render.
    /// </summary>
    [Parameter]
    public List<FlattenedJsonNode>? Nodes { get; set; }

    /// <summary>
    ///     The currently selected node path.
    /// </summary>
    [Parameter]
    public string? SelectedPath { get; set; }

    /// <summary>
    ///     Callback when a node's expand/collapse toggle is clicked.
    /// </summary>
    [Parameter]
    public EventCallback<string> OnToggle { get; set; }

    /// <summary>
    ///     Callback when a node is clicked (selected).
    /// </summary>
    [Parameter]
    public EventCallback<string> OnSelect { get; set; }

    /// <summary>
    ///     Callback when the context menu is requested on a node.
    /// </summary>
    [Parameter]
    public EventCallback<(string Path, double ClientX, double ClientY)> OnContextMenu { get; set; }

    /// <summary>
    ///     Callback when a node is double-clicked.
    /// </summary>
    [Parameter]
    public EventCallback<string> OnDoubleClick { get; set; }

    /// <summary>
    ///     Whether to show line numbers in the gutter.
    /// </summary>
    [Parameter]
    public bool ShowLineNumbers { get; set; }

    /// <summary>
    ///     Whether to show child count on collapsed containers.
    /// </summary>
    [Parameter]
    public bool ShowChildCount { get; set; } = true;

    /// <summary>
    ///     Style of expand/collapse toggle indicators.
    /// </summary>
    [Parameter]
    public MokaJsonToggleStyle ToggleStyle { get; set; }

    /// <summary>
    ///     Size of expand/collapse toggle indicators.
    /// </summary>
    [Parameter]
    public MokaJsonToggleSize ToggleSize { get; set; }

    /// <summary>
    ///     Active inline edit state, if any.
    /// </summary>
    [Parameter]
    public InlineEditState? EditState { get; set; }

    /// <summary>
    ///     Callback when an inline edit is committed.
    /// </summary>
    [Parameter]
    public EventCallback<InlineEditResult> OnEditCommit { get; set; }

    /// <summary>
    ///     Callback when an inline edit is cancelled.
    /// </summary>
    [Parameter]
    public EventCallback OnEditCancel { get; set; }

    /// <summary>
    ///     Whether the viewer is in read-only mode.
    /// </summary>
    [Parameter]
    public bool ReadOnly { get; set; }

    /// <summary>
    ///     Scrolls the row at <paramref name = "rowIndex"/> of <see cref = "Nodes"/> into view.
    /// </summary>
    public ValueTask ScrollToRowAsync(int rowIndex) => Interop.ScrollToRowAsync(ViewportId, rowIndex);
    /// <inheritdoc/>
    protected override bool ShouldRender()
    {
        (bool, bool, MokaJsonToggleStyle, MokaJsonToggleSize, bool) flags = (ShowLineNumbers, ShowChildCount, ToggleStyle, ToggleSize, ReadOnly);
        if (ReferenceEquals(Nodes, _renderedNodes) && SelectedPath == _renderedSelectedPath && ReferenceEquals(EditState, _renderedEditState) && flags == _renderedFlags)
        {
            return false;
        }

        _renderedNodes = Nodes;
        _renderedSelectedPath = SelectedPath;
        _renderedEditState = EditState;
        _renderedFlags = flags;
        return true;
    }
}
Was this page helpful?