import { html, nothing, type TemplateResult } from 'lit'; import type { NuiType } from '../../types/nui-type.js'; import type { MenuItem } from './types.js'; export interface NuiMenuViewProps { model: MenuItem[]; popup: boolean; disabled: boolean; menuClass: string; nuiType: NuiType; overlayVisible: boolean; } export interface MenuRenderHandlers { onItemClick: (item: MenuItem, event: Event) => void; } function renderItem( item: MenuItem, handler: (item: MenuItem, event: Event) => void, ): TemplateResult { if (item.visible === false) { return html`${nothing}`; } if (item.separator) { return html` `; } const hasIcon = !!item.icon; const linkContent = html` ${hasIcon ? html`` : nothing} ${item.label} `; const handleClick = (e: Event) => { if (item.disabled) { e.preventDefault(); return; } handler(item, e); }; return html`
  • ${ item.url ? html` ${linkContent} ` : html` ` }
  • `; } export function renderMenu( state: NuiMenuViewProps, handlers: MenuRenderHandlers, ): TemplateResult { const isHidden = state.popup && !state.overlayVisible; return html` `; }