@fluentui/react-menu 9.4.0 → 9.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. package/CHANGELOG.json +143 -1
  2. package/CHANGELOG.md +36 -2
  3. package/dist/index.d.ts +46 -5
  4. package/lib/components/Menu/Menu.types.js.map +1 -1
  5. package/lib/components/Menu/useMenu.js +13 -7
  6. package/lib/components/Menu/useMenu.js.map +1 -1
  7. package/lib/components/MenuItem/useMenuItem.js +3 -1
  8. package/lib/components/MenuItem/useMenuItem.js.map +1 -1
  9. package/lib/components/MenuPopover/useMenuPopover.js +20 -14
  10. package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
  11. package/lib/components/MenuTrigger/MenuTrigger.types.js.map +1 -1
  12. package/lib/components/MenuTrigger/useMenuTrigger.js +46 -31
  13. package/lib/components/MenuTrigger/useMenuTrigger.js.map +1 -1
  14. package/lib/index.js.map +1 -1
  15. package/lib-amd/Menu.js +6 -0
  16. package/lib-amd/Menu.js.map +1 -0
  17. package/lib-amd/MenuDivider.js +6 -0
  18. package/lib-amd/MenuDivider.js.map +1 -0
  19. package/lib-amd/MenuGroup.js +6 -0
  20. package/lib-amd/MenuGroup.js.map +1 -0
  21. package/lib-amd/MenuGroupHeader.js +6 -0
  22. package/lib-amd/MenuGroupHeader.js.map +1 -0
  23. package/lib-amd/MenuItem.js +6 -0
  24. package/lib-amd/MenuItem.js.map +1 -0
  25. package/lib-amd/MenuItemCheckbox.js +6 -0
  26. package/lib-amd/MenuItemCheckbox.js.map +1 -0
  27. package/lib-amd/MenuItemRadio.js +6 -0
  28. package/lib-amd/MenuItemRadio.js.map +1 -0
  29. package/lib-amd/MenuList.js +6 -0
  30. package/lib-amd/MenuList.js.map +1 -0
  31. package/lib-amd/MenuPopover.js +6 -0
  32. package/lib-amd/MenuPopover.js.map +1 -0
  33. package/lib-amd/MenuSplitGroup.js +6 -0
  34. package/lib-amd/MenuSplitGroup.js.map +1 -0
  35. package/lib-amd/MenuTrigger.js +6 -0
  36. package/lib-amd/MenuTrigger.js.map +1 -0
  37. package/lib-amd/components/Menu/Menu.js +16 -0
  38. package/lib-amd/components/Menu/Menu.js.map +1 -0
  39. package/lib-amd/components/Menu/Menu.types.js +5 -0
  40. package/lib-amd/components/Menu/Menu.types.js.map +1 -0
  41. package/lib-amd/components/Menu/index.js +10 -0
  42. package/lib-amd/components/Menu/index.js.map +1 -0
  43. package/lib-amd/components/Menu/renderMenu.js +15 -0
  44. package/lib-amd/components/Menu/renderMenu.js.map +1 -0
  45. package/lib-amd/components/Menu/useMenu.js +233 -0
  46. package/lib-amd/components/Menu/useMenu.js.map +1 -0
  47. package/lib-amd/components/Menu/useMenuContextValues.js +29 -0
  48. package/lib-amd/components/Menu/useMenuContextValues.js.map +1 -0
  49. package/lib-amd/components/MenuDivider/MenuDivider.js +15 -0
  50. package/lib-amd/components/MenuDivider/MenuDivider.js.map +1 -0
  51. package/lib-amd/components/MenuDivider/MenuDivider.types.js +5 -0
  52. package/lib-amd/components/MenuDivider/MenuDivider.types.js.map +1 -0
  53. package/lib-amd/components/MenuDivider/index.js +10 -0
  54. package/lib-amd/components/MenuDivider/index.js.map +1 -0
  55. package/lib-amd/components/MenuDivider/renderMenuDivider.js +15 -0
  56. package/lib-amd/components/MenuDivider/renderMenuDivider.js.map +1 -0
  57. package/lib-amd/components/MenuDivider/useMenuDivider.js +18 -0
  58. package/lib-amd/components/MenuDivider/useMenuDivider.js.map +1 -0
  59. package/lib-amd/components/MenuDivider/useMenuDividerStyles.js +18 -0
  60. package/lib-amd/components/MenuDivider/useMenuDividerStyles.js.map +1 -0
  61. package/lib-amd/components/MenuGroup/MenuGroup.js +16 -0
  62. package/lib-amd/components/MenuGroup/MenuGroup.js.map +1 -0
  63. package/lib-amd/components/MenuGroup/MenuGroup.types.js +5 -0
  64. package/lib-amd/components/MenuGroup/MenuGroup.types.js.map +1 -0
  65. package/lib-amd/components/MenuGroup/index.js +11 -0
  66. package/lib-amd/components/MenuGroup/index.js.map +1 -0
  67. package/lib-amd/components/MenuGroup/renderMenuGroup.js +16 -0
  68. package/lib-amd/components/MenuGroup/renderMenuGroup.js.map +1 -0
  69. package/lib-amd/components/MenuGroup/useMenuGroup.js +20 -0
  70. package/lib-amd/components/MenuGroup/useMenuGroup.js.map +1 -0
  71. package/lib-amd/components/MenuGroup/useMenuGroupContextValues.js +12 -0
  72. package/lib-amd/components/MenuGroup/useMenuGroupContextValues.js.map +1 -0
  73. package/lib-amd/components/MenuGroup/useMenuGroupStyles.js +14 -0
  74. package/lib-amd/components/MenuGroup/useMenuGroupStyles.js.map +1 -0
  75. package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.js +15 -0
  76. package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -0
  77. package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.types.js +5 -0
  78. package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.types.js.map +1 -0
  79. package/lib-amd/components/MenuGroupHeader/index.js +10 -0
  80. package/lib-amd/components/MenuGroupHeader/index.js.map +1 -0
  81. package/lib-amd/components/MenuGroupHeader/renderMenuGroupHeader.js +15 -0
  82. package/lib-amd/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -0
  83. package/lib-amd/components/MenuGroupHeader/useMenuGroupHeader.js +19 -0
  84. package/lib-amd/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -0
  85. package/lib-amd/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +27 -0
  86. package/lib-amd/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -0
  87. package/lib-amd/components/MenuItem/MenuItem.js +15 -0
  88. package/lib-amd/components/MenuItem/MenuItem.js.map +1 -0
  89. package/lib-amd/components/MenuItem/MenuItem.types.js +5 -0
  90. package/lib-amd/components/MenuItem/MenuItem.types.js.map +1 -0
  91. package/lib-amd/components/MenuItem/index.js +10 -0
  92. package/lib-amd/components/MenuItem/index.js.map +1 -0
  93. package/lib-amd/components/MenuItem/renderMenuItem.js +19 -0
  94. package/lib-amd/components/MenuItem/renderMenuItem.js.map +1 -0
  95. package/lib-amd/components/MenuItem/useCharacterSearch.js +22 -0
  96. package/lib-amd/components/MenuItem/useCharacterSearch.js.map +1 -0
  97. package/lib-amd/components/MenuItem/useMenuItem.js +80 -0
  98. package/lib-amd/components/MenuItem/useMenuItem.js.map +1 -0
  99. package/lib-amd/components/MenuItem/useMenuItemStyles.js +100 -0
  100. package/lib-amd/components/MenuItem/useMenuItemStyles.js.map +1 -0
  101. package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.js +15 -0
  102. package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -0
  103. package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.types.js +5 -0
  104. package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.types.js.map +1 -0
  105. package/lib-amd/components/MenuItemCheckbox/index.js +10 -0
  106. package/lib-amd/components/MenuItemCheckbox/index.js.map +1 -0
  107. package/lib-amd/components/MenuItemCheckbox/renderMenuItemCheckbox.js +16 -0
  108. package/lib-amd/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -0
  109. package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckbox.js +26 -0
  110. package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -0
  111. package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +31 -0
  112. package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -0
  113. package/lib-amd/components/MenuItemRadio/MenuItemRadio.js +15 -0
  114. package/lib-amd/components/MenuItemRadio/MenuItemRadio.js.map +1 -0
  115. package/lib-amd/components/MenuItemRadio/MenuItemRadio.types.js +5 -0
  116. package/lib-amd/components/MenuItemRadio/MenuItemRadio.types.js.map +1 -0
  117. package/lib-amd/components/MenuItemRadio/index.js +10 -0
  118. package/lib-amd/components/MenuItemRadio/index.js.map +1 -0
  119. package/lib-amd/components/MenuItemRadio/renderMenuItemRadio.js +19 -0
  120. package/lib-amd/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -0
  121. package/lib-amd/components/MenuItemRadio/useMenuItemRadio.js +27 -0
  122. package/lib-amd/components/MenuItemRadio/useMenuItemRadio.js.map +1 -0
  123. package/lib-amd/components/MenuItemRadio/useMenuItemRadioStyles.js +31 -0
  124. package/lib-amd/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -0
  125. package/lib-amd/components/MenuList/MenuList.js +16 -0
  126. package/lib-amd/components/MenuList/MenuList.js.map +1 -0
  127. package/lib-amd/components/MenuList/MenuList.types.js +5 -0
  128. package/lib-amd/components/MenuList/MenuList.types.js.map +1 -0
  129. package/lib-amd/components/MenuList/index.js +11 -0
  130. package/lib-amd/components/MenuList/index.js.map +1 -0
  131. package/lib-amd/components/MenuList/renderMenuList.js +15 -0
  132. package/lib-amd/components/MenuList/renderMenuList.js.map +1 -0
  133. package/lib-amd/components/MenuList/useMenuList.js +119 -0
  134. package/lib-amd/components/MenuList/useMenuList.js.map +1 -0
  135. package/lib-amd/components/MenuList/useMenuListContextValues.js +21 -0
  136. package/lib-amd/components/MenuList/useMenuListContextValues.js.map +1 -0
  137. package/lib-amd/components/MenuList/useMenuListStyles.js +21 -0
  138. package/lib-amd/components/MenuList/useMenuListStyles.js.map +1 -0
  139. package/lib-amd/components/MenuPopover/MenuPopover.js +15 -0
  140. package/lib-amd/components/MenuPopover/MenuPopover.js.map +1 -0
  141. package/lib-amd/components/MenuPopover/MenuPopover.types.js +5 -0
  142. package/lib-amd/components/MenuPopover/MenuPopover.types.js.map +1 -0
  143. package/lib-amd/components/MenuPopover/index.js +10 -0
  144. package/lib-amd/components/MenuPopover/index.js.map +1 -0
  145. package/lib-amd/components/MenuPopover/renderMenuPopover.js +18 -0
  146. package/lib-amd/components/MenuPopover/renderMenuPopover.js.map +1 -0
  147. package/lib-amd/components/MenuPopover/useMenuPopover.js +82 -0
  148. package/lib-amd/components/MenuPopover/useMenuPopover.js.map +1 -0
  149. package/lib-amd/components/MenuPopover/useMenuPopoverStyles.js +21 -0
  150. package/lib-amd/components/MenuPopover/useMenuPopoverStyles.js.map +1 -0
  151. package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.js +15 -0
  152. package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -0
  153. package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.types.js +5 -0
  154. package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.types.js.map +1 -0
  155. package/lib-amd/components/MenuSplitGroup/index.js +10 -0
  156. package/lib-amd/components/MenuSplitGroup/index.js.map +1 -0
  157. package/lib-amd/components/MenuSplitGroup/renderMenuSplitGroup.js +14 -0
  158. package/lib-amd/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -0
  159. package/lib-amd/components/MenuSplitGroup/useMenuSplitGroup.js +47 -0
  160. package/lib-amd/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -0
  161. package/lib-amd/components/MenuSplitGroup/useMenuSplitGroupStyles.js +43 -0
  162. package/lib-amd/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -0
  163. package/lib-amd/components/MenuTrigger/MenuTrigger.js +18 -0
  164. package/lib-amd/components/MenuTrigger/MenuTrigger.js.map +1 -0
  165. package/lib-amd/components/MenuTrigger/MenuTrigger.types.js +5 -0
  166. package/lib-amd/components/MenuTrigger/MenuTrigger.types.js.map +1 -0
  167. package/lib-amd/components/MenuTrigger/index.js +9 -0
  168. package/lib-amd/components/MenuTrigger/index.js.map +1 -0
  169. package/lib-amd/components/MenuTrigger/renderMenuTrigger.js +15 -0
  170. package/lib-amd/components/MenuTrigger/renderMenuTrigger.js.map +1 -0
  171. package/lib-amd/components/MenuTrigger/useMenuTrigger.js +112 -0
  172. package/lib-amd/components/MenuTrigger/useMenuTrigger.js.map +1 -0
  173. package/lib-amd/components/index.js +7 -0
  174. package/lib-amd/components/index.js.map +1 -0
  175. package/lib-amd/contexts/menuContext.js +32 -0
  176. package/lib-amd/contexts/menuContext.js.map +1 -0
  177. package/lib-amd/contexts/menuGroupContext.js +13 -0
  178. package/lib-amd/contexts/menuGroupContext.js.map +1 -0
  179. package/lib-amd/contexts/menuListContext.js +24 -0
  180. package/lib-amd/contexts/menuListContext.js.map +1 -0
  181. package/lib-amd/contexts/menuTriggerContext.js +14 -0
  182. package/lib-amd/contexts/menuTriggerContext.js.map +1 -0
  183. package/lib-amd/index.js +69 -0
  184. package/lib-amd/index.js.map +1 -0
  185. package/lib-amd/selectable/index.js +7 -0
  186. package/lib-amd/selectable/index.js.map +1 -0
  187. package/lib-amd/selectable/types.js +5 -0
  188. package/lib-amd/selectable/types.js.map +1 -0
  189. package/lib-amd/selectable/useCheckmarkStyles.js +28 -0
  190. package/lib-amd/selectable/useCheckmarkStyles.js.map +1 -0
  191. package/lib-amd/utils/index.js +6 -0
  192. package/lib-amd/utils/index.js.map +1 -0
  193. package/lib-amd/utils/useIsSubmenu.js +20 -0
  194. package/lib-amd/utils/useIsSubmenu.js.map +1 -0
  195. package/lib-amd/utils/useOnMenuEnter.js +59 -0
  196. package/lib-amd/utils/useOnMenuEnter.js.map +1 -0
  197. package/lib-commonjs/components/Menu/useMenu.js +13 -7
  198. package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
  199. package/lib-commonjs/components/MenuItem/useMenuItem.js +3 -1
  200. package/lib-commonjs/components/MenuItem/useMenuItem.js.map +1 -1
  201. package/lib-commonjs/components/MenuPopover/useMenuPopover.js +20 -14
  202. package/lib-commonjs/components/MenuPopover/useMenuPopover.js.map +1 -1
  203. package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js +46 -31
  204. package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js.map +1 -1
  205. package/lib-commonjs/index.js.map +1 -1
  206. package/package.json +11 -11
@@ -41,52 +41,60 @@ export const useMenuTrigger_unstable = props => {
41
41
  const OpenArrowKey = dir === 'ltr' ? ArrowRight : ArrowLeft;
42
42
  const child = getTriggerChild(children);
43
43
 
44
- const onContextMenu = e => {
45
- if (isTargetDisabled(e)) {
44
+ const onContextMenu = event => {
45
+ if (isTargetDisabled(event)) {
46
46
  return;
47
47
  }
48
48
 
49
49
  if (openOnContext) {
50
- e.preventDefault();
51
- setOpen(e, {
50
+ event.preventDefault();
51
+ setOpen(event, {
52
52
  open: true,
53
- keyboard: false
53
+ keyboard: false,
54
+ type: 'menuTriggerContextMenu',
55
+ event
54
56
  });
55
57
  }
56
58
  };
57
59
 
58
- const onClick = e => {
59
- if (isTargetDisabled(e)) {
60
+ const onClick = event => {
61
+ if (isTargetDisabled(event)) {
60
62
  return;
61
63
  }
62
64
 
63
65
  if (!openOnContext) {
64
- setOpen(e, {
66
+ setOpen(event, {
65
67
  open: !open,
66
- keyboard: openedWithKeyboardRef.current
68
+ keyboard: openedWithKeyboardRef.current,
69
+ type: 'menuTriggerClick',
70
+ event
67
71
  });
68
72
  openedWithKeyboardRef.current = false;
69
73
  }
70
74
  };
71
75
 
72
- const onKeyDown = e => {
73
- if (isTargetDisabled(e)) {
76
+ const onKeyDown = event => {
77
+ if (isTargetDisabled(event)) {
74
78
  return;
75
79
  }
76
80
 
77
- const key = e.key;
81
+ const key = event.key;
78
82
 
79
83
  if (!openOnContext && (isSubmenu && key === OpenArrowKey || !isSubmenu && key === ArrowDown)) {
80
- setOpen(e, {
84
+ setOpen(event, {
81
85
  open: true,
82
- keyboard: true
86
+ keyboard: true,
87
+ type: 'menuTriggerKeyDown',
88
+ event
83
89
  });
84
90
  }
85
91
 
86
92
  if (key === Escape && !isSubmenu) {
87
- setOpen(e, {
93
+ setOpen(event, {
88
94
  open: false,
89
- keyboard: true
95
+ keyboard: true,
96
+ type: 'menuTriggerKeyDown',
97
+ event
90
98
  });
91
99
  } // if menu is already open, can't rely on effects to focus
92
100
 
@@ -96,15 +104,17 @@ export const useMenuTrigger_unstable = props => {
96
104
  }
97
105
  };
98
106
 
99
- const onMouseEnter = e => {
100
- if (isTargetDisabled(e)) {
107
+ const onMouseEnter = event => {
108
+ if (isTargetDisabled(event)) {
101
109
  return;
102
110
  }
103
111
 
104
112
  if (openOnHover && hasMouseMoved.current) {
105
- setOpen(e, {
113
+ setOpen(event, {
106
114
  open: true,
107
- keyboard: false
115
+ keyboard: false,
116
+ type: 'menuTriggerMouseEnter',
117
+ event
108
118
  });
109
119
  }
110
120
  }; // Opening a menu when a mouse hasn't moved and just entering the trigger is a bad a11y experience
@@ -112,36 +122,38 @@ export const useMenuTrigger_unstable = props => {
112
122
  // Only use once to determine that the user is using the mouse since it is an expensive event to handle
113
123
 
114
124
 
115
- const onMouseMove = e => {
116
- if (isTargetDisabled(e)) {
125
+ const onMouseMove = event => {
126
+ if (isTargetDisabled(event)) {
117
127
  return;
118
128
  }
119
129
 
120
130
  if (openOnHover && !hasMouseMoved.current) {
121
- setOpen(e, {
131
+ setOpen(event, {
122
132
  open: true,
123
- keyboard: false
133
+ keyboard: false,
134
+ type: 'menuTriggerMouseMove',
135
+ event
124
136
  });
125
137
  hasMouseMoved.current = true;
126
138
  }
127
139
  };
128
140
 
129
- const onMouseLeave = e => {
130
- if (isTargetDisabled(e)) {
141
+ const onMouseLeave = event => {
142
+ if (isTargetDisabled(event)) {
131
143
  return;
132
144
  }
133
145
 
134
146
  if (openOnHover) {
135
- setOpen(e, {
147
+ setOpen(event, {
136
148
  open: false,
137
- keyboard: false
149
+ keyboard: false,
150
+ type: 'menuTriggerMouseLeave',
151
+ event
138
152
  });
139
153
  }
140
154
  };
141
155
 
142
156
  const contextMenuProps = {
143
- 'aria-haspopup': 'menu',
144
- 'aria-expanded': !open && !isSubmenu ? undefined : open,
145
157
  id: triggerId,
146
158
  ...(child === null || child === void 0 ? void 0 : child.props),
147
159
  ref: useMergedRefs(triggerRef, child === null || child === void 0 ? void 0 : child.ref),
@@ -150,7 +162,10 @@ export const useMenuTrigger_unstable = props => {
150
162
  onContextMenu: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onContextMenu, onContextMenu)),
151
163
  onMouseMove: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onMouseMove, onMouseMove))
152
164
  };
153
- const triggerChildProps = { ...contextMenuProps,
165
+ const triggerChildProps = {
166
+ 'aria-haspopup': 'menu',
167
+ 'aria-expanded': !open && !isSubmenu ? undefined : open,
168
+ ...contextMenuProps,
154
169
  onClick: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onClick, onClick)),
155
170
  onKeyDown: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onKeyDown, onKeyDown))
156
171
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-menu/src/components/MenuTrigger/useMenuTrigger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA,SAAS,uBAAT,QAAwC,4BAAxC;AACA,SAAS,YAAT,QAA6B,0BAA7B;AACA,SAAS,eAAT,QAAgC,yBAAhC;AACA,SAAS,kBAAkB,IAAI,SAA/B,QAAgD,iCAAhD;AACA,SAAS,UAAT,EAAqB,SAArB,EAAgC,MAAhC,EAAwC,SAAxC,QAAyD,yBAAzD;AACA,SACE,2BADF,EAEE,eAFF,EAGE,cAHF,EAIE,gBAJF,EAKE,aALF,QAMO,2BANP;AAOA,SAAS,kBAAT,QAAmC,sBAAnC;AAEA;;;;;AAKG;;AACH,OAAO,MAAM,uBAAuB,GAAI,KAAD,IAA8C;EACnF,MAAM;IAAE,QAAF;IAAY,wBAAwB,GAAG;EAAvC,IAAiD,KAAvD;EAEA,MAAM,UAAU,GAAG,uBAAuB,CAAC,OAAO,IAAI,OAAO,CAAC,UAApB,CAA1C;EACA,MAAM,cAAc,GAAG,uBAAuB,CAAC,OAAO,IAAI,OAAO,CAAC,cAApB,CAA9C;EACA,MAAM,OAAO,GAAG,uBAAuB,CAAC,OAAO,IAAI,OAAO,CAAC,OAApB,CAAvC;EACA,MAAM,IAAI,GAAG,uBAAuB,CAAC,OAAO,IAAI,OAAO,CAAC,IAApB,CAApC;EACA,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,YAAH,CAAgB,UAAhB,KAAgC,EAAE,CAAC,YAAH,CAAgB,eAAhB,KAAoC,EAAE,CAAC,YAAH,CAAgB,eAAhB,MAAqC,MAD3G;;EAEA,IAAI,CAAC,CAAC,MAAF,YAAoB,WAApB,IAAmC,UAAU,CAAC,CAAC,CAAC,MAAH,CAAjD,EAA6D;IAC3D,OAAO,IAAP;EACD;;EAED,OAAO,CAAC,CAAC,aAAF,YAA2B,WAA3B,IAA0C,UAAU,CAAC,CAAC,CAAC,aAAH,CAA3D;AACD,CARD","sourcesContent":["import * as React from 'react';\nimport { MenuTriggerProps, MenuTriggerState } from './MenuTrigger.types';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { ArrowRight, ArrowLeft, Escape, ArrowDown } from '@fluentui/keyboard-keys';\nimport {\n applyTriggerPropsToChildren,\n getTriggerChild,\n mergeCallbacks,\n useEventCallback,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\n\n/**\n * Create the state required to render MenuTrigger.\n * Clones the only child component and adds necessary event handling behaviours to open a popup menu\n *\n * @param props - props from this instance of MenuTrigger\n */\nexport const useMenuTrigger_unstable = (props: MenuTriggerProps): MenuTriggerState => {\n const { children, disableButtonEnhancement = false } = props;\n\n const triggerRef = useMenuContext_unstable(context => context.triggerRef);\n const menuPopoverRef = useMenuContext_unstable(context => context.menuPopoverRef);\n const setOpen = useMenuContext_unstable(context => context.setOpen);\n const open = useMenuContext_unstable(context => context.open);\n const triggerId = useMenuContext_unstable(context => context.triggerId);\n const openOnHover = useMenuContext_unstable(context => context.openOnHover);\n const openOnContext = useMenuContext_unstable(context => context.openOnContext);\n\n const isSubmenu = useIsSubmenu();\n\n const { findFirstFocusable } = useFocusFinders();\n const focusFirst = React.useCallback(() => {\n const firstFocusable = findFirstFocusable(menuPopoverRef.current);\n firstFocusable?.focus();\n }, [findFirstFocusable, menuPopoverRef]);\n\n const openedWithKeyboardRef = React.useRef(false);\n const hasMouseMoved = React.useRef(false);\n\n const { dir } = useFluent();\n const OpenArrowKey = dir === 'ltr' ? ArrowRight : ArrowLeft;\n\n const child = getTriggerChild(children);\n\n const onContextMenu = (e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(e)) {\n return;\n }\n\n if (openOnContext) {\n e.preventDefault();\n setOpen(e, { open: true, keyboard: false });\n }\n };\n\n const onClick = (e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(e)) {\n return;\n }\n\n if (!openOnContext) {\n setOpen(e, { open: !open, keyboard: openedWithKeyboardRef.current });\n openedWithKeyboardRef.current = false;\n }\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(e)) {\n return;\n }\n\n const key = e.key;\n\n if (!openOnContext && ((isSubmenu && key === OpenArrowKey) || (!isSubmenu && key === ArrowDown))) {\n setOpen(e, { open: true, keyboard: true });\n }\n\n if (key === Escape && !isSubmenu) {\n setOpen(e, { open: false, keyboard: true });\n }\n\n // if menu is already open, can't rely on effects to focus\n if (open && key === OpenArrowKey && isSubmenu) {\n focusFirst();\n }\n };\n\n const onMouseEnter = (e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(e)) {\n return;\n }\n if (openOnHover && hasMouseMoved.current) {\n setOpen(e, { open: true, keyboard: false });\n }\n };\n\n // Opening a menu when a mouse hasn't moved and just entering the trigger is a bad a11y experience\n // First time open the mouse using mousemove and then continue with mouseenter\n // Only use once to determine that the user is using the mouse since it is an expensive event to handle\n const onMouseMove = (e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(e)) {\n return;\n }\n if (openOnHover && !hasMouseMoved.current) {\n setOpen(e, { open: true, keyboard: false });\n hasMouseMoved.current = true;\n }\n };\n\n const onMouseLeave = (e: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(e)) {\n return;\n }\n if (openOnHover) {\n setOpen(e, { open: false, keyboard: false });\n }\n };\n\n const contextMenuProps = {\n 'aria-haspopup': 'menu',\n 'aria-expanded': !open && !isSubmenu ? undefined : open,\n id: triggerId,\n ...child?.props,\n ref: useMergedRefs(triggerRef, child?.ref),\n onMouseEnter: useEventCallback(mergeCallbacks(child?.props.onMouseEnter, onMouseEnter)),\n onMouseLeave: useEventCallback(mergeCallbacks(child?.props.onMouseLeave, onMouseLeave)),\n onContextMenu: useEventCallback(mergeCallbacks(child?.props.onContextMenu, onContextMenu)),\n onMouseMove: useEventCallback(mergeCallbacks(child?.props.onMouseMove, onMouseMove)),\n } as const;\n\n const triggerChildProps = {\n ...contextMenuProps,\n onClick: useEventCallback(mergeCallbacks(child?.props.onClick, onClick)),\n onKeyDown: useEventCallback(mergeCallbacks(child?.props.onKeyDown, onKeyDown)),\n };\n\n const ariaButtonTriggerChildProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n triggerChildProps,\n );\n\n return {\n isSubmenu,\n children: applyTriggerPropsToChildren(\n children,\n openOnContext ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps,\n ),\n };\n};\n\nconst isTargetDisabled = (e: React.SyntheticEvent | Event) => {\n const isDisabled = (el: HTMLElement) =>\n el.hasAttribute('disabled') || (el.hasAttribute('aria-disabled') && el.getAttribute('aria-disabled') === 'true');\n if (e.target instanceof HTMLElement && isDisabled(e.target)) {\n return true;\n }\n\n return e.currentTarget instanceof HTMLElement && isDisabled(e.currentTarget);\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-menu/src/components/MenuTrigger/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,MAAqC,MAD3G;;EAEA,IAAI,CAAC,CAAC,MAAF,YAAoB,WAApB,IAAmC,UAAU,CAAC,CAAC,CAAC,MAAH,CAAjD,EAA6D;IAC3D,OAAO,IAAP;EACD;;EAED,OAAO,CAAC,CAAC,aAAF,YAA2B,WAA3B,IAA0C,UAAU,CAAC,CAAC,CAAC,aAAH,CAA3D;AACD,CARD","sourcesContent":["import * as React from 'react';\nimport { MenuTriggerProps, MenuTriggerState } from './MenuTrigger.types';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { ArrowRight, ArrowLeft, Escape, ArrowDown } from '@fluentui/keyboard-keys';\nimport {\n applyTriggerPropsToChildren,\n getTriggerChild,\n mergeCallbacks,\n useEventCallback,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\n\n/**\n * Create the state required to render MenuTrigger.\n * Clones the only child component and adds necessary event handling behaviours to open a popup menu\n *\n * @param props - props from this instance of MenuTrigger\n */\nexport const useMenuTrigger_unstable = (props: MenuTriggerProps): MenuTriggerState => {\n const { children, disableButtonEnhancement = false } = props;\n\n const triggerRef = useMenuContext_unstable(context => context.triggerRef);\n const menuPopoverRef = useMenuContext_unstable(context => context.menuPopoverRef);\n const setOpen = useMenuContext_unstable(context => context.setOpen);\n const open = useMenuContext_unstable(context => context.open);\n const triggerId = useMenuContext_unstable(context => context.triggerId);\n const openOnHover = useMenuContext_unstable(context => context.openOnHover);\n const openOnContext = useMenuContext_unstable(context => context.openOnContext);\n\n const isSubmenu = useIsSubmenu();\n\n const { findFirstFocusable } = useFocusFinders();\n const focusFirst = React.useCallback(() => {\n const firstFocusable = findFirstFocusable(menuPopoverRef.current);\n firstFocusable?.focus();\n }, [findFirstFocusable, menuPopoverRef]);\n\n const openedWithKeyboardRef = React.useRef(false);\n const hasMouseMoved = React.useRef(false);\n\n const { dir } = useFluent();\n const OpenArrowKey = dir === 'ltr' ? ArrowRight : ArrowLeft;\n\n const child = getTriggerChild(children);\n\n const onContextMenu = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n\n if (openOnContext) {\n event.preventDefault();\n setOpen(event, { open: true, keyboard: false, type: 'menuTriggerContextMenu', event });\n }\n };\n\n const onClick = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n\n if (!openOnContext) {\n setOpen(event, { open: !open, keyboard: openedWithKeyboardRef.current, type: 'menuTriggerClick', event });\n openedWithKeyboardRef.current = false;\n }\n };\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n\n const key = event.key;\n\n if (!openOnContext && ((isSubmenu && key === OpenArrowKey) || (!isSubmenu && key === ArrowDown))) {\n setOpen(event, { open: true, keyboard: true, type: 'menuTriggerKeyDown', event });\n }\n\n if (key === Escape && !isSubmenu) {\n setOpen(event, { open: false, keyboard: true, type: 'menuTriggerKeyDown', event });\n }\n\n // if menu is already open, can't rely on effects to focus\n if (open && key === OpenArrowKey && isSubmenu) {\n focusFirst();\n }\n };\n\n const onMouseEnter = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover && hasMouseMoved.current) {\n setOpen(event, { open: true, keyboard: false, type: 'menuTriggerMouseEnter', event });\n }\n };\n\n // Opening a menu when a mouse hasn't moved and just entering the trigger is a bad a11y experience\n // First time open the mouse using mousemove and then continue with mouseenter\n // Only use once to determine that the user is using the mouse since it is an expensive event to handle\n const onMouseMove = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover && !hasMouseMoved.current) {\n setOpen(event, { open: true, keyboard: false, type: 'menuTriggerMouseMove', event });\n hasMouseMoved.current = true;\n }\n };\n\n const onMouseLeave = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover) {\n setOpen(event, { open: false, keyboard: false, type: 'menuTriggerMouseLeave', event });\n }\n };\n\n const contextMenuProps = {\n id: triggerId,\n ...child?.props,\n ref: useMergedRefs(triggerRef, child?.ref),\n onMouseEnter: useEventCallback(mergeCallbacks(child?.props.onMouseEnter, onMouseEnter)),\n onMouseLeave: useEventCallback(mergeCallbacks(child?.props.onMouseLeave, onMouseLeave)),\n onContextMenu: useEventCallback(mergeCallbacks(child?.props.onContextMenu, onContextMenu)),\n onMouseMove: useEventCallback(mergeCallbacks(child?.props.onMouseMove, onMouseMove)),\n };\n\n const triggerChildProps = {\n 'aria-haspopup': 'menu',\n 'aria-expanded': !open && !isSubmenu ? undefined : open,\n ...contextMenuProps,\n onClick: useEventCallback(mergeCallbacks(child?.props.onClick, onClick)),\n onKeyDown: useEventCallback(mergeCallbacks(child?.props.onKeyDown, onKeyDown)),\n } as const;\n\n const ariaButtonTriggerChildProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n triggerChildProps,\n );\n\n return {\n isSubmenu,\n children: applyTriggerPropsToChildren(\n children,\n openOnContext ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps,\n ),\n };\n};\n\nconst isTargetDisabled = (e: React.SyntheticEvent | Event) => {\n const isDisabled = (el: HTMLElement) =>\n el.hasAttribute('disabled') || (el.hasAttribute('aria-disabled') && el.getAttribute('aria-disabled') === 'true');\n if (e.target instanceof HTMLElement && isDisabled(e.target)) {\n return true;\n }\n\n return e.currentTarget instanceof HTMLElement && isDisabled(e.currentTarget);\n};\n"],"sourceRoot":"../src/"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-menu/src/index.ts"],"names":[],"mappings":"AAAA,SAAS,YAAT,EAAuB,uBAAvB,QAAsD,wBAAtD;AAEA,SAAS,0BAAT,EAAqC,8BAArC,QAA2E,+BAA3E;AACA,SAAS,wBAAT,EAAmC,4BAAnC,QAAuE,6BAAvE;AAEA,SAAS,gBAAT,EAA2B,2BAA3B,QAA8D,4BAA9D;AAGA,SAAS,IAAT,EAAe,mBAAf,EAAoC,6BAApC,EAAmE,gBAAnE,QAA2F,QAA3F;AAEA,SACE,WADF,EAEE,qBAFF,EAGE,0BAHF,EAIE,6BAJF,EAKE,uBALF,QAMO,eANP;AAQA,SACE,SADF,EAEE,mBAFF,EAGE,wBAHF,EAIE,kCAJF,EAKE,2BALF,EAME,qBANF,QAOO,aAPP;AASA,SACE,eADF,EAEE,yBAFF,EAGE,8BAHF,EAIE,iCAJF,EAKE,2BALF,QAMO,mBANP;AAQA,SACE,QADF,EAEE,kBAFF,EAGE,uBAHF,EAIE,0BAJF,EAKE,oBALF,QAMO,YANP;AAQA,SACE,gBADF,EAEE,0BAFF,EAGE,+BAHF,EAIE,kCAJF,EAKE,4BALF,QAMO,oBANP;AAQA,SACE,aADF,EAEE,uBAFF,EAGE,4BAHF,EAIE,+BAJF,EAKE,yBALF,QAMO,iBANP;AAQA,SACE,QADF,EAEE,kBAFF,EAGE,uBAHF,EAIE,iCAJF,EAKE,0BALF,EAME,oBANF,QAOO,YAPP;AAiBA,SACE,WADF,EAEE,qBAFF,EAGE,0BAHF,EAIE,6BAJF,EAKE,uBALF,QAMO,eANP;AAQA,SACE,cADF,EAEE,wBAFF,EAGE,6BAHF,EAIE,gCAJF,EAKE,0BALF,QAMO,kBANP;AAQA,SAAS,WAAT,EAAsB,0BAAtB,EAAkD,uBAAlD,QAAiF,eAAjF;AAGA,SAAS,2BAAT,QAA4C,oBAA5C","sourcesContent":["export { MenuProvider, useMenuContext_unstable } from './contexts/menuContext';\nexport type { MenuContextValue } from './contexts/menuContext';\nexport { MenuTriggerContextProvider, useMenuTriggerContext_unstable } from './contexts/menuTriggerContext';\nexport { MenuGroupContextProvider, useMenuGroupContext_unstable } from './contexts/menuGroupContext';\nexport type { MenuGroupContextValue } from './contexts/menuGroupContext';\nexport { MenuListProvider, useMenuListContext_unstable } from './contexts/menuListContext';\nexport type { MenuListContextValue } from './contexts/menuListContext';\n\nexport { Menu, renderMenu_unstable, useMenuContextValues_unstable, useMenu_unstable } from './Menu';\nexport type { MenuContextValues, MenuOpenChangeData, MenuOpenEvents, MenuProps, MenuSlots, MenuState } from './Menu';\nexport {\n MenuDivider,\n menuDividerClassNames,\n renderMenuDivider_unstable,\n useMenuDividerStyles_unstable,\n useMenuDivider_unstable,\n} from './MenuDivider';\nexport type { MenuDividerProps, MenuDividerSlots, MenuDividerState } from './MenuDivider';\nexport {\n MenuGroup,\n menuGroupClassNames,\n renderMenuGroup_unstable,\n useMenuGroupContextValues_unstable,\n useMenuGroupStyles_unstable,\n useMenuGroup_unstable,\n} from './MenuGroup';\nexport type { MenuGroupContextValues, MenuGroupProps, MenuGroupSlots, MenuGroupState } from './MenuGroup';\nexport {\n MenuGroupHeader,\n menuGroupHeaderClassNames,\n renderMenuGroupHeader_unstable,\n useMenuGroupHeaderStyles_unstable,\n useMenuGroupHeader_unstable,\n} from './MenuGroupHeader';\nexport type { MenuGroupHeaderProps, MenuGroupHeaderSlots, MenuGroupHeaderState } from './MenuGroupHeader';\nexport {\n MenuItem,\n menuItemClassNames,\n renderMenuItem_unstable,\n useMenuItemStyles_unstable,\n useMenuItem_unstable,\n} from './MenuItem';\nexport type { MenuItemProps, MenuItemSlots, MenuItemState } from './MenuItem';\nexport {\n MenuItemCheckbox,\n menuItemCheckboxClassNames,\n renderMenuItemCheckbox_unstable,\n useMenuItemCheckboxStyles_unstable,\n useMenuItemCheckbox_unstable,\n} from './MenuItemCheckbox';\nexport type { MenuItemCheckboxProps, MenuItemCheckboxState } from './MenuItemCheckbox';\nexport {\n MenuItemRadio,\n menuItemRadioClassNames,\n renderMenuItemRadio_unstable,\n useMenuItemRadioStyles_unstable,\n useMenuItemRadio_unstable,\n} from './MenuItemRadio';\nexport type { MenuItemRadioProps, MenuItemRadioState } from './MenuItemRadio';\nexport {\n MenuList,\n menuListClassNames,\n renderMenuList_unstable,\n useMenuListContextValues_unstable,\n useMenuListStyles_unstable,\n useMenuList_unstable,\n} from './MenuList';\nexport type {\n MenuCheckedValueChangeData,\n MenuCheckedValueChangeEvent,\n MenuListContextValues,\n MenuListProps,\n MenuListSlots,\n MenuListState,\n UninitializedMenuListState,\n} from './MenuList';\nexport {\n MenuPopover,\n menuPopoverClassNames,\n renderMenuPopover_unstable,\n useMenuPopoverStyles_unstable,\n useMenuPopover_unstable,\n} from './MenuPopover';\nexport type { MenuPopoverProps, MenuPopoverSlots, MenuPopoverState } from './MenuPopover';\nexport {\n MenuSplitGroup,\n menuSplitGroupClassNames,\n renderMenuSplitGroup_unstable,\n useMenuSplitGroupStyles_unstable,\n useMenuSplitGroup_unstable,\n} from './MenuSplitGroup';\nexport type { MenuSplitGroupProps, MenuSplitGroupSlots, MenuSplitGroupState } from './MenuSplitGroup';\nexport { MenuTrigger, renderMenuTrigger_unstable, useMenuTrigger_unstable } from './MenuTrigger';\nexport type { MenuTriggerChildProps, MenuTriggerProps, MenuTriggerState } from './MenuTrigger';\n\nexport { useCheckmarkStyles_unstable } from './selectable/index';\nexport type { MenuItemSelectableProps, MenuItemSelectableState, SelectableHandler } from './selectable/index';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-menu/src/index.ts"],"names":[],"mappings":"AAAA,SAAS,YAAT,EAAuB,uBAAvB,QAAsD,wBAAtD;AAEA,SAAS,0BAAT,EAAqC,8BAArC,QAA2E,+BAA3E;AACA,SAAS,wBAAT,EAAmC,4BAAnC,QAAuE,6BAAvE;AAEA,SAAS,gBAAT,EAA2B,2BAA3B,QAA8D,4BAA9D;AAGA,SAAS,IAAT,EAAe,mBAAf,EAAoC,6BAApC,EAAmE,gBAAnE,QAA2F,QAA3F;AAYA,SACE,WADF,EAEE,qBAFF,EAGE,0BAHF,EAIE,6BAJF,EAKE,uBALF,QAMO,eANP;AAQA,SACE,SADF,EAEE,mBAFF,EAGE,wBAHF,EAIE,kCAJF,EAKE,2BALF,EAME,qBANF,QAOO,aAPP;AASA,SACE,eADF,EAEE,yBAFF,EAGE,8BAHF,EAIE,iCAJF,EAKE,2BALF,QAMO,mBANP;AAQA,SACE,QADF,EAEE,kBAFF,EAGE,uBAHF,EAIE,0BAJF,EAKE,oBALF,QAMO,YANP;AAQA,SACE,gBADF,EAEE,0BAFF,EAGE,+BAHF,EAIE,kCAJF,EAKE,4BALF,QAMO,oBANP;AAQA,SACE,aADF,EAEE,uBAFF,EAGE,4BAHF,EAIE,+BAJF,EAKE,yBALF,QAMO,iBANP;AAQA,SACE,QADF,EAEE,kBAFF,EAGE,uBAHF,EAIE,iCAJF,EAKE,0BALF,EAME,oBANF,QAOO,YAPP;AAiBA,SACE,WADF,EAEE,qBAFF,EAGE,0BAHF,EAIE,6BAJF,EAKE,uBALF,QAMO,eANP;AAQA,SACE,cADF,EAEE,wBAFF,EAGE,6BAHF,EAIE,gCAJF,EAKE,0BALF,QAMO,kBANP;AAQA,SAAS,WAAT,EAAsB,0BAAtB,EAAkD,uBAAlD,QAAiF,eAAjF;AAGA,SAAS,2BAAT,QAA4C,oBAA5C","sourcesContent":["export { MenuProvider, useMenuContext_unstable } from './contexts/menuContext';\nexport type { MenuContextValue } from './contexts/menuContext';\nexport { MenuTriggerContextProvider, useMenuTriggerContext_unstable } from './contexts/menuTriggerContext';\nexport { MenuGroupContextProvider, useMenuGroupContext_unstable } from './contexts/menuGroupContext';\nexport type { MenuGroupContextValue } from './contexts/menuGroupContext';\nexport { MenuListProvider, useMenuListContext_unstable } from './contexts/menuListContext';\nexport type { MenuListContextValue } from './contexts/menuListContext';\n\nexport { Menu, renderMenu_unstable, useMenuContextValues_unstable, useMenu_unstable } from './Menu';\nexport type {\n MenuContextValues,\n MenuOpenChangeData,\n MenuOpenEvent,\n // MenuOpenEvents is deprecated but removing it would be a breaking change\n // eslint-disable-next-line deprecation/deprecation\n MenuOpenEvents,\n MenuProps,\n MenuSlots,\n MenuState,\n} from './Menu';\nexport {\n MenuDivider,\n menuDividerClassNames,\n renderMenuDivider_unstable,\n useMenuDividerStyles_unstable,\n useMenuDivider_unstable,\n} from './MenuDivider';\nexport type { MenuDividerProps, MenuDividerSlots, MenuDividerState } from './MenuDivider';\nexport {\n MenuGroup,\n menuGroupClassNames,\n renderMenuGroup_unstable,\n useMenuGroupContextValues_unstable,\n useMenuGroupStyles_unstable,\n useMenuGroup_unstable,\n} from './MenuGroup';\nexport type { MenuGroupContextValues, MenuGroupProps, MenuGroupSlots, MenuGroupState } from './MenuGroup';\nexport {\n MenuGroupHeader,\n menuGroupHeaderClassNames,\n renderMenuGroupHeader_unstable,\n useMenuGroupHeaderStyles_unstable,\n useMenuGroupHeader_unstable,\n} from './MenuGroupHeader';\nexport type { MenuGroupHeaderProps, MenuGroupHeaderSlots, MenuGroupHeaderState } from './MenuGroupHeader';\nexport {\n MenuItem,\n menuItemClassNames,\n renderMenuItem_unstable,\n useMenuItemStyles_unstable,\n useMenuItem_unstable,\n} from './MenuItem';\nexport type { MenuItemProps, MenuItemSlots, MenuItemState } from './MenuItem';\nexport {\n MenuItemCheckbox,\n menuItemCheckboxClassNames,\n renderMenuItemCheckbox_unstable,\n useMenuItemCheckboxStyles_unstable,\n useMenuItemCheckbox_unstable,\n} from './MenuItemCheckbox';\nexport type { MenuItemCheckboxProps, MenuItemCheckboxState } from './MenuItemCheckbox';\nexport {\n MenuItemRadio,\n menuItemRadioClassNames,\n renderMenuItemRadio_unstable,\n useMenuItemRadioStyles_unstable,\n useMenuItemRadio_unstable,\n} from './MenuItemRadio';\nexport type { MenuItemRadioProps, MenuItemRadioState } from './MenuItemRadio';\nexport {\n MenuList,\n menuListClassNames,\n renderMenuList_unstable,\n useMenuListContextValues_unstable,\n useMenuListStyles_unstable,\n useMenuList_unstable,\n} from './MenuList';\nexport type {\n MenuCheckedValueChangeData,\n MenuCheckedValueChangeEvent,\n MenuListContextValues,\n MenuListProps,\n MenuListSlots,\n MenuListState,\n UninitializedMenuListState,\n} from './MenuList';\nexport {\n MenuPopover,\n menuPopoverClassNames,\n renderMenuPopover_unstable,\n useMenuPopoverStyles_unstable,\n useMenuPopover_unstable,\n} from './MenuPopover';\nexport type { MenuPopoverProps, MenuPopoverSlots, MenuPopoverState } from './MenuPopover';\nexport {\n MenuSplitGroup,\n menuSplitGroupClassNames,\n renderMenuSplitGroup_unstable,\n useMenuSplitGroupStyles_unstable,\n useMenuSplitGroup_unstable,\n} from './MenuSplitGroup';\nexport type { MenuSplitGroupProps, MenuSplitGroupSlots, MenuSplitGroupState } from './MenuSplitGroup';\nexport { MenuTrigger, renderMenuTrigger_unstable, useMenuTrigger_unstable } from './MenuTrigger';\nexport type { MenuTriggerChildProps, MenuTriggerProps, MenuTriggerState } from './MenuTrigger';\n\nexport { useCheckmarkStyles_unstable } from './selectable/index';\nexport type { MenuItemSelectableProps, MenuItemSelectableState, SelectableHandler } from './selectable/index';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/Menu/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=Menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-menu/src/Menu.ts"],"names":[],"mappings":";;;IAAA,uCAAwC","sourcesContent":["export * from './components/Menu/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/MenuDivider/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=MenuDivider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuDivider.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-menu/src/MenuDivider.ts"],"names":[],"mappings":";;;IAAA,uCAA+C","sourcesContent":["export * from './components/MenuDivider/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/MenuGroup/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=MenuGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuGroup.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-menu/src/MenuGroup.ts"],"names":[],"mappings":";;;IAAA,uCAA6C","sourcesContent":["export * from './components/MenuGroup/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/MenuGroupHeader/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=MenuGroupHeader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuGroupHeader.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-menu/src/MenuGroupHeader.ts"],"names":[],"mappings":";;;IAAA,uCAAmD","sourcesContent":["export * from './components/MenuGroupHeader/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/MenuItem/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=MenuItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItem.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-menu/src/MenuItem.ts"],"names":[],"mappings":";;;IAAA,uCAA4C","sourcesContent":["export * from './components/MenuItem/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/MenuItemCheckbox/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=MenuItemCheckbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItemCheckbox.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-menu/src/MenuItemCheckbox.ts"],"names":[],"mappings":";;;IAAA,uCAAoD","sourcesContent":["export * from './components/MenuItemCheckbox/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/MenuItemRadio/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=MenuItemRadio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItemRadio.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-menu/src/MenuItemRadio.ts"],"names":[],"mappings":";;;IAAA,uCAAiD","sourcesContent":["export * from './components/MenuItemRadio/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/MenuList/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=MenuList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuList.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-menu/src/MenuList.ts"],"names":[],"mappings":";;;IAAA,uCAA4C","sourcesContent":["export * from './components/MenuList/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/MenuPopover/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=MenuPopover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuPopover.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-menu/src/MenuPopover.ts"],"names":[],"mappings":";;;IAAA,uCAA+C","sourcesContent":["export * from './components/MenuPopover/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/MenuSplitGroup/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=MenuSplitGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuSplitGroup.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-menu/src/MenuSplitGroup.ts"],"names":[],"mappings":";;;IAAA,uCAAkD","sourcesContent":["export * from './components/MenuSplitGroup/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/MenuTrigger/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=MenuTrigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuTrigger.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-menu/src/MenuTrigger.ts"],"names":[],"mappings":";;;IAAA,uCAA+C","sourcesContent":["export * from './components/MenuTrigger/index';\n"]}
@@ -0,0 +1,16 @@
1
+ define(["require", "exports", "./useMenu", "./useMenuContextValues", "./renderMenu"], function (require, exports, useMenu_1, useMenuContextValues_1, renderMenu_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Menu = void 0;
5
+ /**
6
+ * Wrapper component that manages state for a popup MenuList and a MenuTrigger
7
+ */
8
+ var Menu = function (props) {
9
+ var state = useMenu_1.useMenu_unstable(props);
10
+ var contextValues = useMenuContextValues_1.useMenuContextValues_unstable(state);
11
+ return renderMenu_1.renderMenu_unstable(state, contextValues);
12
+ };
13
+ exports.Menu = Menu;
14
+ exports.Menu.displayName = 'Menu';
15
+ });
16
+ //# sourceMappingURL=Menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/Menu/Menu.tsx"],"names":[],"mappings":";;;;IAMA;;OAEG;IACI,IAAM,IAAI,GAAwB,UAAA,KAAK;QAC5C,IAAM,KAAK,GAAG,0BAAgB,CAAC,KAAK,CAAC,CAAC;QACtC,IAAM,aAAa,GAAG,oDAA6B,CAAC,KAAK,CAAC,CAAC;QAE3D,OAAO,gCAAmB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IACnD,CAAC,CAAC;IALW,QAAA,IAAI,QAKf;IAEF,YAAI,CAAC,WAAW,GAAG,MAAM,CAAC","sourcesContent":["import * as React from 'react';\nimport { useMenu_unstable } from './useMenu';\nimport { useMenuContextValues_unstable } from './useMenuContextValues';\nimport { renderMenu_unstable } from './renderMenu';\nimport type { MenuProps } from './Menu.types';\n\n/**\n * Wrapper component that manages state for a popup MenuList and a MenuTrigger\n */\nexport const Menu: React.FC<MenuProps> = props => {\n const state = useMenu_unstable(props);\n const contextValues = useMenuContextValues_unstable(state);\n\n return renderMenu_unstable(state, contextValues);\n};\n\nMenu.displayName = 'Menu';\n"]}
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=Menu.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/Menu/Menu.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { PositioningVirtualElement, SetVirtualMouseTarget } from '@fluentui/react-positioning';\nimport type { PositioningShorthand } from '@fluentui/react-positioning';\nimport type { ComponentProps, ComponentState } 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> &\n Pick<\n MenuListProps,\n 'checkedValues' | 'defaultCheckedValues' | 'hasCheckmarks' | 'hasIcons' | 'onCheckedValueChange'\n > & {\n /**\n * Can contain two children including {@link MenuTrigger} and {@link MenuPopover}.\n * Alternatively can only contain {@link MenuPopover} if using a custom `target`.\n */\n children: [JSX.Element, JSX.Element] | JSX.Element;\n\n /**\n * Whether the popup is open by default\n *\n * @default false\n */\n defaultOpen?: boolean;\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 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 * 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<MenuSlots> &\n Pick<MenuProps, 'onOpenChange' | 'defaultCheckedValues'> &\n Required<\n Pick<\n MenuProps,\n | 'hasCheckmarks'\n | 'hasIcons'\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 menuPopoverRef: React.MutableRefObject<HTMLElement>;\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) => 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 triggerRef: React.MutableRefObject<HTMLElement>;\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: '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"]}
@@ -0,0 +1,10 @@
1
+ define(["require", "exports", "tslib", "./Menu", "./Menu.types", "./renderMenu", "./useMenu", "./useMenuContextValues"], function (require, exports, tslib_1, Menu_1, Menu_types_1, renderMenu_1, useMenu_1, useMenuContextValues_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(Menu_1, exports);
5
+ tslib_1.__exportStar(Menu_types_1, exports);
6
+ tslib_1.__exportStar(renderMenu_1, exports);
7
+ tslib_1.__exportStar(useMenu_1, exports);
8
+ tslib_1.__exportStar(useMenuContextValues_1, exports);
9
+ });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/Menu/index.ts"],"names":[],"mappings":";;;IAAA,sCAAuB;IACvB,4CAA6B;IAC7B,4CAA6B;IAC7B,yCAA0B;IAC1B,sDAAuC","sourcesContent":["export * from './Menu';\nexport * from './Menu.types';\nexport * from './renderMenu';\nexport * from './useMenu';\nexport * from './useMenuContextValues';\n"]}
@@ -0,0 +1,15 @@
1
+ define(["require", "exports", "react", "../../contexts/menuContext"], function (require, exports, React, menuContext_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.renderMenu_unstable = void 0;
5
+ /**
6
+ * Render the final JSX of Menu
7
+ */
8
+ var renderMenu_unstable = function (state, contextValues) {
9
+ return (React.createElement(menuContext_1.MenuProvider, { value: contextValues.menu },
10
+ state.menuTrigger,
11
+ state.open && state.menuPopover));
12
+ };
13
+ exports.renderMenu_unstable = renderMenu_unstable;
14
+ });
15
+ //# sourceMappingURL=renderMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderMenu.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/Menu/renderMenu.tsx"],"names":[],"mappings":";;;;IAIA;;OAEG;IACI,IAAM,mBAAmB,GAAG,UAAC,KAAgB,EAAE,aAAgC;QACpF,OAAO,CACL,oBAAC,0BAAY,IAAC,KAAK,EAAE,aAAa,CAAC,IAAI;YACpC,KAAK,CAAC,WAAW;YACjB,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,WAAW,CACnB,CAChB,CAAC;IACJ,CAAC,CAAC;IAPW,QAAA,mBAAmB,uBAO9B","sourcesContent":["import * as React from 'react';\nimport { MenuProvider } from '../../contexts/menuContext';\nimport type { MenuContextValues, MenuState } from './Menu.types';\n\n/**\n * Render the final JSX of Menu\n */\nexport const renderMenu_unstable = (state: MenuState, contextValues: MenuContextValues) => {\n return (\n <MenuProvider value={contextValues.menu}>\n {state.menuTrigger}\n {state.open && state.menuPopover}\n </MenuProvider>\n );\n};\n"]}