ant-design-blazor/components/menu/AntSubMenu.razor

71 lines
2.8 KiB
Plaintext

@namespace AntBlazor
@inherits AntSubMenuBase
<CascadingValue Value=this>
<li nz-submenu class="@ClassMapper.Class" @ref="Ref" style="@Style" @attributes="Attributes" Id="@Id">
<div class="@TitleDivClass.Class" style="@titleStyle"
@onmouseover="()=>SetMouseEnterState(true)"
@onmouseout="()=>SetMouseEnterState(false)"
@onclick="()=> ClickSubMenuTitle()">
@if (nzIcon != null)
{
<AntIcon type="@nzIcon"></AntIcon>
}
@*<ng-container *nzStringTemplateOutlet="nzTitle">*@
<span>@((MarkupString)nzTitle)</span>
@*</ng-container>*@
@*<ng-content select="[title]" *ngIf="!nzTitle"></ng-content>*@
@if (Menu.isInDropDown)
{
<span class="ant-dropdown-menu-submenu-arrow">
<AntIcon type="right" class="anticon-right ant-dropdown-menu-submenu-arrow-icon"></AntIcon>
</span>
}
else
{
<i class="ant-menu-submenu-arrow"></i>
}
</div>
@if (Menu.nzMode == NzDirectionVHIType.inline)
{
<ul class="@nzMenuClassName ant-menu ant-menu-inline ant-menu-sub" style="transition: height 0.5s; @submenuStyle">
@ChildContent
</ul>
}
</li>
@if (nzOpen && Menu.nzMode != NzDirectionVHIType.inline)
{
<div style="position: absolute; top: 0px; left: 0px; width: 100%;">
<div class="ant-menu-submenu ant-menu-submenu-popup @PopupClassMapper.Class"
style="left:@(element.offsetLeft+element.clientWidth+10)px; top:@(element.offsetTop)px; @(isMouseHover?"":"display: none;")"
@onmouseout="()=>SetMouseEnterState(false)"
@onmouseover="()=>SetMouseEnterState(true)">
<ul class="@nzMenuClassName @PopupUlClassMapper.Class ant-menu-submenu-content" style="@(isMouseHover?"":"display: none;")">
@ChildContent
</ul>
</div>
</div>
}
</CascadingValue>
@inject JsInterop.JsInterop js
@code {
string titleStyle => Menu.nzMode == NzDirectionVHIType.inline ?
$"padding-left:{(nzPaddingLeft ?? Level * Menu.nzInlineIndent)}px" : "";
string submenuStyle => nzOpen ? "" : "height: 0px; overflow: hidden;";
protected override void OnInitialized()
{
base.OnInitialized();
TitleDivClass
.If("ant-dropdown-menu-submenu-title", () => Menu.isInDropDown)
.If("ant-menu-submenu-title", () => !Menu.isInDropDown)
;
}
}