@fluentui/react-menu 9.21.2 → 9.23.0
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.
- package/CHANGELOG.md +23 -2
- package/dist/index.d.ts +22 -3
- package/lib/components/Menu/Menu.types.js.map +1 -1
- package/lib/components/Menu/MenuSurfaceMotion.js +40 -0
- package/lib/components/Menu/MenuSurfaceMotion.js.map +1 -0
- package/lib/components/Menu/renderMenu.js +15 -3
- package/lib/components/Menu/renderMenu.js.map +1 -1
- package/lib/components/Menu/useMenu.js +33 -5
- package/lib/components/Menu/useMenu.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopover.js +2 -1
- package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopoverStyles.styles.js +2 -25
- package/lib/components/MenuPopover/useMenuPopoverStyles.styles.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopoverStyles.styles.raw.js +1 -3
- package/lib/components/MenuPopover/useMenuPopoverStyles.styles.raw.js.map +1 -1
- package/lib/components/MenuTrigger/useMenuTrigger.js +7 -2
- package/lib/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib/contexts/menuListContext.js.map +1 -1
- package/lib-commonjs/components/Menu/Menu.types.js.map +1 -1
- package/lib-commonjs/components/Menu/MenuSurfaceMotion.js +42 -0
- package/lib-commonjs/components/Menu/MenuSurfaceMotion.js.map +1 -0
- package/lib-commonjs/components/Menu/renderMenu.js +15 -3
- package/lib-commonjs/components/Menu/renderMenu.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenu.js +30 -4
- package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js +2 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.styles.js +2 -50
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.styles.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.styles.raw.js +1 -3
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js +7 -2
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib-commonjs/contexts/menuListContext.js.map +1 -1
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-menu
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 17 Mar 2026 07:56:46 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.23.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-menu_v9.23.0)
|
|
8
|
+
|
|
9
|
+
Tue, 17 Mar 2026 07:56:46 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-menu_v9.22.0..@fluentui/react-menu_v9.23.0)
|
|
11
|
+
|
|
12
|
+
### Minor changes
|
|
13
|
+
|
|
14
|
+
- feat: add shouldOpenOnArrowRight to MenuListContextValue to allow grid containers to opt out of ArrowRight opening submenus ([PR #35871](https://github.com/microsoft/fluentui/pull/35871) by bsunderhus@microsoft.com)
|
|
15
|
+
|
|
16
|
+
## [9.22.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-menu_v9.22.0)
|
|
17
|
+
|
|
18
|
+
Tue, 03 Mar 2026 09:43:40 GMT
|
|
19
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-menu_v9.21.2..@fluentui/react-menu_v9.22.0)
|
|
20
|
+
|
|
21
|
+
### Minor changes
|
|
22
|
+
|
|
23
|
+
- refactor: migrate slide animation from CSS to motion components with surfaceMotion slot ([PR #35763](https://github.com/microsoft/fluentui/pull/35763) by robertpenner@microsoft.com)
|
|
24
|
+
- Bump @fluentui/react-motion to v9.13.0 ([commit](https://github.com/microsoft/fluentui/commit/81e1556b008bfbd07fe427d89af6142459d74c6f) by beachball)
|
|
25
|
+
- Bump @fluentui/react-motion-components-preview to v0.15.2 ([commit](https://github.com/microsoft/fluentui/commit/81e1556b008bfbd07fe427d89af6142459d74c6f) by beachball)
|
|
26
|
+
- Bump @fluentui/react-positioning to v9.22.0 ([commit](https://github.com/microsoft/fluentui/commit/81e1556b008bfbd07fe427d89af6142459d74c6f) by beachball)
|
|
27
|
+
|
|
7
28
|
## [9.21.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-menu_v9.21.2)
|
|
8
29
|
|
|
9
|
-
Wed, 25 Feb 2026 13:28
|
|
30
|
+
Wed, 25 Feb 2026 13:32:28 GMT
|
|
10
31
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-menu_v9.21.1..@fluentui/react-menu_v9.21.2)
|
|
11
32
|
|
|
12
33
|
### Patches
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { JSXElement } from '@fluentui/react-utilities';
|
|
|
9
9
|
import type { PortalProps } from '@fluentui/react-portal';
|
|
10
10
|
import type { PositioningShorthand } from '@fluentui/react-positioning';
|
|
11
11
|
import { PositioningVirtualElement } from '@fluentui/react-positioning';
|
|
12
|
+
import type { PresenceMotionSlotProps } from '@fluentui/react-motion';
|
|
12
13
|
import * as React_2 from 'react';
|
|
13
14
|
import { SetVirtualMouseTarget } from '@fluentui/react-positioning';
|
|
14
15
|
import type { Slot } from '@fluentui/react-utilities';
|
|
@@ -23,6 +24,10 @@ import type { UseOnClickOrScrollOutsideOptions } from '@fluentui/react-utilities
|
|
|
23
24
|
*/
|
|
24
25
|
export declare const dispatchMenuEnterEvent: (el: HTMLElement, nativeEvent: MouseEvent) => void;
|
|
25
26
|
|
|
27
|
+
declare type InternalMenuSlots = {
|
|
28
|
+
surfaceMotion: NonNullable<Slot<PresenceMotionSlotProps>>;
|
|
29
|
+
};
|
|
30
|
+
|
|
26
31
|
/**
|
|
27
32
|
* Wrapper component that manages state for a popup MenuList and a MenuTrigger
|
|
28
33
|
*/
|
|
@@ -302,6 +307,14 @@ export declare type MenuListContextValue = Pick<MenuListProps, 'checkedValues' |
|
|
|
302
307
|
* the signature remains just to avoid breaking changes
|
|
303
308
|
*/
|
|
304
309
|
onCheckedValueChange?: (e: MenuCheckedValueChangeEvent, data: MenuCheckedValueChangeData) => void;
|
|
310
|
+
/**
|
|
311
|
+
* Whether child menus (submenus) should open when the user presses the ArrowRight key on their trigger.
|
|
312
|
+
* Set to `false` when the list context is provided by a grid-like container (e.g. MenuGrid) where
|
|
313
|
+
* ArrowRight is reserved for column navigation.
|
|
314
|
+
*
|
|
315
|
+
* @default true
|
|
316
|
+
*/
|
|
317
|
+
shouldOpenOnArrowRight?: boolean;
|
|
305
318
|
};
|
|
306
319
|
|
|
307
320
|
export declare type MenuListContextValues = {
|
|
@@ -456,7 +469,7 @@ export declare type MenuPopoverState = ComponentState<MenuPopoverSlots> & Pick<P
|
|
|
456
469
|
/**
|
|
457
470
|
* Extends and drills down Menulist props to simplify API
|
|
458
471
|
*/
|
|
459
|
-
export declare type MenuProps = ComponentProps<MenuSlots
|
|
472
|
+
export declare type MenuProps = ComponentProps<Partial<MenuSlots>> & Pick<PortalProps, 'mountNode'> & Pick<MenuListProps, 'checkedValues' | 'defaultCheckedValues' | 'hasCheckmarks' | 'hasIcons' | 'onCheckedValueChange'> & {
|
|
460
473
|
/**
|
|
461
474
|
* Can contain two children including `MenuTrigger` and `MenuPopover`.
|
|
462
475
|
* Alternatively can only contain `MenuPopover` if using a custom `target`.
|
|
@@ -522,7 +535,13 @@ export declare type MenuProps = ComponentProps<MenuSlots> & Pick<PortalProps, 'm
|
|
|
522
535
|
|
|
523
536
|
export declare const MenuProvider: React_2.Provider<MenuContextValue> & React_2.FC<React_2.ProviderProps<MenuContextValue>>;
|
|
524
537
|
|
|
525
|
-
export declare type MenuSlots = {
|
|
538
|
+
export declare type MenuSlots = {
|
|
539
|
+
/**
|
|
540
|
+
* Slot for the surface motion animation.
|
|
541
|
+
* For more information refer to the [Motion docs page](https://react.fluentui.dev/?path=/docs/motion-motion-slot--docs).
|
|
542
|
+
*/
|
|
543
|
+
surfaceMotion: Slot<PresenceMotionSlotProps>;
|
|
544
|
+
};
|
|
526
545
|
|
|
527
546
|
/**
|
|
528
547
|
* Layout wrapper that provides extra keyboard navigation behavior for two `MenuItem` components.
|
|
@@ -553,7 +572,7 @@ export declare type MenuSplitGroupSlots = {
|
|
|
553
572
|
*/
|
|
554
573
|
export declare type MenuSplitGroupState = ComponentState<MenuSplitGroupSlots> & Pick<MenuSplitGroupContextValue, 'setMultiline'>;
|
|
555
574
|
|
|
556
|
-
export declare type MenuState = ComponentState<
|
|
575
|
+
export declare type MenuState = ComponentState<InternalMenuSlots> & Required<Pick<MenuProps, 'hasCheckmarks' | 'hasIcons' | 'mountNode' | 'inline' | 'checkedValues' | 'onCheckedValueChange' | 'open' | 'openOnHover' | 'closeOnScroll' | 'hoverDelay' | 'openOnContext' | 'persistOnItemClick'>> & {
|
|
557
576
|
/**
|
|
558
577
|
* Anchors the popper to the mouse click for context events
|
|
559
578
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Menu/Menu.types.ts"],"sourcesContent":["import * as React from 'react';\nimport { PositioningVirtualElement, SetVirtualMouseTarget } from '@fluentui/react-positioning';\nimport type { PositioningShorthand } from '@fluentui/react-positioning';\nimport type { PortalProps } from '@fluentui/react-portal';\nimport type { ComponentProps, ComponentState, JSXElement } from '@fluentui/react-utilities';\nimport type { MenuContextValue } from '../../contexts/menuContext';\nimport type { MenuListProps } from '../MenuList/MenuList.types';\n\nexport type MenuSlots = {};\n\n/**\n * Extends and drills down Menulist props to simplify API\n */\nexport type MenuProps = ComponentProps<MenuSlots
|
|
1
|
+
{"version":3,"sources":["../src/components/Menu/Menu.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { PresenceMotionSlotProps } from '@fluentui/react-motion';\nimport { PositioningVirtualElement, SetVirtualMouseTarget } from '@fluentui/react-positioning';\nimport type { PositioningShorthand } from '@fluentui/react-positioning';\nimport type { PortalProps } from '@fluentui/react-portal';\nimport type { ComponentProps, ComponentState, JSXElement, Slot } from '@fluentui/react-utilities';\nimport type { MenuContextValue } from '../../contexts/menuContext';\nimport type { MenuListProps } from '../MenuList/MenuList.types';\n\nexport type MenuSlots = {\n /**\n * Slot for the surface motion animation.\n * For more information refer to the [Motion docs page](https://react.fluentui.dev/?path=/docs/motion-motion-slot--docs).\n */\n surfaceMotion: Slot<PresenceMotionSlotProps>;\n};\n\nexport type InternalMenuSlots = {\n surfaceMotion: NonNullable<Slot<PresenceMotionSlotProps>>;\n};\n\n/**\n * Extends and drills down Menulist props to simplify API\n */\nexport type MenuProps = ComponentProps<Partial<MenuSlots>> &\n Pick<PortalProps, 'mountNode'> &\n Pick<\n MenuListProps,\n 'checkedValues' | 'defaultCheckedValues' | 'hasCheckmarks' | 'hasIcons' | 'onCheckedValueChange'\n > & {\n /**\n * Can contain two children including `MenuTrigger` and `MenuPopover`.\n * Alternatively can only contain `MenuPopover` if using a custom `target`.\n */\n children: [JSXElement, JSXElement] | JSXElement;\n\n /**\n * Sets the delay for mouse open/close for the popover one mouse enter/leave\n */\n hoverDelay?: number;\n\n /**\n * Root menus are rendered out of DOM order on `document.body`, use this to render the menu in DOM order\n * This option is disregarded for submenus\n *\n * @default false\n */\n inline?: boolean;\n\n /**\n * Call back when the component requests to change value\n * The `open` value is used as a hint when directly controlling the component\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onOpenChange?: (e: MenuOpenEvent, data: MenuOpenChangeData) => void;\n\n /**\n * Whether the popup is open\n *\n * @default false\n */\n open?: boolean;\n\n /**\n * Whether the popup is open by default\n *\n * @default false\n */\n defaultOpen?: boolean;\n\n /**\n * Opens the menu on right click (context menu), removes all other menu open interactions\n *\n * @default false\n */\n openOnContext?: boolean;\n\n /**\n * Opens the menu on hover\n *\n * @default false\n */\n openOnHover?: boolean;\n\n /**\n * Do not dismiss the menu when a menu item is clicked\n *\n * @default false\n */\n persistOnItemClick?: boolean;\n\n /**\n * Configures the positioned menu\n */\n positioning?: PositioningShorthand;\n\n /**\n * Close when scroll outside of it\n *\n * @default false\n */\n closeOnScroll?: boolean;\n };\n\nexport type MenuState = ComponentState<InternalMenuSlots> &\n Required<\n Pick<\n MenuProps,\n | 'hasCheckmarks'\n | 'hasIcons'\n | 'mountNode'\n | 'inline'\n | 'checkedValues'\n | 'onCheckedValueChange'\n | 'open'\n | 'openOnHover'\n | 'closeOnScroll'\n | 'hoverDelay'\n | 'openOnContext'\n | 'persistOnItemClick'\n >\n > & {\n /**\n * Anchors the popper to the mouse click for context events\n */\n contextTarget?: PositioningVirtualElement;\n\n /**\n * Whether this menu is a submenu\n */\n isSubmenu: boolean;\n\n /**\n * Internal react node that just simplifies handling children\n */\n menuPopover: React.ReactNode;\n\n /**\n * The ref for the popup\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n menuPopoverRef: React.MutableRefObject<HTMLElement | null>;\n\n /**\n * Internal react node that just simplifies handling children\n */\n menuTrigger: React.ReactNode;\n\n /**\n * A callback to set the target of the popper to the mouse click for context events\n */\n setContextTarget: SetVirtualMouseTarget;\n\n /**\n * Callback to open/close the popup\n */\n setOpen: (e: MenuOpenEvent, data: MenuOpenChangeData & { ignoreHoverDelay?: boolean }) => void;\n\n /**\n * Id for the MenuTrigger element for aria relationship\n */\n triggerId: string;\n\n /**\n * The ref for the MenuTrigger, used for popup positioning\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n\n /**\n * Call back when the component requests to change value\n * The `open` value is used as a hint when directly controlling the component\n * @deprecated this property is not used internally anymore,\n * the signature remains just to avoid breaking changes\n */\n onOpenChange?: (e: MenuOpenEvent, data: MenuOpenChangeData) => void;\n /**\n * Default values to be checked on mount\n @deprecated this property is not used internally anymore,\n * the signature remains just to avoid breaking changes\n */\n defaultCheckedValues?: Record<string, string[]>;\n\n /**\n * An optional safe zone area to be rendered around the menu\n */\n safeZone?: React.ReactElement | null;\n };\n\nexport type MenuContextValues = {\n menu: MenuContextValue;\n};\n\n/**\n * The supported events that will trigger open/close of the menu\n */\nexport type MenuOpenEvent = MenuOpenChangeData['event'];\n/**\n * @deprecated use MenuOpenEvent instead\n */\nexport type MenuOpenEvents = MenuOpenEvent;\n\n/**\n * Data attached to open/close events\n */\nexport type MenuOpenChangeData = {\n /**\n * indicates whether the request for the open state was bubbled from a nested menu\n */\n bubble?: boolean;\n /**\n * Indicates whether the change of state was a keyboard interaction\n * @deprecated\n * This should not be used, since `Enter`, `Space` and click should be interpreted as the same thing as a click\n */\n keyboard?: boolean;\n open: boolean;\n} & (\n | {\n type: 'menuTriggerContextMenu';\n event: React.MouseEvent<HTMLElement>;\n }\n | {\n type: 'menuTriggerClick';\n event: React.MouseEvent<HTMLElement>;\n }\n | {\n type: 'menuTriggerMouseEnter';\n event: React.MouseEvent<HTMLElement>;\n }\n | {\n type: 'menuSafeZoneMouseEnter';\n event: React.MouseEvent;\n }\n | {\n type: 'menuSafeZoneTimeout';\n event: Event;\n }\n | {\n type: 'menuTriggerMouseLeave';\n event: React.MouseEvent<HTMLElement>;\n }\n | {\n type: 'menuTriggerMouseMove';\n event: React.MouseEvent<HTMLElement>;\n }\n | {\n type: 'menuTriggerKeyDown';\n event: React.KeyboardEvent<HTMLElement>;\n }\n | {\n type: 'menuItemClick';\n event: React.MouseEvent<HTMLElement>;\n }\n | {\n type: 'menuPopoverMouseEnter';\n event: React.MouseEvent<HTMLElement>;\n }\n | {\n type: 'menuPopoverKeyDown';\n event: React.KeyboardEvent<HTMLElement>;\n }\n | {\n type: 'clickOutside';\n event: MouseEvent | TouchEvent;\n }\n | {\n type: 'scrollOutside';\n event: MouseEvent | TouchEvent;\n }\n | {\n type: 'menuMouseEnter';\n event: MouseEvent | TouchEvent;\n }\n);\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createPresenceComponent, motionTokens } from '@fluentui/react-motion';
|
|
2
|
+
import { fadeAtom, slideAtom } from '@fluentui/react-motion-components-preview';
|
|
3
|
+
import { POSITIONING_SLIDE_DIRECTION_VAR_X as slideDirectionVarX, POSITIONING_SLIDE_DIRECTION_VAR_Y as slideDirectionVarY } from '@fluentui/react-positioning';
|
|
4
|
+
// Shared timing constants for the enter animation.
|
|
5
|
+
const duration = motionTokens.durationSlower;
|
|
6
|
+
const easing = motionTokens.curveDecelerateMid;
|
|
7
|
+
/**
|
|
8
|
+
* Default `surfaceMotion` slot for `<Menu>`.
|
|
9
|
+
*
|
|
10
|
+
* Enter-only animation combining a fade and a direction-aware slide.
|
|
11
|
+
* The slide reads CSS variables set by `usePositioningSlideDirection` and scales
|
|
12
|
+
* them by `distance` pixels. There is no exit animation; the surface unmounts immediately.
|
|
13
|
+
*
|
|
14
|
+
* @param distance - Travel distance (px) for the enter slide. Defaults to `10`.
|
|
15
|
+
*/ export const MenuSurfaceMotion = createPresenceComponent(({ distance = 10 })=>({
|
|
16
|
+
enter: [
|
|
17
|
+
fadeAtom({
|
|
18
|
+
duration,
|
|
19
|
+
easing,
|
|
20
|
+
direction: 'enter'
|
|
21
|
+
}),
|
|
22
|
+
{
|
|
23
|
+
// slideAtom produces translate keyframes from `outX`/`outY` → `0px`.
|
|
24
|
+
// The `outX`/`outY` values read the positioning-provided CSS variables and scale
|
|
25
|
+
// them by `distance` so the surface slides in from the correct direction.
|
|
26
|
+
...slideAtom({
|
|
27
|
+
duration,
|
|
28
|
+
easing,
|
|
29
|
+
direction: 'enter',
|
|
30
|
+
outX: `calc(var(${slideDirectionVarX}, 0px) * ${distance})`,
|
|
31
|
+
outY: `calc(var(${slideDirectionVarY}, 0px) * ${distance})`
|
|
32
|
+
}),
|
|
33
|
+
// 'accumulate' compositing adds this effect's transform on top of the element's
|
|
34
|
+
// existing transform, preserving any transform applied by the positioning engine.
|
|
35
|
+
composite: 'accumulate'
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
// No exit animation — the surface unmounts immediately on close.
|
|
39
|
+
exit: []
|
|
40
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Menu/MenuSurfaceMotion.ts"],"sourcesContent":["import { createPresenceComponent, motionTokens } from '@fluentui/react-motion';\nimport { fadeAtom, slideAtom } from '@fluentui/react-motion-components-preview';\nimport {\n POSITIONING_SLIDE_DIRECTION_VAR_X as slideDirectionVarX,\n POSITIONING_SLIDE_DIRECTION_VAR_Y as slideDirectionVarY,\n} from '@fluentui/react-positioning';\n\n// Shared timing constants for the enter animation.\nconst duration = motionTokens.durationSlower;\nconst easing = motionTokens.curveDecelerateMid;\n\n/**\n * Default `surfaceMotion` slot for `<Menu>`.\n *\n * Enter-only animation combining a fade and a direction-aware slide.\n * The slide reads CSS variables set by `usePositioningSlideDirection` and scales\n * them by `distance` pixels. There is no exit animation; the surface unmounts immediately.\n *\n * @param distance - Travel distance (px) for the enter slide. Defaults to `10`.\n */\nexport const MenuSurfaceMotion = createPresenceComponent(({ distance = 10 }: { distance?: number }) => ({\n enter: [\n fadeAtom({ duration, easing, direction: 'enter' }),\n {\n // slideAtom produces translate keyframes from `outX`/`outY` → `0px`.\n // The `outX`/`outY` values read the positioning-provided CSS variables and scale\n // them by `distance` so the surface slides in from the correct direction.\n ...slideAtom({\n duration,\n easing,\n direction: 'enter',\n outX: `calc(var(${slideDirectionVarX}, 0px) * ${distance})`,\n outY: `calc(var(${slideDirectionVarY}, 0px) * ${distance})`,\n }),\n // 'accumulate' compositing adds this effect's transform on top of the element's\n // existing transform, preserving any transform applied by the positioning engine.\n composite: 'accumulate',\n },\n ],\n // No exit animation — the surface unmounts immediately on close.\n exit: [],\n}));\n"],"names":["createPresenceComponent","motionTokens","fadeAtom","slideAtom","POSITIONING_SLIDE_DIRECTION_VAR_X","slideDirectionVarX","POSITIONING_SLIDE_DIRECTION_VAR_Y","slideDirectionVarY","duration","durationSlower","easing","curveDecelerateMid","MenuSurfaceMotion","distance","enter","direction","outX","outY","composite","exit"],"mappings":"AAAA,SAASA,uBAAuB,EAAEC,YAAY,QAAQ,yBAAyB;AAC/E,SAASC,QAAQ,EAAEC,SAAS,QAAQ,4CAA4C;AAChF,SACEC,qCAAqCC,kBAAkB,EACvDC,qCAAqCC,kBAAkB,QAClD,8BAA8B;AAErC,mDAAmD;AACnD,MAAMC,WAAWP,aAAaQ,cAAc;AAC5C,MAAMC,SAAST,aAAaU,kBAAkB;AAE9C;;;;;;;;CAQC,GACD,OAAO,MAAMC,oBAAoBZ,wBAAwB,CAAC,EAAEa,WAAW,EAAE,EAAyB,GAAM,CAAA;QACtGC,OAAO;YACLZ,SAAS;gBAAEM;gBAAUE;gBAAQK,WAAW;YAAQ;YAChD;gBACE,qEAAqE;gBACrE,iFAAiF;gBACjF,0EAA0E;gBAC1E,GAAGZ,UAAU;oBACXK;oBACAE;oBACAK,WAAW;oBACXC,MAAM,CAAC,SAAS,EAAEX,mBAAmB,SAAS,EAAEQ,SAAS,CAAC,CAAC;oBAC3DI,MAAM,CAAC,SAAS,EAAEV,mBAAmB,SAAS,EAAEM,SAAS,CAAC,CAAC;gBAC7D,EAAE;gBACF,gFAAgF;gBAChF,kFAAkF;gBAClFK,WAAW;YACb;SACD;QACD,iEAAiE;QACjEC,MAAM,EAAE;IACV,CAAA,GAAI"}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
1
2
|
import * as React from 'react';
|
|
3
|
+
import { MotionRefForwarder } from '@fluentui/react-motion';
|
|
4
|
+
import { assertSlots } from '@fluentui/react-utilities';
|
|
2
5
|
import { MenuProvider } from '../../contexts/menuContext';
|
|
3
6
|
/**
|
|
4
7
|
* Render the final JSX of Menu
|
|
5
8
|
*/ export const renderMenu_unstable = (state, contextValues)=>{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
assertSlots(state);
|
|
10
|
+
return /*#__PURE__*/ _jsxs(MenuProvider, {
|
|
11
|
+
value: contextValues.menu,
|
|
12
|
+
children: [
|
|
13
|
+
state.menuTrigger,
|
|
14
|
+
state.menuPopover && /*#__PURE__*/ _jsx(state.surfaceMotion, {
|
|
15
|
+
children: /*#__PURE__*/ _jsx(MotionRefForwarder, {
|
|
16
|
+
children: state.menuPopover
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
]
|
|
20
|
+
});
|
|
9
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Menu/renderMenu.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/components/Menu/renderMenu.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport * as React from 'react';\nimport { MotionRefForwarder } from '@fluentui/react-motion';\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { MenuProvider } from '../../contexts/menuContext';\nimport type { InternalMenuSlots, MenuContextValues, MenuState } from './Menu.types';\n\n/**\n * Render the final JSX of Menu\n */\nexport const renderMenu_unstable = (state: MenuState, contextValues: MenuContextValues): JSXElement => {\n assertSlots<InternalMenuSlots>(state);\n\n return (\n <MenuProvider value={contextValues.menu}>\n {state.menuTrigger}\n {state.menuPopover && (\n <state.surfaceMotion>\n <MotionRefForwarder>\n {/* Casting here as content should be equivalent to <MenuPopover /> */}\n {/* FIXME: content should not be ReactNode it should be ReactElement instead. */}\n {state.menuPopover as React.ReactElement}\n </MotionRefForwarder>\n </state.surfaceMotion>\n )}\n </MenuProvider>\n );\n};\n"],"names":["React","MotionRefForwarder","assertSlots","MenuProvider","renderMenu_unstable","state","contextValues","value","menu","menuTrigger","menuPopover","surfaceMotion"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,YAAYA,WAAW,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,WAAW,QAAQ,4BAA4B;AAExD,SAASC,YAAY,QAAQ,6BAA6B;AAG1D;;CAEC,GACD,OAAO,MAAMC,sBAAsB,CAACC,OAAkBC;IACpDJ,YAA+BG;IAE/B,qBACE,MAACF;QAAaI,OAAOD,cAAcE,IAAI;;YACpCH,MAAMI,WAAW;YACjBJ,MAAMK,WAAW,kBAChB,KAACL,MAAMM,aAAa;0BAClB,cAAA,KAACV;8BAGEI,MAAMK,WAAW;;;;;AAM9B,EAAE"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { resolvePositioningShorthand, usePositioningMouseTarget, usePositioning, useSafeZoneArea } from '@fluentui/react-positioning';
|
|
3
|
+
import { resolvePositioningShorthand, usePositioningMouseTarget, usePositioning, useSafeZoneArea, usePositioningSlideDirection } from '@fluentui/react-positioning';
|
|
4
|
+
import { presenceMotionSlot } from '@fluentui/react-motion';
|
|
4
5
|
import { useControllableState, useId, useOnClickOutside, useEventCallback, useOnScrollOutside, elementContains, useTimeout, useFirstMount, useMergedRefs } from '@fluentui/react-utilities';
|
|
5
6
|
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
|
6
7
|
import { useFocusFinders } from '@fluentui/react-tabster';
|
|
7
8
|
import { useMenuContext_unstable } from '../../contexts/menuContext';
|
|
8
9
|
import { MENU_SAFEZONE_TIMEOUT_EVENT, MENU_ENTER_EVENT, useOnMenuMouseEnter, useIsSubmenu } from '../../utils';
|
|
9
10
|
import { menuItemClassNames } from '../MenuItem/useMenuItemStyles.styles';
|
|
11
|
+
import { MenuSurfaceMotion } from './MenuSurfaceMotion';
|
|
10
12
|
// If it's not possible to position the submenu in smaller viewports, try
|
|
11
13
|
// and fallback to this order of positions
|
|
12
14
|
const submenuFallbackPositions = [
|
|
@@ -30,12 +32,18 @@ const submenuFallbackPositions = [
|
|
|
30
32
|
const { targetDocument } = useFluent();
|
|
31
33
|
const triggerId = useId('menu');
|
|
32
34
|
const [contextTarget, setContextTarget] = usePositioningMouseTarget();
|
|
35
|
+
const resolvedPositioning = resolvePositioningShorthand(props.positioning);
|
|
36
|
+
const handlePositionEnd = usePositioningSlideDirection({
|
|
37
|
+
targetDocument,
|
|
38
|
+
onPositioningEnd: resolvedPositioning.onPositioningEnd
|
|
39
|
+
});
|
|
33
40
|
const positioningOptions = {
|
|
34
41
|
position: isSubmenu ? 'after' : 'below',
|
|
35
42
|
align: isSubmenu ? 'top' : 'start',
|
|
36
43
|
target: props.openOnContext ? contextTarget : undefined,
|
|
37
44
|
fallbackPositions: isSubmenu ? submenuFallbackPositions : undefined,
|
|
38
|
-
...
|
|
45
|
+
...resolvedPositioning,
|
|
46
|
+
onPositioningEnd: handlePositionEnd
|
|
39
47
|
};
|
|
40
48
|
const children = React.Children.toArray(props.children);
|
|
41
49
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -139,14 +147,24 @@ const submenuFallbackPositions = [
|
|
|
139
147
|
mountNode,
|
|
140
148
|
triggerRef,
|
|
141
149
|
menuPopoverRef,
|
|
142
|
-
components: {
|
|
150
|
+
components: {
|
|
151
|
+
surfaceMotion: MenuSurfaceMotion
|
|
152
|
+
},
|
|
143
153
|
openOnContext,
|
|
144
154
|
open,
|
|
145
155
|
setOpen,
|
|
146
156
|
checkedValues,
|
|
147
157
|
onCheckedValueChange,
|
|
148
158
|
persistOnItemClick,
|
|
149
|
-
safeZone: safeZoneHandle.elementToRender
|
|
159
|
+
safeZone: safeZoneHandle.elementToRender,
|
|
160
|
+
surfaceMotion: presenceMotionSlot(props.surfaceMotion, {
|
|
161
|
+
elementType: MenuSurfaceMotion,
|
|
162
|
+
defaultProps: {
|
|
163
|
+
visible: open,
|
|
164
|
+
appear: true,
|
|
165
|
+
unmountOnExit: true
|
|
166
|
+
}
|
|
167
|
+
})
|
|
150
168
|
};
|
|
151
169
|
};
|
|
152
170
|
/**
|
|
@@ -286,8 +304,18 @@ const useMenuOpenState = (state)=>{
|
|
|
286
304
|
if (open) {
|
|
287
305
|
focusFirst();
|
|
288
306
|
} else {
|
|
307
|
+
// Skip the initial render — focus should only be restored when the menu
|
|
308
|
+
// transitions from open → closed, not on mount.
|
|
289
309
|
if (!firstMount) {
|
|
290
|
-
|
|
310
|
+
var // The surfaceMotion presence component delays unmounting the popover
|
|
311
|
+
// (e.g. during an exit animation), so focus may still be inside the
|
|
312
|
+
// popover even though `open` is already false. Proactively move it
|
|
313
|
+
// to the trigger before the DOM element is eventually removed.
|
|
314
|
+
_state_menuPopoverRef_current;
|
|
315
|
+
var _targetDocument_activeElement;
|
|
316
|
+
if (// Focus landed on <body> after the popover was removed from the DOM,
|
|
317
|
+
// meaning the user's focus has nowhere meaningful to go.
|
|
318
|
+
(targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement) === (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.body) || ((_state_menuPopoverRef_current = state.menuPopoverRef.current) === null || _state_menuPopoverRef_current === void 0 ? void 0 : _state_menuPopoverRef_current.contains((_targetDocument_activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement) !== null && _targetDocument_activeElement !== void 0 ? _targetDocument_activeElement : null))) {
|
|
291
319
|
var // We know that React effects are sync so we focus the trigger here
|
|
292
320
|
// after any event handler (event handlers will update state and re-render).
|
|
293
321
|
// Since the browser only performs the default behaviour for the Tab key once
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Menu/useMenu.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n resolvePositioningShorthand,\n usePositioningMouseTarget,\n usePositioning,\n useSafeZoneArea,\n type PositioningShorthandValue,\n} from '@fluentui/react-positioning';\nimport {\n useControllableState,\n useId,\n useOnClickOutside,\n useEventCallback,\n useOnScrollOutside,\n elementContains,\n useTimeout,\n useFirstMount,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useFocusFinders } from '@fluentui/react-tabster';\n\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { MENU_SAFEZONE_TIMEOUT_EVENT, MENU_ENTER_EVENT, useOnMenuMouseEnter, useIsSubmenu } from '../../utils';\nimport { menuItemClassNames } from '../MenuItem/useMenuItemStyles.styles';\nimport type { MenuOpenChangeData, MenuOpenEvent, MenuProps, MenuState } from './Menu.types';\n\n// If it's not possible to position the submenu in smaller viewports, try\n// and fallback to this order of positions\nconst submenuFallbackPositions: PositioningShorthandValue[] = [\n 'after',\n 'after-bottom',\n 'before-top',\n 'before',\n 'before-bottom',\n 'above',\n];\n\n/**\n * Create the state required to render Menu.\n *\n * The returned state can be modified with hooks such as useMenuStyles,\n * before being passed to renderMenu_unstable.\n *\n * @param props - props from this instance of Menu\n */\nexport const useMenu_unstable = (props: MenuProps & { safeZone?: boolean | { timeout?: number } }): MenuState => {\n const isSubmenu = useIsSubmenu();\n const {\n hoverDelay = 500,\n inline = false,\n hasCheckmarks = false,\n hasIcons = false,\n closeOnScroll = false,\n openOnContext = false,\n persistOnItemClick = false,\n openOnHover = isSubmenu,\n defaultCheckedValues,\n mountNode = null,\n safeZone,\n } = props;\n\n const { targetDocument } = useFluent();\n const triggerId = useId('menu');\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n\n const positioningOptions = {\n position: isSubmenu ? 'after' : 'below',\n align: isSubmenu ? 'top' : 'start',\n target: props.openOnContext ? contextTarget : undefined,\n fallbackPositions: isSubmenu ? submenuFallbackPositions : undefined,\n ...resolvePositioningShorthand(props.positioning),\n } as const;\n\n const children = React.Children.toArray(props.children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Menu must contain at least one child');\n }\n\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Menu must contain at most two children');\n }\n }\n\n let menuTrigger: React.ReactElement | undefined = undefined;\n let menuPopover: React.ReactElement | undefined = undefined;\n if (children.length === 2) {\n menuTrigger = children[0];\n menuPopover = children[1];\n } else if (children.length === 1) {\n menuPopover = children[0];\n }\n\n const { targetRef, containerRef } = usePositioning(positioningOptions);\n\n const enableSafeZone = safeZone && openOnHover;\n const safeZoneDescriptorRef = React.useRef({\n isInside: false,\n mouseCoordinates: { x: 0, y: 0 },\n });\n\n const safeZoneHandle = useSafeZoneArea({\n disabled: !enableSafeZone,\n timeout: typeof safeZone === 'object' ? safeZone.timeout : 300,\n\n onSafeZoneEnter: e => {\n setOpen(e, { open: true, keyboard: false, type: 'menuSafeZoneMouseEnter', event: e });\n safeZoneDescriptorRef.current.isInside = true;\n },\n onSafeZoneLeave: () => {\n safeZoneDescriptorRef.current.isInside = false;\n },\n onSafeZoneMove: e => {\n safeZoneDescriptorRef.current.mouseCoordinates = {\n x: e.clientX,\n y: e.clientY,\n };\n },\n onSafeZoneTimeout: () => {\n const event = new CustomEvent(MENU_SAFEZONE_TIMEOUT_EVENT);\n\n setOpen(event, { open: false, keyboard: false, type: 'menuSafeZoneTimeout', event });\n\n if (safeZoneDescriptorRef.current.isInside && targetDocument) {\n const elementsInPoint = targetDocument.elementsFromPoint(\n safeZoneDescriptorRef.current.mouseCoordinates.x,\n safeZoneDescriptorRef.current.mouseCoordinates.y,\n );\n const menuItemEl = elementsInPoint.find(el => {\n return el.classList.contains(menuItemClassNames.root);\n }) as HTMLElement | null;\n\n menuItemEl?.dispatchEvent(event);\n }\n },\n });\n\n const triggerRef = useMergedRefs(targetRef, safeZoneHandle.targetRef);\n const menuPopoverRef = useMergedRefs(containerRef, safeZoneHandle.containerRef);\n\n // TODO Better way to narrow types ?\n const [open, setOpen] = useMenuOpenState({\n hoverDelay,\n isSubmenu,\n setContextTarget,\n closeOnScroll,\n menuPopoverRef,\n triggerRef,\n open: props.open,\n defaultOpen: props.defaultOpen,\n onOpenChange: props.onOpenChange,\n openOnContext,\n });\n\n const [checkedValues, onCheckedValueChange] = useMenuSelectableState({\n checkedValues: props.checkedValues,\n defaultCheckedValues,\n onCheckedValueChange: props.onCheckedValueChange,\n });\n\n return {\n inline,\n hoverDelay,\n triggerId,\n isSubmenu,\n openOnHover,\n contextTarget,\n setContextTarget,\n hasCheckmarks,\n hasIcons,\n closeOnScroll,\n menuTrigger,\n menuPopover,\n mountNode,\n triggerRef,\n menuPopoverRef,\n components: {},\n openOnContext,\n open,\n setOpen,\n checkedValues,\n onCheckedValueChange,\n persistOnItemClick,\n safeZone: safeZoneHandle.elementToRender,\n };\n};\n\n/**\n * Adds appropriate state values and handlers for selectable items\n * i.e checkboxes and radios\n */\nconst useMenuSelectableState = (\n props: Pick<MenuProps, 'checkedValues' | 'defaultCheckedValues' | 'onCheckedValueChange'>,\n) => {\n const [checkedValues, setCheckedValues] = useControllableState({\n state: props.checkedValues,\n defaultState: props.defaultCheckedValues,\n initialState: {},\n });\n const onCheckedValueChange: MenuState['onCheckedValueChange'] = useEventCallback((e, { name, checkedItems }) => {\n props.onCheckedValueChange?.(e, { name, checkedItems });\n\n setCheckedValues(currentValue => ({\n ...currentValue,\n [name]: checkedItems,\n }));\n });\n\n return [checkedValues, onCheckedValueChange] as const;\n};\n\nconst useMenuOpenState = (\n state: Pick<\n MenuState,\n | 'isSubmenu'\n | 'menuPopoverRef'\n | 'setContextTarget'\n | 'triggerRef'\n | 'openOnContext'\n | 'closeOnScroll'\n | 'hoverDelay'\n > &\n Pick<MenuProps, 'open' | 'defaultOpen' | 'onOpenChange'>,\n) => {\n 'use no memo';\n\n const { targetDocument } = useFluent();\n const parentSetOpen = useMenuContext_unstable(context => context.setOpen);\n const onOpenChange: MenuProps['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const enteringTriggerRef = React.useRef(false);\n\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false,\n });\n\n const trySetOpen = useEventCallback((e: MenuOpenEvent, data: MenuOpenChangeData) => {\n const event = e instanceof CustomEvent && e.type === MENU_ENTER_EVENT ? e.detail.nativeEvent : e;\n onOpenChange?.(event, { ...data });\n if (data.open && e.type === 'contextmenu') {\n state.setContextTarget(e as React.MouseEvent);\n }\n\n if (!data.open) {\n state.setContextTarget(undefined);\n }\n\n if (data.bubble) {\n parentSetOpen(e, { ...data });\n }\n\n setOpenState(data.open);\n });\n\n const [setOpenTimeout, clearOpenTimeout] = useTimeout();\n\n const setOpen = useEventCallback((e: MenuOpenEvent, data: MenuOpenChangeData & { ignoreHoverDelay?: boolean }) => {\n clearOpenTimeout();\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n const shouldUseDelay =\n !data.ignoreHoverDelay &&\n (e.type === 'mouseleave' || e.type === 'mouseover' || e.type === 'mousemove' || e.type === MENU_ENTER_EVENT);\n\n if (shouldUseDelay) {\n if (state.triggerRef.current?.contains(e.target as HTMLElement)) {\n enteringTriggerRef.current = e.type === 'mouseover' || e.type === 'mousemove';\n }\n\n setOpenTimeout(() => trySetOpen(e, data), state.hoverDelay);\n } else {\n trySetOpen(e, data);\n }\n });\n\n useOnClickOutside({\n contains: elementContains,\n disabled: !open,\n element: targetDocument,\n refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(\n Boolean,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ) as React.MutableRefObject<HTMLElement | null>[],\n callback: event => setOpen(event, { open: false, type: 'clickOutside', event }),\n });\n\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = state.openOnContext || state.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: event => setOpen(event, { open: false, type: 'scrollOutside', event }),\n refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(\n Boolean,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ) as React.MutableRefObject<HTMLElement | null>[],\n disabled: !open || !closeOnScroll,\n });\n\n useOnMenuMouseEnter({\n element: targetDocument,\n callback: event => {\n // When moving from a menu directly back to its trigger, this handler can close the menu\n // Explicitly check a flag to see if this situation happens\n if (!enteringTriggerRef.current) {\n setOpen(event, { open: false, type: 'menuMouseEnter', event });\n }\n },\n disabled: !open,\n refs: [state.menuPopoverRef],\n });\n\n // Manage focus for open state\n const { findFirstFocusable } = useFocusFinders();\n const focusFirst = React.useCallback(() => {\n const firstFocusable = findFirstFocusable(state.menuPopoverRef.current);\n firstFocusable?.focus();\n }, [findFirstFocusable, state.menuPopoverRef]);\n\n const firstMount = useFirstMount();\n React.useEffect(() => {\n if (open) {\n focusFirst();\n } else {\n if (!firstMount) {\n if (targetDocument?.activeElement === targetDocument?.body) {\n // We know that React effects are sync so we focus the trigger here\n // after any event handler (event handlers will update state and re-render).\n // Since the browser only performs the default behaviour for the Tab key once\n // keyboard events have fully bubbled up the window, the browser will move\n // focus to the next tabbable element before/after the trigger if needed.\n // If the Tab key was not pressed, focus will remain on the trigger as expected.\n state.triggerRef.current?.focus();\n }\n }\n }\n // firstMount change should not re-run this effect\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [state.triggerRef, state.isSubmenu, open, focusFirst, targetDocument, state.menuPopoverRef]);\n\n return [open, setOpen] as const;\n};\n"],"names":["React","resolvePositioningShorthand","usePositioningMouseTarget","usePositioning","useSafeZoneArea","useControllableState","useId","useOnClickOutside","useEventCallback","useOnScrollOutside","elementContains","useTimeout","useFirstMount","useMergedRefs","useFluent_unstable","useFluent","useFocusFinders","useMenuContext_unstable","MENU_SAFEZONE_TIMEOUT_EVENT","MENU_ENTER_EVENT","useOnMenuMouseEnter","useIsSubmenu","menuItemClassNames","submenuFallbackPositions","useMenu_unstable","props","isSubmenu","hoverDelay","inline","hasCheckmarks","hasIcons","closeOnScroll","openOnContext","persistOnItemClick","openOnHover","defaultCheckedValues","mountNode","safeZone","targetDocument","triggerId","contextTarget","setContextTarget","positioningOptions","position","align","target","undefined","fallbackPositions","positioning","children","Children","toArray","process","env","NODE_ENV","length","console","warn","menuTrigger","menuPopover","targetRef","containerRef","enableSafeZone","safeZoneDescriptorRef","useRef","isInside","mouseCoordinates","x","y","safeZoneHandle","disabled","timeout","onSafeZoneEnter","e","setOpen","open","keyboard","type","event","current","onSafeZoneLeave","onSafeZoneMove","clientX","clientY","onSafeZoneTimeout","CustomEvent","elementsInPoint","elementsFromPoint","menuItemEl","find","el","classList","contains","root","dispatchEvent","triggerRef","menuPopoverRef","useMenuOpenState","defaultOpen","onOpenChange","checkedValues","onCheckedValueChange","useMenuSelectableState","components","elementToRender","setCheckedValues","state","defaultState","initialState","name","checkedItems","currentValue","parentSetOpen","context","data","enteringTriggerRef","setOpenState","trySetOpen","detail","nativeEvent","bubble","setOpenTimeout","clearOpenTimeout","Event","persist","shouldUseDelay","ignoreHoverDelay","element","refs","filter","Boolean","callback","findFirstFocusable","focusFirst","useCallback","firstFocusable","focus","firstMount","useEffect","activeElement","body"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,2BAA2B,EAC3BC,yBAAyB,EACzBC,cAAc,EACdC,eAAe,QAEV,8BAA8B;AACrC,SACEC,oBAAoB,EACpBC,KAAK,EACLC,iBAAiB,EACjBC,gBAAgB,EAChBC,kBAAkB,EAClBC,eAAe,EACfC,UAAU,EACVC,aAAa,EACbC,aAAa,QACR,4BAA4B;AACnC,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,eAAe,QAAQ,0BAA0B;AAE1D,SAASC,uBAAuB,QAAQ,6BAA6B;AACrE,SAASC,2BAA2B,EAAEC,gBAAgB,EAAEC,mBAAmB,EAAEC,YAAY,QAAQ,cAAc;AAC/G,SAASC,kBAAkB,QAAQ,uCAAuC;AAG1E,yEAAyE;AACzE,0CAA0C;AAC1C,MAAMC,2BAAwD;IAC5D;IACA;IACA;IACA;IACA;IACA;CACD;AAED;;;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MAAM,EAAEoC,kBAAkB,EAAE,GAAGpH;IAC/B,MAAMqH,aAAarI,MAAMsI,WAAW,CAAC;QACnC,MAAMC,iBAAiBH,mBAAmB1B,MAAMV,cAAc,CAACjB,OAAO;QACtEwD,2BAAAA,qCAAAA,eAAgBC,KAAK;IACvB,GAAG;QAACJ;QAAoB1B,MAAMV,cAAc;KAAC;IAE7C,MAAMyC,aAAa7H;IACnBZ,MAAM0I,SAAS,CAAC;QACd,IAAI/D,MAAM;YACR0D;QACF,OAAO;YACL,IAAI,CAACI,YAAY;gBACf,IAAInG,CAAAA,2BAAAA,qCAAAA,eAAgBqG,aAAa,OAAKrG,2BAAAA,qCAAAA,eAAgBsG,IAAI,GAAE;wBAC1D,mEAAmE;oBACnE,4EAA4E;oBAC5E,6EAA6E;oBAC7E,0EAA0E;oBAC1E,yEAAyE;oBACzE,gFAAgF;oBAChFlC;qBAAAA,4BAAAA,MAAMX,UAAU,CAAChB,OAAO,cAAxB2B,gDAAAA,0BAA0B8B,KAAK;gBACjC;YACF;QACF;IACA,kDAAkD;IAClD,uDAAuD;IACzD,GAAG;QAAC9B,MAAMX,UAAU;QAAEW,MAAMhF,SAAS;QAAEiD;QAAM0D;QAAY/F;QAAgBoE,MAAMV,cAAc;KAAC;IAE9F,OAAO;QAACrB;QAAMD;KAAQ;AACxB"}
|
|
1
|
+
{"version":3,"sources":["../src/components/Menu/useMenu.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n resolvePositioningShorthand,\n usePositioningMouseTarget,\n usePositioning,\n useSafeZoneArea,\n usePositioningSlideDirection,\n type PositioningShorthandValue,\n} from '@fluentui/react-positioning';\nimport { presenceMotionSlot } from '@fluentui/react-motion';\nimport {\n useControllableState,\n useId,\n useOnClickOutside,\n useEventCallback,\n useOnScrollOutside,\n elementContains,\n useTimeout,\n useFirstMount,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useFocusFinders } from '@fluentui/react-tabster';\n\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { MENU_SAFEZONE_TIMEOUT_EVENT, MENU_ENTER_EVENT, useOnMenuMouseEnter, useIsSubmenu } from '../../utils';\nimport { menuItemClassNames } from '../MenuItem/useMenuItemStyles.styles';\nimport type { MenuOpenChangeData, MenuOpenEvent, MenuProps, MenuState } from './Menu.types';\nimport { MenuSurfaceMotion } from './MenuSurfaceMotion';\n\n// If it's not possible to position the submenu in smaller viewports, try\n// and fallback to this order of positions\nconst submenuFallbackPositions: PositioningShorthandValue[] = [\n 'after',\n 'after-bottom',\n 'before-top',\n 'before',\n 'before-bottom',\n 'above',\n];\n\n/**\n * Create the state required to render Menu.\n *\n * The returned state can be modified with hooks such as useMenuStyles,\n * before being passed to renderMenu_unstable.\n *\n * @param props - props from this instance of Menu\n */\nexport const useMenu_unstable = (props: MenuProps & { safeZone?: boolean | { timeout?: number } }): MenuState => {\n const isSubmenu = useIsSubmenu();\n const {\n hoverDelay = 500,\n inline = false,\n hasCheckmarks = false,\n hasIcons = false,\n closeOnScroll = false,\n openOnContext = false,\n persistOnItemClick = false,\n openOnHover = isSubmenu,\n defaultCheckedValues,\n mountNode = null,\n safeZone,\n } = props;\n\n const { targetDocument } = useFluent();\n const triggerId = useId('menu');\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n\n const resolvedPositioning = resolvePositioningShorthand(props.positioning);\n const handlePositionEnd = usePositioningSlideDirection({\n targetDocument,\n onPositioningEnd: resolvedPositioning.onPositioningEnd,\n });\n\n const positioningOptions = {\n position: isSubmenu ? 'after' : 'below',\n align: isSubmenu ? 'top' : 'start',\n target: props.openOnContext ? contextTarget : undefined,\n fallbackPositions: isSubmenu ? submenuFallbackPositions : undefined,\n ...resolvedPositioning,\n onPositioningEnd: handlePositionEnd,\n } as const;\n\n const children = React.Children.toArray(props.children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Menu must contain at least one child');\n }\n\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Menu must contain at most two children');\n }\n }\n\n let menuTrigger: React.ReactElement | undefined = undefined;\n let menuPopover: React.ReactElement | undefined = undefined;\n if (children.length === 2) {\n menuTrigger = children[0];\n menuPopover = children[1];\n } else if (children.length === 1) {\n menuPopover = children[0];\n }\n\n const { targetRef, containerRef } = usePositioning(positioningOptions);\n\n const enableSafeZone = safeZone && openOnHover;\n const safeZoneDescriptorRef = React.useRef({\n isInside: false,\n mouseCoordinates: { x: 0, y: 0 },\n });\n\n const safeZoneHandle = useSafeZoneArea({\n disabled: !enableSafeZone,\n timeout: typeof safeZone === 'object' ? safeZone.timeout : 300,\n\n onSafeZoneEnter: e => {\n setOpen(e, { open: true, keyboard: false, type: 'menuSafeZoneMouseEnter', event: e });\n safeZoneDescriptorRef.current.isInside = true;\n },\n onSafeZoneLeave: () => {\n safeZoneDescriptorRef.current.isInside = false;\n },\n onSafeZoneMove: e => {\n safeZoneDescriptorRef.current.mouseCoordinates = {\n x: e.clientX,\n y: e.clientY,\n };\n },\n onSafeZoneTimeout: () => {\n const event = new CustomEvent(MENU_SAFEZONE_TIMEOUT_EVENT);\n\n setOpen(event, { open: false, keyboard: false, type: 'menuSafeZoneTimeout', event });\n\n if (safeZoneDescriptorRef.current.isInside && targetDocument) {\n const elementsInPoint = targetDocument.elementsFromPoint(\n safeZoneDescriptorRef.current.mouseCoordinates.x,\n safeZoneDescriptorRef.current.mouseCoordinates.y,\n );\n const menuItemEl = elementsInPoint.find(el => {\n return el.classList.contains(menuItemClassNames.root);\n }) as HTMLElement | null;\n\n menuItemEl?.dispatchEvent(event);\n }\n },\n });\n\n const triggerRef = useMergedRefs(targetRef, safeZoneHandle.targetRef);\n const menuPopoverRef = useMergedRefs(containerRef, safeZoneHandle.containerRef);\n\n // TODO Better way to narrow types ?\n const [open, setOpen] = useMenuOpenState({\n hoverDelay,\n isSubmenu,\n setContextTarget,\n closeOnScroll,\n menuPopoverRef,\n triggerRef,\n open: props.open,\n defaultOpen: props.defaultOpen,\n onOpenChange: props.onOpenChange,\n openOnContext,\n });\n\n const [checkedValues, onCheckedValueChange] = useMenuSelectableState({\n checkedValues: props.checkedValues,\n defaultCheckedValues,\n onCheckedValueChange: props.onCheckedValueChange,\n });\n\n return {\n inline,\n hoverDelay,\n triggerId,\n isSubmenu,\n openOnHover,\n contextTarget,\n setContextTarget,\n hasCheckmarks,\n hasIcons,\n closeOnScroll,\n menuTrigger,\n menuPopover,\n mountNode,\n triggerRef,\n menuPopoverRef,\n components: {\n surfaceMotion: MenuSurfaceMotion,\n },\n openOnContext,\n open,\n setOpen,\n checkedValues,\n onCheckedValueChange,\n persistOnItemClick,\n safeZone: safeZoneHandle.elementToRender,\n surfaceMotion: presenceMotionSlot(props.surfaceMotion, {\n elementType: MenuSurfaceMotion,\n defaultProps: {\n visible: open,\n appear: true,\n unmountOnExit: true,\n },\n }),\n };\n};\n\n/**\n * Adds appropriate state values and handlers for selectable items\n * i.e checkboxes and radios\n */\nconst useMenuSelectableState = (\n props: Pick<MenuProps, 'checkedValues' | 'defaultCheckedValues' | 'onCheckedValueChange'>,\n) => {\n const [checkedValues, setCheckedValues] = useControllableState({\n state: props.checkedValues,\n defaultState: props.defaultCheckedValues,\n initialState: {},\n });\n const onCheckedValueChange: MenuState['onCheckedValueChange'] = useEventCallback((e, { name, checkedItems }) => {\n props.onCheckedValueChange?.(e, { name, checkedItems });\n\n setCheckedValues(currentValue => ({\n ...currentValue,\n [name]: checkedItems,\n }));\n });\n\n return [checkedValues, onCheckedValueChange] as const;\n};\n\nconst useMenuOpenState = (\n state: Pick<\n MenuState,\n | 'isSubmenu'\n | 'menuPopoverRef'\n | 'setContextTarget'\n | 'triggerRef'\n | 'openOnContext'\n | 'closeOnScroll'\n | 'hoverDelay'\n > &\n Pick<MenuProps, 'open' | 'defaultOpen' | 'onOpenChange'>,\n) => {\n 'use no memo';\n\n const { targetDocument } = useFluent();\n const parentSetOpen = useMenuContext_unstable(context => context.setOpen);\n const onOpenChange: MenuProps['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const enteringTriggerRef = React.useRef(false);\n\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false,\n });\n\n const trySetOpen = useEventCallback((e: MenuOpenEvent, data: MenuOpenChangeData) => {\n const event = e instanceof CustomEvent && e.type === MENU_ENTER_EVENT ? e.detail.nativeEvent : e;\n onOpenChange?.(event, { ...data });\n if (data.open && e.type === 'contextmenu') {\n state.setContextTarget(e as React.MouseEvent);\n }\n\n if (!data.open) {\n state.setContextTarget(undefined);\n }\n\n if (data.bubble) {\n parentSetOpen(e, { ...data });\n }\n\n setOpenState(data.open);\n });\n\n const [setOpenTimeout, clearOpenTimeout] = useTimeout();\n\n const setOpen = useEventCallback((e: MenuOpenEvent, data: MenuOpenChangeData & { ignoreHoverDelay?: boolean }) => {\n clearOpenTimeout();\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n const shouldUseDelay =\n !data.ignoreHoverDelay &&\n (e.type === 'mouseleave' || e.type === 'mouseover' || e.type === 'mousemove' || e.type === MENU_ENTER_EVENT);\n\n if (shouldUseDelay) {\n if (state.triggerRef.current?.contains(e.target as HTMLElement)) {\n enteringTriggerRef.current = e.type === 'mouseover' || e.type === 'mousemove';\n }\n\n setOpenTimeout(() => trySetOpen(e, data), state.hoverDelay);\n } else {\n trySetOpen(e, data);\n }\n });\n\n useOnClickOutside({\n contains: elementContains,\n disabled: !open,\n element: targetDocument,\n refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(\n Boolean,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ) as React.MutableRefObject<HTMLElement | null>[],\n callback: event => setOpen(event, { open: false, type: 'clickOutside', event }),\n });\n\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = state.openOnContext || state.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: event => setOpen(event, { open: false, type: 'scrollOutside', event }),\n refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(\n Boolean,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ) as React.MutableRefObject<HTMLElement | null>[],\n disabled: !open || !closeOnScroll,\n });\n\n useOnMenuMouseEnter({\n element: targetDocument,\n callback: event => {\n // When moving from a menu directly back to its trigger, this handler can close the menu\n // Explicitly check a flag to see if this situation happens\n if (!enteringTriggerRef.current) {\n setOpen(event, { open: false, type: 'menuMouseEnter', event });\n }\n },\n disabled: !open,\n refs: [state.menuPopoverRef],\n });\n\n // Manage focus for open state\n const { findFirstFocusable } = useFocusFinders();\n const focusFirst = React.useCallback(() => {\n const firstFocusable = findFirstFocusable(state.menuPopoverRef.current);\n firstFocusable?.focus();\n }, [findFirstFocusable, state.menuPopoverRef]);\n\n const firstMount = useFirstMount();\n React.useEffect(() => {\n if (open) {\n focusFirst();\n } else {\n // Skip the initial render — focus should only be restored when the menu\n // transitions from open → closed, not on mount.\n if (!firstMount) {\n if (\n // Focus landed on <body> after the popover was removed from the DOM,\n // meaning the user's focus has nowhere meaningful to go.\n targetDocument?.activeElement === targetDocument?.body ||\n // The surfaceMotion presence component delays unmounting the popover\n // (e.g. during an exit animation), so focus may still be inside the\n // popover even though `open` is already false. Proactively move it\n // to the trigger before the DOM element is eventually removed.\n state.menuPopoverRef.current?.contains(targetDocument?.activeElement ?? null)\n ) {\n // We know that React effects are sync so we focus the trigger here\n // after any event handler (event handlers will update state and re-render).\n // Since the browser only performs the default behaviour for the Tab key once\n // keyboard events have fully bubbled up the window, the browser will move\n // focus to the next tabbable element before/after the trigger if needed.\n // If the Tab key was not pressed, focus will remain on the trigger as expected.\n state.triggerRef.current?.focus();\n }\n }\n }\n // firstMount change should not re-run this effect\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [state.triggerRef, state.isSubmenu, open, focusFirst, targetDocument, state.menuPopoverRef]);\n\n return [open, setOpen] as const;\n};\n"],"names":["React","resolvePositioningShorthand","usePositioningMouseTarget","usePositioning","useSafeZoneArea","usePositioningSlideDirection","presenceMotionSlot","useControllableState","useId","useOnClickOutside","useEventCallback","useOnScrollOutside","elementContains","useTimeout","useFirstMount","useMergedRefs","useFluent_unstable","useFluent","useFocusFinders","useMenuContext_unstable","MENU_SAFEZONE_TIMEOUT_EVENT","MENU_ENTER_EVENT","useOnMenuMouseEnter","useIsSubmenu","menuItemClassNames","MenuSurfaceMotion","submenuFallbackPositions","useMenu_unstable","props","isSubmenu","hoverDelay","inline","hasCheckmarks","hasIcons","closeOnScroll","openOnContext","persistOnItemClick","openOnHover","defaultCheckedValues","mountNode","safeZone","targetDocument","triggerId","contextTarget","setContextTarget","resolvedPositioning","positioning","handlePositionEnd","onPositioningEnd","positioningOptions","position","align","target","undefined","fallbackPositions","children","Children","toArray","process","env","NODE_ENV","length","console","warn","menuTrigger","menuPopover","targetRef","containerRef","enableSafeZone","safeZoneDescriptorRef","useRef","isInside","mouseCoordinates","x","y","safeZoneHandle","disabled","timeout","onSafeZoneEnter","e","setOpen","open","keyboard","type","event","current","onSafeZoneLeave","onSafeZoneMove","clientX","clientY","onSafeZoneTimeout","CustomEvent","elementsInPoint","elementsFromPoint","menuItemEl","find","el","classList","contains","root","dispatchEvent","triggerRef","menuPopoverRef","useMenuOpenState","defaultOpen","onOpenChange","checkedValues","onCheckedValueChange","useMenuSelectableState","components","surfaceMotion","elementToRender","elementType","defaultProps","visible","appear","unmountOnExit","setCheckedValues","state","defaultState","initialState","name","checkedItems","currentValue","parentSetOpen","context","data","enteringTriggerRef","setOpenState","trySetOpen","detail","nativeEvent","bubble","setOpenTimeout","clearOpenTimeout","Event","persist","shouldUseDelay","ignoreHoverDelay","element","refs","filter","Boolean","callback","findFirstFocusable","focusFirst","useCallback","firstFocusable","focus","firstMount","useEffect","activeElement","body"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ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OAAO;YACL,wEAAwE;YACxE,gDAAgD;YAChD,IAAI,CAACI,YAAY;oBAKb,qEAAqE;gBACrE,oEAAoE;gBACpE,mEAAmE;gBACnE,+DAA+D;gBAC/D/B;oBAAuC7E;gBARzC,IACE,qEAAqE;gBACrE,yDAAyD;gBACzDA,CAAAA,2BAAAA,qCAAAA,eAAgB8G,aAAa,OAAK9G,2BAAAA,qCAAAA,eAAgB+G,IAAI,OAKtDlC,gCAAAA,MAAMhB,cAAc,CAACjB,OAAO,cAA5BiC,oDAAAA,8BAA8BpB,QAAQ,CAACzD,CAAAA,gCAAAA,2BAAAA,qCAAAA,eAAgB8G,aAAa,cAA7B9G,2CAAAA,gCAAiC,QACxE;wBACA,mEAAmE;oBACnE,4EAA4E;oBAC5E,6EAA6E;oBAC7E,0EAA0E;oBAC1E,yEAAyE;oBACzE,gFAAgF;oBAChF6E;qBAAAA,4BAAAA,MAAMjB,UAAU,CAAChB,OAAO,cAAxBiC,gDAAAA,0BAA0B8B,KAAK;gBACjC;YACF;QACF;IACA,kDAAkD;IAClD,uDAAuD;IACzD,GAAG;QAAC9B,MAAMjB,UAAU;QAAEiB,MAAMzF,SAAS;QAAEoD;QAAMgE;QAAYxG;QAAgB6E,MAAMhB,cAAc;KAAC;IAE9F,OAAO;QAACrB;QAAMD;KAAQ;AACxB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { ArrowLeft, Tab, ArrowRight, Escape } from '@fluentui/keyboard-keys';
|
|
3
3
|
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
|
4
|
+
import { useMotionForwardedRef } from '@fluentui/react-motion';
|
|
4
5
|
import { useRestoreFocusSource } from '@fluentui/react-tabster';
|
|
5
6
|
import { getIntrinsicElementProps, useEventCallback, useMergedRefs, slot, useTimeout } from '@fluentui/react-utilities';
|
|
6
7
|
import * as React from 'react';
|
|
@@ -64,7 +65,7 @@ import { dispatchMenuEnterEvent, useIsSubmenu } from '../../utils/index';
|
|
|
64
65
|
// FIXME:
|
|
65
66
|
// `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`
|
|
66
67
|
// but since it would be a breaking change to fix it, we are casting ref to it's proper type
|
|
67
|
-
ref: useMergedRefs(ref, popoverRef, mouseOverListenerCallbackRef)
|
|
68
|
+
ref: useMergedRefs(ref, popoverRef, mouseOverListenerCallbackRef, useMotionForwardedRef())
|
|
68
69
|
}), {
|
|
69
70
|
elementType: 'div'
|
|
70
71
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/MenuPopover/useMenuPopover.ts"],"sourcesContent":["'use client';\n\nimport { ArrowLeft, Tab, ArrowRight, Escape } from '@fluentui/keyboard-keys';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useRestoreFocusSource } from '@fluentui/react-tabster';\nimport { getIntrinsicElementProps, useEventCallback, useMergedRefs, slot, useTimeout } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { dispatchMenuEnterEvent, useIsSubmenu } from '../../utils/index';\nimport { MenuPopoverProps, MenuPopoverState } from './MenuPopover.types';\n\n/**\n * Create the state required to render MenuPopover.\n *\n * The returned state can be modified with hooks such as useMenuPopoverStyles_unstable,\n * before being passed to renderMenuPopover_unstable.\n *\n * @param props - props from this instance of MenuPopover\n * @param ref - reference to root HTMLElement of MenuPopover\n */\nexport const useMenuPopover_unstable = (props: MenuPopoverProps, ref: React.Ref<HTMLElement>): MenuPopoverState => {\n 'use no memo';\n\n const safeZone = useMenuContext_unstable(context => context.safeZone);\n const popoverRef = useMenuContext_unstable(context => context.menuPopoverRef);\n const setOpen = useMenuContext_unstable(context => context.setOpen);\n const open = useMenuContext_unstable(context => context.open);\n const openOnHover = useMenuContext_unstable(context => context.openOnHover);\n const triggerRef = useMenuContext_unstable(context => context.triggerRef);\n\n const isSubmenu = useIsSubmenu();\n const canDispatchCustomEventRef = React.useRef(true);\n const restoreFocusSourceAttributes = useRestoreFocusSource();\n const [setThrottleTimeout, clearThrottleTimeout] = useTimeout();\n\n const { dir } = useFluent();\n const CloseArrowKey = dir === 'ltr' ? ArrowLeft : ArrowRight;\n\n // use DOM listener since react events propagate up the react tree\n // no need to do `contains` logic as menus are all positioned in different portals\n const mouseOverListenerCallbackRef = React.useCallback(\n (node: HTMLElement) => {\n if (node) {\n // Dispatches the custom menu mouse enter event with throttling\n // Needs to trigger on mouseover to support keyboard + mouse together\n // i.e. keyboard opens submenus while cursor is still on the parent\n node.addEventListener('mouseover', e => {\n if (canDispatchCustomEventRef.current) {\n canDispatchCustomEventRef.current = false;\n dispatchMenuEnterEvent(popoverRef.current as HTMLElement, e);\n setThrottleTimeout(() => {\n canDispatchCustomEventRef.current = true;\n }, 250);\n }\n });\n }\n },\n [popoverRef, setThrottleTimeout],\n );\n\n React.useEffect(() => {\n return () => clearThrottleTimeout();\n }, [clearThrottleTimeout]);\n\n const inline = useMenuContext_unstable(context => context.inline) ?? false;\n const mountNode = useMenuContext_unstable(context => context.mountNode);\n\n const rootProps = slot.always(\n getIntrinsicElementProps('div', {\n role: 'presentation',\n ...restoreFocusSourceAttributes,\n ...props,\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: useMergedRefs(ref
|
|
1
|
+
{"version":3,"sources":["../src/components/MenuPopover/useMenuPopover.ts"],"sourcesContent":["'use client';\n\nimport { ArrowLeft, Tab, ArrowRight, Escape } from '@fluentui/keyboard-keys';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useMotionForwardedRef } from '@fluentui/react-motion';\nimport { useRestoreFocusSource } from '@fluentui/react-tabster';\nimport { getIntrinsicElementProps, useEventCallback, useMergedRefs, slot, useTimeout } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { dispatchMenuEnterEvent, useIsSubmenu } from '../../utils/index';\nimport { MenuPopoverProps, MenuPopoverState } from './MenuPopover.types';\n\n/**\n * Create the state required to render MenuPopover.\n *\n * The returned state can be modified with hooks such as useMenuPopoverStyles_unstable,\n * before being passed to renderMenuPopover_unstable.\n *\n * @param props - props from this instance of MenuPopover\n * @param ref - reference to root HTMLElement of MenuPopover\n */\nexport const useMenuPopover_unstable = (props: MenuPopoverProps, ref: React.Ref<HTMLElement>): MenuPopoverState => {\n 'use no memo';\n\n const safeZone = useMenuContext_unstable(context => context.safeZone);\n const popoverRef = useMenuContext_unstable(context => context.menuPopoverRef);\n const setOpen = useMenuContext_unstable(context => context.setOpen);\n const open = useMenuContext_unstable(context => context.open);\n const openOnHover = useMenuContext_unstable(context => context.openOnHover);\n const triggerRef = useMenuContext_unstable(context => context.triggerRef);\n\n const isSubmenu = useIsSubmenu();\n const canDispatchCustomEventRef = React.useRef(true);\n const restoreFocusSourceAttributes = useRestoreFocusSource();\n const [setThrottleTimeout, clearThrottleTimeout] = useTimeout();\n\n const { dir } = useFluent();\n const CloseArrowKey = dir === 'ltr' ? ArrowLeft : ArrowRight;\n\n // use DOM listener since react events propagate up the react tree\n // no need to do `contains` logic as menus are all positioned in different portals\n const mouseOverListenerCallbackRef = React.useCallback(\n (node: HTMLElement) => {\n if (node) {\n // Dispatches the custom menu mouse enter event with throttling\n // Needs to trigger on mouseover to support keyboard + mouse together\n // i.e. keyboard opens submenus while cursor is still on the parent\n node.addEventListener('mouseover', e => {\n if (canDispatchCustomEventRef.current) {\n canDispatchCustomEventRef.current = false;\n dispatchMenuEnterEvent(popoverRef.current as HTMLElement, e);\n setThrottleTimeout(() => {\n canDispatchCustomEventRef.current = true;\n }, 250);\n }\n });\n }\n },\n [popoverRef, setThrottleTimeout],\n );\n\n React.useEffect(() => {\n return () => clearThrottleTimeout();\n }, [clearThrottleTimeout]);\n\n const inline = useMenuContext_unstable(context => context.inline) ?? false;\n const mountNode = useMenuContext_unstable(context => context.mountNode);\n\n const rootProps = slot.always(\n getIntrinsicElementProps('div', {\n role: 'presentation',\n ...restoreFocusSourceAttributes,\n ...props,\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: useMergedRefs(\n ref,\n popoverRef,\n mouseOverListenerCallbackRef,\n useMotionForwardedRef(),\n ) as React.Ref<HTMLDivElement>,\n }),\n { elementType: 'div' },\n );\n const { onMouseEnter: onMouseEnterOriginal, onKeyDown: onKeyDownOriginal } = rootProps;\n rootProps.onMouseEnter = useEventCallback((event: React.MouseEvent<HTMLDivElement>) => {\n if (openOnHover || isSubmenu) {\n setOpen(event, { open: true, keyboard: false, type: 'menuPopoverMouseEnter', event });\n }\n onMouseEnterOriginal?.(event);\n });\n rootProps.onKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLDivElement>) => {\n const key = event.key;\n if (key === Escape || (isSubmenu && key === CloseArrowKey)) {\n if (open && popoverRef.current?.contains(event.target as HTMLElement) && !event.isDefaultPrevented()) {\n setOpen(event, { open: false, keyboard: true, type: 'menuPopoverKeyDown', event });\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu and Tooltip\n event.preventDefault();\n }\n }\n if (key === Tab) {\n setOpen(event, { open: false, keyboard: true, type: 'menuPopoverKeyDown', event });\n if (!isSubmenu) {\n triggerRef.current?.focus();\n }\n }\n onKeyDownOriginal?.(event);\n });\n\n return {\n inline,\n mountNode,\n safeZone,\n components: { root: 'div' },\n root: rootProps,\n };\n};\n"],"names":["ArrowLeft","Tab","ArrowRight","Escape","useFluent_unstable","useFluent","useMotionForwardedRef","useRestoreFocusSource","getIntrinsicElementProps","useEventCallback","useMergedRefs","slot","useTimeout","React","useMenuContext_unstable","dispatchMenuEnterEvent","useIsSubmenu","useMenuPopover_unstable","props","ref","safeZone","context","popoverRef","menuPopoverRef","setOpen","open","openOnHover","triggerRef","isSubmenu","canDispatchCustomEventRef","useRef","restoreFocusSourceAttributes","setThrottleTimeout","clearThrottleTimeout","dir","CloseArrowKey","mouseOverListenerCallbackRef","useCallback","node","addEventListener","e","current","useEffect","inline","mountNode","rootProps","always","role","elementType","onMouseEnter","onMouseEnterOriginal","onKeyDown","onKeyDownOriginal","event","keyboard","type","key","contains","target","isDefaultPrevented","preventDefault","focus","components","root"],"mappings":"AAAA;AAEA,SAASA,SAAS,EAAEC,GAAG,EAAEC,UAAU,EAAEC,MAAM,QAAQ,0BAA0B;AAC7E,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,qBAAqB,QAAQ,0BAA0B;AAChE,SAASC,wBAAwB,EAAEC,gBAAgB,EAAEC,aAAa,EAAEC,IAAI,EAAEC,UAAU,QAAQ,4BAA4B;AACxH,YAAYC,WAAW,QAAQ;AAE/B,SAASC,uBAAuB,QAAQ,6BAA6B;AACrE,SAASC,sBAAsB,EAAEC,YAAY,QAAQ,oBAAoB;AAGzE;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAA0B,CAACC,OAAyBC;IAC/D;IAEA,MAAMC,WAAWN,wBAAwBO,CAAAA,UAAWA,QAAQD,QAAQ;IACpE,MAAME,aAAaR,wBAAwBO,CAAAA,UAAWA,QAAQE,cAAc;IAC5E,MAAMC,UAAUV,wBAAwBO,CAAAA,UAAWA,QAAQG,OAAO;IAClE,MAAMC,OAAOX,wBAAwBO,CAAAA,UAAWA,QAAQI,IAAI;IAC5D,MAAMC,cAAcZ,wBAAwBO,CAAAA,UAAWA,QAAQK,WAAW;IAC1E,MAAMC,aAAab,wBAAwBO,CAAAA,UAAWA,QAAQM,UAAU;IAExE,MAAMC,YAAYZ;IAClB,MAAMa,4BAA4BhB,MAAMiB,MAAM,CAAC;IAC/C,MAAMC,+BAA+BxB;IACrC,MAAM,CAACyB,oBAAoBC,qBAAqB,GAAGrB;IAEnD,MAAM,EAAEsB,GAAG,EAAE,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S,GAAG1C,iBAAiB,CAAC4C;QACtC,MAAMG,MAAMH,MAAMG,GAAG;QACrB,IAAIA,QAAQrD,UAAWyB,aAAa4B,QAAQrB,eAAgB;gBAC9Cb;YAAZ,IAAIG,UAAQH,sBAAAA,WAAWmB,OAAO,cAAlBnB,0CAAAA,oBAAoBmC,QAAQ,CAACJ,MAAMK,MAAM,MAAoB,CAACL,MAAMM,kBAAkB,IAAI;gBACpGnC,QAAQ6B,OAAO;oBAAE5B,MAAM;oBAAO6B,UAAU;oBAAMC,MAAM;oBAAsBF;gBAAM;gBAChF,qFAAqF;gBACrF,yCAAyC;gBACzCA,MAAMO,cAAc;YACtB;QACF;QACA,IAAIJ,QAAQvD,KAAK;YACfuB,QAAQ6B,OAAO;gBAAE5B,MAAM;gBAAO6B,UAAU;gBAAMC,MAAM;gBAAsBF;YAAM;YAChF,IAAI,CAACzB,WAAW;oBACdD;iBAAAA,sBAAAA,WAAWc,OAAO,cAAlBd,0CAAAA,oBAAoBkC,KAAK;YAC3B;QACF;QACAT,8BAAAA,wCAAAA,kBAAoBC;IACtB;IAEA,OAAO;QACLV;QACAC;QACAxB;QACA0C,YAAY;YAAEC,MAAM;QAAM;QAC1BA,MAAMlB;IACR;AACF,EAAE"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { mergeClasses, __styles } from '@griffel/react';
|
|
4
4
|
import { tokens, typographyStyles } from '@fluentui/react-theme';
|
|
5
|
-
import { createSlideStyles } from '@fluentui/react-positioning';
|
|
6
5
|
export const menuPopoverClassNames = {
|
|
7
6
|
root: 'fui-MenuPopover'
|
|
8
7
|
};
|
|
@@ -46,22 +45,7 @@ const useStyles = /*#__PURE__*/__styles({
|
|
|
46
45
|
Bahqtrf: "fk6fouc",
|
|
47
46
|
Be2twd7: "fkhj508",
|
|
48
47
|
Bhrd7zp: "figsok6",
|
|
49
|
-
Bg96gwp: "f1i3iumi"
|
|
50
|
-
B93otf3: "f18k4bn6",
|
|
51
|
-
vin17d: "fo1kyvf",
|
|
52
|
-
Ezkn3b: "fetxo7e",
|
|
53
|
-
nyiy2g: "f8x1vz1",
|
|
54
|
-
swvrvq: "f8g0anz",
|
|
55
|
-
Bkovbt3: "fezwn9i",
|
|
56
|
-
hgjdhn: "fz5efge",
|
|
57
|
-
fsy9dk: "f1ydixl4",
|
|
58
|
-
B3ogreh: "f8dgqj5",
|
|
59
|
-
jv49x5: "fnyfnr8",
|
|
60
|
-
Bk7o48c: "fgw77r4",
|
|
61
|
-
Bv12yb3: "f1noc5he",
|
|
62
|
-
i09l9u: "f1k46bua",
|
|
63
|
-
Bcrj8ia: "f1lhuzxm",
|
|
64
|
-
Bmmhre5: "f1f9qikc"
|
|
48
|
+
Bg96gwp: "f1i3iumi"
|
|
65
49
|
}
|
|
66
50
|
}, {
|
|
67
51
|
d: [[".ft85np5{border-radius:var(--borderRadiusMedium);}", {
|
|
@@ -70,14 +54,7 @@ const useStyles = /*#__PURE__*/__styles({
|
|
|
70
54
|
p: -1
|
|
71
55
|
}], [".f9ggezi{border:1px solid var(--colorTransparentStroke);}", {
|
|
72
56
|
p: -2
|
|
73
|
-
}], ".fk6fouc{font-family:var(--fontFamilyBase);}", ".fkhj508{font-size:var(--fontSizeBase300);}", ".figsok6{font-weight:var(--fontWeightRegular);}", ".f1i3iumi{line-height:var(--lineHeightBase300);}"
|
|
74
|
-
k: ["@keyframes f1m0q9mo{from{opacity:-1;}to{opacity:0;}}", "@keyframes f79suad{from{transform:translate(var(--fui-positioning-slide-distance-x), var(--fui-positioning-slide-distance-y));}}"],
|
|
75
|
-
m: [["@media (prefers-reduced-motion){.f1k46bua[data-popper-placement]{animation-duration:1ms;}}", {
|
|
76
|
-
m: "(prefers-reduced-motion)"
|
|
77
|
-
}], ["@media (prefers-reduced-motion){.f1lhuzxm[data-popper-placement]{animation-name:f1m0q9mo;}}", {
|
|
78
|
-
m: "(prefers-reduced-motion)"
|
|
79
|
-
}]],
|
|
80
|
-
t: ["@supports not (animation-composition: accumulate){.f1f9qikc[data-popper-placement]{animation-name:f1m0q9mo;}}"]
|
|
57
|
+
}], ".fk6fouc{font-family:var(--fontFamilyBase);}", ".fkhj508{font-size:var(--fontSizeBase300);}", ".figsok6{font-weight:var(--fontWeightRegular);}", ".f1i3iumi{line-height:var(--lineHeightBase300);}"]
|
|
81
58
|
});
|
|
82
59
|
/**
|
|
83
60
|
* Apply styling to the Menu slots based on the state
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["mergeClasses","__styles","tokens","typographyStyles","
|
|
1
|
+
{"version":3,"names":["mergeClasses","__styles","tokens","typographyStyles","menuPopoverClassNames","root","useStyles","Beyfa6y","Bbmb7ep","Btl43ni","B7oj6ja","Dimara","De3pzq","sj55zd","B7ck84d","Bf4jedk","B2u0y6b","B68tc82","a9b677","E5pizo","Byoj8tv","uwmqm3","z189sj","z8tnut","B0ocmuz","Bgfg5da","B9xav0g","oivjwe","Bn0qgzm","B4g9neb","zhjwy3","wvpqe5","ibv6hh","u1mtju","h3c5rm","vrafjx","Bekrc4i","i8vvqc","g2u3we","icvyot","B4j52fo","irswps","Bahqtrf","Be2twd7","Bhrd7zp","Bg96gwp","d","p","useMenuPopoverStyles_unstable","state","styles","className"],"sources":["useMenuPopoverStyles.styles.js"],"sourcesContent":["'use client';\nimport { mergeClasses, makeStyles } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nexport const menuPopoverClassNames = {\n root: 'fui-MenuPopover'\n};\nconst useStyles = makeStyles({\n root: {\n borderRadius: tokens.borderRadiusMedium,\n backgroundColor: tokens.colorNeutralBackground1,\n color: tokens.colorNeutralForeground1,\n boxSizing: 'border-box',\n minWidth: '138px',\n maxWidth: '300px',\n overflowX: 'hidden',\n width: 'max-content',\n boxShadow: `${tokens.shadow16}`,\n padding: '4px',\n border: `1px solid ${tokens.colorTransparentStroke}`,\n ...typographyStyles.body1\n }\n});\n/**\n * Apply styling to the Menu slots based on the state\n */ export const useMenuPopoverStyles_unstable = (state)=>{\n 'use no memo';\n const styles = useStyles();\n state.root.className = mergeClasses(menuPopoverClassNames.root, styles.root, state.root.className);\n return state;\n};\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,YAAY,EAAAC,QAAA,QAAoB,gBAAgB;AACzD,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,uBAAuB;AAChE,OAAO,MAAMC,qBAAqB,GAAG;EACjCC,IAAI,EAAE;AACV,CAAC;AACD,MAAMC,SAAS,gBAAGL,QAAA;EAAAI,IAAA;IAAAE,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;IAAAC,CAAA;EAAA;IAAAA,CAAA;EAAA;IAAAA,CAAA;EAAA;AAAA,CAejB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,6BAA6B,GAAIC,KAAK,IAAG;EACtD,aAAa;;EACb,MAAMC,MAAM,GAAG5C,SAAS,CAAC,CAAC;EAC1B2C,KAAK,CAAC5C,IAAI,CAAC8C,SAAS,GAAGnD,YAAY,CAACI,qBAAqB,CAACC,IAAI,EAAE6C,MAAM,CAAC7C,IAAI,EAAE4C,KAAK,CAAC5C,IAAI,CAAC8C,SAAS,CAAC;EAClG,OAAOF,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { mergeClasses, makeStyles } from '@griffel/react';
|
|
3
3
|
import { tokens, typographyStyles } from '@fluentui/react-theme';
|
|
4
|
-
import { createSlideStyles } from '@fluentui/react-positioning';
|
|
5
4
|
export const menuPopoverClassNames = {
|
|
6
5
|
root: 'fui-MenuPopover'
|
|
7
6
|
};
|
|
@@ -18,8 +17,7 @@ const useStyles = makeStyles({
|
|
|
18
17
|
boxShadow: `${tokens.shadow16}`,
|
|
19
18
|
padding: '4px',
|
|
20
19
|
border: `1px solid ${tokens.colorTransparentStroke}`,
|
|
21
|
-
...typographyStyles.body1
|
|
22
|
-
...createSlideStyles(10)
|
|
20
|
+
...typographyStyles.body1
|
|
23
21
|
}
|
|
24
22
|
});
|
|
25
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/MenuPopover/useMenuPopoverStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { mergeClasses, makeStyles } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport type { MenuPopoverSlots, MenuPopoverState } from './MenuPopover.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\
|
|
1
|
+
{"version":3,"sources":["../src/components/MenuPopover/useMenuPopoverStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { mergeClasses, makeStyles } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport type { MenuPopoverSlots, MenuPopoverState } from './MenuPopover.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const menuPopoverClassNames: SlotClassNames<MenuPopoverSlots> = {\n root: 'fui-MenuPopover',\n};\n\nconst useStyles = makeStyles({\n root: {\n borderRadius: tokens.borderRadiusMedium,\n backgroundColor: tokens.colorNeutralBackground1,\n color: tokens.colorNeutralForeground1,\n boxSizing: 'border-box',\n minWidth: '138px',\n maxWidth: '300px',\n overflowX: 'hidden',\n width: 'max-content',\n boxShadow: `${tokens.shadow16}`,\n padding: '4px',\n border: `1px solid ${tokens.colorTransparentStroke}`,\n ...typographyStyles.body1,\n },\n});\n\n/**\n * Apply styling to the Menu slots based on the state\n */\nexport const useMenuPopoverStyles_unstable = (state: MenuPopoverState): MenuPopoverState => {\n 'use no memo';\n\n const styles = useStyles();\n state.root.className = mergeClasses(menuPopoverClassNames.root, styles.root, state.root.className);\n return state;\n};\n"],"names":["mergeClasses","makeStyles","tokens","typographyStyles","menuPopoverClassNames","root","useStyles","borderRadius","borderRadiusMedium","backgroundColor","colorNeutralBackground1","color","colorNeutralForeground1","boxSizing","minWidth","maxWidth","overflowX","width","boxShadow","shadow16","padding","border","colorTransparentStroke","body1","useMenuPopoverStyles_unstable","state","styles","className"],"mappings":"AAAA;AAEA,SAASA,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAC1D,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,wBAAwB;AAIjE,OAAO,MAAMC,wBAA0D;IACrEC,MAAM;AACR,EAAE;AAEF,MAAMC,YAAYL,WAAW;IAC3BI,MAAM;QACJE,cAAcL,OAAOM,kBAAkB;QACvCC,iBAAiBP,OAAOQ,uBAAuB;QAC/CC,OAAOT,OAAOU,uBAAuB;QACrCC,WAAW;QACXC,UAAU;QACVC,UAAU;QACVC,WAAW;QACXC,OAAO;QACPC,WAAW,GAAGhB,OAAOiB,QAAQ,EAAE;QAC/BC,SAAS;QACTC,QAAQ,CAAC,UAAU,EAAEnB,OAAOoB,sBAAsB,EAAE;QACpD,GAAGnB,iBAAiBoB,KAAK;IAC3B;AACF;AAEA;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C;IAEA,MAAMC,SAASpB;IACfmB,MAAMpB,IAAI,CAACsB,SAAS,GAAG3B,aAAaI,sBAAsBC,IAAI,EAAEqB,OAAOrB,IAAI,EAAEoB,MAAMpB,IAAI,CAACsB,SAAS;IACjG,OAAOF;AACT,EAAE"}
|