{"version":3,"file":"SubMenu.cjs","names":[],"sources":["../../../src/components/Menu/SubMenu.tsx"],"sourcesContent":["/*\nCopyright 2026 Element Creations Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { type FC, type ReactNode, useContext } from \"react\";\nimport { MenuContext } from \"./MenuContext\";\n\ninterface Props {\n  /**\n   * The trigger element that opens the submenu. This should be a MenuItem.\n   */\n  trigger: ReactNode;\n  /**\n   * Whether the submenu is open (controlled).\n   */\n  open?: boolean;\n  /**\n   * Event handler called when the open state of the submenu changes.\n   */\n  onOpenChange?: (open: boolean) => void;\n  /**\n   * The submenu contents (typically MenuItem elements).\n   */\n  children: ReactNode;\n}\n\n/**\n * A submenu within a Menu or ContextMenu. The trigger should be a MenuItem\n * component and the children are the submenu items.\n */\nexport const SubMenu: FC<Props> = ({\n  trigger,\n  open,\n  onOpenChange,\n  children,\n}) => {\n  const context = useContext(MenuContext);\n\n  // When there's no SubMenuWrapper (e.g. drawer on mobile), flatten the\n  // submenu items inline — nested flyouts don't work well in drawers.\n  if (context?.SubMenuWrapper == null) {\n    return (\n      <>\n        {trigger}\n        {children}\n      </>\n    );\n  }\n\n  return (\n    <context.SubMenuWrapper\n      trigger={trigger}\n      open={open}\n      onOpenChange={onOpenChange}\n    >\n      {children}\n    </context.SubMenuWrapper>\n  );\n};\n"],"mappings":";;;;;;;;;;AAiCA,IAAa,WAAsB,EACjC,SACA,MACA,cACA,eACI;CACJ,MAAM,WAAA,GAAA,MAAA,YAAqB,oBAAA,YAAY;AAIvC,KAAI,SAAS,kBAAkB,KAC7B,QACE,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA,CACG,SACA,SACA,EAAA,CAAA;AAIP,QACE,iBAAA,GAAA,kBAAA,KAAC,QAAQ,gBAAT;EACW;EACH;EACQ;EAEb;EACsB,CAAA"}