import XNode from "@web-atoms/core/dist/core/XNode"; import { IInlinePopupButtonOptions, InlinePopupButton } from "./InlinePopup"; import "./styles/popup-button-style"; export interface IMenuItem { label?: string; icon?: string; eventClick?: any; href?: string; target?: string; [key: string]: any; } export interface IPopupButton { icon?: string; label?: string; showAsDialog?: boolean; [key: string]: any; } export function MenuItem({ label, icon, eventClick, href, target, ... others }: IMenuItem) { if (href) { return { icon && } { label && } ; } return
{ icon && } { label && }
; } export default InlinePopupButton; export function PopupActionButton(a: IInlinePopupButtonOptions, ... nodes: XNode[]) { a.anchorRight = true; a["data-alignment"] ??= "bottom-right"; return InlinePopupButton(a, ... nodes); } // export default function PopupButton( // { // icon, // label, // showAsDialog, // ... others // }: IPopupButton, // ... menus: Array) { // let popup: IPopup = null; // function openPopup(s: AtomControl, e: Event) { // const button = e.currentTarget as HTMLElement; // button.classList.add("pressed"); // if (popup) { // popup.dispose(); // popup = null; // return; // } // const menu = document.createElement("div"); // (s as any).render(
// { ... menus} //
, menu); // const options: IPopupOptions = showAsDialog // ? { // alignment: "centerOfScreen", // popupStyle: ".none" // } // : { // alignment: "bottomLeft", // popupStyle: ".none" // }; // popup = PopupService.show(button, menu, options); // const clickHandler = (e) => { // let start = e.target as HTMLElement; // const body = document.body; // while (start) { // if (start === body) { // return; // } // if (start.dataset.menuItem === "menu-item") { // break; // } // start = start.parentElement; // } // popup?.dispose(); // popup = null; // }; // menu.addEventListener("click", clickHandler); // popup.registerDisposable(() => { // button.classList.remove("pressed"); // menu.removeEventListener("click", clickHandler); // popup = null; // }); // } // if (label) { // return ; // } // return ; // }