Class Sealed
public sealed class MokaJsonNode : ComponentBase

Namespace: Moka.Blazor.Json.Components

Renders a single row in the JSON tree view. Stateless — receives all data via parameters.

Inheritance

Inherits from: ComponentBase

Properties

NameDescription
EditState Active inline edit state from the parent viewer.
IsSelected Whether this node is currently selected.
Node The flattened node data to render.
OnContextMenu Callback when the context menu is requested.
OnDoubleClick Callback when the node is double-clicked (edit mode).
OnEditCancel Callback when an inline edit is cancelled.
OnEditCommit Callback when an inline edit is committed.
OnSelect Callback when the node row is clicked (selection).
OnToggle Callback when the expand/collapse toggle is clicked.
ReadOnly Whether the viewer is in read-only mode.
ShowChildCount Whether to show the child count (e.g. "13 items") 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 from the parent viewer.

IsSelected

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

Whether this node is currently selected.

Node

[Parameter]
public FlattenedJsonNode Node { get; set; }

The flattened node data to render.

OnContextMenu

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

Callback when the context menu is requested.

OnDoubleClick

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

Callback when the node is double-clicked (edit mode).

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 the node row is clicked (selection).

OnToggle

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

Callback when the expand/collapse toggle is clicked.

ReadOnly

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

Whether the viewer is in read-only mode.

ShowChildCount

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

Whether to show the child count (e.g. "13 items") 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
ShouldRender() override
Type Relationships
classDiagram
    style MokaJsonNode fill:#f9f,stroke:#333,stroke-width:2px
    MokaJsonNode --|> ComponentBase : inherits
View Source
/// <summary>
///     Renders a single row in the JSON tree view. Stateless — receives all data via parameters.
/// </summary>
public sealed partial class MokaJsonNode : ComponentBase
{
#region Parameters
    /// <summary>
    ///     The flattened node data to render.
    /// </summary>
    [Parameter]
    public FlattenedJsonNode Node { get; set; }

    /// <summary>
    ///     Whether this node is currently selected.
    /// </summary>
    [Parameter]
    public bool IsSelected { get; set; }

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

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

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

    /// <summary>
    ///     Callback when the node is double-clicked (edit mode).
    /// </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>
    ///     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>
    ///     Whether to show the child count (e.g. "13 items") on collapsed containers.
    /// </summary>
    [Parameter]
    public bool ShowChildCount { get; set; } = true;

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

    /// <summary>
    ///     Active inline edit state from the parent viewer.
    /// </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; }

#endregion
#region Computed Properties
#endregion
#region Event Handlers
#endregion
#region Render Optimization
    /// <inheritdoc/>
    protected override bool ShouldRender()
    {
        bool editStateChanged = EditState != _previousEditState || _forceRender;
        _forceRender = false;
        if (Node != _previousNode || IsSelected != _previousIsSelected || ShowLineNumbers != _previousShowLineNumbers || ToggleStyle != _previousToggleStyle || ToggleSize != _previousToggleSize || ShowChildCount != _previousShowChildCount || ReadOnly != _previousReadOnly || editStateChanged)
        {
            _previousNode = Node;
            _previousIsSelected = IsSelected;
            _previousShowLineNumbers = ShowLineNumbers;
            _previousToggleStyle = ToggleStyle;
            _previousToggleSize = ToggleSize;
            _previousShowChildCount = ShowChildCount;
            _previousReadOnly = ReadOnly;
            _previousEditState = EditState;
            return true;
        }

        return false;
    }
#endregion
}
Was this page helpful?