@funstack/ui 0.1.0-alpha.13 → 0.1.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/accordion/accordion-root.d.mts.map +1 -1
  2. package/dist/accordion/accordion-root.mjs +5 -4
  3. package/dist/accordion/accordion-root.mjs.map +1 -1
  4. package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
  5. package/dist/checkbox-group/checkbox-group-root.mjs +4 -5
  6. package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
  7. package/dist/combobox/combobox-context.mjs.map +1 -1
  8. package/dist/combobox/combobox-input.d.mts +7 -6
  9. package/dist/combobox/combobox-input.d.mts.map +1 -1
  10. package/dist/combobox/combobox-input.mjs +6 -5
  11. package/dist/combobox/combobox-input.mjs.map +1 -1
  12. package/dist/combobox/combobox-label.d.mts +2 -1
  13. package/dist/combobox/combobox-label.d.mts.map +1 -1
  14. package/dist/combobox/combobox-label.mjs +2 -1
  15. package/dist/combobox/combobox-label.mjs.map +1 -1
  16. package/dist/combobox/combobox-popup.d.mts +4 -2
  17. package/dist/combobox/combobox-popup.d.mts.map +1 -1
  18. package/dist/combobox/combobox-popup.mjs +7 -3
  19. package/dist/combobox/combobox-popup.mjs.map +1 -1
  20. package/dist/combobox/combobox-root.d.mts.map +1 -1
  21. package/dist/combobox/combobox-root.mjs +9 -80
  22. package/dist/combobox/combobox-root.mjs.map +1 -1
  23. package/dist/combobox/combobox-trigger.d.mts +15 -10
  24. package/dist/combobox/combobox-trigger.d.mts.map +1 -1
  25. package/dist/combobox/combobox-trigger.mjs +28 -19
  26. package/dist/combobox/combobox-trigger.mjs.map +1 -1
  27. package/dist/combobox/index.d.mts +2 -2
  28. package/dist/combobox/index.mjs +2 -2
  29. package/dist/combobox/index.mjs.map +1 -1
  30. package/dist/combobox/use-deferred-leave.mjs +105 -0
  31. package/dist/combobox/use-deferred-leave.mjs.map +1 -0
  32. package/dist/dialog/dialog-context.mjs.map +1 -1
  33. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  34. package/dist/dialog/dialog-popup.mjs +5 -4
  35. package/dist/dialog/dialog-popup.mjs.map +1 -1
  36. package/dist/dialog/dialog-trigger.mjs.map +1 -1
  37. package/dist/form/form-root.mjs +1 -1
  38. package/dist/form/form-root.mjs.map +1 -1
  39. package/dist/internal/anchor-position.mjs.map +1 -1
  40. package/dist/internal/announce.mjs +12 -7
  41. package/dist/internal/announce.mjs.map +1 -1
  42. package/dist/internal/focus-first-invalid.mjs +2 -11
  43. package/dist/internal/focus-first-invalid.mjs.map +1 -1
  44. package/dist/internal/focus-visible.mjs +26 -0
  45. package/dist/internal/focus-visible.mjs.map +1 -0
  46. package/dist/internal/invokers.mjs +63 -0
  47. package/dist/internal/invokers.mjs.map +1 -0
  48. package/dist/internal/platform-attributes.d.mts +2 -1
  49. package/dist/internal/platform-attributes.d.mts.map +1 -1
  50. package/dist/internal/pointer-capture.mjs +1 -1
  51. package/dist/internal/pointer-capture.mjs.map +1 -1
  52. package/dist/internal/render-element.mjs.map +1 -1
  53. package/dist/internal/trigger-ref.mjs +3 -3
  54. package/dist/internal/trigger-ref.mjs.map +1 -1
  55. package/dist/internal/use-interest-dismiss.mjs +84 -0
  56. package/dist/internal/use-interest-dismiss.mjs.map +1 -0
  57. package/dist/internal/use-overlay-root.mjs +2 -1
  58. package/dist/internal/use-overlay-root.mjs.map +1 -1
  59. package/dist/internal/use-popover-popup.mjs +59 -48
  60. package/dist/internal/use-popover-popup.mjs.map +1 -1
  61. package/dist/internal/use-popover-trigger.d.mts.map +1 -1
  62. package/dist/internal/use-popover-trigger.mjs +37 -15
  63. package/dist/internal/use-popover-trigger.mjs.map +1 -1
  64. package/dist/internal/use-resolved-placement.mjs +1 -1
  65. package/dist/internal/use-resolved-placement.mjs.map +1 -1
  66. package/dist/internal/use-value-set.mjs +20 -0
  67. package/dist/internal/use-value-set.mjs.map +1 -0
  68. package/dist/menu/menu-context.mjs.map +1 -1
  69. package/dist/menu/menu-popup.d.mts +3 -1
  70. package/dist/menu/menu-popup.d.mts.map +1 -1
  71. package/dist/menu/menu-popup.mjs +15 -18
  72. package/dist/menu/menu-popup.mjs.map +1 -1
  73. package/dist/menu/menu-submenu-trigger.d.mts +11 -9
  74. package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
  75. package/dist/menu/menu-submenu-trigger.mjs +11 -10
  76. package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
  77. package/dist/menu/menu-trigger.d.mts +13 -10
  78. package/dist/menu/menu-trigger.d.mts.map +1 -1
  79. package/dist/menu/menu-trigger.mjs +10 -14
  80. package/dist/menu/menu-trigger.mjs.map +1 -1
  81. package/dist/number-field/number-field-root.mjs +1 -1
  82. package/dist/popover/index.d.mts +1 -1
  83. package/dist/popover/index.mjs +1 -1
  84. package/dist/popover/index.mjs.map +1 -1
  85. package/dist/popover/popover-close.d.mts +5 -3
  86. package/dist/popover/popover-close.d.mts.map +1 -1
  87. package/dist/popover/popover-close.mjs +3 -1
  88. package/dist/popover/popover-close.mjs.map +1 -1
  89. package/dist/popover/popover-popup.d.mts +1 -1
  90. package/dist/popover/popover-popup.mjs +1 -1
  91. package/dist/popover/popover-popup.mjs.map +1 -1
  92. package/dist/popover/popover-root.d.mts +1 -1
  93. package/dist/popover/popover-root.mjs +1 -1
  94. package/dist/popover/popover-root.mjs.map +1 -1
  95. package/dist/popover/popover-trigger.d.mts +10 -9
  96. package/dist/popover/popover-trigger.d.mts.map +1 -1
  97. package/dist/popover/popover-trigger.mjs +9 -8
  98. package/dist/popover/popover-trigger.mjs.map +1 -1
  99. package/dist/toast/toast-root.mjs.map +1 -1
  100. package/dist/toast/toast-viewport.d.mts.map +1 -1
  101. package/dist/toast/toast-viewport.mjs +4 -5
  102. package/dist/toast/toast-viewport.mjs.map +1 -1
  103. package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
  104. package/dist/toggle-group/toggle-group-root.mjs +4 -5
  105. package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
  106. package/package.json +1 -1
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { toSet } from "./value-set.mjs";
3
+ import { useMemo } from "react";
4
+ //#region src/internal/use-value-set.ts
5
+ /**
6
+ * A `value` / `defaultValue` prop of a set-valued component as a set, `undefined` when absent.
7
+ *
8
+ * The set's identity is stable while the prop has the same contents, so `useOptimistic` only
9
+ * re-bases, and the context only changes, when the value really changed. Keyed on the contents,
10
+ * not the array: an inline `value={["a"]}` is a new array on every render. (Order-sensitive; a
11
+ * reordered array only costs one new set.)
12
+ */
13
+ function useValueSet(value) {
14
+ const key = value === void 0 ? void 0 : JSON.stringify(value);
15
+ return useMemo(() => key === void 0 ? void 0 : toSet(JSON.parse(key)), [key]);
16
+ }
17
+ //#endregion
18
+ export { useValueSet };
19
+
20
+ //# sourceMappingURL=use-value-set.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-value-set.mjs","names":[],"sources":["../../src/internal/use-value-set.ts"],"sourcesContent":["\"use client\";\nimport { useMemo } from \"react\";\nimport { toSet } from \"./value-set.js\";\nimport type { ValueSet } from \"./value-set.js\";\n\n/**\n * A `value` / `defaultValue` prop of a set-valued component as a set, `undefined` when absent.\n *\n * The set's identity is stable while the prop has the same contents, so `useOptimistic` only\n * re-bases, and the context only changes, when the value really changed. Keyed on the contents,\n * not the array: an inline `value={[\"a\"]}` is a new array on every render. (Order-sensitive; a\n * reordered array only costs one new set.)\n */\nexport function useValueSet(\n value: string | readonly string[] | null | undefined,\n): ValueSet | undefined {\n const key = value === undefined ? undefined : JSON.stringify(value);\n return useMemo(\n () =>\n key === undefined ? undefined : toSet(JSON.parse(key) as string | readonly string[] | null),\n [key],\n );\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,YACd,OACsB;CACtB,MAAM,MAAM,UAAU,KAAA,IAAY,KAAA,IAAY,KAAK,UAAU,KAAK;CAClE,OAAO,cAEH,QAAQ,KAAA,IAAY,KAAA,IAAY,MAAM,KAAK,MAAM,GAAG,CAAsC,GAC5F,CAAC,GAAG,CACN;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"menu-context.mjs","names":[],"sources":["../../src/menu/menu-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { DelayedPair } from \"../internal/use-delayed-pair.js\";\nimport type { PopoverRootValue } from \"../internal/use-overlay-root.js\";\n\n/**\n * Where focus goes when the menu opens (design/components/menu.md 6.1): the first enabled item,\n * the last one (ArrowUp on the Trigger), or nowhere (a hover-opened submenu keeps focus on its\n * SubmenuTrigger).\n */\nexport type MenuOpenCause = \"first\" | \"last\" | \"none\";\n\n/** How the open being shown should place focus (design 6.1). */\nexport interface MenuOpenFocus {\n readonly cause: MenuOpenCause;\n /**\n * The open came from a pointer click (`detail > 0`): the item is focused without the focus\n * ring where the engine supports `focus({ focusVisible: false })`.\n */\n readonly pointer: boolean;\n}\n\n/**\n * How the current open is placed (design/components/context-menu.md 3.1): against the Trigger\n * (`anchor`: a Menu.Trigger, a foreign invoker, a controlled or platform open), or at a point\n * (`point`: a Menu.ContextTrigger). `generation` grows with every point open or move, so a second\n * right-click at a new point is a state change while the menu is open (4.3).\n */\nexport type MenuPlacement =\n | { readonly kind: \"anchor\" }\n | {\n readonly kind: \"point\";\n readonly x: number;\n readonly y: number;\n readonly generation: number;\n /** The region that opened: the `source` of `showPopover({ source })` (nesting). */\n readonly source: HTMLElement;\n /** The pointer held down at the open, re-captured after a move's re-show (2.1). */\n readonly pointerId: number | undefined;\n /**\n * The popup's computed `direction` at this open or move (4.6): which edge of the menu\n * sits at the point. Read once by `openAt`, never during render.\n */\n readonly direction: \"ltr\" | \"rtl\";\n /**\n * A touch or pen open (4.7): the menu is placed above the point with\n * `--menu-point-gap`, so it does not open under the finger.\n */\n readonly offset: boolean;\n };\n\nexport const ANCHOR_PLACEMENT: MenuPlacement = { kind: \"anchor\" };\n\n/** What a ContextTrigger passes to `openAt`. */\nexport interface MenuOpenAtOptions {\n readonly source: HTMLElement;\n /** The `contextmenu` event, or the long-press `pointerdown` (`details.event`). */\n readonly event: Event;\n /** A pointer opened (quiet focus); `false` for the keyboard (focus ring). */\n readonly pointer: boolean;\n readonly pointerId: number | undefined;\n /** A touch or pen open: placed above the point (4.7). */\n readonly offset: boolean;\n}\n\n/** One menu level: what its Root provides to its Trigger, Popup and items. */\nexport interface MenuContextValue {\n /** The shared popover machinery (`useOverlayRoot`). */\n readonly popover: PopoverRootValue;\n /** This Root is nested in a `Menu.Popup`. */\n readonly submenu: boolean;\n /** The top-level menu: item activation closes the whole stack through it (design 2.2). */\n readonly root: MenuContextValue;\n /** The enclosing menu of a submenu; `null` at the top level. */\n readonly parent: MenuContextValue | null;\n readonly loop: boolean;\n readonly delay: number;\n readonly closeDelay: number;\n /** The Trigger's id (`aria-labelledby` of the Popup). */\n readonly triggerId: string;\n /** Record the focus target of the next open (and whether a pointer asked for it). */\n readonly setOpenCause: (cause: MenuOpenCause, pointer?: boolean) => void;\n /** Read and clear the focus target of the open being shown (default `\"first\"`, keyboard). */\n readonly takeOpenCause: () => MenuOpenFocus;\n /** Submenu hover-intent timers, shared by the SubmenuTrigger and the Popup. */\n readonly timers: DelayedPair;\n /** Placement of the current (or last) open (context-menu.md 3.1). */\n readonly placement: MenuPlacement;\n /**\n * A ContextTrigger opens the menu at `point`, or moves it there when it is already open (no\n * dispatch, 4.3).\n */\n readonly openAt: (\n point: { readonly x: number; readonly y: number },\n options: MenuOpenAtOptions,\n ) => void;\n /**\n * Back to the anchored placement once a point open has been shown and hidden (the popup is no\n * longer visible): the next open that is not a ContextTrigger's (controlled, platform, foreign\n * invoker) places against the Trigger. Ignored when a newer point was recorded meanwhile.\n */\n readonly resetPlacement: (generation: number) => void;\n}\n\nexport const MenuContext = createContext<MenuContextValue | null>(null);\n\n/**\n * `true` inside a `Menu.ContextTrigger`: a `Menu.Root` there is a nested context region's own\n * top-level menu (context-menu.md 2.4), not a misplaced submenu.\n */\nexport const MenuRegionContext = createContext(false);\n\n/**\n * `contextmenu` events a ContextTrigger handled (opened or moved its menu), with the top-level\n * menu they belong to: that menu's document listener leaves its menu open for them\n * (context-menu.md 5 and 14).\n */\nconst handledEvents = new WeakMap<Event, object>();\n\n/**\n * `pointerdown` events that are not a long-press of an enclosing region: claimed by the innermost\n * region that started its timer for them (nested regions), and by every `Menu.Popup` for the\n * presses inside it (a menu inside a region). As `contextmenu`'s `defaultPrevented`\n * rule (context-menu.md 2.4).\n */\nconst claimedPresses = new WeakSet<Event>();\n\nexport function claimPress(event: Event): void {\n claimedPresses.add(event);\n}\n\nexport function isPressClaimed(event: Event): boolean {\n return claimedPresses.has(event);\n}\n\n/**\n * What a hit on a `Menu.SubmenuTrigger` during a press-drag-release gesture does (context-menu.md\n * 2.6): the hover intent a real `pointerenter` / `pointerleave` would start. Registered by the\n * SubmenuTrigger on its element; the gesture runs under pointer capture, so the element never\n * receives boundary events itself.\n */\nexport interface SubmenuHover {\n readonly enter: (event: Event) => void;\n readonly leave: (event: Event) => void;\n /**\n * The submenu's popup, for the gesture's \"still over the submenu\" test (not `commandfor`: a\n * non-button SubmenuTrigger has none).\n */\n readonly popup: () => HTMLElement | null;\n}\n\nconst submenuHovers = new WeakMap<Element, SubmenuHover>();\n\nexport function registerSubmenuHover(element: Element, hover: SubmenuHover): () => void {\n submenuHovers.set(element, hover);\n return () => {\n if (submenuHovers.get(element) === hover) submenuHovers.delete(element);\n };\n}\n\nexport function submenuHover(element: Element): SubmenuHover | undefined {\n return submenuHovers.get(element);\n}\n\n/** The top-level menu's identity: its popup ref object, stable for the Root's lifetime. */\nconst menuKey = (menu: MenuContextValue): object => menu.root.popover.popupRef;\n\nexport function markHandled(event: Event, menu: MenuContextValue): void {\n handledEvents.set(event, menuKey(menu));\n}\n\nexport function isHandledBy(event: Event, menu: MenuContextValue): boolean {\n return handledEvents.get(event) === menuKey(menu);\n}\n\n/**\n * The close an activated item runs once its action settled: the whole stack, through the\n * top-level Root (design 2.2). Recorded at activation: if the menu was dismissed and opened again\n * meanwhile, the close belongs to the previous opening and does nothing (as `useActionTrigger`).\n */\nexport function closeStackLater(menu: MenuContextValue, event: Event): () => void {\n const { popover } = menu.root;\n const generation = popover.openGeneration();\n return () => {\n if (popover.openGeneration() === generation) popover.requestClose(event, \"activate\");\n };\n}\n\nexport function useMenuContext(part: string): MenuContextValue {\n const context = use(MenuContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Menu.Root.`);\n }\n return context;\n}\n\n/** What a `Menu.Popup` tells the items rendered in it. */\nexport interface MenuListContextValue {\n /** The menu this popup belongs to. */\n readonly menu: MenuContextValue;\n /**\n * `experimental_focusgroup` is on and the engine implements it: items render no `tabindex`\n * (Chromium leaves `tabindex=\"-1\"` elements out of a focusgroup) and the JS arrow keys step\n * aside.\n */\n readonly nativeFocusgroup: boolean;\n /** A typeahead buffer is active: Space is a character, not an activation (design 5.1). */\n readonly typingAhead: () => boolean;\n}\n\nexport const MenuListContext = createContext<MenuListContextValue | null>(null);\n\n/** `Menu.Group` / `Menu.RadioGroup`: the id their `Menu.GroupLabel` renders. */\nexport interface MenuGroupContextValue {\n readonly labelId: string;\n}\n\nexport const MenuGroupContext = createContext<MenuGroupContextValue | null>(null);\n\n/** `Menu.RadioGroup`'s state for its `Menu.RadioItem`s. */\nexport interface MenuRadioGroupContextValue {\n /** Optimistic value. */\n readonly value: string | null;\n readonly pending: boolean;\n /**\n * Dispatch `value` through the group's transition; `then` runs once the change action\n * resolved (an item's `closeOnActivate`).\n */\n readonly select: (value: string, event: Event, then: (() => void) | undefined) => void;\n}\n\nexport const MenuRadioGroupContext = createContext<MenuRadioGroupContextValue | null>(null);\n"],"mappings":";;;AAmDA,MAAa,mBAAkC,EAAE,MAAM,SAAS;AAqDhE,MAAa,cAAc,cAAuC,IAAI;;;;;AAMtE,MAAa,oBAAoB,cAAc,KAAK;;;;;;AAOpD,MAAM,gCAAgB,IAAI,QAAuB;;;;;;;AAQjD,MAAM,iCAAiB,IAAI,QAAe;AAE1C,SAAgB,WAAW,OAAoB;CAC7C,eAAe,IAAI,KAAK;AAC1B;AAEA,SAAgB,eAAe,OAAuB;CACpD,OAAO,eAAe,IAAI,KAAK;AACjC;AAkBA,MAAM,gCAAgB,IAAI,QAA+B;AAEzD,SAAgB,qBAAqB,SAAkB,OAAiC;CACtF,cAAc,IAAI,SAAS,KAAK;CAChC,aAAa;EACX,IAAI,cAAc,IAAI,OAAO,MAAM,OAAO,cAAc,OAAO,OAAO;CACxE;AACF;AAEA,SAAgB,aAAa,SAA4C;CACvE,OAAO,cAAc,IAAI,OAAO;AAClC;;AAGA,MAAM,WAAW,SAAmC,KAAK,KAAK,QAAQ;AAEtE,SAAgB,YAAY,OAAc,MAA8B;CACtE,cAAc,IAAI,OAAO,QAAQ,IAAI,CAAC;AACxC;AAEA,SAAgB,YAAY,OAAc,MAAiC;CACzE,OAAO,cAAc,IAAI,KAAK,MAAM,QAAQ,IAAI;AAClD;;;;;;AAOA,SAAgB,gBAAgB,MAAwB,OAA0B;CAChF,MAAM,EAAE,YAAY,KAAK;CACzB,MAAM,aAAa,QAAQ,eAAe;CAC1C,aAAa;EACX,IAAI,QAAQ,eAAe,MAAM,YAAY,QAAQ,aAAa,OAAO,UAAU;CACrF;AACF;AAEA,SAAgB,eAAe,MAAgC;CAC7D,MAAM,UAAU,IAAI,WAAW;CAC/B,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,sCAAsC;CAEhE,OAAO;AACT;AAgBA,MAAa,kBAAkB,cAA2C,IAAI;AAO9E,MAAa,mBAAmB,cAA4C,IAAI;AAchF,MAAa,wBAAwB,cAAiD,IAAI"}
1
+ {"version":3,"file":"menu-context.mjs","names":[],"sources":["../../src/menu/menu-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { DelayedPair } from \"../internal/use-delayed-pair.js\";\nimport type { PopoverRootValue } from \"../internal/use-overlay-root.js\";\n\n/**\n * Where focus goes when the menu opens (design/components/menu.md 6.1): the first enabled item,\n * the last one (ArrowUp on the Trigger), or nowhere (a hover-opened submenu keeps focus on its\n * SubmenuTrigger).\n */\nexport type MenuOpenCause = \"first\" | \"last\" | \"none\";\n\n/** How the open being shown should place focus (design 6.1). */\nexport interface MenuOpenFocus {\n readonly cause: MenuOpenCause;\n /**\n * The open came from a pointer click (`detail > 0`): the item is focused without the focus\n * ring where the engine supports `focus({ focusVisible: false })`.\n */\n readonly pointer: boolean;\n}\n\n/**\n * How the current open is placed (design/components/context-menu.md 3.1): against the Trigger\n * (`anchor`: a Menu.Trigger, a foreign invoker, a controlled or platform open), or at a point\n * (`point`: a Menu.ContextTrigger). `generation` grows with every point open or move, so a second\n * right-click at a new point is a state change while the menu is open (4.3).\n */\nexport type MenuPlacement =\n | { readonly kind: \"anchor\" }\n | {\n readonly kind: \"point\";\n readonly x: number;\n readonly y: number;\n readonly generation: number;\n /** The region that opened: the `source` of `showPopover({ source })` (nesting). */\n readonly source: HTMLElement;\n /** The pointer held down at the open, re-captured after a move's re-show (2.1). */\n readonly pointerId: number | undefined;\n /**\n * The popup's computed `direction` at this open or move (4.6): which edge of the menu\n * sits at the point. Read once by `openAt`, never during render.\n */\n readonly direction: \"ltr\" | \"rtl\";\n /**\n * A touch or pen open (4.7): the menu is placed above the point with\n * `--menu-point-gap`, so it does not open under the finger.\n */\n readonly offset: boolean;\n };\n\nexport const ANCHOR_PLACEMENT: MenuPlacement = { kind: \"anchor\" };\n\n/** What a ContextTrigger passes to `openAt`. */\nexport interface MenuOpenAtOptions {\n readonly source: HTMLElement;\n /** The `contextmenu` event, or the long-press `pointerdown` (`details.event`). */\n readonly event: Event;\n /** A pointer opened (quiet focus); `false` for the keyboard (focus ring). */\n readonly pointer: boolean;\n readonly pointerId: number | undefined;\n /** A touch or pen open: placed above the point (4.7). */\n readonly offset: boolean;\n}\n\n/** One menu level: what its Root provides to its Trigger, Popup and items. */\nexport interface MenuContextValue {\n /** The shared popover machinery (`useOverlayRoot`). */\n readonly popover: PopoverRootValue;\n /** This Root is nested in a `Menu.Popup`. */\n readonly submenu: boolean;\n /** The top-level menu: item activation closes the whole stack through it (design 2.2). */\n readonly root: MenuContextValue;\n /** The enclosing menu of a submenu; `null` at the top level. */\n readonly parent: MenuContextValue | null;\n readonly loop: boolean;\n readonly delay: number;\n readonly closeDelay: number;\n /** The Trigger's id (`aria-labelledby` of the Popup). */\n readonly triggerId: string;\n /** Record the focus target of the next open (and whether a pointer asked for it). */\n readonly setOpenCause: (cause: MenuOpenCause, pointer?: boolean) => void;\n /** Read and clear the focus target of the open being shown (default `\"first\"`, keyboard). */\n readonly takeOpenCause: () => MenuOpenFocus;\n /** Submenu hover-intent timers, shared by the SubmenuTrigger and the Popup. */\n readonly timers: DelayedPair;\n /** Placement of the current (or last) open (context-menu.md 3.1). */\n readonly placement: MenuPlacement;\n /**\n * A ContextTrigger opens the menu at `point`, or moves it there when it is already open (no\n * dispatch, 4.3).\n */\n readonly openAt: (\n point: { readonly x: number; readonly y: number },\n options: MenuOpenAtOptions,\n ) => void;\n /**\n * Back to the anchored placement once a point open has been shown and hidden (the popup is no\n * longer visible): the next open that is not a ContextTrigger's (controlled, platform, foreign\n * invoker) places against the Trigger. Ignored when a newer point was recorded meanwhile.\n */\n readonly resetPlacement: (generation: number) => void;\n}\n\nexport const MenuContext = createContext<MenuContextValue | null>(null);\n\n/**\n * `true` inside a `Menu.ContextTrigger`: a `Menu.Root` there is a nested context region's own\n * top-level menu (context-menu.md 2.4), not a misplaced submenu.\n */\nexport const MenuRegionContext = createContext(false);\n\n/**\n * `contextmenu` events a ContextTrigger handled (opened or moved its menu), with the top-level\n * menu they belong to: that menu's document listener leaves its menu open for them\n * (context-menu.md 5 and 14).\n */\nconst handledEvents = new WeakMap<Event, object>();\n\n/**\n * `pointerdown` events that are not a long-press of an enclosing region: claimed by the innermost\n * region that started its timer for them (nested regions), and by every `Menu.Popup` for the\n * presses inside it (a menu inside a region). As `contextmenu`'s `defaultPrevented`\n * rule (context-menu.md 2.4).\n */\nconst claimedPresses = new WeakSet<Event>();\n\nexport function claimPress(event: Event): void {\n claimedPresses.add(event);\n}\n\nexport function isPressClaimed(event: Event): boolean {\n return claimedPresses.has(event);\n}\n\n/**\n * What a hit on a `Menu.SubmenuTrigger` during a press-drag-release gesture does (context-menu.md\n * 2.6): the hover intent a real `pointerenter` / `pointerleave` would start. Registered by the\n * SubmenuTrigger on its element; the gesture runs under pointer capture, so the element never\n * receives boundary events itself.\n */\nexport interface SubmenuHover {\n readonly enter: (event: Event) => void;\n readonly leave: (event: Event) => void;\n /**\n * The submenu's popup, for the gesture's \"still over the submenu\" test (not `popovertarget`: a\n * non-button SubmenuTrigger has none).\n */\n readonly popup: () => HTMLElement | null;\n}\n\nconst submenuHovers = new WeakMap<Element, SubmenuHover>();\n\nexport function registerSubmenuHover(element: Element, hover: SubmenuHover): () => void {\n submenuHovers.set(element, hover);\n return () => {\n if (submenuHovers.get(element) === hover) submenuHovers.delete(element);\n };\n}\n\nexport function submenuHover(element: Element): SubmenuHover | undefined {\n return submenuHovers.get(element);\n}\n\n/** The top-level menu's identity: its popup ref object, stable for the Root's lifetime. */\nconst menuKey = (menu: MenuContextValue): object => menu.root.popover.popupRef;\n\nexport function markHandled(event: Event, menu: MenuContextValue): void {\n handledEvents.set(event, menuKey(menu));\n}\n\nexport function isHandledBy(event: Event, menu: MenuContextValue): boolean {\n return handledEvents.get(event) === menuKey(menu);\n}\n\n/**\n * The close an activated item runs once its action settled: the whole stack, through the\n * top-level Root (design 2.2). Recorded at activation: if the menu was dismissed and opened again\n * meanwhile, the close belongs to the previous opening and does nothing (as `useActionTrigger`).\n */\nexport function closeStackLater(menu: MenuContextValue, event: Event): () => void {\n const { popover } = menu.root;\n const generation = popover.openGeneration();\n return () => {\n if (popover.openGeneration() === generation) popover.requestClose(event, \"activate\");\n };\n}\n\nexport function useMenuContext(part: string): MenuContextValue {\n const context = use(MenuContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Menu.Root.`);\n }\n return context;\n}\n\n/** What a `Menu.Popup` tells the items rendered in it. */\nexport interface MenuListContextValue {\n /** The menu this popup belongs to. */\n readonly menu: MenuContextValue;\n /**\n * `experimental_focusgroup` is on and the engine implements it: items render no `tabindex`\n * (Chromium leaves `tabindex=\"-1\"` elements out of a focusgroup) and the JS arrow keys step\n * aside.\n */\n readonly nativeFocusgroup: boolean;\n /** A typeahead buffer is active: Space is a character, not an activation (design 5.1). */\n readonly typingAhead: () => boolean;\n}\n\nexport const MenuListContext = createContext<MenuListContextValue | null>(null);\n\n/** `Menu.Group` / `Menu.RadioGroup`: the id their `Menu.GroupLabel` renders. */\nexport interface MenuGroupContextValue {\n readonly labelId: string;\n}\n\nexport const MenuGroupContext = createContext<MenuGroupContextValue | null>(null);\n\n/** `Menu.RadioGroup`'s state for its `Menu.RadioItem`s. */\nexport interface MenuRadioGroupContextValue {\n /** Optimistic value. */\n readonly value: string | null;\n readonly pending: boolean;\n /**\n * Dispatch `value` through the group's transition; `then` runs once the change action\n * resolved (an item's `closeOnActivate`).\n */\n readonly select: (value: string, event: Event, then: (() => void) | undefined) => void;\n}\n\nexport const MenuRadioGroupContext = createContext<MenuRadioGroupContextValue | null>(null);\n"],"mappings":";;;AAmDA,MAAa,mBAAkC,EAAE,MAAM,SAAS;AAqDhE,MAAa,cAAc,cAAuC,IAAI;;;;;AAMtE,MAAa,oBAAoB,cAAc,KAAK;;;;;;AAOpD,MAAM,gCAAgB,IAAI,QAAuB;;;;;;;AAQjD,MAAM,iCAAiB,IAAI,QAAe;AAE1C,SAAgB,WAAW,OAAoB;CAC7C,eAAe,IAAI,KAAK;AAC1B;AAEA,SAAgB,eAAe,OAAuB;CACpD,OAAO,eAAe,IAAI,KAAK;AACjC;AAkBA,MAAM,gCAAgB,IAAI,QAA+B;AAEzD,SAAgB,qBAAqB,SAAkB,OAAiC;CACtF,cAAc,IAAI,SAAS,KAAK;CAChC,aAAa;EACX,IAAI,cAAc,IAAI,OAAO,MAAM,OAAO,cAAc,OAAO,OAAO;CACxE;AACF;AAEA,SAAgB,aAAa,SAA4C;CACvE,OAAO,cAAc,IAAI,OAAO;AAClC;;AAGA,MAAM,WAAW,SAAmC,KAAK,KAAK,QAAQ;AAEtE,SAAgB,YAAY,OAAc,MAA8B;CACtE,cAAc,IAAI,OAAO,QAAQ,IAAI,CAAC;AACxC;AAEA,SAAgB,YAAY,OAAc,MAAiC;CACzE,OAAO,cAAc,IAAI,KAAK,MAAM,QAAQ,IAAI;AAClD;;;;;;AAOA,SAAgB,gBAAgB,MAAwB,OAA0B;CAChF,MAAM,EAAE,YAAY,KAAK;CACzB,MAAM,aAAa,QAAQ,eAAe;CAC1C,aAAa;EACX,IAAI,QAAQ,eAAe,MAAM,YAAY,QAAQ,aAAa,OAAO,UAAU;CACrF;AACF;AAEA,SAAgB,eAAe,MAAgC;CAC7D,MAAM,UAAU,IAAI,WAAW;CAC/B,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,sCAAsC;CAEhE,OAAO;AACT;AAgBA,MAAa,kBAAkB,cAA2C,IAAI;AAO9E,MAAa,mBAAmB,cAA4C,IAAI;AAchF,MAAa,wBAAwB,cAAiD,IAAI"}
@@ -73,7 +73,9 @@ export interface MenuPopupProps extends Omit<ComponentPropsWithRef<"div">, "id"
73
73
  * placed against its Trigger with CSS Anchor Positioning. Owns the keyboard model (design 5):
74
74
  * ArrowUp / ArrowDown / Home / End move focus between items (or the browser does, with
75
75
  * `experimental_focusgroup` where supported), printable characters run typeahead, ArrowLeft
76
- * closes a submenu. The top-level popup closes the whole menu at once when focus leaves it (Tab).
76
+ * closes a submenu. The top-level popup closes the whole menu at once when focus leaves it (Tab);
77
+ * a press on a button of the consumer's that names it (`popovertarget`, `commandfor`) moves no
78
+ * focus, so that button's click closes the menu as `"activate"`.
77
79
  * Style it with `:popover-open`; it emits `data-side` / `data-align` but no `data-open`. While
78
80
  * shown, those are where the browser placed it (conventions 13.2), otherwise the requested
79
81
  * values.
@@ -1 +1 @@
1
- {"version":3,"file":"menu-popup.d.mts","names":[],"sources":["../../src/menu/menu-popup.tsx"],"mappings":";;;;;YAqCY,WAAW;YACX,YAAY;iBAEP;;WAEN;;;;;;WAMA,MAAM;;WAEN,OAAO;;WAEP;;;;;WAKA;;iBAGM,uBAAuB,KACtC;;;;;;;;;;;EA4BA,OAAO;;;;;;EAMP,QAAQ;;;;;;EAMR;;;;;;;EAOA;;;;;;;EAOA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;;;;;;;;;;;wBA2BpC,YACd,MAAM,UACN,OACA,aACA,yBACA,YACA,WACA,OACA,UACA,WACG,QACF,iBAAc;yBAXD"}
1
+ {"version":3,"file":"menu-popup.d.mts","names":[],"sources":["../../src/menu/menu-popup.tsx"],"mappings":";;;;;YAsCY,WAAW;YACX,YAAY;iBAEP;;WAEN;;;;;;WAMA,MAAM;;WAEN,OAAO;;WAEP;;;;;WAKA;;iBAGM,uBAAuB,KACtC;;;;;;;;;;;EA4BA,OAAO;;;;;;EAMP,QAAQ;;;;;;EAMR;;;;;;;EAOA;;;;;;;EAOA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;wBA6BpC,YACd,MAAM,UACN,OACA,aACA,yBACA,YACA,WACA,OACA,UACA,WACG,QACF,iBAAc;yBAXD"}
@@ -10,6 +10,7 @@ import { isPopoverOpen } from "../internal/popover-open.mjs";
10
10
  import { useAnchoredPlacement } from "../internal/use-resolved-placement.mjs";
11
11
  import { CSPContext } from "../internal/csp-context.mjs";
12
12
  import { FSUI_PRECEDENCE } from "../internal/shipped-styles.mjs";
13
+ import { listenInvokerPresses } from "../internal/invokers.mjs";
13
14
  import { usePopoverPopup } from "../internal/use-popover-popup.mjs";
14
15
  import { MenuListContext, claimPress, useMenuContext } from "./menu-context.mjs";
15
16
  import { edgeItem } from "./menu-dom.mjs";
@@ -18,7 +19,7 @@ import { scheduleHoverClose } from "./menu-hover.mjs";
18
19
  import { listenOutside } from "./menu-outside.mjs";
19
20
  import { MENU_POINT_HREF, MENU_POINT_RULES, pointStyle } from "./menu-point.mjs";
20
21
  import { useMenuKeyboard } from "./use-menu-keyboard.mjs";
21
- import { use, useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
22
+ import { use, useCallback, useLayoutEffect, useMemo, useRef } from "react";
22
23
  import { jsx, jsxs } from "react/jsx-runtime";
23
24
  //#region src/menu/menu-popup.tsx
24
25
  const isDev = process.env.NODE_ENV !== "production";
@@ -29,7 +30,9 @@ const FOCUSABLE_SELECTOR = "a[href], button, input, select, textarea, summary, [
29
30
  * placed against its Trigger with CSS Anchor Positioning. Owns the keyboard model (design 5):
30
31
  * ArrowUp / ArrowDown / Home / End move focus between items (or the browser does, with
31
32
  * `experimental_focusgroup` where supported), printable characters run typeahead, ArrowLeft
32
- * closes a submenu. The top-level popup closes the whole menu at once when focus leaves it (Tab).
33
+ * closes a submenu. The top-level popup closes the whole menu at once when focus leaves it (Tab);
34
+ * a press on a button of the consumer's that names it (`popovertarget`, `commandfor`) moves no
35
+ * focus, so that button's click closes the menu as `"activate"`.
33
36
  * Style it with `:popover-open`; it emits `data-side` / `data-align` but no `data-open`. While
34
37
  * shown, those are where the browser placed it (conventions 13.2), otherwise the requested
35
38
  * values.
@@ -56,16 +59,9 @@ function MenuPopup({ side: sideProp, align = "start", keepMounted, experimental_
56
59
  align,
57
60
  fallbacks: submenu ? "flip-inline" : void 0
58
61
  });
59
- const { side } = placement;
60
- const resolvedAlign = placement.align;
62
+ const { side, align: resolvedAlign, ref: placementRef } = placement;
61
63
  const nativeFocusgroup = useNativeFocusgroup(experimental_focusgroup);
62
64
  const { onKeyDown, typingAhead } = useMenuKeyboard(menu, nativeFocusgroup);
63
- const outside = useRef(null);
64
- const stopOutside = useCallback(() => {
65
- outside.current?.();
66
- outside.current = null;
67
- }, []);
68
- useEffect(() => stopOutside, [stopOutside]);
69
65
  const { setElement, visible, renderContent, reshow } = usePopoverPopup(popover, {
70
66
  part: "Menu.Popup",
71
67
  resolveInitialFocus: (popup) => {
@@ -80,11 +76,13 @@ function MenuPopup({ side: sideProp, align = "start", keepMounted, experimental_
80
76
  keepMounted,
81
77
  transition,
82
78
  source: () => point !== null ? point.source : popover.triggerRef.current,
83
- onToggle: (event) => {
84
- if (submenu) return;
85
- const element = popover.popupRef.current;
86
- if (event.newState === "open" && element !== null && isPopoverOpen(element)) outside.current ??= listenOutside(element, menu, () => latestPlacement.current);
87
- else if (event.newState === "closed") stopOutside();
79
+ whileShown: submenu ? void 0 : (element) => {
80
+ const stopListening = listenOutside(element, menu, () => latestPlacement.current);
81
+ const stopPresses = listenInvokerPresses(element);
82
+ return () => {
83
+ stopListening();
84
+ stopPresses();
85
+ };
88
86
  }
89
87
  });
90
88
  const shownKey = useRef(null);
@@ -101,14 +99,13 @@ function MenuPopup({ side: sideProp, align = "start", keepMounted, experimental_
101
99
  }
102
100
  });
103
101
  const checkElement = useElementCheck(isDev && ((element) => element.tagName === "DIALOG" ? "Menu.Popup: rendered a <dialog>. Render a <div>: a <dialog popover> runs the dialog focusing steps, which fight the menu's item focus." : null));
104
- const devRef = useCallback((element) => {
102
+ const pressRef = useCallback((element) => {
105
103
  checkElement?.(element);
106
104
  const onPointerDown = (event) => claimPress(event);
107
105
  element.addEventListener("pointerdown", onPointerDown);
108
106
  return () => element.removeEventListener("pointerdown", onPointerDown);
109
107
  }, [checkElement]);
110
- const placementRef = placement.ref;
111
- const ref = useMergedRefs(setElement, devRef, placementRef);
108
+ const ref = useMergedRefs(setElement, pressRef, placementRef);
112
109
  const listContext = useMemo(() => ({
113
110
  menu,
114
111
  nativeFocusgroup,
@@ -1 +1 @@
1
- {"version":3,"file":"menu-popup.mjs","names":[],"sources":["../../src/menu/menu-popup.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback, useEffect, useLayoutEffect, useMemo, useRef } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n FocusEvent,\n MouseEvent,\n PointerEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport type { AnchorAlign, AnchorSide } from \"../internal/anchor-position.js\";\nimport { CSPContext } from \"../internal/csp-context.js\";\nimport { isPopoverOpen } from \"../internal/popover-open.js\";\nimport { capturePointer } from \"../internal/pointer-capture.js\";\nimport { FSUI_PRECEDENCE } from \"../internal/shipped-styles.js\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { useNativeFocusgroup } from \"../internal/use-native-focusgroup.js\";\nimport { usePopoverPopup } from \"../internal/use-popover-popup.js\";\nimport { useAnchoredPlacement } from \"../internal/use-resolved-placement.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { claimPress, MenuListContext, useMenuContext } from \"./menu-context.js\";\nimport type { MenuListContextValue } from \"./menu-context.js\";\nimport { edgeItem } from \"./menu-dom.js\";\nimport { scheduleHoverClose } from \"./menu-hover.js\";\nimport { listenOutside } from \"./menu-outside.js\";\nimport { MENU_POINT_HREF, MENU_POINT_RULES, pointStyle } from \"./menu-point.js\";\nimport { useMenuKeyboard } from \"./use-menu-keyboard.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** `inline-start` / `inline-end` follow the popup's `direction` (conventions 13.1). */\nexport type MenuSide = AnchorSide;\nexport type MenuAlign = AnchorAlign;\n\nexport interface MenuPopupState {\n /** Committed open state. Read `:popover-open` for the DOM truth. */\n readonly open: boolean;\n /**\n * While shown: the physical side the browser placed the popup on (after any fallback flip;\n * conventions 13.2). Otherwise the `side` prop. `null` with `side={null}`, and while the menu\n * is placed at a point (`context`).\n */\n readonly side: MenuSide | null;\n /** While shown: the resolved alignment; otherwise the `align` prop. */\n readonly align: MenuAlign;\n /** This popup belongs to a submenu. */\n readonly submenu: boolean;\n /**\n * The current open came from a `Menu.ContextTrigger`: the popup is placed at the pointer, with\n * `--menu-point-x` / `--menu-point-y` set inline (`data-context`).\n */\n readonly context: boolean;\n}\n\nexport interface MenuPopupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"id\"\n | \"popover\"\n | \"role\"\n | \"aria-labelledby\"\n | \"onKeyDown\"\n | \"onFocus\"\n | \"onBlur\"\n | \"onMouseDown\"\n | \"onContextMenu\"\n | \"onPointerEnter\"\n | \"onPointerLeave\"\n | \"onToggle\"\n | \"onBeforeToggle\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * Placement against the Trigger through inline `position-area`, with `position-try-fallbacks`\n * flipping it when it does not fit. Default `\"bottom\"` for a top-level menu, `\"inline-end\"` for\n * a submenu (the right of the item in LTR, its left in RTL; its fallback is `flip-inline`\n * only). `\"left\"` / `\"right\"` stay physical. `null` emits no inline positioning (and no\n * `data-side` / `data-align`): the stylesheet owns placement. Ignored for an open from a\n * `Menu.ContextTrigger`, which is placed at the pointer; there `null` also opts out of the\n * inline point placement and the library's `@position-try` rules, leaving only\n * `--menu-point-x` / `--menu-point-y`.\n */\n side?: MenuSide | null;\n /**\n * Alignment along the side. Default `\"start\"` (both levels): inline-relative on a top / bottom\n * side (mirrored under `direction: rtl`), the top edges on the others. Ignored when `side` is\n * `null`.\n */\n align?: MenuAlign;\n /**\n * `false` (default): the items are not rendered while the menu is closed; mounting them is part\n * of the opening transition, so items that suspend hold the open (and the Trigger pending)\n * until they are ready. `true`: they stay mounted inside `<Activity mode=\"hidden\">`.\n */\n keepMounted?: boolean;\n /**\n * Experimental (Chromium 150+). Renders `focusgroup=\"menu wrap|nowrap\"` and, where the engine\n * implements `focusGroup`, lets the browser handle ArrowUp / ArrowDown / Home / End: items then\n * render no `tabindex` and the library's arrow-key handling steps aside. Typeahead, activation,\n * submenu keys and Tab stay in JS. No effect in other engines. Default `false`.\n */\n experimental_focusgroup?: boolean;\n /**\n * Forwarded to the `<ViewTransition default>` around the popup element. Animates the opening\n * commit and every library-driven close (an item's activation, the Trigger, ArrowLeft, hover\n * leaving a submenu, controlled `open={false}`) in all engines; dismissals (Escape, a click\n * outside, Tab) animate with CSS only. Without it the part renders no `<ViewTransition>`.\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, MenuPopupState>;\n style?: StateValue<CSSProperties | undefined, MenuPopupState>;\n children?: StateValue<ReactNode, MenuPopupState>;\n /** Should render a `<div>`; a `<dialog>` would run the dialog focusing steps. */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, MenuPopupState>;\n}\n\n/** What a press may focus inside a popup: items, the popup itself, the consumer's controls. */\nconst FOCUSABLE_SELECTOR =\n 'a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]:not([contenteditable=\"false\"])';\n\n/**\n * The menu itself: `<div popover=\"auto\" role=\"menu\" aria-labelledby={trigger} tabindex=\"-1\">`,\n * placed against its Trigger with CSS Anchor Positioning. Owns the keyboard model (design 5):\n * ArrowUp / ArrowDown / Home / End move focus between items (or the browser does, with\n * `experimental_focusgroup` where supported), printable characters run typeahead, ArrowLeft\n * closes a submenu. The top-level popup closes the whole menu at once when focus leaves it (Tab).\n * Style it with `:popover-open`; it emits `data-side` / `data-align` but no `data-open`. While\n * shown, those are where the browser placed it (conventions 13.2), otherwise the requested\n * values.\n *\n * Owned keys (conventions 1.2): `id`, `popover`, `role`, `aria-labelledby` (token-merged),\n * `tabIndex`, `focusgroup` (with the flag), `onKeyDown`, `onBlur`, `onMouseDown` (a press on\n * non-item space keeps focus on the current item), `onContextMenu` (no native menu over this\n * one), `onPointerEnter` / `onPointerLeave`, `data-side` / `data-align` unless `side` is `null`\n * or the menu is placed at a point, and `data-context` for an open from a `Menu.ContextTrigger`.\n * Such an open is placed at the pointer: `--menu-point-x` / `--menu-point-y` inline and, unless\n * `side` is `null`, `top` and `left` (`right` for an RTL popup) at the point with the library's\n * `@position-try` fallbacks, whose rules it renders as a hoisted `<style>`. A top-level menu\n * closes at once on a right- or middle-click outside it.\n */\nexport function MenuPopup({\n side: sideProp,\n align = \"start\",\n keepMounted,\n experimental_focusgroup = false,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: MenuPopupProps) {\n const menu = useMenuContext(\"Menu.Popup\");\n const { popover, submenu, loop } = menu;\n const csp = use(CSPContext);\n // The listeners installed at the open read the placement of the latest commit (4.8).\n const latestPlacement = useLatest(menu.placement);\n // A submenu opens on the inline-end side of its item: the side ArrowRight (ArrowLeft in RTL)\n // points to.\n const sideOption = sideProp === undefined ? (submenu ? \"inline-end\" : \"bottom\") : sideProp;\n // A ContextTrigger's open is placed at the point; nothing is anchored (context-menu.md 3.3).\n const point = menu.placement.kind === \"point\" ? menu.placement : null;\n const requestedSide = point !== null ? null : sideOption;\n // Resolved while shown (conventions 13.2); idle for a point open, which has no side.\n const placement = useAnchoredPlacement({\n side: requestedSide,\n align,\n fallbacks: submenu ? \"flip-inline\" : undefined,\n });\n const { side } = placement;\n const resolvedAlign = placement.align;\n\n const nativeFocusgroup = useNativeFocusgroup(experimental_focusgroup);\n const { onKeyDown, typingAhead } = useMenuKeyboard(menu, nativeFocusgroup);\n\n // The outside right- / middle-click listeners of a top-level menu, while it is shown.\n const outside = useRef<(() => void) | null>(null);\n const stopOutside = useCallback(() => {\n outside.current?.();\n outside.current = null;\n }, []);\n useEffect(() => stopOutside, [stopOutside]);\n\n const { setElement, visible, renderContent, reshow } = usePopoverPopup(popover, {\n part: \"Menu.Popup\",\n // Design 6.1: the first (or last) enabled item by open cause, nothing for a hover open, the\n // popup itself when there are no items.\n // A pointer open focuses without the focus ring where the engine can be told so.\n resolveInitialFocus: (popup) => {\n const { cause, pointer } = menu.takeOpenCause();\n if (cause === \"none\") return null;\n const element = edgeItem(popup, cause) ?? popup;\n return pointer ? { element, focusVisible: false } : element;\n },\n keepMounted,\n transition,\n // A point open nests through the region that opened it (context-menu.md 3.1).\n source: () => (point !== null ? point.source : popover.triggerRef.current),\n onToggle: (event) => {\n if (submenu) return;\n const element = popover.popupRef.current;\n if (event.newState === \"open\" && element !== null && isPopoverOpen(element)) {\n outside.current ??= listenOutside(element, menu, () => latestPlacement.current);\n } else if (event.newState === \"closed\") {\n stopOutside();\n }\n },\n });\n\n // A move (context-menu.md 4.3): the popup is shown and the placement changed since it was\n // shown (a new point, or a right-click in the region while a Trigger open is shown). Re-show\n // it so the respelled fallbacks place it afresh, the source is the region and the first item\n // is focused again; then capture the still-pressed pointer again, against the Firefox / WebKit\n // `pointerup` light dismiss. Runs after the hook's apply effect (declared after it).\n // Once the popup is not visible (hidden, exit animation over) and no open is intended or in\n // flight, a point placement goes back to anchored for the next open that is not a\n // ContextTrigger's: after a point open that was shown and closed, and after one that was\n // rejected or refused.\n const shownKey = useRef<number | \"anchor\" | null>(null);\n useLayoutEffect(() => {\n const element = popover.popupRef.current;\n if (element === null) return;\n const key = point !== null ? point.generation : \"anchor\";\n if (isPopoverOpen(element)) {\n if (shownKey.current !== null && shownKey.current !== key && reshow()) {\n capturePointer(element, point?.pointerId);\n }\n shownKey.current = key;\n } else {\n shownKey.current = null;\n if (!visible && point !== null && !popover.pending && !popover.intended()) {\n menu.resetPlacement(point.generation);\n }\n }\n });\n\n const checkElement = useElementCheck(\n isDev &&\n ((element) =>\n element.tagName === \"DIALOG\"\n ? \"Menu.Popup: rendered a <dialog>. Render a <div>: a <dialog popover> runs the dialog \" +\n \"focusing steps, which fight the menu's item focus.\"\n : null),\n );\n const devRef = useCallback(\n (element: HTMLElement) => {\n checkElement?.(element);\n // A press inside a menu is never a long-press of a Menu.ContextTrigger around it.\n // Native, so it runs before React's root listener dispatches to the region.\n const onPointerDown = (event: Event) => claimPress(event);\n element.addEventListener(\"pointerdown\", onPointerDown);\n return () => element.removeEventListener(\"pointerdown\", onPointerDown);\n },\n [checkElement],\n );\n const placementRef = placement.ref;\n const ref = useMergedRefs(setElement, devRef, placementRef);\n\n const listContext = useMemo<MenuListContextValue>(\n () => ({ menu, nativeFocusgroup, typingAhead }),\n [menu, nativeFocusgroup, typingAhead],\n );\n\n const state: MenuPopupState = {\n open: popover.committed,\n side,\n align: resolvedAlign,\n submenu,\n context: point !== null,\n };\n\n // Tab / Shift+Tab or any focus move out of the tree closes the whole stack at once (design\n // 2.2): submenus are DOM descendants of the top-level popup, the Trigger is outside on purpose.\n // A null `relatedTarget` (window blur, a removed element) closes nothing.\n const onBlur = (event: FocusEvent<HTMLElement>) => {\n if (submenu) return;\n const popup = event.currentTarget;\n const next = event.relatedTarget;\n if (!(next instanceof Node) || popup.contains(next)) return;\n if (isPopoverOpen(popup)) popup.hidePopover();\n };\n\n // A press on non-item space (padding, a Separator, a GroupLabel) would focus the popup itself\n // (`tabindex=\"-1\"`) and take focus off the current item; keep it where it is (the\n // pointer-focus model of design 6.2). Focusable content of the consumer's (a text field) still\n // takes focus.\n const onMouseDown = (event: MouseEvent<HTMLElement>) => {\n if (event.button !== 0) return;\n const target = event.target as Element;\n const focusable = target.closest(FOCUSABLE_SELECTOR);\n if (focusable === null || focusable.getAttribute(\"role\") === \"menu\") event.preventDefault();\n };\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: popover.ids.popup,\n popover: \"auto\",\n role: \"menu\",\n \"aria-labelledby\": menu.triggerId,\n // The popup itself takes focus as the last resort when a menu has no items.\n tabIndex: -1,\n ...(experimental_focusgroup && { focusgroup: `menu ${loop ? \"wrap\" : \"nowrap\"}` }),\n onKeyDown,\n onBlur,\n onMouseDown,\n // No native menu over the custom one. The popup is a sibling of any ContextTrigger, so this\n // event never reaches a region as a move; an outer region sees it prevented and stays quiet.\n onContextMenu: (event: MouseEvent<HTMLElement>) => {\n event.preventDefault();\n },\n ...(submenu && {\n onPointerEnter: (event: PointerEvent<HTMLElement>) => {\n if (event.pointerType !== \"touch\") menu.timers.cancelClose();\n },\n onPointerLeave: (event: PointerEvent<HTMLElement>) => {\n if (event.pointerType !== \"touch\") scheduleHoverClose(menu, event.nativeEvent);\n },\n }),\n ...placement.dataAttributes,\n \"data-context\": point !== null ? \"\" : undefined,\n };\n\n // The shipped `@position-try` rules (conventions 12): hoisted into <head> and deduplicated by\n // React, rendered only by a point open that does not opt out with `side={null}`, with the\n // `<CSPProvider>` nonce for a nonce-based `style-src`.\n const pointRules =\n point !== null && sideOption !== null ? (\n <style href={MENU_POINT_HREF} precedence={FSUI_PRECEDENCE} nonce={csp?.nonce}>\n {MENU_POINT_RULES}\n </style>\n ) : null;\n\n const content = (s: MenuPopupState): ReactNode => (\n <MenuListContext value={listContext}>\n {pointRules}\n {renderContent(() => resolveStateValue(children, s))}\n </MenuListContext>\n );\n\n const element = useRender<ComponentPropsWithRef<\"div\">, MenuPopupState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // The inline placement sits under the consumer's style: the consumer wins.\n style:\n point !== null\n ? (s) => ({ ...pointStyle(point, sideOption === null), ...resolveStateValue(style, s) })\n : placement.style(style),\n children: content,\n props: rest,\n libraryProps,\n ref,\n });\n\n return useTransitionBoundary(\"Menu.Popup\", transition, element);\n}\n\nMenuPopup.displayName = \"MenuPopup\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;AA0FvC,MAAM,qBACJ;;;;;;;;;;;;;;;;;;;;;AAsBF,SAAgB,UAAU,EACxB,MAAM,UACN,QAAQ,SACR,aACA,0BAA0B,OAC1B,YACA,WACA,OACA,UACA,QACA,GAAG,QACc;CACjB,MAAM,OAAO,eAAe,YAAY;CACxC,MAAM,EAAE,SAAS,SAAS,SAAS;CACnC,MAAM,MAAM,IAAI,UAAU;CAE1B,MAAM,kBAAkB,UAAU,KAAK,SAAS;CAGhD,MAAM,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AI,2BAA2B,EAAE,YAAY,QAAQ,OAAO,SAAS,WAAW;EAChF;EACA;EACA;EAGA,gBAAgB,UAAmC;GACjD,MAAM,eAAe;EACvB;EACA,GAAI,WAAW;GACb,iBAAiB,UAAqC;IACpD,IAAI,MAAM,gBAAgB,SAAS,KAAK,OAAO,YAAY;GAC7D;GACA,iBAAiB,UAAqC;IACpD,IAAI,MAAM,gBAAgB,SAAS,mBAAmB,MAAM,MAAM,WAAW;GAC/E;EACF;EACA,GAAG,UAAU;EACb,gBAAgB,UAAU,OAAO,KAAK,KAAA;CACxC;CAKA,MAAM,aACJ,UAAU,QAAQ,eAAe,OAC/B,oBAAC,SAAD;EAAO,MAAM;EAAiB,YAAY;EAAiB,OAAO,KAAK;EACpE,UAAA;CACI,CAAA,IACL;CAEN,MAAM,WAAW,MACf,qBAAC,iBAAD;EAAiB,OAAO;EAAxB,UAAA,CACG,YACA,oBAAoB,kBAAkB,UAAU,CAAC,CAAC,CACpC;;CAGnB,MAAM,UAAU,UAAwD;EACtE,gBAAgB;EAChB;EACA;EACA;EAEA,OACE,UAAU,QACL,OAAO;GAAE,GAAG,WAAW,OAAO,eAAe,IAAI;GAAG,GAAG,kBAAkB,OAAO,CAAC;EAAE,KACpF,UAAU,MAAM,KAAK;EAC3B,UAAU;EACV,OAAO;EACP;EACA;CACF,CAAC;CAED,OAAO,sBAAsB,cAAc,YAAY,OAAO;AAChE;AAEA,UAAU,cAAc"}
1
+ {"version":3,"file":"menu-popup.mjs","names":[],"sources":["../../src/menu/menu-popup.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback, useLayoutEffect, useMemo, useRef } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n FocusEvent,\n MouseEvent,\n PointerEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport type { AnchorAlign, AnchorSide } from \"../internal/anchor-position.js\";\nimport { CSPContext } from \"../internal/csp-context.js\";\nimport { listenInvokerPresses } from \"../internal/invokers.js\";\nimport { isPopoverOpen } from \"../internal/popover-open.js\";\nimport { capturePointer } from \"../internal/pointer-capture.js\";\nimport { FSUI_PRECEDENCE } from \"../internal/shipped-styles.js\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { useNativeFocusgroup } from \"../internal/use-native-focusgroup.js\";\nimport { usePopoverPopup } from \"../internal/use-popover-popup.js\";\nimport { useAnchoredPlacement } from \"../internal/use-resolved-placement.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { claimPress, MenuListContext, useMenuContext } from \"./menu-context.js\";\nimport type { MenuListContextValue } from \"./menu-context.js\";\nimport { edgeItem } from \"./menu-dom.js\";\nimport { scheduleHoverClose } from \"./menu-hover.js\";\nimport { listenOutside } from \"./menu-outside.js\";\nimport { MENU_POINT_HREF, MENU_POINT_RULES, pointStyle } from \"./menu-point.js\";\nimport { useMenuKeyboard } from \"./use-menu-keyboard.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** `inline-start` / `inline-end` follow the popup's `direction` (conventions 13.1). */\nexport type MenuSide = AnchorSide;\nexport type MenuAlign = AnchorAlign;\n\nexport interface MenuPopupState {\n /** Committed open state. Read `:popover-open` for the DOM truth. */\n readonly open: boolean;\n /**\n * While shown: the physical side the browser placed the popup on (after any fallback flip;\n * conventions 13.2). Otherwise the `side` prop. `null` with `side={null}`, and while the menu\n * is placed at a point (`context`).\n */\n readonly side: MenuSide | null;\n /** While shown: the resolved alignment; otherwise the `align` prop. */\n readonly align: MenuAlign;\n /** This popup belongs to a submenu. */\n readonly submenu: boolean;\n /**\n * The current open came from a `Menu.ContextTrigger`: the popup is placed at the pointer, with\n * `--menu-point-x` / `--menu-point-y` set inline (`data-context`).\n */\n readonly context: boolean;\n}\n\nexport interface MenuPopupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"id\"\n | \"popover\"\n | \"role\"\n | \"aria-labelledby\"\n | \"onKeyDown\"\n | \"onFocus\"\n | \"onBlur\"\n | \"onMouseDown\"\n | \"onContextMenu\"\n | \"onPointerEnter\"\n | \"onPointerLeave\"\n | \"onToggle\"\n | \"onBeforeToggle\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * Placement against the Trigger through inline `position-area`, with `position-try-fallbacks`\n * flipping it when it does not fit. Default `\"bottom\"` for a top-level menu, `\"inline-end\"` for\n * a submenu (the right of the item in LTR, its left in RTL; its fallback is `flip-inline`\n * only). `\"left\"` / `\"right\"` stay physical. `null` emits no inline positioning (and no\n * `data-side` / `data-align`): the stylesheet owns placement. Ignored for an open from a\n * `Menu.ContextTrigger`, which is placed at the pointer; there `null` also opts out of the\n * inline point placement and the library's `@position-try` rules, leaving only\n * `--menu-point-x` / `--menu-point-y`.\n */\n side?: MenuSide | null;\n /**\n * Alignment along the side. Default `\"start\"` (both levels): inline-relative on a top / bottom\n * side (mirrored under `direction: rtl`), the top edges on the others. Ignored when `side` is\n * `null`.\n */\n align?: MenuAlign;\n /**\n * `false` (default): the items are not rendered while the menu is closed; mounting them is part\n * of the opening transition, so items that suspend hold the open (and the Trigger pending)\n * until they are ready. `true`: they stay mounted inside `<Activity mode=\"hidden\">`.\n */\n keepMounted?: boolean;\n /**\n * Experimental (Chromium 150+). Renders `focusgroup=\"menu wrap|nowrap\"` and, where the engine\n * implements `focusGroup`, lets the browser handle ArrowUp / ArrowDown / Home / End: items then\n * render no `tabindex` and the library's arrow-key handling steps aside. Typeahead, activation,\n * submenu keys and Tab stay in JS. No effect in other engines. Default `false`.\n */\n experimental_focusgroup?: boolean;\n /**\n * Forwarded to the `<ViewTransition default>` around the popup element. Animates the opening\n * commit and every library-driven close (an item's activation, the Trigger, ArrowLeft, hover\n * leaving a submenu, controlled `open={false}`) in all engines; dismissals (Escape, a click\n * outside, Tab) animate with CSS only. Without it the part renders no `<ViewTransition>`.\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, MenuPopupState>;\n style?: StateValue<CSSProperties | undefined, MenuPopupState>;\n children?: StateValue<ReactNode, MenuPopupState>;\n /** Should render a `<div>`; a `<dialog>` would run the dialog focusing steps. */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, MenuPopupState>;\n}\n\n/** What a press may focus inside a popup: items, the popup itself, the consumer's controls. */\nconst FOCUSABLE_SELECTOR =\n 'a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]:not([contenteditable=\"false\"])';\n\n/**\n * The menu itself: `<div popover=\"auto\" role=\"menu\" aria-labelledby={trigger} tabindex=\"-1\">`,\n * placed against its Trigger with CSS Anchor Positioning. Owns the keyboard model (design 5):\n * ArrowUp / ArrowDown / Home / End move focus between items (or the browser does, with\n * `experimental_focusgroup` where supported), printable characters run typeahead, ArrowLeft\n * closes a submenu. The top-level popup closes the whole menu at once when focus leaves it (Tab);\n * a press on a button of the consumer's that names it (`popovertarget`, `commandfor`) moves no\n * focus, so that button's click closes the menu as `\"activate\"`.\n * Style it with `:popover-open`; it emits `data-side` / `data-align` but no `data-open`. While\n * shown, those are where the browser placed it (conventions 13.2), otherwise the requested\n * values.\n *\n * Owned keys (conventions 1.2): `id`, `popover`, `role`, `aria-labelledby` (token-merged),\n * `tabIndex`, `focusgroup` (with the flag), `onKeyDown`, `onBlur`, `onMouseDown` (a press on\n * non-item space keeps focus on the current item), `onContextMenu` (no native menu over this\n * one), `onPointerEnter` / `onPointerLeave`, `data-side` / `data-align` unless `side` is `null`\n * or the menu is placed at a point, and `data-context` for an open from a `Menu.ContextTrigger`.\n * Such an open is placed at the pointer: `--menu-point-x` / `--menu-point-y` inline and, unless\n * `side` is `null`, `top` and `left` (`right` for an RTL popup) at the point with the library's\n * `@position-try` fallbacks, whose rules it renders as a hoisted `<style>`. A top-level menu\n * closes at once on a right- or middle-click outside it.\n */\nexport function MenuPopup({\n side: sideProp,\n align = \"start\",\n keepMounted,\n experimental_focusgroup = false,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: MenuPopupProps) {\n const menu = useMenuContext(\"Menu.Popup\");\n const { popover, submenu, loop } = menu;\n const csp = use(CSPContext);\n // The listeners installed at the open read the placement of the latest commit (4.8).\n const latestPlacement = useLatest(menu.placement);\n // A submenu opens on the inline-end side of its item: the side ArrowRight (ArrowLeft in RTL)\n // points to.\n const sideOption = sideProp === undefined ? (submenu ? \"inline-end\" : \"bottom\") : sideProp;\n // A ContextTrigger's open is placed at the point; nothing is anchored (context-menu.md 3.3).\n const point = menu.placement.kind === \"point\" ? menu.placement : null;\n const requestedSide = point !== null ? null : sideOption;\n // Resolved while shown (conventions 13.2); idle for a point open, which has no side.\n const placement = useAnchoredPlacement({\n side: requestedSide,\n align,\n fallbacks: submenu ? \"flip-inline\" : undefined,\n });\n const { side, align: resolvedAlign, ref: placementRef } = placement;\n\n const nativeFocusgroup = useNativeFocusgroup(experimental_focusgroup);\n const { onKeyDown, typingAhead } = useMenuKeyboard(menu, nativeFocusgroup);\n\n const { setElement, visible, renderContent, reshow } = usePopoverPopup(popover, {\n part: \"Menu.Popup\",\n // Design 6.1: the first (or last) enabled item by open cause, nothing for a hover open, the\n // popup itself when there are no items.\n // A pointer open focuses without the focus ring where the engine can be told so.\n resolveInitialFocus: (popup) => {\n const { cause, pointer } = menu.takeOpenCause();\n if (cause === \"none\") return null;\n const element = edgeItem(popup, cause) ?? popup;\n return pointer ? { element, focusVisible: false } : element;\n },\n keepMounted,\n transition,\n // A point open nests through the region that opened it (context-menu.md 3.1).\n source: () => (point !== null ? point.source : popover.triggerRef.current),\n // The outside right- / middle-click listeners and the foreign invoker press guard of a\n // top-level menu.\n whileShown: submenu\n ? undefined\n : (element) => {\n const stopListening = listenOutside(element, menu, () => latestPlacement.current);\n const stopPresses = listenInvokerPresses(element);\n return () => {\n stopListening();\n stopPresses();\n };\n },\n });\n\n // A move (context-menu.md 4.3): the popup is shown and the placement changed since it was\n // shown (a new point, or a right-click in the region while a Trigger open is shown). Re-show\n // it so the respelled fallbacks place it afresh, the source is the region and the first item\n // is focused again; then capture the still-pressed pointer again, against the Firefox / WebKit\n // `pointerup` light dismiss. Runs after the hook's apply effect (declared after it).\n // Once the popup is not visible (hidden, exit animation over) and no open is intended or in\n // flight, a point placement goes back to anchored for the next open that is not a\n // ContextTrigger's: after a point open that was shown and closed, and after one that was\n // rejected or refused.\n const shownKey = useRef<number | \"anchor\" | null>(null);\n useLayoutEffect(() => {\n const element = popover.popupRef.current;\n if (element === null) return;\n const key = point !== null ? point.generation : \"anchor\";\n if (isPopoverOpen(element)) {\n if (shownKey.current !== null && shownKey.current !== key && reshow()) {\n capturePointer(element, point?.pointerId);\n }\n shownKey.current = key;\n } else {\n shownKey.current = null;\n if (!visible && point !== null && !popover.pending && !popover.intended()) {\n menu.resetPlacement(point.generation);\n }\n }\n });\n\n const checkElement = useElementCheck(\n isDev &&\n ((element) =>\n element.tagName === \"DIALOG\"\n ? \"Menu.Popup: rendered a <dialog>. Render a <div>: a <dialog popover> runs the dialog \" +\n \"focusing steps, which fight the menu's item focus.\"\n : null),\n );\n const pressRef = useCallback(\n (element: HTMLElement) => {\n checkElement?.(element);\n // A press inside a menu is never a long-press of a Menu.ContextTrigger around it.\n // Native, so it runs before React's root listener dispatches to the region.\n const onPointerDown = (event: Event) => claimPress(event);\n element.addEventListener(\"pointerdown\", onPointerDown);\n return () => element.removeEventListener(\"pointerdown\", onPointerDown);\n },\n [checkElement],\n );\n const ref = useMergedRefs(setElement, pressRef, placementRef);\n\n const listContext = useMemo<MenuListContextValue>(\n () => ({ menu, nativeFocusgroup, typingAhead }),\n [menu, nativeFocusgroup, typingAhead],\n );\n\n const state: MenuPopupState = {\n open: popover.committed,\n side,\n align: resolvedAlign,\n submenu,\n context: point !== null,\n };\n\n // Tab / Shift+Tab or any focus move out of the tree closes the whole stack at once (design\n // 2.2): submenus are DOM descendants of the top-level popup, the Trigger is outside on purpose.\n // A null `relatedTarget` (window blur, a removed element) closes nothing.\n const onBlur = (event: FocusEvent<HTMLElement>) => {\n if (submenu) return;\n const popup = event.currentTarget;\n const next = event.relatedTarget;\n if (!(next instanceof Node) || popup.contains(next)) return;\n if (isPopoverOpen(popup)) popup.hidePopover();\n };\n\n // A press on non-item space (padding, a Separator, a GroupLabel) would focus the popup itself\n // (`tabindex=\"-1\"`) and take focus off the current item; keep it where it is (the\n // pointer-focus model of design 6.2). Focusable content of the consumer's (a text field) still\n // takes focus.\n const onMouseDown = (event: MouseEvent<HTMLElement>) => {\n if (event.button !== 0) return;\n const target = event.target as Element;\n const focusable = target.closest(FOCUSABLE_SELECTOR);\n if (focusable === null || focusable.getAttribute(\"role\") === \"menu\") event.preventDefault();\n };\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: popover.ids.popup,\n popover: \"auto\",\n role: \"menu\",\n \"aria-labelledby\": menu.triggerId,\n // The popup itself takes focus as the last resort when a menu has no items.\n tabIndex: -1,\n ...(experimental_focusgroup && { focusgroup: `menu ${loop ? \"wrap\" : \"nowrap\"}` }),\n onKeyDown,\n onBlur,\n onMouseDown,\n // No native menu over the custom one. The popup is a sibling of any ContextTrigger, so this\n // event never reaches a region as a move; an outer region sees it prevented and stays quiet.\n onContextMenu: (event: MouseEvent<HTMLElement>) => {\n event.preventDefault();\n },\n ...(submenu && {\n onPointerEnter: (event: PointerEvent<HTMLElement>) => {\n if (event.pointerType !== \"touch\") menu.timers.cancelClose();\n },\n onPointerLeave: (event: PointerEvent<HTMLElement>) => {\n if (event.pointerType !== \"touch\") scheduleHoverClose(menu, event.nativeEvent);\n },\n }),\n ...placement.dataAttributes,\n \"data-context\": point !== null ? \"\" : undefined,\n };\n\n // The shipped `@position-try` rules (conventions 12): hoisted into <head> and deduplicated by\n // React, rendered only by a point open that does not opt out with `side={null}`, with the\n // `<CSPProvider>` nonce for a nonce-based `style-src`.\n const pointRules =\n point !== null && sideOption !== null ? (\n <style href={MENU_POINT_HREF} precedence={FSUI_PRECEDENCE} nonce={csp?.nonce}>\n {MENU_POINT_RULES}\n </style>\n ) : null;\n\n const content = (s: MenuPopupState): ReactNode => (\n <MenuListContext value={listContext}>\n {pointRules}\n {renderContent(() => resolveStateValue(children, s))}\n </MenuListContext>\n );\n\n const element = useRender<ComponentPropsWithRef<\"div\">, MenuPopupState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // The inline placement sits under the consumer's style: the consumer wins.\n style:\n point !== null\n ? (s) => ({ ...pointStyle(point, sideOption === null), ...resolveStateValue(style, s) })\n : placement.style(style),\n children: content,\n props: rest,\n libraryProps,\n ref,\n });\n\n return useTransitionBoundary(\"Menu.Popup\", transition, element);\n}\n\nMenuPopup.displayName = \"MenuPopup\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;AA0FvC,MAAM,qBACJ;;;;;;;;;;;;;;;;;;;;;;;AAwBF,SAAgB,UAAU,EACxB,MAAM,UACN,QAAQ,SACR,aACA,0BAA0B,OAC1B,YACA,WACA,OACA,UACA,QACA,GAAG,QACc;CACjB,MAAM,OAAO,eAAe,YAAY;CACxC,MAAM,EAAE,SAAS,SAAS,SAAS;CACnC,MAAM,MAAM,IAAI,UAAU;CAE1B,MAAM,kBAAkB,UAAU,KAAK,SAAS;CAGhD,MAAM,aAAa,aAAa,KAAA,IAAa,UAAU,eAAe,WAAY;CAElF,MAAM,QAAQ,KAAK,UAAU,SAAS,UAAU,KAAK,YAAY;CAGjE,MAAM,YAAY,qBAAqB;EACrC,MAHoB,UAAU,OAAO,OAAO;EAI5C;EACA,WAAW,UAAU,gBAAgB,KAAA;CACvC,CAAC;CACD,MAAM,EAAE,MAAM,OAAO,eAAe,KAAK,iBAAiB;CAE1D,MAAM,mBAAmB,oBAAoB,uBAAuB;CACpE,MAAM,EAAE,WAAW,gBAAgB,gBAAgB,MAAM,gBAA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,CAAC,CACpC;;CAGnB,MAAM,UAAU,UAAwD;EACtE,gBAAgB;EAChB;EACA;EACA;EAEA,OACE,UAAU,QACL,OAAO;GAAE,GAAG,WAAW,OAAO,eAAe,IAAI;GAAG,GAAG,kBAAkB,OAAO,CAAC;EAAE,KACpF,UAAU,MAAM,KAAK;EAC3B,UAAU;EACV,OAAO;EACP;EACA;CACF,CAAC;CAED,OAAO,sBAAsB,cAAc,YAAY,OAAO;AAChE;AAEA,UAAU,cAAc"}
@@ -4,7 +4,7 @@ import { MenuTriggerState } from "./menu-trigger.mjs";
4
4
  import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
5
5
  //#region src/menu/menu-submenu-trigger.d.ts
6
6
  export type MenuSubmenuTriggerState = MenuTriggerState;
7
- export interface MenuSubmenuTriggerProps extends Omit<MenuItemProps, "action" | "closeOnActivate" | "aria-expanded" | "aria-haspopup" | "onPointerEnter" | "onPointerLeave" | "className" | "style" | "children" | "render"> {
7
+ export interface MenuSubmenuTriggerProps extends Omit<MenuItemProps, "action" | "closeOnActivate" | "aria-expanded" | "aria-haspopup" | "commandfor" | "command" | "popoverTarget" | "popoverTargetAction" | "onPointerEnter" | "onPointerLeave" | "className" | "style" | "children" | "render"> {
8
8
  className?: StateValue<string | undefined, MenuSubmenuTriggerState>;
9
9
  style?: StateValue<CSSProperties | undefined, MenuSubmenuTriggerState>;
10
10
  /** Rendered from optimistic state; must not suspend. */
@@ -13,15 +13,17 @@ export interface MenuSubmenuTriggerProps extends Omit<MenuItemProps, "action" |
13
13
  }
14
14
  /**
15
15
  * The item that opens a submenu: an item of the parent menu (`role="menuitem"`, roving
16
- * `tabindex`, typeahead) and the Trigger of the submenu's Root (`commandfor`,
17
- * `command="toggle-popover"`, `aria-haspopup="menu"`, `aria-expanded`). ArrowRight (ArrowLeft in
18
- * RTL), Enter, Space or a click open the submenu with its first item focused; hovering it opens
19
- * the submenu after the Root's `delay` and leaves focus where it is.
16
+ * `tabindex`, typeahead) and the Trigger of the submenu's Root (`popovertarget`,
17
+ * `aria-haspopup="menu"`; no `aria-expanded`: the browser exposes the submenu's state on its
18
+ * invoker). ArrowRight (ArrowLeft in RTL), Enter, Space or a click open the submenu with its first
19
+ * item focused; hovering it opens the submenu after the Root's `delay` and leaves focus where it
20
+ * is.
20
21
  *
21
- * Owned keys (conventions 1.2): the Trigger's (`type`, `id`, `commandfor`, `command`,
22
- * `aria-haspopup`, `aria-expanded`, `data-open`, `data-pending`) and the item's (`role`,
23
- * `tabIndex`, `disabled` (absent), `aria-disabled`, `data-disabled`, `data-typeahead`,
24
- * `onClick`, `onKeyDown`, `onPointerMove`, `onPointerEnter`, `onPointerLeave`).
22
+ * Owned keys (conventions 1.2): the Trigger's (`type`, `id`, `popoverTarget`, `aria-haspopup`,
23
+ * `aria-expanded`, `data-open`, `data-pending`; `commandfor`, `command` and `popoverTargetAction`,
24
+ * never written) and the item's (`role`, `tabIndex`, `disabled` (absent), `aria-disabled`,
25
+ * `data-disabled`, `data-typeahead`, `onClick`, `onKeyDown`, `onPointerMove`, `onPointerEnter`,
26
+ * `onPointerLeave`).
25
27
  */
26
28
  export declare function MenuSubmenuTrigger({ disabled, label, className, style, children, render, ...rest }: MenuSubmenuTriggerProps): ReactNode;
27
29
  export declare namespace MenuSubmenuTrigger {
@@ -1 +1 @@
1
- {"version":3,"file":"menu-submenu-trigger.d.mts","names":[],"sources":["../../src/menu/menu-submenu-trigger.tsx"],"mappings":";;;;;YAyBY,0BAA0B;iBAErB,gCAAgC,KAC/C;EAYA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;;wBAevC,qBACd,UACA,OACA,WACA,OACA,UACA,WACG,QACF,0BAAuB;yBARV"}
1
+ {"version":3,"file":"menu-submenu-trigger.d.mts","names":[],"sources":["../../src/menu/menu-submenu-trigger.tsx"],"mappings":";;;;;YAyBY,0BAA0B;iBAErB,gCAAgC,KAC/C;EAgBA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;;;;wBAiBvC,qBACd,UACA,OACA,WACA,OACA,UACA,WACG,QACF,0BAAuB;yBARV"}
@@ -14,15 +14,17 @@ import { useCallback } from "react";
14
14
  const isDev = process.env.NODE_ENV !== "production";
15
15
  /**
16
16
  * The item that opens a submenu: an item of the parent menu (`role="menuitem"`, roving
17
- * `tabindex`, typeahead) and the Trigger of the submenu's Root (`commandfor`,
18
- * `command="toggle-popover"`, `aria-haspopup="menu"`, `aria-expanded`). ArrowRight (ArrowLeft in
19
- * RTL), Enter, Space or a click open the submenu with its first item focused; hovering it opens
20
- * the submenu after the Root's `delay` and leaves focus where it is.
17
+ * `tabindex`, typeahead) and the Trigger of the submenu's Root (`popovertarget`,
18
+ * `aria-haspopup="menu"`; no `aria-expanded`: the browser exposes the submenu's state on its
19
+ * invoker). ArrowRight (ArrowLeft in RTL), Enter, Space or a click open the submenu with its first
20
+ * item focused; hovering it opens the submenu after the Root's `delay` and leaves focus where it
21
+ * is.
21
22
  *
22
- * Owned keys (conventions 1.2): the Trigger's (`type`, `id`, `commandfor`, `command`,
23
- * `aria-haspopup`, `aria-expanded`, `data-open`, `data-pending`) and the item's (`role`,
24
- * `tabIndex`, `disabled` (absent), `aria-disabled`, `data-disabled`, `data-typeahead`,
25
- * `onClick`, `onKeyDown`, `onPointerMove`, `onPointerEnter`, `onPointerLeave`).
23
+ * Owned keys (conventions 1.2): the Trigger's (`type`, `id`, `popoverTarget`, `aria-haspopup`,
24
+ * `aria-expanded`, `data-open`, `data-pending`; `commandfor`, `command` and `popoverTargetAction`,
25
+ * never written) and the item's (`role`, `tabIndex`, `disabled` (absent), `aria-disabled`,
26
+ * `data-disabled`, `data-typeahead`, `onClick`, `onKeyDown`, `onPointerMove`, `onPointerEnter`,
27
+ * `onPointerLeave`).
26
28
  */
27
29
  function MenuSubmenuTrigger({ disabled = false, label, className, style, children, render, ...rest }) {
28
30
  const menu = useMenuContext("Menu.SubmenuTrigger");
@@ -81,8 +83,7 @@ function MenuSubmenuTrigger({ disabled = false, label, className, style, childre
81
83
  if (event.pointerType !== "touch") hoverLeave(event.nativeEvent);
82
84
  }
83
85
  },
84
- activate: (event) => open(event.nativeEvent),
85
- opensOnly: true
86
+ activate: (event) => open(event.nativeEvent)
86
87
  });
87
88
  const ref = useMergedRefs(triggerRef, hoverRef);
88
89
  return useRender({
@@ -1 +1 @@
1
- {"version":3,"file":"menu-submenu-trigger.mjs","names":[],"sources":["../../src/menu/menu-submenu-trigger.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n KeyboardEvent,\n PointerEvent,\n ReactNode,\n} from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { usePopoverTrigger } from \"../internal/use-popover-trigger.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { registerSubmenuHover, useMenuContext } from \"./menu-context.js\";\nimport { hasModifier, isRtl } from \"./menu-dom.js\";\nimport { scheduleHoverClose } from \"./menu-hover.js\";\nimport type { MenuItemProps } from \"./menu-item.js\";\nimport { openMenuWithFocus } from \"./menu-trigger.js\";\nimport type { MenuTriggerState } from \"./menu-trigger.js\";\nimport { useMenuItem } from \"./use-menu-item.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport type MenuSubmenuTriggerState = MenuTriggerState;\n\nexport interface MenuSubmenuTriggerProps extends Omit<\n MenuItemProps,\n | \"action\"\n | \"closeOnActivate\"\n | \"aria-expanded\"\n | \"aria-haspopup\"\n | \"onPointerEnter\"\n | \"onPointerLeave\"\n | \"className\"\n | \"style\"\n | \"children\"\n | \"render\"\n> {\n className?: StateValue<string | undefined, MenuSubmenuTriggerState>;\n style?: StateValue<CSSProperties | undefined, MenuSubmenuTriggerState>;\n /** Rendered from optimistic state; must not suspend. */\n children?: StateValue<ReactNode, MenuSubmenuTriggerState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, MenuSubmenuTriggerState>;\n}\n\n/**\n * The item that opens a submenu: an item of the parent menu (`role=\"menuitem\"`, roving\n * `tabindex`, typeahead) and the Trigger of the submenu's Root (`commandfor`,\n * `command=\"toggle-popover\"`, `aria-haspopup=\"menu\"`, `aria-expanded`). ArrowRight (ArrowLeft in\n * RTL), Enter, Space or a click open the submenu with its first item focused; hovering it opens\n * the submenu after the Root's `delay` and leaves focus where it is.\n *\n * Owned keys (conventions 1.2): the Trigger's (`type`, `id`, `commandfor`, `command`,\n * `aria-haspopup`, `aria-expanded`, `data-open`, `data-pending`) and the item's (`role`,\n * `tabIndex`, `disabled` (absent), `aria-disabled`, `data-disabled`, `data-typeahead`,\n * `onClick`, `onKeyDown`, `onPointerMove`, `onPointerEnter`, `onPointerLeave`).\n */\nexport function MenuSubmenuTrigger({\n disabled = false,\n label,\n className,\n style,\n children,\n render,\n ...rest\n}: MenuSubmenuTriggerProps) {\n const menu = useMenuContext(\"Menu.SubmenuTrigger\");\n useDevWarning(\n !menu.submenu,\n isDev &&\n \"Menu.SubmenuTrigger: rendered in a top-level Menu.Root. Use Menu.Trigger, or put this Root \" +\n \"inside the parent's Menu.Popup.\",\n );\n\n const open = (event: Event) => openMenuWithFocus(menu, event, \"first\");\n\n // The item half: role, roving tabindex, aria-disabled, Enter / Space, pointer focus. Its\n // activation is the click, which the trigger half handles (`activate` below), so the item's own\n // `onClick` is not used.\n const item = useMenuItem({\n part: \"Menu.SubmenuTrigger\",\n role: \"menuitem\",\n disabled,\n label,\n });\n\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.defaultPrevented || hasModifier(event) || disabled) return;\n const parentPopup = event.currentTarget.closest('[role=\"menu\"]');\n const forward = parentPopup !== null && isRtl(parentPopup) ? \"ArrowLeft\" : \"ArrowRight\";\n if (event.key !== forward) return;\n event.preventDefault();\n open(event.nativeEvent);\n };\n\n // Hover intent (design/components/menu.md 7), shared by the pointer handlers and a\n // press-drag-release gesture of a context menu, whose captured pointer never enters this element\n // (context-menu.md 2.6).\n const hoverEnter = (native: Event) => {\n if (disabled) return;\n menu.timers.open(menu.delay, () => {\n menu.setOpenCause(\"none\");\n menu.popover.requestOpen(native, \"activate\");\n });\n };\n const hoverLeave = (native: Event) => {\n // Leaving before the open delay cancels it; leaving an open submenu's trigger starts the\n // close delay (cancelled by entering the submenu).\n if (menu.popover.intended()) scheduleHoverClose(menu, native);\n else menu.timers.cancel();\n };\n const submenuPopupRef = menu.popover.popupRef;\n const latestHover = useLatest({ enter: hoverEnter, leave: hoverLeave });\n const hoverRef = useCallback(\n (element: HTMLElement) =>\n registerSubmenuHover(element, {\n enter: (event) => latestHover.current.enter(event),\n leave: (event) => latestHover.current.leave(event),\n popup: () => submenuPopupRef.current,\n }),\n [latestHover, submenuPopupRef],\n );\n\n const {\n state,\n libraryProps,\n ref: triggerRef,\n } = usePopoverTrigger(menu.popover, {\n part: \"Menu.SubmenuTrigger\",\n disabled,\n render,\n disabledAs: \"aria\",\n // Item first (Enter / Space activation, pointer focus), then the submenu keys.\n handlers: {\n onKeyDown: (event) => {\n item.libraryProps.onKeyDown(event);\n onKeyDown(event);\n },\n onPointerMove: item.libraryProps.onPointerMove,\n onPointerEnter: (event: PointerEvent<HTMLButtonElement>) => {\n if (event.pointerType !== \"touch\") hoverEnter(event.nativeEvent);\n },\n onPointerLeave: (event: PointerEvent<HTMLButtonElement>) => {\n if (event.pointerType !== \"touch\") hoverLeave(event.nativeEvent);\n },\n },\n // A click opens (or moves focus into the open submenu); it never closes.\n activate: (event) => open(event.nativeEvent),\n opensOnly: true,\n });\n const ref = useMergedRefs(triggerRef, hoverRef);\n\n return useRender<ComponentPropsWithRef<\"button\">, MenuSubmenuTriggerState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n ...libraryProps,\n role: item.libraryProps.role,\n tabIndex: item.libraryProps.tabIndex,\n \"data-typeahead\": item.libraryProps[\"data-typeahead\"],\n id: menu.triggerId,\n \"aria-haspopup\": \"menu\",\n },\n ref,\n });\n}\n\nMenuSubmenuTrigger.displayName = \"MenuSubmenuTrigger\";\n"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;;AAoCvC,SAAgB,mBAAmB,EACjC,WAAW,OACX,OACA,WACA,OACA,UACA,QACA,GAAG,QACuB;CAC1B,MAAM,OAAO,eAAe,qBAAqB;CACjD,cACE,CAAC,KAAK,SACN,SACE,4HAEJ;CAEA,MAAM,QAAQ,UAAiB,kBAAkB,MAAM,OAAO,OAAO;CAKrE,MAAM,OAAO,YAAY;EACvB,MAAM;EACN,MAAM;EACN;EACA;CACF,CAAC;CAED,MAAM,aAAa,UAA4C;EAC7D,IAAI,MAAM,oBAAoB,YAAY,KAAK,KAAK,UAAU;EAC9D,MAAM,cAAc,MAAM,cAAc,QAAQ,iBAAe;EAC/D,MAAM,UAAU,gBAAgB,QAAQ,MAAM,WAAW,IAAI,cAAc;EAC3E,IAAI,MAAM,QAAQ,SAAS;EAC3B,MAAM,eAAe;EACrB,KAAK,MAAM,WAAW;CACxB;CAKA,MAAM,cAAc,WAAkB;EACpC,IAAI,UAAU;EACd,KAAK,OAAO,KAAK,KAAK,aAAa;GACjC,KAAK,aAAa,MAAM;GACxB,KAAK,QAAQ,YAAY,QAAQ,UAAU;EAC7C,CAAC;CACH;CACA,MAAM,cAAc,WAAkB;EAGpC,IAAI,KAAK,QAAQ,SAAS,GAAG,mBAAmB,MAAM,MAAM;OACvD,KAAK,OAAO,OAAO;CAC1B;CACA,MAAM,kBAAkB,KAAK,QAAQ;CACrC,MAAM,cAAc,UAAU;EAAE,OAAO;EAAY,OAAO;CAAW,CAAC;CACtE,MAAM,WAAW,aACd,YACC,qBAAqB,SAAS;EAC5B,QAAQ,UAAU,YAAY,QAAQ,MAAM,KAAK;EACjD,QAAQ,UAAU,YAAY,QAAQ,MAAM,KAAK;EACjD,aAAa,gBAAgB;CAC/B,CAAC,GACH,CAAC,aAAa,eAAe,CAC/B;CAEA,MAAM,EACJ,OACA,cACA,KAAK,eACH,kBAAkB,KAAK,SAAS;EAClC,MAAM;EACN;EACA;EACA,YAAY;EAEZ,UAAU;GACR,YAAY,UAAU;IACpB,KAAK,aAAa,UAAU,KAAK;IACjC,UAAU,KAAK;GACjB;GACA,eAAe,KAAK,aAAa;GACjC,iBAAiB,UAA2C;IAC1D,IAAI,MAAM,gBAAgB,SAAS,WAAW,MAAM,WAAW;GACjE;GACA,iBAAiB,UAA2C;IAC1D,IAAI,MAAM,gBAAgB,SAAS,WAAW,MAAM,WAAW;GACjE;EACF;EAEA,WAAW,UAAU,KAAK,MAAM,WAAW;EAC3C,WAAW;CACb,CAAC;CACD,MAAM,MAAM,cAAc,YAAY,QAAQ;CAE9C,OAAO,UAAoE;EACzE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,GAAG;GACH,MAAM,KAAK,aAAa;GACxB,UAAU,KAAK,aAAa;GAC5B,kBAAkB,KAAK,aAAa;GACpC,IAAI,KAAK;GACT,iBAAiB;EACnB;EACA;CACF,CAAC;AACH;AAEA,mBAAmB,cAAc"}
1
+ {"version":3,"file":"menu-submenu-trigger.mjs","names":[],"sources":["../../src/menu/menu-submenu-trigger.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n KeyboardEvent,\n PointerEvent,\n ReactNode,\n} from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { usePopoverTrigger } from \"../internal/use-popover-trigger.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { registerSubmenuHover, useMenuContext } from \"./menu-context.js\";\nimport { hasModifier, isRtl } from \"./menu-dom.js\";\nimport { scheduleHoverClose } from \"./menu-hover.js\";\nimport type { MenuItemProps } from \"./menu-item.js\";\nimport { openMenuWithFocus } from \"./menu-trigger.js\";\nimport type { MenuTriggerState } from \"./menu-trigger.js\";\nimport { useMenuItem } from \"./use-menu-item.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport type MenuSubmenuTriggerState = MenuTriggerState;\n\nexport interface MenuSubmenuTriggerProps extends Omit<\n MenuItemProps,\n | \"action\"\n | \"closeOnActivate\"\n | \"aria-expanded\"\n | \"aria-haspopup\"\n | \"commandfor\"\n | \"command\"\n | \"popoverTarget\"\n | \"popoverTargetAction\"\n | \"onPointerEnter\"\n | \"onPointerLeave\"\n | \"className\"\n | \"style\"\n | \"children\"\n | \"render\"\n> {\n className?: StateValue<string | undefined, MenuSubmenuTriggerState>;\n style?: StateValue<CSSProperties | undefined, MenuSubmenuTriggerState>;\n /** Rendered from optimistic state; must not suspend. */\n children?: StateValue<ReactNode, MenuSubmenuTriggerState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, MenuSubmenuTriggerState>;\n}\n\n/**\n * The item that opens a submenu: an item of the parent menu (`role=\"menuitem\"`, roving\n * `tabindex`, typeahead) and the Trigger of the submenu's Root (`popovertarget`,\n * `aria-haspopup=\"menu\"`; no `aria-expanded`: the browser exposes the submenu's state on its\n * invoker). ArrowRight (ArrowLeft in RTL), Enter, Space or a click open the submenu with its first\n * item focused; hovering it opens the submenu after the Root's `delay` and leaves focus where it\n * is.\n *\n * Owned keys (conventions 1.2): the Trigger's (`type`, `id`, `popoverTarget`, `aria-haspopup`,\n * `aria-expanded`, `data-open`, `data-pending`; `commandfor`, `command` and `popoverTargetAction`,\n * never written) and the item's (`role`, `tabIndex`, `disabled` (absent), `aria-disabled`,\n * `data-disabled`, `data-typeahead`, `onClick`, `onKeyDown`, `onPointerMove`, `onPointerEnter`,\n * `onPointerLeave`).\n */\nexport function MenuSubmenuTrigger({\n disabled = false,\n label,\n className,\n style,\n children,\n render,\n ...rest\n}: MenuSubmenuTriggerProps) {\n const menu = useMenuContext(\"Menu.SubmenuTrigger\");\n useDevWarning(\n !menu.submenu,\n isDev &&\n \"Menu.SubmenuTrigger: rendered in a top-level Menu.Root. Use Menu.Trigger, or put this Root \" +\n \"inside the parent's Menu.Popup.\",\n );\n\n const open = (event: Event) => openMenuWithFocus(menu, event, \"first\");\n\n // The item half: role, roving tabindex, aria-disabled, Enter / Space, pointer focus. Its\n // activation is the click, which the trigger half handles (`activate` below), so the item's own\n // `onClick` is not used.\n const item = useMenuItem({\n part: \"Menu.SubmenuTrigger\",\n role: \"menuitem\",\n disabled,\n label,\n });\n\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.defaultPrevented || hasModifier(event) || disabled) return;\n const parentPopup = event.currentTarget.closest('[role=\"menu\"]');\n const forward = parentPopup !== null && isRtl(parentPopup) ? \"ArrowLeft\" : \"ArrowRight\";\n if (event.key !== forward) return;\n event.preventDefault();\n open(event.nativeEvent);\n };\n\n // Hover intent (design/components/menu.md 7), shared by the pointer handlers and a\n // press-drag-release gesture of a context menu, whose captured pointer never enters this element\n // (context-menu.md 2.6).\n const hoverEnter = (native: Event) => {\n if (disabled) return;\n menu.timers.open(menu.delay, () => {\n menu.setOpenCause(\"none\");\n menu.popover.requestOpen(native, \"activate\");\n });\n };\n const hoverLeave = (native: Event) => {\n // Leaving before the open delay cancels it; leaving an open submenu's trigger starts the\n // close delay (cancelled by entering the submenu).\n if (menu.popover.intended()) scheduleHoverClose(menu, native);\n else menu.timers.cancel();\n };\n const submenuPopupRef = menu.popover.popupRef;\n const latestHover = useLatest({ enter: hoverEnter, leave: hoverLeave });\n const hoverRef = useCallback(\n (element: HTMLElement) =>\n registerSubmenuHover(element, {\n enter: (event) => latestHover.current.enter(event),\n leave: (event) => latestHover.current.leave(event),\n popup: () => submenuPopupRef.current,\n }),\n [latestHover, submenuPopupRef],\n );\n\n const {\n state,\n libraryProps,\n ref: triggerRef,\n } = usePopoverTrigger(menu.popover, {\n part: \"Menu.SubmenuTrigger\",\n disabled,\n render,\n disabledAs: \"aria\",\n // Item first (Enter / Space activation, pointer focus), then the submenu keys.\n handlers: {\n onKeyDown: (event) => {\n item.libraryProps.onKeyDown(event);\n onKeyDown(event);\n },\n onPointerMove: item.libraryProps.onPointerMove,\n onPointerEnter: (event: PointerEvent<HTMLButtonElement>) => {\n if (event.pointerType !== \"touch\") hoverEnter(event.nativeEvent);\n },\n onPointerLeave: (event: PointerEvent<HTMLButtonElement>) => {\n if (event.pointerType !== \"touch\") hoverLeave(event.nativeEvent);\n },\n },\n // A click opens (or moves focus into the open submenu); it never closes.\n activate: (event) => open(event.nativeEvent),\n });\n const ref = useMergedRefs(triggerRef, hoverRef);\n\n return useRender<ComponentPropsWithRef<\"button\">, MenuSubmenuTriggerState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n ...libraryProps,\n role: item.libraryProps.role,\n tabIndex: item.libraryProps.tabIndex,\n \"data-typeahead\": item.libraryProps[\"data-typeahead\"],\n id: menu.triggerId,\n \"aria-haspopup\": \"menu\",\n },\n ref,\n });\n}\n\nMenuSubmenuTrigger.displayName = \"MenuSubmenuTrigger\";\n"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;;;;AA0CvC,SAAgB,mBAAmB,EACjC,WAAW,OACX,OACA,WACA,OACA,UACA,QACA,GAAG,QACuB;CAC1B,MAAM,OAAO,eAAe,qBAAqB;CACjD,cACE,CAAC,KAAK,SACN,SACE,4HAEJ;CAEA,MAAM,QAAQ,UAAiB,kBAAkB,MAAM,OAAO,OAAO;CAKrE,MAAM,OAAO,YAAY;E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,WAAW,UAAU,KAAK,MAAM,WAAW;CAC7C,CAAC;CACD,MAAM,MAAM,cAAc,YAAY,QAAQ;CAE9C,OAAO,UAAoE;EACzE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,GAAG;GACH,MAAM,KAAK,aAAa;GACxB,UAAU,KAAK,aAAa;GAC5B,kBAAkB,KAAK,aAAa;GACpC,IAAI,KAAK;GACT,iBAAiB;EACnB;EACA;CACF,CAAC;AACH;AAEA,mBAAmB,cAAc"}
@@ -4,7 +4,7 @@ import "./menu-context.mjs";
4
4
  import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
5
5
  //#region src/menu/menu-trigger.d.ts
6
6
  export type MenuTriggerState = PopoverTriggerHookState;
7
- export interface MenuTriggerProps extends Omit<ComponentPropsWithRef<"button">, "onClick" | "onKeyDown" | "onMouseDown" | "aria-expanded" | "aria-haspopup" | "className" | "style" | "children"> {
7
+ export interface MenuTriggerProps extends Omit<ComponentPropsWithRef<"button">, "onClick" | "onKeyDown" | "onMouseDown" | "aria-expanded" | "aria-haspopup" | "commandfor" | "command" | "popoverTarget" | "popoverTargetAction" | "className" | "style" | "children"> {
8
8
  /**
9
9
  * The menu cannot be opened from this button. Native `disabled` on a `<button>`; with a link or
10
10
  * component `render`, `aria-disabled="true"` instead (the element stays focusable).
@@ -15,21 +15,24 @@ export interface MenuTriggerProps extends Omit<ComponentPropsWithRef<"button">,
15
15
  /** Rendered from optimistic state; must not suspend. */
16
16
  children?: StateValue<ReactNode, MenuTriggerState>;
17
17
  /**
18
- * Should render a `<button>` (the command path before hydration). Another element works through
19
- * the click handler, but a press on it while the menu is open is a light dismiss rather than the
20
- * awaited close.
18
+ * Should render a `<button>` (the `popovertarget` path before hydration). Another element works
19
+ * through the click handler, but a press on it while the menu is open is a light dismiss rather
20
+ * than the awaited close.
21
21
  */
22
22
  render?: RenderProp<ComponentPropsWithRef<"button">, MenuTriggerState>;
23
23
  }
24
24
  /**
25
- * The menu button: `<button type="button" commandfor command="toggle-popover"
26
- * aria-haspopup="menu" aria-expanded>`. A click (Enter, Space) toggles the menu through the
27
- * Root's transition; ArrowDown / ArrowUp open it with the first / last item focused (inside a
28
- * vertical `Toolbar.Root`: the inline-end arrow, with the first item focused).
25
+ * The menu button: `<button type="button" popovertarget aria-haspopup="menu">`, with no
26
+ * `aria-expanded` (the browser exposes the menu's state on its invoker; a link or other non-button
27
+ * element, or a disabled component `render`, renders it from the shown menu). A click (Enter,
28
+ * Space) toggles the menu through the Root's transition; ArrowDown / ArrowUp open it with the
29
+ * first / last item focused (inside a vertical `Toolbar.Root`: the inline-end arrow, with the
30
+ * first item focused).
29
31
  *
30
32
  * Owned keys (conventions 1.2): `type` (on a `<button>` only), `id`, `disabled`, `aria-disabled`
31
- * (link or component `render`), `commandfor`, `command`, `aria-haspopup`, `aria-expanded`,
32
- * `onClick`, `onKeyDown`, `onMouseDown`, `data-open`, `data-pending`, `data-disabled`.
33
+ * (link or component `render`), `popoverTarget`, `aria-haspopup`, `aria-expanded`, `onClick`,
34
+ * `onKeyDown`, `onMouseDown`, `data-open`, `data-pending`, `data-disabled`; `commandfor`,
35
+ * `command` and `popoverTargetAction` (never written; omitted from the props type).
33
36
  */
34
37
  export declare function MenuTrigger({ disabled, className, style, children, render, ...rest }: MenuTriggerProps): ReactNode;
35
38
  export declare namespace MenuTrigger {
@@ -1 +1 @@
1
- {"version":3,"file":"menu-trigger.d.mts","names":[],"sources":["../../src/menu/menu-trigger.tsx"],"mappings":";;;;;YAqBY,mBAAmB;iBAEd,yBAAyB,KACxC;;;;;EAcA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;;;;;EAMjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;wBAwCvC,cACd,UACA,WACA,OACA,UACA,WACG,QACF,mBAAgB;yBAPH"}
1
+ {"version":3,"file":"menu-trigger.d.mts","names":[],"sources":["../../src/menu/menu-trigger.tsx"],"mappings":";;;;;YAqBY,mBAAmB;iBAEd,yBAAyB,KACxC;;;;;EAkBA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;;;;;EAMjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;;;wBA2CvC,cACd,UACA,WACA,OACA,UACA,WACG,QACF,mBAAgB;yBAPH"}
@@ -30,14 +30,17 @@ function isPointerClick(event) {
30
30
  return event.type === "click" && event.detail > 0;
31
31
  }
32
32
  /**
33
- * The menu button: `<button type="button" commandfor command="toggle-popover"
34
- * aria-haspopup="menu" aria-expanded>`. A click (Enter, Space) toggles the menu through the
35
- * Root's transition; ArrowDown / ArrowUp open it with the first / last item focused (inside a
36
- * vertical `Toolbar.Root`: the inline-end arrow, with the first item focused).
33
+ * The menu button: `<button type="button" popovertarget aria-haspopup="menu">`, with no
34
+ * `aria-expanded` (the browser exposes the menu's state on its invoker; a link or other non-button
35
+ * element, or a disabled component `render`, renders it from the shown menu). A click (Enter,
36
+ * Space) toggles the menu through the Root's transition; ArrowDown / ArrowUp open it with the
37
+ * first / last item focused (inside a vertical `Toolbar.Root`: the inline-end arrow, with the
38
+ * first item focused).
37
39
  *
38
40
  * Owned keys (conventions 1.2): `type` (on a `<button>` only), `id`, `disabled`, `aria-disabled`
39
- * (link or component `render`), `commandfor`, `command`, `aria-haspopup`, `aria-expanded`,
40
- * `onClick`, `onKeyDown`, `onMouseDown`, `data-open`, `data-pending`, `data-disabled`.
41
+ * (link or component `render`), `popoverTarget`, `aria-haspopup`, `aria-expanded`, `onClick`,
42
+ * `onKeyDown`, `onMouseDown`, `data-open`, `data-pending`, `data-disabled`; `commandfor`,
43
+ * `command` and `popoverTargetAction` (never written; omitted from the props type).
41
44
  */
42
45
  function MenuTrigger({ disabled = false, className, style, children, render, ...rest }) {
43
46
  const menu = useMenuContext("Menu.Trigger");
@@ -67,14 +70,7 @@ function MenuTrigger({ disabled = false, className, style, children, render, ...
67
70
  if (event.button === 0 && menu.popover.intended()) event.preventDefault();
68
71
  }
69
72
  },
70
- activate: (event) => {
71
- const native = event.nativeEvent;
72
- if (menu.popover.intended()) menu.popover.requestClose(native, "activate");
73
- else {
74
- menu.setOpenCause("first", isPointerClick(native));
75
- menu.popover.requestOpen(native, "activate");
76
- }
77
- }
73
+ beforeOpen: (event) => menu.setOpenCause("first", isPointerClick(event.nativeEvent))
78
74
  });
79
75
  return useRender({
80
76
  defaultElement: "button",
@@ -1 +1 @@
1
- {"version":3,"file":"menu-trigger.mjs","names":[],"sources":["../../src/menu/menu-trigger.tsx"],"sourcesContent":["\"use client\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n KeyboardEvent,\n MouseEvent as ReactMouseEvent,\n ReactNode,\n} from \"react\";\nimport { isPopoverOpen } from \"../internal/popover-open.js\";\nimport { useToolbarContext } from \"../internal/toolbar-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { usePopoverTrigger } from \"../internal/use-popover-trigger.js\";\nimport type { PopoverTriggerHookState } from \"../internal/use-popover-trigger.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useMenuContext } from \"./menu-context.js\";\nimport type { MenuContextValue } from \"./menu-context.js\";\nimport { edgeItem, focusItem, hasModifier, isRtl } from \"./menu-dom.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport type MenuTriggerState = PopoverTriggerHookState;\n\nexport interface MenuTriggerProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n | \"onClick\"\n | \"onKeyDown\"\n | \"onMouseDown\"\n | \"aria-expanded\"\n | \"aria-haspopup\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * The menu cannot be opened from this button. Native `disabled` on a `<button>`; with a link or\n * component `render`, `aria-disabled=\"true\"` instead (the element stays focusable).\n */\n disabled?: boolean;\n className?: StateValue<string | undefined, MenuTriggerState>;\n style?: StateValue<CSSProperties | undefined, MenuTriggerState>;\n /** Rendered from optimistic state; must not suspend. */\n children?: StateValue<ReactNode, MenuTriggerState>;\n /**\n * Should render a `<button>` (the command path before hydration). Another element works through\n * the click handler, but a press on it while the menu is open is a light dismiss rather than the\n * awaited close.\n */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, MenuTriggerState>;\n}\n\n/**\n * Opens with the first (`\"first\"`) or last (`\"last\"`) item focused, or focuses that item when the\n * menu is already open (a pre-hydration open, design walkthrough 10). Shared with SubmenuTrigger.\n */\nexport function openMenuWithFocus(\n menu: MenuContextValue,\n event: Event,\n which: \"first\" | \"last\",\n): void {\n const { popover } = menu;\n if (popover.intended()) {\n const popup = popover.popupRef.current;\n if (popup !== null && isPopoverOpen(popup)) {\n const item = edgeItem(popup, which);\n if (item !== null) focusItem(item);\n }\n return;\n }\n menu.setOpenCause(which, isPointerClick(event));\n popover.requestOpen(event, \"activate\");\n}\n\n/** A click from a pointing device (`detail` counts clicks; keyboard and `click()` give 0). */\nfunction isPointerClick(event: Event): boolean {\n return event.type === \"click\" && (event as MouseEvent).detail > 0;\n}\n\n/**\n * The menu button: `<button type=\"button\" commandfor command=\"toggle-popover\"\n * aria-haspopup=\"menu\" aria-expanded>`. A click (Enter, Space) toggles the menu through the\n * Root's transition; ArrowDown / ArrowUp open it with the first / last item focused (inside a\n * vertical `Toolbar.Root`: the inline-end arrow, with the first item focused).\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `id`, `disabled`, `aria-disabled`\n * (link or component `render`), `commandfor`, `command`, `aria-haspopup`, `aria-expanded`,\n * `onClick`, `onKeyDown`, `onMouseDown`, `data-open`, `data-pending`, `data-disabled`.\n */\nexport function MenuTrigger({\n disabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: MenuTriggerProps) {\n const menu = useMenuContext(\"Menu.Trigger\");\n useDevWarning(\n menu.submenu,\n isDev &&\n \"Menu.Trigger: rendered in a submenu. Use Menu.SubmenuTrigger, which is also an item of the \" +\n \"parent menu.\",\n );\n\n // Inside a vertical Toolbar, ArrowDown / ArrowUp are the Toolbar's: the trigger opens on the\n // inline-end arrow instead, as a submenu trigger does (design/components/toggle-group.md 7.4).\n const toolbar = useToolbarContext();\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (disabled || hasModifier(event)) return;\n let which: \"first\" | \"last\";\n if (toolbar?.orientation === \"vertical\") {\n const openKey = isRtl(event.currentTarget) ? \"ArrowLeft\" : \"ArrowRight\";\n if (event.key !== openKey) return;\n which = \"first\";\n } else {\n if (event.key !== \"ArrowDown\" && event.key !== \"ArrowUp\") return;\n which = event.key === \"ArrowDown\" ? \"first\" : \"last\";\n }\n // No page scroll, and an enclosing Toolbar sees `defaultPrevented`; Enter and Space stay the\n // native click.\n event.preventDefault();\n openMenuWithFocus(menu, event.nativeEvent, which);\n };\n\n const { state, libraryProps, ref } = usePopoverTrigger(menu.popover, {\n part: \"Menu.Trigger\",\n disabled,\n render,\n handlers: {\n onKeyDown,\n onMouseDown: (event: ReactMouseEvent<HTMLButtonElement>) => {\n // A press on the Trigger of an open menu must not move focus out of the popup: the Popup's\n // focusout would hide the menu before the click's library-owned close (design 2.2, #110).\n if (event.button === 0 && menu.popover.intended()) event.preventDefault();\n },\n },\n activate: (event) => {\n const native = event.nativeEvent;\n if (menu.popover.intended()) {\n menu.popover.requestClose(native, \"activate\");\n } else {\n menu.setOpenCause(\"first\", isPointerClick(native));\n menu.popover.requestOpen(native, \"activate\");\n }\n },\n });\n\n return useRender<ComponentPropsWithRef<\"button\">, MenuTriggerState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n ...libraryProps,\n id: menu.triggerId,\n \"aria-haspopup\": \"menu\",\n },\n ref,\n });\n}\n\nMenuTrigger.displayName = \"MenuTrigger\";\n"],"mappings":";;;;;;;;;AAmBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;AAoCvC,SAAgB,kBACd,MACA,OACA,OACM;CACN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KAAK,aAAa,SAAS,eAAe,MAAM,CAAC;IACjD,KAAK,QAAQ,YAAY,QAAQ,UAAU;GAC7C;EACF;CACF,CAAC;CAED,OAAO,UAA6D;EAClE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,GAAG;GACH,IAAI,KAAK;GACT,iBAAiB;EACnB;EACA;CACF,CAAC;AACH;AAEA,YAAY,cAAc"}
1
+ {"version":3,"file":"menu-trigger.mjs","names":[],"sources":["../../src/menu/menu-trigger.tsx"],"sourcesContent":["\"use client\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n KeyboardEvent,\n MouseEvent as ReactMouseEvent,\n ReactNode,\n} from \"react\";\nimport { isPopoverOpen } from \"../internal/popover-open.js\";\nimport { useToolbarContext } from \"../internal/toolbar-context.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { usePopoverTrigger } from \"../internal/use-popover-trigger.js\";\nimport type { PopoverTriggerHookState } from \"../internal/use-popover-trigger.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useMenuContext } from \"./menu-context.js\";\nimport type { MenuContextValue } from \"./menu-context.js\";\nimport { edgeItem, focusItem, hasModifier, isRtl } from \"./menu-dom.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport type MenuTriggerState = PopoverTriggerHookState;\n\nexport interface MenuTriggerProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n | \"onClick\"\n | \"onKeyDown\"\n | \"onMouseDown\"\n | \"aria-expanded\"\n | \"aria-haspopup\"\n | \"commandfor\"\n | \"command\"\n | \"popoverTarget\"\n | \"popoverTargetAction\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * The menu cannot be opened from this button. Native `disabled` on a `<button>`; with a link or\n * component `render`, `aria-disabled=\"true\"` instead (the element stays focusable).\n */\n disabled?: boolean;\n className?: StateValue<string | undefined, MenuTriggerState>;\n style?: StateValue<CSSProperties | undefined, MenuTriggerState>;\n /** Rendered from optimistic state; must not suspend. */\n children?: StateValue<ReactNode, MenuTriggerState>;\n /**\n * Should render a `<button>` (the `popovertarget` path before hydration). Another element works\n * through the click handler, but a press on it while the menu is open is a light dismiss rather\n * than the awaited close.\n */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, MenuTriggerState>;\n}\n\n/**\n * Opens with the first (`\"first\"`) or last (`\"last\"`) item focused, or focuses that item when the\n * menu is already open (a pre-hydration open, design walkthrough 10). Shared with SubmenuTrigger.\n */\nexport function openMenuWithFocus(\n menu: MenuContextValue,\n event: Event,\n which: \"first\" | \"last\",\n): void {\n const { popover } = menu;\n if (popover.intended()) {\n const popup = popover.popupRef.current;\n if (popup !== null && isPopoverOpen(popup)) {\n const item = edgeItem(popup, which);\n if (item !== null) focusItem(item);\n }\n return;\n }\n menu.setOpenCause(which, isPointerClick(event));\n popover.requestOpen(event, \"activate\");\n}\n\n/** A click from a pointing device (`detail` counts clicks; keyboard and `click()` give 0). */\nfunction isPointerClick(event: Event): boolean {\n return event.type === \"click\" && (event as MouseEvent).detail > 0;\n}\n\n/**\n * The menu button: `<button type=\"button\" popovertarget aria-haspopup=\"menu\">`, with no\n * `aria-expanded` (the browser exposes the menu's state on its invoker; a link or other non-button\n * element, or a disabled component `render`, renders it from the shown menu). A click (Enter,\n * Space) toggles the menu through the Root's transition; ArrowDown / ArrowUp open it with the\n * first / last item focused (inside a vertical `Toolbar.Root`: the inline-end arrow, with the\n * first item focused).\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `id`, `disabled`, `aria-disabled`\n * (link or component `render`), `popoverTarget`, `aria-haspopup`, `aria-expanded`, `onClick`,\n * `onKeyDown`, `onMouseDown`, `data-open`, `data-pending`, `data-disabled`; `commandfor`,\n * `command` and `popoverTargetAction` (never written; omitted from the props type).\n */\nexport function MenuTrigger({\n disabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: MenuTriggerProps) {\n const menu = useMenuContext(\"Menu.Trigger\");\n useDevWarning(\n menu.submenu,\n isDev &&\n \"Menu.Trigger: rendered in a submenu. Use Menu.SubmenuTrigger, which is also an item of the \" +\n \"parent menu.\",\n );\n\n // Inside a vertical Toolbar, ArrowDown / ArrowUp are the Toolbar's: the trigger opens on the\n // inline-end arrow instead, as a submenu trigger does (design/components/toggle-group.md 7.4).\n const toolbar = useToolbarContext();\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (disabled || hasModifier(event)) return;\n let which: \"first\" | \"last\";\n if (toolbar?.orientation === \"vertical\") {\n const openKey = isRtl(event.currentTarget) ? \"ArrowLeft\" : \"ArrowRight\";\n if (event.key !== openKey) return;\n which = \"first\";\n } else {\n if (event.key !== \"ArrowDown\" && event.key !== \"ArrowUp\") return;\n which = event.key === \"ArrowDown\" ? \"first\" : \"last\";\n }\n // No page scroll, and an enclosing Toolbar sees `defaultPrevented`; Enter and Space stay the\n // native click.\n event.preventDefault();\n openMenuWithFocus(menu, event.nativeEvent, which);\n };\n\n const { state, libraryProps, ref } = usePopoverTrigger(menu.popover, {\n part: \"Menu.Trigger\",\n disabled,\n render,\n handlers: {\n onKeyDown,\n onMouseDown: (event: ReactMouseEvent<HTMLButtonElement>) => {\n // A press on the Trigger of an open menu must not move focus out of the popup: the Popup's\n // focusout would hide the menu before the click's library-owned close (design 2.2).\n if (event.button === 0 && menu.popover.intended()) event.preventDefault();\n },\n },\n beforeOpen: (event) => menu.setOpenCause(\"first\", isPointerClick(event.nativeEvent)),\n });\n\n return useRender<ComponentPropsWithRef<\"button\">, MenuTriggerState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n ...libraryProps,\n id: menu.triggerId,\n \"aria-haspopup\": \"menu\",\n },\n ref,\n });\n}\n\nMenuTrigger.displayName = \"MenuTrigger\";\n"],"mappings":";;;;;;;;;AAmBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;AAwCvC,SAAgB,kBACd,MACA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EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,GAAG;GACH,IAAI,KAAK;GACT,iBAAiB;EACnB;EACA;CACF,CAAC;AACH;AAEA,YAAY,cAAc"}
@@ -11,9 +11,9 @@ import { useControllableAction } from "../internal/use-controllable-action.mjs";
11
11
  import { FieldContext } from "../internal/field-context.mjs";
12
12
  import { resolveFieldDefaults, useFieldValueChange } from "../internal/use-field-control.mjs";
13
13
  import { useNativeGroupReconciliation } from "../internal/use-native-group-reconciliation.mjs";
14
+ import { announce } from "../internal/announce.mjs";
14
15
  import { keyStep, stepValue } from "./number-field-arithmetic.mjs";
15
16
  import { NumberFieldContext } from "./number-field-context.mjs";
16
- import { announce } from "../internal/announce.mjs";
17
17
  import { createNumberFormatter, formatKey } from "./number-field-format.mjs";
18
18
  import { useNumberFieldDevWarnings } from "./use-number-field-dev-warnings.mjs";
19
19
  import { addTransitionType, use, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
@@ -8,7 +8,7 @@ import { PopoverTrigger, PopoverTriggerProps, PopoverTriggerState } from "./popo
8
8
  //#region src/popover/index.d.ts
9
9
  /**
10
10
  * Popover built on `popover="auto"` and Invoker Commands: `Root` (no DOM) > `Trigger`
11
- * (`button[command=toggle-popover]`) + `Popup` (`dialog[popover=auto][aria-modal=false]`) >
11
+ * (`button[popovertarget]`) + `Popup` (`dialog[popover=auto][aria-modal=false]`) >
12
12
  * `Title`, `Description`, `Close`. The platform gives the top layer, light dismiss, Escape,
13
13
  * nesting, the implicit anchor and focus return. JS-free when the Root has none of `open` /
14
14
  * `defaultOpen` / `openChangeAction`; otherwise opening and the closes a part asks for are
@@ -7,7 +7,7 @@ import { PopoverTrigger } from "./popover-trigger.mjs";
7
7
  //#region src/popover/index.ts
8
8
  /**
9
9
  * Popover built on `popover="auto"` and Invoker Commands: `Root` (no DOM) > `Trigger`
10
- * (`button[command=toggle-popover]`) + `Popup` (`dialog[popover=auto][aria-modal=false]`) >
10
+ * (`button[popovertarget]`) + `Popup` (`dialog[popover=auto][aria-modal=false]`) >
11
11
  * `Title`, `Description`, `Close`. The platform gives the top layer, light dismiss, Escape,
12
12
  * nesting, the implicit anchor and focus return. JS-free when the Root has none of `open` /
13
13
  * `defaultOpen` / `openChangeAction`; otherwise opening and the closes a part asks for are
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/popover/index.ts"],"sourcesContent":["// Ships the platform attribute typings (`command`, `commandfor`) with this subpath\n// (conventions 7.4). Type-only: the built JS has no import of it.\nimport \"../internal/platform-attributes.js\";\nimport { PopoverClose } from \"./popover-close.js\";\nimport { PopoverDescription } from \"./popover-description.js\";\nimport { PopoverPopup } from \"./popover-popup.js\";\nimport { PopoverRoot } from \"./popover-root.js\";\nimport { PopoverTitle } from \"./popover-title.js\";\nimport { PopoverTrigger } from \"./popover-trigger.js\";\n\n/**\n * Popover built on `popover=\"auto\"` and Invoker Commands: `Root` (no DOM) > `Trigger`\n * (`button[command=toggle-popover]`) + `Popup` (`dialog[popover=auto][aria-modal=false]`) >\n * `Title`, `Description`, `Close`. The platform gives the top layer, light dismiss, Escape,\n * nesting, the implicit anchor and focus return. JS-free when the Root has none of `open` /\n * `defaultOpen` / `openChangeAction`; otherwise opening and the closes a part asks for are\n * transitions (pending Trigger, content from committed state), and dismissals are notified\n * through `openChangeAction(false)`.\n */\nexport const Popover = {\n Root: PopoverRoot,\n Trigger: PopoverTrigger,\n Popup: PopoverPopup,\n Close: PopoverClose,\n Title: PopoverTitle,\n Description: PopoverDescription,\n} as const;\n\nexport type {\n PopoverRootProps,\n PopoverRootState,\n PopoverOpenChangeDetails,\n} from \"./popover-root.js\";\nexport type { PopoverTriggerProps, PopoverTriggerState } from \"./popover-trigger.js\";\nexport type {\n PopoverPopupProps,\n PopoverPopupState,\n PopoverSide,\n PopoverAlign,\n} from \"./popover-popup.js\";\nexport type { PopoverCloseProps, PopoverCloseState } from \"./popover-close.js\";\nexport type { PopoverTitleProps, PopoverTitleState } from \"./popover-title.js\";\nexport type { PopoverDescriptionProps, PopoverDescriptionState } from \"./popover-description.js\";\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,MAAa,UAAU;CACrB,MAAM;CACN,SAAS;CACT,OAAO;CACP,OAAO;CACP,OAAO;CACP,aAAa;AACf"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/popover/index.ts"],"sourcesContent":["// Ships the platform attribute typings (`command`, `commandfor`) with this subpath\n// (conventions 7.4). Type-only: the built JS has no import of it.\nimport \"../internal/platform-attributes.js\";\nimport { PopoverClose } from \"./popover-close.js\";\nimport { PopoverDescription } from \"./popover-description.js\";\nimport { PopoverPopup } from \"./popover-popup.js\";\nimport { PopoverRoot } from \"./popover-root.js\";\nimport { PopoverTitle } from \"./popover-title.js\";\nimport { PopoverTrigger } from \"./popover-trigger.js\";\n\n/**\n * Popover built on `popover=\"auto\"` and Invoker Commands: `Root` (no DOM) > `Trigger`\n * (`button[popovertarget]`) + `Popup` (`dialog[popover=auto][aria-modal=false]`) >\n * `Title`, `Description`, `Close`. The platform gives the top layer, light dismiss, Escape,\n * nesting, the implicit anchor and focus return. JS-free when the Root has none of `open` /\n * `defaultOpen` / `openChangeAction`; otherwise opening and the closes a part asks for are\n * transitions (pending Trigger, content from committed state), and dismissals are notified\n * through `openChangeAction(false)`.\n */\nexport const Popover = {\n Root: PopoverRoot,\n Trigger: PopoverTrigger,\n Popup: PopoverPopup,\n Close: PopoverClose,\n Title: PopoverTitle,\n Description: PopoverDescription,\n} as const;\n\nexport type {\n PopoverRootProps,\n PopoverRootState,\n PopoverOpenChangeDetails,\n} from \"./popover-root.js\";\nexport type { PopoverTriggerProps, PopoverTriggerState } from \"./popover-trigger.js\";\nexport type {\n PopoverPopupProps,\n PopoverPopupState,\n PopoverSide,\n PopoverAlign,\n} from \"./popover-popup.js\";\nexport type { PopoverCloseProps, PopoverCloseState } from \"./popover-close.js\";\nexport type { PopoverTitleProps, PopoverTitleState } from \"./popover-title.js\";\nexport type { PopoverDescriptionProps, PopoverDescriptionState } from \"./popover-description.js\";\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,MAAa,UAAU;CACrB,MAAM;CACN,SAAS;CACT,OAAO;CACP,OAAO;CACP,OAAO;CACP,aAAa;AACf"}