@fluentui/react-menu 9.4.1 → 9.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. package/CHANGELOG.json +119 -1
  2. package/CHANGELOG.md +32 -2
  3. package/dist/index.d.ts +102 -14
  4. package/lib/components/Menu/Menu.types.js.map +1 -1
  5. package/lib/components/Menu/useMenu.js +23 -26
  6. package/lib/components/Menu/useMenu.js.map +1 -1
  7. package/lib/components/Menu/useMenuContextValues.js +0 -2
  8. package/lib/components/Menu/useMenuContextValues.js.map +1 -1
  9. package/lib/components/MenuDivider/useMenuDividerStyles.js +2 -2
  10. package/lib/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
  11. package/lib/components/MenuGroup/useMenuGroup.js +1 -1
  12. package/lib/components/MenuGroup/useMenuGroup.js.map +1 -1
  13. package/lib/components/MenuItem/useMenuItem.js +3 -1
  14. package/lib/components/MenuItem/useMenuItem.js.map +1 -1
  15. package/lib/components/MenuList/MenuList.types.js.map +1 -1
  16. package/lib/components/MenuList/useMenuList.js +20 -29
  17. package/lib/components/MenuList/useMenuList.js.map +1 -1
  18. package/lib/components/MenuList/useMenuListContextValues.js +0 -2
  19. package/lib/components/MenuList/useMenuListContextValues.js.map +1 -1
  20. package/lib/components/MenuPopover/useMenuPopover.js +20 -14
  21. package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
  22. package/lib/components/MenuTrigger/useMenuTrigger.js +42 -28
  23. package/lib/components/MenuTrigger/useMenuTrigger.js.map +1 -1
  24. package/lib/contexts/menuContext.js +0 -1
  25. package/lib/contexts/menuContext.js.map +1 -1
  26. package/lib/contexts/menuListContext.js +0 -1
  27. package/lib/contexts/menuListContext.js.map +1 -1
  28. package/lib/index.js.map +1 -1
  29. package/lib-amd/Menu.js +6 -0
  30. package/lib-amd/Menu.js.map +1 -0
  31. package/lib-amd/MenuDivider.js +6 -0
  32. package/lib-amd/MenuDivider.js.map +1 -0
  33. package/lib-amd/MenuGroup.js +6 -0
  34. package/lib-amd/MenuGroup.js.map +1 -0
  35. package/lib-amd/MenuGroupHeader.js +6 -0
  36. package/lib-amd/MenuGroupHeader.js.map +1 -0
  37. package/lib-amd/MenuItem.js +6 -0
  38. package/lib-amd/MenuItem.js.map +1 -0
  39. package/lib-amd/MenuItemCheckbox.js +6 -0
  40. package/lib-amd/MenuItemCheckbox.js.map +1 -0
  41. package/lib-amd/MenuItemRadio.js +6 -0
  42. package/lib-amd/MenuItemRadio.js.map +1 -0
  43. package/lib-amd/MenuList.js +6 -0
  44. package/lib-amd/MenuList.js.map +1 -0
  45. package/lib-amd/MenuPopover.js +6 -0
  46. package/lib-amd/MenuPopover.js.map +1 -0
  47. package/lib-amd/MenuSplitGroup.js +6 -0
  48. package/lib-amd/MenuSplitGroup.js.map +1 -0
  49. package/lib-amd/MenuTrigger.js +6 -0
  50. package/lib-amd/MenuTrigger.js.map +1 -0
  51. package/lib-amd/components/Menu/Menu.js +16 -0
  52. package/lib-amd/components/Menu/Menu.js.map +1 -0
  53. package/lib-amd/components/Menu/Menu.types.js +5 -0
  54. package/lib-amd/components/Menu/Menu.types.js.map +1 -0
  55. package/lib-amd/components/Menu/index.js +10 -0
  56. package/lib-amd/components/Menu/index.js.map +1 -0
  57. package/lib-amd/components/Menu/renderMenu.js +15 -0
  58. package/lib-amd/components/Menu/renderMenu.js.map +1 -0
  59. package/lib-amd/components/Menu/useMenu.js +230 -0
  60. package/lib-amd/components/Menu/useMenu.js.map +1 -0
  61. package/lib-amd/components/Menu/useMenuContextValues.js +28 -0
  62. package/lib-amd/components/Menu/useMenuContextValues.js.map +1 -0
  63. package/lib-amd/components/MenuDivider/MenuDivider.js +15 -0
  64. package/lib-amd/components/MenuDivider/MenuDivider.js.map +1 -0
  65. package/lib-amd/components/MenuDivider/MenuDivider.types.js +5 -0
  66. package/lib-amd/components/MenuDivider/MenuDivider.types.js.map +1 -0
  67. package/lib-amd/components/MenuDivider/index.js +10 -0
  68. package/lib-amd/components/MenuDivider/index.js.map +1 -0
  69. package/lib-amd/components/MenuDivider/renderMenuDivider.js +15 -0
  70. package/lib-amd/components/MenuDivider/renderMenuDivider.js.map +1 -0
  71. package/lib-amd/components/MenuDivider/useMenuDivider.js +18 -0
  72. package/lib-amd/components/MenuDivider/useMenuDivider.js.map +1 -0
  73. package/lib-amd/components/MenuDivider/useMenuDividerStyles.js +18 -0
  74. package/lib-amd/components/MenuDivider/useMenuDividerStyles.js.map +1 -0
  75. package/lib-amd/components/MenuGroup/MenuGroup.js +16 -0
  76. package/lib-amd/components/MenuGroup/MenuGroup.js.map +1 -0
  77. package/lib-amd/components/MenuGroup/MenuGroup.types.js +5 -0
  78. package/lib-amd/components/MenuGroup/MenuGroup.types.js.map +1 -0
  79. package/lib-amd/components/MenuGroup/index.js +11 -0
  80. package/lib-amd/components/MenuGroup/index.js.map +1 -0
  81. package/lib-amd/components/MenuGroup/renderMenuGroup.js +16 -0
  82. package/lib-amd/components/MenuGroup/renderMenuGroup.js.map +1 -0
  83. package/lib-amd/components/MenuGroup/useMenuGroup.js +20 -0
  84. package/lib-amd/components/MenuGroup/useMenuGroup.js.map +1 -0
  85. package/lib-amd/components/MenuGroup/useMenuGroupContextValues.js +12 -0
  86. package/lib-amd/components/MenuGroup/useMenuGroupContextValues.js.map +1 -0
  87. package/lib-amd/components/MenuGroup/useMenuGroupStyles.js +14 -0
  88. package/lib-amd/components/MenuGroup/useMenuGroupStyles.js.map +1 -0
  89. package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.js +15 -0
  90. package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -0
  91. package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.types.js +5 -0
  92. package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.types.js.map +1 -0
  93. package/lib-amd/components/MenuGroupHeader/index.js +10 -0
  94. package/lib-amd/components/MenuGroupHeader/index.js.map +1 -0
  95. package/lib-amd/components/MenuGroupHeader/renderMenuGroupHeader.js +15 -0
  96. package/lib-amd/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -0
  97. package/lib-amd/components/MenuGroupHeader/useMenuGroupHeader.js +19 -0
  98. package/lib-amd/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -0
  99. package/lib-amd/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +27 -0
  100. package/lib-amd/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -0
  101. package/lib-amd/components/MenuItem/MenuItem.js +15 -0
  102. package/lib-amd/components/MenuItem/MenuItem.js.map +1 -0
  103. package/lib-amd/components/MenuItem/MenuItem.types.js +5 -0
  104. package/lib-amd/components/MenuItem/MenuItem.types.js.map +1 -0
  105. package/lib-amd/components/MenuItem/index.js +10 -0
  106. package/lib-amd/components/MenuItem/index.js.map +1 -0
  107. package/lib-amd/components/MenuItem/renderMenuItem.js +19 -0
  108. package/lib-amd/components/MenuItem/renderMenuItem.js.map +1 -0
  109. package/lib-amd/components/MenuItem/useCharacterSearch.js +22 -0
  110. package/lib-amd/components/MenuItem/useCharacterSearch.js.map +1 -0
  111. package/lib-amd/components/MenuItem/useMenuItem.js +80 -0
  112. package/lib-amd/components/MenuItem/useMenuItem.js.map +1 -0
  113. package/lib-amd/components/MenuItem/useMenuItemStyles.js +100 -0
  114. package/lib-amd/components/MenuItem/useMenuItemStyles.js.map +1 -0
  115. package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.js +15 -0
  116. package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -0
  117. package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.types.js +5 -0
  118. package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.types.js.map +1 -0
  119. package/lib-amd/components/MenuItemCheckbox/index.js +10 -0
  120. package/lib-amd/components/MenuItemCheckbox/index.js.map +1 -0
  121. package/lib-amd/components/MenuItemCheckbox/renderMenuItemCheckbox.js +16 -0
  122. package/lib-amd/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -0
  123. package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckbox.js +26 -0
  124. package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -0
  125. package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +31 -0
  126. package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -0
  127. package/lib-amd/components/MenuItemRadio/MenuItemRadio.js +15 -0
  128. package/lib-amd/components/MenuItemRadio/MenuItemRadio.js.map +1 -0
  129. package/lib-amd/components/MenuItemRadio/MenuItemRadio.types.js +5 -0
  130. package/lib-amd/components/MenuItemRadio/MenuItemRadio.types.js.map +1 -0
  131. package/lib-amd/components/MenuItemRadio/index.js +10 -0
  132. package/lib-amd/components/MenuItemRadio/index.js.map +1 -0
  133. package/lib-amd/components/MenuItemRadio/renderMenuItemRadio.js +19 -0
  134. package/lib-amd/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -0
  135. package/lib-amd/components/MenuItemRadio/useMenuItemRadio.js +27 -0
  136. package/lib-amd/components/MenuItemRadio/useMenuItemRadio.js.map +1 -0
  137. package/lib-amd/components/MenuItemRadio/useMenuItemRadioStyles.js +31 -0
  138. package/lib-amd/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -0
  139. package/lib-amd/components/MenuList/MenuList.js +16 -0
  140. package/lib-amd/components/MenuList/MenuList.js.map +1 -0
  141. package/lib-amd/components/MenuList/MenuList.types.js +5 -0
  142. package/lib-amd/components/MenuList/MenuList.types.js.map +1 -0
  143. package/lib-amd/components/MenuList/index.js +11 -0
  144. package/lib-amd/components/MenuList/index.js.map +1 -0
  145. package/lib-amd/components/MenuList/renderMenuList.js +15 -0
  146. package/lib-amd/components/MenuList/renderMenuList.js.map +1 -0
  147. package/lib-amd/components/MenuList/useMenuList.js +124 -0
  148. package/lib-amd/components/MenuList/useMenuList.js.map +1 -0
  149. package/lib-amd/components/MenuList/useMenuListContextValues.js +20 -0
  150. package/lib-amd/components/MenuList/useMenuListContextValues.js.map +1 -0
  151. package/lib-amd/components/MenuList/useMenuListStyles.js +21 -0
  152. package/lib-amd/components/MenuList/useMenuListStyles.js.map +1 -0
  153. package/lib-amd/components/MenuPopover/MenuPopover.js +15 -0
  154. package/lib-amd/components/MenuPopover/MenuPopover.js.map +1 -0
  155. package/lib-amd/components/MenuPopover/MenuPopover.types.js +5 -0
  156. package/lib-amd/components/MenuPopover/MenuPopover.types.js.map +1 -0
  157. package/lib-amd/components/MenuPopover/index.js +10 -0
  158. package/lib-amd/components/MenuPopover/index.js.map +1 -0
  159. package/lib-amd/components/MenuPopover/renderMenuPopover.js +18 -0
  160. package/lib-amd/components/MenuPopover/renderMenuPopover.js.map +1 -0
  161. package/lib-amd/components/MenuPopover/useMenuPopover.js +82 -0
  162. package/lib-amd/components/MenuPopover/useMenuPopover.js.map +1 -0
  163. package/lib-amd/components/MenuPopover/useMenuPopoverStyles.js +21 -0
  164. package/lib-amd/components/MenuPopover/useMenuPopoverStyles.js.map +1 -0
  165. package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.js +15 -0
  166. package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -0
  167. package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.types.js +5 -0
  168. package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.types.js.map +1 -0
  169. package/lib-amd/components/MenuSplitGroup/index.js +10 -0
  170. package/lib-amd/components/MenuSplitGroup/index.js.map +1 -0
  171. package/lib-amd/components/MenuSplitGroup/renderMenuSplitGroup.js +14 -0
  172. package/lib-amd/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -0
  173. package/lib-amd/components/MenuSplitGroup/useMenuSplitGroup.js +47 -0
  174. package/lib-amd/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -0
  175. package/lib-amd/components/MenuSplitGroup/useMenuSplitGroupStyles.js +43 -0
  176. package/lib-amd/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -0
  177. package/lib-amd/components/MenuTrigger/MenuTrigger.js +18 -0
  178. package/lib-amd/components/MenuTrigger/MenuTrigger.js.map +1 -0
  179. package/lib-amd/components/MenuTrigger/MenuTrigger.types.js +5 -0
  180. package/lib-amd/components/MenuTrigger/MenuTrigger.types.js.map +1 -0
  181. package/lib-amd/components/MenuTrigger/index.js +9 -0
  182. package/lib-amd/components/MenuTrigger/index.js.map +1 -0
  183. package/lib-amd/components/MenuTrigger/renderMenuTrigger.js +15 -0
  184. package/lib-amd/components/MenuTrigger/renderMenuTrigger.js.map +1 -0
  185. package/lib-amd/components/MenuTrigger/useMenuTrigger.js +112 -0
  186. package/lib-amd/components/MenuTrigger/useMenuTrigger.js.map +1 -0
  187. package/lib-amd/components/index.js +7 -0
  188. package/lib-amd/components/index.js.map +1 -0
  189. package/lib-amd/contexts/menuContext.js +31 -0
  190. package/lib-amd/contexts/menuContext.js.map +1 -0
  191. package/lib-amd/contexts/menuGroupContext.js +13 -0
  192. package/lib-amd/contexts/menuGroupContext.js.map +1 -0
  193. package/lib-amd/contexts/menuListContext.js +23 -0
  194. package/lib-amd/contexts/menuListContext.js.map +1 -0
  195. package/lib-amd/contexts/menuTriggerContext.js +14 -0
  196. package/lib-amd/contexts/menuTriggerContext.js.map +1 -0
  197. package/lib-amd/index.js +69 -0
  198. package/lib-amd/index.js.map +1 -0
  199. package/lib-amd/selectable/index.js +7 -0
  200. package/lib-amd/selectable/index.js.map +1 -0
  201. package/lib-amd/selectable/types.js +5 -0
  202. package/lib-amd/selectable/types.js.map +1 -0
  203. package/lib-amd/selectable/useCheckmarkStyles.js +28 -0
  204. package/lib-amd/selectable/useCheckmarkStyles.js.map +1 -0
  205. package/lib-amd/utils/index.js +6 -0
  206. package/lib-amd/utils/index.js.map +1 -0
  207. package/lib-amd/utils/useIsSubmenu.js +20 -0
  208. package/lib-amd/utils/useIsSubmenu.js.map +1 -0
  209. package/lib-amd/utils/useOnMenuEnter.js +59 -0
  210. package/lib-amd/utils/useOnMenuEnter.js.map +1 -0
  211. package/lib-commonjs/components/Menu/useMenu.js +23 -26
  212. package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
  213. package/lib-commonjs/components/Menu/useMenuContextValues.js +0 -2
  214. package/lib-commonjs/components/Menu/useMenuContextValues.js.map +1 -1
  215. package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js +2 -2
  216. package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
  217. package/lib-commonjs/components/MenuGroup/useMenuGroup.js +1 -1
  218. package/lib-commonjs/components/MenuGroup/useMenuGroup.js.map +1 -1
  219. package/lib-commonjs/components/MenuItem/useMenuItem.js +3 -1
  220. package/lib-commonjs/components/MenuItem/useMenuItem.js.map +1 -1
  221. package/lib-commonjs/components/MenuList/useMenuList.js +20 -29
  222. package/lib-commonjs/components/MenuList/useMenuList.js.map +1 -1
  223. package/lib-commonjs/components/MenuList/useMenuListContextValues.js +0 -2
  224. package/lib-commonjs/components/MenuList/useMenuListContextValues.js.map +1 -1
  225. package/lib-commonjs/components/MenuPopover/useMenuPopover.js +20 -14
  226. package/lib-commonjs/components/MenuPopover/useMenuPopover.js.map +1 -1
  227. package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js +42 -28
  228. package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js.map +1 -1
  229. package/lib-commonjs/contexts/menuContext.js +0 -1
  230. package/lib-commonjs/contexts/menuContext.js.map +1 -1
  231. package/lib-commonjs/contexts/menuListContext.js +0 -1
  232. package/lib-commonjs/contexts/menuListContext.js.map +1 -1
  233. package/lib-commonjs/index.js.map +1 -1
  234. package/package.json +9 -9
package/CHANGELOG.json CHANGED
@@ -2,7 +2,125 @@
2
2
  "name": "@fluentui/react-menu",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 11 Nov 2022 14:53:55 GMT",
5
+ "date": "Mon, 05 Dec 2022 18:25:22 GMT",
6
+ "tag": "@fluentui/react-menu_v9.5.1",
7
+ "version": "9.5.1",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "bernardo.sunderhus@gmail.com",
12
+ "package": "@fluentui/react-menu",
13
+ "commit": "41b0dbe63181a473ea54811fffd5a9582d7b28b6",
14
+ "comment": "chore: removes prop spreading on MenuList state"
15
+ },
16
+ {
17
+ "author": "lingfangao@hotmail.com",
18
+ "package": "@fluentui/react-menu",
19
+ "commit": "6f036a808e0d09e6395abe1f6d3046d1f7d2c28d",
20
+ "comment": "fix: MenuDivider thickness should be `strokeWidthThin`"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui/react-menu",
25
+ "comment": "Bump @fluentui/react-portal to v9.0.12",
26
+ "commit": "4c29542a51bf068e171690cc8e59c14489883912"
27
+ },
28
+ {
29
+ "author": "beachball",
30
+ "package": "@fluentui/react-menu",
31
+ "comment": "Bump @fluentui/react-positioning to v9.3.3",
32
+ "commit": "4c29542a51bf068e171690cc8e59c14489883912"
33
+ },
34
+ {
35
+ "author": "beachball",
36
+ "package": "@fluentui/react-menu",
37
+ "comment": "Bump @fluentui/react-shared-contexts to v9.1.2",
38
+ "commit": "4c29542a51bf068e171690cc8e59c14489883912"
39
+ },
40
+ {
41
+ "author": "beachball",
42
+ "package": "@fluentui/react-menu",
43
+ "comment": "Bump @fluentui/react-tabster to v9.3.2",
44
+ "commit": "4c29542a51bf068e171690cc8e59c14489883912"
45
+ },
46
+ {
47
+ "author": "beachball",
48
+ "package": "@fluentui/react-menu",
49
+ "comment": "Bump @fluentui/react-theme to v9.1.3",
50
+ "commit": "4c29542a51bf068e171690cc8e59c14489883912"
51
+ }
52
+ ],
53
+ "none": [
54
+ {
55
+ "author": "mgodbolt@microsoft.com",
56
+ "package": "@fluentui/react-menu",
57
+ "commit": "b7bc3cad64eeb09c193b102b9497b1b01464dfeb",
58
+ "comment": "Added a link in the docs to the MenuButton"
59
+ }
60
+ ]
61
+ }
62
+ },
63
+ {
64
+ "date": "Thu, 17 Nov 2022 23:05:41 GMT",
65
+ "tag": "@fluentui/react-menu_v9.5.0",
66
+ "version": "9.5.0",
67
+ "comments": {
68
+ "minor": [
69
+ {
70
+ "author": "bernardo.sunderhus@gmail.com",
71
+ "package": "@fluentui/react-menu",
72
+ "commit": "71139fbfe025c22f9934738ab53d14b5f62e4d66",
73
+ "comment": "feature: menu open change data union types"
74
+ },
75
+ {
76
+ "author": "beachball",
77
+ "package": "@fluentui/react-menu",
78
+ "comment": "Bump @fluentui/react-aria to v9.3.2",
79
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
80
+ },
81
+ {
82
+ "author": "beachball",
83
+ "package": "@fluentui/react-menu",
84
+ "comment": "Bump @fluentui/react-context-selector to v9.1.2",
85
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
86
+ },
87
+ {
88
+ "author": "beachball",
89
+ "package": "@fluentui/react-menu",
90
+ "comment": "Bump @fluentui/react-portal to v9.0.11",
91
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
92
+ },
93
+ {
94
+ "author": "beachball",
95
+ "package": "@fluentui/react-menu",
96
+ "comment": "Bump @fluentui/react-positioning to v9.3.2",
97
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
98
+ },
99
+ {
100
+ "author": "beachball",
101
+ "package": "@fluentui/react-menu",
102
+ "comment": "Bump @fluentui/react-tabster to v9.3.1",
103
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
104
+ },
105
+ {
106
+ "author": "beachball",
107
+ "package": "@fluentui/react-menu",
108
+ "comment": "Bump @fluentui/react-utilities to v9.2.2",
109
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
110
+ }
111
+ ],
112
+ "none": [
113
+ {
114
+ "author": "martinhochel@microsoft.com",
115
+ "package": "@fluentui/react-menu",
116
+ "commit": "ea768501802d65d63ddc63fff3816fb6b5008ae4",
117
+ "comment": "chore: update package scaffold"
118
+ }
119
+ ]
120
+ }
121
+ },
122
+ {
123
+ "date": "Fri, 11 Nov 2022 14:58:08 GMT",
6
124
  "tag": "@fluentui/react-menu_v9.4.1",
7
125
  "version": "9.4.1",
8
126
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,42 @@
1
1
  # Change Log - @fluentui/react-menu
2
2
 
3
- This log was last generated on Fri, 11 Nov 2022 14:53:55 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 05 Dec 2022 18:25:22 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.5.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-menu_v9.5.1)
8
+
9
+ Mon, 05 Dec 2022 18:25:22 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-menu_v9.5.0..@fluentui/react-menu_v9.5.1)
11
+
12
+ ### Patches
13
+
14
+ - chore: removes prop spreading on MenuList state ([PR #25672](https://github.com/microsoft/fluentui/pull/25672) by bernardo.sunderhus@gmail.com)
15
+ - fix: MenuDivider thickness should be `strokeWidthThin` ([PR #25711](https://github.com/microsoft/fluentui/pull/25711) by lingfangao@hotmail.com)
16
+ - Bump @fluentui/react-portal to v9.0.12 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
17
+ - Bump @fluentui/react-positioning to v9.3.3 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
18
+ - Bump @fluentui/react-shared-contexts to v9.1.2 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
19
+ - Bump @fluentui/react-tabster to v9.3.2 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
20
+ - Bump @fluentui/react-theme to v9.1.3 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
21
+
22
+ ## [9.5.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-menu_v9.5.0)
23
+
24
+ Thu, 17 Nov 2022 23:05:41 GMT
25
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-menu_v9.4.1..@fluentui/react-menu_v9.5.0)
26
+
27
+ ### Minor changes
28
+
29
+ - feature: menu open change data union types ([PR #25503](https://github.com/microsoft/fluentui/pull/25503) by bernardo.sunderhus@gmail.com)
30
+ - Bump @fluentui/react-aria to v9.3.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
31
+ - Bump @fluentui/react-context-selector to v9.1.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
32
+ - Bump @fluentui/react-portal to v9.0.11 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
33
+ - Bump @fluentui/react-positioning to v9.3.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
34
+ - Bump @fluentui/react-tabster to v9.3.1 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
35
+ - Bump @fluentui/react-utilities to v9.2.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
36
+
7
37
  ## [9.4.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-menu_v9.4.1)
8
38
 
9
- Fri, 11 Nov 2022 14:53:55 GMT
39
+ Fri, 11 Nov 2022 14:58:08 GMT
10
40
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-menu_v9.4.0..@fluentui/react-menu_v9.4.1)
11
41
 
12
42
  ### Patches
package/dist/index.d.ts CHANGED
@@ -35,9 +35,15 @@ export declare type MenuCheckedValueChangeEvent = React_2.MouseEvent | React_2.K
35
35
  *
36
36
  * Extends and drills down MenuList props to simplify API
37
37
  */
38
- export declare type MenuContextValue = Pick<MenuState, 'openOnHover' | 'openOnContext' | 'triggerRef' | 'menuPopoverRef' | 'setOpen' | 'isSubmenu' | 'triggerId' | 'hasIcons' | 'hasCheckmarks' | 'persistOnItemClick' | 'inline' | 'checkedValues' | 'onCheckedValueChange' | 'defaultCheckedValues'> & {
38
+ export declare type MenuContextValue = Pick<MenuState, 'openOnHover' | 'openOnContext' | 'triggerRef' | 'menuPopoverRef' | 'setOpen' | 'isSubmenu' | 'triggerId' | 'hasIcons' | 'hasCheckmarks' | 'persistOnItemClick' | 'inline' | 'checkedValues' | 'onCheckedValueChange'> & {
39
39
  open: boolean;
40
40
  triggerId: string;
41
+ /**
42
+ * Default values to be checked on mount
43
+ * @deprecated this property is not used internally anymore,
44
+ * the signature remains just to avoid breaking changes
45
+ */
46
+ defaultCheckedValues?: Record<string, string[]>;
41
47
  };
42
48
 
43
49
  export declare type MenuContextValues = {
@@ -221,10 +227,20 @@ export declare const menuListClassNames: SlotClassNames<MenuListSlots>;
221
227
  /**
222
228
  * Context shared between MenuList and its children components
223
229
  */
224
- export declare type MenuListContextValue = Pick<MenuListProps, 'checkedValues' | 'onCheckedValueChange' | 'hasIcons' | 'hasCheckmarks'> & {
230
+ export declare type MenuListContextValue = Pick<MenuListProps, 'checkedValues' | 'hasIcons' | 'hasCheckmarks'> & {
225
231
  setFocusByFirstCharacter?: (e: React_2.KeyboardEvent<HTMLElement>, itemEl: HTMLElement) => void;
226
232
  toggleCheckbox?: SelectableHandler;
227
233
  selectRadio?: SelectableHandler;
234
+ /**
235
+ * Callback when checked items change for value with a name
236
+ *
237
+ * @param event - React's original SyntheticEvent
238
+ * @param data - A data object with relevant information
239
+ *
240
+ * @deprecated this property is not used internally anymore,
241
+ * the signature remains just to avoid breaking changes
242
+ */
243
+ onCheckedValueChange?: (e: MenuCheckedValueChangeEvent, data: MenuCheckedValueChangeData) => void;
228
244
  };
229
245
 
230
246
  export declare type MenuListContextValues = {
@@ -263,7 +279,7 @@ export declare type MenuListSlots = {
263
279
  root: Slot<'div'>;
264
280
  };
265
281
 
266
- export declare type MenuListState = ComponentState<MenuListSlots> & Pick<MenuListProps, 'defaultCheckedValues' | 'onCheckedValueChange'> & Required<Pick<MenuListProps, 'checkedValues' | 'hasCheckmarks' | 'hasIcons'>> & {
282
+ export declare type MenuListState = ComponentState<MenuListSlots> & Required<Pick<MenuListProps, 'checkedValues' | 'hasCheckmarks' | 'hasIcons'>> & {
267
283
  /**
268
284
  * Selects a radio item, will de-select the currently selected ratio item
269
285
  */
@@ -273,6 +289,21 @@ export declare type MenuListState = ComponentState<MenuListSlots> & Pick<MenuLis
273
289
  */
274
290
  setFocusByFirstCharacter: NonNullable<MenuListContextValue['setFocusByFirstCharacter']>;
275
291
  toggleCheckbox: SelectableHandler;
292
+ /**
293
+ * Default values to be checked on mount
294
+ * @deprecated this property is not used internally anymore,
295
+ * the signature remains just to avoid breaking changes
296
+ */
297
+ defaultCheckedValues?: Record<string, string[]>;
298
+ /**
299
+ * Callback when checked items change for value with a name
300
+ *
301
+ * @param event - React's original SyntheticEvent
302
+ * @param data - A data object with relevant information
303
+ * @deprecated this property is not used internally anymore,
304
+ * the signature remains just to avoid breaking changes
305
+ */
306
+ onCheckedValueChange?: (e: MenuCheckedValueChangeEvent, data: MenuCheckedValueChangeData) => void;
276
307
  };
277
308
 
278
309
  /**
@@ -290,12 +321,53 @@ export declare type MenuOpenChangeData = {
290
321
  */
291
322
  keyboard?: boolean;
292
323
  open: boolean;
293
- };
324
+ } & ({
325
+ type: 'menuTriggerContextMenu';
326
+ event: React_2.MouseEvent<HTMLElement>;
327
+ } | {
328
+ type: 'menuTriggerClick';
329
+ event: React_2.MouseEvent<HTMLElement>;
330
+ } | {
331
+ type: 'menuTriggerMouseEnter';
332
+ event: React_2.MouseEvent<HTMLElement>;
333
+ } | {
334
+ type: 'menuTriggerMouseLeave';
335
+ event: React_2.MouseEvent<HTMLElement>;
336
+ } | {
337
+ type: 'menuTriggerMouseMove';
338
+ event: React_2.MouseEvent<HTMLElement>;
339
+ } | {
340
+ type: 'menuTriggerKeyDown';
341
+ event: React_2.KeyboardEvent<HTMLElement>;
342
+ } | {
343
+ type: 'menuItemClick';
344
+ event: React_2.MouseEvent<HTMLElement>;
345
+ } | {
346
+ type: 'menuPopoverMouseEnter';
347
+ event: React_2.MouseEvent<HTMLElement>;
348
+ } | {
349
+ type: 'menuPopoverKeyDown';
350
+ event: React_2.KeyboardEvent<HTMLElement>;
351
+ } | {
352
+ type: 'clickOutside';
353
+ event: MouseEvent | TouchEvent;
354
+ } | {
355
+ type: 'scrollOutside';
356
+ event: MouseEvent | TouchEvent;
357
+ } | {
358
+ type: 'menuMouseEnter';
359
+ event: MouseEvent | TouchEvent;
360
+ });
294
361
 
295
362
  /**
296
363
  * The supported events that will trigger open/close of the menu
297
364
  */
298
- export declare type MenuOpenEvents = MouseEvent | TouchEvent | React_2.FocusEvent<HTMLElement> | React_2.KeyboardEvent<HTMLElement> | React_2.MouseEvent<HTMLElement>;
365
+ export declare type MenuOpenEvent = MenuOpenChangeData['event'];
366
+
367
+ /**
368
+ * @deprecated use MenuOpenEvent instead
369
+ */
370
+ export declare type MenuOpenEvents = MenuOpenEvent;
299
371
 
300
372
  /**
301
373
  * Popover intended to wrap `MenuList` and adds styling and interaction support specific to menus
@@ -333,12 +405,6 @@ export declare type MenuProps = ComponentProps<MenuSlots> & Pick<MenuListProps,
333
405
  * Alternatively can only contain {@link MenuPopover} if using a custom `target`.
334
406
  */
335
407
  children: [JSX.Element, JSX.Element] | JSX.Element;
336
- /**
337
- * Whether the popup is open by default
338
- *
339
- * @default false
340
- */
341
- defaultOpen?: boolean;
342
408
  /**
343
409
  * Sets the delay for mouse open/close for the popover one mouse enter/leave
344
410
  */
@@ -354,13 +420,19 @@ export declare type MenuProps = ComponentProps<MenuSlots> & Pick<MenuListProps,
354
420
  * Call back when the component requests to change value
355
421
  * The `open` value is used as a hint when directly controlling the component
356
422
  */
357
- onOpenChange?: (e: MenuOpenEvents, data: MenuOpenChangeData) => void;
423
+ onOpenChange?: (e: MenuOpenEvent, data: MenuOpenChangeData) => void;
358
424
  /**
359
425
  * Whether the popup is open
360
426
  *
361
427
  * @default false
362
428
  */
363
429
  open?: boolean;
430
+ /**
431
+ * Whether the popup is open by default
432
+ *
433
+ * @default false
434
+ */
435
+ defaultOpen?: boolean;
364
436
  /**
365
437
  * Opens the menu on right click (context menu), removes all other menu open interactions
366
438
  *
@@ -416,7 +488,7 @@ export declare type MenuSplitGroupSlots = {
416
488
  */
417
489
  export declare type MenuSplitGroupState = ComponentState<MenuSplitGroupSlots>;
418
490
 
419
- export declare type MenuState = ComponentState<MenuSlots> & Pick<MenuProps, 'onOpenChange' | 'defaultCheckedValues'> & Required<Pick<MenuProps, 'hasCheckmarks' | 'hasIcons' | 'inline' | 'checkedValues' | 'onCheckedValueChange' | 'open' | 'openOnHover' | 'closeOnScroll' | 'hoverDelay' | 'openOnContext' | 'persistOnItemClick'>> & {
491
+ export declare type MenuState = ComponentState<MenuSlots> & Required<Pick<MenuProps, 'hasCheckmarks' | 'hasIcons' | 'inline' | 'checkedValues' | 'onCheckedValueChange' | 'open' | 'openOnHover' | 'closeOnScroll' | 'hoverDelay' | 'openOnContext' | 'persistOnItemClick'>> & {
420
492
  /**
421
493
  * Anchors the popper to the mouse click for context events
422
494
  */
@@ -444,7 +516,7 @@ export declare type MenuState = ComponentState<MenuSlots> & Pick<MenuProps, 'onO
444
516
  /**
445
517
  * Callback to open/close the popup
446
518
  */
447
- setOpen: (e: MenuOpenEvents, data: MenuOpenChangeData) => void;
519
+ setOpen: (e: MenuOpenEvent, data: MenuOpenChangeData) => void;
448
520
  /**
449
521
  * Id for the MenuTrigger element for aria relationship
450
522
  */
@@ -453,6 +525,19 @@ export declare type MenuState = ComponentState<MenuSlots> & Pick<MenuProps, 'onO
453
525
  * The ref for the MenuTrigger, used for popup positioning
454
526
  */
455
527
  triggerRef: React_2.MutableRefObject<HTMLElement>;
528
+ /**
529
+ * Call back when the component requests to change value
530
+ * The `open` value is used as a hint when directly controlling the component
531
+ * @deprecated this property is not used internally anymore,
532
+ * the signature remains just to avoid breaking changes
533
+ */
534
+ onOpenChange?: (e: MenuOpenEvent, data: MenuOpenChangeData) => void;
535
+ /**
536
+ * Default values to be checked on mount
537
+ @deprecated this property is not used internally anymore,
538
+ * the signature remains just to avoid breaking changes
539
+ */
540
+ defaultCheckedValues?: Record<string, string[]>;
456
541
  };
457
542
 
458
543
  /**
@@ -551,6 +636,9 @@ export declare const renderMenuTrigger_unstable: (state: MenuTriggerState) => JS
551
636
 
552
637
  export declare type SelectableHandler = (e: React_2.MouseEvent | React_2.KeyboardEvent, name: string, value: string, checked: boolean) => void;
553
638
 
639
+ /**
640
+ * @deprecated this type is not being used internally anymore
641
+ */
554
642
  export declare type UninitializedMenuListState = Omit<MenuListState, 'checkedValues' | 'selectRadio' | 'setFocusByFirstCharacter' | 'toggleCheckbox'> & Partial<Pick<MenuListState, 'checkedValues'>>;
555
643
 
556
644
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.types.js","sourceRoot":"../src/","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: MenuOpenEvents, 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: MenuOpenEvents, 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\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\nexport type MenuContextValues = {\n menu: MenuContextValue;\n};\n\n/**\n * The supported events that will trigger open/close of the menu\n */\nexport type MenuOpenEvents =\n | MouseEvent\n | TouchEvent\n | React.FocusEvent<HTMLElement>\n | React.KeyboardEvent<HTMLElement>\n | React.MouseEvent<HTMLElement>;\n"]}
1
+ {"version":3,"file":"Menu.types.js","sourceRoot":"../src/","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 * 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 * 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<MenuSlots> &\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 /**\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\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"]}
@@ -104,7 +104,6 @@ export const useMenu_unstable = props => {
104
104
  open,
105
105
  setOpen,
106
106
  checkedValues,
107
- defaultCheckedValues,
108
107
  onCheckedValueChange,
109
108
  persistOnItemClick
110
109
  };
@@ -114,33 +113,25 @@ export const useMenu_unstable = props => {
114
113
  * i.e checkboxes and radios
115
114
  */
116
115
 
117
- const useMenuSelectableState = state => {
116
+ const useMenuSelectableState = props => {
118
117
  const [checkedValues, setCheckedValues] = useControllableState({
119
- state: state.checkedValues,
120
- defaultState: state.defaultCheckedValues,
118
+ state: props.checkedValues,
119
+ defaultState: props.defaultCheckedValues,
121
120
  initialState: {}
122
121
  });
123
- const {
124
- onCheckedValueChange: onCheckedValueChangeOriginal
125
- } = state;
126
122
  const onCheckedValueChange = useEventCallback((e, {
127
123
  name,
128
124
  checkedItems
129
125
  }) => {
130
- if (onCheckedValueChangeOriginal) {
131
- onCheckedValueChangeOriginal(e, {
132
- name,
133
- checkedItems
134
- });
135
- }
126
+ var _a;
136
127
 
137
- setCheckedValues(s => {
138
- return s ? { ...s,
139
- [name]: checkedItems
140
- } : {
141
- [name]: checkedItems
142
- };
128
+ (_a = props.onCheckedValueChange) === null || _a === void 0 ? void 0 : _a.call(props, e, {
129
+ name,
130
+ checkedItems
143
131
  });
132
+ setCheckedValues(currentValue => ({ ...currentValue,
133
+ [name]: checkedItems
134
+ }));
144
135
  });
145
136
  return [checkedValues, onCheckedValueChange];
146
137
  };
@@ -221,8 +212,10 @@ const useMenuOpenState = state => {
221
212
  disabled: !open,
222
213
  element: targetDocument,
223
214
  refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(Boolean),
224
- callback: e => setOpen(e, {
225
- open: false
215
+ callback: event => setOpen(event, {
216
+ open: false,
217
+ type: 'clickOutside',
218
+ event
226
219
  })
227
220
  }); // only close on scroll for context, or when closeOnScroll is specified
228
221
 
@@ -230,20 +223,24 @@ const useMenuOpenState = state => {
230
223
  useOnScrollOutside({
231
224
  contains: elementContains,
232
225
  element: targetDocument,
233
- callback: ev => setOpen(ev, {
234
- open: false
226
+ callback: event => setOpen(event, {
227
+ open: false,
228
+ type: 'scrollOutside',
229
+ event
235
230
  }),
236
231
  refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(Boolean),
237
232
  disabled: !open || !closeOnScroll
238
233
  });
239
234
  useOnMenuMouseEnter({
240
235
  element: targetDocument,
241
- callback: e => {
236
+ callback: event => {
242
237
  // When moving from a menu directly back to its trigger, this handler can close the menu
243
238
  // Explicitly check a flag to see if this situation happens
244
239
  if (!enteringTriggerRef.current) {
245
- setOpen(e, {
246
- open: false
240
+ setOpen(event, {
241
+ open: false,
242
+ type: 'menuMouseEnter',
243
+ event
247
244
  });
248
245
  }
249
246
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-menu/src/components/Menu/useMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,yBAAT,EAAoC,cAApC,EAAoD,2BAApD,QAAuF,6BAAvF;AACA,SACE,oBADF,EAEE,KAFF,EAGE,iBAHF,EAIE,gBAJF,EAKE,kBALF,QAMO,2BANP;AAOA,SAAS,kBAAkB,IAAI,SAA/B,QAAgD,iCAAhD;AACA,SAAS,eAAT,QAAgC,wBAAhC;AACA,SAAS,eAAT,QAAgC,yBAAhC;AACA,SAAS,uBAAT,QAAwC,4BAAxC;AACA,SAAS,gBAAT,EAA2B,mBAA3B,QAAsD,mBAAtD;AACA,SAAS,YAAT,QAA6B,0BAA7B;AAEA,SAAS,GAAT,QAAoB,yBAApB;AAEA;;;;;;;AAOG;;AACH,OAAO,MAAM,gBAAgB,GAAI,KAAD,IAAgC;EAC9D,MAAM,SAAS,GAAG,YAAY,EAA9B;EACA,MAAM;IACJ,UAAU,GAAG,GADT;IAEJ,MAAM,GAAG,KAFL;IAGJ,aAAa,GAAG,KAHZ;IAIJ,QAAQ,GAAG,KAJP;IAKJ,aAAa,GAAG,KALZ;IAMJ,aAAa,GAAG,KANZ;IAOJ,kBAAkB,GAAG,KAPjB;IAQJ,WAAW,GAAG,SARV;IASJ;EATI,IAUF,KAVJ;EAWA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAD,CAAvB;EACA,MAAM,CAAC,aAAD,EAAgB,gBAAhB,IAAoC,yBAAyB,E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IACpD,MAAM,aAAa,GAAG,iBAAiB,CAAC,KAAK,CAAC,UAAN,CAAiB,OAAlB,CAAvC;IACA,aAAa,KAAA,IAAb,IAAA,aAAa,KAAA,KAAA,CAAb,GAAa,KAAA,CAAb,GAAA,aAAa,CAAE,KAAf,EAAA;EACD,CAH8B,EAG5B,CAAC,iBAAD,EAAoB,KAAK,CAAC,UAA1B,CAH4B,CAA/B;EAKA,KAAK,CAAC,SAAN,CAAgB,MAAK;;;IACnB,IAAI,IAAJ,EAAU;MACR,UAAU;IACX,CAFD,MAEO;MACL,IAAI,oBAAoB,CAAC,OAAzB,EAAkC;QAChC,IAAI,kBAAkB,CAAC,OAAnB,IAA8B,CAAC,KAAK,CAAC,SAAzC,EAAoD;UAClD,eAAe,CAAC,OAAhB,GAA0B,sBAAsB,EAAhD,GAAqD,qBAAqB,EAA1E;QACD,CAFD,MAEO;UACL,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,CAAiB,OAAjB,MAAwB,IAAxB,IAAwB,EAAA,KAAA,KAAA,CAAxB,GAAwB,KAAA,CAAxB,GAAwB,EAAA,CAAE,KAAF,EAAxB;QACD;MACF;IACF;;IAED,oBAAoB,CAAC,OAArB,GAA+B,KAA/B;IACA,kBAAkB,CAAC,OAAnB,GAA6B,KAA7B;IACA,eAAe,CAAC,OAAhB,GAA0B,KAA1B;EACD,CAhBD,EAgBG,CAAC,KAAK,CAAC,UAAP,EAAmB,KAAK,CAAC,SAAzB,EAAoC,IAApC,EAA0C,UAA1C,EAAsD,qBAAtD,EAA6E,sBAA7E,CAhBH;EAkBA,OAAO,CAAC,IAAD,EAAO,OAAP,CAAP;AACD,CA5JD","sourcesContent":["import * as React from 'react';\nimport { usePositioningMouseTarget, usePositioning, resolvePositioningShorthand } from '@fluentui/react-positioning';\nimport {\n useControllableState,\n useId,\n useOnClickOutside,\n useEventCallback,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { MENU_ENTER_EVENT, useOnMenuMouseEnter } from '../../utils/index';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\nimport type { MenuOpenChangeData, MenuOpenEvents, MenuProps, MenuState } from './Menu.types';\nimport { Tab } from '@fluentui/keyboard-keys';\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): 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 } = props;\n const triggerId = useId('menu');\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n\n const positioningState = {\n position: isSubmenu ? ('after' as const) : ('below' as const),\n align: isSubmenu ? ('top' as const) : ('start' as const),\n target: props.openOnContext ? contextTarget : undefined,\n ...resolvePositioningShorthand(props.positioning),\n };\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 const { targetRef: triggerRef, containerRef: menuPopoverRef } = usePositioning(positioningState);\n\n // TODO Better way to narrow types ?\n\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 triggerRef,\n menuPopoverRef,\n components: {},\n openOnContext,\n open,\n setOpen,\n checkedValues,\n defaultCheckedValues,\n onCheckedValueChange,\n persistOnItemClick,\n };\n};\n\n/**\n * Adds appropriate state values and handlers for selectable items\n * i.e checkboxes and radios\n */\nconst useMenuSelectableState = (\n state: Pick<MenuProps, 'checkedValues' | 'defaultCheckedValues' | 'onCheckedValueChange'>,\n) => {\n const [checkedValues, setCheckedValues] = useControllableState({\n state: state.checkedValues,\n defaultState: state.defaultCheckedValues,\n initialState: {},\n });\n const { onCheckedValueChange: onCheckedValueChangeOriginal } = state;\n const onCheckedValueChange: MenuState['onCheckedValueChange'] = useEventCallback((e, { name, checkedItems }) => {\n if (onCheckedValueChangeOriginal) {\n onCheckedValueChangeOriginal(e, { name, checkedItems });\n }\n\n setCheckedValues(s => {\n return s ? { ...s, [name]: checkedItems } : { [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 | 'onOpenChange'\n | 'setContextTarget'\n | 'triggerRef'\n | 'openOnContext'\n | 'closeOnScroll'\n | 'hoverDelay'\n > &\n Pick<MenuProps, 'open' | 'defaultOpen'>,\n) => {\n const { targetDocument } = useFluent();\n const parentSetOpen = useMenuContext_unstable(context => context.setOpen);\n const onOpenChange: MenuState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const shouldHandleCloseRef = React.useRef(false);\n const shouldHandleTabRef = React.useRef(false);\n const pressedShiftRef = React.useRef(false);\n const setOpenTimeout = React.useRef(0);\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: MenuOpenEvents, 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 shouldHandleCloseRef.current = true;\n }\n\n if (e.type === 'keydown') {\n if ((e as React.KeyboardEvent<HTMLElement>).key === Tab) {\n shouldHandleTabRef.current = true;\n pressedShiftRef.current = (e as React.KeyboardEvent<HTMLElement>).shiftKey;\n }\n }\n\n if (data.bubble) {\n parentSetOpen(e, { ...data });\n }\n\n setOpenState(data.open);\n });\n\n const setOpen = useEventCallback((e: MenuOpenEvents, data: MenuOpenChangeData) => {\n clearTimeout(setOpenTimeout.current);\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n if (e.type === 'mouseleave' || e.type === 'mouseenter' || e.type === 'mousemove' || e.type === MENU_ENTER_EVENT) {\n if (state.triggerRef.current?.contains(e.target as HTMLElement)) {\n enteringTriggerRef.current = e.type === 'mouseenter' || e.type === 'mousemove';\n }\n\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeout.current = setTimeout(() => 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 ) as React.MutableRefObject<HTMLElement>[],\n callback: e => setOpen(e, { open: false }),\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: ev => setOpen(ev, { open: false }),\n refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(\n Boolean,\n ) as React.MutableRefObject<HTMLElement>[],\n disabled: !open || !closeOnScroll,\n });\n\n useOnMenuMouseEnter({\n element: targetDocument,\n callback: e => {\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(e, { open: false });\n }\n },\n disabled: !open,\n refs: [state.menuPopoverRef],\n });\n\n // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeout.current);\n };\n }, []);\n\n // Manage focus for open state\n const { findFirstFocusable, findNextFocusable, findPrevFocusable } = useFocusFinders();\n const focusFirst = React.useCallback(() => {\n const firstFocusable = findFirstFocusable(state.menuPopoverRef.current);\n firstFocusable?.focus();\n }, [findFirstFocusable, state.menuPopoverRef]);\n\n const focusAfterMenuTrigger = React.useCallback(() => {\n const nextFocusable = findNextFocusable(state.triggerRef.current);\n nextFocusable?.focus();\n }, [findNextFocusable, state.triggerRef]);\n\n const focusBeforeMenuTrigger = React.useCallback(() => {\n const prevFocusable = findPrevFocusable(state.triggerRef.current);\n prevFocusable?.focus();\n }, [findPrevFocusable, state.triggerRef]);\n\n React.useEffect(() => {\n if (open) {\n focusFirst();\n } else {\n if (shouldHandleCloseRef.current) {\n if (shouldHandleTabRef.current && !state.isSubmenu) {\n pressedShiftRef.current ? focusBeforeMenuTrigger() : focusAfterMenuTrigger();\n } else {\n state.triggerRef.current?.focus();\n }\n }\n }\n\n shouldHandleCloseRef.current = false;\n shouldHandleTabRef.current = false;\n pressedShiftRef.current = false;\n }, [state.triggerRef, state.isSubmenu, open, focusFirst, focusAfterMenuTrigger, focusBeforeMenuTrigger]);\n\n return [open, setOpen] as const;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-menu/src/components/Menu/useMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,yBAAT,EAAoC,cAApC,EAAoD,2BAApD,QAAuF,6BAAvF;AACA,SACE,oBADF,EAEE,KAFF,EAGE,iBAHF,EAIE,gBAJF,EAKE,kBALF,QAMO,2BANP;AAOA,SAAS,kBAAkB,IAAI,SAA/B,QAAgD,iCAAhD;AACA,SAAS,eAAT,QAAgC,wBAAhC;AACA,SAAS,eAAT,QAAgC,yBAAhC;AACA,SAAS,uBAAT,QAAwC,4BAAxC;AACA,SAAS,gBAAT,EAA2B,mBAA3B,QAAsD,mBAAtD;AACA,SAAS,YAAT,QAA6B,0BAA7B;AAEA,SAAS,GAAT,QAAoB,yBAApB;AAEA;;;;;;;AAOG;;AACH,OAAO,MAAM,gBAAgB,GAAI,KAAD,IAAgC;EAC9D,MAAM,SAAS,GAAG,YAAY,EAA9B;EACA,MAAM;IACJ,UAAU,GAAG,GADT;IAEJ,MAAM,GAAG,KAFL;IAGJ,aAAa,GAAG,KAHZ;IAIJ,QAAQ,GAAG,KAJP;IAKJ,aAAa,GAAG,KALZ;IAMJ,aAAa,GAAG,KANZ;IAOJ,kBAAkB,GAAG,KAPjB;IAQJ,WAAW,GAAG,SARV;IASJ;EATI,IAUF,KAVJ;EAWA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAD,CAAvB;EACA,MAAM,CAAC,aAAD,EAAgB,gBAAhB,IAAoC,yBAAyB,EAAnE;EAEA,MAAM,gBAAgB,GAAG;IACvB,QAAQ,EAAE,SAAS,GAAG,OAAH,GAAa,OADT;IAEvB,KAAK,EAAE,SAAS,GAAG,KAAH,GAAW,OAFJ;IAGvB,MAAM,EAAE,KAAK,CAAC,aAAN,GAAsB,aAAtB,GAAsC,SAHvB;IAIvB,GAAG,2BAA2B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CAAb,GAAA,aAAa,CAAE,KAAf,EAAA;EACD,CAH8B,EAG5B,CAAC,iBAAD,EAAoB,KAAK,CAAC,UAA1B,CAH4B,CAA/B;EAKA,KAAK,CAAC,SAAN,CAAgB,MAAK;;;IACnB,IAAI,IAAJ,EAAU;MACR,UAAU;IACX,CAFD,MAEO;MACL,IAAI,oBAAoB,CAAC,OAAzB,EAAkC;QAChC,IAAI,kBAAkB,CAAC,OAAnB,IAA8B,CAAC,KAAK,CAAC,SAAzC,EAAoD;UAClD,eAAe,CAAC,OAAhB,GAA0B,sBAAsB,EAAhD,GAAqD,qBAAqB,EAA1E;QACD,CAFD,MAEO;UACL,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,CAAiB,OAAjB,MAAwB,IAAxB,IAAwB,EAAA,KAAA,KAAA,CAAxB,GAAwB,KAAA,CAAxB,GAAwB,EAAA,CAAE,KAAF,EAAxB;QACD;MACF;IACF;;IAED,oBAAoB,CAAC,OAArB,GAA+B,KAA/B;IACA,kBAAkB,CAAC,OAAnB,GAA6B,KAA7B;IACA,eAAe,CAAC,OAAhB,GAA0B,KAA1B;EACD,CAhBD,EAgBG,CAAC,KAAK,CAAC,UAAP,EAAmB,KAAK,CAAC,SAAzB,EAAoC,IAApC,EAA0C,UAA1C,EAAsD,qBAAtD,EAA6E,sBAA7E,CAhBH;EAkBA,OAAO,CAAC,IAAD,EAAO,OAAP,CAAP;AACD,CA3JD","sourcesContent":["import * as React from 'react';\nimport { usePositioningMouseTarget, usePositioning, resolvePositioningShorthand } from '@fluentui/react-positioning';\nimport {\n useControllableState,\n useId,\n useOnClickOutside,\n useEventCallback,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { MENU_ENTER_EVENT, useOnMenuMouseEnter } from '../../utils/index';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\nimport type { MenuOpenChangeData, MenuOpenEvent, MenuProps, MenuState } from './Menu.types';\nimport { Tab } from '@fluentui/keyboard-keys';\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): 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 } = props;\n const triggerId = useId('menu');\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n\n const positioningState = {\n position: isSubmenu ? 'after' : 'below',\n align: isSubmenu ? 'top' : 'start',\n target: props.openOnContext ? contextTarget : 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: triggerRef, containerRef: menuPopoverRef } = usePositioning(positioningState);\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 triggerRef,\n menuPopoverRef,\n components: {},\n openOnContext,\n open,\n setOpen,\n checkedValues,\n onCheckedValueChange,\n persistOnItemClick,\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 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 shouldHandleCloseRef = React.useRef(false);\n const shouldHandleTabRef = React.useRef(false);\n const pressedShiftRef = React.useRef(false);\n const setOpenTimeout = React.useRef(0);\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 shouldHandleCloseRef.current = true;\n }\n\n if (e.type === 'keydown') {\n if ((e as React.KeyboardEvent<HTMLElement>).key === Tab) {\n shouldHandleTabRef.current = true;\n pressedShiftRef.current = (e as React.KeyboardEvent<HTMLElement>).shiftKey;\n }\n }\n\n if (data.bubble) {\n parentSetOpen(e, { ...data });\n }\n\n setOpenState(data.open);\n });\n\n const setOpen = useEventCallback((e: MenuOpenEvent, data: MenuOpenChangeData) => {\n clearTimeout(setOpenTimeout.current);\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n if (e.type === 'mouseleave' || e.type === 'mouseenter' || e.type === 'mousemove' || e.type === MENU_ENTER_EVENT) {\n if (state.triggerRef.current?.contains(e.target as HTMLElement)) {\n enteringTriggerRef.current = e.type === 'mouseenter' || e.type === 'mousemove';\n }\n\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeout.current = setTimeout(() => 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 ) as React.MutableRefObject<HTMLElement>[],\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 ) as React.MutableRefObject<HTMLElement>[],\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 // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeout.current);\n };\n }, []);\n\n // Manage focus for open state\n const { findFirstFocusable, findNextFocusable, findPrevFocusable } = useFocusFinders();\n const focusFirst = React.useCallback(() => {\n const firstFocusable = findFirstFocusable(state.menuPopoverRef.current);\n firstFocusable?.focus();\n }, [findFirstFocusable, state.menuPopoverRef]);\n\n const focusAfterMenuTrigger = React.useCallback(() => {\n const nextFocusable = findNextFocusable(state.triggerRef.current);\n nextFocusable?.focus();\n }, [findNextFocusable, state.triggerRef]);\n\n const focusBeforeMenuTrigger = React.useCallback(() => {\n const prevFocusable = findPrevFocusable(state.triggerRef.current);\n prevFocusable?.focus();\n }, [findPrevFocusable, state.triggerRef]);\n\n React.useEffect(() => {\n if (open) {\n focusFirst();\n } else {\n if (shouldHandleCloseRef.current) {\n if (shouldHandleTabRef.current && !state.isSubmenu) {\n pressedShiftRef.current ? focusBeforeMenuTrigger() : focusAfterMenuTrigger();\n } else {\n state.triggerRef.current?.focus();\n }\n }\n }\n\n shouldHandleCloseRef.current = false;\n shouldHandleTabRef.current = false;\n pressedShiftRef.current = false;\n }, [state.triggerRef, state.isSubmenu, open, focusFirst, focusAfterMenuTrigger, focusBeforeMenuTrigger]);\n\n return [open, setOpen] as const;\n};\n"],"sourceRoot":"../src/"}
@@ -1,7 +1,6 @@
1
1
  export function useMenuContextValues_unstable(state) {
2
2
  const {
3
3
  checkedValues,
4
- defaultCheckedValues,
5
4
  hasCheckmarks,
6
5
  hasIcons,
7
6
  inline,
@@ -19,7 +18,6 @@ export function useMenuContextValues_unstable(state) {
19
18
 
20
19
  const menu = {
21
20
  checkedValues,
22
- defaultCheckedValues,
23
21
  hasCheckmarks,
24
22
  hasIcons,
25
23
  inline,
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-menu/src/components/Menu/useMenuContextValues.ts"],"names":[],"mappings":"AAEA,OAAM,SAAU,6BAAV,CAAwC,KAAxC,EAAwD;EAC5D,MAAM;IACJ,aADI;IAEJ,oBAFI;IAGJ,aAHI;IAIJ,QAJI;IAKJ,MALI;IAMJ,SANI;IAOJ,cAPI;IAQJ,oBARI;IASJ,IATI;IAUJ,aAVI;IAWJ,WAXI;IAYJ,kBAZI;IAaJ,OAbI;IAcJ,SAdI;IAeJ;EAfI,IAgBF,KAhBJ,CAD4D,CAmB5D;;EACA,MAAM,IAAI,GAAG;IACX,aADW;IAEX,oBAFW;IAGX,aAHW;IAIX,QAJW;IAKX,MALW;IAMX,SANW;IAOX,cAPW;IAQX,oBARW;IASX,IATW;IAUX,aAVW;IAWX,WAXW;IAYX,kBAZW;IAaX,OAbW;IAcX,SAdW;IAeX;EAfW,CAAb;EAkBA,OAAO;IAAE;EAAF,CAAP;AACD","sourcesContent":["import type { MenuContextValues, MenuState } from './Menu.types';\n\nexport function useMenuContextValues_unstable(state: MenuState): MenuContextValues {\n const {\n checkedValues,\n defaultCheckedValues,\n hasCheckmarks,\n hasIcons,\n inline,\n isSubmenu,\n menuPopoverRef,\n onCheckedValueChange,\n open,\n openOnContext,\n openOnHover,\n persistOnItemClick,\n setOpen,\n triggerId,\n triggerRef,\n } = state;\n\n // This context is created with \"@fluentui/react-context-selector\", these is no sense to memoize it\n const menu = {\n checkedValues,\n defaultCheckedValues,\n hasCheckmarks,\n hasIcons,\n inline,\n isSubmenu,\n menuPopoverRef,\n onCheckedValueChange,\n open,\n openOnContext,\n openOnHover,\n persistOnItemClick,\n setOpen,\n triggerId,\n triggerRef,\n };\n\n return { menu };\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-menu/src/components/Menu/useMenuContextValues.ts"],"names":[],"mappings":"AAEA,OAAM,SAAU,6BAAV,CAAwC,KAAxC,EAAwD;EAC5D,MAAM;IACJ,aADI;IAEJ,aAFI;IAGJ,QAHI;IAIJ,MAJI;IAKJ,SALI;IAMJ,cANI;IAOJ,oBAPI;IAQJ,IARI;IASJ,aATI;IAUJ,WAVI;IAWJ,kBAXI;IAYJ,OAZI;IAaJ,SAbI;IAcJ;EAdI,IAeF,KAfJ,CAD4D,CAkB5D;;EACA,MAAM,IAAI,GAAG;IACX,aADW;IAEX,aAFW;IAGX,QAHW;IAIX,MAJW;IAKX,SALW;IAMX,cANW;IAOX,oBAPW;IAQX,IARW;IASX,aATW;IAUX,WAVW;IAWX,kBAXW;IAYX,OAZW;IAaX,SAbW;IAcX;EAdW,CAAb;EAiBA,OAAO;IAAE;EAAF,CAAP;AACD","sourcesContent":["import type { MenuContextValues, MenuState } from './Menu.types';\n\nexport function useMenuContextValues_unstable(state: MenuState): MenuContextValues {\n const {\n checkedValues,\n hasCheckmarks,\n hasIcons,\n inline,\n isSubmenu,\n menuPopoverRef,\n onCheckedValueChange,\n open,\n openOnContext,\n openOnHover,\n persistOnItemClick,\n setOpen,\n triggerId,\n triggerRef,\n } = state;\n\n // This context is created with \"@fluentui/react-context-selector\", these is no sense to memoize it\n const menu = {\n checkedValues,\n hasCheckmarks,\n hasIcons,\n inline,\n isSubmenu,\n menuPopoverRef,\n onCheckedValueChange,\n open,\n openOnContext,\n openOnHover,\n persistOnItemClick,\n setOpen,\n triggerId,\n triggerRef,\n };\n\n return { menu };\n}\n"],"sourceRoot":"../src/"}
@@ -11,12 +11,12 @@ const useStyles = /*#__PURE__*/__styles({
11
11
  "jrapky": "fd1gkq",
12
12
  "Frg6f3": ["f1q7jvqi", "f1rnx978"],
13
13
  "a9b677": "f14z66ap",
14
- "Bn0qgzm": "f1f09k3d",
14
+ "Bn0qgzm": "f1vxd6vx",
15
15
  "oivjwe": "fg706s2",
16
16
  "B9xav0g": "frpde29"
17
17
  }
18
18
  }, {
19
- "d": [".fvjh0tl{margin-top:4px;}", ".f1rnx978{margin-right:-5px;}", ".f1q7jvqi{margin-left:-5px;}", ".fd1gkq{margin-bottom:4px;}", ".f14z66ap{width:auto;}", ".f1f09k3d{border-bottom-width:1px;}", ".fg706s2{border-bottom-style:solid;}", ".frpde29{border-bottom-color:var(--colorNeutralStroke2);}"]
19
+ "d": [".fvjh0tl{margin-top:4px;}", ".f1rnx978{margin-right:-5px;}", ".f1q7jvqi{margin-left:-5px;}", ".fd1gkq{margin-bottom:4px;}", ".f14z66ap{width:auto;}", ".f1vxd6vx{border-bottom-width:var(--strokeWidthThin);}", ".fg706s2{border-bottom-style:solid;}", ".frpde29{border-bottom-color:var(--colorNeutralStroke2);}"]
20
20
  });
21
21
 
22
22
  export const useMenuDividerStyles_unstable = state => {