event.preventDefault()}> {#each items as item, index (index)} {#if 'separator' in item}
{:else} {@const menuItem = item as MenuItem} {@const hasSubmenu = !!menuItem.children?.length}
{ if (menuItem.disabled) return if (hasSubmenu) { subOpen = subOpen === index ? -1 : index return } menuItem.onClick() onClose() }} onmouseenter={() => { if (menuItem.disabled) return focused = index subOpen = hasSubmenu ? index : -1 }} onmouseleave={() => { focused = -1 }} >
{#if menuItem.icon}
{/if}
{menuItem.label}
{#if hasSubmenu}
›
{/if}
{#if hasSubmenu && subOpen === index}
{ subOpen = index }}> {#each menuItem.children as child, childIndex (childIndex)} {#if 'separator' in child}
{:else} {@const childItem = child as MenuItem}
{ if (childItem.disabled) return childItem.onClick() onClose() }}>
{#if childItem.icon}
{/if}
{childItem.label}
{/if} {/each}
{/if}
{/if} {/each}