@inherits RadzenComponent
@using Microsoft.AspNetCore.Components.Rendering;
@using System.Collections
@using System.Linq

@if (Visible)
{
    <div @ref="@Element" @attributes="Attributes" class="@GetCssClass()" style="@Style" id="@GetId()"
        role="tree" aria-multiselectable="@(AllowCheckBoxes ? "true" : null)"
        tabindex="0" @onkeydown="@OnKeyPress" @onkeydown:preventDefault=preventKeyPress @onkeydown:stopPropagation="stopKeydownPropagation">
    <ul class="rz-tree-container">
        <CascadingValue Value=this>
            @ChildContent
        </CascadingValue>
        @if (Data != null && Levels != null && Levels.Any())
            {
                <CascadingValue Value=this>
                    @RenderChildren(Data, 0)
                </CascadingValue>
            }
        </ul>
    </div>
}