import type { JsxTemplate } from "@ui5/webcomponents-base/dist/index.js"; import type MenuItem from "./MenuItem.js"; import PopoverPlacement from "./types/PopoverPlacement.js"; import ResponsivePopover from "./ResponsivePopover.js"; import Button from "./Button.js"; import List from "./List.js"; import BusyIndicator from "./BusyIndicator.js"; import navBackIcon from "@ui5/webcomponents-icons/dist/nav-back.js"; import checkIcon from "@ui5/webcomponents-icons/dist/accept.js"; import slimArrowRight from "@ui5/webcomponents-icons/dist/slim-arrow-right.js"; import Icon from "./Icon.js"; import ListItemTemplate from "./ListItemTemplate.js"; import type { ListItemHooks } from "./ListItemTemplate.js"; export type MenuItemHooks = ListItemHooks & { menuItemTextContent: JsxTemplate; } const predefinedHooks: Partial = { iconBegin, menuItemTextContent, }; export default function MenuItemTemplate(this: MenuItem, hooks?: Partial) { const currentHooks = { ...predefinedHooks, ...hooks }; if (!hooks?.listItemContent) { currentHooks.listItemContent = function listItemContent(this: MenuItem) { return (<> {currentHooks.menuItemTextContent!.call(this)} {rightContent.call(this)} {checkmarkContent.call(this)} ); }; } return <> {ListItemTemplate.call(this, currentHooks)} {listItemPostContent.call(this)} ; } function menuItemTextContent(this: MenuItem) { return <>{this.text &&
{this.text}
}; } function checkmarkContent(this: MenuItem) { return !this._markChecked ? "" : (
); } function rightContent(this: MenuItem) { switch (true) { case this.hasSubmenu: return (
); case this.hasEndContent: return (
); case !!this.additionalText: return ( {this.additionalText} ); } } function iconBegin(this: MenuItem) { if (this.hasIcon) { return ; } if (this._siblingsWithIcon) { return
; } } function listItemPostContent(this: MenuItem) { return this.hasSubmenu && { this.isPhone && ( <>
) }
{ this.items.length ? ( ) : this.loading && }
{ this.isPhone && ( ) }
; }