import { useWindowSize } from "@solid-primitives/resize-observer"; import { MenuList } from "@suid/material"; import { batch, createEffect, createSignal, splitProps, type Component, type JSX, type ParentProps, } from "solid-js"; import { ANIM_CURVE_STD } from "./theme"; import "./Menu.css"; import { animateGrowFromTopRight, animateShrinkToTopRight, } from "~platform/anim"; import type { MenuListProps } from "@suid/material/MenuList"; export type Anchor = Pick & { e?: number }; export type MenuProps = ParentProps< { open?: boolean; onClose?: JSX.EventHandlerUnion; anchor: () => Anchor; MenuListProps?: MenuListProps; id?: string; } & JSX.AriaAttributes >; function px(n?: number) { if (n) { return `${n}px`; } else { return undefined; } } /** * Create managed state for {@link Menu}. This function * expose an "open" closure for you to open the menu. The * opening and closing is automatically managed internally. * * @returns The first element is the "open" closure, calls * with anchor infomation to open the menu. * The second element is the state props for {@link Menu}, use * spread syntax to set the props. * @example * ````tsx * const [openMenu, menuState] = createManagedMenuState(); * * * *